fix: Crypt::AuthEnc::GCM - Encryption of the empty string #37
Karel Miko
6 years ago
4 | 4 |
*
|
5 | 5 |
* The library is free for all purposes without any express
|
6 | 6 |
* guarantee it works.
|
7 | |
*
|
8 | |
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
9 | 7 |
*/
|
10 | 8 |
|
11 | 9 |
/**
|
|
118 | 116 |
#endif
|
119 | 117 |
|
120 | 118 |
|
121 | |
/* $Source$ */
|
122 | |
/* $Revision$ */
|
123 | |
/* $Date$ */
|
|
119 |
/* ref: $Format:%D$ */
|
|
120 |
/* git commit: $Format:%H$ */
|
|
121 |
/* commit time: $Format:%ai$ */
|
4 | 4 |
*
|
5 | 5 |
* The library is free for all purposes without any express
|
6 | 6 |
* guarantee it works.
|
7 | |
*
|
8 | |
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
9 | 7 |
*/
|
10 | 8 |
|
11 | 9 |
/**
|
|
88 | 86 |
#endif
|
89 | 87 |
|
90 | 88 |
|
91 | |
/* $Source$ */
|
92 | |
/* $Revision$ */
|
93 | |
/* $Date$ */
|
|
89 |
/* ref: $Format:%D$ */
|
|
90 |
/* git commit: $Format:%H$ */
|
|
91 |
/* commit time: $Format:%ai$ */
|
4 | 4 |
*
|
5 | 5 |
* The library is free for all purposes without any express
|
6 | 6 |
* guarantee it works.
|
7 | |
*
|
8 | |
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
9 | 7 |
*/
|
10 | 8 |
|
11 | 9 |
/**
|
|
41 | 39 |
return err;
|
42 | 40 |
}
|
43 | 41 |
|
|
42 |
if (gcm->mode == LTC_GCM_MODE_IV) {
|
|
43 |
/* let's process the IV */
|
|
44 |
if ((err = gcm_add_aad(gcm, NULL, 0)) != CRYPT_OK) return err;
|
|
45 |
}
|
|
46 |
|
|
47 |
if (gcm->mode == LTC_GCM_MODE_AAD) {
|
|
48 |
/* let's process the AAD */
|
|
49 |
if ((err = gcm_process(gcm, NULL, 0, NULL, 0)) != CRYPT_OK) return err;
|
|
50 |
}
|
44 | 51 |
|
45 | 52 |
if (gcm->mode != LTC_GCM_MODE_TEXT) {
|
46 | 53 |
return CRYPT_INVALID_ARG;
|
|
77 | 84 |
#endif
|
78 | 85 |
|
79 | 86 |
|
80 | |
/* $Source$ */
|
81 | |
/* $Revision$ */
|
82 | |
/* $Date$ */
|
|
87 |
/* ref: $Format:%D$ */
|
|
88 |
/* git commit: $Format:%H$ */
|
|
89 |
/* commit time: $Format:%ai$ */
|
4 | 4 |
*
|
5 | 5 |
* The library is free for all purposes without any express
|
6 | 6 |
* guarantee it works.
|
7 | |
*
|
8 | |
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
9 | 7 |
*/
|
10 | 8 |
|
11 | 9 |
/**
|
|
59 | 57 |
|
60 | 58 |
#ifndef LTC_FAST
|
61 | 59 |
/* right shift */
|
62 | |
static void gcm_rightshift(unsigned char *a)
|
|
60 |
static void _gcm_rightshift(unsigned char *a)
|
63 | 61 |
{
|
64 | 62 |
int x;
|
65 | 63 |
for (x = 15; x > 0; x--) {
|
|
93 | 91 |
}
|
94 | 92 |
}
|
95 | 93 |
z = V[15] & 0x01;
|
96 | |
gcm_rightshift(V);
|
|
94 |
_gcm_rightshift(V);
|
97 | 95 |
V[0] ^= poly[z];
|
98 | 96 |
}
|
99 | 97 |
XMEMCPY(c, Z, 16);
|
|
214 | 212 |
|
215 | 213 |
#endif
|
216 | 214 |
|
217 | |
/* $Source$ */
|
218 | |
/* $Revision$ */
|
219 | |
/* $Date$ */
|
220 | |
|
|
215 |
/* ref: $Format:%D$ */
|
|
216 |
/* git commit: $Format:%H$ */
|
|
217 |
/* commit time: $Format:%ai$ */
|
|
218 |
|
4 | 4 |
*
|
5 | 5 |
* The library is free for all purposes without any express
|
6 | 6 |
* guarantee it works.
|
7 | |
*
|
8 | |
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
9 | 7 |
*/
|
10 | 8 |
|
11 | 9 |
/**
|
|
101 | 99 |
|
102 | 100 |
#endif
|
103 | 101 |
|
104 | |
/* $Source$ */
|
105 | |
/* $Revision$ */
|
106 | |
/* $Date$ */
|
|
102 |
/* ref: $Format:%D$ */
|
|
103 |
/* git commit: $Format:%H$ */
|
|
104 |
/* commit time: $Format:%ai$ */
|
4 | 4 |
*
|
5 | 5 |
* The library is free for all purposes without any express
|
6 | 6 |
* guarantee it works.
|
7 | |
*
|
8 | |
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
9 | 7 |
*/
|
10 | 8 |
|
11 | 9 |
/**
|
|
102 | 100 |
#endif
|
103 | 101 |
|
104 | 102 |
|
105 | |
/* $Source$ */
|
106 | |
/* $Revision$ */
|
107 | |
/* $Date$ */
|
|
103 |
/* ref: $Format:%D$ */
|
|
104 |
/* git commit: $Format:%H$ */
|
|
105 |
/* commit time: $Format:%ai$ */
|
4 | 4 |
*
|
5 | 5 |
* The library is free for all purposes without any express
|
6 | 6 |
* guarantee it works.
|
7 | |
*
|
8 | |
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
9 | 7 |
*/
|
10 | 8 |
|
11 | 9 |
/**
|
|
53 | 51 |
}
|
54 | 52 |
#endif
|
55 | 53 |
|
56 | |
/* $Source$ */
|
57 | |
/* $Revision$ */
|
58 | |
/* $Date$ */
|
|
54 |
/* ref: $Format:%D$ */
|
|
55 |
/* git commit: $Format:%H$ */
|
|
56 |
/* commit time: $Format:%ai$ */
|
4 | 4 |
*
|
5 | 5 |
* The library is free for all purposes without any express
|
6 | 6 |
* guarantee it works.
|
7 | |
*
|
8 | |
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
9 | 7 |
*/
|
10 | 8 |
|
11 | 9 |
/**
|
|
51 | 49 |
/* 0xFFFFFFFE0 = ((2^39)-256)/8 */
|
52 | 50 |
if (gcm->pttotlen / 8 + (ulong64)gcm->buflen + (ulong64)ptlen >= CONST64(0xFFFFFFFE0)) {
|
53 | 51 |
return CRYPT_INVALID_ARG;
|
|
52 |
}
|
|
53 |
|
|
54 |
if (gcm->mode == LTC_GCM_MODE_IV) {
|
|
55 |
/* let's process the IV */
|
|
56 |
if ((err = gcm_add_aad(gcm, NULL, 0)) != CRYPT_OK) return err;
|
54 | 57 |
}
|
55 | 58 |
|
56 | 59 |
/* in AAD mode? */
|
|
151 | 154 |
|
152 | 155 |
#endif
|
153 | 156 |
|
154 | |
/* $Source$ */
|
155 | |
/* $Revision$ */
|
156 | |
/* $Date$ */
|
|
157 |
/* ref: $Format:%D$ */
|
|
158 |
/* git commit: $Format:%H$ */
|
|
159 |
/* commit time: $Format:%ai$ */
|
4 | 4 |
*
|
5 | 5 |
* The library is free for all purposes without any express
|
6 | 6 |
* guarantee it works.
|
7 | |
*
|
8 | |
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
9 | 7 |
*/
|
10 | 8 |
|
11 | 9 |
/**
|
|
38 | 36 |
|
39 | 37 |
#endif
|
40 | 38 |
|
41 | |
/* $Source$ */
|
42 | |
/* $Revision$ */
|
43 | |
/* $Date$ */
|
|
39 |
/* ref: $Format:%D$ */
|
|
40 |
/* git commit: $Format:%H$ */
|
|
41 |
/* commit time: $Format:%ai$ */
|