Compare commits
85 Commits
OpenSSL_1_
...
OpenSSL_1_
Author | SHA1 | Date | |
---|---|---|---|
![]() |
88be4ebfbc | ||
![]() |
effa47b80a | ||
![]() |
067400b16e | ||
![]() |
748628ced0 | ||
![]() |
6791060eae | ||
![]() |
502dfeb8de | ||
![]() |
5bbed29518 | ||
![]() |
2f2d33f470 | ||
![]() |
be60a3feaa | ||
![]() |
e504a829a0 | ||
![]() |
0d829f6681 | ||
![]() |
d9540579c5 | ||
![]() |
ecf963b80d | ||
![]() |
7fc6d35be0 | ||
![]() |
e7d2a37158 | ||
![]() |
531c6fc8f3 | ||
![]() |
e011d0a3c4 | ||
![]() |
8d5505d099 | ||
![]() |
d36e0ee460 | ||
![]() |
143619ccf6 | ||
![]() |
9f339d75b5 | ||
![]() |
28583660fb | ||
![]() |
dedfe959dd | ||
![]() |
4d936ace08 | ||
![]() |
89bd25eb26 | ||
![]() |
4a1cf50187 | ||
![]() |
32e12316e5 | ||
![]() |
ad7b24f145 | ||
![]() |
c2770c0e0e | ||
![]() |
371056f2b9 | ||
![]() |
2d613908e8 | ||
![]() |
18fb1fae08 | ||
![]() |
39ef161c72 | ||
![]() |
a7612c5066 | ||
![]() |
6cbae10b5e | ||
![]() |
ebe81134c0 | ||
![]() |
a1d573e282 | ||
![]() |
e959e24b47 | ||
![]() |
3f98d7c0b5 | ||
![]() |
d2f950c984 | ||
![]() |
63e8f16737 | ||
![]() |
9bf5fd894f | ||
![]() |
6296729fae | ||
![]() |
67d216801b | ||
![]() |
0a5575f3f6 | ||
![]() |
418044cbab | ||
![]() |
8c67b13407 | ||
![]() |
2a477ccf0b | ||
![]() |
c34137bef9 | ||
![]() |
914d91c5b3 | ||
![]() |
e733dea3ce | ||
![]() |
78c5d2a9bb | ||
![]() |
3bf4e14cc3 | ||
![]() |
d68d160cb7 | ||
![]() |
202cb42fbb | ||
![]() |
49f6cb968f | ||
![]() |
07e120b7da | ||
![]() |
f3dcae15ac | ||
![]() |
25ec498dc7 | ||
![]() |
9cc42cb091 | ||
![]() |
bcf9cf89e7 | ||
![]() |
f0729fc3e0 | ||
![]() |
8186c00ef3 | ||
![]() |
c0b31ccb87 | ||
![]() |
267c950c5f | ||
![]() |
ce1605b508 | ||
![]() |
66fdb1c0d4 | ||
![]() |
25bfdca16a | ||
![]() |
9c284f9651 | ||
![]() |
6d78c381f6 | ||
![]() |
784e2080df | ||
![]() |
70505bc334 | ||
![]() |
8e8b247341 | ||
![]() |
a8595879ec | ||
![]() |
33a688e806 | ||
![]() |
5c2bfad9b4 | ||
![]() |
250f979237 | ||
![]() |
b527b6e8ff | ||
![]() |
a54ce007e6 | ||
![]() |
4ed1f3490e | ||
![]() |
0a082e9b37 | ||
![]() |
236a99a409 | ||
![]() |
04b4363ec8 | ||
![]() |
37ebc20093 | ||
![]() |
cef781cc87 |
69
CHANGES
69
CHANGES
@@ -2,7 +2,61 @@
|
||||
OpenSSL CHANGES
|
||||
_______________
|
||||
|
||||
Changes between 1.0.0h and 1.0.1 [xx XXX xxxx]
|
||||
Changes between 1.0.1a and 1.0.1b [26 Apr 2012]
|
||||
|
||||
*) OpenSSL 1.0.0 sets SSL_OP_ALL to 0x80000FFFL and OpenSSL 1.0.1 and
|
||||
1.0.1a set SSL_OP_NO_TLSv1_1 to 0x00000400L which would unfortunately
|
||||
mean any application compiled against OpenSSL 1.0.0 headers setting
|
||||
SSL_OP_ALL would also set SSL_OP_NO_TLSv1_1, unintentionally disablng
|
||||
TLS 1.1 also. Fix this by changing the value of SSL_OP_NO_TLSv1_1 to
|
||||
0x10000000L Any application which was previously compiled against
|
||||
OpenSSL 1.0.1 or 1.0.1a headers and which cares about SSL_OP_NO_TLSv1_1
|
||||
will need to be recompiled as a result. Letting be results in
|
||||
inability to disable specifically TLS 1.1 and in client context,
|
||||
in unlike event, limit maximum offered version to TLS 1.0 [see below].
|
||||
[Steve Henson]
|
||||
|
||||
*) In order to ensure interoperabilty SSL_OP_NO_protocolX does not
|
||||
disable just protocol X, but all protocols above X *if* there are
|
||||
protocols *below* X still enabled. In more practical terms it means
|
||||
that if application wants to disable TLS1.0 in favor of TLS1.1 and
|
||||
above, it's not sufficient to pass SSL_OP_NO_TLSv1, one has to pass
|
||||
SSL_OP_NO_TLSv1|SSL_OP_NO_SSLv3|SSL_OP_NO_SSLv2. This applies to
|
||||
client side.
|
||||
[Andy Polyakov]
|
||||
|
||||
Changes between 1.0.1 and 1.0.1a [19 Apr 2012]
|
||||
|
||||
*) Check for potentially exploitable overflows in asn1_d2i_read_bio
|
||||
BUF_mem_grow and BUF_mem_grow_clean. Refuse attempts to shrink buffer
|
||||
in CRYPTO_realloc_clean.
|
||||
|
||||
Thanks to Tavis Ormandy, Google Security Team, for discovering this
|
||||
issue and to Adam Langley <agl@chromium.org> for fixing it.
|
||||
(CVE-2012-2110)
|
||||
[Adam Langley (Google), Tavis Ormandy, Google Security Team]
|
||||
|
||||
*) Don't allow TLS 1.2 SHA-256 ciphersuites in TLS 1.0, 1.1 connections.
|
||||
[Adam Langley]
|
||||
|
||||
*) Workarounds for some broken servers that "hang" if a client hello
|
||||
record length exceeds 255 bytes.
|
||||
|
||||
1. Do not use record version number > TLS 1.0 in initial client
|
||||
hello: some (but not all) hanging servers will now work.
|
||||
2. If we set OPENSSL_MAX_TLS1_2_CIPHER_LENGTH this will truncate
|
||||
the number of ciphers sent in the client hello. This should be
|
||||
set to an even number, such as 50, for example by passing:
|
||||
-DOPENSSL_MAX_TLS1_2_CIPHER_LENGTH=50 to config or Configure.
|
||||
Most broken servers should now work.
|
||||
3. If all else fails setting OPENSSL_NO_TLS1_2_CLIENT will disable
|
||||
TLS 1.2 client support entirely.
|
||||
[Steve Henson]
|
||||
|
||||
*) Fix SEGV in Vector Permutation AES module observed in OpenSSH.
|
||||
[Andy Polyakov]
|
||||
|
||||
Changes between 1.0.0h and 1.0.1 [14 Mar 2012]
|
||||
|
||||
*) Add compatibility with old MDC2 signatures which use an ASN1 OCTET
|
||||
STRING form instead of a DigestInfo.
|
||||
@@ -285,7 +339,18 @@
|
||||
Add command line options to s_client/s_server.
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 1.0.0g and 1.0.0h [xx XXX xxxx]
|
||||
Changes between 1.0.0g and 1.0.0h [12 Mar 2012]
|
||||
|
||||
*) Fix MMA (Bleichenbacher's attack on PKCS #1 v1.5 RSA padding) weakness
|
||||
in CMS and PKCS7 code. When RSA decryption fails use a random key for
|
||||
content decryption and always return the same error. Note: this attack
|
||||
needs on average 2^20 messages so it only affects automated senders. The
|
||||
old behaviour can be reenabled in the CMS code by setting the
|
||||
CMS_DEBUG_DECRYPT flag: this is useful for debugging and testing where
|
||||
an MMA defence is not necessary.
|
||||
Thanks to Ivan Nestlerode <inestlerode@us.ibm.com> for discovering
|
||||
this issue. (CVE-2012-0884)
|
||||
[Steve Henson]
|
||||
|
||||
*) Fix CVE-2011-4619: make sure we really are receiving a
|
||||
client hello before rejecting multiple SGC restarts. Thanks to
|
||||
|
16
Configure
16
Configure
@@ -904,11 +904,11 @@ PROCESS_ARGS:
|
||||
}
|
||||
elsif (/^--with-fipsdir=(.*)$/)
|
||||
{
|
||||
$fipsdir="$1/";
|
||||
$fipsdir="$1";
|
||||
}
|
||||
elsif (/^--with-fipslibdir=(.*)$/)
|
||||
{
|
||||
$fipslibdir="$1/";
|
||||
$fipslibdir="$1";
|
||||
}
|
||||
elsif (/^--with-baseaddr=(.*)$/)
|
||||
{
|
||||
@@ -1095,6 +1095,8 @@ foreach (sort (keys %disabled))
|
||||
else
|
||||
{
|
||||
push @skip, $algo;
|
||||
# fix-up crypto/directory name(s)
|
||||
@skip[$#skip]="whrlpool" if $algo eq "whirlpool";
|
||||
print " (skip dir)";
|
||||
|
||||
$depflags .= " -DOPENSSL_NO_$ALGO";
|
||||
@@ -1391,14 +1393,6 @@ if (!$IsMK1MF)
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined($disabled{"sctp"}))
|
||||
{
|
||||
if ($target =~ /^solaris/)
|
||||
{
|
||||
$cflags = "$cflags -D_XPG4_2 -D__EXTENSIONS__";
|
||||
}
|
||||
}
|
||||
|
||||
$cpuid_obj.=" uplink.o uplink-x86.o" if ($cflags =~ /\-DOPENSSL_USE_APPLINK/);
|
||||
|
||||
#
|
||||
@@ -1521,7 +1515,7 @@ else {
|
||||
$aes_obj=$aes_enc;
|
||||
}
|
||||
$wp_obj="" if ($wp_obj =~ /mmx/ && $processor eq "386");
|
||||
if ($wp_obj =~ /\.o$/)
|
||||
if ($wp_obj =~ /\.o$/ && !$disabled{"whirlpool"})
|
||||
{
|
||||
$cflags.=" -DWHIRLPOOL_ASM";
|
||||
}
|
||||
|
22
FAQ
22
FAQ
@@ -10,6 +10,7 @@ OpenSSL - Frequently Asked Questions
|
||||
* Why aren't tools like 'autoconf' and 'libtool' used?
|
||||
* What is an 'engine' version?
|
||||
* How do I check the authenticity of the OpenSSL distribution?
|
||||
* How does the versioning scheme work?
|
||||
|
||||
[LEGAL] Legal questions
|
||||
|
||||
@@ -82,7 +83,7 @@ OpenSSL - Frequently Asked Questions
|
||||
* Which is the current version of OpenSSL?
|
||||
|
||||
The current version is available from <URL: http://www.openssl.org>.
|
||||
OpenSSL 1.0.0d was released on Feb 8th, 2011.
|
||||
OpenSSL 1.0.1b was released on Apr 26th, 2012.
|
||||
|
||||
In addition to the current stable release, you can also access daily
|
||||
snapshots of the OpenSSL development version at <URL:
|
||||
@@ -108,7 +109,9 @@ In addition, you can read the most current versions at
|
||||
<URL: http://www.openssl.org/docs/>. Note that the online documents refer
|
||||
to the very latest development versions of OpenSSL and may include features
|
||||
not present in released versions. If in doubt refer to the documentation
|
||||
that came with the version of OpenSSL you are using.
|
||||
that came with the version of OpenSSL you are using. The pod format
|
||||
documentation is included in each OpenSSL distribution under the docs
|
||||
directory.
|
||||
|
||||
For information on parts of libcrypto that are not yet documented, you
|
||||
might want to read Ariel Glenn's documentation on SSLeay 0.9, OpenSSL's
|
||||
@@ -173,6 +176,19 @@ just do:
|
||||
|
||||
pgp TARBALL.asc
|
||||
|
||||
* How does the versioning scheme work?
|
||||
|
||||
After the release of OpenSSL 1.0.0 the versioning scheme changed. Letter
|
||||
releases (e.g. 1.0.1a) can only contain bug and security fixes and no
|
||||
new features. Minor releases change the last number (e.g. 1.0.2) and
|
||||
can contain new features that retain binary compatibility. Changes to
|
||||
the middle number are considered major releases and neither source nor
|
||||
binary compatibility is guaranteed.
|
||||
|
||||
Therefore the answer to the common question "when will feature X be
|
||||
backported to OpenSSL 1.0.0/0.9.8?" is "never" but it could appear
|
||||
in the next minor release.
|
||||
|
||||
[LEGAL] =======================================================================
|
||||
|
||||
* Do I need patent licenses to use OpenSSL?
|
||||
@@ -284,7 +300,7 @@ current directory in this case, but this has changed with 0.9.6a.)
|
||||
Check out the CA.pl(1) manual page. This provides a simple wrapper round
|
||||
the 'req', 'verify', 'ca' and 'pkcs12' utilities. For finer control check
|
||||
out the manual pages for the individual utilities and the certificate
|
||||
extensions documentation (currently in doc/openssl.txt).
|
||||
extensions documentation (in ca(1), req(1), x509v3_config(5) )
|
||||
|
||||
|
||||
* Why can't I create certificate requests?
|
||||
|
@@ -198,7 +198,7 @@ CLEARENV= TOP= && unset TOP $${LIB+LIB} $${LIBS+LIBS} \
|
||||
$${EXHEADER+EXHEADER} $${HEADER+HEADER} \
|
||||
$${GENERAL+GENERAL} $${CFLAGS+CFLAGS} \
|
||||
$${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS} \
|
||||
$${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} \
|
||||
$${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} $${SCRIPTS+SCRIPTS} \
|
||||
$${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS} \
|
||||
$${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS}
|
||||
|
||||
@@ -469,9 +469,9 @@ tags:
|
||||
find . -name '[^.]*.[ch]' | xargs etags -a
|
||||
|
||||
errors:
|
||||
$(PERL) util/ck_errf.pl -strict */*.c */*/*.c
|
||||
$(PERL) util/mkerr.pl -recurse -write
|
||||
(cd engines; $(MAKE) PERL=$(PERL) errors)
|
||||
$(PERL) util/ck_errf.pl -strict */*.c */*/*.c
|
||||
|
||||
stacks:
|
||||
$(PERL) util/mkstack.pl -write
|
||||
|
20
NEWS
20
NEWS
@@ -5,7 +5,19 @@
|
||||
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.0g and OpenSSL 1.0.1:
|
||||
Major changes between OpenSSL 1.0.1a and OpenSSL 1.0.1b:
|
||||
|
||||
o Fix compilation error on non-x86 platforms.
|
||||
o Make FIPS capable OpenSSL ciphers work in non-FIPS mode.
|
||||
o Fix SSL_OP_NO_TLSv1_1 clash with SSL_OP_ALL in OpenSSL 1.0.0
|
||||
|
||||
Major changes between OpenSSL 1.0.1 and OpenSSL 1.0.1a:
|
||||
|
||||
o Fix for ASN1 overflow bug CVE-2012-2110
|
||||
o Workarounds for some servers that hang on long client hellos.
|
||||
o Fix SEGV in AES code.
|
||||
|
||||
Major changes between OpenSSL 1.0.0h and OpenSSL 1.0.1:
|
||||
|
||||
o TLS/DTLS heartbeat support.
|
||||
o SCTP support.
|
||||
@@ -18,6 +30,12 @@
|
||||
o Preliminary FIPS capability for unvalidated 2.0 FIPS module.
|
||||
o SRP support.
|
||||
|
||||
Major changes between OpenSSL 1.0.0g and OpenSSL 1.0.0h:
|
||||
|
||||
o Fix for CMS/PKCS#7 MMA CVE-2012-0884
|
||||
o Corrected fix for CVE-2011-4619
|
||||
o Various DTLS fixes.
|
||||
|
||||
Major changes between OpenSSL 1.0.0f and OpenSSL 1.0.0g:
|
||||
|
||||
o Fix for DTLS DoS issue CVE-2012-0050
|
||||
|
2
README
2
README
@@ -1,5 +1,5 @@
|
||||
|
||||
OpenSSL 1.0.1-beta3 23 Feb 2012
|
||||
OpenSSL 1.0.1b 26 Apr 2012
|
||||
|
||||
Copyright (c) 1998-2011 The OpenSSL Project
|
||||
Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
|
||||
|
15
STATUS
15
STATUS
@@ -1,18 +1,25 @@
|
||||
|
||||
OpenSSL STATUS Last modified at
|
||||
______________ $Date: 2012/02/23 22:13:59 $
|
||||
______________ $Date: 2012/04/26 10:40:38 $
|
||||
|
||||
DEVELOPMENT STATE
|
||||
|
||||
o OpenSSL 1.1.0: Under development...
|
||||
o OpenSSL 1.0.1-beta3: Released on February 23rd, 2011
|
||||
o OpenSSL 1.0.1-beta2: Released on January 19th, 2011
|
||||
o OpenSSL 1.0.1-beta1: Released on January 3rd, 2011
|
||||
o OpenSSL 1.0.1b: Released on April 26th, 2012
|
||||
o OpenSSL 1.0.1a: Released on April 19th, 2012
|
||||
o OpenSSL 1.0.1: Released on March 14th, 2012
|
||||
o OpenSSL 1.0.0h: Released on March 12th, 2012
|
||||
o OpenSSL 1.0.0g: Released on January 18th, 2012
|
||||
o OpenSSL 1.0.0f: Released on January 4th, 2012
|
||||
o OpenSSL 1.0.0e: Released on September 6th, 2011
|
||||
o OpenSSL 1.0.0d: Released on February 8nd, 2011
|
||||
o OpenSSL 1.0.0c: Released on December 2nd, 2010
|
||||
o OpenSSL 1.0.0b: Released on November 16th, 2010
|
||||
o OpenSSL 1.0.0a: Released on June 1st, 2010
|
||||
o OpenSSL 1.0.0: Released on March 29th, 2010
|
||||
o OpenSSL 0.9.8u: Released on March 12th, 2012
|
||||
o OpenSSL 0.9.8t: Released on January 18th, 2012
|
||||
o OpenSSL 0.9.8s: Released on January 4th, 2012
|
||||
o OpenSSL 0.9.8r: Released on February 8nd, 2011
|
||||
o OpenSSL 0.9.8q: Released on December 2nd, 2010
|
||||
o OpenSSL 0.9.8p: Released on November 16th, 2010
|
||||
|
45
apps/s_cb.c
45
apps/s_cb.c
@@ -686,6 +686,22 @@ void MS_CALLBACK tlsext_cb(SSL *s, int client_server, int type,
|
||||
extname = "status request";
|
||||
break;
|
||||
|
||||
case TLSEXT_TYPE_user_mapping:
|
||||
extname = "user mapping";
|
||||
break;
|
||||
|
||||
case TLSEXT_TYPE_client_authz:
|
||||
extname = "client authz";
|
||||
break;
|
||||
|
||||
case TLSEXT_TYPE_server_authz:
|
||||
extname = "server authz";
|
||||
break;
|
||||
|
||||
case TLSEXT_TYPE_cert_type:
|
||||
extname = "cert type";
|
||||
break;
|
||||
|
||||
case TLSEXT_TYPE_elliptic_curves:
|
||||
extname = "elliptic curves";
|
||||
break;
|
||||
@@ -694,23 +710,40 @@ void MS_CALLBACK tlsext_cb(SSL *s, int client_server, int type,
|
||||
extname = "EC point formats";
|
||||
break;
|
||||
|
||||
case TLSEXT_TYPE_session_ticket:
|
||||
extname = "server ticket";
|
||||
break;
|
||||
|
||||
case TLSEXT_TYPE_renegotiate:
|
||||
extname = "renegotiate";
|
||||
case TLSEXT_TYPE_srp:
|
||||
extname = "SRP";
|
||||
break;
|
||||
|
||||
case TLSEXT_TYPE_signature_algorithms:
|
||||
extname = "signature algorithms";
|
||||
break;
|
||||
|
||||
case TLSEXT_TYPE_use_srtp:
|
||||
extname = "use SRTP";
|
||||
break;
|
||||
|
||||
case TLSEXT_TYPE_heartbeat:
|
||||
extname = "heartbeat";
|
||||
break;
|
||||
|
||||
case TLSEXT_TYPE_session_ticket:
|
||||
extname = "session ticket";
|
||||
break;
|
||||
|
||||
case TLSEXT_TYPE_renegotiate:
|
||||
extname = "renegotiation info";
|
||||
break;
|
||||
|
||||
#ifdef TLSEXT_TYPE_opaque_prf_input
|
||||
case TLSEXT_TYPE_opaque_prf_input:
|
||||
extname = "opaque PRF input";
|
||||
break;
|
||||
#endif
|
||||
#ifdef TLSEXT_TYPE_next_proto_neg
|
||||
case TLSEXT_TYPE_next_proto_neg:
|
||||
extname = "next protocol";
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
extname = "unknown";
|
||||
|
@@ -622,13 +622,7 @@ int MAIN(int argc, char **argv)
|
||||
SRP_ARG srp_arg = {NULL,NULL,0,0,0,1024};
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
|
||||
meth=SSLv23_client_method();
|
||||
#elif !defined(OPENSSL_NO_SSL3)
|
||||
meth=SSLv3_client_method();
|
||||
#elif !defined(OPENSSL_NO_SSL2)
|
||||
meth=SSLv2_client_method();
|
||||
#endif
|
||||
|
||||
apps_startup();
|
||||
c_Pause=0;
|
||||
@@ -993,14 +987,13 @@ bad:
|
||||
goto end;
|
||||
}
|
||||
psk_identity = "JPAKE";
|
||||
if (cipher)
|
||||
{
|
||||
BIO_printf(bio_err, "JPAKE sets cipher to PSK\n");
|
||||
goto end;
|
||||
}
|
||||
cipher = "PSK";
|
||||
}
|
||||
|
||||
if (cipher)
|
||||
{
|
||||
BIO_printf(bio_err, "JPAKE sets cipher to PSK\n");
|
||||
goto end;
|
||||
}
|
||||
cipher = "PSK";
|
||||
#endif
|
||||
|
||||
OpenSSL_add_ssl_algorithms();
|
||||
|
@@ -969,17 +969,7 @@ int MAIN(int argc, char *argv[])
|
||||
char *srpuserseed = NULL;
|
||||
char *srp_verifier_file = NULL;
|
||||
#endif
|
||||
#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
|
||||
meth=SSLv23_server_method();
|
||||
#elif !defined(OPENSSL_NO_SSL3)
|
||||
meth=SSLv3_server_method();
|
||||
#elif !defined(OPENSSL_NO_SSL2)
|
||||
meth=SSLv2_server_method();
|
||||
#elif !defined(OPENSSL_NO_TLS1)
|
||||
meth=TLSv1_server_method();
|
||||
#else
|
||||
/* #error no SSL version enabled */
|
||||
#endif
|
||||
|
||||
local_argc=argc;
|
||||
local_argv=argv;
|
||||
|
@@ -408,6 +408,7 @@ _armv4_AES_encrypt:
|
||||
.type private_AES_set_encrypt_key,%function
|
||||
.align 5
|
||||
private_AES_set_encrypt_key:
|
||||
_armv4_AES_set_encrypt_key:
|
||||
sub r3,pc,#8 @ AES_set_encrypt_key
|
||||
teq r0,#0
|
||||
moveq r0,#-1
|
||||
@@ -425,7 +426,7 @@ private_AES_set_encrypt_key:
|
||||
bne .Labrt
|
||||
|
||||
.Lok: stmdb sp!,{r4-r12,lr}
|
||||
sub $tbl,r3,#private_AES_set_encrypt_key-AES_Te-1024 @ Te4
|
||||
sub $tbl,r3,#_armv4_AES_set_encrypt_key-AES_Te-1024 @ Te4
|
||||
|
||||
mov $rounds,r0 @ inp
|
||||
mov lr,r1 @ bits
|
||||
@@ -685,7 +686,7 @@ private_AES_set_encrypt_key:
|
||||
.align 5
|
||||
private_AES_set_decrypt_key:
|
||||
str lr,[sp,#-4]! @ push lr
|
||||
bl private_AES_set_encrypt_key
|
||||
bl _armv4_AES_set_encrypt_key
|
||||
teq r0,#0
|
||||
ldrne lr,[sp],#4 @ pop lr
|
||||
bne .Labrt
|
||||
|
@@ -783,6 +783,7 @@ $code.=<<___;
|
||||
.type private_AES_set_encrypt_key,\@function
|
||||
.align 16
|
||||
private_AES_set_encrypt_key:
|
||||
_s390x_AES_set_encrypt_key:
|
||||
lghi $t0,0
|
||||
cl${g}r $inp,$t0
|
||||
je .Lminus1
|
||||
@@ -836,7 +837,8 @@ $code.=<<___ if (!$softonly);
|
||||
je 1f
|
||||
lg %r1,24($inp)
|
||||
stg %r1,24($key)
|
||||
1: st $bits,236($key) # save bits
|
||||
1: st $bits,236($key) # save bits [for debugging purposes]
|
||||
lgr $t0,%r5
|
||||
st %r5,240($key) # save km code
|
||||
lghi %r2,0
|
||||
br %r14
|
||||
@@ -844,7 +846,7 @@ ___
|
||||
$code.=<<___;
|
||||
.align 16
|
||||
.Lekey_internal:
|
||||
stm${g} %r6,%r13,6*$SIZE_T($sp) # all non-volatile regs
|
||||
stm${g} %r4,%r13,4*$SIZE_T($sp) # all non-volatile regs and $key
|
||||
|
||||
larl $tbl,AES_Te+2048
|
||||
|
||||
@@ -904,8 +906,9 @@ $code.=<<___;
|
||||
la $key,16($key) # key+=4
|
||||
la $t3,4($t3) # i++
|
||||
brct $rounds,.L128_loop
|
||||
lghi $t0,10
|
||||
lghi %r2,0
|
||||
lm${g} %r6,%r13,6*$SIZE_T($sp)
|
||||
lm${g} %r4,%r13,4*$SIZE_T($sp)
|
||||
br $ra
|
||||
|
||||
.align 16
|
||||
@@ -952,8 +955,9 @@ $code.=<<___;
|
||||
st $s2,32($key)
|
||||
st $s3,36($key)
|
||||
brct $rounds,.L192_continue
|
||||
lghi $t0,12
|
||||
lghi %r2,0
|
||||
lm${g} %r6,%r13,6*$SIZE_T($sp)
|
||||
lm${g} %r4,%r13,4*$SIZE_T($sp)
|
||||
br $ra
|
||||
|
||||
.align 16
|
||||
@@ -1014,8 +1018,9 @@ $code.=<<___;
|
||||
st $s2,40($key)
|
||||
st $s3,44($key)
|
||||
brct $rounds,.L256_continue
|
||||
lghi $t0,14
|
||||
lghi %r2,0
|
||||
lm${g} %r6,%r13,6*$SIZE_T($sp)
|
||||
lm${g} %r4,%r13,4*$SIZE_T($sp)
|
||||
br $ra
|
||||
|
||||
.align 16
|
||||
@@ -1066,34 +1071,26 @@ $code.=<<___;
|
||||
.type private_AES_set_decrypt_key,\@function
|
||||
.align 16
|
||||
private_AES_set_decrypt_key:
|
||||
st${g} $key,4*$SIZE_T($sp) # I rely on AES_set_encrypt_key to
|
||||
st${g} $ra,14*$SIZE_T($sp) # save non-volatile registers!
|
||||
bras $ra,AES_set_encrypt_key
|
||||
l${g} $key,4*$SIZE_T($sp)
|
||||
#st${g} $key,4*$SIZE_T($sp) # I rely on AES_set_encrypt_key to
|
||||
st${g} $ra,14*$SIZE_T($sp) # save non-volatile registers and $key!
|
||||
bras $ra,_s390x_AES_set_encrypt_key
|
||||
#l${g} $key,4*$SIZE_T($sp)
|
||||
l${g} $ra,14*$SIZE_T($sp)
|
||||
ltgr %r2,%r2
|
||||
bnzr $ra
|
||||
___
|
||||
$code.=<<___ if (!$softonly);
|
||||
l $t0,240($key)
|
||||
#l $t0,240($key)
|
||||
lhi $t1,16
|
||||
cr $t0,$t1
|
||||
jl .Lgo
|
||||
oill $t0,0x80 # set "decrypt" bit
|
||||
st $t0,240($key)
|
||||
br $ra
|
||||
|
||||
.align 16
|
||||
.Ldkey_internal:
|
||||
st${g} $key,4*$SIZE_T($sp)
|
||||
st${g} $ra,14*$SIZE_T($sp)
|
||||
bras $ra,.Lekey_internal
|
||||
l${g} $key,4*$SIZE_T($sp)
|
||||
l${g} $ra,14*$SIZE_T($sp)
|
||||
___
|
||||
$code.=<<___;
|
||||
|
||||
.Lgo: llgf $rounds,240($key)
|
||||
.align 16
|
||||
.Lgo: lgr $rounds,$t0 #llgf $rounds,240($key)
|
||||
la $i1,0($key)
|
||||
sllg $i2,$rounds,4
|
||||
la $i2,0($i2,$key)
|
||||
|
@@ -65,12 +65,12 @@
|
||||
# function is:
|
||||
#
|
||||
# conversion conversion/8x block
|
||||
# Core 2 410 0.37
|
||||
# Nehalem 310 0.35
|
||||
# Atom 570 0.26
|
||||
# Core 2 240 0.22
|
||||
# Nehalem 180 0.20
|
||||
# Atom 430 0.19
|
||||
#
|
||||
# The ratio values mean that 128-byte blocks will be processed
|
||||
# 21-27% slower, 256-byte blocks - 12-16%, 384-byte blocks - 8-11%,
|
||||
# 16-18% slower, 256-byte blocks - 9-10%, 384-byte blocks - 6-7%,
|
||||
# etc. Then keep in mind that input sizes not divisible by 128 are
|
||||
# *effectively* slower, especially shortest ones, e.g. consecutive
|
||||
# 144-byte blocks are processed 44% slower than one would expect,
|
||||
@@ -85,6 +85,7 @@
|
||||
#
|
||||
# Core 2 11.0
|
||||
# Nehalem 9.16
|
||||
# Atom 20.9
|
||||
#
|
||||
# November 2011.
|
||||
#
|
||||
@@ -754,7 +755,7 @@ _bsaes_encrypt8:
|
||||
|
||||
movdqa ($key), @XMM[9] # round 0 key
|
||||
lea 0x10($key), $key
|
||||
movdqa 0x60($const), @XMM[8] # .LM0SR
|
||||
movdqa 0x50($const), @XMM[8] # .LM0SR
|
||||
pxor @XMM[9], @XMM[0] # xor with round0 key
|
||||
pxor @XMM[9], @XMM[1]
|
||||
pshufb @XMM[8], @XMM[0]
|
||||
@@ -905,46 +906,82 @@ $code.=<<___;
|
||||
.type _bsaes_key_convert,\@abi-omnipotent
|
||||
.align 16
|
||||
_bsaes_key_convert:
|
||||
lea .LBS1(%rip), $const
|
||||
lea .Lmasks(%rip), $const
|
||||
movdqu ($inp), %xmm7 # load round 0 key
|
||||
movdqa -0x10($const), %xmm8 # .LBS0
|
||||
movdqa 0x00($const), %xmm9 # .LBS1
|
||||
movdqa 0x10($const), %xmm10 # .LBS2
|
||||
movdqa 0x40($const), %xmm13 # .LM0
|
||||
movdqa 0x60($const), %xmm14 # .LNOT
|
||||
|
||||
movdqu 0x10($inp), %xmm6 # load round 1 key
|
||||
lea 0x10($inp), $inp
|
||||
movdqa 0x00($const), %xmm0 # 0x01...
|
||||
movdqa 0x10($const), %xmm1 # 0x02...
|
||||
movdqa 0x20($const), %xmm2 # 0x04...
|
||||
movdqa 0x30($const), %xmm3 # 0x08...
|
||||
movdqa 0x40($const), %xmm4 # .LM0
|
||||
pcmpeqd %xmm5, %xmm5 # .LNOT
|
||||
|
||||
movdqu ($inp), %xmm6 # load round 1 key
|
||||
movdqa %xmm7, ($out) # save round 0 key
|
||||
lea 0x10($out), $out
|
||||
dec $rounds
|
||||
jmp .Lkey_loop
|
||||
.align 16
|
||||
.Lkey_loop:
|
||||
pshufb %xmm13, %xmm6 # .LM0
|
||||
movdqa %xmm6, %xmm7
|
||||
___
|
||||
&bitslice_key (map("%xmm$_",(0..7, 8..12)));
|
||||
$code.=<<___;
|
||||
pxor %xmm14, %xmm5 # "pnot"
|
||||
pxor %xmm14, %xmm6
|
||||
pxor %xmm14, %xmm0
|
||||
pxor %xmm14, %xmm1
|
||||
lea 0x10($inp), $inp
|
||||
movdqa %xmm0, 0x00($out) # write bit-sliced round key
|
||||
movdqa %xmm1, 0x10($out)
|
||||
movdqa %xmm2, 0x20($out)
|
||||
movdqa %xmm3, 0x30($out)
|
||||
movdqa %xmm4, 0x40($out)
|
||||
movdqa %xmm5, 0x50($out)
|
||||
movdqa %xmm6, 0x60($out)
|
||||
movdqa %xmm7, 0x70($out)
|
||||
pshufb %xmm4, %xmm6 # .LM0
|
||||
|
||||
movdqa %xmm0, %xmm8
|
||||
movdqa %xmm1, %xmm9
|
||||
|
||||
pand %xmm6, %xmm8
|
||||
pand %xmm6, %xmm9
|
||||
movdqa %xmm2, %xmm10
|
||||
pcmpeqb %xmm0, %xmm8
|
||||
psllq \$4, %xmm0 # 0x10...
|
||||
movdqa %xmm3, %xmm11
|
||||
pcmpeqb %xmm1, %xmm9
|
||||
psllq \$4, %xmm1 # 0x20...
|
||||
|
||||
pand %xmm6, %xmm10
|
||||
pand %xmm6, %xmm11
|
||||
movdqa %xmm0, %xmm12
|
||||
pcmpeqb %xmm2, %xmm10
|
||||
psllq \$4, %xmm2 # 0x40...
|
||||
movdqa %xmm1, %xmm13
|
||||
pcmpeqb %xmm3, %xmm11
|
||||
psllq \$4, %xmm3 # 0x80...
|
||||
|
||||
movdqa %xmm2, %xmm14
|
||||
movdqa %xmm3, %xmm15
|
||||
pxor %xmm5, %xmm8 # "pnot"
|
||||
pxor %xmm5, %xmm9
|
||||
|
||||
pand %xmm6, %xmm12
|
||||
pand %xmm6, %xmm13
|
||||
movdqa %xmm8, 0x00($out) # write bit-sliced round key
|
||||
pcmpeqb %xmm0, %xmm12
|
||||
psrlq \$4, %xmm0 # 0x01...
|
||||
movdqa %xmm9, 0x10($out)
|
||||
pcmpeqb %xmm1, %xmm13
|
||||
psrlq \$4, %xmm1 # 0x02...
|
||||
lea 0x10($inp), $inp
|
||||
|
||||
pand %xmm6, %xmm14
|
||||
pand %xmm6, %xmm15
|
||||
movdqa %xmm10, 0x20($out)
|
||||
pcmpeqb %xmm2, %xmm14
|
||||
psrlq \$4, %xmm2 # 0x04...
|
||||
movdqa %xmm11, 0x30($out)
|
||||
pcmpeqb %xmm3, %xmm15
|
||||
psrlq \$4, %xmm3 # 0x08...
|
||||
movdqu ($inp), %xmm6 # load next round key
|
||||
|
||||
pxor %xmm5, %xmm13 # "pnot"
|
||||
pxor %xmm5, %xmm14
|
||||
movdqa %xmm12, 0x40($out)
|
||||
movdqa %xmm13, 0x50($out)
|
||||
movdqa %xmm14, 0x60($out)
|
||||
movdqa %xmm15, 0x70($out)
|
||||
lea 0x80($out),$out
|
||||
movdqu ($inp), %xmm6 # load next round key
|
||||
dec $rounds
|
||||
jnz .Lkey_loop
|
||||
|
||||
movdqa 0x70($const), %xmm7 # .L63
|
||||
movdqa 0x50($const), %xmm7 # .L63
|
||||
#movdqa %xmm6, ($out) # don't save last round key
|
||||
ret
|
||||
.size _bsaes_key_convert,.-_bsaes_key_convert
|
||||
@@ -2800,14 +2837,8 @@ _bsaes_const:
|
||||
.quad 0x0504070600030201, 0x0f0e0d0c0a09080b
|
||||
.LSRM0:
|
||||
.quad 0x0304090e00050a0f, 0x01060b0c0207080d
|
||||
.LM0:
|
||||
.quad 0x02060a0e03070b0f, 0x0004080c0105090d
|
||||
.LM0SR:
|
||||
.quad 0x0a0e02060f03070b, 0x0004080c05090d01
|
||||
.LNOT: # magic constants
|
||||
.quad 0xffffffffffffffff, 0xffffffffffffffff
|
||||
.L63:
|
||||
.quad 0x6363636363636363, 0x6363636363636363
|
||||
.LSWPUP: # byte-swap upper dword
|
||||
.quad 0x0706050403020100, 0x0c0d0e0f0b0a0908
|
||||
.LSWPUPM0SR:
|
||||
@@ -2830,6 +2861,15 @@ _bsaes_const:
|
||||
.quad 0x0000000000000000, 0x0000000800000000
|
||||
.Lxts_magic:
|
||||
.long 0x87,0,1,0
|
||||
.Lmasks:
|
||||
.quad 0x0101010101010101, 0x0101010101010101
|
||||
.quad 0x0202020202020202, 0x0202020202020202
|
||||
.quad 0x0404040404040404, 0x0404040404040404
|
||||
.quad 0x0808080808080808, 0x0808080808080808
|
||||
.LM0:
|
||||
.quad 0x02060a0e03070b0f, 0x0004080c0105090d
|
||||
.L63:
|
||||
.quad 0x6363636363636363, 0x6363636363636363
|
||||
.asciz "Bit-sliced AES for x86_64/SSSE3, Emilia Käsper, Peter Schwabe, Andy Polyakov"
|
||||
.align 64
|
||||
.size _bsaes_const,.-_bsaes_const
|
||||
|
@@ -843,6 +843,8 @@ $k_dsbo=0x2c0; # decryption sbox final output
|
||||
&mov ($out,&wparam(1)); # out
|
||||
&mov ($round,&wparam(2)); # len
|
||||
&mov ($key,&wparam(3)); # key
|
||||
&sub ($round,16);
|
||||
&jc (&label("cbc_abort"));
|
||||
&lea ($base,&DWP(-56,"esp"));
|
||||
&mov ($const,&wparam(4)); # ivp
|
||||
&and ($base,-16);
|
||||
@@ -853,7 +855,6 @@ $k_dsbo=0x2c0; # decryption sbox final output
|
||||
&mov (&DWP(48,"esp"),$base);
|
||||
|
||||
&mov (&DWP(0,"esp"),$out); # save out
|
||||
&sub ($round,16);
|
||||
&mov (&DWP(4,"esp"),$key) # save key
|
||||
&mov (&DWP(8,"esp"),$const); # save ivp
|
||||
&mov ($out,$round); # $out works as $len
|
||||
@@ -896,6 +897,7 @@ $k_dsbo=0x2c0; # decryption sbox final output
|
||||
&mov ($base,&DWP(8,"esp")); # restore ivp
|
||||
&mov ("esp",&DWP(48,"esp"));
|
||||
&movdqu (&QWP(0,$base),"xmm1"); # write IV
|
||||
&set_label("cbc_abort");
|
||||
&function_end("${PREFIX}_cbc_encrypt");
|
||||
|
||||
&asm_finish();
|
||||
|
@@ -263,7 +263,7 @@ _vpaes_decrypt_core:
|
||||
pshufb %xmm2, %xmm4 # 4 = sbou
|
||||
pxor %xmm0, %xmm4 # 4 = sb1u + k
|
||||
movdqa 0x70(%r10), %xmm0 # 0 : sbot
|
||||
movdqa .Lk_sr-.Lk_dsbd(%r11), %xmm2
|
||||
movdqa -0x160(%r11), %xmm2 # .Lk_sr-.Lk_dsbd=-0x160
|
||||
pshufb %xmm3, %xmm0 # 0 = sb1t
|
||||
pxor %xmm4, %xmm0 # 0 = A
|
||||
pshufb %xmm2, %xmm0
|
||||
@@ -869,6 +869,8 @@ ${PREFIX}_cbc_encrypt:
|
||||
___
|
||||
($len,$key)=($key,$len);
|
||||
$code.=<<___;
|
||||
sub \$16,$len
|
||||
jc .Lcbc_abort
|
||||
___
|
||||
$code.=<<___ if ($win64);
|
||||
lea -0xb8(%rsp),%rsp
|
||||
@@ -887,7 +889,6 @@ ___
|
||||
$code.=<<___;
|
||||
movdqu ($ivp),%xmm6 # load IV
|
||||
sub $inp,$out
|
||||
sub \$16,$len
|
||||
call _vpaes_preheat
|
||||
cmp \$0,${enc}d
|
||||
je .Lcbc_dec_loop
|
||||
@@ -932,6 +933,7 @@ $code.=<<___ if ($win64);
|
||||
.Lcbc_epilogue:
|
||||
___
|
||||
$code.=<<___;
|
||||
.Lcbc_abort:
|
||||
ret
|
||||
.size ${PREFIX}_cbc_encrypt,.-${PREFIX}_cbc_encrypt
|
||||
___
|
||||
|
@@ -57,6 +57,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/buffer.h>
|
||||
#include <openssl/asn1_mac.h>
|
||||
@@ -143,17 +144,11 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
BUF_MEM *b;
|
||||
unsigned char *p;
|
||||
int i;
|
||||
int ret=-1;
|
||||
ASN1_const_CTX c;
|
||||
int want=HEADER_SIZE;
|
||||
size_t want=HEADER_SIZE;
|
||||
int eos=0;
|
||||
#if defined(__GNUC__) && defined(__ia64)
|
||||
/* pathetic compiler bug in all known versions as of Nov. 2002 */
|
||||
long off=0;
|
||||
#else
|
||||
int off=0;
|
||||
#endif
|
||||
int len=0;
|
||||
size_t off=0;
|
||||
size_t len=0;
|
||||
|
||||
b=BUF_MEM_new();
|
||||
if (b == NULL)
|
||||
@@ -169,7 +164,7 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
{
|
||||
want-=(len-off);
|
||||
|
||||
if (!BUF_MEM_grow_clean(b,len+want))
|
||||
if (len + want < len || !BUF_MEM_grow_clean(b,len+want))
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
@@ -181,7 +176,14 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
goto err;
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
if (len+i < len)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
len+=i;
|
||||
}
|
||||
}
|
||||
/* else data already loaded */
|
||||
|
||||
@@ -206,6 +208,11 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
{
|
||||
/* no data body so go round again */
|
||||
eos++;
|
||||
if (eos < 0)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_HEADER_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
want=HEADER_SIZE;
|
||||
}
|
||||
else if (eos && (c.slen == 0) && (c.tag == V_ASN1_EOC))
|
||||
@@ -220,10 +227,16 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
else
|
||||
{
|
||||
/* suck in c.slen bytes of data */
|
||||
want=(int)c.slen;
|
||||
want=c.slen;
|
||||
if (want > (len-off))
|
||||
{
|
||||
want-=(len-off);
|
||||
if (want > INT_MAX /* BIO_read takes an int length */ ||
|
||||
len+want < len)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
if (!BUF_MEM_grow_clean(b,len+want))
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE);
|
||||
@@ -238,11 +251,18 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
ASN1_R_NOT_ENOUGH_DATA);
|
||||
goto err;
|
||||
}
|
||||
/* This can't overflow because
|
||||
* |len+want| didn't overflow. */
|
||||
len+=i;
|
||||
want -= i;
|
||||
want-=i;
|
||||
}
|
||||
}
|
||||
off+=(int)c.slen;
|
||||
if (off + c.slen < off)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
off+=c.slen;
|
||||
if (eos <= 0)
|
||||
{
|
||||
break;
|
||||
@@ -252,9 +272,15 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
}
|
||||
}
|
||||
|
||||
if (off > INT_MAX)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
|
||||
*pb = b;
|
||||
return off;
|
||||
err:
|
||||
if (b != NULL) BUF_MEM_free(b);
|
||||
return(ret);
|
||||
return -1;
|
||||
}
|
||||
|
@@ -377,8 +377,12 @@ static int asn1_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags,
|
||||
BIO *tmpbio;
|
||||
const ASN1_AUX *aux = it->funcs;
|
||||
ASN1_STREAM_ARG sarg;
|
||||
int rv = 1;
|
||||
|
||||
if (!(flags & SMIME_DETACHED))
|
||||
/* If data is not deteched or resigning then the output BIO is
|
||||
* already set up to finalise when it is written through.
|
||||
*/
|
||||
if (!(flags & SMIME_DETACHED) || (flags & PKCS7_REUSE_DIGEST))
|
||||
{
|
||||
SMIME_crlf_copy(data, out, flags);
|
||||
return 1;
|
||||
@@ -405,7 +409,7 @@ static int asn1_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags,
|
||||
|
||||
/* Finalize structure */
|
||||
if (aux->asn1_cb(ASN1_OP_DETACHED_POST, &val, it, &sarg) <= 0)
|
||||
return 0;
|
||||
rv = 0;
|
||||
|
||||
/* Now remove any digests prepended to the BIO */
|
||||
|
||||
@@ -416,7 +420,7 @@ static int asn1_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags,
|
||||
sarg.ndef_bio = tmpbio;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
@@ -486,9 +490,9 @@ ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it)
|
||||
|
||||
if(strcmp(hdr->value, "application/x-pkcs7-signature") &&
|
||||
strcmp(hdr->value, "application/pkcs7-signature")) {
|
||||
sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
|
||||
ASN1err(ASN1_F_SMIME_READ_ASN1,ASN1_R_SIG_INVALID_MIME_TYPE);
|
||||
ERR_add_error_data(2, "type: ", hdr->value);
|
||||
sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
|
||||
sk_BIO_pop_free(parts, BIO_vfree);
|
||||
return NULL;
|
||||
}
|
||||
@@ -858,9 +862,8 @@ static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value)
|
||||
static int mime_hdr_cmp(const MIME_HEADER * const *a,
|
||||
const MIME_HEADER * const *b)
|
||||
{
|
||||
if ((*a)->name == NULL || (*b)->name == NULL)
|
||||
return (*a)->name - (*b)->name < 0 ? -1 :
|
||||
(*a)->name - (*b)->name > 0 ? 1 : 0;
|
||||
if (!(*a)->name || !(*b)->name)
|
||||
return !!(*a)->name - !!(*b)->name;
|
||||
|
||||
return(strcmp((*a)->name, (*b)->name));
|
||||
}
|
||||
@@ -868,6 +871,8 @@ static int mime_hdr_cmp(const MIME_HEADER * const *a,
|
||||
static int mime_param_cmp(const MIME_PARAM * const *a,
|
||||
const MIME_PARAM * const *b)
|
||||
{
|
||||
if (!(*a)->param_name || !(*b)->param_name)
|
||||
return !!(*a)->param_name - !!(*b)->param_name;
|
||||
return(strcmp((*a)->param_name, (*b)->param_name));
|
||||
}
|
||||
|
||||
|
@@ -446,11 +446,11 @@ static int asn1_print_fsname(BIO *out, int indent,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int asn1_print_boolean_ctx(BIO *out, const int bool,
|
||||
static int asn1_print_boolean_ctx(BIO *out, int boolval,
|
||||
const ASN1_PCTX *pctx)
|
||||
{
|
||||
const char *str;
|
||||
switch (bool)
|
||||
switch (boolval)
|
||||
{
|
||||
case -1:
|
||||
str = "BOOL ABSENT";
|
||||
@@ -574,10 +574,10 @@ static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
|
||||
{
|
||||
case V_ASN1_BOOLEAN:
|
||||
{
|
||||
int bool = *(int *)fld;
|
||||
if (bool == -1)
|
||||
bool = it->size;
|
||||
ret = asn1_print_boolean_ctx(out, bool, pctx);
|
||||
int boolval = *(int *)fld;
|
||||
if (boolval == -1)
|
||||
boolval = it->size;
|
||||
ret = asn1_print_boolean_ctx(out, boolval, pctx);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@@ -399,8 +399,7 @@ static int asn1_string_canon(ASN1_STRING *out, ASN1_STRING *in)
|
||||
/* If type not in bitmask just copy string across */
|
||||
if (!(ASN1_tag2bit(in->type) & ASN1_MASK_CANON))
|
||||
{
|
||||
out->type = in->type;
|
||||
if (!ASN1_STRING_set(out, in->data, in->length))
|
||||
if (!ASN1_STRING_copy(out, in))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
@@ -171,7 +171,16 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)
|
||||
goto error;
|
||||
}
|
||||
|
||||
key->pkey = ret;
|
||||
/* Check to see if another thread set key->pkey first */
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);
|
||||
if (key->pkey)
|
||||
{
|
||||
EVP_PKEY_free(ret);
|
||||
ret = key->pkey;
|
||||
}
|
||||
else
|
||||
key->pkey = ret;
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY);
|
||||
CRYPTO_add(&ret->references, 1, CRYPTO_LOCK_EVP_PKEY);
|
||||
|
||||
return ret;
|
||||
|
@@ -960,7 +960,6 @@ int BIO_set_tcp_ndelay(int s, int on)
|
||||
#endif
|
||||
return(ret == 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
int BIO_socket_nbio(int s, int mode)
|
||||
{
|
||||
@@ -973,3 +972,4 @@ int BIO_socket_nbio(int s, int mode)
|
||||
#endif
|
||||
return(ret == 0);
|
||||
}
|
||||
#endif
|
||||
|
@@ -69,7 +69,11 @@
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
#ifndef OPENSSL_NO_SCTP
|
||||
#include <stdint.h>
|
||||
# ifndef OPENSSL_SYS_VMS
|
||||
# include <stdint.h>
|
||||
# else
|
||||
# include <inttypes.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -153,6 +157,7 @@ extern "C" {
|
||||
/* #endif */
|
||||
|
||||
#define BIO_CTRL_DGRAM_QUERY_MTU 40 /* as kernel for current MTU */
|
||||
#define BIO_CTRL_DGRAM_GET_FALLBACK_MTU 47
|
||||
#define BIO_CTRL_DGRAM_GET_MTU 41 /* get cached value for MTU */
|
||||
#define BIO_CTRL_DGRAM_SET_MTU 42 /* set cached value for
|
||||
* MTU. want to use this
|
||||
|
@@ -521,40 +521,40 @@ void BIO_free_all(BIO *bio)
|
||||
|
||||
BIO *BIO_dup_chain(BIO *in)
|
||||
{
|
||||
BIO *ret=NULL,*eoc=NULL,*bio,*new;
|
||||
BIO *ret=NULL,*eoc=NULL,*bio,*new_bio;
|
||||
|
||||
for (bio=in; bio != NULL; bio=bio->next_bio)
|
||||
{
|
||||
if ((new=BIO_new(bio->method)) == NULL) goto err;
|
||||
new->callback=bio->callback;
|
||||
new->cb_arg=bio->cb_arg;
|
||||
new->init=bio->init;
|
||||
new->shutdown=bio->shutdown;
|
||||
new->flags=bio->flags;
|
||||
if ((new_bio=BIO_new(bio->method)) == NULL) goto err;
|
||||
new_bio->callback=bio->callback;
|
||||
new_bio->cb_arg=bio->cb_arg;
|
||||
new_bio->init=bio->init;
|
||||
new_bio->shutdown=bio->shutdown;
|
||||
new_bio->flags=bio->flags;
|
||||
|
||||
/* This will let SSL_s_sock() work with stdin/stdout */
|
||||
new->num=bio->num;
|
||||
new_bio->num=bio->num;
|
||||
|
||||
if (!BIO_dup_state(bio,(char *)new))
|
||||
if (!BIO_dup_state(bio,(char *)new_bio))
|
||||
{
|
||||
BIO_free(new);
|
||||
BIO_free(new_bio);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* copy app data */
|
||||
if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_BIO, &new->ex_data,
|
||||
if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_BIO, &new_bio->ex_data,
|
||||
&bio->ex_data))
|
||||
goto err;
|
||||
|
||||
if (ret == NULL)
|
||||
{
|
||||
eoc=new;
|
||||
eoc=new_bio;
|
||||
ret=eoc;
|
||||
}
|
||||
else
|
||||
{
|
||||
BIO_push(eoc,new);
|
||||
eoc=new;
|
||||
BIO_push(eoc,new_bio);
|
||||
eoc=new_bio;
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
|
@@ -616,6 +616,27 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
ret = 0;
|
||||
#endif
|
||||
break;
|
||||
case BIO_CTRL_DGRAM_GET_FALLBACK_MTU:
|
||||
switch (data->peer.sa.sa_family)
|
||||
{
|
||||
case AF_INET:
|
||||
ret = 576 - 20 - 8;
|
||||
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;
|
||||
else
|
||||
#endif
|
||||
ret = 1280 - 40 - 8;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
ret = 576 - 20 - 8;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_DGRAM_GET_MTU:
|
||||
return data->mtu;
|
||||
break;
|
||||
|
@@ -628,8 +628,11 @@ int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
|
||||
}
|
||||
if (ubits==vbits)
|
||||
{
|
||||
bn_correct_top(u);
|
||||
ubits = BN_num_bits(u);
|
||||
BN_ULONG ul;
|
||||
int utop = (ubits-1)/BN_BITS2;
|
||||
|
||||
while ((ul=udp[utop])==0 && utop) utop--;
|
||||
ubits = utop*BN_BITS2 + BN_num_bits_word(ul);
|
||||
}
|
||||
}
|
||||
bn_correct_top(b);
|
||||
|
@@ -60,6 +60,11 @@
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/buffer.h>
|
||||
|
||||
/* LIMIT_BEFORE_EXPANSION is the maximum n such that (n+3)/3*4 < 2**31. That
|
||||
* function is applied in several functions in this file and this limit ensures
|
||||
* that the result fits in an int. */
|
||||
#define LIMIT_BEFORE_EXPANSION 0x5ffffffc
|
||||
|
||||
BUF_MEM *BUF_MEM_new(void)
|
||||
{
|
||||
BUF_MEM *ret;
|
||||
@@ -105,6 +110,12 @@ int BUF_MEM_grow(BUF_MEM *str, size_t len)
|
||||
str->length=len;
|
||||
return(len);
|
||||
}
|
||||
/* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */
|
||||
if (len > LIMIT_BEFORE_EXPANSION)
|
||||
{
|
||||
BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
n=(len+3)/3*4;
|
||||
if (str->data == NULL)
|
||||
ret=OPENSSL_malloc(n);
|
||||
@@ -142,6 +153,12 @@ int BUF_MEM_grow_clean(BUF_MEM *str, size_t len)
|
||||
str->length=len;
|
||||
return(len);
|
||||
}
|
||||
/* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */
|
||||
if (len > LIMIT_BEFORE_EXPANSION)
|
||||
{
|
||||
BUFerr(BUF_F_BUF_MEM_GROW_CLEAN,ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
n=(len+3)/3*4;
|
||||
if (str->data == NULL)
|
||||
ret=OPENSSL_malloc(n);
|
||||
|
@@ -179,6 +179,8 @@ int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen,
|
||||
return 0;
|
||||
if (!EVP_EncryptInit_ex(&ctx->cctx, NULL, NULL, NULL, zero_iv))
|
||||
return 0;
|
||||
memset(ctx->tbl, 0, EVP_CIPHER_CTX_block_size(&ctx->cctx));
|
||||
ctx->nlast_block = 0;
|
||||
return 1;
|
||||
}
|
||||
/* Initialiase context */
|
||||
|
@@ -111,6 +111,7 @@ DECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo)
|
||||
#define CMS_PARTIAL 0x4000
|
||||
#define CMS_REUSE_DIGEST 0x8000
|
||||
#define CMS_USE_KEYID 0x10000
|
||||
#define CMS_DEBUG_DECRYPT 0x20000
|
||||
|
||||
const ASN1_OBJECT *CMS_get0_type(CMS_ContentInfo *cms);
|
||||
|
||||
|
@@ -73,6 +73,8 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec)
|
||||
const EVP_CIPHER *ciph;
|
||||
X509_ALGOR *calg = ec->contentEncryptionAlgorithm;
|
||||
unsigned char iv[EVP_MAX_IV_LENGTH], *piv = NULL;
|
||||
unsigned char *tkey = NULL;
|
||||
size_t tkeylen;
|
||||
|
||||
int ok = 0;
|
||||
|
||||
@@ -137,32 +139,57 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec)
|
||||
CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
if (enc && !ec->key)
|
||||
/* Generate random session key */
|
||||
if (!enc || !ec->key)
|
||||
{
|
||||
/* Generate random key */
|
||||
if (!ec->keylen)
|
||||
ec->keylen = EVP_CIPHER_CTX_key_length(ctx);
|
||||
ec->key = OPENSSL_malloc(ec->keylen);
|
||||
if (!ec->key)
|
||||
tkeylen = EVP_CIPHER_CTX_key_length(ctx);
|
||||
tkey = OPENSSL_malloc(tkeylen);
|
||||
if (!tkey)
|
||||
{
|
||||
CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
if (EVP_CIPHER_CTX_rand_key(ctx, ec->key) <= 0)
|
||||
if (EVP_CIPHER_CTX_rand_key(ctx, tkey) <= 0)
|
||||
goto err;
|
||||
keep_key = 1;
|
||||
}
|
||||
else if (ec->keylen != (unsigned int)EVP_CIPHER_CTX_key_length(ctx))
|
||||
|
||||
if (!ec->key)
|
||||
{
|
||||
ec->key = tkey;
|
||||
ec->keylen = tkeylen;
|
||||
tkey = NULL;
|
||||
if (enc)
|
||||
keep_key = 1;
|
||||
else
|
||||
ERR_clear_error();
|
||||
|
||||
}
|
||||
|
||||
if (ec->keylen != tkeylen)
|
||||
{
|
||||
/* If necessary set key length */
|
||||
if (EVP_CIPHER_CTX_set_key_length(ctx, ec->keylen) <= 0)
|
||||
{
|
||||
CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO,
|
||||
CMS_R_INVALID_KEY_LENGTH);
|
||||
goto err;
|
||||
/* Only reveal failure if debugging so we don't
|
||||
* leak information which may be useful in MMA.
|
||||
*/
|
||||
if (ec->debug)
|
||||
{
|
||||
CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO,
|
||||
CMS_R_INVALID_KEY_LENGTH);
|
||||
goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Use random key */
|
||||
OPENSSL_cleanse(ec->key, ec->keylen);
|
||||
OPENSSL_free(ec->key);
|
||||
ec->key = tkey;
|
||||
ec->keylen = tkeylen;
|
||||
tkey = NULL;
|
||||
ERR_clear_error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,6 +225,11 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec)
|
||||
OPENSSL_free(ec->key);
|
||||
ec->key = NULL;
|
||||
}
|
||||
if (tkey)
|
||||
{
|
||||
OPENSSL_cleanse(tkey, tkeylen);
|
||||
OPENSSL_free(tkey);
|
||||
}
|
||||
if (ok)
|
||||
return b;
|
||||
BIO_free(b);
|
||||
|
@@ -370,6 +370,8 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms,
|
||||
unsigned char *ek = NULL;
|
||||
size_t eklen;
|
||||
int ret = 0;
|
||||
CMS_EncryptedContentInfo *ec;
|
||||
ec = cms->d.envelopedData->encryptedContentInfo;
|
||||
|
||||
if (ktri->pkey == NULL)
|
||||
{
|
||||
@@ -416,8 +418,14 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms,
|
||||
|
||||
ret = 1;
|
||||
|
||||
cms->d.envelopedData->encryptedContentInfo->key = ek;
|
||||
cms->d.envelopedData->encryptedContentInfo->keylen = eklen;
|
||||
if (ec->key)
|
||||
{
|
||||
OPENSSL_cleanse(ec->key, ec->keylen);
|
||||
OPENSSL_free(ec->key);
|
||||
}
|
||||
|
||||
ec->key = ek;
|
||||
ec->keylen = eklen;
|
||||
|
||||
err:
|
||||
if (pctx)
|
||||
|
@@ -175,6 +175,8 @@ struct CMS_EncryptedContentInfo_st
|
||||
const EVP_CIPHER *cipher;
|
||||
unsigned char *key;
|
||||
size_t keylen;
|
||||
/* Set to 1 if we are debugging decrypt and don't fake keys for MMA */
|
||||
int debug;
|
||||
};
|
||||
|
||||
struct CMS_RecipientInfo_st
|
||||
|
@@ -611,7 +611,10 @@ int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert)
|
||||
STACK_OF(CMS_RecipientInfo) *ris;
|
||||
CMS_RecipientInfo *ri;
|
||||
int i, r;
|
||||
int debug = 0;
|
||||
ris = CMS_get0_RecipientInfos(cms);
|
||||
if (ris)
|
||||
debug = cms->d.envelopedData->encryptedContentInfo->debug;
|
||||
for (i = 0; i < sk_CMS_RecipientInfo_num(ris); i++)
|
||||
{
|
||||
ri = sk_CMS_RecipientInfo_value(ris, i);
|
||||
@@ -625,17 +628,38 @@ int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert)
|
||||
CMS_RecipientInfo_set0_pkey(ri, pk);
|
||||
r = CMS_RecipientInfo_decrypt(cms, ri);
|
||||
CMS_RecipientInfo_set0_pkey(ri, NULL);
|
||||
if (r > 0)
|
||||
return 1;
|
||||
if (cert)
|
||||
{
|
||||
/* If not debugging clear any error and
|
||||
* return success to avoid leaking of
|
||||
* information useful to MMA
|
||||
*/
|
||||
if (!debug)
|
||||
{
|
||||
ERR_clear_error();
|
||||
return 1;
|
||||
}
|
||||
if (r > 0)
|
||||
return 1;
|
||||
CMSerr(CMS_F_CMS_DECRYPT_SET1_PKEY,
|
||||
CMS_R_DECRYPT_ERROR);
|
||||
return 0;
|
||||
}
|
||||
ERR_clear_error();
|
||||
/* If no cert and not debugging don't leave loop
|
||||
* after first successful decrypt. Always attempt
|
||||
* to decrypt all recipients to avoid leaking timing
|
||||
* of a successful decrypt.
|
||||
*/
|
||||
else if (r > 0 && debug)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/* If no cert and not debugging always return success */
|
||||
if (!cert && !debug)
|
||||
{
|
||||
ERR_clear_error();
|
||||
return 1;
|
||||
}
|
||||
|
||||
CMSerr(CMS_F_CMS_DECRYPT_SET1_PKEY, CMS_R_NO_MATCHING_RECIPIENT);
|
||||
return 0;
|
||||
@@ -718,9 +742,14 @@ int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert,
|
||||
}
|
||||
if (!dcont && !check_content(cms))
|
||||
return 0;
|
||||
if (flags & CMS_DEBUG_DECRYPT)
|
||||
cms->d.envelopedData->encryptedContentInfo->debug = 1;
|
||||
else
|
||||
cms->d.envelopedData->encryptedContentInfo->debug = 0;
|
||||
if (!pk && !cert && !dcont && !out)
|
||||
return 1;
|
||||
if (pk && !CMS_decrypt_set1_pkey(cms, pk, cert))
|
||||
return 0;
|
||||
|
||||
cont = CMS_dataInit(cms, dcont);
|
||||
if (!cont)
|
||||
return 0;
|
||||
|
@@ -28,7 +28,12 @@
|
||||
#include <openssl/opensslconf.h>
|
||||
#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
|
||||
|
||||
#ifndef OPENSSL_SYS_VMS
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <openssl/err.h>
|
||||
#include "ec_lcl.h"
|
||||
|
@@ -29,7 +29,12 @@
|
||||
#include <openssl/opensslconf.h>
|
||||
#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
|
||||
|
||||
#ifndef OPENSSL_SYS_VMS
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <openssl/err.h>
|
||||
#include "ec_lcl.h"
|
||||
|
@@ -29,7 +29,12 @@
|
||||
#include <openssl/opensslconf.h>
|
||||
#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
|
||||
|
||||
#ifndef OPENSSL_SYS_VMS
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <openssl/err.h>
|
||||
#include "ec_lcl.h"
|
||||
|
@@ -79,8 +79,6 @@ struct dev_crypto_state {
|
||||
unsigned char digest_res[HASH_MAX_LEN];
|
||||
char *mac_data;
|
||||
int mac_len;
|
||||
|
||||
int copy;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -200,6 +198,7 @@ get_dev_crypto(void)
|
||||
|
||||
if ((fd = open_dev_crypto()) == -1)
|
||||
return (-1);
|
||||
#ifndef CRIOGET_NOT_NEEDED
|
||||
if (ioctl(fd, CRIOGET, &retfd) == -1)
|
||||
return (-1);
|
||||
|
||||
@@ -208,9 +207,19 @@ get_dev_crypto(void)
|
||||
close(retfd);
|
||||
return (-1);
|
||||
}
|
||||
#else
|
||||
retfd = fd;
|
||||
#endif
|
||||
return (retfd);
|
||||
}
|
||||
|
||||
static void put_dev_crypto(int fd)
|
||||
{
|
||||
#ifndef CRIOGET_NOT_NEEDED
|
||||
close(fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Caching version for asym operations */
|
||||
static int
|
||||
get_asym_dev_crypto(void)
|
||||
@@ -252,7 +261,7 @@ get_cryptodev_ciphers(const int **cnids)
|
||||
ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
|
||||
nids[count++] = ciphers[i].nid;
|
||||
}
|
||||
close(fd);
|
||||
put_dev_crypto(fd);
|
||||
|
||||
if (count > 0)
|
||||
*cnids = nids;
|
||||
@@ -291,7 +300,7 @@ get_cryptodev_digests(const int **cnids)
|
||||
ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
|
||||
nids[count++] = digests[i].nid;
|
||||
}
|
||||
close(fd);
|
||||
put_dev_crypto(fd);
|
||||
|
||||
if (count > 0)
|
||||
*cnids = nids;
|
||||
@@ -436,7 +445,7 @@ cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
sess->cipher = cipher;
|
||||
|
||||
if (ioctl(state->d_fd, CIOCGSESSION, sess) == -1) {
|
||||
close(state->d_fd);
|
||||
put_dev_crypto(state->d_fd);
|
||||
state->d_fd = -1;
|
||||
return (0);
|
||||
}
|
||||
@@ -473,7 +482,7 @@ cryptodev_cleanup(EVP_CIPHER_CTX *ctx)
|
||||
} else {
|
||||
ret = 1;
|
||||
}
|
||||
close(state->d_fd);
|
||||
put_dev_crypto(state->d_fd);
|
||||
state->d_fd = -1;
|
||||
|
||||
return (ret);
|
||||
@@ -686,7 +695,7 @@ static int cryptodev_digest_init(EVP_MD_CTX *ctx)
|
||||
sess->mac = digest;
|
||||
|
||||
if (ioctl(state->d_fd, CIOCGSESSION, sess) < 0) {
|
||||
close(state->d_fd);
|
||||
put_dev_crypto(state->d_fd);
|
||||
state->d_fd = -1;
|
||||
printf("cryptodev_digest_init: Open session failed\n");
|
||||
return (0);
|
||||
@@ -758,14 +767,12 @@ static int cryptodev_digest_final(EVP_MD_CTX *ctx, unsigned char *md)
|
||||
if (! (ctx->flags & EVP_MD_CTX_FLAG_ONESHOT) ) {
|
||||
/* if application doesn't support one buffer */
|
||||
memset(&cryp, 0, sizeof(cryp));
|
||||
|
||||
cryp.ses = sess->ses;
|
||||
cryp.flags = 0;
|
||||
cryp.len = state->mac_len;
|
||||
cryp.src = state->mac_data;
|
||||
cryp.dst = NULL;
|
||||
cryp.mac = (caddr_t)md;
|
||||
|
||||
if (ioctl(state->d_fd, CIOCCRYPT, &cryp) < 0) {
|
||||
printf("cryptodev_digest_final: digest failed\n");
|
||||
return (0);
|
||||
@@ -786,6 +793,9 @@ static int cryptodev_digest_cleanup(EVP_MD_CTX *ctx)
|
||||
struct dev_crypto_state *state = ctx->md_data;
|
||||
struct session_op *sess = &state->d_sess;
|
||||
|
||||
if (state == NULL)
|
||||
return 0;
|
||||
|
||||
if (state->d_fd < 0) {
|
||||
printf("cryptodev_digest_cleanup: illegal input\n");
|
||||
return (0);
|
||||
@@ -797,16 +807,13 @@ static int cryptodev_digest_cleanup(EVP_MD_CTX *ctx)
|
||||
state->mac_len = 0;
|
||||
}
|
||||
|
||||
if (state->copy)
|
||||
return 1;
|
||||
|
||||
if (ioctl(state->d_fd, CIOCFSESSION, &sess->ses) < 0) {
|
||||
printf("cryptodev_digest_cleanup: failed to close session\n");
|
||||
ret = 0;
|
||||
} else {
|
||||
ret = 1;
|
||||
}
|
||||
close(state->d_fd);
|
||||
put_dev_crypto(state->d_fd);
|
||||
state->d_fd = -1;
|
||||
|
||||
return (ret);
|
||||
@@ -816,15 +823,39 @@ static int cryptodev_digest_copy(EVP_MD_CTX *to,const EVP_MD_CTX *from)
|
||||
{
|
||||
struct dev_crypto_state *fstate = from->md_data;
|
||||
struct dev_crypto_state *dstate = to->md_data;
|
||||
struct session_op *sess;
|
||||
int digest;
|
||||
|
||||
memcpy(dstate, fstate, sizeof(struct dev_crypto_state));
|
||||
if (dstate == NULL || fstate == NULL)
|
||||
return 1;
|
||||
|
||||
if (fstate->mac_len != 0) {
|
||||
dstate->mac_data = OPENSSL_malloc(fstate->mac_len);
|
||||
memcpy(dstate->mac_data, fstate->mac_data, fstate->mac_len);
|
||||
memcpy(dstate, fstate, sizeof(struct dev_crypto_state));
|
||||
|
||||
sess = &dstate->d_sess;
|
||||
|
||||
digest = digest_nid_to_cryptodev(to->digest->type);
|
||||
|
||||
sess->mackey = dstate->dummy_mac_key;
|
||||
sess->mackeylen = digest_key_length(to->digest->type);
|
||||
sess->mac = digest;
|
||||
|
||||
dstate->d_fd = get_dev_crypto();
|
||||
|
||||
if (ioctl(dstate->d_fd, CIOCGSESSION, sess) < 0) {
|
||||
put_dev_crypto(dstate->d_fd);
|
||||
dstate->d_fd = -1;
|
||||
printf("cryptodev_digest_init: Open session failed\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
dstate->copy = 1;
|
||||
if (fstate->mac_len != 0) {
|
||||
if (fstate->mac_data != NULL)
|
||||
{
|
||||
dstate->mac_data = OPENSSL_malloc(fstate->mac_len);
|
||||
memcpy(dstate->mac_data, fstate->mac_data, fstate->mac_len);
|
||||
dstate->mac_len = fstate->mac_len;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1347,11 +1378,11 @@ ENGINE_load_cryptodev(void)
|
||||
* find out what asymmetric crypto algorithms we support
|
||||
*/
|
||||
if (ioctl(fd, CIOCASYMFEAT, &cryptodev_asymfeat) == -1) {
|
||||
close(fd);
|
||||
put_dev_crypto(fd);
|
||||
ENGINE_free(engine);
|
||||
return;
|
||||
}
|
||||
close(fd);
|
||||
put_dev_crypto(fd);
|
||||
|
||||
if (!ENGINE_set_id(engine, "cryptodev") ||
|
||||
!ENGINE_set_name(engine, "BSD cryptodev engine") ||
|
||||
|
@@ -211,6 +211,7 @@ e_aes_cbc_hmac_sha1.o: ../../include/openssl/safestack.h
|
||||
e_aes_cbc_hmac_sha1.o: ../../include/openssl/sha.h
|
||||
e_aes_cbc_hmac_sha1.o: ../../include/openssl/stack.h
|
||||
e_aes_cbc_hmac_sha1.o: ../../include/openssl/symhacks.h e_aes_cbc_hmac_sha1.c
|
||||
e_aes_cbc_hmac_sha1.o: evp_locl.h
|
||||
e_bf.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
e_bf.o: ../../include/openssl/blowfish.h ../../include/openssl/buffer.h
|
||||
e_bf.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
|
@@ -83,6 +83,8 @@ typedef struct
|
||||
} aux;
|
||||
} EVP_AES_HMAC_SHA1;
|
||||
|
||||
#define NO_PAYLOAD_LENGTH ((size_t)-1)
|
||||
|
||||
#if defined(AES_ASM) && ( \
|
||||
defined(__x86_64) || defined(__x86_64__) || \
|
||||
defined(_M_AMD64) || defined(_M_X64) || \
|
||||
@@ -124,7 +126,7 @@ static int aesni_cbc_hmac_sha1_init_key(EVP_CIPHER_CTX *ctx,
|
||||
key->tail = key->head;
|
||||
key->md = key->head;
|
||||
|
||||
key->payload_length = 0;
|
||||
key->payload_length = NO_PAYLOAD_LENGTH;
|
||||
|
||||
return ret<0?0:1;
|
||||
}
|
||||
@@ -185,7 +187,7 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
if (len%AES_BLOCK_SIZE) return 0;
|
||||
|
||||
if (ctx->encrypt) {
|
||||
if (plen==0)
|
||||
if (plen==NO_PAYLOAD_LENGTH)
|
||||
plen = len;
|
||||
else if (len!=((plen+SHA_DIGEST_LENGTH+AES_BLOCK_SIZE)&-AES_BLOCK_SIZE))
|
||||
return 0;
|
||||
@@ -271,7 +273,7 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
}
|
||||
}
|
||||
|
||||
key->payload_length = 0;
|
||||
key->payload_length = NO_PAYLOAD_LENGTH;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@@ -75,6 +75,8 @@ typedef struct
|
||||
size_t payload_length;
|
||||
} EVP_RC4_HMAC_MD5;
|
||||
|
||||
#define NO_PAYLOAD_LENGTH ((size_t)-1)
|
||||
|
||||
void rc4_md5_enc (RC4_KEY *key, const void *in0, void *out,
|
||||
MD5_CTX *ctx,const void *inp,size_t blocks);
|
||||
|
||||
@@ -93,7 +95,7 @@ static int rc4_hmac_md5_init_key(EVP_CIPHER_CTX *ctx,
|
||||
key->tail = key->head;
|
||||
key->md = key->head;
|
||||
|
||||
key->payload_length = 0;
|
||||
key->payload_length = NO_PAYLOAD_LENGTH;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -120,18 +122,20 @@ static int rc4_hmac_md5_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
md5_off = MD5_CBLOCK-key->md.num,
|
||||
blocks;
|
||||
unsigned int l;
|
||||
extern unsigned int OPENSSL_ia32cap_P[];
|
||||
#endif
|
||||
size_t plen = key->payload_length;
|
||||
|
||||
if (plen && len!=(plen+MD5_DIGEST_LENGTH)) return 0;
|
||||
if (plen!=NO_PAYLOAD_LENGTH && len!=(plen+MD5_DIGEST_LENGTH)) return 0;
|
||||
|
||||
if (ctx->encrypt) {
|
||||
if (plen==0) plen = len;
|
||||
if (plen==NO_PAYLOAD_LENGTH) plen = len;
|
||||
#if defined(STITCHED_CALL)
|
||||
/* cipher has to "fall behind" */
|
||||
if (rc4_off>md5_off) md5_off+=MD5_CBLOCK;
|
||||
|
||||
if (plen>md5_off && (blocks=(plen-md5_off)/MD5_CBLOCK)) {
|
||||
if (plen>md5_off && (blocks=(plen-md5_off)/MD5_CBLOCK) &&
|
||||
(OPENSSL_ia32cap_P[0]&(1<<20))==0) {
|
||||
MD5_Update(&key->md,in,md5_off);
|
||||
RC4(&key->ks,rc4_off,in,out);
|
||||
|
||||
@@ -171,7 +175,8 @@ static int rc4_hmac_md5_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
if (md5_off>rc4_off) rc4_off += 2*MD5_CBLOCK;
|
||||
else rc4_off += MD5_CBLOCK;
|
||||
|
||||
if (len>rc4_off && (blocks=(len-rc4_off)/MD5_CBLOCK)) {
|
||||
if (len>rc4_off && (blocks=(len-rc4_off)/MD5_CBLOCK) &&
|
||||
(OPENSSL_ia32cap_P[0]&(1<<20))==0) {
|
||||
RC4(&key->ks,rc4_off,in,out);
|
||||
MD5_Update(&key->md,out,md5_off);
|
||||
|
||||
@@ -191,7 +196,7 @@ static int rc4_hmac_md5_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
#endif
|
||||
/* decrypt HMAC at once */
|
||||
RC4(&key->ks,len-rc4_off,in+rc4_off,out+rc4_off);
|
||||
if (plen) { /* "TLS" mode of operation */
|
||||
if (plen!=NO_PAYLOAD_LENGTH) { /* "TLS" mode of operation */
|
||||
MD5_Update(&key->md,out+md5_off,plen-md5_off);
|
||||
|
||||
/* calculate HMAC and verify it */
|
||||
@@ -207,7 +212,7 @@ static int rc4_hmac_md5_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
}
|
||||
}
|
||||
|
||||
key->payload_length = 0;
|
||||
key->payload_length = NO_PAYLOAD_LENGTH;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@@ -170,8 +170,9 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
|
||||
#endif
|
||||
|
||||
#ifdef OPENSSL_FIPS
|
||||
return FIPS_cipherinit(ctx, cipher, key, iv, enc);
|
||||
#else
|
||||
if (FIPS_mode())
|
||||
return FIPS_cipherinit(ctx, cipher, key, iv, enc);
|
||||
#endif
|
||||
ctx->cipher=cipher;
|
||||
if (ctx->cipher->ctx_size)
|
||||
{
|
||||
@@ -196,7 +197,6 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if(!ctx->cipher)
|
||||
{
|
||||
@@ -207,8 +207,9 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
|
||||
skip_to_init:
|
||||
#endif
|
||||
#ifdef OPENSSL_FIPS
|
||||
return FIPS_cipherinit(ctx, cipher, key, iv, enc);
|
||||
#else
|
||||
if (FIPS_mode())
|
||||
return FIPS_cipherinit(ctx, cipher, key, iv, enc);
|
||||
#endif
|
||||
/* we assume block size is a power of 2 in *cryptUpdate */
|
||||
OPENSSL_assert(ctx->cipher->block_size == 1
|
||||
|| ctx->cipher->block_size == 8
|
||||
@@ -255,7 +256,6 @@ skip_to_init:
|
||||
ctx->final_used=0;
|
||||
ctx->block_mask=ctx->cipher->block_size-1;
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
|
||||
|
@@ -138,5 +138,6 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
|
||||
OPENSSL_cleanse(iv, EVP_MAX_IV_LENGTH);
|
||||
rv = 1;
|
||||
err:
|
||||
EVP_MD_CTX_cleanup(&ctx);
|
||||
return rv;
|
||||
}
|
||||
|
@@ -363,6 +363,10 @@ void *CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file,
|
||||
|
||||
if (num <= 0) return NULL;
|
||||
|
||||
/* We don't support shrinking the buffer. Note the memcpy that copies
|
||||
* |old_len| bytes to the new buffer, below. */
|
||||
if (num < old_len) return NULL;
|
||||
|
||||
if (realloc_debug_func != NULL)
|
||||
realloc_debug_func(str, NULL, num, file, line, 0);
|
||||
ret=malloc_ex_func(num,file,line);
|
||||
|
@@ -138,7 +138,7 @@ $code.=<<___ if(!$softonly);
|
||||
.align 32
|
||||
.Lsoft_ghash:
|
||||
___
|
||||
$cdoe.=<<___ if ($flavour =~ /3[12]/);
|
||||
$code.=<<___ if ($flavour =~ /3[12]/);
|
||||
llgfr $len,$len
|
||||
___
|
||||
$code.=<<___;
|
||||
|
@@ -45,7 +45,7 @@ typedef unsigned char u8;
|
||||
# define BSWAP4(x) ({ u32 ret=(x); \
|
||||
asm ("bswapl %0" \
|
||||
: "+r"(ret)); ret; })
|
||||
# elif (defined(__i386) || defined(__i386__))
|
||||
# elif (defined(__i386) || defined(__i386__)) && !defined(I386_ONLY)
|
||||
# define BSWAP8(x) ({ u32 lo=(u64)(x)>>32,hi=(x); \
|
||||
asm ("bswapl %0; bswapl %1" \
|
||||
: "+r"(hi),"+r"(lo)); \
|
||||
|
@@ -64,6 +64,7 @@
|
||||
|
||||
int FIPS_mode(void)
|
||||
{
|
||||
OPENSSL_init();
|
||||
#ifdef OPENSSL_FIPS
|
||||
return FIPS_module_mode();
|
||||
#else
|
||||
|
@@ -25,11 +25,11 @@
|
||||
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
|
||||
* major minor fix final patch/beta)
|
||||
*/
|
||||
#define OPENSSL_VERSION_NUMBER 0x10001003L
|
||||
#define OPENSSL_VERSION_NUMBER 0x1000102fL
|
||||
#ifdef OPENSSL_FIPS
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1-fips-beta3 23 Feb 2012"
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1b-fips 26 Apr 2012"
|
||||
#else
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1-beta3 23 Feb 2012"
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1b 26 Apr 2012"
|
||||
#endif
|
||||
#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
|
||||
|
||||
|
@@ -62,12 +62,8 @@ my $flavour = shift;
|
||||
my $output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
|
||||
{ my ($stddev,$stdino,@junk)=stat(STDOUT);
|
||||
my ($outdev,$outino,@junk)=stat($output);
|
||||
|
||||
open STDOUT,">$output" || die "can't open $output: $!"
|
||||
if ($stddev!=$outdev || $stdino!=$outino);
|
||||
}
|
||||
open STDOUT,">$output" || die "can't open $output: $!"
|
||||
if (defined($output));
|
||||
|
||||
my $gas=1; $gas=0 if ($output =~ /\.asm$/);
|
||||
my $elf=1; $elf=0 if (!$gas);
|
||||
|
@@ -16,7 +16,7 @@ sub ::generic
|
||||
# fix hexadecimal constants
|
||||
for (@arg) { s/(?<![\w\$\.])0x([0-9a-f]+)/0$1h/oi; }
|
||||
|
||||
if ($opcode =~ /lea/ && @arg[1] =~ s/.*PTR\s+([^\[]+)$/$1/) # no []
|
||||
if ($opcode =~ /lea/ && @arg[1] =~ s/.*PTR\s+(\(.*\))$/OFFSET $1/) # no []
|
||||
{ $opcode="mov"; }
|
||||
elsif ($opcode !~ /movq/)
|
||||
{ # fix xmm references
|
||||
|
@@ -167,7 +167,7 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
|
||||
if (cert && *cert)
|
||||
X509_free(*cert);
|
||||
if (x)
|
||||
X509_free(*cert);
|
||||
X509_free(x);
|
||||
if (ocerts)
|
||||
sk_X509_pop_free(ocerts, X509_free);
|
||||
return 0;
|
||||
|
@@ -204,11 +204,11 @@ static int pkcs7_decrypt_rinfo(unsigned char **pek, int *peklen,
|
||||
unsigned char *ek = NULL;
|
||||
size_t eklen;
|
||||
|
||||
int ret = 0;
|
||||
int ret = -1;
|
||||
|
||||
pctx = EVP_PKEY_CTX_new(pkey, NULL);
|
||||
if (!pctx)
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
if (EVP_PKEY_decrypt_init(pctx) <= 0)
|
||||
goto err;
|
||||
@@ -235,12 +235,19 @@ static int pkcs7_decrypt_rinfo(unsigned char **pek, int *peklen,
|
||||
if (EVP_PKEY_decrypt(pctx, ek, &eklen,
|
||||
ri->enc_key->data, ri->enc_key->length) <= 0)
|
||||
{
|
||||
ret = 0;
|
||||
PKCS7err(PKCS7_F_PKCS7_DECRYPT_RINFO, ERR_R_EVP_LIB);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
if (*pek)
|
||||
{
|
||||
OPENSSL_cleanse(*pek, *peklen);
|
||||
OPENSSL_free(*pek);
|
||||
}
|
||||
|
||||
*pek = ek;
|
||||
*peklen = eklen;
|
||||
|
||||
@@ -423,6 +430,8 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
STACK_OF(X509_ALGOR) *md_sk=NULL;
|
||||
STACK_OF(PKCS7_RECIP_INFO) *rsk=NULL;
|
||||
PKCS7_RECIP_INFO *ri=NULL;
|
||||
unsigned char *ek = NULL, *tkey = NULL;
|
||||
int eklen = 0, tkeylen = 0;
|
||||
|
||||
i=OBJ_obj2nid(p7->type);
|
||||
p7->state=PKCS7_S_HEADER;
|
||||
@@ -500,8 +509,6 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
int max;
|
||||
X509_OBJECT ret;
|
||||
#endif
|
||||
unsigned char *ek = NULL;
|
||||
int eklen;
|
||||
|
||||
if ((etmp=BIO_new(BIO_f_cipher())) == NULL)
|
||||
{
|
||||
@@ -534,29 +541,28 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
}
|
||||
|
||||
/* If we haven't got a certificate try each ri in turn */
|
||||
|
||||
if (pcert == NULL)
|
||||
{
|
||||
/* Always attempt to decrypt all rinfo even
|
||||
* after sucess as a defence against MMA timing
|
||||
* attacks.
|
||||
*/
|
||||
for (i=0; i<sk_PKCS7_RECIP_INFO_num(rsk); i++)
|
||||
{
|
||||
ri=sk_PKCS7_RECIP_INFO_value(rsk,i);
|
||||
|
||||
if (pkcs7_decrypt_rinfo(&ek, &eklen,
|
||||
ri, pkey) > 0)
|
||||
break;
|
||||
ri, pkey) < 0)
|
||||
goto err;
|
||||
ERR_clear_error();
|
||||
ri = NULL;
|
||||
}
|
||||
if (ri == NULL)
|
||||
{
|
||||
PKCS7err(PKCS7_F_PKCS7_DATADECODE,
|
||||
PKCS7_R_NO_RECIPIENT_MATCHES_KEY);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pkcs7_decrypt_rinfo(&ek, &eklen, ri, pkey) <= 0)
|
||||
/* Only exit on fatal errors, not decrypt failure */
|
||||
if (pkcs7_decrypt_rinfo(&ek, &eklen, ri, pkey) < 0)
|
||||
goto err;
|
||||
ERR_clear_error();
|
||||
}
|
||||
|
||||
evp_ctx=NULL;
|
||||
@@ -565,6 +571,19 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
goto err;
|
||||
if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0)
|
||||
goto err;
|
||||
/* Generate random key as MMA defence */
|
||||
tkeylen = EVP_CIPHER_CTX_key_length(evp_ctx);
|
||||
tkey = OPENSSL_malloc(tkeylen);
|
||||
if (!tkey)
|
||||
goto err;
|
||||
if (EVP_CIPHER_CTX_rand_key(evp_ctx, tkey) <= 0)
|
||||
goto err;
|
||||
if (ek == NULL)
|
||||
{
|
||||
ek = tkey;
|
||||
eklen = tkeylen;
|
||||
tkey = NULL;
|
||||
}
|
||||
|
||||
if (eklen != EVP_CIPHER_CTX_key_length(evp_ctx)) {
|
||||
/* Some S/MIME clients don't use the same key
|
||||
@@ -573,11 +592,16 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
*/
|
||||
if(!EVP_CIPHER_CTX_set_key_length(evp_ctx, eklen))
|
||||
{
|
||||
PKCS7err(PKCS7_F_PKCS7_DATADECODE,
|
||||
PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH);
|
||||
goto err;
|
||||
/* Use random key as MMA defence */
|
||||
OPENSSL_cleanse(ek, eklen);
|
||||
OPENSSL_free(ek);
|
||||
ek = tkey;
|
||||
eklen = tkeylen;
|
||||
tkey = NULL;
|
||||
}
|
||||
}
|
||||
/* Clear errors so we don't leak information useful in MMA */
|
||||
ERR_clear_error();
|
||||
if (EVP_CipherInit_ex(evp_ctx,NULL,NULL,ek,NULL,0) <= 0)
|
||||
goto err;
|
||||
|
||||
@@ -585,6 +609,13 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
{
|
||||
OPENSSL_cleanse(ek,eklen);
|
||||
OPENSSL_free(ek);
|
||||
ek = NULL;
|
||||
}
|
||||
if (tkey)
|
||||
{
|
||||
OPENSSL_cleanse(tkey,tkeylen);
|
||||
OPENSSL_free(tkey);
|
||||
tkey = NULL;
|
||||
}
|
||||
|
||||
if (out == NULL)
|
||||
@@ -627,6 +658,16 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
if (0)
|
||||
{
|
||||
err:
|
||||
if (ek)
|
||||
{
|
||||
OPENSSL_cleanse(ek,eklen);
|
||||
OPENSSL_free(ek);
|
||||
}
|
||||
if (tkey)
|
||||
{
|
||||
OPENSSL_cleanse(tkey,tkeylen);
|
||||
OPENSSL_free(tkey);
|
||||
}
|
||||
if (out != NULL) BIO_free_all(out);
|
||||
if (btmp != NULL) BIO_free_all(btmp);
|
||||
if (etmp != NULL) BIO_free_all(etmp);
|
||||
|
@@ -573,15 +573,34 @@ int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags)
|
||||
return 0;
|
||||
}
|
||||
ret = SMIME_text(bread, data);
|
||||
if (ret > 0 && BIO_method_type(tmpmem) == BIO_TYPE_CIPHER)
|
||||
{
|
||||
if (!BIO_get_cipher_status(tmpmem))
|
||||
ret = 0;
|
||||
}
|
||||
BIO_free_all(bread);
|
||||
return ret;
|
||||
} else {
|
||||
for(;;) {
|
||||
i = BIO_read(tmpmem, buf, sizeof(buf));
|
||||
if(i <= 0) break;
|
||||
BIO_write(data, buf, i);
|
||||
if(i <= 0)
|
||||
{
|
||||
ret = 1;
|
||||
if (BIO_method_type(tmpmem) == BIO_TYPE_CIPHER)
|
||||
{
|
||||
if (!BIO_get_cipher_status(tmpmem))
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
if (BIO_write(data, buf, i) != i)
|
||||
{
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
BIO_free_all(tmpmem);
|
||||
return 1;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@@ -171,10 +171,10 @@ $ikey="%r7";
|
||||
$iinp="%r8";
|
||||
|
||||
$code.=<<___;
|
||||
.globl RC4_set_key
|
||||
.type RC4_set_key,\@function
|
||||
.globl private_RC4_set_key
|
||||
.type private_RC4_set_key,\@function
|
||||
.align 64
|
||||
RC4_set_key:
|
||||
private_RC4_set_key:
|
||||
stm${g} %r6,%r8,6*$SIZE_T($sp)
|
||||
lhi $cnt,256
|
||||
la $idx,0(%r0)
|
||||
@@ -210,7 +210,7 @@ RC4_set_key:
|
||||
.Ldone:
|
||||
lm${g} %r6,%r8,6*$SIZE_T($sp)
|
||||
br $rp
|
||||
.size RC4_set_key,.-RC4_set_key
|
||||
.size private_RC4_set_key,.-private_RC4_set_key
|
||||
|
||||
___
|
||||
}
|
||||
|
@@ -225,11 +225,12 @@ rsa_pk1.o: ../../include/openssl/symhacks.h ../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
|
||||
rsa_pmeth.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
rsa_pmeth.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
rsa_pmeth.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
|
||||
rsa_pmeth.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
|
||||
rsa_pmeth.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
rsa_pmeth.o: ../../include/openssl/cms.h ../../include/openssl/crypto.h
|
||||
rsa_pmeth.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
rsa_pmeth.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
|
||||
rsa_pmeth.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
rsa_pmeth.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
rsa_pmeth.o: ../../include/openssl/objects.h
|
||||
rsa_pmeth.o: ../../include/openssl/opensslconf.h
|
||||
rsa_pmeth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
rsa_pmeth.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
|
||||
|
@@ -36,6 +36,10 @@
|
||||
#include <openssl/seed.h>
|
||||
#include "seed_locl.h"
|
||||
|
||||
#ifdef SS /* can get defined on Solaris by inclusion of <stdlib.h> */
|
||||
#undef SS
|
||||
#endif
|
||||
|
||||
static const seed_word SS[4][256] = { {
|
||||
0x2989a1a8, 0x05858184, 0x16c6d2d4, 0x13c3d3d0, 0x14445054, 0x1d0d111c, 0x2c8ca0ac, 0x25052124,
|
||||
0x1d4d515c, 0x03434340, 0x18081018, 0x1e0e121c, 0x11415150, 0x3cccf0fc, 0x0acac2c8, 0x23436360,
|
||||
|
@@ -87,7 +87,7 @@ void X509_LOOKUP_free(X509_LOOKUP *ctx)
|
||||
if (ctx == NULL) return;
|
||||
if ( (ctx->method != NULL) &&
|
||||
(ctx->method->free != NULL))
|
||||
ctx->method->free(ctx);
|
||||
(*ctx->method->free)(ctx);
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
|
||||
|
@@ -19,9 +19,9 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
|
||||
&pushf ();
|
||||
&pop ("eax");
|
||||
&xor ("ecx","eax");
|
||||
&bt ("ecx",21);
|
||||
&jnc (&label("generic"));
|
||||
&xor ("eax","eax");
|
||||
&bt ("ecx",21);
|
||||
&jnc (&label("nocpuid"));
|
||||
&cpuid ();
|
||||
&mov ("edi","eax"); # max value for standard query level
|
||||
|
||||
@@ -136,6 +136,7 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
|
||||
&set_label("done");
|
||||
&mov ("eax","esi");
|
||||
&mov ("edx","ebp");
|
||||
&set_label("nocpuid");
|
||||
&function_end("OPENSSL_ia32_cpuid");
|
||||
|
||||
&external_label("OPENSSL_ia32cap_P");
|
||||
|
@@ -6,7 +6,8 @@ EVP_MD_CTX_init, EVP_MD_CTX_create, EVP_DigestInit_ex, EVP_DigestUpdate,
|
||||
EVP_DigestFinal_ex, EVP_MD_CTX_cleanup, EVP_MD_CTX_destroy, EVP_MAX_MD_SIZE,
|
||||
EVP_MD_CTX_copy_ex, EVP_MD_CTX_copy, EVP_MD_type, EVP_MD_pkey_type, EVP_MD_size,
|
||||
EVP_MD_block_size, EVP_MD_CTX_md, EVP_MD_CTX_size, EVP_MD_CTX_block_size, EVP_MD_CTX_type,
|
||||
EVP_md_null, EVP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_dss, EVP_dss1, EVP_mdc2,
|
||||
EVP_md_null, EVP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_sha224, EVP_sha256,
|
||||
EVP_sha384, EVP_sha512, EVP_dss, EVP_dss1, EVP_mdc2,
|
||||
EVP_ripemd160, EVP_get_digestbyname, EVP_get_digestbynid, EVP_get_digestbyobj -
|
||||
EVP digest routines
|
||||
|
||||
@@ -33,16 +34,15 @@ EVP digest routines
|
||||
|
||||
int EVP_MD_CTX_copy(EVP_MD_CTX *out,EVP_MD_CTX *in);
|
||||
|
||||
#define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */
|
||||
#define EVP_MAX_MD_SIZE 64 /* SHA512 */
|
||||
|
||||
int EVP_MD_type(const EVP_MD *md);
|
||||
int EVP_MD_pkey_type(const EVP_MD *md);
|
||||
int EVP_MD_size(const EVP_MD *md);
|
||||
int EVP_MD_block_size(const EVP_MD *md);
|
||||
|
||||
#define EVP_MD_type(e) ((e)->type)
|
||||
#define EVP_MD_pkey_type(e) ((e)->pkey_type)
|
||||
#define EVP_MD_size(e) ((e)->md_size)
|
||||
#define EVP_MD_block_size(e) ((e)->block_size)
|
||||
|
||||
#define EVP_MD_CTX_md(e) (e)->digest)
|
||||
#define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest)
|
||||
const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx);
|
||||
#define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e))
|
||||
#define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest)
|
||||
#define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest)
|
||||
|
||||
@@ -56,6 +56,11 @@ EVP digest routines
|
||||
const EVP_MD *EVP_mdc2(void);
|
||||
const EVP_MD *EVP_ripemd160(void);
|
||||
|
||||
const EVP_MD *EVP_sha224(void);
|
||||
const EVP_MD *EVP_sha256(void);
|
||||
const EVP_MD *EVP_sha384(void);
|
||||
const EVP_MD *EVP_sha512(void);
|
||||
|
||||
const EVP_MD *EVP_get_digestbyname(const char *name);
|
||||
#define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
|
||||
#define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))
|
||||
@@ -124,12 +129,14 @@ B<EVP_MD_CTX>.
|
||||
|
||||
EVP_MD_pkey_type() returns the NID of the public key signing algorithm associated
|
||||
with this digest. For example EVP_sha1() is associated with RSA so this will
|
||||
return B<NID_sha1WithRSAEncryption>. This "link" between digests and signature
|
||||
algorithms may not be retained in future versions of OpenSSL.
|
||||
return B<NID_sha1WithRSAEncryption>. Since digests and signature algorithms
|
||||
are no longer linked this function is only retained for compatibility
|
||||
reasons.
|
||||
|
||||
EVP_md2(), EVP_md5(), EVP_sha(), EVP_sha1(), EVP_mdc2() and EVP_ripemd160()
|
||||
return B<EVP_MD> structures for the MD2, MD5, SHA, SHA1, MDC2 and RIPEMD160 digest
|
||||
algorithms respectively. The associated signature algorithm is RSA in each case.
|
||||
EVP_md2(), EVP_md5(), EVP_sha(), EVP_sha1(), EVP_sha224(), EVP_sha256(),
|
||||
EVP_sha384(), EVP_sha512(), EVP_mdc2() and EVP_ripemd160() return B<EVP_MD>
|
||||
structures for the MD2, MD5, SHA, SHA1, SHA224, SHA256, SHA384, SHA512, MDC2
|
||||
and RIPEMD160 digest algorithms respectively.
|
||||
|
||||
EVP_dss() and EVP_dss1() return B<EVP_MD> structures for SHA and SHA1 digest
|
||||
algorithms but using DSS (DSA) for the signature algorithm. Note: there is
|
||||
@@ -171,8 +178,8 @@ The B<EVP> interface to message digests should almost always be used in
|
||||
preference to the low level interfaces. This is because the code then becomes
|
||||
transparent to the digest used and much more flexible.
|
||||
|
||||
SHA1 is the digest of choice for new applications. The other digest algorithms
|
||||
are still in common use.
|
||||
New applications should use the SHA2 digest algorithms such as SHA256.
|
||||
The other digest algorithms are still in common use.
|
||||
|
||||
For most applications the B<impl> parameter to EVP_DigestInit_ex() will be
|
||||
set to NULL to use the default digest implementation.
|
||||
@@ -187,6 +194,19 @@ implementations of digests to be specified.
|
||||
In OpenSSL 0.9.7 and later if digest contexts are not cleaned up after use
|
||||
memory leaks will occur.
|
||||
|
||||
Stack allocation of EVP_MD_CTX structures is common, for example:
|
||||
|
||||
EVP_MD_CTX mctx;
|
||||
EVP_MD_CTX_init(&mctx);
|
||||
|
||||
This will cause binary compatibility issues if the size of EVP_MD_CTX
|
||||
structure changes (this will only happen with a major release of OpenSSL).
|
||||
Applications wishing to avoid this should use EVP_MD_CTX_create() instead:
|
||||
|
||||
EVP_MD_CTX *mctx;
|
||||
mctx = EVP_MD_CTX_create();
|
||||
|
||||
|
||||
=head1 EXAMPLE
|
||||
|
||||
This example digests the data "Test Message\n" and "Hello World\n", using the
|
||||
@@ -197,7 +217,7 @@ digest name passed on the command line.
|
||||
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
EVP_MD_CTX mdctx;
|
||||
EVP_MD_CTX *mdctx;
|
||||
const EVP_MD *md;
|
||||
char mess1[] = "Test Message\n";
|
||||
char mess2[] = "Hello World\n";
|
||||
@@ -218,12 +238,12 @@ digest name passed on the command line.
|
||||
exit(1);
|
||||
}
|
||||
|
||||
EVP_MD_CTX_init(&mdctx);
|
||||
EVP_DigestInit_ex(&mdctx, md, NULL);
|
||||
EVP_DigestUpdate(&mdctx, mess1, strlen(mess1));
|
||||
EVP_DigestUpdate(&mdctx, mess2, strlen(mess2));
|
||||
EVP_DigestFinal_ex(&mdctx, md_value, &md_len);
|
||||
EVP_MD_CTX_cleanup(&mdctx);
|
||||
mdctx = EVP_MD_CTX_create();
|
||||
EVP_DigestInit_ex(mdctx, md, NULL);
|
||||
EVP_DigestUpdate(mdctx, mess1, strlen(mess1));
|
||||
EVP_DigestUpdate(mdctx, mess2, strlen(mess2));
|
||||
EVP_DigestFinal_ex(mdctx, md_value, &md_len);
|
||||
EVP_MD_CTX_destroy(mdctx);
|
||||
|
||||
printf("Digest is: ");
|
||||
for(i = 0; i < md_len; i++) printf("%02x", md_value[i]);
|
||||
|
@@ -142,13 +142,13 @@ gost94_keyx.o: ../../include/openssl/x509_vfy.h e_gost_err.h gost89.h
|
||||
gost94_keyx.o: gost94_keyx.c gost_keywrap.h gost_lcl.h gosthash.h
|
||||
gost_ameth.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
|
||||
gost_ameth.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
gost_ameth.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
gost_ameth.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
|
||||
gost_ameth.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
gost_ameth.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
|
||||
gost_ameth.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
gost_ameth.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
gost_ameth.o: ../../include/openssl/objects.h
|
||||
gost_ameth.o: ../../include/openssl/buffer.h ../../include/openssl/cms.h
|
||||
gost_ameth.o: ../../include/openssl/crypto.h ../../include/openssl/dsa.h
|
||||
gost_ameth.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
gost_ameth.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
|
||||
gost_ameth.o: ../../include/openssl/engine.h ../../include/openssl/err.h
|
||||
gost_ameth.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
|
||||
gost_ameth.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
gost_ameth.o: ../../include/openssl/opensslconf.h
|
||||
gost_ameth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
gost_ameth.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
|
@@ -13,6 +13,9 @@
|
||||
#include <openssl/engine.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/asn1.h>
|
||||
#ifndef OPENSSL_NO_CMS
|
||||
#include <openssl/cms.h>
|
||||
#endif
|
||||
#include "gost_params.h"
|
||||
#include "gost_lcl.h"
|
||||
#include "e_gost_err.h"
|
||||
@@ -230,6 +233,24 @@ static int pkey_ctrl_gost(EVP_PKEY *pkey, int op,
|
||||
X509_ALGOR_set0(alg2, OBJ_nid2obj(nid), V_ASN1_NULL, 0);
|
||||
}
|
||||
return 1;
|
||||
#ifndef OPENSSL_NO_CMS
|
||||
case ASN1_PKEY_CTRL_CMS_SIGN:
|
||||
if (arg1 == 0)
|
||||
{
|
||||
X509_ALGOR *alg1 = NULL, *alg2 = NULL;
|
||||
int nid = EVP_PKEY_base_id(pkey);
|
||||
CMS_SignerInfo_get0_algs((CMS_SignerInfo *)arg2,
|
||||
NULL, NULL, &alg1, &alg2);
|
||||
X509_ALGOR_set0(alg1, OBJ_nid2obj(NID_id_GostR3411_94),
|
||||
V_ASN1_NULL, 0);
|
||||
if (nid == NID_undef)
|
||||
{
|
||||
return (-1);
|
||||
}
|
||||
X509_ALGOR_set0(alg2, OBJ_nid2obj(nid), V_ASN1_NULL, 0);
|
||||
}
|
||||
return 1;
|
||||
#endif
|
||||
case ASN1_PKEY_CTRL_PKCS7_ENCRYPT:
|
||||
if (arg1 == 0)
|
||||
{
|
||||
@@ -244,6 +265,22 @@ static int pkey_ctrl_gost(EVP_PKEY *pkey, int op,
|
||||
V_ASN1_SEQUENCE, params);
|
||||
}
|
||||
return 1;
|
||||
#ifndef OPENSSL_NO_CMS
|
||||
case ASN1_PKEY_CTRL_CMS_ENVELOPE:
|
||||
if (arg1 == 0)
|
||||
{
|
||||
X509_ALGOR *alg;
|
||||
ASN1_STRING * params = encode_gost_algor_params(pkey);
|
||||
if (!params)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
CMS_RecipientInfo_ktri_get0_algs((CMS_RecipientInfo *)arg2, NULL, NULL, &alg);
|
||||
X509_ALGOR_set0(alg, OBJ_nid2obj(pkey->type),
|
||||
V_ASN1_SEQUENCE, params);
|
||||
}
|
||||
return 1;
|
||||
#endif
|
||||
case ASN1_PKEY_CTRL_DEFAULT_MD_NID:
|
||||
*(int *)arg2 = NID_id_GostR3411_94;
|
||||
return 2;
|
||||
|
@@ -89,6 +89,12 @@ static int pkey_gost_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
|
||||
case EVP_PKEY_CTRL_PKCS7_ENCRYPT:
|
||||
case EVP_PKEY_CTRL_PKCS7_DECRYPT:
|
||||
case EVP_PKEY_CTRL_PKCS7_SIGN:
|
||||
case EVP_PKEY_CTRL_DIGESTINIT:
|
||||
#ifndef OPENSSL_NO_CMS
|
||||
case EVP_PKEY_CTRL_CMS_ENCRYPT:
|
||||
case EVP_PKEY_CTRL_CMS_DECRYPT:
|
||||
case EVP_PKEY_CTRL_CMS_SIGN:
|
||||
#endif
|
||||
return 1;
|
||||
|
||||
case EVP_PKEY_CTRL_GOST_PARAMSET:
|
||||
@@ -521,6 +527,7 @@ static int pkey_gost_mac_ctrl_str(EVP_PKEY_CTX *ctx,
|
||||
{
|
||||
GOSTerr(GOST_F_PKEY_GOST_MAC_CTRL_STR,
|
||||
GOST_R_INVALID_MAC_KEY_LENGTH);
|
||||
OPENSSL_free(keybuf);
|
||||
return 0;
|
||||
}
|
||||
ret= pkey_gost_mac_ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY,
|
||||
|
@@ -503,6 +503,9 @@ $ WRITE H_FILE " * value _IONBF is not supported."
|
||||
$ WRITE H_FILE " * So, skip it on VMS."
|
||||
$ WRITE H_FILE " */"
|
||||
$ WRITE H_FILE "#define OPENSSL_NO_SETVBUF_IONBF"
|
||||
$ WRITE H_FILE "/* STCP support comes with TCPIP 5.7 ECO 2 "
|
||||
$ WRITE H_FILE " * enable on newer systems / 2012-02-24 arpadffy */"
|
||||
$ WRITE H_FILE "#define OPENSSL_NO_SCTP"
|
||||
$ WRITE H_FILE ""
|
||||
$!
|
||||
$! Add in the common "crypto/opensslconf.h.in".
|
||||
|
@@ -2,15 +2,15 @@
|
||||
%define libmaj 1
|
||||
%define libmin 0
|
||||
%define librel 1
|
||||
#%define librev a
|
||||
%define librev b
|
||||
Release: 1
|
||||
|
||||
%define openssldir /var/ssl
|
||||
|
||||
Summary: Secure Sockets Layer and cryptography libraries and tools
|
||||
Name: openssl
|
||||
Version: %{libmaj}.%{libmin}.%{librel}
|
||||
#Version: %{libmaj}.%{libmin}.%{librel}%{librev}
|
||||
#Version: %{libmaj}.%{libmin}.%{librel}
|
||||
Version: %{libmaj}.%{libmin}.%{librel}%{librev}
|
||||
Source0: ftp://ftp.openssl.org/source/%{name}-%{version}.tar.gz
|
||||
Copyright: Freely distributable
|
||||
Group: System Environment/Libraries
|
||||
|
@@ -538,6 +538,7 @@ err:
|
||||
|
||||
BIO *BIO_new_ssl_connect(SSL_CTX *ctx)
|
||||
{
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
BIO *ret=NULL,*con=NULL,*ssl=NULL;
|
||||
|
||||
if ((con=BIO_new(BIO_s_connect())) == NULL)
|
||||
@@ -549,6 +550,7 @@ BIO *BIO_new_ssl_connect(SSL_CTX *ctx)
|
||||
return(ret);
|
||||
err:
|
||||
if (con != NULL) BIO_free(con);
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@@ -227,14 +227,14 @@ int dtls1_do_write(SSL *s, int type)
|
||||
unsigned int len, frag_off, mac_size, blocksize;
|
||||
|
||||
/* AHA! Figure out the MTU, and stick to the right size */
|
||||
if ( ! (SSL_get_options(s) & SSL_OP_NO_QUERY_MTU))
|
||||
if (s->d1->mtu < dtls1_min_mtu() && !(SSL_get_options(s) & SSL_OP_NO_QUERY_MTU))
|
||||
{
|
||||
s->d1->mtu =
|
||||
BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_QUERY_MTU, 0, NULL);
|
||||
|
||||
/* I've seen the kernel return bogus numbers when it doesn't know
|
||||
* (initial write), so just make sure we have a reasonable number */
|
||||
if ( s->d1->mtu < dtls1_min_mtu())
|
||||
if (s->d1->mtu < dtls1_min_mtu())
|
||||
{
|
||||
s->d1->mtu = 0;
|
||||
s->d1->mtu = dtls1_guess_mtu(s->d1->mtu);
|
||||
@@ -1478,8 +1478,9 @@ dtls1_process_heartbeat(SSL *s)
|
||||
*bp++ = TLS1_HB_RESPONSE;
|
||||
s2n(payload, bp);
|
||||
memcpy(bp, pl, payload);
|
||||
bp += payload;
|
||||
/* Random padding */
|
||||
RAND_pseudo_bytes(p, padding);
|
||||
RAND_pseudo_bytes(bp, padding);
|
||||
|
||||
r = dtls1_write_bytes(s, TLS1_RT_HEARTBEAT, buffer, 3 + payload + padding);
|
||||
|
||||
|
@@ -329,7 +329,6 @@ int dtls1_connect(SSL *s)
|
||||
if (ret <= 0) goto end;
|
||||
else
|
||||
{
|
||||
dtls1_stop_timer(s);
|
||||
if (s->hit)
|
||||
{
|
||||
#ifndef OPENSSL_NO_SCTP
|
||||
@@ -440,6 +439,7 @@ int dtls1_connect(SSL *s)
|
||||
case SSL3_ST_CR_SRVR_DONE_B:
|
||||
ret=ssl3_get_server_done(s);
|
||||
if (ret <= 0) goto end;
|
||||
dtls1_stop_timer(s);
|
||||
if (s->s3->tmp.cert_req)
|
||||
s->s3->tmp.next_state=SSL3_ST_CW_CERT_A;
|
||||
else
|
||||
|
40
ssl/d1_lib.c
40
ssl/d1_lib.c
@@ -391,6 +391,7 @@ void dtls1_double_timeout(SSL *s)
|
||||
void dtls1_stop_timer(SSL *s)
|
||||
{
|
||||
/* Reset everything */
|
||||
memset(&(s->d1->timeout), 0, sizeof(struct dtls1_timeout_st));
|
||||
memset(&(s->d1->next_timeout), 0, sizeof(struct timeval));
|
||||
s->d1->timeout_duration = 1;
|
||||
BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, 0, &(s->d1->next_timeout));
|
||||
@@ -398,10 +399,28 @@ void dtls1_stop_timer(SSL *s)
|
||||
dtls1_clear_record_buffer(s);
|
||||
}
|
||||
|
||||
int dtls1_check_timeout_num(SSL *s)
|
||||
{
|
||||
s->d1->timeout.num_alerts++;
|
||||
|
||||
/* Reduce MTU after 2 unsuccessful retransmissions */
|
||||
if (s->d1->timeout.num_alerts > 2)
|
||||
{
|
||||
s->d1->mtu = BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_GET_FALLBACK_MTU, 0, NULL);
|
||||
}
|
||||
|
||||
if (s->d1->timeout.num_alerts > DTLS1_TMO_ALERT_COUNT)
|
||||
{
|
||||
/* fail the connection, enough alerts have been sent */
|
||||
SSLerr(SSL_F_DTLS1_CHECK_TIMEOUT_NUM,SSL_R_READ_TIMEOUT_EXPIRED);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dtls1_handle_timeout(SSL *s)
|
||||
{
|
||||
DTLS1_STATE *state;
|
||||
|
||||
/* if no timer is expired, don't do anything */
|
||||
if (!dtls1_is_timer_expired(s))
|
||||
{
|
||||
@@ -409,19 +428,14 @@ int dtls1_handle_timeout(SSL *s)
|
||||
}
|
||||
|
||||
dtls1_double_timeout(s);
|
||||
state = s->d1;
|
||||
state->timeout.num_alerts++;
|
||||
if ( state->timeout.num_alerts > DTLS1_TMO_ALERT_COUNT)
|
||||
{
|
||||
/* fail the connection, enough alerts have been sent */
|
||||
SSLerr(SSL_F_DTLS1_HANDLE_TIMEOUT,SSL_R_READ_TIMEOUT_EXPIRED);
|
||||
return -1;
|
||||
}
|
||||
|
||||
state->timeout.read_timeouts++;
|
||||
if ( state->timeout.read_timeouts > DTLS1_TMO_READ_COUNT)
|
||||
if (dtls1_check_timeout_num(s) < 0)
|
||||
return -1;
|
||||
|
||||
s->d1->timeout.read_timeouts++;
|
||||
if (s->d1->timeout.read_timeouts > DTLS1_TMO_READ_COUNT)
|
||||
{
|
||||
state->timeout.read_timeouts = 1;
|
||||
s->d1->timeout.read_timeouts = 1;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_HEARTBEATS
|
||||
|
12
ssl/d1_pkt.c
12
ssl/d1_pkt.c
@@ -179,7 +179,6 @@ static int dtls1_record_needs_buffering(SSL *s, SSL3_RECORD *rr,
|
||||
static int dtls1_buffer_record(SSL *s, record_pqueue *q,
|
||||
unsigned char *priority);
|
||||
static int dtls1_process_record(SSL *s);
|
||||
static void dtls1_clear_timeouts(SSL *s);
|
||||
|
||||
/* copy buffered record into SSL structure */
|
||||
static int
|
||||
@@ -698,7 +697,6 @@ again:
|
||||
goto again; /* get another record */
|
||||
}
|
||||
|
||||
dtls1_clear_timeouts(s); /* done waiting */
|
||||
return(1);
|
||||
|
||||
}
|
||||
@@ -1250,6 +1248,9 @@ start:
|
||||
*/
|
||||
if (msg_hdr.type == SSL3_MT_FINISHED)
|
||||
{
|
||||
if (dtls1_check_timeout_num(s) < 0)
|
||||
return -1;
|
||||
|
||||
dtls1_retransmit_buffered_messages(s);
|
||||
rr->length = 0;
|
||||
goto start;
|
||||
@@ -1873,10 +1874,3 @@ dtls1_reset_seq_numbers(SSL *s, int rw)
|
||||
|
||||
memset(seq, 0x00, seq_bytes);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dtls1_clear_timeouts(SSL *s)
|
||||
{
|
||||
memset(&(s->d1->timeout), 0x00, sizeof(struct dtls1_timeout_st));
|
||||
}
|
||||
|
@@ -591,15 +591,16 @@ int dtls1_accept(SSL *s)
|
||||
ret = ssl3_check_client_hello(s);
|
||||
if (ret <= 0)
|
||||
goto end;
|
||||
dtls1_stop_timer(s);
|
||||
if (ret == 2)
|
||||
{
|
||||
dtls1_stop_timer(s);
|
||||
s->state = SSL3_ST_SR_CLNT_HELLO_C;
|
||||
}
|
||||
else {
|
||||
/* could be sent for a DH cert, even if we
|
||||
* have not asked for it :-) */
|
||||
ret=ssl3_get_client_certificate(s);
|
||||
if (ret <= 0) goto end;
|
||||
dtls1_stop_timer(s);
|
||||
s->init_num=0;
|
||||
s->state=SSL3_ST_SR_KEY_EXCH_A;
|
||||
}
|
||||
@@ -609,7 +610,6 @@ int dtls1_accept(SSL *s)
|
||||
case SSL3_ST_SR_KEY_EXCH_B:
|
||||
ret=ssl3_get_client_key_exchange(s);
|
||||
if (ret <= 0) goto end;
|
||||
dtls1_stop_timer(s);
|
||||
#ifndef OPENSSL_NO_SCTP
|
||||
/* Add new shared key for SCTP-Auth,
|
||||
* will be ignored if no SCTP used.
|
||||
@@ -661,7 +661,6 @@ int dtls1_accept(SSL *s)
|
||||
/* we should decide if we expected this one */
|
||||
ret=ssl3_get_cert_verify(s);
|
||||
if (ret <= 0) goto end;
|
||||
dtls1_stop_timer(s);
|
||||
#ifndef OPENSSL_NO_SCTP
|
||||
if (BIO_dgram_is_sctp(SSL_get_wbio(s)) &&
|
||||
state == SSL_ST_RENEGOTIATE)
|
||||
@@ -921,7 +920,7 @@ int dtls1_send_server_hello(SSL *s)
|
||||
p=s->s3->server_random;
|
||||
Time=(unsigned long)time(NULL); /* Time */
|
||||
l2n(Time,p);
|
||||
RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-sizeof(Time));
|
||||
RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-4);
|
||||
/* Do the message type and length last */
|
||||
d=p= &(buf[DTLS1_HM_HEADER_LENGTH]);
|
||||
|
||||
|
@@ -282,32 +282,51 @@ static int ssl23_client_hello(SSL *s)
|
||||
SSL_COMP *comp;
|
||||
#endif
|
||||
int ret;
|
||||
unsigned long mask, options = s->options;
|
||||
|
||||
ssl2_compat = (s->options & SSL_OP_NO_SSLv2) ? 0 : 1;
|
||||
ssl2_compat = (options & SSL_OP_NO_SSLv2) ? 0 : 1;
|
||||
|
||||
if (ssl2_compat && ssl23_no_ssl2_ciphers(s))
|
||||
ssl2_compat = 0;
|
||||
|
||||
if (!(s->options & SSL_OP_NO_TLSv1_2))
|
||||
{
|
||||
version = TLS1_2_VERSION;
|
||||
}
|
||||
else if (!(s->options & SSL_OP_NO_TLSv1_1))
|
||||
{
|
||||
/*
|
||||
* SSL_OP_NO_X disables all protocols above X *if* there are
|
||||
* some protocols below X enabled. This is required in order
|
||||
* to maintain "version capability" vector contiguous. So
|
||||
* that if application wants to disable TLS1.0 in favour of
|
||||
* TLS1>=1, it would be insufficient to pass SSL_NO_TLSv1, the
|
||||
* answer is SSL_OP_NO_TLSv1|SSL_OP_NO_SSLv3|SSL_OP_NO_SSLv2.
|
||||
*/
|
||||
mask = SSL_OP_NO_TLSv1_1|SSL_OP_NO_TLSv1
|
||||
#if !defined(OPENSSL_NO_SSL3)
|
||||
|SSL_OP_NO_SSLv3
|
||||
#endif
|
||||
#if !defined(OPENSSL_NO_SSL2)
|
||||
|(ssl2_compat?SSL_OP_NO_SSLv2:0)
|
||||
#endif
|
||||
;
|
||||
#if !defined(OPENSSL_NO_TLS1_2_CLIENT)
|
||||
version = TLS1_2_VERSION;
|
||||
|
||||
if ((options & SSL_OP_NO_TLSv1_2) && (options & mask) != mask)
|
||||
version = TLS1_1_VERSION;
|
||||
}
|
||||
else if (!(s->options & SSL_OP_NO_TLSv1))
|
||||
{
|
||||
#else
|
||||
version = TLS1_1_VERSION;
|
||||
#endif
|
||||
mask &= ~SSL_OP_NO_TLSv1_1;
|
||||
if ((options & SSL_OP_NO_TLSv1_1) && (options & mask) != mask)
|
||||
version = TLS1_VERSION;
|
||||
}
|
||||
else if (!(s->options & SSL_OP_NO_SSLv3))
|
||||
{
|
||||
mask &= ~SSL_OP_NO_TLSv1;
|
||||
#if !defined(OPENSSL_NO_SSL3)
|
||||
if ((options & SSL_OP_NO_TLSv1) && (options & mask) != mask)
|
||||
version = SSL3_VERSION;
|
||||
}
|
||||
else if (!(s->options & SSL_OP_NO_SSLv2))
|
||||
{
|
||||
mask &= ~SSL_OP_NO_SSLv3;
|
||||
#endif
|
||||
#if !defined(OPENSSL_NO_SSL2)
|
||||
if ((options & SSL_OP_NO_SSLv3) && (options & mask) != mask)
|
||||
version = SSL2_VERSION;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_TLSEXT
|
||||
if (version != SSL2_VERSION)
|
||||
{
|
||||
@@ -467,6 +486,15 @@ static int ssl23_client_hello(SSL *s)
|
||||
SSLerr(SSL_F_SSL23_CLIENT_HELLO,SSL_R_NO_CIPHERS_AVAILABLE);
|
||||
return -1;
|
||||
}
|
||||
#ifdef OPENSSL_MAX_TLS1_2_CIPHER_LENGTH
|
||||
/* Some servers hang if client hello > 256 bytes
|
||||
* as hack workaround chop number of supported ciphers
|
||||
* to keep it well below this if we use TLS v1.2
|
||||
*/
|
||||
if (TLS1_get_version(s) >= TLS1_2_VERSION
|
||||
&& i > OPENSSL_MAX_TLS1_2_CIPHER_LENGTH)
|
||||
i = OPENSSL_MAX_TLS1_2_CIPHER_LENGTH & ~1;
|
||||
#endif
|
||||
s2n(i,p);
|
||||
p+=i;
|
||||
|
||||
@@ -521,8 +549,13 @@ static int ssl23_client_hello(SSL *s)
|
||||
d=buf;
|
||||
*(d++) = SSL3_RT_HANDSHAKE;
|
||||
*(d++) = version_major;
|
||||
*(d++) = version_minor; /* arguably we should send the *lowest* suported version here
|
||||
* (indicating, e.g., TLS 1.0 in "SSL 3.0 format") */
|
||||
/* Some servers hang if we use long client hellos
|
||||
* and a record number > TLS 1.0.
|
||||
*/
|
||||
if (TLS1_get_client_version(s) > TLS1_VERSION)
|
||||
*(d++) = 1;
|
||||
else
|
||||
*(d++) = version_minor;
|
||||
s2n((int)l,d);
|
||||
|
||||
/* number of bytes to write */
|
||||
|
@@ -755,6 +755,15 @@ int ssl3_client_hello(SSL *s)
|
||||
SSLerr(SSL_F_SSL3_CLIENT_HELLO,SSL_R_NO_CIPHERS_AVAILABLE);
|
||||
goto err;
|
||||
}
|
||||
#ifdef OPENSSL_MAX_TLS1_2_CIPHER_LENGTH
|
||||
/* Some servers hang if client hello > 256 bytes
|
||||
* as hack workaround chop number of supported ciphers
|
||||
* to keep it well below this if we use TLS v1.2
|
||||
*/
|
||||
if (TLS1_get_version(s) >= TLS1_2_VERSION
|
||||
&& i > OPENSSL_MAX_TLS1_2_CIPHER_LENGTH)
|
||||
i = OPENSSL_MAX_TLS1_2_CIPHER_LENGTH & ~1;
|
||||
#endif
|
||||
s2n(i,p);
|
||||
p+=i;
|
||||
|
||||
|
26
ssl/s3_lib.c
26
ssl/s3_lib.c
@@ -1081,7 +1081,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
|
||||
SSL_aRSA,
|
||||
SSL_eNULL,
|
||||
SSL_SHA256,
|
||||
SSL_SSLV3,
|
||||
SSL_TLSV1_2,
|
||||
SSL_NOT_EXP|SSL_STRONG_NONE|SSL_FIPS,
|
||||
SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
|
||||
0,
|
||||
@@ -1097,7 +1097,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
|
||||
SSL_aRSA,
|
||||
SSL_AES128,
|
||||
SSL_SHA256,
|
||||
SSL_TLSV1,
|
||||
SSL_TLSV1_2,
|
||||
SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
|
||||
SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
|
||||
128,
|
||||
@@ -1113,7 +1113,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
|
||||
SSL_aRSA,
|
||||
SSL_AES256,
|
||||
SSL_SHA256,
|
||||
SSL_TLSV1,
|
||||
SSL_TLSV1_2,
|
||||
SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
|
||||
SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
|
||||
256,
|
||||
@@ -1129,7 +1129,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
|
||||
SSL_aDH,
|
||||
SSL_AES128,
|
||||
SSL_SHA256,
|
||||
SSL_TLSV1,
|
||||
SSL_TLSV1_2,
|
||||
SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
|
||||
SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
|
||||
128,
|
||||
@@ -1145,7 +1145,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
|
||||
SSL_aDH,
|
||||
SSL_AES128,
|
||||
SSL_SHA256,
|
||||
SSL_TLSV1,
|
||||
SSL_TLSV1_2,
|
||||
SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
|
||||
SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
|
||||
128,
|
||||
@@ -1161,7 +1161,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
|
||||
SSL_aDSS,
|
||||
SSL_AES128,
|
||||
SSL_SHA256,
|
||||
SSL_TLSV1,
|
||||
SSL_TLSV1_2,
|
||||
SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
|
||||
SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
|
||||
128,
|
||||
@@ -1395,7 +1395,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
|
||||
SSL_aRSA,
|
||||
SSL_AES128,
|
||||
SSL_SHA256,
|
||||
SSL_TLSV1,
|
||||
SSL_TLSV1_2,
|
||||
SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
|
||||
SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
|
||||
128,
|
||||
@@ -1411,7 +1411,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
|
||||
SSL_aDH,
|
||||
SSL_AES256,
|
||||
SSL_SHA256,
|
||||
SSL_TLSV1,
|
||||
SSL_TLSV1_2,
|
||||
SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
|
||||
SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
|
||||
256,
|
||||
@@ -1427,7 +1427,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
|
||||
SSL_aDH,
|
||||
SSL_AES256,
|
||||
SSL_SHA256,
|
||||
SSL_TLSV1,
|
||||
SSL_TLSV1_2,
|
||||
SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
|
||||
SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
|
||||
256,
|
||||
@@ -1443,7 +1443,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
|
||||
SSL_aDSS,
|
||||
SSL_AES256,
|
||||
SSL_SHA256,
|
||||
SSL_TLSV1,
|
||||
SSL_TLSV1_2,
|
||||
SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
|
||||
SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
|
||||
256,
|
||||
@@ -1459,7 +1459,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
|
||||
SSL_aRSA,
|
||||
SSL_AES256,
|
||||
SSL_SHA256,
|
||||
SSL_TLSV1,
|
||||
SSL_TLSV1_2,
|
||||
SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
|
||||
SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
|
||||
256,
|
||||
@@ -1475,7 +1475,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
|
||||
SSL_aNULL,
|
||||
SSL_AES128,
|
||||
SSL_SHA256,
|
||||
SSL_TLSV1,
|
||||
SSL_TLSV1_2,
|
||||
SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
|
||||
SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
|
||||
128,
|
||||
@@ -1491,7 +1491,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
|
||||
SSL_aNULL,
|
||||
SSL_AES256,
|
||||
SSL_SHA256,
|
||||
SSL_TLSV1,
|
||||
SSL_TLSV1_2,
|
||||
SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
|
||||
SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
|
||||
256,
|
||||
|
17
ssl/s3_pkt.c
17
ssl/s3_pkt.c
@@ -664,10 +664,14 @@ static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
|
||||
if ( (sess == NULL) ||
|
||||
(s->enc_write_ctx == NULL) ||
|
||||
(EVP_MD_CTX_md(s->write_hash) == NULL))
|
||||
{
|
||||
#if 1
|
||||
clear=s->enc_write_ctx?0:1; /* must be AEAD cipher */
|
||||
#else
|
||||
clear=1;
|
||||
|
||||
if (clear)
|
||||
#endif
|
||||
mac_size=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
mac_size=EVP_MD_CTX_size(s->write_hash);
|
||||
@@ -736,7 +740,14 @@ static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
|
||||
wr->type=type;
|
||||
|
||||
*(p++)=(s->version>>8);
|
||||
*(p++)=s->version&0xff;
|
||||
/* Some servers hang if iniatial client hello is larger than 256
|
||||
* bytes and record version number > TLS 1.0
|
||||
*/
|
||||
if (s->state == SSL3_ST_CW_CLNT_HELLO_B
|
||||
&& TLS1_get_version(s) > TLS1_VERSION)
|
||||
*(p++) = 0x1;
|
||||
else
|
||||
*(p++)=s->version&0xff;
|
||||
|
||||
/* field where we are to write out packet length */
|
||||
plen=p;
|
||||
|
@@ -2930,7 +2930,7 @@ int ssl3_get_cert_verify(SSL *s)
|
||||
if (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE_VERIFY)
|
||||
{
|
||||
s->s3->tmp.reuse_message=1;
|
||||
if ((peer != NULL) && (type | EVP_PKT_SIGN))
|
||||
if ((peer != NULL) && (type & EVP_PKT_SIGN))
|
||||
{
|
||||
al=SSL_AD_UNEXPECTED_MESSAGE;
|
||||
SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_MISSING_VERIFY_MESSAGE);
|
||||
|
@@ -556,7 +556,6 @@ struct ssl_session_st
|
||||
#define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x00000080L
|
||||
#define SSL_OP_TLS_D5_BUG 0x00000100L
|
||||
#define SSL_OP_TLS_BLOCK_PADDING_BUG 0x00000200L
|
||||
#define SSL_OP_NO_TLSv1_1 0x00000400L
|
||||
|
||||
/* Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added
|
||||
* in OpenSSL 0.9.6d. Usually (depending on the application protocol)
|
||||
@@ -604,6 +603,7 @@ struct ssl_session_st
|
||||
#define SSL_OP_NO_SSLv3 0x02000000L
|
||||
#define SSL_OP_NO_TLSv1 0x04000000L
|
||||
#define SSL_OP_NO_TLSv1_2 0x08000000L
|
||||
#define SSL_OP_NO_TLSv1_1 0x10000000L
|
||||
|
||||
/* These next two were never actually used for anything since SSLeay
|
||||
* zap so we have some more flags.
|
||||
@@ -2058,6 +2058,7 @@ void ERR_load_SSL_strings(void);
|
||||
#define SSL_F_DTLS1_ACCEPT 246
|
||||
#define SSL_F_DTLS1_ADD_CERT_TO_BUF 295
|
||||
#define SSL_F_DTLS1_BUFFER_RECORD 247
|
||||
#define SSL_F_DTLS1_CHECK_TIMEOUT_NUM 316
|
||||
#define SSL_F_DTLS1_CLIENT_HELLO 248
|
||||
#define SSL_F_DTLS1_CONNECT 249
|
||||
#define SSL_F_DTLS1_ENC 250
|
||||
|
@@ -616,18 +616,19 @@ int ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc,
|
||||
{
|
||||
const EVP_CIPHER *evp;
|
||||
|
||||
if (s->ssl_version >= TLS1_VERSION &&
|
||||
c->algorithm_enc == SSL_RC4 &&
|
||||
if (s->ssl_version>>8 != TLS1_VERSION_MAJOR ||
|
||||
s->ssl_version < TLS1_VERSION)
|
||||
return 1;
|
||||
|
||||
if (c->algorithm_enc == SSL_RC4 &&
|
||||
c->algorithm_mac == SSL_MD5 &&
|
||||
(evp=EVP_get_cipherbyname("RC4-HMAC-MD5")))
|
||||
*enc = evp, *md = NULL;
|
||||
else if (s->ssl_version >= TLS1_VERSION &&
|
||||
c->algorithm_enc == SSL_AES128 &&
|
||||
else if (c->algorithm_enc == SSL_AES128 &&
|
||||
c->algorithm_mac == SSL_SHA1 &&
|
||||
(evp=EVP_get_cipherbyname("AES-128-CBC-HMAC-SHA1")))
|
||||
*enc = evp, *md = NULL;
|
||||
else if (s->ssl_version >= TLS1_VERSION &&
|
||||
c->algorithm_enc == SSL_AES256 &&
|
||||
else if (c->algorithm_enc == SSL_AES256 &&
|
||||
c->algorithm_mac == SSL_SHA1 &&
|
||||
(evp=EVP_get_cipherbyname("AES-256-CBC-HMAC-SHA1")))
|
||||
*enc = evp, *md = NULL;
|
||||
|
@@ -80,6 +80,7 @@ static ERR_STRING_DATA SSL_str_functs[]=
|
||||
{ERR_FUNC(SSL_F_DTLS1_ACCEPT), "DTLS1_ACCEPT"},
|
||||
{ERR_FUNC(SSL_F_DTLS1_ADD_CERT_TO_BUF), "DTLS1_ADD_CERT_TO_BUF"},
|
||||
{ERR_FUNC(SSL_F_DTLS1_BUFFER_RECORD), "DTLS1_BUFFER_RECORD"},
|
||||
{ERR_FUNC(SSL_F_DTLS1_CHECK_TIMEOUT_NUM), "DTLS1_CHECK_TIMEOUT_NUM"},
|
||||
{ERR_FUNC(SSL_F_DTLS1_CLIENT_HELLO), "DTLS1_CLIENT_HELLO"},
|
||||
{ERR_FUNC(SSL_F_DTLS1_CONNECT), "DTLS1_CONNECT"},
|
||||
{ERR_FUNC(SSL_F_DTLS1_ENC), "DTLS1_ENC"},
|
||||
|
@@ -965,6 +965,7 @@ void dtls1_get_ccs_header(unsigned char *data, struct ccs_header_st *ccs_hdr);
|
||||
void dtls1_reset_seq_numbers(SSL *s, int rw);
|
||||
long dtls1_default_timeout(void);
|
||||
struct timeval* dtls1_get_timeout(SSL *s, struct timeval* timeleft);
|
||||
int dtls1_check_timeout_num(SSL *s);
|
||||
int dtls1_handle_timeout(SSL *s);
|
||||
const SSL_CIPHER *dtls1_get_cipher(unsigned int u);
|
||||
void dtls1_start_timer(SSL *s);
|
||||
|
@@ -825,7 +825,10 @@ int tls1_enc(SSL *s, int send)
|
||||
}
|
||||
}
|
||||
|
||||
if (EVP_Cipher(ds,rec->data,rec->input,l) < 0)
|
||||
i = EVP_Cipher(ds,rec->data,rec->input,l);
|
||||
if ((EVP_CIPHER_flags(ds->cipher)&EVP_CIPH_FLAG_CUSTOM_CIPHER)
|
||||
?(i<0)
|
||||
:(i==0))
|
||||
return -1; /* AEAD can fail to verify MAC */
|
||||
if (EVP_CIPHER_mode(enc) == EVP_CIPH_GCM_MODE && !send)
|
||||
{
|
||||
|
@@ -544,7 +544,7 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *p, unsigned cha
|
||||
}
|
||||
skip_ext:
|
||||
|
||||
if (TLS1_get_version(s) >= TLS1_2_VERSION)
|
||||
if (TLS1_get_client_version(s) >= TLS1_2_VERSION)
|
||||
{
|
||||
if ((size_t)(limit - ret) < sizeof(tls12_sigalgs) + 6)
|
||||
return NULL;
|
||||
@@ -2467,7 +2467,10 @@ tls1_process_heartbeat(SSL *s)
|
||||
*bp++ = TLS1_HB_RESPONSE;
|
||||
s2n(payload, bp);
|
||||
memcpy(bp, pl, payload);
|
||||
|
||||
bp += payload;
|
||||
/* Random padding */
|
||||
RAND_pseudo_bytes(bp, padding);
|
||||
|
||||
r = ssl3_write_bytes(s, TLS1_RT_HEARTBEAT, buffer, 3 + payload + padding);
|
||||
|
||||
if (r >= 0 && s->msg_callback)
|
||||
|
30
ssl/tls1.h
30
ssl/tls1.h
@@ -197,20 +197,42 @@ extern "C" {
|
||||
#define TLS1_AD_BAD_CERTIFICATE_HASH_VALUE 114
|
||||
#define TLS1_AD_UNKNOWN_PSK_IDENTITY 115 /* fatal */
|
||||
|
||||
/* ExtensionType values from RFC3546 / RFC4366 */
|
||||
/* ExtensionType values from RFC3546 / RFC4366 / RFC6066 */
|
||||
#define TLSEXT_TYPE_server_name 0
|
||||
#define TLSEXT_TYPE_max_fragment_length 1
|
||||
#define TLSEXT_TYPE_client_certificate_url 2
|
||||
#define TLSEXT_TYPE_trusted_ca_keys 3
|
||||
#define TLSEXT_TYPE_truncated_hmac 4
|
||||
#define TLSEXT_TYPE_status_request 5
|
||||
/* ExtensionType values from RFC4681 */
|
||||
#define TLSEXT_TYPE_user_mapping 6
|
||||
|
||||
/* ExtensionType values from RFC5878 */
|
||||
#define TLSEXT_TYPE_client_authz 7
|
||||
#define TLSEXT_TYPE_server_authz 8
|
||||
|
||||
/* ExtensionType values from RFC6091 */
|
||||
#define TLSEXT_TYPE_cert_type 9
|
||||
|
||||
/* ExtensionType values from RFC4492 */
|
||||
#define TLSEXT_TYPE_elliptic_curves 10
|
||||
#define TLSEXT_TYPE_ec_point_formats 11
|
||||
|
||||
/* ExtensionType value from RFC5054 */
|
||||
#define TLSEXT_TYPE_srp 12
|
||||
|
||||
/* ExtensionType values from RFC5246 */
|
||||
#define TLSEXT_TYPE_signature_algorithms 13
|
||||
|
||||
/* ExtensionType value from RFC5764 */
|
||||
#define TLSEXT_TYPE_use_srtp 14
|
||||
|
||||
/* ExtensionType value from RFC5620 */
|
||||
#define TLSEXT_TYPE_heartbeat 15
|
||||
|
||||
/* ExtensionType value from RFC4507 */
|
||||
#define TLSEXT_TYPE_session_ticket 35
|
||||
|
||||
/* ExtensionType value from draft-rescorla-tls-opaque-prf-input-00.txt */
|
||||
#if 0 /* will have to be provided externally for now ,
|
||||
* i.e. build with -DTLSEXT_TYPE_opaque_prf_input=38183
|
||||
@@ -253,12 +275,6 @@ extern "C" {
|
||||
#define TLSEXT_hash_sha384 5
|
||||
#define TLSEXT_hash_sha512 6
|
||||
|
||||
/* ExtensionType value from RFC5764 */
|
||||
#define TLSEXT_TYPE_use_srtp 14
|
||||
|
||||
/* Heartbeat extension */
|
||||
#define TLSEXT_TYPE_heartbeat 15
|
||||
|
||||
#ifndef OPENSSL_NO_TLSEXT
|
||||
|
||||
#define TLSEXT_MAXLEN_host_name 255
|
||||
|
@@ -68,6 +68,8 @@ $ EXPTEST := exptest
|
||||
$ IDEATEST := ideatest
|
||||
$ SHATEST := shatest
|
||||
$ SHA1TEST := sha1test
|
||||
$ SHA256TEST := sha256t
|
||||
$ SHA512TEST := sha512t
|
||||
$ MDC2TEST := mdc2test
|
||||
$ RMDTEST := rmdtest
|
||||
$ MD2TEST := md2test
|
||||
@@ -115,6 +117,8 @@ $ return
|
||||
$ test_sha:
|
||||
$ mcr 'texe_dir''shatest'
|
||||
$ mcr 'texe_dir''sha1test'
|
||||
$ mcr 'texe_dir''sha256test'
|
||||
$ mcr 'texe_dir''sha512test'
|
||||
$ return
|
||||
$ test_mdc2:
|
||||
$ mcr 'texe_dir''mdc2test'
|
||||
|
@@ -11,6 +11,7 @@ CONFIG_OPTIONS="--prefix=/usr shared zlib no-idea no-rc5"
|
||||
INSTALL_PREFIX=/tmp/install/INSTALL
|
||||
|
||||
VERSION=
|
||||
SHLIB_VERSION_NUMBER=
|
||||
SUBVERSION=$1
|
||||
|
||||
function cleanup()
|
||||
@@ -28,6 +29,13 @@ function get_openssl_version()
|
||||
echo " Check value of variable VERSION in Makefile."
|
||||
exit 1
|
||||
fi
|
||||
eval `grep '^SHLIB_VERSION_NUMBER=' Makefile`
|
||||
if [ -z "${SHLIB_VERSION_NUMBER}" ]
|
||||
then
|
||||
echo "Error: Couldn't retrieve OpenSSL shared lib version from Makefile."
|
||||
echo " Check value of variable SHLIB_VERSION_NUMBER in Makefile."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function base_install()
|
||||
@@ -124,7 +132,7 @@ strip usr/bin/*.exe usr/bin/*.dll usr/lib/engines/*.so
|
||||
chmod u-w usr/lib/engines/*.so
|
||||
|
||||
# Runtime package
|
||||
tar cjf libopenssl${VERSION//[!0-9]/}-${VERSION}-${SUBVERSION}.tar.bz2 \
|
||||
tar cjf libopenssl${SHLIB_VERSION_NUMBER//[!0-9]/}-${VERSION}-${SUBVERSION}.tar.bz2 \
|
||||
usr/bin/cyg*dll
|
||||
# Base package
|
||||
find etc usr/bin/openssl.exe usr/bin/c_rehash usr/lib/engines usr/share/doc \
|
||||
@@ -139,7 +147,7 @@ tar cjfT openssl-devel-${VERSION}-${SUBVERSION}.tar.bz2 -
|
||||
|
||||
ls -l openssl-${VERSION}-${SUBVERSION}.tar.bz2
|
||||
ls -l openssl-devel-${VERSION}-${SUBVERSION}.tar.bz2
|
||||
ls -l libopenssl${VERSION//[!0-9]/}-${VERSION}-${SUBVERSION}.tar.bz2
|
||||
ls -l libopenssl${SHLIB_VERSION_NUMBER//[!0-9]/}-${VERSION}-${SUBVERSION}.tar.bz2
|
||||
|
||||
cleanup
|
||||
|
||||
|
Reference in New Issue
Block a user