speck.h 665 B

12345678910111213141516171819
  1. #ifndef SPECK_HEADER
  2. #define SPECK_HEADER
  3. #define ER64(x,y,k) (x=ROTR64(x,8), x+=y, x^=k, y=ROTL64(y,3), y^=x)
  4. #define DR64(x,y,k) (y^=x, y=ROTR64(y,3), x^=k, x-=y, x=ROTL64(x,8))
  5. #define ROTL64(x,r) (((x)<<(r)) | (x>>(64-(r))))
  6. #define ROTR64(x,r) (((x)>>(r)) | ((x)<<(64-(r))))
  7. #define u8 uint8_t
  8. #define u32 uint32_t
  9. #define u64 uint64_t
  10. void Words64ToBytes(u64 words[],u8 bytes[],int numwords);
  11. void BytesToWords64(u8 bytes[],u64 words[],int numbytes);
  12. void Speck128256KeySchedule(u64 K[],u64 rk[]);
  13. void Speck128256Encrypt(u64 Pt[],u64 Ct[],u64 rk[]);
  14. void Speck128256Decrypt(u64 Pt[],u64 Ct[],u64 rk[]);
  15. void EncryptBlock(u8 pt[], u8 k[], u8 ct[]);
  16. #endif