Coverage Report

Created: 2022-12-08 06:09

/src/libgcrypt/cipher/cipher-internal.h
Line
Count
Source (jump to first uncovered line)
1
/* cipher-internal.h  - Internal defs for cipher.c
2
 * Copyright (C) 2011 Free Software Foundation, Inc.
3
 *
4
 * This file is part of Libgcrypt.
5
 *
6
 * Libgcrypt is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU Lesser general Public License as
8
 * published by the Free Software Foundation; either version 2.1 of
9
 * the License, or (at your option) any later version.
10
 *
11
 * Libgcrypt is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
18
 */
19
20
#ifndef G10_CIPHER_INTERNAL_H
21
#define G10_CIPHER_INTERNAL_H
22
23
#include "./poly1305-internal.h"
24
25
26
/* The maximum supported size of a block in bytes.  */
27
0
#define MAX_BLOCKSIZE 16
28
29
/* The length for an OCB block.  Although OCB supports any block
30
   length it does not make sense to use a 64 bit blocklen (and cipher)
31
   because this reduces the security margin to an unacceptable state.
32
   Thus we require a cipher with 128 bit blocklength.  */
33
0
#define OCB_BLOCK_LEN  (128/8)
34
35
/* The size of the pre-computed L table for OCB.  This takes the same
36
   size as the table used for GCM and thus we don't save anything by
37
   not using such a table.  */
38
0
#define OCB_L_TABLE_SIZE 16
39
40
41
/* Check the above constants.  */
42
#if OCB_BLOCK_LEN > MAX_BLOCKSIZE
43
# error OCB_BLOCKLEN > MAX_BLOCKSIZE
44
#endif
45
46
47
48
/* Magic values for the context structure.  */
49
0
#define CTX_MAGIC_NORMAL 0x24091964
50
0
#define CTX_MAGIC_SECURE 0x46919042
51
52
/* Try to use 16 byte aligned cipher context for better performance.
53
   We use the aligned attribute, thus it is only possible to implement
54
   this with gcc.  */
55
#undef NEED_16BYTE_ALIGNED_CONTEXT
56
#ifdef HAVE_GCC_ATTRIBUTE_ALIGNED
57
# define NEED_16BYTE_ALIGNED_CONTEXT 1
58
#endif
59
60
/* Undef this symbol to trade GCM speed for 256 bytes of memory per context */
61
#define GCM_USE_TABLES 1
62
63
64
/* GCM_USE_INTEL_PCLMUL indicates whether to compile GCM with Intel PCLMUL
65
   code.  */
66
#undef GCM_USE_INTEL_PCLMUL
67
#if defined(ENABLE_PCLMUL_SUPPORT) && defined(GCM_USE_TABLES)
68
# if ((defined(__i386__) && SIZEOF_UNSIGNED_LONG == 4) || defined(__x86_64__))
69
#  if __GNUC__ >= 4
70
#   define GCM_USE_INTEL_PCLMUL 1
71
#  endif
72
# endif
73
#endif /* GCM_USE_INTEL_PCLMUL */
74
75
/* GCM_USE_INTEL_VPCLMUL_AVX2 indicates whether to compile GCM with Intel
76
   VPCLMUL/AVX2 code.  */
77
#undef GCM_USE_INTEL_VPCLMUL_AVX2
78
#if defined(__x86_64__) && defined(GCM_USE_INTEL_PCLMUL) && \
79
    defined(ENABLE_AVX2_SUPPORT) && defined(HAVE_GCC_INLINE_ASM_VAES_VPCLMUL)
80
# define GCM_USE_INTEL_VPCLMUL_AVX2 1
81
#endif /* GCM_USE_INTEL_VPCLMUL_AVX2 */
82
83
/* GCM_USE_INTEL_VPCLMUL_AVX512 indicates whether to compile GCM with Intel
84
   VPCLMUL/AVX512 code.  */
85
#undef GCM_USE_INTEL_VPCLMUL_AVX512
86
#if defined(__x86_64__) && defined(GCM_USE_INTEL_VPCLMUL_AVX2) && \
87
    defined(ENABLE_AVX512_SUPPORT) && defined(HAVE_GCC_INLINE_ASM_AVX512)
88
# define GCM_USE_INTEL_VPCLMUL_AVX512 1
89
#endif /* GCM_USE_INTEL_VPCLMUL_AVX512 */
90
91
/* GCM_USE_ARM_PMULL indicates whether to compile GCM with ARMv8 PMULL code. */
92
#undef GCM_USE_ARM_PMULL
93
#if defined(ENABLE_ARM_CRYPTO_SUPPORT) && defined(GCM_USE_TABLES)
94
# if defined(HAVE_ARM_ARCH_V6) && defined(__ARMEL__) \
95
     && defined(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS) \
96
     && defined(HAVE_GCC_INLINE_ASM_AARCH32_CRYPTO)
97
#  define GCM_USE_ARM_PMULL 1
98
# elif defined(__AARCH64EL__) && \
99
    defined(HAVE_COMPATIBLE_GCC_AARCH64_PLATFORM_AS) && \
100
    defined(HAVE_GCC_INLINE_ASM_AARCH64_CRYPTO)
101
#  define GCM_USE_ARM_PMULL 1
102
# endif
103
#endif /* GCM_USE_ARM_PMULL */
104
105
/* GCM_USE_ARM_NEON indicates whether to compile GCM with ARMv7 NEON code. */
106
#undef GCM_USE_ARM_NEON
107
#if defined(GCM_USE_TABLES)
108
#if defined(HAVE_ARM_ARCH_V6) && defined(__ARMEL__) && \
109
    defined(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS) && \
110
    defined(HAVE_GCC_INLINE_ASM_NEON)
111
#  define GCM_USE_ARM_NEON 1
112
#endif
113
#endif /* GCM_USE_ARM_NEON */
114
115
/* GCM_USE_S390X_CRYPTO indicates whether to enable zSeries code. */
116
#undef GCM_USE_S390X_CRYPTO
117
#if defined(HAVE_GCC_INLINE_ASM_S390X)
118
# define GCM_USE_S390X_CRYPTO 1
119
#endif /* GCM_USE_S390X_CRYPTO */
120
121
/* GCM_USE_PPC_VPMSUM indicates whether to compile GCM with PPC Power 8
122
 * polynomial multiplication instruction. */
123
#undef GCM_USE_PPC_VPMSUM
124
#if defined(GCM_USE_TABLES)
125
#if defined(ENABLE_PPC_CRYPTO_SUPPORT) && defined(__powerpc64__) && \
126
    defined(HAVE_COMPATIBLE_CC_PPC_ALTIVEC) && \
127
    defined(HAVE_GCC_INLINE_ASM_PPC_ALTIVEC) && __GNUC__ >= 4
128
#  define GCM_USE_PPC_VPMSUM 1
129
#  define NEED_16BYTE_ALIGNED_CONTEXT 1 /* this also aligns gcm_table */
130
#endif
131
#endif /* GCM_USE_PPC_VPMSUM */
132
133
typedef unsigned int (*ghash_fn_t) (gcry_cipher_hd_t c, byte *result,
134
                                    const byte *buf, size_t nblocks);
135
136
137
/* A structure with function pointers for mode operations. */
138
typedef struct cipher_mode_ops
139
{
140
  gcry_err_code_t (*encrypt)(gcry_cipher_hd_t c, unsigned char *outbuf,
141
           size_t outbuflen, const unsigned char *inbuf,
142
           size_t inbuflen);
143
  gcry_err_code_t (*decrypt)(gcry_cipher_hd_t c, unsigned char *outbuf,
144
           size_t outbuflen, const unsigned char *inbuf,
145
           size_t inbuflen);
146
  gcry_err_code_t (*setiv)(gcry_cipher_hd_t c, const unsigned char *iv,
147
         size_t ivlen);
148
149
  gcry_err_code_t (*authenticate)(gcry_cipher_hd_t c,
150
          const unsigned char *abuf, size_t abuflen);
151
  gcry_err_code_t (*get_tag)(gcry_cipher_hd_t c, unsigned char *outtag,
152
           size_t taglen);
153
  gcry_err_code_t (*check_tag)(gcry_cipher_hd_t c, const unsigned char *intag,
154
             size_t taglen);
155
} cipher_mode_ops_t;
156
157
158
/* A structure with function pointers for bulk operations.  The cipher
159
   algorithm setkey function initializes them when bulk operations are
160
   available and the actual encryption routines use them if they are
161
   not NULL.  */
