GHI Electronics,LLC USBwiz User Manual
USBwiz Command Set
CK - Check Key
Checking the stored key:
1. The user application will generate a random 8 bytes and then encrypt them
using XTEA algorithm against the "secret key" that was used above
2. The user application will keep the original values and will send the new encrypted
values to USBwiz to the Check Key command"CK xxxxxxxxxxxxxxxx"
3. USBwiz will decrypt the incoming data using the "secret key” and send it back to
the application.
4. The returned value will match what the user started with only if the "secret key"
was correct.
Format CK<SP>8EncryptedBytes<CR>
!00<CR>
8CorrectBytes, if the stored
key was correct<CR>
!00<CR>
8Bytes The 8 encrypted bytes.
Example CK<SP>be5147f1cce6e72b<CR>
!00<CR>
0102030405060708<CR>
!00<CR>
be5147f1cce6e72b 8Bytes were
decrypted against the previous key
0102030405060708 The actual
bytes before decryption
XTEA Algorithm Code:
This is the Encryption algorithm:
v: an array of 8 bytes to encrypt
k: the "Secret key"
void Encrypt8ByteBlock(int32* v, int32* k) {
int32 v0=v[0], v1=v[1], i;
int32 sum=0, delta=0x9E3779B9;
for(i=0; i<32; i++) {
v0 += (v1 << 4 ^ v1 >> 5) + v1 ^ sum + k[sum & 3];
sum += delta;
v1 += (v0 << 4 ^ v0 >> 5) + v0 ^ sum + k[sum>>11 & 3];
}
v[0]=v0; v[1]=v1;
}
Rev.2.27 Page 51 of 64 www.ghielectronics.com
Commentaires sur ces manuels