#include #include #include void Words64ToBytes(u64 words[],u8 bytes[],int numwords) { int i,j=0; for(i=0;i>8); bytes[j+2]=(u8)(words[i]>>16); bytes[j+3]=(u8)(words[i]>>24); bytes[j+4]=(u8)(words[i]>>32); bytes[j+5]=(u8)(words[i]>>40); bytes[j+6]=(u8)(words[i]>>48); bytes[j+7]=(u8)(words[i]>>56); j+=8; } } void BytesToWords64(u8 bytes[],u64 words[],int numbytes) { int i,j=0; for(i=0;i=0;) DR64(Pt[1],Pt[0],rk[i--]); } void EncryptBlock(u8 pt[], u8 k[], u8 ct[]) { u64 Pt[2] = {0}; u64 K[4] = {0}; u64 rk[34] = {0}; u64 Ct[2] = {0}; BytesToWords64(pt,Pt,16); BytesToWords64(k,K,32); Speck128256KeySchedule(K,rk); Speck128256Encrypt(Pt,Ct,rk); Words64ToBytes(Ct,ct,2); }