162
typedef struct cipher_bulk_ops
163
{
164
  void (*ecb_crypt)(void *context, void *outbuf_arg, const void *inbuf_arg,
165
        size_t nblocks, int encrypt);
166
  void (*cfb_enc)(void *context, unsigned char *iv, void *outbuf_arg,
167
      const void *inbuf_arg, size_t nblocks);
168
  void (*cfb_dec)(void *context, unsigned char *iv, void *outbuf_arg,
169
      const void *inbuf_arg, size_t nblocks);
170
  void (*cbc_enc)(void *context, unsigned char *iv, void *outbuf_arg,
171
      const void *inbuf_arg, size_t nblocks, int cbc_mac);
172
  void (*cbc_dec)(void *context, unsigned char *iv, void *outbuf_arg,
173
      const void *inbuf_arg, size_t nblocks);
174
  void (*ofb_enc)(void *context, unsigned char *iv, void *outbuf_arg,
175
      const void *inbuf_arg, size_t nblocks);
176
  void (*ctr_enc)(void *context, unsigned char *iv, void *outbuf_arg,
177
      const void *inbuf_arg, size_t nblocks);
178
  void (*ctr32le_enc)(void *context, unsigned char *iv, void *outbuf_arg,
179
          const void *inbuf_arg, size_t nblocks);
180
  size_t (*ocb_crypt)(gcry_cipher_hd_t c, void *outbuf_arg,
181
          const void *inbuf_arg, size_t nblocks, int encrypt);
182
  size_t (*ocb_auth)(gcry_cipher_hd_t c, const void *abuf_arg, size_t nblocks);
183
  void (*xts_crypt)(void *context, unsigned char *tweak, void *outbuf_arg,
184
        const void *inbuf_arg, size_t nblocks, int encrypt);
185
  size_t (*gcm_crypt)(gcry_cipher_hd_t c, void *outbuf_arg,
186
          const void *inbuf_arg, size_t nblocks, int encrypt);
187
} cipher_bulk_ops_t;
188
189
190
/* A VIA processor with the Padlock engine as well as the Intel AES_NI
191
   instructions require an alignment of most data on a 16 byte
192
   boundary.  Because we trick out the compiler while allocating the
193
   context, the align attribute as used in rijndael.c does not work on
194
   its own.  Thus we need to make sure that the entire context
195
   structure is a aligned on that boundary.  We achieve this by
196
   defining a new type and use that instead of our usual alignment
197
   type.  */
198
typedef union
199
{
200
  PROPERLY_ALIGNED_TYPE foo;
201
#ifdef NEED_16BYTE_ALIGNED_CONTEXT
202
  char bar[16] __attribute__ ((aligned (16)));
203
#endif
204
  char c[1];
205
} cipher_context_alignment_t;
206
207
208
/* Storage structure for CMAC, for CMAC and EAX modes. */
209
typedef struct {
210
  /* The initialization vector. Also contains tag after finalization. */
211
  union {
212
    cipher_context_alignment_t iv_align;
213
    unsigned char iv[MAX_BLOCKSIZE];
214
  } u_iv;
215
216
  /* Subkeys for tag creation, not cleared by gcry_cipher_reset. */
217
  unsigned char subkeys[2][MAX_BLOCKSIZE];
218
219
  /* Space to save partial input lengths for MAC. */
220
  unsigned char macbuf[MAX_BLOCKSIZE];
221
222
  int mac_unused;  /* Number of unprocessed bytes in MACBUF. */
223
  unsigned int tag:1; /* Set to 1 if tag has been finalized.  */
224
} gcry_cmac_context_t;
225
226
227
/* The handle structure.  */
228
struct gcry_cipher_handle
229
{
230
  int magic;
231
  size_t actual_handle_size;     /* Allocated size of this handle. */
232
  size_t handle_offset;          /* Offset to the malloced block.  */
233
  gcry_cipher_spec_t *spec;
234
235
  /* The algorithm id.  This is a hack required because the module
236
     interface does not easily allow to retrieve this value. */
237
  int algo;
238
239
  /* A structure with function pointers for mode operations. */
240
  cipher_mode_ops_t mode_ops;
241
242
  /* A structure with function pointers for bulk operations.  Due to
243
     limitations of the module system (we don't want to change the
244
     API) we need to keep these function pointers here.  */
245
  cipher_bulk_ops_t bulk;
246
247
  int mode;
248
  unsigned int flags;
249
250
  struct {
251
    int geniv_method;
252
    unsigned char fixed[MAX_BLOCKSIZE];
253
    unsigned char dynamic[MAX_BLOCKSIZE];
254
    size_t fixed_iv_len;
255
    size_t dynamic_iv_len;
256
  } aead;
257
258
  struct {
259
    unsigned int key:1; /* Set to 1 if a key has been set.  */
260
    unsigned int iv:1;  /* Set to 1 if a IV has been set.  */
261
    unsigned int tag:1; /* Set to 1 if a tag is finalized. */
262
    unsigned int finalize:1; /* Next encrypt/decrypt has the final data.  */
263
    unsigned int allow_weak_key:1; /* Set to 1 if weak keys are allowed. */
264
  } marks;
265
266
  /* The initialization vector.  For best performance we make sure
267
     that it is properly aligned.  In particular some implementations
268
     of bulk operations expect an 16 byte aligned IV.  IV is also used
269
     to store CBC-MAC in CCM mode; counter IV is stored in U_CTR.  For
270
     OCB mode it is used for the offset value.  */
271
  union {
272
    cipher_context_alignment_t iv_align;
273
    unsigned char iv[MAX_BLOCKSIZE];
274
  } u_iv;
275
276
  /* The counter for CTR mode.  This field is also used by AESWRAP and
277
     thus we can't use the U_IV union.  For OCB mode it is used for
278
     the checksum.  */
279
  union {
280
    cipher_context_alignment_t iv_align;
281
    unsigned char ctr[MAX_BLOCKSIZE];
282
  } u_ctr;
283
284
  /* Space to save an IV or CTR for chaining operations.  */
285
  unsigned char lastiv[MAX_BLOCKSIZE];
286
  int unused;  /* Number of unused bytes in LASTIV. */
287
288
  union {
289
    /* Mode specific storage for CCM mode. */
290
    struct {
291
      u64 encryptlen;
292
      u64 aadlen;
293
      unsigned int authlen;
294
295
      /* Space to save partial input lengths for MAC. */
296
      unsigned char macbuf[GCRY_CCM_BLOCK_LEN];
297
      int mac_unused;  /* Number of unprocessed bytes in MACBUF. */
298
299
      unsigned char s0[GCRY_CCM_BLOCK_LEN];
300
301
      unsigned int nonce:1; /* Set to 1 if nonce has been set.  */
302
      unsigned int lengths:1; /* Set to 1 if CCM length parameters has been
303
                                 processed.  */
304
    } ccm;
305
306
    /* Mode specific storage for Poly1305 mode. */
307
    struct {
308
      /* byte counter for AAD. */
309
      u32 aadcount[2];
310
311
      /* byte counter for data. */
312
      u32 datacount[2];
313
314
      unsigned int aad_finalized:1;
315
      unsigned int bytecount_over_limits:1;
316
317
      poly1305_context_t ctx;
318
    } poly1305;
319
320
    /* Mode specific storage for CMAC mode. */
321
    gcry_cmac_context_t cmac;
322
323
    /* Mode specific storage for EAX mode. */
324
    struct {
325
      /* CMAC for header (AAD). */
326
      gcry_cmac_context_t cmac_header;
327
328
      /* CMAC for ciphertext. */
329
      gcry_cmac_context_t cmac_ciphertext;
330
    } eax;
331
332
    /* Mode specific storage for GCM mode and GCM-SIV mode. */
333
    struct {
334
      /* The interim tag for GCM mode.  */
335
      union {
336
        cipher_context_alignment_t iv_align;
337
        unsigned char tag[MAX_BLOCKSIZE];
338
      } u_tag;
339
340
      /* Space to save partial input lengths for MAC. */
341
      unsigned char macbuf[GCRY_CCM_BLOCK_LEN];
342
      int mac_unused;  /* Number of unprocessed bytes in MACBUF. */
343
344
      /* byte counters for GCM */
345
      u32 aadlen[2];
346
      u32 datalen[2];
347
348
      /* encrypted tag counter */
349
      unsigned char tagiv[MAX_BLOCKSIZE];
350
351
      unsigned int ghash_data_finalized:1;
352
      unsigned int ghash_aad_finalized:1;
353
354
      unsigned int datalen_over_limits:1;
355
      unsigned int disallow_encryption_because_of_setiv_in_fips_mode:1;
356
357
      /* --- Following members are not cleared in gcry_cipher_reset --- */
358
359
      /* GHASH multiplier from key.  */
360
      union {
361
        cipher_context_alignment_t iv_align;
362
        unsigned char key[MAX_BLOCKSIZE];
363
      } u_ghash_key;
364
365
      /* Pre-calculated table for GCM. */
366
#ifdef GCM_USE_TABLES
367
 #if (SIZEOF_UNSIGNED_LONG == 8 || defined(__x86_64__))
368
      #define GCM_TABLES_USE_U64 1
369
      u64 gcm_table[4 * 16];
370
 #else
371
      #undef GCM_TABLES_USE_U64
372
      u32 gcm_table[8 * 16];
373
 #endif
374
#endif
375
376
      /* GHASH implementation in use. */
377
      ghash_fn_t ghash_fn;
378
379
      /* POLYVAL implementation in use (GCM-SIV). */
380
      ghash_fn_t polyval_fn;
381
382
      /* Key length used for GCM-SIV key generating key. */
383
      unsigned int siv_keylen;
384
385
      /* Flags for accelerated implementations. */
386
      unsigned int hw_impl_flags;
387
    } gcm;
388
389
    /* Mode specific storage for OCB mode. */
390
    struct {
391
      /* --- Following members are not cleared in gcry_cipher_reset --- */
392
393
      /* Helper variables and pre-computed table of L values.  */
394
      unsigned char L_star[OCB_BLOCK_LEN];
395
      unsigned char L_dollar[OCB_BLOCK_LEN];
396
      unsigned char L0L1[OCB_BLOCK_LEN];
397
      unsigned char L[OCB_L_TABLE_SIZE][OCB_BLOCK_LEN];
398
399
      /* --- Following members are cleared in gcry_cipher_reset --- */
400
401
      /* The tag is valid if marks.tag has been set.  */
402
      unsigned char tag[OCB_BLOCK_LEN];
403
404
      /* A buffer to hold the offset for the AAD processing.  */
405
      unsigned char aad_offset[OCB_BLOCK_LEN];
406
407
      /* A buffer to hold the current sum of AAD processing.  We can't
408
         use tag here because tag may already hold the preprocessed
409
         checksum of the data.  */
410
      unsigned char aad_sum[OCB_BLOCK_LEN];
411
412
      /* A buffer to store AAD data not yet processed.  */
413
      unsigned char aad_leftover[OCB_BLOCK_LEN];
414
415
      /* Number of data/aad blocks processed so far.  */
416
      u64 data_nblocks;
417
      u64 aad_nblocks;
418
419
      /* Number of valid bytes in AAD_LEFTOVER.  */
420
      unsigned char aad_nleftover;
421
422
      /* Length of the tag.  Fixed for now but may eventually be
423
         specified using a set of gcry_cipher_flags.  */
424
      unsigned char taglen;
425
426
      /* Flags indicating that the final data/aad block has been
427
         processed.  */
428
      unsigned int data_finalized:1;
429
      unsigned int aad_finalized:1;
430
    } ocb;
431
432
    /* Mode specific storage for XTS mode. */
433
    struct {
434
      /* Pointer to tweak cipher context, allocated after actual
435
       * cipher context. */
436
      char *tweak_context;
437
    } xts;
438
439
    /* Mode specific storage for SIV mode. */
440
    struct {
441
      /* Tag used for decryption. */
442
      unsigned char dec_tag[GCRY_SIV_BLOCK_LEN];
443
444
      /* S2V state. */
445
      unsigned char s2v_d[GCRY_SIV_BLOCK_LEN];
446
447
      /* Number of AAD elements processed. */
448
      unsigned int aad_count:8;
449
450
      /* Flags for SIV state. */
451
      unsigned int dec_tag_set:1;
452
453
      /* --- Following members are not cleared in gcry_cipher_reset --- */
454
455
      /* S2V CMAC state. */
456
      gcry_cmac_context_t s2v_cmac;
457
      unsigned char s2v_zero_block[GCRY_SIV_BLOCK_LEN];
458
459
      /* Pointer to CTR cipher context, allocated after actual
460
       * cipher context. */
461
      char *ctr_context;
462
    } siv;
463
464
    /* Mode specific storage for WRAP mode. */
465
    struct {
466
      unsigned char plen[4];
467
    } wrap;
468
  } u_mode;
469
470
  /* What follows are two contexts of the cipher in use.  The first
471
     one needs to be aligned well enough for the cipher operation
472
     whereas the second one is a copy created by cipher_setkey and
473
     used by cipher_reset.  That second copy has no need for proper
474
     aligment because it is only accessed by memcpy.  */
475
  cipher_context_alignment_t context;
476
};
477
478
479
/*-- cipher-cbc.c --*/
480
gcry_err_code_t _gcry_cipher_cbc_encrypt
481
/*           */ (gcry_cipher_hd_t c,
482
                 unsigned char *outbuf, size_t outbuflen,
483
                 const unsigned char *inbuf, size_t inbuflen);
