Mercurial > dropbear
comparison libtomcrypt/src/mac/omac/omac_done.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 | f849a5ca2efc |
children |
comparison
equal
deleted
inserted
replaced
1470:8bba51a55704 | 1471:6dba84798cd5 |
---|---|
3 * LibTomCrypt is a library that provides various cryptographic | 3 * LibTomCrypt is a library that provides various cryptographic |
4 * algorithms in a highly modular and flexible manner. | 4 * algorithms in a highly modular and flexible manner. |
5 * | 5 * |
6 * The library is free for all purposes without any express | 6 * The library is free for all purposes without any express |
7 * guarantee it works. | 7 * guarantee it works. |
8 * | |
9 * Tom St Denis, [email protected], http://libtom.org | |
10 */ | 8 */ |
11 #include "tomcrypt.h" | 9 #include "tomcrypt.h" |
12 | 10 |
13 /** | 11 /** |
14 @file omac_done.c | 12 @file omac_done.c |
15 LTC_OMAC1 support, terminate a stream, Tom St Denis | 13 OMAC1 support, terminate a stream, Tom St Denis |
16 */ | 14 */ |
17 | 15 |
18 #ifdef LTC_OMAC | 16 #ifdef LTC_OMAC |
19 | 17 |
20 /** | 18 /** |
21 Terminate an LTC_OMAC stream | 19 Terminate an OMAC stream |
22 @param omac The LTC_OMAC state | 20 @param omac The OMAC state |
23 @param out [out] Destination for the authentication tag | 21 @param out [out] Destination for the authentication tag |
24 @param outlen [in/out] The max size and resulting size of the authentication tag | 22 @param outlen [in/out] The max size and resulting size of the authentication tag |
25 @return CRYPT_OK if successful | 23 @return CRYPT_OK if successful |
26 */ | 24 */ |
27 int omac_done(omac_state *omac, unsigned char *out, unsigned long *outlen) | 25 int omac_done(omac_state *omac, unsigned char *out, unsigned long *outlen) |
63 /* encrypt it */ | 61 /* encrypt it */ |
64 if ((err = cipher_descriptor[omac->cipher_idx].ecb_encrypt(omac->block, omac->block, &omac->key)) != CRYPT_OK) { | 62 if ((err = cipher_descriptor[omac->cipher_idx].ecb_encrypt(omac->block, omac->block, &omac->key)) != CRYPT_OK) { |
65 return err; | 63 return err; |
66 } | 64 } |
67 cipher_descriptor[omac->cipher_idx].done(&omac->key); | 65 cipher_descriptor[omac->cipher_idx].done(&omac->key); |
68 | 66 |
69 /* output it */ | 67 /* output it */ |
70 for (x = 0; x < (unsigned)omac->blklen && x < *outlen; x++) { | 68 for (x = 0; x < (unsigned)omac->blklen && x < *outlen; x++) { |
71 out[x] = omac->block[x]; | 69 out[x] = omac->block[x]; |
72 } | 70 } |
73 *outlen = x; | 71 *outlen = x; |
79 } | 77 } |
80 | 78 |
81 #endif | 79 #endif |
82 | 80 |
83 | 81 |
84 /* $Source$ */ | 82 /* ref: $Format:%D$ */ |
85 /* $Revision$ */ | 83 /* git commit: $Format:%H$ */ |
86 /* $Date$ */ | 84 /* commit time: $Format:%ai$ */ |