This commit is contained in:
Pauli 2025-07-30 22:11:27 +08:00 committed by GitHub
commit 178edb5d3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
98 changed files with 2122 additions and 427 deletions

3
.gitignore vendored
View File

@ -59,9 +59,6 @@
/include/openssl/x509_vfy.h
/include/openssl/core_names.h
# Auto generated parameter name files
/crypto/params_idx.c
# Auto generated doc files
doc/man1/openssl-*.pod

View File

@ -52,6 +52,11 @@ OpenSSL 3.6
*Alexandr Nedvedicky*
* Added NIST post-quantum security strength categories for cipher, digests
and public key algorithms.
*Dr Paul Dale*
* The VxWorks platforms have been removed. These platforms were unadopted,
unmaintained and reported to be non-functional.

View File

@ -984,9 +984,10 @@ static void set_legacy_nid(const char *name, void *vlegacy_nid)
static int evp_md_cache_constants(EVP_MD *md)
{
int ok, xof = 0, algid_absent = 0;
int seccat_collision = -1, seccat_preimage = -1;
size_t blksz = 0;
size_t mdsize = 0;
OSSL_PARAM params[5];
OSSL_PARAM params[7];
/*
* Note that these parameters are 'constants' that are only set up
@ -998,13 +999,19 @@ static int evp_md_cache_constants(EVP_MD *md)
params[2] = OSSL_PARAM_construct_int(OSSL_DIGEST_PARAM_XOF, &xof);
params[3] = OSSL_PARAM_construct_int(OSSL_DIGEST_PARAM_ALGID_ABSENT,
&algid_absent);
params[4] = OSSL_PARAM_construct_end();
params[4] = OSSL_PARAM_construct_int(OSSL_DIGEST_PARAM_SECURITY_CATEGORY_COLLISION,
&seccat_collision);
params[5] = OSSL_PARAM_construct_int(OSSL_DIGEST_PARAM_SECURITY_CATEGORY_PREIMAGE,
&seccat_preimage);
params[6] = OSSL_PARAM_construct_end();
ok = evp_do_md_getparams(md, params) > 0;
if (mdsize > INT_MAX || blksz > INT_MAX)
ok = 0;
if (ok) {
md->block_size = (int)blksz;
md->md_size = (int)mdsize;
md->security_category_collision = seccat_collision;
md->security_category_preimage = seccat_preimage;
if (xof)
md->flags |= EVP_MD_FLAG_XOF;
if (algid_absent)

View File

@ -419,9 +419,9 @@ static int aesni_ocb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t len);
# endif /* OPENSSL_NO_OCB */
# define BLOCK_CIPHER_generic(nid,keylen,blocksize,ivlen,nmode,mode,MODE,flags) \
# define BLOCK_CIPHER_generic(nid,keylen,blocksize,ivlen,seccat,nmode,mode,MODE,flags) \
static const EVP_CIPHER aesni_##keylen##_##mode = { \
nid##_##keylen##_##nmode,blocksize,keylen/8,ivlen, \
nid##_##keylen##_##nmode,blocksize,keylen/8,ivlen, seccat, \
flags|EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
aesni_init_key, \
@ -431,7 +431,7 @@ static const EVP_CIPHER aesni_##keylen##_##mode = { \
NULL,NULL,NULL,NULL }; \
static const EVP_CIPHER aes_##keylen##_##mode = { \
nid##_##keylen##_##nmode,blocksize, \
keylen/8,ivlen, \
keylen/8,ivlen, seccat, \
flags|EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
aes_init_key, \
@ -442,11 +442,11 @@ static const EVP_CIPHER aes_##keylen##_##mode = { \
const EVP_CIPHER *EVP_aes_##keylen##_##mode(void) \
{ return AESNI_CAPABLE?&aesni_##keylen##_##mode:&aes_##keylen##_##mode; }
# define BLOCK_CIPHER_custom(nid,keylen,blocksize,ivlen,mode,MODE,flags) \
# define BLOCK_CIPHER_custom(nid,keylen,blocksize,ivlen,seccat,mode,MODE,flags) \
static const EVP_CIPHER aesni_##keylen##_##mode = { \
nid##_##keylen##_##mode,blocksize, \
(EVP_CIPH_##MODE##_MODE==EVP_CIPH_XTS_MODE||EVP_CIPH_##MODE##_MODE==EVP_CIPH_SIV_MODE?2:1)*keylen/8, \
ivlen, \
ivlen, seccat, \
flags|EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
aesni_##mode##_init_key, \
@ -457,7 +457,7 @@ static const EVP_CIPHER aesni_##keylen##_##mode = { \
static const EVP_CIPHER aes_##keylen##_##mode = { \
nid##_##keylen##_##mode,blocksize, \
(EVP_CIPH_##MODE##_MODE==EVP_CIPH_XTS_MODE||EVP_CIPH_##MODE##_MODE==EVP_CIPH_SIV_MODE?2:1)*keylen/8, \
ivlen, \
ivlen, seccat, \
flags|EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
aes_##mode##_init_key, \
@ -805,9 +805,9 @@ static int aes_t4_ocb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
# define aes_t4_siv_cipher aes_siv_cipher
# endif /* OPENSSL_NO_SIV */
# define BLOCK_CIPHER_generic(nid,keylen,blocksize,ivlen,nmode,mode,MODE,flags) \
# define BLOCK_CIPHER_generic(nid,keylen,blocksize,ivlen,seccat,nmode,mode,MODE,flags) \
static const EVP_CIPHER aes_t4_##keylen##_##mode = { \
nid##_##keylen##_##nmode,blocksize,keylen/8,ivlen, \
nid##_##keylen##_##nmode,blocksize,keylen/8,ivlen, seccat, \
flags|EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
aes_t4_init_key, \
@ -817,7 +817,7 @@ static const EVP_CIPHER aes_t4_##keylen##_##mode = { \
NULL,NULL,NULL,NULL }; \
static const EVP_CIPHER aes_##keylen##_##mode = { \
nid##_##keylen##_##nmode,blocksize, \
keylen/8,ivlen, \
keylen/8,ivlen, seccat, \
flags|EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
aes_init_key, \
@ -828,11 +828,11 @@ static const EVP_CIPHER aes_##keylen##_##mode = { \
const EVP_CIPHER *EVP_aes_##keylen##_##mode(void) \
{ return SPARC_AES_CAPABLE?&aes_t4_##keylen##_##mode:&aes_##keylen##_##mode; }
# define BLOCK_CIPHER_custom(nid,keylen,blocksize,ivlen,mode,MODE,flags) \
# define BLOCK_CIPHER_custom(nid,keylen,blocksize,ivlen,seccat,mode,MODE,flags) \
static const EVP_CIPHER aes_t4_##keylen##_##mode = { \
nid##_##keylen##_##mode,blocksize, \
(EVP_CIPH_##MODE##_MODE==EVP_CIPH_XTS_MODE||EVP_CIPH_##MODE##_MODE==EVP_CIPH_SIV_MODE?2:1)*keylen/8, \
ivlen, \
ivlen, seccat, \
flags|EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
aes_t4_##mode##_init_key, \
@ -843,7 +843,7 @@ static const EVP_CIPHER aes_t4_##keylen##_##mode = { \
static const EVP_CIPHER aes_##keylen##_##mode = { \
nid##_##keylen##_##mode,blocksize, \
(EVP_CIPH_##MODE##_MODE==EVP_CIPH_XTS_MODE||EVP_CIPH_##MODE##_MODE==EVP_CIPH_SIV_MODE?2:1)*keylen/8, \
ivlen, \
ivlen, seccat, \
flags|EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
aes_##mode##_init_key, \
@ -2282,12 +2282,12 @@ static int s390x_aes_ocb_ctrl(EVP_CIPHER_CTX *, int type, int arg, void *ptr);
# define s390x_aes_siv_ctrl aes_siv_ctrl
# endif
# define BLOCK_CIPHER_generic(nid,keylen,blocksize,ivlen,nmode,mode, \
MODE,flags) \
# define BLOCK_CIPHER_generic(nid,keylen,blocksize,ivlen,seccat, \
nmode,mode,MODE,flags) \
static const EVP_CIPHER s390x_aes_##keylen##_##mode = { \
nid##_##keylen##_##nmode,blocksize, \
keylen / 8, \
ivlen, \
ivlen, seccat, \
flags | EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
s390x_aes_##mode##_init_key, \
@ -2303,7 +2303,7 @@ static const EVP_CIPHER aes_##keylen##_##mode = { \
nid##_##keylen##_##nmode, \
blocksize, \
keylen / 8, \
ivlen, \
ivlen, seccat, \
flags | EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
aes_init_key, \
@ -2321,12 +2321,12 @@ const EVP_CIPHER *EVP_aes_##keylen##_##mode(void) \
&s390x_aes_##keylen##_##mode : &aes_##keylen##_##mode; \
}
# define BLOCK_CIPHER_custom(nid,keylen,blocksize,ivlen,mode,MODE,flags)\
# define BLOCK_CIPHER_custom(nid,keylen,blocksize,ivlen,seccat,mode,MODE,flags)\
static const EVP_CIPHER s390x_aes_##keylen##_##mode = { \
nid##_##keylen##_##mode, \
blocksize, \
(EVP_CIPH_##MODE##_MODE==EVP_CIPH_XTS_MODE||EVP_CIPH_##MODE##_MODE==EVP_CIPH_SIV_MODE ? 2 : 1) * keylen / 8, \
ivlen, \
ivlen, seccat, \
flags | EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
s390x_aes_##mode##_init_key, \
@ -2341,7 +2341,7 @@ static const EVP_CIPHER s390x_aes_##keylen##_##mode = { \
static const EVP_CIPHER aes_##keylen##_##mode = { \
nid##_##keylen##_##mode,blocksize, \
(EVP_CIPH_##MODE##_MODE==EVP_CIPH_XTS_MODE||EVP_CIPH_##MODE##_MODE==EVP_CIPH_SIV_MODE ? 2 : 1) * keylen / 8, \
ivlen, \
ivlen, seccat, \
flags | EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
aes_##mode##_init_key, \
@ -2361,9 +2361,9 @@ const EVP_CIPHER *EVP_aes_##keylen##_##mode(void) \
#else
# define BLOCK_CIPHER_generic(nid,keylen,blocksize,ivlen,nmode,mode,MODE,flags) \
# define BLOCK_CIPHER_generic(nid,keylen,blocksize,ivlen,seccat,nmode,mode,MODE,flags) \
static const EVP_CIPHER aes_##keylen##_##mode = { \
nid##_##keylen##_##nmode,blocksize,keylen/8,ivlen, \
nid##_##keylen##_##nmode,blocksize,keylen/8,ivlen, seccat, \
flags|EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
aes_init_key, \
@ -2374,11 +2374,11 @@ static const EVP_CIPHER aes_##keylen##_##mode = { \
const EVP_CIPHER *EVP_aes_##keylen##_##mode(void) \
{ return &aes_##keylen##_##mode; }
# define BLOCK_CIPHER_custom(nid,keylen,blocksize,ivlen,mode,MODE,flags) \
# define BLOCK_CIPHER_custom(nid,keylen,blocksize,ivlen,seccat,mode,MODE,flags) \
static const EVP_CIPHER aes_##keylen##_##mode = { \
nid##_##keylen##_##mode,blocksize, \
(EVP_CIPH_##MODE##_MODE==EVP_CIPH_XTS_MODE||EVP_CIPH_##MODE##_MODE==EVP_CIPH_SIV_MODE?2:1)*keylen/8, \
ivlen, \
ivlen, seccat, \
flags|EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
aes_##mode##_init_key, \
@ -2391,14 +2391,14 @@ const EVP_CIPHER *EVP_aes_##keylen##_##mode(void) \
#endif
#define BLOCK_CIPHER_generic_pack(nid,keylen,flags) \
BLOCK_CIPHER_generic(nid,keylen,16,16,cbc,cbc,CBC,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid,keylen,16,0,ecb,ecb,ECB,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid,keylen,1,16,ofb128,ofb,OFB,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid,keylen,1,16,cfb128,cfb,CFB,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid,keylen,1,16,cfb1,cfb1,CFB,flags) \
BLOCK_CIPHER_generic(nid,keylen,1,16,cfb8,cfb8,CFB,flags) \
BLOCK_CIPHER_generic(nid,keylen,1,16,ctr,ctr,CTR,flags)
#define BLOCK_CIPHER_generic_pack(nid,keylen,seccat,flags) \
BLOCK_CIPHER_generic(nid,keylen,16,16,seccat,cbc,cbc,CBC,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid,keylen,16,0,seccat,ecb,ecb,ECB,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid,keylen,1,16,seccat,ofb128,ofb,OFB,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid,keylen,1,16,seccat,cfb128,cfb,CFB,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid,keylen,1,16,seccat,cfb1,cfb1,CFB,flags) \
BLOCK_CIPHER_generic(nid,keylen,1,16,seccat,cfb8,cfb8,CFB,flags) \
BLOCK_CIPHER_generic(nid,keylen,1,16,seccat,ctr,ctr,CTR,flags)
static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
const unsigned char *iv, int enc)
@ -2632,9 +2632,9 @@ static int aes_ctr_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
return 1;
}
BLOCK_CIPHER_generic_pack(NID_aes, 128, 0)
BLOCK_CIPHER_generic_pack(NID_aes, 192, 0)
BLOCK_CIPHER_generic_pack(NID_aes, 256, 0)
BLOCK_CIPHER_generic_pack(NID_aes, 128, 1, 0)
BLOCK_CIPHER_generic_pack(NID_aes, 192, 3, 0)
BLOCK_CIPHER_generic_pack(NID_aes, 256, 5, 0)
static int aes_gcm_cleanup(EVP_CIPHER_CTX *c)
{
@ -3181,11 +3181,11 @@ static int aes_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
| EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT \
| EVP_CIPH_CUSTOM_COPY | EVP_CIPH_CUSTOM_IV_LENGTH)
BLOCK_CIPHER_custom(NID_aes, 128, 1, 12, gcm, GCM,
BLOCK_CIPHER_custom(NID_aes, 128, 1, 12, 1, gcm, GCM,
EVP_CIPH_FLAG_AEAD_CIPHER | CUSTOM_FLAGS)
BLOCK_CIPHER_custom(NID_aes, 192, 1, 12, gcm, GCM,
BLOCK_CIPHER_custom(NID_aes, 192, 1, 12, 3, gcm, GCM,
EVP_CIPH_FLAG_AEAD_CIPHER | CUSTOM_FLAGS)
BLOCK_CIPHER_custom(NID_aes, 256, 1, 12, gcm, GCM,
BLOCK_CIPHER_custom(NID_aes, 256, 1, 12, 5, gcm, GCM,
EVP_CIPH_FLAG_AEAD_CIPHER | CUSTOM_FLAGS)
static int aes_xts_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
@ -3371,8 +3371,8 @@ static int aes_xts_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
| EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT \
| EVP_CIPH_CUSTOM_COPY)
BLOCK_CIPHER_custom(NID_aes, 128, 1, 16, xts, XTS, XTS_FLAGS)
BLOCK_CIPHER_custom(NID_aes, 256, 1, 16, xts, XTS, XTS_FLAGS)
BLOCK_CIPHER_custom(NID_aes, 128, 1, 16, 1, xts, XTS, XTS_FLAGS)
BLOCK_CIPHER_custom(NID_aes, 256, 1, 16, 5, xts, XTS, XTS_FLAGS)
static int aes_ccm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
{
@ -3649,11 +3649,11 @@ static int aes_ccm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
#define aes_ccm_cleanup NULL
BLOCK_CIPHER_custom(NID_aes, 128, 1, 12, ccm, CCM,
BLOCK_CIPHER_custom(NID_aes, 128, 1, 12, 1, ccm, CCM,
EVP_CIPH_FLAG_AEAD_CIPHER | CUSTOM_FLAGS)
BLOCK_CIPHER_custom(NID_aes, 192, 1, 12, ccm, CCM,
BLOCK_CIPHER_custom(NID_aes, 192, 1, 12, 3, ccm, CCM,
EVP_CIPH_FLAG_AEAD_CIPHER | CUSTOM_FLAGS)
BLOCK_CIPHER_custom(NID_aes, 256, 1, 12, ccm, CCM,
BLOCK_CIPHER_custom(NID_aes, 256, 1, 12, 5, ccm, CCM,
EVP_CIPH_FLAG_AEAD_CIPHER | CUSTOM_FLAGS)
typedef struct {
@ -3761,7 +3761,7 @@ static int aes_wrap_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
static const EVP_CIPHER aes_128_wrap = {
NID_id_aes128_wrap,
8, 16, 8, WRAP_FLAGS, EVP_ORIG_GLOBAL,
8, 16, 8, 1, WRAP_FLAGS, EVP_ORIG_GLOBAL,
aes_wrap_init_key, aes_wrap_cipher,
NULL,
sizeof(EVP_AES_WRAP_CTX),
@ -3775,7 +3775,7 @@ const EVP_CIPHER *EVP_aes_128_wrap(void)
static const EVP_CIPHER aes_192_wrap = {
NID_id_aes192_wrap,
8, 24, 8, WRAP_FLAGS, EVP_ORIG_GLOBAL,
8, 24, 8, 3, WRAP_FLAGS, EVP_ORIG_GLOBAL,
aes_wrap_init_key, aes_wrap_cipher,
NULL,
sizeof(EVP_AES_WRAP_CTX),
@ -3789,7 +3789,7 @@ const EVP_CIPHER *EVP_aes_192_wrap(void)
static const EVP_CIPHER aes_256_wrap = {
NID_id_aes256_wrap,
8, 32, 8, WRAP_FLAGS, EVP_ORIG_GLOBAL,
8, 32, 8, 5, WRAP_FLAGS, EVP_ORIG_GLOBAL,
aes_wrap_init_key, aes_wrap_cipher,
NULL,
sizeof(EVP_AES_WRAP_CTX),
@ -3803,7 +3803,7 @@ const EVP_CIPHER *EVP_aes_256_wrap(void)
static const EVP_CIPHER aes_128_wrap_pad = {
NID_id_aes128_wrap_pad,
8, 16, 4, WRAP_FLAGS, EVP_ORIG_GLOBAL,
8, 16, 4, 1, WRAP_FLAGS, EVP_ORIG_GLOBAL,
aes_wrap_init_key, aes_wrap_cipher,
NULL,
sizeof(EVP_AES_WRAP_CTX),
@ -3817,7 +3817,7 @@ const EVP_CIPHER *EVP_aes_128_wrap_pad(void)
static const EVP_CIPHER aes_192_wrap_pad = {
NID_id_aes192_wrap_pad,
8, 24, 4, WRAP_FLAGS, EVP_ORIG_GLOBAL,
8, 24, 4, 3, WRAP_FLAGS, EVP_ORIG_GLOBAL,
aes_wrap_init_key, aes_wrap_cipher,
NULL,
sizeof(EVP_AES_WRAP_CTX),
@ -3831,7 +3831,7 @@ const EVP_CIPHER *EVP_aes_192_wrap_pad(void)
static const EVP_CIPHER aes_256_wrap_pad = {
NID_id_aes256_wrap_pad,
8, 32, 4, WRAP_FLAGS, EVP_ORIG_GLOBAL,
8, 32, 4, 5, WRAP_FLAGS, EVP_ORIG_GLOBAL,
aes_wrap_init_key, aes_wrap_cipher,
NULL,
sizeof(EVP_AES_WRAP_CTX),
@ -4145,10 +4145,10 @@ static int aes_ocb_cleanup(EVP_CIPHER_CTX *c)
return 1;
}
BLOCK_CIPHER_custom(NID_aes, 128, 16, 12, ocb, OCB,
BLOCK_CIPHER_custom(NID_aes, 128, 16, 12, 1, ocb, OCB,
EVP_CIPH_FLAG_AEAD_CIPHER | CUSTOM_FLAGS)
BLOCK_CIPHER_custom(NID_aes, 192, 16, 12, ocb, OCB,
BLOCK_CIPHER_custom(NID_aes, 192, 16, 12, 3, ocb, OCB,
EVP_CIPH_FLAG_AEAD_CIPHER | CUSTOM_FLAGS)
BLOCK_CIPHER_custom(NID_aes, 256, 16, 12, ocb, OCB,
BLOCK_CIPHER_custom(NID_aes, 256, 16, 12, 5, ocb, OCB,
EVP_CIPH_FLAG_AEAD_CIPHER | CUSTOM_FLAGS)
#endif /* OPENSSL_NO_OCB */

View File

@ -912,13 +912,23 @@ static int aesni_cbc_hmac_sha1_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,
}
}
static EVP_CIPHER aesni_128_cbc_hmac_sha1_cipher = {
/*
* Note about security categories.
*
* The security category of the combined algorithms will be the lower of
* the category for the cipher and the HMAC. NIST has not defined security
* categories for HMACs at this stage but it seems reasonable to equate
* these to the pre-image security category of the underlying digest. The
* pre-image category of SHA1 is less than or equal to the category for the
* AES flavour used, so we use it throughout.
*/
static const EVP_CIPHER aesni_128_cbc_hmac_sha1_cipher = {
# ifdef NID_aes_128_cbc_hmac_sha1
NID_aes_128_cbc_hmac_sha1,
# else
NID_undef,
# endif
AES_BLOCK_SIZE, 16, AES_BLOCK_SIZE,
AES_BLOCK_SIZE, 16, AES_BLOCK_SIZE, SHA1_PREIMAGE_CATEGORY,
EVP_CIPH_CBC_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1 |
EVP_CIPH_FLAG_AEAD_CIPHER | EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK,
EVP_ORIG_GLOBAL,
@ -932,13 +942,13 @@ static EVP_CIPHER aesni_128_cbc_hmac_sha1_cipher = {
NULL
};
static EVP_CIPHER aesni_256_cbc_hmac_sha1_cipher = {
static const EVP_CIPHER aesni_256_cbc_hmac_sha1_cipher = {
# ifdef NID_aes_256_cbc_hmac_sha1
NID_aes_256_cbc_hmac_sha1,
# else
NID_undef,
# endif
AES_BLOCK_SIZE, 32, AES_BLOCK_SIZE,
AES_BLOCK_SIZE, 32, AES_BLOCK_SIZE, SHA1_PREIMAGE_CATEGORY,
EVP_CIPH_CBC_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1 |
EVP_CIPH_FLAG_AEAD_CIPHER | EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK,
EVP_ORIG_GLOBAL,

View File

@ -889,13 +889,23 @@ static int aesni_cbc_hmac_sha256_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,
}
}
static EVP_CIPHER aesni_128_cbc_hmac_sha256_cipher = {
/*
* Note about security categories.
*
* The security category of the combined algorithms will be the lower of
* the category for the cipher and the HMAC. NIST has not defined security
* categories for HMACs at this stage but it seems reasonable to equate
* these to the pre-image security category of the underlying digest.
*/
#define SEC_CAT(c) ((c) < SHA256_PREIMAGE_CATEGORY ? (c) : SHA256_PREIMAGE_CATEGORY)
static const EVP_CIPHER aesni_128_cbc_hmac_sha256_cipher = {
# ifdef NID_aes_128_cbc_hmac_sha256
NID_aes_128_cbc_hmac_sha256,
# else
NID_undef,
# endif
AES_BLOCK_SIZE, 16, AES_BLOCK_SIZE,
AES_BLOCK_SIZE, 16, AES_BLOCK_SIZE, SEC_CAT(1),
EVP_CIPH_CBC_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1 |
EVP_CIPH_FLAG_AEAD_CIPHER | EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK,
EVP_ORIG_GLOBAL,
@ -909,13 +919,13 @@ static EVP_CIPHER aesni_128_cbc_hmac_sha256_cipher = {
NULL
};
static EVP_CIPHER aesni_256_cbc_hmac_sha256_cipher = {
static const EVP_CIPHER aesni_256_cbc_hmac_sha256_cipher = {
# ifdef NID_aes_256_cbc_hmac_sha256
NID_aes_256_cbc_hmac_sha256,
# else
NID_undef,
# endif
AES_BLOCK_SIZE, 32, AES_BLOCK_SIZE,
AES_BLOCK_SIZE, 32, AES_BLOCK_SIZE, SEC_CAT(5),
EVP_CIPH_CBC_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1 |
EVP_CIPH_FLAG_AEAD_CIPHER | EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK,
EVP_ORIG_GLOBAL,

View File

@ -132,36 +132,36 @@ static void aria_ofb128_encrypt(const unsigned char *in, unsigned char *out,
}
IMPLEMENT_BLOCK_CIPHER(aria_128, ks, aria, EVP_ARIA_KEY,
NID_aria_128, 16, 16, 16, 128,
NID_aria_128, 16, 16, 16, 128, 1,
0, aria_init_key, NULL,
EVP_CIPHER_set_asn1_iv,
EVP_CIPHER_get_asn1_iv,
NULL)
IMPLEMENT_BLOCK_CIPHER(aria_192, ks, aria, EVP_ARIA_KEY,
NID_aria_192, 16, 24, 16, 128,
NID_aria_192, 16, 24, 16, 128, 3,
0, aria_init_key, NULL,
EVP_CIPHER_set_asn1_iv,
EVP_CIPHER_get_asn1_iv,
NULL)
IMPLEMENT_BLOCK_CIPHER(aria_256, ks, aria, EVP_ARIA_KEY,
NID_aria_256, 16, 32, 16, 128,
NID_aria_256, 16, 32, 16, 128, 5,
0, aria_init_key, NULL,
EVP_CIPHER_set_asn1_iv,
EVP_CIPHER_get_asn1_iv,
NULL)
# define IMPLEMENT_ARIA_CFBR(ksize,cbits) \
IMPLEMENT_CFBR(aria,aria,EVP_ARIA_KEY,ks,ksize,cbits,16,0)
IMPLEMENT_ARIA_CFBR(128,1)
IMPLEMENT_ARIA_CFBR(192,1)
IMPLEMENT_ARIA_CFBR(256,1)
IMPLEMENT_ARIA_CFBR(128,8)
IMPLEMENT_ARIA_CFBR(192,8)
IMPLEMENT_ARIA_CFBR(256,8)
# define IMPLEMENT_ARIA_CFBR(ksize,cbits,seccat) \
IMPLEMENT_CFBR(aria,aria,EVP_ARIA_KEY,ks,ksize,cbits,16,seccat,0)
IMPLEMENT_ARIA_CFBR(128,1,1)
IMPLEMENT_ARIA_CFBR(192,1,3)
IMPLEMENT_ARIA_CFBR(256,1,5)
IMPLEMENT_ARIA_CFBR(128,8,1)
IMPLEMENT_ARIA_CFBR(192,8,3)
IMPLEMENT_ARIA_CFBR(256,8,5)
# define BLOCK_CIPHER_generic(nid,keylen,blocksize,ivlen,nmode,mode,MODE,flags) \
# define BLOCK_CIPHER_generic(nid,keylen,blocksize,ivlen,seccat,nmode,mode,MODE,flags) \
static const EVP_CIPHER aria_##keylen##_##mode = { \
nid##_##keylen##_##nmode,blocksize,keylen/8,ivlen, \
nid##_##keylen##_##nmode,blocksize,keylen/8,ivlen, seccat, \
flags|EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
aria_init_key, \
@ -190,9 +190,9 @@ static int aria_ctr_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
return 1;
}
BLOCK_CIPHER_generic(NID_aria, 128, 1, 16, ctr, ctr, CTR, 0)
BLOCK_CIPHER_generic(NID_aria, 192, 1, 16, ctr, ctr, CTR, 0)
BLOCK_CIPHER_generic(NID_aria, 256, 1, 16, ctr, ctr, CTR, 0)
BLOCK_CIPHER_generic(NID_aria, 128, 1, 16, 1, ctr, ctr, CTR, 0)
BLOCK_CIPHER_generic(NID_aria, 192, 1, 16, 3, ctr, ctr, CTR, 0)
BLOCK_CIPHER_generic(NID_aria, 256, 1, 16, 5, ctr, ctr, CTR, 0)
/* Authenticated cipher modes (GCM/CCM) */
@ -761,10 +761,10 @@ static int aria_ccm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
| EVP_CIPH_CUSTOM_COPY | EVP_CIPH_FLAG_AEAD_CIPHER \
| EVP_CIPH_CUSTOM_IV_LENGTH)
#define BLOCK_CIPHER_aead(keylen,mode,MODE) \
#define BLOCK_CIPHER_aead(keylen,seccat,mode,MODE) \
static const EVP_CIPHER aria_##keylen##_##mode = { \
NID_aria_##keylen##_##mode, \
1, keylen/8, 12, \
1, keylen/8, 12, seccat, \
ARIA_AUTH_FLAGS|EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
aria_##mode##_init_key, \
@ -775,12 +775,12 @@ static const EVP_CIPHER aria_##keylen##_##mode = { \
const EVP_CIPHER *EVP_aria_##keylen##_##mode(void) \
{ return (EVP_CIPHER*)&aria_##keylen##_##mode; }
BLOCK_CIPHER_aead(128, gcm, GCM)
BLOCK_CIPHER_aead(192, gcm, GCM)
BLOCK_CIPHER_aead(256, gcm, GCM)
BLOCK_CIPHER_aead(128, 1, gcm, GCM)
BLOCK_CIPHER_aead(192, 3, gcm, GCM)
BLOCK_CIPHER_aead(256, 5, gcm, GCM)
BLOCK_CIPHER_aead(128, ccm, CCM)
BLOCK_CIPHER_aead(192, ccm, CCM)
BLOCK_CIPHER_aead(256, ccm, CCM)
BLOCK_CIPHER_aead(128, 1, ccm, CCM)
BLOCK_CIPHER_aead(192, 3, ccm, CCM)
BLOCK_CIPHER_aead(256, 5, ccm, CCM)
#endif

View File

@ -31,7 +31,7 @@ typedef struct {
# define data(ctx) EVP_C_DATA(EVP_BF_KEY,ctx)
IMPLEMENT_BLOCK_CIPHER(bf, ks, BF, EVP_BF_KEY, NID_bf, 8, 16, 8, 64,
IMPLEMENT_BLOCK_CIPHER(bf, ks, BF, EVP_BF_KEY, NID_bf, 8, 16, 8, 64, 0,
EVP_CIPH_VARIABLE_LENGTH, bf_init_key, NULL,
EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL)

View File

@ -139,9 +139,9 @@ static int cmll_t4_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
static int cmll_t4_ctr_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t len);
# define BLOCK_CIPHER_generic(nid,keylen,blocksize,ivlen,nmode,mode,MODE,flags) \
# define BLOCK_CIPHER_generic(nid,keylen,blocksize,ivlen,seccat,nmode,mode,MODE,flags) \
static const EVP_CIPHER cmll_t4_##keylen##_##mode = { \
nid##_##keylen##_##nmode,blocksize,keylen/8,ivlen, \
nid##_##keylen##_##nmode,blocksize,keylen/8,ivlen, seccat, \
flags|EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
cmll_t4_init_key, \
@ -151,7 +151,7 @@ static const EVP_CIPHER cmll_t4_##keylen##_##mode = { \
NULL,NULL,NULL,NULL }; \
static const EVP_CIPHER camellia_##keylen##_##mode = { \
nid##_##keylen##_##nmode,blocksize, \
keylen/8,ivlen, \
keylen/8,ivlen, seccat, \
flags|EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
camellia_init_key, \
@ -164,9 +164,9 @@ const EVP_CIPHER *EVP_camellia_##keylen##_##mode(void) \
#else
# define BLOCK_CIPHER_generic(nid,keylen,blocksize,ivlen,nmode,mode,MODE,flags) \
# define BLOCK_CIPHER_generic(nid,keylen,blocksize,ivlen,seccat,nmode,mode,MODE,flags) \
static const EVP_CIPHER camellia_##keylen##_##mode = { \
nid##_##keylen##_##nmode,blocksize,keylen/8,ivlen, \
nid##_##keylen##_##nmode,blocksize,keylen/8,ivlen, seccat, \
flags|EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
camellia_init_key, \
@ -179,14 +179,14 @@ const EVP_CIPHER *EVP_camellia_##keylen##_##mode(void) \
#endif
#define BLOCK_CIPHER_generic_pack(nid,keylen,flags) \
BLOCK_CIPHER_generic(nid,keylen,16,16,cbc,cbc,CBC,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid,keylen,16,0,ecb,ecb,ECB,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid,keylen,1,16,ofb128,ofb,OFB,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid,keylen,1,16,cfb128,cfb,CFB,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid,keylen,1,16,cfb1,cfb1,CFB,flags) \
BLOCK_CIPHER_generic(nid,keylen,1,16,cfb8,cfb8,CFB,flags) \
BLOCK_CIPHER_generic(nid, keylen, 1, 16, ctr, ctr, CTR, flags)
#define BLOCK_CIPHER_generic_pack(nid,keylen,seccat,flags) \
BLOCK_CIPHER_generic(nid,keylen,16,16,seccat,cbc,cbc,CBC,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid,keylen,16,0,seccat,ecb,ecb,ECB,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid,keylen,1,16,seccat,ofb128,ofb,OFB,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid,keylen,1,16,seccat,cfb128,cfb,CFB,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid,keylen,1,16,seccat,cfb1,cfb1,CFB,flags) \
BLOCK_CIPHER_generic(nid,keylen,1,16,seccat,cfb8,cfb8,CFB,flags) \
BLOCK_CIPHER_generic(nid, keylen, 1, 16, seccat, ctr, ctr, CTR, flags)
/* The subkey for Camellia is generated. */
static int camellia_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
@ -344,6 +344,6 @@ static int camellia_ctr_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
return 1;
}
BLOCK_CIPHER_generic_pack(NID_camellia, 128, 0)
BLOCK_CIPHER_generic_pack(NID_camellia, 192, 0)
BLOCK_CIPHER_generic_pack(NID_camellia, 256, 0)
BLOCK_CIPHER_generic_pack(NID_camellia, 128, 1, 0)
BLOCK_CIPHER_generic_pack(NID_camellia, 192, 3, 0)
BLOCK_CIPHER_generic_pack(NID_camellia, 256, 5, 0)

View File

@ -33,7 +33,7 @@ typedef struct {
# define data(ctx) EVP_C_DATA(EVP_CAST_KEY,ctx)
IMPLEMENT_BLOCK_CIPHER(cast5, ks, CAST, EVP_CAST_KEY,
NID_cast5, 8, CAST_KEY_LENGTH, 8, 64,
NID_cast5, 8, CAST_KEY_LENGTH, 8, 64, 0,
EVP_CIPH_VARIABLE_LENGTH, cast_init_key, NULL,
EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL)

View File

@ -130,6 +130,7 @@ static const EVP_CIPHER chacha20 = {
1, /* block_size */
CHACHA_KEY_SIZE, /* key_len */
CHACHA_CTR_SIZE, /* iv_len, 128-bit counter in the context */
5, /* PQ security strength category */
EVP_CIPH_CUSTOM_IV | EVP_CIPH_ALWAYS_CALL_INIT,
EVP_ORIG_GLOBAL,
chacha_init_key,
@ -607,11 +608,12 @@ static int chacha20_poly1305_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,
}
}
static EVP_CIPHER chacha20_poly1305 = {
static const EVP_CIPHER chacha20_poly1305 = {
NID_chacha20_poly1305,
1, /* block_size */
CHACHA_KEY_SIZE, /* key_len */
12, /* iv_len, 96-bit nonce in the context */
5, /* PQ security strength category */
EVP_CIPH_FLAG_AEAD_CIPHER | EVP_CIPH_CUSTOM_IV |
EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT |
EVP_CIPH_CUSTOM_COPY | EVP_CIPH_FLAG_CUSTOM_CIPHER |

View File

@ -195,17 +195,17 @@ static int des_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
return 1;
}
BLOCK_CIPHER_defs(des, EVP_DES_KEY, NID_des, 8, 8, 8, 64,
BLOCK_CIPHER_defs(des, EVP_DES_KEY, NID_des, 8, 8, 8, 64, 0,
EVP_CIPH_RAND_KEY, des_init_key, NULL,
EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, des_ctrl)
BLOCK_CIPHER_def_cfb(des, EVP_DES_KEY, NID_des, 8, 8, 1,
EVP_CIPH_RAND_KEY, des_init_key, NULL,
EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, des_ctrl)
BLOCK_CIPHER_def_cfb(des, EVP_DES_KEY, NID_des, 8, 8, 1, 0,
EVP_CIPH_RAND_KEY, des_init_key, NULL,
EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, des_ctrl)
BLOCK_CIPHER_def_cfb(des, EVP_DES_KEY, NID_des, 8, 8, 8,
EVP_CIPH_RAND_KEY, des_init_key, NULL,
EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, des_ctrl)
BLOCK_CIPHER_def_cfb(des, EVP_DES_KEY, NID_des, 8, 8, 8, 0,
EVP_CIPH_RAND_KEY, des_init_key, NULL,
EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, des_ctrl)
static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
const unsigned char *iv, int enc)

View File

@ -203,22 +203,22 @@ static int des_ede3_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
return 1;
}
BLOCK_CIPHER_defs(des_ede, DES_EDE_KEY, NID_des_ede, 8, 16, 8, 64,
BLOCK_CIPHER_defs(des_ede, DES_EDE_KEY, NID_des_ede, 8, 16, 8, 64, 0,
EVP_CIPH_RAND_KEY | EVP_CIPH_FLAG_DEFAULT_ASN1,
des_ede_init_key, NULL, NULL, NULL, des3_ctrl)
# define des_ede3_cfb64_cipher des_ede_cfb64_cipher
# define des_ede3_ofb_cipher des_ede_ofb_cipher
# define des_ede3_cbc_cipher des_ede_cbc_cipher
# define des_ede3_ecb_cipher des_ede_ecb_cipher
BLOCK_CIPHER_defs(des_ede3, DES_EDE_KEY, NID_des_ede3, 8, 24, 8, 64,
BLOCK_CIPHER_defs(des_ede3, DES_EDE_KEY, NID_des_ede3, 8, 24, 8, 64, 0,
EVP_CIPH_RAND_KEY | EVP_CIPH_FLAG_DEFAULT_ASN1,
des_ede3_init_key, NULL, NULL, NULL, des3_ctrl)
BLOCK_CIPHER_def_cfb(des_ede3, DES_EDE_KEY, NID_des_ede3, 24, 8, 1,
BLOCK_CIPHER_def_cfb(des_ede3, DES_EDE_KEY, NID_des_ede3, 24, 8, 1, 0,
EVP_CIPH_RAND_KEY | EVP_CIPH_FLAG_DEFAULT_ASN1,
des_ede3_init_key, NULL, NULL, NULL, des3_ctrl)
BLOCK_CIPHER_def_cfb(des_ede3, DES_EDE_KEY, NID_des_ede3, 24, 8, 8,
BLOCK_CIPHER_def_cfb(des_ede3, DES_EDE_KEY, NID_des_ede3, 24, 8, 8, 0,
EVP_CIPH_RAND_KEY | EVP_CIPH_FLAG_DEFAULT_ASN1,
des_ede3_init_key, NULL, NULL, NULL, des3_ctrl)
@ -410,7 +410,7 @@ static int des_ede3_wrap_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
static const EVP_CIPHER des3_wrap = {
NID_id_smime_alg_CMS3DESwrap,
8, 24, 0,
8, 24, 0, 0,
EVP_CIPH_WRAP_MODE | EVP_CIPH_CUSTOM_IV | EVP_CIPH_FLAG_CUSTOM_CIPHER
| EVP_CIPH_FLAG_DEFAULT_ASN1,
EVP_ORIG_GLOBAL,

View File

@ -50,7 +50,7 @@ BLOCK_CIPHER_func_cbc(idea, IDEA, EVP_IDEA_KEY, ks)
BLOCK_CIPHER_func_ofb(idea, IDEA, 64, EVP_IDEA_KEY, ks)
BLOCK_CIPHER_func_cfb(idea, IDEA, 64, EVP_IDEA_KEY, ks)
BLOCK_CIPHER_defs(idea, IDEA_KEY_SCHEDULE, NID_idea, 8, 16, 8, 64,
BLOCK_CIPHER_defs(idea, IDEA_KEY_SCHEDULE, NID_idea, 8, 16, 8, 64, 1,
0, idea_init_key, NULL,
EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL)

View File

@ -19,7 +19,7 @@ static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t inl);
static const EVP_CIPHER n_cipher = {
NID_undef,
1, 0, 0, 0,
1, 0, 0, 0, 0,
EVP_ORIG_GLOBAL,
null_init_key,
null_cipher,

View File

@ -41,7 +41,7 @@ typedef struct {
IMPLEMENT_BLOCK_CIPHER(rc2, ks, RC2, EVP_RC2_KEY, NID_rc2,
8,
RC2_KEY_LENGTH, 8, 64,
RC2_KEY_LENGTH, 8, 64, 0,
EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
rc2_init_key, NULL,
rc2_set_asn1_type_and_iv, rc2_get_asn1_type_and_iv,
@ -51,7 +51,7 @@ IMPLEMENT_BLOCK_CIPHER(rc2, ks, RC2, EVP_RC2_KEY, NID_rc2,
# define RC2_128_MAGIC 0x3a
static const EVP_CIPHER r2_64_cbc_cipher = {
NID_rc2_64_cbc,
8, 8 /* 64 bit */ , 8,
8, 8 /* 64 bit */ , 8, 0,
EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
EVP_ORIG_GLOBAL,
rc2_init_key,
@ -66,7 +66,7 @@ static const EVP_CIPHER r2_64_cbc_cipher = {
static const EVP_CIPHER r2_40_cbc_cipher = {
NID_rc2_40_cbc,
8, 5 /* 40 bit */ , 8,
8, 5 /* 40 bit */ , 8, 0,
EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
EVP_ORIG_GLOBAL,
rc2_init_key,

View File

@ -36,7 +36,7 @@ static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t inl);
static const EVP_CIPHER r4_cipher = {
NID_rc4,
1, EVP_RC4_KEY_SIZE, 0,
1, EVP_RC4_KEY_SIZE, 0, 0,
EVP_CIPH_VARIABLE_LENGTH,
EVP_ORIG_GLOBAL,
rc4_init_key,
@ -51,7 +51,7 @@ static const EVP_CIPHER r4_cipher = {
static const EVP_CIPHER r4_40_cipher = {
NID_rc4_40,
1, 5 /* 40 bit */ , 0,
1, 5 /* 40 bit */ , 0, 0,
EVP_CIPH_VARIABLE_LENGTH,
EVP_ORIG_GLOBAL,
rc4_init_key,

View File

@ -246,13 +246,13 @@ static int rc4_hmac_md5_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,
}
}
static EVP_CIPHER r4_hmac_md5_cipher = {
static const EVP_CIPHER r4_hmac_md5_cipher = {
# ifdef NID_rc4_hmac_md5
NID_rc4_hmac_md5,
# else
NID_undef,
# endif
1, EVP_RC4_KEY_SIZE, 0,
1, EVP_RC4_KEY_SIZE, 0, 0,
EVP_CIPH_STREAM_CIPHER | EVP_CIPH_VARIABLE_LENGTH |
EVP_CIPH_FLAG_AEAD_CIPHER,
EVP_ORIG_GLOBAL,

View File

@ -36,7 +36,7 @@ typedef struct {
# define data(ctx) EVP_C_DATA(EVP_RC5_KEY,ctx)
IMPLEMENT_BLOCK_CIPHER(rc5_32_12_16, ks, RC5_32, EVP_RC5_KEY, NID_rc5,
8, RC5_32_KEY_LENGTH, 8, 64,
8, RC5_32_KEY_LENGTH, 8, 64, 0,
EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
r_32_12_16_init_key, NULL, NULL, NULL, rc5_ctrl)

View File

@ -30,7 +30,7 @@ typedef struct {
} EVP_SEED_KEY;
IMPLEMENT_BLOCK_CIPHER(seed, ks, SEED, EVP_SEED_KEY, NID_seed,
16, 16, 16, 128, EVP_CIPH_FLAG_DEFAULT_ASN1,
16, 16, 16, 128, 1, EVP_CIPH_FLAG_DEFAULT_ASN1,
seed_init_key, 0, 0, 0, 0)
static int seed_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,

View File

@ -35,7 +35,7 @@ typedef struct {
# define BLOCK_CIPHER_generic(nid,blocksize,ivlen,nmode,mode,MODE,flags) \
static const EVP_CIPHER sm4_##mode = { \
nid##_##nmode,blocksize,128/8,ivlen, \
nid##_##nmode,blocksize,128/8,ivlen, 1, \
flags|EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
sm4_init_key, \

View File

@ -39,7 +39,7 @@ typedef struct {
static const EVP_CIPHER d_xcbc_cipher = {
NID_desx_cbc,
8, 24, 8,
8, 24, 8, 0,
EVP_CIPH_CBC_MODE,
EVP_ORIG_GLOBAL,
desx_cbc_init_key,

View File

@ -320,12 +320,13 @@ int EVP_CIPHER_get_type(const EVP_CIPHER *cipher)
int evp_cipher_cache_constants(EVP_CIPHER *cipher)
{
int ok, aead = 0, custom_iv = 0, cts = 0, multiblock = 0, randkey = 0;
int security_category = -1;
int encrypt_then_mac = 0;
size_t ivlen = 0;
size_t blksz = 0;
size_t keylen = 0;
unsigned int mode = 0;
OSSL_PARAM params[11];
OSSL_PARAM params[12];
params[0] = OSSL_PARAM_construct_size_t(OSSL_CIPHER_PARAM_BLOCK_SIZE, &blksz);
params[1] = OSSL_PARAM_construct_size_t(OSSL_CIPHER_PARAM_IVLEN, &ivlen);
@ -341,13 +342,16 @@ int evp_cipher_cache_constants(EVP_CIPHER *cipher)
&randkey);
params[9] = OSSL_PARAM_construct_int(OSSL_CIPHER_PARAM_ENCRYPT_THEN_MAC,
&encrypt_then_mac);
params[10] = OSSL_PARAM_construct_end();
params[10] = OSSL_PARAM_construct_int(OSSL_CIPHER_PARAM_SECURITY_CATEGORY,
&security_category);
params[11] = OSSL_PARAM_construct_end();
ok = evp_do_ciph_getparams(cipher, params) > 0;
if (ok) {
cipher->block_size = (int)blksz;
cipher->iv_len = (int)ivlen;
cipher->key_len = (int)keylen;
cipher->flags = mode;
cipher->security_category = security_category;
if (aead)
cipher->flags |= EVP_CIPH_FLAG_AEAD_CIPHER;
if (custom_iv)
@ -672,6 +676,11 @@ int EVP_CIPHER_CTX_get_key_length(const EVP_CIPHER_CTX *ctx)
return ctx->key_len;
}
int EVP_CIPHER_get_security_category(const EVP_CIPHER *cipher)
{
return cipher->security_category;
}
int EVP_CIPHER_get_nid(const EVP_CIPHER *cipher)
{
return (cipher == NULL) ? NID_undef : cipher->nid;
@ -819,6 +828,24 @@ int EVP_MD_get_size(const EVP_MD *md)
return md->md_size;
}
int EVP_MD_get_security_category_collision(const EVP_MD *md)
{
if (md == NULL) {
ERR_raise(ERR_LIB_EVP, EVP_R_MESSAGE_DIGEST_IS_NULL);
return -1;
}
return md->security_category_collision;
}
int EVP_MD_get_security_category_preimage(const EVP_MD *md)
{
if (md == NULL) {
ERR_raise(ERR_LIB_EVP, EVP_R_MESSAGE_DIGEST_IS_NULL);
return -1;
}
return md->security_category_preimage;
}
int EVP_MD_xof(const EVP_MD *md)
{
return md != NULL && ((EVP_MD_get_flags(md) & EVP_MD_FLAG_XOF) != 0);

View File

@ -41,6 +41,7 @@ static const EVP_MD blake2b_md = {
NID_blake2b512,
0,
BLAKE2B_DIGEST_LENGTH,
5, 5,
0,
EVP_ORIG_GLOBAL,
LEGACY_EVP_MD_METH_TABLE(blake2b_int_init, blake2b_int_update,
@ -56,6 +57,7 @@ static const EVP_MD blake2s_md = {
NID_blake2s256,
0,
BLAKE2S_DIGEST_LENGTH,
2, 5,
0,
EVP_ORIG_GLOBAL,
LEGACY_EVP_MD_METH_TABLE(blake2s_int_init, blake2s_int_update,

View File

@ -23,6 +23,7 @@ static const EVP_MD md2_md = {
NID_md2,
NID_md2WithRSAEncryption,
MD2_DIGEST_LENGTH,
0, 0,
0,
EVP_ORIG_GLOBAL,
LEGACY_EVP_MD_METH_TABLE(md2_init, md2_update, md2_final, NULL, MD2_BLOCK)

View File

@ -23,6 +23,7 @@ static const EVP_MD md4_md = {
NID_md4,
NID_md4WithRSAEncryption,
MD4_DIGEST_LENGTH,
0, 0,
0,
EVP_ORIG_GLOBAL,
LEGACY_EVP_MD_METH_TABLE(md4_init, md4_update, md4_final, NULL, MD4_CBLOCK),

View File

@ -23,6 +23,7 @@ static const EVP_MD md5_md = {
NID_md5,
NID_md5WithRSAEncryption,
MD5_DIGEST_LENGTH,
0, 0,
0,
EVP_ORIG_GLOBAL,
LEGACY_EVP_MD_METH_TABLE(md5_init, md5_update, md5_final, NULL, MD5_CBLOCK)

View File

@ -28,6 +28,7 @@ static const EVP_MD md5_sha1_md = {
NID_md5_sha1,
NID_md5_sha1,
MD5_SHA1_DIGEST_LENGTH,
SHA1_COLLISION_CATEGORY, SHA1_PREIMAGE_CATEGORY,
0,
EVP_ORIG_GLOBAL,
LEGACY_EVP_MD_METH_TABLE(md5_sha1_int_init, md5_sha1_int_update,

View File

@ -23,6 +23,7 @@ static const EVP_MD mdc2_md = {
NID_mdc2,
NID_mdc2WithRSA,
MDC2_DIGEST_LENGTH,
0, 0,
0,
EVP_ORIG_GLOBAL,
LEGACY_EVP_MD_METH_TABLE(mdc2_init, mdc2_update, mdc2_final, NULL,

View File

@ -23,6 +23,7 @@ static const EVP_MD ripemd160_md = {
NID_ripemd160,
NID_ripemd160WithRSA,
RIPEMD160_DIGEST_LENGTH,
0, 1,
0,
EVP_ORIG_GLOBAL,
LEGACY_EVP_MD_METH_TABLE(ripe_init, ripe_update, ripe_final, NULL,

View File

@ -93,6 +93,7 @@ static const EVP_MD sha1_md = {
NID_sha1,
NID_sha1WithRSAEncryption,
SHA_DIGEST_LENGTH,
SHA1_COLLISION_CATEGORY, SHA1_PREIMAGE_CATEGORY,
EVP_MD_FLAG_DIGALGID_ABSENT,
EVP_ORIG_GLOBAL,
LEGACY_EVP_MD_METH_TABLE(sha1_init, sha1_update, sha1_final, sha1_int_ctrl,
@ -108,6 +109,7 @@ static const EVP_MD sha224_md = {
NID_sha224,
NID_sha224WithRSAEncryption,
SHA224_DIGEST_LENGTH,
SHA224_COLLISION_CATEGORY, SHA224_PREIMAGE_CATEGORY,
EVP_MD_FLAG_DIGALGID_ABSENT,
EVP_ORIG_GLOBAL,
LEGACY_EVP_MD_METH_TABLE(sha224_init, sha224_update, sha224_final, NULL,
@ -123,6 +125,7 @@ static const EVP_MD sha256_md = {
NID_sha256,
NID_sha256WithRSAEncryption,
SHA256_DIGEST_LENGTH,
SHA256_COLLISION_CATEGORY, SHA256_PREIMAGE_CATEGORY,
EVP_MD_FLAG_DIGALGID_ABSENT,
EVP_ORIG_GLOBAL,
LEGACY_EVP_MD_METH_TABLE(sha256_init, sha256_update, sha256_final, NULL,
@ -138,6 +141,7 @@ static const EVP_MD sha512_224_md = {
NID_sha512_224,
NID_sha512_224WithRSAEncryption,
SHA224_DIGEST_LENGTH,
SHA224_COLLISION_CATEGORY, SHA224_PREIMAGE_CATEGORY,
EVP_MD_FLAG_DIGALGID_ABSENT,
EVP_ORIG_GLOBAL,
LEGACY_EVP_MD_METH_TABLE(sha512_224_int_init, sha512_224_int_update,
@ -153,6 +157,7 @@ static const EVP_MD sha512_256_md = {
NID_sha512_256,
NID_sha512_256WithRSAEncryption,
SHA256_DIGEST_LENGTH,
SHA256_COLLISION_CATEGORY, SHA256_PREIMAGE_CATEGORY,
EVP_MD_FLAG_DIGALGID_ABSENT,
EVP_ORIG_GLOBAL,
LEGACY_EVP_MD_METH_TABLE(sha512_256_int_init, sha512_256_int_update,
@ -168,6 +173,7 @@ static const EVP_MD sha384_md = {
NID_sha384,
NID_sha384WithRSAEncryption,
SHA384_DIGEST_LENGTH,
SHA384_COLLISION_CATEGORY, SHA384_PREIMAGE_CATEGORY,
EVP_MD_FLAG_DIGALGID_ABSENT,
EVP_ORIG_GLOBAL,
LEGACY_EVP_MD_METH_TABLE(sha384_init, sha384_update, sha384_final, NULL,
@ -183,6 +189,7 @@ static const EVP_MD sha512_md = {
NID_sha512,
NID_sha512WithRSAEncryption,
SHA512_DIGEST_LENGTH,
SHA512_COLLISION_CATEGORY, SHA512_PREIMAGE_CATEGORY,
EVP_MD_FLAG_DIGALGID_ABSENT,
EVP_ORIG_GLOBAL,
LEGACY_EVP_MD_METH_TABLE(sha512_init, sha512_update, sha512_final, NULL,
@ -194,13 +201,14 @@ const EVP_MD *EVP_sha512(void)
return &sha512_md;
}
#define EVP_MD_SHA3(bitlen) \
#define EVP_MD_SHA3(bitlen, seccat_collision, seccat_preimage) \
const EVP_MD *EVP_sha3_##bitlen(void) \
{ \
static const EVP_MD sha3_##bitlen##_md = { \
NID_sha3_##bitlen, \
NID_RSA_SHA3_##bitlen, \
bitlen / 8, \
seccat_collision, seccat_preimage, \
EVP_MD_FLAG_DIGALGID_ABSENT, \
EVP_ORIG_GLOBAL, \
LEGACY_EVP_MD_METH_TABLE(sha3_int_init, sha3_int_update, \
@ -209,13 +217,14 @@ const EVP_MD *EVP_sha3_##bitlen(void) \
}; \
return &sha3_##bitlen##_md; \
}
#define EVP_MD_SHAKE(bitlen) \
#define EVP_MD_SHAKE(bitlen, seccat_collision, seccat_preimage) \
const EVP_MD *EVP_shake##bitlen(void) \
{ \
static const EVP_MD shake##bitlen##_md = { \
NID_shake##bitlen, \
0, \
bitlen / 8, \
seccat_collision, seccat_preimage, \
EVP_MD_FLAG_XOF | EVP_MD_FLAG_DIGALGID_ABSENT, \
EVP_ORIG_GLOBAL, \
LEGACY_EVP_MD_METH_TABLE(shake_init, sha3_int_update, sha3_int_final, \
@ -224,10 +233,10 @@ const EVP_MD *EVP_shake##bitlen(void) \
return &shake##bitlen##_md; \
}
EVP_MD_SHA3(224)
EVP_MD_SHA3(256)
EVP_MD_SHA3(384)
EVP_MD_SHA3(512)
EVP_MD_SHA3(224, SHA3_224_COLLISION_CATEGORY, SHA3_224_PREIMAGE_CATEGORY)
EVP_MD_SHA3(256, SHA3_256_COLLISION_CATEGORY, SHA3_256_PREIMAGE_CATEGORY)
EVP_MD_SHA3(384, SHA3_384_COLLISION_CATEGORY, SHA3_384_PREIMAGE_CATEGORY)
EVP_MD_SHA3(512, SHA3_512_COLLISION_CATEGORY, SHA3_512_PREIMAGE_CATEGORY)
EVP_MD_SHAKE(128)
EVP_MD_SHAKE(256)
EVP_MD_SHAKE(128, SHAKE128_COLLISION_CATEGORY, SHAKE128_PREIMAGE_CATEGORY)
EVP_MD_SHAKE(256, SHAKE256_COLLISION_CATEGORY, SHAKE256_PREIMAGE_CATEGORY)

View File

@ -23,6 +23,7 @@ static const EVP_MD whirlpool_md = {
NID_whirlpool,
0,
WHIRLPOOL_DIGEST_LENGTH,
5, 5,
0,
EVP_ORIG_GLOBAL,
LEGACY_EVP_MD_METH_TABLE(wp_init, wp_update, wp_final, NULL,

View File

@ -33,6 +33,8 @@ static const EVP_MD null_md = {
NID_undef,
NID_undef,
0,
0, /* Collision security category */
0, /* Preimage security category */
0,
EVP_ORIG_GLOBAL,
init,

View File

@ -19,6 +19,7 @@ static const EVP_MD sm3_md = {
NID_sm3,
NID_sm3WithRSAEncryption,
SM3_DIGEST_LENGTH,
2, 5,
0,
EVP_ORIG_GLOBAL,
LEGACY_EVP_MD_METH_TABLE(sm3_int_init, sm3_int_update, sm3_int_final, NULL,

View File

@ -16,6 +16,7 @@ EVP_DigestSqueeze,
EVP_MD_is_a, EVP_MD_get0_name, EVP_MD_get0_description,
EVP_MD_names_do_all, EVP_MD_get0_provider, EVP_MD_get_type,
EVP_MD_get_pkey_type, EVP_MD_get_size, EVP_MD_get_block_size, EVP_MD_get_flags,
EVP_MD_get_security_category_collision, EVP_MD_get_security_category_preimage,
EVP_MD_CTX_get0_name, EVP_MD_CTX_md, EVP_MD_CTX_get0_md, EVP_MD_CTX_get1_md,
EVP_MD_CTX_get_type, EVP_MD_CTX_get_size_ex, EVP_MD_CTX_get_block_size,
EVP_MD_CTX_get0_md_data, EVP_MD_CTX_update_fn, EVP_MD_CTX_set_update_fn,
@ -85,6 +86,8 @@ EVP_MD_CTX_type, EVP_MD_CTX_pkey_ctx, EVP_MD_CTX_md_data
int EVP_MD_get_pkey_type(const EVP_MD *md);
int EVP_MD_get_size(const EVP_MD *md);
int EVP_MD_get_block_size(const EVP_MD *md);
int EVP_MD_get_security_category_collision(const EVP_MD *md);
int EVP_MD_get_security_category_preimage(const EVP_MD *md);
unsigned long EVP_MD_get_flags(const EVP_MD *md);
int EVP_MD_xof(const EVP_MD *md);
@ -441,6 +444,48 @@ Returns the update function for I<ctx>.
Returns the I<md> flags. Note that these are different from the B<EVP_MD_CTX>
ones. See L<EVP_MD_meth_set_flags(3)> for more information.
=item EVP_MD_get_security_category_collision(),
EVP_MD_get_security_category_preimage()
These functions return the
L<post-quantum security categories|https://nvlpubs.nist.gov/nistpubs/ir/2024/NIST.IR.8547.ipd.pdf>
for the digest as defined by NIST.
EVP_MD_get_security_category_collision() returns the security category with respect
to the generation of two inputs that output an identical digest value.
EVP_MD_get_security_category_preimage() returns the security category with respect
to the generation of an input that outputs a specific digest value.
The post-quantum security category is an integer value from 0 to 5 that
is based on an algorithm's classification on the range of security strengths
offered by the existing standards in symmetric cryptography:
=begin text
Security Attack
Category Type
==============================================================
0 Weak
1 Key search on a block cipher with a 128-bit key
2 Collision search on a 256-bit hash function
3 Key search on a block cipher with a 192-bit key
4 Collision search on a 384-bit hash function
5 Key search on a block cipher with a 256-bit key
=end text
=begin html
<table>
<tr><th>Security Category</th><th>Attack Type</th>></tr>
<tr><td>0</td><td>Weak</td></tr>
<tr><td>1</td><td>Key search on a block cipher with a 128-bit key</td></tr>
<tr><td>2</td><td>Collision search on a 256-bit hash function</td></tr>
<tr><td>3</td><td>Key search on a block cipher with a 192-bit key</td></tr>
<tr><td>4</td><td>Collision search on a 384-bit hash function</td></tr>
<tr><td>5</td><td>Key search on a block cipher with a 256-bit key</td></tr>
</table>
=end html
=item EVP_MD_get_pkey_type()
Returns the NID of the public key signing algorithm associated with this
@ -692,6 +737,13 @@ This function has no return value.
Returns 1 if the callback was called for all names. A return value of 0 means
that the callback was not called for any names.
=item EVP_MD_get_security_category_collision(),
EVP_MD_get_security_category_preimage()
Return the post-quantum security category which is an integer in the range
zero to five inclusive. They returns -1 if the security category information
isn't available.
=back
=head1 NOTES
@ -862,9 +914,12 @@ to be aliases for EVP_MD_CTX_get_size_ex(), previously they were aliases for
EVP_MD_get_size which returned a constant value. This is required for XOF
digests since they do not have a fixed size.
The EVP_MD_get_security_category_collision() and
EVP_MD_get_security_category_preimage() functions were added in OpenSSL 3.6.
=head1 COPYRIGHT
Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved.
Copyright 2000-2025 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use
this file except in compliance with the License. You can obtain a copy

View File

@ -51,6 +51,7 @@ EVP_CIPHER_gettable_params,
EVP_CIPHER_get_block_size,
EVP_CIPHER_get_key_length,
EVP_CIPHER_get_iv_length,
EVP_CIPHER_get_security_category,
EVP_CIPHER_get_flags,
EVP_CIPHER_get_mode,
EVP_CIPHER_get_type,
@ -207,6 +208,7 @@ EVP_CIPHER_CTX_mode
int EVP_CIPHER_get_block_size(const EVP_CIPHER *e);
int EVP_CIPHER_get_key_length(const EVP_CIPHER *e);
int EVP_CIPHER_get_iv_length(const EVP_CIPHER *e);
int EVP_CIPHER_get_security_category(const EVP_CIPHER *e);
unsigned long EVP_CIPHER_get_flags(const EVP_CIPHER *e);
unsigned long EVP_CIPHER_get_mode(const EVP_CIPHER *e);
int EVP_CIPHER_get_type(const EVP_CIPHER *cipher);
@ -613,6 +615,43 @@ the cipher has not yet been initialized within the B<EVP_CIPHER_CTX>, or if the
passed cipher is NULL. The constant B<EVP_MAX_IV_LENGTH> is the maximum IV
length for all ciphers.
=item EVP_CIPHER_get_security_category()
EVP_CIPHER_get_security_category() returns the
L<post-quantum security category|https://nvlpubs.nist.gov/nistpubs/ir/2024/NIST.IR.8547.ipd.pdf>
as defined by NIST.
The post-quantum security category is an integer value from 0 to 5 that
is based on an algorithm's classification on the range of security strengths
offered by the existing standards in symmetric cryptography:
=begin text
Security Attack
Category Type
==============================================================
0 Weak
1 Key search on a block cipher with a 128-bit key
2 Collision search on a 256-bit hash function
3 Key search on a block cipher with a 192-bit key
4 Collision search on a 384-bit hash function
5 Key search on a block cipher with a 256-bit key
=end text
=begin html
<table>
<tr><th>Security Category</th><th>Attack Type</th>></tr>
<tr><td>0</td><td>Weak</td></tr>
<tr><td>1</td><td>Key search on a block cipher with a 128-bit key</td></tr>
<tr><td>2</td><td>Collision search on a 256-bit hash function</td></tr>
<tr><td>3</td><td>Key search on a block cipher with a 192-bit key</td></tr>
<tr><td>4</td><td>Collision search on a 384-bit hash function</td></tr>
<tr><td>5</td><td>Key search on a block cipher with a 256-bit key</td></tr>
</table>
=end html
=item EVP_CIPHER_CTX_get_tag_length()
Returns the tag length of an AEAD cipher when passed a B<EVP_CIPHER_CTX>. It will
@ -766,6 +805,13 @@ Use EVP_CIPHER_get_key_length() to retrieve the cached value.
Gets the IV length for the associated cipher algorithm I<cipher>.
Use EVP_CIPHER_get_iv_length() to retrieve the cached value.
=item "security-category" (B<OSSL_CIPHER_PARAM_SECURITY_CATEGORY>) <integer>
The value is the NIST
L<post-quantum security category|https://nvlpubs.nist.gov/nistpubs/ir/2024/NIST.IR.8547.ipd.pdf>
for the associated cipher algorithm.
It is an integer value in the range [0, 5] inclusive.
=item "blocksize" (B<OSSL_CIPHER_PARAM_BLOCK_SIZE>) <unsigned integer>
Gets the block size for the associated cipher algorithm I<cipher>.
@ -1429,6 +1475,10 @@ EVP_CIPHER_CTX_set_padding() always returns 1.
EVP_CIPHER_get_iv_length() and EVP_CIPHER_CTX_get_iv_length() return the IV
length, zero if the cipher does not use an IV and a negative value on error.
EVP_CIPHER_get_security_category() returns the post-quantum security category
which is an integer in the range zero to five inclusive. It returns -1 if
the security category information isn't available.
EVP_CIPHER_CTX_get_tag_length() return the tag length or zero if the cipher
does not use a tag.
@ -1958,6 +2008,8 @@ Prior to OpenSSL 3.5, passing a NULL I<ctx> to
B<EVP_CIPHER_CTX_get_block_size()> would result in a NULL pointer dereference,
rather than a 0 return value indicating an error.
EVP_CIPHER_get_security_category() was added in OpenSSL 3.6.
=head1 COPYRIGHT
Copyright 2000-2025 The OpenSSL Project Authors. All Rights Reserved.

View File

@ -197,6 +197,24 @@ The length of the "blocksize" parameter should not exceed that of a B<size_t>.
The digest output size.
The length of the "size" parameter should not exceed that of a B<size_t>.
=item "collision-security-category" (B<OSSL_DIGEST_PARAM_SECURITY_CATEGORY_COLLISION>) <integer>
The value is the NIST
L<post-quantum collision security category|https://nvlpubs.nist.gov/nistpubs/ir/2024/NIST.IR.8547.ipd.pdf>
for the algorithm.
The digest collision security category represents the difficulty of producing two
different inputs that result in an identical digested output.
It is an integer value in the range [0, 5] inclusive.
=item "preimage-security-category" (B<OSSL_DIGEST_PARAM_SECURITY_CATEGORY_PREIMAGE>) <integer>
The value is the NIST
L<post-quantum collision security category|https://nvlpubs.nist.gov/nistpubs/ir/2024/NIST.IR.8547.ipd.pdf>
for the algorithm.
The digest collision security category represents the difficulty of producing an
inputs that results in a specific digested output.
It is an integer value in the range [0, 5] inclusive.
=item "flags" (B<OSSL_DIGEST_PARAM_FLAGS>) <unsigned integer>
Diverse flags that describe exceptional behaviour for the digest:

View File

@ -253,6 +253,37 @@ struct evp_kdf_st {
#define EVP_ORIG_GLOBAL 1
#define EVP_ORIG_METH 2
/* Security categories for SHA algorithms */
# define SHA1_COLLISION_CATEGORY 0
# define SHA256_192_COLLISION_CATEGORY 0
# define SHA224_COLLISION_CATEGORY 0
# define SHA256_COLLISION_CATEGORY 2
# define SHA384_COLLISION_CATEGORY 4
# define SHA512_COLLISION_CATEGORY 5
# define SHA3_224_COLLISION_CATEGORY 0
# define SHA3_256_COLLISION_CATEGORY 2
# define SHA3_384_COLLISION_CATEGORY 4
# define SHA3_512_COLLISION_CATEGORY 5
# define SHAKE128_COLLISION_CATEGORY 2
# define SHAKE256_COLLISION_CATEGORY 5
# define KMAC128_COLLISION_CATEGORY 2
# define KMAC256_COLLISION_CATEGORY 5
# define SHA1_PREIMAGE_CATEGORY 1
# define SHA256_192_PREIMAGE_CATEGORY 1
# define SHA224_PREIMAGE_CATEGORY 3
# define SHA256_PREIMAGE_CATEGORY 5
# define SHA384_PREIMAGE_CATEGORY 5
# define SHA512_PREIMAGE_CATEGORY 5
# define SHA3_224_PREIMAGE_CATEGORY 3
# define SHA3_256_PREIMAGE_CATEGORY 5
# define SHA3_384_PREIMAGE_CATEGORY 5
# define SHA3_512_PREIMAGE_CATEGORY 5
# define SHAKE128_PREIMAGE_CATEGORY 2
# define SHAKE256_PREIMAGE_CATEGORY 5
# define KMAC128_PREIMAGE_CATEGORY 2
# define KMAC256_PREIMAGE_CATEGORY 5
struct evp_md_st {
/* nid */
int type;
@ -260,6 +291,8 @@ struct evp_md_st {
/* Legacy structure members */
int pkey_type;
int md_size;
int security_category_collision;
int security_category_preimage;
unsigned long flags;
int origin;
int (*init) (EVP_MD_CTX *ctx);
@ -304,6 +337,7 @@ struct evp_cipher_st {
/* Default value for variable length ciphers */
int key_len;
int iv_len;
int security_category;
/* Legacy structure members */
/* Various flags */
@ -445,10 +479,10 @@ static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched)
#define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \
key_len, iv_len, flags, init_key, cleanup, \
key_len, iv_len, seccat, flags, init_key, cleanup, \
set_asn1, get_asn1, ctrl) \
static const EVP_CIPHER cname##_##mode = { \
nid##_##nmode, block_size, key_len, iv_len, \
nid##_##nmode, block_size, key_len, iv_len, seccat, \
flags | EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
init_key, \
@ -462,41 +496,43 @@ static const EVP_CIPHER cname##_##mode = { \
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
#define BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, \
iv_len, flags, init_key, cleanup, set_asn1, \
get_asn1, ctrl) \
iv_len, seccat, flags, init_key, cleanup, \
set_asn1, get_asn1, ctrl) \
BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \
iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
iv_len, seccat, flags, init_key, cleanup, set_asn1, \
get_asn1, ctrl)
#define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, \
iv_len, cbits, flags, init_key, cleanup, \
iv_len, cbits, seccat, flags, init_key, cleanup, \
set_asn1, get_asn1, ctrl) \
BLOCK_CIPHER_def1(cname, cfb##cbits, cfb##cbits, CFB, kstruct, nid, 1, \
key_len, iv_len, flags, init_key, cleanup, set_asn1, \
key_len, iv_len, seccat, flags, init_key, cleanup, set_asn1, \
get_asn1, ctrl)
#define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, \
iv_len, cbits, flags, init_key, cleanup, \
iv_len, cbits, seccat, flags, init_key, cleanup, \
set_asn1, get_asn1, ctrl) \
BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, 1, \
key_len, iv_len, flags, init_key, cleanup, set_asn1, \
key_len, iv_len, seccat, flags, init_key, cleanup, set_asn1, \
get_asn1, ctrl)
#define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, \
flags, init_key, cleanup, set_asn1, \
seccat, flags, init_key, cleanup, set_asn1, \
get_asn1, ctrl) \
BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \
0, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
0, seccat, flags, init_key, cleanup, set_asn1, get_asn1, \
ctrl)
#define BLOCK_CIPHER_defs(cname, kstruct, \
nid, block_size, key_len, iv_len, cbits, flags, \
init_key, cleanup, set_asn1, get_asn1, ctrl) \
BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, \
init_key, cleanup, set_asn1, get_asn1, ctrl) \
BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, \
nid, block_size, key_len, iv_len, cbits, seccat, \
flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, seccat, \
flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \
BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, seccat, \
flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, flags, \
BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, seccat, \
flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, seccat, flags, \
init_key, cleanup, set_asn1, get_asn1, ctrl)
/*-
@ -563,18 +599,18 @@ const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; }
#define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, \
block_size, key_len, iv_len, cbits, \
flags, init_key, \
seccat, flags, init_key, \
cleanup, set_asn1, get_asn1, ctrl) \
BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \
cbits, flags, init_key, cleanup, set_asn1, \
cbits, seccat, flags, init_key, cleanup, set_asn1, \
get_asn1, ctrl)
#define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len,fl) \
#define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len,seccat,fl) \
BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \
BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \
NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \
(fl)|EVP_CIPH_FLAG_DEFAULT_ASN1, \
seccat, (fl)|EVP_CIPH_FLAG_DEFAULT_ASN1, \
cipher##_init_key, NULL, NULL, NULL, NULL)
typedef struct {

View File

@ -578,6 +578,8 @@ int EVP_MD_get_size(const EVP_MD *md);
# define EVP_MD_size EVP_MD_get_size
int EVP_MD_get_block_size(const EVP_MD *md);
# define EVP_MD_block_size EVP_MD_get_block_size
int EVP_MD_get_security_category_collision(const EVP_MD *md);
int EVP_MD_get_security_category_preimage(const EVP_MD *md);
unsigned long EVP_MD_get_flags(const EVP_MD *md);
# define EVP_MD_flags EVP_MD_get_flags
int EVP_MD_xof(const EVP_MD *md);
@ -630,6 +632,7 @@ int EVP_CIPHER_get_key_length(const EVP_CIPHER *cipher);
# define EVP_CIPHER_key_length EVP_CIPHER_get_key_length
int EVP_CIPHER_get_iv_length(const EVP_CIPHER *cipher);
# define EVP_CIPHER_iv_length EVP_CIPHER_get_iv_length
int EVP_CIPHER_get_security_category(const EVP_CIPHER *cipher);
unsigned long EVP_CIPHER_get_flags(const EVP_CIPHER *cipher);
# define EVP_CIPHER_flags EVP_CIPHER_get_flags
int EVP_CIPHER_get_mode(const EVP_CIPHER *cipher);

View File

@ -49,46 +49,46 @@ static void *aes_dupctx(void *ctx)
}
/* ossl_aes256ecb_functions */
IMPLEMENT_generic_cipher(aes, AES, ecb, ECB, 0, 256, 128, 0, block)
IMPLEMENT_generic_cipher(aes, AES, ecb, ECB, 0, 256, 128, 0, 5, block)
/* ossl_aes192ecb_functions */
IMPLEMENT_generic_cipher(aes, AES, ecb, ECB, 0, 192, 128, 0, block)
IMPLEMENT_generic_cipher(aes, AES, ecb, ECB, 0, 192, 128, 0, 3, block)
/* ossl_aes128ecb_functions */
IMPLEMENT_generic_cipher(aes, AES, ecb, ECB, 0, 128, 128, 0, block)
IMPLEMENT_generic_cipher(aes, AES, ecb, ECB, 0, 128, 128, 0, 1, block)
/* ossl_aes256cbc_functions */
IMPLEMENT_generic_cipher(aes, AES, cbc, CBC, 0, 256, 128, 128, block)
IMPLEMENT_generic_cipher(aes, AES, cbc, CBC, 0, 256, 128, 128, 5, block)
/* ossl_aes192cbc_functions */
IMPLEMENT_generic_cipher(aes, AES, cbc, CBC, 0, 192, 128, 128, block)
IMPLEMENT_generic_cipher(aes, AES, cbc, CBC, 0, 192, 128, 128, 3, block)
/* ossl_aes128cbc_functions */
IMPLEMENT_generic_cipher(aes, AES, cbc, CBC, 0, 128, 128, 128, block)
IMPLEMENT_generic_cipher(aes, AES, cbc, CBC, 0, 128, 128, 128, 1, block)
/* ossl_aes256ofb_functions */
IMPLEMENT_generic_cipher(aes, AES, ofb, OFB, 0, 256, 8, 128, stream)
IMPLEMENT_generic_cipher(aes, AES, ofb, OFB, 0, 256, 8, 128, 5, stream)
/* ossl_aes192ofb_functions */
IMPLEMENT_generic_cipher(aes, AES, ofb, OFB, 0, 192, 8, 128, stream)
IMPLEMENT_generic_cipher(aes, AES, ofb, OFB, 0, 192, 8, 128, 3, stream)
/* ossl_aes128ofb_functions */
IMPLEMENT_generic_cipher(aes, AES, ofb, OFB, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(aes, AES, ofb, OFB, 0, 128, 8, 128, 1, stream)
/* ossl_aes256cfb_functions */
IMPLEMENT_generic_cipher(aes, AES, cfb, CFB, 0, 256, 8, 128, stream)
IMPLEMENT_generic_cipher(aes, AES, cfb, CFB, 0, 256, 8, 128, 5, stream)
/* ossl_aes192cfb_functions */
IMPLEMENT_generic_cipher(aes, AES, cfb, CFB, 0, 192, 8, 128, stream)
IMPLEMENT_generic_cipher(aes, AES, cfb, CFB, 0, 192, 8, 128, 3, stream)
/* ossl_aes128cfb_functions */
IMPLEMENT_generic_cipher(aes, AES, cfb, CFB, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(aes, AES, cfb, CFB, 0, 128, 8, 128, 1, stream)
/* ossl_aes256cfb1_functions */
IMPLEMENT_generic_cipher(aes, AES, cfb1, CFB, 0, 256, 8, 128, stream)
IMPLEMENT_generic_cipher(aes, AES, cfb1, CFB, 0, 256, 8, 128, 5, stream)
/* ossl_aes192cfb1_functions */
IMPLEMENT_generic_cipher(aes, AES, cfb1, CFB, 0, 192, 8, 128, stream)
IMPLEMENT_generic_cipher(aes, AES, cfb1, CFB, 0, 192, 8, 128, 3, stream)
/* ossl_aes128cfb1_functions */
IMPLEMENT_generic_cipher(aes, AES, cfb1, CFB, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(aes, AES, cfb1, CFB, 0, 128, 8, 128, 1, stream)
/* ossl_aes256cfb8_functions */
IMPLEMENT_generic_cipher(aes, AES, cfb8, CFB, 0, 256, 8, 128, stream)
IMPLEMENT_generic_cipher(aes, AES, cfb8, CFB, 0, 256, 8, 128, 5, stream)
/* ossl_aes192cfb8_functions */
IMPLEMENT_generic_cipher(aes, AES, cfb8, CFB, 0, 192, 8, 128, stream)
IMPLEMENT_generic_cipher(aes, AES, cfb8, CFB, 0, 192, 8, 128, 3, stream)
/* ossl_aes128cfb8_functions */
IMPLEMENT_generic_cipher(aes, AES, cfb8, CFB, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(aes, AES, cfb8, CFB, 0, 128, 8, 128, 1, stream)
/* ossl_aes256ctr_functions */
IMPLEMENT_generic_cipher(aes, AES, ctr, CTR, 0, 256, 8, 128, stream)
IMPLEMENT_generic_cipher(aes, AES, ctr, CTR, 0, 256, 8, 128, 5, stream)
/* ossl_aes192ctr_functions */
IMPLEMENT_generic_cipher(aes, AES, ctr, CTR, 0, 192, 8, 128, stream)
IMPLEMENT_generic_cipher(aes, AES, ctr, CTR, 0, 192, 8, 128, 3, stream)
/* ossl_aes128ctr_functions */
IMPLEMENT_generic_cipher(aes, AES, ctr, CTR, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(aes, AES, ctr, CTR, 0, 128, 8, 128, 1, stream)
#include "cipher_aes_cts.inc"

View File

@ -20,13 +20,14 @@
#include <openssl/prov_ssl.h>
#include <openssl/proverr.h>
#include "cipher_aes_cbc_hmac_sha.h"
#include "crypto/evp.h"
#include "prov/implementations.h"
#include "prov/providercommon.h"
#ifndef AES_CBC_HMAC_SHA_CAPABLE
# define IMPLEMENT_CIPHER(nm, sub, kbits, blkbits, ivbits, flags) \
# define IMPLEMENT_CIPHER(nm, sub, kbits, blkbits, ivbits, seccat, flags) \
const OSSL_DISPATCH ossl_##nm##kbits##sub##_functions[] = { \
OSSL_DISPATCH_END \
OSSL_DISPATCH_END \
};
#else
@ -392,7 +393,7 @@ static void aes_cbc_hmac_sha256_freectx(void *vctx)
}
}
# define IMPLEMENT_CIPHER(nm, sub, kbits, blkbits, ivbits, flags) \
# define IMPLEMENT_CIPHER(nm, sub, kbits, blkbits, ivbits, seccat, flags) \
static OSSL_FUNC_cipher_newctx_fn nm##_##kbits##_##sub##_newctx; \
static void *nm##_##kbits##_##sub##_newctx(void *provctx) \
{ \
@ -402,7 +403,8 @@ static OSSL_FUNC_cipher_get_params_fn nm##_##kbits##_##sub##_get_params; \
static int nm##_##kbits##_##sub##_get_params(OSSL_PARAM params[]) \
{ \
return ossl_cipher_generic_get_params(params, EVP_CIPH_CBC_MODE, \
flags, kbits, blkbits, ivbits); \
flags, kbits, blkbits, ivbits, \
seccat); \
} \
const OSSL_DISPATCH ossl_##nm##kbits##sub##_functions[] = { \
{ OSSL_FUNC_CIPHER_NEWCTX, (void (*)(void))nm##_##kbits##_##sub##_newctx },\
@ -430,11 +432,24 @@ const OSSL_DISPATCH ossl_##nm##kbits##sub##_functions[] = { \
#endif /* AES_CBC_HMAC_SHA_CAPABLE */
/*
* Note about security categories.
*
* The security category of the combined algorithms will be the lower of
* the category for the cipher and the HMAC. NIST has not defined security
* categories for HMACs at this stage but it seems reasonable to equate
* these to the pre-image security category of the underlying digest.
*/
#define SC_SHA1(c) \
((c) < SHA1_PREIMAGE_CATEGORY ? (c) : SHA1_PREIMAGE_CATEGORY)
#define SC_SHA256(c)\
((c) < SHA256_PREIMAGE_CATEGORY ? (c) : SHA256_PREIMAGE_CATEGORY)
/* ossl_aes128cbc_hmac_sha1_functions */
IMPLEMENT_CIPHER(aes, cbc_hmac_sha1, 128, 128, 128, AES_CBC_HMAC_SHA_FLAGS)
IMPLEMENT_CIPHER(aes, cbc_hmac_sha1, 128, 128, 128, SC_SHA1(1), AES_CBC_HMAC_SHA_FLAGS)
/* ossl_aes256cbc_hmac_sha1_functions */
IMPLEMENT_CIPHER(aes, cbc_hmac_sha1, 256, 128, 128, AES_CBC_HMAC_SHA_FLAGS)
IMPLEMENT_CIPHER(aes, cbc_hmac_sha1, 256, 128, 128, SC_SHA1(5), AES_CBC_HMAC_SHA_FLAGS)
/* ossl_aes128cbc_hmac_sha256_functions */
IMPLEMENT_CIPHER(aes, cbc_hmac_sha256, 128, 128, 128, AES_CBC_HMAC_SHA_FLAGS)
IMPLEMENT_CIPHER(aes, cbc_hmac_sha256, 128, 128, 128, SC_SHA256(1), AES_CBC_HMAC_SHA_FLAGS)
/* ossl_aes256cbc_hmac_sha256_functions */
IMPLEMENT_CIPHER(aes, cbc_hmac_sha256, 256, 128, 128, AES_CBC_HMAC_SHA_FLAGS)
IMPLEMENT_CIPHER(aes, cbc_hmac_sha256, 256, 128, 128, SC_SHA256(5), AES_CBC_HMAC_SHA_FLAGS)

View File

@ -9,12 +9,13 @@
#include "internal/deprecated.h"
#include "cipher_aes_cbc_hmac_sha_etm.h"
#include "crypto/evp.h"
#include "prov/providercommon.h"
#include "prov/ciphercommon_aead.h"
#include "prov/implementations.h"
#ifndef AES_CBC_HMAC_SHA_ETM_CAPABLE
# define IMPLEMENT_CIPHER(nm, sub, kbits, blkbits, ivbits, flags) \
# define IMPLEMENT_CIPHER(nm, sub, kbits, blkbits, ivbits, seccat, flags) \
const OSSL_DISPATCH ossl_##nm##kbits##sub##_functions[] = { \
OSSL_DISPATCH_END \
};
@ -296,7 +297,7 @@ static void *aes_cbc_hmac_sha512_etm_dupctx(void *provctx)
return OPENSSL_memdup(ctx, sizeof(*ctx));
}
# define IMPLEMENT_CIPHER(nm, sub, kbits, blkbits, ivbits, flags) \
# define IMPLEMENT_CIPHER(nm, sub, kbits, blkbits, ivbits, seccat, flags) \
static OSSL_FUNC_cipher_newctx_fn nm##_##kbits##_##sub##_newctx; \
static void *nm##_##kbits##_##sub##_newctx(void *provctx) \
{ \
@ -306,7 +307,8 @@ static OSSL_FUNC_cipher_get_params_fn nm##_##kbits##_##sub##_get_params; \
static int nm##_##kbits##_##sub##_get_params(OSSL_PARAM params[]) \
{ \
return ossl_cipher_generic_get_params(params, EVP_CIPH_CBC_MODE, \
flags, kbits, blkbits, ivbits); \
flags, kbits, blkbits, ivbits, \
seccat); \
} \
const OSSL_DISPATCH ossl_##nm##kbits##sub##_functions[] = { \
{ OSSL_FUNC_CIPHER_NEWCTX, (void (*)(void))nm##_##kbits##_##sub##_newctx },\
@ -333,21 +335,36 @@ const OSSL_DISPATCH ossl_##nm##kbits##sub##_functions[] = { \
};
#endif /* AES_CBC_HMAC_SHA_ETM_CAPABLE */
/*
* Note about security categories.
*
* The security category of the combined algorithms will be the lower of
* the category for the cipher and the HMAC. NIST has not defined security
* categories for HMACs at this stage but it seems reasonable to equate
* these to the pre-image security category of the underlying digest.
*/
#define SC_SHA1(c) \
((c) < SHA1_PREIMAGE_CATEGORY ? (c) : SHA1_PREIMAGE_CATEGORY)
#define SC_SHA256(c)\
((c) < SHA256_PREIMAGE_CATEGORY ? (c) : SHA256_PREIMAGE_CATEGORY)
#define SC_SHA512(c)\
((c) < SHA512_PREIMAGE_CATEGORY ? (c) : SHA512_PREIMAGE_CATEGORY)
/* ossl_aes128cbc_hmac_sha1_etm_functions */
IMPLEMENT_CIPHER(aes, cbc_hmac_sha1_etm, 128, 128, 128, EVP_CIPH_FLAG_ENC_THEN_MAC)
IMPLEMENT_CIPHER(aes, cbc_hmac_sha1_etm, 128, 128, 128, SC_SHA1(1), EVP_CIPH_FLAG_ENC_THEN_MAC)
/* ossl_aes192cbc_hmac_sha1_etm_functions */
IMPLEMENT_CIPHER(aes, cbc_hmac_sha1_etm, 192, 128, 128, EVP_CIPH_FLAG_ENC_THEN_MAC)
IMPLEMENT_CIPHER(aes, cbc_hmac_sha1_etm, 192, 128, 128, SC_SHA1(3), EVP_CIPH_FLAG_ENC_THEN_MAC)
/* ossl_aes256cbc_hmac_sha1_etm_functions */
IMPLEMENT_CIPHER(aes, cbc_hmac_sha1_etm, 256, 128, 128, EVP_CIPH_FLAG_ENC_THEN_MAC)
IMPLEMENT_CIPHER(aes, cbc_hmac_sha1_etm, 256, 128, 128, SC_SHA1(5), EVP_CIPH_FLAG_ENC_THEN_MAC)
/* ossl_aes128cbc_hmac_sha256_etm_functions */
IMPLEMENT_CIPHER(aes, cbc_hmac_sha256_etm, 128, 128, 128, EVP_CIPH_FLAG_ENC_THEN_MAC)
IMPLEMENT_CIPHER(aes, cbc_hmac_sha256_etm, 128, 128, 128, SC_SHA256(1), EVP_CIPH_FLAG_ENC_THEN_MAC)
/* ossl_aes192cbc_hmac_sha256_etm_functions */
IMPLEMENT_CIPHER(aes, cbc_hmac_sha256_etm, 192, 128, 128, EVP_CIPH_FLAG_ENC_THEN_MAC)
IMPLEMENT_CIPHER(aes, cbc_hmac_sha256_etm, 192, 128, 128, SC_SHA256(3), EVP_CIPH_FLAG_ENC_THEN_MAC)
/* ossl_aes256cbc_hmac_sha256_etm_functions */
IMPLEMENT_CIPHER(aes, cbc_hmac_sha256_etm, 256, 128, 128, EVP_CIPH_FLAG_ENC_THEN_MAC)
IMPLEMENT_CIPHER(aes, cbc_hmac_sha256_etm, 256, 128, 128, SC_SHA256(5), EVP_CIPH_FLAG_ENC_THEN_MAC)
/* ossl_aes128cbc_hmac_sha512_etm_functions */
IMPLEMENT_CIPHER(aes, cbc_hmac_sha512_etm, 128, 128, 128, EVP_CIPH_FLAG_ENC_THEN_MAC)
IMPLEMENT_CIPHER(aes, cbc_hmac_sha512_etm, 128, 128, 128, SC_SHA512(1), EVP_CIPH_FLAG_ENC_THEN_MAC)
/* ossl_aes192cbc_hmac_sha512_etm_functions */
IMPLEMENT_CIPHER(aes, cbc_hmac_sha512_etm, 192, 128, 128, EVP_CIPH_FLAG_ENC_THEN_MAC)
IMPLEMENT_CIPHER(aes, cbc_hmac_sha512_etm, 192, 128, 128, SC_SHA512(3), EVP_CIPH_FLAG_ENC_THEN_MAC)
/* ossl_aes256cbc_hmac_sha512_etm_functions */
IMPLEMENT_CIPHER(aes, cbc_hmac_sha512_etm, 256, 128, 128, EVP_CIPH_FLAG_ENC_THEN_MAC)
IMPLEMENT_CIPHER(aes, cbc_hmac_sha512_etm, 256, 128, 128, SC_SHA512(5), EVP_CIPH_FLAG_ENC_THEN_MAC)

View File

@ -65,8 +65,8 @@ static void aes_ccm_freectx(void *vctx)
}
/* ossl_aes128ccm_functions */
IMPLEMENT_aead_cipher(aes, ccm, CCM, AEAD_FLAGS, 128, 8, 96);
IMPLEMENT_aead_cipher(aes, ccm, CCM, AEAD_FLAGS, 128, 8, 96, 1);
/* ossl_aes192ccm_functions */
IMPLEMENT_aead_cipher(aes, ccm, CCM, AEAD_FLAGS, 192, 8, 96);
IMPLEMENT_aead_cipher(aes, ccm, CCM, AEAD_FLAGS, 192, 8, 96, 3);
/* ossl_aes256ccm_functions */
IMPLEMENT_aead_cipher(aes, ccm, CCM, AEAD_FLAGS, 256, 8, 96);
IMPLEMENT_aead_cipher(aes, ccm, CCM, AEAD_FLAGS, 256, 8, 96, 5);

View File

@ -87,8 +87,8 @@ err:
}
/* ossl_aes256cbc_cts_functions */
IMPLEMENT_cts_cipher(aes, AES, cbc, CBC, CTS_FLAGS, 256, 128, 128, block)
IMPLEMENT_cts_cipher(aes, AES, cbc, CBC, CTS_FLAGS, 256, 128, 128, 5, block)
/* ossl_aes192cbc_cts_functions */
IMPLEMENT_cts_cipher(aes, AES, cbc, CBC, CTS_FLAGS, 192, 128, 128, block)
IMPLEMENT_cts_cipher(aes, AES, cbc, CBC, CTS_FLAGS, 192, 128, 128, 3, block)
/* ossl_aes128cbc_cts_functions */
IMPLEMENT_cts_cipher(aes, AES, cbc, CBC, CTS_FLAGS, 128, 128, 128, block)
IMPLEMENT_cts_cipher(aes, AES, cbc, CBC, CTS_FLAGS, 128, 128, 128, 1, block)

View File

@ -61,8 +61,8 @@ static void aes_gcm_freectx(void *vctx)
}
/* ossl_aes128gcm_functions */
IMPLEMENT_aead_cipher(aes, gcm, GCM, AEAD_FLAGS, 128, 8, 96);
IMPLEMENT_aead_cipher(aes, gcm, GCM, AEAD_FLAGS, 128, 8, 96, 1);
/* ossl_aes192gcm_functions */
IMPLEMENT_aead_cipher(aes, gcm, GCM, AEAD_FLAGS, 192, 8, 96);
IMPLEMENT_aead_cipher(aes, gcm, GCM, AEAD_FLAGS, 192, 8, 96, 3);
/* ossl_aes256gcm_functions */
IMPLEMENT_aead_cipher(aes, gcm, GCM, AEAD_FLAGS, 256, 8, 96);
IMPLEMENT_aead_cipher(aes, gcm, GCM, AEAD_FLAGS, 256, 8, 96, 5);

View File

@ -270,7 +270,7 @@ static const OSSL_PARAM *ossl_aes_gcm_siv_settable_ctx_params(ossl_unused void *
return aes_gcm_siv_known_settable_ctx_params;
}
#define IMPLEMENT_cipher(alg, lc, UCMODE, flags, kbits, blkbits, ivbits) \
#define IMPLEMENT_cipher(alg, lc, UCMODE, flags, kbits, blkbits, ivbits, seccat) \
static OSSL_FUNC_cipher_newctx_fn ossl_##alg##kbits##_##lc##_newctx; \
static OSSL_FUNC_cipher_freectx_fn ossl_##alg##_##lc##_freectx; \
static OSSL_FUNC_cipher_dupctx_fn ossl_##alg##_##lc##_dupctx; \
@ -287,9 +287,9 @@ static OSSL_FUNC_cipher_settable_ctx_params_fn ossl_##alg##_##lc##_settable_ctx_
static int ossl_##alg##_##kbits##_##lc##_get_params(OSSL_PARAM params[]) \
{ \
return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \
flags, kbits, blkbits, ivbits); \
flags, kbits, blkbits, ivbits, seccat); \
} \
static void *ossl_##alg##kbits##_##lc##_newctx(void *provctx) \
static void *ossl_##alg##kbits##_##lc##_newctx(void *provctx) \
{ \
return ossl_##alg##_##lc##_newctx(provctx, kbits); \
} \
@ -311,6 +311,6 @@ const OSSL_DISPATCH ossl_##alg##kbits##lc##_functions[] = {
OSSL_DISPATCH_END \
}
IMPLEMENT_cipher(aes, gcm_siv, GCM_SIV, AEAD_FLAGS, 128, 8, 96);
IMPLEMENT_cipher(aes, gcm_siv, GCM_SIV, AEAD_FLAGS, 192, 8, 96);
IMPLEMENT_cipher(aes, gcm_siv, GCM_SIV, AEAD_FLAGS, 256, 8, 96);
IMPLEMENT_cipher(aes, gcm_siv, GCM_SIV, AEAD_FLAGS, 128, 8, 96, 1);
IMPLEMENT_cipher(aes, gcm_siv, GCM_SIV, AEAD_FLAGS, 192, 8, 96, 3);
IMPLEMENT_cipher(aes, gcm_siv, GCM_SIV, AEAD_FLAGS, 256, 8, 96, 5);

View File

@ -523,12 +523,13 @@ static int aes_ocb_cipher(void *vctx, unsigned char *out, size_t *outl,
return 1;
}
#define IMPLEMENT_cipher(mode, UCMODE, flags, kbits, blkbits, ivbits) \
#define IMPLEMENT_cipher(mode, UCMODE, flags, kbits, blkbits, ivbits, seccat) \
static OSSL_FUNC_cipher_get_params_fn aes_##kbits##_##mode##_get_params; \
static int aes_##kbits##_##mode##_get_params(OSSL_PARAM params[]) \
{ \
return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \
flags, kbits, blkbits, ivbits); \
flags, kbits, blkbits, ivbits, \
seccat); \
} \
static OSSL_FUNC_cipher_newctx_fn aes_##kbits##_##mode##_newctx; \
static void *aes_##kbits##_##mode##_newctx(void *provctx) \
@ -561,6 +562,6 @@ const OSSL_DISPATCH ossl_##aes##kbits##mode##_functions[] = { \
OSSL_DISPATCH_END \
}
IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 256, 128, OCB_DEFAULT_IV_LEN * 8);
IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 192, 128, OCB_DEFAULT_IV_LEN * 8);
IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 128, 128, OCB_DEFAULT_IV_LEN * 8);
IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 256, 128, OCB_DEFAULT_IV_LEN * 8, 5);
IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 192, 128, OCB_DEFAULT_IV_LEN * 8, 3);
IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 128, 128, OCB_DEFAULT_IV_LEN * 8, 1);

View File

@ -241,7 +241,7 @@ static const OSSL_PARAM *aes_siv_settable_ctx_params(ossl_unused void *cctx,
return aes_siv_known_settable_ctx_params;
}
#define IMPLEMENT_cipher(alg, lc, UCMODE, flags, kbits, blkbits, ivbits) \
#define IMPLEMENT_cipher(alg, lc, UCMODE, flags, kbits, blkbits, ivbits, seccat) \
static OSSL_FUNC_cipher_newctx_fn alg##kbits##lc##_newctx; \
static OSSL_FUNC_cipher_freectx_fn alg##_##lc##_freectx; \
static OSSL_FUNC_cipher_dupctx_fn lc##_dupctx; \
@ -260,7 +260,8 @@ static OSSL_FUNC_cipher_settable_ctx_params_fn \
static int alg##_##kbits##_##lc##_get_params(OSSL_PARAM params[]) \
{ \
return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \
flags, 2*kbits, blkbits, ivbits); \
flags, 2*kbits, blkbits, ivbits, \
seccat); \
} \
static void *alg##kbits##lc##_newctx(void *provctx) \
{ \
@ -291,6 +292,6 @@ const OSSL_DISPATCH ossl_##alg##kbits##lc##_functions[] = { \
OSSL_DISPATCH_END \
};
IMPLEMENT_cipher(aes, siv, SIV, SIV_FLAGS, 128, 8, 0)
IMPLEMENT_cipher(aes, siv, SIV, SIV_FLAGS, 192, 8, 0)
IMPLEMENT_cipher(aes, siv, SIV, SIV_FLAGS, 256, 8, 0)
IMPLEMENT_cipher(aes, siv, SIV, SIV_FLAGS, 128, 8, 0, 1)
IMPLEMENT_cipher(aes, siv, SIV, SIV_FLAGS, 192, 8, 0, 3)
IMPLEMENT_cipher(aes, siv, SIV, SIV_FLAGS, 256, 8, 0, 5)

View File

@ -283,12 +283,13 @@ static int aes_wrap_set_ctx_params(void *vctx, const OSSL_PARAM params[])
return 1;
}
#define IMPLEMENT_cipher(mode, fname, UCMODE, flags, kbits, blkbits, ivbits) \
#define IMPLEMENT_cipher(mode, fname, UCMODE, flags, kbits, blkbits, ivbits, seccat) \
static OSSL_FUNC_cipher_get_params_fn aes_##kbits##_##fname##_get_params; \
static int aes_##kbits##_##fname##_get_params(OSSL_PARAM params[]) \
{ \
return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,\
flags, kbits, blkbits, ivbits); \
flags, kbits, blkbits, ivbits, \
seccat); \
} \
static OSSL_FUNC_cipher_newctx_fn aes_##kbits##fname##_newctx; \
static void *aes_##kbits##fname##_newctx(void *provctx) \
@ -320,16 +321,16 @@ static int aes_wrap_set_ctx_params(void *vctx, const OSSL_PARAM params[])
OSSL_DISPATCH_END \
}
IMPLEMENT_cipher(wrap, wrap, WRAP, WRAP_FLAGS, 256, 64, AES_WRAP_NOPAD_IVLEN * 8);
IMPLEMENT_cipher(wrap, wrap, WRAP, WRAP_FLAGS, 192, 64, AES_WRAP_NOPAD_IVLEN * 8);
IMPLEMENT_cipher(wrap, wrap, WRAP, WRAP_FLAGS, 128, 64, AES_WRAP_NOPAD_IVLEN * 8);
IMPLEMENT_cipher(wrap, wrappad, WRAP, WRAP_FLAGS, 256, 64, AES_WRAP_PAD_IVLEN * 8);
IMPLEMENT_cipher(wrap, wrappad, WRAP, WRAP_FLAGS, 192, 64, AES_WRAP_PAD_IVLEN * 8);
IMPLEMENT_cipher(wrap, wrappad, WRAP, WRAP_FLAGS, 128, 64, AES_WRAP_PAD_IVLEN * 8);
IMPLEMENT_cipher(wrap, wrap, WRAP, WRAP_FLAGS, 256, 64, AES_WRAP_NOPAD_IVLEN * 8, 5);
IMPLEMENT_cipher(wrap, wrap, WRAP, WRAP_FLAGS, 192, 64, AES_WRAP_NOPAD_IVLEN * 8, 3);
IMPLEMENT_cipher(wrap, wrap, WRAP, WRAP_FLAGS, 128, 64, AES_WRAP_NOPAD_IVLEN * 8, 1);
IMPLEMENT_cipher(wrap, wrappad, WRAP, WRAP_FLAGS, 256, 64, AES_WRAP_PAD_IVLEN * 8, 5);
IMPLEMENT_cipher(wrap, wrappad, WRAP, WRAP_FLAGS, 192, 64, AES_WRAP_PAD_IVLEN * 8, 3);
IMPLEMENT_cipher(wrap, wrappad, WRAP, WRAP_FLAGS, 128, 64, AES_WRAP_PAD_IVLEN * 8, 1);
IMPLEMENT_cipher(wrap, wrapinv, WRAP, WRAP_FLAGS_INV, 256, 64, AES_WRAP_NOPAD_IVLEN * 8);
IMPLEMENT_cipher(wrap, wrapinv, WRAP, WRAP_FLAGS_INV, 192, 64, AES_WRAP_NOPAD_IVLEN * 8);
IMPLEMENT_cipher(wrap, wrapinv, WRAP, WRAP_FLAGS_INV, 128, 64, AES_WRAP_NOPAD_IVLEN * 8);
IMPLEMENT_cipher(wrap, wrappadinv, WRAP, WRAP_FLAGS_INV, 256, 64, AES_WRAP_PAD_IVLEN * 8);
IMPLEMENT_cipher(wrap, wrappadinv, WRAP, WRAP_FLAGS_INV, 192, 64, AES_WRAP_PAD_IVLEN * 8);
IMPLEMENT_cipher(wrap, wrappadinv, WRAP, WRAP_FLAGS_INV, 128, 64, AES_WRAP_PAD_IVLEN * 8);
IMPLEMENT_cipher(wrap, wrapinv, WRAP, WRAP_FLAGS_INV, 256, 64, AES_WRAP_NOPAD_IVLEN * 8, 5);
IMPLEMENT_cipher(wrap, wrapinv, WRAP, WRAP_FLAGS_INV, 192, 64, AES_WRAP_NOPAD_IVLEN * 8, 3);
IMPLEMENT_cipher(wrap, wrapinv, WRAP, WRAP_FLAGS_INV, 128, 64, AES_WRAP_NOPAD_IVLEN * 8, 1);
IMPLEMENT_cipher(wrap, wrappadinv, WRAP, WRAP_FLAGS_INV, 256, 64, AES_WRAP_PAD_IVLEN * 8, 5);
IMPLEMENT_cipher(wrap, wrappadinv, WRAP, WRAP_FLAGS_INV, 192, 64, AES_WRAP_PAD_IVLEN * 8, 3);
IMPLEMENT_cipher(wrap, wrappadinv, WRAP, WRAP_FLAGS_INV, 128, 64, AES_WRAP_PAD_IVLEN * 8, 1);

View File

@ -276,13 +276,13 @@ static int aes_xts_set_ctx_params(void *vctx, const OSSL_PARAM params[])
return 1;
}
#define IMPLEMENT_cipher(lcmode, UCMODE, kbits, flags) \
#define IMPLEMENT_cipher(lcmode, UCMODE, kbits, seccat, flags) \
static OSSL_FUNC_cipher_get_params_fn aes_##kbits##_##lcmode##_get_params; \
static int aes_##kbits##_##lcmode##_get_params(OSSL_PARAM params[]) \
{ \
return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \
flags, 2 * kbits, AES_XTS_BLOCK_BITS, \
AES_XTS_IV_BITS); \
AES_XTS_IV_BITS, seccat); \
} \
static OSSL_FUNC_cipher_newctx_fn aes_##kbits##_xts_newctx; \
static void *aes_##kbits##_xts_newctx(void *provctx) \
@ -314,5 +314,5 @@ const OSSL_DISPATCH ossl_aes##kbits##xts_functions[] = { \
OSSL_DISPATCH_END \
}
IMPLEMENT_cipher(xts, XTS, 256, AES_XTS_FLAGS);
IMPLEMENT_cipher(xts, XTS, 128, AES_XTS_FLAGS);
IMPLEMENT_cipher(xts, XTS, 256, 5, AES_XTS_FLAGS);
IMPLEMENT_cipher(xts, XTS, 128, 1, AES_XTS_FLAGS);

View File

@ -41,44 +41,44 @@ static void *aria_dupctx(void *ctx)
}
/* ossl_aria256ecb_functions */
IMPLEMENT_generic_cipher(aria, ARIA, ecb, ECB, 0, 256, 128, 0, block)
IMPLEMENT_generic_cipher(aria, ARIA, ecb, ECB, 0, 256, 128, 0, 5, block)
/* ossl_aria192ecb_functions */
IMPLEMENT_generic_cipher(aria, ARIA, ecb, ECB, 0, 192, 128, 0, block)
IMPLEMENT_generic_cipher(aria, ARIA, ecb, ECB, 0, 192, 128, 0, 3, block)
/* ossl_aria128ecb_functions */
IMPLEMENT_generic_cipher(aria, ARIA, ecb, ECB, 0, 128, 128, 0, block)
IMPLEMENT_generic_cipher(aria, ARIA, ecb, ECB, 0, 128, 128, 0, 1, block)
/* ossl_aria256cbc_functions */
IMPLEMENT_generic_cipher(aria, ARIA, cbc, CBC, 0, 256, 128, 128, block)
IMPLEMENT_generic_cipher(aria, ARIA, cbc, CBC, 0, 256, 128, 128, 5, block)
/* ossl_aria192cbc_functions */
IMPLEMENT_generic_cipher(aria, ARIA, cbc, CBC, 0, 192, 128, 128, block)
IMPLEMENT_generic_cipher(aria, ARIA, cbc, CBC, 0, 192, 128, 128, 3, block)
/* ossl_aria128cbc_functions */
IMPLEMENT_generic_cipher(aria, ARIA, cbc, CBC, 0, 128, 128, 128, block)
IMPLEMENT_generic_cipher(aria, ARIA, cbc, CBC, 0, 128, 128, 128, 1, block)
/* ossl_aria256ofb_functions */
IMPLEMENT_generic_cipher(aria, ARIA, ofb, OFB, 0, 256, 8, 128, stream)
IMPLEMENT_generic_cipher(aria, ARIA, ofb, OFB, 0, 256, 8, 128, 5, stream)
/* ossl_aria192ofb_functions */
IMPLEMENT_generic_cipher(aria, ARIA, ofb, OFB, 0, 192, 8, 128, stream)
IMPLEMENT_generic_cipher(aria, ARIA, ofb, OFB, 0, 192, 8, 128, 3, stream)
/* ossl_aria128ofb_functions */
IMPLEMENT_generic_cipher(aria, ARIA, ofb, OFB, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(aria, ARIA, ofb, OFB, 0, 128, 8, 128, 1, stream)
/* ossl_aria256cfb_functions */
IMPLEMENT_generic_cipher(aria, ARIA, cfb, CFB, 0, 256, 8, 128, stream)
IMPLEMENT_generic_cipher(aria, ARIA, cfb, CFB, 0, 256, 8, 128, 5, stream)
/* ossl_aria192cfb_functions */
IMPLEMENT_generic_cipher(aria, ARIA, cfb, CFB, 0, 192, 8, 128, stream)
IMPLEMENT_generic_cipher(aria, ARIA, cfb, CFB, 0, 192, 8, 128, 3, stream)
/* ossl_aria128cfb_functions */
IMPLEMENT_generic_cipher(aria, ARIA, cfb, CFB, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(aria, ARIA, cfb, CFB, 0, 128, 8, 128, 1, stream)
/* ossl_aria256cfb1_functions */
IMPLEMENT_generic_cipher(aria, ARIA, cfb1, CFB, 0, 256, 8, 128, stream)
IMPLEMENT_generic_cipher(aria, ARIA, cfb1, CFB, 0, 256, 8, 128, 5, stream)
/* ossl_aria192cfb1_functions */
IMPLEMENT_generic_cipher(aria, ARIA, cfb1, CFB, 0, 192, 8, 128, stream)
IMPLEMENT_generic_cipher(aria, ARIA, cfb1, CFB, 0, 192, 8, 128, 3, stream)
/* ossl_aria128cfb1_functions */
IMPLEMENT_generic_cipher(aria, ARIA, cfb1, CFB, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(aria, ARIA, cfb1, CFB, 0, 128, 8, 128, 1, stream)
/* ossl_aria256cfb8_functions */
IMPLEMENT_generic_cipher(aria, ARIA, cfb8, CFB, 0, 256, 8, 128, stream)
IMPLEMENT_generic_cipher(aria, ARIA, cfb8, CFB, 0, 256, 8, 128, 5, stream)
/* ossl_aria192cfb8_functions */
IMPLEMENT_generic_cipher(aria, ARIA, cfb8, CFB, 0, 192, 8, 128, stream)
IMPLEMENT_generic_cipher(aria, ARIA, cfb8, CFB, 0, 192, 8, 128, 3, stream)
/* ossl_aria128cfb8_functions */
IMPLEMENT_generic_cipher(aria, ARIA, cfb8, CFB, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(aria, ARIA, cfb8, CFB, 0, 128, 8, 128, 1, stream)
/* ossl_aria256ctr_functions */
IMPLEMENT_generic_cipher(aria, ARIA, ctr, CTR, 0, 256, 8, 128, stream)
IMPLEMENT_generic_cipher(aria, ARIA, ctr, CTR, 0, 256, 8, 128, 5, stream)
/* ossl_aria192ctr_functions */
IMPLEMENT_generic_cipher(aria, ARIA, ctr, CTR, 0, 192, 8, 128, stream)
IMPLEMENT_generic_cipher(aria, ARIA, ctr, CTR, 0, 192, 8, 128, 3, stream)
/* ossl_aria128ctr_functions */
IMPLEMENT_generic_cipher(aria, ARIA, ctr, CTR, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(aria, ARIA, ctr, CTR, 0, 128, 8, 128, 1, stream)

View File

@ -51,9 +51,9 @@ static void aria_ccm_freectx(void *vctx)
}
/* aria128ccm functions */
IMPLEMENT_aead_cipher(aria, ccm, CCM, AEAD_FLAGS, 128, 8, 96);
IMPLEMENT_aead_cipher(aria, ccm, CCM, AEAD_FLAGS, 128, 8, 96, 1);
/* aria192ccm functions */
IMPLEMENT_aead_cipher(aria, ccm, CCM, AEAD_FLAGS, 192, 8, 96);
IMPLEMENT_aead_cipher(aria, ccm, CCM, AEAD_FLAGS, 192, 8, 96, 3);
/* aria256ccm functions */
IMPLEMENT_aead_cipher(aria, ccm, CCM, AEAD_FLAGS, 256, 8, 96);
IMPLEMENT_aead_cipher(aria, ccm, CCM, AEAD_FLAGS, 256, 8, 96, 5);

View File

@ -51,9 +51,9 @@ static void aria_gcm_freectx(void *vctx)
}
/* ossl_aria128gcm_functions */
IMPLEMENT_aead_cipher(aria, gcm, GCM, AEAD_FLAGS, 128, 8, 96);
IMPLEMENT_aead_cipher(aria, gcm, GCM, AEAD_FLAGS, 128, 8, 96, 1);
/* ossl_aria192gcm_functions */
IMPLEMENT_aead_cipher(aria, gcm, GCM, AEAD_FLAGS, 192, 8, 96);
IMPLEMENT_aead_cipher(aria, gcm, GCM, AEAD_FLAGS, 192, 8, 96, 3);
/* ossl_aria256gcm_functions */
IMPLEMENT_aead_cipher(aria, gcm, GCM, AEAD_FLAGS, 256, 8, 96);
IMPLEMENT_aead_cipher(aria, gcm, GCM, AEAD_FLAGS, 256, 8, 96, 5);

View File

@ -49,10 +49,10 @@ static void *blowfish_dupctx(void *ctx)
}
/* bf_ecb_functions */
IMPLEMENT_var_keylen_cipher(blowfish, BLOWFISH, ecb, ECB, BF_FLAGS, 128, 64, 0, block)
IMPLEMENT_var_keylen_cipher(blowfish, BLOWFISH, ecb, ECB, BF_FLAGS, 128, 64, 0, 0, block)
/* bf_cbc_functions */
IMPLEMENT_var_keylen_cipher(blowfish, BLOWFISH, cbc, CBC, BF_FLAGS, 128, 64, 64, block)
IMPLEMENT_var_keylen_cipher(blowfish, BLOWFISH, cbc, CBC, BF_FLAGS, 128, 64, 64, 0, block)
/* bf_ofb_functions */
IMPLEMENT_var_keylen_cipher(blowfish, BLOWFISH, ofb64, OFB, BF_FLAGS, 128, 8, 64, stream)
IMPLEMENT_var_keylen_cipher(blowfish, BLOWFISH, ofb64, OFB, BF_FLAGS, 128, 8, 64, 0, stream)
/* bf_cfb_functions */
IMPLEMENT_var_keylen_cipher(blowfish, BLOWFISH, cfb64, CFB, BF_FLAGS, 128, 8, 64, stream)
IMPLEMENT_var_keylen_cipher(blowfish, BLOWFISH, cfb64, CFB, BF_FLAGS, 128, 8, 64, 0, stream)

View File

@ -47,46 +47,46 @@ static void *camellia_dupctx(void *ctx)
}
/* ossl_camellia256ecb_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 256, 128, 0, block)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 256, 128, 0, 5, block)
/* ossl_camellia192ecb_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 192, 128, 0, block)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 192, 128, 0, 3, block)
/* ossl_camellia128ecb_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 128, 128, 0, block)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 128, 128, 0, 1, block)
/* ossl_camellia256cbc_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 256, 128, 128, block)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 256, 128, 128, 5, block)
/* ossl_camellia192cbc_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 192, 128, 128, block)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 192, 128, 128, 3, block)
/* ossl_camellia128cbc_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 128, 128, 128, block)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 128, 128, 128, 1, block)
/* ossl_camellia256ofb_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 256, 8, 128, stream)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 256, 8, 128, 5, stream)
/* ossl_camellia192ofb_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 192, 8, 128, stream)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 192, 8, 128, 3, stream)
/* ossl_camellia128ofb_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 128, 8, 128, 1, stream)
/* ossl_camellia256cfb_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 256, 8, 128, stream)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 256, 8, 128, 5, stream)
/* ossl_camellia192cfb_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 192, 8, 128, stream)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 192, 8, 128, 3, stream)
/* ossl_camellia128cfb_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 128, 8, 128, 1, stream)
/* ossl_camellia256cfb1_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 256, 8, 128, stream)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 256, 8, 128, 5, stream)
/* ossl_camellia192cfb1_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 192, 8, 128, stream)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 192, 8, 128, 3, stream)
/* ossl_camellia128cfb1_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 128, 8, 128, 1, stream)
/* ossl_camellia256cfb8_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 256, 8, 128, stream)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 256, 8, 128, 5, stream)
/* ossl_camellia192cfb8_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 192, 8, 128, stream)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 192, 8, 128, 3, stream)
/* ossl_camellia128cfb8_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 128, 8, 128, 1, stream)
/* ossl_camellia256ctr_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 256, 8, 128, stream)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 256, 8, 128, 5, stream)
/* ossl_camellia192ctr_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 192, 8, 128, stream)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 192, 8, 128, 3, stream)
/* ossl_camellia128ctr_functions */
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 128, 8, 128, 1, stream)
#include "cipher_camellia_cts.inc"

View File

@ -87,8 +87,8 @@ err:
}
/* ossl_camellia256cbc_cts_functions */
IMPLEMENT_cts_cipher(camellia, CAMELLIA, cbc, CBC, CTS_FLAGS, 256, 128, 128, block)
IMPLEMENT_cts_cipher(camellia, CAMELLIA, cbc, CBC, CTS_FLAGS, 256, 128, 128, 5, block)
/* ossl_camellia192cbc_cts_functions */
IMPLEMENT_cts_cipher(camellia, CAMELLIA, cbc, CBC, CTS_FLAGS, 192, 128, 128, block)
IMPLEMENT_cts_cipher(camellia, CAMELLIA, cbc, CBC, CTS_FLAGS, 192, 128, 128, 3, block)
/* ossl_camellia128cbc_cts_functions */
IMPLEMENT_cts_cipher(camellia, CAMELLIA, cbc, CBC, CTS_FLAGS, 128, 128, 128, block)
IMPLEMENT_cts_cipher(camellia, CAMELLIA, cbc, CBC, CTS_FLAGS, 128, 128, 128, 1, block)

View File

@ -50,10 +50,10 @@ static void *cast5_dupctx(void *ctx)
}
/* ossl_cast5128ecb_functions */
IMPLEMENT_var_keylen_cipher(cast5, CAST, ecb, ECB, CAST5_FLAGS, 128, 64, 0, block)
IMPLEMENT_var_keylen_cipher(cast5, CAST, ecb, ECB, CAST5_FLAGS, 128, 64, 0, 0, block)
/* ossl_cast5128cbc_functions */
IMPLEMENT_var_keylen_cipher(cast5, CAST, cbc, CBC, CAST5_FLAGS, 128, 64, 64, block)
IMPLEMENT_var_keylen_cipher(cast5, CAST, cbc, CBC, CAST5_FLAGS, 128, 64, 64, 0, block)
/* ossl_cast5128ofb64_functions */
IMPLEMENT_var_keylen_cipher(cast5, CAST, ofb64, OFB, CAST5_FLAGS, 128, 8, 64, stream)
IMPLEMENT_var_keylen_cipher(cast5, CAST, ofb64, OFB, CAST5_FLAGS, 128, 8, 64, 0, stream)
/* ossl_cast5128cfb64_functions */
IMPLEMENT_var_keylen_cipher(cast5, CAST, cfb64, CFB, CAST5_FLAGS, 128, 8, 64, stream)
IMPLEMENT_var_keylen_cipher(cast5, CAST, cfb64, CFB, CAST5_FLAGS, 128, 8, 64, 0, stream)

View File

@ -97,7 +97,8 @@ static int chacha20_get_params(OSSL_PARAM params[])
return ossl_cipher_generic_get_params(params, 0, CHACHA20_FLAGS,
CHACHA20_KEYLEN * 8,
CHACHA20_BLKLEN * 8,
CHACHA20_IVLEN * 8);
CHACHA20_IVLEN * 8,
5);
}
static int chacha20_get_ctx_params(void *vctx, OSSL_PARAM params[])

View File

@ -97,7 +97,8 @@ static int chacha20_poly1305_get_params(OSSL_PARAM params[])
return ossl_cipher_generic_get_params(params, 0, CHACHA20_POLY1305_FLAGS,
CHACHA20_POLY1305_KEYLEN * 8,
CHACHA20_POLY1305_BLKLEN * 8,
CHACHA20_POLY1305_IVLEN * 8);
CHACHA20_POLY1305_IVLEN * 8,
5);
}
{- produce_param_decoder('chacha20_poly1305_get_ctx_params',

View File

@ -11,12 +11,13 @@
/* NOTE: The underlying block cipher is CBC so we reuse most of the code */
#define IMPLEMENT_cts_cipher(alg, UCALG, lcmode, UCMODE, flags, kbits, \
blkbits, ivbits, typ) \
blkbits, ivbits, seccat, typ) \
static OSSL_FUNC_cipher_get_params_fn alg##_##kbits##_##lcmode##_get_params; \
static int alg##_cts_##kbits##_##lcmode##_get_params(OSSL_PARAM params[]) \
{ \
return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \
flags, kbits, blkbits, ivbits); \
flags, kbits, blkbits, ivbits, \
seccat); \
} \
const OSSL_DISPATCH ossl_##alg##kbits##lcmode##_cts_functions[] = { \
{ OSSL_FUNC_CIPHER_NEWCTX, \

View File

@ -154,13 +154,13 @@ static void *des_##lcmode##_newctx(void *provctx) \
{ \
return des_newctx(provctx, kbits, blkbits, ivbits, \
EVP_CIPH_##UCMODE##_MODE, flags, \
ossl_prov_cipher_hw_des_##lcmode()); \
ossl_prov_cipher_hw_des_##lcmode()); \
} \
static OSSL_FUNC_cipher_get_params_fn des_##lcmode##_get_params; \
static int des_##lcmode##_get_params(OSSL_PARAM params[]) \
{ \
return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \
flags, kbits, blkbits, ivbits); \
flags, kbits, blkbits, ivbits, 0); \
} \
const OSSL_DISPATCH ossl_##des_##lcmode##_functions[] = { \
{ OSSL_FUNC_CIPHER_ENCRYPT_INIT, (void (*)(void))des_einit }, \

View File

@ -48,10 +48,10 @@ static void *idea_dupctx(void *ctx)
}
/* ossl_idea128ecb_functions */
IMPLEMENT_generic_cipher(idea, IDEA, ecb, ECB, 0, 128, 64, 0, block)
IMPLEMENT_generic_cipher(idea, IDEA, ecb, ECB, 0, 128, 64, 0, 1, block)
/* ossl_idea128cbc_functions */
IMPLEMENT_generic_cipher(idea, IDEA, cbc, CBC, 0, 128, 64, 64, block)
IMPLEMENT_generic_cipher(idea, IDEA, cbc, CBC, 0, 128, 64, 64, 1, block)
/* ossl_idea128ofb64_functions */
IMPLEMENT_generic_cipher(idea, IDEA, ofb64, OFB, 0, 128, 8, 64, stream)
IMPLEMENT_generic_cipher(idea, IDEA, ofb64, OFB, 0, 128, 8, 64, 1, stream)
/* ossl_idea128cfb64_functions */
IMPLEMENT_generic_cipher(idea, IDEA, cfb64, CFB, 0, 128, 8, 64, stream)
IMPLEMENT_generic_cipher(idea, IDEA, cfb64, CFB, 0, 128, 8, 64, 1, stream)

View File

@ -102,7 +102,7 @@ static int null_final(void *vctx, unsigned char *out, size_t *outl,
static OSSL_FUNC_cipher_get_params_fn null_get_params;
static int null_get_params(OSSL_PARAM params[])
{
return ossl_cipher_generic_get_params(params, 0, 0, 0, 8, 0);
return ossl_cipher_generic_get_params(params, 0, 0, 0, 8, 0, 0);
}
static const OSSL_PARAM null_known_gettable_ctx_params[] = {

View File

@ -237,7 +237,7 @@ static OSSL_FUNC_cipher_get_params_fn alg##_##kbits##_##lcmode##_get_params; \
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[]) \
{ \
return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \
flags, kbits, blkbits, ivbits); \
flags, kbits, blkbits, ivbits, 0); \
} \
static OSSL_FUNC_cipher_newctx_fn alg##_##kbits##_##lcmode##_newctx; \
static void *alg##_##kbits##_##lcmode##_newctx(void *provctx) \

View File

@ -73,7 +73,7 @@ static OSSL_FUNC_cipher_get_params_fn alg##_##kbits##_get_params; \
static int alg##_##kbits##_get_params(OSSL_PARAM params[]) \
{ \
return ossl_cipher_generic_get_params(params, 0, flags, \
kbits, blkbits, ivbits); \
kbits, blkbits, ivbits, 0); \
} \
static OSSL_FUNC_cipher_newctx_fn alg##_##kbits##_newctx; \
static void *alg##_##kbits##_newctx(void *provctx) \

View File

@ -218,7 +218,8 @@ static int rc4_hmac_md5_get_params(OSSL_PARAM params[])
RC4_HMAC_MD5_FLAGS,
RC4_HMAC_MD5_KEY_BITS,
RC4_HMAC_MD5_BLOCK_BITS,
RC4_HMAC_MD5_IV_BITS);
RC4_HMAC_MD5_IV_BITS,
0);
}
const OSSL_DISPATCH ossl_rc4_hmac_ossl_md5_functions[] = {

View File

@ -133,7 +133,7 @@ static OSSL_FUNC_cipher_get_params_fn alg##_##kbits##_##lcmode##_get_params; \
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[]) \
{ \
return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \
flags, kbits, blkbits, ivbits); \
flags, kbits, blkbits, ivbits, 0); \
} \
static OSSL_FUNC_cipher_newctx_fn alg##_##kbits##_##lcmode##_newctx; \
static void *alg##_##kbits##_##lcmode##_newctx(void *provctx) \

View File

@ -47,10 +47,10 @@ static void *seed_dupctx(void *ctx)
}
/* ossl_seed128ecb_functions */
IMPLEMENT_generic_cipher(seed, SEED, ecb, ECB, 0, 128, 128, 0, block)
IMPLEMENT_generic_cipher(seed, SEED, ecb, ECB, 0, 128, 128, 0, 1, block)
/* ossl_seed128cbc_functions */
IMPLEMENT_generic_cipher(seed, SEED, cbc, CBC, 0, 128, 128, 128, block)
IMPLEMENT_generic_cipher(seed, SEED, cbc, CBC, 0, 128, 128, 128, 1, block)
/* ossl_seed128ofb128_functions */
IMPLEMENT_generic_cipher(seed, SEED, ofb128, OFB, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(seed, SEED, ofb128, OFB, 0, 128, 8, 128, 1, stream)
/* ossl_seed128cfb128_functions */
IMPLEMENT_generic_cipher(seed, SEED, cfb128, CFB, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(seed, SEED, cfb128, CFB, 0, 128, 8, 128, 1, stream)

View File

@ -41,12 +41,12 @@ static void *sm4_dupctx(void *ctx)
}
/* ossl_sm4128ecb_functions */
IMPLEMENT_generic_cipher(sm4, SM4, ecb, ECB, 0, 128, 128, 0, block)
IMPLEMENT_generic_cipher(sm4, SM4, ecb, ECB, 0, 128, 128, 0, 1, block)
/* ossl_sm4128cbc_functions */
IMPLEMENT_generic_cipher(sm4, SM4, cbc, CBC, 0, 128, 128, 128, block)
IMPLEMENT_generic_cipher(sm4, SM4, cbc, CBC, 0, 128, 128, 128, 1, block)
/* ossl_sm4128ctr_functions */
IMPLEMENT_generic_cipher(sm4, SM4, ctr, CTR, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(sm4, SM4, ctr, CTR, 0, 128, 8, 128, 1, stream)
/* ossl_sm4128ofb128_functions */
IMPLEMENT_generic_cipher(sm4, SM4, ofb128, OFB, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(sm4, SM4, ofb128, OFB, 0, 128, 8, 128, 1, stream)
/* ossl_sm4128cfb128_functions */
IMPLEMENT_generic_cipher(sm4, SM4, cfb128, CFB, 0, 128, 8, 128, stream)
IMPLEMENT_generic_cipher(sm4, SM4, cfb128, CFB, 0, 128, 8, 128, 1, stream)

View File

@ -51,4 +51,4 @@ static void sm4_ccm_freectx(void *vctx)
}
/* sm4128ccm functions */
IMPLEMENT_aead_cipher(sm4, ccm, CCM, AEAD_FLAGS, 128, 8, 96);
IMPLEMENT_aead_cipher(sm4, ccm, CCM, AEAD_FLAGS, 128, 8, 96, 1);

View File

@ -52,4 +52,4 @@ static void sm4_gcm_freectx(void *vctx)
}
/* ossl_sm4128gcm_functions */
IMPLEMENT_aead_cipher(sm4, gcm, GCM, AEAD_FLAGS, 128, 8, 96);
IMPLEMENT_aead_cipher(sm4, gcm, GCM, AEAD_FLAGS, 128, 8, 96, 1);

View File

@ -246,7 +246,7 @@ static int sm4_##kbits##_##lcmode##_get_params(OSSL_PARAM params[]) \
{ \
return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \
flags, 2 * kbits, SM4_XTS_BLOCK_BITS,\
SM4_XTS_IV_BITS); \
SM4_XTS_IV_BITS, 1); \
} \
static OSSL_FUNC_cipher_newctx_fn sm4_##kbits##_xts_newctx; \
static void *sm4_##kbits##_xts_newctx(void *provctx) \

View File

@ -200,5 +200,5 @@ int ossl_tdes_get_params(OSSL_PARAM params[], unsigned int md, uint64_t flags,
}
return ossl_cipher_generic_get_params(params, md, flags,
kbits, blkbits, ivbits);
kbits, blkbits, ivbits, 0);
}

View File

@ -181,7 +181,7 @@ static OSSL_FUNC_cipher_get_params_fn tdes_wrap_get_params; \
static int tdes_wrap_get_params(OSSL_PARAM params[]) \
{ \
return ossl_cipher_generic_get_params(params, EVP_CIPH_WRAP_MODE, flags, \
kbits, blkbits, ivbits); \
kbits, blkbits, ivbits, 0); \
} \
const OSSL_DISPATCH ossl_tdes_wrap_cbc_functions[] = \
{ \

View File

@ -33,6 +33,7 @@ use OpenSSL::paramnames qw(produce_param_decoder);
['CIPHER_PARAM_KEYLEN', 'keylen', 'size_t'],
['CIPHER_PARAM_IVLEN', 'ivlen', 'size_t'],
['CIPHER_PARAM_BLOCK_SIZE', 'bsize', 'size_t'],
['CIPHER_PARAM_SECURITY_CATEGORY','sc', 'int'],
['CIPHER_PARAM_AEAD', 'aead', 'int' ],
['CIPHER_PARAM_CUSTOM_IV', 'custiv', 'int' ],
['CIPHER_PARAM_CTS', 'cts', 'int' ],
@ -48,7 +49,8 @@ const OSSL_PARAM *ossl_cipher_generic_gettable_params(ossl_unused void *provctx)
int ossl_cipher_generic_get_params(OSSL_PARAM params[], unsigned int md,
uint64_t flags,
size_t kbits, size_t blkbits, size_t ivbits)
size_t kbits, size_t blkbits, size_t ivbits,
int security_category)
{
struct ossl_cipher_generic_get_params_st p;
@ -100,6 +102,10 @@ int ossl_cipher_generic_get_params(OSSL_PARAM params[], unsigned int md,
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
return 0;
}
if (p.sc != NULL && !OSSL_PARAM_set_int(p.sc, security_category)) {
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
return 0;
}
return 1;
}

View File

@ -15,7 +15,8 @@
#include "prov/digestcommon.h"
#include "prov/implementations.h"
#define IMPLEMENT_BLAKE_functions(variant, VARIANT, variantsize) \
#define IMPLEMENT_BLAKE_functions(variant, VARIANT, variantsize, \
seccat_collision, seccat_preimage) \
static const OSSL_PARAM known_blake##variant##_ctx_params[] = { \
{OSSL_DIGEST_PARAM_SIZE, OSSL_PARAM_UNSIGNED_INTEGER, NULL, 0, 0}, \
OSSL_PARAM_END \
@ -169,7 +170,11 @@ static int blake##variantsize##_internal_final(void *ctx, unsigned char *out, \
\
static int blake##variantsize##_get_params(OSSL_PARAM params[]) \
{ \
return ossl_digest_default_get_params(params, BLAKE##VARIANT##_BLOCKBYTES, BLAKE##VARIANT##_OUTBYTES, 0); \
return ossl_digest_default_get_params(params, \
BLAKE##VARIANT##_BLOCKBYTES, \
BLAKE##VARIANT##_OUTBYTES, \
seccat_collision, seccat_preimage, \
0); \
} \
\
const OSSL_DISPATCH ossl_blake##variantsize##_functions[] = { \
@ -194,5 +199,5 @@ const OSSL_DISPATCH ossl_blake##variantsize##_functions[] = { \
{0, NULL} \
};
IMPLEMENT_BLAKE_functions(2s, 2S, 2s256)
IMPLEMENT_BLAKE_functions(2b, 2B, 2b512)
IMPLEMENT_BLAKE_functions(2s, 2S, 2s256, 2, 5)
IMPLEMENT_BLAKE_functions(2b, 2B, 2b512, 5, 5)

View File

@ -17,14 +17,17 @@ use OpenSSL::paramnames qw(produce_param_decoder);
#include "internal/common.h"
{- produce_param_decoder('digest_default_get_params',
(['DIGEST_PARAM_BLOCK_SIZE', 'bsize', 'size_t'],
['DIGEST_PARAM_SIZE', 'size', 'size_t'],
['DIGEST_PARAM_XOF', 'xof', 'int'],
['DIGEST_PARAM_ALGID_ABSENT', 'aldid', 'int'],
(['DIGEST_PARAM_BLOCK_SIZE', 'bsize', 'size_t'],
['DIGEST_PARAM_SIZE', 'size', 'size_t'],
['DIGEST_PARAM_SECURITY_CATEGORY_COLLISION', 'sc_c', 'int'],
['DIGEST_PARAM_SECURITY_CATEGORY_PREIMAGE', 'sc_pi', 'int'],
['DIGEST_PARAM_XOF', 'xof', 'int'],
['DIGEST_PARAM_ALGID_ABSENT', 'aldid', 'int'],
)); -}
int ossl_digest_default_get_params(OSSL_PARAM params[], size_t blksz,
size_t paramsz, unsigned long flags)
size_t paramsz, int seccat_collision,
int seccat_preimage, unsigned long flags)
{
struct digest_default_get_params_st p;
@ -48,6 +51,14 @@ int ossl_digest_default_get_params(OSSL_PARAM params[], size_t blksz,
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
return 0;
}
if (p.sc_c != NULL && !OSSL_PARAM_set_int(p.sc_c, seccat_collision)) {
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
return 0;
}
if (p.sc_pi != NULL && !OSSL_PARAM_set_int(p.sc_pi, seccat_preimage)) {
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
return 0;
}
return 1;
}

View File

@ -20,5 +20,5 @@
/* ossl_md2_functions */
IMPLEMENT_digest_functions(md2, MD2_CTX,
MD2_BLOCK, MD2_DIGEST_LENGTH, 0,
MD2_BLOCK, MD2_DIGEST_LENGTH, 0, 0, 0,
MD2_Init, MD2_Update, MD2_Final)

View File

@ -20,5 +20,5 @@
/* ossl_md4_functions */
IMPLEMENT_digest_functions(md4, MD4_CTX,
MD4_CBLOCK, MD4_DIGEST_LENGTH, 0,
MD4_CBLOCK, MD4_DIGEST_LENGTH, 0, 0, 0,
MD4_Init, MD4_Update, MD4_Final)

View File

@ -20,5 +20,5 @@
/* ossl_md5_functions */
IMPLEMENT_digest_functions(md5, MD5_CTX,
MD5_CBLOCK, MD5_DIGEST_LENGTH, 0,
MD5_CBLOCK, MD5_DIGEST_LENGTH, 0, 0, 0,
MD5_Init, MD5_Update, MD5_Final)

View File

@ -56,6 +56,6 @@ static int md5_sha1_set_ctx_params(void *vctx, const OSSL_PARAM params[])
/* ossl_md5_sha1_functions */
IMPLEMENT_digest_functions_with_settable_ctx(
md5_sha1, MD5_SHA1_CTX, MD5_SHA1_CBLOCK, MD5_SHA1_DIGEST_LENGTH, 0,
md5_sha1, MD5_SHA1_CTX, MD5_SHA1_CBLOCK, MD5_SHA1_DIGEST_LENGTH, 0, 1, 0,
ossl_md5_sha1_init, ossl_md5_sha1_update, ossl_md5_sha1_final,
md5_sha1_settable_ctx_params, md5_sha1_set_ctx_params)

View File

@ -56,6 +56,6 @@ static int mdc2_set_ctx_params(void *vctx, const OSSL_PARAM params[])
/* ossl_mdc2_functions */
IMPLEMENT_digest_functions_with_settable_ctx(
mdc2, MDC2_CTX, MDC2_BLOCK, MDC2_DIGEST_LENGTH, 0,
mdc2, MDC2_CTX, MDC2_BLOCK, MDC2_DIGEST_LENGTH, 0, 0, 0,
MDC2_Init, MDC2_Update, MDC2_Final,
mdc2_settable_ctx_params, mdc2_set_ctx_params)

View File

@ -48,5 +48,5 @@ static int name##_internal_final(void *ctx, unsigned char *out, size_t *outl, \
}
IMPLEMENT_digest_functions(nullmd, NULLMD_CTX,
0, 0, 0,
0, 0, 0, 0, 0,
null_init, null_update, null_final)

View File

@ -20,5 +20,5 @@
/* ossl_ripemd160_functions */
IMPLEMENT_digest_functions(ripemd160, RIPEMD160_CTX,
RIPEMD160_CBLOCK, RIPEMD160_DIGEST_LENGTH, 0,
RIPEMD160_CBLOCK, RIPEMD160_DIGEST_LENGTH, 0, 1, 0,
RIPEMD160_Init, RIPEMD160_Update, RIPEMD160_Final)

View File

@ -58,39 +58,56 @@ static int sha1_set_ctx_params(void *vctx, const OSSL_PARAM params[])
/* ossl_sha1_functions */
IMPLEMENT_digest_functions_with_settable_ctx(
sha1, SHA_CTX, SHA_CBLOCK, SHA_DIGEST_LENGTH, SHA2_FLAGS,
sha1, SHA_CTX, SHA_CBLOCK, SHA_DIGEST_LENGTH,
SHA1_COLLISION_CATEGORY, SHA1_PREIMAGE_CATEGORY, SHA2_FLAGS,
SHA1_Init, SHA1_Update, SHA1_Final,
sha1_settable_ctx_params, sha1_set_ctx_params)
/* ossl_sha224_functions */
IMPLEMENT_digest_functions(sha224, SHA256_CTX,
SHA256_CBLOCK, SHA224_DIGEST_LENGTH, SHA2_FLAGS,
SHA256_CBLOCK, SHA224_DIGEST_LENGTH,
SHA224_COLLISION_CATEGORY,
SHA224_PREIMAGE_CATEGORY, SHA2_FLAGS,
SHA224_Init, SHA224_Update, SHA224_Final)
/* ossl_sha256_functions */
IMPLEMENT_digest_functions(sha256, SHA256_CTX,
SHA256_CBLOCK, SHA256_DIGEST_LENGTH, SHA2_FLAGS,
SHA256_CBLOCK, SHA256_DIGEST_LENGTH,
SHA256_COLLISION_CATEGORY,
SHA256_PREIMAGE_CATEGORY, SHA2_FLAGS,
SHA256_Init, SHA256_Update, SHA256_Final)
/* ossl_sha256_192_internal_functions */
IMPLEMENT_digest_functions(sha256_192_internal, SHA256_CTX,
SHA256_CBLOCK, SHA256_192_DIGEST_LENGTH, SHA2_FLAGS,
SHA256_CBLOCK, SHA256_192_DIGEST_LENGTH,
SHA256_192_COLLISION_CATEGORY,
SHA256_192_PREIMAGE_CATEGORY, SHA2_FLAGS,
ossl_sha256_192_init, SHA256_Update, SHA256_Final)
/* ossl_sha384_functions */
IMPLEMENT_digest_functions(sha384, SHA512_CTX,
SHA512_CBLOCK, SHA384_DIGEST_LENGTH, SHA2_FLAGS,
SHA512_CBLOCK, SHA384_DIGEST_LENGTH,
SHA384_COLLISION_CATEGORY,
SHA384_PREIMAGE_CATEGORY, SHA2_FLAGS,
SHA384_Init, SHA384_Update, SHA384_Final)
/* ossl_sha512_functions */
IMPLEMENT_digest_functions(sha512, SHA512_CTX,
SHA512_CBLOCK, SHA512_DIGEST_LENGTH, SHA2_FLAGS,
SHA512_CBLOCK, SHA512_DIGEST_LENGTH,
SHA512_COLLISION_CATEGORY,
SHA512_PREIMAGE_CATEGORY, SHA2_FLAGS,
SHA512_Init, SHA512_Update, SHA512_Final)
/* ossl_sha512_224_functions */
IMPLEMENT_digest_functions(sha512_224, SHA512_CTX,
SHA512_CBLOCK, SHA224_DIGEST_LENGTH, SHA2_FLAGS,
SHA512_CBLOCK, SHA224_DIGEST_LENGTH,
SHA224_COLLISION_CATEGORY,
SHA224_PREIMAGE_CATEGORY, SHA2_FLAGS,
sha512_224_init, SHA512_Update, SHA512_Final)
/* ossl_sha512_256_functions */
IMPLEMENT_digest_functions(sha512_256, SHA512_CTX,
SHA512_CBLOCK, SHA256_DIGEST_LENGTH, SHA2_FLAGS,
SHA512_CBLOCK, SHA256_DIGEST_LENGTH,
SHA256_COLLISION_CATEGORY,
SHA256_PREIMAGE_CATEGORY, SHA2_FLAGS,
sha512_256_init, SHA512_Update, SHA512_Final)

View File

@ -528,8 +528,11 @@ static void *uname##_newctx(void *provctx) \
return ctx; \
}
#define PROV_FUNC_SHA3_DIGEST_COMMON(name, bitlen, blksize, dgstsize, flags) \
PROV_FUNC_DIGEST_GET_PARAM(name, blksize, dgstsize, flags) \
#define PROV_FUNC_SHA3_DIGEST_COMMON( \
name, bitlen, blksize, dgstsize, seccat_collision, seccat_preimage, \
flags) \
PROV_FUNC_DIGEST_GET_PARAM(name, blksize, dgstsize, seccat_collision, \
seccat_preimage, flags) \
const OSSL_DISPATCH ossl_##name##_functions[] = { \
{ OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))name##_newctx }, \
{ OSSL_FUNC_DIGEST_UPDATE, (void (*)(void))keccak_update }, \
@ -539,14 +542,16 @@ const OSSL_DISPATCH ossl_##name##_functions[] = { \
{ OSSL_FUNC_DIGEST_COPYCTX, (void (*)(void))keccak_copyctx }, \
PROV_DISPATCH_FUNC_DIGEST_GET_PARAMS(name)
#define PROV_FUNC_SHA3_DIGEST(name, bitlen, blksize, dgstsize, flags) \
PROV_FUNC_SHA3_DIGEST_COMMON(name, bitlen, blksize, dgstsize, flags), \
#define PROV_FUNC_SHA3_DIGEST(name, bitlen, blksize, dgstsize, seccat_collision, seccat_preimage, flags) \
PROV_FUNC_SHA3_DIGEST_COMMON(name, bitlen, blksize, dgstsize, \
seccat_collision, seccat_preimage, flags), \
{ OSSL_FUNC_DIGEST_INIT, (void (*)(void))keccak_init }, \
PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_END
#define PROV_FUNC_SHAKE_DIGEST(name, bitlen, blksize, dgstsize, flags) \
PROV_FUNC_SHA3_DIGEST_COMMON(name, bitlen, blksize, dgstsize, flags), \
{ OSSL_FUNC_DIGEST_SQUEEZE, (void (*)(void))shake_squeeze }, \
#define PROV_FUNC_SHAKE_DIGEST(name, bitlen, blksize, dgstsize, seccat_collision, seccat_preimage, flags) \
PROV_FUNC_SHA3_DIGEST_COMMON(name, bitlen, blksize, dgstsize, \
seccat_collision, seccat_preimage, flags), \
{ OSSL_FUNC_DIGEST_SQUEEZE, (void (*)(void))shake_squeeze }, \
{ OSSL_FUNC_DIGEST_INIT, (void (*)(void))keccak_init_params }, \
{ OSSL_FUNC_DIGEST_SET_CTX_PARAMS, (void (*)(void))shake_set_ctx_params }, \
{ OSSL_FUNC_DIGEST_SETTABLE_CTX_PARAMS, \
@ -650,52 +655,64 @@ static int shake_set_ctx_params(void *vctx, const OSSL_PARAM params[])
return 1;
}
#define IMPLEMENT_SHA3_functions(bitlen) \
#define IMPLEMENT_SHA3_functions(bitlen, seccat_collision, seccat_preimage) \
SHA3_newctx(sha3, SHA3_##bitlen, sha3_##bitlen, bitlen, '\x06') \
PROV_FUNC_SHA3_DIGEST(sha3_##bitlen, bitlen, \
SHA3_BLOCKSIZE(bitlen), SHA3_MDSIZE(bitlen), \
SHA3_FLAGS)
seccat_collision, seccat_preimage, SHA3_FLAGS)
#define IMPLEMENT_KECCAK_functions(bitlen) \
#define IMPLEMENT_KECCAK_functions(bitlen, seccat_collision, seccat_preimage) \
SHA3_newctx(keccak, KECCAK_##bitlen, keccak_##bitlen, bitlen, '\x01') \
PROV_FUNC_SHA3_DIGEST(keccak_##bitlen, bitlen, \
SHA3_BLOCKSIZE(bitlen), SHA3_MDSIZE(bitlen), \
SHA3_FLAGS)
seccat_collision, seccat_preimage, SHA3_FLAGS)
#define IMPLEMENT_SHAKE_functions(bitlen) \
#define IMPLEMENT_SHAKE_functions(bitlen, seccat_collision, seccat_preimage) \
SHAKE_newctx(shake, SHAKE_##bitlen, shake_##bitlen, bitlen, \
0 /* no default md length */, '\x1f') \
PROV_FUNC_SHAKE_DIGEST(shake_##bitlen, bitlen, \
SHA3_BLOCKSIZE(bitlen), 0, \
SHAKE_FLAGS)
seccat_collision, seccat_preimage, SHAKE_FLAGS)
#define IMPLEMENT_KMAC_functions(bitlen) \
#define IMPLEMENT_KMAC_functions(bitlen, seccat_collision, seccat_preimage) \
KMAC_newctx(keccak_kmac_##bitlen, bitlen, '\x04') \
PROV_FUNC_SHAKE_DIGEST(keccak_kmac_##bitlen, bitlen, \
SHA3_BLOCKSIZE(bitlen), KMAC_MDSIZE(bitlen), \
KMAC_FLAGS)
seccat_collision, seccat_preimage, KMAC_FLAGS)
/* ossl_sha3_224_functions */
IMPLEMENT_SHA3_functions(224)
IMPLEMENT_SHA3_functions(224, SHA224_COLLISION_CATEGORY,
SHA224_PREIMAGE_CATEGORY)
/* ossl_sha3_256_functions */
IMPLEMENT_SHA3_functions(256)
IMPLEMENT_SHA3_functions(256, SHA256_COLLISION_CATEGORY,
SHA256_PREIMAGE_CATEGORY)
/* ossl_sha3_384_functions */
IMPLEMENT_SHA3_functions(384)
IMPLEMENT_SHA3_functions(384, SHA384_COLLISION_CATEGORY,
SHA384_PREIMAGE_CATEGORY)
/* ossl_sha3_512_functions */
IMPLEMENT_SHA3_functions(512)
IMPLEMENT_SHA3_functions(512, SHA512_COLLISION_CATEGORY,
SHA512_PREIMAGE_CATEGORY)
/* ossl_keccak_224_functions */
IMPLEMENT_KECCAK_functions(224)
IMPLEMENT_KECCAK_functions(224, SHA224_COLLISION_CATEGORY,
SHA224_PREIMAGE_CATEGORY)
/* ossl_keccak_256_functions */
IMPLEMENT_KECCAK_functions(256)
IMPLEMENT_KECCAK_functions(256, SHA256_COLLISION_CATEGORY,
SHA256_PREIMAGE_CATEGORY)
/* ossl_keccak_384_functions */
IMPLEMENT_KECCAK_functions(384)
IMPLEMENT_KECCAK_functions(384, SHA384_COLLISION_CATEGORY,
SHA384_PREIMAGE_CATEGORY)
/* ossl_keccak_512_functions */
IMPLEMENT_KECCAK_functions(512)
IMPLEMENT_KECCAK_functions(512, SHA512_COLLISION_CATEGORY,
SHA512_PREIMAGE_CATEGORY)
/* ossl_shake_128_functions */
IMPLEMENT_SHAKE_functions(128)
IMPLEMENT_SHAKE_functions(128, SHAKE128_COLLISION_CATEGORY,
SHAKE128_PREIMAGE_CATEGORY)
/* ossl_shake_256_functions */
IMPLEMENT_SHAKE_functions(256)
IMPLEMENT_SHAKE_functions(256, SHAKE256_COLLISION_CATEGORY,
SHAKE256_PREIMAGE_CATEGORY)
/* ossl_keccak_kmac_128_functions */
IMPLEMENT_KMAC_functions(128)
IMPLEMENT_KMAC_functions(128, KMAC128_COLLISION_CATEGORY,
KMAC128_PREIMAGE_CATEGORY)
/* ossl_keccak_kmac_256_functions */
IMPLEMENT_KMAC_functions(256)
IMPLEMENT_KMAC_functions(256, KMAC256_COLLISION_CATEGORY,
KMAC256_PREIMAGE_CATEGORY)

View File

@ -14,5 +14,5 @@
/* ossl_sm3_functions */
IMPLEMENT_digest_functions(sm3, SM3_CTX,
SM3_CBLOCK, SM3_DIGEST_LENGTH, 0,
SM3_CBLOCK, SM3_DIGEST_LENGTH, 2, 5, 0,
ossl_sm3_init, ossl_sm3_update, ossl_sm3_final)

View File

@ -20,5 +20,6 @@
/* ossl_wp_functions */
IMPLEMENT_digest_functions(wp, WHIRLPOOL_CTX,
WHIRLPOOL_BBLOCK / 8, WHIRLPOOL_DIGEST_LENGTH, 0,
WHIRLPOOL_BBLOCK / 8, WHIRLPOOL_DIGEST_LENGTH,
5, 5, 0,
WHIRLPOOL_Init, WHIRLPOOL_Update, WHIRLPOOL_Final)

View File

@ -127,7 +127,8 @@ OSSL_FUNC_cipher_decrypt_skey_init_fn ossl_cipher_generic_skey_dinit;
int ossl_cipher_generic_get_params(OSSL_PARAM params[], unsigned int md,
uint64_t flags,
size_t kbits, size_t blkbits, size_t ivbits);
size_t kbits, size_t blkbits, size_t ivbits,
int security_category);
void ossl_cipher_generic_initkey(void *vctx, size_t kbits, size_t blkbits,
size_t ivbits, unsigned int mode,
uint64_t flags,
@ -192,13 +193,14 @@ const OSSL_DISPATCH ossl_##alg##kbits##lcmode##_functions[] = { \
};
# define IMPLEMENT_generic_cipher_genfn(alg, UCALG, lcmode, UCMODE, flags, \
kbits, blkbits, ivbits, typ) \
# define IMPLEMENT_generic_cipher_genfn(alg, UCALG, lcmode, UCMODE, flags, \
kbits, blkbits, ivbits, seccat, typ) \
static OSSL_FUNC_cipher_get_params_fn alg##_##kbits##_##lcmode##_get_params; \
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[]) \
{ \
return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \
flags, kbits, blkbits, ivbits); \
flags, kbits, blkbits, ivbits, \
seccat); \
} \
static OSSL_FUNC_cipher_newctx_fn alg##_##kbits##_##lcmode##_newctx; \
static void * alg##_##kbits##_##lcmode##_newctx(void *provctx) \
@ -214,17 +216,17 @@ static void * alg##_##kbits##_##lcmode##_newctx(void *provctx) \
return ctx; \
} \
# define IMPLEMENT_generic_cipher(alg, UCALG, lcmode, UCMODE, flags, kbits, \
blkbits, ivbits, typ) \
# define IMPLEMENT_generic_cipher(alg, UCALG, lcmode, UCMODE, flags, kbits, \
blkbits, ivbits, seccat, typ) \
IMPLEMENT_generic_cipher_genfn(alg, UCALG, lcmode, UCMODE, flags, kbits, \
blkbits, ivbits, typ) \
blkbits, ivbits, seccat, typ) \
IMPLEMENT_generic_cipher_func(alg, UCALG, lcmode, UCMODE, flags, kbits, \
blkbits, ivbits, typ)
# define IMPLEMENT_var_keylen_cipher(alg, UCALG, lcmode, UCMODE, flags, kbits, \
blkbits, ivbits, typ) \
# define IMPLEMENT_var_keylen_cipher(alg, UCALG, lcmode, UCMODE, flags, kbits, \
blkbits, ivbits, seccat, typ) \
IMPLEMENT_generic_cipher_genfn(alg, UCALG, lcmode, UCMODE, flags, kbits, \
blkbits, ivbits, typ) \
blkbits, ivbits, seccat, typ) \
IMPLEMENT_var_keylen_cipher_func(alg, UCALG, lcmode, UCMODE, flags, kbits, \
blkbits, ivbits, typ)

