diff options
Diffstat (limited to 'providers/implementations/ciphers/ciphercommon.c')
-rw-r--r-- | providers/implementations/ciphers/ciphercommon.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/providers/implementations/ciphers/ciphercommon.c b/providers/implementations/ciphers/ciphercommon.c index 7ad3eb0a1f52..b1331b5b64f1 100644 --- a/providers/implementations/ciphers/ciphercommon.c +++ b/providers/implementations/ciphers/ciphercommon.c @@ -1,5 +1,5 @@ /* - * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2019-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 @@ -17,6 +17,8 @@ #include "ciphercommon_local.h" #include "prov/provider_ctx.h" #include "prov/providercommon.h" +#include "internal/skey.h" +#include "crypto/types.h" /*- * Generic cipher functions for OSSL_PARAM gettables and settables @@ -115,7 +117,7 @@ int ossl_cipher_var_keylen_set_ctx_params(void *vctx, const OSSL_PARAM params[]) PROV_CIPHER_CTX *ctx = (PROV_CIPHER_CTX *)vctx; const OSSL_PARAM *p; - if (params == NULL) + if (ossl_param_is_empty(params)) return 1; if (!ossl_cipher_generic_set_ctx_params(vctx, params)) @@ -152,6 +154,7 @@ static const OSSL_PARAM cipher_aead_known_gettable_ctx_params[] = { OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_AEAD_TAG, NULL, 0), OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_AEAD_TLS1_AAD_PAD, NULL), OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_AEAD_TLS1_GET_IV_GEN, NULL, 0), + OSSL_PARAM_uint(OSSL_CIPHER_PARAM_AEAD_IV_GENERATED, NULL), OSSL_PARAM_END }; const OSSL_PARAM *ossl_cipher_aead_gettable_ctx_params( @@ -241,6 +244,28 @@ int ossl_cipher_generic_dinit(void *vctx, const unsigned char *key, iv, ivlen, params, 0); } +int ossl_cipher_generic_skey_einit(void *vctx, void *skeydata, + const unsigned char *iv, size_t ivlen, + const OSSL_PARAM params[]) +{ + PROV_SKEY *key = skeydata; + + return cipher_generic_init_internal((PROV_CIPHER_CTX *)vctx, + key->data, key->length, + iv, ivlen, params, 1); +} + +int ossl_cipher_generic_skey_dinit(void *vctx, void *skeydata, + const unsigned char *iv, size_t ivlen, + const OSSL_PARAM params[]) +{ + PROV_SKEY *key = skeydata; + + return cipher_generic_init_internal((PROV_CIPHER_CTX *)vctx, + key->data, key->length, + iv, ivlen, params, 0); +} + /* Max padding including padding length byte */ #define MAX_PADDING 256 @@ -624,7 +649,7 @@ int ossl_cipher_generic_set_ctx_params(void *vctx, const OSSL_PARAM params[]) PROV_CIPHER_CTX *ctx = (PROV_CIPHER_CTX *)vctx; const OSSL_PARAM *p; - if (params == NULL) + if (ossl_param_is_empty(params)) return 1; p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_PADDING); |