comparison libtomcrypt/src/mac/xcbc/xcbc_init.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 #include "tomcrypt.h" 9 #include "tomcrypt.h"
12 10
13 /** 11 /**
14 @file xcbc_init.c 12 @file xcbc_init.c
69 } 67 }
70 68
71 if ((err = cipher_descriptor[cipher].setup(key, keylen, 0, skey)) != CRYPT_OK) { 69 if ((err = cipher_descriptor[cipher].setup(key, keylen, 0, skey)) != CRYPT_OK) {
72 goto done; 70 goto done;
73 } 71 }
74 72
75 /* make the three keys */ 73 /* make the three keys */
76 for (y = 0; y < 3; y++) { 74 for (y = 0; y < 3; y++) {
77 for (x = 0; x < cipher_descriptor[cipher].block_length; x++) { 75 for (x = 0; x < cipher_descriptor[cipher].block_length; x++) {
78 xcbc->K[y][x] = y + 1; 76 xcbc->K[y][x] = y + 1;
79 } 77 }
80 cipher_descriptor[cipher].ecb_encrypt(xcbc->K[y], xcbc->K[y], skey); 78 cipher_descriptor[cipher].ecb_encrypt(xcbc->K[y], xcbc->K[y], skey);
81 } 79 }
82 } 80 }
83 81
84 /* setup K1 */ 82 /* setup K1 */
85 err = cipher_descriptor[cipher].setup(xcbc->K[0], k1, 0, &xcbc->key); 83 err = cipher_descriptor[cipher].setup(xcbc->K[0], k1, 0, &xcbc->key);
86 84
87 /* setup struct */ 85 /* setup struct */
88 zeromem(xcbc->IV, cipher_descriptor[cipher].block_length); 86 zeromem(xcbc->IV, cipher_descriptor[cipher].block_length);
89 xcbc->blocksize = cipher_descriptor[cipher].block_length; 87 xcbc->blocksize = cipher_descriptor[cipher].block_length;
90 xcbc->cipher = cipher; 88 xcbc->cipher = cipher;
91 xcbc->buflen = 0; 89 xcbc->buflen = 0;
92 done: 90 done:
93 cipher_descriptor[cipher].done(skey); 91 cipher_descriptor[cipher].done(skey);
94 if (skey != NULL) { 92 if (skey != NULL) {
95 #ifdef LTC_CLEAN_STACK 93 #ifdef LTC_CLEAN_STACK
96 zeromem(skey, sizeof(*skey)); 94 zeromem(skey, sizeof(*skey));
97 #endif 95 #endif
98 XFREE(skey); 96 XFREE(skey);
99 } 97 }
100 return err; 98 return err;
101 } 99 }
102 100
103 #endif 101 #endif
104 102
105 /* $Source$ */ 103 /* ref: $Format:%D$ */
106 /* $Revision$ */ 104 /* git commit: $Format:%H$ */
107 /* $Date$ */ 105 /* commit time: $Format:%ai$ */
108 106