484
gcry_err_code_t _gcry_cipher_cbc_decrypt
485
/*           */ (gcry_cipher_hd_t c,
486
                 unsigned char *outbuf, size_t outbuflen,
487
                 const unsigned char *inbuf, size_t inbuflen);
488
gcry_err_code_t _gcry_cipher_cbc_cts_encrypt
489
/*           */ (gcry_cipher_hd_t c,
490
                 unsigned char *outbuf, size_t outbuflen,
491
                 const unsigned char *inbuf, size_t inbuflen);
492
gcry_err_code_t _gcry_cipher_cbc_cts_decrypt
493
/*           */ (gcry_cipher_hd_t c,
494
                 unsigned char *outbuf, size_t outbuflen,
495
                 const unsigned char *inbuf, size_t inbuflen);
496
497
/*-- cipher-cfb.c --*/
498
gcry_err_code_t _gcry_cipher_cfb_encrypt
499
/*           */ (gcry_cipher_hd_t c,
500
                 unsigned char *outbuf, size_t outbuflen,
501
                 const unsigned char *inbuf, size_t inbuflen);
502
gcry_err_code_t _gcry_cipher_cfb_decrypt
503
/*           */ (gcry_cipher_hd_t c,
504
                 unsigned char *outbuf, size_t outbuflen,
505
                 const unsigned char *inbuf, size_t inbuflen);
506
gcry_err_code_t _gcry_cipher_cfb8_encrypt
507
/*           */ (gcry_cipher_hd_t c,
508
                 unsigned char *outbuf, size_t outbuflen,
509
                 const unsigned char *inbuf, size_t inbuflen);
510
gcry_err_code_t _gcry_cipher_cfb8_decrypt
511
/*           */ (gcry_cipher_hd_t c,
512
                 unsigned char *outbuf, size_t outbuflen,
513
                 const unsigned char *inbuf, size_t inbuflen);
514
515
516
/*-- cipher-ofb.c --*/
517
gcry_err_code_t _gcry_cipher_ofb_encrypt
518
/*           */ (gcry_cipher_hd_t c,
519
                 unsigned char *outbuf, size_t outbuflen,
520
                 const unsigned char *inbuf, size_t inbuflen);
521
522
/*-- cipher-ctr.c --*/
523
gcry_err_code_t _gcry_cipher_ctr_encrypt_ctx
524
/*           */ (gcry_cipher_hd_t c,
525
     unsigned char *outbuf, size_t outbuflen,
526
     const unsigned char *inbuf, size_t inbuflen,
527
     void *algo_context);
528
gcry_err_code_t _gcry_cipher_ctr_encrypt
529
/*           */ (gcry_cipher_hd_t c,
530
                 unsigned char *outbuf, size_t outbuflen,
531
                 const unsigned char *inbuf, size_t inbuflen);
532
533
534
/*-- cipher-aeswrap.c --*/
535
gcry_err_code_t _gcry_cipher_keywrap_encrypt
536
/*           */   (gcry_cipher_hd_t c,
537
                   byte *outbuf, size_t outbuflen,
538
                   const byte *inbuf, size_t inbuflen);
539
gcry_err_code_t _gcry_cipher_keywrap_encrypt_padding
540
/*           */   (gcry_cipher_hd_t c,
541
                   byte *outbuf, size_t outbuflen,
542
                   const byte *inbuf, size_t inbuflen);
543
gcry_err_code_t _gcry_cipher_keywrap_decrypt_auto
544
/*           */   (gcry_cipher_hd_t c,
545
                   byte *outbuf, size_t outbuflen,
546
                   const byte *inbuf, size_t inbuflen);
547
548
549
/*-- cipher-ccm.c --*/
550
gcry_err_code_t _gcry_cipher_ccm_encrypt
551
/*           */ (gcry_cipher_hd_t c,
552
                 unsigned char *outbuf, size_t outbuflen,
553
                 const unsigned char *inbuf, size_t inbuflen);
