X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=providers%2Fimplementations%2Fciphers%2Fcipher_tdes_wrap.c;h=9007e403a4ce671679109ee1e63eb0a92fbbb22a;hb=1be63951f87dfcbc98efe5d94a15298fea885890;hp=a6f4e4efe420ee74ca1697d424054895775a21d9;hpb=85d843c8eccce937d073a9df7a193032478e21dd;p=openssl.git diff --git a/providers/implementations/ciphers/cipher_tdes_wrap.c b/providers/implementations/ciphers/cipher_tdes_wrap.c index a6f4e4efe4..9007e403a4 100644 --- a/providers/implementations/ciphers/cipher_tdes_wrap.c +++ b/providers/implementations/ciphers/cipher_tdes_wrap.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 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 @@ -8,24 +8,25 @@ */ /* - * SHA-1 low level APIs are deprecated for public use, but still ok for + * DES and SHA-1 low level APIs are deprecated for public use, but still ok for * internal use. */ #include "internal/deprecated.h" #include +#include #include "cipher_tdes_default.h" #include "crypto/evp.h" -#include "crypto/rand.h" #include "prov/implementations.h" +#include "prov/providercommon.h" #include "prov/providercommonerr.h" /* TODO (3.0) Figure out what flags are required */ #define TDES_WRAP_FLAGS (EVP_CIPH_WRAP_MODE | EVP_CIPH_CUSTOM_IV) -static OSSL_OP_cipher_update_fn tdes_wrap_update; -static OSSL_OP_cipher_cipher_fn tdes_wrap_cipher; +static OSSL_FUNC_cipher_update_fn tdes_wrap_update; +static OSSL_FUNC_cipher_cipher_fn tdes_wrap_cipher; static const unsigned char wrap_iv[8] = { @@ -98,7 +99,7 @@ static int des_ede3_wrap(PROV_CIPHER_CTX *ctx, unsigned char *out, memcpy(out + inl + ivlen, sha1tmp, icvlen); OPENSSL_cleanse(sha1tmp, SHA_DIGEST_LENGTH); /* Generate random IV */ - if (rand_bytes_ex(ctx->libctx, ctx->iv, ivlen) <= 0) + if (RAND_bytes_ex(ctx->libctx, ctx->iv, ivlen) <= 0) return 0; memcpy(out, ctx->iv, ivlen); /* Encrypt everything after IV in place */ @@ -133,6 +134,9 @@ static int tdes_wrap_cipher(void *vctx, int ret; *outl = 0; + if (!ossl_prov_is_running()) + return 0; + if (outsize < inl) { PROVerr(0, PROV_R_OUTPUT_BUFFER_TOO_SMALL); return 0; @@ -167,19 +171,19 @@ static int tdes_wrap_update(void *vctx, unsigned char *out, size_t *outl, # define IMPLEMENT_WRAP_CIPHER(flags, kbits, blkbits, ivbits) \ -static OSSL_OP_cipher_newctx_fn tdes_wrap_newctx; \ +static OSSL_FUNC_cipher_newctx_fn tdes_wrap_newctx; \ static void *tdes_wrap_newctx(void *provctx) \ { \ return tdes_newctx(provctx, EVP_CIPH_WRAP_MODE, kbits, blkbits, ivbits, \ flags, PROV_CIPHER_HW_tdes_wrap_cbc()); \ } \ -static OSSL_OP_cipher_get_params_fn tdes_wrap_get_params; \ +static OSSL_FUNC_cipher_get_params_fn tdes_wrap_get_params; \ static int tdes_wrap_get_params(OSSL_PARAM params[]) \ { \ return cipher_generic_get_params(params, EVP_CIPH_WRAP_MODE, flags, \ kbits, blkbits, ivbits); \ } \ -const OSSL_DISPATCH tdes_wrap_cbc_functions[] = \ +const OSSL_DISPATCH ossl_tdes_wrap_cbc_functions[] = \ { \ { OSSL_FUNC_CIPHER_ENCRYPT_INIT, (void (*)(void)) tdes_einit }, \ { OSSL_FUNC_CIPHER_DECRYPT_INIT, (void (*)(void)) tdes_dinit }, \ @@ -201,5 +205,5 @@ const OSSL_DISPATCH tdes_wrap_cbc_functions[] = \ { 0, NULL } \ } -/* tdes_wrap_cbc_functions */ +/* ossl_tdes_wrap_cbc_functions */ IMPLEMENT_WRAP_CIPHER(TDES_WRAP_FLAGS, 64*3, 64, 0);