View File

@ -15,12 +15,13 @@
# define AEAD_FLAGS (PROV_CIPHER_FLAG_AEAD | PROV_CIPHER_FLAG_CUSTOM_IV)
# define IMPLEMENT_aead_cipher(alg, lc, UCMODE, flags, kbits, blkbits, ivbits) \
# define IMPLEMENT_aead_cipher(alg, lc, UCMODE, flags, kbits, blkbits, ivbits, seccat) \
static OSSL_FUNC_cipher_get_params_fn alg##_##kbits##_##lc##_get_params; \
static int alg##_##kbits##_##lc##_get_params(OSSL_PARAM params[]) \
{ \
return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \
flags, kbits, blkbits, ivbits); \
flags, kbits, blkbits, ivbits, \
seccat); \
} \
static OSSL_FUNC_cipher_newctx_fn alg##kbits##lc##_newctx; \
static void * alg##kbits##lc##_newctx(void *provctx) \

View File

@ -13,6 +13,7 @@
# include <openssl/core_dispatch.h>
# include <openssl/core_names.h>
# include <openssl/params.h>
# include "crypto/evp.h"
# include "prov/providercommon.h"
/* Internal flags that can be queried */
@ -23,11 +24,14 @@
extern "C" {
# endif
#define PROV_FUNC_DIGEST_GET_PARAM(name, blksize, dgstsize, flags) \
#define PROV_FUNC_DIGEST_GET_PARAM(name, blksize, dgstsize, seccat_collision, \
seccat_preimage, flags) \
static OSSL_FUNC_digest_get_params_fn name##_get_params; \
static int name##_get_params(OSSL_PARAM params[]) \
{ \
return ossl_digest_default_get_params(params, blksize, dgstsize, flags); \
return ossl_digest_default_get_params(params, blksize, dgstsize, \
seccat_collision, \
seccat_preimage, flags); \
}
#define PROV_DISPATCH_FUNC_DIGEST_GET_PARAMS(name) \
@ -48,7 +52,8 @@ static int name##_internal_final(void *ctx, unsigned char *out, size_t *outl, \
}
# define PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_START( \
name, CTX, blksize, dgstsize, flags, upd, fin) \
name, CTX, blksize, dgstsize, settable_ctx_params, set_ctx_params, \
seccat_collision, seccat_preimage, flags, upd, fin) \
static OSSL_FUNC_digest_newctx_fn name##_newctx; \
static OSSL_FUNC_digest_freectx_fn name##_freectx; \
static OSSL_FUNC_digest_dupctx_fn name##_dupctx; \
@ -77,7 +82,8 @@ static void name##_copyctx(void *voutctx, void *vinctx) \
*outctx = *inctx; \
} \
PROV_FUNC_DIGEST_FINAL(name, dgstsize, fin) \
PROV_FUNC_DIGEST_GET_PARAM(name, blksize, dgstsize, flags) \
PROV_FUNC_DIGEST_GET_PARAM(name, blksize, dgstsize, seccat_collision, \
seccat_preimage, flags) \
const OSSL_DISPATCH ossl_##name##_functions[] = { \
{ OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))name##_newctx }, \
{ OSSL_FUNC_DIGEST_UPDATE, (void (*)(void))upd }, \
@ -92,21 +98,24 @@ const OSSL_DISPATCH ossl_##name##_functions[] = { \
};
# define IMPLEMENT_digest_functions( \
name, CTX, blksize, dgstsize, flags, init, upd, fin) \
name, CTX, blksize, dgstsize, seccat_collision, seccat_preimage, flags, \
init, upd, fin) \
static OSSL_FUNC_digest_init_fn name##_internal_init; \
static int name##_internal_init(void *ctx, \
ossl_unused const OSSL_PARAM params[]) \
{ \
return ossl_prov_is_running() && init(ctx); \
} \
PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_START(name, CTX, blksize, dgstsize, flags, \
upd, fin), \
PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_START(name, CTX, blksize, dgstsize, \
settable_ctx_params, set_ctx_params, \
seccat_collision, seccat_preimage, \
flags, upd, fin), \
{ OSSL_FUNC_DIGEST_INIT, (void (*)(void))name##_internal_init }, \
PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_END
# define IMPLEMENT_digest_functions_with_settable_ctx( \
name, CTX, blksize, dgstsize, flags, init, upd, fin, \
settable_ctx_params, set_ctx_params) \
name, CTX, blksize, dgstsize, seccat_collision, seccat_preimage, flags, \
init, upd, fin, settable_ctx_params, set_ctx_params) \
static OSSL_FUNC_digest_init_fn name##_internal_init; \
static int name##_internal_init(void *ctx, const OSSL_PARAM params[]) \
{ \
@ -114,8 +123,10 @@ static int name##_internal_init(void *ctx, const OSSL_PARAM params[]) \
&& init(ctx) \
&& set_ctx_params(ctx, params); \
} \
PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_START(name, CTX, blksize, dgstsize, flags, \
upd, fin), \
PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_START(name, CTX, blksize, dgstsize, \
settable_ctx_params, set_ctx_params, \
seccat_collision, seccat_preimage, \
flags, upd, fin), \
{ OSSL_FUNC_DIGEST_INIT, (void (*)(void))name##_internal_init }, \
{ OSSL_FUNC_DIGEST_SETTABLE_CTX_PARAMS, (void (*)(void))settable_ctx_params }, \
{ OSSL_FUNC_DIGEST_SET_CTX_PARAMS, (void (*)(void))set_ctx_params }, \
@ -124,7 +135,8 @@ PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_END
const OSSL_PARAM *ossl_digest_default_gettable_params(void *provctx);
int ossl_digest_default_get_params(OSSL_PARAM params[], size_t blksz,
size_t paramsz, unsigned long flags);
size_t paramsz, int seccat_collision,
int seccat_preimage, unsigned long flags);
# ifdef __cplusplus
}