554
gcry_err_code_t _gcry_cipher_ccm_decrypt
555
/*           */ (gcry_cipher_hd_t c,
556
                 unsigned char *outbuf, size_t outbuflen,
557
                 const unsigned char *inbuf, size_t inbuflen);
558
gcry_err_code_t _gcry_cipher_ccm_set_nonce
559
/*           */ (gcry_cipher_hd_t c, const unsigned char *nonce,
560
                 size_t noncelen);
561
gcry_err_code_t _gcry_cipher_ccm_authenticate
562
/*           */ (gcry_cipher_hd_t c, const unsigned char *abuf, size_t abuflen);
563
gcry_err_code_t _gcry_cipher_ccm_set_lengths
564
/*           */ (gcry_cipher_hd_t c, u64 encryptedlen, u64 aadlen, u64 taglen);
565
gcry_err_code_t _gcry_cipher_ccm_get_tag
566
/*           */ (gcry_cipher_hd_t c,
567
                 unsigned char *outtag, size_t taglen);
568
gcry_err_code_t _gcry_cipher_ccm_check_tag
569
/*           */ (gcry_cipher_hd_t c,
570
                 const unsigned char *intag, size_t taglen);
571
572
573
/*-- cipher-cmac.c --*/
574
gcry_err_code_t _gcry_cmac_generate_subkeys
575
/*           */ (gcry_cipher_hd_t c, gcry_cmac_context_t *ctx);
576
gcry_err_code_t _gcry_cmac_write
577
/*           */ (gcry_cipher_hd_t c, gcry_cmac_context_t *ctx,
578
     const byte * inbuf, size_t inlen);
579
gcry_err_code_t _gcry_cmac_final
580
/*           */ (gcry_cipher_hd_t c, gcry_cmac_context_t *ctx);
581
void _gcry_cmac_reset (gcry_cmac_context_t *ctx);
582
583
584
/*-- cipher-eax.c --*/
585
gcry_err_code_t _gcry_cipher_eax_encrypt
586
/*           */   (gcry_cipher_hd_t c,
587
                   unsigned char *outbuf, size_t outbuflen,
588
                   const unsigned char *inbuf, size_t inbuflen);
589
gcry_err_code_t _gcry_cipher_eax_decrypt
590
/*           */   (gcry_cipher_hd_t c,
591
                   unsigned char *outbuf, size_t outbuflen,
592
                   const unsigned char *inbuf, size_t inbuflen);
593
gcry_err_code_t _gcry_cipher_eax_set_nonce
594
/*           */   (gcry_cipher_hd_t c,
595
                   const unsigned char *nonce, size_t noncelen);
596
gcry_err_code_t _gcry_cipher_eax_authenticate
597
/*           */   (gcry_cipher_hd_t c,
598
                   const unsigned char *aadbuf, size_t aadbuflen);
599
gcry_err_code_t _gcry_cipher_eax_get_tag
600
/*           */   (gcry_cipher_hd_t c,
601
                   unsigned char *outtag, size_t taglen);
602
gcry_err_code_t _gcry_cipher_eax_check_tag
603
/*           */   (gcry_cipher_hd_t c,
604
                   const unsigned char *intag, size_t taglen);
605
gcry_err_code_t _gcry_cipher_eax_setkey
606
/*           */   (gcry_cipher_hd_t c);
607
608
609
/*-- cipher-gcm.c --*/
610
gcry_err_code_t _gcry_cipher_gcm_encrypt
611
/*           */   (gcry_cipher_hd_t c,
612
                   unsigned char *outbuf, size_t outbuflen,
613
                   const unsigned char *inbuf, size_t inbuflen);
614
gcry_err_code_t _gcry_cipher_gcm_decrypt
615
/*           */   (gcry_cipher_hd_t c,
616
                   unsigned char *outbuf, size_t outbuflen,
617
                   const unsigned char *inbuf, size_t inbuflen);
618
gcry_err_code_t _gcry_cipher_gcm_setiv
619
/*           */   (gcry_cipher_hd_t c,
620
                   const unsigned char *iv, size_t ivlen);
621
gcry_err_code_t _gcry_cipher_gcm_authenticate
622
/*           */   (gcry_cipher_hd_t c,
623
                   const unsigned char *aadbuf, size_t aadbuflen);
624
gcry_err_code_t _gcry_cipher_gcm_get_tag
625
/*           */   (gcry_cipher_hd_t c,
626
                   unsigned char *outtag, size_t taglen);
627
gcry_err_code_t _gcry_cipher_gcm_check_tag
628
/*           */   (gcry_cipher_hd_t c,
629
                   const unsigned char *intag, size_t taglen);
630
void _gcry_cipher_gcm_setkey
631
/*           */   (gcry_cipher_hd_t c);
632
void _gcry_cipher_gcm_setupM
633
/*           */   (gcry_cipher_hd_t c);
634
635
636
/*-- cipher-poly1305.c --*/
637
gcry_err_code_t _gcry_cipher_poly1305_encrypt
638
/*           */   (gcry_cipher_hd_t c,
639
                   unsigned char *outbuf, size_t outbuflen,
640
                   const unsigned char *inbuf, size_t inbuflen);
641
gcry_err_code_t _gcry_cipher_poly1305_decrypt
642
/*           */   (gcry_cipher_hd_t c,
643
                   unsigned char *outbuf, size_t outbuflen,
644
                   const unsigned char *inbuf, size_t inbuflen);
645
gcry_err_code_t _gcry_cipher_poly1305_setiv
646
/*           */   (gcry_cipher_hd_t c,
647
                   const unsigned char *iv, size_t ivlen);
648
gcry_err_code_t _gcry_cipher_poly1305_authenticate
649
/*           */   (gcry_cipher_hd_t c,
650
                   const unsigned char *aadbuf, size_t aadbuflen);
651
gcry_err_code_t _gcry_cipher_poly1305_get_tag
652
/*           */   (gcry_cipher_hd_t c,
653
                   unsigned char *outtag, size_t taglen);
654
gcry_err_code_t _gcry_cipher_poly1305_check_tag
655
/*           */   (gcry_cipher_hd_t c,
656
                   const unsigned char *intag, size_t taglen);
657
void _gcry_cipher_poly1305_setkey
658
/*           */   (gcry_cipher_hd_t c);
659
660
661
/*-- chacha20.c --*/
662
gcry_err_code_t _gcry_chacha20_poly1305_encrypt
663
/*           */   (gcry_cipher_hd_t c, byte *outbuf, const byte *inbuf,
664
       size_t length);
665
gcry_err_code_t _gcry_chacha20_poly1305_decrypt
666
/*           */   (gcry_cipher_hd_t c, byte *outbuf, const byte *inbuf,
667
       size_t length);
668
669
670
/*-- cipher-ocb.c --*/
671
gcry_err_code_t _gcry_cipher_ocb_encrypt
672
/*           */ (gcry_cipher_hd_t c,
673
                 unsigned char *outbuf, size_t outbuflen,
674
                 const unsigned char *inbuf, size_t inbuflen);
675
gcry_err_code_t _gcry_cipher_ocb_decrypt
676
/*           */ (gcry_cipher_hd_t c,
677
                 unsigned char *outbuf, size_t outbuflen,
678
                 const unsigned char *inbuf, size_t inbuflen);
679
gcry_err_code_t _gcry_cipher_ocb_set_nonce
680
/*           */ (gcry_cipher_hd_t c, const unsigned char *nonce,
681
                 size_t noncelen);
682
gcry_err_code_t _gcry_cipher_ocb_authenticate
683
/*           */ (gcry_cipher_hd_t c, const unsigned char *abuf, size_t abuflen);
684
gcry_err_code_t _gcry_cipher_ocb_get_tag
685
/*           */ (gcry_cipher_hd_t c,
686
                 unsigned char *outtag, size_t taglen);
687
gcry_err_code_t _gcry_cipher_ocb_check_tag
688
/*           */ (gcry_cipher_hd_t c,
689
                 const unsigned char *intag, size_t taglen);
690
void _gcry_cipher_ocb_setkey
691
/*           */ (gcry_cipher_hd_t c);
692
693
694
/*-- cipher-xts.c --*/
695
gcry_err_code_t _gcry_cipher_xts_encrypt
696
/*           */ (gcry_cipher_hd_t c, unsigned char *outbuf, size_t outbuflen,
697
     const unsigned char *inbuf, size_t inbuflen);
