Coverage Report

Created: 2023-03-26 08:33

/src/gnutls/lib/accelerated/x86/aes-gcm-aead.h
Line
Count
Source (jump to first uncovered line)
1
#ifndef GNUTLS_LIB_ACCELERATED_X86_AES_GCM_AEAD_H
2
# define GNUTLS_LIB_ACCELERATED_X86_AES_GCM_AEAD_H
3
4
static int
5
aes_gcm_aead_encrypt(void *ctx,
6
         const void *nonce, size_t nonce_size,
7
         const void *auth, size_t auth_size,
8
         size_t tag_size,
9
         const void *plain, size_t plain_size,
10
         void *encr, size_t encr_size)
11
0
{
12
  /* proper AEAD cipher */
13
0
  if (unlikely(encr_size - tag_size < plain_size))
14
0
    return gnutls_assert_val(GNUTLS_E_SHORT_MEMORY_BUFFER);
15
16
0
  aes_gcm_setiv(ctx, nonce, nonce_size);
17
0
  aes_gcm_auth(ctx, auth, auth_size);
18
19
0
  aes_gcm_encrypt(ctx, plain, plain_size, encr, encr_size);
20
21
0
  aes_gcm_tag(ctx, ((uint8_t *) encr) + plain_size, tag_size);
22
0
  return 0;
23
0
}
Unexecuted instantiation: aes-gcm-padlock.c:aes_gcm_aead_encrypt
Unexecuted instantiation: aes-gcm-x86-aesni.c:aes_gcm_aead_encrypt
Unexecuted instantiation: aes-gcm-x86-pclmul.c:aes_gcm_aead_encrypt
Unexecuted instantiation: aes-gcm-x86-ssse3.c:aes_gcm_aead_encrypt
24
25
static int
26
aes_gcm_aead_decrypt(void *ctx,
27
         const void *nonce, size_t nonce_size,
28
         const void *auth, size_t auth_size,
29
         size_t tag_size,
30
         const void *encr, size_t encr_size,
31
         void *plain, size_t plain_size)
32
0
{
33
0
  uint8_t tag[MAX_HASH_SIZE];
34
35
0
  if (unlikely(encr_size < tag_size))
36
0
    return gnutls_assert_val(GNUTLS_E_DECRYPTION_FAILED);
37
38
0
  if (unlikely(plain_size < encr_size - tag_size))
39
0
    return gnutls_assert_val(GNUTLS_E_SHORT_MEMORY_BUFFER);
40
41
0
  aes_gcm_setiv(ctx, nonce, nonce_size);
42
0
  aes_gcm_auth(ctx, auth, auth_size);
43
44
0
  encr_size -= tag_size;
45
0
  aes_gcm_decrypt(ctx, encr, encr_size, plain, plain_size);
46
47
0
  aes_gcm_tag(ctx, tag, tag_size);
48
49
0
  if (gnutls_memcmp(((uint8_t *) encr) + encr_size, tag, tag_size) != 0)
50
0
    return gnutls_assert_val(GNUTLS_E_DECRYPTION_FAILED);
51
52
0
  return 0;
53
0
}
Unexecuted instantiation: aes-gcm-padlock.c:aes_gcm_aead_decrypt
Unexecuted instantiation: aes-gcm-x86-aesni.c:aes_gcm_aead_decrypt
Unexecuted instantiation: aes-gcm-x86-pclmul.c:aes_gcm_aead_decrypt
Unexecuted instantiation: aes-gcm-x86-ssse3.c:aes_gcm_aead_decrypt
54
55
#endif        /* GNUTLS_LIB_ACCELERATED_X86_AES_GCM_AEAD_H */