Mercurial > dropbear
comparison libtomcrypt/src/stream/chacha/chacha_ivctr64.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 /* The implementation is based on: | |
11 * chacha-ref.c version 20080118 | |
12 * Public domain from D. J. Bernstein | |
13 */ | |
14 | |
15 #include "tomcrypt.h" | |
16 | |
17 #ifdef LTC_CHACHA | |
18 | |
19 /** | |
20 Set IV + counter data to the ChaCha state | |
21 @param st The ChaCha20 state | |
22 @param iv The IV data to add | |
23 @param ivlen The length of the IV (must be 8) | |
24 @param counter 64bit (unsigned) initial counter value | |
25 @return CRYPT_OK on success | |
26 */ | |
27 int chacha_ivctr64(chacha_state *st, const unsigned char *iv, unsigned long ivlen, ulong64 counter) | |
28 { | |
29 LTC_ARGCHK(st != NULL); | |
30 LTC_ARGCHK(iv != NULL); | |
31 /* 64bit IV + 64bit counter */ | |
32 LTC_ARGCHK(ivlen == 8); | |
33 | |
34 st->input[12] = (ulong32)(counter & 0xFFFFFFFF); | |
35 st->input[13] = (ulong32)(counter >> 32); | |
36 LOAD32L(st->input[14], iv + 0); | |
37 LOAD32L(st->input[15], iv + 4); | |
38 st->ksleft = 0; | |
39 st->ivlen = ivlen; | |
40 return CRYPT_OK; | |
41 } | |
42 | |
43 #endif | |
44 | |
45 /* ref: $Format:%D$ */ | |
46 /* git commit: $Format:%H$ */ | |
47 /* commit time: $Format:%ai$ */ |