698
gcry_err_code_t _gcry_cipher_xts_decrypt
699
/*           */ (gcry_cipher_hd_t c, unsigned char *outbuf, size_t outbuflen,
700
     const unsigned char *inbuf, size_t inbuflen);
701
702
703
/*-- cipher-siv.c --*/
704
gcry_err_code_t _gcry_cipher_siv_encrypt
705
/*           */ (gcry_cipher_hd_t c,
706
                 unsigned char *outbuf, size_t outbuflen,
707
                 const unsigned char *inbuf, size_t inbuflen);
708
gcry_err_code_t _gcry_cipher_siv_decrypt
709
/*           */ (gcry_cipher_hd_t c,
710
                 unsigned char *outbuf, size_t outbuflen,
711
                 const unsigned char *inbuf, size_t inbuflen);
712
gcry_err_code_t _gcry_cipher_siv_set_nonce
713
/*           */ (gcry_cipher_hd_t c, const unsigned char *nonce,
714
                 size_t noncelen);
715
gcry_err_code_t _gcry_cipher_siv_authenticate
716
/*           */ (gcry_cipher_hd_t c, const unsigned char *abuf, size_t abuflen);
717
gcry_err_code_t _gcry_cipher_siv_set_decryption_tag
718
/*           */ (gcry_cipher_hd_t c, const byte *tag, size_t taglen);
719
gcry_err_code_t _gcry_cipher_siv_get_tag
720
/*           */ (gcry_cipher_hd_t c,
721
                 unsigned char *outtag, size_t taglen);
722
gcry_err_code_t _gcry_cipher_siv_check_tag
723
/*           */ (gcry_cipher_hd_t c,
724
                 const unsigned char *intag, size_t taglen);
725
gcry_err_code_t _gcry_cipher_siv_setkey
726
/*           */ (gcry_cipher_hd_t c,
727
                 const unsigned char *ctrkey, size_t ctrkeylen);
728
729
730
/*-- cipher-gcm-siv.c --*/
731
gcry_err_code_t _gcry_cipher_gcm_siv_encrypt
732
/*           */ (gcry_cipher_hd_t c,
733
                 unsigned char *outbuf, size_t outbuflen,
734
                 const unsigned char *inbuf, size_t inbuflen);
735
gcry_err_code_t _gcry_cipher_gcm_siv_decrypt
736
/*           */ (gcry_cipher_hd_t c,
737
                 unsigned char *outbuf, size_t outbuflen,
738
                 const unsigned char *inbuf, size_t inbuflen);
739
gcry_err_code_t _gcry_cipher_gcm_siv_set_nonce
740
/*           */ (gcry_cipher_hd_t c, const unsigned char *nonce,
741
                 size_t noncelen);
742
gcry_err_code_t _gcry_cipher_gcm_siv_authenticate
743
/*           */ (gcry_cipher_hd_t c, const unsigned char *abuf, size_t abuflen);
744
gcry_err_code_t _gcry_cipher_gcm_siv_set_decryption_tag
745
/*           */ (gcry_cipher_hd_t c, const byte *tag, size_t taglen);
746
gcry_err_code_t _gcry_cipher_gcm_siv_get_tag
747
/*           */ (gcry_cipher_hd_t c,
748
                 unsigned char *outtag, size_t taglen);
749
gcry_err_code_t _gcry_cipher_gcm_siv_check_tag
750
/*           */ (gcry_cipher_hd_t c,
751
                 const unsigned char *intag, size_t taglen);
752
gcry_err_code_t _gcry_cipher_gcm_siv_setkey
753
/*           */ (gcry_cipher_hd_t c, unsigned int keylen);
754
755
756
/* Return the L-value for block N.  Note: 'cipher_ocb.c' ensures that N
757
 * will never be multiple of 65536 (1 << OCB_L_TABLE_SIZE), thus N can
758
 * be directly passed to _gcry_ctz() function and resulting index will
759
 * never overflow the table.  */
