Latest update.
This commit is contained in:
@@ -216,7 +216,12 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it,
|
||||
goto err;
|
||||
}
|
||||
inl = buf_len;
|
||||
outll = outl = EVP_PKEY_size(pkey);
|
||||
if (!EVP_DigestSign(ctx, NULL, &outll, buf_in, inl)) {
|
||||
outl = 0;
|
||||
ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ERR_R_EVP_LIB);
|
||||
goto err;
|
||||
}
|
||||
outl = outll;
|
||||
buf_out = OPENSSL_malloc(outll);
|
||||
if (buf_in == NULL || buf_out == NULL) {
|
||||
outl = 0;
|
||||
|
||||
+4
-4
@@ -47,8 +47,8 @@ static int bnrand(BNRAND_FLAG flag, BIGNUM *rnd, int bits, int top, int bottom,
|
||||
}
|
||||
|
||||
/* make a random number and set the top and bottom bits */
|
||||
b = flag == NORMAL ? rand_bytes_ex(libctx, buf, bytes)
|
||||
: rand_priv_bytes_ex(libctx, buf, bytes);
|
||||
b = flag == NORMAL ? RAND_bytes_ex(libctx, buf, bytes)
|
||||
: RAND_priv_bytes_ex(libctx, buf, bytes);
|
||||
if (b <= 0)
|
||||
goto err;
|
||||
|
||||
@@ -60,7 +60,7 @@ static int bnrand(BNRAND_FLAG flag, BIGNUM *rnd, int bits, int top, int bottom,
|
||||
unsigned char c;
|
||||
|
||||
for (i = 0; i < bytes; i++) {
|
||||
if (rand_bytes_ex(libctx, &c, 1) <= 0)
|
||||
if (RAND_bytes_ex(libctx, &c, 1) <= 0)
|
||||
goto err;
|
||||
if (c >= 128 && i > 0)
|
||||
buf[i] = buf[i - 1];
|
||||
@@ -280,7 +280,7 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
|
||||
goto err;
|
||||
}
|
||||
for (done = 0; done < num_k_bytes;) {
|
||||
if (!rand_priv_bytes_ex(libctx, random_bytes, sizeof(random_bytes)))
|
||||
if (!RAND_priv_bytes_ex(libctx, random_bytes, sizeof(random_bytes)))
|
||||
goto err;
|
||||
|
||||
if (!EVP_DigestInit_ex(mdctx, md, NULL)
|
||||
|
||||
+2
-2
@@ -76,14 +76,14 @@ static int ct_v1_log_id_from_pkey(EVP_PKEY *pkey,
|
||||
int ret = 0;
|
||||
unsigned char *pkey_der = NULL;
|
||||
int pkey_der_len = i2d_PUBKEY(pkey, &pkey_der);
|
||||
unsigned int len;
|
||||
|
||||
if (pkey_der_len <= 0) {
|
||||
CTerr(CT_F_CT_V1_LOG_ID_FROM_PKEY, CT_R_LOG_KEY_INVALID);
|
||||
goto err;
|
||||
}
|
||||
|
||||
SHA256(pkey_der, pkey_der_len, log_id);
|
||||
ret = 1;
|
||||
ret = EVP_Digest(pkey_der, pkey_der_len, log_id, &len, EVP_sha256(), NULL);
|
||||
err:
|
||||
OPENSSL_free(pkey_der);
|
||||
return ret;
|
||||
|
||||
+50
-23
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include "ec_local.h"
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
#if defined(X25519_ASM) && (defined(__x86_64) || defined(__x86_64__) || \
|
||||
@@ -5436,39 +5437,50 @@ int ED25519_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len,
|
||||
uint8_t nonce[SHA512_DIGEST_LENGTH];
|
||||
ge_p3 R;
|
||||
uint8_t hram[SHA512_DIGEST_LENGTH];
|
||||
SHA512_CTX hash_ctx;
|
||||
EVP_MD *sha512 = EVP_MD_fetch(NULL, SN_sha512, NULL);
|
||||
EVP_MD_CTX *hash_ctx = EVP_MD_CTX_new();
|
||||
unsigned int sz;
|
||||
int res = 0;
|
||||
|
||||
SHA512_Init(&hash_ctx);
|
||||
SHA512_Update(&hash_ctx, private_key, 32);
|
||||
SHA512_Final(az, &hash_ctx);
|
||||
if (sha512 == NULL || hash_ctx == NULL)
|
||||
goto err;
|
||||
|
||||
if (!EVP_DigestInit_ex(hash_ctx, sha512, NULL)
|
||||
|| !EVP_DigestUpdate(hash_ctx, private_key, 32)
|
||||
|| !EVP_DigestFinal_ex(hash_ctx, az, &sz))
|
||||
goto err;
|
||||
|
||||
az[0] &= 248;
|
||||
az[31] &= 63;
|
||||
az[31] |= 64;
|
||||
|
||||
SHA512_Init(&hash_ctx);
|
||||
SHA512_Update(&hash_ctx, az + 32, 32);
|
||||
SHA512_Update(&hash_ctx, message, message_len);
|
||||
SHA512_Final(nonce, &hash_ctx);
|
||||
if (!EVP_DigestInit_ex(hash_ctx, sha512, NULL)
|
||||
|| !EVP_DigestUpdate(hash_ctx, az + 32, 32)
|
||||
|| !EVP_DigestUpdate(hash_ctx, message, message_len)
|
||||
|| !EVP_DigestFinal_ex(hash_ctx, nonce, &sz))
|
||||
goto err;
|
||||
|
||||
x25519_sc_reduce(nonce);
|
||||
ge_scalarmult_base(&R, nonce);
|
||||
ge_p3_tobytes(out_sig, &R);
|
||||
|
||||
SHA512_Init(&hash_ctx);
|
||||
SHA512_Update(&hash_ctx, out_sig, 32);
|
||||
SHA512_Update(&hash_ctx, public_key, 32);
|
||||
SHA512_Update(&hash_ctx, message, message_len);
|
||||
SHA512_Final(hram, &hash_ctx);
|
||||
if (!EVP_DigestInit_ex(hash_ctx, sha512, NULL)
|
||||
|| !EVP_DigestUpdate(hash_ctx, out_sig, 32)
|
||||
|| !EVP_DigestUpdate(hash_ctx, public_key, 32)
|
||||
|| !EVP_DigestUpdate(hash_ctx, message, message_len)
|
||||
|| !EVP_DigestFinal_ex(hash_ctx, hram, &sz))
|
||||
goto err;
|
||||
|
||||
x25519_sc_reduce(hram);
|
||||
sc_muladd(out_sig + 32, hram, az, nonce);
|
||||
|
||||
OPENSSL_cleanse(&hash_ctx, sizeof(hash_ctx));
|
||||
res = 1;
|
||||
err:
|
||||
OPENSSL_cleanse(nonce, sizeof(nonce));
|
||||
OPENSSL_cleanse(az, sizeof(az));
|
||||
|
||||
return 1;
|
||||
EVP_MD_free(sha512);
|
||||
EVP_MD_CTX_free(hash_ctx);
|
||||
return res;
|
||||
}
|
||||
|
||||
static const char allzeroes[15];
|
||||
@@ -5479,7 +5491,10 @@ int ED25519_verify(const uint8_t *message, size_t message_len,
|
||||
int i;
|
||||
ge_p3 A;
|
||||
const uint8_t *r, *s;
|
||||
SHA512_CTX hash_ctx;
|
||||
EVP_MD *sha512;
|
||||
EVP_MD_CTX *hash_ctx = NULL;
|
||||
unsigned int sz;
|
||||
int res = 0;
|
||||
ge_p2 R;
|
||||
uint8_t rcheck[32];
|
||||
uint8_t h[SHA512_DIGEST_LENGTH];
|
||||
@@ -5526,11 +5541,19 @@ int ED25519_verify(const uint8_t *message, size_t message_len,
|
||||
fe_neg(A.X, A.X);
|
||||
fe_neg(A.T, A.T);
|
||||
|
||||
SHA512_Init(&hash_ctx);
|
||||
SHA512_Update(&hash_ctx, r, 32);
|
||||
SHA512_Update(&hash_ctx, public_key, 32);
|
||||
SHA512_Update(&hash_ctx, message, message_len);
|
||||
SHA512_Final(h, &hash_ctx);
|
||||
sha512 = EVP_MD_fetch(NULL, SN_sha512, NULL);
|
||||
if (sha512 == NULL)
|
||||
return 0;
|
||||
hash_ctx = EVP_MD_CTX_new();
|
||||
if (hash_ctx == NULL)
|
||||
goto err;
|
||||
|
||||
if (!EVP_DigestInit_ex(hash_ctx, sha512, NULL)
|
||||
|| !EVP_DigestUpdate(hash_ctx, r, 32)
|
||||
|| !EVP_DigestUpdate(hash_ctx, public_key, 32)
|
||||
|| !EVP_DigestUpdate(hash_ctx, message, message_len)
|
||||
|| !EVP_DigestFinal_ex(hash_ctx, h, &sz))
|
||||
goto err;
|
||||
|
||||
x25519_sc_reduce(h);
|
||||
|
||||
@@ -5538,7 +5561,11 @@ int ED25519_verify(const uint8_t *message, size_t message_len,
|
||||
|
||||
ge_tobytes(rcheck, &R);
|
||||
|
||||
return CRYPTO_memcmp(rcheck, r, sizeof(rcheck)) == 0;
|
||||
res = CRYPTO_memcmp(rcheck, r, sizeof(rcheck)) == 0;
|
||||
err:
|
||||
EVP_MD_free(sha512);
|
||||
EVP_MD_CTX_free(hash_ctx);
|
||||
return res;
|
||||
}
|
||||
|
||||
void ED25519_public_from_private(uint8_t out_public_key[32],
|
||||
|
||||
@@ -1156,6 +1156,7 @@ static int s390x_pkey_ecd_keygen25519(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
unsigned char x_dst[32], buff[SHA512_DIGEST_LENGTH];
|
||||
ECX_KEY *key;
|
||||
unsigned char *privkey = NULL, *pubkey;
|
||||
unsigned int sz;
|
||||
|
||||
key = OPENSSL_zalloc(sizeof(*key));
|
||||
if (key == NULL) {
|
||||
@@ -1174,7 +1175,9 @@ static int s390x_pkey_ecd_keygen25519(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
if (RAND_priv_bytes(privkey, ED25519_KEYLEN) <= 0)
|
||||
goto err;
|
||||
|
||||
SHA512(privkey, 32, buff);
|
||||
if (!EVP_Digest(privkey, 32, buff, &sz, EVP_sha512(), NULL))
|
||||
goto err;
|
||||
|
||||
buff[0] &= 248;
|
||||
buff[31] &= 63;
|
||||
buff[31] |= 64;
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* RC4 low level APIs are deprecated for public use, but still ok for internal
|
||||
* use.
|
||||
* RC4 and SHA-1 low level APIs are deprecated for public use, but still ok
|
||||
* for internal use.
|
||||
*/
|
||||
#include "internal/deprecated.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 <stdio.h>
|
||||
#include "internal/cryptlib.h"
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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"
|
||||
|
||||
|
||||
@@ -142,6 +142,7 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
|
||||
|
||||
if (tmpcipher->prov == NULL) {
|
||||
switch(tmpcipher->nid) {
|
||||
case NID_undef:
|
||||
case NID_aes_256_ecb:
|
||||
case NID_aes_192_ecb:
|
||||
case NID_aes_128_ecb:
|
||||
@@ -326,7 +327,10 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
|
||||
return 0;
|
||||
#else
|
||||
EVP_CIPHER *provciph =
|
||||
EVP_CIPHER_fetch(NULL, OBJ_nid2sn(cipher->nid), "");
|
||||
EVP_CIPHER_fetch(NULL,
|
||||
cipher->nid == NID_undef ? "NULL"
|
||||
: OBJ_nid2sn(cipher->nid),
|
||||
"");
|
||||
|
||||
if (provciph == NULL) {
|
||||
EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_INITIALIZATION_ERROR);
|
||||
|
||||
@@ -281,3 +281,6 @@ void evp_names_do_all(OSSL_PROVIDER *prov, int number,
|
||||
void (*fn)(const char *name, void *data),
|
||||
void *data);
|
||||
int evp_cipher_cache_constants(EVP_CIPHER *cipher);
|
||||
void *evp_pkey_make_provided(EVP_PKEY *pk, OPENSSL_CTX *libctx,
|
||||
EVP_KEYMGMT **keymgmt, const char *propquery,
|
||||
int domainparams);
|
||||
+30
-32
@@ -164,6 +164,8 @@ int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx)
|
||||
int ret;
|
||||
void *provkey = NULL;
|
||||
EVP_KEYEXCH *exchange = NULL;
|
||||
EVP_KEYMGMT *tmp_keymgmt = NULL;
|
||||
const char *supported_exch = NULL;
|
||||
|
||||
if (ctx == NULL) {
|
||||
EVPerr(0, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
||||
@@ -176,33 +178,36 @@ int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx)
|
||||
if (ctx->engine != NULL || ctx->keytype == NULL)
|
||||
goto legacy;
|
||||
|
||||
if (ctx->keymgmt == NULL)
|
||||
ctx->keymgmt =
|
||||
EVP_KEYMGMT_fetch(ctx->libctx, ctx->keytype, ctx->propquery);
|
||||
if (ctx->keymgmt != NULL) {
|
||||
const char *supported_exch = NULL;
|
||||
|
||||
if (ctx->keymgmt->query_operation_name != NULL)
|
||||
supported_exch =
|
||||
ctx->keymgmt->query_operation_name(OSSL_OP_KEYEXCH);
|
||||
|
||||
/*
|
||||
* If we didn't get a supported exch, assume there is one with the
|
||||
* same name as the key type.
|
||||
*/
|
||||
if (supported_exch == NULL)
|
||||
supported_exch = ctx->keytype;
|
||||
|
||||
/*
|
||||
* Because we cleared out old ops, we shouldn't need to worry about
|
||||
* checking if exchange is already there.
|
||||
*/
|
||||
exchange =
|
||||
EVP_KEYEXCH_fetch(ctx->libctx, supported_exch, ctx->propquery);
|
||||
/* Ensure that the key is provided. If not, go legacy */
|
||||
tmp_keymgmt = ctx->keymgmt;
|
||||
provkey = evp_pkey_make_provided(ctx->pkey, ctx->libctx,
|
||||
&tmp_keymgmt, ctx->propquery, 0);
|
||||
if (provkey == NULL)
|
||||
goto legacy;
|
||||
if (!EVP_KEYMGMT_up_ref(tmp_keymgmt)) {
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
goto err;
|
||||
}
|
||||
EVP_KEYMGMT_free(ctx->keymgmt);
|
||||
ctx->keymgmt = tmp_keymgmt;
|
||||
|
||||
if (ctx->keymgmt == NULL
|
||||
|| exchange == NULL
|
||||
if (ctx->keymgmt->query_operation_name != NULL)
|
||||
supported_exch = ctx->keymgmt->query_operation_name(OSSL_OP_KEYEXCH);
|
||||
|
||||
/*
|
||||
* If we didn't get a supported exch, assume there is one with the
|
||||
* same name as the key type.
|
||||
*/
|
||||
if (supported_exch == NULL)
|
||||
supported_exch = ctx->keytype;
|
||||
|
||||
/*
|
||||
* Because we cleared out old ops, we shouldn't need to worry about
|
||||
* checking if exchange is already there.
|
||||
*/
|
||||
exchange = EVP_KEYEXCH_fetch(ctx->libctx, supported_exch, ctx->propquery);
|
||||
|
||||
if (exchange == NULL
|
||||
|| (EVP_KEYMGMT_provider(ctx->keymgmt)
|
||||
!= EVP_KEYEXCH_provider(exchange))) {
|
||||
/*
|
||||
@@ -217,13 +222,6 @@ int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx)
|
||||
|
||||
|
||||
ctx->op.kex.exchange = exchange;
|
||||
|
||||
if (ctx->pkey != NULL) {
|
||||
provkey = evp_keymgmt_export_to_provider(ctx->pkey, ctx->keymgmt, 0);
|
||||
/* If export failed, legacy may be able to pick it up */
|
||||
if (provkey == NULL)
|
||||
goto legacy;
|
||||
}
|
||||
ctx->op.kex.exchprovctx = exchange->newctx(ossl_provider_ctx(exchange->prov));
|
||||
if (ctx->op.kex.exchprovctx == NULL) {
|
||||
/* The provider key can stay in the cache */
|
||||
|
||||
@@ -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/md5.h>
|
||||
#include "crypto/evp.h"
|
||||
#include "legacy_meth.h"
|
||||
|
||||
@@ -7,6 +7,13 @@
|
||||
* 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. The prov/md5_sha1.h include requires this, but this must
|
||||
* be the first include loaded.
|
||||
*/
|
||||
#include "internal/deprecated.h"
|
||||
|
||||
#include "crypto/evp.h"
|
||||
#include "prov/md5_sha1.h" /* diverse MD5_SHA1 macros */
|
||||
#include "legacy_meth.h"
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/*
|
||||
* All SHA low level APIs are deprecated for public use, but still ok for
|
||||
* internal use.
|
||||
*/
|
||||
#include "internal/deprecated.h"
|
||||
|
||||
#include <openssl/sha.h> /* diverse SHA macros */
|
||||
#include "internal/sha3.h" /* KECCAK1600_WIDTH */
|
||||
#include "crypto/evp.h"
|
||||
|
||||
+32
-33
@@ -31,6 +31,8 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
|
||||
{
|
||||
EVP_PKEY_CTX *locpctx = NULL;
|
||||
EVP_SIGNATURE *signature = NULL;
|
||||
EVP_KEYMGMT *tmp_keymgmt = NULL;
|
||||
const char *supported_sig = NULL;
|
||||
void *provkey = NULL;
|
||||
int ret;
|
||||
|
||||
@@ -71,33 +73,38 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
|
||||
}
|
||||
}
|
||||
|
||||
if (locpctx->keymgmt == NULL)
|
||||
locpctx->keymgmt = EVP_KEYMGMT_fetch(locpctx->libctx, locpctx->keytype,
|
||||
locpctx->propquery);
|
||||
if (locpctx->keymgmt != NULL) {
|
||||
const char *supported_sig = NULL;
|
||||
|
||||
if (locpctx->keymgmt->query_operation_name != NULL)
|
||||
supported_sig =
|
||||
locpctx->keymgmt->query_operation_name(OSSL_OP_SIGNATURE);
|
||||
|
||||
/*
|
||||
* If we didn't get a supported sig, assume there is one with the
|
||||
* same name as the key type.
|
||||
*/
|
||||
if (supported_sig == NULL)
|
||||
supported_sig = locpctx->keytype;
|
||||
|
||||
/*
|
||||
* Because we cleared out old ops, we shouldn't need to worry about
|
||||
* checking if signature is already there.
|
||||
*/
|
||||
signature = EVP_SIGNATURE_fetch(locpctx->libctx, supported_sig,
|
||||
locpctx->propquery);
|
||||
/* Ensure that the key is provided. If not, go legacy */
|
||||
tmp_keymgmt = locpctx->keymgmt;
|
||||
provkey = evp_pkey_make_provided(locpctx->pkey, locpctx->libctx,
|
||||
&tmp_keymgmt, locpctx->propquery, 0);
|
||||
if (provkey == NULL)
|
||||
goto legacy;
|
||||
if (!EVP_KEYMGMT_up_ref(tmp_keymgmt)) {
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
goto err;
|
||||
}
|
||||
EVP_KEYMGMT_free(locpctx->keymgmt);
|
||||
locpctx->keymgmt = tmp_keymgmt;
|
||||
|
||||
if (locpctx->keymgmt == NULL
|
||||
|| signature == NULL
|
||||
if (locpctx->keymgmt->query_operation_name != NULL)
|
||||
supported_sig =
|
||||
locpctx->keymgmt->query_operation_name(OSSL_OP_SIGNATURE);
|
||||
|
||||
/*
|
||||
* If we didn't get a supported sig, assume there is one with the
|
||||
* same name as the key type.
|
||||
*/
|
||||
if (supported_sig == NULL)
|
||||
supported_sig = locpctx->keytype;
|
||||
|
||||
/*
|
||||
* Because we cleared out old ops, we shouldn't need to worry about
|
||||
* checking if signature is already there.
|
||||
*/
|
||||
signature = EVP_SIGNATURE_fetch(locpctx->libctx, supported_sig,
|
||||
locpctx->propquery);
|
||||
|
||||
if (signature == NULL
|
||||
|| (EVP_KEYMGMT_provider(locpctx->keymgmt)
|
||||
!= EVP_SIGNATURE_provider(signature))) {
|
||||
/*
|
||||
@@ -113,16 +120,8 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
|
||||
/* No more legacy from here down to legacy: */
|
||||
|
||||
locpctx->op.sig.signature = signature;
|
||||
|
||||
provkey =
|
||||
evp_keymgmt_export_to_provider(locpctx->pkey, locpctx->keymgmt, 0);
|
||||
/* If export failed, legacy may be able to pick it up */
|
||||
if (provkey == NULL)
|
||||
goto legacy;
|
||||
|
||||
locpctx->operation = ver ? EVP_PKEY_OP_VERIFYCTX
|
||||
: EVP_PKEY_OP_SIGNCTX;
|
||||
|
||||
locpctx->op.sig.sigprovctx
|
||||
= signature->newctx(ossl_provider_ctx(signature->prov));
|
||||
if (locpctx->op.sig.sigprovctx == NULL) {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "crypto/asn1.h"
|
||||
#include "crypto/evp.h"
|
||||
#include "internal/provider.h"
|
||||
#include "evp_local.h"
|
||||
|
||||
static void evp_pkey_free_it(EVP_PKEY *key);
|
||||
|
||||
@@ -827,3 +828,47 @@ int EVP_PKEY_size(const EVP_PKEY *pkey)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *evp_pkey_make_provided(EVP_PKEY *pk, OPENSSL_CTX *libctx,
|
||||
EVP_KEYMGMT **keymgmt, const char *propquery,
|
||||
int domainparams)
|
||||
{
|
||||
EVP_KEYMGMT *allocated_keymgmt = NULL;
|
||||
EVP_KEYMGMT *tmp_keymgmt = NULL;
|
||||
void *provdata = NULL;
|
||||
|
||||
if (pk == NULL)
|
||||
return NULL;
|
||||
|
||||
if (keymgmt != NULL) {
|
||||
tmp_keymgmt = *keymgmt;
|
||||
*keymgmt = NULL;
|
||||
}
|
||||
|
||||
if (tmp_keymgmt == NULL) {
|
||||
EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new_from_pkey(libctx, pk);
|
||||
|
||||
if (ctx != NULL && ctx->keytype != NULL)
|
||||
tmp_keymgmt = allocated_keymgmt =
|
||||
EVP_KEYMGMT_fetch(ctx->libctx, ctx->keytype, propquery);
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
}
|
||||
|
||||
if (tmp_keymgmt != NULL)
|
||||
provdata =
|
||||
evp_keymgmt_export_to_provider(pk, tmp_keymgmt, domainparams);
|
||||
|
||||
/*
|
||||
* If nothing was exported, |tmp_keymgmt| might point at a freed
|
||||
* EVP_KEYMGMT, so we clear it to be safe. It shouldn't be useful for
|
||||
* the caller either way in that case.
|
||||
*/
|
||||
if (provdata == NULL)
|
||||
tmp_keymgmt = NULL;
|
||||
|
||||
if (keymgmt != NULL)
|
||||
*keymgmt = tmp_keymgmt;
|
||||
|
||||
EVP_KEYMGMT_free(allocated_keymgmt);
|
||||
return provdata;
|
||||
}
|
||||
+27
-30
@@ -21,6 +21,8 @@ static int evp_pkey_asym_cipher_init(EVP_PKEY_CTX *ctx, int operation)
|
||||
int ret = 0;
|
||||
void *provkey = NULL;
|
||||
EVP_ASYM_CIPHER *cipher = NULL;
|
||||
EVP_KEYMGMT *tmp_keymgmt = NULL;
|
||||
const char *supported_ciph = NULL;
|
||||
|
||||
if (ctx == NULL) {
|
||||
EVPerr(0, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
||||
@@ -33,33 +35,35 @@ static int evp_pkey_asym_cipher_init(EVP_PKEY_CTX *ctx, int operation)
|
||||
if (ctx->keytype == NULL || ctx->engine != NULL)
|
||||
goto legacy;
|
||||
|
||||
if (ctx->keymgmt == NULL)
|
||||
ctx->keymgmt =
|
||||
EVP_KEYMGMT_fetch(ctx->libctx, ctx->keytype, ctx->propquery);
|
||||
if (ctx->keymgmt != NULL) {
|
||||
const char *supported_ciph = NULL;
|
||||
/* Ensure that the key is provided. If not, go legacy */
|
||||
tmp_keymgmt = ctx->keymgmt;
|
||||
provkey = evp_pkey_make_provided(ctx->pkey, ctx->libctx,
|
||||
&tmp_keymgmt, ctx->propquery, 0);
|
||||
if (provkey == NULL)
|
||||
goto legacy;
|
||||
EVP_KEYMGMT_up_ref(tmp_keymgmt);
|
||||
EVP_KEYMGMT_free(ctx->keymgmt);
|
||||
ctx->keymgmt = tmp_keymgmt;
|
||||
|
||||
if (ctx->keymgmt->query_operation_name != NULL)
|
||||
supported_ciph =
|
||||
ctx->keymgmt->query_operation_name(OSSL_OP_ASYM_CIPHER);
|
||||
if (ctx->keymgmt->query_operation_name != NULL)
|
||||
supported_ciph =
|
||||
ctx->keymgmt->query_operation_name(OSSL_OP_ASYM_CIPHER);
|
||||
|
||||
/*
|
||||
* If we didn't get a supported ciph, assume there is one with the
|
||||
* same name as the key type.
|
||||
*/
|
||||
if (supported_ciph == NULL)
|
||||
supported_ciph = ctx->keytype;
|
||||
/*
|
||||
* If we didn't get a supported ciph, assume there is one with the
|
||||
* same name as the key type.
|
||||
*/
|
||||
if (supported_ciph == NULL)
|
||||
supported_ciph = ctx->keytype;
|
||||
|
||||
/*
|
||||
* Because we cleared out old ops, we shouldn't need to worry about
|
||||
* checking if cipher is already there.
|
||||
*/
|
||||
cipher =
|
||||
EVP_ASYM_CIPHER_fetch(ctx->libctx, supported_ciph, ctx->propquery);
|
||||
}
|
||||
/*
|
||||
* Because we cleared out old ops, we shouldn't need to worry about
|
||||
* checking if cipher is already there.
|
||||
*/
|
||||
cipher =
|
||||
EVP_ASYM_CIPHER_fetch(ctx->libctx, supported_ciph, ctx->propquery);
|
||||
|
||||
if (ctx->keymgmt == NULL
|
||||
|| cipher == NULL
|
||||
if (cipher == NULL
|
||||
|| (EVP_KEYMGMT_provider(ctx->keymgmt)
|
||||
!= EVP_ASYM_CIPHER_provider(cipher))) {
|
||||
/*
|
||||
@@ -73,13 +77,6 @@ static int evp_pkey_asym_cipher_init(EVP_PKEY_CTX *ctx, int operation)
|
||||
}
|
||||
|
||||
ctx->op.ciph.cipher = cipher;
|
||||
|
||||
if (ctx->pkey != NULL) {
|
||||
provkey = evp_keymgmt_export_to_provider(ctx->pkey, ctx->keymgmt, 0);
|
||||
/* If export failed, legacy may be able to pick it up */
|
||||
if (provkey == NULL)
|
||||
goto legacy;
|
||||
}
|
||||
ctx->op.ciph.ciphprovctx = cipher->newctx(ossl_provider_ctx(cipher->prov));
|
||||
if (ctx->op.ciph.ciphprovctx == NULL) {
|
||||
/* The provider key can stay in the cache */
|
||||
|
||||
+31
-33
@@ -322,6 +322,8 @@ static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, int operation)
|
||||
int ret = 0;
|
||||
void *provkey = NULL;
|
||||
EVP_SIGNATURE *signature = NULL;
|
||||
EVP_KEYMGMT *tmp_keymgmt = NULL;
|
||||
const char *supported_sig = NULL;
|
||||
|
||||
if (ctx == NULL) {
|
||||
EVPerr(0, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
||||
@@ -334,33 +336,37 @@ static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, int operation)
|
||||
if (ctx->keytype == NULL)
|
||||
goto legacy;
|
||||
|
||||
if (ctx->keymgmt == NULL)
|
||||
ctx->keymgmt =
|
||||
EVP_KEYMGMT_fetch(ctx->libctx, ctx->keytype, ctx->propquery);
|
||||
if (ctx->keymgmt != NULL) {
|
||||
const char *supported_sig = NULL;
|
||||
|
||||
if (ctx->keymgmt->query_operation_name != NULL)
|
||||
supported_sig =
|
||||
ctx->keymgmt->query_operation_name(OSSL_OP_SIGNATURE);
|
||||
|
||||
/*
|
||||
* If we didn't get a supported sig, assume there is one with the
|
||||
* same name as the key type.
|
||||
*/
|
||||
if (supported_sig == NULL)
|
||||
supported_sig = ctx->keytype;
|
||||
|
||||
/*
|
||||
* Because we cleared out old ops, we shouldn't need to worry about
|
||||
* checking if signature is already there.
|
||||
*/
|
||||
signature =
|
||||
EVP_SIGNATURE_fetch(ctx->libctx, supported_sig, ctx->propquery);
|
||||
/* Ensure that the key is provided. If not, go legacy */
|
||||
tmp_keymgmt = ctx->keymgmt;
|
||||
provkey = evp_pkey_make_provided(ctx->pkey, ctx->libctx,
|
||||
&tmp_keymgmt, ctx->propquery, 0);
|
||||
if (provkey == NULL)
|
||||
goto legacy;
|
||||
if (!EVP_KEYMGMT_up_ref(tmp_keymgmt)) {
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
goto err;
|
||||
}
|
||||
EVP_KEYMGMT_free(ctx->keymgmt);
|
||||
ctx->keymgmt = tmp_keymgmt;
|
||||
|
||||
if (ctx->keymgmt == NULL
|
||||
|| signature == NULL
|
||||
if (ctx->keymgmt->query_operation_name != NULL)
|
||||
supported_sig = ctx->keymgmt->query_operation_name(OSSL_OP_SIGNATURE);
|
||||
|
||||
/*
|
||||
* If we didn't get a supported sig, assume there is one with the
|
||||
* same name as the key type.
|
||||
*/
|
||||
if (supported_sig == NULL)
|
||||
supported_sig = ctx->keytype;
|
||||
|
||||
/*
|
||||
* Because we cleared out old ops, we shouldn't need to worry about
|
||||
* checking if signature is already there.
|
||||
*/
|
||||
signature =
|
||||
EVP_SIGNATURE_fetch(ctx->libctx, supported_sig, ctx->propquery);
|
||||
|
||||
if (signature == NULL
|
||||
|| (EVP_KEYMGMT_provider(ctx->keymgmt)
|
||||
!= EVP_SIGNATURE_provider(signature))) {
|
||||
/*
|
||||
@@ -374,14 +380,6 @@ static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, int operation)
|
||||
}
|
||||
|
||||
ctx->op.sig.signature = signature;
|
||||
|
||||
if (ctx->pkey != NULL) {
|
||||
provkey =
|
||||
evp_keymgmt_export_to_provider(ctx->pkey, ctx->keymgmt, 0);
|
||||
/* If export failed, legacy may be able to pick it up */
|
||||
if (provkey == NULL)
|
||||
goto legacy;
|
||||
}
|
||||
ctx->op.sig.sigprovctx = signature->newctx(ossl_provider_ctx(signature->prov));
|
||||
if (ctx->op.sig.sigprovctx == NULL) {
|
||||
/* The provider key can stay in the cache */
|
||||
|
||||
@@ -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 <openssl/idea.h>
|
||||
#include "idea_local.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 <openssl/idea.h>
|
||||
#include "idea_local.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 <openssl/idea.h>
|
||||
#include "idea_local.h"
|
||||
#include <openssl/opensslv.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 <openssl/idea.h>
|
||||
#include "idea_local.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 <openssl/idea.h>
|
||||
#include "idea_local.h"
|
||||
|
||||
|
||||
+10
-5
@@ -297,7 +297,7 @@ void ossl_ctx_thread_stop(void *arg)
|
||||
|
||||
static void init_thread_stop(void *arg, THREAD_EVENT_HANDLER **hands)
|
||||
{
|
||||
THREAD_EVENT_HANDLER *curr, *prev = NULL;
|
||||
THREAD_EVENT_HANDLER *curr, *prev = NULL, *tmp;
|
||||
|
||||
/* Can't do much about this */
|
||||
if (hands == NULL)
|
||||
@@ -306,15 +306,20 @@ static void init_thread_stop(void *arg, THREAD_EVENT_HANDLER **hands)
|
||||
curr = *hands;
|
||||
while (curr != NULL) {
|
||||
if (arg != NULL && curr->arg != arg) {
|
||||
prev = curr;
|
||||
curr = curr->next;
|
||||
continue;
|
||||
}
|
||||
curr->handfn(curr->arg);
|
||||
prev = curr;
|
||||
if (prev == NULL)
|
||||
*hands = curr->next;
|
||||
else
|
||||
prev->next = curr->next;
|
||||
|
||||
tmp = curr;
|
||||
curr = curr->next;
|
||||
if (prev == *hands)
|
||||
*hands = curr;
|
||||
OPENSSL_free(prev);
|
||||
|
||||
OPENSSL_free(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <stdio.h>
|
||||
#include "md5_local.h"
|
||||
#include <openssl/opensslv.h>
|
||||
|
||||
@@ -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 <stdio.h>
|
||||
#include <string.h>
|
||||
#include <openssl/md5.h>
|
||||
|
||||
@@ -6,6 +6,13 @@
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* 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 "prov/md5_sha1.h"
|
||||
#include <openssl/evp.h>
|
||||
|
||||
+16
-7
@@ -138,21 +138,30 @@ int ossl_param_bld_push_double(OSSL_PARAM_BLD *bld, const char *key,
|
||||
int ossl_param_bld_push_BN(OSSL_PARAM_BLD *bld, const char *key,
|
||||
const BIGNUM *bn)
|
||||
{
|
||||
int sz = -1, secure = 0;
|
||||
return ossl_param_bld_push_BN_pad(bld, key, bn,
|
||||
bn == NULL ? 0 : BN_num_bytes(bn));
|
||||
}
|
||||
|
||||
int ossl_param_bld_push_BN_pad(OSSL_PARAM_BLD *bld, const char *key,
|
||||
const BIGNUM *bn, size_t sz)
|
||||
{
|
||||
int n, secure = 0;
|
||||
OSSL_PARAM_BLD_DEF *pd;
|
||||
|
||||
if (bn != NULL) {
|
||||
sz = BN_num_bytes(bn);
|
||||
if (sz < 0) {
|
||||
CRYPTOerr(CRYPTO_F_OSSL_PARAM_BLD_PUSH_BN,
|
||||
CRYPTO_R_ZERO_LENGTH_NUMBER);
|
||||
n = BN_num_bytes(bn);
|
||||
if (n < 0) {
|
||||
CRYPTOerr(0, CRYPTO_R_ZERO_LENGTH_NUMBER);
|
||||
return 0;
|
||||
}
|
||||
if (sz < (size_t)n) {
|
||||
CRYPTOerr(0, CRYPTO_R_TOO_SMALL_BUFFER);
|
||||
return 0;
|
||||
}
|
||||
if (BN_get_flags(bn, BN_FLG_SECURE) == BN_FLG_SECURE)
|
||||
secure = 1;
|
||||
}
|
||||
pd = param_push(bld, key, sz, sz >= 0 ? sz : 0,
|
||||
OSSL_PARAM_UNSIGNED_INTEGER, secure);
|
||||
pd = param_push(bld, key, sz, sz, OSSL_PARAM_UNSIGNED_INTEGER, secure);
|
||||
if (pd == NULL)
|
||||
return 0;
|
||||
pd->bn = bn;
|
||||
|
||||
@@ -101,6 +101,24 @@ elsif (!$gas)
|
||||
$decor="\$L\$";
|
||||
}
|
||||
|
||||
my $cet_property = <<'_____';
|
||||
.section ".note.gnu.property", "a"
|
||||
.align 8
|
||||
.long 1f - 0f
|
||||
.long 4f - 1f
|
||||
.long 5
|
||||
0:
|
||||
.asciz "GNU"
|
||||
1:
|
||||
.align 8
|
||||
.long 0xc0000002
|
||||
.long 3f - 2f
|
||||
2:
|
||||
.long 3
|
||||
3:
|
||||
.p2align 3
|
||||
4:
|
||||
_____
|
||||
my $current_segment;
|
||||
my $current_function;
|
||||
my %globals;
|
||||
@@ -1127,7 +1145,9 @@ my $vprotq = sub {
|
||||
# Intel Control-flow Enforcement Technology extension. All functions and
|
||||
# indirect branch targets will have to start with this instruction...
|
||||
|
||||
my $used_cet = 0;
|
||||
my $endbranch = sub {
|
||||
$used_cet = 1;
|
||||
(0xf3,0x0f,0x1e,0xfa);
|
||||
};
|
||||
|
||||
@@ -1213,6 +1233,7 @@ while(defined(my $line=<>)) {
|
||||
print $line,"\n";
|
||||
}
|
||||
|
||||
print "$cet_property" if ($gas && $used_cet);
|
||||
print "\n$current_segment\tENDS\n" if ($current_segment && $masm);
|
||||
print "END\n" if ($masm);
|
||||
|
||||
|
||||
+12
-2
@@ -1353,7 +1353,12 @@ RAND_DRBG *OPENSSL_CTX_get0_public_drbg(OPENSSL_CTX *ctx)
|
||||
drbg = CRYPTO_THREAD_get_local(&dgbl->public_drbg);
|
||||
if (drbg == NULL) {
|
||||
ctx = openssl_ctx_get_concrete(ctx);
|
||||
if (!ossl_init_thread_start(NULL, ctx, drbg_delete_thread_state))
|
||||
/*
|
||||
* If the private_drbg is also NULL then this is the first time we've
|
||||
* used this thread.
|
||||
*/
|
||||
if (CRYPTO_THREAD_get_local(&dgbl->private_drbg) == NULL
|
||||
&& !ossl_init_thread_start(NULL, ctx, drbg_delete_thread_state))
|
||||
return NULL;
|
||||
drbg = drbg_setup(ctx, dgbl->master_drbg, RAND_DRBG_TYPE_PUBLIC);
|
||||
CRYPTO_THREAD_set_local(&dgbl->public_drbg, drbg);
|
||||
@@ -1381,7 +1386,12 @@ RAND_DRBG *OPENSSL_CTX_get0_private_drbg(OPENSSL_CTX *ctx)
|
||||
drbg = CRYPTO_THREAD_get_local(&dgbl->private_drbg);
|
||||
if (drbg == NULL) {
|
||||
ctx = openssl_ctx_get_concrete(ctx);
|
||||
if (!ossl_init_thread_start(NULL, ctx, drbg_delete_thread_state))
|
||||
/*
|
||||
* If the public_drbg is also NULL then this is the first time we've
|
||||
* used this thread.
|
||||
*/
|
||||
if (CRYPTO_THREAD_get_local(&dgbl->public_drbg) == NULL
|
||||
&& !ossl_init_thread_start(NULL, ctx, drbg_delete_thread_state))
|
||||
return NULL;
|
||||
drbg = drbg_setup(ctx, dgbl->master_drbg, RAND_DRBG_TYPE_PRIVATE);
|
||||
CRYPTO_THREAD_set_local(&dgbl->private_drbg, drbg);
|
||||
|
||||
@@ -851,7 +851,7 @@ void RAND_add(const void *buf, int num, double randomness)
|
||||
* the default method, then just call RAND_bytes(). Otherwise make
|
||||
* sure we're instantiated and use the private DRBG.
|
||||
*/
|
||||
int rand_priv_bytes_ex(OPENSSL_CTX *ctx, unsigned char *buf, int num)
|
||||
int RAND_priv_bytes_ex(OPENSSL_CTX *ctx, unsigned char *buf, int num)
|
||||
{
|
||||
RAND_DRBG *drbg;
|
||||
const RAND_METHOD *meth = RAND_get_rand_method();
|
||||
@@ -872,10 +872,10 @@ int rand_priv_bytes_ex(OPENSSL_CTX *ctx, unsigned char *buf, int num)
|
||||
|
||||
int RAND_priv_bytes(unsigned char *buf, int num)
|
||||
{
|
||||
return rand_priv_bytes_ex(NULL, buf, num);
|
||||
return RAND_priv_bytes_ex(NULL, buf, num);
|
||||
}
|
||||
|
||||
int rand_bytes_ex(OPENSSL_CTX *ctx, unsigned char *buf, int num)
|
||||
int RAND_bytes_ex(OPENSSL_CTX *ctx, unsigned char *buf, int num)
|
||||
{
|
||||
RAND_DRBG *drbg;
|
||||
const RAND_METHOD *meth = RAND_get_rand_method();
|
||||
@@ -896,7 +896,7 @@ int rand_bytes_ex(OPENSSL_CTX *ctx, unsigned char *buf, int num)
|
||||
|
||||
int RAND_bytes(unsigned char *buf, int num)
|
||||
{
|
||||
return rand_bytes_ex(NULL, buf, num);
|
||||
return RAND_bytes_ex(NULL, buf, num);
|
||||
}
|
||||
|
||||
#if !defined(OPENSSL_NO_DEPRECATED_1_1_0) && !defined(FIPS_MODE)
|
||||
|
||||
@@ -140,11 +140,12 @@ $code=<<___;
|
||||
.globl RC4
|
||||
.type RC4,\@function,4
|
||||
.align 16
|
||||
RC4: or $len,$len
|
||||
RC4:
|
||||
.cfi_startproc
|
||||
or $len,$len
|
||||
jne .Lentry
|
||||
ret
|
||||
.Lentry:
|
||||
.cfi_startproc
|
||||
push %rbx
|
||||
.cfi_push %rbx
|
||||
push %r12
|
||||
@@ -529,6 +530,7 @@ RC4_set_key:
|
||||
.type RC4_options,\@abi-omnipotent
|
||||
.align 16
|
||||
RC4_options:
|
||||
.cfi_startproc
|
||||
lea .Lopts(%rip),%rax
|
||||
mov OPENSSL_ia32cap_P(%rip),%edx
|
||||
bt \$20,%edx
|
||||
@@ -541,6 +543,7 @@ RC4_options:
|
||||
add \$12,%rax
|
||||
.Ldone:
|
||||
ret
|
||||
.cfi_endproc
|
||||
.align 64
|
||||
.Lopts:
|
||||
.asciz "rc4(8x,int)"
|
||||
|
||||
@@ -589,6 +589,7 @@ static RSA_PSS_PARAMS *rsa_ctx_to_pss(EVP_PKEY_CTX *pkctx)
|
||||
{
|
||||
const EVP_MD *sigmd, *mgf1md;
|
||||
EVP_PKEY *pk = EVP_PKEY_CTX_get0_pkey(pkctx);
|
||||
RSA *rsa = EVP_PKEY_get0_RSA(pk);
|
||||
int saltlen;
|
||||
|
||||
if (EVP_PKEY_CTX_get_signature_md(pkctx, &sigmd) <= 0)
|
||||
@@ -600,7 +601,7 @@ static RSA_PSS_PARAMS *rsa_ctx_to_pss(EVP_PKEY_CTX *pkctx)
|
||||
if (saltlen == -1) {
|
||||
saltlen = EVP_MD_size(sigmd);
|
||||
} else if (saltlen == -2 || saltlen == -3) {
|
||||
saltlen = EVP_PKEY_size(pk) - EVP_MD_size(sigmd) - 2;
|
||||
saltlen = RSA_size(rsa) - EVP_MD_size(sigmd) - 2;
|
||||
if ((EVP_PKEY_bits(pk) & 0x7) == 1)
|
||||
saltlen--;
|
||||
if (saltlen < 0)
|
||||
|
||||
@@ -104,7 +104,7 @@ static int setup_tbuf(RSA_PKEY_CTX *ctx, EVP_PKEY_CTX *pk)
|
||||
{
|
||||
if (ctx->tbuf != NULL)
|
||||
return 1;
|
||||
if ((ctx->tbuf = OPENSSL_malloc(EVP_PKEY_size(pk->pkey))) == NULL) {
|
||||
if ((ctx->tbuf = OPENSSL_malloc(RSA_size(pk->pkey->pkey.rsa))) == NULL) {
|
||||
RSAerr(RSA_F_SETUP_TBUF, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
@@ -147,7 +147,7 @@ static int pkey_rsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig,
|
||||
return ret;
|
||||
ret = sltmp;
|
||||
} else if (rctx->pad_mode == RSA_X931_PADDING) {
|
||||
if ((size_t)EVP_PKEY_size(ctx->pkey) < tbslen + 1) {
|
||||
if ((size_t)RSA_size(rsa) < tbslen + 1) {
|
||||
RSAerr(RSA_F_PKEY_RSA_SIGN, RSA_R_KEY_SIZE_TOO_SMALL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
* 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 <stdio.h>
|
||||
#include <string.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
* 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/crypto.h>
|
||||
#include <openssl/opensslconf.h>
|
||||
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/*
|
||||
* SHA256 low level APIs are deprecated for public use, but still ok for
|
||||
* internal use.
|
||||
*/
|
||||
#include "internal/deprecated.h"
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -7,6 +7,13 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/*
|
||||
* SHA512 low level APIs are deprecated for public use, but still ok for
|
||||
* internal use.
|
||||
*/
|
||||
#include "internal/deprecated.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <openssl/opensslconf.h>
|
||||
/*-
|
||||
* IMPLEMENTATION NOTES.
|
||||
|
||||
Reference in New Issue
Block a user