/*
- * 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
*/
/*
- * 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 <openssl/sha.h>
+#include <openssl/rand.h>
#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] =
{
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 */
int ret;
*outl = 0;
+ if (!ossl_prov_is_running())
+ return 0;
+
if (outsize < inl) {
PROVerr(0, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
return 0;
# 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 }, \
{ 0, NULL } \
}
-/* tdes_wrap_cbc_functions */
+/* ossl_tdes_wrap_cbc_functions */
IMPLEMENT_WRAP_CIPHER(TDES_WRAP_FLAGS, 64*3, 64, 0);