Hi All,
I would like to know how to implement the DES/3DES and MACTriple DES in QNX, I would very appreciated for any source code.
I use setkey() and encrypt() for a simple testing as following:
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
unsigned char i;
unsigned char key[64];
unsigned char blk[64];
for(i=0;i<64;i++)
{
if(i%2)
key[i]=1;
else
key[i]=0;
}
for(i=0;i<64;i++)
{
if(i%2)
blk[i]=0;
else
blk[i]=1;
}
printf("Plain:");
for(i=0;i<64;i++)
printf("%d ",blk[i]);
printf("\n");
setkey(key);
encrypt(blk,0);
printf("Encry:");
for(i=0;i<64;i++)
printf("%d ",blk[i]);
printf("\n");
setkey(key);
encrypt(blk,1);
printf("Decry:");
for(i=0;i<64;i++)
printf("%d ",blk[i]);
printf("\n");
return EXIT_SUCCESS;
}
and the result as below:
Plain:1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
Encry:0 0 1 1 0 1 0 0 0 0 1 1 1 0 1 0 0 0 0 0 1 0 0 1 1 1 1 1 1 0 0 1 1 0 1 1 0 0 1 0 1 1 0 0 1 0 1 1 0 1 0 1 1 1 0 0 1 1 0 0 1 0 1 0
Decry:0 0 1 1 0 1 0 0 0 0 1 1 1 0 1 0 0 0 0 0 1 0 0 1 1 1 1 1 1 0 0 1 1 0 1 1 0 0 1 0 1 1 0 0 1 0 1 1 0 1 0 1 1 1 0 0 1 1 0 0 1 0 1 0
there is no decrypt implmented with encrypt() function.
Thanks a lot
Regards,