comparison libtomcrypt/src/encauth/gcm/gcm_memory.c @ 1478:3a933956437e coverity

update coverity
author Matt Johnston <matt@ucc.asn.au>
date Fri, 09 Feb 2018 23:49:22 +0800
parents 6dba84798cd5
children
comparison
equal deleted inserted replaced
1439:8d24733026c5 1478:3a933956437e
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_memory.c 11 @file gcm_memory.c
14 GCM implementation, process a packet, by Tom St Denis 12 GCM implementation, process a packet, by Tom St Denis
20 /** 18 /**
21 Process an entire GCM packet in one call. 19 Process an entire GCM packet in one call.
22 @param cipher Index of cipher to use 20 @param cipher Index of cipher to use
23 @param key The secret key 21 @param key The secret key
24 @param keylen The length of the secret key 22 @param keylen The length of the secret key
25 @param IV The initial vector 23 @param IV The initialization vector
26 @param IVlen The length of the initial vector 24 @param IVlen The length of the initialization vector
27 @param adata The additional authentication data (header) 25 @param adata The additional authentication data (header)
28 @param adatalen The length of the adata 26 @param adatalen The length of the adata
29 @param pt The plaintext 27 @param pt The plaintext
30 @param ptlen The length of the plaintext (ciphertext length is the same) 28 @param ptlen The length of the plaintext (ciphertext length is the same)
31 @param ct The ciphertext 29 @param ct The ciphertext
37 int gcm_memory( int cipher, 35 int gcm_memory( int cipher,
38 const unsigned char *key, unsigned long keylen, 36 const unsigned char *key, unsigned long keylen,
39 const unsigned char *IV, unsigned long IVlen, 37 const unsigned char *IV, unsigned long IVlen,
40 const unsigned char *adata, unsigned long adatalen, 38 const unsigned char *adata, unsigned long adatalen,
41 unsigned char *pt, unsigned long ptlen, 39 unsigned char *pt, unsigned long ptlen,
42 unsigned char *ct, 40 unsigned char *ct,
43 unsigned char *tag, unsigned long *taglen, 41 unsigned char *tag, unsigned long *taglen,
44 int direction) 42 int direction)
45 { 43 {
46 void *orig; 44 void *orig;
47 gcm_state *gcm; 45 gcm_state *gcm;
48 int err; 46 int err;
49 47
50 if ((err = cipher_is_valid(cipher)) != CRYPT_OK) { 48 if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
51 return err; 49 return err;
52 } 50 }
53 51
54 if (cipher_descriptor[cipher].accel_gcm_memory != NULL) { 52 if (cipher_descriptor[cipher].accel_gcm_memory != NULL) {
55 return 53 return cipher_descriptor[cipher].accel_gcm_memory
56 cipher_descriptor[cipher].accel_gcm_memory
57 (key, keylen, 54 (key, keylen,
58 IV, IVlen, 55 IV, IVlen,
59 adata, adatalen, 56 adata, adatalen,
60 pt, ptlen, 57 pt, ptlen,
61 ct, 58 ct,
102 return err; 99 return err;
103 } 100 }
104 #endif 101 #endif
105 102
106 103
107 /* $Source$ */ 104 /* ref: $Format:%D$ */
108 /* $Revision$ */ 105 /* git commit: $Format:%H$ */
109 /* $Date$ */ 106 /* commit time: $Format:%ai$ */