Update pre9
This commit is contained in:
@@ -9,12 +9,37 @@
|
|||||||
|
|
||||||
Changes between 1.1.0h and 1.1.1 [xx XXX xxxx]
|
Changes between 1.1.0h and 1.1.1 [xx XXX xxxx]
|
||||||
|
|
||||||
|
*) Use the new ec_scalar_mul_ladder scaffold to implement a specialized ladder
|
||||||
|
step for prime curves. The new implementation is based on formulae from
|
||||||
|
differential addition-and-doubling in homogeneous projective coordinates
|
||||||
|
from Izu-Takagi "A fast parallel elliptic curve multiplication resistant
|
||||||
|
against side channel attacks" and Brier-Joye "Weierstrass Elliptic Curves
|
||||||
|
and Side-Channel Attacks" Eq. (8) for y-coordinate recovery, modified
|
||||||
|
to work in projective coordinates.
|
||||||
|
[Billy Bob Brumley, Nicola Tuveri]
|
||||||
|
|
||||||
|
*) Change generating and checking of primes so that the error rate of not
|
||||||
|
being prime depends on the intended use based on the size of the input.
|
||||||
|
For larger primes this will result in more rounds of Miller-Rabin.
|
||||||
|
The maximal error rate for primes with more than 1080 bits is lowered
|
||||||
|
to 2^-128.
|
||||||
|
[Kurt Roeckx, Annie Yousar]
|
||||||
|
|
||||||
|
*) Increase the number of Miller-Rabin rounds for DSA key generating to 64.
|
||||||
|
[Kurt Roeckx]
|
||||||
|
|
||||||
|
*) The 'tsget' script is renamed to 'tsget.pl', to avoid confusion when
|
||||||
|
moving between systems, and to avoid confusion when a Windows build is
|
||||||
|
done with mingw vs with MSVC. For POSIX installs, there's still a
|
||||||
|
symlink or copy named 'tsget' to avoid that confusion as well.
|
||||||
|
[Richard Levitte]
|
||||||
|
|
||||||
*) Revert blinding in ECDSA sign and instead make problematic addition
|
*) Revert blinding in ECDSA sign and instead make problematic addition
|
||||||
length-invariant. Switch even to fixed-length Montgomery multiplication.
|
length-invariant. Switch even to fixed-length Montgomery multiplication.
|
||||||
[Andy Polyakov]
|
[Andy Polyakov]
|
||||||
|
|
||||||
*) Use the new ec_scalar_mul_ladder scaffold to implement a specialized ladder
|
*) Use the new ec_scalar_mul_ladder scaffold to implement a specialized ladder
|
||||||
step for binary curves. The new implementation is based on formulas from
|
step for binary curves. The new implementation is based on formulae from
|
||||||
differential addition-and-doubling in mixed Lopez-Dahab projective
|
differential addition-and-doubling in mixed Lopez-Dahab projective
|
||||||
coordinates, modified to independently blind the operands.
|
coordinates, modified to independently blind the operands.
|
||||||
[Billy Bob Brumley, Sohaib ul Hassan, Nicola Tuveri]
|
[Billy Bob Brumley, Sohaib ul Hassan, Nicola Tuveri]
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ my %targets=(
|
|||||||
ppc64_asm => {
|
ppc64_asm => {
|
||||||
inherit_from => [ "ppc32_asm" ],
|
inherit_from => [ "ppc32_asm" ],
|
||||||
template => 1,
|
template => 1,
|
||||||
ec_asm_src => "ecp_nistz256.c ecp_nistz256-ppc64.s",
|
ec_asm_src => "ecp_nistz256.c ecp_nistz256-ppc64.s x25519-ppc64.s",
|
||||||
keccak1600_asm_src => "keccak1600-ppc64.s",
|
keccak1600_asm_src => "keccak1600-ppc64.s",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -17,7 +17,7 @@ sub vc_win64a_info {
|
|||||||
asflags => "/c /Cp /Cx",
|
asflags => "/c /Cp /Cx",
|
||||||
asoutflag => "/Fo" };
|
asoutflag => "/Fo" };
|
||||||
} else {
|
} else {
|
||||||
$die->("NASM not found - please read INSTALL and NOTES.WIN for further details\n");
|
$die->("NASM not found - make sure it's installed and available on %PATH%\n");
|
||||||
$vc_win64a_info = { AS => "{unknown}",
|
$vc_win64a_info = { AS => "{unknown}",
|
||||||
ASFLAGS => "",
|
ASFLAGS => "",
|
||||||
asflags => "",
|
asflags => "",
|
||||||
@@ -46,7 +46,7 @@ sub vc_win32_info {
|
|||||||
asoutflag => "/Fo",
|
asoutflag => "/Fo",
|
||||||
perlasm_scheme => "win32" };
|
perlasm_scheme => "win32" };
|
||||||
} else {
|
} else {
|
||||||
$die->("NASM not found - please read INSTALL and NOTES.WIN for further details\n");
|
$die->("NASM not found - make sure it's installed and available on %PATH%\n");
|
||||||
$vc_win32_info = { AS => "{unknown}",
|
$vc_win32_info = { AS => "{unknown}",
|
||||||
ASFLAGS => "",
|
ASFLAGS => "",
|
||||||
asflags => "",
|
asflags => "",
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}
|
|||||||
INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{install}->{programs}}) -}
|
INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{install}->{programs}}) -}
|
||||||
{- output_off() if $disabled{apps}; "" -}
|
{- output_off() if $disabled{apps}; "" -}
|
||||||
BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
|
BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
|
||||||
MISC_SCRIPTS=$(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget
|
MISC_SCRIPTS=$(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget.pl:tsget
|
||||||
{- output_on() if $disabled{apps}; "" -}
|
{- output_on() if $disabled{apps}; "" -}
|
||||||
|
|
||||||
APPS_OPENSSL={- use File::Spec::Functions;
|
APPS_OPENSSL={- use File::Spec::Functions;
|
||||||
@@ -452,12 +452,25 @@ install_ssldirs:
|
|||||||
@$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
|
@$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
|
||||||
@set -e; for x in dummy $(MISC_SCRIPTS); do \
|
@set -e; for x in dummy $(MISC_SCRIPTS); do \
|
||||||
if [ "$$x" = "dummy" ]; then continue; fi; \
|
if [ "$$x" = "dummy" ]; then continue; fi; \
|
||||||
fn=`basename $$x`; \
|
x1=`echo "$$x" | cut -f1 -d:`; \
|
||||||
$(ECHO) "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
|
x2=`echo "$$x" | cut -f2 -d:`; \
|
||||||
cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
|
fn=`basename $$x1`; \
|
||||||
|
$(ECHO) "install $$x1 -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
|
||||||
|
cp $$x1 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
|
||||||
chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
|
chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
|
||||||
mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
|
mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
|
||||||
$(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
|
$(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
|
||||||
|
if [ "$$x1" != "$$x2" ]; then \
|
||||||
|
ln=`basename "$$x2"`; \
|
||||||
|
: {- output_off() unless windowsdll(); "" -}; \
|
||||||
|
$(ECHO) "copy $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
|
||||||
|
cp $(DESTDIR)$(OPENSSLDIR)/misc/$$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
|
||||||
|
: {- output_on() unless windowsdll();
|
||||||
|
output_off() if windowsdll(); "" -}; \
|
||||||
|
$(ECHO) "link $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
|
||||||
|
ln -sf $$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
|
||||||
|
: {- output_on() if windowsdll(); "" -}; \
|
||||||
|
fi; \
|
||||||
done
|
done
|
||||||
@$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
|
@$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
|
||||||
@cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
|
@cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ use OpenSSL::Glob;
|
|||||||
|
|
||||||
# see INSTALL for instructions.
|
# see INSTALL for instructions.
|
||||||
|
|
||||||
|
my $orig_death_handler = $SIG{__DIE__};
|
||||||
|
$SIG{__DIE__} = \&death_handler;
|
||||||
|
|
||||||
my $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-hw-xxx|no-hw] [[no-]threads] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-dso] [no-egd] [sctp] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--config=FILE] os/compiler[:flags]\n";
|
my $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-hw-xxx|no-hw] [[no-]threads] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-dso] [no-egd] [sctp] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--config=FILE] os/compiler[:flags]\n";
|
||||||
|
|
||||||
# Options:
|
# Options:
|
||||||
@@ -888,6 +891,7 @@ while (@argvcopy)
|
|||||||
else
|
else
|
||||||
{ $config{options} .= " ".$_; }
|
{ $config{options} .= " ".$_; }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (defined($config{api}) && !exists $apitable->{$config{api}}) {
|
if (defined($config{api}) && !exists $apitable->{$config{api}}) {
|
||||||
die "***** Unsupported api compatibility level: $config{api}\n",
|
die "***** Unsupported api compatibility level: $config{api}\n",
|
||||||
@@ -903,7 +907,6 @@ while (@argvcopy)
|
|||||||
die "***** Unsupported options: ",
|
die "***** Unsupported options: ",
|
||||||
join(", ", keys %unsupported_options), "\n";
|
join(", ", keys %unsupported_options), "\n";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
# If any %useradd entry has been set, we must check that the "make
|
# If any %useradd entry has been set, we must check that the "make
|
||||||
# variables" haven't been set. We start by checking of any %useradd entry
|
# variables" haven't been set. We start by checking of any %useradd entry
|
||||||
@@ -2679,6 +2682,8 @@ my %builders = (
|
|||||||
|
|
||||||
$builders{$builder}->($builder_platform, @builder_opts);
|
$builders{$builder}->($builder_platform, @builder_opts);
|
||||||
|
|
||||||
|
$SIG{__DIE__} = $orig_death_handler;
|
||||||
|
|
||||||
print <<"EOF" if ($disabled{threads} eq "unavailable");
|
print <<"EOF" if ($disabled{threads} eq "unavailable");
|
||||||
|
|
||||||
The library could not be configured for supporting multi-threaded
|
The library could not be configured for supporting multi-threaded
|
||||||
@@ -2714,6 +2719,24 @@ exit(0);
|
|||||||
# Helpers and utility functions
|
# Helpers and utility functions
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Death handler, to print a helpful message in case of failure #######
|
||||||
|
#
|
||||||
|
sub death_handler {
|
||||||
|
die @_ if $^S; # To prevent the added message in eval blocks
|
||||||
|
my $build_file = $target{build_file} // "build file";
|
||||||
|
my @message = ( <<"_____", @_ );
|
||||||
|
|
||||||
|
Failure! $build_file wasn't produced.
|
||||||
|
Please read INSTALL and associated NOTES files. You may also have to look over
|
||||||
|
your available compiler tool chain or change your configuration.
|
||||||
|
|
||||||
|
_____
|
||||||
|
|
||||||
|
# Dying is terminal, so it's ok to reset the signal handler here.
|
||||||
|
$SIG{__DIE__} = $orig_death_handler;
|
||||||
|
die @message;
|
||||||
|
}
|
||||||
|
|
||||||
# Configuration file reading #########################################
|
# Configuration file reading #########################################
|
||||||
|
|
||||||
# Note: All of the helper functions are for lazy evaluation. They all
|
# Note: All of the helper functions are for lazy evaluation. They all
|
||||||
|
|||||||
@@ -256,8 +256,10 @@
|
|||||||
no-shared option.
|
no-shared option.
|
||||||
|
|
||||||
no-asm
|
no-asm
|
||||||
Do not use assembler code. On some platforms a small amount
|
Do not use assembler code. This should be viewed as
|
||||||
of assembler code may still be used.
|
debugging/trouble-shooting option rather than production.
|
||||||
|
On some platforms a small amount of assembler code may
|
||||||
|
still be used even with this option.
|
||||||
|
|
||||||
no-async
|
no-async
|
||||||
Do not build support for async operations.
|
Do not build support for async operations.
|
||||||
|
|||||||
@@ -47,10 +47,11 @@
|
|||||||
the other hand oldest one is known not to work. Everything between
|
the other hand oldest one is known not to work. Everything between
|
||||||
falls into best-effort category.
|
falls into best-effort category.
|
||||||
|
|
||||||
- Netwide Assembler, a.k.a. NASM, available from http://www.nasm.us,
|
- Netwide Assembler, a.k.a. NASM, available from https://www.nasm.us,
|
||||||
is required if you intend to utilize assembler modules. Note that NASM
|
is required. Note that NASM is the only supported assembler. Even
|
||||||
is the only supported assembler. The Microsoft provided assembler is NOT
|
though Microsoft provided assembler is NOT supported, contemporary
|
||||||
supported.
|
64-bit version is exercised through continuous integration of
|
||||||
|
VC-WIN64A-masm target.
|
||||||
|
|
||||||
|
|
||||||
Installation directories
|
Installation directories
|
||||||
|
|||||||
+2
-3
@@ -1188,14 +1188,13 @@ void print_bignum_var(BIO *out, const BIGNUM *in, const char *var,
|
|||||||
{
|
{
|
||||||
BIO_printf(out, " static unsigned char %s_%d[] = {", var, len);
|
BIO_printf(out, " static unsigned char %s_%d[] = {", var, len);
|
||||||
if (BN_is_zero(in)) {
|
if (BN_is_zero(in)) {
|
||||||
BIO_printf(out, "\n\t0x00");
|
BIO_printf(out, "\n 0x00");
|
||||||
} else {
|
} else {
|
||||||
int i, l;
|
int i, l;
|
||||||
|
|
||||||
l = BN_bn2bin(in, buffer);
|
l = BN_bn2bin(in, buffer);
|
||||||
for (i = 0; i < l; i++) {
|
for (i = 0; i < l; i++) {
|
||||||
if ((i % 10) == 0)
|
BIO_printf(out, (i % 10) == 0 ? "\n " : " ");
|
||||||
BIO_printf(out, "\n\t");
|
|
||||||
if (i < l - 1)
|
if (i < l - 1)
|
||||||
BIO_printf(out, "0x%02X,", buffer[i]);
|
BIO_printf(out, "0x%02X,", buffer[i]);
|
||||||
else
|
else
|
||||||
|
|||||||
+3
-4
@@ -1,5 +1,4 @@
|
|||||||
{- our $tsget_name = $config{target} =~ /^(VC|vms)-/ ? "tsget.pl" : "tsget";
|
{- our @apps_openssl_src =
|
||||||
our @apps_openssl_src =
|
|
||||||
qw(openssl.c
|
qw(openssl.c
|
||||||
asn1pars.c ca.c ciphers.c cms.c crl.c crl2p7.c dgst.c dhparam.c
|
asn1pars.c ca.c ciphers.c cms.c crl.c crl2p7.c dgst.c dhparam.c
|
||||||
dsa.c dsaparam.c ec.c ecparam.c enc.c engine.c errstr.c gendsa.c
|
dsa.c dsaparam.c ec.c ecparam.c enc.c engine.c errstr.c gendsa.c
|
||||||
@@ -33,7 +32,7 @@ ENDIF
|
|||||||
GENERATE[progs.h]=progs.pl $(APPS_OPENSSL)
|
GENERATE[progs.h]=progs.pl $(APPS_OPENSSL)
|
||||||
DEPEND[progs.h]=../configdata.pm
|
DEPEND[progs.h]=../configdata.pm
|
||||||
|
|
||||||
SCRIPTS=CA.pl {- $tsget_name -}
|
SCRIPTS=CA.pl tsget.pl
|
||||||
SOURCE[CA.pl]=CA.pl.in
|
SOURCE[CA.pl]=CA.pl.in
|
||||||
SOURCE[{- $tsget_name -}]=tsget.in
|
SOURCE[tsget.pl]=tsget.in
|
||||||
ENDIF
|
ENDIF
|
||||||
+12
-21
@@ -309,33 +309,31 @@ int dhparam_main(int argc, char **argv)
|
|||||||
bits = DH_bits(dh);
|
bits = DH_bits(dh);
|
||||||
DH_get0_pqg(dh, &pbn, NULL, &gbn);
|
DH_get0_pqg(dh, &pbn, NULL, &gbn);
|
||||||
data = app_malloc(len, "print a BN");
|
data = app_malloc(len, "print a BN");
|
||||||
BIO_printf(out, "#ifndef HEADER_DH_H\n"
|
|
||||||
"# include <openssl/dh.h>\n"
|
BIO_printf(out, "static DH *get_dh%d(void)\n{\n", bits);
|
||||||
"#endif\n"
|
|
||||||
"\n");
|
|
||||||
BIO_printf(out, "DH *get_dh%d()\n{\n", bits);
|
|
||||||
print_bignum_var(out, pbn, "dhp", bits, data);
|
print_bignum_var(out, pbn, "dhp", bits, data);
|
||||||
print_bignum_var(out, gbn, "dhg", bits, data);
|
print_bignum_var(out, gbn, "dhg", bits, data);
|
||||||
BIO_printf(out, " DH *dh = DH_new();\n"
|
BIO_printf(out, " DH *dh = DH_new();\n"
|
||||||
" BIGNUM *dhp_bn, *dhg_bn;\n"
|
" BIGNUM *p, *g;\n"
|
||||||
"\n"
|
"\n"
|
||||||
" if (dh == NULL)\n"
|
" if (dh == NULL)\n"
|
||||||
" return NULL;\n");
|
" return NULL;\n");
|
||||||
BIO_printf(out, " dhp_bn = BN_bin2bn(dhp_%d, sizeof(dhp_%d), NULL);\n",
|
BIO_printf(out, " p = BN_bin2bn(dhp_%d, sizeof(dhp_%d), NULL);\n",
|
||||||
bits, bits);
|
bits, bits);
|
||||||
BIO_printf(out, " dhg_bn = BN_bin2bn(dhg_%d, sizeof(dhg_%d), NULL);\n",
|
BIO_printf(out, " g = BN_bin2bn(dhg_%d, sizeof(dhg_%d), NULL);\n",
|
||||||
bits, bits);
|
bits, bits);
|
||||||
BIO_printf(out, " if (dhp_bn == NULL || dhg_bn == NULL\n"
|
BIO_printf(out, " if (p == NULL || g == NULL\n"
|
||||||
" || !DH_set0_pqg(dh, dhp_bn, NULL, dhg_bn)) {\n"
|
" || !DH_set0_pqg(dh, p, NULL, g)) {\n"
|
||||||
" DH_free(dh);\n"
|
" DH_free(dh);\n"
|
||||||
" BN_free(dhp_bn);\n"
|
" BN_free(p);\n"
|
||||||
" BN_free(dhg_bn);\n"
|
" BN_free(g);\n"
|
||||||
" return NULL;\n"
|
" return NULL;\n"
|
||||||
" }\n");
|
" }\n");
|
||||||
if (DH_get_length(dh) > 0)
|
if (DH_get_length(dh) > 0)
|
||||||
BIO_printf(out,
|
BIO_printf(out,
|
||||||
" if (!DH_set_length(dh, %ld)) {\n"
|
" if (!DH_set_length(dh, %ld)) {\n"
|
||||||
" DH_free(dh);\n"
|
" DH_free(dh);\n"
|
||||||
|
" return NULL;\n"
|
||||||
" }\n", DH_get_length(dh));
|
" }\n", DH_get_length(dh));
|
||||||
BIO_printf(out, " return dh;\n}\n");
|
BIO_printf(out, " return dh;\n}\n");
|
||||||
OPENSSL_free(data);
|
OPENSSL_free(data);
|
||||||
@@ -371,16 +369,9 @@ int dhparam_main(int argc, char **argv)
|
|||||||
|
|
||||||
static int dh_cb(int p, int n, BN_GENCB *cb)
|
static int dh_cb(int p, int n, BN_GENCB *cb)
|
||||||
{
|
{
|
||||||
char c = '*';
|
static const char symbols[] = ".+*\n";
|
||||||
|
char c = (p >= 0 && (size_t)p < sizeof(symbols) - 1) ? symbols[p] : '?';
|
||||||
|
|
||||||
if (p == 0)
|
|
||||||
c = '.';
|
|
||||||
if (p == 1)
|
|
||||||
c = '+';
|
|
||||||
if (p == 2)
|
|
||||||
c = '*';
|
|
||||||
if (p == 3)
|
|
||||||
c = '\n';
|
|
||||||
BIO_write(BN_GENCB_get_arg(cb), &c, 1);
|
BIO_write(BN_GENCB_get_arg(cb), &c, 1);
|
||||||
(void)BIO_flush(BN_GENCB_get_arg(cb));
|
(void)BIO_flush(BN_GENCB_get_arg(cb));
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
+15
-19
@@ -179,25 +179,28 @@ int dsaparam_main(int argc, char **argv)
|
|||||||
|
|
||||||
data = app_malloc(len + 20, "BN space");
|
data = app_malloc(len + 20, "BN space");
|
||||||
|
|
||||||
BIO_printf(bio_out, "DSA *get_dsa%d()\n{\n", bits_p);
|
BIO_printf(bio_out, "static DSA *get_dsa%d(void)\n{\n", bits_p);
|
||||||
print_bignum_var(bio_out, p, "dsap", len, data);
|
print_bignum_var(bio_out, p, "dsap", bits_p, data);
|
||||||
print_bignum_var(bio_out, q, "dsaq", len, data);
|
print_bignum_var(bio_out, q, "dsaq", bits_p, data);
|
||||||
print_bignum_var(bio_out, g, "dsag", len, data);
|
print_bignum_var(bio_out, g, "dsag", bits_p, data);
|
||||||
BIO_printf(bio_out, " DSA *dsa = DSA_new();\n"
|
BIO_printf(bio_out, " DSA *dsa = DSA_new();\n"
|
||||||
|
" BIGNUM *p, *q, *g;\n"
|
||||||
"\n");
|
"\n");
|
||||||
BIO_printf(bio_out, " if (dsa == NULL)\n"
|
BIO_printf(bio_out, " if (dsa == NULL)\n"
|
||||||
" return NULL;\n");
|
" return NULL;\n");
|
||||||
BIO_printf(bio_out, " dsa->p = BN_bin2bn(dsap_%d, sizeof(dsap_%d), NULL);\n",
|
BIO_printf(bio_out, " if (!DSA_set0_pqg(dsa, p = BN_bin2bn(dsap_%d, sizeof(dsap_%d), NULL),\n",
|
||||||
bits_p, bits_p);
|
bits_p, bits_p);
|
||||||
BIO_printf(bio_out, " dsa->q = BN_bin2bn(dsaq_%d, sizeof(dsaq_%d), NULL);\n",
|
BIO_printf(bio_out, " q = BN_bin2bn(dsaq_%d, sizeof(dsaq_%d), NULL),\n",
|
||||||
bits_p, bits_p);
|
bits_p, bits_p);
|
||||||
BIO_printf(bio_out, " dsa->g = BN_bin2bn(dsag_%d, sizeof(dsag_%d), NULL);\n",
|
BIO_printf(bio_out, " g = BN_bin2bn(dsag_%d, sizeof(dsag_%d), NULL))) {\n",
|
||||||
bits_p, bits_p);
|
bits_p, bits_p);
|
||||||
BIO_printf(bio_out, " if (!dsa->p || !dsa->q || !dsa->g) {\n"
|
BIO_printf(bio_out, " DSA_free(dsa);\n"
|
||||||
" DSA_free(dsa);\n"
|
" BN_free(p);\n"
|
||||||
|
" BN_free(q);\n"
|
||||||
|
" BN_free(g);\n"
|
||||||
" return NULL;\n"
|
" return NULL;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" return(dsa);\n}\n");
|
" return dsa;\n}\n");
|
||||||
OPENSSL_free(data);
|
OPENSSL_free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,16 +248,9 @@ int dsaparam_main(int argc, char **argv)
|
|||||||
|
|
||||||
static int dsa_cb(int p, int n, BN_GENCB *cb)
|
static int dsa_cb(int p, int n, BN_GENCB *cb)
|
||||||
{
|
{
|
||||||
char c = '*';
|
static const char symbols[] = ".+*\n";
|
||||||
|
char c = (p >= 0 && (size_t)p < sizeof(symbols) - 1) ? symbols[p] : '?';
|
||||||
|
|
||||||
if (p == 0)
|
|
||||||
c = '.';
|
|
||||||
if (p == 1)
|
|
||||||
c = '+';
|
|
||||||
if (p == 2)
|
|
||||||
c = '*';
|
|
||||||
if (p == 3)
|
|
||||||
c = '\n';
|
|
||||||
BIO_write(BN_GENCB_get_arg(cb), &c, 1);
|
BIO_write(BN_GENCB_get_arg(cb), &c, 1);
|
||||||
(void)BIO_flush(BN_GENCB_get_arg(cb));
|
(void)BIO_flush(BN_GENCB_get_arg(cb));
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
+1
-1
@@ -299,7 +299,7 @@ int ecparam_main(int argc, char **argv)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EC_GROUP_get_curve_GFp(group, ec_p, ec_a, ec_b, NULL))
|
if (!EC_GROUP_get_curve(group, ec_p, ec_a, ec_b, NULL))
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
if ((point = EC_GROUP_get0_generator(group)) == NULL)
|
if ((point = EC_GROUP_get0_generator(group)) == NULL)
|
||||||
|
|||||||
@@ -364,7 +364,7 @@ static long dgram_get_mtu_overhead(bio_dgram_data *data)
|
|||||||
*/
|
*/
|
||||||
ret = 28;
|
ret = 28;
|
||||||
break;
|
break;
|
||||||
# ifdef AF_INET6
|
# if OPENSSL_USE_IPV6
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
{
|
{
|
||||||
# ifdef IN6_IS_ADDR_V4MAPPED
|
# ifdef IN6_IS_ADDR_V4MAPPED
|
||||||
|
|||||||
@@ -356,11 +356,6 @@ int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
|||||||
aa = val[0];
|
aa = val[0];
|
||||||
} else
|
} else
|
||||||
aa = a;
|
aa = a;
|
||||||
if (BN_is_zero(aa)) {
|
|
||||||
BN_zero(rr);
|
|
||||||
ret = 1;
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
if (!bn_to_mont_fixed_top(val[0], aa, mont, ctx))
|
if (!bn_to_mont_fixed_top(val[0], aa, mont, ctx))
|
||||||
goto err; /* 1 */
|
goto err; /* 1 */
|
||||||
|
|
||||||
|
|||||||
@@ -172,16 +172,20 @@ BN_ULONG *bn_get_words(const BIGNUM *a)
|
|||||||
return a->d;
|
return a->d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bn_set_static_words(BIGNUM *a, BN_ULONG *words, int size)
|
void bn_set_static_words(BIGNUM *a, const BN_ULONG *words, int size)
|
||||||
{
|
{
|
||||||
a->d = words;
|
/*
|
||||||
|
* |const| qualifier omission is compensated by BN_FLG_STATIC_DATA
|
||||||
|
* flag, which effectively means "read-only data".
|
||||||
|
*/
|
||||||
|
a->d = (BN_ULONG *)words;
|
||||||
a->dmax = a->top = size;
|
a->dmax = a->top = size;
|
||||||
a->neg = 0;
|
a->neg = 0;
|
||||||
a->flags |= BN_FLG_STATIC_DATA;
|
a->flags |= BN_FLG_STATIC_DATA;
|
||||||
bn_correct_top(a);
|
bn_correct_top(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bn_set_words(BIGNUM *a, BN_ULONG *words, int num_words)
|
int bn_set_words(BIGNUM *a, const BN_ULONG *words, int num_words)
|
||||||
{
|
{
|
||||||
if (bn_wexpand(a, num_words) == NULL) {
|
if (bn_wexpand(a, num_words) == NULL) {
|
||||||
BNerr(BN_F_BN_SET_WORDS, ERR_R_MALLOC_FAILURE);
|
BNerr(BN_F_BN_SET_WORDS, ERR_R_MALLOC_FAILURE);
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ int bn_mod_add_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
|||||||
((volatile BN_ULONG *)tp)[i] = 0;
|
((volatile BN_ULONG *)tp)[i] = 0;
|
||||||
}
|
}
|
||||||
r->top = mtop;
|
r->top = mtop;
|
||||||
|
r->neg = 0;
|
||||||
|
|
||||||
if (tp != storage)
|
if (tp != storage)
|
||||||
OPENSSL_free(tp);
|
OPENSSL_free(tp);
|
||||||
|
|||||||
+21
-3
@@ -27,6 +27,10 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef S_ISDIR
|
||||||
|
# define S_ISDIR(a) (((a) & S_IFMT) == S_IFDIR)
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The maximum length we can grow a value to after variable expansion. 64k
|
* The maximum length we can grow a value to after variable expansion. 64k
|
||||||
* should be more than enough for all reasonable uses.
|
* should be more than enough for all reasonable uses.
|
||||||
@@ -420,12 +424,26 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
|
|||||||
}
|
}
|
||||||
BUF_MEM_free(buff);
|
BUF_MEM_free(buff);
|
||||||
OPENSSL_free(section);
|
OPENSSL_free(section);
|
||||||
sk_BIO_pop_free(biosk, BIO_vfree);
|
/*
|
||||||
|
* No need to pop, since we only get here if the stack is empty.
|
||||||
|
* If this causes a BIO leak, THE ISSUE IS SOMEWHERE ELSE!
|
||||||
|
*/
|
||||||
|
sk_BIO_free(biosk);
|
||||||
return 1;
|
return 1;
|
||||||
err:
|
err:
|
||||||
BUF_MEM_free(buff);
|
BUF_MEM_free(buff);
|
||||||
OPENSSL_free(section);
|
OPENSSL_free(section);
|
||||||
sk_BIO_pop_free(biosk, BIO_vfree);
|
/*
|
||||||
|
* Since |in| is the first element of the stack and should NOT be freed
|
||||||
|
* here, we cannot use sk_BIO_pop_free(). Instead, we pop and free one
|
||||||
|
* BIO at a time, making sure that the last one popped isn't.
|
||||||
|
*/
|
||||||
|
while (sk_BIO_num(biosk) > 0) {
|
||||||
|
BIO *popped = sk_BIO_pop(biosk);
|
||||||
|
BIO_vfree(in);
|
||||||
|
in = popped;
|
||||||
|
}
|
||||||
|
sk_BIO_free(biosk);
|
||||||
#ifndef OPENSSL_NO_POSIX_IO
|
#ifndef OPENSSL_NO_POSIX_IO
|
||||||
OPENSSL_free(dirpath);
|
OPENSSL_free(dirpath);
|
||||||
if (dirctx != NULL)
|
if (dirctx != NULL)
|
||||||
@@ -656,7 +674,7 @@ static BIO *process_include(char *include, OPENSSL_DIR_CTX **dirctx,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((st.st_mode & S_IFDIR) == S_IFDIR) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
if (*dirctx != NULL) {
|
if (*dirctx != NULL) {
|
||||||
CONFerr(CONF_F_PROCESS_INCLUDE,
|
CONFerr(CONF_F_PROCESS_INCLUDE,
|
||||||
CONF_R_RECURSIVE_DIRECTORY_INCLUDE);
|
CONF_R_RECURSIVE_DIRECTORY_INCLUDE);
|
||||||
|
|||||||
+87
-21
@@ -19,29 +19,97 @@
|
|||||||
extern unsigned int OPENSSL_ia32cap_P[4];
|
extern unsigned int OPENSSL_ia32cap_P[4];
|
||||||
|
|
||||||
# if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY)
|
# if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY)
|
||||||
#include <stdio.h>
|
|
||||||
|
/*
|
||||||
|
* Purpose of these minimalistic and character-type-agnostic subroutines
|
||||||
|
* is to break dependency on MSVCRT (on Windows) and locale. This makes
|
||||||
|
* OPENSSL_cpuid_setup safe to use as "constructor". "Character-type-
|
||||||
|
* agnostic" means that they work with either wide or 8-bit characters,
|
||||||
|
* exploiting the fact that first 127 characters can be simply casted
|
||||||
|
* between the sets, while the rest would be simply rejected by ossl_is*
|
||||||
|
* subroutines.
|
||||||
|
*/
|
||||||
|
# ifdef _WIN32
|
||||||
|
typedef WCHAR variant_char;
|
||||||
|
|
||||||
|
static variant_char *ossl_getenv(const char *name)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Since we pull only one environment variable, it's simpler to
|
||||||
|
* to just ignore |name| and use equivalent wide-char L-literal.
|
||||||
|
* As well as to ignore excessively long values...
|
||||||
|
*/
|
||||||
|
static WCHAR value[48];
|
||||||
|
DWORD len = GetEnvironmentVariableW(L"OPENSSL_ia32cap", value, 48);
|
||||||
|
|
||||||
|
return (len > 0 && len < 48) ? value : NULL;
|
||||||
|
}
|
||||||
|
# else
|
||||||
|
typedef char variant_char;
|
||||||
|
# define ossl_getenv getenv
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# include "internal/ctype.h"
|
||||||
|
|
||||||
|
static int todigit(variant_char c)
|
||||||
|
{
|
||||||
|
if (ossl_isdigit(c))
|
||||||
|
return c - '0';
|
||||||
|
else if (ossl_isxdigit(c))
|
||||||
|
return ossl_tolower(c) - 'a' + 10;
|
||||||
|
|
||||||
|
/* return largest base value to make caller terminate the loop */
|
||||||
|
return 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint64_t ossl_strtouint64(const variant_char *str)
|
||||||
|
{
|
||||||
|
uint64_t ret = 0;
|
||||||
|
unsigned int digit, base = 10;
|
||||||
|
|
||||||
|
if (*str == '0') {
|
||||||
|
base = 8, str++;
|
||||||
|
if (ossl_tolower(*str) == 'x')
|
||||||
|
base = 16, str++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while((digit = todigit(*str++)) < base)
|
||||||
|
ret = ret * base + digit;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static variant_char *ossl_strchr(const variant_char *str, char srch)
|
||||||
|
{ variant_char c;
|
||||||
|
|
||||||
|
while((c = *str)) {
|
||||||
|
if (c == srch)
|
||||||
|
return (variant_char *)str;
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
# define OPENSSL_CPUID_SETUP
|
# define OPENSSL_CPUID_SETUP
|
||||||
typedef uint64_t IA32CAP;
|
typedef uint64_t IA32CAP;
|
||||||
|
|
||||||
void OPENSSL_cpuid_setup(void)
|
void OPENSSL_cpuid_setup(void)
|
||||||
{
|
{
|
||||||
static int trigger = 0;
|
static int trigger = 0;
|
||||||
IA32CAP OPENSSL_ia32_cpuid(unsigned int *);
|
IA32CAP OPENSSL_ia32_cpuid(unsigned int *);
|
||||||
IA32CAP vec;
|
IA32CAP vec;
|
||||||
char *env;
|
const variant_char *env;
|
||||||
|
|
||||||
if (trigger)
|
if (trigger)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
trigger = 1;
|
trigger = 1;
|
||||||
if ((env = getenv("OPENSSL_ia32cap"))) {
|
if ((env = ossl_getenv("OPENSSL_ia32cap")) != NULL) {
|
||||||
int off = (env[0] == '~') ? 1 : 0;
|
int off = (env[0] == '~') ? 1 : 0;
|
||||||
# if defined(_WIN32)
|
|
||||||
if (!sscanf(env + off, "%I64i", &vec))
|
vec = ossl_strtouint64(env + off);
|
||||||
vec = strtoul(env + off, NULL, 0);
|
|
||||||
# else
|
|
||||||
if (!sscanf(env + off, "%lli", (long long *)&vec))
|
|
||||||
vec = strtoul(env + off, NULL, 0);
|
|
||||||
# endif
|
|
||||||
if (off) {
|
if (off) {
|
||||||
IA32CAP mask = vec;
|
IA32CAP mask = vec;
|
||||||
vec = OPENSSL_ia32_cpuid(OPENSSL_ia32cap_P) & ~mask;
|
vec = OPENSSL_ia32_cpuid(OPENSSL_ia32cap_P) & ~mask;
|
||||||
@@ -60,17 +128,12 @@ void OPENSSL_cpuid_setup(void)
|
|||||||
vec = OPENSSL_ia32_cpuid(OPENSSL_ia32cap_P);
|
vec = OPENSSL_ia32_cpuid(OPENSSL_ia32cap_P);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((env = strchr(env, ':'))) {
|
if ((env = ossl_strchr(env, ':')) != NULL) {
|
||||||
IA32CAP vecx;
|
IA32CAP vecx;
|
||||||
|
|
||||||
env++;
|
env++;
|
||||||
off = (env[0] == '~') ? 1 : 0;
|
off = (env[0] == '~') ? 1 : 0;
|
||||||
# if defined(_WIN32)
|
vecx = ossl_strtouint64(env + off);
|
||||||
if (!sscanf(env + off, "%I64i", &vecx))
|
|
||||||
vecx = strtoul(env + off, NULL, 0);
|
|
||||||
# else
|
|
||||||
if (!sscanf(env + off, "%lli", (long long *)&vecx))
|
|
||||||
vecx = strtoul(env + off, NULL, 0);
|
|
||||||
# endif
|
|
||||||
if (off) {
|
if (off) {
|
||||||
OPENSSL_ia32cap_P[2] &= ~(unsigned int)vecx;
|
OPENSSL_ia32cap_P[2] &= ~(unsigned int)vecx;
|
||||||
OPENSSL_ia32cap_P[3] &= ~(unsigned int)(vecx >> 32);
|
OPENSSL_ia32cap_P[3] &= ~(unsigned int)(vecx >> 32);
|
||||||
@@ -98,7 +161,6 @@ void OPENSSL_cpuid_setup(void)
|
|||||||
unsigned int OPENSSL_ia32cap_P[4];
|
unsigned int OPENSSL_ia32cap_P[4];
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
int OPENSSL_NONPIC_relocated = 0;
|
|
||||||
#if !defined(OPENSSL_CPUID_SETUP) && !defined(OPENSSL_CPUID_OBJ)
|
#if !defined(OPENSSL_CPUID_SETUP) && !defined(OPENSSL_CPUID_OBJ)
|
||||||
void OPENSSL_cpuid_setup(void)
|
void OPENSSL_cpuid_setup(void)
|
||||||
{
|
{
|
||||||
@@ -142,10 +204,14 @@ int OPENSSL_isservice(void)
|
|||||||
|
|
||||||
if (_OPENSSL_isservice.p == NULL) {
|
if (_OPENSSL_isservice.p == NULL) {
|
||||||
HANDLE mod = GetModuleHandle(NULL);
|
HANDLE mod = GetModuleHandle(NULL);
|
||||||
|
FARPROC f;
|
||||||
|
|
||||||
if (mod != NULL)
|
if (mod != NULL)
|
||||||
_OPENSSL_isservice.f = GetProcAddress(mod, "_OPENSSL_isservice");
|
f = GetProcAddress(mod, "_OPENSSL_isservice");
|
||||||
if (_OPENSSL_isservice.p == NULL)
|
if (f == NULL)
|
||||||
_OPENSSL_isservice.p = (void *)-1;
|
_OPENSSL_isservice.p = (void *)-1;
|
||||||
|
else
|
||||||
|
_OPENSSL_isservice.f = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_OPENSSL_isservice.p != (void *)-1)
|
if (_OPENSSL_isservice.p != (void *)-1)
|
||||||
|
|||||||
@@ -31,21 +31,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|||||||
switch (fdwReason) {
|
switch (fdwReason) {
|
||||||
case DLL_PROCESS_ATTACH:
|
case DLL_PROCESS_ATTACH:
|
||||||
OPENSSL_cpuid_setup();
|
OPENSSL_cpuid_setup();
|
||||||
# if defined(_WIN32_WINNT)
|
|
||||||
{
|
|
||||||
IMAGE_DOS_HEADER *dos_header = (IMAGE_DOS_HEADER *) hinstDLL;
|
|
||||||
IMAGE_NT_HEADERS *nt_headers;
|
|
||||||
|
|
||||||
if (dos_header->e_magic == IMAGE_DOS_SIGNATURE) {
|
|
||||||
nt_headers = (IMAGE_NT_HEADERS *) ((char *)dos_header
|
|
||||||
+ dos_header->e_lfanew);
|
|
||||||
if (nt_headers->Signature == IMAGE_NT_SIGNATURE &&
|
|
||||||
hinstDLL !=
|
|
||||||
(HINSTANCE) (nt_headers->OptionalHeader.ImageBase))
|
|
||||||
OPENSSL_NONPIC_relocated = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
break;
|
break;
|
||||||
case DLL_THREAD_ATTACH:
|
case DLL_THREAD_ATTACH:
|
||||||
break;
|
break;
|
||||||
|
|||||||
+2
-12
@@ -77,13 +77,8 @@ static int pkey_dsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig,
|
|||||||
DSA_PKEY_CTX *dctx = ctx->data;
|
DSA_PKEY_CTX *dctx = ctx->data;
|
||||||
DSA *dsa = ctx->pkey->pkey.dsa;
|
DSA *dsa = ctx->pkey->pkey.dsa;
|
||||||
|
|
||||||
if (dctx->md) {
|
if (dctx->md != NULL && tbslen != (size_t)EVP_MD_size(dctx->md))
|
||||||
if (tbslen != (size_t)EVP_MD_size(dctx->md))
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
|
||||||
if (tbslen != SHA_DIGEST_LENGTH)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = DSA_sign(0, tbs, tbslen, sig, &sltmp, dsa);
|
ret = DSA_sign(0, tbs, tbslen, sig, &sltmp, dsa);
|
||||||
|
|
||||||
@@ -101,13 +96,8 @@ static int pkey_dsa_verify(EVP_PKEY_CTX *ctx,
|
|||||||
DSA_PKEY_CTX *dctx = ctx->data;
|
DSA_PKEY_CTX *dctx = ctx->data;
|
||||||
DSA *dsa = ctx->pkey->pkey.dsa;
|
DSA *dsa = ctx->pkey->pkey.dsa;
|
||||||
|
|
||||||
if (dctx->md) {
|
if (dctx->md != NULL && tbslen != (size_t)EVP_MD_size(dctx->md))
|
||||||
if (tbslen != (size_t)EVP_MD_size(dctx->md))
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
|
||||||
if (tbslen != SHA_DIGEST_LENGTH)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = DSA_verify(0, tbs, tbslen, sig, siglen, dsa);
|
ret = DSA_verify(0, tbs, tbslen, sig, siglen, dsa);
|
||||||
|
|
||||||
|
|||||||
@@ -894,13 +894,13 @@ ecp_nistz256_scatter_w7:
|
|||||||
.Loop_scatter_w7:
|
.Loop_scatter_w7:
|
||||||
ldr $mask,[$inp],#4
|
ldr $mask,[$inp],#4
|
||||||
subs $index,$index,#1
|
subs $index,$index,#1
|
||||||
strb $mask,[$out,#64*0-1]
|
strb $mask,[$out,#64*0]
|
||||||
mov $mask,$mask,lsr#8
|
mov $mask,$mask,lsr#8
|
||||||
strb $mask,[$out,#64*1-1]
|
strb $mask,[$out,#64*1]
|
||||||
mov $mask,$mask,lsr#8
|
mov $mask,$mask,lsr#8
|
||||||
strb $mask,[$out,#64*2-1]
|
strb $mask,[$out,#64*2]
|
||||||
mov $mask,$mask,lsr#8
|
mov $mask,$mask,lsr#8
|
||||||
strb $mask,[$out,#64*3-1]
|
strb $mask,[$out,#64*3]
|
||||||
add $out,$out,#64*4
|
add $out,$out,#64*4
|
||||||
bne .Loop_scatter_w7
|
bne .Loop_scatter_w7
|
||||||
|
|
||||||
|
|||||||
@@ -1776,21 +1776,21 @@ ecp_nistz256_scatter_w7:
|
|||||||
prfm pstl1strm,[$out,#4096+64*5]
|
prfm pstl1strm,[$out,#4096+64*5]
|
||||||
prfm pstl1strm,[$out,#4096+64*6]
|
prfm pstl1strm,[$out,#4096+64*6]
|
||||||
prfm pstl1strm,[$out,#4096+64*7]
|
prfm pstl1strm,[$out,#4096+64*7]
|
||||||
strb w3,[$out,#64*0-1]
|
strb w3,[$out,#64*0]
|
||||||
lsr x3,x3,#8
|
lsr x3,x3,#8
|
||||||
strb w3,[$out,#64*1-1]
|
strb w3,[$out,#64*1]
|
||||||
lsr x3,x3,#8
|
lsr x3,x3,#8
|
||||||
strb w3,[$out,#64*2-1]
|
strb w3,[$out,#64*2]
|
||||||
lsr x3,x3,#8
|
lsr x3,x3,#8
|
||||||
strb w3,[$out,#64*3-1]
|
strb w3,[$out,#64*3]
|
||||||
lsr x3,x3,#8
|
lsr x3,x3,#8
|
||||||
strb w3,[$out,#64*4-1]
|
strb w3,[$out,#64*4]
|
||||||
lsr x3,x3,#8
|
lsr x3,x3,#8
|
||||||
strb w3,[$out,#64*5-1]
|
strb w3,[$out,#64*5]
|
||||||
lsr x3,x3,#8
|
lsr x3,x3,#8
|
||||||
strb w3,[$out,#64*6-1]
|
strb w3,[$out,#64*6]
|
||||||
lsr x3,x3,#8
|
lsr x3,x3,#8
|
||||||
strb w3,[$out,#64*7-1]
|
strb w3,[$out,#64*7]
|
||||||
add $out,$out,#64*8
|
add $out,$out,#64*8
|
||||||
b.ne .Loop_scatter_w7
|
b.ne .Loop_scatter_w7
|
||||||
|
|
||||||
|
|||||||
@@ -2297,21 +2297,21 @@ ecp_nistz256_scatter_w7:
|
|||||||
|
|
||||||
.Loop_scatter_w7:
|
.Loop_scatter_w7:
|
||||||
ldu r0,8($inp)
|
ldu r0,8($inp)
|
||||||
stb r0,64*0-1($out)
|
stb r0,64*0($out)
|
||||||
srdi r0,r0,8
|
srdi r0,r0,8
|
||||||
stb r0,64*1-1($out)
|
stb r0,64*1($out)
|
||||||
srdi r0,r0,8
|
srdi r0,r0,8
|
||||||
stb r0,64*2-1($out)
|
stb r0,64*2($out)
|
||||||
srdi r0,r0,8
|
srdi r0,r0,8
|
||||||
stb r0,64*3-1($out)
|
stb r0,64*3($out)
|
||||||
srdi r0,r0,8
|
srdi r0,r0,8
|
||||||
stb r0,64*4-1($out)
|
stb r0,64*4($out)
|
||||||
srdi r0,r0,8
|
srdi r0,r0,8
|
||||||
stb r0,64*5-1($out)
|
stb r0,64*5($out)
|
||||||
srdi r0,r0,8
|
srdi r0,r0,8
|
||||||
stb r0,64*6-1($out)
|
stb r0,64*6($out)
|
||||||
srdi r0,r0,8
|
srdi r0,r0,8
|
||||||
stb r0,64*7-1($out)
|
stb r0,64*7($out)
|
||||||
addi $out,$out,64*8
|
addi $out,$out,64*8
|
||||||
bdnz .Loop_scatter_w7
|
bdnz .Loop_scatter_w7
|
||||||
|
|
||||||
|
|||||||
@@ -1531,13 +1531,13 @@ ecp_nistz256_scatter_w7:
|
|||||||
ld [$inp],%l0
|
ld [$inp],%l0
|
||||||
add $inp,4,$inp
|
add $inp,4,$inp
|
||||||
subcc $index,1,$index
|
subcc $index,1,$index
|
||||||
stb %l0,[$out+64*0-1]
|
stb %l0,[$out+64*0]
|
||||||
srl %l0,8,%l1
|
srl %l0,8,%l1
|
||||||
stb %l1,[$out+64*1-1]
|
stb %l1,[$out+64*1]
|
||||||
srl %l0,16,%l2
|
srl %l0,16,%l2
|
||||||
stb %l2,[$out+64*2-1]
|
stb %l2,[$out+64*2]
|
||||||
srl %l0,24,%l3
|
srl %l0,24,%l3
|
||||||
stb %l3,[$out+64*3-1]
|
stb %l3,[$out+64*3]
|
||||||
bne .Loop_scatter_w7
|
bne .Loop_scatter_w7
|
||||||
add $out,64*4,$out
|
add $out,64*4,$out
|
||||||
|
|
||||||
|
|||||||
@@ -1179,7 +1179,7 @@ for ($i=0;$i<7;$i++) {
|
|||||||
&mov ("esi",&wparam(1));
|
&mov ("esi",&wparam(1));
|
||||||
&mov ("ebp",&wparam(2));
|
&mov ("ebp",&wparam(2));
|
||||||
|
|
||||||
&lea ("edi",&DWP(-1,"edi","ebp"));
|
&lea ("edi",&DWP(0,"edi","ebp"));
|
||||||
&mov ("ebp",64/4);
|
&mov ("ebp",64/4);
|
||||||
&set_label("scatter_w7_loop");
|
&set_label("scatter_w7_loop");
|
||||||
&mov ("eax",&DWP(0,"esi"));
|
&mov ("eax",&DWP(0,"esi"));
|
||||||
|
|||||||
Executable
+824
@@ -0,0 +1,824 @@
|
|||||||
|
#! /usr/bin/env perl
|
||||||
|
# Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
# this file except in compliance with the License. You can obtain a copy
|
||||||
|
# in the file LICENSE in the source distribution or at
|
||||||
|
# https://www.openssl.org/source/license.html
|
||||||
|
#
|
||||||
|
# ====================================================================
|
||||||
|
# Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
|
||||||
|
# project. The module is, however, dual licensed under OpenSSL and
|
||||||
|
# CRYPTOGAMS licenses depending on where you obtain it. For further
|
||||||
|
# details see http://www.openssl.org/~appro/cryptogams/.
|
||||||
|
# ====================================================================
|
||||||
|
#
|
||||||
|
# X25519 lower-level primitives for PPC64.
|
||||||
|
#
|
||||||
|
# July 2018.
|
||||||
|
#
|
||||||
|
# Base 2^64 is faster than base 2^51 on pre-POWER8, most notably ~15%
|
||||||
|
# faster on PPC970/G5. POWER8 on the other hand seems to trip on own
|
||||||
|
# shoelaces when handling longer carry chains. As base 2^51 has just
|
||||||
|
# single-carry pairs, it's 25% faster than base 2^64. Since PPC970 is
|
||||||
|
# pretty old, base 2^64 implementation is not engaged. Comparison to
|
||||||
|
# compiler-generated code is complicated by the fact that not all
|
||||||
|
# compilers support 128-bit integers. When compiler doesn't, like xlc,
|
||||||
|
# this module delivers more than 2x improvement, and when it does,
|
||||||
|
# from 12% to 30% improvement was measured...
|
||||||
|
|
||||||
|
$flavour = shift;
|
||||||
|
while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
|
||||||
|
|
||||||
|
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||||
|
( $xlate="${dir}ppc-xlate.pl" and -f $xlate ) or
|
||||||
|
( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or
|
||||||
|
die "can't locate ppc-xlate.pl";
|
||||||
|
|
||||||
|
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||||
|
*STDOUT=*OUT;
|
||||||
|
|
||||||
|
my $sp = "r1";
|
||||||
|
my ($rp,$ap,$bp) = map("r$_",3..5);
|
||||||
|
|
||||||
|
####################################################### base 2^64
|
||||||
|
if (0) {
|
||||||
|
my ($bi,$a0,$a1,$a2,$a3,$t0,$t1, $t2,$t3,
|
||||||
|
$acc0,$acc1,$acc2,$acc3,$acc4,$acc5,$acc6,$acc7) =
|
||||||
|
map("r$_",(6..12,22..31));
|
||||||
|
my $zero = "r0";
|
||||||
|
my $FRAME = 16*8;
|
||||||
|
|
||||||
|
$code.=<<___;
|
||||||
|
.text
|
||||||
|
|
||||||
|
.globl x25519_fe64_mul
|
||||||
|
.type x25519_fe64_mul,\@function
|
||||||
|
.align 5
|
||||||
|
x25519_fe64_mul:
|
||||||
|
stdu $sp,-$FRAME($sp)
|
||||||
|
std r22,`$FRAME-8*10`($sp)
|
||||||
|
std r23,`$FRAME-8*9`($sp)
|
||||||
|
std r24,`$FRAME-8*8`($sp)
|
||||||
|
std r25,`$FRAME-8*7`($sp)
|
||||||
|
std r26,`$FRAME-8*6`($sp)
|
||||||
|
std r27,`$FRAME-8*5`($sp)
|
||||||
|
std r28,`$FRAME-8*4`($sp)
|
||||||
|
std r29,`$FRAME-8*3`($sp)
|
||||||
|
std r30,`$FRAME-8*2`($sp)
|
||||||
|
std r31,`$FRAME-8*1`($sp)
|
||||||
|
|
||||||
|
ld $bi,0($bp)
|
||||||
|
ld $a0,0($ap)
|
||||||
|
xor $zero,$zero,$zero
|
||||||
|
ld $a1,8($ap)
|
||||||
|
ld $a2,16($ap)
|
||||||
|
ld $a3,24($ap)
|
||||||
|
|
||||||
|
mulld $acc0,$a0,$bi # a[0]*b[0]
|
||||||
|
mulhdu $t0,$a0,$bi
|
||||||
|
mulld $acc1,$a1,$bi # a[1]*b[0]
|
||||||
|
mulhdu $t1,$a1,$bi
|
||||||
|
mulld $acc2,$a2,$bi # a[2]*b[0]
|
||||||
|
mulhdu $t2,$a2,$bi
|
||||||
|
mulld $acc3,$a3,$bi # a[3]*b[0]
|
||||||
|
mulhdu $t3,$a3,$bi
|
||||||
|
___
|
||||||
|
for(my @acc=($acc0,$acc1,$acc2,$acc3,$acc4,$acc5,$acc6,$acc7),
|
||||||
|
my $i=1; $i<4; shift(@acc), $i++) {
|
||||||
|
my $acc4 = $i==1? $zero : @acc[4];
|
||||||
|
|
||||||
|
$code.=<<___;
|
||||||
|
ld $bi,`8*$i`($bp)
|
||||||
|
addc @acc[1],@acc[1],$t0 # accumulate high parts
|
||||||
|
mulld $t0,$a0,$bi
|
||||||
|
adde @acc[2],@acc[2],$t1
|
||||||
|
mulld $t1,$a1,$bi
|
||||||
|
adde @acc[3],@acc[3],$t2
|
||||||
|
mulld $t2,$a2,$bi
|
||||||
|
adde @acc[4],$acc4,$t3
|
||||||
|
mulld $t3,$a3,$bi
|
||||||
|
addc @acc[1],@acc[1],$t0 # accumulate low parts
|
||||||
|
mulhdu $t0,$a0,$bi
|
||||||
|
adde @acc[2],@acc[2],$t1
|
||||||
|
mulhdu $t1,$a1,$bi
|
||||||
|
adde @acc[3],@acc[3],$t2
|
||||||
|
mulhdu $t2,$a2,$bi
|
||||||
|
adde @acc[4],@acc[4],$t3
|
||||||
|
mulhdu $t3,$a3,$bi
|
||||||
|
adde @acc[5],$zero,$zero
|
||||||
|
___
|
||||||
|
}
|
||||||
|
$code.=<<___;
|
||||||
|
li $bi,38
|
||||||
|
addc $acc4,$acc4,$t0
|
||||||
|
mulld $t0,$acc4,$bi
|
||||||
|
adde $acc5,$acc5,$t1
|
||||||
|
mulld $t1,$acc5,$bi
|
||||||
|
adde $acc6,$acc6,$t2
|
||||||
|
mulld $t2,$acc6,$bi
|
||||||
|
adde $acc7,$acc7,$t3
|
||||||
|
mulld $t3,$acc7,$bi
|
||||||
|
|
||||||
|
addc $acc0,$acc0,$t0
|
||||||
|
mulhdu $t0,$acc4,$bi
|
||||||
|
adde $acc1,$acc1,$t1
|
||||||
|
mulhdu $t1,$acc5,$bi
|
||||||
|
adde $acc2,$acc2,$t2
|
||||||
|
mulhdu $t2,$acc6,$bi
|
||||||
|
adde $acc3,$acc3,$t3
|
||||||
|
mulhdu $t3,$acc7,$bi
|
||||||
|
adde $acc4,$zero,$zero
|
||||||
|
|
||||||
|
addc $acc1,$acc1,$t0
|
||||||
|
adde $acc2,$acc2,$t1
|
||||||
|
adde $acc3,$acc3,$t2
|
||||||
|
adde $acc4,$acc4,$t3
|
||||||
|
|
||||||
|
mulld $acc4,$acc4,$bi
|
||||||
|
|
||||||
|
addc $acc0,$acc0,$acc4
|
||||||
|
addze $acc1,$acc1
|
||||||
|
addze $acc2,$acc2
|
||||||
|
addze $acc3,$acc3
|
||||||
|
|
||||||
|
subfe $acc4,$acc4,$acc4 # carry -> ~mask
|
||||||
|
std $acc1,8($rp)
|
||||||
|
andc $acc4,$bi,$acc4
|
||||||
|
std $acc2,16($rp)
|
||||||
|
add $acc0,$acc0,$acc4
|
||||||
|
std $acc3,24($rp)
|
||||||
|
std $acc0,0($rp)
|
||||||
|
|
||||||
|
ld r22,`$FRAME-8*10`($sp)
|
||||||
|
ld r23,`$FRAME-8*9`($sp)
|
||||||
|
ld r24,`$FRAME-8*8`($sp)
|
||||||
|
ld r25,`$FRAME-8*7`($sp)
|
||||||
|
ld r26,`$FRAME-8*6`($sp)
|
||||||
|
ld r27,`$FRAME-8*5`($sp)
|
||||||
|
ld r28,`$FRAME-8*4`($sp)
|
||||||
|
ld r29,`$FRAME-8*3`($sp)
|
||||||
|
ld r30,`$FRAME-8*2`($sp)
|
||||||
|
ld r31,`$FRAME-8*1`($sp)
|
||||||
|
addi $sp,$sp,$FRAME
|
||||||
|
blr
|
||||||
|
.long 0
|
||||||
|
.byte 0,12,4,0,0x80,10,3,0
|
||||||
|
.long 0
|
||||||
|
.size x25519_fe64_mul,.-x25519_fe64_mul
|
||||||
|
|
||||||
|
.globl x25519_fe64_sqr
|
||||||
|
.type x25519_fe64_sqr,\@function
|
||||||
|
.align 5
|
||||||
|
x25519_fe64_sqr:
|
||||||
|
stdu $sp,-$FRAME($sp)
|
||||||
|
std r22,`$FRAME-8*10`($sp)
|
||||||
|
std r23,`$FRAME-8*9`($sp)
|
||||||
|
std r24,`$FRAME-8*8`($sp)
|
||||||
|
std r25,`$FRAME-8*7`($sp)
|
||||||
|
std r26,`$FRAME-8*6`($sp)
|
||||||
|
std r27,`$FRAME-8*5`($sp)
|
||||||
|
std r28,`$FRAME-8*4`($sp)
|
||||||
|
std r29,`$FRAME-8*3`($sp)
|
||||||
|
std r30,`$FRAME-8*2`($sp)
|
||||||
|
std r31,`$FRAME-8*1`($sp)
|
||||||
|
|
||||||
|
ld $a0,0($ap)
|
||||||
|
xor $zero,$zero,$zero
|
||||||
|
ld $a1,8($ap)
|
||||||
|
ld $a2,16($ap)
|
||||||
|
ld $a3,24($ap)
|
||||||
|
|
||||||
|
################################
|
||||||
|
# | | | | | |a1*a0| |
|
||||||
|
# | | | | |a2*a0| | |
|
||||||
|
# | |a3*a2|a3*a0| | | |
|
||||||
|
# | | | |a2*a1| | | |
|
||||||
|
# | | |a3*a1| | | | |
|
||||||
|
# *| | | | | | | | 2|
|
||||||
|
# +|a3*a3|a2*a2|a1*a1|a0*a0|
|
||||||
|
# |--+--+--+--+--+--+--+--|
|
||||||
|
# |A7|A6|A5|A4|A3|A2|A1|A0|, where Ax is $accx, i.e. follow $accx
|
||||||
|
#
|
||||||
|
# "can't overflow" below mark carrying into high part of
|
||||||
|
# multiplication result, which can't overflow, because it
|
||||||
|
# can never be all ones.
|
||||||
|
|
||||||
|
mulld $acc1,$a1,$a0 # a[1]*a[0]
|
||||||
|
mulhdu $t1,$a1,$a0
|
||||||
|
mulld $acc2,$a2,$a0 # a[2]*a[0]
|
||||||
|
mulhdu $t2,$a2,$a0
|
||||||
|
mulld $acc3,$a3,$a0 # a[3]*a[0]
|
||||||
|
mulhdu $acc4,$a3,$a0
|
||||||
|
|
||||||
|
addc $acc2,$acc2,$t1 # accumulate high parts of multiplication
|
||||||
|
mulld $t0,$a2,$a1 # a[2]*a[1]
|
||||||
|
mulhdu $t1,$a2,$a1
|
||||||
|
adde $acc3,$acc3,$t2
|
||||||
|
mulld $t2,$a3,$a1 # a[3]*a[1]
|
||||||
|
mulhdu $t3,$a3,$a1
|
||||||
|
addze $acc4,$acc4 # can't overflow
|
||||||
|
|
||||||
|
mulld $acc5,$a3,$a2 # a[3]*a[2]
|
||||||
|
mulhdu $acc6,$a3,$a2
|
||||||
|
|
||||||
|
addc $t1,$t1,$t2 # accumulate high parts of multiplication
|
||||||
|
mulld $acc0,$a0,$a0 # a[0]*a[0]
|
||||||
|
addze $t2,$t3 # can't overflow
|
||||||
|
|
||||||
|
addc $acc3,$acc3,$t0 # accumulate low parts of multiplication
|
||||||
|
mulhdu $a0,$a0,$a0
|
||||||
|
adde $acc4,$acc4,$t1
|
||||||
|
mulld $t1,$a1,$a1 # a[1]*a[1]
|
||||||
|
adde $acc5,$acc5,$t2
|
||||||
|
mulhdu $a1,$a1,$a1
|
||||||
|
addze $acc6,$acc6 # can't overflow
|
||||||
|
|
||||||
|
addc $acc1,$acc1,$acc1 # acc[1-6]*=2
|
||||||
|
mulld $t2,$a2,$a2 # a[2]*a[2]
|
||||||
|
adde $acc2,$acc2,$acc2
|
||||||
|
mulhdu $a2,$a2,$a2
|
||||||
|
adde $acc3,$acc3,$acc3
|
||||||
|
mulld $t3,$a3,$a3 # a[3]*a[3]
|
||||||
|
adde $acc4,$acc4,$acc4
|
||||||
|
mulhdu $a3,$a3,$a3
|
||||||
|
adde $acc5,$acc5,$acc5
|
||||||
|
adde $acc6,$acc6,$acc6
|
||||||
|
addze $acc7,$zero
|
||||||
|
|
||||||
|
addc $acc1,$acc1,$a0 # +a[i]*a[i]
|
||||||
|
li $bi,38
|
||||||
|
adde $acc2,$acc2,$t1
|
||||||
|
adde $acc3,$acc3,$a1
|
||||||
|
adde $acc4,$acc4,$t2
|
||||||
|
adde $acc5,$acc5,$a2
|
||||||
|
adde $acc6,$acc6,$t3
|
||||||
|
adde $acc7,$acc7,$a3
|
||||||
|
|
||||||
|
mulld $t0,$acc4,$bi
|
||||||
|
mulld $t1,$acc5,$bi
|
||||||
|
mulld $t2,$acc6,$bi
|
||||||
|
mulld $t3,$acc7,$bi
|
||||||
|
|
||||||
|
addc $acc0,$acc0,$t0
|
||||||
|
mulhdu $t0,$acc4,$bi
|
||||||
|
adde $acc1,$acc1,$t1
|
||||||
|
mulhdu $t1,$acc5,$bi
|
||||||
|
adde $acc2,$acc2,$t2
|
||||||
|
mulhdu $t2,$acc6,$bi
|
||||||
|
adde $acc3,$acc3,$t3
|
||||||
|
mulhdu $t3,$acc7,$bi
|
||||||
|
addze $acc4,$zero
|
||||||
|
|
||||||
|
addc $acc1,$acc1,$t0
|
||||||
|
adde $acc2,$acc2,$t1
|
||||||
|
adde $acc3,$acc3,$t2
|
||||||
|
adde $acc4,$acc4,$t3
|
||||||
|
|
||||||
|
mulld $acc4,$acc4,$bi
|
||||||
|
|
||||||
|
addc $acc0,$acc0,$acc4
|
||||||
|
addze $acc1,$acc1
|
||||||
|
addze $acc2,$acc2
|
||||||
|
addze $acc3,$acc3
|
||||||
|
|
||||||
|
subfe $acc4,$acc4,$acc4 # carry -> ~mask
|
||||||
|
std $acc1,8($rp)
|
||||||
|
andc $acc4,$bi,$acc4
|
||||||
|
std $acc2,16($rp)
|
||||||
|
add $acc0,$acc0,$acc4
|
||||||
|
std $acc3,24($rp)
|
||||||
|
std $acc0,0($rp)
|
||||||
|
|
||||||
|
ld r22,`$FRAME-8*10`($sp)
|
||||||
|
ld r23,`$FRAME-8*9`($sp)
|
||||||
|
ld r24,`$FRAME-8*8`($sp)
|
||||||
|
ld r25,`$FRAME-8*7`($sp)
|
||||||
|
ld r26,`$FRAME-8*6`($sp)
|
||||||
|
ld r27,`$FRAME-8*5`($sp)
|
||||||
|
ld r28,`$FRAME-8*4`($sp)
|
||||||
|
ld r29,`$FRAME-8*3`($sp)
|
||||||
|
ld r30,`$FRAME-8*2`($sp)
|
||||||
|
ld r31,`$FRAME-8*1`($sp)
|
||||||
|
addi $sp,$sp,$FRAME
|
||||||
|
blr
|
||||||
|
.long 0
|
||||||
|
.byte 0,12,4,0,0x80,10,2,0
|
||||||
|
.long 0
|
||||||
|
.size x25519_fe64_sqr,.-x25519_fe64_sqr
|
||||||
|
|
||||||
|
.globl x25519_fe64_mul121666
|
||||||
|
.type x25519_fe64_mul121666,\@function
|
||||||
|
.align 5
|
||||||
|
x25519_fe64_mul121666:
|
||||||
|
lis $bi,`65536>>16`
|
||||||
|
ori $bi,$bi,`121666-65536`
|
||||||
|
|
||||||
|
ld $t0,0($ap)
|
||||||
|
ld $t1,8($ap)
|
||||||
|
ld $bp,16($ap)
|
||||||
|
ld $ap,24($ap)
|
||||||
|
|
||||||
|
mulld $a0,$t0,$bi
|
||||||
|
mulhdu $t0,$t0,$bi
|
||||||
|
mulld $a1,$t1,$bi
|
||||||
|
mulhdu $t1,$t1,$bi
|
||||||
|
mulld $a2,$bp,$bi
|
||||||
|
mulhdu $bp,$bp,$bi
|
||||||
|
mulld $a3,$ap,$bi
|
||||||
|
mulhdu $ap,$ap,$bi
|
||||||
|
|
||||||
|
addc $a1,$a1,$t0
|
||||||
|
adde $a2,$a2,$t1
|
||||||
|
adde $a3,$a3,$bp
|
||||||
|
addze $ap, $ap
|
||||||
|
|
||||||
|
mulli $ap,$ap,38
|
||||||
|
|
||||||
|
addc $a0,$a0,$ap
|
||||||
|
addze $a1,$a1
|
||||||
|
addze $a2,$a2
|
||||||
|
addze $a3,$a3
|
||||||
|
|
||||||
|
subfe $t1,$t1,$t1 # carry -> ~mask
|
||||||
|
std $a1,8($rp)
|
||||||
|
andc $t0,$t0,$t1
|
||||||
|
std $a2,16($rp)
|
||||||
|
add $a0,$a0,$t0
|
||||||
|
std $a3,24($rp)
|
||||||
|
std $a0,0($rp)
|
||||||
|
|
||||||
|
blr
|
||||||
|
.long 0
|
||||||
|
.byte 0,12,0x14,0,0,0,2,0
|
||||||
|
.long 0
|
||||||
|
.size x25519_fe64_mul121666,.-x25519_fe64_mul121666
|
||||||
|
|
||||||
|
.globl x25519_fe64_add
|
||||||
|
.type x25519_fe64_add,\@function
|
||||||
|
.align 5
|
||||||
|
x25519_fe64_add:
|
||||||
|
ld $a0,0($ap)
|
||||||
|
ld $t0,0($bp)
|
||||||
|
ld $a1,8($ap)
|
||||||
|
ld $t1,8($bp)
|
||||||
|
ld $a2,16($ap)
|
||||||
|
ld $bi,16($bp)
|
||||||
|
ld $a3,24($ap)
|
||||||
|
ld $bp,24($bp)
|
||||||
|
|
||||||
|
addc $a0,$a0,$t0
|
||||||
|
adde $a1,$a1,$t1
|
||||||
|
adde $a2,$a2,$bi
|
||||||
|
adde $a3,$a3,$bp
|
||||||
|
|
||||||
|
li $t0,38
|
||||||
|
subfe $t1,$t1,$t1 # carry -> ~mask
|
||||||
|
andc $t1,$t0,$t1
|
||||||
|
|
||||||
|
addc $a0,$a0,$t1
|
||||||
|
addze $a1,$a1
|
||||||
|
addze $a2,$a2
|
||||||
|
addze $a3,$a3
|
||||||
|
|
||||||
|
subfe $t1,$t1,$t1 # carry -> ~mask
|
||||||
|
std $a1,8($rp)
|
||||||
|
andc $t0,$t0,$t1
|
||||||
|
std $a2,16($rp)
|
||||||
|
add $a0,$a0,$t0
|
||||||
|
std $a3,24($rp)
|
||||||
|
std $a0,0($rp)
|
||||||
|
|
||||||
|
blr
|
||||||
|
.long 0
|
||||||
|
.byte 0,12,0x14,0,0,0,3,0
|
||||||
|
.long 0
|
||||||
|
.size x25519_fe64_add,.-x25519_fe64_add
|
||||||
|
|
||||||
|
.globl x25519_fe64_sub
|
||||||
|
.type x25519_fe64_sub,\@function
|
||||||
|
.align 5
|
||||||
|
x25519_fe64_sub:
|
||||||
|
ld $a0,0($ap)
|
||||||
|
ld $t0,0($bp)
|
||||||
|
ld $a1,8($ap)
|
||||||
|
ld $t1,8($bp)
|
||||||
|
ld $a2,16($ap)
|
||||||
|
ld $bi,16($bp)
|
||||||
|
ld $a3,24($ap)
|
||||||
|
ld $bp,24($bp)
|
||||||
|
|
||||||
|
subfc $a0,$t0,$a0
|
||||||
|
subfe $a1,$t1,$a1
|
||||||
|
subfe $a2,$bi,$a2
|
||||||
|
subfe $a3,$bp,$a3
|
||||||
|
|
||||||
|
li $t0,38
|
||||||
|
subfe $t1,$t1,$t1 # borrow -> mask
|
||||||
|
xor $zero,$zero,$zero
|
||||||
|
and $t1,$t0,$t1
|
||||||
|
|
||||||
|
subfc $a0,$t1,$a0
|
||||||
|
subfe $a1,$zero,$a1
|
||||||
|
subfe $a2,$zero,$a2
|
||||||
|
subfe $a3,$zero,$a3
|
||||||
|
|
||||||
|
subfe $t1,$t1,$t1 # borrow -> mask
|
||||||
|
std $a1,8($rp)
|
||||||
|
and $t0,$t0,$t1
|
||||||
|
std $a2,16($rp)
|
||||||
|
subf $a0,$t0,$a0
|
||||||
|
std $a3,24($rp)
|
||||||
|
std $a0,0($rp)
|
||||||
|
|
||||||
|
blr
|
||||||
|
.long 0
|
||||||
|
.byte 0,12,0x14,0,0,0,3,0
|
||||||
|
.long 0
|
||||||
|
.size x25519_fe64_sub,.-x25519_fe64_sub
|
||||||
|
|
||||||
|
.globl x25519_fe64_tobytes
|
||||||
|
.type x25519_fe64_tobytes,\@function
|
||||||
|
.align 5
|
||||||
|
x25519_fe64_tobytes:
|
||||||
|
ld $a3,24($ap)
|
||||||
|
ld $a0,0($ap)
|
||||||
|
ld $a1,8($ap)
|
||||||
|
ld $a2,16($ap)
|
||||||
|
|
||||||
|
sradi $t0,$a3,63 # most significant bit -> mask
|
||||||
|
li $t1,19
|
||||||
|
and $t0,$t0,$t1
|
||||||
|
sldi $a3,$a3,1
|
||||||
|
add $t0,$t0,$t1 # compare to modulus in the same go
|
||||||
|
srdi $a3,$a3,1 # most signifcant bit cleared
|
||||||
|
|
||||||
|
addc $a0,$a0,$t0
|
||||||
|
addze $a1,$a1
|
||||||
|
addze $a2,$a2
|
||||||
|
addze $a3,$a3
|
||||||
|
|
||||||
|
xor $zero,$zero,$zero
|
||||||
|
sradi $t0,$a3,63 # most significant bit -> mask
|
||||||
|
sldi $a3,$a3,1
|
||||||
|
andc $t0,$t1,$t0
|
||||||
|
srdi $a3,$a3,1 # most signifcant bit cleared
|
||||||
|
|
||||||
|
subi $rp,$rp,1
|
||||||
|
subfc $a0,$t0,$a0
|
||||||
|
subfe $a1,$zero,$a1
|
||||||
|
subfe $a2,$zero,$a2
|
||||||
|
subfe $a3,$zero,$a3
|
||||||
|
|
||||||
|
___
|
||||||
|
for (my @a=($a0,$a1,$a2,$a3), my $i=0; $i<4; shift(@a), $i++) {
|
||||||
|
$code.=<<___;
|
||||||
|
srdi $t0,@a[0],8
|
||||||
|
stbu @a[0],1($rp)
|
||||||
|
srdi @a[0],@a[0],16
|
||||||
|
stbu $t0,1($rp)
|
||||||
|
srdi $t0,@a[0],8
|
||||||
|
stbu @a[0],1($rp)
|
||||||
|
srdi @a[0],@a[0],16
|
||||||
|
stbu $t0,1($rp)
|
||||||
|
srdi $t0,@a[0],8
|
||||||
|
stbu @a[0],1($rp)
|
||||||
|
srdi @a[0],@a[0],16
|
||||||
|
stbu $t0,1($rp)
|
||||||
|
srdi $t0,@a[0],8
|
||||||
|
stbu @a[0],1($rp)
|
||||||
|
stbu $t0,1($rp)
|
||||||
|
___
|
||||||
|
}
|
||||||
|
$code.=<<___;
|
||||||
|
blr
|
||||||
|
.long 0
|
||||||
|
.byte 0,12,0x14,0,0,0,2,0
|
||||||
|
.long 0
|
||||||
|
.size x25519_fe64_tobytes,.-x25519_fe64_tobytes
|
||||||
|
___
|
||||||
|
}
|
||||||
|
####################################################### base 2^51
|
||||||
|
{
|
||||||
|
my ($bi,$a0,$a1,$a2,$a3,$a4,$t0, $t1,
|
||||||
|
$h0lo,$h0hi,$h1lo,$h1hi,$h2lo,$h2hi,$h3lo,$h3hi,$h4lo,$h4hi) =
|
||||||
|
map("r$_",(6..12,21..31));
|
||||||
|
my $mask = "r0";
|
||||||
|
my $FRAME = 18*8;
|
||||||
|
|
||||||
|
$code.=<<___;
|
||||||
|
.text
|
||||||
|
|
||||||
|
.globl x25519_fe51_mul
|
||||||
|
.type x25519_fe51_mul,\@function
|
||||||
|
.align 5
|
||||||
|
x25519_fe51_mul:
|
||||||
|
stdu $sp,-$FRAME($sp)
|
||||||
|
std r21,`$FRAME-8*11`($sp)
|
||||||
|
std r22,`$FRAME-8*10`($sp)
|
||||||
|
std r23,`$FRAME-8*9`($sp)
|
||||||
|
std r24,`$FRAME-8*8`($sp)
|
||||||
|
std r25,`$FRAME-8*7`($sp)
|
||||||
|
std r26,`$FRAME-8*6`($sp)
|
||||||
|
std r27,`$FRAME-8*5`($sp)
|
||||||
|
std r28,`$FRAME-8*4`($sp)
|
||||||
|
std r29,`$FRAME-8*3`($sp)
|
||||||
|
std r30,`$FRAME-8*2`($sp)
|
||||||
|
std r31,`$FRAME-8*1`($sp)
|
||||||
|
|
||||||
|
ld $bi,0($bp)
|
||||||
|
ld $a0,0($ap)
|
||||||
|
ld $a1,8($ap)
|
||||||
|
ld $a2,16($ap)
|
||||||
|
ld $a3,24($ap)
|
||||||
|
ld $a4,32($ap)
|
||||||
|
|
||||||
|
mulld $h0lo,$a0,$bi # a[0]*b[0]
|
||||||
|
mulhdu $h0hi,$a0,$bi
|
||||||
|
|
||||||
|
mulld $h1lo,$a1,$bi # a[1]*b[0]
|
||||||
|
mulhdu $h1hi,$a1,$bi
|
||||||
|
|
||||||
|
mulld $h4lo,$a4,$bi # a[4]*b[0]
|
||||||
|
mulhdu $h4hi,$a4,$bi
|
||||||
|
ld $ap,8($bp)
|
||||||
|
mulli $a4,$a4,19
|
||||||
|
|
||||||
|
mulld $h2lo,$a2,$bi # a[2]*b[0]
|
||||||
|
mulhdu $h2hi,$a2,$bi
|
||||||
|
|
||||||
|
mulld $h3lo,$a3,$bi # a[3]*b[0]
|
||||||
|
mulhdu $h3hi,$a3,$bi
|
||||||
|
___
|
||||||
|
for(my @a=($a0,$a1,$a2,$a3,$a4),
|
||||||
|
my $i=1; $i<4; $i++) {
|
||||||
|
($ap,$bi) = ($bi,$ap);
|
||||||
|
$code.=<<___;
|
||||||
|
mulld $t0,@a[4],$bi
|
||||||
|
mulhdu $t1,@a[4],$bi
|
||||||
|
addc $h0lo,$h0lo,$t0
|
||||||
|
adde $h0hi,$h0hi,$t1
|
||||||
|
|
||||||
|
mulld $t0,@a[0],$bi
|
||||||
|
mulhdu $t1,@a[0],$bi
|
||||||
|
addc $h1lo,$h1lo,$t0
|
||||||
|
adde $h1hi,$h1hi,$t1
|
||||||
|
|
||||||
|
mulld $t0,@a[3],$bi
|
||||||
|
mulhdu $t1,@a[3],$bi
|
||||||
|
ld $ap,`8*($i+1)`($bp)
|
||||||
|
mulli @a[3],@a[3],19
|
||||||
|
addc $h4lo,$h4lo,$t0
|
||||||
|
adde $h4hi,$h4hi,$t1
|
||||||
|
|
||||||
|
mulld $t0,@a[1],$bi
|
||||||
|
mulhdu $t1,@a[1],$bi
|
||||||
|
addc $h2lo,$h2lo,$t0
|
||||||
|
adde $h2hi,$h2hi,$t1
|
||||||
|
|
||||||
|
mulld $t0,@a[2],$bi
|
||||||
|
mulhdu $t1,@a[2],$bi
|
||||||
|
addc $h3lo,$h3lo,$t0
|
||||||
|
adde $h3hi,$h3hi,$t1
|
||||||
|
___
|
||||||
|
unshift(@a,pop(@a));
|
||||||
|
}
|
||||||
|
($ap,$bi) = ($bi,$ap);
|
||||||
|
$code.=<<___;
|
||||||
|
mulld $t0,$a1,$bi
|
||||||
|
mulhdu $t1,$a1,$bi
|
||||||
|
addc $h0lo,$h0lo,$t0
|
||||||
|
adde $h0hi,$h0hi,$t1
|
||||||
|
|
||||||
|
mulld $t0,$a2,$bi
|
||||||
|
mulhdu $t1,$a2,$bi
|
||||||
|
addc $h1lo,$h1lo,$t0
|
||||||
|
adde $h1hi,$h1hi,$t1
|
||||||
|
|
||||||
|
mulld $t0,$a3,$bi
|
||||||
|
mulhdu $t1,$a3,$bi
|
||||||
|
addc $h2lo,$h2lo,$t0
|
||||||
|
adde $h2hi,$h2hi,$t1
|
||||||
|
|
||||||
|
mulld $t0,$a4,$bi
|
||||||
|
mulhdu $t1,$a4,$bi
|
||||||
|
addc $h3lo,$h3lo,$t0
|
||||||
|
adde $h3hi,$h3hi,$t1
|
||||||
|
|
||||||
|
mulld $t0,$a0,$bi
|
||||||
|
mulhdu $t1,$a0,$bi
|
||||||
|
addc $h4lo,$h4lo,$t0
|
||||||
|
adde $h4hi,$h4hi,$t1
|
||||||
|
|
||||||
|
.Lfe51_reduce:
|
||||||
|
li $mask,-1
|
||||||
|
srdi $mask,$mask,13 # 0x7ffffffffffff
|
||||||
|
|
||||||
|
srdi $t0,$h2lo,51
|
||||||
|
and $a2,$h2lo,$mask
|
||||||
|
insrdi $t0,$h2hi,51,0 # h2>>51
|
||||||
|
srdi $t1,$h0lo,51
|
||||||
|
and $a0,$h0lo,$mask
|
||||||
|
insrdi $t1,$h0hi,51,0 # h0>>51
|
||||||
|
addc $h3lo,$h3lo,$t0
|
||||||
|
addze $h3hi,$h3hi
|
||||||
|
addc $h1lo,$h1lo,$t1
|
||||||
|
addze $h1hi,$h1hi
|
||||||
|
|
||||||
|
srdi $t0,$h3lo,51
|
||||||
|
and $a3,$h3lo,$mask
|
||||||
|
insrdi $t0,$h3hi,51,0 # h3>>51
|
||||||
|
srdi $t1,$h1lo,51
|
||||||
|
and $a1,$h1lo,$mask
|
||||||
|
insrdi $t1,$h1hi,51,0 # h1>>51
|
||||||
|
addc $h4lo,$h4lo,$t0
|
||||||
|
addze $h4hi,$h4hi
|
||||||
|
add $a2,$a2,$t1
|
||||||
|
|
||||||
|
srdi $t0,$h4lo,51
|
||||||
|
and $a4,$h4lo,$mask
|
||||||
|
insrdi $t0,$h4hi,51,0
|
||||||
|
mulli $t0,$t0,19 # (h4 >> 51) * 19
|
||||||
|
|
||||||
|
add $a0,$a0,$t0
|
||||||
|
|
||||||
|
srdi $t1,$a2,51
|
||||||
|
and $a2,$a2,$mask
|
||||||
|
add $a3,$a3,$t1
|
||||||
|
|
||||||
|
srdi $t0,$a0,51
|
||||||
|
and $a0,$a0,$mask
|
||||||
|
add $a1,$a1,$t0
|
||||||
|
|
||||||
|
std $a2,16($rp)
|
||||||
|
std $a3,24($rp)
|
||||||
|
std $a4,32($rp)
|
||||||
|
std $a0,0($rp)
|
||||||
|
std $a1,8($rp)
|
||||||
|
|
||||||
|
ld r21,`$FRAME-8*11`($sp)
|
||||||
|
ld r22,`$FRAME-8*10`($sp)
|
||||||
|
ld r23,`$FRAME-8*9`($sp)
|
||||||
|
ld r24,`$FRAME-8*8`($sp)
|
||||||
|
ld r25,`$FRAME-8*7`($sp)
|
||||||
|
ld r26,`$FRAME-8*6`($sp)
|
||||||
|
ld r27,`$FRAME-8*5`($sp)
|
||||||
|
ld r28,`$FRAME-8*4`($sp)
|
||||||
|
ld r29,`$FRAME-8*3`($sp)
|
||||||
|
ld r30,`$FRAME-8*2`($sp)
|
||||||
|
ld r31,`$FRAME-8*1`($sp)
|
||||||
|
addi $sp,$sp,$FRAME
|
||||||
|
blr
|
||||||
|
.long 0
|
||||||
|
.byte 0,12,4,0,0x80,11,3,0
|
||||||
|
.long 0
|
||||||
|
.size x25519_fe51_mul,.-x25519_fe51_mul
|
||||||
|
___
|
||||||
|
{
|
||||||
|
my ($a0,$a1,$a2,$a3,$a4,$t0,$t1) = ($a0,$a1,$a2,$a3,$a4,$t0,$t1);
|
||||||
|
$code.=<<___;
|
||||||
|
.globl x25519_fe51_sqr
|
||||||
|
.type x25519_fe51_sqr,\@function
|
||||||
|
.align 5
|
||||||
|
x25519_fe51_sqr:
|
||||||
|
stdu $sp,-$FRAME($sp)
|
||||||
|
std r21,`$FRAME-8*11`($sp)
|
||||||
|
std r22,`$FRAME-8*10`($sp)
|
||||||
|
std r23,`$FRAME-8*9`($sp)
|
||||||
|
std r24,`$FRAME-8*8`($sp)
|
||||||
|
std r25,`$FRAME-8*7`($sp)
|
||||||
|
std r26,`$FRAME-8*6`($sp)
|
||||||
|
std r27,`$FRAME-8*5`($sp)
|
||||||
|
std r28,`$FRAME-8*4`($sp)
|
||||||
|
std r29,`$FRAME-8*3`($sp)
|
||||||
|
std r30,`$FRAME-8*2`($sp)
|
||||||
|
std r31,`$FRAME-8*1`($sp)
|
||||||
|
|
||||||
|
ld $a0,0($ap)
|
||||||
|
ld $a1,8($ap)
|
||||||
|
ld $a2,16($ap)
|
||||||
|
ld $a3,24($ap)
|
||||||
|
ld $a4,32($ap)
|
||||||
|
|
||||||
|
add $bi,$a0,$a0 # a[0]*2
|
||||||
|
mulli $t1,$a4,19 # a[4]*19
|
||||||
|
|
||||||
|
mulld $h0lo,$a0,$a0
|
||||||
|
mulhdu $h0hi,$a0,$a0
|
||||||
|
mulld $h1lo,$a1,$bi
|
||||||
|
mulhdu $h1hi,$a1,$bi
|
||||||
|
mulld $h2lo,$a2,$bi
|
||||||
|
mulhdu $h2hi,$a2,$bi
|
||||||
|
mulld $h3lo,$a3,$bi
|
||||||
|
mulhdu $h3hi,$a3,$bi
|
||||||
|
mulld $h4lo,$a4,$bi
|
||||||
|
mulhdu $h4hi,$a4,$bi
|
||||||
|
add $bi,$a1,$a1 # a[1]*2
|
||||||
|
___
|
||||||
|
($a4,$t1) = ($t1,$a4);
|
||||||
|
$code.=<<___;
|
||||||
|
mulld $t0,$t1,$a4
|
||||||
|
mulhdu $t1,$t1,$a4
|
||||||
|
addc $h3lo,$h3lo,$t0
|
||||||
|
adde $h3hi,$h3hi,$t1
|
||||||
|
|
||||||
|
mulli $bp,$a3,19 # a[3]*19
|
||||||
|
|
||||||
|
mulld $t0,$a1,$a1
|
||||||
|
mulhdu $t1,$a1,$a1
|
||||||
|
addc $h2lo,$h2lo,$t0
|
||||||
|
adde $h2hi,$h2hi,$t1
|
||||||
|
mulld $t0,$a2,$bi
|
||||||
|
mulhdu $t1,$a2,$bi
|
||||||
|
addc $h3lo,$h3lo,$t0
|
||||||
|
adde $h3hi,$h3hi,$t1
|
||||||
|
mulld $t0,$a3,$bi
|
||||||
|
mulhdu $t1,$a3,$bi
|
||||||
|
addc $h4lo,$h4lo,$t0
|
||||||
|
adde $h4hi,$h4hi,$t1
|
||||||
|
mulld $t0,$a4,$bi
|
||||||
|
mulhdu $t1,$a4,$bi
|
||||||
|
add $bi,$a3,$a3 # a[3]*2
|
||||||
|
addc $h0lo,$h0lo,$t0
|
||||||
|
adde $h0hi,$h0hi,$t1
|
||||||
|
___
|
||||||
|
($a3,$t1) = ($bp,$a3);
|
||||||
|
$code.=<<___;
|
||||||
|
mulld $t0,$t1,$a3
|
||||||
|
mulhdu $t1,$t1,$a3
|
||||||
|
addc $h1lo,$h1lo,$t0
|
||||||
|
adde $h1hi,$h1hi,$t1
|
||||||
|
mulld $t0,$bi,$a4
|
||||||
|
mulhdu $t1,$bi,$a4
|
||||||
|
add $bi,$a2,$a2 # a[2]*2
|
||||||
|
addc $h2lo,$h2lo,$t0
|
||||||
|
adde $h2hi,$h2hi,$t1
|
||||||
|
|
||||||
|
mulld $t0,$a2,$a2
|
||||||
|
mulhdu $t1,$a2,$a2
|
||||||
|
addc $h4lo,$h4lo,$t0
|
||||||
|
adde $h4hi,$h4hi,$t1
|
||||||
|
mulld $t0,$a3,$bi
|
||||||
|
mulhdu $t1,$a3,$bi
|
||||||
|
addc $h0lo,$h0lo,$t0
|
||||||
|
adde $h0hi,$h0hi,$t1
|
||||||
|
mulld $t0,$a4,$bi
|
||||||
|
mulhdu $t1,$a4,$bi
|
||||||
|
addc $h1lo,$h1lo,$t0
|
||||||
|
adde $h1hi,$h1hi,$t1
|
||||||
|
|
||||||
|
b .Lfe51_reduce
|
||||||
|
.long 0
|
||||||
|
.byte 0,12,4,0,0x80,11,2,0
|
||||||
|
.long 0
|
||||||
|
.size x25519_fe51_sqr,.-x25519_fe51_sqr
|
||||||
|
___
|
||||||
|
}
|
||||||
|
$code.=<<___;
|
||||||
|
.globl x25519_fe51_mul121666
|
||||||
|
.type x25519_fe51_mul121666,\@function
|
||||||
|
.align 5
|
||||||
|
x25519_fe51_mul121666:
|
||||||
|
stdu $sp,-$FRAME($sp)
|
||||||
|
std r21,`$FRAME-8*11`($sp)
|
||||||
|
std r22,`$FRAME-8*10`($sp)
|
||||||
|
std r23,`$FRAME-8*9`($sp)
|
||||||
|
std r24,`$FRAME-8*8`($sp)
|
||||||
|
std r25,`$FRAME-8*7`($sp)
|
||||||
|
std r26,`$FRAME-8*6`($sp)
|
||||||
|
std r27,`$FRAME-8*5`($sp)
|
||||||
|
std r28,`$FRAME-8*4`($sp)
|
||||||
|
std r29,`$FRAME-8*3`($sp)
|
||||||
|
std r30,`$FRAME-8*2`($sp)
|
||||||
|
std r31,`$FRAME-8*1`($sp)
|
||||||
|
|
||||||
|
lis $bi,`65536>>16`
|
||||||
|
ori $bi,$bi,`121666-65536`
|
||||||
|
ld $a0,0($ap)
|
||||||
|
ld $a1,8($ap)
|
||||||
|
ld $a2,16($ap)
|
||||||
|
ld $a3,24($ap)
|
||||||
|
ld $a4,32($ap)
|
||||||
|
|
||||||
|
mulld $h0lo,$a0,$bi # a[0]*121666
|
||||||
|
mulhdu $h0hi,$a0,$bi
|
||||||
|
mulld $h1lo,$a1,$bi # a[1]*121666
|
||||||
|
mulhdu $h1hi,$a1,$bi
|
||||||
|
mulld $h2lo,$a2,$bi # a[2]*121666
|
||||||
|
mulhdu $h2hi,$a2,$bi
|
||||||
|
mulld $h3lo,$a3,$bi # a[3]*121666
|
||||||
|
mulhdu $h3hi,$a3,$bi
|
||||||
|
mulld $h4lo,$a4,$bi # a[4]*121666
|
||||||
|
mulhdu $h4hi,$a4,$bi
|
||||||
|
|
||||||
|
b .Lfe51_reduce
|
||||||
|
.long 0
|
||||||
|
.byte 0,12,4,0,0x80,11,2,0
|
||||||
|
.long 0
|
||||||
|
.size x25519_fe51_mul121666,.-x25519_fe51_mul121666
|
||||||
|
___
|
||||||
|
}
|
||||||
|
|
||||||
|
$code =~ s/\`([^\`]*)\`/eval $1/gem;
|
||||||
|
print $code;
|
||||||
|
close STDOUT;
|
||||||
@@ -27,6 +27,7 @@ INCLUDE[ecp_nistz256-armv8.o]=..
|
|||||||
GENERATE[ecp_nistz256-ppc64.s]=asm/ecp_nistz256-ppc64.pl $(PERLASM_SCHEME)
|
GENERATE[ecp_nistz256-ppc64.s]=asm/ecp_nistz256-ppc64.pl $(PERLASM_SCHEME)
|
||||||
|
|
||||||
GENERATE[x25519-x86_64.s]=asm/x25519-x86_64.pl $(PERLASM_SCHEME)
|
GENERATE[x25519-x86_64.s]=asm/x25519-x86_64.pl $(PERLASM_SCHEME)
|
||||||
|
GENERATE[x25519-ppc64.s]=asm/x25519-ppc64.pl $(PERLASM_SCHEME)
|
||||||
|
|
||||||
BEGINRAW[Makefile]
|
BEGINRAW[Makefile]
|
||||||
{- $builddir -}/ecp_nistz256-%.S: {- $sourcedir -}/asm/ecp_nistz256-%.pl
|
{- $builddir -}/ecp_nistz256-%.S: {- $sourcedir -}/asm/ecp_nistz256-%.pl
|
||||||
|
|||||||
+5
-6
@@ -94,7 +94,7 @@ int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EC_POINT_set_affine_coordinates_GF2m(group, point, x, y, ctx))
|
if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
@@ -166,7 +166,7 @@ size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point,
|
|||||||
if (yxi == NULL)
|
if (yxi == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx))
|
if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
buf[0] = form;
|
buf[0] = form;
|
||||||
@@ -301,8 +301,7 @@ int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (form == POINT_CONVERSION_COMPRESSED) {
|
if (form == POINT_CONVERSION_COMPRESSED) {
|
||||||
if (!EC_POINT_set_compressed_coordinates_GF2m
|
if (!EC_POINT_set_compressed_coordinates(group, point, x, y_bit, ctx))
|
||||||
(group, point, x, y_bit, ctx))
|
|
||||||
goto err;
|
goto err;
|
||||||
} else {
|
} else {
|
||||||
if (!BN_bin2bn(buf + 1 + field_len, field_len, y))
|
if (!BN_bin2bn(buf + 1 + field_len, field_len, y))
|
||||||
@@ -321,10 +320,10 @@ int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* EC_POINT_set_affine_coordinates_GF2m is responsible for checking that
|
* EC_POINT_set_affine_coordinates is responsible for checking that
|
||||||
* the point is on the curve.
|
* the point is on the curve.
|
||||||
*/
|
*/
|
||||||
if (!EC_POINT_set_affine_coordinates_GF2m(group, point, x, y, ctx))
|
if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx))
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
|
|||||||
if (!BN_copy(y0, a->Y))
|
if (!BN_copy(y0, a->Y))
|
||||||
goto err;
|
goto err;
|
||||||
} else {
|
} else {
|
||||||
if (!EC_POINT_get_affine_coordinates_GF2m(group, a, x0, y0, ctx))
|
if (!EC_POINT_get_affine_coordinates(group, a, x0, y0, ctx))
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
if (b->Z_is_one) {
|
if (b->Z_is_one) {
|
||||||
@@ -399,7 +399,7 @@ int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
|
|||||||
if (!BN_copy(y1, b->Y))
|
if (!BN_copy(y1, b->Y))
|
||||||
goto err;
|
goto err;
|
||||||
} else {
|
} else {
|
||||||
if (!EC_POINT_get_affine_coordinates_GF2m(group, b, x1, y1, ctx))
|
if (!EC_POINT_get_affine_coordinates(group, b, x1, y1, ctx))
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,7 +447,7 @@ int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
|
|||||||
if (!BN_GF2m_add(y2, y2, y1))
|
if (!BN_GF2m_add(y2, y2, y1))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (!EC_POINT_set_affine_coordinates_GF2m(group, r, x2, y2, ctx))
|
if (!EC_POINT_set_affine_coordinates(group, r, x2, y2, ctx))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
@@ -590,9 +590,9 @@ int ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a,
|
|||||||
if (bY == NULL)
|
if (bY == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (!EC_POINT_get_affine_coordinates_GF2m(group, a, aX, aY, ctx))
|
if (!EC_POINT_get_affine_coordinates(group, a, aX, aY, ctx))
|
||||||
goto err;
|
goto err;
|
||||||
if (!EC_POINT_get_affine_coordinates_GF2m(group, b, bX, bY, ctx))
|
if (!EC_POINT_get_affine_coordinates(group, b, bX, bY, ctx))
|
||||||
goto err;
|
goto err;
|
||||||
ret = ((BN_cmp(aX, bX) == 0) && BN_cmp(aY, bY) == 0) ? 0 : 1;
|
ret = ((BN_cmp(aX, bX) == 0) && BN_cmp(aY, bY) == 0) ? 0 : 1;
|
||||||
|
|
||||||
@@ -625,7 +625,7 @@ int ec_GF2m_simple_make_affine(const EC_GROUP *group, EC_POINT *point,
|
|||||||
if (y == NULL)
|
if (y == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx))
|
if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx))
|
||||||
goto err;
|
goto err;
|
||||||
if (!BN_copy(point->X, x))
|
if (!BN_copy(point->X, x))
|
||||||
goto err;
|
goto err;
|
||||||
|
|||||||
@@ -92,19 +92,19 @@ static int eckey_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
|
|||||||
static EC_KEY *eckey_type2param(int ptype, const void *pval)
|
static EC_KEY *eckey_type2param(int ptype, const void *pval)
|
||||||
{
|
{
|
||||||
EC_KEY *eckey = NULL;
|
EC_KEY *eckey = NULL;
|
||||||
|
EC_GROUP *group = NULL;
|
||||||
|
|
||||||
if (ptype == V_ASN1_SEQUENCE) {
|
if (ptype == V_ASN1_SEQUENCE) {
|
||||||
const ASN1_STRING *pstr = pval;
|
const ASN1_STRING *pstr = pval;
|
||||||
const unsigned char *pm = NULL;
|
const unsigned char *pm = pstr->data;
|
||||||
int pmlen;
|
int pmlen = pstr->length;
|
||||||
pm = pstr->data;
|
|
||||||
pmlen = pstr->length;
|
|
||||||
if ((eckey = d2i_ECParameters(NULL, &pm, pmlen)) == NULL) {
|
if ((eckey = d2i_ECParameters(NULL, &pm, pmlen)) == NULL) {
|
||||||
ECerr(EC_F_ECKEY_TYPE2PARAM, EC_R_DECODE_ERROR);
|
ECerr(EC_F_ECKEY_TYPE2PARAM, EC_R_DECODE_ERROR);
|
||||||
goto ecerr;
|
goto ecerr;
|
||||||
}
|
}
|
||||||
} else if (ptype == V_ASN1_OBJECT) {
|
} else if (ptype == V_ASN1_OBJECT) {
|
||||||
const ASN1_OBJECT *poid = pval;
|
const ASN1_OBJECT *poid = pval;
|
||||||
EC_GROUP *group;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* type == V_ASN1_OBJECT => the parameters are given by an asn1 OID
|
* type == V_ASN1_OBJECT => the parameters are given by an asn1 OID
|
||||||
@@ -129,6 +129,7 @@ static EC_KEY *eckey_type2param(int ptype, const void *pval)
|
|||||||
|
|
||||||
ecerr:
|
ecerr:
|
||||||
EC_KEY_free(eckey);
|
EC_KEY_free(eckey);
|
||||||
|
EC_GROUP_free(group);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-15
@@ -266,7 +266,7 @@ static int ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
/* the parameters are specified by the prime number p */
|
/* the parameters are specified by the prime number p */
|
||||||
if (!EC_GROUP_get_curve_GFp(group, tmp, NULL, NULL, NULL)) {
|
if (!EC_GROUP_get_curve(group, tmp, NULL, NULL, NULL)) {
|
||||||
ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_EC_LIB);
|
ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_EC_LIB);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -365,7 +365,7 @@ static int ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field)
|
|||||||
|
|
||||||
static int ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve)
|
static int ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve)
|
||||||
{
|
{
|
||||||
int ok = 0, nid;
|
int ok = 0;
|
||||||
BIGNUM *tmp_1 = NULL, *tmp_2 = NULL;
|
BIGNUM *tmp_1 = NULL, *tmp_2 = NULL;
|
||||||
unsigned char *a_buf = NULL, *b_buf = NULL;
|
unsigned char *a_buf = NULL, *b_buf = NULL;
|
||||||
size_t len;
|
size_t len;
|
||||||
@@ -378,24 +378,12 @@ static int ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
nid = EC_METHOD_get_field_type(EC_GROUP_method_of(group));
|
|
||||||
|
|
||||||
/* get a and b */
|
/* get a and b */
|
||||||
if (nid == NID_X9_62_prime_field) {
|
if (!EC_GROUP_get_curve(group, NULL, tmp_1, tmp_2, NULL)) {
|
||||||
if (!EC_GROUP_get_curve_GFp(group, NULL, tmp_1, tmp_2, NULL)) {
|
|
||||||
ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_EC_LIB);
|
ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_EC_LIB);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#ifndef OPENSSL_NO_EC2M
|
|
||||||
else { /* nid == NID_X9_62_characteristic_two_field */
|
|
||||||
|
|
||||||
if (!EC_GROUP_get_curve_GF2m(group, NULL, tmp_1, tmp_2, NULL)) {
|
|
||||||
ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_EC_LIB);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/*
|
/*
|
||||||
* Per SEC 1, the curve coefficients must be padded up to size. See C.2's
|
* Per SEC 1, the curve coefficients must be padded up to size. See C.2's
|
||||||
* definition of Curve, C.1's definition of FieldElement, and 2.3.5's
|
* definition of Curve, C.1's definition of FieldElement, and 2.3.5's
|
||||||
|
|||||||
@@ -3078,7 +3078,7 @@ static EC_GROUP *ec_group_new_from_data(const ec_list_element curve)
|
|||||||
ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB);
|
ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
if (!EC_POINT_set_affine_coordinates_GFp(group, P, x, y, ctx)) {
|
if (!EC_POINT_set_affine_coordinates(group, P, x, y, ctx)) {
|
||||||
ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB);
|
ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -51,7 +51,7 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a,
|
|||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!EC_GROUP_set_curve_GFp(ret, p, a, b, ctx)) {
|
if (!EC_GROUP_set_curve(ret, p, a, b, ctx)) {
|
||||||
EC_GROUP_clear_free(ret);
|
EC_GROUP_clear_free(ret);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a,
|
|||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!EC_GROUP_set_curve_GF2m(ret, p, a, b, ctx)) {
|
if (!EC_GROUP_set_curve(ret, p, a, b, ctx)) {
|
||||||
EC_GROUP_clear_free(ret);
|
EC_GROUP_clear_free(ret);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ static const ERR_STRING_DATA EC_str_functs[] = {
|
|||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_GROUP_CHECK_DISCRIMINANT, 0),
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_GROUP_CHECK_DISCRIMINANT, 0),
|
||||||
"EC_GROUP_check_discriminant"},
|
"EC_GROUP_check_discriminant"},
|
||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_GROUP_COPY, 0), "EC_GROUP_copy"},
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_GROUP_COPY, 0), "EC_GROUP_copy"},
|
||||||
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_GROUP_GET_CURVE, 0), "EC_GROUP_get_curve"},
|
||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_GROUP_GET_CURVE_GF2M, 0),
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_GROUP_GET_CURVE_GF2M, 0),
|
||||||
"EC_GROUP_get_curve_GF2m"},
|
"EC_GROUP_get_curve_GF2m"},
|
||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_GROUP_GET_CURVE_GFP, 0),
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_GROUP_GET_CURVE_GFP, 0),
|
||||||
@@ -168,6 +169,7 @@ static const ERR_STRING_DATA EC_str_functs[] = {
|
|||||||
"EC_GROUP_new_from_ecparameters"},
|
"EC_GROUP_new_from_ecparameters"},
|
||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS, 0),
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS, 0),
|
||||||
"EC_GROUP_new_from_ecpkparameters"},
|
"EC_GROUP_new_from_ecpkparameters"},
|
||||||
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_GROUP_SET_CURVE, 0), "EC_GROUP_set_curve"},
|
||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_GROUP_SET_CURVE_GF2M, 0),
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_GROUP_SET_CURVE_GF2M, 0),
|
||||||
"EC_GROUP_set_curve_GF2m"},
|
"EC_GROUP_set_curve_GF2m"},
|
||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_GROUP_SET_CURVE_GFP, 0),
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_GROUP_SET_CURVE_GFP, 0),
|
||||||
@@ -203,6 +205,8 @@ static const ERR_STRING_DATA EC_str_functs[] = {
|
|||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_CMP, 0), "EC_POINT_cmp"},
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_CMP, 0), "EC_POINT_cmp"},
|
||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_COPY, 0), "EC_POINT_copy"},
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_COPY, 0), "EC_POINT_copy"},
|
||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_DBL, 0), "EC_POINT_dbl"},
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_DBL, 0), "EC_POINT_dbl"},
|
||||||
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_GET_AFFINE_COORDINATES, 0),
|
||||||
|
"EC_POINT_get_affine_coordinates"},
|
||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M, 0),
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M, 0),
|
||||||
"EC_POINT_get_affine_coordinates_GF2m"},
|
"EC_POINT_get_affine_coordinates_GF2m"},
|
||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP, 0),
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP, 0),
|
||||||
@@ -220,10 +224,14 @@ static const ERR_STRING_DATA EC_str_functs[] = {
|
|||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_OCT2POINT, 0), "EC_POINT_oct2point"},
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_OCT2POINT, 0), "EC_POINT_oct2point"},
|
||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_POINT2BUF, 0), "EC_POINT_point2buf"},
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_POINT2BUF, 0), "EC_POINT_point2buf"},
|
||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_POINT2OCT, 0), "EC_POINT_point2oct"},
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_POINT2OCT, 0), "EC_POINT_point2oct"},
|
||||||
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_SET_AFFINE_COORDINATES, 0),
|
||||||
|
"EC_POINT_set_affine_coordinates"},
|
||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M, 0),
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M, 0),
|
||||||
"EC_POINT_set_affine_coordinates_GF2m"},
|
"EC_POINT_set_affine_coordinates_GF2m"},
|
||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP, 0),
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP, 0),
|
||||||
"EC_POINT_set_affine_coordinates_GFp"},
|
"EC_POINT_set_affine_coordinates_GFp"},
|
||||||
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_SET_COMPRESSED_COORDINATES, 0),
|
||||||
|
"EC_POINT_set_compressed_coordinates"},
|
||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M, 0),
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M, 0),
|
||||||
"EC_POINT_set_compressed_coordinates_GF2m"},
|
"EC_POINT_set_compressed_coordinates_GF2m"},
|
||||||
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP, 0),
|
{ERR_PACK(ERR_LIB_EC, EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP, 0),
|
||||||
|
|||||||
+4
-25
@@ -341,9 +341,6 @@ int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x,
|
|||||||
BIGNUM *tx, *ty;
|
BIGNUM *tx, *ty;
|
||||||
EC_POINT *point = NULL;
|
EC_POINT *point = NULL;
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
#ifndef OPENSSL_NO_EC2M
|
|
||||||
int tmp_nid, is_char_two = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (key == NULL || key->group == NULL || x == NULL || y == NULL) {
|
if (key == NULL || key->group == NULL || x == NULL || y == NULL) {
|
||||||
ECerr(EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES,
|
ECerr(EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES,
|
||||||
@@ -365,29 +362,11 @@ int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x,
|
|||||||
if (ty == NULL)
|
if (ty == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_EC2M
|
if (!EC_POINT_set_affine_coordinates(key->group, point, x, y, ctx))
|
||||||
tmp_nid = EC_METHOD_get_field_type(EC_GROUP_method_of(key->group));
|
goto err;
|
||||||
|
if (!EC_POINT_get_affine_coordinates(key->group, point, tx, ty, ctx))
|
||||||
|
goto err;
|
||||||
|
|
||||||
if (tmp_nid == NID_X9_62_characteristic_two_field)
|
|
||||||
is_char_two = 1;
|
|
||||||
|
|
||||||
if (is_char_two) {
|
|
||||||
if (!EC_POINT_set_affine_coordinates_GF2m(key->group, point,
|
|
||||||
x, y, ctx))
|
|
||||||
goto err;
|
|
||||||
if (!EC_POINT_get_affine_coordinates_GF2m(key->group, point,
|
|
||||||
tx, ty, ctx))
|
|
||||||
goto err;
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
if (!EC_POINT_set_affine_coordinates_GFp(key->group, point,
|
|
||||||
x, y, ctx))
|
|
||||||
goto err;
|
|
||||||
if (!EC_POINT_get_affine_coordinates_GFp(key->group, point,
|
|
||||||
tx, ty, ctx))
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Check if retrieved coordinates match originals and are less than field
|
* Check if retrieved coordinates match originals and are less than field
|
||||||
* order: if not values are out of range.
|
* order: if not values are out of range.
|
||||||
|
|||||||
+16
-10
@@ -50,8 +50,7 @@ struct ec_method_st {
|
|||||||
void (*group_finish) (EC_GROUP *);
|
void (*group_finish) (EC_GROUP *);
|
||||||
void (*group_clear_finish) (EC_GROUP *);
|
void (*group_clear_finish) (EC_GROUP *);
|
||||||
int (*group_copy) (EC_GROUP *, const EC_GROUP *);
|
int (*group_copy) (EC_GROUP *, const EC_GROUP *);
|
||||||
/* used by EC_GROUP_set_curve_GFp, EC_GROUP_get_curve_GFp, */
|
/* used by EC_GROUP_set_curve, EC_GROUP_get_curve: */
|
||||||
/* EC_GROUP_set_curve_GF2m, and EC_GROUP_get_curve_GF2m: */
|
|
||||||
int (*group_set_curve) (EC_GROUP *, const BIGNUM *p, const BIGNUM *a,
|
int (*group_set_curve) (EC_GROUP *, const BIGNUM *p, const BIGNUM *a,
|
||||||
const BIGNUM *b, BN_CTX *);
|
const BIGNUM *b, BN_CTX *);
|
||||||
int (*group_get_curve) (const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b,
|
int (*group_get_curve) (const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b,
|
||||||
@@ -73,9 +72,9 @@ struct ec_method_st {
|
|||||||
* used by EC_POINT_set_to_infinity,
|
* used by EC_POINT_set_to_infinity,
|
||||||
* EC_POINT_set_Jprojective_coordinates_GFp,
|
* EC_POINT_set_Jprojective_coordinates_GFp,
|
||||||
* EC_POINT_get_Jprojective_coordinates_GFp,
|
* EC_POINT_get_Jprojective_coordinates_GFp,
|
||||||
* EC_POINT_set_affine_coordinates_GFp, ..._GF2m,
|
* EC_POINT_set_affine_coordinates,
|
||||||
* EC_POINT_get_affine_coordinates_GFp, ..._GF2m,
|
* EC_POINT_get_affine_coordinates,
|
||||||
* EC_POINT_set_compressed_coordinates_GFp, ..._GF2m:
|
* EC_POINT_set_compressed_coordinates:
|
||||||
*/
|
*/
|
||||||
int (*point_set_to_infinity) (const EC_GROUP *, EC_POINT *);
|
int (*point_set_to_infinity) (const EC_GROUP *, EC_POINT *);
|
||||||
int (*point_set_Jprojective_coordinates_GFp) (const EC_GROUP *,
|
int (*point_set_Jprojective_coordinates_GFp) (const EC_GROUP *,
|
||||||
@@ -301,7 +300,6 @@ struct ec_point_st {
|
|||||||
* special case */
|
* special case */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static ossl_inline int ec_point_is_compat(const EC_POINT *point,
|
static ossl_inline int ec_point_is_compat(const EC_POINT *point,
|
||||||
const EC_GROUP *group)
|
const EC_GROUP *group)
|
||||||
{
|
{
|
||||||
@@ -314,7 +312,6 @@ static ossl_inline int ec_point_is_compat(const EC_POINT *point,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NISTP224_PRE_COMP *EC_nistp224_pre_comp_dup(NISTP224_PRE_COMP *);
|
NISTP224_PRE_COMP *EC_nistp224_pre_comp_dup(NISTP224_PRE_COMP *);
|
||||||
NISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *);
|
NISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *);
|
||||||
NISTP521_PRE_COMP *EC_nistp521_pre_comp_dup(NISTP521_PRE_COMP *);
|
NISTP521_PRE_COMP *EC_nistp521_pre_comp_dup(NISTP521_PRE_COMP *);
|
||||||
@@ -395,6 +392,15 @@ int ec_GFp_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
|
|||||||
BN_CTX *);
|
BN_CTX *);
|
||||||
int ec_GFp_simple_blind_coordinates(const EC_GROUP *group, EC_POINT *p,
|
int ec_GFp_simple_blind_coordinates(const EC_GROUP *group, EC_POINT *p,
|
||||||
BN_CTX *ctx);
|
BN_CTX *ctx);
|
||||||
|
int ec_GFp_simple_ladder_pre(const EC_GROUP *group,
|
||||||
|
EC_POINT *r, EC_POINT *s,
|
||||||
|
EC_POINT *p, BN_CTX *ctx);
|
||||||
|
int ec_GFp_simple_ladder_step(const EC_GROUP *group,
|
||||||
|
EC_POINT *r, EC_POINT *s,
|
||||||
|
EC_POINT *p, BN_CTX *ctx);
|
||||||
|
int ec_GFp_simple_ladder_post(const EC_GROUP *group,
|
||||||
|
EC_POINT *r, EC_POINT *s,
|
||||||
|
EC_POINT *p, BN_CTX *ctx);
|
||||||
|
|
||||||
/* method functions in ecp_mont.c */
|
/* method functions in ecp_mont.c */
|
||||||
int ec_GFp_mont_group_init(EC_GROUP *);
|
int ec_GFp_mont_group_init(EC_GROUP *);
|
||||||
@@ -681,7 +687,7 @@ int ec_scalar_mul_ladder(const EC_GROUP *group, EC_POINT *r,
|
|||||||
|
|
||||||
int ec_point_blind_coordinates(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx);
|
int ec_point_blind_coordinates(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx);
|
||||||
|
|
||||||
static inline int ec_point_ladder_pre(const EC_GROUP *group,
|
static ossl_inline int ec_point_ladder_pre(const EC_GROUP *group,
|
||||||
EC_POINT *r, EC_POINT *s,
|
EC_POINT *r, EC_POINT *s,
|
||||||
EC_POINT *p, BN_CTX *ctx)
|
EC_POINT *p, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
@@ -695,7 +701,7 @@ static inline int ec_point_ladder_pre(const EC_GROUP *group,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int ec_point_ladder_step(const EC_GROUP *group,
|
static ossl_inline int ec_point_ladder_step(const EC_GROUP *group,
|
||||||
EC_POINT *r, EC_POINT *s,
|
EC_POINT *r, EC_POINT *s,
|
||||||
EC_POINT *p, BN_CTX *ctx)
|
EC_POINT *p, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
@@ -710,7 +716,7 @@ static inline int ec_point_ladder_step(const EC_GROUP *group,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int ec_point_ladder_post(const EC_GROUP *group,
|
static ossl_inline int ec_point_ladder_post(const EC_GROUP *group,
|
||||||
EC_POINT *r, EC_POINT *s,
|
EC_POINT *r, EC_POINT *s,
|
||||||
EC_POINT *p, BN_CTX *ctx)
|
EC_POINT *p, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
|
|||||||
+55
-64
@@ -415,49 +415,53 @@ size_t EC_GROUP_get_seed_len(const EC_GROUP *group)
|
|||||||
return group->seed_len;
|
return group->seed_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
|
int EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
|
||||||
const BIGNUM *b, BN_CTX *ctx)
|
const BIGNUM *b, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
if (group->meth->group_set_curve == 0) {
|
if (group->meth->group_set_curve == 0) {
|
||||||
ECerr(EC_F_EC_GROUP_SET_CURVE_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
ECerr(EC_F_EC_GROUP_SET_CURVE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return group->meth->group_set_curve(group, p, a, b, ctx);
|
return group->meth->group_set_curve(group, p, a, b, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
|
int EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b,
|
||||||
BIGNUM *b, BN_CTX *ctx)
|
BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
if (group->meth->group_get_curve == 0) {
|
if (group->meth->group_get_curve == NULL) {
|
||||||
ECerr(EC_F_EC_GROUP_GET_CURVE_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
ECerr(EC_F_EC_GROUP_GET_CURVE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return group->meth->group_get_curve(group, p, a, b, ctx);
|
return group->meth->group_get_curve(group, p, a, b, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if OPENSSL_API_COMPAT < 0x10200000L
|
||||||
|
int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
|
||||||
|
const BIGNUM *b, BN_CTX *ctx)
|
||||||
|
{
|
||||||
|
return EC_GROUP_set_curve(group, p, a, b, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
|
||||||
|
BIGNUM *b, BN_CTX *ctx)
|
||||||
|
{
|
||||||
|
return EC_GROUP_get_curve(group, p, a, b, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_EC2M
|
# ifndef OPENSSL_NO_EC2M
|
||||||
int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
|
int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
|
||||||
const BIGNUM *b, BN_CTX *ctx)
|
const BIGNUM *b, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
if (group->meth->group_set_curve == 0) {
|
return EC_GROUP_set_curve(group, p, a, b, ctx);
|
||||||
ECerr(EC_F_EC_GROUP_SET_CURVE_GF2M,
|
|
||||||
ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return group->meth->group_set_curve(group, p, a, b, ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
|
int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
|
||||||
BIGNUM *b, BN_CTX *ctx)
|
BIGNUM *b, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
if (group->meth->group_get_curve == 0) {
|
return EC_GROUP_get_curve(group, p, a, b, ctx);
|
||||||
ECerr(EC_F_EC_GROUP_GET_CURVE_GF2M,
|
|
||||||
ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return group->meth->group_get_curve(group, p, a, b, ctx);
|
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
int EC_GROUP_get_degree(const EC_GROUP *group)
|
int EC_GROUP_get_degree(const EC_GROUP *group)
|
||||||
{
|
{
|
||||||
@@ -699,73 +703,69 @@ int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
|
|||||||
y, z, ctx);
|
y, z, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group,
|
int EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point,
|
||||||
EC_POINT *point, const BIGNUM *x,
|
const BIGNUM *x, const BIGNUM *y,
|
||||||
const BIGNUM *y, BN_CTX *ctx)
|
BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
if (group->meth->point_set_affine_coordinates == 0) {
|
if (group->meth->point_set_affine_coordinates == NULL) {
|
||||||
ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP,
|
ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES,
|
||||||
ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!ec_point_is_compat(point, group)) {
|
if (!ec_point_is_compat(point, group)) {
|
||||||
ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP,
|
ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES, EC_R_INCOMPATIBLE_OBJECTS);
|
||||||
EC_R_INCOMPATIBLE_OBJECTS);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!group->meth->point_set_affine_coordinates(group, point, x, y, ctx))
|
if (!group->meth->point_set_affine_coordinates(group, point, x, y, ctx))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (EC_POINT_is_on_curve(group, point, ctx) <= 0) {
|
if (EC_POINT_is_on_curve(group, point, ctx) <= 0) {
|
||||||
ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP,
|
ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES, EC_R_POINT_IS_NOT_ON_CURVE);
|
||||||
EC_R_POINT_IS_NOT_ON_CURVE);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if OPENSSL_API_COMPAT < 0x10200000L
|
||||||
|
int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group,
|
||||||
|
EC_POINT *point, const BIGNUM *x,
|
||||||
|
const BIGNUM *y, BN_CTX *ctx)
|
||||||
|
{
|
||||||
|
return EC_POINT_set_affine_coordinates(group, point, x, y, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_EC2M
|
# ifndef OPENSSL_NO_EC2M
|
||||||
int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group,
|
int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group,
|
||||||
EC_POINT *point, const BIGNUM *x,
|
EC_POINT *point, const BIGNUM *x,
|
||||||
const BIGNUM *y, BN_CTX *ctx)
|
const BIGNUM *y, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
if (group->meth->point_set_affine_coordinates == 0) {
|
return EC_POINT_set_affine_coordinates(group, point, x, y, ctx);
|
||||||
ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M,
|
}
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int EC_POINT_get_affine_coordinates(const EC_GROUP *group,
|
||||||
|
const EC_POINT *point, BIGNUM *x, BIGNUM *y,
|
||||||
|
BN_CTX *ctx)
|
||||||
|
{
|
||||||
|
if (group->meth->point_get_affine_coordinates == NULL) {
|
||||||
|
ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES,
|
||||||
ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!ec_point_is_compat(point, group)) {
|
if (!ec_point_is_compat(point, group)) {
|
||||||
ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M,
|
ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES, EC_R_INCOMPATIBLE_OBJECTS);
|
||||||
EC_R_INCOMPATIBLE_OBJECTS);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!group->meth->point_set_affine_coordinates(group, point, x, y, ctx))
|
return group->meth->point_get_affine_coordinates(group, point, x, y, ctx);
|
||||||
return 0;
|
}
|
||||||
|
|
||||||
if (EC_POINT_is_on_curve(group, point, ctx) <= 0) {
|
|
||||||
ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M,
|
|
||||||
EC_R_POINT_IS_NOT_ON_CURVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#if OPENSSL_API_COMPAT < 0x10200000L
|
||||||
int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
|
int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
|
||||||
const EC_POINT *point, BIGNUM *x,
|
const EC_POINT *point, BIGNUM *x,
|
||||||
BIGNUM *y, BN_CTX *ctx)
|
BIGNUM *y, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
if (group->meth->point_get_affine_coordinates == 0) {
|
return EC_POINT_get_affine_coordinates(group, point, x, y, ctx);
|
||||||
ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP,
|
|
||||||
ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!ec_point_is_compat(point, group)) {
|
|
||||||
ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP,
|
|
||||||
EC_R_INCOMPATIBLE_OBJECTS);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return group->meth->point_get_affine_coordinates(group, point, x, y, ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_EC2M
|
# ifndef OPENSSL_NO_EC2M
|
||||||
@@ -773,19 +773,10 @@ int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
|
|||||||
const EC_POINT *point, BIGNUM *x,
|
const EC_POINT *point, BIGNUM *x,
|
||||||
BIGNUM *y, BN_CTX *ctx)
|
BIGNUM *y, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
if (group->meth->point_get_affine_coordinates == 0) {
|
return EC_POINT_get_affine_coordinates(group, point, x, y, ctx);
|
||||||
ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M,
|
|
||||||
ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!ec_point_is_compat(point, group)) {
|
|
||||||
ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M,
|
|
||||||
EC_R_INCOMPATIBLE_OBJECTS);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return group->meth->point_get_affine_coordinates(group, point, x, y, ctx);
|
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
|
int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
|
||||||
const EC_POINT *b, BN_CTX *ctx)
|
const EC_POINT *b, BN_CTX *ctx)
|
||||||
|
|||||||
+16
-28
@@ -15,18 +15,17 @@
|
|||||||
|
|
||||||
#include "ec_lcl.h"
|
#include "ec_lcl.h"
|
||||||
|
|
||||||
int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,
|
int EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point,
|
||||||
EC_POINT *point, const BIGNUM *x,
|
const BIGNUM *x, int y_bit, BN_CTX *ctx)
|
||||||
int y_bit, BN_CTX *ctx)
|
|
||||||
{
|
{
|
||||||
if (group->meth->point_set_compressed_coordinates == 0
|
if (group->meth->point_set_compressed_coordinates == NULL
|
||||||
&& !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) {
|
&& !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) {
|
||||||
ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP,
|
ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES,
|
||||||
ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!ec_point_is_compat(point, group)) {
|
if (!ec_point_is_compat(point, group)) {
|
||||||
ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP,
|
ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES,
|
||||||
EC_R_INCOMPATIBLE_OBJECTS);
|
EC_R_INCOMPATIBLE_OBJECTS);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -37,7 +36,7 @@ int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,
|
|||||||
else
|
else
|
||||||
#ifdef OPENSSL_NO_EC2M
|
#ifdef OPENSSL_NO_EC2M
|
||||||
{
|
{
|
||||||
ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP,
|
ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES,
|
||||||
EC_R_GF2M_NOT_SUPPORTED);
|
EC_R_GF2M_NOT_SUPPORTED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -50,34 +49,23 @@ int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,
|
|||||||
y_bit, ctx);
|
y_bit, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if OPENSSL_API_COMPAT < 0x10200000L
|
||||||
|
int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,
|
||||||
|
EC_POINT *point, const BIGNUM *x,
|
||||||
|
int y_bit, BN_CTX *ctx)
|
||||||
|
{
|
||||||
|
return EC_POINT_set_compressed_coordinates(group, point, x, y_bit, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_EC2M
|
# ifndef OPENSSL_NO_EC2M
|
||||||
int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group,
|
int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group,
|
||||||
EC_POINT *point, const BIGNUM *x,
|
EC_POINT *point, const BIGNUM *x,
|
||||||
int y_bit, BN_CTX *ctx)
|
int y_bit, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
if (group->meth->point_set_compressed_coordinates == 0
|
return EC_POINT_set_compressed_coordinates(group, point, x, y_bit, ctx);
|
||||||
&& !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) {
|
|
||||||
ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M,
|
|
||||||
ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!ec_point_is_compat(point, group)) {
|
|
||||||
ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M,
|
|
||||||
EC_R_INCOMPATIBLE_OBJECTS);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) {
|
|
||||||
if (group->meth->field_type == NID_X9_62_prime_field)
|
|
||||||
return ec_GFp_simple_set_compressed_coordinates(group, point, x,
|
|
||||||
y_bit, ctx);
|
|
||||||
else
|
|
||||||
return ec_GF2m_simple_set_compressed_coordinates(group, point, x,
|
|
||||||
y_bit, ctx);
|
|
||||||
}
|
|
||||||
return group->meth->point_set_compressed_coordinates(group, point, x,
|
|
||||||
y_bit, ctx);
|
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point,
|
size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point,
|
||||||
point_conversion_form_t form, unsigned char *buf,
|
point_conversion_form_t form, unsigned char *buf,
|
||||||
|
|||||||
+1
-12
@@ -83,21 +83,10 @@ int ecdh_simple_compute_key(unsigned char **pout, size_t *poutlen,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) ==
|
if (!EC_POINT_get_affine_coordinates(group, tmp, x, NULL, ctx)) {
|
||||||
NID_X9_62_prime_field) {
|
|
||||||
if (!EC_POINT_get_affine_coordinates_GFp(group, tmp, x, NULL, ctx)) {
|
|
||||||
ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, EC_R_POINT_ARITHMETIC_FAILURE);
|
ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, EC_R_POINT_ARITHMETIC_FAILURE);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#ifndef OPENSSL_NO_EC2M
|
|
||||||
else {
|
|
||||||
if (!EC_POINT_get_affine_coordinates_GF2m(group, tmp, x, NULL, ctx)) {
|
|
||||||
ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, EC_R_POINT_ARITHMETIC_FAILURE);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
buflen = (EC_GROUP_get_degree(group) + 7) / 8;
|
buflen = (EC_GROUP_get_degree(group) + 7) / 8;
|
||||||
len = BN_num_bytes(x);
|
len = BN_num_bytes(x);
|
||||||
|
|||||||
+5
-26
@@ -104,23 +104,12 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in,
|
|||||||
ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB);
|
ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) ==
|
|
||||||
NID_X9_62_prime_field) {
|
if (!EC_POINT_get_affine_coordinates(group, tmp_point, X, NULL, ctx)) {
|
||||||
if (!EC_POINT_get_affine_coordinates_GFp(group, tmp_point, X,
|
|
||||||
NULL, ctx)) {
|
|
||||||
ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB);
|
ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#ifndef OPENSSL_NO_EC2M
|
|
||||||
else { /* NID_X9_62_characteristic_two_field */
|
|
||||||
if (!EC_POINT_get_affine_coordinates_GF2m(group, tmp_point, X,
|
|
||||||
NULL, ctx)) {
|
|
||||||
ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (!BN_nnmod(r, X, order, ctx)) {
|
if (!BN_nnmod(r, X, order, ctx)) {
|
||||||
ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB);
|
ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB);
|
||||||
goto err;
|
goto err;
|
||||||
@@ -408,22 +397,12 @@ int ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len,
|
|||||||
ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_EC_LIB);
|
ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_EC_LIB);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) ==
|
|
||||||
NID_X9_62_prime_field) {
|
|
||||||
if (!EC_POINT_get_affine_coordinates_GFp(group, point, X, NULL, ctx)) {
|
|
||||||
ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_EC_LIB);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifndef OPENSSL_NO_EC2M
|
|
||||||
else { /* NID_X9_62_characteristic_two_field */
|
|
||||||
|
|
||||||
if (!EC_POINT_get_affine_coordinates_GF2m(group, point, X, NULL, ctx)) {
|
if (!EC_POINT_get_affine_coordinates(group, point, X, NULL, ctx)) {
|
||||||
ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_EC_LIB);
|
ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_EC_LIB);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (!BN_nnmod(u1, X, order, ctx)) {
|
if (!BN_nnmod(u1, X, order, ctx)) {
|
||||||
ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_BN_LIB);
|
ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_BN_LIB);
|
||||||
goto err;
|
goto err;
|
||||||
|
|||||||
+2
-11
@@ -125,20 +125,11 @@ int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off)
|
|||||||
reason = ERR_R_MALLOC_FAILURE;
|
reason = ERR_R_MALLOC_FAILURE;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
#ifndef OPENSSL_NO_EC2M
|
|
||||||
if (is_char_two) {
|
if (!EC_GROUP_get_curve(x, p, a, b, ctx)) {
|
||||||
if (!EC_GROUP_get_curve_GF2m(x, p, a, b, ctx)) {
|
|
||||||
reason = ERR_R_EC_LIB;
|
reason = ERR_R_EC_LIB;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
} else /* prime field */
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
if (!EC_GROUP_get_curve_GFp(x, p, a, b, ctx)) {
|
|
||||||
reason = ERR_R_EC_LIB;
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((point = EC_GROUP_get0_generator(x)) == NULL) {
|
if ((point = EC_GROUP_get0_generator(x)) == NULL) {
|
||||||
reason = ERR_R_EC_LIB;
|
reason = ERR_R_EC_LIB;
|
||||||
|
|||||||
@@ -64,9 +64,9 @@ const EC_METHOD *EC_GFp_mont_method(void)
|
|||||||
ecdh_simple_compute_key,
|
ecdh_simple_compute_key,
|
||||||
0, /* field_inverse_mod_ord */
|
0, /* field_inverse_mod_ord */
|
||||||
ec_GFp_simple_blind_coordinates,
|
ec_GFp_simple_blind_coordinates,
|
||||||
0, /* ladder_pre */
|
ec_GFp_simple_ladder_pre,
|
||||||
0, /* ladder_step */
|
ec_GFp_simple_ladder_step,
|
||||||
0 /* ladder_post */
|
ec_GFp_simple_ladder_post
|
||||||
};
|
};
|
||||||
|
|
||||||
return &ret;
|
return &ret;
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ const EC_METHOD *EC_GFp_nist_method(void)
|
|||||||
ecdh_simple_compute_key,
|
ecdh_simple_compute_key,
|
||||||
0, /* field_inverse_mod_ord */
|
0, /* field_inverse_mod_ord */
|
||||||
ec_GFp_simple_blind_coordinates,
|
ec_GFp_simple_blind_coordinates,
|
||||||
0, /* ladder_pre */
|
ec_GFp_simple_ladder_pre,
|
||||||
0, /* ladder_step */
|
ec_GFp_simple_ladder_step,
|
||||||
0 /* ladder_post */
|
ec_GFp_simple_ladder_post
|
||||||
};
|
};
|
||||||
|
|
||||||
return &ret;
|
return &ret;
|
||||||
|
|||||||
@@ -1608,7 +1608,7 @@ int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
|||||||
goto err;
|
goto err;
|
||||||
BN_bin2bn(nistp224_curve_params[3], sizeof(felem_bytearray), x);
|
BN_bin2bn(nistp224_curve_params[3], sizeof(felem_bytearray), x);
|
||||||
BN_bin2bn(nistp224_curve_params[4], sizeof(felem_bytearray), y);
|
BN_bin2bn(nistp224_curve_params[4], sizeof(felem_bytearray), y);
|
||||||
if (!EC_POINT_set_affine_coordinates_GFp(group, generator, x, y, ctx))
|
if (!EC_POINT_set_affine_coordinates(group, generator, x, y, ctx))
|
||||||
goto err;
|
goto err;
|
||||||
if ((pre = nistp224_pre_comp_new()) == NULL)
|
if ((pre = nistp224_pre_comp_new()) == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
|
|||||||
@@ -2238,7 +2238,7 @@ int ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
|||||||
goto err;
|
goto err;
|
||||||
BN_bin2bn(nistp256_curve_params[3], sizeof(felem_bytearray), x);
|
BN_bin2bn(nistp256_curve_params[3], sizeof(felem_bytearray), x);
|
||||||
BN_bin2bn(nistp256_curve_params[4], sizeof(felem_bytearray), y);
|
BN_bin2bn(nistp256_curve_params[4], sizeof(felem_bytearray), y);
|
||||||
if (!EC_POINT_set_affine_coordinates_GFp(group, generator, x, y, ctx))
|
if (!EC_POINT_set_affine_coordinates(group, generator, x, y, ctx))
|
||||||
goto err;
|
goto err;
|
||||||
if ((pre = nistp256_pre_comp_new()) == NULL)
|
if ((pre = nistp256_pre_comp_new()) == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
|
|||||||
@@ -2071,7 +2071,7 @@ int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
|||||||
goto err;
|
goto err;
|
||||||
BN_bin2bn(nistp521_curve_params[3], sizeof(felem_bytearray), x);
|
BN_bin2bn(nistp521_curve_params[3], sizeof(felem_bytearray), x);
|
||||||
BN_bin2bn(nistp521_curve_params[4], sizeof(felem_bytearray), y);
|
BN_bin2bn(nistp521_curve_params[4], sizeof(felem_bytearray), y);
|
||||||
if (!EC_POINT_set_affine_coordinates_GFp(group, generator, x, y, ctx))
|
if (!EC_POINT_set_affine_coordinates(group, generator, x, y, ctx))
|
||||||
goto err;
|
goto err;
|
||||||
if ((pre = nistp521_pre_comp_new()) == NULL)
|
if ((pre = nistp521_pre_comp_new()) == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
|
|||||||
@@ -1104,28 +1104,12 @@ __owur static int ecp_nistz256_set_from_affine(EC_POINT *out, const EC_GROUP *gr
|
|||||||
const P256_POINT_AFFINE *in,
|
const P256_POINT_AFFINE *in,
|
||||||
BN_CTX *ctx)
|
BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
BIGNUM *x, *y;
|
|
||||||
BN_ULONG d_x[P256_LIMBS], d_y[P256_LIMBS];
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
x = BN_new();
|
if ((ret = bn_set_words(out->X, in->X, P256_LIMBS))
|
||||||
if (x == NULL)
|
&& (ret = bn_set_words(out->Y, in->Y, P256_LIMBS))
|
||||||
return 0;
|
&& (ret = bn_set_words(out->Z, ONE, P256_LIMBS)))
|
||||||
y = BN_new();
|
out->Z_is_one = 1;
|
||||||
if (y == NULL) {
|
|
||||||
BN_free(x);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
memcpy(d_x, in->X, sizeof(d_x));
|
|
||||||
bn_set_static_words(x, d_x, P256_LIMBS);
|
|
||||||
|
|
||||||
memcpy(d_y, in->Y, sizeof(d_y));
|
|
||||||
bn_set_static_words(y, d_y, P256_LIMBS);
|
|
||||||
|
|
||||||
ret = EC_POINT_set_affine_coordinates_GFp(group, out, x, y, ctx);
|
|
||||||
|
|
||||||
BN_free(x);
|
|
||||||
BN_free(y);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -1181,9 +1165,9 @@ __owur static int ecp_nistz256_points_mul(const EC_GROUP *group,
|
|||||||
if (pre_comp_generator == NULL)
|
if (pre_comp_generator == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
ecp_nistz256_gather_w7(&p.a, pre_comp->precomp[0], 1);
|
||||||
if (!ecp_nistz256_set_from_affine(pre_comp_generator,
|
if (!ecp_nistz256_set_from_affine(pre_comp_generator,
|
||||||
group, pre_comp->precomp[0],
|
group, &p.a, ctx)) {
|
||||||
ctx)) {
|
|
||||||
EC_POINT_free(pre_comp_generator);
|
EC_POINT_free(pre_comp_generator);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -1355,7 +1339,6 @@ __owur static int ecp_nistz256_points_mul(const EC_GROUP *group,
|
|||||||
ret = 1;
|
ret = 1;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (ctx)
|
|
||||||
BN_CTX_end(ctx);
|
BN_CTX_end(ctx);
|
||||||
OPENSSL_free(new_points);
|
OPENSSL_free(new_points);
|
||||||
OPENSSL_free(new_scalars);
|
OPENSSL_free(new_scalars);
|
||||||
|
|||||||
+5
-6
@@ -140,7 +140,7 @@ int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *group,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx))
|
if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
@@ -206,7 +206,7 @@ size_t ec_GFp_simple_point2oct(const EC_GROUP *group, const EC_POINT *point,
|
|||||||
if (y == NULL)
|
if (y == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (!EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx))
|
if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if ((form == POINT_CONVERSION_COMPRESSED
|
if ((form == POINT_CONVERSION_COMPRESSED
|
||||||
@@ -333,8 +333,7 @@ int ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (form == POINT_CONVERSION_COMPRESSED) {
|
if (form == POINT_CONVERSION_COMPRESSED) {
|
||||||
if (!EC_POINT_set_compressed_coordinates_GFp
|
if (!EC_POINT_set_compressed_coordinates(group, point, x, y_bit, ctx))
|
||||||
(group, point, x, y_bit, ctx))
|
|
||||||
goto err;
|
goto err;
|
||||||
} else {
|
} else {
|
||||||
if (!BN_bin2bn(buf + 1 + field_len, field_len, y))
|
if (!BN_bin2bn(buf + 1 + field_len, field_len, y))
|
||||||
@@ -351,10 +350,10 @@ int ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* EC_POINT_set_affine_coordinates_GFp is responsible for checking that
|
* EC_POINT_set_affine_coordinates is responsible for checking that
|
||||||
* the point is on the curve.
|
* the point is on the curve.
|
||||||
*/
|
*/
|
||||||
if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx))
|
if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx))
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+223
-5
@@ -65,9 +65,9 @@ const EC_METHOD *EC_GFp_simple_method(void)
|
|||||||
ecdh_simple_compute_key,
|
ecdh_simple_compute_key,
|
||||||
0, /* field_inverse_mod_ord */
|
0, /* field_inverse_mod_ord */
|
||||||
ec_GFp_simple_blind_coordinates,
|
ec_GFp_simple_blind_coordinates,
|
||||||
0, /* ladder_pre */
|
ec_GFp_simple_ladder_pre,
|
||||||
0, /* ladder_step */
|
ec_GFp_simple_ladder_step,
|
||||||
0 /* ladder_post */
|
ec_GFp_simple_ladder_post
|
||||||
};
|
};
|
||||||
|
|
||||||
return &ret;
|
return &ret;
|
||||||
@@ -1181,9 +1181,9 @@ int ec_GFp_simple_make_affine(const EC_GROUP *group, EC_POINT *point,
|
|||||||
if (y == NULL)
|
if (y == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (!EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx))
|
if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx))
|
||||||
goto err;
|
goto err;
|
||||||
if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx))
|
if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx))
|
||||||
goto err;
|
goto err;
|
||||||
if (!point->Z_is_one) {
|
if (!point->Z_is_one) {
|
||||||
ECerr(EC_F_EC_GFP_SIMPLE_MAKE_AFFINE, ERR_R_INTERNAL_ERROR);
|
ECerr(EC_F_EC_GFP_SIMPLE_MAKE_AFFINE, ERR_R_INTERNAL_ERROR);
|
||||||
@@ -1421,3 +1421,221 @@ int ec_GFp_simple_blind_coordinates(const EC_GROUP *group, EC_POINT *p,
|
|||||||
BN_CTX_end(ctx);
|
BN_CTX_end(ctx);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Set s := p, r := 2p.
|
||||||
|
*
|
||||||
|
* For doubling we use Formula 3 from Izu-Takagi "A fast parallel elliptic curve
|
||||||
|
* multiplication resistant against side channel attacks" appendix, as described
|
||||||
|
* at
|
||||||
|
* https://hyperelliptic.org/EFD/g1p/auto-shortw-xz.html#doubling-dbl-2002-it-2
|
||||||
|
*
|
||||||
|
* The input point p will be in randomized Jacobian projective coords:
|
||||||
|
* x = X/Z**2, y=Y/Z**3
|
||||||
|
*
|
||||||
|
* The output points p, s, and r are converted to standard (homogeneous)
|
||||||
|
* projective coords:
|
||||||
|
* x = X/Z, y=Y/Z
|
||||||
|
*/
|
||||||
|
int ec_GFp_simple_ladder_pre(const EC_GROUP *group,
|
||||||
|
EC_POINT *r, EC_POINT *s,
|
||||||
|
EC_POINT *p, BN_CTX *ctx)
|
||||||
|
{
|
||||||
|
BIGNUM *t1, *t2, *t3, *t4, *t5, *t6 = NULL;
|
||||||
|
|
||||||
|
t1 = r->Z;
|
||||||
|
t2 = r->Y;
|
||||||
|
t3 = s->X;
|
||||||
|
t4 = r->X;
|
||||||
|
t5 = s->Y;
|
||||||
|
t6 = s->Z;
|
||||||
|
|
||||||
|
/* convert p: (X,Y,Z) -> (XZ,Y,Z**3) */
|
||||||
|
if (!group->meth->field_mul(group, p->X, p->X, p->Z, ctx)
|
||||||
|
|| !group->meth->field_sqr(group, t1, p->Z, ctx)
|
||||||
|
|| !group->meth->field_mul(group, p->Z, p->Z, t1, ctx)
|
||||||
|
/* r := 2p */
|
||||||
|
|| !group->meth->field_sqr(group, t2, p->X, ctx)
|
||||||
|
|| !group->meth->field_sqr(group, t3, p->Z, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t4, t3, group->a, ctx)
|
||||||
|
|| !BN_mod_sub_quick(t5, t2, t4, group->field)
|
||||||
|
|| !BN_mod_add_quick(t2, t2, t4, group->field)
|
||||||
|
|| !group->meth->field_sqr(group, t5, t5, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t6, t3, group->b, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t1, p->X, p->Z, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t4, t1, t6, ctx)
|
||||||
|
|| !BN_mod_lshift_quick(t4, t4, 3, group->field)
|
||||||
|
/* r->X coord output */
|
||||||
|
|| !BN_mod_sub_quick(r->X, t5, t4, group->field)
|
||||||
|
|| !group->meth->field_mul(group, t1, t1, t2, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t2, t3, t6, ctx)
|
||||||
|
|| !BN_mod_add_quick(t1, t1, t2, group->field)
|
||||||
|
/* r->Z coord output */
|
||||||
|
|| !BN_mod_lshift_quick(r->Z, t1, 2, group->field)
|
||||||
|
|| !EC_POINT_copy(s, p))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
r->Z_is_one = 0;
|
||||||
|
s->Z_is_one = 0;
|
||||||
|
p->Z_is_one = 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Differential addition-and-doubling using Eq. (8) and (10) from Izu-Takagi
|
||||||
|
* "A fast parallel elliptic curve multiplication resistant against side channel
|
||||||
|
* attacks", as described at
|
||||||
|
* https://hyperelliptic.org/EFD/g1p/auto-shortw-xz.html#ladder-ladd-2002-it-3
|
||||||
|
*/
|
||||||
|
int ec_GFp_simple_ladder_step(const EC_GROUP *group,
|
||||||
|
EC_POINT *r, EC_POINT *s,
|
||||||
|
EC_POINT *p, BN_CTX *ctx)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
BIGNUM *t0, *t1, *t2, *t3, *t4, *t5, *t6, *t7 = NULL;
|
||||||
|
|
||||||
|
BN_CTX_start(ctx);
|
||||||
|
t0 = BN_CTX_get(ctx);
|
||||||
|
t1 = BN_CTX_get(ctx);
|
||||||
|
t2 = BN_CTX_get(ctx);
|
||||||
|
t3 = BN_CTX_get(ctx);
|
||||||
|
t4 = BN_CTX_get(ctx);
|
||||||
|
t5 = BN_CTX_get(ctx);
|
||||||
|
t6 = BN_CTX_get(ctx);
|
||||||
|
t7 = BN_CTX_get(ctx);
|
||||||
|
|
||||||
|
if (t7 == NULL
|
||||||
|
|| !group->meth->field_mul(group, t0, r->X, s->X, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t1, r->Z, s->Z, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t2, r->X, s->Z, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t3, r->Z, s->X, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t4, group->a, t1, ctx)
|
||||||
|
|| !BN_mod_sub_quick(t4, t0, t4, group->field)
|
||||||
|
|| !BN_mod_add_quick(t5, t3, t2, group->field)
|
||||||
|
|| !group->meth->field_sqr(group, t4, t4, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t5, t1, t5, ctx)
|
||||||
|
|| !BN_mod_lshift_quick(t0, group->b, 2, group->field)
|
||||||
|
|| !group->meth->field_mul(group, t5, t0, t5, ctx)
|
||||||
|
|| !BN_mod_sub_quick(t5, t4, t5, group->field)
|
||||||
|
/* s->X coord output */
|
||||||
|
|| !group->meth->field_mul(group, s->X, t5, p->Z, ctx)
|
||||||
|
|| !BN_mod_sub_quick(t3, t2, t3, group->field)
|
||||||
|
|| !group->meth->field_sqr(group, t3, t3, ctx)
|
||||||
|
/* s->Z coord output */
|
||||||
|
|| !group->meth->field_mul(group, s->Z, t3, p->X, ctx)
|
||||||
|
|| !group->meth->field_sqr(group, t2, r->X, ctx)
|
||||||
|
|| !group->meth->field_sqr(group, t4, r->Z, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t1, t4, group->a, ctx)
|
||||||
|
|| !BN_mod_add_quick(t6, r->X, r->Z, group->field)
|
||||||
|
|| !group->meth->field_sqr(group, t6, t6, ctx)
|
||||||
|
|| !BN_mod_sub_quick(t6, t6, t2, group->field)
|
||||||
|
|| !BN_mod_sub_quick(t6, t6, t4, group->field)
|
||||||
|
|| !BN_mod_sub_quick(t7, t2, t1, group->field)
|
||||||
|
|| !group->meth->field_sqr(group, t7, t7, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t5, t4, t6, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t5, t0, t5, ctx)
|
||||||
|
/* r->X coord output */
|
||||||
|
|| !BN_mod_sub_quick(r->X, t7, t5, group->field)
|
||||||
|
|| !BN_mod_add_quick(t2, t2, t1, group->field)
|
||||||
|
|| !group->meth->field_sqr(group, t5, t4, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t5, t5, t0, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t6, t6, t2, ctx)
|
||||||
|
|| !BN_mod_lshift1_quick(t6, t6, group->field)
|
||||||
|
/* r->Z coord output */
|
||||||
|
|| !BN_mod_add_quick(r->Z, t5, t6, group->field))
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
ret = 1;
|
||||||
|
|
||||||
|
err:
|
||||||
|
BN_CTX_end(ctx);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Recovers the y-coordinate of r using Eq. (8) from Brier-Joye, "Weierstrass
|
||||||
|
* Elliptic Curves and Side-Channel Attacks", modified to work in projective
|
||||||
|
* coordinates and return r in Jacobian projective coordinates.
|
||||||
|
*
|
||||||
|
* X4 = two*Y1*X2*Z3*Z2*Z1;
|
||||||
|
* Y4 = two*b*Z3*SQR(Z2*Z1) + Z3*(a*Z2*Z1+X1*X2)*(X1*Z2+X2*Z1) - X3*SQR(X1*Z2-X2*Z1);
|
||||||
|
* Z4 = two*Y1*Z3*SQR(Z2)*Z1;
|
||||||
|
*
|
||||||
|
* Z4 != 0 because:
|
||||||
|
* - Z1==0 implies p is at infinity, which would have caused an early exit in
|
||||||
|
* the caller;
|
||||||
|
* - Z2==0 implies r is at infinity (handled by the BN_is_zero(r->Z) branch);
|
||||||
|
* - Z3==0 implies s is at infinity (handled by the BN_is_zero(s->Z) branch);
|
||||||
|
* - Y1==0 implies p has order 2, so either r or s are infinity and handled by
|
||||||
|
* one of the BN_is_zero(...) branches.
|
||||||
|
*/
|
||||||
|
int ec_GFp_simple_ladder_post(const EC_GROUP *group,
|
||||||
|
EC_POINT *r, EC_POINT *s,
|
||||||
|
EC_POINT *p, BN_CTX *ctx)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
BIGNUM *t0, *t1, *t2, *t3, *t4, *t5, *t6 = NULL;
|
||||||
|
|
||||||
|
if (BN_is_zero(r->Z))
|
||||||
|
return EC_POINT_set_to_infinity(group, r);
|
||||||
|
|
||||||
|
if (BN_is_zero(s->Z)) {
|
||||||
|
/* (X,Y,Z) -> (XZ,YZ**2,Z) */
|
||||||
|
if (!group->meth->field_mul(group, r->X, p->X, p->Z, ctx)
|
||||||
|
|| !group->meth->field_sqr(group, r->Z, p->Z, ctx)
|
||||||
|
|| !group->meth->field_mul(group, r->Y, p->Y, r->Z, ctx)
|
||||||
|
|| !BN_copy(r->Z, p->Z)
|
||||||
|
|| !EC_POINT_invert(group, r, ctx))
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
BN_CTX_start(ctx);
|
||||||
|
t0 = BN_CTX_get(ctx);
|
||||||
|
t1 = BN_CTX_get(ctx);
|
||||||
|
t2 = BN_CTX_get(ctx);
|
||||||
|
t3 = BN_CTX_get(ctx);
|
||||||
|
t4 = BN_CTX_get(ctx);
|
||||||
|
t5 = BN_CTX_get(ctx);
|
||||||
|
t6 = BN_CTX_get(ctx);
|
||||||
|
|
||||||
|
if (t6 == NULL
|
||||||
|
|| !BN_mod_lshift1_quick(t0, p->Y, group->field)
|
||||||
|
|| !group->meth->field_mul(group, t1, r->X, p->Z, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t2, r->Z, s->Z, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t2, t1, t2, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t3, t2, t0, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t2, r->Z, p->Z, ctx)
|
||||||
|
|| !group->meth->field_sqr(group, t4, t2, ctx)
|
||||||
|
|| !BN_mod_lshift1_quick(t5, group->b, group->field)
|
||||||
|
|| !group->meth->field_mul(group, t4, t4, t5, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t6, t2, group->a, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t5, r->X, p->X, ctx)
|
||||||
|
|| !BN_mod_add_quick(t5, t6, t5, group->field)
|
||||||
|
|| !group->meth->field_mul(group, t6, r->Z, p->X, ctx)
|
||||||
|
|| !BN_mod_add_quick(t2, t6, t1, group->field)
|
||||||
|
|| !group->meth->field_mul(group, t5, t5, t2, ctx)
|
||||||
|
|| !BN_mod_sub_quick(t6, t6, t1, group->field)
|
||||||
|
|| !group->meth->field_sqr(group, t6, t6, ctx)
|
||||||
|
|| !group->meth->field_mul(group, t6, t6, s->X, ctx)
|
||||||
|
|| !BN_mod_add_quick(t4, t5, t4, group->field)
|
||||||
|
|| !group->meth->field_mul(group, t4, t4, s->Z, ctx)
|
||||||
|
|| !BN_mod_sub_quick(t4, t4, t6, group->field)
|
||||||
|
|| !group->meth->field_sqr(group, t5, r->Z, ctx)
|
||||||
|
|| !group->meth->field_mul(group, r->Z, p->Z, s->Z, ctx)
|
||||||
|
|| !group->meth->field_mul(group, r->Z, t5, r->Z, ctx)
|
||||||
|
|| !group->meth->field_mul(group, r->Z, r->Z, t0, ctx)
|
||||||
|
/* t3 := X, t4 := Y */
|
||||||
|
/* (X,Y,Z) -> (XZ,YZ**2,Z) */
|
||||||
|
|| !group->meth->field_mul(group, r->X, t3, r->Z, ctx)
|
||||||
|
|| !group->meth->field_sqr(group, t3, r->Z, ctx)
|
||||||
|
|| !group->meth->field_mul(group, r->Y, t4, t3, ctx))
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
ret = 1;
|
||||||
|
|
||||||
|
err:
|
||||||
|
BN_CTX_end(ctx);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
@@ -67,10 +67,12 @@ R SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080
|
|||||||
R SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK 1086
|
R SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK 1086
|
||||||
R SSL_R_TLSV1_ALERT_USER_CANCELLED 1090
|
R SSL_R_TLSV1_ALERT_USER_CANCELLED 1090
|
||||||
R SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100
|
R SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100
|
||||||
|
R SSL_R_TLSV13_ALERT_MISSING_EXTENSION 1109
|
||||||
R SSL_R_TLSV1_UNSUPPORTED_EXTENSION 1110
|
R SSL_R_TLSV1_UNSUPPORTED_EXTENSION 1110
|
||||||
R SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE 1111
|
R SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE 1111
|
||||||
R SSL_R_TLSV1_UNRECOGNIZED_NAME 1112
|
R SSL_R_TLSV1_UNRECOGNIZED_NAME 1112
|
||||||
R SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE 1113
|
R SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE 1113
|
||||||
R SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE 1114
|
R SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE 1114
|
||||||
R TLS1_AD_UNKNOWN_PSK_IDENTITY 1115
|
R TLS1_AD_UNKNOWN_PSK_IDENTITY 1115
|
||||||
|
R SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED 1116
|
||||||
R TLS1_AD_NO_APPLICATION_PROTOCOL 1120
|
R TLS1_AD_NO_APPLICATION_PROTOCOL 1120
|
||||||
@@ -570,6 +570,7 @@ EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES:169:\
|
|||||||
EC_F_EC_GROUP_CHECK:170:EC_GROUP_check
|
EC_F_EC_GROUP_CHECK:170:EC_GROUP_check
|
||||||
EC_F_EC_GROUP_CHECK_DISCRIMINANT:171:EC_GROUP_check_discriminant
|
EC_F_EC_GROUP_CHECK_DISCRIMINANT:171:EC_GROUP_check_discriminant
|
||||||
EC_F_EC_GROUP_COPY:106:EC_GROUP_copy
|
EC_F_EC_GROUP_COPY:106:EC_GROUP_copy
|
||||||
|
EC_F_EC_GROUP_GET_CURVE:291:EC_GROUP_get_curve
|
||||||
EC_F_EC_GROUP_GET_CURVE_GF2M:172:EC_GROUP_get_curve_GF2m
|
EC_F_EC_GROUP_GET_CURVE_GF2M:172:EC_GROUP_get_curve_GF2m
|
||||||
EC_F_EC_GROUP_GET_CURVE_GFP:130:EC_GROUP_get_curve_GFp
|
EC_F_EC_GROUP_GET_CURVE_GFP:130:EC_GROUP_get_curve_GFp
|
||||||
EC_F_EC_GROUP_GET_DEGREE:173:EC_GROUP_get_degree
|
EC_F_EC_GROUP_GET_DEGREE:173:EC_GROUP_get_degree
|
||||||
@@ -582,6 +583,7 @@ EC_F_EC_GROUP_NEW_BY_CURVE_NAME:174:EC_GROUP_new_by_curve_name
|
|||||||
EC_F_EC_GROUP_NEW_FROM_DATA:175:ec_group_new_from_data
|
EC_F_EC_GROUP_NEW_FROM_DATA:175:ec_group_new_from_data
|
||||||
EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS:263:EC_GROUP_new_from_ecparameters
|
EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS:263:EC_GROUP_new_from_ecparameters
|
||||||
EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS:264:EC_GROUP_new_from_ecpkparameters
|
EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS:264:EC_GROUP_new_from_ecpkparameters
|
||||||
|
EC_F_EC_GROUP_SET_CURVE:292:EC_GROUP_set_curve
|
||||||
EC_F_EC_GROUP_SET_CURVE_GF2M:176:EC_GROUP_set_curve_GF2m
|
EC_F_EC_GROUP_SET_CURVE_GF2M:176:EC_GROUP_set_curve_GF2m
|
||||||
EC_F_EC_GROUP_SET_CURVE_GFP:109:EC_GROUP_set_curve_GFp
|
EC_F_EC_GROUP_SET_CURVE_GFP:109:EC_GROUP_set_curve_GFp
|
||||||
EC_F_EC_GROUP_SET_GENERATOR:111:EC_GROUP_set_generator
|
EC_F_EC_GROUP_SET_GENERATOR:111:EC_GROUP_set_generator
|
||||||
@@ -610,6 +612,7 @@ EC_F_EC_POINT_BN2POINT:280:EC_POINT_bn2point
|
|||||||
EC_F_EC_POINT_CMP:113:EC_POINT_cmp
|
EC_F_EC_POINT_CMP:113:EC_POINT_cmp
|
||||||
EC_F_EC_POINT_COPY:114:EC_POINT_copy
|
EC_F_EC_POINT_COPY:114:EC_POINT_copy
|
||||||
EC_F_EC_POINT_DBL:115:EC_POINT_dbl
|
EC_F_EC_POINT_DBL:115:EC_POINT_dbl
|
||||||
|
EC_F_EC_POINT_GET_AFFINE_COORDINATES:293:EC_POINT_get_affine_coordinates
|
||||||
EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M:183:\
|
EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M:183:\
|
||||||
EC_POINT_get_affine_coordinates_GF2m
|
EC_POINT_get_affine_coordinates_GF2m
|
||||||
EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP:116:EC_POINT_get_affine_coordinates_GFp
|
EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP:116:EC_POINT_get_affine_coordinates_GFp
|
||||||
@@ -623,9 +626,11 @@ EC_F_EC_POINT_NEW:121:EC_POINT_new
|
|||||||
EC_F_EC_POINT_OCT2POINT:122:EC_POINT_oct2point
|
EC_F_EC_POINT_OCT2POINT:122:EC_POINT_oct2point
|
||||||
EC_F_EC_POINT_POINT2BUF:281:EC_POINT_point2buf
|
EC_F_EC_POINT_POINT2BUF:281:EC_POINT_point2buf
|
||||||
EC_F_EC_POINT_POINT2OCT:123:EC_POINT_point2oct
|
EC_F_EC_POINT_POINT2OCT:123:EC_POINT_point2oct
|
||||||
|
EC_F_EC_POINT_SET_AFFINE_COORDINATES:294:EC_POINT_set_affine_coordinates
|
||||||
EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M:185:\
|
EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M:185:\
|
||||||
EC_POINT_set_affine_coordinates_GF2m
|
EC_POINT_set_affine_coordinates_GF2m
|
||||||
EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP:124:EC_POINT_set_affine_coordinates_GFp
|
EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP:124:EC_POINT_set_affine_coordinates_GFp
|
||||||
|
EC_F_EC_POINT_SET_COMPRESSED_COORDINATES:295:EC_POINT_set_compressed_coordinates
|
||||||
EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M:186:\
|
EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M:186:\
|
||||||
EC_POINT_set_compressed_coordinates_GF2m
|
EC_POINT_set_compressed_coordinates_GF2m
|
||||||
EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP:125:\
|
EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP:125:\
|
||||||
@@ -2581,6 +2586,7 @@ SSL_R_BAD_HELLO_REQUEST:105:bad hello request
|
|||||||
SSL_R_BAD_HRR_VERSION:263:bad hrr version
|
SSL_R_BAD_HRR_VERSION:263:bad hrr version
|
||||||
SSL_R_BAD_KEY_SHARE:108:bad key share
|
SSL_R_BAD_KEY_SHARE:108:bad key share
|
||||||
SSL_R_BAD_KEY_UPDATE:122:bad key update
|
SSL_R_BAD_KEY_UPDATE:122:bad key update
|
||||||
|
SSL_R_BAD_LEGACY_VERSION:292:bad legacy version
|
||||||
SSL_R_BAD_LENGTH:271:bad length
|
SSL_R_BAD_LENGTH:271:bad length
|
||||||
SSL_R_BAD_PACKET:240:bad packet
|
SSL_R_BAD_PACKET:240:bad packet
|
||||||
SSL_R_BAD_PACKET_LENGTH:115:bad packet length
|
SSL_R_BAD_PACKET_LENGTH:115:bad packet length
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ static const EVP_PBE_CTL builtin_pbe[] = {
|
|||||||
NID_id_GostR3411_2012_256, 0},
|
NID_id_GostR3411_2012_256, 0},
|
||||||
{EVP_PBE_TYPE_PRF, NID_id_tc26_hmac_gost_3411_2012_512, -1,
|
{EVP_PBE_TYPE_PRF, NID_id_tc26_hmac_gost_3411_2012_512, -1,
|
||||||
NID_id_GostR3411_2012_512, 0},
|
NID_id_GostR3411_2012_512, 0},
|
||||||
|
{EVP_PBE_TYPE_PRF, NID_hmacWithSHA512_224, -1, NID_sha512_224, 0},
|
||||||
|
{EVP_PBE_TYPE_PRF, NID_hmacWithSHA512_256, -1, NID_sha512_256, 0},
|
||||||
{EVP_PBE_TYPE_KDF, NID_id_pbkdf2, -1, -1, PKCS5_v2_PBKDF2_keyivgen},
|
{EVP_PBE_TYPE_KDF, NID_id_pbkdf2, -1, -1, PKCS5_v2_PBKDF2_keyivgen},
|
||||||
#ifndef OPENSSL_NO_SCRYPT
|
#ifndef OPENSSL_NO_SCRYPT
|
||||||
{EVP_PBE_TYPE_KDF, NID_id_scrypt, -1, -1, PKCS5_v2_scrypt_keyivgen}
|
{EVP_PBE_TYPE_KDF, NID_id_scrypt, -1, -1, PKCS5_v2_scrypt_keyivgen}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ BN_ULONG *bn_get_words(const BIGNUM *a);
|
|||||||
* Set the internal data words in a to point to words which contains size
|
* Set the internal data words in a to point to words which contains size
|
||||||
* elements. The BN_FLG_STATIC_DATA flag is set
|
* elements. The BN_FLG_STATIC_DATA flag is set
|
||||||
*/
|
*/
|
||||||
void bn_set_static_words(BIGNUM *a, BN_ULONG *words, int size);
|
void bn_set_static_words(BIGNUM *a, const BN_ULONG *words, int size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy words into the BIGNUM |a|, reallocating space as necessary.
|
* Copy words into the BIGNUM |a|, reallocating space as necessary.
|
||||||
@@ -58,7 +58,7 @@ void bn_set_static_words(BIGNUM *a, BN_ULONG *words, int size);
|
|||||||
* |num_words| is int because bn_expand2 takes an int. This is an internal
|
* |num_words| is int because bn_expand2 takes an int. This is an internal
|
||||||
* function so we simply trust callers not to pass negative values.
|
* function so we simply trust callers not to pass negative values.
|
||||||
*/
|
*/
|
||||||
int bn_set_words(BIGNUM *a, BN_ULONG *words, int num_words);
|
int bn_set_words(BIGNUM *a, const BN_ULONG *words, int num_words);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some BIGNUM functions assume most significant limb to be non-zero, which
|
* Some BIGNUM functions assume most significant limb to be non-zero, which
|
||||||
|
|||||||
+35
-19
@@ -30,11 +30,25 @@
|
|||||||
|
|
||||||
static int stopped = 0;
|
static int stopped = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Since per-thread-specific-data destructors are not universally
|
||||||
|
* available, i.e. not on Windows, only below CRYPTO_THREAD_LOCAL key
|
||||||
|
* is assumed to have destructor associated. And then an effort is made
|
||||||
|
* to call this single destructor on non-pthread platform[s].
|
||||||
|
*
|
||||||
|
* Initial value is "impossible". It is used as guard value to shortcut
|
||||||
|
* destructor for threads terminating before libcrypto is initialized or
|
||||||
|
* after it's de-initialized. Access to the key doesn't have to be
|
||||||
|
* serialized for the said threads, because they didn't use libcrypto
|
||||||
|
* and it doesn't matter if they pick "impossible" or derefernce real
|
||||||
|
* key value and pull NULL past initialization in the first thread that
|
||||||
|
* intends to use libcrypto.
|
||||||
|
*/
|
||||||
|
static CRYPTO_THREAD_LOCAL destructor_key = (CRYPTO_THREAD_LOCAL)-1;
|
||||||
|
|
||||||
static void ossl_init_thread_stop(struct thread_local_inits_st *locals);
|
static void ossl_init_thread_stop(struct thread_local_inits_st *locals);
|
||||||
|
|
||||||
static CRYPTO_THREAD_LOCAL threadstopkey;
|
static void ossl_init_thread_destructor(void *local)
|
||||||
|
|
||||||
static void ossl_init_thread_stop_wrap(void *local)
|
|
||||||
{
|
{
|
||||||
ossl_init_thread_stop((struct thread_local_inits_st *)local);
|
ossl_init_thread_stop((struct thread_local_inits_st *)local);
|
||||||
}
|
}
|
||||||
@@ -42,17 +56,17 @@ static void ossl_init_thread_stop_wrap(void *local)
|
|||||||
static struct thread_local_inits_st *ossl_init_get_thread_local(int alloc)
|
static struct thread_local_inits_st *ossl_init_get_thread_local(int alloc)
|
||||||
{
|
{
|
||||||
struct thread_local_inits_st *local =
|
struct thread_local_inits_st *local =
|
||||||
CRYPTO_THREAD_get_local(&threadstopkey);
|
CRYPTO_THREAD_get_local(&destructor_key);
|
||||||
|
|
||||||
if (local == NULL && alloc) {
|
if (alloc) {
|
||||||
local = OPENSSL_zalloc(sizeof(*local));
|
if (local == NULL
|
||||||
if (local != NULL && !CRYPTO_THREAD_set_local(&threadstopkey, local)) {
|
&& (local = OPENSSL_zalloc(sizeof(*local))) != NULL
|
||||||
|
&& !CRYPTO_THREAD_set_local(&destructor_key, local)) {
|
||||||
OPENSSL_free(local);
|
OPENSSL_free(local);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
if (!alloc) {
|
CRYPTO_THREAD_set_local(&destructor_key, NULL);
|
||||||
CRYPTO_THREAD_set_local(&threadstopkey, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return local;
|
return local;
|
||||||
@@ -71,17 +85,15 @@ static CRYPTO_ONCE base = CRYPTO_ONCE_STATIC_INIT;
|
|||||||
static int base_inited = 0;
|
static int base_inited = 0;
|
||||||
DEFINE_RUN_ONCE_STATIC(ossl_init_base)
|
DEFINE_RUN_ONCE_STATIC(ossl_init_base)
|
||||||
{
|
{
|
||||||
|
CRYPTO_THREAD_LOCAL key;
|
||||||
|
|
||||||
#ifdef OPENSSL_INIT_DEBUG
|
#ifdef OPENSSL_INIT_DEBUG
|
||||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_base: Setting up stop handlers\n");
|
fprintf(stderr, "OPENSSL_INIT: ossl_init_base: Setting up stop handlers\n");
|
||||||
#endif
|
#endif
|
||||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||||
ossl_malloc_setup_failures();
|
ossl_malloc_setup_failures();
|
||||||
#endif
|
#endif
|
||||||
/*
|
if (!CRYPTO_THREAD_init_local(&key, ossl_init_thread_destructor))
|
||||||
* We use a dummy thread local key here. We use the destructor to detect
|
|
||||||
* when the thread is going to stop (where that feature is available)
|
|
||||||
*/
|
|
||||||
if (!CRYPTO_THREAD_init_local(&threadstopkey, ossl_init_thread_stop_wrap))
|
|
||||||
return 0;
|
return 0;
|
||||||
if ((init_lock = CRYPTO_THREAD_lock_new()) == NULL)
|
if ((init_lock = CRYPTO_THREAD_lock_new()) == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
@@ -91,6 +103,7 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_base)
|
|||||||
#endif
|
#endif
|
||||||
OPENSSL_cpuid_setup();
|
OPENSSL_cpuid_setup();
|
||||||
|
|
||||||
|
destructor_key = key;
|
||||||
base_inited = 1;
|
base_inited = 1;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@@ -101,7 +114,7 @@ err:
|
|||||||
CRYPTO_THREAD_lock_free(init_lock);
|
CRYPTO_THREAD_lock_free(init_lock);
|
||||||
init_lock = NULL;
|
init_lock = NULL;
|
||||||
|
|
||||||
CRYPTO_THREAD_cleanup_local(&threadstopkey);
|
CRYPTO_THREAD_cleanup_local(&key);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,8 +409,8 @@ static void ossl_init_thread_stop(struct thread_local_inits_st *locals)
|
|||||||
|
|
||||||
void OPENSSL_thread_stop(void)
|
void OPENSSL_thread_stop(void)
|
||||||
{
|
{
|
||||||
ossl_init_thread_stop(
|
if (destructor_key != (CRYPTO_THREAD_LOCAL)-1)
|
||||||
(struct thread_local_inits_st *)ossl_init_get_thread_local(0));
|
ossl_init_thread_stop(ossl_init_get_thread_local(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
int ossl_init_thread_start(uint64_t opts)
|
int ossl_init_thread_start(uint64_t opts)
|
||||||
@@ -442,6 +455,7 @@ int ossl_init_thread_start(uint64_t opts)
|
|||||||
void OPENSSL_cleanup(void)
|
void OPENSSL_cleanup(void)
|
||||||
{
|
{
|
||||||
OPENSSL_INIT_STOP *currhandler, *lasthandler;
|
OPENSSL_INIT_STOP *currhandler, *lasthandler;
|
||||||
|
CRYPTO_THREAD_LOCAL key;
|
||||||
|
|
||||||
/* If we've not been inited then no need to deinit */
|
/* If we've not been inited then no need to deinit */
|
||||||
if (!base_inited)
|
if (!base_inited)
|
||||||
@@ -501,7 +515,9 @@ void OPENSSL_cleanup(void)
|
|||||||
err_free_strings_int();
|
err_free_strings_int();
|
||||||
}
|
}
|
||||||
|
|
||||||
CRYPTO_THREAD_cleanup_local(&threadstopkey);
|
key = destructor_key;
|
||||||
|
destructor_key = (CRYPTO_THREAD_LOCAL)-1;
|
||||||
|
CRYPTO_THREAD_cleanup_local(&key);
|
||||||
|
|
||||||
#ifdef OPENSSL_INIT_DEBUG
|
#ifdef OPENSSL_INIT_DEBUG
|
||||||
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
|
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Serialized OID's */
|
/* Serialized OID's */
|
||||||
static const unsigned char so[7746] = {
|
static const unsigned char so[7762] = {
|
||||||
0x2A,0x86,0x48,0x86,0xF7,0x0D, /* [ 0] OBJ_rsadsi */
|
0x2A,0x86,0x48,0x86,0xF7,0x0D, /* [ 0] OBJ_rsadsi */
|
||||||
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01, /* [ 6] OBJ_pkcs */
|
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01, /* [ 6] OBJ_pkcs */
|
||||||
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x02, /* [ 13] OBJ_md2 */
|
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x02, /* [ 13] OBJ_md2 */
|
||||||
@@ -1074,9 +1074,11 @@ static const unsigned char so[7746] = {
|
|||||||
0x2A,0x85,0x03,0x07,0x01,0x02,0x01,0x01,0x02, /* [ 7718] OBJ_id_tc26_gost_3410_2012_256_paramSetB */
|
0x2A,0x85,0x03,0x07,0x01,0x02,0x01,0x01,0x02, /* [ 7718] OBJ_id_tc26_gost_3410_2012_256_paramSetB */
|
||||||
0x2A,0x85,0x03,0x07,0x01,0x02,0x01,0x01,0x03, /* [ 7727] OBJ_id_tc26_gost_3410_2012_256_paramSetC */
|
0x2A,0x85,0x03,0x07,0x01,0x02,0x01,0x01,0x03, /* [ 7727] OBJ_id_tc26_gost_3410_2012_256_paramSetC */
|
||||||
0x2A,0x85,0x03,0x07,0x01,0x02,0x01,0x01,0x04, /* [ 7736] OBJ_id_tc26_gost_3410_2012_256_paramSetD */
|
0x2A,0x85,0x03,0x07,0x01,0x02,0x01,0x01,0x04, /* [ 7736] OBJ_id_tc26_gost_3410_2012_256_paramSetD */
|
||||||
|
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x0C, /* [ 7745] OBJ_hmacWithSHA512_224 */
|
||||||
|
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x0D, /* [ 7753] OBJ_hmacWithSHA512_256 */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NUM_NID 1193
|
#define NUM_NID 1195
|
||||||
static const ASN1_OBJECT nid_objs[NUM_NID] = {
|
static const ASN1_OBJECT nid_objs[NUM_NID] = {
|
||||||
{"UNDEF", "undefined", NID_undef},
|
{"UNDEF", "undefined", NID_undef},
|
||||||
{"rsadsi", "RSA Data Security, Inc.", NID_rsadsi, 6, &so[0]},
|
{"rsadsi", "RSA Data Security, Inc.", NID_rsadsi, 6, &so[0]},
|
||||||
@@ -2271,9 +2273,11 @@ static const ASN1_OBJECT nid_objs[NUM_NID] = {
|
|||||||
{"magma-cbc", "magma-cbc", NID_magma_cbc},
|
{"magma-cbc", "magma-cbc", NID_magma_cbc},
|
||||||
{"magma-cfb", "magma-cfb", NID_magma_cfb},
|
{"magma-cfb", "magma-cfb", NID_magma_cfb},
|
||||||
{"magma-mac", "magma-mac", NID_magma_mac},
|
{"magma-mac", "magma-mac", NID_magma_mac},
|
||||||
|
{"hmacWithSHA512-224", "hmacWithSHA512-224", NID_hmacWithSHA512_224, 8, &so[7745]},
|
||||||
|
{"hmacWithSHA512-256", "hmacWithSHA512-256", NID_hmacWithSHA512_256, 8, &so[7753]},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NUM_SN 1184
|
#define NUM_SN 1186
|
||||||
static const unsigned int sn_objs[NUM_SN] = {
|
static const unsigned int sn_objs[NUM_SN] = {
|
||||||
364, /* "AD_DVCS" */
|
364, /* "AD_DVCS" */
|
||||||
419, /* "AES-128-CBC" */
|
419, /* "AES-128-CBC" */
|
||||||
@@ -2757,6 +2761,8 @@ static const unsigned int sn_objs[NUM_SN] = {
|
|||||||
799, /* "hmacWithSHA256" */
|
799, /* "hmacWithSHA256" */
|
||||||
800, /* "hmacWithSHA384" */
|
800, /* "hmacWithSHA384" */
|
||||||
801, /* "hmacWithSHA512" */
|
801, /* "hmacWithSHA512" */
|
||||||
|
1193, /* "hmacWithSHA512-224" */
|
||||||
|
1194, /* "hmacWithSHA512-256" */
|
||||||
432, /* "holdInstructionCallIssuer" */
|
432, /* "holdInstructionCallIssuer" */
|
||||||
430, /* "holdInstructionCode" */
|
430, /* "holdInstructionCode" */
|
||||||
431, /* "holdInstructionNone" */
|
431, /* "holdInstructionNone" */
|
||||||
@@ -3461,7 +3467,7 @@ static const unsigned int sn_objs[NUM_SN] = {
|
|||||||
1093, /* "x509ExtAdmission" */
|
1093, /* "x509ExtAdmission" */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NUM_LN 1184
|
#define NUM_LN 1186
|
||||||
static const unsigned int ln_objs[NUM_LN] = {
|
static const unsigned int ln_objs[NUM_LN] = {
|
||||||
363, /* "AD Time Stamping" */
|
363, /* "AD Time Stamping" */
|
||||||
405, /* "ANSI X9.62" */
|
405, /* "ANSI X9.62" */
|
||||||
@@ -3981,6 +3987,8 @@ static const unsigned int ln_objs[NUM_LN] = {
|
|||||||
799, /* "hmacWithSHA256" */
|
799, /* "hmacWithSHA256" */
|
||||||
800, /* "hmacWithSHA384" */
|
800, /* "hmacWithSHA384" */
|
||||||
801, /* "hmacWithSHA512" */
|
801, /* "hmacWithSHA512" */
|
||||||
|
1193, /* "hmacWithSHA512-224" */
|
||||||
|
1194, /* "hmacWithSHA512-256" */
|
||||||
486, /* "homePostalAddress" */
|
486, /* "homePostalAddress" */
|
||||||
473, /* "homeTelephoneNumber" */
|
473, /* "homeTelephoneNumber" */
|
||||||
466, /* "host" */
|
466, /* "host" */
|
||||||
@@ -4649,7 +4657,7 @@ static const unsigned int ln_objs[NUM_LN] = {
|
|||||||
125, /* "zlib compression" */
|
125, /* "zlib compression" */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NUM_OBJ 1069
|
#define NUM_OBJ 1071
|
||||||
static const unsigned int obj_objs[NUM_OBJ] = {
|
static const unsigned int obj_objs[NUM_OBJ] = {
|
||||||
0, /* OBJ_undef 0 */
|
0, /* OBJ_undef 0 */
|
||||||
181, /* OBJ_iso 1 */
|
181, /* OBJ_iso 1 */
|
||||||
@@ -5161,6 +5169,8 @@ static const unsigned int obj_objs[NUM_OBJ] = {
|
|||||||
799, /* OBJ_hmacWithSHA256 1 2 840 113549 2 9 */
|
799, /* OBJ_hmacWithSHA256 1 2 840 113549 2 9 */
|
||||||
800, /* OBJ_hmacWithSHA384 1 2 840 113549 2 10 */
|
800, /* OBJ_hmacWithSHA384 1 2 840 113549 2 10 */
|
||||||
801, /* OBJ_hmacWithSHA512 1 2 840 113549 2 11 */
|
801, /* OBJ_hmacWithSHA512 1 2 840 113549 2 11 */
|
||||||
|
1193, /* OBJ_hmacWithSHA512_224 1 2 840 113549 2 12 */
|
||||||
|
1194, /* OBJ_hmacWithSHA512_256 1 2 840 113549 2 13 */
|
||||||
37, /* OBJ_rc2_cbc 1 2 840 113549 3 2 */
|
37, /* OBJ_rc2_cbc 1 2 840 113549 3 2 */
|
||||||
5, /* OBJ_rc4 1 2 840 113549 3 4 */
|
5, /* OBJ_rc4 1 2 840 113549 3 4 */
|
||||||
44, /* OBJ_des_ede3_cbc 1 2 840 113549 3 7 */
|
44, /* OBJ_des_ede3_cbc 1 2 840 113549 3 7 */
|
||||||
|
|||||||
@@ -1190,3 +1190,5 @@ magma_ofb 1189
|
|||||||
magma_cbc 1190
|
magma_cbc 1190
|
||||||
magma_cfb 1191
|
magma_cfb 1191
|
||||||
magma_mac 1192
|
magma_mac 1192
|
||||||
|
hmacWithSHA512_224 1193
|
||||||
|
hmacWithSHA512_256 1194
|
||||||
@@ -391,6 +391,10 @@ rsadsi 2 9 : : hmacWithSHA256
|
|||||||
rsadsi 2 10 : : hmacWithSHA384
|
rsadsi 2 10 : : hmacWithSHA384
|
||||||
rsadsi 2 11 : : hmacWithSHA512
|
rsadsi 2 11 : : hmacWithSHA512
|
||||||
|
|
||||||
|
# From RFC8018
|
||||||
|
rsadsi 2 12 : : hmacWithSHA512-224
|
||||||
|
rsadsi 2 13 : : hmacWithSHA512-256
|
||||||
|
|
||||||
rsadsi 3 2 : RC2-CBC : rc2-cbc
|
rsadsi 3 2 : RC2-CBC : rc2-cbc
|
||||||
: RC2-ECB : rc2-ecb
|
: RC2-ECB : rc2-ecb
|
||||||
!Cname rc2-cfb64
|
!Cname rc2-cfb64
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ ASN1_ADB_TEMPLATE(safebag_default) = ASN1_EXP(PKCS12_SAFEBAG, value.other, ASN1_
|
|||||||
ASN1_ADB(PKCS12_SAFEBAG) = {
|
ASN1_ADB(PKCS12_SAFEBAG) = {
|
||||||
ADB_ENTRY(NID_keyBag, ASN1_EXP(PKCS12_SAFEBAG, value.keybag, PKCS8_PRIV_KEY_INFO, 0)),
|
ADB_ENTRY(NID_keyBag, ASN1_EXP(PKCS12_SAFEBAG, value.keybag, PKCS8_PRIV_KEY_INFO, 0)),
|
||||||
ADB_ENTRY(NID_pkcs8ShroudedKeyBag, ASN1_EXP(PKCS12_SAFEBAG, value.shkeybag, X509_SIG, 0)),
|
ADB_ENTRY(NID_pkcs8ShroudedKeyBag, ASN1_EXP(PKCS12_SAFEBAG, value.shkeybag, X509_SIG, 0)),
|
||||||
ADB_ENTRY(NID_safeContentsBag, ASN1_EXP_SET_OF(PKCS12_SAFEBAG, value.safes, PKCS12_SAFEBAG, 0)),
|
ADB_ENTRY(NID_safeContentsBag, ASN1_EXP_SEQUENCE_OF(PKCS12_SAFEBAG, value.safes, PKCS12_SAFEBAG, 0)),
|
||||||
ADB_ENTRY(NID_certBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)),
|
ADB_ENTRY(NID_certBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)),
|
||||||
ADB_ENTRY(NID_crlBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)),
|
ADB_ENTRY(NID_crlBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)),
|
||||||
ADB_ENTRY(NID_secretBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0))
|
ADB_ENTRY(NID_secretBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0))
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ size_t rand_drbg_get_entropy(RAND_DRBG *drbg,
|
|||||||
if (RAND_DRBG_generate(drbg->parent,
|
if (RAND_DRBG_generate(drbg->parent,
|
||||||
buffer, bytes_needed,
|
buffer, bytes_needed,
|
||||||
prediction_resistance,
|
prediction_resistance,
|
||||||
(unsigned char *)drbg, sizeof(*drbg)) != 0)
|
NULL, 0) != 0)
|
||||||
bytes = bytes_needed;
|
bytes = bytes_needed;
|
||||||
rand_drbg_unlock(drbg->parent);
|
rand_drbg_unlock(drbg->parent);
|
||||||
|
|
||||||
|
|||||||
@@ -339,7 +339,8 @@ static int rsa_ossl_private_encrypt(int flen, const unsigned char *from,
|
|||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (padding == RSA_X931_PADDING) {
|
if (padding == RSA_X931_PADDING) {
|
||||||
BN_sub(f, rsa->n, ret);
|
if (!BN_sub(f, rsa->n, ret))
|
||||||
|
goto err;
|
||||||
if (BN_cmp(ret, f) > 0)
|
if (BN_cmp(ret, f) > 0)
|
||||||
res = f;
|
res = f;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ static size_t ec_field_size(const EC_GROUP *group)
|
|||||||
if (p == NULL || a == NULL || b == NULL)
|
if (p == NULL || a == NULL || b == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (!EC_GROUP_get_curve_GFp(group, p, a, b, NULL))
|
if (!EC_GROUP_get_curve(group, p, a, b, NULL))
|
||||||
goto done;
|
goto done;
|
||||||
field_size = (BN_num_bits(p) + 7) / 8;
|
field_size = (BN_num_bits(p) + 7) / 8;
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ int sm2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len,
|
|||||||
if (field_size == 0 || md_size < 0)
|
if (field_size == 0 || md_size < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
*ct_size = 10 + 2 * field_size + (size_t)md_size + msg_len;
|
*ct_size = 12 + 2 * field_size + (size_t)md_size + msg_len;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,9 +176,9 @@ int sm2_encrypt(const EC_KEY *key,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!EC_POINT_mul(group, kG, k, NULL, NULL, ctx)
|
if (!EC_POINT_mul(group, kG, k, NULL, NULL, ctx)
|
||||||
|| !EC_POINT_get_affine_coordinates_GFp(group, kG, x1, y1, ctx)
|
|| !EC_POINT_get_affine_coordinates(group, kG, x1, y1, ctx)
|
||||||
|| !EC_POINT_mul(group, kP, NULL, P, k, ctx)
|
|| !EC_POINT_mul(group, kP, NULL, P, k, ctx)
|
||||||
|| !EC_POINT_get_affine_coordinates_GFp(group, kP, x2, y2, ctx)) {
|
|| !EC_POINT_get_affine_coordinates(group, kP, x2, y2, ctx)) {
|
||||||
SM2err(SM2_F_SM2_ENCRYPT, ERR_R_EC_LIB);
|
SM2err(SM2_F_SM2_ENCRYPT, ERR_R_EC_LIB);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@@ -326,11 +326,11 @@ int sm2_decrypt(const EC_KEY *key,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EC_POINT_set_affine_coordinates_GFp(group, C1, sm2_ctext->C1x,
|
if (!EC_POINT_set_affine_coordinates(group, C1, sm2_ctext->C1x,
|
||||||
sm2_ctext->C1y, ctx)
|
sm2_ctext->C1y, ctx)
|
||||||
|| !EC_POINT_mul(group, C1, NULL, C1, EC_KEY_get0_private_key(key),
|
|| !EC_POINT_mul(group, C1, NULL, C1, EC_KEY_get0_private_key(key),
|
||||||
ctx)
|
ctx)
|
||||||
|| !EC_POINT_get_affine_coordinates_GFp(group, C1, x2, y2, ctx)) {
|
|| !EC_POINT_get_affine_coordinates(group, C1, x2, y2, ctx)) {
|
||||||
SM2err(SM2_F_SM2_DECRYPT, ERR_R_EC_LIB);
|
SM2err(SM2_F_SM2_DECRYPT, ERR_R_EC_LIB);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ static ECDSA_SIG *sm2_sig_gen(const EC_KEY *key, const BIGNUM *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!EC_POINT_mul(group, kG, k, NULL, NULL, ctx)
|
if (!EC_POINT_mul(group, kG, k, NULL, NULL, ctx)
|
||||||
|| !EC_POINT_get_affine_coordinates_GFp(group, kG, x1, NULL,
|
|| !EC_POINT_get_affine_coordinates(group, kG, x1, NULL,
|
||||||
ctx)
|
ctx)
|
||||||
|| !BN_mod_add(r, e, x1, order, ctx)) {
|
|| !BN_mod_add(r, e, x1, order, ctx)) {
|
||||||
SM2err(SM2_F_SM2_SIG_GEN, ERR_R_INTERNAL_ERROR);
|
SM2err(SM2_F_SM2_SIG_GEN, ERR_R_INTERNAL_ERROR);
|
||||||
@@ -224,7 +224,7 @@ static int sm2_sig_verify(const EC_KEY *key, const ECDSA_SIG *sig,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!EC_POINT_mul(group, pt, s, EC_KEY_get0_public_key(key), t, ctx)
|
if (!EC_POINT_mul(group, pt, s, EC_KEY_get0_public_key(key), t, ctx)
|
||||||
|| !EC_POINT_get_affine_coordinates_GFp(group, pt, x1, NULL, ctx)) {
|
|| !EC_POINT_get_affine_coordinates(group, pt, x1, NULL, ctx)) {
|
||||||
SM2err(SM2_F_SM2_SIG_VERIFY, ERR_R_EC_LIB);
|
SM2err(SM2_F_SM2_SIG_VERIFY, ERR_R_EC_LIB);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -87,7 +87,7 @@ int sm2_compute_userid_digest(uint8_t *out,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EC_GROUP_get_curve_GFp(group, p, a, b, ctx)) {
|
if (!EC_GROUP_get_curve(group, p, a, b, ctx)) {
|
||||||
SM2err(SM2_F_SM2_COMPUTE_USERID_DIGEST, ERR_R_EC_LIB);
|
SM2err(SM2_F_SM2_COMPUTE_USERID_DIGEST, ERR_R_EC_LIB);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@@ -103,14 +103,14 @@ int sm2_compute_userid_digest(uint8_t *out,
|
|||||||
|| !EVP_DigestUpdate(hash, buf, p_bytes)
|
|| !EVP_DigestUpdate(hash, buf, p_bytes)
|
||||||
|| BN_bn2binpad(b, buf, p_bytes) < 0
|
|| BN_bn2binpad(b, buf, p_bytes) < 0
|
||||||
|| !EVP_DigestUpdate(hash, buf, p_bytes)
|
|| !EVP_DigestUpdate(hash, buf, p_bytes)
|
||||||
|| !EC_POINT_get_affine_coordinates_GFp(group,
|
|| !EC_POINT_get_affine_coordinates(group,
|
||||||
EC_GROUP_get0_generator(group),
|
EC_GROUP_get0_generator(group),
|
||||||
xG, yG, ctx)
|
xG, yG, ctx)
|
||||||
|| BN_bn2binpad(xG, buf, p_bytes) < 0
|
|| BN_bn2binpad(xG, buf, p_bytes) < 0
|
||||||
|| !EVP_DigestUpdate(hash, buf, p_bytes)
|
|| !EVP_DigestUpdate(hash, buf, p_bytes)
|
||||||
|| BN_bn2binpad(yG, buf, p_bytes) < 0
|
|| BN_bn2binpad(yG, buf, p_bytes) < 0
|
||||||
|| !EVP_DigestUpdate(hash, buf, p_bytes)
|
|| !EVP_DigestUpdate(hash, buf, p_bytes)
|
||||||
|| !EC_POINT_get_affine_coordinates_GFp(group,
|
|| !EC_POINT_get_affine_coordinates(group,
|
||||||
EC_KEY_get0_public_key(key),
|
EC_KEY_get0_public_key(key),
|
||||||
xA, yA, ctx)
|
xA, yA, ctx)
|
||||||
|| BN_bn2binpad(xA, buf, p_bytes) < 0
|
|| BN_bn2binpad(xA, buf, p_bytes) < 0
|
||||||
|
|||||||
@@ -35,6 +35,10 @@
|
|||||||
# define stat _stat
|
# define stat _stat
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef S_ISDIR
|
||||||
|
# define S_ISDIR(a) (((a) & S_IFMT) == S_IFDIR)
|
||||||
|
#endif
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Password prompting
|
* Password prompting
|
||||||
* ------------------
|
* ------------------
|
||||||
@@ -839,7 +843,7 @@ static OSSL_STORE_LOADER_CTX *file_open(const OSSL_STORE_LOADER *loader,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((st.st_mode & S_IFDIR) == S_IFDIR) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
/*
|
/*
|
||||||
* Try to copy everything, even if we know that some of them must be
|
* Try to copy everything, even if we know that some of them must be
|
||||||
* NULL for the moment. This prevents errors in the future, when more
|
* NULL for the moment. This prevents errors in the future, when more
|
||||||
|
|||||||
+2
-3
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -22,10 +22,9 @@ int TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num)
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
char *hex;
|
char *hex;
|
||||||
|
|
||||||
num_bn = BN_new();
|
num_bn = ASN1_INTEGER_to_BN(num, NULL);
|
||||||
if (num_bn == NULL)
|
if (num_bn == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
ASN1_INTEGER_to_BN(num, num_bn);
|
|
||||||
if ((hex = BN_bn2hex(num_bn))) {
|
if ((hex = BN_bn2hex(num_bn))) {
|
||||||
result = BIO_write(bio, "0x", 2) > 0;
|
result = BIO_write(bio, "0x", 2) > 0;
|
||||||
result = result && BIO_write(bio, hex, strlen(hex)) > 0;
|
result = result && BIO_write(bio, hex, strlen(hex)) > 0;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
* If unistd.h defines _POSIX_VERSION, we conclude that we are on a POSIX
|
* If unistd.h defines _POSIX_VERSION, we conclude that we are on a POSIX
|
||||||
* system and have sigaction and termios.
|
* system and have sigaction and termios.
|
||||||
*/
|
*/
|
||||||
# if defined(_POSIX_VERSION)
|
# if defined(_POSIX_VERSION) && _POSIX_VERSION>=199309L
|
||||||
|
|
||||||
# define SIGACTION
|
# define SIGACTION
|
||||||
# if !defined(TERMIOS) && !defined(TERMIO) && !defined(SGTTY)
|
# if !defined(TERMIOS) && !defined(TERMIO) && !defined(SGTTY)
|
||||||
|
|||||||
@@ -122,13 +122,12 @@ static TLS_FEATURE *v2i_TLS_FEATURE(const X509V3_EXT_METHOD *method,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ai = ASN1_INTEGER_new();
|
if ((ai = ASN1_INTEGER_new()) == NULL
|
||||||
if (ai == NULL) {
|
|| !ASN1_INTEGER_set(ai, tlsextid)
|
||||||
|
|| sk_ASN1_INTEGER_push(tlsf, ai) <= 0) {
|
||||||
X509V3err(X509V3_F_V2I_TLS_FEATURE, ERR_R_MALLOC_FAILURE);
|
X509V3err(X509V3_F_V2I_TLS_FEATURE, ERR_R_MALLOC_FAILURE);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
ASN1_INTEGER_set(ai, tlsextid);
|
|
||||||
sk_ASN1_INTEGER_push(tlsf, ai);
|
|
||||||
}
|
}
|
||||||
return tlsf;
|
return tlsf;
|
||||||
|
|
||||||
|
|||||||
+5
-23
@@ -73,30 +73,12 @@ L<SSL_CIPHER_description(3)>.
|
|||||||
|
|
||||||
Like B<-v>, but include the official cipher suite values in hex.
|
Like B<-v>, but include the official cipher suite values in hex.
|
||||||
|
|
||||||
=item B<-tls1_3>
|
=item B<-tls1_3>, B<-tls1_2>, B<-tls1_1>, B<-tls1>, B<-ssl3>
|
||||||
|
|
||||||
In combination with the B<-s> option, list the ciphers which would be used if
|
In combination with the B<-s> option, list the ciphers which could be used if
|
||||||
TLSv1.3 were negotiated.
|
the specified protocol were negotiated.
|
||||||
|
Note that not all protocols and flags may be available, depending on how
|
||||||
=item B<-tls1_2>
|
OpenSSL was built.
|
||||||
|
|
||||||
In combination with the B<-s> option, list the ciphers which would be used if
|
|
||||||
TLSv1.2 were negotiated.
|
|
||||||
|
|
||||||
=item B<-ssl3>
|
|
||||||
|
|
||||||
In combination with the B<-s> option, list the ciphers which would be used if
|
|
||||||
SSLv3 were negotiated.
|
|
||||||
|
|
||||||
=item B<-tls1>
|
|
||||||
|
|
||||||
In combination with the B<-s> option, list the ciphers which would be used if
|
|
||||||
TLSv1 were negotiated.
|
|
||||||
|
|
||||||
=item B<-tls1_1>
|
|
||||||
|
|
||||||
In combination with the B<-s> option, list the ciphers which would be used if
|
|
||||||
TLSv1.1 were negotiated.
|
|
||||||
|
|
||||||
=item B<-stdname>
|
=item B<-stdname>
|
||||||
|
|
||||||
|
|||||||
@@ -473,6 +473,8 @@ By default B<s_client> will negotiate the highest mutually supported protocol
|
|||||||
version.
|
version.
|
||||||
When a specific TLS version is required, only that version will be offered to
|
When a specific TLS version is required, only that version will be offered to
|
||||||
and accepted from the server.
|
and accepted from the server.
|
||||||
|
Note that not all protocols and flags may be available, depending on how
|
||||||
|
OpenSSL was built.
|
||||||
|
|
||||||
=item B<-dtls>, B<-dtls1>, B<-dtls1_2>
|
=item B<-dtls>, B<-dtls1>, B<-dtls1_2>
|
||||||
|
|
||||||
|
|||||||
@@ -532,6 +532,8 @@ By default B<s_server> will negotiate the highest mutually supported protocol
|
|||||||
version.
|
version.
|
||||||
When a specific TLS version is required, only that version will be accepted
|
When a specific TLS version is required, only that version will be accepted
|
||||||
from the client.
|
from the client.
|
||||||
|
Note that not all protocols and flags may be available, depending on how
|
||||||
|
OpenSSL was built.
|
||||||
|
|
||||||
=item B<-bugs>
|
=item B<-bugs>
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -112,16 +112,19 @@ specified, they are both on by default and executed in sequence.
|
|||||||
|
|
||||||
=item B<-ssl3>
|
=item B<-ssl3>
|
||||||
|
|
||||||
These options disable the use of certain SSL or TLS protocols. By default
|
This option disables the use of SSL version 3. By default
|
||||||
the initial handshake uses a method which should be compatible with all
|
the initial handshake uses a method which should be compatible with all
|
||||||
servers and permit them to use SSL v3 or TLS as appropriate.
|
servers and permit them to use SSL v3 or TLS as appropriate.
|
||||||
|
|
||||||
The timing program is not as rich in options to turn protocols on and off as
|
The timing program is not as rich in options to turn protocols on and off as
|
||||||
the L<s_client(1)> program and may not connect to all servers.
|
the L<s_client(1)> program and may not connect to all servers.
|
||||||
|
|
||||||
Unfortunately there are a lot of ancient and broken servers in use which
|
Unfortunately there are a lot of ancient and broken servers in use which
|
||||||
cannot handle this technique and will fail to connect. Some servers only
|
cannot handle this technique and will fail to connect. Some servers only
|
||||||
work if TLS is turned off with the B<-ssl3> option.
|
work if TLS is turned off with the B<-ssl3> option.
|
||||||
|
|
||||||
|
Note that this option may not be available, depending on how
|
||||||
|
OpenSSL was built.
|
||||||
|
|
||||||
=item B<-bugs>
|
=item B<-bugs>
|
||||||
|
|
||||||
There are several known bug in SSL and TLS implementations. Adding this
|
There are several known bug in SSL and TLS implementations. Adding this
|
||||||
|
|||||||
@@ -72,6 +72,11 @@ B<BN_GENCB_call(cb, 1, j)> is called as described below.
|
|||||||
|
|
||||||
When a prime has been found, B<BN_GENCB_call(cb, 2, i)> is called.
|
When a prime has been found, B<BN_GENCB_call(cb, 2, i)> is called.
|
||||||
|
|
||||||
|
=item *
|
||||||
|
|
||||||
|
The callers of BN_generate_prime_ex() may call B<BN_GENCB_call(cb, i, j)> with
|
||||||
|
other values as described in their respective man pages; see L</SEE ALSO>.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
The prime may have to fulfill additional requirements for use in
|
The prime may have to fulfill additional requirements for use in
|
||||||
@@ -101,7 +106,17 @@ If B<do_trial_division == 0>, this test is skipped.
|
|||||||
Both BN_is_prime_ex() and BN_is_prime_fasttest_ex() perform a Miller-Rabin
|
Both BN_is_prime_ex() and BN_is_prime_fasttest_ex() perform a Miller-Rabin
|
||||||
probabilistic primality test with B<nchecks> iterations. If
|
probabilistic primality test with B<nchecks> iterations. If
|
||||||
B<nchecks == BN_prime_checks>, a number of iterations is used that
|
B<nchecks == BN_prime_checks>, a number of iterations is used that
|
||||||
yields a false positive rate of at most 2^-80 for random input.
|
yields a false positive rate of at most 2^-64 for random input.
|
||||||
|
The error rate depends on the size of the prime and goes down for bigger primes.
|
||||||
|
The rate is 2^-80 starting at 308 bits, 2^-112 at 852 bits, 2^-128 at 1080 bits,
|
||||||
|
2^-192 at 3747 bits and 2^-256 at 6394 bits.
|
||||||
|
|
||||||
|
When the source of the prime is not random or not trusted, the number
|
||||||
|
of checks needs to be much higher to reach the same level of assurance:
|
||||||
|
It should equal half of the targeted security level in bits (rounded up to the
|
||||||
|
next integer if necessary).
|
||||||
|
For instance, to reach the 128 bit security level, B<nchecks> should be set to
|
||||||
|
64.
|
||||||
|
|
||||||
If B<cb> is not B<NULL>, B<BN_GENCB_call(cb, 1, j)> is called
|
If B<cb> is not B<NULL>, B<BN_GENCB_call(cb, 1, j)> is called
|
||||||
after the j-th iteration (j = 0, 1, ...). B<ctx> is a
|
after the j-th iteration (j = 0, 1, ...). B<ctx> is a
|
||||||
@@ -177,7 +192,8 @@ Instead applications should create a BN_GENCB structure using BN_GENCB_new:
|
|||||||
|
|
||||||
=head1 SEE ALSO
|
=head1 SEE ALSO
|
||||||
|
|
||||||
L<ERR_get_error(3)>, L<RAND_bytes(3)>
|
L<DH_generate_parameters(3)>, L<DSA_generate_parameters(3)>,
|
||||||
|
L<RSA_generate_key(3)>, L<ERR_get_error(3)>, L<RAND_bytes(3)>
|
||||||
|
|
||||||
=head1 HISTORY
|
=head1 HISTORY
|
||||||
|
|
||||||
|
|||||||
+33
-15
@@ -2,12 +2,22 @@
|
|||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
EC_GROUP_get_ecparameters, EC_GROUP_get_ecpkparameters,
|
EC_GROUP_get_ecparameters,
|
||||||
EC_GROUP_new, EC_GROUP_new_from_ecparameters,
|
EC_GROUP_get_ecpkparameters,
|
||||||
|
EC_GROUP_new,
|
||||||
|
EC_GROUP_new_from_ecparameters,
|
||||||
EC_GROUP_new_from_ecpkparameters,
|
EC_GROUP_new_from_ecpkparameters,
|
||||||
EC_GROUP_free, EC_GROUP_clear_free, EC_GROUP_new_curve_GFp,
|
EC_GROUP_free,
|
||||||
EC_GROUP_new_curve_GF2m, EC_GROUP_new_by_curve_name, EC_GROUP_set_curve_GFp,
|
EC_GROUP_clear_free,
|
||||||
EC_GROUP_get_curve_GFp, EC_GROUP_set_curve_GF2m, EC_GROUP_get_curve_GF2m,
|
EC_GROUP_new_curve_GFp,
|
||||||
|
EC_GROUP_new_curve_GF2m,
|
||||||
|
EC_GROUP_new_by_curve_name,
|
||||||
|
EC_GROUP_set_curve,
|
||||||
|
EC_GROUP_get_curve,
|
||||||
|
EC_GROUP_set_curve_GFp,
|
||||||
|
EC_GROUP_get_curve_GFp,
|
||||||
|
EC_GROUP_set_curve_GF2m,
|
||||||
|
EC_GROUP_get_curve_GF2m,
|
||||||
EC_get_builtin_curves - Functions for creating and destroying EC_GROUP
|
EC_get_builtin_curves - Functions for creating and destroying EC_GROUP
|
||||||
objects
|
objects
|
||||||
|
|
||||||
@@ -27,6 +37,10 @@ objects
|
|||||||
const BIGNUM *b, BN_CTX *ctx);
|
const BIGNUM *b, BN_CTX *ctx);
|
||||||
EC_GROUP *EC_GROUP_new_by_curve_name(int nid);
|
EC_GROUP *EC_GROUP_new_by_curve_name(int nid);
|
||||||
|
|
||||||
|
int EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
|
||||||
|
const BIGNUM *b, BN_CTX *ctx);
|
||||||
|
int EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b,
|
||||||
|
BN_CTX *ctx);
|
||||||
int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p,
|
int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p,
|
||||||
const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
|
const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
|
||||||
int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p,
|
int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p,
|
||||||
@@ -58,22 +72,26 @@ Operations in a binary field are performed relative to an B<irreducible polynomi
|
|||||||
use a trinomial or a pentanomial for this parameter.
|
use a trinomial or a pentanomial for this parameter.
|
||||||
|
|
||||||
A new curve can be constructed by calling EC_GROUP_new, using the implementation provided by B<meth> (see
|
A new curve can be constructed by calling EC_GROUP_new, using the implementation provided by B<meth> (see
|
||||||
L<EC_GFp_simple_method(3)>). It is then necessary to call either EC_GROUP_set_curve_GFp or
|
L<EC_GFp_simple_method(3)>). It is then necessary to call EC_GROUP_set_curve() to set the curve parameters.
|
||||||
EC_GROUP_set_curve_GF2m as appropriate to create a curve defined over Fp or over F2^m respectively.
|
|
||||||
EC_GROUP_new_from_ecparameters() will create a group from the
|
EC_GROUP_new_from_ecparameters() will create a group from the
|
||||||
specified B<params> and
|
specified B<params> and
|
||||||
EC_GROUP_new_from_ecpkparameters() will create a group from the specific PK B<params>.
|
EC_GROUP_new_from_ecpkparameters() will create a group from the specific PK B<params>.
|
||||||
|
|
||||||
EC_GROUP_set_curve_GFp sets the curve parameters B<p>, B<a> and B<b> for a curve over Fp stored in B<group>.
|
EC_GROUP_set_curve() sets the curve parameters B<p>, B<a> and B<b>. For a curve over Fp B<b>
|
||||||
EC_group_get_curve_GFp obtains the previously set curve parameters.
|
is the prime for the field. For a curve over F2^m B<p> represents the irreducible polynomial - each bit
|
||||||
|
represents a term in the polynomial. Therefore there will either be three or five bits set dependent on whether
|
||||||
|
the polynomial is a trinomial or a pentanomial.
|
||||||
|
|
||||||
EC_GROUP_set_curve_GF2m sets the equivalent curve parameters for a curve over F2^m. In this case B<p> represents
|
EC_group_get_curve() obtains the previously set curve parameters.
|
||||||
the irreducible polynomial - each bit represents a term in the polynomial. Therefore there will either be three
|
|
||||||
or five bits set dependent on whether the polynomial is a trinomial or a pentanomial.
|
|
||||||
EC_group_get_curve_GF2m obtains the previously set curve parameters.
|
|
||||||
|
|
||||||
The functions EC_GROUP_new_curve_GFp and EC_GROUP_new_curve_GF2m are shortcuts for calling EC_GROUP_new and the
|
EC_GROUP_set_curve_GFp() and EC_GROUP_set_curve_GF2m() are synonyms for EC_GROUP_set_curve(). They are defined for
|
||||||
appropriate EC_group_set_curve function. An appropriate default implementation method will be used.
|
backwards compatibility only and should not be used.
|
||||||
|
|
||||||
|
EC_GROUP_get_curve_GFp() and EC_GROUP_get_curve_GF2m() are synonyms for EC_GROUP_get_curve(). They are defined for
|
||||||
|
backwards compatibility only and should not be used.
|
||||||
|
|
||||||
|
The functions EC_GROUP_new_curve_GFp and EC_GROUP_new_curve_GF2m are shortcuts for calling EC_GROUP_new and then the
|
||||||
|
EC_GROUP_set_curve function. An appropriate default implementation method will be used.
|
||||||
|
|
||||||
Whilst the library can be used to create any curve using the functions described above, there are also a number of
|
Whilst the library can be used to create any curve using the functions described above, there are also a number of
|
||||||
predefined curves that are available. In order to obtain a list of all of the predefined curves, call the function
|
predefined curves that are available. In order to obtain a list of all of the predefined curves, call the function
|
||||||
|
|||||||
+49
-15
@@ -2,16 +2,30 @@
|
|||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
EC_POINT_set_Jprojective_coordinates_GFp, EC_POINT_point2buf,
|
EC_POINT_set_Jprojective_coordinates_GFp,
|
||||||
EC_POINT_new, EC_POINT_free, EC_POINT_clear_free,
|
EC_POINT_point2buf,
|
||||||
EC_POINT_copy, EC_POINT_dup, EC_POINT_method_of,
|
EC_POINT_new,
|
||||||
|
EC_POINT_free,
|
||||||
|
EC_POINT_clear_free,
|
||||||
|
EC_POINT_copy,
|
||||||
|
EC_POINT_dup,
|
||||||
|
EC_POINT_method_of,
|
||||||
EC_POINT_set_to_infinity,
|
EC_POINT_set_to_infinity,
|
||||||
EC_POINT_get_Jprojective_coordinates_GFp,
|
EC_POINT_get_Jprojective_coordinates_GFp,
|
||||||
|
EC_POINT_set_affine_coordinates,
|
||||||
|
EC_POINT_get_affine_coordinates,
|
||||||
|
EC_POINT_set_compressed_coordinates,
|
||||||
EC_POINT_set_affine_coordinates_GFp,
|
EC_POINT_set_affine_coordinates_GFp,
|
||||||
EC_POINT_get_affine_coordinates_GFp, EC_POINT_set_compressed_coordinates_GFp,
|
EC_POINT_get_affine_coordinates_GFp,
|
||||||
EC_POINT_set_affine_coordinates_GF2m, EC_POINT_get_affine_coordinates_GF2m,
|
EC_POINT_set_compressed_coordinates_GFp,
|
||||||
EC_POINT_set_compressed_coordinates_GF2m, EC_POINT_point2oct,
|
EC_POINT_set_affine_coordinates_GF2m,
|
||||||
EC_POINT_oct2point, EC_POINT_point2bn, EC_POINT_bn2point, EC_POINT_point2hex,
|
EC_POINT_get_affine_coordinates_GF2m,
|
||||||
|
EC_POINT_set_compressed_coordinates_GF2m,
|
||||||
|
EC_POINT_point2oct,
|
||||||
|
EC_POINT_oct2point,
|
||||||
|
EC_POINT_point2bn,
|
||||||
|
EC_POINT_bn2point,
|
||||||
|
EC_POINT_point2hex,
|
||||||
EC_POINT_hex2point
|
EC_POINT_hex2point
|
||||||
- Functions for creating, destroying and manipulating EC_POINT objects
|
- Functions for creating, destroying and manipulating EC_POINT objects
|
||||||
|
|
||||||
@@ -34,6 +48,14 @@ EC_POINT_hex2point
|
|||||||
const EC_POINT *p,
|
const EC_POINT *p,
|
||||||
BIGNUM *x, BIGNUM *y, BIGNUM *z,
|
BIGNUM *x, BIGNUM *y, BIGNUM *z,
|
||||||
BN_CTX *ctx);
|
BN_CTX *ctx);
|
||||||
|
int EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *p,
|
||||||
|
const BIGNUM *x, const BIGNUM *y,
|
||||||
|
BN_CTX *ctx);
|
||||||
|
int EC_POINT_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *p,
|
||||||
|
BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
|
||||||
|
int EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *p,
|
||||||
|
const BIGNUM *x, int y_bit,
|
||||||
|
BN_CTX *ctx);
|
||||||
int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
|
int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
|
||||||
const BIGNUM *x, const BIGNUM *y,
|
const BIGNUM *x, const BIGNUM *y,
|
||||||
BN_CTX *ctx);
|
BN_CTX *ctx);
|
||||||
@@ -97,12 +119,20 @@ A valid point on a curve is the special point at infinity. A point is set to
|
|||||||
be at infinity by calling EC_POINT_set_to_infinity().
|
be at infinity by calling EC_POINT_set_to_infinity().
|
||||||
|
|
||||||
The affine co-ordinates for a point describe a point in terms of its x and y
|
The affine co-ordinates for a point describe a point in terms of its x and y
|
||||||
position. The functions EC_POINT_set_affine_coordinates_GFp() and
|
position. The function EC_POINT_set_affine_coordinates() sets the B<x> and B<y>
|
||||||
EC_POINT_set_affine_coordinates_GF2m() set the B<x> and B<y> co-ordinates for
|
co-ordinates for the point B<p> defined over the curve given in B<group>. The
|
||||||
the point B<p> defined over the curve given in B<group>. The functions
|
function EC_POINT_get_affine_coordinates() sets B<x> and B<y>, either of which
|
||||||
EC_POINT_get_affine_coordinates_GFp() and
|
may be NULL, to the corresponding coordinates of B<p>.
|
||||||
EC_POINT_get_affine_coordinates_GF2m() set B<x> and B<y>, either of which may
|
|
||||||
be NULL, to the corresponding coordinates of B<p>.
|
The functions EC_POINT_set_affine_coordinates_GFp() and
|
||||||
|
EC_POINT_set_affine_coordinates_GF2m() are synonyms for
|
||||||
|
EC_POINT_set_affine_coordinates(). They are defined for backwards compatibility
|
||||||
|
only and should not be used.
|
||||||
|
|
||||||
|
The functions EC_POINT_get_affine_coordinates_GFp() and
|
||||||
|
EC_POINT_get_affine_coordinates_GF2m() are synonyms for
|
||||||
|
EC_POINT_get_affine_coordinates(). They are defined for backwards compatibility
|
||||||
|
only and should not be used.
|
||||||
|
|
||||||
As well as the affine co-ordinates, a point can alternatively be described in
|
As well as the affine co-ordinates, a point can alternatively be described in
|
||||||
terms of its Jacobian projective co-ordinates (for Fp curves only). Jacobian
|
terms of its Jacobian projective co-ordinates (for Fp curves only). Jacobian
|
||||||
@@ -119,11 +149,15 @@ EC_POINT_get_Jprojective_coordinates_GFp() respectively.
|
|||||||
Points can also be described in terms of their compressed co-ordinates. For a
|
Points can also be described in terms of their compressed co-ordinates. For a
|
||||||
point (x, y), for any given value for x such that the point is on the curve
|
point (x, y), for any given value for x such that the point is on the curve
|
||||||
there will only ever be two possible values for y. Therefore a point can be set
|
there will only ever be two possible values for y. Therefore a point can be set
|
||||||
using the EC_POINT_set_compressed_coordinates_GFp() and
|
using the EC_POINT_set_compressed_coordinates() function where B<x> is the x
|
||||||
EC_POINT_set_compressed_coordinates_GF2m() functions where B<x> is the x
|
|
||||||
co-ordinate and B<y_bit> is a value 0 or 1 to identify which of the two
|
co-ordinate and B<y_bit> is a value 0 or 1 to identify which of the two
|
||||||
possible values for y should be used.
|
possible values for y should be used.
|
||||||
|
|
||||||
|
The functions EC_POINT_set_compressed_coordinates_GFp() and
|
||||||
|
EC_POINT_set_compressed_coordinates_GF2m() are synonyms for
|
||||||
|
EC_POINT_set_compressed_coordinates(). They are defined for backwards
|
||||||
|
compatibility only and should not be used.
|
||||||
|
|
||||||
In addition B<EC_POINT> can be converted to and from various external
|
In addition B<EC_POINT> can be converted to and from various external
|
||||||
representations. The octet form is the binary encoding of the B<ECPoint>
|
representations. The octet form is the binary encoding of the B<ECPoint>
|
||||||
structure (as defined in RFC5480 and used in certificates and TLS records):
|
structure (as defined in RFC5480 and used in certificates and TLS records):
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ SSL_get_state
|
|||||||
|
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
|
|
||||||
int SSL_in_init(SSL *s);
|
int SSL_in_init(const SSL *s);
|
||||||
int SSL_in_before(SSL *s);
|
int SSL_in_before(const SSL *s);
|
||||||
int SSL_is_init_finished(SSL *s);
|
int SSL_is_init_finished(const SSL *s);
|
||||||
|
|
||||||
int SSL_in_connect_init(SSL *s);
|
int SSL_in_connect_init(SSL *s);
|
||||||
int SSL_in_accept_init(SSL *s);
|
int SSL_in_accept_init(SSL *s);
|
||||||
|
|||||||
@@ -267,6 +267,19 @@ Nagle's algorithm. If an application opts to disable Nagle's algorithm
|
|||||||
consideration should be given to turning it back on again after the handshake is
|
consideration should be given to turning it back on again after the handshake is
|
||||||
complete if appropriate.
|
complete if appropriate.
|
||||||
|
|
||||||
|
In rare circumstances, it may be possible for a client to have a session that
|
||||||
|
reports a max early data value greater than 0, but where the server does not
|
||||||
|
support this. For example, this can occur if a server has had its configuration
|
||||||
|
changed to accept a lower max early data value such as by calling
|
||||||
|
SSL_CTX_set_recv_max_early_data(). Another example is if a server used to
|
||||||
|
support TLSv1.3 but was later downgraded to TLSv1.2. Sending early data to such
|
||||||
|
a server will cause the connection to abort. Clients that encounter an aborted
|
||||||
|
connection while sending early data may want to retry the connection without
|
||||||
|
sending early data as this does not happen automatically. A client will have to
|
||||||
|
establish a new transport layer connection to the server and attempt the SSL/TLS
|
||||||
|
connection again but without sending early data. Note that it is inadvisable to
|
||||||
|
retry with a lower maximum protocol version.
|
||||||
|
|
||||||
=head1 REPLAY PROTECTION
|
=head1 REPLAY PROTECTION
|
||||||
|
|
||||||
When early data is in use the TLS protocol provides no security guarantees that
|
When early data is in use the TLS protocol provides no security guarantees that
|
||||||
|
|||||||
@@ -1061,3 +1061,5 @@ OBJ_id_tc26_wrap_gostr3412_2015_kuznyechik_kexp15="\x2A\x85\x03\x07\x01\x01\x07\
|
|||||||
OBJ_id_tc26_gost_3410_2012_256_paramSetB="\x2A\x85\x03\x07\x01\x02\x01\x01\x02"
|
OBJ_id_tc26_gost_3410_2012_256_paramSetB="\x2A\x85\x03\x07\x01\x02\x01\x01\x02"
|
||||||
OBJ_id_tc26_gost_3410_2012_256_paramSetC="\x2A\x85\x03\x07\x01\x02\x01\x01\x03"
|
OBJ_id_tc26_gost_3410_2012_256_paramSetC="\x2A\x85\x03\x07\x01\x02\x01\x01\x03"
|
||||||
OBJ_id_tc26_gost_3410_2012_256_paramSetD="\x2A\x85\x03\x07\x01\x02\x01\x01\x04"
|
OBJ_id_tc26_gost_3410_2012_256_paramSetD="\x2A\x85\x03\x07\x01\x02\x01\x01\x04"
|
||||||
|
OBJ_hmacWithSHA512_224="\x2A\x86\x48\x86\xF7\x0D\x02\x0C"
|
||||||
|
OBJ_hmacWithSHA512_256="\x2A\x86\x48\x86\xF7\x0D\x02\x0D"
|
||||||
@@ -78,7 +78,6 @@ DEFINE_LHASH_OF(MEM);
|
|||||||
void OPENSSL_cpuid_setup(void);
|
void OPENSSL_cpuid_setup(void);
|
||||||
extern unsigned int OPENSSL_ia32cap_P[];
|
extern unsigned int OPENSSL_ia32cap_P[];
|
||||||
void OPENSSL_showfatal(const char *fmta, ...);
|
void OPENSSL_showfatal(const char *fmta, ...);
|
||||||
extern int OPENSSL_NONPIC_relocated;
|
|
||||||
void crypto_cleanup_all_ex_data_int(void);
|
void crypto_cleanup_all_ex_data_int(void);
|
||||||
int openssl_init_fork_handlers(void);
|
int openssl_init_fork_handlers(void);
|
||||||
|
|
||||||
|
|||||||
+69
-18
@@ -107,25 +107,76 @@ void *BN_GENCB_get_arg(BN_GENCB *cb);
|
|||||||
* on the size of the number */
|
* on the size of the number */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* number of Miller-Rabin iterations for an error rate of less than 2^-80 for
|
* BN_prime_checks_for_size() returns the number of Miller-Rabin iterations
|
||||||
* random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook of
|
* that will be done for checking that a random number is probably prime. The
|
||||||
* Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996];
|
* error rate for accepting a composite number as prime depends on the size of
|
||||||
* original paper: Damgaard, Landrock, Pomerance: Average case error
|
* the prime |b|. The error rates used are for calculating an RSA key with 2 primes,
|
||||||
* estimates for the strong probable prime test. -- Math. Comp. 61 (1993)
|
* and so the level is what you would expect for a key of double the size of the
|
||||||
* 177-194)
|
* prime.
|
||||||
|
*
|
||||||
|
* This table is generated using the algorithm of FIPS PUB 186-4
|
||||||
|
* Digital Signature Standard (DSS), section F.1, page 117.
|
||||||
|
* (https://dx.doi.org/10.6028/NIST.FIPS.186-4)
|
||||||
|
*
|
||||||
|
* The following magma script was used to generate the output:
|
||||||
|
* securitybits:=125;
|
||||||
|
* k:=1024;
|
||||||
|
* for t:=1 to 65 do
|
||||||
|
* for M:=3 to Floor(2*Sqrt(k-1)-1) do
|
||||||
|
* S:=0;
|
||||||
|
* // Sum over m
|
||||||
|
* for m:=3 to M do
|
||||||
|
* s:=0;
|
||||||
|
* // Sum over j
|
||||||
|
* for j:=2 to m do
|
||||||
|
* s+:=(RealField(32)!2)^-(j+(k-1)/j);
|
||||||
|
* end for;
|
||||||
|
* S+:=2^(m-(m-1)*t)*s;
|
||||||
|
* end for;
|
||||||
|
* A:=2^(k-2-M*t);
|
||||||
|
* B:=8*(Pi(RealField(32))^2-6)/3*2^(k-2)*S;
|
||||||
|
* pkt:=2.00743*Log(2)*k*2^-k*(A+B);
|
||||||
|
* seclevel:=Floor(-Log(2,pkt));
|
||||||
|
* if seclevel ge securitybits then
|
||||||
|
* printf "k: %5o, security: %o bits (t: %o, M: %o)\n",k,seclevel,t,M;
|
||||||
|
* break;
|
||||||
|
* end if;
|
||||||
|
* end for;
|
||||||
|
* if seclevel ge securitybits then break; end if;
|
||||||
|
* end for;
|
||||||
|
*
|
||||||
|
* It can be run online at:
|
||||||
|
* http://magma.maths.usyd.edu.au/calc
|
||||||
|
*
|
||||||
|
* And will output:
|
||||||
|
* k: 1024, security: 129 bits (t: 6, M: 23)
|
||||||
|
*
|
||||||
|
* k is the number of bits of the prime, securitybits is the level we want to
|
||||||
|
* reach.
|
||||||
|
*
|
||||||
|
* prime length | RSA key size | # MR tests | security level
|
||||||
|
* -------------+--------------|------------+---------------
|
||||||
|
* (b) >= 6394 | >= 12788 | 3 | 256 bit
|
||||||
|
* (b) >= 3747 | >= 7494 | 3 | 192 bit
|
||||||
|
* (b) >= 1345 | >= 2690 | 4 | 128 bit
|
||||||
|
* (b) >= 1080 | >= 2160 | 5 | 128 bit
|
||||||
|
* (b) >= 852 | >= 1704 | 5 | 112 bit
|
||||||
|
* (b) >= 476 | >= 952 | 5 | 80 bit
|
||||||
|
* (b) >= 400 | >= 800 | 6 | 80 bit
|
||||||
|
* (b) >= 347 | >= 694 | 7 | 80 bit
|
||||||
|
* (b) >= 308 | >= 616 | 8 | 80 bit
|
||||||
|
* (b) >= 55 | >= 110 | 27 | 64 bit
|
||||||
|
* (b) >= 6 | >= 12 | 34 | 64 bit
|
||||||
*/
|
*/
|
||||||
# define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \
|
|
||||||
(b) >= 850 ? 3 : \
|
# define BN_prime_checks_for_size(b) ((b) >= 3747 ? 3 : \
|
||||||
(b) >= 650 ? 4 : \
|
(b) >= 1345 ? 4 : \
|
||||||
(b) >= 550 ? 5 : \
|
(b) >= 476 ? 5 : \
|
||||||
(b) >= 450 ? 6 : \
|
(b) >= 400 ? 6 : \
|
||||||
(b) >= 400 ? 7 : \
|
(b) >= 347 ? 7 : \
|
||||||
(b) >= 350 ? 8 : \
|
(b) >= 308 ? 8 : \
|
||||||
(b) >= 300 ? 9 : \
|
(b) >= 55 ? 27 : \
|
||||||
(b) >= 250 ? 12 : \
|
/* b >= 6 */ 34)
|
||||||
(b) >= 200 ? 15 : \
|
|
||||||
(b) >= 150 ? 18 : \
|
|
||||||
/* b >= 100 */ 27)
|
|
||||||
|
|
||||||
# define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
|
# define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
|
||||||
|
|
||||||
|
|||||||
@@ -141,10 +141,12 @@ int DSAparams_print_fp(FILE *fp, const DSA *x);
|
|||||||
int DSA_print_fp(FILE *bp, const DSA *x, int off);
|
int DSA_print_fp(FILE *bp, const DSA *x, int off);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# define DSS_prime_checks 50
|
# define DSS_prime_checks 64
|
||||||
/*
|
/*
|
||||||
* Primality test according to FIPS PUB 186[-1], Appendix 2.1: 50 rounds of
|
* Primality test according to FIPS PUB 186-4, Appendix C.3. Since we only
|
||||||
* Rabin-Miller
|
* have one value here we set the number of checks to 64 which is the 128 bit
|
||||||
|
* security level that is the highest level and valid for creating a 3072 bit
|
||||||
|
* DSA key.
|
||||||
*/
|
*/
|
||||||
# define DSA_is_prime(n, callback, cb_arg) \
|
# define DSA_is_prime(n, callback, cb_arg) \
|
||||||
BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)
|
BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)
|
||||||
|
|||||||
@@ -216,6 +216,8 @@ extern "C" {
|
|||||||
# define OSSL_SSIZE_MAX SSIZE_MAX
|
# define OSSL_SSIZE_MAX SSIZE_MAX
|
||||||
# elif defined(_POSIX_SSIZE_MAX)
|
# elif defined(_POSIX_SSIZE_MAX)
|
||||||
# define OSSL_SSIZE_MAX _POSIX_SSIZE_MAX
|
# define OSSL_SSIZE_MAX _POSIX_SSIZE_MAX
|
||||||
|
# else
|
||||||
|
# define OSSL_SSIZE_MAX ((ssize_t)(SIZE_MAX>>1))
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
|||||||
+124
-37
@@ -223,50 +223,84 @@ unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x);
|
|||||||
size_t EC_GROUP_get_seed_len(const EC_GROUP *);
|
size_t EC_GROUP_get_seed_len(const EC_GROUP *);
|
||||||
size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);
|
size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);
|
||||||
|
|
||||||
/** Sets the parameter of a ec over GFp defined by y^2 = x^3 + a*x + b
|
/** Sets the parameters of a ec curve defined by y^2 = x^3 + a*x + b (for GFp)
|
||||||
|
* or y^2 + x*y = x^3 + a*x^2 + b (for GF2m)
|
||||||
* \param group EC_GROUP object
|
* \param group EC_GROUP object
|
||||||
* \param p BIGNUM with the prime number
|
* \param p BIGNUM with the prime number (GFp) or the polynomial
|
||||||
|
* defining the underlying field (GF2m)
|
||||||
* \param a BIGNUM with parameter a of the equation
|
* \param a BIGNUM with parameter a of the equation
|
||||||
* \param b BIGNUM with parameter b of the equation
|
* \param b BIGNUM with parameter b of the equation
|
||||||
* \param ctx BN_CTX object (optional)
|
* \param ctx BN_CTX object (optional)
|
||||||
* \return 1 on success and 0 if an error occurred
|
* \return 1 on success and 0 if an error occurred
|
||||||
*/
|
*/
|
||||||
int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
|
int EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
|
||||||
const BIGNUM *b, BN_CTX *ctx);
|
const BIGNUM *b, BN_CTX *ctx);
|
||||||
|
|
||||||
/** Gets the parameter of the ec over GFp defined by y^2 = x^3 + a*x + b
|
/** Gets the parameters of the ec curve defined by y^2 = x^3 + a*x + b (for GFp)
|
||||||
|
* or y^2 + x*y = x^3 + a*x^2 + b (for GF2m)
|
||||||
* \param group EC_GROUP object
|
* \param group EC_GROUP object
|
||||||
* \param p BIGNUM for the prime number
|
* \param p BIGNUM with the prime number (GFp) or the polynomial
|
||||||
|
* defining the underlying field (GF2m)
|
||||||
* \param a BIGNUM for parameter a of the equation
|
* \param a BIGNUM for parameter a of the equation
|
||||||
* \param b BIGNUM for parameter b of the equation
|
* \param b BIGNUM for parameter b of the equation
|
||||||
* \param ctx BN_CTX object (optional)
|
* \param ctx BN_CTX object (optional)
|
||||||
* \return 1 on success and 0 if an error occurred
|
* \return 1 on success and 0 if an error occurred
|
||||||
*/
|
*/
|
||||||
int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
|
int EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b,
|
||||||
BIGNUM *b, BN_CTX *ctx);
|
BN_CTX *ctx);
|
||||||
|
|
||||||
|
/** Sets the parameters of an ec curve. Synonym for EC_GROUP_set_curve
|
||||||
|
* \param group EC_GROUP object
|
||||||
|
* \param p BIGNUM with the prime number (GFp) or the polynomial
|
||||||
|
* defining the underlying field (GF2m)
|
||||||
|
* \param a BIGNUM with parameter a of the equation
|
||||||
|
* \param b BIGNUM with parameter b of the equation
|
||||||
|
* \param ctx BN_CTX object (optional)
|
||||||
|
* \return 1 on success and 0 if an error occurred
|
||||||
|
*/
|
||||||
|
DEPRECATEDIN_1_2_0(int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p,
|
||||||
|
const BIGNUM *a, const BIGNUM *b,
|
||||||
|
BN_CTX *ctx))
|
||||||
|
|
||||||
|
/** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve
|
||||||
|
* \param group EC_GROUP object
|
||||||
|
* \param p BIGNUM with the prime number (GFp) or the polynomial
|
||||||
|
* defining the underlying field (GF2m)
|
||||||
|
* \param a BIGNUM for parameter a of the equation
|
||||||
|
* \param b BIGNUM for parameter b of the equation
|
||||||
|
* \param ctx BN_CTX object (optional)
|
||||||
|
* \return 1 on success and 0 if an error occurred
|
||||||
|
*/
|
||||||
|
DEPRECATEDIN_1_2_0(int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p,
|
||||||
|
BIGNUM *a, BIGNUM *b,
|
||||||
|
BN_CTX *ctx))
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_EC2M
|
# ifndef OPENSSL_NO_EC2M
|
||||||
/** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
|
/** Sets the parameter of an ec curve. Synonym for EC_GROUP_set_curve
|
||||||
* \param group EC_GROUP object
|
* \param group EC_GROUP object
|
||||||
* \param p BIGNUM with the polynomial defining the underlying field
|
* \param p BIGNUM with the prime number (GFp) or the polynomial
|
||||||
|
* defining the underlying field (GF2m)
|
||||||
* \param a BIGNUM with parameter a of the equation
|
* \param a BIGNUM with parameter a of the equation
|
||||||
* \param b BIGNUM with parameter b of the equation
|
* \param b BIGNUM with parameter b of the equation
|
||||||
* \param ctx BN_CTX object (optional)
|
* \param ctx BN_CTX object (optional)
|
||||||
* \return 1 on success and 0 if an error occurred
|
* \return 1 on success and 0 if an error occurred
|
||||||
*/
|
*/
|
||||||
int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
|
DEPRECATEDIN_1_2_0(int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p,
|
||||||
const BIGNUM *b, BN_CTX *ctx);
|
const BIGNUM *a, const BIGNUM *b,
|
||||||
|
BN_CTX *ctx))
|
||||||
|
|
||||||
/** Gets the parameter of the ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
|
/** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve
|
||||||
* \param group EC_GROUP object
|
* \param group EC_GROUP object
|
||||||
* \param p BIGNUM for the polynomial defining the underlying field
|
* \param p BIGNUM with the prime number (GFp) or the polynomial
|
||||||
|
* defining the underlying field (GF2m)
|
||||||
* \param a BIGNUM for parameter a of the equation
|
* \param a BIGNUM for parameter a of the equation
|
||||||
* \param b BIGNUM for parameter b of the equation
|
* \param b BIGNUM for parameter b of the equation
|
||||||
* \param ctx BN_CTX object (optional)
|
* \param ctx BN_CTX object (optional)
|
||||||
* \return 1 on success and 0 if an error occurred
|
* \return 1 on success and 0 if an error occurred
|
||||||
*/
|
*/
|
||||||
int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
|
DEPRECATEDIN_1_2_0(int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p,
|
||||||
BIGNUM *b, BN_CTX *ctx);
|
BIGNUM *a, BIGNUM *b,
|
||||||
|
BN_CTX *ctx))
|
||||||
# endif
|
# endif
|
||||||
/** Returns the number of bits needed to represent a field element
|
/** Returns the number of bits needed to represent a field element
|
||||||
* \param group EC_GROUP object
|
* \param group EC_GROUP object
|
||||||
@@ -459,7 +493,7 @@ int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
|
|||||||
BIGNUM *y, BIGNUM *z,
|
BIGNUM *y, BIGNUM *z,
|
||||||
BN_CTX *ctx);
|
BN_CTX *ctx);
|
||||||
|
|
||||||
/** Sets the affine coordinates of a EC_POINT over GFp
|
/** Sets the affine coordinates of an EC_POINT
|
||||||
* \param group underlying EC_GROUP object
|
* \param group underlying EC_GROUP object
|
||||||
* \param p EC_POINT object
|
* \param p EC_POINT object
|
||||||
* \param x BIGNUM with the x-coordinate
|
* \param x BIGNUM with the x-coordinate
|
||||||
@@ -467,11 +501,11 @@ int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
|
|||||||
* \param ctx BN_CTX object (optional)
|
* \param ctx BN_CTX object (optional)
|
||||||
* \return 1 on success and 0 if an error occurred
|
* \return 1 on success and 0 if an error occurred
|
||||||
*/
|
*/
|
||||||
int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
|
int EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *p,
|
||||||
const BIGNUM *x, const BIGNUM *y,
|
const BIGNUM *x, const BIGNUM *y,
|
||||||
BN_CTX *ctx);
|
BN_CTX *ctx);
|
||||||
|
|
||||||
/** Gets the affine coordinates of a EC_POINT over GFp
|
/** Gets the affine coordinates of an EC_POINT.
|
||||||
* \param group underlying EC_GROUP object
|
* \param group underlying EC_GROUP object
|
||||||
* \param p EC_POINT object
|
* \param p EC_POINT object
|
||||||
* \param x BIGNUM for the x-coordinate
|
* \param x BIGNUM for the x-coordinate
|
||||||
@@ -479,11 +513,40 @@ int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
|
|||||||
* \param ctx BN_CTX object (optional)
|
* \param ctx BN_CTX object (optional)
|
||||||
* \return 1 on success and 0 if an error occurred
|
* \return 1 on success and 0 if an error occurred
|
||||||
*/
|
*/
|
||||||
int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
|
int EC_POINT_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *p,
|
||||||
const EC_POINT *p, BIGNUM *x,
|
BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
|
||||||
BIGNUM *y, BN_CTX *ctx);
|
|
||||||
|
|
||||||
/** Sets the x9.62 compressed coordinates of a EC_POINT over GFp
|
/** Sets the affine coordinates of an EC_POINT. A synonym of
|
||||||
|
* EC_POINT_set_affine_coordinates
|
||||||
|
* \param group underlying EC_GROUP object
|
||||||
|
* \param p EC_POINT object
|
||||||
|
* \param x BIGNUM with the x-coordinate
|
||||||
|
* \param y BIGNUM with the y-coordinate
|
||||||
|
* \param ctx BN_CTX object (optional)
|
||||||
|
* \return 1 on success and 0 if an error occurred
|
||||||
|
*/
|
||||||
|
DEPRECATEDIN_1_2_0(int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group,
|
||||||
|
EC_POINT *p,
|
||||||
|
const BIGNUM *x,
|
||||||
|
const BIGNUM *y,
|
||||||
|
BN_CTX *ctx))
|
||||||
|
|
||||||
|
/** Gets the affine coordinates of an EC_POINT. A synonym of
|
||||||
|
* EC_POINT_get_affine_coordinates
|
||||||
|
* \param group underlying EC_GROUP object
|
||||||
|
* \param p EC_POINT object
|
||||||
|
* \param x BIGNUM for the x-coordinate
|
||||||
|
* \param y BIGNUM for the y-coordinate
|
||||||
|
* \param ctx BN_CTX object (optional)
|
||||||
|
* \return 1 on success and 0 if an error occurred
|
||||||
|
*/
|
||||||
|
DEPRECATEDIN_1_2_0(int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
|
||||||
|
const EC_POINT *p,
|
||||||
|
BIGNUM *x,
|
||||||
|
BIGNUM *y,
|
||||||
|
BN_CTX *ctx))
|
||||||
|
|
||||||
|
/** Sets the x9.62 compressed coordinates of a EC_POINT
|
||||||
* \param group underlying EC_GROUP object
|
* \param group underlying EC_GROUP object
|
||||||
* \param p EC_POINT object
|
* \param p EC_POINT object
|
||||||
* \param x BIGNUM with x-coordinate
|
* \param x BIGNUM with x-coordinate
|
||||||
@@ -491,11 +554,27 @@ int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
|
|||||||
* \param ctx BN_CTX object (optional)
|
* \param ctx BN_CTX object (optional)
|
||||||
* \return 1 on success and 0 if an error occurred
|
* \return 1 on success and 0 if an error occurred
|
||||||
*/
|
*/
|
||||||
int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,
|
int EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *p,
|
||||||
EC_POINT *p, const BIGNUM *x,
|
const BIGNUM *x, int y_bit,
|
||||||
int y_bit, BN_CTX *ctx);
|
BN_CTX *ctx);
|
||||||
|
|
||||||
|
/** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of
|
||||||
|
* EC_POINT_set_compressed_coordinates
|
||||||
|
* \param group underlying EC_GROUP object
|
||||||
|
* \param p EC_POINT object
|
||||||
|
* \param x BIGNUM with x-coordinate
|
||||||
|
* \param y_bit integer with the y-Bit (either 0 or 1)
|
||||||
|
* \param ctx BN_CTX object (optional)
|
||||||
|
* \return 1 on success and 0 if an error occurred
|
||||||
|
*/
|
||||||
|
DEPRECATEDIN_1_2_0(int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,
|
||||||
|
EC_POINT *p,
|
||||||
|
const BIGNUM *x,
|
||||||
|
int y_bit,
|
||||||
|
BN_CTX *ctx))
|
||||||
# ifndef OPENSSL_NO_EC2M
|
# ifndef OPENSSL_NO_EC2M
|
||||||
/** Sets the affine coordinates of a EC_POINT over GF2m
|
/** Sets the affine coordinates of an EC_POINT. A synonym of
|
||||||
|
* EC_POINT_set_affine_coordinates
|
||||||
* \param group underlying EC_GROUP object
|
* \param group underlying EC_GROUP object
|
||||||
* \param p EC_POINT object
|
* \param p EC_POINT object
|
||||||
* \param x BIGNUM with the x-coordinate
|
* \param x BIGNUM with the x-coordinate
|
||||||
@@ -503,11 +582,14 @@ int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,
|
|||||||
* \param ctx BN_CTX object (optional)
|
* \param ctx BN_CTX object (optional)
|
||||||
* \return 1 on success and 0 if an error occurred
|
* \return 1 on success and 0 if an error occurred
|
||||||
*/
|
*/
|
||||||
int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
|
DEPRECATEDIN_1_2_0(int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group,
|
||||||
const BIGNUM *x, const BIGNUM *y,
|
EC_POINT *p,
|
||||||
BN_CTX *ctx);
|
const BIGNUM *x,
|
||||||
|
const BIGNUM *y,
|
||||||
|
BN_CTX *ctx))
|
||||||
|
|
||||||
/** Gets the affine coordinates of a EC_POINT over GF2m
|
/** Gets the affine coordinates of an EC_POINT. A synonym of
|
||||||
|
* EC_POINT_get_affine_coordinates
|
||||||
* \param group underlying EC_GROUP object
|
* \param group underlying EC_GROUP object
|
||||||
* \param p EC_POINT object
|
* \param p EC_POINT object
|
||||||
* \param x BIGNUM for the x-coordinate
|
* \param x BIGNUM for the x-coordinate
|
||||||
@@ -515,11 +597,14 @@ int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
|
|||||||
* \param ctx BN_CTX object (optional)
|
* \param ctx BN_CTX object (optional)
|
||||||
* \return 1 on success and 0 if an error occurred
|
* \return 1 on success and 0 if an error occurred
|
||||||
*/
|
*/
|
||||||
int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
|
DEPRECATEDIN_1_2_0(int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
|
||||||
const EC_POINT *p, BIGNUM *x,
|
const EC_POINT *p,
|
||||||
BIGNUM *y, BN_CTX *ctx);
|
BIGNUM *x,
|
||||||
|
BIGNUM *y,
|
||||||
|
BN_CTX *ctx))
|
||||||
|
|
||||||
/** Sets the x9.62 compressed coordinates of a EC_POINT over GF2m
|
/** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of
|
||||||
|
* EC_POINT_set_compressed_coordinates
|
||||||
* \param group underlying EC_GROUP object
|
* \param group underlying EC_GROUP object
|
||||||
* \param p EC_POINT object
|
* \param p EC_POINT object
|
||||||
* \param x BIGNUM with x-coordinate
|
* \param x BIGNUM with x-coordinate
|
||||||
@@ -527,9 +612,11 @@ int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
|
|||||||
* \param ctx BN_CTX object (optional)
|
* \param ctx BN_CTX object (optional)
|
||||||
* \return 1 on success and 0 if an error occurred
|
* \return 1 on success and 0 if an error occurred
|
||||||
*/
|
*/
|
||||||
int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group,
|
DEPRECATEDIN_1_2_0(int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group,
|
||||||
EC_POINT *p, const BIGNUM *x,
|
EC_POINT *p,
|
||||||
int y_bit, BN_CTX *ctx);
|
const BIGNUM *x,
|
||||||
|
int y_bit,
|
||||||
|
BN_CTX *ctx))
|
||||||
# endif
|
# endif
|
||||||
/** Encodes a EC_POINT object to a octet string
|
/** Encodes a EC_POINT object to a octet string
|
||||||
* \param group underlying EC_GROUP object
|
* \param group underlying EC_GROUP object
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ int ERR_load_EC_strings(void);
|
|||||||
# define EC_F_EC_GROUP_CHECK 170
|
# define EC_F_EC_GROUP_CHECK 170
|
||||||
# define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171
|
# define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171
|
||||||
# define EC_F_EC_GROUP_COPY 106
|
# define EC_F_EC_GROUP_COPY 106
|
||||||
|
# define EC_F_EC_GROUP_GET_CURVE 291
|
||||||
# define EC_F_EC_GROUP_GET_CURVE_GF2M 172
|
# define EC_F_EC_GROUP_GET_CURVE_GF2M 172
|
||||||
# define EC_F_EC_GROUP_GET_CURVE_GFP 130
|
# define EC_F_EC_GROUP_GET_CURVE_GFP 130
|
||||||
# define EC_F_EC_GROUP_GET_DEGREE 173
|
# define EC_F_EC_GROUP_GET_DEGREE 173
|
||||||
@@ -115,6 +116,7 @@ int ERR_load_EC_strings(void);
|
|||||||
# define EC_F_EC_GROUP_NEW_FROM_DATA 175
|
# define EC_F_EC_GROUP_NEW_FROM_DATA 175
|
||||||
# define EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS 263
|
# define EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS 263
|
||||||
# define EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS 264
|
# define EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS 264
|
||||||
|
# define EC_F_EC_GROUP_SET_CURVE 292
|
||||||
# define EC_F_EC_GROUP_SET_CURVE_GF2M 176
|
# define EC_F_EC_GROUP_SET_CURVE_GF2M 176
|
||||||
# define EC_F_EC_GROUP_SET_CURVE_GFP 109
|
# define EC_F_EC_GROUP_SET_CURVE_GFP 109
|
||||||
# define EC_F_EC_GROUP_SET_GENERATOR 111
|
# define EC_F_EC_GROUP_SET_GENERATOR 111
|
||||||
@@ -142,6 +144,7 @@ int ERR_load_EC_strings(void);
|
|||||||
# define EC_F_EC_POINT_CMP 113
|
# define EC_F_EC_POINT_CMP 113
|
||||||
# define EC_F_EC_POINT_COPY 114
|
# define EC_F_EC_POINT_COPY 114
|
||||||
# define EC_F_EC_POINT_DBL 115
|
# define EC_F_EC_POINT_DBL 115
|
||||||
|
# define EC_F_EC_POINT_GET_AFFINE_COORDINATES 293
|
||||||
# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183
|
# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183
|
||||||
# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116
|
# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116
|
||||||
# define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117
|
# define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117
|
||||||
@@ -153,8 +156,10 @@ int ERR_load_EC_strings(void);
|
|||||||
# define EC_F_EC_POINT_OCT2POINT 122
|
# define EC_F_EC_POINT_OCT2POINT 122
|
||||||
# define EC_F_EC_POINT_POINT2BUF 281
|
# define EC_F_EC_POINT_POINT2BUF 281
|
||||||
# define EC_F_EC_POINT_POINT2OCT 123
|
# define EC_F_EC_POINT_POINT2OCT 123
|
||||||
|
# define EC_F_EC_POINT_SET_AFFINE_COORDINATES 294
|
||||||
# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185
|
# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185
|
||||||
# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124
|
# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124
|
||||||
|
# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES 295
|
||||||
# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186
|
# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186
|
||||||
# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125
|
# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125
|
||||||
# define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126
|
# define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126
|
||||||
|
|||||||
@@ -1195,6 +1195,14 @@
|
|||||||
#define NID_hmacWithSHA512 801
|
#define NID_hmacWithSHA512 801
|
||||||
#define OBJ_hmacWithSHA512 OBJ_rsadsi,2L,11L
|
#define OBJ_hmacWithSHA512 OBJ_rsadsi,2L,11L
|
||||||
|
|
||||||
|
#define LN_hmacWithSHA512_224 "hmacWithSHA512-224"
|
||||||
|
#define NID_hmacWithSHA512_224 1193
|
||||||
|
#define OBJ_hmacWithSHA512_224 OBJ_rsadsi,2L,12L
|
||||||
|
|
||||||
|
#define LN_hmacWithSHA512_256 "hmacWithSHA512-256"
|
||||||
|
#define NID_hmacWithSHA512_256 1194
|
||||||
|
#define OBJ_hmacWithSHA512_256 OBJ_rsadsi,2L,13L
|
||||||
|
|
||||||
#define SN_rc2_cbc "RC2-CBC"
|
#define SN_rc2_cbc "RC2-CBC"
|
||||||
#define LN_rc2_cbc "rc2-cbc"
|
#define LN_rc2_cbc "rc2-cbc"
|
||||||
#define NID_rc2_cbc 37
|
#define NID_rc2_cbc 37
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
* https://www.openssl.org/source/license.html
|
* https://www.openssl.org/source/license.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <openssl/opensslv.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@@ -97,7 +99,13 @@ extern "C" {
|
|||||||
# define OPENSSL_API_COMPAT OPENSSL_MIN_API
|
# define OPENSSL_API_COMPAT OPENSSL_MIN_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if OPENSSL_API_COMPAT < 0x10200000L
|
/*
|
||||||
|
* Do not deprecate things to be deprecated in version 1.2.0 before the
|
||||||
|
* OpenSSL version number matches.
|
||||||
|
*/
|
||||||
|
#if OPENSSL_VERSION_NUMBER < 0x10200000L
|
||||||
|
# define DEPRECATEDIN_1_2_0(f) f;
|
||||||
|
#elif OPENSSL_API_COMPAT < 0x10200000L
|
||||||
# define DEPRECATEDIN_1_2_0(f) DECLARE_DEPRECATED(f)
|
# define DEPRECATEDIN_1_2_0(f) DECLARE_DEPRECATED(f)
|
||||||
#else
|
#else
|
||||||
# define DEPRECATEDIN_1_2_0(f)
|
# define DEPRECATEDIN_1_2_0(f)
|
||||||
|
|||||||
@@ -1058,9 +1058,9 @@ typedef enum {
|
|||||||
/* Is the SSL_connection established? */
|
/* Is the SSL_connection established? */
|
||||||
# define SSL_in_connect_init(a) (SSL_in_init(a) && !SSL_is_server(a))
|
# define SSL_in_connect_init(a) (SSL_in_init(a) && !SSL_is_server(a))
|
||||||
# define SSL_in_accept_init(a) (SSL_in_init(a) && SSL_is_server(a))
|
# define SSL_in_accept_init(a) (SSL_in_init(a) && SSL_is_server(a))
|
||||||
int SSL_in_init(SSL *s);
|
int SSL_in_init(const SSL *s);
|
||||||
int SSL_in_before(SSL *s);
|
int SSL_in_before(const SSL *s);
|
||||||
int SSL_is_init_finished(SSL *s);
|
int SSL_is_init_finished(const SSL *s);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following 3 states are kept in ssl->rlayer.rstate when reads fail, you
|
* The following 3 states are kept in ssl->rlayer.rstate when reads fail, you
|
||||||
|
|||||||
@@ -471,6 +471,7 @@ int ERR_load_SSL_strings(void);
|
|||||||
# define SSL_R_BAD_HRR_VERSION 263
|
# define SSL_R_BAD_HRR_VERSION 263
|
||||||
# define SSL_R_BAD_KEY_SHARE 108
|
# define SSL_R_BAD_KEY_SHARE 108
|
||||||
# define SSL_R_BAD_KEY_UPDATE 122
|
# define SSL_R_BAD_KEY_UPDATE 122
|
||||||
|
# define SSL_R_BAD_LEGACY_VERSION 292
|
||||||
# define SSL_R_BAD_LENGTH 271
|
# define SSL_R_BAD_LENGTH 271
|
||||||
# define SSL_R_BAD_PACKET 240
|
# define SSL_R_BAD_PACKET 240
|
||||||
# define SSL_R_BAD_PACKET_LENGTH 115
|
# define SSL_R_BAD_PACKET_LENGTH 115
|
||||||
@@ -696,6 +697,8 @@ int ERR_load_SSL_strings(void);
|
|||||||
# define SSL_R_SSL_SESSION_ID_TOO_LONG 408
|
# define SSL_R_SSL_SESSION_ID_TOO_LONG 408
|
||||||
# define SSL_R_SSL_SESSION_VERSION_MISMATCH 210
|
# define SSL_R_SSL_SESSION_VERSION_MISMATCH 210
|
||||||
# define SSL_R_STILL_IN_INIT 121
|
# define SSL_R_STILL_IN_INIT 121
|
||||||
|
# define SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED 1116
|
||||||
|
# define SSL_R_TLSV13_ALERT_MISSING_EXTENSION 1109
|
||||||
# define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049
|
# define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049
|
||||||
# define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050
|
# define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050
|
||||||
# define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021
|
# define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ extern "C" {
|
|||||||
# define TLS1_AD_USER_CANCELLED 90
|
# define TLS1_AD_USER_CANCELLED 90
|
||||||
# define TLS1_AD_NO_RENEGOTIATION 100
|
# define TLS1_AD_NO_RENEGOTIATION 100
|
||||||
/* TLSv1.3 alerts */
|
/* TLSv1.3 alerts */
|
||||||
# define TLS13_AD_END_OF_EARLY_DATA 1
|
|
||||||
# define TLS13_AD_MISSING_EXTENSION 109 /* fatal */
|
# define TLS13_AD_MISSING_EXTENSION 109 /* fatal */
|
||||||
# define TLS13_AD_CERTIFICATE_REQUIRED 116 /* fatal */
|
# define TLS13_AD_CERTIFICATE_REQUIRED 116 /* fatal */
|
||||||
/* codes 110-114 are from RFC3546 */
|
/* codes 110-114 are from RFC3546 */
|
||||||
|
|||||||
@@ -3472,6 +3472,15 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
|
|||||||
break;
|
break;
|
||||||
#endif /* !OPENSSL_NO_EC */
|
#endif /* !OPENSSL_NO_EC */
|
||||||
case SSL_CTRL_SET_TLSEXT_HOSTNAME:
|
case SSL_CTRL_SET_TLSEXT_HOSTNAME:
|
||||||
|
/*
|
||||||
|
* TODO(OpenSSL1.2)
|
||||||
|
* This API is only used for a client to set what SNI it will request
|
||||||
|
* from the server, but we currently allow it to be used on servers
|
||||||
|
* as well, which is a programming error. Currently we just clear
|
||||||
|
* the field in SSL_do_handshake() for server SSLs, but when we can
|
||||||
|
* make ABI-breaking changes, we may want to make use of this API
|
||||||
|
* an error on server SSLs.
|
||||||
|
*/
|
||||||
if (larg == TLSEXT_NAMETYPE_host_name) {
|
if (larg == TLSEXT_NAMETYPE_host_name) {
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
|
|||||||
@@ -757,6 +757,7 @@ static const ERR_STRING_DATA SSL_str_reasons[] = {
|
|||||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_HRR_VERSION), "bad hrr version"},
|
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_HRR_VERSION), "bad hrr version"},
|
||||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_KEY_SHARE), "bad key share"},
|
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_KEY_SHARE), "bad key share"},
|
||||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_KEY_UPDATE), "bad key update"},
|
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_KEY_UPDATE), "bad key update"},
|
||||||
|
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_LEGACY_VERSION), "bad legacy version"},
|
||||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_LENGTH), "bad length"},
|
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_LENGTH), "bad length"},
|
||||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_PACKET), "bad packet"},
|
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_PACKET), "bad packet"},
|
||||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_PACKET_LENGTH), "bad packet length"},
|
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_PACKET_LENGTH), "bad packet length"},
|
||||||
@@ -1139,6 +1140,10 @@ static const ERR_STRING_DATA SSL_str_reasons[] = {
|
|||||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_SSL_SESSION_VERSION_MISMATCH),
|
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_SSL_SESSION_VERSION_MISMATCH),
|
||||||
"ssl session version mismatch"},
|
"ssl session version mismatch"},
|
||||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_STILL_IN_INIT), "still in init"},
|
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_STILL_IN_INIT), "still in init"},
|
||||||
|
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED),
|
||||||
|
"tlsv13 alert certificate required"},
|
||||||
|
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_TLSV13_ALERT_MISSING_EXTENSION),
|
||||||
|
"tlsv13 alert missing extension"},
|
||||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_TLSV1_ALERT_ACCESS_DENIED),
|
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_TLSV1_ALERT_ACCESS_DENIED),
|
||||||
"tlsv1 alert access denied"},
|
"tlsv1 alert access denied"},
|
||||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_TLSV1_ALERT_DECODE_ERROR),
|
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_TLSV1_ALERT_DECODE_ERROR),
|
||||||
|
|||||||
+12
-1
@@ -2678,7 +2678,18 @@ const char *SSL_get_servername(const SSL *s, const int type)
|
|||||||
if (type != TLSEXT_NAMETYPE_host_name)
|
if (type != TLSEXT_NAMETYPE_host_name)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return s->session && !s->ext.hostname ?
|
/*
|
||||||
|
* TODO(OpenSSL1.2) clean up this compat mess. This API is
|
||||||
|
* currently a mix of "what did I configure" and "what did the
|
||||||
|
* peer send" and "what was actually negotiated"; we should have
|
||||||
|
* a clear distinction amongst those three.
|
||||||
|
*/
|
||||||
|
if (SSL_in_init(s)) {
|
||||||
|
if (s->hit)
|
||||||
|
return s->session->ext.hostname;
|
||||||
|
return s->ext.hostname;
|
||||||
|
}
|
||||||
|
return (s->session != NULL && s->ext.hostname == NULL) ?
|
||||||
s->session->ext.hostname : s->ext.hostname;
|
s->session->ext.hostname : s->ext.hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -421,15 +421,6 @@ int ssl_get_new_session(SSL *s, int session)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->ext.hostname) {
|
|
||||||
ss->ext.hostname = OPENSSL_strdup(s->ext.hostname);
|
|
||||||
if (ss->ext.hostname == NULL) {
|
|
||||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GET_NEW_SESSION,
|
|
||||||
ERR_R_INTERNAL_ERROR);
|
|
||||||
SSL_SESSION_free(ss);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
ss->session_id_length = 0;
|
ss->session_id_length = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-1
@@ -929,9 +929,28 @@ static int final_server_name(SSL *s, unsigned int context, int sent)
|
|||||||
ret = s->session_ctx->ext.servername_cb(s, &altmp,
|
ret = s->session_ctx->ext.servername_cb(s, &altmp,
|
||||||
s->session_ctx->ext.servername_arg);
|
s->session_ctx->ext.servername_arg);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For servers, propagate the SNI hostname from the temporary
|
||||||
|
* storage in the SSL to the persistent SSL_SESSION, now that we
|
||||||
|
* know we accepted it.
|
||||||
|
* Clients make this copy when parsing the server's response to
|
||||||
|
* the extension, which is when they find out that the negotiation
|
||||||
|
* was successful.
|
||||||
|
*/
|
||||||
|
if (s->server) {
|
||||||
if (!sent) {
|
if (!sent) {
|
||||||
|
/* Nothing from the client this handshake; cleanup stale value */
|
||||||
|
OPENSSL_free(s->ext.hostname);
|
||||||
|
s->ext.hostname = NULL;
|
||||||
|
} else if (ret == SSL_TLSEXT_ERR_OK && (!s->hit || SSL_IS_TLS13(s))) {
|
||||||
|
/* Only store the hostname in the session if we accepted it. */
|
||||||
OPENSSL_free(s->session->ext.hostname);
|
OPENSSL_free(s->session->ext.hostname);
|
||||||
s->session->ext.hostname = NULL;
|
s->session->ext.hostname = OPENSSL_strdup(s->ext.hostname);
|
||||||
|
if (s->session->ext.hostname == NULL && s->ext.hostname != NULL) {
|
||||||
|
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_FINAL_SERVER_NAME,
|
||||||
|
ERR_R_INTERNAL_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ int tls_parse_ctos_server_name(SSL *s, PACKET *pkt, unsigned int context,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s->hit) {
|
if (!s->hit || SSL_IS_TLS13(s)) {
|
||||||
if (PACKET_remaining(&hostname) > TLSEXT_MAXLEN_host_name) {
|
if (PACKET_remaining(&hostname) > TLSEXT_MAXLEN_host_name) {
|
||||||
SSLfatal(s, SSL_AD_UNRECOGNIZED_NAME,
|
SSLfatal(s, SSL_AD_UNRECOGNIZED_NAME,
|
||||||
SSL_F_TLS_PARSE_CTOS_SERVER_NAME,
|
SSL_F_TLS_PARSE_CTOS_SERVER_NAME,
|
||||||
@@ -142,21 +142,26 @@ int tls_parse_ctos_server_name(SSL *s, PACKET *pkt, unsigned int context,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
OPENSSL_free(s->session->ext.hostname);
|
/*
|
||||||
s->session->ext.hostname = NULL;
|
* Store the requested SNI in the SSL as temporary storage.
|
||||||
if (!PACKET_strndup(&hostname, &s->session->ext.hostname)) {
|
* If we accept it, it will get stored in the SSL_SESSION as well.
|
||||||
|
*/
|
||||||
|
OPENSSL_free(s->ext.hostname);
|
||||||
|
s->ext.hostname = NULL;
|
||||||
|
if (!PACKET_strndup(&hostname, &s->ext.hostname)) {
|
||||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PARSE_CTOS_SERVER_NAME,
|
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PARSE_CTOS_SERVER_NAME,
|
||||||
ERR_R_INTERNAL_ERROR);
|
ERR_R_INTERNAL_ERROR);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->servername_done = 1;
|
s->servername_done = 1;
|
||||||
} else {
|
}
|
||||||
|
if (s->hit) {
|
||||||
/*
|
/*
|
||||||
* TODO(openssl-team): if the SNI doesn't match, we MUST
|
* TODO(openssl-team): if the SNI doesn't match, we MUST
|
||||||
* fall back to a full handshake.
|
* fall back to a full handshake.
|
||||||
*/
|
*/
|
||||||
s->servername_done = s->session->ext.hostname
|
s->servername_done = (s->session->ext.hostname != NULL)
|
||||||
&& PACKET_equal(&hostname, s->session->ext.hostname,
|
&& PACKET_equal(&hostname, s->session->ext.hostname,
|
||||||
strlen(s->session->ext.hostname));
|
strlen(s->session->ext.hostname));
|
||||||
|
|
||||||
@@ -1325,7 +1330,7 @@ EXT_RETURN tls_construct_stoc_server_name(SSL *s, WPACKET *pkt,
|
|||||||
size_t chainidx)
|
size_t chainidx)
|
||||||
{
|
{
|
||||||
if (s->hit || s->servername_done != 1
|
if (s->hit || s->servername_done != 1
|
||||||
|| s->session->ext.hostname == NULL)
|
|| s->ext.hostname == NULL)
|
||||||
return EXT_RETURN_NOT_SENT;
|
return EXT_RETURN_NOT_SENT;
|
||||||
|
|
||||||
if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_server_name)
|
if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_server_name)
|
||||||
|
|||||||
+3
-3
@@ -68,17 +68,17 @@ OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl)
|
|||||||
return ssl->statem.hand_state;
|
return ssl->statem.hand_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SSL_in_init(SSL *s)
|
int SSL_in_init(const SSL *s)
|
||||||
{
|
{
|
||||||
return s->statem.in_init;
|
return s->statem.in_init;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SSL_is_init_finished(SSL *s)
|
int SSL_is_init_finished(const SSL *s)
|
||||||
{
|
{
|
||||||
return !(s->statem.in_init) && (s->statem.hand_state == TLS_ST_OK);
|
return !(s->statem.in_init) && (s->statem.hand_state == TLS_ST_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SSL_in_before(SSL *s)
|
int SSL_in_before(const SSL *s)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Historically being "in before" meant before anything had happened. In the
|
* Historically being "in before" meant before anything had happened. In the
|
||||||
|
|||||||
@@ -1753,6 +1753,18 @@ int ssl_choose_server_version(SSL *s, CLIENTHELLO_MSG *hello, DOWNGRADE *dgrd)
|
|||||||
return SSL_R_LENGTH_MISMATCH;
|
return SSL_R_LENGTH_MISMATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The TLSv1.3 spec says the client MUST set this to TLS1_2_VERSION.
|
||||||
|
* The spec only requires servers to check that it isn't SSLv3:
|
||||||
|
* "Any endpoint receiving a Hello message with
|
||||||
|
* ClientHello.legacy_version or ServerHello.legacy_version set to
|
||||||
|
* 0x0300 MUST abort the handshake with a "protocol_version" alert."
|
||||||
|
* We are slightly stricter and require that it isn't SSLv3 or lower.
|
||||||
|
* We tolerate TLSv1 and TLSv1.1.
|
||||||
|
*/
|
||||||
|
if (client_version <= SSL3_VERSION)
|
||||||
|
return SSL_R_BAD_LEGACY_VERSION;
|
||||||
|
|
||||||
while (PACKET_get_net_2(&versionslist, &candidate_vers)) {
|
while (PACKET_get_net_2(&versionslist, &candidate_vers)) {
|
||||||
/* TODO(TLS1.3): Remove this before release */
|
/* TODO(TLS1.3): Remove this before release */
|
||||||
if (candidate_vers == TLS1_3_VERSION_DRAFT
|
if (candidate_vers == TLS1_3_VERSION_DRAFT
|
||||||
|
|||||||
+2
-1
@@ -701,7 +701,8 @@ int tls13_update_key(SSL *s, int sending)
|
|||||||
|
|
||||||
int tls13_alert_code(int code)
|
int tls13_alert_code(int code)
|
||||||
{
|
{
|
||||||
if (code == SSL_AD_MISSING_EXTENSION)
|
/* There are 2 additional alerts in TLSv1.3 compared to TLSv1.2 */
|
||||||
|
if (code == SSL_AD_MISSING_EXTENSION || code == SSL_AD_CERTIFICATE_REQUIRED)
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
return tls1_alert_code(code);
|
return tls1_alert_code(code);
|
||||||
|
|||||||
+5
-1
@@ -33,7 +33,7 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN
|
|||||||
rc2test rc4test rc5test \
|
rc2test rc4test rc5test \
|
||||||
destest mdc2test \
|
destest mdc2test \
|
||||||
dhtest enginetest casttest \
|
dhtest enginetest casttest \
|
||||||
bftest ssltest_old dsatest exptest rsa_test \
|
bftest ssltest_old dsatest dsa_no_digest_size_test exptest rsa_test \
|
||||||
evp_test evp_extra_test igetest v3nametest v3ext \
|
evp_test evp_extra_test igetest v3nametest v3ext \
|
||||||
crltest danetest bad_dtls_test lhash_test \
|
crltest danetest bad_dtls_test lhash_test \
|
||||||
conf_include_test \
|
conf_include_test \
|
||||||
@@ -152,6 +152,10 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN
|
|||||||
INCLUDE[dsatest]=../include
|
INCLUDE[dsatest]=../include
|
||||||
DEPEND[dsatest]=../libcrypto libtestutil.a
|
DEPEND[dsatest]=../libcrypto libtestutil.a
|
||||||
|
|
||||||
|
SOURCE[dsa_no_digest_size_test]=dsa_no_digest_size_test.c
|
||||||
|
INCLUDE[dsa_no_digest_size_test]=../include
|
||||||
|
DEPEND[dsa_no_digest_size_test]=../libcrypto libtestutil.a
|
||||||
|
|
||||||
SOURCE[exptest]=exptest.c
|
SOURCE[exptest]=exptest.c
|
||||||
INCLUDE[exptest]=../include
|
INCLUDE[exptest]=../include
|
||||||
DEPEND[exptest]=../libcrypto libtestutil.a
|
DEPEND[exptest]=../libcrypto libtestutil.a
|
||||||
|
|||||||
@@ -0,0 +1,245 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "testutil.h"
|
||||||
|
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/rand.h>
|
||||||
|
|
||||||
|
#ifndef OPENSSL_NO_DSA
|
||||||
|
#include <openssl/dsa.h>
|
||||||
|
|
||||||
|
static DSA *dsakey;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These parameters are from test/recipes/04-test_pem_data/dsaparam.pem,
|
||||||
|
* converted using dsaparam -C
|
||||||
|
*/
|
||||||
|
static DSA *load_dsa_params(void)
|
||||||
|
{
|
||||||
|
static unsigned char dsap_2048[] = {
|
||||||
|
0xAE, 0x35, 0x7D, 0x4E, 0x1D, 0x96, 0xE2, 0x9F, 0x00, 0x96,
|
||||||
|
0x60, 0x5A, 0x6E, 0x4D, 0x07, 0x8D, 0xA5, 0x7C, 0xBC, 0xF9,
|
||||||
|
0xAD, 0xD7, 0x9F, 0xD5, 0xE9, 0xEE, 0xA6, 0x33, 0x51, 0xDE,
|
||||||
|
0x7B, 0x72, 0xD2, 0x75, 0xAA, 0x71, 0x77, 0xF1, 0x63, 0xFB,
|
||||||
|
0xB6, 0xEC, 0x5A, 0xBA, 0x0D, 0x72, 0xA2, 0x1A, 0x1C, 0x64,
|
||||||
|
0xB8, 0xE5, 0x89, 0x09, 0x6D, 0xC9, 0x6F, 0x0B, 0x7F, 0xD2,
|
||||||
|
0xCE, 0x9F, 0xEF, 0x87, 0x5A, 0xB6, 0x67, 0x2F, 0xEF, 0xEE,
|
||||||
|
0xEB, 0x59, 0xF5, 0x5E, 0xFF, 0xA8, 0x28, 0x84, 0x9E, 0x5B,
|
||||||
|
0x37, 0x09, 0x11, 0x80, 0x7C, 0x08, 0x5C, 0xD5, 0xE1, 0x48,
|
||||||
|
0x4B, 0xD2, 0x68, 0xFB, 0x3F, 0x9F, 0x2B, 0x6B, 0x6C, 0x0D,
|
||||||
|
0x48, 0x1B, 0x1A, 0x80, 0xC2, 0xEB, 0x11, 0x1B, 0x37, 0x79,
|
||||||
|
0xD6, 0x8C, 0x8B, 0x72, 0x3E, 0x67, 0xA5, 0x05, 0x0E, 0x41,
|
||||||
|
0x8A, 0x9E, 0x35, 0x50, 0xB4, 0xD2, 0x40, 0x27, 0x6B, 0xFD,
|
||||||
|
0xE0, 0x64, 0x6B, 0x5B, 0x38, 0x42, 0x94, 0xB5, 0x49, 0xDA,
|
||||||
|
0xEF, 0x6E, 0x78, 0x37, 0xCD, 0x30, 0x89, 0xC3, 0x45, 0x50,
|
||||||
|
0x7B, 0x9C, 0x8C, 0xE7, 0x1C, 0x98, 0x70, 0x71, 0x5D, 0x79,
|
||||||
|
0x5F, 0xEF, 0xE8, 0x94, 0x85, 0x53, 0x3E, 0xEF, 0xA3, 0x2C,
|
||||||
|
0xCE, 0x1A, 0xAB, 0x7D, 0xD6, 0x5E, 0x14, 0xCD, 0x51, 0x54,
|
||||||
|
0x89, 0x9D, 0x77, 0xE4, 0xF8, 0x22, 0xF0, 0x35, 0x10, 0x75,
|
||||||
|
0x05, 0x71, 0x51, 0x4F, 0x8C, 0x4C, 0x5C, 0x0D, 0x2C, 0x2C,
|
||||||
|
0xBE, 0x6C, 0x34, 0xEE, 0x12, 0x82, 0x87, 0x03, 0x19, 0x06,
|
||||||
|
0x12, 0xA8, 0xAA, 0xF4, 0x0D, 0x3C, 0x49, 0xCC, 0x70, 0x5A,
|
||||||
|
0xD8, 0x32, 0xEE, 0x32, 0x50, 0x85, 0x70, 0xE8, 0x18, 0xFD,
|
||||||
|
0x74, 0x80, 0x53, 0x32, 0x57, 0xEE, 0x50, 0xC9, 0xAE, 0xEB,
|
||||||
|
0xAE, 0xB6, 0x22, 0x32, 0x16, 0x6B, 0x8C, 0x59, 0xDA, 0xEE,
|
||||||
|
0x1D, 0x33, 0xDF, 0x4C, 0xA2, 0x3D
|
||||||
|
};
|
||||||
|
static unsigned char dsaq_2048[] = {
|
||||||
|
0xAD, 0x2D, 0x6E, 0x17, 0xB0, 0xF3, 0xEB, 0xC7, 0xB8, 0xEE,
|
||||||
|
0x95, 0x78, 0xF2, 0x17, 0xF5, 0x33, 0x01, 0x67, 0xBC, 0xDE,
|
||||||
|
0x93, 0xFF, 0xEE, 0x40, 0xE8, 0x7F, 0xF1, 0x93, 0x6D, 0x4B,
|
||||||
|
0x87, 0x13
|
||||||
|
};
|
||||||
|
static unsigned char dsag_2048[] = {
|
||||||
|
0x66, 0x6F, 0xDA, 0x63, 0xA5, 0x8E, 0xD2, 0x4C, 0xD5, 0x45,
|
||||||
|
0x2D, 0x76, 0x5D, 0x5F, 0xCD, 0x4A, 0xB4, 0x1A, 0x42, 0x35,
|
||||||
|
0x86, 0x3A, 0x6F, 0xA9, 0xFA, 0x27, 0xAB, 0xDE, 0x03, 0x21,
|
||||||
|
0x36, 0x0A, 0x07, 0x29, 0xC9, 0x2F, 0x6D, 0x49, 0xA8, 0xF7,
|
||||||
|
0xC6, 0xF4, 0x92, 0xD7, 0x73, 0xC1, 0xD8, 0x76, 0x0E, 0x61,
|
||||||
|
0xA7, 0x0B, 0x6E, 0x96, 0xB8, 0xC8, 0xCB, 0x38, 0x35, 0x12,
|
||||||
|
0x20, 0x79, 0xA5, 0x08, 0x28, 0x35, 0x5C, 0xBC, 0x52, 0x16,
|
||||||
|
0xAF, 0x52, 0xBA, 0x0F, 0xC3, 0xB1, 0x63, 0x12, 0x27, 0x0B,
|
||||||
|
0x74, 0xA4, 0x47, 0x43, 0xD6, 0x30, 0xB8, 0x9C, 0x2E, 0x40,
|
||||||
|
0x14, 0xCD, 0x99, 0x7F, 0xE8, 0x8E, 0x37, 0xB0, 0xA9, 0x3F,
|
||||||
|
0x54, 0xE9, 0x66, 0x22, 0x61, 0x4C, 0xF8, 0x49, 0x03, 0x57,
|
||||||
|
0x14, 0x32, 0x1D, 0x37, 0x3D, 0xE2, 0x92, 0xF8, 0x8E, 0xA0,
|
||||||
|
0x6A, 0x66, 0x63, 0xF0, 0xB0, 0x6E, 0x07, 0x2B, 0x3D, 0xBF,
|
||||||
|
0xD0, 0x84, 0x6A, 0xAA, 0x1F, 0x30, 0x77, 0x65, 0xE5, 0xFC,
|
||||||
|
0xF5, 0xEC, 0x55, 0xCE, 0x73, 0xDB, 0xBE, 0xA7, 0x8D, 0x3A,
|
||||||
|
0x9F, 0x7A, 0xED, 0x4F, 0xAF, 0xA2, 0x80, 0x4C, 0x30, 0x9E,
|
||||||
|
0x28, 0x49, 0x65, 0x40, 0xF0, 0x03, 0x45, 0x56, 0x99, 0xA2,
|
||||||
|
0x93, 0x1B, 0x9C, 0x46, 0xDE, 0xBD, 0xA8, 0xAB, 0x5F, 0x90,
|
||||||
|
0x3F, 0xB7, 0x3F, 0xD4, 0x6F, 0x8D, 0x5A, 0x30, 0xE1, 0xD4,
|
||||||
|
0x63, 0x3A, 0x6A, 0x7C, 0x8F, 0x24, 0xFC, 0xD9, 0x14, 0x28,
|
||||||
|
0x09, 0xE4, 0x84, 0x4E, 0x17, 0x43, 0x56, 0xB8, 0xD4, 0x4B,
|
||||||
|
0xA2, 0x29, 0x45, 0xD3, 0x13, 0xF0, 0xC2, 0x76, 0x9B, 0x01,
|
||||||
|
0xA0, 0x80, 0x6E, 0x93, 0x63, 0x5E, 0x87, 0x24, 0x20, 0x2A,
|
||||||
|
0xFF, 0xBB, 0x9F, 0xA8, 0x99, 0x6C, 0xA7, 0x9A, 0x00, 0xB9,
|
||||||
|
0x7D, 0xDA, 0x66, 0xC9, 0xC0, 0x72, 0x72, 0x22, 0x0F, 0x1A,
|
||||||
|
0xCC, 0x23, 0xD9, 0xB7, 0x5F, 0x1B
|
||||||
|
};
|
||||||
|
DSA *dsa = DSA_new();
|
||||||
|
BIGNUM *p, *q, *g;
|
||||||
|
|
||||||
|
if (dsa == NULL)
|
||||||
|
return NULL;
|
||||||
|
if (!DSA_set0_pqg(dsa, p = BN_bin2bn(dsap_2048, sizeof(dsap_2048), NULL),
|
||||||
|
q = BN_bin2bn(dsaq_2048, sizeof(dsaq_2048), NULL),
|
||||||
|
g = BN_bin2bn(dsag_2048, sizeof(dsag_2048), NULL))) {
|
||||||
|
DSA_free(dsa);
|
||||||
|
BN_free(p);
|
||||||
|
BN_free(q);
|
||||||
|
BN_free(g);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return dsa;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int genkeys(void)
|
||||||
|
{
|
||||||
|
if (!TEST_ptr(dsakey = load_dsa_params()))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!TEST_int_eq(DSA_generate_key(dsakey), 1))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int sign_and_verify(int len)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Per FIPS 186-4, the hash is recommended to be the same length as q.
|
||||||
|
* If the hash is longer than q, the leftmost N bits are used; if the hash
|
||||||
|
* is shorter, then we left-pad (see appendix C.2.1).
|
||||||
|
*/
|
||||||
|
size_t sigLength;
|
||||||
|
int digestlen = BN_num_bytes(DSA_get0_q(dsakey));
|
||||||
|
int ok = 0;
|
||||||
|
|
||||||
|
unsigned char *dataToSign = OPENSSL_malloc(len);
|
||||||
|
unsigned char *paddedData = OPENSSL_malloc(digestlen);
|
||||||
|
unsigned char *signature = NULL;
|
||||||
|
EVP_PKEY_CTX *ctx = NULL;
|
||||||
|
EVP_PKEY *pkey = NULL;
|
||||||
|
|
||||||
|
if (!TEST_ptr(dataToSign) ||
|
||||||
|
!TEST_ptr(paddedData) ||
|
||||||
|
!TEST_int_eq(RAND_bytes(dataToSign, len), 1))
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
memset(paddedData, 0, digestlen);
|
||||||
|
if (len > digestlen)
|
||||||
|
memcpy(paddedData, dataToSign, digestlen);
|
||||||
|
else
|
||||||
|
memcpy(paddedData + digestlen - len, dataToSign, len);
|
||||||
|
|
||||||
|
if (!TEST_ptr(pkey = EVP_PKEY_new()))
|
||||||
|
goto end;
|
||||||
|
EVP_PKEY_set1_DSA(pkey, dsakey);
|
||||||
|
|
||||||
|
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new(pkey, NULL)))
|
||||||
|
goto end;
|
||||||
|
if (!TEST_int_eq(EVP_PKEY_sign_init(ctx), 1))
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
if (EVP_PKEY_sign(ctx, NULL, &sigLength, dataToSign, len) != 1) {
|
||||||
|
TEST_error("Failed to get signature length, len=%d", len);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!TEST_ptr(signature = OPENSSL_malloc(sigLength)))
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
if (EVP_PKEY_sign(ctx, signature, &sigLength, dataToSign, len) != 1) {
|
||||||
|
TEST_error("Failed to sign, len=%d", len);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check that the signature is okay via the EVP interface */
|
||||||
|
if (!TEST_int_eq(EVP_PKEY_verify_init(ctx), 1))
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
/* ... using the same data we just signed */
|
||||||
|
if (EVP_PKEY_verify(ctx, signature, sigLength, dataToSign, len) != 1) {
|
||||||
|
TEST_error("EVP verify with unpadded length %d failed\n", len);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ... padding/truncating the data to the appropriate digest size */
|
||||||
|
if (EVP_PKEY_verify(ctx, signature, sigLength, paddedData, digestlen) != 1) {
|
||||||
|
TEST_error("EVP verify with length %d failed\n", len);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Verify again using the raw DSA interface */
|
||||||
|
if (DSA_verify(0, dataToSign, len, signature, sigLength, dsakey) != 1) {
|
||||||
|
TEST_error("Verification with unpadded data failed, len=%d", len);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DSA_verify(0, paddedData, digestlen, signature, sigLength, dsakey) != 1) {
|
||||||
|
TEST_error("verify with length %d failed\n", len);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
ok = 1;
|
||||||
|
end:
|
||||||
|
EVP_PKEY_CTX_free(ctx);
|
||||||
|
EVP_PKEY_free(pkey);
|
||||||
|
|
||||||
|
OPENSSL_free(signature);
|
||||||
|
OPENSSL_free(paddedData);
|
||||||
|
OPENSSL_free(dataToSign);
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dsa_exact_size_test(void) {
|
||||||
|
/*
|
||||||
|
* For a 2048-bit p, q should be either 224 or 256 bits per the table in
|
||||||
|
* FIPS 186-4 4.2.
|
||||||
|
*/
|
||||||
|
|
||||||
|
return sign_and_verify(224 / 8) && sign_and_verify(256 / 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dsa_small_digest_test(void) {
|
||||||
|
return sign_and_verify(16) && sign_and_verify(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dsa_large_digest_test(void) {
|
||||||
|
return sign_and_verify(33) && sign_and_verify(64);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cleanup_tests(void)
|
||||||
|
{
|
||||||
|
DSA_free(dsakey);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* OPENSSL_NO_DSA */
|
||||||
|
|
||||||
|
int setup_tests(void)
|
||||||
|
{
|
||||||
|
#ifndef OPENSSL_NO_DSA
|
||||||
|
if (!genkeys())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ADD_TEST(dsa_exact_size_test);
|
||||||
|
ADD_TEST(dsa_small_digest_test);
|
||||||
|
ADD_TEST(dsa_large_digest_test);
|
||||||
|
#endif
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
+2
-3
@@ -45,14 +45,13 @@ static BIGNUM *walk_curve(const EC_GROUP *group, EC_POINT *point, int64_t num)
|
|||||||
int64_t i;
|
int64_t i;
|
||||||
|
|
||||||
if (!TEST_ptr(scalar = BN_new())
|
if (!TEST_ptr(scalar = BN_new())
|
||||||
|| !TEST_true(EC_POINT_get_affine_coordinates_GFp(group, point,
|
|| !TEST_true(EC_POINT_get_affine_coordinates(group, point, scalar,
|
||||||
scalar,
|
|
||||||
NULL, NULL)))
|
NULL, NULL)))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
if (!TEST_true(EC_POINT_mul(group, point, NULL, point, scalar, NULL))
|
if (!TEST_true(EC_POINT_mul(group, point, NULL, point, scalar, NULL))
|
||||||
|| !TEST_true(EC_POINT_get_affine_coordinates_GFp(group, point,
|
|| !TEST_true(EC_POINT_get_affine_coordinates(group, point,
|
||||||
scalar,
|
scalar,
|
||||||
NULL, NULL)))
|
NULL, NULL)))
|
||||||
goto err;
|
goto err;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user