Compare commits
193 Commits
OpenSSL_1_
...
OpenSSL_1_
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3a9a032163 | ||
![]() |
b83ceba7d5 | ||
![]() |
d9738d5f07 | ||
![]() |
583f0bc402 | ||
![]() |
e8e878bec7 | ||
![]() |
6099e629f5 | ||
![]() |
3570086760 | ||
![]() |
acb341eb6e | ||
![]() |
8fb2c9922a | ||
![]() |
a97c208c5a | ||
![]() |
cc6e9f9abb | ||
![]() |
56cd740449 | ||
![]() |
8437225d34 | ||
![]() |
b4a57c4c41 | ||
![]() |
faa8038edd | ||
![]() |
e02863b5ac | ||
![]() |
04685bc949 | ||
![]() |
98a0f9660d | ||
![]() |
45fe66b8ba | ||
![]() |
8d7aab986b | ||
![]() |
e078642dde | ||
![]() |
ffd14272c4 | ||
![]() |
f16f3ac559 | ||
![]() |
4fb433d221 | ||
![]() |
293c1e2235 | ||
![]() |
d5e16a711e | ||
![]() |
178c562a46 | ||
![]() |
61052e891e | ||
![]() |
cb951e336b | ||
![]() |
37580f43b5 | ||
![]() |
ef28c6d676 | ||
![]() |
2175744952 | ||
![]() |
2357cd2e20 | ||
![]() |
5951cc004b | ||
![]() |
a8565530e2 | ||
![]() |
9e9ee7e37f | ||
![]() |
500d67f15a | ||
![]() |
40fb8587ed | ||
![]() |
c14a808c51 | ||
![]() |
cdf42d7b43 | ||
![]() |
7858d304bc | ||
![]() |
f14a6bf515 | ||
![]() |
5dad57536f | ||
![]() |
a5fad4d6bc | ||
![]() |
d6c2e3e621 | ||
![]() |
8c46748bcb | ||
![]() |
86edf13b1c | ||
![]() |
fcd9b1073a | ||
![]() |
036df29387 | ||
![]() |
60b7d3bbb5 | ||
![]() |
7e9d42ce97 | ||
![]() |
b3147fcbe6 | ||
![]() |
feefb73ad9 | ||
![]() |
8932b82f7d | ||
![]() |
a4a759acec | ||
![]() |
6e5a554533 | ||
![]() |
2164a17a7d | ||
![]() |
dc1e493808 | ||
![]() |
1fe8304db0 | ||
![]() |
bfd19df6d0 | ||
![]() |
7f9edfd23a | ||
![]() |
9673056c25 | ||
![]() |
f50730d361 | ||
![]() |
9beb948c0d | ||
![]() |
ce5ddefc43 | ||
![]() |
458f23f610 | ||
![]() |
c983a77887 | ||
![]() |
7516eaf492 | ||
![]() |
c6a84ff351 | ||
![]() |
b8b9bcb458 | ||
![]() |
be617fbaf8 | ||
![]() |
321ba85899 | ||
![]() |
fcabfc66ae | ||
![]() |
9844573039 | ||
![]() |
6579603874 | ||
![]() |
d68aade28a | ||
![]() |
3242e5938b | ||
![]() |
35384e8e5b | ||
![]() |
4c21e004a3 | ||
![]() |
59ee70e386 | ||
![]() |
43e569921e | ||
![]() |
8aaeec9f9a | ||
![]() |
8454d3f924 | ||
![]() |
5004c22c25 | ||
![]() |
e96872f4c0 | ||
![]() |
14e9a78d47 | ||
![]() |
2aca9b272e | ||
![]() |
26d7cb400e | ||
![]() |
2db95e094d | ||
![]() |
5fc8bb6ab7 | ||
![]() |
244d0955ad | ||
![]() |
061e68c554 | ||
![]() |
3f1d582f70 | ||
![]() |
8a2e5bf6b7 | ||
![]() |
6c3d948723 | ||
![]() |
51c5ab5d3a | ||
![]() |
ff60f33811 | ||
![]() |
2cfa5edb26 | ||
![]() |
291a3e9629 | ||
![]() |
2184a14b62 | ||
![]() |
2e84084fbc | ||
![]() |
26f9cfbdca | ||
![]() |
7fc5f4f117 | ||
![]() |
249a3e362f | ||
![]() |
15d717f574 | ||
![]() |
b8712b2b9a | ||
![]() |
1eaccbef57 | ||
![]() |
e2f69f5ce7 | ||
![]() |
821bee4333 | ||
![]() |
8b6205c484 | ||
![]() |
e5cf62b04d | ||
![]() |
b1edca2a4c | ||
![]() |
e7768ebbd2 | ||
![]() |
329a76c085 | ||
![]() |
bbb76be9b5 | ||
![]() |
b726b8a60c | ||
![]() |
e298409c34 | ||
![]() |
25012d5e79 | ||
![]() |
09b7de77b3 | ||
![]() |
9bdedec0cf | ||
![]() |
f63fa8b10a | ||
![]() |
d47aebbb47 | ||
![]() |
08931f1cd6 | ||
![]() |
6ce9687b5a | ||
![]() |
20e610580e | ||
![]() |
4fa17211bb | ||
![]() |
d8d40fc676 | ||
![]() |
3c7fcdfdd4 | ||
![]() |
e356ac5c06 | ||
![]() |
872e681c00 | ||
![]() |
38b71ba8ff | ||
![]() |
f8cf36c298 | ||
![]() |
26a59d9b46 | ||
![]() |
7fd4ce6a99 | ||
![]() |
d9d09a8d0f | ||
![]() |
2b0532f398 | ||
![]() |
7d07c75c5b | ||
![]() |
f34297db80 | ||
![]() |
e2e5326e5b | ||
![]() |
592c6e1191 | ||
![]() |
8202802fad | ||
![]() |
f79bb32926 | ||
![]() |
7a3809fd97 | ||
![]() |
f13a149088 | ||
![]() |
fc586d2955 | ||
![]() |
17d45dec4d | ||
![]() |
6bfe55380a | ||
![]() |
4e05aedbca | ||
![]() |
bf3e200eb4 | ||
![]() |
55614f89f0 | ||
![]() |
b1620443f3 | ||
![]() |
4ed98b6e25 | ||
![]() |
3a33923515 | ||
![]() |
f2df488a1c | ||
![]() |
8d507aee7c | ||
![]() |
133145686e | ||
![]() |
0f04b004ac | ||
![]() |
81e3a6055c | ||
![]() |
bea9a17726 | ||
![]() |
b537ea9ce4 | ||
![]() |
13ce52be1b | ||
![]() |
11853c50ec | ||
![]() |
a60aa7e008 | ||
![]() |
a49256a349 | ||
![]() |
e517dfd3d1 | ||
![]() |
74687f5979 | ||
![]() |
8dc6617ad5 | ||
![]() |
c2119214c2 | ||
![]() |
22387f00b6 | ||
![]() |
4d16915381 | ||
![]() |
e7169a5835 | ||
![]() |
abc2dfbcc3 | ||
![]() |
23ea9f6f03 | ||
![]() |
3e5df37861 | ||
![]() |
4e5f9f8a9a | ||
![]() |
9446ecfb3a | ||
![]() |
48ecdec7a0 | ||
![]() |
8f5f782253 | ||
![]() |
228a77a4ad | ||
![]() |
03b17a5789 | ||
![]() |
391f3b5708 | ||
![]() |
fe9b9a880f | ||
![]() |
9f96ea4c2b | ||
![]() |
41a765182f | ||
![]() |
bcdd904c6c | ||
![]() |
a90b1e32d2 | ||
![]() |
0ed8e95c4b | ||
![]() |
6b5b85f4f6 | ||
![]() |
03ebf85f77 | ||
![]() |
30fbe92c78 | ||
![]() |
1241e77f15 | ||
![]() |
1433cac53c | ||
![]() |
204fb36a0e |
32
.gitignore
vendored
32
.gitignore
vendored
@@ -1,5 +1,6 @@
|
||||
# Object files
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# editor artefacts
|
||||
*.swp
|
||||
@@ -47,6 +48,21 @@
|
||||
*.s
|
||||
!/crypto/bn/asm/pa-risc2.s
|
||||
!/crypto/bn/asm/pa-risc2W.s
|
||||
crypto/aes/asm/a_win32.asm
|
||||
crypto/bf/asm/b_win32.asm
|
||||
crypto/bn/asm/bn_win32.asm
|
||||
crypto/bn/asm/co_win32.asm
|
||||
crypto/bn/asm/mt_win32.asm
|
||||
crypto/cast/asm/c_win32.asm
|
||||
crypto/cpu_win32.asm
|
||||
crypto/des/asm/d_win32.asm
|
||||
crypto/des/asm/y_win32.asm
|
||||
crypto/md5/asm/m5_win32.asm
|
||||
crypto/rc4/asm/r4_win32.asm
|
||||
crypto/rc5/asm/r5_win32.asm
|
||||
crypto/ripemd/asm/rm_win32.asm
|
||||
crypto/sha/asm/s1_win32.asm
|
||||
crypto/sha/asm/sha512-sse2.asm
|
||||
|
||||
# Executables
|
||||
/apps/openssl
|
||||
@@ -75,3 +91,19 @@
|
||||
lib
|
||||
Makefile.save
|
||||
*.bak
|
||||
tags
|
||||
TAGS
|
||||
|
||||
# Windows
|
||||
/tmp32dll
|
||||
/tmp32dll.dbg
|
||||
/out32dll
|
||||
/out32dll.dbg
|
||||
/inc32
|
||||
/MINFO
|
||||
ms/bcb.mak
|
||||
ms/libeay32.def
|
||||
ms/nt.mak
|
||||
ms/ntdll.mak
|
||||
ms/ssleay32.def
|
||||
ms/version32.rc
|
||||
|
190
CHANGES
190
CHANGES
@@ -2,6 +2,196 @@
|
||||
OpenSSL CHANGES
|
||||
_______________
|
||||
|
||||
Changes between 1.0.1l and 1.0.1m [xx XXX xxxx]
|
||||
|
||||
*)
|
||||
|
||||
Changes between 1.0.1k and 1.0.1l [15 Jan 2015]
|
||||
|
||||
*) Build fixes for the Windows and OpenVMS platforms
|
||||
[Matt Caswell and Richard Levitte]
|
||||
|
||||
Changes between 1.0.1j and 1.0.1k [8 Jan 2015]
|
||||
|
||||
*) Fix DTLS segmentation fault in dtls1_get_record. A carefully crafted DTLS
|
||||
message can cause a segmentation fault in OpenSSL due to a NULL pointer
|
||||
dereference. This could lead to a Denial Of Service attack. Thanks to
|
||||
Markus Stenberg of Cisco Systems, Inc. for reporting this issue.
|
||||
(CVE-2014-3571)
|
||||
[Steve Henson]
|
||||
|
||||
*) Fix DTLS memory leak in dtls1_buffer_record. A memory leak can occur in the
|
||||
dtls1_buffer_record function under certain conditions. In particular this
|
||||
could occur if an attacker sent repeated DTLS records with the same
|
||||
sequence number but for the next epoch. The memory leak could be exploited
|
||||
by an attacker in a Denial of Service attack through memory exhaustion.
|
||||
Thanks to Chris Mueller for reporting this issue.
|
||||
(CVE-2015-0206)
|
||||
[Matt Caswell]
|
||||
|
||||
*) Fix issue where no-ssl3 configuration sets method to NULL. When openssl is
|
||||
built with the no-ssl3 option and a SSL v3 ClientHello is received the ssl
|
||||
method would be set to NULL which could later result in a NULL pointer
|
||||
dereference. Thanks to Frank Schmirler for reporting this issue.
|
||||
(CVE-2014-3569)
|
||||
[Kurt Roeckx]
|
||||
|
||||
*) Abort handshake if server key exchange message is omitted for ephemeral
|
||||
ECDH ciphersuites.
|
||||
|
||||
Thanks to Karthikeyan Bhargavan of the PROSECCO team at INRIA for
|
||||
reporting this issue.
|
||||
(CVE-2014-3572)
|
||||
[Steve Henson]
|
||||
|
||||
*) Remove non-export ephemeral RSA code on client and server. This code
|
||||
violated the TLS standard by allowing the use of temporary RSA keys in
|
||||
non-export ciphersuites and could be used by a server to effectively
|
||||
downgrade the RSA key length used to a value smaller than the server
|
||||
certificate. Thanks for Karthikeyan Bhargavan of the PROSECCO team at
|
||||
INRIA or reporting this issue.
|
||||
(CVE-2015-0204)
|
||||
[Steve Henson]
|
||||
|
||||
*) Fixed issue where DH client certificates are accepted without verification.
|
||||
An OpenSSL server will accept a DH certificate for client authentication
|
||||
without the certificate verify message. This effectively allows a client to
|
||||
authenticate without the use of a private key. This only affects servers
|
||||
which trust a client certificate authority which issues certificates
|
||||
containing DH keys: these are extremely rare and hardly ever encountered.
|
||||
Thanks for Karthikeyan Bhargavan of the PROSECCO team at INRIA or reporting
|
||||
this issue.
|
||||
(CVE-2015-0205)
|
||||
[Steve Henson]
|
||||
|
||||
*) Ensure that the session ID context of an SSL is updated when its
|
||||
SSL_CTX is updated via SSL_set_SSL_CTX.
|
||||
|
||||
The session ID context is typically set from the parent SSL_CTX,
|
||||
and can vary with the CTX.
|
||||
[Adam Langley]
|
||||
|
||||
*) Fix various certificate fingerprint issues.
|
||||
|
||||
By using non-DER or invalid encodings outside the signed portion of a
|
||||
certificate the fingerprint can be changed without breaking the signature.
|
||||
Although no details of the signed portion of the certificate can be changed
|
||||
this can cause problems with some applications: e.g. those using the
|
||||
certificate fingerprint for blacklists.
|
||||
|
||||
1. Reject signatures with non zero unused bits.
|
||||
|
||||
If the BIT STRING containing the signature has non zero unused bits reject
|
||||
the signature. All current signature algorithms require zero unused bits.
|
||||
|
||||
2. Check certificate algorithm consistency.
|
||||
|
||||
Check the AlgorithmIdentifier inside TBS matches the one in the
|
||||
certificate signature. NB: this will result in signature failure
|
||||
errors for some broken certificates.
|
||||
|
||||
Thanks to Konrad Kraszewski from Google for reporting this issue.
|
||||
|
||||
3. Check DSA/ECDSA signatures use DER.
|
||||
|
||||
Reencode DSA/ECDSA signatures and compare with the original received
|
||||
signature. Return an error if there is a mismatch.
|
||||
|
||||
This will reject various cases including garbage after signature
|
||||
(thanks to Antti Karjalainen and Tuomo Untinen from the Codenomicon CROSS
|
||||
program for discovering this case) and use of BER or invalid ASN.1 INTEGERs
|
||||
(negative or with leading zeroes).
|
||||
|
||||
Further analysis was conducted and fixes were developed by Stephen Henson
|
||||
of the OpenSSL core team.
|
||||
|
||||
(CVE-2014-8275)
|
||||
[Steve Henson]
|
||||
|
||||
*) Correct Bignum squaring. Bignum squaring (BN_sqr) may produce incorrect
|
||||
results on some platforms, including x86_64. This bug occurs at random
|
||||
with a very low probability, and is not known to be exploitable in any
|
||||
way, though its exact impact is difficult to determine. Thanks to Pieter
|
||||
Wuille (Blockstream) who reported this issue and also suggested an initial
|
||||
fix. Further analysis was conducted by the OpenSSL development team and
|
||||
Adam Langley of Google. The final fix was developed by Andy Polyakov of
|
||||
the OpenSSL core team.
|
||||
(CVE-2014-3570)
|
||||
[Andy Polyakov]
|
||||
|
||||
*) Do not resume sessions on the server if the negotiated protocol
|
||||
version does not match the session's version. Resuming with a different
|
||||
version, while not strictly forbidden by the RFC, is of questionable
|
||||
sanity and breaks all known clients.
|
||||
[David Benjamin, Emilia K<>sper]
|
||||
|
||||
*) Tighten handling of the ChangeCipherSpec (CCS) message: reject
|
||||
early CCS messages during renegotiation. (Note that because
|
||||
renegotiation is encrypted, this early CCS was not exploitable.)
|
||||
[Emilia K<>sper]
|
||||
|
||||
*) Tighten client-side session ticket handling during renegotiation:
|
||||
ensure that the client only accepts a session ticket if the server sends
|
||||
the extension anew in the ServerHello. Previously, a TLS client would
|
||||
reuse the old extension state and thus accept a session ticket if one was
|
||||
announced in the initial ServerHello.
|
||||
|
||||
Similarly, ensure that the client requires a session ticket if one
|
||||
was advertised in the ServerHello. Previously, a TLS client would
|
||||
ignore a missing NewSessionTicket message.
|
||||
[Emilia K<>sper]
|
||||
|
||||
Changes between 1.0.1i and 1.0.1j [15 Oct 2014]
|
||||
|
||||
*) SRTP Memory Leak.
|
||||
|
||||
A flaw in the DTLS SRTP extension parsing code allows an attacker, who
|
||||
sends a carefully crafted handshake message, to cause OpenSSL to fail
|
||||
to free up to 64k of memory causing a memory leak. This could be
|
||||
exploited in a Denial Of Service attack. This issue affects OpenSSL
|
||||
1.0.1 server implementations for both SSL/TLS and DTLS regardless of
|
||||
whether SRTP is used or configured. Implementations of OpenSSL that
|
||||
have been compiled with OPENSSL_NO_SRTP defined are not affected.
|
||||
|
||||
The fix was developed by the OpenSSL team.
|
||||
(CVE-2014-3513)
|
||||
[OpenSSL team]
|
||||
|
||||
*) Session Ticket Memory Leak.
|
||||
|
||||
When an OpenSSL SSL/TLS/DTLS server receives a session ticket the
|
||||
integrity of that ticket is first verified. In the event of a session
|
||||
ticket integrity check failing, OpenSSL will fail to free memory
|
||||
causing a memory leak. By sending a large number of invalid session
|
||||
tickets an attacker could exploit this issue in a Denial Of Service
|
||||
attack.
|
||||
(CVE-2014-3567)
|
||||
[Steve Henson]
|
||||
|
||||
*) Build option no-ssl3 is incomplete.
|
||||
|
||||
When OpenSSL is configured with "no-ssl3" as a build option, servers
|
||||
could accept and complete a SSL 3.0 handshake, and clients could be
|
||||
configured to send them.
|
||||
(CVE-2014-3568)
|
||||
[Akamai and the OpenSSL team]
|
||||
|
||||
*) Add support for TLS_FALLBACK_SCSV.
|
||||
Client applications doing fallback retries should call
|
||||
SSL_set_mode(s, SSL_MODE_SEND_FALLBACK_SCSV).
|
||||
(CVE-2014-3566)
|
||||
[Adam Langley, Bodo Moeller]
|
||||
|
||||
*) Add additional DigestInfo checks.
|
||||
|
||||
Reencode DigestInto in DER and check against the original when
|
||||
verifying RSA signature: this will reject any improperly encoded
|
||||
DigestInfo structures.
|
||||
|
||||
Note: this is a precautionary measure and no attacks are currently known.
|
||||
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 1.0.1h and 1.0.1i [6 Aug 2014]
|
||||
|
||||
*) Fix SRP buffer overrun vulnerability. Invalid parameters passed to the
|
||||
|
11
Configure
11
Configure
@@ -804,6 +804,11 @@ PROCESS_ARGS:
|
||||
{
|
||||
$disabled{"tls1"} = "option(tls)"
|
||||
}
|
||||
elsif ($1 eq "ssl3-method")
|
||||
{
|
||||
$disabled{"ssl3-method"} = "option(ssl)";
|
||||
$disabled{"ssl3"} = "option(ssl)";
|
||||
}
|
||||
else
|
||||
{
|
||||
$disabled{$1} = "option";
|
||||
@@ -1767,6 +1772,9 @@ open(OUT,'>crypto/opensslconf.h.new') || die "unable to create crypto/opensslcon
|
||||
print OUT "/* opensslconf.h */\n";
|
||||
print OUT "/* WARNING: Generated automatically from opensslconf.h.in by Configure. */\n\n";
|
||||
|
||||
print OUT "#ifdef __cplusplus\n";
|
||||
print OUT "extern \"C\" {\n";
|
||||
print OUT "#endif\n";
|
||||
print OUT "/* OpenSSL was configured with the following options: */\n";
|
||||
my $openssl_algorithm_defines_trans = $openssl_algorithm_defines;
|
||||
$openssl_experimental_defines =~ s/^\s*#\s*define\s+OPENSSL_NO_(.*)/#ifndef OPENSSL_EXPERIMENTAL_$1\n# ifndef OPENSSL_NO_$1\n# define OPENSSL_NO_$1\n# endif\n#endif/mg;
|
||||
@@ -1871,6 +1879,9 @@ while (<IN>)
|
||||
{ print OUT $_; }
|
||||
}
|
||||
close(IN);
|
||||
print OUT "#ifdef __cplusplus\n";
|
||||
print OUT "}\n";
|
||||
print OUT "#endif\n";
|
||||
close(OUT);
|
||||
rename("crypto/opensslconf.h","crypto/opensslconf.h.bak") || die "unable to rename crypto/opensslconf.h\n" if -e "crypto/opensslconf.h";
|
||||
rename("crypto/opensslconf.h.new","crypto/opensslconf.h") || die "unable to rename crypto/opensslconf.h.new\n";
|
||||
|
26
NEWS
26
NEWS
@@ -5,6 +5,32 @@
|
||||
This file gives a brief overview of the major changes between each OpenSSL
|
||||
release. For more details please read the CHANGES file.
|
||||
|
||||
Major changes between OpenSSL 1.0.1l and OpenSSL 1.0.1m [under development]
|
||||
|
||||
o
|
||||
|
||||
Major changes between OpenSSL 1.0.1k and OpenSSL 1.0.1l [15 Jan 2015]
|
||||
|
||||
o Build fixes for the Windows and OpenVMS platforms
|
||||
|
||||
Major changes between OpenSSL 1.0.1j and OpenSSL 1.0.1k [8 Jan 2015]
|
||||
|
||||
o Fix for CVE-2014-3571
|
||||
o Fix for CVE-2015-0206
|
||||
o Fix for CVE-2014-3569
|
||||
o Fix for CVE-2014-3572
|
||||
o Fix for CVE-2015-0204
|
||||
o Fix for CVE-2015-0205
|
||||
o Fix for CVE-2014-8275
|
||||
o Fix for CVE-2014-3570
|
||||
|
||||
Major changes between OpenSSL 1.0.1i and OpenSSL 1.0.1j [15 Oct 2014]
|
||||
|
||||
o Fix for CVE-2014-3513
|
||||
o Fix for CVE-2014-3567
|
||||
o Mitigation for CVE-2014-3566 (SSL protocol vulnerability)
|
||||
o Fix for CVE-2014-3568
|
||||
|
||||
Major changes between OpenSSL 1.0.1h and OpenSSL 1.0.1i [6 Aug 2014]
|
||||
|
||||
o Fix for CVE-2014-3512
|
||||
|
2
README
2
README
@@ -1,5 +1,5 @@
|
||||
|
||||
OpenSSL 1.0.1i 6 Aug 2014
|
||||
OpenSSL 1.0.1m-dev
|
||||
|
||||
Copyright (c) 1998-2011 The OpenSSL Project
|
||||
Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
|
||||
|
@@ -703,7 +703,7 @@ bad:
|
||||
ERR_clear_error();
|
||||
#ifdef RL_DEBUG
|
||||
if (!p)
|
||||
BIO_printf(bio_err, "DEBUG: unique_subject undefined\n", p);
|
||||
BIO_printf(bio_err, "DEBUG: unique_subject undefined\n");
|
||||
#endif
|
||||
#ifdef RL_DEBUG
|
||||
BIO_printf(bio_err, "DEBUG: configured unique_subject is %d\n",
|
||||
|
@@ -273,6 +273,8 @@ int MAIN(int argc, char **argv)
|
||||
BIO_printf(bio_err,"-d to output debug info\n");
|
||||
BIO_printf(bio_err,"-hex output as hex dump\n");
|
||||
BIO_printf(bio_err,"-binary output in binary form\n");
|
||||
BIO_printf(bio_err,"-hmac arg set the HMAC key to arg\n");
|
||||
BIO_printf(bio_err,"-non-fips-allow allow use of non FIPS digest\n");
|
||||
BIO_printf(bio_err,"-sign file sign digest using private key in file\n");
|
||||
BIO_printf(bio_err,"-verify file verify a signature using public key in file\n");
|
||||
BIO_printf(bio_err,"-prverify file verify a signature using private key in file\n");
|
||||
|
@@ -773,9 +773,12 @@ $ CCDEFS = "MONOLITH"
|
||||
$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
|
||||
$ CCEXTRAFLAGS = ""
|
||||
$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
|
||||
$ CCDISABLEWARNINGS = "" !!! "LONGLONGTYPE,LONGLONGSUFX,FOUNDCR"
|
||||
$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
|
||||
CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," + USER_CCDISABLEWARNINGS
|
||||
$ CCDISABLEWARNINGS = "" !!! "MAYLOSEDATA3" !!! "LONGLONGTYPE,LONGLONGSUFX,FOUNDCR"
|
||||
$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. ""
|
||||
$ THEN
|
||||
$ IF CCDISABLEWARNINGS .NES. "" THEN CCDISABLEWARNINGS = CCDISABLEWARNINGS + ","
|
||||
$ CCDISABLEWARNINGS = CCDISABLEWARNINGS + USER_CCDISABLEWARNINGS
|
||||
$ ENDIF
|
||||
$!
|
||||
$! Check To See If We Have A ZLIB Option.
|
||||
$!
|
||||
@@ -1064,6 +1067,18 @@ $! Finish up the definition of CC.
|
||||
$!
|
||||
$ IF COMPILER .EQS. "DECC"
|
||||
$ THEN
|
||||
$! Not all compiler versions support MAYLOSEDATA3.
|
||||
$ OPT_TEST = "MAYLOSEDATA3"
|
||||
$ DEFINE /USER_MODE SYS$ERROR NL:
|
||||
$ DEFINE /USER_MODE SYS$OUTPUT NL:
|
||||
$ 'CC' /NOCROSS_REFERENCE /NOLIST /NOOBJECT -
|
||||
/WARNINGS = DISABLE = ('OPT_TEST', EMPTYFILE) NL:
|
||||
$ IF ($SEVERITY)
|
||||
$ THEN
|
||||
$ IF CCDISABLEWARNINGS .NES. "" THEN -
|
||||
CCDISABLEWARNINGS = CCDISABLEWARNINGS+ ","
|
||||
$ CCDISABLEWARNINGS = CCDISABLEWARNINGS+ OPT_TEST
|
||||
$ ENDIF
|
||||
$ IF CCDISABLEWARNINGS .NES. ""
|
||||
$ THEN
|
||||
$ CCDISABLEWARNINGS = " /WARNING=(DISABLE=(" + CCDISABLEWARNINGS + "))"
|
||||
|
98
apps/ocsp.c
98
apps/ocsp.c
@@ -583,51 +583,52 @@ int MAIN(int argc, char **argv)
|
||||
BIO_printf (bio_err, "OCSP utility\n");
|
||||
BIO_printf (bio_err, "Usage ocsp [options]\n");
|
||||
BIO_printf (bio_err, "where options are\n");
|
||||
BIO_printf (bio_err, "-out file output filename\n");
|
||||
BIO_printf (bio_err, "-issuer file issuer certificate\n");
|
||||
BIO_printf (bio_err, "-cert file certificate to check\n");
|
||||
BIO_printf (bio_err, "-serial n serial number to check\n");
|
||||
BIO_printf (bio_err, "-signer file certificate to sign OCSP request with\n");
|
||||
BIO_printf (bio_err, "-signkey file private key to sign OCSP request with\n");
|
||||
BIO_printf (bio_err, "-sign_other file additional certificates to include in signed request\n");
|
||||
BIO_printf (bio_err, "-no_certs don't include any certificates in signed request\n");
|
||||
BIO_printf (bio_err, "-req_text print text form of request\n");
|
||||
BIO_printf (bio_err, "-resp_text print text form of response\n");
|
||||
BIO_printf (bio_err, "-text print text form of request and response\n");
|
||||
BIO_printf (bio_err, "-reqout file write DER encoded OCSP request to \"file\"\n");
|
||||
BIO_printf (bio_err, "-respout file write DER encoded OCSP reponse to \"file\"\n");
|
||||
BIO_printf (bio_err, "-reqin file read DER encoded OCSP request from \"file\"\n");
|
||||
BIO_printf (bio_err, "-respin file read DER encoded OCSP reponse from \"file\"\n");
|
||||
BIO_printf (bio_err, "-nonce add OCSP nonce to request\n");
|
||||
BIO_printf (bio_err, "-no_nonce don't add OCSP nonce to request\n");
|
||||
BIO_printf (bio_err, "-url URL OCSP responder URL\n");
|
||||
BIO_printf (bio_err, "-host host:n send OCSP request to host on port n\n");
|
||||
BIO_printf (bio_err, "-path path to use in OCSP request\n");
|
||||
BIO_printf (bio_err, "-CApath dir trusted certificates directory\n");
|
||||
BIO_printf (bio_err, "-CAfile file trusted certificates file\n");
|
||||
BIO_printf (bio_err, "-VAfile file validator certificates file\n");
|
||||
BIO_printf (bio_err, "-validity_period n maximum validity discrepancy in seconds\n");
|
||||
BIO_printf (bio_err, "-status_age n maximum status age in seconds\n");
|
||||
BIO_printf (bio_err, "-noverify don't verify response at all\n");
|
||||
BIO_printf (bio_err, "-verify_other file additional certificates to search for signer\n");
|
||||
BIO_printf (bio_err, "-trust_other don't verify additional certificates\n");
|
||||
BIO_printf (bio_err, "-no_intern don't search certificates contained in response for signer\n");
|
||||
BIO_printf (bio_err, "-out file output filename\n");
|
||||
BIO_printf (bio_err, "-issuer file issuer certificate\n");
|
||||
BIO_printf (bio_err, "-cert file certificate to check\n");
|
||||
BIO_printf (bio_err, "-serial n serial number to check\n");
|
||||
BIO_printf (bio_err, "-signer file certificate to sign OCSP request with\n");
|
||||
BIO_printf (bio_err, "-signkey file private key to sign OCSP request with\n");
|
||||
BIO_printf (bio_err, "-sign_other file additional certificates to include in signed request\n");
|
||||
BIO_printf (bio_err, "-no_certs don't include any certificates in signed request\n");
|
||||
BIO_printf (bio_err, "-req_text print text form of request\n");
|
||||
BIO_printf (bio_err, "-resp_text print text form of response\n");
|
||||
BIO_printf (bio_err, "-text print text form of request and response\n");
|
||||
BIO_printf (bio_err, "-reqout file write DER encoded OCSP request to \"file\"\n");
|
||||
BIO_printf (bio_err, "-respout file write DER encoded OCSP reponse to \"file\"\n");
|
||||
BIO_printf (bio_err, "-reqin file read DER encoded OCSP request from \"file\"\n");
|
||||
BIO_printf (bio_err, "-respin file read DER encoded OCSP reponse from \"file\"\n");
|
||||
BIO_printf (bio_err, "-nonce add OCSP nonce to request\n");
|
||||
BIO_printf (bio_err, "-no_nonce don't add OCSP nonce to request\n");
|
||||
BIO_printf (bio_err, "-url URL OCSP responder URL\n");
|
||||
BIO_printf (bio_err, "-host host:n send OCSP request to host on port n\n");
|
||||
BIO_printf (bio_err, "-path path to use in OCSP request\n");
|
||||
BIO_printf (bio_err, "-CApath dir trusted certificates directory\n");
|
||||
BIO_printf (bio_err, "-CAfile file trusted certificates file\n");
|
||||
BIO_printf (bio_err, "-VAfile file validator certificates file\n");
|
||||
BIO_printf (bio_err, "-validity_period n maximum validity discrepancy in seconds\n");
|
||||
BIO_printf (bio_err, "-status_age n maximum status age in seconds\n");
|
||||
BIO_printf (bio_err, "-noverify don't verify response at all\n");
|
||||
BIO_printf (bio_err, "-verify_other file additional certificates to search for signer\n");
|
||||
BIO_printf (bio_err, "-trust_other don't verify additional certificates\n");
|
||||
BIO_printf (bio_err, "-no_intern don't search certificates contained in response for signer\n");
|
||||
BIO_printf (bio_err, "-no_signature_verify don't check signature on response\n");
|
||||
BIO_printf (bio_err, "-no_cert_verify don't check signing certificate\n");
|
||||
BIO_printf (bio_err, "-no_chain don't chain verify response\n");
|
||||
BIO_printf (bio_err, "-no_cert_checks don't do additional checks on signing certificate\n");
|
||||
BIO_printf (bio_err, "-port num port to run responder on\n");
|
||||
BIO_printf (bio_err, "-index file certificate status index file\n");
|
||||
BIO_printf (bio_err, "-CA file CA certificate\n");
|
||||
BIO_printf (bio_err, "-rsigner file responder certificate to sign responses with\n");
|
||||
BIO_printf (bio_err, "-rkey file responder key to sign responses with\n");
|
||||
BIO_printf (bio_err, "-rother file other certificates to include in response\n");
|
||||
BIO_printf (bio_err, "-resp_no_certs don't include any certificates in response\n");
|
||||
BIO_printf (bio_err, "-nmin n number of minutes before next update\n");
|
||||
BIO_printf (bio_err, "-ndays n number of days before next update\n");
|
||||
BIO_printf (bio_err, "-resp_key_id identify reponse by signing certificate key ID\n");
|
||||
BIO_printf (bio_err, "-nrequest n number of requests to accept (default unlimited)\n");
|
||||
BIO_printf (bio_err, "-<dgst alg> use specified digest in the request\n");
|
||||
BIO_printf (bio_err, "-no_cert_verify don't check signing certificate\n");
|
||||
BIO_printf (bio_err, "-no_chain don't chain verify response\n");
|
||||
BIO_printf (bio_err, "-no_cert_checks don't do additional checks on signing certificate\n");
|
||||
BIO_printf (bio_err, "-port num port to run responder on\n");
|
||||
BIO_printf (bio_err, "-index file certificate status index file\n");
|
||||
BIO_printf (bio_err, "-CA file CA certificate\n");
|
||||
BIO_printf (bio_err, "-rsigner file responder certificate to sign responses with\n");
|
||||
BIO_printf (bio_err, "-rkey file responder key to sign responses with\n");
|
||||
BIO_printf (bio_err, "-rother file other certificates to include in response\n");
|
||||
BIO_printf (bio_err, "-resp_no_certs don't include any certificates in response\n");
|
||||
BIO_printf (bio_err, "-nmin n number of minutes before next update\n");
|
||||
BIO_printf (bio_err, "-ndays n number of days before next update\n");
|
||||
BIO_printf (bio_err, "-resp_key_id identify reponse by signing certificate key ID\n");
|
||||
BIO_printf (bio_err, "-nrequest n number of requests to accept (default unlimited)\n");
|
||||
BIO_printf (bio_err, "-<dgst alg> use specified digest in the request\n");
|
||||
BIO_printf (bio_err, "-timeout n timeout connection to OCSP responder after n seconds\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -1398,16 +1399,7 @@ OCSP_RESPONSE *process_responder(BIO *err, OCSP_REQUEST *req,
|
||||
if (use_ssl == 1)
|
||||
{
|
||||
BIO *sbio;
|
||||
#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
|
||||
ctx = SSL_CTX_new(SSLv23_client_method());
|
||||
#elif !defined(OPENSSL_NO_SSL3)
|
||||
ctx = SSL_CTX_new(SSLv3_client_method());
|
||||
#elif !defined(OPENSSL_NO_SSL2)
|
||||
ctx = SSL_CTX_new(SSLv2_client_method());
|
||||
#else
|
||||
BIO_printf(err, "SSL is disabled\n");
|
||||
goto end;
|
||||
#endif
|
||||
if (ctx == NULL)
|
||||
{
|
||||
BIO_printf(err, "Error creating SSL context.\n");
|
||||
|
@@ -435,9 +435,7 @@ end:
|
||||
if (prog != NULL) lh_FUNCTION_free(prog);
|
||||
if (arg.data != NULL) OPENSSL_free(arg.data);
|
||||
|
||||
apps_shutdown();
|
||||
|
||||
CRYPTO_mem_leaks(bio_err);
|
||||
if (bio_err != NULL)
|
||||
{
|
||||
BIO_free(bio_err);
|
||||
@@ -450,6 +448,9 @@ end:
|
||||
OPENSSL_free(Argv);
|
||||
}
|
||||
#endif
|
||||
apps_shutdown();
|
||||
CRYPTO_mem_leaks(bio_err);
|
||||
|
||||
OPENSSL_EXIT(ret);
|
||||
}
|
||||
|
||||
|
@@ -329,14 +329,17 @@ static void sc_usage(void)
|
||||
BIO_printf(bio_err," -srppass arg - password for 'user'\n");
|
||||
BIO_printf(bio_err," -srp_lateuser - SRP username into second ClientHello message\n");
|
||||
BIO_printf(bio_err," -srp_moregroups - Tolerate other than the known g N values.\n");
|
||||
BIO_printf(bio_err," -srp_strength int - minimal mength in bits for N (default %d).\n",SRP_MINIMAL_N);
|
||||
BIO_printf(bio_err," -srp_strength int - minimal length in bits for N (default %d).\n",SRP_MINIMAL_N);
|
||||
#endif
|
||||
BIO_printf(bio_err," -ssl2 - just use SSLv2\n");
|
||||
#ifndef OPENSSL_NO_SSL3_METHOD
|
||||
BIO_printf(bio_err," -ssl3 - just use SSLv3\n");
|
||||
#endif
|
||||
BIO_printf(bio_err," -tls1_2 - just use TLSv1.2\n");
|
||||
BIO_printf(bio_err," -tls1_1 - just use TLSv1.1\n");
|
||||
BIO_printf(bio_err," -tls1 - just use TLSv1\n");
|
||||
BIO_printf(bio_err," -dtls1 - just use DTLSv1\n");
|
||||
BIO_printf(bio_err," -fallback_scsv - send TLS_FALLBACK_SCSV\n");
|
||||
BIO_printf(bio_err," -mtu - set the link layer MTU\n");
|
||||
BIO_printf(bio_err," -no_tls1_2/-no_tls1_1/-no_tls1/-no_ssl3/-no_ssl2 - turn off that protocol\n");
|
||||
BIO_printf(bio_err," -bugs - Switch on all SSL implementation bug workarounds\n");
|
||||
@@ -617,6 +620,7 @@ int MAIN(int argc, char **argv)
|
||||
char *sess_out = NULL;
|
||||
struct sockaddr peer;
|
||||
int peerlen = sizeof(peer);
|
||||
int fallback_scsv = 0;
|
||||
int enable_timeouts = 0 ;
|
||||
long socket_mtu = 0;
|
||||
#ifndef OPENSSL_NO_JPAKE
|
||||
@@ -805,7 +809,7 @@ int MAIN(int argc, char **argv)
|
||||
else if (strcmp(*argv,"-ssl2") == 0)
|
||||
meth=SSLv2_client_method();
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL3
|
||||
#ifndef OPENSSL_NO_SSL3_METHOD
|
||||
else if (strcmp(*argv,"-ssl3") == 0)
|
||||
meth=SSLv3_client_method();
|
||||
#endif
|
||||
@@ -823,6 +827,10 @@ int MAIN(int argc, char **argv)
|
||||
meth=DTLSv1_client_method();
|
||||
socket_type=SOCK_DGRAM;
|
||||
}
|
||||
else if (strcmp(*argv,"-fallback_scsv") == 0)
|
||||
{
|
||||
fallback_scsv = 1;
|
||||
}
|
||||
else if (strcmp(*argv,"-timeout") == 0)
|
||||
enable_timeouts=1;
|
||||
else if (strcmp(*argv,"-mtu") == 0)
|
||||
@@ -1235,6 +1243,10 @@ bad:
|
||||
SSL_set_session(con, sess);
|
||||
SSL_SESSION_free(sess);
|
||||
}
|
||||
|
||||
if (fallback_scsv)
|
||||
SSL_set_mode(con, SSL_MODE_SEND_FALLBACK_SCSV);
|
||||
|
||||
#ifndef OPENSSL_NO_TLSEXT
|
||||
if (servername != NULL)
|
||||
{
|
||||
@@ -1309,10 +1321,22 @@ re_start:
|
||||
BIO_ctrl(sbio, BIO_CTRL_DGRAM_SET_SEND_TIMEOUT, 0, &timeout);
|
||||
}
|
||||
|
||||
if (socket_mtu > 28)
|
||||
if (socket_mtu)
|
||||
{
|
||||
if(socket_mtu < DTLS_get_link_min_mtu(con))
|
||||
{
|
||||
BIO_printf(bio_err,"MTU too small. Must be at least %ld\n",
|
||||
DTLS_get_link_min_mtu(con));
|
||||
BIO_free(sbio);
|
||||
goto shut;
|
||||
}
|
||||
SSL_set_options(con, SSL_OP_NO_QUERY_MTU);
|
||||
SSL_set_mtu(con, socket_mtu - 28);
|
||||
if(!DTLS_set_link_mtu(con, socket_mtu))
|
||||
{
|
||||
BIO_printf(bio_err, "Failed to set MTU\n");
|
||||
BIO_free(sbio);
|
||||
goto shut;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* want to do MTU discovery */
|
||||
|
@@ -515,7 +515,9 @@ static void sv_usage(void)
|
||||
BIO_printf(bio_err," -srpuserseed string - A seed string for a default user salt.\n");
|
||||
#endif
|
||||
BIO_printf(bio_err," -ssl2 - Just talk SSLv2\n");
|
||||
#ifndef OPENSSL_NO_SSL3_METHOD
|
||||
BIO_printf(bio_err," -ssl3 - Just talk SSLv3\n");
|
||||
#endif
|
||||
BIO_printf(bio_err," -tls1_2 - Just talk TLSv1.2\n");
|
||||
BIO_printf(bio_err," -tls1_1 - Just talk TLSv1.1\n");
|
||||
BIO_printf(bio_err," -tls1 - Just talk TLSv1\n");
|
||||
@@ -1251,7 +1253,7 @@ int MAIN(int argc, char *argv[])
|
||||
else if (strcmp(*argv,"-ssl2") == 0)
|
||||
{ meth=SSLv2_server_method(); }
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL3
|
||||
#ifndef OPENSSL_NO_SSL3_METHOD
|
||||
else if (strcmp(*argv,"-ssl3") == 0)
|
||||
{ meth=SSLv3_server_method(); }
|
||||
#endif
|
||||
@@ -2049,10 +2051,24 @@ static int sv_body(char *hostname, int s, unsigned char *context)
|
||||
BIO_ctrl(sbio, BIO_CTRL_DGRAM_SET_SEND_TIMEOUT, 0, &timeout);
|
||||
}
|
||||
|
||||
if (socket_mtu > 28)
|
||||
if (socket_mtu)
|
||||
{
|
||||
if(socket_mtu < DTLS_get_link_min_mtu(con))
|
||||
{
|
||||
BIO_printf(bio_err,"MTU too small. Must be at least %ld\n",
|
||||
DTLS_get_link_min_mtu(con));
|
||||
ret = -1;
|
||||
BIO_free(sbio);
|
||||
goto err;
|
||||
}
|
||||
SSL_set_options(con, SSL_OP_NO_QUERY_MTU);
|
||||
SSL_set_mtu(con, socket_mtu - 28);
|
||||
if(!DTLS_set_link_mtu(con, socket_mtu))
|
||||
{
|
||||
BIO_printf(bio_err, "Failed to set MTU\n");
|
||||
ret = -1;
|
||||
BIO_free(sbio);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* want to do MTU discovery */
|
||||
|
@@ -349,13 +349,7 @@ int MAIN(int argc, char **argv)
|
||||
if (bio_err == NULL)
|
||||
bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
|
||||
|
||||
#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
|
||||
s_time_meth=SSLv23_client_method();
|
||||
#elif !defined(OPENSSL_NO_SSL3)
|
||||
s_time_meth=SSLv3_client_method();
|
||||
#elif !defined(OPENSSL_NO_SSL2)
|
||||
s_time_meth=SSLv2_client_method();
|
||||
#endif
|
||||
|
||||
/* parse the command line arguments */
|
||||
if( parseArgs( argc, argv ) < 0 )
|
||||
|
23
apps/speed.c
23
apps/speed.c
@@ -225,7 +225,7 @@
|
||||
|
||||
#undef BUFSIZE
|
||||
#define BUFSIZE ((long)1024*8+1)
|
||||
int run=0;
|
||||
static volatile int run=0;
|
||||
|
||||
static int mr=0;
|
||||
static int usertime=1;
|
||||
@@ -2727,27 +2727,6 @@ static int do_multi(int multi)
|
||||
k=atoi(sstrsep(&p,sep));
|
||||
sstrsep(&p,sep);
|
||||
|
||||
d=atof(sstrsep(&p,sep));
|
||||
if(n)
|
||||
rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
|
||||
else
|
||||
rsa_results[k][0]=d;
|
||||
|
||||
d=atof(sstrsep(&p,sep));
|
||||
if(n)
|
||||
rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
|
||||
else
|
||||
rsa_results[k][1]=d;
|
||||
}
|
||||
else if(!strncmp(buf,"+F2:",4))
|
||||
{
|
||||
int k;
|
||||
double d;
|
||||
|
||||
p=buf+4;
|
||||
k=atoi(sstrsep(&p,sep));
|
||||
sstrsep(&p,sep);
|
||||
|
||||
d=atof(sstrsep(&p,sep));
|
||||
if(n)
|
||||
rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
|
||||
|
@@ -1,4 +1,3 @@
|
||||
/* $LP: LPlib/source/LPdir_vms.c,v 1.20 2004/08/26 13:36:05 _cvs_levitte Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2004, Richard Levitte <richard@levitte.org>
|
||||
* All rights reserved.
|
||||
@@ -88,6 +87,12 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
|
||||
size_t filespeclen = strlen(directory);
|
||||
char *filespec = NULL;
|
||||
|
||||
if (filespeclen == 0)
|
||||
{
|
||||
errno = ENOENT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* MUST be a VMS directory specification! Let's estimate if it is. */
|
||||
if (directory[filespeclen-1] != ']'
|
||||
&& directory[filespeclen-1] != '>'
|
||||
|
@@ -1,4 +1,3 @@
|
||||
/* $LP: LPlib/source/LPdir_win.c,v 1.10 2004/08/26 13:36:05 _cvs_levitte Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2004, Richard Levitte <richard@levitte.org>
|
||||
* All rights reserved.
|
||||
@@ -37,7 +36,7 @@
|
||||
#if defined(LP_SYS_WINCE) && !defined(FindFirstFile)
|
||||
# define FindFirstFile FindFirstFileW
|
||||
#endif
|
||||
#if defined(LP_SYS_WINCE) && !defined(FindFirstFile)
|
||||
#if defined(LP_SYS_WINCE) && !defined(FindNextFile)
|
||||
# define FindNextFile FindNextFileW
|
||||
#endif
|
||||
|
||||
@@ -63,6 +62,16 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
|
||||
errno = 0;
|
||||
if (*ctx == NULL)
|
||||
{
|
||||
const char *extdir = directory;
|
||||
char *extdirbuf = NULL;
|
||||
size_t dirlen = strlen (directory);
|
||||
|
||||
if (dirlen == 0)
|
||||
{
|
||||
errno = ENOENT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
*ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX));
|
||||
if (*ctx == NULL)
|
||||
{
|
||||
@@ -71,15 +80,35 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
|
||||
}
|
||||
memset(*ctx, '\0', sizeof(LP_DIR_CTX));
|
||||
|
||||
if (directory[dirlen-1] != '*')
|
||||
{
|
||||
extdirbuf = (char *)malloc(dirlen + 3);
|
||||
if (extdirbuf == NULL)
|
||||
{
|
||||
free(*ctx);
|
||||
*ctx = NULL;
|
||||
errno = ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
if (directory[dirlen-1] != '/' && directory[dirlen-1] != '\\')
|
||||
extdir = strcat(strcpy (extdirbuf,directory),"/*");
|
||||
else
|
||||
extdir = strcat(strcpy (extdirbuf,directory),"*");
|
||||
}
|
||||
|
||||
if (sizeof(TCHAR) != sizeof(char))
|
||||
{
|
||||
TCHAR *wdir = NULL;
|
||||
/* len_0 denotes string length *with* trailing 0 */
|
||||
size_t index = 0,len_0 = strlen(directory) + 1;
|
||||
size_t index = 0,len_0 = strlen(extdir) + 1;
|
||||
|
||||
wdir = (TCHAR *)malloc(len_0 * sizeof(TCHAR));
|
||||
wdir = (TCHAR *)calloc(len_0, sizeof(TCHAR));
|
||||
if (wdir == NULL)
|
||||
{
|
||||
if (extdirbuf != NULL)
|
||||
{
|
||||
free (extdirbuf);
|
||||
}
|
||||
free(*ctx);
|
||||
*ctx = NULL;
|
||||
errno = ENOMEM;
|
||||
@@ -87,17 +116,23 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
|
||||
}
|
||||
|
||||
#ifdef LP_MULTIBYTE_AVAILABLE
|
||||
if (!MultiByteToWideChar(CP_ACP, 0, directory, len_0, (WCHAR *)wdir, len_0))
|
||||
if (!MultiByteToWideChar(CP_ACP, 0, extdir, len_0, (WCHAR *)wdir, len_0))
|
||||
#endif
|
||||
for (index = 0; index < len_0; index++)
|
||||
wdir[index] = (TCHAR)directory[index];
|
||||
wdir[index] = (TCHAR)extdir[index];
|
||||
|
||||
(*ctx)->handle = FindFirstFile(wdir, &(*ctx)->ctx);
|
||||
|
||||
free(wdir);
|
||||
}
|
||||
else
|
||||
(*ctx)->handle = FindFirstFile((TCHAR *)directory, &(*ctx)->ctx);
|
||||
{
|
||||
(*ctx)->handle = FindFirstFile((TCHAR *)extdir, &(*ctx)->ctx);
|
||||
}
|
||||
if (extdirbuf != NULL)
|
||||
{
|
||||
free (extdirbuf);
|
||||
}
|
||||
|
||||
if ((*ctx)->handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@@ -114,7 +149,6 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (sizeof(TCHAR) != sizeof(char))
|
||||
{
|
||||
TCHAR *wdir = (*ctx)->ctx.cFileName;
|
||||
|
@@ -31,6 +31,7 @@ CPUID_OBJ=mem_clr.o
|
||||
LIBS=
|
||||
|
||||
GENERAL=Makefile README crypto-lib.com install.com
|
||||
TEST=constant_time_test.c
|
||||
|
||||
LIB= $(TOP)/libcrypto.a
|
||||
SHARED_LIB= libcrypto$(SHLIB_EXT)
|
||||
@@ -43,7 +44,8 @@ SRC= $(LIBSRC)
|
||||
|
||||
EXHEADER= crypto.h opensslv.h opensslconf.h ebcdic.h symhacks.h \
|
||||
ossl_typ.h
|
||||
HEADER= cryptlib.h buildinf.h md32_common.h o_time.h o_str.h o_dir.h $(EXHEADER)
|
||||
HEADER= cryptlib.h buildinf.h md32_common.h o_time.h o_str.h o_dir.h \
|
||||
constant_time_locl.h $(EXHEADER)
|
||||
|
||||
ALL= $(GENERAL) $(SRC) $(HEADER)
|
||||
|
||||
@@ -53,12 +55,7 @@ top:
|
||||
all: shared
|
||||
|
||||
buildinf.h: ../Makefile
|
||||
( echo "#ifndef MK1MF_BUILD"; \
|
||||
echo ' /* auto-generated by crypto/Makefile for crypto/cversion.c */'; \
|
||||
echo ' #define CFLAGS "$(CC) $(CFLAG)"'; \
|
||||
echo ' #define PLATFORM "$(PLATFORM)"'; \
|
||||
echo " #define DATE \"`LC_ALL=C LC_TIME=C date`\""; \
|
||||
echo '#endif' ) >buildinf.h
|
||||
$(PERL) $(TOP)/util/mkbuildinf.pl "$(CC) $(CFLAGS)" "$(PLATFORM)" >buildinf.h
|
||||
|
||||
x86cpuid.s: x86cpuid.pl perlasm/x86asm.pl
|
||||
$(PERL) x86cpuid.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) > $@
|
||||
|
@@ -70,7 +70,7 @@ $pf = ($flavour =~ /nubi/i) ? $t0 : $t2;
|
||||
#
|
||||
######################################################################
|
||||
|
||||
$big_endian=(`echo MIPSEL | $ENV{CC} -E -P -`=~/MIPSEL/)?1:0;
|
||||
$big_endian=(`echo MIPSEL | $ENV{CC} -E -`=~/MIPSEL/)?1:0 if ($ENV{CC});
|
||||
|
||||
for (@ARGV) { $output=$_ if (/^\w[\w\-]*\.\w+$/); }
|
||||
open STDOUT,">$output";
|
||||
|
@@ -525,6 +525,16 @@ $code.=<<___;
|
||||
.type aesni_ecb_encrypt,\@function,5
|
||||
.align 16
|
||||
aesni_ecb_encrypt:
|
||||
___
|
||||
$code.=<<___ if ($win64);
|
||||
lea -0x58(%rsp),%rsp
|
||||
movaps %xmm6,(%rsp)
|
||||
movaps %xmm7,0x10(%rsp)
|
||||
movaps %xmm8,0x20(%rsp)
|
||||
movaps %xmm9,0x30(%rsp)
|
||||
.Lecb_enc_body:
|
||||
___
|
||||
$code.=<<___;
|
||||
and \$-16,$len
|
||||
jz .Lecb_ret
|
||||
|
||||
@@ -805,6 +815,16 @@ $code.=<<___;
|
||||
movups $inout5,0x50($out)
|
||||
|
||||
.Lecb_ret:
|
||||
___
|
||||
$code.=<<___ if ($win64);
|
||||
movaps (%rsp),%xmm6
|
||||
movaps 0x10(%rsp),%xmm7
|
||||
movaps 0x20(%rsp),%xmm8
|
||||
movaps 0x30(%rsp),%xmm9
|
||||
lea 0x58(%rsp),%rsp
|
||||
.Lecb_enc_ret:
|
||||
___
|
||||
$code.=<<___;
|
||||
ret
|
||||
.size aesni_ecb_encrypt,.-aesni_ecb_encrypt
|
||||
___
|
||||
@@ -2730,28 +2750,9 @@ $code.=<<___;
|
||||
.extern __imp_RtlVirtualUnwind
|
||||
___
|
||||
$code.=<<___ if ($PREFIX eq "aesni");
|
||||
.type ecb_se_handler,\@abi-omnipotent
|
||||
.type ecb_ccm64_se_handler,\@abi-omnipotent
|
||||
.align 16
|
||||
ecb_se_handler:
|
||||
push %rsi
|
||||
push %rdi
|
||||
push %rbx
|
||||
push %rbp
|
||||
push %r12
|
||||
push %r13
|
||||
push %r14
|
||||
push %r15
|
||||
pushfq
|
||||
sub \$64,%rsp
|
||||
|
||||
mov 152($context),%rax # pull context->Rsp
|
||||
|
||||
jmp .Lcommon_seh_tail
|
||||
.size ecb_se_handler,.-ecb_se_handler
|
||||
|
||||
.type ccm64_se_handler,\@abi-omnipotent
|
||||
.align 16
|
||||
ccm64_se_handler:
|
||||
ecb_ccm64_se_handler:
|
||||
push %rsi
|
||||
push %rdi
|
||||
push %rbx
|
||||
@@ -2788,7 +2789,7 @@ ccm64_se_handler:
|
||||
lea 0x58(%rax),%rax # adjust stack pointer
|
||||
|
||||
jmp .Lcommon_seh_tail
|
||||
.size ccm64_se_handler,.-ccm64_se_handler
|
||||
.size ecb_ccm64_se_handler,.-ecb_ccm64_se_handler
|
||||
|
||||
.type ctr32_se_handler,\@abi-omnipotent
|
||||
.align 16
|
||||
@@ -2993,14 +2994,15 @@ ___
|
||||
$code.=<<___ if ($PREFIX eq "aesni");
|
||||
.LSEH_info_ecb:
|
||||
.byte 9,0,0,0
|
||||
.rva ecb_se_handler
|
||||
.rva ecb_ccm64_se_handler
|
||||
.rva .Lecb_enc_body,.Lecb_enc_ret # HandlerData[]
|
||||
.LSEH_info_ccm64_enc:
|
||||
.byte 9,0,0,0
|
||||
.rva ccm64_se_handler
|
||||
.rva ecb_ccm64_se_handler
|
||||
.rva .Lccm64_enc_body,.Lccm64_enc_ret # HandlerData[]
|
||||
.LSEH_info_ccm64_dec:
|
||||
.byte 9,0,0,0
|
||||
.rva ccm64_se_handler
|
||||
.rva ecb_ccm64_se_handler
|
||||
.rva .Lccm64_dec_body,.Lccm64_dec_ret # HandlerData[]
|
||||
.LSEH_info_ctr32:
|
||||
.byte 9,0,0,0
|
||||
|
@@ -136,11 +136,16 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
|
||||
|
||||
p= *pp;
|
||||
i= *(p++);
|
||||
if (i > 7)
|
||||
{
|
||||
i=ASN1_R_INVALID_BIT_STRING_BITS_LEFT;
|
||||
goto err;
|
||||
}
|
||||
/* We do this to preserve the settings. If we modify
|
||||
* the settings, via the _set_bit function, we will recalculate
|
||||
* on output */
|
||||
ret->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear */
|
||||
ret->flags|=(ASN1_STRING_FLAG_BITS_LEFT|(i&0x07)); /* set */
|
||||
ret->flags|=(ASN1_STRING_FLAG_BITS_LEFT|i); /* set */
|
||||
|
||||
if (len-- > 1) /* using one because of the bits left byte */
|
||||
{
|
||||
|
@@ -568,6 +568,7 @@ int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in)
|
||||
mbflag |= MBSTRING_FLAG;
|
||||
stmp.data = NULL;
|
||||
stmp.length = 0;
|
||||
stmp.flags = 0;
|
||||
ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag, B_ASN1_UTF8STRING);
|
||||
if(ret < 0) return ret;
|
||||
*out = stmp.data;
|
||||
|
@@ -113,7 +113,7 @@ IMPLEMENT_STACK_OF(ASN1_TYPE)
|
||||
IMPLEMENT_ASN1_SET_OF(ASN1_TYPE)
|
||||
|
||||
/* Returns 0 if they are equal, != 0 otherwise. */
|
||||
int ASN1_TYPE_cmp(ASN1_TYPE *a, ASN1_TYPE *b)
|
||||
int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b)
|
||||
{
|
||||
int result = -1;
|
||||
|
||||
|
@@ -90,6 +90,12 @@ int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *a, ASN1_BIT_STRING *signature,
|
||||
ASN1err(ASN1_F_ASN1_VERIFY,ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (signature->type == V_ASN1_BIT_STRING && signature->flags & 0x7)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_VERIFY, ASN1_R_INVALID_BIT_STRING_BITS_LEFT);
|
||||
goto err;
|
||||
}
|
||||
|
||||
inl=i2d(data,NULL);
|
||||
buf_in=OPENSSL_malloc((unsigned int)inl);
|
||||
@@ -146,6 +152,12 @@ int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (signature->type == V_ASN1_BIT_STRING && signature->flags & 0x7)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ASN1_R_INVALID_BIT_STRING_BITS_LEFT);
|
||||
return -1;
|
||||
}
|
||||
|
||||
EVP_MD_CTX_init(&ctx);
|
||||
|
||||
/* Convert signature OID into digest and public key OIDs */
|
||||
|
@@ -776,7 +776,7 @@ DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)
|
||||
int ASN1_TYPE_get(ASN1_TYPE *a);
|
||||
void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
|
||||
int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);
|
||||
int ASN1_TYPE_cmp(ASN1_TYPE *a, ASN1_TYPE *b);
|
||||
int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);
|
||||
|
||||
ASN1_OBJECT * ASN1_OBJECT_new(void );
|
||||
void ASN1_OBJECT_free(ASN1_OBJECT *a);
|
||||
@@ -1329,6 +1329,7 @@ void ERR_load_ASN1_strings(void);
|
||||
#define ASN1_R_ILLEGAL_TIME_VALUE 184
|
||||
#define ASN1_R_INTEGER_NOT_ASCII_FORMAT 185
|
||||
#define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128
|
||||
#define ASN1_R_INVALID_BIT_STRING_BITS_LEFT 220
|
||||
#define ASN1_R_INVALID_BMPSTRING_LENGTH 129
|
||||
#define ASN1_R_INVALID_DIGIT 130
|
||||
#define ASN1_R_INVALID_MIME_TYPE 205
|
||||
@@ -1378,6 +1379,7 @@ void ERR_load_ASN1_strings(void);
|
||||
#define ASN1_R_TIME_NOT_ASCII_FORMAT 193
|
||||
#define ASN1_R_TOO_LONG 155
|
||||
#define ASN1_R_TYPE_NOT_CONSTRUCTED 156
|
||||
#define ASN1_R_TYPE_NOT_PRIMITIVE 218
|
||||
#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 157
|
||||
#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 158
|
||||
#define ASN1_R_UNEXPECTED_EOC 159
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* crypto/asn1/asn1_err.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1999-2014 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -246,6 +246,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_TIME_VALUE) ,"illegal time value"},
|
||||
{ERR_REASON(ASN1_R_INTEGER_NOT_ASCII_FORMAT),"integer not ascii format"},
|
||||
{ERR_REASON(ASN1_R_INTEGER_TOO_LARGE_FOR_LONG),"integer too large for long"},
|
||||
{ERR_REASON(ASN1_R_INVALID_BIT_STRING_BITS_LEFT),"invalid bit string bits left"},
|
||||
{ERR_REASON(ASN1_R_INVALID_BMPSTRING_LENGTH),"invalid bmpstring length"},
|
||||
{ERR_REASON(ASN1_R_INVALID_DIGIT) ,"invalid digit"},
|
||||
{ERR_REASON(ASN1_R_INVALID_MIME_TYPE) ,"invalid mime type"},
|
||||
@@ -295,6 +296,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
|
||||
{ERR_REASON(ASN1_R_TIME_NOT_ASCII_FORMAT),"time not ascii format"},
|
||||
{ERR_REASON(ASN1_R_TOO_LONG) ,"too long"},
|
||||
{ERR_REASON(ASN1_R_TYPE_NOT_CONSTRUCTED) ,"type not constructed"},
|
||||
{ERR_REASON(ASN1_R_TYPE_NOT_PRIMITIVE) ,"type not primitive"},
|
||||
{ERR_REASON(ASN1_R_UNABLE_TO_DECODE_RSA_KEY),"unable to decode rsa key"},
|
||||
{ERR_REASON(ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY),"unable to decode rsa private key"},
|
||||
{ERR_REASON(ASN1_R_UNEXPECTED_EOC) ,"unexpected eoc"},
|
||||
|
@@ -870,6 +870,14 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval,
|
||||
}
|
||||
else if (cst)
|
||||
{
|
||||
if (utype == V_ASN1_NULL || utype == V_ASN1_BOOLEAN
|
||||
|| utype == V_ASN1_OBJECT || utype == V_ASN1_INTEGER
|
||||
|| utype == V_ASN1_ENUMERATED)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE,
|
||||
ASN1_R_TYPE_NOT_PRIMITIVE);
|
||||
return 0;
|
||||
}
|
||||
buf.length = 0;
|
||||
buf.max = 0;
|
||||
buf.data = NULL;
|
||||
|
@@ -142,3 +142,14 @@ void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md)
|
||||
X509_ALGOR_set0(alg, OBJ_nid2obj(EVP_MD_type(md)), param_type, NULL);
|
||||
|
||||
}
|
||||
|
||||
int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b)
|
||||
{
|
||||
int rv;
|
||||
rv = OBJ_cmp(a->algorithm, b->algorithm);
|
||||
if (rv)
|
||||
return rv;
|
||||
if (!a->parameter && !b->parameter)
|
||||
return 0;
|
||||
return ASN1_TYPE_cmp(a->parameter, b->parameter);
|
||||
}
|
||||
|
@@ -350,6 +350,8 @@ static int x509_name_canon(X509_NAME *a)
|
||||
set = entry->set;
|
||||
}
|
||||
tmpentry = X509_NAME_ENTRY_new();
|
||||
if (!tmpentry)
|
||||
goto err;
|
||||
tmpentry->object = OBJ_dup(entry->object);
|
||||
if (!asn1_string_canon(tmpentry->value, entry->value))
|
||||
goto err;
|
||||
|
@@ -175,6 +175,8 @@ extern "C" {
|
||||
#define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT 45 /* Next DTLS handshake timeout to
|
||||
* adjust socket timeouts */
|
||||
|
||||
#define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD 49
|
||||
|
||||
#ifndef OPENSSL_NO_SCTP
|
||||
/* SCTP stuff */
|
||||
#define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE 50
|
||||
@@ -607,6 +609,8 @@ int BIO_ctrl_reset_read_request(BIO *b);
|
||||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)peer)
|
||||
#define BIO_dgram_set_peer(b,peer) \
|
||||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer)
|
||||
#define BIO_dgram_get_mtu_overhead(b) \
|
||||
(unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL)
|
||||
|
||||
/* These two aren't currently implemented */
|
||||
/* int BIO_get_ex_num(BIO *bio); */
|
||||
|
@@ -454,6 +454,36 @@ static int dgram_write(BIO *b, const char *in, int inl)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static long dgram_get_mtu_overhead(bio_dgram_data *data)
|
||||
{
|
||||
long ret;
|
||||
|
||||
switch (data->peer.sa.sa_family)
|
||||
{
|
||||
case AF_INET:
|
||||
/* Assume this is UDP - 20 bytes for IP, 8 bytes for UDP */
|
||||
ret = 28;
|
||||
break;
|
||||
#if OPENSSL_USE_IPV6
|
||||
case AF_INET6:
|
||||
#ifdef IN6_IS_ADDR_V4MAPPED
|
||||
if (IN6_IS_ADDR_V4MAPPED(&data->peer.sa_in6.sin6_addr))
|
||||
/* Assume this is UDP - 20 bytes for IP, 8 bytes for UDP */
|
||||
ret = 28;
|
||||
else
|
||||
#endif
|
||||
/* Assume this is UDP - 40 bytes for IP, 8 bytes for UDP */
|
||||
ret = 48;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
/* We don't know. Go with the historical default */
|
||||
ret = 28;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret=1;
|
||||
@@ -630,23 +660,24 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
#endif
|
||||
break;
|
||||
case BIO_CTRL_DGRAM_GET_FALLBACK_MTU:
|
||||
ret = -dgram_get_mtu_overhead(data);
|
||||
switch (data->peer.sa.sa_family)
|
||||
{
|
||||
case AF_INET:
|
||||
ret = 576 - 20 - 8;
|
||||
ret += 576;
|
||||
break;
|
||||
#if OPENSSL_USE_IPV6
|
||||
case AF_INET6:
|
||||
#ifdef IN6_IS_ADDR_V4MAPPED
|
||||
if (IN6_IS_ADDR_V4MAPPED(&data->peer.sa_in6.sin6_addr))
|
||||
ret = 576 - 20 - 8;
|
||||
ret += 576;
|
||||
else
|
||||
#endif
|
||||
ret = 1280 - 40 - 8;
|
||||
ret += 1280;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
ret = 576 - 20 - 8;
|
||||
ret += 576;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -847,6 +878,9 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
ret = 0;
|
||||
break;
|
||||
#endif
|
||||
case BIO_CTRL_DGRAM_GET_MTU_OVERHEAD:
|
||||
ret = dgram_get_mtu_overhead(data);
|
||||
break;
|
||||
default:
|
||||
ret=0;
|
||||
break;
|
||||
@@ -893,10 +927,18 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
|
||||
/* Activate SCTP-AUTH for DATA and FORWARD-TSN chunks */
|
||||
auth.sauth_chunk = OPENSSL_SCTP_DATA_CHUNK_TYPE;
|
||||
ret = setsockopt(fd, IPPROTO_SCTP, SCTP_AUTH_CHUNK, &auth, sizeof(struct sctp_authchunk));
|
||||
OPENSSL_assert(ret >= 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
BIO_vfree(bio);
|
||||
return(NULL);
|
||||
}
|
||||
auth.sauth_chunk = OPENSSL_SCTP_FORWARD_CUM_TSN_CHUNK_TYPE;
|
||||
ret = setsockopt(fd, IPPROTO_SCTP, SCTP_AUTH_CHUNK, &auth, sizeof(struct sctp_authchunk));
|
||||
OPENSSL_assert(ret >= 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
BIO_vfree(bio);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Test if activation was successful. When using accept(),
|
||||
* SCTP-AUTH has to be activated for the listening socket
|
||||
@@ -905,7 +947,13 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
|
||||
authchunks = OPENSSL_malloc(sockopt_len);
|
||||
memset(authchunks, 0, sizeof(sockopt_len));
|
||||
ret = getsockopt(fd, IPPROTO_SCTP, SCTP_LOCAL_AUTH_CHUNKS, authchunks, &sockopt_len);
|
||||
OPENSSL_assert(ret >= 0);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
OPENSSL_free(authchunks);
|
||||
BIO_vfree(bio);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
for (p = (unsigned char*) authchunks->gauth_chunks;
|
||||
p < (unsigned char*) authchunks + sockopt_len;
|
||||
@@ -927,16 +975,28 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
|
||||
event.se_type = SCTP_AUTHENTICATION_EVENT;
|
||||
event.se_on = 1;
|
||||
ret = setsockopt(fd, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(struct sctp_event));
|
||||
OPENSSL_assert(ret >= 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
BIO_vfree(bio);
|
||||
return(NULL);
|
||||
}
|
||||
#else
|
||||
sockopt_len = (socklen_t) sizeof(struct sctp_event_subscribe);
|
||||
ret = getsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &event, &sockopt_len);
|
||||
OPENSSL_assert(ret >= 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
BIO_vfree(bio);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
event.sctp_authentication_event = 1;
|
||||
|
||||
ret = setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(struct sctp_event_subscribe));
|
||||
OPENSSL_assert(ret >= 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
BIO_vfree(bio);
|
||||
return(NULL);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -944,7 +1004,11 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
|
||||
* larger than the max record size of 2^14 + 2048 + 13
|
||||
*/
|
||||
ret = setsockopt(fd, IPPROTO_SCTP, SCTP_PARTIAL_DELIVERY_POINT, &optval, sizeof(optval));
|
||||
OPENSSL_assert(ret >= 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
BIO_vfree(bio);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
return(bio);
|
||||
}
|
||||
@@ -982,7 +1046,12 @@ static int dgram_sctp_free(BIO *a)
|
||||
return 0;
|
||||
|
||||
data = (bio_dgram_sctp_data *)a->ptr;
|
||||
if(data != NULL) OPENSSL_free(data);
|
||||
if(data != NULL)
|
||||
{
|
||||
if(data->saved_message.data != NULL)
|
||||
OPENSSL_free(data->saved_message.data);
|
||||
OPENSSL_free(data);
|
||||
}
|
||||
|
||||
return(1);
|
||||
}
|
||||
@@ -1034,6 +1103,13 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
|
||||
msg.msg_flags = 0;
|
||||
n = recvmsg(b->num, &msg, 0);
|
||||
|
||||
if (n <= 0)
|
||||
{
|
||||
if (n < 0)
|
||||
ret = n;
|
||||
break;
|
||||
}
|
||||
|
||||
if (msg.msg_controllen > 0)
|
||||
{
|
||||
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg))
|
||||
@@ -1073,13 +1149,6 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
|
||||
}
|
||||
}
|
||||
|
||||
if (n <= 0)
|
||||
{
|
||||
if (n < 0)
|
||||
ret = n;
|
||||
break;
|
||||
}
|
||||
|
||||
if (msg.msg_flags & MSG_NOTIFICATION)
|
||||
{
|
||||
snp = (union sctp_notification*) out;
|
||||
@@ -1099,6 +1168,7 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
|
||||
dgram_sctp_write(data->saved_message.bio, data->saved_message.data,
|
||||
data->saved_message.length);
|
||||
OPENSSL_free(data->saved_message.data);
|
||||
data->saved_message.data = NULL;
|
||||
data->saved_message.length = 0;
|
||||
}
|
||||
|
||||
@@ -1109,16 +1179,28 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
|
||||
event.se_type = SCTP_SENDER_DRY_EVENT;
|
||||
event.se_on = 0;
|
||||
i = setsockopt(b->num, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(struct sctp_event));
|
||||
OPENSSL_assert(i >= 0);
|
||||
if (i < 0)
|
||||
{
|
||||
ret = i;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
eventsize = sizeof(struct sctp_event_subscribe);
|
||||
i = getsockopt(b->num, IPPROTO_SCTP, SCTP_EVENTS, &event, &eventsize);
|
||||
OPENSSL_assert(i >= 0);
|
||||
if (i < 0)
|
||||
{
|
||||
ret = i;
|
||||
break;
|
||||
}
|
||||
|
||||
event.sctp_sender_dry_event = 0;
|
||||
|
||||
i = setsockopt(b->num, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(struct sctp_event_subscribe));
|
||||
OPENSSL_assert(i >= 0);
|
||||
if (i < 0)
|
||||
{
|
||||
ret = i;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1151,8 +1233,8 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
|
||||
*/
|
||||
optlen = (socklen_t) sizeof(int);
|
||||
ret = getsockopt(b->num, SOL_SOCKET, SO_RCVBUF, &optval, &optlen);
|
||||
OPENSSL_assert(ret >= 0);
|
||||
OPENSSL_assert(optval >= 18445);
|
||||
if (ret >= 0)
|
||||
OPENSSL_assert(optval >= 18445);
|
||||
|
||||
/* Test if SCTP doesn't partially deliver below
|
||||
* max record size (2^14 + 2048 + 13)
|
||||
@@ -1160,8 +1242,8 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
|
||||
optlen = (socklen_t) sizeof(int);
|
||||
ret = getsockopt(b->num, IPPROTO_SCTP, SCTP_PARTIAL_DELIVERY_POINT,
|
||||
&optval, &optlen);
|
||||
OPENSSL_assert(ret >= 0);
|
||||
OPENSSL_assert(optval >= 18445);
|
||||
if (ret >= 0)
|
||||
OPENSSL_assert(optval >= 18445);
|
||||
|
||||
/* Partially delivered notification??? Probably a bug.... */
|
||||
OPENSSL_assert(!(msg.msg_flags & MSG_NOTIFICATION));
|
||||
@@ -1195,15 +1277,15 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
|
||||
authchunks = OPENSSL_malloc(optlen);
|
||||
memset(authchunks, 0, sizeof(optlen));
|
||||
ii = getsockopt(b->num, IPPROTO_SCTP, SCTP_PEER_AUTH_CHUNKS, authchunks, &optlen);
|
||||
OPENSSL_assert(ii >= 0);
|
||||
|
||||
for (p = (unsigned char*) authchunks->gauth_chunks;
|
||||
p < (unsigned char*) authchunks + optlen;
|
||||
p += sizeof(uint8_t))
|
||||
{
|
||||
if (*p == OPENSSL_SCTP_DATA_CHUNK_TYPE) auth_data = 1;
|
||||
if (*p == OPENSSL_SCTP_FORWARD_CUM_TSN_CHUNK_TYPE) auth_forward = 1;
|
||||
}
|
||||
if (ii >= 0)
|
||||
for (p = (unsigned char*) authchunks->gauth_chunks;
|
||||
p < (unsigned char*) authchunks + optlen;
|
||||
p += sizeof(uint8_t))
|
||||
{
|
||||
if (*p == OPENSSL_SCTP_DATA_CHUNK_TYPE) auth_data = 1;
|
||||
if (*p == OPENSSL_SCTP_FORWARD_CUM_TSN_CHUNK_TYPE) auth_forward = 1;
|
||||
}
|
||||
|
||||
OPENSSL_free(authchunks);
|
||||
|
||||
@@ -1258,9 +1340,11 @@ static int dgram_sctp_write(BIO *b, const char *in, int inl)
|
||||
if (data->save_shutdown && !BIO_dgram_sctp_wait_for_dry(b))
|
||||
{
|
||||
data->saved_message.bio = b;
|
||||
data->saved_message.length = inl;
|
||||
if (data->saved_message.data)
|
||||
OPENSSL_free(data->saved_message.data);
|
||||
data->saved_message.data = OPENSSL_malloc(inl);
|
||||
memcpy(data->saved_message.data, in, inl);
|
||||
data->saved_message.length = inl;
|
||||
return inl;
|
||||
}
|
||||
|
||||
@@ -1367,6 +1451,10 @@ static long dgram_sctp_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
* Returns always 1.
|
||||
*/
|
||||
break;
|
||||
case BIO_CTRL_DGRAM_GET_MTU_OVERHEAD:
|
||||
/* We allow transport protocol fragmentation so this is irrelevant */
|
||||
ret = 0;
|
||||
break;
|
||||
case BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE:
|
||||
if (num > 0)
|
||||
data->in_handshake = 1;
|
||||
|
@@ -1872,6 +1872,41 @@ ___
|
||||
|
||||
($a_4,$a_5,$a_6,$a_7)=($b_0,$b_1,$b_2,$b_3);
|
||||
|
||||
sub add_c2 () {
|
||||
my ($hi,$lo,$c0,$c1,$c2,
|
||||
$warm, # !$warm denotes first call with specific sequence of
|
||||
# $c_[XYZ] when there is no Z-carry to accumulate yet;
|
||||
$an,$bn # these two are arguments for multiplication which
|
||||
# result is used in *next* step [which is why it's
|
||||
# commented as "forward multiplication" below];
|
||||
)=@_;
|
||||
$code.=<<___;
|
||||
mflo $lo
|
||||
mfhi $hi
|
||||
$ADDU $c0,$lo
|
||||
sltu $at,$c0,$lo
|
||||
$MULTU $an,$bn # forward multiplication
|
||||
$ADDU $c0,$lo
|
||||
$ADDU $at,$hi
|
||||
sltu $lo,$c0,$lo
|
||||
$ADDU $c1,$at
|
||||
$ADDU $hi,$lo
|
||||
___
|
||||
$code.=<<___ if (!$warm);
|
||||
sltu $c2,$c1,$at
|
||||
$ADDU $c1,$hi
|
||||
sltu $hi,$c1,$hi
|
||||
$ADDU $c2,$hi
|
||||
___
|
||||
$code.=<<___ if ($warm);
|
||||
sltu $at,$c1,$at
|
||||
$ADDU $c1,$hi
|
||||
$ADDU $c2,$at
|
||||
sltu $hi,$c1,$hi
|
||||
$ADDU $c2,$hi
|
||||
___
|
||||
}
|
||||
|
||||
$code.=<<___;
|
||||
|
||||
.align 5
|
||||
@@ -1920,21 +1955,10 @@ $code.=<<___;
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $c_3,$t_2,$at
|
||||
$ST $c_2,$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_2,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_1,$a_1 # mul_add_c(a[1],b[1],c3,c1,c2);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,0,
|
||||
$a_1,$a_1); # mul_add_c(a[1],b[1],c3,c1,c2);
|
||||
$code.=<<___;
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
$ADDU $c_3,$t_1
|
||||
@@ -1945,67 +1969,19 @@ $code.=<<___;
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
$ST $c_3,2*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_3,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_1,$a_2 # mul_add_c2(a[1],b[2],c1,c2,c3);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_3,$at
|
||||
$MULTU $a_4,$a_0 # mul_add_c2(a[4],b[0],c2,c3,c1);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,0,
|
||||
$a_1,$a_2); # mul_add_c2(a[1],b[2],c1,c2,c3);
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,1,
|
||||
$a_4,$a_0); # mul_add_c2(a[4],b[0],c2,c3,c1);
|
||||
$code.=<<___;
|
||||
$ST $c_1,3*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_1,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_3,$a_1 # mul_add_c2(a[3],b[1],c2,c3,c1);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_1,$at
|
||||
$MULTU $a_2,$a_2 # mul_add_c(a[2],b[2],c2,c3,c1);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,0,
|
||||
$a_3,$a_1); # mul_add_c2(a[3],b[1],c2,c3,c1);
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,1,
|
||||
$a_2,$a_2); # mul_add_c(a[2],b[2],c2,c3,c1);
|
||||
$code.=<<___;
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
$ADDU $c_2,$t_1
|
||||
@@ -2016,97 +1992,23 @@ $code.=<<___;
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
$ST $c_2,4*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_2,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_1,$a_4 # mul_add_c2(a[1],b[4],c3,c1,c2);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_2,$at
|
||||
$MULTU $a_2,$a_3 # mul_add_c2(a[2],b[3],c3,c1,c2);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$MULTU $a_6,$a_0 # mul_add_c2(a[6],b[0],c1,c2,c3);
|
||||
$ADDU $c_2,$at
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,0,
|
||||
$a_1,$a_4); # mul_add_c2(a[1],b[4],c3,c1,c2);
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,1,
|
||||
$a_2,$a_3); # mul_add_c2(a[2],b[3],c3,c1,c2);
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,1,
|
||||
$a_6,$a_0); # mul_add_c2(a[6],b[0],c1,c2,c3);
|
||||
$code.=<<___;
|
||||
$ST $c_3,5*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_3,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_5,$a_1 # mul_add_c2(a[5],b[1],c1,c2,c3);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_3,$at
|
||||
$MULTU $a_4,$a_2 # mul_add_c2(a[4],b[2],c1,c2,c3);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_3,$at
|
||||
$MULTU $a_3,$a_3 # mul_add_c(a[3],b[3],c1,c2,c3);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,0,
|
||||
$a_5,$a_1); # mul_add_c2(a[5],b[1],c1,c2,c3);
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,1,
|
||||
$a_4,$a_2); # mul_add_c2(a[4],b[2],c1,c2,c3);
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,1,
|
||||
$a_3,$a_3); # mul_add_c(a[3],b[3],c1,c2,c3);
|
||||
$code.=<<___;
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
$ADDU $c_1,$t_1
|
||||
@@ -2117,112 +2019,25 @@ $code.=<<___;
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
$ST $c_1,6*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_1,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_1,$a_6 # mul_add_c2(a[1],b[6],c2,c3,c1);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_1,$at
|
||||
$MULTU $a_2,$a_5 # mul_add_c2(a[2],b[5],c2,c3,c1);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_1,$at
|
||||
$MULTU $a_3,$a_4 # mul_add_c2(a[3],b[4],c2,c3,c1);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_1,$at
|
||||
$MULTU $a_7,$a_1 # mul_add_c2(a[7],b[1],c3,c1,c2);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,0,
|
||||
$a_1,$a_6); # mul_add_c2(a[1],b[6],c2,c3,c1);
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,1,
|
||||
$a_2,$a_5); # mul_add_c2(a[2],b[5],c2,c3,c1);
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,1,
|
||||
$a_3,$a_4); # mul_add_c2(a[3],b[4],c2,c3,c1);
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,1,
|
||||
$a_7,$a_1); # mul_add_c2(a[7],b[1],c3,c1,c2);
|
||||
$code.=<<___;
|
||||
$ST $c_2,7*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_2,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_6,$a_2 # mul_add_c2(a[6],b[2],c3,c1,c2);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_2,$at
|
||||
$MULTU $a_5,$a_3 # mul_add_c2(a[5],b[3],c3,c1,c2);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_2,$at
|
||||
$MULTU $a_4,$a_4 # mul_add_c(a[4],b[4],c3,c1,c2);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,0,
|
||||
$a_6,$a_2); # mul_add_c2(a[6],b[2],c3,c1,c2);
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,1,
|
||||
$a_5,$a_3); # mul_add_c2(a[5],b[3],c3,c1,c2);
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,1,
|
||||
$a_4,$a_4); # mul_add_c(a[4],b[4],c3,c1,c2);
|
||||
$code.=<<___;
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
$ADDU $c_3,$t_1
|
||||
@@ -2233,82 +2048,21 @@ $code.=<<___;
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
$ST $c_3,8*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_3,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_3,$a_6 # mul_add_c2(a[3],b[6],c1,c2,c3);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_3,$at
|
||||
$MULTU $a_4,$a_5 # mul_add_c2(a[4],b[5],c1,c2,c3);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_3,$at
|
||||
$MULTU $a_7,$a_3 # mul_add_c2(a[7],b[3],c2,c3,c1);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,0,
|
||||
$a_3,$a_6); # mul_add_c2(a[3],b[6],c1,c2,c3);
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,1,
|
||||
$a_4,$a_5); # mul_add_c2(a[4],b[5],c1,c2,c3);
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,1,
|
||||
$a_7,$a_3); # mul_add_c2(a[7],b[3],c2,c3,c1);
|
||||
$code.=<<___;
|
||||
$ST $c_1,9*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_1,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_6,$a_4 # mul_add_c2(a[6],b[4],c2,c3,c1);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_1,$at
|
||||
$MULTU $a_5,$a_5 # mul_add_c(a[5],b[5],c2,c3,c1);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,0,
|
||||
$a_6,$a_4); # mul_add_c2(a[6],b[4],c2,c3,c1);
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,1,
|
||||
$a_5,$a_5); # mul_add_c(a[5],b[5],c2,c3,c1);
|
||||
$code.=<<___;
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
$ADDU $c_2,$t_1
|
||||
@@ -2319,52 +2073,17 @@ $code.=<<___;
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
$ST $c_2,10*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_2,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_5,$a_6 # mul_add_c2(a[5],b[6],c3,c1,c2);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_2,$at
|
||||
$MULTU $a_7,$a_5 # mul_add_c2(a[7],b[5],c1,c2,c3);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,0,
|
||||
$a_5,$a_6); # mul_add_c2(a[5],b[6],c3,c1,c2);
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,1,
|
||||
$a_7,$a_5); # mul_add_c2(a[7],b[5],c1,c2,c3);
|
||||
$code.=<<___;
|
||||
$ST $c_3,11*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_3,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_6,$a_6 # mul_add_c(a[6],b[6],c1,c2,c3);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,0,
|
||||
$a_6,$a_6); # mul_add_c(a[6],b[6],c1,c2,c3);
|
||||
$code.=<<___;
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
$ADDU $c_1,$t_1
|
||||
@@ -2375,21 +2094,10 @@ $code.=<<___;
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
$ST $c_1,12*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_1,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_7,$a_7 # mul_add_c(a[7],b[7],c3,c1,c2);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,0,
|
||||
$a_7,$a_7); # mul_add_c(a[7],b[7],c3,c1,c2);
|
||||
$code.=<<___;
|
||||
$ST $c_2,13*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
@@ -2457,21 +2165,10 @@ $code.=<<___;
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $c_3,$t_2,$at
|
||||
$ST $c_2,$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_2,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_1,$a_1 # mul_add_c(a[1],b[1],c3,c1,c2);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,0,
|
||||
$a_1,$a_1); # mul_add_c(a[1],b[1],c3,c1,c2);
|
||||
$code.=<<___;
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
$ADDU $c_3,$t_1
|
||||
@@ -2482,52 +2179,17 @@ $code.=<<___;
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
$ST $c_3,2*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_3,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_1,$a_2 # mul_add_c(a2[1],b[2],c1,c2,c3);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_3,$at
|
||||
$MULTU $a_3,$a_1 # mul_add_c2(a[3],b[1],c2,c3,c1);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,0,
|
||||
$a_1,$a_2); # mul_add_c2(a2[1],b[2],c1,c2,c3);
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,1,
|
||||
$a_3,$a_1); # mul_add_c2(a[3],b[1],c2,c3,c1);
|
||||
$code.=<<___;
|
||||
$ST $c_1,3*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_1,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_2,$a_2 # mul_add_c(a[2],b[2],c2,c3,c1);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,0,
|
||||
$a_2,$a_2); # mul_add_c(a[2],b[2],c2,c3,c1);
|
||||
$code.=<<___;
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
$ADDU $c_2,$t_1
|
||||
@@ -2538,21 +2200,10 @@ $code.=<<___;
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
$ST $c_2,4*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_2,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_3,$a_3 # mul_add_c(a[3],b[3],c1,c2,c3);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,0,
|
||||
$a_3,$a_3); # mul_add_c(a[3],b[3],c1,c2,c3);
|
||||
$code.=<<___;
|
||||
$ST $c_3,5*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -189,7 +189,7 @@ BN_ULONG bn_add_words (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int
|
||||
|
||||
if (n <= 0) return 0;
|
||||
|
||||
asm (
|
||||
asm volatile (
|
||||
" subq %2,%2 \n"
|
||||
".p2align 4 \n"
|
||||
"1: movq (%4,%2,8),%0 \n"
|
||||
@@ -200,7 +200,7 @@ BN_ULONG bn_add_words (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int
|
||||
" sbbq %0,%0 \n"
|
||||
: "=&a"(ret),"+c"(n),"=&r"(i)
|
||||
: "r"(rp),"r"(ap),"r"(bp)
|
||||
: "cc"
|
||||
: "cc", "memory"
|
||||
);
|
||||
|
||||
return ret&1;
|
||||
@@ -212,7 +212,7 @@ BN_ULONG bn_sub_words (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int
|
||||
|
||||
if (n <= 0) return 0;
|
||||
|
||||
asm (
|
||||
asm volatile (
|
||||
" subq %2,%2 \n"
|
||||
".p2align 4 \n"
|
||||
"1: movq (%4,%2,8),%0 \n"
|
||||
@@ -223,7 +223,7 @@ BN_ULONG bn_sub_words (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int
|
||||
" sbbq %0,%0 \n"
|
||||
: "=&a"(ret),"+c"(n),"=&r"(i)
|
||||
: "r"(rp),"r"(ap),"r"(bp)
|
||||
: "cc"
|
||||
: "cc", "memory"
|
||||
);
|
||||
|
||||
return ret&1;
|
||||
@@ -273,6 +273,10 @@ BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
|
||||
/* sqr_add_c(a,i,c0,c1,c2) -- c+=a[i]^2 for three word number c=(c2,c1,c0) */
|
||||
/* sqr_add_c2(a,i,c0,c1,c2) -- c+=2*a[i]*a[j] for three word number c=(c2,c1,c0) */
|
||||
|
||||
/*
|
||||
* Keep in mind that carrying into high part of multiplication result
|
||||
* can not overflow, because it cannot be all-ones.
|
||||
*/
|
||||
#if 0
|
||||
/* original macros are kept for reference purposes */
|
||||
#define mul_add_c(a,b,c0,c1,c2) { \
|
||||
@@ -287,10 +291,10 @@ BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
|
||||
BN_ULONG ta=(a),tb=(b),t0; \
|
||||
t1 = BN_UMULT_HIGH(ta,tb); \
|
||||
t0 = ta * tb; \
|
||||
t2 = t1+t1; c2 += (t2<t1)?1:0; \
|
||||
t1 = t0+t0; t2 += (t1<t0)?1:0; \
|
||||
c0 += t1; t2 += (c0<t1)?1:0; \
|
||||
c0 += t0; t2 = t1+((c0<t0)?1:0);\
|
||||
c1 += t2; c2 += (c1<t2)?1:0; \
|
||||
c0 += t0; t1 += (c0<t0)?1:0; \
|
||||
c1 += t1; c2 += (c1<t1)?1:0; \
|
||||
}
|
||||
#else
|
||||
#define mul_add_c(a,b,c0,c1,c2) do { \
|
||||
@@ -328,22 +332,14 @@ BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
|
||||
: "=a"(t1),"=d"(t2) \
|
||||
: "a"(a),"m"(b) \
|
||||
: "cc"); \
|
||||
asm ("addq %0,%0; adcq %2,%1" \
|
||||
: "+d"(t2),"+r"(c2) \
|
||||
: "g"(0) \
|
||||
: "cc"); \
|
||||
asm ("addq %0,%0; adcq %2,%1" \
|
||||
: "+a"(t1),"+d"(t2) \
|
||||
: "g"(0) \
|
||||
: "cc"); \
|
||||
asm ("addq %2,%0; adcq %3,%1" \
|
||||
: "+r"(c0),"+d"(t2) \
|
||||
: "a"(t1),"g"(0) \
|
||||
: "cc"); \
|
||||
asm ("addq %2,%0; adcq %3,%1" \
|
||||
: "+r"(c1),"+r"(c2) \
|
||||
: "d"(t2),"g"(0) \
|
||||
: "cc"); \
|
||||
asm ("addq %3,%0; adcq %4,%1; adcq %5,%2" \
|
||||
: "+r"(c0),"+r"(c1),"+r"(c2) \
|
||||
: "r"(t1),"r"(t2),"g"(0) \
|
||||
: "cc"); \
|
||||
asm ("addq %3,%0; adcq %4,%1; adcq %5,%2" \
|
||||
: "+r"(c0),"+r"(c1),"+r"(c2) \
|
||||
: "r"(t1),"r"(t2),"g"(0) \
|
||||
: "cc"); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
|
@@ -780,7 +780,9 @@ int RAND_pseudo_bytes(unsigned char *buf,int num);
|
||||
#define bn_wcheck_size(bn, words) \
|
||||
do { \
|
||||
const BIGNUM *_bnum2 = (bn); \
|
||||
assert(words <= (_bnum2)->dmax && words >= (_bnum2)->top); \
|
||||
assert((words) <= (_bnum2)->dmax && (words) >= (_bnum2)->top); \
|
||||
/* avoid unused variable warning with NDEBUG */ \
|
||||
(void)(_bnum2); \
|
||||
} while(0)
|
||||
|
||||
#else /* !BN_DEBUG */
|
||||
|
@@ -438,6 +438,10 @@ BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
|
||||
/* sqr_add_c(a,i,c0,c1,c2) -- c+=a[i]^2 for three word number c=(c2,c1,c0) */
|
||||
/* sqr_add_c2(a,i,c0,c1,c2) -- c+=2*a[i]*a[j] for three word number c=(c2,c1,c0) */
|
||||
|
||||
/*
|
||||
* Keep in mind that carrying into high part of multiplication result
|
||||
* can not overflow, because it cannot be all-ones.
|
||||
*/
|
||||
#ifdef BN_LLONG
|
||||
#define mul_add_c(a,b,c0,c1,c2) \
|
||||
t=(BN_ULLONG)a*b; \
|
||||
@@ -478,10 +482,10 @@ BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
|
||||
#define mul_add_c2(a,b,c0,c1,c2) { \
|
||||
BN_ULONG ta=(a),tb=(b),t0; \
|
||||
BN_UMULT_LOHI(t0,t1,ta,tb); \
|
||||
t2 = t1+t1; c2 += (t2<t1)?1:0; \
|
||||
t1 = t0+t0; t2 += (t1<t0)?1:0; \
|
||||
c0 += t1; t2 += (c0<t1)?1:0; \
|
||||
c0 += t0; t2 = t1+((c0<t0)?1:0);\
|
||||
c1 += t2; c2 += (c1<t2)?1:0; \
|
||||
c0 += t0; t1 += (c0<t0)?1:0; \
|
||||
c1 += t1; c2 += (c1<t1)?1:0; \
|
||||
}
|
||||
|
||||
#define sqr_add_c(a,i,c0,c1,c2) { \
|
||||
@@ -508,10 +512,10 @@ BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
|
||||
BN_ULONG ta=(a),tb=(b),t0; \
|
||||
t1 = BN_UMULT_HIGH(ta,tb); \
|
||||
t0 = ta * tb; \
|
||||
t2 = t1+t1; c2 += (t2<t1)?1:0; \
|
||||
t1 = t0+t0; t2 += (t1<t0)?1:0; \
|
||||
c0 += t1; t2 += (c0<t1)?1:0; \
|
||||
c0 += t0; t2 = t1+((c0<t0)?1:0);\
|
||||
c1 += t2; c2 += (c1<t2)?1:0; \
|
||||
c0 += t0; t1 += (c0<t0)?1:0; \
|
||||
c1 += t1; c2 += (c1<t1)?1:0; \
|
||||
}
|
||||
|
||||
#define sqr_add_c(a,i,c0,c1,c2) { \
|
||||
|
@@ -158,7 +158,7 @@ static void ctxdbg(BN_CTX *ctx)
|
||||
unsigned int bnidx = 0, fpidx = 0;
|
||||
BN_POOL_ITEM *item = ctx->pool.head;
|
||||
BN_STACK *stack = &ctx->stack;
|
||||
fprintf(stderr,"(%08x): ", (unsigned int)ctx);
|
||||
fprintf(stderr,"(%16p): ", ctx);
|
||||
while(bnidx < ctx->used)
|
||||
{
|
||||
fprintf(stderr,"%03x ", item->vals[bnidx++ % BN_CTX_POOL_SIZE].dmax);
|
||||
|
@@ -189,15 +189,17 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
|
||||
int no_branch=0;
|
||||
|
||||
/* Invalid zero-padding would have particularly bad consequences
|
||||
* in the case of 'num', so don't just rely on bn_check_top() for this one
|
||||
* so don't just rely on bn_check_top() here
|
||||
* (bn_check_top() works only for BN_DEBUG builds) */
|
||||
if (num->top > 0 && num->d[num->top - 1] == 0)
|
||||
if ((num->top > 0 && num->d[num->top - 1] == 0) ||
|
||||
(divisor->top > 0 && divisor->d[divisor->top - 1] == 0))
|
||||
{
|
||||
BNerr(BN_F_BN_DIV,BN_R_NOT_INITIALIZED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bn_check_top(num);
|
||||
bn_check_top(divisor);
|
||||
|
||||
if ((BN_get_flags(num, BN_FLG_CONSTTIME) != 0) || (BN_get_flags(divisor, BN_FLG_CONSTTIME) != 0))
|
||||
{
|
||||
@@ -207,7 +209,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
|
||||
bn_check_top(dv);
|
||||
bn_check_top(rm);
|
||||
/* bn_check_top(num); */ /* 'num' has been checked already */
|
||||
bn_check_top(divisor);
|
||||
/* bn_check_top(divisor); */ /* 'divisor' has been checked already */
|
||||
|
||||
if (BN_is_zero(divisor))
|
||||
{
|
||||
|
@@ -874,7 +874,14 @@ int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p,
|
||||
bits = BN_num_bits(p);
|
||||
if (bits == 0)
|
||||
{
|
||||
ret = BN_one(rr);
|
||||
/* x**0 mod 1 is still zero. */
|
||||
if (BN_is_one(m))
|
||||
{
|
||||
ret = 1;
|
||||
BN_zero(rr);
|
||||
}
|
||||
else
|
||||
ret = BN_one(rr);
|
||||
return ret;
|
||||
}
|
||||
if (a == 0)
|
||||
|
@@ -1088,9 +1088,9 @@ int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
|
||||
/* ... and right shift */
|
||||
for (val=t_d[0],i=0; i<BN_NIST_521_TOP-1; i++)
|
||||
{
|
||||
tmp = val>>BN_NIST_521_RSHIFT;
|
||||
val = t_d[i+1];
|
||||
t_d[i] = (tmp | val<<BN_NIST_521_LSHIFT) & BN_MASK2;
|
||||
t_d[i] = ( val>>BN_NIST_521_RSHIFT |
|
||||
(tmp=t_d[i+1])<<BN_NIST_521_LSHIFT ) & BN_MASK2;
|
||||
val=tmp;
|
||||
}
|
||||
t_d[i] = val>>BN_NIST_521_RSHIFT;
|
||||
/* lower 521 bits */
|
||||
|
@@ -107,6 +107,7 @@ int test_mod(BIO *bp,BN_CTX *ctx);
|
||||
int test_mod_mul(BIO *bp,BN_CTX *ctx);
|
||||
int test_mod_exp(BIO *bp,BN_CTX *ctx);
|
||||
int test_mod_exp_mont_consttime(BIO *bp,BN_CTX *ctx);
|
||||
int test_mod_exp_mont5(BIO *bp, BN_CTX *ctx);
|
||||
int test_exp(BIO *bp,BN_CTX *ctx);
|
||||
int test_gf2m_add(BIO *bp);
|
||||
int test_gf2m_mod(BIO *bp);
|
||||
@@ -249,6 +250,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
message(out,"BN_mod_exp_mont_consttime");
|
||||
if (!test_mod_exp_mont_consttime(out,ctx)) goto err;
|
||||
if (!test_mod_exp_mont5(out,ctx)) goto err;
|
||||
(void)BIO_flush(out);
|
||||
|
||||
message(out,"BN_exp");
|
||||
@@ -676,44 +678,98 @@ int test_mul(BIO *bp)
|
||||
|
||||
int test_sqr(BIO *bp, BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM a,c,d,e;
|
||||
int i;
|
||||
BIGNUM *a,*c,*d,*e;
|
||||
int i, ret = 0;
|
||||
|
||||
BN_init(&a);
|
||||
BN_init(&c);
|
||||
BN_init(&d);
|
||||
BN_init(&e);
|
||||
a = BN_new();
|
||||
c = BN_new();
|
||||
d = BN_new();
|
||||
e = BN_new();
|
||||
if (a == NULL || c == NULL || d == NULL || e == NULL)
|
||||
{
|
||||
goto err;
|
||||
}
|
||||
|
||||
for (i=0; i<num0; i++)
|
||||
{
|
||||
BN_bntest_rand(&a,40+i*10,0,0);
|
||||
a.neg=rand_neg();
|
||||
BN_sqr(&c,&a,ctx);
|
||||
BN_bntest_rand(a,40+i*10,0,0);
|
||||
a->neg=rand_neg();
|
||||
BN_sqr(c,a,ctx);
|
||||
if (bp != NULL)
|
||||
{
|
||||
if (!results)
|
||||
{
|
||||
BN_print(bp,&a);
|
||||
BN_print(bp,a);
|
||||
BIO_puts(bp," * ");
|
||||
BN_print(bp,&a);
|
||||
BN_print(bp,a);
|
||||
BIO_puts(bp," - ");
|
||||
}
|
||||
BN_print(bp,&c);
|
||||
BN_print(bp,c);
|
||||
BIO_puts(bp,"\n");
|
||||
}
|
||||
BN_div(&d,&e,&c,&a,ctx);
|
||||
BN_sub(&d,&d,&a);
|
||||
if(!BN_is_zero(&d) || !BN_is_zero(&e))
|
||||
{
|
||||
fprintf(stderr,"Square test failed!\n");
|
||||
return 0;
|
||||
}
|
||||
BN_div(d,e,c,a,ctx);
|
||||
BN_sub(d,d,a);
|
||||
if(!BN_is_zero(d) || !BN_is_zero(e))
|
||||
{
|
||||
fprintf(stderr,"Square test failed!\n");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
BN_free(&a);
|
||||
BN_free(&c);
|
||||
BN_free(&d);
|
||||
BN_free(&e);
|
||||
return(1);
|
||||
|
||||
/* Regression test for a BN_sqr overflow bug. */
|
||||
BN_hex2bn(&a,
|
||||
"80000000000000008000000000000001FFFFFFFFFFFFFFFE0000000000000000");
|
||||
BN_sqr(c, a, ctx);
|
||||
if (bp != NULL)
|
||||
{
|
||||
if (!results)
|
||||
{
|
||||
BN_print(bp,a);
|
||||
BIO_puts(bp," * ");
|
||||
BN_print(bp,a);
|
||||
BIO_puts(bp," - ");
|
||||
}
|
||||
BN_print(bp,c);
|
||||
BIO_puts(bp,"\n");
|
||||
}
|
||||
BN_mul(d, a, a, ctx);
|
||||
if (BN_cmp(c, d))
|
||||
{
|
||||
fprintf(stderr, "Square test failed: BN_sqr and BN_mul produce "
|
||||
"different results!\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Regression test for a BN_sqr overflow bug. */
|
||||
BN_hex2bn(&a,
|
||||
"80000000000000000000000080000001FFFFFFFE000000000000000000000000");
|
||||
BN_sqr(c, a, ctx);
|
||||
if (bp != NULL)
|
||||
{
|
||||
if (!results)
|
||||
{
|
||||
BN_print(bp,a);
|
||||
BIO_puts(bp," * ");
|
||||
BN_print(bp,a);
|
||||
BIO_puts(bp," - ");
|
||||
}
|
||||
BN_print(bp,c);
|
||||
BIO_puts(bp,"\n");
|
||||
}
|
||||
BN_mul(d, a, a, ctx);
|
||||
if (BN_cmp(c, d))
|
||||
{
|
||||
fprintf(stderr, "Square test failed: BN_sqr and BN_mul produce "
|
||||
"different results!\n");
|
||||
goto err;
|
||||
}
|
||||
ret = 1;
|
||||
err:
|
||||
if (a != NULL) BN_free(a);
|
||||
if (c != NULL) BN_free(c);
|
||||
if (d != NULL) BN_free(d);
|
||||
if (e != NULL) BN_free(e);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int test_mont(BIO *bp, BN_CTX *ctx)
|
||||
@@ -1012,6 +1068,80 @@ int test_mod_exp_mont_consttime(BIO *bp, BN_CTX *ctx)
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* Test constant-time modular exponentiation with 1024-bit inputs,
|
||||
* which on x86_64 cause a different code branch to be taken.
|
||||
*/
|
||||
int test_mod_exp_mont5(BIO *bp, BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM *a,*p,*m,*d,*e;
|
||||
|
||||
BN_MONT_CTX *mont;
|
||||
|
||||
a=BN_new();
|
||||
p=BN_new();
|
||||
m=BN_new();
|
||||
d=BN_new();
|
||||
e=BN_new();
|
||||
|
||||
mont = BN_MONT_CTX_new();
|
||||
|
||||
BN_bntest_rand(m,1024,0,1); /* must be odd for montgomery */
|
||||
/* Zero exponent */
|
||||
BN_bntest_rand(a,1024,0,0);
|
||||
BN_zero(p);
|
||||
if(!BN_mod_exp_mont_consttime(d,a,p,m,ctx,NULL))
|
||||
return 0;
|
||||
if(!BN_is_one(d))
|
||||
{
|
||||
fprintf(stderr, "Modular exponentiation test failed!\n");
|
||||
return 0;
|
||||
}
|
||||
/* Zero input */
|
||||
BN_bntest_rand(p,1024,0,0);
|
||||
BN_zero(a);
|
||||
if(!BN_mod_exp_mont_consttime(d,a,p,m,ctx,NULL))
|
||||
return 0;
|
||||
if(!BN_is_zero(d))
|
||||
{
|
||||
fprintf(stderr, "Modular exponentiation test failed!\n");
|
||||
return 0;
|
||||
}
|
||||
/* Craft an input whose Montgomery representation is 1,
|
||||
* i.e., shorter than the modulus m, in order to test
|
||||
* the const time precomputation scattering/gathering.
|
||||
*/
|
||||
BN_one(a);
|
||||
BN_MONT_CTX_set(mont,m,ctx);
|
||||
if(!BN_from_montgomery(e,a,mont,ctx))
|
||||
return 0;
|
||||
if(!BN_mod_exp_mont_consttime(d,e,p,m,ctx,NULL))
|
||||
return 0;
|
||||
if(!BN_mod_exp_simple(a,e,p,m,ctx))
|
||||
return 0;
|
||||
if(BN_cmp(a,d) != 0)
|
||||
{
|
||||
fprintf(stderr,"Modular exponentiation test failed!\n");
|
||||
return 0;
|
||||
}
|
||||
/* Finally, some regular test vectors. */
|
||||
BN_bntest_rand(e,1024,0,0);
|
||||
if(!BN_mod_exp_mont_consttime(d,e,p,m,ctx,NULL))
|
||||
return 0;
|
||||
if(!BN_mod_exp_simple(a,e,p,m,ctx))
|
||||
return 0;
|
||||
if(BN_cmp(a,d) != 0)
|
||||
{
|
||||
fprintf(stderr,"Modular exponentiation test failed!\n");
|
||||
return 0;
|
||||
}
|
||||
BN_free(a);
|
||||
BN_free(p);
|
||||
BN_free(m);
|
||||
BN_free(d);
|
||||
BN_free(e);
|
||||
return(1);
|
||||
}
|
||||
|
||||
int test_exp(BIO *bp, BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM *a,*b,*d,*e,*one;
|
||||
|
@@ -71,6 +71,43 @@
|
||||
|
||||
static const char rnd_seed[] = "string to make the random number generator think it has entropy";
|
||||
|
||||
/* test_exp_mod_zero tests that x**0 mod 1 == 0. It returns zero on success. */
|
||||
static int test_exp_mod_zero() {
|
||||
BIGNUM a, p, m;
|
||||
BIGNUM r;
|
||||
BN_CTX *ctx = BN_CTX_new();
|
||||
int ret = 1;
|
||||
|
||||
BN_init(&m);
|
||||
BN_one(&m);
|
||||
|
||||
BN_init(&a);
|
||||
BN_one(&a);
|
||||
|
||||
BN_init(&p);
|
||||
BN_zero(&p);
|
||||
|
||||
BN_init(&r);
|
||||
BN_mod_exp(&r, &a, &p, &m, ctx);
|
||||
BN_CTX_free(ctx);
|
||||
|
||||
if (BN_is_zero(&r))
|
||||
ret = 0;
|
||||
else
|
||||
{
|
||||
printf("1**0 mod 1 = ");
|
||||
BN_print_fp(stdout, &r);
|
||||
printf(", should be 0\n");
|
||||
}
|
||||
|
||||
BN_free(&r);
|
||||
BN_free(&a);
|
||||
BN_free(&p);
|
||||
BN_free(&m);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
BN_CTX *ctx;
|
||||
@@ -190,7 +227,13 @@ int main(int argc, char *argv[])
|
||||
ERR_remove_thread_state(NULL);
|
||||
CRYPTO_mem_leaks(out);
|
||||
BIO_free(out);
|
||||
printf(" done\n");
|
||||
printf("\n");
|
||||
|
||||
if (test_exp_mod_zero() != 0)
|
||||
goto err;
|
||||
|
||||
printf("done\n");
|
||||
|
||||
EXIT(0);
|
||||
err:
|
||||
ERR_load_crypto_strings();
|
||||
|
206
crypto/constant_time_locl.h
Normal file
206
crypto/constant_time_locl.h
Normal file
@@ -0,0 +1,206 @@
|
||||
/* crypto/constant_time_locl.h */
|
||||
/*
|
||||
* Utilities for constant-time cryptography.
|
||||
*
|
||||
* Author: Emilia Kasper (emilia@openssl.org)
|
||||
* Based on previous work by Bodo Moeller, Emilia Kasper, Adam Langley
|
||||
* (Google).
|
||||
* ====================================================================
|
||||
* Copyright (c) 2014 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_CONSTANT_TIME_LOCL_H
|
||||
#define HEADER_CONSTANT_TIME_LOCL_H
|
||||
|
||||
#include "e_os.h" /* For 'inline' */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The boolean methods return a bitmask of all ones (0xff...f) for true
|
||||
* and 0 for false. This is useful for choosing a value based on the result
|
||||
* of a conditional in constant time. For example,
|
||||
*
|
||||
* if (a < b) {
|
||||
* c = a;
|
||||
* } else {
|
||||
* c = b;
|
||||
* }
|
||||
*
|
||||
* can be written as
|
||||
*
|
||||
* unsigned int lt = constant_time_lt(a, b);
|
||||
* c = constant_time_select(lt, a, b);
|
||||
*/
|
||||
|
||||
/*
|
||||
* Returns the given value with the MSB copied to all the other
|
||||
* bits. Uses the fact that arithmetic shift shifts-in the sign bit.
|
||||
* However, this is not ensured by the C standard so you may need to
|
||||
* replace this with something else on odd CPUs.
|
||||
*/
|
||||
static inline unsigned int constant_time_msb(unsigned int a);
|
||||
|
||||
/*
|
||||
* Returns 0xff..f if a < b and 0 otherwise.
|
||||
*/
|
||||
static inline unsigned int constant_time_lt(unsigned int a, unsigned int b);
|
||||
/* Convenience method for getting an 8-bit mask. */
|
||||
static inline unsigned char constant_time_lt_8(unsigned int a, unsigned int b);
|
||||
|
||||
/*
|
||||
* Returns 0xff..f if a >= b and 0 otherwise.
|
||||
*/
|
||||
static inline unsigned int constant_time_ge(unsigned int a, unsigned int b);
|
||||
/* Convenience method for getting an 8-bit mask. */
|
||||
static inline unsigned char constant_time_ge_8(unsigned int a, unsigned int b);
|
||||
|
||||
/*
|
||||
* Returns 0xff..f if a == 0 and 0 otherwise.
|
||||
*/
|
||||
static inline unsigned int constant_time_is_zero(unsigned int a);
|
||||
/* Convenience method for getting an 8-bit mask. */
|
||||
static inline unsigned char constant_time_is_zero_8(unsigned int a);
|
||||
|
||||
|
||||
/*
|
||||
* Returns 0xff..f if a == b and 0 otherwise.
|
||||
*/
|
||||
static inline unsigned int constant_time_eq(unsigned int a, unsigned int b);
|
||||
/* Convenience method for getting an 8-bit mask. */
|
||||
static inline unsigned char constant_time_eq_8(unsigned int a, unsigned int b);
|
||||
/* Signed integers. */
|
||||
static inline unsigned int constant_time_eq_int(int a, int b);
|
||||
/* Convenience method for getting an 8-bit mask. */
|
||||
static inline unsigned char constant_time_eq_int_8(int a, int b);
|
||||
|
||||
|
||||
/*
|
||||
* Returns (mask & a) | (~mask & b).
|
||||
*
|
||||
* When |mask| is all 1s or all 0s (as returned by the methods above),
|
||||
* the select methods return either |a| (if |mask| is nonzero) or |b|
|
||||
* (if |mask| is zero).
|
||||
*/
|
||||
static inline unsigned int constant_time_select(unsigned int mask,
|
||||
unsigned int a, unsigned int b);
|
||||
/* Convenience method for unsigned chars. */
|
||||
static inline unsigned char constant_time_select_8(unsigned char mask,
|
||||
unsigned char a, unsigned char b);
|
||||
/* Convenience method for signed integers. */
|
||||
static inline int constant_time_select_int(unsigned int mask, int a, int b);
|
||||
|
||||
static inline unsigned int constant_time_msb(unsigned int a)
|
||||
{
|
||||
return 0-(a >> (sizeof(a) * 8 - 1));
|
||||
}
|
||||
|
||||
static inline unsigned int constant_time_lt(unsigned int a, unsigned int b)
|
||||
{
|
||||
return constant_time_msb(a^((a^b)|((a-b)^b)));
|
||||
}
|
||||
|
||||
static inline unsigned char constant_time_lt_8(unsigned int a, unsigned int b)
|
||||
{
|
||||
return (unsigned char)(constant_time_lt(a, b));
|
||||
}
|
||||
|
||||
static inline unsigned int constant_time_ge(unsigned int a, unsigned int b)
|
||||
{
|
||||
return ~constant_time_lt(a, b);
|
||||
}
|
||||
|
||||
static inline unsigned char constant_time_ge_8(unsigned int a, unsigned int b)
|
||||
{
|
||||
return (unsigned char)(constant_time_ge(a, b));
|
||||
}
|
||||
|
||||
static inline unsigned int constant_time_is_zero(unsigned int a)
|
||||
{
|
||||
return constant_time_msb(~a & (a - 1));
|
||||
}
|
||||
|
||||
static inline unsigned char constant_time_is_zero_8(unsigned int a)
|
||||
{
|
||||
return (unsigned char)(constant_time_is_zero(a));
|
||||
}
|
||||
|
||||
static inline unsigned int constant_time_eq(unsigned int a, unsigned int b)
|
||||
{
|
||||
return constant_time_is_zero(a ^ b);
|
||||
}
|
||||
|
||||
static inline unsigned char constant_time_eq_8(unsigned int a, unsigned int b)
|
||||
{
|
||||
return (unsigned char)(constant_time_eq(a, b));
|
||||
}
|
||||
|
||||
static inline unsigned int constant_time_eq_int(int a, int b)
|
||||
{
|
||||
return constant_time_eq((unsigned)(a), (unsigned)(b));
|
||||
}
|
||||
|
||||
static inline unsigned char constant_time_eq_int_8(int a, int b)
|
||||
{
|
||||
return constant_time_eq_8((unsigned)(a), (unsigned)(b));
|
||||
}
|
||||
|
||||
static inline unsigned int constant_time_select(unsigned int mask,
|
||||
unsigned int a, unsigned int b)
|
||||
{
|
||||
return (mask & a) | (~mask & b);
|
||||
}
|
||||
|
||||
static inline unsigned char constant_time_select_8(unsigned char mask,
|
||||
unsigned char a, unsigned char b)
|
||||
{
|
||||
return (unsigned char)(constant_time_select(mask, a, b));
|
||||
}
|
||||
|
||||
static inline int constant_time_select_int(unsigned int mask, int a, int b)
|
||||
{
|
||||
return (int)(constant_time_select(mask, (unsigned)(a), (unsigned)(b)));
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HEADER_CONSTANT_TIME_LOCL_H */
|
330
crypto/constant_time_test.c
Normal file
330
crypto/constant_time_test.c
Normal file
@@ -0,0 +1,330 @@
|
||||
/* crypto/constant_time_test.c */
|
||||
/*
|
||||
* Utilities for constant-time cryptography.
|
||||
*
|
||||
* Author: Emilia Kasper (emilia@openssl.org)
|
||||
* Based on previous work by Bodo Moeller, Emilia Kasper, Adam Langley
|
||||
* (Google).
|
||||
* ====================================================================
|
||||
* Copyright (c) 2014 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include "../crypto/constant_time_locl.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static const unsigned int CONSTTIME_TRUE = (unsigned)(~0);
|
||||
static const unsigned int CONSTTIME_FALSE = 0;
|
||||
static const unsigned char CONSTTIME_TRUE_8 = 0xff;
|
||||
static const unsigned char CONSTTIME_FALSE_8 = 0;
|
||||
|
||||
static int test_binary_op(unsigned int (*op)(unsigned int a, unsigned int b),
|
||||
const char* op_name, unsigned int a, unsigned int b, int is_true)
|
||||
{
|
||||
unsigned c = op(a, b);
|
||||
if (is_true && c != CONSTTIME_TRUE)
|
||||
{
|
||||
fprintf(stderr, "Test failed for %s(%du, %du): expected %du "
|
||||
"(TRUE), got %du\n", op_name, a, b, CONSTTIME_TRUE, c);
|
||||
return 1;
|
||||
}
|
||||
else if (!is_true && c != CONSTTIME_FALSE)
|
||||
{
|
||||
fprintf(stderr, "Test failed for %s(%du, %du): expected %du "
|
||||
"(FALSE), got %du\n", op_name, a, b, CONSTTIME_FALSE,
|
||||
c);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_binary_op_8(unsigned char (*op)(unsigned int a, unsigned int b),
|
||||
const char* op_name, unsigned int a, unsigned int b, int is_true)
|
||||
{
|
||||
unsigned char c = op(a, b);
|
||||
if (is_true && c != CONSTTIME_TRUE_8)
|
||||
{
|
||||
fprintf(stderr, "Test failed for %s(%du, %du): expected %u "
|
||||
"(TRUE), got %u\n", op_name, a, b, CONSTTIME_TRUE_8, c);
|
||||
return 1;
|
||||
}
|
||||
else if (!is_true && c != CONSTTIME_FALSE_8)
|
||||
{
|
||||
fprintf(stderr, "Test failed for %s(%du, %du): expected %u "
|
||||
"(FALSE), got %u\n", op_name, a, b, CONSTTIME_FALSE_8,
|
||||
c);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_is_zero(unsigned int a)
|
||||
{
|
||||
unsigned int c = constant_time_is_zero(a);
|
||||
if (a == 0 && c != CONSTTIME_TRUE)
|
||||
{
|
||||
fprintf(stderr, "Test failed for constant_time_is_zero(%du): "
|
||||
"expected %du (TRUE), got %du\n", a, CONSTTIME_TRUE, c);
|
||||
return 1;
|
||||
}
|
||||
else if (a != 0 && c != CONSTTIME_FALSE)
|
||||
{
|
||||
fprintf(stderr, "Test failed for constant_time_is_zero(%du): "
|
||||
"expected %du (FALSE), got %du\n", a, CONSTTIME_FALSE,
|
||||
c);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_is_zero_8(unsigned int a)
|
||||
{
|
||||
unsigned char c = constant_time_is_zero_8(a);
|
||||
if (a == 0 && c != CONSTTIME_TRUE_8)
|
||||
{
|
||||
fprintf(stderr, "Test failed for constant_time_is_zero(%du): "
|
||||
"expected %u (TRUE), got %u\n", a, CONSTTIME_TRUE_8, c);
|
||||
return 1;
|
||||
}
|
||||
else if (a != 0 && c != CONSTTIME_FALSE)
|
||||
{
|
||||
fprintf(stderr, "Test failed for constant_time_is_zero(%du): "
|
||||
"expected %u (FALSE), got %u\n", a, CONSTTIME_FALSE_8,
|
||||
c);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_select(unsigned int a, unsigned int b)
|
||||
{
|
||||
unsigned int selected = constant_time_select(CONSTTIME_TRUE, a, b);
|
||||
if (selected != a)
|
||||
{
|
||||
fprintf(stderr, "Test failed for constant_time_select(%du, %du,"
|
||||
"%du): expected %du(first value), got %du\n",
|
||||
CONSTTIME_TRUE, a, b, a, selected);
|
||||
return 1;
|
||||
}
|
||||
selected = constant_time_select(CONSTTIME_FALSE, a, b);
|
||||
if (selected != b)
|
||||
{
|
||||
fprintf(stderr, "Test failed for constant_time_select(%du, %du,"
|
||||
"%du): expected %du(second value), got %du\n",
|
||||
CONSTTIME_FALSE, a, b, b, selected);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_select_8(unsigned char a, unsigned char b)
|
||||
{
|
||||
unsigned char selected = constant_time_select_8(CONSTTIME_TRUE_8, a, b);
|
||||
if (selected != a)
|
||||
{
|
||||
fprintf(stderr, "Test failed for constant_time_select(%u, %u,"
|
||||
"%u): expected %u(first value), got %u\n",
|
||||
CONSTTIME_TRUE, a, b, a, selected);
|
||||
return 1;
|
||||
}
|
||||
selected = constant_time_select_8(CONSTTIME_FALSE_8, a, b);
|
||||
if (selected != b)
|
||||
{
|
||||
fprintf(stderr, "Test failed for constant_time_select(%u, %u,"
|
||||
"%u): expected %u(second value), got %u\n",
|
||||
CONSTTIME_FALSE, a, b, b, selected);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_select_int(int a, int b)
|
||||
{
|
||||
int selected = constant_time_select_int(CONSTTIME_TRUE, a, b);
|
||||
if (selected != a)
|
||||
{
|
||||
fprintf(stderr, "Test failed for constant_time_select(%du, %d,"
|
||||
"%d): expected %d(first value), got %d\n",
|
||||
CONSTTIME_TRUE, a, b, a, selected);
|
||||
return 1;
|
||||
}
|
||||
selected = constant_time_select_int(CONSTTIME_FALSE, a, b);
|
||||
if (selected != b)
|
||||
{
|
||||
fprintf(stderr, "Test failed for constant_time_select(%du, %d,"
|
||||
"%d): expected %d(second value), got %d\n",
|
||||
CONSTTIME_FALSE, a, b, b, selected);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_eq_int(int a, int b)
|
||||
{
|
||||
unsigned int equal = constant_time_eq_int(a, b);
|
||||
if (a == b && equal != CONSTTIME_TRUE)
|
||||
{
|
||||
fprintf(stderr, "Test failed for constant_time_eq_int(%d, %d): "
|
||||
"expected %du(TRUE), got %du\n",
|
||||
a, b, CONSTTIME_TRUE, equal);
|
||||
return 1;
|
||||
}
|
||||
else if (a != b && equal != CONSTTIME_FALSE)
|
||||
{
|
||||
fprintf(stderr, "Test failed for constant_time_eq_int(%d, %d): "
|
||||
"expected %du(FALSE), got %du\n",
|
||||
a, b, CONSTTIME_FALSE, equal);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_eq_int_8(int a, int b)
|
||||
{
|
||||
unsigned char equal = constant_time_eq_int_8(a, b);
|
||||
if (a == b && equal != CONSTTIME_TRUE_8)
|
||||
{
|
||||
fprintf(stderr, "Test failed for constant_time_eq_int_8(%d, %d): "
|
||||
"expected %u(TRUE), got %u\n",
|
||||
a, b, CONSTTIME_TRUE_8, equal);
|
||||
return 1;
|
||||
}
|
||||
else if (a != b && equal != CONSTTIME_FALSE_8)
|
||||
{
|
||||
fprintf(stderr, "Test failed for constant_time_eq_int_8(%d, %d): "
|
||||
"expected %u(FALSE), got %u\n",
|
||||
a, b, CONSTTIME_FALSE_8, equal);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int test_values[] = {0, 1, 1024, 12345, 32000, UINT_MAX/2-1,
|
||||
UINT_MAX/2, UINT_MAX/2+1, UINT_MAX-1,
|
||||
UINT_MAX};
|
||||
|
||||
static unsigned char test_values_8[] = {0, 1, 2, 20, 32, 127, 128, 129, 255};
|
||||
|
||||
static int signed_test_values[] = {0, 1, -1, 1024, -1024, 12345, -12345,
|
||||
32000, -32000, INT_MAX, INT_MIN, INT_MAX-1,
|
||||
INT_MIN+1};
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
unsigned int a, b, i, j;
|
||||
int c, d;
|
||||
unsigned char e, f;
|
||||
int num_failed = 0, num_all = 0;
|
||||
fprintf(stdout, "Testing constant time operations...\n");
|
||||
|
||||
for (i = 0; i < sizeof(test_values)/sizeof(int); ++i)
|
||||
{
|
||||
a = test_values[i];
|
||||
num_failed += test_is_zero(a);
|
||||
num_failed += test_is_zero_8(a);
|
||||
num_all += 2;
|
||||
for (j = 0; j < sizeof(test_values)/sizeof(int); ++j)
|
||||
{
|
||||
b = test_values[j];
|
||||
num_failed += test_binary_op(&constant_time_lt,
|
||||
"constant_time_lt", a, b, a < b);
|
||||
num_failed += test_binary_op_8(&constant_time_lt_8,
|
||||
"constant_time_lt_8", a, b, a < b);
|
||||
num_failed += test_binary_op(&constant_time_lt,
|
||||
"constant_time_lt_8", b, a, b < a);
|
||||
num_failed += test_binary_op_8(&constant_time_lt_8,
|
||||
"constant_time_lt_8", b, a, b < a);
|
||||
num_failed += test_binary_op(&constant_time_ge,
|
||||
"constant_time_ge", a, b, a >= b);
|
||||
num_failed += test_binary_op_8(&constant_time_ge_8,
|
||||
"constant_time_ge_8", a, b, a >= b);
|
||||
num_failed += test_binary_op(&constant_time_ge,
|
||||
"constant_time_ge", b, a, b >= a);
|
||||
num_failed += test_binary_op_8(&constant_time_ge_8,
|
||||
"constant_time_ge_8", b, a, b >= a);
|
||||
num_failed += test_binary_op(&constant_time_eq,
|
||||
"constant_time_eq", a, b, a == b);
|
||||
num_failed += test_binary_op_8(&constant_time_eq_8,
|
||||
"constant_time_eq_8", a, b, a == b);
|
||||
num_failed += test_binary_op(&constant_time_eq,
|
||||
"constant_time_eq", b, a, b == a);
|
||||
num_failed += test_binary_op_8(&constant_time_eq_8,
|
||||
"constant_time_eq_8", b, a, b == a);
|
||||
num_failed += test_select(a, b);
|
||||
num_all += 13;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(signed_test_values)/sizeof(int); ++i)
|
||||
{
|
||||
c = signed_test_values[i];
|
||||
for (j = 0; j < sizeof(signed_test_values)/sizeof(int); ++j)
|
||||
{
|
||||
d = signed_test_values[j];
|
||||
num_failed += test_select_int(c, d);
|
||||
num_failed += test_eq_int(c, d);
|
||||
num_failed += test_eq_int_8(c, d);
|
||||
num_all += 3;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(test_values_8); ++i)
|
||||
{
|
||||
e = test_values_8[i];
|
||||
for (j = 0; j < sizeof(test_values_8); ++j)
|
||||
{
|
||||
f = test_values_8[j];
|
||||
num_failed += test_select_8(e, f);
|
||||
num_all += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!num_failed)
|
||||
{
|
||||
fprintf(stdout, "ok (ran %d tests)\n", num_all);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stdout, "%d of %d tests failed!\n", num_failed, num_all);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
@@ -111,8 +111,8 @@ $ ET_WHIRLPOOL = "WHRLPOOL"
|
||||
$ IF ARCH .EQS. "VAX" THEN ET_WHIRLPOOL = ""
|
||||
$ ENCRYPT_TYPES = "Basic,"+ -
|
||||
"OBJECTS,"+ -
|
||||
"MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,"+ET_WHIRLPOOL+","+ -
|
||||
"DES,AES,RC2,RC4,RC5,IDEA,BF,CAST,CAMELLIA,SEED,MODES,"+ -
|
||||
"MD4,MD5,SHA,MDC2,HMAC,RIPEMD,"+ET_WHIRLPOOL+","+ -
|
||||
"DES,AES,RC2,RC4,IDEA,BF,CAST,CAMELLIA,SEED,MODES,"+ -
|
||||
"BN,EC,RSA,DSA,ECDSA,DH,ECDH,DSO,ENGINE,"+ -
|
||||
"BUFFER,BIO,STACK,LHASH,RAND,ERR,"+ -
|
||||
"EVP,EVP_2,EVP_3,ASN1,ASN1_2,PEM,X509,X509V3,"+ -
|
||||
@@ -204,11 +204,18 @@ $ GOSUB CHECK_OPT_FILE
|
||||
$!
|
||||
$! Define The Different Encryption "library" Strings.
|
||||
$!
|
||||
$ APPS_DES = "DES/DES,CBC3_ENC"
|
||||
$ APPS_PKCS7 = "ENC/ENC;DEC/DEC;SIGN/SIGN;VERIFY/VERIFY,EXAMPLE"
|
||||
$!!! Test apps disabled, as they aren't supported at all,
|
||||
$!!! not even in the unix build
|
||||
$!!! APPS_DES = "DES/DES,CBC3_ENC"
|
||||
$!!! APPS_PKCS7 = "ENC/ENC;DEC/DEC;SIGN/SIGN;VERIFY/VERIFY,EXAMPLE"
|
||||
$
|
||||
$ LIB_ = "cryptlib,mem,mem_clr,mem_dbg,cversion,ex_data,cpt_err,"+ -
|
||||
"ebcdic,uid,o_time,o_str,o_dir,o_fips.c,o_init,fips_ers"
|
||||
$! These variables are ordered as the SDIRS variable from the top Makefile.org
|
||||
$! The contents of these variables are copied from the LIBOBJ variable in the
|
||||
$! corresponding Makefile from each corresponding subdirectory, with .o stripped
|
||||
$! and spaces replaced with commas.
|
||||
$ LIB_ = "cryptlib,mem,mem_dbg,cversion,ex_data,cpt_err,ebcdic,"+ -
|
||||
"uid,o_time,o_str,o_dir,o_fips.c,o_init,fips_ers,mem_clr"
|
||||
$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err,obj_xref"
|
||||
$ LIB_MD2 = "md2_dgst,md2_one"
|
||||
$ LIB_MD4 = "md4_dgst,md4_one"
|
||||
$ LIB_MD5 = "md5_dgst,md5_one"
|
||||
@@ -225,13 +232,13 @@ $ LIB_DES = "set_key,ecb_enc,cbc_enc,"+ -
|
||||
"fcrypt,xcbc_enc,rpc_enc,cbc_cksm,"+ -
|
||||
"ede_cbcm_enc,des_old,des_old2,read2pwd"
|
||||
$ LIB_RC2 = "rc2_ecb,rc2_skey,rc2_cbc,rc2cfb64,rc2ofb64"
|
||||
$ LIB_RC4 = "rc4_skey,rc4_enc,rc4_utl"
|
||||
$ LIB_RC4 = "rc4_enc,rc4_skey,rc4_utl"
|
||||
$ LIB_RC5 = "rc5_skey,rc5_ecb,rc5_enc,rc5cfb64,rc5ofb64"
|
||||
$ LIB_IDEA = "i_cbc,i_cfb64,i_ofb64,i_ecb,i_skey"
|
||||
$ LIB_BF = "bf_skey,bf_ecb,bf_enc,bf_cfb64,bf_ofb64"
|
||||
$ LIB_CAST = "c_skey,c_ecb,c_enc,c_cfb64,c_ofb64"
|
||||
$ LIB_CAMELLIA = "camellia,cmll_misc,cmll_ecb,cmll_cbc,cmll_ofb,"+ -
|
||||
"cmll_cfb,cmll_ctr,cmll_utl"
|
||||
$ LIB_CAMELLIA = "cmll_ecb,cmll_ofb,cmll_cfb,cmll_ctr,cmll_utl,"+ -
|
||||
"camellia,cmll_misc,cmll_cbc"
|
||||
$ LIB_SEED = "seed,seed_ecb,seed_cbc,seed_cfb,seed_ofb"
|
||||
$ LIB_MODES = "cbc128,ctr128,cts128,cfb128,ofb128,gcm128,"+ -
|
||||
"ccm128,xts128"
|
||||
@@ -264,24 +271,23 @@ $ LIB_ENGINE = "eng_err,eng_lib,eng_list,eng_init,eng_ctrl,"+ -
|
||||
"eng_table,eng_pkey,eng_fat,eng_all,"+ -
|
||||
"tb_rsa,tb_dsa,tb_ecdsa,tb_dh,tb_ecdh,tb_rand,tb_store,"+ -
|
||||
"tb_cipher,tb_digest,tb_pkmeth,tb_asnmth,"+ -
|
||||
"eng_openssl,eng_dyn,eng_cnf,eng_cryptodev,"+ -
|
||||
"eng_openssl,eng_cnf,eng_dyn,eng_cryptodev,"+ -
|
||||
"eng_rsax,eng_rdrand"
|
||||
$ LIB_AES = "aes_core,aes_misc,aes_ecb,aes_cbc,aes_cfb,aes_ofb,aes_ctr,"+ -
|
||||
"aes_ige,aes_wrap"
|
||||
$ LIB_AES = "aes_misc,aes_ecb,aes_cfb,aes_ofb,aes_ctr,aes_ige,aes_wrap,"+ -
|
||||
"aes_core,aes_cbc"
|
||||
$ LIB_BUFFER = "buffer,buf_str,buf_err"
|
||||
$ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ -
|
||||
"bss_mem,bss_null,bss_fd,"+ -
|
||||
"bss_file,bss_sock,bss_conn,"+ -
|
||||
"bf_null,bf_buff,b_print,b_dump,"+ -
|
||||
"b_sock,bss_acpt,bf_nbio,bss_rtcp,bss_bio,bss_log,"+ -
|
||||
"b_sock,bss_acpt,bf_nbio,bss_log,bss_bio,"+ -
|
||||
"bss_dgram,"+ -
|
||||
"bf_lbuf"
|
||||
"bf_lbuf,bss_rtcp" ! The last two are VMS specific
|
||||
$ LIB_STACK = "stack"
|
||||
$ LIB_LHASH = "lhash,lh_stats"
|
||||
$ LIB_RAND = "md_rand,randfile,rand_lib,rand_err,rand_egd,"+ -
|
||||
"rand_vms"
|
||||
"rand_vms" ! The last one is VMS specific
|
||||
$ LIB_ERR = "err,err_all,err_prn"
|
||||
$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err,obj_xref"
|
||||
$ LIB_EVP = "encode,digest,evp_enc,evp_key,evp_acnf,evp_cnf,"+ -
|
||||
"e_des,e_bf,e_idea,e_des3,e_camellia,"+ -
|
||||
"e_rc4,e_aes,names,e_seed,"+ -
|
||||
@@ -345,7 +351,7 @@ $ LIB_TS = "ts_err,ts_req_utils,ts_req_print,ts_rsp_utils,ts_rsp_print,"+ -
|
||||
$ LIB_JPAKE = "jpake,jpake_err"
|
||||
$ LIB_SRP = "srp_lib,srp_vfy"
|
||||
$ LIB_STORE = "str_err,str_lib,str_meth,str_mem"
|
||||
$ LIB_CMAC = "cmac,cm_ameth.c,cm_pmeth"
|
||||
$ LIB_CMAC = "cmac,cm_ameth,cm_pmeth"
|
||||
$!
|
||||
$! Setup exceptional compilations
|
||||
$!
|
||||
@@ -381,7 +387,7 @@ $ MODULE_NEXT:
|
||||
$!
|
||||
$! Extract The Module Name From The Encryption List.
|
||||
$!
|
||||
$ MODULE_NAME = F$ELEMENT(MODULE_COUNTER,",",ENCRYPT_TYPES)
|
||||
$ MODULE_NAME = F$EDIT(F$ELEMENT(MODULE_COUNTER,",",ENCRYPT_TYPES),"COLLAPSE")
|
||||
$ IF MODULE_NAME.EQS."Basic" THEN MODULE_NAME = ""
|
||||
$ MODULE_NAME1 = MODULE_NAME
|
||||
$!
|
||||
@@ -465,7 +471,7 @@ $ THEN
|
||||
$!
|
||||
$! O.K, Extract The File Name From The File List.
|
||||
$!
|
||||
$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",'LIB_MODULE')
|
||||
$ FILE_NAME = F$EDIT(F$ELEMENT(FILE_COUNTER,",",'LIB_MODULE'),"COLLAPSE")
|
||||
$!
|
||||
$! else
|
||||
$!
|
||||
@@ -492,7 +498,7 @@ $! SHOW SYMBOL APPLICATION*
|
||||
$!
|
||||
$ IF APPLICATION .NES. ";"
|
||||
$ THEN
|
||||
$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",APPLICATION_OBJECTS)
|
||||
$ FILE_NAME = F$EDIT(F$ELEMENT(FILE_COUNTER,",",APPLICATION_OBJECTS),"COLLAPSE")
|
||||
$ IF FILE_NAME .EQS. ","
|
||||
$ THEN
|
||||
$ APPLICATION = ""
|
||||
@@ -1132,9 +1138,12 @@ $ CCDEFS = "TCPIP_TYPE_''P4',DSO_VMS"
|
||||
$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
|
||||
$ CCEXTRAFLAGS = ""
|
||||
$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
|
||||
$ CCDISABLEWARNINGS = "" !!! "LONGLONGTYPE,LONGLONGSUFX,FOUNDCR"
|
||||
$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
|
||||
CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," + USER_CCDISABLEWARNINGS
|
||||
$ CCDISABLEWARNINGS = "" !!! "MAYLOSEDATA3" !!! "LONGLONGTYPE,LONGLONGSUFX,FOUNDCR"
|
||||
$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. ""
|
||||
$ THEN
|
||||
$ IF CCDISABLEWARNINGS .NES. "" THEN CCDISABLEWARNINGS = CCDISABLEWARNINGS + ","
|
||||
$ CCDISABLEWARNINGS = CCDISABLEWARNINGS + USER_CCDISABLEWARNINGS
|
||||
$ ENDIF
|
||||
$!
|
||||
$! Check To See If We Have A ZLIB Option.
|
||||
$!
|
||||
@@ -1299,6 +1308,18 @@ $! Finish up the definition of CC.
|
||||
$!
|
||||
$ IF COMPILER .EQS. "DECC"
|
||||
$ THEN
|
||||
$! Not all compiler versions support MAYLOSEDATA3.
|
||||
$ OPT_TEST = "MAYLOSEDATA3"
|
||||
$ DEFINE /USER_MODE SYS$ERROR NL:
|
||||
$ DEFINE /USER_MODE SYS$OUTPUT NL:
|
||||
$ 'CC' /NOCROSS_REFERENCE /NOLIST /NOOBJECT -
|
||||
/WARNINGS = DISABLE = ('OPT_TEST', EMPTYFILE) NL:
|
||||
$ IF ($SEVERITY)
|
||||
$ THEN
|
||||
$ IF CCDISABLEWARNINGS .NES. "" THEN -
|
||||
CCDISABLEWARNINGS = CCDISABLEWARNINGS+ ","
|
||||
$ CCDISABLEWARNINGS = CCDISABLEWARNINGS+ OPT_TEST
|
||||
$ ENDIF
|
||||
$ IF CCDISABLEWARNINGS .EQS. ""
|
||||
$ THEN
|
||||
$ CC4DISABLEWARNINGS = "DOLLARID"
|
||||
|
@@ -69,10 +69,7 @@ const char *SSLeay_version(int t)
|
||||
if (t == SSLEAY_BUILT_ON)
|
||||
{
|
||||
#ifdef DATE
|
||||
static char buf[sizeof(DATE)+11];
|
||||
|
||||
BIO_snprintf(buf,sizeof buf,"built on: %s",DATE);
|
||||
return(buf);
|
||||
return(DATE);
|
||||
#else
|
||||
return("built on: date not available");
|
||||
#endif
|
||||
@@ -80,10 +77,7 @@ const char *SSLeay_version(int t)
|
||||
if (t == SSLEAY_CFLAGS)
|
||||
{
|
||||
#ifdef CFLAGS
|
||||
static char buf[sizeof(CFLAGS)+11];
|
||||
|
||||
BIO_snprintf(buf,sizeof buf,"compiler: %s",CFLAGS);
|
||||
return(buf);
|
||||
return(CFLAGS);
|
||||
#else
|
||||
return("compiler: information not available");
|
||||
#endif
|
||||
@@ -91,10 +85,7 @@ const char *SSLeay_version(int t)
|
||||
if (t == SSLEAY_PLATFORM)
|
||||
{
|
||||
#ifdef PLATFORM
|
||||
static char buf[sizeof(PLATFORM)+11];
|
||||
|
||||
BIO_snprintf(buf,sizeof buf,"platform: %s", PLATFORM);
|
||||
return(buf);
|
||||
return(PLATFORM);
|
||||
#else
|
||||
return("platform: information not available");
|
||||
#endif
|
||||
|
@@ -307,6 +307,12 @@ static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
|
||||
unsigned char *dp = NULL;
|
||||
int dplen;
|
||||
|
||||
if (!pkey->pkey.dsa || !pkey->pkey.dsa->priv_key)
|
||||
{
|
||||
DSAerr(DSA_F_DSA_PRIV_ENCODE,DSA_R_MISSING_PARAMETERS);
|
||||
goto err;
|
||||
}
|
||||
|
||||
params = ASN1_STRING_new();
|
||||
|
||||
if (!params)
|
||||
@@ -701,4 +707,3 @@ const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[] =
|
||||
old_dsa_priv_encode
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -176,13 +176,25 @@ int DSA_verify(int type, const unsigned char *dgst, int dgst_len,
|
||||
const unsigned char *sigbuf, int siglen, DSA *dsa)
|
||||
{
|
||||
DSA_SIG *s;
|
||||
const unsigned char *p = sigbuf;
|
||||
unsigned char *der = NULL;
|
||||
int derlen = -1;
|
||||
int ret=-1;
|
||||
|
||||
s = DSA_SIG_new();
|
||||
if (s == NULL) return(ret);
|
||||
if (d2i_DSA_SIG(&s,&sigbuf,siglen) == NULL) goto err;
|
||||
if (d2i_DSA_SIG(&s,&p,siglen) == NULL) goto err;
|
||||
/* Ensure signature uses DER and doesn't have trailing garbage */
|
||||
derlen = i2d_DSA_SIG(s, &der);
|
||||
if (derlen != siglen || memcmp(sigbuf, der, derlen))
|
||||
goto err;
|
||||
ret=DSA_do_verify(dgst,dgst_len,s,dsa);
|
||||
err:
|
||||
if (derlen > 0)
|
||||
{
|
||||
OPENSSL_cleanse(der, derlen);
|
||||
OPENSSL_free(der);
|
||||
}
|
||||
DSA_SIG_free(s);
|
||||
return(ret);
|
||||
}
|
||||
|
@@ -60,10 +60,8 @@
|
||||
that handle _GNU_SOURCE and other similar macros. Defining it later
|
||||
is simply too late, because those headers are protected from re-
|
||||
inclusion. */
|
||||
#ifdef __linux
|
||||
# ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE /* make sure dladdr is declared */
|
||||
# endif
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE /* make sure dladdr is declared */
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
@@ -5,6 +5,10 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Avoid name clashes with other applications */
|
||||
#define os_toascii _openssl_os_toascii
|
||||
#define os_toebcdic _openssl_os_toebcdic
|
||||
@@ -16,4 +20,7 @@ extern const unsigned char os_toebcdic[256];
|
||||
void *ebcdic2ascii(void *dest, const void *srce, size_t count);
|
||||
void *ascii2ebcdic(void *dest, const void *srce, size_t count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@@ -629,7 +629,7 @@ int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN
|
||||
int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx);
|
||||
int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx);
|
||||
|
||||
/** Computes r = generator * n sum_{i=0}^num p[i] * m[i]
|
||||
/** Computes r = generator * n sum_{i=0}^{num-1} p[i] * m[i]
|
||||
* \param group underlying EC_GROUP object
|
||||
* \param r EC_POINT object for the result
|
||||
* \param n BIGNUM with the multiplier for the group generator (optional)
|
||||
|
@@ -80,9 +80,6 @@
|
||||
|
||||
const EC_METHOD *EC_GF2m_simple_method(void)
|
||||
{
|
||||
#ifdef OPENSSL_FIPS
|
||||
return fips_ec_gf2m_simple_method();
|
||||
#else
|
||||
static const EC_METHOD ret = {
|
||||
EC_FLAGS_DEFAULT_OCT,
|
||||
NID_X9_62_characteristic_two_field,
|
||||
@@ -125,8 +122,12 @@ const EC_METHOD *EC_GF2m_simple_method(void)
|
||||
0 /* field_decode */,
|
||||
0 /* field_set_to_one */ };
|
||||
|
||||
return &ret;
|
||||
#ifdef OPENSSL_FIPS
|
||||
if (FIPS_mode())
|
||||
return fips_ec_gf2m_simple_method();
|
||||
#endif
|
||||
|
||||
return &ret;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -453,14 +453,16 @@ static int do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype)
|
||||
if (ktype > 0)
|
||||
{
|
||||
public_key = EC_KEY_get0_public_key(x);
|
||||
if ((pub_key = EC_POINT_point2bn(group, public_key,
|
||||
EC_KEY_get_conv_form(x), NULL, ctx)) == NULL)
|
||||
if (public_key != NULL)
|
||||
{
|
||||
reason = ERR_R_EC_LIB;
|
||||
goto err;
|
||||
}
|
||||
if (pub_key)
|
||||
if ((pub_key = EC_POINT_point2bn(group, public_key,
|
||||
EC_KEY_get_conv_form(x), NULL, ctx)) == NULL)
|
||||
{
|
||||
reason = ERR_R_EC_LIB;
|
||||
goto err;
|
||||
}
|
||||
buf_len = (size_t)BN_num_bytes(pub_key);
|
||||
}
|
||||
}
|
||||
|
||||
if (ktype == 2)
|
||||
|
@@ -1183,30 +1183,47 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len)
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (ret->pub_key)
|
||||
EC_POINT_clear_free(ret->pub_key);
|
||||
ret->pub_key = EC_POINT_new(ret->group);
|
||||
if (ret->pub_key == NULL)
|
||||
{
|
||||
ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (priv_key->publicKey)
|
||||
{
|
||||
const unsigned char *pub_oct;
|
||||
size_t pub_oct_len;
|
||||
int pub_oct_len;
|
||||
|
||||
if (ret->pub_key)
|
||||
EC_POINT_clear_free(ret->pub_key);
|
||||
ret->pub_key = EC_POINT_new(ret->group);
|
||||
if (ret->pub_key == NULL)
|
||||
{
|
||||
ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB);
|
||||
goto err;
|
||||
}
|
||||
pub_oct = M_ASN1_STRING_data(priv_key->publicKey);
|
||||
pub_oct_len = M_ASN1_STRING_length(priv_key->publicKey);
|
||||
/* save the point conversion form */
|
||||
/* The first byte - point conversion form - must be present. */
|
||||
if (pub_oct_len <= 0)
|
||||
{
|
||||
ECerr(EC_F_D2I_ECPRIVATEKEY, EC_R_BUFFER_TOO_SMALL);
|
||||
goto err;
|
||||
}
|
||||
/* Save the point conversion form. */
|
||||
ret->conv_form = (point_conversion_form_t)(pub_oct[0] & ~0x01);
|
||||
if (!EC_POINT_oct2point(ret->group, ret->pub_key,
|
||||
pub_oct, pub_oct_len, NULL))
|
||||
pub_oct, (size_t)(pub_oct_len), NULL))
|
||||
{
|
||||
ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!EC_POINT_mul(ret->group, ret->pub_key, ret->priv_key, NULL, NULL, NULL))
|
||||
{
|
||||
ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB);
|
||||
goto err;
|
||||
}
|
||||
/* Remember the original private-key-only encoding. */
|
||||
ret->enc_flag |= EC_PKEY_NO_PUBKEY;
|
||||
}
|
||||
|
||||
ok = 1;
|
||||
err:
|
||||
@@ -1230,7 +1247,8 @@ int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out)
|
||||
size_t buf_len=0, tmp_len;
|
||||
EC_PRIVATEKEY *priv_key=NULL;
|
||||
|
||||
if (a == NULL || a->group == NULL || a->priv_key == NULL)
|
||||
if (a == NULL || a->group == NULL || a->priv_key == NULL ||
|
||||
(!(a->enc_flag & EC_PKEY_NO_PUBKEY) && a->pub_key == NULL))
|
||||
{
|
||||
ECerr(EC_F_I2D_ECPRIVATEKEY,
|
||||
ERR_R_PASSED_NULL_PARAMETER);
|
||||
|
@@ -68,7 +68,7 @@
|
||||
|
||||
#include "ec_lcl.h"
|
||||
|
||||
static const char EC_version[] = "EC" OPENSSL_VERSION_PTEXT;
|
||||
const char EC_version[] = "EC" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
|
||||
/* functions for EC_GROUP objects */
|
||||
|
@@ -445,15 +445,16 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
|
||||
wNAF_len = OPENSSL_malloc(totalnum * sizeof wNAF_len[0]);
|
||||
wNAF = OPENSSL_malloc((totalnum + 1) * sizeof wNAF[0]); /* includes space for pivot */
|
||||
val_sub = OPENSSL_malloc(totalnum * sizeof val_sub[0]);
|
||||
|
||||
|
||||
/* Ensure wNAF is initialised in case we end up going to err */
|
||||
if (wNAF) wNAF[0] = NULL; /* preliminary pivot */
|
||||
|
||||
if (!wsize || !wNAF_len || !wNAF || !val_sub)
|
||||
{
|
||||
ECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
wNAF[0] = NULL; /* preliminary pivot */
|
||||
|
||||
/* num_val will be the total number of temporarily precomputed points */
|
||||
num_val = 0;
|
||||
|
||||
|
@@ -167,6 +167,7 @@ static int pkey_ec_verify(EVP_PKEY_CTX *ctx,
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_ECDH
|
||||
static int pkey_ec_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen)
|
||||
{
|
||||
int ret;
|
||||
@@ -200,6 +201,7 @@ static int pkey_ec_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen)
|
||||
*keylen = ret;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
|
||||
{
|
||||
@@ -333,7 +335,11 @@ const EVP_PKEY_METHOD ec_pkey_meth =
|
||||
0,0,
|
||||
|
||||
0,
|
||||
#ifndef OPENSSL_NO_ECDH
|
||||
pkey_ec_derive,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
|
||||
pkey_ec_ctrl,
|
||||
pkey_ec_ctrl_str
|
||||
|
@@ -72,9 +72,6 @@
|
||||
|
||||
const EC_METHOD *EC_GFp_mont_method(void)
|
||||
{
|
||||
#ifdef OPENSSL_FIPS
|
||||
return fips_ec_gfp_mont_method();
|
||||
#else
|
||||
static const EC_METHOD ret = {
|
||||
EC_FLAGS_DEFAULT_OCT,
|
||||
NID_X9_62_prime_field,
|
||||
@@ -114,8 +111,12 @@ const EC_METHOD *EC_GFp_mont_method(void)
|
||||
ec_GFp_mont_field_decode,
|
||||
ec_GFp_mont_field_set_to_one };
|
||||
|
||||
return &ret;
|
||||
#ifdef OPENSSL_FIPS
|
||||
if (FIPS_mode())
|
||||
return fips_ec_gfp_mont_method();
|
||||
#endif
|
||||
|
||||
return &ret;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -73,9 +73,6 @@
|
||||
|
||||
const EC_METHOD *EC_GFp_nist_method(void)
|
||||
{
|
||||
#ifdef OPENSSL_FIPS
|
||||
return fips_ec_gfp_nist_method();
|
||||
#else
|
||||
static const EC_METHOD ret = {
|
||||
EC_FLAGS_DEFAULT_OCT,
|
||||
NID_X9_62_prime_field,
|
||||
@@ -115,8 +112,12 @@ const EC_METHOD *EC_GFp_nist_method(void)
|
||||
0 /* field_decode */,
|
||||
0 /* field_set_to_one */ };
|
||||
|
||||
return &ret;
|
||||
#ifdef OPENSSL_FIPS
|
||||
if (FIPS_mode())
|
||||
return fips_ec_gfp_nist_method();
|
||||
#endif
|
||||
|
||||
return &ret;
|
||||
}
|
||||
|
||||
int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src)
|
||||
|
@@ -113,7 +113,6 @@ typedef u64 smallfelem[NLIMBS];
|
||||
|
||||
/* This is the value of the prime as four 64-bit words, little-endian. */
|
||||
static const u64 kPrime[4] = { 0xfffffffffffffffful, 0xffffffff, 0, 0xffffffff00000001ul };
|
||||
static const limb bottom32bits = 0xffffffff;
|
||||
static const u64 bottom63bits = 0x7ffffffffffffffful;
|
||||
|
||||
/* bin32_to_felem takes a little-endian byte array and converts it into felem
|
||||
|
@@ -73,9 +73,6 @@
|
||||
|
||||
const EC_METHOD *EC_GFp_simple_method(void)
|
||||
{
|
||||
#ifdef OPENSSL_FIPS
|
||||
return fips_ec_gfp_simple_method();
|
||||
#else
|
||||
static const EC_METHOD ret = {
|
||||
EC_FLAGS_DEFAULT_OCT,
|
||||
NID_X9_62_prime_field,
|
||||
@@ -115,8 +112,12 @@ const EC_METHOD *EC_GFp_simple_method(void)
|
||||
0 /* field_decode */,
|
||||
0 /* field_set_to_one */ };
|
||||
|
||||
return &ret;
|
||||
#ifdef OPENSSL_FIPS
|
||||
if (FIPS_mode())
|
||||
return fips_ec_gfp_simple_method();
|
||||
#endif
|
||||
|
||||
return &ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1317,8 +1318,8 @@ int ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT
|
||||
{
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
if (prod_Z[i] != NULL)
|
||||
BN_clear_free(prod_Z[i]);
|
||||
if (prod_Z[i] == NULL) break;
|
||||
BN_clear_free(prod_Z[i]);
|
||||
}
|
||||
OPENSSL_free(prod_Z);
|
||||
}
|
||||
|
@@ -251,14 +251,15 @@ static void group_order_tests(EC_GROUP *group)
|
||||
if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
|
||||
|
||||
/* Exercise EC_POINTs_mul, including corner cases. */
|
||||
if (EC_POINT_is_at_infinity(group, P)) ABORT;
|
||||
scalars[0] = n1; points[0] = Q; /* => infinity */
|
||||
scalars[1] = n2; points[1] = P; /* => -P */
|
||||
scalars[2] = n1; points[2] = Q; /* => infinity */
|
||||
scalars[3] = n2; points[3] = Q; /* => infinity */
|
||||
scalars[4] = n1; points[4] = P; /* => P */
|
||||
scalars[5] = n2; points[5] = Q; /* => infinity */
|
||||
if (!EC_POINTs_mul(group, Q, NULL, 5, points, scalars, ctx)) ABORT;
|
||||
if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
|
||||
if (!EC_POINTs_mul(group, P, NULL, 6, points, scalars, ctx)) ABORT;
|
||||
if (!EC_POINT_is_at_infinity(group, P)) ABORT;
|
||||
}
|
||||
fprintf(stdout, "ok\n");
|
||||
|
||||
@@ -1365,7 +1366,7 @@ static const struct nistp_test_params nistp_tests_params[] =
|
||||
},
|
||||
};
|
||||
|
||||
void nistp_single_test(const struct nistp_test_params *test)
|
||||
static void nistp_single_test(const struct nistp_test_params *test)
|
||||
{
|
||||
BN_CTX *ctx;
|
||||
BIGNUM *p, *a, *b, *x, *y, *n, *m, *order;
|
||||
@@ -1468,7 +1469,7 @@ void nistp_single_test(const struct nistp_test_params *test)
|
||||
BN_CTX_free(ctx);
|
||||
}
|
||||
|
||||
void nistp_tests()
|
||||
static void nistp_tests()
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
|
@@ -57,6 +57,7 @@
|
||||
*/
|
||||
|
||||
#include "ecs_locl.h"
|
||||
#include <string.h>
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
#include <openssl/engine.h>
|
||||
#endif
|
||||
@@ -84,13 +85,25 @@ int ECDSA_verify(int type, const unsigned char *dgst, int dgst_len,
|
||||
const unsigned char *sigbuf, int sig_len, EC_KEY *eckey)
|
||||
{
|
||||
ECDSA_SIG *s;
|
||||
const unsigned char *p = sigbuf;
|
||||
unsigned char *der = NULL;
|
||||
int derlen = -1;
|
||||
int ret=-1;
|
||||
|
||||
s = ECDSA_SIG_new();
|
||||
if (s == NULL) return(ret);
|
||||
if (d2i_ECDSA_SIG(&s, &sigbuf, sig_len) == NULL) goto err;
|
||||
if (d2i_ECDSA_SIG(&s, &p, sig_len) == NULL) goto err;
|
||||
/* Ensure signature uses DER and doesn't have trailing garbage */
|
||||
derlen = i2d_ECDSA_SIG(s, &der);
|
||||
if (derlen != sig_len || memcmp(sigbuf, der, derlen))
|
||||
goto err;
|
||||
ret=ECDSA_do_verify(dgst, dgst_len, s, eckey);
|
||||
err:
|
||||
if (derlen > 0)
|
||||
{
|
||||
OPENSSL_cleanse(der, derlen);
|
||||
OPENSSL_free(der);
|
||||
}
|
||||
ECDSA_SIG_free(s);
|
||||
return(ret);
|
||||
}
|
||||
|
@@ -114,9 +114,6 @@ static const ENGINE_CMD_DEFN dynamic_cmd_defns[] = {
|
||||
ENGINE_CMD_FLAG_NO_INPUT},
|
||||
{0, NULL, NULL, 0}
|
||||
};
|
||||
static const ENGINE_CMD_DEFN dynamic_cmd_defns_empty[] = {
|
||||
{0, NULL, NULL, 0}
|
||||
};
|
||||
|
||||
/* Loading code stores state inside the ENGINE structure via the "ex_data"
|
||||
* element. We load all our state into a single structure and use that as a
|
||||
|
@@ -71,6 +71,7 @@ R SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060
|
||||
R SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070
|
||||
R SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071
|
||||
R SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080
|
||||
R SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK 1086
|
||||
R SSL_R_TLSV1_ALERT_USER_CANCELLED 1090
|
||||
R SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100
|
||||
R SSL_R_TLSV1_UNSUPPORTED_EXTENSION 1110
|
||||
|
@@ -166,7 +166,7 @@ extern unsigned int OPENSSL_ia32cap_P[2];
|
||||
#define VPAES_CAPABLE (OPENSSL_ia32cap_P[1]&(1<<(41-32)))
|
||||
#endif
|
||||
#ifdef BSAES_ASM
|
||||
#define BSAES_CAPABLE VPAES_CAPABLE
|
||||
#define BSAES_CAPABLE (OPENSSL_ia32cap_P[1]&(1<<(41-32)))
|
||||
#endif
|
||||
/*
|
||||
* AES-NI section
|
||||
|
@@ -124,12 +124,11 @@ static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
#ifdef KSSL_DEBUG
|
||||
{
|
||||
int i;
|
||||
char *cp;
|
||||
printf("des_ede_cbc_cipher(ctx=%lx, buflen=%d)\n", ctx, ctx->buf_len);
|
||||
printf("\t iv= ");
|
||||
fprintf(stderr,"des_ede_cbc_cipher(ctx=%p, buflen=%d)\n", ctx, ctx->buf_len);
|
||||
fprintf(stderr,"\t iv= ");
|
||||
for(i=0;i<8;i++)
|
||||
printf("%02X",ctx->iv[i]);
|
||||
printf("\n");
|
||||
fprintf(stderr,"%02X",ctx->iv[i]);
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
#endif /* KSSL_DEBUG */
|
||||
while (inl>=EVP_MAXCHUNK)
|
||||
@@ -260,11 +259,14 @@ static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
#ifdef KSSL_DEBUG
|
||||
{
|
||||
int i;
|
||||
printf("des_ede3_init_key(ctx=%lx)\n", ctx);
|
||||
printf("\tKEY= ");
|
||||
for(i=0;i<24;i++) printf("%02X",key[i]); printf("\n");
|
||||
printf("\t IV= ");
|
||||
for(i=0;i<8;i++) printf("%02X",iv[i]); printf("\n");
|
||||
fprintf(stderr,"des_ede3_init_key(ctx=%p)\n", ctx);
|
||||
fprintf(stderr,"\tKEY= ");
|
||||
for(i=0;i<24;i++) fprintf(stderr,"%02X",key[i]); fprintf(stderr,"\n");
|
||||
if (iv)
|
||||
{
|
||||
fprintf(stderr,"\t IV= ");
|
||||
for(i=0;i<8;i++) fprintf(stderr,"%02X",iv[i]); fprintf(stderr,"\n");
|
||||
}
|
||||
}
|
||||
#endif /* KSSL_DEBUG */
|
||||
|
||||
|
@@ -533,6 +533,11 @@ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
|
||||
return(0);
|
||||
}
|
||||
OPENSSL_assert(b <= sizeof ctx->final);
|
||||
|
||||
/*
|
||||
* The following assumes that the ciphertext has been authenticated.
|
||||
* Otherwise it provides a padding oracle.
|
||||
*/
|
||||
n=ctx->final[b-1];
|
||||
if (n == 0 || n > (int)b)
|
||||
{
|
||||
@@ -678,4 +683,3 @@ int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in)
|
||||
return in->cipher->ctrl((EVP_CIPHER_CTX *)in, EVP_CTRL_COPY, 0, out);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@@ -75,13 +75,13 @@ $!
|
||||
$ sdirs := , -
|
||||
'archd', -
|
||||
objects, -
|
||||
md2, md4, md5, sha, mdc2, hmac, ripemd, whrlpool, -
|
||||
des, aes, rc2, rc4, rc5, idea, bf, cast, camellia, seed, -
|
||||
md4, md5, sha, mdc2, hmac, ripemd, whrlpool, -
|
||||
des, aes, rc2, rc4, idea, bf, cast, camellia, seed, -
|
||||
bn, ec, rsa, dsa, ecdsa, dh, ecdh, dso, engine, -
|
||||
buffer, bio, stack, lhash, rand, err, -
|
||||
evp, asn1, pem, x509, x509v3, conf, txt_db, pkcs7, pkcs12, comp, ocsp, -
|
||||
ui, krb5, -
|
||||
store, cms, pqueue, ts, jpake
|
||||
cms, pqueue, ts, jpake, srp, store, cmac
|
||||
$!
|
||||
$ exheader_ := crypto.h, opensslv.h, ebcdic.h, symhacks.h, ossl_typ.h
|
||||
$ exheader_'archd' := opensslconf.h
|
||||
@@ -139,6 +139,9 @@ $ exheader_cms := cms.h
|
||||
$ exheader_pqueue := pqueue.h
|
||||
$ exheader_ts := ts.h
|
||||
$ exheader_jpake := jpake.h
|
||||
$ exheader_srp := srp.h
|
||||
$ exheader_store := store.h
|
||||
$ exheader_cmac := cmac.h
|
||||
$ libs := ssl_libcrypto
|
||||
$!
|
||||
$ exe_dir := [-.'archd'.exe.crypto]
|
||||
|
@@ -225,8 +225,7 @@
|
||||
#define HOST_c2l(c,l) (l =(((unsigned long)(*((c)++)))<<24), \
|
||||
l|=(((unsigned long)(*((c)++)))<<16), \
|
||||
l|=(((unsigned long)(*((c)++)))<< 8), \
|
||||
l|=(((unsigned long)(*((c)++))) ), \
|
||||
l)
|
||||
l|=(((unsigned long)(*((c)++))) ) )
|
||||
#endif
|
||||
#ifndef HOST_l2c
|
||||
#define HOST_l2c(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \
|
||||
@@ -262,8 +261,7 @@
|
||||
#define HOST_c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \
|
||||
l|=(((unsigned long)(*((c)++)))<< 8), \
|
||||
l|=(((unsigned long)(*((c)++)))<<16), \
|
||||
l|=(((unsigned long)(*((c)++)))<<24), \
|
||||
l)
|
||||
l|=(((unsigned long)(*((c)++)))<<24) )
|
||||
#endif
|
||||
#ifndef HOST_l2c
|
||||
#define HOST_l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
|
||||
|
@@ -108,6 +108,7 @@ sub round4_step
|
||||
EOF
|
||||
}
|
||||
|
||||
no warnings qw(uninitialized);
|
||||
my $flavour = shift;
|
||||
my $output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
@@ -119,7 +120,6 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; my $dir=$1; my $xlate;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
no warnings qw(uninitialized);
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
|
12
crypto/mem.c
12
crypto/mem.c
@@ -255,10 +255,12 @@ void *CRYPTO_malloc_locked(int num, const char *file, int line)
|
||||
|
||||
if (num <= 0) return NULL;
|
||||
|
||||
allow_customize = 0;
|
||||
if(allow_customize)
|
||||
allow_customize = 0;
|
||||
if (malloc_debug_func != NULL)
|
||||
{
|
||||
allow_customize_debug = 0;
|
||||
if(allow_customize_debug)
|
||||
allow_customize_debug = 0;
|
||||
malloc_debug_func(NULL, num, file, line, 0);
|
||||
}
|
||||
ret = malloc_locked_ex_func(num,file,line);
|
||||
@@ -299,10 +301,12 @@ void *CRYPTO_malloc(int num, const char *file, int line)
|
||||
|
||||
if (num <= 0) return NULL;
|
||||
|
||||
allow_customize = 0;
|
||||
if(allow_customize)
|
||||
allow_customize = 0;
|
||||
if (malloc_debug_func != NULL)
|
||||
{
|
||||
allow_customize_debug = 0;
|
||||
if(allow_customize_debug)
|
||||
allow_customize_debug = 0;
|
||||
malloc_debug_func(NULL, num, file, line, 0);
|
||||
}
|
||||
ret = malloc_ex_func(num,file,line);
|
||||
|
@@ -7,6 +7,9 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
typedef void (*block128_f)(const unsigned char in[16],
|
||||
unsigned char out[16],
|
||||
const void *key);
|
||||
@@ -133,3 +136,6 @@ typedef struct xts128_context XTS128_CONTEXT;
|
||||
|
||||
int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char iv[16],
|
||||
const unsigned char *inp, unsigned char *out, size_t len, int enc);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -43,9 +43,6 @@ static const nid_triple sigoid_srt[] =
|
||||
|
||||
static const nid_triple * const sigoid_srt_xref[] =
|
||||
{
|
||||
&sigoid_srt[29],
|
||||
&sigoid_srt[17],
|
||||
&sigoid_srt[18],
|
||||
&sigoid_srt[0],
|
||||
&sigoid_srt[1],
|
||||
&sigoid_srt[7],
|
||||
|
@@ -90,7 +90,10 @@ EOF
|
||||
|
||||
foreach (@srt2)
|
||||
{
|
||||
my $x = $xref_tbl{$_}[2];
|
||||
my ($p1, $p2, $x) = @{$xref_tbl{$_}};
|
||||
# If digest or signature algorithm is "undef" then the algorithm
|
||||
# needs special handling and is excluded from the cross reference table.
|
||||
next if $p1 eq "undef" || $p2 eq "undef";
|
||||
print "\t\&sigoid_srt\[$x\],\n";
|
||||
}
|
||||
|
||||
|
@@ -436,8 +436,11 @@ static int ocsp_req_find_signer(X509 **psigner, OCSP_REQUEST *req, X509_NAME *nm
|
||||
if(!(flags & OCSP_NOINTERN))
|
||||
{
|
||||
signer = X509_find_by_subject(req->optionalSignature->certs, nm);
|
||||
*psigner = signer;
|
||||
return 1;
|
||||
if (signer)
|
||||
{
|
||||
*psigner = signer;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
signer = X509_find_by_subject(certs, nm);
|
||||
|
@@ -1,6 +1,10 @@
|
||||
#ifndef HEADER_OPENSSLV_H
|
||||
#define HEADER_OPENSSLV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Numeric release version identifier:
|
||||
* MNNFFPPS: major minor fix patch status
|
||||
* The status nibble has one of the values 0 for development, 1 to e for betas
|
||||
@@ -25,11 +29,11 @@
|
||||
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
|
||||
* major minor fix final patch/beta)
|
||||
*/
|
||||
#define OPENSSL_VERSION_NUMBER 0x1000109fL
|
||||
#define OPENSSL_VERSION_NUMBER 0x100010d0L
|
||||
#ifdef OPENSSL_FIPS
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1i-fips 6 Aug 2014"
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1m-fips-dev xx XXX xxxx"
|
||||
#else
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1i 6 Aug 2014"
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1m-dev xx XXX xxxx"
|
||||
#endif
|
||||
#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
|
||||
|
||||
@@ -86,4 +90,7 @@
|
||||
#define SHLIB_VERSION_NUMBER "1.0.0"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* HEADER_OPENSSLV_H */
|
||||
|
@@ -55,6 +55,10 @@
|
||||
#ifndef HEADER_OPENSSL_TYPES_H
|
||||
#define HEADER_OPENSSL_TYPES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
#ifdef NO_ASN1_TYPEDEFS
|
||||
@@ -199,4 +203,7 @@ typedef struct ocsp_req_ctx_st OCSP_REQ_CTX;
|
||||
typedef struct ocsp_response_st OCSP_RESPONSE;
|
||||
typedef struct ocsp_responder_id_st OCSP_RESPID;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* def HEADER_OPENSSL_TYPES_H */
|
||||
|
@@ -233,10 +233,6 @@ DECLARE_PKCS12_STACK_OF(PKCS7)
|
||||
(OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped)
|
||||
#define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data)
|
||||
#define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest)
|
||||
#define PKCS7_type_is_encrypted(a) \
|
||||
(OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted)
|
||||
|
||||
#define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest)
|
||||
|
||||
#define PKCS7_set_detached(p,v) \
|
||||
PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL)
|
||||
|
@@ -64,6 +64,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
typedef struct _pqueue *pqueue;
|
||||
|
||||
typedef struct _pitem
|
||||
@@ -91,4 +94,7 @@ pitem *pqueue_next(piterator *iter);
|
||||
void pqueue_print(pqueue pq);
|
||||
int pqueue_size(pqueue pq);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* ! HEADER_PQUEUE_H */
|
||||
|
@@ -196,12 +196,6 @@ int RAND_poll(void)
|
||||
DWORD w;
|
||||
int good = 0;
|
||||
|
||||
/* Determine the OS version we are on so we can turn off things
|
||||
* that do not work properly.
|
||||
*/
|
||||
OSVERSIONINFO osverinfo ;
|
||||
osverinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO) ;
|
||||
GetVersionEx( &osverinfo ) ;
|
||||
|
||||
#if defined(OPENSSL_SYS_WINCE)
|
||||
# if defined(_WIN32_WCE) && _WIN32_WCE>=300
|
||||
@@ -281,56 +275,6 @@ int RAND_poll(void)
|
||||
* at random times on Windows 2000. Reported by Jeffrey Altman.
|
||||
* Only use it on NT.
|
||||
*/
|
||||
/* Wolfgang Marczy <WMarczy@topcall.co.at> reports that
|
||||
* the RegQueryValueEx call below can hang on NT4.0 (SP6).
|
||||
* So we don't use this at all for now. */
|
||||
#if 0
|
||||
if ( osverinfo.dwPlatformId == VER_PLATFORM_WIN32_NT &&
|
||||
osverinfo.dwMajorVersion < 5)
|
||||
{
|
||||
/* Read Performance Statistics from NT/2000 registry
|
||||
* The size of the performance data can vary from call
|
||||
* to call so we must guess the size of the buffer to use
|
||||
* and increase its size if we get an ERROR_MORE_DATA
|
||||
* return instead of ERROR_SUCCESS.
|
||||
*/
|
||||
LONG rc=ERROR_MORE_DATA;
|
||||
char * buf=NULL;
|
||||
DWORD bufsz=0;
|
||||
DWORD length;
|
||||
|
||||
while (rc == ERROR_MORE_DATA)
|
||||
{
|
||||
buf = realloc(buf,bufsz+8192);
|
||||
if (!buf)
|
||||
break;
|
||||
bufsz += 8192;
|
||||
|
||||
length = bufsz;
|
||||
rc = RegQueryValueEx(HKEY_PERFORMANCE_DATA, TEXT("Global"),
|
||||
NULL, NULL, buf, &length);
|
||||
}
|
||||
if (rc == ERROR_SUCCESS)
|
||||
{
|
||||
/* For entropy count assume only least significant
|
||||
* byte of each DWORD is random.
|
||||
*/
|
||||
RAND_add(&length, sizeof(length), 0);
|
||||
RAND_add(buf, length, length / 4.0);
|
||||
|
||||
/* Close the Registry Key to allow Windows to cleanup/close
|
||||
* the open handle
|
||||
* Note: The 'HKEY_PERFORMANCE_DATA' key is implicitly opened
|
||||
* when the RegQueryValueEx above is done. However, if
|
||||
* it is not explicitly closed, it can cause disk
|
||||
* partition manipulation problems.
|
||||
*/
|
||||
RegCloseKey(HKEY_PERFORMANCE_DATA);
|
||||
}
|
||||
if (buf)
|
||||
free(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (advapi)
|
||||
{
|
||||
@@ -383,7 +327,7 @@ int RAND_poll(void)
|
||||
if (advapi)
|
||||
FreeLibrary(advapi);
|
||||
|
||||
if ((osverinfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
|
||||
if ((!check_winnt() ||
|
||||
!OPENSSL_isservice()) &&
|
||||
(user = LoadLibrary(TEXT("USER32.DLL"))))
|
||||
{
|
||||
@@ -407,8 +351,7 @@ int RAND_poll(void)
|
||||
* on NT4 even though it exists in SP3 (or SP6) and
|
||||
* higher.
|
||||
*/
|
||||
if ( osverinfo.dwPlatformId == VER_PLATFORM_WIN32_NT &&
|
||||
osverinfo.dwMajorVersion < 5)
|
||||
if (check_winnt() && !check_win_minplat(5))
|
||||
cursor = 0;
|
||||
}
|
||||
if (cursor)
|
||||
|
@@ -212,7 +212,7 @@ rsa_oaep.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
rsa_oaep.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
|
||||
rsa_oaep.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
||||
rsa_oaep.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
rsa_oaep.o: ../cryptlib.h rsa_oaep.c
|
||||
rsa_oaep.o: ../constant_time_locl.h ../cryptlib.h rsa_oaep.c
|
||||
rsa_pk1.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
rsa_pk1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
rsa_pk1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
@@ -221,7 +221,8 @@ rsa_pk1.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
rsa_pk1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
rsa_pk1.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
|
||||
rsa_pk1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
rsa_pk1.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_pk1.c
|
||||
rsa_pk1.o: ../../include/openssl/symhacks.h ../constant_time_locl.h
|
||||
rsa_pk1.o: ../cryptlib.h rsa_pk1.c
|
||||
rsa_pmeth.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
rsa_pmeth.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
|
||||
rsa_pmeth.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
|
||||
|
@@ -559,6 +559,7 @@ void ERR_load_RSA_strings(void);
|
||||
#define RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE 158
|
||||
#define RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 148
|
||||
#define RSA_R_PADDING_CHECK_FAILED 114
|
||||
#define RSA_R_PKCS_DECODING_ERROR 159
|
||||
#define RSA_R_P_NOT_PRIME 128
|
||||
#define RSA_R_Q_NOT_PRIME 129
|
||||
#define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 130
|
||||
|
@@ -175,6 +175,7 @@ static ERR_STRING_DATA RSA_str_reasons[]=
|
||||
{ERR_REASON(RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE),"operation not allowed in fips mode"},
|
||||
{ERR_REASON(RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE),"operation not supported for this keytype"},
|
||||
{ERR_REASON(RSA_R_PADDING_CHECK_FAILED) ,"padding check failed"},
|
||||
{ERR_REASON(RSA_R_PKCS_DECODING_ERROR) ,"pkcs decoding error"},
|
||||
{ERR_REASON(RSA_R_P_NOT_PRIME) ,"p not prime"},
|
||||
{ERR_REASON(RSA_R_Q_NOT_PRIME) ,"q not prime"},
|
||||
{ERR_REASON(RSA_R_RSA_OPERATIONS_NOT_SUPPORTED),"rsa operations not supported"},
|
||||
|
@@ -18,6 +18,7 @@
|
||||
* an equivalent notion.
|
||||
*/
|
||||
|
||||
#include "constant_time_locl.h"
|
||||
|
||||
#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
|
||||
#include <stdio.h>
|
||||
@@ -95,92 +96,117 @@ int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
|
||||
const unsigned char *from, int flen, int num,
|
||||
const unsigned char *param, int plen)
|
||||
{
|
||||
int i, dblen, mlen = -1;
|
||||
const unsigned char *maskeddb;
|
||||
int lzero;
|
||||
unsigned char *db = NULL, seed[SHA_DIGEST_LENGTH], phash[SHA_DIGEST_LENGTH];
|
||||
unsigned char *padded_from;
|
||||
int bad = 0;
|
||||
int i, dblen, mlen = -1, one_index = 0, msg_index;
|
||||
unsigned int good, found_one_byte;
|
||||
const unsigned char *maskedseed, *maskeddb;
|
||||
/* |em| is the encoded message, zero-padded to exactly |num| bytes:
|
||||
* em = Y || maskedSeed || maskedDB */
|
||||
unsigned char *db = NULL, *em = NULL, seed[EVP_MAX_MD_SIZE],
|
||||
phash[EVP_MAX_MD_SIZE];
|
||||
|
||||
if (--num < 2 * SHA_DIGEST_LENGTH + 1)
|
||||
/* 'num' is the length of the modulus, i.e. does not depend on the
|
||||
* particular ciphertext. */
|
||||
if (tlen <= 0 || flen <= 0)
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* |num| is the length of the modulus; |flen| is the length of the
|
||||
* encoded message. Therefore, for any |from| that was obtained by
|
||||
* decrypting a ciphertext, we must have |flen| <= |num|. Similarly,
|
||||
* num < 2 * SHA_DIGEST_LENGTH + 2 must hold for the modulus
|
||||
* irrespective of the ciphertext, see PKCS #1 v2.2, section 7.1.2.
|
||||
* This does not leak any side-channel information.
|
||||
*/
|
||||
if (num < flen || num < 2 * SHA_DIGEST_LENGTH + 2)
|
||||
goto decoding_err;
|
||||
|
||||
lzero = num - flen;
|
||||
if (lzero < 0)
|
||||
{
|
||||
/* signalling this error immediately after detection might allow
|
||||
* for side-channel attacks (e.g. timing if 'plen' is huge
|
||||
* -- cf. James H. Manger, "A Chosen Ciphertext Attack on RSA Optimal
|
||||
* Asymmetric Encryption Padding (OAEP) [...]", CRYPTO 2001),
|
||||
* so we use a 'bad' flag */
|
||||
bad = 1;
|
||||
lzero = 0;
|
||||
flen = num; /* don't overflow the memcpy to padded_from */
|
||||
}
|
||||
|
||||
dblen = num - SHA_DIGEST_LENGTH;
|
||||
db = OPENSSL_malloc(dblen + num);
|
||||
if (db == NULL)
|
||||
dblen = num - SHA_DIGEST_LENGTH - 1;
|
||||
db = OPENSSL_malloc(dblen);
|
||||
em = OPENSSL_malloc(num);
|
||||
if (db == NULL || em == NULL)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, ERR_R_MALLOC_FAILURE);
|
||||
return -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Always do this zero-padding copy (even when lzero == 0)
|
||||
* to avoid leaking timing info about the value of lzero. */
|
||||
padded_from = db + dblen;
|
||||
memset(padded_from, 0, lzero);
|
||||
memcpy(padded_from + lzero, from, flen);
|
||||
/*
|
||||
* Always do this zero-padding copy (even when num == flen) to avoid
|
||||
* leaking that information. The copy still leaks some side-channel
|
||||
* information, but it's impossible to have a fixed memory access
|
||||
* pattern since we can't read out of the bounds of |from|.
|
||||
*
|
||||
* TODO(emilia): Consider porting BN_bn2bin_padded from BoringSSL.
|
||||
*/
|
||||
memset(em, 0, num);
|
||||
memcpy(em + num - flen, from, flen);
|
||||
|
||||
maskeddb = padded_from + SHA_DIGEST_LENGTH;
|
||||
/*
|
||||
* The first byte must be zero, however we must not leak if this is
|
||||
* true. See James H. Manger, "A Chosen Ciphertext Attack on RSA
|
||||
* Optimal Asymmetric Encryption Padding (OAEP) [...]", CRYPTO 2001).
|
||||
*/
|
||||
good = constant_time_is_zero(em[0]);
|
||||
|
||||
maskedseed = em + 1;
|
||||
maskeddb = em + 1 + SHA_DIGEST_LENGTH;
|
||||
|
||||
if (MGF1(seed, SHA_DIGEST_LENGTH, maskeddb, dblen))
|
||||
return -1;
|
||||
goto cleanup;
|
||||
for (i = 0; i < SHA_DIGEST_LENGTH; i++)
|
||||
seed[i] ^= padded_from[i];
|
||||
|
||||
seed[i] ^= maskedseed[i];
|
||||
|
||||
if (MGF1(db, dblen, seed, SHA_DIGEST_LENGTH))
|
||||
return -1;
|
||||
goto cleanup;
|
||||
for (i = 0; i < dblen; i++)
|
||||
db[i] ^= maskeddb[i];
|
||||
|
||||
if (!EVP_Digest((void *)param, plen, phash, NULL, EVP_sha1(), NULL))
|
||||
return -1;
|
||||
goto cleanup;
|
||||
|
||||
if (CRYPTO_memcmp(db, phash, SHA_DIGEST_LENGTH) != 0 || bad)
|
||||
good &= constant_time_is_zero(CRYPTO_memcmp(db, phash, SHA_DIGEST_LENGTH));
|
||||
|
||||
found_one_byte = 0;
|
||||
for (i = SHA_DIGEST_LENGTH; i < dblen; i++)
|
||||
{
|
||||
/* Padding consists of a number of 0-bytes, followed by a 1. */
|
||||
unsigned int equals1 = constant_time_eq(db[i], 1);
|
||||
unsigned int equals0 = constant_time_is_zero(db[i]);
|
||||
one_index = constant_time_select_int(~found_one_byte & equals1,
|
||||
i, one_index);
|
||||
found_one_byte |= equals1;
|
||||
good &= (found_one_byte | equals0);
|
||||
}
|
||||
|
||||
good &= found_one_byte;
|
||||
|
||||
/*
|
||||
* At this point |good| is zero unless the plaintext was valid,
|
||||
* so plaintext-awareness ensures timing side-channels are no longer a
|
||||
* concern.
|
||||
*/
|
||||
if (!good)
|
||||
goto decoding_err;
|
||||
|
||||
msg_index = one_index + 1;
|
||||
mlen = dblen - msg_index;
|
||||
|
||||
if (tlen < mlen)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, RSA_R_DATA_TOO_LARGE);
|
||||
mlen = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = SHA_DIGEST_LENGTH; i < dblen; i++)
|
||||
if (db[i] != 0x00)
|
||||
break;
|
||||
if (i == dblen || db[i] != 0x01)
|
||||
goto decoding_err;
|
||||
else
|
||||
{
|
||||
/* everything looks OK */
|
||||
|
||||
mlen = dblen - ++i;
|
||||
if (tlen < mlen)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, RSA_R_DATA_TOO_LARGE);
|
||||
mlen = -1;
|
||||
}
|
||||
else
|
||||
memcpy(to, db + i, mlen);
|
||||
}
|
||||
memcpy(to, db + msg_index, mlen);
|
||||
goto cleanup;
|
||||
}
|
||||
OPENSSL_free(db);
|
||||
return mlen;
|
||||
|
||||
decoding_err:
|
||||
/* to avoid chosen ciphertext attacks, the error message should not reveal
|
||||
* which kind of decoding error happened */
|
||||
/* To avoid chosen ciphertext attacks, the error message should not reveal
|
||||
* which kind of decoding error happened. */
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, RSA_R_OAEP_DECODING_ERROR);
|
||||
cleanup:
|
||||
if (db != NULL) OPENSSL_free(db);
|
||||
return -1;
|
||||
if (em != NULL) OPENSSL_free(em);
|
||||
return mlen;
|
||||
}
|
||||
|
||||
int PKCS1_MGF1(unsigned char *mask, long len,
|
||||
|
@@ -56,6 +56,8 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include "constant_time_locl.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/bn.h>
|
||||
@@ -181,44 +183,87 @@ int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
|
||||
int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
|
||||
const unsigned char *from, int flen, int num)
|
||||
{
|
||||
int i,j;
|
||||
const unsigned char *p;
|
||||
int i;
|
||||
/* |em| is the encoded message, zero-padded to exactly |num| bytes */
|
||||
unsigned char *em = NULL;
|
||||
unsigned int good, found_zero_byte;
|
||||
int zero_index = 0, msg_index, mlen = -1;
|
||||
|
||||
p=from;
|
||||
if ((num != (flen+1)) || (*(p++) != 02))
|
||||
if (tlen < 0 || flen < 0)
|
||||
return -1;
|
||||
|
||||
/* PKCS#1 v1.5 decryption. See "PKCS #1 v2.2: RSA Cryptography
|
||||
* Standard", section 7.2.2. */
|
||||
|
||||
if (flen > num)
|
||||
goto err;
|
||||
|
||||
if (num < 11)
|
||||
goto err;
|
||||
|
||||
em = OPENSSL_malloc(num);
|
||||
if (em == NULL)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2,RSA_R_BLOCK_TYPE_IS_NOT_02);
|
||||
return(-1);
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2, ERR_R_MALLOC_FAILURE);
|
||||
return -1;
|
||||
}
|
||||
#ifdef PKCS1_CHECK
|
||||
return(num-11);
|
||||
#endif
|
||||
memset(em, 0, num);
|
||||
/*
|
||||
* Always do this zero-padding copy (even when num == flen) to avoid
|
||||
* leaking that information. The copy still leaks some side-channel
|
||||
* information, but it's impossible to have a fixed memory access
|
||||
* pattern since we can't read out of the bounds of |from|.
|
||||
*
|
||||
* TODO(emilia): Consider porting BN_bn2bin_padded from BoringSSL.
|
||||
*/
|
||||
memcpy(em + num - flen, from, flen);
|
||||
|
||||
/* scan over padding data */
|
||||
j=flen-1; /* one for type. */
|
||||
for (i=0; i<j; i++)
|
||||
if (*(p++) == 0) break;
|
||||
good = constant_time_is_zero(em[0]);
|
||||
good &= constant_time_eq(em[1], 2);
|
||||
|
||||
if (i == j)
|
||||
found_zero_byte = 0;
|
||||
for (i = 2; i < num; i++)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2,RSA_R_NULL_BEFORE_BLOCK_MISSING);
|
||||
return(-1);
|
||||
unsigned int equals0 = constant_time_is_zero(em[i]);
|
||||
zero_index = constant_time_select_int(~found_zero_byte & equals0, i, zero_index);
|
||||
found_zero_byte |= equals0;
|
||||
}
|
||||
|
||||
if (i < 8)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2,RSA_R_BAD_PAD_BYTE_COUNT);
|
||||
return(-1);
|
||||
}
|
||||
i++; /* Skip over the '\0' */
|
||||
j-=i;
|
||||
if (j > tlen)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2,RSA_R_DATA_TOO_LARGE);
|
||||
return(-1);
|
||||
}
|
||||
memcpy(to,p,(unsigned int)j);
|
||||
/*
|
||||
* PS must be at least 8 bytes long, and it starts two bytes into |em|.
|
||||
* If we never found a 0-byte, then |zero_index| is 0 and the check
|
||||
* also fails.
|
||||
*/
|
||||
good &= constant_time_ge((unsigned int)(zero_index), 2 + 8);
|
||||
|
||||
return(j);
|
||||
/* Skip the zero byte. This is incorrect if we never found a zero-byte
|
||||
* but in this case we also do not copy the message out. */
|
||||
msg_index = zero_index + 1;
|
||||
mlen = num - msg_index;
|
||||
|
||||
/* For good measure, do this check in constant time as well; it could
|
||||
* leak something if |tlen| was assuming valid padding. */
|
||||
good &= constant_time_ge((unsigned int)(tlen), (unsigned int)(mlen));
|
||||
|
||||
/*
|
||||
* We can't continue in constant-time because we need to copy the result
|
||||
* and we cannot fake its length. This unavoidably leaks timing
|
||||
* information at the API boundary.
|
||||
* TODO(emilia): this could be addressed at the call site,
|
||||
* see BoringSSL commit 0aa0767340baf925bda4804882aab0cb974b2d26.
|
||||
*/
|
||||
if (!good)
|
||||
{
|
||||
mlen = -1;
|
||||
goto err;
|
||||
}
|
||||
|
||||
memcpy(to, em + msg_index, mlen);
|
||||
|
||||
err:
|
||||
if (em != NULL)
|
||||
OPENSSL_free(em);
|
||||
if (mlen == -1)
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2, RSA_R_PKCS_DECODING_ERROR);
|
||||
return mlen;
|
||||
}
|
||||
|
||||
|
@@ -151,6 +151,25 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len,
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check DigestInfo structure does not contain extraneous data by reencoding
|
||||
* using DER and checking encoding against original.
|
||||
*/
|
||||
static int rsa_check_digestinfo(X509_SIG *sig, const unsigned char *dinfo, int dinfolen)
|
||||
{
|
||||
unsigned char *der = NULL;
|
||||
int derlen;
|
||||
int ret = 0;
|
||||
derlen = i2d_X509_SIG(sig, &der);
|
||||
if (derlen <= 0)
|
||||
return 0;
|
||||
if (derlen == dinfolen && !memcmp(dinfo, der, derlen))
|
||||
ret = 1;
|
||||
OPENSSL_cleanse(der, derlen);
|
||||
OPENSSL_free(der);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int int_rsa_verify(int dtype, const unsigned char *m,
|
||||
unsigned int m_len,
|
||||
unsigned char *rm, size_t *prm_len,
|
||||
@@ -228,7 +247,7 @@ int int_rsa_verify(int dtype, const unsigned char *m,
|
||||
if (sig == NULL) goto err;
|
||||
|
||||
/* Excess data can be used to create forgeries */
|
||||
if(p != s+i)
|
||||
if(p != s+i || !rsa_check_digestinfo(sig, s, i))
|
||||
{
|
||||
RSAerr(RSA_F_INT_RSA_VERIFY,RSA_R_BAD_SIGNATURE);
|
||||
goto err;
|
||||
|
@@ -64,7 +64,7 @@ if ($flavour =~ /64|n32/i) {
|
||||
#
|
||||
######################################################################
|
||||
|
||||
$big_endian=(`echo MIPSEL | $ENV{CC} -E -P -`=~/MIPSEL/)?1:0;
|
||||
$big_endian=(`echo MIPSEL | $ENV{CC} -E -`=~/MIPSEL/)?1:0 if ($ENV{CC});
|
||||
|
||||
for (@ARGV) { $output=$_ if (/^\w[\w\-]*\.\w+$/); }
|
||||
open STDOUT,">$output";
|
||||
|
@@ -68,7 +68,7 @@ $pf = ($flavour =~ /nubi/i) ? $t0 : $t2;
|
||||
#
|
||||
######################################################################
|
||||
|
||||
$big_endian=(`echo MIPSEL | $ENV{CC} -E -P -`=~/MIPSEL/)?1:0;
|
||||
$big_endian=(`echo MIPSEL | $ENV{CC} -E -`=~/MIPSEL/)?1:0 if ($ENV{CC});
|
||||
|
||||
for (@ARGV) { $output=$_ if (/^\w[\w\-]*\.\w+$/); }
|
||||
open STDOUT,">$output";
|
||||
|
@@ -57,6 +57,10 @@
|
||||
|
||||
#include <openssl/stack.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef CHECKED_PTR_OF
|
||||
#define CHECKED_PTR_OF(type, p) \
|
||||
((void*) (1 ? p : (type*)0))
|
||||
@@ -2660,4 +2664,8 @@ DECLARE_SPECIAL_STACK_OF(OPENSSL_BLOCK, void)
|
||||
#define lh_SSL_SESSION_free(lh) LHM_lh_free(SSL_SESSION,lh)
|
||||
/* End of util/mkstack.pl block, you may now edit :-) */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !defined HEADER_SAFESTACK_H */
|
||||
|
@@ -977,7 +977,7 @@ TS_RESP_set_genTime_with_precision(ASN1_GENERALIZEDTIME *asn1_time,
|
||||
if (precision > 0)
|
||||
{
|
||||
/* Add fraction of seconds (leave space for dot and null). */
|
||||
BIO_snprintf(p, 2 + precision, ".%ld", usec);
|
||||
BIO_snprintf(p, 2 + precision, ".%06ld", usec);
|
||||
/* We cannot use the snprintf return value,
|
||||
because it might have been truncated. */
|
||||
p += strlen(p);
|
||||
|
@@ -768,6 +768,7 @@ int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval);
|
||||
void X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval,
|
||||
X509_ALGOR *algor);
|
||||
void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);
|
||||
int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);
|
||||
|
||||
X509_NAME *X509_NAME_dup(X509_NAME *xn);
|
||||
X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);
|
||||
|
@@ -89,6 +89,8 @@ X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void)
|
||||
{
|
||||
X509_VERIFY_PARAM *param;
|
||||
param = OPENSSL_malloc(sizeof(X509_VERIFY_PARAM));
|
||||
if (!param)
|
||||
return NULL;
|
||||
memset(param, 0, sizeof(X509_VERIFY_PARAM));
|
||||
x509_verify_param_zero(param);
|
||||
return param;
|
||||
|
@@ -72,6 +72,8 @@
|
||||
|
||||
int X509_verify(X509 *a, EVP_PKEY *r)
|
||||
{
|
||||
if (X509_ALGOR_cmp(a->sig_alg, a->cert_info->signature))
|
||||
return 0;
|
||||
return(ASN1_item_verify(ASN1_ITEM_rptr(X509_CINF),a->sig_alg,
|
||||
a->signature,a->cert_info,r));
|
||||
}
|
||||
|
@@ -401,7 +401,7 @@ static int nc_dns(ASN1_IA5STRING *dns, ASN1_IA5STRING *base)
|
||||
if (dns->length > base->length)
|
||||
{
|
||||
dnsptr += dns->length - base->length;
|
||||
if (dnsptr[-1] != '.')
|
||||
if (*baseptr != '.' && dnsptr[-1] != '.')
|
||||
return X509_V_ERR_PERMITTED_VIOLATION;
|
||||
}
|
||||
|
||||
|
@@ -3,22 +3,22 @@
|
||||
|
||||
1. Introduction
|
||||
|
||||
How you handle certificates depend a great deal on what your role is.
|
||||
How you handle certificates depends a great deal on what your role is.
|
||||
Your role can be one or several of:
|
||||
|
||||
- User of some client software
|
||||
- User of some server software
|
||||
- User of some client application
|
||||
- User of some server application
|
||||
- Certificate authority
|
||||
|
||||
This file is for users who wish to get a certificate of their own.
|
||||
Certificate authorities should read ca.txt.
|
||||
Certificate authorities should read https://www.openssl.org/docs/apps/ca.html.
|
||||
|
||||
In all the cases shown below, the standard configuration file, as
|
||||
compiled into openssl, will be used. You may find it in /etc/,
|
||||
/usr/local/ssl/ or somewhere else. The name is openssl.cnf, and
|
||||
is better described in another HOWTO <config.txt?>. If you want to
|
||||
use a different configuration file, use the argument '-config {file}'
|
||||
with the command shown below.
|
||||
/usr/local/ssl/ or somewhere else. By default the file is named
|
||||
openssl.cnf and is described at https://www.openssl.org/docs/apps/config.html.
|
||||
You can specify a different configuration file using the
|
||||
'-config {file}' argument with the commands shown below.
|
||||
|
||||
|
||||
2. Relationship with keys
|
||||
@@ -29,24 +29,26 @@ somewhere. With OpenSSL, public keys are easily derived from private
|
||||
keys, so before you create a certificate or a certificate request, you
|
||||
need to create a private key.
|
||||
|
||||
Private keys are generated with 'openssl genrsa' if you want a RSA
|
||||
private key, or 'openssl gendsa' if you want a DSA private key.
|
||||
Further information on how to create private keys can be found in
|
||||
another HOWTO <keys.txt?>. The rest of this text assumes you have
|
||||
a private key in the file privkey.pem.
|
||||
Private keys are generated with 'openssl genrsa -out privkey.pem' if
|
||||
you want a RSA private key, or if you want a DSA private key:
|
||||
'openssl dsaparam -out dsaparam.pem 2048; openssl gendsa -out privkey.pem dsaparam.pem'.
|
||||
|
||||
The private keys created by these commands are not passphrase protected;
|
||||
it might or might not be the desirable thing. Further information on how to
|
||||
create private keys can be found at https://www.openssl.org/docs/HOWTO/keys.txt.
|
||||
The rest of this text assumes you have a private key in the file privkey.pem.
|
||||
|
||||
|
||||
3. Creating a certificate request
|
||||
|
||||
To create a certificate, you need to start with a certificate
|
||||
request (or, as some certificate authorities like to put
|
||||
it, "certificate signing request", since that's exactly what they do,
|
||||
they sign it and give you the result back, thus making it authentic
|
||||
according to their policies). A certificate request can then be sent
|
||||
to a certificate authority to get it signed into a certificate, or if
|
||||
you have your own certificate authority, you may sign it yourself, or
|
||||
if you need a self-signed certificate (because you just want a test
|
||||
certificate or because you are setting up your own CA).
|
||||
To create a certificate, you need to start with a certificate request
|
||||
(or, as some certificate authorities like to put it, "certificate
|
||||
signing request", since that's exactly what they do, they sign it and
|
||||
give you the result back, thus making it authentic according to their
|
||||
policies). A certificate request is sent to a certificate authority
|
||||
to get it signed into a certificate. You can also sign the certificate
|
||||
yourself if you have your own certificate authority or create a
|
||||
self-signed certificate (typically for testing purpose).
|
||||
|
||||
The certificate request is created like this:
|
||||
|
||||
@@ -55,12 +57,14 @@ The certificate request is created like this:
|
||||
Now, cert.csr can be sent to the certificate authority, if they can
|
||||
handle files in PEM format. If not, use the extra argument '-outform'
|
||||
followed by the keyword for the format to use (see another HOWTO
|
||||
<formats.txt?>). In some cases, that isn't sufficient and you will
|
||||
have to be more creative.
|
||||
<formats.txt?>). In some cases, -outform does not let you output the
|
||||
certificate request in the right format and you will have to use one
|
||||
of the various other commands that are exposed by openssl (or get
|
||||
creative and use a combination of tools).
|
||||
|
||||
When the certificate authority has then done the checks the need to
|
||||
do (and probably gotten payment from you), they will hand over your
|
||||
new certificate to you.
|
||||
The certificate authority performs various checks (according to their
|
||||
policies) and usually waits for payment from you. Once that is
|
||||
complete, they send you your new certificate.
|
||||
|
||||
Section 5 will tell you more on how to handle the certificate you
|
||||
received.
|
||||
@@ -68,11 +72,12 @@ received.
|
||||
|
||||
4. Creating a self-signed test certificate
|
||||
|
||||
If you don't want to deal with another certificate authority, or just
|
||||
want to create a test certificate for yourself. This is similar to
|
||||
creating a certificate request, but creates a certificate instead of
|
||||
a certificate request. This is NOT the recommended way to create a
|
||||
CA certificate, see ca.txt.
|
||||
You can create a self-signed certificate if you don't want to deal
|
||||
with a certificate authority, or if you just want to create a test
|
||||
certificate for yourself. This is similar to creating a certificate
|
||||
request, but creates a certificate instead of a certificate request.
|
||||
This is NOT the recommended way to create a CA certificate, see
|
||||
https://www.openssl.org/docs/apps/ca.html.
|
||||
|
||||
openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095
|
||||
|
||||
@@ -93,13 +98,13 @@ certificate and your key to various formats, most often also putting
|
||||
them together into one file. The ways to do this is described in
|
||||
another HOWTO <formats.txt?>, I will just mention the simplest case.
|
||||
In the case of a raw DER thing in PEM format, and assuming that's all
|
||||
right for yor applications, simply concatenating the certificate and
|
||||
right for your applications, simply concatenating the certificate and
|
||||
the key into a new file and using that one should be enough. With
|
||||
some applications, you don't even have to do that.
|
||||
|
||||
|
||||
By now, you have your cetificate and your private key and can start
|
||||
using the software that depend on it.
|
||||
By now, you have your certificate and your private key and can start
|
||||
using applications that depend on it.
|
||||
|
||||
--
|
||||
Richard Levitte
|
||||
|
@@ -1,74 +1,69 @@
|
||||
<DRAFT!>
|
||||
HOWTO proxy certificates
|
||||
|
||||
0. WARNING
|
||||
|
||||
NONE OF THE CODE PRESENTED HERE HAVE BEEN CHECKED! They are just an
|
||||
example to show you how things can be done. There may be typos or
|
||||
type conflicts, and you will have to resolve them.
|
||||
NONE OF THE CODE PRESENTED HERE HAS BEEN CHECKED! The code is just examples to
|
||||
show you how things could be done. There might be typos or type conflicts, and
|
||||
you will have to resolve them.
|
||||
|
||||
1. Introduction
|
||||
|
||||
Proxy certificates are defined in RFC 3820. They are really usual
|
||||
certificates with the mandatory extension proxyCertInfo.
|
||||
Proxy certificates are defined in RFC 3820. They are really usual certificates
|
||||
with the mandatory extension proxyCertInfo.
|
||||
|
||||
Proxy certificates are issued by an End Entity (typically a user),
|
||||
either directly with the EE certificate as issuing certificate, or by
|
||||
extension through an already issued proxy certificate.. They are used
|
||||
to extend rights to some other entity (a computer process, typically,
|
||||
or sometimes to the user itself), so it can perform operations in the
|
||||
name of the owner of the EE certificate.
|
||||
Proxy certificates are issued by an End Entity (typically a user), either
|
||||
directly with the EE certificate as issuing certificate, or by extension through
|
||||
an already issued proxy certificate. Proxy certificates are used to extend
|
||||
rights to some other entity (a computer process, typically, or sometimes to the
|
||||
user itself). This allows the entity to perform operations on behalf of the
|
||||
owner of the EE certificate.
|
||||
|
||||
See http://www.ietf.org/rfc/rfc3820.txt for more information.
|
||||
|
||||
|
||||
2. A warning about proxy certificates
|
||||
|
||||
Noone seems to have tested proxy certificates with security in mind.
|
||||
Basically, to this date, it seems that proxy certificates have only
|
||||
been used in a world that's highly aware of them. What would happen
|
||||
if an unsuspecting application is to validate a chain of certificates
|
||||
that contains proxy certificates? It would usually consider the leaf
|
||||
to be the certificate to check for authorisation data, and since proxy
|
||||
certificates are controlled by the EE certificate owner alone, it's
|
||||
would be normal to consider what the EE certificate owner could do
|
||||
with them.
|
||||
No one seems to have tested proxy certificates with security in mind. To this
|
||||
date, it seems that proxy certificates have only been used in a context highly
|
||||
aware of them.
|
||||
|
||||
subjectAltName and issuerAltName are forbidden in proxy certificates,
|
||||
and this is enforced in OpenSSL. The subject must be the same as the
|
||||
issuer, with one commonName added on.
|
||||
Existing applications might misbehave when trying to validate a chain of
|
||||
certificates which use a proxy certificate. They might incorrectly consider the
|
||||
leaf to be the certificate to check for authorisation data, which is controlled
|
||||
by the EE certificate owner.
|
||||
|
||||
Possible threats are, as far as has been imagined so far:
|
||||
subjectAltName and issuerAltName are forbidden in proxy certificates, and this
|
||||
is enforced in OpenSSL. The subject must be the same as the issuer, with one
|
||||
commonName added on.
|
||||
|
||||
Possible threats we can think of at this time include:
|
||||
|
||||
- impersonation through commonName (think server certificates).
|
||||
- use of additional extensions, possibly non-standard ones used in
|
||||
certain environments, that would grant extra or different
|
||||
authorisation rights.
|
||||
- use of additional extensions, possibly non-standard ones used in certain
|
||||
environments, that would grant extra or different authorisation rights.
|
||||
|
||||
For this reason, OpenSSL requires that the use of proxy certificates
|
||||
be explicitely allowed. Currently, this can be done using the
|
||||
following methods:
|
||||
For these reasons, OpenSSL requires that the use of proxy certificates be
|
||||
explicitly allowed. Currently, this can be done using the following methods:
|
||||
|
||||
- if the application calls X509_verify_cert() itself, it can do the
|
||||
following prior to that call (ctx is the pointer passed in the call
|
||||
to X509_verify_cert()):
|
||||
- if the application directly calls X509_verify_cert(), it can first call:
|
||||
|
||||
X509_STORE_CTX_set_flags(ctx, X509_V_FLAG_ALLOW_PROXY_CERTS);
|
||||
X509_STORE_CTX_set_flags(ctx, X509_V_FLAG_ALLOW_PROXY_CERTS);
|
||||
|
||||
- in all other cases, proxy certificate validation can be enabled
|
||||
before starting the application by setting the envirnoment variable
|
||||
OPENSSL_ALLOW_PROXY_CERTS with some non-empty value.
|
||||
Where ctx is the pointer which then gets passed to X509_verify_cert().
|
||||
|
||||
There are thoughts to allow proxy certificates with a line in the
|
||||
default openssl.cnf, but that's still in the future.
|
||||
- proxy certificate validation can be enabled before starting the application
|
||||
by setting the environment variable OPENSSL_ALLOW_PROXY_CERTS.
|
||||
|
||||
In the future, it might be possible to enable proxy certificates by editing
|
||||
openssl.cnf.
|
||||
|
||||
|
||||
3. How to create proxy cerificates
|
||||
3. How to create proxy certificates
|
||||
|
||||
It's quite easy to create proxy certificates, by taking advantage of
|
||||
the lack of checks of the 'openssl x509' application (*ahem*). But
|
||||
first, you need to create a configuration section that contains a
|
||||
definition of the proxyCertInfo extension, a little like this:
|
||||
Creating proxy certificates is quite easy, by taking advantage of a lack of
|
||||
checks in the 'openssl x509' application (*ahem*). You must first create a
|
||||
configuration section that contains a definition of the proxyCertInfo extension,
|
||||
for example:
|
||||
|
||||
[ v3_proxy ]
|
||||
# A proxy certificate MUST NEVER be a CA certificate.
|
||||
@@ -77,10 +72,10 @@ definition of the proxyCertInfo extension, a little like this:
|
||||
# Usual authority key ID
|
||||
authorityKeyIdentifier=keyid,issuer:always
|
||||
|
||||
# Now, for the extension that marks this certificate as a proxy one
|
||||
# The extension which marks this certificate as a proxy
|
||||
proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:1,policy:text:AB
|
||||
|
||||
It's also possible to give the proxy extension in a separate section:
|
||||
It's also possible to specify the proxy extension in a separate section:
|
||||
|
||||
proxyCertInfo=critical,@proxy_ext
|
||||
|
||||
@@ -89,96 +84,85 @@ It's also possible to give the proxy extension in a separate section:
|
||||
pathlen=0
|
||||
policy=text:BC
|
||||
|
||||
The policy value has a specific syntax, {syntag}:{string}, where the
|
||||
syntag determines what will be done with the string. The recognised
|
||||
syntags are as follows:
|
||||
The policy value has a specific syntax, {syntag}:{string}, where the syntag
|
||||
determines what will be done with the string. The following syntags are
|
||||
recognised:
|
||||
|
||||
text indicates that the string is simply the bytes, not
|
||||
encoded in any kind of way:
|
||||
text indicates that the string is simply bytes, without any encoding:
|
||||
|
||||
policy=text:r<EFBFBD>ksm<EFBFBD>rg<EFBFBD>s
|
||||
policy=text:räksmörgås
|
||||
|
||||
Previous versions of this design had a specific tag
|
||||
for UTF-8 text. However, since the bytes are copied
|
||||
as-is anyway, there's no need for it. Instead, use
|
||||
the text: tag, like this:
|
||||
Previous versions of this design had a specific tag for UTF-8 text.
|
||||
However, since the bytes are copied as-is anyway, there is no need for
|
||||
such a specific tag.
|
||||
|
||||
policy=text:räksmörgås
|
||||
hex indicates the string is encoded in hex, with colons between each byte
|
||||
(every second hex digit):
|
||||
|
||||
hex indicates the string is encoded in hex, with colons
|
||||
between each byte (every second hex digit):
|
||||
policy=hex:72:E4:6B:73:6D:F6:72:67:E5:73
|
||||
|
||||
policy=hex:72:E4:6B:73:6D:F6:72:67:E5:73
|
||||
Previous versions of this design had a tag to insert a complete DER
|
||||
blob. However, the only legal use for this would be to surround the
|
||||
bytes that would go with the hex: tag with whatever is needed to
|
||||
construct a correct OCTET STRING. The DER tag therefore felt
|
||||
superfluous, and was removed.
|
||||
|
||||
Previous versions of this design had a tag to insert a
|
||||
complete DER blob. However, the only legal use for
|
||||
this would be to surround the bytes that would go with
|
||||
the hex: tag with what's needed to construct a correct
|
||||
OCTET STRING. Since hex: does that, the DER tag felt
|
||||
superfluous, and was therefore removed.
|
||||
|
||||
file indicates that the text of the policy should really be
|
||||
taken from a file. The string is then really a file
|
||||
name. This is useful for policies that are large
|
||||
(more than a few of lines) XML documents, for example.
|
||||
file indicates that the text of the policy should really be taken from a
|
||||
file. The string is then really a file name. This is useful for
|
||||
policies that are large (more than a few lines, e.g. XML documents).
|
||||
|
||||
The 'policy' setting can be split up in multiple lines like this:
|
||||
|
||||
0.policy=This is
|
||||
1.polisy= a multi-
|
||||
1.policy= a multi-
|
||||
2.policy=line policy.
|
||||
|
||||
NOTE: the proxy policy value is the part that determines the rights
|
||||
granted to the process using the proxy certificate. The value is
|
||||
completely dependent on the application reading and interpretting it!
|
||||
NOTE: the proxy policy value is the part which determines the rights granted to
|
||||
the process using the proxy certificate. The value is completely dependent on
|
||||
the application reading and interpreting it!
|
||||
|
||||
Now that you have created an extension section for your proxy
|
||||
certificate, you can now easily create a proxy certificate like this:
|
||||
Now that you have created an extension section for your proxy certificate, you
|
||||
can easily create a proxy certificate by doing:
|
||||
|
||||
openssl req -new -config openssl.cnf \
|
||||
-out proxy.req -keyout proxy.key
|
||||
openssl x509 -req -CAcreateserial -in proxy.req -days 7 \
|
||||
-out proxy.crt -CA user.crt -CAkey user.key \
|
||||
-extfile openssl.cnf -extensions v3_proxy
|
||||
openssl req -new -config openssl.cnf -out proxy.req -keyout proxy.key
|
||||
openssl x509 -req -CAcreateserial -in proxy.req -days 7 -out proxy.crt \
|
||||
-CA user.crt -CAkey user.key -extfile openssl.cnf -extensions v3_proxy
|
||||
|
||||
It's just as easy to create a proxy certificate using another proxy
|
||||
certificate as issuer (note that I'm using a different configuration
|
||||
section for it):
|
||||
You can also create a proxy certificate using another proxy certificate as
|
||||
issuer (note: I'm using a different configuration section for it):
|
||||
|
||||
openssl req -new -config openssl.cnf \
|
||||
-out proxy2.req -keyout proxy2.key
|
||||
openssl x509 -req -CAcreateserial -in proxy2.req -days 7 \
|
||||
-out proxy2.crt -CA proxy.crt -CAkey proxy.key \
|
||||
-extfile openssl.cnf -extensions v3_proxy2
|
||||
openssl req -new -config openssl.cnf -out proxy2.req -keyout proxy2.key
|
||||
openssl x509 -req -CAcreateserial -in proxy2.req -days 7 -out proxy2.crt \
|
||||
-CA proxy.crt -CAkey proxy.key -extfile openssl.cnf -extensions v3_proxy2
|
||||
|
||||
|
||||
4. How to have your application interpret the policy?
|
||||
|
||||
The basic way to interpret proxy policies is to prepare some default
|
||||
rights, then do a check of the proxy certificate against the a chain
|
||||
of proxy certificates, user certificate and CA certificates, and see
|
||||
what rights came out by the end. Sounds easy, huh? It almost is.
|
||||
The basic way to interpret proxy policies is to start with some default rights,
|
||||
then compute the resulting rights by checking the proxy certificate against
|
||||
the chain of proxy certificates, user certificate and CA certificates. You then
|
||||
use the final computed rights. Sounds easy, huh? It almost is.
|
||||
|
||||
The slightly complicated part is how to pass data between your
|
||||
The slightly complicated part is figuring out how to pass data between your
|
||||
application and the certificate validation procedure.
|
||||
|
||||
You need the following ingredients:
|
||||
|
||||
- a callback routing that will be called for every certificate that's
|
||||
validated. It will be called several times for each certificates,
|
||||
so you must be attentive to when it's a good time to do the proxy
|
||||
policy interpretation and check, as well as to fill in the defaults
|
||||
when the EE certificate is checked.
|
||||
- a callback function that will be called for every certificate being
|
||||
validated. The callback be called several times for each certificate,
|
||||
so you must be careful to do the proxy policy interpretation at the right
|
||||
time. You also need to fill in the defaults when the EE certificate is
|
||||
checked.
|
||||
|
||||
- a structure of data that's shared between your application code and
|
||||
the callback.
|
||||
- a data structure that is shared between your application code and the
|
||||
callback.
|
||||
|
||||
- a wrapper function that sets it all up.
|
||||
|
||||
- an ex_data index function that creates an index into the generic
|
||||
ex_data store that's attached to an X509 validation context.
|
||||
- an ex_data index function that creates an index into the generic ex_data
|
||||
store that is attached to an X509 validation context.
|
||||
|
||||
This is some cookbook code for you to fill in:
|
||||
Here is some skeleton code you can fill in:
|
||||
|
||||
/* In this example, I will use a view of granted rights as a bit
|
||||
array, one bit for each possible right. */
|
||||
@@ -210,7 +194,7 @@ This is some cookbook code for you to fill in:
|
||||
static int verify_callback(int ok, X509_STORE_CTX *ctx)
|
||||
{
|
||||
if (ok == 1) /* It's REALLY important you keep the proxy policy
|
||||
check within this secion. It's important to know
|
||||
check within this section. It's important to know
|
||||
that when ok is 1, the certificates are checked
|
||||
from top to bottom. You get the CA root first,
|
||||
followed by the possible chain of intermediate
|
||||
@@ -221,7 +205,7 @@ This is some cookbook code for you to fill in:
|
||||
|
||||
if (xs->ex_flags & EXFLAG_PROXY)
|
||||
{
|
||||
YOUR_RIGHTS *rights =
|
||||
YOUR_RIGHTS *rights =
|
||||
(YOUR_RIGHTS *)X509_STORE_CTX_get_ex_data(ctx,
|
||||
get_proxy_auth_ex_data_idx());
|
||||
PROXY_CERT_INFO_EXTENSION *pci =
|
||||
@@ -250,12 +234,12 @@ This is some cookbook code for you to fill in:
|
||||
bit array and fill it with the rights granted by
|
||||
the current proxy certificate, then use it as a
|
||||
mask on the accumulated rights bit array, and
|
||||
voil<EFBFBD>, you now have a new accumulated rights bit
|
||||
voilà, you now have a new accumulated rights bit
|
||||
array. */
|
||||
{
|
||||
int i;
|
||||
YOUR_RIGHTS tmp_rights;
|
||||
memset(tmp_rights.rights, 0, sizeof(tmp_rights.rights));
|
||||
memset(tmp_rights.rights, 0, sizeof(tmp_rights.rights));
|
||||
|
||||
/* process_rights() is supposed to be a procedure
|
||||
that takes a string and it's length, interprets
|
||||
@@ -276,7 +260,7 @@ This is some cookbook code for you to fill in:
|
||||
{
|
||||
/* We have a EE certificate, let's use it to set default!
|
||||
*/
|
||||
YOUR_RIGHTS *rights =
|
||||
YOUR_RIGHTS *rights =
|
||||
(YOUR_RIGHTS *)X509_STORE_CTX_get_ex_data(ctx,
|
||||
get_proxy_auth_ex_data_idx());
|
||||
|
||||
|
81
doc/apps/c_rehash.pod
Normal file
81
doc/apps/c_rehash.pod
Normal file
@@ -0,0 +1,81 @@
|
||||
=pod
|
||||
|
||||
=for comment
|
||||
Original text by James Westby, contributed under the OpenSSL license.
|
||||
|
||||
=head1 NAME
|
||||
|
||||
c_rehash - Create symbolic links to files named by the hash values
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
B<c_rehash>
|
||||
[ I<directory>...]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<c_rehash> scans directories and calculates a hash value of each C<.pem>
|
||||
file in the specified directory list and creates symbolic links
|
||||
for each file, where the name of the link is the hash value.
|
||||
This utility is useful as many programs that use OpenSSL require
|
||||
directories to be set up like this in order to find certificates.
|
||||
|
||||
If any directories are named on the command line, then those are
|
||||
processed in turn. If not, then the B<SSL_CERT_DIR> environment variable
|
||||
is consulted; this shold be a colon-separated list of directories,
|
||||
like the Unix B<PATH> variable.
|
||||
If that is not set then the default directory (installation-specific
|
||||
but often B</usr/local/ssl/certs>) is processed.
|
||||
|
||||
In order for a directory to be processed, the user must have write
|
||||
permissions on that directory, otherwise it will be skipped.
|
||||
The links created are of the form C<HHHHHHHH.D>, where each B<H>
|
||||
is a hexadecimal character and B<D> is a single decimal digit.
|
||||
When processing a directory, B<c_rehash> will first remove all links
|
||||
that have a name in that syntax. If you have links in that format
|
||||
used for other purposes, they will be removed.
|
||||
Hashes for CRL's look similar except the letter B<r> appears after
|
||||
the period, like this: C<HHHHHHHH.rD>.
|
||||
|
||||
Multiple objects may have the same hash; they will be indicated by
|
||||
incrementing the B<D> value. Duplicates are found by comparing the
|
||||
full SHA-1 fingerprint. A warning will be displayed if a duplicate
|
||||
is found.
|
||||
|
||||
A warning will also be displayed if there are B<.pem> files that
|
||||
cannot be parsed as either a certificate or a CRL.
|
||||
|
||||
The program uses the B<openssl> program to compute the hashes and
|
||||
fingerprints. If not found in the user's B<PATH>, then set the
|
||||
B<OPENSSL> environment variable to the full pathname.
|
||||
Any program can be used, it will be invoked as follows for either
|
||||
a certificate or CRL:
|
||||
|
||||
$OPENSSL x509 -hash -fingerprint -noout -in FFFFFF
|
||||
$OPENSSL crl -hash -fingerprint -noout -in FFFFFF
|
||||
|
||||
where B<FFFFFF> is the filename. It must output the hash of the
|
||||
file on the first line, and the fingerprint on the second,
|
||||
optionally prefixed with some text and an equals sign.
|
||||
|
||||
=head1 ENVIRONMENT
|
||||
|
||||
=over
|
||||
|
||||
=item B<OPENSSL>
|
||||
|
||||
The path to an executable to use to generate hashes and
|
||||
fingerprints (see above).
|
||||
|
||||
=item B<SSL_CERT_DIR>
|
||||
|
||||
Colon separated list of directories to operate on.
|
||||
Ignored if directories are listed on the command line.
|
||||
|
||||
=back
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<openssl(1)|openssl(1)>,
|
||||
L<crl(1)|crl(1)>.
|
||||
L<x509(1)|x509(1)>.
|
@@ -2,16 +2,19 @@
|
||||
|
||||
=head1 NAME
|
||||
|
||||
dgst, md5, md4, md2, sha1, sha, mdc2, ripemd160 - message digests
|
||||
dgst, sha, sha1, mdc2, ripemd160, sha224, sha256, sha384, sha512, md2, md4, md5, dss1 - message digests
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
B<openssl> B<dgst>
|
||||
[B<-md5|-md4|-md2|-sha1|-sha|-mdc2|-ripemd160|-dss1>]
|
||||
[B<-sha|-sha1|-mdc2|-ripemd160|-sha224|-sha256|-sha384|-sha512|-md2|-md4|-md5|-dss1>]
|
||||
[B<-c>]
|
||||
[B<-d>]
|
||||
[B<-hex>]
|
||||
[B<-binary>]
|
||||
[B<-r>]
|
||||
[B<-hmac arg>]
|
||||
[B<-non-fips-allow>]
|
||||
[B<-out filename>]
|
||||
[B<-sign filename>]
|
||||
[B<-keyform arg>]
|
||||
@@ -20,17 +23,19 @@ B<openssl> B<dgst>
|
||||
[B<-prverify filename>]
|
||||
[B<-signature filename>]
|
||||
[B<-hmac key>]
|
||||
[B<-non-fips-allow>]
|
||||
[B<-fips-fingerprint>]
|
||||
[B<file...>]
|
||||
|
||||
[B<md5|md4|md2|sha1|sha|mdc2|ripemd160>]
|
||||
[B<-c>]
|
||||
[B<-d>]
|
||||
[B<file...>]
|
||||
B<openssl>
|
||||
[I<digest>]
|
||||
[B<...>]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
The digest functions output the message digest of a supplied file or files
|
||||
in hexadecimal form. They can also be used for digital signing and verification.
|
||||
in hexadecimal. The digest functions also generate and verify digital
|
||||
signatures using message digests.
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
@@ -48,12 +53,26 @@ print out BIO debugging information.
|
||||
=item B<-hex>
|
||||
|
||||
digest is to be output as a hex dump. This is the default case for a "normal"
|
||||
digest as opposed to a digital signature.
|
||||
digest as opposed to a digital signature. See NOTES below for digital
|
||||
signatures using B<-hex>.
|
||||
|
||||
=item B<-binary>
|
||||
|
||||
output the digest or signature in binary form.
|
||||
|
||||
=item B<-r>
|
||||
|
||||
output the digest in the "coreutils" format used by programs like B<sha1sum>.
|
||||
|
||||
=item B<-hmac arg>
|
||||
|
||||
set the HMAC key to "arg".
|
||||
|
||||
=item B<-non-fips-allow>
|
||||
|
||||
Allow use of non FIPS digest when in FIPS mode. This has no effect when not in
|
||||
FIPS mode.
|
||||
|
||||
=item B<-out filename>
|
||||
|
||||
filename to output to, or standard output by default.
|
||||
@@ -64,8 +83,8 @@ digitally sign the digest using the private key in "filename".
|
||||
|
||||
=item B<-keyform arg>
|
||||
|
||||
Specifies the key format to sign digest with. Only PEM and ENGINE
|
||||
formats are supported by the B<dgst> command.
|
||||
Specifies the key format to sign digest with. The DER, PEM, P12,
|
||||
and ENGINE formats are supported.
|
||||
|
||||
=item B<-engine id>
|
||||
|
||||
@@ -117,7 +136,7 @@ Following options are supported by both by B<HMAC> and B<gost-mac>:
|
||||
=over 8
|
||||
|
||||
=item B<key:string>
|
||||
|
||||
|
||||
Specifies MAC key as alphnumeric string (use if key contain printable
|
||||
characters only). String length must conform to any restrictions of
|
||||
the MAC algorithm for example exactly 32 chars for gost-mac.
|
||||
@@ -138,6 +157,15 @@ Multiple files can be specified separated by a OS-dependent character.
|
||||
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
|
||||
all others.
|
||||
|
||||
=item B<-non-fips-allow>
|
||||
|
||||
enable use of non-FIPS algorithms such as MD5 even in FIPS mode.
|
||||
|
||||
=item B<-fips-fingerprint>
|
||||
|
||||
compute HMAC using a specific key
|
||||
for certain OpenSSL-FIPS operations.
|
||||
|
||||
=item B<file...>
|
||||
|
||||
file or files to digest. If no files are specified then standard input is
|
||||
@@ -145,18 +173,41 @@ used.
|
||||
|
||||
=back
|
||||
|
||||
|
||||
=head1 EXAMPLES
|
||||
|
||||
To create a hex-encoded message digest of a file:
|
||||
openssl dgst -md5 -hex file.txt
|
||||
|
||||
To sign a file using SHA-256 with binary file output:
|
||||
openssl dgst -sha256 -sign privatekey.pem -out signature.sign file.txt
|
||||
|
||||
To verify a signature:
|
||||
openssl dgst -sha256 -verify publickey.pem \
|
||||
-signature signature.sign \
|
||||
file.txt
|
||||
|
||||
|
||||
=head1 NOTES
|
||||
|
||||
The digest of choice for all new applications is SHA1. Other digests are
|
||||
however still widely used.
|
||||
|
||||
If you wish to sign or verify data using the DSA algorithm then the dss1
|
||||
digest must be used.
|
||||
When signing a file, B<dgst> will automatically determine the algorithm
|
||||
(RSA, ECC, etc) to use for signing based on the private key's ASN.1 info.
|
||||
When verifying signatures, it only handles the RSA, DSA, or ECDSA signature
|
||||
itself, not the related data to identify the signer and algorithm used in
|
||||
formats such as x.509, CMS, and S/MIME.
|
||||
|
||||
A source of random numbers is required for certain signing algorithms, in
|
||||
particular DSA.
|
||||
particular ECDSA and DSA.
|
||||
|
||||
The signing and verify options should only be used if a single file is
|
||||
being signed or verified.
|
||||
|
||||
Hex signatures cannot be verified using B<openssl>. Instead, use "xxd -r"
|
||||
or similar program to transform the hex signature into a binary signature
|
||||
prior to verification.
|
||||
|
||||
|
||||
=cut
|
||||
|
@@ -133,6 +133,10 @@ if the B<host> option is present then the OCSP request is sent to the host
|
||||
B<hostname> on port B<port>. B<path> specifies the HTTP path name to use
|
||||
or "/" by default.
|
||||
|
||||
=item B<-timeout seconds>
|
||||
|
||||
connection timeout to the OCSP responder in seconds
|
||||
|
||||
=item B<-CAfile file>, B<-CApath pathname>
|
||||
|
||||
file or pathname containing trusted CA certificates. These are used to verify
|
||||
|
@@ -59,8 +59,8 @@ the accept socket. See L<BIO_s_fd(3)|BIO_s_fd(3)>
|
||||
BIO_set_accept_port() uses the string B<name> to set the accept
|
||||
port. The port is represented as a string of the form "host:port",
|
||||
where "host" is the interface to use and "port" is the port.
|
||||
Either or both values can be "*" which is interpreted as meaning
|
||||
any interface or port respectively. "port" has the same syntax
|
||||
The host can be can be "*" which is interpreted as meaning
|
||||
any interface; "port" has the same syntax
|
||||
as the port specified in BIO_set_conn_port() for connect BIOs,
|
||||
that is it can be a numerical port string or a string to lookup
|
||||
using getservbyname() and a string table.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user