2 * Written in 2013 by Gregor Pintar <grpintar@gmail.com>
4 * To the extent possible under law, the author(s) have dedicated
5 * all copyright and related and neighboring rights to this software
6 * to the public domain worldwide.
8 * This software is distributed without any warranty.
10 * You should have received a copy of the CC0 Public Domain Dedication.
11 * If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
17 #include <kripto/block/speck64.h>
26 0x1B, 0x1A, 0x19, 0x18, 0x13, 0x12, 0x11, 0x10,
27 0x0B, 0x0A, 0x09, 0x08, 0x03, 0x02, 0x01, 0x00
29 const uint8_t pt96
[8] =
31 0x74, 0x61, 0x46, 0x20, 0x73, 0x6E, 0x61, 0x65
33 const uint8_t pt128
[8] =
35 0x3B, 0x72, 0x65, 0x74, 0x74, 0x75, 0x43, 0x2D
37 const uint8_t ct96
[8] =
39 0x9F, 0x79, 0x52, 0xEC, 0x41, 0x75, 0x94, 0x6C
41 const uint8_t ct128
[8] =
43 0x8C, 0x6F, 0xA5, 0x48, 0x45, 0x4E, 0x02, 0x8B
46 puts("kripto_block_speck64");
49 s
= kripto_block_create(kripto_block_speck64
, 0, k
+ 4, 12);
52 kripto_block_encrypt(s
, pt96
, t
);
53 for(i
= 0; i
< 8; i
++) if(t
[i
] != ct96
[i
])
55 puts("96-bit key encrypt: FAIL");
58 if(i
== 8) puts("96-bit key encrypt: OK");
60 kripto_block_decrypt(s
, ct96
, t
);
61 for(i
= 0; i
< 8; i
++) if(t
[i
] != pt96
[i
])
63 puts("96-bit key decrypt: FAIL");
66 if(i
== 8) puts("96-bit key decrypt: OK");
69 s
= kripto_block_recreate(s
, 0, k
, 16);
72 kripto_block_encrypt(s
, pt128
, t
);
73 for(i
= 0; i
< 8; i
++) if(t
[i
] != ct128
[i
])
75 puts("128-bit key encrypt: FAIL");
78 if(i
== 8) puts("128-bit key encrypt: OK");
80 kripto_block_decrypt(s
, ct128
, t
);
81 for(i
= 0; i
< 8; i
++) if(t
[i
] != pt128
[i
])
83 puts("128-bit key decrypt: FAIL");
86 if(i
== 8) puts("128-bit key decrypt: OK");
88 kripto_block_destroy(s
);