File indexing completed on 2025-01-18 10:02:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifndef NETTLE_SIV_H_INCLUDED
0035 #define NETTLE_SIV_H_INCLUDED
0036
0037 #include "nettle-types.h"
0038 #include "nettle-meta.h"
0039 #include "cmac.h"
0040 #include "aes.h"
0041
0042 #ifdef __cplusplus
0043 extern "C" {
0044 #endif
0045
0046
0047 #define siv_cmac_set_key nettle_siv_cmac_set_key
0048 #define siv_cmac_encrypt_message nettle_siv_cmac_encrypt_message
0049 #define siv_cmac_decrypt_message nettle_siv_cmac_decrypt_message
0050 #define siv_cmac_aes128_set_key nettle_siv_cmac_aes128_set_key
0051 #define siv_cmac_aes128_encrypt_message nettle_siv_cmac_aes128_encrypt_message
0052 #define siv_cmac_aes128_decrypt_message nettle_siv_cmac_aes128_decrypt_message
0053 #define siv_cmac_aes256_set_key nettle_siv_cmac_aes256_set_key
0054 #define siv_cmac_aes256_encrypt_message nettle_siv_cmac_aes256_encrypt_message
0055 #define siv_cmac_aes256_decrypt_message nettle_siv_cmac_aes256_decrypt_message
0056
0057
0058 #define SIV_BLOCK_SIZE 16
0059 #define SIV_DIGEST_SIZE 16
0060 #define SIV_MIN_NONCE_SIZE 1
0061
0062 void
0063 siv_cmac_set_key(struct cmac128_key *cmac_key, void *cmac_cipher, void *ctr_cipher,
0064 const struct nettle_cipher *nc,
0065 const uint8_t *key);
0066
0067 void
0068 siv_cmac_encrypt_message(const struct cmac128_key *cmac_key, const void *cmac_cipher_ctx,
0069 const struct nettle_cipher *nc,
0070 const void *ctr_ctx,
0071 size_t nlength, const uint8_t *nonce,
0072 size_t alength, const uint8_t *adata,
0073 size_t clength, uint8_t *dst, const uint8_t *src);
0074
0075 int
0076 siv_cmac_decrypt_message(const struct cmac128_key *cmac_key, const void *cmac_cipher,
0077 const struct nettle_cipher *nc,
0078 const void *ctr_cipher,
0079 size_t nlength, const uint8_t *nonce,
0080 size_t alength, const uint8_t *adata,
0081 size_t mlength, uint8_t *dst, const uint8_t *src);
0082
0083
0084
0085
0086
0087
0088 #define SIV_CMAC_CTX(type) { struct cmac128_key cmac_key; type cmac_cipher; type ctr_cipher; }
0089
0090
0091 #define SIV_CMAC_AES128_KEY_SIZE 32
0092
0093 struct siv_cmac_aes128_ctx SIV_CMAC_CTX(struct aes128_ctx);
0094
0095 void
0096 siv_cmac_aes128_set_key(struct siv_cmac_aes128_ctx *ctx, const uint8_t *key);
0097
0098 void
0099 siv_cmac_aes128_encrypt_message(const struct siv_cmac_aes128_ctx *ctx,
0100 size_t nlength, const uint8_t *nonce,
0101 size_t alength, const uint8_t *adata,
0102 size_t clength, uint8_t *dst, const uint8_t *src);
0103
0104 int
0105 siv_cmac_aes128_decrypt_message(const struct siv_cmac_aes128_ctx *ctx,
0106 size_t nlength, const uint8_t *nonce,
0107 size_t alength, const uint8_t *adata,
0108 size_t mlength, uint8_t *dst, const uint8_t *src);
0109
0110
0111 #define SIV_CMAC_AES256_KEY_SIZE 64
0112
0113 struct siv_cmac_aes256_ctx SIV_CMAC_CTX(struct aes256_ctx);
0114
0115 void
0116 siv_cmac_aes256_set_key(struct siv_cmac_aes256_ctx *ctx, const uint8_t *key);
0117
0118 void
0119 siv_cmac_aes256_encrypt_message(const struct siv_cmac_aes256_ctx *ctx,
0120 size_t nlength, const uint8_t *nonce,
0121 size_t alength, const uint8_t *adata,
0122 size_t clength, uint8_t *dst, const uint8_t *src);
0123
0124 int
0125 siv_cmac_aes256_decrypt_message(const struct siv_cmac_aes256_ctx *ctx,
0126 size_t nlength, const uint8_t *nonce,
0127 size_t alength, const uint8_t *adata,
0128 size_t mlength, uint8_t *dst, const uint8_t *src);
0129
0130 #ifdef __cplusplus
0131 }
0132 #endif
0133
0134 #endif