Latest update.
This commit is contained in:
@@ -138,6 +138,7 @@ static const OSSL_ALGORITHM deflt_digests[] = {
|
||||
};
|
||||
|
||||
static const OSSL_ALGORITHM_CAPABLE deflt_ciphers[] = {
|
||||
ALG("NULL", null_functions),
|
||||
ALG("AES-256-ECB", aes256ecb_functions),
|
||||
ALG("AES-192-ECB", aes192ecb_functions),
|
||||
ALG("AES-128-ECB", aes128ecb_functions),
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
$COMMON_GOAL=../../libcommon.a
|
||||
|
||||
$NULL_GOAL=../../libimplementations.a
|
||||
$AES_GOAL=../../libimplementations.a
|
||||
$TDES_1_GOAL=../../libimplementations.a
|
||||
$TDES_2_GOAL=../../libimplementations.a
|
||||
@@ -35,6 +36,9 @@ IF[{- !$disabled{des} -}]
|
||||
SOURCE[$TDES_1_GOAL]=cipher_tdes.c cipher_tdes_hw.c
|
||||
ENDIF
|
||||
|
||||
SOURCE[$NULL_GOAL]=\
|
||||
cipher_null.c
|
||||
|
||||
SOURCE[$AES_GOAL]=\
|
||||
cipher_aes.c cipher_aes_hw.c \
|
||||
cipher_aes_xts.c cipher_aes_xts_hw.c \
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* AES low level APIs are deprecated for public use, but still ok for internal
|
||||
* All low level APIs are deprecated for public use, but still ok for internal
|
||||
* use where we're using them to implement the higher level EVP interface, as is
|
||||
* the case here.
|
||||
*/
|
||||
@@ -23,7 +23,7 @@ int cipher_capable_aes_cbc_hmac_sha1(void)
|
||||
}
|
||||
#else
|
||||
|
||||
# include "crypto/rand.h"
|
||||
# include <openssl/rand.h>
|
||||
# include "crypto/evp.h"
|
||||
# include "internal/constant_time.h"
|
||||
|
||||
@@ -135,7 +135,7 @@ static size_t tls1_multi_block_encrypt(void *vctx,
|
||||
# endif
|
||||
|
||||
/* ask for IVs in bulk */
|
||||
if (rand_bytes_ex(ctx->base.libctx, (IVs = blocks[0].c), 16 * x4) <= 0)
|
||||
if (RAND_bytes_ex(ctx->base.libctx, (IVs = blocks[0].c), 16 * x4) <= 0)
|
||||
return 0;
|
||||
|
||||
mctx = (SHA1_MB_CTX *) (storage + 32 - ((size_t)storage % 32)); /* align */
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* AES low level APIs are deprecated for public use, but still ok for internal
|
||||
* All low level APIs are deprecated for public use, but still ok for internal
|
||||
* use where we're using them to implement the higher level EVP interface, as is
|
||||
* the case here.
|
||||
*/
|
||||
@@ -23,7 +23,7 @@ int cipher_capable_aes_cbc_hmac_sha256(void)
|
||||
}
|
||||
#else
|
||||
|
||||
# include "crypto/rand.h"
|
||||
# include <openssl/rand.h>
|
||||
# include "crypto/evp.h"
|
||||
# include "internal/constant_time.h"
|
||||
|
||||
@@ -139,7 +139,7 @@ static size_t tls1_multi_block_encrypt(void *vctx,
|
||||
# endif
|
||||
|
||||
/* ask for IVs in bulk */
|
||||
if (rand_bytes_ex(ctx->base.libctx, (IVs = blocks[0].c), 16 * x4) <= 0)
|
||||
if (RAND_bytes_ex(ctx->base.libctx, (IVs = blocks[0].c), 16 * x4) <= 0)
|
||||
return 0;
|
||||
|
||||
mctx = (SHA256_MB_CTX *) (storage + 32 - ((size_t)storage % 32)); /* align */
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "prov/ciphercommon.h"
|
||||
#include "cipher_des.h"
|
||||
#include "crypto/rand.h"
|
||||
#include <openssl/rand.h>
|
||||
#include "prov/implementations.h"
|
||||
#include "prov/providercommonerr.h"
|
||||
|
||||
@@ -81,7 +81,7 @@ static int des_generatekey(PROV_CIPHER_CTX *ctx, void *ptr)
|
||||
DES_cblock *deskey = ptr;
|
||||
size_t kl = ctx->keylen;
|
||||
|
||||
if (kl == 0 || rand_priv_bytes_ex(ctx->libctx, ptr, kl) <= 0)
|
||||
if (kl == 0 || RAND_priv_bytes_ex(ctx->libctx, ptr, kl) <= 0)
|
||||
return 0;
|
||||
DES_set_odd_parity(deskey);
|
||||
return 1;
|
||||
|
||||
@@ -7,6 +7,13 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/*
|
||||
* IDEA low level APIs are deprecated for public use, but still ok for internal
|
||||
* use where we're using them to implement the higher level EVP interface, as is
|
||||
* the case here.
|
||||
*/
|
||||
#include "internal/deprecated.h"
|
||||
|
||||
/* Dispatch functions for Idea cipher modes ecb, cbc, ofb, cfb */
|
||||
|
||||
#include "cipher_idea.h"
|
||||
|
||||
@@ -7,6 +7,13 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/*
|
||||
* IDEA low level APIs are deprecated for public use, but still ok for internal
|
||||
* use where we're using them to implement the higher level EVP interface, as is
|
||||
* the case here.
|
||||
*/
|
||||
#include "internal/deprecated.h"
|
||||
|
||||
#include "cipher_idea.h"
|
||||
|
||||
static int cipher_hw_idea_initkey(PROV_CIPHER_CTX *ctx,
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright 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
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/core_numbers.h>
|
||||
#include "prov/implementations.h"
|
||||
#include "prov/ciphercommon.h"
|
||||
#include "prov/providercommonerr.h"
|
||||
|
||||
static OSSL_OP_cipher_newctx_fn null_newctx;
|
||||
static void *null_newctx(void *provctx)
|
||||
{
|
||||
static int dummy = 0;
|
||||
|
||||
return &dummy;
|
||||
}
|
||||
|
||||
static OSSL_OP_cipher_freectx_fn null_freectx;
|
||||
static void null_freectx(void *vctx)
|
||||
{
|
||||
}
|
||||
|
||||
static OSSL_OP_cipher_encrypt_init_fn null_init;
|
||||
static int null_init(void *vctx, const unsigned char *key, size_t keylen,
|
||||
const unsigned char *iv, size_t ivlen)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static OSSL_OP_cipher_cipher_fn null_cipher;
|
||||
static int null_cipher(void *vctx, unsigned char *out, size_t *outl,
|
||||
size_t outsize, const unsigned char *in, size_t inl)
|
||||
{
|
||||
if (outsize < inl)
|
||||
return 0;
|
||||
if (in != out)
|
||||
memcpy(out, in, inl);
|
||||
*outl = inl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static OSSL_OP_cipher_final_fn null_final;
|
||||
static int null_final(void *vctx, unsigned char *out, size_t *outl,
|
||||
size_t outsize)
|
||||
{
|
||||
*outl = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static OSSL_OP_cipher_get_params_fn null_get_params;
|
||||
static int null_get_params(OSSL_PARAM params[])
|
||||
{
|
||||
return cipher_generic_get_params(params, 0, 0, 0, 8, 0);
|
||||
}
|
||||
|
||||
static const OSSL_PARAM null_known_gettable_ctx_params[] = {
|
||||
OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_KEYLEN, NULL),
|
||||
OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_IVLEN, NULL),
|
||||
OSSL_PARAM_END
|
||||
};
|
||||
|
||||
static OSSL_OP_cipher_gettable_ctx_params_fn null_gettable_ctx_params;
|
||||
static const OSSL_PARAM *null_gettable_ctx_params(void)
|
||||
{
|
||||
return null_known_gettable_ctx_params;
|
||||
}
|
||||
|
||||
static OSSL_OP_cipher_get_ctx_params_fn null_get_ctx_params;
|
||||
static int null_get_ctx_params(void *vctx, OSSL_PARAM params[])
|
||||
{
|
||||
OSSL_PARAM *p;
|
||||
|
||||
p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_IVLEN);
|
||||
if (p != NULL && !OSSL_PARAM_set_size_t(p, 0)) {
|
||||
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_KEYLEN);
|
||||
if (p != NULL && !OSSL_PARAM_set_size_t(p, 0)) {
|
||||
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
const OSSL_DISPATCH null_functions[] = {
|
||||
{ OSSL_FUNC_CIPHER_NEWCTX,
|
||||
(void (*)(void)) null_newctx },
|
||||
{ OSSL_FUNC_CIPHER_FREECTX, (void (*)(void)) null_freectx },
|
||||
{ OSSL_FUNC_CIPHER_DUPCTX, (void (*)(void)) null_newctx },
|
||||
{ OSSL_FUNC_CIPHER_ENCRYPT_INIT, (void (*)(void))null_init },
|
||||
{ OSSL_FUNC_CIPHER_DECRYPT_INIT, (void (*)(void))null_init },
|
||||
{ OSSL_FUNC_CIPHER_UPDATE, (void (*)(void))null_cipher },
|
||||
{ OSSL_FUNC_CIPHER_FINAL, (void (*)(void))null_final },
|
||||
{ OSSL_FUNC_CIPHER_CIPHER, (void (*)(void))null_cipher },
|
||||
{ OSSL_FUNC_CIPHER_GET_PARAMS, (void (*)(void)) null_get_params },
|
||||
{ OSSL_FUNC_CIPHER_GETTABLE_PARAMS,
|
||||
(void (*)(void))cipher_generic_gettable_params },
|
||||
{ OSSL_FUNC_CIPHER_GET_CTX_PARAMS, (void (*)(void))null_get_ctx_params },
|
||||
{ OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS,
|
||||
(void (*)(void))null_gettable_ctx_params },
|
||||
{ 0, NULL }
|
||||
};
|
||||
@@ -10,8 +10,8 @@
|
||||
/* Dispatch functions for RC4_HMAC_MD5 cipher */
|
||||
|
||||
/*
|
||||
* RC4 low level APIs are deprecated for public use, but still ok for internal
|
||||
* use.
|
||||
* MD5 and RC4 low level APIs are deprecated for public use, but still ok for
|
||||
* internal use.
|
||||
*/
|
||||
#include "internal/deprecated.h"
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
/* RC4_HMAC_MD5 cipher implementation */
|
||||
|
||||
/*
|
||||
* RC4 low level APIs are deprecated for public use, but still ok for internal
|
||||
* use.
|
||||
* MD5 and RC4 low level APIs are deprecated for public use, but still ok for
|
||||
* internal use.
|
||||
*/
|
||||
#include "internal/deprecated.h"
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "prov/ciphercommon.h"
|
||||
#include "cipher_tdes.h"
|
||||
#include "crypto/rand.h"
|
||||
#include <openssl/rand.h>
|
||||
#include "prov/implementations.h"
|
||||
#include "prov/providercommonerr.h"
|
||||
|
||||
@@ -71,7 +71,7 @@ static int tdes_generatekey(PROV_CIPHER_CTX *ctx, void *ptr)
|
||||
DES_cblock *deskey = ptr;
|
||||
size_t kl = ctx->keylen;
|
||||
|
||||
if (kl == 0 || rand_priv_bytes_ex(ctx->libctx, ptr, kl) <= 0)
|
||||
if (kl == 0 || RAND_priv_bytes_ex(ctx->libctx, ptr, kl) <= 0)
|
||||
return 0;
|
||||
DES_set_odd_parity(deskey);
|
||||
if (kl >= 16)
|
||||
|
||||
@@ -7,10 +7,16 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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/providercommonerr.h"
|
||||
|
||||
@@ -92,7 +98,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 */
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "prov/ciphercommon.h"
|
||||
#include "prov/ciphercommon_gcm.h"
|
||||
#include "prov/providercommonerr.h"
|
||||
#include "crypto/rand.h"
|
||||
#include <openssl/rand.h>
|
||||
#include "prov/provider_ctx.h"
|
||||
|
||||
static int gcm_tls_init(PROV_GCM_CTX *dat, unsigned char *aad, size_t aad_len);
|
||||
@@ -338,7 +338,7 @@ static int gcm_iv_generate(PROV_GCM_CTX *ctx, int offset)
|
||||
return 0;
|
||||
|
||||
/* Use DRBG to generate random iv */
|
||||
if (rand_bytes_ex(ctx->libctx, ctx->iv + offset, sz) <= 0)
|
||||
if (RAND_bytes_ex(ctx->libctx, ctx->iv + offset, sz) <= 0)
|
||||
return 0;
|
||||
ctx->iv_state = IV_STATE_BUFFERED;
|
||||
ctx->iv_gen_rand = 1;
|
||||
@@ -452,7 +452,7 @@ static int gcm_tls_iv_set_fixed(PROV_GCM_CTX *ctx, unsigned char *iv,
|
||||
if (len > 0)
|
||||
memcpy(ctx->iv, iv, len);
|
||||
if (ctx->enc
|
||||
&& rand_bytes_ex(ctx->libctx, ctx->iv + len, ctx->ivlen - len) <= 0)
|
||||
&& RAND_bytes_ex(ctx->libctx, ctx->iv + len, ctx->ivlen - len) <= 0)
|
||||
return 0;
|
||||
ctx->iv_gen = 1;
|
||||
ctx->iv_state = IV_STATE_BUFFERED;
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/*
|
||||
* MD5 low level APIs are deprecated for public use, but still ok for
|
||||
* internal use.
|
||||
*/
|
||||
#include "internal/deprecated.h"
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/md5.h>
|
||||
#include "prov/digestcommon.h"
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/*
|
||||
* MD5 and SHA-1 low level APIs are deprecated for public use, but still ok for
|
||||
* internal use.
|
||||
*/
|
||||
#include "internal/deprecated.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/*
|
||||
* SHA low level APIs are deprecated for public use, but still ok for
|
||||
* internal use.
|
||||
*/
|
||||
#include "internal/deprecated.h"
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/core_numbers.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
@@ -35,6 +35,7 @@ extern const OSSL_DISPATCH wp_functions[];
|
||||
extern const OSSL_DISPATCH ripemd160_functions[];
|
||||
|
||||
/* Ciphers */
|
||||
extern const OSSL_DISPATCH null_functions[];
|
||||
extern const OSSL_DISPATCH aes256ecb_functions[];
|
||||
extern const OSSL_DISPATCH aes192ecb_functions[];
|
||||
extern const OSSL_DISPATCH aes128ecb_functions[];
|
||||
|
||||
Reference in New Issue
Block a user