User's Manual

52
printf("DLL checksum %08X\n",checksum);
if (checksum != 0x007ffcf1) {
printf("Error invalid checksum\n");
exit(EXIT_FAILURE);
}
return EXIT_SUCCESS;
}
10.3.5 Example 6 – Hiding Label and Password information
This example shows how to hide the Label and Password information, by using a simple masking algorithm. This
algorithm must be used to prevent the possibility of discovering the Label and Password from the executable file, thus
frustrating all SmartKey's protections.
#include "skeylink.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* Hidden values */
static unsigned char hidden_label[LABEL_LENGTH] = {
0x09, 0x2f, 0x2d, 0x2a, 0xd2, 0xdd, 0xed, 0xe5,
0xd2, 0xea, 0x04, 0x20, 0x3e, 0x5e, 0x80, 0xa4
};
static unsigned char hidden_password[PASSWORD_LENGTH] = {
0xe0, 0x91, 0xb1, 0x5a, 0x62, 0x1a, 0x7d, 0xa8,
0xd5, 0x04, 0x35, 0x68, 0x9d, 0xd4, 0x0d, 0x48
};
int main() {
KEY_NET k;
unsigned i;
memset(&k,0,sizeof(k));
/* Calcola la label e la password corrette */
for(i=0;i<LABEL_LENGTH;++i)
k.label[i] = hidden_label[i] ^ (i*(i+0x7)+0x5a);
for(i=0;i<PASSWORD_LENGTH;++i)
k.password[i] = hidden_password[i] ^ (i*(i+0x1e)+0xa5);
/* Open */
k.net_command = NET_KEY_OPEN;
smartlink(&k);
if (k.status != ST_OK) {
printf("Error in NET_KEY_OPEN\n");
exit(EXIT_FAILURE);
}
printf("Net password %d\n",k.net_password);
/* Close */
k.net_command = NET_KEY_CLOSE;
smartlink(&k);
if (k.status != ST_OK) {
printf("Error in NET_KEY_CLOSE\n");
exit(EXIT_FAILURE);
}