Mercurial > dropbear
comparison libtomcrypt/src/stream/sober128/sober128_test.c @ 1471:6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 09 Feb 2018 21:44:05 +0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1470:8bba51a55704 | 1471:6dba84798cd5 |
---|---|
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis | |
2 * | |
3 * LibTomCrypt is a library that provides various cryptographic | |
4 * algorithms in a highly modular and flexible manner. | |
5 * | |
6 * The library is free for all purposes without any express | |
7 * guarantee it works. | |
8 */ | |
9 | |
10 #include "tomcrypt.h" | |
11 | |
12 #ifdef LTC_SOBER128 | |
13 | |
14 int sober128_stream_test(void) | |
15 { | |
16 #ifndef LTC_TEST | |
17 return CRYPT_NOP; | |
18 #else | |
19 unsigned char key[16] = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6b, 0x65, 0x79, | |
20 0x20, 0x31, 0x32, 0x38, 0x62, 0x69, 0x74, 0x73 }; | |
21 unsigned char iv[4] = { 0x00, 0x00, 0x00, 0x00 }; | |
22 unsigned char out[20] = { 0x43, 0x50, 0x0c, 0xcf, 0x89, 0x91, 0x9f, 0x1d, | |
23 0xaa, 0x37, 0x74, 0x95, 0xf4, 0xb4, 0x58, 0xc2, | |
24 0x40, 0x37, 0x8b, 0xbb }; | |
25 int err, len = 20; | |
26 unsigned char src[20], dst[20]; | |
27 sober128_state st; | |
28 | |
29 XMEMSET(src, 0, len); /* input */ | |
30 if ((err = sober128_stream_setup(&st, key, sizeof(key))) != CRYPT_OK) return err; | |
31 if ((err = sober128_stream_setiv(&st, iv, sizeof(iv))) != CRYPT_OK) return err; | |
32 if ((err = sober128_stream_crypt(&st, src, len, dst)) != CRYPT_OK) return err; | |
33 if ((err = sober128_stream_done(&st)) != CRYPT_OK) return err; | |
34 if (compare_testvector(dst, len, out, len, "SOBER-128", 0)) { | |
35 return CRYPT_FAIL_TESTVECTOR; | |
36 } | |
37 return CRYPT_OK; | |
38 #endif | |
39 } | |
40 | |
41 #endif | |
42 | |
43 /* ref: $Format:%D$ */ | |
44 /* git commit: $Format:%H$ */ | |
45 /* commit time: $Format:%ai$ */ |