speck.h 768 B

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