User's Manual

56
printf("Wrong SCRAMBLING\n");
exit(EXIT_FAILURE);
}
printf("Scramble ok\n");
/* Close */
k.net_command = NET_KEY_CLOSE;
smartlink(&k);
if (k.status != ST_OK) {
printf("Error in NET_KEY_CLOSE\n");
exit(EXIT_FAILURE);
}
return EXIT_SUCCESS;
}
The “table.h” generated file
This is the
table.h generated file
void scramble_in(unsigned char* dst, unsigned src) {
unsigned i;
for(i=0;i<SCRAMBLE_LENGTH;++i)
dst[i] = (((src + 0x5a) >> i) * (i + 0x13)) ^ 0x3e;
}
#define SCRAMBLE_MAX 1024
unsigned char SCRAMBLE[SCRAMBLE_MAX][SCRAMBLE_LENGTH] = {
{ 0xa2, 0x43, 0x2d, 0xdc, 0xf0, 0x49, 0x4b, 0x5c },
{ 0x00, 0x24, 0x9f, 0x6e, 0x51, 0x10, 0x9c, 0x1a },
…stripped…
{ 0x10, 0x0f, 0x5e, 0x8e, 0x5b, 0x44, 0x67, 0x11 },
{ 0xcd, 0x0a, 0x74, 0xed, 0x78, 0xc0, 0x0a, 0x97 }
};
10.3.8 Example 10 – Code encrypting
Furthermore, SmartKey can be used to encrypt the code of your executable files or of the dynamic libraries (DLL), if
these are developed in Visual C. A full, extensive example can be found in the archive:
SmartKeyEncryptionGuidelinesExample.zip
. For further details, consult files README.txt (English) and
LEGGIMI.txt (Italian) in .zip.
10.3.9 Example 11 – AES authentication
The following are two examples to set AES keys and use them.
Setkey
This example sets the AES keys.
WARNING! the AES keys can be set ONLY ONE TIME!
#include "skeydrv.h"
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
/* Serial */
unsigned char serial[16] = {
0x39, 0x9d, 0x81, 0xd0, 0x6f, 0x78, 0x94, 0x41, 0xec, 0xfe, 0x71, 0xa1, 0x21,
0xd4, 0xe1, 0x6d,
};
/* 20 AES keys */
unsigned char aeskey[16*20] = {
0x27, 0xe1, 0x4e, 0xf4, 0x82, 0x3a, 0x1d, 0xa2, 0xbd, 0xee, 0xc7, 0xd2, 0x50,
0xe1, 0x37, 0x66,
…stripped…