760
static inline const unsigned char *
761
ocb_get_l (gcry_cipher_hd_t c, u64 n)
762
0
{
763
0
  unsigned long ntz;
764
765
0
#if ((defined(__i386__) || defined(__x86_64__)) && __GNUC__ >= 4)
766
  /* Assumes that N != 0. */
767
0
  asm ("rep;bsfl %k[low], %k[ntz]\n\t"
768
0
        : [ntz] "=r" (ntz)
769
0
        : [low] "r" ((unsigned long)n)
770
0
        : "cc");
771
#else
772
  ntz = _gcry_ctz (n);
773
#endif
774
775
0
  return c->u_mode.ocb.L[ntz];
776
0
}
Unexecuted instantiation: cipher.c:ocb_get_l
Unexecuted instantiation: des.c:ocb_get_l
Unexecuted instantiation: gost28147.c:ocb_get_l
Unexecuted instantiation: idea.c:ocb_get_l
Unexecuted instantiation: rfc2268.c:ocb_get_l
Unexecuted instantiation: rijndael.c:ocb_get_l
Unexecuted instantiation: salsa20.c:ocb_get_l
Unexecuted instantiation: seed.c:ocb_get_l
Unexecuted instantiation: serpent.c:ocb_get_l
Unexecuted instantiation: sm4.c:ocb_get_l
Unexecuted instantiation: twofish.c:ocb_get_l
Unexecuted instantiation: arcfour.c:ocb_get_l
Unexecuted instantiation: blowfish.c:ocb_get_l
Unexecuted instantiation: camellia-glue.c:ocb_get_l
Unexecuted instantiation: cast5.c:ocb_get_l
Unexecuted instantiation: chacha20.c:ocb_get_l
Unexecuted instantiation: cipher-aeswrap.c:ocb_get_l
Unexecuted instantiation: cipher-cbc.c:ocb_get_l
Unexecuted instantiation: cipher-ccm.c:ocb_get_l
Unexecuted instantiation: cipher-cfb.c:ocb_get_l
Unexecuted instantiation: cipher-cmac.c:ocb_get_l
Unexecuted instantiation: cipher-ctr.c:ocb_get_l
Unexecuted instantiation: cipher-eax.c:ocb_get_l
Unexecuted instantiation: cipher-gcm-siv.c:ocb_get_l
Unexecuted instantiation: cipher-gcm.c:ocb_get_l
Unexecuted instantiation: cipher-ocb.c:ocb_get_l
Unexecuted instantiation: cipher-ofb.c:ocb_get_l
Unexecuted instantiation: cipher-poly1305.c:ocb_get_l
Unexecuted instantiation: cipher-siv.c:ocb_get_l
Unexecuted instantiation: cipher-xts.c:ocb_get_l
Unexecuted instantiation: rijndael-vaes.c:ocb_get_l
777
778
779
/* Return bit-shift of blocksize. */
780
static inline unsigned int _gcry_blocksize_shift(gcry_cipher_hd_t c)
781
0
{
782
  /* Only blocksizes 8 and 16 are used. Return value in such way
783
   * that compiler can optimize calling functions based on this.  */
784
0
  return c->spec->blocksize == 8 ? 3 : 4;
785
0
}
Unexecuted instantiation: cipher.c:_gcry_blocksize_shift
Unexecuted instantiation: des.c:_gcry_blocksize_shift
Unexecuted instantiation: gost28147.c:_gcry_blocksize_shift
Unexecuted instantiation: idea.c:_gcry_blocksize_shift
Unexecuted instantiation: rfc2268.c:_gcry_blocksize_shift
Unexecuted instantiation: rijndael.c:_gcry_blocksize_shift
Unexecuted instantiation: salsa20.c:_gcry_blocksize_shift
Unexecuted instantiation: seed.c:_gcry_blocksize_shift
Unexecuted instantiation: serpent.c:_gcry_blocksize_shift
Unexecuted instantiation: sm4.c:_gcry_blocksize_shift
Unexecuted instantiation: twofish.c:_gcry_blocksize_shift
Unexecuted instantiation: arcfour.c:_gcry_blocksize_shift
Unexecuted instantiation: blowfish.c:_gcry_blocksize_shift
Unexecuted instantiation: camellia-glue.c:_gcry_blocksize_shift
Unexecuted instantiation: cast5.c:_gcry_blocksize_shift
Unexecuted instantiation: chacha20.c:_gcry_blocksize_shift
Unexecuted instantiation: cipher-aeswrap.c:_gcry_blocksize_shift
Unexecuted instantiation: cipher-cbc.c:_gcry_blocksize_shift
Unexecuted instantiation: cipher-ccm.c:_gcry_blocksize_shift
Unexecuted instantiation: cipher-cfb.c:_gcry_blocksize_shift
Unexecuted instantiation: cipher-cmac.c:_gcry_blocksize_shift
Unexecuted instantiation: cipher-ctr.c:_gcry_blocksize_shift
Unexecuted instantiation: cipher-eax.c:_gcry_blocksize_shift
Unexecuted instantiation: cipher-gcm-siv.c:_gcry_blocksize_shift
Unexecuted instantiation: cipher-gcm.c:_gcry_blocksize_shift
Unexecuted instantiation: cipher-ocb.c:_gcry_blocksize_shift
Unexecuted instantiation: cipher-ofb.c:_gcry_blocksize_shift
Unexecuted instantiation: cipher-poly1305.c:_gcry_blocksize_shift
Unexecuted instantiation: cipher-siv.c:_gcry_blocksize_shift
Unexecuted instantiation: cipher-xts.c:_gcry_blocksize_shift
Unexecuted instantiation: rijndael-vaes.c:_gcry_blocksize_shift
786
787
788
/* Optimized function for adding value to cipher block. */
789
static inline void
790
cipher_block_add(void *_dstsrc, unsigned int add, size_t blocksize)
791
0
{
792
0
  byte *dstsrc = _dstsrc;
793
0
  u64 s[2];
794
795
0
  if (blocksize == 8)
796
0
    {
797
0
      buf_put_be64(dstsrc + 0, buf_get_be64(dstsrc + 0) + add);
798
0
    }
799
0
  else /* blocksize == 16 */
800
0
    {
801
0
      s[0] = buf_get_be64(dstsrc + 8);
802
0
      s[1] = buf_get_be64(dstsrc + 0);
803
0
      s[0] += add;
804
0
      s[1] += (s[0] < add);
805
0
      buf_put_be64(dstsrc + 8, s[0]);
806
0
      buf_put_be64(dstsrc + 0, s[1]);
807
0
    }
808
0
}
Unexecuted instantiation: cipher.c:cipher_block_add
Unexecuted instantiation: des.c:cipher_block_add
Unexecuted instantiation: gost28147.c:cipher_block_add
Unexecuted instantiation: idea.c:cipher_block_add
Unexecuted instantiation: rfc2268.c:cipher_block_add
Unexecuted instantiation: rijndael.c:cipher_block_add
Unexecuted instantiation: salsa20.c:cipher_block_add
Unexecuted instantiation: seed.c:cipher_block_add
Unexecuted instantiation: serpent.c:cipher_block_add
Unexecuted instantiation: sm4.c:cipher_block_add
Unexecuted instantiation: twofish.c:cipher_block_add
Unexecuted instantiation: arcfour.c:cipher_block_add
Unexecuted instantiation: blowfish.c:cipher_block_add
Unexecuted instantiation: camellia-glue.c:cipher_block_add
Unexecuted instantiation: cast5.c:cipher_block_add
Unexecuted instantiation: chacha20.c:cipher_block_add
Unexecuted instantiation: cipher-aeswrap.c:cipher_block_add
Unexecuted instantiation: cipher-cbc.c:cipher_block_add
Unexecuted instantiation: cipher-ccm.c:cipher_block_add
Unexecuted instantiation: cipher-cfb.c:cipher_block_add
Unexecuted instantiation: cipher-cmac.c:cipher_block_add
Unexecuted instantiation: cipher-ctr.c:cipher_block_add
Unexecuted instantiation: cipher-eax.c:cipher_block_add
Unexecuted instantiation: cipher-gcm-siv.c:cipher_block_add
Unexecuted instantiation: cipher-gcm.c:cipher_block_add
Unexecuted instantiation: cipher-ocb.c:cipher_block_add
Unexecuted instantiation: cipher-ofb.c:cipher_block_add
Unexecuted instantiation: cipher-poly1305.c:cipher_block_add
Unexecuted instantiation: cipher-siv.c:cipher_block_add
Unexecuted instantiation: cipher-xts.c:cipher_block_add
Unexecuted instantiation: rijndael-vaes.c:cipher_block_add
809
810
811
/* Optimized function for cipher block copying */
812
static inline void
813
cipher_block_cpy(void *_dst, const void *_src, size_t blocksize)
814
0
{
815
0
  byte *dst = _dst;
816
0
  const byte *src = _src;
817
0
  u64 s[2];
818
819
0
  if (blocksize == 8)
820
0
    {
821
0
      buf_put_he64(dst + 0, buf_get_he64(src + 0));
822
0
    }
823
0
  else /* blocksize == 16 */
824
0
    {
825
0
      s[0] = buf_get_he64(src + 0);
826
0
      s[1] = buf_get_he64(src + 8);
827
0
      buf_put_he64(dst + 0, s[0]);
828
0
      buf_put_he64(dst + 8, s[1]);
829
0
    }
830
0
}
Unexecuted instantiation: cipher.c:cipher_block_cpy
Unexecuted instantiation: des.c:cipher_block_cpy
Unexecuted instantiation: gost28147.c:cipher_block_cpy
Unexecuted instantiation: idea.c:cipher_block_cpy
Unexecuted instantiation: rfc2268.c:cipher_block_cpy
Unexecuted instantiation: rijndael.c:cipher_block_cpy
Unexecuted instantiation: salsa20.c:cipher_block_cpy
Unexecuted instantiation: seed.c:cipher_block_cpy
Unexecuted instantiation: serpent.c:cipher_block_cpy
Unexecuted instantiation: sm4.c:cipher_block_cpy
Unexecuted instantiation: twofish.c:cipher_block_cpy
Unexecuted instantiation: arcfour.c:cipher_block_cpy
Unexecuted instantiation: blowfish.c:cipher_block_cpy
Unexecuted instantiation: camellia-glue.c:cipher_block_cpy
Unexecuted instantiation: cast5.c:cipher_block_cpy
Unexecuted instantiation: chacha20.c:cipher_block_cpy
Unexecuted instantiation: cipher-aeswrap.c:cipher_block_cpy
Unexecuted instantiation: cipher-cbc.c:cipher_block_cpy
Unexecuted instantiation: cipher-ccm.c:cipher_block_cpy
Unexecuted instantiation: cipher-cfb.c:cipher_block_cpy
Unexecuted instantiation: cipher-cmac.c:cipher_block_cpy
Unexecuted instantiation: cipher-ctr.c:cipher_block_cpy
Unexecuted instantiation: cipher-eax.c:cipher_block_cpy
Unexecuted instantiation: cipher-gcm-siv.c:cipher_block_cpy
Unexecuted instantiation: cipher-gcm.c:cipher_block_cpy
Unexecuted instantiation: cipher-ocb.c:cipher_block_cpy
Unexecuted instantiation: cipher-ofb.c:cipher_block_cpy
Unexecuted instantiation: cipher-poly1305.c:cipher_block_cpy
Unexecuted instantiation: cipher-siv.c:cipher_block_cpy
Unexecuted instantiation: cipher-xts.c:cipher_block_cpy
Unexecuted instantiation: rijndael-vaes.c:cipher_block_cpy
831
832
833
/* Optimized function for cipher block xoring */
834
static inline void
835
cipher_block_xor(void *_dst, const void *_src1, const void *_src2,
836
                 size_t blocksize)
