status update, probably last commit
[rofl0r-kripto.git] / test / block / khazad.c
blob5616a24bcb2e72618515bcf4c19dd471c566b165
1 /*
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.
7 *
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/>.
14 #include <stdint.h>
15 #include <stdio.h>
16 #include <string.h>
18 #include <kripto/block.h>
19 #include <kripto/block/khazad.h>
21 int main(void)
23 kripto_block *s;
24 uint8_t t[8];
25 const uint8_t k[16] =
27 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
30 const uint8_t pt[8] =
32 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
34 const uint8_t ct[8] =
36 0x49, 0xA4, 0xCE, 0x32, 0xAC, 0x19, 0x0E, 0x3F
39 puts("kripto_block_khazad");
41 /* 128-bit key */
42 s = kripto_block_create(kripto_block_khazad, 0, k, 16);
43 if(!s) puts("error");
45 kripto_block_encrypt(s, pt, t);
46 if(memcmp(t, ct, 8)) puts("128-bit key encrypt: FAIL");
47 else puts("128-bit key encrypt: OK");
49 kripto_block_decrypt(s, ct, t);
50 if(memcmp(t, pt, 8)) puts("128-bit key decrypt: FAIL");
51 else puts("128-bit key decrypt: OK");
53 kripto_block_destroy(s);
55 return 0;