Latest update.
This commit is contained in:
@@ -198,9 +198,7 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "x86asm.pl";
|
||||
|
||||
$output = pop;
|
||||
open OUT,">$output";
|
||||
*STDOUT=*OUT;
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0],$x86only = $ARGV[$#ARGV] eq "386");
|
||||
&static_label("AES_Te");
|
||||
|
||||
@@ -39,9 +39,10 @@
|
||||
# Profiler-assisted and platform-specific optimization resulted in 16%
|
||||
# improvement on Cortex A8 core and ~21.5 cycles per byte.
|
||||
|
||||
$flavour = shift;
|
||||
if ($flavour=~/\w[\w\-]*\.\w+$/) { $output=$flavour; undef $flavour; }
|
||||
else { while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} }
|
||||
# $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;
|
||||
|
||||
if ($flavour && $flavour ne "void") {
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
@@ -49,9 +50,10 @@ if ($flavour && $flavour ne "void") {
|
||||
( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or
|
||||
die "can't locate arm-xlate.pl";
|
||||
|
||||
open STDOUT,"| \"$^X\" $xlate $flavour $output";
|
||||
open STDOUT,"| \"$^X\" $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
} else {
|
||||
open STDOUT,">$output";
|
||||
$output and open STDOUT,">$output";
|
||||
}
|
||||
|
||||
$s0="r0";
|
||||
|
||||
@@ -37,8 +37,7 @@
|
||||
# cost of 8x increased pressure on L1D. 8x because you'd have
|
||||
# to interleave both Te and Td tables...
|
||||
|
||||
while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
($TEA,$TEB)=("A5","B5");
|
||||
($KPA,$KPB)=("A3","B1");
|
||||
|
||||
@@ -65,8 +65,12 @@
|
||||
# ($t0,$t1,$t2,$t3,$t8,$t9)=map("\$$_",(12..15,24,25));
|
||||
# ($s0,$s1,$s2,$s3,$s4,$s5,$s6,$s7)=map("\$$_",(16..23));
|
||||
# ($gp,$sp,$fp,$ra)=map("\$$_",(28..31));
|
||||
#
|
||||
$flavour = shift || "o32"; # supported flavours are o32,n32,64,nubi32,nubi64
|
||||
|
||||
# $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;
|
||||
$flavour ||= "o32"; # supported flavours are o32,n32,64,nubi32,nubi64
|
||||
|
||||
if ($flavour =~ /64|n32/i) {
|
||||
$PTR_LA="dla";
|
||||
@@ -95,17 +99,13 @@ $pf = ($flavour =~ /nubi/i) ? $t0 : $t2;
|
||||
|
||||
$big_endian=(`echo MIPSEB | $ENV{CC} -E -`=~/MIPSEB/)?0:1 if ($ENV{CC});
|
||||
|
||||
for (@ARGV) { $output=$_ if (/\w[\w\-]*\.\w+$/); }
|
||||
open STDOUT,">$output";
|
||||
|
||||
if (!defined($big_endian))
|
||||
{ $big_endian=(unpack('L',pack('N',1))==1); }
|
||||
|
||||
while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
|
||||
open STDOUT,">$output";
|
||||
|
||||
my ($MSB,$LSB)=(0,3); # automatically converted to little-endian
|
||||
|
||||
$output and open STDOUT,">$output";
|
||||
|
||||
$code.=<<___;
|
||||
#include "mips_arch.h"
|
||||
|
||||
|
||||
@@ -28,9 +28,12 @@
|
||||
#
|
||||
# Special thanks to polarhome.com for providing HP-UX account.
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
open STDOUT,">$output";
|
||||
# $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";
|
||||
|
||||
if ($flavour =~ /64/) {
|
||||
$LEVEL ="2.0W";
|
||||
|
||||
@@ -36,7 +36,10 @@
|
||||
# ppc_AES_encrypt_compact operates at 42 cycles per byte, while
|
||||
# ppc_AES_decrypt_compact - at 55 (in 64-bit build).
|
||||
|
||||
$flavour = shift;
|
||||
# $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;
|
||||
|
||||
if ($flavour =~ /64/) {
|
||||
$SIZE_T =8;
|
||||
@@ -59,7 +62,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or
|
||||
die "can't locate ppc-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!";
|
||||
open STDOUT,"| $^X $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
|
||||
$FRAME=32*$SIZE_T;
|
||||
|
||||
|
||||
@@ -89,7 +89,10 @@
|
||||
# instructions, which deliver ~70% improvement at 8KB block size over
|
||||
# vanilla km-based code, 37% - at most like 512-bytes block size.
|
||||
|
||||
$flavour = shift;
|
||||
# $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;
|
||||
|
||||
if ($flavour =~ /3[12]/) {
|
||||
$SIZE_T=4;
|
||||
@@ -99,8 +102,7 @@ if ($flavour =~ /3[12]/) {
|
||||
$g="g";
|
||||
}
|
||||
|
||||
while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
|
||||
open STDOUT,">$output";
|
||||
$output and open STDOUT,">$output";
|
||||
|
||||
$softonly=0; # allow hardware support
|
||||
|
||||
|
||||
@@ -37,8 +37,7 @@
|
||||
# optimal decrypt procedure]. Compared to GNU C generated code both
|
||||
# procedures are more than 60% faster:-)
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
$frame="STACK_FRAME";
|
||||
$bias="STACK_BIAS";
|
||||
|
||||
@@ -33,9 +33,10 @@
|
||||
#
|
||||
# (*) with hyper-threading off
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $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;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -44,7 +45,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$verticalspin=1; # unlike 32-bit version $verticalspin performs
|
||||
|
||||
@@ -33,8 +33,7 @@
|
||||
# instructions and improve single-block and short-input performance
|
||||
# with misaligned data.
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
{
|
||||
my ($inp,$out,$key,$rounds,$tmp,$mask) = map("%o$_",(0..5));
|
||||
|
||||
@@ -42,9 +42,10 @@
|
||||
# (*) Sandy/Ivy Bridge are known to handle high interleave factors
|
||||
# suboptimally;
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $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;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -74,7 +75,8 @@ if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([
|
||||
$avx = ($2>=3.0) + ($2>3.0);
|
||||
}
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
# void aesni_multi_cbc_encrypt (
|
||||
|
||||
@@ -88,9 +88,10 @@
|
||||
# (**) Execution is fully dominated by integer code sequence and
|
||||
# SIMD still hardly shows [in single-process benchmark;-]
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $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;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -114,7 +115,8 @@ $shaext=1; ### set to zero if compiling for 1.0.1
|
||||
|
||||
$stitched_decrypt=0;
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
# void aesni_cbc_sha1_enc(const void *inp,
|
||||
|
||||
@@ -44,9 +44,10 @@
|
||||
# -evp aes-256-cbc-hmac-sha256' will vary by percent or two;
|
||||
# (***) these are SHAEXT results;
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $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;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -77,7 +78,8 @@ if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([
|
||||
$shaext=$avx; ### set to zero if compiling for 1.0.1
|
||||
$avx=1 if (!$shaext && $avx);
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$func="aesni_cbc_sha256_enc";
|
||||
|
||||
@@ -76,9 +76,7 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "x86asm.pl";
|
||||
|
||||
$output = pop;
|
||||
open OUT,">$output";
|
||||
*STDOUT=*OUT;
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0]);
|
||||
|
||||
|
||||
@@ -192,9 +192,10 @@ $PREFIX="aesni"; # if $PREFIX is set to "AES", the script
|
||||
# generates drop-in replacement for
|
||||
# crypto/aes/asm/aes-x86_64.pl:-)
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $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;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -203,7 +204,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$movkey = $PREFIX eq "aesni" ? "movups" : "movups";
|
||||
|
||||
@@ -43,7 +43,10 @@
|
||||
# POWER9[le] 4.02/0.86 0.84 1.05
|
||||
# POWER9[be] 3.99/0.78 0.79 0.97
|
||||
|
||||
$flavour = shift;
|
||||
# $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;
|
||||
|
||||
if ($flavour =~ /64/) {
|
||||
$SIZE_T =8;
|
||||
@@ -70,7 +73,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or
|
||||
die "can't locate ppc-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!";
|
||||
open STDOUT,"| $^X $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
|
||||
$FRAME=8*$SIZE_T;
|
||||
$prefix="aes_p8";
|
||||
|
||||
@@ -75,8 +75,7 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "sparcv9_modes.pl";
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
$::evp=1; # if $evp is set to 0, script generates module with
|
||||
# AES_[en|de]crypt, AES_set_[en|de]crypt_key and AES_cbc_encrypt entry
|
||||
|
||||
@@ -56,15 +56,18 @@
|
||||
# (**) numbers after slash are for 32-bit code, which is 3x-
|
||||
# interleaved;
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
# $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}arm-xlate.pl" and -f $xlate ) or
|
||||
( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or
|
||||
die "can't locate arm-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$prefix="aes_v8";
|
||||
|
||||
@@ -50,9 +50,10 @@
|
||||
# April-August 2013
|
||||
# Add CBC, CTR and XTS subroutines and adapt for kernel use; courtesy of Ard.
|
||||
|
||||
$flavour = shift;
|
||||
if ($flavour=~/\w[\w\-]*\.\w+$/) { $output=$flavour; undef $flavour; }
|
||||
else { while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} }
|
||||
# $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;
|
||||
|
||||
if ($flavour && $flavour ne "void") {
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
@@ -60,9 +61,10 @@ if ($flavour && $flavour ne "void") {
|
||||
( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or
|
||||
die "can't locate arm-xlate.pl";
|
||||
|
||||
open STDOUT,"| \"$^X\" $xlate $flavour $output";
|
||||
open STDOUT,"| \"$^X\" $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
} else {
|
||||
open STDOUT,">$output";
|
||||
$output and open STDOUT,">$output";
|
||||
}
|
||||
|
||||
my ($inp,$out,$len,$key)=("r0","r1","r2","r3");
|
||||
|
||||
@@ -97,9 +97,10 @@
|
||||
#
|
||||
# <appro@openssl.org>
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $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;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -108,7 +109,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
my ($inp,$out,$len,$key,$ivp)=("%rdi","%rsi","%rdx","%rcx");
|
||||
|
||||
@@ -38,15 +38,18 @@
|
||||
# code, but it's constant-time and therefore preferred;
|
||||
# (***) presented for reference/comparison purposes;
|
||||
|
||||
$flavour = shift;
|
||||
while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
|
||||
# $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}arm-xlate.pl" and -f $xlate ) or
|
||||
( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or
|
||||
die "can't locate arm-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$code.=<<___;
|
||||
|
||||
@@ -35,7 +35,10 @@
|
||||
# (**) Inadequate POWER6 performance is due to astronomic AltiVec
|
||||
# latency, 9 cycles per simple logical operation.
|
||||
|
||||
$flavour = shift;
|
||||
# $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;
|
||||
|
||||
if ($flavour =~ /64/) {
|
||||
$SIZE_T =8;
|
||||
@@ -61,7 +64,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or
|
||||
die "can't locate ppc-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!";
|
||||
open STDOUT,"| $^X $xlate $flavour \"$output\""
|
||||
|| die "can't call $xlate: $!";
|
||||
|
||||
$code.=<<___;
|
||||
.machine "any"
|
||||
|
||||
@@ -58,9 +58,7 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "x86asm.pl";
|
||||
|
||||
$output = pop;
|
||||
open OUT,">$output";
|
||||
*STDOUT=*OUT;
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0],$x86only = $ARGV[$#ARGV] eq "386");
|
||||
|
||||
|
||||
@@ -54,9 +54,10 @@
|
||||
#
|
||||
# <appro@openssl.org>
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $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;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -65,7 +66,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$PREFIX="vpaes";
|
||||
|
||||
+24
-27
@@ -67,51 +67,48 @@ DEFINE[../../providers/fips]=$AESDEF
|
||||
|
||||
GENERATE[aes-ia64.s]=asm/aes-ia64.S
|
||||
|
||||
GENERATE[aes-586.s]=asm/aes-586.pl \
|
||||
$(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR)
|
||||
GENERATE[aes-586.s]=asm/aes-586.pl
|
||||
DEPEND[aes-586.s]=../perlasm/x86asm.pl
|
||||
GENERATE[vpaes-x86.s]=asm/vpaes-x86.pl \
|
||||
$(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR)
|
||||
GENERATE[vpaes-x86.s]=asm/vpaes-x86.pl
|
||||
DEPEND[vpaes-586.s]=../perlasm/x86asm.pl
|
||||
GENERATE[aesni-x86.s]=asm/aesni-x86.pl \
|
||||
$(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR)
|
||||
GENERATE[aesni-x86.s]=asm/aesni-x86.pl
|
||||
DEPEND[aesni-586.s]=../perlasm/x86asm.pl
|
||||
|
||||
GENERATE[aes-x86_64.s]=asm/aes-x86_64.pl $(PERLASM_SCHEME)
|
||||
GENERATE[vpaes-x86_64.s]=asm/vpaes-x86_64.pl $(PERLASM_SCHEME)
|
||||
GENERATE[bsaes-x86_64.s]=asm/bsaes-x86_64.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aesni-x86_64.s]=asm/aesni-x86_64.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aesni-sha1-x86_64.s]=asm/aesni-sha1-x86_64.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aesni-sha256-x86_64.s]=asm/aesni-sha256-x86_64.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aesni-mb-x86_64.s]=asm/aesni-mb-x86_64.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aes-x86_64.s]=asm/aes-x86_64.pl
|
||||
GENERATE[vpaes-x86_64.s]=asm/vpaes-x86_64.pl
|
||||
GENERATE[bsaes-x86_64.s]=asm/bsaes-x86_64.pl
|
||||
GENERATE[aesni-x86_64.s]=asm/aesni-x86_64.pl
|
||||
GENERATE[aesni-sha1-x86_64.s]=asm/aesni-sha1-x86_64.pl
|
||||
GENERATE[aesni-sha256-x86_64.s]=asm/aesni-sha256-x86_64.pl
|
||||
GENERATE[aesni-mb-x86_64.s]=asm/aesni-mb-x86_64.pl
|
||||
|
||||
GENERATE[aes-sparcv9.S]=asm/aes-sparcv9.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aes-sparcv9.S]=asm/aes-sparcv9.pl
|
||||
INCLUDE[aes-sparcv9.o]=..
|
||||
GENERATE[aest4-sparcv9.S]=asm/aest4-sparcv9.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aest4-sparcv9.S]=asm/aest4-sparcv9.pl
|
||||
INCLUDE[aest4-sparcv9.o]=..
|
||||
DEPEND[aest4-sparcv9.S]=../perlasm/sparcv9_modes.pl
|
||||
GENERATE[aesfx-sparcv9.S]=asm/aesfx-sparcv9.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aesfx-sparcv9.S]=asm/aesfx-sparcv9.pl
|
||||
INCLUDE[aesfx-sparcv9.o]=..
|
||||
|
||||
GENERATE[aes-ppc.s]=asm/aes-ppc.pl $(PERLASM_SCHEME)
|
||||
GENERATE[vpaes-ppc.s]=asm/vpaes-ppc.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aesp8-ppc.s]=asm/aesp8-ppc.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aes-ppc.s]=asm/aes-ppc.pl
|
||||
GENERATE[vpaes-ppc.s]=asm/vpaes-ppc.pl
|
||||
GENERATE[aesp8-ppc.s]=asm/aesp8-ppc.pl
|
||||
|
||||
GENERATE[aes-parisc.s]=asm/aes-parisc.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aes-parisc.s]=asm/aes-parisc.pl
|
||||
|
||||
GENERATE[aes-mips.S]=asm/aes-mips.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aes-mips.S]=asm/aes-mips.pl
|
||||
INCLUDE[aes-mips.o]=..
|
||||
|
||||
GENERATE[aesv8-armx.S]=asm/aesv8-armx.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aesv8-armx.S]=asm/aesv8-armx.pl
|
||||
INCLUDE[aesv8-armx.o]=..
|
||||
GENERATE[vpaes-armv8.S]=asm/vpaes-armv8.pl $(PERLASM_SCHEME)
|
||||
GENERATE[vpaes-armv8.S]=asm/vpaes-armv8.pl
|
||||
|
||||
GENERATE[aes-armv4.S]=asm/aes-armv4.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aes-armv4.S]=asm/aes-armv4.pl
|
||||
INCLUDE[aes-armv4.o]=..
|
||||
GENERATE[bsaes-armv7.S]=asm/bsaes-armv7.pl $(PERLASM_SCHEME)
|
||||
GENERATE[bsaes-armv7.S]=asm/bsaes-armv7.pl
|
||||
INCLUDE[bsaes-armv7.o]=..
|
||||
|
||||
GENERATE[aes-s390x.S]=asm/aes-s390x.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aes-s390x.S]=asm/aes-s390x.pl
|
||||
INCLUDE[aes-s390x.o]=..
|
||||
|
||||
GENERATE[aes-c64xplus.S]=asm/aes-c64xplus.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aes-c64xplus.S]=asm/aes-c64xplus.pl
|
||||
@@ -7,8 +7,7 @@
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
print <<'___';
|
||||
.text
|
||||
|
||||
+1
-1
@@ -1007,7 +1007,7 @@ static void sl2(ARIA_c128 o, const ARIA_u128 *x, const ARIA_u128 *y)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < ARIA_BLOCK_SIZE; i += 4) {
|
||||
o[i ] = sb3[x->c[i ] ^ y->c[i ]];
|
||||
o[i ] = sb3[x->c[i ] ^ y->c[i ]];
|
||||
o[i + 1] = sb4[x->c[i + 1] ^ y->c[i + 1]];
|
||||
o[i + 2] = sb1[x->c[i + 2] ^ y->c[i + 2]];
|
||||
o[i + 3] = sb2[x->c[i + 3] ^ y->c[i + 3]];
|
||||
|
||||
@@ -7,15 +7,18 @@
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
# $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}arm-xlate.pl" and -f $xlate ) or
|
||||
( $xlate="${dir}perlasm/arm-xlate.pl" and -f $xlate) or
|
||||
die "can't locate arm-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$code.=<<___;
|
||||
|
||||
@@ -7,15 +7,18 @@
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
# $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}arm-xlate.pl" and -f $xlate ) or
|
||||
( $xlate="${dir}perlasm/arm-xlate.pl" and -f $xlate) or
|
||||
die "can't locate arm-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$code.=<<___;
|
||||
|
||||
@@ -129,6 +129,9 @@ ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
|
||||
int idx;
|
||||
ASN1_STRING_TABLE fnd;
|
||||
|
||||
/* "stable" can be impacted by config, so load the config file first */
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL);
|
||||
|
||||
fnd.nid = nid;
|
||||
if (stable) {
|
||||
idx = sk_ASN1_STRING_TABLE_find(stable, &fnd);
|
||||
|
||||
+24
-19
@@ -79,7 +79,11 @@ int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d)
|
||||
char *a;
|
||||
int n, i, i2, l, o, min_l = 11, strict = 0, end = 6, btz = 5, md;
|
||||
struct tm tmp;
|
||||
|
||||
#if defined(CHARSET_EBCDIC)
|
||||
const char upper_z = 0x5A, num_zero = 0x30, period = 0x2E, minus = 0x2D, plus = 0x2B;
|
||||
#else
|
||||
const char upper_z = 'Z', num_zero = '0', period = '.', minus = '-', plus = '+';
|
||||
#endif
|
||||
/*
|
||||
* ASN1_STRING_FLAG_X509_TIME is used to enforce RFC 5280
|
||||
* time string format, in which:
|
||||
@@ -120,20 +124,20 @@ int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d)
|
||||
if (l < min_l)
|
||||
goto err;
|
||||
for (i = 0; i < end; i++) {
|
||||
if (!strict && (i == btz) && ((a[o] == 'Z') || (a[o] == '+') || (a[o] == '-'))) {
|
||||
if (!strict && (i == btz) && ((a[o] == upper_z) || (a[o] == plus) || (a[o] == minus))) {
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
if (!ossl_isdigit(a[o]))
|
||||
if (!ascii_isdigit(a[o]))
|
||||
goto err;
|
||||
n = a[o] - '0';
|
||||
n = a[o] - num_zero;
|
||||
/* incomplete 2-digital number */
|
||||
if (++o == l)
|
||||
goto err;
|
||||
|
||||
if (!ossl_isdigit(a[o]))
|
||||
if (!ascii_isdigit(a[o]))
|
||||
goto err;
|
||||
n = (n * 10) + a[o] - '0';
|
||||
n = (n * 10) + a[o] - num_zero;
|
||||
/* no more bytes to read, but we haven't seen time-zone yet */
|
||||
if (++o == l)
|
||||
goto err;
|
||||
@@ -185,14 +189,14 @@ int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d)
|
||||
* Optional fractional seconds: decimal point followed by one or more
|
||||
* digits.
|
||||
*/
|
||||
if (d->type == V_ASN1_GENERALIZEDTIME && a[o] == '.') {
|
||||
if (d->type == V_ASN1_GENERALIZEDTIME && a[o] == period) {
|
||||
if (strict)
|
||||
/* RFC 5280 forbids fractional seconds */
|
||||
goto err;
|
||||
if (++o == l)
|
||||
goto err;
|
||||
i = o;
|
||||
while ((o < l) && ossl_isdigit(a[o]))
|
||||
while ((o < l) && ascii_isdigit(a[o]))
|
||||
o++;
|
||||
/* Must have at least one digit after decimal point */
|
||||
if (i == o)
|
||||
@@ -207,10 +211,10 @@ int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d)
|
||||
* 'o' can point to '\0' is either the subsequent if or the first
|
||||
* else if is true.
|
||||
*/
|
||||
if (a[o] == 'Z') {
|
||||
if (a[o] == upper_z) {
|
||||
o++;
|
||||
} else if (!strict && ((a[o] == '+') || (a[o] == '-'))) {
|
||||
int offsign = a[o] == '-' ? 1 : -1;
|
||||
} else if (!strict && ((a[o] == plus) || (a[o] == minus))) {
|
||||
int offsign = a[o] == minus ? 1 : -1;
|
||||
int offset = 0;
|
||||
|
||||
o++;
|
||||
@@ -223,13 +227,13 @@ int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d)
|
||||
if (o + 4 != l)
|
||||
goto err;
|
||||
for (i = end; i < end + 2; i++) {
|
||||
if (!ossl_isdigit(a[o]))
|
||||
if (!ascii_isdigit(a[o]))
|
||||
goto err;
|
||||
n = a[o] - '0';
|
||||
n = a[o] - num_zero;
|
||||
o++;
|
||||
if (!ossl_isdigit(a[o]))
|
||||
if (!ascii_isdigit(a[o]))
|
||||
goto err;
|
||||
n = (n * 10) + a[o] - '0';
|
||||
n = (n * 10) + a[o] - num_zero;
|
||||
i2 = (d->type == V_ASN1_UTCTIME) ? i + 1 : i;
|
||||
if ((n < min[i2]) || (n > max[i2]))
|
||||
goto err;
|
||||
@@ -300,7 +304,7 @@ ASN1_TIME *asn1_time_from_tm(ASN1_TIME *s, struct tm *ts, int type)
|
||||
ts->tm_mday, ts->tm_hour, ts->tm_min,
|
||||
ts->tm_sec);
|
||||
|
||||
#ifdef CHARSET_EBCDIC_not
|
||||
#ifdef CHARSET_EBCDIC
|
||||
ebcdic2ascii(tmps->data, tmps->data, tmps->length);
|
||||
#endif
|
||||
return tmps;
|
||||
@@ -467,6 +471,7 @@ int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)
|
||||
char *v;
|
||||
int gmt = 0, l;
|
||||
struct tm stm;
|
||||
const char upper_z = 0x5A, period = 0x2E;
|
||||
|
||||
if (!asn1_time_to_tm(&stm, tm)) {
|
||||
/* asn1_time_to_tm will check the time type */
|
||||
@@ -475,7 +480,7 @@ int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)
|
||||
|
||||
l = tm->length;
|
||||
v = (char *)tm->data;
|
||||
if (v[l - 1] == 'Z')
|
||||
if (v[l - 1] == upper_z)
|
||||
gmt = 1;
|
||||
|
||||
if (tm->type == V_ASN1_GENERALIZEDTIME) {
|
||||
@@ -486,10 +491,10 @@ int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)
|
||||
* Try to parse fractional seconds. '14' is the place of
|
||||
* 'fraction point' in a GeneralizedTime string.
|
||||
*/
|
||||
if (tm->length > 15 && v[14] == '.') {
|
||||
if (tm->length > 15 && v[14] == period) {
|
||||
f = &v[14];
|
||||
f_len = 1;
|
||||
while (14 + f_len < l && ossl_isdigit(f[f_len]))
|
||||
while (14 + f_len < l && ascii_isdigit(f[f_len]))
|
||||
++f_len;
|
||||
}
|
||||
|
||||
|
||||
+1
-145
@@ -13,148 +13,6 @@
|
||||
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
static const ERR_STRING_DATA ASN1_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_A2D_ASN1_OBJECT, 0), "a2d_ASN1_OBJECT"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_A2I_ASN1_INTEGER, 0), "a2i_ASN1_INTEGER"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_A2I_ASN1_STRING, 0), "a2i_ASN1_STRING"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_APPEND_EXP, 0), "append_exp"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_BIO_INIT, 0), "asn1_bio_init"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_BIT_STRING_SET_BIT, 0),
|
||||
"ASN1_BIT_STRING_set_bit"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_CB, 0), "asn1_cb"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_CHECK_TLEN, 0), "asn1_check_tlen"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_COLLECT, 0), "asn1_collect"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_D2I_EX_PRIMITIVE, 0),
|
||||
"asn1_d2i_ex_primitive"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_D2I_FP, 0), "ASN1_d2i_fp"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_D2I_READ_BIO, 0), "asn1_d2i_read_bio"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_DIGEST, 0), "ASN1_digest"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_DO_ADB, 0), "asn1_do_adb"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_DO_LOCK, 0), "asn1_do_lock"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_DUP, 0), "ASN1_dup"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ENC_SAVE, 0), "asn1_enc_save"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_EX_C2I, 0), "asn1_ex_c2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_FIND_END, 0), "asn1_find_end"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_GENERALIZEDTIME_ADJ, 0),
|
||||
"ASN1_GENERALIZEDTIME_adj"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_GENERATE_V3, 0), "ASN1_generate_v3"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_GET_INT64, 0), "asn1_get_int64"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_GET_OBJECT, 0), "ASN1_get_object"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_GET_UINT64, 0), "asn1_get_uint64"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_I2D_BIO, 0), "ASN1_i2d_bio"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_I2D_FP, 0), "ASN1_i2d_fp"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_D2I_FP, 0), "ASN1_item_d2i_fp"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_DUP, 0), "ASN1_item_dup"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_EMBED_D2I, 0),
|
||||
"asn1_item_embed_d2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_EMBED_NEW, 0),
|
||||
"asn1_item_embed_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_FLAGS_I2D, 0),
|
||||
"asn1_item_flags_i2d"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_I2D_BIO, 0), "ASN1_item_i2d_bio"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_I2D_FP, 0), "ASN1_item_i2d_fp"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_PACK, 0), "ASN1_item_pack"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_SIGN, 0), "ASN1_item_sign"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_SIGN_CTX, 0),
|
||||
"ASN1_item_sign_ctx"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_UNPACK, 0), "ASN1_item_unpack"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_VERIFY, 0), "ASN1_item_verify"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_MBSTRING_NCOPY, 0),
|
||||
"ASN1_mbstring_ncopy"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_OBJECT_NEW, 0), "ASN1_OBJECT_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_OUTPUT_DATA, 0), "asn1_output_data"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_PCTX_NEW, 0), "ASN1_PCTX_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_PRIMITIVE_NEW, 0),
|
||||
"asn1_primitive_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_SCTX_NEW, 0), "ASN1_SCTX_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_SIGN, 0), "ASN1_sign"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STR2TYPE, 0), "asn1_str2type"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STRING_GET_INT64, 0),
|
||||
"asn1_string_get_int64"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STRING_GET_UINT64, 0),
|
||||
"asn1_string_get_uint64"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STRING_SET, 0), "ASN1_STRING_set"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STRING_TABLE_ADD, 0),
|
||||
"ASN1_STRING_TABLE_add"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STRING_TO_BN, 0), "asn1_string_to_bn"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STRING_TYPE_NEW, 0),
|
||||
"ASN1_STRING_type_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_TEMPLATE_EX_D2I, 0),
|
||||
"asn1_template_ex_d2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_TEMPLATE_NEW, 0), "asn1_template_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, 0),
|
||||
"asn1_template_noexp_d2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_TIME_ADJ, 0), "ASN1_TIME_adj"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING, 0),
|
||||
"ASN1_TYPE_get_int_octetstring"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_TYPE_GET_OCTETSTRING, 0),
|
||||
"ASN1_TYPE_get_octetstring"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_UTCTIME_ADJ, 0), "ASN1_UTCTIME_adj"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_VERIFY, 0), "ASN1_verify"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_B64_READ_ASN1, 0), "b64_read_asn1"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_B64_WRITE_ASN1, 0), "B64_write_ASN1"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_BIO_NEW_NDEF, 0), "BIO_new_NDEF"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_BITSTR_CB, 0), "bitstr_cb"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_BN_TO_ASN1_STRING, 0), "bn_to_asn1_string"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_C2I_ASN1_BIT_STRING, 0),
|
||||
"c2i_ASN1_BIT_STRING"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_C2I_ASN1_INTEGER, 0), "c2i_ASN1_INTEGER"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_C2I_ASN1_OBJECT, 0), "c2i_ASN1_OBJECT"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_C2I_IBUF, 0), "c2i_ibuf"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_C2I_UINT64_INT, 0), "c2i_uint64_int"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_COLLECT_DATA, 0), "collect_data"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_D2I_ASN1_OBJECT, 0), "d2i_ASN1_OBJECT"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_D2I_ASN1_UINTEGER, 0), "d2i_ASN1_UINTEGER"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_D2I_AUTOPRIVATEKEY, 0),
|
||||
"d2i_AutoPrivateKey"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_D2I_KEYPARAMS, 0), "d2i_KeyParams"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_D2I_PRIVATEKEY, 0), "d2i_PrivateKey"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_D2I_PUBLICKEY, 0), "d2i_PublicKey"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_DO_BUF, 0), "do_buf"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_DO_CREATE, 0), "do_create"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_DO_DUMP, 0), "do_dump"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_DO_TCREATE, 0), "do_tcreate"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2A_ASN1_OBJECT, 0), "i2a_ASN1_OBJECT"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_ASN1_BIO_STREAM, 0),
|
||||
"i2d_ASN1_bio_stream"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_ASN1_OBJECT, 0), "i2d_ASN1_OBJECT"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_DSA_PUBKEY, 0), "i2d_DSA_PUBKEY"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_EC_PUBKEY, 0), "i2d_EC_PUBKEY"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_KEYPARAMS, 0), "i2d_KeyParams"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_PRIVATEKEY, 0), "i2d_PrivateKey"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_PUBLICKEY, 0), "i2d_PublicKey"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_RSA_PUBKEY, 0), "i2d_RSA_PUBKEY"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_LONG_C2I, 0), "long_c2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_NDEF_PREFIX, 0), "ndef_prefix"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_NDEF_SUFFIX, 0), "ndef_suffix"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_OID_MODULE_INIT, 0), "oid_module_init"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PARSE_TAGGING, 0), "parse_tagging"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PKCS5_PBE2_SET_IV, 0), "PKCS5_pbe2_set_iv"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PKCS5_PBE2_SET_SCRYPT, 0),
|
||||
"PKCS5_pbe2_set_scrypt"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PKCS5_PBE_SET, 0), "PKCS5_pbe_set"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PKCS5_PBE_SET0_ALGOR, 0),
|
||||
"PKCS5_pbe_set0_algor"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PKCS5_PBKDF2_SET, 0), "PKCS5_pbkdf2_set"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PKCS5_SCRYPT_SET, 0), "pkcs5_scrypt_set"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_SMIME_READ_ASN1, 0), "SMIME_read_ASN1"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_SMIME_TEXT, 0), "SMIME_text"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_STABLE_GET, 0), "stable_get"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_STBL_MODULE_INIT, 0), "stbl_module_init"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_UINT32_C2I, 0), "uint32_c2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_UINT32_NEW, 0), "uint32_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_UINT64_C2I, 0), "uint64_c2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_UINT64_NEW, 0), "uint64_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_X509_CRL_ADD0_REVOKED, 0),
|
||||
"X509_CRL_add0_revoked"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_X509_INFO_NEW, 0), "X509_INFO_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_X509_NAME_ENCODE, 0), "x509_name_encode"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_X509_NAME_EX_D2I, 0), "x509_name_ex_d2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_X509_NAME_EX_NEW, 0), "x509_name_ex_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_X509_PKEY_NEW, 0), "X509_PKEY_new"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static const ERR_STRING_DATA ASN1_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ADDING_OBJECT), "adding object"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ASN1_PARSE_ERROR), "asn1 parse error"},
|
||||
@@ -343,10 +201,8 @@ static const ERR_STRING_DATA ASN1_str_reasons[] = {
|
||||
int ERR_load_ASN1_strings(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
if (ERR_func_error_string(ASN1_str_functs[0].error) == NULL) {
|
||||
ERR_load_strings_const(ASN1_str_functs);
|
||||
if (ERR_reason_error_string(ASN1_str_reasons[0].error) == NULL)
|
||||
ERR_load_strings_const(ASN1_str_reasons);
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -184,6 +184,8 @@ static int ndef_suffix(BIO *b, unsigned char **pbuf, int *plen, void *parg)
|
||||
return 0;
|
||||
|
||||
derlen = ASN1_item_ndef_i2d(ndef_aux->val, NULL, ndef_aux->it);
|
||||
if (derlen < 0)
|
||||
return 0;
|
||||
if ((p = OPENSSL_malloc(derlen)) == NULL) {
|
||||
ASN1err(ASN1_F_NDEF_SUFFIX, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
|
||||
@@ -52,10 +52,6 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
|
||||
else
|
||||
asn1_cb = 0;
|
||||
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
OPENSSL_mem_debug_push(it->sname ? it->sname : "asn1_item_embed_new");
|
||||
#endif
|
||||
|
||||
switch (it->itype) {
|
||||
|
||||
case ASN1_ITYPE_EXTERN:
|
||||
@@ -85,9 +81,6 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
|
||||
if (!i)
|
||||
goto auxerr;
|
||||
if (i == 2) {
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
OPENSSL_mem_debug_pop();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -110,9 +103,6 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
|
||||
if (!i)
|
||||
goto auxerr;
|
||||
if (i == 2) {
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
OPENSSL_mem_debug_pop();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -141,27 +131,18 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
|
||||
goto auxerr2;
|
||||
break;
|
||||
}
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
OPENSSL_mem_debug_pop();
|
||||
#endif
|
||||
return 1;
|
||||
|
||||
memerr2:
|
||||
asn1_item_embed_free(pval, it, embed);
|
||||
memerr:
|
||||
ASN1err(ASN1_F_ASN1_ITEM_EMBED_NEW, ERR_R_MALLOC_FAILURE);
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
OPENSSL_mem_debug_pop();
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
auxerr2:
|
||||
asn1_item_embed_free(pval, it, embed);
|
||||
auxerr:
|
||||
ASN1err(ASN1_F_ASN1_ITEM_EMBED_NEW, ASN1_R_AUX_ERROR);
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
OPENSSL_mem_debug_pop();
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -219,10 +200,6 @@ static int asn1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
|
||||
*pval = NULL;
|
||||
return 1;
|
||||
}
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
OPENSSL_mem_debug_push(tt->field_name
|
||||
? tt->field_name : "asn1_template_new");
|
||||
#endif
|
||||
/* If SET OF or SEQUENCE OF, its a STACK */
|
||||
if (tt->flags & ASN1_TFLG_SK_MASK) {
|
||||
STACK_OF(ASN1_VALUE) *skval;
|
||||
@@ -239,9 +216,6 @@ static int asn1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
|
||||
/* Otherwise pass it back to the item routine */
|
||||
ret = asn1_item_embed_new(pval, it, embed);
|
||||
done:
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
OPENSSL_mem_debug_pop();
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
+14
-3
@@ -130,9 +130,20 @@ static int bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
static int bn_secure_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
int utype, char *free_cont, const ASN1_ITEM *it)
|
||||
{
|
||||
if (!*pval)
|
||||
bn_secure_new(pval, it);
|
||||
return bn_c2i(pval, cont, len, utype, free_cont, it);
|
||||
int ret;
|
||||
BIGNUM *bn;
|
||||
|
||||
if (!*pval && !bn_secure_new(pval, it))
|
||||
return 0;
|
||||
|
||||
ret = bn_c2i(pval, cont, len, utype, free_cont, it);
|
||||
if (!ret)
|
||||
return 0;
|
||||
|
||||
/* Set constant-time flag for all secure BIGNUMS */
|
||||
bn = (BIGNUM *)*pval;
|
||||
BN_set_flags(bn, BN_FLG_CONSTTIME);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int bn_print(BIO *out, const ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
|
||||
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* A simple ASN.1 DER encoder/decoder for DSA-Sig-Value and ECDSA-Sig-Value.
|
||||
*
|
||||
* DSA-Sig-Value ::= SEQUENCE {
|
||||
* r INTEGER,
|
||||
* s INTEGER
|
||||
* }
|
||||
*
|
||||
* ECDSA-Sig-Value ::= SEQUENCE {
|
||||
* r INTEGER,
|
||||
* s INTEGER
|
||||
* }
|
||||
*/
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/bn.h>
|
||||
#include "internal/asn1_dsa.h"
|
||||
#include "internal/packet.h"
|
||||
|
||||
#define ID_SEQUENCE 0x30
|
||||
#define ID_INTEGER 0x02
|
||||
|
||||
/*
|
||||
* Outputs the encoding of the length octets for a DER value with a content
|
||||
* length of cont_len bytes to pkt. The maximum supported content length is
|
||||
* 65535 (0xffff) bytes.
|
||||
*
|
||||
* Returns 1 on success or 0 on error.
|
||||
*/
|
||||
int encode_der_length(WPACKET *pkt, size_t cont_len)
|
||||
{
|
||||
if (cont_len > 0xffff)
|
||||
return 0; /* Too large for supported length encodings */
|
||||
|
||||
if (cont_len > 0xff) {
|
||||
if (!WPACKET_put_bytes_u8(pkt, 0x82)
|
||||
|| !WPACKET_put_bytes_u16(pkt, cont_len))
|
||||
return 0;
|
||||
} else {
|
||||
if (cont_len > 0x7f
|
||||
&& !WPACKET_put_bytes_u8(pkt, 0x81))
|
||||
return 0;
|
||||
if (!WPACKET_put_bytes_u8(pkt, cont_len))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Outputs the DER encoding of a positive ASN.1 INTEGER to pkt.
|
||||
*
|
||||
* Results in an error if n is negative or too large.
|
||||
*
|
||||
* Returns 1 on success or 0 on error.
|
||||
*/
|
||||
int encode_der_integer(WPACKET *pkt, const BIGNUM *n)
|
||||
{
|
||||
unsigned char *bnbytes;
|
||||
size_t cont_len;
|
||||
|
||||
if (BN_is_negative(n))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Calculate the ASN.1 INTEGER DER content length for n.
|
||||
* This is the number of whole bytes required to represent n (i.e. rounded
|
||||
* down), plus one.
|
||||
* If n is zero then the content is a single zero byte (length = 1).
|
||||
* If the number of bits of n is a multiple of 8 then an extra zero padding
|
||||
* byte is included to ensure that the value is still treated as positive
|
||||
* in the INTEGER two's complement representation.
|
||||
*/
|
||||
cont_len = BN_num_bits(n) / 8 + 1;
|
||||
|
||||
if (!WPACKET_start_sub_packet(pkt)
|
||||
|| !WPACKET_put_bytes_u8(pkt, ID_INTEGER)
|
||||
|| !encode_der_length(pkt, cont_len)
|
||||
|| !WPACKET_allocate_bytes(pkt, cont_len, &bnbytes)
|
||||
|| !WPACKET_close(pkt))
|
||||
return 0;
|
||||
|
||||
if (bnbytes != NULL
|
||||
&& BN_bn2binpad(n, bnbytes, (int)cont_len) != (int)cont_len)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Outputs the DER encoding of a DSA-Sig-Value or ECDSA-Sig-Value to pkt. pkt
|
||||
* may be initialised with a NULL buffer which enables pkt to be used to
|
||||
* calulate how many bytes would be needed.
|
||||
*
|
||||
* Returns 1 on success or 0 on error.
|
||||
*/
|
||||
int encode_der_dsa_sig(WPACKET *pkt, const BIGNUM *r, const BIGNUM *s)
|
||||
{
|
||||
WPACKET tmppkt, *dummypkt;
|
||||
size_t cont_len;
|
||||
int isnull = WPACKET_is_null_buf(pkt);
|
||||
|
||||
if (!WPACKET_start_sub_packet(pkt))
|
||||
return 0;
|
||||
|
||||
if (!isnull) {
|
||||
if (!WPACKET_init_null(&tmppkt, 0))
|
||||
return 0;
|
||||
dummypkt = &tmppkt;
|
||||
} else {
|
||||
/* If the input packet has a NULL buffer, we don't need a dummy packet */
|
||||
dummypkt = pkt;
|
||||
}
|
||||
|
||||
/* Calculate the content length */
|
||||
if (!encode_der_integer(dummypkt, r)
|
||||
|| !encode_der_integer(dummypkt, s)
|
||||
|| !WPACKET_get_length(dummypkt, &cont_len)
|
||||
|| (!isnull && !WPACKET_finish(dummypkt))) {
|
||||
if (!isnull)
|
||||
WPACKET_cleanup(dummypkt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Add the tag and length bytes */
|
||||
if (!WPACKET_put_bytes_u8(pkt, ID_SEQUENCE)
|
||||
|| !encode_der_length(pkt, cont_len)
|
||||
/*
|
||||
* Really encode the integers. We already wrote to the main pkt
|
||||
* if it had a NULL buffer, so don't do it again
|
||||
*/
|
||||
|| (!isnull && !encode_der_integer(pkt, r))
|
||||
|| (!isnull && !encode_der_integer(pkt, s))
|
||||
|| !WPACKET_close(pkt))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decodes the DER length octets in pkt and initialises subpkt with the
|
||||
* following bytes of that length.
|
||||
*
|
||||
* Returns 1 on success or 0 on failure.
|
||||
*/
|
||||
int decode_der_length(PACKET *pkt, PACKET *subpkt)
|
||||
{
|
||||
unsigned int byte;
|
||||
|
||||
if (!PACKET_get_1(pkt, &byte))
|
||||
return 0;
|
||||
|
||||
if (byte < 0x80)
|
||||
return PACKET_get_sub_packet(pkt, subpkt, (size_t)byte);
|
||||
if (byte == 0x81)
|
||||
return PACKET_get_length_prefixed_1(pkt, subpkt);
|
||||
if (byte == 0x82)
|
||||
return PACKET_get_length_prefixed_2(pkt, subpkt);
|
||||
|
||||
/* Too large, invalid, or not DER. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decodes a single ASN.1 INTEGER value from pkt, which must be DER encoded,
|
||||
* and updates n with the decoded value.
|
||||
*
|
||||
* The BIGNUM, n, must have already been allocated by calling BN_new().
|
||||
* pkt must not be NULL.
|
||||
*
|
||||
* An attempt to consume more than len bytes results in an error.
|
||||
* Returns 1 on success or 0 on error.
|
||||
*
|
||||
* If the PACKET is supposed to only contain a single INTEGER value with no
|
||||
* trailing garbage then it is up to the caller to verify that all bytes
|
||||
* were consumed.
|
||||
*/
|
||||
int decode_der_integer(PACKET *pkt, BIGNUM *n)
|
||||
{
|
||||
PACKET contpkt, tmppkt;
|
||||
unsigned int tag, tmp;
|
||||
|
||||
/* Check we have an integer and get the content bytes */
|
||||
if (!PACKET_get_1(pkt, &tag)
|
||||
|| tag != ID_INTEGER
|
||||
|| !decode_der_length(pkt, &contpkt))
|
||||
return 0;
|
||||
|
||||
/* Peek ahead at the first bytes to check for proper encoding */
|
||||
tmppkt = contpkt;
|
||||
/* The INTEGER must be positive */
|
||||
if (!PACKET_get_1(&tmppkt, &tmp)
|
||||
|| (tmp & 0x80) != 0)
|
||||
return 0;
|
||||
/* If there a zero padding byte the next byte must have the msb set */
|
||||
if (PACKET_remaining(&tmppkt) > 0 && tmp == 0) {
|
||||
if (!PACKET_get_1(&tmppkt, &tmp)
|
||||
|| (tmp & 0x80) == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (BN_bin2bn(PACKET_data(&contpkt),
|
||||
(int)PACKET_remaining(&contpkt), n) == NULL)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decodes a single DSA-Sig-Value or ECDSA-Sig-Value from *ppin, which must be
|
||||
* DER encoded, updates r and s with the decoded values, and increments *ppin
|
||||
* past the data that was consumed.
|
||||
*
|
||||
* The BIGNUMs, r and s, must have already been allocated by calls to BN_new().
|
||||
* ppin and *ppin must not be NULL.
|
||||
*
|
||||
* An attempt to consume more than len bytes results in an error.
|
||||
* Returns the number of bytes of input consumed or 0 if an error occurs.
|
||||
*
|
||||
* If the buffer is supposed to only contain a single [EC]DSA-Sig-Value with no
|
||||
* trailing garbage then it is up to the caller to verify that all bytes
|
||||
* were consumed.
|
||||
*/
|
||||
size_t decode_der_dsa_sig(BIGNUM *r, BIGNUM *s, const unsigned char **ppin,
|
||||
size_t len)
|
||||
{
|
||||
size_t consumed;
|
||||
PACKET pkt, contpkt;
|
||||
unsigned int tag;
|
||||
|
||||
if (!PACKET_buf_init(&pkt, *ppin, len)
|
||||
|| !PACKET_get_1(&pkt, &tag)
|
||||
|| tag != ID_SEQUENCE
|
||||
|| !decode_der_length(&pkt, &contpkt)
|
||||
|| !decode_der_integer(&contpkt, r)
|
||||
|| !decode_der_integer(&contpkt, s)
|
||||
|| PACKET_remaining(&contpkt) != 0)
|
||||
return 0;
|
||||
|
||||
consumed = PACKET_data(&pkt) - *ppin;
|
||||
*ppin += consumed;
|
||||
return consumed;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Generated by util/mkerr.pl DO NOT EDIT
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2019 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
|
||||
@@ -13,19 +13,6 @@
|
||||
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
static const ERR_STRING_DATA ASYNC_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_CTX_NEW, 0), "async_ctx_new"},
|
||||
{ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_INIT_THREAD, 0),
|
||||
"ASYNC_init_thread"},
|
||||
{ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_JOB_NEW, 0), "async_job_new"},
|
||||
{ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_PAUSE_JOB, 0), "ASYNC_pause_job"},
|
||||
{ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_START_FUNC, 0), "async_start_func"},
|
||||
{ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_START_JOB, 0), "ASYNC_start_job"},
|
||||
{ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_WAIT_CTX_SET_WAIT_FD, 0),
|
||||
"ASYNC_WAIT_CTX_set_wait_fd"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static const ERR_STRING_DATA ASYNC_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_ASYNC, 0, ASYNC_R_FAILED_TO_SET_POOL),
|
||||
"failed to set pool"},
|
||||
@@ -42,10 +29,8 @@ static const ERR_STRING_DATA ASYNC_str_reasons[] = {
|
||||
int ERR_load_ASYNC_strings(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
if (ERR_func_error_string(ASYNC_str_functs[0].error) == NULL) {
|
||||
ERR_load_strings_const(ASYNC_str_functs);
|
||||
if (ERR_reason_error_string(ASYNC_str_reasons[0].error) == NULL)
|
||||
ERR_load_strings_const(ASYNC_str_reasons);
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -12,8 +12,7 @@ push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "x86asm.pl";
|
||||
require "cbc.pl";
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0],$ARGV[$#ARGV] eq "386");
|
||||
|
||||
|
||||
@@ -13,6 +13,5 @@ ENDIF
|
||||
|
||||
SOURCE[../../libcrypto]=bf_skey.c bf_ecb.c bf_cfb64.c bf_ofb64.c $BFASM
|
||||
|
||||
GENERATE[bf-586.s]=asm/bf-586.pl \
|
||||
$(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR)
|
||||
GENERATE[bf-586.s]=asm/bf-586.pl
|
||||
DEPEND[bf-586.s]=../perlasm/x86asm.pl ../perlasm/cbc.pl
|
||||
+27
-25
@@ -207,7 +207,8 @@ static int addr_strings(const BIO_ADDR *ap, int numeric,
|
||||
flags)) != 0) {
|
||||
# ifdef EAI_SYSTEM
|
||||
if (ret == EAI_SYSTEM) {
|
||||
SYSerr(SYS_F_GETNAMEINFO, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling getnameinfo()");
|
||||
BIOerr(BIO_F_ADDR_STRINGS, ERR_R_SYS_LIB);
|
||||
} else
|
||||
# endif
|
||||
@@ -675,7 +676,7 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
|
||||
|
||||
if (1) {
|
||||
#ifdef AI_PASSIVE
|
||||
int gai_ret = 0;
|
||||
int gai_ret = 0, old_ret = 0;
|
||||
struct addrinfo hints;
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
@@ -683,12 +684,12 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
|
||||
hints.ai_family = family;
|
||||
hints.ai_socktype = socktype;
|
||||
hints.ai_protocol = protocol;
|
||||
#ifdef AI_ADDRCONFIG
|
||||
#ifdef AF_UNSPEC
|
||||
# ifdef AI_ADDRCONFIG
|
||||
# ifdef AF_UNSPEC
|
||||
if (family == AF_UNSPEC)
|
||||
#endif
|
||||
# endif
|
||||
hints.ai_flags |= AI_ADDRCONFIG;
|
||||
#endif
|
||||
# endif
|
||||
|
||||
if (lookup_type == BIO_LOOKUP_SERVER)
|
||||
hints.ai_flags |= AI_PASSIVE;
|
||||
@@ -700,29 +701,30 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
|
||||
switch ((gai_ret = getaddrinfo(host, service, &hints, res))) {
|
||||
# ifdef EAI_SYSTEM
|
||||
case EAI_SYSTEM:
|
||||
SYSerr(SYS_F_GETADDRINFO, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling getaddrinfo()");
|
||||
BIOerr(BIO_F_BIO_LOOKUP_EX, ERR_R_SYS_LIB);
|
||||
break;
|
||||
# endif
|
||||
# ifdef EAI_MEMORY
|
||||
case EAI_MEMORY:
|
||||
BIOerr(BIO_F_BIO_LOOKUP_EX, ERR_R_MALLOC_FAILURE);
|
||||
break;
|
||||
# endif
|
||||
case 0:
|
||||
ret = 1; /* Success */
|
||||
break;
|
||||
# if (defined(EAI_FAMILY) || defined(EAI_ADDRFAMILY)) && defined(AI_ADDRCONFIG)
|
||||
# ifdef EAI_FAMILY
|
||||
case EAI_FAMILY:
|
||||
# endif
|
||||
# ifdef EAI_ADDRFAMILY
|
||||
case EAI_ADDRFAMILY:
|
||||
# endif
|
||||
default:
|
||||
# if defined(AI_ADDRCONFIG) && defined(AI_NUMERICHOST)
|
||||
if (hints.ai_flags & AI_ADDRCONFIG) {
|
||||
hints.ai_flags &= ~AI_ADDRCONFIG;
|
||||
hints.ai_flags |= AI_NUMERICHOST;
|
||||
old_ret = gai_ret;
|
||||
goto retry;
|
||||
}
|
||||
# endif
|
||||
/* fall through */
|
||||
default:
|
||||
BIOerr(BIO_F_BIO_LOOKUP_EX, ERR_R_SYS_LIB);
|
||||
ERR_add_error_data(1, gai_strerror(gai_ret));
|
||||
ERR_add_error_data(1, gai_strerror(old_ret ? old_ret : gai_ret));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -804,12 +806,15 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
|
||||
*/
|
||||
# if defined(OPENSSL_SYS_VXWORKS)
|
||||
/* h_errno doesn't exist on VxWorks */
|
||||
SYSerr(SYS_F_GETHOSTBYNAME, 1000 );
|
||||
ERR_raise_data(ERR_LIB_SYS, 1000,
|
||||
"calling gethostbyname()");
|
||||
# else
|
||||
SYSerr(SYS_F_GETHOSTBYNAME, 1000 + h_errno);
|
||||
ERR_raise_data(ERR_LIB_SYS, 1000 + h_errno,
|
||||
"calling gethostbyname()");
|
||||
# endif
|
||||
#else
|
||||
SYSerr(SYS_F_GETHOSTBYNAME, WSAGetLastError());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling gethostbyname()");
|
||||
#endif
|
||||
ret = 0;
|
||||
goto err;
|
||||
@@ -855,11 +860,8 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
|
||||
se = getservbyname(service, proto);
|
||||
|
||||
if (se == NULL) {
|
||||
#ifndef OPENSSL_SYS_WINDOWS
|
||||
SYSerr(SYS_F_GETSERVBYNAME, errno);
|
||||
#else
|
||||
SYSerr(SYS_F_GETSERVBYNAME, WSAGetLastError());
|
||||
#endif
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling getservbyname()");
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
|
||||
+12
-9
@@ -120,8 +120,6 @@ int BIO_sock_init(void)
|
||||
static struct WSAData wsa_state;
|
||||
|
||||
if (!wsa_init_done) {
|
||||
int err;
|
||||
|
||||
wsa_init_done = 1;
|
||||
memset(&wsa_state, 0, sizeof(wsa_state));
|
||||
/*
|
||||
@@ -131,8 +129,8 @@ int BIO_sock_init(void)
|
||||
* probed at run-time with DSO_global_lookup.
|
||||
*/
|
||||
if (WSAStartup(0x0202, &wsa_state) != 0) {
|
||||
err = WSAGetLastError();
|
||||
SYSerr(SYS_F_WSASTARTUP, err);
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling wsastartup()");
|
||||
BIOerr(BIO_F_BIO_SOCK_INIT, BIO_R_WSASTARTUP);
|
||||
return -1;
|
||||
}
|
||||
@@ -192,7 +190,8 @@ int BIO_socket_ioctl(int fd, long type, void *arg)
|
||||
i = ioctlsocket(fd, type, ARG);
|
||||
# endif /* __DJGPP__ */
|
||||
if (i < 0)
|
||||
SYSerr(SYS_F_IOCTLSOCKET, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling ioctlsocket()");
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -243,7 +242,8 @@ int BIO_accept(int sock, char **ip_port)
|
||||
ret = -2;
|
||||
goto end;
|
||||
}
|
||||
SYSerr(SYS_F_ACCEPT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling accept()");
|
||||
BIOerr(BIO_F_BIO_ACCEPT, BIO_R_ACCEPT_ERROR);
|
||||
goto end;
|
||||
}
|
||||
@@ -308,7 +308,8 @@ int BIO_socket_nbio(int s, int mode)
|
||||
|
||||
l = fcntl(s, F_GETFL, 0);
|
||||
if (l == -1) {
|
||||
SYSerr(SYS_F_FCNTL, get_last_sys_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
|
||||
"calling fcntl()");
|
||||
ret = -1;
|
||||
} else {
|
||||
# if defined(O_NONBLOCK)
|
||||
@@ -326,7 +327,8 @@ int BIO_socket_nbio(int s, int mode)
|
||||
ret = fcntl(s, F_SETFL, l);
|
||||
|
||||
if (ret < 0) {
|
||||
SYSerr(SYS_F_FCNTL, get_last_sys_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
|
||||
"calling fcntl()");
|
||||
}
|
||||
}
|
||||
# else
|
||||
@@ -349,7 +351,8 @@ int BIO_sock_info(int sock,
|
||||
ret = getsockname(sock, BIO_ADDR_sockaddr_noconst(info->addr),
|
||||
&addr_len);
|
||||
if (ret == -1) {
|
||||
SYSerr(SYS_F_GETSOCKNAME, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling getsockname()");
|
||||
BIOerr(BIO_F_BIO_SOCK_INFO, BIO_R_GETSOCKNAME_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+24
-12
@@ -46,7 +46,8 @@ int BIO_socket(int domain, int socktype, int protocol, int options)
|
||||
|
||||
sock = socket(domain, socktype, protocol);
|
||||
if (sock == -1) {
|
||||
SYSerr(SYS_F_SOCKET, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling socket()");
|
||||
BIOerr(BIO_F_BIO_SOCKET, BIO_R_UNABLE_TO_CREATE_SOCKET);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
@@ -89,7 +90,8 @@ int BIO_connect(int sock, const BIO_ADDR *addr, int options)
|
||||
if (options & BIO_SOCK_KEEPALIVE) {
|
||||
if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
|
||||
(const void *)&on, sizeof(on)) != 0) {
|
||||
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling setsockopt()");
|
||||
BIOerr(BIO_F_BIO_CONNECT, BIO_R_UNABLE_TO_KEEPALIVE);
|
||||
return 0;
|
||||
}
|
||||
@@ -98,7 +100,8 @@ int BIO_connect(int sock, const BIO_ADDR *addr, int options)
|
||||
if (options & BIO_SOCK_NODELAY) {
|
||||
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
|
||||
(const void *)&on, sizeof(on)) != 0) {
|
||||
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling setsockopt()");
|
||||
BIOerr(BIO_F_BIO_CONNECT, BIO_R_UNABLE_TO_NODELAY);
|
||||
return 0;
|
||||
}
|
||||
@@ -107,7 +110,8 @@ int BIO_connect(int sock, const BIO_ADDR *addr, int options)
|
||||
if (connect(sock, BIO_ADDR_sockaddr(addr),
|
||||
BIO_ADDR_sockaddr_size(addr)) == -1) {
|
||||
if (!BIO_sock_should_retry(-1)) {
|
||||
SYSerr(SYS_F_CONNECT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling connect()");
|
||||
BIOerr(BIO_F_BIO_CONNECT, BIO_R_CONNECT_ERROR);
|
||||
}
|
||||
return 0;
|
||||
@@ -150,7 +154,8 @@ int BIO_bind(int sock, const BIO_ADDR *addr, int options)
|
||||
if (options & BIO_SOCK_REUSEADDR) {
|
||||
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
|
||||
(const void *)&on, sizeof(on)) != 0) {
|
||||
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling setsockopt()");
|
||||
BIOerr(BIO_F_BIO_BIND, BIO_R_UNABLE_TO_REUSEADDR);
|
||||
return 0;
|
||||
}
|
||||
@@ -158,7 +163,8 @@ int BIO_bind(int sock, const BIO_ADDR *addr, int options)
|
||||
# endif
|
||||
|
||||
if (bind(sock, BIO_ADDR_sockaddr(addr), BIO_ADDR_sockaddr_size(addr)) != 0) {
|
||||
SYSerr(SYS_F_BIND, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling bind()");
|
||||
BIOerr(BIO_F_BIO_BIND, BIO_R_UNABLE_TO_BIND_SOCKET);
|
||||
return 0;
|
||||
}
|
||||
@@ -217,7 +223,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
|
||||
if (getsockopt(sock, SOL_SOCKET, SO_TYPE,
|
||||
(void *)&socktype, &socktype_len) != 0
|
||||
|| socktype_len != sizeof(socktype)) {
|
||||
SYSerr(SYS_F_GETSOCKOPT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling getsockopt()");
|
||||
BIOerr(BIO_F_BIO_LISTEN, BIO_R_GETTING_SOCKTYPE);
|
||||
return 0;
|
||||
}
|
||||
@@ -228,7 +235,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
|
||||
if (options & BIO_SOCK_KEEPALIVE) {
|
||||
if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
|
||||
(const void *)&on, sizeof(on)) != 0) {
|
||||
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling setsockopt()");
|
||||
BIOerr(BIO_F_BIO_LISTEN, BIO_R_UNABLE_TO_KEEPALIVE);
|
||||
return 0;
|
||||
}
|
||||
@@ -237,7 +245,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
|
||||
if (options & BIO_SOCK_NODELAY) {
|
||||
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
|
||||
(const void *)&on, sizeof(on)) != 0) {
|
||||
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling setsockopt()");
|
||||
BIOerr(BIO_F_BIO_LISTEN, BIO_R_UNABLE_TO_NODELAY);
|
||||
return 0;
|
||||
}
|
||||
@@ -252,7 +261,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
|
||||
on = options & BIO_SOCK_V6_ONLY ? 1 : 0;
|
||||
if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||
(const void *)&on, sizeof(on)) != 0) {
|
||||
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling setsockopt()");
|
||||
BIOerr(BIO_F_BIO_LISTEN, BIO_R_LISTEN_V6_ONLY);
|
||||
return 0;
|
||||
}
|
||||
@@ -263,7 +273,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
|
||||
return 0;
|
||||
|
||||
if (socktype != SOCK_DGRAM && listen(sock, MAX_LISTEN) == -1) {
|
||||
SYSerr(SYS_F_LISTEN, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling listen()");
|
||||
BIOerr(BIO_F_BIO_LISTEN, BIO_R_UNABLE_TO_LISTEN_SOCKET);
|
||||
return 0;
|
||||
}
|
||||
@@ -290,7 +301,8 @@ int BIO_accept_ex(int accept_sock, BIO_ADDR *addr_, int options)
|
||||
BIO_ADDR_sockaddr_noconst(addr), &len);
|
||||
if (accepted_sock == -1) {
|
||||
if (!BIO_sock_should_retry(accepted_sock)) {
|
||||
SYSerr(SYS_F_ACCEPT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling accept()");
|
||||
BIOerr(BIO_F_BIO_ACCEPT_EX, BIO_R_ACCEPT_ERROR);
|
||||
}
|
||||
return INVALID_SOCKET;
|
||||
|
||||
+2
-64
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Generated by util/mkerr.pl DO NOT EDIT
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2019 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
|
||||
@@ -13,66 +13,6 @@
|
||||
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
static const ERR_STRING_DATA BIO_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_ACPT_STATE, 0), "acpt_state"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_ADDRINFO_WRAP, 0), "addrinfo_wrap"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_ADDR_STRINGS, 0), "addr_strings"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_ACCEPT, 0), "BIO_accept"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_ACCEPT_EX, 0), "BIO_accept_ex"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_ACCEPT_NEW, 0), "BIO_ACCEPT_new"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_ADDR_NEW, 0), "BIO_ADDR_new"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_BIND, 0), "BIO_bind"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_CALLBACK_CTRL, 0), "BIO_callback_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_CONNECT, 0), "BIO_connect"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_CONNECT_NEW, 0), "BIO_CONNECT_new"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_CTRL, 0), "BIO_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_GETS, 0), "BIO_gets"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_GET_HOST_IP, 0), "BIO_get_host_ip"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_GET_NEW_INDEX, 0), "BIO_get_new_index"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_GET_PORT, 0), "BIO_get_port"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_LISTEN, 0), "BIO_listen"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_LOOKUP, 0), "BIO_lookup"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_LOOKUP_EX, 0), "BIO_lookup_ex"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_MAKE_PAIR, 0), "bio_make_pair"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_METH_NEW, 0), "BIO_meth_new"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NEW, 0), "BIO_new"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NEW_DGRAM_SCTP, 0), "BIO_new_dgram_sctp"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NEW_FILE, 0), "BIO_new_file"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NEW_MEM_BUF, 0), "BIO_new_mem_buf"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NREAD, 0), "BIO_nread"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NREAD0, 0), "BIO_nread0"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NWRITE, 0), "BIO_nwrite"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NWRITE0, 0), "BIO_nwrite0"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_PARSE_HOSTSERV, 0), "BIO_parse_hostserv"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_PUTS, 0), "BIO_puts"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_READ, 0), "BIO_read"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_READ_EX, 0), "BIO_read_ex"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_READ_INTERN, 0), "bio_read_intern"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_SOCKET, 0), "BIO_socket"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_SOCKET_NBIO, 0), "BIO_socket_nbio"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_SOCK_INFO, 0), "BIO_sock_info"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_SOCK_INIT, 0), "BIO_sock_init"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_WRITE, 0), "BIO_write"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_WRITE_EX, 0), "BIO_write_ex"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_WRITE_INTERN, 0), "bio_write_intern"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BUFFER_CTRL, 0), "buffer_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_CONN_CTRL, 0), "conn_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_CONN_STATE, 0), "conn_state"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_DGRAM_SCTP_NEW, 0), "dgram_sctp_new"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_DGRAM_SCTP_READ, 0), "dgram_sctp_read"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_DGRAM_SCTP_WRITE, 0), "dgram_sctp_write"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_DOAPR_OUTCH, 0), "doapr_outch"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_FILE_CTRL, 0), "file_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_FILE_READ, 0), "file_read"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_LINEBUFFER_CTRL, 0), "linebuffer_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_LINEBUFFER_NEW, 0), "linebuffer_new"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_MEM_WRITE, 0), "mem_write"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_NBIOF_NEW, 0), "nbiof_new"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_SLG_WRITE, 0), "slg_write"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_SSL_NEW, 0), "SSL_new"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static const ERR_STRING_DATA BIO_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_BIO, 0, BIO_R_ACCEPT_ERROR), "accept error"},
|
||||
{ERR_PACK(ERR_LIB_BIO, 0, BIO_R_ADDRINFO_ADDR_IS_NOT_AF_INET),
|
||||
@@ -136,10 +76,8 @@ static const ERR_STRING_DATA BIO_str_reasons[] = {
|
||||
int ERR_load_BIO_strings(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
if (ERR_func_error_string(BIO_str_functs[0].error) == NULL) {
|
||||
ERR_load_strings_const(BIO_str_functs);
|
||||
if (ERR_reason_error_string(BIO_str_reasons[0].error) == NULL)
|
||||
ERR_load_strings_const(BIO_str_reasons);
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -226,10 +226,9 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c)
|
||||
BIO_ADDRINFO_socktype(c->addr_iter),
|
||||
BIO_ADDRINFO_protocol(c->addr_iter), 0);
|
||||
if (ret == (int)INVALID_SOCKET) {
|
||||
SYSerr(SYS_F_SOCKET, get_last_socket_error());
|
||||
ERR_add_error_data(4,
|
||||
"hostname=", c->param_addr,
|
||||
" service=", c->param_serv);
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling socket(%s, %s)",
|
||||
c->param_addr, c->param_serv);
|
||||
BIOerr(BIO_F_ACPT_STATE, BIO_R_UNABLE_TO_CREATE_SOCKET);
|
||||
goto exit_loop;
|
||||
}
|
||||
|
||||
+9
-12
@@ -138,10 +138,9 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
|
||||
BIO_ADDRINFO_socktype(c->addr_iter),
|
||||
BIO_ADDRINFO_protocol(c->addr_iter), 0);
|
||||
if (ret == (int)INVALID_SOCKET) {
|
||||
SYSerr(SYS_F_SOCKET, get_last_socket_error());
|
||||
ERR_add_error_data(4,
|
||||
"hostname=", c->param_hostname,
|
||||
" service=", c->param_service);
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling socket(%s, %s)",
|
||||
c->param_hostname, c->param_service);
|
||||
BIOerr(BIO_F_CONN_STATE, BIO_R_UNABLE_TO_CREATE_SOCKET);
|
||||
goto exit_loop;
|
||||
}
|
||||
@@ -170,10 +169,9 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
|
||||
ERR_clear_error();
|
||||
break;
|
||||
} else {
|
||||
SYSerr(SYS_F_CONNECT, get_last_socket_error());
|
||||
ERR_add_error_data(4,
|
||||
"hostname=", c->param_hostname,
|
||||
" service=", c->param_service);
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling connect(%s, %s)",
|
||||
c->param_hostname, c->param_service);
|
||||
BIOerr(BIO_F_CONN_STATE, BIO_R_CONNECT_ERROR);
|
||||
}
|
||||
goto exit_loop;
|
||||
@@ -186,10 +184,9 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
|
||||
i = BIO_sock_error(b->num);
|
||||
if (i) {
|
||||
BIO_clear_retry_flags(b);
|
||||
SYSerr(SYS_F_CONNECT, i);
|
||||
ERR_add_error_data(4,
|
||||
"hostname=", c->param_hostname,
|
||||
" service=", c->param_service);
|
||||
ERR_raise_data(ERR_LIB_SYS, i,
|
||||
"calling connect(%s, %s)",
|
||||
c->param_hostname, c->param_service);
|
||||
BIOerr(BIO_F_CONN_STATE, BIO_R_NBIO_CONNECT_ERROR);
|
||||
ret = 0;
|
||||
goto exit_loop;
|
||||
|
||||
+19
-6
@@ -53,6 +53,8 @@ static int dgram_sctp_puts(BIO *h, const char *str);
|
||||
static long dgram_sctp_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int dgram_sctp_new(BIO *h);
|
||||
static int dgram_sctp_free(BIO *data);
|
||||
static int dgram_sctp_wait_for_dry(BIO *b);
|
||||
static int dgram_sctp_msg_waiting(BIO *b);
|
||||
# ifdef SCTP_AUTHENTICATION_EVENT
|
||||
static void dgram_sctp_handle_auth_free_key_event(BIO *b, union sctp_notification
|
||||
*snp);
|
||||
@@ -124,7 +126,7 @@ typedef struct bio_dgram_sctp_data_st {
|
||||
struct bio_dgram_sctp_sndinfo sndinfo;
|
||||
struct bio_dgram_sctp_rcvinfo rcvinfo;
|
||||
struct bio_dgram_sctp_prinfo prinfo;
|
||||
void (*handle_notifications) (BIO *bio, void *context, void *buf);
|
||||
BIO_dgram_sctp_notification_handler_fn handle_notifications;
|
||||
void *notification_context;
|
||||
int in_handshake;
|
||||
int ccs_rcvd;
|
||||
@@ -1562,6 +1564,10 @@ static long dgram_sctp_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
else
|
||||
data->save_shutdown = 0;
|
||||
break;
|
||||
case BIO_CTRL_DGRAM_SCTP_WAIT_FOR_DRY:
|
||||
return dgram_sctp_wait_for_dry(b);
|
||||
case BIO_CTRL_DGRAM_SCTP_MSG_WAITING:
|
||||
return dgram_sctp_msg_waiting(b);
|
||||
|
||||
default:
|
||||
/*
|
||||
@@ -1574,11 +1580,8 @@ static long dgram_sctp_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
}
|
||||
|
||||
int BIO_dgram_sctp_notification_cb(BIO *b,
|
||||
void (*handle_notifications) (BIO *bio,
|
||||
void
|
||||
*context,
|
||||
void *buf),
|
||||
void *context)
|
||||
BIO_dgram_sctp_notification_handler_fn handle_notifications,
|
||||
void *context)
|
||||
{
|
||||
bio_dgram_sctp_data *data = (bio_dgram_sctp_data *) b->ptr;
|
||||
|
||||
@@ -1605,6 +1608,11 @@ int BIO_dgram_sctp_notification_cb(BIO *b,
|
||||
* 1 when dry
|
||||
*/
|
||||
int BIO_dgram_sctp_wait_for_dry(BIO *b)
|
||||
{
|
||||
return (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SCTP_WAIT_FOR_DRY, 0, NULL);
|
||||
}
|
||||
|
||||
static int dgram_sctp_wait_for_dry(BIO *b)
|
||||
{
|
||||
int is_dry = 0;
|
||||
int sockflags = 0;
|
||||
@@ -1763,6 +1771,11 @@ int BIO_dgram_sctp_wait_for_dry(BIO *b)
|
||||
}
|
||||
|
||||
int BIO_dgram_sctp_msg_waiting(BIO *b)
|
||||
{
|
||||
return (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SCTP_MSG_WAITING, 0, NULL);
|
||||
}
|
||||
|
||||
static int dgram_sctp_msg_waiting(BIO *b)
|
||||
{
|
||||
int n, sockflags;
|
||||
union sctp_notification snp;
|
||||
|
||||
+38
-40
@@ -7,10 +7,7 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BSS_FILE_C
|
||||
# define HEADER_BSS_FILE_C
|
||||
|
||||
# if defined(__linux) || defined(__sun) || defined(__hpux)
|
||||
#if defined(__linux) || defined(__sun) || defined(__hpux)
|
||||
/*
|
||||
* Following definition aliases fopen to fopen64 on above mentioned
|
||||
* platforms. This makes it possible to open and sequentially access files
|
||||
@@ -23,17 +20,17 @@
|
||||
* of 32-bit platforms which allow for sequential access of large files
|
||||
* without extra "magic" comprise *BSD, Darwin, IRIX...
|
||||
*/
|
||||
# ifndef _FILE_OFFSET_BITS
|
||||
# define _FILE_OFFSET_BITS 64
|
||||
# endif
|
||||
# ifndef _FILE_OFFSET_BITS
|
||||
# define _FILE_OFFSET_BITS 64
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# include <stdio.h>
|
||||
# include <errno.h>
|
||||
# include "bio_lcl.h"
|
||||
# include <openssl/err.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "bio_lcl.h"
|
||||
#include <openssl/err.h>
|
||||
|
||||
# if !defined(OPENSSL_NO_STDIO)
|
||||
#if !defined(OPENSSL_NO_STDIO)
|
||||
|
||||
static int file_write(BIO *h, const char *buf, int num);
|
||||
static int file_read(BIO *h, char *buf, int size);
|
||||
@@ -69,12 +66,13 @@ BIO *BIO_new_file(const char *filename, const char *mode)
|
||||
fp_flags |= BIO_FP_TEXT;
|
||||
|
||||
if (file == NULL) {
|
||||
SYSerr(SYS_F_FOPEN, get_last_sys_error());
|
||||
ERR_add_error_data(5, "fopen('", filename, "','", mode, "')");
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
|
||||
"calling fopen(%s, %s)",
|
||||
filename, mode);
|
||||
if (errno == ENOENT
|
||||
# ifdef ENXIO
|
||||
#ifdef ENXIO
|
||||
|| errno == ENXIO
|
||||
# endif
|
||||
#endif
|
||||
)
|
||||
BIOerr(BIO_F_BIO_NEW_FILE, BIO_R_NO_SUCH_FILE);
|
||||
else
|
||||
@@ -149,7 +147,8 @@ static int file_read(BIO *b, char *out, int outl)
|
||||
if (ret == 0
|
||||
&& (b->flags & BIO_FLAGS_UPLINK_INTERNAL
|
||||
? UP_ferror((FILE *)b->ptr) : ferror((FILE *)b->ptr))) {
|
||||
SYSerr(SYS_F_FREAD, get_last_sys_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
|
||||
"calling fread()");
|
||||
BIOerr(BIO_F_FILE_READ, ERR_R_SYS_LIB);
|
||||
ret = -1;
|
||||
}
|
||||
@@ -212,33 +211,33 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
b->shutdown = (int)num & BIO_CLOSE;
|
||||
b->ptr = ptr;
|
||||
b->init = 1;
|
||||
# if BIO_FLAGS_UPLINK_INTERNAL!=0
|
||||
# if defined(__MINGW32__) && defined(__MSVCRT__) && !defined(_IOB_ENTRIES)
|
||||
# define _IOB_ENTRIES 20
|
||||
# endif
|
||||
# if BIO_FLAGS_UPLINK_INTERNAL!=0
|
||||
# if defined(__MINGW32__) && defined(__MSVCRT__) && !defined(_IOB_ENTRIES)
|
||||
# define _IOB_ENTRIES 20
|
||||
# endif
|
||||
/* Safety net to catch purely internal BIO_set_fp calls */
|
||||
# if defined(_MSC_VER) && _MSC_VER>=1900
|
||||
# if defined(_MSC_VER) && _MSC_VER>=1900
|
||||
if (ptr == stdin || ptr == stdout || ptr == stderr)
|
||||
BIO_clear_flags(b, BIO_FLAGS_UPLINK_INTERNAL);
|
||||
# elif defined(_IOB_ENTRIES)
|
||||
# elif defined(_IOB_ENTRIES)
|
||||
if ((size_t)ptr >= (size_t)stdin &&
|
||||
(size_t)ptr < (size_t)(stdin + _IOB_ENTRIES))
|
||||
BIO_clear_flags(b, BIO_FLAGS_UPLINK_INTERNAL);
|
||||
# endif
|
||||
# endif
|
||||
# ifdef UP_fsetmod
|
||||
# endif
|
||||
# ifdef UP_fsetmod
|
||||
if (b->flags & BIO_FLAGS_UPLINK_INTERNAL)
|
||||
UP_fsetmod(b->ptr, (char)((num & BIO_FP_TEXT) ? 't' : 'b'));
|
||||
else
|
||||
# endif
|
||||
# endif
|
||||
{
|
||||
# if defined(OPENSSL_SYS_WINDOWS)
|
||||
# if defined(OPENSSL_SYS_WINDOWS)
|
||||
int fd = _fileno((FILE *)ptr);
|
||||
if (num & BIO_FP_TEXT)
|
||||
_setmode(fd, _O_TEXT);
|
||||
else
|
||||
_setmode(fd, _O_BINARY);
|
||||
# elif defined(OPENSSL_SYS_MSDOS)
|
||||
# elif defined(OPENSSL_SYS_MSDOS)
|
||||
int fd = fileno((FILE *)ptr);
|
||||
/* Set correct text/binary mode */
|
||||
if (num & BIO_FP_TEXT)
|
||||
@@ -251,11 +250,11 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
} else
|
||||
_setmode(fd, _O_BINARY);
|
||||
}
|
||||
# elif defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
# elif defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
int fd = fileno((FILE *)ptr);
|
||||
if (!(num & BIO_FP_TEXT))
|
||||
setmode(fd, O_BINARY);
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
break;
|
||||
case BIO_C_SET_FILENAME:
|
||||
@@ -277,19 +276,20 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS)
|
||||
# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS)
|
||||
if (!(num & BIO_FP_TEXT))
|
||||
OPENSSL_strlcat(p, "b", sizeof(p));
|
||||
else
|
||||
OPENSSL_strlcat(p, "t", sizeof(p));
|
||||
# elif defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
# elif defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
if (!(num & BIO_FP_TEXT))
|
||||
OPENSSL_strlcat(p, "b", sizeof(p));
|
||||
# endif
|
||||
# endif
|
||||
fp = openssl_fopen(ptr, p);
|
||||
if (fp == NULL) {
|
||||
SYSerr(SYS_F_FOPEN, get_last_sys_error());
|
||||
ERR_add_error_data(5, "fopen('", ptr, "','", p, "')");
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
|
||||
"calling fopen(%s, %s)",
|
||||
ptr, p);
|
||||
BIOerr(BIO_F_FILE_CTRL, ERR_R_SYS_LIB);
|
||||
ret = 0;
|
||||
break;
|
||||
@@ -316,8 +316,8 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
st = b->flags & BIO_FLAGS_UPLINK_INTERNAL
|
||||
? UP_fflush(b->ptr) : fflush((FILE *)b->ptr);
|
||||
if (st == EOF) {
|
||||
SYSerr(SYS_F_FFLUSH, get_last_sys_error());
|
||||
ERR_add_error_data(1, "fflush()");
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
|
||||
"calling fflush()");
|
||||
BIOerr(BIO_F_FILE_CTRL, ERR_R_SYS_LIB);
|
||||
ret = 0;
|
||||
}
|
||||
@@ -422,6 +422,4 @@ BIO *BIO_new_file(const char *filename, const char *mode)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
# endif /* OPENSSL_NO_STDIO */
|
||||
|
||||
#endif /* HEADER_BSS_FILE_C */
|
||||
#endif /* OPENSSL_NO_STDIO */
|
||||
@@ -1,196 +0,0 @@
|
||||
/*
|
||||
* Copyright 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
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#ifndef OPENSSL_NO_BLAKE2
|
||||
|
||||
# include <openssl/evp.h>
|
||||
# include "internal/blake2.h"
|
||||
# include "internal/cryptlib.h"
|
||||
# include "internal/evp_int.h"
|
||||
|
||||
/* typedef EVP_MAC_IMPL */
|
||||
struct evp_mac_impl_st {
|
||||
BLAKE2B_CTX ctx;
|
||||
BLAKE2B_PARAM params;
|
||||
unsigned char key[BLAKE2B_KEYBYTES];
|
||||
};
|
||||
|
||||
static EVP_MAC_IMPL *blake2b_mac_new(void)
|
||||
{
|
||||
EVP_MAC_IMPL *macctx = OPENSSL_zalloc(sizeof(*macctx));
|
||||
if (macctx != NULL) {
|
||||
blake2b_param_init(&macctx->params);
|
||||
/* ctx initialization is deferred to blake2b_init() */
|
||||
}
|
||||
return macctx;
|
||||
}
|
||||
|
||||
static void blake2b_mac_free(EVP_MAC_IMPL *macctx)
|
||||
{
|
||||
if (macctx != NULL) {
|
||||
OPENSSL_cleanse(macctx->key, sizeof(macctx->key));
|
||||
OPENSSL_free(macctx);
|
||||
}
|
||||
}
|
||||
|
||||
static EVP_MAC_IMPL *blake2b_mac_dup(const EVP_MAC_IMPL *src)
|
||||
{
|
||||
EVP_MAC_IMPL *dst;
|
||||
|
||||
dst = OPENSSL_zalloc(sizeof(*dst));
|
||||
if (dst == NULL)
|
||||
return NULL;
|
||||
|
||||
*dst = *src;
|
||||
return dst;
|
||||
}
|
||||
|
||||
static int blake2b_mac_init(EVP_MAC_IMPL *macctx)
|
||||
{
|
||||
/* Check key has been set */
|
||||
if (macctx->params.key_length == 0) {
|
||||
EVPerr(EVP_F_BLAKE2B_MAC_INIT, EVP_R_NO_KEY_SET);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return blake2b_init_key(&macctx->ctx, &macctx->params, macctx->key);
|
||||
}
|
||||
|
||||
static int blake2b_mac_update(EVP_MAC_IMPL *macctx, const unsigned char *data,
|
||||
size_t datalen)
|
||||
{
|
||||
return blake2b_update(&macctx->ctx, data, datalen);
|
||||
}
|
||||
|
||||
static int blake2b_mac_final(EVP_MAC_IMPL *macctx, unsigned char *out)
|
||||
{
|
||||
return blake2b_final(out, &macctx->ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
* ALL Ctrl functions should be set before init().
|
||||
*/
|
||||
static int blake2b_mac_ctrl(EVP_MAC_IMPL *macctx, int cmd, va_list args)
|
||||
{
|
||||
const unsigned char *p;
|
||||
size_t len;
|
||||
size_t size;
|
||||
|
||||
switch (cmd) {
|
||||
case EVP_MAC_CTRL_SET_SIZE:
|
||||
size = va_arg(args, size_t);
|
||||
if (size < 1 || size > BLAKE2B_OUTBYTES) {
|
||||
EVPerr(EVP_F_BLAKE2B_MAC_CTRL, EVP_R_NOT_XOF_OR_INVALID_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
blake2b_param_set_digest_length(&macctx->params, (uint8_t)size);
|
||||
return 1;
|
||||
|
||||
case EVP_MAC_CTRL_SET_KEY:
|
||||
p = va_arg(args, const unsigned char *);
|
||||
len = va_arg(args, size_t);
|
||||
if (len < 1 || len > BLAKE2B_KEYBYTES) {
|
||||
EVPerr(EVP_F_BLAKE2B_MAC_CTRL, EVP_R_INVALID_KEY_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
blake2b_param_set_key_length(&macctx->params, (uint8_t)len);
|
||||
memcpy(macctx->key, p, len);
|
||||
memset(macctx->key + len, 0, BLAKE2B_KEYBYTES - len);
|
||||
return 1;
|
||||
|
||||
case EVP_MAC_CTRL_SET_CUSTOM:
|
||||
p = va_arg(args, const unsigned char *);
|
||||
len = va_arg(args, size_t);
|
||||
if (len > BLAKE2B_PERSONALBYTES) {
|
||||
EVPerr(EVP_F_BLAKE2B_MAC_CTRL, EVP_R_INVALID_CUSTOM_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
blake2b_param_set_personal(&macctx->params, p, len);
|
||||
return 1;
|
||||
|
||||
case EVP_MAC_CTRL_SET_SALT:
|
||||
p = va_arg(args, const unsigned char *);
|
||||
len = va_arg(args, size_t);
|
||||
if (len > BLAKE2B_SALTBYTES) {
|
||||
EVPerr(EVP_F_BLAKE2B_MAC_CTRL, EVP_R_INVALID_SALT_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
blake2b_param_set_salt(&macctx->params, p, len);
|
||||
return 1;
|
||||
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
static int blake2b_mac_ctrl_int(EVP_MAC_IMPL *macctx, int cmd, ...)
|
||||
{
|
||||
int rv;
|
||||
va_list args;
|
||||
|
||||
va_start(args, cmd);
|
||||
rv = blake2b_mac_ctrl(macctx, cmd, args);
|
||||
va_end(args);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int blake2b_mac_ctrl_str_cb(void *macctx, int cmd, void *buf, size_t buflen)
|
||||
{
|
||||
return blake2b_mac_ctrl_int(macctx, cmd, buf, buflen);
|
||||
}
|
||||
|
||||
static int blake2b_mac_ctrl_str(EVP_MAC_IMPL *macctx, const char *type,
|
||||
const char *value)
|
||||
{
|
||||
if (value == NULL)
|
||||
return 0;
|
||||
|
||||
if (strcmp(type, "outlen") == 0)
|
||||
return blake2b_mac_ctrl_int(macctx, EVP_MAC_CTRL_SET_SIZE, (size_t)atoi(value));
|
||||
if (strcmp(type, "key") == 0)
|
||||
return EVP_str2ctrl(blake2b_mac_ctrl_str_cb, macctx, EVP_MAC_CTRL_SET_KEY,
|
||||
value);
|
||||
if (strcmp(type, "hexkey") == 0)
|
||||
return EVP_hex2ctrl(blake2b_mac_ctrl_str_cb, macctx, EVP_MAC_CTRL_SET_KEY,
|
||||
value);
|
||||
if (strcmp(type, "custom") == 0)
|
||||
return EVP_str2ctrl(blake2b_mac_ctrl_str_cb, macctx, EVP_MAC_CTRL_SET_CUSTOM,
|
||||
value);
|
||||
if (strcmp(type, "hexcustom") == 0)
|
||||
return EVP_hex2ctrl(blake2b_mac_ctrl_str_cb, macctx, EVP_MAC_CTRL_SET_CUSTOM,
|
||||
value);
|
||||
if (strcmp(type, "salt") == 0)
|
||||
return EVP_str2ctrl(blake2b_mac_ctrl_str_cb, macctx, EVP_MAC_CTRL_SET_SALT,
|
||||
value);
|
||||
if (strcmp(type, "hexsalt") == 0)
|
||||
return EVP_hex2ctrl(blake2b_mac_ctrl_str_cb, macctx, EVP_MAC_CTRL_SET_SALT,
|
||||
value);
|
||||
return -2;
|
||||
}
|
||||
|
||||
static size_t blake2b_mac_size(EVP_MAC_IMPL *macctx)
|
||||
{
|
||||
return macctx->params.digest_length;
|
||||
}
|
||||
|
||||
const EVP_MAC blake2b_mac_meth = {
|
||||
EVP_MAC_BLAKE2B,
|
||||
blake2b_mac_new,
|
||||
blake2b_mac_dup,
|
||||
blake2b_mac_free,
|
||||
blake2b_mac_size,
|
||||
blake2b_mac_init,
|
||||
blake2b_mac_update,
|
||||
blake2b_mac_final,
|
||||
blake2b_mac_ctrl,
|
||||
blake2b_mac_ctrl_str
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,196 +0,0 @@
|
||||
/*
|
||||
* Copyright 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
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#ifndef OPENSSL_NO_BLAKE2
|
||||
|
||||
# include <openssl/evp.h>
|
||||
# include "internal/blake2.h"
|
||||
# include "internal/cryptlib.h"
|
||||
# include "internal/evp_int.h"
|
||||
|
||||
/* typedef EVP_MAC_IMPL */
|
||||
struct evp_mac_impl_st {
|
||||
BLAKE2S_CTX ctx;
|
||||
BLAKE2S_PARAM params;
|
||||
unsigned char key[BLAKE2S_KEYBYTES];
|
||||
};
|
||||
|
||||
static EVP_MAC_IMPL *blake2s_mac_new(void)
|
||||
{
|
||||
EVP_MAC_IMPL *macctx = OPENSSL_zalloc(sizeof(*macctx));
|
||||
if (macctx != NULL) {
|
||||
blake2s_param_init(&macctx->params);
|
||||
/* ctx initialization is deferred to BLAKE2s_Init() */
|
||||
}
|
||||
return macctx;
|
||||
}
|
||||
|
||||
static void blake2s_mac_free(EVP_MAC_IMPL *macctx)
|
||||
{
|
||||
if (macctx != NULL) {
|
||||
OPENSSL_cleanse(macctx->key, sizeof(macctx->key));
|
||||
OPENSSL_free(macctx);
|
||||
}
|
||||
}
|
||||
|
||||
static EVP_MAC_IMPL *blake2s_mac_dup(const EVP_MAC_IMPL *src)
|
||||
{
|
||||
EVP_MAC_IMPL *dst;
|
||||
|
||||
dst = OPENSSL_malloc(sizeof(*dst));
|
||||
if (dst == NULL)
|
||||
return NULL;
|
||||
|
||||
*dst = *src;
|
||||
return dst;
|
||||
}
|
||||
|
||||
static int blake2s_mac_init(EVP_MAC_IMPL *macctx)
|
||||
{
|
||||
/* Check key has been set */
|
||||
if (macctx->params.key_length == 0) {
|
||||
EVPerr(EVP_F_BLAKE2S_MAC_INIT, EVP_R_NO_KEY_SET);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return blake2s_init_key(&macctx->ctx, &macctx->params, macctx->key);
|
||||
}
|
||||
|
||||
static int blake2s_mac_update(EVP_MAC_IMPL *macctx, const unsigned char *data,
|
||||
size_t datalen)
|
||||
{
|
||||
return blake2s_update(&macctx->ctx, data, datalen);
|
||||
}
|
||||
|
||||
static int blake2s_mac_final(EVP_MAC_IMPL *macctx, unsigned char *out)
|
||||
{
|
||||
return blake2s_final(out, &macctx->ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
* ALL Ctrl functions should be set before init().
|
||||
*/
|
||||
static int blake2s_mac_ctrl(EVP_MAC_IMPL *macctx, int cmd, va_list args)
|
||||
{
|
||||
const unsigned char *p;
|
||||
size_t len;
|
||||
size_t size;
|
||||
|
||||
switch (cmd) {
|
||||
case EVP_MAC_CTRL_SET_SIZE:
|
||||
size = va_arg(args, size_t);
|
||||
if (size < 1 || size > BLAKE2S_OUTBYTES) {
|
||||
EVPerr(EVP_F_BLAKE2S_MAC_CTRL, EVP_R_NOT_XOF_OR_INVALID_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
blake2s_param_set_digest_length(&macctx->params, (uint8_t)size);
|
||||
return 1;
|
||||
|
||||
case EVP_MAC_CTRL_SET_KEY:
|
||||
p = va_arg(args, const unsigned char *);
|
||||
len = va_arg(args, size_t);
|
||||
if (len < 1 || len > BLAKE2S_KEYBYTES) {
|
||||
EVPerr(EVP_F_BLAKE2S_MAC_CTRL, EVP_R_INVALID_KEY_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
blake2s_param_set_key_length(&macctx->params, (uint8_t)len);
|
||||
memcpy(macctx->key, p, len);
|
||||
memset(macctx->key + len, 0, BLAKE2S_KEYBYTES - len);
|
||||
return 1;
|
||||
|
||||
case EVP_MAC_CTRL_SET_CUSTOM:
|
||||
p = va_arg(args, const unsigned char *);
|
||||
len = va_arg(args, size_t);
|
||||
if (len > BLAKE2S_PERSONALBYTES) {
|
||||
EVPerr(EVP_F_BLAKE2S_MAC_CTRL, EVP_R_INVALID_CUSTOM_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
blake2s_param_set_personal(&macctx->params, p, len);
|
||||
return 1;
|
||||
|
||||
case EVP_MAC_CTRL_SET_SALT:
|
||||
p = va_arg(args, const unsigned char *);
|
||||
len = va_arg(args, size_t);
|
||||
if (len > BLAKE2S_SALTBYTES) {
|
||||
EVPerr(EVP_F_BLAKE2S_MAC_CTRL, EVP_R_INVALID_SALT_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
blake2s_param_set_salt(&macctx->params, p, len);
|
||||
return 1;
|
||||
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
static int blake2s_mac_ctrl_int(EVP_MAC_IMPL *macctx, int cmd, ...)
|
||||
{
|
||||
int rv;
|
||||
va_list args;
|
||||
|
||||
va_start(args, cmd);
|
||||
rv = blake2s_mac_ctrl(macctx, cmd, args);
|
||||
va_end(args);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int blake2s_mac_ctrl_str_cb(void *macctx, int cmd, void *buf, size_t buflen)
|
||||
{
|
||||
return blake2s_mac_ctrl_int(macctx, cmd, buf, buflen);
|
||||
}
|
||||
|
||||
static int blake2s_mac_ctrl_str(EVP_MAC_IMPL *macctx, const char *type,
|
||||
const char *value)
|
||||
{
|
||||
if (value == NULL)
|
||||
return 0;
|
||||
|
||||
if (strcmp(type, "outlen") == 0)
|
||||
return blake2s_mac_ctrl_int(macctx, EVP_MAC_CTRL_SET_SIZE, (size_t)atoi(value));
|
||||
if (strcmp(type, "key") == 0)
|
||||
return EVP_str2ctrl(blake2s_mac_ctrl_str_cb, macctx, EVP_MAC_CTRL_SET_KEY,
|
||||
value);
|
||||
if (strcmp(type, "hexkey") == 0)
|
||||
return EVP_hex2ctrl(blake2s_mac_ctrl_str_cb, macctx, EVP_MAC_CTRL_SET_KEY,
|
||||
value);
|
||||
if (strcmp(type, "custom") == 0)
|
||||
return EVP_str2ctrl(blake2s_mac_ctrl_str_cb, macctx, EVP_MAC_CTRL_SET_CUSTOM,
|
||||
value);
|
||||
if (strcmp(type, "hexcustom") == 0)
|
||||
return EVP_hex2ctrl(blake2s_mac_ctrl_str_cb, macctx, EVP_MAC_CTRL_SET_CUSTOM,
|
||||
value);
|
||||
if (strcmp(type, "salt") == 0)
|
||||
return EVP_str2ctrl(blake2s_mac_ctrl_str_cb, macctx, EVP_MAC_CTRL_SET_SALT,
|
||||
value);
|
||||
if (strcmp(type, "hexsalt") == 0)
|
||||
return EVP_hex2ctrl(blake2s_mac_ctrl_str_cb, macctx, EVP_MAC_CTRL_SET_SALT,
|
||||
value);
|
||||
return -2;
|
||||
}
|
||||
|
||||
static size_t blake2s_mac_size(EVP_MAC_IMPL *macctx)
|
||||
{
|
||||
return macctx->params.digest_length;
|
||||
}
|
||||
|
||||
const EVP_MAC blake2s_mac_meth = {
|
||||
EVP_MAC_BLAKE2S,
|
||||
blake2s_mac_new,
|
||||
blake2s_mac_dup,
|
||||
blake2s_mac_free,
|
||||
blake2s_mac_size,
|
||||
blake2s_mac_init,
|
||||
blake2s_mac_update,
|
||||
blake2s_mac_final,
|
||||
blake2s_mac_ctrl,
|
||||
blake2s_mac_ctrl_str
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,3 +1,2 @@
|
||||
LIBS=../../libcrypto
|
||||
SOURCE[../../libcrypto]=\
|
||||
blake2b_mac.c blake2s_mac.c m_blake2b.c m_blake2s.c
|
||||
SOURCE[../../libcrypto]=m_blake2b.c m_blake2s.c
|
||||
@@ -22,8 +22,7 @@
|
||||
# I.e. if you compare 1GHz 21264 and 2GHz Opteron, you'll observe ~2x
|
||||
# difference.
|
||||
|
||||
$output=pop;
|
||||
open STDOUT,">$output";
|
||||
$output=pop and open STDOUT,">$output";
|
||||
|
||||
# int bn_mul_mont(
|
||||
$rp="a0"; # BN_ULONG *rp,
|
||||
|
||||
@@ -39,9 +39,10 @@
|
||||
#
|
||||
# http://conradoplg.cryptoland.net/files/2010/12/mocrysen13.pdf
|
||||
|
||||
$flavour = shift;
|
||||
if ($flavour=~/\w[\w\-]*\.\w+$/) { $output=$flavour; undef $flavour; }
|
||||
else { while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} }
|
||||
# $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;
|
||||
|
||||
if ($flavour && $flavour ne "void") {
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
@@ -49,9 +50,10 @@ if ($flavour && $flavour ne "void") {
|
||||
( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or
|
||||
die "can't locate arm-xlate.pl";
|
||||
|
||||
open STDOUT,"| \"$^X\" $xlate $flavour $output";
|
||||
open STDOUT,"| \"$^X\" $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $1";
|
||||
} else {
|
||||
open STDOUT,">$output";
|
||||
$output and open STDOUT,">$output";
|
||||
}
|
||||
|
||||
$code=<<___;
|
||||
|
||||
@@ -54,9 +54,10 @@
|
||||
# integer-only on Cortex-A8, ~10-210% on Cortex-A15, ~70-450% on
|
||||
# Snapdragon S4.
|
||||
|
||||
$flavour = shift;
|
||||
if ($flavour=~/\w[\w\-]*\.\w+$/) { $output=$flavour; undef $flavour; }
|
||||
else { while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} }
|
||||
# $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
|
||||
my $output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
my $flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
if ($flavour && $flavour ne "void") {
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
@@ -64,9 +65,10 @@ if ($flavour && $flavour ne "void") {
|
||||
( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or
|
||||
die "can't locate arm-xlate.pl";
|
||||
|
||||
open STDOUT,"| \"$^X\" $xlate $flavour $output";
|
||||
open STDOUT,"| \"$^X\" $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $1";
|
||||
} else {
|
||||
open STDOUT,">$output";
|
||||
$output and open STDOUT,">$output";
|
||||
}
|
||||
|
||||
$num="r0"; # starts as num argument, but holds &tp[num-1]
|
||||
|
||||
@@ -40,15 +40,18 @@
|
||||
# 50-70% improvement for RSA4096 sign. RSA2048 sign is ~25% faster
|
||||
# on Cortex-A57 and ~60-100% faster on others.
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
# $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
|
||||
my $output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
my $flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or
|
||||
( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or
|
||||
die "can't locate arm-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $1";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
($lo0,$hi0,$aj,$m0,$alo,$ahi,
|
||||
|
||||
@@ -11,8 +11,7 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "x86asm.pl";
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0]);
|
||||
|
||||
|
||||
@@ -23,8 +23,7 @@
|
||||
# totally unfair, because this module utilizes Galois Field Multiply
|
||||
# instruction.
|
||||
|
||||
while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
($rp,$a1,$a0,$b1,$b0)=("A4","B4","A6","B6","A8"); # argument vector
|
||||
|
||||
|
||||
@@ -10,8 +10,7 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "x86asm.pl";
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0]);
|
||||
|
||||
|
||||
@@ -67,7 +67,8 @@
|
||||
# hereafter less for longer keys, while verify - by 74-13%.
|
||||
# DSA performance improves by 115-30%.
|
||||
|
||||
$output=pop;
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
|
||||
if ($^O eq "hpux") {
|
||||
$ADDP="addp4";
|
||||
|
||||
@@ -52,8 +52,12 @@
|
||||
# ($t0,$t1,$t2,$t3,$t8,$t9)=map("\$$_",(12..15,24,25));
|
||||
# ($s0,$s1,$s2,$s3,$s4,$s5,$s6,$s7)=map("\$$_",(16..23));
|
||||
# ($gp,$sp,$fp,$ra)=map("\$$_",(28..31));
|
||||
#
|
||||
$flavour = shift || "o32"; # supported flavours are o32,n32,64,nubi32,nubi64
|
||||
|
||||
# $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;
|
||||
# supported flavours are o32,n32,64,nubi32,nubi64, default is o32
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : "o32";
|
||||
|
||||
if ($flavour =~ /64|n32/i) {
|
||||
$PTR_ADD="daddu"; # incidentally works even on n32
|
||||
@@ -74,8 +78,7 @@ $SAVED_REGS_MASK = ($flavour =~ /nubi/i) ? 0x00fff000 : 0x00ff0000;
|
||||
#
|
||||
######################################################################
|
||||
|
||||
while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
|
||||
open STDOUT,">$output";
|
||||
$output and open STDOUT,">$output";
|
||||
|
||||
if ($flavour =~ /64|n32/i) {
|
||||
$LD="ld";
|
||||
|
||||
@@ -54,9 +54,10 @@
|
||||
# has to content with 40-85% improvement depending on benchmark and
|
||||
# key length, more for longer keys.
|
||||
|
||||
$flavour = shift || "o32";
|
||||
while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
|
||||
open STDOUT,">$output";
|
||||
# $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 : "o32";
|
||||
|
||||
if ($flavour =~ /64|n32/i) {
|
||||
$LD="ld";
|
||||
@@ -91,6 +92,8 @@ if ($flavour =~ /64|n32/i) {
|
||||
$code="#if !(defined (__mips_isa_rev) && (__mips_isa_rev >= 6))\n.set mips2\n#endif\n";
|
||||
}
|
||||
|
||||
$output and open STDOUT,">$output";
|
||||
|
||||
# Below is N32/64 register layout used in the original module.
|
||||
#
|
||||
($zero,$at,$v0,$v1)=map("\$$_",(0..3));
|
||||
|
||||
@@ -69,10 +69,12 @@
|
||||
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
# $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;
|
||||
|
||||
open STDOUT,">$output";
|
||||
$output and open STDOUT,">$output";
|
||||
|
||||
if ($flavour =~ /64/) {
|
||||
$LEVEL ="2.0W";
|
||||
|
||||
@@ -41,7 +41,10 @@
|
||||
# builds. On low-end 32-bit processors performance improvement turned
|
||||
# to be marginal...
|
||||
|
||||
$flavour = shift;
|
||||
# $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;
|
||||
|
||||
if ($flavour =~ /32/) {
|
||||
$BITS= 32;
|
||||
@@ -94,7 +97,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or
|
||||
die "can't locate ppc-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!";
|
||||
open STDOUT,"| $^X $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
|
||||
$sp="r1";
|
||||
$toc="r2";
|
||||
|
||||
@@ -103,7 +103,10 @@
|
||||
# Performance increase of ~60%
|
||||
# Based on submission from Suresh N. Chari of IBM
|
||||
|
||||
$flavour = shift;
|
||||
# $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;
|
||||
|
||||
if ($flavour =~ /32/) {
|
||||
$BITS= 32;
|
||||
@@ -159,7 +162,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or
|
||||
die "can't locate ppc-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!";
|
||||
open STDOUT,"| $^X $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
|
||||
$data=<<EOF;
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
@@ -80,7 +80,10 @@
|
||||
# ppc-mont.pl, but improvement coefficient is not as impressive
|
||||
# for longer keys...
|
||||
|
||||
$flavour = shift;
|
||||
# $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;
|
||||
|
||||
if ($flavour =~ /32/) {
|
||||
$SIZE_T=4;
|
||||
@@ -108,7 +111,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or
|
||||
die "can't locate ppc-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!";
|
||||
open STDOUT,"| $^X $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
|
||||
$FRAME=64; # padded frame header
|
||||
$TRANSFER=16*8;
|
||||
|
||||
@@ -37,9 +37,10 @@
|
||||
# (***) scalar AD*X code is faster than AVX2 and is preferred code
|
||||
# path for Broadwell;
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $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;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -72,7 +73,8 @@ if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|based on LLVM) ([3-
|
||||
$addx = ($ver>=3.03);
|
||||
}
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT = *OUT;
|
||||
|
||||
if ($avx>1) {{{
|
||||
|
||||
@@ -52,9 +52,10 @@
|
||||
# purposes;
|
||||
# (**) MULX was attempted, but found to give only marginal improvement;
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $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;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -63,7 +64,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
if (`$ENV{CC} -Wa,-v -c -o /dev/null -x assembler /dev/null 2>&1`
|
||||
|
||||
@@ -32,7 +32,10 @@
|
||||
# so that improvement coefficients can vary from one specific
|
||||
# setup to another.
|
||||
|
||||
$flavour = shift;
|
||||
# $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;
|
||||
|
||||
if ($flavour =~ /3[12]/) {
|
||||
$SIZE_T=4;
|
||||
@@ -42,8 +45,7 @@ if ($flavour =~ /3[12]/) {
|
||||
$g="g";
|
||||
}
|
||||
|
||||
while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
|
||||
open STDOUT,">$output";
|
||||
$output and open STDOUT,">$output";
|
||||
|
||||
$stdframe=16*$SIZE_T+4*8;
|
||||
|
||||
|
||||
@@ -51,7 +51,10 @@
|
||||
# On z990 it was measured to perform 2.6-2.2 times better than
|
||||
# compiler-generated code, less for longer keys...
|
||||
|
||||
$flavour = shift;
|
||||
# $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;
|
||||
|
||||
if ($flavour =~ /3[12]/) {
|
||||
$SIZE_T=4;
|
||||
@@ -61,8 +64,7 @@ if ($flavour =~ /3[12]/) {
|
||||
$g="g";
|
||||
}
|
||||
|
||||
while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
|
||||
open STDOUT,">$output";
|
||||
$output and open STDOUT,">$output";
|
||||
|
||||
$stdframe=16*$SIZE_T+4*8;
|
||||
|
||||
|
||||
@@ -83,8 +83,7 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "sparcv9_modes.pl";
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
$code.=<<___;
|
||||
#include "sparc_arch.h"
|
||||
|
||||
@@ -25,8 +25,7 @@
|
||||
# ~100-230% faster than gcc-generated code and ~35-90% faster than
|
||||
# the pure SPARCv9 code path.
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
$locals=16*8;
|
||||
|
||||
|
||||
@@ -49,8 +49,7 @@
|
||||
# module still have hidden potential [see TODO list there], which is
|
||||
# estimated to be larger than 20%...
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
# int bn_mul_mont(
|
||||
$rp="%i0"; # BN_ULONG *rp,
|
||||
|
||||
@@ -62,8 +62,10 @@
|
||||
# key length, more for longer keys] on USI&II cores and 30-80% - on
|
||||
# USIII&IV.
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
|
||||
$output and open STDOUT,">$output";
|
||||
|
||||
$fname="bn_mul_mont_fpu";
|
||||
|
||||
|
||||
@@ -88,8 +88,7 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "x86asm.pl";
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0]);
|
||||
|
||||
|
||||
@@ -25,8 +25,7 @@
|
||||
# for reference purposes, because T4 has dedicated Montgomery
|
||||
# multiplication and squaring *instructions* that deliver even more.
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
$frame = "STACK_FRAME";
|
||||
$bias = "STACK_BIAS";
|
||||
|
||||
@@ -43,8 +43,7 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "x86asm.pl";
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0],$x86only = $ARGV[$#ARGV] eq "386");
|
||||
|
||||
|
||||
@@ -37,8 +37,7 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "x86asm.pl";
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0]);
|
||||
|
||||
|
||||
@@ -27,9 +27,10 @@
|
||||
# these coefficients are not ones for bn_GF2m_mul_2x2 itself, as not
|
||||
# all CPU time is burnt in it...
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $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;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -38,7 +39,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
($lo,$hi)=("%rax","%rdx"); $a=$lo;
|
||||
|
||||
@@ -46,9 +46,10 @@
|
||||
#
|
||||
# Add MULX/ADOX/ADCX code path.
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $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;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -57,7 +58,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
if (`$ENV{CC} -Wa,-v -c -o /dev/null -x assembler /dev/null 2>&1`
|
||||
|
||||
@@ -31,9 +31,10 @@
|
||||
# the np argument is not just modulus value, but one interleaved
|
||||
# with 0. This is to optimize post-condition...
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $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;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -42,7 +43,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
if (`$ENV{CC} -Wa,-v -c -o /dev/null -x assembler /dev/null 2>&1`
|
||||
|
||||
@@ -270,7 +270,7 @@ BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
|
||||
|
||||
do {
|
||||
int rv;
|
||||
if (!BN_priv_rand_range(ret->A, ret->mod))
|
||||
if (!BN_priv_rand_range_ex(ret->A, ret->mod, ctx))
|
||||
goto err;
|
||||
if (int_bn_mod_inverse(ret->Ai, ret->A, ret->mod, ctx, &rv))
|
||||
break;
|
||||
|
||||
@@ -143,10 +143,12 @@ BN_CTX *BN_CTX_new_ex(OPENSSL_CTX *ctx)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
BN_CTX *BN_CTX_new(void)
|
||||
{
|
||||
return BN_CTX_new_ex(NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
BN_CTX *BN_CTX_secure_new_ex(OPENSSL_CTX *ctx)
|
||||
{
|
||||
@@ -157,10 +159,12 @@ BN_CTX *BN_CTX_secure_new_ex(OPENSSL_CTX *ctx)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
BN_CTX *BN_CTX_secure_new(void)
|
||||
{
|
||||
return BN_CTX_secure_new_ex(NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
void BN_CTX_free(BN_CTX *ctx)
|
||||
{
|
||||
|
||||
+1
-67
@@ -13,70 +13,6 @@
|
||||
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
static const ERR_STRING_DATA BN_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BNRAND, 0), "bnrand"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BNRAND_RANGE, 0), "bnrand_range"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_BLINDING_CONVERT_EX, 0),
|
||||
"BN_BLINDING_convert_ex"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_BLINDING_CREATE_PARAM, 0),
|
||||
"BN_BLINDING_create_param"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_BLINDING_INVERT_EX, 0),
|
||||
"BN_BLINDING_invert_ex"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_BLINDING_NEW, 0), "BN_BLINDING_new"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_BLINDING_UPDATE, 0), "BN_BLINDING_update"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_BN2DEC, 0), "BN_bn2dec"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_BN2HEX, 0), "BN_bn2hex"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_COMPUTE_WNAF, 0), "bn_compute_wNAF"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_CTX_GET, 0), "BN_CTX_get"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_CTX_NEW, 0), "BN_CTX_new"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_CTX_NEW_EX, 0), "BN_CTX_new_ex"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_CTX_START, 0), "BN_CTX_start"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_DIV, 0), "BN_div"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_DIV_RECP, 0), "BN_div_recp"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_EXP, 0), "BN_exp"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_EXPAND_INTERNAL, 0), "bn_expand_internal"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_GENCB_NEW, 0), "BN_GENCB_new"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_GENERATE_DSA_NONCE, 0),
|
||||
"BN_generate_dsa_nonce"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_GENERATE_PRIME_EX, 0),
|
||||
"BN_generate_prime_ex"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_GF2M_MOD, 0), "BN_GF2m_mod"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_GF2M_MOD_EXP, 0), "BN_GF2m_mod_exp"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_GF2M_MOD_MUL, 0), "BN_GF2m_mod_mul"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_GF2M_MOD_SOLVE_QUAD, 0),
|
||||
"BN_GF2m_mod_solve_quad"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR, 0),
|
||||
"BN_GF2m_mod_solve_quad_arr"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_GF2M_MOD_SQR, 0), "BN_GF2m_mod_sqr"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_GF2M_MOD_SQRT, 0), "BN_GF2m_mod_sqrt"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_LSHIFT, 0), "BN_lshift"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_MOD_EXP2_MONT, 0), "BN_mod_exp2_mont"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_MOD_EXP_MONT, 0), "BN_mod_exp_mont"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_MOD_EXP_MONT_CONSTTIME, 0),
|
||||
"BN_mod_exp_mont_consttime"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_MOD_EXP_MONT_WORD, 0),
|
||||
"BN_mod_exp_mont_word"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_MOD_EXP_RECP, 0), "BN_mod_exp_recp"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_MOD_EXP_SIMPLE, 0), "BN_mod_exp_simple"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_MOD_INVERSE, 0), "BN_mod_inverse"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_MOD_INVERSE_NO_BRANCH, 0),
|
||||
"BN_mod_inverse_no_branch"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_MOD_LSHIFT_QUICK, 0), "BN_mod_lshift_quick"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_MOD_SQRT, 0), "BN_mod_sqrt"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_MONT_CTX_NEW, 0), "BN_MONT_CTX_new"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_MPI2BN, 0), "BN_mpi2bn"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_NEW, 0), "BN_new"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_POOL_GET, 0), "BN_POOL_get"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_RAND, 0), "BN_rand"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_RAND_RANGE, 0), "BN_rand_range"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_RECP_CTX_NEW, 0), "BN_RECP_CTX_new"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_RSHIFT, 0), "BN_rshift"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_SET_WORDS, 0), "bn_set_words"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_STACK_PUSH, 0), "BN_STACK_push"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_USUB, 0), "BN_usub"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static const ERR_STRING_DATA BN_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_BN, 0, BN_R_ARG2_LT_ARG3), "arg2 lt arg3"},
|
||||
{ERR_PACK(ERR_LIB_BN, 0, BN_R_BAD_RECIPROCAL), "bad reciprocal"},
|
||||
@@ -111,10 +47,8 @@ static const ERR_STRING_DATA BN_str_reasons[] = {
|
||||
int ERR_load_BN_strings(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
if (ERR_func_error_string(BN_str_functs[0].error) == NULL) {
|
||||
ERR_load_strings_const(BN_str_functs);
|
||||
if (ERR_reason_error_string(BN_str_reasons[0].error) == NULL)
|
||||
ERR_load_strings_const(BN_str_reasons);
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
+4
-3
@@ -732,8 +732,8 @@ int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
|
||||
|
||||
/* generate blinding value */
|
||||
do {
|
||||
if (!BN_priv_rand(b, BN_num_bits(p) - 1,
|
||||
BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY))
|
||||
if (!BN_priv_rand_ex(b, BN_num_bits(p) - 1,
|
||||
BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY, ctx))
|
||||
goto err;
|
||||
} while (BN_is_zero(b));
|
||||
|
||||
@@ -1031,7 +1031,8 @@ int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a_, const int p[],
|
||||
if (tmp == NULL)
|
||||
goto err;
|
||||
do {
|
||||
if (!BN_priv_rand(rho, p[0], BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY))
|
||||
if (!BN_priv_rand_ex(rho, p[0], BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY,
|
||||
ctx))
|
||||
goto err;
|
||||
if (!BN_GF2m_mod_arr(rho, rho, p))
|
||||
goto err;
|
||||
|
||||
+1
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2019 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
|
||||
@@ -654,9 +654,6 @@ BIGNUM *int_bn_mod_inverse(BIGNUM *in,
|
||||
const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx,
|
||||
int *noinv);
|
||||
|
||||
int bn_probable_prime_dh(BIGNUM *rnd, int bits,
|
||||
const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx);
|
||||
|
||||
static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)
|
||||
{
|
||||
if (bits > (INT_MAX - BN_BITS2 + 1))
|
||||
@@ -668,6 +665,4 @@ static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)
|
||||
return bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2);
|
||||
}
|
||||
|
||||
OPENSSL_CTX *bn_get_lib_ctx(BN_CTX *ctx);
|
||||
|
||||
#endif
|
||||
+70
-31
@@ -132,20 +132,66 @@ int BN_num_bits_word(BN_ULONG l)
|
||||
return bits;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function still leaks `a->dmax`: it's caller's responsibility to
|
||||
* expand the input `a` in advance to a public length.
|
||||
*/
|
||||
static ossl_inline
|
||||
int bn_num_bits_consttime(const BIGNUM *a)
|
||||
{
|
||||
int j, ret;
|
||||
unsigned int mask, past_i;
|
||||
int i = a->top - 1;
|
||||
bn_check_top(a);
|
||||
|
||||
for (j = 0, past_i = 0, ret = 0; j < a->dmax; j++) {
|
||||
mask = constant_time_eq_int(i, j); /* 0xff..ff if i==j, 0x0 otherwise */
|
||||
|
||||
ret += BN_BITS2 & (~mask & ~past_i);
|
||||
ret += BN_num_bits_word(a->d[j]) & mask;
|
||||
|
||||
past_i |= mask; /* past_i will become 0xff..ff after i==j */
|
||||
}
|
||||
|
||||
/*
|
||||
* if BN_is_zero(a) => i is -1 and ret contains garbage, so we mask the
|
||||
* final result.
|
||||
*/
|
||||
mask = ~(constant_time_eq_int(i, ((int)-1)));
|
||||
|
||||
return ret & mask;
|
||||
}
|
||||
|
||||
int BN_num_bits(const BIGNUM *a)
|
||||
{
|
||||
int i = a->top - 1;
|
||||
bn_check_top(a);
|
||||
|
||||
if (a->flags & BN_FLG_CONSTTIME) {
|
||||
/*
|
||||
* We assume that BIGNUMs flagged as CONSTTIME have also been expanded
|
||||
* so that a->dmax is not leaking secret information.
|
||||
*
|
||||
* In other words, it's the caller's responsibility to ensure `a` has
|
||||
* been preallocated in advance to a public length if we hit this
|
||||
* branch.
|
||||
*
|
||||
*/
|
||||
return bn_num_bits_consttime(a);
|
||||
}
|
||||
|
||||
if (BN_is_zero(a))
|
||||
return 0;
|
||||
|
||||
return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));
|
||||
}
|
||||
|
||||
static void bn_free_d(BIGNUM *a)
|
||||
static void bn_free_d(BIGNUM *a, int clear)
|
||||
{
|
||||
if (BN_get_flags(a, BN_FLG_SECURE))
|
||||
OPENSSL_secure_free(a->d);
|
||||
OPENSSL_secure_clear_free(a->d, a->dmax * sizeof(a->d[0]));
|
||||
else if (clear != 0)
|
||||
OPENSSL_clear_free(a->d, a->dmax * sizeof(a->d[0]));
|
||||
else
|
||||
OPENSSL_free(a->d);
|
||||
}
|
||||
@@ -155,10 +201,8 @@ void BN_clear_free(BIGNUM *a)
|
||||
{
|
||||
if (a == NULL)
|
||||
return;
|
||||
if (a->d != NULL && !BN_get_flags(a, BN_FLG_STATIC_DATA)) {
|
||||
OPENSSL_cleanse(a->d, a->dmax * sizeof(a->d[0]));
|
||||
bn_free_d(a);
|
||||
}
|
||||
if (a->d != NULL && !BN_get_flags(a, BN_FLG_STATIC_DATA))
|
||||
bn_free_d(a, 1);
|
||||
if (BN_get_flags(a, BN_FLG_MALLOCED)) {
|
||||
OPENSSL_cleanse(a, sizeof(*a));
|
||||
OPENSSL_free(a);
|
||||
@@ -170,7 +214,7 @@ void BN_free(BIGNUM *a)
|
||||
if (a == NULL)
|
||||
return;
|
||||
if (!BN_get_flags(a, BN_FLG_STATIC_DATA))
|
||||
bn_free_d(a);
|
||||
bn_free_d(a, 0);
|
||||
if (a->flags & BN_FLG_MALLOCED)
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
@@ -248,10 +292,8 @@ BIGNUM *bn_expand2(BIGNUM *b, int words)
|
||||
BN_ULONG *a = bn_expand_internal(b, words);
|
||||
if (!a)
|
||||
return NULL;
|
||||
if (b->d) {
|
||||
OPENSSL_cleanse(b->d, b->dmax * sizeof(b->d[0]));
|
||||
bn_free_d(b);
|
||||
}
|
||||
if (b->d != NULL)
|
||||
bn_free_d(b, 1);
|
||||
b->d = a;
|
||||
b->dmax = words;
|
||||
}
|
||||
@@ -416,8 +458,11 @@ BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
typedef enum {big, little} endianess_t;
|
||||
|
||||
/* ignore negative */
|
||||
static int bn2binpad(const BIGNUM *a, unsigned char *to, int tolen)
|
||||
static
|
||||
int bn2binpad(const BIGNUM *a, unsigned char *to, int tolen, endianess_t endianess)
|
||||
{
|
||||
int n;
|
||||
size_t i, lasti, j, atop, mask;
|
||||
@@ -449,10 +494,17 @@ static int bn2binpad(const BIGNUM *a, unsigned char *to, int tolen)
|
||||
|
||||
lasti = atop - 1;
|
||||
atop = a->top * BN_BYTES;
|
||||
for (i = 0, j = 0, to += tolen; j < (size_t)tolen; j++) {
|
||||
if (endianess == big)
|
||||
to += tolen; /* start from the end of the buffer */
|
||||
for (i = 0, j = 0; j < (size_t)tolen; j++) {
|
||||
unsigned char val;
|
||||
l = a->d[i / BN_BYTES];
|
||||
mask = 0 - ((j - atop) >> (8 * sizeof(i) - 1));
|
||||
*--to = (unsigned char)(l >> (8 * (i % BN_BYTES)) & mask);
|
||||
val = (unsigned char)(l >> (8 * (i % BN_BYTES)) & mask);
|
||||
if (endianess == big)
|
||||
*--to = val;
|
||||
else
|
||||
*to++ = val;
|
||||
i += (i - lasti) >> (8 * sizeof(i) - 1); /* stay on last limb */
|
||||
}
|
||||
|
||||
@@ -463,12 +515,12 @@ int BN_bn2binpad(const BIGNUM *a, unsigned char *to, int tolen)
|
||||
{
|
||||
if (tolen < 0)
|
||||
return -1;
|
||||
return bn2binpad(a, to, tolen);
|
||||
return bn2binpad(a, to, tolen, big);
|
||||
}
|
||||
|
||||
int BN_bn2bin(const BIGNUM *a, unsigned char *to)
|
||||
{
|
||||
return bn2binpad(a, to, -1);
|
||||
return bn2binpad(a, to, -1, big);
|
||||
}
|
||||
|
||||
BIGNUM *BN_lebin2bn(const unsigned char *s, int len, BIGNUM *ret)
|
||||
@@ -520,22 +572,9 @@ BIGNUM *BN_lebin2bn(const unsigned char *s, int len, BIGNUM *ret)
|
||||
|
||||
int BN_bn2lebinpad(const BIGNUM *a, unsigned char *to, int tolen)
|
||||
{
|
||||
int i;
|
||||
BN_ULONG l;
|
||||
bn_check_top(a);
|
||||
i = BN_num_bytes(a);
|
||||
if (tolen < i)
|
||||
if (tolen < 0)
|
||||
return -1;
|
||||
/* Add trailing zeroes if necessary */
|
||||
if (tolen > i)
|
||||
memset(to + i, 0, tolen - i);
|
||||
to += i;
|
||||
while (i--) {
|
||||
l = a->d[i / BN_BYTES];
|
||||
to--;
|
||||
*to = (unsigned char)(l >> (8 * (i % BN_BYTES))) & 0xff;
|
||||
}
|
||||
return tolen;
|
||||
return bn2binpad(a, to, tolen, little);
|
||||
}
|
||||
|
||||
BIGNUM *BN_native2bn(const unsigned char *s, int len, BIGNUM *ret)
|
||||
|
||||
+103
-161
@@ -19,10 +19,13 @@
|
||||
*/
|
||||
#include "bn_prime.h"
|
||||
|
||||
static int probable_prime(BIGNUM *rnd, int bits, prime_t *mods);
|
||||
static int probable_prime_dh_safe(BIGNUM *rnd, int bits,
|
||||
const BIGNUM *add, const BIGNUM *rem,
|
||||
BN_CTX *ctx);
|
||||
static int probable_prime(BIGNUM *rnd, int bits, int safe, prime_t *mods,
|
||||
BN_CTX *ctx);
|
||||
static int probable_prime_dh(BIGNUM *rnd, int bits, int safe, prime_t *mods,
|
||||
const BIGNUM *add, const BIGNUM *rem,
|
||||
BN_CTX *ctx);
|
||||
|
||||
#define square(x) ((BN_ULONG)(x) * (BN_ULONG)(x))
|
||||
|
||||
#if BN_BITS2 == 64
|
||||
# define BN_DEF(lo, hi) (BN_ULONG)hi<<32|lo
|
||||
@@ -84,19 +87,19 @@ int BN_GENCB_call(BN_GENCB *cb, int a, int b)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
|
||||
const BIGNUM *add, const BIGNUM *rem, BN_GENCB *cb)
|
||||
int BN_generate_prime_ex2(BIGNUM *ret, int bits, int safe,
|
||||
const BIGNUM *add, const BIGNUM *rem, BN_GENCB *cb,
|
||||
BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM *t;
|
||||
int found = 0;
|
||||
int i, j, c1 = 0;
|
||||
BN_CTX *ctx = NULL;
|
||||
prime_t *mods = NULL;
|
||||
int checks = BN_prime_checks_for_size(bits);
|
||||
|
||||
if (bits < 2) {
|
||||
/* There are no prime numbers this small. */
|
||||
BNerr(BN_F_BN_GENERATE_PRIME_EX, BN_R_BITS_TOO_SMALL);
|
||||
BNerr(BN_F_BN_GENERATE_PRIME_EX2, BN_R_BITS_TOO_SMALL);
|
||||
return 0;
|
||||
} else if (add == NULL && safe && bits < 6 && bits != 3) {
|
||||
/*
|
||||
@@ -104,7 +107,7 @@ int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
|
||||
* But the following two safe primes with less than 6 bits (11, 23)
|
||||
* are unreachable for BN_rand with BN_RAND_TOP_TWO.
|
||||
*/
|
||||
BNerr(BN_F_BN_GENERATE_PRIME_EX, BN_R_BITS_TOO_SMALL);
|
||||
BNerr(BN_F_BN_GENERATE_PRIME_EX2, BN_R_BITS_TOO_SMALL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -112,9 +115,6 @@ int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
|
||||
if (mods == NULL)
|
||||
goto err;
|
||||
|
||||
ctx = BN_CTX_new();
|
||||
if (ctx == NULL)
|
||||
goto err;
|
||||
BN_CTX_start(ctx);
|
||||
t = BN_CTX_get(ctx);
|
||||
if (t == NULL)
|
||||
@@ -122,16 +122,11 @@ int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
|
||||
loop:
|
||||
/* make a random number and set the top and bottom bits */
|
||||
if (add == NULL) {
|
||||
if (!probable_prime(ret, bits, mods))
|
||||
if (!probable_prime(ret, bits, safe, mods, ctx))
|
||||
goto err;
|
||||
} else {
|
||||
if (safe) {
|
||||
if (!probable_prime_dh_safe(ret, bits, add, rem, ctx))
|
||||
goto err;
|
||||
} else {
|
||||
if (!bn_probable_prime_dh(ret, bits, add, rem, ctx))
|
||||
goto err;
|
||||
}
|
||||
if (!probable_prime_dh(ret, bits, safe, mods, add, rem, ctx))
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!BN_GENCB_call(cb, 0, c1++))
|
||||
@@ -175,11 +170,27 @@ int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
|
||||
err:
|
||||
OPENSSL_free(mods);
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(ctx);
|
||||
bn_check_top(ret);
|
||||
return found;
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
|
||||
const BIGNUM *add, const BIGNUM *rem, BN_GENCB *cb)
|
||||
{
|
||||
BN_CTX *ctx = BN_CTX_new();
|
||||
int retval;
|
||||
|
||||
if (ctx == NULL)
|
||||
return 0;
|
||||
|
||||
retval = BN_generate_prime_ex2(ret, bits, safe, add, rem, cb, ctx);
|
||||
|
||||
BN_CTX_free(ctx);
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
int BN_is_prime_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed,
|
||||
BN_GENCB *cb)
|
||||
{
|
||||
@@ -187,11 +198,17 @@ int BN_is_prime_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed,
|
||||
}
|
||||
|
||||
/* See FIPS 186-4 C.3.1 Miller Rabin Probabilistic Primality Test. */
|
||||
int BN_is_prime_fasttest_ex(const BIGNUM *w, int checks, BN_CTX *ctx_passed,
|
||||
int BN_is_prime_fasttest_ex(const BIGNUM *w, int checks, BN_CTX *ctx,
|
||||
int do_trial_division, BN_GENCB *cb)
|
||||
{
|
||||
int i, status, ret = -1;
|
||||
BN_CTX *ctx = NULL;
|
||||
#ifndef FIPS_MODE
|
||||
BN_CTX *ctxlocal = NULL;
|
||||
#else
|
||||
|
||||
if (ctx == NULL)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
/* w must be bigger than 1 */
|
||||
if (BN_cmp(w, BN_value_one()) <= 0)
|
||||
@@ -219,18 +236,19 @@ int BN_is_prime_fasttest_ex(const BIGNUM *w, int checks, BN_CTX *ctx_passed,
|
||||
if (!BN_GENCB_call(cb, 1, -1))
|
||||
return -1;
|
||||
}
|
||||
if (ctx_passed != NULL)
|
||||
ctx = ctx_passed;
|
||||
else if ((ctx = BN_CTX_new()) == NULL)
|
||||
#ifndef FIPS_MODE
|
||||
if (ctx == NULL && (ctxlocal = ctx = BN_CTX_new()) == NULL)
|
||||
goto err;
|
||||
#endif
|
||||
|
||||
ret = bn_miller_rabin_is_prime(w, checks, ctx, cb, 0, &status);
|
||||
if (!ret)
|
||||
goto err;
|
||||
ret = (status == BN_PRIMETEST_PROBABLY_PRIME);
|
||||
err:
|
||||
if (ctx_passed == NULL)
|
||||
BN_CTX_free(ctx);
|
||||
#ifndef FIPS_MODE
|
||||
BN_CTX_free(ctxlocal);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -301,7 +319,8 @@ int bn_miller_rabin_is_prime(const BIGNUM *w, int iterations, BN_CTX *ctx,
|
||||
/* (Step 4) */
|
||||
for (i = 0; i < iterations; ++i) {
|
||||
/* (Step 4.1) obtain a Random string of bits b where 1 < b < w-1 */
|
||||
if (!BN_priv_rand_range(b, w3) || !BN_add_word(b, 2)) /* 1 < b < w-1 */
|
||||
if (!BN_priv_rand_range_ex(b, w3, ctx)
|
||||
|| !BN_add_word(b, 2)) /* 1 < b < w-1 */
|
||||
goto err;
|
||||
|
||||
if (enhanced) {
|
||||
@@ -379,16 +398,18 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int probable_prime(BIGNUM *rnd, int bits, prime_t *mods)
|
||||
static int probable_prime(BIGNUM *rnd, int bits, int safe, prime_t *mods,
|
||||
BN_CTX *ctx)
|
||||
{
|
||||
int i;
|
||||
BN_ULONG delta;
|
||||
BN_ULONG maxdelta = BN_MASK2 - primes[NUMPRIMES - 1];
|
||||
char is_single_word = bits <= BN_BITS2;
|
||||
|
||||
again:
|
||||
/* TODO: Not all primes are private */
|
||||
if (!BN_priv_rand(rnd, bits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ODD))
|
||||
if (!BN_priv_rand_ex(rnd, bits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ODD, ctx))
|
||||
return 0;
|
||||
if (safe && !BN_set_bit(rnd, 1))
|
||||
return 0;
|
||||
/* we now have a random number 'rnd' to test. */
|
||||
for (i = 1; i < NUMPRIMES; i++) {
|
||||
@@ -397,61 +418,25 @@ static int probable_prime(BIGNUM *rnd, int bits, prime_t *mods)
|
||||
return 0;
|
||||
mods[i] = (prime_t) mod;
|
||||
}
|
||||
/*
|
||||
* If bits is so small that it fits into a single word then we
|
||||
* additionally don't want to exceed that many bits.
|
||||
*/
|
||||
if (is_single_word) {
|
||||
BN_ULONG size_limit;
|
||||
|
||||
if (bits == BN_BITS2) {
|
||||
/*
|
||||
* Shifting by this much has undefined behaviour so we do it a
|
||||
* different way
|
||||
*/
|
||||
size_limit = ~((BN_ULONG)0) - BN_get_word(rnd);
|
||||
} else {
|
||||
size_limit = (((BN_ULONG)1) << bits) - BN_get_word(rnd) - 1;
|
||||
}
|
||||
if (size_limit < maxdelta)
|
||||
maxdelta = size_limit;
|
||||
}
|
||||
delta = 0;
|
||||
loop:
|
||||
if (is_single_word) {
|
||||
BN_ULONG rnd_word = BN_get_word(rnd);
|
||||
|
||||
/*-
|
||||
* In the case that the candidate prime is a single word then
|
||||
* we check that:
|
||||
* 1) It's greater than primes[i] because we shouldn't reject
|
||||
* 3 as being a prime number because it's a multiple of
|
||||
* three.
|
||||
* 2) That it's not a multiple of a known prime. We don't
|
||||
* check that rnd-1 is also coprime to all the known
|
||||
* primes because there aren't many small primes where
|
||||
* that's true.
|
||||
for (i = 1; i < NUMPRIMES; i++) {
|
||||
/*
|
||||
* check that rnd is a prime and also that
|
||||
* gcd(rnd-1,primes) == 1 (except for 2)
|
||||
* do the second check only if we are interested in safe primes
|
||||
* in the case that the candidate prime is a single word then
|
||||
* we check only the primes up to sqrt(rnd)
|
||||
*/
|
||||
for (i = 1; i < NUMPRIMES && primes[i] < rnd_word; i++) {
|
||||
if ((mods[i] + delta) % primes[i] == 0) {
|
||||
delta += 2;
|
||||
if (delta > maxdelta)
|
||||
goto again;
|
||||
goto loop;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 1; i < NUMPRIMES; i++) {
|
||||
/*
|
||||
* check that rnd is not a prime and also that gcd(rnd-1,primes)
|
||||
* == 1 (except for 2)
|
||||
*/
|
||||
if (((mods[i] + delta) % primes[i]) <= 1) {
|
||||
delta += 2;
|
||||
if (delta > maxdelta)
|
||||
goto again;
|
||||
goto loop;
|
||||
}
|
||||
if (bits <= 31 && delta <= 0x7fffffff
|
||||
&& square(primes[i]) > BN_get_word(rnd) + delta)
|
||||
break;
|
||||
if (safe ? (mods[i] + delta) % primes[i] <= 1
|
||||
: (mods[i] + delta) % primes[i] == 0) {
|
||||
delta += safe ? 4 : 2;
|
||||
if (delta > maxdelta)
|
||||
goto again;
|
||||
goto loop;
|
||||
}
|
||||
}
|
||||
if (!BN_add_word(rnd, delta))
|
||||
@@ -462,17 +447,24 @@ static int probable_prime(BIGNUM *rnd, int bits, prime_t *mods)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int bn_probable_prime_dh(BIGNUM *rnd, int bits,
|
||||
const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx)
|
||||
static int probable_prime_dh(BIGNUM *rnd, int bits, int safe, prime_t *mods,
|
||||
const BIGNUM *add, const BIGNUM *rem,
|
||||
BN_CTX *ctx)
|
||||
{
|
||||
int i, ret = 0;
|
||||
BIGNUM *t1;
|
||||
BN_ULONG delta;
|
||||
BN_ULONG maxdelta = BN_MASK2 - primes[NUMPRIMES - 1];
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
if ((t1 = BN_CTX_get(ctx)) == NULL)
|
||||
goto err;
|
||||
|
||||
if (!BN_rand(rnd, bits, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD))
|
||||
if (maxdelta > BN_MASK2 - BN_get_word(add))
|
||||
maxdelta = BN_MASK2 - BN_get_word(add);
|
||||
|
||||
again:
|
||||
if (!BN_rand_ex(rnd, bits, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD, ctx))
|
||||
goto err;
|
||||
|
||||
/* we need ((rnd-rem) % add) == 0 */
|
||||
@@ -482,27 +474,44 @@ int bn_probable_prime_dh(BIGNUM *rnd, int bits,
|
||||
if (!BN_sub(rnd, rnd, t1))
|
||||
goto err;
|
||||
if (rem == NULL) {
|
||||
if (!BN_add_word(rnd, 1))
|
||||
if (!BN_add_word(rnd, safe ? 3u : 1u))
|
||||
goto err;
|
||||
} else {
|
||||
if (!BN_add(rnd, rnd, rem))
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* we now have a random number 'rand' to test. */
|
||||
if (BN_num_bits(rnd) < bits
|
||||
|| BN_get_word(rnd) < (safe ? 5u : 3u)) {
|
||||
if (!BN_add(rnd, rnd, add))
|
||||
goto err;
|
||||
}
|
||||
|
||||
loop:
|
||||
/* we now have a random number 'rnd' to test. */
|
||||
for (i = 1; i < NUMPRIMES; i++) {
|
||||
/* check that rnd is a prime */
|
||||
BN_ULONG mod = BN_mod_word(rnd, (BN_ULONG)primes[i]);
|
||||
if (mod == (BN_ULONG)-1)
|
||||
goto err;
|
||||
if (mod <= 1) {
|
||||
if (!BN_add(rnd, rnd, add))
|
||||
goto err;
|
||||
mods[i] = (prime_t) mod;
|
||||
}
|
||||
delta = 0;
|
||||
loop:
|
||||
for (i = 1; i < NUMPRIMES; i++) {
|
||||
/* check that rnd is a prime */
|
||||
if (bits <= 31 && delta <= 0x7fffffff
|
||||
&& square(primes[i]) > BN_get_word(rnd) + delta)
|
||||
break;
|
||||
/* rnd mod p == 1 implies q = (rnd-1)/2 is divisible by p */
|
||||
if (safe ? (mods[i] + delta) % primes[i] <= 1
|
||||
: (mods[i] + delta) % primes[i] == 0) {
|
||||
delta += BN_get_word(add);
|
||||
if (delta > maxdelta)
|
||||
goto again;
|
||||
goto loop;
|
||||
}
|
||||
}
|
||||
if (!BN_add_word(rnd, delta))
|
||||
goto err;
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
@@ -510,70 +519,3 @@ int bn_probable_prime_dh(BIGNUM *rnd, int bits,
|
||||
bn_check_top(rnd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int probable_prime_dh_safe(BIGNUM *p, int bits, const BIGNUM *padd,
|
||||
const BIGNUM *rem, BN_CTX *ctx)
|
||||
{
|
||||
int i, ret = 0;
|
||||
BIGNUM *t1, *qadd, *q;
|
||||
|
||||
bits--;
|
||||
BN_CTX_start(ctx);
|
||||
t1 = BN_CTX_get(ctx);
|
||||
q = BN_CTX_get(ctx);
|
||||
qadd = BN_CTX_get(ctx);
|
||||
if (qadd == NULL)
|
||||
goto err;
|
||||
|
||||
if (!BN_rshift1(qadd, padd))
|
||||
goto err;
|
||||
|
||||
if (!BN_rand(q, bits, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD))
|
||||
goto err;
|
||||
|
||||
/* we need ((rnd-rem) % add) == 0 */
|
||||
if (!BN_mod(t1, q, qadd, ctx))
|
||||
goto err;
|
||||
if (!BN_sub(q, q, t1))
|
||||
goto err;
|
||||
if (rem == NULL) {
|
||||
if (!BN_add_word(q, 1))
|
||||
goto err;
|
||||
} else {
|
||||
if (!BN_rshift1(t1, rem))
|
||||
goto err;
|
||||
if (!BN_add(q, q, t1))
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* we now have a random number 'rand' to test. */
|
||||
if (!BN_lshift1(p, q))
|
||||
goto err;
|
||||
if (!BN_add_word(p, 1))
|
||||
goto err;
|
||||
|
||||
loop:
|
||||
for (i = 1; i < NUMPRIMES; i++) {
|
||||
/* check that p and q are prime */
|
||||
/*
|
||||
* check that for p and q gcd(p-1,primes) == 1 (except for 2)
|
||||
*/
|
||||
BN_ULONG pmod = BN_mod_word(p, (BN_ULONG)primes[i]);
|
||||
BN_ULONG qmod = BN_mod_word(q, (BN_ULONG)primes[i]);
|
||||
if (pmod == (BN_ULONG)-1 || qmod == (BN_ULONG)-1)
|
||||
goto err;
|
||||
if (pmod == 0 || qmod == 0) {
|
||||
if (!BN_add(p, p, padd))
|
||||
goto err;
|
||||
if (!BN_add(q, q, qadd))
|
||||
goto err;
|
||||
goto loop;
|
||||
}
|
||||
}
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
bn_check_top(p);
|
||||
return ret;
|
||||
}
|
||||
+10
-5
@@ -103,6 +103,7 @@ int BN_rand_ex(BIGNUM *rnd, int bits, int top, int bottom, BN_CTX *ctx)
|
||||
{
|
||||
return bnrand(NORMAL, rnd, bits, top, bottom, ctx);
|
||||
}
|
||||
#ifndef FIPS_MODE
|
||||
int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)
|
||||
{
|
||||
return bnrand(NORMAL, rnd, bits, top, bottom, NULL);
|
||||
@@ -112,16 +113,19 @@ int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
|
||||
{
|
||||
return bnrand(TESTING, rnd, bits, top, bottom, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
int BN_priv_rand_ex(BIGNUM *rnd, int bits, int top, int bottom, BN_CTX *ctx)
|
||||
{
|
||||
return bnrand(PRIVATE, rnd, bits, top, bottom, ctx);
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
int BN_priv_rand(BIGNUM *rnd, int bits, int top, int bottom)
|
||||
{
|
||||
return bnrand(PRIVATE, rnd, bits, top, bottom, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* random number r: 0 <= r < range */
|
||||
static int bnrand_range(BNRAND_FLAG flag, BIGNUM *r, const BIGNUM *range,
|
||||
@@ -195,16 +199,19 @@ int BN_rand_range_ex(BIGNUM *r, const BIGNUM *range, BN_CTX *ctx)
|
||||
return bnrand_range(NORMAL, r, range, ctx);
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
int BN_rand_range(BIGNUM *r, const BIGNUM *range)
|
||||
{
|
||||
return bnrand_range(NORMAL, r, range, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
int BN_priv_rand_range_ex(BIGNUM *r, const BIGNUM *range, BN_CTX *ctx)
|
||||
{
|
||||
return bnrand_range(PRIVATE, r, range, ctx);
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
int BN_priv_rand_range(BIGNUM *r, const BIGNUM *range)
|
||||
{
|
||||
return bnrand_range(PRIVATE, r, range, NULL);
|
||||
@@ -219,6 +226,7 @@ int BN_pseudo_rand_range(BIGNUM *r, const BIGNUM *range)
|
||||
{
|
||||
return BN_rand_range(r, range);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* BN_generate_dsa_nonce generates a random number 0 <= out < range. Unlike
|
||||
@@ -256,8 +264,7 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
|
||||
goto err;
|
||||
|
||||
/* We copy |priv| into a local buffer to avoid exposing its length. */
|
||||
todo = sizeof(priv->d[0]) * priv->top;
|
||||
if (todo > sizeof(private_bytes)) {
|
||||
if (BN_bn2binpad(priv, private_bytes, sizeof(private_bytes)) < 0) {
|
||||
/*
|
||||
* No reasonable DSA or ECDSA key should have a private key this
|
||||
* large and we don't handle this case in order to avoid leaking the
|
||||
@@ -266,8 +273,6 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
|
||||
BNerr(BN_F_BN_GENERATE_DSA_NONCE, BN_R_PRIVATE_KEY_TOO_LARGE);
|
||||
goto err;
|
||||
}
|
||||
memcpy(private_bytes, priv->d, todo);
|
||||
memset(private_bytes + todo, 0, sizeof(private_bytes) - todo);
|
||||
|
||||
md = EVP_MD_fetch(libctx, "SHA512", NULL);
|
||||
if (md == NULL) {
|
||||
@@ -302,7 +307,7 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
|
||||
|
||||
err:
|
||||
EVP_MD_CTX_free(mdctx);
|
||||
EVP_MD_meth_free(md);
|
||||
EVP_MD_free(md);
|
||||
OPENSSL_free(k_bytes);
|
||||
OPENSSL_cleanse(private_bytes, sizeof(private_bytes));
|
||||
return ret;
|
||||
|
||||
@@ -193,13 +193,15 @@ int bn_rsa_fips186_4_gen_prob_primes(BIGNUM *p, BIGNUM *Xpout,
|
||||
/* (Steps 4.1/5.1): Randomly generate Xp1 if it is not passed in */
|
||||
if (Xp1 == NULL) {
|
||||
/* Set the top and bottom bits to make it odd and the correct size */
|
||||
if (!BN_priv_rand(Xp1i, bitlen, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD))
|
||||
if (!BN_priv_rand_ex(Xp1i, bitlen, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD,
|
||||
ctx))
|
||||
goto err;
|
||||
}
|
||||
/* (Steps 4.1/5.1): Randomly generate Xp2 if it is not passed in */
|
||||
if (Xp2 == NULL) {
|
||||
/* Set the top and bottom bits to make it odd and the correct size */
|
||||
if (!BN_priv_rand(Xp2i, bitlen, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD))
|
||||
if (!BN_priv_rand_ex(Xp2i, bitlen, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD,
|
||||
ctx))
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -305,7 +307,8 @@ int bn_rsa_fips186_4_derive_prime(BIGNUM *Y, BIGNUM *X, const BIGNUM *Xin,
|
||||
* so largest number will have B5... as the top byte
|
||||
* Setting the top 2 bits gives 0xC0.
|
||||
*/
|
||||
if (!BN_priv_rand(X, bits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ANY))
|
||||
if (!BN_priv_rand_ex(X, bits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ANY,
|
||||
ctx))
|
||||
goto end;
|
||||
}
|
||||
/* (Step 4) Y = X + ((R - X) mod 2r1r2) */
|
||||
|
||||
+1
-1
@@ -180,7 +180,7 @@ BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
|
||||
if (!BN_set_word(y, i))
|
||||
goto end;
|
||||
} else {
|
||||
if (!BN_priv_rand(y, BN_num_bits(p), 0, 0))
|
||||
if (!BN_priv_rand_ex(y, BN_num_bits(p), 0, 0, ctx))
|
||||
goto end;
|
||||
if (BN_ucmp(y, p) >= 0) {
|
||||
if (!(p->neg ? BN_add : BN_sub) (y, y, p))
|
||||
|
||||
@@ -173,7 +173,7 @@ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx)
|
||||
* - 1. By setting the top two bits we ensure that the lower bound is
|
||||
* exceeded.
|
||||
*/
|
||||
if (!BN_priv_rand(Xp, nbits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ANY))
|
||||
if (!BN_priv_rand_ex(Xp, nbits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ANY, ctx))
|
||||
goto err;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
@@ -182,7 +182,8 @@ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx)
|
||||
goto err;
|
||||
|
||||
for (i = 0; i < 1000; i++) {
|
||||
if (!BN_priv_rand(Xq, nbits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ANY))
|
||||
if (!BN_priv_rand_ex(Xq, nbits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ANY,
|
||||
ctx))
|
||||
goto err;
|
||||
|
||||
/* Check that |Xp - Xq| > 2^(nbits - 100) */
|
||||
@@ -227,9 +228,9 @@ int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
|
||||
if (Xp1 == NULL || Xp2 == NULL)
|
||||
goto error;
|
||||
|
||||
if (!BN_priv_rand(Xp1, 101, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY))
|
||||
if (!BN_priv_rand_ex(Xp1, 101, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY, ctx))
|
||||
goto error;
|
||||
if (!BN_priv_rand(Xp2, 101, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY))
|
||||
if (!BN_priv_rand_ex(Xp2, 101, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY, ctx))
|
||||
goto error;
|
||||
if (!BN_X931_derive_prime_ex(p, p1, p2, Xp, Xp1, Xp2, e, ctx, cb))
|
||||
goto error;
|
||||
|
||||
+28
-32
@@ -96,7 +96,7 @@ IF[{- !$disabled{asm} -}]
|
||||
$BNDEF=$BNDEF $BNDEF_{- $target{asm_arch} -}_ec2m
|
||||
ENDIF
|
||||
IF[{- !$disabled{sse2} -}]
|
||||
$BNDEF_sse2=$BNDEF $BNDEF_{- $target{asm_arch} -}_sse2
|
||||
$BNDEF=$BNDEF $BNDEF_{- $target{asm_arch} -}_sse2
|
||||
ENDIF
|
||||
ENDIF
|
||||
ENDIF
|
||||
@@ -116,58 +116,54 @@ INCLUDE[../../libcrypto]=../../crypto/include
|
||||
|
||||
INCLUDE[bn_exp.o]=..
|
||||
|
||||
GENERATE[bn-586.s]=asm/bn-586.pl \
|
||||
$(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR)
|
||||
GENERATE[bn-586.s]=asm/bn-586.pl
|
||||
DEPEND[bn-586.s]=../perlasm/x86asm.pl
|
||||
GENERATE[co-586.s]=asm/co-586.pl \
|
||||
$(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR)
|
||||
GENERATE[co-586.s]=asm/co-586.pl
|
||||
DEPEND[co-586.s]=../perlasm/x86asm.pl
|
||||
GENERATE[x86-mont.s]=asm/x86-mont.pl \
|
||||
$(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR)
|
||||
GENERATE[x86-mont.s]=asm/x86-mont.pl
|
||||
DEPEND[x86-mont.s]=../perlasm/x86asm.pl
|
||||
GENERATE[x86-gf2m.s]=asm/x86-gf2m.pl \
|
||||
$(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR)
|
||||
GENERATE[x86-gf2m.s]=asm/x86-gf2m.pl
|
||||
DEPEND[x86-gf2m.s]=../perlasm/x86asm.pl
|
||||
|
||||
GENERATE[sparcv9a-mont.S]=asm/sparcv9a-mont.pl $(PERLASM_SCHEME)
|
||||
GENERATE[sparcv9a-mont.S]=asm/sparcv9a-mont.pl
|
||||
INCLUDE[sparcv9a-mont.o]=..
|
||||
GENERATE[sparcv9-mont.S]=asm/sparcv9-mont.pl $(PERLASM_SCHEME)
|
||||
GENERATE[sparcv9-mont.S]=asm/sparcv9-mont.pl
|
||||
INCLUDE[sparcv9-mont.o]=..
|
||||
GENERATE[vis3-mont.S]=asm/vis3-mont.pl $(PERLASM_SCHEME)
|
||||
GENERATE[vis3-mont.S]=asm/vis3-mont.pl
|
||||
INCLUDE[vis3-mont.o]=..
|
||||
GENERATE[sparct4-mont.S]=asm/sparct4-mont.pl $(PERLASM_SCHEME)
|
||||
GENERATE[sparct4-mont.S]=asm/sparct4-mont.pl
|
||||
INCLUDE[sparct4-mont.o]=..
|
||||
GENERATE[sparcv9-gf2m.S]=asm/sparcv9-gf2m.pl $(PERLASM_SCHEME)
|
||||
GENERATE[sparcv9-gf2m.S]=asm/sparcv9-gf2m.pl
|
||||
INCLUDE[sparcv9-gf2m.o]=..
|
||||
|
||||
GENERATE[bn-mips.S]=asm/mips.pl $(PERLASM_SCHEME)
|
||||
GENERATE[bn-mips.S]=asm/mips.pl
|
||||
INCLUDE[bn-mips.o]=..
|
||||
GENERATE[mips-mont.S]=asm/mips-mont.pl $(PERLASM_SCHEME)
|
||||
GENERATE[mips-mont.S]=asm/mips-mont.pl
|
||||
INCLUDE[mips-mont.o]=..
|
||||
|
||||
GENERATE[s390x-mont.S]=asm/s390x-mont.pl $(PERLASM_SCHEME)
|
||||
GENERATE[s390x-gf2m.s]=asm/s390x-gf2m.pl $(PERLASM_SCHEME)
|
||||
GENERATE[s390x-mont.S]=asm/s390x-mont.pl
|
||||
GENERATE[s390x-gf2m.s]=asm/s390x-gf2m.pl
|
||||
|
||||
GENERATE[x86_64-mont.s]=asm/x86_64-mont.pl $(PERLASM_SCHEME)
|
||||
GENERATE[x86_64-mont5.s]=asm/x86_64-mont5.pl $(PERLASM_SCHEME)
|
||||
GENERATE[x86_64-gf2m.s]=asm/x86_64-gf2m.pl $(PERLASM_SCHEME)
|
||||
GENERATE[rsaz-x86_64.s]=asm/rsaz-x86_64.pl $(PERLASM_SCHEME)
|
||||
GENERATE[rsaz-avx2.s]=asm/rsaz-avx2.pl $(PERLASM_SCHEME)
|
||||
GENERATE[x86_64-mont.s]=asm/x86_64-mont.pl
|
||||
GENERATE[x86_64-mont5.s]=asm/x86_64-mont5.pl
|
||||
GENERATE[x86_64-gf2m.s]=asm/x86_64-gf2m.pl
|
||||
GENERATE[rsaz-x86_64.s]=asm/rsaz-x86_64.pl
|
||||
GENERATE[rsaz-avx2.s]=asm/rsaz-avx2.pl
|
||||
|
||||
GENERATE[bn-ia64.s]=asm/ia64.S
|
||||
GENERATE[ia64-mont.s]=asm/ia64-mont.pl $(LIB_CFLAGS) $(LIB_CPPFLAGS)
|
||||
GENERATE[ia64-mont.s]=asm/ia64-mont.pl
|
||||
|
||||
GENERATE[parisc-mont.s]=asm/parisc-mont.pl $(PERLASM_SCHEME)
|
||||
GENERATE[parisc-mont.s]=asm/parisc-mont.pl
|
||||
|
||||
# ppc - AIX, Linux, MacOS X...
|
||||
GENERATE[bn-ppc.s]=asm/ppc.pl $(PERLASM_SCHEME)
|
||||
GENERATE[ppc-mont.s]=asm/ppc-mont.pl $(PERLASM_SCHEME)
|
||||
GENERATE[ppc64-mont.s]=asm/ppc64-mont.pl $(PERLASM_SCHEME)
|
||||
GENERATE[bn-ppc.s]=asm/ppc.pl
|
||||
GENERATE[ppc-mont.s]=asm/ppc-mont.pl
|
||||
GENERATE[ppc64-mont.s]=asm/ppc64-mont.pl
|
||||
|
||||
GENERATE[alpha-mont.S]=asm/alpha-mont.pl $(PERLASM_SCHEME)
|
||||
GENERATE[alpha-mont.S]=asm/alpha-mont.pl
|
||||
|
||||
GENERATE[armv4-mont.S]=asm/armv4-mont.pl $(PERLASM_SCHEME)
|
||||
GENERATE[armv4-mont.S]=asm/armv4-mont.pl
|
||||
INCLUDE[armv4-mont.o]=..
|
||||
GENERATE[armv4-gf2m.S]=asm/armv4-gf2m.pl $(PERLASM_SCHEME)
|
||||
GENERATE[armv4-gf2m.S]=asm/armv4-gf2m.pl
|
||||
INCLUDE[armv4-gf2m.o]=..
|
||||
GENERATE[armv8-mont.S]=asm/armv8-mont.pl $(PERLASM_SCHEME)
|
||||
GENERATE[armv8-mont.S]=asm/armv8-mont.pl
|
||||
+2
-11
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Generated by util/mkerr.pl DO NOT EDIT
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2019 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
|
||||
@@ -13,13 +13,6 @@
|
||||
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
static const ERR_STRING_DATA BUF_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_BUF, BUF_F_BUF_MEM_GROW, 0), "BUF_MEM_grow"},
|
||||
{ERR_PACK(ERR_LIB_BUF, BUF_F_BUF_MEM_GROW_CLEAN, 0), "BUF_MEM_grow_clean"},
|
||||
{ERR_PACK(ERR_LIB_BUF, BUF_F_BUF_MEM_NEW, 0), "BUF_MEM_new"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static const ERR_STRING_DATA BUF_str_reasons[] = {
|
||||
{0, NULL}
|
||||
};
|
||||
@@ -29,10 +22,8 @@ static const ERR_STRING_DATA BUF_str_reasons[] = {
|
||||
int ERR_load_BUF_strings(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
if (ERR_func_error_string(BUF_str_functs[0].error) == NULL) {
|
||||
ERR_load_strings_const(BUF_str_functs);
|
||||
if (ERR_reason_error_string(BUF_str_reasons[0].error) == NULL)
|
||||
ERR_load_strings_const(BUF_str_reasons);
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
LIBS=../../libcrypto
|
||||
SOURCE[../../libcrypto]=buffer.c buf_err.c
|
||||
SOURCE[../../providers/fips]=buffer.c
|
||||
+18
-19
@@ -1,11 +1,11 @@
|
||||
# Note that these directories are filtered in Configure. Look for %skipdir
|
||||
# there for further explanations.
|
||||
SUBDIRS=objects buffer bio stack lhash rand evp asn1 pem x509 conf \
|
||||
txt_db pkcs7 pkcs12 ui kdf store property \
|
||||
md2 md4 md5 sha mdc2 gmac hmac ripemd whrlpool poly1305 blake2 \
|
||||
txt_db pkcs7 pkcs12 ui store property \
|
||||
md2 md4 md5 sha mdc2 hmac ripemd whrlpool poly1305 blake2 \
|
||||
siphash sm3 des aes rc2 rc4 rc5 idea aria bf cast camellia \
|
||||
seed sm4 chacha modes bn ec rsa dsa dh sm2 dso engine \
|
||||
err comp ocsp cms ts srp cmac ct async kmac ess crmf cmp
|
||||
err comp ocsp cms ts srp cmac ct async ess crmf cmp
|
||||
|
||||
LIBS=../libcrypto
|
||||
|
||||
@@ -59,52 +59,51 @@ IF[{- !$disabled{asm} && $config{processor} ne '386' -}]
|
||||
ENDIF
|
||||
|
||||
# The Core
|
||||
$CORE_COMMON=provider_core.c provider_predefined.c core_fetch.c core_namemap.c
|
||||
$CORE_COMMON=provider_core.c provider_predefined.c \
|
||||
core_fetch.c core_algorithm.c core_namemap.c
|
||||
|
||||
SOURCE[../libcrypto]=$CORE_COMMON provider_conf.c
|
||||
SOURCE[../providers/fips]=$CORE_COMMON
|
||||
|
||||
# Central utilities
|
||||
$UTIL_COMMON=\
|
||||
cryptlib.c params.c bsearch.c ex_data.c o_str.c \
|
||||
cryptlib.c params.c params_from_text.c bsearch.c ex_data.c o_str.c \
|
||||
ctype.c threads_pthread.c threads_win.c threads_none.c initthread.c \
|
||||
context.c sparse_array.c $CPUIDASM
|
||||
context.c sparse_array.c asn1_dsa.c packet.c param_build.c $CPUIDASM
|
||||
$UTIL_DEFINE=$CPUIDDEF
|
||||
|
||||
SOURCE[../libcrypto]=$UTIL_COMMON \
|
||||
mem.c mem_sec.c mem_str.c mem_dbg.c \
|
||||
mem.c mem_sec.c mem_dbg.c \
|
||||
cversion.c info.c cpt_err.c ebcdic.c uid.c o_time.c o_dir.c \
|
||||
o_fopen.c getenv.c o_init.c o_fips.c init.c trace.c provider.c \
|
||||
$UPLINKSRC
|
||||
DEFINE[../libcrypto]=$UTIL_DEFINE $UPLINKDEF
|
||||
SOURCE[../providers/fips]=$UTIL_COMMON
|
||||
DEFINE[../providers/fips]=$UTIL_DEFINE
|
||||
|
||||
|
||||
|
||||
DEPEND[cversion.o]=buildinf.h
|
||||
GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(CC) $(LIB_CFLAGS) $(CPPFLAGS_Q)" "$(PLATFORM)"
|
||||
DEPEND[buildinf.h]=../configdata.pm
|
||||
|
||||
GENERATE[uplink-x86.s]=../ms/uplink-x86.pl $(PERLASM_SCHEME)
|
||||
GENERATE[uplink-x86_64.s]=../ms/uplink-x86_64.pl $(PERLASM_SCHEME)
|
||||
GENERATE[uplink-ia64.s]=../ms/uplink-ia64.pl $(PERLASM_SCHEME)
|
||||
GENERATE[uplink-x86.s]=../ms/uplink-x86.pl
|
||||
GENERATE[uplink-x86_64.s]=../ms/uplink-x86_64.pl
|
||||
GENERATE[uplink-ia64.s]=../ms/uplink-ia64.pl
|
||||
|
||||
GENERATE[x86cpuid.s]=x86cpuid.pl \
|
||||
$(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR)
|
||||
GENERATE[x86cpuid.s]=x86cpuid.pl
|
||||
DEPEND[x86cpuid.s]=perlasm/x86asm.pl
|
||||
|
||||
GENERATE[x86_64cpuid.s]=x86_64cpuid.pl $(PERLASM_SCHEME)
|
||||
GENERATE[x86_64cpuid.s]=x86_64cpuid.pl
|
||||
|
||||
GENERATE[ia64cpuid.s]=ia64cpuid.S
|
||||
GENERATE[ppccpuid.s]=ppccpuid.pl $(PERLASM_SCHEME)
|
||||
GENERATE[pariscid.s]=pariscid.pl $(PERLASM_SCHEME)
|
||||
GENERATE[ppccpuid.s]=ppccpuid.pl
|
||||
GENERATE[pariscid.s]=pariscid.pl
|
||||
GENERATE[alphacpuid.s]=alphacpuid.pl
|
||||
GENERATE[arm64cpuid.S]=arm64cpuid.pl $(PERLASM_SCHEME)
|
||||
GENERATE[arm64cpuid.S]=arm64cpuid.pl
|
||||
INCLUDE[arm64cpuid.o]=.
|
||||
GENERATE[armv4cpuid.S]=armv4cpuid.pl $(PERLASM_SCHEME)
|
||||
GENERATE[armv4cpuid.S]=armv4cpuid.pl
|
||||
INCLUDE[armv4cpuid.o]=.
|
||||
GENERATE[s390xcpuid.S]=s390xcpuid.pl $(PERLASM_SCHEME)
|
||||
GENERATE[s390xcpuid.S]=s390xcpuid.pl
|
||||
INCLUDE[s390xcpuid.o]=.
|
||||
|
||||
IF[{- $config{target} =~ /^(?:Cygwin|mingw|VC-)/ -}]
|
||||
|
||||
@@ -49,8 +49,7 @@ require "x86asm.pl";
|
||||
|
||||
$OPENSSL=1;
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0],$ARGV[$#ARGV] eq "386");
|
||||
|
||||
|
||||
@@ -36,9 +36,10 @@
|
||||
# EM64T, pre-Core2 Intel x86_64 CPU, is not as impressive, because it
|
||||
# apparently emulates some of 64-bit operations in [32-bit] microcode.
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $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;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -47,7 +48,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
sub hi() { my $r=shift; $r =~ s/%[er]([a-d])x/%\1h/; $r; }
|
||||
|
||||
@@ -53,8 +53,7 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "sparcv9_modes.pl";
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
$::evp=1; # if $evp is set to 0, script generates module with
|
||||
# Camellia_[en|de]crypt, Camellia_set_key and Camellia_cbc_encrypt
|
||||
|
||||
@@ -15,11 +15,9 @@ ENDIF
|
||||
|
||||
SOURCE[../../libcrypto]=cmll_ecb.c cmll_ofb.c cmll_cfb.c cmll_ctr.c $CMLLASM
|
||||
|
||||
GENERATE[cmll-x86.s]=asm/cmll-x86.pl \
|
||||
$(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) \
|
||||
$(PROCESSOR)
|
||||
GENERATE[cmll-x86.s]=asm/cmll-x86.pl
|
||||
DEPEND[cmll-x86.s]=../perlasm/x86asm.pl
|
||||
GENERATE[cmll-x86_64.s]=asm/cmll-x86_64.pl $(PERLASM_SCHEME)
|
||||
GENERATE[cmllt4-sparcv9.S]=asm/cmllt4-sparcv9.pl $(PERLASM_SCHEME)
|
||||
GENERATE[cmll-x86_64.s]=asm/cmll-x86_64.pl
|
||||
GENERATE[cmllt4-sparcv9.S]=asm/cmllt4-sparcv9.pl
|
||||
INCLUDE[cmllt4-sparcv9.o]=..
|
||||
DEPEND[cmllt4-sparcv9.S]=../perlasm/sparcv9_modes.pl
|
||||
@@ -18,8 +18,7 @@ push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "x86asm.pl";
|
||||
require "cbc.pl";
|
||||
|
||||
$output=pop;
|
||||
open STDOUT,">$output";
|
||||
$output=pop and open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0],$ARGV[$#ARGV] eq "386");
|
||||
|
||||
|
||||
@@ -14,6 +14,5 @@ ENDIF
|
||||
|
||||
SOURCE[../../libcrypto]=c_skey.c c_ecb.c $CASTASM c_cfb64.c c_ofb64.c
|
||||
|
||||
GENERATE[cast-586.s]=asm/cast-586.pl \
|
||||
$(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR)
|
||||
GENERATE[cast-586.s]=asm/cast-586.pl
|
||||
DEPEND[cast-586.s]=../perlasm/x86asm.pl ../perlasm/cbc.pl
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user