add original 3.5.0 and replace with 3.1.7. NOTE:- This commit will NOT COMPILE. (#15)
Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/15 Co-authored-by: siddhant <siddhant.singh@neominds.in> Co-committed-by: siddhant <siddhant.singh@neominds.in>
This commit is contained in:
@@ -1,29 +0,0 @@
|
|||||||
package platform::AIX;
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
use Carp;
|
|
||||||
|
|
||||||
use vars qw(@ISA);
|
|
||||||
|
|
||||||
require platform::Unix;
|
|
||||||
@ISA = qw(platform::Unix);
|
|
||||||
|
|
||||||
# Assume someone set @INC right before loading this module
|
|
||||||
use configdata;
|
|
||||||
|
|
||||||
sub dsoext { '.so' }
|
|
||||||
sub shlibextsimple { '.a' }
|
|
||||||
|
|
||||||
# In shared mode, the default static library names clashes with the final
|
|
||||||
# "simple" full shared library name, so we add '_a' to the basename of the
|
|
||||||
# static libraries in that case.
|
|
||||||
sub staticname {
|
|
||||||
# Non-installed libraries are *always* static, and their names remain
|
|
||||||
# the same, except for the mandatory extension
|
|
||||||
my $in_libname = platform::BASE->staticname($_[1]);
|
|
||||||
return $in_libname
|
|
||||||
if $unified_info{attributes}->{libraries}->{$_[1]}->{noinst};
|
|
||||||
|
|
||||||
return platform::BASE->staticname($_[1]) . ($disabled{shared} ? '' : '_a');
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,452 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2018-2023 The OpenSSL Project Authors. All Rights Reserved.
|
|
||||||
* Copyright Siemens AG 2018-2020
|
|
||||||
*
|
|
||||||
* 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 atf
|
|
||||||
* https://www.openssl.org/source/license.html
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "apps.h"
|
|
||||||
#include "cmp_mock_srv.h"
|
|
||||||
|
|
||||||
#include <openssl/cmp.h>
|
|
||||||
#include <openssl/err.h>
|
|
||||||
#include <openssl/cmperr.h>
|
|
||||||
|
|
||||||
/* the context for the CMP mock server */
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
X509 *certOut; /* certificate to be returned in cp/ip/kup msg */
|
|
||||||
STACK_OF(X509) *chainOut; /* chain of certOut to add to extraCerts field */
|
|
||||||
STACK_OF(X509) *caPubsOut; /* certs to return in caPubs field of ip msg */
|
|
||||||
OSSL_CMP_PKISI *statusOut; /* status for ip/cp/kup/rp msg unless polling */
|
|
||||||
int sendError; /* send error response on given request type */
|
|
||||||
OSSL_CMP_MSG *certReq; /* ir/cr/p10cr/kur remembered while polling */
|
|
||||||
int pollCount; /* number of polls before actual cert response */
|
|
||||||
int curr_pollCount; /* number of polls so far for current request */
|
|
||||||
int checkAfterTime; /* time the client should wait between polling */
|
|
||||||
} mock_srv_ctx;
|
|
||||||
|
|
||||||
|
|
||||||
static void mock_srv_ctx_free(mock_srv_ctx *ctx)
|
|
||||||
{
|
|
||||||
if (ctx == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
OSSL_CMP_PKISI_free(ctx->statusOut);
|
|
||||||
X509_free(ctx->certOut);
|
|
||||||
sk_X509_pop_free(ctx->chainOut, X509_free);
|
|
||||||
sk_X509_pop_free(ctx->caPubsOut, X509_free);
|
|
||||||
OSSL_CMP_MSG_free(ctx->certReq);
|
|
||||||
OPENSSL_free(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static mock_srv_ctx *mock_srv_ctx_new(void)
|
|
||||||
{
|
|
||||||
mock_srv_ctx *ctx = OPENSSL_zalloc(sizeof(mock_srv_ctx));
|
|
||||||
|
|
||||||
if (ctx == NULL)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
if ((ctx->statusOut = OSSL_CMP_PKISI_new()) == NULL)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
ctx->sendError = -1;
|
|
||||||
|
|
||||||
/* all other elements are initialized to 0 or NULL, respectively */
|
|
||||||
return ctx;
|
|
||||||
err:
|
|
||||||
mock_srv_ctx_free(ctx);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_cmp_mock_srv_set1_certOut(OSSL_CMP_SRV_CTX *srv_ctx, X509 *cert)
|
|
||||||
{
|
|
||||||
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
|
||||||
|
|
||||||
if (ctx == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (cert == NULL || X509_up_ref(cert)) {
|
|
||||||
X509_free(ctx->certOut);
|
|
||||||
ctx->certOut = cert;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_cmp_mock_srv_set1_chainOut(OSSL_CMP_SRV_CTX *srv_ctx,
|
|
||||||
STACK_OF(X509) *chain)
|
|
||||||
{
|
|
||||||
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
|
||||||
STACK_OF(X509) *chain_copy = NULL;
|
|
||||||
|
|
||||||
if (ctx == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (chain != NULL && (chain_copy = X509_chain_up_ref(chain)) == NULL)
|
|
||||||
return 0;
|
|
||||||
sk_X509_pop_free(ctx->chainOut, X509_free);
|
|
||||||
ctx->chainOut = chain_copy;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_cmp_mock_srv_set1_caPubsOut(OSSL_CMP_SRV_CTX *srv_ctx,
|
|
||||||
STACK_OF(X509) *caPubs)
|
|
||||||
{
|
|
||||||
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
|
||||||
STACK_OF(X509) *caPubs_copy = NULL;
|
|
||||||
|
|
||||||
if (ctx == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (caPubs != NULL && (caPubs_copy = X509_chain_up_ref(caPubs)) == NULL)
|
|
||||||
return 0;
|
|
||||||
sk_X509_pop_free(ctx->caPubsOut, X509_free);
|
|
||||||
ctx->caPubsOut = caPubs_copy;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_cmp_mock_srv_set_statusInfo(OSSL_CMP_SRV_CTX *srv_ctx, int status,
|
|
||||||
int fail_info, const char *text)
|
|
||||||
{
|
|
||||||
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
|
||||||
OSSL_CMP_PKISI *si;
|
|
||||||
|
|
||||||
if (ctx == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if ((si = OSSL_CMP_STATUSINFO_new(status, fail_info, text)) == NULL)
|
|
||||||
return 0;
|
|
||||||
OSSL_CMP_PKISI_free(ctx->statusOut);
|
|
||||||
ctx->statusOut = si;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_cmp_mock_srv_set_sendError(OSSL_CMP_SRV_CTX *srv_ctx, int bodytype)
|
|
||||||
{
|
|
||||||
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
|
||||||
|
|
||||||
if (ctx == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/* might check bodytype, but this would require exporting all body types */
|
|
||||||
ctx->sendError = bodytype;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_cmp_mock_srv_set_pollCount(OSSL_CMP_SRV_CTX *srv_ctx, int count)
|
|
||||||
{
|
|
||||||
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
|
||||||
|
|
||||||
if (ctx == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (count < 0) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_INVALID_ARGS);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
ctx->pollCount = count;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_cmp_mock_srv_set_checkAfterTime(OSSL_CMP_SRV_CTX *srv_ctx, int sec)
|
|
||||||
{
|
|
||||||
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
|
||||||
|
|
||||||
if (ctx == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
ctx->checkAfterTime = sec;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static OSSL_CMP_PKISI *process_cert_request(OSSL_CMP_SRV_CTX *srv_ctx,
|
|
||||||
const OSSL_CMP_MSG *cert_req,
|
|
||||||
ossl_unused int certReqId,
|
|
||||||
const OSSL_CRMF_MSG *crm,
|
|
||||||
const X509_REQ *p10cr,
|
|
||||||
X509 **certOut,
|
|
||||||
STACK_OF(X509) **chainOut,
|
|
||||||
STACK_OF(X509) **caPubs)
|
|
||||||
{
|
|
||||||
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
|
||||||
OSSL_CMP_PKISI *si = NULL;
|
|
||||||
|
|
||||||
if (ctx == NULL || cert_req == NULL
|
|
||||||
|| certOut == NULL || chainOut == NULL || caPubs == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (ctx->sendError == 1
|
|
||||||
|| ctx->sendError == OSSL_CMP_MSG_get_bodytype(cert_req)) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_ERROR_PROCESSING_MESSAGE);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
*certOut = NULL;
|
|
||||||
*chainOut = NULL;
|
|
||||||
*caPubs = NULL;
|
|
||||||
|
|
||||||
if (ctx->pollCount > 0 && ctx->curr_pollCount == 0) {
|
|
||||||
/* start polling */
|
|
||||||
if (ctx->certReq != NULL) {
|
|
||||||
/* already in polling mode */
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_UNEXPECTED_PKIBODY);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if ((ctx->certReq = OSSL_CMP_MSG_dup(cert_req)) == NULL)
|
|
||||||
return NULL;
|
|
||||||
return OSSL_CMP_STATUSINFO_new(OSSL_CMP_PKISTATUS_waiting, 0, NULL);
|
|
||||||
}
|
|
||||||
if (ctx->curr_pollCount >= ctx->pollCount)
|
|
||||||
/* give final response after polling */
|
|
||||||
ctx->curr_pollCount = 0;
|
|
||||||
|
|
||||||
if (OSSL_CMP_MSG_get_bodytype(cert_req) == OSSL_CMP_KUR
|
|
||||||
&& crm != NULL && ctx->certOut != NULL) {
|
|
||||||
const OSSL_CRMF_CERTID *cid = OSSL_CRMF_MSG_get0_regCtrl_oldCertID(crm);
|
|
||||||
const X509_NAME *issuer = X509_get_issuer_name(ctx->certOut);
|
|
||||||
const ASN1_INTEGER *serial = X509_get0_serialNumber(ctx->certOut);
|
|
||||||
|
|
||||||
if (cid == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_MISSING_CERTID);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (issuer != NULL
|
|
||||||
&& X509_NAME_cmp(issuer, OSSL_CRMF_CERTID_get0_issuer(cid)) != 0) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_WRONG_CERTID);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (serial != NULL
|
|
||||||
&& ASN1_INTEGER_cmp(serial,
|
|
||||||
OSSL_CRMF_CERTID_get0_serialNumber(cid)) != 0) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_WRONG_CERTID);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx->certOut != NULL
|
|
||||||
&& (*certOut = X509_dup(ctx->certOut)) == NULL)
|
|
||||||
goto err;
|
|
||||||
if (ctx->chainOut != NULL
|
|
||||||
&& (*chainOut = X509_chain_up_ref(ctx->chainOut)) == NULL)
|
|
||||||
goto err;
|
|
||||||
if (ctx->caPubsOut != NULL
|
|
||||||
&& (*caPubs = X509_chain_up_ref(ctx->caPubsOut)) == NULL)
|
|
||||||
goto err;
|
|
||||||
if (ctx->statusOut != NULL
|
|
||||||
&& (si = OSSL_CMP_PKISI_dup(ctx->statusOut)) == NULL)
|
|
||||||
goto err;
|
|
||||||
return si;
|
|
||||||
|
|
||||||
err:
|
|
||||||
X509_free(*certOut);
|
|
||||||
*certOut = NULL;
|
|
||||||
sk_X509_pop_free(*chainOut, X509_free);
|
|
||||||
*chainOut = NULL;
|
|
||||||
sk_X509_pop_free(*caPubs, X509_free);
|
|
||||||
*caPubs = NULL;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static OSSL_CMP_PKISI *process_rr(OSSL_CMP_SRV_CTX *srv_ctx,
|
|
||||||
const OSSL_CMP_MSG *rr,
|
|
||||||
const X509_NAME *issuer,
|
|
||||||
const ASN1_INTEGER *serial)
|
|
||||||
{
|
|
||||||
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
|
||||||
|
|
||||||
if (ctx == NULL || rr == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (ctx->certOut == NULL || ctx->sendError == 1
|
|
||||||
|| ctx->sendError == OSSL_CMP_MSG_get_bodytype(rr)) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_ERROR_PROCESSING_MESSAGE);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allow any RR derived from CSR, which may include subject and serial */
|
|
||||||
if (issuer == NULL || serial == NULL)
|
|
||||||
return OSSL_CMP_PKISI_dup(ctx->statusOut);
|
|
||||||
|
|
||||||
/* accept revocation only for the certificate we sent in ir/cr/kur */
|
|
||||||
if (X509_NAME_cmp(issuer, X509_get_issuer_name(ctx->certOut)) != 0
|
|
||||||
|| ASN1_INTEGER_cmp(serial,
|
|
||||||
X509_get0_serialNumber(ctx->certOut)) != 0) {
|
|
||||||
ERR_raise_data(ERR_LIB_CMP, CMP_R_REQUEST_NOT_ACCEPTED,
|
|
||||||
"wrong certificate to revoke");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return OSSL_CMP_PKISI_dup(ctx->statusOut);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int process_genm(OSSL_CMP_SRV_CTX *srv_ctx,
|
|
||||||
const OSSL_CMP_MSG *genm,
|
|
||||||
const STACK_OF(OSSL_CMP_ITAV) *in,
|
|
||||||
STACK_OF(OSSL_CMP_ITAV) **out)
|
|
||||||
{
|
|
||||||
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
|
||||||
|
|
||||||
if (ctx == NULL || genm == NULL || in == NULL || out == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (ctx->sendError == 1
|
|
||||||
|| ctx->sendError == OSSL_CMP_MSG_get_bodytype(genm)
|
|
||||||
|| sk_OSSL_CMP_ITAV_num(in) > 1) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_ERROR_PROCESSING_MESSAGE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
*out = sk_OSSL_CMP_ITAV_deep_copy(in, OSSL_CMP_ITAV_dup,
|
|
||||||
OSSL_CMP_ITAV_free);
|
|
||||||
return *out != NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void process_error(OSSL_CMP_SRV_CTX *srv_ctx, const OSSL_CMP_MSG *error,
|
|
||||||
const OSSL_CMP_PKISI *statusInfo,
|
|
||||||
const ASN1_INTEGER *errorCode,
|
|
||||||
const OSSL_CMP_PKIFREETEXT *errorDetails)
|
|
||||||
{
|
|
||||||
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
|
||||||
char buf[OSSL_CMP_PKISI_BUFLEN];
|
|
||||||
char *sibuf;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (ctx == NULL || error == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BIO_printf(bio_err, "mock server received error:\n");
|
|
||||||
|
|
||||||
if (statusInfo == NULL) {
|
|
||||||
BIO_printf(bio_err, "pkiStatusInfo absent\n");
|
|
||||||
} else {
|
|
||||||
sibuf = OSSL_CMP_snprint_PKIStatusInfo(statusInfo, buf, sizeof(buf));
|
|
||||||
BIO_printf(bio_err, "pkiStatusInfo: %s\n",
|
|
||||||
sibuf != NULL ? sibuf: "<invalid>");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errorCode == NULL)
|
|
||||||
BIO_printf(bio_err, "errorCode absent\n");
|
|
||||||
else
|
|
||||||
BIO_printf(bio_err, "errorCode: %ld\n", ASN1_INTEGER_get(errorCode));
|
|
||||||
|
|
||||||
if (sk_ASN1_UTF8STRING_num(errorDetails) <= 0) {
|
|
||||||
BIO_printf(bio_err, "errorDetails absent\n");
|
|
||||||
} else {
|
|
||||||
BIO_printf(bio_err, "errorDetails: ");
|
|
||||||
for (i = 0; i < sk_ASN1_UTF8STRING_num(errorDetails); i++) {
|
|
||||||
if (i > 0)
|
|
||||||
BIO_printf(bio_err, ", ");
|
|
||||||
BIO_printf(bio_err, "\"");
|
|
||||||
ASN1_STRING_print(bio_err,
|
|
||||||
sk_ASN1_UTF8STRING_value(errorDetails, i));
|
|
||||||
BIO_printf(bio_err, "\"");
|
|
||||||
}
|
|
||||||
BIO_printf(bio_err, "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int process_certConf(OSSL_CMP_SRV_CTX *srv_ctx,
|
|
||||||
const OSSL_CMP_MSG *certConf,
|
|
||||||
ossl_unused int certReqId,
|
|
||||||
const ASN1_OCTET_STRING *certHash,
|
|
||||||
const OSSL_CMP_PKISI *si)
|
|
||||||
{
|
|
||||||
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
|
||||||
ASN1_OCTET_STRING *digest;
|
|
||||||
|
|
||||||
if (ctx == NULL || certConf == NULL || certHash == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (ctx->sendError == 1
|
|
||||||
|| ctx->sendError == OSSL_CMP_MSG_get_bodytype(certConf)
|
|
||||||
|| ctx->certOut == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_ERROR_PROCESSING_MESSAGE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((digest = X509_digest_sig(ctx->certOut, NULL, NULL)) == NULL)
|
|
||||||
return 0;
|
|
||||||
if (ASN1_OCTET_STRING_cmp(certHash, digest) != 0) {
|
|
||||||
ASN1_OCTET_STRING_free(digest);
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_CERTHASH_UNMATCHED);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
ASN1_OCTET_STRING_free(digest);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int process_pollReq(OSSL_CMP_SRV_CTX *srv_ctx,
|
|
||||||
const OSSL_CMP_MSG *pollReq,
|
|
||||||
ossl_unused int certReqId,
|
|
||||||
OSSL_CMP_MSG **certReq, int64_t *check_after)
|
|
||||||
{
|
|
||||||
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
|
||||||
|
|
||||||
if (ctx == NULL || pollReq == NULL
|
|
||||||
|| certReq == NULL || check_after == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (ctx->sendError == 1
|
|
||||||
|| ctx->sendError == OSSL_CMP_MSG_get_bodytype(pollReq)) {
|
|
||||||
*certReq = NULL;
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_ERROR_PROCESSING_MESSAGE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (ctx->certReq == NULL) {
|
|
||||||
/* not currently in polling mode */
|
|
||||||
*certReq = NULL;
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_UNEXPECTED_PKIBODY);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (++ctx->curr_pollCount >= ctx->pollCount) {
|
|
||||||
/* end polling */
|
|
||||||
*certReq = ctx->certReq;
|
|
||||||
ctx->certReq = NULL;
|
|
||||||
*check_after = 0;
|
|
||||||
} else {
|
|
||||||
*certReq = NULL;
|
|
||||||
*check_after = ctx->checkAfterTime;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
OSSL_CMP_SRV_CTX *ossl_cmp_mock_srv_new(OSSL_LIB_CTX *libctx, const char *propq)
|
|
||||||
{
|
|
||||||
OSSL_CMP_SRV_CTX *srv_ctx = OSSL_CMP_SRV_CTX_new(libctx, propq);
|
|
||||||
mock_srv_ctx *ctx = mock_srv_ctx_new();
|
|
||||||
|
|
||||||
if (srv_ctx != NULL && ctx != NULL
|
|
||||||
&& OSSL_CMP_SRV_CTX_init(srv_ctx, ctx, process_cert_request,
|
|
||||||
process_rr, process_genm, process_error,
|
|
||||||
process_certConf, process_pollReq))
|
|
||||||
return srv_ctx;
|
|
||||||
|
|
||||||
mock_srv_ctx_free(ctx);
|
|
||||||
OSSL_CMP_SRV_CTX_free(srv_ctx);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ossl_cmp_mock_srv_free(OSSL_CMP_SRV_CTX *srv_ctx)
|
|
||||||
{
|
|
||||||
if (srv_ctx != NULL)
|
|
||||||
mock_srv_ctx_free(OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx));
|
|
||||||
OSSL_CMP_SRV_CTX_free(srv_ctx);
|
|
||||||
}
|
|
||||||
@@ -1,149 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 1998-2021 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 "apps.h"
|
|
||||||
#include "progs.h"
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <openssl/bio.h>
|
|
||||||
#include <openssl/err.h>
|
|
||||||
#include <openssl/rand.h>
|
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
|
||||||
OPT_COMMON,
|
|
||||||
OPT_OUT, OPT_ENGINE, OPT_BASE64, OPT_HEX,
|
|
||||||
OPT_R_ENUM, OPT_PROV_ENUM
|
|
||||||
} OPTION_CHOICE;
|
|
||||||
|
|
||||||
const OPTIONS rand_options[] = {
|
|
||||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] num\n"},
|
|
||||||
|
|
||||||
OPT_SECTION("General"),
|
|
||||||
{"help", OPT_HELP, '-', "Display this summary"},
|
|
||||||
#ifndef OPENSSL_NO_ENGINE
|
|
||||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
|
||||||
#endif
|
|
||||||
|
|
||||||
OPT_SECTION("Output"),
|
|
||||||
{"out", OPT_OUT, '>', "Output file"},
|
|
||||||
{"base64", OPT_BASE64, '-', "Base64 encode output"},
|
|
||||||
{"hex", OPT_HEX, '-', "Hex encode output"},
|
|
||||||
|
|
||||||
OPT_R_OPTIONS,
|
|
||||||
OPT_PROV_OPTIONS,
|
|
||||||
|
|
||||||
OPT_PARAMETERS(),
|
|
||||||
{"num", 0, 0, "Number of bytes to generate"},
|
|
||||||
{NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
int rand_main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
ENGINE *e = NULL;
|
|
||||||
BIO *out = NULL;
|
|
||||||
char *outfile = NULL, *prog;
|
|
||||||
OPTION_CHOICE o;
|
|
||||||
int format = FORMAT_BINARY, i, num = -1, r, ret = 1;
|
|
||||||
|
|
||||||
prog = opt_init(argc, argv, rand_options);
|
|
||||||
while ((o = opt_next()) != OPT_EOF) {
|
|
||||||
switch (o) {
|
|
||||||
case OPT_EOF:
|
|
||||||
case OPT_ERR:
|
|
||||||
opthelp:
|
|
||||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
|
||||||
goto end;
|
|
||||||
case OPT_HELP:
|
|
||||||
opt_help(rand_options);
|
|
||||||
ret = 0;
|
|
||||||
goto end;
|
|
||||||
case OPT_OUT:
|
|
||||||
outfile = opt_arg();
|
|
||||||
break;
|
|
||||||
case OPT_ENGINE:
|
|
||||||
e = setup_engine(opt_arg(), 0);
|
|
||||||
break;
|
|
||||||
case OPT_R_CASES:
|
|
||||||
if (!opt_rand(o))
|
|
||||||
goto end;
|
|
||||||
break;
|
|
||||||
case OPT_BASE64:
|
|
||||||
format = FORMAT_BASE64;
|
|
||||||
break;
|
|
||||||
case OPT_HEX:
|
|
||||||
format = FORMAT_TEXT;
|
|
||||||
break;
|
|
||||||
case OPT_PROV_CASES:
|
|
||||||
if (!opt_provider(o))
|
|
||||||
goto end;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Optional argument is number of bytes to generate. */
|
|
||||||
argc = opt_num_rest();
|
|
||||||
argv = opt_rest();
|
|
||||||
if (argc == 1) {
|
|
||||||
if (!opt_int(argv[0], &num) || num <= 0)
|
|
||||||
goto opthelp;
|
|
||||||
} else if (argc != 0) {
|
|
||||||
goto opthelp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!app_RAND_load())
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
out = bio_open_default(outfile, 'w', format);
|
|
||||||
if (out == NULL)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
if (format == FORMAT_BASE64) {
|
|
||||||
BIO *b64 = BIO_new(BIO_f_base64());
|
|
||||||
if (b64 == NULL)
|
|
||||||
goto end;
|
|
||||||
out = BIO_push(b64, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (num > 0) {
|
|
||||||
unsigned char buf[4096];
|
|
||||||
int chunk;
|
|
||||||
|
|
||||||
chunk = num;
|
|
||||||
if (chunk > (int)sizeof(buf))
|
|
||||||
chunk = sizeof(buf);
|
|
||||||
r = RAND_bytes(buf, chunk);
|
|
||||||
if (r <= 0)
|
|
||||||
goto end;
|
|
||||||
if (format != FORMAT_TEXT) {
|
|
||||||
if (BIO_write(out, buf, chunk) != chunk)
|
|
||||||
goto end;
|
|
||||||
} else {
|
|
||||||
for (i = 0; i < chunk; i++)
|
|
||||||
if (BIO_printf(out, "%02x", buf[i]) != 2)
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
num -= chunk;
|
|
||||||
}
|
|
||||||
if (format == FORMAT_TEXT)
|
|
||||||
BIO_puts(out, "\n");
|
|
||||||
if (BIO_flush(out) <= 0)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
end:
|
|
||||||
if (ret != 0)
|
|
||||||
ERR_print_errors(bio_err);
|
|
||||||
release_engine(e);
|
|
||||||
BIO_free_all(out);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
@@ -1,195 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2011-2023 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OSSL_CRYPTO_ARM_ARCH_H
|
|
||||||
# define OSSL_CRYPTO_ARM_ARCH_H
|
|
||||||
|
|
||||||
# if !defined(__ARM_ARCH__)
|
|
||||||
# if defined(__CC_ARM)
|
|
||||||
# define __ARM_ARCH__ __TARGET_ARCH_ARM
|
|
||||||
# if defined(__BIG_ENDIAN)
|
|
||||||
# define __ARMEB__
|
|
||||||
# else
|
|
||||||
# define __ARMEL__
|
|
||||||
# endif
|
|
||||||
# elif defined(__GNUC__)
|
|
||||||
# if defined(__aarch64__)
|
|
||||||
# define __ARM_ARCH__ 8
|
|
||||||
/*
|
|
||||||
* Why doesn't gcc define __ARM_ARCH__? Instead it defines
|
|
||||||
* bunch of below macros. See all_architectures[] table in
|
|
||||||
* gcc/config/arm/arm.c. On a side note it defines
|
|
||||||
* __ARMEL__/__ARMEB__ for little-/big-endian.
|
|
||||||
*/
|
|
||||||
# elif defined(__ARM_ARCH)
|
|
||||||
# define __ARM_ARCH__ __ARM_ARCH
|
|
||||||
# elif defined(__ARM_ARCH_8A__)
|
|
||||||
# define __ARM_ARCH__ 8
|
|
||||||
# elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \
|
|
||||||
defined(__ARM_ARCH_7R__)|| defined(__ARM_ARCH_7M__) || \
|
|
||||||
defined(__ARM_ARCH_7EM__)
|
|
||||||
# define __ARM_ARCH__ 7
|
|
||||||
# elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
|
|
||||||
defined(__ARM_ARCH_6K__)|| defined(__ARM_ARCH_6M__) || \
|
|
||||||
defined(__ARM_ARCH_6Z__)|| defined(__ARM_ARCH_6ZK__) || \
|
|
||||||
defined(__ARM_ARCH_6T2__)
|
|
||||||
# define __ARM_ARCH__ 6
|
|
||||||
# elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || \
|
|
||||||
defined(__ARM_ARCH_5E__)|| defined(__ARM_ARCH_5TE__) || \
|
|
||||||
defined(__ARM_ARCH_5TEJ__)
|
|
||||||
# define __ARM_ARCH__ 5
|
|
||||||
# elif defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__)
|
|
||||||
# define __ARM_ARCH__ 4
|
|
||||||
# else
|
|
||||||
# error "unsupported ARM architecture"
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# if !defined(__ARM_MAX_ARCH__)
|
|
||||||
# define __ARM_MAX_ARCH__ __ARM_ARCH__
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# if __ARM_MAX_ARCH__<__ARM_ARCH__
|
|
||||||
# error "__ARM_MAX_ARCH__ can't be less than __ARM_ARCH__"
|
|
||||||
# elif __ARM_MAX_ARCH__!=__ARM_ARCH__
|
|
||||||
# if __ARM_ARCH__<7 && __ARM_MAX_ARCH__>=7 && defined(__ARMEB__)
|
|
||||||
# error "can't build universal big-endian binary"
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef __ASSEMBLER__
|
|
||||||
extern unsigned int OPENSSL_armcap_P;
|
|
||||||
extern unsigned int OPENSSL_arm_midr;
|
|
||||||
extern unsigned int OPENSSL_armv8_rsa_neonized;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# define ARMV7_NEON (1<<0)
|
|
||||||
# define ARMV7_TICK (1<<1)
|
|
||||||
# define ARMV8_AES (1<<2)
|
|
||||||
# define ARMV8_SHA1 (1<<3)
|
|
||||||
# define ARMV8_SHA256 (1<<4)
|
|
||||||
# define ARMV8_PMULL (1<<5)
|
|
||||||
# define ARMV8_SHA512 (1<<6)
|
|
||||||
# define ARMV8_CPUID (1<<7)
|
|
||||||
# define ARMV8_RNG (1<<8)
|
|
||||||
# define ARMV8_SM3 (1<<9)
|
|
||||||
# define ARMV8_SM4 (1<<10)
|
|
||||||
# define ARMV8_SHA3 (1<<11)
|
|
||||||
# define ARMV8_UNROLL8_EOR3 (1<<12)
|
|
||||||
# define ARMV8_SVE (1<<13)
|
|
||||||
# define ARMV8_SVE2 (1<<14)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* MIDR_EL1 system register
|
|
||||||
*
|
|
||||||
* 63___ _ ___32_31___ _ ___24_23_____20_19_____16_15__ _ __4_3_______0
|
|
||||||
* | | | | | | |
|
|
||||||
* |RES0 | Implementer | Variant | Arch | PartNum |Revision|
|
|
||||||
* |____ _ _____|_____ _ _____|_________|_______ _|____ _ ___|________|
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
# define ARM_CPU_IMP_ARM 0x41
|
|
||||||
|
|
||||||
# define ARM_CPU_PART_CORTEX_A72 0xD08
|
|
||||||
# define ARM_CPU_PART_N1 0xD0C
|
|
||||||
# define ARM_CPU_PART_V1 0xD40
|
|
||||||
# define ARM_CPU_PART_N2 0xD49
|
|
||||||
# define ARM_CPU_PART_V2 0xD4F
|
|
||||||
|
|
||||||
# define MIDR_PARTNUM_SHIFT 4
|
|
||||||
# define MIDR_PARTNUM_MASK (0xfffU << MIDR_PARTNUM_SHIFT)
|
|
||||||
# define MIDR_PARTNUM(midr) \
|
|
||||||
(((midr) & MIDR_PARTNUM_MASK) >> MIDR_PARTNUM_SHIFT)
|
|
||||||
|
|
||||||
# define MIDR_IMPLEMENTER_SHIFT 24
|
|
||||||
# define MIDR_IMPLEMENTER_MASK (0xffU << MIDR_IMPLEMENTER_SHIFT)
|
|
||||||
# define MIDR_IMPLEMENTER(midr) \
|
|
||||||
(((midr) & MIDR_IMPLEMENTER_MASK) >> MIDR_IMPLEMENTER_SHIFT)
|
|
||||||
|
|
||||||
# define MIDR_ARCHITECTURE_SHIFT 16
|
|
||||||
# define MIDR_ARCHITECTURE_MASK (0xfU << MIDR_ARCHITECTURE_SHIFT)
|
|
||||||
# define MIDR_ARCHITECTURE(midr) \
|
|
||||||
(((midr) & MIDR_ARCHITECTURE_MASK) >> MIDR_ARCHITECTURE_SHIFT)
|
|
||||||
|
|
||||||
# define MIDR_CPU_MODEL_MASK \
|
|
||||||
(MIDR_IMPLEMENTER_MASK | \
|
|
||||||
MIDR_PARTNUM_MASK | \
|
|
||||||
MIDR_ARCHITECTURE_MASK)
|
|
||||||
|
|
||||||
# define MIDR_CPU_MODEL(imp, partnum) \
|
|
||||||
(((imp) << MIDR_IMPLEMENTER_SHIFT) | \
|
|
||||||
(0xfU << MIDR_ARCHITECTURE_SHIFT) | \
|
|
||||||
((partnum) << MIDR_PARTNUM_SHIFT))
|
|
||||||
|
|
||||||
# define MIDR_IS_CPU_MODEL(midr, imp, partnum) \
|
|
||||||
(((midr) & MIDR_CPU_MODEL_MASK) == MIDR_CPU_MODEL(imp, partnum))
|
|
||||||
|
|
||||||
#if defined(__ASSEMBLER__)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Support macros for
|
|
||||||
* - Armv8.3-A Pointer Authentication and
|
|
||||||
* - Armv8.5-A Branch Target Identification
|
|
||||||
* features which require emitting a .note.gnu.property section with the
|
|
||||||
* appropriate architecture-dependent feature bits set.
|
|
||||||
* Read more: "ELF for the Arm® 64-bit Architecture"
|
|
||||||
*/
|
|
||||||
|
|
||||||
# if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1
|
|
||||||
# define GNU_PROPERTY_AARCH64_BTI (1 << 0) /* Has Branch Target Identification */
|
|
||||||
# define AARCH64_VALID_CALL_TARGET hint #34 /* BTI 'c' */
|
|
||||||
# else
|
|
||||||
# define GNU_PROPERTY_AARCH64_BTI 0 /* No Branch Target Identification */
|
|
||||||
# define AARCH64_VALID_CALL_TARGET
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# if defined(__ARM_FEATURE_PAC_DEFAULT) && \
|
|
||||||
(__ARM_FEATURE_PAC_DEFAULT & 1) == 1 /* Signed with A-key */
|
|
||||||
# define GNU_PROPERTY_AARCH64_POINTER_AUTH \
|
|
||||||
(1 << 1) /* Has Pointer Authentication */
|
|
||||||
# define AARCH64_SIGN_LINK_REGISTER hint #25 /* PACIASP */
|
|
||||||
# define AARCH64_VALIDATE_LINK_REGISTER hint #29 /* AUTIASP */
|
|
||||||
# elif defined(__ARM_FEATURE_PAC_DEFAULT) && \
|
|
||||||
(__ARM_FEATURE_PAC_DEFAULT & 2) == 2 /* Signed with B-key */
|
|
||||||
# define GNU_PROPERTY_AARCH64_POINTER_AUTH \
|
|
||||||
(1 << 1) /* Has Pointer Authentication */
|
|
||||||
# define AARCH64_SIGN_LINK_REGISTER hint #27 /* PACIBSP */
|
|
||||||
# define AARCH64_VALIDATE_LINK_REGISTER hint #31 /* AUTIBSP */
|
|
||||||
# else
|
|
||||||
# define GNU_PROPERTY_AARCH64_POINTER_AUTH 0 /* No Pointer Authentication */
|
|
||||||
# if GNU_PROPERTY_AARCH64_BTI != 0
|
|
||||||
# define AARCH64_SIGN_LINK_REGISTER AARCH64_VALID_CALL_TARGET
|
|
||||||
# else
|
|
||||||
# define AARCH64_SIGN_LINK_REGISTER
|
|
||||||
# endif
|
|
||||||
# define AARCH64_VALIDATE_LINK_REGISTER
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# if GNU_PROPERTY_AARCH64_POINTER_AUTH != 0 || GNU_PROPERTY_AARCH64_BTI != 0
|
|
||||||
.pushsection .note.gnu.property, "a";
|
|
||||||
.balign 8;
|
|
||||||
.long 4;
|
|
||||||
.long 0x10;
|
|
||||||
.long 0x5;
|
|
||||||
.asciz "GNU";
|
|
||||||
.long 0xc0000000; /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */
|
|
||||||
.long 4;
|
|
||||||
.long (GNU_PROPERTY_AARCH64_POINTER_AUTH | GNU_PROPERTY_AARCH64_BTI);
|
|
||||||
.long 0;
|
|
||||||
.popsection;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# endif /* defined __ASSEMBLER__ */
|
|
||||||
|
|
||||||
# define IS_CPU_SUPPORT_UNROLL8_EOR3() \
|
|
||||||
(OPENSSL_armcap_P & ARMV8_UNROLL8_EOR3)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015-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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* This must be the first #include file */
|
|
||||||
#include "../async_local.h"
|
|
||||||
|
|
||||||
#ifdef ASYNC_POSIX
|
|
||||||
|
|
||||||
# include <stddef.h>
|
|
||||||
# include <unistd.h>
|
|
||||||
|
|
||||||
#define STACKSIZE 32768
|
|
||||||
|
|
||||||
int ASYNC_is_capable(void)
|
|
||||||
{
|
|
||||||
ucontext_t ctx;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Some platforms provide getcontext() but it does not work (notably
|
|
||||||
* MacOSX PPC64). Check for a working getcontext();
|
|
||||||
*/
|
|
||||||
return getcontext(&ctx) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void async_local_cleanup(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int async_fibre_makecontext(async_fibre *fibre)
|
|
||||||
{
|
|
||||||
#ifndef USE_SWAPCONTEXT
|
|
||||||
fibre->env_init = 0;
|
|
||||||
#endif
|
|
||||||
if (getcontext(&fibre->fibre) == 0) {
|
|
||||||
fibre->fibre.uc_stack.ss_sp = OPENSSL_malloc(STACKSIZE);
|
|
||||||
if (fibre->fibre.uc_stack.ss_sp != NULL) {
|
|
||||||
fibre->fibre.uc_stack.ss_size = STACKSIZE;
|
|
||||||
fibre->fibre.uc_link = NULL;
|
|
||||||
makecontext(&fibre->fibre, async_start_func, 0);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fibre->fibre.uc_stack.ss_sp = NULL;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void async_fibre_free(async_fibre *fibre)
|
|
||||||
{
|
|
||||||
OPENSSL_free(fibre->fibre.uc_stack.ss_sp);
|
|
||||||
fibre->fibre.uc_stack.ss_sp = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
LIBS=../../libcrypto
|
|
||||||
SOURCE[../../libcrypto]= cmp_asn.c cmp_ctx.c cmp_err.c cmp_util.c \
|
|
||||||
cmp_status.c cmp_hdr.c cmp_protect.c cmp_msg.c cmp_vfy.c \
|
|
||||||
cmp_server.c cmp_client.c cmp_http.c
|
|
||||||
@@ -1,459 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2007-2023 The OpenSSL Project Authors. All Rights Reserved.
|
|
||||||
* Copyright Nokia 2007-2019
|
|
||||||
* Copyright Siemens AG 2015-2019
|
|
||||||
*
|
|
||||||
* 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 <openssl/asn1t.h>
|
|
||||||
|
|
||||||
#include "cmp_local.h"
|
|
||||||
|
|
||||||
/* explicit #includes not strictly needed since implied by the above: */
|
|
||||||
#include <openssl/cmp.h>
|
|
||||||
#include <openssl/crmf.h>
|
|
||||||
|
|
||||||
/* ASN.1 declarations from RFC4210 */
|
|
||||||
ASN1_SEQUENCE(OSSL_CMP_REVANNCONTENT) = {
|
|
||||||
/* OSSL_CMP_PKISTATUS is effectively ASN1_INTEGER so it is used directly */
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_REVANNCONTENT, status, ASN1_INTEGER),
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_REVANNCONTENT, certId, OSSL_CRMF_CERTID),
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_REVANNCONTENT, willBeRevokedAt, ASN1_GENERALIZEDTIME),
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_REVANNCONTENT, badSinceDate, ASN1_GENERALIZEDTIME),
|
|
||||||
ASN1_OPT(OSSL_CMP_REVANNCONTENT, crlDetails, X509_EXTENSIONS)
|
|
||||||
} ASN1_SEQUENCE_END(OSSL_CMP_REVANNCONTENT)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_REVANNCONTENT)
|
|
||||||
|
|
||||||
|
|
||||||
ASN1_SEQUENCE(OSSL_CMP_CHALLENGE) = {
|
|
||||||
ASN1_OPT(OSSL_CMP_CHALLENGE, owf, X509_ALGOR),
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_CHALLENGE, witness, ASN1_OCTET_STRING),
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_CHALLENGE, challenge, ASN1_OCTET_STRING)
|
|
||||||
} ASN1_SEQUENCE_END(OSSL_CMP_CHALLENGE)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CHALLENGE)
|
|
||||||
|
|
||||||
|
|
||||||
ASN1_ITEM_TEMPLATE(OSSL_CMP_POPODECKEYCHALLCONTENT) =
|
|
||||||
ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
|
|
||||||
OSSL_CMP_POPODECKEYCHALLCONTENT, OSSL_CMP_CHALLENGE)
|
|
||||||
ASN1_ITEM_TEMPLATE_END(OSSL_CMP_POPODECKEYCHALLCONTENT)
|
|
||||||
|
|
||||||
|
|
||||||
ASN1_ITEM_TEMPLATE(OSSL_CMP_POPODECKEYRESPCONTENT) =
|
|
||||||
ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
|
|
||||||
OSSL_CMP_POPODECKEYRESPCONTENT, ASN1_INTEGER)
|
|
||||||
ASN1_ITEM_TEMPLATE_END(OSSL_CMP_POPODECKEYRESPCONTENT)
|
|
||||||
|
|
||||||
|
|
||||||
ASN1_SEQUENCE(OSSL_CMP_CAKEYUPDANNCONTENT) = {
|
|
||||||
/* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_CAKEYUPDANNCONTENT, oldWithNew, X509),
|
|
||||||
/* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_CAKEYUPDANNCONTENT, newWithOld, X509),
|
|
||||||
/* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_CAKEYUPDANNCONTENT, newWithNew, X509)
|
|
||||||
} ASN1_SEQUENCE_END(OSSL_CMP_CAKEYUPDANNCONTENT)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CAKEYUPDANNCONTENT)
|
|
||||||
|
|
||||||
|
|
||||||
ASN1_SEQUENCE(OSSL_CMP_ERRORMSGCONTENT) = {
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_ERRORMSGCONTENT, pKIStatusInfo, OSSL_CMP_PKISI),
|
|
||||||
ASN1_OPT(OSSL_CMP_ERRORMSGCONTENT, errorCode, ASN1_INTEGER),
|
|
||||||
/*
|
|
||||||
* OSSL_CMP_PKIFREETEXT is effectively a sequence of ASN1_UTF8STRING
|
|
||||||
* so it is used directly
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ERRORMSGCONTENT, errorDetails,
|
|
||||||
ASN1_UTF8STRING)
|
|
||||||
} ASN1_SEQUENCE_END(OSSL_CMP_ERRORMSGCONTENT)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_ERRORMSGCONTENT)
|
|
||||||
|
|
||||||
ASN1_ADB_TEMPLATE(infotypeandvalue_default) = ASN1_OPT(OSSL_CMP_ITAV,
|
|
||||||
infoValue.other,
|
|
||||||
ASN1_ANY);
|
|
||||||
/* ITAV means InfoTypeAndValue */
|
|
||||||
ASN1_ADB(OSSL_CMP_ITAV) = {
|
|
||||||
/* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
|
|
||||||
ADB_ENTRY(NID_id_it_caProtEncCert, ASN1_OPT(OSSL_CMP_ITAV,
|
|
||||||
infoValue.caProtEncCert, X509)),
|
|
||||||
ADB_ENTRY(NID_id_it_signKeyPairTypes,
|
|
||||||
ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ITAV,
|
|
||||||
infoValue.signKeyPairTypes, X509_ALGOR)),
|
|
||||||
ADB_ENTRY(NID_id_it_encKeyPairTypes,
|
|
||||||
ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ITAV,
|
|
||||||
infoValue.encKeyPairTypes, X509_ALGOR)),
|
|
||||||
ADB_ENTRY(NID_id_it_preferredSymmAlg,
|
|
||||||
ASN1_OPT(OSSL_CMP_ITAV, infoValue.preferredSymmAlg,
|
|
||||||
X509_ALGOR)),
|
|
||||||
ADB_ENTRY(NID_id_it_caKeyUpdateInfo,
|
|
||||||
ASN1_OPT(OSSL_CMP_ITAV, infoValue.caKeyUpdateInfo,
|
|
||||||
OSSL_CMP_CAKEYUPDANNCONTENT)),
|
|
||||||
ADB_ENTRY(NID_id_it_currentCRL,
|
|
||||||
ASN1_OPT(OSSL_CMP_ITAV, infoValue.currentCRL, X509_CRL)),
|
|
||||||
ADB_ENTRY(NID_id_it_unsupportedOIDs,
|
|
||||||
ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ITAV,
|
|
||||||
infoValue.unsupportedOIDs, ASN1_OBJECT)),
|
|
||||||
ADB_ENTRY(NID_id_it_keyPairParamReq,
|
|
||||||
ASN1_OPT(OSSL_CMP_ITAV, infoValue.keyPairParamReq,
|
|
||||||
ASN1_OBJECT)),
|
|
||||||
ADB_ENTRY(NID_id_it_keyPairParamRep,
|
|
||||||
ASN1_OPT(OSSL_CMP_ITAV, infoValue.keyPairParamRep,
|
|
||||||
X509_ALGOR)),
|
|
||||||
ADB_ENTRY(NID_id_it_revPassphrase,
|
|
||||||
ASN1_OPT(OSSL_CMP_ITAV, infoValue.revPassphrase,
|
|
||||||
OSSL_CRMF_ENCRYPTEDVALUE)),
|
|
||||||
ADB_ENTRY(NID_id_it_implicitConfirm,
|
|
||||||
ASN1_OPT(OSSL_CMP_ITAV, infoValue.implicitConfirm,
|
|
||||||
ASN1_NULL)),
|
|
||||||
ADB_ENTRY(NID_id_it_confirmWaitTime,
|
|
||||||
ASN1_OPT(OSSL_CMP_ITAV, infoValue.confirmWaitTime,
|
|
||||||
ASN1_GENERALIZEDTIME)),
|
|
||||||
ADB_ENTRY(NID_id_it_origPKIMessage,
|
|
||||||
ASN1_OPT(OSSL_CMP_ITAV, infoValue.origPKIMessage,
|
|
||||||
OSSL_CMP_MSGS)),
|
|
||||||
ADB_ENTRY(NID_id_it_suppLangTags,
|
|
||||||
ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ITAV, infoValue.suppLangTagsValue,
|
|
||||||
ASN1_UTF8STRING)),
|
|
||||||
} ASN1_ADB_END(OSSL_CMP_ITAV, 0, infoType, 0,
|
|
||||||
&infotypeandvalue_default_tt, NULL);
|
|
||||||
|
|
||||||
|
|
||||||
ASN1_SEQUENCE(OSSL_CMP_ITAV) = {
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_ITAV, infoType, ASN1_OBJECT),
|
|
||||||
ASN1_ADB_OBJECT(OSSL_CMP_ITAV)
|
|
||||||
} ASN1_SEQUENCE_END(OSSL_CMP_ITAV)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_ITAV)
|
|
||||||
IMPLEMENT_ASN1_DUP_FUNCTION(OSSL_CMP_ITAV)
|
|
||||||
|
|
||||||
OSSL_CMP_ITAV *OSSL_CMP_ITAV_create(ASN1_OBJECT *type, ASN1_TYPE *value)
|
|
||||||
{
|
|
||||||
OSSL_CMP_ITAV *itav;
|
|
||||||
|
|
||||||
if (type == NULL || (itav = OSSL_CMP_ITAV_new()) == NULL)
|
|
||||||
return NULL;
|
|
||||||
OSSL_CMP_ITAV_set0(itav, type, value);
|
|
||||||
return itav;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OSSL_CMP_ITAV_set0(OSSL_CMP_ITAV *itav, ASN1_OBJECT *type,
|
|
||||||
ASN1_TYPE *value)
|
|
||||||
{
|
|
||||||
itav->infoType = type;
|
|
||||||
itav->infoValue.other = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASN1_OBJECT *OSSL_CMP_ITAV_get0_type(const OSSL_CMP_ITAV *itav)
|
|
||||||
{
|
|
||||||
if (itav == NULL)
|
|
||||||
return NULL;
|
|
||||||
return itav->infoType;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASN1_TYPE *OSSL_CMP_ITAV_get0_value(const OSSL_CMP_ITAV *itav)
|
|
||||||
{
|
|
||||||
if (itav == NULL)
|
|
||||||
return NULL;
|
|
||||||
return itav->infoValue.other;
|
|
||||||
}
|
|
||||||
|
|
||||||
int OSSL_CMP_ITAV_push0_stack_item(STACK_OF(OSSL_CMP_ITAV) **itav_sk_p,
|
|
||||||
OSSL_CMP_ITAV *itav)
|
|
||||||
{
|
|
||||||
int created = 0;
|
|
||||||
|
|
||||||
if (itav_sk_p == NULL || itav == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*itav_sk_p == NULL) {
|
|
||||||
if ((*itav_sk_p = sk_OSSL_CMP_ITAV_new_null()) == NULL)
|
|
||||||
goto err;
|
|
||||||
created = 1;
|
|
||||||
}
|
|
||||||
if (!sk_OSSL_CMP_ITAV_push(*itav_sk_p, itav))
|
|
||||||
goto err;
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
err:
|
|
||||||
if (created != 0) {
|
|
||||||
sk_OSSL_CMP_ITAV_free(*itav_sk_p);
|
|
||||||
*itav_sk_p = NULL;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get ASN.1 encoded integer, return -2 on error; -1 is valid for certReqId */
|
|
||||||
int ossl_cmp_asn1_get_int(const ASN1_INTEGER *a)
|
|
||||||
{
|
|
||||||
int64_t res;
|
|
||||||
|
|
||||||
if (!ASN1_INTEGER_get_int64(&res, a)) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, ASN1_R_INVALID_NUMBER);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
if (res < INT_MIN) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, ASN1_R_TOO_SMALL);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
if (res > INT_MAX) {
|
|
||||||
ERR_raise(ERR_LIB_CMP, ASN1_R_TOO_LARGE);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
return (int)res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ossl_cmp_msg_cb(int operation, ASN1_VALUE **pval,
|
|
||||||
const ASN1_ITEM *it, void *exarg)
|
|
||||||
{
|
|
||||||
OSSL_CMP_MSG *msg = (OSSL_CMP_MSG *)*pval;
|
|
||||||
|
|
||||||
switch (operation) {
|
|
||||||
case ASN1_OP_FREE_POST:
|
|
||||||
OPENSSL_free(msg->propq);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ASN1_OP_DUP_POST:
|
|
||||||
{
|
|
||||||
OSSL_CMP_MSG *old = exarg;
|
|
||||||
|
|
||||||
if (!ossl_cmp_msg_set0_libctx(msg, old->libctx, old->propq))
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ASN1_OP_GET0_LIBCTX:
|
|
||||||
{
|
|
||||||
OSSL_LIB_CTX **libctx = exarg;
|
|
||||||
|
|
||||||
*libctx = msg->libctx;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ASN1_OP_GET0_PROPQ:
|
|
||||||
{
|
|
||||||
const char **propq = exarg;
|
|
||||||
|
|
||||||
*propq = msg->propq;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASN1_CHOICE(OSSL_CMP_CERTORENCCERT) = {
|
|
||||||
/* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
|
|
||||||
ASN1_EXP(OSSL_CMP_CERTORENCCERT, value.certificate, X509, 0),
|
|
||||||
ASN1_EXP(OSSL_CMP_CERTORENCCERT, value.encryptedCert,
|
|
||||||
OSSL_CRMF_ENCRYPTEDVALUE, 1),
|
|
||||||
} ASN1_CHOICE_END(OSSL_CMP_CERTORENCCERT)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTORENCCERT)
|
|
||||||
|
|
||||||
|
|
||||||
ASN1_SEQUENCE(OSSL_CMP_CERTIFIEDKEYPAIR) = {
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_CERTIFIEDKEYPAIR, certOrEncCert,
|
|
||||||
OSSL_CMP_CERTORENCCERT),
|
|
||||||
ASN1_EXP_OPT(OSSL_CMP_CERTIFIEDKEYPAIR, privateKey,
|
|
||||||
OSSL_CRMF_ENCRYPTEDVALUE, 0),
|
|
||||||
ASN1_EXP_OPT(OSSL_CMP_CERTIFIEDKEYPAIR, publicationInfo,
|
|
||||||
OSSL_CRMF_PKIPUBLICATIONINFO, 1)
|
|
||||||
} ASN1_SEQUENCE_END(OSSL_CMP_CERTIFIEDKEYPAIR)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTIFIEDKEYPAIR)
|
|
||||||
|
|
||||||
|
|
||||||
ASN1_SEQUENCE(OSSL_CMP_REVDETAILS) = {
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_REVDETAILS, certDetails, OSSL_CRMF_CERTTEMPLATE),
|
|
||||||
ASN1_OPT(OSSL_CMP_REVDETAILS, crlEntryDetails, X509_EXTENSIONS)
|
|
||||||
} ASN1_SEQUENCE_END(OSSL_CMP_REVDETAILS)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_REVDETAILS)
|
|
||||||
|
|
||||||
|
|
||||||
ASN1_ITEM_TEMPLATE(OSSL_CMP_REVREQCONTENT) =
|
|
||||||
ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_REVREQCONTENT,
|
|
||||||
OSSL_CMP_REVDETAILS)
|
|
||||||
ASN1_ITEM_TEMPLATE_END(OSSL_CMP_REVREQCONTENT)
|
|
||||||
|
|
||||||
|
|
||||||
ASN1_SEQUENCE(OSSL_CMP_REVREPCONTENT) = {
|
|
||||||
ASN1_SEQUENCE_OF(OSSL_CMP_REVREPCONTENT, status, OSSL_CMP_PKISI),
|
|
||||||
ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_REVREPCONTENT, revCerts, OSSL_CRMF_CERTID,
|
|
||||||
0),
|
|
||||||
ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_REVREPCONTENT, crls, X509_CRL, 1)
|
|
||||||
} ASN1_SEQUENCE_END(OSSL_CMP_REVREPCONTENT)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_REVREPCONTENT)
|
|
||||||
|
|
||||||
|
|
||||||
ASN1_SEQUENCE(OSSL_CMP_KEYRECREPCONTENT) = {
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_KEYRECREPCONTENT, status, OSSL_CMP_PKISI),
|
|
||||||
ASN1_EXP_OPT(OSSL_CMP_KEYRECREPCONTENT, newSigCert, X509, 0),
|
|
||||||
ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_KEYRECREPCONTENT, caCerts, X509, 1),
|
|
||||||
ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_KEYRECREPCONTENT, keyPairHist,
|
|
||||||
OSSL_CMP_CERTIFIEDKEYPAIR, 2)
|
|
||||||
} ASN1_SEQUENCE_END(OSSL_CMP_KEYRECREPCONTENT)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_KEYRECREPCONTENT)
|
|
||||||
|
|
||||||
|
|
||||||
ASN1_ITEM_TEMPLATE(OSSL_CMP_PKISTATUS) =
|
|
||||||
ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_UNIVERSAL, 0, status, ASN1_INTEGER)
|
|
||||||
ASN1_ITEM_TEMPLATE_END(OSSL_CMP_PKISTATUS)
|
|
||||||
|
|
||||||
ASN1_SEQUENCE(OSSL_CMP_PKISI) = {
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_PKISI, status, OSSL_CMP_PKISTATUS),
|
|
||||||
/*
|
|
||||||
* CMP_PKIFREETEXT is effectively a sequence of ASN1_UTF8STRING
|
|
||||||
* so it is used directly
|
|
||||||
*/
|
|
||||||
ASN1_SEQUENCE_OF_OPT(OSSL_CMP_PKISI, statusString, ASN1_UTF8STRING),
|
|
||||||
/*
|
|
||||||
* OSSL_CMP_PKIFAILUREINFO is effectively ASN1_BIT_STRING so used directly
|
|
||||||
*/
|
|
||||||
ASN1_OPT(OSSL_CMP_PKISI, failInfo, ASN1_BIT_STRING)
|
|
||||||
} ASN1_SEQUENCE_END(OSSL_CMP_PKISI)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_PKISI)
|
|
||||||
IMPLEMENT_ASN1_DUP_FUNCTION(OSSL_CMP_PKISI)
|
|
||||||
|
|
||||||
ASN1_SEQUENCE(OSSL_CMP_CERTSTATUS) = {
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_CERTSTATUS, certHash, ASN1_OCTET_STRING),
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_CERTSTATUS, certReqId, ASN1_INTEGER),
|
|
||||||
ASN1_OPT(OSSL_CMP_CERTSTATUS, statusInfo, OSSL_CMP_PKISI)
|
|
||||||
} ASN1_SEQUENCE_END(OSSL_CMP_CERTSTATUS)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTSTATUS)
|
|
||||||
|
|
||||||
ASN1_ITEM_TEMPLATE(OSSL_CMP_CERTCONFIRMCONTENT) =
|
|
||||||
ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_CERTCONFIRMCONTENT,
|
|
||||||
OSSL_CMP_CERTSTATUS)
|
|
||||||
ASN1_ITEM_TEMPLATE_END(OSSL_CMP_CERTCONFIRMCONTENT)
|
|
||||||
|
|
||||||
ASN1_SEQUENCE(OSSL_CMP_CERTRESPONSE) = {
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_CERTRESPONSE, certReqId, ASN1_INTEGER),
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_CERTRESPONSE, status, OSSL_CMP_PKISI),
|
|
||||||
ASN1_OPT(OSSL_CMP_CERTRESPONSE, certifiedKeyPair,
|
|
||||||
OSSL_CMP_CERTIFIEDKEYPAIR),
|
|
||||||
ASN1_OPT(OSSL_CMP_CERTRESPONSE, rspInfo, ASN1_OCTET_STRING)
|
|
||||||
} ASN1_SEQUENCE_END(OSSL_CMP_CERTRESPONSE)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTRESPONSE)
|
|
||||||
|
|
||||||
ASN1_SEQUENCE(OSSL_CMP_POLLREQ) = {
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_POLLREQ, certReqId, ASN1_INTEGER)
|
|
||||||
} ASN1_SEQUENCE_END(OSSL_CMP_POLLREQ)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_POLLREQ)
|
|
||||||
|
|
||||||
ASN1_ITEM_TEMPLATE(OSSL_CMP_POLLREQCONTENT) =
|
|
||||||
ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_POLLREQCONTENT,
|
|
||||||
OSSL_CMP_POLLREQ)
|
|
||||||
ASN1_ITEM_TEMPLATE_END(OSSL_CMP_POLLREQCONTENT)
|
|
||||||
|
|
||||||
ASN1_SEQUENCE(OSSL_CMP_POLLREP) = {
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_POLLREP, certReqId, ASN1_INTEGER),
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_POLLREP, checkAfter, ASN1_INTEGER),
|
|
||||||
ASN1_SEQUENCE_OF_OPT(OSSL_CMP_POLLREP, reason, ASN1_UTF8STRING),
|
|
||||||
} ASN1_SEQUENCE_END(OSSL_CMP_POLLREP)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_POLLREP)
|
|
||||||
|
|
||||||
ASN1_ITEM_TEMPLATE(OSSL_CMP_POLLREPCONTENT) =
|
|
||||||
ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
|
|
||||||
OSSL_CMP_POLLREPCONTENT,
|
|
||||||
OSSL_CMP_POLLREP)
|
|
||||||
ASN1_ITEM_TEMPLATE_END(OSSL_CMP_POLLREPCONTENT)
|
|
||||||
|
|
||||||
ASN1_SEQUENCE(OSSL_CMP_CERTREPMESSAGE) = {
|
|
||||||
/* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
|
|
||||||
ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_CERTREPMESSAGE, caPubs, X509, 1),
|
|
||||||
ASN1_SEQUENCE_OF(OSSL_CMP_CERTREPMESSAGE, response, OSSL_CMP_CERTRESPONSE)
|
|
||||||
} ASN1_SEQUENCE_END(OSSL_CMP_CERTREPMESSAGE)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTREPMESSAGE)
|
|
||||||
|
|
||||||
ASN1_ITEM_TEMPLATE(OSSL_CMP_GENMSGCONTENT) =
|
|
||||||
ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_GENMSGCONTENT,
|
|
||||||
OSSL_CMP_ITAV)
|
|
||||||
ASN1_ITEM_TEMPLATE_END(OSSL_CMP_GENMSGCONTENT)
|
|
||||||
|
|
||||||
ASN1_ITEM_TEMPLATE(OSSL_CMP_GENREPCONTENT) =
|
|
||||||
ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_GENREPCONTENT,
|
|
||||||
OSSL_CMP_ITAV)
|
|
||||||
ASN1_ITEM_TEMPLATE_END(OSSL_CMP_GENREPCONTENT)
|
|
||||||
|
|
||||||
ASN1_ITEM_TEMPLATE(OSSL_CMP_CRLANNCONTENT) =
|
|
||||||
ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
|
|
||||||
OSSL_CMP_CRLANNCONTENT, X509_CRL)
|
|
||||||
ASN1_ITEM_TEMPLATE_END(OSSL_CMP_CRLANNCONTENT)
|
|
||||||
|
|
||||||
ASN1_CHOICE(OSSL_CMP_PKIBODY) = {
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.ir, OSSL_CRMF_MSGS, 0),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.ip, OSSL_CMP_CERTREPMESSAGE, 1),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.cr, OSSL_CRMF_MSGS, 2),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.cp, OSSL_CMP_CERTREPMESSAGE, 3),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.p10cr, X509_REQ, 4),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.popdecc,
|
|
||||||
OSSL_CMP_POPODECKEYCHALLCONTENT, 5),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.popdecr,
|
|
||||||
OSSL_CMP_POPODECKEYRESPCONTENT, 6),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.kur, OSSL_CRMF_MSGS, 7),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.kup, OSSL_CMP_CERTREPMESSAGE, 8),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.krr, OSSL_CRMF_MSGS, 9),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.krp, OSSL_CMP_KEYRECREPCONTENT, 10),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.rr, OSSL_CMP_REVREQCONTENT, 11),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.rp, OSSL_CMP_REVREPCONTENT, 12),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.ccr, OSSL_CRMF_MSGS, 13),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.ccp, OSSL_CMP_CERTREPMESSAGE, 14),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.ckuann, OSSL_CMP_CAKEYUPDANNCONTENT, 15),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.cann, X509, 16),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.rann, OSSL_CMP_REVANNCONTENT, 17),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.crlann, OSSL_CMP_CRLANNCONTENT, 18),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.pkiconf, ASN1_ANY, 19),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.nested, OSSL_CMP_MSGS, 20),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.genm, OSSL_CMP_GENMSGCONTENT, 21),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.genp, OSSL_CMP_GENREPCONTENT, 22),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.error, OSSL_CMP_ERRORMSGCONTENT, 23),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.certConf, OSSL_CMP_CERTCONFIRMCONTENT, 24),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.pollReq, OSSL_CMP_POLLREQCONTENT, 25),
|
|
||||||
ASN1_EXP(OSSL_CMP_PKIBODY, value.pollRep, OSSL_CMP_POLLREPCONTENT, 26),
|
|
||||||
} ASN1_CHOICE_END(OSSL_CMP_PKIBODY)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_PKIBODY)
|
|
||||||
|
|
||||||
ASN1_SEQUENCE(OSSL_CMP_PKIHEADER) = {
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_PKIHEADER, pvno, ASN1_INTEGER),
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_PKIHEADER, sender, GENERAL_NAME),
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_PKIHEADER, recipient, GENERAL_NAME),
|
|
||||||
ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, messageTime, ASN1_GENERALIZEDTIME, 0),
|
|
||||||
ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, protectionAlg, X509_ALGOR, 1),
|
|
||||||
ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, senderKID, ASN1_OCTET_STRING, 2),
|
|
||||||
ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, recipKID, ASN1_OCTET_STRING, 3),
|
|
||||||
ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, transactionID, ASN1_OCTET_STRING, 4),
|
|
||||||
ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, senderNonce, ASN1_OCTET_STRING, 5),
|
|
||||||
ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, recipNonce, ASN1_OCTET_STRING, 6),
|
|
||||||
/*
|
|
||||||
* OSSL_CMP_PKIFREETEXT is effectively a sequence of ASN1_UTF8STRING
|
|
||||||
* so it is used directly
|
|
||||||
*/
|
|
||||||
ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_PKIHEADER, freeText, ASN1_UTF8STRING, 7),
|
|
||||||
ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_PKIHEADER, generalInfo,
|
|
||||||
OSSL_CMP_ITAV, 8)
|
|
||||||
} ASN1_SEQUENCE_END(OSSL_CMP_PKIHEADER)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_PKIHEADER)
|
|
||||||
|
|
||||||
ASN1_SEQUENCE(OSSL_CMP_PROTECTEDPART) = {
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_MSG, header, OSSL_CMP_PKIHEADER),
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_MSG, body, OSSL_CMP_PKIBODY)
|
|
||||||
} ASN1_SEQUENCE_END(OSSL_CMP_PROTECTEDPART)
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_PROTECTEDPART)
|
|
||||||
|
|
||||||
ASN1_SEQUENCE_cb(OSSL_CMP_MSG, ossl_cmp_msg_cb) = {
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_MSG, header, OSSL_CMP_PKIHEADER),
|
|
||||||
ASN1_SIMPLE(OSSL_CMP_MSG, body, OSSL_CMP_PKIBODY),
|
|
||||||
ASN1_EXP_OPT(OSSL_CMP_MSG, protection, ASN1_BIT_STRING, 0),
|
|
||||||
/* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
|
|
||||||
ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_MSG, extraCerts, X509, 1)
|
|
||||||
} ASN1_SEQUENCE_END_cb(OSSL_CMP_MSG, OSSL_CMP_MSG)
|
|
||||||
IMPLEMENT_ASN1_DUP_FUNCTION(OSSL_CMP_MSG)
|
|
||||||
|
|
||||||
ASN1_ITEM_TEMPLATE(OSSL_CMP_MSGS) =
|
|
||||||
ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_MSGS,
|
|
||||||
OSSL_CMP_MSG)
|
|
||||||
ASN1_ITEM_TEMPLATE_END(OSSL_CMP_MSGS)
|
|
||||||
@@ -1,364 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 1995-2023 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DSA low level APIs are deprecated for public use, but still ok for
|
|
||||||
* internal use.
|
|
||||||
*/
|
|
||||||
#include "internal/deprecated.h"
|
|
||||||
|
|
||||||
#include <openssl/bn.h>
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
# include <openssl/engine.h>
|
|
||||||
#endif
|
|
||||||
#include "internal/cryptlib.h"
|
|
||||||
#include "internal/refcount.h"
|
|
||||||
#include "crypto/dsa.h"
|
|
||||||
#include "crypto/dh.h" /* required by DSA_dup_DH() */
|
|
||||||
#include "dsa_local.h"
|
|
||||||
|
|
||||||
static DSA *dsa_new_intern(ENGINE *engine, OSSL_LIB_CTX *libctx);
|
|
||||||
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
|
|
||||||
int DSA_set_ex_data(DSA *d, int idx, void *arg)
|
|
||||||
{
|
|
||||||
return CRYPTO_set_ex_data(&d->ex_data, idx, arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *DSA_get_ex_data(const DSA *d, int idx)
|
|
||||||
{
|
|
||||||
return CRYPTO_get_ex_data(&d->ex_data, idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DH
|
|
||||||
DH *DSA_dup_DH(const DSA *r)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* DSA has p, q, g, optional pub_key, optional priv_key.
|
|
||||||
* DH has p, optional length, g, optional pub_key,
|
|
||||||
* optional priv_key, optional q.
|
|
||||||
*/
|
|
||||||
DH *ret = NULL;
|
|
||||||
BIGNUM *pub_key = NULL, *priv_key = NULL;
|
|
||||||
|
|
||||||
if (r == NULL)
|
|
||||||
goto err;
|
|
||||||
ret = DH_new();
|
|
||||||
if (ret == NULL)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
if (!ossl_ffc_params_copy(ossl_dh_get0_params(ret), &r->params))
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
if (r->pub_key != NULL) {
|
|
||||||
pub_key = BN_dup(r->pub_key);
|
|
||||||
if (pub_key == NULL)
|
|
||||||
goto err;
|
|
||||||
if (r->priv_key != NULL) {
|
|
||||||
priv_key = BN_dup(r->priv_key);
|
|
||||||
if (priv_key == NULL)
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
if (!DH_set0_key(ret, pub_key, priv_key))
|
|
||||||
goto err;
|
|
||||||
} else if (r->priv_key != NULL) {
|
|
||||||
/* Shouldn't happen */
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
err:
|
|
||||||
BN_free(pub_key);
|
|
||||||
BN_free(priv_key);
|
|
||||||
DH_free(ret);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
# endif /* OPENSSL_NO_DH */
|
|
||||||
|
|
||||||
void DSA_clear_flags(DSA *d, int flags)
|
|
||||||
{
|
|
||||||
d->flags &= ~flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
int DSA_test_flags(const DSA *d, int flags)
|
|
||||||
{
|
|
||||||
return d->flags & flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DSA_set_flags(DSA *d, int flags)
|
|
||||||
{
|
|
||||||
d->flags |= flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
ENGINE *DSA_get0_engine(DSA *d)
|
|
||||||
{
|
|
||||||
return d->engine;
|
|
||||||
}
|
|
||||||
|
|
||||||
int DSA_set_method(DSA *dsa, const DSA_METHOD *meth)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* NB: The caller is specifically setting a method, so it's not up to us
|
|
||||||
* to deal with which ENGINE it comes from.
|
|
||||||
*/
|
|
||||||
const DSA_METHOD *mtmp;
|
|
||||||
mtmp = dsa->meth;
|
|
||||||
if (mtmp->finish)
|
|
||||||
mtmp->finish(dsa);
|
|
||||||
#ifndef OPENSSL_NO_ENGINE
|
|
||||||
ENGINE_finish(dsa->engine);
|
|
||||||
dsa->engine = NULL;
|
|
||||||
#endif
|
|
||||||
dsa->meth = meth;
|
|
||||||
if (meth->init)
|
|
||||||
meth->init(dsa);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif /* FIPS_MODULE */
|
|
||||||
|
|
||||||
|
|
||||||
const DSA_METHOD *DSA_get_method(DSA *d)
|
|
||||||
{
|
|
||||||
return d->meth;
|
|
||||||
}
|
|
||||||
|
|
||||||
static DSA *dsa_new_intern(ENGINE *engine, OSSL_LIB_CTX *libctx)
|
|
||||||
{
|
|
||||||
DSA *ret = OPENSSL_zalloc(sizeof(*ret));
|
|
||||||
|
|
||||||
if (ret == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_DSA, ERR_R_MALLOC_FAILURE);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret->references = 1;
|
|
||||||
ret->lock = CRYPTO_THREAD_lock_new();
|
|
||||||
if (ret->lock == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_DSA, ERR_R_MALLOC_FAILURE);
|
|
||||||
OPENSSL_free(ret);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret->libctx = libctx;
|
|
||||||
ret->meth = DSA_get_default_method();
|
|
||||||
#if !defined(FIPS_MODULE) && !defined(OPENSSL_NO_ENGINE)
|
|
||||||
ret->flags = ret->meth->flags & ~DSA_FLAG_NON_FIPS_ALLOW; /* early default init */
|
|
||||||
if (engine) {
|
|
||||||
if (!ENGINE_init(engine)) {
|
|
||||||
ERR_raise(ERR_LIB_DSA, ERR_R_ENGINE_LIB);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
ret->engine = engine;
|
|
||||||
} else
|
|
||||||
ret->engine = ENGINE_get_default_DSA();
|
|
||||||
if (ret->engine) {
|
|
||||||
ret->meth = ENGINE_get_DSA(ret->engine);
|
|
||||||
if (ret->meth == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_DSA, ERR_R_ENGINE_LIB);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret->flags = ret->meth->flags & ~DSA_FLAG_NON_FIPS_ALLOW;
|
|
||||||
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
if (!ossl_crypto_new_ex_data_ex(libctx, CRYPTO_EX_INDEX_DSA, ret,
|
|
||||||
&ret->ex_data))
|
|
||||||
goto err;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ossl_ffc_params_init(&ret->params);
|
|
||||||
|
|
||||||
if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
|
|
||||||
ERR_raise(ERR_LIB_DSA, ERR_R_INIT_FAIL);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
err:
|
|
||||||
DSA_free(ret);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
DSA *DSA_new_method(ENGINE *engine)
|
|
||||||
{
|
|
||||||
return dsa_new_intern(engine, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
DSA *ossl_dsa_new(OSSL_LIB_CTX *libctx)
|
|
||||||
{
|
|
||||||
return dsa_new_intern(NULL, libctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
DSA *DSA_new(void)
|
|
||||||
{
|
|
||||||
return dsa_new_intern(NULL, NULL);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void DSA_free(DSA *r)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (r == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
CRYPTO_DOWN_REF(&r->references, &i, r->lock);
|
|
||||||
REF_PRINT_COUNT("DSA", r);
|
|
||||||
if (i > 0)
|
|
||||||
return;
|
|
||||||
REF_ASSERT_ISNT(i < 0);
|
|
||||||
|
|
||||||
if (r->meth != NULL && r->meth->finish != NULL)
|
|
||||||
r->meth->finish(r);
|
|
||||||
#if !defined(FIPS_MODULE) && !defined(OPENSSL_NO_ENGINE)
|
|
||||||
ENGINE_finish(r->engine);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CRYPTO_THREAD_lock_free(r->lock);
|
|
||||||
|
|
||||||
ossl_ffc_params_cleanup(&r->params);
|
|
||||||
BN_clear_free(r->pub_key);
|
|
||||||
BN_clear_free(r->priv_key);
|
|
||||||
OPENSSL_free(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
int DSA_up_ref(DSA *r)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (CRYPTO_UP_REF(&r->references, &i, r->lock) <= 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
REF_PRINT_COUNT("DSA", r);
|
|
||||||
REF_ASSERT_ISNT(i < 2);
|
|
||||||
return ((i > 1) ? 1 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ossl_dsa_set0_libctx(DSA *d, OSSL_LIB_CTX *libctx)
|
|
||||||
{
|
|
||||||
d->libctx = libctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DSA_get0_pqg(const DSA *d,
|
|
||||||
const BIGNUM **p, const BIGNUM **q, const BIGNUM **g)
|
|
||||||
{
|
|
||||||
ossl_ffc_params_get0_pqg(&d->params, p, q, g);
|
|
||||||
}
|
|
||||||
|
|
||||||
int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g)
|
|
||||||
{
|
|
||||||
/* If the fields p, q and g in d are NULL, the corresponding input
|
|
||||||
* parameters MUST be non-NULL.
|
|
||||||
*/
|
|
||||||
if ((d->params.p == NULL && p == NULL)
|
|
||||||
|| (d->params.q == NULL && q == NULL)
|
|
||||||
|| (d->params.g == NULL && g == NULL))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ossl_ffc_params_set0_pqg(&d->params, p, q, g);
|
|
||||||
d->dirty_cnt++;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const BIGNUM *DSA_get0_p(const DSA *d)
|
|
||||||
{
|
|
||||||
return d->params.p;
|
|
||||||
}
|
|
||||||
|
|
||||||
const BIGNUM *DSA_get0_q(const DSA *d)
|
|
||||||
{
|
|
||||||
return d->params.q;
|
|
||||||
}
|
|
||||||
|
|
||||||
const BIGNUM *DSA_get0_g(const DSA *d)
|
|
||||||
{
|
|
||||||
return d->params.g;
|
|
||||||
}
|
|
||||||
|
|
||||||
const BIGNUM *DSA_get0_pub_key(const DSA *d)
|
|
||||||
{
|
|
||||||
return d->pub_key;
|
|
||||||
}
|
|
||||||
|
|
||||||
const BIGNUM *DSA_get0_priv_key(const DSA *d)
|
|
||||||
{
|
|
||||||
return d->priv_key;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DSA_get0_key(const DSA *d,
|
|
||||||
const BIGNUM **pub_key, const BIGNUM **priv_key)
|
|
||||||
{
|
|
||||||
if (pub_key != NULL)
|
|
||||||
*pub_key = d->pub_key;
|
|
||||||
if (priv_key != NULL)
|
|
||||||
*priv_key = d->priv_key;
|
|
||||||
}
|
|
||||||
|
|
||||||
int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key)
|
|
||||||
{
|
|
||||||
if (pub_key != NULL) {
|
|
||||||
BN_free(d->pub_key);
|
|
||||||
d->pub_key = pub_key;
|
|
||||||
}
|
|
||||||
if (priv_key != NULL) {
|
|
||||||
BN_free(d->priv_key);
|
|
||||||
d->priv_key = priv_key;
|
|
||||||
}
|
|
||||||
d->dirty_cnt++;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int DSA_security_bits(const DSA *d)
|
|
||||||
{
|
|
||||||
if (d->params.p != NULL && d->params.q != NULL)
|
|
||||||
return BN_security_bits(BN_num_bits(d->params.p),
|
|
||||||
BN_num_bits(d->params.q));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int DSA_bits(const DSA *dsa)
|
|
||||||
{
|
|
||||||
if (dsa->params.p != NULL)
|
|
||||||
return BN_num_bits(dsa->params.p);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
FFC_PARAMS *ossl_dsa_get0_params(DSA *dsa)
|
|
||||||
{
|
|
||||||
return &dsa->params;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_dsa_ffc_params_fromdata(DSA *dsa, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
FFC_PARAMS *ffc;
|
|
||||||
|
|
||||||
if (dsa == NULL)
|
|
||||||
return 0;
|
|
||||||
ffc = ossl_dsa_get0_params(dsa);
|
|
||||||
if (ffc == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ret = ossl_ffc_params_fromdata(ffc, params);
|
|
||||||
if (ret)
|
|
||||||
dsa->dirty_cnt++;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
-24
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017-2021 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
|
|
||||||
*/
|
|
||||||
#ifndef OSSL_CRYPTO_EC_CURVE448_LOCAL_H
|
|
||||||
# define OSSL_CRYPTO_EC_CURVE448_LOCAL_H
|
|
||||||
# include "curve448utils.h"
|
|
||||||
|
|
||||||
int
|
|
||||||
ossl_ed448ph_sign(OSSL_LIB_CTX *ctx, uint8_t *out_sig, const uint8_t hash[64],
|
|
||||||
const uint8_t public_key[57], const uint8_t private_key[57],
|
|
||||||
const uint8_t *context, size_t context_len, const char *propq);
|
|
||||||
|
|
||||||
int
|
|
||||||
ossl_ed448ph_verify(OSSL_LIB_CTX *ctx, const uint8_t hash[64],
|
|
||||||
const uint8_t signature[114], const uint8_t public_key[57],
|
|
||||||
const uint8_t *context, size_t context_len,
|
|
||||||
const char *propq);
|
|
||||||
|
|
||||||
#endif /* OSSL_CRYPTO_EC_CURVE448_LOCAL_H */
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020-2021 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/err.h>
|
|
||||||
#include "crypto/ecx.h"
|
|
||||||
|
|
||||||
ECX_KEY *ossl_ecx_key_new(OSSL_LIB_CTX *libctx, ECX_KEY_TYPE type, int haspubkey,
|
|
||||||
const char *propq)
|
|
||||||
{
|
|
||||||
ECX_KEY *ret = OPENSSL_zalloc(sizeof(*ret));
|
|
||||||
|
|
||||||
if (ret == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ret->libctx = libctx;
|
|
||||||
ret->haspubkey = haspubkey;
|
|
||||||
switch (type) {
|
|
||||||
case ECX_KEY_TYPE_X25519:
|
|
||||||
ret->keylen = X25519_KEYLEN;
|
|
||||||
break;
|
|
||||||
case ECX_KEY_TYPE_X448:
|
|
||||||
ret->keylen = X448_KEYLEN;
|
|
||||||
break;
|
|
||||||
case ECX_KEY_TYPE_ED25519:
|
|
||||||
ret->keylen = ED25519_KEYLEN;
|
|
||||||
break;
|
|
||||||
case ECX_KEY_TYPE_ED448:
|
|
||||||
ret->keylen = ED448_KEYLEN;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ret->type = type;
|
|
||||||
ret->references = 1;
|
|
||||||
|
|
||||||
if (propq != NULL) {
|
|
||||||
ret->propq = OPENSSL_strdup(propq);
|
|
||||||
if (ret->propq == NULL)
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret->lock = CRYPTO_THREAD_lock_new();
|
|
||||||
if (ret->lock == NULL)
|
|
||||||
goto err;
|
|
||||||
return ret;
|
|
||||||
err:
|
|
||||||
ERR_raise(ERR_LIB_EC, ERR_R_MALLOC_FAILURE);
|
|
||||||
OPENSSL_free(ret);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ossl_ecx_key_free(ECX_KEY *key)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (key == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
CRYPTO_DOWN_REF(&key->references, &i, key->lock);
|
|
||||||
REF_PRINT_COUNT("ECX_KEY", key);
|
|
||||||
if (i > 0)
|
|
||||||
return;
|
|
||||||
REF_ASSERT_ISNT(i < 0);
|
|
||||||
|
|
||||||
OPENSSL_free(key->propq);
|
|
||||||
OPENSSL_secure_clear_free(key->privkey, key->keylen);
|
|
||||||
CRYPTO_THREAD_lock_free(key->lock);
|
|
||||||
OPENSSL_free(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ossl_ecx_key_set0_libctx(ECX_KEY *key, OSSL_LIB_CTX *libctx)
|
|
||||||
{
|
|
||||||
key->libctx = libctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_ecx_key_up_ref(ECX_KEY *key)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (CRYPTO_UP_REF(&key->references, &i, key->lock) <= 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
REF_PRINT_COUNT("ECX_KEY", key);
|
|
||||||
REF_ASSERT_ISNT(i < 2);
|
|
||||||
return ((i > 1) ? 1 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char *ossl_ecx_key_allocate_privkey(ECX_KEY *key)
|
|
||||||
{
|
|
||||||
key->privkey = OPENSSL_secure_zalloc(key->keylen);
|
|
||||||
|
|
||||||
return key->privkey;
|
|
||||||
}
|
|
||||||
@@ -1,447 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2001-2023 The OpenSSL Project Authors. All Rights Reserved.
|
|
||||||
* Copyright (c) 2002, Oracle and/or its affiliates. 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* We need to use some engine deprecated APIs */
|
|
||||||
#define OPENSSL_SUPPRESS_DEPRECATED
|
|
||||||
|
|
||||||
#include "eng_local.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The linked-list of pointers to engine types. engine_list_head incorporates
|
|
||||||
* an implicit structural reference but engine_list_tail does not - the
|
|
||||||
* latter is a computational optimization and only points to something that
|
|
||||||
* is already pointed to by its predecessor in the list (or engine_list_head
|
|
||||||
* itself). In the same way, the use of the "prev" pointer in each ENGINE is
|
|
||||||
* to save excessive list iteration, it doesn't correspond to an extra
|
|
||||||
* structural reference. Hence, engine_list_head, and each non-null "next"
|
|
||||||
* pointer account for the list itself assuming exactly 1 structural
|
|
||||||
* reference on each list member.
|
|
||||||
*/
|
|
||||||
static ENGINE *engine_list_head = NULL;
|
|
||||||
static ENGINE *engine_list_tail = NULL;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The linked list of currently loaded dynamic engines.
|
|
||||||
*/
|
|
||||||
static ENGINE *engine_dyn_list_head = NULL;
|
|
||||||
static ENGINE *engine_dyn_list_tail = NULL;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This cleanup function is only needed internally. If it should be called,
|
|
||||||
* we register it with the "engine_cleanup_int()" stack to be called during
|
|
||||||
* cleanup.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void engine_list_cleanup(void)
|
|
||||||
{
|
|
||||||
ENGINE *iterator = engine_list_head;
|
|
||||||
|
|
||||||
while (iterator != NULL) {
|
|
||||||
ENGINE_remove(iterator);
|
|
||||||
iterator = engine_list_head;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These static functions starting with a lower case "engine_" always take
|
|
||||||
* place when global_engine_lock has been locked up.
|
|
||||||
*/
|
|
||||||
static int engine_list_add(ENGINE *e)
|
|
||||||
{
|
|
||||||
int conflict = 0;
|
|
||||||
ENGINE *iterator = NULL;
|
|
||||||
|
|
||||||
if (e == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ERR_R_PASSED_NULL_PARAMETER);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
iterator = engine_list_head;
|
|
||||||
while (iterator && !conflict) {
|
|
||||||
conflict = (strcmp(iterator->id, e->id) == 0);
|
|
||||||
iterator = iterator->next;
|
|
||||||
}
|
|
||||||
if (conflict) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ENGINE_R_CONFLICTING_ENGINE_ID);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (engine_list_head == NULL) {
|
|
||||||
/* We are adding to an empty list. */
|
|
||||||
if (engine_list_tail) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ENGINE_R_INTERNAL_LIST_ERROR);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* The first time the list allocates, we should register the cleanup.
|
|
||||||
*/
|
|
||||||
if (!engine_cleanup_add_last(engine_list_cleanup)) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ENGINE_R_INTERNAL_LIST_ERROR);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
engine_list_head = e;
|
|
||||||
e->prev = NULL;
|
|
||||||
} else {
|
|
||||||
/* We are adding to the tail of an existing list. */
|
|
||||||
if ((engine_list_tail == NULL) || (engine_list_tail->next != NULL)) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ENGINE_R_INTERNAL_LIST_ERROR);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
engine_list_tail->next = e;
|
|
||||||
e->prev = engine_list_tail;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Having the engine in the list assumes a structural reference.
|
|
||||||
*/
|
|
||||||
e->struct_ref++;
|
|
||||||
ENGINE_REF_PRINT(e, 0, 1);
|
|
||||||
/* However it came to be, e is the last item in the list. */
|
|
||||||
engine_list_tail = e;
|
|
||||||
e->next = NULL;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int engine_list_remove(ENGINE *e)
|
|
||||||
{
|
|
||||||
ENGINE *iterator;
|
|
||||||
|
|
||||||
if (e == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ERR_R_PASSED_NULL_PARAMETER);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/* We need to check that e is in our linked list! */
|
|
||||||
iterator = engine_list_head;
|
|
||||||
while (iterator && (iterator != e))
|
|
||||||
iterator = iterator->next;
|
|
||||||
if (iterator == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ENGINE_R_ENGINE_IS_NOT_IN_LIST);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/* un-link e from the chain. */
|
|
||||||
if (e->next)
|
|
||||||
e->next->prev = e->prev;
|
|
||||||
if (e->prev)
|
|
||||||
e->prev->next = e->next;
|
|
||||||
/* Correct our head/tail if necessary. */
|
|
||||||
if (engine_list_head == e)
|
|
||||||
engine_list_head = e->next;
|
|
||||||
if (engine_list_tail == e)
|
|
||||||
engine_list_tail = e->prev;
|
|
||||||
engine_free_util(e, 0);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add engine to dynamic engine list. */
|
|
||||||
int engine_add_dynamic_id(ENGINE *e, ENGINE_DYNAMIC_ID dynamic_id,
|
|
||||||
int not_locked)
|
|
||||||
{
|
|
||||||
int result = 0;
|
|
||||||
ENGINE *iterator = NULL;
|
|
||||||
|
|
||||||
if (e == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (e->dynamic_id == NULL && dynamic_id == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (not_locked && !CRYPTO_THREAD_write_lock(global_engine_lock))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (dynamic_id != NULL) {
|
|
||||||
iterator = engine_dyn_list_head;
|
|
||||||
while (iterator != NULL) {
|
|
||||||
if (iterator->dynamic_id == dynamic_id)
|
|
||||||
goto err;
|
|
||||||
iterator = iterator->next;
|
|
||||||
}
|
|
||||||
if (e->dynamic_id != NULL)
|
|
||||||
goto err;
|
|
||||||
e->dynamic_id = dynamic_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (engine_dyn_list_head == NULL) {
|
|
||||||
/* We are adding to an empty list. */
|
|
||||||
if (engine_dyn_list_tail != NULL)
|
|
||||||
goto err;
|
|
||||||
engine_dyn_list_head = e;
|
|
||||||
e->prev_dyn = NULL;
|
|
||||||
} else {
|
|
||||||
/* We are adding to the tail of an existing list. */
|
|
||||||
if (engine_dyn_list_tail == NULL
|
|
||||||
|| engine_dyn_list_tail->next_dyn != NULL)
|
|
||||||
goto err;
|
|
||||||
engine_dyn_list_tail->next_dyn = e;
|
|
||||||
e->prev_dyn = engine_dyn_list_tail;
|
|
||||||
}
|
|
||||||
|
|
||||||
engine_dyn_list_tail = e;
|
|
||||||
e->next_dyn = NULL;
|
|
||||||
result = 1;
|
|
||||||
|
|
||||||
err:
|
|
||||||
if (not_locked)
|
|
||||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove engine from dynamic engine list. */
|
|
||||||
void engine_remove_dynamic_id(ENGINE *e, int not_locked)
|
|
||||||
{
|
|
||||||
if (e == NULL || e->dynamic_id == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (not_locked && !CRYPTO_THREAD_write_lock(global_engine_lock))
|
|
||||||
return;
|
|
||||||
|
|
||||||
e->dynamic_id = NULL;
|
|
||||||
|
|
||||||
/* un-link e from the chain. */
|
|
||||||
if (e->next_dyn != NULL)
|
|
||||||
e->next_dyn->prev_dyn = e->prev_dyn;
|
|
||||||
if (e->prev_dyn != NULL)
|
|
||||||
e->prev_dyn->next_dyn = e->next_dyn;
|
|
||||||
/* Correct our head/tail if necessary. */
|
|
||||||
if (engine_dyn_list_head == e)
|
|
||||||
engine_dyn_list_head = e->next_dyn;
|
|
||||||
if (engine_dyn_list_tail == e)
|
|
||||||
engine_dyn_list_tail = e->prev_dyn;
|
|
||||||
|
|
||||||
if (not_locked)
|
|
||||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the first/last "ENGINE" type available. */
|
|
||||||
ENGINE *ENGINE_get_first(void)
|
|
||||||
{
|
|
||||||
ENGINE *ret;
|
|
||||||
|
|
||||||
if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ERR_R_MALLOC_FAILURE);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_write_lock(global_engine_lock))
|
|
||||||
return NULL;
|
|
||||||
ret = engine_list_head;
|
|
||||||
if (ret) {
|
|
||||||
ret->struct_ref++;
|
|
||||||
ENGINE_REF_PRINT(ret, 0, 1);
|
|
||||||
}
|
|
||||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ENGINE *ENGINE_get_last(void)
|
|
||||||
{
|
|
||||||
ENGINE *ret;
|
|
||||||
|
|
||||||
if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ERR_R_MALLOC_FAILURE);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_write_lock(global_engine_lock))
|
|
||||||
return NULL;
|
|
||||||
ret = engine_list_tail;
|
|
||||||
if (ret) {
|
|
||||||
ret->struct_ref++;
|
|
||||||
ENGINE_REF_PRINT(ret, 0, 1);
|
|
||||||
}
|
|
||||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */
|
|
||||||
ENGINE *ENGINE_get_next(ENGINE *e)
|
|
||||||
{
|
|
||||||
ENGINE *ret = NULL;
|
|
||||||
if (e == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ERR_R_PASSED_NULL_PARAMETER);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (!CRYPTO_THREAD_write_lock(global_engine_lock))
|
|
||||||
return NULL;
|
|
||||||
ret = e->next;
|
|
||||||
if (ret) {
|
|
||||||
/* Return a valid structural reference to the next ENGINE */
|
|
||||||
ret->struct_ref++;
|
|
||||||
ENGINE_REF_PRINT(ret, 0, 1);
|
|
||||||
}
|
|
||||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
|
||||||
/* Release the structural reference to the previous ENGINE */
|
|
||||||
ENGINE_free(e);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ENGINE *ENGINE_get_prev(ENGINE *e)
|
|
||||||
{
|
|
||||||
ENGINE *ret = NULL;
|
|
||||||
if (e == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ERR_R_PASSED_NULL_PARAMETER);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (!CRYPTO_THREAD_write_lock(global_engine_lock))
|
|
||||||
return NULL;
|
|
||||||
ret = e->prev;
|
|
||||||
if (ret) {
|
|
||||||
/* Return a valid structural reference to the next ENGINE */
|
|
||||||
ret->struct_ref++;
|
|
||||||
ENGINE_REF_PRINT(ret, 0, 1);
|
|
||||||
}
|
|
||||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
|
||||||
/* Release the structural reference to the previous ENGINE */
|
|
||||||
ENGINE_free(e);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add another "ENGINE" type into the list. */
|
|
||||||
int ENGINE_add(ENGINE *e)
|
|
||||||
{
|
|
||||||
int to_return = 1;
|
|
||||||
if (e == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ERR_R_PASSED_NULL_PARAMETER);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if ((e->id == NULL) || (e->name == NULL)) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ENGINE_R_ID_OR_NAME_MISSING);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!CRYPTO_THREAD_write_lock(global_engine_lock))
|
|
||||||
return 0;
|
|
||||||
if (!engine_list_add(e)) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ENGINE_R_INTERNAL_LIST_ERROR);
|
|
||||||
to_return = 0;
|
|
||||||
}
|
|
||||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
|
||||||
return to_return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove an existing "ENGINE" type from the array. */
|
|
||||||
int ENGINE_remove(ENGINE *e)
|
|
||||||
{
|
|
||||||
int to_return = 1;
|
|
||||||
if (e == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ERR_R_PASSED_NULL_PARAMETER);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!CRYPTO_THREAD_write_lock(global_engine_lock))
|
|
||||||
return 0;
|
|
||||||
if (!engine_list_remove(e)) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ENGINE_R_INTERNAL_LIST_ERROR);
|
|
||||||
to_return = 0;
|
|
||||||
}
|
|
||||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
|
||||||
return to_return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void engine_cpy(ENGINE *dest, const ENGINE *src)
|
|
||||||
{
|
|
||||||
dest->id = src->id;
|
|
||||||
dest->name = src->name;
|
|
||||||
dest->rsa_meth = src->rsa_meth;
|
|
||||||
#ifndef OPENSSL_NO_DSA
|
|
||||||
dest->dsa_meth = src->dsa_meth;
|
|
||||||
#endif
|
|
||||||
#ifndef OPENSSL_NO_DH
|
|
||||||
dest->dh_meth = src->dh_meth;
|
|
||||||
#endif
|
|
||||||
#ifndef OPENSSL_NO_EC
|
|
||||||
dest->ec_meth = src->ec_meth;
|
|
||||||
#endif
|
|
||||||
dest->rand_meth = src->rand_meth;
|
|
||||||
dest->ciphers = src->ciphers;
|
|
||||||
dest->digests = src->digests;
|
|
||||||
dest->pkey_meths = src->pkey_meths;
|
|
||||||
dest->destroy = src->destroy;
|
|
||||||
dest->init = src->init;
|
|
||||||
dest->finish = src->finish;
|
|
||||||
dest->ctrl = src->ctrl;
|
|
||||||
dest->load_privkey = src->load_privkey;
|
|
||||||
dest->load_pubkey = src->load_pubkey;
|
|
||||||
dest->cmd_defns = src->cmd_defns;
|
|
||||||
dest->flags = src->flags;
|
|
||||||
dest->dynamic_id = src->dynamic_id;
|
|
||||||
engine_add_dynamic_id(dest, NULL, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
ENGINE *ENGINE_by_id(const char *id)
|
|
||||||
{
|
|
||||||
ENGINE *iterator;
|
|
||||||
char *load_dir = NULL;
|
|
||||||
if (id == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ERR_R_PASSED_NULL_PARAMETER);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
ENGINE_load_builtin_engines();
|
|
||||||
|
|
||||||
if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ERR_R_MALLOC_FAILURE);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_write_lock(global_engine_lock))
|
|
||||||
return NULL;
|
|
||||||
iterator = engine_list_head;
|
|
||||||
while (iterator && (strcmp(id, iterator->id) != 0))
|
|
||||||
iterator = iterator->next;
|
|
||||||
if (iterator != NULL) {
|
|
||||||
/*
|
|
||||||
* We need to return a structural reference. If this is an ENGINE
|
|
||||||
* type that returns copies, make a duplicate - otherwise increment
|
|
||||||
* the existing ENGINE's reference count.
|
|
||||||
*/
|
|
||||||
if (iterator->flags & ENGINE_FLAGS_BY_ID_COPY) {
|
|
||||||
ENGINE *cp = ENGINE_new();
|
|
||||||
if (cp == NULL)
|
|
||||||
iterator = NULL;
|
|
||||||
else {
|
|
||||||
engine_cpy(cp, iterator);
|
|
||||||
iterator = cp;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
iterator->struct_ref++;
|
|
||||||
ENGINE_REF_PRINT(iterator, 0, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
|
||||||
if (iterator != NULL)
|
|
||||||
return iterator;
|
|
||||||
/*
|
|
||||||
* Prevent infinite recursion if we're looking for the dynamic engine.
|
|
||||||
*/
|
|
||||||
if (strcmp(id, "dynamic")) {
|
|
||||||
if ((load_dir = ossl_safe_getenv("OPENSSL_ENGINES")) == NULL)
|
|
||||||
load_dir = ENGINESDIR;
|
|
||||||
iterator = ENGINE_by_id("dynamic");
|
|
||||||
if (!iterator || !ENGINE_ctrl_cmd_string(iterator, "ID", id, 0) ||
|
|
||||||
!ENGINE_ctrl_cmd_string(iterator, "DIR_LOAD", "2", 0) ||
|
|
||||||
!ENGINE_ctrl_cmd_string(iterator, "DIR_ADD",
|
|
||||||
load_dir, 0) ||
|
|
||||||
!ENGINE_ctrl_cmd_string(iterator, "LIST_ADD", "1", 0) ||
|
|
||||||
!ENGINE_ctrl_cmd_string(iterator, "LOAD", NULL, 0))
|
|
||||||
goto notfound;
|
|
||||||
return iterator;
|
|
||||||
}
|
|
||||||
notfound:
|
|
||||||
ENGINE_free(iterator);
|
|
||||||
ERR_raise_data(ERR_LIB_ENGINE, ENGINE_R_NO_SUCH_ENGINE, "id=%s", id);
|
|
||||||
return NULL;
|
|
||||||
/* EEK! Experimental code ends */
|
|
||||||
}
|
|
||||||
|
|
||||||
int ENGINE_up_ref(ENGINE *e)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
if (e == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_ENGINE, ERR_R_PASSED_NULL_PARAMETER);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
CRYPTO_UP_REF(&e->struct_ref, &i, global_engine_lock);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
LIBS=../../libcrypto
|
|
||||||
SOURCE[../../libcrypto]=\
|
|
||||||
err_blocks.c err.c err_all.c err_all_legacy.c err_prn.c
|
|
||||||
@@ -1,371 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2000-2022 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 <openssl/core_dispatch.h>
|
|
||||||
#include "internal/refcount.h"
|
|
||||||
|
|
||||||
#define EVP_CTRL_RET_UNSUPPORTED -1
|
|
||||||
|
|
||||||
|
|
||||||
struct evp_md_ctx_st {
|
|
||||||
const EVP_MD *reqdigest; /* The original requested digest */
|
|
||||||
const EVP_MD *digest;
|
|
||||||
ENGINE *engine; /* functional reference if 'digest' is
|
|
||||||
* ENGINE-provided */
|
|
||||||
unsigned long flags;
|
|
||||||
void *md_data;
|
|
||||||
/* Public key context for sign/verify */
|
|
||||||
EVP_PKEY_CTX *pctx;
|
|
||||||
/* Update function: usually copied from EVP_MD */
|
|
||||||
int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Opaque ctx returned from a providers digest algorithm implementation
|
|
||||||
* OSSL_FUNC_digest_newctx()
|
|
||||||
*/
|
|
||||||
void *algctx;
|
|
||||||
EVP_MD *fetched_digest;
|
|
||||||
} /* EVP_MD_CTX */ ;
|
|
||||||
|
|
||||||
struct evp_cipher_ctx_st {
|
|
||||||
const EVP_CIPHER *cipher;
|
|
||||||
ENGINE *engine; /* functional reference if 'cipher' is
|
|
||||||
* ENGINE-provided */
|
|
||||||
int encrypt; /* encrypt or decrypt */
|
|
||||||
int buf_len; /* number we have left */
|
|
||||||
unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */
|
|
||||||
unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */
|
|
||||||
unsigned char buf[EVP_MAX_BLOCK_LENGTH]; /* saved partial block */
|
|
||||||
int num; /* used by cfb/ofb/ctr mode */
|
|
||||||
/* FIXME: Should this even exist? It appears unused */
|
|
||||||
void *app_data; /* application stuff */
|
|
||||||
int key_len; /* May change for variable length cipher */
|
|
||||||
int iv_len; /* IV length */
|
|
||||||
unsigned long flags; /* Various flags */
|
|
||||||
void *cipher_data; /* per EVP data */
|
|
||||||
int final_used;
|
|
||||||
int block_mask;
|
|
||||||
unsigned char final[EVP_MAX_BLOCK_LENGTH]; /* possible final block */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Opaque ctx returned from a providers cipher algorithm implementation
|
|
||||||
* OSSL_FUNC_cipher_newctx()
|
|
||||||
*/
|
|
||||||
void *algctx;
|
|
||||||
EVP_CIPHER *fetched_cipher;
|
|
||||||
} /* EVP_CIPHER_CTX */ ;
|
|
||||||
|
|
||||||
struct evp_mac_ctx_st {
|
|
||||||
EVP_MAC *meth; /* Method structure */
|
|
||||||
/*
|
|
||||||
* Opaque ctx returned from a providers MAC algorithm implementation
|
|
||||||
* OSSL_FUNC_mac_newctx()
|
|
||||||
*/
|
|
||||||
void *algctx;
|
|
||||||
} /* EVP_MAC_CTX */;
|
|
||||||
|
|
||||||
struct evp_kdf_ctx_st {
|
|
||||||
EVP_KDF *meth; /* Method structure */
|
|
||||||
/*
|
|
||||||
* Opaque ctx returned from a providers KDF algorithm implementation
|
|
||||||
* OSSL_FUNC_kdf_newctx()
|
|
||||||
*/
|
|
||||||
void *algctx;
|
|
||||||
} /* EVP_KDF_CTX */ ;
|
|
||||||
|
|
||||||
struct evp_rand_ctx_st {
|
|
||||||
EVP_RAND *meth; /* Method structure */
|
|
||||||
/*
|
|
||||||
* Opaque ctx returned from a providers rand algorithm implementation
|
|
||||||
* OSSL_FUNC_rand_newctx()
|
|
||||||
*/
|
|
||||||
void *algctx;
|
|
||||||
EVP_RAND_CTX *parent; /* Parent EVP_RAND or NULL if none */
|
|
||||||
CRYPTO_REF_COUNT refcnt; /* Context reference count */
|
|
||||||
CRYPTO_RWLOCK *refcnt_lock;
|
|
||||||
} /* EVP_RAND_CTX */ ;
|
|
||||||
|
|
||||||
struct evp_keymgmt_st {
|
|
||||||
int id; /* libcrypto internal */
|
|
||||||
|
|
||||||
int name_id;
|
|
||||||
char *type_name;
|
|
||||||
const char *description;
|
|
||||||
OSSL_PROVIDER *prov;
|
|
||||||
CRYPTO_REF_COUNT refcnt;
|
|
||||||
CRYPTO_RWLOCK *lock;
|
|
||||||
|
|
||||||
/* Constructor(s), destructor, information */
|
|
||||||
OSSL_FUNC_keymgmt_new_fn *new;
|
|
||||||
OSSL_FUNC_keymgmt_free_fn *free;
|
|
||||||
OSSL_FUNC_keymgmt_get_params_fn *get_params;
|
|
||||||
OSSL_FUNC_keymgmt_gettable_params_fn *gettable_params;
|
|
||||||
OSSL_FUNC_keymgmt_set_params_fn *set_params;
|
|
||||||
OSSL_FUNC_keymgmt_settable_params_fn *settable_params;
|
|
||||||
|
|
||||||
/* Generation, a complex constructor */
|
|
||||||
OSSL_FUNC_keymgmt_gen_init_fn *gen_init;
|
|
||||||
OSSL_FUNC_keymgmt_gen_set_template_fn *gen_set_template;
|
|
||||||
OSSL_FUNC_keymgmt_gen_set_params_fn *gen_set_params;
|
|
||||||
OSSL_FUNC_keymgmt_gen_settable_params_fn *gen_settable_params;
|
|
||||||
OSSL_FUNC_keymgmt_gen_fn *gen;
|
|
||||||
OSSL_FUNC_keymgmt_gen_cleanup_fn *gen_cleanup;
|
|
||||||
|
|
||||||
OSSL_FUNC_keymgmt_load_fn *load;
|
|
||||||
|
|
||||||
/* Key object checking */
|
|
||||||
OSSL_FUNC_keymgmt_query_operation_name_fn *query_operation_name;
|
|
||||||
OSSL_FUNC_keymgmt_has_fn *has;
|
|
||||||
OSSL_FUNC_keymgmt_validate_fn *validate;
|
|
||||||
OSSL_FUNC_keymgmt_match_fn *match;
|
|
||||||
|
|
||||||
/* Import and export routines */
|
|
||||||
OSSL_FUNC_keymgmt_import_fn *import;
|
|
||||||
OSSL_FUNC_keymgmt_import_types_fn *import_types;
|
|
||||||
OSSL_FUNC_keymgmt_export_fn *export;
|
|
||||||
OSSL_FUNC_keymgmt_export_types_fn *export_types;
|
|
||||||
OSSL_FUNC_keymgmt_dup_fn *dup;
|
|
||||||
} /* EVP_KEYMGMT */ ;
|
|
||||||
|
|
||||||
struct evp_keyexch_st {
|
|
||||||
int name_id;
|
|
||||||
char *type_name;
|
|
||||||
const char *description;
|
|
||||||
OSSL_PROVIDER *prov;
|
|
||||||
CRYPTO_REF_COUNT refcnt;
|
|
||||||
CRYPTO_RWLOCK *lock;
|
|
||||||
|
|
||||||
OSSL_FUNC_keyexch_newctx_fn *newctx;
|
|
||||||
OSSL_FUNC_keyexch_init_fn *init;
|
|
||||||
OSSL_FUNC_keyexch_set_peer_fn *set_peer;
|
|
||||||
OSSL_FUNC_keyexch_derive_fn *derive;
|
|
||||||
OSSL_FUNC_keyexch_freectx_fn *freectx;
|
|
||||||
OSSL_FUNC_keyexch_dupctx_fn *dupctx;
|
|
||||||
OSSL_FUNC_keyexch_set_ctx_params_fn *set_ctx_params;
|
|
||||||
OSSL_FUNC_keyexch_settable_ctx_params_fn *settable_ctx_params;
|
|
||||||
OSSL_FUNC_keyexch_get_ctx_params_fn *get_ctx_params;
|
|
||||||
OSSL_FUNC_keyexch_gettable_ctx_params_fn *gettable_ctx_params;
|
|
||||||
} /* EVP_KEYEXCH */;
|
|
||||||
|
|
||||||
struct evp_signature_st {
|
|
||||||
int name_id;
|
|
||||||
char *type_name;
|
|
||||||
const char *description;
|
|
||||||
OSSL_PROVIDER *prov;
|
|
||||||
CRYPTO_REF_COUNT refcnt;
|
|
||||||
CRYPTO_RWLOCK *lock;
|
|
||||||
|
|
||||||
OSSL_FUNC_signature_newctx_fn *newctx;
|
|
||||||
OSSL_FUNC_signature_sign_init_fn *sign_init;
|
|
||||||
OSSL_FUNC_signature_sign_fn *sign;
|
|
||||||
OSSL_FUNC_signature_verify_init_fn *verify_init;
|
|
||||||
OSSL_FUNC_signature_verify_fn *verify;
|
|
||||||
OSSL_FUNC_signature_verify_recover_init_fn *verify_recover_init;
|
|
||||||
OSSL_FUNC_signature_verify_recover_fn *verify_recover;
|
|
||||||
OSSL_FUNC_signature_digest_sign_init_fn *digest_sign_init;
|
|
||||||
OSSL_FUNC_signature_digest_sign_update_fn *digest_sign_update;
|
|
||||||
OSSL_FUNC_signature_digest_sign_final_fn *digest_sign_final;
|
|
||||||
OSSL_FUNC_signature_digest_sign_fn *digest_sign;
|
|
||||||
OSSL_FUNC_signature_digest_verify_init_fn *digest_verify_init;
|
|
||||||
OSSL_FUNC_signature_digest_verify_update_fn *digest_verify_update;
|
|
||||||
OSSL_FUNC_signature_digest_verify_final_fn *digest_verify_final;
|
|
||||||
OSSL_FUNC_signature_digest_verify_fn *digest_verify;
|
|
||||||
OSSL_FUNC_signature_freectx_fn *freectx;
|
|
||||||
OSSL_FUNC_signature_dupctx_fn *dupctx;
|
|
||||||
OSSL_FUNC_signature_get_ctx_params_fn *get_ctx_params;
|
|
||||||
OSSL_FUNC_signature_gettable_ctx_params_fn *gettable_ctx_params;
|
|
||||||
OSSL_FUNC_signature_set_ctx_params_fn *set_ctx_params;
|
|
||||||
OSSL_FUNC_signature_settable_ctx_params_fn *settable_ctx_params;
|
|
||||||
OSSL_FUNC_signature_get_ctx_md_params_fn *get_ctx_md_params;
|
|
||||||
OSSL_FUNC_signature_gettable_ctx_md_params_fn *gettable_ctx_md_params;
|
|
||||||
OSSL_FUNC_signature_set_ctx_md_params_fn *set_ctx_md_params;
|
|
||||||
OSSL_FUNC_signature_settable_ctx_md_params_fn *settable_ctx_md_params;
|
|
||||||
} /* EVP_SIGNATURE */;
|
|
||||||
|
|
||||||
struct evp_asym_cipher_st {
|
|
||||||
int name_id;
|
|
||||||
char *type_name;
|
|
||||||
const char *description;
|
|
||||||
OSSL_PROVIDER *prov;
|
|
||||||
CRYPTO_REF_COUNT refcnt;
|
|
||||||
CRYPTO_RWLOCK *lock;
|
|
||||||
|
|
||||||
OSSL_FUNC_asym_cipher_newctx_fn *newctx;
|
|
||||||
OSSL_FUNC_asym_cipher_encrypt_init_fn *encrypt_init;
|
|
||||||
OSSL_FUNC_asym_cipher_encrypt_fn *encrypt;
|
|
||||||
OSSL_FUNC_asym_cipher_decrypt_init_fn *decrypt_init;
|
|
||||||
OSSL_FUNC_asym_cipher_decrypt_fn *decrypt;
|
|
||||||
OSSL_FUNC_asym_cipher_freectx_fn *freectx;
|
|
||||||
OSSL_FUNC_asym_cipher_dupctx_fn *dupctx;
|
|
||||||
OSSL_FUNC_asym_cipher_get_ctx_params_fn *get_ctx_params;
|
|
||||||
OSSL_FUNC_asym_cipher_gettable_ctx_params_fn *gettable_ctx_params;
|
|
||||||
OSSL_FUNC_asym_cipher_set_ctx_params_fn *set_ctx_params;
|
|
||||||
OSSL_FUNC_asym_cipher_settable_ctx_params_fn *settable_ctx_params;
|
|
||||||
} /* EVP_ASYM_CIPHER */;
|
|
||||||
|
|
||||||
struct evp_kem_st {
|
|
||||||
int name_id;
|
|
||||||
char *type_name;
|
|
||||||
const char *description;
|
|
||||||
OSSL_PROVIDER *prov;
|
|
||||||
CRYPTO_REF_COUNT refcnt;
|
|
||||||
CRYPTO_RWLOCK *lock;
|
|
||||||
|
|
||||||
OSSL_FUNC_kem_newctx_fn *newctx;
|
|
||||||
OSSL_FUNC_kem_encapsulate_init_fn *encapsulate_init;
|
|
||||||
OSSL_FUNC_kem_encapsulate_fn *encapsulate;
|
|
||||||
OSSL_FUNC_kem_decapsulate_init_fn *decapsulate_init;
|
|
||||||
OSSL_FUNC_kem_decapsulate_fn *decapsulate;
|
|
||||||
OSSL_FUNC_kem_freectx_fn *freectx;
|
|
||||||
OSSL_FUNC_kem_dupctx_fn *dupctx;
|
|
||||||
OSSL_FUNC_kem_get_ctx_params_fn *get_ctx_params;
|
|
||||||
OSSL_FUNC_kem_gettable_ctx_params_fn *gettable_ctx_params;
|
|
||||||
OSSL_FUNC_kem_set_ctx_params_fn *set_ctx_params;
|
|
||||||
OSSL_FUNC_kem_settable_ctx_params_fn *settable_ctx_params;
|
|
||||||
} /* EVP_KEM */;
|
|
||||||
|
|
||||||
int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass,
|
|
||||||
int passlen, ASN1_TYPE *param,
|
|
||||||
const EVP_CIPHER *c, const EVP_MD *md,
|
|
||||||
int en_de);
|
|
||||||
int PKCS5_v2_PBKDF2_keyivgen_ex(EVP_CIPHER_CTX *ctx, const char *pass,
|
|
||||||
int passlen, ASN1_TYPE *param,
|
|
||||||
const EVP_CIPHER *c, const EVP_MD *md,
|
|
||||||
int en_de, OSSL_LIB_CTX *libctx, const char *propq);
|
|
||||||
|
|
||||||
struct evp_Encode_Ctx_st {
|
|
||||||
/* number saved in a partial encode/decode */
|
|
||||||
int num;
|
|
||||||
/*
|
|
||||||
* The length is either the output line length (in input bytes) or the
|
|
||||||
* shortest input line length that is ok. Once decoding begins, the
|
|
||||||
* length is adjusted up each time a longer line is decoded
|
|
||||||
*/
|
|
||||||
int length;
|
|
||||||
/* data to encode */
|
|
||||||
unsigned char enc_data[80];
|
|
||||||
/* number read on current line */
|
|
||||||
int line_num;
|
|
||||||
unsigned int flags;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct evp_pbe_st EVP_PBE_CTL;
|
|
||||||
DEFINE_STACK_OF(EVP_PBE_CTL)
|
|
||||||
|
|
||||||
int ossl_is_partially_overlapping(const void *ptr1, const void *ptr2, int len);
|
|
||||||
|
|
||||||
#include <openssl/types.h>
|
|
||||||
#include <openssl/core.h>
|
|
||||||
|
|
||||||
void *evp_generic_fetch(OSSL_LIB_CTX *ctx, int operation_id,
|
|
||||||
const char *name, const char *properties,
|
|
||||||
void *(*new_method)(int name_id,
|
|
||||||
const OSSL_ALGORITHM *algodef,
|
|
||||||
OSSL_PROVIDER *prov),
|
|
||||||
int (*up_ref_method)(void *),
|
|
||||||
void (*free_method)(void *));
|
|
||||||
void *evp_generic_fetch_from_prov(OSSL_PROVIDER *prov, int operation_id,
|
|
||||||
const char *name, const char *properties,
|
|
||||||
void *(*new_method)(int name_id,
|
|
||||||
const OSSL_ALGORITHM *algodef,
|
|
||||||
OSSL_PROVIDER *prov),
|
|
||||||
int (*up_ref_method)(void *),
|
|
||||||
void (*free_method)(void *));
|
|
||||||
void evp_generic_do_all_prefetched(OSSL_LIB_CTX *libctx, int operation_id,
|
|
||||||
void (*user_fn)(void *method, void *arg),
|
|
||||||
void *user_arg);
|
|
||||||
void evp_generic_do_all(OSSL_LIB_CTX *libctx, int operation_id,
|
|
||||||
void (*user_fn)(void *method, void *arg),
|
|
||||||
void *user_arg,
|
|
||||||
void *(*new_method)(int name_id,
|
|
||||||
const OSSL_ALGORITHM *algodef,
|
|
||||||
OSSL_PROVIDER *prov),
|
|
||||||
int (*up_ref_method)(void *),
|
|
||||||
void (*free_method)(void *));
|
|
||||||
|
|
||||||
/* Internal fetchers for method types that are to be combined with others */
|
|
||||||
EVP_KEYMGMT *evp_keymgmt_fetch_by_number(OSSL_LIB_CTX *ctx, int name_id,
|
|
||||||
const char *properties);
|
|
||||||
EVP_SIGNATURE *evp_signature_fetch_from_prov(OSSL_PROVIDER *prov,
|
|
||||||
const char *name,
|
|
||||||
const char *properties);
|
|
||||||
EVP_ASYM_CIPHER *evp_asym_cipher_fetch_from_prov(OSSL_PROVIDER *prov,
|
|
||||||
const char *name,
|
|
||||||
const char *properties);
|
|
||||||
EVP_KEYEXCH *evp_keyexch_fetch_from_prov(OSSL_PROVIDER *prov,
|
|
||||||
const char *name,
|
|
||||||
const char *properties);
|
|
||||||
EVP_KEM *evp_kem_fetch_from_prov(OSSL_PROVIDER *prov,
|
|
||||||
const char *name,
|
|
||||||
const char *properties);
|
|
||||||
|
|
||||||
/* Internal structure constructors for fetched methods */
|
|
||||||
EVP_MD *evp_md_new(void);
|
|
||||||
EVP_CIPHER *evp_cipher_new(void);
|
|
||||||
|
|
||||||
int evp_cipher_get_asn1_aead_params(EVP_CIPHER_CTX *c, ASN1_TYPE *type,
|
|
||||||
evp_cipher_aead_asn1_params *asn1_params);
|
|
||||||
int evp_cipher_set_asn1_aead_params(EVP_CIPHER_CTX *c, ASN1_TYPE *type,
|
|
||||||
evp_cipher_aead_asn1_params *asn1_params);
|
|
||||||
|
|
||||||
/* Helper functions to avoid duplicating code */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These methods implement different ways to pass a params array to the
|
|
||||||
* provider. They will return one of these values:
|
|
||||||
*
|
|
||||||
* -2 if the method doesn't come from a provider
|
|
||||||
* (evp_do_param will return this to the called)
|
|
||||||
* -1 if the provider doesn't offer the desired function
|
|
||||||
* (evp_do_param will raise an error and return 0)
|
|
||||||
* or the return value from the desired function
|
|
||||||
* (evp_do_param will return it to the caller)
|
|
||||||
*/
|
|
||||||
int evp_do_ciph_getparams(const EVP_CIPHER *ciph, OSSL_PARAM params[]);
|
|
||||||
int evp_do_ciph_ctx_getparams(const EVP_CIPHER *ciph, void *provctx,
|
|
||||||
OSSL_PARAM params[]);
|
|
||||||
int evp_do_ciph_ctx_setparams(const EVP_CIPHER *ciph, void *provctx,
|
|
||||||
OSSL_PARAM params[]);
|
|
||||||
int evp_do_md_getparams(const EVP_MD *md, OSSL_PARAM params[]);
|
|
||||||
int evp_do_md_ctx_getparams(const EVP_MD *md, void *provctx,
|
|
||||||
OSSL_PARAM params[]);
|
|
||||||
int evp_do_md_ctx_setparams(const EVP_MD *md, void *provctx,
|
|
||||||
OSSL_PARAM params[]);
|
|
||||||
|
|
||||||
OSSL_PARAM *evp_pkey_to_param(EVP_PKEY *pkey, size_t *sz);
|
|
||||||
|
|
||||||
#define M_check_autoarg(ctx, arg, arglen, err) \
|
|
||||||
if (ctx->pmeth->flags & EVP_PKEY_FLAG_AUTOARGLEN) { \
|
|
||||||
size_t pksize = (size_t)EVP_PKEY_get_size(ctx->pkey); \
|
|
||||||
\
|
|
||||||
if (pksize == 0) { \
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_INVALID_KEY); /*ckerr_ignore*/ \
|
|
||||||
return 0; \
|
|
||||||
} \
|
|
||||||
if (arg == NULL) { \
|
|
||||||
*arglen = pksize; \
|
|
||||||
return 1; \
|
|
||||||
} \
|
|
||||||
if (*arglen < pksize) { \
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_BUFFER_TOO_SMALL); /*ckerr_ignore*/ \
|
|
||||||
return 0; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
void evp_pkey_ctx_free_old_ops(EVP_PKEY_CTX *ctx);
|
|
||||||
void evp_cipher_free_int(EVP_CIPHER *md);
|
|
||||||
void evp_md_free_int(EVP_MD *md);
|
|
||||||
|
|
||||||
/* OSSL_PROVIDER * is only used to get the library context */
|
|
||||||
int evp_is_a(OSSL_PROVIDER *prov, int number,
|
|
||||||
const char *legacy_name, const char *name);
|
|
||||||
int 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);
|
|
||||||
@@ -1,763 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2006-2024 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 <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <openssl/objects.h>
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
#include "internal/numbers.h" /* includes SIZE_MAX */
|
|
||||||
#include "internal/cryptlib.h"
|
|
||||||
#include "internal/provider.h"
|
|
||||||
#include "internal/core.h"
|
|
||||||
#include "crypto/evp.h"
|
|
||||||
#include "evp_local.h"
|
|
||||||
|
|
||||||
static EVP_SIGNATURE *evp_signature_new(OSSL_PROVIDER *prov)
|
|
||||||
{
|
|
||||||
EVP_SIGNATURE *signature = OPENSSL_zalloc(sizeof(EVP_SIGNATURE));
|
|
||||||
|
|
||||||
if (signature == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, ERR_R_MALLOC_FAILURE);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
signature->lock = CRYPTO_THREAD_lock_new();
|
|
||||||
if (signature->lock == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, ERR_R_MALLOC_FAILURE);
|
|
||||||
OPENSSL_free(signature);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
signature->prov = prov;
|
|
||||||
ossl_provider_up_ref(prov);
|
|
||||||
signature->refcnt = 1;
|
|
||||||
|
|
||||||
return signature;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *evp_signature_from_algorithm(int name_id,
|
|
||||||
const OSSL_ALGORITHM *algodef,
|
|
||||||
OSSL_PROVIDER *prov)
|
|
||||||
{
|
|
||||||
const OSSL_DISPATCH *fns = algodef->implementation;
|
|
||||||
EVP_SIGNATURE *signature = NULL;
|
|
||||||
int ctxfncnt = 0, signfncnt = 0, verifyfncnt = 0, verifyrecfncnt = 0;
|
|
||||||
int digsignfncnt = 0, digverifyfncnt = 0;
|
|
||||||
int gparamfncnt = 0, sparamfncnt = 0, gmdparamfncnt = 0, smdparamfncnt = 0;
|
|
||||||
|
|
||||||
if ((signature = evp_signature_new(prov)) == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, ERR_R_MALLOC_FAILURE);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
signature->name_id = name_id;
|
|
||||||
if ((signature->type_name = ossl_algorithm_get1_first_name(algodef)) == NULL)
|
|
||||||
goto err;
|
|
||||||
signature->description = algodef->algorithm_description;
|
|
||||||
|
|
||||||
for (; fns->function_id != 0; fns++) {
|
|
||||||
switch (fns->function_id) {
|
|
||||||
case OSSL_FUNC_SIGNATURE_NEWCTX:
|
|
||||||
if (signature->newctx != NULL)
|
|
||||||
break;
|
|
||||||
signature->newctx = OSSL_FUNC_signature_newctx(fns);
|
|
||||||
ctxfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_SIGN_INIT:
|
|
||||||
if (signature->sign_init != NULL)
|
|
||||||
break;
|
|
||||||
signature->sign_init = OSSL_FUNC_signature_sign_init(fns);
|
|
||||||
signfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_SIGN:
|
|
||||||
if (signature->sign != NULL)
|
|
||||||
break;
|
|
||||||
signature->sign = OSSL_FUNC_signature_sign(fns);
|
|
||||||
signfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_VERIFY_INIT:
|
|
||||||
if (signature->verify_init != NULL)
|
|
||||||
break;
|
|
||||||
signature->verify_init = OSSL_FUNC_signature_verify_init(fns);
|
|
||||||
verifyfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_VERIFY:
|
|
||||||
if (signature->verify != NULL)
|
|
||||||
break;
|
|
||||||
signature->verify = OSSL_FUNC_signature_verify(fns);
|
|
||||||
verifyfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_VERIFY_RECOVER_INIT:
|
|
||||||
if (signature->verify_recover_init != NULL)
|
|
||||||
break;
|
|
||||||
signature->verify_recover_init
|
|
||||||
= OSSL_FUNC_signature_verify_recover_init(fns);
|
|
||||||
verifyrecfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_VERIFY_RECOVER:
|
|
||||||
if (signature->verify_recover != NULL)
|
|
||||||
break;
|
|
||||||
signature->verify_recover
|
|
||||||
= OSSL_FUNC_signature_verify_recover(fns);
|
|
||||||
verifyrecfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT:
|
|
||||||
if (signature->digest_sign_init != NULL)
|
|
||||||
break;
|
|
||||||
signature->digest_sign_init
|
|
||||||
= OSSL_FUNC_signature_digest_sign_init(fns);
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE:
|
|
||||||
if (signature->digest_sign_update != NULL)
|
|
||||||
break;
|
|
||||||
signature->digest_sign_update
|
|
||||||
= OSSL_FUNC_signature_digest_sign_update(fns);
|
|
||||||
digsignfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL:
|
|
||||||
if (signature->digest_sign_final != NULL)
|
|
||||||
break;
|
|
||||||
signature->digest_sign_final
|
|
||||||
= OSSL_FUNC_signature_digest_sign_final(fns);
|
|
||||||
digsignfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_DIGEST_SIGN:
|
|
||||||
if (signature->digest_sign != NULL)
|
|
||||||
break;
|
|
||||||
signature->digest_sign
|
|
||||||
= OSSL_FUNC_signature_digest_sign(fns);
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT:
|
|
||||||
if (signature->digest_verify_init != NULL)
|
|
||||||
break;
|
|
||||||
signature->digest_verify_init
|
|
||||||
= OSSL_FUNC_signature_digest_verify_init(fns);
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE:
|
|
||||||
if (signature->digest_verify_update != NULL)
|
|
||||||
break;
|
|
||||||
signature->digest_verify_update
|
|
||||||
= OSSL_FUNC_signature_digest_verify_update(fns);
|
|
||||||
digverifyfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL:
|
|
||||||
if (signature->digest_verify_final != NULL)
|
|
||||||
break;
|
|
||||||
signature->digest_verify_final
|
|
||||||
= OSSL_FUNC_signature_digest_verify_final(fns);
|
|
||||||
digverifyfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_DIGEST_VERIFY:
|
|
||||||
if (signature->digest_verify != NULL)
|
|
||||||
break;
|
|
||||||
signature->digest_verify
|
|
||||||
= OSSL_FUNC_signature_digest_verify(fns);
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_FREECTX:
|
|
||||||
if (signature->freectx != NULL)
|
|
||||||
break;
|
|
||||||
signature->freectx = OSSL_FUNC_signature_freectx(fns);
|
|
||||||
ctxfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_DUPCTX:
|
|
||||||
if (signature->dupctx != NULL)
|
|
||||||
break;
|
|
||||||
signature->dupctx = OSSL_FUNC_signature_dupctx(fns);
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS:
|
|
||||||
if (signature->get_ctx_params != NULL)
|
|
||||||
break;
|
|
||||||
signature->get_ctx_params
|
|
||||||
= OSSL_FUNC_signature_get_ctx_params(fns);
|
|
||||||
gparamfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS:
|
|
||||||
if (signature->gettable_ctx_params != NULL)
|
|
||||||
break;
|
|
||||||
signature->gettable_ctx_params
|
|
||||||
= OSSL_FUNC_signature_gettable_ctx_params(fns);
|
|
||||||
gparamfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS:
|
|
||||||
if (signature->set_ctx_params != NULL)
|
|
||||||
break;
|
|
||||||
signature->set_ctx_params
|
|
||||||
= OSSL_FUNC_signature_set_ctx_params(fns);
|
|
||||||
sparamfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS:
|
|
||||||
if (signature->settable_ctx_params != NULL)
|
|
||||||
break;
|
|
||||||
signature->settable_ctx_params
|
|
||||||
= OSSL_FUNC_signature_settable_ctx_params(fns);
|
|
||||||
sparamfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS:
|
|
||||||
if (signature->get_ctx_md_params != NULL)
|
|
||||||
break;
|
|
||||||
signature->get_ctx_md_params
|
|
||||||
= OSSL_FUNC_signature_get_ctx_md_params(fns);
|
|
||||||
gmdparamfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS:
|
|
||||||
if (signature->gettable_ctx_md_params != NULL)
|
|
||||||
break;
|
|
||||||
signature->gettable_ctx_md_params
|
|
||||||
= OSSL_FUNC_signature_gettable_ctx_md_params(fns);
|
|
||||||
gmdparamfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS:
|
|
||||||
if (signature->set_ctx_md_params != NULL)
|
|
||||||
break;
|
|
||||||
signature->set_ctx_md_params
|
|
||||||
= OSSL_FUNC_signature_set_ctx_md_params(fns);
|
|
||||||
smdparamfncnt++;
|
|
||||||
break;
|
|
||||||
case OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS:
|
|
||||||
if (signature->settable_ctx_md_params != NULL)
|
|
||||||
break;
|
|
||||||
signature->settable_ctx_md_params
|
|
||||||
= OSSL_FUNC_signature_settable_ctx_md_params(fns);
|
|
||||||
smdparamfncnt++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ctxfncnt != 2
|
|
||||||
|| (signfncnt == 0
|
|
||||||
&& verifyfncnt == 0
|
|
||||||
&& verifyrecfncnt == 0
|
|
||||||
&& digsignfncnt == 0
|
|
||||||
&& digverifyfncnt == 0
|
|
||||||
&& signature->digest_sign == NULL
|
|
||||||
&& signature->digest_verify == NULL)
|
|
||||||
|| (signfncnt != 0 && signfncnt != 2)
|
|
||||||
|| (verifyfncnt != 0 && verifyfncnt != 2)
|
|
||||||
|| (verifyrecfncnt != 0 && verifyrecfncnt != 2)
|
|
||||||
|| (digsignfncnt != 0 && digsignfncnt != 2)
|
|
||||||
|| (digsignfncnt == 2 && signature->digest_sign_init == NULL)
|
|
||||||
|| (digverifyfncnt != 0 && digverifyfncnt != 2)
|
|
||||||
|| (digverifyfncnt == 2 && signature->digest_verify_init == NULL)
|
|
||||||
|| (signature->digest_sign != NULL
|
|
||||||
&& signature->digest_sign_init == NULL)
|
|
||||||
|| (signature->digest_verify != NULL
|
|
||||||
&& signature->digest_verify_init == NULL)
|
|
||||||
|| (gparamfncnt != 0 && gparamfncnt != 2)
|
|
||||||
|| (sparamfncnt != 0 && sparamfncnt != 2)
|
|
||||||
|| (gmdparamfncnt != 0 && gmdparamfncnt != 2)
|
|
||||||
|| (smdparamfncnt != 0 && smdparamfncnt != 2)) {
|
|
||||||
/*
|
|
||||||
* In order to be a consistent set of functions we must have at least
|
|
||||||
* a set of context functions (newctx and freectx) as well as a set of
|
|
||||||
* "signature" functions:
|
|
||||||
* (sign_init, sign) or
|
|
||||||
* (verify_init verify) or
|
|
||||||
* (verify_recover_init, verify_recover) or
|
|
||||||
* (digest_sign_init, digest_sign_update, digest_sign_final) or
|
|
||||||
* (digest_verify_init, digest_verify_update, digest_verify_final) or
|
|
||||||
* (digest_sign_init, digest_sign) or
|
|
||||||
* (digest_verify_init, digest_verify).
|
|
||||||
*
|
|
||||||
* set_ctx_params and settable_ctx_params are optional, but if one of
|
|
||||||
* them is present then the other one must also be present. The same
|
|
||||||
* applies to get_ctx_params and gettable_ctx_params. The same rules
|
|
||||||
* apply to the "md_params" functions. The dupctx function is optional.
|
|
||||||
*/
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_INVALID_PROVIDER_FUNCTIONS);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
return signature;
|
|
||||||
err:
|
|
||||||
EVP_SIGNATURE_free(signature);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EVP_SIGNATURE_free(EVP_SIGNATURE *signature)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (signature == NULL)
|
|
||||||
return;
|
|
||||||
CRYPTO_DOWN_REF(&signature->refcnt, &i, signature->lock);
|
|
||||||
if (i > 0)
|
|
||||||
return;
|
|
||||||
OPENSSL_free(signature->type_name);
|
|
||||||
ossl_provider_free(signature->prov);
|
|
||||||
CRYPTO_THREAD_lock_free(signature->lock);
|
|
||||||
OPENSSL_free(signature);
|
|
||||||
}
|
|
||||||
|
|
||||||
int EVP_SIGNATURE_up_ref(EVP_SIGNATURE *signature)
|
|
||||||
{
|
|
||||||
int ref = 0;
|
|
||||||
|
|
||||||
CRYPTO_UP_REF(&signature->refcnt, &ref, signature->lock);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
OSSL_PROVIDER *EVP_SIGNATURE_get0_provider(const EVP_SIGNATURE *signature)
|
|
||||||
{
|
|
||||||
return signature->prov;
|
|
||||||
}
|
|
||||||
|
|
||||||
EVP_SIGNATURE *EVP_SIGNATURE_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
|
|
||||||
const char *properties)
|
|
||||||
{
|
|
||||||
return evp_generic_fetch(ctx, OSSL_OP_SIGNATURE, algorithm, properties,
|
|
||||||
evp_signature_from_algorithm,
|
|
||||||
(int (*)(void *))EVP_SIGNATURE_up_ref,
|
|
||||||
(void (*)(void *))EVP_SIGNATURE_free);
|
|
||||||
}
|
|
||||||
|
|
||||||
EVP_SIGNATURE *evp_signature_fetch_from_prov(OSSL_PROVIDER *prov,
|
|
||||||
const char *algorithm,
|
|
||||||
const char *properties)
|
|
||||||
{
|
|
||||||
return evp_generic_fetch_from_prov(prov, OSSL_OP_SIGNATURE,
|
|
||||||
algorithm, properties,
|
|
||||||
evp_signature_from_algorithm,
|
|
||||||
(int (*)(void *))EVP_SIGNATURE_up_ref,
|
|
||||||
(void (*)(void *))EVP_SIGNATURE_free);
|
|
||||||
}
|
|
||||||
|
|
||||||
int EVP_SIGNATURE_is_a(const EVP_SIGNATURE *signature, const char *name)
|
|
||||||
{
|
|
||||||
return signature != NULL
|
|
||||||
&& evp_is_a(signature->prov, signature->name_id, NULL, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int evp_signature_get_number(const EVP_SIGNATURE *signature)
|
|
||||||
{
|
|
||||||
return signature->name_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *EVP_SIGNATURE_get0_name(const EVP_SIGNATURE *signature)
|
|
||||||
{
|
|
||||||
return signature->type_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *EVP_SIGNATURE_get0_description(const EVP_SIGNATURE *signature)
|
|
||||||
{
|
|
||||||
return signature->description;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EVP_SIGNATURE_do_all_provided(OSSL_LIB_CTX *libctx,
|
|
||||||
void (*fn)(EVP_SIGNATURE *signature,
|
|
||||||
void *arg),
|
|
||||||
void *arg)
|
|
||||||
{
|
|
||||||
evp_generic_do_all(libctx, OSSL_OP_SIGNATURE,
|
|
||||||
(void (*)(void *, void *))fn, arg,
|
|
||||||
evp_signature_from_algorithm,
|
|
||||||
(int (*)(void *))EVP_SIGNATURE_up_ref,
|
|
||||||
(void (*)(void *))EVP_SIGNATURE_free);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int EVP_SIGNATURE_names_do_all(const EVP_SIGNATURE *signature,
|
|
||||||
void (*fn)(const char *name, void *data),
|
|
||||||
void *data)
|
|
||||||
{
|
|
||||||
if (signature->prov != NULL)
|
|
||||||
return evp_names_do_all(signature->prov, signature->name_id, fn, data);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const OSSL_PARAM *EVP_SIGNATURE_gettable_ctx_params(const EVP_SIGNATURE *sig)
|
|
||||||
{
|
|
||||||
void *provctx;
|
|
||||||
|
|
||||||
if (sig == NULL || sig->gettable_ctx_params == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
provctx = ossl_provider_ctx(EVP_SIGNATURE_get0_provider(sig));
|
|
||||||
return sig->gettable_ctx_params(NULL, provctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
const OSSL_PARAM *EVP_SIGNATURE_settable_ctx_params(const EVP_SIGNATURE *sig)
|
|
||||||
{
|
|
||||||
void *provctx;
|
|
||||||
|
|
||||||
if (sig == NULL || sig->settable_ctx_params == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
provctx = ossl_provider_ctx(EVP_SIGNATURE_get0_provider(sig));
|
|
||||||
return sig->settable_ctx_params(NULL, provctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, int operation,
|
|
||||||
const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
void *provkey = NULL;
|
|
||||||
EVP_SIGNATURE *signature = NULL;
|
|
||||||
EVP_KEYMGMT *tmp_keymgmt = NULL;
|
|
||||||
const OSSL_PROVIDER *tmp_prov = NULL;
|
|
||||||
const char *supported_sig = NULL;
|
|
||||||
int iter;
|
|
||||||
|
|
||||||
if (ctx == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, ERR_R_PASSED_NULL_PARAMETER);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
evp_pkey_ctx_free_old_ops(ctx);
|
|
||||||
ctx->operation = operation;
|
|
||||||
|
|
||||||
ERR_set_mark();
|
|
||||||
|
|
||||||
if (evp_pkey_ctx_is_legacy(ctx))
|
|
||||||
goto legacy;
|
|
||||||
|
|
||||||
if (ctx->pkey == NULL) {
|
|
||||||
ERR_clear_last_mark();
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_NO_KEY_SET);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Try to derive the supported signature from |ctx->keymgmt|.
|
|
||||||
*/
|
|
||||||
if (!ossl_assert(ctx->pkey->keymgmt == NULL
|
|
||||||
|| ctx->pkey->keymgmt == ctx->keymgmt)) {
|
|
||||||
ERR_clear_last_mark();
|
|
||||||
ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
supported_sig = evp_keymgmt_util_query_operation_name(ctx->keymgmt,
|
|
||||||
OSSL_OP_SIGNATURE);
|
|
||||||
if (supported_sig == NULL) {
|
|
||||||
ERR_clear_last_mark();
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We perform two iterations:
|
|
||||||
*
|
|
||||||
* 1. Do the normal signature fetch, using the fetching data given by
|
|
||||||
* the EVP_PKEY_CTX.
|
|
||||||
* 2. Do the provider specific signature fetch, from the same provider
|
|
||||||
* as |ctx->keymgmt|
|
|
||||||
*
|
|
||||||
* We then try to fetch the keymgmt from the same provider as the
|
|
||||||
* signature, and try to export |ctx->pkey| to that keymgmt (when
|
|
||||||
* this keymgmt happens to be the same as |ctx->keymgmt|, the export
|
|
||||||
* is a no-op, but we call it anyway to not complicate the code even
|
|
||||||
* more).
|
|
||||||
* If the export call succeeds (returns a non-NULL provider key pointer),
|
|
||||||
* we're done and can perform the operation itself. If not, we perform
|
|
||||||
* the second iteration, or jump to legacy.
|
|
||||||
*/
|
|
||||||
for (iter = 1; iter < 3 && provkey == NULL; iter++) {
|
|
||||||
EVP_KEYMGMT *tmp_keymgmt_tofree = NULL;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If we're on the second iteration, free the results from the first.
|
|
||||||
* They are NULL on the first iteration, so no need to check what
|
|
||||||
* iteration we're on.
|
|
||||||
*/
|
|
||||||
EVP_SIGNATURE_free(signature);
|
|
||||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
|
||||||
|
|
||||||
switch (iter) {
|
|
||||||
case 1:
|
|
||||||
signature =
|
|
||||||
EVP_SIGNATURE_fetch(ctx->libctx, supported_sig, ctx->propquery);
|
|
||||||
if (signature != NULL)
|
|
||||||
tmp_prov = EVP_SIGNATURE_get0_provider(signature);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
tmp_prov = EVP_KEYMGMT_get0_provider(ctx->keymgmt);
|
|
||||||
signature =
|
|
||||||
evp_signature_fetch_from_prov((OSSL_PROVIDER *)tmp_prov,
|
|
||||||
supported_sig, ctx->propquery);
|
|
||||||
if (signature == NULL)
|
|
||||||
goto legacy;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (signature == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Ensure that the key is provided, either natively, or as a cached
|
|
||||||
* export. We start by fetching the keymgmt with the same name as
|
|
||||||
* |ctx->pkey|, but from the provider of the signature method, using
|
|
||||||
* the same property query as when fetching the signature method.
|
|
||||||
* With the keymgmt we found (if we did), we try to export |ctx->pkey|
|
|
||||||
* to it (evp_pkey_export_to_provider() is smart enough to only actually
|
|
||||||
|
|
||||||
* export it if |tmp_keymgmt| is different from |ctx->pkey|'s keymgmt)
|
|
||||||
*/
|
|
||||||
tmp_keymgmt_tofree = tmp_keymgmt =
|
|
||||||
evp_keymgmt_fetch_from_prov((OSSL_PROVIDER *)tmp_prov,
|
|
||||||
EVP_KEYMGMT_get0_name(ctx->keymgmt),
|
|
||||||
ctx->propquery);
|
|
||||||
if (tmp_keymgmt != NULL)
|
|
||||||
provkey = evp_pkey_export_to_provider(ctx->pkey, ctx->libctx,
|
|
||||||
&tmp_keymgmt, ctx->propquery);
|
|
||||||
if (tmp_keymgmt == NULL)
|
|
||||||
EVP_KEYMGMT_free(tmp_keymgmt_tofree);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (provkey == NULL) {
|
|
||||||
EVP_SIGNATURE_free(signature);
|
|
||||||
goto legacy;
|
|
||||||
}
|
|
||||||
|
|
||||||
ERR_pop_to_mark();
|
|
||||||
|
|
||||||
/* No more legacy from here down to legacy: */
|
|
||||||
|
|
||||||
ctx->op.sig.signature = signature;
|
|
||||||
ctx->op.sig.algctx =
|
|
||||||
signature->newctx(ossl_provider_ctx(signature->prov), ctx->propquery);
|
|
||||||
if (ctx->op.sig.algctx == NULL) {
|
|
||||||
/* The provider key can stay in the cache */
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (operation) {
|
|
||||||
case EVP_PKEY_OP_SIGN:
|
|
||||||
if (signature->sign_init == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
|
||||||
ret = -2;
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
ret = signature->sign_init(ctx->op.sig.algctx, provkey, params);
|
|
||||||
break;
|
|
||||||
case EVP_PKEY_OP_VERIFY:
|
|
||||||
if (signature->verify_init == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
|
||||||
ret = -2;
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
ret = signature->verify_init(ctx->op.sig.algctx, provkey, params);
|
|
||||||
break;
|
|
||||||
case EVP_PKEY_OP_VERIFYRECOVER:
|
|
||||||
if (signature->verify_recover_init == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
|
||||||
ret = -2;
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
ret = signature->verify_recover_init(ctx->op.sig.algctx, provkey,
|
|
||||||
params);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret <= 0) {
|
|
||||||
signature->freectx(ctx->op.sig.algctx);
|
|
||||||
ctx->op.sig.algctx = NULL;
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
legacy:
|
|
||||||
/*
|
|
||||||
* If we don't have the full support we need with provided methods,
|
|
||||||
* let's go see if legacy does.
|
|
||||||
*/
|
|
||||||
ERR_pop_to_mark();
|
|
||||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
|
||||||
tmp_keymgmt = NULL;
|
|
||||||
|
|
||||||
if (ctx->pmeth == NULL
|
|
||||||
|| (operation == EVP_PKEY_OP_SIGN && ctx->pmeth->sign == NULL)
|
|
||||||
|| (operation == EVP_PKEY_OP_VERIFY && ctx->pmeth->verify == NULL)
|
|
||||||
|| (operation == EVP_PKEY_OP_VERIFYRECOVER
|
|
||||||
&& ctx->pmeth->verify_recover == NULL)) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (operation) {
|
|
||||||
case EVP_PKEY_OP_SIGN:
|
|
||||||
if (ctx->pmeth->sign_init == NULL)
|
|
||||||
return 1;
|
|
||||||
ret = ctx->pmeth->sign_init(ctx);
|
|
||||||
break;
|
|
||||||
case EVP_PKEY_OP_VERIFY:
|
|
||||||
if (ctx->pmeth->verify_init == NULL)
|
|
||||||
return 1;
|
|
||||||
ret = ctx->pmeth->verify_init(ctx);
|
|
||||||
break;
|
|
||||||
case EVP_PKEY_OP_VERIFYRECOVER:
|
|
||||||
if (ctx->pmeth->verify_recover_init == NULL)
|
|
||||||
return 1;
|
|
||||||
ret = ctx->pmeth->verify_recover_init(ctx);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
if (ret <= 0)
|
|
||||||
goto err;
|
|
||||||
end:
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
if (ret > 0)
|
|
||||||
ret = evp_pkey_ctx_use_cached_data(ctx);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
|
||||||
return ret;
|
|
||||||
err:
|
|
||||||
evp_pkey_ctx_free_old_ops(ctx);
|
|
||||||
ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
|
||||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx)
|
|
||||||
{
|
|
||||||
return evp_pkey_signature_init(ctx, EVP_PKEY_OP_SIGN, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int EVP_PKEY_sign_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
return evp_pkey_signature_init(ctx, EVP_PKEY_OP_SIGN, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
int EVP_PKEY_sign(EVP_PKEY_CTX *ctx,
|
|
||||||
unsigned char *sig, size_t *siglen,
|
|
||||||
const unsigned char *tbs, size_t tbslen)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (ctx == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, ERR_R_PASSED_NULL_PARAMETER);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx->operation != EVP_PKEY_OP_SIGN) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_INITIALIZED);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx->op.sig.algctx == NULL)
|
|
||||||
goto legacy;
|
|
||||||
|
|
||||||
if (ctx->op.sig.signature->sign == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = ctx->op.sig.signature->sign(ctx->op.sig.algctx, sig, siglen,
|
|
||||||
(sig == NULL) ? 0 : *siglen, tbs, tbslen);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
legacy:
|
|
||||||
|
|
||||||
if (ctx->pmeth == NULL || ctx->pmeth->sign == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
M_check_autoarg(ctx, sig, siglen, EVP_F_EVP_PKEY_SIGN)
|
|
||||||
return ctx->pmeth->sign(ctx, sig, siglen, tbs, tbslen);
|
|
||||||
}
|
|
||||||
|
|
||||||
int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx)
|
|
||||||
{
|
|
||||||
return evp_pkey_signature_init(ctx, EVP_PKEY_OP_VERIFY, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int EVP_PKEY_verify_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
return evp_pkey_signature_init(ctx, EVP_PKEY_OP_VERIFY, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
int EVP_PKEY_verify(EVP_PKEY_CTX *ctx,
|
|
||||||
const unsigned char *sig, size_t siglen,
|
|
||||||
const unsigned char *tbs, size_t tbslen)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (ctx == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, ERR_R_PASSED_NULL_PARAMETER);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx->operation != EVP_PKEY_OP_VERIFY) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_INITIALIZED);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx->op.sig.algctx == NULL)
|
|
||||||
goto legacy;
|
|
||||||
|
|
||||||
if (ctx->op.sig.signature->verify == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = ctx->op.sig.signature->verify(ctx->op.sig.algctx, sig, siglen,
|
|
||||||
tbs, tbslen);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
legacy:
|
|
||||||
if (ctx->pmeth == NULL || ctx->pmeth->verify == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ctx->pmeth->verify(ctx, sig, siglen, tbs, tbslen);
|
|
||||||
}
|
|
||||||
|
|
||||||
int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx)
|
|
||||||
{
|
|
||||||
return evp_pkey_signature_init(ctx, EVP_PKEY_OP_VERIFYRECOVER, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int EVP_PKEY_verify_recover_init_ex(EVP_PKEY_CTX *ctx,
|
|
||||||
const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
return evp_pkey_signature_init(ctx, EVP_PKEY_OP_VERIFYRECOVER, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,
|
|
||||||
unsigned char *rout, size_t *routlen,
|
|
||||||
const unsigned char *sig, size_t siglen)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (ctx == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, ERR_R_PASSED_NULL_PARAMETER);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx->operation != EVP_PKEY_OP_VERIFYRECOVER) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_INITIALIZED);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx->op.sig.algctx == NULL)
|
|
||||||
goto legacy;
|
|
||||||
|
|
||||||
if (ctx->op.sig.signature->verify_recover == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = ctx->op.sig.signature->verify_recover(ctx->op.sig.algctx, rout,
|
|
||||||
routlen,
|
|
||||||
(rout == NULL ? 0 : *routlen),
|
|
||||||
sig, siglen);
|
|
||||||
return ret;
|
|
||||||
legacy:
|
|
||||||
if (ctx->pmeth == NULL || ctx->pmeth->verify_recover == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
M_check_autoarg(ctx, rout, routlen, EVP_F_EVP_PKEY_VERIFY_RECOVER)
|
|
||||||
return ctx->pmeth->verify_recover(ctx, rout, routlen, sig, siglen);
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
* in the file LICENSE in the source distribution or at
|
|
||||||
* https://www.openssl.org/source/license.html
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OSSL_CRYPTO_HMAC_LOCAL_H
|
|
||||||
# define OSSL_CRYPTO_HMAC_LOCAL_H
|
|
||||||
|
|
||||||
/* The current largest case is for SHA3-224 */
|
|
||||||
#define HMAC_MAX_MD_CBLOCK_SIZE 144
|
|
||||||
|
|
||||||
struct hmac_ctx_st {
|
|
||||||
const EVP_MD *md;
|
|
||||||
EVP_MD_CTX *md_ctx;
|
|
||||||
EVP_MD_CTX *i_ctx;
|
|
||||||
EVP_MD_CTX *o_ctx;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
LIBS=../../libcrypto
|
|
||||||
SOURCE[../../libcrypto]=http_client.c http_err.c http_lib.c
|
|
||||||
@@ -1,211 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2023 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 <openssl/crypto.h>
|
|
||||||
#include "crypto/rand.h"
|
|
||||||
#include "crypto/dso_conf.h"
|
|
||||||
#include "internal/thread_once.h"
|
|
||||||
#include "internal/cryptlib.h"
|
|
||||||
#include "internal/e_os.h"
|
|
||||||
#include "buildinf.h"
|
|
||||||
|
|
||||||
#if defined(__arm__) || defined(__arm) || defined(__aarch64__)
|
|
||||||
# include "arm_arch.h"
|
|
||||||
# define CPU_INFO_STR_LEN 128
|
|
||||||
#elif defined(__s390__) || defined(__s390x__)
|
|
||||||
# include "s390x_arch.h"
|
|
||||||
# define CPU_INFO_STR_LEN 2048
|
|
||||||
#else
|
|
||||||
# define CPU_INFO_STR_LEN 128
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* extern declaration to avoid warning */
|
|
||||||
extern char ossl_cpu_info_str[];
|
|
||||||
|
|
||||||
static char *seed_sources = NULL;
|
|
||||||
|
|
||||||
char ossl_cpu_info_str[CPU_INFO_STR_LEN] = "";
|
|
||||||
#define CPUINFO_PREFIX "CPUINFO: "
|
|
||||||
|
|
||||||
static CRYPTO_ONCE init_info = CRYPTO_ONCE_STATIC_INIT;
|
|
||||||
|
|
||||||
DEFINE_RUN_ONCE_STATIC(init_info_strings)
|
|
||||||
{
|
|
||||||
#if defined(OPENSSL_CPUID_OBJ)
|
|
||||||
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
|
|
||||||
defined(__x86_64) || defined(__x86_64__) || \
|
|
||||||
defined(_M_AMD64) || defined(_M_X64)
|
|
||||||
const char *env;
|
|
||||||
|
|
||||||
BIO_snprintf(ossl_cpu_info_str, sizeof(ossl_cpu_info_str),
|
|
||||||
CPUINFO_PREFIX "OPENSSL_ia32cap=0x%llx:0x%llx",
|
|
||||||
(unsigned long long)OPENSSL_ia32cap_P[0] |
|
|
||||||
(unsigned long long)OPENSSL_ia32cap_P[1] << 32,
|
|
||||||
(unsigned long long)OPENSSL_ia32cap_P[2] |
|
|
||||||
(unsigned long long)OPENSSL_ia32cap_P[3] << 32);
|
|
||||||
if ((env = getenv("OPENSSL_ia32cap")) != NULL)
|
|
||||||
BIO_snprintf(ossl_cpu_info_str + strlen(ossl_cpu_info_str),
|
|
||||||
sizeof(ossl_cpu_info_str) - strlen(ossl_cpu_info_str),
|
|
||||||
" env:%s", env);
|
|
||||||
# elif defined(__arm__) || defined(__arm) || defined(__aarch64__)
|
|
||||||
const char *env;
|
|
||||||
|
|
||||||
BIO_snprintf(ossl_cpu_info_str, sizeof(ossl_cpu_info_str),
|
|
||||||
CPUINFO_PREFIX "OPENSSL_armcap=0x%x", OPENSSL_armcap_P);
|
|
||||||
if ((env = getenv("OPENSSL_armcap")) != NULL)
|
|
||||||
BIO_snprintf(ossl_cpu_info_str + strlen(ossl_cpu_info_str),
|
|
||||||
sizeof(ossl_cpu_info_str) - strlen(ossl_cpu_info_str),
|
|
||||||
" env:%s", env);
|
|
||||||
# elif defined(__s390__) || defined(__s390x__)
|
|
||||||
const char *env;
|
|
||||||
|
|
||||||
BIO_snprintf(ossl_cpu_info_str, sizeof(ossl_cpu_info_str),
|
|
||||||
CPUINFO_PREFIX "OPENSSL_s390xcap="
|
|
||||||
"stfle:0x%llx:0x%llx:0x%llx:0x%llx:"
|
|
||||||
"kimd:0x%llx:0x%llx:"
|
|
||||||
"klmd:0x%llx:0x%llx:"
|
|
||||||
"km:0x%llx:0x%llx:"
|
|
||||||
"kmc:0x%llx:0x%llx:"
|
|
||||||
"kmac:0x%llx:0x%llx:"
|
|
||||||
"kmctr:0x%llx:0x%llx:"
|
|
||||||
"kmo:0x%llx:0x%llx:"
|
|
||||||
"kmf:0x%llx:0x%llx:"
|
|
||||||
"prno:0x%llx:0x%llx:"
|
|
||||||
"kma:0x%llx:0x%llx:"
|
|
||||||
"pcc:0x%llx:0x%llx:"
|
|
||||||
"kdsa:0x%llx:0x%llx",
|
|
||||||
OPENSSL_s390xcap_P.stfle[0], OPENSSL_s390xcap_P.stfle[1],
|
|
||||||
OPENSSL_s390xcap_P.stfle[2], OPENSSL_s390xcap_P.stfle[3],
|
|
||||||
OPENSSL_s390xcap_P.kimd[0], OPENSSL_s390xcap_P.kimd[1],
|
|
||||||
OPENSSL_s390xcap_P.klmd[0], OPENSSL_s390xcap_P.klmd[1],
|
|
||||||
OPENSSL_s390xcap_P.km[0], OPENSSL_s390xcap_P.km[1],
|
|
||||||
OPENSSL_s390xcap_P.kmc[0], OPENSSL_s390xcap_P.kmc[1],
|
|
||||||
OPENSSL_s390xcap_P.kmac[0], OPENSSL_s390xcap_P.kmac[1],
|
|
||||||
OPENSSL_s390xcap_P.kmctr[0], OPENSSL_s390xcap_P.kmctr[1],
|
|
||||||
OPENSSL_s390xcap_P.kmo[0], OPENSSL_s390xcap_P.kmo[1],
|
|
||||||
OPENSSL_s390xcap_P.kmf[0], OPENSSL_s390xcap_P.kmf[1],
|
|
||||||
OPENSSL_s390xcap_P.prno[0], OPENSSL_s390xcap_P.prno[1],
|
|
||||||
OPENSSL_s390xcap_P.kma[0], OPENSSL_s390xcap_P.kma[1],
|
|
||||||
OPENSSL_s390xcap_P.pcc[0], OPENSSL_s390xcap_P.pcc[1],
|
|
||||||
OPENSSL_s390xcap_P.kdsa[0], OPENSSL_s390xcap_P.kdsa[1]);
|
|
||||||
if ((env = getenv("OPENSSL_s390xcap")) != NULL)
|
|
||||||
BIO_snprintf(ossl_cpu_info_str + strlen(ossl_cpu_info_str),
|
|
||||||
sizeof(ossl_cpu_info_str) - strlen(ossl_cpu_info_str),
|
|
||||||
" env:%s", env);
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{
|
|
||||||
static char seeds[512] = "";
|
|
||||||
|
|
||||||
#define add_seeds_string(str) \
|
|
||||||
do { \
|
|
||||||
if (seeds[0] != '\0') \
|
|
||||||
OPENSSL_strlcat(seeds, " ", sizeof(seeds)); \
|
|
||||||
OPENSSL_strlcat(seeds, str, sizeof(seeds)); \
|
|
||||||
} while (0)
|
|
||||||
#define add_seeds_stringlist(label, strlist) \
|
|
||||||
do { \
|
|
||||||
add_seeds_string(label "("); \
|
|
||||||
{ \
|
|
||||||
const char *dev[] = { strlist, NULL }; \
|
|
||||||
const char **p; \
|
|
||||||
int first = 1; \
|
|
||||||
\
|
|
||||||
for (p = dev; *p != NULL; p++) { \
|
|
||||||
if (!first) \
|
|
||||||
OPENSSL_strlcat(seeds, " ", sizeof(seeds)); \
|
|
||||||
first = 0; \
|
|
||||||
OPENSSL_strlcat(seeds, *p, sizeof(seeds)); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
OPENSSL_strlcat(seeds, ")", sizeof(seeds)); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#ifdef OPENSSL_RAND_SEED_NONE
|
|
||||||
add_seeds_string("none");
|
|
||||||
#endif
|
|
||||||
#ifdef OPENSSL_RAND_SEED_RDTSC
|
|
||||||
add_seeds_string("rdtsc");
|
|
||||||
#endif
|
|
||||||
#ifdef OPENSSL_RAND_SEED_RDCPU
|
|
||||||
# ifdef __aarch64__
|
|
||||||
add_seeds_string("rndr ( rndrrs rndr )");
|
|
||||||
# else
|
|
||||||
add_seeds_string("rdrand ( rdseed rdrand )");
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifdef OPENSSL_RAND_SEED_LIBRANDOM
|
|
||||||
add_seeds_string("C-library-random");
|
|
||||||
#endif
|
|
||||||
#ifdef OPENSSL_RAND_SEED_GETRANDOM
|
|
||||||
add_seeds_string("getrandom-syscall");
|
|
||||||
#endif
|
|
||||||
#ifdef OPENSSL_RAND_SEED_DEVRANDOM
|
|
||||||
add_seeds_stringlist("random-device", DEVRANDOM);
|
|
||||||
#endif
|
|
||||||
#ifdef OPENSSL_RAND_SEED_EGD
|
|
||||||
add_seeds_stringlist("EGD", DEVRANDOM_EGD);
|
|
||||||
#endif
|
|
||||||
#ifdef OPENSSL_RAND_SEED_OS
|
|
||||||
add_seeds_string("os-specific");
|
|
||||||
#endif
|
|
||||||
seed_sources = seeds;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *OPENSSL_info(int t)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* We don't care about the result. Worst case scenario, the strings
|
|
||||||
* won't be initialised, i.e. remain NULL, which means that the info
|
|
||||||
* isn't available anyway...
|
|
||||||
*/
|
|
||||||
(void)RUN_ONCE(&init_info, init_info_strings);
|
|
||||||
|
|
||||||
switch (t) {
|
|
||||||
case OPENSSL_INFO_CONFIG_DIR:
|
|
||||||
return OPENSSLDIR;
|
|
||||||
case OPENSSL_INFO_ENGINES_DIR:
|
|
||||||
return ENGINESDIR;
|
|
||||||
case OPENSSL_INFO_MODULES_DIR:
|
|
||||||
return MODULESDIR;
|
|
||||||
case OPENSSL_INFO_DSO_EXTENSION:
|
|
||||||
return DSO_EXTENSION;
|
|
||||||
case OPENSSL_INFO_DIR_FILENAME_SEPARATOR:
|
|
||||||
#if defined(_WIN32)
|
|
||||||
return "\\";
|
|
||||||
#elif defined(__VMS)
|
|
||||||
return "";
|
|
||||||
#else /* Assume POSIX */
|
|
||||||
return "/";
|
|
||||||
#endif
|
|
||||||
case OPENSSL_INFO_LIST_SEPARATOR:
|
|
||||||
{
|
|
||||||
static const char list_sep[] = { LIST_SEPARATOR_CHAR, '\0' };
|
|
||||||
return list_sep;
|
|
||||||
}
|
|
||||||
case OPENSSL_INFO_SEED_SOURCE:
|
|
||||||
return seed_sources;
|
|
||||||
case OPENSSL_INFO_CPU_SETTINGS:
|
|
||||||
/*
|
|
||||||
* If successfully initialized, ossl_cpu_info_str will start
|
|
||||||
* with CPUINFO_PREFIX, if failed it will be an empty string.
|
|
||||||
* Strip away the CPUINFO_PREFIX which we don't need here.
|
|
||||||
*/
|
|
||||||
if (ossl_cpu_info_str[0] != '\0')
|
|
||||||
return ossl_cpu_info_str + strlen(CPUINFO_PREFIX);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* Not an error */
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
@@ -1,478 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2023 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 <openssl/crypto.h>
|
|
||||||
#include <openssl/core_dispatch.h>
|
|
||||||
#include "crypto/cryptlib.h"
|
|
||||||
#include "prov/providercommon.h"
|
|
||||||
#include "internal/thread_once.h"
|
|
||||||
#include "crypto/context.h"
|
|
||||||
|
|
||||||
#ifdef FIPS_MODULE
|
|
||||||
#include "prov/provider_ctx.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Thread aware code may want to be told about thread stop events. We register
|
|
||||||
* to hear about those thread stop events when we see a new thread has started.
|
|
||||||
* We call the ossl_init_thread_start function to do that. In the FIPS provider
|
|
||||||
* we have our own copy of ossl_init_thread_start, which cascades notifications
|
|
||||||
* about threads stopping from libcrypto to all the code in the FIPS provider
|
|
||||||
* that needs to know about it.
|
|
||||||
*
|
|
||||||
* The FIPS provider tells libcrypto about which threads it is interested in
|
|
||||||
* by calling "c_thread_start" which is a function pointer created during
|
|
||||||
* provider initialisation (i.e. OSSL_init_provider).
|
|
||||||
*/
|
|
||||||
extern OSSL_FUNC_core_thread_start_fn *c_thread_start;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct thread_event_handler_st THREAD_EVENT_HANDLER;
|
|
||||||
struct thread_event_handler_st {
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
const void *index;
|
|
||||||
#endif
|
|
||||||
void *arg;
|
|
||||||
OSSL_thread_stop_handler_fn handfn;
|
|
||||||
THREAD_EVENT_HANDLER *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
DEFINE_SPECIAL_STACK_OF(THREAD_EVENT_HANDLER_PTR, THREAD_EVENT_HANDLER *)
|
|
||||||
|
|
||||||
typedef struct global_tevent_register_st GLOBAL_TEVENT_REGISTER;
|
|
||||||
struct global_tevent_register_st {
|
|
||||||
STACK_OF(THREAD_EVENT_HANDLER_PTR) *skhands;
|
|
||||||
CRYPTO_RWLOCK *lock;
|
|
||||||
};
|
|
||||||
|
|
||||||
static GLOBAL_TEVENT_REGISTER *glob_tevent_reg = NULL;
|
|
||||||
|
|
||||||
static CRYPTO_ONCE tevent_register_runonce = CRYPTO_ONCE_STATIC_INIT;
|
|
||||||
|
|
||||||
DEFINE_RUN_ONCE_STATIC(create_global_tevent_register)
|
|
||||||
{
|
|
||||||
glob_tevent_reg = OPENSSL_zalloc(sizeof(*glob_tevent_reg));
|
|
||||||
if (glob_tevent_reg == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
glob_tevent_reg->skhands = sk_THREAD_EVENT_HANDLER_PTR_new_null();
|
|
||||||
glob_tevent_reg->lock = CRYPTO_THREAD_lock_new();
|
|
||||||
if (glob_tevent_reg->skhands == NULL || glob_tevent_reg->lock == NULL) {
|
|
||||||
sk_THREAD_EVENT_HANDLER_PTR_free(glob_tevent_reg->skhands);
|
|
||||||
CRYPTO_THREAD_lock_free(glob_tevent_reg->lock);
|
|
||||||
OPENSSL_free(glob_tevent_reg);
|
|
||||||
glob_tevent_reg = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GLOBAL_TEVENT_REGISTER *get_global_tevent_register(void)
|
|
||||||
{
|
|
||||||
if (!RUN_ONCE(&tevent_register_runonce, create_global_tevent_register))
|
|
||||||
return NULL;
|
|
||||||
return glob_tevent_reg;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
static int init_thread_push_handlers(THREAD_EVENT_HANDLER **hands);
|
|
||||||
static void init_thread_remove_handlers(THREAD_EVENT_HANDLER **handsin);
|
|
||||||
static void init_thread_destructor(void *hands);
|
|
||||||
static int init_thread_deregister(void *arg, int all);
|
|
||||||
#endif
|
|
||||||
static void init_thread_stop(void *arg, THREAD_EVENT_HANDLER **hands);
|
|
||||||
|
|
||||||
static THREAD_EVENT_HANDLER **
|
|
||||||
init_get_thread_local(CRYPTO_THREAD_LOCAL *local, int alloc, int keep)
|
|
||||||
{
|
|
||||||
THREAD_EVENT_HANDLER **hands = CRYPTO_THREAD_get_local(local);
|
|
||||||
|
|
||||||
if (alloc) {
|
|
||||||
if (hands == NULL) {
|
|
||||||
|
|
||||||
if ((hands = OPENSSL_zalloc(sizeof(*hands))) == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_set_local(local, hands)) {
|
|
||||||
OPENSSL_free(hands);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
if (!init_thread_push_handlers(hands)) {
|
|
||||||
CRYPTO_THREAD_set_local(local, NULL);
|
|
||||||
OPENSSL_free(hands);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
} else if (!keep) {
|
|
||||||
CRYPTO_THREAD_set_local(local, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return hands;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
/*
|
|
||||||
* Since per-thread-specific-data destructors are not universally
|
|
||||||
* available, i.e. not on Windows, only below CRYPTO_THREAD_LOCAL key
|
|
||||||
* is assumed to have destructor associated. And then an effort is made
|
|
||||||
* to call this single destructor on non-pthread platform[s].
|
|
||||||
*
|
|
||||||
* Initial value is "impossible". It is used as guard value to shortcut
|
|
||||||
* destructor for threads terminating before libcrypto is initialized or
|
|
||||||
* after it's de-initialized. Access to the key doesn't have to be
|
|
||||||
* serialized for the said threads, because they didn't use libcrypto
|
|
||||||
* and it doesn't matter if they pick "impossible" or dereference real
|
|
||||||
* key value and pull NULL past initialization in the first thread that
|
|
||||||
* intends to use libcrypto.
|
|
||||||
*/
|
|
||||||
static union {
|
|
||||||
long sane;
|
|
||||||
CRYPTO_THREAD_LOCAL value;
|
|
||||||
} destructor_key = { -1 };
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The thread event handler list is a thread specific linked list
|
|
||||||
* of callback functions which are invoked in list order by the
|
|
||||||
* current thread in case of certain events. (Currently, there is
|
|
||||||
* only one type of event, the 'thread stop' event.)
|
|
||||||
*
|
|
||||||
* We also keep a global reference to that linked list, so that we
|
|
||||||
* can deregister handlers if necessary before all the threads are
|
|
||||||
* stopped.
|
|
||||||
*/
|
|
||||||
static int init_thread_push_handlers(THREAD_EVENT_HANDLER **hands)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
GLOBAL_TEVENT_REGISTER *gtr;
|
|
||||||
|
|
||||||
gtr = get_global_tevent_register();
|
|
||||||
if (gtr == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_write_lock(gtr->lock))
|
|
||||||
return 0;
|
|
||||||
ret = (sk_THREAD_EVENT_HANDLER_PTR_push(gtr->skhands, hands) != 0);
|
|
||||||
CRYPTO_THREAD_unlock(gtr->lock);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void init_thread_remove_handlers(THREAD_EVENT_HANDLER **handsin)
|
|
||||||
{
|
|
||||||
GLOBAL_TEVENT_REGISTER *gtr;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
gtr = get_global_tevent_register();
|
|
||||||
if (gtr == NULL)
|
|
||||||
return;
|
|
||||||
if (!CRYPTO_THREAD_write_lock(gtr->lock))
|
|
||||||
return;
|
|
||||||
for (i = 0; i < sk_THREAD_EVENT_HANDLER_PTR_num(gtr->skhands); i++) {
|
|
||||||
THREAD_EVENT_HANDLER **hands
|
|
||||||
= sk_THREAD_EVENT_HANDLER_PTR_value(gtr->skhands, i);
|
|
||||||
|
|
||||||
if (hands == handsin) {
|
|
||||||
sk_THREAD_EVENT_HANDLER_PTR_delete(gtr->skhands, i);
|
|
||||||
CRYPTO_THREAD_unlock(gtr->lock);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CRYPTO_THREAD_unlock(gtr->lock);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void init_thread_destructor(void *hands)
|
|
||||||
{
|
|
||||||
init_thread_stop(NULL, (THREAD_EVENT_HANDLER **)hands);
|
|
||||||
init_thread_remove_handlers(hands);
|
|
||||||
OPENSSL_free(hands);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_init_thread(void)
|
|
||||||
{
|
|
||||||
if (!CRYPTO_THREAD_init_local(&destructor_key.value,
|
|
||||||
init_thread_destructor))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ossl_cleanup_thread(void)
|
|
||||||
{
|
|
||||||
init_thread_deregister(NULL, 1);
|
|
||||||
CRYPTO_THREAD_cleanup_local(&destructor_key.value);
|
|
||||||
destructor_key.sane = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OPENSSL_thread_stop_ex(OSSL_LIB_CTX *ctx)
|
|
||||||
{
|
|
||||||
ctx = ossl_lib_ctx_get_concrete(ctx);
|
|
||||||
/*
|
|
||||||
* It would be nice if we could figure out a way to do this on all threads
|
|
||||||
* that have used the OSSL_LIB_CTX when the context is freed. This is
|
|
||||||
* currently not possible due to the use of thread local variables.
|
|
||||||
*/
|
|
||||||
ossl_ctx_thread_stop(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OPENSSL_thread_stop(void)
|
|
||||||
{
|
|
||||||
if (destructor_key.sane != -1) {
|
|
||||||
THREAD_EVENT_HANDLER **hands
|
|
||||||
= init_get_thread_local(&destructor_key.value, 0, 0);
|
|
||||||
init_thread_stop(NULL, hands);
|
|
||||||
|
|
||||||
init_thread_remove_handlers(hands);
|
|
||||||
OPENSSL_free(hands);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ossl_ctx_thread_stop(OSSL_LIB_CTX *ctx)
|
|
||||||
{
|
|
||||||
if (destructor_key.sane != -1) {
|
|
||||||
THREAD_EVENT_HANDLER **hands
|
|
||||||
= init_get_thread_local(&destructor_key.value, 0, 1);
|
|
||||||
init_thread_stop(ctx, hands);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
static void ossl_arg_thread_stop(void *arg);
|
|
||||||
|
|
||||||
/* Register the current thread so that we are informed if it gets stopped */
|
|
||||||
int ossl_thread_register_fips(OSSL_LIB_CTX *libctx)
|
|
||||||
{
|
|
||||||
return c_thread_start(FIPS_get_core_handle(libctx), ossl_arg_thread_stop,
|
|
||||||
libctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *ossl_thread_event_ctx_new(OSSL_LIB_CTX *libctx)
|
|
||||||
{
|
|
||||||
THREAD_EVENT_HANDLER **hands = NULL;
|
|
||||||
CRYPTO_THREAD_LOCAL *tlocal = OPENSSL_zalloc(sizeof(*tlocal));
|
|
||||||
|
|
||||||
if (tlocal == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_init_local(tlocal, NULL)) {
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
hands = OPENSSL_zalloc(sizeof(*hands));
|
|
||||||
if (hands == NULL)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_set_local(tlocal, hands))
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We should ideally call ossl_thread_register_fips() here. This function
|
|
||||||
* is called during the startup of the FIPS provider and we need to ensure
|
|
||||||
* that the main thread is registered to receive thread callbacks in order
|
|
||||||
* to free |hands| that we allocated above. However we are too early in
|
|
||||||
* the FIPS provider initialisation that FIPS_get_core_handle() doesn't work
|
|
||||||
* yet. So we defer this to the main provider OSSL_provider_init_int()
|
|
||||||
* function.
|
|
||||||
*/
|
|
||||||
|
|
||||||
return tlocal;
|
|
||||||
err:
|
|
||||||
OPENSSL_free(hands);
|
|
||||||
OPENSSL_free(tlocal);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ossl_thread_event_ctx_free(void *tlocal)
|
|
||||||
{
|
|
||||||
OPENSSL_free(tlocal);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ossl_arg_thread_stop(void *arg)
|
|
||||||
{
|
|
||||||
ossl_ctx_thread_stop((OSSL_LIB_CTX *)arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ossl_ctx_thread_stop(OSSL_LIB_CTX *ctx)
|
|
||||||
{
|
|
||||||
THREAD_EVENT_HANDLER **hands;
|
|
||||||
CRYPTO_THREAD_LOCAL *local
|
|
||||||
= ossl_lib_ctx_get_data(ctx, OSSL_LIB_CTX_THREAD_EVENT_HANDLER_INDEX);
|
|
||||||
|
|
||||||
if (local == NULL)
|
|
||||||
return;
|
|
||||||
hands = init_get_thread_local(local, 0, 0);
|
|
||||||
init_thread_stop(ctx, hands);
|
|
||||||
OPENSSL_free(hands);
|
|
||||||
}
|
|
||||||
#endif /* FIPS_MODULE */
|
|
||||||
|
|
||||||
|
|
||||||
static void init_thread_stop(void *arg, THREAD_EVENT_HANDLER **hands)
|
|
||||||
{
|
|
||||||
THREAD_EVENT_HANDLER *curr, *prev = NULL, *tmp;
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
GLOBAL_TEVENT_REGISTER *gtr;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Can't do much about this */
|
|
||||||
if (hands == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
gtr = get_global_tevent_register();
|
|
||||||
if (gtr == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_write_lock(gtr->lock))
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
curr = *hands;
|
|
||||||
while (curr != NULL) {
|
|
||||||
if (arg != NULL && curr->arg != arg) {
|
|
||||||
prev = curr;
|
|
||||||
curr = curr->next;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
curr->handfn(curr->arg);
|
|
||||||
if (prev == NULL)
|
|
||||||
*hands = curr->next;
|
|
||||||
else
|
|
||||||
prev->next = curr->next;
|
|
||||||
|
|
||||||
tmp = curr;
|
|
||||||
curr = curr->next;
|
|
||||||
|
|
||||||
OPENSSL_free(tmp);
|
|
||||||
}
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
CRYPTO_THREAD_unlock(gtr->lock);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_init_thread_start(const void *index, void *arg,
|
|
||||||
OSSL_thread_stop_handler_fn handfn)
|
|
||||||
{
|
|
||||||
THREAD_EVENT_HANDLER **hands;
|
|
||||||
THREAD_EVENT_HANDLER *hand;
|
|
||||||
#ifdef FIPS_MODULE
|
|
||||||
OSSL_LIB_CTX *ctx = arg;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* In FIPS mode the list of THREAD_EVENT_HANDLERs is unique per combination
|
|
||||||
* of OSSL_LIB_CTX and thread. This is because in FIPS mode each
|
|
||||||
* OSSL_LIB_CTX gets informed about thread stop events individually.
|
|
||||||
*/
|
|
||||||
CRYPTO_THREAD_LOCAL *local
|
|
||||||
= ossl_lib_ctx_get_data(ctx, OSSL_LIB_CTX_THREAD_EVENT_HANDLER_INDEX);
|
|
||||||
#else
|
|
||||||
/*
|
|
||||||
* Outside of FIPS mode the list of THREAD_EVENT_HANDLERs is unique per
|
|
||||||
* thread, but may hold multiple OSSL_LIB_CTXs. We only get told about
|
|
||||||
* thread stop events globally, so we have to ensure all affected
|
|
||||||
* OSSL_LIB_CTXs are informed.
|
|
||||||
*/
|
|
||||||
CRYPTO_THREAD_LOCAL *local = &destructor_key.value;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
hands = init_get_thread_local(local, 1, 0);
|
|
||||||
if (hands == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#ifdef FIPS_MODULE
|
|
||||||
if (*hands == NULL) {
|
|
||||||
/*
|
|
||||||
* We've not yet registered any handlers for this thread. We need to get
|
|
||||||
* libcrypto to tell us about later thread stop events. c_thread_start
|
|
||||||
* is a callback to libcrypto defined in fipsprov.c
|
|
||||||
*/
|
|
||||||
if (!ossl_thread_register_fips(ctx))
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
hand = OPENSSL_malloc(sizeof(*hand));
|
|
||||||
if (hand == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
hand->handfn = handfn;
|
|
||||||
hand->arg = arg;
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
hand->index = index;
|
|
||||||
#endif
|
|
||||||
hand->next = *hands;
|
|
||||||
*hands = hand;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
static int init_thread_deregister(void *index, int all)
|
|
||||||
{
|
|
||||||
GLOBAL_TEVENT_REGISTER *gtr;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
gtr = get_global_tevent_register();
|
|
||||||
if (gtr == NULL)
|
|
||||||
return 0;
|
|
||||||
if (!all) {
|
|
||||||
if (!CRYPTO_THREAD_write_lock(gtr->lock))
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
glob_tevent_reg = NULL;
|
|
||||||
}
|
|
||||||
for (i = 0; i < sk_THREAD_EVENT_HANDLER_PTR_num(gtr->skhands); i++) {
|
|
||||||
THREAD_EVENT_HANDLER **hands
|
|
||||||
= sk_THREAD_EVENT_HANDLER_PTR_value(gtr->skhands, i);
|
|
||||||
THREAD_EVENT_HANDLER *curr = NULL, *prev = NULL, *tmp;
|
|
||||||
|
|
||||||
if (hands == NULL) {
|
|
||||||
if (!all)
|
|
||||||
CRYPTO_THREAD_unlock(gtr->lock);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
curr = *hands;
|
|
||||||
while (curr != NULL) {
|
|
||||||
if (all || curr->index == index) {
|
|
||||||
if (prev != NULL)
|
|
||||||
prev->next = curr->next;
|
|
||||||
else
|
|
||||||
*hands = curr->next;
|
|
||||||
tmp = curr;
|
|
||||||
curr = curr->next;
|
|
||||||
OPENSSL_free(tmp);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
prev = curr;
|
|
||||||
curr = curr->next;
|
|
||||||
}
|
|
||||||
if (all)
|
|
||||||
OPENSSL_free(hands);
|
|
||||||
}
|
|
||||||
if (all) {
|
|
||||||
CRYPTO_THREAD_lock_free(gtr->lock);
|
|
||||||
sk_THREAD_EVENT_HANDLER_PTR_free(gtr->skhands);
|
|
||||||
OPENSSL_free(gtr);
|
|
||||||
} else {
|
|
||||||
CRYPTO_THREAD_unlock(gtr->lock);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_init_thread_deregister(void *index)
|
|
||||||
{
|
|
||||||
return init_thread_deregister(index, 0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -1,729 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015-2023 The OpenSSL Project Authors. All Rights Reserved.
|
|
||||||
* Copyright 2004-2014, Akamai Technologies. 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is in two halves. The first half implements the public API
|
|
||||||
* to be used by external consumers, and to be used by OpenSSL to store
|
|
||||||
* data in a "secure arena." The second half implements the secure arena.
|
|
||||||
* For details on that implementation, see below (look for uppercase
|
|
||||||
* "SECURE HEAP IMPLEMENTATION").
|
|
||||||
*/
|
|
||||||
#include "internal/e_os.h"
|
|
||||||
#include <openssl/crypto.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_SECURE_MEMORY
|
|
||||||
# if defined(_WIN32)
|
|
||||||
# include <windows.h>
|
|
||||||
# if defined(WINAPI_FAMILY_PARTITION)
|
|
||||||
# if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
|
|
||||||
/*
|
|
||||||
* While VirtualLock is available under the app partition (e.g. UWP),
|
|
||||||
* the headers do not define the API. Define it ourselves instead.
|
|
||||||
*/
|
|
||||||
WINBASEAPI
|
|
||||||
BOOL
|
|
||||||
WINAPI
|
|
||||||
VirtualLock(
|
|
||||||
_In_ LPVOID lpAddress,
|
|
||||||
_In_ SIZE_T dwSize
|
|
||||||
);
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <assert.h>
|
|
||||||
# if defined(OPENSSL_SYS_UNIX)
|
|
||||||
# include <unistd.h>
|
|
||||||
# endif
|
|
||||||
# include <sys/types.h>
|
|
||||||
# if defined(OPENSSL_SYS_UNIX)
|
|
||||||
# include <sys/mman.h>
|
|
||||||
# if defined(__FreeBSD__)
|
|
||||||
# define MADV_DONTDUMP MADV_NOCORE
|
|
||||||
# endif
|
|
||||||
# if !defined(MAP_CONCEAL)
|
|
||||||
# define MAP_CONCEAL 0
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# if defined(OPENSSL_SYS_LINUX)
|
|
||||||
# include <sys/syscall.h>
|
|
||||||
# if defined(SYS_mlock2)
|
|
||||||
# include <linux/mman.h>
|
|
||||||
# include <errno.h>
|
|
||||||
# endif
|
|
||||||
# include <sys/param.h>
|
|
||||||
# endif
|
|
||||||
# include <sys/stat.h>
|
|
||||||
# include <fcntl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CLEAR(p, s) OPENSSL_cleanse(p, s)
|
|
||||||
#ifndef PAGE_SIZE
|
|
||||||
# define PAGE_SIZE 4096
|
|
||||||
#endif
|
|
||||||
#if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)
|
|
||||||
# define MAP_ANON MAP_ANONYMOUS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_SECURE_MEMORY
|
|
||||||
static size_t secure_mem_used;
|
|
||||||
|
|
||||||
static int secure_mem_initialized;
|
|
||||||
|
|
||||||
static CRYPTO_RWLOCK *sec_malloc_lock = NULL;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These are the functions that must be implemented by a secure heap (sh).
|
|
||||||
*/
|
|
||||||
static int sh_init(size_t size, size_t minsize);
|
|
||||||
static void *sh_malloc(size_t size);
|
|
||||||
static void sh_free(void *ptr);
|
|
||||||
static void sh_done(void);
|
|
||||||
static size_t sh_actual_size(char *ptr);
|
|
||||||
static int sh_allocated(const char *ptr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int CRYPTO_secure_malloc_init(size_t size, size_t minsize)
|
|
||||||
{
|
|
||||||
#ifndef OPENSSL_NO_SECURE_MEMORY
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (!secure_mem_initialized) {
|
|
||||||
sec_malloc_lock = CRYPTO_THREAD_lock_new();
|
|
||||||
if (sec_malloc_lock == NULL)
|
|
||||||
return 0;
|
|
||||||
if ((ret = sh_init(size, minsize)) != 0) {
|
|
||||||
secure_mem_initialized = 1;
|
|
||||||
} else {
|
|
||||||
CRYPTO_THREAD_lock_free(sec_malloc_lock);
|
|
||||||
sec_malloc_lock = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif /* OPENSSL_NO_SECURE_MEMORY */
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_secure_malloc_done(void)
|
|
||||||
{
|
|
||||||
#ifndef OPENSSL_NO_SECURE_MEMORY
|
|
||||||
if (secure_mem_used == 0) {
|
|
||||||
sh_done();
|
|
||||||
secure_mem_initialized = 0;
|
|
||||||
CRYPTO_THREAD_lock_free(sec_malloc_lock);
|
|
||||||
sec_malloc_lock = NULL;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif /* OPENSSL_NO_SECURE_MEMORY */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_secure_malloc_initialized(void)
|
|
||||||
{
|
|
||||||
#ifndef OPENSSL_NO_SECURE_MEMORY
|
|
||||||
return secure_mem_initialized;
|
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif /* OPENSSL_NO_SECURE_MEMORY */
|
|
||||||
}
|
|
||||||
|
|
||||||
void *CRYPTO_secure_malloc(size_t num, const char *file, int line)
|
|
||||||
{
|
|
||||||
#ifndef OPENSSL_NO_SECURE_MEMORY
|
|
||||||
void *ret;
|
|
||||||
size_t actual_size;
|
|
||||||
|
|
||||||
if (!secure_mem_initialized) {
|
|
||||||
return CRYPTO_malloc(num, file, line);
|
|
||||||
}
|
|
||||||
if (!CRYPTO_THREAD_write_lock(sec_malloc_lock))
|
|
||||||
return NULL;
|
|
||||||
ret = sh_malloc(num);
|
|
||||||
actual_size = ret ? sh_actual_size(ret) : 0;
|
|
||||||
secure_mem_used += actual_size;
|
|
||||||
CRYPTO_THREAD_unlock(sec_malloc_lock);
|
|
||||||
return ret;
|
|
||||||
#else
|
|
||||||
return CRYPTO_malloc(num, file, line);
|
|
||||||
#endif /* OPENSSL_NO_SECURE_MEMORY */
|
|
||||||
}
|
|
||||||
|
|
||||||
void *CRYPTO_secure_zalloc(size_t num, const char *file, int line)
|
|
||||||
{
|
|
||||||
#ifndef OPENSSL_NO_SECURE_MEMORY
|
|
||||||
if (secure_mem_initialized)
|
|
||||||
/* CRYPTO_secure_malloc() zeroes allocations when it is implemented */
|
|
||||||
return CRYPTO_secure_malloc(num, file, line);
|
|
||||||
#endif
|
|
||||||
return CRYPTO_zalloc(num, file, line);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CRYPTO_secure_free(void *ptr, const char *file, int line)
|
|
||||||
{
|
|
||||||
#ifndef OPENSSL_NO_SECURE_MEMORY
|
|
||||||
size_t actual_size;
|
|
||||||
|
|
||||||
if (ptr == NULL)
|
|
||||||
return;
|
|
||||||
if (!CRYPTO_secure_allocated(ptr)) {
|
|
||||||
CRYPTO_free(ptr, file, line);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!CRYPTO_THREAD_write_lock(sec_malloc_lock))
|
|
||||||
return;
|
|
||||||
actual_size = sh_actual_size(ptr);
|
|
||||||
CLEAR(ptr, actual_size);
|
|
||||||
secure_mem_used -= actual_size;
|
|
||||||
sh_free(ptr);
|
|
||||||
CRYPTO_THREAD_unlock(sec_malloc_lock);
|
|
||||||
#else
|
|
||||||
CRYPTO_free(ptr, file, line);
|
|
||||||
#endif /* OPENSSL_NO_SECURE_MEMORY */
|
|
||||||
}
|
|
||||||
|
|
||||||
void CRYPTO_secure_clear_free(void *ptr, size_t num,
|
|
||||||
const char *file, int line)
|
|
||||||
{
|
|
||||||
#ifndef OPENSSL_NO_SECURE_MEMORY
|
|
||||||
size_t actual_size;
|
|
||||||
|
|
||||||
if (ptr == NULL)
|
|
||||||
return;
|
|
||||||
if (!CRYPTO_secure_allocated(ptr)) {
|
|
||||||
OPENSSL_cleanse(ptr, num);
|
|
||||||
CRYPTO_free(ptr, file, line);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!CRYPTO_THREAD_write_lock(sec_malloc_lock))
|
|
||||||
return;
|
|
||||||
actual_size = sh_actual_size(ptr);
|
|
||||||
CLEAR(ptr, actual_size);
|
|
||||||
secure_mem_used -= actual_size;
|
|
||||||
sh_free(ptr);
|
|
||||||
CRYPTO_THREAD_unlock(sec_malloc_lock);
|
|
||||||
#else
|
|
||||||
if (ptr == NULL)
|
|
||||||
return;
|
|
||||||
OPENSSL_cleanse(ptr, num);
|
|
||||||
CRYPTO_free(ptr, file, line);
|
|
||||||
#endif /* OPENSSL_NO_SECURE_MEMORY */
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_secure_allocated(const void *ptr)
|
|
||||||
{
|
|
||||||
#ifndef OPENSSL_NO_SECURE_MEMORY
|
|
||||||
if (!secure_mem_initialized)
|
|
||||||
return 0;
|
|
||||||
/*
|
|
||||||
* Only read accesses to the arena take place in sh_allocated() and this
|
|
||||||
* is only changed by the sh_init() and sh_done() calls which are not
|
|
||||||
* locked. Hence, it is safe to make this check without a lock too.
|
|
||||||
*/
|
|
||||||
return sh_allocated(ptr);
|
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif /* OPENSSL_NO_SECURE_MEMORY */
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t CRYPTO_secure_used(void)
|
|
||||||
{
|
|
||||||
size_t ret = 0;
|
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_SECURE_MEMORY
|
|
||||||
if (!CRYPTO_THREAD_read_lock(sec_malloc_lock))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ret = secure_mem_used;
|
|
||||||
|
|
||||||
CRYPTO_THREAD_unlock(sec_malloc_lock);
|
|
||||||
#endif /* OPENSSL_NO_SECURE_MEMORY */
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t CRYPTO_secure_actual_size(void *ptr)
|
|
||||||
{
|
|
||||||
#ifndef OPENSSL_NO_SECURE_MEMORY
|
|
||||||
size_t actual_size;
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_write_lock(sec_malloc_lock))
|
|
||||||
return 0;
|
|
||||||
actual_size = sh_actual_size(ptr);
|
|
||||||
CRYPTO_THREAD_unlock(sec_malloc_lock);
|
|
||||||
return actual_size;
|
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SECURE HEAP IMPLEMENTATION
|
|
||||||
*/
|
|
||||||
#ifndef OPENSSL_NO_SECURE_MEMORY
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The implementation provided here uses a fixed-sized mmap() heap,
|
|
||||||
* which is locked into memory, not written to core files, and protected
|
|
||||||
* on either side by an unmapped page, which will catch pointer overruns
|
|
||||||
* (or underruns) and an attempt to read data out of the secure heap.
|
|
||||||
* Free'd memory is zero'd or otherwise cleansed.
|
|
||||||
*
|
|
||||||
* This is a pretty standard buddy allocator. We keep areas in a multiple
|
|
||||||
* of "sh.minsize" units. The freelist and bitmaps are kept separately,
|
|
||||||
* so all (and only) data is kept in the mmap'd heap.
|
|
||||||
*
|
|
||||||
* This code assumes eight-bit bytes. The numbers 3 and 7 are all over the
|
|
||||||
* place.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define ONE ((size_t)1)
|
|
||||||
|
|
||||||
# define TESTBIT(t, b) (t[(b) >> 3] & (ONE << ((b) & 7)))
|
|
||||||
# define SETBIT(t, b) (t[(b) >> 3] |= (ONE << ((b) & 7)))
|
|
||||||
# define CLEARBIT(t, b) (t[(b) >> 3] &= (0xFF & ~(ONE << ((b) & 7))))
|
|
||||||
|
|
||||||
#define WITHIN_ARENA(p) \
|
|
||||||
((char*)(p) >= sh.arena && (char*)(p) < &sh.arena[sh.arena_size])
|
|
||||||
#define WITHIN_FREELIST(p) \
|
|
||||||
((char*)(p) >= (char*)sh.freelist && (char*)(p) < (char*)&sh.freelist[sh.freelist_size])
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct sh_list_st
|
|
||||||
{
|
|
||||||
struct sh_list_st *next;
|
|
||||||
struct sh_list_st **p_next;
|
|
||||||
} SH_LIST;
|
|
||||||
|
|
||||||
typedef struct sh_st
|
|
||||||
{
|
|
||||||
char* map_result;
|
|
||||||
size_t map_size;
|
|
||||||
char *arena;
|
|
||||||
size_t arena_size;
|
|
||||||
char **freelist;
|
|
||||||
ossl_ssize_t freelist_size;
|
|
||||||
size_t minsize;
|
|
||||||
unsigned char *bittable;
|
|
||||||
unsigned char *bitmalloc;
|
|
||||||
size_t bittable_size; /* size in bits */
|
|
||||||
} SH;
|
|
||||||
|
|
||||||
static SH sh;
|
|
||||||
|
|
||||||
static size_t sh_getlist(char *ptr)
|
|
||||||
{
|
|
||||||
ossl_ssize_t list = sh.freelist_size - 1;
|
|
||||||
size_t bit = (sh.arena_size + ptr - sh.arena) / sh.minsize;
|
|
||||||
|
|
||||||
for (; bit; bit >>= 1, list--) {
|
|
||||||
if (TESTBIT(sh.bittable, bit))
|
|
||||||
break;
|
|
||||||
OPENSSL_assert((bit & 1) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int sh_testbit(char *ptr, int list, unsigned char *table)
|
|
||||||
{
|
|
||||||
size_t bit;
|
|
||||||
|
|
||||||
OPENSSL_assert(list >= 0 && list < sh.freelist_size);
|
|
||||||
OPENSSL_assert(((ptr - sh.arena) & ((sh.arena_size >> list) - 1)) == 0);
|
|
||||||
bit = (ONE << list) + ((ptr - sh.arena) / (sh.arena_size >> list));
|
|
||||||
OPENSSL_assert(bit > 0 && bit < sh.bittable_size);
|
|
||||||
return TESTBIT(table, bit);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sh_clearbit(char *ptr, int list, unsigned char *table)
|
|
||||||
{
|
|
||||||
size_t bit;
|
|
||||||
|
|
||||||
OPENSSL_assert(list >= 0 && list < sh.freelist_size);
|
|
||||||
OPENSSL_assert(((ptr - sh.arena) & ((sh.arena_size >> list) - 1)) == 0);
|
|
||||||
bit = (ONE << list) + ((ptr - sh.arena) / (sh.arena_size >> list));
|
|
||||||
OPENSSL_assert(bit > 0 && bit < sh.bittable_size);
|
|
||||||
OPENSSL_assert(TESTBIT(table, bit));
|
|
||||||
CLEARBIT(table, bit);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sh_setbit(char *ptr, int list, unsigned char *table)
|
|
||||||
{
|
|
||||||
size_t bit;
|
|
||||||
|
|
||||||
OPENSSL_assert(list >= 0 && list < sh.freelist_size);
|
|
||||||
OPENSSL_assert(((ptr - sh.arena) & ((sh.arena_size >> list) - 1)) == 0);
|
|
||||||
bit = (ONE << list) + ((ptr - sh.arena) / (sh.arena_size >> list));
|
|
||||||
OPENSSL_assert(bit > 0 && bit < sh.bittable_size);
|
|
||||||
OPENSSL_assert(!TESTBIT(table, bit));
|
|
||||||
SETBIT(table, bit);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sh_add_to_list(char **list, char *ptr)
|
|
||||||
{
|
|
||||||
SH_LIST *temp;
|
|
||||||
|
|
||||||
OPENSSL_assert(WITHIN_FREELIST(list));
|
|
||||||
OPENSSL_assert(WITHIN_ARENA(ptr));
|
|
||||||
|
|
||||||
temp = (SH_LIST *)ptr;
|
|
||||||
temp->next = *(SH_LIST **)list;
|
|
||||||
OPENSSL_assert(temp->next == NULL || WITHIN_ARENA(temp->next));
|
|
||||||
temp->p_next = (SH_LIST **)list;
|
|
||||||
|
|
||||||
if (temp->next != NULL) {
|
|
||||||
OPENSSL_assert((char **)temp->next->p_next == list);
|
|
||||||
temp->next->p_next = &(temp->next);
|
|
||||||
}
|
|
||||||
|
|
||||||
*list = ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sh_remove_from_list(char *ptr)
|
|
||||||
{
|
|
||||||
SH_LIST *temp, *temp2;
|
|
||||||
|
|
||||||
temp = (SH_LIST *)ptr;
|
|
||||||
if (temp->next != NULL)
|
|
||||||
temp->next->p_next = temp->p_next;
|
|
||||||
*temp->p_next = temp->next;
|
|
||||||
if (temp->next == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
temp2 = temp->next;
|
|
||||||
OPENSSL_assert(WITHIN_FREELIST(temp2->p_next) || WITHIN_ARENA(temp2->p_next));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int sh_init(size_t size, size_t minsize)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
size_t i;
|
|
||||||
size_t pgsize;
|
|
||||||
size_t aligned;
|
|
||||||
#if defined(_WIN32)
|
|
||||||
DWORD flOldProtect;
|
|
||||||
SYSTEM_INFO systemInfo;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
memset(&sh, 0, sizeof(sh));
|
|
||||||
|
|
||||||
/* make sure size is a powers of 2 */
|
|
||||||
OPENSSL_assert(size > 0);
|
|
||||||
OPENSSL_assert((size & (size - 1)) == 0);
|
|
||||||
if (size == 0 || (size & (size - 1)) != 0)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
if (minsize <= sizeof(SH_LIST)) {
|
|
||||||
OPENSSL_assert(sizeof(SH_LIST) <= 65536);
|
|
||||||
/*
|
|
||||||
* Compute the minimum possible allocation size.
|
|
||||||
* This must be a power of 2 and at least as large as the SH_LIST
|
|
||||||
* structure.
|
|
||||||
*/
|
|
||||||
minsize = sizeof(SH_LIST) - 1;
|
|
||||||
minsize |= minsize >> 1;
|
|
||||||
minsize |= minsize >> 2;
|
|
||||||
if (sizeof(SH_LIST) > 16)
|
|
||||||
minsize |= minsize >> 4;
|
|
||||||
if (sizeof(SH_LIST) > 256)
|
|
||||||
minsize |= minsize >> 8;
|
|
||||||
minsize++;
|
|
||||||
} else {
|
|
||||||
/* make sure minsize is a powers of 2 */
|
|
||||||
OPENSSL_assert((minsize & (minsize - 1)) == 0);
|
|
||||||
if ((minsize & (minsize - 1)) != 0)
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
sh.arena_size = size;
|
|
||||||
sh.minsize = minsize;
|
|
||||||
sh.bittable_size = (sh.arena_size / sh.minsize) * 2;
|
|
||||||
|
|
||||||
/* Prevent allocations of size 0 later on */
|
|
||||||
if (sh.bittable_size >> 3 == 0)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
sh.freelist_size = -1;
|
|
||||||
for (i = sh.bittable_size; i; i >>= 1)
|
|
||||||
sh.freelist_size++;
|
|
||||||
|
|
||||||
sh.freelist = OPENSSL_zalloc(sh.freelist_size * sizeof(char *));
|
|
||||||
OPENSSL_assert(sh.freelist != NULL);
|
|
||||||
if (sh.freelist == NULL)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
sh.bittable = OPENSSL_zalloc(sh.bittable_size >> 3);
|
|
||||||
OPENSSL_assert(sh.bittable != NULL);
|
|
||||||
if (sh.bittable == NULL)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
sh.bitmalloc = OPENSSL_zalloc(sh.bittable_size >> 3);
|
|
||||||
OPENSSL_assert(sh.bitmalloc != NULL);
|
|
||||||
if (sh.bitmalloc == NULL)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
/* Allocate space for heap, and two extra pages as guards */
|
|
||||||
#if defined(_SC_PAGE_SIZE) || defined (_SC_PAGESIZE)
|
|
||||||
{
|
|
||||||
# if defined(_SC_PAGE_SIZE)
|
|
||||||
long tmppgsize = sysconf(_SC_PAGE_SIZE);
|
|
||||||
# else
|
|
||||||
long tmppgsize = sysconf(_SC_PAGESIZE);
|
|
||||||
# endif
|
|
||||||
if (tmppgsize < 1)
|
|
||||||
pgsize = PAGE_SIZE;
|
|
||||||
else
|
|
||||||
pgsize = (size_t)tmppgsize;
|
|
||||||
}
|
|
||||||
#elif defined(_WIN32)
|
|
||||||
GetSystemInfo(&systemInfo);
|
|
||||||
pgsize = (size_t)systemInfo.dwPageSize;
|
|
||||||
#else
|
|
||||||
pgsize = PAGE_SIZE;
|
|
||||||
#endif
|
|
||||||
sh.map_size = pgsize + sh.arena_size + pgsize;
|
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
|
||||||
# ifdef MAP_ANON
|
|
||||||
sh.map_result = mmap(NULL, sh.map_size,
|
|
||||||
PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE|MAP_CONCEAL, -1, 0);
|
|
||||||
# else
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
sh.map_result = MAP_FAILED;
|
|
||||||
if ((fd = open("/dev/zero", O_RDWR)) >= 0) {
|
|
||||||
sh.map_result = mmap(NULL, sh.map_size,
|
|
||||||
PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
if (sh.map_result == MAP_FAILED)
|
|
||||||
goto err;
|
|
||||||
#else
|
|
||||||
sh.map_result = VirtualAlloc(NULL, sh.map_size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
|
||||||
|
|
||||||
if (sh.map_result == NULL)
|
|
||||||
goto err;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sh.arena = (char *)(sh.map_result + pgsize);
|
|
||||||
sh_setbit(sh.arena, 0, sh.bittable);
|
|
||||||
sh_add_to_list(&sh.freelist[0], sh.arena);
|
|
||||||
|
|
||||||
/* Now try to add guard pages and lock into memory. */
|
|
||||||
ret = 1;
|
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
|
||||||
/* Starting guard is already aligned from mmap. */
|
|
||||||
if (mprotect(sh.map_result, pgsize, PROT_NONE) < 0)
|
|
||||||
ret = 2;
|
|
||||||
#else
|
|
||||||
if (VirtualProtect(sh.map_result, pgsize, PAGE_NOACCESS, &flOldProtect) == FALSE)
|
|
||||||
ret = 2;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Ending guard page - need to round up to page boundary */
|
|
||||||
aligned = (pgsize + sh.arena_size + (pgsize - 1)) & ~(pgsize - 1);
|
|
||||||
#if !defined(_WIN32)
|
|
||||||
if (mprotect(sh.map_result + aligned, pgsize, PROT_NONE) < 0)
|
|
||||||
ret = 2;
|
|
||||||
#else
|
|
||||||
if (VirtualProtect(sh.map_result + aligned, pgsize, PAGE_NOACCESS, &flOldProtect) == FALSE)
|
|
||||||
ret = 2;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(OPENSSL_SYS_LINUX) && defined(MLOCK_ONFAULT) && defined(SYS_mlock2)
|
|
||||||
if (syscall(SYS_mlock2, sh.arena, sh.arena_size, MLOCK_ONFAULT) < 0) {
|
|
||||||
if (errno == ENOSYS) {
|
|
||||||
if (mlock(sh.arena, sh.arena_size) < 0)
|
|
||||||
ret = 2;
|
|
||||||
} else {
|
|
||||||
ret = 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#elif defined(_WIN32)
|
|
||||||
if (VirtualLock(sh.arena, sh.arena_size) == FALSE)
|
|
||||||
ret = 2;
|
|
||||||
#else
|
|
||||||
if (mlock(sh.arena, sh.arena_size) < 0)
|
|
||||||
ret = 2;
|
|
||||||
#endif
|
|
||||||
#ifdef MADV_DONTDUMP
|
|
||||||
if (madvise(sh.arena, sh.arena_size, MADV_DONTDUMP) < 0)
|
|
||||||
ret = 2;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
err:
|
|
||||||
sh_done();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sh_done(void)
|
|
||||||
{
|
|
||||||
OPENSSL_free(sh.freelist);
|
|
||||||
OPENSSL_free(sh.bittable);
|
|
||||||
OPENSSL_free(sh.bitmalloc);
|
|
||||||
#if !defined(_WIN32)
|
|
||||||
if (sh.map_result != MAP_FAILED && sh.map_size)
|
|
||||||
munmap(sh.map_result, sh.map_size);
|
|
||||||
#else
|
|
||||||
if (sh.map_result != NULL && sh.map_size)
|
|
||||||
VirtualFree(sh.map_result, 0, MEM_RELEASE);
|
|
||||||
#endif
|
|
||||||
memset(&sh, 0, sizeof(sh));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int sh_allocated(const char *ptr)
|
|
||||||
{
|
|
||||||
return WITHIN_ARENA(ptr) ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *sh_find_my_buddy(char *ptr, int list)
|
|
||||||
{
|
|
||||||
size_t bit;
|
|
||||||
char *chunk = NULL;
|
|
||||||
|
|
||||||
bit = (ONE << list) + (ptr - sh.arena) / (sh.arena_size >> list);
|
|
||||||
bit ^= 1;
|
|
||||||
|
|
||||||
if (TESTBIT(sh.bittable, bit) && !TESTBIT(sh.bitmalloc, bit))
|
|
||||||
chunk = sh.arena + ((bit & ((ONE << list) - 1)) * (sh.arena_size >> list));
|
|
||||||
|
|
||||||
return chunk;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *sh_malloc(size_t size)
|
|
||||||
{
|
|
||||||
ossl_ssize_t list, slist;
|
|
||||||
size_t i;
|
|
||||||
char *chunk;
|
|
||||||
|
|
||||||
if (size > sh.arena_size)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
list = sh.freelist_size - 1;
|
|
||||||
for (i = sh.minsize; i < size; i <<= 1)
|
|
||||||
list--;
|
|
||||||
if (list < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* try to find a larger entry to split */
|
|
||||||
for (slist = list; slist >= 0; slist--)
|
|
||||||
if (sh.freelist[slist] != NULL)
|
|
||||||
break;
|
|
||||||
if (slist < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* split larger entry */
|
|
||||||
while (slist != list) {
|
|
||||||
char *temp = sh.freelist[slist];
|
|
||||||
|
|
||||||
/* remove from bigger list */
|
|
||||||
OPENSSL_assert(!sh_testbit(temp, slist, sh.bitmalloc));
|
|
||||||
sh_clearbit(temp, slist, sh.bittable);
|
|
||||||
sh_remove_from_list(temp);
|
|
||||||
OPENSSL_assert(temp != sh.freelist[slist]);
|
|
||||||
|
|
||||||
/* done with bigger list */
|
|
||||||
slist++;
|
|
||||||
|
|
||||||
/* add to smaller list */
|
|
||||||
OPENSSL_assert(!sh_testbit(temp, slist, sh.bitmalloc));
|
|
||||||
sh_setbit(temp, slist, sh.bittable);
|
|
||||||
sh_add_to_list(&sh.freelist[slist], temp);
|
|
||||||
OPENSSL_assert(sh.freelist[slist] == temp);
|
|
||||||
|
|
||||||
/* split in 2 */
|
|
||||||
temp += sh.arena_size >> slist;
|
|
||||||
OPENSSL_assert(!sh_testbit(temp, slist, sh.bitmalloc));
|
|
||||||
sh_setbit(temp, slist, sh.bittable);
|
|
||||||
sh_add_to_list(&sh.freelist[slist], temp);
|
|
||||||
OPENSSL_assert(sh.freelist[slist] == temp);
|
|
||||||
|
|
||||||
OPENSSL_assert(temp-(sh.arena_size >> slist) == sh_find_my_buddy(temp, slist));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* peel off memory to hand back */
|
|
||||||
chunk = sh.freelist[list];
|
|
||||||
OPENSSL_assert(sh_testbit(chunk, list, sh.bittable));
|
|
||||||
sh_setbit(chunk, list, sh.bitmalloc);
|
|
||||||
sh_remove_from_list(chunk);
|
|
||||||
|
|
||||||
OPENSSL_assert(WITHIN_ARENA(chunk));
|
|
||||||
|
|
||||||
/* zero the free list header as a precaution against information leakage */
|
|
||||||
memset(chunk, 0, sizeof(SH_LIST));
|
|
||||||
|
|
||||||
return chunk;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sh_free(void *ptr)
|
|
||||||
{
|
|
||||||
size_t list;
|
|
||||||
void *buddy;
|
|
||||||
|
|
||||||
if (ptr == NULL)
|
|
||||||
return;
|
|
||||||
OPENSSL_assert(WITHIN_ARENA(ptr));
|
|
||||||
if (!WITHIN_ARENA(ptr))
|
|
||||||
return;
|
|
||||||
|
|
||||||
list = sh_getlist(ptr);
|
|
||||||
OPENSSL_assert(sh_testbit(ptr, list, sh.bittable));
|
|
||||||
sh_clearbit(ptr, list, sh.bitmalloc);
|
|
||||||
sh_add_to_list(&sh.freelist[list], ptr);
|
|
||||||
|
|
||||||
/* Try to coalesce two adjacent free areas. */
|
|
||||||
while ((buddy = sh_find_my_buddy(ptr, list)) != NULL) {
|
|
||||||
OPENSSL_assert(ptr == sh_find_my_buddy(buddy, list));
|
|
||||||
OPENSSL_assert(ptr != NULL);
|
|
||||||
OPENSSL_assert(!sh_testbit(ptr, list, sh.bitmalloc));
|
|
||||||
sh_clearbit(ptr, list, sh.bittable);
|
|
||||||
sh_remove_from_list(ptr);
|
|
||||||
OPENSSL_assert(!sh_testbit(ptr, list, sh.bitmalloc));
|
|
||||||
sh_clearbit(buddy, list, sh.bittable);
|
|
||||||
sh_remove_from_list(buddy);
|
|
||||||
|
|
||||||
list--;
|
|
||||||
|
|
||||||
/* Zero the higher addressed block's free list pointers */
|
|
||||||
memset(ptr > buddy ? ptr : buddy, 0, sizeof(SH_LIST));
|
|
||||||
if (ptr > buddy)
|
|
||||||
ptr = buddy;
|
|
||||||
|
|
||||||
OPENSSL_assert(!sh_testbit(ptr, list, sh.bitmalloc));
|
|
||||||
sh_setbit(ptr, list, sh.bittable);
|
|
||||||
sh_add_to_list(&sh.freelist[list], ptr);
|
|
||||||
OPENSSL_assert(sh.freelist[list] == ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t sh_actual_size(char *ptr)
|
|
||||||
{
|
|
||||||
int list;
|
|
||||||
|
|
||||||
OPENSSL_assert(WITHIN_ARENA(ptr));
|
|
||||||
if (!WITHIN_ARENA(ptr))
|
|
||||||
return 0;
|
|
||||||
list = sh_getlist(ptr);
|
|
||||||
OPENSSL_assert(sh_testbit(ptr, list, sh.bittable));
|
|
||||||
return sh.arena_size / (ONE << list);
|
|
||||||
}
|
|
||||||
#endif /* OPENSSL_NO_SECURE_MEMORY */
|
|
||||||
-298
@@ -1,298 +0,0 @@
|
|||||||
#! /usr/bin/env perl
|
|
||||||
# Copyright 2022 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
|
|
||||||
|
|
||||||
# $output is the last argument if it looks like a file (it has an extension)
|
|
||||||
# $flavour is the first argument if it doesn't look like a file
|
|
||||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
|
||||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
|
||||||
|
|
||||||
$output and open STDOUT,">$output";
|
|
||||||
|
|
||||||
my @regs = map("x$_",(0..31));
|
|
||||||
my @regaliases = ('zero','ra','sp','gp','tp','t0','t1','t2','s0','s1',
|
|
||||||
map("a$_",(0..7)),
|
|
||||||
map("s$_",(2..11)),
|
|
||||||
map("t$_",(3..6))
|
|
||||||
);
|
|
||||||
|
|
||||||
my %reglookup;
|
|
||||||
@reglookup{@regs} = @regs;
|
|
||||||
@reglookup{@regaliases} = @regs;
|
|
||||||
|
|
||||||
# Takes a register name, possibly an alias, and converts it to a register index
|
|
||||||
# from 0 to 31
|
|
||||||
sub read_reg {
|
|
||||||
my $reg = lc shift;
|
|
||||||
if (!exists($reglookup{$reg})) {
|
|
||||||
die("Unknown register ".$reg);
|
|
||||||
}
|
|
||||||
my $regstr = $reglookup{$reg};
|
|
||||||
if (!($regstr =~ /^x([0-9]+)$/)) {
|
|
||||||
die("Could not process register ".$reg);
|
|
||||||
}
|
|
||||||
return $1;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub rv64_rev8 {
|
|
||||||
# Encoding for rev8 rd, rs instruction on RV64
|
|
||||||
# XXXXXXXXXXXXX_ rs _XXX_ rd _XXXXXXX
|
|
||||||
my $template = 0b011010111000_00000_101_00000_0010011;
|
|
||||||
my $rd = read_reg shift;
|
|
||||||
my $rs = read_reg shift;
|
|
||||||
|
|
||||||
return ".word ".($template | ($rs << 15) | ($rd << 7));
|
|
||||||
}
|
|
||||||
|
|
||||||
sub rv64_clmul {
|
|
||||||
# Encoding for clmul rd, rs1, rs2 instruction on RV64
|
|
||||||
# XXXXXXX_ rs2 _ rs1 _XXX_ rd _XXXXXXX
|
|
||||||
my $template = 0b0000101_00000_00000_001_00000_0110011;
|
|
||||||
my $rd = read_reg shift;
|
|
||||||
my $rs1 = read_reg shift;
|
|
||||||
my $rs2 = read_reg shift;
|
|
||||||
|
|
||||||
return ".word ".($template | ($rs2 << 20) | ($rs1 << 15) | ($rd << 7));
|
|
||||||
}
|
|
||||||
|
|
||||||
sub rv64_clmulh {
|
|
||||||
# Encoding for clmulh rd, rs1, rs2 instruction on RV64
|
|
||||||
# XXXXXXX_ rs2 _ rs1 _XXX_ rd _XXXXXXX
|
|
||||||
my $template = 0b0000101_00000_00000_011_00000_0110011;
|
|
||||||
my $rd = read_reg shift;
|
|
||||||
my $rs1 = read_reg shift;
|
|
||||||
my $rs2 = read_reg shift;
|
|
||||||
|
|
||||||
return ".word ".($template | ($rs2 << 20) | ($rs1 << 15) | ($rd << 7));
|
|
||||||
}
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# gcm_init_clmul_rv64i_zbb_zbc(u128 Htable[16], const u64 Xi[2])
|
|
||||||
# Initialization function for clmul-based implementation of GMULT
|
|
||||||
# This function is used in tandem with gcm_gmult_clmul_rv64i_zbb_zbc
|
|
||||||
################################################################################
|
|
||||||
{
|
|
||||||
my ($Haddr,$Xi,$TEMP) = ("a0","a1","a2");
|
|
||||||
|
|
||||||
$code .= <<___;
|
|
||||||
.text
|
|
||||||
.balign 16
|
|
||||||
.globl gcm_init_clmul_rv64i_zbb_zbc
|
|
||||||
.type gcm_init_clmul_rv64i_zbb_zbc,\@function
|
|
||||||
# Initialize clmul-based implementation of galois field multiplication routine.
|
|
||||||
# gcm_init_clmul_rv64i_zbb_zbc(ctx->Htable, ctx->H.u)
|
|
||||||
gcm_init_clmul_rv64i_zbb_zbc:
|
|
||||||
# argument 0 = ctx->Htable (store H here)
|
|
||||||
# argument 1 = H.u[] (2x 64-bit words) [H_high64, H_low64]
|
|
||||||
|
|
||||||
# Simply store [H_high64, H_low64] for later
|
|
||||||
ld $TEMP,0($Xi)
|
|
||||||
sd $TEMP,0($Haddr)
|
|
||||||
ld $TEMP,8($Xi)
|
|
||||||
sd $TEMP,8($Haddr)
|
|
||||||
|
|
||||||
ret
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# gcm_gmult_clmul_rv64i_zbb_zbc(u64 Xi[2], const u128 Htable[16])
|
|
||||||
# Compute GMULT (X*H mod f) using the Zbc (clmul) and Zbb (basic bit manip)
|
|
||||||
# extensions, and the Modified Barrett Reduction technique
|
|
||||||
################################################################################
|
|
||||||
{
|
|
||||||
my ($Xi,$Haddr,$A1,$A0,$B1,$B0,$C1,$C0,$D1,$D0,$E1,$E0,$TEMP,$TEMP2,$qp_low) =
|
|
||||||
("a0","a1","a2","a3","a4","a5","a6","a7","t0","t1","t2","t3","t4","t5","t6");
|
|
||||||
|
|
||||||
$code .= <<___;
|
|
||||||
.text
|
|
||||||
.balign 16
|
|
||||||
.globl gcm_gmult_clmul_rv64i_zbb_zbc
|
|
||||||
.type gcm_gmult_clmul_rv64i_zbb_zbc,\@function
|
|
||||||
# static void gcm_gmult_clmul_rv64i_zbb_zbc(u64 Xi[2], const u128 Htable[16])
|
|
||||||
# Computes product of X*H mod f
|
|
||||||
gcm_gmult_clmul_rv64i_zbb_zbc:
|
|
||||||
|
|
||||||
# Load X and H (H is saved previously in gcm_init_clmul_rv64i_zbb_zbc)
|
|
||||||
ld $A1,0($Xi)
|
|
||||||
ld $A0,8($Xi)
|
|
||||||
|
|
||||||
ld $B1,0($Haddr)
|
|
||||||
ld $B0,8($Haddr)
|
|
||||||
|
|
||||||
li $qp_low,0xe100000000000000
|
|
||||||
|
|
||||||
# Perform Katratsuba Multiplication to generate a 255-bit intermediate
|
|
||||||
# A = [A1:A0]
|
|
||||||
# B = [B1:B0]
|
|
||||||
# Let:
|
|
||||||
# [C1:C0] = A1*B1
|
|
||||||
# [D1:D0] = A0*B0
|
|
||||||
# [E1:E0] = (A0+A1)*(B0+B1)
|
|
||||||
# Then:
|
|
||||||
# A*B = [C1:C0+C1+D1+E1:D1+C0+D0+E0:D0]
|
|
||||||
|
|
||||||
@{[rv64_rev8 $A1, $A1]}
|
|
||||||
@{[rv64_clmul $C0,$A1,$B1]}
|
|
||||||
@{[rv64_clmulh $C1,$A1,$B1]}
|
|
||||||
|
|
||||||
@{[rv64_rev8 $A0,$A0]}
|
|
||||||
@{[rv64_clmul $D0,$A0,$B0]}
|
|
||||||
@{[rv64_clmulh $D1,$A0,$B0]}
|
|
||||||
|
|
||||||
xor $TEMP,$A0,$A1
|
|
||||||
xor $TEMP2,$B0,$B1
|
|
||||||
|
|
||||||
@{[rv64_clmul $E0,$TEMP,$TEMP2]}
|
|
||||||
@{[rv64_clmulh $E1,$TEMP,$TEMP2]}
|
|
||||||
|
|
||||||
# 0th term is just C1
|
|
||||||
|
|
||||||
# Construct term 1 in E1 (E1 only appears in dword 1)
|
|
||||||
xor $E1,$E1,$D1
|
|
||||||
xor $E1,$E1,$C1
|
|
||||||
xor $E1,$E1,$C0
|
|
||||||
|
|
||||||
# Term 1 is E1
|
|
||||||
|
|
||||||
# Construct term 2 in E0 (E0 only appears in dword 2)
|
|
||||||
xor $E0,$E0,$D0
|
|
||||||
xor $E0,$E0,$C0
|
|
||||||
xor $E0,$E0,$D1
|
|
||||||
|
|
||||||
# Term 2 is E0
|
|
||||||
|
|
||||||
# final term is just D0
|
|
||||||
|
|
||||||
# X*H is now stored in [C1,E1,E0,D0]
|
|
||||||
|
|
||||||
# Left-justify
|
|
||||||
slli $C1,$C1,1
|
|
||||||
# Or in the high bit of E1
|
|
||||||
srli $TEMP,$E1,63
|
|
||||||
or $C1,$C1,$TEMP
|
|
||||||
|
|
||||||
slli $E1,$E1,1
|
|
||||||
# Or in the high bit of E0
|
|
||||||
srli $TEMP2,$E0,63
|
|
||||||
or $E1,$E1,$TEMP2
|
|
||||||
|
|
||||||
slli $E0,$E0,1
|
|
||||||
# Or in the high bit of D0
|
|
||||||
srli $TEMP,$D0,63
|
|
||||||
or $E0,$E0,$TEMP
|
|
||||||
|
|
||||||
slli $D0,$D0,1
|
|
||||||
|
|
||||||
# Barrett Reduction
|
|
||||||
# c = [E0, D0]
|
|
||||||
# We want the top 128 bits of the result of c*f
|
|
||||||
# We'll get this by computing the low-half (most significant 128 bits in
|
|
||||||
# the reflected domain) of clmul(c,fs)<<1 first, then
|
|
||||||
# xor in c to complete the calculation
|
|
||||||
|
|
||||||
# AA = [AA1:AA0] = [E0,D0] = c
|
|
||||||
# BB = [BB1:BB0] = [qp_low,0]
|
|
||||||
# [CC1:CC0] = AA1*BB1
|
|
||||||
# [DD1:DD0] = AA0*BB0
|
|
||||||
# [EE1:EE0] = (AA0+AA1)*(BB0+BB1)
|
|
||||||
# Then:
|
|
||||||
# AA*BB = [CC1:CC0+CC1+DD1+EE1:DD1+CC0+DD0+EE0:DD0]
|
|
||||||
# We only need CC0,DD1,DD0,EE0 to compute the low 128 bits of c * qp_low
|
|
||||||
___
|
|
||||||
|
|
||||||
my ($CC0,$EE0,$AA1,$AA0,$BB1) = ($A0,$B1,$E0,$D0,$qp_low);
|
|
||||||
|
|
||||||
$code .= <<___;
|
|
||||||
|
|
||||||
@{[rv64_clmul $CC0,$AA1,$BB1]}
|
|
||||||
#clmul DD0,AA0,BB0 # BB0 is 0, so DD0 = 0
|
|
||||||
#clmulh DD1,AA0,BB0 # BB0 is 0, so DD1 = 0
|
|
||||||
xor $TEMP,$AA0,$AA1
|
|
||||||
#xor TEMP2,BB0,BB1 # TEMP2 = BB1 = qp_low
|
|
||||||
@{[rv64_clmul $EE0,$TEMP,$BB1]}
|
|
||||||
|
|
||||||
# Result is [N/A:N/A:DD1+CC0+DD0+EE0:DD0]
|
|
||||||
# Simplifying: [CC0+EE0:0]
|
|
||||||
xor $TEMP2,$CC0,$EE0
|
|
||||||
# Shift left by 1 to correct for bit reflection
|
|
||||||
slli $TEMP2,$TEMP2,1
|
|
||||||
|
|
||||||
# xor into c = [E0,D0]
|
|
||||||
# Note that only E0 is affected
|
|
||||||
xor $E0,$E0,$TEMP2
|
|
||||||
|
|
||||||
# Now, q = [E0,D0]
|
|
||||||
|
|
||||||
# The final step is to compute clmul(q,[qp_low:0])<<1
|
|
||||||
# The leftmost 128 bits are the reduced result.
|
|
||||||
# Once again, we use Karatsuba multiplication, but many of the terms
|
|
||||||
# simplify or cancel out.
|
|
||||||
# AA = [AA1:AA0] = [E0,D0] = c
|
|
||||||
# BB = [BB1:BB0] = [qp_low,0]
|
|
||||||
# [CC1:CC0] = AA1*BB1
|
|
||||||
# [DD1:DD0] = AA0*BB0
|
|
||||||
# [EE1:EE0] = (AA0+AA1)*(BB0+BB1)
|
|
||||||
# Then:
|
|
||||||
# AA*BB = [CC1:CC0+CC1+DD1+EE1:DD1+CC0+DD0+EE0:DD0]
|
|
||||||
# We need CC1,CC0,DD0,DD1,EE1,EE0 to compute the leftmost 128 bits of AA*BB
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
my ($AA1,$AA0,$BB1,$CC1,$CC0,$EE1,$EE0) = ($E0,$D0,$qp_low,$A0,$A1,$C0,$B0);
|
|
||||||
|
|
||||||
$code .= <<___;
|
|
||||||
|
|
||||||
@{[rv64_clmul $CC0,$AA1,$BB1]}
|
|
||||||
@{[rv64_clmulh $CC1,$AA1,$BB1]}
|
|
||||||
|
|
||||||
#clmul DD0,AA0,BB0 # BB0 = 0 so DD0 = 0
|
|
||||||
#clmulh DD1,AA0,BB0 # BB0 = 0 so DD1 = 0
|
|
||||||
|
|
||||||
xor $TEMP,$AA0,$AA1
|
|
||||||
#xor TEMP2,BB0,BB1 # BB0 = 0 to TEMP2 == BB1 == qp_low
|
|
||||||
|
|
||||||
@{[rv64_clmul $EE0,$TEMP,$BB1]}
|
|
||||||
@{[rv64_clmulh $EE1,$TEMP,$BB1]}
|
|
||||||
|
|
||||||
# Need the DD1+CC0+DD0+EE0 term to shift its leftmost bit into the
|
|
||||||
# intermediate result.
|
|
||||||
# This is just CC0+EE0, store it in TEMP
|
|
||||||
xor $TEMP,$CC0,$EE0
|
|
||||||
|
|
||||||
# Result is [CC1:CC0+CC1+EE1:(a single bit)]<<1
|
|
||||||
# Combine into [CC1:CC0]
|
|
||||||
xor $CC0,$CC0,$CC1
|
|
||||||
xor $CC0,$CC0,$EE1
|
|
||||||
|
|
||||||
# Shift 128-bit quantity, xor in [C1,E1] and store
|
|
||||||
slli $CC1,$CC1,1
|
|
||||||
srli $TEMP2,$CC0,63
|
|
||||||
or $CC1,$CC1,$TEMP2
|
|
||||||
# xor in C1
|
|
||||||
xor $CC1,$CC1,$C1
|
|
||||||
@{[rv64_rev8 $CC1,$CC1]}
|
|
||||||
|
|
||||||
slli $CC0,$CC0,1
|
|
||||||
srli $TEMP,$TEMP,63
|
|
||||||
or $CC0,$CC0,$TEMP
|
|
||||||
# xor in E1
|
|
||||||
xor $CC0,$CC0,$E1
|
|
||||||
@{[rv64_rev8 $CC0,$CC0]}
|
|
||||||
sd $CC1,0(a0)
|
|
||||||
sd $CC0,8(a0)
|
|
||||||
|
|
||||||
ret
|
|
||||||
___
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
print $code;
|
|
||||||
|
|
||||||
close STDOUT or die "error closing STDOUT: $!";
|
|
||||||
@@ -1,286 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 1999-2024 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* HMAC low level APIs are deprecated for public use, but still ok for internal
|
|
||||||
* use.
|
|
||||||
*/
|
|
||||||
#include "internal/deprecated.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "internal/cryptlib.h"
|
|
||||||
#include <openssl/crypto.h>
|
|
||||||
#include <openssl/hmac.h>
|
|
||||||
#include <openssl/rand.h>
|
|
||||||
#include <openssl/pkcs12.h>
|
|
||||||
#include "p12_local.h"
|
|
||||||
|
|
||||||
int PKCS12_mac_present(const PKCS12 *p12)
|
|
||||||
{
|
|
||||||
return p12->mac ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PKCS12_get0_mac(const ASN1_OCTET_STRING **pmac,
|
|
||||||
const X509_ALGOR **pmacalg,
|
|
||||||
const ASN1_OCTET_STRING **psalt,
|
|
||||||
const ASN1_INTEGER **piter,
|
|
||||||
const PKCS12 *p12)
|
|
||||||
{
|
|
||||||
if (p12->mac) {
|
|
||||||
X509_SIG_get0(p12->mac->dinfo, pmacalg, pmac);
|
|
||||||
if (psalt)
|
|
||||||
*psalt = p12->mac->salt;
|
|
||||||
if (piter)
|
|
||||||
*piter = p12->mac->iter;
|
|
||||||
} else {
|
|
||||||
if (pmac)
|
|
||||||
*pmac = NULL;
|
|
||||||
if (pmacalg)
|
|
||||||
*pmacalg = NULL;
|
|
||||||
if (psalt)
|
|
||||||
*psalt = NULL;
|
|
||||||
if (piter)
|
|
||||||
*piter = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define TK26_MAC_KEY_LEN 32
|
|
||||||
|
|
||||||
static int pkcs12_gen_gost_mac_key(const char *pass, int passlen,
|
|
||||||
const unsigned char *salt, int saltlen,
|
|
||||||
int iter, int keylen, unsigned char *key,
|
|
||||||
const EVP_MD *digest)
|
|
||||||
{
|
|
||||||
unsigned char out[96];
|
|
||||||
|
|
||||||
if (keylen != TK26_MAC_KEY_LEN) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!PKCS5_PBKDF2_HMAC(pass, passlen, salt, saltlen, iter,
|
|
||||||
digest, sizeof(out), out)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
memcpy(key, out + sizeof(out) - TK26_MAC_KEY_LEN, TK26_MAC_KEY_LEN);
|
|
||||||
OPENSSL_cleanse(out, sizeof(out));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Generate a MAC */
|
|
||||||
static int pkcs12_gen_mac(PKCS12 *p12, const char *pass, int passlen,
|
|
||||||
unsigned char *mac, unsigned int *maclen,
|
|
||||||
int (*pkcs12_key_gen)(const char *pass, int passlen,
|
|
||||||
unsigned char *salt, int slen,
|
|
||||||
int id, int iter, int n,
|
|
||||||
unsigned char *out,
|
|
||||||
const EVP_MD *md_type))
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
const EVP_MD *md;
|
|
||||||
EVP_MD *md_fetch;
|
|
||||||
HMAC_CTX *hmac = NULL;
|
|
||||||
unsigned char key[EVP_MAX_MD_SIZE], *salt;
|
|
||||||
int saltlen, iter;
|
|
||||||
char md_name[80];
|
|
||||||
int md_size = 0;
|
|
||||||
int md_nid;
|
|
||||||
const X509_ALGOR *macalg;
|
|
||||||
const ASN1_OBJECT *macoid;
|
|
||||||
|
|
||||||
if (!PKCS7_type_is_data(p12->authsafes)) {
|
|
||||||
ERR_raise(ERR_LIB_PKCS12, PKCS12_R_CONTENT_TYPE_NOT_DATA);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p12->authsafes->d.data == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_PKCS12, PKCS12_R_DECODE_ERROR);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
salt = p12->mac->salt->data;
|
|
||||||
saltlen = p12->mac->salt->length;
|
|
||||||
if (p12->mac->iter == NULL)
|
|
||||||
iter = 1;
|
|
||||||
else
|
|
||||||
iter = ASN1_INTEGER_get(p12->mac->iter);
|
|
||||||
X509_SIG_get0(p12->mac->dinfo, &macalg, NULL);
|
|
||||||
X509_ALGOR_get0(&macoid, NULL, NULL, macalg);
|
|
||||||
if (OBJ_obj2txt(md_name, sizeof(md_name), macoid, 0) < 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
(void)ERR_set_mark();
|
|
||||||
md = md_fetch = EVP_MD_fetch(p12->authsafes->ctx.libctx, md_name,
|
|
||||||
p12->authsafes->ctx.propq);
|
|
||||||
if (md == NULL)
|
|
||||||
md = EVP_get_digestbynid(OBJ_obj2nid(macoid));
|
|
||||||
|
|
||||||
if (md == NULL) {
|
|
||||||
(void)ERR_clear_last_mark();
|
|
||||||
ERR_raise(ERR_LIB_PKCS12, PKCS12_R_UNKNOWN_DIGEST_ALGORITHM);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
(void)ERR_pop_to_mark();
|
|
||||||
|
|
||||||
md_size = EVP_MD_get_size(md);
|
|
||||||
md_nid = EVP_MD_get_type(md);
|
|
||||||
if (md_size < 0)
|
|
||||||
goto err;
|
|
||||||
if ((md_nid == NID_id_GostR3411_94
|
|
||||||
|| md_nid == NID_id_GostR3411_2012_256
|
|
||||||
|| md_nid == NID_id_GostR3411_2012_512)
|
|
||||||
&& ossl_safe_getenv("LEGACY_GOST_PKCS12") == NULL) {
|
|
||||||
md_size = TK26_MAC_KEY_LEN;
|
|
||||||
if (!pkcs12_gen_gost_mac_key(pass, passlen, salt, saltlen, iter,
|
|
||||||
md_size, key, md)) {
|
|
||||||
ERR_raise(ERR_LIB_PKCS12, PKCS12_R_KEY_GEN_ERROR);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (pkcs12_key_gen != NULL) {
|
|
||||||
if (!(*pkcs12_key_gen)(pass, passlen, salt, saltlen, PKCS12_MAC_ID,
|
|
||||||
iter, md_size, key, md)) {
|
|
||||||
ERR_raise(ERR_LIB_PKCS12, PKCS12_R_KEY_GEN_ERROR);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* Default to UTF-8 password */
|
|
||||||
if (!PKCS12_key_gen_utf8_ex(pass, passlen, salt, saltlen, PKCS12_MAC_ID,
|
|
||||||
iter, md_size, key, md,
|
|
||||||
p12->authsafes->ctx.libctx,
|
|
||||||
p12->authsafes->ctx.propq)) {
|
|
||||||
ERR_raise(ERR_LIB_PKCS12, PKCS12_R_KEY_GEN_ERROR);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((hmac = HMAC_CTX_new()) == NULL
|
|
||||||
|| !HMAC_Init_ex(hmac, key, md_size, md, NULL)
|
|
||||||
|| !HMAC_Update(hmac, p12->authsafes->d.data->data,
|
|
||||||
p12->authsafes->d.data->length)
|
|
||||||
|| !HMAC_Final(hmac, mac, maclen)) {
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
ret = 1;
|
|
||||||
|
|
||||||
err:
|
|
||||||
OPENSSL_cleanse(key, sizeof(key));
|
|
||||||
HMAC_CTX_free(hmac);
|
|
||||||
EVP_MD_free(md_fetch);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,
|
|
||||||
unsigned char *mac, unsigned int *maclen)
|
|
||||||
{
|
|
||||||
return pkcs12_gen_mac(p12, pass, passlen, mac, maclen, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Verify the mac */
|
|
||||||
int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen)
|
|
||||||
{
|
|
||||||
unsigned char mac[EVP_MAX_MD_SIZE];
|
|
||||||
unsigned int maclen;
|
|
||||||
const ASN1_OCTET_STRING *macoct;
|
|
||||||
|
|
||||||
if (p12->mac == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_PKCS12, PKCS12_R_MAC_ABSENT);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!pkcs12_gen_mac(p12, pass, passlen, mac, &maclen, NULL)) {
|
|
||||||
ERR_raise(ERR_LIB_PKCS12, PKCS12_R_MAC_GENERATION_ERROR);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
X509_SIG_get0(p12->mac->dinfo, NULL, &macoct);
|
|
||||||
if ((maclen != (unsigned int)ASN1_STRING_length(macoct))
|
|
||||||
|| CRYPTO_memcmp(mac, ASN1_STRING_get0_data(macoct), maclen) != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set a mac */
|
|
||||||
|
|
||||||
int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen,
|
|
||||||
unsigned char *salt, int saltlen, int iter,
|
|
||||||
const EVP_MD *md_type)
|
|
||||||
{
|
|
||||||
unsigned char mac[EVP_MAX_MD_SIZE];
|
|
||||||
unsigned int maclen;
|
|
||||||
ASN1_OCTET_STRING *macoct;
|
|
||||||
|
|
||||||
if (md_type == NULL)
|
|
||||||
/* No need to do a fetch as the md_type is used only to get a NID */
|
|
||||||
md_type = EVP_sha256();
|
|
||||||
if (!iter)
|
|
||||||
iter = PKCS12_DEFAULT_ITER;
|
|
||||||
if (PKCS12_setup_mac(p12, iter, salt, saltlen, md_type) == PKCS12_ERROR) {
|
|
||||||
ERR_raise(ERR_LIB_PKCS12, PKCS12_R_MAC_SETUP_ERROR);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Note that output mac is forced to UTF-8...
|
|
||||||
*/
|
|
||||||
if (!pkcs12_gen_mac(p12, pass, passlen, mac, &maclen, NULL)) {
|
|
||||||
ERR_raise(ERR_LIB_PKCS12, PKCS12_R_MAC_GENERATION_ERROR);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
X509_SIG_getm(p12->mac->dinfo, NULL, &macoct);
|
|
||||||
if (!ASN1_OCTET_STRING_set(macoct, mac, maclen)) {
|
|
||||||
ERR_raise(ERR_LIB_PKCS12, PKCS12_R_MAC_STRING_SET_ERROR);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set up a mac structure */
|
|
||||||
int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen,
|
|
||||||
const EVP_MD *md_type)
|
|
||||||
{
|
|
||||||
X509_ALGOR *macalg;
|
|
||||||
|
|
||||||
PKCS12_MAC_DATA_free(p12->mac);
|
|
||||||
p12->mac = NULL;
|
|
||||||
|
|
||||||
if ((p12->mac = PKCS12_MAC_DATA_new()) == NULL)
|
|
||||||
return PKCS12_ERROR;
|
|
||||||
if (iter > 1) {
|
|
||||||
if ((p12->mac->iter = ASN1_INTEGER_new()) == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_PKCS12, ERR_R_MALLOC_FAILURE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!ASN1_INTEGER_set(p12->mac->iter, iter)) {
|
|
||||||
ERR_raise(ERR_LIB_PKCS12, ERR_R_MALLOC_FAILURE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (saltlen == 0)
|
|
||||||
saltlen = PKCS12_SALT_LEN;
|
|
||||||
else if (saltlen < 0)
|
|
||||||
return 0;
|
|
||||||
if ((p12->mac->salt->data = OPENSSL_malloc(saltlen)) == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_PKCS12, ERR_R_MALLOC_FAILURE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
p12->mac->salt->length = saltlen;
|
|
||||||
if (salt == NULL) {
|
|
||||||
if (RAND_bytes_ex(p12->authsafes->ctx.libctx, p12->mac->salt->data,
|
|
||||||
(size_t)saltlen, 0) <= 0)
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
memcpy(p12->mac->salt->data, salt, saltlen);
|
|
||||||
}
|
|
||||||
X509_SIG_getm(p12->mac->dinfo, &macalg, NULL);
|
|
||||||
if (!X509_ALGOR_set0(macalg, OBJ_nid2obj(EVP_MD_get_type(md_type)),
|
|
||||||
V_ASN1_NULL, NULL)) {
|
|
||||||
ERR_raise(ERR_LIB_PKCS12, ERR_R_MALLOC_FAILURE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,324 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2009-2022 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 <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <setjmp.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#if defined(__linux) || defined(_AIX)
|
|
||||||
# include <sys/utsname.h>
|
|
||||||
#endif
|
|
||||||
#if defined(_AIX53) /* defined even on post-5.3 */
|
|
||||||
# include <sys/systemcfg.h>
|
|
||||||
# if !defined(__power_set)
|
|
||||||
# define __power_set(a) (_system_configuration.implementation & (a))
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if defined(__APPLE__) && defined(__MACH__)
|
|
||||||
# include <sys/types.h>
|
|
||||||
# include <sys/sysctl.h>
|
|
||||||
#endif
|
|
||||||
#include <openssl/crypto.h>
|
|
||||||
#include "internal/cryptlib.h"
|
|
||||||
#include "crypto/ppc_arch.h"
|
|
||||||
|
|
||||||
unsigned int OPENSSL_ppccap_P = 0;
|
|
||||||
|
|
||||||
static sigset_t all_masked;
|
|
||||||
|
|
||||||
static sigjmp_buf ill_jmp;
|
|
||||||
static void ill_handler(int sig)
|
|
||||||
{
|
|
||||||
siglongjmp(ill_jmp, sig);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OPENSSL_fpu_probe(void);
|
|
||||||
void OPENSSL_ppc64_probe(void);
|
|
||||||
void OPENSSL_altivec_probe(void);
|
|
||||||
void OPENSSL_crypto207_probe(void);
|
|
||||||
void OPENSSL_madd300_probe(void);
|
|
||||||
void OPENSSL_brd31_probe(void);
|
|
||||||
|
|
||||||
long OPENSSL_rdtsc_mftb(void);
|
|
||||||
long OPENSSL_rdtsc_mfspr268(void);
|
|
||||||
|
|
||||||
uint32_t OPENSSL_rdtsc(void)
|
|
||||||
{
|
|
||||||
if (OPENSSL_ppccap_P & PPC_MFTB)
|
|
||||||
return OPENSSL_rdtsc_mftb();
|
|
||||||
else if (OPENSSL_ppccap_P & PPC_MFSPR268)
|
|
||||||
return OPENSSL_rdtsc_mfspr268();
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t OPENSSL_instrument_bus_mftb(unsigned int *, size_t);
|
|
||||||
size_t OPENSSL_instrument_bus_mfspr268(unsigned int *, size_t);
|
|
||||||
|
|
||||||
size_t OPENSSL_instrument_bus(unsigned int *out, size_t cnt)
|
|
||||||
{
|
|
||||||
if (OPENSSL_ppccap_P & PPC_MFTB)
|
|
||||||
return OPENSSL_instrument_bus_mftb(out, cnt);
|
|
||||||
else if (OPENSSL_ppccap_P & PPC_MFSPR268)
|
|
||||||
return OPENSSL_instrument_bus_mfspr268(out, cnt);
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t OPENSSL_instrument_bus2_mftb(unsigned int *, size_t, size_t);
|
|
||||||
size_t OPENSSL_instrument_bus2_mfspr268(unsigned int *, size_t, size_t);
|
|
||||||
|
|
||||||
size_t OPENSSL_instrument_bus2(unsigned int *out, size_t cnt, size_t max)
|
|
||||||
{
|
|
||||||
if (OPENSSL_ppccap_P & PPC_MFTB)
|
|
||||||
return OPENSSL_instrument_bus2_mftb(out, cnt, max);
|
|
||||||
else if (OPENSSL_ppccap_P & PPC_MFSPR268)
|
|
||||||
return OPENSSL_instrument_bus2_mfspr268(out, cnt, max);
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
|
|
||||||
# if __GLIBC_PREREQ(2, 16)
|
|
||||||
# include <sys/auxv.h>
|
|
||||||
# define OSSL_IMPLEMENT_GETAUXVAL
|
|
||||||
# elif defined(__ANDROID_API__)
|
|
||||||
/* see https://developer.android.google.cn/ndk/guides/cpu-features */
|
|
||||||
# if __ANDROID_API__ >= 18
|
|
||||||
# include <sys/auxv.h>
|
|
||||||
# define OSSL_IMPLEMENT_GETAUXVAL
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__FreeBSD__)
|
|
||||||
# include <sys/param.h>
|
|
||||||
# if __FreeBSD_version >= 1200000
|
|
||||||
# include <sys/auxv.h>
|
|
||||||
# define OSSL_IMPLEMENT_GETAUXVAL
|
|
||||||
|
|
||||||
static unsigned long getauxval(unsigned long key)
|
|
||||||
{
|
|
||||||
unsigned long val = 0ul;
|
|
||||||
|
|
||||||
if (elf_aux_info((int)key, &val, sizeof(val)) != 0)
|
|
||||||
return 0ul;
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* I wish <sys/auxv.h> was universally available */
|
|
||||||
#ifndef AT_HWCAP
|
|
||||||
# define AT_HWCAP 16 /* AT_HWCAP */
|
|
||||||
#endif
|
|
||||||
#define HWCAP_PPC64 (1U << 30)
|
|
||||||
#define HWCAP_ALTIVEC (1U << 28)
|
|
||||||
#define HWCAP_FPU (1U << 27)
|
|
||||||
#define HWCAP_POWER6_EXT (1U << 9)
|
|
||||||
#define HWCAP_VSX (1U << 7)
|
|
||||||
|
|
||||||
#ifndef AT_HWCAP2
|
|
||||||
# define AT_HWCAP2 26 /* AT_HWCAP2 */
|
|
||||||
#endif
|
|
||||||
#define HWCAP_VEC_CRYPTO (1U << 25)
|
|
||||||
#define HWCAP_ARCH_3_00 (1U << 23)
|
|
||||||
#define HWCAP_ARCH_3_1 (1U << 18)
|
|
||||||
|
|
||||||
# if defined(__GNUC__) && __GNUC__>=2
|
|
||||||
__attribute__ ((constructor))
|
|
||||||
# endif
|
|
||||||
void OPENSSL_cpuid_setup(void)
|
|
||||||
{
|
|
||||||
char *e;
|
|
||||||
struct sigaction ill_oact, ill_act;
|
|
||||||
sigset_t oset;
|
|
||||||
static int trigger = 0;
|
|
||||||
|
|
||||||
if (trigger)
|
|
||||||
return;
|
|
||||||
trigger = 1;
|
|
||||||
|
|
||||||
if ((e = getenv("OPENSSL_ppccap"))) {
|
|
||||||
OPENSSL_ppccap_P = strtoul(e, NULL, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
OPENSSL_ppccap_P = 0;
|
|
||||||
|
|
||||||
#if defined(_AIX)
|
|
||||||
OPENSSL_ppccap_P |= PPC_FPU;
|
|
||||||
|
|
||||||
if (sizeof(size_t) == 4) {
|
|
||||||
struct utsname uts;
|
|
||||||
# if defined(_SC_AIX_KERNEL_BITMODE)
|
|
||||||
if (sysconf(_SC_AIX_KERNEL_BITMODE) != 64)
|
|
||||||
return;
|
|
||||||
# endif
|
|
||||||
if (uname(&uts) != 0 || atoi(uts.version) < 6)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
# if defined(__power_set)
|
|
||||||
/*
|
|
||||||
* Value used in __power_set is a single-bit 1<<n one denoting
|
|
||||||
* specific processor class. Incidentally 0xffffffff<<n can be
|
|
||||||
* used to denote specific processor and its successors.
|
|
||||||
*/
|
|
||||||
if (sizeof(size_t) == 4) {
|
|
||||||
/* In 32-bit case PPC_FPU64 is always fastest [if option] */
|
|
||||||
if (__power_set(0xffffffffU<<13)) /* POWER5 and later */
|
|
||||||
OPENSSL_ppccap_P |= PPC_FPU64;
|
|
||||||
} else {
|
|
||||||
/* In 64-bit case PPC_FPU64 is fastest only on POWER6 */
|
|
||||||
if (__power_set(0x1U<<14)) /* POWER6 */
|
|
||||||
OPENSSL_ppccap_P |= PPC_FPU64;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (__power_set(0xffffffffU<<14)) /* POWER6 and later */
|
|
||||||
OPENSSL_ppccap_P |= PPC_ALTIVEC;
|
|
||||||
|
|
||||||
if (__power_set(0xffffffffU<<16)) /* POWER8 and later */
|
|
||||||
OPENSSL_ppccap_P |= PPC_CRYPTO207;
|
|
||||||
|
|
||||||
if (__power_set(0xffffffffU<<17)) /* POWER9 and later */
|
|
||||||
OPENSSL_ppccap_P |= PPC_MADD300;
|
|
||||||
|
|
||||||
if (__power_set(0xffffffffU<<18)) /* POWER10 and later */
|
|
||||||
OPENSSL_ppccap_P |= PPC_BRD31;
|
|
||||||
|
|
||||||
return;
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__APPLE__) && defined(__MACH__)
|
|
||||||
OPENSSL_ppccap_P |= PPC_FPU;
|
|
||||||
|
|
||||||
{
|
|
||||||
int val;
|
|
||||||
size_t len = sizeof(val);
|
|
||||||
|
|
||||||
if (sysctlbyname("hw.optional.64bitops", &val, &len, NULL, 0) == 0) {
|
|
||||||
if (val)
|
|
||||||
OPENSSL_ppccap_P |= PPC_FPU64;
|
|
||||||
}
|
|
||||||
|
|
||||||
len = sizeof(val);
|
|
||||||
if (sysctlbyname("hw.optional.altivec", &val, &len, NULL, 0) == 0) {
|
|
||||||
if (val)
|
|
||||||
OPENSSL_ppccap_P |= PPC_ALTIVEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef OSSL_IMPLEMENT_GETAUXVAL
|
|
||||||
{
|
|
||||||
unsigned long hwcap = getauxval(AT_HWCAP);
|
|
||||||
unsigned long hwcap2 = getauxval(AT_HWCAP2);
|
|
||||||
|
|
||||||
if (hwcap & HWCAP_FPU) {
|
|
||||||
OPENSSL_ppccap_P |= PPC_FPU;
|
|
||||||
|
|
||||||
if (sizeof(size_t) == 4) {
|
|
||||||
/* In 32-bit case PPC_FPU64 is always fastest [if option] */
|
|
||||||
if (hwcap & HWCAP_PPC64)
|
|
||||||
OPENSSL_ppccap_P |= PPC_FPU64;
|
|
||||||
} else {
|
|
||||||
/* In 64-bit case PPC_FPU64 is fastest only on POWER6 */
|
|
||||||
if (hwcap & HWCAP_POWER6_EXT)
|
|
||||||
OPENSSL_ppccap_P |= PPC_FPU64;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hwcap & HWCAP_ALTIVEC) {
|
|
||||||
OPENSSL_ppccap_P |= PPC_ALTIVEC;
|
|
||||||
|
|
||||||
if ((hwcap & HWCAP_VSX) && (hwcap2 & HWCAP_VEC_CRYPTO))
|
|
||||||
OPENSSL_ppccap_P |= PPC_CRYPTO207;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hwcap2 & HWCAP_ARCH_3_00) {
|
|
||||||
OPENSSL_ppccap_P |= PPC_MADD300;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hwcap2 & HWCAP_ARCH_3_1) {
|
|
||||||
OPENSSL_ppccap_P |= PPC_BRD31;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sigfillset(&all_masked);
|
|
||||||
sigdelset(&all_masked, SIGILL);
|
|
||||||
sigdelset(&all_masked, SIGTRAP);
|
|
||||||
#ifdef SIGEMT
|
|
||||||
sigdelset(&all_masked, SIGEMT);
|
|
||||||
#endif
|
|
||||||
sigdelset(&all_masked, SIGFPE);
|
|
||||||
sigdelset(&all_masked, SIGBUS);
|
|
||||||
sigdelset(&all_masked, SIGSEGV);
|
|
||||||
|
|
||||||
memset(&ill_act, 0, sizeof(ill_act));
|
|
||||||
ill_act.sa_handler = ill_handler;
|
|
||||||
ill_act.sa_mask = all_masked;
|
|
||||||
|
|
||||||
sigprocmask(SIG_SETMASK, &ill_act.sa_mask, &oset);
|
|
||||||
sigaction(SIGILL, &ill_act, &ill_oact);
|
|
||||||
|
|
||||||
#ifndef OSSL_IMPLEMENT_GETAUXVAL
|
|
||||||
if (sigsetjmp(ill_jmp,1) == 0) {
|
|
||||||
OPENSSL_fpu_probe();
|
|
||||||
OPENSSL_ppccap_P |= PPC_FPU;
|
|
||||||
|
|
||||||
if (sizeof(size_t) == 4) {
|
|
||||||
# ifdef __linux
|
|
||||||
struct utsname uts;
|
|
||||||
if (uname(&uts) == 0 && strcmp(uts.machine, "ppc64") == 0)
|
|
||||||
# endif
|
|
||||||
if (sigsetjmp(ill_jmp, 1) == 0) {
|
|
||||||
OPENSSL_ppc64_probe();
|
|
||||||
OPENSSL_ppccap_P |= PPC_FPU64;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Wanted code detecting POWER6 CPU and setting PPC_FPU64
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sigsetjmp(ill_jmp, 1) == 0) {
|
|
||||||
OPENSSL_altivec_probe();
|
|
||||||
OPENSSL_ppccap_P |= PPC_ALTIVEC;
|
|
||||||
if (sigsetjmp(ill_jmp, 1) == 0) {
|
|
||||||
OPENSSL_crypto207_probe();
|
|
||||||
OPENSSL_ppccap_P |= PPC_CRYPTO207;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sigsetjmp(ill_jmp, 1) == 0) {
|
|
||||||
OPENSSL_madd300_probe();
|
|
||||||
OPENSSL_ppccap_P |= PPC_MADD300;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (sigsetjmp(ill_jmp, 1) == 0) {
|
|
||||||
OPENSSL_rdtsc_mftb();
|
|
||||||
OPENSSL_ppccap_P |= PPC_MFTB;
|
|
||||||
} else if (sigsetjmp(ill_jmp, 1) == 0) {
|
|
||||||
OPENSSL_rdtsc_mfspr268();
|
|
||||||
OPENSSL_ppccap_P |= PPC_MFSPR268;
|
|
||||||
}
|
|
||||||
|
|
||||||
sigaction(SIGILL, &ill_oact, NULL);
|
|
||||||
sigprocmask(SIG_SETMASK, &oset, NULL);
|
|
||||||
}
|
|
||||||
@@ -1,397 +0,0 @@
|
|||||||
#! /usr/bin/env perl
|
|
||||||
# Copyright 2007-2022 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
|
|
||||||
|
|
||||||
|
|
||||||
# $output is the last argument if it looks like a file (it has an extension)
|
|
||||||
# $flavour is the first argument if it doesn't look like a file
|
|
||||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
|
||||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
|
||||||
|
|
||||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
|
||||||
( $xlate="${dir}ppc-xlate.pl" and -f $xlate ) or
|
|
||||||
( $xlate="${dir}perlasm/ppc-xlate.pl" and -f $xlate) or
|
|
||||||
die "can't locate ppc-xlate.pl";
|
|
||||||
|
|
||||||
open STDOUT,"| $^X $xlate $flavour \"$output\""
|
|
||||||
or die "can't call $xlate: $!";
|
|
||||||
|
|
||||||
if ($flavour=~/64/) {
|
|
||||||
$CMPLI="cmpldi";
|
|
||||||
$SHRLI="srdi";
|
|
||||||
$SIGNX="extsw";
|
|
||||||
} else {
|
|
||||||
$CMPLI="cmplwi";
|
|
||||||
$SHRLI="srwi";
|
|
||||||
$SIGNX="mr";
|
|
||||||
}
|
|
||||||
|
|
||||||
$code=<<___;
|
|
||||||
.machine "any"
|
|
||||||
.text
|
|
||||||
|
|
||||||
.globl .OPENSSL_fpu_probe
|
|
||||||
.align 4
|
|
||||||
.OPENSSL_fpu_probe:
|
|
||||||
fmr f0,f0
|
|
||||||
blr
|
|
||||||
.long 0
|
|
||||||
.byte 0,12,0x14,0,0,0,0,0
|
|
||||||
.size .OPENSSL_fpu_probe,.-.OPENSSL_fpu_probe
|
|
||||||
.globl .OPENSSL_ppc64_probe
|
|
||||||
.align 4
|
|
||||||
.OPENSSL_ppc64_probe:
|
|
||||||
fcfid f1,f1
|
|
||||||
extrdi r0,r0,32,0
|
|
||||||
blr
|
|
||||||
.long 0
|
|
||||||
.byte 0,12,0x14,0,0,0,0,0
|
|
||||||
.size .OPENSSL_ppc64_probe,.-.OPENSSL_ppc64_probe
|
|
||||||
|
|
||||||
.globl .OPENSSL_altivec_probe
|
|
||||||
.align 4
|
|
||||||
.OPENSSL_altivec_probe:
|
|
||||||
.long 0x10000484 # vor v0,v0,v0
|
|
||||||
blr
|
|
||||||
.long 0
|
|
||||||
.byte 0,12,0x14,0,0,0,0,0
|
|
||||||
.size .OPENSSL_altivec_probe,.-..OPENSSL_altivec_probe
|
|
||||||
|
|
||||||
.globl .OPENSSL_crypto207_probe
|
|
||||||
.align 4
|
|
||||||
.OPENSSL_crypto207_probe:
|
|
||||||
lvx_u v0,0,r1
|
|
||||||
vcipher v0,v0,v0
|
|
||||||
blr
|
|
||||||
.long 0
|
|
||||||
.byte 0,12,0x14,0,0,0,0,0
|
|
||||||
.size .OPENSSL_crypto207_probe,.-.OPENSSL_crypto207_probe
|
|
||||||
|
|
||||||
.globl .OPENSSL_madd300_probe
|
|
||||||
.align 4
|
|
||||||
.OPENSSL_madd300_probe:
|
|
||||||
xor r0,r0,r0
|
|
||||||
maddld r3,r0,r0,r0
|
|
||||||
maddhdu r3,r0,r0,r0
|
|
||||||
blr
|
|
||||||
.long 0
|
|
||||||
.byte 0,12,0x14,0,0,0,0,0
|
|
||||||
|
|
||||||
.globl .OPENSSL_brd31_probe
|
|
||||||
.align 4
|
|
||||||
.OPENSSL_brd31_probe:
|
|
||||||
xor r0,r0,r0
|
|
||||||
brd r3,r0
|
|
||||||
blr
|
|
||||||
.long 0
|
|
||||||
.byte 0,12,0x14,0,0,0,0,0
|
|
||||||
.size .OPENSSL_brd31_probe,.-.OPENSSL_brd31_probe
|
|
||||||
|
|
||||||
|
|
||||||
.globl .OPENSSL_wipe_cpu
|
|
||||||
.align 4
|
|
||||||
.OPENSSL_wipe_cpu:
|
|
||||||
xor r0,r0,r0
|
|
||||||
fmr f0,f31
|
|
||||||
fmr f1,f31
|
|
||||||
fmr f2,f31
|
|
||||||
mr r3,r1
|
|
||||||
fmr f3,f31
|
|
||||||
xor r4,r4,r4
|
|
||||||
fmr f4,f31
|
|
||||||
xor r5,r5,r5
|
|
||||||
fmr f5,f31
|
|
||||||
xor r6,r6,r6
|
|
||||||
fmr f6,f31
|
|
||||||
xor r7,r7,r7
|
|
||||||
fmr f7,f31
|
|
||||||
xor r8,r8,r8
|
|
||||||
fmr f8,f31
|
|
||||||
xor r9,r9,r9
|
|
||||||
fmr f9,f31
|
|
||||||
xor r10,r10,r10
|
|
||||||
fmr f10,f31
|
|
||||||
xor r11,r11,r11
|
|
||||||
fmr f11,f31
|
|
||||||
xor r12,r12,r12
|
|
||||||
fmr f12,f31
|
|
||||||
fmr f13,f31
|
|
||||||
blr
|
|
||||||
.long 0
|
|
||||||
.byte 0,12,0x14,0,0,0,0,0
|
|
||||||
.size .OPENSSL_wipe_cpu,.-.OPENSSL_wipe_cpu
|
|
||||||
|
|
||||||
.globl .OPENSSL_atomic_add
|
|
||||||
.align 4
|
|
||||||
.OPENSSL_atomic_add:
|
|
||||||
Ladd: lwarx r5,0,r3
|
|
||||||
add r0,r4,r5
|
|
||||||
stwcx. r0,0,r3
|
|
||||||
bne- Ladd
|
|
||||||
$SIGNX r3,r0
|
|
||||||
blr
|
|
||||||
.long 0
|
|
||||||
.byte 0,12,0x14,0,0,0,2,0
|
|
||||||
.long 0
|
|
||||||
.size .OPENSSL_atomic_add,.-.OPENSSL_atomic_add
|
|
||||||
|
|
||||||
.globl .OPENSSL_rdtsc_mftb
|
|
||||||
.align 4
|
|
||||||
.OPENSSL_rdtsc_mftb:
|
|
||||||
mftb r3
|
|
||||||
blr
|
|
||||||
.long 0
|
|
||||||
.byte 0,12,0x14,0,0,0,0,0
|
|
||||||
.size .OPENSSL_rdtsc_mftb,.-.OPENSSL_rdtsc_mftb
|
|
||||||
|
|
||||||
.globl .OPENSSL_rdtsc_mfspr268
|
|
||||||
.align 4
|
|
||||||
.OPENSSL_rdtsc_mfspr268:
|
|
||||||
mfspr r3,268
|
|
||||||
blr
|
|
||||||
.long 0
|
|
||||||
.byte 0,12,0x14,0,0,0,0,0
|
|
||||||
.size .OPENSSL_rdtsc_mfspr268,.-.OPENSSL_rdtsc_mfspr268
|
|
||||||
|
|
||||||
.globl .OPENSSL_cleanse
|
|
||||||
.align 4
|
|
||||||
.OPENSSL_cleanse:
|
|
||||||
$CMPLI r4,7
|
|
||||||
li r0,0
|
|
||||||
bge Lot
|
|
||||||
$CMPLI r4,0
|
|
||||||
beqlr_ori
|
|
||||||
Little: mtctr r4
|
|
||||||
stb r0,0(r3)
|
|
||||||
addi r3,r3,1
|
|
||||||
bdnz \$-8
|
|
||||||
blr
|
|
||||||
Lot: andi. r5,r3,3
|
|
||||||
beq Laligned
|
|
||||||
stb r0,0(r3)
|
|
||||||
subi r4,r4,1
|
|
||||||
addi r3,r3,1
|
|
||||||
b Lot
|
|
||||||
Laligned:
|
|
||||||
$SHRLI r5,r4,2
|
|
||||||
mtctr r5
|
|
||||||
stw r0,0(r3)
|
|
||||||
addi r3,r3,4
|
|
||||||
bdnz \$-8
|
|
||||||
andi. r4,r4,3
|
|
||||||
bne Little
|
|
||||||
blr
|
|
||||||
.long 0
|
|
||||||
.byte 0,12,0x14,0,0,0,2,0
|
|
||||||
.long 0
|
|
||||||
.size .OPENSSL_cleanse,.-.OPENSSL_cleanse
|
|
||||||
|
|
||||||
globl .CRYPTO_memcmp
|
|
||||||
.align 4
|
|
||||||
.CRYPTO_memcmp:
|
|
||||||
$CMPLI r5,0
|
|
||||||
li r0,0
|
|
||||||
beq Lno_data
|
|
||||||
mtctr r5
|
|
||||||
Loop_cmp:
|
|
||||||
lbz r6,0(r3)
|
|
||||||
addi r3,r3,1
|
|
||||||
lbz r7,0(r4)
|
|
||||||
addi r4,r4,1
|
|
||||||
xor r6,r6,r7
|
|
||||||
or r0,r0,r6
|
|
||||||
bdnz Loop_cmp
|
|
||||||
|
|
||||||
Lno_data:
|
|
||||||
li r3,0
|
|
||||||
sub r3,r3,r0
|
|
||||||
extrwi r3,r3,1,0
|
|
||||||
blr
|
|
||||||
.long 0
|
|
||||||
.byte 0,12,0x14,0,0,0,3,0
|
|
||||||
.long 0
|
|
||||||
.size .CRYPTO_memcmp,.-.CRYPTO_memcmp
|
|
||||||
___
|
|
||||||
{
|
|
||||||
my ($out,$cnt,$max)=("r3","r4","r5");
|
|
||||||
my ($tick,$lasttick)=("r6","r7");
|
|
||||||
my ($diff,$lastdiff)=("r8","r9");
|
|
||||||
|
|
||||||
$code.=<<___;
|
|
||||||
.globl .OPENSSL_instrument_bus_mftb
|
|
||||||
.align 4
|
|
||||||
.OPENSSL_instrument_bus_mftb:
|
|
||||||
mtctr $cnt
|
|
||||||
|
|
||||||
mftb $lasttick # collect 1st tick
|
|
||||||
li $diff,0
|
|
||||||
|
|
||||||
dcbf 0,$out # flush cache line
|
|
||||||
lwarx $tick,0,$out # load and lock
|
|
||||||
add $tick,$tick,$diff
|
|
||||||
stwcx. $tick,0,$out
|
|
||||||
stwx $tick,0,$out
|
|
||||||
|
|
||||||
Loop: mftb $tick
|
|
||||||
sub $diff,$tick,$lasttick
|
|
||||||
mr $lasttick,$tick
|
|
||||||
dcbf 0,$out # flush cache line
|
|
||||||
lwarx $tick,0,$out # load and lock
|
|
||||||
add $tick,$tick,$diff
|
|
||||||
stwcx. $tick,0,$out
|
|
||||||
stwx $tick,0,$out
|
|
||||||
addi $out,$out,4 # ++$out
|
|
||||||
bdnz Loop
|
|
||||||
|
|
||||||
mr r3,$cnt
|
|
||||||
blr
|
|
||||||
.long 0
|
|
||||||
.byte 0,12,0x14,0,0,0,2,0
|
|
||||||
.long 0
|
|
||||||
.size .OPENSSL_instrument_bus_mftb,.-.OPENSSL_instrument_bus_mftb
|
|
||||||
|
|
||||||
.globl .OPENSSL_instrument_bus2_mftb
|
|
||||||
.align 4
|
|
||||||
.OPENSSL_instrument_bus2_mftb:
|
|
||||||
mr r0,$cnt
|
|
||||||
slwi $cnt,$cnt,2
|
|
||||||
|
|
||||||
mftb $lasttick # collect 1st tick
|
|
||||||
li $diff,0
|
|
||||||
|
|
||||||
dcbf 0,$out # flush cache line
|
|
||||||
lwarx $tick,0,$out # load and lock
|
|
||||||
add $tick,$tick,$diff
|
|
||||||
stwcx. $tick,0,$out
|
|
||||||
stwx $tick,0,$out
|
|
||||||
|
|
||||||
mftb $tick # collect 1st diff
|
|
||||||
sub $diff,$tick,$lasttick
|
|
||||||
mr $lasttick,$tick
|
|
||||||
mr $lastdiff,$diff
|
|
||||||
Loop2:
|
|
||||||
dcbf 0,$out # flush cache line
|
|
||||||
lwarx $tick,0,$out # load and lock
|
|
||||||
add $tick,$tick,$diff
|
|
||||||
stwcx. $tick,0,$out
|
|
||||||
stwx $tick,0,$out
|
|
||||||
|
|
||||||
addic. $max,$max,-1
|
|
||||||
beq Ldone2
|
|
||||||
|
|
||||||
mftb $tick
|
|
||||||
sub $diff,$tick,$lasttick
|
|
||||||
mr $lasttick,$tick
|
|
||||||
cmplw 7,$diff,$lastdiff
|
|
||||||
mr $lastdiff,$diff
|
|
||||||
|
|
||||||
mfcr $tick # pull cr
|
|
||||||
not $tick,$tick # flip bits
|
|
||||||
rlwinm $tick,$tick,1,29,29 # isolate flipped eq bit and scale
|
|
||||||
|
|
||||||
sub. $cnt,$cnt,$tick # conditional --$cnt
|
|
||||||
add $out,$out,$tick # conditional ++$out
|
|
||||||
bne Loop2
|
|
||||||
|
|
||||||
Ldone2:
|
|
||||||
srwi $cnt,$cnt,2
|
|
||||||
sub r3,r0,$cnt
|
|
||||||
blr
|
|
||||||
.long 0
|
|
||||||
.byte 0,12,0x14,0,0,0,3,0
|
|
||||||
.long 0
|
|
||||||
.size .OPENSSL_instrument_bus2_mftb,.-.OPENSSL_instrument_bus2_mftb
|
|
||||||
|
|
||||||
.globl .OPENSSL_instrument_bus_mfspr268
|
|
||||||
.align 4
|
|
||||||
.OPENSSL_instrument_bus_mfspr268:
|
|
||||||
mtctr $cnt
|
|
||||||
|
|
||||||
mfspr $lasttick,268 # collect 1st tick
|
|
||||||
li $diff,0
|
|
||||||
|
|
||||||
dcbf 0,$out # flush cache line
|
|
||||||
lwarx $tick,0,$out # load and lock
|
|
||||||
add $tick,$tick,$diff
|
|
||||||
stwcx. $tick,0,$out
|
|
||||||
stwx $tick,0,$out
|
|
||||||
|
|
||||||
Loop3: mfspr $tick,268
|
|
||||||
sub $diff,$tick,$lasttick
|
|
||||||
mr $lasttick,$tick
|
|
||||||
dcbf 0,$out # flush cache line
|
|
||||||
lwarx $tick,0,$out # load and lock
|
|
||||||
add $tick,$tick,$diff
|
|
||||||
stwcx. $tick,0,$out
|
|
||||||
stwx $tick,0,$out
|
|
||||||
addi $out,$out,4 # ++$out
|
|
||||||
bdnz Loop3
|
|
||||||
|
|
||||||
mr r3,$cnt
|
|
||||||
blr
|
|
||||||
.long 0
|
|
||||||
.byte 0,12,0x14,0,0,0,2,0
|
|
||||||
.long 0
|
|
||||||
.size .OPENSSL_instrument_bus_mfspr268,.-.OPENSSL_instrument_bus_mfspr268
|
|
||||||
|
|
||||||
.globl .OPENSSL_instrument_bus2_mfspr268
|
|
||||||
.align 4
|
|
||||||
.OPENSSL_instrument_bus2_mfspr268:
|
|
||||||
mr r0,$cnt
|
|
||||||
slwi $cnt,$cnt,2
|
|
||||||
|
|
||||||
mfspr $lasttick,268 # collect 1st tick
|
|
||||||
li $diff,0
|
|
||||||
|
|
||||||
dcbf 0,$out # flush cache line
|
|
||||||
lwarx $tick,0,$out # load and lock
|
|
||||||
add $tick,$tick,$diff
|
|
||||||
stwcx. $tick,0,$out
|
|
||||||
stwx $tick,0,$out
|
|
||||||
|
|
||||||
mfspr $tick,268 # collect 1st diff
|
|
||||||
sub $diff,$tick,$lasttick
|
|
||||||
mr $lasttick,$tick
|
|
||||||
mr $lastdiff,$diff
|
|
||||||
Loop4:
|
|
||||||
dcbf 0,$out # flush cache line
|
|
||||||
lwarx $tick,0,$out # load and lock
|
|
||||||
add $tick,$tick,$diff
|
|
||||||
stwcx. $tick,0,$out
|
|
||||||
stwx $tick,0,$out
|
|
||||||
|
|
||||||
addic. $max,$max,-1
|
|
||||||
beq Ldone4
|
|
||||||
|
|
||||||
mfspr $tick,268
|
|
||||||
sub $diff,$tick,$lasttick
|
|
||||||
mr $lasttick,$tick
|
|
||||||
cmplw 7,$diff,$lastdiff
|
|
||||||
mr $lastdiff,$diff
|
|
||||||
|
|
||||||
mfcr $tick # pull cr
|
|
||||||
not $tick,$tick # flip bits
|
|
||||||
rlwinm $tick,$tick,1,29,29 # isolate flipped eq bit and scale
|
|
||||||
|
|
||||||
sub. $cnt,$cnt,$tick # conditional --$cnt
|
|
||||||
add $out,$out,$tick # conditional ++$out
|
|
||||||
bne Loop4
|
|
||||||
|
|
||||||
Ldone4:
|
|
||||||
srwi $cnt,$cnt,2
|
|
||||||
sub r3,r0,$cnt
|
|
||||||
blr
|
|
||||||
.long 0
|
|
||||||
.byte 0,12,0x14,0,0,0,3,0
|
|
||||||
.long 0
|
|
||||||
.size .OPENSSL_instrument_bus2_mfspr268,.-.OPENSSL_instrument_bus2_mfspr268
|
|
||||||
___
|
|
||||||
}
|
|
||||||
|
|
||||||
$code =~ s/\`([^\`]*)\`/eval $1/gem;
|
|
||||||
print $code;
|
|
||||||
close STDOUT or die "error closing STDOUT: $!";
|
|
||||||
@@ -1,960 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 1995-2023 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* We need to use some engine deprecated APIs */
|
|
||||||
#define OPENSSL_SUPPRESS_DEPRECATED
|
|
||||||
|
|
||||||
#include <openssl/err.h>
|
|
||||||
#include <openssl/opensslconf.h>
|
|
||||||
#include <openssl/core_names.h>
|
|
||||||
#include "internal/cryptlib.h"
|
|
||||||
#include "internal/thread_once.h"
|
|
||||||
#include "crypto/rand.h"
|
|
||||||
#include "crypto/cryptlib.h"
|
|
||||||
#include "rand_local.h"
|
|
||||||
#include "crypto/context.h"
|
|
||||||
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
# include <stdio.h>
|
|
||||||
# include <time.h>
|
|
||||||
# include <limits.h>
|
|
||||||
# include <openssl/conf.h>
|
|
||||||
# include <openssl/trace.h>
|
|
||||||
# include <openssl/engine.h>
|
|
||||||
# include "crypto/rand_pool.h"
|
|
||||||
# include "prov/seeding.h"
|
|
||||||
# include "internal/e_os.h"
|
|
||||||
# include "internal/property.h"
|
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
|
||||||
/* non-NULL if default_RAND_meth is ENGINE-provided */
|
|
||||||
static ENGINE *funct_ref;
|
|
||||||
static CRYPTO_RWLOCK *rand_engine_lock;
|
|
||||||
# endif
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
static CRYPTO_RWLOCK *rand_meth_lock;
|
|
||||||
static const RAND_METHOD *default_RAND_meth;
|
|
||||||
# endif
|
|
||||||
static CRYPTO_ONCE rand_init = CRYPTO_ONCE_STATIC_INIT;
|
|
||||||
|
|
||||||
static int rand_inited = 0;
|
|
||||||
|
|
||||||
DEFINE_RUN_ONCE_STATIC(do_rand_init)
|
|
||||||
{
|
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
|
||||||
rand_engine_lock = CRYPTO_THREAD_lock_new();
|
|
||||||
if (rand_engine_lock == NULL)
|
|
||||||
return 0;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
rand_meth_lock = CRYPTO_THREAD_lock_new();
|
|
||||||
if (rand_meth_lock == NULL)
|
|
||||||
goto err;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
if (!ossl_rand_pool_init())
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
rand_inited = 1;
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
err:
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
CRYPTO_THREAD_lock_free(rand_meth_lock);
|
|
||||||
rand_meth_lock = NULL;
|
|
||||||
# endif
|
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
|
||||||
CRYPTO_THREAD_lock_free(rand_engine_lock);
|
|
||||||
rand_engine_lock = NULL;
|
|
||||||
# endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ossl_rand_cleanup_int(void)
|
|
||||||
{
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
const RAND_METHOD *meth = default_RAND_meth;
|
|
||||||
|
|
||||||
if (!rand_inited)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (meth != NULL && meth->cleanup != NULL)
|
|
||||||
meth->cleanup();
|
|
||||||
RAND_set_rand_method(NULL);
|
|
||||||
# endif
|
|
||||||
ossl_rand_pool_cleanup();
|
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
|
||||||
CRYPTO_THREAD_lock_free(rand_engine_lock);
|
|
||||||
rand_engine_lock = NULL;
|
|
||||||
# endif
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
CRYPTO_THREAD_lock_free(rand_meth_lock);
|
|
||||||
rand_meth_lock = NULL;
|
|
||||||
# endif
|
|
||||||
ossl_release_default_drbg_ctx();
|
|
||||||
rand_inited = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* RAND_close_seed_files() ensures that any seed file descriptors are
|
|
||||||
* closed after use. This only applies to libcrypto/default provider,
|
|
||||||
* it does not apply to other providers.
|
|
||||||
*/
|
|
||||||
void RAND_keep_random_devices_open(int keep)
|
|
||||||
{
|
|
||||||
if (RUN_ONCE(&rand_init, do_rand_init))
|
|
||||||
ossl_rand_pool_keep_random_devices_open(keep);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* RAND_poll() reseeds the default RNG using random input
|
|
||||||
*
|
|
||||||
* The random input is obtained from polling various entropy
|
|
||||||
* sources which depend on the operating system and are
|
|
||||||
* configurable via the --with-rand-seed configure option.
|
|
||||||
*/
|
|
||||||
int RAND_poll(void)
|
|
||||||
{
|
|
||||||
static const char salt[] = "polling";
|
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
const RAND_METHOD *meth = RAND_get_rand_method();
|
|
||||||
int ret = meth == RAND_OpenSSL();
|
|
||||||
|
|
||||||
if (meth == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!ret) {
|
|
||||||
/* fill random pool and seed the current legacy RNG */
|
|
||||||
RAND_POOL *pool = ossl_rand_pool_new(RAND_DRBG_STRENGTH, 1,
|
|
||||||
(RAND_DRBG_STRENGTH + 7) / 8,
|
|
||||||
RAND_POOL_MAX_LENGTH);
|
|
||||||
|
|
||||||
if (pool == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (ossl_pool_acquire_entropy(pool) == 0)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
if (meth->add == NULL
|
|
||||||
|| meth->add(ossl_rand_pool_buffer(pool),
|
|
||||||
ossl_rand_pool_length(pool),
|
|
||||||
(ossl_rand_pool_entropy(pool) / 8.0)) == 0)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
ret = 1;
|
|
||||||
err:
|
|
||||||
ossl_rand_pool_free(pool);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
RAND_seed(salt, sizeof(salt));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
static int rand_set_rand_method_internal(const RAND_METHOD *meth,
|
|
||||||
ossl_unused ENGINE *e)
|
|
||||||
{
|
|
||||||
if (!RUN_ONCE(&rand_init, do_rand_init))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_write_lock(rand_meth_lock))
|
|
||||||
return 0;
|
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
|
||||||
ENGINE_finish(funct_ref);
|
|
||||||
funct_ref = e;
|
|
||||||
# endif
|
|
||||||
default_RAND_meth = meth;
|
|
||||||
CRYPTO_THREAD_unlock(rand_meth_lock);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int RAND_set_rand_method(const RAND_METHOD *meth)
|
|
||||||
{
|
|
||||||
return rand_set_rand_method_internal(meth, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
const RAND_METHOD *RAND_get_rand_method(void)
|
|
||||||
{
|
|
||||||
const RAND_METHOD *tmp_meth = NULL;
|
|
||||||
|
|
||||||
if (!RUN_ONCE(&rand_init, do_rand_init))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_write_lock(rand_meth_lock))
|
|
||||||
return NULL;
|
|
||||||
if (default_RAND_meth == NULL) {
|
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
|
||||||
ENGINE *e;
|
|
||||||
|
|
||||||
/* If we have an engine that can do RAND, use it. */
|
|
||||||
if ((e = ENGINE_get_default_RAND()) != NULL
|
|
||||||
&& (tmp_meth = ENGINE_get_RAND(e)) != NULL) {
|
|
||||||
funct_ref = e;
|
|
||||||
default_RAND_meth = tmp_meth;
|
|
||||||
} else {
|
|
||||||
ENGINE_finish(e);
|
|
||||||
default_RAND_meth = &ossl_rand_meth;
|
|
||||||
}
|
|
||||||
# else
|
|
||||||
default_RAND_meth = &ossl_rand_meth;
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
tmp_meth = default_RAND_meth;
|
|
||||||
CRYPTO_THREAD_unlock(rand_meth_lock);
|
|
||||||
return tmp_meth;
|
|
||||||
}
|
|
||||||
|
|
||||||
# if !defined(OPENSSL_NO_ENGINE)
|
|
||||||
int RAND_set_rand_engine(ENGINE *engine)
|
|
||||||
{
|
|
||||||
const RAND_METHOD *tmp_meth = NULL;
|
|
||||||
|
|
||||||
if (!RUN_ONCE(&rand_init, do_rand_init))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (engine != NULL) {
|
|
||||||
if (!ENGINE_init(engine))
|
|
||||||
return 0;
|
|
||||||
tmp_meth = ENGINE_get_RAND(engine);
|
|
||||||
if (tmp_meth == NULL) {
|
|
||||||
ENGINE_finish(engine);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!CRYPTO_THREAD_write_lock(rand_engine_lock)) {
|
|
||||||
ENGINE_finish(engine);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This function releases any prior ENGINE so call it first */
|
|
||||||
rand_set_rand_method_internal(tmp_meth, engine);
|
|
||||||
CRYPTO_THREAD_unlock(rand_engine_lock);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
# endif /* OPENSSL_NO_DEPRECATED_3_0 */
|
|
||||||
|
|
||||||
void RAND_seed(const void *buf, int num)
|
|
||||||
{
|
|
||||||
EVP_RAND_CTX *drbg;
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
const RAND_METHOD *meth = RAND_get_rand_method();
|
|
||||||
|
|
||||||
if (meth != NULL && meth->seed != NULL) {
|
|
||||||
meth->seed(buf, num);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
drbg = RAND_get0_primary(NULL);
|
|
||||||
if (drbg != NULL && num > 0)
|
|
||||||
EVP_RAND_reseed(drbg, 0, NULL, 0, buf, num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RAND_add(const void *buf, int num, double randomness)
|
|
||||||
{
|
|
||||||
EVP_RAND_CTX *drbg;
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
const RAND_METHOD *meth = RAND_get_rand_method();
|
|
||||||
|
|
||||||
if (meth != NULL && meth->add != NULL) {
|
|
||||||
meth->add(buf, num, randomness);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
drbg = RAND_get0_primary(NULL);
|
|
||||||
if (drbg != NULL && num > 0)
|
|
||||||
# ifdef OPENSSL_RAND_SEED_NONE
|
|
||||||
/* Without an entropy source, we have to rely on the user */
|
|
||||||
EVP_RAND_reseed(drbg, 0, buf, num, NULL, 0);
|
|
||||||
# else
|
|
||||||
/* With an entropy source, we downgrade this to additional input */
|
|
||||||
EVP_RAND_reseed(drbg, 0, NULL, 0, buf, num);
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
|
|
||||||
# if !defined(OPENSSL_NO_DEPRECATED_1_1_0)
|
|
||||||
int RAND_pseudo_bytes(unsigned char *buf, int num)
|
|
||||||
{
|
|
||||||
const RAND_METHOD *meth = RAND_get_rand_method();
|
|
||||||
|
|
||||||
if (meth != NULL && meth->pseudorand != NULL)
|
|
||||||
return meth->pseudorand(buf, num);
|
|
||||||
ERR_raise(ERR_LIB_RAND, RAND_R_FUNC_NOT_IMPLEMENTED);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
int RAND_status(void)
|
|
||||||
{
|
|
||||||
EVP_RAND_CTX *rand;
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
const RAND_METHOD *meth = RAND_get_rand_method();
|
|
||||||
|
|
||||||
if (meth != NULL && meth != RAND_OpenSSL())
|
|
||||||
return meth->status != NULL ? meth->status() : 0;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
if ((rand = RAND_get0_primary(NULL)) == NULL)
|
|
||||||
return 0;
|
|
||||||
return EVP_RAND_get_state(rand) == EVP_RAND_STATE_READY;
|
|
||||||
}
|
|
||||||
# else /* !FIPS_MODULE */
|
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
const RAND_METHOD *RAND_get_rand_method(void)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
#endif /* !FIPS_MODULE */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This function is not part of RAND_METHOD, so if we're not using
|
|
||||||
* the default method, then just call RAND_bytes(). Otherwise make
|
|
||||||
* sure we're instantiated and use the private DRBG.
|
|
||||||
*/
|
|
||||||
int RAND_priv_bytes_ex(OSSL_LIB_CTX *ctx, unsigned char *buf, size_t num,
|
|
||||||
unsigned int strength)
|
|
||||||
{
|
|
||||||
EVP_RAND_CTX *rand;
|
|
||||||
#if !defined(OPENSSL_NO_DEPRECATED_3_0) && !defined(FIPS_MODULE)
|
|
||||||
const RAND_METHOD *meth = RAND_get_rand_method();
|
|
||||||
|
|
||||||
if (meth != NULL && meth != RAND_OpenSSL()) {
|
|
||||||
if (meth->bytes != NULL)
|
|
||||||
return meth->bytes(buf, num);
|
|
||||||
ERR_raise(ERR_LIB_RAND, RAND_R_FUNC_NOT_IMPLEMENTED);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rand = RAND_get0_private(ctx);
|
|
||||||
if (rand != NULL)
|
|
||||||
return EVP_RAND_generate(rand, buf, num, strength, 0, NULL, 0);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int RAND_priv_bytes(unsigned char *buf, int num)
|
|
||||||
{
|
|
||||||
if (num < 0)
|
|
||||||
return 0;
|
|
||||||
return RAND_priv_bytes_ex(NULL, buf, (size_t)num, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int RAND_bytes_ex(OSSL_LIB_CTX *ctx, unsigned char *buf, size_t num,
|
|
||||||
unsigned int strength)
|
|
||||||
{
|
|
||||||
EVP_RAND_CTX *rand;
|
|
||||||
#if !defined(OPENSSL_NO_DEPRECATED_3_0) && !defined(FIPS_MODULE)
|
|
||||||
const RAND_METHOD *meth = RAND_get_rand_method();
|
|
||||||
|
|
||||||
if (meth != NULL && meth != RAND_OpenSSL()) {
|
|
||||||
if (meth->bytes != NULL)
|
|
||||||
return meth->bytes(buf, num);
|
|
||||||
ERR_raise(ERR_LIB_RAND, RAND_R_FUNC_NOT_IMPLEMENTED);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rand = RAND_get0_public(ctx);
|
|
||||||
if (rand != NULL)
|
|
||||||
return EVP_RAND_generate(rand, buf, num, strength, 0, NULL, 0);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int RAND_bytes(unsigned char *buf, int num)
|
|
||||||
{
|
|
||||||
if (num < 0)
|
|
||||||
return 0;
|
|
||||||
return RAND_bytes_ex(NULL, buf, (size_t)num, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct rand_global_st {
|
|
||||||
/*
|
|
||||||
* The three shared DRBG instances
|
|
||||||
*
|
|
||||||
* There are three shared DRBG instances: <primary>, <public>, and
|
|
||||||
* <private>. The <public> and <private> DRBGs are secondary ones.
|
|
||||||
* These are used for non-secret (e.g. nonces) and secret
|
|
||||||
* (e.g. private keys) data respectively.
|
|
||||||
*/
|
|
||||||
CRYPTO_RWLOCK *lock;
|
|
||||||
|
|
||||||
EVP_RAND_CTX *seed;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The <primary> DRBG
|
|
||||||
*
|
|
||||||
* Not used directly by the application, only for reseeding the two other
|
|
||||||
* DRBGs. It reseeds itself by pulling either randomness from os entropy
|
|
||||||
* sources or by consuming randomness which was added by RAND_add().
|
|
||||||
*
|
|
||||||
* The <primary> DRBG is a global instance which is accessed concurrently by
|
|
||||||
* all threads. The necessary locking is managed automatically by its child
|
|
||||||
* DRBG instances during reseeding.
|
|
||||||
*/
|
|
||||||
EVP_RAND_CTX *primary;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The <public> DRBG
|
|
||||||
*
|
|
||||||
* Used by default for generating random bytes using RAND_bytes().
|
|
||||||
*
|
|
||||||
* The <public> secondary DRBG is thread-local, i.e., there is one instance
|
|
||||||
* per thread.
|
|
||||||
*/
|
|
||||||
CRYPTO_THREAD_LOCAL public;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The <private> DRBG
|
|
||||||
*
|
|
||||||
* Used by default for generating private keys using RAND_priv_bytes()
|
|
||||||
*
|
|
||||||
* The <private> secondary DRBG is thread-local, i.e., there is one
|
|
||||||
* instance per thread.
|
|
||||||
*/
|
|
||||||
CRYPTO_THREAD_LOCAL private;
|
|
||||||
|
|
||||||
/* Which RNG is being used by default and it's configuration settings */
|
|
||||||
char *rng_name;
|
|
||||||
char *rng_cipher;
|
|
||||||
char *rng_digest;
|
|
||||||
char *rng_propq;
|
|
||||||
|
|
||||||
/* Allow the randomness source to be changed */
|
|
||||||
char *seed_name;
|
|
||||||
char *seed_propq;
|
|
||||||
} RAND_GLOBAL;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize the OSSL_LIB_CTX global DRBGs on first use.
|
|
||||||
* Returns the allocated global data on success or NULL on failure.
|
|
||||||
*/
|
|
||||||
void *ossl_rand_ctx_new(OSSL_LIB_CTX *libctx)
|
|
||||||
{
|
|
||||||
RAND_GLOBAL *dgbl = OPENSSL_zalloc(sizeof(*dgbl));
|
|
||||||
|
|
||||||
if (dgbl == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
/*
|
|
||||||
* We need to ensure that base libcrypto thread handling has been
|
|
||||||
* initialised.
|
|
||||||
*/
|
|
||||||
OPENSSL_init_crypto(OPENSSL_INIT_BASE_ONLY, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
dgbl->lock = CRYPTO_THREAD_lock_new();
|
|
||||||
if (dgbl->lock == NULL)
|
|
||||||
goto err1;
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_init_local(&dgbl->private, NULL))
|
|
||||||
goto err1;
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_init_local(&dgbl->public, NULL))
|
|
||||||
goto err2;
|
|
||||||
|
|
||||||
return dgbl;
|
|
||||||
|
|
||||||
err2:
|
|
||||||
CRYPTO_THREAD_cleanup_local(&dgbl->private);
|
|
||||||
err1:
|
|
||||||
CRYPTO_THREAD_lock_free(dgbl->lock);
|
|
||||||
OPENSSL_free(dgbl);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ossl_rand_ctx_free(void *vdgbl)
|
|
||||||
{
|
|
||||||
RAND_GLOBAL *dgbl = vdgbl;
|
|
||||||
|
|
||||||
if (dgbl == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
CRYPTO_THREAD_lock_free(dgbl->lock);
|
|
||||||
CRYPTO_THREAD_cleanup_local(&dgbl->private);
|
|
||||||
CRYPTO_THREAD_cleanup_local(&dgbl->public);
|
|
||||||
EVP_RAND_CTX_free(dgbl->primary);
|
|
||||||
EVP_RAND_CTX_free(dgbl->seed);
|
|
||||||
OPENSSL_free(dgbl->rng_name);
|
|
||||||
OPENSSL_free(dgbl->rng_cipher);
|
|
||||||
OPENSSL_free(dgbl->rng_digest);
|
|
||||||
OPENSSL_free(dgbl->rng_propq);
|
|
||||||
OPENSSL_free(dgbl->seed_name);
|
|
||||||
OPENSSL_free(dgbl->seed_propq);
|
|
||||||
|
|
||||||
OPENSSL_free(dgbl);
|
|
||||||
}
|
|
||||||
|
|
||||||
static RAND_GLOBAL *rand_get_global(OSSL_LIB_CTX *libctx)
|
|
||||||
{
|
|
||||||
return ossl_lib_ctx_get_data(libctx, OSSL_LIB_CTX_DRBG_INDEX);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void rand_delete_thread_state(void *arg)
|
|
||||||
{
|
|
||||||
OSSL_LIB_CTX *ctx = arg;
|
|
||||||
RAND_GLOBAL *dgbl = rand_get_global(ctx);
|
|
||||||
EVP_RAND_CTX *rand;
|
|
||||||
|
|
||||||
if (dgbl == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
rand = CRYPTO_THREAD_get_local(&dgbl->public);
|
|
||||||
CRYPTO_THREAD_set_local(&dgbl->public, NULL);
|
|
||||||
EVP_RAND_CTX_free(rand);
|
|
||||||
|
|
||||||
rand = CRYPTO_THREAD_get_local(&dgbl->private);
|
|
||||||
CRYPTO_THREAD_set_local(&dgbl->private, NULL);
|
|
||||||
EVP_RAND_CTX_free(rand);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
static EVP_RAND_CTX *rand_new_seed(OSSL_LIB_CTX *libctx)
|
|
||||||
{
|
|
||||||
EVP_RAND *rand;
|
|
||||||
RAND_GLOBAL *dgbl = rand_get_global(libctx);
|
|
||||||
EVP_RAND_CTX *ctx = NULL;
|
|
||||||
const char *propq;
|
|
||||||
char *name, *props = NULL;
|
|
||||||
size_t props_len;
|
|
||||||
OSSL_PROPERTY_LIST *pl1, *pl2, *pl3 = NULL;
|
|
||||||
|
|
||||||
if (dgbl == NULL)
|
|
||||||
return NULL;
|
|
||||||
propq = dgbl->seed_propq;
|
|
||||||
if (dgbl->seed_name != NULL) {
|
|
||||||
name = dgbl->seed_name;
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Default to our internal seed source. This isn't part of the FIPS
|
|
||||||
* provider so we need to override any FIPS properties.
|
|
||||||
*/
|
|
||||||
if (propq == NULL || *propq == '\0') {
|
|
||||||
propq = "-fips";
|
|
||||||
} else {
|
|
||||||
pl1 = ossl_parse_query(libctx, propq, 1);
|
|
||||||
if (pl1 == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_RAND, RAND_R_INVALID_PROPERTY_QUERY);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
pl2 = ossl_parse_query(libctx, "-fips", 1);
|
|
||||||
if (pl2 == NULL) {
|
|
||||||
ossl_property_free(pl1);
|
|
||||||
ERR_raise(ERR_LIB_RAND, ERR_R_INTERNAL_ERROR);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
pl3 = ossl_property_merge(pl2, pl1);
|
|
||||||
ossl_property_free(pl1);
|
|
||||||
ossl_property_free(pl2);
|
|
||||||
if (pl3 == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_RAND, ERR_R_INTERNAL_ERROR);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
props_len = ossl_property_list_to_string(libctx, pl3, NULL, 0);
|
|
||||||
if (props_len == 0) {
|
|
||||||
/* Shouldn't happen since we added a query element */
|
|
||||||
ERR_raise(ERR_LIB_RAND, ERR_R_INTERNAL_ERROR);
|
|
||||||
goto err;
|
|
||||||
} else {
|
|
||||||
props = OPENSSL_malloc(props_len);
|
|
||||||
if (props == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_RAND, ERR_R_MALLOC_FAILURE);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
if (ossl_property_list_to_string(libctx, pl3,
|
|
||||||
props, props_len) == 0) {
|
|
||||||
ERR_raise(ERR_LIB_RAND, ERR_R_INTERNAL_ERROR);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
ossl_property_free(pl3);
|
|
||||||
pl3 = NULL;
|
|
||||||
propq = props;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
name = "SEED-SRC";
|
|
||||||
}
|
|
||||||
|
|
||||||
rand = EVP_RAND_fetch(libctx, name, propq);
|
|
||||||
if (rand == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_RAND, RAND_R_UNABLE_TO_FETCH_DRBG);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
ctx = EVP_RAND_CTX_new(rand, NULL);
|
|
||||||
EVP_RAND_free(rand);
|
|
||||||
if (ctx == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_RAND, RAND_R_UNABLE_TO_CREATE_DRBG);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
if (!EVP_RAND_instantiate(ctx, 0, 0, NULL, 0, NULL)) {
|
|
||||||
ERR_raise(ERR_LIB_RAND, RAND_R_ERROR_INSTANTIATING_DRBG);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
OPENSSL_free(props);
|
|
||||||
return ctx;
|
|
||||||
err:
|
|
||||||
EVP_RAND_CTX_free(ctx);
|
|
||||||
ossl_property_free(pl3);
|
|
||||||
OPENSSL_free(props);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
EVP_RAND_CTX *ossl_rand_get0_seed_noncreating(OSSL_LIB_CTX *ctx)
|
|
||||||
{
|
|
||||||
RAND_GLOBAL *dgbl = rand_get_global(ctx);
|
|
||||||
EVP_RAND_CTX *ret;
|
|
||||||
|
|
||||||
if (dgbl == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_read_lock(dgbl->lock))
|
|
||||||
return NULL;
|
|
||||||
ret = dgbl->seed;
|
|
||||||
CRYPTO_THREAD_unlock(dgbl->lock);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static EVP_RAND_CTX *rand_new_drbg(OSSL_LIB_CTX *libctx, EVP_RAND_CTX *parent,
|
|
||||||
unsigned int reseed_interval,
|
|
||||||
time_t reseed_time_interval)
|
|
||||||
{
|
|
||||||
EVP_RAND *rand;
|
|
||||||
RAND_GLOBAL *dgbl = rand_get_global(libctx);
|
|
||||||
EVP_RAND_CTX *ctx;
|
|
||||||
OSSL_PARAM params[7], *p = params;
|
|
||||||
char *name, *cipher;
|
|
||||||
|
|
||||||
if (dgbl == NULL)
|
|
||||||
return NULL;
|
|
||||||
name = dgbl->rng_name != NULL ? dgbl->rng_name : "CTR-DRBG";
|
|
||||||
rand = EVP_RAND_fetch(libctx, name, dgbl->rng_propq);
|
|
||||||
if (rand == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_RAND, RAND_R_UNABLE_TO_FETCH_DRBG);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
ctx = EVP_RAND_CTX_new(rand, parent);
|
|
||||||
EVP_RAND_free(rand);
|
|
||||||
if (ctx == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_RAND, RAND_R_UNABLE_TO_CREATE_DRBG);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Rather than trying to decode the DRBG settings, just pass them through
|
|
||||||
* and rely on the other end to ignore those it doesn't care about.
|
|
||||||
*/
|
|
||||||
cipher = dgbl->rng_cipher != NULL ? dgbl->rng_cipher : "AES-256-CTR";
|
|
||||||
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_DRBG_PARAM_CIPHER,
|
|
||||||
cipher, 0);
|
|
||||||
if (dgbl->rng_digest != NULL)
|
|
||||||
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_DRBG_PARAM_DIGEST,
|
|
||||||
dgbl->rng_digest, 0);
|
|
||||||
if (dgbl->rng_propq != NULL)
|
|
||||||
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_DRBG_PARAM_PROPERTIES,
|
|
||||||
dgbl->rng_propq, 0);
|
|
||||||
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_ALG_PARAM_MAC, "HMAC", 0);
|
|
||||||
*p++ = OSSL_PARAM_construct_uint(OSSL_DRBG_PARAM_RESEED_REQUESTS,
|
|
||||||
&reseed_interval);
|
|
||||||
*p++ = OSSL_PARAM_construct_time_t(OSSL_DRBG_PARAM_RESEED_TIME_INTERVAL,
|
|
||||||
&reseed_time_interval);
|
|
||||||
*p = OSSL_PARAM_construct_end();
|
|
||||||
if (!EVP_RAND_instantiate(ctx, 0, 0, NULL, 0, params)) {
|
|
||||||
ERR_raise(ERR_LIB_RAND, RAND_R_ERROR_INSTANTIATING_DRBG);
|
|
||||||
EVP_RAND_CTX_free(ctx);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the primary random generator.
|
|
||||||
* Returns pointer to its EVP_RAND_CTX on success, NULL on failure.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
EVP_RAND_CTX *RAND_get0_primary(OSSL_LIB_CTX *ctx)
|
|
||||||
{
|
|
||||||
RAND_GLOBAL *dgbl = rand_get_global(ctx);
|
|
||||||
EVP_RAND_CTX *ret;
|
|
||||||
|
|
||||||
if (dgbl == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_read_lock(dgbl->lock))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ret = dgbl->primary;
|
|
||||||
CRYPTO_THREAD_unlock(dgbl->lock);
|
|
||||||
|
|
||||||
if (ret != NULL)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_write_lock(dgbl->lock))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ret = dgbl->primary;
|
|
||||||
if (ret != NULL) {
|
|
||||||
CRYPTO_THREAD_unlock(dgbl->lock);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
if (dgbl->seed == NULL) {
|
|
||||||
ERR_set_mark();
|
|
||||||
dgbl->seed = rand_new_seed(ctx);
|
|
||||||
ERR_pop_to_mark();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = dgbl->primary = rand_new_drbg(ctx, dgbl->seed,
|
|
||||||
PRIMARY_RESEED_INTERVAL,
|
|
||||||
PRIMARY_RESEED_TIME_INTERVAL);
|
|
||||||
/*
|
|
||||||
* The primary DRBG may be shared between multiple threads so we must
|
|
||||||
* enable locking.
|
|
||||||
*/
|
|
||||||
if (ret != NULL && !EVP_RAND_enable_locking(ret)) {
|
|
||||||
ERR_raise(ERR_LIB_EVP, EVP_R_UNABLE_TO_ENABLE_LOCKING);
|
|
||||||
EVP_RAND_CTX_free(ret);
|
|
||||||
ret = dgbl->primary = NULL;
|
|
||||||
}
|
|
||||||
CRYPTO_THREAD_unlock(dgbl->lock);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the public random generator.
|
|
||||||
* Returns pointer to its EVP_RAND_CTX on success, NULL on failure.
|
|
||||||
*/
|
|
||||||
EVP_RAND_CTX *RAND_get0_public(OSSL_LIB_CTX *ctx)
|
|
||||||
{
|
|
||||||
RAND_GLOBAL *dgbl = rand_get_global(ctx);
|
|
||||||
EVP_RAND_CTX *rand, *primary;
|
|
||||||
|
|
||||||
if (dgbl == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
rand = CRYPTO_THREAD_get_local(&dgbl->public);
|
|
||||||
if (rand == NULL) {
|
|
||||||
primary = RAND_get0_primary(ctx);
|
|
||||||
if (primary == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ctx = ossl_lib_ctx_get_concrete(ctx);
|
|
||||||
/*
|
|
||||||
* If the private is also NULL then this is the first time we've
|
|
||||||
* used this thread.
|
|
||||||
*/
|
|
||||||
if (CRYPTO_THREAD_get_local(&dgbl->private) == NULL
|
|
||||||
&& !ossl_init_thread_start(NULL, ctx, rand_delete_thread_state))
|
|
||||||
return NULL;
|
|
||||||
rand = rand_new_drbg(ctx, primary, SECONDARY_RESEED_INTERVAL,
|
|
||||||
SECONDARY_RESEED_TIME_INTERVAL);
|
|
||||||
CRYPTO_THREAD_set_local(&dgbl->public, rand);
|
|
||||||
}
|
|
||||||
return rand;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the private random generator.
|
|
||||||
* Returns pointer to its EVP_RAND_CTX on success, NULL on failure.
|
|
||||||
*/
|
|
||||||
EVP_RAND_CTX *RAND_get0_private(OSSL_LIB_CTX *ctx)
|
|
||||||
{
|
|
||||||
RAND_GLOBAL *dgbl = rand_get_global(ctx);
|
|
||||||
EVP_RAND_CTX *rand, *primary;
|
|
||||||
|
|
||||||
if (dgbl == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
rand = CRYPTO_THREAD_get_local(&dgbl->private);
|
|
||||||
if (rand == NULL) {
|
|
||||||
primary = RAND_get0_primary(ctx);
|
|
||||||
if (primary == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ctx = ossl_lib_ctx_get_concrete(ctx);
|
|
||||||
/*
|
|
||||||
* If the public is also NULL then this is the first time we've
|
|
||||||
* used this thread.
|
|
||||||
*/
|
|
||||||
if (CRYPTO_THREAD_get_local(&dgbl->public) == NULL
|
|
||||||
&& !ossl_init_thread_start(NULL, ctx, rand_delete_thread_state))
|
|
||||||
return NULL;
|
|
||||||
rand = rand_new_drbg(ctx, primary, SECONDARY_RESEED_INTERVAL,
|
|
||||||
SECONDARY_RESEED_TIME_INTERVAL);
|
|
||||||
CRYPTO_THREAD_set_local(&dgbl->private, rand);
|
|
||||||
}
|
|
||||||
return rand;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef FIPS_MODULE
|
|
||||||
EVP_RAND_CTX *ossl_rand_get0_private_noncreating(OSSL_LIB_CTX *ctx)
|
|
||||||
{
|
|
||||||
RAND_GLOBAL *dgbl = rand_get_global(ctx);
|
|
||||||
|
|
||||||
if (dgbl == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return CRYPTO_THREAD_get_local(&dgbl->private);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int RAND_set0_public(OSSL_LIB_CTX *ctx, EVP_RAND_CTX *rand)
|
|
||||||
{
|
|
||||||
RAND_GLOBAL *dgbl = rand_get_global(ctx);
|
|
||||||
EVP_RAND_CTX *old;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
if (dgbl == NULL)
|
|
||||||
return 0;
|
|
||||||
old = CRYPTO_THREAD_get_local(&dgbl->public);
|
|
||||||
if ((r = CRYPTO_THREAD_set_local(&dgbl->public, rand)) > 0)
|
|
||||||
EVP_RAND_CTX_free(old);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
int RAND_set0_private(OSSL_LIB_CTX *ctx, EVP_RAND_CTX *rand)
|
|
||||||
{
|
|
||||||
RAND_GLOBAL *dgbl = rand_get_global(ctx);
|
|
||||||
EVP_RAND_CTX *old;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
if (dgbl == NULL)
|
|
||||||
return 0;
|
|
||||||
old = CRYPTO_THREAD_get_local(&dgbl->private);
|
|
||||||
if ((r = CRYPTO_THREAD_set_local(&dgbl->private, rand)) > 0)
|
|
||||||
EVP_RAND_CTX_free(old);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
static int random_set_string(char **p, const char *s)
|
|
||||||
{
|
|
||||||
char *d = NULL;
|
|
||||||
|
|
||||||
if (s != NULL) {
|
|
||||||
d = OPENSSL_strdup(s);
|
|
||||||
if (d == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CRYPTO, ERR_R_MALLOC_FAILURE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OPENSSL_free(*p);
|
|
||||||
*p = d;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Load the DRBG definitions from a configuration file.
|
|
||||||
*/
|
|
||||||
static int random_conf_init(CONF_IMODULE *md, const CONF *cnf)
|
|
||||||
{
|
|
||||||
STACK_OF(CONF_VALUE) *elist;
|
|
||||||
CONF_VALUE *cval;
|
|
||||||
RAND_GLOBAL *dgbl = rand_get_global(NCONF_get0_libctx((CONF *)cnf));
|
|
||||||
int i, r = 1;
|
|
||||||
|
|
||||||
OSSL_TRACE1(CONF, "Loading random module: section %s\n",
|
|
||||||
CONF_imodule_get_value(md));
|
|
||||||
|
|
||||||
/* Value is a section containing RANDOM configuration */
|
|
||||||
elist = NCONF_get_section(cnf, CONF_imodule_get_value(md));
|
|
||||||
if (elist == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CRYPTO, CRYPTO_R_RANDOM_SECTION_ERROR);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dgbl == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (i = 0; i < sk_CONF_VALUE_num(elist); i++) {
|
|
||||||
cval = sk_CONF_VALUE_value(elist, i);
|
|
||||||
if (OPENSSL_strcasecmp(cval->name, "random") == 0) {
|
|
||||||
if (!random_set_string(&dgbl->rng_name, cval->value))
|
|
||||||
return 0;
|
|
||||||
} else if (OPENSSL_strcasecmp(cval->name, "cipher") == 0) {
|
|
||||||
if (!random_set_string(&dgbl->rng_cipher, cval->value))
|
|
||||||
return 0;
|
|
||||||
} else if (OPENSSL_strcasecmp(cval->name, "digest") == 0) {
|
|
||||||
if (!random_set_string(&dgbl->rng_digest, cval->value))
|
|
||||||
return 0;
|
|
||||||
} else if (OPENSSL_strcasecmp(cval->name, "properties") == 0) {
|
|
||||||
if (!random_set_string(&dgbl->rng_propq, cval->value))
|
|
||||||
return 0;
|
|
||||||
} else if (OPENSSL_strcasecmp(cval->name, "seed") == 0) {
|
|
||||||
if (!random_set_string(&dgbl->seed_name, cval->value))
|
|
||||||
return 0;
|
|
||||||
} else if (OPENSSL_strcasecmp(cval->name, "seed_properties") == 0) {
|
|
||||||
if (!random_set_string(&dgbl->seed_propq, cval->value))
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
ERR_raise_data(ERR_LIB_CRYPTO,
|
|
||||||
CRYPTO_R_UNKNOWN_NAME_IN_RANDOM_SECTION,
|
|
||||||
"name=%s, value=%s", cval->name, cval->value);
|
|
||||||
r = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void random_conf_deinit(CONF_IMODULE *md)
|
|
||||||
{
|
|
||||||
OSSL_TRACE(CONF, "Cleaned up random\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ossl_random_add_conf_module(void)
|
|
||||||
{
|
|
||||||
OSSL_TRACE(CONF, "Adding config module 'random'\n");
|
|
||||||
CONF_module_add("random", random_conf_init, random_conf_deinit);
|
|
||||||
}
|
|
||||||
|
|
||||||
int RAND_set_DRBG_type(OSSL_LIB_CTX *ctx, const char *drbg, const char *propq,
|
|
||||||
const char *cipher, const char *digest)
|
|
||||||
{
|
|
||||||
RAND_GLOBAL *dgbl = rand_get_global(ctx);
|
|
||||||
|
|
||||||
if (dgbl == NULL)
|
|
||||||
return 0;
|
|
||||||
if (dgbl->primary != NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CRYPTO, RAND_R_ALREADY_INSTANTIATED);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return random_set_string(&dgbl->rng_name, drbg)
|
|
||||||
&& random_set_string(&dgbl->rng_propq, propq)
|
|
||||||
&& random_set_string(&dgbl->rng_cipher, cipher)
|
|
||||||
&& random_set_string(&dgbl->rng_digest, digest);
|
|
||||||
}
|
|
||||||
|
|
||||||
int RAND_set_seed_source_type(OSSL_LIB_CTX *ctx, const char *seed,
|
|
||||||
const char *propq)
|
|
||||||
{
|
|
||||||
RAND_GLOBAL *dgbl = rand_get_global(ctx);
|
|
||||||
|
|
||||||
if (dgbl == NULL)
|
|
||||||
return 0;
|
|
||||||
if (dgbl->seed != NULL) {
|
|
||||||
ERR_raise(ERR_LIB_CRYPTO, RAND_R_ALREADY_INSTANTIATED);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return random_set_string(&dgbl->seed_name, seed)
|
|
||||||
&& random_set_string(&dgbl->seed_propq, propq);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 1995-2022 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
#undef c2l
|
|
||||||
#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
|
|
||||||
l|=((unsigned long)(*((c)++)))<< 8L, \
|
|
||||||
l|=((unsigned long)(*((c)++)))<<16L, \
|
|
||||||
l|=((unsigned long)(*((c)++)))<<24L)
|
|
||||||
|
|
||||||
/* NOTE - c is not incremented as per c2l */
|
|
||||||
#undef c2ln
|
|
||||||
#define c2ln(c,l1,l2,n) { \
|
|
||||||
c+=n; \
|
|
||||||
l1=l2=0; \
|
|
||||||
switch (n) { \
|
|
||||||
case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
|
|
||||||
/* fall through */ \
|
|
||||||
case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
|
|
||||||
/* fall through */ \
|
|
||||||
case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
|
|
||||||
/* fall through */ \
|
|
||||||
case 5: l2|=((unsigned long)(*(--(c)))); \
|
|
||||||
/* fall through */ \
|
|
||||||
case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
|
|
||||||
/* fall through */ \
|
|
||||||
case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
|
|
||||||
/* fall through */ \
|
|
||||||
case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
|
|
||||||
/* fall through */ \
|
|
||||||
case 1: l1|=((unsigned long)(*(--(c)))); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef l2c
|
|
||||||
#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
|
|
||||||
*((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
|
|
||||||
*((c)++)=(unsigned char)(((l)>>16L)&0xff), \
|
|
||||||
*((c)++)=(unsigned char)(((l)>>24L)&0xff))
|
|
||||||
|
|
||||||
/* NOTE - c is not incremented as per l2c */
|
|
||||||
#undef l2cn
|
|
||||||
#define l2cn(l1,l2,c,n) { \
|
|
||||||
c+=n; \
|
|
||||||
switch (n) { \
|
|
||||||
case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
|
|
||||||
/* fall through */ \
|
|
||||||
case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
|
|
||||||
/* fall through */ \
|
|
||||||
case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
|
|
||||||
/* fall through */ \
|
|
||||||
case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
|
|
||||||
/* fall through */ \
|
|
||||||
case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
|
|
||||||
/* fall through */ \
|
|
||||||
case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
|
|
||||||
/* fall through */ \
|
|
||||||
case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
|
|
||||||
/* fall through */ \
|
|
||||||
case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* NOTE - c is not incremented as per n2l */
|
|
||||||
#define n2ln(c,l1,l2,n) { \
|
|
||||||
c+=n; \
|
|
||||||
l1=l2=0; \
|
|
||||||
switch (n) { \
|
|
||||||
case 8: l2 =((unsigned long)(*(--(c)))) ; \
|
|
||||||
/* fall through */ \
|
|
||||||
case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
|
|
||||||
/* fall through */ \
|
|
||||||
case 6: l2|=((unsigned long)(*(--(c))))<<16; \
|
|
||||||
/* fall through */ \
|
|
||||||
case 5: l2|=((unsigned long)(*(--(c))))<<24; \
|
|
||||||
/* fall through */ \
|
|
||||||
case 4: l1 =((unsigned long)(*(--(c)))) ; \
|
|
||||||
/* fall through */ \
|
|
||||||
case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
|
|
||||||
/* fall through */ \
|
|
||||||
case 2: l1|=((unsigned long)(*(--(c))))<<16; \
|
|
||||||
/* fall through */ \
|
|
||||||
case 1: l1|=((unsigned long)(*(--(c))))<<24; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* NOTE - c is not incremented as per l2n */
|
|
||||||
#define l2nn(l1,l2,c,n) { \
|
|
||||||
c+=n; \
|
|
||||||
switch (n) { \
|
|
||||||
case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
|
|
||||||
/* fall through */ \
|
|
||||||
case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
|
|
||||||
/* fall through */ \
|
|
||||||
case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
|
|
||||||
/* fall through */ \
|
|
||||||
case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
|
|
||||||
/* fall through */ \
|
|
||||||
case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
|
|
||||||
/* fall through */ \
|
|
||||||
case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
|
|
||||||
/* fall through */ \
|
|
||||||
case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
|
|
||||||
/* fall through */ \
|
|
||||||
case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef n2l
|
|
||||||
#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
|
|
||||||
l|=((unsigned long)(*((c)++)))<<16L, \
|
|
||||||
l|=((unsigned long)(*((c)++)))<< 8L, \
|
|
||||||
l|=((unsigned long)(*((c)++))))
|
|
||||||
|
|
||||||
#undef l2n
|
|
||||||
#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
|
|
||||||
*((c)++)=(unsigned char)(((l)>>16L)&0xff), \
|
|
||||||
*((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
|
|
||||||
*((c)++)=(unsigned char)(((l) )&0xff))
|
|
||||||
|
|
||||||
#define C_RC2(n) \
|
|
||||||
t=(x0+(x1& ~x3)+(x2&x3)+ *(p0++))&0xffff; \
|
|
||||||
x0=(t<<1)|(t>>15); \
|
|
||||||
t=(x1+(x2& ~x0)+(x3&x0)+ *(p0++))&0xffff; \
|
|
||||||
x1=(t<<2)|(t>>14); \
|
|
||||||
t=(x2+(x3& ~x1)+(x0&x1)+ *(p0++))&0xffff; \
|
|
||||||
x2=(t<<3)|(t>>13); \
|
|
||||||
t=(x3+(x0& ~x2)+(x1&x2)+ *(p0++))&0xffff; \
|
|
||||||
x3=(t<<5)|(t>>11);
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017-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 "internal/sha3.h"
|
|
||||||
|
|
||||||
void SHA3_squeeze(uint64_t A[5][5], unsigned char *out, size_t len, size_t r);
|
|
||||||
|
|
||||||
void ossl_sha3_reset(KECCAK1600_CTX *ctx)
|
|
||||||
{
|
|
||||||
memset(ctx->A, 0, sizeof(ctx->A));
|
|
||||||
ctx->bufsz = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_sha3_init(KECCAK1600_CTX *ctx, unsigned char pad, size_t bitlen)
|
|
||||||
{
|
|
||||||
size_t bsz = SHA3_BLOCKSIZE(bitlen);
|
|
||||||
|
|
||||||
if (bsz <= sizeof(ctx->buf)) {
|
|
||||||
ossl_sha3_reset(ctx);
|
|
||||||
ctx->block_size = bsz;
|
|
||||||
ctx->md_size = bitlen / 8;
|
|
||||||
ctx->pad = pad;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_keccak_kmac_init(KECCAK1600_CTX *ctx, unsigned char pad, size_t bitlen)
|
|
||||||
{
|
|
||||||
int ret = ossl_sha3_init(ctx, pad, bitlen);
|
|
||||||
|
|
||||||
if (ret)
|
|
||||||
ctx->md_size *= 2;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_sha3_update(KECCAK1600_CTX *ctx, const void *_inp, size_t len)
|
|
||||||
{
|
|
||||||
const unsigned char *inp = _inp;
|
|
||||||
size_t bsz = ctx->block_size;
|
|
||||||
size_t num, rem;
|
|
||||||
|
|
||||||
if (len == 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if ((num = ctx->bufsz) != 0) { /* process intermediate buffer? */
|
|
||||||
rem = bsz - num;
|
|
||||||
|
|
||||||
if (len < rem) {
|
|
||||||
memcpy(ctx->buf + num, inp, len);
|
|
||||||
ctx->bufsz += len;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* We have enough data to fill or overflow the intermediate
|
|
||||||
* buffer. So we append |rem| bytes and process the block,
|
|
||||||
* leaving the rest for later processing...
|
|
||||||
*/
|
|
||||||
memcpy(ctx->buf + num, inp, rem);
|
|
||||||
inp += rem, len -= rem;
|
|
||||||
(void)SHA3_absorb(ctx->A, ctx->buf, bsz, bsz);
|
|
||||||
ctx->bufsz = 0;
|
|
||||||
/* ctx->buf is processed, ctx->num is guaranteed to be zero */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (len >= bsz)
|
|
||||||
rem = SHA3_absorb(ctx->A, inp, len, bsz);
|
|
||||||
else
|
|
||||||
rem = len;
|
|
||||||
|
|
||||||
if (rem) {
|
|
||||||
memcpy(ctx->buf, inp + len - rem, rem);
|
|
||||||
ctx->bufsz = rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_sha3_final(unsigned char *md, KECCAK1600_CTX *ctx)
|
|
||||||
{
|
|
||||||
size_t bsz = ctx->block_size;
|
|
||||||
size_t num = ctx->bufsz;
|
|
||||||
|
|
||||||
if (ctx->md_size == 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Pad the data with 10*1. Note that |num| can be |bsz - 1|
|
|
||||||
* in which case both byte operations below are performed on
|
|
||||||
* same byte...
|
|
||||||
*/
|
|
||||||
memset(ctx->buf + num, 0, bsz - num);
|
|
||||||
ctx->buf[num] = ctx->pad;
|
|
||||||
ctx->buf[bsz - 1] |= 0x80;
|
|
||||||
|
|
||||||
(void)SHA3_absorb(ctx->A, ctx->buf, bsz, bsz);
|
|
||||||
|
|
||||||
SHA3_squeeze(ctx->A, md, ctx->md_size, bsz);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,284 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016-2023 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* We need to use the OPENSSL_fork_*() deprecated APIs */
|
|
||||||
#define OPENSSL_SUPPRESS_DEPRECATED
|
|
||||||
|
|
||||||
#include <openssl/crypto.h>
|
|
||||||
#include "internal/cryptlib.h"
|
|
||||||
|
|
||||||
#if defined(__sun)
|
|
||||||
# include <atomic.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__apple_build_version__) && __apple_build_version__ < 6000000
|
|
||||||
/*
|
|
||||||
* OS/X 10.7 and 10.8 had a weird version of clang which has __ATOMIC_ACQUIRE and
|
|
||||||
* __ATOMIC_ACQ_REL but which expects only one parameter for __atomic_is_lock_free()
|
|
||||||
* rather than two which has signature __atomic_is_lock_free(sizeof(_Atomic(T))).
|
|
||||||
* All of this makes impossible to use __atomic_is_lock_free here.
|
|
||||||
*
|
|
||||||
* See: https://github.com/llvm/llvm-project/commit/a4c2602b714e6c6edb98164550a5ae829b2de760
|
|
||||||
*/
|
|
||||||
#define BROKEN_CLANG_ATOMICS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG) && !defined(OPENSSL_SYS_WINDOWS)
|
|
||||||
|
|
||||||
# if defined(OPENSSL_SYS_UNIX)
|
|
||||||
# include <sys/types.h>
|
|
||||||
# include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
# include <assert.h>
|
|
||||||
|
|
||||||
# ifdef PTHREAD_RWLOCK_INITIALIZER
|
|
||||||
# define USE_RWLOCK
|
|
||||||
# endif
|
|
||||||
|
|
||||||
CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
|
|
||||||
{
|
|
||||||
# ifdef USE_RWLOCK
|
|
||||||
CRYPTO_RWLOCK *lock;
|
|
||||||
|
|
||||||
if ((lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t))) == NULL) {
|
|
||||||
/* Don't set error, to avoid recursion blowup. */
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pthread_rwlock_init(lock, NULL) != 0) {
|
|
||||||
OPENSSL_free(lock);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
# else
|
|
||||||
pthread_mutexattr_t attr;
|
|
||||||
CRYPTO_RWLOCK *lock;
|
|
||||||
|
|
||||||
if ((lock = OPENSSL_zalloc(sizeof(pthread_mutex_t))) == NULL) {
|
|
||||||
/* Don't set error, to avoid recursion blowup. */
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We don't use recursive mutexes, but try to catch errors if we do.
|
|
||||||
*/
|
|
||||||
pthread_mutexattr_init(&attr);
|
|
||||||
# if !defined (__TANDEM) && !defined (_SPT_MODEL_)
|
|
||||||
# if !defined(NDEBUG) && !defined(OPENSSL_NO_MUTEX_ERRORCHECK)
|
|
||||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
|
|
||||||
# endif
|
|
||||||
# else
|
|
||||||
/* The SPT Thread Library does not define MUTEX attributes. */
|
|
||||||
# endif
|
|
||||||
|
|
||||||
if (pthread_mutex_init(lock, &attr) != 0) {
|
|
||||||
pthread_mutexattr_destroy(&attr);
|
|
||||||
OPENSSL_free(lock);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutexattr_destroy(&attr);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
return lock;
|
|
||||||
}
|
|
||||||
|
|
||||||
__owur int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
# ifdef USE_RWLOCK
|
|
||||||
if (pthread_rwlock_rdlock(lock) != 0)
|
|
||||||
return 0;
|
|
||||||
# else
|
|
||||||
if (pthread_mutex_lock(lock) != 0) {
|
|
||||||
assert(errno != EDEADLK && errno != EBUSY);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
__owur int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
# ifdef USE_RWLOCK
|
|
||||||
if (pthread_rwlock_wrlock(lock) != 0)
|
|
||||||
return 0;
|
|
||||||
# else
|
|
||||||
if (pthread_mutex_lock(lock) != 0) {
|
|
||||||
assert(errno != EDEADLK && errno != EBUSY);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
# ifdef USE_RWLOCK
|
|
||||||
if (pthread_rwlock_unlock(lock) != 0)
|
|
||||||
return 0;
|
|
||||||
# else
|
|
||||||
if (pthread_mutex_unlock(lock) != 0) {
|
|
||||||
assert(errno != EPERM);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
if (lock == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
# ifdef USE_RWLOCK
|
|
||||||
pthread_rwlock_destroy(lock);
|
|
||||||
# else
|
|
||||||
pthread_mutex_destroy(lock);
|
|
||||||
# endif
|
|
||||||
OPENSSL_free(lock);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
|
|
||||||
{
|
|
||||||
if (pthread_once(once, init) != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))
|
|
||||||
{
|
|
||||||
if (pthread_key_create(key, cleanup) != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)
|
|
||||||
{
|
|
||||||
return pthread_getspecific(*key);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)
|
|
||||||
{
|
|
||||||
if (pthread_setspecific(*key, val) != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key)
|
|
||||||
{
|
|
||||||
if (pthread_key_delete(*key) != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
CRYPTO_THREAD_ID CRYPTO_THREAD_get_current_id(void)
|
|
||||||
{
|
|
||||||
return pthread_self();
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b)
|
|
||||||
{
|
|
||||||
return pthread_equal(a, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
# if defined(__GNUC__) && defined(__ATOMIC_ACQ_REL) && !defined(BROKEN_CLANG_ATOMICS)
|
|
||||||
if (__atomic_is_lock_free(sizeof(*val), val)) {
|
|
||||||
*ret = __atomic_add_fetch(val, amount, __ATOMIC_ACQ_REL);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
# elif defined(__sun) && (defined(__SunOS_5_10) || defined(__SunOS_5_11))
|
|
||||||
/* This will work for all future Solaris versions. */
|
|
||||||
if (ret != NULL) {
|
|
||||||
*ret = atomic_add_int_nv((volatile unsigned int *)val, amount);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
if (lock == NULL || !CRYPTO_THREAD_write_lock(lock))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
*val += amount;
|
|
||||||
*ret = *val;
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_unlock(lock))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_atomic_or(uint64_t *val, uint64_t op, uint64_t *ret,
|
|
||||||
CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
# if defined(__GNUC__) && defined(__ATOMIC_ACQ_REL) && !defined(BROKEN_CLANG_ATOMICS)
|
|
||||||
if (__atomic_is_lock_free(sizeof(*val), val)) {
|
|
||||||
*ret = __atomic_or_fetch(val, op, __ATOMIC_ACQ_REL);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
# elif defined(__sun) && (defined(__SunOS_5_10) || defined(__SunOS_5_11))
|
|
||||||
/* This will work for all future Solaris versions. */
|
|
||||||
if (ret != NULL) {
|
|
||||||
*ret = atomic_or_64_nv(val, op);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
if (lock == NULL || !CRYPTO_THREAD_write_lock(lock))
|
|
||||||
return 0;
|
|
||||||
*val |= op;
|
|
||||||
*ret = *val;
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_unlock(lock))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_atomic_load(uint64_t *val, uint64_t *ret, CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
# if defined(__GNUC__) && defined(__ATOMIC_ACQUIRE) && !defined(BROKEN_CLANG_ATOMICS)
|
|
||||||
if (__atomic_is_lock_free(sizeof(*val), val)) {
|
|
||||||
__atomic_load(val, ret, __ATOMIC_ACQUIRE);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
# elif defined(__sun) && (defined(__SunOS_5_10) || defined(__SunOS_5_11))
|
|
||||||
/* This will work for all future Solaris versions. */
|
|
||||||
if (ret != NULL) {
|
|
||||||
*ret = atomic_or_64_nv(val, 0);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
if (lock == NULL || !CRYPTO_THREAD_read_lock(lock))
|
|
||||||
return 0;
|
|
||||||
*ret = *val;
|
|
||||||
if (!CRYPTO_THREAD_unlock(lock))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
# ifndef FIPS_MODULE
|
|
||||||
int openssl_init_fork_handlers(void)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
# endif /* FIPS_MODULE */
|
|
||||||
|
|
||||||
int openssl_get_fork_id(void)
|
|
||||||
{
|
|
||||||
return getpid();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -1,171 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016-2022 The OpenSSL Project Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the OpenSSL license (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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Copyright (c) 2022 Wind River Systems, Inc. */
|
|
||||||
|
|
||||||
|
|
||||||
#include <vxWorks.h>
|
|
||||||
#include <private/semLibP.h>
|
|
||||||
#include <openssl/crypto.h>
|
|
||||||
|
|
||||||
#if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG) && defined(OPENSSL_SYS_VXWORKS)
|
|
||||||
|
|
||||||
# define SEM_MAX_READERS 0x20
|
|
||||||
# define SEM_CREATE(options) semRWCreate((int) options, (int) SEM_MAX_READERS)
|
|
||||||
# define SEM_R_TAKE(sem, timeout) semRTake((SEM_ID) sem, (_Vx_ticks_t) timeout)
|
|
||||||
# define SEM_W_TAKE(sem, timeout) semWTake((SEM_ID) sem, (_Vx_ticks_t) timeout)
|
|
||||||
# define SEM_DELETE(sem) semDelete((SEM_ID) sem)
|
|
||||||
|
|
||||||
# if defined(_WRS_KERNEL)
|
|
||||||
# define SEM_GIVE(sem) semRWGive((SEM_ID) sem)
|
|
||||||
# else
|
|
||||||
# define SEM_GIVE(sem) semGive((SEM_ID) sem)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
|
|
||||||
{
|
|
||||||
CRYPTO_RWLOCK *lock;
|
|
||||||
|
|
||||||
lock = SEM_CREATE (SEM_Q_PRIORITY);
|
|
||||||
|
|
||||||
if (SEM_ID_NULL == lock) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return lock;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
if(SEM_R_TAKE(lock, WAIT_FOREVER) != OK)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
if(SEM_W_TAKE(lock, WAIT_FOREVER) != OK)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
if(SEM_GIVE(lock) != OK)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
if (lock == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
SEM_DELETE(lock);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
|
|
||||||
{
|
|
||||||
call_once(once, init);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))
|
|
||||||
{
|
|
||||||
if (tss_create(key, cleanup) != thrd_success)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)
|
|
||||||
{
|
|
||||||
return tss_get(*key);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)
|
|
||||||
{
|
|
||||||
if (tss_set(*key, val) != thrd_success)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key)
|
|
||||||
{
|
|
||||||
tss_delete(*key);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
CRYPTO_THREAD_ID CRYPTO_THREAD_get_current_id(void)
|
|
||||||
{
|
|
||||||
return taskIdSelf ();
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b)
|
|
||||||
{
|
|
||||||
return (a == b);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
*ret = vxAtomic32Add(val, amount) + amount;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if (_VX_CPU_FAMILY == _VX_PPC) && defined (_WRS_CONFIG_ILP32)
|
|
||||||
int CRYPTO_atomic_or(uint64_t *val, uint64_t op, uint64_t *ret,
|
|
||||||
CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
*val |= op;
|
|
||||||
*ret = *val;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_atomic_load(uint64_t *val, uint64_t *ret, CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
*ret = *val;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
int CRYPTO_atomic_or(uint64_t *val, uint64_t op, uint64_t *ret,
|
|
||||||
CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
*ret = (uint64_t)vxAtomic64Or((atomic64_t *)val, (atomic64Val_t)op) | op;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_atomic_load(uint64_t *val, uint64_t *ret, CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
*ret = (uint64_t)vxAtomic64Or((atomic64_t *)val, 0);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int openssl_init_fork_handlers(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int openssl_get_fork_id(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,263 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016-2023 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
# include <windows.h>
|
|
||||||
# if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600
|
|
||||||
# define USE_RWLOCK
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* VC++ 2008 or earlier x86 compilers do not have an inline implementation
|
|
||||||
* of InterlockedOr64 for 32bit and will fail to run on Windows XP 32bit.
|
|
||||||
* https://docs.microsoft.com/en-us/cpp/intrinsics/interlockedor-intrinsic-functions#requirements
|
|
||||||
* To work around this problem, we implement a manual locking mechanism for
|
|
||||||
* only VC++ 2008 or earlier x86 compilers.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if (defined(_MSC_VER) && defined(_M_IX86) && _MSC_VER <= 1600)
|
|
||||||
# define NO_INTERLOCKEDOR64
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <openssl/crypto.h>
|
|
||||||
|
|
||||||
#if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG) && defined(OPENSSL_SYS_WINDOWS)
|
|
||||||
|
|
||||||
# ifdef USE_RWLOCK
|
|
||||||
typedef struct {
|
|
||||||
SRWLOCK lock;
|
|
||||||
int exclusive;
|
|
||||||
} CRYPTO_win_rwlock;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
|
|
||||||
{
|
|
||||||
CRYPTO_RWLOCK *lock;
|
|
||||||
# ifdef USE_RWLOCK
|
|
||||||
CRYPTO_win_rwlock *rwlock;
|
|
||||||
|
|
||||||
if ((lock = OPENSSL_zalloc(sizeof(CRYPTO_win_rwlock))) == NULL)
|
|
||||||
return NULL;
|
|
||||||
rwlock = lock;
|
|
||||||
InitializeSRWLock(&rwlock->lock);
|
|
||||||
# else
|
|
||||||
|
|
||||||
if ((lock = OPENSSL_zalloc(sizeof(CRITICAL_SECTION))) == NULL) {
|
|
||||||
/* Don't set error, to avoid recursion blowup. */
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
# if !defined(_WIN32_WCE)
|
|
||||||
/* 0x400 is the spin count value suggested in the documentation */
|
|
||||||
if (!InitializeCriticalSectionAndSpinCount(lock, 0x400)) {
|
|
||||||
OPENSSL_free(lock);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
# else
|
|
||||||
InitializeCriticalSection(lock);
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
return lock;
|
|
||||||
}
|
|
||||||
|
|
||||||
__owur int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
# ifdef USE_RWLOCK
|
|
||||||
CRYPTO_win_rwlock *rwlock = lock;
|
|
||||||
|
|
||||||
AcquireSRWLockShared(&rwlock->lock);
|
|
||||||
# else
|
|
||||||
EnterCriticalSection(lock);
|
|
||||||
# endif
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
__owur int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
# ifdef USE_RWLOCK
|
|
||||||
CRYPTO_win_rwlock *rwlock = lock;
|
|
||||||
|
|
||||||
AcquireSRWLockExclusive(&rwlock->lock);
|
|
||||||
rwlock->exclusive = 1;
|
|
||||||
# else
|
|
||||||
EnterCriticalSection(lock);
|
|
||||||
# endif
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
# ifdef USE_RWLOCK
|
|
||||||
CRYPTO_win_rwlock *rwlock = lock;
|
|
||||||
|
|
||||||
if (rwlock->exclusive) {
|
|
||||||
rwlock->exclusive = 0;
|
|
||||||
ReleaseSRWLockExclusive(&rwlock->lock);
|
|
||||||
} else {
|
|
||||||
ReleaseSRWLockShared(&rwlock->lock);
|
|
||||||
}
|
|
||||||
# else
|
|
||||||
LeaveCriticalSection(lock);
|
|
||||||
# endif
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
if (lock == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
# ifndef USE_RWLOCK
|
|
||||||
DeleteCriticalSection(lock);
|
|
||||||
# endif
|
|
||||||
OPENSSL_free(lock);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
# define ONCE_UNINITED 0
|
|
||||||
# define ONCE_ININIT 1
|
|
||||||
# define ONCE_DONE 2
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We don't use InitOnceExecuteOnce because that isn't available in WinXP which
|
|
||||||
* we still have to support.
|
|
||||||
*/
|
|
||||||
int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
|
|
||||||
{
|
|
||||||
LONG volatile *lock = (LONG *)once;
|
|
||||||
LONG result;
|
|
||||||
|
|
||||||
if (*lock == ONCE_DONE)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
do {
|
|
||||||
result = InterlockedCompareExchange(lock, ONCE_ININIT, ONCE_UNINITED);
|
|
||||||
if (result == ONCE_UNINITED) {
|
|
||||||
init();
|
|
||||||
*lock = ONCE_DONE;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
} while (result == ONCE_ININIT);
|
|
||||||
|
|
||||||
return (*lock == ONCE_DONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))
|
|
||||||
{
|
|
||||||
*key = TlsAlloc();
|
|
||||||
if (*key == TLS_OUT_OF_INDEXES)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)
|
|
||||||
{
|
|
||||||
DWORD last_error;
|
|
||||||
void *ret;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* TlsGetValue clears the last error even on success, so that callers may
|
|
||||||
* distinguish it successfully returning NULL or failing. It is documented
|
|
||||||
* to never fail if the argument is a valid index from TlsAlloc, so we do
|
|
||||||
* not need to handle this.
|
|
||||||
*
|
|
||||||
* However, this error-mangling behavior interferes with the caller's use of
|
|
||||||
* GetLastError. In particular SSL_get_error queries the error queue to
|
|
||||||
* determine whether the caller should look at the OS's errors. To avoid
|
|
||||||
* destroying state, save and restore the Windows error.
|
|
||||||
*
|
|
||||||
* https://msdn.microsoft.com/en-us/library/windows/desktop/ms686812(v=vs.85).aspx
|
|
||||||
*/
|
|
||||||
last_error = GetLastError();
|
|
||||||
ret = TlsGetValue(*key);
|
|
||||||
SetLastError(last_error);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)
|
|
||||||
{
|
|
||||||
if (TlsSetValue(*key, val) == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key)
|
|
||||||
{
|
|
||||||
if (TlsFree(*key) == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
CRYPTO_THREAD_ID CRYPTO_THREAD_get_current_id(void)
|
|
||||||
{
|
|
||||||
return GetCurrentThreadId();
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b)
|
|
||||||
{
|
|
||||||
return (a == b);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
*ret = (int)InterlockedExchangeAdd((long volatile *)val, (long)amount) + amount;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_atomic_or(uint64_t *val, uint64_t op, uint64_t *ret,
|
|
||||||
CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
#if (defined(NO_INTERLOCKEDOR64))
|
|
||||||
if (lock == NULL || !CRYPTO_THREAD_write_lock(lock))
|
|
||||||
return 0;
|
|
||||||
*val |= op;
|
|
||||||
*ret = *val;
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_unlock(lock))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
#else
|
|
||||||
*ret = (uint64_t)InterlockedOr64((LONG64 volatile *)val, (LONG64)op) | op;
|
|
||||||
return 1;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYPTO_atomic_load(uint64_t *val, uint64_t *ret, CRYPTO_RWLOCK *lock)
|
|
||||||
{
|
|
||||||
#if (defined(NO_INTERLOCKEDOR64))
|
|
||||||
if (lock == NULL || !CRYPTO_THREAD_read_lock(lock))
|
|
||||||
return 0;
|
|
||||||
*ret = *val;
|
|
||||||
if (!CRYPTO_THREAD_unlock(lock))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
#else
|
|
||||||
*ret = (uint64_t)InterlockedOr64((LONG64 volatile *)val, 0);
|
|
||||||
return 1;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int openssl_init_fork_handlers(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int openssl_get_fork_id(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 1995-2016 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 <stdio.h>
|
|
||||||
#include "internal/cryptlib.h"
|
|
||||||
#include <openssl/crypto.h>
|
|
||||||
#include <openssl/x509.h>
|
|
||||||
|
|
||||||
const char *X509_get_default_private_dir(void)
|
|
||||||
{
|
|
||||||
return X509_PRIVATE_DIR;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *X509_get_default_cert_area(void)
|
|
||||||
{
|
|
||||||
return X509_CERT_AREA;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *X509_get_default_cert_dir(void)
|
|
||||||
{
|
|
||||||
return X509_CERT_DIR;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *X509_get_default_cert_file(void)
|
|
||||||
{
|
|
||||||
return X509_CERT_FILE;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *X509_get_default_cert_dir_env(void)
|
|
||||||
{
|
|
||||||
return X509_CERT_DIR_EVP;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *X509_get_default_cert_file_env(void)
|
|
||||||
{
|
|
||||||
return X509_CERT_FILE_EVP;
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
* in the file LICENSE in the source distribution or at
|
|
||||||
* https://www.openssl.org/source/license.html
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "internal/cryptlib.h"
|
|
||||||
#include <openssl/objects.h>
|
|
||||||
#include <openssl/asn1t.h>
|
|
||||||
#include <openssl/x509.h>
|
|
||||||
#include "x509_local.h"
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* X509_ATTRIBUTE: this has the following form:
|
|
||||||
*
|
|
||||||
* typedef struct x509_attributes_st
|
|
||||||
* {
|
|
||||||
* ASN1_OBJECT *object;
|
|
||||||
* STACK_OF(ASN1_TYPE) *set;
|
|
||||||
* } X509_ATTRIBUTE;
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
ASN1_SEQUENCE(X509_ATTRIBUTE) = {
|
|
||||||
ASN1_SIMPLE(X509_ATTRIBUTE, object, ASN1_OBJECT),
|
|
||||||
ASN1_SET_OF(X509_ATTRIBUTE, set, ASN1_ANY)
|
|
||||||
} ASN1_SEQUENCE_END(X509_ATTRIBUTE)
|
|
||||||
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(X509_ATTRIBUTE)
|
|
||||||
IMPLEMENT_ASN1_DUP_FUNCTION(X509_ATTRIBUTE)
|
|
||||||
|
|
||||||
X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value)
|
|
||||||
{
|
|
||||||
X509_ATTRIBUTE *ret = NULL;
|
|
||||||
ASN1_TYPE *val = NULL;
|
|
||||||
ASN1_OBJECT *oid;
|
|
||||||
|
|
||||||
if ((oid = OBJ_nid2obj(nid)) == NULL)
|
|
||||||
return NULL;
|
|
||||||
if ((ret = X509_ATTRIBUTE_new()) == NULL)
|
|
||||||
return NULL;
|
|
||||||
ret->object = oid;
|
|
||||||
if ((val = ASN1_TYPE_new()) == NULL)
|
|
||||||
goto err;
|
|
||||||
if (!sk_ASN1_TYPE_push(ret->set, val))
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
ASN1_TYPE_set(val, atrtype, value);
|
|
||||||
return ret;
|
|
||||||
err:
|
|
||||||
X509_ATTRIBUTE_free(ret);
|
|
||||||
ASN1_TYPE_free(val);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
# Quick instruction:
|
|
||||||
# To build against an OpenSSL built in the source tree, do this:
|
|
||||||
#
|
|
||||||
# make OPENSSL_INCS_LOCATION=-I../../include OPENSSL_LIBS_LOCATION=-L../..
|
|
||||||
#
|
|
||||||
# To run the demos when linked with a shared library (default):
|
|
||||||
#
|
|
||||||
# LD_LIBRARY_PATH=../.. ./server-arg
|
|
||||||
# LD_LIBRARY_PATH=../.. ./server-cmod
|
|
||||||
# LD_LIBRARY_PATH=../.. ./server-conf
|
|
||||||
# LD_LIBRARY_PATH=../.. ./client-arg
|
|
||||||
# LD_LIBRARY_PATH=../.. ./client-conf
|
|
||||||
# LD_LIBRARY_PATH=../.. ./saccept
|
|
||||||
# LD_LIBRARY_PATH=../.. ./sconnect
|
|
||||||
|
|
||||||
CFLAGS = $(OPENSSL_INCS_LOCATION)
|
|
||||||
LDFLAGS = $(OPENSSL_LIBS_LOCATION) -lssl -lcrypto $(EX_LIBS)
|
|
||||||
|
|
||||||
all: client-arg client-conf saccept sconnect server-arg server-cmod server-conf
|
|
||||||
|
|
||||||
client-arg: client-arg.o
|
|
||||||
client-conf: client-conf.o
|
|
||||||
saccept: saccept.o
|
|
||||||
sconnect: sconnect.o
|
|
||||||
server-arg: server-arg.o
|
|
||||||
server-cmod: server-cmod.o
|
|
||||||
server-conf: server-conf.o
|
|
||||||
|
|
||||||
client-arg client-conf saccept sconnect server-arg server-cmod server-conf:
|
|
||||||
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) *.o client-arg client-conf saccept sconnect server-arg server-cmod server-conf
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Recreate the demo certificates in the apps directory.
|
|
||||||
|
|
||||||
OPENSSL=openssl
|
|
||||||
|
|
||||||
# Root CA: create certificate directly
|
|
||||||
CN="OpenSSL Test Root CA" $OPENSSL req -config apps.cnf -x509 -nodes \
|
|
||||||
-keyout root.pem -out root.pem -key rootkey.pem -new -days 3650
|
|
||||||
# Intermediate CA: request first
|
|
||||||
CN="OpenSSL Test Intermediate CA" $OPENSSL req -config apps.cnf -nodes \
|
|
||||||
-key intkey.pem -out intreq.pem -new
|
|
||||||
# Sign request: CA extensions
|
|
||||||
$OPENSSL x509 -req -in intreq.pem -CA root.pem -CAkey rootkey.pem -days 3630 \
|
|
||||||
-extfile apps.cnf -extensions v3_ca -CAcreateserial -out intca.pem
|
|
||||||
# Client certificate: request first
|
|
||||||
CN="Test Client Cert" $OPENSSL req -config apps.cnf -nodes \
|
|
||||||
-key ckey.pem -out creq.pem -new
|
|
||||||
# Sign using intermediate CA
|
|
||||||
$OPENSSL x509 -req -in creq.pem -CA intca.pem -CAkey intkey.pem -days 3600 \
|
|
||||||
-extfile apps.cnf -extensions usr_cert -CAcreateserial | \
|
|
||||||
$OPENSSL x509 -nameopt oneline -subject -issuer >client.pem
|
|
||||||
# Server certificate: request first
|
|
||||||
CN="Test Server Cert" $OPENSSL req -config apps.cnf -nodes \
|
|
||||||
-key skey.pem -out sreq.pem -new
|
|
||||||
# Sign using intermediate CA
|
|
||||||
$OPENSSL x509 -req -in sreq.pem -CA intca.pem -CAkey intkey.pem -days 3600 \
|
|
||||||
-extfile apps.cnf -extensions usr_cert -CAcreateserial | \
|
|
||||||
$OPENSSL x509 -nameopt oneline -subject -issuer >server.pem
|
|
||||||
# Server certificate #2: request first
|
|
||||||
CN="Test Server Cert #2" $OPENSSL req -config apps.cnf -nodes \
|
|
||||||
-key skey2.pem -out sreq2.pem -new
|
|
||||||
# Sign using intermediate CA
|
|
||||||
$OPENSSL x509 -req -in sreq2.pem -CA intca.pem -CAkey intkey.pem -days 3600 \
|
|
||||||
-extfile apps.cnf -extensions usr_cert -CAcreateserial | \
|
|
||||||
$OPENSSL x509 -nameopt oneline -subject -issuer >server2.pem
|
|
||||||
|
|
||||||
# Append keys to file.
|
|
||||||
|
|
||||||
cat skey.pem >>server.pem
|
|
||||||
cat skey2.pem >>server2.pem
|
|
||||||
cat ckey.pem >>client.pem
|
|
||||||
|
|
||||||
$OPENSSL verify -CAfile root.pem -untrusted intca.pem \
|
|
||||||
server2.pem server.pem client.pem
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
# Quick instruction:
|
|
||||||
# To build against an OpenSSL built in the source tree, do this:
|
|
||||||
#
|
|
||||||
# make OPENSSL_INCS_LOCATION=-I../../include OPENSSL_LIBS_LOCATION=-L../..
|
|
||||||
#
|
|
||||||
# To run the demos when linked with a shared library (default):
|
|
||||||
#
|
|
||||||
# LD_LIBRARY_PATH=../.. ./aesccm
|
|
||||||
# LD_LIBRARY_PATH=../.. ./aesgcm
|
|
||||||
# LD_LIBRARY_PATH=../.. ./aeskeywrap
|
|
||||||
# LD_LIBRARY_PATH=../.. ./ariacbc
|
|
||||||
|
|
||||||
CFLAGS = $(OPENSSL_INCS_LOCATION)
|
|
||||||
LDFLAGS = $(OPENSSL_LIBS_LOCATION) -lssl -lcrypto
|
|
||||||
|
|
||||||
all: aesccm aesgcm aeskeywrap ariacbc
|
|
||||||
|
|
||||||
aesccm: aesccm.o
|
|
||||||
aesgcm: aesgcm.o
|
|
||||||
aeskeywrap: aeskeywrap.o
|
|
||||||
ariacbc: ariacbc.o
|
|
||||||
|
|
||||||
aesccm aesgcm aeskeywrap ariacbc:
|
|
||||||
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) aesccm aesgcm aeskeywrap ariacbc *.o
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#
|
|
||||||
# To run the demos when linked with a shared library (default):
|
|
||||||
#
|
|
||||||
# LD_LIBRARY_PATH=../.. ./EVP_MD_demo
|
|
||||||
|
|
||||||
CFLAGS = -I../../include -g -Wall
|
|
||||||
LDFLAGS = -L../..
|
|
||||||
LDLIBS = -lcrypto
|
|
||||||
|
|
||||||
all: EVP_MD_demo EVP_MD_stdin EVP_MD_xof BIO_f_md
|
|
||||||
|
|
||||||
%.o: %.c
|
|
||||||
$(CC) $(CFLAGS) -c $<
|
|
||||||
|
|
||||||
EVP_MD_demo: EVP_MD_demo.o
|
|
||||||
EVP_MD_stdin: EVP_MD_stdin.o
|
|
||||||
EVP_MD_xof: EVP_MD_xof.o
|
|
||||||
BIO_f_md: BIO_f_md.o
|
|
||||||
|
|
||||||
test: ;
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) *.o EVP_MD_demo EVP_MD_stdin EVP_MD_xof BIO_f_md
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#
|
|
||||||
# To run the demos when linked with a shared library (default):
|
|
||||||
#
|
|
||||||
# LD_LIBRARY_PATH=../.. ./rsa_encode
|
|
||||||
|
|
||||||
CFLAGS = -I../../include -g -Wall
|
|
||||||
LDFLAGS = -L../..
|
|
||||||
LDLIBS = -lcrypto
|
|
||||||
|
|
||||||
all: ec_encode rsa_encode
|
|
||||||
|
|
||||||
%.o: %.c
|
|
||||||
$(CC) $(CFLAGS) -c $<
|
|
||||||
|
|
||||||
%_encode: %_encode.o
|
|
||||||
|
|
||||||
test: ;
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) *.o rsa_encode ec_encode
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#
|
|
||||||
# To run the demos when linked with a shared library (default):
|
|
||||||
#
|
|
||||||
# LD_LIBRARY_PATH=../.. ./rsa_encrypt
|
|
||||||
|
|
||||||
CFLAGS = -I../../include -g
|
|
||||||
LDFLAGS = -L../..
|
|
||||||
LDLIBS = -lcrypto
|
|
||||||
|
|
||||||
all: rsa_encrypt
|
|
||||||
|
|
||||||
%.o: %.c
|
|
||||||
$(CC) $(CFLAGS) -c $<
|
|
||||||
|
|
||||||
rsa_encrypt: rsa_encrypt.o
|
|
||||||
|
|
||||||
test: ;
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) *.o rsa_encrypt
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#
|
|
||||||
# To run the demos when linked with a shared library (default):
|
|
||||||
#
|
|
||||||
# LD_LIBRARY_PATH=../.. ./hkdf
|
|
||||||
|
|
||||||
CFLAGS = -I../../include -g
|
|
||||||
LDFLAGS = -L../..
|
|
||||||
LDLIBS = -lcrypto
|
|
||||||
|
|
||||||
all: hkdf pbkdf2 scrypt
|
|
||||||
|
|
||||||
%.o: %.c
|
|
||||||
$(CC) $(CFLAGS) -c $<
|
|
||||||
|
|
||||||
hkdf: hkdf.o
|
|
||||||
pbkdf2: pbkdf2.o
|
|
||||||
scrypt: scrypt.o
|
|
||||||
|
|
||||||
test: ;
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) *.o hkdf pbkdf2 scrypt
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
# Quick instruction:
|
|
||||||
# To build against an OpenSSL built in the source tree, do this:
|
|
||||||
#
|
|
||||||
# make OPENSSL_INCS_LOCATION=-I../../include OPENSSL_LIBS_LOCATION=-L../..
|
|
||||||
#
|
|
||||||
# To run the demos when linked with a shared library (default):
|
|
||||||
#
|
|
||||||
# LD_LIBRARY_PATH=../.. ./gmac
|
|
||||||
# LD_LIBRARY_PATH=../.. ./poly1305
|
|
||||||
|
|
||||||
CFLAGS = $(OPENSSL_INCS_LOCATION) -Wall
|
|
||||||
LDFLAGS = $(OPENSSL_LIBS_LOCATION) -lssl -lcrypto
|
|
||||||
|
|
||||||
all: gmac hmac-sha512 cmac-aes256 poly1305
|
|
||||||
|
|
||||||
gmac: gmac.o
|
|
||||||
hmac-sha512: hmac-sha512.o
|
|
||||||
cmac-aes256: cmac-aes256.o
|
|
||||||
poly1305: poly1305.o
|
|
||||||
|
|
||||||
gmac hmac-sha512 cmac-aes256 poly1305:
|
|
||||||
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) gmac hmac-sha512 cmac-aes256 poly1305 *.o
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
#
|
|
||||||
# To run the demos when linked with a shared library (default):
|
|
||||||
#
|
|
||||||
# LD_LIBRARY_PATH=../.. ./EVP_PKEY_EC_keygen
|
|
||||||
# LD_LIBRARY_PATH=../.. ./EVP_PKEY_RSA_keygen
|
|
||||||
# LD_LIBRARY_PATH=../.. ./EVP_PKEY_DSA_keygen
|
|
||||||
# LD_LIBRARY_PATH=../.. ./EVP_PKEY_DSA_paramgen
|
|
||||||
# LD_LIBRARY_PATH=../.. ./EVP_PKEY_DSA_paramvalidate
|
|
||||||
# LD_LIBRARY_PATH=../.. ./EVP_PKEY_DSA_paramfromdata
|
|
||||||
|
|
||||||
CFLAGS = -I../../include -g -Wall
|
|
||||||
LDFLAGS = -L../..
|
|
||||||
LDLIBS = -lcrypto
|
|
||||||
|
|
||||||
all: EVP_PKEY_EC_keygen EVP_PKEY_RSA_keygen EVP_PKEY_DSA_keygen \
|
|
||||||
EVP_PKEY_DSA_paramgen EVP_PKEY_DSA_paramvalidate EVP_PKEY_DSA_paramfromdata \
|
|
||||||
|
|
||||||
%.o: %.c dsa.inc
|
|
||||||
$(CC) $(CFLAGS) -c $<
|
|
||||||
|
|
||||||
EVP_PKEY_EC_keygen: EVP_PKEY_EC_keygen.o
|
|
||||||
|
|
||||||
EVP_PKEY_RSA_keygen: EVP_PKEY_RSA_keygen.o
|
|
||||||
|
|
||||||
EVP_PKEY_DSA_keygen: EVP_PKEY_DSA_keygen.o
|
|
||||||
|
|
||||||
EVP_PKEY_DSA_paramgen: EVP_PKEY_DSA_paramgen.o
|
|
||||||
|
|
||||||
EVP_PKEY_DSA_paramvalidate: EVP_PKEY_DSA_paramvalidate.o
|
|
||||||
|
|
||||||
EVP_PKEY_DSA_paramfromdata: EVP_PKEY_DSA_paramfromdata.o
|
|
||||||
|
|
||||||
test: ;
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) *.o EVP_PKEY_EC_keygen EVP_PKEY_RSA_keygen EVP_PKEY_DSA_keygen \
|
|
||||||
EVP_PKEY_DSA_paramgen EVP_PKEY_DSA_paramfromdata EVP_PKEY_DSA_paramvalidate
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#
|
|
||||||
# To run the demos when linked with a shared library (default):
|
|
||||||
#
|
|
||||||
# LD_LIBRARY_PATH=../.. ./EVP_Signature_demo
|
|
||||||
|
|
||||||
CFLAGS = -I../../include -g -Wall
|
|
||||||
LDFLAGS = -L../..
|
|
||||||
LDLIBS = -lcrypto
|
|
||||||
|
|
||||||
all: EVP_EC_Signature_demo EVP_DSA_Signature_demo rsa_pss_direct rsa_pss_hash
|
|
||||||
|
|
||||||
%.o: %.c
|
|
||||||
$(CC) $(CFLAGS) -c $<
|
|
||||||
|
|
||||||
EVP_EC_Signature_demo: EVP_EC_Signature_demo.o
|
|
||||||
EVP_DSA_Signature_demo: EVP_DSA_Signature_demo.o
|
|
||||||
rsa_pss_direct: rsa_pss_direct.o
|
|
||||||
rsa_pss_hash: rsa_pss_hash.o
|
|
||||||
|
|
||||||
test: ;
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) *.o EVP_EC_Signature_demo EVP_DSA_Signature_demo rsa_pss_direct rsa_pss_hash
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
PROG ?= sslecho
|
|
||||||
|
|
||||||
all: $(PROG)
|
|
||||||
|
|
||||||
# Debug version.
|
|
||||||
#
|
|
||||||
$(PROG): main.c
|
|
||||||
|
|
||||||
$(CC) -O0 -g3 -W -Wall -I../../include -L../../ -o $(PROG) main.c -lssl -lcrypto
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf $(PROG) *.o *.obj
|
|
||||||
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 76 KiB |
@@ -1,49 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Generator: Adobe Illustrator 28.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
||||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
||||||
viewBox="0 0 510 510" style="enable-background:new 0 0 510 510;" xml:space="preserve">
|
|
||||||
<style type="text/css">
|
|
||||||
.st0{fill:#231F20;}
|
|
||||||
.st1{fill:#6D2520;}
|
|
||||||
</style>
|
|
||||||
<g id="Layer_1">
|
|
||||||
</g>
|
|
||||||
<g id="Layer_2">
|
|
||||||
<g>
|
|
||||||
<path class="st0" d="M256.2,289c-5.2,0-9.3,1-12.1,3.1c-2.9,2.1-4.3,5.2-4.3,9.3c0,3.8,2.1,7.1,6.3,10c4.2,2.9,9.8,5.6,16.7,8.2
|
|
||||||
c5.7,2.1,10.5,4.4,14.5,7.1c4,2.7,7.4,6.3,10,11c2.7,4.7,4,10.6,4,17.8c0,6.2-1.6,11.9-4.8,17.2c-3.2,5.3-7.9,9.5-14.1,12.6
|
|
||||||
c-6.2,3.1-13.6,4.6-22.2,4.6c-7.2,0-14.3-1.1-21.4-3.2c-7.1-2.1-13.6-5.4-19.7-9.7l10.4-18.4c4.1,3,8.9,5.5,14.2,7.5
|
|
||||||
c5.3,2,10.1,2.9,14.4,2.9c5,0,9.4-1.1,13-3.2s5.5-5.6,5.5-10.4c0-6.2-5.8-11.6-17.4-16.1c-6.8-2.7-12.6-5.3-17.1-7.8
|
|
||||||
c-4.6-2.5-8.5-6.1-11.8-10.8c-3.3-4.7-5-10.5-5-17.6c0-10.3,3.4-18.6,10.2-25c6.8-6.3,15.8-9.7,27.2-10.3c8.9,0,16.4,1,22.3,3
|
|
||||||
c6,2,11.8,4.9,17.4,8.6l-9,18.1C273,291.9,263.9,289,256.2,289z"/>
|
|
||||||
<path class="st0" d="M351.3,289c-5.2,0-9.3,1-12.1,3.1c-2.9,2.1-4.3,5.2-4.3,9.3c0,3.8,2.1,7.1,6.3,10c4.2,2.9,9.8,5.6,16.7,8.2
|
|
||||||
c5.7,2.1,10.5,4.4,14.5,7.1c4,2.7,7.4,6.3,10,11c2.7,4.7,4,10.6,4,17.8c0,6.2-1.6,11.9-4.8,17.2c-3.2,5.3-7.9,9.5-14.1,12.6
|
|
||||||
c-6.2,3.1-13.6,4.6-22.2,4.6c-7.2,0-14.3-1.1-21.4-3.2c-7.1-2.1-13.6-5.4-19.7-9.7l10.4-18.4c4.1,3,8.9,5.5,14.2,7.5
|
|
||||||
c5.3,2,10.1,2.9,14.4,2.9c5,0,9.4-1.1,13-3.2s5.5-5.6,5.5-10.4c0-6.2-5.8-11.6-17.4-16.1c-6.8-2.7-12.6-5.3-17.1-7.8
|
|
||||||
c-4.6-2.5-8.5-6.1-11.8-10.8c-3.3-4.7-5-10.5-5-17.6c0-10.3,3.4-18.6,10.2-25c6.8-6.3,15.8-9.7,27.2-10.3c8.9,0,16.4,1,22.3,3
|
|
||||||
c6,2,11.8,4.9,17.4,8.6l-9,18.1C368.1,291.9,359,289,351.3,289z"/>
|
|
||||||
<path class="st0" d="M433.2,268.7v97.2h56.4v22.8h-80.1v-120H433.2z"/>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
<path class="st1" d="M27.5,147.3c5.6-9.5,13-17,22.4-22.6s19.7-8.4,30.8-8.4c11,0,21.2,2.8,30.7,8.4c9.4,5.6,17,13.1,22.6,22.6
|
|
||||||
c5.6,9.5,8.4,19.7,8.4,30.7c0,11.1-2.8,21.4-8.3,30.9s-13.1,16.9-22.6,22.4c-9.5,5.5-19.8,8.3-30.8,8.3c-11.1,0-21.4-2.7-30.9-8.2
|
|
||||||
c-9.5-5.4-16.9-12.9-22.4-22.3c-5.5-9.4-8.3-19.8-8.3-31.1C19.1,167,21.9,156.8,27.5,147.3z M41.8,201c4,7,9.5,12.6,16.4,16.7
|
|
||||||
s14.5,6.2,22.8,6.2c8.2,0,15.8-2,22.6-6.1c6.8-4.1,12.2-9.6,16.2-16.7c3.9-7.1,5.9-14.8,5.9-23.1c0-8.3-2-16.1-6-23.2
|
|
||||||
c-4-7.1-9.5-12.7-16.3-16.8c-6.9-4.1-14.5-6.2-22.7-6.2s-15.8,2.1-22.7,6.3c-6.9,4.2-12.3,9.8-16.3,16.9
|
|
||||||
c-3.9,7.1-5.9,14.8-5.9,23.2C35.8,186.4,37.8,194,41.8,201z"/>
|
|
||||||
<path class="st1" d="M215.1,171c5.2,3.1,9.3,7.5,12.3,13.1c3,5.6,4.5,12.1,4.5,19.4c0,7.2-1.6,13.6-4.8,19.1
|
|
||||||
c-3.2,5.5-7.7,9.8-13.3,12.8c-5.7,3-12,4.5-19,4.5c-5,0-9.8-1.1-14.3-3.3c-4.6-2.2-8.2-5.1-11-8.8v43.5h-15.5V168h13.5l1.3,11.7
|
|
||||||
c3.6-4,7.8-7.2,12.8-9.7c4.9-2.4,10.3-3.7,16.1-3.7C204,166.3,209.8,167.9,215.1,171z M203.8,224.3c3.7-2.1,6.7-4.9,8.9-8.5
|
|
||||||
c2.2-3.6,3.3-7.6,3.3-12.1c0-4.6-1-8.7-3.1-12.3c-2.1-3.7-4.9-6.6-8.4-8.7c-3.6-2.1-7.5-3.2-11.8-3.2c-5.9,0-10.9,1.6-15.1,4.9
|
|
||||||
s-6.9,7.7-8.3,13.3v11.5c0.9,5.3,3.4,9.7,7.6,13.1c4.2,3.4,9.1,5.1,14.8,5.1C196,227.4,200.1,226.4,203.8,224.3z"/>
|
|
||||||
<path class="st1" d="M384.1,172.3c4.2,3.8,6.4,8.8,6.5,14.9v51h-15.7v-45.7c-0.2-3.9-1.4-6.9-3.5-9.2c-2.1-2.2-5.3-3.4-9.5-3.5
|
|
||||||
c-6.1,0-11.2,2.4-15.2,7.3c-4,4.9-6,11.1-6,18.7v32.4h-15.5v-69.1h14l1,13.3c2.4-5,6.1-8.9,11-11.8c4.9-2.8,10.5-4.3,16.8-4.3
|
|
||||||
C374.5,166.5,379.9,168.4,384.1,172.3z"/>
|
|
||||||
<g>
|
|
||||||
<path class="st1" d="M242.5,203.4c0-21.3,16.2-38.1,36.9-38.1c20.3,0,35.6,16.9,35.6,38.8v4.1h-58c2,12.2,12,21.1,24.7,21.1
|
|
||||||
c7.2,0,14-2.3,18.7-6.5l9.3,9.1c-8.7,6.7-17.5,9.7-28.5,9.7C259.4,241.6,242.5,224.9,242.5,203.4z M300.7,197.3
|
|
||||||
c-2-11.3-10.9-19.7-21.6-19.7c-11.1,0-20,8-22,19.7H300.7z"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 3.7 KiB |
@@ -1,49 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Generator: Adobe Illustrator 28.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
||||||
<svg version="1.1"
|
|
||||||
id="svg2" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/"
|
|
||||||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 779 199.2"
|
|
||||||
style="enable-background:new 0 0 779 199.2;" xml:space="preserve">
|
|
||||||
<style type="text/css">
|
|
||||||
.st0{fill:#231F20;}
|
|
||||||
.st1{fill:#6D2520;}
|
|
||||||
</style>
|
|
||||||
<g>
|
|
||||||
<g>
|
|
||||||
<path class="st0" d="M457.3,48.3c-4.9,0-8.7,1-11.4,2.9c-2.7,1.9-4.1,4.9-4.1,8.7c0,3.6,2,6.7,5.9,9.4c3.9,2.7,9.2,5.3,15.7,7.7
|
|
||||||
c5.3,1.9,9.9,4.2,13.7,6.7c3.8,2.5,6.9,6,9.4,10.4c2.5,4.4,3.8,10,3.8,16.7c0,5.8-1.5,11.2-4.5,16.2c-3,5-7.4,8.9-13.3,11.8
|
|
||||||
c-5.8,2.9-12.8,4.4-20.9,4.4c-6.7,0-13.4-1-20.1-3c-6.6-2-12.8-5-18.6-9.1l9.8-17.3c3.9,2.9,8.3,5.2,13.3,7.1
|
|
||||||
c5,1.8,9.5,2.8,13.5,2.8c4.7,0,8.8-1,12.3-3c3.5-2,5.2-5.2,5.2-9.7c0-5.8-5.5-10.9-16.4-15.2c-6.4-2.6-11.8-5-16.1-7.4
|
|
||||||
c-4.3-2.3-8-5.7-11.1-10.1c-3.1-4.4-4.7-9.9-4.7-16.6c0-9.7,3.2-17.5,9.6-23.5c6.4-5.9,14.9-9.2,25.5-9.7c8.4,0,15.4,0.9,21,2.8
|
|
||||||
c5.6,1.9,11.1,4.6,16.4,8.1l-8.4,17C473.1,51,464.6,48.3,457.3,48.3z"/>
|
|
||||||
<path class="st0" d="M546.8,48.3c-4.9,0-8.7,1-11.4,2.9c-2.7,1.9-4.1,4.9-4.1,8.7c0,3.6,2,6.7,5.9,9.4c3.9,2.7,9.2,5.3,15.7,7.7
|
|
||||||
c5.3,1.9,9.9,4.2,13.7,6.7c3.8,2.5,6.9,6,9.4,10.4c2.5,4.4,3.8,10,3.8,16.7c0,5.8-1.5,11.2-4.5,16.2c-3,5-7.4,8.9-13.3,11.8
|
|
||||||
c-5.8,2.9-12.8,4.4-20.9,4.4c-6.7,0-13.4-1-20.1-3s-12.8-5-18.6-9.1l9.8-17.3c3.9,2.9,8.3,5.2,13.3,7.1s9.5,2.8,13.5,2.8
|
|
||||||
c4.7,0,8.8-1,12.3-3s5.2-5.2,5.2-9.7c0-5.8-5.5-10.9-16.4-15.2c-6.4-2.6-11.8-5-16.1-7.4c-4.3-2.3-8-5.7-11.1-10.1
|
|
||||||
c-3.1-4.4-4.7-9.9-4.7-16.6c0-9.7,3.2-17.5,9.6-23.5c6.4-5.9,14.9-9.2,25.5-9.7c8.4,0,15.4,0.9,21,2.8c5.6,1.9,11.1,4.6,16.4,8.1
|
|
||||||
l-8.4,17C562.6,51,554,48.3,546.8,48.3z"/>
|
|
||||||
<path class="st0" d="M623.8,29.1v91.4h53.1V142h-75.3V29.1H623.8z"/>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
<path class="st1" d="M61.9,58.4c5.1-8.7,12-15.6,20.6-20.8s18.1-7.7,28.3-7.7c10.1,0,19.5,2.6,28.2,7.7
|
|
||||||
c8.7,5.2,15.6,12.1,20.8,20.8c5.2,8.7,7.7,18.1,7.7,28.2c0,10.2-2.6,19.7-7.7,28.4c-5.1,8.7-12,15.6-20.8,20.6
|
|
||||||
c-8.7,5.1-18.2,7.6-28.3,7.6c-10.2,0-19.7-2.5-28.4-7.5c-8.7-5-15.6-11.8-20.6-20.5c-5.1-8.6-7.6-18.2-7.6-28.6
|
|
||||||
C54.2,76.5,56.8,67.1,61.9,58.4z M75.1,107.8c3.7,6.4,8.7,11.6,15.1,15.3c6.4,3.8,13.4,5.7,20.9,5.7c7.6,0,14.5-1.9,20.8-5.6
|
|
||||||
c6.3-3.7,11.2-8.8,14.9-15.3c3.6-6.5,5.4-13.6,5.4-21.2c0-7.7-1.8-14.8-5.5-21.3s-8.7-11.7-15-15.5c-6.3-3.8-13.3-5.7-20.9-5.7
|
|
||||||
c-7.6,0-14.5,1.9-20.9,5.8c-6.3,3.8-11.3,9-15,15.6s-5.4,13.7-5.4,21.3C69.6,94.4,71.4,101.4,75.1,107.8z"/>
|
|
||||||
<path class="st1" d="M234.4,80.2c4.8,2.9,8.6,6.9,11.3,12c2.8,5.2,4.1,11.1,4.1,17.9c0,6.7-1.5,12.5-4.5,17.6
|
|
||||||
c-3,5.1-7.1,9-12.3,11.7c-5.2,2.8-11,4.1-17.5,4.1c-4.6,0-9-1-13.2-3c-4.2-2-7.6-4.7-10.1-8.1v40h-14.3V77.5h12.4l1.2,10.7
|
|
||||||
c3.3-3.7,7.2-6.6,11.7-8.9c4.5-2.3,9.5-3.4,14.8-3.4C224.2,75.9,229.6,77.4,234.4,80.2z M224,129.2c3.4-1.9,6.2-4.5,8.2-7.8
|
|
||||||
c2-3.3,3.1-7,3.1-11.1c0-4.2-0.9-8-2.8-11.3c-1.9-3.4-4.5-6-7.7-8c-3.3-1.9-6.9-2.9-10.9-2.9c-5.4,0-10,1.5-13.9,4.5
|
|
||||||
c-3.8,3-6.4,7.1-7.6,12.2v10.6c0.8,4.9,3.1,8.9,7,12c3.8,3.1,8.4,4.7,13.6,4.7C216.9,132.1,220.6,131.1,224,129.2z"/>
|
|
||||||
<path class="st1" d="M389.8,81.4c3.9,3.5,5.9,8.1,6,13.7V142h-14.4v-42c-0.2-3.6-1.3-6.4-3.2-8.4c-1.9-2-4.9-3.1-8.7-3.2
|
|
||||||
c-5.6,0-10.3,2.3-14,6.7c-3.7,4.5-5.5,10.2-5.5,17.2V142h-14.3V78.5h12.9l0.9,12.3c2.2-4.6,5.6-8.2,10.1-10.8
|
|
||||||
c4.5-2.6,9.7-3.9,15.5-3.9C381,76.1,386,77.8,389.8,81.4z"/>
|
|
||||||
<g>
|
|
||||||
<path class="st1" d="M259.6,110c0-19.6,14.9-35,33.9-35c18.6,0,32.7,15.6,32.7,35.7v3.7h-53.4c1.9,11.2,11,19.4,22.8,19.4
|
|
||||||
c6.7,0,12.9-2.1,17.2-6l8.5,8.4c-8,6.1-16.1,8.9-26.2,8.9C275.2,145.1,259.6,129.8,259.6,110z M313.1,104.4
|
|
||||||
c-1.9-10.4-10-18.1-19.8-18.1c-10.2,0-18.4,7.3-20.2,18.1H313.1z"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 3.8 KiB |
-49
@@ -1,49 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
CMS_EncryptedData_decrypt
|
|
||||||
- Decrypt CMS EncryptedData
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
#include <openssl/cms.h>
|
|
||||||
|
|
||||||
int CMS_EncryptedData_decrypt(CMS_ContentInfo *cms,
|
|
||||||
const unsigned char *key, size_t keylen,
|
|
||||||
BIO *dcont, BIO *out, unsigned int flags);
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
CMS_EncryptedData_decrypt() decrypts a I<cms> EncryptedData object using the
|
|
||||||
symmetric I<key> of size I<keylen> bytes. I<out> is a BIO to write the content
|
|
||||||
to and I<flags> is an optional set of flags.
|
|
||||||
I<dcont> is used in the rare case where the encrypted content is detached. It
|
|
||||||
will normally be set to NULL.
|
|
||||||
|
|
||||||
The following flags can be passed in the I<flags> parameter.
|
|
||||||
|
|
||||||
If the B<CMS_TEXT> flag is set MIME headers for type C<text/plain> are deleted
|
|
||||||
from the content. If the content is not of type C<text/plain> then an error is
|
|
||||||
returned.
|
|
||||||
|
|
||||||
=head1 RETURN VALUES
|
|
||||||
|
|
||||||
CMS_EncryptedData_decrypt() returns 0 if an error occurred otherwise it
|
|
||||||
returns 1.
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
L<ERR_get_error(3)>, L<CMS_EncryptedData_encrypt(3)>
|
|
||||||
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2020-2023 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
-101
@@ -1,101 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
EVP_PKEY_decapsulate_init, EVP_PKEY_decapsulate
|
|
||||||
- Key decapsulation using a KEM algorithm with a private key
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
|
|
||||||
int EVP_PKEY_decapsulate_init(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]);
|
|
||||||
int EVP_PKEY_decapsulate(EVP_PKEY_CTX *ctx,
|
|
||||||
unsigned char *unwrapped, size_t *unwrappedlen,
|
|
||||||
const unsigned char *wrapped, size_t wrappedlen);
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
The EVP_PKEY_decapsulate_init() function initializes a private key algorithm
|
|
||||||
context I<ctx> for a decapsulation operation and then sets the I<params>
|
|
||||||
on the context in the same way as calling L<EVP_PKEY_CTX_set_params(3)>.
|
|
||||||
Note that I<ctx> usually is produced using L<EVP_PKEY_CTX_new_from_pkey(3)>,
|
|
||||||
specifying the private key to use.
|
|
||||||
|
|
||||||
The EVP_PKEY_decapsulate() function performs a private key decapsulation
|
|
||||||
operation using I<ctx>. The data to be decapsulated is specified using the
|
|
||||||
I<wrapped> and I<wrappedlen> parameters.
|
|
||||||
If I<unwrapped> is NULL then the maximum size of the output secret buffer
|
|
||||||
is written to I<*unwrappedlen>. If I<unwrapped> is not NULL and the
|
|
||||||
call is successful then the decapsulated secret data is written to I<unwrapped>
|
|
||||||
and the amount of data written to I<*unwrappedlen>.
|
|
||||||
|
|
||||||
=head1 NOTES
|
|
||||||
|
|
||||||
After the call to EVP_PKEY_decapsulate_init() algorithm-specific parameters
|
|
||||||
for the operation may be set or modified using L<EVP_PKEY_CTX_set_params(3)>.
|
|
||||||
|
|
||||||
=head1 RETURN VALUES
|
|
||||||
|
|
||||||
EVP_PKEY_decapsulate_init() and EVP_PKEY_decapsulate() return 1 for
|
|
||||||
success and 0 or a negative value for failure. In particular a return value of -2
|
|
||||||
indicates the operation is not supported by the private key algorithm.
|
|
||||||
|
|
||||||
=head1 EXAMPLES
|
|
||||||
|
|
||||||
Decapsulate data using RSA:
|
|
||||||
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NB: assumes rsa_priv_key is an RSA private key,
|
|
||||||
* and that in, inlen are already set up to contain encapsulated data.
|
|
||||||
*/
|
|
||||||
|
|
||||||
EVP_PKEY_CTX *ctx = NULL;
|
|
||||||
size_t secretlen = 0;
|
|
||||||
unsigned char *secret = NULL;;
|
|
||||||
|
|
||||||
ctx = EVP_PKEY_CTX_new_from_pkey(libctx, rsa_priv_key, NULL);
|
|
||||||
if (ctx = NULL)
|
|
||||||
/* Error */
|
|
||||||
if (EVP_PKEY_decapsulate_init(ctx, NULL) <= 0)
|
|
||||||
/* Error */
|
|
||||||
|
|
||||||
/* Set the mode - only 'RSASVE' is currently supported */
|
|
||||||
if (EVP_PKEY_CTX_set_kem_op(ctx, "RSASVE") <= 0)
|
|
||||||
/* Error */
|
|
||||||
|
|
||||||
/* Determine buffer length */
|
|
||||||
if (EVP_PKEY_decapsulate(ctx, NULL, &secretlen, in, inlen) <= 0)
|
|
||||||
/* Error */
|
|
||||||
|
|
||||||
secret = OPENSSL_malloc(secretlen);
|
|
||||||
if (secret == NULL)
|
|
||||||
/* malloc failure */
|
|
||||||
|
|
||||||
/* Decapsulated secret data is secretlen bytes long */
|
|
||||||
if (EVP_PKEY_decapsulaterctx, secret, &secretlen, in, inlen) <= 0)
|
|
||||||
/* Error */
|
|
||||||
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
L<EVP_PKEY_CTX_new_from_pkey(3)>,
|
|
||||||
L<EVP_PKEY_encapsulate(3)>,
|
|
||||||
L<EVP_KEM-RSA(7)>,
|
|
||||||
|
|
||||||
=head1 HISTORY
|
|
||||||
|
|
||||||
These functions were added in OpenSSL 3.0.
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2020-2023 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
-110
@@ -1,110 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
EVP_PKEY_encapsulate_init, EVP_PKEY_encapsulate
|
|
||||||
- Key encapsulation using a KEM algorithm with a public key
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
|
|
||||||
int EVP_PKEY_encapsulate_init(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]);
|
|
||||||
int EVP_PKEY_encapsulate(EVP_PKEY_CTX *ctx,
|
|
||||||
unsigned char *wrappedkey, size_t *wrappedkeylen,
|
|
||||||
unsigned char *genkey, size_t *genkeylen);
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
The EVP_PKEY_encapsulate_init() function initializes a public key algorithm
|
|
||||||
context I<ctx> for an encapsulation operation and then sets the I<params>
|
|
||||||
on the context in the same way as calling L<EVP_PKEY_CTX_set_params(3)>.
|
|
||||||
Note that I<ctx> is usually is produced using L<EVP_PKEY_CTX_new_from_pkey(3)>,
|
|
||||||
specifying the public key to use.
|
|
||||||
|
|
||||||
The EVP_PKEY_encapsulate() function performs a public key encapsulation
|
|
||||||
operation using I<ctx>.
|
|
||||||
The symmetric secret generated in I<genkey> can be used as key material.
|
|
||||||
The ciphertext in I<wrappedkey> is its encapsulated form, which can be sent
|
|
||||||
to another party, who can use L<EVP_PKEY_decapsulate(3)> to retrieve it
|
|
||||||
using their private key.
|
|
||||||
If I<wrappedkey> is NULL then the maximum size of the output buffer
|
|
||||||
is written to the I<*wrappedkeylen> parameter unless I<wrappedkeylen> is NULL
|
|
||||||
and the maximum size of the generated key buffer is written to I<*genkeylen>
|
|
||||||
unless I<genkeylen> is NULL.
|
|
||||||
If I<wrappedkey> is not NULL and the call is successful then the
|
|
||||||
internally generated key is written to I<genkey> and its size is written to
|
|
||||||
I<*genkeylen>. The encapsulated version of the generated key is written to
|
|
||||||
I<wrappedkey> and its size is written to I<*wrappedkeylen>.
|
|
||||||
|
|
||||||
=head1 NOTES
|
|
||||||
|
|
||||||
After the call to EVP_PKEY_encapsulate_init() algorithm-specific parameters
|
|
||||||
for the operation may be set or modified using L<EVP_PKEY_CTX_set_params(3)>.
|
|
||||||
|
|
||||||
=head1 RETURN VALUES
|
|
||||||
|
|
||||||
EVP_PKEY_encapsulate_init() and EVP_PKEY_encapsulate() return 1 for
|
|
||||||
success and 0 or a negative value for failure. In particular a return value of -2
|
|
||||||
indicates the operation is not supported by the public key algorithm.
|
|
||||||
|
|
||||||
=head1 EXAMPLES
|
|
||||||
|
|
||||||
Encapsulate an RSASVE key (for RSA keys).
|
|
||||||
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NB: assumes rsa_pub_key is an public key of another party.
|
|
||||||
*/
|
|
||||||
|
|
||||||
EVP_PKEY_CTX *ctx = NULL;
|
|
||||||
size_t secretlen = 0, outlen = 0;
|
|
||||||
unsigned char *out = NULL, *secret = NULL;
|
|
||||||
|
|
||||||
ctx = EVP_PKEY_CTX_new_from_pkey(libctx, rsa_pub_key, NULL);
|
|
||||||
if (ctx = NULL)
|
|
||||||
/* Error */
|
|
||||||
if (EVP_PKEY_encapsulate_init(ctx, NULL) <= 0)
|
|
||||||
/* Error */
|
|
||||||
|
|
||||||
/* Set the mode - only 'RSASVE' is currently supported */
|
|
||||||
if (EVP_PKEY_CTX_set_kem_op(ctx, "RSASVE") <= 0)
|
|
||||||
/* Error */
|
|
||||||
/* Determine buffer length */
|
|
||||||
if (EVP_PKEY_encapsulate(ctx, NULL, &outlen, NULL, &secretlen) <= 0)
|
|
||||||
/* Error */
|
|
||||||
|
|
||||||
out = OPENSSL_malloc(outlen);
|
|
||||||
secret = OPENSSL_malloc(secretlen);
|
|
||||||
if (out == NULL || secret == NULL)
|
|
||||||
/* malloc failure */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The generated 'secret' can be used as key material.
|
|
||||||
* The encapsulated 'out' can be sent to another party who can
|
|
||||||
* decapsulate it using their private key to retrieve the 'secret'.
|
|
||||||
*/
|
|
||||||
if (EVP_PKEY_encapsulate(ctx, out, &outlen, secret, &secretlen) <= 0)
|
|
||||||
/* Error */
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
L<EVP_PKEY_CTX_new_from_pkey(3)>,
|
|
||||||
L<EVP_PKEY_decapsulate(3)>,
|
|
||||||
L<EVP_KEM-RSA(7)>,
|
|
||||||
|
|
||||||
=head1 HISTORY
|
|
||||||
|
|
||||||
These functions were added in OpenSSL 3.0.
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2020-2023 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
EVP_PKEY_sign_init, EVP_PKEY_sign_init_ex, EVP_PKEY_sign
|
|
||||||
- sign using a public key algorithm
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
|
|
||||||
int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx);
|
|
||||||
int EVP_PKEY_sign_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]);
|
|
||||||
int EVP_PKEY_sign(EVP_PKEY_CTX *ctx,
|
|
||||||
unsigned char *sig, size_t *siglen,
|
|
||||||
const unsigned char *tbs, size_t tbslen);
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
EVP_PKEY_sign_init() initializes a public key algorithm context I<ctx> for
|
|
||||||
signing using the algorithm given when the context was created
|
|
||||||
using L<EVP_PKEY_CTX_new(3)> or variants thereof. The algorithm is used to
|
|
||||||
fetch a B<EVP_SIGNATURE> method implicitly, see L<provider(7)/Implicit fetch>
|
|
||||||
for more information about implicit fetches.
|
|
||||||
|
|
||||||
EVP_PKEY_sign_init_ex() is the same as EVP_PKEY_sign_init() but additionally
|
|
||||||
sets the passed parameters I<params> on the context before returning.
|
|
||||||
|
|
||||||
The EVP_PKEY_sign() function performs a public key signing operation
|
|
||||||
using I<ctx>. The data to be signed is specified using the I<tbs> and
|
|
||||||
I<tbslen> parameters. If I<sig> is NULL then the maximum size of the output
|
|
||||||
buffer is written to the I<siglen> parameter. If I<sig> is not NULL then
|
|
||||||
before the call the I<siglen> parameter should contain the length of the
|
|
||||||
I<sig> buffer, if the call is successful the signature is written to
|
|
||||||
I<sig> and the amount of data written to I<siglen>.
|
|
||||||
|
|
||||||
=head1 NOTES
|
|
||||||
|
|
||||||
EVP_PKEY_sign() does not hash the data to be signed, and therefore is
|
|
||||||
normally used to sign digests. For signing arbitrary messages, see the
|
|
||||||
L<EVP_DigestSignInit(3)> and
|
|
||||||
L<EVP_SignInit(3)> signing interfaces instead.
|
|
||||||
|
|
||||||
After the call to EVP_PKEY_sign_init() algorithm specific control
|
|
||||||
operations can be performed to set any appropriate parameters for the
|
|
||||||
operation (see L<EVP_PKEY_CTX_ctrl(3)>).
|
|
||||||
|
|
||||||
The function EVP_PKEY_sign() can be called more than once on the same
|
|
||||||
context if several operations are performed using the same parameters.
|
|
||||||
|
|
||||||
=head1 RETURN VALUES
|
|
||||||
|
|
||||||
EVP_PKEY_sign_init() and EVP_PKEY_sign() return 1 for success and 0
|
|
||||||
or a negative value for failure. In particular a return value of -2
|
|
||||||
indicates the operation is not supported by the public key algorithm.
|
|
||||||
|
|
||||||
=head1 EXAMPLES
|
|
||||||
|
|
||||||
Sign data using RSA with PKCS#1 padding and SHA256 digest:
|
|
||||||
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
#include <openssl/rsa.h>
|
|
||||||
|
|
||||||
EVP_PKEY_CTX *ctx;
|
|
||||||
/* md is a SHA-256 digest in this example. */
|
|
||||||
unsigned char *md, *sig;
|
|
||||||
size_t mdlen = 32, siglen;
|
|
||||||
EVP_PKEY *signing_key;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NB: assumes signing_key and md are set up before the next
|
|
||||||
* step. signing_key must be an RSA private key and md must
|
|
||||||
* point to the SHA-256 digest to be signed.
|
|
||||||
*/
|
|
||||||
ctx = EVP_PKEY_CTX_new(signing_key, NULL /* no engine */);
|
|
||||||
if (!ctx)
|
|
||||||
/* Error occurred */
|
|
||||||
if (EVP_PKEY_sign_init(ctx) <= 0)
|
|
||||||
/* Error */
|
|
||||||
if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0)
|
|
||||||
/* Error */
|
|
||||||
if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0)
|
|
||||||
/* Error */
|
|
||||||
|
|
||||||
/* Determine buffer length */
|
|
||||||
if (EVP_PKEY_sign(ctx, NULL, &siglen, md, mdlen) <= 0)
|
|
||||||
/* Error */
|
|
||||||
|
|
||||||
sig = OPENSSL_malloc(siglen);
|
|
||||||
|
|
||||||
if (!sig)
|
|
||||||
/* malloc failure */
|
|
||||||
|
|
||||||
if (EVP_PKEY_sign(ctx, sig, &siglen, md, mdlen) <= 0)
|
|
||||||
/* Error */
|
|
||||||
|
|
||||||
/* Signature is siglen bytes written to buffer sig */
|
|
||||||
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
L<EVP_PKEY_CTX_new(3)>,
|
|
||||||
L<EVP_PKEY_CTX_ctrl(3)>,
|
|
||||||
L<EVP_PKEY_encrypt(3)>,
|
|
||||||
L<EVP_PKEY_decrypt(3)>,
|
|
||||||
L<EVP_PKEY_verify(3)>,
|
|
||||||
L<EVP_PKEY_verify_recover(3)>,
|
|
||||||
L<EVP_PKEY_derive(3)>
|
|
||||||
|
|
||||||
=head1 HISTORY
|
|
||||||
|
|
||||||
The EVP_PKEY_sign_init() and EVP_PKEY_sign() functions were added in
|
|
||||||
OpenSSL 1.0.0.
|
|
||||||
|
|
||||||
The EVP_PKEY_sign_init_ex() function was added in OpenSSL 3.0.
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2006-2021 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
EVP_PKEY_verify_init, EVP_PKEY_verify_init_ex, EVP_PKEY_verify
|
|
||||||
- signature verification using a public key algorithm
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
|
|
||||||
int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx);
|
|
||||||
int EVP_PKEY_verify_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]);
|
|
||||||
int EVP_PKEY_verify(EVP_PKEY_CTX *ctx,
|
|
||||||
const unsigned char *sig, size_t siglen,
|
|
||||||
const unsigned char *tbs, size_t tbslen);
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
EVP_PKEY_verify_init() initializes a public key algorithm context I<ctx> for
|
|
||||||
signing using the algorithm given when the context was created
|
|
||||||
using L<EVP_PKEY_CTX_new(3)> or variants thereof. The algorithm is used to
|
|
||||||
fetch a B<EVP_SIGNATURE> method implicitly, see L<provider(7)/Implicit fetch>
|
|
||||||
for more information about implicit fetches.
|
|
||||||
|
|
||||||
EVP_PKEY_verify_init_ex() is the same as EVP_PKEY_verify_init() but additionally
|
|
||||||
sets the passed parameters I<params> on the context before returning.
|
|
||||||
|
|
||||||
The EVP_PKEY_verify() function performs a public key verification operation
|
|
||||||
using I<ctx>. The signature is specified using the I<sig> and
|
|
||||||
I<siglen> parameters. The verified data (i.e. the data believed originally
|
|
||||||
signed) is specified using the I<tbs> and I<tbslen> parameters.
|
|
||||||
|
|
||||||
=head1 NOTES
|
|
||||||
|
|
||||||
After the call to EVP_PKEY_verify_init() algorithm specific control
|
|
||||||
operations can be performed to set any appropriate parameters for the
|
|
||||||
operation.
|
|
||||||
|
|
||||||
The function EVP_PKEY_verify() can be called more than once on the same
|
|
||||||
context if several operations are performed using the same parameters.
|
|
||||||
|
|
||||||
=head1 RETURN VALUES
|
|
||||||
|
|
||||||
EVP_PKEY_verify_init() and EVP_PKEY_verify() return 1 if the verification was
|
|
||||||
successful and 0 if it failed. Unlike other functions the return value 0 from
|
|
||||||
EVP_PKEY_verify() only indicates that the signature did not verify
|
|
||||||
successfully (that is tbs did not match the original data or the signature was
|
|
||||||
of invalid form) it is not an indication of a more serious error.
|
|
||||||
|
|
||||||
A negative value indicates an error other that signature verification failure.
|
|
||||||
In particular a return value of -2 indicates the operation is not supported by
|
|
||||||
the public key algorithm.
|
|
||||||
|
|
||||||
=head1 EXAMPLES
|
|
||||||
|
|
||||||
Verify signature using PKCS#1 and SHA256 digest:
|
|
||||||
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
#include <openssl/rsa.h>
|
|
||||||
|
|
||||||
EVP_PKEY_CTX *ctx;
|
|
||||||
unsigned char *md, *sig;
|
|
||||||
size_t mdlen, siglen;
|
|
||||||
EVP_PKEY *verify_key;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NB: assumes verify_key, sig, siglen md and mdlen are already set up
|
|
||||||
* and that verify_key is an RSA public key
|
|
||||||
*/
|
|
||||||
ctx = EVP_PKEY_CTX_new(verify_key, NULL /* no engine */);
|
|
||||||
if (!ctx)
|
|
||||||
/* Error occurred */
|
|
||||||
if (EVP_PKEY_verify_init(ctx) <= 0)
|
|
||||||
/* Error */
|
|
||||||
if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0)
|
|
||||||
/* Error */
|
|
||||||
if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0)
|
|
||||||
/* Error */
|
|
||||||
|
|
||||||
/* Perform operation */
|
|
||||||
ret = EVP_PKEY_verify(ctx, sig, siglen, md, mdlen);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ret == 1 indicates success, 0 verify failure and < 0 for some
|
|
||||||
* other error.
|
|
||||||
*/
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
L<EVP_PKEY_CTX_new(3)>,
|
|
||||||
L<EVP_PKEY_encrypt(3)>,
|
|
||||||
L<EVP_PKEY_decrypt(3)>,
|
|
||||||
L<EVP_PKEY_sign(3)>,
|
|
||||||
L<EVP_PKEY_verify_recover(3)>,
|
|
||||||
L<EVP_PKEY_derive(3)>
|
|
||||||
|
|
||||||
=head1 HISTORY
|
|
||||||
|
|
||||||
The EVP_PKEY_verify_init() and EVP_PKEY_verify() functions were added in
|
|
||||||
OpenSSL 1.0.0.
|
|
||||||
|
|
||||||
The EVP_PKEY_verify_init_ex() function was added in OpenSSL 3.0.
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2006-2021 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
@@ -1,139 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
OPENSSL_ia32cap - the x86[_64] processor capabilities vector
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
env OPENSSL_ia32cap=... <application>
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
OpenSSL supports a range of x86[_64] instruction set extensions. These
|
|
||||||
extensions are denoted by individual bits in capability vector returned
|
|
||||||
by processor in EDX:ECX register pair after executing CPUID instruction
|
|
||||||
with EAX=1 input value (see Intel Application Note #241618). This vector
|
|
||||||
is copied to memory upon toolkit initialization and used to choose
|
|
||||||
between different code paths to provide optimal performance across wide
|
|
||||||
range of processors. For the moment of this writing following bits are
|
|
||||||
significant:
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item bit #4 denoting presence of Time-Stamp Counter.
|
|
||||||
|
|
||||||
=item bit #19 denoting availability of CLFLUSH instruction;
|
|
||||||
|
|
||||||
=item bit #20, reserved by Intel, is used to choose among RC4 code paths;
|
|
||||||
|
|
||||||
=item bit #23 denoting MMX support;
|
|
||||||
|
|
||||||
=item bit #24, FXSR bit, denoting availability of XMM registers;
|
|
||||||
|
|
||||||
=item bit #25 denoting SSE support;
|
|
||||||
|
|
||||||
=item bit #26 denoting SSE2 support;
|
|
||||||
|
|
||||||
=item bit #28 denoting Hyperthreading, which is used to distinguish
|
|
||||||
cores with shared cache;
|
|
||||||
|
|
||||||
=item bit #30, reserved by Intel, denotes specifically Intel CPUs;
|
|
||||||
|
|
||||||
=item bit #33 denoting availability of PCLMULQDQ instruction;
|
|
||||||
|
|
||||||
=item bit #41 denoting SSSE3, Supplemental SSE3, support;
|
|
||||||
|
|
||||||
=item bit #43 denoting AMD XOP support (forced to zero on non-AMD CPUs);
|
|
||||||
|
|
||||||
=item bit #54 denoting availability of MOVBE instruction;
|
|
||||||
|
|
||||||
=item bit #57 denoting AES-NI instruction set extension;
|
|
||||||
|
|
||||||
=item bit #58, XSAVE bit, lack of which in combination with MOVBE is used
|
|
||||||
to identify Atom Silvermont core;
|
|
||||||
|
|
||||||
=item bit #59, OSXSAVE bit, denoting availability of YMM registers;
|
|
||||||
|
|
||||||
=item bit #60 denoting AVX extension;
|
|
||||||
|
|
||||||
=item bit #62 denoting availability of RDRAND instruction;
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
For example, in 32-bit application context clearing bit #26 at run-time
|
|
||||||
disables high-performance SSE2 code present in the crypto library, while
|
|
||||||
clearing bit #24 disables SSE2 code operating on 128-bit XMM register
|
|
||||||
bank. You might have to do the latter if target OpenSSL application is
|
|
||||||
executed on SSE2 capable CPU, but under control of OS that does not
|
|
||||||
enable XMM registers. Historically address of the capability vector copy
|
|
||||||
was exposed to application through OPENSSL_ia32cap_loc(), but not
|
|
||||||
anymore. Now the only way to affect the capability detection is to set
|
|
||||||
B<OPENSSL_ia32cap> environment variable prior target application start. To
|
|
||||||
give a specific example, on Intel P4 processor
|
|
||||||
C<env OPENSSL_ia32cap=0x16980010 apps/openssl>, or better yet
|
|
||||||
C<env OPENSSL_ia32cap=~0x1000000 apps/openssl> would achieve the desired
|
|
||||||
effect. Alternatively you can reconfigure the toolkit with no-sse2
|
|
||||||
option and recompile.
|
|
||||||
|
|
||||||
Less intuitive is clearing bit #28, or ~0x10000000 in the "environment
|
|
||||||
variable" terms. The truth is that it's not copied from CPUID output
|
|
||||||
verbatim, but is adjusted to reflect whether or not the data cache is
|
|
||||||
actually shared between logical cores. This in turn affects the decision
|
|
||||||
on whether or not expensive countermeasures against cache-timing attacks
|
|
||||||
are applied, most notably in AES assembler module.
|
|
||||||
|
|
||||||
The capability vector is further extended with EBX value returned by
|
|
||||||
CPUID with EAX=7 and ECX=0 as input. Following bits are significant:
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item bit #64+3 denoting availability of BMI1 instructions, e.g. ANDN;
|
|
||||||
|
|
||||||
=item bit #64+5 denoting availability of AVX2 instructions;
|
|
||||||
|
|
||||||
=item bit #64+8 denoting availability of BMI2 instructions, e.g. MULX
|
|
||||||
and RORX;
|
|
||||||
|
|
||||||
=item bit #64+16 denoting availability of AVX512F extension;
|
|
||||||
|
|
||||||
=item bit #64+17 denoting availability of AVX512DQ extension;
|
|
||||||
|
|
||||||
=item bit #64+18 denoting availability of RDSEED instruction;
|
|
||||||
|
|
||||||
=item bit #64+19 denoting availability of ADCX and ADOX instructions;
|
|
||||||
|
|
||||||
=item bit #64+21 denoting availability of VPMADD52[LH]UQ instructions,
|
|
||||||
aka AVX512IFMA extension;
|
|
||||||
|
|
||||||
=item bit #64+29 denoting availability of SHA extension;
|
|
||||||
|
|
||||||
=item bit #64+30 denoting availability of AVX512BW extension;
|
|
||||||
|
|
||||||
=item bit #64+31 denoting availability of AVX512VL extension;
|
|
||||||
|
|
||||||
=item bit #64+41 denoting availability of VAES extension;
|
|
||||||
|
|
||||||
=item bit #64+42 denoting availability of VPCLMULQDQ extension;
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
To control this extended capability word use C<:> as delimiter when
|
|
||||||
setting up B<OPENSSL_ia32cap> environment variable. For example assigning
|
|
||||||
C<:~0x20> would disable AVX2 code paths, and C<:0> - all post-AVX
|
|
||||||
extensions.
|
|
||||||
|
|
||||||
=head1 RETURN VALUES
|
|
||||||
|
|
||||||
Not available.
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2004-2022 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
-98
@@ -1,98 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
OSSL_CRMF_MSG_get0_tmpl,
|
|
||||||
OSSL_CRMF_CERTTEMPLATE_get0_serialNumber,
|
|
||||||
OSSL_CRMF_CERTTEMPLATE_get0_subject,
|
|
||||||
OSSL_CRMF_CERTTEMPLATE_get0_issuer,
|
|
||||||
OSSL_CRMF_CERTTEMPLATE_get0_extensions,
|
|
||||||
OSSL_CRMF_CERTID_get0_serialNumber,
|
|
||||||
OSSL_CRMF_CERTID_get0_issuer,
|
|
||||||
OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert,
|
|
||||||
OSSL_CRMF_MSG_get_certReqId
|
|
||||||
- functions reading from CRMF CertReqMsg structures
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
#include <openssl/crmf.h>
|
|
||||||
|
|
||||||
OSSL_CRMF_CERTTEMPLATE *OSSL_CRMF_MSG_get0_tmpl(const OSSL_CRMF_MSG *crm);
|
|
||||||
const ASN1_INTEGER
|
|
||||||
*OSSL_CRMF_CERTTEMPLATE_get0_serialNumber(const OSSL_CRMF_CERTTEMPLATE *tmpl);
|
|
||||||
const X509_NAME
|
|
||||||
*OSSL_CRMF_CERTTEMPLATE_get0_subject(const OSSL_CRMF_CERTTEMPLATE *tmpl);
|
|
||||||
const X509_NAME
|
|
||||||
*OSSL_CRMF_CERTTEMPLATE_get0_issuer(const OSSL_CRMF_CERTTEMPLATE *tmpl);
|
|
||||||
X509_EXTENSIONS
|
|
||||||
*OSSL_CRMF_CERTTEMPLATE_get0_extensions(const OSSL_CRMF_CERTTEMPLATE *tmpl);
|
|
||||||
|
|
||||||
const ASN1_INTEGER
|
|
||||||
*OSSL_CRMF_CERTID_get0_serialNumber(const OSSL_CRMF_CERTID *cid);
|
|
||||||
const X509_NAME *OSSL_CRMF_CERTID_get0_issuer(const OSSL_CRMF_CERTID *cid);
|
|
||||||
|
|
||||||
X509
|
|
||||||
*OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert(const OSSL_CRMF_ENCRYPTEDVALUE *ecert,
|
|
||||||
OSSL_LIB_CTX *libctx, const char *propq,
|
|
||||||
EVP_PKEY *pkey);
|
|
||||||
|
|
||||||
int OSSL_CRMF_MSG_get_certReqId(const OSSL_CRMF_MSG *crm);
|
|
||||||
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
OSSL_CRMF_MSG_get0_tmpl() retrieves the certificate template of I<crm>.
|
|
||||||
|
|
||||||
OSSL_CRMF_CERTTEMPLATE_get0_serialNumber() retrieves the serialNumber of the
|
|
||||||
given certificate template I<tmpl>.
|
|
||||||
|
|
||||||
OSSL_CRMF_CERTTEMPLATE_get0_subject() retrieves the subject name of the
|
|
||||||
given certificate template I<tmpl>.
|
|
||||||
|
|
||||||
OSSL_CRMF_CERTTEMPLATE_get0_issuer() retrieves the issuer name of the
|
|
||||||
given certificate template I<tmpl>.
|
|
||||||
|
|
||||||
OSSL_CRMF_CERTTEMPLATE_get0_extensions() retrieves the X.509 extensions
|
|
||||||
of the given certificate template I<tmpl>, or NULL if not present.
|
|
||||||
|
|
||||||
OSSL_CRMF_CERTID_get0_serialNumber retrieves the serialNumber
|
|
||||||
of the given CertId I<cid>.
|
|
||||||
|
|
||||||
OSSL_CRMF_CERTID_get0_issuer retrieves the issuer name
|
|
||||||
of the given CertId I<cid>, which must be of ASN.1 type GEN_DIRNAME.
|
|
||||||
|
|
||||||
OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert() decrypts the certificate in the given
|
|
||||||
encryptedValue I<ecert>, using the private key I<pkey>, library context
|
|
||||||
I<libctx> and property query string I<propq> (see L<OSSL_LIB_CTX(3)>).
|
|
||||||
This is needed for the indirect POPO method as in RFC 4210 section 5.2.8.2.
|
|
||||||
The function returns the decrypted certificate as a copy, leaving its ownership
|
|
||||||
with the caller, who is responsible for freeing it.
|
|
||||||
|
|
||||||
OSSL_CRMF_MSG_get_certReqId() retrieves the certReqId of I<crm>.
|
|
||||||
|
|
||||||
|
|
||||||
=head1 RETURN VALUES
|
|
||||||
|
|
||||||
OSSL_CRMF_MSG_get_certReqId() returns the certificate request ID as a
|
|
||||||
nonnegative integer or -1 on error.
|
|
||||||
|
|
||||||
All other functions return a pointer with the intended result or NULL on error.
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
RFC 4211
|
|
||||||
|
|
||||||
=head1 HISTORY
|
|
||||||
|
|
||||||
The OpenSSL CRMF support was added in OpenSSL 3.0.
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2007-2021 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
-141
@@ -1,141 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
SSL_CTX_set1_groups, SSL_CTX_set1_groups_list, SSL_set1_groups,
|
|
||||||
SSL_set1_groups_list, SSL_get1_groups, SSL_get_shared_group,
|
|
||||||
SSL_get_negotiated_group, SSL_CTX_set1_curves, SSL_CTX_set1_curves_list,
|
|
||||||
SSL_set1_curves, SSL_set1_curves_list, SSL_get1_curves, SSL_get_shared_curve
|
|
||||||
- EC supported curve functions
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
#include <openssl/ssl.h>
|
|
||||||
|
|
||||||
int SSL_CTX_set1_groups(SSL_CTX *ctx, int *glist, int glistlen);
|
|
||||||
int SSL_CTX_set1_groups_list(SSL_CTX *ctx, char *list);
|
|
||||||
|
|
||||||
int SSL_set1_groups(SSL *ssl, int *glist, int glistlen);
|
|
||||||
int SSL_set1_groups_list(SSL *ssl, char *list);
|
|
||||||
|
|
||||||
int SSL_get1_groups(SSL *ssl, int *groups);
|
|
||||||
int SSL_get_shared_group(SSL *s, int n);
|
|
||||||
int SSL_get_negotiated_group(SSL *s);
|
|
||||||
|
|
||||||
int SSL_CTX_set1_curves(SSL_CTX *ctx, int *clist, int clistlen);
|
|
||||||
int SSL_CTX_set1_curves_list(SSL_CTX *ctx, char *list);
|
|
||||||
|
|
||||||
int SSL_set1_curves(SSL *ssl, int *clist, int clistlen);
|
|
||||||
int SSL_set1_curves_list(SSL *ssl, char *list);
|
|
||||||
|
|
||||||
int SSL_get1_curves(SSL *ssl, int *curves);
|
|
||||||
int SSL_get_shared_curve(SSL *s, int n);
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
For all of the functions below that set the supported groups there must be at
|
|
||||||
least one group in the list. A number of these functions identify groups via a
|
|
||||||
unique integer NID value. However, support for some groups may be added by
|
|
||||||
external providers. In this case there will be no NID assigned for the group.
|
|
||||||
When setting such groups applications should use the "list" form of these
|
|
||||||
functions (i.e. SSL_CTX_set1_groups_list() and SSL_set1_groups_list).
|
|
||||||
|
|
||||||
SSL_CTX_set1_groups() sets the supported groups for B<ctx> to B<glistlen>
|
|
||||||
groups in the array B<glist>. The array consist of all NIDs of groups in
|
|
||||||
preference order. For a TLS client the groups are used directly in the
|
|
||||||
supported groups extension. For a TLS server the groups are used to
|
|
||||||
determine the set of shared groups. Currently supported groups for
|
|
||||||
B<TLSv1.3> are B<NID_X9_62_prime256v1>, B<NID_secp384r1>, B<NID_secp521r1>,
|
|
||||||
B<NID_X25519>, B<NID_X448>, B<NID_ffdhe2048>, B<NID_ffdhe3072>,
|
|
||||||
B<NID_ffdhe4096>, B<NID_ffdhe6144> and B<NID_ffdhe8192>.
|
|
||||||
|
|
||||||
SSL_CTX_set1_groups_list() sets the supported groups for B<ctx> to
|
|
||||||
string B<list>. The string is a colon separated list of group NIDs or
|
|
||||||
names, for example "P-521:P-384:P-256:X25519:ffdhe2048". Currently supported
|
|
||||||
groups for B<TLSv1.3> are B<P-256>, B<P-384>, B<P-521>, B<X25519>, B<X448>,
|
|
||||||
B<ffdhe2048>, B<ffdhe3072>, B<ffdhe4096>, B<ffdhe6144>, B<ffdhe8192>. Support
|
|
||||||
for other groups may be added by external providers.
|
|
||||||
|
|
||||||
SSL_set1_groups() and SSL_set1_groups_list() are similar except they set
|
|
||||||
supported groups for the SSL structure B<ssl>.
|
|
||||||
|
|
||||||
SSL_get1_groups() returns the set of supported groups sent by a client
|
|
||||||
in the supported groups extension. It returns the total number of
|
|
||||||
supported groups. The B<groups> parameter can be B<NULL> to simply
|
|
||||||
return the number of groups for memory allocation purposes. The
|
|
||||||
B<groups> array is in the form of a set of group NIDs in preference
|
|
||||||
order. It can return zero if the client did not send a supported groups
|
|
||||||
extension. If a supported group NID is unknown then the value is set to the
|
|
||||||
bitwise OR of TLSEXT_nid_unknown (0x1000000) and the id of the group.
|
|
||||||
|
|
||||||
SSL_get_shared_group() returns the NID of the shared group B<n> for a
|
|
||||||
server-side SSL B<ssl>. If B<n> is -1 then the total number of shared groups is
|
|
||||||
returned, which may be zero. Other than for diagnostic purposes,
|
|
||||||
most applications will only be interested in the first shared group
|
|
||||||
so B<n> is normally set to zero. If the value B<n> is out of range,
|
|
||||||
NID_undef is returned. If the NID for the shared group is unknown then the value
|
|
||||||
is set to the bitwise OR of TLSEXT_nid_unknown (0x1000000) and the id of the
|
|
||||||
group.
|
|
||||||
|
|
||||||
SSL_get_negotiated_group() returns the NID of the negotiated group used for
|
|
||||||
the handshake key exchange process. For TLSv1.3 connections this typically
|
|
||||||
reflects the state of the current connection, though in the case of PSK-only
|
|
||||||
resumption, the returned value will be from a previous connection. For earlier
|
|
||||||
TLS versions, when a session has been resumed, it always reflects the group
|
|
||||||
used for key exchange during the initial handshake (otherwise it is from the
|
|
||||||
current, non-resumption, connection). This can be called by either client or
|
|
||||||
server. If the NID for the shared group is unknown then the value is set to the
|
|
||||||
bitwise OR of TLSEXT_nid_unknown (0x1000000) and the id of the group.
|
|
||||||
|
|
||||||
All these functions are implemented as macros.
|
|
||||||
|
|
||||||
The curve functions are synonyms for the equivalently named group functions and
|
|
||||||
are identical in every respect. They exist because, prior to TLS1.3, there was
|
|
||||||
only the concept of supported curves. In TLS1.3 this was renamed to supported
|
|
||||||
groups, and extended to include Diffie Hellman groups. The group functions
|
|
||||||
should be used in preference.
|
|
||||||
|
|
||||||
=head1 NOTES
|
|
||||||
|
|
||||||
If an application wishes to make use of several of these functions for
|
|
||||||
configuration purposes either on a command line or in a file it should
|
|
||||||
consider using the SSL_CONF interface instead of manually parsing options.
|
|
||||||
|
|
||||||
=head1 RETURN VALUES
|
|
||||||
|
|
||||||
SSL_CTX_set1_groups(), SSL_CTX_set1_groups_list(), SSL_set1_groups() and
|
|
||||||
SSL_set1_groups_list(), return 1 for success and 0 for failure.
|
|
||||||
|
|
||||||
SSL_get1_groups() returns the number of groups, which may be zero.
|
|
||||||
|
|
||||||
SSL_get_shared_group() returns the NID of shared group B<n> or NID_undef if there
|
|
||||||
is no shared group B<n>; or the total number of shared groups if B<n>
|
|
||||||
is -1.
|
|
||||||
|
|
||||||
When called on a client B<ssl>, SSL_get_shared_group() has no meaning and
|
|
||||||
returns -1.
|
|
||||||
|
|
||||||
SSL_get_negotiated_group() returns the NID of the negotiated group used for
|
|
||||||
key exchange, or NID_undef if there was no negotiated group.
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
L<ssl(7)>,
|
|
||||||
L<SSL_CTX_add_extra_chain_cert(3)>
|
|
||||||
|
|
||||||
=head1 HISTORY
|
|
||||||
|
|
||||||
The curve functions were added in OpenSSL 1.0.2. The equivalent group
|
|
||||||
functions were added in OpenSSL 1.1.1. The SSL_get_negotiated_group() function
|
|
||||||
was added in OpenSSL 3.0.0.
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2013-2021 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
-53
@@ -1,53 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
SSL_get_peer_signature_nid, SSL_get_peer_signature_type_nid,
|
|
||||||
SSL_get_signature_nid, SSL_get_signature_type_nid - get TLS message signing
|
|
||||||
types
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
#include <openssl/ssl.h>
|
|
||||||
|
|
||||||
int SSL_get_peer_signature_nid(SSL *ssl, int *psig_nid);
|
|
||||||
int SSL_get_peer_signature_type_nid(const SSL *ssl, int *psigtype_nid);
|
|
||||||
int SSL_get_signature_nid(SSL *ssl, int *psig_nid);
|
|
||||||
int SSL_get_signature_type_nid(const SSL *ssl, int *psigtype_nid);
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
SSL_get_peer_signature_nid() sets B<*psig_nid> to the NID of the digest used
|
|
||||||
by the peer to sign TLS messages. It is implemented as a macro.
|
|
||||||
|
|
||||||
SSL_get_peer_signature_type_nid() sets B<*psigtype_nid> to the signature
|
|
||||||
type used by the peer to sign TLS messages. Currently the signature type
|
|
||||||
is the NID of the public key type used for signing except for PSS signing
|
|
||||||
where it is B<EVP_PKEY_RSA_PSS>. To differentiate between
|
|
||||||
B<rsa_pss_rsae_*> and B<rsa_pss_pss_*> signatures, it's necessary to check
|
|
||||||
the type of public key in the peer's certificate.
|
|
||||||
|
|
||||||
SSL_get_signature_nid() and SSL_get_signature_type_nid() return the equivalent
|
|
||||||
information for the local end of the connection.
|
|
||||||
|
|
||||||
=head1 RETURN VALUES
|
|
||||||
|
|
||||||
These functions return 1 for success and 0 for failure. There are several
|
|
||||||
possible reasons for failure: the cipher suite has no signature (e.g. it
|
|
||||||
uses RSA key exchange or is anonymous), the TLS version is below 1.2 or
|
|
||||||
the functions were called too early, e.g. before the peer signed a message.
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
L<ssl(7)>, L<SSL_get_peer_certificate(3)>,
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2017-2018 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
SSL_client_version, SSL_get_version, SSL_is_dtls, SSL_version - get the
|
|
||||||
protocol information of a connection
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
#include <openssl/ssl.h>
|
|
||||||
|
|
||||||
int SSL_client_version(const SSL *s);
|
|
||||||
|
|
||||||
const char *SSL_get_version(const SSL *ssl);
|
|
||||||
|
|
||||||
int SSL_is_dtls(const SSL *ssl);
|
|
||||||
|
|
||||||
int SSL_version(const SSL *s);
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
SSL_client_version() returns the numeric protocol version advertised by the
|
|
||||||
client in the legacy_version field of the ClientHello when initiating the
|
|
||||||
connection. Note that, for TLS, this value will never indicate a version greater
|
|
||||||
than TLSv1.2 even if TLSv1.3 is subsequently negotiated. SSL_get_version()
|
|
||||||
returns the name of the protocol used for the connection. SSL_version() returns
|
|
||||||
the numeric protocol version used for the connection. They should only be called
|
|
||||||
after the initial handshake has been completed. Prior to that the results
|
|
||||||
returned from these functions may be unreliable.
|
|
||||||
|
|
||||||
SSL_is_dtls() returns one if the connection is using DTLS, zero if not.
|
|
||||||
|
|
||||||
=head1 RETURN VALUES
|
|
||||||
|
|
||||||
|
|
||||||
SSL_get_version() returns one of the following strings:
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item SSLv3
|
|
||||||
|
|
||||||
The connection uses the SSLv3 protocol.
|
|
||||||
|
|
||||||
=item TLSv1
|
|
||||||
|
|
||||||
The connection uses the TLSv1.0 protocol.
|
|
||||||
|
|
||||||
=item TLSv1.1
|
|
||||||
|
|
||||||
The connection uses the TLSv1.1 protocol.
|
|
||||||
|
|
||||||
=item TLSv1.2
|
|
||||||
|
|
||||||
The connection uses the TLSv1.2 protocol.
|
|
||||||
|
|
||||||
=item TLSv1.3
|
|
||||||
|
|
||||||
The connection uses the TLSv1.3 protocol.
|
|
||||||
|
|
||||||
=item unknown
|
|
||||||
|
|
||||||
This indicates an unknown protocol version.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
SSL_version() and SSL_client_version() return an integer which could include any
|
|
||||||
of the following:
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item SSL3_VERSION
|
|
||||||
|
|
||||||
The connection uses the SSLv3 protocol.
|
|
||||||
|
|
||||||
=item TLS1_VERSION
|
|
||||||
|
|
||||||
The connection uses the TLSv1.0 protocol.
|
|
||||||
|
|
||||||
=item TLS1_1_VERSION
|
|
||||||
|
|
||||||
The connection uses the TLSv1.1 protocol.
|
|
||||||
|
|
||||||
=item TLS1_2_VERSION
|
|
||||||
|
|
||||||
The connection uses the TLSv1.2 protocol.
|
|
||||||
|
|
||||||
=item TLS1_3_VERSION
|
|
||||||
|
|
||||||
The connection uses the TLSv1.3 protocol (never returned for
|
|
||||||
SSL_client_version()).
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
L<ssl(7)>
|
|
||||||
|
|
||||||
=head1 HISTORY
|
|
||||||
|
|
||||||
The SSL_is_dtls() function was added in OpenSSL 1.1.0.
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2001-2018 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
@@ -1,177 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
SSL_shutdown - shut down a TLS/SSL connection
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
#include <openssl/ssl.h>
|
|
||||||
|
|
||||||
int SSL_shutdown(SSL *ssl);
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
SSL_shutdown() shuts down an active TLS/SSL connection. It sends the
|
|
||||||
close_notify shutdown alert to the peer.
|
|
||||||
|
|
||||||
SSL_shutdown() tries to send the close_notify shutdown alert to the peer.
|
|
||||||
Whether the operation succeeds or not, the SSL_SENT_SHUTDOWN flag is set and
|
|
||||||
a currently open session is considered closed and good and will be kept in the
|
|
||||||
session cache for further reuse.
|
|
||||||
|
|
||||||
Note that SSL_shutdown() must not be called if a previous fatal error has
|
|
||||||
occurred on a connection i.e. if SSL_get_error() has returned SSL_ERROR_SYSCALL
|
|
||||||
or SSL_ERROR_SSL.
|
|
||||||
|
|
||||||
The shutdown procedure consists of two steps: sending of the close_notify
|
|
||||||
shutdown alert, and reception of the peer's close_notify shutdown alert.
|
|
||||||
The order of those two steps depends on the application.
|
|
||||||
|
|
||||||
It is acceptable for an application to only send its shutdown alert and
|
|
||||||
then close the underlying connection without waiting for the peer's response.
|
|
||||||
This way resources can be saved, as the process can already terminate or
|
|
||||||
serve another connection.
|
|
||||||
This should only be done when it is known that the other side will not send more
|
|
||||||
data, otherwise there is a risk of a truncation attack.
|
|
||||||
|
|
||||||
When a client only writes and never reads from the connection, and the server
|
|
||||||
has sent a session ticket to establish a session, the client might not be able
|
|
||||||
to resume the session because it did not received and process the session ticket
|
|
||||||
from the server.
|
|
||||||
In case the application wants to be able to resume the session, it is recommended to
|
|
||||||
do a complete shutdown procedure (bidirectional close_notify alerts).
|
|
||||||
|
|
||||||
When the underlying connection shall be used for more communications, the
|
|
||||||
complete shutdown procedure must be performed, so that the peers stay
|
|
||||||
synchronized.
|
|
||||||
|
|
||||||
SSL_shutdown() only closes the write direction.
|
|
||||||
It is not possible to call SSL_write() after calling SSL_shutdown().
|
|
||||||
The read direction is closed by the peer.
|
|
||||||
|
|
||||||
The behaviour of SSL_shutdown() additionally depends on the underlying BIO.
|
|
||||||
If the underlying BIO is B<blocking>, SSL_shutdown() will only return once the
|
|
||||||
handshake step has been finished or an error occurred.
|
|
||||||
|
|
||||||
If the underlying BIO is B<nonblocking>, SSL_shutdown() will also return
|
|
||||||
when the underlying BIO could not satisfy the needs of SSL_shutdown()
|
|
||||||
to continue the handshake. In this case a call to SSL_get_error() with the
|
|
||||||
return value of SSL_shutdown() will yield B<SSL_ERROR_WANT_READ> or
|
|
||||||
B<SSL_ERROR_WANT_WRITE>. The calling process then must repeat the call after
|
|
||||||
taking appropriate action to satisfy the needs of SSL_shutdown().
|
|
||||||
The action depends on the underlying BIO. When using a nonblocking socket,
|
|
||||||
nothing is to be done, but select() can be used to check for the required
|
|
||||||
condition. When using a buffering BIO, like a BIO pair, data must be written
|
|
||||||
into or retrieved out of the BIO before being able to continue.
|
|
||||||
|
|
||||||
After SSL_shutdown() returned 0, it is possible to call SSL_shutdown() again
|
|
||||||
to wait for the peer's close_notify alert.
|
|
||||||
SSL_shutdown() will return 1 in that case.
|
|
||||||
However, it is recommended to wait for it using SSL_read() instead.
|
|
||||||
|
|
||||||
SSL_shutdown() can be modified to only set the connection to "shutdown"
|
|
||||||
state but not actually send the close_notify alert messages,
|
|
||||||
see L<SSL_CTX_set_quiet_shutdown(3)>.
|
|
||||||
When "quiet shutdown" is enabled, SSL_shutdown() will always succeed
|
|
||||||
and return 1.
|
|
||||||
Note that this is not standard compliant behaviour.
|
|
||||||
It should only be done when the peer has a way to make sure all
|
|
||||||
data has been received and doesn't wait for the close_notify alert
|
|
||||||
message, otherwise an unexpected EOF will be reported.
|
|
||||||
|
|
||||||
There are implementations that do not send the required close_notify alert.
|
|
||||||
If there is a need to communicate with such an implementation, and it's clear
|
|
||||||
that all data has been received, do not wait for the peer's close_notify alert.
|
|
||||||
Waiting for the close_notify alert when the peer just closes the connection
|
|
||||||
will result in an error being generated.
|
|
||||||
The error can be ignored using the B<SSL_OP_IGNORE_UNEXPECTED_EOF>.
|
|
||||||
For more information see L<SSL_CTX_set_options(3)>.
|
|
||||||
|
|
||||||
=head2 First to close the connection
|
|
||||||
|
|
||||||
When the application is the first party to send the close_notify
|
|
||||||
alert, SSL_shutdown() will only send the alert and then set the
|
|
||||||
SSL_SENT_SHUTDOWN flag (so that the session is considered good and will
|
|
||||||
be kept in the cache).
|
|
||||||
If successful, SSL_shutdown() will return 0.
|
|
||||||
|
|
||||||
If a unidirectional shutdown is enough (the underlying connection shall be
|
|
||||||
closed anyway), this first successful call to SSL_shutdown() is sufficient.
|
|
||||||
|
|
||||||
In order to complete the bidirectional shutdown handshake, the peer needs
|
|
||||||
to send back a close_notify alert.
|
|
||||||
The SSL_RECEIVED_SHUTDOWN flag will be set after receiving and processing
|
|
||||||
it.
|
|
||||||
|
|
||||||
The peer is still allowed to send data after receiving the close_notify
|
|
||||||
event.
|
|
||||||
When it is done sending data, it will send the close_notify alert.
|
|
||||||
SSL_read() should be called until all data is received.
|
|
||||||
SSL_read() will indicate the end of the peer data by returning <= 0
|
|
||||||
and SSL_get_error() returning SSL_ERROR_ZERO_RETURN.
|
|
||||||
|
|
||||||
=head2 Peer closes the connection
|
|
||||||
|
|
||||||
If the peer already sent the close_notify alert B<and> it was
|
|
||||||
already processed implicitly inside another function
|
|
||||||
(L<SSL_read(3)>), the SSL_RECEIVED_SHUTDOWN flag is set.
|
|
||||||
SSL_read() will return <= 0 in that case, and SSL_get_error() will return
|
|
||||||
SSL_ERROR_ZERO_RETURN.
|
|
||||||
SSL_shutdown() will send the close_notify alert, set the SSL_SENT_SHUTDOWN
|
|
||||||
flag.
|
|
||||||
If successful, SSL_shutdown() will return 1.
|
|
||||||
|
|
||||||
Whether SSL_RECEIVED_SHUTDOWN is already set can be checked using the
|
|
||||||
SSL_get_shutdown() (see also L<SSL_set_shutdown(3)> call.
|
|
||||||
|
|
||||||
=head1 RETURN VALUES
|
|
||||||
|
|
||||||
The following return values can occur:
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item Z<>0
|
|
||||||
|
|
||||||
The shutdown is not yet finished: the close_notify was sent but the peer
|
|
||||||
did not send it back yet.
|
|
||||||
Call SSL_read() to do a bidirectional shutdown.
|
|
||||||
|
|
||||||
Unlike most other function, returning 0 does not indicate an error.
|
|
||||||
L<SSL_get_error(3)> should not get called, it may misleadingly
|
|
||||||
indicate an error even though no error occurred.
|
|
||||||
|
|
||||||
=item Z<>1
|
|
||||||
|
|
||||||
The shutdown was successfully completed. The close_notify alert was sent
|
|
||||||
and the peer's close_notify alert was received.
|
|
||||||
|
|
||||||
=item E<lt>0
|
|
||||||
|
|
||||||
The shutdown was not successful.
|
|
||||||
Call L<SSL_get_error(3)> with the return value B<ret> to find out the reason.
|
|
||||||
It can occur if an action is needed to continue the operation for nonblocking
|
|
||||||
BIOs.
|
|
||||||
|
|
||||||
It can also occur when not all data was read using SSL_read().
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
L<SSL_get_error(3)>, L<SSL_connect(3)>,
|
|
||||||
L<SSL_accept(3)>, L<SSL_set_shutdown(3)>,
|
|
||||||
L<SSL_CTX_set_quiet_shutdown(3)>, L<SSL_CTX_set_options(3)>
|
|
||||||
L<SSL_clear(3)>, L<SSL_free(3)>,
|
|
||||||
L<ssl(7)>, L<bio(7)>
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2000-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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
-61
@@ -1,61 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
TS_VERIFY_CTX_set_certs, TS_VERIFY_CTS_set_certs
|
|
||||||
- set certificates for TS response verification
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
#include <openssl/ts.h>
|
|
||||||
|
|
||||||
STACK_OF(X509) *TS_VERIFY_CTX_set_certs(TS_VERIFY_CTX *ctx,
|
|
||||||
STACK_OF(X509) *certs);
|
|
||||||
STACK_OF(X509) *TS_VERIFY_CTS_set_certs(TS_VERIFY_CTX *ctx,
|
|
||||||
STACK_OF(X509) *certs);
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
The Time-Stamp Protocol (TSP) is defined by RFC 3161. TSP is a protocol used to
|
|
||||||
provide long term proof of the existence of a certain datum before a particular
|
|
||||||
time. TSP defines a Time Stamping Authority (TSA) and an entity who shall make
|
|
||||||
requests to the TSA. Usually the TSA is denoted as the server side and the
|
|
||||||
requesting entity is denoted as the client.
|
|
||||||
|
|
||||||
In TSP, when a server is sending a response to a client, the server normally
|
|
||||||
needs to sign the response data - the TimeStampToken (TST) - with its private
|
|
||||||
key. Then the client shall verify the received TST by the server's certificate
|
|
||||||
chain.
|
|
||||||
|
|
||||||
TS_VERIFY_CTX_set_certs() is used to set the server's certificate chain when
|
|
||||||
verifying a TST. B<ctx> is the verification context created in advance and
|
|
||||||
B<certs> is a stack of B<X509> certificates.
|
|
||||||
|
|
||||||
TS_VERIFY_CTS_set_certs() is a misspelled version of TS_VERIFY_CTX_set_certs()
|
|
||||||
which takes the same parameters and returns the same result.
|
|
||||||
|
|
||||||
=head1 RETURN VALUES
|
|
||||||
|
|
||||||
TS_VERIFY_CTX_set_certs() returns the stack of B<X509> certificates the user
|
|
||||||
passes in via parameter B<certs>.
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
L<OSSL_ESS_check_signing_certs(3)>
|
|
||||||
|
|
||||||
=head1 HISTORY
|
|
||||||
|
|
||||||
The spelling of TS_VERIFY_CTX_set_certs() was corrected in OpenSSL 3.0.0.
|
|
||||||
The misspelled version TS_VERIFY_CTS_set_certs() has been retained for
|
|
||||||
compatibility reasons, but it is deprecated in OpenSSL 3.0.0.
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2019-2021 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
X509_check_purpose - Check the purpose of a certificate
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
#include <openssl/x509v3.h>
|
|
||||||
|
|
||||||
int X509_check_purpose(X509 *x, int id, int ca);
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
This function checks if certificate I<x> was created with the purpose
|
|
||||||
represented by I<id>. If I<ca> is nonzero, then certificate I<x> is
|
|
||||||
checked to determine if it's a possible CA with various levels of certainty
|
|
||||||
possibly returned. The certificate I<x> must be a complete certificate
|
|
||||||
otherwise the function returns an error.
|
|
||||||
|
|
||||||
Below are the potential ID's that can be checked:
|
|
||||||
|
|
||||||
# define X509_PURPOSE_SSL_CLIENT 1
|
|
||||||
# define X509_PURPOSE_SSL_SERVER 2
|
|
||||||
# define X509_PURPOSE_NS_SSL_SERVER 3
|
|
||||||
# define X509_PURPOSE_SMIME_SIGN 4
|
|
||||||
# define X509_PURPOSE_SMIME_ENCRYPT 5
|
|
||||||
# define X509_PURPOSE_CRL_SIGN 6
|
|
||||||
# define X509_PURPOSE_ANY 7
|
|
||||||
# define X509_PURPOSE_OCSP_HELPER 8
|
|
||||||
# define X509_PURPOSE_TIMESTAMP_SIGN 9
|
|
||||||
|
|
||||||
The checks performed take into account the X.509 extensions
|
|
||||||
keyUsage, extendedKeyUsage, and basicConstraints.
|
|
||||||
|
|
||||||
=head1 RETURN VALUES
|
|
||||||
|
|
||||||
For non-CA checks
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item -1 an error condition has occurred
|
|
||||||
|
|
||||||
=item E<32>1 if the certificate was created to perform the purpose represented by I<id>
|
|
||||||
|
|
||||||
=item E<32>0 if the certificate was not created to perform the purpose represented by I<id>
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
For CA checks the below integers could be returned with the following meanings:
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item -1 an error condition has occurred
|
|
||||||
|
|
||||||
=item E<32>0 not a CA or does not have the purpose represented by I<id>
|
|
||||||
|
|
||||||
=item E<32>1 is a CA.
|
|
||||||
|
|
||||||
=item E<32>2 Only possible in old versions of openSSL when basicConstraints are absent.
|
|
||||||
New versions will not return this value. May be a CA
|
|
||||||
|
|
||||||
=item E<32>3 basicConstraints absent but self signed V1.
|
|
||||||
|
|
||||||
=item E<32>4 basicConstraints absent but keyUsage present and keyCertSign asserted.
|
|
||||||
|
|
||||||
=item E<32>5 legacy Netscape specific CA Flags present
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2019-2021 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 L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
EVP_SIGNATURE-DSA
|
|
||||||
- The B<EVP_PKEY> DSA signature implementation
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
Support for computing DSA signatures.
|
|
||||||
See L<EVP_PKEY-DSA(7)> for information related to DSA keys.
|
|
||||||
|
|
||||||
=head2 Signature Parameters
|
|
||||||
|
|
||||||
The following signature parameters can be set using EVP_PKEY_CTX_set_params().
|
|
||||||
This may be called after EVP_PKEY_sign_init() or EVP_PKEY_verify_init(),
|
|
||||||
and before calling EVP_PKEY_sign() or EVP_PKEY_verify().
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item "digest" (B<OSSL_SIGNATURE_PARAM_DIGEST>) <UTF8 string>
|
|
||||||
|
|
||||||
=item "properties" (B<OSSL_SIGNATURE_PARAM_PROPERTIES>) <UTF8 string>
|
|
||||||
|
|
||||||
The settable parameters are described in L<provider-signature(7)>.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
The following signature parameters can be retrieved using
|
|
||||||
EVP_PKEY_CTX_get_params().
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item "algorithm-id" (B<OSSL_SIGNATURE_PARAM_ALGORITHM_ID>) <octet string>
|
|
||||||
|
|
||||||
=item "digest" (B<OSSL_SIGNATURE_PARAM_DIGEST>) <UTF8 string>
|
|
||||||
|
|
||||||
The gettable parameters are described in L<provider-signature(7)>.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
L<EVP_PKEY_CTX_set_params(3)>,
|
|
||||||
L<EVP_PKEY_sign(3)>,
|
|
||||||
L<EVP_PKEY_verify(3)>,
|
|
||||||
L<provider-signature(7)>,
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2020-2021 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
EVP_SIGNATURE-ECDSA - The EVP_PKEY ECDSA signature implementation.
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
Support for computing ECDSA signatures.
|
|
||||||
See L<EVP_PKEY-EC(7)> for information related to EC keys.
|
|
||||||
|
|
||||||
=head2 ECDSA Signature Parameters
|
|
||||||
|
|
||||||
The following signature parameters can be set using EVP_PKEY_CTX_set_params().
|
|
||||||
This may be called after EVP_PKEY_sign_init() or EVP_PKEY_verify_init(),
|
|
||||||
and before calling EVP_PKEY_sign() or EVP_PKEY_verify().
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item "digest" (B<OSSL_SIGNATURE_PARAM_DIGEST>) <UTF8 string>
|
|
||||||
|
|
||||||
=item "properties" (B<OSSL_SIGNATURE_PARAM_PROPERTIES>) <UTF8 string>
|
|
||||||
|
|
||||||
These parameters are described in L<provider-signature(7)>.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
The following signature parameters can be retrieved using
|
|
||||||
EVP_PKEY_CTX_get_params().
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item "algorithm-id" (B<OSSL_SIGNATURE_PARAM_ALGORITHM_ID>) <octet string>
|
|
||||||
|
|
||||||
=item "digest" (B<OSSL_SIGNATURE_PARAM_DIGEST>) <UTF8 string>
|
|
||||||
|
|
||||||
The parameters are described in L<provider-signature(7)>.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
L<EVP_PKEY_CTX_set_params(3)>,
|
|
||||||
L<EVP_PKEY_sign(3)>,
|
|
||||||
L<EVP_PKEY_verify(3)>,
|
|
||||||
L<provider-signature(7)>,
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2020-2021 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
-102
@@ -1,102 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
EVP_SIGNATURE-ED25519,
|
|
||||||
EVP_SIGNATURE-ED448,
|
|
||||||
Ed25519,
|
|
||||||
Ed448
|
|
||||||
- EVP_PKEY Ed25519 and Ed448 support
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
The B<Ed25519> and B<Ed448> EVP_PKEY implementation supports key generation,
|
|
||||||
one-shot digest sign and digest verify using PureEdDSA and B<Ed25519> or B<Ed448>
|
|
||||||
(see RFC8032). It has associated private and public key formats compatible with
|
|
||||||
RFC 8410.
|
|
||||||
|
|
||||||
=head2 ED25519 and ED448 Signature Parameters
|
|
||||||
|
|
||||||
No additional parameters can be set during one-shot signing or verification.
|
|
||||||
In particular, because PureEdDSA is used, a digest must B<NOT> be specified when
|
|
||||||
signing or verifying.
|
|
||||||
See L<EVP_PKEY-X25519(7)> for information related to B<X25519> and B<X448> keys.
|
|
||||||
|
|
||||||
The following signature parameters can be retrieved using
|
|
||||||
EVP_PKEY_CTX_get_params().
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item "algorithm-id" (B<OSSL_SIGNATURE_PARAM_ALGORITHM_ID>) <octet string>
|
|
||||||
|
|
||||||
The parameters are described in L<provider-signature(7)>.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=head1 NOTES
|
|
||||||
|
|
||||||
The PureEdDSA algorithm does not support the streaming mechanism
|
|
||||||
of other signature algorithms using, for example, EVP_DigestUpdate().
|
|
||||||
The message to sign or verify must be passed using the one-shot
|
|
||||||
EVP_DigestSign() and EVP_DigestVerify() functions.
|
|
||||||
|
|
||||||
When calling EVP_DigestSignInit() or EVP_DigestVerifyInit(), the
|
|
||||||
digest I<type> parameter B<MUST> be set to NULL.
|
|
||||||
|
|
||||||
Applications wishing to sign certificates (or other structures such as
|
|
||||||
CRLs or certificate requests) using Ed25519 or Ed448 can either use X509_sign()
|
|
||||||
or X509_sign_ctx() in the usual way.
|
|
||||||
|
|
||||||
Ed25519 or Ed448 private keys can be set directly using
|
|
||||||
L<EVP_PKEY_new_raw_private_key(3)> or loaded from a PKCS#8 private key file
|
|
||||||
using L<PEM_read_bio_PrivateKey(3)> (or similar function). Completely new keys
|
|
||||||
can also be generated (see the example below). Setting a private key also sets
|
|
||||||
the associated public key.
|
|
||||||
|
|
||||||
Ed25519 or Ed448 public keys can be set directly using
|
|
||||||
L<EVP_PKEY_new_raw_public_key(3)> or loaded from a SubjectPublicKeyInfo
|
|
||||||
structure in a PEM file using L<PEM_read_bio_PUBKEY(3)> (or similar function).
|
|
||||||
|
|
||||||
Ed25519 and Ed448 can be tested with the L<openssl-speed(1)> application
|
|
||||||
since version 1.1.1.
|
|
||||||
Valid algorithm names are B<ed25519>, B<ed448> and B<eddsa>. If B<eddsa> is
|
|
||||||
specified, then both Ed25519 and Ed448 are benchmarked.
|
|
||||||
|
|
||||||
=head1 EXAMPLES
|
|
||||||
|
|
||||||
To sign a message using a ED25519 or ED448 key:
|
|
||||||
|
|
||||||
void do_sign(EVP_PKEY *ed_key, unsigned char *msg, size_t msg_len)
|
|
||||||
{
|
|
||||||
size_t sig_len;
|
|
||||||
unsigned char *sig = NULL;
|
|
||||||
EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();
|
|
||||||
|
|
||||||
EVP_DigestSignInit(md_ctx, NULL, NULL, NULL, ed_key);
|
|
||||||
/* Calculate the requires size for the signature by passing a NULL buffer */
|
|
||||||
EVP_DigestSign(md_ctx, NULL, &sig_len, msg, msg_len);
|
|
||||||
sig = OPENSSL_zalloc(sig_len);
|
|
||||||
|
|
||||||
EVP_DigestSign(md_ctx, sig, &sig_len, msg, msg_len);
|
|
||||||
...
|
|
||||||
OPENSSL_free(sig);
|
|
||||||
EVP_MD_CTX_free(md_ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
L<EVP_PKEY-X25519(7)>
|
|
||||||
L<provider-signature(7)>,
|
|
||||||
L<EVP_DigestSignInit(3)>,
|
|
||||||
L<EVP_DigestVerifyInit(3)>,
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2017-2021 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
EVP_SIGNATURE-RSA
|
|
||||||
- The EVP_PKEY RSA signature implementation
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
Support for computing RSA signatures.
|
|
||||||
See L<EVP_PKEY-RSA(7)> for information related to RSA keys.
|
|
||||||
|
|
||||||
=head2 Signature Parameters
|
|
||||||
|
|
||||||
The following signature parameters can be set using EVP_PKEY_CTX_set_params().
|
|
||||||
This may be called after EVP_PKEY_sign_init() or EVP_PKEY_verify_init(),
|
|
||||||
and before calling EVP_PKEY_sign() or EVP_PKEY_verify().
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item "digest" (B<OSSL_SIGNATURE_PARAM_DIGEST>) <UTF8 string>
|
|
||||||
|
|
||||||
=item "properties" (B<OSSL_SIGNATURE_PARAM_PROPERTIES>) <UTF8 string>
|
|
||||||
|
|
||||||
These common parameters are described in L<provider-signature(7)>.
|
|
||||||
|
|
||||||
=item "pad-mode" (B<OSSL_SIGNATURE_PARAM_PAD_MODE>) <UTF8 string>
|
|
||||||
|
|
||||||
The type of padding to be used. Its value can be one of the following:
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item "none" (B<OSSL_PKEY_RSA_PAD_MODE_NONE>)
|
|
||||||
|
|
||||||
=item "pkcs1" (B<OSSL_PKEY_RSA_PAD_MODE_PKCSV15>)
|
|
||||||
|
|
||||||
=item "x931" (B<OSSL_PKEY_RSA_PAD_MODE_X931>)
|
|
||||||
|
|
||||||
=item "pss" (B<OSSL_PKEY_RSA_PAD_MODE_PSS>)
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=item "mgf1-digest" (B<OSSL_SIGNATURE_PARAM_MGF1_DIGEST>) <UTF8 string>
|
|
||||||
|
|
||||||
The digest algorithm name to use for the maskGenAlgorithm used by "pss" mode.
|
|
||||||
|
|
||||||
=item "mgf1-properties" (B<OSSL_SIGNATURE_PARAM_MGF1_PROPERTIES>) <UTF8 string>
|
|
||||||
|
|
||||||
Sets the name of the property query associated with the "mgf1-digest" algorithm.
|
|
||||||
NULL is used if this optional value is not set.
|
|
||||||
|
|
||||||
=item "saltlen" (B<OSSL_SIGNATURE_PARAM_PSS_SALTLEN>) <integer> or <UTF8 string>
|
|
||||||
|
|
||||||
The "pss" mode minimum salt length. The value can either be an integer,
|
|
||||||
a string value representing a number or one of the following string values:
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item "digest" (B<OSSL_PKEY_RSA_PSS_SALT_LEN_DIGEST>)
|
|
||||||
|
|
||||||
Use the same length as the digest size.
|
|
||||||
|
|
||||||
=item "max" (B<OSSL_PKEY_RSA_PSS_SALT_LEN_MAX>)
|
|
||||||
|
|
||||||
Use the maximum salt length.
|
|
||||||
|
|
||||||
=item "auto" (B<OSSL_PKEY_RSA_PSS_SALT_LEN_AUTO>)
|
|
||||||
|
|
||||||
Auto detect the salt length.
|
|
||||||
|
|
||||||
=item "auto-digestmax" (B<OSSL_PKEY_RSA_PSS_SALT_LEN_AUTO_DIGEST_MAX>)
|
|
||||||
|
|
||||||
Auto detect the salt length when verifying. Maximize the salt length up to the
|
|
||||||
digest size when signing to comply with FIPS 186-4 section 5.5.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
The following signature parameters can be retrieved using
|
|
||||||
EVP_PKEY_CTX_get_params().
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item "algorithm-id" (B<OSSL_SIGNATURE_PARAM_ALGORITHM_ID>) <octet string>
|
|
||||||
|
|
||||||
This common parameter is described in L<provider-signature(7)>.
|
|
||||||
|
|
||||||
=item "digest" (B<OSSL_SIGNATURE_PARAM_DIGEST>) <UTF8 string>
|
|
||||||
|
|
||||||
=item "pad-mode" (B<OSSL_SIGNATURE_PARAM_PAD_MODE>) <UTF8 string>
|
|
||||||
|
|
||||||
=item "mgf1-digest" (B<OSSL_SIGNATURE_PARAM_MGF1_DIGEST>) <UTF8 string>
|
|
||||||
|
|
||||||
=item "saltlen" (B<OSSL_SIGNATURE_PARAM_PSS_SALTLEN>) <integer> or <UTF8 string>
|
|
||||||
|
|
||||||
These parameters are as described above.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
L<EVP_PKEY_CTX_set_params(3)>,
|
|
||||||
L<EVP_PKEY_sign(3)>,
|
|
||||||
L<EVP_PKEY_verify(3)>,
|
|
||||||
L<provider-signature(7)>,
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2020-2022 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
OSSL_PROVIDER-base - OpenSSL base provider
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
The OpenSSL base provider supplies the encoding for OpenSSL's
|
|
||||||
asymmetric cryptography.
|
|
||||||
|
|
||||||
=head2 Properties
|
|
||||||
|
|
||||||
The implementations in this provider specifically have this property
|
|
||||||
defined:
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item "provider=base"
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
It may be used in a property query string with fetching functions.
|
|
||||||
|
|
||||||
It isn't mandatory to query for this property, except to make sure to get
|
|
||||||
implementations of this provider and none other.
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item "type=parameters"
|
|
||||||
|
|
||||||
=item "type=private"
|
|
||||||
|
|
||||||
=item "type=public"
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
These may be used in a property query string with fetching functions to select
|
|
||||||
which data are to be encoded. Either the private key material, the public
|
|
||||||
key material or the domain parameters can be selected.
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item "format=der"
|
|
||||||
|
|
||||||
=item "format=pem"
|
|
||||||
|
|
||||||
=item "format=text"
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
These may be used in a property query string with fetching functions to select
|
|
||||||
the encoding output format. Either the DER, PEM and plaintext are
|
|
||||||
currently permitted.
|
|
||||||
|
|
||||||
=head1 OPERATIONS AND ALGORITHMS
|
|
||||||
|
|
||||||
The OpenSSL base provider supports these operations and algorithms:
|
|
||||||
|
|
||||||
=head2 Asymmetric Key Encoder
|
|
||||||
|
|
||||||
In addition to "provider=base", some of these encoders define the
|
|
||||||
property "fips=yes", to allow them to be used together with the FIPS
|
|
||||||
provider.
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item RSA, see L<OSSL_ENCODER-RSA(7)>
|
|
||||||
|
|
||||||
=item DH, see L<OSSL_ENCODER-DH(7)>
|
|
||||||
|
|
||||||
=item DSA, see L<OSSL_ENCODER-DSA(7)>
|
|
||||||
|
|
||||||
=item EC, see L<OSSL_ENCODER-EC(7)>
|
|
||||||
|
|
||||||
=item X25519, see L<OSSL_ENCODER-X25519(7)>
|
|
||||||
|
|
||||||
=item X448, see L<OSSL_ENCODER-X448(7)>
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
L<OSSL_PROVIDER-default(7)>, L<openssl-core.h(7)>,
|
|
||||||
L<openssl-core_dispatch.h(7)>, L<provider(7)>
|
|
||||||
|
|
||||||
=head1 HISTORY
|
|
||||||
|
|
||||||
This functionality was added in OpenSSL 3.0.
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2020-2022 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
@@ -1,580 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
crypto - OpenSSL cryptographic library
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
See the individual manual pages for details.
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
The OpenSSL crypto library (C<libcrypto>) implements a wide range of
|
|
||||||
cryptographic algorithms used in various Internet standards. The services
|
|
||||||
provided by this library are used by the OpenSSL implementations of TLS and
|
|
||||||
CMS, and they have also been used to implement many other third party products
|
|
||||||
and protocols.
|
|
||||||
|
|
||||||
The functionality includes symmetric encryption, public key cryptography, key
|
|
||||||
agreement, certificate handling, cryptographic hash functions, cryptographic
|
|
||||||
pseudo-random number generators, message authentication codes (MACs), key
|
|
||||||
derivation functions (KDFs), and various utilities.
|
|
||||||
|
|
||||||
=head2 Algorithms
|
|
||||||
|
|
||||||
Cryptographic primitives such as the SHA256 digest, or AES encryption are
|
|
||||||
referred to in OpenSSL as "algorithms". Each algorithm may have multiple
|
|
||||||
implementations available for use. For example the RSA algorithm is available as
|
|
||||||
a "default" implementation suitable for general use, and a "fips" implementation
|
|
||||||
which has been validated to FIPS standards for situations where that is
|
|
||||||
important. It is also possible that a third party could add additional
|
|
||||||
implementations such as in a hardware security module (HSM).
|
|
||||||
|
|
||||||
=head2 Operations
|
|
||||||
|
|
||||||
Different algorithms can be grouped together by their purpose. For example there
|
|
||||||
are algorithms for encryption, and different algorithms for digesting data.
|
|
||||||
These different groups are known as "operations" in OpenSSL. Each operation
|
|
||||||
has a different set of functions associated with it. For example to perform an
|
|
||||||
encryption operation using AES (or any other encryption algorithm) you would use
|
|
||||||
the encryption functions detailed on the L<EVP_EncryptInit(3)> page. Or to
|
|
||||||
perform a digest operation using SHA256 then you would use the digesting
|
|
||||||
functions on the L<EVP_DigestInit(3)> page.
|
|
||||||
|
|
||||||
=head2 Providers
|
|
||||||
|
|
||||||
A provider in OpenSSL is a component that collects together algorithm
|
|
||||||
implementations. In order to use an algorithm you must have at least one
|
|
||||||
provider loaded that contains an implementation of it. OpenSSL comes with a
|
|
||||||
number of providers and they may also be obtained from third parties. If you
|
|
||||||
don't load a provider explicitly (either in program code or via config) then the
|
|
||||||
OpenSSL built-in "default" provider will be automatically loaded.
|
|
||||||
|
|
||||||
=head2 Library contexts
|
|
||||||
|
|
||||||
A library context can be thought of as a "scope" within which configuration
|
|
||||||
options take effect. When a provider is loaded, it is only loaded within the
|
|
||||||
scope of a given library context. In this way it is possible for different
|
|
||||||
components of a complex application to each use a different library context and
|
|
||||||
have different providers loaded with different configuration settings.
|
|
||||||
|
|
||||||
If an application does not explicitly create a library context then the
|
|
||||||
"default" library context will be used.
|
|
||||||
|
|
||||||
Library contexts are represented by the B<OSSL_LIB_CTX> type. Many OpenSSL API
|
|
||||||
functions take a library context as a parameter. Applications can always pass
|
|
||||||
B<NULL> for this parameter to just use the default library context.
|
|
||||||
|
|
||||||
The default library context is automatically created the first time it is
|
|
||||||
needed. This will automatically load any available configuration file and will
|
|
||||||
initialise OpenSSL for use. Unlike in earlier versions of OpenSSL (prior to
|
|
||||||
1.1.0) no explicit initialisation steps need to be taken.
|
|
||||||
|
|
||||||
Similarly when the application exits the default library context is
|
|
||||||
automatically destroyed. No explicit de-initialisation steps need to be taken.
|
|
||||||
|
|
||||||
See L<OSSL_LIB_CTX(3)> for more information about library contexts.
|
|
||||||
See also L</ALGORITHM FETCHING>.
|
|
||||||
|
|
||||||
=head2 Multi-threaded applications
|
|
||||||
|
|
||||||
As long as OpenSSL has been built with support for threads (the default case
|
|
||||||
on most platforms) then most OpenSSL I<functions> are thread-safe in the sense
|
|
||||||
that it is safe to call the same function from multiple threads at the same
|
|
||||||
time. However most OpenSSL I<data structures> are not thread-safe. For example
|
|
||||||
the L<BIO_write(3)> and L<BIO_read(3)> functions are thread safe. However it
|
|
||||||
would not be thread safe to call BIO_write() from one thread while calling
|
|
||||||
BIO_read() in another where both functions are passed the same B<BIO> object
|
|
||||||
since both of them may attempt to make changes to the same B<BIO> object.
|
|
||||||
|
|
||||||
There are exceptions to these rules. A small number of functions are not thread
|
|
||||||
safe at all. Where this is the case this restriction should be noted in the
|
|
||||||
documentation for the function. Similarly some data structures may be partially
|
|
||||||
or fully thread safe. For example it is safe to use an B<OSSL_LIB_CTX> in
|
|
||||||
multiple threads.
|
|
||||||
|
|
||||||
See L<openssl-threads(7)> for a more detailed discussion on OpenSSL threading
|
|
||||||
support.
|
|
||||||
|
|
||||||
=head1 ALGORITHM FETCHING
|
|
||||||
|
|
||||||
In order to use an algorithm an implementation for it must first be "fetched".
|
|
||||||
Fetching is the process of looking through the available implementations,
|
|
||||||
applying selection criteria (via a property query string), and finally choosing
|
|
||||||
the implementation that will be used.
|
|
||||||
|
|
||||||
Two types of fetching are supported by OpenSSL - explicit fetching and implicit
|
|
||||||
fetching.
|
|
||||||
|
|
||||||
=head2 Property query strings
|
|
||||||
|
|
||||||
When fetching an algorithm it is possible to specify a property query string to
|
|
||||||
guide the selection process. For example a property query string of
|
|
||||||
"provider=default" could be used to force the selection to only consider
|
|
||||||
algorithm implementations in the default provider.
|
|
||||||
|
|
||||||
Property query strings can be specified explicitly as an argument to a function.
|
|
||||||
It is also possible to specify a default property query string for the whole
|
|
||||||
library context using the L<EVP_set_default_properties(3)> or
|
|
||||||
L<EVP_default_properties_enable_fips(3)> functions. Where both
|
|
||||||
default properties and function specific properties are specified then they are
|
|
||||||
combined. Function specific properties will override default properties where
|
|
||||||
there is a conflict.
|
|
||||||
|
|
||||||
See L<property(7)> for more information about properties.
|
|
||||||
|
|
||||||
=head2 Explicit fetching
|
|
||||||
|
|
||||||
Users of the OpenSSL libraries never query a provider directly for an algorithm
|
|
||||||
implementation. Instead, the diverse OpenSSL APIs often have explicit fetching
|
|
||||||
functions that do the work, and they return an appropriate algorithm object back
|
|
||||||
to the user. These functions usually have the name C<APINAME_fetch>, where
|
|
||||||
C<APINAME> is the name of the operation. For example L<EVP_MD_fetch(3)> can
|
|
||||||
be used to explicitly fetch a digest algorithm implementation. The user is
|
|
||||||
responsible for freeing the object returned from the C<APINAME_fetch> function
|
|
||||||
using C<APINAME_free> when it is no longer needed.
|
|
||||||
|
|
||||||
These fetching functions follow a fairly common pattern, where three
|
|
||||||
arguments are passed:
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item The library context
|
|
||||||
|
|
||||||
See L<OSSL_LIB_CTX(3)> for a more detailed description.
|
|
||||||
This may be NULL to signify the default (global) library context, or a
|
|
||||||
context created by the user. Only providers loaded in this library context (see
|
|
||||||
L<OSSL_PROVIDER_load(3)>) will be considered by the fetching function. In case
|
|
||||||
no provider has been loaded in this library context then the default provider
|
|
||||||
will be loaded as a fallback (see L<OSSL_PROVIDER-default(7)>).
|
|
||||||
|
|
||||||
=item An identifier
|
|
||||||
|
|
||||||
For all currently implemented fetching functions this is the algorithm name.
|
|
||||||
|
|
||||||
=item A property query string
|
|
||||||
|
|
||||||
The property query string used to guide selection of the algorithm
|
|
||||||
implementation.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
The algorithm implementation that is fetched can then be used with other diverse
|
|
||||||
functions that use them. For example the L<EVP_DigestInit_ex(3)> function takes
|
|
||||||
as a parameter an B<EVP_MD> object which may have been returned from an earlier
|
|
||||||
call to L<EVP_MD_fetch(3)>.
|
|
||||||
|
|
||||||
=head2 Implicit fetching
|
|
||||||
|
|
||||||
OpenSSL has a number of functions that return an algorithm object with no
|
|
||||||
associated implementation, such as L<EVP_sha256(3)>, L<EVP_aes_128_cbc(3)>,
|
|
||||||
L<EVP_get_cipherbyname(3)> or L<EVP_get_digestbyname(3)>. These are present for
|
|
||||||
compatibility with OpenSSL before version 3.0 where explicit fetching was not
|
|
||||||
available.
|
|
||||||
|
|
||||||
When they are used with functions like L<EVP_DigestInit_ex(3)> or
|
|
||||||
L<EVP_CipherInit_ex(3)>, the actual implementation to be used is
|
|
||||||
fetched implicitly using default search criteria.
|
|
||||||
|
|
||||||
In some cases implicit fetching can also occur when a NULL algorithm parameter
|
|
||||||
is supplied. In this case an algorithm implementation is implicitly fetched
|
|
||||||
using default search criteria and an algorithm name that is consistent with
|
|
||||||
the context in which it is being used.
|
|
||||||
|
|
||||||
Functions that revolve around B<EVP_PKEY_CTX> and L<EVP_PKEY(3)>, such as
|
|
||||||
L<EVP_DigestSignInit(3)> and friends, all fetch the implementations
|
|
||||||
implicitly. Because these functions involve both an operation type (such as
|
|
||||||
L<EVP_SIGNATURE(3)>) and an L<EVP_KEYMGMT(3)> for the L<EVP_PKEY(3)>, they try
|
|
||||||
the following:
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item 1.
|
|
||||||
|
|
||||||
Fetch the operation type implementation from any provider given a library
|
|
||||||
context and property string stored in the B<EVP_PKEY_CTX>.
|
|
||||||
|
|
||||||
If the provider of the operation type implementation is different from the
|
|
||||||
provider of the L<EVP_PKEY(3)>'s L<EVP_KEYMGMT(3)> implementation, try to
|
|
||||||
fetch a L<EVP_KEYMGMT(3)> implementation in the same provider as the operation
|
|
||||||
type implementation and export the L<EVP_PKEY(3)> to it (effectively making a
|
|
||||||
temporary copy of the original key).
|
|
||||||
|
|
||||||
If anything in this step fails, the next step is used as a fallback.
|
|
||||||
|
|
||||||
=item 2.
|
|
||||||
|
|
||||||
As a fallback, try to fetch the operation type implementation from the same
|
|
||||||
provider as the original L<EVP_PKEY(3)>'s L<EVP_KEYMGMT(3)>, still using the
|
|
||||||
property string from the B<EVP_PKEY_CTX>.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=head2 Performance
|
|
||||||
|
|
||||||
If you perform the same operation many times then it is recommended to use
|
|
||||||
L</Explicit fetching> to prefetch an algorithm once initially,
|
|
||||||
and then pass this created object to any operations that are currently
|
|
||||||
using L</Implicit fetching>.
|
|
||||||
See an example of Explicit fetching in L</USING ALGORITHMS IN APPLICATIONS>.
|
|
||||||
|
|
||||||
Prior to OpenSSL 3.0, constant method tables (such as EVP_sha256()) were used
|
|
||||||
directly to access methods. If you pass one of these convenience functions
|
|
||||||
to an operation the fixed methods are ignored, and only the name is used to
|
|
||||||
internally fetch methods from a provider.
|
|
||||||
|
|
||||||
If the prefetched object is not passed to operations, then any implicit
|
|
||||||
fetch will use the internally cached prefetched object, but it will
|
|
||||||
still be slower than passing the prefetched object directly.
|
|
||||||
|
|
||||||
Fetching via a provider offers more flexibility, but it is slower than the
|
|
||||||
old method, since it must search for the algorithm in all loaded providers,
|
|
||||||
and then populate the method table using provider supplied methods.
|
|
||||||
Internally OpenSSL caches similar algorithms on the first fetch
|
|
||||||
(so loading a digest caches all digests).
|
|
||||||
|
|
||||||
The following methods can be used for prefetching:
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item L<EVP_MD_fetch(3)>
|
|
||||||
|
|
||||||
=item L<EVP_CIPHER_fetch(3)>
|
|
||||||
|
|
||||||
=item L<EVP_KDF_fetch(3)>
|
|
||||||
|
|
||||||
=item L<EVP_MAC_fetch(3)>
|
|
||||||
|
|
||||||
=item L<EVP_KEM_fetch(3)>
|
|
||||||
|
|
||||||
=item L<OSSL_ENCODER_fetch(3)>
|
|
||||||
|
|
||||||
=item L<OSSL_DECODER_fetch(3)>
|
|
||||||
|
|
||||||
=item L<EVP_RAND_fetch(3)>
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
The following methods are used internally when performing operations:
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item L<EVP_KEYMGMT_fetch(3)>
|
|
||||||
|
|
||||||
=item L<EVP_KEYEXCH_fetch(3)>
|
|
||||||
|
|
||||||
=item L<EVP_SIGNATURE_fetch(3)>
|
|
||||||
|
|
||||||
=item L<OSSL_STORE_LOADER_fetch(3)>
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
See L<OSSL_PROVIDER-default(7)>, L<OSSL_PROVIDER-FIPS(7)> and
|
|
||||||
L<OSSL_PROVIDER-legacy(7)> for a list of algorithm names that
|
|
||||||
can be fetched.
|
|
||||||
|
|
||||||
=head1 FETCHING EXAMPLES
|
|
||||||
|
|
||||||
The following section provides a series of examples of fetching algorithm
|
|
||||||
implementations.
|
|
||||||
|
|
||||||
Fetch any available implementation of SHA2-256 in the default context. Note
|
|
||||||
that some algorithms have aliases. So "SHA256" and "SHA2-256" are synonymous:
|
|
||||||
|
|
||||||
EVP_MD *md = EVP_MD_fetch(NULL, "SHA2-256", NULL);
|
|
||||||
...
|
|
||||||
EVP_MD_free(md);
|
|
||||||
|
|
||||||
Fetch any available implementation of AES-128-CBC in the default context:
|
|
||||||
|
|
||||||
EVP_CIPHER *cipher = EVP_CIPHER_fetch(NULL, "AES-128-CBC", NULL);
|
|
||||||
...
|
|
||||||
EVP_CIPHER_free(cipher);
|
|
||||||
|
|
||||||
Fetch an implementation of SHA2-256 from the default provider in the default
|
|
||||||
context:
|
|
||||||
|
|
||||||
EVP_MD *md = EVP_MD_fetch(NULL, "SHA2-256", "provider=default");
|
|
||||||
...
|
|
||||||
EVP_MD_free(md);
|
|
||||||
|
|
||||||
Fetch an implementation of SHA2-256 that is not from the default provider in the
|
|
||||||
default context:
|
|
||||||
|
|
||||||
EVP_MD *md = EVP_MD_fetch(NULL, "SHA2-256", "provider!=default");
|
|
||||||
...
|
|
||||||
EVP_MD_free(md);
|
|
||||||
|
|
||||||
Fetch an implementation of SHA2-256 from the default provider in the specified
|
|
||||||
context:
|
|
||||||
|
|
||||||
EVP_MD *md = EVP_MD_fetch(ctx, "SHA2-256", "provider=default");
|
|
||||||
...
|
|
||||||
EVP_MD_free(md);
|
|
||||||
|
|
||||||
Load the legacy provider into the default context and then fetch an
|
|
||||||
implementation of WHIRLPOOL from it:
|
|
||||||
|
|
||||||
/* This only needs to be done once - usually at application start up */
|
|
||||||
OSSL_PROVIDER *legacy = OSSL_PROVIDER_load(NULL, "legacy");
|
|
||||||
|
|
||||||
EVP_MD *md = EVP_MD_fetch(NULL, "WHIRLPOOL", "provider=legacy");
|
|
||||||
...
|
|
||||||
EVP_MD_free(md);
|
|
||||||
|
|
||||||
Note that in the above example the property string "provider=legacy" is optional
|
|
||||||
since, assuming no other providers have been loaded, the only implementation of
|
|
||||||
the "whirlpool" algorithm is in the "legacy" provider. Also note that the
|
|
||||||
default provider should be explicitly loaded if it is required in addition to
|
|
||||||
other providers:
|
|
||||||
|
|
||||||
/* This only needs to be done once - usually at application start up */
|
|
||||||
OSSL_PROVIDER *legacy = OSSL_PROVIDER_load(NULL, "legacy");
|
|
||||||
OSSL_PROVIDER *default = OSSL_PROVIDER_load(NULL, "default");
|
|
||||||
|
|
||||||
EVP_MD *md_whirlpool = EVP_MD_fetch(NULL, "whirlpool", NULL);
|
|
||||||
EVP_MD *md_sha256 = EVP_MD_fetch(NULL, "SHA2-256", NULL);
|
|
||||||
...
|
|
||||||
EVP_MD_free(md_whirlpool);
|
|
||||||
EVP_MD_free(md_sha256);
|
|
||||||
|
|
||||||
=head1 OPENSSL PROVIDERS
|
|
||||||
|
|
||||||
OpenSSL comes with a set of providers.
|
|
||||||
|
|
||||||
The algorithms available in each of these providers may vary due to build time
|
|
||||||
configuration options. The L<openssl-list(1)> command can be used to list the
|
|
||||||
currently available algorithms.
|
|
||||||
|
|
||||||
The names of the algorithms shown from L<openssl-list(1)> can be used as an
|
|
||||||
algorithm identifier to the appropriate fetching function. Also see the provider
|
|
||||||
specific manual pages linked below for further details about using the
|
|
||||||
algorithms available in each of the providers.
|
|
||||||
|
|
||||||
As well as the OpenSSL providers third parties can also implement providers.
|
|
||||||
For information on writing a provider see L<provider(7)>.
|
|
||||||
|
|
||||||
=head2 Default provider
|
|
||||||
|
|
||||||
The default provider is built in as part of the F<libcrypto> library and
|
|
||||||
contains all of the most commonly used algorithm implementations. Should it be
|
|
||||||
needed (if other providers are loaded and offer implementations of the same
|
|
||||||
algorithms), the property query string "provider=default" can be used as a
|
|
||||||
search criterion for these implementations. The default provider includes all
|
|
||||||
of the functionality in the base provider below.
|
|
||||||
|
|
||||||
If you don't load any providers at all then the "default" provider will be
|
|
||||||
automatically loaded. If you explicitly load any provider then the "default"
|
|
||||||
provider would also need to be explicitly loaded if it is required.
|
|
||||||
|
|
||||||
See L<OSSL_PROVIDER-default(7)>.
|
|
||||||
|
|
||||||
=head2 Base provider
|
|
||||||
|
|
||||||
The base provider is built in as part of the F<libcrypto> library and contains
|
|
||||||
algorithm implementations for encoding and decoding for OpenSSL keys.
|
|
||||||
Should it be needed (if other providers are loaded and offer
|
|
||||||
implementations of the same algorithms), the property query string
|
|
||||||
"provider=base" can be used as a search criterion for these implementations.
|
|
||||||
Some encoding and decoding algorithm implementations are not FIPS algorithm
|
|
||||||
implementations in themselves but support algorithms from the FIPS provider and
|
|
||||||
are allowed for use in "FIPS mode". The property query string "fips=yes" can be
|
|
||||||
used to select such algorithms.
|
|
||||||
|
|
||||||
See L<OSSL_PROVIDER-base(7)>.
|
|
||||||
|
|
||||||
=head2 FIPS provider
|
|
||||||
|
|
||||||
The FIPS provider is a dynamically loadable module, and must therefore
|
|
||||||
be loaded explicitly, either in code or through OpenSSL configuration
|
|
||||||
(see L<config(5)>). It contains algorithm implementations that have been
|
|
||||||
validated according to the FIPS 140-2 standard. Should it be needed (if other
|
|
||||||
providers are loaded and offer implementations of the same algorithms), the
|
|
||||||
property query string "provider=fips" can be used as a search criterion for
|
|
||||||
these implementations. All approved algorithm implementations in the FIPS
|
|
||||||
provider can also be selected with the property "fips=yes". The FIPS provider
|
|
||||||
may also contain non-approved algorithm implementations and these can be
|
|
||||||
selected with the property "fips=no".
|
|
||||||
|
|
||||||
See L<OSSL_PROVIDER-FIPS(7)> and L<fips_module(7)>.
|
|
||||||
|
|
||||||
=head2 Legacy provider
|
|
||||||
|
|
||||||
The legacy provider is a dynamically loadable module, and must therefore
|
|
||||||
be loaded explicitly, either in code or through OpenSSL configuration
|
|
||||||
(see L<config(5)>). It contains algorithm implementations that are considered
|
|
||||||
insecure, or are no longer in common use such as MD2 or RC4. Should it be needed
|
|
||||||
(if other providers are loaded and offer implementations of the same algorithms),
|
|
||||||
the property "provider=legacy" can be used as a search criterion for these
|
|
||||||
implementations.
|
|
||||||
|
|
||||||
See L<OSSL_PROVIDER-legacy(7)>.
|
|
||||||
|
|
||||||
=head2 Null provider
|
|
||||||
|
|
||||||
The null provider is built in as part of the F<libcrypto> library. It contains
|
|
||||||
no algorithms in it at all. When fetching algorithms the default provider will
|
|
||||||
be automatically loaded if no other provider has been explicitly loaded. To
|
|
||||||
prevent that from happening you can explicitly load the null provider.
|
|
||||||
|
|
||||||
See L<OSSL_PROVIDER-null(7)>.
|
|
||||||
|
|
||||||
=head1 USING ALGORITHMS IN APPLICATIONS
|
|
||||||
|
|
||||||
Cryptographic algorithms are made available to applications through use of the
|
|
||||||
"EVP" APIs. Each of the various operations such as encryption, digesting,
|
|
||||||
message authentication codes, etc., have a set of EVP function calls that can
|
|
||||||
be invoked to use them. See the L<evp(7)> page for further details.
|
|
||||||
|
|
||||||
Most of these follow a common pattern. A "context" object is first created. For
|
|
||||||
example for a digest operation you would use an B<EVP_MD_CTX>, and for an
|
|
||||||
encryption/decryption operation you would use an B<EVP_CIPHER_CTX>. The
|
|
||||||
operation is then initialised ready for use via an "init" function - optionally
|
|
||||||
passing in a set of parameters (using the L<OSSL_PARAM(3)> type) to configure how
|
|
||||||
the operation should behave. Next data is fed into the operation in a series of
|
|
||||||
"update" calls. The operation is finalised using a "final" call which will
|
|
||||||
typically provide some kind of output. Finally the context is cleaned up and
|
|
||||||
freed.
|
|
||||||
|
|
||||||
The following shows a complete example for doing this process for digesting
|
|
||||||
data using SHA256. The process is similar for other operations such as
|
|
||||||
encryption/decryption, signatures, message authentication codes, etc.
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
#include <openssl/bio.h>
|
|
||||||
#include <openssl/err.h>
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
EVP_MD_CTX *ctx = NULL;
|
|
||||||
EVP_MD *sha256 = NULL;
|
|
||||||
const unsigned char msg[] = {
|
|
||||||
0x00, 0x01, 0x02, 0x03
|
|
||||||
};
|
|
||||||
unsigned int len = 0;
|
|
||||||
unsigned char *outdigest = NULL;
|
|
||||||
int ret = 1;
|
|
||||||
|
|
||||||
/* Create a context for the digest operation */
|
|
||||||
ctx = EVP_MD_CTX_new();
|
|
||||||
if (ctx == NULL)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fetch the SHA256 algorithm implementation for doing the digest. We're
|
|
||||||
* using the "default" library context here (first NULL parameter), and
|
|
||||||
* we're not supplying any particular search criteria for our SHA256
|
|
||||||
* implementation (second NULL parameter). Any SHA256 implementation will
|
|
||||||
* do.
|
|
||||||
* In a larger application this fetch would just be done once, and could
|
|
||||||
* be used for multiple calls to other operations such as EVP_DigestInit_ex().
|
|
||||||
*/
|
|
||||||
sha256 = EVP_MD_fetch(NULL, "SHA256", NULL);
|
|
||||||
if (sha256 == NULL)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
/* Initialise the digest operation */
|
|
||||||
if (!EVP_DigestInit_ex(ctx, sha256, NULL))
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Pass the message to be digested. This can be passed in over multiple
|
|
||||||
* EVP_DigestUpdate calls if necessary
|
|
||||||
*/
|
|
||||||
if (!EVP_DigestUpdate(ctx, msg, sizeof(msg)))
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
/* Allocate the output buffer */
|
|
||||||
outdigest = OPENSSL_malloc(EVP_MD_get_size(sha256));
|
|
||||||
if (outdigest == NULL)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
/* Now calculate the digest itself */
|
|
||||||
if (!EVP_DigestFinal_ex(ctx, outdigest, &len))
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
/* Print out the digest result */
|
|
||||||
BIO_dump_fp(stdout, outdigest, len);
|
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
err:
|
|
||||||
/* Clean up all the resources we allocated */
|
|
||||||
OPENSSL_free(outdigest);
|
|
||||||
EVP_MD_free(sha256);
|
|
||||||
EVP_MD_CTX_free(ctx);
|
|
||||||
if (ret != 0)
|
|
||||||
ERR_print_errors_fp(stderr);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
=head1 CONFIGURATION
|
|
||||||
|
|
||||||
By default OpenSSL will load a configuration file when it is first used. This
|
|
||||||
will set up various configuration settings within the default library context.
|
|
||||||
Applications that create their own library contexts may optionally configure
|
|
||||||
them with a config file using the L<OSSL_LIB_CTX_load_config(3)> function.
|
|
||||||
|
|
||||||
The configuration file can be used to automatically load providers and set up
|
|
||||||
default property query strings.
|
|
||||||
|
|
||||||
For information on the OpenSSL configuration file format see L<config(5)>.
|
|
||||||
|
|
||||||
=head1 ENCODING AND DECODING KEYS
|
|
||||||
|
|
||||||
Many algorithms require the use of a key. Keys can be generated dynamically
|
|
||||||
using the EVP APIs (for example see L<EVP_PKEY_Q_keygen(3)>). However it is often
|
|
||||||
necessary to save or load keys (or their associated parameters) to or from some
|
|
||||||
external format such as PEM or DER (see L<openssl-glossary(7)>). OpenSSL uses
|
|
||||||
encoders and decoders to perform this task.
|
|
||||||
|
|
||||||
Encoders and decoders are just algorithm implementations in the same way as
|
|
||||||
any other algorithm implementation in OpenSSL. They are implemented by
|
|
||||||
providers. The OpenSSL encoders and decoders are available in the default
|
|
||||||
provider. They are also duplicated in the base provider.
|
|
||||||
|
|
||||||
For information about encoders see L<OSSL_ENCODER_CTX_new_for_pkey(3)>. For
|
|
||||||
information about decoders see L<OSSL_DECODER_CTX_new_for_pkey(3)>.
|
|
||||||
|
|
||||||
=head1 LIBRARY CONVENTIONS
|
|
||||||
|
|
||||||
Many OpenSSL functions that "get" or "set" a value follow a naming convention
|
|
||||||
using the numbers B<0> and B<1>, i.e. "get0", "get1", "set0" and "set1". This
|
|
||||||
can also apply to some functions that "add" a value to an existing set, i.e.
|
|
||||||
"add0" and "add1".
|
|
||||||
|
|
||||||
For example the functions:
|
|
||||||
|
|
||||||
int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
|
|
||||||
int X509_add1_trust_object(X509 *x, const ASN1_OBJECT *obj);
|
|
||||||
|
|
||||||
In the B<0> version the ownership of the object is passed to (for an add or set)
|
|
||||||
or retained by (for a get) the parent object. For example after calling the
|
|
||||||
X509_CRL_add0_revoked() function above, ownership of the I<rev> object is passed
|
|
||||||
to the I<crl> object. Therefore, after calling this function I<rev> should not
|
|
||||||
be freed directly. It will be freed implicitly when I<crl> is freed.
|
|
||||||
|
|
||||||
In the B<1> version the ownership of the object is not passed to or retained by
|
|
||||||
the parent object. Instead a copy or "up ref" of the object is performed. So
|
|
||||||
after calling the X509_add1_trust_object() function above the application will
|
|
||||||
still be responsible for freeing the I<obj> value where appropriate.
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
L<openssl(1)>, L<ssl(7)>, L<evp(7)>, L<OSSL_LIB_CTX(3)>, L<openssl-threads(7)>,
|
|
||||||
L<property(7)>, L<OSSL_PROVIDER-default(7)>, L<OSSL_PROVIDER-base(7)>,
|
|
||||||
L<OSSL_PROVIDER-FIPS(7)>, L<OSSL_PROVIDER-legacy(7)>, L<OSSL_PROVIDER-null(7)>,
|
|
||||||
L<openssl-glossary(7)>, L<provider(7)>
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2000-2023 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 56 KiB |
@@ -1,221 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
life_cycle-digest - The digest algorithm life-cycle
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
All message digests (MDs) go through a number of stages in their life-cycle:
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item start
|
|
||||||
|
|
||||||
This state represents the MD before it has been allocated. It is the
|
|
||||||
starting state for any life-cycle transitions.
|
|
||||||
|
|
||||||
=item newed
|
|
||||||
|
|
||||||
This state represents the MD after it has been allocated.
|
|
||||||
|
|
||||||
=item initialised
|
|
||||||
|
|
||||||
This state represents the MD when it is set up and capable of processing
|
|
||||||
input.
|
|
||||||
|
|
||||||
=item updated
|
|
||||||
|
|
||||||
This state represents the MD when it is set up and capable of processing
|
|
||||||
additional input or generating output.
|
|
||||||
|
|
||||||
=item finaled
|
|
||||||
|
|
||||||
This state represents the MD when it has generated output.
|
|
||||||
|
|
||||||
=item freed
|
|
||||||
|
|
||||||
This state is entered when the MD is freed. It is the terminal state
|
|
||||||
for all life-cycle transitions.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=head2 State Transition Diagram
|
|
||||||
|
|
||||||
The usual life-cycle of a MD is illustrated:
|
|
||||||
|
|
||||||
=begin man
|
|
||||||
|
|
||||||
+-------------------+
|
|
||||||
| start |
|
|
||||||
+-------------------+
|
|
||||||
|
|
|
||||||
| EVP_MD_CTX_new
|
|
||||||
v
|
|
||||||
+-------------------+ EVP_MD_CTX_reset
|
|
||||||
| newed | <------------------------------+
|
|
||||||
+-------------------+ |
|
|
||||||
| |
|
|
||||||
| EVP_DigestInit |
|
|
||||||
v |
|
|
||||||
+-------------------+ |
|
|
||||||
+--> | initialised | <+ EVP_DigestInit |
|
|
||||||
| +-------------------+ | |
|
|
||||||
| | | EVP_DigestUpdate |
|
|
||||||
| | EVP_DigestUpdate | +------------------+ |
|
|
||||||
| v | v | |
|
|
||||||
| +------------------------------------------------+ |
|
|
||||||
EVP_DigestInit | | updated | --+
|
|
||||||
| +------------------------------------------------+ |
|
|
||||||
| | | |
|
|
||||||
| | EVP_DigestFinal | EVP_DigestFinalXOF |
|
|
||||||
| v v |
|
|
||||||
| +------------------------------------------------+ |
|
|
||||||
+--- | finaled | --+
|
|
||||||
+------------------------------------------------+
|
|
||||||
|
|
|
||||||
| EVP_MD_CTX_free
|
|
||||||
v
|
|
||||||
+-------------------+
|
|
||||||
| freed |
|
|
||||||
+-------------------+
|
|
||||||
|
|
||||||
=end man
|
|
||||||
|
|
||||||
=for html <img src="img/digest.png">
|
|
||||||
|
|
||||||
=head2 Formal State Transitions
|
|
||||||
|
|
||||||
This section defines all of the legal state transitions.
|
|
||||||
This is the canonical list.
|
|
||||||
|
|
||||||
=begin man
|
|
||||||
|
|
||||||
Function Call --------------------- Current State ----------------------
|
|
||||||
start newed initialised updated finaled freed
|
|
||||||
EVP_MD_CTX_new newed
|
|
||||||
EVP_DigestInit initialised initialised initialised initialised
|
|
||||||
EVP_DigestUpdate updated updated
|
|
||||||
EVP_DigestFinal finaled
|
|
||||||
EVP_DigestFinalXOF finaled
|
|
||||||
EVP_MD_CTX_free freed freed freed freed freed
|
|
||||||
EVP_MD_CTX_reset newed newed newed newed
|
|
||||||
EVP_MD_CTX_get_params newed initialised updated
|
|
||||||
EVP_MD_CTX_set_params newed initialised updated
|
|
||||||
EVP_MD_CTX_gettable_params newed initialised updated
|
|
||||||
EVP_MD_CTX_settable_params newed initialised updated
|
|
||||||
|
|
||||||
=end man
|
|
||||||
|
|
||||||
=begin html
|
|
||||||
|
|
||||||
<table style="border:1px solid; border-collapse:collapse">
|
|
||||||
<tr><th style="border:1px solid" align="left">Function Call</th>
|
|
||||||
<th style="border:1px solid" colspan="6">Current State</th></tr>
|
|
||||||
<tr><th style="border:1px solid"></th>
|
|
||||||
<th style="border:1px solid" align="center">start</th>
|
|
||||||
<th style="border:1px solid" align="center">newed</th>
|
|
||||||
<th style="border:1px solid" align="center">initialised</th>
|
|
||||||
<th style="border:1px solid" align="center">updated</th>
|
|
||||||
<th style="border:1px solid" align="center">finaled</th>
|
|
||||||
<th style="border:1px solid" align="center">freed</th></tr>
|
|
||||||
<tr><th style="border:1px solid" align="left">EVP_MD_CTX_new</th>
|
|
||||||
<td style="border:1px solid" align="center">newed</td>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center"></td></tr>
|
|
||||||
<tr><th style="border:1px solid" align="left">EVP_DigestInit</th>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center">initialised</td>
|
|
||||||
<td style="border:1px solid" align="center">initialised</td>
|
|
||||||
<td style="border:1px solid" align="center">initialised</td>
|
|
||||||
<td style="border:1px solid" align="center">initialised</td>
|
|
||||||
<td style="border:1px solid" align="center"></td></tr>
|
|
||||||
<tr><th style="border:1px solid" align="left">EVP_DigestUpdate</th>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center">updated</td>
|
|
||||||
<td style="border:1px solid" align="center">updated</td>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center"></td></tr>
|
|
||||||
<tr><th style="border:1px solid" align="left">EVP_DigestFinal</th>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center">finaled</td>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center"></td></tr>
|
|
||||||
<tr><th style="border:1px solid" align="left">EVP_DigestFinalXOF</th>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center">finaled</td>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center"></td></tr>
|
|
||||||
<tr><th style="border:1px solid" align="left">EVP_MD_CTX_free</th>
|
|
||||||
<td style="border:1px solid" align="center">freed</td>
|
|
||||||
<td style="border:1px solid" align="center">freed</td>
|
|
||||||
<td style="border:1px solid" align="center">freed</td>
|
|
||||||
<td style="border:1px solid" align="center">freed</td>
|
|
||||||
<td style="border:1px solid" align="center">freed</td>
|
|
||||||
<td style="border:1px solid" align="center"></td></tr>
|
|
||||||
<tr><th style="border:1px solid" align="left">EVP_MD_CTX_reset</th>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center">newed</td>
|
|
||||||
<td style="border:1px solid" align="center">newed</td>
|
|
||||||
<td style="border:1px solid" align="center">newed</td>
|
|
||||||
<td style="border:1px solid" align="center">newed</td>
|
|
||||||
<td style="border:1px solid" align="center"></td></tr>
|
|
||||||
<tr><th style="border:1px solid" align="left">EVP_MD_CTX_get_params</th>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center">newed</td>
|
|
||||||
<td style="border:1px solid" align="center">initialised</td>
|
|
||||||
<td style="border:1px solid" align="center">updated</td>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center"></td></tr>
|
|
||||||
<tr><th style="border:1px solid" align="left">EVP_MD_CTX_set_params</th>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center">newed</td>
|
|
||||||
<td style="border:1px solid" align="center">initialised</td>
|
|
||||||
<td style="border:1px solid" align="center">updated</td>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center"></td></tr>
|
|
||||||
<tr><th style="border:1px solid" align="left">EVP_MD_CTX_gettable_params</th>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center">newed</td>
|
|
||||||
<td style="border:1px solid" align="center">initialised</td>
|
|
||||||
<td style="border:1px solid" align="center">updated</td>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center"></td></tr>
|
|
||||||
<tr><th style="border:1px solid" align="left">EVP_MD_CTX_settable_params</th>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center">newed</td>
|
|
||||||
<td style="border:1px solid" align="center">initialised</td>
|
|
||||||
<td style="border:1px solid" align="center">updated</td>
|
|
||||||
<td style="border:1px solid" align="center"></td>
|
|
||||||
<td style="border:1px solid" align="center"></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
=end html
|
|
||||||
|
|
||||||
=head1 NOTES
|
|
||||||
|
|
||||||
At some point the EVP layer will begin enforcing the transitions described
|
|
||||||
herein.
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
L<provider-digest(7)>, L<EVP_DigestInit(3)>
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2021 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
openssl-env - OpenSSL environment variables
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
The OpenSSL libraries use environment variables to override the
|
|
||||||
compiled-in default paths for various data.
|
|
||||||
To avoid security risks, the environment is usually not consulted when
|
|
||||||
the executable is set-user-ID or set-group-ID.
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item B<CTLOG_FILE>
|
|
||||||
|
|
||||||
Specifies the path to a certificate transparency log list.
|
|
||||||
See L<CTLOG_STORE_new(3)>.
|
|
||||||
|
|
||||||
=item B<OPENSSL>
|
|
||||||
|
|
||||||
Specifies the path to the B<openssl> executable. Used by
|
|
||||||
the B<rehash> script (see L<openssl-rehash(1)/Script Configuration>)
|
|
||||||
and by the B<CA.pl> script (see L<CA.pl(1)/NOTES>
|
|
||||||
|
|
||||||
=item B<OPENSSL_CONF>, B<OPENSSL_CONF_INCLUDE>
|
|
||||||
|
|
||||||
Specifies the path to a configuration file and the directory for
|
|
||||||
included files.
|
|
||||||
See L<config(5)>.
|
|
||||||
|
|
||||||
=item B<OPENSSL_CONFIG>
|
|
||||||
|
|
||||||
Specifies a configuration option and filename for the B<req> and B<ca>
|
|
||||||
commands invoked by the B<CA.pl> script.
|
|
||||||
See L<CA.pl(1)>.
|
|
||||||
|
|
||||||
=item B<OPENSSL_ENGINES>
|
|
||||||
|
|
||||||
Specifies the directory from which dynamic engines are loaded.
|
|
||||||
See L<openssl-engine(1)>.
|
|
||||||
|
|
||||||
=item B<OPENSSL_MALLOC_FD>, B<OPENSSL_MALLOC_FAILURES>
|
|
||||||
|
|
||||||
If built with debugging, this allows memory allocation to fail.
|
|
||||||
See L<OPENSSL_malloc(3)>.
|
|
||||||
|
|
||||||
=item B<OPENSSL_MODULES>
|
|
||||||
|
|
||||||
Specifies the directory from which cryptographic providers are loaded.
|
|
||||||
Equivalently, the generic B<-provider-path> command-line option may be used.
|
|
||||||
|
|
||||||
=item B<OPENSSL_WIN32_UTF8>
|
|
||||||
|
|
||||||
If set, then L<UI_OpenSSL(3)> returns UTF-8 encoded strings, rather than
|
|
||||||
ones encoded in the current code page, and
|
|
||||||
the L<openssl(1)> program also transcodes the command-line parameters
|
|
||||||
from the current code page to UTF-8.
|
|
||||||
This environment variable is only checked on Microsoft Windows platforms.
|
|
||||||
|
|
||||||
=item B<RANDFILE>
|
|
||||||
|
|
||||||
The state file for the random number generator.
|
|
||||||
This should not be needed in normal use.
|
|
||||||
See L<RAND_load_file(3)>.
|
|
||||||
|
|
||||||
=item B<SSL_CERT_DIR>, B<SSL_CERT_FILE>
|
|
||||||
|
|
||||||
Specify the default directory or file containing CA certificates.
|
|
||||||
See L<SSL_CTX_load_verify_locations(3)>.
|
|
||||||
|
|
||||||
=item B<TSGET>
|
|
||||||
|
|
||||||
Additional arguments for the L<tsget(1)> command.
|
|
||||||
|
|
||||||
=item B<OPENSSL_ia32cap>, B<OPENSSL_sparcv9cap>, B<OPENSSL_ppccap>, B<OPENSSL_armcap>, B<OPENSSL_s390xcap>, B<OPENSSL_riscvcap>
|
|
||||||
|
|
||||||
OpenSSL supports a number of different algorithm implementations for
|
|
||||||
various machines and, by default, it determines which to use based on the
|
|
||||||
processor capabilities and run time feature enquiry. These environment
|
|
||||||
variables can be used to exert more control over this selection process.
|
|
||||||
See L<OPENSSL_ia32cap(3)>, L<OPENSSL_s390xcap(3)>.
|
|
||||||
|
|
||||||
=item B<NO_PROXY>, B<HTTPS_PROXY>, B<HTTP_PROXY>
|
|
||||||
|
|
||||||
Specify a proxy hostname.
|
|
||||||
See L<OSSL_HTTP_parse_url(3)>.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2019-2022 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
=pod
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
ssl - OpenSSL SSL/TLS library
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
See the individual manual pages for details.
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
The OpenSSL B<ssl> library implements several versions of the
|
|
||||||
Secure Sockets Layer, Transport Layer Security, and Datagram Transport Layer
|
|
||||||
Security protocols.
|
|
||||||
This page gives a brief overview of the extensive API and data types
|
|
||||||
provided by the library.
|
|
||||||
|
|
||||||
An B<SSL_CTX> object is created as a framework to establish
|
|
||||||
TLS/SSL enabled connections (see L<SSL_CTX_new(3)>).
|
|
||||||
Various options regarding certificates, algorithms etc. can be set
|
|
||||||
in this object.
|
|
||||||
|
|
||||||
When a network connection has been created, it can be assigned to an
|
|
||||||
B<SSL> object. After the B<SSL> object has been created using
|
|
||||||
L<SSL_new(3)>, L<SSL_set_fd(3)> or
|
|
||||||
L<SSL_set_bio(3)> can be used to associate the network
|
|
||||||
connection with the object.
|
|
||||||
|
|
||||||
When the TLS/SSL handshake is performed using
|
|
||||||
L<SSL_accept(3)> or L<SSL_connect(3)>
|
|
||||||
respectively.
|
|
||||||
L<SSL_read_ex(3)>, L<SSL_read(3)>, L<SSL_write_ex(3)> and L<SSL_write(3)> are
|
|
||||||
used to read and write data on the TLS/SSL connection.
|
|
||||||
L<SSL_shutdown(3)> can be used to shut down the
|
|
||||||
TLS/SSL connection.
|
|
||||||
|
|
||||||
=head1 DATA STRUCTURES
|
|
||||||
|
|
||||||
Here are some of the main data structures in the library.
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item B<SSL_METHOD> (SSL Method)
|
|
||||||
|
|
||||||
This is a dispatch structure describing the internal B<ssl> library
|
|
||||||
methods/functions which implement the various protocol versions (SSLv3
|
|
||||||
TLSv1, ...). It's needed to create an B<SSL_CTX>.
|
|
||||||
|
|
||||||
=item B<SSL_CIPHER> (SSL Cipher)
|
|
||||||
|
|
||||||
This structure holds the algorithm information for a particular cipher which
|
|
||||||
are a core part of the SSL/TLS protocol. The available ciphers are configured
|
|
||||||
on a B<SSL_CTX> basis and the actual ones used are then part of the
|
|
||||||
B<SSL_SESSION>.
|
|
||||||
|
|
||||||
=item B<SSL_CTX> (SSL Context)
|
|
||||||
|
|
||||||
This is the global context structure which is created by a server or client
|
|
||||||
once per program life-time and which holds mainly default values for the
|
|
||||||
B<SSL> structures which are later created for the connections.
|
|
||||||
|
|
||||||
=item B<SSL_SESSION> (SSL Session)
|
|
||||||
|
|
||||||
This is a structure containing the current TLS/SSL session details for a
|
|
||||||
connection: B<SSL_CIPHER>s, client and server certificates, keys, etc.
|
|
||||||
|
|
||||||
=item B<SSL> (SSL Connection)
|
|
||||||
|
|
||||||
This is the main SSL/TLS structure which is created by a server or client per
|
|
||||||
established connection. This actually is the core structure in the SSL API.
|
|
||||||
At run-time the application usually deals with this structure which has
|
|
||||||
links to mostly all other structures.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=head1 HEADER FILES
|
|
||||||
|
|
||||||
Currently the OpenSSL B<ssl> library provides the following C header files
|
|
||||||
containing the prototypes for the data structures and functions:
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item F<< <openssl/ssl.h> >>
|
|
||||||
|
|
||||||
This is the common header file for the SSL/TLS API. Include it into your
|
|
||||||
program to make the API of the B<ssl> library available. It internally
|
|
||||||
includes both more private SSL headers and headers from the B<crypto> library.
|
|
||||||
Whenever you need hard-core details on the internals of the SSL API, look
|
|
||||||
inside this header file.
|
|
||||||
This file also includes the others listed below.
|
|
||||||
|
|
||||||
=item F<< <openssl/ssl2.h> >>
|
|
||||||
|
|
||||||
Unused. Present for backwards compatibility only.
|
|
||||||
|
|
||||||
=item F<< <openssl/ssl3.h> >>
|
|
||||||
|
|
||||||
This is the sub header file dealing with the SSLv3 protocol only.
|
|
||||||
|
|
||||||
=item F<< <openssl/tls1.h> >>
|
|
||||||
|
|
||||||
This is the sub header file dealing with the TLSv1 protocol only.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
|
||||||
|
|
||||||
Copyright 2000-2018 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
|
|
||||||
L<https://www.openssl.org/source/license.html>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
@@ -1,156 +0,0 @@
|
|||||||
{- use File::Spec::Functions;
|
|
||||||
our $ex_inc = $withargs{fuzzer_include} &&
|
|
||||||
(file_name_is_absolute($withargs{fuzzer_include}) ?
|
|
||||||
$withargs{fuzzer_include} : catdir(updir(), $withargs{fuzzer_include}));
|
|
||||||
our $ex_lib = $withargs{fuzzer_lib} &&
|
|
||||||
(file_name_is_absolute($withargs{fuzzer_lib}) ?
|
|
||||||
$withargs{fuzzer_lib} : catfile(updir(), $withargs{fuzzer_lib}));
|
|
||||||
""
|
|
||||||
-}
|
|
||||||
|
|
||||||
IF[{- !$disabled{"fuzz-afl"} || !$disabled{"fuzz-libfuzzer"} -}]
|
|
||||||
PROGRAMS{noinst}=asn1 asn1parse bignum bndiv client conf crl server
|
|
||||||
PROGRAMS{noinst}=punycode
|
|
||||||
|
|
||||||
IF[{- !$disabled{"cmp"} -}]
|
|
||||||
PROGRAMS{noinst}=cmp
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
IF[{- !$disabled{"cms"} -}]
|
|
||||||
PROGRAMS{noinst}=cms
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
IF[{- !$disabled{"ct"} -}]
|
|
||||||
PROGRAMS{noinst}=ct
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
IF[{- !$disabled{"ocsp"} -}]
|
|
||||||
PROGRAMS{noinst}=x509
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
SOURCE[asn1]=asn1.c driver.c fuzz_rand.c
|
|
||||||
INCLUDE[asn1]=../include {- $ex_inc -}
|
|
||||||
DEPEND[asn1]=../libcrypto ../libssl {- $ex_lib -}
|
|
||||||
|
|
||||||
SOURCE[asn1parse]=asn1parse.c driver.c
|
|
||||||
INCLUDE[asn1parse]=../include {- $ex_inc -}
|
|
||||||
DEPEND[asn1parse]=../libcrypto {- $ex_lib -}
|
|
||||||
|
|
||||||
SOURCE[bignum]=bignum.c driver.c
|
|
||||||
INCLUDE[bignum]=../include {- $ex_inc -}
|
|
||||||
DEPEND[bignum]=../libcrypto {- $ex_lib -}
|
|
||||||
|
|
||||||
SOURCE[bndiv]=bndiv.c driver.c
|
|
||||||
INCLUDE[bndiv]=../include {- $ex_inc -}
|
|
||||||
DEPEND[bndiv]=../libcrypto {- $ex_lib -}
|
|
||||||
|
|
||||||
SOURCE[client]=client.c driver.c fuzz_rand.c
|
|
||||||
INCLUDE[client]=../include {- $ex_inc -}
|
|
||||||
DEPEND[client]=../libcrypto ../libssl {- $ex_lib -}
|
|
||||||
|
|
||||||
SOURCE[cmp]=cmp.c driver.c fuzz_rand.c
|
|
||||||
INCLUDE[cmp]=../include {- $ex_inc -}
|
|
||||||
DEPEND[cmp]=../libcrypto {- $ex_lib -}
|
|
||||||
|
|
||||||
SOURCE[cms]=cms.c driver.c
|
|
||||||
INCLUDE[cms]=../include {- $ex_inc -}
|
|
||||||
DEPEND[cms]=../libcrypto {- $ex_lib -}
|
|
||||||
|
|
||||||
SOURCE[conf]=conf.c driver.c
|
|
||||||
INCLUDE[conf]=../include {- $ex_inc -}
|
|
||||||
DEPEND[conf]=../libcrypto {- $ex_lib -}
|
|
||||||
|
|
||||||
SOURCE[crl]=crl.c driver.c
|
|
||||||
INCLUDE[crl]=../include {- $ex_inc -}
|
|
||||||
DEPEND[crl]=../libcrypto {- $ex_lib -}
|
|
||||||
|
|
||||||
SOURCE[ct]=ct.c driver.c
|
|
||||||
INCLUDE[ct]=../include {- $ex_inc -}
|
|
||||||
DEPEND[ct]=../libcrypto {- $ex_lib -}
|
|
||||||
|
|
||||||
SOURCE[punycode]=punycode.c driver.c
|
|
||||||
INCLUDE[punycode]=../include {- $ex_inc -}
|
|
||||||
DEPEND[punycode]=../libcrypto.a {- $ex_lib -}
|
|
||||||
|
|
||||||
SOURCE[server]=server.c driver.c fuzz_rand.c
|
|
||||||
INCLUDE[server]=../include {- $ex_inc -}
|
|
||||||
DEPEND[server]=../libcrypto ../libssl {- $ex_lib -}
|
|
||||||
|
|
||||||
SOURCE[x509]=x509.c driver.c fuzz_rand.c
|
|
||||||
INCLUDE[x509]=../include {- $ex_inc -}
|
|
||||||
DEPEND[x509]=../libcrypto {- $ex_lib -}
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
IF[{- !$disabled{tests} -}]
|
|
||||||
PROGRAMS{noinst}=asn1-test asn1parse-test bignum-test bndiv-test client-test conf-test crl-test server-test
|
|
||||||
PROGRAMS{noinst}=punycode-test
|
|
||||||
|
|
||||||
IF[{- !$disabled{"cmp"} -}]
|
|
||||||
PROGRAMS{noinst}=cmp-test
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
IF[{- !$disabled{"cms"} -}]
|
|
||||||
PROGRAMS{noinst}=cms-test
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
IF[{- !$disabled{"ct"} -}]
|
|
||||||
PROGRAMS{noinst}=ct-test
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
IF[{- !$disabled{"ocsp"} -}]
|
|
||||||
PROGRAMS{noinst}=x509-test
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
SOURCE[asn1-test]=asn1.c test-corpus.c fuzz_rand.c
|
|
||||||
INCLUDE[asn1-test]=../include
|
|
||||||
DEPEND[asn1-test]=../libcrypto ../libssl
|
|
||||||
|
|
||||||
SOURCE[asn1parse-test]=asn1parse.c test-corpus.c
|
|
||||||
INCLUDE[asn1parse-test]=../include
|
|
||||||
DEPEND[asn1parse-test]=../libcrypto
|
|
||||||
|
|
||||||
SOURCE[bignum-test]=bignum.c test-corpus.c
|
|
||||||
INCLUDE[bignum-test]=../include
|
|
||||||
DEPEND[bignum-test]=../libcrypto
|
|
||||||
|
|
||||||
SOURCE[bndiv-test]=bndiv.c test-corpus.c
|
|
||||||
INCLUDE[bndiv-test]=../include
|
|
||||||
DEPEND[bndiv-test]=../libcrypto
|
|
||||||
|
|
||||||
SOURCE[client-test]=client.c test-corpus.c fuzz_rand.c
|
|
||||||
INCLUDE[client-test]=../include
|
|
||||||
DEPEND[client-test]=../libcrypto ../libssl
|
|
||||||
|
|
||||||
SOURCE[cmp-test]=cmp.c test-corpus.c fuzz_rand.c
|
|
||||||
INCLUDE[cmp-test]=../include
|
|
||||||
DEPEND[cmp-test]=../libcrypto.a
|
|
||||||
# referring to static lib allows using non-exported functions
|
|
||||||
|
|
||||||
SOURCE[cms-test]=cms.c test-corpus.c
|
|
||||||
INCLUDE[cms-test]=../include
|
|
||||||
DEPEND[cms-test]=../libcrypto
|
|
||||||
|
|
||||||
SOURCE[conf-test]=conf.c test-corpus.c
|
|
||||||
INCLUDE[conf-test]=../include
|
|
||||||
DEPEND[conf-test]=../libcrypto
|
|
||||||
|
|
||||||
SOURCE[crl-test]=crl.c test-corpus.c
|
|
||||||
INCLUDE[crl-test]=../include
|
|
||||||
DEPEND[crl-test]=../libcrypto
|
|
||||||
|
|
||||||
SOURCE[ct-test]=ct.c test-corpus.c
|
|
||||||
INCLUDE[ct-test]=../include
|
|
||||||
DEPEND[ct-test]=../libcrypto
|
|
||||||
|
|
||||||
SOURCE[punycode-test]=punycode.c test-corpus.c
|
|
||||||
INCLUDE[punycode-test]=../include
|
|
||||||
DEPEND[punycode-test]=../libcrypto.a
|
|
||||||
|
|
||||||
SOURCE[server-test]=server.c test-corpus.c fuzz_rand.c
|
|
||||||
INCLUDE[server-test]=../include
|
|
||||||
DEPEND[server-test]=../libcrypto ../libssl
|
|
||||||
|
|
||||||
SOURCE[x509-test]=x509.c test-corpus.c fuzz_rand.c
|
|
||||||
INCLUDE[x509-test]=../include
|
|
||||||
DEPEND[x509-test]=../libcrypto
|
|
||||||
ENDIF
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2022 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* X Macro Definitions for Specification of RISC-V Arch Capabilities */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Each RISC-V capability ends up encoded as a single set bit in an array of
|
|
||||||
* words. When specifying a new capability, write a new RISCV_DEFINE_CAP
|
|
||||||
* statement, with an argument as the extension name in all-caps,
|
|
||||||
* second argument as the index in the array where the capability will be stored
|
|
||||||
* and third argument as the index of the bit to be used to encode the
|
|
||||||
* capability.
|
|
||||||
* RISCV_DEFINE_CAP(EXTENSION NAME, array index, bit index) */
|
|
||||||
|
|
||||||
RISCV_DEFINE_CAP(ZBA, 0, 0)
|
|
||||||
RISCV_DEFINE_CAP(ZBB, 0, 1)
|
|
||||||
RISCV_DEFINE_CAP(ZBC, 0, 2)
|
|
||||||
RISCV_DEFINE_CAP(ZBS, 0, 3)
|
|
||||||
RISCV_DEFINE_CAP(ZBKB, 0, 4)
|
|
||||||
RISCV_DEFINE_CAP(ZBKC, 0, 5)
|
|
||||||
RISCV_DEFINE_CAP(ZBKX, 0, 6)
|
|
||||||
RISCV_DEFINE_CAP(ZKND, 0, 7)
|
|
||||||
RISCV_DEFINE_CAP(ZKNE, 0, 8)
|
|
||||||
RISCV_DEFINE_CAP(ZKNH, 0, 9)
|
|
||||||
RISCV_DEFINE_CAP(ZKSED, 0, 10)
|
|
||||||
RISCV_DEFINE_CAP(ZKSH, 0, 11)
|
|
||||||
RISCV_DEFINE_CAP(ZKR, 0, 12)
|
|
||||||
RISCV_DEFINE_CAP(ZKT, 0, 13)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* In the future ...
|
|
||||||
* RISCV_DEFINE_CAP(ZFOO, 0, 31)
|
|
||||||
* RISCV_DEFINE_CAP(ZBAR, 1, 0)
|
|
||||||
* ... and so on.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#undef RISCV_DEFINE_CAP
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2022 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OSSL_CRYPTO_RISCV_ARCH_H
|
|
||||||
# define OSSL_CRYPTO_RISCV_ARCH_H
|
|
||||||
|
|
||||||
# include <ctype.h>
|
|
||||||
# include <stdint.h>
|
|
||||||
|
|
||||||
# define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) +1
|
|
||||||
extern uint32_t OPENSSL_riscvcap_P[ ((
|
|
||||||
# include "riscv_arch.def"
|
|
||||||
) + sizeof(uint32_t) - 1) / sizeof(uint32_t) ];
|
|
||||||
|
|
||||||
# ifdef OPENSSL_RISCVCAP_IMPL
|
|
||||||
# define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) +1
|
|
||||||
uint32_t OPENSSL_riscvcap_P[ ((
|
|
||||||
# include "riscv_arch.def"
|
|
||||||
) + sizeof(uint32_t) - 1) / sizeof(uint32_t) ];
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) \
|
|
||||||
static inline int RISCV_HAS_##NAME(void) \
|
|
||||||
{ \
|
|
||||||
return (OPENSSL_riscvcap_P[INDEX] & (1 << BIT_INDEX)) != 0; \
|
|
||||||
}
|
|
||||||
# include "riscv_arch.def"
|
|
||||||
|
|
||||||
struct RISCV_capability_s {
|
|
||||||
const char *name;
|
|
||||||
size_t index;
|
|
||||||
size_t bit_offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
# define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) +1
|
|
||||||
extern const struct RISCV_capability_s RISCV_capabilities[
|
|
||||||
# include "riscv_arch.def"
|
|
||||||
];
|
|
||||||
|
|
||||||
# ifdef OPENSSL_RISCVCAP_IMPL
|
|
||||||
# define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) \
|
|
||||||
{ #NAME, INDEX, BIT_INDEX },
|
|
||||||
const struct RISCV_capability_s RISCV_capabilities[] = {
|
|
||||||
# include "riscv_arch.def"
|
|
||||||
};
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) +1
|
|
||||||
static const size_t kRISCVNumCaps =
|
|
||||||
# include "riscv_arch.def"
|
|
||||||
;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,198 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016-2023 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
|
|
||||||
*/
|
|
||||||
#ifndef OSSL_INTERNAL_REFCOUNT_H
|
|
||||||
# define OSSL_INTERNAL_REFCOUNT_H
|
|
||||||
# pragma once
|
|
||||||
|
|
||||||
# include <openssl/e_os2.h>
|
|
||||||
# include <openssl/trace.h>
|
|
||||||
|
|
||||||
# if defined(OPENSSL_THREADS) && !defined(OPENSSL_DEV_NO_ATOMICS)
|
|
||||||
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \
|
|
||||||
&& !defined(__STDC_NO_ATOMICS__)
|
|
||||||
# include <stdatomic.h>
|
|
||||||
# define HAVE_C11_ATOMICS
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# if defined(HAVE_C11_ATOMICS) && defined(ATOMIC_INT_LOCK_FREE) \
|
|
||||||
&& ATOMIC_INT_LOCK_FREE > 0
|
|
||||||
|
|
||||||
# define HAVE_ATOMICS 1
|
|
||||||
|
|
||||||
# if defined(OPENSSL_SYS_VXWORKS) && defined(_WRS_CONFIG_ARM_ARMV7M) && !defined(_WRS_CONFIG_SUPPORTS_LDREX_STREX)
|
|
||||||
|
|
||||||
typedef atomic32_t CRYPTO_REF_COUNT;
|
|
||||||
|
|
||||||
static inline int CRYPTO_UP_REF(_Atomic int *val, int *ret, void *lock)
|
|
||||||
{
|
|
||||||
vxAtomicInc(val);
|
|
||||||
*ret = *val;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int CRYPTO_DOWN_REF(_Atomic int *val, int *ret, void *lock)
|
|
||||||
{
|
|
||||||
vxAtomicDec(val);
|
|
||||||
*ret = *val;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
# else
|
|
||||||
|
|
||||||
typedef _Atomic int CRYPTO_REF_COUNT;
|
|
||||||
|
|
||||||
static inline int CRYPTO_UP_REF(_Atomic int *val, int *ret,
|
|
||||||
ossl_unused void *lock)
|
|
||||||
{
|
|
||||||
*ret = atomic_fetch_add_explicit(val, 1, memory_order_relaxed) + 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Changes to shared structure other than reference counter have to be
|
|
||||||
* serialized. And any kind of serialization implies a release fence. This
|
|
||||||
* means that by the time reference counter is decremented all other
|
|
||||||
* changes are visible on all processors. Hence decrement itself can be
|
|
||||||
* relaxed. In case it hits zero, object will be destructed. Since it's
|
|
||||||
* last use of the object, destructor programmer might reason that access
|
|
||||||
* to mutable members doesn't have to be serialized anymore, which would
|
|
||||||
* otherwise imply an acquire fence. Hence conditional acquire fence...
|
|
||||||
*/
|
|
||||||
static inline int CRYPTO_DOWN_REF(_Atomic int *val, int *ret,
|
|
||||||
ossl_unused void *lock)
|
|
||||||
{
|
|
||||||
*ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1;
|
|
||||||
if (*ret == 0)
|
|
||||||
atomic_thread_fence(memory_order_acquire);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# elif defined(__GNUC__) && defined(__ATOMIC_RELAXED) && __GCC_ATOMIC_INT_LOCK_FREE > 0
|
|
||||||
|
|
||||||
# define HAVE_ATOMICS 1
|
|
||||||
|
|
||||||
typedef int CRYPTO_REF_COUNT;
|
|
||||||
|
|
||||||
static __inline__ int CRYPTO_UP_REF(int *val, int *ret, ossl_unused void *lock)
|
|
||||||
{
|
|
||||||
*ret = __atomic_fetch_add(val, 1, __ATOMIC_RELAXED) + 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline__ int CRYPTO_DOWN_REF(int *val, int *ret,
|
|
||||||
ossl_unused void *lock)
|
|
||||||
{
|
|
||||||
*ret = __atomic_fetch_sub(val, 1, __ATOMIC_RELAXED) - 1;
|
|
||||||
if (*ret == 0)
|
|
||||||
__atomic_thread_fence(__ATOMIC_ACQUIRE);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
# elif defined(__ICL) && defined(_WIN32)
|
|
||||||
# define HAVE_ATOMICS 1
|
|
||||||
typedef volatile int CRYPTO_REF_COUNT;
|
|
||||||
|
|
||||||
static __inline int CRYPTO_UP_REF(volatile int *val, int *ret,
|
|
||||||
ossl_unused void *lock)
|
|
||||||
{
|
|
||||||
*ret = _InterlockedExchangeAdd((void *)val, 1) + 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret,
|
|
||||||
ossl_unused void *lock)
|
|
||||||
{
|
|
||||||
*ret = _InterlockedExchangeAdd((void *)val, -1) - 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
# elif defined(_MSC_VER) && _MSC_VER>=1200
|
|
||||||
|
|
||||||
# define HAVE_ATOMICS 1
|
|
||||||
|
|
||||||
typedef volatile int CRYPTO_REF_COUNT;
|
|
||||||
|
|
||||||
# if (defined(_M_ARM) && _M_ARM>=7 && !defined(_WIN32_WCE)) || defined(_M_ARM64)
|
|
||||||
# include <intrin.h>
|
|
||||||
# if defined(_M_ARM64) && !defined(_ARM_BARRIER_ISH)
|
|
||||||
# define _ARM_BARRIER_ISH _ARM64_BARRIER_ISH
|
|
||||||
# endif
|
|
||||||
|
|
||||||
static __inline int CRYPTO_UP_REF(volatile int *val, int *ret,
|
|
||||||
ossl_unused void *lock)
|
|
||||||
{
|
|
||||||
*ret = _InterlockedExchangeAdd_nf(val, 1) + 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret,
|
|
||||||
ossl_unused void *lock)
|
|
||||||
{
|
|
||||||
*ret = _InterlockedExchangeAdd_nf(val, -1) - 1;
|
|
||||||
if (*ret == 0)
|
|
||||||
__dmb(_ARM_BARRIER_ISH);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
# else
|
|
||||||
# if !defined(_WIN32_WCE)
|
|
||||||
# pragma intrinsic(_InterlockedExchangeAdd)
|
|
||||||
# else
|
|
||||||
# if _WIN32_WCE >= 0x600
|
|
||||||
extern long __cdecl _InterlockedExchangeAdd(long volatile*, long);
|
|
||||||
# else
|
|
||||||
/* under Windows CE we still have old-style Interlocked* functions */
|
|
||||||
extern long __cdecl InterlockedExchangeAdd(long volatile*, long);
|
|
||||||
# define _InterlockedExchangeAdd InterlockedExchangeAdd
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
static __inline int CRYPTO_UP_REF(volatile int *val, int *ret,
|
|
||||||
ossl_unused void *lock)
|
|
||||||
{
|
|
||||||
*ret = _InterlockedExchangeAdd((long volatile *)val, 1) + 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret,
|
|
||||||
ossl_unused void *lock)
|
|
||||||
{
|
|
||||||
*ret = _InterlockedExchangeAdd((long volatile *)val, -1) - 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# endif
|
|
||||||
# endif /* !OPENSSL_DEV_NO_ATOMICS */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* All the refcounting implementations above define HAVE_ATOMICS, so if it's
|
|
||||||
* still undefined here (such as when OPENSSL_DEV_NO_ATOMICS is defined), it
|
|
||||||
* means we need to implement a fallback. This fallback uses locks.
|
|
||||||
*/
|
|
||||||
# ifndef HAVE_ATOMICS
|
|
||||||
|
|
||||||
typedef int CRYPTO_REF_COUNT;
|
|
||||||
|
|
||||||
# define CRYPTO_UP_REF(val, ret, lock) CRYPTO_atomic_add(val, 1, ret, lock)
|
|
||||||
# define CRYPTO_DOWN_REF(val, ret, lock) CRYPTO_atomic_add(val, -1, ret, lock)
|
|
||||||
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# if !defined(NDEBUG) && !defined(OPENSSL_NO_STDIO)
|
|
||||||
# define REF_ASSERT_ISNT(test) \
|
|
||||||
(void)((test) ? (OPENSSL_die("refcount error", __FILE__, __LINE__), 1) : 0)
|
|
||||||
# else
|
|
||||||
# define REF_ASSERT_ISNT(i)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# define REF_PRINT_EX(text, count, object) \
|
|
||||||
OSSL_TRACE3(REF_COUNT, "%p:%4d:%s\n", (object), (count), (text));
|
|
||||||
# define REF_PRINT_COUNT(text, object) \
|
|
||||||
REF_PRINT_EX(text, object->references, (void *)object)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,186 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 1995-2022 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OSSL_INTERNAL_SOCKETS_H
|
|
||||||
# define OSSL_INTERNAL_SOCKETS_H
|
|
||||||
# pragma once
|
|
||||||
|
|
||||||
# include <openssl/opensslconf.h>
|
|
||||||
|
|
||||||
# if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)
|
|
||||||
# define NO_SYS_PARAM_H
|
|
||||||
# endif
|
|
||||||
# ifdef WIN32
|
|
||||||
# define NO_SYS_UN_H
|
|
||||||
# endif
|
|
||||||
# ifdef OPENSSL_SYS_VMS
|
|
||||||
# define NO_SYS_PARAM_H
|
|
||||||
# define NO_SYS_UN_H
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef OPENSSL_NO_SOCK
|
|
||||||
|
|
||||||
# elif defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
|
|
||||||
# if defined(__DJGPP__)
|
|
||||||
# define WATT32
|
|
||||||
# define WATT32_NO_OLDIES
|
|
||||||
# include <sys/socket.h>
|
|
||||||
# include <sys/un.h>
|
|
||||||
# include <tcp.h>
|
|
||||||
# include <netdb.h>
|
|
||||||
# include <arpa/inet.h>
|
|
||||||
# include <netinet/tcp.h>
|
|
||||||
# elif defined(_WIN32_WCE) && _WIN32_WCE<410
|
|
||||||
# define getservbyname _masked_declaration_getservbyname
|
|
||||||
# endif
|
|
||||||
# if !defined(IPPROTO_IP)
|
|
||||||
/* winsock[2].h was included already? */
|
|
||||||
# include <winsock.h>
|
|
||||||
# endif
|
|
||||||
# ifdef getservbyname
|
|
||||||
/* this is used to be wcecompat/include/winsock_extras.h */
|
|
||||||
# undef getservbyname
|
|
||||||
struct servent *PASCAL getservbyname(const char *, const char *);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef _WIN64
|
|
||||||
/*
|
|
||||||
* Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
|
|
||||||
* the value constitutes an index in per-process table of limited size
|
|
||||||
* and not a real pointer. And we also depend on fact that all processors
|
|
||||||
* Windows run on happen to be two's-complement, which allows to
|
|
||||||
* interchange INVALID_SOCKET and -1.
|
|
||||||
*/
|
|
||||||
# define socket(d,t,p) ((int)socket(d,t,p))
|
|
||||||
# define accept(s,f,l) ((int)accept(s,f,l))
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# else
|
|
||||||
|
|
||||||
# ifndef NO_SYS_PARAM_H
|
|
||||||
# include <sys/param.h>
|
|
||||||
# endif
|
|
||||||
# ifdef OPENSSL_SYS_VXWORKS
|
|
||||||
# include <time.h>
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# include <netdb.h>
|
|
||||||
# if defined(OPENSSL_SYS_VMS_NODECC)
|
|
||||||
# include <socket.h>
|
|
||||||
# include <in.h>
|
|
||||||
# include <inet.h>
|
|
||||||
# else
|
|
||||||
# include <sys/socket.h>
|
|
||||||
# if !defined(NO_SYS_UN_H) && defined(AF_UNIX) && !defined(OPENSSL_NO_UNIX_SOCK)
|
|
||||||
# include <sys/un.h>
|
|
||||||
# ifndef UNIX_PATH_MAX
|
|
||||||
# define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)NULL)->sun_path)
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# ifdef FILIO_H
|
|
||||||
# include <sys/filio.h> /* FIONBIO in some SVR4, e.g. unixware, solaris */
|
|
||||||
# endif
|
|
||||||
# include <netinet/in.h>
|
|
||||||
# include <arpa/inet.h>
|
|
||||||
# include <netinet/tcp.h>
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef OPENSSL_SYS_AIX
|
|
||||||
# include <sys/select.h>
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef VMS
|
|
||||||
# include <sys/ioctl.h>
|
|
||||||
# else
|
|
||||||
# if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
|
|
||||||
/* ioctl is only in VMS > 7.0 and when socketshr is not used */
|
|
||||||
# include <sys/ioctl.h>
|
|
||||||
# endif
|
|
||||||
# include <unixio.h>
|
|
||||||
# if defined(TCPIP_TYPE_SOCKETSHR)
|
|
||||||
# include <socketshr.h>
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef INVALID_SOCKET
|
|
||||||
# define INVALID_SOCKET (-1)
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Some IPv6 implementations are broken, you can disable them in known
|
|
||||||
* bad versions.
|
|
||||||
*/
|
|
||||||
# if !defined(OPENSSL_USE_IPV6)
|
|
||||||
# if defined(AF_INET6)
|
|
||||||
# define OPENSSL_USE_IPV6 1
|
|
||||||
# else
|
|
||||||
# define OPENSSL_USE_IPV6 0
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Some platforms define AF_UNIX, but don't support it
|
|
||||||
*/
|
|
||||||
# if !defined(OPENSSL_NO_UNIX_SOCK)
|
|
||||||
# if !defined(AF_UNIX) || defined(NO_SYS_UN_H)
|
|
||||||
# define OPENSSL_NO_UNIX_SOCK
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# define get_last_socket_error() errno
|
|
||||||
# define clear_socket_error() errno=0
|
|
||||||
|
|
||||||
# if defined(OPENSSL_SYS_WINDOWS)
|
|
||||||
# undef get_last_socket_error
|
|
||||||
# undef clear_socket_error
|
|
||||||
# define get_last_socket_error() WSAGetLastError()
|
|
||||||
# define clear_socket_error() WSASetLastError(0)
|
|
||||||
# define readsocket(s,b,n) recv((s),(b),(n),0)
|
|
||||||
# define writesocket(s,b,n) send((s),(b),(n),0)
|
|
||||||
# elif defined(__DJGPP__)
|
|
||||||
# define closesocket(s) close_s(s)
|
|
||||||
# define readsocket(s,b,n) read_s(s,b,n)
|
|
||||||
# define writesocket(s,b,n) send(s,b,n,0)
|
|
||||||
# elif defined(OPENSSL_SYS_VMS)
|
|
||||||
# define ioctlsocket(a,b,c) ioctl(a,b,c)
|
|
||||||
# define closesocket(s) close(s)
|
|
||||||
# define readsocket(s,b,n) recv((s),(b),(n),0)
|
|
||||||
# define writesocket(s,b,n) send((s),(b),(n),0)
|
|
||||||
# elif defined(OPENSSL_SYS_VXWORKS)
|
|
||||||
# define ioctlsocket(a,b,c) ioctl((a),(b),(int)(c))
|
|
||||||
# define closesocket(s) close(s)
|
|
||||||
# define readsocket(s,b,n) read((s),(b),(n))
|
|
||||||
# define writesocket(s,b,n) write((s),(char *)(b),(n))
|
|
||||||
# elif defined(OPENSSL_SYS_TANDEM)
|
|
||||||
# if defined(OPENSSL_TANDEM_FLOSS)
|
|
||||||
# include <floss.h(floss_read, floss_write)>
|
|
||||||
# define readsocket(s,b,n) floss_read((s),(b),(n))
|
|
||||||
# define writesocket(s,b,n) floss_write((s),(b),(n))
|
|
||||||
# else
|
|
||||||
# define readsocket(s,b,n) read((s),(b),(n))
|
|
||||||
# define writesocket(s,b,n) write((s),(b),(n))
|
|
||||||
# endif
|
|
||||||
# define ioctlsocket(a,b,c) ioctl(a,b,c)
|
|
||||||
# define closesocket(s) close(s)
|
|
||||||
# else
|
|
||||||
# define ioctlsocket(a,b,c) ioctl(a,b,c)
|
|
||||||
# define closesocket(s) close(s)
|
|
||||||
# define readsocket(s,b,n) read((s),(b),(n))
|
|
||||||
# define writesocket(s,b,n) write((s),(b),(n))
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* also in apps/include/apps.h */
|
|
||||||
# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINCE)
|
|
||||||
# define openssl_fdset(a, b) FD_SET((unsigned int)(a), b)
|
|
||||||
# else
|
|
||||||
# define openssl_fdset(a, b) FD_SET(a, b)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,561 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2023 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OPENSSL_CORE_NAMES_H
|
|
||||||
# define OPENSSL_CORE_NAMES_H
|
|
||||||
# pragma once
|
|
||||||
|
|
||||||
# ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* Well known parameter names that core passes to providers */
|
|
||||||
#define OSSL_PROV_PARAM_CORE_VERSION "openssl-version" /* utf8_ptr */
|
|
||||||
#define OSSL_PROV_PARAM_CORE_PROV_NAME "provider-name" /* utf8_ptr */
|
|
||||||
#define OSSL_PROV_PARAM_CORE_MODULE_FILENAME "module-filename" /* utf8_ptr */
|
|
||||||
|
|
||||||
/* Well known parameter names that Providers can define */
|
|
||||||
#define OSSL_PROV_PARAM_NAME "name" /* utf8_ptr */
|
|
||||||
#define OSSL_PROV_PARAM_VERSION "version" /* utf8_ptr */
|
|
||||||
#define OSSL_PROV_PARAM_BUILDINFO "buildinfo" /* utf8_ptr */
|
|
||||||
#define OSSL_PROV_PARAM_STATUS "status" /* uint */
|
|
||||||
#define OSSL_PROV_PARAM_SECURITY_CHECKS "security-checks" /* uint */
|
|
||||||
#define OSSL_PROV_PARAM_TLS1_PRF_EMS_CHECK "tls1-prf-ems-check" /* uint */
|
|
||||||
#define OSSL_PROV_PARAM_DRBG_TRUNC_DIGEST "drbg-no-trunc-md" /* uint */
|
|
||||||
|
|
||||||
/* Self test callback parameters */
|
|
||||||
#define OSSL_PROV_PARAM_SELF_TEST_PHASE "st-phase" /* utf8_string */
|
|
||||||
#define OSSL_PROV_PARAM_SELF_TEST_TYPE "st-type" /* utf8_string */
|
|
||||||
#define OSSL_PROV_PARAM_SELF_TEST_DESC "st-desc" /* utf8_string */
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Provider-native object abstractions
|
|
||||||
*
|
|
||||||
* These are used when a provider wants to pass object data or an object
|
|
||||||
* reference back to libcrypto. This is only useful for provider functions
|
|
||||||
* that take a callback to which an OSSL_PARAM array with these parameters
|
|
||||||
* can be passed.
|
|
||||||
*
|
|
||||||
* This set of parameter names is explained in detail in provider-object(7)
|
|
||||||
* (doc/man7/provider-object.pod)
|
|
||||||
*/
|
|
||||||
#define OSSL_OBJECT_PARAM_TYPE "type" /* INTEGER */
|
|
||||||
#define OSSL_OBJECT_PARAM_DATA_TYPE "data-type" /* UTF8_STRING */
|
|
||||||
#define OSSL_OBJECT_PARAM_DATA_STRUCTURE "data-structure" /* UTF8_STRING */
|
|
||||||
#define OSSL_OBJECT_PARAM_REFERENCE "reference" /* OCTET_STRING */
|
|
||||||
#define OSSL_OBJECT_PARAM_DATA "data" /* OCTET_STRING or UTF8_STRING */
|
|
||||||
#define OSSL_OBJECT_PARAM_DESC "desc" /* UTF8_STRING */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Algorithm parameters
|
|
||||||
* If "engine" or "properties" are specified, they should always be paired
|
|
||||||
* with the algorithm type.
|
|
||||||
* Note these are common names that are shared by many types (such as kdf, mac,
|
|
||||||
* and pkey) e.g: see OSSL_MAC_PARAM_DIGEST below.
|
|
||||||
*/
|
|
||||||
#define OSSL_ALG_PARAM_DIGEST "digest" /* utf8_string */
|
|
||||||
#define OSSL_ALG_PARAM_CIPHER "cipher" /* utf8_string */
|
|
||||||
#define OSSL_ALG_PARAM_ENGINE "engine" /* utf8_string */
|
|
||||||
#define OSSL_ALG_PARAM_MAC "mac" /* utf8_string */
|
|
||||||
#define OSSL_ALG_PARAM_PROPERTIES "properties"/* utf8_string */
|
|
||||||
|
|
||||||
/* cipher parameters */
|
|
||||||
#define OSSL_CIPHER_PARAM_PADDING "padding" /* uint */
|
|
||||||
#define OSSL_CIPHER_PARAM_USE_BITS "use-bits" /* uint */
|
|
||||||
#define OSSL_CIPHER_PARAM_TLS_VERSION "tls-version" /* uint */
|
|
||||||
#define OSSL_CIPHER_PARAM_TLS_MAC "tls-mac" /* octet_ptr */
|
|
||||||
#define OSSL_CIPHER_PARAM_TLS_MAC_SIZE "tls-mac-size" /* size_t */
|
|
||||||
#define OSSL_CIPHER_PARAM_MODE "mode" /* uint */
|
|
||||||
#define OSSL_CIPHER_PARAM_BLOCK_SIZE "blocksize" /* size_t */
|
|
||||||
#define OSSL_CIPHER_PARAM_AEAD "aead" /* int, 0 or 1 */
|
|
||||||
#define OSSL_CIPHER_PARAM_CUSTOM_IV "custom-iv" /* int, 0 or 1 */
|
|
||||||
#define OSSL_CIPHER_PARAM_CTS "cts" /* int, 0 or 1 */
|
|
||||||
#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK "tls-multi" /* int, 0 or 1 */
|
|
||||||
#define OSSL_CIPHER_PARAM_HAS_RAND_KEY "has-randkey" /* int, 0 or 1 */
|
|
||||||
#define OSSL_CIPHER_PARAM_KEYLEN "keylen" /* size_t */
|
|
||||||
#define OSSL_CIPHER_PARAM_IVLEN "ivlen" /* size_t */
|
|
||||||
#define OSSL_CIPHER_PARAM_IV "iv" /* octet_string OR octet_ptr */
|
|
||||||
#define OSSL_CIPHER_PARAM_UPDATED_IV "updated-iv" /* octet_string OR octet_ptr */
|
|
||||||
#define OSSL_CIPHER_PARAM_NUM "num" /* uint */
|
|
||||||
#define OSSL_CIPHER_PARAM_ROUNDS "rounds" /* uint */
|
|
||||||
#define OSSL_CIPHER_PARAM_AEAD_TAG "tag" /* octet_string */
|
|
||||||
#define OSSL_CIPHER_PARAM_AEAD_TLS1_AAD "tlsaad" /* octet_string */
|
|
||||||
#define OSSL_CIPHER_PARAM_AEAD_TLS1_AAD_PAD "tlsaadpad" /* size_t */
|
|
||||||
#define OSSL_CIPHER_PARAM_AEAD_TLS1_IV_FIXED "tlsivfixed" /* octet_string */
|
|
||||||
#define OSSL_CIPHER_PARAM_AEAD_TLS1_GET_IV_GEN "tlsivgen" /* octet_string */
|
|
||||||
#define OSSL_CIPHER_PARAM_AEAD_TLS1_SET_IV_INV "tlsivinv" /* octet_string */
|
|
||||||
#define OSSL_CIPHER_PARAM_AEAD_IVLEN OSSL_CIPHER_PARAM_IVLEN
|
|
||||||
#define OSSL_CIPHER_PARAM_AEAD_TAGLEN "taglen" /* size_t */
|
|
||||||
#define OSSL_CIPHER_PARAM_AEAD_MAC_KEY "mackey" /* octet_string */
|
|
||||||
#define OSSL_CIPHER_PARAM_RANDOM_KEY "randkey" /* octet_string */
|
|
||||||
#define OSSL_CIPHER_PARAM_RC2_KEYBITS "keybits" /* size_t */
|
|
||||||
#define OSSL_CIPHER_PARAM_SPEED "speed" /* uint */
|
|
||||||
#define OSSL_CIPHER_PARAM_CTS_MODE "cts_mode" /* utf8_string */
|
|
||||||
/* For passing the AlgorithmIdentifier parameter in DER form */
|
|
||||||
#define OSSL_CIPHER_PARAM_ALGORITHM_ID_PARAMS "alg_id_param" /* octet_string */
|
|
||||||
|
|
||||||
#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_SEND_FRAGMENT \
|
|
||||||
"tls1multi_maxsndfrag" /* uint */
|
|
||||||
#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_BUFSIZE \
|
|
||||||
"tls1multi_maxbufsz" /* size_t */
|
|
||||||
#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_INTERLEAVE \
|
|
||||||
"tls1multi_interleave" /* uint */
|
|
||||||
#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD \
|
|
||||||
"tls1multi_aad" /* octet_string */
|
|
||||||
#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD_PACKLEN \
|
|
||||||
"tls1multi_aadpacklen" /* uint */
|
|
||||||
#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC \
|
|
||||||
"tls1multi_enc" /* octet_string */
|
|
||||||
#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_IN \
|
|
||||||
"tls1multi_encin" /* octet_string */
|
|
||||||
#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_LEN \
|
|
||||||
"tls1multi_enclen" /* size_t */
|
|
||||||
|
|
||||||
/* OSSL_CIPHER_PARAM_CTS_MODE Values */
|
|
||||||
#define OSSL_CIPHER_CTS_MODE_CS1 "CS1"
|
|
||||||
#define OSSL_CIPHER_CTS_MODE_CS2 "CS2"
|
|
||||||
#define OSSL_CIPHER_CTS_MODE_CS3 "CS3"
|
|
||||||
|
|
||||||
/* digest parameters */
|
|
||||||
#define OSSL_DIGEST_PARAM_XOFLEN "xoflen" /* size_t */
|
|
||||||
#define OSSL_DIGEST_PARAM_SSL3_MS "ssl3-ms" /* octet string */
|
|
||||||
#define OSSL_DIGEST_PARAM_PAD_TYPE "pad-type" /* uint */
|
|
||||||
#define OSSL_DIGEST_PARAM_MICALG "micalg" /* utf8 string */
|
|
||||||
#define OSSL_DIGEST_PARAM_BLOCK_SIZE "blocksize" /* size_t */
|
|
||||||
#define OSSL_DIGEST_PARAM_SIZE "size" /* size_t */
|
|
||||||
#define OSSL_DIGEST_PARAM_XOF "xof" /* int, 0 or 1 */
|
|
||||||
#define OSSL_DIGEST_PARAM_ALGID_ABSENT "algid-absent" /* int, 0 or 1 */
|
|
||||||
|
|
||||||
/* Known DIGEST names (not a complete list) */
|
|
||||||
#define OSSL_DIGEST_NAME_MD5 "MD5"
|
|
||||||
#define OSSL_DIGEST_NAME_MD5_SHA1 "MD5-SHA1"
|
|
||||||
#define OSSL_DIGEST_NAME_SHA1 "SHA1"
|
|
||||||
#define OSSL_DIGEST_NAME_SHA2_224 "SHA2-224"
|
|
||||||
#define OSSL_DIGEST_NAME_SHA2_256 "SHA2-256"
|
|
||||||
#define OSSL_DIGEST_NAME_SHA2_384 "SHA2-384"
|
|
||||||
#define OSSL_DIGEST_NAME_SHA2_512 "SHA2-512"
|
|
||||||
#define OSSL_DIGEST_NAME_SHA2_512_224 "SHA2-512/224"
|
|
||||||
#define OSSL_DIGEST_NAME_SHA2_512_256 "SHA2-512/256"
|
|
||||||
#define OSSL_DIGEST_NAME_MD2 "MD2"
|
|
||||||
#define OSSL_DIGEST_NAME_MD4 "MD4"
|
|
||||||
#define OSSL_DIGEST_NAME_MDC2 "MDC2"
|
|
||||||
#define OSSL_DIGEST_NAME_RIPEMD160 "RIPEMD160"
|
|
||||||
#define OSSL_DIGEST_NAME_SHA3_224 "SHA3-224"
|
|
||||||
#define OSSL_DIGEST_NAME_SHA3_256 "SHA3-256"
|
|
||||||
#define OSSL_DIGEST_NAME_SHA3_384 "SHA3-384"
|
|
||||||
#define OSSL_DIGEST_NAME_SHA3_512 "SHA3-512"
|
|
||||||
#define OSSL_DIGEST_NAME_KECCAK_KMAC128 "KECCAK-KMAC-128"
|
|
||||||
#define OSSL_DIGEST_NAME_KECCAK_KMAC256 "KECCAK-KMAC-256"
|
|
||||||
#define OSSL_DIGEST_NAME_SM3 "SM3"
|
|
||||||
|
|
||||||
/* MAC parameters */
|
|
||||||
#define OSSL_MAC_PARAM_KEY "key" /* octet string */
|
|
||||||
#define OSSL_MAC_PARAM_IV "iv" /* octet string */
|
|
||||||
#define OSSL_MAC_PARAM_CUSTOM "custom" /* utf8 string */
|
|
||||||
#define OSSL_MAC_PARAM_SALT "salt" /* octet string */
|
|
||||||
#define OSSL_MAC_PARAM_XOF "xof" /* int, 0 or 1 */
|
|
||||||
#define OSSL_MAC_PARAM_DIGEST_NOINIT "digest-noinit" /* int, 0 or 1 */
|
|
||||||
#define OSSL_MAC_PARAM_DIGEST_ONESHOT "digest-oneshot" /* int, 0 or 1 */
|
|
||||||
#define OSSL_MAC_PARAM_C_ROUNDS "c-rounds" /* unsigned int */
|
|
||||||
#define OSSL_MAC_PARAM_D_ROUNDS "d-rounds" /* unsigned int */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If "engine" or "properties" are specified, they should always be paired
|
|
||||||
* with "cipher" or "digest".
|
|
||||||
*/
|
|
||||||
#define OSSL_MAC_PARAM_CIPHER OSSL_ALG_PARAM_CIPHER /* utf8 string */
|
|
||||||
#define OSSL_MAC_PARAM_DIGEST OSSL_ALG_PARAM_DIGEST /* utf8 string */
|
|
||||||
#define OSSL_MAC_PARAM_PROPERTIES OSSL_ALG_PARAM_PROPERTIES /* utf8 string */
|
|
||||||
#define OSSL_MAC_PARAM_SIZE "size" /* size_t */
|
|
||||||
#define OSSL_MAC_PARAM_BLOCK_SIZE "block-size" /* size_t */
|
|
||||||
#define OSSL_MAC_PARAM_TLS_DATA_SIZE "tls-data-size" /* size_t */
|
|
||||||
|
|
||||||
/* Known MAC names */
|
|
||||||
#define OSSL_MAC_NAME_BLAKE2BMAC "BLAKE2BMAC"
|
|
||||||
#define OSSL_MAC_NAME_BLAKE2SMAC "BLAKE2SMAC"
|
|
||||||
#define OSSL_MAC_NAME_CMAC "CMAC"
|
|
||||||
#define OSSL_MAC_NAME_GMAC "GMAC"
|
|
||||||
#define OSSL_MAC_NAME_HMAC "HMAC"
|
|
||||||
#define OSSL_MAC_NAME_KMAC128 "KMAC128"
|
|
||||||
#define OSSL_MAC_NAME_KMAC256 "KMAC256"
|
|
||||||
#define OSSL_MAC_NAME_POLY1305 "POLY1305"
|
|
||||||
#define OSSL_MAC_NAME_SIPHASH "SIPHASH"
|
|
||||||
|
|
||||||
/* KDF / PRF parameters */
|
|
||||||
#define OSSL_KDF_PARAM_SECRET "secret" /* octet string */
|
|
||||||
#define OSSL_KDF_PARAM_KEY "key" /* octet string */
|
|
||||||
#define OSSL_KDF_PARAM_SALT "salt" /* octet string */
|
|
||||||
#define OSSL_KDF_PARAM_PASSWORD "pass" /* octet string */
|
|
||||||
#define OSSL_KDF_PARAM_PREFIX "prefix" /* octet string */
|
|
||||||
#define OSSL_KDF_PARAM_LABEL "label" /* octet string */
|
|
||||||
#define OSSL_KDF_PARAM_DATA "data" /* octet string */
|
|
||||||
#define OSSL_KDF_PARAM_DIGEST OSSL_ALG_PARAM_DIGEST /* utf8 string */
|
|
||||||
#define OSSL_KDF_PARAM_CIPHER OSSL_ALG_PARAM_CIPHER /* utf8 string */
|
|
||||||
#define OSSL_KDF_PARAM_MAC OSSL_ALG_PARAM_MAC /* utf8 string */
|
|
||||||
#define OSSL_KDF_PARAM_MAC_SIZE "maclen" /* size_t */
|
|
||||||
#define OSSL_KDF_PARAM_PROPERTIES OSSL_ALG_PARAM_PROPERTIES /* utf8 string */
|
|
||||||
#define OSSL_KDF_PARAM_ITER "iter" /* unsigned int */
|
|
||||||
#define OSSL_KDF_PARAM_MODE "mode" /* utf8 string or int */
|
|
||||||
#define OSSL_KDF_PARAM_PKCS5 "pkcs5" /* int */
|
|
||||||
#define OSSL_KDF_PARAM_UKM "ukm" /* octet string */
|
|
||||||
#define OSSL_KDF_PARAM_CEK_ALG "cekalg" /* utf8 string */
|
|
||||||
#define OSSL_KDF_PARAM_SCRYPT_N "n" /* uint64_t */
|
|
||||||
#define OSSL_KDF_PARAM_SCRYPT_R "r" /* uint32_t */
|
|
||||||
#define OSSL_KDF_PARAM_SCRYPT_P "p" /* uint32_t */
|
|
||||||
#define OSSL_KDF_PARAM_SCRYPT_MAXMEM "maxmem_bytes" /* uint64_t */
|
|
||||||
#define OSSL_KDF_PARAM_INFO "info" /* octet string */
|
|
||||||
#define OSSL_KDF_PARAM_SEED "seed" /* octet string */
|
|
||||||
#define OSSL_KDF_PARAM_SSHKDF_XCGHASH "xcghash" /* octet string */
|
|
||||||
#define OSSL_KDF_PARAM_SSHKDF_SESSION_ID "session_id" /* octet string */
|
|
||||||
#define OSSL_KDF_PARAM_SSHKDF_TYPE "type" /* int */
|
|
||||||
#define OSSL_KDF_PARAM_SIZE "size" /* size_t */
|
|
||||||
#define OSSL_KDF_PARAM_CONSTANT "constant" /* octet string */
|
|
||||||
#define OSSL_KDF_PARAM_PKCS12_ID "id" /* int */
|
|
||||||
#define OSSL_KDF_PARAM_KBKDF_USE_L "use-l" /* int */
|
|
||||||
#define OSSL_KDF_PARAM_KBKDF_USE_SEPARATOR "use-separator" /* int */
|
|
||||||
#define OSSL_KDF_PARAM_KBKDF_R "r" /* int */
|
|
||||||
#define OSSL_KDF_PARAM_X942_ACVPINFO "acvp-info"
|
|
||||||
#define OSSL_KDF_PARAM_X942_PARTYUINFO "partyu-info"
|
|
||||||
#define OSSL_KDF_PARAM_X942_PARTYVINFO "partyv-info"
|
|
||||||
#define OSSL_KDF_PARAM_X942_SUPP_PUBINFO "supp-pubinfo"
|
|
||||||
#define OSSL_KDF_PARAM_X942_SUPP_PRIVINFO "supp-privinfo"
|
|
||||||
#define OSSL_KDF_PARAM_X942_USE_KEYBITS "use-keybits"
|
|
||||||
|
|
||||||
/* Known KDF names */
|
|
||||||
#define OSSL_KDF_NAME_HKDF "HKDF"
|
|
||||||
#define OSSL_KDF_NAME_TLS1_3_KDF "TLS13-KDF"
|
|
||||||
#define OSSL_KDF_NAME_PBKDF1 "PBKDF1"
|
|
||||||
#define OSSL_KDF_NAME_PBKDF2 "PBKDF2"
|
|
||||||
#define OSSL_KDF_NAME_SCRYPT "SCRYPT"
|
|
||||||
#define OSSL_KDF_NAME_SSHKDF "SSHKDF"
|
|
||||||
#define OSSL_KDF_NAME_SSKDF "SSKDF"
|
|
||||||
#define OSSL_KDF_NAME_TLS1_PRF "TLS1-PRF"
|
|
||||||
#define OSSL_KDF_NAME_X942KDF_ASN1 "X942KDF-ASN1"
|
|
||||||
#define OSSL_KDF_NAME_X942KDF_CONCAT "X942KDF-CONCAT"
|
|
||||||
#define OSSL_KDF_NAME_X963KDF "X963KDF"
|
|
||||||
#define OSSL_KDF_NAME_KBKDF "KBKDF"
|
|
||||||
#define OSSL_KDF_NAME_KRB5KDF "KRB5KDF"
|
|
||||||
|
|
||||||
/* Known RAND names */
|
|
||||||
#define OSSL_RAND_PARAM_STATE "state"
|
|
||||||
#define OSSL_RAND_PARAM_STRENGTH "strength"
|
|
||||||
#define OSSL_RAND_PARAM_MAX_REQUEST "max_request"
|
|
||||||
#define OSSL_RAND_PARAM_TEST_ENTROPY "test_entropy"
|
|
||||||
#define OSSL_RAND_PARAM_TEST_NONCE "test_nonce"
|
|
||||||
#define OSSL_RAND_PARAM_GENERATE "generate"
|
|
||||||
|
|
||||||
/* RAND/DRBG names */
|
|
||||||
#define OSSL_DRBG_PARAM_RESEED_REQUESTS "reseed_requests"
|
|
||||||
#define OSSL_DRBG_PARAM_RESEED_TIME_INTERVAL "reseed_time_interval"
|
|
||||||
#define OSSL_DRBG_PARAM_MIN_ENTROPYLEN "min_entropylen"
|
|
||||||
#define OSSL_DRBG_PARAM_MAX_ENTROPYLEN "max_entropylen"
|
|
||||||
#define OSSL_DRBG_PARAM_MIN_NONCELEN "min_noncelen"
|
|
||||||
#define OSSL_DRBG_PARAM_MAX_NONCELEN "max_noncelen"
|
|
||||||
#define OSSL_DRBG_PARAM_MAX_PERSLEN "max_perslen"
|
|
||||||
#define OSSL_DRBG_PARAM_MAX_ADINLEN "max_adinlen"
|
|
||||||
#define OSSL_DRBG_PARAM_RESEED_COUNTER "reseed_counter"
|
|
||||||
#define OSSL_DRBG_PARAM_RESEED_TIME "reseed_time"
|
|
||||||
#define OSSL_DRBG_PARAM_PROPERTIES OSSL_ALG_PARAM_PROPERTIES
|
|
||||||
#define OSSL_DRBG_PARAM_DIGEST OSSL_ALG_PARAM_DIGEST
|
|
||||||
#define OSSL_DRBG_PARAM_CIPHER OSSL_ALG_PARAM_CIPHER
|
|
||||||
#define OSSL_DRBG_PARAM_MAC OSSL_ALG_PARAM_MAC
|
|
||||||
#define OSSL_DRBG_PARAM_USE_DF "use_derivation_function"
|
|
||||||
|
|
||||||
/* DRBG call back parameters */
|
|
||||||
#define OSSL_DRBG_PARAM_ENTROPY_REQUIRED "entropy_required"
|
|
||||||
#define OSSL_DRBG_PARAM_PREDICTION_RESISTANCE "prediction_resistance"
|
|
||||||
#define OSSL_DRBG_PARAM_MIN_LENGTH "minium_length"
|
|
||||||
#define OSSL_DRBG_PARAM_MAX_LENGTH "maxium_length"
|
|
||||||
#define OSSL_DRBG_PARAM_RANDOM_DATA "random_data"
|
|
||||||
#define OSSL_DRBG_PARAM_SIZE "size"
|
|
||||||
|
|
||||||
/* PKEY parameters */
|
|
||||||
/* Common PKEY parameters */
|
|
||||||
#define OSSL_PKEY_PARAM_BITS "bits" /* integer */
|
|
||||||
#define OSSL_PKEY_PARAM_MAX_SIZE "max-size" /* integer */
|
|
||||||
#define OSSL_PKEY_PARAM_SECURITY_BITS "security-bits" /* integer */
|
|
||||||
#define OSSL_PKEY_PARAM_DIGEST OSSL_ALG_PARAM_DIGEST
|
|
||||||
#define OSSL_PKEY_PARAM_CIPHER OSSL_ALG_PARAM_CIPHER /* utf8 string */
|
|
||||||
#define OSSL_PKEY_PARAM_ENGINE OSSL_ALG_PARAM_ENGINE /* utf8 string */
|
|
||||||
#define OSSL_PKEY_PARAM_PROPERTIES OSSL_ALG_PARAM_PROPERTIES
|
|
||||||
#define OSSL_PKEY_PARAM_DEFAULT_DIGEST "default-digest" /* utf8 string */
|
|
||||||
#define OSSL_PKEY_PARAM_MANDATORY_DIGEST "mandatory-digest" /* utf8 string */
|
|
||||||
#define OSSL_PKEY_PARAM_PAD_MODE "pad-mode"
|
|
||||||
#define OSSL_PKEY_PARAM_DIGEST_SIZE "digest-size"
|
|
||||||
#define OSSL_PKEY_PARAM_MASKGENFUNC "mgf"
|
|
||||||
#define OSSL_PKEY_PARAM_MGF1_DIGEST "mgf1-digest"
|
|
||||||
#define OSSL_PKEY_PARAM_MGF1_PROPERTIES "mgf1-properties"
|
|
||||||
#define OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY "encoded-pub-key"
|
|
||||||
#define OSSL_PKEY_PARAM_GROUP_NAME "group"
|
|
||||||
#define OSSL_PKEY_PARAM_DIST_ID "distid"
|
|
||||||
#define OSSL_PKEY_PARAM_PUB_KEY "pub"
|
|
||||||
#define OSSL_PKEY_PARAM_PRIV_KEY "priv"
|
|
||||||
|
|
||||||
/* Diffie-Hellman/DSA Parameters */
|
|
||||||
#define OSSL_PKEY_PARAM_FFC_P "p"
|
|
||||||
#define OSSL_PKEY_PARAM_FFC_G "g"
|
|
||||||
#define OSSL_PKEY_PARAM_FFC_Q "q"
|
|
||||||
#define OSSL_PKEY_PARAM_FFC_GINDEX "gindex"
|
|
||||||
#define OSSL_PKEY_PARAM_FFC_PCOUNTER "pcounter"
|
|
||||||
#define OSSL_PKEY_PARAM_FFC_SEED "seed"
|
|
||||||
#define OSSL_PKEY_PARAM_FFC_COFACTOR "j"
|
|
||||||
#define OSSL_PKEY_PARAM_FFC_H "hindex"
|
|
||||||
#define OSSL_PKEY_PARAM_FFC_VALIDATE_PQ "validate-pq"
|
|
||||||
#define OSSL_PKEY_PARAM_FFC_VALIDATE_G "validate-g"
|
|
||||||
#define OSSL_PKEY_PARAM_FFC_VALIDATE_LEGACY "validate-legacy"
|
|
||||||
|
|
||||||
/* Diffie-Hellman params */
|
|
||||||
#define OSSL_PKEY_PARAM_DH_GENERATOR "safeprime-generator"
|
|
||||||
#define OSSL_PKEY_PARAM_DH_PRIV_LEN "priv_len"
|
|
||||||
|
|
||||||
/* Elliptic Curve Domain Parameters */
|
|
||||||
#define OSSL_PKEY_PARAM_EC_PUB_X "qx"
|
|
||||||
#define OSSL_PKEY_PARAM_EC_PUB_Y "qy"
|
|
||||||
|
|
||||||
/* Elliptic Curve Explicit Domain Parameters */
|
|
||||||
#define OSSL_PKEY_PARAM_EC_FIELD_TYPE "field-type"
|
|
||||||
#define OSSL_PKEY_PARAM_EC_P "p"
|
|
||||||
#define OSSL_PKEY_PARAM_EC_A "a"
|
|
||||||
#define OSSL_PKEY_PARAM_EC_B "b"
|
|
||||||
#define OSSL_PKEY_PARAM_EC_GENERATOR "generator"
|
|
||||||
#define OSSL_PKEY_PARAM_EC_ORDER "order"
|
|
||||||
#define OSSL_PKEY_PARAM_EC_COFACTOR "cofactor"
|
|
||||||
#define OSSL_PKEY_PARAM_EC_SEED "seed"
|
|
||||||
#define OSSL_PKEY_PARAM_EC_CHAR2_M "m"
|
|
||||||
#define OSSL_PKEY_PARAM_EC_CHAR2_TYPE "basis-type"
|
|
||||||
#define OSSL_PKEY_PARAM_EC_CHAR2_TP_BASIS "tp"
|
|
||||||
#define OSSL_PKEY_PARAM_EC_CHAR2_PP_K1 "k1"
|
|
||||||
#define OSSL_PKEY_PARAM_EC_CHAR2_PP_K2 "k2"
|
|
||||||
#define OSSL_PKEY_PARAM_EC_CHAR2_PP_K3 "k3"
|
|
||||||
#define OSSL_PKEY_PARAM_EC_DECODED_FROM_EXPLICIT_PARAMS "decoded-from-explicit"
|
|
||||||
|
|
||||||
/* Elliptic Curve Key Parameters */
|
|
||||||
#define OSSL_PKEY_PARAM_USE_COFACTOR_FLAG "use-cofactor-flag"
|
|
||||||
#define OSSL_PKEY_PARAM_USE_COFACTOR_ECDH \
|
|
||||||
OSSL_PKEY_PARAM_USE_COFACTOR_FLAG
|
|
||||||
|
|
||||||
/* RSA Keys */
|
|
||||||
/*
|
|
||||||
* n, e, d are the usual public and private key components
|
|
||||||
*
|
|
||||||
* rsa-num is the number of factors, including p and q
|
|
||||||
* rsa-factor is used for each factor: p, q, r_i (i = 3, ...)
|
|
||||||
* rsa-exponent is used for each exponent: dP, dQ, d_i (i = 3, ...)
|
|
||||||
* rsa-coefficient is used for each coefficient: qInv, t_i (i = 3, ...)
|
|
||||||
*
|
|
||||||
* The number of rsa-factor items must be equal to the number of rsa-exponent
|
|
||||||
* items, and the number of rsa-coefficients must be one less.
|
|
||||||
* (the base i for the coefficients is 2, not 1, at least as implied by
|
|
||||||
* RFC 8017)
|
|
||||||
*/
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_N "n"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_E "e"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_D "d"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_FACTOR "rsa-factor"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_EXPONENT "rsa-exponent"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_COEFFICIENT "rsa-coefficient"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_FACTOR1 OSSL_PKEY_PARAM_RSA_FACTOR"1"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_FACTOR2 OSSL_PKEY_PARAM_RSA_FACTOR"2"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_FACTOR3 OSSL_PKEY_PARAM_RSA_FACTOR"3"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_FACTOR4 OSSL_PKEY_PARAM_RSA_FACTOR"4"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_FACTOR5 OSSL_PKEY_PARAM_RSA_FACTOR"5"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_FACTOR6 OSSL_PKEY_PARAM_RSA_FACTOR"6"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_FACTOR7 OSSL_PKEY_PARAM_RSA_FACTOR"7"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_FACTOR8 OSSL_PKEY_PARAM_RSA_FACTOR"8"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_FACTOR9 OSSL_PKEY_PARAM_RSA_FACTOR"9"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_FACTOR10 OSSL_PKEY_PARAM_RSA_FACTOR"10"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_EXPONENT1 OSSL_PKEY_PARAM_RSA_EXPONENT"1"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_EXPONENT2 OSSL_PKEY_PARAM_RSA_EXPONENT"2"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_EXPONENT3 OSSL_PKEY_PARAM_RSA_EXPONENT"3"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_EXPONENT4 OSSL_PKEY_PARAM_RSA_EXPONENT"4"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_EXPONENT5 OSSL_PKEY_PARAM_RSA_EXPONENT"5"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_EXPONENT6 OSSL_PKEY_PARAM_RSA_EXPONENT"6"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_EXPONENT7 OSSL_PKEY_PARAM_RSA_EXPONENT"7"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_EXPONENT8 OSSL_PKEY_PARAM_RSA_EXPONENT"8"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_EXPONENT9 OSSL_PKEY_PARAM_RSA_EXPONENT"9"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_EXPONENT10 OSSL_PKEY_PARAM_RSA_EXPONENT"10"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_COEFFICIENT1 OSSL_PKEY_PARAM_RSA_COEFFICIENT"1"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_COEFFICIENT2 OSSL_PKEY_PARAM_RSA_COEFFICIENT"2"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_COEFFICIENT3 OSSL_PKEY_PARAM_RSA_COEFFICIENT"3"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_COEFFICIENT4 OSSL_PKEY_PARAM_RSA_COEFFICIENT"4"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_COEFFICIENT5 OSSL_PKEY_PARAM_RSA_COEFFICIENT"5"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_COEFFICIENT6 OSSL_PKEY_PARAM_RSA_COEFFICIENT"6"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_COEFFICIENT7 OSSL_PKEY_PARAM_RSA_COEFFICIENT"7"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_COEFFICIENT8 OSSL_PKEY_PARAM_RSA_COEFFICIENT"8"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_COEFFICIENT9 OSSL_PKEY_PARAM_RSA_COEFFICIENT"9"
|
|
||||||
|
|
||||||
/* RSA padding modes */
|
|
||||||
#define OSSL_PKEY_RSA_PAD_MODE_NONE "none"
|
|
||||||
#define OSSL_PKEY_RSA_PAD_MODE_PKCSV15 "pkcs1"
|
|
||||||
#define OSSL_PKEY_RSA_PAD_MODE_OAEP "oaep"
|
|
||||||
#define OSSL_PKEY_RSA_PAD_MODE_X931 "x931"
|
|
||||||
#define OSSL_PKEY_RSA_PAD_MODE_PSS "pss"
|
|
||||||
|
|
||||||
/* RSA pss padding salt length */
|
|
||||||
#define OSSL_PKEY_RSA_PSS_SALT_LEN_DIGEST "digest"
|
|
||||||
#define OSSL_PKEY_RSA_PSS_SALT_LEN_MAX "max"
|
|
||||||
#define OSSL_PKEY_RSA_PSS_SALT_LEN_AUTO "auto"
|
|
||||||
#define OSSL_PKEY_RSA_PSS_SALT_LEN_AUTO_DIGEST_MAX "auto-digestmax"
|
|
||||||
|
|
||||||
/* Key generation parameters */
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_BITS OSSL_PKEY_PARAM_BITS
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_PRIMES "primes"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_DIGEST OSSL_PKEY_PARAM_DIGEST
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_DIGEST_PROPS OSSL_PKEY_PARAM_PROPERTIES
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_MASKGENFUNC OSSL_PKEY_PARAM_MASKGENFUNC
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_MGF1_DIGEST OSSL_PKEY_PARAM_MGF1_DIGEST
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_PSS_SALTLEN "saltlen"
|
|
||||||
|
|
||||||
/* Key generation parameters */
|
|
||||||
#define OSSL_PKEY_PARAM_FFC_TYPE "type"
|
|
||||||
#define OSSL_PKEY_PARAM_FFC_PBITS "pbits"
|
|
||||||
#define OSSL_PKEY_PARAM_FFC_QBITS "qbits"
|
|
||||||
#define OSSL_PKEY_PARAM_FFC_DIGEST OSSL_PKEY_PARAM_DIGEST
|
|
||||||
#define OSSL_PKEY_PARAM_FFC_DIGEST_PROPS OSSL_PKEY_PARAM_PROPERTIES
|
|
||||||
|
|
||||||
#define OSSL_PKEY_PARAM_EC_ENCODING "encoding" /* utf8_string */
|
|
||||||
#define OSSL_PKEY_PARAM_EC_POINT_CONVERSION_FORMAT "point-format"
|
|
||||||
#define OSSL_PKEY_PARAM_EC_GROUP_CHECK_TYPE "group-check"
|
|
||||||
#define OSSL_PKEY_PARAM_EC_INCLUDE_PUBLIC "include-public"
|
|
||||||
|
|
||||||
/* OSSL_PKEY_PARAM_EC_ENCODING values */
|
|
||||||
#define OSSL_PKEY_EC_ENCODING_EXPLICIT "explicit"
|
|
||||||
#define OSSL_PKEY_EC_ENCODING_GROUP "named_curve"
|
|
||||||
|
|
||||||
#define OSSL_PKEY_EC_POINT_CONVERSION_FORMAT_UNCOMPRESSED "uncompressed"
|
|
||||||
#define OSSL_PKEY_EC_POINT_CONVERSION_FORMAT_COMPRESSED "compressed"
|
|
||||||
#define OSSL_PKEY_EC_POINT_CONVERSION_FORMAT_HYBRID "hybrid"
|
|
||||||
|
|
||||||
#define OSSL_PKEY_EC_GROUP_CHECK_DEFAULT "default"
|
|
||||||
#define OSSL_PKEY_EC_GROUP_CHECK_NAMED "named"
|
|
||||||
#define OSSL_PKEY_EC_GROUP_CHECK_NAMED_NIST "named-nist"
|
|
||||||
|
|
||||||
/* Key Exchange parameters */
|
|
||||||
#define OSSL_EXCHANGE_PARAM_PAD "pad" /* uint */
|
|
||||||
#define OSSL_EXCHANGE_PARAM_EC_ECDH_COFACTOR_MODE "ecdh-cofactor-mode" /* int */
|
|
||||||
#define OSSL_EXCHANGE_PARAM_KDF_TYPE "kdf-type" /* utf8_string */
|
|
||||||
#define OSSL_EXCHANGE_PARAM_KDF_DIGEST "kdf-digest" /* utf8_string */
|
|
||||||
#define OSSL_EXCHANGE_PARAM_KDF_DIGEST_PROPS "kdf-digest-props" /* utf8_string */
|
|
||||||
#define OSSL_EXCHANGE_PARAM_KDF_OUTLEN "kdf-outlen" /* size_t */
|
|
||||||
/* The following parameter is an octet_string on set and an octet_ptr on get */
|
|
||||||
#define OSSL_EXCHANGE_PARAM_KDF_UKM "kdf-ukm"
|
|
||||||
|
|
||||||
/* Signature parameters */
|
|
||||||
#define OSSL_SIGNATURE_PARAM_ALGORITHM_ID "algorithm-id"
|
|
||||||
#define OSSL_SIGNATURE_PARAM_PAD_MODE OSSL_PKEY_PARAM_PAD_MODE
|
|
||||||
#define OSSL_SIGNATURE_PARAM_DIGEST OSSL_PKEY_PARAM_DIGEST
|
|
||||||
#define OSSL_SIGNATURE_PARAM_PROPERTIES OSSL_PKEY_PARAM_PROPERTIES
|
|
||||||
#define OSSL_SIGNATURE_PARAM_PSS_SALTLEN "saltlen"
|
|
||||||
#define OSSL_SIGNATURE_PARAM_MGF1_DIGEST OSSL_PKEY_PARAM_MGF1_DIGEST
|
|
||||||
#define OSSL_SIGNATURE_PARAM_MGF1_PROPERTIES \
|
|
||||||
OSSL_PKEY_PARAM_MGF1_PROPERTIES
|
|
||||||
#define OSSL_SIGNATURE_PARAM_DIGEST_SIZE OSSL_PKEY_PARAM_DIGEST_SIZE
|
|
||||||
|
|
||||||
/* Asym cipher parameters */
|
|
||||||
#define OSSL_ASYM_CIPHER_PARAM_DIGEST OSSL_PKEY_PARAM_DIGEST
|
|
||||||
#define OSSL_ASYM_CIPHER_PARAM_PROPERTIES OSSL_PKEY_PARAM_PROPERTIES
|
|
||||||
#define OSSL_ASYM_CIPHER_PARAM_ENGINE OSSL_PKEY_PARAM_ENGINE
|
|
||||||
#define OSSL_ASYM_CIPHER_PARAM_PAD_MODE OSSL_PKEY_PARAM_PAD_MODE
|
|
||||||
#define OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST \
|
|
||||||
OSSL_PKEY_PARAM_MGF1_DIGEST
|
|
||||||
#define OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST_PROPS \
|
|
||||||
OSSL_PKEY_PARAM_MGF1_PROPERTIES
|
|
||||||
#define OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST OSSL_ALG_PARAM_DIGEST
|
|
||||||
#define OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST_PROPS "digest-props"
|
|
||||||
/* The following parameter is an octet_string on set and an octet_ptr on get */
|
|
||||||
#define OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL "oaep-label"
|
|
||||||
#define OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION "tls-client-version"
|
|
||||||
#define OSSL_ASYM_CIPHER_PARAM_TLS_NEGOTIATED_VERSION "tls-negotiated-version"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Encoder / decoder parameters
|
|
||||||
*/
|
|
||||||
#define OSSL_ENCODER_PARAM_CIPHER OSSL_ALG_PARAM_CIPHER
|
|
||||||
#define OSSL_ENCODER_PARAM_PROPERTIES OSSL_ALG_PARAM_PROPERTIES
|
|
||||||
/* Currently PVK only, but reusable for others as needed */
|
|
||||||
#define OSSL_ENCODER_PARAM_ENCRYPT_LEVEL "encrypt-level"
|
|
||||||
#define OSSL_ENCODER_PARAM_SAVE_PARAMETERS "save-parameters" /* integer */
|
|
||||||
|
|
||||||
#define OSSL_DECODER_PARAM_PROPERTIES OSSL_ALG_PARAM_PROPERTIES
|
|
||||||
|
|
||||||
/* Passphrase callback parameters */
|
|
||||||
#define OSSL_PASSPHRASE_PARAM_INFO "info"
|
|
||||||
|
|
||||||
/* Keygen callback parameters, from provider to libcrypto */
|
|
||||||
#define OSSL_GEN_PARAM_POTENTIAL "potential" /* integer */
|
|
||||||
#define OSSL_GEN_PARAM_ITERATION "iteration" /* integer */
|
|
||||||
|
|
||||||
/* ACVP Test parameters : These should not be used normally */
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_TEST_XP1 "xp1"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_TEST_XP2 "xp2"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_TEST_XP "xp"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_TEST_XQ1 "xq1"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_TEST_XQ2 "xq2"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_TEST_XQ "xq"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_TEST_P1 "p1"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_TEST_P2 "p2"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_TEST_Q1 "q1"
|
|
||||||
#define OSSL_PKEY_PARAM_RSA_TEST_Q2 "q2"
|
|
||||||
#define OSSL_SIGNATURE_PARAM_KAT "kat"
|
|
||||||
|
|
||||||
/* KEM parameters */
|
|
||||||
#define OSSL_KEM_PARAM_OPERATION "operation"
|
|
||||||
|
|
||||||
/* OSSL_KEM_PARAM_OPERATION values */
|
|
||||||
#define OSSL_KEM_PARAM_OPERATION_RSASVE "RSASVE"
|
|
||||||
|
|
||||||
/* Capabilities */
|
|
||||||
|
|
||||||
/* TLS-GROUP Capability */
|
|
||||||
#define OSSL_CAPABILITY_TLS_GROUP_NAME "tls-group-name"
|
|
||||||
#define OSSL_CAPABILITY_TLS_GROUP_NAME_INTERNAL "tls-group-name-internal"
|
|
||||||
#define OSSL_CAPABILITY_TLS_GROUP_ID "tls-group-id"
|
|
||||||
#define OSSL_CAPABILITY_TLS_GROUP_ALG "tls-group-alg"
|
|
||||||
#define OSSL_CAPABILITY_TLS_GROUP_SECURITY_BITS "tls-group-sec-bits"
|
|
||||||
#define OSSL_CAPABILITY_TLS_GROUP_IS_KEM "tls-group-is-kem"
|
|
||||||
#define OSSL_CAPABILITY_TLS_GROUP_MIN_TLS "tls-min-tls"
|
|
||||||
#define OSSL_CAPABILITY_TLS_GROUP_MAX_TLS "tls-max-tls"
|
|
||||||
#define OSSL_CAPABILITY_TLS_GROUP_MIN_DTLS "tls-min-dtls"
|
|
||||||
#define OSSL_CAPABILITY_TLS_GROUP_MAX_DTLS "tls-max-dtls"
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* storemgmt parameters
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Used by storemgmt_ctx_set_params():
|
|
||||||
*
|
|
||||||
* - OSSL_STORE_PARAM_EXPECT is an INTEGER, and the value is any of the
|
|
||||||
* OSSL_STORE_INFO numbers. This is used to set the expected type of
|
|
||||||
* object loaded.
|
|
||||||
*
|
|
||||||
* - OSSL_STORE_PARAM_SUBJECT, OSSL_STORE_PARAM_ISSUER,
|
|
||||||
* OSSL_STORE_PARAM_SERIAL, OSSL_STORE_PARAM_FINGERPRINT,
|
|
||||||
* OSSL_STORE_PARAM_DIGEST, OSSL_STORE_PARAM_ALIAS
|
|
||||||
* are used as search criteria.
|
|
||||||
* (OSSL_STORE_PARAM_DIGEST is used with OSSL_STORE_PARAM_FINGERPRINT)
|
|
||||||
*/
|
|
||||||
#define OSSL_STORE_PARAM_EXPECT "expect" /* INTEGER */
|
|
||||||
#define OSSL_STORE_PARAM_SUBJECT "subject" /* DER blob => OCTET_STRING */
|
|
||||||
#define OSSL_STORE_PARAM_ISSUER "name" /* DER blob => OCTET_STRING */
|
|
||||||
#define OSSL_STORE_PARAM_SERIAL "serial" /* INTEGER */
|
|
||||||
#define OSSL_STORE_PARAM_DIGEST "digest" /* UTF8_STRING */
|
|
||||||
#define OSSL_STORE_PARAM_FINGERPRINT "fingerprint" /* OCTET_STRING */
|
|
||||||
#define OSSL_STORE_PARAM_ALIAS "alias" /* UTF8_STRING */
|
|
||||||
|
|
||||||
/* You may want to pass properties for the provider implementation to use */
|
|
||||||
#define OSSL_STORE_PARAM_PROPERTIES "properties" /* utf8_string */
|
|
||||||
/* OSSL_DECODER input type if a decoder is used by the store */
|
|
||||||
#define OSSL_STORE_PARAM_INPUT_TYPE "input-type" /* UTF8_STRING */
|
|
||||||
|
|
||||||
# ifdef __cplusplus
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,283 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 1995-2022 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OPENSSL_DSA_H
|
|
||||||
# define OPENSSL_DSA_H
|
|
||||||
# pragma once
|
|
||||||
|
|
||||||
# include <openssl/macros.h>
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
# define HEADER_DSA_H
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# include <openssl/opensslconf.h>
|
|
||||||
# include <openssl/types.h>
|
|
||||||
|
|
||||||
# include <stdlib.h>
|
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DSA
|
|
||||||
# include <openssl/e_os2.h>
|
|
||||||
# include <openssl/asn1.h>
|
|
||||||
# include <openssl/bio.h>
|
|
||||||
# include <openssl/crypto.h>
|
|
||||||
# include <openssl/bn.h>
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_1_1_0
|
|
||||||
# include <openssl/dh.h>
|
|
||||||
# endif
|
|
||||||
# include <openssl/dsaerr.h>
|
|
||||||
# ifndef OPENSSL_NO_STDIO
|
|
||||||
# include <stdio.h>
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
# endif
|
|
||||||
|
|
||||||
int EVP_PKEY_CTX_set_dsa_paramgen_bits(EVP_PKEY_CTX *ctx, int nbits);
|
|
||||||
int EVP_PKEY_CTX_set_dsa_paramgen_q_bits(EVP_PKEY_CTX *ctx, int qbits);
|
|
||||||
int EVP_PKEY_CTX_set_dsa_paramgen_md_props(EVP_PKEY_CTX *ctx,
|
|
||||||
const char *md_name,
|
|
||||||
const char *md_properties);
|
|
||||||
int EVP_PKEY_CTX_set_dsa_paramgen_gindex(EVP_PKEY_CTX *ctx, int gindex);
|
|
||||||
int EVP_PKEY_CTX_set_dsa_paramgen_type(EVP_PKEY_CTX *ctx, const char *name);
|
|
||||||
int EVP_PKEY_CTX_set_dsa_paramgen_seed(EVP_PKEY_CTX *ctx,
|
|
||||||
const unsigned char *seed,
|
|
||||||
size_t seedlen);
|
|
||||||
int EVP_PKEY_CTX_set_dsa_paramgen_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
|
|
||||||
|
|
||||||
# define EVP_PKEY_CTRL_DSA_PARAMGEN_BITS (EVP_PKEY_ALG_CTRL + 1)
|
|
||||||
# define EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS (EVP_PKEY_ALG_CTRL + 2)
|
|
||||||
# define EVP_PKEY_CTRL_DSA_PARAMGEN_MD (EVP_PKEY_ALG_CTRL + 3)
|
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DSA
|
|
||||||
# ifndef OPENSSL_DSA_MAX_MODULUS_BITS
|
|
||||||
# define OPENSSL_DSA_MAX_MODULUS_BITS 10000
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# define OPENSSL_DSA_FIPS_MIN_MODULUS_BITS 1024
|
|
||||||
|
|
||||||
typedef struct DSA_SIG_st DSA_SIG;
|
|
||||||
DSA_SIG *DSA_SIG_new(void);
|
|
||||||
void DSA_SIG_free(DSA_SIG *a);
|
|
||||||
DECLARE_ASN1_ENCODE_FUNCTIONS_only(DSA_SIG, DSA_SIG)
|
|
||||||
void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps);
|
|
||||||
int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s);
|
|
||||||
|
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_1_1_0
|
|
||||||
/*
|
|
||||||
* Does nothing. Previously this switched off constant time behaviour.
|
|
||||||
*/
|
|
||||||
# define DSA_FLAG_NO_EXP_CONSTTIME 0x00
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
# define DSA_FLAG_CACHE_MONT_P 0x01
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If this flag is set the DSA method is FIPS compliant and can be used in
|
|
||||||
* FIPS mode. This is set in the validated module method. If an application
|
|
||||||
* sets this flag in its own methods it is its responsibility to ensure the
|
|
||||||
* result is compliant.
|
|
||||||
*/
|
|
||||||
|
|
||||||
# define DSA_FLAG_FIPS_METHOD 0x0400
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If this flag is set the operations normally disabled in FIPS mode are
|
|
||||||
* permitted it is then the applications responsibility to ensure that the
|
|
||||||
* usage is compliant.
|
|
||||||
*/
|
|
||||||
|
|
||||||
# define DSA_FLAG_NON_FIPS_ALLOW 0x0400
|
|
||||||
# define DSA_FLAG_FIPS_CHECKED 0x0800
|
|
||||||
|
|
||||||
/* Already defined in ossl_typ.h */
|
|
||||||
/* typedef struct dsa_st DSA; */
|
|
||||||
/* typedef struct dsa_method DSA_METHOD; */
|
|
||||||
|
|
||||||
# define d2i_DSAparams_fp(fp, x) \
|
|
||||||
(DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \
|
|
||||||
(char *(*)())d2i_DSAparams, (fp), \
|
|
||||||
(unsigned char **)(x))
|
|
||||||
# define i2d_DSAparams_fp(fp, x) \
|
|
||||||
ASN1_i2d_fp(i2d_DSAparams, (fp), (unsigned char *)(x))
|
|
||||||
# define d2i_DSAparams_bio(bp, x) \
|
|
||||||
ASN1_d2i_bio_of(DSA, DSA_new, d2i_DSAparams, bp, x)
|
|
||||||
# define i2d_DSAparams_bio(bp, x) \
|
|
||||||
ASN1_i2d_bio_of(DSA, i2d_DSAparams, bp, x)
|
|
||||||
|
|
||||||
DECLARE_ASN1_DUP_FUNCTION_name_attr(OSSL_DEPRECATEDIN_3_0, DSA, DSAparams)
|
|
||||||
OSSL_DEPRECATEDIN_3_0 DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen,
|
|
||||||
DSA *dsa);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_do_verify(const unsigned char *dgst, int dgst_len,
|
|
||||||
DSA_SIG *sig, DSA *dsa);
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const DSA_METHOD *DSA_OpenSSL(void);
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void DSA_set_default_method(const DSA_METHOD *);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const DSA_METHOD *DSA_get_default_method(void);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_set_method(DSA *dsa, const DSA_METHOD *);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const DSA_METHOD *DSA_get_method(DSA *d);
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0 DSA *DSA_new(void);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 DSA *DSA_new_method(ENGINE *engine);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void DSA_free(DSA *r);
|
|
||||||
/* "up" the DSA object's reference count */
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_up_ref(DSA *r);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_size(const DSA *);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_bits(const DSA *d);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_security_bits(const DSA *d);
|
|
||||||
/* next 4 return -1 on error */
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in,
|
|
||||||
BIGNUM **kinvp, BIGNUM **rp);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_sign(int type, const unsigned char *dgst,
|
|
||||||
int dlen, unsigned char *sig,
|
|
||||||
unsigned int *siglen, DSA *dsa);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_verify(int type, const unsigned char *dgst,
|
|
||||||
int dgst_len, const unsigned char *sigbuf,
|
|
||||||
int siglen, DSA *dsa);
|
|
||||||
|
|
||||||
# define DSA_get_ex_new_index(l, p, newf, dupf, freef) \
|
|
||||||
CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DSA, l, p, newf, dupf, freef)
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_set_ex_data(DSA *d, int idx, void *arg);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void *DSA_get_ex_data(const DSA *d, int idx);
|
|
||||||
|
|
||||||
DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0,
|
|
||||||
DSA, DSAPublicKey)
|
|
||||||
DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0,
|
|
||||||
DSA, DSAPrivateKey)
|
|
||||||
DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0,
|
|
||||||
DSA, DSAparams)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_0_9_8
|
|
||||||
/* Deprecated version */
|
|
||||||
OSSL_DEPRECATEDIN_0_9_8
|
|
||||||
DSA *DSA_generate_parameters(int bits, unsigned char *seed, int seed_len,
|
|
||||||
int *counter_ret, unsigned long *h_ret,
|
|
||||||
void (*callback) (int, int, void *),
|
|
||||||
void *cb_arg);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
/* New version */
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_generate_parameters_ex(DSA *dsa, int bits,
|
|
||||||
const unsigned char *seed,
|
|
||||||
int seed_len,
|
|
||||||
int *counter_ret,
|
|
||||||
unsigned long *h_ret,
|
|
||||||
BN_GENCB *cb);
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_generate_key(DSA *a);
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSAparams_print(BIO *bp, const DSA *x);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_print(BIO *bp, const DSA *x, int off);
|
|
||||||
# ifndef OPENSSL_NO_STDIO
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSAparams_print_fp(FILE *fp, const DSA *x);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_print_fp(FILE *bp, const DSA *x, int off);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# define DSS_prime_checks 64
|
|
||||||
/*
|
|
||||||
* Primality test according to FIPS PUB 186-4, Appendix C.3. Since we only
|
|
||||||
* have one value here we set the number of checks to 64 which is the 128 bit
|
|
||||||
* security level that is the highest level and valid for creating a 3072 bit
|
|
||||||
* DSA key.
|
|
||||||
*/
|
|
||||||
# define DSA_is_prime(n, callback, cb_arg) \
|
|
||||||
BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)
|
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DH
|
|
||||||
/*
|
|
||||||
* Convert DSA structure (key or just parameters) into DH structure (be
|
|
||||||
* careful to avoid small subgroup attacks when using this!)
|
|
||||||
*/
|
|
||||||
OSSL_DEPRECATEDIN_3_0 DH *DSA_dup_DH(const DSA *r);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void DSA_get0_pqg(const DSA *d, const BIGNUM **p,
|
|
||||||
const BIGNUM **q, const BIGNUM **g);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void DSA_get0_key(const DSA *d, const BIGNUM **pub_key,
|
|
||||||
const BIGNUM **priv_key);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_set0_key(DSA *d, BIGNUM *pub_key,
|
|
||||||
BIGNUM *priv_key);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_p(const DSA *d);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_q(const DSA *d);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_g(const DSA *d);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_pub_key(const DSA *d);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_priv_key(const DSA *d);
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void DSA_setnull_priv_key(DSA *d);
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void DSA_clear_flags(DSA *d, int flags);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_test_flags(const DSA *d, int flags);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void DSA_set_flags(DSA *d, int flags);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 ENGINE *DSA_get0_engine(DSA *d);
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0 DSA_METHOD *DSA_meth_new(const char *name, int flags);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void DSA_meth_free(DSA_METHOD *dsam);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 DSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const char *DSA_meth_get0_name(const DSA_METHOD *dsam);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_meth_set1_name(DSA_METHOD *dsam,
|
|
||||||
const char *name);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_meth_get_flags(const DSA_METHOD *dsam);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_flags(DSA_METHOD *dsam, int flags);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void *DSA_meth_get0_app_data(const DSA_METHOD *dsam);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_meth_set0_app_data(DSA_METHOD *dsam,
|
|
||||||
void *app_data);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 DSA_SIG *(*DSA_meth_get_sign(const DSA_METHOD *dsam))
|
|
||||||
(const unsigned char *, int, DSA *);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_sign(DSA_METHOD *dsam,
|
|
||||||
DSA_SIG *(*sign) (const unsigned char *, int, DSA *));
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_sign_setup(const DSA_METHOD *dsam))
|
|
||||||
(DSA *, BN_CTX *, BIGNUM **, BIGNUM **);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_sign_setup(DSA_METHOD *dsam,
|
|
||||||
int (*sign_setup) (DSA *, BN_CTX *, BIGNUM **, BIGNUM **));
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_verify(const DSA_METHOD *dsam))
|
|
||||||
(const unsigned char *, int, DSA_SIG *, DSA *);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_verify(DSA_METHOD *dsam,
|
|
||||||
int (*verify) (const unsigned char *, int, DSA_SIG *, DSA *));
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_mod_exp(const DSA_METHOD *dsam))
|
|
||||||
(DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,
|
|
||||||
const BIGNUM *, const BIGNUM *, BN_CTX *, BN_MONT_CTX *);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_mod_exp(DSA_METHOD *dsam,
|
|
||||||
int (*mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,
|
|
||||||
const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *,
|
|
||||||
BN_MONT_CTX *));
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_bn_mod_exp(const DSA_METHOD *dsam))
|
|
||||||
(DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,
|
|
||||||
BN_CTX *, BN_MONT_CTX *);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_bn_mod_exp(DSA_METHOD *dsam,
|
|
||||||
int (*bn_mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,
|
|
||||||
const BIGNUM *, BN_CTX *, BN_MONT_CTX *));
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_init(const DSA_METHOD *dsam))(DSA *);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_init(DSA_METHOD *dsam,
|
|
||||||
int (*init)(DSA *));
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_finish(const DSA_METHOD *dsam))(DSA *);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_finish(DSA_METHOD *dsam,
|
|
||||||
int (*finish)(DSA *));
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_paramgen(const DSA_METHOD *dsam))
|
|
||||||
(DSA *, int, const unsigned char *, int, int *, unsigned long *,
|
|
||||||
BN_GENCB *);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_paramgen(DSA_METHOD *dsam,
|
|
||||||
int (*paramgen) (DSA *, int, const unsigned char *, int, int *,
|
|
||||||
unsigned long *, BN_GENCB *));
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_keygen(const DSA_METHOD *dsam))(DSA *);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_keygen(DSA_METHOD *dsam,
|
|
||||||
int (*keygen) (DSA *));
|
|
||||||
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# ifdef __cplusplus
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,77 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2023 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OPENSSL_FIPS_NAMES_H
|
|
||||||
# define OPENSSL_FIPS_NAMES_H
|
|
||||||
# pragma once
|
|
||||||
|
|
||||||
# ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Parameter names that the FIPS Provider defines
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The calculated MAC of the module file (Used for FIPS Self Testing)
|
|
||||||
* Type: OSSL_PARAM_UTF8_STRING
|
|
||||||
*/
|
|
||||||
# define OSSL_PROV_FIPS_PARAM_MODULE_MAC "module-mac"
|
|
||||||
/*
|
|
||||||
* A version number for the fips install process (Used for FIPS Self Testing)
|
|
||||||
* Type: OSSL_PARAM_UTF8_STRING
|
|
||||||
*/
|
|
||||||
# define OSSL_PROV_FIPS_PARAM_INSTALL_VERSION "install-version"
|
|
||||||
/*
|
|
||||||
* The calculated MAC of the install status indicator (Used for FIPS Self Testing)
|
|
||||||
* Type: OSSL_PARAM_UTF8_STRING
|
|
||||||
*/
|
|
||||||
# define OSSL_PROV_FIPS_PARAM_INSTALL_MAC "install-mac"
|
|
||||||
/*
|
|
||||||
* The install status indicator (Used for FIPS Self Testing)
|
|
||||||
* Type: OSSL_PARAM_UTF8_STRING
|
|
||||||
*/
|
|
||||||
# define OSSL_PROV_FIPS_PARAM_INSTALL_STATUS "install-status"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* A boolean that determines if the FIPS conditional test errors result in
|
|
||||||
* the module entering an error state.
|
|
||||||
* Type: OSSL_PARAM_UTF8_STRING
|
|
||||||
*/
|
|
||||||
# define OSSL_PROV_FIPS_PARAM_CONDITIONAL_ERRORS "conditional-errors"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* A boolean that determines if the runtime FIPS security checks are performed.
|
|
||||||
* This is enabled by default.
|
|
||||||
* Type: OSSL_PARAM_UTF8_STRING
|
|
||||||
*/
|
|
||||||
# define OSSL_PROV_FIPS_PARAM_SECURITY_CHECKS "security-checks"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* A boolean that determines if the runtime FIPS check for TLS1_PRF EMS is performed.
|
|
||||||
* This is disabled by default.
|
|
||||||
* Type: OSSL_PARAM_UTF8_STRING
|
|
||||||
*/
|
|
||||||
# define OSSL_PROV_FIPS_PARAM_TLS1_PRF_EMS_CHECK "tls1-prf-ems-check"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* A boolean that determines if truncated digests can be used with Hash and HMAC
|
|
||||||
* DRBGs. FIPS 140-3 IG D.R disallows such use for efficiency rather than
|
|
||||||
* security reasons.
|
|
||||||
* This is disabled by default.
|
|
||||||
* Type: OSSL_PARAM_UTF8_STRING
|
|
||||||
*/
|
|
||||||
# define OSSL_PROV_FIPS_PARAM_DRBG_TRUNC_DIGEST "drbg-no-trunc-md"
|
|
||||||
|
|
||||||
# ifdef __cplusplus
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#endif /* OPENSSL_FIPS_NAMES_H */
|
|
||||||
@@ -1,613 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 1995-2022 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OPENSSL_RSA_H
|
|
||||||
# define OPENSSL_RSA_H
|
|
||||||
# pragma once
|
|
||||||
|
|
||||||
# include <openssl/macros.h>
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
# define HEADER_RSA_H
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# include <openssl/opensslconf.h>
|
|
||||||
|
|
||||||
# include <openssl/asn1.h>
|
|
||||||
# include <openssl/bio.h>
|
|
||||||
# include <openssl/crypto.h>
|
|
||||||
# include <openssl/types.h>
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_1_1_0
|
|
||||||
# include <openssl/bn.h>
|
|
||||||
# endif
|
|
||||||
# include <openssl/rsaerr.h>
|
|
||||||
# include <openssl/safestack.h>
|
|
||||||
# ifndef OPENSSL_NO_STDIO
|
|
||||||
# include <stdio.h>
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef OPENSSL_RSA_MAX_MODULUS_BITS
|
|
||||||
# define OPENSSL_RSA_MAX_MODULUS_BITS 16384
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# define RSA_3 0x3L
|
|
||||||
# define RSA_F4 0x10001L
|
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
/* The types RSA and RSA_METHOD are defined in ossl_typ.h */
|
|
||||||
|
|
||||||
# define OPENSSL_RSA_FIPS_MIN_MODULUS_BITS 2048
|
|
||||||
|
|
||||||
# ifndef OPENSSL_RSA_SMALL_MODULUS_BITS
|
|
||||||
# define OPENSSL_RSA_SMALL_MODULUS_BITS 3072
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* exponent limit enforced for "large" modulus only */
|
|
||||||
# ifndef OPENSSL_RSA_MAX_PUBEXP_BITS
|
|
||||||
# define OPENSSL_RSA_MAX_PUBEXP_BITS 64
|
|
||||||
# endif
|
|
||||||
/* based on RFC 8017 appendix A.1.2 */
|
|
||||||
# define RSA_ASN1_VERSION_DEFAULT 0
|
|
||||||
# define RSA_ASN1_VERSION_MULTI 1
|
|
||||||
|
|
||||||
# define RSA_DEFAULT_PRIME_NUM 2
|
|
||||||
|
|
||||||
# define RSA_METHOD_FLAG_NO_CHECK 0x0001
|
|
||||||
# define RSA_FLAG_CACHE_PUBLIC 0x0002
|
|
||||||
# define RSA_FLAG_CACHE_PRIVATE 0x0004
|
|
||||||
# define RSA_FLAG_BLINDING 0x0008
|
|
||||||
# define RSA_FLAG_THREAD_SAFE 0x0010
|
|
||||||
/*
|
|
||||||
* This flag means the private key operations will be handled by rsa_mod_exp
|
|
||||||
* and that they do not depend on the private key components being present:
|
|
||||||
* for example a key stored in external hardware. Without this flag
|
|
||||||
* bn_mod_exp gets called when private key components are absent.
|
|
||||||
*/
|
|
||||||
# define RSA_FLAG_EXT_PKEY 0x0020
|
|
||||||
|
|
||||||
/*
|
|
||||||
* new with 0.9.6j and 0.9.7b; the built-in
|
|
||||||
* RSA implementation now uses blinding by
|
|
||||||
* default (ignoring RSA_FLAG_BLINDING),
|
|
||||||
* but other engines might not need it
|
|
||||||
*/
|
|
||||||
# define RSA_FLAG_NO_BLINDING 0x0080
|
|
||||||
# endif /* OPENSSL_NO_DEPRECATED_3_0 */
|
|
||||||
/*
|
|
||||||
* Does nothing. Previously this switched off constant time behaviour.
|
|
||||||
*/
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_1_1_0
|
|
||||||
# define RSA_FLAG_NO_CONSTTIME 0x0000
|
|
||||||
# endif
|
|
||||||
/* deprecated name for the flag*/
|
|
||||||
/*
|
|
||||||
* new with 0.9.7h; the built-in RSA
|
|
||||||
* implementation now uses constant time
|
|
||||||
* modular exponentiation for secret exponents
|
|
||||||
* by default. This flag causes the
|
|
||||||
* faster variable sliding window method to
|
|
||||||
* be used for all exponents.
|
|
||||||
*/
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_0_9_8
|
|
||||||
# define RSA_FLAG_NO_EXP_CONSTTIME RSA_FLAG_NO_CONSTTIME
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* New with 3.0: use part of the flags to denote exact type of RSA key,
|
|
||||||
* some of which are limited to specific signature and encryption schemes.
|
|
||||||
* These different types share the same RSA structure, but indicate the
|
|
||||||
* use of certain fields in that structure.
|
|
||||||
* Currently known are:
|
|
||||||
* RSA - this is the "normal" unlimited RSA structure (typenum 0)
|
|
||||||
* RSASSA-PSS - indicates that the PSS parameters are used.
|
|
||||||
* RSAES-OAEP - no specific field used for the moment, but OAEP padding
|
|
||||||
* is expected. (currently unused)
|
|
||||||
*
|
|
||||||
* 4 bits allow for 16 types
|
|
||||||
*/
|
|
||||||
# define RSA_FLAG_TYPE_MASK 0xF000
|
|
||||||
# define RSA_FLAG_TYPE_RSA 0x0000
|
|
||||||
# define RSA_FLAG_TYPE_RSASSAPSS 0x1000
|
|
||||||
# define RSA_FLAG_TYPE_RSAESOAEP 0x2000
|
|
||||||
|
|
||||||
int EVP_PKEY_CTX_set_rsa_padding(EVP_PKEY_CTX *ctx, int pad_mode);
|
|
||||||
int EVP_PKEY_CTX_get_rsa_padding(EVP_PKEY_CTX *ctx, int *pad_mode);
|
|
||||||
|
|
||||||
int EVP_PKEY_CTX_set_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int saltlen);
|
|
||||||
int EVP_PKEY_CTX_get_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int *saltlen);
|
|
||||||
|
|
||||||
int EVP_PKEY_CTX_set_rsa_keygen_bits(EVP_PKEY_CTX *ctx, int bits);
|
|
||||||
int EVP_PKEY_CTX_set1_rsa_keygen_pubexp(EVP_PKEY_CTX *ctx, BIGNUM *pubexp);
|
|
||||||
int EVP_PKEY_CTX_set_rsa_keygen_primes(EVP_PKEY_CTX *ctx, int primes);
|
|
||||||
int EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen(EVP_PKEY_CTX *ctx, int saltlen);
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int EVP_PKEY_CTX_set_rsa_keygen_pubexp(EVP_PKEY_CTX *ctx, BIGNUM *pubexp);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* Salt length matches digest */
|
|
||||||
# define RSA_PSS_SALTLEN_DIGEST -1
|
|
||||||
/* Verify only: auto detect salt length */
|
|
||||||
# define RSA_PSS_SALTLEN_AUTO -2
|
|
||||||
/* Set salt length to maximum possible */
|
|
||||||
# define RSA_PSS_SALTLEN_MAX -3
|
|
||||||
/* Auto-detect on verify, set salt length to min(maximum possible, digest
|
|
||||||
* length) on sign */
|
|
||||||
# define RSA_PSS_SALTLEN_AUTO_DIGEST_MAX -4
|
|
||||||
/* Old compatible max salt length for sign only */
|
|
||||||
# define RSA_PSS_SALTLEN_MAX_SIGN -2
|
|
||||||
|
|
||||||
int EVP_PKEY_CTX_set_rsa_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
|
|
||||||
int EVP_PKEY_CTX_set_rsa_mgf1_md_name(EVP_PKEY_CTX *ctx, const char *mdname,
|
|
||||||
const char *mdprops);
|
|
||||||
int EVP_PKEY_CTX_get_rsa_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD **md);
|
|
||||||
int EVP_PKEY_CTX_get_rsa_mgf1_md_name(EVP_PKEY_CTX *ctx, char *name,
|
|
||||||
size_t namelen);
|
|
||||||
int EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
|
|
||||||
int EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md_name(EVP_PKEY_CTX *ctx,
|
|
||||||
const char *mdname);
|
|
||||||
|
|
||||||
int EVP_PKEY_CTX_set_rsa_pss_keygen_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
|
|
||||||
int EVP_PKEY_CTX_set_rsa_pss_keygen_md_name(EVP_PKEY_CTX *ctx,
|
|
||||||
const char *mdname,
|
|
||||||
const char *mdprops);
|
|
||||||
|
|
||||||
int EVP_PKEY_CTX_set_rsa_oaep_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
|
|
||||||
int EVP_PKEY_CTX_set_rsa_oaep_md_name(EVP_PKEY_CTX *ctx, const char *mdname,
|
|
||||||
const char *mdprops);
|
|
||||||
int EVP_PKEY_CTX_get_rsa_oaep_md(EVP_PKEY_CTX *ctx, const EVP_MD **md);
|
|
||||||
int EVP_PKEY_CTX_get_rsa_oaep_md_name(EVP_PKEY_CTX *ctx, char *name,
|
|
||||||
size_t namelen);
|
|
||||||
int EVP_PKEY_CTX_set0_rsa_oaep_label(EVP_PKEY_CTX *ctx, void *label, int llen);
|
|
||||||
int EVP_PKEY_CTX_get0_rsa_oaep_label(EVP_PKEY_CTX *ctx, unsigned char **label);
|
|
||||||
|
|
||||||
# define EVP_PKEY_CTRL_RSA_PADDING (EVP_PKEY_ALG_CTRL + 1)
|
|
||||||
# define EVP_PKEY_CTRL_RSA_PSS_SALTLEN (EVP_PKEY_ALG_CTRL + 2)
|
|
||||||
|
|
||||||
# define EVP_PKEY_CTRL_RSA_KEYGEN_BITS (EVP_PKEY_ALG_CTRL + 3)
|
|
||||||
# define EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP (EVP_PKEY_ALG_CTRL + 4)
|
|
||||||
# define EVP_PKEY_CTRL_RSA_MGF1_MD (EVP_PKEY_ALG_CTRL + 5)
|
|
||||||
|
|
||||||
# define EVP_PKEY_CTRL_GET_RSA_PADDING (EVP_PKEY_ALG_CTRL + 6)
|
|
||||||
# define EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN (EVP_PKEY_ALG_CTRL + 7)
|
|
||||||
# define EVP_PKEY_CTRL_GET_RSA_MGF1_MD (EVP_PKEY_ALG_CTRL + 8)
|
|
||||||
|
|
||||||
# define EVP_PKEY_CTRL_RSA_OAEP_MD (EVP_PKEY_ALG_CTRL + 9)
|
|
||||||
# define EVP_PKEY_CTRL_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 10)
|
|
||||||
|
|
||||||
# define EVP_PKEY_CTRL_GET_RSA_OAEP_MD (EVP_PKEY_ALG_CTRL + 11)
|
|
||||||
# define EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 12)
|
|
||||||
|
|
||||||
# define EVP_PKEY_CTRL_RSA_KEYGEN_PRIMES (EVP_PKEY_ALG_CTRL + 13)
|
|
||||||
|
|
||||||
# define RSA_PKCS1_PADDING 1
|
|
||||||
# define RSA_NO_PADDING 3
|
|
||||||
# define RSA_PKCS1_OAEP_PADDING 4
|
|
||||||
# define RSA_X931_PADDING 5
|
|
||||||
|
|
||||||
/* EVP_PKEY_ only */
|
|
||||||
# define RSA_PKCS1_PSS_PADDING 6
|
|
||||||
# define RSA_PKCS1_WITH_TLS_PADDING 7
|
|
||||||
|
|
||||||
# define RSA_PKCS1_PADDING_SIZE 11
|
|
||||||
|
|
||||||
# define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,arg)
|
|
||||||
# define RSA_get_app_data(s) RSA_get_ex_data(s,0)
|
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
OSSL_DEPRECATEDIN_3_0 RSA *RSA_new(void);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 RSA *RSA_new_method(ENGINE *engine);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_bits(const RSA *rsa);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_size(const RSA *rsa);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_security_bits(const RSA *rsa);
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_set0_crt_params(RSA *r,
|
|
||||||
BIGNUM *dmp1, BIGNUM *dmq1,
|
|
||||||
BIGNUM *iqmp);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_set0_multi_prime_params(RSA *r,
|
|
||||||
BIGNUM *primes[],
|
|
||||||
BIGNUM *exps[],
|
|
||||||
BIGNUM *coeffs[],
|
|
||||||
int pnum);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void RSA_get0_key(const RSA *r,
|
|
||||||
const BIGNUM **n, const BIGNUM **e,
|
|
||||||
const BIGNUM **d);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void RSA_get0_factors(const RSA *r,
|
|
||||||
const BIGNUM **p, const BIGNUM **q);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_get_multi_prime_extra_count(const RSA *r);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_get0_multi_prime_factors(const RSA *r,
|
|
||||||
const BIGNUM *primes[]);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void RSA_get0_crt_params(const RSA *r,
|
|
||||||
const BIGNUM **dmp1,
|
|
||||||
const BIGNUM **dmq1,
|
|
||||||
const BIGNUM **iqmp);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_get0_multi_prime_crt_params(const RSA *r, const BIGNUM *exps[],
|
|
||||||
const BIGNUM *coeffs[]);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_n(const RSA *d);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_e(const RSA *d);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_d(const RSA *d);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_p(const RSA *d);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_q(const RSA *d);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_dmp1(const RSA *r);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_dmq1(const RSA *r);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_iqmp(const RSA *r);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const RSA_PSS_PARAMS *RSA_get0_pss_params(const RSA *r);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void RSA_clear_flags(RSA *r, int flags);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_test_flags(const RSA *r, int flags);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void RSA_set_flags(RSA *r, int flags);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_get_version(RSA *r);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 ENGINE *RSA_get0_engine(const RSA *r);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void RSA_setnull_factors(RSA *r, int p, int q);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void RSA_setnull_key(RSA *r, int n, int e, int d);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void RSA_setnull_crt_params(RSA *r, int dmp1, int dmq1, int iqmp);
|
|
||||||
# endif /* !OPENSSL_NO_DEPRECATED_3_0 */
|
|
||||||
|
|
||||||
# define EVP_RSA_gen(bits) \
|
|
||||||
EVP_PKEY_Q_keygen(NULL, NULL, "RSA", (size_t)(0 + (bits)))
|
|
||||||
|
|
||||||
/* Deprecated version */
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_0_9_8
|
|
||||||
OSSL_DEPRECATEDIN_0_9_8 RSA *RSA_generate_key(int bits, unsigned long e, void
|
|
||||||
(*callback) (int, int, void *),
|
|
||||||
void *cb_arg);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* New version */
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e,
|
|
||||||
BN_GENCB *cb);
|
|
||||||
/* Multi-prime version */
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_generate_multi_prime_key(RSA *rsa, int bits,
|
|
||||||
int primes, BIGNUM *e,
|
|
||||||
BN_GENCB *cb);
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_X931_derive_ex(RSA *rsa, BIGNUM *p1, BIGNUM *p2,
|
|
||||||
BIGNUM *q1, BIGNUM *q2,
|
|
||||||
const BIGNUM *Xp1, const BIGNUM *Xp2,
|
|
||||||
const BIGNUM *Xp, const BIGNUM *Xq1,
|
|
||||||
const BIGNUM *Xq2, const BIGNUM *Xq,
|
|
||||||
const BIGNUM *e, BN_GENCB *cb);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_X931_generate_key_ex(RSA *rsa, int bits,
|
|
||||||
const BIGNUM *e,
|
|
||||||
BN_GENCB *cb);
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_check_key(const RSA *);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_check_key_ex(const RSA *, BN_GENCB *cb);
|
|
||||||
/* next 4 return -1 on error */
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to,
|
|
||||||
RSA *rsa, int padding);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_private_encrypt(int flen, const unsigned char *from, unsigned char *to,
|
|
||||||
RSA *rsa, int padding);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to,
|
|
||||||
RSA *rsa, int padding);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_private_decrypt(int flen, const unsigned char *from, unsigned char *to,
|
|
||||||
RSA *rsa, int padding);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void RSA_free(RSA *r);
|
|
||||||
/* "up" the RSA object's reference count */
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_up_ref(RSA *r);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_flags(const RSA *r);
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void RSA_set_default_method(const RSA_METHOD *meth);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const RSA_METHOD *RSA_get_default_method(void);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const RSA_METHOD *RSA_null_method(void);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const RSA_METHOD *RSA_get_method(const RSA *rsa);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
|
|
||||||
|
|
||||||
/* these are the actual RSA functions */
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const RSA_METHOD *RSA_PKCS1_OpenSSL(void);
|
|
||||||
|
|
||||||
DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(OSSL_DEPRECATEDIN_3_0,
|
|
||||||
RSA, RSAPublicKey)
|
|
||||||
DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(OSSL_DEPRECATEDIN_3_0,
|
|
||||||
RSA, RSAPrivateKey)
|
|
||||||
# endif /* !OPENSSL_NO_DEPRECATED_3_0 */
|
|
||||||
|
|
||||||
int RSA_pkey_ctx_ctrl(EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2);
|
|
||||||
|
|
||||||
struct rsa_pss_params_st {
|
|
||||||
X509_ALGOR *hashAlgorithm;
|
|
||||||
X509_ALGOR *maskGenAlgorithm;
|
|
||||||
ASN1_INTEGER *saltLength;
|
|
||||||
ASN1_INTEGER *trailerField;
|
|
||||||
/* Decoded hash algorithm from maskGenAlgorithm */
|
|
||||||
X509_ALGOR *maskHash;
|
|
||||||
};
|
|
||||||
|
|
||||||
DECLARE_ASN1_FUNCTIONS(RSA_PSS_PARAMS)
|
|
||||||
DECLARE_ASN1_DUP_FUNCTION(RSA_PSS_PARAMS)
|
|
||||||
|
|
||||||
typedef struct rsa_oaep_params_st {
|
|
||||||
X509_ALGOR *hashFunc;
|
|
||||||
X509_ALGOR *maskGenFunc;
|
|
||||||
X509_ALGOR *pSourceFunc;
|
|
||||||
/* Decoded hash algorithm from maskGenFunc */
|
|
||||||
X509_ALGOR *maskHash;
|
|
||||||
} RSA_OAEP_PARAMS;
|
|
||||||
|
|
||||||
DECLARE_ASN1_FUNCTIONS(RSA_OAEP_PARAMS)
|
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
# ifndef OPENSSL_NO_STDIO
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_print_fp(FILE *fp, const RSA *r, int offset);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_print(BIO *bp, const RSA *r, int offset);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following 2 functions sign and verify a X509_SIG ASN1 object inside
|
|
||||||
* PKCS#1 padded RSA encryption
|
|
||||||
*/
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_sign(int type, const unsigned char *m,
|
|
||||||
unsigned int m_length, unsigned char *sigret,
|
|
||||||
unsigned int *siglen, RSA *rsa);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_verify(int type, const unsigned char *m,
|
|
||||||
unsigned int m_length,
|
|
||||||
const unsigned char *sigbuf,
|
|
||||||
unsigned int siglen, RSA *rsa);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following 2 function sign and verify a ASN1_OCTET_STRING object inside
|
|
||||||
* PKCS#1 padded RSA encryption
|
|
||||||
*/
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_sign_ASN1_OCTET_STRING(int type,
|
|
||||||
const unsigned char *m, unsigned int m_length,
|
|
||||||
unsigned char *sigret, unsigned int *siglen,
|
|
||||||
RSA *rsa);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_verify_ASN1_OCTET_STRING(int type,
|
|
||||||
const unsigned char *m, unsigned int m_length,
|
|
||||||
unsigned char *sigbuf, unsigned int siglen,
|
|
||||||
RSA *rsa);
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void RSA_blinding_off(RSA *rsa);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx);
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
|
|
||||||
const unsigned char *f, int fl);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
|
|
||||||
const unsigned char *f, int fl,
|
|
||||||
int rsa_len);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
|
|
||||||
const unsigned char *f, int fl);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
|
|
||||||
const unsigned char *f, int fl,
|
|
||||||
int rsa_len);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int PKCS1_MGF1(unsigned char *mask, long len,
|
|
||||||
const unsigned char *seed, long seedlen,
|
|
||||||
const EVP_MD *dgst);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
|
|
||||||
const unsigned char *f, int fl,
|
|
||||||
const unsigned char *p, int pl);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
|
|
||||||
const unsigned char *f, int fl, int rsa_len,
|
|
||||||
const unsigned char *p, int pl);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
|
|
||||||
const unsigned char *from, int flen,
|
|
||||||
const unsigned char *param, int plen,
|
|
||||||
const EVP_MD *md, const EVP_MD *mgf1md);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
|
|
||||||
const unsigned char *from, int flen,
|
|
||||||
int num,
|
|
||||||
const unsigned char *param, int plen,
|
|
||||||
const EVP_MD *md, const EVP_MD *mgf1md);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_padding_add_none(unsigned char *to, int tlen,
|
|
||||||
const unsigned char *f, int fl);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_padding_check_none(unsigned char *to, int tlen,
|
|
||||||
const unsigned char *f, int fl,
|
|
||||||
int rsa_len);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_padding_add_X931(unsigned char *to, int tlen,
|
|
||||||
const unsigned char *f, int fl);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_padding_check_X931(unsigned char *to, int tlen,
|
|
||||||
const unsigned char *f, int fl,
|
|
||||||
int rsa_len);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_X931_hash_id(int nid);
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash,
|
|
||||||
const EVP_MD *Hash, const unsigned char *EM,
|
|
||||||
int sLen);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM,
|
|
||||||
const unsigned char *mHash, const EVP_MD *Hash,
|
|
||||||
int sLen);
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash,
|
|
||||||
const EVP_MD *Hash, const EVP_MD *mgf1Hash,
|
|
||||||
const unsigned char *EM, int sLen);
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM,
|
|
||||||
const unsigned char *mHash,
|
|
||||||
const EVP_MD *Hash, const EVP_MD *mgf1Hash,
|
|
||||||
int sLen);
|
|
||||||
|
|
||||||
# define RSA_get_ex_new_index(l, p, newf, dupf, freef) \
|
|
||||||
CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_RSA, l, p, newf, dupf, freef)
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_set_ex_data(RSA *r, int idx, void *arg);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void *RSA_get_ex_data(const RSA *r, int idx);
|
|
||||||
|
|
||||||
DECLARE_ASN1_DUP_FUNCTION_name_attr(OSSL_DEPRECATEDIN_3_0, RSA, RSAPublicKey)
|
|
||||||
DECLARE_ASN1_DUP_FUNCTION_name_attr(OSSL_DEPRECATEDIN_3_0, RSA, RSAPrivateKey)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If this flag is set the RSA method is FIPS compliant and can be used in
|
|
||||||
* FIPS mode. This is set in the validated module method. If an application
|
|
||||||
* sets this flag in its own methods it is its responsibility to ensure the
|
|
||||||
* result is compliant.
|
|
||||||
*/
|
|
||||||
|
|
||||||
# define RSA_FLAG_FIPS_METHOD 0x0400
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If this flag is set the operations normally disabled in FIPS mode are
|
|
||||||
* permitted it is then the applications responsibility to ensure that the
|
|
||||||
* usage is compliant.
|
|
||||||
*/
|
|
||||||
|
|
||||||
# define RSA_FLAG_NON_FIPS_ALLOW 0x0400
|
|
||||||
/*
|
|
||||||
* Application has decided PRNG is good enough to generate a key: don't
|
|
||||||
* check.
|
|
||||||
*/
|
|
||||||
# define RSA_FLAG_CHECKED 0x0800
|
|
||||||
|
|
||||||
OSSL_DEPRECATEDIN_3_0 RSA_METHOD *RSA_meth_new(const char *name, int flags);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void RSA_meth_free(RSA_METHOD *meth);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 const char *RSA_meth_get0_name(const RSA_METHOD *meth);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_meth_set1_name(RSA_METHOD *meth,
|
|
||||||
const char *name);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_meth_get_flags(const RSA_METHOD *meth);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_meth_set_flags(RSA_METHOD *meth, int flags);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 void *RSA_meth_get0_app_data(const RSA_METHOD *meth);
|
|
||||||
OSSL_DEPRECATEDIN_3_0 int RSA_meth_set0_app_data(RSA_METHOD *meth,
|
|
||||||
void *app_data);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int (*RSA_meth_get_pub_enc(const RSA_METHOD *meth)) (int flen,
|
|
||||||
const unsigned char *from,
|
|
||||||
unsigned char *to,
|
|
||||||
RSA *rsa, int padding);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_meth_set_pub_enc(RSA_METHOD *rsa,
|
|
||||||
int (*pub_enc) (int flen, const unsigned char *from,
|
|
||||||
unsigned char *to, RSA *rsa,
|
|
||||||
int padding));
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int (*RSA_meth_get_pub_dec(const RSA_METHOD *meth)) (int flen,
|
|
||||||
const unsigned char *from,
|
|
||||||
unsigned char *to,
|
|
||||||
RSA *rsa, int padding);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_meth_set_pub_dec(RSA_METHOD *rsa,
|
|
||||||
int (*pub_dec) (int flen, const unsigned char *from,
|
|
||||||
unsigned char *to, RSA *rsa,
|
|
||||||
int padding));
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int (*RSA_meth_get_priv_enc(const RSA_METHOD *meth)) (int flen,
|
|
||||||
const unsigned char *from,
|
|
||||||
unsigned char *to,
|
|
||||||
RSA *rsa, int padding);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_meth_set_priv_enc(RSA_METHOD *rsa,
|
|
||||||
int (*priv_enc) (int flen, const unsigned char *from,
|
|
||||||
unsigned char *to, RSA *rsa,
|
|
||||||
int padding));
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int (*RSA_meth_get_priv_dec(const RSA_METHOD *meth)) (int flen,
|
|
||||||
const unsigned char *from,
|
|
||||||
unsigned char *to,
|
|
||||||
RSA *rsa, int padding);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_meth_set_priv_dec(RSA_METHOD *rsa,
|
|
||||||
int (*priv_dec) (int flen, const unsigned char *from,
|
|
||||||
unsigned char *to, RSA *rsa,
|
|
||||||
int padding));
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int (*RSA_meth_get_mod_exp(const RSA_METHOD *meth)) (BIGNUM *r0,
|
|
||||||
const BIGNUM *i,
|
|
||||||
RSA *rsa, BN_CTX *ctx);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_meth_set_mod_exp(RSA_METHOD *rsa,
|
|
||||||
int (*mod_exp) (BIGNUM *r0, const BIGNUM *i, RSA *rsa,
|
|
||||||
BN_CTX *ctx));
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth)) (BIGNUM *r,
|
|
||||||
const BIGNUM *a,
|
|
||||||
const BIGNUM *p,
|
|
||||||
const BIGNUM *m,
|
|
||||||
BN_CTX *ctx,
|
|
||||||
BN_MONT_CTX *m_ctx);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_meth_set_bn_mod_exp(RSA_METHOD *rsa,
|
|
||||||
int (*bn_mod_exp) (BIGNUM *r,
|
|
||||||
const BIGNUM *a,
|
|
||||||
const BIGNUM *p,
|
|
||||||
const BIGNUM *m,
|
|
||||||
BN_CTX *ctx,
|
|
||||||
BN_MONT_CTX *m_ctx));
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int (*RSA_meth_get_init(const RSA_METHOD *meth)) (RSA *rsa);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_meth_set_init(RSA_METHOD *rsa, int (*init) (RSA *rsa));
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int (*RSA_meth_get_finish(const RSA_METHOD *meth)) (RSA *rsa);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_meth_set_finish(RSA_METHOD *rsa, int (*finish) (RSA *rsa));
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int (*RSA_meth_get_sign(const RSA_METHOD *meth)) (int type,
|
|
||||||
const unsigned char *m,
|
|
||||||
unsigned int m_length,
|
|
||||||
unsigned char *sigret,
|
|
||||||
unsigned int *siglen,
|
|
||||||
const RSA *rsa);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_meth_set_sign(RSA_METHOD *rsa,
|
|
||||||
int (*sign) (int type, const unsigned char *m,
|
|
||||||
unsigned int m_length,
|
|
||||||
unsigned char *sigret, unsigned int *siglen,
|
|
||||||
const RSA *rsa));
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int (*RSA_meth_get_verify(const RSA_METHOD *meth)) (int dtype,
|
|
||||||
const unsigned char *m,
|
|
||||||
unsigned int m_length,
|
|
||||||
const unsigned char *sigbuf,
|
|
||||||
unsigned int siglen,
|
|
||||||
const RSA *rsa);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_meth_set_verify(RSA_METHOD *rsa,
|
|
||||||
int (*verify) (int dtype, const unsigned char *m,
|
|
||||||
unsigned int m_length,
|
|
||||||
const unsigned char *sigbuf,
|
|
||||||
unsigned int siglen, const RSA *rsa));
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int (*RSA_meth_get_keygen(const RSA_METHOD *meth)) (RSA *rsa, int bits,
|
|
||||||
BIGNUM *e, BN_GENCB *cb);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_meth_set_keygen(RSA_METHOD *rsa,
|
|
||||||
int (*keygen) (RSA *rsa, int bits, BIGNUM *e,
|
|
||||||
BN_GENCB *cb));
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int (*RSA_meth_get_multi_prime_keygen(const RSA_METHOD *meth)) (RSA *rsa,
|
|
||||||
int bits,
|
|
||||||
int primes,
|
|
||||||
BIGNUM *e,
|
|
||||||
BN_GENCB *cb);
|
|
||||||
OSSL_DEPRECATEDIN_3_0
|
|
||||||
int RSA_meth_set_multi_prime_keygen(RSA_METHOD *meth,
|
|
||||||
int (*keygen) (RSA *rsa, int bits,
|
|
||||||
int primes, BIGNUM *e,
|
|
||||||
BN_GENCB *cb));
|
|
||||||
#endif /* !OPENSSL_NO_DEPRECATED_3_0 */
|
|
||||||
|
|
||||||
# ifdef __cplusplus
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
@@ -1,225 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2022 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 <assert.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <openssl/core_dispatch.h>
|
|
||||||
#include <openssl/core_names.h>
|
|
||||||
/* For TLS1_VERSION etc */
|
|
||||||
#include <openssl/prov_ssl.h>
|
|
||||||
#include <openssl/params.h>
|
|
||||||
#include "internal/nelem.h"
|
|
||||||
#include "internal/tlsgroups.h"
|
|
||||||
#include "prov/providercommon.h"
|
|
||||||
#include "internal/e_os.h"
|
|
||||||
|
|
||||||
/* If neither ec or dh is available then we have no TLS-GROUP capabilities */
|
|
||||||
#if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH)
|
|
||||||
typedef struct tls_group_constants_st {
|
|
||||||
unsigned int group_id; /* Group ID */
|
|
||||||
unsigned int secbits; /* Bits of security */
|
|
||||||
int mintls; /* Minimum TLS version, -1 unsupported */
|
|
||||||
int maxtls; /* Maximum TLS version (or 0 for undefined) */
|
|
||||||
int mindtls; /* Minimum DTLS version, -1 unsupported */
|
|
||||||
int maxdtls; /* Maximum DTLS version (or 0 for undefined) */
|
|
||||||
} TLS_GROUP_CONSTANTS;
|
|
||||||
|
|
||||||
static const TLS_GROUP_CONSTANTS group_list[35] = {
|
|
||||||
{ OSSL_TLS_GROUP_ID_sect163k1, 80, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_sect163r1, 80, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_sect163r2, 80, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_sect193r1, 80, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_sect193r2, 80, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_sect233k1, 112, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_sect233r1, 112, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_sect239k1, 112, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_sect283k1, 128, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_sect283r1, 128, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_sect409k1, 192, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_sect409r1, 192, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_sect571k1, 256, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_sect571r1, 256, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_secp160k1, 80, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_secp160r1, 80, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_secp160r2, 80, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_secp192k1, 80, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_secp192r1, 80, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_secp224k1, 112, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_secp224r1, 112, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_secp256k1, 128, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_secp256r1, 128, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
|
|
||||||
{ OSSL_TLS_GROUP_ID_secp384r1, 192, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
|
|
||||||
{ OSSL_TLS_GROUP_ID_secp521r1, 256, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
|
|
||||||
{ OSSL_TLS_GROUP_ID_brainpoolP256r1, 128, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_brainpoolP384r1, 192, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_brainpoolP512r1, 256, TLS1_VERSION, TLS1_2_VERSION,
|
|
||||||
DTLS1_VERSION, DTLS1_2_VERSION },
|
|
||||||
{ OSSL_TLS_GROUP_ID_x25519, 128, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
|
|
||||||
{ OSSL_TLS_GROUP_ID_x448, 224, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
|
|
||||||
/* Security bit values as given by BN_security_bits() */
|
|
||||||
{ OSSL_TLS_GROUP_ID_ffdhe2048, 112, TLS1_3_VERSION, 0, -1, -1 },
|
|
||||||
{ OSSL_TLS_GROUP_ID_ffdhe3072, 128, TLS1_3_VERSION, 0, -1, -1 },
|
|
||||||
{ OSSL_TLS_GROUP_ID_ffdhe4096, 128, TLS1_3_VERSION, 0, -1, -1 },
|
|
||||||
{ OSSL_TLS_GROUP_ID_ffdhe6144, 128, TLS1_3_VERSION, 0, -1, -1 },
|
|
||||||
{ OSSL_TLS_GROUP_ID_ffdhe8192, 192, TLS1_3_VERSION, 0, -1, -1 },
|
|
||||||
};
|
|
||||||
|
|
||||||
#define TLS_GROUP_ENTRY(tlsname, realname, algorithm, idx) \
|
|
||||||
{ \
|
|
||||||
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_GROUP_NAME, \
|
|
||||||
tlsname, \
|
|
||||||
sizeof(tlsname)), \
|
|
||||||
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_GROUP_NAME_INTERNAL, \
|
|
||||||
realname, \
|
|
||||||
sizeof(realname)), \
|
|
||||||
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_GROUP_ALG, \
|
|
||||||
algorithm, \
|
|
||||||
sizeof(algorithm)), \
|
|
||||||
OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_GROUP_ID, \
|
|
||||||
(unsigned int *)&group_list[idx].group_id), \
|
|
||||||
OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_GROUP_SECURITY_BITS, \
|
|
||||||
(unsigned int *)&group_list[idx].secbits), \
|
|
||||||
OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MIN_TLS, \
|
|
||||||
(unsigned int *)&group_list[idx].mintls), \
|
|
||||||
OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MAX_TLS, \
|
|
||||||
(unsigned int *)&group_list[idx].maxtls), \
|
|
||||||
OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MIN_DTLS, \
|
|
||||||
(unsigned int *)&group_list[idx].mindtls), \
|
|
||||||
OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MAX_DTLS, \
|
|
||||||
(unsigned int *)&group_list[idx].maxdtls), \
|
|
||||||
OSSL_PARAM_END \
|
|
||||||
}
|
|
||||||
|
|
||||||
static const OSSL_PARAM param_group_list[][10] = {
|
|
||||||
# ifndef OPENSSL_NO_EC
|
|
||||||
# ifndef OPENSSL_NO_EC2M
|
|
||||||
TLS_GROUP_ENTRY("sect163k1", "sect163k1", "EC", 0),
|
|
||||||
TLS_GROUP_ENTRY("K-163", "sect163k1", "EC", 0), /* Alias of above */
|
|
||||||
# endif
|
|
||||||
# ifndef FIPS_MODULE
|
|
||||||
TLS_GROUP_ENTRY("sect163r1", "sect163r1", "EC", 1),
|
|
||||||
# endif
|
|
||||||
# ifndef OPENSSL_NO_EC2M
|
|
||||||
TLS_GROUP_ENTRY("sect163r2", "sect163r2", "EC", 2),
|
|
||||||
TLS_GROUP_ENTRY("B-163", "sect163r2", "EC", 2), /* Alias of above */
|
|
||||||
# endif
|
|
||||||
# ifndef FIPS_MODULE
|
|
||||||
TLS_GROUP_ENTRY("sect193r1", "sect193r1", "EC", 3),
|
|
||||||
TLS_GROUP_ENTRY("sect193r2", "sect193r2", "EC", 4),
|
|
||||||
# endif
|
|
||||||
# ifndef OPENSSL_NO_EC2M
|
|
||||||
TLS_GROUP_ENTRY("sect233k1", "sect233k1", "EC", 5),
|
|
||||||
TLS_GROUP_ENTRY("K-233", "sect233k1", "EC", 5), /* Alias of above */
|
|
||||||
TLS_GROUP_ENTRY("sect233r1", "sect233r1", "EC", 6),
|
|
||||||
TLS_GROUP_ENTRY("B-233", "sect233r1", "EC", 6), /* Alias of above */
|
|
||||||
# endif
|
|
||||||
# ifndef FIPS_MODULE
|
|
||||||
TLS_GROUP_ENTRY("sect239k1", "sect239k1", "EC", 7),
|
|
||||||
# endif
|
|
||||||
# ifndef OPENSSL_NO_EC2M
|
|
||||||
TLS_GROUP_ENTRY("sect283k1", "sect283k1", "EC", 8),
|
|
||||||
TLS_GROUP_ENTRY("K-283", "sect283k1", "EC", 8), /* Alias of above */
|
|
||||||
TLS_GROUP_ENTRY("sect283r1", "sect283r1", "EC", 9),
|
|
||||||
TLS_GROUP_ENTRY("B-283", "sect283r1", "EC", 9), /* Alias of above */
|
|
||||||
TLS_GROUP_ENTRY("sect409k1", "sect409k1", "EC", 10),
|
|
||||||
TLS_GROUP_ENTRY("K-409", "sect409k1", "EC", 10), /* Alias of above */
|
|
||||||
TLS_GROUP_ENTRY("sect409r1", "sect409r1", "EC", 11),
|
|
||||||
TLS_GROUP_ENTRY("B-409", "sect409r1", "EC", 11), /* Alias of above */
|
|
||||||
TLS_GROUP_ENTRY("sect571k1", "sect571k1", "EC", 12),
|
|
||||||
TLS_GROUP_ENTRY("K-571", "sect571k1", "EC", 12), /* Alias of above */
|
|
||||||
TLS_GROUP_ENTRY("sect571r1", "sect571r1", "EC", 13),
|
|
||||||
TLS_GROUP_ENTRY("B-571", "sect571r1", "EC", 13), /* Alias of above */
|
|
||||||
# endif
|
|
||||||
# ifndef FIPS_MODULE
|
|
||||||
TLS_GROUP_ENTRY("secp160k1", "secp160k1", "EC", 14),
|
|
||||||
TLS_GROUP_ENTRY("secp160r1", "secp160r1", "EC", 15),
|
|
||||||
TLS_GROUP_ENTRY("secp160r2", "secp160r2", "EC", 16),
|
|
||||||
TLS_GROUP_ENTRY("secp192k1", "secp192k1", "EC", 17),
|
|
||||||
# endif
|
|
||||||
TLS_GROUP_ENTRY("secp192r1", "prime192v1", "EC", 18),
|
|
||||||
TLS_GROUP_ENTRY("P-192", "prime192v1", "EC", 18), /* Alias of above */
|
|
||||||
# ifndef FIPS_MODULE
|
|
||||||
TLS_GROUP_ENTRY("secp224k1", "secp224k1", "EC", 19),
|
|
||||||
# endif
|
|
||||||
TLS_GROUP_ENTRY("secp224r1", "secp224r1", "EC", 20),
|
|
||||||
TLS_GROUP_ENTRY("P-224", "secp224r1", "EC", 20), /* Alias of above */
|
|
||||||
# ifndef FIPS_MODULE
|
|
||||||
TLS_GROUP_ENTRY("secp256k1", "secp256k1", "EC", 21),
|
|
||||||
# endif
|
|
||||||
TLS_GROUP_ENTRY("secp256r1", "prime256v1", "EC", 22),
|
|
||||||
TLS_GROUP_ENTRY("P-256", "prime256v1", "EC", 22), /* Alias of above */
|
|
||||||
TLS_GROUP_ENTRY("secp384r1", "secp384r1", "EC", 23),
|
|
||||||
TLS_GROUP_ENTRY("P-384", "secp384r1", "EC", 23), /* Alias of above */
|
|
||||||
TLS_GROUP_ENTRY("secp521r1", "secp521r1", "EC", 24),
|
|
||||||
TLS_GROUP_ENTRY("P-521", "secp521r1", "EC", 24), /* Alias of above */
|
|
||||||
# ifndef FIPS_MODULE
|
|
||||||
TLS_GROUP_ENTRY("brainpoolP256r1", "brainpoolP256r1", "EC", 25),
|
|
||||||
TLS_GROUP_ENTRY("brainpoolP384r1", "brainpoolP384r1", "EC", 26),
|
|
||||||
TLS_GROUP_ENTRY("brainpoolP512r1", "brainpoolP512r1", "EC", 27),
|
|
||||||
# endif
|
|
||||||
TLS_GROUP_ENTRY("x25519", "X25519", "X25519", 28),
|
|
||||||
TLS_GROUP_ENTRY("x448", "X448", "X448", 29),
|
|
||||||
# endif /* OPENSSL_NO_EC */
|
|
||||||
# ifndef OPENSSL_NO_DH
|
|
||||||
/* Security bit values for FFDHE groups are as per RFC 7919 */
|
|
||||||
TLS_GROUP_ENTRY("ffdhe2048", "ffdhe2048", "DH", 30),
|
|
||||||
TLS_GROUP_ENTRY("ffdhe3072", "ffdhe3072", "DH", 31),
|
|
||||||
TLS_GROUP_ENTRY("ffdhe4096", "ffdhe4096", "DH", 32),
|
|
||||||
TLS_GROUP_ENTRY("ffdhe6144", "ffdhe6144", "DH", 33),
|
|
||||||
TLS_GROUP_ENTRY("ffdhe8192", "ffdhe8192", "DH", 34),
|
|
||||||
# endif
|
|
||||||
};
|
|
||||||
#endif /* !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) */
|
|
||||||
|
|
||||||
static int tls_group_capability(OSSL_CALLBACK *cb, void *arg)
|
|
||||||
{
|
|
||||||
#if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH)
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
for (i = 0; i < OSSL_NELEM(param_group_list); i++)
|
|
||||||
if (!cb(param_group_list[i], arg))
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_prov_get_capabilities(void *provctx, const char *capability,
|
|
||||||
OSSL_CALLBACK *cb, void *arg)
|
|
||||||
{
|
|
||||||
if (OPENSSL_strcasecmp(capability, "TLS-GROUP") == 0)
|
|
||||||
return tls_group_capability(cb, arg);
|
|
||||||
|
|
||||||
/* We don't support this capability */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
-31
@@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2023 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 "crypto/types.h"
|
|
||||||
|
|
||||||
/* Functions that are common */
|
|
||||||
int ossl_rsa_check_key(OSSL_LIB_CTX *ctx, const RSA *rsa, int operation);
|
|
||||||
int ossl_ec_check_key(OSSL_LIB_CTX *ctx, const EC_KEY *ec, int protect);
|
|
||||||
int ossl_dsa_check_key(OSSL_LIB_CTX *ctx, const DSA *dsa, int sign);
|
|
||||||
int ossl_dh_check_key(OSSL_LIB_CTX *ctx, const DH *dh);
|
|
||||||
|
|
||||||
int ossl_digest_is_allowed(OSSL_LIB_CTX *ctx, const EVP_MD *md);
|
|
||||||
/* With security check enabled it can return -1 to indicate disallowed md */
|
|
||||||
int ossl_digest_get_approved_nid_with_sha1(OSSL_LIB_CTX *ctx, const EVP_MD *md,
|
|
||||||
int sha1_allowed);
|
|
||||||
|
|
||||||
/* Functions that are common */
|
|
||||||
int ossl_digest_md_to_nid(const EVP_MD *md, const OSSL_ITEM *it, size_t it_len);
|
|
||||||
int ossl_digest_get_approved_nid(const EVP_MD *md);
|
|
||||||
|
|
||||||
/* Functions that have different implementations for the FIPS_MODULE */
|
|
||||||
int ossl_digest_rsa_sign_get_md_nid(OSSL_LIB_CTX *ctx, const EVP_MD *md,
|
|
||||||
int sha1_allowed);
|
|
||||||
int ossl_securitycheck_enabled(OSSL_LIB_CTX *libctx);
|
|
||||||
int ossl_tls1_prf_ems_check_enabled(OSSL_LIB_CTX *libctx);
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 <stdlib.h>
|
|
||||||
#include "prov/provider_ctx.h"
|
|
||||||
#include "prov/bio.h"
|
|
||||||
|
|
||||||
PROV_CTX *ossl_prov_ctx_new(void)
|
|
||||||
{
|
|
||||||
return OPENSSL_zalloc(sizeof(PROV_CTX));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ossl_prov_ctx_free(PROV_CTX *ctx)
|
|
||||||
{
|
|
||||||
OPENSSL_free(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ossl_prov_ctx_set0_libctx(PROV_CTX *ctx, OSSL_LIB_CTX *libctx)
|
|
||||||
{
|
|
||||||
if (ctx != NULL)
|
|
||||||
ctx->libctx = libctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ossl_prov_ctx_set0_handle(PROV_CTX *ctx, const OSSL_CORE_HANDLE *handle)
|
|
||||||
{
|
|
||||||
if (ctx != NULL)
|
|
||||||
ctx->handle = handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ossl_prov_ctx_set0_core_bio_method(PROV_CTX *ctx, BIO_METHOD *corebiometh)
|
|
||||||
{
|
|
||||||
if (ctx != NULL)
|
|
||||||
ctx->corebiometh = corebiometh;
|
|
||||||
}
|
|
||||||
|
|
||||||
OSSL_LIB_CTX *ossl_prov_ctx_get0_libctx(PROV_CTX *ctx)
|
|
||||||
{
|
|
||||||
if (ctx == NULL)
|
|
||||||
return NULL;
|
|
||||||
return ctx->libctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
const OSSL_CORE_HANDLE *ossl_prov_ctx_get0_handle(PROV_CTX *ctx)
|
|
||||||
{
|
|
||||||
if (ctx == NULL)
|
|
||||||
return NULL;
|
|
||||||
return ctx->handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
BIO_METHOD *ossl_prov_ctx_get0_core_bio_method(PROV_CTX *ctx)
|
|
||||||
{
|
|
||||||
if (ctx == NULL)
|
|
||||||
return NULL;
|
|
||||||
return ctx->corebiometh;
|
|
||||||
}
|
|
||||||
-256
@@ -1,256 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020-2023 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 "internal/deprecated.h"
|
|
||||||
|
|
||||||
#include <openssl/rsa.h>
|
|
||||||
#include <openssl/dsa.h>
|
|
||||||
#include <openssl/dh.h>
|
|
||||||
#include <openssl/ec.h>
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
#include <openssl/err.h>
|
|
||||||
#include <openssl/proverr.h>
|
|
||||||
#include <openssl/core_names.h>
|
|
||||||
#include <openssl/obj_mac.h>
|
|
||||||
#include "prov/securitycheck.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* FIPS requires a minimum security strength of 112 bits (for encryption or
|
|
||||||
* signing), and for legacy purposes 80 bits (for decryption or verifying).
|
|
||||||
* Set protect = 1 for encryption or signing operations, or 0 otherwise. See
|
|
||||||
* https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf.
|
|
||||||
*/
|
|
||||||
int ossl_rsa_check_key(OSSL_LIB_CTX *ctx, const RSA *rsa, int operation)
|
|
||||||
{
|
|
||||||
int protect = 0;
|
|
||||||
|
|
||||||
switch (operation) {
|
|
||||||
case EVP_PKEY_OP_SIGN:
|
|
||||||
protect = 1;
|
|
||||||
/* fallthrough */
|
|
||||||
case EVP_PKEY_OP_VERIFY:
|
|
||||||
break;
|
|
||||||
case EVP_PKEY_OP_ENCAPSULATE:
|
|
||||||
case EVP_PKEY_OP_ENCRYPT:
|
|
||||||
protect = 1;
|
|
||||||
/* fallthrough */
|
|
||||||
case EVP_PKEY_OP_VERIFYRECOVER:
|
|
||||||
case EVP_PKEY_OP_DECAPSULATE:
|
|
||||||
case EVP_PKEY_OP_DECRYPT:
|
|
||||||
if (RSA_test_flags(rsa,
|
|
||||||
RSA_FLAG_TYPE_MASK) == RSA_FLAG_TYPE_RSASSAPSS) {
|
|
||||||
ERR_raise_data(ERR_LIB_PROV,
|
|
||||||
PROV_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE,
|
|
||||||
"operation: %d", operation);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ERR_raise_data(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR,
|
|
||||||
"invalid operation: %d", operation);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(OPENSSL_NO_FIPS_SECURITYCHECKS)
|
|
||||||
if (ossl_securitycheck_enabled(ctx)) {
|
|
||||||
int sz = RSA_bits(rsa);
|
|
||||||
|
|
||||||
if (protect ? (sz < 2048) : (sz < 1024)) {
|
|
||||||
ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH,
|
|
||||||
"operation: %d", operation);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
/* make protect used */
|
|
||||||
(void)protect;
|
|
||||||
#endif /* OPENSSL_NO_FIPS_SECURITYCHECKS */
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_EC
|
|
||||||
/*
|
|
||||||
* In FIPS mode:
|
|
||||||
* protect should be 1 for any operations that need 112 bits of security
|
|
||||||
* strength (such as signing, and key exchange), or 0 for operations that allow
|
|
||||||
* a lower security strength (such as verify).
|
|
||||||
*
|
|
||||||
* For ECDH key agreement refer to SP800-56A
|
|
||||||
* https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-56Ar3.pdf
|
|
||||||
* "Appendix D"
|
|
||||||
*
|
|
||||||
* For ECDSA signatures refer to
|
|
||||||
* https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf
|
|
||||||
* "Table 2"
|
|
||||||
*/
|
|
||||||
int ossl_ec_check_key(OSSL_LIB_CTX *ctx, const EC_KEY *ec, int protect)
|
|
||||||
{
|
|
||||||
# if !defined(OPENSSL_NO_FIPS_SECURITYCHECKS)
|
|
||||||
if (ossl_securitycheck_enabled(ctx)) {
|
|
||||||
int nid, strength;
|
|
||||||
const char *curve_name;
|
|
||||||
const EC_GROUP *group = EC_KEY_get0_group(ec);
|
|
||||||
|
|
||||||
if (group == NULL) {
|
|
||||||
ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_CURVE, "No group");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
nid = EC_GROUP_get_curve_name(group);
|
|
||||||
if (nid == NID_undef) {
|
|
||||||
ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_CURVE,
|
|
||||||
"Explicit curves are not allowed in fips mode");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
curve_name = EC_curve_nid2nist(nid);
|
|
||||||
if (curve_name == NULL) {
|
|
||||||
ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_CURVE,
|
|
||||||
"Curve %s is not approved in FIPS mode", curve_name);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For EC the security strength is the (order_bits / 2)
|
|
||||||
* e.g. P-224 is 112 bits.
|
|
||||||
*/
|
|
||||||
strength = EC_GROUP_order_bits(group) / 2;
|
|
||||||
/* The min security strength allowed for legacy verification is 80 bits */
|
|
||||||
if (strength < 80) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_CURVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For signing or key agreement only allow curves with at least 112 bits of
|
|
||||||
* security strength
|
|
||||||
*/
|
|
||||||
if (protect && strength < 112) {
|
|
||||||
ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_CURVE,
|
|
||||||
"Curve %s cannot be used for signing", curve_name);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# endif /* OPENSSL_NO_FIPS_SECURITYCHECKS */
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif /* OPENSSL_NO_EC */
|
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_DSA
|
|
||||||
/*
|
|
||||||
* Check for valid key sizes if fips mode. Refer to
|
|
||||||
* https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf
|
|
||||||
* "Table 2"
|
|
||||||
*/
|
|
||||||
int ossl_dsa_check_key(OSSL_LIB_CTX *ctx, const DSA *dsa, int sign)
|
|
||||||
{
|
|
||||||
# if !defined(OPENSSL_NO_FIPS_SECURITYCHECKS)
|
|
||||||
if (ossl_securitycheck_enabled(ctx)) {
|
|
||||||
size_t L, N;
|
|
||||||
const BIGNUM *p, *q;
|
|
||||||
|
|
||||||
if (dsa == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
p = DSA_get0_p(dsa);
|
|
||||||
q = DSA_get0_q(dsa);
|
|
||||||
if (p == NULL || q == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
L = BN_num_bits(p);
|
|
||||||
N = BN_num_bits(q);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For Digital signature verification DSA keys with < 112 bits of
|
|
||||||
* security strength, are still allowed for legacy
|
|
||||||
* use. The bounds given in SP 800-131Ar2 - Table 2 are
|
|
||||||
* (512 <= L < 2048 or 160 <= N < 224).
|
|
||||||
*
|
|
||||||
* We are a little stricter and insist that both minimums are met.
|
|
||||||
* For example a L = 256, N = 160 key *would* be allowed by SP 800-131Ar2
|
|
||||||
* but we don't.
|
|
||||||
*/
|
|
||||||
if (!sign) {
|
|
||||||
if (L < 512 || N < 160)
|
|
||||||
return 0;
|
|
||||||
if (L < 2048 || N < 224)
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Valid sizes for both sign and verify */
|
|
||||||
if (L == 2048 && (N == 224 || N == 256)) /* 112 bits */
|
|
||||||
return 1;
|
|
||||||
return (L == 3072 && N == 256); /* 128 bits */
|
|
||||||
}
|
|
||||||
# endif /* OPENSSL_NO_FIPS_SECURITYCHECKS */
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif /* OPENSSL_NO_DSA */
|
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_DH
|
|
||||||
/*
|
|
||||||
* For DH key agreement refer to SP800-56A
|
|
||||||
* https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-56Ar3.pdf
|
|
||||||
* "Section 5.5.1.1FFC Domain Parameter Selection/Generation" and
|
|
||||||
* "Appendix D" FFC Safe-prime Groups
|
|
||||||
*/
|
|
||||||
int ossl_dh_check_key(OSSL_LIB_CTX *ctx, const DH *dh)
|
|
||||||
{
|
|
||||||
# if !defined(OPENSSL_NO_FIPS_SECURITYCHECKS)
|
|
||||||
if (ossl_securitycheck_enabled(ctx)) {
|
|
||||||
size_t L, N;
|
|
||||||
const BIGNUM *p, *q;
|
|
||||||
|
|
||||||
if (dh == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
p = DH_get0_p(dh);
|
|
||||||
q = DH_get0_q(dh);
|
|
||||||
if (p == NULL || q == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
L = BN_num_bits(p);
|
|
||||||
if (L < 2048)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* If it is a safe prime group then it is ok */
|
|
||||||
if (DH_get_nid(dh))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
/* If not then it must be FFC, which only allows certain sizes. */
|
|
||||||
N = BN_num_bits(q);
|
|
||||||
|
|
||||||
return (L == 2048 && (N == 224 || N == 256));
|
|
||||||
}
|
|
||||||
# endif /* OPENSSL_NO_FIPS_SECURITYCHECKS */
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif /* OPENSSL_NO_DH */
|
|
||||||
|
|
||||||
int ossl_digest_get_approved_nid_with_sha1(OSSL_LIB_CTX *ctx, const EVP_MD *md,
|
|
||||||
int sha1_allowed)
|
|
||||||
{
|
|
||||||
int mdnid = ossl_digest_get_approved_nid(md);
|
|
||||||
|
|
||||||
# if !defined(OPENSSL_NO_FIPS_SECURITYCHECKS)
|
|
||||||
if (ossl_securitycheck_enabled(ctx)) {
|
|
||||||
if (mdnid == NID_undef || (mdnid == NID_sha1 && !sha1_allowed))
|
|
||||||
mdnid = -1; /* disallowed by security checks */
|
|
||||||
}
|
|
||||||
# endif /* OPENSSL_NO_FIPS_SECURITYCHECKS */
|
|
||||||
return mdnid;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_digest_is_allowed(OSSL_LIB_CTX *ctx, const EVP_MD *md)
|
|
||||||
{
|
|
||||||
# if !defined(OPENSSL_NO_FIPS_SECURITYCHECKS)
|
|
||||||
if (ossl_securitycheck_enabled(ctx))
|
|
||||||
return ossl_digest_get_approved_nid(md) != NID_undef;
|
|
||||||
# endif /* OPENSSL_NO_FIPS_SECURITYCHECKS */
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
-45
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020-2023 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 "internal/deprecated.h"
|
|
||||||
|
|
||||||
#include <openssl/rsa.h>
|
|
||||||
#include <openssl/dsa.h>
|
|
||||||
#include <openssl/dh.h>
|
|
||||||
#include <openssl/ec.h>
|
|
||||||
#include <openssl/err.h>
|
|
||||||
#include <openssl/proverr.h>
|
|
||||||
#include <openssl/core_names.h>
|
|
||||||
#include <openssl/obj_mac.h>
|
|
||||||
#include "prov/securitycheck.h"
|
|
||||||
#include "prov/fipscommon.h"
|
|
||||||
|
|
||||||
int ossl_securitycheck_enabled(OSSL_LIB_CTX *libctx)
|
|
||||||
{
|
|
||||||
#if !defined(OPENSSL_NO_FIPS_SECURITYCHECKS)
|
|
||||||
return FIPS_security_check_enabled(libctx);
|
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif /* OPENSSL_NO_FIPS_SECURITYCHECKS */
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_tls1_prf_ems_check_enabled(OSSL_LIB_CTX *libctx)
|
|
||||||
{
|
|
||||||
return FIPS_tls_prf_ems_check(libctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_digest_rsa_sign_get_md_nid(OSSL_LIB_CTX *ctx, const EVP_MD *md,
|
|
||||||
int sha1_allowed)
|
|
||||||
{
|
|
||||||
#if !defined(OPENSSL_NO_FIPS_SECURITYCHECKS)
|
|
||||||
if (ossl_securitycheck_enabled(ctx))
|
|
||||||
return ossl_digest_get_approved_nid_with_sha1(ctx, md, sha1_allowed);
|
|
||||||
#endif /* OPENSSL_NO_FIPS_SECURITYCHECKS */
|
|
||||||
return ossl_digest_get_approved_nid(md);
|
|
||||||
}
|
|
||||||
-614
@@ -1,614 +0,0 @@
|
|||||||
0e22ea0cf34ef3871e30df0bc302dc29352d38001d1622ddb78a27a374b6aee8 crypto/aes/aes_cbc.c
|
|
||||||
c049a936d74100fcced225f575d46662792a6a0039777d2d4df0cf61eff90a68 crypto/aes/aes_core.c
|
|
||||||
3fac41ce96acb9189eac2d5571425c3ff33a34c884ae7e275e1fd3068b5fc662 crypto/aes/aes_ecb.c
|
|
||||||
c1e674d08683a25bc053f6233f73a0d0b3a90aafe591ff57b702c7da1582e4a5 crypto/aes/aes_local.h
|
|
||||||
a2466f18da5847c7d9fbced17524633c10ce024671a72f53f9c9c55b9b9923dd crypto/aes/aes_misc.c
|
|
||||||
6979c133f76f4623e62e6e970deae70fa025e713a72b71aead5a048d49e47f6f crypto/aes/asm/aes-586.pl
|
|
||||||
2eef5f20f1410b48bdaaafa24ded24f56f34c4ca79db1d38fa6bf1b3b19535bf crypto/aes/asm/aes-armv4.pl
|
|
||||||
38c2cf8ed3910efd89d8721e1b0763a8fde073b91f6529d251165a0496ef9555 crypto/aes/asm/aes-c64xplus.pl
|
|
||||||
00196f01f5218ad731e6a058d406078f7228a9756d9d73f51c0d0c2a68f885af crypto/aes/asm/aes-ia64.S
|
|
||||||
b4ef595194fe1692e1ab2b561f385da01b277cf004902e8fc99e8ac5389bbd35 crypto/aes/asm/aes-mips.pl
|
|
||||||
123c4498c94040b70708fdd911cb08c6411b020b4cf3eb761d6fa22c583c3e6f crypto/aes/asm/aes-parisc.pl
|
|
||||||
7a7f2f90791415ef4ffc1ba2a6f6b6fe994bfe0e03d3bf9dab6e428e6874695c crypto/aes/asm/aes-ppc.pl
|
|
||||||
a2e05801f00e5ac8e91127b86f55e9f348731019e5e0d918dd0df1a04be1cc34 crypto/aes/asm/aes-riscv32-zkn.pl
|
|
||||||
e22c00b84c59746f74a6fcd4f18b72628b3799d71ac3311ad917bdf779f2a7d7 crypto/aes/asm/aes-riscv64-zkn.pl
|
|
||||||
18283dea4477ab722ec7e4bff000a4a2df89b2a430c42c6fa8ee8099b13c86ee crypto/aes/asm/aes-riscv64.pl
|
|
||||||
d139e5ad69560fd0ffd8aa2e72304e463650cea4c657be7a90e0d1eb782d580a crypto/aes/asm/aes-s390x.pl
|
|
||||||
133ba35d77002abcd430414749c4e98c4a319630da898e45ff8dbc5800176df1 crypto/aes/asm/aes-sparcv9.pl
|
|
||||||
c98690249d490d23e6fee84f672f1463ffc029427110a4329244a59e4e4aaed8 crypto/aes/asm/aes-x86_64.pl
|
|
||||||
7ec99947b47e56595f0b085b8bda0b3113112f694e78b1f71b63ecd1f0fa2c67 crypto/aes/asm/aesfx-sparcv9.pl
|
|
||||||
ab94a27e533e164bcf09898a6f6019f43609d51a3b374cf75482dcf2914d464e crypto/aes/asm/aesni-mb-x86_64.pl
|
|
||||||
74939261340a0056eb9333fff1c843c8758b9f93de3d94650cd6d2899c6790d8 crypto/aes/asm/aesni-sha1-x86_64.pl
|
|
||||||
ce91f0893a2a35fdf4c024ccb0fd8329b30fdbd955f0ae011ab948101ee14951 crypto/aes/asm/aesni-sha256-x86_64.pl
|
|
||||||
4ff74d4e629a88ef5a9e3d3f5b340fc0a4793d16d7cc7f1b70da62512a856248 crypto/aes/asm/aesni-x86.pl
|
|
||||||
30103cfe3b29d06b34feff48a927e0fa649e9109d35a3db64b09cfeb15426fa2 crypto/aes/asm/aesni-x86_64.pl
|
|
||||||
f3490c936a80e012c49e577ec6e1d4d36df324dfef6264e788e6225e20b5fd52 crypto/aes/asm/aesp8-ppc.pl
|
|
||||||
a5807ed92ec8a16d123061487c385bf1f65e50878cee95c8e8096844454129f8 crypto/aes/asm/aest4-sparcv9.pl
|
|
||||||
43d53858459de47a43f00f4b49465b8a5b8ec09ec33ddb3a205b52ab6c4cfe6c crypto/aes/asm/aesv8-armx.pl
|
|
||||||
a0b578b7d2787c91013547df07dfa73d8d7a420446dd624c66f7c55159817eb2 crypto/aes/asm/bsaes-armv7.pl
|
|
||||||
6e0a4f8f137c01be2bd3203a60c5b16c83d50d8cabd18cdbd5f94efc55459cb2 crypto/aes/asm/bsaes-armv8.pl
|
|
||||||
34accd08242a6bf4a751105f89b0c4de2cd7e54320753587815647abff7124de crypto/aes/asm/bsaes-x86_64.pl
|
|
||||||
068cb6cdf4c737b7f7f9ebf27284599d17f6f5c4a01f0c61c7777323b2f203f5 crypto/aes/asm/vpaes-armv8.pl
|
|
||||||
b4656c09bec06eea0b3fe504d47af847ceb0c90f1fb1cc76f43c1caa0dc17613 crypto/aes/asm/vpaes-loongarch64.pl
|
|
||||||
516421b1a321b842f879ad69e7b82ae3e1f3efc8288c83bb34d6577996e85787 crypto/aes/asm/vpaes-ppc.pl
|
|
||||||
3ec24185750a995377516bc2fb2eae8b1c52094c6fff093bff591837fc12d6c3 crypto/aes/asm/vpaes-x86.pl
|
|
||||||
47bedbe6a04254eede121e71f11a657b1f1940aee1916bbfc04fa9fb8454f9b8 crypto/aes/asm/vpaes-x86_64.pl
|
|
||||||
1c9a2a0e8cee4a1283c74b2e306f46f79890f6d236394de2a80d1994fd411d1d crypto/alphacpuid.pl
|
|
||||||
f2e5fee49c133a63fda341580a898f3266743b4ef15d539ba6abf90a5d660628 crypto/arm64cpuid.pl
|
|
||||||
7144d95f74d8f84b5c32fe5b343c1d6d958a96ffcf9d0374a343cd82e599d753 crypto/armcap.c
|
|
||||||
ff7aa344dbcd04767837e1319de718ce85c4b55c065c52435bf5a2a60e65d304 crypto/armv4cpuid.pl
|
|
||||||
16739d54200fb81ca7835b5814f965022a2ab41589c7787e2697e3ea72d4fafa crypto/asn1_dsa.c
|
|
||||||
155eff9d747eed808398cfa2af4b276dfc1f9aac8a0f9d801b314ab3f2bf5b56 crypto/bn/asm/alpha-mont.pl
|
|
||||||
9831ce3e8a057bc7c7b2cd3d5a25397b259bfbf33ca2f81424ec1203cfa5be51 crypto/bn/asm/armv4-gf2m.pl
|
|
||||||
77ba642efd4608f9d6e60b796ba0f876c13f9d78a8302234756ad5dae35f3316 crypto/bn/asm/armv4-mont.pl
|
|
||||||
3465446d414c2be999d4f103f027658644802d9a31e4afa31b365aea3290c8a0 crypto/bn/asm/armv8-mont.pl
|
|
||||||
cb4ad7b7461fcb8e2a0d52881158d0211b79544842d4eae36fc566869a2d62c8 crypto/bn/asm/bn-586.pl
|
|
||||||
10fb73a6cc1bc064ebdcf6d7fe3c7407ea1c28b0d65ad0123046f8b1518fa75a crypto/bn/asm/c64xplus-gf2m.pl
|
|
||||||
c86664fb974362ee52a454c83c2c4b23fd5b7d64b3c9e23ef1e0dfd130a46ee5 crypto/bn/asm/co-586.pl
|
|
||||||
b88190d748056e6a64988bf1a3d19efc4c292e3d338a65f4505cf769a2041077 crypto/bn/asm/ia64-mont.pl
|
|
||||||
a511aafbf76647a0c83705d4491c898a5584d300aa449fa6166c8803372946eb crypto/bn/asm/ia64.S
|
|
||||||
fee42cabeeb87cdf0fa0a6ff3698b2fe98a8a47d10a756052df572097161a8b9 crypto/bn/asm/mips-mont.pl
|
|
||||||
b197a8e1be79b8c21f8d26b34b9a282ca42ec4bcd1f3212fde3889747082a1f7 crypto/bn/asm/mips.pl
|
|
||||||
13df09cee06a21669137294f92e5c31b4bf05a8035be6800c1cb4403d7cd8290 crypto/bn/asm/parisc-mont.pl
|
|
||||||
25c96e545b4981d45557eb14ea5c83aa2d6375ae0df806cb6e6ded2f59ddfed3 crypto/bn/asm/ppc-mont.pl
|
|
||||||
1c057083546fa1a3bb1b9819dc5110f5a3b11b7bf5a2fb275012323bd7412403 crypto/bn/asm/ppc.pl
|
|
||||||
04c9b5d2494c06e6f8a47c35274ddf53ae46b65e6abc297bd41e5beb735a3e8e crypto/bn/asm/ppc64-mont-fixed.pl
|
|
||||||
fe9278a2504fb40257637a4718081775c29c4eb81f87a8528e5c85f8d0c6281a crypto/bn/asm/ppc64-mont.pl
|
|
||||||
6600c0303306f286679f6f50d4f642599f380a57875c09382a4608f51b31a04d crypto/bn/asm/rsaz-2k-avx512.pl
|
|
||||||
fbbb79bbde7db1294d55f41919a29dca46ce44f5105a98abfd107f2ab07caa0a crypto/bn/asm/rsaz-3k-avx512.pl
|
|
||||||
8db2e45c5bbc01313f31f57d068a54bc6889da8e8e73250a79bf1cb65a468d46 crypto/bn/asm/rsaz-4k-avx512.pl
|
|
||||||
94b2d5cf0faf2efddeb5fb7c575dabc35c1791715cc9299d59a01d9f96cb2d6f crypto/bn/asm/rsaz-avx2.pl
|
|
||||||
c19c717d87dd1ba74f138af05c044c05f5d025e26323637f46ba54a8c871a378 crypto/bn/asm/rsaz-x86_64.pl
|
|
||||||
ae26becda9f6d30e9edde8bb89c251a0c40a9a6c879c4cdaec273d8c09af9cd6 crypto/bn/asm/s390x-gf2m.pl
|
|
||||||
2700337ef133d6688047a1a8e1c671db06016aae777679923ce2b301896762cf crypto/bn/asm/s390x-mont.pl
|
|
||||||
aa02597f3dc09cfbc190aedb75711859ba0f3efff87067ebfba1ec78ebee40d7 crypto/bn/asm/s390x.S
|
|
||||||
87d49e83a7df467097fdfc577aa206be9ee622c40fcbbbe5133b35d9783b7816 crypto/bn/asm/sparct4-mont.pl
|
|
||||||
ca21a9ccbc54e19fb7c2e6cdf286ce7cb08b0fba960c777c6edce5c57ccc2101 crypto/bn/asm/sparcv8.S
|
|
||||||
fbc93c8dbbecefe66086f58fe9719ed87b13b2cdc61454a10e841228296fecef crypto/bn/asm/sparcv8plus.S
|
|
||||||
2ec1497fa06826f7bc574239e425dd8dda0d4a2743e1fe87669ede900291fcb6 crypto/bn/asm/sparcv9-gf2m.pl
|
|
||||||
1f490fe184c7a51b2d0646a59e69aa659bfe51270ad21594951b8d7b785bac38 crypto/bn/asm/sparcv9-mont.pl
|
|
||||||
277dcb7faa1913b25fd43946c50039bcdd45cb643fd9ddeedd6c207cefa4dd50 crypto/bn/asm/sparcv9a-mont.pl
|
|
||||||
d404375a21d33396824a3da212d6646d4f3150dd141ee4b4a250aefae3482efb crypto/bn/asm/via-mont.pl
|
|
||||||
d632edf9b9bab7d2cd2d616512a98d15cf4b3ebba7a8e7b83650d654ceb52ecb crypto/bn/asm/vis3-mont.pl
|
|
||||||
89278854f44d95be916516609ce6f79dcd346bab52574b9b6336a9952aa94bee crypto/bn/asm/x86-gf2m.pl
|
|
||||||
90d4ae234c08267adce9ed38d56e0edc223f7480cb9605f5d7399d0b3914c6be crypto/bn/asm/x86-mont.pl
|
|
||||||
d444ca73875e97e0ea88b20e4c02f2fcf3850e8b9311e3b67a2d04fe2796d543 crypto/bn/asm/x86_64-gcc.c
|
|
||||||
a5481ca55d94dc7ebdc93173610d38ae2569cea1fe9b5180debe0ab94e455ce1 crypto/bn/asm/x86_64-gf2m.pl
|
|
||||||
d8cc080824a72774cb3343a3d50ddf8f41a5b8321203d4c9a764762b62498b96 crypto/bn/asm/x86_64-mont.pl
|
|
||||||
03788cb685268e6a50ddfa742ea1fe937570c9b86f2ebc88ee35f3304f67c045 crypto/bn/asm/x86_64-mont5.pl
|
|
||||||
0ea8185a037a2951bb3d1e590bbbdeac305176d5e618f3e43a04c09733a9de34 crypto/bn/bn_add.c
|
|
||||||
964c7eecef99ef56997cbb90b6560d41e0e90bb1f87dcc5e2a1bf177851c005f crypto/bn/bn_asm.c
|
|
||||||
14bd5a35c05fcf454854b92fb30b356d7ac618c1eb699dd798f6ad2936d1f5ee crypto/bn/bn_blind.c
|
|
||||||
7b761d541e3b7f6a3f2b14a09b2b3836a079a845cf67a54db4853e3fd38277c6 crypto/bn/bn_const.c
|
|
||||||
58b587e20404efa408b31a88ba9c357059ced709bea78c07deb91df7b687db81 crypto/bn/bn_conv.c
|
|
||||||
2893b6d03d4850d09c15959941b0759bbb50d8c20e873bed088e7cde4e15a65a crypto/bn/bn_ctx.c
|
|
||||||
d94295953ab91469fe2b9da2a542b8ea11ac38551ecde8f8202b7f645c2dea16 crypto/bn/bn_dh.c
|
|
||||||
74b63a4515894592b7241fb30b91b21510beaa3d397809e3d74bc9a73e879d18 crypto/bn/bn_div.c
|
|
||||||
99b26dc23253a5c3853847810a21829a35713f8cccf32c6312df5f554470e0d1 crypto/bn/bn_exp.c
|
|
||||||
ec2b6e3af6df473a23e7f1a8522f2554cb0eb5d34e3282458c4a66d242278434 crypto/bn/bn_exp2.c
|
|
||||||
5d7ece58f63fbf2f3e685b815e6c71c380ec3b09a78d97863b0687bec5010433 crypto/bn/bn_gcd.c
|
|
||||||
5fbb1ab8463cd5544a1d95cf7996b6387ae634984a42256b7a21482ce3ac30a2 crypto/bn/bn_gf2m.c
|
|
||||||
081e8a6abc23599307dab3b1a92113a65e0bf8717cbc40c970c7469350bc4581 crypto/bn/bn_intern.c
|
|
||||||
602ed46fbfe12c899dfb7d9d99ff0dbfff96b454fce3cd02817f3e2488dd9192 crypto/bn/bn_kron.c
|
|
||||||
9efc90237e1f5f468d62a5cd56b0d664fe1b7d6b421dad8da19e9978d48bcd81 crypto/bn/bn_lib.c
|
|
||||||
d5beb9fbac2ff5dc3ccbdfa4d1aabca7225c778cff4e3b05b6d6c63e182637f5 crypto/bn/bn_local.h
|
|
||||||
96f98cdf50087c5b567c31bf2581728623206d79b3f97f5a0c5fdaa0009e6e3c crypto/bn/bn_mod.c
|
|
||||||
f60f3d49b183b04bcdf9b82f7c961b8c1bcb00e68a2c1166fe9edd95a783356e crypto/bn/bn_mont.c
|
|
||||||
2da73a76b746a47d8cf8ec8b3e0708c2a34e810abde4b4f1241a49e7f5bb2b60 crypto/bn/bn_mpi.c
|
|
||||||
76982b18b0803d59b33168b260677e7412970757d3b9513de5c80025290f211d crypto/bn/bn_mul.c
|
|
||||||
b3677b73ac29aab660c9a549f7af154ca14347fac5cffd43b153a75211f1373f crypto/bn/bn_nist.c
|
|
||||||
b93ce358e1cdffcf36466bc6a1e4e050bd35841bb9afbbf5c77158240710ce7d crypto/bn/bn_prime.c
|
|
||||||
c56ad3073108a0de21c5820a48beae2bccdbf5aa8075ec21738878222eb9adc3 crypto/bn/bn_prime.h
|
|
||||||
71186d5bd40d467a919e6449d8aa23d13df88e0c85765d1a165f3eeec6bd33a7 crypto/bn/bn_rand.c
|
|
||||||
4df8f204c8a06de2b4395be613ca0b9943613c523586e2005876d5c7bb891c75 crypto/bn/bn_recp.c
|
|
||||||
569cebbb1644d1a4f0df888f17e9f0f474c1066b439e2633dcad415d04932509 crypto/bn/bn_rsa_fips186_4.c
|
|
||||||
6889866bca4673bccb8adf870859a867757ccd3c8ad4652675615afff710add3 crypto/bn/bn_shift.c
|
|
||||||
622e90766b29e0d25f46474429aebda8eba2246835b9e85dc26da7cdbd49334f crypto/bn/bn_sqr.c
|
|
||||||
42c8ce944c889abcfcf089d0ad2744b7587696d8d7785efa91b3f7ec53dc062a crypto/bn/bn_sqrt.c
|
|
||||||
24e62baa56e02f2db6454e10168b7c7fa7638db9221b9acda1803d43f38f36e0 crypto/bn/bn_word.c
|
|
||||||
be27115efd36f0077a3ec26b1ff1f586b0b8969ba05d8ffa34b2ff4badf227bf crypto/bn/rsaz_exp.c
|
|
||||||
c4d64da1cdc732ea918fccd6a7bb2746b03365dd26f7ba1e74e08c307ca4c58e crypto/bn/rsaz_exp.h
|
|
||||||
9ec2b47477e22d8ddb708df5ab507a4a5ada49284c1ecdd91ad5e582cf8d4c6e crypto/bn/rsaz_exp_x2.c
|
|
||||||
834db8ff36006e5cb53e09ca6c44290124bd23692f4341ea6563b66fcade4cea crypto/bsearch.c
|
|
||||||
c39334b70e1394e43f378ae8d31b6e6dc125e4d9181e6536d38e649c4eaadb75 crypto/buffer/buffer.c
|
|
||||||
d2bfdfd96b182741d2d51f91478ffcc48491b0da44662bc1c32bc506b3eef1ba crypto/c64xpluscpuid.pl
|
|
||||||
0e1a41a2d81b5765bca3df448f60bf1fad91e485fe89dd65a7300ffc419e316d crypto/cmac/cmac.c
|
|
||||||
b75a3f5f2b97c2e11b1c2024bc11250263f5f5e9eb5d6f4d448a76231c083f76 crypto/context.c
|
|
||||||
c309d81ea991ddf5be4337afad2fd132169f7443c76f863349d3f3c82f3374e4 crypto/core_algorithm.c
|
|
||||||
f0fd9eb38bf7f196bbb4d26ce8fdf86d0a4f9db219157e66b2c0ffefb4f42005 crypto/core_fetch.c
|
|
||||||
2f03908edadddc55a61e4cfb4d76751a342f61aad564971df37a6b90c7b2a26f crypto/core_namemap.c
|
|
||||||
97dfe8dd6278dc0f94f2ea3845b03a8d78cb31ee03c802c4b5822d9bfb28c1c6 crypto/cpuid.c
|
|
||||||
14ffbee223d679dcc2b365999f7fa5be259582ec53609399c74e2ff09df80899 crypto/cryptlib.c
|
|
||||||
66dbfc58916709d5a6913777346083247942a8d9458ee9b2bf443f0ea4988d64 crypto/ctype.c
|
|
||||||
51e56541daea6d4a26d5bae2ea458414063bf08b045bab8df370f6695903e0a5 crypto/der_writer.c
|
|
||||||
fea3ba4225df97aee90690adf387625b746d8edfdc5af2357ee65151a3d236ac crypto/des/des_enc.c
|
|
||||||
9da9a319d4391b6d20b646f0de9dc79489f230621b983c4088fef146c79cacea crypto/des/des_local.h
|
|
||||||
eeef5722ad56bf1af2ff71681bcc8b8525bc7077e973c98cee920ce9bcc66c81 crypto/des/ecb3_enc.c
|
|
||||||
04d4cc355200b57f1e7d265a2cebdf094df1eb6e96621b533adddc3d60d31fbe crypto/des/fcrypt_b.c
|
|
||||||
499513b3ad386fe694c4e04b3c8a9fd4c4e18fc44bb6c4f94d6bf2d9362a3a5a crypto/des/ncbc_enc.c
|
|
||||||
61926e30dd940616e80936d1c94c5f522daf0d475fb3a40a9e589e78f322901e crypto/des/set_key.c
|
|
||||||
8344811b14d151f6cd40a7bc45c8f4a1106252b119c1d5e6a589a023f39b107d crypto/des/spr.h
|
|
||||||
816472a54c273906d0a2b58650e0b9d28cc2c8023d120f0d77160f1fe34c4ca3 crypto/dh/dh_backend.c
|
|
||||||
24cf9462da6632c52b726041271f8a43dfb3f74414abe460d9cc9c7fd2fd2d7d crypto/dh/dh_check.c
|
|
||||||
c117ac4fd24369c7813ac9dc9685640700a82bb32b0f7e038e85afd6c8db75c7 crypto/dh/dh_gen.c
|
|
||||||
6b17861887b2535159b9e6ca4f927767dad3e71b6e8be50055bc784f78e92d64 crypto/dh/dh_group_params.c
|
|
||||||
a539a8930035fee3b723d74a1d13e931ff69a2b523c83d4a2d0d9db6c78ba902 crypto/dh/dh_kdf.c
|
|
||||||
b0c248efc7dad48eaceb939a18cb2592cbfe5b02dd406592e5e590645488b153 crypto/dh/dh_key.c
|
|
||||||
92345c259ea2a8c09e6d6b069d0942bd6ca4642231580f3e8148ae7a832a1115 crypto/dh/dh_lib.c
|
|
||||||
8300775d88db0a1aa26a77eb49d6c4f7252e7fee69e1440de4c40edadc9da044 crypto/dh/dh_local.h
|
|
||||||
bbcf4fc3067ac462a27d7277973180b7dc140df9262a686c7fbe4318ca01f7b8 crypto/dsa/dsa_backend.c
|
|
||||||
786d6c65ced7ee4e25f5dd7c3150259ec95b6aa321a7590d905757b8139f8230 crypto/dsa/dsa_check.c
|
|
||||||
ae727bf6319eb57e682de35d75ea357921987953b3688365c710e7fba51c7c58 crypto/dsa/dsa_gen.c
|
|
||||||
100889e879ffba26b3f2cf0a118943e7cf04076e632d76cfacf96c133949791a crypto/dsa/dsa_key.c
|
|
||||||
9f4837c5abe53613a2dc1c5db81d073d4f42bd28b6a2d1e93a2b350d8e25d52a crypto/dsa/dsa_lib.c
|
|
||||||
f4d52d3897219786c6046bf76abb2f174655c584caa50272bf5d281720df5022 crypto/dsa/dsa_local.h
|
|
||||||
196dc024873e413d92672c3a9b6c062ed6269250b0da6d41c0da1c03cfec9ef8 crypto/dsa/dsa_ossl.c
|
|
||||||
9f501a59c09fc3cb3caafaff25abd44397a94d1062950a4d62e855d2c8986b5a crypto/dsa/dsa_sign.c
|
|
||||||
53fa10cc87ac63e35df661882852dc46ae68e6fee83b842f1aeefe00b8900ee1 crypto/dsa/dsa_vrf.c
|
|
||||||
786779d7014bc04846832f80638743784a3850c7ee36e4a8062fe8eb7ac31c9b crypto/ec/asm/ecp_nistp521-ppc64.pl
|
|
||||||
2e3056ea14fab8b306b0281d6a6f4317a6e86dbf652a79ade726e716cd79bb1e crypto/ec/asm/ecp_nistz256-armv4.pl
|
|
||||||
fa172e62f175a58ffa69c41476fe41d297411f1822af88ce8c9faa125fbad2d1 crypto/ec/asm/ecp_nistz256-armv8.pl
|
|
||||||
729729f8233c95138158f4647b33a36cf175e707ce29563db0eedc811f324ec0 crypto/ec/asm/ecp_nistz256-ppc64.pl
|
|
||||||
78a5b172f7c13ae8ac622439ffb9d99b240dbb4bbda3f5c88d1533ae74a445ad crypto/ec/asm/ecp_nistz256-sparcv9.pl
|
|
||||||
922725c4761cfa567af6ed9ecab04f2c7729ae2595f2fc0fa46dc67879dc87b0 crypto/ec/asm/ecp_nistz256-x86.pl
|
|
||||||
19ba01af58788e2873ebc1d5b503a76604bec0b9b6296fa794946e141fc945a4 crypto/ec/asm/ecp_nistz256-x86_64.pl
|
|
||||||
e806141073aa3792e2748f6feeee6d3017124b3bc6059a9eca0d53a2f5785346 crypto/ec/asm/x25519-ppc64.pl
|
|
||||||
a397592dc9fdb13016311db6184b4a3a4f2e198aacb03528f770f30ea4966cc4 crypto/ec/asm/x25519-x86_64.pl
|
|
||||||
c0bcde09fd6f1d4682438a6e61365b377a288ce53d1ec81b354d76832bf308fa crypto/ec/curve25519.c
|
|
||||||
ebd47dd501b147a53ea3c0a0cca18789ac14e2ee4b94e2eed54248992763d454 crypto/ec/curve448/arch_32/f_impl32.c
|
|
||||||
063dac1e4a9573c47532123e9e03e3532a7473cc3e146521ba9ec6f486ddf3b1 crypto/ec/curve448/arch_64/arch_intrinsics.h
|
|
||||||
43423b7ee85a5c740c1d81499ee06f4a17732c7731a598e7429d5e402ee77cf4 crypto/ec/curve448/arch_64/f_impl.h
|
|
||||||
eaaeb5a56079f0aabd6b3123b25f2a526fa45567c11c27cc692dab44006a33c2 crypto/ec/curve448/arch_64/f_impl64.c
|
|
||||||
9b408ec0d43f3b6d714ef5963147e2c2abaddc88633db7dd759193d3c56ed727 crypto/ec/curve448/curve448.c
|
|
||||||
3c12d90e3fdd59b5d32d63186f1a6f15c75eb73f5035b844a2054356a9459780 crypto/ec/curve448/curve448_local.h
|
|
||||||
178fb9863c33174b633c2e7607160b1bedb506d66cc06d53382d87431441f306 crypto/ec/curve448/curve448_tables.c
|
|
||||||
f30e13bba5a136ab9ba5225c98b9b94c2cd73fb3aef60f9dcde3cd471cfa1ca4 crypto/ec/curve448/curve448utils.h
|
|
||||||
4a45e7828831fbe9f282f933cda54b12cd393ec9bffe5c0ace8e4d1c4d5d6358 crypto/ec/curve448/ed448.h
|
|
||||||
a1211ed3991af967c728b9f6d0774b9ea098d43cef0631ff88984a2580d2ac4f crypto/ec/curve448/eddsa.c
|
|
||||||
450946e1cccb81e45e5601b6154e2311666b06e294aab926369995af06d1a328 crypto/ec/curve448/f_generic.c
|
|
||||||
f6447921a0031fa5beddedd298e82096fb3fdb189b712fab328b61f6beae0c23 crypto/ec/curve448/field.h
|
|
||||||
2ad8331e893b5db33198e27603891587686c0dfdab29706dc52a7097c5d6f219 crypto/ec/curve448/point_448.h
|
|
||||||
1ff6e467d72530c71d21c310180d04a24f0a9cb41168fba94b43309ecdda3888 crypto/ec/curve448/scalar.c
|
|
||||||
3052a044afae2e91b677542fc8b34b3ec9d033e0c6562b0d43098cfb34ab3c9d crypto/ec/curve448/word.h
|
|
||||||
ae1637d89287c9d22a34bdc0d67f6e01262a2f8dcef9b61369dba8c334f5a80d crypto/ec/ec2_oct.c
|
|
||||||
6bbbf570ce31f5b579f7e03ec9f8a774663c7c1eb5e475bd31f8fee94a021ffc crypto/ec/ec2_smpl.c
|
|
||||||
2a71bd8dbe4f427c117d990581709a4ddce07fa8e530794b5a9574fef7c48a0c crypto/ec/ec_asn1.c
|
|
||||||
73318950cad070cf883f2883d73ca85adae4125cde85d7feb98a220e6044dc6a crypto/ec/ec_backend.c
|
|
||||||
86e2becf9b3870979e2abefa1bd318e1a31820d275e2b50e03b17fc287abb20a crypto/ec/ec_check.c
|
|
||||||
265f911b9d4aada326a2d52cd8a589b556935c8b641598dcd36c6f85d29ce655 crypto/ec/ec_curve.c
|
|
||||||
8cfd0dcfb5acbf6105691a2d5e2826dba1ff3906707bc9dd6ff9bffcc306468f crypto/ec/ec_cvt.c
|
|
||||||
0139b6fc533a885b4a8c2929c3b9c61c676d53e32ddda05c57618714724fa9f7 crypto/ec/ec_key.c
|
|
||||||
7e40fc646863e0675bbb90f075b809f61bdf0600d8095c8366858d9533ab7700 crypto/ec/ec_kmeth.c
|
|
||||||
57c6107e235ace603498eadde6bcb03ede2e2e828c0041ed2084a42aa5eb7144 crypto/ec/ec_lib.c
|
|
||||||
a8a4690e42b4af60aad822aa8b16196df337906af53ea4db926707f7b596ff27 crypto/ec/ec_local.h
|
|
||||||
fa901b996eb0e460359cd470843bdb03af7a77a2f1136c5e1d30daef70f3e4d2 crypto/ec/ec_mult.c
|
|
||||||
129c6b42417bfcf582f4a959cfd65433e6f85b158274f4fa38f9c62615ac9166 crypto/ec/ec_oct.c
|
|
||||||
c7fba2f2c33f67dafa23caef8c3abd12f5336274a9a07d412b83be0366969ee6 crypto/ec/ecdh_kdf.c
|
|
||||||
b2cf8f052a5716137da7b0e857ed7a5df5fb513b6d14534199a05e32f2b5a866 crypto/ec/ecdh_ossl.c
|
|
||||||
2e00c2e0e6f6d58b81fc23fe500f59e98793dc828ca87d64eba10cc0fddd0dc1 crypto/ec/ecdsa_ossl.c
|
|
||||||
b6baa42b16e8df69a12e0ab101033100cddc808ec2682ba1574373e6ec86ae93 crypto/ec/ecdsa_sign.c
|
|
||||||
f686cea8c8a3259d95c1e6142813d9da47b6d624c62f26c7e4a16d5607cddb35 crypto/ec/ecdsa_vrf.c
|
|
||||||
141cfc1459214555b623517a054a9e8d5e4065a11301237b7247be2c6f397a0a crypto/ec/ecp_mont.c
|
|
||||||
13b30f34aeeb0c98747239bfe91b5f0f14e91b2c1f11db62ebb5950c7219daa0 crypto/ec/ecp_nist.c
|
|
||||||
f288c23b6f83740956886b2303c64d5a3098c98b530859c3bb4b698c01c1643b crypto/ec/ecp_nistz256.c
|
|
||||||
51cb98e7e9c241e33261589f0d74103238baaa850e333c61ff1da360e127518a crypto/ec/ecp_oct.c
|
|
||||||
19f227a48a24d34a1db31f1c4b925ac01a709ba1916a1d3aefec1da4d834d065 crypto/ec/ecp_smpl.c
|
|
||||||
e2705097cfab64e8d7eb2feba37c3f12b18aec74b135ad0c7f073efccf336d4c crypto/ec/ecx_backend.c
|
|
||||||
5ee19c357c318b2948ff5d9118a626a6207af2b2eade7d8536051d4a522668d3 crypto/ec/ecx_backend.h
|
|
||||||
22c44f561ab42d1bd7fd3a3c538ebaba375a704f98056b035e7949d73963c580 crypto/ec/ecx_key.c
|
|
||||||
28abc295dad8888b5482eb61d31cd78dd80545ecb67dc6f9446a36deb8c40a5e crypto/evp/asymcipher.c
|
|
||||||
0e75a058dcbbb62cfe39fec6c4a85385dc1a8fce794e4278ce6cebb29763b82b crypto/evp/dh_support.c
|
|
||||||
1876339183b401fc9aab6670f65e5dd8631c39b869240a3750afee9a914881af crypto/evp/digest.c
|
|
||||||
838277f228cd3025cf95a9cd435e5606ad1fb5d207bbb057aa29892e6a657c55 crypto/evp/ec_support.c
|
|
||||||
5cc8225a5a4df7a0feeeb5a7fd07bd826072f1c212772094c02ca26024d33b62 crypto/evp/evp_enc.c
|
|
||||||
30cc374463249f5a3b9dea9404f81b5fc7ac69c62723c89c28cd930feea04960 crypto/evp/evp_fetch.c
|
|
||||||
ce982249442688249f7c53d0824ae6affb1cf89281f35fbd68c1e0c4c57217d3 crypto/evp/evp_lib.c
|
|
||||||
5afebfcf415079974ab3b8b70eac93b618fd264135cd68fee5834edffc60ce22 crypto/evp/evp_local.h
|
|
||||||
958c32605960fff7a56ddbf2708a9b74f0e30d00c9e415e1fd111fefd3feb0b5 crypto/evp/evp_rand.c
|
|
||||||
2a128617ec0178e9eeacbe41d75a5530755f41ea524cd124607543cf73456a0c crypto/evp/evp_utils.c
|
|
||||||
ca8c6cfd30efd53f2e5d1f19bcf09a3a3d0dff6d8947c3943d07a3f4b354aa86 crypto/evp/exchange.c
|
|
||||||
9e25042581b73e295c059c6217f3ecf809134d518eb79b1b67f34e3ca9145677 crypto/evp/kdf_lib.c
|
|
||||||
1d72f5506984df1df8606e8c7045f041cf517223e2e1b50c4da8ba8bf1c6c186 crypto/evp/kdf_meth.c
|
|
||||||
5179624b8e03615dc9caedc9ec16d094fa081495613dd552d71c2c39475bcd83 crypto/evp/kem.c
|
|
||||||
5cf3e490bf917bd37ae70313d126ae4720432fbec518e4a45e8fa886d5e1689a crypto/evp/keymgmt_lib.c
|
|
||||||
4c4f49b0305fe3977e04a4315f24470f6e190a3e25735d5dd512d430e2140290 crypto/evp/keymgmt_meth.c
|
|
||||||
e1a052839b8b70dca20dbac1282d61abd1c415bf4fb6afb56b811e8770d8a2e1 crypto/evp/m_sigver.c
|
|
||||||
4290c95f63b43688a8da57690d122add5161a6811f9753da1444d28f46739961 crypto/evp/mac_lib.c
|
|
||||||
e7e8eb5683cd3fbd409df888020dc353b65ac291361829cc4131d5bc86c9fcb3 crypto/evp/mac_meth.c
|
|
||||||
546d83abecf8973e2d872102a03bde5a46552909fa9e7d1402e1464a27453801 crypto/evp/p_lib.c
|
|
||||||
3b4228b92eebd04616ecc3ee58684095313dd5ffd1b43cf698a7d6c202cb4622 crypto/evp/pmeth_check.c
|
|
||||||
1f0e9e94e9b0ad322956521b438b78d44cfcd8eb974e8921d05f9e21ba1c05cf crypto/evp/pmeth_gn.c
|
|
||||||
76511fba789089a50ef87774817a5482c33633a76a94ecf7b6e8eb915585575d crypto/evp/pmeth_lib.c
|
|
||||||
53058617c153a7676e7ca18c98c23df867a93087d67935907076f3c5bd65c15e crypto/evp/signature.c
|
|
||||||
600a90728cea180e3c9f6ac5269fa86fef82494f9cde3d8914df3387c80afbfd crypto/ex_data.c
|
|
||||||
1c8389c5d49616d491978f0f2b2a54ba82d805ec41c8f75c67853216953cf46a crypto/ffc/ffc_backend.c
|
|
||||||
a12af33e605315cdddd6d759e70cd9632f0f33682b9aa7103ed1ecd354fc7e55 crypto/ffc/ffc_dh.c
|
|
||||||
854378f57707e31ad02cca6eec94369f91f327288d3665713e249c12f7b13211 crypto/ffc/ffc_key_generate.c
|
|
||||||
4e973d956d4ec2087994de8e963be1a512da1441f22e6e7b9cd7ee536e3ff834 crypto/ffc/ffc_key_validate.c
|
|
||||||
8b72d5a7452b2c15aec6d20027053a83f7df89d49a3b6cfedd77e2b1a29e9fc1 crypto/ffc/ffc_params.c
|
|
||||||
1a1d227f9a0f427d2ec93bc646c726c9cd49a84a343b4aff0c9c744fa6df05a9 crypto/ffc/ffc_params_generate.c
|
|
||||||
73dac805abab36cd9df53a421221c71d06a366a4ce479fa788be777f11b47159 crypto/ffc/ffc_params_validate.c
|
|
||||||
0a4fc92e408b0562cf95c480df93a9907a318a2c92356642903a5d50ed04fd88 crypto/hmac/hmac.c
|
|
||||||
0395c1b0834f2f4a0ca1756385f4dc1a4ef6fb925b2db3743df7f57256c5166f crypto/hmac/hmac_local.h
|
|
||||||
0e2d6129504d15ffaf5baa63158ccec0e4b6193a8275333956d8f868ef35127e crypto/ia64cpuid.S
|
|
||||||
3f123f7de496711fa60c47aeaef96640571dbcb1657b23901307e04c3d712579 crypto/initthread.c
|
|
||||||
f91d8ca9ac5e7f6ba3282ab53700acf7dc477972d2effd239518043eb1a59a96 crypto/lhash/lhash.c
|
|
||||||
5d49ce00fc06df1b64cbc139ef45c71e0faf08a33f966bc608c82d574521a49e crypto/lhash/lhash_local.h
|
|
||||||
83b3c1250097ce8f047c918e80169df2c51eaba1d71079ab18a935615e8e49c5 crypto/loongarch64cpuid.pl
|
|
||||||
460a7af09cde89a820b091522ada1310cfcec99c60aee505f94c48c35e9a29e8 crypto/loongarchcap.c
|
|
||||||
f866aafae928db1b439ac950dc90744a2397dfe222672fe68b3798396190c8b0 crypto/mem_clr.c
|
|
||||||
6906e197c84ae0d828748d47c47d565fd912076c35a65ea304e306fee4a17157 crypto/modes/asm/aes-gcm-armv8-unroll8_64.pl
|
|
||||||
2c97a18aad5f681876dbd77f0a0ed20d86fc22060592cbda1fc0449fdf329724 crypto/modes/asm/aes-gcm-armv8_64.pl
|
|
||||||
efba3c8944a19993565989e33d8758f32f18ac484305e5b8f2a40c8734057389 crypto/modes/asm/aes-gcm-avx512.pl
|
|
||||||
b878b589b9c74bddac990f9f98fe323d3cbe0dfb5634d92224812d18ecca3f23 crypto/modes/asm/aes-gcm-ppc.pl
|
|
||||||
e482f02932d77d61142548ca4f3c8d5709d88ec14ab84723d82331444c0f57da crypto/modes/asm/aesni-gcm-x86_64.pl
|
|
||||||
8fdcb4313fa3a6e541a697525856b9527a06ddf4c794f9393e843f86d67f543c crypto/modes/asm/ghash-alpha.pl
|
|
||||||
ace8c376b394439301cecaf468d2a9a8adae21eff1d43191cefbf6765023452d crypto/modes/asm/ghash-armv4.pl
|
|
||||||
c22f4945e7de3bd7bfef73447f09983e40a3e4dd0938244d902a1c44c98a8467 crypto/modes/asm/ghash-c64xplus.pl
|
|
||||||
315a76491cdba48c88df6549c9efd96b50515400810b185a568b7a871681e03d crypto/modes/asm/ghash-ia64.pl
|
|
||||||
25e9f494fcb6eb636c04af2f322736fae8aa339037e199332c96b8c9c3a50afa crypto/modes/asm/ghash-parisc.pl
|
|
||||||
e4ea504b2f5878dd6ad97a68d2be86c2f8eb655af6b713b022982aa560b83468 crypto/modes/asm/ghash-riscv64.pl
|
|
||||||
4bb81f297f0c76762116895295fe027fb1b22ddb5b992c216128116afd09db77 crypto/modes/asm/ghash-s390x.pl
|
|
||||||
de97107e0c19ff9dd4069f0761eccb00e0b3ced345e1f119ab3b918dd2f9c5f6 crypto/modes/asm/ghash-sparcv9.pl
|
|
||||||
26f55a57e77f774d17dfba93d757f78edfa3a03f68a71ffa37ccf3bfc468b1e2 crypto/modes/asm/ghash-x86.pl
|
|
||||||
2a0d23a644083e46745c7cb1ca79de393af9336a2e8eab7c85ffeb3b7b1a286f crypto/modes/asm/ghash-x86_64.pl
|
|
||||||
b407d9fc6ea65fe1a05edc2d139298d78391f3c165314fa6d56dd375b8e453cd crypto/modes/asm/ghashp8-ppc.pl
|
|
||||||
3643d2ec821a959ad79bd41b82fe6d56d32264c972b34544ded519029c948f5d crypto/modes/asm/ghashv8-armx.pl
|
|
||||||
65112dfe63cd59487e7bdb1706b44acfcf48ecede12cc3ae51daa5b661f41f06 crypto/modes/cbc128.c
|
|
||||||
1611e73dc1e01b5c2201f51756a7405b7673aa0bb872e2957d1ec80c3530486f crypto/modes/ccm128.c
|
|
||||||
d8c2f256532a4b94db6d03aea5cb609cccc938069f644b2fc77c5015648d148d crypto/modes/cfb128.c
|
|
||||||
af1c034152d82b29cb7c938c8516cfd136b62bac0908c1d40eb50790d23b288c crypto/modes/ctr128.c
|
|
||||||
df064432bdd596550920b7a5807811116d24bb11d17729f8d49033418964bed1 crypto/modes/gcm128.c
|
|
||||||
bdf25257b15eca206be4d950d2dd807ca5f058f91f54edbd7a0d312ed83eef8e crypto/modes/ofb128.c
|
|
||||||
e55a816c356b2d526bc6e40c8b81afa02576e4d44c7d7b6bbe444fb8b01aad41 crypto/modes/wrap128.c
|
|
||||||
608a04f387be2a509b4d4ad414b7015ab833e56b85020e692e193160f36883a2 crypto/modes/xts128.c
|
|
||||||
e9d29619f9e3f1b818c807727eacdb20afb69c4d2bdc5eca857a0172b7e40236 crypto/o_str.c
|
|
||||||
8ddbbdf43131c10dcd4428aef0eff2b1e98b0410accada0fad41a4925868beef crypto/packet.c
|
|
||||||
a5ec003c261e1d97490d9629ec8893f3fc0c759dba73179912cf504816b708cf crypto/param_build.c
|
|
||||||
cae7bd4973d36edbdc3bdd8d2c8d157f2c4fcfae00fdf821b67aebb789bc8aa6 crypto/param_build_set.c
|
|
||||||
ce0e3fb4f466947b58d19a6fbc6c909ba0767b752ec8f563bfa7a8497b9a67d7 crypto/params.c
|
|
||||||
5aed5133eac67516866a8187ec875ff2f8abac4272f80264b52fa225b732dc4a crypto/params_dup.c
|
|
||||||
b6cbfc8791b31587f32a3f9e4c117549793528ebddc34a361bad1ad8cf8d4c42 crypto/params_from_text.c
|
|
||||||
98eb56498937aca2d4fca8670760485f8b342b7dcd84442f8e114d47310eacbf crypto/ppccap.c
|
|
||||||
b650e7e96b8faad750842b86905032db51e17880958bb8d9826d02ca8eb60642 crypto/ppccpuid.pl
|
|
||||||
467c416422ecf61e3b713c5eb259fdbcb4aa73ae8dee61804d0b85cfd3fff4f7 crypto/property/defn_cache.c
|
|
||||||
14cf71685e645a4473affdacac28a12a7b2eb0a995f2936a4aecb53d52447743 crypto/property/property.c
|
|
||||||
66da4f28d408133fb544b14aeb9ad4913e7c5c67e2826e53f0dc5bf4d8fada26 crypto/property/property_local.h
|
|
||||||
0a84d66734df7515a6de2b8da744a398f11b977f8479076090e67357fa0eb51d crypto/property/property_parse.c
|
|
||||||
a7cefda6a117550e2c76e0f307565ce1e11640b11ba10c80e469a837fd1212a3 crypto/property/property_query.c
|
|
||||||
20e69b9d594dfc443075eddbb0e6bcc0ed36ca51993cd50cc5a4f86eb31127f8 crypto/property/property_string.c
|
|
||||||
bbf12717cb8b74699cf4ca6959018e32a2f3123d5a1a3f9080dbabcc173d141d crypto/provider_core.c
|
|
||||||
d0af10d4091b2032aac1b7db80f8c2e14fa7176592716b25b9437ab6b53c0a89 crypto/provider_local.h
|
|
||||||
5ba2e1c74ddcd0453d02e32612299d1eef18eff8493a7606c15d0dc3738ad1d9 crypto/provider_predefined.c
|
|
||||||
aec47f5e7ec054226692df055a90305fd0dbaf0fbf20b56df353c04a2c2725e0 crypto/rand/rand_lib.c
|
|
||||||
fd03b9bb2c23470fa40880ed3bf9847bb17d50592101a78c0ad7a0f121209788 crypto/rand/rand_local.h
|
|
||||||
15e8438f4fe53b9c625d9f59590f9c952aa6baca32d1cf5f64afad1e1d7ed1c1 crypto/riscv32cpuid.pl
|
|
||||||
710fc90ee9de3719c98a80fd468444f097da681186d9c45169a417ae3bdc3bfb crypto/riscv64cpuid.pl
|
|
||||||
a0870a2d4189788a4500227e7142f2fd9805357ecf083699273ef94b1f455ae3 crypto/riscvcap.c
|
|
||||||
f0c8792a99132e0b9c027cfa7370f45594a115934cdc9e8f23bdd64abecaf7fd crypto/rsa/rsa_acvp_test_params.c
|
|
||||||
5834d7c518ad53ea0dd3db811c0e51568c81cc6c117012030101d29003d0725c crypto/rsa/rsa_backend.c
|
|
||||||
38a102cd1da1f6ca5a46e6a22f018237964336274385f5c70cbedcaa6997647e crypto/rsa/rsa_chk.c
|
|
||||||
e32cfa04221a2a3ea33f7bcb93ee51b84cbeba97e94c1fbf6e420b24f97fc9ce crypto/rsa/rsa_crpt.c
|
|
||||||
e995da1c2e5007bd7f5907f369fe45ed15f4e657143a85078c755bd5e6863d0b crypto/rsa/rsa_gen.c
|
|
||||||
f2222f270e57559537d3da8abbeb1390bc5376b73dae59d536af6e73eb48bba0 crypto/rsa/rsa_lib.c
|
|
||||||
a65e85be5269d8cb88e86b3413c978fa8994419a671092cbf104ff1a08fda23b crypto/rsa/rsa_local.h
|
|
||||||
cf0b75cd54b61b9b9a290ef18d0ddce9fb26a029a54eb3f720d9b25188440f00 crypto/rsa/rsa_mp_names.c
|
|
||||||
5c60f6e05db82e13178d805deb1947b8eee4a905e6e77523d3b288da70a46bb5 crypto/rsa/rsa_none.c
|
|
||||||
f733d03a7f633514bfb33862cd0fa46ac952a86f84000f109c0d37937bac9a1e crypto/rsa/rsa_oaep.c
|
|
||||||
e05fcad237b7e4e7842ad6e142789fe25d060247283c337c78703be6ecc31ed9 crypto/rsa/rsa_ossl.c
|
|
||||||
be3f39c1fcb777d6c0122061f9ef735d10a6bee95d67fcc1ca6ae2a664022d2b crypto/rsa/rsa_pk1.c
|
|
||||||
04b3d6145d36262d7b8f625a2595a48ea8cbf2190b2760762c1eef3cdb8566c0 crypto/rsa/rsa_pss.c
|
|
||||||
bf6d300b7e7e9e512a47c5bd1f8713806ae3033a140d83dfae4a16ad58d11170 crypto/rsa/rsa_schemes.c
|
|
||||||
f01af62704dbf9457e2669c3e7c1d4d740f0388faa49df93611b987a8aa2bf11 crypto/rsa/rsa_sign.c
|
|
||||||
42d821612b0b0d62f587beb8a0cab8b8d876fedccd6913fec6d2044f8ac52b63 crypto/rsa/rsa_sp800_56b_check.c
|
|
||||||
3aba73dacebb046faf8d09dc279149b52c629004b524ec33e6d81c8ad0bc31a8 crypto/rsa/rsa_sp800_56b_gen.c
|
|
||||||
1c1c2aeeb18bf1d69e8f134315b7e50d8f43d30eb1aa5bf42983eec9136a2fdc crypto/rsa/rsa_x931.c
|
|
||||||
630b267c189964f2d1ffbf50e6588e8409cbf87e1e49edaec81b57b6f845df34 crypto/s390xcap.c
|
|
||||||
370d98549d4d98e04b60677b319b85904259359bd9401dd5385aa728278e6626 crypto/s390xcpuid.pl
|
|
||||||
465f850c3d6f2e9410f2e1ee9604b1b5b80f99bae1f6c581161c2f7ebc2c6e41 crypto/self_test_core.c
|
|
||||||
58a1a8aeb45421954fa0e4bc87157addb96d086ac4e6aade47da96523cecaa74 crypto/sha/asm/keccak1600-armv4.pl
|
|
||||||
350cf5e6ce9594a287e51cd725c4a6dd65704aea60384003aea7aa8863bd0000 crypto/sha/asm/keccak1600-armv8.pl
|
|
||||||
81bfb4484d68a3a3e1d704855f76356090867fe10a75db7707b6f7364e8ee8da crypto/sha/asm/keccak1600-avx2.pl
|
|
||||||
b7bb35d51d439abbf3810454ccb9bfb5a51e2111eaf389fb95796ad6220a61a0 crypto/sha/asm/keccak1600-avx512.pl
|
|
||||||
37365dcc576f99006132271968bab990e2bebdab7f4168c726bd449a2fa51c6a crypto/sha/asm/keccak1600-avx512vl.pl
|
|
||||||
2767ae2f379a7a3d0c6dd1471d4d90dd896545b456cb6efd6c230df29e511d70 crypto/sha/asm/keccak1600-c64x.pl
|
|
||||||
09fc831dd39bd90a701e9b16d9e9987cc215252a22e1e0355f5da6c495fca35a crypto/sha/asm/keccak1600-mmx.pl
|
|
||||||
956506c0c1da347210425e97aef5ef5f181f1ba1292ec98c2f22cb8719273254 crypto/sha/asm/keccak1600-ppc64.pl
|
|
||||||
49535b60a1a981059a2a9636fdeeab22942d2a15e775b1ec9b5af8937a46aa76 crypto/sha/asm/keccak1600-s390x.pl
|
|
||||||
093751655b460d33b2fa6aa4d63a86e902f7f20b2d2a02ed948b78e5698c0dd5 crypto/sha/asm/keccak1600-x86_64.pl
|
|
||||||
e0a4a1df82716053a3f01ec0b096c735a0e3c4f6c9d9ec6b2006b37aaac64448 crypto/sha/asm/keccak1600p8-ppc.pl
|
|
||||||
75d832db9bf0e98e7a5c522169060a6dd276c5118cfb297fc3f1111f55cd4007 crypto/sha/asm/sha1-586.pl
|
|
||||||
8d937771993f04407f5fdcca8ca8565f9f8a4d9c9a8f7bfd4e9f9121dd0450bb crypto/sha/asm/sha1-alpha.pl
|
|
||||||
99a58a0069f3336764b46f74f1023d399bd48c32bc4cf06d66e008fb926fceaf crypto/sha/asm/sha1-armv4-large.pl
|
|
||||||
083ab18f3753fe886b188328eae183f24a2ef5cfc929dc3a53c24410d91ca052 crypto/sha/asm/sha1-armv8.pl
|
|
||||||
c36f51761e7f59bdd0f61230297fb802542ac5d2d1c6d2b1096ed937131bd583 crypto/sha/asm/sha1-c64xplus.pl
|
|
||||||
4ab7c9153b085274a579b388ddff97a4ac7e11585e01811ca95b93a3ec786605 crypto/sha/asm/sha1-ia64.pl
|
|
||||||
7a392c5ef7dc19c39d67c7080e0c5214e7a80572c85c022be7e7d4378a5f740d crypto/sha/asm/sha1-mb-x86_64.pl
|
|
||||||
c0fea5a0d32001263c8bcf7fc0757aa68c6a7377f20fef8d28708e1b81de5dec crypto/sha/asm/sha1-mips.pl
|
|
||||||
f11b75a54c5f42aa3a052de8091bfba47d7cac01920b2fe0ddcb637d4c9d0eb9 crypto/sha/asm/sha1-parisc.pl
|
|
||||||
d46ef3fc166271a83144d90985034e2c514bd1020b84ec0fe5427ad593bfeb74 crypto/sha/asm/sha1-ppc.pl
|
|
||||||
a48c7d9403fe99fbd4daec60e96eb22058da766ab9e606d084a63613962851a2 crypto/sha/asm/sha1-s390x.pl
|
|
||||||
0e2951e0574c64ee055ffddf16ceefdec00823107d60362976605f139ad8ae68 crypto/sha/asm/sha1-sparcv9.pl
|
|
||||||
5da48400d4fae85e205e95a2fa368e7bf525e51e274b1dd680dfb48645426c85 crypto/sha/asm/sha1-sparcv9a.pl
|
|
||||||
04b73c902d36c28b5a7eab47cb85f743eb9c648ed5936f64f655524a1010a1b5 crypto/sha/asm/sha1-thumb.pl
|
|
||||||
f36d7ec7464c932230585a754b91f13cea4cde5a381fc9f798d959256d07910e crypto/sha/asm/sha1-x86_64.pl
|
|
||||||
c099059ef107f548ea2c2bab64a4eb8c277070ce6d74c4d32bb9808dc19c5fa3 crypto/sha/asm/sha256-586.pl
|
|
||||||
8bfdb28ef338f981fffa5957a7867ce2408680d71a4c6e975eeb85970579d6a8 crypto/sha/asm/sha256-armv4.pl
|
|
||||||
c394bb5b0ff05595a9e6848b6602a0f29f73a79fc006593740f3ca645ad9d316 crypto/sha/asm/sha256-c64xplus.pl
|
|
||||||
f33af8e2e2f57b7b63b8c8b35722d7d11ca6ef1f73fb6c4ccebdd3e86912f4b1 crypto/sha/asm/sha256-mb-x86_64.pl
|
|
||||||
dd82e1311703abb019975fc7b61fb87d67e1ed916dddd065aced051e851114b9 crypto/sha/asm/sha512-586.pl
|
|
||||||
101659eaade9a3162ecc0257c271b9c05411318fc45b02445ec3ace5f6bf28d0 crypto/sha/asm/sha512-armv4.pl
|
|
||||||
9e6b3e56bf34a0ca032e72990dfa56b87abe60075e6dffc9fcb66a4c1477cc52 crypto/sha/asm/sha512-armv8.pl
|
|
||||||
5b6796a9978b69fd78ee2ff1adc5cf35d44cad8194a38d1c2aba2023012cf252 crypto/sha/asm/sha512-c64xplus.pl
|
|
||||||
e8df660671ba61aa2e8f51358baf5d8ca913093e2ee1a40c9cb46d9c2c0851f6 crypto/sha/asm/sha512-ia64.pl
|
|
||||||
525f253ef8051bfb0e344ac2e40688ce359a42707fe360d23a03f522cc88c81a crypto/sha/asm/sha512-mips.pl
|
|
||||||
3c3e03529d8514467f8d77c01978348636bb339315feb8041fbde7640565001e crypto/sha/asm/sha512-parisc.pl
|
|
||||||
952ef1b10e8bbe3f638cc798b91ab9c5b47b66ed8fe94647b1beec9874f2e71e crypto/sha/asm/sha512-ppc.pl
|
|
||||||
193a0ea240264b29dd68a425f604a6da4b18e28838dcf909dd7e711af880f782 crypto/sha/asm/sha512-s390x.pl
|
|
||||||
dcb466a1e5938fb64ecb38b0533602192d61334da864ee8dfdcfa12d3cdfa273 crypto/sha/asm/sha512-sparcv9.pl
|
|
||||||
bb6503967a58b767a3e73441cfabc77f15c8ac747f377e276d4aa63d05f2c3c4 crypto/sha/asm/sha512-x86_64.pl
|
|
||||||
68d2f3b2dccb978ee42640f4fb4d2eae6b74d071017a3eedd9e7cb77762817dc crypto/sha/asm/sha512p8-ppc.pl
|
|
||||||
57f6cf54b1b5d2cac7a8f622b7b6bd1878f360fff3fa0f02352061c24162ebbb crypto/sha/keccak1600.c
|
|
||||||
306cacd3f86e5cacaca74c58ef862516515e5c0cafaff48636d537fd84f1c2fb crypto/sha/sha1dgst.c
|
|
||||||
58f6bacfa26273c9cf1b7b11dd2456253f44f20958905f7cb9d0f8eaf40f9591 crypto/sha/sha256.c
|
|
||||||
3d972a11be18bfbfcd45790028635d63548bfe0a2e45d2fc56b6051b759d22f0 crypto/sha/sha3.c
|
|
||||||
dc89d6740cfb58729e3276e03d290ae8319c6b081bfeaf21a0aa15ffb9839e17 crypto/sha/sha512.c
|
|
||||||
6c6f0e6069ac98e407a5810b84deace2d1396d252c584703bcd154d1a015c3ea crypto/sha/sha_local.h
|
|
||||||
9ef5a01caccc2eb15f72e367d0424737040ac8018479bbbbce3d216c655765c2 crypto/sparccpuid.S
|
|
||||||
5056b14a55665ffa342a9a1bb32c1c36886add5d0819869193427f33cee028f7 crypto/sparcv9cap.c
|
|
||||||
c50c584c55e56347bb43aca4b796b5344d70daece3061f586b79c871c21f5d1a crypto/sparse_array.c
|
|
||||||
8da78169fa8c09dc3c29c9bf1602b22e88c5eac4815e274ba1864c166e31584b crypto/stack/stack.c
|
|
||||||
67ba8d87fbbb7c9a9e438018e7ecfd1cedd4d00224be05755580d044f5f1317a crypto/threads_lib.c
|
|
||||||
a41ae93a755e2ec89b3cb5b4932e2b508fdda92ace2e025a2650a6da0e9e972c crypto/threads_none.c
|
|
||||||
3729e2bd36f945808b578e0d89fac0fcb3114e4fc9381614bcbd8a9869991716 crypto/threads_pthread.c
|
|
||||||
88423960f0414f6fd41fba4f4c67f9f7260c2741e4788adcd52493e895ec8027 crypto/threads_win.c
|
|
||||||
af0af59fe2cb8668a96751f343232d7faa3e7a937beb2bda09ed74fe60b9cb5f crypto/x86_64cpuid.pl
|
|
||||||
bbec287bb9bf35379885f8f8998b7fd9e8fc22efee9e1b299109af0f33a7ee16 crypto/x86cpuid.pl
|
|
||||||
7e9fbf99fbccb8a95dd200eb58380930a4130b671c8b6fff3702bff343abc78e include/crypto/aes_platform.h
|
|
||||||
8c6f308c1ca774e6127e325c3b80511dbcdc99631f032694d8db53a5c02364ee include/crypto/asn1_dsa.h
|
|
||||||
523c3d2401ec3468a4dc3f920146f1aa4a176c6f57825d6ede6e90c8b6cd994b include/crypto/bn.h
|
|
||||||
1c46818354d42bd1b1c4e5fdae9e019814936e775fd8c918ca49959c2a6416df include/crypto/bn_conf.h.in
|
|
||||||
7a43a4898fcc8446065e6c99249bcc14e475716e8c1d40d50408c0ab179520e6 include/crypto/bn_dh.h
|
|
||||||
04efb7f98705423b2a63a697a174d37c66d12edf349770e8433b2da5301be390 include/crypto/context.h
|
|
||||||
e69b2b20fb415e24b970941c84a62b752b5d0175bc68126e467f7cc970495504 include/crypto/cryptlib.h
|
|
||||||
6c72cfa9e59d276c1debcfd36a0aff277539b43d2272267147fad4165d72747c include/crypto/ctype.h
|
|
||||||
89693e0a7528a9574e1d2f80644b29e3b895d3684111dd07c18cc5bed28b45b7 include/crypto/des_platform.h
|
|
||||||
daf508bb7ed5783f1c8c622f0c230e179244dd3f584e1223a19ab95930fbcb4f include/crypto/dh.h
|
|
||||||
20d99c9a740e4d7d67e23fa4ae4c6a39d114e486c66ad41b65d91a8244cd1dea include/crypto/dsa.h
|
|
||||||
2ea47c059e84ce9d14cc31f4faf45f64d631de9e2937aa1d7a83de5571c63574 include/crypto/ec.h
|
|
||||||
edbfae8720502a4708983b60eac72aa04f031059f197ada31627cb5e72812858 include/crypto/ecx.h
|
|
||||||
596d8efb42a05d3d11fa81d38193828b46e812f7b2553f2bfaf398b35b7b1da8 include/crypto/evp.h
|
|
||||||
bbe5e52d84e65449a13e42cd2d6adce59b8ed6e73d6950917aa77dc1f3f5dff6 include/crypto/lhash.h
|
|
||||||
9190c0b67ead73be80c0b9e53a492bbbc7f22641e6abed82e105fd80198595c4 include/crypto/md32_common.h
|
|
||||||
cf90ee889f93092e260ae6d7a01bbefbf3ad8651153729206e45db671bac3dab include/crypto/modes.h
|
|
||||||
b194efe362380fe989e1f6cbd96c0899496949f17676f3a1ee541731511ce672 include/crypto/rand.h
|
|
||||||
90930fc8788d6e04e57829346e0405293ac7a678c3cef23d0692c742e9586d09 include/crypto/rand_pool.h
|
|
||||||
306abf9d327a9e63fff2cdef730275abc4d2781254a032b1f370f3428eb5a2ef include/crypto/rsa.h
|
|
||||||
32f0149ab1d82fddbdfbbc44e3078b4a4cc6936d35187e0f8d02cc0bc19f2401 include/crypto/security_bits.h
|
|
||||||
0f743762f646656b5480648c05632575fe8acc7506460c63e0fcdf42cf20c08a include/crypto/sha.h
|
|
||||||
7676b02824b2d68df6bddeb251e9b8a8fa2e35a95dad9a7ebeca53f9ab8d2dad include/crypto/sparse_array.h
|
|
||||||
7ad02c7de77304c3b298deeb038ab2550cf8b2bce03021994477c6c43dbcf86e include/crypto/types.h
|
|
||||||
782a83d4e489fd865e2768a20bfa31e78c2071fd0ceeb9eb077276ae2bcc6590 include/internal/bio.h
|
|
||||||
8e984890c7c62cdd6356963f034831831f7167c65096cb4d23bc765d84d2c598 include/internal/constant_time.h
|
|
||||||
c5bb97f654984130c8b44c09a52395bce0b22985d5dbc9c4d9377d86283f11f8 include/internal/core.h
|
|
||||||
7b5b7c98d783cc5ae769f59c1973f0f46117116abf766e72b6837228412bb030 include/internal/cryptlib.h
|
|
||||||
9571cfd3d5666749084b354a6d65adee443deeb5713a58c098c7b03bc69dbc63 include/internal/deprecated.h
|
|
||||||
3325b895d15c0a6341f456a8d866a0f83e80fc8a31a01c34fcfd717715b33075 include/internal/der.h
|
|
||||||
fd1722d6b79520ee4ac477280d5131eb1b744c3b422fd15f5e737ef966a97c3b include/internal/dso.h
|
|
||||||
f144daebef828a5bd4416466257a50f06b894e0ce0adf1601aa381f34f25a9e7 include/internal/dsoerr.h
|
|
||||||
01f42777507eda755d4c2638c8a94eb5fa1789263d81bdbf20f174641ddc4303 include/internal/e_os.h
|
|
||||||
70d3e0d5a1bd8db58dcc57bea4d1c3ed816c735fe0e6b2f4b07073712d2dc5ef include/internal/endian.h
|
|
||||||
7854b5c1cd786dc01d052204c5b3ea946dc9929590f47ec4c27697387c5b7ce5 include/internal/ffc.h
|
|
||||||
55c4102496ed5ab16de11afe38c328a1396c3b6e2c7e44add4a38855103c19da include/internal/namemap.h
|
|
||||||
b02701592960eb4608bb83b297eed90184004828c7fc03ea81568062f347623d include/internal/nelem.h
|
|
||||||
ae41a2fb41bf592bbb47e4855cf4efd9ef85fc11f910a7e195ceef78fb4321dc include/internal/numbers.h
|
|
||||||
b89cca3b727d4526b459246de11e768a20333555bf3a9ed9a9b8beb2b565dc7f include/internal/packet.h
|
|
||||||
dd7ddecf30bef3002313e6b776ce34d660931e783b2f6edacf64c7c6e729e688 include/internal/param_build_set.h
|
|
||||||
d4ac19b28ea61f03383364cfad1e941cac44fc36787d80882c5b76ecc9d34e29 include/internal/property.h
|
|
||||||
727326afb3d33fdffdf26471e313f27892708318c0934089369e4b28267e2635 include/internal/propertyerr.h
|
|
||||||
9a73c9ac02eb93a8399381862397bc27fbf8abb7523b07e9f1da9f2e66a913ae include/internal/provider.h
|
|
||||||
34432d71c49dc8ee9926218ba78bdcd03c46cee4e966ee20d100e4519d85b064 include/internal/refcount.h
|
|
||||||
11ee9893f7774c83fcfdee6e0ca593af3d28b779107883553facdbfdae3a68f5 include/internal/sha3.h
|
|
||||||
494ab5c802716bf38032986674fb094dde927a21752fe395d82e6044d81801d1 include/internal/sizes.h
|
|
||||||
24f41a1985fa305833c3f58030c494d2563d15fc922cdf3eeb6a7ea8c135a880 include/internal/symhacks.h
|
|
||||||
640cc6a2aae208073a7f495c08b4c5006a69e8ac1c2d9aaaafd56b0e74d5f859 include/internal/thread_once.h
|
|
||||||
415b725d7f949a6191ab7bb30b48931bafc01c7aa93607e529fabbc853a4ddc5 include/internal/tlsgroups.h
|
|
||||||
7c8d8dfb769cd88c23033e86a2b2cf945391d33c6df1dce86c8d2fc5112636e2 include/internal/tsan_assist.h
|
|
||||||
2b38fb6e65d549aca3b2c76907daf67124f395251c0261dec26faa54da8d6d73 include/openssl/aes.h
|
|
||||||
3157a0e4fba3df5db17e7843ef614d46dd4b6bcdebcb2c3667b777f20a092f2c include/openssl/asn1.h.in
|
|
||||||
d4733dcd490b3a2554eaf859d1ea964fe76f7d24f78e42be1094bdad6dee7429 include/openssl/asn1err.h
|
|
||||||
1550474ee05423896ec4abfb6346f1bc44c7be22329efac9ea25de10e81d549c include/openssl/asn1t.h.in
|
|
||||||
dbd1501acb0804eec0f2aa7bbac4dbc483cf2b4691c6eb1436461b5ed4685b42 include/openssl/bio.h.in
|
|
||||||
0a26138aaded05cafe2326e11fdc19b28408e054cfe3dda40d45ef95ce8136b0 include/openssl/bioerr.h
|
|
||||||
82171a089d3dc93249ea59ae4900d78197eef1040cd658117be67f3b0b318d03 include/openssl/bn.h
|
|
||||||
9ad8b04764797f5138f01f549ba18b44cf698ffc7fe795fef42c1822d84a6ff4 include/openssl/bnerr.h
|
|
||||||
93954e6c450716e158948d67f64736a451ea9473d02f3a908f3bc8a96cf049a5 include/openssl/buffer.h
|
|
||||||
9d48e6cab2ee98ae94d7113e4c65f000d97e125fdb3445642865ace3f34d06ac include/openssl/buffererr.h
|
|
||||||
8e772c24b051e59d2f65339f54584e3e44165a3eaf997d497faea764990130f5 include/openssl/cmac.h
|
|
||||||
1342636127f3d365ac538115e706ea1aea43ab8fa79e86756e818b30a72789c7 include/openssl/conf.h.in
|
|
||||||
bb45de4eafdd89c14096e9af9b0aee12b09adcee43b9313a3a373294dec99142 include/openssl/conferr.h
|
|
||||||
02a1baff7b71a298419c6c5dcb43eaa9cc13e9beeb88c03fb14854b4e84e8862 include/openssl/configuration.h.in
|
|
||||||
6b3810dac6c9d6f5ee36a10ad6d895a5e4553afdfb9641ce9b7dc5db7eef30b7 include/openssl/conftypes.h
|
|
||||||
df5e60af861665675e4a00d40d15e36884f940e3379c7b45c9f717eaf1942697 include/openssl/core.h
|
|
||||||
c5e821b6e8191fa6a8377df741f746dbdad84803a111e3675e945662fe3d5cd5 include/openssl/core_dispatch.h
|
|
||||||
206559e1af84fd1ff4144cf63133559ee814ad6684656a5d69346f395eddc995 include/openssl/core_names.h
|
|
||||||
80e6806ba08aaafb45fefc6fec015f93bf3b717ff61f83f33dfd54f5ff3bd00e include/openssl/crypto.h.in
|
|
||||||
2f9570c2514b4d1b2a86fbdf30ced879e5c52e62f1d3691cb3da37ce4f6a98dd include/openssl/cryptoerr.h
|
|
||||||
bbc82260cbcadd406091f39b9e3b5ea63146d9a4822623ead16fa12c43ab9fc6 include/openssl/cryptoerr_legacy.h
|
|
||||||
fa3e6b6c2e6222424b9cd7005e3c5499a2334c831cd5d6a29256ce945be8cb1d include/openssl/des.h
|
|
||||||
0837b1ec7074b37d2e1d5ac46d6003c3fc4f1ff10f2e44c64b5709b0bacec4e8 include/openssl/dh.h
|
|
||||||
ab7ba5d7eb18d2ea8abc6862ae2ceaa1fa116a702c2bff617c5ae1651d97b6bc include/openssl/dherr.h
|
|
||||||
3cfb7211419c5dcc98b9a20713e2245befa0182a10615edb89a5ce0a0725a787 include/openssl/dsa.h
|
|
||||||
276d1f6e111ba933bc708e6a0670047cbe0d0b67aabe31807abbbc231de4d8cf include/openssl/dsaerr.h
|
|
||||||
46921241755eec0c0fe1a0a5b32c51ac7a3ecd33b9aa05a7489ad4f67d5454be include/openssl/e_os2.h
|
|
||||||
bc9ec2be442a4f49980ba2c63c8f0da701de1f6e23d7db35d781658f833dd7b9 include/openssl/ebcdic.h
|
|
||||||
b6a11924ed95072f4af0a895ee6b93d17aa06104619fb79c9cd0a7bfd5c9164c include/openssl/ec.h
|
|
||||||
7aa8c5bee779af59d4733f6a50f7f6be39f1eb43409e5b3357440f9a7d0ca115 include/openssl/ecerr.h
|
|
||||||
61c76ee3f12ed0e42503a56421ca00f1cb9a0f4caa5f9c4421c374bcd45917d7 include/openssl/encoder.h
|
|
||||||
69dd983f45b8ccd551f084796519446552963a18c52b70470d978b597c81b2dc include/openssl/encodererr.h
|
|
||||||
c6ee8f17d7252bdd0807a124dc6d50a95c32c04e17688b7c2e061998570b7028 include/openssl/err.h.in
|
|
||||||
87451ed43c9cacf86e76bc974e0832cc9600001cef7d4b8a6acd6ddc6ab3d565 include/openssl/evp.h
|
|
||||||
5bd1b5dcd14067a1fe490d49df911002793c0b4f0bd4492cd8f71cfed7bf9f2a include/openssl/evperr.h
|
|
||||||
3085bc5a77ea3776619bf9c748632a3a23f1d8dcad5239ba0f48939f375fb0e8 include/openssl/fips_names.h
|
|
||||||
b1d41beba560a41383f899a361b786e04f889106fb5960ec831b0af7996c9783 include/openssl/fipskey.h.in
|
|
||||||
47a088c98ad536ea99f2c6a9333e372507cb61b9bdffb930c586ed52f8f261eb include/openssl/hmac.h
|
|
||||||
faab8accc9520269dd874126ae164a43526d5784e6280521c7ab3772c02b0a0c include/openssl/kdf.h
|
|
||||||
2dc06275ed23fbea883b1126e69c5344ef64fbc81036478fba0c3c9f2d20839f include/openssl/lhash.h.in
|
|
||||||
a07beaeeffecf72afa66a5a01e01c0bbd75a926987e146f5fd92d1fd012e8fbd include/openssl/macros.h
|
|
||||||
9184207c562fd1fa7bd3a4f1fadcb984130561279818f0cdfcf3e9c55be8a7d1 include/openssl/modes.h
|
|
||||||
7c71200e35f4cc1b4011a4bc14e521e4dc037b9b2d640a74bc30ef334b813de3 include/openssl/obj_mac.h
|
|
||||||
157797b450215f973eb10be96a04e58048ab9c131ad29427e80d0e37e230ed98 include/openssl/objects.h
|
|
||||||
d25537af264684dff033dd8ae62b0348f868fcfec4aa51fa8f07bcfa4bd807ad include/openssl/objectserr.h
|
|
||||||
fe6acd42c3e90db31aaafc2236a7d30ebfa53c4c07ea4d8265064c7fcb951970 include/openssl/opensslconf.h
|
|
||||||
1bf52d136e94f727a96651c1f48ad040482f35dae152519ccd585efd410b92f0 include/openssl/opensslv.h.in
|
|
||||||
767d9d7d5051c937a3ce8a268c702902fda93eeaa210a94dfde1f45c23277d20 include/openssl/param_build.h
|
|
||||||
30085f4d1b4934bb25ffe7aa9a30859966318a1b4d4dcea937c426e90e6e1984 include/openssl/params.h
|
|
||||||
097615b849375e2903967521f76c570512e5be47b8159fdbcd31e433f8a4cca7 include/openssl/prov_ssl.h
|
|
||||||
033c0dd117bbd44af2af9ab2eddb16552bd46ce1ce7435736a187ef82357ee92 include/openssl/proverr.h
|
|
||||||
b97e8ad49b38683817387596aefec0abd5f4d572643beef48be4f7acba26768d include/openssl/provider.h
|
|
||||||
e512ab2e492d968a9bf8b2b048f79ac5dfe11bddf3c00f2eec6e9c6ecc57d330 include/openssl/rand.h
|
|
||||||
5be9d723cf368b48ab35bda5db1a3e83bda6e9e38218dd0b020be1a5427e7488 include/openssl/randerr.h
|
|
||||||
140340d4735a8bac1be0a07f5446ce316619ebacde0f8a8a942ab03ddc4f3da3 include/openssl/rsa.h
|
|
||||||
2f339ba2f22b8faa406692289a6e51fdbbb04b03f85cf3ca849835e58211ad23 include/openssl/rsaerr.h
|
|
||||||
6586f2187991731835353de0ffad0b6b57609b495e53d0f32644491ece629eb2 include/openssl/safestack.h.in
|
|
||||||
676015d7541e7929c8ecbea648665f869d7edf50f9e7292a401b18c63a7ffe05 include/openssl/self_test.h
|
|
||||||
2964274ab32b1ba8578a06b06663db2eda4317ae806369271d889176bb5a7d04 include/openssl/sha.h
|
|
||||||
c169a015d7be52b7b99dd41c418a48d97e52ad21687c39c512a83a7c3f3ddb70 include/openssl/stack.h
|
|
||||||
22d7584ad609e30e818b54dca1dfae8dea38913fffedd25cd540c550372fb9a6 include/openssl/symhacks.h
|
|
||||||
c2a80f226bf916c1fd9067f2d9f37d78a48a9377d14bb554ef013b6ee3ca4a24 include/openssl/trace.h
|
|
||||||
a22bb862d4e1e7bb41b4199f81fc6737dc0a277534b17f9e22b102ea297532c1 include/openssl/types.h
|
|
||||||
c0a9551efccf43f3dd748d4fd8ec897ddaabbc629c00ec1ad76ce983e1195a13 providers/common/bio_prov.c
|
|
||||||
e086f0f9c4a22bdada5e2f7ba34124d8cdc52d12d2f156e49ea7a5cf1ec85dac providers/common/capabilities.c
|
|
||||||
f94b7435d4ec888ec30df1c611afa8b9eedbb59e905a2c7cb17cfc8c4b9b85b8 providers/common/der/der_digests_gen.c.in
|
|
||||||
424d7b2ece984a0904b80c73e541400c6e2d50a285c397dd323b440a4f2a8d8e providers/common/der/der_dsa_gen.c.in
|
|
||||||
27ff361a5fbfc97cd41690ab26639708961d0507b60912f55f5919649842c6ae providers/common/der/der_dsa_key.c
|
|
||||||
2529d253b3e45c33249461fdedb2c32b3c16a7a305fe4920f2a79e7b3f16ed3f providers/common/der/der_dsa_sig.c
|
|
||||||
a81d36446eb8afa5c2318e24b86b52647059b4721ee52309b741e4ee78af29dd providers/common/der/der_ec_gen.c.in
|
|
||||||
b8f2f94daeaf20c636c90e386284c246cfded0c8275411fa02fe68b534520b95 providers/common/der/der_ec_key.c
|
|
||||||
9104cd39dddd6e1a6e8f267656482131f4d0765e96fdced1f7344817a1c8ed7e providers/common/der/der_ec_sig.c
|
|
||||||
03a5620654438c58a8f971398e68922a3f33a519e2c92edb141d13ef4cbc4651 providers/common/der/der_ecx_gen.c.in
|
|
||||||
f3b089fd3dcccc8e3ebfbbdbf87c47d58330f82bd0e2a1223da74977930cccf1 providers/common/der/der_ecx_key.c
|
|
||||||
5b3b0ae8da0fad1f7ba8b5fba2206210884728bf69a8aa00644036eb51953467 providers/common/der/der_rsa_gen.c.in
|
|
||||||
029aec80a45b477f7c8bd8d24d48e36de92f8056b421e9f128c336dc246dbc4e providers/common/der/der_rsa_key.c
|
|
||||||
7e8d579986f53eaf1875d677e5cf4adfd4ccf79db0275368f6cac580ab6007ca providers/common/der/der_rsa_sig.c
|
|
||||||
0b18bc007f296e16f6210956f5b6ab612b77d8a95170f12ae32764125901db6d providers/common/der/der_wrap_gen.c.in
|
|
||||||
d447cd774869da68a2cc0bbb19c547ee6ed4858c7aee1f3d5bba7796f97823a9 providers/common/digest_to_nid.c
|
|
||||||
440c8ce0a4ca9f63157202bbfa26e12fec25847215fbae3416274124604ada6e providers/common/include/prov/bio.h
|
|
||||||
18ce379903b078446945da9116026da8639b4b0d81d357f86f9674a2a5cb94ef providers/common/include/prov/der_digests.h.in
|
|
||||||
c0a020765feb7ededc7e6f20b2b140dca09f347cc72404a5c7971df82b2f9ad0 providers/common/include/prov/der_dsa.h.in
|
|
||||||
6024645ac9e165685b0a44a20feb342355eb06c07b7c7954508a125348570aea providers/common/include/prov/der_ec.h.in
|
|
||||||
5b6b7d8d12011c48195b7db8f65bc4bc4a48fb753763a3ce5006dc227b5139d7 providers/common/include/prov/der_ecx.h.in
|
|
||||||
ce605f32413b09d33ce5795de9498a08183895c3347f33344f9ae5d31c29ccac providers/common/include/prov/der_rsa.h.in
|
|
||||||
6c1fa3f229c6f049c3ac152c4c265f3eb056d94221b82df95a15400649690e93 providers/common/include/prov/der_wrap.h.in
|
|
||||||
237c3e6f6c23f64414f3e93c08c0bcbfe8ba859efb930df836958ba6be682518 providers/common/include/prov/fipscommon.h
|
|
||||||
76087f04f4de6414c240f88807659fb2a04af914108f0c5f2515a4cb5482f655 providers/common/include/prov/proverr.h
|
|
||||||
83a57505d88a6a9cc4f7781c9f7f4af07668e7923502dfd6c5960bb492c1d24e providers/common/include/prov/provider_ctx.h
|
|
||||||
f533a548eee6ec1863ca4afc4eb27766596fdf74c5eaed81817a92d26bbf26f0 providers/common/include/prov/provider_util.h
|
|
||||||
e1ef8b2be828a54312d6561b37751a5b6e9d5ebdb6c3e63589728c3d8adca7dc providers/common/include/prov/providercommon.h
|
|
||||||
c2b4301a9f835c0b3776ad3afba7121d00cd7ae6387fe11c96269a37da08027c providers/common/include/prov/securitycheck.h
|
|
||||||
737cc1228106e555e9bab24e3c2438982e04e05b0d5b9ee6995d71df16c49143 providers/common/provider_ctx.c
|
|
||||||
34d0b6d119167d18770ac47e6cee0ad169ec9318e9a33747341a1a75beb20175 providers/common/provider_err.c
|
|
||||||
18fe559e6634615caaee95c70c6fdcbc0327df8f787290d1a2272904f41bd8ab providers/common/provider_seeding.c
|
|
||||||
8008cc352afcc74177ae3c61dd997097395bddcec4461871c0f52ffed6b7e50c providers/common/provider_util.c
|
|
||||||
5b94312727ca33e4f5c038f4caaae8417bf584cfde22df83d91f3c55c30c81ee providers/common/securitycheck.c
|
|
||||||
bc4370324c4c8791ea6de8641d255073c6745ee984e18912d535e155d9815244 providers/common/securitycheck_fips.c
|
|
||||||
abd5997bc33b681a4ab275978b92aebca0806a4a3f0c2f41dacf11b3b6f4e101 providers/fips/fips_entry.c
|
|
||||||
3797ab5b3ef46c4ce22b6c842ef9b54f3f37ec86f52af3ba541fc6b420cf0009 providers/fips/fipsprov.c
|
|
||||||
029fad3c27617c725e516621c2f6c3a0e1dca0fa22f4e89a1a6b9a977c8d935d providers/fips/self_test.c
|
|
||||||
f822a03138e8b83ccaa910b89d72f31691da6778bf6638181f993ec7ae1167e3 providers/fips/self_test.h
|
|
||||||
5f99d767ecb87f536d031afb28cd26198dd479eca285591d7af9a78ce642d14b providers/fips/self_test_data.inc
|
|
||||||
47b5e2649e7b37178c2c6236c8503bf87fabfe2b7cc5ecee69a5ed4780decb92 providers/fips/self_test_kats.c
|
|
||||||
99baeec10374301e90352ab637056104a8ea28a6880804f44c640d0c9ee16eba providers/implementations/asymciphers/rsa_enc.c
|
|
||||||
4db1826ecce8b60cb641bcd7a61430ec8cef73d2fe3cbc06aa33526afe1c954a providers/implementations/ciphers/cipher_aes.c
|
|
||||||
6ba7d817081cf0d87ba7bfb38cd9d70e41505480bb8bc796ef896f68d4514ea6 providers/implementations/ciphers/cipher_aes.h
|
|
||||||
aef500281e7cd5a25a806a9bd45ec00a5b73984673202527dac5896fbcc9fa9c providers/implementations/ciphers/cipher_aes_cbc_hmac_sha.c
|
|
||||||
7668e5c1cac474ad7b0f28aa78ca885edf44815fe4a606a6cd328b3c02fac25a providers/implementations/ciphers/cipher_aes_cbc_hmac_sha.h
|
|
||||||
26e0f28523b416ba4067e471061f5a11fd76f5dc8bfe57ce37a137cf5667630b providers/implementations/ciphers/cipher_aes_cbc_hmac_sha1_hw.c
|
|
||||||
6d2ab2e059ef38fad342d4c65eebd533c08a2092bb174ff3566c6604e175c5a4 providers/implementations/ciphers/cipher_aes_cbc_hmac_sha256_hw.c
|
|
||||||
f37c3cf9e2e6fcfcbed941f3670b790fe09990349db72eb065bef51705d46e96 providers/implementations/ciphers/cipher_aes_ccm.c
|
|
||||||
00f36bf48e522dbb5ec71df0ec13e387955fa3672e6ff90e8a412ae95c4a642f providers/implementations/ciphers/cipher_aes_ccm.h
|
|
||||||
b18ca62d4962990bd29bc9531493d61bcb74ba6d8d3ae6c3d6c7b39ba5189b2b providers/implementations/ciphers/cipher_aes_ccm_hw.c
|
|
||||||
302b3819ff9fdfed750185421616b248b0e1233d75b45a065490fe4762b42f55 providers/implementations/ciphers/cipher_aes_ccm_hw_aesni.inc
|
|
||||||
a8eaca99a71521ff8ac4ffcf08315e59220f7e0b7f505ecddad04fadd021ec14 providers/implementations/ciphers/cipher_aes_cts.inc
|
|
||||||
7e886ecc088b5903aa082eac72a4c46f9064392bdf5723a592368ecebfeb71c0 providers/implementations/ciphers/cipher_aes_gcm.c
|
|
||||||
79f5a732820d2512a7f4fc2a99ece7e6e2523a51e62561eb67a4b70d5538b0c4 providers/implementations/ciphers/cipher_aes_gcm.h
|
|
||||||
559e65d698d0d854022f69644422b66677ee980ecddb91c8ca5e0c0efd2083b7 providers/implementations/ciphers/cipher_aes_gcm_hw.c
|
|
||||||
be18c20e0197f25fe7b9e0268657a2271a69d216b89cb100f082fa5fcaad1e07 providers/implementations/ciphers/cipher_aes_gcm_hw_aesni.inc
|
|
||||||
60c4f604cf9b5457be48f31cc24ca21729660381081b2dbf99f362a013a09684 providers/implementations/ciphers/cipher_aes_gcm_hw_vaes_avx512.inc
|
|
||||||
73e27d146a51c59abb0999889de5054dcec7d3ad9b47be70c9ef03f50ef527a6 providers/implementations/ciphers/cipher_aes_hw.c
|
|
||||||
89de794c090192459d99d95bc4a422e7782e62192cd0fdb3bdef4128cfedee68 providers/implementations/ciphers/cipher_aes_hw_aesni.inc
|
|
||||||
fac3a1878dc9c0c363d0ecdd9f74926157df54ca4f40adf8c479927395082008 providers/implementations/ciphers/cipher_aes_ocb.c
|
|
||||||
88138a1aff9705e608c0557653be92eb4de65b152555a2b79ec8b2a8fae73e8f providers/implementations/ciphers/cipher_aes_ocb.h
|
|
||||||
06a116e0d790b6618c1403efb0f08af13d8f62e7ffd2be777251a49079d4a610 providers/implementations/ciphers/cipher_aes_ocb_hw.c
|
|
||||||
6a8782c728575d69c86b735c9f47acda5c0daa04e17f1e0faef2c963f23fab20 providers/implementations/ciphers/cipher_aes_wrp.c
|
|
||||||
527ff9277b92606517ee7af13225a9d5fcffbbc36eb18bce39f59d594cbe4931 providers/implementations/ciphers/cipher_aes_xts.c
|
|
||||||
c4a2499b214d7cf786dafaaee5c8c6963b3d5d1c27c144eec4b460f839074a3b providers/implementations/ciphers/cipher_aes_xts.h
|
|
||||||
281157d1da4d7285d878978e6d42d0d33b3a6bc16e3bc5b6879e39093a7d70da providers/implementations/ciphers/cipher_aes_xts_fips.c
|
|
||||||
c05b9144577565675244ba2e795356797dec38fd480150131985e5e6f4d42e42 providers/implementations/ciphers/cipher_aes_xts_hw.c
|
|
||||||
46ba8271917b53fd8fdf77aee19cc326a219c950b94e043d6d118dcac25ad7ad providers/implementations/ciphers/cipher_cts.c
|
|
||||||
74640ce402acc704af72e055fb7f27e6aa8efd417babc56f710478e571d8631c providers/implementations/ciphers/cipher_cts.h
|
|
||||||
fcc3bb0637864252402aaa9d543209909df9a39611127f777b168bc888498dc0 providers/implementations/ciphers/cipher_tdes.c
|
|
||||||
77709f7fc3f7c08986cd4f0ebf2ef6e44bacb975c1483ef444b3cf5e5071f9d6 providers/implementations/ciphers/cipher_tdes.h
|
|
||||||
f6b81faf6abf3baa926be7c054cda1ff2be109b0a2143b34b2f2d266b6cb2c52 providers/implementations/ciphers/cipher_tdes_common.c
|
|
||||||
50645122f08ef4891cd96cace833bd550be7f5278ab785515fd61fe8993c8c25 providers/implementations/ciphers/cipher_tdes_hw.c
|
|
||||||
1f44963b1ac450cb77d75df9fbf956b04742e38d236d316c7eb8021bdf0573a4 providers/implementations/ciphers/ciphercommon.c
|
|
||||||
dd72ea861edf70b94197821ceb00e07165d550934a2e851d62afa5034b79f468 providers/implementations/ciphers/ciphercommon_block.c
|
|
||||||
8af515e63a0c16ff35dcedcc43c7b4735a10943f1e937eeeb73eb1af3dc92782 providers/implementations/ciphers/ciphercommon_ccm.c
|
|
||||||
8b6828f188c2590c7d9c6cac13fa0eb6d38a522b0f2859e7c8a766580fa9b66e providers/implementations/ciphers/ciphercommon_ccm_hw.c
|
|
||||||
142785a128a0d694e2457e7d79da545791b73ae388dcf700b538763099f91f65 providers/implementations/ciphers/ciphercommon_gcm.c
|
|
||||||
bb67eaa7a98494ca938726f9218213870fc97dd87b56bda950626cc794baf20b providers/implementations/ciphers/ciphercommon_gcm_hw.c
|
|
||||||
23fd89e3239e596c325a8c5d23eb1fe157a8d23aa4d90ed2c574bf06dfabd693 providers/implementations/ciphers/ciphercommon_hw.c
|
|
||||||
c4b1cb143de15acc396ce2e03fdd165defd25ebc831de9cdfacf408ea883c666 providers/implementations/ciphers/ciphercommon_local.h
|
|
||||||
39b47b6ef9d71852964c26e07ef0e9b23f04c7493b1b16ba7c3dba7074b6b70d providers/implementations/digests/digestcommon.c
|
|
||||||
5f41dd1bf77bd08d287a875f9d6e5a423bf286524694ae7ee133cdd03ee763c0 providers/implementations/digests/sha2_prov.c
|
|
||||||
d06fd84c0771176e847ad5ea546a1d77f7d9575cd8ce53c9913c7b422dab1b88 providers/implementations/digests/sha3_prov.c
|
|
||||||
966496fb90dc7506d518c9e5198e0eb89cdd8fd6f6dd27ef8707d1cd405e3f8c providers/implementations/exchange/dh_exch.c
|
|
||||||
f8692118f4b6c89258c62864b273ebdfce302662dfe4b7647701a4cd7c5419b5 providers/implementations/exchange/ecdh_exch.c
|
|
||||||
9bf87b8429398a6465c7e9f749a33b84974303a458736b56f3359b30726d3969 providers/implementations/exchange/ecx_exch.c
|
|
||||||
4692ea3852bf5763db576359bd793fc1ec3bcd0ca42fc906991d7ec4cced7b2a providers/implementations/exchange/kdf_exch.c
|
|
||||||
996f1397f61b9eab1e31b5d06bccd9ac958dbd5982fd41fdb263ee889b84275c providers/implementations/include/prov/ciphercommon.h
|
|
||||||
a9f5de1623221f327245957ec1dfd66a1914bff25adf4bcb81213c7955d19382 providers/implementations/include/prov/ciphercommon_aead.h
|
|
||||||
dd07797d61988fd4124cfb920616df672938da80649fac5977bfd061c981edc5 providers/implementations/include/prov/ciphercommon_ccm.h
|
|
||||||
2c9cccda3dc269c29b104346e19fa7213bb8912a5e2876b70851c614fd9357ce providers/implementations/include/prov/ciphercommon_gcm.h
|
|
||||||
b9a61ce951c1904d8315b1bb26c0ab0aaadb47e71d4ead5df0a891608c728c4b providers/implementations/include/prov/digestcommon.h
|
|
||||||
82087efa8777dc5417d934873ae4ef5feeca73dca12ad937fa4e437b2ea29de2 providers/implementations/include/prov/implementations.h
|
|
||||||
5f09fc71874b00419d71646714f21ebbdcceda277463b6f77d3d3ea6946914e8 providers/implementations/include/prov/kdfexchange.h
|
|
||||||
c95ce5498e724b9b3d58e3c2f4723e7e3e4beb07f9bea9422e43182cbadb43af providers/implementations/include/prov/macsignature.h
|
|
||||||
0eaab474a7e8464cd22adb886295ee5afc46137c687b02af3d2ba5dd69a8da9c providers/implementations/include/prov/names.h
|
|
||||||
b9f8781167f274ccd8b643b3bb6c4e1108fb27b2aae588518261af9415228dae providers/implementations/include/prov/seeding.h
|
|
||||||
bc0a388f4a8c79b77264805a233cd789e09ce6af1d610fb0315bcfc325d5cb77 providers/implementations/kdfs/hkdf.c
|
|
||||||
0e6a6c60b4b47f9566aefda4cd9c14c1f829e7608bffc39d5c44d4cd320d3ea6 providers/implementations/kdfs/kbkdf.c
|
|
||||||
5cb7cf8c6387a73ea779aedd133ed14b7642f02569f414dde5aa973e2a38d5c9 providers/implementations/kdfs/pbkdf2.c
|
|
||||||
c0778565abff112c0c5257329a7750ec4605e62f26cc36851fa1fbee6e03c70c providers/implementations/kdfs/pbkdf2.h
|
|
||||||
abe2b0f3711eaa34846e155cffc9242e4051c45de896f747afd5ac9d87f637dc providers/implementations/kdfs/pbkdf2_fips.c
|
|
||||||
13717d4f921787ab2b994ffb86d56aede9b3109bdf00c2a17baf6f53e11c4434 providers/implementations/kdfs/sshkdf.c
|
|
||||||
6a798e505555baa96ef302dc84f26aeb6920d355b0ad138eb3d17c63e7687234 providers/implementations/kdfs/sskdf.c
|
|
||||||
a66987548504bbe5bb81b80e7c1e190ab68abd852fb04f59ae40fd4e93160841 providers/implementations/kdfs/tls1_prf.c
|
|
||||||
1e5aaa6dc3bb52b0b5a07e662386b71e0e3ee7c83b9f15a4144ab24264c7431c providers/implementations/kdfs/x942kdf.c
|
|
||||||
8e8b9094c757c78638f60d7bde822a035adeecde11f9565cbd24c1322ec7e06b providers/implementations/kem/rsa_kem.c
|
|
||||||
11a0d0fb88ed88e965f10b3a0ef6c880f60341df995128f57ad943053aaf15b2 providers/implementations/keymgmt/dh_kmgmt.c
|
|
||||||
a329f57cb041cd03907e9d996fbc2f378ee116c7f8d7fbf1ea08b7a5df7e0304 providers/implementations/keymgmt/dsa_kmgmt.c
|
|
||||||
9bc88451d3ae110c7a108ee73d3b3b6bda801ec3494d2dfb9c9970b85c2d34fe providers/implementations/keymgmt/ec_kmgmt.c
|
|
||||||
258ae17bb2dd87ed1511a8eb3fe99eed9b77f5c2f757215ff6b3d0e8791fc251 providers/implementations/keymgmt/ec_kmgmt_imexport.inc
|
|
||||||
011c36aad6834729043f23eacab417732541ee23916d9afa5bb9164862be00bb providers/implementations/keymgmt/ecx_kmgmt.c
|
|
||||||
053a2be39a87f50b877ebdbbf799cf5faf8b2de33b04311d819d212ee1ea329b providers/implementations/keymgmt/kdf_legacy_kmgmt.c
|
|
||||||
1646b477fa231dd0f6c22444c99098f9b447cab0d39ff69b811262469d4dbe09 providers/implementations/keymgmt/mac_legacy_kmgmt.c
|
|
||||||
19f22fc70a6321441e56d5bd4aab3d01d52d17069d4e4b5cefce0f411ecece75 providers/implementations/keymgmt/rsa_kmgmt.c
|
|
||||||
2e40dccbb3681e1a6b355783ffd91c098b4b0734f3b27e2c2f587cccc74fd7b9 providers/implementations/macs/cmac_prov.c
|
|
||||||
e69aa06f8f3c6f5a26702b9f44a844b8589b99dc0ee590953a29e8b9ef10acbe providers/implementations/macs/gmac_prov.c
|
|
||||||
895c8dc7235b9ad5ff893be0293cbc245a5455e8850195ac7d446646e4ea71d0 providers/implementations/macs/hmac_prov.c
|
|
||||||
8640b63fd8325aaf8f7128d6cc448d9af448a65bf51a8978075467d33a67944e providers/implementations/macs/kmac_prov.c
|
|
||||||
3034074f99b02db045f2ccecc8782322e876dad07a3c169bdb24168b6b1f8cbd providers/implementations/rands/crngt.c
|
|
||||||
177183eccdeeef1f6f74af29560bfb499ae71134cadc5bad486dcc1479aaddca providers/implementations/rands/drbg.c
|
|
||||||
7e8fa6333845778474ed1313a66867512512372c9397f699a8f68fa6d5fc05fa providers/implementations/rands/drbg_ctr.c
|
|
||||||
c1ffe5fda9ecd653018cafb9f6d6bc9e3e4d7cbdd5fa53b93fa8e3dafcfd676a providers/implementations/rands/drbg_hash.c
|
|
||||||
9c11ae4bb13672cdb09d3fa1f91436658d0c7a702928faa518c597a36a62594b providers/implementations/rands/drbg_hmac.c
|
|
||||||
60c7b2344481b9120801b51ec66ea396232b0367e882427a0388b2606ce1457e providers/implementations/rands/drbg_local.h
|
|
||||||
a3072e7516b603f3ab9586a5bc4dce18d23b6300108e6e3514a2da09d73b8021 providers/implementations/rands/test_rng.c
|
|
||||||
6bb8ae1a0608746d42c7162a51e8245c5b9868be4c6e51bef30ae39ef06b60f3 providers/implementations/signature/dsa_sig.c
|
|
||||||
a30dc6308de0ca33406e7ce909f3bcf7580fb84d863b0976b275839f866258df providers/implementations/signature/ecdsa_sig.c
|
|
||||||
9a752462904fc50748c15cdab54262b0bf5e2a8220fbd718d93ccb60aa551fee providers/implementations/signature/eddsa_sig.c
|
|
||||||
3bb0f342b4cc1b4594ed0986adc47791c0a7b5c1ae7b1888c1fb5edb268a78d9 providers/implementations/signature/mac_legacy_sig.c
|
|
||||||
eb66f8f2de828f3ab779a734282ed2cc759b7a98c0a3bb42b804de8729fad809 providers/implementations/signature/rsa_sig.c
|
|
||||||
a14e901b02fe095713624db4080b3aa3ca685d43f9ebec03041f992240973346 ssl/record/tls_pad.c
|
|
||||||
3f2e01a98d9e3fda6cc5cb4b44dd43f6cae4ec34994e8f734d11b1e643e58636 ssl/s3_cbc.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
f2854788afabab9a8d6135345f29537660ab5bb4abde4d375f4e67ebdc112211 providers/fips-sources.checksums
|
|
||||||
-1687
File diff suppressed because it is too large
Load Diff
-37
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2022 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* RISC-V 64 ZKND ZKNE support for AES CCM.
|
|
||||||
* This file is included by cipher_aes_ccm_hw.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
static int ccm_rv64i_zknd_zkne_initkey(PROV_CCM_CTX *ctx, const unsigned char *key,
|
|
||||||
size_t keylen)
|
|
||||||
{
|
|
||||||
PROV_AES_CCM_CTX *actx = (PROV_AES_CCM_CTX *)ctx;
|
|
||||||
|
|
||||||
AES_HW_CCM_SET_KEY_FN(rv64i_zkne_set_encrypt_key, rv64i_zkne_encrypt,
|
|
||||||
NULL, NULL);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const PROV_CCM_HW rv64i_zknd_zkne_ccm = {
|
|
||||||
ccm_rv64i_zknd_zkne_initkey,
|
|
||||||
ossl_ccm_generic_setiv,
|
|
||||||
ossl_ccm_generic_setaad,
|
|
||||||
ossl_ccm_generic_auth_encrypt,
|
|
||||||
ossl_ccm_generic_auth_decrypt,
|
|
||||||
ossl_ccm_generic_gettag
|
|
||||||
};
|
|
||||||
|
|
||||||
const PROV_CCM_HW *ossl_prov_aes_hw_ccm(size_t keybits)
|
|
||||||
{
|
|
||||||
return RV64I_ZKND_ZKNE_CAPABLE ? &rv64i_zknd_zkne_ccm : &aes_ccm;
|
|
||||||
}
|
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2022 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* RISC-V 64 ZKND ZKNE support for AES GCM.
|
|
||||||
* This file is included by cipher_aes_gcm_hw.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
static int rv64i_zknd_zkne_gcm_initkey(PROV_GCM_CTX *ctx, const unsigned char *key,
|
|
||||||
size_t keylen)
|
|
||||||
{
|
|
||||||
PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx;
|
|
||||||
AES_KEY *ks = &actx->ks.ks;
|
|
||||||
GCM_HW_SET_KEY_CTR_FN(ks, rv64i_zkne_set_encrypt_key, rv64i_zkne_encrypt,
|
|
||||||
NULL);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const PROV_GCM_HW rv64i_zknd_zkne_gcm = {
|
|
||||||
rv64i_zknd_zkne_gcm_initkey,
|
|
||||||
ossl_gcm_setiv,
|
|
||||||
ossl_gcm_aad_update,
|
|
||||||
generic_aes_gcm_cipher_update,
|
|
||||||
ossl_gcm_cipher_final,
|
|
||||||
ossl_gcm_one_shot
|
|
||||||
};
|
|
||||||
|
|
||||||
const PROV_GCM_HW *ossl_prov_aes_hw_gcm(size_t keybits)
|
|
||||||
{
|
|
||||||
if (RV64I_ZKND_ZKNE_CAPABLE)
|
|
||||||
return &rv64i_zknd_zkne_gcm;
|
|
||||||
else
|
|
||||||
return &aes_gcm;
|
|
||||||
}
|
|
||||||
-59
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2022 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* RISC-V 64 ZKND ZKNE support for AES modes ecb, cbc, ofb, cfb, ctr.
|
|
||||||
* This file is included by cipher_aes_hw.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define cipher_hw_rv64i_zknd_zkne_cbc ossl_cipher_hw_generic_cbc
|
|
||||||
#define cipher_hw_rv64i_zknd_zkne_ecb ossl_cipher_hw_generic_ecb
|
|
||||||
#define cipher_hw_rv64i_zknd_zkne_ofb128 ossl_cipher_hw_generic_ofb128
|
|
||||||
#define cipher_hw_rv64i_zknd_zkne_cfb128 ossl_cipher_hw_generic_cfb128
|
|
||||||
#define cipher_hw_rv64i_zknd_zkne_cfb8 ossl_cipher_hw_generic_cfb8
|
|
||||||
#define cipher_hw_rv64i_zknd_zkne_cfb1 ossl_cipher_hw_generic_cfb1
|
|
||||||
#define cipher_hw_rv64i_zknd_zkne_ctr ossl_cipher_hw_generic_ctr
|
|
||||||
|
|
||||||
static int cipher_hw_rv64i_zknd_zkne_initkey(PROV_CIPHER_CTX *dat,
|
|
||||||
const unsigned char *key, size_t keylen)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
PROV_AES_CTX *adat = (PROV_AES_CTX *)dat;
|
|
||||||
AES_KEY *ks = &adat->ks.ks;
|
|
||||||
|
|
||||||
dat->ks = ks;
|
|
||||||
|
|
||||||
if ((dat->mode == EVP_CIPH_ECB_MODE || dat->mode == EVP_CIPH_CBC_MODE)
|
|
||||||
&& !dat->enc) {
|
|
||||||
ret = rv64i_zknd_set_decrypt_key(key, keylen * 8, ks);
|
|
||||||
dat->block = (block128_f) rv64i_zknd_decrypt;
|
|
||||||
dat->stream.cbc = NULL;
|
|
||||||
} else {
|
|
||||||
ret = rv64i_zkne_set_encrypt_key(key, keylen * 8, ks);
|
|
||||||
dat->block = (block128_f) rv64i_zkne_encrypt;
|
|
||||||
dat->stream.cbc = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret < 0) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_KEY_SETUP_FAILED);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PROV_CIPHER_HW_declare(mode) \
|
|
||||||
static const PROV_CIPHER_HW rv64i_zknd_zkne_##mode = { \
|
|
||||||
cipher_hw_rv64i_zknd_zkne_initkey, \
|
|
||||||
cipher_hw_rv64i_zknd_zkne_##mode, \
|
|
||||||
cipher_hw_aes_copyctx \
|
|
||||||
};
|
|
||||||
#define PROV_CIPHER_HW_select(mode) \
|
|
||||||
if (RV64I_ZKND_ZKNE_CAPABLE) \
|
|
||||||
return &rv64i_zknd_zkne_##mode;
|
|
||||||
-41
@@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021-2022 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Generic support for SM4 CCM.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "cipher_sm4_ccm.h"
|
|
||||||
|
|
||||||
static int ccm_sm4_initkey(PROV_CCM_CTX *ctx,
|
|
||||||
const unsigned char *key, size_t keylen)
|
|
||||||
{
|
|
||||||
PROV_SM4_CCM_CTX *actx = (PROV_SM4_CCM_CTX *)ctx;
|
|
||||||
|
|
||||||
ossl_sm4_set_key(key, &actx->ks.ks);
|
|
||||||
CRYPTO_ccm128_init(&ctx->ccm_ctx, ctx->m, ctx->l, &actx->ks.ks,
|
|
||||||
(block128_f)ossl_sm4_encrypt);
|
|
||||||
ctx->str = NULL;
|
|
||||||
ctx->key_set = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const PROV_CCM_HW ccm_sm4 = {
|
|
||||||
ccm_sm4_initkey,
|
|
||||||
ossl_ccm_generic_setiv,
|
|
||||||
ossl_ccm_generic_setaad,
|
|
||||||
ossl_ccm_generic_auth_encrypt,
|
|
||||||
ossl_ccm_generic_auth_decrypt,
|
|
||||||
ossl_ccm_generic_gettag
|
|
||||||
};
|
|
||||||
|
|
||||||
const PROV_CCM_HW *ossl_prov_sm4_hw_ccm(size_t keybits)
|
|
||||||
{
|
|
||||||
return &ccm_sm4;
|
|
||||||
}
|
|
||||||
-41
@@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2021 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 <openssl/crypto.h>
|
|
||||||
#include "prov/blake2.h"
|
|
||||||
#include "prov/digestcommon.h"
|
|
||||||
#include "prov/implementations.h"
|
|
||||||
|
|
||||||
int ossl_blake2s256_init(void *ctx)
|
|
||||||
{
|
|
||||||
BLAKE2S_PARAM P;
|
|
||||||
|
|
||||||
ossl_blake2s_param_init(&P);
|
|
||||||
return ossl_blake2s_init((BLAKE2S_CTX *)ctx, &P);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_blake2b512_init(void *ctx)
|
|
||||||
{
|
|
||||||
BLAKE2B_PARAM P;
|
|
||||||
|
|
||||||
ossl_blake2b_param_init(&P);
|
|
||||||
return ossl_blake2b_init((BLAKE2B_CTX *)ctx, &P);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ossl_blake2s256_functions */
|
|
||||||
IMPLEMENT_digest_functions(blake2s256, BLAKE2S_CTX,
|
|
||||||
BLAKE2S_BLOCKBYTES, BLAKE2S_DIGEST_LENGTH, 0,
|
|
||||||
ossl_blake2s256_init, ossl_blake2s_update,
|
|
||||||
ossl_blake2s_final)
|
|
||||||
|
|
||||||
/* ossl_blake2b512_functions */
|
|
||||||
IMPLEMENT_digest_functions(blake2b512, BLAKE2B_CTX,
|
|
||||||
BLAKE2B_BLOCKBYTES, BLAKE2B_DIGEST_LENGTH, 0,
|
|
||||||
ossl_blake2b512_init, ossl_blake2b_update,
|
|
||||||
ossl_blake2b_final)
|
|
||||||
-378
@@ -1,378 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2023 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/core_names.h>
|
|
||||||
#include <openssl/crypto.h>
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
#include <openssl/params.h>
|
|
||||||
#include <openssl/err.h>
|
|
||||||
#include <openssl/proverr.h>
|
|
||||||
#include "internal/sha3.h"
|
|
||||||
#include "prov/digestcommon.h"
|
|
||||||
#include "prov/implementations.h"
|
|
||||||
|
|
||||||
#define SHA3_FLAGS PROV_DIGEST_FLAG_ALGID_ABSENT
|
|
||||||
#define SHAKE_FLAGS PROV_DIGEST_FLAG_XOF
|
|
||||||
#define KMAC_FLAGS PROV_DIGEST_FLAG_XOF
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Forward declaration of any unique methods implemented here. This is not strictly
|
|
||||||
* necessary for the compiler, but provides an assurance that the signatures
|
|
||||||
* of the functions in the dispatch table are correct.
|
|
||||||
*/
|
|
||||||
static OSSL_FUNC_digest_init_fn keccak_init;
|
|
||||||
static OSSL_FUNC_digest_init_fn keccak_init_params;
|
|
||||||
static OSSL_FUNC_digest_update_fn keccak_update;
|
|
||||||
static OSSL_FUNC_digest_final_fn keccak_final;
|
|
||||||
static OSSL_FUNC_digest_freectx_fn keccak_freectx;
|
|
||||||
static OSSL_FUNC_digest_dupctx_fn keccak_dupctx;
|
|
||||||
static OSSL_FUNC_digest_set_ctx_params_fn shake_set_ctx_params;
|
|
||||||
static OSSL_FUNC_digest_settable_ctx_params_fn shake_settable_ctx_params;
|
|
||||||
static sha3_absorb_fn generic_sha3_absorb;
|
|
||||||
static sha3_final_fn generic_sha3_final;
|
|
||||||
|
|
||||||
#if defined(OPENSSL_CPUID_OBJ) && defined(__s390__) && defined(KECCAK1600_ASM)
|
|
||||||
/*
|
|
||||||
* IBM S390X support
|
|
||||||
*/
|
|
||||||
# include "s390x_arch.h"
|
|
||||||
# define S390_SHA3 1
|
|
||||||
# define S390_SHA3_CAPABLE(name) \
|
|
||||||
((OPENSSL_s390xcap_P.kimd[0] & S390X_CAPBIT(S390X_##name)) && \
|
|
||||||
(OPENSSL_s390xcap_P.klmd[0] & S390X_CAPBIT(S390X_##name)))
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int keccak_init(void *vctx, ossl_unused const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return 0;
|
|
||||||
/* The newctx() handles most of the ctx fixed setup. */
|
|
||||||
ossl_sha3_reset((KECCAK1600_CTX *)vctx);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int keccak_init_params(void *vctx, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
return keccak_init(vctx, NULL)
|
|
||||||
&& shake_set_ctx_params(vctx, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int keccak_update(void *vctx, const unsigned char *inp, size_t len)
|
|
||||||
{
|
|
||||||
KECCAK1600_CTX *ctx = vctx;
|
|
||||||
const size_t bsz = ctx->block_size;
|
|
||||||
size_t num, rem;
|
|
||||||
|
|
||||||
if (len == 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
/* Is there anything in the buffer already ? */
|
|
||||||
if ((num = ctx->bufsz) != 0) {
|
|
||||||
/* Calculate how much space is left in the buffer */
|
|
||||||
rem = bsz - num;
|
|
||||||
/* If the new input does not fill the buffer then just add it */
|
|
||||||
if (len < rem) {
|
|
||||||
memcpy(ctx->buf + num, inp, len);
|
|
||||||
ctx->bufsz += len;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/* otherwise fill up the buffer and absorb the buffer */
|
|
||||||
memcpy(ctx->buf + num, inp, rem);
|
|
||||||
/* Update the input pointer */
|
|
||||||
inp += rem;
|
|
||||||
len -= rem;
|
|
||||||
ctx->meth.absorb(ctx, ctx->buf, bsz);
|
|
||||||
ctx->bufsz = 0;
|
|
||||||
}
|
|
||||||
/* Absorb the input - rem = leftover part of the input < blocksize) */
|
|
||||||
rem = ctx->meth.absorb(ctx, inp, len);
|
|
||||||
/* Copy the leftover bit of the input into the buffer */
|
|
||||||
if (rem) {
|
|
||||||
memcpy(ctx->buf, inp + len - rem, rem);
|
|
||||||
ctx->bufsz = rem;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int keccak_final(void *vctx, unsigned char *out, size_t *outl,
|
|
||||||
size_t outsz)
|
|
||||||
{
|
|
||||||
int ret = 1;
|
|
||||||
KECCAK1600_CTX *ctx = vctx;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return 0;
|
|
||||||
if (outsz > 0)
|
|
||||||
ret = ctx->meth.final(out, ctx);
|
|
||||||
|
|
||||||
*outl = ctx->md_size;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Generic software version of the absorb() and final().
|
|
||||||
*/
|
|
||||||
static size_t generic_sha3_absorb(void *vctx, const void *inp, size_t len)
|
|
||||||
{
|
|
||||||
KECCAK1600_CTX *ctx = vctx;
|
|
||||||
|
|
||||||
return SHA3_absorb(ctx->A, inp, len, ctx->block_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int generic_sha3_final(unsigned char *md, void *vctx)
|
|
||||||
{
|
|
||||||
return ossl_sha3_final(md, (KECCAK1600_CTX *)vctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static PROV_SHA3_METHOD sha3_generic_md =
|
|
||||||
{
|
|
||||||
generic_sha3_absorb,
|
|
||||||
generic_sha3_final
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(S390_SHA3)
|
|
||||||
|
|
||||||
static sha3_absorb_fn s390x_sha3_absorb;
|
|
||||||
static sha3_final_fn s390x_sha3_final;
|
|
||||||
static sha3_final_fn s390x_shake_final;
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* The platform specific parts of the absorb() and final() for S390X.
|
|
||||||
*/
|
|
||||||
static size_t s390x_sha3_absorb(void *vctx, const void *inp, size_t len)
|
|
||||||
{
|
|
||||||
KECCAK1600_CTX *ctx = vctx;
|
|
||||||
size_t rem = len % ctx->block_size;
|
|
||||||
|
|
||||||
s390x_kimd(inp, len - rem, ctx->pad, ctx->A);
|
|
||||||
return rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int s390x_sha3_final(unsigned char *md, void *vctx)
|
|
||||||
{
|
|
||||||
KECCAK1600_CTX *ctx = vctx;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return 0;
|
|
||||||
s390x_klmd(ctx->buf, ctx->bufsz, NULL, 0, ctx->pad, ctx->A);
|
|
||||||
memcpy(md, ctx->A, ctx->md_size);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int s390x_shake_final(unsigned char *md, void *vctx)
|
|
||||||
{
|
|
||||||
KECCAK1600_CTX *ctx = vctx;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return 0;
|
|
||||||
s390x_klmd(ctx->buf, ctx->bufsz, md, ctx->md_size, ctx->pad, ctx->A);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int s390x_keccakc_final(unsigned char *md, void *vctx, int padding)
|
|
||||||
{
|
|
||||||
KECCAK1600_CTX *ctx = vctx;
|
|
||||||
size_t bsz = ctx->block_size;
|
|
||||||
size_t num = ctx->bufsz;
|
|
||||||
size_t needed = ctx->md_size;
|
|
||||||
static const unsigned char empty[KECCAK1600_WIDTH / 8] = {0};
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return 0;
|
|
||||||
if (ctx->md_size == 0)
|
|
||||||
return 1;
|
|
||||||
memset(ctx->buf + num, 0, bsz - num);
|
|
||||||
ctx->buf[num] = padding;
|
|
||||||
ctx->buf[bsz - 1] |= 0x80;
|
|
||||||
s390x_kimd(ctx->buf, bsz, ctx->pad, ctx->A);
|
|
||||||
while (needed > bsz) {
|
|
||||||
memcpy(md, ctx->A, bsz);
|
|
||||||
needed -= bsz;
|
|
||||||
md += bsz;
|
|
||||||
s390x_kimd(empty, bsz, ctx->pad, ctx->A);
|
|
||||||
}
|
|
||||||
memcpy(md, ctx->A, needed);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int s390x_kmac_final(unsigned char *md, void *vctx)
|
|
||||||
{
|
|
||||||
return s390x_keccakc_final(md, vctx, 0x04);
|
|
||||||
}
|
|
||||||
|
|
||||||
static PROV_SHA3_METHOD sha3_s390x_md =
|
|
||||||
{
|
|
||||||
s390x_sha3_absorb,
|
|
||||||
s390x_sha3_final
|
|
||||||
};
|
|
||||||
|
|
||||||
static PROV_SHA3_METHOD shake_s390x_md =
|
|
||||||
{
|
|
||||||
s390x_sha3_absorb,
|
|
||||||
s390x_shake_final
|
|
||||||
};
|
|
||||||
|
|
||||||
static PROV_SHA3_METHOD kmac_s390x_md =
|
|
||||||
{
|
|
||||||
s390x_sha3_absorb,
|
|
||||||
s390x_kmac_final
|
|
||||||
};
|
|
||||||
|
|
||||||
# define SHA3_SET_MD(uname, typ) \
|
|
||||||
if (S390_SHA3_CAPABLE(uname)) { \
|
|
||||||
ctx->pad = S390X_##uname; \
|
|
||||||
ctx->meth = typ##_s390x_md; \
|
|
||||||
} else { \
|
|
||||||
ctx->meth = sha3_generic_md; \
|
|
||||||
}
|
|
||||||
# define KMAC_SET_MD(bitlen) \
|
|
||||||
if (S390_SHA3_CAPABLE(SHAKE_##bitlen)) { \
|
|
||||||
ctx->pad = S390X_SHAKE_##bitlen; \
|
|
||||||
ctx->meth = kmac_s390x_md; \
|
|
||||||
} else { \
|
|
||||||
ctx->meth = sha3_generic_md; \
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
# define SHA3_SET_MD(uname, typ) ctx->meth = sha3_generic_md;
|
|
||||||
# define KMAC_SET_MD(bitlen) ctx->meth = sha3_generic_md;
|
|
||||||
#endif /* S390_SHA3 */
|
|
||||||
|
|
||||||
#define SHA3_newctx(typ, uname, name, bitlen, pad) \
|
|
||||||
static OSSL_FUNC_digest_newctx_fn name##_newctx; \
|
|
||||||
static void *name##_newctx(void *provctx) \
|
|
||||||
{ \
|
|
||||||
KECCAK1600_CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) \
|
|
||||||
: NULL; \
|
|
||||||
\
|
|
||||||
if (ctx == NULL) \
|
|
||||||
return NULL; \
|
|
||||||
ossl_sha3_init(ctx, pad, bitlen); \
|
|
||||||
SHA3_SET_MD(uname, typ) \
|
|
||||||
return ctx; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define KMAC_newctx(uname, bitlen, pad) \
|
|
||||||
static OSSL_FUNC_digest_newctx_fn uname##_newctx; \
|
|
||||||
static void *uname##_newctx(void *provctx) \
|
|
||||||
{ \
|
|
||||||
KECCAK1600_CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) \
|
|
||||||
: NULL; \
|
|
||||||
\
|
|
||||||
if (ctx == NULL) \
|
|
||||||
return NULL; \
|
|
||||||
ossl_keccak_kmac_init(ctx, pad, bitlen); \
|
|
||||||
KMAC_SET_MD(bitlen) \
|
|
||||||
return ctx; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PROV_FUNC_SHA3_DIGEST_COMMON(name, bitlen, blksize, dgstsize, flags) \
|
|
||||||
PROV_FUNC_DIGEST_GET_PARAM(name, blksize, dgstsize, flags) \
|
|
||||||
const OSSL_DISPATCH ossl_##name##_functions[] = { \
|
|
||||||
{ OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))name##_newctx }, \
|
|
||||||
{ OSSL_FUNC_DIGEST_UPDATE, (void (*)(void))keccak_update }, \
|
|
||||||
{ OSSL_FUNC_DIGEST_FINAL, (void (*)(void))keccak_final }, \
|
|
||||||
{ OSSL_FUNC_DIGEST_FREECTX, (void (*)(void))keccak_freectx }, \
|
|
||||||
{ OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void))keccak_dupctx }, \
|
|
||||||
PROV_DISPATCH_FUNC_DIGEST_GET_PARAMS(name)
|
|
||||||
|
|
||||||
#define PROV_FUNC_SHA3_DIGEST(name, bitlen, blksize, dgstsize, flags) \
|
|
||||||
PROV_FUNC_SHA3_DIGEST_COMMON(name, bitlen, blksize, dgstsize, flags), \
|
|
||||||
{ OSSL_FUNC_DIGEST_INIT, (void (*)(void))keccak_init }, \
|
|
||||||
PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_END
|
|
||||||
|
|
||||||
#define PROV_FUNC_SHAKE_DIGEST(name, bitlen, blksize, dgstsize, flags) \
|
|
||||||
PROV_FUNC_SHA3_DIGEST_COMMON(name, bitlen, blksize, dgstsize, flags), \
|
|
||||||
{ OSSL_FUNC_DIGEST_INIT, (void (*)(void))keccak_init_params }, \
|
|
||||||
{ OSSL_FUNC_DIGEST_SET_CTX_PARAMS, (void (*)(void))shake_set_ctx_params }, \
|
|
||||||
{ OSSL_FUNC_DIGEST_SETTABLE_CTX_PARAMS, \
|
|
||||||
(void (*)(void))shake_settable_ctx_params }, \
|
|
||||||
PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_END
|
|
||||||
|
|
||||||
static void keccak_freectx(void *vctx)
|
|
||||||
{
|
|
||||||
KECCAK1600_CTX *ctx = (KECCAK1600_CTX *)vctx;
|
|
||||||
|
|
||||||
OPENSSL_clear_free(ctx, sizeof(*ctx));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *keccak_dupctx(void *ctx)
|
|
||||||
{
|
|
||||||
KECCAK1600_CTX *in = (KECCAK1600_CTX *)ctx;
|
|
||||||
KECCAK1600_CTX *ret = ossl_prov_is_running() ? OPENSSL_malloc(sizeof(*ret))
|
|
||||||
: NULL;
|
|
||||||
|
|
||||||
if (ret != NULL)
|
|
||||||
*ret = *in;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const OSSL_PARAM known_shake_settable_ctx_params[] = {
|
|
||||||
{OSSL_DIGEST_PARAM_XOFLEN, OSSL_PARAM_UNSIGNED_INTEGER, NULL, 0, 0},
|
|
||||||
OSSL_PARAM_END
|
|
||||||
};
|
|
||||||
static const OSSL_PARAM *shake_settable_ctx_params(ossl_unused void *ctx,
|
|
||||||
ossl_unused void *provctx)
|
|
||||||
{
|
|
||||||
return known_shake_settable_ctx_params;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int shake_set_ctx_params(void *vctx, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
const OSSL_PARAM *p;
|
|
||||||
KECCAK1600_CTX *ctx = (KECCAK1600_CTX *)vctx;
|
|
||||||
|
|
||||||
if (ctx == NULL)
|
|
||||||
return 0;
|
|
||||||
if (params == NULL)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_XOFLEN);
|
|
||||||
if (p != NULL && !OSSL_PARAM_get_size_t(p, &ctx->md_size)) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define IMPLEMENT_SHA3_functions(bitlen) \
|
|
||||||
SHA3_newctx(sha3, SHA3_##bitlen, sha3_##bitlen, bitlen, '\x06') \
|
|
||||||
PROV_FUNC_SHA3_DIGEST(sha3_##bitlen, bitlen, \
|
|
||||||
SHA3_BLOCKSIZE(bitlen), SHA3_MDSIZE(bitlen), \
|
|
||||||
SHA3_FLAGS)
|
|
||||||
|
|
||||||
#define IMPLEMENT_SHAKE_functions(bitlen) \
|
|
||||||
SHA3_newctx(shake, SHAKE_##bitlen, shake_##bitlen, bitlen, '\x1f') \
|
|
||||||
PROV_FUNC_SHAKE_DIGEST(shake_##bitlen, bitlen, \
|
|
||||||
SHA3_BLOCKSIZE(bitlen), SHA3_MDSIZE(bitlen), \
|
|
||||||
SHAKE_FLAGS)
|
|
||||||
#define IMPLEMENT_KMAC_functions(bitlen) \
|
|
||||||
KMAC_newctx(keccak_kmac_##bitlen, bitlen, '\x04') \
|
|
||||||
PROV_FUNC_SHAKE_DIGEST(keccak_kmac_##bitlen, bitlen, \
|
|
||||||
SHA3_BLOCKSIZE(bitlen), KMAC_MDSIZE(bitlen), \
|
|
||||||
KMAC_FLAGS)
|
|
||||||
|
|
||||||
/* ossl_sha3_224_functions */
|
|
||||||
IMPLEMENT_SHA3_functions(224)
|
|
||||||
/* ossl_sha3_256_functions */
|
|
||||||
IMPLEMENT_SHA3_functions(256)
|
|
||||||
/* ossl_sha3_384_functions */
|
|
||||||
IMPLEMENT_SHA3_functions(384)
|
|
||||||
/* ossl_sha3_512_functions */
|
|
||||||
IMPLEMENT_SHA3_functions(512)
|
|
||||||
/* ossl_shake_128_functions */
|
|
||||||
IMPLEMENT_SHAKE_functions(128)
|
|
||||||
/* ossl_shake_256_functions */
|
|
||||||
IMPLEMENT_SHAKE_functions(256)
|
|
||||||
/* ossl_keccak_kmac_128_functions */
|
|
||||||
IMPLEMENT_KMAC_functions(128)
|
|
||||||
/* ossl_keccak_kmac_256_functions */
|
|
||||||
IMPLEMENT_KMAC_functions(256)
|
|
||||||
-6
@@ -1,6 +0,0 @@
|
|||||||
# We make separate GOAL variables for each algorithm, to make it easy to
|
|
||||||
# switch each to the Legacy provider when needed.
|
|
||||||
|
|
||||||
$RSA_KEM_GOAL=../../libdefault.a ../../libfips.a
|
|
||||||
|
|
||||||
SOURCE[$RSA_KEM_GOAL]=rsa_kem.c
|
|
||||||
-578
@@ -1,578 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020-2023 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* We need to use some engine deprecated APIs */
|
|
||||||
#define OPENSSL_SUPPRESS_DEPRECATED
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <openssl/core_dispatch.h>
|
|
||||||
#include <openssl/core_names.h>
|
|
||||||
#include <openssl/params.h>
|
|
||||||
#include <openssl/err.h>
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
#include <openssl/proverr.h>
|
|
||||||
#include <openssl/param_build.h>
|
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
# include <openssl/engine.h>
|
|
||||||
#endif
|
|
||||||
#include "internal/param_build_set.h"
|
|
||||||
#include "prov/implementations.h"
|
|
||||||
#include "prov/providercommon.h"
|
|
||||||
#include "prov/provider_ctx.h"
|
|
||||||
#include "prov/macsignature.h"
|
|
||||||
|
|
||||||
static OSSL_FUNC_keymgmt_new_fn mac_new;
|
|
||||||
static OSSL_FUNC_keymgmt_free_fn mac_free;
|
|
||||||
static OSSL_FUNC_keymgmt_gen_init_fn mac_gen_init;
|
|
||||||
static OSSL_FUNC_keymgmt_gen_fn mac_gen;
|
|
||||||
static OSSL_FUNC_keymgmt_gen_cleanup_fn mac_gen_cleanup;
|
|
||||||
static OSSL_FUNC_keymgmt_gen_set_params_fn mac_gen_set_params;
|
|
||||||
static OSSL_FUNC_keymgmt_gen_settable_params_fn mac_gen_settable_params;
|
|
||||||
static OSSL_FUNC_keymgmt_get_params_fn mac_get_params;
|
|
||||||
static OSSL_FUNC_keymgmt_gettable_params_fn mac_gettable_params;
|
|
||||||
static OSSL_FUNC_keymgmt_set_params_fn mac_set_params;
|
|
||||||
static OSSL_FUNC_keymgmt_settable_params_fn mac_settable_params;
|
|
||||||
static OSSL_FUNC_keymgmt_has_fn mac_has;
|
|
||||||
static OSSL_FUNC_keymgmt_match_fn mac_match;
|
|
||||||
static OSSL_FUNC_keymgmt_import_fn mac_import;
|
|
||||||
static OSSL_FUNC_keymgmt_import_types_fn mac_imexport_types;
|
|
||||||
static OSSL_FUNC_keymgmt_export_fn mac_export;
|
|
||||||
static OSSL_FUNC_keymgmt_export_types_fn mac_imexport_types;
|
|
||||||
|
|
||||||
static OSSL_FUNC_keymgmt_new_fn mac_new_cmac;
|
|
||||||
static OSSL_FUNC_keymgmt_gettable_params_fn cmac_gettable_params;
|
|
||||||
static OSSL_FUNC_keymgmt_import_types_fn cmac_imexport_types;
|
|
||||||
static OSSL_FUNC_keymgmt_export_types_fn cmac_imexport_types;
|
|
||||||
static OSSL_FUNC_keymgmt_gen_init_fn cmac_gen_init;
|
|
||||||
static OSSL_FUNC_keymgmt_gen_set_params_fn cmac_gen_set_params;
|
|
||||||
static OSSL_FUNC_keymgmt_gen_settable_params_fn cmac_gen_settable_params;
|
|
||||||
|
|
||||||
struct mac_gen_ctx {
|
|
||||||
OSSL_LIB_CTX *libctx;
|
|
||||||
int selection;
|
|
||||||
unsigned char *priv_key;
|
|
||||||
size_t priv_key_len;
|
|
||||||
PROV_CIPHER cipher;
|
|
||||||
};
|
|
||||||
|
|
||||||
MAC_KEY *ossl_mac_key_new(OSSL_LIB_CTX *libctx, int cmac)
|
|
||||||
{
|
|
||||||
MAC_KEY *mackey;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
mackey = OPENSSL_zalloc(sizeof(*mackey));
|
|
||||||
if (mackey == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
mackey->lock = CRYPTO_THREAD_lock_new();
|
|
||||||
if (mackey->lock == NULL) {
|
|
||||||
OPENSSL_free(mackey);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
mackey->libctx = libctx;
|
|
||||||
mackey->refcnt = 1;
|
|
||||||
mackey->cmac = cmac;
|
|
||||||
|
|
||||||
return mackey;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ossl_mac_key_free(MAC_KEY *mackey)
|
|
||||||
{
|
|
||||||
int ref = 0;
|
|
||||||
|
|
||||||
if (mackey == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
CRYPTO_DOWN_REF(&mackey->refcnt, &ref, mackey->lock);
|
|
||||||
if (ref > 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
OPENSSL_secure_clear_free(mackey->priv_key, mackey->priv_key_len);
|
|
||||||
OPENSSL_free(mackey->properties);
|
|
||||||
ossl_prov_cipher_reset(&mackey->cipher);
|
|
||||||
CRYPTO_THREAD_lock_free(mackey->lock);
|
|
||||||
OPENSSL_free(mackey);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ossl_mac_key_up_ref(MAC_KEY *mackey)
|
|
||||||
{
|
|
||||||
int ref = 0;
|
|
||||||
|
|
||||||
/* This is effectively doing a new operation on the MAC_KEY and should be
|
|
||||||
* adequately guarded again modules' error states. However, both current
|
|
||||||
* calls here are guarded properly in signature/mac_legacy.c. Thus, it
|
|
||||||
* could be removed here. The concern is that something in the future
|
|
||||||
* might call this function without adequate guards. It's a cheap call,
|
|
||||||
* it seems best to leave it even though it is currently redundant.
|
|
||||||
*/
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
CRYPTO_UP_REF(&mackey->refcnt, &ref, mackey->lock);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *mac_new(void *provctx)
|
|
||||||
{
|
|
||||||
return ossl_mac_key_new(PROV_LIBCTX_OF(provctx), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *mac_new_cmac(void *provctx)
|
|
||||||
{
|
|
||||||
return ossl_mac_key_new(PROV_LIBCTX_OF(provctx), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mac_free(void *mackey)
|
|
||||||
{
|
|
||||||
ossl_mac_key_free(mackey);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int mac_has(const void *keydata, int selection)
|
|
||||||
{
|
|
||||||
const MAC_KEY *key = keydata;
|
|
||||||
int ok = 0;
|
|
||||||
|
|
||||||
if (ossl_prov_is_running() && key != NULL) {
|
|
||||||
/*
|
|
||||||
* MAC keys always have all the parameters they need (i.e. none).
|
|
||||||
* Therefore we always return with 1, if asked about parameters.
|
|
||||||
* Similarly for public keys.
|
|
||||||
*/
|
|
||||||
ok = 1;
|
|
||||||
|
|
||||||
if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
|
|
||||||
ok = key->priv_key != NULL;
|
|
||||||
}
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int mac_match(const void *keydata1, const void *keydata2, int selection)
|
|
||||||
{
|
|
||||||
const MAC_KEY *key1 = keydata1;
|
|
||||||
const MAC_KEY *key2 = keydata2;
|
|
||||||
int ok = 1;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
|
|
||||||
if ((key1->priv_key == NULL && key2->priv_key != NULL)
|
|
||||||
|| (key1->priv_key != NULL && key2->priv_key == NULL)
|
|
||||||
|| key1->priv_key_len != key2->priv_key_len
|
|
||||||
|| (key1->cipher.cipher == NULL && key2->cipher.cipher != NULL)
|
|
||||||
|| (key1->cipher.cipher != NULL && key2->cipher.cipher == NULL))
|
|
||||||
ok = 0;
|
|
||||||
else
|
|
||||||
ok = ok && (key1->priv_key == NULL /* implies key2->privkey == NULL */
|
|
||||||
|| CRYPTO_memcmp(key1->priv_key, key2->priv_key,
|
|
||||||
key1->priv_key_len) == 0);
|
|
||||||
if (key1->cipher.cipher != NULL)
|
|
||||||
ok = ok && EVP_CIPHER_is_a(key1->cipher.cipher,
|
|
||||||
EVP_CIPHER_get0_name(key2->cipher.cipher));
|
|
||||||
}
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int mac_key_fromdata(MAC_KEY *key, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
const OSSL_PARAM *p;
|
|
||||||
|
|
||||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY);
|
|
||||||
if (p != NULL) {
|
|
||||||
if (p->data_type != OSSL_PARAM_OCTET_STRING) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
OPENSSL_secure_clear_free(key->priv_key, key->priv_key_len);
|
|
||||||
/* allocate at least one byte to distinguish empty key from no key set */
|
|
||||||
key->priv_key = OPENSSL_secure_malloc(p->data_size > 0 ? p->data_size : 1);
|
|
||||||
if (key->priv_key == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
memcpy(key->priv_key, p->data, p->data_size);
|
|
||||||
key->priv_key_len = p->data_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PROPERTIES);
|
|
||||||
if (p != NULL) {
|
|
||||||
if (p->data_type != OSSL_PARAM_UTF8_STRING) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
OPENSSL_free(key->properties);
|
|
||||||
key->properties = OPENSSL_strdup(p->data);
|
|
||||||
if (key->properties == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key->cmac && !ossl_prov_cipher_load_from_params(&key->cipher, params,
|
|
||||||
key->libctx)) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key->priv_key != NULL)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int mac_import(void *keydata, int selection, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
MAC_KEY *key = keydata;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running() || key == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return mac_key_fromdata(key, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int key_to_params(MAC_KEY *key, OSSL_PARAM_BLD *tmpl,
|
|
||||||
OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
if (key == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (key->priv_key != NULL
|
|
||||||
&& !ossl_param_build_set_octet_string(tmpl, params,
|
|
||||||
OSSL_PKEY_PARAM_PRIV_KEY,
|
|
||||||
key->priv_key, key->priv_key_len))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (key->cipher.cipher != NULL
|
|
||||||
&& !ossl_param_build_set_utf8_string(tmpl, params,
|
|
||||||
OSSL_PKEY_PARAM_CIPHER,
|
|
||||||
EVP_CIPHER_get0_name(key->cipher.cipher)))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE)
|
|
||||||
if (key->cipher.engine != NULL
|
|
||||||
&& !ossl_param_build_set_utf8_string(tmpl, params,
|
|
||||||
OSSL_PKEY_PARAM_ENGINE,
|
|
||||||
ENGINE_get_id(key->cipher.engine)))
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int mac_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
|
|
||||||
void *cbarg)
|
|
||||||
{
|
|
||||||
MAC_KEY *key = keydata;
|
|
||||||
OSSL_PARAM_BLD *tmpl;
|
|
||||||
OSSL_PARAM *params = NULL;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running() || key == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
tmpl = OSSL_PARAM_BLD_new();
|
|
||||||
if (tmpl == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0
|
|
||||||
&& !key_to_params(key, tmpl, NULL))
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
params = OSSL_PARAM_BLD_to_param(tmpl);
|
|
||||||
if (params == NULL)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
ret = param_cb(params, cbarg);
|
|
||||||
OSSL_PARAM_free(params);
|
|
||||||
err:
|
|
||||||
OSSL_PARAM_BLD_free(tmpl);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const OSSL_PARAM mac_key_types[] = {
|
|
||||||
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
|
|
||||||
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_PROPERTIES, NULL, 0),
|
|
||||||
OSSL_PARAM_END
|
|
||||||
};
|
|
||||||
static const OSSL_PARAM *mac_imexport_types(int selection)
|
|
||||||
{
|
|
||||||
if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
|
|
||||||
return mac_key_types;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const OSSL_PARAM cmac_key_types[] = {
|
|
||||||
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
|
|
||||||
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_CIPHER, NULL, 0),
|
|
||||||
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_ENGINE, NULL, 0),
|
|
||||||
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_PROPERTIES, NULL, 0),
|
|
||||||
OSSL_PARAM_END
|
|
||||||
};
|
|
||||||
static const OSSL_PARAM *cmac_imexport_types(int selection)
|
|
||||||
{
|
|
||||||
if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
|
|
||||||
return cmac_key_types;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int mac_get_params(void *key, OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
return key_to_params(key, NULL, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const OSSL_PARAM *mac_gettable_params(void *provctx)
|
|
||||||
{
|
|
||||||
static const OSSL_PARAM gettable_params[] = {
|
|
||||||
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
|
|
||||||
OSSL_PARAM_END
|
|
||||||
};
|
|
||||||
return gettable_params;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const OSSL_PARAM *cmac_gettable_params(void *provctx)
|
|
||||||
{
|
|
||||||
static const OSSL_PARAM gettable_params[] = {
|
|
||||||
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
|
|
||||||
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_CIPHER, NULL, 0),
|
|
||||||
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_ENGINE, NULL, 0),
|
|
||||||
OSSL_PARAM_END
|
|
||||||
};
|
|
||||||
return gettable_params;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int mac_set_params(void *keydata, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
MAC_KEY *key = keydata;
|
|
||||||
const OSSL_PARAM *p;
|
|
||||||
|
|
||||||
if (key == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY);
|
|
||||||
if (p != NULL)
|
|
||||||
return mac_key_fromdata(key, params);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const OSSL_PARAM *mac_settable_params(void *provctx)
|
|
||||||
{
|
|
||||||
static const OSSL_PARAM settable_params[] = {
|
|
||||||
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
|
|
||||||
OSSL_PARAM_END
|
|
||||||
};
|
|
||||||
return settable_params;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *mac_gen_init_common(void *provctx, int selection)
|
|
||||||
{
|
|
||||||
OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(provctx);
|
|
||||||
struct mac_gen_ctx *gctx = NULL;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if ((gctx = OPENSSL_zalloc(sizeof(*gctx))) != NULL) {
|
|
||||||
gctx->libctx = libctx;
|
|
||||||
gctx->selection = selection;
|
|
||||||
}
|
|
||||||
return gctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *mac_gen_init(void *provctx, int selection,
|
|
||||||
const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
struct mac_gen_ctx *gctx = mac_gen_init_common(provctx, selection);
|
|
||||||
|
|
||||||
if (gctx != NULL && !mac_gen_set_params(gctx, params)) {
|
|
||||||
OPENSSL_free(gctx);
|
|
||||||
gctx = NULL;
|
|
||||||
}
|
|
||||||
return gctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *cmac_gen_init(void *provctx, int selection,
|
|
||||||
const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
struct mac_gen_ctx *gctx = mac_gen_init_common(provctx, selection);
|
|
||||||
|
|
||||||
if (gctx != NULL && !cmac_gen_set_params(gctx, params)) {
|
|
||||||
OPENSSL_free(gctx);
|
|
||||||
gctx = NULL;
|
|
||||||
}
|
|
||||||
return gctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int mac_gen_set_params(void *genctx, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
struct mac_gen_ctx *gctx = genctx;
|
|
||||||
const OSSL_PARAM *p;
|
|
||||||
|
|
||||||
if (gctx == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY);
|
|
||||||
if (p != NULL) {
|
|
||||||
if (p->data_type != OSSL_PARAM_OCTET_STRING) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
gctx->priv_key = OPENSSL_secure_malloc(p->data_size);
|
|
||||||
if (gctx->priv_key == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
memcpy(gctx->priv_key, p->data, p->data_size);
|
|
||||||
gctx->priv_key_len = p->data_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int cmac_gen_set_params(void *genctx, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
struct mac_gen_ctx *gctx = genctx;
|
|
||||||
|
|
||||||
if (!mac_gen_set_params(genctx, params))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!ossl_prov_cipher_load_from_params(&gctx->cipher, params,
|
|
||||||
gctx->libctx)) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const OSSL_PARAM *mac_gen_settable_params(ossl_unused void *genctx,
|
|
||||||
ossl_unused void *provctx)
|
|
||||||
{
|
|
||||||
static OSSL_PARAM settable[] = {
|
|
||||||
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
|
|
||||||
OSSL_PARAM_END
|
|
||||||
};
|
|
||||||
return settable;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const OSSL_PARAM *cmac_gen_settable_params(ossl_unused void *genctx,
|
|
||||||
ossl_unused void *provctx)
|
|
||||||
{
|
|
||||||
static OSSL_PARAM settable[] = {
|
|
||||||
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
|
|
||||||
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_CIPHER, NULL, 0),
|
|
||||||
OSSL_PARAM_END
|
|
||||||
};
|
|
||||||
return settable;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *mac_gen(void *genctx, OSSL_CALLBACK *cb, void *cbarg)
|
|
||||||
{
|
|
||||||
struct mac_gen_ctx *gctx = genctx;
|
|
||||||
MAC_KEY *key;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running() || gctx == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if ((key = ossl_mac_key_new(gctx->libctx, 0)) == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we're doing parameter generation then we just return a blank key */
|
|
||||||
if ((gctx->selection & OSSL_KEYMGMT_SELECT_KEYPAIR) == 0)
|
|
||||||
return key;
|
|
||||||
|
|
||||||
if (gctx->priv_key == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY);
|
|
||||||
ossl_mac_key_free(key);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is horrible but required for backwards compatibility. We don't
|
|
||||||
* actually do real key generation at all. We simply copy the key that was
|
|
||||||
* previously set in the gctx. Hopefully at some point in the future all
|
|
||||||
* of this can be removed and we will only support the EVP_KDF APIs.
|
|
||||||
*/
|
|
||||||
if (!ossl_prov_cipher_copy(&key->cipher, &gctx->cipher)) {
|
|
||||||
ossl_mac_key_free(key);
|
|
||||||
ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
ossl_prov_cipher_reset(&gctx->cipher);
|
|
||||||
key->priv_key = gctx->priv_key;
|
|
||||||
key->priv_key_len = gctx->priv_key_len;
|
|
||||||
gctx->priv_key_len = 0;
|
|
||||||
gctx->priv_key = NULL;
|
|
||||||
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mac_gen_cleanup(void *genctx)
|
|
||||||
{
|
|
||||||
struct mac_gen_ctx *gctx = genctx;
|
|
||||||
|
|
||||||
OPENSSL_secure_clear_free(gctx->priv_key, gctx->priv_key_len);
|
|
||||||
ossl_prov_cipher_reset(&gctx->cipher);
|
|
||||||
OPENSSL_free(gctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
const OSSL_DISPATCH ossl_mac_legacy_keymgmt_functions[] = {
|
|
||||||
{ OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))mac_new },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))mac_free },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*) (void))mac_get_params },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, (void (*) (void))mac_gettable_params },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_SET_PARAMS, (void (*) (void))mac_set_params },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS, (void (*) (void))mac_settable_params },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))mac_has },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_MATCH, (void (*)(void))mac_match },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))mac_import },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))mac_imexport_types },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))mac_export },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))mac_imexport_types },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))mac_gen_init },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, (void (*)(void))mac_gen_set_params },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS,
|
|
||||||
(void (*)(void))mac_gen_settable_params },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))mac_gen },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))mac_gen_cleanup },
|
|
||||||
{ 0, NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
const OSSL_DISPATCH ossl_cmac_legacy_keymgmt_functions[] = {
|
|
||||||
{ OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))mac_new_cmac },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))mac_free },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*) (void))mac_get_params },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, (void (*) (void))cmac_gettable_params },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_SET_PARAMS, (void (*) (void))mac_set_params },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS, (void (*) (void))mac_settable_params },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))mac_has },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_MATCH, (void (*)(void))mac_match },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))mac_import },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))cmac_imexport_types },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))mac_export },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))cmac_imexport_types },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))cmac_gen_init },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, (void (*)(void))cmac_gen_set_params },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS,
|
|
||||||
(void (*)(void))cmac_gen_settable_params },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))mac_gen },
|
|
||||||
{ OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))mac_gen_cleanup },
|
|
||||||
{ 0, NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
-6
@@ -1,6 +0,0 @@
|
|||||||
SUBDIRS=seeding
|
|
||||||
|
|
||||||
$RANDS_GOAL=../../libdefault.a ../../libfips.a
|
|
||||||
|
|
||||||
SOURCE[$RANDS_GOAL]=drbg.c test_rng.c drbg_ctr.c drbg_hash.c drbg_hmac.c crngt.c
|
|
||||||
SOURCE[../../libdefault.a]=seed_src.c
|
|
||||||
-192
@@ -1,192 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved.
|
|
||||||
* Copyright (c) 2019, Oracle and/or its affiliates. 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Implementation of the FIPS 140-2 section 4.9.2 Conditional Tests.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
#include <openssl/core_dispatch.h>
|
|
||||||
#include <openssl/params.h>
|
|
||||||
#include <openssl/self_test.h>
|
|
||||||
#include "prov/providercommon.h"
|
|
||||||
#include "prov/provider_ctx.h"
|
|
||||||
#include "internal/cryptlib.h"
|
|
||||||
#include "crypto/rand_pool.h"
|
|
||||||
#include "drbg_local.h"
|
|
||||||
#include "prov/seeding.h"
|
|
||||||
#include "crypto/context.h"
|
|
||||||
|
|
||||||
typedef struct crng_test_global_st {
|
|
||||||
unsigned char crngt_prev[EVP_MAX_MD_SIZE];
|
|
||||||
EVP_MD *md;
|
|
||||||
int preloaded;
|
|
||||||
CRYPTO_RWLOCK *lock;
|
|
||||||
} CRNG_TEST_GLOBAL;
|
|
||||||
|
|
||||||
static int crngt_get_entropy(PROV_CTX *provctx, const EVP_MD *digest,
|
|
||||||
unsigned char *buf, unsigned char *md,
|
|
||||||
unsigned int *md_size)
|
|
||||||
{
|
|
||||||
int r;
|
|
||||||
size_t n;
|
|
||||||
unsigned char *p;
|
|
||||||
|
|
||||||
n = ossl_prov_get_entropy(provctx, &p, 0, CRNGT_BUFSIZ, CRNGT_BUFSIZ);
|
|
||||||
if (n == CRNGT_BUFSIZ) {
|
|
||||||
r = EVP_Digest(p, CRNGT_BUFSIZ, md, md_size, digest, NULL);
|
|
||||||
if (r != 0)
|
|
||||||
memcpy(buf, p, CRNGT_BUFSIZ);
|
|
||||||
ossl_prov_cleanup_entropy(provctx, p, n);
|
|
||||||
return r != 0;
|
|
||||||
}
|
|
||||||
if (n != 0)
|
|
||||||
ossl_prov_cleanup_entropy(provctx, p, n);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ossl_rand_crng_ctx_free(void *vcrngt_glob)
|
|
||||||
{
|
|
||||||
CRNG_TEST_GLOBAL *crngt_glob = vcrngt_glob;
|
|
||||||
|
|
||||||
CRYPTO_THREAD_lock_free(crngt_glob->lock);
|
|
||||||
EVP_MD_free(crngt_glob->md);
|
|
||||||
OPENSSL_free(crngt_glob);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *ossl_rand_crng_ctx_new(OSSL_LIB_CTX *ctx)
|
|
||||||
{
|
|
||||||
CRNG_TEST_GLOBAL *crngt_glob = OPENSSL_zalloc(sizeof(*crngt_glob));
|
|
||||||
|
|
||||||
if (crngt_glob == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if ((crngt_glob->md = EVP_MD_fetch(ctx, "SHA256", "")) == NULL) {
|
|
||||||
OPENSSL_free(crngt_glob);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((crngt_glob->lock = CRYPTO_THREAD_lock_new()) == NULL) {
|
|
||||||
EVP_MD_free(crngt_glob->md);
|
|
||||||
OPENSSL_free(crngt_glob);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return crngt_glob;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int prov_crngt_compare_previous(const unsigned char *prev,
|
|
||||||
const unsigned char *cur,
|
|
||||||
size_t sz)
|
|
||||||
{
|
|
||||||
const int res = memcmp(prev, cur, sz) != 0;
|
|
||||||
|
|
||||||
if (!res)
|
|
||||||
ossl_set_error_state(OSSL_SELF_TEST_TYPE_CRNG);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t ossl_crngt_get_entropy(PROV_DRBG *drbg,
|
|
||||||
unsigned char **pout,
|
|
||||||
int entropy, size_t min_len, size_t max_len,
|
|
||||||
int prediction_resistance)
|
|
||||||
{
|
|
||||||
unsigned char md[EVP_MAX_MD_SIZE];
|
|
||||||
unsigned char buf[CRNGT_BUFSIZ];
|
|
||||||
unsigned char *ent, *entp, *entbuf;
|
|
||||||
unsigned int sz;
|
|
||||||
size_t bytes_needed;
|
|
||||||
size_t r = 0, s, t;
|
|
||||||
int crng_test_pass = 1;
|
|
||||||
OSSL_LIB_CTX *libctx = ossl_prov_ctx_get0_libctx(drbg->provctx);
|
|
||||||
CRNG_TEST_GLOBAL *crngt_glob
|
|
||||||
= ossl_lib_ctx_get_data(libctx, OSSL_LIB_CTX_RAND_CRNGT_INDEX);
|
|
||||||
OSSL_CALLBACK *stcb = NULL;
|
|
||||||
void *stcbarg = NULL;
|
|
||||||
OSSL_SELF_TEST *st = NULL;
|
|
||||||
|
|
||||||
if (crngt_glob == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!CRYPTO_THREAD_write_lock(crngt_glob->lock))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!crngt_glob->preloaded) {
|
|
||||||
if (!crngt_get_entropy(drbg->provctx, crngt_glob->md, buf,
|
|
||||||
crngt_glob->crngt_prev, NULL)) {
|
|
||||||
OPENSSL_cleanse(buf, sizeof(buf));
|
|
||||||
goto unlock_return;
|
|
||||||
}
|
|
||||||
crngt_glob->preloaded = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Calculate how many bytes of seed material we require, rounded up
|
|
||||||
* to the nearest byte. If the entropy is of less than full quality,
|
|
||||||
* the amount required should be scaled up appropriately here.
|
|
||||||
*/
|
|
||||||
bytes_needed = (entropy + 7) / 8;
|
|
||||||
if (bytes_needed < min_len)
|
|
||||||
bytes_needed = min_len;
|
|
||||||
if (bytes_needed > max_len)
|
|
||||||
goto unlock_return;
|
|
||||||
entp = ent = OPENSSL_secure_malloc(bytes_needed);
|
|
||||||
if (ent == NULL)
|
|
||||||
goto unlock_return;
|
|
||||||
|
|
||||||
OSSL_SELF_TEST_get_callback(libctx, &stcb, &stcbarg);
|
|
||||||
if (stcb != NULL) {
|
|
||||||
st = OSSL_SELF_TEST_new(stcb, stcbarg);
|
|
||||||
if (st == NULL)
|
|
||||||
goto err;
|
|
||||||
OSSL_SELF_TEST_onbegin(st, OSSL_SELF_TEST_TYPE_CRNG,
|
|
||||||
OSSL_SELF_TEST_DESC_RNG);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (t = bytes_needed; t > 0;) {
|
|
||||||
/* Care needs to be taken to avoid overrunning the buffer */
|
|
||||||
s = t >= CRNGT_BUFSIZ ? CRNGT_BUFSIZ : t;
|
|
||||||
entbuf = t >= CRNGT_BUFSIZ ? entp : buf;
|
|
||||||
if (!crngt_get_entropy(drbg->provctx, crngt_glob->md, entbuf, md, &sz))
|
|
||||||
goto err;
|
|
||||||
if (t < CRNGT_BUFSIZ)
|
|
||||||
memcpy(entp, buf, t);
|
|
||||||
/* Force a failure here if the callback returns 1 */
|
|
||||||
if (OSSL_SELF_TEST_oncorrupt_byte(st, md))
|
|
||||||
memcpy(md, crngt_glob->crngt_prev, sz);
|
|
||||||
if (!prov_crngt_compare_previous(crngt_glob->crngt_prev, md, sz)) {
|
|
||||||
crng_test_pass = 0;
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
/* Update for next block */
|
|
||||||
memcpy(crngt_glob->crngt_prev, md, sz);
|
|
||||||
entp += s;
|
|
||||||
t -= s;
|
|
||||||
}
|
|
||||||
r = bytes_needed;
|
|
||||||
*pout = ent;
|
|
||||||
ent = NULL;
|
|
||||||
|
|
||||||
err:
|
|
||||||
OSSL_SELF_TEST_onend(st, crng_test_pass);
|
|
||||||
OSSL_SELF_TEST_free(st);
|
|
||||||
OPENSSL_secure_clear_free(ent, bytes_needed);
|
|
||||||
|
|
||||||
unlock_return:
|
|
||||||
CRYPTO_THREAD_unlock(crngt_glob->lock);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ossl_crngt_cleanup_entropy(ossl_unused PROV_DRBG *drbg,
|
|
||||||
unsigned char *out, size_t outlen)
|
|
||||||
{
|
|
||||||
OPENSSL_secure_clear_free(out, outlen);
|
|
||||||
}
|
|
||||||
-600
@@ -1,600 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2022 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DSA 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/core_dispatch.h>
|
|
||||||
#include <openssl/core_names.h>
|
|
||||||
#include <openssl/err.h>
|
|
||||||
#include <openssl/dsa.h>
|
|
||||||
#include <openssl/params.h>
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
#include <openssl/proverr.h>
|
|
||||||
#include "internal/nelem.h"
|
|
||||||
#include "internal/sizes.h"
|
|
||||||
#include "internal/cryptlib.h"
|
|
||||||
#include "prov/providercommon.h"
|
|
||||||
#include "prov/implementations.h"
|
|
||||||
#include "prov/provider_ctx.h"
|
|
||||||
#include "prov/securitycheck.h"
|
|
||||||
#include "crypto/dsa.h"
|
|
||||||
#include "prov/der_dsa.h"
|
|
||||||
|
|
||||||
static OSSL_FUNC_signature_newctx_fn dsa_newctx;
|
|
||||||
static OSSL_FUNC_signature_sign_init_fn dsa_sign_init;
|
|
||||||
static OSSL_FUNC_signature_verify_init_fn dsa_verify_init;
|
|
||||||
static OSSL_FUNC_signature_sign_fn dsa_sign;
|
|
||||||
static OSSL_FUNC_signature_verify_fn dsa_verify;
|
|
||||||
static OSSL_FUNC_signature_digest_sign_init_fn dsa_digest_sign_init;
|
|
||||||
static OSSL_FUNC_signature_digest_sign_update_fn dsa_digest_signverify_update;
|
|
||||||
static OSSL_FUNC_signature_digest_sign_final_fn dsa_digest_sign_final;
|
|
||||||
static OSSL_FUNC_signature_digest_verify_init_fn dsa_digest_verify_init;
|
|
||||||
static OSSL_FUNC_signature_digest_verify_update_fn dsa_digest_signverify_update;
|
|
||||||
static OSSL_FUNC_signature_digest_verify_final_fn dsa_digest_verify_final;
|
|
||||||
static OSSL_FUNC_signature_freectx_fn dsa_freectx;
|
|
||||||
static OSSL_FUNC_signature_dupctx_fn dsa_dupctx;
|
|
||||||
static OSSL_FUNC_signature_get_ctx_params_fn dsa_get_ctx_params;
|
|
||||||
static OSSL_FUNC_signature_gettable_ctx_params_fn dsa_gettable_ctx_params;
|
|
||||||
static OSSL_FUNC_signature_set_ctx_params_fn dsa_set_ctx_params;
|
|
||||||
static OSSL_FUNC_signature_settable_ctx_params_fn dsa_settable_ctx_params;
|
|
||||||
static OSSL_FUNC_signature_get_ctx_md_params_fn dsa_get_ctx_md_params;
|
|
||||||
static OSSL_FUNC_signature_gettable_ctx_md_params_fn dsa_gettable_ctx_md_params;
|
|
||||||
static OSSL_FUNC_signature_set_ctx_md_params_fn dsa_set_ctx_md_params;
|
|
||||||
static OSSL_FUNC_signature_settable_ctx_md_params_fn dsa_settable_ctx_md_params;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* What's passed as an actual key is defined by the KEYMGMT interface.
|
|
||||||
* We happen to know that our KEYMGMT simply passes DSA structures, so
|
|
||||||
* we use that here too.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
OSSL_LIB_CTX *libctx;
|
|
||||||
char *propq;
|
|
||||||
DSA *dsa;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Flag to determine if the hash function can be changed (1) or not (0)
|
|
||||||
* Because it's dangerous to change during a DigestSign or DigestVerify
|
|
||||||
* operation, this flag is cleared by their Init function, and set again
|
|
||||||
* by their Final function.
|
|
||||||
*/
|
|
||||||
unsigned int flag_allow_md : 1;
|
|
||||||
|
|
||||||
char mdname[OSSL_MAX_NAME_SIZE];
|
|
||||||
|
|
||||||
/* The Algorithm Identifier of the combined signature algorithm */
|
|
||||||
unsigned char aid_buf[OSSL_MAX_ALGORITHM_ID_SIZE];
|
|
||||||
unsigned char *aid;
|
|
||||||
size_t aid_len;
|
|
||||||
|
|
||||||
/* main digest */
|
|
||||||
EVP_MD *md;
|
|
||||||
EVP_MD_CTX *mdctx;
|
|
||||||
int operation;
|
|
||||||
} PROV_DSA_CTX;
|
|
||||||
|
|
||||||
|
|
||||||
static size_t dsa_get_md_size(const PROV_DSA_CTX *pdsactx)
|
|
||||||
{
|
|
||||||
if (pdsactx->md != NULL)
|
|
||||||
return EVP_MD_get_size(pdsactx->md);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *dsa_newctx(void *provctx, const char *propq)
|
|
||||||
{
|
|
||||||
PROV_DSA_CTX *pdsactx;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
pdsactx = OPENSSL_zalloc(sizeof(PROV_DSA_CTX));
|
|
||||||
if (pdsactx == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
pdsactx->libctx = PROV_LIBCTX_OF(provctx);
|
|
||||||
pdsactx->flag_allow_md = 1;
|
|
||||||
if (propq != NULL && (pdsactx->propq = OPENSSL_strdup(propq)) == NULL) {
|
|
||||||
OPENSSL_free(pdsactx);
|
|
||||||
pdsactx = NULL;
|
|
||||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
|
||||||
}
|
|
||||||
return pdsactx;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dsa_setup_md(PROV_DSA_CTX *ctx,
|
|
||||||
const char *mdname, const char *mdprops)
|
|
||||||
{
|
|
||||||
if (mdprops == NULL)
|
|
||||||
mdprops = ctx->propq;
|
|
||||||
|
|
||||||
if (mdname != NULL) {
|
|
||||||
int sha1_allowed = (ctx->operation != EVP_PKEY_OP_SIGN);
|
|
||||||
WPACKET pkt;
|
|
||||||
EVP_MD *md = EVP_MD_fetch(ctx->libctx, mdname, mdprops);
|
|
||||||
int md_nid = ossl_digest_get_approved_nid_with_sha1(ctx->libctx, md,
|
|
||||||
sha1_allowed);
|
|
||||||
size_t mdname_len = strlen(mdname);
|
|
||||||
|
|
||||||
if (md == NULL || md_nid < 0) {
|
|
||||||
if (md == NULL)
|
|
||||||
ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST,
|
|
||||||
"%s could not be fetched", mdname);
|
|
||||||
if (md_nid < 0)
|
|
||||||
ERR_raise_data(ERR_LIB_PROV, PROV_R_DIGEST_NOT_ALLOWED,
|
|
||||||
"digest=%s", mdname);
|
|
||||||
if (mdname_len >= sizeof(ctx->mdname))
|
|
||||||
ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST,
|
|
||||||
"%s exceeds name buffer length", mdname);
|
|
||||||
EVP_MD_free(md);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ctx->flag_allow_md) {
|
|
||||||
if (ctx->mdname[0] != '\0' && !EVP_MD_is_a(md, ctx->mdname)) {
|
|
||||||
ERR_raise_data(ERR_LIB_PROV, PROV_R_DIGEST_NOT_ALLOWED,
|
|
||||||
"digest %s != %s", mdname, ctx->mdname);
|
|
||||||
EVP_MD_free(md);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
EVP_MD_free(md);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
EVP_MD_CTX_free(ctx->mdctx);
|
|
||||||
EVP_MD_free(ctx->md);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We do not care about DER writing errors.
|
|
||||||
* All it really means is that for some reason, there's no
|
|
||||||
* AlgorithmIdentifier to be had, but the operation itself is
|
|
||||||
* still valid, just as long as it's not used to construct
|
|
||||||
* anything that needs an AlgorithmIdentifier.
|
|
||||||
*/
|
|
||||||
ctx->aid_len = 0;
|
|
||||||
if (WPACKET_init_der(&pkt, ctx->aid_buf, sizeof(ctx->aid_buf))
|
|
||||||
&& ossl_DER_w_algorithmIdentifier_DSA_with_MD(&pkt, -1, ctx->dsa,
|
|
||||||
md_nid)
|
|
||||||
&& WPACKET_finish(&pkt)) {
|
|
||||||
WPACKET_get_total_written(&pkt, &ctx->aid_len);
|
|
||||||
ctx->aid = WPACKET_get_curr(&pkt);
|
|
||||||
}
|
|
||||||
WPACKET_cleanup(&pkt);
|
|
||||||
|
|
||||||
ctx->mdctx = NULL;
|
|
||||||
ctx->md = md;
|
|
||||||
OPENSSL_strlcpy(ctx->mdname, mdname, sizeof(ctx->mdname));
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dsa_signverify_init(void *vpdsactx, void *vdsa,
|
|
||||||
const OSSL_PARAM params[], int operation)
|
|
||||||
{
|
|
||||||
PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running()
|
|
||||||
|| pdsactx == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (vdsa == NULL && pdsactx->dsa == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_NO_KEY_SET);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vdsa != NULL) {
|
|
||||||
if (!ossl_dsa_check_key(pdsactx->libctx, vdsa,
|
|
||||||
operation == EVP_PKEY_OP_SIGN)) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!DSA_up_ref(vdsa))
|
|
||||||
return 0;
|
|
||||||
DSA_free(pdsactx->dsa);
|
|
||||||
pdsactx->dsa = vdsa;
|
|
||||||
}
|
|
||||||
|
|
||||||
pdsactx->operation = operation;
|
|
||||||
|
|
||||||
if (!dsa_set_ctx_params(pdsactx, params))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dsa_sign_init(void *vpdsactx, void *vdsa, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
return dsa_signverify_init(vpdsactx, vdsa, params, EVP_PKEY_OP_SIGN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dsa_verify_init(void *vpdsactx, void *vdsa,
|
|
||||||
const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
return dsa_signverify_init(vpdsactx, vdsa, params, EVP_PKEY_OP_VERIFY);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dsa_sign(void *vpdsactx, unsigned char *sig, size_t *siglen,
|
|
||||||
size_t sigsize, const unsigned char *tbs, size_t tbslen)
|
|
||||||
{
|
|
||||||
PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
|
|
||||||
int ret;
|
|
||||||
unsigned int sltmp;
|
|
||||||
size_t dsasize = DSA_size(pdsactx->dsa);
|
|
||||||
size_t mdsize = dsa_get_md_size(pdsactx);
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (sig == NULL) {
|
|
||||||
*siglen = dsasize;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sigsize < (size_t)dsasize)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (mdsize != 0 && tbslen != mdsize)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ret = ossl_dsa_sign_int(0, tbs, tbslen, sig, &sltmp, pdsactx->dsa);
|
|
||||||
if (ret <= 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
*siglen = sltmp;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dsa_verify(void *vpdsactx, const unsigned char *sig, size_t siglen,
|
|
||||||
const unsigned char *tbs, size_t tbslen)
|
|
||||||
{
|
|
||||||
PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
|
|
||||||
size_t mdsize = dsa_get_md_size(pdsactx);
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running() || (mdsize != 0 && tbslen != mdsize))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return DSA_verify(0, tbs, tbslen, sig, siglen, pdsactx->dsa);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dsa_digest_signverify_init(void *vpdsactx, const char *mdname,
|
|
||||||
void *vdsa, const OSSL_PARAM params[],
|
|
||||||
int operation)
|
|
||||||
{
|
|
||||||
PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!dsa_signverify_init(vpdsactx, vdsa, params, operation))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!dsa_setup_md(pdsactx, mdname, NULL))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
pdsactx->flag_allow_md = 0;
|
|
||||||
|
|
||||||
if (pdsactx->mdctx == NULL) {
|
|
||||||
pdsactx->mdctx = EVP_MD_CTX_new();
|
|
||||||
if (pdsactx->mdctx == NULL)
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!EVP_DigestInit_ex2(pdsactx->mdctx, pdsactx->md, params))
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
error:
|
|
||||||
EVP_MD_CTX_free(pdsactx->mdctx);
|
|
||||||
pdsactx->mdctx = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dsa_digest_sign_init(void *vpdsactx, const char *mdname,
|
|
||||||
void *vdsa, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
return dsa_digest_signverify_init(vpdsactx, mdname, vdsa, params,
|
|
||||||
EVP_PKEY_OP_SIGN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dsa_digest_verify_init(void *vpdsactx, const char *mdname,
|
|
||||||
void *vdsa, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
return dsa_digest_signverify_init(vpdsactx, mdname, vdsa, params,
|
|
||||||
EVP_PKEY_OP_VERIFY);
|
|
||||||
}
|
|
||||||
|
|
||||||
int dsa_digest_signverify_update(void *vpdsactx, const unsigned char *data,
|
|
||||||
size_t datalen)
|
|
||||||
{
|
|
||||||
PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
|
|
||||||
|
|
||||||
if (pdsactx == NULL || pdsactx->mdctx == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return EVP_DigestUpdate(pdsactx->mdctx, data, datalen);
|
|
||||||
}
|
|
||||||
|
|
||||||
int dsa_digest_sign_final(void *vpdsactx, unsigned char *sig, size_t *siglen,
|
|
||||||
size_t sigsize)
|
|
||||||
{
|
|
||||||
PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
|
|
||||||
unsigned char digest[EVP_MAX_MD_SIZE];
|
|
||||||
unsigned int dlen = 0;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running() || pdsactx == NULL || pdsactx->mdctx == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If sig is NULL then we're just finding out the sig size. Other fields
|
|
||||||
* are ignored. Defer to dsa_sign.
|
|
||||||
*/
|
|
||||||
if (sig != NULL) {
|
|
||||||
/*
|
|
||||||
* There is the possibility that some externally provided
|
|
||||||
* digests exceed EVP_MAX_MD_SIZE. We should probably handle that somehow -
|
|
||||||
* but that problem is much larger than just in DSA.
|
|
||||||
*/
|
|
||||||
if (!EVP_DigestFinal_ex(pdsactx->mdctx, digest, &dlen))
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pdsactx->flag_allow_md = 1;
|
|
||||||
|
|
||||||
return dsa_sign(vpdsactx, sig, siglen, sigsize, digest, (size_t)dlen);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int dsa_digest_verify_final(void *vpdsactx, const unsigned char *sig,
|
|
||||||
size_t siglen)
|
|
||||||
{
|
|
||||||
PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
|
|
||||||
unsigned char digest[EVP_MAX_MD_SIZE];
|
|
||||||
unsigned int dlen = 0;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running() || pdsactx == NULL || pdsactx->mdctx == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* There is the possibility that some externally provided
|
|
||||||
* digests exceed EVP_MAX_MD_SIZE. We should probably handle that somehow -
|
|
||||||
* but that problem is much larger than just in DSA.
|
|
||||||
*/
|
|
||||||
if (!EVP_DigestFinal_ex(pdsactx->mdctx, digest, &dlen))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
pdsactx->flag_allow_md = 1;
|
|
||||||
|
|
||||||
return dsa_verify(vpdsactx, sig, siglen, digest, (size_t)dlen);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void dsa_freectx(void *vpdsactx)
|
|
||||||
{
|
|
||||||
PROV_DSA_CTX *ctx = (PROV_DSA_CTX *)vpdsactx;
|
|
||||||
|
|
||||||
OPENSSL_free(ctx->propq);
|
|
||||||
EVP_MD_CTX_free(ctx->mdctx);
|
|
||||||
EVP_MD_free(ctx->md);
|
|
||||||
ctx->propq = NULL;
|
|
||||||
ctx->mdctx = NULL;
|
|
||||||
ctx->md = NULL;
|
|
||||||
DSA_free(ctx->dsa);
|
|
||||||
OPENSSL_free(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *dsa_dupctx(void *vpdsactx)
|
|
||||||
{
|
|
||||||
PROV_DSA_CTX *srcctx = (PROV_DSA_CTX *)vpdsactx;
|
|
||||||
PROV_DSA_CTX *dstctx;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
dstctx = OPENSSL_zalloc(sizeof(*srcctx));
|
|
||||||
if (dstctx == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
*dstctx = *srcctx;
|
|
||||||
dstctx->dsa = NULL;
|
|
||||||
dstctx->md = NULL;
|
|
||||||
dstctx->mdctx = NULL;
|
|
||||||
dstctx->propq = NULL;
|
|
||||||
|
|
||||||
if (srcctx->dsa != NULL && !DSA_up_ref(srcctx->dsa))
|
|
||||||
goto err;
|
|
||||||
dstctx->dsa = srcctx->dsa;
|
|
||||||
|
|
||||||
if (srcctx->md != NULL && !EVP_MD_up_ref(srcctx->md))
|
|
||||||
goto err;
|
|
||||||
dstctx->md = srcctx->md;
|
|
||||||
|
|
||||||
if (srcctx->mdctx != NULL) {
|
|
||||||
dstctx->mdctx = EVP_MD_CTX_new();
|
|
||||||
if (dstctx->mdctx == NULL
|
|
||||||
|| !EVP_MD_CTX_copy_ex(dstctx->mdctx, srcctx->mdctx))
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
if (srcctx->propq != NULL) {
|
|
||||||
dstctx->propq = OPENSSL_strdup(srcctx->propq);
|
|
||||||
if (dstctx->propq == NULL)
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dstctx;
|
|
||||||
err:
|
|
||||||
dsa_freectx(dstctx);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dsa_get_ctx_params(void *vpdsactx, OSSL_PARAM *params)
|
|
||||||
{
|
|
||||||
PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
|
|
||||||
OSSL_PARAM *p;
|
|
||||||
|
|
||||||
if (pdsactx == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_ALGORITHM_ID);
|
|
||||||
if (p != NULL
|
|
||||||
&& !OSSL_PARAM_set_octet_string(p, pdsactx->aid, pdsactx->aid_len))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_DIGEST);
|
|
||||||
if (p != NULL && !OSSL_PARAM_set_utf8_string(p, pdsactx->mdname))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const OSSL_PARAM known_gettable_ctx_params[] = {
|
|
||||||
OSSL_PARAM_octet_string(OSSL_SIGNATURE_PARAM_ALGORITHM_ID, NULL, 0),
|
|
||||||
OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0),
|
|
||||||
OSSL_PARAM_END
|
|
||||||
};
|
|
||||||
|
|
||||||
static const OSSL_PARAM *dsa_gettable_ctx_params(ossl_unused void *ctx,
|
|
||||||
ossl_unused void *provctx)
|
|
||||||
{
|
|
||||||
return known_gettable_ctx_params;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dsa_set_ctx_params(void *vpdsactx, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
|
|
||||||
const OSSL_PARAM *p;
|
|
||||||
|
|
||||||
if (pdsactx == NULL)
|
|
||||||
return 0;
|
|
||||||
if (params == NULL)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
p = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_DIGEST);
|
|
||||||
if (p != NULL) {
|
|
||||||
char mdname[OSSL_MAX_NAME_SIZE] = "", *pmdname = mdname;
|
|
||||||
char mdprops[OSSL_MAX_PROPQUERY_SIZE] = "", *pmdprops = mdprops;
|
|
||||||
const OSSL_PARAM *propsp =
|
|
||||||
OSSL_PARAM_locate_const(params,
|
|
||||||
OSSL_SIGNATURE_PARAM_PROPERTIES);
|
|
||||||
|
|
||||||
if (!OSSL_PARAM_get_utf8_string(p, &pmdname, sizeof(mdname)))
|
|
||||||
return 0;
|
|
||||||
if (propsp != NULL
|
|
||||||
&& !OSSL_PARAM_get_utf8_string(propsp, &pmdprops, sizeof(mdprops)))
|
|
||||||
return 0;
|
|
||||||
if (!dsa_setup_md(pdsactx, mdname, mdprops))
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const OSSL_PARAM settable_ctx_params[] = {
|
|
||||||
OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0),
|
|
||||||
OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_PROPERTIES, NULL, 0),
|
|
||||||
OSSL_PARAM_END
|
|
||||||
};
|
|
||||||
|
|
||||||
static const OSSL_PARAM settable_ctx_params_no_digest[] = {
|
|
||||||
OSSL_PARAM_END
|
|
||||||
};
|
|
||||||
|
|
||||||
static const OSSL_PARAM *dsa_settable_ctx_params(void *vpdsactx,
|
|
||||||
ossl_unused void *provctx)
|
|
||||||
{
|
|
||||||
PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
|
|
||||||
|
|
||||||
if (pdsactx != NULL && !pdsactx->flag_allow_md)
|
|
||||||
return settable_ctx_params_no_digest;
|
|
||||||
return settable_ctx_params;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dsa_get_ctx_md_params(void *vpdsactx, OSSL_PARAM *params)
|
|
||||||
{
|
|
||||||
PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
|
|
||||||
|
|
||||||
if (pdsactx->mdctx == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return EVP_MD_CTX_get_params(pdsactx->mdctx, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const OSSL_PARAM *dsa_gettable_ctx_md_params(void *vpdsactx)
|
|
||||||
{
|
|
||||||
PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
|
|
||||||
|
|
||||||
if (pdsactx->md == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return EVP_MD_gettable_ctx_params(pdsactx->md);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dsa_set_ctx_md_params(void *vpdsactx, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
|
|
||||||
|
|
||||||
if (pdsactx->mdctx == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return EVP_MD_CTX_set_params(pdsactx->mdctx, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const OSSL_PARAM *dsa_settable_ctx_md_params(void *vpdsactx)
|
|
||||||
{
|
|
||||||
PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
|
|
||||||
|
|
||||||
if (pdsactx->md == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return EVP_MD_settable_ctx_params(pdsactx->md);
|
|
||||||
}
|
|
||||||
|
|
||||||
const OSSL_DISPATCH ossl_dsa_signature_functions[] = {
|
|
||||||
{ OSSL_FUNC_SIGNATURE_NEWCTX, (void (*)(void))dsa_newctx },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_SIGN_INIT, (void (*)(void))dsa_sign_init },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_SIGN, (void (*)(void))dsa_sign },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_VERIFY_INIT, (void (*)(void))dsa_verify_init },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_VERIFY, (void (*)(void))dsa_verify },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT,
|
|
||||||
(void (*)(void))dsa_digest_sign_init },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE,
|
|
||||||
(void (*)(void))dsa_digest_signverify_update },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL,
|
|
||||||
(void (*)(void))dsa_digest_sign_final },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT,
|
|
||||||
(void (*)(void))dsa_digest_verify_init },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE,
|
|
||||||
(void (*)(void))dsa_digest_signverify_update },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL,
|
|
||||||
(void (*)(void))dsa_digest_verify_final },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_FREECTX, (void (*)(void))dsa_freectx },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DUPCTX, (void (*)(void))dsa_dupctx },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS, (void (*)(void))dsa_get_ctx_params },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS,
|
|
||||||
(void (*)(void))dsa_gettable_ctx_params },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS, (void (*)(void))dsa_set_ctx_params },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS,
|
|
||||||
(void (*)(void))dsa_settable_ctx_params },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS,
|
|
||||||
(void (*)(void))dsa_get_ctx_md_params },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS,
|
|
||||||
(void (*)(void))dsa_gettable_ctx_md_params },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS,
|
|
||||||
(void (*)(void))dsa_set_ctx_md_params },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS,
|
|
||||||
(void (*)(void))dsa_settable_ctx_md_params },
|
|
||||||
{ 0, NULL }
|
|
||||||
};
|
|
||||||
-619
@@ -1,619 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020-2021 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ECDSA low level APIs are deprecated for public use, but still ok for
|
|
||||||
* internal use.
|
|
||||||
*/
|
|
||||||
#include "internal/deprecated.h"
|
|
||||||
|
|
||||||
#include <string.h> /* memcpy */
|
|
||||||
#include <openssl/crypto.h>
|
|
||||||
#include <openssl/core_dispatch.h>
|
|
||||||
#include <openssl/core_names.h>
|
|
||||||
#include <openssl/dsa.h>
|
|
||||||
#include <openssl/params.h>
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
#include <openssl/err.h>
|
|
||||||
#include <openssl/proverr.h>
|
|
||||||
#include "internal/nelem.h"
|
|
||||||
#include "internal/sizes.h"
|
|
||||||
#include "internal/cryptlib.h"
|
|
||||||
#include "prov/providercommon.h"
|
|
||||||
#include "prov/implementations.h"
|
|
||||||
#include "prov/provider_ctx.h"
|
|
||||||
#include "prov/securitycheck.h"
|
|
||||||
#include "crypto/ec.h"
|
|
||||||
#include "prov/der_ec.h"
|
|
||||||
|
|
||||||
static OSSL_FUNC_signature_newctx_fn ecdsa_newctx;
|
|
||||||
static OSSL_FUNC_signature_sign_init_fn ecdsa_sign_init;
|
|
||||||
static OSSL_FUNC_signature_verify_init_fn ecdsa_verify_init;
|
|
||||||
static OSSL_FUNC_signature_sign_fn ecdsa_sign;
|
|
||||||
static OSSL_FUNC_signature_verify_fn ecdsa_verify;
|
|
||||||
static OSSL_FUNC_signature_digest_sign_init_fn ecdsa_digest_sign_init;
|
|
||||||
static OSSL_FUNC_signature_digest_sign_update_fn ecdsa_digest_signverify_update;
|
|
||||||
static OSSL_FUNC_signature_digest_sign_final_fn ecdsa_digest_sign_final;
|
|
||||||
static OSSL_FUNC_signature_digest_verify_init_fn ecdsa_digest_verify_init;
|
|
||||||
static OSSL_FUNC_signature_digest_verify_update_fn ecdsa_digest_signverify_update;
|
|
||||||
static OSSL_FUNC_signature_digest_verify_final_fn ecdsa_digest_verify_final;
|
|
||||||
static OSSL_FUNC_signature_freectx_fn ecdsa_freectx;
|
|
||||||
static OSSL_FUNC_signature_dupctx_fn ecdsa_dupctx;
|
|
||||||
static OSSL_FUNC_signature_get_ctx_params_fn ecdsa_get_ctx_params;
|
|
||||||
static OSSL_FUNC_signature_gettable_ctx_params_fn ecdsa_gettable_ctx_params;
|
|
||||||
static OSSL_FUNC_signature_set_ctx_params_fn ecdsa_set_ctx_params;
|
|
||||||
static OSSL_FUNC_signature_settable_ctx_params_fn ecdsa_settable_ctx_params;
|
|
||||||
static OSSL_FUNC_signature_get_ctx_md_params_fn ecdsa_get_ctx_md_params;
|
|
||||||
static OSSL_FUNC_signature_gettable_ctx_md_params_fn ecdsa_gettable_ctx_md_params;
|
|
||||||
static OSSL_FUNC_signature_set_ctx_md_params_fn ecdsa_set_ctx_md_params;
|
|
||||||
static OSSL_FUNC_signature_settable_ctx_md_params_fn ecdsa_settable_ctx_md_params;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* What's passed as an actual key is defined by the KEYMGMT interface.
|
|
||||||
* We happen to know that our KEYMGMT simply passes DSA structures, so
|
|
||||||
* we use that here too.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
OSSL_LIB_CTX *libctx;
|
|
||||||
char *propq;
|
|
||||||
EC_KEY *ec;
|
|
||||||
char mdname[OSSL_MAX_NAME_SIZE];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Flag to determine if the hash function can be changed (1) or not (0)
|
|
||||||
* Because it's dangerous to change during a DigestSign or DigestVerify
|
|
||||||
* operation, this flag is cleared by their Init function, and set again
|
|
||||||
* by their Final function.
|
|
||||||
*/
|
|
||||||
unsigned int flag_allow_md : 1;
|
|
||||||
|
|
||||||
/* The Algorithm Identifier of the combined signature algorithm */
|
|
||||||
unsigned char aid_buf[OSSL_MAX_ALGORITHM_ID_SIZE];
|
|
||||||
unsigned char *aid;
|
|
||||||
size_t aid_len;
|
|
||||||
size_t mdsize;
|
|
||||||
int operation;
|
|
||||||
|
|
||||||
EVP_MD *md;
|
|
||||||
EVP_MD_CTX *mdctx;
|
|
||||||
/*
|
|
||||||
* Internally used to cache the results of calling the EC group
|
|
||||||
* sign_setup() methods which are then passed to the sign operation.
|
|
||||||
* This is used by CAVS failure tests to terminate a loop if the signature
|
|
||||||
* is not valid.
|
|
||||||
* This could of also been done with a simple flag.
|
|
||||||
*/
|
|
||||||
BIGNUM *kinv;
|
|
||||||
BIGNUM *r;
|
|
||||||
#if !defined(OPENSSL_NO_ACVP_TESTS)
|
|
||||||
/*
|
|
||||||
* This indicates that KAT (CAVS) test is running. Externally an app will
|
|
||||||
* override the random callback such that the generated private key and k
|
|
||||||
* are known.
|
|
||||||
* Normal operation will loop to choose a new k if the signature is not
|
|
||||||
* valid - but for this mode of operation it forces a failure instead.
|
|
||||||
*/
|
|
||||||
unsigned int kattest;
|
|
||||||
#endif
|
|
||||||
} PROV_ECDSA_CTX;
|
|
||||||
|
|
||||||
static void *ecdsa_newctx(void *provctx, const char *propq)
|
|
||||||
{
|
|
||||||
PROV_ECDSA_CTX *ctx;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ctx = OPENSSL_zalloc(sizeof(PROV_ECDSA_CTX));
|
|
||||||
if (ctx == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ctx->flag_allow_md = 1;
|
|
||||||
ctx->libctx = PROV_LIBCTX_OF(provctx);
|
|
||||||
if (propq != NULL && (ctx->propq = OPENSSL_strdup(propq)) == NULL) {
|
|
||||||
OPENSSL_free(ctx);
|
|
||||||
ctx = NULL;
|
|
||||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
|
||||||
}
|
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ecdsa_signverify_init(void *vctx, void *ec,
|
|
||||||
const OSSL_PARAM params[], int operation)
|
|
||||||
{
|
|
||||||
PROV_ECDSA_CTX *ctx = (PROV_ECDSA_CTX *)vctx;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running()
|
|
||||||
|| ctx == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (ec == NULL && ctx->ec == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_NO_KEY_SET);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ec != NULL) {
|
|
||||||
if (!ossl_ec_check_key(ctx->libctx, ec, operation == EVP_PKEY_OP_SIGN))
|
|
||||||
return 0;
|
|
||||||
if (!EC_KEY_up_ref(ec))
|
|
||||||
return 0;
|
|
||||||
EC_KEY_free(ctx->ec);
|
|
||||||
ctx->ec = ec;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx->operation = operation;
|
|
||||||
|
|
||||||
if (!ecdsa_set_ctx_params(ctx, params))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ecdsa_sign_init(void *vctx, void *ec, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
return ecdsa_signverify_init(vctx, ec, params, EVP_PKEY_OP_SIGN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ecdsa_verify_init(void *vctx, void *ec, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
return ecdsa_signverify_init(vctx, ec, params, EVP_PKEY_OP_VERIFY);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ecdsa_sign(void *vctx, unsigned char *sig, size_t *siglen,
|
|
||||||
size_t sigsize, const unsigned char *tbs, size_t tbslen)
|
|
||||||
{
|
|
||||||
PROV_ECDSA_CTX *ctx = (PROV_ECDSA_CTX *)vctx;
|
|
||||||
int ret;
|
|
||||||
unsigned int sltmp;
|
|
||||||
size_t ecsize = ECDSA_size(ctx->ec);
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (sig == NULL) {
|
|
||||||
*siglen = ecsize;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(OPENSSL_NO_ACVP_TESTS)
|
|
||||||
if (ctx->kattest && !ECDSA_sign_setup(ctx->ec, NULL, &ctx->kinv, &ctx->r))
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (sigsize < (size_t)ecsize)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (ctx->mdsize != 0 && tbslen != ctx->mdsize)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ret = ECDSA_sign_ex(0, tbs, tbslen, sig, &sltmp, ctx->kinv, ctx->r, ctx->ec);
|
|
||||||
if (ret <= 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
*siglen = sltmp;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ecdsa_verify(void *vctx, const unsigned char *sig, size_t siglen,
|
|
||||||
const unsigned char *tbs, size_t tbslen)
|
|
||||||
{
|
|
||||||
PROV_ECDSA_CTX *ctx = (PROV_ECDSA_CTX *)vctx;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running() || (ctx->mdsize != 0 && tbslen != ctx->mdsize))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return ECDSA_verify(0, tbs, tbslen, sig, siglen, ctx->ec);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ecdsa_setup_md(PROV_ECDSA_CTX *ctx, const char *mdname,
|
|
||||||
const char *mdprops)
|
|
||||||
{
|
|
||||||
EVP_MD *md = NULL;
|
|
||||||
size_t mdname_len;
|
|
||||||
int md_nid, sha1_allowed;
|
|
||||||
WPACKET pkt;
|
|
||||||
|
|
||||||
if (mdname == NULL)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
mdname_len = strlen(mdname);
|
|
||||||
if (mdname_len >= sizeof(ctx->mdname)) {
|
|
||||||
ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST,
|
|
||||||
"%s exceeds name buffer length", mdname);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (mdprops == NULL)
|
|
||||||
mdprops = ctx->propq;
|
|
||||||
md = EVP_MD_fetch(ctx->libctx, mdname, mdprops);
|
|
||||||
if (md == NULL) {
|
|
||||||
ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST,
|
|
||||||
"%s could not be fetched", mdname);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
sha1_allowed = (ctx->operation != EVP_PKEY_OP_SIGN);
|
|
||||||
md_nid = ossl_digest_get_approved_nid_with_sha1(ctx->libctx, md,
|
|
||||||
sha1_allowed);
|
|
||||||
if (md_nid < 0) {
|
|
||||||
ERR_raise_data(ERR_LIB_PROV, PROV_R_DIGEST_NOT_ALLOWED,
|
|
||||||
"digest=%s", mdname);
|
|
||||||
EVP_MD_free(md);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ctx->flag_allow_md) {
|
|
||||||
if (ctx->mdname[0] != '\0' && !EVP_MD_is_a(md, ctx->mdname)) {
|
|
||||||
ERR_raise_data(ERR_LIB_PROV, PROV_R_DIGEST_NOT_ALLOWED,
|
|
||||||
"digest %s != %s", mdname, ctx->mdname);
|
|
||||||
EVP_MD_free(md);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
EVP_MD_free(md);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
EVP_MD_CTX_free(ctx->mdctx);
|
|
||||||
EVP_MD_free(ctx->md);
|
|
||||||
|
|
||||||
ctx->aid_len = 0;
|
|
||||||
if (WPACKET_init_der(&pkt, ctx->aid_buf, sizeof(ctx->aid_buf))
|
|
||||||
&& ossl_DER_w_algorithmIdentifier_ECDSA_with_MD(&pkt, -1, ctx->ec,
|
|
||||||
md_nid)
|
|
||||||
&& WPACKET_finish(&pkt)) {
|
|
||||||
WPACKET_get_total_written(&pkt, &ctx->aid_len);
|
|
||||||
ctx->aid = WPACKET_get_curr(&pkt);
|
|
||||||
}
|
|
||||||
WPACKET_cleanup(&pkt);
|
|
||||||
ctx->mdctx = NULL;
|
|
||||||
ctx->md = md;
|
|
||||||
ctx->mdsize = EVP_MD_get_size(ctx->md);
|
|
||||||
OPENSSL_strlcpy(ctx->mdname, mdname, sizeof(ctx->mdname));
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ecdsa_digest_signverify_init(void *vctx, const char *mdname,
|
|
||||||
void *ec, const OSSL_PARAM params[],
|
|
||||||
int operation)
|
|
||||||
{
|
|
||||||
PROV_ECDSA_CTX *ctx = (PROV_ECDSA_CTX *)vctx;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!ecdsa_signverify_init(vctx, ec, params, operation)
|
|
||||||
|| !ecdsa_setup_md(ctx, mdname, NULL))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ctx->flag_allow_md = 0;
|
|
||||||
|
|
||||||
if (ctx->mdctx == NULL) {
|
|
||||||
ctx->mdctx = EVP_MD_CTX_new();
|
|
||||||
if (ctx->mdctx == NULL)
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!EVP_DigestInit_ex2(ctx->mdctx, ctx->md, params))
|
|
||||||
goto error;
|
|
||||||
return 1;
|
|
||||||
error:
|
|
||||||
EVP_MD_CTX_free(ctx->mdctx);
|
|
||||||
ctx->mdctx = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ecdsa_digest_sign_init(void *vctx, const char *mdname, void *ec,
|
|
||||||
const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
return ecdsa_digest_signverify_init(vctx, mdname, ec, params,
|
|
||||||
EVP_PKEY_OP_SIGN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ecdsa_digest_verify_init(void *vctx, const char *mdname, void *ec,
|
|
||||||
const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
return ecdsa_digest_signverify_init(vctx, mdname, ec, params,
|
|
||||||
EVP_PKEY_OP_VERIFY);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ecdsa_digest_signverify_update(void *vctx, const unsigned char *data,
|
|
||||||
size_t datalen)
|
|
||||||
{
|
|
||||||
PROV_ECDSA_CTX *ctx = (PROV_ECDSA_CTX *)vctx;
|
|
||||||
|
|
||||||
if (ctx == NULL || ctx->mdctx == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return EVP_DigestUpdate(ctx->mdctx, data, datalen);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ecdsa_digest_sign_final(void *vctx, unsigned char *sig, size_t *siglen,
|
|
||||||
size_t sigsize)
|
|
||||||
{
|
|
||||||
PROV_ECDSA_CTX *ctx = (PROV_ECDSA_CTX *)vctx;
|
|
||||||
unsigned char digest[EVP_MAX_MD_SIZE];
|
|
||||||
unsigned int dlen = 0;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running() || ctx == NULL || ctx->mdctx == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If sig is NULL then we're just finding out the sig size. Other fields
|
|
||||||
* are ignored. Defer to ecdsa_sign.
|
|
||||||
*/
|
|
||||||
if (sig != NULL
|
|
||||||
&& !EVP_DigestFinal_ex(ctx->mdctx, digest, &dlen))
|
|
||||||
return 0;
|
|
||||||
ctx->flag_allow_md = 1;
|
|
||||||
return ecdsa_sign(vctx, sig, siglen, sigsize, digest, (size_t)dlen);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ecdsa_digest_verify_final(void *vctx, const unsigned char *sig,
|
|
||||||
size_t siglen)
|
|
||||||
{
|
|
||||||
PROV_ECDSA_CTX *ctx = (PROV_ECDSA_CTX *)vctx;
|
|
||||||
unsigned char digest[EVP_MAX_MD_SIZE];
|
|
||||||
unsigned int dlen = 0;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running() || ctx == NULL || ctx->mdctx == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!EVP_DigestFinal_ex(ctx->mdctx, digest, &dlen))
|
|
||||||
return 0;
|
|
||||||
ctx->flag_allow_md = 1;
|
|
||||||
return ecdsa_verify(ctx, sig, siglen, digest, (size_t)dlen);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ecdsa_freectx(void *vctx)
|
|
||||||
{
|
|
||||||
PROV_ECDSA_CTX *ctx = (PROV_ECDSA_CTX *)vctx;
|
|
||||||
|
|
||||||
OPENSSL_free(ctx->propq);
|
|
||||||
EVP_MD_CTX_free(ctx->mdctx);
|
|
||||||
EVP_MD_free(ctx->md);
|
|
||||||
ctx->propq = NULL;
|
|
||||||
ctx->mdctx = NULL;
|
|
||||||
ctx->md = NULL;
|
|
||||||
ctx->mdsize = 0;
|
|
||||||
EC_KEY_free(ctx->ec);
|
|
||||||
BN_clear_free(ctx->kinv);
|
|
||||||
BN_clear_free(ctx->r);
|
|
||||||
OPENSSL_free(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *ecdsa_dupctx(void *vctx)
|
|
||||||
{
|
|
||||||
PROV_ECDSA_CTX *srcctx = (PROV_ECDSA_CTX *)vctx;
|
|
||||||
PROV_ECDSA_CTX *dstctx;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
dstctx = OPENSSL_zalloc(sizeof(*srcctx));
|
|
||||||
if (dstctx == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
*dstctx = *srcctx;
|
|
||||||
dstctx->ec = NULL;
|
|
||||||
dstctx->md = NULL;
|
|
||||||
dstctx->mdctx = NULL;
|
|
||||||
dstctx->propq = NULL;
|
|
||||||
|
|
||||||
if (srcctx->ec != NULL && !EC_KEY_up_ref(srcctx->ec))
|
|
||||||
goto err;
|
|
||||||
/* Test KATS should not need to be supported */
|
|
||||||
if (srcctx->kinv != NULL || srcctx->r != NULL)
|
|
||||||
goto err;
|
|
||||||
dstctx->ec = srcctx->ec;
|
|
||||||
|
|
||||||
if (srcctx->md != NULL && !EVP_MD_up_ref(srcctx->md))
|
|
||||||
goto err;
|
|
||||||
dstctx->md = srcctx->md;
|
|
||||||
|
|
||||||
if (srcctx->mdctx != NULL) {
|
|
||||||
dstctx->mdctx = EVP_MD_CTX_new();
|
|
||||||
if (dstctx->mdctx == NULL
|
|
||||||
|| !EVP_MD_CTX_copy_ex(dstctx->mdctx, srcctx->mdctx))
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (srcctx->propq != NULL) {
|
|
||||||
dstctx->propq = OPENSSL_strdup(srcctx->propq);
|
|
||||||
if (dstctx->propq == NULL)
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dstctx;
|
|
||||||
err:
|
|
||||||
ecdsa_freectx(dstctx);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ecdsa_get_ctx_params(void *vctx, OSSL_PARAM *params)
|
|
||||||
{
|
|
||||||
PROV_ECDSA_CTX *ctx = (PROV_ECDSA_CTX *)vctx;
|
|
||||||
OSSL_PARAM *p;
|
|
||||||
|
|
||||||
if (ctx == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_ALGORITHM_ID);
|
|
||||||
if (p != NULL && !OSSL_PARAM_set_octet_string(p, ctx->aid, ctx->aid_len))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_DIGEST_SIZE);
|
|
||||||
if (p != NULL && !OSSL_PARAM_set_size_t(p, ctx->mdsize))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_DIGEST);
|
|
||||||
if (p != NULL && !OSSL_PARAM_set_utf8_string(p, ctx->md == NULL
|
|
||||||
? ctx->mdname
|
|
||||||
: EVP_MD_get0_name(ctx->md)))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const OSSL_PARAM known_gettable_ctx_params[] = {
|
|
||||||
OSSL_PARAM_octet_string(OSSL_SIGNATURE_PARAM_ALGORITHM_ID, NULL, 0),
|
|
||||||
OSSL_PARAM_size_t(OSSL_SIGNATURE_PARAM_DIGEST_SIZE, NULL),
|
|
||||||
OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0),
|
|
||||||
OSSL_PARAM_END
|
|
||||||
};
|
|
||||||
|
|
||||||
static const OSSL_PARAM *ecdsa_gettable_ctx_params(ossl_unused void *vctx,
|
|
||||||
ossl_unused void *provctx)
|
|
||||||
{
|
|
||||||
return known_gettable_ctx_params;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ecdsa_set_ctx_params(void *vctx, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
PROV_ECDSA_CTX *ctx = (PROV_ECDSA_CTX *)vctx;
|
|
||||||
const OSSL_PARAM *p;
|
|
||||||
size_t mdsize = 0;
|
|
||||||
|
|
||||||
if (ctx == NULL)
|
|
||||||
return 0;
|
|
||||||
if (params == NULL)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
#if !defined(OPENSSL_NO_ACVP_TESTS)
|
|
||||||
p = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_KAT);
|
|
||||||
if (p != NULL && !OSSL_PARAM_get_uint(p, &ctx->kattest))
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
p = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_DIGEST);
|
|
||||||
if (p != NULL) {
|
|
||||||
char mdname[OSSL_MAX_NAME_SIZE] = "", *pmdname = mdname;
|
|
||||||
char mdprops[OSSL_MAX_PROPQUERY_SIZE] = "", *pmdprops = mdprops;
|
|
||||||
const OSSL_PARAM *propsp =
|
|
||||||
OSSL_PARAM_locate_const(params,
|
|
||||||
OSSL_SIGNATURE_PARAM_PROPERTIES);
|
|
||||||
|
|
||||||
if (!OSSL_PARAM_get_utf8_string(p, &pmdname, sizeof(mdname)))
|
|
||||||
return 0;
|
|
||||||
if (propsp != NULL
|
|
||||||
&& !OSSL_PARAM_get_utf8_string(propsp, &pmdprops, sizeof(mdprops)))
|
|
||||||
return 0;
|
|
||||||
if (!ecdsa_setup_md(ctx, mdname, mdprops))
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_DIGEST_SIZE);
|
|
||||||
if (p != NULL) {
|
|
||||||
if (!OSSL_PARAM_get_size_t(p, &mdsize)
|
|
||||||
|| (!ctx->flag_allow_md && mdsize != ctx->mdsize))
|
|
||||||
return 0;
|
|
||||||
ctx->mdsize = mdsize;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const OSSL_PARAM settable_ctx_params[] = {
|
|
||||||
OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0),
|
|
||||||
OSSL_PARAM_size_t(OSSL_SIGNATURE_PARAM_DIGEST_SIZE, NULL),
|
|
||||||
OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_PROPERTIES, NULL, 0),
|
|
||||||
OSSL_PARAM_uint(OSSL_SIGNATURE_PARAM_KAT, NULL),
|
|
||||||
OSSL_PARAM_END
|
|
||||||
};
|
|
||||||
|
|
||||||
static const OSSL_PARAM settable_ctx_params_no_digest[] = {
|
|
||||||
OSSL_PARAM_uint(OSSL_SIGNATURE_PARAM_KAT, NULL),
|
|
||||||
OSSL_PARAM_END
|
|
||||||
};
|
|
||||||
|
|
||||||
static const OSSL_PARAM *ecdsa_settable_ctx_params(void *vctx,
|
|
||||||
ossl_unused void *provctx)
|
|
||||||
{
|
|
||||||
PROV_ECDSA_CTX *ctx = (PROV_ECDSA_CTX *)vctx;
|
|
||||||
|
|
||||||
if (ctx != NULL && !ctx->flag_allow_md)
|
|
||||||
return settable_ctx_params_no_digest;
|
|
||||||
return settable_ctx_params;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ecdsa_get_ctx_md_params(void *vctx, OSSL_PARAM *params)
|
|
||||||
{
|
|
||||||
PROV_ECDSA_CTX *ctx = (PROV_ECDSA_CTX *)vctx;
|
|
||||||
|
|
||||||
if (ctx->mdctx == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return EVP_MD_CTX_get_params(ctx->mdctx, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const OSSL_PARAM *ecdsa_gettable_ctx_md_params(void *vctx)
|
|
||||||
{
|
|
||||||
PROV_ECDSA_CTX *ctx = (PROV_ECDSA_CTX *)vctx;
|
|
||||||
|
|
||||||
if (ctx->md == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return EVP_MD_gettable_ctx_params(ctx->md);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ecdsa_set_ctx_md_params(void *vctx, const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
PROV_ECDSA_CTX *ctx = (PROV_ECDSA_CTX *)vctx;
|
|
||||||
|
|
||||||
if (ctx->mdctx == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return EVP_MD_CTX_set_params(ctx->mdctx, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const OSSL_PARAM *ecdsa_settable_ctx_md_params(void *vctx)
|
|
||||||
{
|
|
||||||
PROV_ECDSA_CTX *ctx = (PROV_ECDSA_CTX *)vctx;
|
|
||||||
|
|
||||||
if (ctx->md == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return EVP_MD_settable_ctx_params(ctx->md);
|
|
||||||
}
|
|
||||||
|
|
||||||
const OSSL_DISPATCH ossl_ecdsa_signature_functions[] = {
|
|
||||||
{ OSSL_FUNC_SIGNATURE_NEWCTX, (void (*)(void))ecdsa_newctx },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_SIGN_INIT, (void (*)(void))ecdsa_sign_init },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_SIGN, (void (*)(void))ecdsa_sign },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_VERIFY_INIT, (void (*)(void))ecdsa_verify_init },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_VERIFY, (void (*)(void))ecdsa_verify },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT,
|
|
||||||
(void (*)(void))ecdsa_digest_sign_init },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE,
|
|
||||||
(void (*)(void))ecdsa_digest_signverify_update },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL,
|
|
||||||
(void (*)(void))ecdsa_digest_sign_final },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT,
|
|
||||||
(void (*)(void))ecdsa_digest_verify_init },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE,
|
|
||||||
(void (*)(void))ecdsa_digest_signverify_update },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL,
|
|
||||||
(void (*)(void))ecdsa_digest_verify_final },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_FREECTX, (void (*)(void))ecdsa_freectx },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DUPCTX, (void (*)(void))ecdsa_dupctx },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS, (void (*)(void))ecdsa_get_ctx_params },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS,
|
|
||||||
(void (*)(void))ecdsa_gettable_ctx_params },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS, (void (*)(void))ecdsa_set_ctx_params },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS,
|
|
||||||
(void (*)(void))ecdsa_settable_ctx_params },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS,
|
|
||||||
(void (*)(void))ecdsa_get_ctx_md_params },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS,
|
|
||||||
(void (*)(void))ecdsa_gettable_ctx_md_params },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS,
|
|
||||||
(void (*)(void))ecdsa_set_ctx_md_params },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS,
|
|
||||||
(void (*)(void))ecdsa_settable_ctx_md_params },
|
|
||||||
{ 0, NULL }
|
|
||||||
};
|
|
||||||
-467
@@ -1,467 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020-2022 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 <openssl/crypto.h>
|
|
||||||
#include <openssl/core_dispatch.h>
|
|
||||||
#include <openssl/core_names.h>
|
|
||||||
#include <openssl/err.h>
|
|
||||||
#include <openssl/params.h>
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
#include <openssl/proverr.h>
|
|
||||||
#include "internal/nelem.h"
|
|
||||||
#include "internal/sizes.h"
|
|
||||||
#include "prov/providercommon.h"
|
|
||||||
#include "prov/implementations.h"
|
|
||||||
#include "prov/provider_ctx.h"
|
|
||||||
#include "prov/der_ecx.h"
|
|
||||||
#include "crypto/ecx.h"
|
|
||||||
|
|
||||||
#ifdef S390X_EC_ASM
|
|
||||||
# include "s390x_arch.h"
|
|
||||||
|
|
||||||
# define S390X_CAN_SIGN(edtype) \
|
|
||||||
((OPENSSL_s390xcap_P.pcc[1] & S390X_CAPBIT(S390X_SCALAR_MULTIPLY_##edtype)) \
|
|
||||||
&& (OPENSSL_s390xcap_P.kdsa[0] & S390X_CAPBIT(S390X_EDDSA_SIGN_##edtype)) \
|
|
||||||
&& (OPENSSL_s390xcap_P.kdsa[0] & S390X_CAPBIT(S390X_EDDSA_VERIFY_##edtype)))
|
|
||||||
|
|
||||||
static int s390x_ed25519_digestsign(const ECX_KEY *edkey, unsigned char *sig,
|
|
||||||
const unsigned char *tbs, size_t tbslen);
|
|
||||||
static int s390x_ed448_digestsign(const ECX_KEY *edkey, unsigned char *sig,
|
|
||||||
const unsigned char *tbs, size_t tbslen);
|
|
||||||
static int s390x_ed25519_digestverify(const ECX_KEY *edkey,
|
|
||||||
const unsigned char *sig,
|
|
||||||
const unsigned char *tbs, size_t tbslen);
|
|
||||||
static int s390x_ed448_digestverify(const ECX_KEY *edkey,
|
|
||||||
const unsigned char *sig,
|
|
||||||
const unsigned char *tbs, size_t tbslen);
|
|
||||||
|
|
||||||
#endif /* S390X_EC_ASM */
|
|
||||||
|
|
||||||
static OSSL_FUNC_signature_newctx_fn eddsa_newctx;
|
|
||||||
static OSSL_FUNC_signature_digest_sign_init_fn eddsa_digest_signverify_init;
|
|
||||||
static OSSL_FUNC_signature_digest_sign_fn ed25519_digest_sign;
|
|
||||||
static OSSL_FUNC_signature_digest_sign_fn ed448_digest_sign;
|
|
||||||
static OSSL_FUNC_signature_digest_verify_fn ed25519_digest_verify;
|
|
||||||
static OSSL_FUNC_signature_digest_verify_fn ed448_digest_verify;
|
|
||||||
static OSSL_FUNC_signature_freectx_fn eddsa_freectx;
|
|
||||||
static OSSL_FUNC_signature_dupctx_fn eddsa_dupctx;
|
|
||||||
static OSSL_FUNC_signature_get_ctx_params_fn eddsa_get_ctx_params;
|
|
||||||
static OSSL_FUNC_signature_gettable_ctx_params_fn eddsa_gettable_ctx_params;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
OSSL_LIB_CTX *libctx;
|
|
||||||
ECX_KEY *key;
|
|
||||||
|
|
||||||
/* The Algorithm Identifier of the signature algorithm */
|
|
||||||
unsigned char aid_buf[OSSL_MAX_ALGORITHM_ID_SIZE];
|
|
||||||
unsigned char *aid;
|
|
||||||
size_t aid_len;
|
|
||||||
} PROV_EDDSA_CTX;
|
|
||||||
|
|
||||||
static void *eddsa_newctx(void *provctx, const char *propq_unused)
|
|
||||||
{
|
|
||||||
PROV_EDDSA_CTX *peddsactx;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
peddsactx = OPENSSL_zalloc(sizeof(PROV_EDDSA_CTX));
|
|
||||||
if (peddsactx == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
peddsactx->libctx = PROV_LIBCTX_OF(provctx);
|
|
||||||
|
|
||||||
return peddsactx;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int eddsa_digest_signverify_init(void *vpeddsactx, const char *mdname,
|
|
||||||
void *vedkey,
|
|
||||||
ossl_unused const OSSL_PARAM params[])
|
|
||||||
{
|
|
||||||
PROV_EDDSA_CTX *peddsactx = (PROV_EDDSA_CTX *)vpeddsactx;
|
|
||||||
ECX_KEY *edkey = (ECX_KEY *)vedkey;
|
|
||||||
WPACKET pkt;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (mdname != NULL && mdname[0] != '\0') {
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_DIGEST);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (edkey == NULL) {
|
|
||||||
if (peddsactx->key != NULL)
|
|
||||||
/* there is nothing to do on reinit */
|
|
||||||
return 1;
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_NO_KEY_SET);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ossl_ecx_key_up_ref(edkey)) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We do not care about DER writing errors.
|
|
||||||
* All it really means is that for some reason, there's no
|
|
||||||
* AlgorithmIdentifier to be had, but the operation itself is
|
|
||||||
* still valid, just as long as it's not used to construct
|
|
||||||
* anything that needs an AlgorithmIdentifier.
|
|
||||||
*/
|
|
||||||
peddsactx->aid_len = 0;
|
|
||||||
ret = WPACKET_init_der(&pkt, peddsactx->aid_buf, sizeof(peddsactx->aid_buf));
|
|
||||||
switch (edkey->type) {
|
|
||||||
case ECX_KEY_TYPE_ED25519:
|
|
||||||
ret = ret && ossl_DER_w_algorithmIdentifier_ED25519(&pkt, -1, edkey);
|
|
||||||
break;
|
|
||||||
case ECX_KEY_TYPE_ED448:
|
|
||||||
ret = ret && ossl_DER_w_algorithmIdentifier_ED448(&pkt, -1, edkey);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* Should never happen */
|
|
||||||
ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
|
|
||||||
ossl_ecx_key_free(edkey);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (ret && WPACKET_finish(&pkt)) {
|
|
||||||
WPACKET_get_total_written(&pkt, &peddsactx->aid_len);
|
|
||||||
peddsactx->aid = WPACKET_get_curr(&pkt);
|
|
||||||
}
|
|
||||||
WPACKET_cleanup(&pkt);
|
|
||||||
|
|
||||||
peddsactx->key = edkey;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ed25519_digest_sign(void *vpeddsactx, unsigned char *sigret,
|
|
||||||
size_t *siglen, size_t sigsize,
|
|
||||||
const unsigned char *tbs, size_t tbslen)
|
|
||||||
{
|
|
||||||
PROV_EDDSA_CTX *peddsactx = (PROV_EDDSA_CTX *)vpeddsactx;
|
|
||||||
const ECX_KEY *edkey = peddsactx->key;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (sigret == NULL) {
|
|
||||||
*siglen = ED25519_SIGSIZE;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (sigsize < ED25519_SIGSIZE) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (edkey->privkey == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PRIVATE_KEY);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#ifdef S390X_EC_ASM
|
|
||||||
if (S390X_CAN_SIGN(ED25519)) {
|
|
||||||
if (s390x_ed25519_digestsign(edkey, sigret, tbs, tbslen) == 0) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SIGN);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*siglen = ED25519_SIGSIZE;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif /* S390X_EC_ASM */
|
|
||||||
if (ossl_ed25519_sign(sigret, tbs, tbslen, edkey->pubkey, edkey->privkey,
|
|
||||||
peddsactx->libctx, NULL) == 0) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SIGN);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*siglen = ED25519_SIGSIZE;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ed448_digest_sign(void *vpeddsactx, unsigned char *sigret,
|
|
||||||
size_t *siglen, size_t sigsize,
|
|
||||||
const unsigned char *tbs, size_t tbslen)
|
|
||||||
{
|
|
||||||
PROV_EDDSA_CTX *peddsactx = (PROV_EDDSA_CTX *)vpeddsactx;
|
|
||||||
const ECX_KEY *edkey = peddsactx->key;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (sigret == NULL) {
|
|
||||||
*siglen = ED448_SIGSIZE;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (sigsize < ED448_SIGSIZE) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (edkey->privkey == NULL) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PRIVATE_KEY);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#ifdef S390X_EC_ASM
|
|
||||||
if (S390X_CAN_SIGN(ED448)) {
|
|
||||||
if (s390x_ed448_digestsign(edkey, sigret, tbs, tbslen) == 0) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SIGN);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*siglen = ED448_SIGSIZE;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif /* S390X_EC_ASM */
|
|
||||||
if (ossl_ed448_sign(peddsactx->libctx, sigret, tbs, tbslen, edkey->pubkey,
|
|
||||||
edkey->privkey, NULL, 0, edkey->propq) == 0) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SIGN);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*siglen = ED448_SIGSIZE;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ed25519_digest_verify(void *vpeddsactx, const unsigned char *sig,
|
|
||||||
size_t siglen, const unsigned char *tbs,
|
|
||||||
size_t tbslen)
|
|
||||||
{
|
|
||||||
PROV_EDDSA_CTX *peddsactx = (PROV_EDDSA_CTX *)vpeddsactx;
|
|
||||||
const ECX_KEY *edkey = peddsactx->key;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running() || siglen != ED25519_SIGSIZE)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#ifdef S390X_EC_ASM
|
|
||||||
if (S390X_CAN_SIGN(ED25519))
|
|
||||||
return s390x_ed25519_digestverify(edkey, sig, tbs, tbslen);
|
|
||||||
#endif /* S390X_EC_ASM */
|
|
||||||
|
|
||||||
return ossl_ed25519_verify(tbs, tbslen, sig, edkey->pubkey,
|
|
||||||
peddsactx->libctx, edkey->propq);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ed448_digest_verify(void *vpeddsactx, const unsigned char *sig,
|
|
||||||
size_t siglen, const unsigned char *tbs,
|
|
||||||
size_t tbslen)
|
|
||||||
{
|
|
||||||
PROV_EDDSA_CTX *peddsactx = (PROV_EDDSA_CTX *)vpeddsactx;
|
|
||||||
const ECX_KEY *edkey = peddsactx->key;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running() || siglen != ED448_SIGSIZE)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#ifdef S390X_EC_ASM
|
|
||||||
if (S390X_CAN_SIGN(ED448))
|
|
||||||
return s390x_ed448_digestverify(edkey, sig, tbs, tbslen);
|
|
||||||
#endif /* S390X_EC_ASM */
|
|
||||||
|
|
||||||
return ossl_ed448_verify(peddsactx->libctx, tbs, tbslen, sig, edkey->pubkey,
|
|
||||||
NULL, 0, edkey->propq);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void eddsa_freectx(void *vpeddsactx)
|
|
||||||
{
|
|
||||||
PROV_EDDSA_CTX *peddsactx = (PROV_EDDSA_CTX *)vpeddsactx;
|
|
||||||
|
|
||||||
ossl_ecx_key_free(peddsactx->key);
|
|
||||||
|
|
||||||
OPENSSL_free(peddsactx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *eddsa_dupctx(void *vpeddsactx)
|
|
||||||
{
|
|
||||||
PROV_EDDSA_CTX *srcctx = (PROV_EDDSA_CTX *)vpeddsactx;
|
|
||||||
PROV_EDDSA_CTX *dstctx;
|
|
||||||
|
|
||||||
if (!ossl_prov_is_running())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
dstctx = OPENSSL_zalloc(sizeof(*srcctx));
|
|
||||||
if (dstctx == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
*dstctx = *srcctx;
|
|
||||||
dstctx->key = NULL;
|
|
||||||
|
|
||||||
if (srcctx->key != NULL && !ossl_ecx_key_up_ref(srcctx->key)) {
|
|
||||||
ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
dstctx->key = srcctx->key;
|
|
||||||
|
|
||||||
return dstctx;
|
|
||||||
err:
|
|
||||||
eddsa_freectx(dstctx);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int eddsa_get_ctx_params(void *vpeddsactx, OSSL_PARAM *params)
|
|
||||||
{
|
|
||||||
PROV_EDDSA_CTX *peddsactx = (PROV_EDDSA_CTX *)vpeddsactx;
|
|
||||||
OSSL_PARAM *p;
|
|
||||||
|
|
||||||
if (peddsactx == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_ALGORITHM_ID);
|
|
||||||
if (p != NULL && !OSSL_PARAM_set_octet_string(p, peddsactx->aid,
|
|
||||||
peddsactx->aid_len))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const OSSL_PARAM known_gettable_ctx_params[] = {
|
|
||||||
OSSL_PARAM_octet_string(OSSL_SIGNATURE_PARAM_ALGORITHM_ID, NULL, 0),
|
|
||||||
OSSL_PARAM_END
|
|
||||||
};
|
|
||||||
|
|
||||||
static const OSSL_PARAM *eddsa_gettable_ctx_params(ossl_unused void *vpeddsactx,
|
|
||||||
ossl_unused void *provctx)
|
|
||||||
{
|
|
||||||
return known_gettable_ctx_params;
|
|
||||||
}
|
|
||||||
|
|
||||||
const OSSL_DISPATCH ossl_ed25519_signature_functions[] = {
|
|
||||||
{ OSSL_FUNC_SIGNATURE_NEWCTX, (void (*)(void))eddsa_newctx },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT,
|
|
||||||
(void (*)(void))eddsa_digest_signverify_init },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_SIGN,
|
|
||||||
(void (*)(void))ed25519_digest_sign },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT,
|
|
||||||
(void (*)(void))eddsa_digest_signverify_init },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_VERIFY,
|
|
||||||
(void (*)(void))ed25519_digest_verify },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_FREECTX, (void (*)(void))eddsa_freectx },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DUPCTX, (void (*)(void))eddsa_dupctx },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS, (void (*)(void))eddsa_get_ctx_params },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS,
|
|
||||||
(void (*)(void))eddsa_gettable_ctx_params },
|
|
||||||
{ 0, NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
const OSSL_DISPATCH ossl_ed448_signature_functions[] = {
|
|
||||||
{ OSSL_FUNC_SIGNATURE_NEWCTX, (void (*)(void))eddsa_newctx },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT,
|
|
||||||
(void (*)(void))eddsa_digest_signverify_init },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_SIGN,
|
|
||||||
(void (*)(void))ed448_digest_sign },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT,
|
|
||||||
(void (*)(void))eddsa_digest_signverify_init },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DIGEST_VERIFY,
|
|
||||||
(void (*)(void))ed448_digest_verify },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_FREECTX, (void (*)(void))eddsa_freectx },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_DUPCTX, (void (*)(void))eddsa_dupctx },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS, (void (*)(void))eddsa_get_ctx_params },
|
|
||||||
{ OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS,
|
|
||||||
(void (*)(void))eddsa_gettable_ctx_params },
|
|
||||||
{ 0, NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef S390X_EC_ASM
|
|
||||||
|
|
||||||
static int s390x_ed25519_digestsign(const ECX_KEY *edkey, unsigned char *sig,
|
|
||||||
const unsigned char *tbs, size_t tbslen)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
unsigned char sig[64];
|
|
||||||
unsigned char priv[32];
|
|
||||||
} ed25519;
|
|
||||||
unsigned long long buff[512];
|
|
||||||
} param;
|
|
||||||
|
|
||||||
memset(¶m, 0, sizeof(param));
|
|
||||||
memcpy(param.ed25519.priv, edkey->privkey, sizeof(param.ed25519.priv));
|
|
||||||
|
|
||||||
rc = s390x_kdsa(S390X_EDDSA_SIGN_ED25519, ¶m.ed25519, tbs, tbslen);
|
|
||||||
OPENSSL_cleanse(param.ed25519.priv, sizeof(param.ed25519.priv));
|
|
||||||
if (rc != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
s390x_flip_endian32(sig, param.ed25519.sig);
|
|
||||||
s390x_flip_endian32(sig + 32, param.ed25519.sig + 32);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int s390x_ed448_digestsign(const ECX_KEY *edkey, unsigned char *sig,
|
|
||||||
const unsigned char *tbs, size_t tbslen)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
unsigned char sig[128];
|
|
||||||
unsigned char priv[64];
|
|
||||||
} ed448;
|
|
||||||
unsigned long long buff[512];
|
|
||||||
} param;
|
|
||||||
|
|
||||||
memset(¶m, 0, sizeof(param));
|
|
||||||
memcpy(param.ed448.priv + 64 - 57, edkey->privkey, 57);
|
|
||||||
|
|
||||||
rc = s390x_kdsa(S390X_EDDSA_SIGN_ED448, ¶m.ed448, tbs, tbslen);
|
|
||||||
OPENSSL_cleanse(param.ed448.priv, sizeof(param.ed448.priv));
|
|
||||||
if (rc != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
s390x_flip_endian64(param.ed448.sig, param.ed448.sig);
|
|
||||||
s390x_flip_endian64(param.ed448.sig + 64, param.ed448.sig + 64);
|
|
||||||
memcpy(sig, param.ed448.sig, 57);
|
|
||||||
memcpy(sig + 57, param.ed448.sig + 64, 57);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int s390x_ed25519_digestverify(const ECX_KEY *edkey,
|
|
||||||
const unsigned char *sig,
|
|
||||||
const unsigned char *tbs, size_t tbslen)
|
|
||||||
{
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
unsigned char sig[64];
|
|
||||||
unsigned char pub[32];
|
|
||||||
} ed25519;
|
|
||||||
unsigned long long buff[512];
|
|
||||||
} param;
|
|
||||||
|
|
||||||
memset(¶m, 0, sizeof(param));
|
|
||||||
s390x_flip_endian32(param.ed25519.sig, sig);
|
|
||||||
s390x_flip_endian32(param.ed25519.sig + 32, sig + 32);
|
|
||||||
s390x_flip_endian32(param.ed25519.pub, edkey->pubkey);
|
|
||||||
|
|
||||||
return s390x_kdsa(S390X_EDDSA_VERIFY_ED25519,
|
|
||||||
¶m.ed25519, tbs, tbslen) == 0 ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int s390x_ed448_digestverify(const ECX_KEY *edkey,
|
|
||||||
const unsigned char *sig,
|
|
||||||
const unsigned char *tbs,
|
|
||||||
size_t tbslen)
|
|
||||||
{
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
unsigned char sig[128];
|
|
||||||
unsigned char pub[64];
|
|
||||||
} ed448;
|
|
||||||
unsigned long long buff[512];
|
|
||||||
} param;
|
|
||||||
|
|
||||||
memset(¶m, 0, sizeof(param));
|
|
||||||
memcpy(param.ed448.sig, sig, 57);
|
|
||||||
s390x_flip_endian64(param.ed448.sig, param.ed448.sig);
|
|
||||||
memcpy(param.ed448.sig + 64, sig + 57, 57);
|
|
||||||
s390x_flip_endian64(param.ed448.sig + 64, param.ed448.sig + 64);
|
|
||||||
memcpy(param.ed448.pub, edkey->pubkey, 57);
|
|
||||||
s390x_flip_endian64(param.ed448.pub, param.ed448.pub);
|
|
||||||
|
|
||||||
return s390x_kdsa(S390X_EDDSA_VERIFY_ED448,
|
|
||||||
¶m.ed448, tbs, tbslen) == 0 ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* S390X_EC_ASM */
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user