837
0
{
838
0
  byte *dst = _dst;
839
0
  const byte *src1 = _src1;
840
0
  const byte *src2 = _src2;
841
0
  u64 s1[2];
842
0
  u64 s2[2];
843
844
0
  if (blocksize == 8)
845
0
    {
846
0
      buf_put_he64(dst + 0, buf_get_he64(src1 + 0) ^ buf_get_he64(src2 + 0));
847
0
    }
848
0
  else /* blocksize == 16 */
849
0
    {
850
0
      s1[0] = buf_get_he64(src1 + 0);
851
0
      s1[1] = buf_get_he64(src1 + 8);
852
0
      s2[0] = buf_get_he64(src2 + 0);
853
0
      s2[1] = buf_get_he64(src2 + 8);
854
0
      buf_put_he64(dst + 0, s1[0] ^ s2[0]);
855
0
      buf_put_he64(dst + 8, s1[1] ^ s2[1]);
856
0
    }
857
0
}
Unexecuted instantiation: cipher.c:cipher_block_xor
Unexecuted instantiation: des.c:cipher_block_xor
Unexecuted instantiation: gost28147.c:cipher_block_xor
Unexecuted instantiation: idea.c:cipher_block_xor
Unexecuted instantiation: rfc2268.c:cipher_block_xor
Unexecuted instantiation: rijndael.c:cipher_block_xor
Unexecuted instantiation: salsa20.c:cipher_block_xor
Unexecuted instantiation: seed.c:cipher_block_xor
Unexecuted instantiation: serpent.c:cipher_block_xor
Unexecuted instantiation: sm4.c:cipher_block_xor
Unexecuted instantiation: twofish.c:cipher_block_xor
Unexecuted instantiation: arcfour.c:cipher_block_xor
Unexecuted instantiation: blowfish.c:cipher_block_xor
Unexecuted instantiation: camellia-glue.c:cipher_block_xor
Unexecuted instantiation: cast5.c:cipher_block_xor
Unexecuted instantiation: chacha20.c:cipher_block_xor
Unexecuted instantiation: cipher-aeswrap.c:cipher_block_xor
Unexecuted instantiation: cipher-cbc.c:cipher_block_xor
Unexecuted instantiation: cipher-ccm.c:cipher_block_xor
Unexecuted instantiation: cipher-cfb.c:cipher_block_xor
Unexecuted instantiation: cipher-cmac.c:cipher_block_xor
Unexecuted instantiation: cipher-ctr.c:cipher_block_xor
Unexecuted instantiation: cipher-eax.c:cipher_block_xor
Unexecuted instantiation: cipher-gcm-siv.c:cipher_block_xor
Unexecuted instantiation: cipher-gcm.c:cipher_block_xor
Unexecuted instantiation: cipher-ocb.c:cipher_block_xor
Unexecuted instantiation: cipher-ofb.c:cipher_block_xor
Unexecuted instantiation: cipher-poly1305.c:cipher_block_xor
Unexecuted instantiation: cipher-siv.c:cipher_block_xor
Unexecuted instantiation: cipher-xts.c:cipher_block_xor
Unexecuted instantiation: rijndael-vaes.c:cipher_block_xor
858
859
860
/* Optimized function for in-place cipher block xoring */
861
static inline void
862
cipher_block_xor_1(void *_dst, const void *_src, size_t blocksize)
863
0
{
864
0
  cipher_block_xor (_dst, _dst, _src, blocksize);
865
0
}
Unexecuted instantiation: cipher.c:cipher_block_xor_1
Unexecuted instantiation: des.c:cipher_block_xor_1
Unexecuted instantiation: gost28147.c:cipher_block_xor_1
Unexecuted instantiation: idea.c:cipher_block_xor_1
Unexecuted instantiation: rfc2268.c:cipher_block_xor_1
Unexecuted instantiation: rijndael.c:cipher_block_xor_1
Unexecuted instantiation: salsa20.c:cipher_block_xor_1
Unexecuted instantiation: seed.c:cipher_block_xor_1
Unexecuted instantiation: serpent.c:cipher_block_xor_1
Unexecuted instantiation: sm4.c:cipher_block_xor_1
Unexecuted instantiation: twofish.c:cipher_block_xor_1
Unexecuted instantiation: arcfour.c:cipher_block_xor_1
Unexecuted instantiation: blowfish.c:cipher_block_xor_1
Unexecuted instantiation: camellia-glue.c:cipher_block_xor_1
Unexecuted instantiation: cast5.c:cipher_block_xor_1
Unexecuted instantiation: chacha20.c:cipher_block_xor_1
Unexecuted instantiation: cipher-aeswrap.c:cipher_block_xor_1
Unexecuted instantiation: cipher-cbc.c:cipher_block_xor_1
Unexecuted instantiation: cipher-ccm.c:cipher_block_xor_1
Unexecuted instantiation: cipher-cfb.c:cipher_block_xor_1
Unexecuted instantiation: cipher-cmac.c:cipher_block_xor_1
Unexecuted instantiation: cipher-ctr.c:cipher_block_xor_1
Unexecuted instantiation: cipher-eax.c:cipher_block_xor_1
Unexecuted instantiation: cipher-gcm-siv.c:cipher_block_xor_1
Unexecuted instantiation: cipher-gcm.c:cipher_block_xor_1
Unexecuted instantiation: cipher-ocb.c:cipher_block_xor_1
Unexecuted instantiation: cipher-ofb.c:cipher_block_xor_1
Unexecuted instantiation: cipher-poly1305.c:cipher_block_xor_1
Unexecuted instantiation: cipher-siv.c:cipher_block_xor_1
Unexecuted instantiation: cipher-xts.c:cipher_block_xor_1
Unexecuted instantiation: rijndael-vaes.c:cipher_block_xor_1
866
867
868
/* Optimized function for cipher block xoring with two destination cipher
869
   blocks.  Used mainly by CFB mode encryption.  */
870
static inline void
871
cipher_block_xor_2dst(void *_dst1, void *_dst2, const void *_src,
872
                      size_t blocksize)
873
0
{
874
0
  byte *dst1 = _dst1;
875
0
  byte *dst2 = _dst2;
876
0
  const byte *src = _src;
877
0
  u64 d2[2];
878
0
  u64 s[2];
879
880
0
  if (blocksize == 8)
881
0
    {
882
0
      d2[0] = buf_get_he64(dst2 + 0) ^ buf_get_he64(src + 0);
883
0
      buf_put_he64(dst2 + 0, d2[0]);
884
0
      buf_put_he64(dst1 + 0, d2[0]);
885
0
    }
886
0
  else /* blocksize == 16 */
887
0
    {
888
0
      s[0] = buf_get_he64(src + 0);
889
0
      s[1] = buf_get_he64(src + 8);
890
0
      d2[0] = buf_get_he64(dst2 + 0);
891
0
      d2[1] = buf_get_he64(dst2 + 8);
892
0
      d2[0] = d2[0] ^ s[0];
893
0
      d2[1] = d2[1] ^ s[1];
894
0
      buf_put_he64(dst2 + 0, d2[0]);
895
0
      buf_put_he64(dst2 + 8, d2[1]);
896
0
      buf_put_he64(dst1 + 0, d2[0]);
897
0
      buf_put_he64(dst1 + 8, d2[1]);
898
0
    }
899
0
}
Unexecuted instantiation: cipher.c:cipher_block_xor_2dst
Unexecuted instantiation: des.c:cipher_block_xor_2dst
Unexecuted instantiation: gost28147.c:cipher_block_xor_2dst
Unexecuted instantiation: idea.c:cipher_block_xor_2dst
Unexecuted instantiation: rfc2268.c:cipher_block_xor_2dst
Unexecuted instantiation: rijndael.c:cipher_block_xor_2dst
Unexecuted instantiation: salsa20.c:cipher_block_xor_2dst
Unexecuted instantiation: seed.c:cipher_block_xor_2dst
Unexecuted instantiation: serpent.c:cipher_block_xor_2dst
Unexecuted instantiation: sm4.c:cipher_block_xor_2dst
Unexecuted instantiation: twofish.c:cipher_block_xor_2dst
Unexecuted instantiation: arcfour.c:cipher_block_xor_2dst
Unexecuted instantiation: blowfish.c:cipher_block_xor_2dst
Unexecuted instantiation: camellia-glue.c:cipher_block_xor_2dst
Unexecuted instantiation: cast5.c:cipher_block_xor_2dst
Unexecuted instantiation: chacha20.c:cipher_block_xor_2dst
Unexecuted instantiation: cipher-aeswrap.c:cipher_block_xor_2dst
Unexecuted instantiation: cipher-cbc.c:cipher_block_xor_2dst
Unexecuted instantiation: cipher-ccm.c:cipher_block_xor_2dst
Unexecuted instantiation: cipher-cfb.c:cipher_block_xor_2dst
Unexecuted instantiation: cipher-cmac.c:cipher_block_xor_2dst
Unexecuted instantiation: cipher-ctr.c:cipher_block_xor_2dst
Unexecuted instantiation: cipher-eax.c:cipher_block_xor_2dst
Unexecuted instantiation: cipher-gcm-siv.c:cipher_block_xor_2dst
Unexecuted instantiation: cipher-gcm.c:cipher_block_xor_2dst
Unexecuted instantiation: cipher-ocb.c:cipher_block_xor_2dst
Unexecuted instantiation: cipher-ofb.c:cipher_block_xor_2dst
Unexecuted instantiation: cipher-poly1305.c:cipher_block_xor_2dst
Unexecuted instantiation: cipher-siv.c:cipher_block_xor_2dst
Unexecuted instantiation: cipher-xts.c:cipher_block_xor_2dst
Unexecuted instantiation: rijndael-vaes.c:cipher_block_xor_2dst
900
901
902
/* Optimized function for combined cipher block xoring and copying.
903
   Used by mainly CBC mode decryption.  */
904
static inline void
905
cipher_block_xor_n_copy_2(void *_dst_xor, const void *_src_xor,
906
                          void *_srcdst_cpy, const void *_src_cpy,
907
                          size_t blocksize)
