speck.h 740 B

1234567891011121314151617181920212223242526
  1. #ifndef SPECK_HEADER
  2. #define SPECK_HEADER
  3. #define ROTL16(x,r) (((x)<<(r)) | (x>>(16-(r))))
  4. #define ROTR16(x,r) (((x)>>(r)) | ((x)<<(16-(r))))
  5. #define ER16(x,y,k) (x=ROTR16(x,7), x+=y, x^=k, y=ROTL16(y,2), y^=x)
  6. #define DR16(x,y,k) (y^=x, y=ROTR16(y,2), x^=k, x-=y, x=ROTL16(x,7))
  7. #define u8 uint8_t
  8. #define u16 uint16_t
  9. #define u32 uint32_t
  10. #define u64 uint64_t
  11. void EncryptBlock(u8 pt[], u8 k[], u8 ct[]);
  12. void Speck3264_EncryptBlock(u8 pt[], u8 k[], u8 ct[]);
  13. void Words16ToBytes(u16 words[],u8 bytes[],int numwords);
  14. void BytesToWords16(u8 bytes[],u16 words[],int numbytes);
  15. void Speck3264KeySchedule(u16 K[],u16 rk[]);
  16. void Speck3264Encrypt(u16 Pt[],u16 Ct[],u16 rk[]);
  17. void Speck3264Decrypt(u16 Pt[],u16 Ct[],u16 rk[]);
  18. #endif