comparison libtomcrypt/src/encauth/gcm/gcm_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 9
12 /** 10 /**
13 @file gcm_done.c 11 @file gcm_done.c
14 GCM implementation, Terminate the stream, by Tom St Denis 12 GCM implementation, Terminate the stream, by Tom St Denis
22 @param gcm The GCM state 20 @param gcm The GCM state
23 @param tag [out] The destination for the MAC tag 21 @param tag [out] The destination for the MAC tag
24 @param taglen [in/out] The length of the MAC tag 22 @param taglen [in/out] The length of the MAC tag
25 @return CRYPT_OK on success 23 @return CRYPT_OK on success
26 */ 24 */
27 int gcm_done(gcm_state *gcm, 25 int gcm_done(gcm_state *gcm,
28 unsigned char *tag, unsigned long *taglen) 26 unsigned char *tag, unsigned long *taglen)
29 { 27 {
30 unsigned long x; 28 unsigned long x;
31 int err; 29 int err;
32 30
40 38
41 if ((err = cipher_is_valid(gcm->cipher)) != CRYPT_OK) { 39 if ((err = cipher_is_valid(gcm->cipher)) != CRYPT_OK) {
42 return err; 40 return err;
43 } 41 }
44 42
43 if (gcm->mode == LTC_GCM_MODE_IV) {
44 /* let's process the IV */
45 if ((err = gcm_add_aad(gcm, NULL, 0)) != CRYPT_OK) return err;
46 }
47
48 if (gcm->mode == LTC_GCM_MODE_AAD) {
49 /* let's process the AAD */
50 if ((err = gcm_process(gcm, NULL, 0, NULL, 0)) != CRYPT_OK) return err;
51 }
45 52
46 if (gcm->mode != LTC_GCM_MODE_TEXT) { 53 if (gcm->mode != LTC_GCM_MODE_TEXT) {
47 return CRYPT_INVALID_ARG; 54 return CRYPT_INVALID_ARG;
48 } 55 }
49 56
76 } 83 }
77 84
78 #endif 85 #endif
79 86
80 87
81 /* $Source$ */ 88 /* ref: $Format:%D$ */
82 /* $Revision$ */ 89 /* git commit: $Format:%H$ */
83 /* $Date$ */ 90 /* commit time: $Format:%ai$ */