908
0
{
909
0
  byte *dst_xor = _dst_xor;
910
0
  byte *srcdst_cpy = _srcdst_cpy;
911
0
  const byte *src_xor = _src_xor;
912
0
  const byte *src_cpy = _src_cpy;
913
0
  u64 sc[2];
914
0
  u64 sx[2];
915
0
  u64 sdc[2];
916
917
0
  if (blocksize == 8)
918
0
    {
919
0
      sc[0] = buf_get_he64(src_cpy + 0);
920
0
      buf_put_he64(dst_xor + 0,
921
0
                   buf_get_he64(srcdst_cpy + 0) ^ buf_get_he64(src_xor + 0));
922
0
      buf_put_he64(srcdst_cpy + 0, sc[0]);
923
0
    }
924
0
  else /* blocksize == 16 */
925
0
    {
926
0
      sc[0] = buf_get_he64(src_cpy + 0);
927
0
      sc[1] = buf_get_he64(src_cpy + 8);
928
0
      sx[0] = buf_get_he64(src_xor + 0);
929
0
      sx[1] = buf_get_he64(src_xor + 8);
930
0
      sdc[0] = buf_get_he64(srcdst_cpy + 0);
931
0
      sdc[1] = buf_get_he64(srcdst_cpy + 8);
932
0
      sx[0] ^= sdc[0];
933
0
      sx[1] ^= sdc[1];
934
0
      buf_put_he64(dst_xor + 0, sx[0]);
935
0
      buf_put_he64(dst_xor + 8, sx[1]);
936
0
      buf_put_he64(srcdst_cpy + 0, sc[0]);
937
0
      buf_put_he64(srcdst_cpy + 8, sc[1]);
938
0
    }
939
0
}
Unexecuted instantiation: cipher.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: des.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: gost28147.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: idea.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: rfc2268.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: rijndael.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: salsa20.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: seed.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: serpent.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: sm4.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: twofish.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: arcfour.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: blowfish.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: camellia-glue.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: cast5.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: chacha20.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: cipher-aeswrap.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: cipher-cbc.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: cipher-ccm.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: cipher-cfb.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: cipher-cmac.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: cipher-ctr.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: cipher-eax.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: cipher-gcm-siv.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: cipher-gcm.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: cipher-ocb.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: cipher-ofb.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: cipher-poly1305.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: cipher-siv.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: cipher-xts.c:cipher_block_xor_n_copy_2
Unexecuted instantiation: rijndael-vaes.c:cipher_block_xor_n_copy_2
940
941
942
/* Optimized function for combined cipher block byte-swapping.  */
943
static inline void
944
cipher_block_bswap (void *_dst_bswap, const void *_src_bswap,
945
                    size_t blocksize)
946
0
{
947
0
  byte *dst_bswap = _dst_bswap;
948
0
  const byte *src_bswap = _src_bswap;
949
0
  u64 t[2];
950
951
0
  if (blocksize == 8)
952
0
    {
953
0
      buf_put_le64(dst_bswap, buf_get_be64(src_bswap));
954
0
    }
955
0
  else
956
0
    {
957
0
      t[0] = buf_get_be64(src_bswap + 0);
958
0
      t[1] = buf_get_be64(src_bswap + 8);
959
0
      buf_put_le64(dst_bswap + 8, t[0]);
960
0
      buf_put_le64(dst_bswap + 0, t[1]);
961
0
    }
962
0
}
Unexecuted instantiation: cipher.c:cipher_block_bswap
Unexecuted instantiation: des.c:cipher_block_bswap
Unexecuted instantiation: gost28147.c:cipher_block_bswap
Unexecuted instantiation: idea.c:cipher_block_bswap
Unexecuted instantiation: rfc2268.c:cipher_block_bswap
Unexecuted instantiation: rijndael.c:cipher_block_bswap
Unexecuted instantiation: salsa20.c:cipher_block_bswap
Unexecuted instantiation: seed.c:cipher_block_bswap
Unexecuted instantiation: serpent.c:cipher_block_bswap
Unexecuted instantiation: sm4.c:cipher_block_bswap
Unexecuted instantiation: twofish.c:cipher_block_bswap
Unexecuted instantiation: arcfour.c:cipher_block_bswap
Unexecuted instantiation: blowfish.c:cipher_block_bswap
Unexecuted instantiation: camellia-glue.c:cipher_block_bswap
Unexecuted instantiation: cast5.c:cipher_block_bswap
Unexecuted instantiation: chacha20.c:cipher_block_bswap
Unexecuted instantiation: cipher-aeswrap.c:cipher_block_bswap
Unexecuted instantiation: cipher-cbc.c:cipher_block_bswap
Unexecuted instantiation: cipher-ccm.c:cipher_block_bswap
Unexecuted instantiation: cipher-cfb.c:cipher_block_bswap
Unexecuted instantiation: cipher-cmac.c:cipher_block_bswap
Unexecuted instantiation: cipher-ctr.c:cipher_block_bswap
Unexecuted instantiation: cipher-eax.c:cipher_block_bswap
Unexecuted instantiation: cipher-gcm-siv.c:cipher_block_bswap
Unexecuted instantiation: cipher-gcm.c:cipher_block_bswap
Unexecuted instantiation: cipher-ocb.c:cipher_block_bswap
Unexecuted instantiation: cipher-ofb.c:cipher_block_bswap
Unexecuted instantiation: cipher-poly1305.c:cipher_block_bswap
Unexecuted instantiation: cipher-siv.c:cipher_block_bswap
Unexecuted instantiation: cipher-xts.c:cipher_block_bswap
Unexecuted instantiation: rijndael-vaes.c:cipher_block_bswap
963
964
965
/* Optimized function for combined cipher block xoring and copying.
966
   Used by mainly CFB mode decryption.  */
967
static inline void
968
cipher_block_xor_n_copy(void *_dst_xor, void *_srcdst_cpy, const void *_src,
969
                        size_t blocksize)
970
0
{
971
0
  cipher_block_xor_n_copy_2(_dst_xor, _src, _srcdst_cpy, _src, blocksize);
972
0
}
Unexecuted instantiation: cipher.c:cipher_block_xor_n_copy
Unexecuted instantiation: des.c:cipher_block_xor_n_copy
Unexecuted instantiation: gost28147.c:cipher_block_xor_n_copy
Unexecuted instantiation: idea.c:cipher_block_xor_n_copy
Unexecuted instantiation: rfc2268.c:cipher_block_xor_n_copy
Unexecuted instantiation: rijndael.c:cipher_block_xor_n_copy
Unexecuted instantiation: salsa20.c:cipher_block_xor_n_copy
Unexecuted instantiation: seed.c:cipher_block_xor_n_copy
Unexecuted instantiation: serpent.c:cipher_block_xor_n_copy
Unexecuted instantiation: sm4.c:cipher_block_xor_n_copy
Unexecuted instantiation: twofish.c:cipher_block_xor_n_copy
Unexecuted instantiation: arcfour.c:cipher_block_xor_n_copy
Unexecuted instantiation: blowfish.c:cipher_block_xor_n_copy
Unexecuted instantiation: camellia-glue.c:cipher_block_xor_n_copy
Unexecuted instantiation: cast5.c:cipher_block_xor_n_copy
Unexecuted instantiation: chacha20.c:cipher_block_xor_n_copy
Unexecuted instantiation: cipher-aeswrap.c:cipher_block_xor_n_copy
Unexecuted instantiation: cipher-cbc.c:cipher_block_xor_n_copy
Unexecuted instantiation: cipher-ccm.c:cipher_block_xor_n_copy
Unexecuted instantiation: cipher-cfb.c:cipher_block_xor_n_copy
Unexecuted instantiation: cipher-cmac.c:cipher_block_xor_n_copy
Unexecuted instantiation: cipher-ctr.c:cipher_block_xor_n_copy
Unexecuted instantiation: cipher-eax.c:cipher_block_xor_n_copy
Unexecuted instantiation: cipher-gcm-siv.c:cipher_block_xor_n_copy
Unexecuted instantiation: cipher-gcm.c:cipher_block_xor_n_copy
Unexecuted instantiation: cipher-ocb.c:cipher_block_xor_n_copy
Unexecuted instantiation: cipher-ofb.c:cipher_block_xor_n_copy
Unexecuted instantiation: cipher-poly1305.c:cipher_block_xor_n_copy
Unexecuted instantiation: cipher-siv.c:cipher_block_xor_n_copy
Unexecuted instantiation: cipher-xts.c:cipher_block_xor_n_copy
Unexecuted instantiation: rijndael-vaes.c:cipher_block_xor_n_copy
973
974
975
#endif /*G10_CIPHER_INTERNAL_H*/