Coverage Report

Created: 2023-09-25 06:34

/src/nettle-with-mini-gmp/siv-gcm-aes256.c
Line
Count
Source
1
/* siv-gcm-aes256.c
2
3
   AES-GCM-SIV, RFC8452
4
5
   Copyright (C) 2022 Red Hat, Inc.
6
7
   This file is part of GNU Nettle.
8
9
   GNU Nettle is free software: you can redistribute it and/or
10
   modify it under the terms of either:
11
12
     * the GNU Lesser General Public License as published by the Free
13
       Software Foundation; either version 3 of the License, or (at your
14
       option) any later version.
15
16
   or
17
18
     * the GNU General Public License as published by the Free
19
       Software Foundation; either version 2 of the License, or (at your
20
       option) any later version.
21
22
   or both in parallel, as here.
23
24
   GNU Nettle is distributed in the hope that it will be useful,
25
   but WITHOUT ANY WARRANTY; without even the implied warranty of
26
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
27
   General Public License for more details.
28
29
   You should have received copies of the GNU General Public License and
30
   the GNU Lesser General Public License along with this program.  If
31
   not, see http://www.gnu.org/licenses/.
32
*/
33
34
#if HAVE_CONFIG_H
35
# include "config.h"
36
#endif
37
38
#include "nettle-meta.h"
39
#include "siv-gcm.h"
40
41
void
42
siv_gcm_aes256_encrypt_message (const struct aes256_ctx *ctx,
43
        size_t nlength, const uint8_t *nonce,
44
        size_t alength, const uint8_t *adata,
45
        size_t clength, uint8_t *dst, const uint8_t *src)
46
131
{
47
131
  struct aes256_ctx ctr_ctx;
48
131
  siv_gcm_encrypt_message (&nettle_aes256, ctx, &ctr_ctx,
49
131
         nlength, nonce,
50
131
         alength, adata,
51
131
         clength, dst, src);
52
131
}
53
54
int
55
siv_gcm_aes256_decrypt_message (const struct aes256_ctx *ctx,
56
        size_t nlength, const uint8_t *nonce,
57
        size_t alength, const uint8_t *adata,
58
        size_t mlength, uint8_t *dst, const uint8_t *src)
59
186
{
60
186
  struct aes256_ctx ctr_ctx;
61
186
  return siv_gcm_decrypt_message (&nettle_aes256, ctx, &ctr_ctx,
62
186
          nlength, nonce,
63
186
          alength, adata,
64
186
          mlength, dst, src);
65
186
}