View File

@ -224,7 +224,8 @@ static int rand_check_fips_approved(EVP_RAND_CTX *ctx, EVP_TEST *t)
}
static int check_security_category(EVP_TEST *t, void *alg_obj,
int (*get_param)(void *, OSSL_PARAM *)) {
int (*get_param)(void *, OSSL_PARAM *),
int (*get_security_category)(void *)) {
OSSL_PARAM p[2];
int security_category = -1;
@ -233,7 +234,9 @@ static int check_security_category(EVP_TEST *t, void *alg_obj,
p[0] = OSSL_PARAM_construct_int(OSSL_ALG_PARAM_SECURITY_CATEGORY,
&security_category);
p[1] = OSSL_PARAM_construct_end();
if (!TEST_int_gt(get_param(alg_obj, p), 0)
if (!TEST_int_eq(get_security_category(alg_obj), t->security_category)
/* Test getting via the param too */
|| !TEST_int_gt(get_param(alg_obj, p), 0)
|| !TEST_true(OSSL_PARAM_modified(p))
|| !TEST_int_eq(security_category, t->security_category)) {
t->err = "INCORRECT_SECURITY_CATEGORY";
@ -244,7 +247,8 @@ static int check_security_category(EVP_TEST *t, void *alg_obj,
static int pkey_check_security_category(EVP_TEST *t, EVP_PKEY *pkey) {
return check_security_category(t, pkey,
(int (*)(void *, OSSL_PARAM *))EVP_PKEY_get_params);
(int (*)(void *, OSSL_PARAM *))EVP_PKEY_get_params,
(int (*)(void *))EVP_PKEY_get_security_category);
}
static int ctrladd(STACK_OF(OPENSSL_STRING) *controls, const char *value)
@ -709,8 +713,46 @@ typedef struct digest_data_st {
int xof;
/* Size for variable output length but non-XOF */
size_t digest_size;
/* NIST security categories */
int security_category_collision;
int security_category_preimage;
} DIGEST_DATA;
static int md_check_security_categories(EVP_TEST *t, const DIGEST_DATA *mdat) {
OSSL_PARAM p[3];
int security_category_collision = -1;
int security_category_preimage = -1;
const EVP_MD *md = mdat->digest;
p[0] = OSSL_PARAM_construct_int(OSSL_DIGEST_PARAM_SECURITY_CATEGORY_COLLISION,
&security_category_collision);
p[1] = OSSL_PARAM_construct_int(OSSL_DIGEST_PARAM_SECURITY_CATEGORY_PREIMAGE,
&security_category_preimage);
p[2] = OSSL_PARAM_construct_end();
if (!TEST_int_gt(EVP_MD_get_params(md, p), 0))
goto err;
if (mdat->security_category_collision >= 0)
if (!TEST_int_eq(EVP_MD_get_security_category_collision(md),
mdat->security_category_collision)
|| !TEST_true(OSSL_PARAM_modified(p))
|| !TEST_int_eq(security_category_collision,
mdat->security_category_collision))
goto err;
if (mdat->security_category_preimage >= 0)
if (!TEST_int_eq(EVP_MD_get_security_category_preimage(md),
mdat->security_category_preimage)
|| !TEST_true(OSSL_PARAM_modified(p + 1))
|| !TEST_int_eq(security_category_preimage,
mdat->security_category_preimage))
goto err;
return 1;
err:
t->err = "INCORRECT_SECURITY_CATEGORY";
return 0;
}
static int digest_test_init(EVP_TEST *t, const char *alg)
{
DIGEST_DATA *mdat;
@ -735,6 +777,8 @@ static int digest_test_init(EVP_TEST *t, const char *alg)
mdat->fetched_digest = fetched_digest;
mdat->pad_type = 0;
mdat->xof = 0;
mdat->security_category_collision = -1;
mdat->security_category_preimage = -1;
if (fetched_digest != NULL)
TEST_info("%s is fetched", alg);
return 1;
@ -753,6 +797,7 @@ static int digest_test_parse(EVP_TEST *t,
const char *keyword, const char *value)
{
DIGEST_DATA *mdata = t->data;
int n;
if (strcmp(keyword, "Input") == 0)
return evp_test_buffer_append(value, data_chunk_size, &mdata->input);
@ -767,12 +812,24 @@ static int digest_test_parse(EVP_TEST *t,
if (strcmp(keyword, "XOF") == 0)
return (mdata->xof = atoi(value)) > 0;
if (strcmp(keyword, "OutputSize") == 0) {
int sz;
sz = atoi(value);
if (sz < 0)
n = atoi(value);
if (n < 0)
return -1;
mdata->digest_size = sz;
mdata->digest_size = n;
return 1;
}
if (strcmp(keyword, "Security-Category-Collision") == 0) {
n = atoi(value);
if (n < 0)
return -1;
mdata->security_category_collision = n;
return 1;
}
if (strcmp(keyword, "Security-Category-Preimage") == 0) {
n = atoi(value);
if (n < 0)
return -1;
mdata->security_category_preimage = n;
return 1;
}
return 0;
@ -807,13 +864,21 @@ static int digest_test_run(EVP_TEST *t)
{
DIGEST_DATA *expected = t->data;
EVP_TEST_BUFFER *inbuf;
EVP_MD_CTX *mctx;
EVP_MD_CTX *mctx = NULL;
unsigned char *got = NULL;
unsigned int got_len;
size_t size = 0;
int xof = 0;
OSSL_PARAM params[4], *p = &params[0];
/* Digests don't have a single security category so fail if test is bad */
if (!TEST_int_eq(t->security_category, -1)) {
t->err = "INVALID_TEST_SECURITY_CATEGORY";
goto err;
}
if (!md_check_security_categories(t, expected))
goto err;
t->err = "TEST_FAILURE";
if (!TEST_ptr(mctx = EVP_MD_CTX_new()))
goto err;
@ -1592,6 +1657,12 @@ static int cipher_test_run(EVP_TEST *t)
size_t params_n = 0;
TEST_info("RUNNING TEST FOR CIPHER %s\n", EVP_CIPHER_get0_name(cdat->cipher));
if (!TEST_true(check_security_category(t, (void *)cdat->cipher,
(int (*)(void *, OSSL_PARAM *))EVP_CIPHER_get_params,
(int (*)(void *))EVP_CIPHER_get_security_category)))
return 0;
if (!cdat->key) {
t->err = "NO_KEY";
return 0;

View File

@ -250,12 +250,12 @@ int fake_pipeline_aead_set_ctx_params(void *vctx, const OSSL_PARAM params[])
}
#define IMPLEMENT_aead_cipher_pipeline(alg, lc, UCMODE, flags, kbits, blkbits, \
ivbits, ciphername) \
ivbits, seccat, ciphername) \
static OSSL_FUNC_cipher_get_params_fn alg##_##kbits##_##lc##_get_params; \
static int alg##_##kbits##_##lc##_get_params(OSSL_PARAM params[]) \
{ \
return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \
flags, kbits, blkbits, ivbits); \
flags, kbits, blkbits, ivbits, seccat); \
} \
static OSSL_FUNC_cipher_newctx_fn fake_pipeline_##alg##_##kbits##_##lc##_newctx; \
static void * fake_pipeline_##alg##_##kbits##_##lc##_newctx(void *provctx) \
@ -290,7 +290,7 @@ int fake_pipeline_aead_set_ctx_params(void *vctx, const OSSL_PARAM params[])
OSSL_DISPATCH_END \
}
IMPLEMENT_aead_cipher_pipeline(aes, gcm, GCM, AEAD_FLAGS, 256, 8, 96, "AES-256-GCM");
IMPLEMENT_aead_cipher_pipeline(aes, gcm, GCM, AEAD_FLAGS, 256, 8, 96, 5, "AES-256-GCM");
static const OSSL_ALGORITHM fake_ciphers[] = {
{"AES-256-GCM", "provider=fake-pipeline", fake_pipeline_aes256gcm_functions},

View File

@ -51,6 +51,7 @@ my @files = qw(
evpciph_aes_wrap.txt
evpciph_aes_stitched.txt
evpciph_des3_common.txt
evpciph_security_category.txt
evpkdf_hkdf.txt
evpkdf_kbkdf_counter.txt
evpkdf_kbkdf_kmac.txt
@ -63,6 +64,7 @@ my @files = qw(
evpkdf_x942.txt
evpkdf_x963.txt
evpmac_common.txt
evpmd_security_category.txt
evpmd_sha.txt
evppbe_pbkdf2.txt
evppkey_kdf_hkdf.txt

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,209 @@
#
# Copyright 2025 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
Title = Post Quantum Security Strength Category test
Availablein = default
Digest = BLAKE2s256
Input = 6162636465666768696a6b6c6d6e6f707172737475767778797a
Output = bdf88eb1f86a0cdf0e840ba88fa118508369df186c7355b4b16cf79fa2710a12
Security-Category-Collision = 2
Security-Category-Preimage = 5
Availablein = default
Digest = BLAKE2b512
Input = 6d65737361676520646967657374
Output = 3c26ce487b1c0f062363afa3c675ebdbf5f4ef9bdc022cfbef91e3111cdc283840d8331fc30a8a0906cff4bcdbcd230c61aaec60fdfad457ed96b709a382359a
Security-Category-Collision = 5
Security-Category-Preimage = 5
Availablein = legacy
Digest = MD2
Input = "abcdefghijklmnopqrstuvwxyz"
Output = 4e8ddff3650292ab5a4108c3aa47940b
Security-Category-Collision = 0
Security-Category-Preimage = 0
Availablein = legacy
Digest = MD4
Input = "abcdefghijklmnopqrstuvwxyz"
Output = d79e1c308aa5bbcdeea8ed63df412da9
Security-Category-Collision = 0
Security-Category-Preimage = 0
Availablein = default
Digest = MD5
Input = 6162636465666768696a6b6c6d6e6f707172737475767778797a
Output = c3fcd3d76192e4007dfb496cca67e13b
Security-Category-Collision = 0
Security-Category-Preimage = 0
Availablein = default
Digest = MD5-SHA1
Input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
Output = 8215ef0796a20bcaaae116d3876c664a84983e441c3bd26ebaae4aa1f95129e5e54670f1
Security-Category-Collision = 0
Security-Category-Preimage = 1
Availablein = legacy
Digest = MDC2
Input = "Now is the time for all "
Output = 42e50cd224baceba760bdd2bd409281a
Security-Category-Collision = 0
Security-Category-Preimage = 0
Availablein = legacy default
Digest = RIPEMD160
Input = "message digest"
Output = 5d0689ef49d2fae572b881b123a85ffa21595f36
Security-Category-Collision = 0
Security-Category-Preimage = 1
Availablein = legacy
Digest = whirlpool
Input = "abcdefghijklmnopqrstuvwxyz"
Output = F1D754662636FFE92C82EBB9212A484A8D38631EAD4238F5442EE13B8054E41B08BF2A9251C30B6A0B8AAE86177AB4A6F68F673E7207865D5D9819A3DBA4EB3B
Security-Category-Collision = 5
Security-Category-Preimage = 5
Availablein = default
Digest = SM3
Input = 0090414C494345313233405941484F4F2E434F4D787968B4FA32C3FD2417842E73BBFEFF2F3C848B6831D7E0EC65228B3937E49863E4C6D3B23B0C849CF84241484BFE48F61D59A5B16BA06E6E12D1DA27C5249A421DEBD61B62EAB6746434EBC3CC315E32220B3BADD50BDC4C4E6C147FEDD43D0680512BCBB42C07D47349D2153B70C4E5D7FDFCBFA36EA1A85841B9E46E09A20AE4C7798AA0F119471BEE11825BE46202BB79E2A5844495E97C04FF4DF2548A7C0240F88F1CD4E16352A73C17B7F16F07353E53A176D684A9FE0C6BB798E857
Output = F4A38489E32B45B6F876E3AC2168CA392362DC8F23459C1D1146FC3DBFB7BC9A
Security-Category-Collision = 2
Security-Category-Preimage = 5
FIPSversion = >=3.6.0
Digest = SHA1
Input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
Output = 84983e441c3bd26ebaae4aa1f95129e5e54670f1
Security-Category-Collision = 0
Security-Category-Preimage = 1
FIPSversion = >=3.6.0
Digest = SHA224
Input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
Output = 75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525
Security-Category-Collision = 0
Security-Category-Preimage = 3
FIPSversion = >=3.6.0
Digest = SHA256
Input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
Output = 248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1
Security-Category-Collision = 2
Security-Category-Preimage = 5
Availablein = default
Digest = SHA256-192
Input = "abc"
Output = ba7816bf8f01cfea414140de5dae2223b00361a396177a9c
Security-Category-Collision = 0
Security-Category-Preimage = 1
FIPSversion = >=3.6.0
Digest = SHA384
Input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
Output = 09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039
Security-Category-Collision = 4
Security-Category-Preimage = 5
FIPSversion = >=3.6.0
Digest = SHA512
Input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
Output = 8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909
Security-Category-Collision = 5
Security-Category-Preimage = 5
FIPSversion = >=3.6.0
Digest = SHA512-224
Input = 6963446913771410
Output = 21f6c373637e6a5e89d6e88811110c5c3fa12e497144912914c546e1
Security-Category-Collision = 0
Security-Category-Preimage = 3
FIPSversion = >=3.6.0
Digest = SHA512-256
Input = 63188781f4e9cbd1e89a54a65da053b93722e1106f00f024ad1582421ab919326f8a6e17536d6596e3cf413a9231141733e37aae540f8711cefafe489a87c4f2e6fd942f6809f3bef3076763487de48c2ee88733c5bc870617a668c6f01471ed
Output = 91a8e285029085e224987078066486b6c605cbac27e49e84f4639710ddd05d33
Security-Category-Collision = 2
Security-Category-Preimage = 5
FIPSversion = >=3.6.0
Digest = SHA3-224
Input = 31c82d71785b7ca6b651cb6c8c9ad5e2aceb0b0633c088d33aa247ada7a594ff4936c023251319820a9b19fc6c48de8a6f7ada214176ccdaadaeef51ed43714ac0c8269bbd497e46e78bb5e58196494b2471b1680e2d4c6dbd249831bd83a4d3be06c8a2e903933974aa05ee748bfe6ef359f7a143edf0d4918da916bd6f15e26a790cff514b40a5da7f72e1ed2fe63a05b8149587bea05653718cc8980eadbfeca85b7c9c286dd040936585938be7f98219700c83a9443c2856a80ff46852b26d1b1edf72a30203cf6c44a10fa6eaf1920173cedfb5c4cf3ac665b37a86ed02155bbbf17dc2e786af9478fe0889d86c5bfa85a242eb0854b1482b7bd16f67f80bef9c7a628f05a107936a64273a97b0088b0e515451f916b5656230a12ba6dc78
Output = aab23c9e7fb9d7dacefdfd0b1ae85ab1374abff7c4e3f7556ecae412
Security-Category-Collision = 0
Security-Category-Preimage = 3
FIPSversion = >=3.6.0
Digest = SHA3-256
Input = b1caa396771a09a1db9bc20543e988e359d47c2a616417bbca1b62cb02796a888fc6eeff5c0b5c3d5062fcb4256f6ae1782f492c1cf03610b4a1fb7b814c057878e1190b9835425c7a4a0e182ad1f91535ed2a35033a5d8c670e21c575ff43c194a58a82d4a1a44881dd61f9f8161fc6b998860cbe4975780be93b6f87980bad0a99aa2cb7556b478ca35d1f3746c33e2bb7c47af426641cc7bbb3425e2144820345e1d0ea5b7da2c3236a52906acdc3b4d34e474dd714c0c40bf006a3a1d889a632983814bbc4a14fe5f159aa89249e7c738b3b73666bac2a615a83fd21ae0a1ce7352ade7b278b587158fd2fabb217aa1fe31d0bda53272045598015a8ae4d8cec226fefa58daa05500906c4d85e7567
Output = cb5648a1d61c6c5bdacd96f81c9591debc3950dcf658145b8d996570ba881a05
Security-Category-Collision = 2
Security-Category-Preimage = 5
FIPSversion = >=3.6.0
Digest = SHA3-384
Input = 5fe35923b4e0af7dd24971812a58425519850a506dfa9b0d254795be785786c319a2567cbaa5e35bcf8fe83d943e23fa5169b73adc1fcf8b607084b15e6a013df147e46256e4e803ab75c110f77848136be7d806e8b2f868c16c3a90c14463407038cb7d9285079ef162c6a45cedf9c9f066375c969b5fcbcda37f02aacff4f31cded3767570885426bebd9eca877e44674e9ae2f0c24cdd0e7e1aaf1ff2fe7f80a1c4f5078eb34cd4f06fa94a2d1eab5806ca43fd0f06c60b63d5402b95c70c21ea65a151c5cfaf8262a46be3c722264b
Output = 3054d249f916a6039b2a9c3ebec1418791a0608a170e6d36486035e5f92635eaba98072a85373cb54e2ae3f982ce132b
Security-Category-Collision = 4
Security-Category-Preimage = 5
FIPSversion = >=3.6.0
Digest = SHA3-512
Input = 664ef2e3a7059daf1c58caf52008c5227e85cdcb83b4c59457f02c508d4f4f69f826bd82c0cffc5cb6a97af6e561c6f96970005285e58f21ef6511d26e709889a7e513c434c90a3cf7448f0caeec7114c747b2a0758a3b4503a7cf0c69873ed31d94dbef2b7b2f168830ef7da3322c3d3e10cafb7c2c33c83bbf4c46a31da90cff3bfd4ccc6ed4b310758491eeba603a76
Output = e5825ff1a3c070d5a52fbbe711854a440554295ffb7a7969a17908d10163bfbe8f1d52a676e8a0137b56a11cdf0ffbb456bc899fc727d14bd8882232549d914e
Security-Category-Collision = 5
Security-Category-Preimage = 5
FIPSversion = >=3.6.0
Digest = SHAKE128
Input = a6fe00064257aa318b621c5eb311d32bb8004c2fa1a969d205d71762cc5d2e633907992629d1b69d9557ff6d5e8deb454ab00f6e497c89a4fea09e257a6fa2074bd818ceb5981b3e3faefd6e720f2d1edd9c5e4a5c51e5009abf636ed5bca53fe159c8287014a1bd904f5c8a7501625f79ac81eb618f478ce21cae6664acffb30572f059e1ad0fc2912264e8f1ca52af26c8bf78e09d75f3dd9fc734afa8770abe0bd78c90cc2ff448105fb16dd2c5b7edd8611a62e537db9331f5023e16d6ec150cc6e706d7c7fcbfff930c7281831fd5c4aff86ece57ed0db882f59a5fe403105d0592ca38a081fed84922873f538ee774f13b8cc09bd0521db4374aec69f4bae6dcb66455822c0b84c91a3474ffac2ad06f0a4423cd2c6a49d4f0d6242d6a1890937b5d9835a5f0ea5b1d01884d22a6c1718e1f60b3ab5e232947c76ef70b344171083c688093b5f1475377e3069863
Output = 3109d9472ca436e805c6b3db2251a9bc
Security-Category-Collision = 2
Security-Category-Preimage = 2
FIPSversion = >=3.6.0
Digest = SHAKE256
Input = dc5a100fa16df1583c79722a0d72833d3bf22c109b8889dbd35213c6bfce205813edae3242695cfd9f59b9a1c203c1b72ef1a5423147cb990b5316a85266675894e2644c3f9578cebe451a09e58c53788fe77a9e850943f8a275f830354b0593a762bac55e984db3e0661eca3cb83f67a6fb348e6177f7dee2df40c4322602f094953905681be3954fe44c4c902c8f6bba565a788b38f13411ba76ce0f9f6756a2a2687424c5435a51e62df7a8934b6e141f74c6ccf539e3782d22b5955d3baf1ab2cf7b5c3f74ec2f9447344e937957fd7f0bdfec56d5d25f61cde18c0986e244ecf780d6307e313117256948d4230ebb9ea62bb302cfe80d7dfebabc4a51d7687967ed5b416a139e974c005fff507a96
Output = 2bac5716803a9cda8f9e84365ab0a681327b5ba34fdedfb1c12e6e807f45284b
Security-Category-Collision = 5
Security-Category-Preimage = 5
FIPSversion = >=3.6.0
Availablein = default
Digest = KECCAK-224
Input = 20FF454369A5D05B81A78F3DB05819FEA9B08C2384F75CB0AB6AA115DD690DA3131874A1CA8F708AD1519EA952C1E249CB540D196392C79E87755424FEE7C890808C562722359EEA52E8A12FBBB969DD7961D2BA52037493755A5FA04F0D50A1AA26C9B44148C0D3B94D1C4A59A31ACA15AE8BD44ACB7833D8E91C4B86FA3135A423387B8151B4133ED23F6D7187B50EC2204AD901AD74D396E44274E0ECAFAAE17B3B9085E22260B35CA53B15CC52ABBA758AF6798FBD04ECEECED648F3AF4FDB3DED7557A9A5CFB7382612A8A8F3F45947D1A29CE29072928EC193CA25D51071BD5E1984ECF402F306EA762F0F25282F5296D997658BE3F983696FFA6D095C6369B4DAF79E9A5D3136229128F8EB63C12B9E9FA78AFF7A3E9E19A62022493CD136DEFBB5BB7BA1B938F367FD2F63EB5CA76C0B0FF21B9E36C3F07230CF3C3074E5DA587040A76975D7E39F4494ACE5486FCBF380AB7558C4FE89656335B82E4DB8659509EAB46A19613126E594042732DD4C411F41AA8CDEAC71C0FB40A94E6DA558C05E77B6182806F26D9AFDF3DA00C69419222C8186A6EFAD600B410E6CE2F2A797E49DC1F135319801FA6F396B06F975E2A190A023E474B618E7
Output = 34A58DDFC5C2222281FA73EB34BFB5E152272CC3AC7FE97AC58C08B0
Security-Category-Collision = 0
Security-Category-Preimage = 3
FIPSversion = >=3.6.0
Availablein = default
Digest = KECCAK-256
Input = 20FF454369A5D05B81A78F3DB05819FEA9B08C2384F75CB0AB6AA115DD690DA3131874A1CA8F708AD1519EA952C1E249CB540D196392C79E87755424FEE7C890808C562722359EEA52E8A12FBBB969DD7961D2BA52037493755A5FA04F0D50A1AA26C9B44148C0D3B94D1C4A59A31ACA15AE8BD44ACB7833D8E91C4B86FA3135A423387B8151B4133ED23F6D7187B50EC2204AD901AD74D396E44274E0ECAFAAE17B3B9085E22260B35CA53B15CC52ABBA758AF6798FBD04ECEECED648F3AF4FDB3DED7557A9A5CFB7382612A8A8F3F45947D1A29CE29072928EC193CA25D51071BD5E1984ECF402F306EA762F0F25282F5296D997658BE3F983696FFA6D095C6369B4DAF79E9A5D3136229128F8EB63C12B9E9FA78AFF7A3E9E19A62022493CD136DEFBB5BB7BA1B938F367FD2F63EB5CA76C0B0FF21B9E36C3F07230CF3C3074E5DA587040A76975D7E39F4494ACE5486FCBF380AB7558C4FE89656335B82E4DB8659509EAB46A19613126E594042732DD4C411F41AA8CDEAC71C0FB40A94E6DA558C05E77B6182806F26D9AFDF3DA00C69419222C8186A6EFAD600B410E6CE2F2A797E49DC1F135319801FA6F396B06F975E2A190A023E474B618E7
Output = 0EC8D9D20DDF0A7B0251E941A7261B557507FF6287B504362A8F1734C5A91012
Security-Category-Collision = 2
Security-Category-Preimage = 5
FIPSversion = >=3.6.0
Availablein = default
Digest = KECCAK-384
Input = 20FF454369A5D05B81A78F3DB05819FEA9B08C2384F75CB0AB6AA115DD690DA3131874A1CA8F708AD1519EA952C1E249CB540D196392C79E87755424FEE7C890808C562722359EEA52E8A12FBBB969DD7961D2BA52037493755A5FA04F0D50A1AA26C9B44148C0D3B94D1C4A59A31ACA15AE8BD44ACB7833D8E91C4B86FA3135A423387B8151B4133ED23F6D7187B50EC2204AD901AD74D396E44274E0ECAFAAE17B3B9085E22260B35CA53B15CC52ABBA758AF6798FBD04ECEECED648F3AF4FDB3DED7557A9A5CFB7382612A8A8F3F45947D1A29CE29072928EC193CA25D51071BD5E1984ECF402F306EA762F0F25282F5296D997658BE3F983696FFA6D095C6369B4DAF79E9A5D3136229128F8EB63C12B9E9FA78AFF7A3E9E19A62022493CD136DEFBB5BB7BA1B938F367FD2F63EB5CA76C0B0FF21B9E36C3F07230CF3C3074E5DA587040A76975D7E39F4494ACE5486FCBF380AB7558C4FE89656335B82E4DB8659509EAB46A19613126E594042732DD4C411F41AA8CDEAC71C0FB40A94E6DA558C05E77B6182806F26D9AFDF3DA00C69419222C8186A6EFAD600B410E6CE2F2A797E49DC1F135319801FA6F396B06F975E2A190A023E474B618E7
Output = 5975FA4BCEFC79FADC79CCF1254BBA9EAC252E24C7DEC7EB8972D265EFAD3F6CF648C49DFFF5453AD27D62FF867A2F03
Security-Category-Collision = 4
Security-Category-Preimage = 5
FIPSversion = >=3.6.0
Availablein = default
Digest = KECCAK-512
Input = 20FF454369A5D05B81A78F3DB05819FEA9B08C2384F75CB0AB6AA115DD690DA3131874A1CA8F708AD1519EA952C1E249CB540D196392C79E87755424FEE7C890808C562722359EEA52E8A12FBBB969DD7961D2BA52037493755A5FA04F0D50A1AA26C9B44148C0D3B94D1C4A59A31ACA15AE8BD44ACB7833D8E91C4B86FA3135A423387B8151B4133ED23F6D7187B50EC2204AD901AD74D396E44274E0ECAFAAE17B3B9085E22260B35CA53B15CC52ABBA758AF6798FBD04ECEECED648F3AF4FDB3DED7557A9A5CFB7382612A8A8F3F45947D1A29CE29072928EC193CA25D51071BD5E1984ECF402F306EA762F0F25282F5296D997658BE3F983696FFA6D095C6369B4DAF79E9A5D3136229128F8EB63C12B9E9FA78AFF7A3E9E19A62022493CD136DEFBB5BB7BA1B938F367FD2F63EB5CA76C0B0FF21B9E36C3F07230CF3C3074E5DA587040A76975D7E39F4494ACE5486FCBF380AB7558C4FE89656335B82E4DB8659509EAB46A19613126E594042732DD4C411F41AA8CDEAC71C0FB40A94E6DA558C05E77B6182806F26D9AFDF3DA00C69419222C8186A6EFAD600B410E6CE2F2A797E49DC1F135319801FA6F396B06F975E2A190A023E474B618E7
Output = 116AE94C86F68F96B8AEF298A9F5852CC9913A2AD3C3C344F28DCC9B29292A716FAF51DD04A9433D8A12572E1DBC581A7CDC4E50BC1CA9051DDBC121F2E864E2
Security-Category-Collision = 5
Security-Category-Preimage = 5

View File

@ -5926,10 +5926,13 @@ OSSL_AA_DIST_POINT_it ? 3_5_0 EXIST::FUNCTION:
PEM_ASN1_write_bio_ctx ? 3_5_0 EXIST::FUNCTION:
EVP_PKEY_get_security_category ? 3_6_0 EXIST::FUNCTION:
X509_STORE_CTX_set_ocsp_resp ? 3_6_0 EXIST::FUNCTION:OCSP
EVP_CIPHER_get_security_category ? 3_6_0 EXIST::FUNCTION:
OPENSSL_sk_set_thunks ? 3_6_0 EXIST::FUNCTION:
i2d_PKCS8PrivateKey ? 3_6_0 EXIST::FUNCTION:
OSSL_PARAM_set_octet_string_or_ptr ? 3_6_0 EXIST::FUNCTION:
OSSL_STORE_LOADER_settable_ctx_params ? 3_6_0 EXIST::FUNCTION:
EVP_MD_get_security_category_collision ? 3_6_0 EXIST::FUNCTION:
EVP_MD_get_security_category_preimage ? 3_6_0 EXIST::FUNCTION:
X509_CRL_get0_tbs_sigalg ? 3_6_0 EXIST::FUNCTION:
CMS_RecipientInfo_kemri_cert_cmp ? 3_6_0 EXIST::FUNCTION:CMS
CMS_RecipientInfo_kemri_set0_pkey ? 3_6_0 EXIST::FUNCTION:CMS

View File

@ -113,6 +113,7 @@ my %params = (
'CIPHER_PARAM_TLS_MAC_SIZE' => "tls-mac-size",# size_t
'CIPHER_PARAM_MODE' => "mode", # uint
'CIPHER_PARAM_BLOCK_SIZE' => "blocksize", # size_t
'CIPHER_PARAM_SECURITY_CATEGORY' => '*ALG_PARAM_SECURITY_CATEGORY',
'CIPHER_PARAM_AEAD' => "aead", # int, 0 or 1
'CIPHER_PARAM_CUSTOM_IV' => "custom-iv", # int, 0 or 1
'CIPHER_PARAM_CTS' => "cts", # int, 0 or 1
@ -171,6 +172,8 @@ my %params = (
'DIGEST_PARAM_SIZE' => "size", # size_t
'DIGEST_PARAM_XOF' => "xof", # int, 0 or 1
'DIGEST_PARAM_ALGID_ABSENT' => "algid-absent", # int, 0 or 1
'DIGEST_PARAM_SECURITY_CATEGORY_COLLISION' => "collision-security-category", # Security Category
'DIGEST_PARAM_SECURITY_CATEGORY_PREIMAGE' => "preimage-security-category", # Security Category
# MAC parameters
'MAC_PARAM_KEY' => "key", # octet string