Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/nettle/siv-gcm.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* siv-gcm.h
0002 
0003    AES-GCM-SIV, RFC8452
0004 
0005    Copyright (C) 2022 Red Hat, Inc.
0006 
0007    This file is part of GNU Nettle.
0008 
0009    GNU Nettle is free software: you can redistribute it and/or
0010    modify it under the terms of either:
0011 
0012      * the GNU Lesser General Public License as published by the Free
0013        Software Foundation; either version 3 of the License, or (at your
0014        option) any later version.
0015 
0016    or
0017 
0018      * the GNU General Public License as published by the Free
0019        Software Foundation; either version 2 of the License, or (at your
0020        option) any later version.
0021 
0022    or both in parallel, as here.
0023 
0024    GNU Nettle is distributed in the hope that it will be useful,
0025    but WITHOUT ANY WARRANTY; without even the implied warranty of
0026    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0027    General Public License for more details.
0028 
0029    You should have received copies of the GNU General Public License and
0030    the GNU Lesser General Public License along with this program.  If
0031    not, see http://www.gnu.org/licenses/.
0032 */
0033 
0034 #ifndef NETTLE_SIV_GCM_H_INCLUDED
0035 #define NETTLE_SIV_GCM_H_INCLUDED
0036 
0037 #include "nettle-types.h"
0038 #include "nettle-meta.h"
0039 #include "aes.h"
0040 
0041 #ifdef __cplusplus
0042 extern "C" {
0043 #endif
0044 
0045 /* Name mangling */
0046 #define siv_gcm_encrypt_message nettle_siv_gcm_encrypt_message
0047 #define siv_gcm_decrypt_message nettle_siv_gcm_decrypt_message
0048 #define siv_gcm_aes128_encrypt_message nettle_siv_gcm_aes128_encrypt_message
0049 #define siv_gcm_aes128_decrypt_message nettle_siv_gcm_aes128_decrypt_message
0050 #define siv_gcm_aes256_encrypt_message nettle_siv_gcm_aes256_encrypt_message
0051 #define siv_gcm_aes256_decrypt_message nettle_siv_gcm_aes256_decrypt_message
0052 
0053 /* For AES-GCM-SIV, the block size of the underlying cipher shall be 128 bits. */
0054 #define SIV_GCM_BLOCK_SIZE 16
0055 #define SIV_GCM_DIGEST_SIZE 16
0056 #define SIV_GCM_NONCE_SIZE 12
0057 
0058 /* Generic interface.  NC must be a block cipher with 128-bit block
0059    size, and keysize that is a multiple of 64 bits, such as AES-128 or
0060    AES-256.  */
0061 void
0062 siv_gcm_encrypt_message (const struct nettle_cipher *nc,
0063              const void *ctx,
0064              void *ctr_ctx,
0065              size_t nlength, const uint8_t *nonce,
0066              size_t alength, const uint8_t *adata,
0067              size_t clength, uint8_t *dst, const uint8_t *src);
0068 
0069 int
0070 siv_gcm_decrypt_message (const struct nettle_cipher *nc,
0071              const void *ctx,
0072              void *ctr_ctx,
0073              size_t nlength, const uint8_t *nonce,
0074              size_t alength, const uint8_t *adata,
0075              size_t mlength, uint8_t *dst, const uint8_t *src);
0076 
0077 /* AEAD_AES_128_GCM_SIV */
0078 void
0079 siv_gcm_aes128_encrypt_message (const struct aes128_ctx *ctx,
0080                 size_t nlength, const uint8_t *nonce,
0081                 size_t alength, const uint8_t *adata,
0082                 size_t clength, uint8_t *dst, const uint8_t *src);
0083 
0084 int
0085 siv_gcm_aes128_decrypt_message (const struct aes128_ctx *ctx,
0086                 size_t nlength, const uint8_t *nonce,
0087                 size_t alength, const uint8_t *adata,
0088                 size_t mlength, uint8_t *dst, const uint8_t *src);
0089 
0090 /* AEAD_AES_256_GCM_SIV */
0091 void
0092 siv_gcm_aes256_encrypt_message (const struct aes256_ctx *ctx,
0093                 size_t nlength, const uint8_t *nonce,
0094                 size_t alength, const uint8_t *adata,
0095                 size_t clength, uint8_t *dst, const uint8_t *src);
0096 
0097 int
0098 siv_gcm_aes256_decrypt_message (const struct aes256_ctx *ctx,
0099                 size_t nlength, const uint8_t *nonce,
0100                 size_t alength, const uint8_t *adata,
0101                 size_t mlength, uint8_t *dst, const uint8_t *src);
0102 
0103 #ifdef __cplusplus
0104 }
0105 #endif
0106 
0107 #endif /* NETTLE_SIV_H_INCLUDED */