Coverage Report

Created: 2025-03-18 06:55

/src/gnutls/lib/accelerated/x86/aes-x86.h
Line
Count
Source (jump to first uncovered line)
1
#ifndef GNUTLS_LIB_ACCELERATED_X86_AES_X86_H
2
#define GNUTLS_LIB_ACCELERATED_X86_AES_X86_H
3
4
#include "gnutls_int.h"
5
6
void register_x86_crypto(void);
7
8
#define ALIGN16(x) \
9
0
  ((void *)(((ptrdiff_t)(x) + (ptrdiff_t)0x0f) & ~((ptrdiff_t)0x0f)))
10
11
#define AES_KEY_ALIGN_SIZE 4
12
#define AES_MAXNR 14
13
typedef struct {
14
  /* We add few more integers to allow alignment 
15
   * on a 16-byte boundary.
16
   */
17
  uint32_t rd_key[4 * (AES_MAXNR + 1) + AES_KEY_ALIGN_SIZE];
18
  uint32_t rounds;
19
} AES_KEY;
20
21
#define CHECK_AES_KEYSIZE(s)               \
22
  if (s != 16 && s != 24 && s != 32) \
23
  return GNUTLS_E_INVALID_REQUEST
24
25
#include <intprops.h>
26
0
#define AES_GCM_ENCRYPT_MAX_BYTES ((1ULL << 36) - 32)
27
static inline int record_aes_gcm_encrypt_size(size_t *counter, size_t size)
28
0
{
29
0
  size_t sum;
30
31
0
  if (!INT_ADD_OK(*counter, size, &sum) ||
32
0
      sum > AES_GCM_ENCRYPT_MAX_BYTES) {
33
0
    return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
34
0
  }
35
0
  *counter = sum;
36
37
0
  return 0;
38
0
}
Unexecuted instantiation: accelerated.c:record_aes_gcm_encrypt_size
Unexecuted instantiation: x86-common.c:record_aes_gcm_encrypt_size
Unexecuted instantiation: aes-cbc-x86-aesni.c:record_aes_gcm_encrypt_size
Unexecuted instantiation: aes-cbc-x86-ssse3.c:record_aes_gcm_encrypt_size
Unexecuted instantiation: aes-ccm-x86-aesni.c:record_aes_gcm_encrypt_size
Unexecuted instantiation: aes-gcm-padlock.c:record_aes_gcm_encrypt_size
Unexecuted instantiation: aes-gcm-x86-aesni.c:record_aes_gcm_encrypt_size
Unexecuted instantiation: aes-gcm-x86-pclmul-avx.c:record_aes_gcm_encrypt_size
Unexecuted instantiation: aes-gcm-x86-pclmul.c:record_aes_gcm_encrypt_size
Unexecuted instantiation: aes-gcm-x86-ssse3.c:record_aes_gcm_encrypt_size
Unexecuted instantiation: aes-padlock.c:record_aes_gcm_encrypt_size
Unexecuted instantiation: aes-xts-x86-aesni.c:record_aes_gcm_encrypt_size
Unexecuted instantiation: hmac-padlock.c:record_aes_gcm_encrypt_size
Unexecuted instantiation: hmac-x86-ssse3.c:record_aes_gcm_encrypt_size
Unexecuted instantiation: sha-padlock.c:record_aes_gcm_encrypt_size
Unexecuted instantiation: sha-x86-ssse3.c:record_aes_gcm_encrypt_size
39
40
void aesni_ecb_encrypt(const unsigned char *in, unsigned char *out, size_t len,
41
           const AES_KEY *key, int enc);
42
43
void aesni_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len,
44
           const AES_KEY *key, unsigned char *ivec, const int enc);
45
int aesni_set_decrypt_key(const unsigned char *userKey, const int bits,
46
        AES_KEY *key);
47
int aesni_set_encrypt_key(const unsigned char *userKey, const int bits,
48
        AES_KEY *key);
49
50
void aesni_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out,
51
        size_t blocks, const void *key,
52
        const unsigned char *ivec);
53
54
size_t aesni_gcm_encrypt(const void *inp, void *out, size_t len,
55
       const AES_KEY *key, const unsigned char iv[16],
56
       uint64_t *Xi);
57
58
size_t aesni_gcm_decrypt(const void *inp, void *out, size_t len,
59
       const AES_KEY *key, const unsigned char iv[16],
60
       uint64_t *Xi);
61
62
void aesni_xts_encrypt(const unsigned char *in, unsigned char *out, size_t len,
63
           const AES_KEY *key, const AES_KEY *key2,
64
           const unsigned char iv[16]);
65
66
void aesni_xts_decrypt(const unsigned char *in, unsigned char *out, size_t len,
67
           const AES_KEY *key, const AES_KEY *key2,
68
           const unsigned char iv[16]);
69
70
int vpaes_set_encrypt_key(const unsigned char *userKey, int bits, AES_KEY *key);
71
int vpaes_set_decrypt_key(const unsigned char *userKey, int bits, AES_KEY *key);
72
void vpaes_cbc_encrypt(const unsigned char *in, unsigned char *out,
73
           size_t length, const AES_KEY *key, unsigned char *ivec,
74
           int enc);
75
void vpaes_encrypt(const unsigned char *in, unsigned char *out,
76
       const AES_KEY *key);
77
void vpaes_decrypt(const unsigned char *in, unsigned char *out,
78
       const AES_KEY *key);
79
80
extern const gnutls_crypto_cipher_st _gnutls_aes_gcm_pclmul;
81
extern const gnutls_crypto_cipher_st _gnutls_aes_gcm_pclmul_avx;
82
extern const gnutls_crypto_cipher_st _gnutls_aes_gcm_x86_aesni;
83
extern const gnutls_crypto_cipher_st _gnutls_aes_ccm_x86_aesni;
84
extern const gnutls_crypto_cipher_st _gnutls_aes_xts_x86_aesni;
85
extern const gnutls_crypto_cipher_st _gnutls_aes_gcm_x86_ssse3;
86
87
extern const gnutls_crypto_cipher_st _gnutls_aes_ssse3;
88
89
extern const gnutls_crypto_cipher_st _gnutls_aesni_x86;
90
91
#endif /* GNUTLS_LIB_ACCELERATED_X86_AES_X86_H */