Chapter Seven -- Writing Hardware Algorithm |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Developers may define their own algorithms and securely store them inside Rockey4ND. The dongle may then be used to calculate a result, and the result used by the application. Since the Rockey4ND’s User Algorithm Zone (UAZ) is unreadable, even by the manufacturer, this type of software protection is potentially very powerful. Developers may use either the Rockey4ND editor or the RY_WRITE_ARITHMETIC function to write algorithms to the dongle. 1.Rockey4ND User Defined Algorithm Introduction 1.1) Instruction Format All instructions must be of the form: reg1 = reg2 op reg3/value reg1, reg2 and reg3 are registers, value is a figure, op is an operator. For example: A = A + B Rockey4ND supports the following operations:
value, it only is a decimal figure between 0 and 63. Note: “?” operator is for comparison, for example, C = A ? B, the results are listed below:
It will write either “0xFFFF” or “0” to parameter C according to the table above. First let us have a look at the algorithm example we will write to Rockey4ND: A= A+B, B = B + E, C = A * F, D = B + C, H = H ^ H A, B, C… are registers in Rockey4ND. There are a total of eight 16-bit registers in Rockey4ND and they are designed: A, B, C, D, E, F, G and H. 1.2)Internal Algorithms & Application Interface FEITIAN offers 3 calculation functions to call the user-defined algorithms: RY_CALCULATE1, RY_CALCULATE2, RY_CALCULATE3 These three functions are structurally similar. Data is passed and received by way of the memory addresses p1, p2, p3, and p4. When passing data to registers: Register A = p1 Register variables vary according to the calculation type: Register E When receiving data from registers: p1 = Register A Register A, B, C and D are user interface variables, register E, F, G and H are internal variables. 1.3)Differences between the Three Functions p1, p2, p3 and p4 correspond to registers A, B, C and D in all three calculation functions. These registers are used nearly identically by the three calculation functions. The differences between the functions can be seen by reviewing the results written to registers E, F, G and H. When a developer’s Rockey4ND internal program is called, registers A, B, C and D will be populated with data from p1, p2, p3 and p4. The content of registers E, F, G and H will be initialized according to the calculation function in use. See below:
1.4)API Interface of the User’s Applications Below is the definition and description of the three calculation functions.
2.Writing User Defined Algorithms into Rockey4ND 2.1)Writing Algorithm Developers may use the RY_WRITE_ARITHMETIC to write algorithms to the Rockey4ND User Algorithm Zone (UAZ). The Rockey4ND editor is another option for writing algorithms to the UAZ.
For example: The “buffer” is the place for you to temporarily store the algorithm. One instruction is separated from another by a ",". Rockey4ND will automatically assign the first instruction in the algorithm, “Start” and the last instruction, “End”. Taking this program as an example: Address 3 in Algorithm Zone: A=A+E Then 3 is the starting point of the algorithm in the User Algorithm Zone (UAZ). 6 is the end point. ROCKEY4ND will return to the user application after performing the instruction in address 6. The users must call the program in the dongles from the starting point of the algorithm. Otherwise the results are 4 random numbers. 2.2)Instruction Conventions There are some conventions when developers write algorithm instructions:
3.Note Rockey4ND has as many as 128 instructions. Developers do not need to consider the start and end attributes of an algorithm. Rockey4ND will automatically assign a Start/End attribute to the instructions. In practice this means that if the developer writes a two-instruction algorithm to the User Algorithm Zone (UAZ), and then a three instruction algorithm, the result will not be a single five instruction algorithm. Algorithms that begin with “Null” or “E” will produce unpredictable results. 4.Tips 4.1) Make randomized calls to the Rockey4ND API - Randomly scatter calls to the Rockey4ND API from within your application. Calls made to the API from time-to-time will make it very difficult to mimic the behavior of the protection method or hack the application. 4.2) Use dynamic information with the seed code function -The use of dynamic information with the seed code function, such as system date, makes the protection method stronger because the results can change with the input and calculation. 4.3) Do not repeatedly use the same protection method in your application -If you use the same protection method several times in your application it will be easier for the cracker to find the rule and crack your application. Protection methods that are complex and rely on a number of different checks and calculations are the most difficult to crack. 4.4) Encrypt the character string and data – In “Step 18” of “Chapter Six -- API Application Examples", we showed an encryption method using information stored inside the dongle. Encrypting a character string in the manner described is a strong method because a failure to properly decrypt the string can cause the application to terminate or take other actions in accordance with the licensing agreement. 4.5) Use API encryption and Envelope encryption together – The strongest protection method will have the developer first using a complex and dynamic implementation of the Rockey4ND API, and then protecting this new file with the Rockey4ND Envelope. Please keep the end user environment in mind when you design the software protection solution. You should flexibly adopt the methods suggested here within the limitations and objectives of your environment and licensing policy.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Copyright (C) 2007-2009 Feitian Technologies Co.,Ltd.
All rights reserved. |