e_aesgcmsiv.c
Go to the documentation of this file.
1 /* Copyright (c) 2017, Google Inc.
2  *
3  * Permission to use, copy, modify, and/or distribute this software for any
4  * purpose with or without fee is hereby granted, provided that the above
5  * copyright notice and this permission notice appear in all copies.
6  *
7  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14 
15 #include <openssl/aead.h>
16 
17 #include <assert.h>
18 
19 #include <openssl/cipher.h>
20 #include <openssl/cpu.h>
21 #include <openssl/crypto.h>
22 #include <openssl/err.h>
23 
24 #include "../fipsmodule/cipher/internal.h"
25 
26 
27 #define EVP_AEAD_AES_GCM_SIV_NONCE_LEN 12
28 #define EVP_AEAD_AES_GCM_SIV_TAG_LEN 16
29 
30 // TODO(davidben): AES-GCM-SIV assembly is not correct for Windows. It must save
31 // and restore xmm6 through xmm15.
32 #if defined(OPENSSL_X86_64) && !defined(OPENSSL_NO_ASM) && \
33  !defined(OPENSSL_WINDOWS)
34 #define AES_GCM_SIV_ASM
35 
36 // Optimised AES-GCM-SIV
37 
38 struct aead_aes_gcm_siv_asm_ctx {
39  alignas(16) uint8_t key[16*15];
40  int is_128_bit;
41 };
42 
43 // The assembly code assumes 8-byte alignment of the EVP_AEAD_CTX's state, and
44 // aligns to 16 bytes itself.
45 OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) + 8 >=
46  sizeof(struct aead_aes_gcm_siv_asm_ctx),
47  "AEAD state is too small");
48 #if defined(__GNUC__) || defined(__clang__)
50  "AEAD state has insufficient alignment");
51 #endif
52 
53 // asm_ctx_from_ctx returns a 16-byte aligned context pointer from |ctx|.
54 static struct aead_aes_gcm_siv_asm_ctx *asm_ctx_from_ctx(
55  const EVP_AEAD_CTX *ctx) {
56  // ctx->state must already be 8-byte aligned. Thus, at most, we may need to
57  // add eight to align it to 16 bytes.
58  const uintptr_t offset = ((uintptr_t)&ctx->state) & 8;
59  return (struct aead_aes_gcm_siv_asm_ctx *)(&ctx->state.opaque[offset]);
60 }
61 
62 // aes128gcmsiv_aes_ks writes an AES-128 key schedule for |key| to
63 // |out_expanded_key|.
64 extern void aes128gcmsiv_aes_ks(
65  const uint8_t key[16], uint8_t out_expanded_key[16*15]);
66 
67 // aes256gcmsiv_aes_ks writes an AES-256 key schedule for |key| to
68 // |out_expanded_key|.
69 extern void aes256gcmsiv_aes_ks(
70  const uint8_t key[32], uint8_t out_expanded_key[16*15]);
71 
72 static int aead_aes_gcm_siv_asm_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
73  size_t key_len, size_t tag_len) {
74  const size_t key_bits = key_len * 8;
75 
76  if (key_bits != 128 && key_bits != 256) {
78  return 0; // EVP_AEAD_CTX_init should catch this.
79  }
80 
81  if (tag_len == EVP_AEAD_DEFAULT_TAG_LENGTH) {
83  }
84 
85  if (tag_len != EVP_AEAD_AES_GCM_SIV_TAG_LEN) {
87  return 0;
88  }
89 
90  struct aead_aes_gcm_siv_asm_ctx *gcm_siv_ctx = asm_ctx_from_ctx(ctx);
91  assert((((uintptr_t)gcm_siv_ctx) & 15) == 0);
92 
93  if (key_bits == 128) {
94  aes128gcmsiv_aes_ks(key, &gcm_siv_ctx->key[0]);
95  gcm_siv_ctx->is_128_bit = 1;
96  } else {
97  aes256gcmsiv_aes_ks(key, &gcm_siv_ctx->key[0]);
98  gcm_siv_ctx->is_128_bit = 0;
99  }
100 
101  ctx->tag_len = tag_len;
102 
103  return 1;
104 }
105 
106 static void aead_aes_gcm_siv_asm_cleanup(EVP_AEAD_CTX *ctx) {}
107 
108 // aesgcmsiv_polyval_horner updates the POLYVAL value in |in_out_poly| to
109 // include a number (|in_blocks|) of 16-byte blocks of data from |in|, given
110 // the POLYVAL key in |key|.
111 extern void aesgcmsiv_polyval_horner(const uint8_t in_out_poly[16],
112  const uint8_t key[16], const uint8_t *in,
113  size_t in_blocks);
114 
115 // aesgcmsiv_htable_init writes powers 1..8 of |auth_key| to |out_htable|.
116 extern void aesgcmsiv_htable_init(uint8_t out_htable[16 * 8],
117  const uint8_t auth_key[16]);
118 
119 // aesgcmsiv_htable6_init writes powers 1..6 of |auth_key| to |out_htable|.
120 extern void aesgcmsiv_htable6_init(uint8_t out_htable[16 * 6],
121  const uint8_t auth_key[16]);
122 
123 // aesgcmsiv_htable_polyval updates the POLYVAL value in |in_out_poly| to
124 // include |in_len| bytes of data from |in|. (Where |in_len| must be a multiple
125 // of 16.) It uses the precomputed powers of the key given in |htable|.
126 extern void aesgcmsiv_htable_polyval(const uint8_t htable[16 * 8],
127  const uint8_t *in, size_t in_len,
128  uint8_t in_out_poly[16]);
129 
130 // aes128gcmsiv_dec decrypts |in_len| & ~15 bytes from |out| and writes them to
131 // |in|. (The full value of |in_len| is still used to find the authentication
132 // tag appended to the ciphertext, however, so must not be pre-masked.)
133 //
134 // |in| and |out| may be equal, but must not otherwise overlap.
135 //
136 // While decrypting, it updates the POLYVAL value found at the beginning of
137 // |in_out_calculated_tag_and_scratch| and writes the updated value back before
138 // return. During executation, it may use the whole of this space for other
139 // purposes. In order to decrypt and update the POLYVAL value, it uses the
140 // expanded key from |key| and the table of powers in |htable|.
141 extern void aes128gcmsiv_dec(const uint8_t *in, uint8_t *out,
142  uint8_t in_out_calculated_tag_and_scratch[16 * 8],
143  const uint8_t htable[16 * 6],
144  const struct aead_aes_gcm_siv_asm_ctx *key,
145  size_t in_len);
146 
147 // aes256gcmsiv_dec acts like |aes128gcmsiv_dec|, but for AES-256.
148 extern void aes256gcmsiv_dec(const uint8_t *in, uint8_t *out,
149  uint8_t in_out_calculated_tag_and_scratch[16 * 8],
150  const uint8_t htable[16 * 6],
151  const struct aead_aes_gcm_siv_asm_ctx *key,
152  size_t in_len);
153 
154 // aes128gcmsiv_kdf performs the AES-GCM-SIV KDF given the expanded key from
155 // |key_schedule| and the nonce in |nonce|. Note that, while only 12 bytes of
156 // the nonce are used, 16 bytes are read and so the value must be
157 // right-padded.
158 extern void aes128gcmsiv_kdf(const uint8_t nonce[16],
159  uint64_t out_key_material[8],
160  const uint8_t *key_schedule);
161 
162 // aes256gcmsiv_kdf acts like |aes128gcmsiv_kdf|, but for AES-256.
163 extern void aes256gcmsiv_kdf(const uint8_t nonce[16],
164  uint64_t out_key_material[12],
165  const uint8_t *key_schedule);
166 
167 // aes128gcmsiv_aes_ks_enc_x1 performs a key expansion of the AES-128 key in
168 // |key|, writes the expanded key to |out_expanded_key| and encrypts a single
169 // block from |in| to |out|.
170 extern void aes128gcmsiv_aes_ks_enc_x1(const uint8_t in[16], uint8_t out[16],
171  uint8_t out_expanded_key[16 * 15],
172  const uint64_t key[2]);
173 
174 // aes256gcmsiv_aes_ks_enc_x1 acts like |aes128gcmsiv_aes_ks_enc_x1|, but for
175 // AES-256.
176 extern void aes256gcmsiv_aes_ks_enc_x1(const uint8_t in[16], uint8_t out[16],
177  uint8_t out_expanded_key[16 * 15],
178  const uint64_t key[4]);
179 
180 // aes128gcmsiv_ecb_enc_block encrypts a single block from |in| to |out| using
181 // the expanded key in |expanded_key|.
182 extern void aes128gcmsiv_ecb_enc_block(
183  const uint8_t in[16], uint8_t out[16],
184  const struct aead_aes_gcm_siv_asm_ctx *expanded_key);
185 
186 // aes256gcmsiv_ecb_enc_block acts like |aes128gcmsiv_ecb_enc_block|, but for
187 // AES-256.
188 extern void aes256gcmsiv_ecb_enc_block(
189  const uint8_t in[16], uint8_t out[16],
190  const struct aead_aes_gcm_siv_asm_ctx *expanded_key);
191 
192 // aes128gcmsiv_enc_msg_x4 encrypts |in_len| bytes from |in| to |out| using the
193 // expanded key from |key|. (The value of |in_len| must be a multiple of 16.)
194 // The |in| and |out| buffers may be equal but must not otherwise overlap. The
195 // initial counter is constructed from the given |tag| as required by
196 // AES-GCM-SIV.
197 extern void aes128gcmsiv_enc_msg_x4(const uint8_t *in, uint8_t *out,
198  const uint8_t *tag,
199  const struct aead_aes_gcm_siv_asm_ctx *key,
200  size_t in_len);
201 
202 // aes256gcmsiv_enc_msg_x4 acts like |aes128gcmsiv_enc_msg_x4|, but for
203 // AES-256.
204 extern void aes256gcmsiv_enc_msg_x4(const uint8_t *in, uint8_t *out,
205  const uint8_t *tag,
206  const struct aead_aes_gcm_siv_asm_ctx *key,
207  size_t in_len);
208 
209 // aes128gcmsiv_enc_msg_x8 acts like |aes128gcmsiv_enc_msg_x4|, but is
210 // optimised for longer messages.
211 extern void aes128gcmsiv_enc_msg_x8(const uint8_t *in, uint8_t *out,
212  const uint8_t *tag,
213  const struct aead_aes_gcm_siv_asm_ctx *key,
214  size_t in_len);
215 
216 // aes256gcmsiv_enc_msg_x8 acts like |aes256gcmsiv_enc_msg_x4|, but is
217 // optimised for longer messages.
218 extern void aes256gcmsiv_enc_msg_x8(const uint8_t *in, uint8_t *out,
219  const uint8_t *tag,
220  const struct aead_aes_gcm_siv_asm_ctx *key,
221  size_t in_len);
222 
223 // gcm_siv_asm_polyval evaluates POLYVAL at |auth_key| on the given plaintext
224 // and AD. The result is written to |out_tag|.
225 static void gcm_siv_asm_polyval(uint8_t out_tag[16], const uint8_t *in,
226  size_t in_len, const uint8_t *ad, size_t ad_len,
227  const uint8_t auth_key[16],
228  const uint8_t nonce[12]) {
229  OPENSSL_memset(out_tag, 0, 16);
230  const size_t ad_blocks = ad_len / 16;
231  const size_t in_blocks = in_len / 16;
232  int htable_init = 0;
233  alignas(16) uint8_t htable[16*8];
234 
235  if (ad_blocks > 8 || in_blocks > 8) {
236  htable_init = 1;
237  aesgcmsiv_htable_init(htable, auth_key);
238  }
239 
240  if (htable_init) {
241  aesgcmsiv_htable_polyval(htable, ad, ad_len & ~15, out_tag);
242  } else {
243  aesgcmsiv_polyval_horner(out_tag, auth_key, ad, ad_blocks);
244  }
245 
246  uint8_t scratch[16];
247  if (ad_len & 15) {
248  OPENSSL_memset(scratch, 0, sizeof(scratch));
249  OPENSSL_memcpy(scratch, &ad[ad_len & ~15], ad_len & 15);
250  aesgcmsiv_polyval_horner(out_tag, auth_key, scratch, 1);
251  }
252 
253  if (htable_init) {
254  aesgcmsiv_htable_polyval(htable, in, in_len & ~15, out_tag);
255  } else {
256  aesgcmsiv_polyval_horner(out_tag, auth_key, in, in_blocks);
257  }
258 
259  if (in_len & 15) {
260  OPENSSL_memset(scratch, 0, sizeof(scratch));
261  OPENSSL_memcpy(scratch, &in[in_len & ~15], in_len & 15);
262  aesgcmsiv_polyval_horner(out_tag, auth_key, scratch, 1);
263  }
264 
265  union {
266  uint8_t c[16];
267  struct {
268  uint64_t ad;
269  uint64_t in;
270  } bitlens;
271  } length_block;
272 
273  length_block.bitlens.ad = ad_len * 8;
274  length_block.bitlens.in = in_len * 8;
275  aesgcmsiv_polyval_horner(out_tag, auth_key, length_block.c, 1);
276 
277  for (size_t i = 0; i < 12; i++) {
278  out_tag[i] ^= nonce[i];
279  }
280 
281  out_tag[15] &= 0x7f;
282 }
283 
284 // aead_aes_gcm_siv_asm_crypt_last_block handles the encryption/decryption
285 // (same thing in CTR mode) of the final block of a plaintext/ciphertext. It
286 // writes |in_len| & 15 bytes to |out| + |in_len|, based on an initial counter
287 // derived from |tag|.
288 static void aead_aes_gcm_siv_asm_crypt_last_block(
289  int is_128_bit, uint8_t *out, const uint8_t *in, size_t in_len,
290  const uint8_t tag[16],
291  const struct aead_aes_gcm_siv_asm_ctx *enc_key_expanded) {
292  alignas(16) union {
293  uint8_t c[16];
294  uint32_t u32[4];
295  } counter;
296  OPENSSL_memcpy(&counter, tag, sizeof(counter));
297  counter.c[15] |= 0x80;
298  counter.u32[0] += in_len / 16;
299 
300  if (is_128_bit) {
301  aes128gcmsiv_ecb_enc_block(&counter.c[0], &counter.c[0], enc_key_expanded);
302  } else {
303  aes256gcmsiv_ecb_enc_block(&counter.c[0], &counter.c[0], enc_key_expanded);
304  }
305 
306  const size_t last_bytes_offset = in_len & ~15;
307  const size_t last_bytes_len = in_len & 15;
308  uint8_t *last_bytes_out = &out[last_bytes_offset];
309  const uint8_t *last_bytes_in = &in[last_bytes_offset];
310  for (size_t i = 0; i < last_bytes_len; i++) {
311  last_bytes_out[i] = last_bytes_in[i] ^ counter.c[i];
312  }
313 }
314 
315 // aead_aes_gcm_siv_kdf calculates the record encryption and authentication
316 // keys given the |nonce|.
317 static void aead_aes_gcm_siv_kdf(
318  int is_128_bit, const struct aead_aes_gcm_siv_asm_ctx *gcm_siv_ctx,
319  uint64_t out_record_auth_key[2], uint64_t out_record_enc_key[4],
320  const uint8_t nonce[12]) {
321  alignas(16) uint8_t padded_nonce[16];
322  OPENSSL_memcpy(padded_nonce, nonce, 12);
323 
324  alignas(16) uint64_t key_material[12];
325  if (is_128_bit) {
326  aes128gcmsiv_kdf(padded_nonce, key_material, &gcm_siv_ctx->key[0]);
327  out_record_enc_key[0] = key_material[4];
328  out_record_enc_key[1] = key_material[6];
329  } else {
330  aes256gcmsiv_kdf(padded_nonce, key_material, &gcm_siv_ctx->key[0]);
331  out_record_enc_key[0] = key_material[4];
332  out_record_enc_key[1] = key_material[6];
333  out_record_enc_key[2] = key_material[8];
334  out_record_enc_key[3] = key_material[10];
335  }
336 
337  out_record_auth_key[0] = key_material[0];
338  out_record_auth_key[1] = key_material[2];
339 }
340 
341 static int aead_aes_gcm_siv_asm_seal_scatter(
342  const EVP_AEAD_CTX *ctx, uint8_t *out, uint8_t *out_tag,
343  size_t *out_tag_len, size_t max_out_tag_len, const uint8_t *nonce,
344  size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *extra_in,
345  size_t extra_in_len, const uint8_t *ad, size_t ad_len) {
346  const struct aead_aes_gcm_siv_asm_ctx *gcm_siv_ctx = asm_ctx_from_ctx(ctx);
347  const uint64_t in_len_64 = in_len;
348  const uint64_t ad_len_64 = ad_len;
349 
350  if (in_len_64 > (UINT64_C(1) << 36) ||
351  ad_len_64 >= (UINT64_C(1) << 61)) {
353  return 0;
354  }
355 
356  if (max_out_tag_len < EVP_AEAD_AES_GCM_SIV_TAG_LEN) {
358  return 0;
359  }
360 
361  if (nonce_len != EVP_AEAD_AES_GCM_SIV_NONCE_LEN) {
363  return 0;
364  }
365 
366  alignas(16) uint64_t record_auth_key[2];
367  alignas(16) uint64_t record_enc_key[4];
368  aead_aes_gcm_siv_kdf(gcm_siv_ctx->is_128_bit, gcm_siv_ctx, record_auth_key,
369  record_enc_key, nonce);
370 
371  alignas(16) uint8_t tag[16] = {0};
372  gcm_siv_asm_polyval(tag, in, in_len, ad, ad_len,
373  (const uint8_t *)record_auth_key, nonce);
374 
375  struct aead_aes_gcm_siv_asm_ctx enc_key_expanded;
376 
377  if (gcm_siv_ctx->is_128_bit) {
378  aes128gcmsiv_aes_ks_enc_x1(tag, tag, &enc_key_expanded.key[0],
379  record_enc_key);
380 
381  if (in_len < 128) {
382  aes128gcmsiv_enc_msg_x4(in, out, tag, &enc_key_expanded, in_len & ~15);
383  } else {
384  aes128gcmsiv_enc_msg_x8(in, out, tag, &enc_key_expanded, in_len & ~15);
385  }
386  } else {
387  aes256gcmsiv_aes_ks_enc_x1(tag, tag, &enc_key_expanded.key[0],
388  record_enc_key);
389 
390  if (in_len < 128) {
391  aes256gcmsiv_enc_msg_x4(in, out, tag, &enc_key_expanded, in_len & ~15);
392  } else {
393  aes256gcmsiv_enc_msg_x8(in, out, tag, &enc_key_expanded, in_len & ~15);
394  }
395  }
396 
397  if (in_len & 15) {
398  aead_aes_gcm_siv_asm_crypt_last_block(gcm_siv_ctx->is_128_bit, out, in,
399  in_len, tag, &enc_key_expanded);
400  }
401 
402  OPENSSL_memcpy(out_tag, tag, sizeof(tag));
403  *out_tag_len = EVP_AEAD_AES_GCM_SIV_TAG_LEN;
404 
405  return 1;
406 }
407 
408 // TODO(martinkr): Add aead_aes_gcm_siv_asm_open_gather. N.B. aes128gcmsiv_dec
409 // expects ciphertext and tag in a contiguous buffer.
410 
411 static int aead_aes_gcm_siv_asm_open(const EVP_AEAD_CTX *ctx, uint8_t *out,
412  size_t *out_len, size_t max_out_len,
413  const uint8_t *nonce, size_t nonce_len,
414  const uint8_t *in, size_t in_len,
415  const uint8_t *ad, size_t ad_len) {
416  const uint64_t ad_len_64 = ad_len;
417  if (ad_len_64 >= (UINT64_C(1) << 61)) {
419  return 0;
420  }
421 
422  const uint64_t in_len_64 = in_len;
423  if (in_len < EVP_AEAD_AES_GCM_SIV_TAG_LEN ||
424  in_len_64 > (UINT64_C(1) << 36) + AES_BLOCK_SIZE) {
426  return 0;
427  }
428 
429  if (nonce_len != EVP_AEAD_AES_GCM_SIV_NONCE_LEN) {
431  return 0;
432  }
433 
434  const struct aead_aes_gcm_siv_asm_ctx *gcm_siv_ctx = asm_ctx_from_ctx(ctx);
435  const size_t plaintext_len = in_len - EVP_AEAD_AES_GCM_SIV_TAG_LEN;
436  const uint8_t *const given_tag = in + plaintext_len;
437 
438  if (max_out_len < plaintext_len) {
440  return 0;
441  }
442 
443  alignas(16) uint64_t record_auth_key[2];
444  alignas(16) uint64_t record_enc_key[4];
445  aead_aes_gcm_siv_kdf(gcm_siv_ctx->is_128_bit, gcm_siv_ctx, record_auth_key,
446  record_enc_key, nonce);
447 
448  struct aead_aes_gcm_siv_asm_ctx expanded_key;
449  if (gcm_siv_ctx->is_128_bit) {
450  aes128gcmsiv_aes_ks((const uint8_t *) record_enc_key, &expanded_key.key[0]);
451  } else {
452  aes256gcmsiv_aes_ks((const uint8_t *) record_enc_key, &expanded_key.key[0]);
453  }
454  // calculated_tag is 16*8 bytes, rather than 16 bytes, because
455  // aes[128|256]gcmsiv_dec uses the extra as scratch space.
456  alignas(16) uint8_t calculated_tag[16 * 8] = {0};
457 
458  OPENSSL_memset(calculated_tag, 0, EVP_AEAD_AES_GCM_SIV_TAG_LEN);
459  const size_t ad_blocks = ad_len / 16;
460  aesgcmsiv_polyval_horner(calculated_tag, (const uint8_t *)record_auth_key, ad,
461  ad_blocks);
462 
463  uint8_t scratch[16];
464  if (ad_len & 15) {
465  OPENSSL_memset(scratch, 0, sizeof(scratch));
466  OPENSSL_memcpy(scratch, &ad[ad_len & ~15], ad_len & 15);
467  aesgcmsiv_polyval_horner(calculated_tag, (const uint8_t *)record_auth_key,
468  scratch, 1);
469  }
470 
471  alignas(16) uint8_t htable[16 * 6];
472  aesgcmsiv_htable6_init(htable, (const uint8_t *)record_auth_key);
473 
474  if (gcm_siv_ctx->is_128_bit) {
475  aes128gcmsiv_dec(in, out, calculated_tag, htable, &expanded_key,
476  plaintext_len);
477  } else {
478  aes256gcmsiv_dec(in, out, calculated_tag, htable, &expanded_key,
479  plaintext_len);
480  }
481 
482  if (plaintext_len & 15) {
483  aead_aes_gcm_siv_asm_crypt_last_block(gcm_siv_ctx->is_128_bit, out, in,
484  plaintext_len, given_tag,
485  &expanded_key);
486  OPENSSL_memset(scratch, 0, sizeof(scratch));
487  OPENSSL_memcpy(scratch, out + (plaintext_len & ~15), plaintext_len & 15);
488  aesgcmsiv_polyval_horner(calculated_tag, (const uint8_t *)record_auth_key,
489  scratch, 1);
490  }
491 
492  union {
493  uint8_t c[16];
494  struct {
495  uint64_t ad;
496  uint64_t in;
497  } bitlens;
498  } length_block;
499 
500  length_block.bitlens.ad = ad_len * 8;
501  length_block.bitlens.in = plaintext_len * 8;
502  aesgcmsiv_polyval_horner(calculated_tag, (const uint8_t *)record_auth_key,
503  length_block.c, 1);
504 
505  for (size_t i = 0; i < 12; i++) {
506  calculated_tag[i] ^= nonce[i];
507  }
508 
509  calculated_tag[15] &= 0x7f;
510 
511  if (gcm_siv_ctx->is_128_bit) {
512  aes128gcmsiv_ecb_enc_block(calculated_tag, calculated_tag, &expanded_key);
513  } else {
514  aes256gcmsiv_ecb_enc_block(calculated_tag, calculated_tag, &expanded_key);
515  }
516 
517  if (CRYPTO_memcmp(calculated_tag, given_tag, EVP_AEAD_AES_GCM_SIV_TAG_LEN) !=
518  0) {
520  return 0;
521  }
522 
523  *out_len = in_len - EVP_AEAD_AES_GCM_SIV_TAG_LEN;
524  return 1;
525 }
526 
527 static const EVP_AEAD aead_aes_128_gcm_siv_asm = {
528  16, // key length
529  EVP_AEAD_AES_GCM_SIV_NONCE_LEN, // nonce length
530  EVP_AEAD_AES_GCM_SIV_TAG_LEN, // overhead
531  EVP_AEAD_AES_GCM_SIV_TAG_LEN, // max tag length
532  0, // seal_scatter_supports_extra_in
533 
534  aead_aes_gcm_siv_asm_init,
535  NULL /* init_with_direction */,
536  aead_aes_gcm_siv_asm_cleanup,
537  aead_aes_gcm_siv_asm_open,
538  aead_aes_gcm_siv_asm_seal_scatter,
539  NULL /* open_gather */,
540  NULL /* get_iv */,
541  NULL /* tag_len */,
542 };
543 
544 static const EVP_AEAD aead_aes_256_gcm_siv_asm = {
545  32, // key length
546  EVP_AEAD_AES_GCM_SIV_NONCE_LEN, // nonce length
547  EVP_AEAD_AES_GCM_SIV_TAG_LEN, // overhead
548  EVP_AEAD_AES_GCM_SIV_TAG_LEN, // max tag length
549  0, // seal_scatter_supports_extra_in
550 
551  aead_aes_gcm_siv_asm_init,
552  NULL /* init_with_direction */,
553  aead_aes_gcm_siv_asm_cleanup,
554  aead_aes_gcm_siv_asm_open,
555  aead_aes_gcm_siv_asm_seal_scatter,
556  NULL /* open_gather */,
557  NULL /* get_iv */,
558  NULL /* tag_len */,
559 };
560 
561 #endif // X86_64 && !NO_ASM && !WINDOWS
562 
564  union {
565  double align;
567  } ks;
569  unsigned is_256:1;
570 };
571 
572 OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) >=
573  sizeof(struct aead_aes_gcm_siv_ctx),
574  "AEAD state is too small");
575 #if defined(__GNUC__) || defined(__clang__)
577  alignof(struct aead_aes_gcm_siv_ctx),
578  "AEAD state has insufficient alignment");
579 #endif
580 
582  size_t key_len, size_t tag_len) {
583  const size_t key_bits = key_len * 8;
584 
585  if (key_bits != 128 && key_bits != 256) {
587  return 0; // EVP_AEAD_CTX_init should catch this.
588  }
589 
590  if (tag_len == EVP_AEAD_DEFAULT_TAG_LENGTH) {
592  }
593  if (tag_len != EVP_AEAD_AES_GCM_SIV_TAG_LEN) {
595  return 0;
596  }
597 
598  struct aead_aes_gcm_siv_ctx *gcm_siv_ctx =
599  (struct aead_aes_gcm_siv_ctx *)&ctx->state;
600  OPENSSL_memset(gcm_siv_ctx, 0, sizeof(struct aead_aes_gcm_siv_ctx));
601 
602  aes_ctr_set_key(&gcm_siv_ctx->ks.ks, NULL, &gcm_siv_ctx->kgk_block, key,
603  key_len);
604  gcm_siv_ctx->is_256 = (key_len == 32);
605  ctx->tag_len = tag_len;
606 
607  return 1;
608 }
609 
611 
612 // gcm_siv_crypt encrypts (or decrypts—it's the same thing) |in_len| bytes from
613 // |in| to |out|, using the block function |enc_block| with |key| in counter
614 // mode, starting at |initial_counter|. This differs from the traditional
615 // counter mode code in that the counter is handled little-endian, only the
616 // first four bytes are used and the GCM-SIV tweak to the final byte is
617 // applied. The |in| and |out| pointers may be equal but otherwise must not
618 // alias.
619 static void gcm_siv_crypt(uint8_t *out, const uint8_t *in, size_t in_len,
620  const uint8_t initial_counter[AES_BLOCK_SIZE],
621  block128_f enc_block, const AES_KEY *key) {
622  union {
623  uint32_t w[4];
624  uint8_t c[16];
625  } counter;
626 
627  OPENSSL_memcpy(counter.c, initial_counter, AES_BLOCK_SIZE);
628  counter.c[15] |= 0x80;
629 
630  for (size_t done = 0; done < in_len;) {
631  uint8_t keystream[AES_BLOCK_SIZE];
632  enc_block(counter.c, keystream, key);
633  counter.w[0]++;
634 
635  size_t todo = AES_BLOCK_SIZE;
636  if (in_len - done < todo) {
637  todo = in_len - done;
638  }
639 
640  for (size_t i = 0; i < todo; i++) {
641  out[done + i] = keystream[i] ^ in[done + i];
642  }
643 
644  done += todo;
645  }
646 }
647 
648 // gcm_siv_polyval evaluates POLYVAL at |auth_key| on the given plaintext and
649 // AD. The result is written to |out_tag|.
650 static void gcm_siv_polyval(
651  uint8_t out_tag[16], const uint8_t *in, size_t in_len, const uint8_t *ad,
652  size_t ad_len, const uint8_t auth_key[16],
654  struct polyval_ctx polyval_ctx;
655  CRYPTO_POLYVAL_init(&polyval_ctx, auth_key);
656 
657  CRYPTO_POLYVAL_update_blocks(&polyval_ctx, ad, ad_len & ~15);
658 
659  uint8_t scratch[16];
660  if (ad_len & 15) {
661  OPENSSL_memset(scratch, 0, sizeof(scratch));
662  OPENSSL_memcpy(scratch, &ad[ad_len & ~15], ad_len & 15);
664  }
665 
667  if (in_len & 15) {
668  OPENSSL_memset(scratch, 0, sizeof(scratch));
669  OPENSSL_memcpy(scratch, &in[in_len & ~15], in_len & 15);
671  }
672 
673  union {
674  uint8_t c[16];
675  struct {
676  uint64_t ad;
677  uint64_t in;
678  } bitlens;
679  } length_block;
680 
681  length_block.bitlens.ad = ad_len * 8;
682  length_block.bitlens.in = in_len * 8;
683  CRYPTO_POLYVAL_update_blocks(&polyval_ctx, length_block.c,
684  sizeof(length_block));
685 
687  for (size_t i = 0; i < EVP_AEAD_AES_GCM_SIV_NONCE_LEN; i++) {
688  out_tag[i] ^= nonce[i];
689  }
690  out_tag[15] &= 0x7f;
691 }
692 
693 // gcm_siv_record_keys contains the keys used for a specific GCM-SIV record.
696  union {
697  double align;
699  } enc_key;
701 };
702 
703 // gcm_siv_keys calculates the keys for a specific GCM-SIV record with the
704 // given nonce and writes them to |*out_keys|.
705 static void gcm_siv_keys(
706  const struct aead_aes_gcm_siv_ctx *gcm_siv_ctx,
707  struct gcm_siv_record_keys *out_keys,
709  const AES_KEY *const key = &gcm_siv_ctx->ks.ks;
710  uint8_t key_material[(128 /* POLYVAL key */ + 256 /* max AES key */) / 8];
711  const size_t blocks_needed = gcm_siv_ctx->is_256 ? 6 : 4;
712 
717  for (size_t i = 0; i < blocks_needed; i++) {
718  counter[0] = i;
719 
721  gcm_siv_ctx->kgk_block(counter, ciphertext, key);
722  OPENSSL_memcpy(&key_material[i * 8], ciphertext, 8);
723  }
724 
725  OPENSSL_memcpy(out_keys->auth_key, key_material, 16);
726  // Note the |ctr128_f| function uses a big-endian couner, while AES-GCM-SIV
727  // uses a little-endian counter. We ignore the return value and only use
728  // |block128_f|. This has a significant performance cost for the fallback
729  // bitsliced AES implementations (bsaes and aes_nohw).
730  //
731  // We currently do not consider AES-GCM-SIV to be performance-sensitive on
732  // client hardware. If this changes, we can write little-endian |ctr128_f|
733  // functions.
734  aes_ctr_set_key(&out_keys->enc_key.ks, NULL, &out_keys->enc_block,
735  key_material + 16, gcm_siv_ctx->is_256 ? 32 : 16);
736 }
737 
739  const EVP_AEAD_CTX *ctx, uint8_t *out, uint8_t *out_tag,
740  size_t *out_tag_len, size_t max_out_tag_len, const uint8_t *nonce,
741  size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *extra_in,
742  size_t extra_in_len, const uint8_t *ad, size_t ad_len) {
743  const struct aead_aes_gcm_siv_ctx *gcm_siv_ctx =
744  (struct aead_aes_gcm_siv_ctx *)&ctx->state;
745  const uint64_t in_len_64 = in_len;
746  const uint64_t ad_len_64 = ad_len;
747 
748  if (in_len + EVP_AEAD_AES_GCM_SIV_TAG_LEN < in_len ||
749  in_len_64 > (UINT64_C(1) << 36) ||
750  ad_len_64 >= (UINT64_C(1) << 61)) {
752  return 0;
753  }
754 
755  if (max_out_tag_len < EVP_AEAD_AES_GCM_SIV_TAG_LEN) {
757  return 0;
758  }
759 
760  if (nonce_len != EVP_AEAD_AES_GCM_SIV_NONCE_LEN) {
762  return 0;
763  }
764 
765  struct gcm_siv_record_keys keys;
766  gcm_siv_keys(gcm_siv_ctx, &keys, nonce);
767 
768  uint8_t tag[16];
769  gcm_siv_polyval(tag, in, in_len, ad, ad_len, keys.auth_key, nonce);
770  keys.enc_block(tag, tag, &keys.enc_key.ks);
771 
772  gcm_siv_crypt(out, in, in_len, tag, keys.enc_block, &keys.enc_key.ks);
773 
775  *out_tag_len = EVP_AEAD_AES_GCM_SIV_TAG_LEN;
776 
777  return 1;
778 }
779 
781  const uint8_t *nonce, size_t nonce_len,
782  const uint8_t *in, size_t in_len,
783  const uint8_t *in_tag,
784  size_t in_tag_len, const uint8_t *ad,
785  size_t ad_len) {
786  const uint64_t ad_len_64 = ad_len;
787  if (ad_len_64 >= (UINT64_C(1) << 61)) {
789  return 0;
790  }
791 
792  const uint64_t in_len_64 = in_len;
793  if (in_tag_len != EVP_AEAD_AES_GCM_SIV_TAG_LEN ||
794  in_len_64 > (UINT64_C(1) << 36) + AES_BLOCK_SIZE) {
796  return 0;
797  }
798 
799  if (nonce_len != EVP_AEAD_AES_GCM_SIV_NONCE_LEN) {
801  return 0;
802  }
803 
804  const struct aead_aes_gcm_siv_ctx *gcm_siv_ctx =
805  (struct aead_aes_gcm_siv_ctx *)&ctx->state;
806 
807  struct gcm_siv_record_keys keys;
808  gcm_siv_keys(gcm_siv_ctx, &keys, nonce);
809 
810  gcm_siv_crypt(out, in, in_len, in_tag, keys.enc_block, &keys.enc_key.ks);
811 
813  gcm_siv_polyval(expected_tag, out, in_len, ad, ad_len, keys.auth_key, nonce);
814  keys.enc_block(expected_tag, expected_tag, &keys.enc_key.ks);
815 
816  if (CRYPTO_memcmp(expected_tag, in_tag, sizeof(expected_tag)) != 0) {
818  return 0;
819  }
820 
821  return 1;
822 }
823 
825  16, // key length
826  EVP_AEAD_AES_GCM_SIV_NONCE_LEN, // nonce length
827  EVP_AEAD_AES_GCM_SIV_TAG_LEN, // overhead
828  EVP_AEAD_AES_GCM_SIV_TAG_LEN, // max tag length
829  0, // seal_scatter_supports_extra_in
830 
832  NULL /* init_with_direction */,
834  NULL /* open */,
837  NULL /* get_iv */,
838  NULL /* tag_len */,
839 };
840 
842  32, // key length
843  EVP_AEAD_AES_GCM_SIV_NONCE_LEN, // nonce length
844  EVP_AEAD_AES_GCM_SIV_TAG_LEN, // overhead
845  EVP_AEAD_AES_GCM_SIV_TAG_LEN, // max tag length
846  0, // seal_scatter_supports_extra_in
847 
849  NULL /* init_with_direction */,
851  NULL /* open */,
854  NULL /* get_iv */,
855  NULL /* tag_len */,
856 };
857 
858 #if defined(AES_GCM_SIV_ASM)
859 
860 static char avx_aesni_capable(void) {
861  const uint32_t ecx = OPENSSL_ia32cap_P[1];
862 
863  return (ecx & (1 << (57 - 32))) != 0 /* AESNI */ &&
864  (ecx & (1 << 28)) != 0 /* AVX */;
865 }
866 
867 const EVP_AEAD *EVP_aead_aes_128_gcm_siv(void) {
868  if (avx_aesni_capable()) {
869  return &aead_aes_128_gcm_siv_asm;
870  }
871  return &aead_aes_128_gcm_siv;
872 }
873 
874 const EVP_AEAD *EVP_aead_aes_256_gcm_siv(void) {
875  if (avx_aesni_capable()) {
876  return &aead_aes_256_gcm_siv_asm;
877  }
878  return &aead_aes_256_gcm_siv;
879 }
880 
881 #else
882 
884  return &aead_aes_128_gcm_siv;
885 }
886 
888  return &aead_aes_256_gcm_siv;
889 }
890 
891 #endif // AES_GCM_SIV_ASM
gen_build_yaml.out
dictionary out
Definition: src/benchmark/gen_build_yaml.py:24
gcm_siv_polyval
static void gcm_siv_polyval(uint8_t out_tag[16], const uint8_t *in, size_t in_len, const uint8_t *ad, size_t ad_len, const uint8_t auth_key[16], const uint8_t nonce[EVP_AEAD_AES_GCM_SIV_NONCE_LEN])
Definition: e_aesgcmsiv.c:650
aes256gcmsiv_kdf
#define aes256gcmsiv_kdf
Definition: boringssl_prefix_symbols.h:2806
ctx
Definition: benchmark-async.c:30
aes128gcmsiv_kdf
#define aes128gcmsiv_kdf
Definition: boringssl_prefix_symbols.h:2799
aesgcmsiv_polyval_horner
#define aesgcmsiv_polyval_horner
Definition: boringssl_prefix_symbols.h:2824
keys
const void * keys
Definition: abseil-cpp/absl/random/internal/randen.cc:49
OPENSSL_PUT_ERROR
#define OPENSSL_PUT_ERROR(library, reason)
Definition: err.h:423
aes256gcmsiv_enc_msg_x4
#define aes256gcmsiv_enc_msg_x4
Definition: boringssl_prefix_symbols.h:2804
ciphertext
const char * ciphertext
Definition: protobuf/src/google/protobuf/stubs/strutil_unittest.cc:86
OPENSSL_STATIC_ASSERT
OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *) NULL) ->state) >=sizeof(struct aead_aes_gcm_siv_ctx), "AEAD state is too small")
aead_aes_gcm_siv_ctx::kgk_block
block128_f kgk_block
Definition: e_aesgcmsiv.c:568
CIPHER_R_BAD_KEY_LENGTH
#define CIPHER_R_BAD_KEY_LENGTH
Definition: cipher.h:648
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
OPENSSL_memset
static void * OPENSSL_memset(void *dst, int c, size_t n)
Definition: third_party/boringssl-with-bazel/src/crypto/internal.h:835
aes256gcmsiv_ecb_enc_block
#define aes256gcmsiv_ecb_enc_block
Definition: boringssl_prefix_symbols.h:2803
aead_aes_gcm_siv_cleanup
static void aead_aes_gcm_siv_cleanup(EVP_AEAD_CTX *ctx)
Definition: e_aesgcmsiv.c:610
AES_BLOCK_SIZE
#define AES_BLOCK_SIZE
Definition: aes.h:68
gcm_siv_record_keys::ks
AES_KEY ks
Definition: e_aesgcmsiv.c:698
EVP_AEAD_DEFAULT_TAG_LENGTH
#define EVP_AEAD_DEFAULT_TAG_LENGTH
Definition: aead.h:240
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
aead_aes_gcm_siv_seal_scatter
static int aead_aes_gcm_siv_seal_scatter(const EVP_AEAD_CTX *ctx, uint8_t *out, uint8_t *out_tag, size_t *out_tag_len, size_t max_out_tag_len, const uint8_t *nonce, size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *extra_in, size_t extra_in_len, const uint8_t *ad, size_t ad_len)
Definition: e_aesgcmsiv.c:738
aes256gcmsiv_aes_ks
#define aes256gcmsiv_aes_ks
Definition: boringssl_prefix_symbols.h:2800
aes128gcmsiv_aes_ks
#define aes128gcmsiv_aes_ks
Definition: boringssl_prefix_symbols.h:2793
in
const char * in
Definition: third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc:391
c
void c(T a)
Definition: miscompile_with_no_unique_address_test.cc:40
OPENSSL_ia32cap_P
#define OPENSSL_ia32cap_P
Definition: boringssl_prefix_symbols.h:1874
gcm_siv_record_keys::auth_key
uint8_t auth_key[16]
Definition: e_aesgcmsiv.c:695
tag
static void * tag(intptr_t t)
Definition: bad_client.cc:318
evp_aead_ctx_st_state
Definition: aead.h:210
aes256gcmsiv_aes_ks_enc_x1
#define aes256gcmsiv_aes_ks_enc_x1
Definition: boringssl_prefix_symbols.h:2801
aead_aes_gcm_siv_ctx::align
double align
Definition: e_aesgcmsiv.c:565
gcm_siv_keys
static void gcm_siv_keys(const struct aead_aes_gcm_siv_ctx *gcm_siv_ctx, struct gcm_siv_record_keys *out_keys, const uint8_t nonce[EVP_AEAD_AES_GCM_SIV_NONCE_LEN])
Definition: e_aesgcmsiv.c:705
EVP_aead_aes_128_gcm_siv
const EVP_AEAD * EVP_aead_aes_128_gcm_siv(void)
Definition: e_aesgcmsiv.c:883
CIPHER_R_UNSUPPORTED_NONCE_SIZE
#define CIPHER_R_UNSUPPORTED_NONCE_SIZE
Definition: cipher.h:667
evp_aead_ctx_st
Definition: aead.h:217
CIPHER_R_TAG_TOO_LARGE
#define CIPHER_R_TAG_TOO_LARGE
Definition: cipher.h:662
aes_ctr_set_key
#define aes_ctr_set_key
Definition: boringssl_prefix_symbols.h:2807
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
aes128gcmsiv_ecb_enc_block
#define aes128gcmsiv_ecb_enc_block
Definition: boringssl_prefix_symbols.h:2796
aesgcmsiv_htable_init
#define aesgcmsiv_htable_init
Definition: boringssl_prefix_symbols.h:2822
OPENSSL_memcpy
static void * OPENSSL_memcpy(void *dst, const void *src, size_t n)
Definition: third_party/boringssl-with-bazel/src/crypto/internal.h:819
aes256gcmsiv_enc_msg_x8
#define aes256gcmsiv_enc_msg_x8
Definition: boringssl_prefix_symbols.h:2805
done
struct tab * done
Definition: bloaty/third_party/zlib/examples/enough.c:176
CRYPTO_POLYVAL_finish
#define CRYPTO_POLYVAL_finish
Definition: boringssl_prefix_symbols.h:1129
err.h
counter
static int counter
Definition: abseil-cpp/absl/flags/reflection_test.cc:131
crypto.h
cipher.h
aesgcmsiv_htable6_init
#define aesgcmsiv_htable6_init
Definition: boringssl_prefix_symbols.h:2821
aead_aes_128_gcm_siv
static const EVP_AEAD aead_aes_128_gcm_siv
Definition: e_aesgcmsiv.c:824
uintptr_t
_W64 unsigned int uintptr_t
Definition: stdint-msvc2008.h:119
EVP_aead_aes_256_gcm_siv
const EVP_AEAD * EVP_aead_aes_256_gcm_siv(void)
Definition: e_aesgcmsiv.c:887
aead.h
UINT64_C
#define UINT64_C(val)
Definition: stdint-msvc2008.h:238
aead_aes_gcm_siv_ctx::ks
AES_KEY ks
Definition: e_aesgcmsiv.c:566
CIPHER_R_BUFFER_TOO_SMALL
#define CIPHER_R_BUFFER_TOO_SMALL
Definition: cipher.h:649
gcm_siv_crypt
static void gcm_siv_crypt(uint8_t *out, const uint8_t *in, size_t in_len, const uint8_t initial_counter[AES_BLOCK_SIZE], block128_f enc_block, const AES_KEY *key)
Definition: e_aesgcmsiv.c:619
aead_aes_gcm_siv_ctx::is_256
unsigned is_256
Definition: e_aesgcmsiv.c:569
evp_aead_st
Definition: third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/internal.h:77
CRYPTO_POLYVAL_update_blocks
#define CRYPTO_POLYVAL_update_blocks
Definition: boringssl_prefix_symbols.h:1131
EVP_AEAD_AES_GCM_SIV_NONCE_LEN
#define EVP_AEAD_AES_GCM_SIV_NONCE_LEN
Definition: e_aesgcmsiv.c:27
gcm_siv_record_keys::align
double align
Definition: e_aesgcmsiv.c:697
key
const char * key
Definition: hpack_parser_table.cc:164
scratch
static char scratch[256]
Definition: test-random.c:27
CRYPTO_POLYVAL_init
#define CRYPTO_POLYVAL_init
Definition: boringssl_prefix_symbols.h:1130
aes128gcmsiv_dec
#define aes128gcmsiv_dec
Definition: boringssl_prefix_symbols.h:2795
aes128gcmsiv_aes_ks_enc_x1
#define aes128gcmsiv_aes_ks_enc_x1
Definition: boringssl_prefix_symbols.h:2794
gcm_siv_record_keys::enc_key
union gcm_siv_record_keys::@342 enc_key
state
Definition: bloaty/third_party/zlib/contrib/blast/blast.c:41
aead_aes_256_gcm_siv
static const EVP_AEAD aead_aes_256_gcm_siv
Definition: e_aesgcmsiv.c:841
CIPHER_R_TOO_LARGE
#define CIPHER_R_TOO_LARGE
Definition: cipher.h:663
cpu.h
aead_aes_gcm_siv_init
static int aead_aes_gcm_siv_init(EVP_AEAD_CTX *ctx, const uint8_t *key, size_t key_len, size_t tag_len)
Definition: e_aesgcmsiv.c:581
polyval_ctx
Definition: third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h:392
aes128gcmsiv_enc_msg_x8
#define aes128gcmsiv_enc_msg_x8
Definition: boringssl_prefix_symbols.h:2798
aes128gcmsiv_enc_msg_x4
#define aes128gcmsiv_enc_msg_x4
Definition: boringssl_prefix_symbols.h:2797
gcm_siv_record_keys::enc_block
block128_f enc_block
Definition: e_aesgcmsiv.c:700
aes256gcmsiv_dec
#define aes256gcmsiv_dec
Definition: boringssl_prefix_symbols.h:2802
gcm_siv_record_keys
Definition: e_aesgcmsiv.c:694
aead_aes_gcm_siv_open_gather
static int aead_aes_gcm_siv_open_gather(const EVP_AEAD_CTX *ctx, uint8_t *out, const uint8_t *nonce, size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *in_tag, size_t in_tag_len, const uint8_t *ad, size_t ad_len)
Definition: e_aesgcmsiv.c:780
aead_aes_gcm_siv_ctx
Definition: e_aesgcmsiv.c:563
mkowners.todo
todo
Definition: mkowners.py:209
aesgcmsiv_htable_polyval
#define aesgcmsiv_htable_polyval
Definition: boringssl_prefix_symbols.h:2823
EVP_AEAD_AES_GCM_SIV_TAG_LEN
#define EVP_AEAD_AES_GCM_SIV_TAG_LEN
Definition: e_aesgcmsiv.c:28
aes_key_st
Definition: aes.h:72
if
if(p->owned &&p->wrapped !=NULL)
Definition: call.c:42
CRYPTO_memcmp
#define CRYPTO_memcmp
Definition: boringssl_prefix_symbols.h:1178
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
block128_f
void(* block128_f)(const uint8_t in[16], uint8_t out[16], const AES_KEY *key)
Definition: third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h:76
offset
voidpf uLong offset
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:142
CIPHER_R_BAD_DECRYPT
#define CIPHER_R_BAD_DECRYPT
Definition: cipher.h:647


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:18