mirror of https://github.com/openssl/openssl.git
Compare commits
7 Commits
2189425d54
...
ddfefc0a8e
| Author | SHA1 | Date |
|---|---|---|
|
|
ddfefc0a8e | |
|
|
296f1f6dd8 | |
|
|
fd7fc90346 | |
|
|
fcb5e20ac7 | |
|
|
b9ff440dd6 | |
|
|
f77fafd16e | |
|
|
584934f965 |
|
|
@ -93,7 +93,6 @@ EOF
|
|||
|
||||
my %cmd_disabler = (
|
||||
ciphers => "sock",
|
||||
genrsa => "rsa",
|
||||
gendsa => "dsa",
|
||||
dsaparam => "dsa",
|
||||
gendh => "dh",
|
||||
|
|
@ -107,7 +106,7 @@ EOF
|
|||
# [2] = preprocessor conditional for excluding irrespective of deprecation
|
||||
# rsa => [ "pkey", "3_0", "rsa" ],
|
||||
# genrsa => [ "genpkey", "3_0", "rsa" ],
|
||||
rsautl => [ "pkeyutl", "3_0", "rsa" ],
|
||||
rsautl => [ "pkeyutl", "3_0", "" ],
|
||||
# dhparam => [ "pkeyparam", "3_0", "dh" ],
|
||||
# dsaparam => [ "pkeyparam", "3_0", "dsa" ],
|
||||
# dsa => [ "pkey", "3_0", "dsa" ],
|
||||
|
|
|
|||
|
|
@ -0,0 +1,446 @@
|
|||
#! /usr/bin/env perl
|
||||
# Copyright 2025 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
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FindBin qw($Bin);
|
||||
use lib "$Bin";
|
||||
use lib "$Bin/../../perlasm";
|
||||
use riscv;
|
||||
|
||||
my $output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
my $flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
$output and open STDOUT,">$output";
|
||||
|
||||
################################################################################
|
||||
# Utility functions to help with keeping track of which registers to stack/
|
||||
# unstack when entering / exiting routines.
|
||||
################################################################################
|
||||
{
|
||||
# Callee-saved registers
|
||||
my @callee_saved = map("x$_",(2,8,9,18..27));
|
||||
# Caller-saved registers
|
||||
my @caller_saved = map("x$_",(1,5..7,10..17,28..31));
|
||||
my @must_save;
|
||||
sub use_reg {
|
||||
my $reg = shift;
|
||||
if (grep(/^$reg$/, @callee_saved)) {
|
||||
push(@must_save, $reg);
|
||||
} elsif (!grep(/^$reg$/, @caller_saved)) {
|
||||
# Register is not usable!
|
||||
die("Unusable register ".$reg);
|
||||
}
|
||||
return $reg;
|
||||
}
|
||||
sub use_regs {
|
||||
return map(use_reg("x$_"), @_);
|
||||
}
|
||||
sub save_regs {
|
||||
my $ret = '';
|
||||
my $stack_reservation = ($#must_save + 1) * 8;
|
||||
my $stack_offset = $stack_reservation;
|
||||
if ($stack_reservation % 16) {
|
||||
$stack_reservation += 8;
|
||||
}
|
||||
$ret.=" addi sp,sp,-$stack_reservation\n";
|
||||
foreach (@must_save) {
|
||||
$stack_offset -= 8;
|
||||
$ret.=" sd $_,$stack_offset(sp)\n";
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
sub load_regs {
|
||||
my $ret = '';
|
||||
my $stack_reservation = ($#must_save + 1) * 8;
|
||||
my $stack_offset = $stack_reservation;
|
||||
if ($stack_reservation % 16) {
|
||||
$stack_reservation += 8;
|
||||
}
|
||||
foreach (@must_save) {
|
||||
$stack_offset -= 8;
|
||||
$ret.=" ld $_,$stack_offset(sp)\n";
|
||||
}
|
||||
$ret.=" addi sp,sp,$stack_reservation\n";
|
||||
return $ret;
|
||||
}
|
||||
sub clear_regs {
|
||||
@must_save = ();
|
||||
}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Register assignment
|
||||
################################################################################
|
||||
|
||||
# Function arguments
|
||||
# RISC-V ABI
|
||||
# $rp x10 a0 # BN_ULONG *rp
|
||||
# $ap x11 a1 # const BN_ULONG *ap
|
||||
# $bp x12 a2 # const BN_ULONG *bp
|
||||
# $np x13 a3 # const BN_ULONG *np
|
||||
# $n0 x14 a4 # const BN_ULONG *n0
|
||||
# $num x15 a5 # int num
|
||||
my ($rp,$ap,$bp,$np,$n0,$num) = use_regs(10, 11, 12, 13, 14, 15);
|
||||
|
||||
# Return address and Frame pointer
|
||||
# RISC-V ABI
|
||||
# $ra x1 ra
|
||||
# $fp x8 s0
|
||||
my ($ra,$fp) = use_regs(1,8);
|
||||
|
||||
# Temporary variable allocation
|
||||
# RISC-V ABI
|
||||
# $lo0 x5 t0
|
||||
# $hi0 x6 t1
|
||||
# $aj x7 t2
|
||||
# $m0 x28 t3
|
||||
# $alo x29 t4
|
||||
# $ahi x30 t5
|
||||
# $lo1 x31 t6
|
||||
# $hi1 x18 s2
|
||||
# $nj x19 s3
|
||||
# $m1 x20 s4
|
||||
# $nlo x21 s5
|
||||
# $nhi x22 s6
|
||||
# $ovf x23 s7
|
||||
# $i x24 s8
|
||||
# $j x25 s9
|
||||
# $tp x26 s10
|
||||
# $tj x27 s11
|
||||
# $temp x9 s1
|
||||
my ($lo0, $hi0, $aj, $m0, $alo, $ahi,$lo1, $hi1, $nj, $m1, $nlo, $nhi, $ovf, $i, $j, $tp, $tj, $temp) = use_regs(5..7, 28..31, 18..27, 9);
|
||||
|
||||
# Carry variable
|
||||
# $carry1 x16 a6
|
||||
# $carry2 x17 a7
|
||||
my ($carry1,$carry2) = use_regs(16,17);
|
||||
|
||||
my $code .= <<___;
|
||||
.text
|
||||
.balign 32
|
||||
.globl bn_mul_mont
|
||||
.type bn_mul_mont,\@function
|
||||
bn_mul_mont:
|
||||
___
|
||||
|
||||
$code .= save_regs();
|
||||
|
||||
$code .= <<___;
|
||||
|
||||
mv s0, sp
|
||||
___
|
||||
|
||||
$code .= <<___;
|
||||
|
||||
.Lmul_mont:
|
||||
ld $m0, 0($bp)
|
||||
addi $bp, $bp, 8
|
||||
slli $temp, $num, 3
|
||||
sub $tp, sp, $temp
|
||||
ld $hi0, 0($ap)
|
||||
ld $aj, 8($ap)
|
||||
addi $ap, $ap, 16
|
||||
slli $num, $num, 3
|
||||
ld $n0, 0($n0)
|
||||
andi $tp, $tp, -16
|
||||
ld $hi1, 0($np)
|
||||
ld $nj, 8($np)
|
||||
addi $np, $np, 16
|
||||
|
||||
mul $lo0, $hi0, $m0
|
||||
addi $j, $num, -16
|
||||
mulhu $hi0, $hi0, $m0
|
||||
mul $alo, $aj, $m0
|
||||
mulhu $ahi, $aj, $m0
|
||||
|
||||
mul $m1, $lo0, $n0
|
||||
mv sp, $tp
|
||||
|
||||
mulhu $hi1, $hi1, $m1
|
||||
mul $nlo, $nj, $m1
|
||||
|
||||
snez $carry1,$lo0
|
||||
mulhu $nhi, $nj, $m1
|
||||
add $hi1, $hi1, $carry1
|
||||
beqz $j, .L1st_skip
|
||||
.L1st:
|
||||
ld $aj, 0($ap)
|
||||
addi $ap, $ap, 8
|
||||
add $lo0, $alo, $hi0
|
||||
sltu $carry1,$lo0,$alo
|
||||
addi $j, $j, -8
|
||||
add $hi0,$ahi,$carry1
|
||||
|
||||
ld $nj, 0($np)
|
||||
addi $np, $np, 8
|
||||
add $lo1, $nlo, $hi1
|
||||
sltu $carry1,$lo1,$nlo
|
||||
mul $alo, $aj, $m0
|
||||
add $hi1, $nhi, $carry1
|
||||
mulhu $ahi, $aj, $m0
|
||||
|
||||
|
||||
add $temp, $lo1, $lo0
|
||||
sltu $carry1,$temp,$lo1
|
||||
mv $lo1, $temp
|
||||
|
||||
mul $nlo,$nj,$m1
|
||||
add $hi1, $hi1, $carry1
|
||||
mulhu $nhi, $nj, $m1
|
||||
sd $lo1, 0($tp)
|
||||
addi $tp, $tp, 8
|
||||
bnez $j, .L1st
|
||||
|
||||
.L1st_skip:
|
||||
add $lo0,$alo,$hi0
|
||||
sltu $carry1, $lo0, $alo
|
||||
sub $ap,$ap,$num
|
||||
add $hi0,$ahi,$carry1
|
||||
|
||||
add $lo1,$nlo,$hi1
|
||||
sltu $carry1, $lo1,$nlo
|
||||
sub $np,$np,$num
|
||||
add $hi1,$nhi,$carry1
|
||||
|
||||
add $lo1, $lo1,$lo0
|
||||
sltu $carry1, $lo1, $lo0
|
||||
addi $i,$num, -8
|
||||
|
||||
add $temp, $hi1, $hi0
|
||||
sltu $carry2, $temp, $hi1
|
||||
add $hi1, $temp, $carry1
|
||||
sltu $ovf, $hi1, $temp
|
||||
or $carry1,$carry2,$ovf
|
||||
|
||||
mv $ovf, $carry1
|
||||
|
||||
sd $lo1, 0($tp)
|
||||
sd $hi1, 8($tp)
|
||||
|
||||
.Louter:
|
||||
ld $m0, 0($bp)
|
||||
addi $bp, $bp, 8
|
||||
ld $hi0, 0($ap)
|
||||
ld $aj, 8($ap)
|
||||
addi $ap, $ap, 16
|
||||
ld $tj, 0(sp)
|
||||
addi $tp, sp, 8
|
||||
|
||||
mul $lo0,$hi0,$m0
|
||||
addi $j,$num,-16
|
||||
|
||||
mulhu $hi0,$hi0,$m0
|
||||
ld $hi1, 0($np)
|
||||
ld $nj, 8($np)
|
||||
addi $np, $np, 16
|
||||
mul $alo,$aj,$m0
|
||||
add $lo0,$lo0,$tj
|
||||
sltu $carry1, $lo0,$tj
|
||||
mulhu $ahi, $aj, $m0
|
||||
add $hi0, $hi0, $carry1
|
||||
|
||||
mul $m1,$lo0, $n0
|
||||
addi $i, $i, -8
|
||||
|
||||
|
||||
mulhu $hi1, $hi1, $m1
|
||||
mul $nlo,$nj,$m1
|
||||
|
||||
snez $carry1, $lo0
|
||||
mulhu $nhi,$nj,$m1
|
||||
beqz $j, .Linner_skip
|
||||
|
||||
.Linner:
|
||||
ld $aj, 0($ap)
|
||||
addi $ap, $ap, 8
|
||||
add $hi1, $hi1, $carry1
|
||||
|
||||
ld $tj, 0($tp)
|
||||
addi $tp, $tp, 8
|
||||
add $lo0, $alo, $hi0
|
||||
sltu $carry1, $lo0, $alo
|
||||
addi $j, $j, -8
|
||||
|
||||
add $hi0, $ahi, $carry1
|
||||
|
||||
add $lo1, $nlo,$hi1
|
||||
sltu $carry1, $lo1, $nlo
|
||||
|
||||
ld $nj, 0($np)
|
||||
addi $np, $np, 8
|
||||
|
||||
add $hi1,$nhi,$carry1
|
||||
|
||||
mul $alo, $aj, $m0
|
||||
|
||||
add $lo0, $lo0, $tj
|
||||
sltu $carry1, $lo0, $tj
|
||||
|
||||
mulhu $ahi, $aj,$m0
|
||||
|
||||
add $hi0, $hi0, $carry1
|
||||
|
||||
mul $nlo,$nj,$m1
|
||||
|
||||
add $lo1, $lo1, $lo0
|
||||
sltu $carry1, $lo1, $lo0
|
||||
|
||||
mulhu $nhi,$nj,$m1
|
||||
sd $lo1, -16($tp)
|
||||
bnez $j, .Linner
|
||||
|
||||
.Linner_skip:
|
||||
ld $tj, 0($tp)
|
||||
addi $tp, $tp, 8
|
||||
|
||||
add $hi1, $hi1, $carry1
|
||||
|
||||
add $lo0, $alo, $hi0
|
||||
sltu $carry1, $lo0, $alo
|
||||
|
||||
sub $ap,$ap,$num
|
||||
add $hi0,$ahi,$carry1
|
||||
|
||||
add $lo1,$nlo,$hi1
|
||||
sltu $carry1, $lo1, $nlo
|
||||
|
||||
sub $np,$np,$num
|
||||
|
||||
add $temp, $nhi, $ovf
|
||||
sltu $carry2, $temp, $nhi
|
||||
add $hi1, $temp, $carry1
|
||||
sltu $ovf, $hi1, $temp
|
||||
or $carry1, $carry2, $ovf
|
||||
|
||||
mv $ovf, $carry1
|
||||
|
||||
add $lo0,$lo0,$tj
|
||||
sltu $carry1, $lo0, $tj
|
||||
add $hi0, $hi0, $carry1
|
||||
|
||||
add $lo1,$lo1,$lo0
|
||||
sltu $carry1, $lo1,$lo0
|
||||
|
||||
add $temp, $hi1, $hi0
|
||||
sltu $carry2, $temp, $hi1
|
||||
add $hi1, $temp, $carry1
|
||||
sltu $carry1, $hi1, $temp
|
||||
or $carry1, $carry2, $carry1
|
||||
|
||||
add $ovf,$ovf,$carry1
|
||||
|
||||
sd $lo1, -16($tp)
|
||||
sd $hi1, -8($tp)
|
||||
|
||||
bnez $i, .Louter
|
||||
|
||||
ld $tj,0(sp) # tj = [sp] (tp[0])
|
||||
|
||||
addi $tp, sp, 8
|
||||
|
||||
ld $nj, 0($np)
|
||||
addi $np, $np, 8
|
||||
|
||||
addi $j,$num,-8
|
||||
sltu $carry1,$num,8
|
||||
xori $carry1,$carry1,1
|
||||
|
||||
mv $ap,$rp
|
||||
.Lsub:
|
||||
xori $carry1,$carry1,1
|
||||
sub $temp,$tj,$nj
|
||||
sltu $carry2,$tj,$temp
|
||||
sub $aj,$temp,$carry1
|
||||
sltu $carry1,$temp,$aj
|
||||
or $carry1,$carry2,$carry1
|
||||
xori $carry1,$carry1,1
|
||||
|
||||
ld $tj, 0($tp)
|
||||
addi s10, s10, 8
|
||||
|
||||
addi $j,$j,-8
|
||||
|
||||
ld $nj, 0($np)
|
||||
addi $np, $np, 8
|
||||
|
||||
sd $aj, 0($ap)
|
||||
addi $ap, $ap, 8
|
||||
|
||||
bnez $j, .Lsub
|
||||
|
||||
xori $carry1,$carry1,1
|
||||
sub $temp,$tj,$nj
|
||||
sltu $carry2,$tj,$temp
|
||||
sub $aj,$temp,$carry1
|
||||
sltu $carry1,$temp,$aj
|
||||
or $carry1,$carry2,$carry1
|
||||
xori $carry1,$carry1,1
|
||||
|
||||
xori $carry1,$carry1,1
|
||||
sub $temp,$ovf,zero
|
||||
sltu $carry2,$ovf,$temp
|
||||
sub $ovf,$temp,$carry1
|
||||
sltu $carry1,$temp,$ovf
|
||||
or $carry1,$carry2,$carry1
|
||||
xori $carry1,$carry1,1
|
||||
|
||||
sd $aj, 0($ap)
|
||||
addi $ap, $ap, 8
|
||||
ld $tj, 0(sp)
|
||||
addi $tp, sp, 8
|
||||
ld $aj, 0($rp)
|
||||
addi $rp, $rp, 8
|
||||
addi $num,$num,-8
|
||||
nop
|
||||
.Lcond_copy:
|
||||
addi $num,$num, -8
|
||||
bnez $carry1,.set_aj1
|
||||
mv $nj,$tj
|
||||
j .end1
|
||||
.set_aj1:
|
||||
mv $nj,$aj
|
||||
.end1:
|
||||
ld $tj, 0($tp)
|
||||
addi $tp, $tp, 8
|
||||
ld $aj, 0($rp)
|
||||
addi $rp, $rp, 8
|
||||
sd zero, -16($tp)
|
||||
sd $nj, -16($rp)
|
||||
bnez $num, .Lcond_copy
|
||||
|
||||
bnez $carry1,.set_aj2
|
||||
mv $nj,$tj
|
||||
j .end2
|
||||
.set_aj2:
|
||||
mv $nj,$aj
|
||||
.end2:
|
||||
sd zero, -8($tp)
|
||||
sd $nj, -8($rp)
|
||||
___
|
||||
|
||||
$code .= <<___;
|
||||
|
||||
mv sp,s0
|
||||
li a0,1
|
||||
___
|
||||
|
||||
|
||||
$code .= load_regs();
|
||||
|
||||
$code .= <<___;
|
||||
ret
|
||||
.size bn_mul_mont,.-bn_mul_mont
|
||||
___
|
||||
|
||||
print $code;
|
||||
close STDOUT or die "error closing STDOUT: $!";
|
||||
|
|
@ -73,6 +73,9 @@ IF[{- !$disabled{asm} -}]
|
|||
$BNASM_aarch64=bn_asm.c armv8-mont.S
|
||||
$BNDEF_aarch64=OPENSSL_BN_ASM_MONT
|
||||
|
||||
$BNASM_riscv64=bn_asm.c riscv64-mont.S
|
||||
$BNDEF_riscv64=OPENSSL_BN_ASM_MONT
|
||||
|
||||
$BNASM_parisc11=bn_asm.c parisc-mont.s
|
||||
$BNDEF_parisc11=OPENSSL_BN_ASM_MONT
|
||||
$BNASM_parisc20_64=$BNASM_parisc11
|
||||
|
|
@ -182,3 +185,5 @@ GENERATE[armv4-gf2m.S]=asm/armv4-gf2m.pl
|
|||
INCLUDE[armv4-gf2m.o]=..
|
||||
GENERATE[armv8-mont.S]=asm/armv8-mont.pl
|
||||
INCLUDE[armv8-mont.o]=..
|
||||
GENERATE[riscv64-mont.S]=asm/riscv64-mont.pl
|
||||
INCLUDE[riscv64-mont.o]=..
|
||||
|
|
|
|||
|
|
@ -261,10 +261,12 @@ int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,
|
|||
|
||||
cipher = ctx->op.ciph.cipher;
|
||||
desc = cipher->description != NULL ? cipher->description : "";
|
||||
ERR_set_mark();
|
||||
ret = cipher->encrypt(ctx->op.ciph.algctx, out, outlen, (out == NULL ? 0 : *outlen), in, inlen);
|
||||
if (ret <= 0)
|
||||
if (ret <= 0 && ERR_count_to_mark() == 0)
|
||||
ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_ASYM_CIPHER_FAILURE,
|
||||
"%s encrypt:%s", cipher->type_name, desc);
|
||||
ERR_clear_last_mark();
|
||||
return ret;
|
||||
|
||||
legacy:
|
||||
|
|
@ -309,10 +311,12 @@ int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,
|
|||
|
||||
cipher = ctx->op.ciph.cipher;
|
||||
desc = cipher->description != NULL ? cipher->description : "";
|
||||
ERR_set_mark();
|
||||
ret = cipher->decrypt(ctx->op.ciph.algctx, out, outlen, (out == NULL ? 0 : *outlen), in, inlen);
|
||||
if (ret <= 0)
|
||||
if (ret <= 0 && ERR_count_to_mark() == 0)
|
||||
ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_ASYM_CIPHER_FAILURE,
|
||||
"%s decrypt:%s", cipher->type_name, desc);
|
||||
ERR_clear_last_mark();
|
||||
|
||||
return ret;
|
||||
|
||||
|
|
|
|||
|
|
@ -460,10 +460,12 @@ void *evp_keymgmt_gen(const EVP_KEYMGMT *keymgmt, void *genctx,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ERR_set_mark();
|
||||
ret = keymgmt->gen(genctx, cb, cbarg);
|
||||
if (ret == NULL)
|
||||
if (ret == NULL && ERR_count_to_mark() == 0)
|
||||
ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_KEYMGMT_FAILURE,
|
||||
"%s key generation:%s", keymgmt->type_name, desc);
|
||||
ERR_clear_last_mark();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -426,10 +426,12 @@ int EVP_DigestSignUpdate(EVP_MD_CTX *ctx, const void *data, size_t dsize)
|
|||
return 0;
|
||||
}
|
||||
|
||||
ERR_set_mark();
|
||||
ret = signature->digest_sign_update(pctx->op.sig.algctx, data, dsize);
|
||||
if (ret <= 0)
|
||||
if (ret <= 0 && ERR_count_to_mark() == 0)
|
||||
ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_FAILURE,
|
||||
"%s digest_sign_update:%s", signature->type_name, desc);
|
||||
ERR_clear_last_mark();
|
||||
return ret;
|
||||
|
||||
legacy:
|
||||
|
|
@ -474,10 +476,12 @@ int EVP_DigestVerifyUpdate(EVP_MD_CTX *ctx, const void *data, size_t dsize)
|
|||
return 0;
|
||||
}
|
||||
|
||||
ERR_set_mark();
|
||||
ret = signature->digest_verify_update(pctx->op.sig.algctx, data, dsize);
|
||||
if (ret <= 0)
|
||||
if (ret <= 0 && ERR_count_to_mark() == 0)
|
||||
ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_FAILURE,
|
||||
"%s digest_verify_update:%s", signature->type_name, desc);
|
||||
ERR_clear_last_mark();
|
||||
return ret;
|
||||
|
||||
legacy:
|
||||
|
|
@ -527,11 +531,13 @@ int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
|
|||
pctx = dctx;
|
||||
}
|
||||
|
||||
ERR_set_mark();
|
||||
r = signature->digest_sign_final(pctx->op.sig.algctx, sigret, siglen,
|
||||
sigret == NULL ? 0 : *siglen);
|
||||
if (!r)
|
||||
if (!r && ERR_count_to_mark() == 0)
|
||||
ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_FAILURE,
|
||||
"%s digest_sign_final:%s", signature->type_name, desc);
|
||||
ERR_clear_last_mark();
|
||||
if (dctx == NULL && sigret != NULL)
|
||||
ctx->flags |= EVP_MD_CTX_FLAG_FINALISED;
|
||||
else
|
||||
|
|
@ -638,11 +644,13 @@ int EVP_DigestSign(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen,
|
|||
|
||||
if (sigret != NULL)
|
||||
ctx->flags |= EVP_MD_CTX_FLAG_FINALISED;
|
||||
ERR_set_mark();
|
||||
ret = signature->digest_sign(pctx->op.sig.algctx, sigret, siglen,
|
||||
sigret == NULL ? 0 : *siglen, tbs, tbslen);
|
||||
if (ret <= 0)
|
||||
if (ret <= 0 && ERR_count_to_mark() == 0)
|
||||
ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_FAILURE,
|
||||
"%s digest_sign:%s", signature->type_name, desc);
|
||||
ERR_clear_last_mark();
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -693,10 +701,12 @@ int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig,
|
|||
pctx = dctx;
|
||||
}
|
||||
|
||||
ERR_set_mark();
|
||||
r = signature->digest_verify_final(pctx->op.sig.algctx, sig, siglen);
|
||||
if (!r)
|
||||
if (!r && ERR_count_to_mark() == 0)
|
||||
ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_FAILURE,
|
||||
"%s digest_verify_final:%s", signature->type_name, desc);
|
||||
ERR_clear_last_mark();
|
||||
if (dctx == NULL)
|
||||
ctx->flags |= EVP_MD_CTX_FLAG_FINALISED;
|
||||
else
|
||||
|
|
@ -769,10 +779,12 @@ int EVP_DigestVerify(EVP_MD_CTX *ctx, const unsigned char *sigret,
|
|||
int ret;
|
||||
|
||||
ctx->flags |= EVP_MD_CTX_FLAG_FINALISED;
|
||||
ERR_set_mark();
|
||||
ret = signature->digest_verify(pctx->op.sig.algctx, sigret, siglen, tbs, tbslen);
|
||||
if (ret <= 0)
|
||||
if (ret <= 0 && ERR_count_to_mark() == 0)
|
||||
ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_FAILURE,
|
||||
"%s digest_verify:%s", signature->type_name, desc);
|
||||
ERR_clear_last_mark();
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -2419,6 +2419,11 @@ static int core_pop_error_to_mark(const OSSL_CORE_HANDLE *handle)
|
|||
return ERR_pop_to_mark();
|
||||
}
|
||||
|
||||
static int core_count_to_mark(const OSSL_CORE_HANDLE *handle)
|
||||
{
|
||||
return ERR_count_to_mark();
|
||||
}
|
||||
|
||||
static void core_indicator_get_callback(OPENSSL_CORE_CTX *libctx,
|
||||
OSSL_INDICATOR_CALLBACK **cb)
|
||||
{
|
||||
|
|
@ -2600,6 +2605,7 @@ static const OSSL_DISPATCH core_dispatch_[] = {
|
|||
{ OSSL_FUNC_CORE_CLEAR_LAST_ERROR_MARK,
|
||||
(void (*)(void))core_clear_last_error_mark },
|
||||
{ OSSL_FUNC_CORE_POP_ERROR_TO_MARK, (void (*)(void))core_pop_error_to_mark },
|
||||
{ OSSL_FUNC_CORE_COUNT_TO_MARK, (void (*)(void))core_count_to_mark },
|
||||
{ OSSL_FUNC_BIO_NEW_FILE, (void (*)(void))ossl_core_bio_new_file },
|
||||
{ OSSL_FUNC_BIO_NEW_MEMBUF, (void (*)(void))ossl_core_bio_new_mem_buf },
|
||||
{ OSSL_FUNC_BIO_READ_EX, (void (*)(void))ossl_core_bio_read_ex },
|
||||
|
|
|
|||
|
|
@ -154,6 +154,10 @@ provider):
|
|||
core_new_error OSSL_FUNC_CORE_NEW_ERROR
|
||||
core_set_error_debug OSSL_FUNC_CORE_SET_ERROR_DEBUG
|
||||
core_vset_error OSSL_FUNC_CORE_VSET_ERROR
|
||||
core_set_error_mark OSSL_FUNC_CORE_SET_ERROR_MARK
|
||||
core_clear_last_error_mark OSSL_FUNC_CORE_CLEAR_LAST_ERROR_MARK
|
||||
core_pop_error_to_mark OSSL_FUNC_CORE_POP_ERROR_TO_MARK
|
||||
core_count_to_mark OSSL_FUNC_CORE_COUNT_TO_MARK
|
||||
core_obj_add_sigid OSSL_FUNC_CORE_OBJ_ADD_SIGID
|
||||
core_obj_create OSSL_FUNC_CORE_OBJ_CREATE
|
||||
CRYPTO_malloc OSSL_FUNC_CRYPTO_MALLOC
|
||||
|
|
@ -270,6 +274,33 @@ error occurred or was reported.
|
|||
|
||||
This corresponds to the OpenSSL function L<ERR_vset_error(3)>.
|
||||
|
||||
=item core_set_error_mark()
|
||||
|
||||
sets a mark on the current topmost error record if there is one.
|
||||
|
||||
This corresponds to the OpenSSL function L<ERR_set_mark(3)>.
|
||||
|
||||
=item core_clear_last_error_mark()
|
||||
|
||||
removes the last mark added if there is one.
|
||||
|
||||
This corresponds to the OpenSSL function L<ERR_clear_last_mark(3)>.
|
||||
|
||||
=item core_pop_error_to_mark()
|
||||
|
||||
pops the top of the error stack until a mark is found. The mark is then removed.
|
||||
If there is no mark, the whole stack is removed.
|
||||
|
||||
This corresponds to the OpenSSL function L<ERR_pop_to_mark(3)>.
|
||||
|
||||
=item core_count_to_mark()
|
||||
|
||||
returns the number of entries on the error stack above the most recently
|
||||
marked entry, not including that entry. If there is no mark in the error stack,
|
||||
the number of entries in the error stack is returned.
|
||||
|
||||
This corresponds to the OpenSSL function L<ERR_count_to_mark(3)>.
|
||||
|
||||
=back
|
||||
|
||||
The core_obj_create() function registers a new OID and associated short name
|
||||
|
|
|
|||
|
|
@ -590,10 +590,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
|
|||
SSL *server;
|
||||
BIO *in;
|
||||
BIO *out;
|
||||
#if !defined(OPENSSL_NO_EC) \
|
||||
|| (!defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_DEPRECATED_3_0))
|
||||
BIO *bio_buf;
|
||||
#endif
|
||||
SSL_CTX *ctx;
|
||||
int ret;
|
||||
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
|
|
|
|||
|
|
@ -253,6 +253,10 @@ OSSL_CORE_MAKE_FUNC(int, provider_up_ref,
|
|||
OSSL_CORE_MAKE_FUNC(int, provider_free,
|
||||
(const OSSL_CORE_HANDLE *prov, int deactivate))
|
||||
|
||||
/* Additional error functions provided by the core */
|
||||
# define OSSL_FUNC_CORE_COUNT_TO_MARK 120
|
||||
OSSL_CORE_MAKE_FUNC(int, core_count_to_mark, (const OSSL_CORE_HANDLE *prov))
|
||||
|
||||
/* Functions provided by the provider to the Core, reserved numbers 1024-1535 */
|
||||
# define OSSL_FUNC_PROVIDER_TEARDOWN 1024
|
||||
OSSL_CORE_MAKE_FUNC(void, provider_teardown, (void *provctx))
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ static OSSL_FUNC_core_vset_error_fn *c_vset_error;
|
|||
static OSSL_FUNC_core_set_error_mark_fn *c_set_error_mark;
|
||||
static OSSL_FUNC_core_clear_last_error_mark_fn *c_clear_last_error_mark;
|
||||
static OSSL_FUNC_core_pop_error_to_mark_fn *c_pop_error_to_mark;
|
||||
static OSSL_FUNC_core_count_to_mark_fn *c_count_to_mark;
|
||||
static OSSL_FUNC_CRYPTO_malloc_fn *c_CRYPTO_malloc;
|
||||
static OSSL_FUNC_CRYPTO_zalloc_fn *c_CRYPTO_zalloc;
|
||||
static OSSL_FUNC_CRYPTO_free_fn *c_CRYPTO_free;
|
||||
|
|
@ -834,6 +835,9 @@ int OSSL_provider_init_int(const OSSL_CORE_HANDLE *handle,
|
|||
case OSSL_FUNC_CORE_POP_ERROR_TO_MARK:
|
||||
set_func(c_pop_error_to_mark, OSSL_FUNC_core_pop_error_to_mark(in));
|
||||
break;
|
||||
case OSSL_FUNC_CORE_COUNT_TO_MARK:
|
||||
set_func(c_count_to_mark, OSSL_FUNC_core_count_to_mark(in));
|
||||
break;
|
||||
case OSSL_FUNC_CRYPTO_MALLOC:
|
||||
set_func(c_CRYPTO_malloc, OSSL_FUNC_CRYPTO_malloc(in));
|
||||
break;
|
||||
|
|
@ -1072,6 +1076,11 @@ int ERR_pop_to_mark(void)
|
|||
return c_pop_error_to_mark(NULL);
|
||||
}
|
||||
|
||||
int ERR_count_to_mark(void)
|
||||
{
|
||||
return c_count_to_mark != NULL ? c_count_to_mark(NULL) : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This must take a library context, since it's called from the depths
|
||||
* of crypto/initthread.c code, where it's (correctly) assumed that the
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ static OSSL_FUNC_core_vset_error_fn *c_vset_error;
|
|||
static OSSL_FUNC_core_set_error_mark_fn *c_set_error_mark;
|
||||
static OSSL_FUNC_core_clear_last_error_mark_fn *c_clear_last_error_mark;
|
||||
static OSSL_FUNC_core_pop_error_to_mark_fn *c_pop_error_to_mark;
|
||||
static OSSL_FUNC_core_count_to_mark_fn *c_count_to_mark;
|
||||
#endif
|
||||
|
||||
/* Parameters we provide to the core */
|
||||
|
|
@ -234,6 +235,9 @@ int OSSL_provider_init(const OSSL_CORE_HANDLE *handle,
|
|||
case OSSL_FUNC_CORE_POP_ERROR_TO_MARK:
|
||||
set_func(c_pop_error_to_mark, OSSL_FUNC_core_pop_error_to_mark(tmp));
|
||||
break;
|
||||
case OSSL_FUNC_CORE_COUNT_TO_MARK:
|
||||
set_func(c_count_to_mark, OSSL_FUNC_core_count_to_mark(in));
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -301,4 +305,9 @@ int ERR_pop_to_mark(void)
|
|||
{
|
||||
return c_pop_error_to_mark(NULL);
|
||||
}
|
||||
|
||||
int ERR_count_to_mark(void)
|
||||
{
|
||||
return c_count_to_mark != NULL ? c_count_to_mark(NULL) : 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -23,9 +23,19 @@ print <<"_____";
|
|||
#ifndef OPENSSL_NO_STDIO
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
_____
|
||||
|
||||
if (${name_uc} eq "RSA") {
|
||||
print("#include <openssl/rsa.h>");
|
||||
}
|
||||
else {
|
||||
print <<"_____";
|
||||
#ifndef OPENSSL_NO_${name_uc}
|
||||
# include <openssl/$name.h>
|
||||
#endif
|
||||
_____
|
||||
}
|
||||
print <<"_____";
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1984,7 +1984,7 @@ static int test_tlsext_status_type(void)
|
|||
if (!create_ssl_ctx_pair(libctx, TLS_server_method(), TLS_client_method(),
|
||||
TLS1_VERSION, 0,
|
||||
&sctx, &cctx, leaf, skey))
|
||||
return 0;
|
||||
goto end;
|
||||
if (SSL_CTX_use_certificate_chain_file(sctx, leaf_chain) <= 0)
|
||||
goto end;
|
||||
if (SSL_CTX_get_tlsext_status_type(cctx) != -1)
|
||||
|
|
|
|||
Loading…
Reference in New Issue