Codebase list libcryptx-perl / 9f92e4a
fix: Crypt::AuthEnc::GCM - Encryption of the empty string #37 Karel Miko 6 years ago
9 changed file(s) with 44 addition(s) and 48 deletion(s). Raw diff Collapse all Expand all
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
118116 #endif
119117
120118
121 /* $Source$ */
122 /* $Revision$ */
123 /* $Date$ */
119 /* ref: $Format:%D$ */
120 /* git commit: $Format:%H$ */
121 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
8886 #endif
8987
9088
91 /* $Source$ */
92 /* $Revision$ */
93 /* $Date$ */
89 /* ref: $Format:%D$ */
90 /* git commit: $Format:%H$ */
91 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
4139 return err;
4240 }
4341
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 }
4451
4552 if (gcm->mode != LTC_GCM_MODE_TEXT) {
4653 return CRYPT_INVALID_ARG;
7784 #endif
7885
7986
80 /* $Source$ */
81 /* $Revision$ */
82 /* $Date$ */
87 /* ref: $Format:%D$ */
88 /* git commit: $Format:%H$ */
89 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
5957
6058 #ifndef LTC_FAST
6159 /* right shift */
62 static void gcm_rightshift(unsigned char *a)
60 static void _gcm_rightshift(unsigned char *a)
6361 {
6462 int x;
6563 for (x = 15; x > 0; x--) {
9391 }
9492 }
9593 z = V[15] & 0x01;
96 gcm_rightshift(V);
94 _gcm_rightshift(V);
9795 V[0] ^= poly[z];
9896 }
9997 XMEMCPY(c, Z, 16);
214212
215213 #endif
216214
217 /* $Source$ */
218 /* $Revision$ */
219 /* $Date$ */
220
215 /* ref: $Format:%D$ */
216 /* git commit: $Format:%H$ */
217 /* commit time: $Format:%ai$ */
218
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
10199
102100 #endif
103101
104 /* $Source$ */
105 /* $Revision$ */
106 /* $Date$ */
102 /* ref: $Format:%D$ */
103 /* git commit: $Format:%H$ */
104 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
102100 #endif
103101
104102
105 /* $Source$ */
106 /* $Revision$ */
107 /* $Date$ */
103 /* ref: $Format:%D$ */
104 /* git commit: $Format:%H$ */
105 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
5351 }
5452 #endif
5553
56 /* $Source$ */
57 /* $Revision$ */
58 /* $Date$ */
54 /* ref: $Format:%D$ */
55 /* git commit: $Format:%H$ */
56 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
5149 /* 0xFFFFFFFE0 = ((2^39)-256)/8 */
5250 if (gcm->pttotlen / 8 + (ulong64)gcm->buflen + (ulong64)ptlen >= CONST64(0xFFFFFFFE0)) {
5351 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;
5457 }
5558
5659 /* in AAD mode? */
151154
152155 #endif
153156
154 /* $Source$ */
155 /* $Revision$ */
156 /* $Date$ */
157 /* ref: $Format:%D$ */
158 /* git commit: $Format:%H$ */
159 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
3836
3937 #endif
4038
41 /* $Source$ */
42 /* $Revision$ */
43 /* $Date$ */
39 /* ref: $Format:%D$ */
40 /* git commit: $Format:%H$ */
41 /* commit time: $Format:%ai$ */