diff options
-rw-r--r-- | providers/implementations/ciphers/ciphercommon.c | 15 | ||||
-rw-r--r-- | providers/implementations/ciphers/ciphercommon_ccm.c | 18 | ||||
-rw-r--r-- | providers/implementations/ciphers/ciphercommon_gcm.c | 18 |
3 files changed, 30 insertions, 21 deletions
diff --git a/providers/implementations/ciphers/ciphercommon.c b/providers/implementations/ciphers/ciphercommon.c index 2054615838..53ecbc9012 100644 --- a/providers/implementations/ciphers/ciphercommon.c +++ b/providers/implementations/ciphers/ciphercommon.c @@ -177,7 +177,7 @@ void ossl_cipher_generic_reset_ctx(PROV_CIPHER_CTX *ctx) static int cipher_generic_init_internal(PROV_CIPHER_CTX *ctx, const unsigned char *key, size_t keylen, const unsigned char *iv, size_t ivlen, - int enc) + const OSSL_PARAM params[], int enc) { ctx->num = 0; ctx->bufsz = 0; @@ -200,25 +200,26 @@ static int cipher_generic_init_internal(PROV_CIPHER_CTX *ctx, } else { ctx->keylen = keylen; } - return ctx->hw->init(ctx, key, ctx->keylen); + if (!ctx->hw->init(ctx, key, ctx->keylen)) + return 0; } - return 1; + return ossl_cipher_generic_set_ctx_params(ctx, params); } int ossl_cipher_generic_einit(void *vctx, const unsigned char *key, size_t keylen, const unsigned char *iv, - size_t ivlen) + size_t ivlen, const OSSL_PARAM params[]) { return cipher_generic_init_internal((PROV_CIPHER_CTX *)vctx, key, keylen, - iv, ivlen, 1); + iv, ivlen, params, 1); } int ossl_cipher_generic_dinit(void *vctx, const unsigned char *key, size_t keylen, const unsigned char *iv, - size_t ivlen) + size_t ivlen, const OSSL_PARAM params[]) { return cipher_generic_init_internal((PROV_CIPHER_CTX *)vctx, key, keylen, - iv, ivlen, 0); + iv, ivlen, params, 0); } /* Max padding including padding length byte */ diff --git a/providers/implementations/ciphers/ciphercommon_ccm.c b/providers/implementations/ciphers/ciphercommon_ccm.c index 02618a784a..ce3f7527f3 100644 --- a/providers/implementations/ciphers/ciphercommon_ccm.c +++ b/providers/implementations/ciphers/ciphercommon_ccm.c @@ -220,7 +220,8 @@ int ossl_ccm_get_ctx_params(void *vctx, OSSL_PARAM params[]) } static int ccm_init(void *vctx, const unsigned char *key, size_t keylen, - const unsigned char *iv, size_t ivlen, int enc) + const unsigned char *iv, size_t ivlen, + const OSSL_PARAM params[], int enc) { PROV_CCM_CTX *ctx = (PROV_CCM_CTX *)vctx; @@ -242,21 +243,24 @@ static int ccm_init(void *vctx, const unsigned char *key, size_t keylen, ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH); return 0; } - return ctx->hw->setkey(ctx, key, keylen); + if (!ctx->hw->setkey(ctx, key, keylen)) + return 0; } - return 1; + return ossl_ccm_set_ctx_params(ctx, params); } int ossl_ccm_einit(void *vctx, const unsigned char *key, size_t keylen, - const unsigned char *iv, size_t ivlen) + const unsigned char *iv, size_t ivlen, + const OSSL_PARAM params[]) { - return ccm_init(vctx, key, keylen, iv, ivlen, 1); + return ccm_init(vctx, key, keylen, iv, ivlen, params, 1); } int ossl_ccm_dinit(void *vctx, const unsigned char *key, size_t keylen, - const unsigned char *iv, size_t ivlen) + const unsigned char *iv, size_t ivlen, + const OSSL_PARAM params[]) { - return ccm_init(vctx, key, keylen, iv, ivlen, 0); + return ccm_init(vctx, key, keylen, iv, ivlen, params, 0); } int ossl_ccm_stream_update(void *vctx, unsigned char *out, size_t *outl, diff --git a/providers/implementations/ciphers/ciphercommon_gcm.c b/providers/implementations/ciphers/ciphercommon_gcm.c index 7fc5bc7dec..b19e15b3b2 100644 --- a/providers/implementations/ciphers/ciphercommon_gcm.c +++ b/providers/implementations/ciphers/ciphercommon_gcm.c @@ -40,7 +40,8 @@ void ossl_gcm_initctx(void *provctx, PROV_GCM_CTX *ctx, size_t keybits, } static int gcm_init(void *vctx, const unsigned char *key, size_t keylen, - const unsigned char *iv, size_t ivlen, int enc) + const unsigned char *iv, size_t ivlen, + const OSSL_PARAM params[], int enc) { PROV_GCM_CTX *ctx = (PROV_GCM_CTX *)vctx; @@ -64,21 +65,24 @@ static int gcm_init(void *vctx, const unsigned char *key, size_t keylen, ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH); return 0; } - return ctx->hw->setkey(ctx, key, ctx->keylen); + if (!ctx->hw->setkey(ctx, key, ctx->keylen)) + return 0; } - return 1; + return ossl_gcm_set_ctx_params(ctx, params); } int ossl_gcm_einit(void *vctx, const unsigned char *key, size_t keylen, - const unsigned char *iv, size_t ivlen) + const unsigned char *iv, size_t ivlen, + const OSSL_PARAM params[]) { - return gcm_init(vctx, key, keylen, iv, ivlen, 1); + return gcm_init(vctx, key, keylen, iv, ivlen, params, 1); } int ossl_gcm_dinit(void *vctx, const unsigned char *key, size_t keylen, - const unsigned char *iv, size_t ivlen) + const unsigned char *iv, size_t ivlen, + const OSSL_PARAM params[]) { - return gcm_init(vctx, key, keylen, iv, ivlen, 0); + return gcm_init(vctx, key, keylen, iv, ivlen, params, 0); } /* increment counter (64-bit int) by 1 */ |