Compare commits

...

1221 Commits

Author SHA1 Message Date
Matt Caswell
2c5db8dac3 Prepare for 1.0.2-beta3 release
Reviewed-by: Stephen Henson <steve@openssl.org>
2014-09-25 21:31:40 +01:00
Matt Caswell
bffd5a7f35 make update
Reviewed-by: Stephen Henson <steve@openssl.org>
2014-09-25 21:31:40 +01:00
Matt Caswell
5e60396fe7 Added 1.0.1i CHANGES and NEWS updates
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2014-09-25 21:29:25 +01:00
Emilia Kasper
0d6a11a91f Add missing tests
Accidentally omitted from commit 455b65dfab0de51c9f67b3c909311770f2b3f801

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
(cherry picked from commit fdc35a9d3e8cf4cfd9330d5df9883f42cf5648ad)
2014-09-25 13:46:55 +02:00
Tim Hudson
f9fac6163e Add constant_time_locl.h to HEADERS,
so the Win32 compile picks it up correctly.

Reviewed-by: Richard Levitte <levitte@openssl.org>
2014-09-25 08:08:51 +02:00
Richard Levitte
ef8055cbb7 Add the constant time test to the VMS build and tests
Reviewed-by: Tim Hudson <tjh@openssl.org>
2014-09-25 08:07:54 +02:00
Richard Levitte
3b7ab6f4b8 Include "constant_time_locl.h" rather than "../constant_time_locl.h".
The different -I compiler parameters will take care of the rest...

Reviewed-by: Tim Hudson <tjh@openssl.org>
2014-09-25 08:06:47 +02:00
Dr. Stephen Henson
3b4a761853 Don't allow non-FIPS curves in FIPS mode.
Reviewed-by: Tim Hudson <tjh@openssl.org>
2014-09-25 00:20:56 +01:00
Dr. Stephen Henson
255401756d Use correct function name: CMS_add1_signer()
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 5886354dcca4f8445ed35b6995a035b75409590c)
2014-09-25 00:06:46 +01:00
Andy Polyakov
ec65b83d65 crypto/bn/bn_nist.c: work around MSC ARM compiler bug.
RT: 3541
Reviewed-by: Emilia Kasper <emilia@openssl.org>
(cherry picked from commit 8b07c005fe006044d0e4a795421447deca3c9f2c)
2014-09-25 00:46:45 +02:00
Andy Polyakov
d169bf9cab e_os.h: allow inline functions to be compiled by legacy compilers.
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 40155f408985aff2e9f1b61b7cb04a3e518633a1)
2014-09-25 00:36:10 +02:00
Emilia Kasper
738911cde6 RT3425: constant-time evp_enc
Do the final padding check in EVP_DecryptFinal_ex in constant time to
avoid a timing leak from padding failure.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 4aac102f75b517bdb56b1bcfd0a856052d559f6e)

Conflicts:
	crypto/evp/evp_enc.c
2014-09-24 16:25:04 +02:00
Emilia Kasper
e1080ea3c7 RT3067: simplify patch
(Original commit adb46dbc6dd7347750df2468c93e8c34bcb93a4b)

Use the new constant-time methods consistently in s3_srvr.c

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
(cherry picked from commit 455b65dfab0de51c9f67b3c909311770f2b3f801)
2014-09-24 15:54:51 +02:00
Adam Langley
941af48fec This change alters the processing of invalid, RSA pre-master secrets so
that bad encryptions are treated like random session keys in constant
time.

(cherry picked from commit adb46dbc6dd7347750df2468c93e8c34bcb93a4b)

Reviewed-by: Rich Salz <rsalz@openssl.org>
2014-09-24 15:42:43 +02:00
Emilia Kasper
9bed73adaa RT3066: rewrite RSA padding checks to be slightly more constant time.
Also tweak s3_cbc.c to use new constant-time methods.
Also fix memory leaks from internal errors in RSA_padding_check_PKCS1_OAEP_mgf1

This patch is based on the original RT submission by Adam Langley <agl@chromium.org>,
as well as code from BoringSSL and OpenSSL.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>

Conflicts:
	crypto/rsa/rsa_oaep.c
	crypto/rsa/rsa_pk1.c
	ssl/s3_cbc.c
2014-09-24 12:47:19 +02:00
Emilia Kasper
e9128d9401 Note i2d_re_X509_tbs and related changes in CHANGES
Reviewed-by: Tim Hudson <tjh@openssl.org>
2014-09-23 18:26:42 +02:00
Emilia Kasper
972868b23d make update
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Andy Polyakov <appro@openssl.org>
2014-09-23 18:20:26 +02:00
Emilia Kasper
e774a3055b Add i2d_re_X509_tbs
i2d_re_X509_tbs re-encodes the TBS portion of the certificate.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Dr Stephen Henson <steve@openssl.org>
(cherry picked from commit 95b1752cc7531e4b609aea166f2db1c155ab5bdd)
2014-09-23 18:20:26 +02:00
Emilia Kasper
d9f99d4ef3 Revert "Add accessor for x509.cert_info."
This reverts commit 519ad9b3845c475d29db8b84b59bde7edecb4e70.

Reviewed-by: Dr Stephen Henson <steve@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
2014-09-23 18:20:26 +02:00
Emilia Kasper
6ce2a64191 Revert "Add more accessors."
This reverts commit cacdfcb2479984d9bfcc79b623118d8af6fea169.

Conflicts:
	crypto/x509/x509.h

Reviewed-by: Dr Stephen Henson <steve@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
2014-09-23 18:20:26 +02:00
Andy Polyakov
d2a1226b81 CHANGES: mention ECP_NISTZ256.
Reviewed-by: Bodo Moeller <bodo@openssl.org>
(cherry picked from commit 507efe737243d7c74a839ea90b3d7eec5eac22e7)
2014-09-23 14:56:46 +02:00
Andy Polyakov
9fa9370b6f crypto/ecp_nistz256.c: harmonize error codes.
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit be07ae9b10ea57242baa1f15291af162442531d6)
2014-09-22 00:11:04 +02:00
Dr. Stephen Henson
12f14b1d8f Fix warning.
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 16e5b45f72cd69b71ca28e84044d2354e068888c)
2014-09-22 00:10:53 +02:00
Andy Polyakov
27918b7c25 crypto/ec: harmonize new code with FIPS module.
RT: 3149
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2014-09-22 00:07:44 +02:00
Andy Polyakov
2e31c47adb Configure: engage ECP_NISTZ256.
RT: 3149

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 847147908bc7596195debb48a554a8cade2075f7)

Resolved conflicts:

	Configure
	TABLE
2014-09-22 00:07:44 +02:00
Andy Polyakov
3842a64d36 Add ECP_NISTZ256 by Shay Gueron, Intel Corp.
RT: 3149

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 4d3fa06fce52682bfbc503c7ded2d0289e3f8cde)
2014-09-22 00:07:44 +02:00
Andy Polyakov
8aed2a7548 Reserve option to use BN_mod_exp_mont_consttime in ECDSA.
Submitted by Shay Gueron, Intel Corp.
RT: 3149

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit f54be179aa4cbbd944728771d7d59ed588158a12)
2014-09-22 00:07:44 +02:00
Andy Polyakov
f7835e1c20 perlasm/x86_64-xlate.pl: handle inter-bank movd.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 902b30df193afc3417a96ba72a81ed390bd50de3)
2014-09-22 00:07:44 +02:00
Andy Polyakov
11d8abb331 Configure: add configuration for crypto/ec/asm extensions.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 6019cdd327526beb25a4c31c1ef63e72f5f8a4b0)

Resolved conflicts:

	Configure
	Makefile.org
	TABLE
2014-09-22 00:07:44 +02:00
Tim Hudson
320d949781 Fixed error introduced in commit f2be92b94dad3c6cbdf79d99a324804094cf1617
that fixed PR#3450 where an existing cast masked an issue when i was changed
from int to long in that commit

Picked up on z/linux (s390) where sizeof(int)!=sizeof(long)

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit b5ff559ff90124c6fd53bbb49dae5edb4e821e0a)
2014-09-22 06:35:57 +10:00
Andy Polyakov
dfb5de6fc0 Harmonize Tru64 and Linux make rules.
RT: 3333,3165
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit d475b2a3bfde8d4aceefb41b21acc3711893d2a8)
2014-09-20 10:22:13 +02:00
Jake Goulding
5015a93ded RT2301: GetDIBits, not GetBitmapBits in rand_win
GetDIBits has been around since Windows2000 and
BitBitmapBits is an old Win16 compatibility function
that is much slower.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 99b00fd99330afb0be46265c3e28f25f938d3221)
2014-09-18 16:42:07 -04:00
Rich Salz
478b3470ff RT2772 update: c_rehash was broken
Move the readdir() lines out of the if statement, so
that flist is available globally.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 6f46c3c3b007f1aed77bbb4d1657fab8521e2e08)
2014-09-11 13:09:56 -04:00
Rich Salz
3258429883 RT3271 update; extra; semi-colon; confuses; some;
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
(cherry picked from commit cb4bb56bae9404572571e8ce573ba9e48d6f7717)
2014-09-10 15:09:53 -04:00
Rich Salz
a9d928a8b6 RT2560: missing NULL check in ocsp_req_find_signer
If we don't find a signer in the internal list, then fall
through and look at the internal list; don't just return NULL.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit b2aa38a980e9fbf158aafe487fb729c492b241fb)
2014-09-10 12:20:15 -04:00
Rich Salz
3aa2d2d08f RT2196: Clear up some README wording
Say where to email bug reports.
Mention general RT tracker info in a separate paragraph.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 468ab1c20d1f3a43a63d0516fed6c9fefb3ccf71)
2014-09-09 17:49:04 -04:00
Matt Caswell
f33ce36aff RT3192: spurious error in DSA verify
This is funny; Ben commented in the source, Matt opend a ticket,
and Rich is doing the submit.  Need more code-review? :)

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit eb63bce040d1cc6147d256f516b59552c018e29b)
2014-09-09 17:10:57 -04:00
Rich Salz
e61c648fd6 RT3271: Don't use "if !" in shell lines
For portability don't use "if ! expr"

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit b999f66e34d19ae4d81263bc96b8b8d548d2e13c)
2014-09-09 17:05:50 -04:00
Geoff Keating
8c0d19d857 RT1909: Omit version for v1 certificates
When calling X509_set_version to set v1 certificate, that
should mean that the version number field is omitted.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 1f18f50c4b0711ebe4a20038d324c0de5dce4512)
2014-09-09 15:16:42 -04:00
Kurt Cancemi
283a8fd1aa RT3506: typo's in ssltest
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 4eadd11cd97ad359a2207e8e554d9fc84fce1110)
2014-09-09 13:58:33 -04:00
Paul Suhler
b8d687bb56 RT2841: Extra return in check_issued
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 4cd1119df38b095b6981dfee993195f18ed3c619)
2014-09-08 18:50:40 -04:00
Kurt Roeckx
57c932dafd RT2626: Change default_bits from 1K to 2K
This is a more comprehensive fix.  It changes all
keygen apps to use 2K keys. It also changes the
default to use SHA256 not SHA1.  This is from
Kurt's upstream Debian changes.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
(cherry picked from commit 44e0c2bae4bfd87d770480902618dbccde84fd81)
2014-09-08 17:23:37 -04:00
Matthias Andree
ef720a67ab RT2272: Add old-style hash to c_rehash
In addition to Matthias's change, I also added -n to
not remove links. And updated the manpage.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit a787c2590e468585a1a19738e0c7f481ec91b762)
2014-09-08 11:35:25 -04:00
Rich Salz
f28c48d07e RT468: SSL_CTX_sess_set_cache_size wrong
The documentation is wrong about what happens when the
session cache fills up.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit e9edfc419674f20b482a9beff9c246519f9c503e)
2014-09-08 11:26:19 -04:00
Erik Auerswald
ff89be854e RT3301: Discard too-long heartbeat requests
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit af4c6e348e4bad6303e7d214cdcf2536487aabe4)
2014-09-08 11:23:02 -04:00
Scott Schaefer
61a44b76a0 RT2518: fix pod2man errors
pod2man now complains when item tags are not sequential.
Also complains about missing =back and other tags.
Silence the warnings; most were already done.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit fe7573042fa7f406fedb78d959659b39a7a1dcfb)
2014-09-08 11:18:58 -04:00
Rich Salz
45236ed6a4 RT3108: OPENSSL_NO_SOCK should imply OPENSSL_NO_DGRAM
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit be0bd11d698677bb7dde14cde73af098da94da18)
2014-09-08 11:08:01 -04:00
Robin Lee
240635c0b2 RT3031: Need to #undef some names for win32
Copy the ifdef/undef stanza from x509.h to x509v3.h

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 83e4e03eeb22d2fbaec516a466330f2ccab22864)
2014-09-08 11:06:07 -04:00
Martin Olsson
610ac0525d RT2843: Remove another spurious close-comment token
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 683cd7c9485009efcd5b522357519f0c7e1d4c47)
2014-09-08 10:52:19 -04:00
Martin Olsson
9c096d0bbf RT2842: Remove spurious close-comment marker.
Also, I (rsalz) changed "#ifdef undef" to "#if 0"

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 6b0dc6eff1a59274730802db923d55802378d011)
2014-09-08 10:50:33 -04:00
Rich Salz
1915744a64 Merge branch 'OpenSSL_1_0_2-stable' of git.openssl.org:openssl into OpenSSL_1_0_2-stable
another empty merge???

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2014-09-08 10:47:03 -04:00
Rich Salz
c387f7d0ea Empty merge
Merge branch 'OpenSSL_1_0_2-stable' of git.openssl.org:openssl into OpenSSL_1_0_2-stable

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2014-09-08 10:45:53 -04:00
Rich Salz
eee95fc64f Empty merge
Merge branch 'OpenSSL_1_0_2-stable' of git.openssl.org:openssl into OpenSSL_1_0_2-stable

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2014-09-08 10:45:31 -04:00
Rich Salz
dd3c21b2d2 RT1834: Fix PKCS7_verify return value
The function returns 0 or 1, only.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit b0e659cfaca9ff4a481cc63b7f6b6e97303ad8fe)
2014-09-08 10:43:32 -04:00
Rich Salz
dd13aadf9e RT1832: Fix PKCS7_verify return value
The function returns 0 or 1, only.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit b0e659cfaca9ff4a481cc63b7f6b6e97303ad8fe)
2014-09-08 10:39:12 -04:00
Alon Bar-Lev
2a49fef28e RT1771: Add string.h include.
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 8842987e5a76535597b9795b0408565baabf18d1)
2014-09-08 10:38:08 -04:00
Viktor Dkhovni
c56be26d9f RT1325,2973: Add more extensions to c_rehash
Regexp was bracketed wrong.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 5a8addc432503d99dba39474892b07345a619641)
2014-09-07 18:25:59 -04:00
Dr. Stephen Henson
2102c53caa Add CHANGES entry for SCT viewer code.
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit b2774f6e17d4204f19a4c009cef9db58821c4456)
2014-09-05 13:45:45 +01:00
Adam Langley
e12e875759 psk_client_callback, 128-byte id bug.
Fix a bug in handling of 128 byte long PSK identity in
psk_client_callback.

OpenSSL supports PSK identities of up to (and including) 128 bytes in
length. PSK identity is obtained via the psk_client_callback,
implementors of which are expected to provide a NULL-terminated
identity. However, the callback is invoked with only 128 bytes of
storage thus making it impossible to return a 128 byte long identity and
the required additional NULL byte.

This CL fixes the issue by passing in a 129 byte long buffer into the
psk_client_callback. As a safety precaution, this CL also zeroes out the
buffer before passing it into the callback, uses strnlen for obtaining
the length of the identity returned by the callback, and aborts the
handshake if the identity (without the NULL terminator) is longer than
128 bytes.

(Original patch amended to achieve strnlen in a different way.)

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit be0d851732bad7370640702bc9c4a33189ede287)
2014-09-05 12:22:33 +02:00
Adam Langley
0600a5cd49 Ensure that x**0 mod 1 = 0.
(cherry picked from commit 2b0180c37fa6ffc48ee40caa831ca398b828e680)

Reviewed-by: Ben Laurie <ben@openssl.org>
2014-09-04 16:05:57 +02:00
Richard Levitte
a91b73fd29 Followup on RT3334 fix: make sure that a directory that's the empty
string returns 0 with errno = ENOENT.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit 360928b7d0f16dde70e26841bbf9e1af727e8b8f)
2014-09-03 22:23:34 +02:00
Phil Mesnier
02c38e37a6 RT3334: Fix crypto/LPdir_win.c
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit 6a14fe7576e7a14a46ba14df8be8fe478536b4fb)
2014-09-03 22:23:34 +02:00
Clang via Jeffrey Walton
fa2ae04c40 RT3140: Possibly-unit variable in pem_lib.c
Can't really happen, but the flow of control isn't obvious.
Add an initializer.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 0ff3687eab8b0915198ad84d83da5998860b11b3)
2014-09-02 23:38:15 -04:00
Emilia Kasper
27739e9265 Make the inline const-time functions static.
"inline" without static is not correct as the compiler may choose to ignore it
and will then either emit an external definition, or expect one.

Reviewed-by: Geoff Thorpe <geoff@openssl.org>
(cherry picked from commit 86f50b36e63275a916b147f9d8764e3c0c060fdb)
2014-09-02 15:24:54 +02:00
Adam Williamson
157c345175 RT3511: doc fix; req default serial is random
RT842, closed back in 2004, changed the default serial number
to be a random number rather than zero.  Finally time to update
the doc

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 3aba132d61baeecffb9a6f8da7d0809352cbfb2d)
2014-08-31 23:41:51 -04:00
Richard Levitte
770b98d02e Add t1_ext and ssl_utst to the VMS build as well.
Reviewed-by: Dr Stephen Henson <steve@openssl.org>
2014-08-31 18:22:02 +02:00
TANABE Hiroyasu
8475416fe7 RT1325,2973: Add more extensions to c_rehash
Add .crt/.cer/.crl to the filenames parsed.

I also updated the podpage (since it didn't exist when
this ticket was first created, nor when it was re-created
seven years later).

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 80ec8d4e3ee212786dc3092b1c97305b871827f0)
2014-08-31 00:37:54 -04:00
Andy Polyakov
30b7d5e1d8 md5-x86_64.pl: work around warning.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 4d86e8df6be69ed13abb73fd564f1f894eea0a98)
2014-08-30 19:18:12 +02:00
Andy Polyakov
9dd6240201 x86[_64] assembly pack: add Silvermont performance data.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit b59f92e75d334c9281082a02faa6c68afb614fd2)
2014-08-30 19:14:49 +02:00
Rich Salz
63eacabb61 RT2820: case-insensitive filenames on Darwin
Andy pointed out there is also darwin64, so tweak the pattern.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit 457f7b14ecce885dce0b1a16bcd0723f1d7a2792)
2014-08-30 10:20:28 -04:00
Rich Salz
0996ccc077 Add tags/TAGS
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 9d6253cfd3395dfe7147dae134579c6b16544c53)
2014-08-30 10:09:01 -04:00
Rich Salz
6aa9dbab0f RT2119,3407: Updated to dgst.pod
Re-order algorithm list.
Be consistent in command synopsis.
Add content about signing.
Add EXAMPLE section
Add some missing options: -r, -fips-fingerprint -non-fips-allow
Various other fixes.

Reviewed-by: Andy Polyakov <appro@openssl.org>
2014-08-30 10:05:19 -04:00
James Westby
c1071ab4f1 RT1941: c_rehash.pod is missing
Add the file written by James Westby, graciously contributed
under the terms of the OpenSSL license.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit cf2239b3b397174a8a6b1cc84ff68aba34ed5941)
2014-08-30 09:51:36 -04:00
Rich Salz
5decce4db0 RT2379: Bug in BIO_set_accept_port.pod
The doc says that port can be "*" to mean any port.
That's wrong.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 07e3b31fae98b985d3d2aad7066144b11833f688)
2014-08-29 16:46:16 -04:00
Jim Reid
12dabfc560 RT2880: HFS is case-insensitive filenames
Add Darwin to list of case-insensitive filenames when
installing manapges.  When doing this, I noticed that
we weren't setting "filecase" for the HTML doc install.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 82d9185ae53f6ba93953ae0e484179be89c8508a)
2014-08-29 16:39:38 -04:00
Dr. Stephen Henson
39d64e9351 update ordinals
Reviewed-by: Tim Hudson <tjh@openssl.org>
2014-08-28 18:24:14 +01:00
Dr. Stephen Henson
f9784baf0e Fix comments, add new test.
Fix comments in ssltest.c: return value of 0 now means extension is
omitted and add_cb is not called for servers if the corresponding
extension is absent in ClientHello.

Test add_cb is not called if extension is not received.
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit f47e203975133ddbae3cde20c8c3c0516f62066c)
2014-08-28 18:10:21 +01:00
Dr. Stephen Henson
8fb57b29d6 Custom extension documentation.
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit f3f56c2a87951e115a7f82d06826e72c9e13987f)
2014-08-28 18:10:21 +01:00
Dr. Stephen Henson
cf8d6c1000 Rename some callbacks, fix alignment.
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 0cfefe4b6dcc6947c236b0f10a7f9e2f02273075)
2014-08-28 18:10:21 +01:00
Dr. Stephen Henson
4164d631bb Use consistent function naming.
Instead of SSL_CTX_set_custom_cli_ext and SSL_CTX_set_custom_srv_ext
use SSL_CTX_add_client_custom_ext and SSL_CTX_add_server_custom_ext.
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 8cafe9e8bfcc99d12adf083c61411955995668c4)
2014-08-28 18:10:21 +01:00
Dr. Stephen Henson
46a1b9ef4f New function SSL_extension_supported().
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit c846a5f5678a7149bc6cbd37dbdae886a5108364)
2014-08-28 18:10:21 +01:00
Dr. Stephen Henson
6db2239c60 New extension callback features.
Support separate parse and add callback arguments.
Add new callback so an application can free extension data.
Change return value for send functions so < 0 is an error 0
omits extension and > 0 includes it. This is more consistent
with the behaviour of other functions in OpenSSL.

Modify parse_cb handling so <= 0 is an error.

Make SSL_CTX_set_custom_cli_ext and SSL_CTX_set_custom_cli_ext argument
order consistent.

NOTE: these changes WILL break existing code.

Remove (now inaccurate) in line documentation.
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 33f653adf3bff5b0795e22de1f54b7c5472252d0)
2014-08-28 18:10:21 +01:00
Dr. Stephen Henson
423ceb8319 Callback revision.
Use "parse" and "add" for function and callback names instead of
"first" and "second".

Change arguments to callback so the extension type is unsigned int
and the buffer length is size_t. Note: this *will* break existing code.
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit de2a9e38f39eacc2e052d694f5b5fa5b7e734abc)
2014-08-28 18:10:21 +01:00
Dr. Stephen Henson
cd2e17020e Remove serverinfo checks.
Since sanity checks are performed for all custom extensions the
serverinfo checks are no longer needed.
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 707b026d7871eb12c23671c975e6a15a8c331785)

Conflicts:

	ssl/ssl3.h
	ssl/t1_lib.c
2014-08-28 18:09:59 +01:00
Dr. Stephen Henson
9346c75cb8 Add custom extension sanity checks.
Reject attempts to use extensions handled internally.

Add flags to each extension structure to indicate if an extension
has been sent or received. Enforce RFC5246 compliance by rejecting
duplicate extensions and unsolicited extensions and only send a
server extension if we have sent the corresponding client extension.
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 28ea0a0c6a5e4e217c405340fa22a8503c7a17db)
2014-08-28 18:09:39 +01:00
Dr. Stephen Henson
0a4fe37fc6 Custom extension revision.
Use the same structure for client and server custom extensions.

Add utility functions in new file t1_ext.c.
Use new utility functions to handle custom server and client extensions
and remove a lot of code duplication.
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit ecf4d660902dcef6e0afc51d52926f00d409ee6b)

Conflicts:

	ssl/ssl_lib.c
	ssl/ssl_locl.h
	ssl/t1_lib.c
2014-08-28 18:09:05 +01:00
Dr. Stephen Henson
da67a0ae34 Revision of custom extension code.
Move custom extension structures from SSL_CTX to CERT structure.

This change means the form can be revised in future without binary
compatibility issues. Also since CERT is part of SSL structures
so per-SSL custom extensions could be supported in future as well as
per SSL_CTX.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit b83294fe3022b9d5d525ccdcfeb53d39c25b05bd)

Conflicts:

	ssl/ssl.h
	ssl/ssl_cert.c
	ssl/ssl_locl.h
2014-08-28 17:06:50 +01:00
Emilia Kasper
9a9b0c0401 Constant-time utilities
Pull constant-time methods out to a separate header, add tests.

Reviewed-by: Bodo Moeller <bodo@openssl.org>
(cherry picked from commit 5a3d21c0585064292bde5cd34089e120487ab687)

Conflicts:
	ssl/s3_cbc.c
	test/Makefile
2014-08-28 16:26:01 +02:00
Raphael Spreitzer
b85d461cdf RT2400: ASN1_STRING_to_UTF8 missing initializer
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit f9fb43e176ad2a914108cd2b403425dc1ebc7262)
2014-08-27 22:59:40 -04:00
Rich Salz
089f10e69e RT2308: Add extern "C" { ... } wrapper
Add the wrapper to all public header files (Configure
generates one).  Don't bother for those that are just
lists of #define's that do renaming.

Reviewed-by: Tim Hudson <tjh@openssl.org>

Cherry-pick of commit 17e80c6bd05de7406a65116f34ed59665607d8d5
2014-08-27 21:45:09 -04:00
Emilia Kasper
7f7c05ca63 Explicitly check for empty ASN.1 strings in d2i_ECPrivateKey
The old code implicitly relies on the ASN.1 code returning a \0-prefixed buffer
when the buffer length is 0. Change this to verify explicitly that the ASN.1 string
has positive length.

Reviewed-by: Dr Stephen Henson <steve@openssl.org>
(cherry picked from commit 82dc08de54ce443c2a9ac478faffe79e76157795)
2014-08-27 19:50:15 +02:00
Matt Caswell
2083f7c465 RT3065: automatically generate a missing EC public key
When d2i_ECPrivateKey reads a private key with a missing (optional) public key,
generate one automatically from the group and private key.

Reviewed-by: Dr Stephen Henson <steve@openssl.org>
(cherry picked from commit ed383f847156940e93f256fed78599873a4a9b28)
2014-08-27 19:50:15 +02:00
Adam Langley
1f2b943254 RT3065: ec_private_key_dont_crash
This change saves several EC routines from crashing when an EC_KEY is
missing a public key. The public key is optional in the EC private key
format and, without this patch, running the following through `openssl
ec` causes a crash:

-----BEGIN EC PRIVATE KEY-----
MBkCAQEECAECAwQFBgcIoAoGCCqGSM49AwEH
-----END EC PRIVATE KEY-----

Reviewed-by: Dr Stephen Henson <steve@openssl.org>
(cherry picked from commit b391570bdeb386d4fd325917c248d593d3c43930)
2014-08-27 19:50:15 +02:00
Mihai Militaru
dc5c3d7370 RT2210: Add missing EVP_cleanup to example
I also removed some trailing whitespace and cleaned
up the "see also" list.

Reviewed-by: Emilia Kasper <emilia@openssl.org>
(cherry picked from commit 7b3e11c54466f1da8b707c932e308d345fd61101)
2014-08-27 13:25:36 -04:00
John Fitzgibbon
383f0e349f RT2724: Remove extra declaration
Extra SSL_get_selected_srtp_profile() declaration in ssl/srtp.h
causes -Werror builds to fail.

Cherry-picked from 3609b02305c3678525930ff9bacb566c0122ea2a

Reviewed-by: Tim Hudson <tjh@openssl.org>
2014-08-26 16:55:54 -04:00
David Gatwood
0a64a864b4 RT1744: SSL_CTX_set_dump_dh() doc feedback
The description of when the server creates a DH key is
confusing.  This cleans it up.
(rsalz: also removed trailing whitespace.)

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
2014-08-26 13:38:27 -04:00
Jan Schaumann
dec128313b RT1804: fix EXAMPLE in EVP_EncryptInit.pod
The EXAMPLE that used FILE and RC2 doesn't compile due to a
few minor errors.  Tweak to use IDEA and AES-128. Remove
examples about RC2 and RC5.

Reviewed-by: Emilia Kasper <emilia@openssl.org>
2014-08-25 10:26:17 -04:00
Matt Caswell
1d4f214eaf Typo fixes to evp documentation.
This patch was submitted by user "Kox" via the wiki

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 2dd8cb3b9593f528d9537aa6a003d5c93df1e3c5)
2014-08-24 21:26:02 +01:00
Adam Langley
3aac17a82f RT3060: Limit the number of empty records.
Limit the number of empty records that will be processed consecutively
in order to prevent ssl3_get_record from never returning.

Reported by "oftc_must_be_destroyed" and George Kadianakis.

Reviewed-by: Bodo Moeller <bodo@openssl.org>
2014-08-22 15:36:06 +02:00
Adam Langley
e19c93811f RT3061: Don't SEGFAULT when trying to export a public DSA key as a private key.
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
2014-08-22 15:21:12 +02:00
Emilia Kasper
108e907645 Improve EVP_PKEY_sign documentation
Clarify the intended use of EVP_PKEY_sign. Make the code example compile.

Reviewed-by: Dr Stephen Henson <steve@openssl.org>
(cherry picked from commit d64c533a207f7b6d86c3bc8ffb053e5f4d0c1ca0)
2014-08-22 15:05:55 +02:00
Emilia Kasper
8958be3946 define inline for Visual Studio
In Visual Studio, inline is available in C++ only, however __inline is available for C, see
http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Dr Stephen Henson <steve@openssl.org>
(cherry picked from commit f511b25a7370c775dc9fd6198dbacd1706cf242b)
2014-08-21 16:07:44 +02:00
Emilia Kasper
ebf221ee25 Fix build when BSAES_ASM is defined but VPAES_ASM is not
Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit da92be4d68bec81030838e3228ef0238c565af85)
2014-08-21 15:48:10 +02:00
Andy Polyakov
ef90877721 bn/asm/rsaz-*.pl: allow spaces in Perl path name.
RT: 2835

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 15735e4f0e81d535cda0ad7ab52a0ed64b644cd0)
2014-08-21 00:19:24 +02:00
Andy Polyakov
a89adc148e sha1-mb-x86_64.pl: add commentary.
Reviewed-by: Emilia Kasper <emilia@openssl.org>
(cherry picked from commit e608273a8094a95a5703c26a428a007497e74392)
2014-08-21 00:16:32 +02:00
Andy Polyakov
b698c427de crypto/evp/e_aes_cbc_hmac_sha[1|256].c: fix compiler warnings.
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 2893a302a9b6a70161d1859d985a52af11b2195d)
2014-08-20 22:20:21 +02:00
Andy Polyakov
e99ac8b868 sha1-mb-x86_64.pl: fix typo.
Reviewed-by: Emilia Kasper <emilia@openssl.org>
(cherry picked from commit 55eb14da201cc35fe744a08718f5c2efb97f6155)
2014-08-20 22:12:50 +02:00
Matt Caswell
43312c624d Fixed out-of-bounds read errors in ssl3_get_key_exchange.
PR#3450

Reviewed-by: Emilia Käsper <emilia@openssl.org>
2014-08-15 23:28:52 +01:00
Istvan Noszticzius
beeb0fa7be Fix use after free bug.
Reviewed-by: Stephen Henson <steve@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 5afa57fb7b17aa51cfba1ffa94e900fc7a5f0e04)
2014-08-15 16:46:14 +01:00
Bodo Moeller
267e6f3cc0 Further improve/fix ec_GFp_simple_points_make_affine (ecp_smpl.c) and
group_order_tests (ectest.c).  Also fix the EC_POINTs_mul documentation (ec.h).

Reviewed-by: emilia@openssl.org
2014-08-13 17:40:33 +02:00
Dr. Stephen Henson
5ed0b6ac0c Fix SRP authentication ciphersuites.
The addition of SRP authentication needs to be checked in various places
to work properly. Specifically:

A certificate is not sent.
A certificate request must not be sent.
Server key exchange message must not contain a signature.
If appropriate SRP authentication ciphersuites should be chosen.
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 8f5a8805b82d1ae81168b11b7f1506db9e047dec)
2014-08-09 00:09:14 +01:00
Dr. Stephen Henson
90a549ddfb Test SRP authentication ciphersuites.
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 193c1c07165b0042abd217274a084b49459d4443)
2014-08-09 00:09:01 +01:00
Dr. Stephen Henson
bc792813f0 Only use FIPS EC methods in FIPS mode.
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 1433cac53c93f9f109290389f60b17078a572d3d)
2014-08-07 02:11:53 +01:00
Dr. Stephen Henson
bb4c9ffd02 Check SRP parameters early.
Check SRP parameters when they are received so we can send back an
appropriate alert.
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
2014-08-06 20:41:53 +01:00
Dr. Stephen Henson
53348780e9 Fix SRP buffer overrun vulnerability.
Invalid parameters passed to the SRP code can be overrun an internal
buffer. Add sanity check that g, A, B < N to SRP code.

Thanks to Sean Devlin and Watson Ladd of Cryptography Services, NCC
Group for reporting this issue.
2014-08-06 20:41:24 +01:00
Dr. Stephen Henson
f338c2e0c2 Fix SRP ciphersuite DoS vulnerability.
If a client attempted to use an SRP ciphersuite and it had not been
set up correctly it would crash with a null pointer read. A malicious
server could exploit this in a DoS attack.

Thanks to Joonas Kuorilehto and Riku Hietamäki from Codenomicon
for reporting this issue.

CVE-2014-2970
Reviewed-by: Tim Hudson <tjh@openssl.org>
2014-08-06 20:41:24 +01:00
Gabor Tyukasz
92aa73bcbf Fix race condition in ssl_parse_serverhello_tlsext
CVE-2014-3509
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2014-08-06 20:41:24 +01:00
Emilia Kasper
c01618dd82 Fix OID handling:
- Upon parsing, reject OIDs with invalid base-128 encoding.
- Always NUL-terminate the destination buffer in OBJ_obj2txt printing function.

CVE-2014-3508

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
2014-08-06 20:41:24 +01:00
Emilia Käsper
1d7d0ed9c2 Fix DTLS anonymous EC(DH) denial of service
CVE-2014-3510

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2014-08-06 20:41:24 +01:00
David Benjamin
40a2200d89 Fix protocol downgrade bug in case of fragmented packets
CVE-2014-3511

Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Bodo Möller <bodo@openssl.org>
2014-08-06 20:41:24 +01:00
Adam Langley
d345a24569 Remove some duplicate DTLS code.
In a couple of functions, a sequence number would be calculated twice.

Additionally, in |dtls1_process_out_of_seq_message|, we know that
|frag_len| <= |msg_hdr->msg_len| so the later tests for |frag_len <
msg_hdr->msg_len| can be more clearly written as |frag_len !=
msg_hdr->msg_len|, since that's the only remaining case.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
2014-08-06 20:41:24 +01:00
Matt Caswell
3d5dceac43 Applying same fix as in dtls1_process_out_of_seq_message. A truncated DTLS fragment would cause *ok to be clear, but the return value would still be the number of bytes read.
Problem identified by Emilia Käsper, based on previous issue/patch by Adam
Langley.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
2014-08-06 20:41:23 +01:00
Adam Langley
aad61c0a57 Fix return code for truncated DTLS fragment.
Previously, a truncated DTLS fragment in
|dtls1_process_out_of_seq_message| would cause *ok to be cleared, but
the return value would still be the number of bytes read. This would
cause |dtls1_get_message| not to consider it an error and it would
continue processing as normal until the calling function noticed that
*ok was zero.

I can't see an exploit here because |dtls1_get_message| uses
|s->init_num| as the length, which will always be zero from what I can
see.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
2014-08-06 20:41:23 +01:00
Adam Langley
8ca4c4b25e Fix memory leak from zero-length DTLS fragments.
The |pqueue_insert| function can fail if one attempts to insert a
duplicate sequence number. When handling a fragment of an out of
sequence message, |dtls1_process_out_of_seq_message| would not call
|dtls1_reassemble_fragment| if the fragment's length was zero. It would
then allocate a fresh fragment and attempt to insert it, but ignore the
return value, leaking the fragment.

This allows an attacker to exhaust the memory of a DTLS peer.

Fixes CVE-2014-3507

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
2014-08-06 20:41:23 +01:00
Matt Caswell
0598468fc0 Fix DTLS handshake message size checks.
In |dtls1_reassemble_fragment|, the value of
|msg_hdr->frag_off+frag_len| was being checked against the maximum
handshake message size, but then |msg_len| bytes were allocated for the
fragment buffer. This means that so long as the fragment was within the
allowed size, the pending handshake message could consume 16MB + 2MB
(for the reassembly bitmap). Approx 10 outstanding handshake messages
are allowed, meaning that an attacker could consume ~180MB per DTLS
connection.

In the non-fragmented path (in |dtls1_process_out_of_seq_message|), no
check was applied.

Fixes CVE-2014-3506

Wholly based on patch by Adam Langley with one minor amendment.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
2014-08-06 20:41:23 +01:00
Matt Caswell
ea7cb53974 Added comment for the frag->reassembly == NULL case as per feedback from Emilia
Reviewed-by: Emilia Käsper <emilia@openssl.org>
2014-08-06 20:41:23 +01:00
Adam Langley
4985007555 Avoid double free when processing DTLS packets.
The |item| variable, in both of these cases, may contain a pointer to a
|pitem| structure within |s->d1->buffered_messages|. It was being freed
in the error case while still being in |buffered_messages|. When the
error later caused the |SSL*| to be destroyed, the item would be double
freed.

Thanks to Wah-Teh Chang for spotting that the fix in 1632ef74 was
inconsistent with the other error paths (but correct).

Fixes CVE-2014-3505

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
2014-08-06 20:41:23 +01:00
Dr. Stephen Henson
89d2f8f1a9 make update
Reviewed-by: Tim Hudson <tjh@openssl.org>
2014-08-01 21:21:03 +01:00
Dr. Stephen Henson
2c3673cd3f Fix error discrepancy.
We can't rename ssleay_rand_bytes to md_rand_bytes_lock as this will cause
an error code discrepancy. Instead keep ssleay_rand_bytes and add an
extra parameter: since ssleay_rand_bytes is not part of the public API
this wont cause any binary compatibility issues.
Reviewed-by: Kurt Roeckx <kurt@openssl.org >
2014-08-01 18:42:41 +01:00
Bodo Moeller
ba5f75d53e Update $default_depflags to match current defaults. 2014-08-01 19:03:03 +02:00
Bodo Moeller
be804523cf Clean up CHANGES files: If a change is already present in 1.0.1f or 1.0.1h,
don't list it again under changes between 1.0.1h and 1.0.2.
2014-08-01 18:38:56 +02:00
Bodo Moeller
d5213519c0 Simplify and fix ec_GFp_simple_points_make_affine
(which didn't always handle value 0 correctly).

Reviewed-by: emilia@openssl.org
2014-08-01 17:27:59 +02:00
Dr. Stephen Henson
a3efe1b6e9 Avoid multiple lock using FIPS DRBG.
Don't use multiple locks when SP800-90 DRBG is used outside FIPS mode.

PR#3176
Reviewed-by: Rich Salz <rsalz@openssl.org>
2014-07-30 21:08:07 +01:00
Dr. Stephen Henson
789b12599d Add conditional unit testing interface.
Don't call internal functions directly call them through
SSL_test_functions(). This also makes unit testing work on
Windows and platforms that don't export internal functions
from shared libraries.

By default unit testing is not enabled: it requires the compile
time option "enable-unit-test".
Reviewed-by: Geoff Thorpe <geoff@openssl.org>
(cherry picked from commit e0fc7961c4fbd27577fb519d9aea2dc788742715)

Conflicts:

	ssl/heartbeat_test.c
	ssl/ssl.h
	util/mkdef.pl
2014-07-24 19:42:26 +01:00
Matt Caswell
371d9a627b Prepare for 1.0.2-beta3-dev
Reviewed-by: Stephen Henson <steve@openssl.org>
2014-07-22 21:31:04 +01:00
Matt Caswell
2f63ad1c6d Prepare for 1.0.2-beta2 release
Reviewed-by: Stephen Henson <steve@openssl.org>
2014-07-22 21:30:33 +01:00
Matt Caswell
0e32035292 make update
Reviewed-by: Stephen Henson <steve@openssl.org>
2014-07-22 21:30:33 +01:00
Dr. Stephen Henson
f5ce8d6a61 update $default_depflags
Reviewed-by: Matt Caswell <matt@openssl.org>
2014-07-22 21:12:25 +01:00
Andy Polyakov
0ae6ba18ab CHANGES: mention new platforms.
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2014-07-22 20:18:06 +02:00
Billy Brumley
4ccc2c19e2 "EC_POINT_invert" was checking "dbl" function pointer instead of "invert".
PR#2569

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit cba11f57ce161fd301a72194827327128191de7e)
2014-07-21 22:28:09 +01:00
Tim Hudson
b5e611a973 Remove old unused and unmaintained demonstration code.
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 62352b8138018775a4c085a105fccd9cdcb6323f)
2014-07-22 07:26:55 +10:00
Andy Polyakov
a2f34441ab sha1-ppc.pl: shave off one cycle from BODY_20_39
and improve performance by 10% on POWER[78].

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
(cherry picked from commit 5c3598307ebbf5a88d1c39fbb2629536e443a5dd)
2014-07-21 15:30:59 +02:00
Tim Hudson
2be9425514 Minor documentation update removing "really" and a
statement of opinion rather than a fact.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit c8d133e4b6f1ed1b7ad3c1a6d2c62f460e26c050)
2014-07-21 20:25:14 +10:00
Dr. Stephen Henson
f284fc7cc3 Add test header to Makefile, update ordinals
Reviewed-by: Tim Hudson <tjh@openssl.org>
2014-07-20 20:50:38 +01:00
Andy Polyakov
c991d8ae8b Initial POWER8 support from development branch.
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
2014-07-20 14:36:49 +02:00
Dr. Stephen Henson
be12cb3e24 Fix documentation for RSA_set_method(3)
PR#1675
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 197400c3f0d617d71ad8167b52fb73046d334320)
2014-07-19 18:25:53 +01:00
Dr. Stephen Henson
4c05b1f8d6 Make *Final work for key wrap again.
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 58f4698f67c33b723a9e99bed1101161a59eea73)
2014-07-17 23:31:11 +01:00
Dr. Stephen Henson
6e1e5996df Sanity check lengths for AES wrap algorithm.
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit d12eef15016e49fc09d6c96653c61624e032d1a3)
2014-07-17 12:58:42 +01:00
Jeffrey Walton
6ccd120f5f Fix typo, add reference.
PR#3456
Reviewed-by: Stephen Henson <steve@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit d48e78f0cf22aaddb563f4bcfccf25b1a45ac8a4)
2014-07-17 12:08:26 +01:00
Matt Caswell
ca818b322d Disabled XTS mode in enc utility as it is not supported
PR#3442

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 2097a17c576f2395a10b05f14490688bc5f45a07)
2014-07-16 21:01:38 +01:00
Matt Caswell
b11c24110c Add Matt Caswell's fingerprint, and general update on the fingerprints file to bring it up to date
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 3bd548192a03142c80cf8bc68659d79dea20a738)
2014-07-15 23:22:49 +01:00
Dr. Stephen Henson
beac6cb5aa Clarify -Verify and PSK.
PR#3452
(cherry picked from commit ca2015a617842fed3d36ed4dcbbf8d5e27bc5216)
2014-07-15 20:23:25 +01:00
Dr. Stephen Henson
666a597ffb Fix DTLS certificate requesting code.
Use same logic when determining when to expect a client
certificate for both TLS and DTLS.

PR#3452
(cherry picked from commit c8d710dc5f83d69d802f941a4cc5895eb5fe3d65)
2014-07-15 18:23:35 +01:00
Dr. Stephen Henson
d4dbabb814 Don't allow -www etc options with DTLS.
The options which emulate a web server don't make sense when doing DTLS.
Exit with an error if an attempt is made to use them.

PR#3453
(cherry picked from commit 58a2aaeade8bdecd0f9f0df41927f7cff3012547)
2014-07-15 12:25:19 +01:00
Dr. Stephen Henson
c71e37aa6c Use case insensitive compare for servername.
PR#3445
(cherry picked from commit 1c3e9a7c67ccdc5e770829fe951e5832e600d377)
2014-07-14 23:59:58 +01:00
Hubert Kario
cdae9a58e6 document -nextprotoneg option in man pages
Add description of the option to advertise support of
Next Protocol Negotiation extension (-nextprotoneg) to
man pages of s_client and s_server.

PR#3444
(cherry picked from commit 7efd0e777e65eaa6c60d85b1cc5c889f872f8fc4)
2014-07-14 23:43:21 +01:00
Dr. Stephen Henson
fa2b54c83a Use more common name for GOST key exchange.
(cherry picked from commit 7aabd9c92fe6f0ea2a82869e5171dcc4518cee85)
2014-07-14 18:31:55 +01:00
Matt Caswell
14b5d0d029 Fixed valgrind complaint due to BN_consttime_swap reading uninitialised data.
This is actually ok for this function, but initialised to zero anyway if
PURIFY defined.

This does have the impact of masking any *real* unitialised data reads in bn though.

Patch based on approach suggested by Rich Salz.

PR#3415

(cherry picked from commit 77747e2d9a5573b1dbc15e247ce18c03374c760c)
2014-07-13 22:20:15 +01:00
Peter Mosmans
2fbd94252a Add names of GOST algorithms.
PR#3440
(cherry picked from commit 924e5eda2c82d737cc5a1b9c37918aa6e34825da)
2014-07-13 18:31:09 +01:00
Richard Levitte
5b9188454b * crypto/ui/ui_lib.c: misplaced brace in switch statement.
Detected by dcruette@qualitesys.com

(cherry picked from commit 8b5dd340919e511137696792279f595a70ae2762)
2014-07-13 19:13:38 +02:00
Ben Laurie
5e189b4b8d Don't clean up uninitialised EVP_CIPHER_CTX on error (CID 483259).
(cherry picked from commit c1d1b0114e9d370c30649e46182393dbfc00e20c)
2014-07-10 17:49:53 +01:00
Matt Caswell
23bd628735 Fix memory leak in BIO_free if there is no destroy function.
Based on an original patch by Neitrino Photonov <neitrinoph@gmail.com>

PR#3439

(cherry picked from commit 66816c53bea0ecddb9448da7ea9a51a334496127)
2014-07-09 23:32:18 +01:00
Andy Polyakov
371feee876 x86_64 assembly pack: improve masm support.
(cherry picked from commit 1b0fe79f3ee27ebd20510da3af9ec04c6ee0f800)
2014-07-09 22:46:13 +02:00
Andy Polyakov
f50f0c6aa3 Please Clang's sanitizer, addendum.
(cherry picked from commit d11c70b2c2a655d112fa72d34c6702e9aa2eff79)
2014-07-09 22:45:52 +02:00
Andy Polyakov
2064e2db08 Please Clang's sanitizer.
PR: #3424,#3423,#3422
(cherry picked from commit 021e5043e524b1cb28a929ef902548a987c16e65)
2014-07-09 22:45:38 +02:00
Andy Polyakov
de222838fe apps/speed.c: fix compiler warnings in multiblock_speed().
(cherry picked from commit c4f8efab34af95a5319bbc5b954b62614604298a)
2014-07-07 17:03:27 +02:00
Andy Polyakov
0ad2a0a303 sha[1|512]-x86_64.pl: fix logical errors with $shaext=0.
(cherry picked from commit 07b635cceb60abaddba2f0e469e5f5978258f46b)
2014-07-07 17:02:00 +02:00
David Lloyd
2cb761c1f4 Prevent infinite loop loading config files.
PR#2985
(cherry picked from commit 9d23f422a32cb333a5e803199ae230706b1bf9f5)
2014-07-07 13:54:11 +01:00
Viktor Dukhovni
3ebcecf5c4 Improve X509_check_host() documentation.
Based on feedback from Jeffrey Walton.

(cherry picked from commit b73ac027357da29d9e393f24cd224999c94028d1)
2014-07-07 20:35:49 +10:00
Viktor Dukhovni
e83c913723 Update API to use (char *) for email addresses and hostnames
Reduces number of silly casts in OpenSSL code and likely most
applications.  Consistent with (char *) for "peername" value from
X509_check_host() and X509_VERIFY_PARAM_get0_peername().

(cherry picked from commit 297c67fcd817ea643de2fdeff4e434b050d571e2)
2014-07-07 19:20:34 +10:00
Viktor Dukhovni
55fe56837a Set optional peername when X509_check_host() succeeds.
Pass address of X509_VERIFY_PARAM_ID peername to X509_check_host().
Document modified interface.

(cherry picked from commit ced3d9158a7a8c676be504bb6cd3b5ffb7cc7f13)
2014-07-07 19:20:34 +10:00
Viktor Dukhovni
1eb57ae2b7 New peername element in X509_VERIFY_PARAM_ID
Declaration, memory management, accessor and documentation.

(cherry picked from commit 6e661d458f5aa8f52bf3d9098bd10025de5f08ea)
2014-07-07 19:20:34 +10:00
Viktor Dukhovni
41e3ebd5ab One more typo when changing !result to result <= 0
(cherry picked from commit eef1827f89ebb82d3bcb5391fa15e05061bab4b2)
2014-07-07 19:19:13 +10:00
Viktor Dukhovni
9624b50d51 Fix typo in last commit
(cherry picked from commit 90b70a6a6b4df267fea2724c7af37d93366a1fec)
2014-07-07 19:19:13 +10:00
Viktor Dukhovni
449d864515 Multiple verifier reference identities.
Implemented as STACK_OF(OPENSSL_STRING).

(cherry picked from commit 8abffa4a73fcbf6536e0a42d736ed9211a8204ea)
2014-07-07 19:19:13 +10:00
Viktor Dukhovni
7f7e11ee5c Implement sk_deep_copy.
(cherry picked from commit 66d884f06770f2daaee8016299ef7e1e3b91dfd1)
2014-07-07 19:19:13 +10:00
Dr. Stephen Henson
43f534b986 Usage for -hack and -prexit -verify_return_error
(cherry picked from commit ee724df75d9ad67fd954253ac514fddb46f1e3c6)
2014-07-06 22:45:20 +01:00
Dr. Stephen Henson
fbe8ea3abe Document certificate status request options.
(cherry picked from commit cba3f1c739f012aaadb85aaefaf8de424d2695e2)
2014-07-06 22:45:20 +01:00
Dr. Stephen Henson
affc941ea6 s_server usage for certificate status requests
(cherry picked from commit a44f219c009798054d6741e919cba5b2e656dbf4)
2014-07-06 22:45:20 +01:00
Dr. Stephen Henson
012f7474f7 Update ticket callback docs.
(cherry picked from commit a23a6e85d8dcd5733a343754f434201f3c9aa6f0)
2014-07-06 12:40:16 +01:00
Dr. Stephen Henson
5c1b373be6 Sanity check keylength in PVK files.
PR#2277
(cherry picked from commit 733a6c882e92f8221bd03a51643bb47f5f81bb81)
2014-07-06 00:36:14 +01:00
Jeffrey Walton
648a9f7c2f Added reference to platform specific cryptographic acceleration such as AES-NI 2014-07-06 00:04:09 +01:00
Matt Caswell
623acb90cc Fixed error in pod files with latest versions of pod2man
(cherry picked from commit 07255f0a76d9d349d915e14f969b9ff2ee0d1953)
2014-07-06 00:04:09 +01:00
Andy Polyakov
6ce295a301 sha512-x86_64.pl: fix typo.
PR: #3431
(cherry picked from commit 7eb9680ae1bf5dd9aeb61c401f2c3bd900ac9aeb)
2014-07-06 00:00:34 +02:00
Andy Polyakov
0359ccfd8b s3_pkt.c: fix typo.
(cherry picked from commit 0e7a32b55e8c5b1ec7c2bb755213d076390cc55e)
2014-07-05 23:57:28 +02:00
Andy Polyakov
9c1cf94f34 apps/speed.c: add multi-block benchmark.
(cherry picked from commit 375a64e3496c7576a7dbcfdf9a549bf2693506e8)
2014-07-05 23:54:43 +02:00
Alan Hryngle
ff5b11f547 Return smaller of ret and f.
PR#3418.
(cherry picked from commit fdea4fff8fb058be928980600b24cf4c62ef3630)
2014-07-05 22:38:17 +01:00
Dr. Stephen Henson
8358302d47 Don't limit message sizes in ssl3_get_cert_verify.
PR#319 (reoponed version).
(cherry picked from commit 7f6e9578648728478e84246fd3e64026b8b6a48e)
2014-07-05 13:30:38 +01:00
Dr. Stephen Henson
534656a997 Add license info.
(cherry picked from commit 55707a36cce3584457f687ff020842c079624ee8)
2014-07-04 18:43:06 +01:00
Dr. Stephen Henson
2cfbec1cae typo 2014-07-04 13:50:26 +01:00
Dr. Stephen Henson
22db480daf Remove all RFC5878 code.
Remove RFC5878 code. It is no longer needed for CT and has numerous bugs.
2014-07-04 13:42:05 +01:00
Rich Salz
d107382214 Merge branch 'rsalz-docfixes' 2014-07-03 12:57:16 -04:00
Rich Salz
03ae3ca621 Close 3170, remove reference to Ariel Glenn's old 0.9.8 doc
(cherry picked from commit f1112985e847286033ac573e70bdee752d26f46f)
2014-07-03 12:54:31 -04:00
Andy Polyakov
61df34e924 e_os.h: limit _MSC_VER trickery to older compilers.
PR: #3390
(cherry picked from commit aab3560b65b9254d17770bb6fe3ca7edd7451429)
2014-07-02 22:34:02 +02:00
Andy Polyakov
47b9e06cfd bn_exp.c: fix x86_64-specific crash with one-word modulus.
PR: #3397
(cherry picked from commit eca441b2b4d33d2a18d163ef9b4b3aff14251c73)
2014-07-02 21:16:45 +02:00
Matt Smart
88822622a1 Fix doc typo.
ERR_get_error(3) references the non-existent
ERR_get_last_error_line_data instead of the one that does exist,
ERR_peek_last_error_line_data.

PR#3283
(cherry picked from commit 5cc99c6cf5e908df6b00b04af7f08e99c0698c7b)
2014-07-02 03:45:01 +01:00
Thijs Alkemade
8f243ab6c1 Make disabling last cipher work.
(cherry picked from commit 7cb472bd0d0fd9da3d42bed1acc56c3a79fc5328)
2014-07-02 03:32:42 +01:00
Dr. Stephen Henson
9223a31eb7 ASN1 sanity check.
Primitive encodings shouldn't use indefinite length constructed
form.

PR#2438 (partial).
(cherry picked from commit 398e99fe5e06edb11f55a39ce0883d9aa633ffa9)
2014-07-02 00:59:44 +01:00
Dr. Stephen Henson
654ae3d6ad Accessor functions for app_data in ECDSA_METHOD
(cherry picked from commit 387b844ffdc79b733be0b1dbaddd2ac64a6c1192)
2014-07-02 00:59:43 +01:00
Ben Laurie
70c739b8db Fix possible buffer overrun.
(cherry picked from commit 2db3ea29298bdc347f15fbfab6d5746022f05101)

Conflicts:
	ssl/ssl_locl.h
	ssl/t1_lib.c
2014-07-02 00:09:39 +01:00
Andy Polyakov
daa96141d3 sha512-x86_64.pl: fix linking problem under Windows.
(cherry picked from commit 29be3f6411774e10169e60e1507df3d7c2e589df)
2014-07-01 17:12:41 +02:00
Dr. Stephen Henson
802fdcda1e Fix copy for CCM, GCM and XTS.
Internal pointers in CCM, GCM and XTS contexts should either be
NULL or set to point to the appropriate key schedule. This needs
to be adjusted when copying contexts.
(cherry picked from commit c2fd5d79ffc4fc9d120a0faad579ce96473e6a2f)
2014-06-30 13:59:38 +01:00
Dr. Stephen Henson
6006e352ad Make EVP_Digest* work again. 2014-06-30 13:59:29 +01:00
Dr. Stephen Henson
2af68ef774 Don't core dump when using CMAC with dgst.
We can't unfortunately print the CMAC cipher used without extending the API.

PR#2579
(cherry picked from commit 79e31a2842e10271581cbfdaae0145dd4bd35107)
2014-06-29 23:44:44 +01:00
Dr. Stephen Henson
df401f4796 Make CMAC work with EVP_PKEY.
Add patch originally accidentally omitted to allow CMAC to work with
EVP_PKEY APIs.
2014-06-29 23:44:44 +01:00
Jeffrey Walton
3875ee59ba Clarified that the signature's buffer size, s, is not used as an
IN parameter.

Under the old docs, the only thing stated was "at most
EVP_PKEY_size(pkey) bytes will be written". It was kind of misleading
since it appears EVP_PKEY_size(pkey) WILL be written regardless of the
signature's buffer size.

(cherry picked from commit 6e6ba36d980f67b6e5c7b139f78da7acbbf8ec76)
2014-06-29 23:36:22 +01:00
ZNV
14183e50e7 Make EVP_CIPHER_CTX_copy work in GCM mode.
PR#3272
(cherry picked from commit 370bf1d708e6d7af42e1752fb078d0822c9bc73d)
2014-06-29 22:02:23 +01:00
Dr. Stephen Henson
15de0f609c Fix memory leak.
PR#2531
(cherry picked from commit 44724beeadf95712a42a8b21dc71bf110e89a262)
2014-06-29 13:51:57 +01:00
Ken Ballou
4824e7d6e9 Typo.
PR#3173
(cherry picked from commit 76ed5a42ea68dd08bba44e4003b7e638e5d8a4a3)
2014-06-29 13:39:20 +01:00
Dr. Stephen Henson
a3b8cd242a Show errors on CSR verification failure.
If CSR verify fails in ca utility print out error messages.
Otherwise some errors give misleading output: for example
if the key size exceeds the library limit.

PR#2875
(cherry picked from commit a30bdb55d1361b9926eef8127debfc2e1bb8c484)
2014-06-29 13:34:25 +01:00
Dr. Stephen Henson
d1cc95f781 Make no-ssl3 no-ssl2 do more sensible things.
(cherry picked from commit 7ae6a4b659facfd7ad8131238aa1d349cb3fc951)
2014-06-29 03:05:21 +01:00
Dr. Stephen Henson
6d02baf6ab Clarify protocols supported.
Update protocols supported and note that SSLv2 is effectively disabled
by default.

PR#3184
(cherry picked from commit 1b13a4f38dfc385d5e776f6b3e06c5795874cf9b)
2014-06-29 00:07:07 +01:00
Andy Polyakov
377551b9c4 x86_64 assembly pack: refine clang detection.
(cherry picked from commit a356e488ad50ca9de3fc4955839441c5aff11ed3)

Resolved conflicts:

	crypto/bn/asm/rsaz-avx2.pl
2014-06-28 17:26:03 +02:00
Dr. Stephen Henson
361fd136e9 Typo.
PR#3107
(cherry picked from commit 7c206db9280865ae4af352dbc14e9019a6c4795d)
2014-06-28 12:42:59 +01:00
Dr. Stephen Henson
4950a528ce Don't disable state strings with no-ssl2
Some state strings were erronously not compiled when no-ssl2
was set.

PR#3295
(cherry picked from commit 0518a3e19e18cfc441cab261b28441b8c8bd77bf)
2014-06-28 00:56:27 +01:00
yogesh nagarkar
00ab230a3f Fix compilation with -DSSL_DEBUG -DTLS_DEBUG -DKSSL_DEBUG
PR#3141
(cherry picked from commit d183545d4589f1e7a40190400b8b99ea3d1f7f97)
2014-06-28 00:41:31 +01:00
Andreas Westfeld
e99980e8fd Fix typo in ideatest.c
(cherry picked from commit d1d4382dcb3fdcad4758ef7e7dd7b61dbf5abbfe)
2014-06-28 00:06:32 +01:00
Ken Ballou
ec77f276e1 Remove redundant check.
PR#3174
(cherry picked from commit fd331c0bb9b557903dd2ce88398570a3327b5ef0)
2014-06-27 23:19:37 +01:00
Dr. Stephen Henson
d0ba994483 Fix for EVP_PBE_alg_add().
In EVP_PBE_alg_add don't use the underlying NID for the cipher
as it may have a non-standard key size.

PR#3206
(cherry picked from commit efb7caef637a1de8468ca109efd355a9d0e73a45)
2014-06-27 23:19:37 +01:00
Andy Polyakov
52f856526c x86_64 assembly pack: addendum to last clang commit.
(cherry picked from commit 7eb048828008f195fb6edceb8f767622694e7426)
2014-06-27 22:55:22 +02:00
Andy Polyakov
912f08dd5e x86_64 assembly pack: allow clang to compile AVX code.
(cherry picked from commit ac171925ab527a55fbb27872ff69af94f7ec995b)
2014-06-27 22:55:07 +02:00
Andy Polyakov
1067663d85 bn/asm/rsaz-avx2.pl: fix occasional failures.
(cherry picked from commit 406d4af050cff0f52c5435504186eaf03ca69698)
2014-06-27 22:43:43 +02:00
Dr. Stephen Henson
22228d2d40 Tolerate critical AKID in CRLs.
PR#3014
(cherry picked from commit 11da66f8b1fbe5777fe08cc6ace9e1f2c1576a50)
2014-06-27 18:50:19 +01:00
Tom Greenslade
c57745596c Handle IPv6 addresses in OCSP_parse_url.
PR#2783
(cherry picked from commit b36f35cda964544a15d53d3fdfec9b2bab8cacb1)
2014-06-27 17:31:37 +01:00
Dr. Stephen Henson
65e4dca40c Rebuild OID table. 2014-06-27 16:58:41 +01:00
Dr. Stephen Henson
ff4cfc4c58 Fix OID encoding for one component.
OIDs with one component don't have an encoding.

PR#2556 (Bug#1)
(cherry picked from commit 95791bf94150f2e3dc96fd2462627aaf354e92e4)
2014-06-27 16:58:16 +01:00
Tomas Mraz
f4623ab996 Don't advertise ECC ciphersuits in SSLv2 compatible client hello.
PR#3374
(cherry picked from commit 0436369fccd128cb7f6a8538d5fed1c876c437af)
2014-06-27 16:52:00 +01:00
Jeffrey Walton
6ef350952c Clarify docs.
Document that the certificate passed to SSL_CTX_add_extra_chain_cert()
should not be freed by the application.

PR#3409
(cherry picked from commit 0535c2d67ca2d684087ef90be35d5fb207aab227)
2014-06-27 16:39:39 +01:00
Dr. Stephen Henson
e42c208235 Memory leak and NULL dereference fixes.
PR#3403
(cherry picked from commit d2aea038297e0c64ca66e6844cbb37377365885e)
2014-06-27 14:52:36 +01:00
Dr. Stephen Henson
e86951ca2a Remove ancient obsolete files under pkcs7.
(cherry picked from commit 7be6b27aaf5ed77f13c93dc89a2c27a42082db3f)
2014-06-27 13:53:23 +01:00
Huzaifa Sidhpurwala
b7a4f98b15 Make sure BN_sqr can never return a negative value.
PR#3410
(cherry picked from commit e14e764c0d5d469da63d0819c6ffc0e1e9e7f0bb)
2014-06-26 23:56:32 +01:00
Andy Polyakov
82a9dafe32 bn_exp.c: move check for AD*X to rsaz-avx2.pl.
This ensures high performance is situations when assembler supports
AVX2, but not AD*X.
(cherry picked from commit f3f620e1e0fa3553116f0b3e8c8d68b070fcdb79)

Resolved conflicts:

	crypto/bn/asm/rsaz-avx2.pl
2014-06-27 00:36:05 +02:00
Andy Polyakov
1536bcfd56 aesv8-armx.pl: rigid input verification in key setup.
(cherry picked from commit 7b8c8c4d7973f17bbbee45d4718224c5853d9dc7)
2014-06-25 22:12:08 +02:00
Viktor Dukhovni
3fc0b1edad X509_check_mumble() failure is <= 0, not just 0
(cherry picked from commit a48fb0400c9c45d56144966b774998ebe37804ef)
2014-06-25 18:21:36 +01:00
Viktor Dukhovni
3d15d58e55 More complete input validation of X509_check_mumble
(cherry picked from commit 29edebe95c2a51470c78c7e769c926719965eeb1)
2014-06-25 18:21:35 +01:00
Viktor Dukhovni
d93edc0aab Drop hostlen from X509_VERIFY_PARAM_ID.
Just store NUL-terminated strings.  This works better when we add
support for multiple hostnames.
(cherry picked from commit b3012c698a086937319ed413a113ed7bec1edd1a)
2014-06-25 18:21:35 +01:00
Viktor Dukhovni
609daababb More complete X509_check_host documentation.
(cherry picked from commit d241b804099ce28c053ba988eb5532b1a32dd51e)
2014-06-25 18:21:35 +01:00
Andy Polyakov
a073ceeff4 aesv8-armx.pl: inclrease interleave factor.
This is to compensate for higher aes* instruction latency on Cortex-A57.
(cherry picked from commit 015364baf3328b93dbed2613e59170715a2a11a6)
2014-06-24 08:10:37 +02:00
Andy Polyakov
5cd8ce42ec ARMv8 assembly pack: add Cortex performance numbers.
(cherry picked from commit 0f777aeb50b109052d41b8a55d97faecf728ea00)
2014-06-24 08:07:04 +02:00
Miod Vallat
d15f2d98ef Fix off-by-one errors in ssl_cipher_get_evp()
In the ssl_cipher_get_evp() function, fix off-by-one errors in index validation before accessing arrays.

Bug discovered and fixed by Miod Vallat from the OpenBSD team.

PR#3375
2014-06-22 23:18:15 +01:00
Matt Caswell
00f5ee445b Revert "Fix off-by-one errors in ssl_cipher_get_evp()"
This reverts commit 3d86077427f93dc46b18fee706b567ec32ac232a.

Incorrect attribution.
2014-06-22 23:17:40 +01:00
Matt Caswell
e7911530a9 Fixed Windows compilation failure 2014-06-22 20:18:09 +02:00
Richard Levitte
6ff73426c3 Make sure test/tests.com exit gracefully, even when openssl.exe wasn't
properly built.
2014-06-18 13:43:10 +02:00
Richard Levitte
a61e509e9b Adjust VMS build to Unix build. Most of all, make it so the disabled
algorithms MD2 and RC5 don't get built.
Also, disable building the test apps in crypto/des and crypto/pkcs7, as
they have no support at all.
2014-06-18 13:43:09 +02:00
Felix Laurie von Massenbach
1b823494de Fix signed/unsigned comparisons.
(cherry picked from commit 50cc4f7b3d64621b6062ad1f16a7630b7c730d9b)
2014-06-17 18:38:36 +01:00
Felix Laurie von Massenbach
6657e68bf2 Fix shadow declaration.
(cherry picked from commit 1f61d8b5b1bda282015236fe9860d2f6de127356)
2014-06-17 18:36:48 +01:00
Richard Levitte
23351c607b Remove unused DANE macros. This should be the last DANE stuff... 2014-06-17 12:38:20 +02:00
Richard Levitte
9a6112d16a DCL doesn't do well with empty lines, or lines starting with # 2014-06-16 13:25:16 +02:00
Richard Levitte
b9c0dae28e Spaces were added in some strings for better readability. However, those spaces do not belong in file names, so when picking out the individual parts, remove the spaces 2014-06-16 13:25:16 +02:00
Andy Polyakov
d940b3b9c7 aesni-sha[1|256]-x86_64.pl: fix logical error and MacOS X build.
(cherry picked from commit 9024b84b7c9a36f75bffc5c77cc86bbe2911653e)
2014-06-16 10:12:56 +02:00
Viktor Dukhovni
cfbc10fb32 Enforce _X509_CHECK_FLAG_DOT_SUBDOMAINS internal-only
(cherry picked from commit d435e23959f1c2cb4feadbfba9ad884c59f37db9)
2014-06-14 22:31:28 +01:00
Dr. Stephen Henson
90d94ce39e Accept CCS after sending finished.
Allow CCS after finished has been sent by client: at this point
keys have been correctly set up so it is OK to accept CCS from
server. Without this renegotiation can sometimes fail.

PR#3400
(cherry picked from commit 99cd6a91fcb0931feaebbb4832681d40a66fad41)
2014-06-14 22:31:28 +01:00
Andy Polyakov
79b960c046 evp/e_aes_cbc_sha[1|256].c: fix -DPEDANTIC build.
(cherry picked from commit ce00c64df9eb78402950e179b54e7745210b04f2)
2014-06-14 23:16:29 +02:00
Richard Levitte
66a6e2b2b6 Adjust VMS build files to the Unix ones 2014-06-14 16:58:11 +02:00
Richard Levitte
1be1d05184 Make sure that disabling the MAYLOSEDATA3 warning is only done when the
compiler supports it.  Otherwise, there are warnings about it lacking
everywhere, which is quite tedious to read through while trying to check
for other warnings.
2014-06-14 16:58:11 +02:00
Richard Levitte
9f8c183283 Update the VMS tests according to the latest unixly tests.
Partly provided by Zoltan Arpadffy <arpadffy@polarhome.com>
2014-06-14 16:58:11 +02:00
Andy Polyakov
8301245a5e aesni-sha256-x86_64.pl: add missing rex in shaext.
PR: 3405
(cherry picked from commit 91a6bf80f8af5fcafececc443e7fbc7981af127b)
2014-06-14 16:04:04 +02:00
Andy Polyakov
1f6d207625 sha1-x86_64.pl: add missing rex prefix in shaext.
PR: 3405
(cherry picked from commit c9cf29cca22d4d724a1e772bc5fdc201b2822f1d)
2014-06-14 15:28:38 +02:00
Matt Caswell
561ba12463 Fixed incorrect return code handling in ssl3_final_finish_mac.
Based on an original patch by Joel Sing (OpenBSD) who also originally identified the issue.
2014-06-13 15:50:58 +01:00
Matt Caswell
7f133c357b Revert "Fixed incorrect return code handling in ssl3_final_finish_mac"
This reverts commit 728bd41a159ea16a60111e7c1120ec2a005507b3.

Missing attribution.
2014-06-13 15:50:28 +01:00
Viktor Dukhovni
3cc8a3f234 Client-side namecheck wildcards.
A client reference identity of ".example.com" matches a server
certificate presented identity that is any sub-domain of "example.com"
(e.g. "www.sub.example.com).

With the X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS flag, it matches
only direct child sub-domains (e.g. "www.sub.example.com").
(cherry picked from commit e52c52f10bb8e34aaf8f28f3e5b56939e8f6b357)
2014-06-12 23:19:24 +01:00
Kurt Cancemi
3d86077427 Fix off-by-one errors in ssl_cipher_get_evp()
In the ssl_cipher_get_evp() function, fix off-by-one errors in index validation before accessing arrays.

PR#3375
2014-06-12 21:12:43 +01:00
Andy Polyakov
56ba280ccd Facilitate back-porting of AESNI and SHA modules.
Fix SEH and stack handling in Win64 build.
(cherry picked from commit 977f32e85241cba8be53e44dade32231e8a91718)
2014-06-12 21:51:35 +02:00
Matt Caswell
955bfbc268 Added OPENSSL_assert check as per PR#3377 reported by Rainer Jung <rainer.jung@kippdata.de> 2014-06-12 20:42:33 +01:00
Dr. Stephen Henson
2eab488c02 remove some more DANE code 2014-06-12 11:09:14 +01:00
Dr. Stephen Henson
fa7a0efbac make update 2014-06-12 10:52:49 +01:00
Dr. Stephen Henson
3fe8f005b0 Fix Windows build. 2014-06-12 10:52:49 +01:00
Dr. Stephen Henson
5af09776ce Remove unimplemented functions. 2014-06-12 10:52:49 +01:00
Richard Levitte
995d08d104 Update the VMS build according to the latest unixly build.
Partly provided by Zoltan Arpadffy <arpadffy@polarhome.com>
2014-06-12 16:59:47 +02:00
Richard Levitte
ca422f3563 The 1.0.2 cms-test.pl had some changes that don't quite work on VMS... 2014-06-12 16:58:39 +02:00
Richard Levitte
68a1e0bc35 Bring in the 1.0.1g to 1.0.1h changes into CHANGES. 2014-06-12 12:22:24 +02:00
Richard Levitte
ed6c278f60 Small cleanup, double entry in CHANGES. 2014-06-12 12:18:13 +02:00
Andy Polyakov
d85a772ec3 Enable multi-block support by default.
(cherry picked from commit 77a27a5066e8c0975d78be635ed356749a6f16db)
2014-06-11 20:41:46 +02:00
Dr. Stephen Henson
fb2f9f266c Fix compilation with no-comp
(cherry picked from commit 7239a09c7b5757ed8d0e9869f3e9b03c0e11f4d1)
2014-06-11 14:41:00 +01:00
Andy Polyakov
66aeaec067 ghash-x86_64.pl: optimize for upcoming Atom.
(cherry picked from commit 1cf8f57b43a99275ac0938e9e230bd0434699d87)
2014-06-11 11:35:23 +02:00
Andy Polyakov
70fddbe32a Add support for Intel SHA extension.
(cherry picked from commit 619b94667cc7a097f6d1e2123c4f4c2c85afb8f7)
2014-06-11 10:30:31 +02:00
Rob Stradling
5fc3d333c7 Separate the SCT List parser from the SCT List viewer
(cherry picked from commit fd2309aa29e3ea00e445f03407820398962c0b94)
2014-06-11 00:10:45 +01:00
Matt Caswell
728bd41a15 Fixed incorrect return code handling in ssl3_final_finish_mac 2014-06-10 23:32:27 +01:00
Andy Polyakov
77fb5a303b Engage GHASH for ARMv8.
(cherry picked from commit 82741e9c8980f96e4b3bba9e54e5904bc3e385bd)
2014-06-11 00:10:00 +02:00
Andy Polyakov
7344089dc3 Add GHASH for ARMv8 Crypto Extension.
Result of joint effort with Ard Biesheuvel.
(cherry picked from commit 2d5a799d27d36ee0477b2e05a7aa14394e3ad4fc)
2014-06-11 00:09:35 +02:00
Andy Polyakov
7e03acf2be Engage ARMv8 AES support [from HEAD]. 2014-06-11 00:08:03 +02:00
Andy Polyakov
9af4cb3d3b Add AES module for ARMv8 Crypto Extension [from HEAD]. 2014-06-11 00:06:27 +02:00
Andy Polyakov
a00caa0257 sha[1|512]-armv8.pl: get instruction endianness right.
Submitted by: Ard Biesheuvel.
(cherry picked from commit cd91fd7c32428c0deb503f19b8061e0980476876)
2014-06-10 23:34:53 +02:00
Andy Polyakov
4672acfa7d linux-aarch64: engage SHA modules.
(cherry picked from commit f8aab6174c217fe4764652dab926e434e7838ce8)
2014-06-10 23:32:26 +02:00
Andy Polyakov
ea61b32719 Add SHA for ARMv8.
(cherry picked from commit ddb6b965da0087dadea5488fe11646e3777c66e1)
2014-06-10 23:32:16 +02:00
Andy Polyakov
dabfbea7d9 Add linux-aarch64 taget.
armcap.c is shared between 32- and 64-bit builds and features link-time
detection of getauxval.

Submitted by: Ard Biesheuvel.
(cherry picked from commit e8d93e342b4b7d43c73e955e81e227c514d389d9)
2014-06-10 23:20:55 +02:00
Andy Polyakov
56d973709c aesni-mb-x86_64.pl: add Win64 SEH.
(cherry picked from commit e2eabed110b6d88fd15ac3063cab23dcd5090b44)
2014-06-10 23:09:04 +02:00
Andy Polyakov
3a97ebb16b ARM assembly pack: get ARMv7 instruction endianness right.
Pointer out and suggested by: Ard Biesheuvel.
(cherry picked from commit 5dcf70a1c57c2019bfad640fe14fd4a73212860a)
2014-06-10 22:51:15 +02:00
Andy Polyakov
16f4d2e32f armv4cpuid.S: switch to CNTVCT tick counter.
(cherry picked from commit 723463282fab13a686a30779c401b98b82134a62)
2014-06-10 22:50:18 +02:00
Andy Polyakov
1f72a76f98 sha[1|256]-armv4: harmonize with arm_arch.h.
(cherry picked from commit 797d24bee9523e5cac14fe82a4dad356d1ec67f9)
2014-06-10 22:49:54 +02:00
Andy Polyakov
f5247cea39 sha/asm/sha1-armv4-large.pl: add NEON and ARMv8 code paths.
sha/asm/sha256-armv4.pl: add ARMv8 code path.
(cherry picked from commit 9250a30692e182957d3fe48e3e07b1824ca1453a)
2014-06-10 22:48:27 +02:00
Andy Polyakov
3da2c3df78 crypto/armcap.c: detect ARMv8 capabilities [in 32-bit build].
(cherry picked from commit 4afa9f033dd58465b4c2d119a9d8cd737edeba26)
2014-06-10 22:47:19 +02:00
Hubert Kario
4ceddeea6c backport changes to ciphers(1) man page
Backport of patch:
add ECC strings to ciphers(1), point out difference between DH and ECDH

and backport of other other assorted fixes to this man page

 * Make a clear distinction between DH and ECDH key exchange.
 * Group all key exchange cipher suite identifiers, first DH then ECDH
 * add descriptions for all supported *DH* identifiers
 * add ECDSA authentication descriptions
 * add example showing how to disable all suites that offer no
   authentication or encryption
 * update status of static DH (it's now supported)
 * backport descriptions of AES128, AES256, AESGCM
 * backport descriptions of CAMELLIA128, CAMELLIA256
 * backport listing of standard names for ECC cipher suites
   and TLSv1.2 cipher suites
 * backport description of PSK cipher suites
2014-06-10 20:55:14 +01:00
Mike Bland
2fddc5fc09 Create test/testutil.h for unit test helper macros
Defines SETUP_TEST_FIXTURE and EXECUTE_TEST, and updates ssl/heartbeat_test.c
using these macros. SETUP_TEST_FIXTURE makes use of the new TEST_CASE_NAME
macro, defined to use __func__ or __FUNCTION__ on platforms that support those
symbols, or to use the file name and line number otherwise. This should fix
several reported build problems related to lack of C99 support.
2014-06-10 19:24:46 +01:00
Dr. Stephen Henson
e3beef1e1b Remove experimental DANE code.
Remove experimental DANE/dnssec code: not ready for use in an
official release yet.
2014-06-10 14:59:10 +01:00
Dr. Stephen Henson
cea5a1d5f2 Fix null pointer errors.
PR#3394
(cherry picked from commit 7a9d59c148b773f59a41f8697eeecf369a0974c2)
2014-06-10 14:48:02 +01:00
Dr. Stephen Henson
f472ada006 SRP ciphersuite correction.
SRP ciphersuites do not have no authentication. They have authentication
based on SRP. Add new SRP authentication flag and cipher string.
(cherry picked from commit a86b88acc373ac1fb0ca709a5fb8a8fa74683f67)
2014-06-09 12:09:51 +01:00
Dr. Stephen Henson
05b2210476 Update strength_bits for 3DES.
Fix strength_bits to 112 for 3DES.
(cherry picked from commit 837c203719205ab19b5609b2df7151be8df05687)
2014-06-09 12:09:51 +01:00
Kurt Roeckx
33e1a1d652 Link heartbeat_test with the static version of the libraries
It's using an internal API that that might not be available in the shared
library.
2014-06-09 00:12:37 +01:00
Jakub Wilk
38956b071a Create ~/.rnd with mode 0600 instead of 0666
Because of a missing include <fcntl.h> we don't have O_CREATE and don't create
the file with open() using mode 0600 but fall back to using fopen() with the
default umask followed by a chmod().

Problem found by Jakub Wilk <jwilk@debian.org>.
2014-06-08 21:20:34 +01:00
Dr. Stephen Henson
a21f350a76 Make tls_session_secret_cb work with CVE-2014-0224 fix.
If application uses tls_session_secret_cb for session resumption
set the CCS_OK flag.
(cherry picked from commit 953c592572e8811b7956cc09fbd8e98037068b58)
2014-06-07 15:27:23 +01:00
Dr. Stephen Henson
74360af359 Update NEWS. 2014-06-07 15:27:23 +01:00
Matt Caswell
5400882ca3 Fixed minor duplication in docs 2014-06-07 12:31:38 +01:00
Dr. Stephen Henson
eb6508d50c Fix for CVE-2014-0195
A buffer overrun attack can be triggered by sending invalid DTLS fragments
to an OpenSSL DTLS client or server. This is potentially exploitable to
run arbitrary code on a vulnerable client or server.

Fixed by adding consistency check for DTLS fragments.

Thanks to Jüri Aedla for reporting this issue.
(cherry picked from commit 1632ef744872edc2aa2a53d487d3e79c965a4ad3)
2014-06-05 13:24:50 +01:00
Dr. Stephen Henson
77719aefb8 Fix for CVE-2014-0224
Only accept change cipher spec when it is expected instead of at any
time. This prevents premature setting of session keys before the master
secret is determined which an attacker could use as a MITM attack.

Thanks to KIKUCHI Masashi (Lepidum Co. Ltd.) for reporting this issue
and providing the initial fix this patch is based on.
(cherry picked from commit bc8923b1ec9c467755cd86f7848c50ee8812e441)
2014-06-05 13:24:46 +01:00
Dr. Stephen Henson
9d2c9dd1e1 Additional CVE-2014-0224 protection.
Return a fatal error if an attempt is made to use a zero length
master secret.
(cherry picked from commit 006cd7083f76ed5cb0d9a914857e9231ef1bc317)
2014-06-05 13:24:40 +01:00
Dr. Stephen Henson
8942b92c7c Fix CVE-2014-0221
Unnecessary recursion when receiving a DTLS hello request can be used to
crash a DTLS client. Fixed by handling DTLS hello request without recursion.

Thanks to Imre Rad (Search-Lab Ltd.) for discovering this issue.
(cherry picked from commit d3152655d5319ce883c8e3ac4b99f8de4c59d846)
2014-06-05 13:24:36 +01:00
Dr. Stephen Henson
e5f706590c Fix CVE-2014-3470
Check session_cert is not NULL before dereferencing it.
(cherry picked from commit 8011cd56e39a433b1837465259a9bd24a38727fb)
2014-06-05 13:24:30 +01:00
Libor Krystek
a5d03c54ab Corrected OPENSSL_NO_EC_NISTP_64_GCC_128 usage in ec_lcl.h. PR#3370 2014-06-03 23:17:21 +01:00
David Benjamin
56b94a38b9 Check there is enough room for extension.
(cherry picked from commit 7d89b3bf42e4b4067371ab33ef7631434e41d1e4)
2014-06-02 18:59:48 +01:00
zhu qun-ying
d52eb82781 Free up s->d1->buffered_app_data.q properly.
PR#3286
(cherry picked from commit 71e95000afb2227fe5cac1c79ae884338bcd8d0b)
2014-06-02 14:40:05 +01:00
Dr. Stephen Henson
4967a832ab Allow reordering of certificates when signing.
Add certificates if -nocerts and -certfile specified when signing
in smime application. This can be used this to specify the
order certificates appear in the PKCS#7 structure: some broken
applications require a certain ordering.

PR#3316
(cherry picked from commit e114abee9ec084a56c1d6076ac6de8a7a3a5cf34)
2014-06-02 14:19:43 +01:00
Sami Farin
6468866823 Typo: set i to -1 before goto.
PR#3302
(cherry picked from commit 9717f01951f976f76dd40a38d9fc7307057fa4c4)
2014-06-02 13:53:54 +01:00
Matt Caswell
de8a5b523f Added SSLErr call for internal error in dtls1_buffer_record 2014-06-01 21:40:31 +01:00
David Ramos
8de85b0048 Delays the queue insertion until after the ssl3_setup_buffers() call due to use-after-free bug. PR#3362 2014-06-01 21:40:25 +01:00
Dr. Stephen Henson
8d71574142 Recognise padding extension.
(cherry picked from commit ea2bb861f0daaa20819bf9ac8c146f7593feacd4)

Conflicts:

	apps/s_cb.c
2014-06-01 16:50:25 +01:00
Dr. Stephen Henson
623a01df49 Option to disable padding extension.
Add TLS padding extension to SSL_OP_ALL so it is used with other
"bugs" options and can be turned off.

This replaces SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG which is an ancient
option referring to SSLv2 and SSLREF.

PR#3336
(cherry picked from commit 758415b2259fa45d3fe17d8e53ae1341b7b6e482)

Conflicts:

	ssl/t1_lib.c
2014-06-01 16:50:25 +01:00
Dr. Stephen Henson
08b172b975 Set default global mask to UTF8 only.
(cherry picked from commit 3009244da47b989c4cc59ba02cf81a4e9d8f8431)
2014-06-01 15:04:21 +01:00
David Ramos
856a4585d6 Allocate extra space when NETSCAPE_HANG_BUG defined.
Make sure there is an extra 4 bytes for server done message when
NETSCAPE_HANG_BUG is defined.

PR#3361
(cherry picked from commit 92d81ba622396425764d676ba4fb3f0dac273f17)
2014-06-01 14:27:58 +01:00
David Ramos
3329765bba Initialise alg.
PR#3313
(cherry picked from commit 7e2c6f7eb01515a990f77fbc5441be8e1a17152a)
2014-06-01 13:05:08 +01:00
Dr. Stephen Henson
87a0cbdf2e Use correct digest when exporting keying material.
PR#3319
(cherry picked from commit 84691390eae86befd33c83721dacedb539ae34e6)
2014-05-30 13:24:36 +01:00
Dr. Stephen Henson
b5bdde9e0e Don't compile heartbeat test code on Windows (for now).
(cherry picked from commit 2c575907d2c8601a18716f718ce309ed4e1f1783)
2014-05-30 13:12:26 +01:00
Dr. Stephen Henson
1788072b9e Set version number correctly.
PR#3249
(cherry picked from commit 8909bf20269035d295743fca559207ef2eb84eb3)
2014-05-29 14:08:54 +01:00
František Bořánek
5f2b5e3823 Fix memory leak.
PR#3278
(cherry picked from commit de56fe797081fc09ebd1add06d6e2df42a324fd5)
2014-05-29 13:49:50 +01:00
Martin Kaiser
42d73874ed remove duplicate 0x for default RSASSA-PSS salt len
(cherry picked from commit 3820fec3a09faecba7fe9912aa20ef7fcda8337b)
2014-05-29 13:32:41 +01:00
Matt Caswell
88d3d6c9ae Fixed error in args for SSL_set_msg_callback and SSL_set_msg_callback_arg 2014-05-25 23:47:32 +01:00
Ben Laurie
3435ef467f Only copy opensslconf.h at init time. 2014-05-24 15:48:24 +01:00
Andy Polyakov
c90c694bc4 vpaes-ppc.pl: comply with ABI.
(cherry picked from commit b83d09f5528990364e0f7ed498eb8a9b56d95b58)
2014-05-23 20:16:21 +02:00
Mike Bland
8db2ba4b84 Fix heartbeat_test for -DOPENSSL_NO_HEARTBEATS
Replaces the entire test with a trivial implementation when
OPENSSL_NO_HEARTBEATS is defined.
2014-05-22 22:02:46 +01:00
Ben Laurie
d77501d8fd Check length first in BUF_strnlen(). 2014-05-22 10:12:10 +01:00
Matt Caswell
15e4565984 Fixed minor copy&paste error, and stray space causing rendering problem 2014-05-22 00:11:40 +01:00
Matt Caswell
5757766550 Fixed unterminated B tag, causing build to fail with newer pod2man versions 2014-05-22 00:01:33 +01:00
Ben Laurie
4f7236edc7 Remove redundant test. 2014-05-21 12:03:50 +01:00
Ben Laurie
ed693e4332 Implement BUF_strnlen() and use it instead of strlen(). 2014-05-21 11:56:21 +01:00
Viktor Dukhovni
a2219f6be3 Fixes to host checking.
Fixes to host checking wild card support and add support for
setting host checking flags when verifying a certificate
chain.
(cherry picked from commit 397a8e747dc3f964196caed5ca4e08d4b598362a)
2014-05-21 11:32:19 +01:00
Dr. Stephen Henson
03b5b78c09 Fix for PKCS12_create if no-rc2 specified.
Use triple DES for certificate encryption if no-rc2 is
specified.

PR#3357
2014-05-21 11:28:57 +01:00
Dr. Stephen Henson
cd302feb5d Change default cipher in smime app to des3.
PR#3357
(cherry picked from commit ca3ffd9670f2b589bf8cc04923f953e06d6fbc58)
2014-05-21 11:28:57 +01:00
Ben Laurie
5cd1a6fc3e Fix signed/unsigned warning. 2014-05-20 15:14:30 +01:00
Ben Laurie
4ceb430a46 Don't allocate more than is needed in BUF_strndup(). 2014-05-20 13:53:35 +01:00
Dr. Stephen Henson
81ce94f8dc For portability use BUF_strndup instead of strndup.
(cherry picked from commit dcca7b13e9066443237dd3001ae52fd103151c98)
2014-05-20 11:22:33 +01:00
Dr. Stephen Henson
feaa3b380b Adding padding extension to trace code.
(cherry picked from commit 6db14dbc514d6b8017827baebea4c75af8bb1976)
2014-05-20 11:22:15 +01:00
Janpopan
5d8e9f2ae0 Fix a wrong parameter count ERR_add_error_data 2014-05-19 22:15:27 +01:00
Ben Laurie
6c1d36a649 Merge branch 'mbland-heartbeat-test-1.0.2' into OpenSSL_1_0_2-stable 2014-05-19 18:04:41 +01:00
Mike Bland
2312a84ca1 Unit/regression test for TLS heartbeats.
Regression test against CVE-2014-0160 (Heartbleed).

More info: http://mike-bland.com/tags/heartbleed.html

(based on commit 35cb55988b75573105eefd00d27d0138eebe40b1)
2014-05-18 10:23:59 -04:00
Matt Caswell
a99d2a22e1 Moved note about lack of support for AEAD modes out of BUGS section to SUPPORTED CIPHERS section (bug has been fixed, but still no support for AEAD) 2014-05-15 21:15:21 +01:00
Dr. Stephen Henson
2fa65aa7d8 Enc doesn't support AEAD ciphers.
(cherry picked from commit 09184dddead165901700b31eb39d540ba30f93c5)
2014-05-15 14:16:45 +01:00
Jeffrey Walton
4907cf0845 Fix grammar error in verify pod. PR#3355 2014-05-14 22:58:19 +01:00
Jeffrey Walton
28b4820f70 Add information to BUGS section of enc documentation. PR#3354 2014-05-14 22:58:19 +01:00
Michal Bozon
72967d5be9 Corrected POD syntax errors. PR#3353 2014-05-14 22:58:19 +01:00
Mike Frysinger
4aebb2c8b8 Have the .pc files depend on each other rather than duplicating the
various link settings. PR#3332
2014-05-12 23:33:35 +01:00
Kurt Roeckx
1f5bce2dce Check sk_SSL_CIPHER_num() after assigning sk. 2014-05-12 22:59:11 +01:00
Jean-Paul Calderone
b953b02849 Correct the return type on the signature for X509_STORE_CTX_get_ex_data given in the pod file. 2014-05-12 22:49:00 +01:00
Serguei E. Leontiev
d6e55b4001 Replace manual ASN1 decoder with ASN1_get_object
Replace manual ASN.1 decoder with ASN1_get object. This
will decode the tag and length properly and check against
it does not exceed the supplied buffer length.

PR#3335
(cherry picked from commit b0308dddd1cc6a8e1de803ef29ba6da25ee072c2)
2014-05-12 18:41:51 +01:00
Matt Caswell
f710c3f198 Fixed NULL pointer dereference. See PR#3321 2014-05-12 00:39:43 +01:00
Kurt Roeckx
99a3d167d9 Set authkey to NULL and check malloc return value. 2014-05-12 00:22:52 +01:00
Martin Brejcha
c622649513 dgram_sctp_ctrl: authkey memory leak
PR: 3327
2014-05-12 00:22:52 +01:00
Günther Noack
8571902e23 Avoid out-of-bounds write in SSL_get_shared_ciphers
PR: 3317
2014-05-11 23:55:06 +01:00
Viktor Dukhovni
711bb9bc88 Fix infinite loop. PR#3347 2014-05-11 21:09:56 +01:00
Matt Caswell
f2ebe2a60e Move length check earlier to ensure we don't go beyond the end of the user's buffer. PR#3320 2014-05-11 11:32:17 +01:00
Tim Hudson
011ee91105 safety check to ensure we dont send out beyond the users buffer 2014-05-11 11:32:17 +01:00
Dr. Stephen Henson
2c4144638a Return an error if no recipient type matches.
If the key type does not match any CMS recipient type return
an error instead of using a random key (MMA mitigation). This
does not leak any useful information to an attacker.

PR#3348
(cherry picked from commit bd43b4cf778a53ffa5d77510ecd408a009dc00d2)
2014-05-09 14:24:53 +01:00
Tim Hudson
2fc04cb872 coverity 966576 - close socket in error path 2014-05-08 23:22:28 +01:00
Tim Hudson
62cc5ff623 PR#3342 fix resource leak coverity issue 966577 2014-05-08 23:22:21 +01:00
Tim Hudson
afe343c3a7 fix coverity issue 966597 - error line is not always initialised 2014-05-07 23:57:00 +01:00
Matt Caswell
e0d2139045 Fixed NULL pointer dereference in PKCS7_dataDecode reported by David Ramos in PR#3339 2014-05-07 23:23:15 +01:00
Geoff Thorpe
d60f019321 dso: eliminate VMS code on non-VMS systems
Even though the meat of dso_vms.c is compiled out on non-VMS builds,
the (pre-)compiler still traverses some of the macro handling. This
trips up at least one non-VMS build configuration, so this commit
makes the skip-VMS case more robust.

Signed-off-by: Geoff Thorpe <geoff@openssl.org>
2014-05-06 18:03:52 -04:00
Geoff Thorpe
65402586c0 evp: prevent underflow in base64 decoding
This patch resolves RT ticket #2608.

Thanks to Robert Dugal for originally spotting this, and to David
Ramos for noticing that the ball had been dropped.

Signed-off-by: Geoff Thorpe <geoff@openssl.org>
2014-05-06 18:02:02 -04:00
Geoff Thorpe
bf43446835 bignum: allow concurrent BN_MONT_CTX_set_locked()
The lazy-initialisation of BN_MONT_CTX was serialising all threads, as
noted by Daniel Sands and co at Sandia. This was to handle the case that
2 or more threads race to lazy-init the same context, but stunted all
scalability in the case where 2 or more threads are doing unrelated
things! We favour the latter case by punishing the former. The init work
gets done by each thread that finds the context to be uninitialised, and
we then lock the "set" logic after that work is done - the winning
thread's work gets used, the losing threads throw away what they've done.

Signed-off-by: Geoff Thorpe <geoff@openssl.org>
2014-05-06 18:01:59 -04:00
Dr. Stephen Henson
7169e56d6b Initialize num properly.
PR#3289
PR#3345
(cherry picked from commit 3ba1e406c2309adb427ced9815ebf05f5b58d155)
2014-05-06 14:09:07 +01:00
Dr. Stephen Henson
1047b8c84d Set Enveloped data version to 2 if ktri version not zero.
(cherry picked from commit 546b1b438468e629eea4e836190b1bb056e39286)
2014-05-06 14:00:11 +01:00
Tim Hudson
9740a03695 - fix coverity issues 966593-966596 2014-05-06 00:04:59 +01:00
David Ramos
e34af3ec2b Double free in i2o_ECPublicKey
PR: 3338
2014-05-04 00:50:42 +01:00
Jeff Trawick
d576146ebf typo in SSL_get_peer_cert_chain docs
RT: 3304
2014-05-02 00:26:05 +01:00
Matt Caswell
7441e7dbe9 Fixed spelling error in error message. Fix supplied by Marcos Marado 2014-05-01 00:27:02 +01:00
Matt Caswell
1d3f432b53 Fixed various pod errors 2014-05-01 00:07:28 +01:00
Lubomir Rintel
15a4add72d POD: Fix item numbering
Newer pod2man considers =item [1-9] part of a numbered list, while =item
0 starts an unnumbered list. Add a zero effect formatting mark to override
this.

doc/apps/smime.pod around line 315: Expected text after =item, not a
number
...

PR#3146
2014-04-30 23:44:54 +01:00
Geoff Thorpe
3cc546a3bb bignum: fix boundary condition in montgomery logic
It's not clear whether this inconsistency could lead to an actual
computation error, but it involved a BIGNUM being passed around the
montgomery logic in an inconsistent state. This was found using flags
-DBN_DEBUG -DBN_DEBUG_RAND, and working backwards from this assertion
in 'ectest';

ectest: bn_mul.c:960: BN_mul: Assertion `(_bnum2->top == 0) ||
(_bnum2->d[_bnum2->top - 1] != 0)' failed

Signed-off-by: Geoff Thorpe <geoff@openssl.org>
(cherry picked from commit a52926189155d906d8c11ff97cbc1e5191d202cd)
2014-04-30 11:53:09 -04:00
Geoff Thorpe
c434f7f80f util/mkerr.pl: fix perl warning
Gets rid of this;

defined(@array) is deprecated at ../util/mkerr.pl line 792.
        (Maybe you should just omit the defined()?)
defined(@array) is deprecated at ../util/mkerr.pl line 800.
        (Maybe you should just omit the defined()?)

Signed-off-by: Geoff Thorpe <geoff@openssl.org>
(cherry picked from commit 647f360e2e86818cee1f2d0429e071d14814e0b5)
2014-04-30 11:52:08 -04:00
mancha
e6a01b47e4 Fix version documentation.
Specify -f is for compilation flags. Add -d to synopsis section.

(cherry picked from commit 006397ea62bbcae22c8664d53c2222b808c4bdd1)

Closes #78.
2014-04-26 11:20:00 +01:00
mancha
3f1b3d9675 Fix eckey_priv_encode()
Fix eckey_priv_encode to return an error on failure of i2d_ECPrivateKey.
2014-04-24 19:31:49 +00:00
Steve Marquess
3e124d66c8 Add new sponsors
(cherry picked from commit 351f0a124bffaa94d2a8abdec2e7dde5ae9c457d)
2014-04-24 12:33:01 +01:00
Andy Polyakov
0fb3d5b4fd bn/asm/armv4-gf2m.pl, modes/asm/ghash-armv4.pl: faster multiplication
algorithm suggested in following paper:

Câmara, D.; Gouvêa, C. P. L.; López, J. & Dahab, R.: Fast Software
Polynomial Multiplication on ARM Processors using the NEON Engine.

http://conradoplg.cryptoland.net/files/2010/12/mocrysen13.pdf
(cherry picked from commit f8cee9d08181f9e966ef01d3b69ba78b6cb7c8a8)
2014-04-24 10:27:52 +02:00
Andy Polyakov
ffdff9f12f aes/asm/bsaes-x86_64.pl: Atom-specific optimization.
(cherry picked from commit 558ff0f0c1d87d74e70b0a70ddd67c0ff7f596ad)
2014-04-24 10:14:46 +02:00
Ben Laurie
a0fe2e72c4 Fix use after free. 2014-04-23 07:30:16 +01:00
Ben Laurie
3b21abfd6c Fix double frees.
Conflicts:
	CHANGES
2014-04-22 17:00:52 +01:00
Kaspar Brand
5aeb43393b Fix SSL_CTX_get{first,next}_certificate.
Fix typo that stopped SSL_CTX_get_{first,next}_certificate from working.
(cherry picked from commit 9330a85e0499f10752434c451977d65d80d8de19)
2014-04-21 16:53:48 +01:00
Dr. Stephen Henson
6e85eba11b Document -debug_decrypt option.
(cherry picked from commit 0dd5b94aeb77c2982bdf6886962b7a8491c6c9ed)
2014-04-16 12:35:54 +01:00
Dr. Stephen Henson
5cd5e0219d Extension checking fixes.
When looking for an extension we need to set the last found
position to -1 to properly search all extensions.

PR#3309.
(cherry picked from commit 300b9f0b704048f60776881f1d378c74d9c32fbd)
2014-04-15 18:52:50 +01:00
Dr. Stephen Henson
9c1d63540f Clarify CMS_decrypt behaviour.
(cherry picked from commit 5f8e9a477a18551052f2019c1f374061acbaa5e6)
2014-04-15 18:19:26 +01:00
Dr. Stephen Henson
db34be4224 Add new key fingerprint.
(cherry picked from commit 3143a332e8f2f5ca1a6f0262a1a1a66103f2adf7)
2014-04-11 02:51:34 +01:00
Dr. Stephen Henson
b9ce05acc4 Fix free errors in ocsp utility.
Keep copy of any host, path and port values allocated by
OCSP_parse_url and free as necessary.
(cherry picked from commit 5219d3dd350cc74498dd49daef5e6ee8c34d9857)
2014-04-09 15:45:16 +01:00
Steven M. Schweda
6ef9d9bacf VMS build fix #2.
(cherry picked from commit a74bee5fc7929c55421d111cc5058a8eba8b97e1)
2014-04-08 17:28:23 +01:00
Steven M. Schweda
40a44a7c3d VMS build fix for older compilers.
(cherry picked from commit 55c9e2487552f732e3d96c5ed8e588530b1aebb8)
2014-04-07 23:15:31 +01:00
Dr. Stephen Henson
13738d5fa1 update CHANGES 2014-04-07 21:56:34 +01:00
Dr. Stephen Henson
363dede7a5 Update NEWS. 2014-04-07 21:32:56 +01:00
Dr. Stephen Henson
43866bd6fc update NEWS 2014-04-07 19:29:04 +01:00
Dr. Stephen Henson
cd29ced6de Return if ssleay_rand_add called with zero num.
Treat a zero length passed to ssleay_rand_add a no op: the existing logic
zeroes the md value which is very bad. OpenSSL itself never does this
internally and the actual call doesn't make sense as it would be passing
zero bytes of entropy.

Thanks to Marcus Meissner <meissner@suse.de> for reporting this bug.
(cherry picked from commit 5be1ae28ef3c4bdec95b94f14e0e939157be550a)
2014-04-07 19:27:46 +01:00
Dr. Stephen Henson
7e840163c0 Add heartbeat extension bounds check.
A missing bounds check in the handling of the TLS heartbeat extension
can be used to reveal up to 64k of memory to a connected client or
server.

Thanks for Neel Mehta of Google Security for discovering this bug and to
Adam Langley <agl@chromium.org> and Bodo Moeller <bmoeller@acm.org> for
preparing the fix (CVE-2014-0160)
(cherry picked from commit 96db9023b881d7cd9f379b0c154650d6c108e9a3)
2014-04-07 19:25:34 +01:00
Dr. Stephen Henson
a4896327e3 Document -verify_return_error option.
(cherry picked from commit 4e6c12f3088d3ee5747ec9e16d03fc671b8f40be)
2014-04-07 13:03:54 +01:00
Andy Polyakov
f396e9f4fc crypto/modes/gcm128.c: more strict aliasing fixes.
(cherry picked from commit 997d1aac7cfb957decb62d8f0034a7eca6177fec)
2014-04-06 17:22:12 +02:00
Andy Polyakov
dacb698ada vpaes-[x86_64|ppc].pl: fix typo, which for some reason triggers rkhunter.
(cherry picked from commit 6eebcf345933694e08aba400faf6f639fb4db196)
2014-04-06 12:53:17 +02:00
Dr. Stephen Henson
6411b83e52 Set TLS padding extension value.
Enable TLS padding extension using official value from:

http://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml
(cherry picked from commit cd6bd5ffda616822b52104fee0c4c7d623fd4f53)

Conflicts:

	CHANGES
2014-04-05 20:49:09 +01:00
Dr. Stephen Henson
bb98beade9 Use correct length when prompting for password.
Use bufsiz - 1 not BUFSIZ - 1 when prompting for a password in
the openssl utility.

Thanks to Rob Mackinnon, Leviathan Security for reporting this issue.
(cherry picked from commit 7ba08a4d73c1bdfd3aced09a628b1d7d7747cdca)
2014-04-04 13:06:49 +01:00
Dr. Stephen Henson
b8d208c549 Update FAQ.
(cherry picked from commit 6cc0068430d0a4abdef0b466d422e6a4d154a5fe)
2014-04-04 13:05:56 +01:00
Dr. Stephen Henson
04f35a8909 Document new crl option.
(cherry picked from commit dbb7654dc189992966ecd95ca66f7a3bb011ab9b)
2014-04-03 13:35:48 +01:00
Tim Hudson
68bd06eb6e Add option to generate old hash format.
New -hash_old to generate CRL hashes using old
(before OpenSSL 1.0.0) algorithm.
(cherry picked from commit de2d97cd799f38024d70847bab37d91aa5a2536e)
2014-04-03 13:35:22 +01:00
Dr. Stephen Henson
686b616ea9 VMS build fix 2014-04-02 21:46:13 +01:00
Eric Young
0bb37c5e23 Fix base64 decoding bug.
A short PEM encoded sequence if passed to the BIO, and the file
had 2 \n following would fail.

PR#3289
(cherry picked from commit 10378fb5f4c67270b800e8f7c600cd0548874811)
2014-04-02 19:57:06 +01:00
Dr. Stephen Henson
e9b4b8afbd Don't try and verify signatures if key is NULL (CVE-2013-0166)
Add additional check to catch this in ASN1_item_verify too.
(cherry picked from commit 66e8211c0b1347970096e04b18aa52567c325200)
2014-04-01 16:39:35 +01:00
Dr. Stephen Henson
bc5ec653ba Fix memory leak with client auth. 2014-03-27 16:10:50 +00:00
Dr. Stephen Henson
1f44dac24d Add -no_resumption_on_reneg to SSL_CONF. 2014-03-27 15:51:25 +00:00
Dr. Stephen Henson
2dd6976f6d Update chain building function.
Don't clear verification errors from the error queue unless
SSL_BUILD_CHAIN_FLAG_CLEAR_ERROR is set.

If errors occur during verification and SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR
is set return 2 so applications can issue warnings.
2014-03-27 14:23:46 +00:00
Emilia Kasper
662239183d Allow duplicate certs in ssl_build_cert_chain 2014-03-25 17:28:04 +00:00
Dr. Stephen Henson
66243398bb Workaround for some CMS signature formats.
Some CMS SignedData structure use a signature algorithm OID such
as SHA1WithRSA instead of the RSA algorithm OID. Workaround this
case by tolerating the signature if we recognise the OID.
(cherry picked from commit 3a98f9cf20c6af604799ee079bec496b296bb5cc)
2014-03-19 17:29:55 +00:00
Piotr Sikora
aa10982c49 Retry callback only after ClientHello received.
(cherry picked from commit f04665a653665cd6432b9adfeb7c7f12a7447d26)
2014-03-18 23:58:39 +00:00
Dr. Stephen Henson
8b0336c810 Update ordinals.
Use a previously unused value as we will be updating multiple released
branches.
(cherry picked from commit 0737acd2a8cc688902b5151cab5dc6737b82fb96)
2014-03-12 14:41:52 +00:00
Dr. Stephen Henson
0a9f7780e5 Fix for CVE-2014-0076
Fix for the attack described in the paper "Recovering OpenSSL
ECDSA Nonces Using the FLUSH+RELOAD Cache Side-channel Attack"
by Yuval Yarom and Naomi Benger. Details can be obtained from:
http://eprint.iacr.org/2014/140

Thanks to Yuval Yarom and Naomi Benger for discovering this
flaw and to Yuval Yarom for supplying a fix.
(cherry picked from commit 2198be3483259de374f91e57d247d0fc667aef29)

Conflicts:

	CHANGES
2014-03-12 14:23:21 +00:00
Dr. Stephen Henson
44f7e399d3 typo
(cherry picked from commit a029788b0e0c19cee4007cc1f73201cf2c13addf)
2014-03-10 15:48:12 +00:00
Dr. Stephen Henson
8419df95e1 Remove -WX option from debug-VC-WIN32
(cherry picked from commit 7a3e67f029969620966b8a627b8485d83692cca5)
2014-03-07 19:07:51 +00:00
Andy Polyakov
59314f304e engines/ccgost/gosthash.c: simplify and avoid SEGV.
PR: 3275
(cherry picked from commit ea38f020492042bc1d1adc26ef197b0b9cadf968)
2014-03-07 11:03:25 +01:00
Andy Polyakov
cc6dc9b229 SPARC T4 assembly pack: treat zero input length in CBC.
The problem is that OpenSSH calls EVP_Cipher, which is not as
protective as EVP_CipherUpdate. Formally speaking we ought to
do more checks in *_cipher methods, including rejecting
lengths not divisible by block size (unless ciphertext stealing
is in place). But for now I implement check for zero length in
low-level based on precedent.

PR: 3087, 2775
(cherry picked from commit 5e44c144e649a53bae2724b34d908f6cb26b01ed)
2014-03-07 10:48:51 +01:00
Andy Polyakov
fe69e6be6e dh_check.c: check BN_CTX_get's return value.
(cherry picked from commit 53e5161231854d64fd89e993944609a329a92db4)
2014-03-06 14:21:17 +01:00
Andy Polyakov
430c5ca02e test/Makefile: allow emulated test (e.g. under wine) [from master].
Submitted by: Roumen Petrov
2014-03-06 14:09:58 +01:00
Andy Polyakov
25ebd9e3ce bss_dgram.c,d1_lib.c: make it compile with mingw.
Submitted by: Roumen Petrov
(cherry picked from commit 972b0dc3500a26edb178a5446a0cdfb8f450f853)
2014-03-06 14:07:16 +01:00
Dr. Stephen Henson
bdfc0e284c For self signed root only indicate one error. 2014-03-03 23:33:51 +00:00
Dr. Stephen Henson
12c56e4888 Sync crypto documentation with master branch. 2014-03-03 15:12:17 +00:00
Dr. Stephen Henson
1bd4ee1da1 Use nid not cipher type as some ciphers don't have OIDs. 2014-03-02 15:00:21 +00:00
Dr. Stephen Henson
3956bfce60 Make null cipher work in FIPS mode. 2014-03-02 13:50:06 +00:00
Dr. Stephen Henson
8394109c89 Add new VMS hack symbol, update ordinals. 2014-03-02 13:50:06 +00:00
Dr. Stephen Henson
813cfd9c0a Add additional FIPS digests.
Add a few special case digests not returned by FIPS_get_digestbynid().

Thanks to Roumen Petrov <openssl@roumenpetrov.info> for reporting this
issue.
2014-03-01 23:14:08 +00:00
Dr. Stephen Henson
976c58302b Add function to free compression methods.
Although the memory allocated by compression methods is fixed and
cannot grow over time it can cause warnings in some leak checking
tools. The function SSL_COMP_free_compression_methods() will free
and zero the list of supported compression methods. This should
*only* be called in a single threaded context when an application
is shutting down to avoid interfering with existing contexts
attempting to look up compression methods.
2014-03-01 23:14:08 +00:00
Dr. Stephen Henson
b60272b01f PKCS#8 support for alternative PRFs.
Add option to set an alternative to the default hmacWithSHA1 PRF
for PKCS#8 private key encryptions. This is used automatically
by PKCS8_encrypt if the nid specified is a PRF.

Add option to pkcs8 utility.

Update docs.
2014-03-01 23:14:08 +00:00
Dr. Stephen Henson
124d218889 Fix memory leak. 2014-03-01 23:14:08 +00:00
Andy Polyakov
cd077dab08 Makefile.org: fix syntax error on Solaris.
PR: 3271
(cherry picked from commit 65370f9bbcbfc4a5bb87aa5e30f74da48966b7c1)
2014-02-28 22:55:44 +01:00
Dr. Stephen Henson
d1201e3195 Fix compilation errors with no-nextprotoneg 2014-02-28 13:35:30 +00:00
Dr. Stephen Henson
5f2329b82a Fix fips flag handling.
Don't set the fips flags in cipher and digests as the implementations
aren't suitable for FIPS mode and will be redirected to the FIPS module
versions anyway.

Return EVP_CIPH_FLAG_FIPS or EVP_MD_FLAG_FIPS if a FIPS implementation
exists when calling EVP_CIPHER_flags and EVP_MD_flags repectively.

Remove unused FIPS code from e_aes.c: the 1.0.2 branch will never be
used to build a FIPS module.
2014-02-27 19:18:58 +00:00
Dr. Stephen Henson
01fb5e133f Remove unused file.
The file evp_fips.c isn't used in OpenSSL 1.0.2 as FIPS and non-FIPS
implementations of algorithms can coexist.
2014-02-27 19:08:53 +00:00
Andy Polyakov
fd2c85f6ae evp/e_aes.c: harmonize with 1.0.1. 2014-02-27 17:47:23 +01:00
Andy Polyakov
41977c2e04 Configure: mark unixware target as elf-1.
(cherry picked from commit 4ca026560a211ef2143199e4531aae377878e17a)
2014-02-27 14:32:46 +01:00
Andy Polyakov
ca88a1d439 perlasm/x86asm.pl: recognize elf-1 denoting old ELF platforms.
(cherry picked from commit b62a4a1c0e77233e201517e5e32d575a0f20cc05)
2014-02-27 14:30:42 +01:00
Andy Polyakov
5615196f7b perlasm/x86gas.pl: limit special OPENSSL_ia32cap_P treatment to ELF.
(cherry picked from commit ce876d8316409542283b356d331f90e1a1dfb853)
2014-02-27 14:29:07 +01:00
Andy Polyakov
1f59eb5f11 rc4/asm/rc4-586.pl: allow for 386-only build.
(cherry picked from commit f861b1d4335d4017953938160c7e4e0df9af5a7b)
2014-02-27 14:28:54 +01:00
Andy Polyakov
4bf6d66e67 des/asm/des-586.pl: shortcut reference to DES_SPtrans.
(cherry picked from commit fd361a67ef5e0ed953abc881aa7061a273bad9fe)
2014-02-27 14:28:44 +01:00
Andy Polyakov
2f34088e5e Makefile.org: mask touch's exit code
[but don't let it mask make's].

PR: 3269
2014-02-27 12:35:02 +01:00
Andy Polyakov
559e69f9b4 crypto/Makefile: make it OSF-make-friendly
PR: 3165
2014-02-26 16:42:57 +01:00
Rob Stradling
f3b7e522d8 CABForum EV OIDs for Subject Jurisdiction of Incorporation or Registration.
(cherry picked from commit ffcc832ba6e17859d45779eea87e38467561dd5d)
2014-02-26 15:33:10 +00:00
Dr. Stephen Henson
73be56a21d Fix for WIN32 builds with KRB5 2014-02-26 15:33:10 +00:00
Andy Polyakov
d00ae7cf70 sha/asm/sha256-586.pl: don't try to compile SIMD with no-sse2.
(cherry picked from commit d49135e7ead795412a8357ff425dc99e328c53f6)
2014-02-26 10:23:56 +01:00
Andy Polyakov
f92926e331 sha/asm/sha512-x86_64.pl: fix compilation error on Solaris.
(cherry picked from commit 147cca8f530b8ddf22087e5709927082e095a062)
2014-02-26 09:31:40 +01:00
Andy Polyakov
241c8004ce Configure: blended processor target in solaris-x86-cc.
(cherry picked from commit 7bb9d84e35dce137c4479915ab0cbdb10ad0cf1d)
2014-02-26 09:31:26 +01:00
Andy Polyakov
8d08627c94 ssl/t1_enc.c: check EVP_MD_CTX_copy return value.
PR: 3201
(cherry picked from commit 03da57fe14f2de5bde9d4496a2ae9a4ae8879f88)
2014-02-25 22:23:49 +01:00
Andy Polyakov
aa1bb606f3 aes/asm/vpaes-ppc.pl: fix traceback info.
(cherry picked from commit e704741bf3ce02c7dbcd9b81c4df257b3d919f7e)
2014-02-25 20:13:41 +01:00
Zoltan Arpadffy
dabd4f1986 OpenVMS fixes. 2014-02-25 15:16:03 +00:00
Dr. Stephen Henson
251c47001b update NEWS with v3_scts.c issue 2014-02-25 15:08:45 +00:00
Dr. Stephen Henson
3678161d71 Don't use BN_ULLONG in n2l8 use SCTS_TIMESTAMP. 2014-02-25 15:05:08 +00:00
Dr. Stephen Henson
6634416732 Fix for v3_scts.c
Not all platforms define BN_ULLONG. Define SCTS_TIMESTAMP as a type
which should work on all platforms.
2014-02-25 14:54:09 +00:00
Dr. Stephen Henson
7101fd705c update NEWS 2014-02-25 13:56:40 +00:00
Dr. Stephen Henson
0f9bcf3319 Avoid Windows 8 Getversion deprecated errors.
Windows 8 SDKs complain that GetVersion() is deprecated.

We only use GetVersion like this:

	(GetVersion() < 0x80000000)

which checks if the Windows version is NT based. Use a macro check_winnt()
which uses GetVersion() on older SDK versions and true otherwise.
(cherry picked from commit a4cc3c8041104896d51ae12ef7b678c31808ce52)
2014-02-25 13:41:53 +00:00
Rob Stradling
a948732e1c Parse non-v1 SCTs less awkwardly.
(cherry picked from commit 19f65ddbab30543415584ae7916e12a3c5249dba)
2014-02-25 13:04:21 +00:00
Andy Polyakov
c3006e0f5a util/pl/VC-32.pl: harmonize with 1.0.1 and fix typo. 2014-02-25 13:41:40 +01:00
Andy Polyakov
efe835eb5a ms/do_win64a.bat: forward to NUL, not NUL:.
Allegedly formwarding to NUL: sometimes creates NUL file in file
system.

PR: 3250
(cherry picked from commit 63aff3001ef6ba2ac376cd3f237fb0d0b3e77f30)
2014-02-24 19:37:48 +01:00
Dr. Stephen Henson
ab03ead035 we need /MD for fips builds 2014-02-24 18:21:35 +00:00
Dr. Stephen Henson
6a6e08960e Update NEWS with known issue. 2014-02-24 16:31:44 +00:00
Andy Polyakov
aedabeee3a BC-32.pl: refresh Borland C support.
PR: 3251
Suggested by: Thorsten Schning
(cherry picked from commit 779c51c6446f384c2f2a7bd5cc4c3e0366baf628)
2014-02-24 16:45:15 +01:00
Andy Polyakov
83fe7b9c83 x509/by_dir.c: fix run-away pointer (and potential SEGV)
when adding duplicates in add_cert_dir.

PR: 3261
Reported by: Marian Done
(cherry picked from commit 758954e0d8232d370ed72b7f86640e40443e1778)
2014-02-24 15:21:37 +01:00
Dr. Stephen Henson
97654d7e28 Prepare for 1.0.2-beta2-dev 2014-02-24 13:52:51 +00:00
Dr. Stephen Henson
94f4166017 Prepare for 1.0.2-beta1 release 2014-02-24 13:51:34 +00:00
Dr. Stephen Henson
a74c9c9e10 OpenSSL 1.0.2 is now in beta 2014-02-24 13:50:38 +00:00
Dr. Stephen Henson
d2a3c4497f make update 2014-02-24 13:50:38 +00:00
Andy Polyakov
a129850922 config: recognize ARMv8/AArch64 target.
(cherry picked from commit d099f0ed6ca518052bb167b31e999e1e7734eebf)
2014-02-24 13:21:14 +01:00
Dr. Stephen Henson
c3f5d3d93a Only set current certificate to valid values.
When setting the current certificate check that it has a corresponding
private key.
(cherry picked from commit 358d352aa244b4f2ef655bccff6658d92d5ce03c)
2014-02-23 13:49:21 +00:00
Dr. Stephen Henson
c5ea65b157 New chain building flags.
New flags to build certificate chains. The can be used to rearrange
the chain so all an application needs to do is add all certificates
in arbitrary order and then build the chain to check and correct them.

Add verify error code when building chain.

Update docs.
(cherry picked from commit 13dc3ce9ab483cade378bcf3844c92bacd817316)
2014-02-23 13:49:21 +00:00
Dr. Stephen Henson
58b86e4235 Option to set current cert to server certificate.
(cherry picked from commit daddd9a950e491c31f9500d5e570bc7eb96b2823)
2014-02-23 13:49:21 +00:00
Ben Laurie
a466be6243 Fix typo. 2014-02-23 11:21:39 +00:00
Ben Laurie
60327ce41a Add debug flag. 2014-02-23 11:21:28 +00:00
Andy Polyakov
2d4d9623da aes/asm/aesni-x86[_64].pl: minor Atom-specific performance tweak.
(cherry picked from commit 214368ffee5736836e2dbb80a16a4fbd85f0eaf9)
2014-02-21 12:15:07 +01:00
Andy Polyakov
6b3b6beaa1 ssl/ssl_cert.c: DANE update. 2014-02-21 12:12:25 +01:00
Dr. Stephen Henson
7743be3aac make update 2014-02-20 22:57:24 +00:00
Dr. Stephen Henson
b709f8ef54 fix WIN32 warnings 2014-02-20 22:41:06 +00:00
Rob Stradling
c74ce24cd2 Show the contents of the RFC6962 Signed Certificate Timestamp List Certificate/OCSP Extensions.
Add the RFC6962 OIDs to the objects table.
(backport from master branch)
2014-02-20 21:43:54 +00:00
Dr. Stephen Henson
612566e752 Don't use CRYPTO_AES_CTR if it isn't defined.
(cherry picked from commit 6ecbc2bb62835a401ad6efe240d469a23b21755b)
2014-02-18 22:21:41 +00:00
Dr. Stephen Henson
3ecce3dbeb Don't use getcwd in non-copy builds.
(cherry picked from commit f3a39032601fab2c704f03338e378592d3b4e262)
2014-02-15 20:17:59 +00:00
Dr. Stephen Henson
71eca86c30 Don't override $srcd for non copy builds. 2014-02-15 20:16:13 +00:00
Dr. Stephen Henson
dd1e3bd8d4 recognise multiblock 2014-02-15 18:19:35 +00:00
Dr. Stephen Henson
c55fef76f7 Add /fixed flag for FIPS links where appropriate. 2014-02-15 17:16:19 +00:00
Dr. Stephen Henson
eb70d4407f Remove duplicate statement.
(cherry picked from commit 5a7652c3e585e970e5b778074c92e617e48fde38)
2014-02-15 01:29:24 +00:00
Klaus-Peter Junghanns
b335b5440a Add support for aes-128/192/256-ctr to the cryptodev engine.
This can be used to speed up SRTP with libsrtp, e.g. on TI omap/sitara based devices.
(cherry picked from commit be2c4d9bd9e81030c547a34216ae2d8e5c888190)
2014-02-15 00:06:43 +00:00
Kurt Roeckx
a8eeedb603 Use defaults bits in req when not given
If you use "-newkey rsa" it's supposed to read the default number of bits from the
config file.  However the value isn't used to generate the key, but it does
print it's generating such a key.  The set_keygen_ctx() doesn't call
EVP_PKEY_CTX_set_rsa_keygen_bits() and you end up with the default set in
pkey_rsa_init() (1024).  Afterwards the number of bits gets read from the config
file, but nothing is done with that anymore.

We now read the config first and use the value from the config file when no size
is given.

PR: 2592
(cherry picked from commit 3343220327664680420d4068e1fbe46d2236f1b0)
2014-02-14 22:35:15 +00:00
Kurt Roeckx
b3d8de7903 Fix additional pod errors with numbered items.
(cherry picked from commit e547c45f1c74e976656c042ec9d873f6eea0e756)
2014-02-14 22:35:15 +00:00
Scott Schaefer
0413ea5801 Fix various spelling errors
(cherry picked from commit 2b4ffc659eabec29f76821f0ac624a2b8c19e4c7)
2014-02-14 22:35:15 +00:00
Scott Schaefer
2f6fba6772 Document pkcs12 -password behavior
apps/pkcs12.c accepts -password as an argument.  The document author
almost certainly meant to write "-password, -passin".

However, that is not correct, either.  Actually the code treats
-password as equivalent to -passin, EXCEPT when -export is also
specified, in which case -password as equivalent to -passout.
(cherry picked from commit 856c6dfb09d69fc82ada2611c6cd792dfc60e355)
2014-02-14 22:35:15 +00:00
Dr. Stephen Henson
d69acceca9 Fix error discrepancy with 1.0.1 2014-02-14 17:50:20 +00:00
Andy Polyakov
aff78bb39a ssl/s3_pkt.c: detect RAND_bytes error in multi-block.
(cherry picked from commit 701134320a94908d8c0ac513741cab41e215a7b5)
2014-02-14 17:45:33 +01:00
Andy Polyakov
104c032b7b x86[_64]cpuid.pl: add low-level RDSEED.
(cherry picked from commit f4d456408d9d7bca31f34765d1a05fbd9fa55826)
2014-02-14 17:25:14 +01:00
Andy Polyakov
b347341c75 aes/asm/aesni-x86_64.pl: further optimization for Atom Silvermont.
Improve CBC decrypt and CTR by ~13/16%, which adds up to ~25/33%
improvement over "pre-Silvermont" version. [Add performance table to
aesni-x86.pl].
(cherry picked from commit 5599c7331b90d9d29c9914c2a95c16d91485415a)
2014-02-14 17:17:39 +01:00
Dr. Stephen Henson
c00f8d697a Include self-signed flag in certificates by checking SKID/AKID as well
as issuer and subject names. Although this is an incompatible change
it should have little impact in pratice because self-issued certificates
that are not self-signed are rarely encountered.
(cherry picked from commit b1efb7161f409c81178b9aa95583db3390f90b1b)
2014-02-14 15:27:30 +00:00
Dr. Stephen Henson
b07e4f2f46 Include TA in checks/callback with partial chains.
When a chain is complete and ends in a trusted root checks are also
performed on the TA and the callback notified with ok==1. For
consistency do the same for chains where the TA is not self signed.
(cherry picked from commit 385b3486661628f3f806205752bf968b8114b347)
2014-02-14 15:12:53 +00:00
Dr. Stephen Henson
ced6dc5cef Add cert_self_signed function to simplify verify
(from master)
2014-02-14 15:12:52 +00:00
Dr. Stephen Henson
bf2d129194 Simplify X509_STORE_CTX_get1_chain (from master). 2014-02-14 15:12:52 +00:00
Andy Polyakov
d59d0b7c21 ssl/ssl[3].h: retain binary compatibility. 2014-02-13 17:03:14 +01:00
Andy Polyakov
dbd512e1b7 Configure: restore binary compatibility in darwin64-x86_64-cc.
(and remove duplicates).
2014-02-13 15:23:36 +01:00
Andy Polyakov
fcc6f699e3 evp/e_aes_cbc_hmac_sha*.c: improve cache locality.
(cherry picked from commit 9587429fa07a34066107e926fbc8708220f058fa)
2014-02-13 14:41:10 +01:00
Andy Polyakov
7078d93307 ghash-x86[_64].pl: ~15% improvement on Atom Silvermont
(other processors unaffected).
(cherry picked from commit 98e143f118aedc2fa79fa0ae90f1b039da106309)
2014-02-13 14:38:59 +01:00
Dr. Stephen Henson
a2317c3ffd fix error discrepancy 2014-02-09 21:12:12 +00:00
Dr. Stephen Henson
75917fac8e Make upate.
Revert libssl ordinals to OpenSSL 1.0.1 values first to tidy up and
avoid entries for deleted functions.
2014-02-09 19:59:54 +00:00
Dr. Stephen Henson
295fd057ce fix error number clash 2014-02-09 19:57:27 +00:00
Ben Laurie
8c4e09f74f Whitespace fixes. 2014-02-09 19:31:07 +00:00
Ben Laurie
e32cbae224 Merge branch '102_stable_tlsext_suppdata_changes' of git://github.com/scottdeboy/openssl into scottdeboy-102_stable_tlsext_suppdata_changes 2014-02-09 19:17:42 +00:00
Scott Deboy
f6fd8db2a4 Restore copyright symbol - ISO-8859-1 encoding for Configure file 2014-02-09 08:26:04 -08:00
Ben Laurie
d65db21976 Const fix. 2014-02-09 08:07:16 -08:00
Ben Laurie
8acf1ff4b4 More cleanup.
(cherry picked from commit 5eda213ebe382009c2f37a8eade5cbcdae6017ed)
Conflicts:
	apps/s_client.c
	apps/s_server.c
2014-02-09 08:07:04 -08:00
Ben Laurie
8b41df41c2 Make it build.
(cherry picked from commit a6a48e87bc469f37ed1c53d0e4d22faaa0a5adf3)
Conflicts:
	ssl/s3_clnt.c
	ssl/t1_lib.c
2014-02-09 08:02:40 -08:00
Scott Deboy
c32ebefaa8 Reverting 1.0.2-only changes supporting the prior authz RFC5878-based tests from commit 835d104f46c4448a27844a9309de456c7972a943 2014-02-09 07:49:44 -08:00
Ben Laurie
ed0dc93d89 Add new asm modules. 2014-02-09 12:18:16 +00:00
Scott Deboy
5a32dd8930 Don't break out of the custom extension callback loop - continue instead
The contract for custom extension callbacks has changed - all custom extension callbacks are triggered
2014-02-08 16:19:30 -08:00
Ben Laurie
130ebe34c8 Fix whitespace, new-style comments. 2014-02-08 16:19:30 -08:00
Scott Deboy
7612511b3b Re-add alert variables removed during rebase
Whitespace fixes

(cherry picked from commit e9add063b50e8a460d5636055156d2760c2fe29f)
Conflicts:
	ssl/s3_clnt.c
2014-02-08 16:19:01 -08:00
Scott Deboy
19a28a8aa3 Updating DTCP authorization type to expected value 2014-02-08 16:18:11 -08:00
Scott Deboy
fc213217e8 Update custom TLS extension and supplemental data 'generate' callbacks to support sending an alert.
If multiple TLS extensions are expected but not received, the TLS extension and supplemental data 'generate' callbacks are the only chance for the receive-side to trigger a specific TLS alert during the handshake.

Removed logic which no-op'd TLS extension generate callbacks (as the generate callbacks need to always be called in order to trigger alerts), and updated the serverinfo-specific custom TLS extension callbacks to track which custom TLS extensions were received by the client, where no-ops for 'generate' callbacks are appropriate.

(cherry picked from commit ac20719d994729970eb3b775c7bffa81f0e9f960)
Conflicts:
	ssl/t1_lib.c
2014-02-08 16:17:24 -08:00
Trevor Perrin
7198c5af1f Redo deletion of some serverinfo code that supplemental data code mistakenly reinstated. 2014-02-08 16:15:10 -08:00
Scott Deboy
40632f6b77 Free generated supp data after handshake completion, add comment regarding use of num_renegotiations in TLS and supp data generation callbacks
(cherry picked from commit 67c408cee9b01a7c8c7ca002d36b4f8c0612b08c)
Conflicts:
	apps/s_client.c
	apps/s_server.c
2014-02-08 16:14:23 -08:00
Scott Deboy
038bec784e Add callbacks supporting generation and retrieval of supplemental data entries, facilitating RFC 5878 (TLS auth extensions)
Removed prior audit proof logic - audit proof support was implemented using the generic TLS extension API
Tests exercising the new supplemental data registration and callback api can be found in ssltest.c.
Implemented changes to s_server and s_client to exercise supplemental data callbacks via the -auth argument, as well as additional flags to exercise supplemental data being sent only during renegotiation.

(cherry picked from commit 36086186a9b90cdad0d2cd0a598a10f03f8f4bcc)
Conflicts:
	Configure
	apps/s_client.c
	apps/s_server.c
	ssl/ssl.h
	ssl/ssl3.h
	ssl/ssltest.c
2014-02-08 16:12:15 -08:00
Dr. Stephen Henson
f407eec799 make update 2014-02-06 14:31:09 +00:00
Dr. Stephen Henson
bd618bebbe update default depflags 2014-02-06 14:28:49 +00:00
Andy Polyakov
e2884b3e9a Configure: recognize experimental-multiblock.
(cherry picked from commit 2d752737c53d0cf4953c11551d6d2a9df3655329)
2014-02-06 14:26:01 +00:00
Dr. Stephen Henson
c41e242e5c Return previous compression methods when setting them.
(cherry picked from commit b45e874d7c4a8fdac7ec10cff43f21d02e75d511)
2014-02-06 13:58:18 +00:00
Andy Polyakov
9578319394 ssl/s3_pkt.c: add multi-block processing [from master]. 2014-02-05 21:43:17 +01:00
Andy Polyakov
16eaca2c79 config: recognize little-endian Linux PPC64. 2014-02-05 20:36:11 +01:00
Dr. Stephen Henson
3bff195dca Oops, get selection logic right.
(cherry picked from commit 3880579240d476d21f68fd01a391dd325920f479)
2014-02-05 18:57:23 +00:00
Andy Polyakov
41cf2d2518 evp/e_aes_cbc_hmac_sha[1|256].c: add multi-block implementations [from master]. 2014-02-05 19:52:38 +01:00
Dr. Stephen Henson
e0d4272a58 Return per-certificate chain if extra chain is NULL.
If an application calls the macro SSL_CTX_get_extra_chain_certs
return either the old "shared" extra certificates or those associated
with the current certificate.

This means applications which call SSL_CTX_use_certificate_chain_file
and retrieve the additional chain using SSL_CTX_get_extra_chain_certs
will still work. An application which only wants to check the shared
extra certificates can call the new macro
SSL_CTX_get_extra_chain_certs_only
(cherry picked from commit a51f767645c117667d337f77fe1dd9c0a66d8410)
2014-02-05 17:06:56 +00:00
Andy Polyakov
41c373fa3e [aesni|sha*]-mb-x86_64.pl: add multi-block assembly modules [from master]. 2014-02-05 14:33:44 +01:00
Dr. Stephen Henson
7f6e09b531 Add quotes as CC can contain spaces.
PR#3253
2014-02-03 14:13:04 +00:00
Dr. Stephen Henson
e2f06800bc New ctrl to set current certificate.
New ctrl sets current certificate based on certain criteria. Currently
two options: set the first valid certificate as current and set the
next valid certificate as current. Using these an application can
iterate over all certificates in an SSL_CTX or SSL structure.
(cherry picked from commit 0f78819c8ccb7c526edbe90d5b619281366ce75c)
2014-02-02 23:12:06 +00:00
Dr. Stephen Henson
1180833643 Fix various typos.
(cherry picked from commit f3efeaad540b000779277b4fc49a239529ee616e)
2014-02-02 23:12:06 +00:00
Dr. Stephen Henson
130eed01cc Update demo.
(cherry picked from commit 88c21c47a3d187d4f8c4e87e3c6088198cb08a99)
2014-02-02 23:06:16 +00:00
Dr. Stephen Henson
2ded87355f Update demos/bio/README
(cherry picked from commit ea131a0644bcebeaa5e911217aadbc9dac241fec)
2014-02-02 23:05:52 +00:00
Dr. Stephen Henson
b1ae02e2ff Modify sample accept.cnf
(cherry picked from commit d80b0eeee59fa48f2506fe103de1b52ef6de3f4f)
2014-02-02 23:05:34 +00:00
Dr. Stephen Henson
381417089a Add demo for SSL server using SSL_CONF.
(cherry picked from commit ebd14bfce9ef6b4bf41129a329823130d1002f42)
2014-02-02 23:05:15 +00:00
Ben Laurie
984a30423d Add extension free function. 2014-02-02 15:22:47 +00:00
Andy Polyakov
2ad673c611 engines/e_capi.c: TCHAR support (cumilative update from master). 2014-02-02 00:17:38 +01:00
Andy Polyakov
0693dd954e modes/asm/ghash-s390x.pl: +15% performance improvement on z10.
(cherry picked from commit d162584b1154153d997fed18a9df2e60771fe06c)
2014-02-02 00:10:41 +01:00
Andy Polyakov
9071b36d9a Add AES-NI+SHA256 stitch registrations (from master). 2014-02-02 00:05:02 +01:00
Andy Polyakov
eb6af20d2e dso/dso_win32.c: fix compiler warning.
(cherry picked from commit 0a2d5003df1a9ecf801ac3b4a5cb7dda85449315)
2014-02-01 23:32:19 +01:00
Andy Polyakov
8087969c5b crypto/cryptlib.c: remove stdio dependency (update from master). 2014-02-01 23:27:49 +01:00
Andy Polyakov
cb437c66d1 camellia/asm/cmll-x86_64.pl: fix symptomless bugs (update from master). 2014-02-01 23:14:33 +01:00
Ben Laurie
40b0d0765e Remove redundant accessor (you can do the same thing, and more, with
X509_ALGOR_[gs]et0()).
2014-02-01 22:03:40 +00:00
Andy Polyakov
41235f30fb util/pl/VC-32.pl fix typo.
(cherry picked from commit fb0a520897778ebeebe9aaaf116f207a838ebb3f)
2014-02-01 22:55:25 +01:00
Andy Polyakov
130c15ef5a util/pl/VC-32.pl: refresh, switch to ws2, add crypt32, fix typo (based on
suggestions from Pierre Delaage).
(cherry picked from commit 668bcfd5ca237fdf6fbef1ab463697a4a48caf39)

Resolved conflicts:

	util/pl/VC-32.pl
2014-02-01 22:53:24 +01:00
Andy Polyakov
2cc5142fb1 Improve WINCE support.
Submitted by: Pierre Delaage
(cherry picked from commit a006fef78e56b078549a80f4bb4518b6a02eba84)

Resolved conflicts:

	crypto/bio/bss_dgram.c
	ssl/d1_lib.c
	util/pl/VC-32.pl
2014-02-01 22:48:56 +01:00
Andy Polyakov
d451ece4e7 b_sock.c: make getsockopt work in cases when optlen is 64-bit value.
(cherry picked from commit 80c42f3e0c34451dd7cfc65e07bc639759ef07d2)
2014-02-01 22:33:02 +01:00
Andy Polyakov
1121ba1b74 wp-mmx.pl: ~10% performance improvement.
(cherry picked from commit ae007d4d09f2ed9940c6e581bab9290d78615506)
2014-02-01 22:27:07 +01:00
Andy Polyakov
1fb039fde2 wp-x86_64.pl: ~10% performance improvement.
(cherry picked from commit 701d593f7095db84459c76265349a83d30a4cae5)
2014-02-01 22:26:45 +01:00
Andy Polyakov
3073927e42 sha512-ia64.pl: 15-20% performance improvement.
(cherry picked from commit 46a2b3387a3feb044527a58a89555029c809190d)
2014-02-01 22:21:57 +01:00
Andy Polyakov
b6c2029931 objxref.pl: improve portability.
(cherry picked from commit 71fa3bc5ece9121d1aa9bb513b5641e9ea605e14)
2014-02-01 22:17:36 +01:00
Adam Langley
45d010255f Add volatile qualifications to two blocks of inline asm to stop GCC from
eliminating them as dead code.

Both volatile and "memory" are used because of some concern that the compiler
may still cache values across the asm block without it, and because this was
such a painful debugging session that I wanted to ensure that it's never
repeated.
(cherry picked from commit 7753a3a68431aa81b82beea4c3f5374b41454679)
2014-02-01 22:01:46 +01:00
Andy Polyakov
7e569022c5 PPC assembly pack: ppc64-mont update from master. 2014-02-01 21:51:51 +01:00
Andy Polyakov
50f1b47c7f PPC assembly pack: jumbo update from master.
Add Vector Permutation AES and little-endian support.
2014-02-01 21:48:31 +01:00
Andy Polyakov
5572bc4e2f crypto/aes/asm/aesni-x86[_64].pl: jumbo update from master. 2014-02-01 21:27:46 +01:00
Andy Polyakov
729d334106 crypto/sha/asm/sha1-x86_64.pl: jumbo update from master. 2014-02-01 21:24:55 +01:00
Ben Laurie
cacdfcb247 Add more accessors. 2014-02-01 18:30:23 +00:00
Ben Laurie
519ad9b384 Add accessor for x509.cert_info. 2014-02-01 18:30:23 +00:00
Ben Laurie
7b2d785d20 Fix warning. 2014-01-29 17:57:32 +01:00
Dr. Stephen Henson
f2d678e6e8 Clarify docs.
Remove reference to ERR_TXT_MALLOCED in the error library as that is
only used internally. Indicate that returned error data must not be
freed.
2014-01-29 00:59:35 +00:00
Dr. Stephen Henson
448e9b7cf1 typo
(cherry picked from commit cb2182676bdf652070bc272a3896d957763a4324)
2014-01-28 15:36:15 +00:00
Dr. Stephen Henson
2c4c9867e7 Fix demo comment: 0.9.9 never released.
(cherry picked from commit 717cc8589540b95122a652dee68e6a75b6262d93)
2014-01-28 15:17:32 +00:00
Dr. Stephen Henson
a99540a6de Check i before r[i].
PR#3244
(cherry picked from commit 9614d2c676ffe74ce0c919d9e5c0d622a011cbed)
2014-01-28 15:14:47 +00:00
Dr. Stephen Henson
9614ed695d Add loaded dynamic ENGINEs to list.
Always add a dynamically loaded ENGINE to list. Otherwise it can cause
problems when multiply loaded, especially if it adds new public key methods.
For all current engines we only want a single implementation anyway.
(cherry picked from commit e933f91f50108a43c0198cdc63ecdfdbc77b4d0d)
2014-01-28 13:57:14 +00:00
Dr. Stephen Henson
aabfee601e Certificate callback doc.
(cherry picked from commit 46ab9bbd7fa610d775fe645dd0fe6d509c8dff3a)
2014-01-28 13:38:55 +00:00
Dr. Stephen Henson
cee1d9e02f make update 2014-01-27 14:59:46 +00:00
Dr. Stephen Henson
285f7fb0f9 Add cert callback retry test.
(cherry picked from commit 3323314fc1c6d18e650a2de97f7cf9892ac92a60)
2014-01-27 14:41:38 +00:00
Dr. Stephen Henson
ede90b1121 Support retries in certificate callback
(cherry picked from commit 0ebc965b9ca4352e407bb7cfa65ac235942117f6)

Conflicts:

	ssl/s3_srvr.c
	ssl/ssl3.h
2014-01-27 14:41:38 +00:00
Dr. Stephen Henson
5e7329d156 Compare encodings in X509_cmp as well as hash.
(cherry picked from commit ec492c8a5a1491949166c4b37df8666741180f4d)
2014-01-27 14:33:10 +00:00
Dr. Stephen Henson
9f1979b94a New function to set compression methods so they can be safely freed.
(cherry picked from commit cbb67448277232c8403f96edad4931c4203e7746)
2014-01-27 14:32:44 +00:00
Dr. Stephen Henson
3fcf327e26 Add -engine_impl option to dgst which will use an implementation of
an algorithm from the supplied engine instead of just the default one.
(cherry picked from commit bb845ee044587a91589357a772a02cffb0ba4454)
2014-01-23 18:35:42 +00:00
Dr. Stephen Henson
3f4742b48c make update 2014-01-23 17:13:37 +00:00
Dr. Stephen Henson
c4f01c533b Add new function SSL_CTX_get_ssl_method().
Partial fix for PR#3183.
(cherry picked from commit ba168244a14bbd056e502d7daa04cae4aabe9d0d)
2014-01-16 14:08:42 +00:00
Kaspar Brand
b7a8550988 Omit initial status request callback check.
PR#3178
(cherry picked from commit d0b039d4a3a19b106cc2cb938125b86aca4974aa)
2014-01-16 13:48:23 +00:00
Zoltan Arpadffy
e775891708 VMS fixes 2014-01-11 22:44:04 +00:00
Jeff Trawick
ae6fbb5df0 typo
(cherry picked from commit 5edce5685f26c1bb7854d4cdf291b9604fcc5dbf)
2014-01-10 23:02:46 +00:00
Jeff Trawick
f9c1f03754 typo
(cherry picked from commit 4b64e0cbdb563e13a6f7cd8631b31532c04f1234)
2014-01-10 23:02:20 +00:00
Dr. Stephen Henson
50701af9d5 Fix bug in X509_V_FLAG_IGNORE_CRITICAL CRL handling.
(cherry picked from commit 8f4077ca69076cebaca51b7b666db1ed49e46b9e)
2014-01-09 22:53:50 +00:00
Dr. Stephen Henson
1d6af3d430 update NEWS 2014-01-09 22:50:07 +00:00
Andy Polyakov
392fd8f89c bn/asm/x86_64-mont5.pl: fix compilation error on Solaris.
(cherry picked from commit eedab5241e32f9f185cfee23a0c67264d3e3ecf2)
2014-01-09 13:47:53 +01:00
Dr. Stephen Henson
802db0fab2 Sync CHANGES 2014-01-07 15:41:11 +00:00
Dr. Stephen Henson
2f972419a3 Add fix for CVE-2013-4353 2014-01-07 15:41:11 +00:00
Dr. Stephen Henson
a05a2c67ef Update NEWS. 2014-01-07 15:41:04 +00:00
Andy Polyakov
e34140620e sha/asm/sha256-armv4.pl: add NEON code path.
(and shave off cycle even from integer-only code)
(cherry picked from commit ad0d2579cf3a293a35a5b606afc5a97c71cf6ca7)
2014-01-04 18:06:36 +01:00
Andy Polyakov
acd9121085 aesni-sha1-x86_64.pl: harmonize [Atom-specific optimizations] with master branch. 2014-01-04 17:42:13 +01:00
Dr. Stephen Henson
b17d6b8d1d Restore SSL_OP_MSIE_SSLV2_RSA_PADDING
The flag SSL_OP_MSIE_SSLV2_RSA_PADDING hasn't done anything since OpenSSL
0.9.7h but deleting it will break source compatibility with any software
that references it. Restore it but #define to zero.
2014-01-04 13:58:51 +00:00
Dr. Stephen Henson
b9fa413a08 Use algorithm specific chains for certificates.
Fix a limitation in SSL_CTX_use_certificate_chain_file(): use algorithm
specific chains instead of the shared chain.

Update docs.
(cherry picked from commit a4339ea3ba045b7da038148f0d48ce25f2996971)

Conflicts:

	CHANGES
2014-01-03 22:45:20 +00:00
Andy Polyakov
4abe148444 ssl/t1_enc.c: optimize PRF (suggested by Intel).
(cherry picked from commit e8b0dd57c0e9c53fd0708f0f458a7a2fd7a95c91)
2014-01-03 21:56:03 +01:00
Dr. Stephen Henson
04d6940436 update NEWS 2014-01-02 19:12:47 +00:00
Dr. Stephen Henson
8511b5f594 Don't change version number if session established
When sending an invalid version number alert don't change the
version number to the client version if a session is already
established.

Thanks to Marek Majkowski for additional analysis of this issue.

PR#3191
(cherry picked from commit b77b58a398c8b9b4113f3fb6b48e162a3b8d4527)
2014-01-02 15:07:51 +00:00
Dr. Stephen Henson
546d6760b9 Update curve list size. 2013-12-29 16:30:34 +00:00
Andy Polyakov
ccbb8d5e95 sparcv9cap.c: omit random detection.
PR: 3202
(cherry picked from commit 926725b3d7c1528f2dc116a48623c42264188277)
2013-12-28 13:32:45 +01:00
Andy Polyakov
d7d7e7b038 ARM assembly pack: make it work with older toolchain.
(cherry picked from commit 2218c296b4981af6f2639bbd7eabfb89437fe776)
2013-12-28 12:18:11 +01:00
Dr. Stephen Henson
80b6d97585 Fix DTLS retransmission from previous session.
For DTLS we might need to retransmit messages from the previous session
so keep a copy of write context in DTLS retransmission buffers instead
of replacing it after sending CCS. CVE-2013-6450.
(cherry picked from commit 34628967f1e65dc8f34e000f0f5518e21afbfc7b)
2013-12-20 23:25:41 +00:00
Dr. Stephen Henson
ff64ab32ae Ignore NULL parameter in EVP_MD_CTX_destroy.
(cherry picked from commit a6c62f0c25a756c263a80ce52afbae888028e986)
2013-12-20 23:24:26 +00:00
Andy Polyakov
fc9c9e47f7 sha1-x86_64.pl: harmonize Win64 SE handlers for SIMD code pathes.
(and ensure stack alignment in the process)
(cherry picked from commit fc0503a25cd638b93f7af04640c20042e0329b3b)
2013-12-18 22:57:14 +01:00
Andy Polyakov
68e6ac4379 evp/e_[aes|camellia].c: fix typo in CBC subroutine.
It worked because it was never called.
(cherry picked from commit e9c80e04c1a3b5a0de8e666155ab4ecb2697a77d)
2013-12-18 22:56:24 +01:00
Andy Polyakov
e34b7e99fd sha512.c: fullfull implicit API contract in SHA512_Transform.
SHA512_Transform was initially added rather as tribute to tradition
than for practucal reasons. But use was recently found in ssl/s3_cbc.c
and it turned to be problematic on platforms that don't tolerate
misasligned references to memory and lack assembly subroutine.
(cherry picked from commit cdd1acd788020d2c525331da1712ada778f1373c)
2013-12-18 22:56:00 +01:00
Dr. Stephen Henson
a32ba49352 Check EVP errors for handshake digests.
Partial mitigation of PR#3200
(cherry picked from commit 0294b2be5f4c11e60620c0018674ff0e17b14238)
2013-12-18 13:27:15 +00:00
Dr. Stephen Henson
3a0c71541b verify parameter enumeration functions
(cherry picked from commit 9b3d75706ef0114362f04665a3c745bfef59d023)

Conflicts:

	crypto/x509/x509_vpm.c
2013-12-13 15:52:27 +00:00
Dr. Stephen Henson
adc6bd73e3 Add opaque ID structure.
Move the IP, email and host checking fields from the public
X509_VERIFY_PARAM structure into an opaque X509_VERIFY_PARAM_ID
structure. By doing this the structure can be modified in future
without risk of breaking any applications.
2013-12-13 15:36:31 +00:00
Dr. Stephen Henson
8c6d8c2a49 Backport TLS padding extension from master. 2013-12-13 15:29:26 +00:00
Dr. Stephen Henson
53a8f8c26d Fix for partial chain notification.
For consistency with other cases if we are performing
partial chain verification with just one certificate
notify the callback with ok==1.
2013-12-13 15:29:26 +00:00
Dr. Stephen Henson
bf4863b3f5 Verify parameter retrieval functions.
New functions to retrieve internal pointers to X509_VERIFY_PARAM
for SSL_CTX and SSL structures.
2013-12-13 15:29:26 +00:00
Dr. Stephen Henson
8f68678989 Don't use rdrand engine as default unless explicitly requested. 2013-12-13 15:29:26 +00:00
Dr. Stephen Henson
57c4e42d75 Get FIPS checking logic right.
We need to lock when *not* in FIPS mode.
2013-12-10 12:52:27 +00:00
Dr. Stephen Henson
ff672cf8dd remove obsolete STATUS file 2013-12-10 00:10:41 +00:00
Dr. Stephen Henson
d43b040773 Add release dates to NEWS 2013-12-10 00:08:33 +00:00
Andy Polyakov
422c8c36e5 ARM assembly pack: SHA update from master. 2013-12-09 23:53:42 +01:00
Andy Polyakov
b76310ba74 ARM assembly pack: AES update from master (including bit-sliced module). 2013-12-09 23:44:45 +01:00
Andy Polyakov
c012f6e576 bn/asm/armv4-mont.pl: add NEON code path.
(cherry picked from commit d1671f4f1a39d938499c67efe5d4a14c34c09b31)
2013-12-09 22:46:29 +01:00
Andy Polyakov
cf6d55961c crypto/bn/asm/x86_64-mont*.pl: update from master.
Add MULX/AD*X code paths and optimize even original code path.
2013-12-09 22:40:53 +01:00
Andy Polyakov
3aa1b1ccbb x86_64-xlate.pl: fix jrcxz in nasm case.
(cherry picked from commit 667053a2f3ad0788586f629f618d07b783bdde31)
2013-12-09 22:19:34 +01:00
Andy Polyakov
3dcae82fa9 x86_64-xlate.pl: minor update.
(cherry picked from commit 41965a84c4bc0f6694fd17203920a6672e3fac7b)
2013-12-09 21:53:41 +01:00
Dr. Stephen Henson
86b81ecb73 update $default_depflags 2013-12-08 13:21:02 +00:00
Dr. Stephen Henson
c43dc3dd77 Avoid multiple locks in FIPS mode.
PR: 3176.

In FIPS mode ssleay_rand_bytes is only used for PRNG seeding and is
performed in either a single threaded context (when the PRNG is first
initialised) or under a lock (reseeding). To avoid multiple locks disable
use of CRYPTO_LOCK_RAND in FIPS mode in ssleay_rand_bytes.
2013-12-08 13:21:02 +00:00
Andy Polyakov
e5eab8a199 bn/asm/x86_64-mont5.pl: comply with Win64 ABI.
PR: 3189
Submitted by: Oscar Ciurana
(cherry picked from commit c5d5f5bd0fe8b2313bec844c0f80f3d49562bfa8)
2013-12-04 00:02:18 +01:00
Andy Polyakov
7bab6eb6f0 crypto/bn/asm/rsaz-x86_64.pl: make it work on Win64.
(cherry picked from commit 8bd7ca99961f341ce2070373e86f22505aed2b2a)
2013-12-03 22:30:00 +01:00
Andy Polyakov
87d9526d0c crypto/bn/rsaz*: fix licensing note.
rsaz_exp.c: harmonize line terminating;
asm/rsaz-*.pl: minor optimizations.
asm/rsaz-x86_64.pl: sync from master.
(cherry picked from commit 31ed9a21315c571db443c68e4f618ecb51c631f9)
2013-12-03 22:17:55 +01:00
Andy Polyakov
36982f056a bn/asm/rsaz-x86_64.pl: fix prototype.
(cherry picked from commit 6efef384c6f649399dcc837825a9ca5a37069733)
2013-12-03 09:44:24 +01:00
Dr. Stephen Henson
c97ec5631b Fix warning. 2013-12-01 23:30:21 +00:00
Dr. Stephen Henson
fdb0d5dd8f Change header order to pick up OPENSSL_SYS_WIN32 2013-12-01 23:29:40 +00:00
Dr. Stephen Henson
81b6dfe40d Recongnise no-dane and no-libunbound 2013-12-01 23:12:27 +00:00
Dr. Stephen Henson
bc35b8e435 make update 2013-12-01 23:09:44 +00:00
Dr. Stephen Henson
6859f3fc12 Fix warnings. 2013-12-01 23:08:13 +00:00
Dr. Stephen Henson
8b2d5cc4a7 WIN32 fixes. 2013-12-01 23:07:18 +00:00
Dr. Stephen Henson
74184b6f21 RSAX no longer compiled. 2013-12-01 23:06:33 +00:00
Dr. Stephen Henson
6416aed586 Simplify and update openssl.spec 2013-11-27 15:35:02 +00:00
Dr. Stephen Henson
2a1b7bd380 New functions to retrieve certificate from SSL_CTX
New functions to retrieve current certificate or private key
from an SSL_CTX.

Constify SSL_get_private_key().
(cherry picked from commit a25f9adc778e17568fe2a325e5c3606adb8329f1)
2013-11-18 18:59:18 +00:00
Dr. Stephen Henson
4bba0bda61 Don't define SSL_select_next_proto if OPENSSL_NO_TLSEXT set
(cherry picked from commit 60aeb18750382362ec1c4e1cf05a7222c99ec886)
2013-11-18 18:59:03 +00:00
Dr. Stephen Henson
27baa8317a Use correct header length in ssl3_send_certifcate_request
(cherry picked from commit fdeaf55bf95e1e2a1e70cca8b68c7d8bbef7c8f0)
2013-11-17 17:50:11 +00:00
Dr. Stephen Henson
1abfa78a8b Constify. 2013-11-14 21:00:40 +00:00
Piotr Sikora
edc687ba0f Fix compilation with no-nextprotoneg.
PR#3106
2013-11-14 01:20:58 +00:00
Dr. Stephen Henson
ff0bdbed85 Allow match selecting of current certificate.
If pointer comparison for current certificate fails check
to see if a match using X509_cmp succeeds for the current
certificate: this is useful for cases where the certificate
pointer is not available.
(cherry picked from commit 6856b288a6e66edd23907b7fa264f42e05ac9fc7)
2013-11-13 23:47:49 +00:00
Rob Stradling
dc4bdf592f Additional "chain_cert" functions.
PR#3169

This patch, which currently applies successfully against master and
1_0_2, adds the following functions:

SSL_[CTX_]select_current_cert() - set the current certificate without
disturbing the existing structure.

SSL_[CTX_]get0_chain_certs() - get the current certificate's chain.

SSL_[CTX_]clear_chain_certs() - clear the current certificate's chain.

The patch also adds these functions to, and fixes some existing errors
in, SSL_CTX_add1_chain_cert.pod.
(cherry picked from commit 2f56c9c015dbca45379c9a725915b3b8e765a119)
2013-11-13 23:47:37 +00:00
Krzysztof Kwiatkowski
b03d0513d0 Delete duplicate entry.
PR#3172
(cherry picked from commit 4f055e34c3598cad00fca097d812fa3e6436d967)
2013-11-13 23:47:26 +00:00
Andy Polyakov
0de70011ad srp/srp_grps.h: make it Compaq C-friendly.
PR: 3165
Submitted by: Daniel Richard G.
(cherry picked from commit 2df9ec01d563f9cc2deab07e8c3391059d476592)
2013-11-12 22:19:40 +01:00
Andy Polyakov
220d1e5353 modes/asm/ghash-alpha.pl: update from HEAD.
PR: 3165
2013-11-12 21:59:01 +01:00
Andy Polyakov
ca44f72938 Make Makefiles OSF-make-friendly.
PR: 3165
(cherry picked from commit d1cf23ac86c05b22b8780e2c03b67230564d2d34)
2013-11-12 21:53:39 +01:00
Dr. Stephen Henson
18f49508a5 Fix memory leak.
(cherry picked from commit 16bc45ba956fdf07c7cda7feda88de597569df63)
2013-11-11 23:55:18 +00:00
Dr. Stephen Henson
5c50462e1e Typo. 2013-11-11 22:24:08 +00:00
Dr. Stephen Henson
a257865303 Fix for some platforms where "char" is unsigned.
(cherry picked from commit 08b433540416c5bc9a874ba0343e35ba490c65f1)
2013-11-11 22:18:07 +00:00
Andy Polyakov
60adefa610 Makefile.org: make FIPS build work with BSD make. 2013-11-10 23:06:41 +01:00
Dr. Stephen Henson
b5dde6bcc6 Check for missing components in RSA_check.
(cherry picked from commit 01be36ef70525e81fc358d2e559bdd0a0d9427a5)
2013-11-09 15:09:22 +00:00
Dr. Stephen Henson
024dbfd44c Document RSAPublicKey_{in,out} options.
(cherry picked from commit 7040d73d22987532faa503630d6616cf2788c975)
2013-11-09 15:09:22 +00:00
Dr. Stephen Henson
233069f8db Add CMS_SignerInfo_get0_signature function.
Add function to retrieve the signature from a CMS_SignerInfo structure:
applications can then read or modify it.
(cherry picked from commit e8df6cec4c09b9a94c4c07abcf0402d31ec82cc1)
2013-11-09 15:09:22 +00:00
Andy Polyakov
c76d6922b1 engines/ccgost/gost89.h: make word32 defintion unconditional.
Original definition depended on __LONG_MAX__ that is not guaranteed to
be present. As we don't support platforms with int narrower that 32 bits
it's appropriate to make defition inconditional.

PR: 3165
(cherry picked from commit 96180cac04591abfe50fc86096365553484bde65)
2013-11-08 23:10:21 +01:00
Andy Polyakov
3241496144 modes/asm/ghash-alpha.pl: make it work with older assembler.
PR: 3165
(cherry picked from commit d24d1d7daf515aa19fbf18f6371e3e617028a07c)
2013-11-08 23:10:09 +01:00
Dr. Stephen Henson
63fe69c12e Enable PSK in FIPS mode.
Enable PSK ciphersuites with AES or DES3 in FIPS mode.
(cherry picked from commit e0ffd129c16af90eb5e2ce54e57832c0046d1aaf)
2013-11-06 14:39:41 +00:00
Dr. Stephen Henson
a4947e4e06 Initialise context before using it. 2013-11-06 13:16:50 +00:00
Ben Laurie
262f1c524e PBKDF2 should be efficient. Contributed by Christian Heimes
<christian@python.org>.
2013-11-03 17:27:12 +00:00
Dr. Stephen Henson
bd80d0229c Add brainpool curves to trace output. 2013-11-02 14:07:21 +00:00
Dr. Stephen Henson
163d794845 Fix warning.
(cherry picked from commit 96e16bddb42563dc09187939dc20b35369d413b7)
2013-11-02 14:02:00 +00:00
Dr. Stephen Henson
0b33466b3f Add SSL_CONF command to set DH Parameters.
(cherry picked from commit c557f921dcb20a1bf2ce75e9dc7dd164e59ec3ea)
2013-11-02 13:42:03 +00:00
Dr. Stephen Henson
bed27f4db3 Fix argument processing.
(cherry picked from commit abf840e4f71c3a8795428c213fd37ece2a910443)
2013-11-02 13:41:51 +00:00
Dr. Stephen Henson
738a224bd0 Constification.
(cherry picked from commit 27f3b65f49ea91fcf4b46ec0298be51b4207214a)
2013-11-02 13:41:38 +00:00
Dr. Stephen Henson
044f8ca87d Extend SSL_CONF
Extend SSL_CONF to return command value types.

Add certificate and key options.

Update documentation.
(cherry picked from commit ec2f7e568ea18a22ab57326fffe78ef2aa6884f5)
2013-11-02 13:41:19 +00:00
Dr. Stephen Henson
45ee08d99b Typo.
(cherry picked from commit 13af1451595b514524b0efc17f99f6392ce090d5)
2013-11-02 13:41:06 +00:00
Piotr Sikora
5ff68e8f6d Fix SSL_OP_SINGLE_ECDH_USE
Don't require a public key in tls1_set_ec_id if compression status is
not needed. This fixes a bug where SSL_OP_SINGLE_ECDH_USE wouldn't work.
2013-11-01 21:37:46 +00:00
Dr. Stephen Henson
f14a4a861d Add -ecdh_single option.
Add -ecdh_single option to set SSL_OP_SINGLE_ECDH_USE on the command line.
2013-11-01 21:35:00 +00:00
Robin Seggelmann
f596e3c491 DTLS/SCTP struct authchunks Bug
PR: 2809

DTLS/SCTP requires DATA and FORWARD-TSN chunks to be protected with
SCTP-AUTH.  It is checked if this has been activated successfully for
the local and remote peer. Due to a bug, however, the
gauth_number_of_chunks field of the authchunks struct is missing on
FreeBSD, and was therefore not considered in the OpenSSL implementation.
This patch sets the corresponding pointer for the check correctly
whether or not this bug is present.
2013-10-30 14:37:22 +00:00
Robin Seggelmann
9fb523adce DTLS/SCTP Finished Auth Bug
PR: 2808

With DTLS/SCTP the SCTP extension SCTP-AUTH is used to protect DATA and
FORWARD-TSN chunks. The key for this extension is derived from the
master secret and changed with the next ChangeCipherSpec, whenever a new
key has been negotiated. The following Finished then already uses the
new key.  Unfortunately, the ChangeCipherSpec and Finished are part of
the same flight as the ClientKeyExchange, which is necessary for the
computation of the new secret. Hence, these messages are sent
immediately following each other, leaving the server very little time to
compute the new secret and pass it to SCTP before the finished arrives.
So the Finished is likely to be discarded by SCTP and a retransmission
becomes necessary. To prevent this issue, the Finished of the client is
still sent with the old key.
2013-10-30 14:37:22 +00:00
Ben Laurie
cecf4d98d0 Remove unused variable. 2013-10-21 03:34:00 +01:00
Nick Mathewson
070e40e2f5 Fix another gmt_unix_time case in server_random 2013-10-20 15:08:58 -07:00
Nick Mathewson
d757097bbc Do not include a timestamp in the Client/ServerHello Random field.
Instead, send random bytes, unless SSL_SEND_{CLIENT,SERVER}RANDOM_MODE
is set.

This is a forward-port of commits:
  4af793036f6ef4f0a1078e5d7155426a98d50e37
  f4c93b46edb51da71f09eda99e83eaf193a33c08
  3da721dac9382c48812c8eba455528fd59af2eef
  2583270191a8b27eed303c03ece1da97b9b69fd3

While the gmt_unix_time record was added in an ostensible attempt to
mitigate the dangers of a bad RNG, its presence leaks the host's view
of the current time in the clear.  This minor leak can help
fingerprint TLS instances across networks and protocols... and what's
worse, it's doubtful thet the gmt_unix_time record does any good at
all for its intended purpose, since:

    * It's quite possible to open two TLS connections in one second.

    * If the PRNG output is prone to repeat itself, ephemeral
      handshakes (and who knows what else besides) are broken.
2013-10-20 15:03:24 -07:00
Steve Marquess
7b112c2766 Remove gratuitous patent references 2013-10-20 22:19:47 +01:00
Dr. Stephen Henson
03ee8c2ed7 Fix no-ssl-trace 2013-10-20 22:07:33 +01:00
Dr. Stephen Henson
3495842bb0 Prevent use of RSA+MD5 in TLS 1.2 by default.
Removing RSA+MD5 from the default signature algorithm list
prevents its use by default.

If a broken implementation attempts to use RSA+MD5 anyway the sanity
checking of signature algorithms will cause a fatal alert.
(cherry picked from commit 77a0f740d00ecf8f6b01c0685a2f858c3f65a3dd)
2013-10-20 22:07:33 +01:00
Ben Laurie
face65dab8 Add clang debug target. 2013-10-20 13:23:14 +01:00
Andy Polyakov
e41a49c625 PPC assembly pack: make new .size directives profiler-friendly.
Suggested by: Anton Blanchard
(cherry picked from commit 76c15d790e07f6cc098be2d7b7f6ddc8acd11ca6)
2013-10-15 23:42:18 +02:00
Dr. Stephen Henson
3a55a42bff Add brainpool curves to NID table too.
(cherry picked from commit 6699cb84912f0d7c04acbf91c3e3dbdae5929857)
2013-10-15 12:09:54 +01:00
Dr. Stephen Henson
72550c52ed Fix warning.
(cherry picked from commit f6983769c1bcd6c3c6b6bbfbbc41848f6dccf127)
2013-10-15 11:33:58 +01:00
Dr. Stephen Henson
a9d0c56de1 Add test vectors from RFC7027
(cherry picked from commit 8ba2d4ed7f128e400693562efd35985068c45e4d)
2013-10-15 11:33:58 +01:00
Dr. Stephen Henson
469bcb0c24 RFC7027 (Brainpool for TLS) support.
(cherry picked from commit 695e8c36528f9c3275f5f56e9633ac6a0c11f2e3)
2013-10-15 11:33:58 +01:00
Andy Polyakov
43ce9cdde9 PPC assembly pack: update from master branch.
Includes multiple updates: AES module to comply with more ABI
flavors, SHA512 for PPC32, .size directives.
2013-10-15 00:31:45 +02:00
Andy Polyakov
011f89893c Add support for Cygwin-x86_64.
PR: 3110
Submitted by Corinna Vinschen.
(cherry picked from commit b3ef742cbbc1c8bf0e33dca60f08c65031647b07)
2013-10-14 16:59:05 +02:00
Andy Polyakov
958608ca1c Initial aarch64 bits.
(cherry picked from commit 039081b80977e2a5de84e1f88f8b4d025b559956)
2013-10-13 19:24:22 +02:00
Andy Polyakov
1aecb23f5b MIPS assembly pack: get rid of deprecated instructions.
Latest MIPS ISA specification declared 'branch likely' instructions
obsolete. To makes code future-proof replace them with equivalent.
(cherry picked from commit 0c2adb0a9be76da8de9bbfd5377215f71711a52e)
2013-10-13 13:18:21 +02:00
Andy Polyakov
9ed6fba2b4 aes/asm/bsaes-x86_64.pl: update from master.
Performance improvement and Windows-specific bugfix (PR#3139).
2013-10-12 21:47:54 +02:00
Andy Polyakov
df5c435c0b bn/asm/rsax-avx2.pl: minor optimization [for Decoded ICache].
(cherry picked from commit fa104be35e24f3fea895d55bb7042d6f4b2963e9)
2013-10-10 23:09:54 +02:00
Ben Laurie
1ebaf97c44 Constification. 2013-10-07 12:44:40 +01:00
Ben Laurie
c8c6914aac Merge branch 'OpenSSL_1_0_2-stable' into pre-aead 2013-10-05 21:20:24 +01:00
Andy Polyakov
c99028f252 evp/e_des3.c: fix typo with potential integer overflow on 32-bit platforms.
Submitted by: Yuriy Kaminskiy
(cherry picked from commit 524b00c0da42b129ed8622dfb3f5eab9cc5d6617)
2013-10-05 21:09:50 +01:00
Andy Polyakov
90d8c5862b perlasm/sparcv9_modes.pl: make it work even with seasoned perl.
PR: 3130
(cherry picked from commit 6b2cae0c16631c6c1ccf61080fc2aa9bd1b5ea1b)
2013-10-05 21:09:39 +01:00
Ben Laurie
2d5dd00f9e Merge branch 'OpenSSL_1_0_2-stable' into agl-1.0.2aead 2013-10-04 12:59:03 +01:00
Ben Laurie
cb52183836 Tidy. 2013-10-04 12:58:08 +01:00
Ben Laurie
ab3b624b0c Merge branch 'OpenSSL_1_0_2-stable' into agl-1.0.2aead 2013-10-04 12:48:24 +01:00
Ben Laurie
7c81de9a91 Make it build and test. 2013-10-03 19:02:58 +01:00
Andy Polyakov
4dfac659ff evp/e_des3.c: fix typo with potential integer overflow on 32-bit platforms.
Submitted by: Yuriy Kaminskiy
(cherry picked from commit 524b00c0da42b129ed8622dfb3f5eab9cc5d6617)
2013-10-03 10:57:45 +02:00
Andy Polyakov
66e0f9db08 perlasm/sparcv9_modes.pl: make it work even with seasoned perl.
PR: 3130
(cherry picked from commit 6b2cae0c16631c6c1ccf61080fc2aa9bd1b5ea1b)
2013-10-03 10:45:36 +02:00
Adam Langley
a2eef41993 AEAD Tests.
Add tests for AEAD functions: AES-128-GCM, AES-256-GCM and
ChaCha20+Poly1305.
2013-10-01 15:34:44 -04:00
Adam Langley
9a8646510b chacha20poly1305
Add support for Chacha20 + Poly1305.
2013-10-01 14:59:22 -04:00
Adam Langley
fa03d0117a Use AEAD for AES-GCM.
Switches AES-GCM ciphersuites to use AEAD interfaces.
2013-10-01 13:09:12 -04:00
Adam Langley
03614034e9 AEAD support in ssl/
This change allows AEADs to be used in ssl/ to implement SSL/TLS
ciphersuites.
2013-10-01 12:49:50 -04:00
Adam Langley
444b1d416b AEAD support.
This change adds an AEAD interface to EVP and an AES-GCM implementation
suitable for use in TLS.
2013-10-01 12:30:52 -04:00
Adam Langley
4055ca1f9e Rework tls1_change_cipher_state.
The previous version of the function made adding AEAD changes very
difficult. This change should be a semantic no-op - it should be purely
a cleanup.
2013-10-01 11:31:30 -04:00
Ben Laurie
7a216dfee5 Constification. 2013-10-01 14:51:04 +01:00
Dr. Stephen Henson
a78b21fc67 Update cms docs.
(cherry picked from commit dfcb42c68eac61b35d52f2fc53771c0f27dd9c29)
2013-10-01 14:01:19 +01:00
Ben Laurie
a808002bc3 Correctly test for no-ec.
(cherry picked from commit d5605699a15d870457f96b3e1795135228547324)
2013-10-01 14:01:19 +01:00
Dr. Stephen Henson
2fc368c111 Don't run ECDH CMS tests if EC disabled.
(cherry picked from commit b85f8afe3735eb77073481ffff2a4c972a6c3b21)
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
6ed3af7d50 Add X9.42 DH test.
(cherry picked from commit bbc098ffb3c0b09e0bbeca787e20efddc3242ec1)
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
d037e0d30c New CMS tests.
Add some ECDH CMS tests.
(cherry picked from commit 5cdc25a7545e44523b1f15418146bbda8eb03015)
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
51cb950904 Add X9.42 DH certificate to S/MIME test
(cherry picked from commit 75787fd833a11798e09b027991aabc5b7dafa335)
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
4bfa88bb4c Scripts to recreate S/MIME test certificates.
Add a script to generate keys and certificates for the S/MIME and CMS
tests.

Update certificates and add EC examples.
(cherry picked from commit a0957d55059f0b6052235737f7441fc35da41afd)
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
9d1e475db6 Custom key wrap option for cms utility.
(cherry picked from commit 5711885a2b31bfb623fb3738ce92a4cce4316bc7)
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
3e792793f6 add cofactor ECDH support from fips branch
(cherry picked from commit a3a2e3a43d13d8486c5e100e1bef7fec8e61b27b)
2013-10-01 14:01:18 +01:00
Ben Laurie
ac5cb33356 Fix compile errors.
(cherry picked from commit a0aaa5660a29f0faa86e5e51ce889299c5f3098b)
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
aaf74259ec CMS RFC2631 X9.42 DH enveloped data support.
(cherry picked from commit bd59f2b91db8fab86e8610de4565b5ab8de2b44b)

Conflicts:

	crypto/dh/dh.h
	crypto/dh/dh_err.c

Sync error codes with 1.0.1.
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
ecf9ceb90d Minor optimisation to KDF algorithm.
Don't need to use temporary buffer if remaining length equals digest length.
(cherry picked from commit 3f6b6f0b8cbd7173b6c007b07caa6ec34cda08c5)
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
5c4ff8ad37 Add KDF for DH.
Add X9.42 DH KDF. Move sharedinfo generation code to CMS library as the
same structure is used by DH and ECDH.

Move ASN1_OBJECT typedef to ossl_typ.h so it can be picked up by dh headers
without the need to use ASN1.
(cherry picked from commit dc1ce3bc64845d16314af1f11acf5384e4ae9b34)
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
dc427fc8e2 Return correct enveloped data type in ASN1 methods.
For RSA and DSA keys return an appropriate RecipientInfo type. By setting
CMS_RECIPINFO_NONE for DSA keys an appropriate error is returned if
an attempt is made to use DSA with enveloped data.
(cherry picked from commit 41b920ef01abeb4c4b1c0f11e647370ae6533d02)
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
e1e6c4dae7 Algorithm parameter support.
Check and set AlgorithmIdenfier parameters for key wrap algorithms.
Currently these just set parameters to NULL.
(cherry picked from commit e61f5d55bc0072e75023be8971ae6e849643f466)
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
1747fd1cc6 Add support for ECDH KARI.
Add support for ECDH in enveloped data. The CMS ctrls for the EC ASN1
method decode/encode the appropriate parameters from the CMS ASN1 data
and send appropriate data to the EC public key method.
(cherry picked from commit 88e20b8584a78c803eca7aa9fcf8c46ff0ece4ae)
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
a119822b90 Add support for X9.62 KDF.
Add X9.62 KDF to EC EVP_PKEY_METHOD.
(cherry picked from commit 25af7a5dbc05c7359d1d7f472d50d65a9d876b7e)
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
8c798690ce CMS support for key agreeement recipient info.
Add hooks to support key agreement recipient info type (KARI) using
algorithm specific code in the relevant public key ASN1 method.
(cherry picked from commit 17c2764d2e6fc5a010ad3c12662068689ed2ad17)
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
ea6bf26657 Add new CMS tests.
Add new tests to cms-test.pl covering PSS and OAEP.
(cherry picked from commit 32b18e0338a326723680c7c347d3f04bf4e24b40)
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
4a26fd6e3b Add -keyopt option to cms utility.
Add support for custom public key parameters in the cms utility using
the -keyopt switch. Works for -sign and also -encrypt if -recip is used.
(cherry picked from commit 02498cc885b801f38f33c0a0d08d4603fd6350c7)
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
dddb38834e Update cms docs.
Document use of -keyopt to use RSA-PSS and RSA-OAEP modes.
(cherry picked from commit 4bf4a6501c6ca3fa1853f07c82e0e9cfe22dee45)
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
af7d6b936b CMS RSA-OAEP and RSA-PSS support.
Extend RSA ASN1 method to support CMS PSS signatures for both sign
and verify.

For signing the EVP_PKEY_CTX parameters are read and the appropriate
CMS structures set up.

For verification the CMS structures are analysed and the corresponding
parameters in the EVP_PKEY_CTX set.

Also add RSA-OAEP support.

For encrypt the EVP_PKEY_CTX parameters are used.

For decrypt the CMS structure is uses to set the appropriate EVP_PKEY_CTX
parameters.
(cherry picked from commit 0574cadf857b19485465b9d71b7dec9549857a4d)

Also sync error codes with OpenSSL 1.0.1 and add new ones.
2013-10-01 14:01:18 +01:00
Dr. Stephen Henson
a64b8786b5 Update to OAEP support.
Add OAEP ctrls to retrieve MD and label. Return errors if
an attempt is made to set or retrieve OAEP parameters when
padding mode is not OAEP.
(cherry picked from commit 211a14f6279f127f7a5a59948819bd939131b0b6)
2013-10-01 14:01:17 +01:00
Dr. Stephen Henson
25f93585a7 Exetended OAEP support.
Extend OAEP support. Generalise the OAEP padding functions to support
arbitrary digests. Extend EVP_PKEY RSA method to handle the new OAEP
padding functions and add ctrls to set the additional parameters.
(cherry picked from commit 271fef0ef39a1c0cb5233a5adf3ff8733abb375e)

Conflicts:

	CHANGES
2013-10-01 14:01:17 +01:00
Dr. Stephen Henson
0d5a49e150 Add FIPS RSA error code.
Add some RSA error codes used by the FIPS module.
2013-10-01 14:01:17 +01:00
Dr. Stephen Henson
5c49a98c5e Set CMS EnvelopedData version correctly.
(cherry picked from commit ff7b6ce9db329eb48775bb81e0ecbbd2a9b23c1c)
2013-10-01 14:01:17 +01:00
Dr. Stephen Henson
869772ff08 Initialise CMS signature buffer length properly.
(cherry picked from commit e0f7cfda68881da6829ea39430e1a5c28ed05ece)
2013-10-01 14:01:17 +01:00
Dr. Stephen Henson
f2edf3181e CMS public key parameter support.
Add support for customisation of CMS handling of signed and enveloped
data from custom public key parameters.

This will provide support for RSA-PSS and RSA-OAEP but could also be
applied to other algorithms.
(cherry picked from commit e365352d6a6368039392fed14a328f8c0bf955c3)
2013-10-01 14:01:17 +01:00
Dr. Stephen Henson
d6dc5c506a Add control to retrieve signature MD.
(cherry picked from commit 810639536cfa66df0c232fa4f15a7e5f00f31ce8)
2013-10-01 14:01:17 +01:00
Dr. Stephen Henson
eebd5e5dd7 Add new OIDs from RFC5753
Add OIDs for KDF schemes from RFC5753 and add cross references for
each type and the appropriate digest to use.
(cherry picked from commit 6af440ced43d766e418c2eb0cda1525eecd3e62b)

Conflicts:

	crypto/objects/obj_dat.h
	crypto/objects/obj_mac.num
2013-10-01 14:01:17 +01:00
Dr. Stephen Henson
868b266451 Add new OID to pSpecified from PKCS#1
(cherry picked from commit e423c360fd2670b151c8e61439b36a77c77f77c3)

Conflicts:

	crypto/objects/obj_dat.h
	crypto/objects/obj_mac.num
2013-10-01 14:01:17 +01:00
Dr. Stephen Henson
3fa23ff0f1 Add FIPS 186-2 DSA parameter generation algorithm.
Backport support for FIPS 186-2 DSA parameter generation from
HEAD. Redirect to FIPS in FIPS mode and workaround prototype error.
2013-10-01 14:01:17 +01:00
Dr. Stephen Henson
c275fb091e Extend DH parameter generation support.
Add support for DH parameter generation using DSA methods including
FIPS 186-3.
(cherry picked from commit 3909087801729bebb3a1182936a855a47e4ee9c9)
2013-10-01 14:01:17 +01:00
Dr. Stephen Henson
90c341c601 Enhance DH dup functions.
Make DHparams_dup work properly with X9.42 DH parameters.
(cherry picked from commit d3cc91eee2cba07d8908f0fea531c62863ed3ccf)
2013-10-01 14:01:17 +01:00
Dr. Stephen Henson
52d0e1ca4e If present print j, seed and counter values for DH
(cherry picked from commit c9577ab5eae56cb00c17a0eb724229f0bc1397a0)

Conflicts:

	crypto/dh/dh_ameth.c
2013-10-01 14:01:17 +01:00
Dr. Stephen Henson
c6f3386577 EVP support for wrapping algorithms.
Add support for key wrap algorithms via EVP interface.

Generalise AES wrap algorithm and add to modes, making existing
AES wrap algorithm a special case.

Move test code to evptests.txt
(cherry picked from commit 97cf1f6c2854a3a955fd7dd3a1f113deba00c9ef)

Conflicts:

	CHANGES
2013-10-01 14:01:17 +01:00
Andy Polyakov
cf65a07256 evptests.txt: add XTS test vectors
(cherry picked from commit c9a8e3d1c754cee8551d36cd54a1ea675ee8d055)
2013-10-01 14:01:17 +01:00
Andy Polyakov
051dc9db2b evptests.txt: additional GCM test vectors.
(cherry picked from commit ca303d333bb3ff61a946f92b2569ee98ae18c3cb)
2013-10-01 14:01:17 +01:00
Ben Laurie
93a886b45a Fix warnings.
(cherry picked from commit 282a480a352e2aac4fad6e75932d951659bff62d)
2013-10-01 14:01:17 +01:00
Dr. Stephen Henson
ec19082ecc GCM and CCM test support
Add code to support GCM an CCM modes in evp_test. On encrypt this
will compare the expected ciphertext and tag. On decrypt it will
compare the expected plaintext: tag comparison is done internally.

Add a simple CCM test case and convert all tests from crypto/modes/gcm128.c
(cherry picked from commit 15652f9825de25481676767aa73945409f9c82e2)
2013-10-01 14:01:17 +01:00
Dr. Stephen Henson
0eff7c7c88 Add CCM ciphers to tables.
(cherry picked from commit 95248de327cb468d2ead36930fdf3d05d10d7b6a)
2013-10-01 14:01:17 +01:00
Dr. Stephen Henson
6c4b3514d7 New SP 800-56A compliant version of DH_compute_key().
(cherry picked from commit bc91494e064ebdcff68f987947f97e404fbca0b5)
2013-10-01 14:01:17 +01:00
Dr. Stephen Henson
d84cca7447 Typo.
(cherry picked from commit 415ece73015a0e24ea934ecfb857d022952bb65b)
2013-10-01 14:01:16 +01:00
Ben Laurie
3a8b23bfd9 Re-add accidentally deleted #endif. 2013-10-01 12:34:44 +01:00
Ben Laurie
63fe322160 Merge remote-tracking branch 'agl/1.0.2alpn' into agl-alpn
Conflicts:
	ssl/ssl3.h
	ssl/t1_lib.c
2013-10-01 12:20:02 +01:00
Ben Laurie
c808798013 Produce PEM we would consume. 2013-09-25 13:55:06 +01:00
Ben Laurie
379f21ce5c Show useful errors. 2013-09-24 23:13:22 +01:00
Ben Laurie
4f3b1b3eb9 Merge remote-tracking branch 'trevp/pempick' into OpenSSL_1_0_2-stable 2013-09-24 12:47:54 +01:00
Dr. Stephen Henson
b49df9502e Disable Dual EC DRBG.
Return an error if an attempt is made to enable the Dual EC DRBG: it
is not used by default.
(cherry picked from commit a4870de5aaef562c0947494b410a2387f3a6d04d)
2013-09-22 18:25:58 +01:00
Ben Laurie
4f8a706dc7 Merge remote-tracking branch 'trevp/pemfix' into trev-pem-fix 2013-09-20 15:39:08 -07:00
Dr. Stephen Henson
7560f63909 Fix warning. 2013-09-18 15:10:22 +01:00
Dr. Stephen Henson
1dfb1b103c DTLS version usage fixes.
Make DTLS behave like TLS when negotiating version: record layer has
DTLS 1.0, message version is 1.2.

Tolerate different version numbers if version hasn't been negotiated
yet.
(cherry picked from commit 40088d8b8190a2a33828a769c23bf35de542c7dc)
2013-09-18 13:47:05 +01:00
Dr. Stephen Henson
6e1987ca1d DTLS trace support.
Add DTLS record header parsing, different client hello format and add
HelloVerifyRequest message type.

Add code to d1_pkt.c to send message headers to the message callback.
(cherry picked from commit 890f2f8b92b385ef3898cdb4a15a071ffcf8107f)

Conflicts:

	ssl/ssl_locl.h
2013-09-18 13:46:03 +01:00
Dr. Stephen Henson
d307176931 Suite B support for DTLS 1.2
Check for Suite B support using method flags instead of version numbers:
anything supporting TLS 1.2 cipher suites will also support Suite B.

Return an error if an attempt to use DTLS 1.0 is made in Suite B mode.
(cherry picked from commit 4544f0a69161a37ee3edce3cc1bc34c3678a4d64)
2013-09-18 13:46:03 +01:00
Dr. Stephen Henson
c391a74266 Always return errors in ssl3_get_client_hello
If we successfully match a cookie don't set return value to 2 as this
results in other error conditions returning 2 as well.

Instead set return value to -2 which can be checked later if everything
else is OK.
(cherry picked from commit c56f5b8edfbcec704f924870daddd96a5f768fbb)
2013-09-18 13:46:02 +01:00
Dr. Stephen Henson
65a87d3cc3 Dual DTLS version methods.
Add new methods DTLS_*_method() which support both DTLS 1.0 and DTLS 1.2 and
pick the highest version the peer supports during negotiation.

As with SSL/TLS options can change this behaviour specifically
SSL_OP_NO_DTLSv1 and SSL_OP_NO_DTLSv1_2.
(cherry picked from commit c6913eeb762edffddecaaba5c84909d7a7962927)

Conflicts:

	CHANGES
2013-09-18 13:46:02 +01:00
Dr. Stephen Henson
b60b9e7afe Enable TLS 1.2 ciphers in DTLS 1.2.
Port TLS 1.2 GCM code to DTLS. Enable use of TLS 1.2 only ciphers when in
DTLS 1.2 mode too.
(cherry picked from commit 4221c0dd3004117c63b182af5e8ab345b7265902)
2013-09-18 13:46:02 +01:00
Dr. Stephen Henson
919834dc84 Update fixed DH requirements.
The relaxed signing requirements for fixed DH certificates apply to DTLS 1.2
too.
(cherry picked from commit fbbaaccaca32742f09dfb02e5e28dcd20f64a17f)
2013-09-18 13:46:02 +01:00
Dr. Stephen Henson
efc17286f8 DTLS 1.2 cached record support.
Add DTLS1.2 support for cached records when computing handshake macs
instead of the MD5+SHA1 case for DTLS < 1.2 (this is a port of the
equivalent TLS 1.2 code to DTLS).
(cherry picked from commit 04fac50045929e7078cad4835478dd7f16b6d4bd)
2013-09-18 13:46:02 +01:00
Dr. Stephen Henson
acec5a6244 Provisional DTLS 1.2 support.
Add correct flags for DTLS 1.2, update s_server and s_client to handle
DTLS 1.2 methods.

Currently no support for version negotiation: i.e. if client/server selects
DTLS 1.2 it is that or nothing.
(cherry picked from commit c3b344e36a088283731b4f65a70e85b100f55686)

Conflicts:

	apps/s_server.c
2013-09-18 13:46:02 +01:00
Dr. Stephen Henson
68039af3e7 Remove versions test from dtls1_buffer_message
Since this is always called from DTLS code it is safe to assume the header
length should be the DTLS value. This avoids the need to check the version
number and should work with any version of DTLS (not just 1.0).
(cherry picked from commit 9cf0f187542f080031f83c5e538d3e1872ac09d1)
2013-09-18 13:46:02 +01:00
Dr. Stephen Henson
da1247d653 Extend DTLS method macros.
Extend DTLS method creation macros to support version numbers and encryption
methods. Update existing code.
(cherry picked from commit cfd298b7aef2b095bee8d172a6a40d6c59d1574b)
2013-09-18 13:46:02 +01:00
Dr. Stephen Henson
052d0358f2 Enable various DTLS extensions.
Some TLS extensions were disabled for DTLS. Possibly because they caused
problems with the old duplicated code. Enable them again.
(cherry picked from commit 874a18cfadc6bac0ad73482325f2ca72dfccdb82)
2013-09-18 13:46:02 +01:00
Dr. Stephen Henson
1b6ab411d3 Use enc_flags when deciding protocol variations.
Use the enc_flags field to determine whether we should use explicit IV,
signature algorithms or SHA256 default PRF instead of hard coding which
versions support each requirement.
(cherry picked from commit cbd64894ec687c6f37d8e43c16dff78e63f6be87)

Conflicts:

	ssl/ssl_locl.h
2013-09-18 13:46:02 +01:00
Dr. Stephen Henson
d88d98edd3 Use appropriate versions of SSL3_ENC_METHOD
(cherry picked from commit 6de2649a6b349bde9c9fb62c3a3d5d6344d8259c)
2013-09-18 13:46:02 +01:00
Dr. Stephen Henson
741c9959f6 DTLS revision.
Revise DTLS code. There was a *lot* of code duplication in the
DTLS code that generates records. This makes it harder to maintain and
sometimes a TLS update is omitted by accident from the DTLS code.

Specifically almost all of the record generation functions have code like
this:

some_pointer = buffer + HANDSHAKE_HEADER_LENGTH;
... Record creation stuff ...
set_handshake_header(ssl, SSL_MT_SOMETHING, message_len);

...

write_handshake_message(ssl);

Where the "Record creation stuff" is identical between SSL/TLS and DTLS or
in some cases has very minor differences.

By adding a few fields to SSL3_ENC to include the header length, some flags
and function pointers for handshake header setting and handshake writing the
code can cope with both cases.

(cherry picked from commit 173e72e64c6a07ae97660c322396b66215009f33)
2013-09-18 13:46:02 +01:00
Dr. Stephen Henson
7c23127fde Add functions to set ECDSA_METHOD structure.
Add various functions to allocate and set the fields of an ECDSA_METHOD
structure.
(cherry picked from commit 94c2f77a62be7079ab1893ab14b18a30157c4532)
2013-09-18 01:23:40 +01:00
Bodo Moeller
8b9722a3c0 Merge branch 'OpenSSL_1_0_2-stable' of openssl.net:openssl into OpenSSL_1_0_2-stable 2013-09-17 09:59:14 +02:00
Bodo Moeller
8c149cfd83 Sync with version from master. 2013-09-17 09:55:27 +02:00
Trevor Perrin
6da498991c Various custom extension fixes.
Force no SSL2 when custom extensions in use.
Don't clear extension state when cert is set.
Clear on renegotiate.

Conflicts:
	ssl/t1_lib.c
2013-09-16 18:40:53 +01:00
Rob Stradling
86a66deb7e Update CHANGES. 2013-09-16 14:03:22 +01:00
Rob Stradling
9409e18179 Tidy up comments. 2013-09-16 14:03:21 +01:00
Rob Stradling
6a0b803fc0 Use TLS version supplied by client when fingerprinting Safari. 2013-09-16 14:03:21 +01:00
Rob Stradling
5fa3b54788 Fix compilation with no-ec and/or no-tlsext. 2013-09-16 14:03:21 +01:00
Rob Stradling
07df5018be Don't prefer ECDHE-ECDSA ciphers when the client appears to be Safari on OS X.
OS X 10.8..10.8.3 has broken support for ECDHE-ECDSA ciphers.
2013-09-16 14:03:21 +01:00
Bodo Moeller
1b9a59c36a Sync CHANGES and NEWS files. 2013-09-16 14:54:34 +02:00
Bodo Moeller
8f89c33451 Merge branch 'OpenSSL_1_0_2-stable' of /usr/local/google/home/bmoeller/openssl/openssl into OpenSSL_1_0_2-stable 2013-09-16 14:51:10 +02:00
Bodo Moeller
485d7d5904 Fix overly lenient comparisons:
- EC_GROUP_cmp shouldn't consider curves equal just because
      the curve name is the same. (They really *should* be the same
      in this case, but there's an EC_GROUP_set_curve_name API,
      which could be misused.)

    - EC_POINT_cmp shouldn't return 0 for ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
      or EC_R_INCOMPATIBLE_OBJECTS errors because in a cmp API, 0 indicates
      equality (not an error).

    Reported by: king cope

(cherry picked from commit 312a46791ab465cfa3bf26764361faed0e5df014)
2013-09-16 14:50:48 +02:00
Bodo Moeller
e3720888c7 Fix overly lenient comparisons:
- EC_GROUP_cmp shouldn't consider curves equal just because
      the curve name is the same. (They really *should* be the same
      in this case, but there's an EC_GROUP_set_curve_name API,
      which could be misused.)

    - EC_POINT_cmp shouldn't return 0 for ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
      or EC_R_INCOMPATIBLE_OBJECTS errors because in a cmp API, 0 indicates
      equality (not an error).

    Reported by: king cope

(cherry picked from commit 312a46791ab465cfa3bf26764361faed0e5df014)
2013-09-16 13:06:30 +02:00
Andy Polyakov
d75e384ff8 Extend OPENSSL_ia32cap_P (backport from HEAD). 2013-09-15 22:13:54 +02:00
Andy Polyakov
c340c7a88c crypto/armcap.c: fix typo in rdtsc subroutine.
PR: 3125
Submitted by: Kyle McMartin
(cherry picked from commit 8e52a9063a8a016bdac780005256994d26f9c2f9)
2013-09-15 22:10:49 +02:00
Dr. Stephen Henson
9ecf6e93af add -badsig option to corrupt CRL signatures for testing too
(cherry picked from commit 139cd16cc58330840890f914c318f00de6bfd831)
2013-09-14 13:53:44 +01:00
Dr. Stephen Henson
a41735288c Add missing code from SSL_CONF backport. 2013-09-14 13:53:44 +01:00
Scott Deboy
8ae78c6bd9 Initialize next_proto in s_server - resolves incorrect attempts to free
Cherry pick of b0d27cb9028cbf552612baa42255737cca0e32d2.
2013-09-13 11:31:39 -04:00
Adam Langley
cb3cec4adf Add tests for ALPN functionality.
Cherry-picked from a898936218bc279b5d7cdf76d58a25e7a2d419cb.
2013-09-13 11:27:26 -04:00
Adam Langley
b0d6f3c58f Support ALPN.
This change adds support for ALPN[1] in OpenSSL. ALPN is the IETF
blessed version of NPN and we'll be supporting both ALPN and NPN for
some time yet.

Cherry-picked from 6f017a8f9db3a79f3a3406cf8d493ccd346db691.

[1] https://tools.ietf.org/html/draft-ietf-tls-applayerprotoneg-00
2013-09-13 11:27:22 -04:00
Ben Laurie
0338648426 Constification. 2013-09-10 17:58:44 +01:00
Andy Polyakov
c7dc404188 crypto/modes/asm/aesni-gcm-x86_64.pl: minor optimization.
Avoid occasional up to 8% performance drops.
(cherry picked from commit 7a1a12232a84621271bf808107f3be9a2df5121a)
2013-09-09 21:46:02 +02:00
Andy Polyakov
08853158b6 crypto/bn/asm/x86_64-mont.pl: minor optimization.
(cherry picked from commit 72a158703bf2b33f4eba6920302941560f7a848d)
2013-09-09 21:42:48 +02:00
Andy Polyakov
74e0187663 Revert "x86cpuid.pl: fix extended feature flags detection."
This reverts commit 514f1a783515e9beb73b759a483c078813cf8ba0.
2013-09-09 21:35:15 +02:00
Dr. Stephen Henson
bb4aa95c81 Remove ancient PATENTS section and FAQ reference.
(cherry picked from commit ce4555967ec0fa7c0b9c15823be52dc23fd09a40)
2013-09-08 21:25:38 +01:00
Dr. Stephen Henson
5117d50b7e Partial path fix.
When verifying a partial path always check to see if the EE certificate
is explicitly trusted: the path could contain other untrusted certificates.
(cherry picked from commit 52073b76753815ef1dcc3ab3f9dba75803f717f4)
2013-09-08 21:25:10 +01:00
Dr. Stephen Henson
593605d3ec Document supported curve functions.
(cherry picked from commit c3eb33763bf2999843fe4124f3f39dea6edc26e6)
2013-09-03 15:43:59 +01:00
Dr. Stephen Henson
c9ea4df8f9 Document -force_pubkey option.
(cherry picked from commit b093a06866bf632a97a9a0286e2d08f69c3cf7dd)
2013-08-21 13:41:17 +01:00
Dr. Stephen Henson
89ff56faf1 Correct ECDSA example.
(cherry picked from commit 3a918ea2bbf4175d9461f81be1403d3781b2c0dc)
2013-08-20 17:30:16 +01:00
Dr. Stephen Henson
9855026c43 fix printout of expiry days if -enddate is used in ca
(cherry picked from commit f7ac0ec89d0daefdea2956c55c17f1246e81c0a6)
2013-08-19 21:55:07 +01:00
Dr. Stephen Henson
904348a492 Time difference functions.
Backport of ASN1_TIME_diff and OPENSSL_gmtime_diff functions from master
branch.
2013-08-19 21:55:07 +01:00
Dr. Stephen Henson
aaaa18392d new command line option -stdname to ciphers utility
(cherry picked from commit 51b9115b6dcaf94718de3c8b4d97b00f8cd63cd5)
2013-08-19 20:25:39 +01:00
Dr. Stephen Henson
8c33e40d2e Add new test option set the version in generated certificates: this
is needed to test some profiles/protocols which reject certificates
with unsupported versions.
(cherry picked from commit df316fd43c5b1e063b84279f245087a578b67e9b)
2013-08-19 18:10:04 +01:00
Dr. Stephen Henson
0d04af1e72 option to output corrupted signature in certificates for testing purposes
(cherry picked from commit 96cfba0fb46a392697295eb6c1350e3110411a75)
2013-08-19 18:09:44 +01:00
Dr. Stephen Henson
8f17495800 update usage messages
(cherry picked from commit 7c8ac5050473ec938f2c2e3e5c9063d680be36a1)
2013-08-19 18:09:26 +01:00
Dr. Stephen Henson
95c1a24853 add -naccept <n> option to s_server to automatically exit after <n> connections
(cherry picked from commit b5cadfb564a604c0ba1c49984ac796cfd8310731)
2013-08-19 17:42:02 +01:00
Dr. Stephen Henson
08374de10f with -rev close connection if client sends "CLOSE"
(cherry picked from commit 685755937a4f9f8b16f8953f631e14808f785c39)
2013-08-19 14:14:05 +01:00
Dr. Stephen Henson
506e70a216 Add simple external session cache to s_server. This serialises sessions
just like a "real" server making it easier to trace any problems.

(manually applied from commit 35b0ea4efe24dee3194964588655d1a3187c6e63)
2013-08-19 14:13:56 +01:00
Dr. Stephen Henson
0cca92cdd3 Remove commented out debug line. 2013-08-19 14:13:38 +01:00
Dr. Stephen Henson
5b430cfc44 Make no-ec compilation work.
(cherry picked from commit 14536c8c9c0abb894afcadb9a58b4b29fc8f7a4d)
2013-08-19 14:13:38 +01:00
Dr. Stephen Henson
171c4da568 Add -rev test option to s_server to just reverse order of characters received
by client and send back to server. Also prints an abbreviated summary of
the connection parameters.
(cherry picked from commit 4f3df8bea2981b1547eaae8704f0207c7766c2fa)
2013-08-19 14:13:38 +01:00
Dr. Stephen Henson
04611fb0f1 Add -brief option to s_client and s_server to summarise connection details.
New option -verify_quiet to shut up the verify callback unless there is
an error.

(manually applied from commit 2a7cbe77b3abb244c2211d22d7aa3416b97c9342)
2013-08-19 14:13:24 +01:00
Dr. Stephen Henson
df430489cf Add documentation.
Preliminary documentation for chain and verify stores and certificate chain
setting functions.
(cherry picked from commit eeb15452a053c14305210522be0e7313cb763bac)
2013-08-18 13:53:32 +01:00
Dr. Stephen Henson
5085e57fb5 Return 1 when setting ECDH auto mode.
(cherry picked from commit 42082eda6f3d64ce87184d65c4eae06d677e971c)
2013-08-18 13:53:00 +01:00
Michael Tuexen
75b81247a0 DTLS message_sequence number wrong in rehandshake ServerHello
This fix ensures that
* A HelloRequest is retransmitted if not responded by a ClientHello
* The HelloRequest "consumes" the sequence number 0. The subsequent
ServerHello uses the sequence number 1.
* The client also expects the sequence number of the ServerHello to
be 1 if a HelloRequest was received earlier.
This patch fixes the RFC violation.
(cherry picked from commit b62f4daac00303280361924b9cc19b3e27528b15)
2013-08-13 18:55:16 +01:00
Michael Tuexen
2c1a5c1039 DTLS handshake fix.
Reported by: Prashant Jaikumar <rmstar@gmail.com>

Fix handling of application data received before a handshake.
(cherry picked from commit 0c75eeacd3285b395dc75b65c3e6fe6ffbef59f0)
2013-08-08 13:31:54 +01:00
Dr. Stephen Henson
71c34b7f2d Fix verify loop with CRL checking.
PR #3090
Reported by: Franck Youssef <fry@open.ch>

If no new reason codes are obtained after checking a CRL exit with an
error to avoid repeatedly checking the same CRL.

This will only happen if verify errors such as invalid CRL scope are
overridden in a callback.
(cherry picked from commit 4b26645c1a71cf9ce489e4f79fc836760b670ffe)
2013-08-06 16:08:04 +01:00
Kaspar Brand
b0cfaf58ad Fix for PEM_X509_INFO_read_bio.
PR: 3028
Fix bug introduced in PEM_X509_INFO_bio which wouldn't process RSA keys
correctly if they appeared first.
(cherry picked from commit 5ae8d6bcbaff99423a2608559d738a3fcf7ed6dc)
2013-08-06 16:04:52 +01:00
Andy Polyakov
9dc07f04c3 crypto/evp/e_aes.c: fix logical pre-processor bug and formatting.
Bug would emerge when XTS is added to bsaes-armv7.pl. Pointed out by
Ard Biesheuvel of Linaro.
(cherry picked from commit 044f63086051d7542fa9485a1432498c39c4d8fa)
2013-08-03 17:09:37 +02:00
Andy Polyakov
f15c16200b crypto/bn/asm/rsax-x86_64.pl: make it work on Darwin.
(cherry picked from commit fd8ad019e194f54fbc651897c1b3b4cc1898c6c4)
2013-08-03 16:30:40 +02:00
Andy Polyakov
4e09add6f8 crypto/sha/asm/sha*-x86_64.pl: comply with Win64 ABI.
(cherry picked from commit 006784378db1a8957fcf587ee1deaa5cf2ae76c7)
2013-07-31 23:52:21 +02:00
Trevor
355a6236be Cosmetic touchups. 2013-07-31 16:38:43 +01:00
Ben Laurie
6d7fa9c25c Support new rsaz asm stuff. 2013-07-31 16:37:19 +01:00
Andy Polyakov
82ae22ef4d bn/asm/rsaz-avx2.pl: Windows-specific fix.
(cherry picked from commit 5c57c69f9ebcc933161a24d77f87f17011c9977b)
2013-07-12 19:01:23 +02:00
Ben Laurie
b56bae5126 s/rsaz_eligible/rsaz_avx2_eligible/.
(cherry picked from commit 852f837f5ee81f2633ddf753fa3a30661ad3835a)
2013-07-12 18:53:05 +02:00
Andy Polyakov
2d3f31e0a1 sha512-586.pl: fix typo.
Submitted by: Gisle Vanem
(cherry picked from commit 241fba4ea9772662e55577de996273cdb272e611)
2013-07-10 10:02:34 +02:00
Andy Polyakov
ae74191e38 Remove RSAX engine, superseded by RSAZ module.
(cherry picked from commit f5b132d652e47af3cde3293d54c1bd028d00758d)

Conflicts [resloved]:

	Configure
2013-07-05 22:16:10 +02:00
Andy Polyakov
ab8233ab81 Take RSAZ modules into build loop, add glue and engage.
RT: 2582, 2850
(cherry picked from commit ca48ace5c52feb0082954fff00a44e1914b9e7e9)

Conflicts:

	Configure
2013-07-05 21:53:05 +02:00
Andy Polyakov
d5572bdc64 Add RSAZ assembly modules.
RT: 2582, 2850
(cherry picked from commit 0b4bb91db65697ab6d3a0fc05b140887cbce3080)
2013-07-05 21:49:19 +02:00
Andy Polyakov
e3990db59c bn/asm/x86_86-mont.pl: optimize reduction for Intel Core family.
(cherry picked from commit 26e43b48a3fa72fc5d7f3aa849af3d7917deea9d)
2013-07-05 21:15:16 +02:00
Andy Polyakov
87d90528ac bn/bn_exp.c: harmonize.
(cherry picked from commit cbce8c4644fa8dfa72e62a2aa921a74eee6d62c9)
2013-07-05 21:01:51 +02:00
Trevor
e27711cfdd Trying cherrypick:
Add support for arbitrary TLS extensions.

Contributed by Trevor Perrin.

Conflicts:

	CHANGES
	ssl/ssl.h
	ssl/ssltest.c
	test/testssl

Fix compilation due to #endif.

Cherrypicking more stuff.

Cleanup of custom extension stuff.

serverinfo rejects non-empty extensions.

Omit extension if no relevant serverinfo data.

Improve error-handling in serverinfo callback.

Cosmetic cleanups.

s_client documentation.

s_server documentation.

SSL_CTX_serverinfo documentation.

Cleaup -1 and NULL callback handling for custom extensions, add tests.

Cleanup ssl_rsa.c serverinfo code.

Whitespace cleanup.

Improve comments in ssl.h for serverinfo.

Whitespace.

Cosmetic cleanup.

Reject non-zero-len serverinfo extensions.

Whitespace.

Make it build.

Conflicts:

	test/testssl
2013-07-03 11:53:30 +01:00
Andy Polyakov
28c08222c0 config: fix executable format detection on latest FreeBSD.
Submitted by: Bryan Drewery
PR: 3075
(cherry picked from commit c256e69d3f3acd0794ae9c1f353f4093bd4c8878)
2013-06-30 23:59:30 +02:00
Andy Polyakov
8508a80998 bn/bn_exp.c: Solaris-specific fix, T4 MONTMUL relies on alloca.
(cherry picked from commit b74ce8d9489b319c0d097ff116b5a0bdb634462d)
2013-06-30 23:14:31 +02:00
Andy Polyakov
7850a8bc04 x86_64-xlate.pl: Windows fixes.
(cherry picked from commit a9d14832fd98cb0c13b53fddea39765fb259358c)
2013-06-30 23:14:19 +02:00
Andy Polyakov
fccec89084 aesni-sha256-x86_64.pl: fix typo in Windows SEH.
(cherry picked from commit 42386fdb62176ed3af237dd3e802ba9b8c0d4def)
2013-06-30 23:14:04 +02:00
Andy Polyakov
6c7fa27404 PA-RISC assembler pack: switch to bve in 64-bit builds.
PR: 3074
(cherry picked from commit 02450ec69dda7815ba1e7bd74eb30f0ae1eb3042)
2013-06-30 23:13:23 +02:00
Andy Polyakov
e7f9c08ab8 SPARC T4 DES support: fix typo.
(cherry picked from commit 8ee3c7e676c5edb1d5fbe0d66b7ce307a4f92899)
2013-06-18 11:07:24 +02:00
Andy Polyakov
03c8441b14 Optimize SPARC T4 MONTMUL support.
Improve RSA sing performance by 20-30% by:
- switching from floating-point to integer conditional moves;
- daisy-chaining sqr-sqr-sqr-sqr-sqr-mul sequences;
- using MONTMUL even during powers table setup;
(cherry picked from commit 4ddacd9921f48013b5cd011e4b93b294c14db1c2)
2013-06-18 11:07:16 +02:00
Ben Laurie
e887c4187e Backport single makefile from master. 2013-06-13 15:09:48 +01:00
Ben Laurie
933aee6199 Wrong include path. 2013-06-13 13:26:22 +01:00
Dr. Stephen Henson
90e7f983b5 Typo: don't call RAND_cleanup during app startup. 2013-06-12 21:16:31 +01:00
Andy Polyakov
f00962aaf3 aesni-sha1-x86_64.pl: update performance data.
(cherry picked from commit 3b848d3401de1892415e46561ae75f06ff65e823)
2013-06-10 22:52:06 +02:00
Andy Polyakov
3eccd2e53a aesni-sha256-x86_64.pl: harmonize with latest sha512-x86_64.pl.
(cherry picked from commit 42b9a4177bf9d465ff9ac8d4e1526301d809a87e)
2013-06-10 22:51:55 +02:00
Andy Polyakov
fcd0e61c24 sha1-x86_64.pl: add AVX2+BMI code path.
(cherry picked from commit cd8d7335afcdef97312e05a9bd29b17a00796f48)
2013-06-10 22:51:47 +02:00
Andy Polyakov
e7a02b24c1 sha512-x86_64.pl: upcoming-Atom-specific optimization.
(cherry picked from commit c7f690c243f5ad3dccaa6dbb918c92eb39622711)
2013-06-10 22:51:31 +02:00
Andy Polyakov
cbe6bb54e6 sha[256|512]-586.pl: add more SIMD code paths.
(cherry picked from commit 32213d8d77e0ce6afc4b19f94c228812d0bf8fd5)
2013-06-10 22:50:32 +02:00
Andy Polyakov
23966faca4 ghash-x86_64.pl: add Haswell performance data.
(cherry picked from commit b42759158d8b7e5b23c7a24d11bc7f2194f55007)
2013-06-10 22:50:23 +02:00
Andy Polyakov
514f1a7835 x86cpuid.pl: fix extended feature flags detection.
(cherry picked from commit 1bc0b68d7b8c7620487310ed84fa273ba0d9f428)
2013-06-10 22:49:35 +02:00
Dr. Stephen Henson
af908bc48b Don't use RC2 with PKCS#12 files in FIPS mode.
(cherry picked from commit cdb6c48445ded3daafab32e5f266943d07bb512b)
2013-06-05 15:06:02 +01:00
Dr. Stephen Henson
233ebcb543 Fix PSS signature printing.
Fix PSS signature printing: consistently use 0x prefix for hex values for
padding length and trailer fields.
(cherry picked from commit deb24ad53147f5a8dd63416224a5edd7bbc0e74a)
2013-06-05 15:06:02 +01:00
Dr. Stephen Henson
da0c007254 Reencode with X509_CRL_ctx_sign too.
(cherry picked from commit 96940f4f2d0300c033379a87db0ff19e598c6264)
2013-06-05 15:06:02 +01:00
Ben Laurie
01bc7dcafc Header needed for SOCK_STREAM on FreeBSD. 2013-06-04 16:27:05 +01:00
Ben Laurie
83e2ff8c51 Fix missing/incorrect prototype. 2013-06-04 16:17:30 +01:00
Ben Laurie
e3120586fb Missing prototypes. 2013-06-04 15:14:18 +01:00
Ben Laurie
3941aa12f1 Remove added ;. 2013-06-04 15:05:18 +01:00
Andy Polyakov
0c10cf0ad6 crypto/modes: even more strict aliasing fixes [and fix bug in cbc128.c from
previous cbc128.c commit].
2013-06-04 14:31:23 +01:00
Andy Polyakov
62874a5a69 cbc128.c: fix strict aliasing warning. 2013-06-04 14:30:49 +01:00
Andy Polyakov
8c1f9c56fd crypto/bn/bn_exp.c: SPARC portability fix.
(cherry picked from commit b69437e1e5cdf9c6dfda17cc238f87f730b198ac)
2013-06-01 09:59:54 +02:00
Andy Polyakov
75063c1527 aesni-sha1-x86_64.pl: Atom-specific optimization.
(cherry picked from commit 4df2280b4f4747256a729116fef0f1c2af457522)
2013-05-25 19:09:47 +02:00
Andy Polyakov
5de583aa91 sha512-x86_64.pl: +16% optimization for Atom.
(and pending AVX2 changes).
(cherry picked from commit 504bbcf3cd236353d7e5ef66fc3bfbf5c7935791)
2013-05-25 19:04:48 +02:00
Andy Polyakov
a0675d8149 vpaes-x86[_64].pl: minor Atom-specific optimization.
(cherry picked from commit 988d11b64193da65e7f9bbf436ad2a08d8d57142)
2013-05-25 18:58:54 +02:00
Andy Polyakov
a7e9ed95ec evp/e_aes.c: engage SPARC T4 AES support [from master]. 2013-05-20 16:36:53 +02:00
Andy Polyakov
615d0edf1f evp/e_aes.c: engage AES-NI GCM stitch. 2013-05-20 16:30:21 +02:00
Andy Polyakov
e775755dec evp/evp_err.c: update from master. 2013-05-20 16:16:34 +02:00
Andy Polyakov
a1bf7de5a7 evp/e_camellia.c: engage SPARC T5 Camellia support [from master]. 2013-05-20 16:09:13 +02:00
Andy Polyakov
047c02e8db evp/e_des[3].c: engage SPARC T4 DES support. 2013-05-20 16:08:39 +02:00
Andy Polyakov
c92989d2b7 Add BN support for SPARC VIS3 and T4 [from master]. 2013-05-20 15:48:13 +02:00
Andy Polyakov
039e7875ff md5_locl.h: enable assembly support on SPARC [from master]. 2013-05-20 00:33:09 +02:00
Andy Polyakov
48b7b96bd0 sparcv9cap.c: update from master. 2013-05-20 00:16:18 +02:00
Andy Polyakov
747b7a636a Add MD5 SPARC T4 code from master. 2013-05-20 00:08:15 +02:00
Andy Polyakov
635f56fabd Add SHA SPARC T4 code from master. 2013-05-20 00:04:38 +02:00
Andy Polyakov
c617bc0054 Add Camellia SPARC T4 module from master. 2013-05-19 23:58:54 +02:00
Andy Polyakov
d215724753 Add AES SPARC T4 module from master. 2013-05-19 23:54:34 +02:00
Andy Polyakov
9c1ee1bed5 Add DES SPARC T4 module from master. 2013-05-19 23:51:22 +02:00
Andy Polyakov
14ef63c15e Add perlasm/sparcv9_modes.pl from master. 2013-05-19 23:47:38 +02:00
Andy Polyakov
5a456140c1 des_enc.m4: update from master. 2013-05-19 23:43:12 +02:00
Andy Polyakov
1ff546737b evp/Makefile: fix typo. 2013-05-19 23:11:03 +02:00
Andy Polyakov
56f0b25754 Add EVP glue to AES-NI SHA256 stich [from master]. 2013-05-19 22:35:37 +02:00
Andy Polyakov
b0f78dc018 Add AES-NI SHA256 stitch and take it into build loop [from master]. 2013-05-19 22:23:18 +02:00
Andy Polyakov
1f2d194acf aesni-sha1-x86_64.pl: update from master. 2013-05-19 22:18:52 +02:00
Andy Polyakov
aacfb2a2c6 Add AES-NI GCM stich and take it into build loop [from master]. 2013-05-19 22:06:18 +02:00
Andy Polyakov
0ba304dd31 gcm128.c: update from master (add AVX and VIS3 support). 2013-05-19 21:55:30 +02:00
Andy Polyakov
8eb2da5fbb ghash-sparcv9.pl: update from master. 2013-05-19 21:53:14 +02:00
Andy Polyakov
d1896e8ccd ghash-x86_64.pl: update from master. 2013-05-19 21:51:19 +02:00
Andy Polyakov
0edcb7a556 ghash-x86.pl: update from master. 2013-05-19 21:46:03 +02:00
Andy Polyakov
ecc2c5d81a sha512-x86_64.pl: update from master. 2013-05-19 21:36:54 +02:00
Andy Polyakov
441dec8e9f sha512-586.pl: update from master. 2013-05-19 21:36:38 +02:00
Andy Polyakov
4f566c360b sha256-598.pl: update from master. 2013-05-19 21:35:55 +02:00
Andy Polyakov
e10cd58090 sha1-x86_64.pl: update from master. 2013-05-19 21:33:04 +02:00
Andy Polyakov
5c8ae6d93e sha1-586.pl: update from master. 2013-05-19 21:32:29 +02:00
Andy Polyakov
e72f7677bf crypto/perlasm: update from master. 2013-05-19 21:27:59 +02:00
Andy Polyakov
e815d72b1f RFC6689 support: add missing commit (git noob alert). 2013-05-15 20:41:51 +02:00
Andy Polyakov
ddf918673d ssl/dnssec.c: compilation errors. 2013-05-15 20:38:58 +02:00
Andy Polyakov
8517d0c00d Initial support for RFC6689, a.k.a. DANE.
Note that it initially applies to 1.0.2, and not to HEAD. This is
in order to allow development with existing libunbound installations
that are dependent on OpenSSL 1.0.x. More details in RT.

RT: 3003
2013-05-13 15:36:06 +02:00
Dr. Stephen Henson
8659dc73f4 Reencode certificates in X509_sign_ctx.
Reencode certificates in X509_sign_ctx as well as X509_sign.

This was causing a problem in the x509 application when it modified an
existing certificate.
(cherry picked from commit c6d8adb8a45186617e0a8e2c09469bd164b92b31)
2013-05-02 12:24:33 +01:00
Andy Polyakov
07464787a8 crypto/modes/modes_lcl.h: let STRICT_ALIGNMENT be on ARMv7.
While ARMv7 in general is capable of unaligned access, not all instructions
actually are. And trouble is that compiler doesn't seem to differentiate
those capable and incapable of unaligned access. Side effect is that kernel
goes into endless loop retrying same instruction triggering unaligned trap.
Problem was observed in xts128.c and ccm128.c modules. It's possible to
resolve it by using (volatile u32*) casts, but letting STRICT_ALIGNMENT
be feels more appropriate.
(cherry picked from commit 3bdd80521a81d50ade4214053cd9b293f920a77b)
2013-04-13 21:19:16 +02:00
Dr. Stephen Henson
e9a3aa9721 Set s->d1 to NULL after freeing it.
(cherry picked from commit 04638f2fc335a6dc2af8e5d556d36e29c261dcd2)
2013-04-08 18:39:52 +01:00
Dr. Stephen Henson
a8cc9f1873 Typo.
(cherry picked from commit 0ded2a06891a4d5a207d8f29aa9a89a755158170)
2013-03-31 17:43:42 +01:00
Dr. Stephen Henson
f25c3c0542 Call RAND_cleanup in openssl application.
(cherry picked from commit 944bc29f9004cf8851427ebfa83ee70b8399da57)
2013-03-28 14:29:11 +00:00
Matt Caswell
4e5b9645e8 Make binary curve ASN.1 work in FIPS mode.
Don't check for binary curves by checking methods: the values will
be different in FIPS mode as they are redirected to the validated module
version.
(cherry picked from commit 94782e0e9c28bd872107b8f814f4db68c9fbf5ab)
2013-03-26 16:58:29 +00:00
Dr. Stephen Henson
04347839ea enhance EC method to support setting curve type when generating keys and add parameter encoding option
(cherry picked from commit 24edfa9df9e6315b107b7c2d8ce0634208e8c350)
2013-03-20 15:54:05 +00:00
Dr. Stephen Henson
e14b8410ca Disable compression for DTLS.
The only standard compression method is stateful and is incompatible with
DTLS.
2013-03-19 13:46:57 +00:00
Andy Polyakov
2a1ab7b438 x86cpuid.pl: make it work with older CPUs.
PR: 3005
(cherry picked from commit 5702e965d759dde8a098d8108660721ba2b93a7d)
2013-03-18 19:50:09 +01:00
Andy Polyakov
dd1e4fbcc0 e_aes_cbc_hmac_sha1.c: fix rare bad record mac on AES-NI plaforms.
PR: 3002
(cherry picked from commit 5c60046553716fcf160718f59160493194f212dc)
2013-03-18 19:35:20 +01:00
Michael Tuexen
3f84d34c37 Avoid unnecessary fragmentation.
(cherry picked from commit 80ccc66d7eedb2d06050130c77c482ae1584199a)
2013-03-18 14:32:59 +00:00
Dr. Stephen Henson
d7e429b91d Encode INTEGER correctly.
If an ASN1_INTEGER structure is allocated but not explicitly set encode
it as zero: don't generate an invalid zero length INTEGER.
(cherry picked from commit 1643edc63c3e15b6db5a15a728bc288f2cc2bbc7)
2013-03-18 14:22:01 +00:00
Dr. Stephen Henson
155ef13c67 Typo.
(cherry picked from commit 1546fb780bc11556a18d70c5fb29af4a9d5beaff)
2013-03-18 13:59:57 +00:00
Dr. Stephen Henson
c3466040ec Update ordinals. 2013-03-04 19:28:57 +00:00
Andy Polyakov
2d9be79407 x86_64-gf2m.pl: fix typo.
(cherry picked from commit 342dbbbe4eb82b6e12163965a12f580c2deb03ad)
2013-03-01 22:37:53 +01:00
Andy Polyakov
2e4b7eede3 x86_64-gf2m.pl: add missing Windows build fix for #2963.
PR: 3004
(cherry picked from commit 7c43601d4424575d589f028aed0d5a4ae337527f)
2013-03-01 21:57:25 +01:00
Dr. Stephen Henson
e1dee801b9 Add function CMS_RecipientInfo_encrypt
Add CMS_RecipientInfo_encrypt: this function encrypts an existing content
encryption key to match the key in the RecipientInfo structure: this is
useful if a new recpient is added to and existing enveloped data structure.

Add documentation.
(cherry picked from commit e1f1d28f34cc5cfc87772e0d8331e00137a4a213)
2013-02-26 17:06:08 +00:00
Dr. Stephen Henson
3c53fd892c Fix error codes.
(cherry picked from commit 388aff08dc38d6e4c5146d445b62f581bb484ed4)
2013-02-26 17:05:39 +00:00
Dr. Stephen Henson
c46990b13b Demo code for SSL_CONF API
Two example programs one for command line argument processing and
one for configuration file processing.
(cherry picked from commit 3646578ae7e29230d7b05a5487ad12990b2ae688)
2013-02-26 16:34:23 +00:00
Dr. Stephen Henson
1510b1f4c2 Update SSL_CONF docs.
Fix some typos and update version number first added: it has now been
backported to OpenSSL 1.0.2.
(cherry picked from commit 4365e4aad97fa37e4a97eb2270a64c03e6547014)
2013-02-26 15:29:49 +00:00
Dr. Stephen Henson
f8a69166ed New -force_pubkey option to x509 utility to supply a different public
key to the one in a request. This is useful for cases where the public
key cannot be used for signing e.g. DH.
(cherry picked from commit 43206a2d7cc87c959535c0f69e2aa3b364eafd6e)
2013-02-25 15:25:27 +00:00
Andy Polyakov
b9eef98883 bn_nist.c: work around clang 3.0 bug.
(cherry picked from commit 750398acd85a7ae220d272d28a76dff7bb269c31)
2013-02-16 11:37:38 +01:00
Nick Alcock
ae5c1ca377 Fix POD errors to stop make install_docs dying with pod2man 2.5.0+
podlators 2.5.0 has switched to dying on POD syntax errors. This means
that a bunch of long-standing erroneous POD in the openssl documentation
now leads to fatal errors from pod2man, halting installation.

Unfortunately POD constraints mean that you have to sort numeric lists
in ascending order if they start with 1: you cannot do 1, 0, 2 even if
you want 1 to appear first. I've reshuffled such (alas, I wish there
were a better way but I don't know of one).
(cherry picked from commit 5cc270774258149235f69e1789b3370f57b0e27b)
2013-02-15 19:39:59 +01:00
Andy Polyakov
188ab7df98 cms-test.pl: make it work with not-so-latest perl.
(cherry picked from commit 9c437e2faded18b4ef6499d7041c65d6e216955b)
2013-02-14 16:39:06 +01:00
Dr. Stephen Henson
2e3d02fe1a Upate FAQ.
Add description of "allocate and encode" operation for ASN1 routines.

Document how versioning will for after the letter release reaches
y.
(cherry picked from commit 2527b94fec345c0bec58f4c7a810b7b8d0552b17)
2013-02-12 16:05:02 +00:00
David Woodhouse
3a3a1af1da Check DTLS_BAD_VER for version number.
The version check for DTLS1_VERSION was redundant as
DTLS1_VERSION > TLS1_1_VERSION, however we do need to
check for DTLS1_BAD_VER for compatibility.

PR:2984
(cherry picked from commit d980abb22e22661e98e5cee33d760ab0c7584ecc)
2013-02-12 15:15:32 +00:00
Dr. Stephen Henson
0ced72c608 Fix in ssltest is no-ssl2 configured
(cherry picked from commit cbf9b4aed3e209fe8a39e1d6f55aaf46d1369dc4)
2013-02-11 18:28:48 +00:00
Lutz Jaenicke
5584a95490 FAQ/README: we are now using Git instead of CVS
(cherry picked from commit f88dbb8385c199a2a28e9525c6bba3a64bda96af)
2013-02-11 11:33:19 +01:00
Andy Polyakov
a3e66779d3 sparccpuid.S: work around emulator bug on T1.
(cherry picked from commit 3caeef94bd045608af03b061643992e3afd9c445)
2013-02-11 10:41:22 +01:00
Andy Polyakov
919eab8a8b s3_cbc.c: make CBC_MAC_ROTATE_IN_PLACE universal.
(cherry picked from commit f93a41877d8d7a287debb7c63d7b646abaaf269c)
2013-02-08 21:36:06 +01:00
Andy Polyakov
e9baceab5a s3_cbc.c: get rid of expensive divisions [from master]. 2013-02-08 16:59:26 +01:00
Andy Polyakov
b05561c4b7 ssl/[d1|s3]_pkt.c: harmomize orig_len handling.
(cherry picked from commit 8545f73b8919770a5d012fe7a82d6785b69baa27)
2013-02-08 10:40:51 +01:00
Dr. Stephen Henson
b7355af421 Fix IV check and padding removal.
Fix the calculation that checks there is enough room in a record
after removing padding and optional explicit IV. (by Steve)

For AEAD remove the correct number of padding bytes (by Andy)
(cherry picked from commit 32cc2479b473c49ce869e57fded7e9a77b695c0d)
2013-02-08 10:40:39 +01:00
Adam Langley
0462eedf5e Fix for EXP-RC2-CBC-MD5
MD5 should use little endian order. Fortunately the only ciphersuite
affected is EXP-RC2-CBC-MD5 (TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5) which
is a rarely used export grade ciphersuite.
(cherry picked from commit f306b87d766e6ecf30824635c7c395b67cff9dbc)
2013-02-08 10:40:13 +01:00
Andy Polyakov
82425f2c28 e_aes_cbc_hmac_sha1.c: align calculated MAC at cache line.
It also ensures that valgring is happy.
(cherry picked from commit 2141e6f30b1fd2906830fd23d8eae71fe72acc47)
2013-02-08 10:35:02 +01:00
Andy Polyakov
af010edd55 e_aes_cbc_hmac_sha1.c: cleanse temporary copy of HMAC secret.
(cherry picked from commit 529d27ea472fc2c7ba9190a15a58cb84012d4ec6)
2013-02-06 13:56:15 +00:00
Andy Polyakov
5966f4d973 e_aes_cbc_hmac_sha1.c: address the CBC decrypt timing issues.
Address CBC decrypt timing issues and reenable the AESNI+SHA1 stitch.
(cherry picked from commit 125093b59f3c2a2d33785b5563d929d0472f1721)
2013-02-06 13:56:15 +00:00
Andy Polyakov
eeb486a5f4 ssl/*: remove SSL3_RECORD->orig_len to restore binary compatibility.
Kludge alert. This is arranged by passing padding length in unused
bits of SSL3_RECORD->type, so that orig_len can be reconstructed.
(cherry picked from commit 8bfd4c659f180a6ce34f21c0e62956b362067fba)
2013-02-06 13:56:15 +00:00
Dr. Stephen Henson
d7f55e76f2 Don't access EVP_MD_CTX internals directly.
(cherry picked from commit 04e45b52ee3be81121359cc1198fd01e38096e9f)
2013-02-06 13:56:14 +00:00
Andy Polyakov
7d9e781a1d s3/s3_cbc.c: allow for compilations with NO_SHA256|512.
(cherry picked from commit d5371324d978e4096bf99b9d0fe71b2cb65d9dc8)
2013-02-06 13:56:14 +00:00
Andy Polyakov
e0c21a0b6b ssl/s3_cbc.c: md_state alignment portability fix.
RISCs are picky and alignment granted by compiler for md_state can be
insufficient for SHA512.
(cherry picked from commit 36260233e7e3396feed884d3f501283e0453c04f)
2013-02-06 13:56:14 +00:00
Andy Polyakov
1dfb4b9400 ssl/s3_cbc.c: uint64_t portability fix.
Break dependency on uint64_t. It's possible to declare bits as
unsigned int, because TLS packets are limited in size and 32-bit
value can't overflow.
(cherry picked from commit cab13fc8473856a43556d41d8dac5605f4ba1f91)
2013-02-06 13:56:14 +00:00
Dr. Stephen Henson
e5cb774323 typo.
(cherry picked from commit 34ab3c8c711ff79c2b768f0b17e4b2a78fd1df5d)
2013-02-06 13:56:14 +00:00
Dr. Stephen Henson
73390e6ba5 Add ordinal for CRYPTO_memcmp: since this will affect multiple
branches it needs to be in a "gap".
(cherry picked from commit 81ce0e14e72e8e255ad1bd9c7cfaa47a6291919c)
2013-02-06 13:56:13 +00:00
Dr. Stephen Henson
d91d9acc58 Timing fix mitigation for FIPS mode.
We have to use EVP in FIPS mode so we can only partially mitigate
timing differences.

Make an extra call to EVP_DigestSignUpdate to hash additonal blocks
to cover any timing differences caused by removal of padding.
(cherry picked from commit b908e88ec15aa0a74805e3f2236fc4f83f2789c2)
2013-02-06 13:56:13 +00:00
Ben Laurie
820988a0c0 Oops. Add missing file.
(cherry picked from commit 014265eb02e26f35c8db58e2ccbf100b0b2f0072)
2013-02-06 13:56:13 +00:00
Ben Laurie
1326a64a33 Update DTLS code to match CBC decoding in TLS.
This change updates the DTLS code to match the constant-time CBC
behaviour in the TLS.
(cherry picked from commit 9f27de170d1b7bef3d46d41382dc4dafde8b3900)
2013-02-06 13:56:13 +00:00
Ben Laurie
e0da2c2ed2 Don't crash when processing a zero-length, TLS >= 1.1 record.
The previous CBC patch was bugged in that there was a path through enc()
in s3_pkt.c/d1_pkt.c which didn't set orig_len. orig_len would be left
at the previous value which could suggest that the packet was a
sufficient length when it wasn't.
(cherry picked from commit 6cb19b7681f600b2f165e4adc57547b097b475fd)
2013-02-06 13:56:13 +00:00
Ben Laurie
fb0a59cc58 Make CBC decoding constant time.
This patch makes the decoding of SSLv3 and TLS CBC records constant
time. Without this, a timing side-channel can be used to build a padding
oracle and mount Vaudenay's attack.

This patch also disables the stitched AESNI+SHA mode pending a similar
fix to that code.

In order to be easy to backport, this change is implemented in ssl/,
rather than as a generic AEAD mode. In the future this should be changed
around so that HMAC isn't in ssl/, but crypto/ as FIPS expects.
(cherry picked from commit e130841bccfc0bb9da254dc84e23bc6a1c78a64e)
2013-02-06 13:56:12 +00:00
Ben Laurie
f5cd3561ba Add and use a constant-time memcmp.
This change adds CRYPTO_memcmp, which compares two vectors of bytes in
an amount of time that's independent of their contents. It also changes
several MAC compares in the code to use this over the standard memcmp,
which may leak information about the size of a matching prefix.
(cherry picked from commit 2ee798880a246d648ecddadc5b91367bee4a5d98)
2013-02-06 13:56:12 +00:00
Dr. Stephen Henson
115f7fa562 Merge branch 'OpenSSL_1_0_2-stable' of /home/steve/src/git/openssl into OpenSSL_1_0_2-stable 2013-02-04 15:14:11 +00:00
Dr. Stephen Henson
c867d87180 Fix for trace code: SSL3 doesn't include a length value for
encrypted premaster secret value.
(cherry picked from commit ea34a58385058748c51037bfb2c3208ee639f5f1)
2013-02-04 15:14:00 +00:00
Andy Polyakov
2a713eadc3 bn_word.c: fix overflow bug in BN_add_word.
(cherry picked from commit 134c00659a1bc67ad35a1e4620e16bc4315e6e37)
2013-02-02 22:37:35 +01:00
Andy Polyakov
2e7900b624 x86_64 assembly pack: keep making Windows build more robust.
PR: 2963 and a number of others
(cherry picked from commit 4568182a8b8cbfd15cbc175189029ac547bd1762)
2013-02-02 19:56:43 +01:00
Dr. Stephen Henson
f8435919a1 Fix warning: lenmax isn't used any more. 2013-01-24 14:08:28 +00:00
Dr. Stephen Henson
1db4354b53 Don't include comp.h in cmd_cd.c if OPENSSL_NO_COMP set 2013-01-23 01:11:05 +00:00
Andy Polyakov
3f233a1e77 x86_64 assembly pack: make Windows build more robust [from master].
PR: 2963 and a number of others
2013-01-22 22:51:29 +01:00
Andy Polyakov
25917e972d TABLE update. 2013-01-22 21:22:20 +01:00
Andy Polyakov
8812a81bdd Configure: update linux-mips* lines [from master]. 2013-01-22 21:21:44 +01:00
Andy Polyakov
b17ffba915 bn/asm/mips.pl: hardwire local call to bn_div_words. 2013-01-22 21:16:02 +01:00
Dr. Stephen Henson
3619e34f50 Don't include comp.h if no-comp set. 2013-01-20 01:10:03 +00:00
Ben Laurie
6924686b78 Merge branch 'OpenSSL_1_0_2-stable' of openssl.net:openssl into OpenSSL_1_0_2-stable 2013-01-19 18:36:44 +00:00
Ben Laurie
92745f8116 Remove extraneous brackets (clang doesn't like them). 2013-01-19 18:24:00 +00:00
Ben Laurie
17cf9864e0 Add MacOS 64-bit debug target. 2013-01-19 18:23:36 +00:00
Andy Polyakov
5cfefd3ce3 engines/ccgost: GOST fixes [from master].
Submitted by: Dmitry Belyavsky, Seguei Leontiev
PR: 2821
2013-01-19 18:24:03 +01:00
Ben Laurie
9ccc6f4382 Can't check a size_t for < 0. 2013-01-19 15:01:18 +00:00
Andy Polyakov
3c92471723 .gitignore adjustments 2013-01-19 13:31:29 +01:00
Dr. Stephen Henson
1a932ae094 -named_curve option handled automatically now. 2013-01-18 15:41:06 +00:00
Dr. Stephen Henson
57912ed329 Add code to download CRLs based on CRLDP extension.
Just a sample, real world applications would have to be cleverer.
2013-01-18 15:38:13 +00:00
Dr. Stephen Henson
e998f8aeb8 cipher is not used in s_server any more. 2013-01-18 15:05:28 +00:00
Dr. Stephen Henson
e318431e54 New option to add CRLs for s_client and s_server. 2013-01-18 14:37:14 +00:00
Dr. Stephen Henson
6a10f38daa initial support for delta CRL generations by diffing two full CRLs 2013-01-17 18:51:50 +00:00
Dr. Stephen Henson
c095078890 Typo (PR2959). 2013-01-17 18:21:54 +00:00
Dr. Stephen Henson
c644b83227 constify 2013-01-17 16:35:50 +00:00
Dr. Stephen Henson
75f535315a New functions to set lookup_crls callback and to retrieve internal X509_STORE
from X509_STORE_CTX.
2013-01-17 16:32:33 +00:00
Dr. Stephen Henson
7c283d9e97 add option to get a certificate or CRL from a URL 2013-01-17 16:08:02 +00:00
Dr. Stephen Henson
2aa3ef78b6 print out issuer and subject unique identifier fields in certificates 2013-01-16 15:08:34 +00:00
Dr. Stephen Henson
1c0964e87f add wrapper function for certificate download 2013-01-15 18:01:54 +00:00
Dr. Stephen Henson
5c8d41be85 Generalise OCSP I/O functions to support dowloading of other ASN1
structures using HTTP. Add wrapper function to handle CRL download.
2013-01-15 18:01:31 +00:00
Dr. Stephen Henson
b286640360 Update default dependency flags. 2013-01-15 16:26:04 +00:00
Dr. Stephen Henson
75a8ff9263 make update 2013-01-15 16:24:07 +00:00
Dr. Stephen Henson
50b5966e57 Add support for broken protocol tests (backport from master branch) 2013-01-15 16:18:13 +00:00
Dr. Stephen Henson
8eb4456f93 Make whitespace consistent with master branch. 2013-01-15 15:55:54 +00:00
Ben Laurie
24c45faba0 Fix some clang warnings. 2013-01-13 21:06:36 +00:00
Ben Laurie
010ac38a98 Correct EVP_PKEY_verifyrecover to EVP_PKEY_verify_recover (RT 2955). 2013-01-12 12:51:58 +00:00
Dr. Stephen Henson
1c25ed5dbb In FIPS mode use PKCS#8 format when writing private keys:
traditional format uses MD5 which is prohibited in FIPS mode.
2013-01-07 16:16:43 +00:00
Dr. Stephen Henson
bf1d32e52a Change default bits to 1024 2013-01-07 16:13:48 +00:00
Dr. Stephen Henson
6c86b69729 Add .gitignore from master branch. 2013-01-06 21:34:51 +00:00
Ben Laurie
72dfff2d5e Fix warning. 2013-01-06 21:03:05 +00:00
Dr. Stephen Henson
3341b820cc add support for separate verify can chain stores to s_client (backport from HEAD) 2012-12-30 16:27:15 +00:00
Dr. Stephen Henson
ede5f6cf74 add -chain options to s_client (backrpot from HEAD) 2012-12-30 16:17:29 +00:00
Dr. Stephen Henson
321a9fea75 make no-comp compile 2012-12-30 16:05:03 +00:00
Dr. Stephen Henson
2e00f46b51 stop warning when compiling with no-comp 2012-12-30 01:12:19 +00:00
Dr. Stephen Henson
8c3f868983 remove unused cipher functionality from s_client 2012-12-30 00:03:40 +00:00
Dr. Stephen Henson
d03cc94f47 Update debug-steve* options. 2012-12-29 23:59:18 +00:00
Dr. Stephen Henson
5477ff9ba2 make JPAKE work again, fix memory leaks 2012-12-29 23:58:44 +00:00
Dr. Stephen Henson
46b11600b0 update ordinals 2012-12-29 14:18:14 +00:00
Dr. Stephen Henson
15387e4ce0 Delegate command line handling for many common options in s_client/s_server to
the SSL_CONF APIs.

This is complicated a little because the SSL_CTX structure is not available
when the command line is processed: so just check syntax of commands initially
and store them, ready to apply later.

(backport from HEAD)
2012-12-29 14:16:41 +00:00
Dr. Stephen Henson
49ef33fa34 add SSL_CONF functions and documentation (backport from HEAD) 2012-12-29 13:30:56 +00:00
Dr. Stephen Henson
1166323530 Update ordinals. 2012-12-26 23:53:52 +00:00
Dr. Stephen Henson
29113688a1 Portability fix: use BIO_snprintf and pick up strcasecmp alternative
definitions from e_os.h
2012-12-26 23:51:41 +00:00
Dr. Stephen Henson
44c970746f typo 2012-12-26 22:43:43 +00:00
Dr. Stephen Henson
bc200e691c SSL/TLS record tracing code (backport from HEAD). 2012-12-26 22:40:46 +00:00
Dr. Stephen Henson
a08f8d73cc Reject zero length ec point format list.
Give more meaningful error is attempt made to use incorrect curve.

(from HEAD)
2012-12-26 18:26:11 +00:00
Dr. Stephen Henson
b52f12b3ba handle point format list retrieval for clients too (from HEAD) 2012-12-26 18:20:07 +00:00
Dr. Stephen Henson
78b5d89ddf Add support for printing out and retrieving EC point formats extension.
(backport from HEAD)
2012-12-26 18:13:49 +00:00
Dr. Stephen Henson
b79df62eff return error if Suite B mode is selected and TLS 1.2 can't be used.
(backport from HEAD)
2012-12-26 17:39:02 +00:00
Dr. Stephen Henson
e3c76874ad set auto ecdh parameter selction for Suite B
(backport from HEAD)
2012-12-26 17:35:02 +00:00
Dr. Stephen Henson
4347394a27 add Suite B 128 bit mode offering only combination 2
(backport from HEAD)
2012-12-26 17:34:50 +00:00
Dr. Stephen Henson
53bb723834 Use client version when deciding which cipher suites to disable.
(backport from HEAD)
2012-12-26 17:09:39 +00:00
Dr. Stephen Henson
684a2264c5 Use default point formats extension for server side as well as client
side, if possible.

Don't advertise compressed char2 for SuiteB as it is not supported.
(backport from HEAD)
2012-12-26 17:09:14 +00:00
Dr. Stephen Henson
fde8dc1798 add Suite B verification flags 2012-12-26 16:57:39 +00:00
Dr. Stephen Henson
3c87a2bdfa contify
(backport from HEAD)
2012-12-26 16:49:59 +00:00
Dr. Stephen Henson
1520e6c084 Add ctrl and utility functions to retrieve raw cipher list sent by client in
client hello message. Previously this could only be retrieved on an initial
connection and it was impossible to determine the cipher IDs of any uknown
ciphersuites.
(backport from HEAD)
2012-12-26 16:25:06 +00:00
Dr. Stephen Henson
2001129f09 new ctrl to retrive value of received temporary key in server key exchange message, print out details in s_client
(backport from HEAD)
2012-12-26 16:23:36 +00:00
Dr. Stephen Henson
a50ecaee56 store and print out message digest peer signed with in TLS 1.2
(backport from HEAD)
2012-12-26 16:23:13 +00:00
Dr. Stephen Henson
67d9dcf003 perform sanity checks on server certificate type as soon as it is received instead of waiting until server key exchange
(backport from HEAD)
2012-12-26 16:22:19 +00:00
Dr. Stephen Henson
79dcae32ef give more meaningful error if presented with wrong certificate type by server
(backport from HEAD)
2012-12-26 16:18:15 +00:00
Dr. Stephen Henson
ccf6a19e2d Add three Suite B modes to TLS code, supporting RFC6460.
(backport from HEAD)
2012-12-26 16:17:40 +00:00
Dr. Stephen Henson
28fbbe3b1b Add missing prototype to x509.h 2012-12-26 16:11:10 +00:00
Dr. Stephen Henson
8d2dbe6ac0 New function X509_chain_up_ref to dup and up the reference count of
a STACK_OF(X509): replace equivalent functionality in several places
by the equivalent call.
(backport from HEAD)
2012-12-26 16:04:03 +00:00
Dr. Stephen Henson
ba8bdea771 add suite B chain validation flags and associated verify errors
(backport from HEAD)
2012-12-26 16:01:31 +00:00
Dr. Stephen Henson
3d9916298a Oops, add missing v3nametest.c 2012-12-26 15:59:57 +00:00
Dr. Stephen Henson
87054c4f0e New -valid option to add a certificate to the ca index.txt that is valid and not revoked
(backport from HEAD)
2012-12-26 15:32:13 +00:00
Dr. Stephen Henson
6660baee66 Make tls1_check_chain return a set of flags indicating checks passed
by a certificate chain. Add additional tests to handle client
certificates: checks for matching certificate type and issuer name
comparison.

Print out results of checks for each candidate chain tested in
s_server/s_client.
(backport from HEAD)
2012-12-26 15:27:44 +00:00
Dr. Stephen Henson
25d4c9254c Abort handshake if signature algorithm used not supported by peer.
(backport from HEAD)
2012-12-26 15:27:24 +00:00
Dr. Stephen Henson
44adfeb6c0 check EC tmp key matches preferences
(backport from HEAD)
2012-12-26 15:27:04 +00:00
Dr. Stephen Henson
5ff2ef79e6 typo 2012-12-26 15:23:16 +00:00
Dr. Stephen Henson
b762acadeb Add support for certificate stores in CERT structure. This makes it
possible to have different stores per SSL structure or one store in
the parent SSL_CTX. Include distint stores for certificate chain
verification and chain building. New ctrl SSL_CTRL_BUILD_CERT_CHAIN
to build and store a certificate chain in CERT structure: returing
an error if the chain cannot be built: this will allow applications
to test if a chain is correctly configured.

Note: if the CERT based stores are not set then the parent SSL_CTX
store is used to retain compatibility with existing behaviour.
(backport from HEAD)
2012-12-26 15:21:53 +00:00
Dr. Stephen Henson
7d779eefb4 add ssl_locl.h to err header files, rebuild ssl error strings
(backport from HEAD)
2012-12-26 15:09:16 +00:00
Dr. Stephen Henson
35b7757f9b set ciphers to NULL before calling cert_cb
(backport from HEAD)
2012-12-26 14:56:40 +00:00
Dr. Stephen Henson
23195e4dcc stop warning
(backport from HEAD)
2012-12-26 14:56:27 +00:00
Dr. Stephen Henson
b28fbdfa7d New function ssl_set_client_disabled to set masks for any ciphersuites
that are disabled for this session (as opposed to always disabled by
configuration).
(backport from HEAD)
2012-12-26 14:55:46 +00:00
Dr. Stephen Henson
a897502cd9 Add new ctrl to retrieve client certificate types, print out
details in s_client.

Also add ctrl to set client certificate types. If not used sensible values
will be included based on supported signature algorithms: for example if
we don't include any DSA signing algorithms the DSA certificate type is
omitted.

Fix restriction in old code where certificate types would be truncated
if it exceeded TLS_CT_NUMBER.
(backport from HEAD)
2012-12-26 14:51:37 +00:00
Dr. Stephen Henson
8546add692 cert_flags is unsigned
(backport from HEAD)
2012-12-26 14:48:05 +00:00
Dr. Stephen Henson
aa5c5eb4c1 add support for client certificate callbak, fix memory leak
(backport from HEAD)
2012-12-26 14:47:31 +00:00
Dr. Stephen Henson
731abd3bd7 new function SSL_is_server to which returns 1 is the corresponding SSL context is for a server
(backport from HEAD)
2012-12-26 14:45:46 +00:00
Dr. Stephen Henson
7531dd18dc no need to check s->server as default_nid is never used for TLS 1.2 client authentication
(backport from HEAD)
2012-12-26 14:45:27 +00:00
Dr. Stephen Henson
04c32cddaa Separate client and server permitted signature algorithm support: by default
the permitted signature algorithms for server and client authentication
are the same but it is now possible to set different algorithms for client
authentication only.
(backport from HEAD)
2012-12-26 14:44:56 +00:00
Dr. Stephen Henson
623a5e24cb Add certificate callback. If set this is called whenever a certificate
is required by client or server. An application can decide which
certificate chain to present based on arbitrary criteria: for example
supported signature algorithms. Add very simple example to s_server.
This fixes many of the problems and restrictions of the existing client
certificate callback: for example you can now clear existing certificates
and specify the whole chain.
(backport from HEAD)
2012-12-26 14:43:51 +00:00
Dr. Stephen Henson
bd9fc1d667 New functions to retrieve certificate signatures and signature OID NID.
(backport from HEAD)
2012-12-26 14:31:05 +00:00
Dr. Stephen Henson
c550f2e37b Function tls1_check_ec_server_key is now redundant as we make
appropriate checks in tls1_check_chain.
(backport from HEAD)
2012-12-26 14:27:27 +00:00
Dr. Stephen Henson
484f876235 Add new "valid_flags" field to CERT_PKEY structure which determines what
the certificate can be used for (if anything). Set valid_flags field
in new tls1_check_chain function. Simplify ssl_set_cert_masks which used
to have similar checks in it.

Add new "cert_flags" field to CERT structure and include a "strict mode".
This enforces some TLS certificate requirements (such as only permitting
certificate signature algorithms contained in the supported algorithms
extension) which some implementations ignore: this option should be used
with caution as it could cause interoperability issues.
(backport from HEAD)
2012-12-26 14:26:53 +00:00
Dr. Stephen Henson
c70a1fee71 Reorganise supported signature algorithm extension processing.
Only store encoded versions of peer and configured signature algorithms.
Determine shared signature algorithms and cache the result along with NID
equivalents of each algorithm.
(backport from HEAD)
2012-12-26 14:26:16 +00:00
Dr. Stephen Henson
0b362de5f5 Add support for application defined signature algorithms for use with
TLS v1.2. These are sent as an extension for clients and during a certificate
request for servers.

TODO: add support for shared signature algorithms, respect shared algorithms
when deciding which ciphersuites and certificates to permit.
(backport from HEAD)
2012-12-26 14:25:29 +00:00
Dr. Stephen Henson
d312f7be37 Make it possible to delete all certificates from an SSL structure.
(backport from HEAD)
2012-12-26 14:18:50 +00:00
Dr. Stephen Henson
2b5e5c3d08 Revert incompatible OCSP_basic_verify changes.
Make partial chain chekcing work with EE certificates only.
Remove unneeded -trust_other option from tocsp.
(Backport from HEAD)
2012-12-26 14:12:09 +00:00
Dr. Stephen Henson
708454f010 add missing \n 2012-12-23 18:12:28 +00:00
Dr. Stephen Henson
f1aec4dec3 fix typo 2012-12-21 18:33:53 +00:00
Dr. Stephen Henson
1c53a72f17 update/fix tocsp script (from HEAD) 2012-12-20 19:15:35 +00:00
Dr. Stephen Henson
9b157602e0 Backport enhancements to OCSP utility from HEAD:
Support - as a file for standard input or output.

Add -badsig option to generate invalid signatures for testing.

New -rmd option to specify digest to sign OCSP responses with.
2012-12-20 19:06:39 +00:00
Dr. Stephen Henson
67e217c84c revert, missing commit message 2012-12-20 19:01:55 +00:00
Dr. Stephen Henson
e6b650df0a oops, revert 2012-12-20 19:01:34 +00:00
Dr. Stephen Henson
7b7b667ddc apps/ocsp.c 2012-12-20 18:59:09 +00:00
Dr. Stephen Henson
70cd3c6b95 Integrate host, email and IP address checks into X509_verify.
Add new verify options to set checks.

(backport from HEAD)
2012-12-19 15:14:10 +00:00
Dr. Stephen Henson
db05bc512d Return success when the responder is active.
Don't verify our own responses.
(backport from HEAD)
2012-12-19 15:02:58 +00:00
Dr. Stephen Henson
45da1efcdb Backport X509 hostname, IP address and email checking code from HEAD. 2012-12-19 15:01:59 +00:00
Dr. Stephen Henson
54a0076e94 Check chain is not NULL before assuming we have a validated chain. The
modification to the OCSP helper purpose breaks normal OCSP verification. It is
no longer needed now we can trust partial chains.
2012-12-19 15:01:32 +00:00
Andy Polyakov
f8cab37bc1 VC-32.pl: fix typo [from HEAD].
Submitted by: Pierre Delaage
2012-12-16 19:40:51 +00:00
Dr. Stephen Henson
2e65277695 Use new partial chain flag instead of modifying input parameters.
(backport from HEAD)
2012-12-14 14:31:16 +00:00
Dr. Stephen Henson
9a1f59cd31 New verify flag to return success if we have any certificate in the trusted
store instead of the default which is to return an error if we can't build
the complete chain. [backport from HEAD]
2012-12-14 14:30:46 +00:00
Ben Laurie
4e72220fd6 Documentation improvements by Chris Palmer (Google). 2012-12-14 13:29:17 +00:00
Ben Laurie
d65b8b2162 Backport OCSP fixes. 2012-12-14 12:53:53 +00:00
Ben Laurie
5dca1e338c Document -pubkey option. 2012-12-13 16:16:48 +00:00
Ben Laurie
5f4cf08864 Make verify return errors. 2012-12-13 15:49:15 +00:00
Ben Laurie
2a2e537983 Ignore more. 2012-12-13 12:43:18 +00:00
Ben Laurie
d79fc8da02 Add my 64-bit debug target. 2012-12-12 13:45:32 +00:00
Dr. Stephen Henson
e04ccbc5cc Fix two bugs which affect delta CRL handling:
Use -1 to check all extensions in CRLs.
Always set flag for freshest CRL.
2012-12-06 18:24:47 +00:00
Andy Polyakov
bc946bfb97 aes-s390x.pl: fix XTS bugs in z196-specific code path [from HEAD]. 2012-12-05 17:45:09 +00:00
Dr. Stephen Henson
38680fa466 check mval for NULL too 2012-12-04 17:26:04 +00:00
Dr. Stephen Henson
a902b6bd98 fix leak 2012-12-03 16:33:15 +00:00
Andy Polyakov
c5e91a9ae9 aes-s390x.pl: harmonize software-only path [from HEAD]. 2012-12-01 11:09:13 +00:00
Dr. Stephen Henson
b5f57f455a PR: 2803
Submitted by: jean-etienne.schwartz@bull.net

In OCSP_basic_varify return an error if X509_STORE_CTX_init fails.
2012-11-29 19:15:27 +00:00
Andy Polyakov
ad00a52f2d Intel compiler support update from HEAD. 2012-11-28 13:12:09 +00:00
Dr. Stephen Henson
e08c7f15b4 change inaccurate error message 2012-11-26 15:47:44 +00:00
Dr. Stephen Henson
7469af4484 reject zero length point format list or supported curves extensions 2012-11-22 14:15:36 +00:00
Dr. Stephen Henson
ec76d850af PR: 2908
Submitted by: Dmitry Belyavsky <beldmit@gmail.com>

Fix DH double free if parameter generation fails.
2012-11-21 14:02:30 +00:00
Dr. Stephen Henson
cedf19f356 fix leaks 2012-11-20 00:28:22 +00:00
Dr. Stephen Henson
1d5f3f4640 correct docs 2012-11-19 20:06:57 +00:00
Andy Polyakov
a060fc3b8e x86_64-gcc.c: resore early clobber constraint [from HEAD].
Submitted by: Florian Weimer
2012-11-19 15:02:34 +00:00
Dr. Stephen Henson
bda5153703 PR: 2880
Submitted by: "Florian Rüchel" <florian.ruechel@ruhr-uni-bochum.de>

Correctly handle local machine keys in the capi ENGINE.
2012-11-18 15:21:12 +00:00
Dr. Stephen Henson
6f539399ef add "missing" TLSv1.2 cipher alias 2012-11-15 19:15:07 +00:00
Andy Polyakov
d90bf2ab21 [vp]aes-x86[_64].pl: update from HEAD. 2012-11-12 18:11:17 +00:00
Andy Polyakov
02620cfcd5 Cumulative updates from HEAD. 2012-10-29 22:29:29 +00:00
Dr. Stephen Henson
74daafaa94 use correct year automatically 2012-10-22 13:03:31 +00:00
Andy Polyakov
aa963813ed linux-ppc: make it more robust [from HEAD]. 2012-10-21 18:25:29 +00:00
Dr. Stephen Henson
9a6aff50ff Don't require tag before ciphertext in AESGCM mode 2012-10-16 22:46:32 +00:00
Andy Polyakov
c7d16ac8da aix[64]-cc: get MT support right [from HEAD].
PR: 2896
2012-10-16 08:09:20 +00:00
Bodo Möller
b626f0396c Fix EC_KEY initialization race.
Submitted by: Adam Langley
2012-10-05 20:50:38 +00:00
Dr. Stephen Henson
9d2006d8ed add -trusted_first option and verify flag (backport from HEAD) 2012-09-26 13:50:42 +00:00
Bodo Möller
abf1e32f2f Fix Valgrind warning.
Submitted by: Adam Langley
2012-09-24 19:49:25 +00:00
Richard Levitte
fc1e09bf81 * Configure: make the debug-levitte-linux{elf,noasm} less extreme. 2012-09-24 18:49:07 +00:00
Richard Levitte
451cec33df * ssl/t1_enc.c (tls1_change_cipher_state): Stupid bug. Fortunately in
debugging code that's seldom used.
2012-09-21 13:08:30 +00:00
Andy Polyakov
16c92916c7 Configure: allow for compiler options starting with double dash [from HEAD]. 2012-09-19 21:00:35 +00:00
Andy Polyakov
988037fe18 MIPS assembly pack: jumbo update from HEAD. 2012-09-19 20:59:18 +00:00
Bodo Möller
9a7f80c869 Fix warning.
Submitted by: Chromium Authors
2012-09-17 17:23:43 +00:00
Andy Polyakov
507e5c3a61 e_aes.c: uninitialized variable in aes_ccm_init_key [from HEAD].
PR: 2874
Submitted by: Tomas Mraz
2012-09-15 08:46:08 +00:00
Dr. Stephen Henson
f8b90b5a5d fix memory leak 2012-09-11 13:44:19 +00:00
Dr. Stephen Henson
dc14441757 Minor enhancement to PR#2836 fix. Instead of modifying SSL_get_certificate
change the current certificate (in s->cert->key) to the one used and then
SSL_get_certificate and SSL_get_privatekey will automatically work.
2012-09-11 13:35:14 +00:00
Ben Laurie
da8512aaff Call OCSP Stapling callback after ciphersuite has been chosen, so the
right response is stapled. Also change SSL_get_certificate() so it
returns the certificate actually sent.  See
http://rt.openssl.org/Ticket/Display.html?id=2836.
2012-09-11 12:00:25 +00:00
Andy Polyakov
d46a1a6178 bn_lcl.h: gcc removed support for "h" constraint, which broke inline
assembler [from HEAD].
2012-09-01 13:21:24 +00:00
Dr. Stephen Henson
957c7c0e88 Don't load GOST ENGINE if it is already loaded.
Multiple copies of the ENGINE will cause problems when it is cleaned up as
the methods are stored in static structures which will be overwritten and
freed up more than once.

Set static methods to NULL when the ENGINE is freed so it can be reloaded.
2012-09-01 11:30:35 +00:00
Andy Polyakov
3ebe87473c x86cpuid.pl: hide symbols [backport from x86_64, from HEAD]. 2012-08-29 14:24:18 +00:00
Andy Polyakov
0e05b51fe5 Add linux-x32 target [from HEAD]. 2012-08-29 14:12:10 +00:00
Dr. Stephen Henson
c759e453bc PR: 2786
Reported by: Tomas Mraz <tmraz@redhat.com>

Treat a NULL value passed to drbg_free_entropy callback as non-op. This
can happen if the call to fips_get_entropy fails.
2012-08-22 22:43:03 +00:00
Andy Polyakov
40ce8fca73 sha1-armv4-large.pl: comply with ABI [from HEAD]. 2012-08-17 19:58:34 +00:00
Andy Polyakov
8e1c33e160 MIPS assembly pack updates from HEAD. 2012-08-17 09:41:30 +00:00
Andy Polyakov
13b0cae256 aes-mips.pl: harmonize with fips module.
PR: 2863
Submitted by: Duane Sand
2012-08-17 09:03:57 +00:00
Bodo Möller
6d78a93b5b Enable message names for TLS 1.1, 1.2 with -msg. 2012-08-16 13:42:37 +00:00
Andy Polyakov
ae92994645 bss_dgram.c: fix compilation failure and warning on Windows with
contemporary SDK [from HEAD].
2012-08-14 09:53:41 +00:00
Andy Polyakov
c4aa6b041b gosthash.c: use memmove in circle_xor8, as input pointers can be equal
[from HEAD].

PR: 2858
2012-08-13 16:37:58 +00:00
Andy Polyakov
80158304f0 ./Configure: libcrypto.a can grow to many GB on Solaris 10, because of ar bug
[from HEAD].

PR: 2838
2012-08-13 16:16:24 +00:00
Andy Polyakov
f0a069c1a2 gcm128.c: fix AAD-only case with AAD length not divisible by 16 [from HEAD].
PR: 2859
Submitted by: John Foley
2012-08-13 15:31:10 +00:00
Dr. Stephen Henson
5b4b9ce976 Don't ignore (!) reference count in X509_STORE_free. 2012-07-19 12:48:02 +00:00
Dr. Stephen Henson
7fbcc2f24a type 2012-07-13 11:17:56 +00:00
Richard Levitte
e4be79a383 Add the missing dh_rfc5114 and evp_cnf. 2012-07-05 13:00:45 +00:00
Richard Levitte
658604473f Added aliases for symbols longer than 31 chars. 2012-07-05 09:08:18 +00:00
Richard Levitte
86bea6455c remove duplicate symbol in crypto/symhacks.h
Have the new names start in column 48, that makes it easy to see when
the 31 character limit is reached (on a 80 column display, do the math)
2012-07-05 08:53:43 +00:00
Dr. Stephen Henson
1e4a6e7b7f add missing evp_cnf.c file 2012-07-04 13:14:44 +00:00
Andy Polyakov
fd6a72fa1c crypto/bn/*.h: move PTR_SIZE_INT to private header [from HEAD]. 2012-07-04 08:51:44 +00:00
Dr. Stephen Henson
ccffdb3fdc revert unrelated test code 2012-07-03 20:21:35 +00:00
Dr. Stephen Henson
74d89b0d93 PR: 2840
Reported by: David McCullough <david_mccullough@mcafee.com>

Restore fips configuration module from 0.9.8.
2012-07-03 20:20:11 +00:00
Dr. Stephen Henson
f142a71c3d Fix memory leak.
Always perform nexproto callback argument initialisation in s_server
otherwise we use uninitialised data if -nocert is specified.
2012-07-03 16:37:31 +00:00
Andy Polyakov
5b7af6de43 bn_nist.c: harmonize buf in BN_nist_mod_256 with other mod functions and
compensate for VC buf [from HEAD].

PR: 2837
2012-07-02 14:38:22 +00:00
Andy Polyakov
ae414a0e42 bss_dgram.c: fix typos in Windows code [from HEAD]. 2012-07-01 09:12:03 +00:00
Dr. Stephen Henson
a240ea8ab8 don't use pseudo digests for default values of keys 2012-06-27 14:12:01 +00:00
Andy Polyakov
8b654459be x86_64 assembly pack: make it possible to compile with Perl located
on path with spaces [from HEAD].

PR: 2835
2012-06-27 12:48:50 +00:00
Dr. Stephen Henson
93cf058334 oops, add -debug_decrypt option which was accidenatally left out 2012-06-19 13:39:17 +00:00
Andy Polyakov
3e8b4b5055 bss_dgram.c: add BIO_CTRL_DGRAM_SET_DONT_FRAG, fix bugs [from HEAD].
PR: 2830, 2833
2012-06-19 12:28:47 +00:00
Ben Laurie
3c56d65a41 Fix memory leak. 2012-06-11 09:23:38 +00:00
Dr. Stephen Henson
e51ec51af9 revert more "version skew" changes that break FIPS builds 2012-06-10 23:02:06 +00:00
Dr. Stephen Henson
ff1c55e983 Revert "version skew" patches that break FIPS compilation 2012-06-09 23:36:38 +00:00
Ben Laurie
835d104f46 Rearrange and test authz extension. 2012-06-07 13:20:20 +00:00
Ben Laurie
aeba1ef352 Fix memory leak. 2012-06-06 12:58:35 +00:00
Ben Laurie
49e9f751a4 Fix authz parsing. 2012-06-06 12:45:14 +00:00
Ben Laurie
ff46820da6 Version skew reduction. 2012-06-06 12:41:46 +00:00
Andy Polyakov
6fba65e20d x86gas.pl: update from HEAD. 2012-06-04 22:14:25 +00:00
Ben Laurie
68d2cf51bc Reduce version skew: trivia (I hope). 2012-06-03 22:03:37 +00:00
Ben Laurie
19eedffcaf Don't insert in the middle. 2012-05-29 18:58:43 +00:00
Ben Laurie
4e14996e8a Missing from previous commit. 2012-05-29 18:39:32 +00:00
Ben Laurie
8a02a46a5c RFC 5878 support. 2012-05-29 17:27:48 +00:00
Ben Laurie
0de5a0feee Work around macro issue with FreeBSD and gcc 4.6. 2012-05-18 12:40:28 +00:00
Andy Polyakov
4d321e0767 s2_clnt.c: compensate for compiler bug [from HEAD]. 2012-05-16 18:22:15 +00:00
Andy Polyakov
67fda0c12e ppccap.c: assume no features under 32-bit AIX kernel [from HEAD].
PR: 2810
2012-05-16 18:18:14 +00:00
Dr. Stephen Henson
1dded7f7e8 Experimental multi-implementation support for FIPS capable OpenSSL.
When in FIPS mode the approved implementations are used as normal,
when not in FIPS mode the internal unapproved versions are used instead.
This means that the FIPS capable OpenSSL isn't forced to use the
(often lower perfomance) FIPS implementations outside FIPS mode.
2012-05-13 18:40:12 +00:00
Dr. Stephen Henson
482f238069 PR: 2813
Reported by: Constantine Sapuntzakis <csapuntz@gmail.com>

Fix possible deadlock when decoding public keys.
2012-05-11 13:53:23 +00:00
Dr. Stephen Henson
5e145e54cc PR: 2811
Reported by: Phil Pennock <openssl-dev@spodhuis.org>

Make renegotiation work for TLS 1.2, 1.1 by not using a lower record
version client hello workaround if renegotiating.
2012-05-11 13:33:34 +00:00
Dr. Stephen Henson
df73e68a43 PR: 2806
Submitted by: PK <runningdoglackey@yahoo.com>

Correct ciphersuite signature algorithm definitions.
2012-05-10 18:25:31 +00:00
Dr. Stephen Henson
e7c8483891 Sanity check record length before skipping explicit IV in TLS 1.2, 1.1 and
DTLS to fix DoS attack.

Thanks to Codenomicon for discovering this issue using Fuzz-o-Matic
fuzzing as a service testing platform.
(CVE-2012-2333)
2012-05-10 16:03:36 +00:00
Richard Levitte
712d523484 Don't forget to install srtp.h as well 2012-05-10 15:01:26 +00:00
Dr. Stephen Henson
24547c23ca Reported by: Solar Designer of Openwall
Make sure tkeylen is initialised properly when encrypting CMS messages.
2012-05-10 13:44:24 +00:00
Richard Levitte
8baf604a39 Correct environment variable is OPENSSL_ALLOW_PROXY_CERTS. 2012-05-04 10:43:24 +00:00
Andy Polyakov
95416ce5b3 ppccpuid.pl: branch hints in OPENSSL_cleanse impact small block performance
of digest algorithms, mosty SHA, on Power7. Mystery of century, why SHA,
why slower algorithm are affected more... [from HEAD].
PR: 2794
Submitted by: Ashley Lai
2012-04-27 20:19:23 +00:00
Dr. Stephen Henson
a56f9a612b Don't try to use unvalidated composite ciphers in FIPS mode 2012-04-26 18:51:26 +00:00
Andy Polyakov
0ae89cf32e CHANGES: clarify. 2012-04-26 07:34:09 +00:00
Andy Polyakov
7e0c9630a3 CHANGES: fix typos and clarify. 2012-04-26 07:24:28 +00:00
Dr. Stephen Henson
a6df6702c6 Change value of SSL_OP_NO_TLSv1_1 to avoid clash with SSL_OP_ALL and
OpenSSL 1.0.0. Add CHANGES entry noting the consequences.
2012-04-25 23:06:31 +00:00
Andy Polyakov
f69abd5321 s23_clnt.c: ensure interoperability by maitaining client "version capability"
vector contiguous [from HEAD].
PR: 2802
2012-04-25 22:07:03 +00:00
Dr. Stephen Henson
fe9ce2b7d6 Submitted by: Peter Sylvester <peter.sylvester@edelweb.fr>
Reviewed by: steve
Improved localisation of TLS extension handling and code tidy.
2012-04-24 12:15:17 +00:00
Andy Polyakov
8e7ccf6ff7 objxref.pl: improve portability [from HEAD]. 2012-04-22 21:19:41 +00:00
Dr. Stephen Henson
51b77c0337 correct error code 2012-04-22 13:31:19 +00:00
Dr. Stephen Henson
85d179d4eb check correctness of errors before updating them so we don't get bogus errors added 2012-04-22 13:25:41 +00:00
Dr. Stephen Henson
890f5ada82 correct old FAQ answers, sync with HEAD 2012-04-22 13:21:15 +00:00
Dr. Stephen Henson
1cc8410e36 PR: 2239
Submitted by: Dominik Oepen <oepen@informatik.hu-berlin.de>

Add Brainpool curves from RFC5639.

Original patch by Annie Yousar <a.yousar@informatik.hu-berlin.de>
2012-04-22 13:11:48 +00:00
Andy Polyakov
6ca7af9ec0 e_rc4_hmac_md5.c: reapply commit#21726, which was erroneously omitted [from 1.0.1].
PR: 2797, 2792
2012-04-20 21:45:21 +00:00
Dr. Stephen Henson
bc2c8efc80 call OPENSSL_init when calling FIPS_mode too 2012-04-20 14:43:14 +00:00
Dr. Stephen Henson
00bb875240 make ciphers work again for FIPS builds 2012-04-20 00:08:32 +00:00
Andy Polyakov
c3cb563d87 e_rc4_hmac_md5.c: last commit was inappropriate for non-x86[_64] platforms
[from HEAD].
PR: 2792
2012-04-19 20:42:24 +00:00
Dr. Stephen Henson
d6ef8165bb update date 2012-04-19 16:21:49 +00:00
Dr. Stephen Henson
564a503b1b 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)
2012-04-19 16:19:07 +00:00
Andy Polyakov
56eeb1b28c Makefile.org: clear yet another environment variable [from HEAD].
PR: 2793
2012-04-19 06:40:21 +00:00
Dr. Stephen Henson
068fc255ac only call FIPS_cipherinit in FIPS mode 2012-04-18 22:42:06 +00:00
Andy Polyakov
cc8f2fb917 e_rc4_hmac_md5.c: update from HEAD, fixes crash on legacy Intel CPUs.
PR: 2792
2012-04-18 17:51:26 +00:00
Dr. Stephen Henson
b583ebb7dd recognise X9.42 DH certificates on servers 2012-04-18 17:03:45 +00:00
Dr. Stephen Henson
f897fe4146 correct error code 2012-04-18 15:17:39 +00:00
Bodo Möller
bb3add20f3 Disable SHA-2 ciphersuites in < TLS 1.2 connections.
(TLS 1.2 clients could end up negotiating these with an OpenSSL server
with TLS 1.2 disabled, which is problematic.)

Submitted by: Adam Langley
2012-04-17 15:21:29 +00:00
Dr. Stephen Henson
48e0f6667b Additional workaround for PR#2771
If OPENSSL_MAX_TLS1_2_CIPHER_LENGTH is set then limit the size of client
ciphersuites to this value. A value of 50 should be sufficient.

Document workarounds in CHANGES.
2012-04-17 14:47:14 +00:00
Dr. Stephen Henson
32213fb25a Partial workaround for PR#2771.
Some servers hang when presented with a client hello record length exceeding
255 bytes but will work with longer client hellos if the TLS record version
in client hello does not exceed TLS v1.0. Unfortunately this doesn't fix all
cases...
2012-04-17 13:20:37 +00:00
Andy Polyakov
f6a1939f0f OPENSSL_NO_SOCK fixes [from HEAD].
PR: 2791
Submitted by: Ben Noordhuis
2012-04-16 17:43:02 +00:00
Andy Polyakov
94c666479d Minor compatibility fixes [from HEAD].
PR: 2790
Submitted by: Alexei Khlebnikov
2012-04-16 17:35:48 +00:00
Andy Polyakov
09f17419a6 s3_srvr.c: fix typo [from HEAD].
PR: 2538
2012-04-15 17:23:54 +00:00
Andy Polyakov
eb8a65db16 e_aes_cbc_hmac_sha1.c: handle zero-length payload and engage empty frag
countermeasure [from HEAD].

PR: 2778
2012-04-15 14:23:26 +00:00
Andy Polyakov
e6255a7d1e s390x asm pack: fix typos. 2012-04-12 06:46:49 +00:00
Dr. Stephen Henson
65a0f68484 Add options to set additional type specific certificate chains to
s_server.
2012-04-11 16:54:07 +00:00
Dr. Stephen Henson
e1a7db8fdd use different variable for chain iteration 2012-04-11 16:01:20 +00:00
Dr. Stephen Henson
65331f225a oops, macro not present in OpenSSL 1.0.2 2012-04-11 15:10:48 +00:00
Dr. Stephen Henson
64e8dc7981 fix reset fix 2012-04-11 15:05:33 +00:00
Dr. Stephen Henson
737fe7ea29 make reinitialisation work for CMAC 2012-04-11 12:26:27 +00:00
Dr. Stephen Henson
b344a826ad update rather ancient EVP digest documentation 2012-04-10 22:28:13 +00:00
Andy Polyakov
bc0f56d6d7 aes-s390x.pl: fix crash in AES_set_decrypt_key in linux32-s390x build [from HEAD]. 2012-04-09 15:12:30 +00:00
Dr. Stephen Henson
3a89e9f106 update year 2012-04-07 22:14:16 +00:00
Dr. Stephen Henson
79e75e04ea recognise DECLARE_PEM_write_const, update ordinals
(backport from HEAD)
2012-04-07 20:48:12 +00:00
Dr. Stephen Henson
c3cb069108 transparently handle X9.42 DH parameters
(backport from HEAD)
2012-04-07 20:42:44 +00:00
Dr. Stephen Henson
cdb41713a4 Document RFC5114 "generation" options.
(backport from HEAD)
2012-04-07 20:42:17 +00:00
Dr. Stephen Henson
491734eb21 Initial experimental support for X9.42 DH parameter format to handle
RFC5114 parameters and X9.42 DH public and private keys.
(backport from HEAD)
2012-04-07 20:22:11 +00:00
Dr. Stephen Henson
4e891a191d branches: 1.2.2;
Correct some parameter values.
(backport from HEAD)
2012-04-07 17:41:51 +00:00
Dr. Stephen Henson
b73a69a9c2 Update DH_check() to peform sensible checks when q parameter is present.
(backport from HEAD)
2012-04-07 17:40:08 +00:00
Dr. Stephen Henson
e811eff5a9 Add RFC5114 DH parameters to OpenSSL. Add test data to dhtest.
(backport from HEAD)
2012-04-07 12:19:50 +00:00
Dr. Stephen Henson
1d0c47fd55 Submitted by: Peter Sylvester <peter.sylvester@edelweb.fr>
Localize client hello extension parsing in t1_lib.c
(backport from HEAD)
2012-04-06 20:16:09 +00:00
Dr. Stephen Henson
e46c807e4f Add support for automatic ECDH temporary key parameter selection. When
enabled instead of requiring an application to hard code a (possibly
inappropriate) parameter set and delve into EC internals we just
automatically use the preferred curve.
(backport from HEAD)
2012-04-06 20:15:50 +00:00
Dr. Stephen Henson
c132ca95c0 Tidy up EC parameter check code: instead of accessing internal structures
add utility functions to t1_lib.c to check if EC certificates and parameters
are consistent with peer.
(backport from HEAD)
2012-04-06 20:14:53 +00:00
Dr. Stephen Henson
6b870763ac Initial revision of ECC extension handling.
Tidy some code up.

Don't allocate a structure to handle ECC extensions when it is used for
default values.

Make supported curves configurable.

Add ctrls to retrieve shared curves: not fully integrated with rest of
ECC code yet.
(backport from HEAD)
2012-04-06 20:12:35 +00:00
Dr. Stephen Henson
5505818199 New ctrls to retrieve supported signature algorithms and curves and
extensions to s_client and s_server to print out retrieved valued.

Extend CERT structure to cache supported signature algorithm data.
(backport from HEAD)
2012-04-06 19:29:49 +00:00
Dr. Stephen Henson
7493bcc659 initialise i if n == 0
(backport from HEAD)
2012-04-06 17:36:40 +00:00
Dr. Stephen Henson
a068a1d0e3 Add new APIs EC_curve_nist2nid and EC_curve_nid2nist which convert
between NIDs and the more common NIST names such as "P-256". Enhance
ecparam utility and ECC method to recognise the NIST names for curves.
(backport from HEAD)
2012-04-06 17:35:01 +00:00
Dr. Stephen Henson
37b16c84bb Add support for distinct certificate chains per key type and per SSL
structure.

Before this the only way to add a custom chain was in the parent SSL_CTX
(which is shared by all key types and SSL structures) or rely on auto
chain building (which is performed on each handshake) from the trust store.
(backport from HEAD)
2012-04-06 17:22:48 +00:00
Dr. Stephen Henson
0ac89e8f54 Backport: code tidy (from HEAD) 2012-04-06 12:02:43 +00:00
Dr. Stephen Henson
7e65b21a24 Backport: Revise ssl code to use CERT_PKEY structure when outputting a certificate chain (from HEAD) 2012-04-06 12:00:24 +00:00
Dr. Stephen Henson
736d69750d Backport: tidy/enhance certificate chain output code (from HEAD) 2012-04-06 11:58:17 +00:00
Dr. Stephen Henson
0cb9dbed4e Backport: allow key agreement in SSL/TLS certificates (from HEAD) 2012-04-06 11:36:35 +00:00
Dr. Stephen Henson
6cfccfec33 Backport: initialise dh_clnt (from HEAD) 2012-04-06 11:35:45 +00:00
Dr. Stephen Henson
c523eb98d1 Backport DH client certificate support (from HEAD) 2012-04-06 11:34:42 +00:00
Dr. Stephen Henson
0ffa49970b Backport support for fixed DH ciphersuites (from HEAD) 2012-04-06 11:33:12 +00:00
Andy Polyakov
8cd2ea552e aes-armv4.pl: make it more foolproof [inspired by aes-s390x.pl in 1.0.1]. 2012-04-05 08:32:08 +00:00
Andy Polyakov
3f0becbf75 aes-s390x.pl: fix endless loop in linux32-s390x build [from 1.0.1]. 2012-04-05 08:17:47 +00:00
Andy Polyakov
1b0ae81f4a ssl/ssl_ciph.c: interim solution for assertion in d1_pkt.c(444) [from HEAD].
PR: 2778
2012-04-04 20:50:58 +00:00
Andy Polyakov
54543b954c CHANGES: harmonize with 1.0.0 and 1.0.1. 2012-03-31 18:56:07 +00:00
Dr. Stephen Henson
5e2187f7ee PR: 2778(part)
Submitted by: John Fitzgibbon <john_fitzgibbon@yahoo.com>

Time is always encoded as 4 bytes, not sizeof(Time).
2012-03-31 18:02:53 +00:00
Andy Polyakov
7b087bf4a9 modes_lcl.h: make it work on i386 [from HEAD].
PR: 2780
2012-03-31 17:03:43 +00:00
Andy Polyakov
9df9c9d102 vpaes-x86[_64].pl: handle zero length in vpaes_cbc_encrypt [from HEAD].
PR: 2775
2012-03-31 16:55:34 +00:00
Andy Polyakov
7e8b5493a4 util/cygwin.sh update [from HEAD].
PR: 2761
Submitted by: Corinna Vinschen
2012-03-31 11:07:09 +00:00
Andy Polyakov
265863c6a4 bn/bn_gf2m.c: make new BN_GF2m_mod_inv work with BN_DEBUG_RAND [from HEAD]. 2012-03-30 17:41:00 +00:00
Andy Polyakov
2fee1e0666 ans1/tasn_prn.c: avoid bool in variable names [from HEAD].
PR: 2776
2012-03-29 19:11:59 +00:00
Andy Polyakov
b4ff166cbc perlasm/x86masm.pl: fix last fix [from HEAD]. 2012-03-29 19:11:08 +00:00
Dr. Stephen Henson
861a0722c2 fix leak 2012-03-22 16:28:21 +00:00
Dr. Stephen Henson
b1cef8d984 Submitted by: Markus Friedl <mfriedl@gmail.com>
Fix memory leaks in 'goto err' cases.
2012-03-22 15:43:28 +00:00
Dr. Stephen Henson
b911523977 set version to 1.0.2-dev 2012-03-22 15:29:21 +00:00
cvs2svn
247c3f6049 This commit was manufactured by cvs2svn to create branch
'OpenSSL_1_0_2-stable'.
2012-03-21 21:32:58 +00:00
Dr. Stephen Henson
bd5770c6b1 file evp_cnf.c was added on branch OpenSSL_1_0_2-stable on 2012-07-04 13:14:44 +0000 2007-04-08 17:50:58 +00:00
868 changed files with 105603 additions and 19001 deletions

84
.gitignore vendored Normal file
View File

@ -0,0 +1,84 @@
# Object files
*.o
# editor artefacts
*.swp
.#*
#*#
*~
# Top level excludes
/Makefile.bak
/Makefile
/MINFO
/*.a
/include
/*.pc
/rehash.time
/inc.*
/makefile.*
/out.*
/tmp.*
# Most *.c files under test/ are symlinks
/test/*.c
# Apart from these
!/test/asn1test.c
!/test/methtest.c
!/test/dummytest.c
!/test/igetest.c
!/test/r160test.c
!/test/fips_algvs.c
/test/*.ss
/test/*.srl
/test/.rnd
/test/test*.pem
/test/newkey.pem
# Certificate symbolic links
*.0
# Links under apps
/apps/CA.pl
/apps/md4.c
# Auto generated headers
/crypto/buildinf.h
/crypto/opensslconf.h
# Auto generated assembly language source files
*.s
!/crypto/bn/asm/pa-risc2.s
!/crypto/bn/asm/pa-risc2W.s
# Executables
/apps/openssl
/test/sha256t
/test/sha512t
/test/*test
/test/fips_aesavs
/test/fips_desmovs
/test/fips_dhvs
/test/fips_drbgvs
/test/fips_dssvs
/test/fips_ecdhvs
/test/fips_ecdsavs
/test/fips_rngvs
/test/fips_test_suite
*.so*
*.dylib*
*.dll*
# Exceptions
!/test/bctest
!/crypto/des/times/486-50.sol
# Misc auto generated files
/tools/c_rehash
/test/evptests.txt
lib
Makefile.save
*.bak
tags
TAGS

View File

@ -10,13 +10,18 @@ OpenSSL project.
We would like to identify and thank the following such sponsors for their past We would like to identify and thank the following such sponsors for their past
or current significant support of the OpenSSL project: or current significant support of the OpenSSL project:
Major support:
Qualys http://www.qualys.com/
Very significant support: Very significant support:
OpenGear: www.opengear.com OpenGear: http://www.opengear.com/
Significant support: Significant support:
PSW Group: www.psw.net PSW Group: http://www.psw.net/
Acano Ltd. http://acano.com/
Please note that we ask permission to identify sponsors and that some sponsors Please note that we ask permission to identify sponsors and that some sponsors
we consider eligible for inclusion here have requested to remain anonymous. we consider eligible for inclusion here have requested to remain anonymous.

767
CHANGES
View File

@ -2,6 +2,623 @@
OpenSSL CHANGES OpenSSL CHANGES
_______________ _______________
Changes between 1.0.1i and 1.0.2 [xx XXX xxxx]
*) Accelerated NIST P-256 elliptic curve implementation for x86_64
(other platforms pending).
[Shay Gueron (Intel Corp), Andy Polyakov]
*) Add support for the SignedCertificateTimestampList certificate and
OCSP response extensions from RFC6962.
[Rob Stradling]
*) Fix ec_GFp_simple_points_make_affine (thus, EC_POINTs_mul etc.)
for corner cases. (Certain input points at infinity could lead to
bogus results, with non-infinity inputs mapped to infinity too.)
[Bodo Moeller]
*) Initial support for PowerISA 2.0.7, first implemented in POWER8.
This covers AES, SHA256/512 and GHASH. "Initial" means that most
common cases are optimized and there still is room for further
improvements. Vector Permutation AES for Altivec is also added.
[Andy Polyakov]
*) Add support for little-endian ppc64 Linux target.
[Marcelo Cerri (IBM)]
*) Initial support for AMRv8 ISA crypto extensions. This covers AES,
SHA1, SHA256 and GHASH. "Initial" means that most common cases
are optimized and there still is room for further improvements.
Both 32- and 64-bit modes are supported.
[Andy Polyakov, Ard Biesheuvel (Linaro)]
*) Improved ARMv7 NEON support.
[Andy Polyakov]
*) Support for SPARC Architecture 2011 crypto extensions, first
implemented in SPARC T4. This covers AES, DES, Camellia, SHA1,
SHA256/512, MD5, GHASH and modular exponentiation.
[Andy Polyakov, David Miller]
*) Accelerated modular exponentiation for Intel processors, a.k.a.
RSAZ.
[Shay Gueron (Intel Corp)]
*) Support for new and upcoming Intel processors, including AVX2,
BMI and SHA ISA extensions. This includes additional "stitched"
implementations, AESNI-SHA256 and GCM, and multi-buffer support
for TLS encrypt.
This work was sponsored by Intel Corp.
[Andy Polyakov]
*) Use algorithm specific chains in SSL_CTX_use_certificate_chain_file():
this fixes a limiation in previous versions of OpenSSL.
[Steve Henson]
*) Extended RSA OAEP support via EVP_PKEY API. Options to specify digest,
MGF1 digest and OAEP label.
[Steve Henson]
*) Add EVP support for key wrapping algorithms, to avoid problems with
existing code the flag EVP_CIPHER_CTX_WRAP_ALLOW has to be set in
the EVP_CIPHER_CTX or an error is returned. Add AES and DES3 wrap
algorithms and include tests cases.
[Steve Henson]
*) Add functions to allocate and set the fields of an ECDSA_METHOD
structure.
[Douglas E. Engert, Steve Henson]
*) New functions OPENSSL_gmtime_diff and ASN1_TIME_diff to find the
difference in days and seconds between two tm or ASN1_TIME structures.
[Steve Henson]
*) Add -rev test option to s_server to just reverse order of characters
received by client and send back to server. Also prints an abbreviated
summary of the connection parameters.
[Steve Henson]
*) New option -brief for s_client and s_server to print out a brief summary
of connection parameters.
[Steve Henson]
*) Add callbacks for arbitrary TLS extensions.
[Trevor Perrin <trevp@trevp.net> and Ben Laurie]
*) New option -crl_download in several openssl utilities to download CRLs
from CRLDP extension in certificates.
[Steve Henson]
*) New options -CRL and -CRLform for s_client and s_server for CRLs.
[Steve Henson]
*) New function X509_CRL_diff to generate a delta CRL from the difference
of two full CRLs. Add support to "crl" utility.
[Steve Henson]
*) New functions to set lookup_crls function and to retrieve
X509_STORE from X509_STORE_CTX.
[Steve Henson]
*) Print out deprecated issuer and subject unique ID fields in
certificates.
[Steve Henson]
*) Extend OCSP I/O functions so they can be used for simple general purpose
HTTP as well as OCSP. New wrapper function which can be used to download
CRLs using the OCSP API.
[Steve Henson]
*) Delegate command line handling in s_client/s_server to SSL_CONF APIs.
[Steve Henson]
*) SSL_CONF* functions. These provide a common framework for application
configuration using configuration files or command lines.
[Steve Henson]
*) SSL/TLS tracing code. This parses out SSL/TLS records using the
message callback and prints the results. Needs compile time option
"enable-ssl-trace". New options to s_client and s_server to enable
tracing.
[Steve Henson]
*) New ctrl and macro to retrieve supported points extensions.
Print out extension in s_server and s_client.
[Steve Henson]
*) New functions to retrieve certificate signature and signature
OID NID.
[Steve Henson]
*) Add functions to retrieve and manipulate the raw cipherlist sent by a
client to OpenSSL.
[Steve Henson]
*) New Suite B modes for TLS code. These use and enforce the requirements
of RFC6460: restrict ciphersuites, only permit Suite B algorithms and
only use Suite B curves. The Suite B modes can be set by using the
strings "SUITEB128", "SUITEB192" or "SUITEB128ONLY" for the cipherstring.
[Steve Henson]
*) New chain verification flags for Suite B levels of security. Check
algorithms are acceptable when flags are set in X509_verify_cert.
[Steve Henson]
*) Make tls1_check_chain return a set of flags indicating checks passed
by a certificate chain. Add additional tests to handle client
certificates: checks for matching certificate type and issuer name
comparison.
[Steve Henson]
*) If an attempt is made to use a signature algorithm not in the peer
preference list abort the handshake. If client has no suitable
signature algorithms in response to a certificate request do not
use the certificate.
[Steve Henson]
*) If server EC tmp key is not in client preference list abort handshake.
[Steve Henson]
*) Add support for certificate stores in CERT structure. This makes it
possible to have different stores per SSL structure or one store in
the parent SSL_CTX. Include distint stores for certificate chain
verification and chain building. New ctrl SSL_CTRL_BUILD_CERT_CHAIN
to build and store a certificate chain in CERT structure: returing
an error if the chain cannot be built: this will allow applications
to test if a chain is correctly configured.
Note: if the CERT based stores are not set then the parent SSL_CTX
store is used to retain compatibility with existing behaviour.
[Steve Henson]
*) New function ssl_set_client_disabled to set a ciphersuite disabled
mask based on the current session, check mask when sending client
hello and checking the requested ciphersuite.
[Steve Henson]
*) New ctrls to retrieve and set certificate types in a certificate
request message. Print out received values in s_client. If certificate
types is not set with custom values set sensible values based on
supported signature algorithms.
[Steve Henson]
*) Support for distinct client and server supported signature algorithms.
[Steve Henson]
*) Add certificate callback. If set this is called whenever a certificate
is required by client or server. An application can decide which
certificate chain to present based on arbitrary criteria: for example
supported signature algorithms. Add very simple example to s_server.
This fixes many of the problems and restrictions of the existing client
certificate callback: for example you can now clear an existing
certificate and specify the whole chain.
[Steve Henson]
*) Add new "valid_flags" field to CERT_PKEY structure which determines what
the certificate can be used for (if anything). Set valid_flags field
in new tls1_check_chain function. Simplify ssl_set_cert_masks which used
to have similar checks in it.
Add new "cert_flags" field to CERT structure and include a "strict mode".
This enforces some TLS certificate requirements (such as only permitting
certificate signature algorithms contained in the supported algorithms
extension) which some implementations ignore: this option should be used
with caution as it could cause interoperability issues.
[Steve Henson]
*) Update and tidy signature algorithm extension processing. Work out
shared signature algorithms based on preferences and peer algorithms
and print them out in s_client and s_server. Abort handshake if no
shared signature algorithms.
[Steve Henson]
*) Add new functions to allow customised supported signature algorithms
for SSL and SSL_CTX structures. Add options to s_client and s_server
to support them.
[Steve Henson]
*) New function SSL_certs_clear() to delete all references to certificates
from an SSL structure. Before this once a certificate had been added
it couldn't be removed.
[Steve Henson]
*) Integrate hostname, email address and IP address checking with certificate
verification. New verify options supporting checking in opensl utility.
[Steve Henson]
*) Fixes and wildcard matching support to hostname and email checking
functions. Add manual page.
[Florian Weimer (Red Hat Product Security Team)]
*) New functions to check a hostname email or IP address against a
certificate. Add options x509 utility to print results of checks against
a certificate.
[Steve Henson]
*) Fix OCSP checking.
[Rob Stradling <rob.stradling@comodo.com> and Ben Laurie]
*) Initial experimental support for explicitly trusted non-root CAs.
OpenSSL still tries to build a complete chain to a root but if an
intermediate CA has a trust setting included that is used. The first
setting is used: whether to trust (e.g., -addtrust option to the x509
utility) or reject.
[Steve Henson]
*) Add -trusted_first option which attempts to find certificates in the
trusted store even if an untrusted chain is also supplied.
[Steve Henson]
*) MIPS assembly pack updates: support for MIPS32r2 and SmartMIPS ASE,
platform support for Linux and Android.
[Andy Polyakov]
*) Support for linux-x32, ILP32 environment in x86_64 framework.
[Andy Polyakov]
*) Experimental multi-implementation support for FIPS capable OpenSSL.
When in FIPS mode the approved implementations are used as normal,
when not in FIPS mode the internal unapproved versions are used instead.
This means that the FIPS capable OpenSSL isn't forced to use the
(often lower perfomance) FIPS implementations outside FIPS mode.
[Steve Henson]
*) Transparently support X9.42 DH parameters when calling
PEM_read_bio_DHparameters. This means existing applications can handle
the new parameter format automatically.
[Steve Henson]
*) Initial experimental support for X9.42 DH parameter format: mainly
to support use of 'q' parameter for RFC5114 parameters.
[Steve Henson]
*) Add DH parameters from RFC5114 including test data to dhtest.
[Steve Henson]
*) Support for automatic EC temporary key parameter selection. If enabled
the most preferred EC parameters are automatically used instead of
hardcoded fixed parameters. Now a server just has to call:
SSL_CTX_set_ecdh_auto(ctx, 1) and the server will automatically
support ECDH and use the most appropriate parameters.
[Steve Henson]
*) Enhance and tidy EC curve and point format TLS extension code. Use
static structures instead of allocation if default values are used.
New ctrls to set curves we wish to support and to retrieve shared curves.
Print out shared curves in s_server. New options to s_server and s_client
to set list of supported curves.
[Steve Henson]
*) New ctrls to retrieve supported signature algorithms and
supported curve values as an array of NIDs. Extend openssl utility
to print out received values.
[Steve Henson]
*) Add new APIs EC_curve_nist2nid and EC_curve_nid2nist which convert
between NIDs and the more common NIST names such as "P-256". Enhance
ecparam utility and ECC method to recognise the NIST names for curves.
[Steve Henson]
*) Enhance SSL/TLS certificate chain handling to support different
chains for each certificate instead of one chain in the parent SSL_CTX.
[Steve Henson]
*) Support for fixed DH ciphersuite client authentication: where both
server and client use DH certificates with common parameters.
[Steve Henson]
*) Support for fixed DH ciphersuites: those requiring DH server
certificates.
[Steve Henson]
*) New function i2d_re_X509_tbs for re-encoding the TBS portion of
the certificate.
Note: Related 1.0.2-beta specific macros X509_get_cert_info,
X509_CINF_set_modified, X509_CINF_get_issuer, X509_CINF_get_extensions and
X509_CINF_get_signature were reverted post internal team review.
Changes between 1.0.1h and 1.0.1i [6 Aug 2014]
*) Fix SRP buffer overrun vulnerability. Invalid parameters passed to the
SRP code can be overrun an internal buffer. Add sanity check that
g, A, B < N to SRP code.
Thanks to Sean Devlin and Watson Ladd of Cryptography Services, NCC
Group for discovering this issue.
(CVE-2014-3512)
[Steve Henson]
*) A flaw in the OpenSSL SSL/TLS server code causes the server to negotiate
TLS 1.0 instead of higher protocol versions when the ClientHello message
is badly fragmented. This allows a man-in-the-middle attacker to force a
downgrade to TLS 1.0 even if both the server and the client support a
higher protocol version, by modifying the client's TLS records.
Thanks to David Benjamin and Adam Langley (Google) for discovering and
researching this issue.
(CVE-2014-3511)
[David Benjamin]
*) OpenSSL DTLS clients enabling anonymous (EC)DH ciphersuites are subject
to a denial of service attack. A malicious server can crash the client
with a null pointer dereference (read) by specifying an anonymous (EC)DH
ciphersuite and sending carefully crafted handshake messages.
Thanks to Felix Gröbert (Google) for discovering and researching this
issue.
(CVE-2014-3510)
[Emilia Käsper]
*) By sending carefully crafted DTLS packets an attacker could cause openssl
to leak memory. This can be exploited through a Denial of Service attack.
Thanks to Adam Langley for discovering and researching this issue.
(CVE-2014-3507)
[Adam Langley]
*) An attacker can force openssl to consume large amounts of memory whilst
processing DTLS handshake messages. This can be exploited through a
Denial of Service attack.
Thanks to Adam Langley for discovering and researching this issue.
(CVE-2014-3506)
[Adam Langley]
*) An attacker can force an error condition which causes openssl to crash
whilst processing DTLS packets due to memory being freed twice. This
can be exploited through a Denial of Service attack.
Thanks to Adam Langley and Wan-Teh Chang for discovering and researching
this issue.
(CVE-2014-3505)
[Adam Langley]
*) If a multithreaded client connects to a malicious server using a resumed
session and the server sends an ec point format extension it could write
up to 255 bytes to freed memory.
Thanks to Gabor Tyukasz (LogMeIn Inc) for discovering and researching this
issue.
(CVE-2014-3509)
[Gabor Tyukasz]
*) A malicious server can crash an OpenSSL client with a null pointer
dereference (read) by specifying an SRP ciphersuite even though it was not
properly negotiated with the client. This can be exploited through a
Denial of Service attack.
Thanks to Joonas Kuorilehto and Riku Hietamäki (Codenomicon) for
discovering and researching this issue.
(CVE-2014-5139)
[Steve Henson]
*) A flaw in OBJ_obj2txt may cause pretty printing functions such as
X509_name_oneline, X509_name_print_ex et al. to leak some information
from the stack. Applications may be affected if they echo pretty printing
output to the attacker.
Thanks to Ivan Fratric (Google) for discovering this issue.
(CVE-2014-3508)
[Emilia Käsper, and Steve Henson]
*) Fix ec_GFp_simple_points_make_affine (thus, EC_POINTs_mul etc.)
for corner cases. (Certain input points at infinity could lead to
bogus results, with non-infinity inputs mapped to infinity too.)
[Bodo Moeller]
Changes between 1.0.1g and 1.0.1h [5 Jun 2014]
*) Fix for SSL/TLS MITM flaw. An attacker using a carefully crafted
handshake can force the use of weak keying material in OpenSSL
SSL/TLS clients and servers.
Thanks to KIKUCHI Masashi (Lepidum Co. Ltd.) for discovering and
researching this issue. (CVE-2014-0224)
[KIKUCHI Masashi, Steve Henson]
*) Fix DTLS recursion flaw. By sending an invalid DTLS handshake to an
OpenSSL DTLS client the code can be made to recurse eventually crashing
in a DoS attack.
Thanks to Imre Rad (Search-Lab Ltd.) for discovering this issue.
(CVE-2014-0221)
[Imre Rad, Steve Henson]
*) Fix DTLS invalid fragment vulnerability. A buffer overrun attack can
be triggered by sending invalid DTLS fragments to an OpenSSL DTLS
client or server. This is potentially exploitable to run arbitrary
code on a vulnerable client or server.
Thanks to Jüri Aedla for reporting this issue. (CVE-2014-0195)
[Jüri Aedla, Steve Henson]
*) Fix bug in TLS code where clients enable anonymous ECDH ciphersuites
are subject to a denial of service attack.
Thanks to Felix Gröbert and Ivan Fratric at Google for discovering
this issue. (CVE-2014-3470)
[Felix Gröbert, Ivan Fratric, Steve Henson]
*) Harmonize version and its documentation. -f flag is used to display
compilation flags.
[mancha <mancha1@zoho.com>]
*) Fix eckey_priv_encode so it immediately returns an error upon a failure
in i2d_ECPrivateKey.
[mancha <mancha1@zoho.com>]
*) Fix some double frees. These are not thought to be exploitable.
[mancha <mancha1@zoho.com>]
Changes between 1.0.1f and 1.0.1g [7 Apr 2014]
*) A missing bounds check in the handling of the TLS heartbeat extension
can be used to reveal up to 64k of memory to a connected client or
server.
Thanks for Neel Mehta of Google Security for discovering this bug and to
Adam Langley <agl@chromium.org> and Bodo Moeller <bmoeller@acm.org> for
preparing the fix (CVE-2014-0160)
[Adam Langley, Bodo Moeller]
*) Fix for the attack described in the paper "Recovering OpenSSL
ECDSA Nonces Using the FLUSH+RELOAD Cache Side-channel Attack"
by Yuval Yarom and Naomi Benger. Details can be obtained from:
http://eprint.iacr.org/2014/140
Thanks to Yuval Yarom and Naomi Benger for discovering this
flaw and to Yuval Yarom for supplying a fix (CVE-2014-0076)
[Yuval Yarom and Naomi Benger]
*) TLS pad extension: draft-agl-tls-padding-03
Workaround for the "TLS hang bug" (see FAQ and PR#2771): if the
TLS client Hello record length value would otherwise be > 255 and
less that 512 pad with a dummy extension containing zeroes so it
is at least 512 bytes long.
[Adam Langley, Steve Henson]
Changes between 1.0.1e and 1.0.1f [6 Jan 2014]
*) Fix for TLS record tampering bug. A carefully crafted invalid
handshake could crash OpenSSL with a NULL pointer exception.
Thanks to Anton Johansson for reporting this issues.
(CVE-2013-4353)
*) Keep original DTLS digest and encryption contexts in retransmission
structures so we can use the previous session parameters if they need
to be resent. (CVE-2013-6450)
[Steve Henson]
*) Add option SSL_OP_SAFARI_ECDHE_ECDSA_BUG (part of SSL_OP_ALL) which
avoids preferring ECDHE-ECDSA ciphers when the client appears to be
Safari on OS X. Safari on OS X 10.8..10.8.3 advertises support for
several ECDHE-ECDSA ciphers, but fails to negotiate them. The bug
is fixed in OS X 10.8.4, but Apple have ruled out both hot fixing
10.8..10.8.3 and forcing users to upgrade to 10.8.4 or newer.
[Rob Stradling, Adam Langley]
Changes between 1.0.1d and 1.0.1e [11 Feb 2013]
*) Correct fix for CVE-2013-0169. The original didn't work on AES-NI
supporting platforms or when small records were transferred.
[Andy Polyakov, Steve Henson]
Changes between 1.0.1c and 1.0.1d [5 Feb 2013]
*) Make the decoding of SSLv3, TLS and DTLS CBC records constant time.
This addresses the flaw in CBC record processing discovered by
Nadhem Alfardan and Kenny Paterson. Details of this attack can be found
at: http://www.isg.rhul.ac.uk/tls/
Thanks go to Nadhem Alfardan and Kenny Paterson of the Information
Security Group at Royal Holloway, University of London
(www.isg.rhul.ac.uk) for discovering this flaw and Adam Langley and
Emilia Käsper for the initial patch.
(CVE-2013-0169)
[Emilia Käsper, Adam Langley, Ben Laurie, Andy Polyakov, Steve Henson]
*) Fix flaw in AESNI handling of TLS 1.2 and 1.1 records for CBC mode
ciphersuites which can be exploited in a denial of service attack.
Thanks go to and to Adam Langley <agl@chromium.org> for discovering
and detecting this bug and to Wolfgang Ettlinger
<wolfgang.ettlinger@gmail.com> for independently discovering this issue.
(CVE-2012-2686)
[Adam Langley]
*) Return an error when checking OCSP signatures when key is NULL.
This fixes a DoS attack. (CVE-2013-0166)
[Steve Henson]
*) Make openssl verify return errors.
[Chris Palmer <palmer@google.com> and Ben Laurie]
*) Call OCSP Stapling callback after ciphersuite has been chosen, so
the right response is stapled. Also change SSL_get_certificate()
so it returns the certificate actually sent.
See http://rt.openssl.org/Ticket/Display.html?id=2836.
[Rob Stradling <rob.stradling@comodo.com>]
*) Fix possible deadlock when decoding public keys.
[Steve Henson]
*) Don't use TLS 1.0 record version number in initial client hello
if renegotiating.
[Steve Henson]
Changes between 1.0.1b and 1.0.1c [10 May 2012]
*) Sanity check record length before skipping explicit IV in TLS
1.2, 1.1 and DTLS to fix DoS attack.
Thanks to Codenomicon for discovering this issue using Fuzz-o-Matic
fuzzing as a service testing platform.
(CVE-2012-2333)
[Steve Henson]
*) Initialise tkeylen properly when encrypting CMS messages.
Thanks to Solar Designer of Openwall for reporting this issue.
[Steve Henson]
*) In FIPS mode don't try to use composite ciphers as they are not
approved.
[Steve Henson]
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] Changes between 1.0.0h and 1.0.1 [14 Mar 2012]
*) Add compatibility with old MDC2 signatures which use an ASN1 OCTET *) Add compatibility with old MDC2 signatures which use an ASN1 OCTET
@ -285,7 +902,75 @@
Add command line options to s_client/s_server. Add command line options to s_client/s_server.
[Steve Henson] [Steve Henson]
Changes between 1.0.0g and 1.0.0h [xx XXX xxxx] Changes between 1.0.0j and 1.0.0k [5 Feb 2013]
*) Make the decoding of SSLv3, TLS and DTLS CBC records constant time.
This addresses the flaw in CBC record processing discovered by
Nadhem Alfardan and Kenny Paterson. Details of this attack can be found
at: http://www.isg.rhul.ac.uk/tls/
Thanks go to Nadhem Alfardan and Kenny Paterson of the Information
Security Group at Royal Holloway, University of London
(www.isg.rhul.ac.uk) for discovering this flaw and Adam Langley and
Emilia Käsper for the initial patch.
(CVE-2013-0169)
[Emilia Käsper, Adam Langley, Ben Laurie, Andy Polyakov, Steve Henson]
*) Return an error when checking OCSP signatures when key is NULL.
This fixes a DoS attack. (CVE-2013-0166)
[Steve Henson]
*) Call OCSP Stapling callback after ciphersuite has been chosen, so
the right response is stapled. Also change SSL_get_certificate()
so it returns the certificate actually sent.
See http://rt.openssl.org/Ticket/Display.html?id=2836.
(This is a backport)
[Rob Stradling <rob.stradling@comodo.com>]
*) Fix possible deadlock when decoding public keys.
[Steve Henson]
Changes between 1.0.0i and 1.0.0j [10 May 2012]
[NB: OpenSSL 1.0.0i and later 1.0.0 patch levels were released after
OpenSSL 1.0.1.]
*) Sanity check record length before skipping explicit IV in DTLS
to fix DoS attack.
Thanks to Codenomicon for discovering this issue using Fuzz-o-Matic
fuzzing as a service testing platform.
(CVE-2012-2333)
[Steve Henson]
*) Initialise tkeylen properly when encrypting CMS messages.
Thanks to Solar Designer of Openwall for reporting this issue.
[Steve Henson]
Changes between 1.0.0h and 1.0.0i [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]
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 *) Fix CVE-2011-4619: make sure we really are receiving a
client hello before rejecting multiple SGC restarts. Thanks to client hello before rejecting multiple SGC restarts. Thanks to
@ -1264,6 +1949,86 @@
*) Change 'Configure' script to enable Camellia by default. *) Change 'Configure' script to enable Camellia by default.
[NTT] [NTT]
Changes between 0.9.8x and 0.9.8y [5 Feb 2013]
*) Make the decoding of SSLv3, TLS and DTLS CBC records constant time.
This addresses the flaw in CBC record processing discovered by
Nadhem Alfardan and Kenny Paterson. Details of this attack can be found
at: http://www.isg.rhul.ac.uk/tls/
Thanks go to Nadhem Alfardan and Kenny Paterson of the Information
Security Group at Royal Holloway, University of London
(www.isg.rhul.ac.uk) for discovering this flaw and Adam Langley and
Emilia Käsper for the initial patch.
(CVE-2013-0169)
[Emilia Käsper, Adam Langley, Ben Laurie, Andy Polyakov, Steve Henson]
*) Return an error when checking OCSP signatures when key is NULL.
This fixes a DoS attack. (CVE-2013-0166)
[Steve Henson]
*) Call OCSP Stapling callback after ciphersuite has been chosen, so
the right response is stapled. Also change SSL_get_certificate()
so it returns the certificate actually sent.
See http://rt.openssl.org/Ticket/Display.html?id=2836.
(This is a backport)
[Rob Stradling <rob.stradling@comodo.com>]
*) Fix possible deadlock when decoding public keys.
[Steve Henson]
Changes between 0.9.8w and 0.9.8x [10 May 2012]
*) Sanity check record length before skipping explicit IV in DTLS
to fix DoS attack.
Thanks to Codenomicon for discovering this issue using Fuzz-o-Matic
fuzzing as a service testing platform.
(CVE-2012-2333)
[Steve Henson]
*) Initialise tkeylen properly when encrypting CMS messages.
Thanks to Solar Designer of Openwall for reporting this issue.
[Steve Henson]
Changes between 0.9.8v and 0.9.8w [23 Apr 2012]
*) The fix for CVE-2012-2110 did not take into account that the
'len' argument to BUF_MEM_grow and BUF_MEM_grow_clean is an
int in OpenSSL 0.9.8, making it still vulnerable. Fix by
rejecting negative len parameter. (CVE-2012-2131)
[Tomas Hoger <thoger@redhat.com>]
Changes between 0.9.8u and 0.9.8v [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]
Changes between 0.9.8t and 0.9.8u [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
Ivan Nestlerode <inestlerode@us.ibm.com> for discovering this bug.
[Steve Henson]
Changes between 0.9.8s and 0.9.8t [18 Jan 2012] Changes between 0.9.8s and 0.9.8t [18 Jan 2012]
*) Fix for DTLS DoS issue introduced by fix for CVE-2011-4109. *) Fix for DTLS DoS issue introduced by fix for CVE-2011-4109.

174
Configure
View File

@ -124,24 +124,25 @@ my $tlib="-lnsl -lsocket";
my $bits1="THIRTY_TWO_BIT "; my $bits1="THIRTY_TWO_BIT ";
my $bits2="SIXTY_FOUR_BIT "; my $bits2="SIXTY_FOUR_BIT ";
my $x86_asm="x86cpuid.o:bn-586.o co-586.o x86-mont.o x86-gf2m.o:des-586.o crypt586.o:aes-586.o vpaes-x86.o aesni-x86.o:bf-586.o:md5-586.o:sha1-586.o sha256-586.o sha512-586.o:cast-586.o:rc4-586.o:rmd-586.o:rc5-586.o:wp_block.o wp-mmx.o:cmll-x86.o:ghash-x86.o:"; my $x86_asm="x86cpuid.o:bn-586.o co-586.o x86-mont.o x86-gf2m.o::des-586.o crypt586.o:aes-586.o vpaes-x86.o aesni-x86.o:bf-586.o:md5-586.o:sha1-586.o sha256-586.o sha512-586.o:cast-586.o:rc4-586.o:rmd-586.o:rc5-586.o:wp_block.o wp-mmx.o:cmll-x86.o:ghash-x86.o:";
my $x86_elf_asm="$x86_asm:elf"; my $x86_elf_asm="$x86_asm:elf";
my $x86_64_asm="x86_64cpuid.o:x86_64-gcc.o x86_64-mont.o x86_64-mont5.o x86_64-gf2m.o modexp512-x86_64.o::aes-x86_64.o vpaes-x86_64.o bsaes-x86_64.o aesni-x86_64.o aesni-sha1-x86_64.o::md5-x86_64.o:sha1-x86_64.o sha256-x86_64.o sha512-x86_64.o::rc4-x86_64.o rc4-md5-x86_64.o:::wp-x86_64.o:cmll-x86_64.o cmll_misc.o:ghash-x86_64.o:"; my $x86_64_asm="x86_64cpuid.o:x86_64-gcc.o x86_64-mont.o x86_64-mont5.o x86_64-gf2m.o rsaz_exp.o rsaz-x86_64.o rsaz-avx2.o:ecp_nistz256.o ecp_nistz256-x86_64.o::aes-x86_64.o vpaes-x86_64.o bsaes-x86_64.o aesni-x86_64.o aesni-sha1-x86_64.o aesni-sha256-x86_64.o aesni-mb-x86_64.o::md5-x86_64.o:sha1-x86_64.o sha256-x86_64.o sha512-x86_64.o sha1-mb-x86_64.o sha256-mb-x86_64.o::rc4-x86_64.o rc4-md5-x86_64.o:::wp-x86_64.o:cmll-x86_64.o cmll_misc.o:ghash-x86_64.o aesni-gcm-x86_64.o:";
my $ia64_asm="ia64cpuid.o:bn-ia64.o ia64-mont.o::aes_core.o aes_cbc.o aes-ia64.o::md5-ia64.o:sha1-ia64.o sha256-ia64.o sha512-ia64.o::rc4-ia64.o rc4_skey.o:::::ghash-ia64.o::void"; my $ia64_asm="ia64cpuid.o:bn-ia64.o ia64-mont.o:::aes_core.o aes_cbc.o aes-ia64.o::md5-ia64.o:sha1-ia64.o sha256-ia64.o sha512-ia64.o::rc4-ia64.o rc4_skey.o:::::ghash-ia64.o::void";
my $sparcv9_asm="sparcv9cap.o sparccpuid.o:bn-sparcv9.o sparcv9-mont.o sparcv9a-mont.o:des_enc-sparc.o fcrypt_b.o:aes_core.o aes_cbc.o aes-sparcv9.o:::sha1-sparcv9.o sha256-sparcv9.o sha512-sparcv9.o:::::::ghash-sparcv9.o::void"; my $sparcv9_asm="sparcv9cap.o sparccpuid.o:bn-sparcv9.o sparcv9-mont.o sparcv9a-mont.o vis3-mont.o sparct4-mont.o sparcv9-gf2m.o::des_enc-sparc.o fcrypt_b.o dest4-sparcv9.o:aes_core.o aes_cbc.o aes-sparcv9.o aest4-sparcv9.o::md5-sparcv9.o:sha1-sparcv9.o sha256-sparcv9.o sha512-sparcv9.o::::::camellia.o cmll_misc.o cmll_cbc.o cmllt4-sparcv9.o:ghash-sparcv9.o::void";
my $sparcv8_asm=":sparcv8.o:des_enc-sparc.o fcrypt_b.o:::::::::::::void"; my $sparcv8_asm=":sparcv8.o::des_enc-sparc.o fcrypt_b.o:::::::::::::void";
my $alpha_asm="alphacpuid.o:bn_asm.o alpha-mont.o:::::sha1-alpha.o:::::::ghash-alpha.o::void"; my $alpha_asm="alphacpuid.o:bn_asm.o alpha-mont.o::::::sha1-alpha.o:::::::ghash-alpha.o::void";
my $mips32_asm=":bn-mips.o::aes_cbc.o aes-mips.o:::sha1-mips.o sha256-mips.o::::::::"; my $mips64_asm=":bn-mips.o mips-mont.o:::aes_cbc.o aes-mips.o:::sha1-mips.o sha256-mips.o sha512-mips.o::::::::";
my $mips64_asm=":bn-mips.o mips-mont.o::aes_cbc.o aes-mips.o:::sha1-mips.o sha256-mips.o sha512-mips.o::::::::"; my $mips32_asm=$mips64_asm; $mips32_asm =~ s/\s*sha512\-mips\.o//;
my $s390x_asm="s390xcap.o s390xcpuid.o:bn-s390x.o s390x-mont.o s390x-gf2m.o::aes-s390x.o aes-ctr.o aes-xts.o:::sha1-s390x.o sha256-s390x.o sha512-s390x.o::rc4-s390x.o:::::ghash-s390x.o:"; my $s390x_asm="s390xcap.o s390xcpuid.o:bn-s390x.o s390x-mont.o s390x-gf2m.o:::aes-s390x.o aes-ctr.o aes-xts.o:::sha1-s390x.o sha256-s390x.o sha512-s390x.o::rc4-s390x.o:::::ghash-s390x.o:";
my $armv4_asm="armcap.o armv4cpuid.o:bn_asm.o armv4-mont.o armv4-gf2m.o::aes_cbc.o aes-armv4.o:::sha1-armv4-large.o sha256-armv4.o sha512-armv4.o:::::::ghash-armv4.o::void"; my $armv4_asm="armcap.o armv4cpuid.o:bn_asm.o armv4-mont.o armv4-gf2m.o:::aes_cbc.o aes-armv4.o bsaes-armv7.o aesv8-armx.o:::sha1-armv4-large.o sha256-armv4.o sha512-armv4.o:::::::ghash-armv4.o ghashv8-armx.o::void";
my $parisc11_asm="pariscid.o:bn_asm.o parisc-mont.o::aes_core.o aes_cbc.o aes-parisc.o:::sha1-parisc.o sha256-parisc.o sha512-parisc.o::rc4-parisc.o:::::ghash-parisc.o::32"; my $aarch64_asm="armcap.o arm64cpuid.o mem_clr.o::::aes_core.o aes_cbc.o aesv8-armx.o:::sha1-armv8.o sha256-armv8.o sha512-armv8.o:::::::ghashv8-armx.o:";
my $parisc20_asm="pariscid.o:pa-risc2W.o parisc-mont.o::aes_core.o aes_cbc.o aes-parisc.o:::sha1-parisc.o sha256-parisc.o sha512-parisc.o::rc4-parisc.o:::::ghash-parisc.o::64"; my $parisc11_asm="pariscid.o:bn_asm.o parisc-mont.o:::aes_core.o aes_cbc.o aes-parisc.o:::sha1-parisc.o sha256-parisc.o sha512-parisc.o::rc4-parisc.o:::::ghash-parisc.o::32";
my $ppc32_asm="ppccpuid.o ppccap.o:bn-ppc.o ppc-mont.o ppc64-mont.o::aes_core.o aes_cbc.o aes-ppc.o:::sha1-ppc.o sha256-ppc.o::::::::"; my $parisc20_asm="pariscid.o:pa-risc2W.o parisc-mont.o:::aes_core.o aes_cbc.o aes-parisc.o:::sha1-parisc.o sha256-parisc.o sha512-parisc.o::rc4-parisc.o:::::ghash-parisc.o::64";
my $ppc64_asm="ppccpuid.o ppccap.o:bn-ppc.o ppc-mont.o ppc64-mont.o::aes_core.o aes_cbc.o aes-ppc.o:::sha1-ppc.o sha256-ppc.o sha512-ppc.o::::::::"; my $ppc64_asm="ppccpuid.o ppccap.o:bn-ppc.o ppc-mont.o ppc64-mont.o:::aes_core.o aes_cbc.o aes-ppc.o vpaes-ppc.o aesp8-ppc.o:::sha1-ppc.o sha256-ppc.o sha512-ppc.o sha256p8-ppc.o sha512p8-ppc.o:::::::ghashp8-ppc.o:";
my $no_asm=":::::::::::::::void"; my $ppc32_asm=$ppc64_asm;
my $no_asm="::::::::::::::::void";
# As for $BSDthreads. Idea is to maintain "collective" set of flags, # As for $BSDthreads. Idea is to maintain "collective" set of flags,
# which would cover all BSD flavors. -pthread applies to them all, # which would cover all BSD flavors. -pthread applies to them all,
@ -152,7 +153,7 @@ my $no_asm=":::::::::::::::void";
# seems to be sufficient? # seems to be sufficient?
my $BSDthreads="-pthread -D_THREAD_SAFE -D_REENTRANT"; my $BSDthreads="-pthread -D_THREAD_SAFE -D_REENTRANT";
#config-string $cc : $cflags : $unistd : $thread_cflag : $sys_id : $lflags : $bn_ops : $cpuid_obj : $bn_obj : $des_obj : $aes_obj : $bf_obj : $md5_obj : $sha1_obj : $cast_obj : $rc4_obj : $rmd160_obj : $rc5_obj : $wp_obj : $cmll_obj : $modes_obj : $engines_obj : $dso_scheme : $shared_target : $shared_cflag : $shared_ldflag : $shared_extension : $ranlib : $arflags : $multilib #config-string $cc : $cflags : $unistd : $thread_cflag : $sys_id : $lflags : $bn_ops : $cpuid_obj : $bn_obj : $ec_obj : $des_obj : $aes_obj : $bf_obj : $md5_obj : $sha1_obj : $cast_obj : $rc4_obj : $rmd160_obj : $rc5_obj : $wp_obj : $cmll_obj : $modes_obj : $engines_obj : $dso_scheme : $shared_target : $shared_cflag : $shared_ldflag : $shared_extension : $ranlib : $arflags : $multilib
my %table=( my %table=(
# File 'TABLE' (created by 'make TABLE') contains the data from this list, # File 'TABLE' (created by 'make TABLE') contains the data from this list,
@ -171,27 +172,30 @@ my %table=(
"debug-ben-openbsd","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::", "debug-ben-openbsd","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::",
"debug-ben-openbsd-debug","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::", "debug-ben-openbsd-debug","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::",
"debug-ben-debug", "gcc44:$gcc_devteam_warn -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O2 -pipe::(unknown)::::::", "debug-ben-debug", "gcc44:$gcc_devteam_warn -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O2 -pipe::(unknown)::::::",
"debug-ben-debug-64", "gcc:$gcc_devteam_warn -Wno-error=overlength-strings -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe::${BSDthreads}:::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"debug-ben-macos", "cc:$gcc_devteam_warn -arch i386 -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -O3 -DL_ENDIAN -g3 -pipe::(unknown)::-Wl,-search_paths_first::::", "debug-ben-macos", "cc:$gcc_devteam_warn -arch i386 -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -O3 -DL_ENDIAN -g3 -pipe::(unknown)::-Wl,-search_paths_first::::",
"debug-ben-macos-gcc46", "gcc-mp-4.6:$gcc_devteam_warn -Wconversion -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -O3 -DL_ENDIAN -g3 -pipe::(unknown)::::::", "debug-ben-macos-gcc46", "gcc-mp-4.6:$gcc_devteam_warn -Wconversion -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -O3 -DL_ENDIAN -g3 -pipe::(unknown)::::::",
"debug-ben-darwin64","cc:$gcc_devteam_warn -g -Wno-language-extension-token -Wno-extended-offsetof -arch x86_64 -O3 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
"debug-ben-debug-64-clang", "clang:$gcc_devteam_warn -Wno-error=overlength-strings -Wno-error=extended-offsetof -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe::${BSDthreads}:::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"debug-ben-no-opt", "gcc: -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG -Werror -DL_ENDIAN -DTERMIOS -Wall -g3::(unknown)::::::", "debug-ben-no-opt", "gcc: -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG -Werror -DL_ENDIAN -DTERMIOS -Wall -g3::(unknown)::::::",
"debug-ben-strict", "gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DCONST_STRICT -O2 -Wall -Wshadow -Werror -Wpointer-arith -Wcast-qual -Wwrite-strings -pipe::(unknown)::::::", "debug-ben-strict", "gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DCONST_STRICT -O2 -Wall -Wshadow -Werror -Wpointer-arith -Wcast-qual -Wwrite-strings -pipe::(unknown)::::::",
"debug-rse","cc:-DTERMIOS -DL_ENDIAN -pipe -O -g -ggdb3 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}", "debug-rse","cc:-DTERMIOS -DL_ENDIAN -pipe -O -g -ggdb3 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}",
"debug-bodo", "gcc:$gcc_devteam_warn -DBN_DEBUG -DBN_DEBUG_RAND -DCONF_DEBUG -DBIO_PAIR_DEBUG -m64 -DL_ENDIAN -DTERMIO -g -DMD32_REG_T=int::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", "debug-bodo", "gcc:$gcc_devteam_warn -Wno-error=overlength-strings -DBN_DEBUG -DBN_DEBUG_RAND -DCONF_DEBUG -DBIO_PAIR_DEBUG -m64 -DL_ENDIAN -DTERMIO -g -DMD32_REG_T=int::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
"debug-ulf", "gcc:-DTERMIOS -DL_ENDIAN -march=i486 -Wall -DBN_DEBUG -DBN_DEBUG_RAND -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -g -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations:::CYGWIN32:::${no_asm}:win32:cygwin-shared:::.dll", "debug-ulf", "gcc:-DTERMIOS -DL_ENDIAN -march=i486 -Wall -DBN_DEBUG -DBN_DEBUG_RAND -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -g -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations:::CYGWIN32:::${no_asm}:win32:cygwin-shared:::.dll",
"debug-steve64", "gcc:$gcc_devteam_warn -m64 -DL_ENDIAN -DTERMIO -DCONF_DEBUG -DDEBUG_SAFESTACK -g::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-steve64", "gcc:$gcc_devteam_warn -m64 -DL_ENDIAN -DTERMIO -DCONF_DEBUG -DDEBUG_SAFESTACK -Wno-overlength-strings -g::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"debug-steve32", "gcc:$gcc_devteam_warn -m32 -DL_ENDIAN -DCONF_DEBUG -DDEBUG_SAFESTACK -g -pipe::-D_REENTRANT::-rdynamic -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC:-m32:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-steve32", "gcc:$gcc_devteam_warn -m32 -DL_ENDIAN -DCONF_DEBUG -DDEBUG_SAFESTACK -Wno-overlength-strings -g -pipe::-D_REENTRANT::-rdynamic -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC:-m32:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"debug-steve-opt", "gcc:$gcc_devteam_warn -m64 -O3 -DL_ENDIAN -DTERMIO -DCONF_DEBUG -DDEBUG_SAFESTACK -g::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-steve-opt", "gcc:$gcc_devteam_warn -m64 -O3 -DL_ENDIAN -DTERMIO -DCONF_DEBUG -DDEBUG_SAFESTACK -g::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"debug-levitte-linux-elf","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-levitte-linux-elf","gcc:-DLEVITTE_DEBUG -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -ggdb -g3 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"debug-levitte-linux-noasm","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-levitte-linux-noasm","gcc:-DLEVITTE_DEBUG -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -ggdb -g3 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"debug-levitte-linux-elf-extreme","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-levitte-linux-elf-extreme","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DL_ENDIAN -DTERMIO -DPEDANTIC -ggdb -g3 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"debug-levitte-linux-noasm-extreme","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-levitte-linux-noasm-extreme","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -DTERMIO -DPEDANTIC -ggdb -g3 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"debug-geoff32","gcc:-DBN_DEBUG -DBN_DEBUG_RAND -DBN_STRICT -DPURIFY -DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -DL_ENDIAN -DTERMIO -DPEDANTIC -O1 -ggdb2 -Wall -Werror -Wundef -pedantic -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare -Wmissing-prototypes -Wmissing-declarations -Wno-long-long::-D_REENTRANT::-ldl:BN_LLONG:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-geoff32","gcc:-DBN_DEBUG -DBN_DEBUG_RAND -DBN_STRICT -DPURIFY -DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -DL_ENDIAN -DTERMIO -DPEDANTIC -O1 -ggdb2 -Wall -Werror -Wundef -pedantic -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare -Wmissing-prototypes -Wmissing-declarations -Wno-long-long::-D_REENTRANT::-ldl:BN_LLONG:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"debug-geoff64","gcc:-DBN_DEBUG -DBN_DEBUG_RAND -DBN_STRICT -DPURIFY -DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -DL_ENDIAN -DTERMIO -DPEDANTIC -O1 -ggdb2 -Wall -Werror -Wundef -pedantic -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare -Wmissing-prototypes -Wmissing-declarations -Wno-long-long::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-geoff64","gcc:-DBN_DEBUG -DBN_DEBUG_RAND -DBN_STRICT -DPURIFY -DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -DL_ENDIAN -DTERMIO -DPEDANTIC -O1 -ggdb2 -Wall -Werror -Wundef -pedantic -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare -Wmissing-prototypes -Wmissing-declarations -Wno-long-long::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"debug-linux-pentium","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -mcpu=pentium -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn", "debug-linux-pentium","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -mcpu=pentium -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn",
"debug-linux-ppro","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -mcpu=pentiumpro -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn", "debug-linux-ppro","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -mcpu=pentiumpro -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn",
"debug-linux-elf","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -march=i486 -Wall::-D_REENTRANT::-lefence -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-linux-elf","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -march=i486 -Wall::-D_REENTRANT::-lefence -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"debug-linux-elf-noefence","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -march=i486 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-linux-elf-noefence","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -march=i486 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"debug-linux-ia32-aes", "gcc:-DAES_EXPERIMENTAL -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:x86cpuid.o:bn-586.o co-586.o x86-mont.o:des-586.o crypt586.o:aes_x86core.o aes_cbc.o aesni-x86.o:bf-586.o:md5-586.o:sha1-586.o sha256-586.o sha512-586.o:cast-586.o:rc4-586.o:rmd-586.o:rc5-586.o:wp_block.o wp-mmx.o::ghash-x86.o::elf:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-linux-ia32-aes", "gcc:-DAES_EXPERIMENTAL -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:x86cpuid.o:bn-586.o co-586.o x86-mont.o::des-586.o crypt586.o:aes_x86core.o aes_cbc.o aesni-x86.o:bf-586.o:md5-586.o:sha1-586.o sha256-586.o sha512-586.o:cast-586.o:rc4-586.o:rmd-586.o:rc5-586.o:wp_block.o wp-mmx.o::ghash-x86.o::elf:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"debug-linux-generic32","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DTERMIO -g -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-linux-generic32","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DTERMIO -g -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"debug-linux-generic64","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DTERMIO -g -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-linux-generic64","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DTERMIO -g -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"debug-linux-x86_64","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -m64 -DL_ENDIAN -DTERMIO -g -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", "debug-linux-x86_64","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -m64 -DL_ENDIAN -DTERMIO -g -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
@ -223,7 +227,7 @@ my %table=(
"solaris64-x86_64-gcc","gcc:-m64 -O3 -Wall -DL_ENDIAN::-D_REENTRANT::-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:solaris-shared:-fPIC:-m64 -shared -static-libgcc:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/64", "solaris64-x86_64-gcc","gcc:-m64 -O3 -Wall -DL_ENDIAN::-D_REENTRANT::-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:solaris-shared:-fPIC:-m64 -shared -static-libgcc:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/64",
#### Solaris x86 with Sun C setups #### Solaris x86 with Sun C setups
"solaris-x86-cc","cc:-fast -O -Xa::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_UNROLL BF_PTR:${no_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "solaris-x86-cc","cc:-fast -xarch=generic -O -Xa::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_UNROLL BF_PTR:${no_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"solaris64-x86_64-cc","cc:-fast -xarch=amd64 -xstrconst -Xa -DL_ENDIAN::-D_REENTRANT::-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:solaris-shared:-KPIC:-xarch=amd64 -G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/64", "solaris64-x86_64-cc","cc:-fast -xarch=amd64 -xstrconst -Xa -DL_ENDIAN::-D_REENTRANT::-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:solaris-shared:-KPIC:-xarch=amd64 -G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/64",
#### SPARC Solaris with GNU C setups #### SPARC Solaris with GNU C setups
@ -243,7 +247,7 @@ my %table=(
"solaris-sparcv7-cc","cc:-xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${no_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "solaris-sparcv7-cc","cc:-xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${no_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"solaris-sparcv8-cc","cc:-xarch=v8 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv8_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "solaris-sparcv8-cc","cc:-xarch=v8 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv8_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"solaris-sparcv9-cc","cc:-xtarget=ultra -xarch=v8plus -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "solaris-sparcv9-cc","cc:-xtarget=ultra -xarch=v8plus -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"solaris64-sparcv9-cc","cc:-xtarget=ultra -xarch=v9 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-xarch=v9 -G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):/usr/ccs/bin/ar rs::/64", "solaris64-sparcv9-cc","cc:-xtarget=ultra -xarch=v9 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-xarch=v9 -G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/64",
#### ####
"debug-solaris-sparcv8-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xarch=v8 -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv8_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-solaris-sparcv8-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xarch=v8 -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv8_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"debug-solaris-sparcv9-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xtarget=ultra -xarch=v8plus -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-solaris-sparcv9-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xtarget=ultra -xarch=v8plus -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
@ -298,7 +302,7 @@ my %table=(
"hpux-parisc-gcc","gcc:-O3 -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-Wl,+s -ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1:${no_asm}:dl:hpux-shared:-fPIC:-shared:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "hpux-parisc-gcc","gcc:-O3 -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-Wl,+s -ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1:${no_asm}:dl:hpux-shared:-fPIC:-shared:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"hpux-parisc1_1-gcc","gcc:-O3 -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-Wl,+s -ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1:${parisc11_asm}:dl:hpux-shared:-fPIC:-shared:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/pa1.1", "hpux-parisc1_1-gcc","gcc:-O3 -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-Wl,+s -ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1:${parisc11_asm}:dl:hpux-shared:-fPIC:-shared:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/pa1.1",
"hpux-parisc2-gcc","gcc:-march=2.0 -O3 -DB_ENDIAN -D_REENTRANT::::-Wl,+s -ldld:SIXTY_FOUR_BIT RC4_CHAR RC4_CHUNK DES_PTR DES_UNROLL DES_RISC1:".eval{my $asm=$parisc20_asm;$asm=~s/2W\./2\./;$asm=~s/:64/:32/;$asm}.":dl:hpux-shared:-fPIC:-shared:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/pa20_32", "hpux-parisc2-gcc","gcc:-march=2.0 -O3 -DB_ENDIAN -D_REENTRANT::::-Wl,+s -ldld:SIXTY_FOUR_BIT RC4_CHAR RC4_CHUNK DES_PTR DES_UNROLL DES_RISC1:".eval{my $asm=$parisc20_asm;$asm=~s/2W\./2\./;$asm=~s/:64/:32/;$asm}.":dl:hpux-shared:-fPIC:-shared:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/pa20_32",
"hpux64-parisc2-gcc","gcc:-O3 -DB_ENDIAN -D_REENTRANT::::-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT::pa-risc2W.o::::::::::::::void:dlfcn:hpux-shared:-fpic:-shared:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/pa20_64", "hpux64-parisc2-gcc","gcc:-O3 -DB_ENDIAN -D_REENTRANT::::-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT::pa-risc2W.o:::::::::::::::void:dlfcn:hpux-shared:-fpic:-shared:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/pa20_64",
# More attempts at unified 10.X and 11.X targets for HP C compiler. # More attempts at unified 10.X and 11.X targets for HP C compiler.
# #
@ -348,17 +352,27 @@ my %table=(
# It's believed that majority of ARM toolchains predefine appropriate -march. # It's believed that majority of ARM toolchains predefine appropriate -march.
# If you compiler does not, do complement config command line with one! # If you compiler does not, do complement config command line with one!
"linux-armv4", "gcc:-DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "linux-armv4", "gcc:-DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"linux-aarch64","gcc:-DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${aarch64_asm}:linux64:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
# Configure script adds minimally required -march for assembly support,
# if no -march was specified at command line. mips32 and mips64 below
# refer to contemporary MIPS Architecture specifications, MIPS32 and
# MIPS64, rather than to kernel bitness.
"linux-mips32", "gcc:-mabi=32 -DTERMIO -O3 -Wall -DBN_DIV3W::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"linux-mips64", "gcc:-mabi=n32 -DTERMIO -O3 -Wall -DBN_DIV3W::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips64_asm}:n32:dlfcn:linux-shared:-fPIC:-mabi=n32:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::32",
"linux64-mips64", "gcc:-mabi=64 -DTERMIO -O3 -Wall -DBN_DIV3W::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips64_asm}:64:dlfcn:linux-shared:-fPIC:-mabi=64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
#### IA-32 targets... #### IA-32 targets...
"linux-ia32-icc", "icc:-DL_ENDIAN -DTERMIO -O2 -no_cpprt::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "linux-ia32-icc", "icc:-DL_ENDIAN -DTERMIO -O2::-D_REENTRANT::-ldl -no_cpprt:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"linux-elf", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "linux-elf", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"linux-aout", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -march=i486 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_asm}:a.out", "linux-aout", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -march=i486 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_asm}:a.out",
#### ####
"linux-generic64","gcc:-DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "linux-generic64","gcc:-DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"linux-ppc64", "gcc:-m64 -DB_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL:${ppc64_asm}:linux64:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", "linux-ppc64", "gcc:-m64 -DB_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL:${ppc64_asm}:linux64:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
"linux-ppc64le","gcc:-m64 -DL_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL:$ppc64_asm:linux64le:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::",
"linux-ia64", "gcc:-DL_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_UNROLL DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "linux-ia64", "gcc:-DL_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_UNROLL DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"linux-ia64-ecc","ecc:-DL_ENDIAN -DTERMIO -O2 -Wall -no_cpprt::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "linux-ia64-icc","icc:-DL_ENDIAN -DTERMIO -O2 -Wall::-D_REENTRANT::-ldl -no_cpprt:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"linux-ia64-icc","icc:-DL_ENDIAN -DTERMIO -O2 -Wall -no_cpprt::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"linux-x86_64", "gcc:-m64 -DL_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", "linux-x86_64", "gcc:-m64 -DL_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
"linux-x86_64-icc", "icc:-DL_ENDIAN -DTERMIO -O2::-D_REENTRANT::-ldl -no_cpprt:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
"linux-x32", "gcc:-mx32 -DL_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-mx32:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::x32",
"linux64-s390x", "gcc:-m64 -DB_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${s390x_asm}:64:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", "linux64-s390x", "gcc:-m64 -DB_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${s390x_asm}:64:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
#### So called "highgprs" target for z/Architecture CPUs #### So called "highgprs" target for z/Architecture CPUs
# "Highgprs" is kernel feature first implemented in Linux 2.6.32, see # "Highgprs" is kernel feature first implemented in Linux 2.6.32, see
@ -405,6 +419,7 @@ my %table=(
"android","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "android","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"android-x86","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "android-x86","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"android-armv7","gcc:-march=armv7-a -mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "android-armv7","gcc:-march=armv7-a -mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"android-mips","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
#### *BSD [do see comment about ${BSDthreads} above!] #### *BSD [do see comment about ${BSDthreads} above!]
"BSD-generic32","gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "BSD-generic32","gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
@ -452,11 +467,11 @@ my %table=(
# UnixWare 2.0x fails destest with -O. # UnixWare 2.0x fails destest with -O.
"unixware-2.0","cc:-DFILIO_H -DNO_STRINGS_H::-Kthread::-lsocket -lnsl -lresolv -lx:${x86_gcc_des} ${x86_gcc_opts}:::", "unixware-2.0","cc:-DFILIO_H -DNO_STRINGS_H::-Kthread::-lsocket -lnsl -lresolv -lx:${x86_gcc_des} ${x86_gcc_opts}:::",
"unixware-2.1","cc:-O -DFILIO_H::-Kthread::-lsocket -lnsl -lresolv -lx:${x86_gcc_des} ${x86_gcc_opts}:::", "unixware-2.1","cc:-O -DFILIO_H::-Kthread::-lsocket -lnsl -lresolv -lx:${x86_gcc_des} ${x86_gcc_opts}:::",
"unixware-7","cc:-O -DFILIO_H -Kalloca::-Kthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}:${x86_elf_asm}:dlfcn:svr5-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "unixware-7","cc:-O -DFILIO_H -Kalloca::-Kthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}:${x86_elf_asm}-1:dlfcn:svr5-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"unixware-7-gcc","gcc:-DL_ENDIAN -DFILIO_H -O3 -fomit-frame-pointer -march=pentium -Wall::-D_REENTRANT::-lsocket -lnsl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:gnu-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "unixware-7-gcc","gcc:-DL_ENDIAN -DFILIO_H -O3 -fomit-frame-pointer -march=pentium -Wall::-D_REENTRANT::-lsocket -lnsl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}-1:dlfcn:gnu-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
# SCO 5 - Ben Laurie <ben@algroup.co.uk> says the -O breaks the SCO cc. # SCO 5 - Ben Laurie <ben@algroup.co.uk> says the -O breaks the SCO cc.
"sco5-cc", "cc:-belf::(unknown)::-lsocket -lnsl:${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:svr3-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "sco5-cc", "cc:-belf::(unknown)::-lsocket -lnsl:${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}-1:dlfcn:svr3-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
"sco5-gcc", "gcc:-O3 -fomit-frame-pointer::(unknown)::-lsocket -lnsl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:svr3-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "sco5-gcc", "gcc:-O3 -fomit-frame-pointer::(unknown)::-lsocket -lnsl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}-1:dlfcn:svr3-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
#### IBM's AIX. #### IBM's AIX.
"aix3-cc", "cc:-O -DB_ENDIAN -qmaxmem=16384::(unknown):AIX::BN_LLONG RC4_CHAR:::", "aix3-cc", "cc:-O -DB_ENDIAN -qmaxmem=16384::(unknown):AIX::BN_LLONG RC4_CHAR:::",
@ -464,8 +479,8 @@ my %table=(
"aix64-gcc","gcc:-maix64 -O -DB_ENDIAN::-pthread:AIX::SIXTY_FOUR_BIT_LONG RC4_CHAR:${ppc64_asm}:aix64:dlfcn:aix-shared::-maix64 -shared -Wl,-G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X64", "aix64-gcc","gcc:-maix64 -O -DB_ENDIAN::-pthread:AIX::SIXTY_FOUR_BIT_LONG RC4_CHAR:${ppc64_asm}:aix64:dlfcn:aix-shared::-maix64 -shared -Wl,-G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X64",
# Below targets assume AIX 5. Idea is to effectively disregard $OBJECT_MODE # Below targets assume AIX 5. Idea is to effectively disregard $OBJECT_MODE
# at build time. $OBJECT_MODE is respected at ./config stage! # at build time. $OBJECT_MODE is respected at ./config stage!
"aix-cc", "cc:-q32 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst::-qthreaded:AIX::BN_LLONG RC4_CHAR:${ppc32_asm}:aix32:dlfcn:aix-shared::-q32 -G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 32", "aix-cc", "cc:-q32 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst::-qthreaded -D_THREAD_SAFE:AIX::BN_LLONG RC4_CHAR:${ppc32_asm}:aix32:dlfcn:aix-shared::-q32 -G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 32",
"aix64-cc", "cc:-q64 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst::-qthreaded:AIX::SIXTY_FOUR_BIT_LONG RC4_CHAR:${ppc64_asm}:aix64:dlfcn:aix-shared::-q64 -G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 64", "aix64-cc", "cc:-q64 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst::-qthreaded -D_THREAD_SAFE:AIX::SIXTY_FOUR_BIT_LONG RC4_CHAR:${ppc64_asm}:aix64:dlfcn:aix-shared::-q64 -G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 64",
# #
# Cray T90 and similar (SDSC) # Cray T90 and similar (SDSC)
@ -516,15 +531,15 @@ my %table=(
# Visual C targets # Visual C targets
# #
# Win64 targets, WIN64I denotes IA-64 and WIN64A - AMD64 # Win64 targets, WIN64I denotes IA-64 and WIN64A - AMD64
"VC-WIN64I","cl:-W3 -Gs0 -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64I::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:ia64cpuid.o:ia64.o ia64-mont.o::aes_core.o aes_cbc.o aes-ia64.o::md5-ia64.o:sha1-ia64.o sha256-ia64.o sha512-ia64.o:::::::ghash-ia64.o::ias:win32", "VC-WIN64I","cl:-W3 -Gs0 -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64I::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:ia64cpuid.o:ia64.o ia64-mont.o:::aes_core.o aes_cbc.o aes-ia64.o::md5-ia64.o:sha1-ia64.o sha256-ia64.o sha512-ia64.o:::::::ghash-ia64.o::ias:win32",
"VC-WIN64A","cl:-W3 -Gs0 -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64A::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:".eval{my $asm=$x86_64_asm;$asm=~s/x86_64-gcc\.o/bn_asm.o/;$asm}.":auto:win32", "VC-WIN64A","cl:-W3 -Gs0 -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64A::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:".eval{my $asm=$x86_64_asm;$asm=~s/x86_64-gcc\.o/bn_asm.o/;$asm}.":auto:win32",
"debug-VC-WIN64I","cl:-W3 -Gs0 -Gy -Zi -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64I::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:ia64cpuid.o:ia64.o::aes_core.o aes_cbc.o aes-ia64.o::md5-ia64.o:sha1-ia64.o sha256-ia64.o sha512-ia64.o:::::::ghash-ia64.o::ias:win32", "debug-VC-WIN64I","cl:-W3 -Gs0 -Gy -Zi -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64I::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:ia64cpuid.o:ia64.o:::aes_core.o aes_cbc.o aes-ia64.o::md5-ia64.o:sha1-ia64.o sha256-ia64.o sha512-ia64.o:::::::ghash-ia64.o::ias:win32",
"debug-VC-WIN64A","cl:-W3 -Gs0 -Gy -Zi -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64A::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:".eval{my $asm=$x86_64_asm;$asm=~s/x86_64-gcc\.o/bn_asm.o/;$asm}.":auto:win32", "debug-VC-WIN64A","cl:-W3 -Gs0 -Gy -Zi -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64A::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:".eval{my $asm=$x86_64_asm;$asm=~s/x86_64-gcc\.o/bn_asm.o/;$asm}.":auto:win32",
# x86 Win32 target defaults to ANSI API, if you want UNICODE, complement # x86 Win32 target defaults to ANSI API, if you want UNICODE, complement
# 'perl Configure VC-WIN32' with '-DUNICODE -D_UNICODE' # 'perl Configure VC-WIN32' with '-DUNICODE -D_UNICODE'
"VC-WIN32","cl:-W3 -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE:::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${x86_asm}:win32n:win32", "VC-WIN32","cl:-W3 -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE:::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${x86_asm}:win32n:win32",
# Unified CE target # Unified CE target
"debug-VC-WIN32","cl:-W3 -WX -Gs0 -GF -Gy -Zi -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE:::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${x86_asm}:win32n:win32", "debug-VC-WIN32","cl:-W3 -Gs0 -GF -Gy -Zi -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE:::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${x86_asm}:win32n:win32",
"VC-CE","cl::::WINCE::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${no_asm}:win32", "VC-CE","cl::::WINCE::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${no_asm}:win32",
# Borland C++ 4.5 # Borland C++ 4.5
@ -547,6 +562,7 @@ my %table=(
# Cygwin # Cygwin
"Cygwin-pre1.3", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown):CYGWIN32::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:win32", "Cygwin-pre1.3", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown):CYGWIN32::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:win32",
"Cygwin", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -march=i486 -Wall:::CYGWIN32::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_asm}:coff:dlfcn:cygwin-shared:-D_WINDLL:-shared:.dll.a", "Cygwin", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -march=i486 -Wall:::CYGWIN32::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_asm}:coff:dlfcn:cygwin-shared:-D_WINDLL:-shared:.dll.a",
"Cygwin-x86_64", "gcc:-DTERMIOS -DL_ENDIAN -O3 -Wall:::CYGWIN32::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:mingw64:dlfcn:cygwin-shared:-D_WINDLL:-shared:.dll.a",
"debug-Cygwin", "gcc:-DTERMIOS -DL_ENDIAN -march=i486 -Wall -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -g -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror:::CYGWIN32:::${no_asm}:dlfcn:cygwin-shared:-D_WINDLL:-shared:.dll.a", "debug-Cygwin", "gcc:-DTERMIOS -DL_ENDIAN -march=i486 -Wall -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -g -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror:::CYGWIN32:::${no_asm}:dlfcn:cygwin-shared:-D_WINDLL:-shared:.dll.a",
# NetWare from David Ward (dsward@novell.com) # NetWare from David Ward (dsward@novell.com)
@ -579,7 +595,8 @@ my %table=(
"darwin64-ppc-cc","cc:-arch ppc64 -O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc64_asm}:osx64:dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", "darwin64-ppc-cc","cc:-arch ppc64 -O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc64_asm}:osx64:dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
"darwin-i386-cc","cc:-arch i386 -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:".eval{my $asm=$x86_asm;$asm=~s/cast\-586\.o//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", "darwin-i386-cc","cc:-arch i386 -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:".eval{my $asm=$x86_asm;$asm=~s/cast\-586\.o//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
"debug-darwin-i386-cc","cc:-arch i386 -g3 -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", "debug-darwin-i386-cc","cc:-arch i386 -g3 -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
"darwin64-x86_64-cc","cc:-arch x86_64 -O3 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", "darwin64-x86_64-cc","cc:-arch x86_64 -O3 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
"debug-darwin64-x86_64-cc","cc:-arch x86_64 -ggdb -g2 -O0 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
"debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", "debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
# iPhoneOS/iOS # iPhoneOS/iOS
"iphoneos-cross","llvm-gcc:-O3 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fomit-frame-pointer -fno-common::-D_REENTRANT:iOS:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", "iphoneos-cross","llvm-gcc:-O3 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fomit-frame-pointer -fno-common::-D_REENTRANT:iOS:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
@ -632,6 +649,7 @@ my $idx_lflags = $idx++;
my $idx_bn_ops = $idx++; my $idx_bn_ops = $idx++;
my $idx_cpuid_obj = $idx++; my $idx_cpuid_obj = $idx++;
my $idx_bn_obj = $idx++; my $idx_bn_obj = $idx++;
my $idx_ec_obj = $idx++;
my $idx_des_obj = $idx++; my $idx_des_obj = $idx++;
my $idx_aes_obj = $idx++; my $idx_aes_obj = $idx++;
my $idx_bf_obj = $idx++; my $idx_bf_obj = $idx++;
@ -712,12 +730,15 @@ my %disabled = ( # "what" => "comment" [or special keyword "experimental
"ec_nistp_64_gcc_128" => "default", "ec_nistp_64_gcc_128" => "default",
"gmp" => "default", "gmp" => "default",
"jpake" => "experimental", "jpake" => "experimental",
"libunbound" => "experimental",
"md2" => "default", "md2" => "default",
"rc5" => "default", "rc5" => "default",
"rfc3779" => "default", "rfc3779" => "default",
"sctp" => "default", "sctp" => "default",
"shared" => "default", "shared" => "default",
"ssl-trace" => "default",
"store" => "experimental", "store" => "experimental",
"unit-test" => "default",
"zlib" => "default", "zlib" => "default",
"zlib-dynamic" => "default" "zlib-dynamic" => "default"
); );
@ -725,7 +746,7 @@ my @experimental = ();
# This is what $depflags will look like with the above defaults # This is what $depflags will look like with the above defaults
# (we need this to see if we should advise the user to run "make depend"): # (we need this to see if we should advise the user to run "make depend"):
my $default_depflags = " -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_STORE"; my $default_depflags = " -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST";
# Explicit "no-..." options will be collected in %disabled along with the defaults. # Explicit "no-..." options will be collected in %disabled along with the defaults.
# To remove something from %disabled, use "enable-foo" (unless it's experimental). # To remove something from %disabled, use "enable-foo" (unless it's experimental).
@ -865,16 +886,7 @@ PROCESS_ARGS:
} }
elsif (/^[-+]/) elsif (/^[-+]/)
{ {
if (/^-[lL](.*)$/ or /^-Wl,/) if (/^--prefix=(.*)$/)
{
$libs.=$_." ";
}
elsif (/^-[^-]/ or /^\+/)
{
$_ =~ s/%([0-9a-f]{1,2})/chr(hex($1))/gei;
$flags.=$_." ";
}
elsif (/^--prefix=(.*)$/)
{ {
$prefix=$1; $prefix=$1;
} }
@ -918,10 +930,14 @@ PROCESS_ARGS:
{ {
$cross_compile_prefix=$1; $cross_compile_prefix=$1;
} }
else elsif (/^-[lL](.*)$/ or /^-Wl,/)
{ {
print STDERR $usage; $libs.=$_." ";
exit(1); }
else # common if (/^[-+]/), just pass down...
{
$_ =~ s/%([0-9a-f]{1,2})/chr(hex($1))/gei;
$flags.=$_." ";
} }
} }
elsif ($_ =~ /^([^:]+):(.+)$/) elsif ($_ =~ /^([^:]+):(.+)$/)
@ -1156,6 +1172,7 @@ my $lflags = $fields[$idx_lflags];
my $bn_ops = $fields[$idx_bn_ops]; my $bn_ops = $fields[$idx_bn_ops];
my $cpuid_obj = $fields[$idx_cpuid_obj]; my $cpuid_obj = $fields[$idx_cpuid_obj];
my $bn_obj = $fields[$idx_bn_obj]; my $bn_obj = $fields[$idx_bn_obj];
my $ec_obj = $fields[$idx_ec_obj];
my $des_obj = $fields[$idx_des_obj]; my $des_obj = $fields[$idx_des_obj];
my $aes_obj = $fields[$idx_aes_obj]; my $aes_obj = $fields[$idx_aes_obj];
my $bf_obj = $fields[$idx_bf_obj]; my $bf_obj = $fields[$idx_bf_obj];
@ -1201,6 +1218,12 @@ if ($target =~ /^mingw/ && `$cc --target-help 2>&1` !~ m/\-mno\-cygwin/m)
$shared_ldflag =~ s/\-mno\-cygwin\s*//; $shared_ldflag =~ s/\-mno\-cygwin\s*//;
} }
if ($target =~ /linux.*\-mips/ && !$no_asm && $flags !~ /\-m(ips|arch=)/) {
# minimally required architecture flags for assembly modules
$cflags="-mips2 $cflags" if ($target =~ /mips32/);
$cflags="-mips3 $cflags" if ($target =~ /mips64/);
}
my $no_shared_warn=0; my $no_shared_warn=0;
my $no_user_cflags=0; my $no_user_cflags=0;
@ -1327,7 +1350,7 @@ $lflags="$libs$lflags" if ($libs ne "");
if ($no_asm) if ($no_asm)
{ {
$cpuid_obj=$bn_obj= $cpuid_obj=$bn_obj=$ec_obj=
$des_obj=$aes_obj=$bf_obj=$cast_obj=$rc4_obj=$rc5_obj=$cmll_obj= $des_obj=$aes_obj=$bf_obj=$cast_obj=$rc4_obj=$rc5_obj=$cmll_obj=
$modes_obj=$sha1_obj=$md5_obj=$rmd160_obj=$wp_obj=$engines_obj=""; $modes_obj=$sha1_obj=$md5_obj=$rmd160_obj=$wp_obj=$engines_obj="";
} }
@ -1408,6 +1431,7 @@ if ($target =~ /\-icc$/) # Intel C compiler
} }
if ($iccver>=8) if ($iccver>=8)
{ {
$cflags=~s/\-KPIC/-fPIC/;
# Eliminate unnecessary dependency from libirc.a. This is # Eliminate unnecessary dependency from libirc.a. This is
# essential for shared library support, as otherwise # essential for shared library support, as otherwise
# apps/openssl can end up in endless loop upon startup... # apps/openssl can end up in endless loop upon startup...
@ -1415,12 +1439,17 @@ if ($target =~ /\-icc$/) # Intel C compiler
} }
if ($iccver>=9) if ($iccver>=9)
{ {
$cflags.=" -i-static"; $lflags.=" -i-static";
$cflags=~s/\-no_cpprt/-no-cpprt/; $lflags=~s/\-no_cpprt/-no-cpprt/;
} }
if ($iccver>=10) if ($iccver>=10)
{ {
$cflags=~s/\-i\-static/-static-intel/; $lflags=~s/\-i\-static/-static-intel/;
}
if ($iccver>=11)
{
$cflags.=" -no-intel-extensions"; # disable Cilk
$lflags=~s/\-no\-cpprt/-no-cxxlib/;
} }
} }
@ -1501,7 +1530,7 @@ if ($rmd160_obj =~ /\.o$/)
} }
if ($aes_obj =~ /\.o$/) if ($aes_obj =~ /\.o$/)
{ {
$cflags.=" -DAES_ASM"; $cflags.=" -DAES_ASM" if ($aes_obj =~ m/\baes\-/);;
# aes-ctr.o is not a real file, only indication that assembler # aes-ctr.o is not a real file, only indication that assembler
# module implements AES_ctr32_encrypt... # module implements AES_ctr32_encrypt...
$cflags.=" -DAES_CTR_ASM" if ($aes_obj =~ s/\s*aes\-ctr\.o//); $cflags.=" -DAES_CTR_ASM" if ($aes_obj =~ s/\s*aes\-ctr\.o//);
@ -1523,10 +1552,14 @@ else {
$wp_obj="wp_block.o"; $wp_obj="wp_block.o";
} }
$cmll_obj=$cmll_enc unless ($cmll_obj =~ /.o$/); $cmll_obj=$cmll_enc unless ($cmll_obj =~ /.o$/);
if ($modes_obj =~ /ghash/) if ($modes_obj =~ /ghash\-/)
{ {
$cflags.=" -DGHASH_ASM"; $cflags.=" -DGHASH_ASM";
} }
if ($ec_obj =~ /ecp_nistz256/)
{
$cflags.=" -DECP_NISTZ256_ASM";
}
# "Stringify" the C flags string. This permits it to be made part of a string # "Stringify" the C flags string. This permits it to be made part of a string
# and works as well on command lines. # and works as well on command lines.
@ -1630,6 +1663,7 @@ while (<IN>)
s/^EXE_EXT=.*$/EXE_EXT= $exe_ext/; s/^EXE_EXT=.*$/EXE_EXT= $exe_ext/;
s/^CPUID_OBJ=.*$/CPUID_OBJ= $cpuid_obj/; s/^CPUID_OBJ=.*$/CPUID_OBJ= $cpuid_obj/;
s/^BN_ASM=.*$/BN_ASM= $bn_obj/; s/^BN_ASM=.*$/BN_ASM= $bn_obj/;
s/^EC_ASM=.*$/EC_ASM= $ec_obj/;
s/^DES_ENC=.*$/DES_ENC= $des_obj/; s/^DES_ENC=.*$/DES_ENC= $des_obj/;
s/^AES_ENC=.*$/AES_ENC= $aes_obj/; s/^AES_ENC=.*$/AES_ENC= $aes_obj/;
s/^BF_ENC=.*$/BF_ENC= $bf_obj/; s/^BF_ENC=.*$/BF_ENC= $bf_obj/;
@ -1691,6 +1725,7 @@ print "CFLAG =$cflags\n";
print "EX_LIBS =$lflags\n"; print "EX_LIBS =$lflags\n";
print "CPUID_OBJ =$cpuid_obj\n"; print "CPUID_OBJ =$cpuid_obj\n";
print "BN_ASM =$bn_obj\n"; print "BN_ASM =$bn_obj\n";
print "EC_ASM =$ec_obj\n";
print "DES_ENC =$des_obj\n"; print "DES_ENC =$des_obj\n";
print "AES_ENC =$aes_obj\n"; print "AES_ENC =$aes_obj\n";
print "BF_ENC =$bf_obj\n"; print "BF_ENC =$bf_obj\n";
@ -1764,6 +1799,9 @@ open(OUT,'>crypto/opensslconf.h.new') || die "unable to create crypto/opensslcon
print OUT "/* opensslconf.h */\n"; print OUT "/* opensslconf.h */\n";
print OUT "/* WARNING: Generated automatically from opensslconf.h.in by Configure. */\n\n"; print OUT "/* WARNING: Generated automatically from opensslconf.h.in by Configure. */\n\n";
print OUT "#ifdef __cplusplus\n";
print OUT "extern \"C\" {\n";
print OUT "#endif\n";
print OUT "/* OpenSSL was configured with the following options: */\n"; print OUT "/* OpenSSL was configured with the following options: */\n";
my $openssl_algorithm_defines_trans = $openssl_algorithm_defines; my $openssl_algorithm_defines_trans = $openssl_algorithm_defines;
$openssl_experimental_defines =~ s/^\s*#\s*define\s+OPENSSL_NO_(.*)/#ifndef OPENSSL_EXPERIMENTAL_$1\n# ifndef OPENSSL_NO_$1\n# define OPENSSL_NO_$1\n# endif\n#endif/mg; $openssl_experimental_defines =~ s/^\s*#\s*define\s+OPENSSL_NO_(.*)/#ifndef OPENSSL_EXPERIMENTAL_$1\n# ifndef OPENSSL_NO_$1\n# define OPENSSL_NO_$1\n# endif\n#endif/mg;
@ -1868,6 +1906,9 @@ while (<IN>)
{ print OUT $_; } { print OUT $_; }
} }
close(IN); close(IN);
print OUT "#ifdef __cplusplus\n";
print OUT "}\n";
print OUT "#endif\n";
close(OUT); close(OUT);
rename("crypto/opensslconf.h","crypto/opensslconf.h.bak") || die "unable to rename crypto/opensslconf.h\n" if -e "crypto/opensslconf.h"; rename("crypto/opensslconf.h","crypto/opensslconf.h.bak") || die "unable to rename crypto/opensslconf.h\n" if -e "crypto/opensslconf.h";
rename("crypto/opensslconf.h.new","crypto/opensslconf.h") || die "unable to rename crypto/opensslconf.h.new\n"; rename("crypto/opensslconf.h.new","crypto/opensslconf.h") || die "unable to rename crypto/opensslconf.h.new\n";
@ -2092,12 +2133,12 @@ sub print_table_entry
{ {
my $target = shift; my $target = shift;
(my $cc,my $cflags,my $unistd,my $thread_cflag,my $sys_id,my $lflags, my ($cc, $cflags, $unistd, $thread_cflag, $sys_id, $lflags,
my $bn_ops,my $cpuid_obj,my $bn_obj,my $des_obj,my $aes_obj, my $bf_obj, $bn_ops, $cpuid_obj, $bn_obj, $ec_obj, $des_obj, $aes_obj, $bf_obj,
my $md5_obj,my $sha1_obj,my $cast_obj,my $rc4_obj,my $rmd160_obj, $md5_obj, $sha1_obj, $cast_obj, $rc4_obj, $rmd160_obj,
my $rc5_obj,my $wp_obj,my $cmll_obj,my $modes_obj, my $engines_obj, $rc5_obj, $wp_obj, $cmll_obj, $modes_obj, $engines_obj,
my $perlasm_scheme,my $dso_scheme,my $shared_target,my $shared_cflag, $perlasm_scheme, $dso_scheme, $shared_target, $shared_cflag,
my $shared_ldflag,my $shared_extension,my $ranlib,my $arflags,my $multilib)= $shared_ldflag, $shared_extension, $ranlib, $arflags, $multilib)=
split(/\s*:\s*/,$table{$target} . ":" x 30 , -1); split(/\s*:\s*/,$table{$target} . ":" x 30 , -1);
print <<EOF print <<EOF
@ -2112,6 +2153,7 @@ sub print_table_entry
\$bn_ops = $bn_ops \$bn_ops = $bn_ops
\$cpuid_obj = $cpuid_obj \$cpuid_obj = $cpuid_obj
\$bn_obj = $bn_obj \$bn_obj = $bn_obj
\$ec_obj = $ec_obj
\$des_obj = $des_obj \$des_obj = $des_obj
\$aes_obj = $aes_obj \$aes_obj = $aes_obj
\$bf_obj = $bf_obj \$bf_obj = $bf_obj

70
FAQ
View File

@ -10,6 +10,7 @@ OpenSSL - Frequently Asked Questions
* Why aren't tools like 'autoconf' and 'libtool' used? * Why aren't tools like 'autoconf' and 'libtool' used?
* What is an 'engine' version? * What is an 'engine' version?
* How do I check the authenticity of the OpenSSL distribution? * How do I check the authenticity of the OpenSSL distribution?
* How does the versioning scheme work?
[LEGAL] Legal questions [LEGAL] Legal questions
@ -82,11 +83,11 @@ OpenSSL - Frequently Asked Questions
* Which is the current version of OpenSSL? * Which is the current version of OpenSSL?
The current version is available from <URL: http://www.openssl.org>. The current version is available from <URL: http://www.openssl.org>.
OpenSSL 1.0.1 was released on Mar 14th, 2012. OpenSSL 1.0.1a was released on Apr 19th, 2012.
In addition to the current stable release, you can also access daily In addition to the current stable release, you can also access daily
snapshots of the OpenSSL development version at <URL: snapshots of the OpenSSL development version at <URL:
ftp://ftp.openssl.org/snapshot/>, or get it by anonymous CVS access. ftp://ftp.openssl.org/snapshot/>, or get it by anonymous Git access.
* Where is the documentation? * Where is the documentation?
@ -108,12 +109,9 @@ In addition, you can read the most current versions at
<URL: http://www.openssl.org/docs/>. Note that the online documents refer <URL: http://www.openssl.org/docs/>. Note that the online documents refer
to the very latest development versions of OpenSSL and may include features to the very latest development versions of OpenSSL and may include features
not present in released versions. If in doubt refer to the documentation 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
For information on parts of libcrypto that are not yet documented, you directory.
might want to read Ariel Glenn's documentation on SSLeay 0.9, OpenSSL's
predecessor, at <URL: http://www.columbia.edu/~ariel/ssleay/>. Much
of this still applies to OpenSSL.
There is some documentation about certificate extensions and PKCS#12 There is some documentation about certificate extensions and PKCS#12
in doc/openssl.txt in doc/openssl.txt
@ -173,14 +171,31 @@ just do:
pgp TARBALL.asc 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.
* What happens when the letter release reaches z?
It was decided after the release of OpenSSL 0.9.8y the next version should
be 0.9.8za then 0.9.8zb and so on.
[LEGAL] ======================================================================= [LEGAL] =======================================================================
* Do I need patent licenses to use OpenSSL? * Do I need patent licenses to use OpenSSL?
The patents section of the README file lists patents that may apply to For information on intellectual property rights, please consult a lawyer.
you if you want to use OpenSSL. For information on intellectual The OpenSSL team does not offer legal advice.
property rights, please consult a lawyer. The OpenSSL team does not
offer legal advice.
You can configure OpenSSL so as not to use IDEA, MDC2 and RC5 by using You can configure OpenSSL so as not to use IDEA, MDC2 and RC5 by using
./config no-idea no-mdc2 no-rc5 ./config no-idea no-mdc2 no-rc5
@ -284,7 +299,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 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 the 'req', 'verify', 'ca' and 'pkcs12' utilities. For finer control check
out the manual pages for the individual utilities and the certificate 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? * Why can't I create certificate requests?
@ -597,8 +612,8 @@ valid for the current DOS session.
* What is special about OpenSSL on Redhat? * What is special about OpenSSL on Redhat?
Red Hat Linux (release 7.0 and later) include a preinstalled limited Red Hat Linux (release 7.0 and later) include a preinstalled limited
version of OpenSSL. For patent reasons, support for IDEA, RC5 and MDC2 version of OpenSSL. Red Hat has chosen to disable support for IDEA, RC5 and
is disabled in this version. The same may apply to other Linux distributions. MDC2 in this version. The same may apply to other Linux distributions.
Users may therefore wish to install more or all of the features left out. Users may therefore wish to install more or all of the features left out.
To do this you MUST ensure that you do not overwrite the openssl that is in To do this you MUST ensure that you do not overwrite the openssl that is in
@ -621,11 +636,6 @@ relevant updates in packages up to and including 0.9.6b.
A possible way around this is to persuade Red Hat to produce a non-US A possible way around this is to persuade Red Hat to produce a non-US
version of Red Hat Linux. version of Red Hat Linux.
FYI: Patent numbers and expiry dates of US patents:
MDC-2: 4,908,861 13/03/2007
IDEA: 5,214,703 25/05/2010
RC5: 5,724,428 03/03/2015
* Why does the OpenSSL compilation fail on MacOS X? * Why does the OpenSSL compilation fail on MacOS X?
@ -752,6 +762,9 @@ openssl-security@openssl.org if you don't get a prompt reply at least
acknowledging receipt then resend or mail it directly to one of the acknowledging receipt then resend or mail it directly to one of the
more active team members (e.g. Steve). more active team members (e.g. Steve).
Note that bugs only present in the openssl utility are not in general
considered to be security issues.
[PROG] ======================================================================== [PROG] ========================================================================
* Is OpenSSL thread-safe? * Is OpenSSL thread-safe?
@ -848,7 +861,7 @@ The opposite assumes we already have len bytes in buf:
p = buf; p = buf;
p7 = d2i_PKCS7(NULL, &p, len); p7 = d2i_PKCS7(NULL, &p, len);
At this point p7 contains a valid PKCS7 structure of NULL if an error At this point p7 contains a valid PKCS7 structure or NULL if an error
occurred. If an error occurred ERR_print_errors(bio) should give more occurred. If an error occurred ERR_print_errors(bio) should give more
information. information.
@ -860,6 +873,21 @@ that has been read or written. This may well be uninitialized data
and attempts to free the buffer will have unpredictable results and attempts to free the buffer will have unpredictable results
because it no longer points to the same address. because it no longer points to the same address.
Memory allocation and encoding can also be combined in a single
operation by the ASN1 routines:
unsigned char *buf = NULL; /* mandatory */
int len;
len = i2d_PKCS7(p7, &buf);
if (len < 0)
/* Error */
/* Do some things with 'buf' */
/* Finished with buf: free it */
OPENSSL_free(buf);
In this special case the "buf" parameter is *not* incremented, it points
to the start of the encoding.
* OpenSSL uses DER but I need BER format: does OpenSSL support BER? * OpenSSL uses DER but I need BER format: does OpenSSL support BER?

8
GitConfigure Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
BRANCH=`git rev-parse --abbrev-ref HEAD`
./Configure $@ no-symlinks
make files
util/mk1mf.pl OUT=out.$BRANCH TMP=tmp.$BRANCH INC=inc.$BRANCH copy > makefile.$BRANCH
make -f makefile.$BRANCH init

5
GitMake Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
BRANCH=`git rev-parse --abbrev-ref HEAD`
make -f makefile.$BRANCH $@

View File

@ -29,7 +29,7 @@
is required if you intend to utilize assembler modules. Note that NASM is required if you intend to utilize assembler modules. Note that NASM
is now the only supported assembler. is now the only supported assembler.
If you are compiling from a tarball or a CVS snapshot then the Win32 files If you are compiling from a tarball or a Git snapshot then the Win32 files
may well be not up to date. This may mean that some "tweaking" is required to may well be not up to date. This may mean that some "tweaking" is required to
get it all to work. See the trouble shooting section later on for if (when?) get it all to work. See the trouble shooting section later on for if (when?)
it goes wrong. it goes wrong.
@ -257,7 +257,7 @@
then ms\do_XXX should not give a warning any more. However the numbers that then ms\do_XXX should not give a warning any more. However the numbers that
get assigned by this technique may not match those that eventually get get assigned by this technique may not match those that eventually get
assigned in the CVS tree: so anything linked against this version of the assigned in the Git tree: so anything linked against this version of the
library may need to be recompiled. library may need to be recompiled.
If you get errors about unresolved symbols there are several possible If you get errors about unresolved symbols there are several possible

View File

@ -88,6 +88,7 @@ PROCESSOR=
# CPUID module collects small commonly used assembler snippets # CPUID module collects small commonly used assembler snippets
CPUID_OBJ= CPUID_OBJ=
BN_ASM= bn_asm.o BN_ASM= bn_asm.o
EC_ASM=
DES_ENC= des_enc.o fcrypt_b.o DES_ENC= des_enc.o fcrypt_b.o
AES_ENC= aes_core.o aes_cbc.o AES_ENC= aes_core.o aes_cbc.o
BF_ENC= bf_enc.o BF_ENC= bf_enc.o
@ -198,7 +199,7 @@ CLEARENV= TOP= && unset TOP $${LIB+LIB} $${LIBS+LIBS} \
$${EXHEADER+EXHEADER} $${HEADER+HEADER} \ $${EXHEADER+EXHEADER} $${HEADER+HEADER} \
$${GENERAL+GENERAL} $${CFLAGS+CFLAGS} \ $${GENERAL+GENERAL} $${CFLAGS+CFLAGS} \
$${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS} \ $${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS} \
$${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} \ $${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} $${SCRIPTS+SCRIPTS} \
$${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS} \ $${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS} \
$${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS} $${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS}
@ -221,8 +222,8 @@ BUILDENV= PLATFORM='$(PLATFORM)' PROCESSOR='$(PROCESSOR)' \
EXE_EXT='$(EXE_EXT)' SHARED_LIBS='$(SHARED_LIBS)' \ EXE_EXT='$(EXE_EXT)' SHARED_LIBS='$(SHARED_LIBS)' \
SHLIB_EXT='$(SHLIB_EXT)' SHLIB_TARGET='$(SHLIB_TARGET)' \ SHLIB_EXT='$(SHLIB_EXT)' SHLIB_TARGET='$(SHLIB_TARGET)' \
PEX_LIBS='$(PEX_LIBS)' EX_LIBS='$(EX_LIBS)' \ PEX_LIBS='$(PEX_LIBS)' EX_LIBS='$(EX_LIBS)' \
CPUID_OBJ='$(CPUID_OBJ)' \ CPUID_OBJ='$(CPUID_OBJ)' BN_ASM='$(BN_ASM)' \
BN_ASM='$(BN_ASM)' DES_ENC='$(DES_ENC)' \ EC_ASM='$(EC_ASM)' DES_ENC='$(DES_ENC)' \
AES_ENC='$(AES_ENC)' CMLL_ENC='$(CMLL_ENC)' \ AES_ENC='$(AES_ENC)' CMLL_ENC='$(CMLL_ENC)' \
BF_ENC='$(BF_ENC)' CAST_ENC='$(CAST_ENC)' \ BF_ENC='$(BF_ENC)' CAST_ENC='$(CAST_ENC)' \
RC4_ENC='$(RC4_ENC)' RC5_ENC='$(RC5_ENC)' \ RC4_ENC='$(RC4_ENC)' RC5_ENC='$(RC5_ENC)' \
@ -302,7 +303,8 @@ libcrypto$(SHLIB_EXT): libcrypto.a fips_premain_dso$(EXE_EXT)
FIPSLD_CC="$(CC)"; CC=$(FIPSDIR)/bin/fipsld; \ FIPSLD_CC="$(CC)"; CC=$(FIPSDIR)/bin/fipsld; \
export CC FIPSLD_CC FIPSLD_LIBCRYPTO; \ export CC FIPSLD_CC FIPSLD_LIBCRYPTO; \
fi; \ fi; \
$(MAKE) -e SHLIBDIRS=crypto build-shared; \ $(MAKE) -e SHLIBDIRS=crypto CC="$${CC:-$(CC)}" build-shared && \
(touch -c fips_premain_dso$(EXE_EXT) || :); \
else \ else \
echo "There's no support for shared libraries on this platform" >&2; \ echo "There's no support for shared libraries on this platform" >&2; \
exit 1; \ exit 1; \
@ -325,7 +327,7 @@ clean-shared:
done; \ done; \
fi; \ fi; \
( set -x; rm -f lib$$i$(SHLIB_EXT) ); \ ( set -x; rm -f lib$$i$(SHLIB_EXT) ); \
if [ "$(PLATFORM)" = "Cygwin" ]; then \ if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
( set -x; rm -f cyg$$i$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \ ( set -x; rm -f cyg$$i$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \
fi; \ fi; \
done done
@ -374,11 +376,11 @@ libssl.pc: Makefile
echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \ echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
echo 'includedir=$${prefix}/include'; \ echo 'includedir=$${prefix}/include'; \
echo ''; \ echo ''; \
echo 'Name: OpenSSL'; \ echo 'Name: OpenSSL-libssl'; \
echo 'Description: Secure Sockets Layer and cryptography libraries'; \ echo 'Description: Secure Sockets Layer and cryptography libraries'; \
echo 'Version: '$(VERSION); \ echo 'Version: '$(VERSION); \
echo 'Requires: '; \ echo 'Requires.private: libcrypto'; \
echo 'Libs: -L$${libdir} -lssl -lcrypto'; \ echo 'Libs: -L$${libdir} -lssl'; \
echo 'Libs.private: $(EX_LIBS)'; \ echo 'Libs.private: $(EX_LIBS)'; \
echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > libssl.pc echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > libssl.pc
@ -391,10 +393,7 @@ openssl.pc: Makefile
echo 'Name: OpenSSL'; \ echo 'Name: OpenSSL'; \
echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \ echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
echo 'Version: '$(VERSION); \ echo 'Version: '$(VERSION); \
echo 'Requires: '; \ echo 'Requires: libssl libcrypto' ) > openssl.pc
echo 'Libs: -L$${libdir} -lssl -lcrypto'; \
echo 'Libs.private: $(EX_LIBS)'; \
echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > openssl.pc
Makefile: Makefile.org Configure config Makefile: Makefile.org Configure config
@echo "Makefile is older than Makefile.org, Configure or config." @echo "Makefile is older than Makefile.org, Configure or config."
@ -444,7 +443,7 @@ rehash.time: certs apps
[ -x "apps/openssl.exe" ] && OPENSSL="apps/openssl.exe" || :; \ [ -x "apps/openssl.exe" ] && OPENSSL="apps/openssl.exe" || :; \
OPENSSL_DEBUG_MEMORY=on; \ OPENSSL_DEBUG_MEMORY=on; \
export OPENSSL OPENSSL_DEBUG_MEMORY; \ export OPENSSL OPENSSL_DEBUG_MEMORY; \
$(PERL) tools/c_rehash certs) && \ $(PERL) tools/c_rehash certs/demo) && \
touch rehash.time; \ touch rehash.time; \
else :; fi else :; fi
@ -469,9 +468,9 @@ tags:
find . -name '[^.]*.[ch]' | xargs etags -a find . -name '[^.]*.[ch]' | xargs etags -a
errors: errors:
$(PERL) util/ck_errf.pl -strict */*.c */*/*.c
$(PERL) util/mkerr.pl -recurse -write $(PERL) util/mkerr.pl -recurse -write
(cd engines; $(MAKE) PERL=$(PERL) errors) (cd engines; $(MAKE) PERL=$(PERL) errors)
$(PERL) util/ck_errf.pl -strict */*.c */*/*.c
stacks: stacks:
$(PERL) util/mkstack.pl -write $(PERL) util/mkstack.pl -write
@ -570,11 +569,7 @@ install_sw:
do \ do \
if [ -f "$$i" -o -f "$$i.a" ]; then \ if [ -f "$$i" -o -f "$$i.a" ]; then \
( echo installing $$i; \ ( echo installing $$i; \
if [ "$(PLATFORM)" != "Cygwin" ]; then \ if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
chmod 555 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
else \
c=`echo $$i | sed 's/^lib\(.*\)\.dll\.a/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \ c=`echo $$i | sed 's/^lib\(.*\)\.dll\.a/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
cp $$c $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \ cp $$c $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \ chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
@ -582,6 +577,10 @@ install_sw:
cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \ cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \ chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \ mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
else \
cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
chmod 555 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
fi ); \ fi ); \
if expr $(PLATFORM) : 'mingw' > /dev/null; then \ if expr $(PLATFORM) : 'mingw' > /dev/null; then \
( case $$i in \ ( case $$i in \
@ -614,6 +613,10 @@ install_sw:
install_html_docs: install_html_docs:
here="`pwd`"; \ here="`pwd`"; \
filecase=; \
case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
filecase=-i; \
esac; \
for subdir in apps crypto ssl; do \ for subdir in apps crypto ssl; do \
mkdir -p $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \ mkdir -p $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
for i in doc/$$subdir/*.pod; do \ for i in doc/$$subdir/*.pod; do \
@ -642,9 +645,9 @@ install_docs:
@pod2man="`cd ./util; ./pod2mantest $(PERL)`"; \ @pod2man="`cd ./util; ./pod2mantest $(PERL)`"; \
here="`pwd`"; \ here="`pwd`"; \
filecase=; \ filecase=; \
if [ "$(PLATFORM)" = "DJGPP" -o "$(PLATFORM)" = "Cygwin" -o "$(PLATFORM)" = "mingw" ]; then \ case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
filecase=-i; \ filecase=-i; \
fi; \ esac; \
set -e; for i in doc/apps/*.pod; do \ set -e; for i in doc/apps/*.pod; do \
fn=`basename $$i .pod`; \ fn=`basename $$i .pod`; \
sec=`$(PERL) util/extract-section.pl 1 < $$i`; \ sec=`$(PERL) util/extract-section.pl 1 < $$i`; \

241
NEWS
View File

@ -5,7 +5,80 @@
This file gives a brief overview of the major changes between each OpenSSL This file gives a brief overview of the major changes between each OpenSSL
release. For more details please read the CHANGES file. release. For more details please read the CHANGES file.
Major changes between OpenSSL 1.0.0h and OpenSSL 1.0.1: Major changes between OpenSSL 1.0.1i and OpenSSL 1.0.2 [in beta]:
o Suite B support for TLS 1.2 and DTLS 1.2
o Support for DTLS 1.2
o TLS automatic EC curve selection.
o API to set TLS supported signature algorithms and curves
o SSL_CONF configuration API.
o TLS Brainpool support.
o ALPN support.
o CMS support for RSA-PSS, RSA-OAEP, ECDH and X9.42 DH.
Major changes between OpenSSL 1.0.1h and OpenSSL 1.0.1i [6 Aug 2014]
o Fix for CVE-2014-3512
o Fix for CVE-2014-3511
o Fix for CVE-2014-3510
o Fix for CVE-2014-3507
o Fix for CVE-2014-3506
o Fix for CVE-2014-3505
o Fix for CVE-2014-3509
o Fix for CVE-2014-5139
o Fix for CVE-2014-3508
Major changes between OpenSSL 1.0.1g and OpenSSL 1.0.1h [5 Jun 2014]
o Fix for CVE-2014-0224
o Fix for CVE-2014-0221
o Fix for CVE-2014-0195
o Fix for CVE-2014-3470
o Fix for CVE-2010-5298
Major changes between OpenSSL 1.0.1f and OpenSSL 1.0.1g [7 Apr 2014]
o Fix for CVE-2014-0160
o Add TLS padding extension workaround for broken servers.
o Fix for CVE-2014-0076
Major changes between OpenSSL 1.0.1e and OpenSSL 1.0.1f [6 Jan 2014]
o Don't include gmt_unix_time in TLS server and client random values
o Fix for TLS record tampering bug CVE-2013-4353
o Fix for TLS version checking bug CVE-2013-6449
o Fix for DTLS retransmission bug CVE-2013-6450
Major changes between OpenSSL 1.0.1d and OpenSSL 1.0.1e [11 Feb 2013]:
o Corrected fix for CVE-2013-0169
Major changes between OpenSSL 1.0.1c and OpenSSL 1.0.1d [4 Feb 2013]:
o Fix renegotiation in TLS 1.1, 1.2 by using the correct TLS version.
o Include the fips configuration module.
o Fix OCSP bad key DoS attack CVE-2013-0166
o Fix for SSL/TLS/DTLS CBC plaintext recovery attack CVE-2013-0169
o Fix for TLS AESNI record handling flaw CVE-2012-2686
Major changes between OpenSSL 1.0.1b and OpenSSL 1.0.1c [10 May 2012]:
o Fix TLS/DTLS record length checking bug CVE-2012-2333
o Don't attempt to use non-FIPS composite ciphers in FIPS mode.
Major changes between OpenSSL 1.0.1a and OpenSSL 1.0.1b [26 Apr 2012]:
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 [19 Apr 2012]:
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 [14 Mar 2012]:
o TLS/DTLS heartbeat support. o TLS/DTLS heartbeat support.
o SCTP support. o SCTP support.
@ -18,17 +91,30 @@
o Preliminary FIPS capability for unvalidated 2.0 FIPS module. o Preliminary FIPS capability for unvalidated 2.0 FIPS module.
o SRP support. o SRP support.
Major changes between OpenSSL 1.0.0g and OpenSSL 1.0.0h: Major changes between OpenSSL 1.0.0j and OpenSSL 1.0.0k [5 Feb 2013]:
o Fix for SSL/TLS/DTLS CBC plaintext recovery attack CVE-2013-0169
o Fix OCSP bad key DoS attack CVE-2013-0166
Major changes between OpenSSL 1.0.0i and OpenSSL 1.0.0j [10 May 2012]:
o Fix DTLS record length checking bug CVE-2012-2333
Major changes between OpenSSL 1.0.0h and OpenSSL 1.0.0i [19 Apr 2012]:
o Fix for ASN1 overflow bug CVE-2012-2110
Major changes between OpenSSL 1.0.0g and OpenSSL 1.0.0h [12 Mar 2012]:
o Fix for CMS/PKCS#7 MMA CVE-2012-0884 o Fix for CMS/PKCS#7 MMA CVE-2012-0884
o Corrected fix for CVE-2011-4619 o Corrected fix for CVE-2011-4619
o Various DTLS fixes. o Various DTLS fixes.
Major changes between OpenSSL 1.0.0f and OpenSSL 1.0.0g: Major changes between OpenSSL 1.0.0f and OpenSSL 1.0.0g [18 Jan 2012]:
o Fix for DTLS DoS issue CVE-2012-0050 o Fix for DTLS DoS issue CVE-2012-0050
Major changes between OpenSSL 1.0.0e and OpenSSL 1.0.0f: Major changes between OpenSSL 1.0.0e and OpenSSL 1.0.0f [4 Jan 2012]:
o Fix for DTLS plaintext recovery attack CVE-2011-4108 o Fix for DTLS plaintext recovery attack CVE-2011-4108
o Clear block padding bytes of SSL 3.0 records CVE-2011-4576 o Clear block padding bytes of SSL 3.0 records CVE-2011-4576
@ -36,7 +122,7 @@
o Check parameters are not NULL in GOST ENGINE CVE-2012-0027 o Check parameters are not NULL in GOST ENGINE CVE-2012-0027
o Check for malformed RFC3779 data CVE-2011-4577 o Check for malformed RFC3779 data CVE-2011-4577
Major changes between OpenSSL 1.0.0d and OpenSSL 1.0.0e: Major changes between OpenSSL 1.0.0d and OpenSSL 1.0.0e [6 Sep 2011]:
o Fix for CRL vulnerability issue CVE-2011-3207 o Fix for CRL vulnerability issue CVE-2011-3207
o Fix for ECDH crashes CVE-2011-3210 o Fix for ECDH crashes CVE-2011-3210
@ -44,11 +130,11 @@
o Support ECDH ciphersuites for certificates using SHA2 algorithms. o Support ECDH ciphersuites for certificates using SHA2 algorithms.
o Various DTLS fixes. o Various DTLS fixes.
Major changes between OpenSSL 1.0.0c and OpenSSL 1.0.0d: Major changes between OpenSSL 1.0.0c and OpenSSL 1.0.0d [8 Feb 2011]:
o Fix for security issue CVE-2011-0014 o Fix for security issue CVE-2011-0014
Major changes between OpenSSL 1.0.0b and OpenSSL 1.0.0c: Major changes between OpenSSL 1.0.0b and OpenSSL 1.0.0c [2 Dec 2010]:
o Fix for security issue CVE-2010-4180 o Fix for security issue CVE-2010-4180
o Fix for CVE-2010-4252 o Fix for CVE-2010-4252
@ -56,18 +142,18 @@
o Fix various platform compilation issues. o Fix various platform compilation issues.
o Corrected fix for security issue CVE-2010-3864. o Corrected fix for security issue CVE-2010-3864.
Major changes between OpenSSL 1.0.0a and OpenSSL 1.0.0b: Major changes between OpenSSL 1.0.0a and OpenSSL 1.0.0b [16 Nov 2010]:
o Fix for security issue CVE-2010-3864. o Fix for security issue CVE-2010-3864.
o Fix for CVE-2010-2939 o Fix for CVE-2010-2939
o Fix WIN32 build system for GOST ENGINE. o Fix WIN32 build system for GOST ENGINE.
Major changes between OpenSSL 1.0.0 and OpenSSL 1.0.0a: Major changes between OpenSSL 1.0.0 and OpenSSL 1.0.0a [1 Jun 2010]:
o Fix for security issue CVE-2010-1633. o Fix for security issue CVE-2010-1633.
o GOST MAC and CFB fixes. o GOST MAC and CFB fixes.
Major changes between OpenSSL 0.9.8n and OpenSSL 1.0.0: Major changes between OpenSSL 0.9.8n and OpenSSL 1.0.0 [29 Mar 2010]:
o RFC3280 path validation: sufficient to process PKITS tests. o RFC3280 path validation: sufficient to process PKITS tests.
o Integrated support for PVK files and keyblobs. o Integrated support for PVK files and keyblobs.
@ -90,20 +176,55 @@
o Opaque PRF Input TLS extension support. o Opaque PRF Input TLS extension support.
o Updated time routines to avoid OS limitations. o Updated time routines to avoid OS limitations.
Major changes between OpenSSL 0.9.8q and OpenSSL 0.9.8r: Major changes between OpenSSL 0.9.8x and OpenSSL 0.9.8y [5 Feb 2013]:
o Fix for SSL/TLS/DTLS CBC plaintext recovery attack CVE-2013-0169
o Fix OCSP bad key DoS attack CVE-2013-0166
Major changes between OpenSSL 0.9.8w and OpenSSL 0.9.8x [10 May 2012]:
o Fix DTLS record length checking bug CVE-2012-2333
Major changes between OpenSSL 0.9.8v and OpenSSL 0.9.8w [23 Apr 2012]:
o Fix for CVE-2012-2131 (corrected fix for 0.9.8 and CVE-2012-2110)
Major changes between OpenSSL 0.9.8u and OpenSSL 0.9.8v [19 Apr 2012]:
o Fix for ASN1 overflow bug CVE-2012-2110
Major changes between OpenSSL 0.9.8t and OpenSSL 0.9.8u [12 Mar 2012]:
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 0.9.8s and OpenSSL 0.9.8t [18 Jan 2012]:
o Fix for DTLS DoS issue CVE-2012-0050
Major changes between OpenSSL 0.9.8r and OpenSSL 0.9.8s [4 Jan 2012]:
o Fix for DTLS plaintext recovery attack CVE-2011-4108
o Fix policy check double free error CVE-2011-4109
o Clear block padding bytes of SSL 3.0 records CVE-2011-4576
o Only allow one SGC handshake restart for SSL/TLS CVE-2011-4619
o Check for malformed RFC3779 data CVE-2011-4577
Major changes between OpenSSL 0.9.8q and OpenSSL 0.9.8r [8 Feb 2011]:
o Fix for security issue CVE-2011-0014 o Fix for security issue CVE-2011-0014
Major changes between OpenSSL 0.9.8p and OpenSSL 0.9.8q: Major changes between OpenSSL 0.9.8p and OpenSSL 0.9.8q [2 Dec 2010]:
o Fix for security issue CVE-2010-4180 o Fix for security issue CVE-2010-4180
o Fix for CVE-2010-4252 o Fix for CVE-2010-4252
Major changes between OpenSSL 0.9.8o and OpenSSL 0.9.8p: Major changes between OpenSSL 0.9.8o and OpenSSL 0.9.8p [16 Nov 2010]:
o Fix for security issue CVE-2010-3864. o Fix for security issue CVE-2010-3864.
Major changes between OpenSSL 0.9.8n and OpenSSL 0.9.8o: Major changes between OpenSSL 0.9.8n and OpenSSL 0.9.8o [1 Jun 2010]:
o Fix for security issue CVE-2010-0742. o Fix for security issue CVE-2010-0742.
o Various DTLS fixes. o Various DTLS fixes.
@ -111,12 +232,12 @@
o Fix for no-rc4 compilation. o Fix for no-rc4 compilation.
o Chil ENGINE unload workaround. o Chil ENGINE unload workaround.
Major changes between OpenSSL 0.9.8m and OpenSSL 0.9.8n: Major changes between OpenSSL 0.9.8m and OpenSSL 0.9.8n [24 Mar 2010]:
o CFB cipher definition fixes. o CFB cipher definition fixes.
o Fix security issues CVE-2010-0740 and CVE-2010-0433. o Fix security issues CVE-2010-0740 and CVE-2010-0433.
Major changes between OpenSSL 0.9.8l and OpenSSL 0.9.8m: Major changes between OpenSSL 0.9.8l and OpenSSL 0.9.8m [25 Feb 2010]:
o Cipher definition fixes. o Cipher definition fixes.
o Workaround for slow RAND_poll() on some WIN32 versions. o Workaround for slow RAND_poll() on some WIN32 versions.
@ -128,33 +249,33 @@
o Ticket and SNI coexistence fixes. o Ticket and SNI coexistence fixes.
o Many fixes to DTLS handling. o Many fixes to DTLS handling.
Major changes between OpenSSL 0.9.8k and OpenSSL 0.9.8l: Major changes between OpenSSL 0.9.8k and OpenSSL 0.9.8l [5 Nov 2009]:
o Temporary work around for CVE-2009-3555: disable renegotiation. o Temporary work around for CVE-2009-3555: disable renegotiation.
Major changes between OpenSSL 0.9.8j and OpenSSL 0.9.8k: Major changes between OpenSSL 0.9.8j and OpenSSL 0.9.8k [25 Mar 2009]:
o Fix various build issues. o Fix various build issues.
o Fix security issues (CVE-2009-0590, CVE-2009-0591, CVE-2009-0789) o Fix security issues (CVE-2009-0590, CVE-2009-0591, CVE-2009-0789)
Major changes between OpenSSL 0.9.8i and OpenSSL 0.9.8j: Major changes between OpenSSL 0.9.8i and OpenSSL 0.9.8j [7 Jan 2009]:
o Fix security issue (CVE-2008-5077) o Fix security issue (CVE-2008-5077)
o Merge FIPS 140-2 branch code. o Merge FIPS 140-2 branch code.
Major changes between OpenSSL 0.9.8g and OpenSSL 0.9.8h: Major changes between OpenSSL 0.9.8g and OpenSSL 0.9.8h [28 May 2008]:
o CryptoAPI ENGINE support. o CryptoAPI ENGINE support.
o Various precautionary measures. o Various precautionary measures.
o Fix for bugs affecting certificate request creation. o Fix for bugs affecting certificate request creation.
o Support for local machine keyset attribute in PKCS#12 files. o Support for local machine keyset attribute in PKCS#12 files.
Major changes between OpenSSL 0.9.8f and OpenSSL 0.9.8g: Major changes between OpenSSL 0.9.8f and OpenSSL 0.9.8g [19 Oct 2007]:
o Backport of CMS functionality to 0.9.8. o Backport of CMS functionality to 0.9.8.
o Fixes for bugs introduced with 0.9.8f. o Fixes for bugs introduced with 0.9.8f.
Major changes between OpenSSL 0.9.8e and OpenSSL 0.9.8f: Major changes between OpenSSL 0.9.8e and OpenSSL 0.9.8f [11 Oct 2007]:
o Add gcc 4.2 support. o Add gcc 4.2 support.
o Add support for AES and SSE2 assembly lanugauge optimization o Add support for AES and SSE2 assembly lanugauge optimization
@ -165,23 +286,23 @@
o RFC4507bis support. o RFC4507bis support.
o TLS Extensions support. o TLS Extensions support.
Major changes between OpenSSL 0.9.8d and OpenSSL 0.9.8e: Major changes between OpenSSL 0.9.8d and OpenSSL 0.9.8e [23 Feb 2007]:
o Various ciphersuite selection fixes. o Various ciphersuite selection fixes.
o RFC3779 support. o RFC3779 support.
Major changes between OpenSSL 0.9.8c and OpenSSL 0.9.8d: Major changes between OpenSSL 0.9.8c and OpenSSL 0.9.8d [28 Sep 2006]:
o Introduce limits to prevent malicious key DoS (CVE-2006-2940) o Introduce limits to prevent malicious key DoS (CVE-2006-2940)
o Fix security issues (CVE-2006-2937, CVE-2006-3737, CVE-2006-4343) o Fix security issues (CVE-2006-2937, CVE-2006-3737, CVE-2006-4343)
o Changes to ciphersuite selection algorithm o Changes to ciphersuite selection algorithm
Major changes between OpenSSL 0.9.8b and OpenSSL 0.9.8c: Major changes between OpenSSL 0.9.8b and OpenSSL 0.9.8c [5 Sep 2006]:
o Fix Daniel Bleichenbacher forged signature attack, CVE-2006-4339 o Fix Daniel Bleichenbacher forged signature attack, CVE-2006-4339
o New cipher Camellia o New cipher Camellia
Major changes between OpenSSL 0.9.8a and OpenSSL 0.9.8b: Major changes between OpenSSL 0.9.8a and OpenSSL 0.9.8b [4 May 2006]:
o Cipher string fixes. o Cipher string fixes.
o Fixes for VC++ 2005. o Fixes for VC++ 2005.
@ -191,12 +312,12 @@
o Built in dynamic engine compilation support on Win32. o Built in dynamic engine compilation support on Win32.
o Fixes auto dynamic engine loading in Win32. o Fixes auto dynamic engine loading in Win32.
Major changes between OpenSSL 0.9.8 and OpenSSL 0.9.8a: Major changes between OpenSSL 0.9.8 and OpenSSL 0.9.8a [11 Oct 2005]:
o Fix potential SSL 2.0 rollback, CVE-2005-2969 o Fix potential SSL 2.0 rollback, CVE-2005-2969
o Extended Windows CE support o Extended Windows CE support
Major changes between OpenSSL 0.9.7g and OpenSSL 0.9.8: Major changes between OpenSSL 0.9.7g and OpenSSL 0.9.8 [5 Jul 2005]:
o Major work on the BIGNUM library for higher efficiency and to o Major work on the BIGNUM library for higher efficiency and to
make operations more streamlined and less contradictory. This make operations more streamlined and less contradictory. This
@ -270,36 +391,36 @@
o Added initial support for Win64. o Added initial support for Win64.
o Added alternate pkg-config files. o Added alternate pkg-config files.
Major changes between OpenSSL 0.9.7l and OpenSSL 0.9.7m: Major changes between OpenSSL 0.9.7l and OpenSSL 0.9.7m [23 Feb 2007]:
o FIPS 1.1.1 module linking. o FIPS 1.1.1 module linking.
o Various ciphersuite selection fixes. o Various ciphersuite selection fixes.
Major changes between OpenSSL 0.9.7k and OpenSSL 0.9.7l: Major changes between OpenSSL 0.9.7k and OpenSSL 0.9.7l [28 Sep 2006]:
o Introduce limits to prevent malicious key DoS (CVE-2006-2940) o Introduce limits to prevent malicious key DoS (CVE-2006-2940)
o Fix security issues (CVE-2006-2937, CVE-2006-3737, CVE-2006-4343) o Fix security issues (CVE-2006-2937, CVE-2006-3737, CVE-2006-4343)
Major changes between OpenSSL 0.9.7j and OpenSSL 0.9.7k: Major changes between OpenSSL 0.9.7j and OpenSSL 0.9.7k [5 Sep 2006]:
o Fix Daniel Bleichenbacher forged signature attack, CVE-2006-4339 o Fix Daniel Bleichenbacher forged signature attack, CVE-2006-4339
Major changes between OpenSSL 0.9.7i and OpenSSL 0.9.7j: Major changes between OpenSSL 0.9.7i and OpenSSL 0.9.7j [4 May 2006]:
o Visual C++ 2005 fixes. o Visual C++ 2005 fixes.
o Update Windows build system for FIPS. o Update Windows build system for FIPS.
Major changes between OpenSSL 0.9.7h and OpenSSL 0.9.7i: Major changes between OpenSSL 0.9.7h and OpenSSL 0.9.7i [14 Oct 2005]:
o Give EVP_MAX_MD_SIZE it's old value, except for a FIPS build. o Give EVP_MAX_MD_SIZE it's old value, except for a FIPS build.
Major changes between OpenSSL 0.9.7g and OpenSSL 0.9.7h: Major changes between OpenSSL 0.9.7g and OpenSSL 0.9.7h [11 Oct 2005]:
o Fix SSL 2.0 Rollback, CVE-2005-2969 o Fix SSL 2.0 Rollback, CVE-2005-2969
o Allow use of fixed-length exponent on DSA signing o Allow use of fixed-length exponent on DSA signing
o Default fixed-window RSA, DSA, DH private-key operations o Default fixed-window RSA, DSA, DH private-key operations
Major changes between OpenSSL 0.9.7f and OpenSSL 0.9.7g: Major changes between OpenSSL 0.9.7f and OpenSSL 0.9.7g [11 Apr 2005]:
o More compilation issues fixed. o More compilation issues fixed.
o Adaptation to more modern Kerberos API. o Adaptation to more modern Kerberos API.
@ -308,7 +429,7 @@
o More constification. o More constification.
o Added processing of proxy certificates (RFC 3820). o Added processing of proxy certificates (RFC 3820).
Major changes between OpenSSL 0.9.7e and OpenSSL 0.9.7f: Major changes between OpenSSL 0.9.7e and OpenSSL 0.9.7f [22 Mar 2005]:
o Several compilation issues fixed. o Several compilation issues fixed.
o Many memory allocation failure checks added. o Many memory allocation failure checks added.
@ -316,12 +437,12 @@
o Mandatory basic checks on certificates. o Mandatory basic checks on certificates.
o Performance improvements. o Performance improvements.
Major changes between OpenSSL 0.9.7d and OpenSSL 0.9.7e: Major changes between OpenSSL 0.9.7d and OpenSSL 0.9.7e [25 Oct 2004]:
o Fix race condition in CRL checking code. o Fix race condition in CRL checking code.
o Fixes to PKCS#7 (S/MIME) code. o Fixes to PKCS#7 (S/MIME) code.
Major changes between OpenSSL 0.9.7c and OpenSSL 0.9.7d: Major changes between OpenSSL 0.9.7c and OpenSSL 0.9.7d [17 Mar 2004]:
o Security: Fix Kerberos ciphersuite SSL/TLS handshaking bug o Security: Fix Kerberos ciphersuite SSL/TLS handshaking bug
o Security: Fix null-pointer assignment in do_change_cipher_spec() o Security: Fix null-pointer assignment in do_change_cipher_spec()
@ -329,14 +450,14 @@
o Multiple X509 verification fixes o Multiple X509 verification fixes
o Speed up HMAC and other operations o Speed up HMAC and other operations
Major changes between OpenSSL 0.9.7b and OpenSSL 0.9.7c: Major changes between OpenSSL 0.9.7b and OpenSSL 0.9.7c [30 Sep 2003]:
o Security: fix various ASN1 parsing bugs. o Security: fix various ASN1 parsing bugs.
o New -ignore_err option to OCSP utility. o New -ignore_err option to OCSP utility.
o Various interop and bug fixes in S/MIME code. o Various interop and bug fixes in S/MIME code.
o SSL/TLS protocol fix for unrequested client certificates. o SSL/TLS protocol fix for unrequested client certificates.
Major changes between OpenSSL 0.9.7a and OpenSSL 0.9.7b: Major changes between OpenSSL 0.9.7a and OpenSSL 0.9.7b [10 Apr 2003]:
o Security: counter the Klima-Pokorny-Rosa extension of o Security: counter the Klima-Pokorny-Rosa extension of
Bleichbacher's attack Bleichbacher's attack
@ -347,7 +468,7 @@
o ASN.1: treat domainComponent correctly. o ASN.1: treat domainComponent correctly.
o Documentation: fixes and additions. o Documentation: fixes and additions.
Major changes between OpenSSL 0.9.7 and OpenSSL 0.9.7a: Major changes between OpenSSL 0.9.7 and OpenSSL 0.9.7a [19 Feb 2003]:
o Security: Important security related bugfixes. o Security: Important security related bugfixes.
o Enhanced compatibility with MIT Kerberos. o Enhanced compatibility with MIT Kerberos.
@ -358,7 +479,7 @@
o SSL/TLS: now handles manual certificate chain building. o SSL/TLS: now handles manual certificate chain building.
o SSL/TLS: certain session ID malfunctions corrected. o SSL/TLS: certain session ID malfunctions corrected.
Major changes between OpenSSL 0.9.6 and OpenSSL 0.9.7: Major changes between OpenSSL 0.9.6 and OpenSSL 0.9.7 [30 Dec 2002]:
o New library section OCSP. o New library section OCSP.
o Complete rewrite of ASN1 code. o Complete rewrite of ASN1 code.
@ -404,23 +525,23 @@
o SSL/TLS: add callback to retrieve SSL/TLS messages. o SSL/TLS: add callback to retrieve SSL/TLS messages.
o SSL/TLS: support AES cipher suites (RFC3268). o SSL/TLS: support AES cipher suites (RFC3268).
Major changes between OpenSSL 0.9.6j and OpenSSL 0.9.6k: Major changes between OpenSSL 0.9.6j and OpenSSL 0.9.6k [30 Sep 2003]:
o Security: fix various ASN1 parsing bugs. o Security: fix various ASN1 parsing bugs.
o SSL/TLS protocol fix for unrequested client certificates. o SSL/TLS protocol fix for unrequested client certificates.
Major changes between OpenSSL 0.9.6i and OpenSSL 0.9.6j: Major changes between OpenSSL 0.9.6i and OpenSSL 0.9.6j [10 Apr 2003]:
o Security: counter the Klima-Pokorny-Rosa extension of o Security: counter the Klima-Pokorny-Rosa extension of
Bleichbacher's attack Bleichbacher's attack
o Security: make RSA blinding default. o Security: make RSA blinding default.
o Build: shared library support fixes. o Build: shared library support fixes.
Major changes between OpenSSL 0.9.6h and OpenSSL 0.9.6i: Major changes between OpenSSL 0.9.6h and OpenSSL 0.9.6i [19 Feb 2003]:
o Important security related bugfixes. o Important security related bugfixes.
Major changes between OpenSSL 0.9.6g and OpenSSL 0.9.6h: Major changes between OpenSSL 0.9.6g and OpenSSL 0.9.6h [5 Dec 2002]:
o New configuration targets for Tandem OSS and A/UX. o New configuration targets for Tandem OSS and A/UX.
o New OIDs for Microsoft attributes. o New OIDs for Microsoft attributes.
@ -434,25 +555,25 @@
o Fixes for smaller building problems. o Fixes for smaller building problems.
o Updates of manuals, FAQ and other instructive documents. o Updates of manuals, FAQ and other instructive documents.
Major changes between OpenSSL 0.9.6f and OpenSSL 0.9.6g: Major changes between OpenSSL 0.9.6f and OpenSSL 0.9.6g [9 Aug 2002]:
o Important building fixes on Unix. o Important building fixes on Unix.
Major changes between OpenSSL 0.9.6e and OpenSSL 0.9.6f: Major changes between OpenSSL 0.9.6e and OpenSSL 0.9.6f [8 Aug 2002]:
o Various important bugfixes. o Various important bugfixes.
Major changes between OpenSSL 0.9.6d and OpenSSL 0.9.6e: Major changes between OpenSSL 0.9.6d and OpenSSL 0.9.6e [30 Jul 2002]:
o Important security related bugfixes. o Important security related bugfixes.
o Various SSL/TLS library bugfixes. o Various SSL/TLS library bugfixes.
Major changes between OpenSSL 0.9.6c and OpenSSL 0.9.6d: Major changes between OpenSSL 0.9.6c and OpenSSL 0.9.6d [9 May 2002]:
o Various SSL/TLS library bugfixes. o Various SSL/TLS library bugfixes.
o Fix DH parameter generation for 'non-standard' generators. o Fix DH parameter generation for 'non-standard' generators.
Major changes between OpenSSL 0.9.6b and OpenSSL 0.9.6c: Major changes between OpenSSL 0.9.6b and OpenSSL 0.9.6c [21 Dec 2001]:
o Various SSL/TLS library bugfixes. o Various SSL/TLS library bugfixes.
o BIGNUM library fixes. o BIGNUM library fixes.
@ -465,7 +586,7 @@
Broadcom and Cryptographic Appliance's keyserver Broadcom and Cryptographic Appliance's keyserver
[in 0.9.6c-engine release]. [in 0.9.6c-engine release].
Major changes between OpenSSL 0.9.6a and OpenSSL 0.9.6b: Major changes between OpenSSL 0.9.6a and OpenSSL 0.9.6b [9 Jul 2001]:
o Security fix: PRNG improvements. o Security fix: PRNG improvements.
o Security fix: RSA OAEP check. o Security fix: RSA OAEP check.
@ -482,7 +603,7 @@
o Increase default size for BIO buffering filter. o Increase default size for BIO buffering filter.
o Compatibility fixes in some scripts. o Compatibility fixes in some scripts.
Major changes between OpenSSL 0.9.6 and OpenSSL 0.9.6a: Major changes between OpenSSL 0.9.6 and OpenSSL 0.9.6a [5 Apr 2001]:
o Security fix: change behavior of OpenSSL to avoid using o Security fix: change behavior of OpenSSL to avoid using
environment variables when running as root. environment variables when running as root.
@ -507,7 +628,7 @@
o New function BN_rand_range(). o New function BN_rand_range().
o Add "-rand" option to openssl s_client and s_server. o Add "-rand" option to openssl s_client and s_server.
Major changes between OpenSSL 0.9.5a and OpenSSL 0.9.6: Major changes between OpenSSL 0.9.5a and OpenSSL 0.9.6 [10 Oct 2000]:
o Some documentation for BIO and SSL libraries. o Some documentation for BIO and SSL libraries.
o Enhanced chain verification using key identifiers. o Enhanced chain verification using key identifiers.
@ -522,7 +643,7 @@
[1] The support for external crypto devices is currently a separate [1] The support for external crypto devices is currently a separate
distribution. See the file README.ENGINE. distribution. See the file README.ENGINE.
Major changes between OpenSSL 0.9.5 and OpenSSL 0.9.5a: Major changes between OpenSSL 0.9.5 and OpenSSL 0.9.5a [1 Apr 2000]:
o Bug fixes for Win32, SuSE Linux, NeXTSTEP and FreeBSD 2.2.8 o Bug fixes for Win32, SuSE Linux, NeXTSTEP and FreeBSD 2.2.8
o Shared library support for HPUX and Solaris-gcc o Shared library support for HPUX and Solaris-gcc
@ -531,7 +652,7 @@
o New 'rand' application o New 'rand' application
o New way to check for existence of algorithms from scripts o New way to check for existence of algorithms from scripts
Major changes between OpenSSL 0.9.4 and OpenSSL 0.9.5: Major changes between OpenSSL 0.9.4 and OpenSSL 0.9.5 [25 May 2000]:
o S/MIME support in new 'smime' command o S/MIME support in new 'smime' command
o Documentation for the OpenSSL command line application o Documentation for the OpenSSL command line application
@ -567,7 +688,7 @@
o Enhanced support for Alpha Linux o Enhanced support for Alpha Linux
o Experimental MacOS support o Experimental MacOS support
Major changes between OpenSSL 0.9.3 and OpenSSL 0.9.4: Major changes between OpenSSL 0.9.3 and OpenSSL 0.9.4 [9 Aug 1999]:
o Transparent support for PKCS#8 format private keys: these are used o Transparent support for PKCS#8 format private keys: these are used
by several software packages and are more secure than the standard by several software packages and are more secure than the standard
@ -578,7 +699,7 @@
o New pipe-like BIO that allows using the SSL library when actual I/O o New pipe-like BIO that allows using the SSL library when actual I/O
must be handled by the application (BIO pair) must be handled by the application (BIO pair)
Major changes between OpenSSL 0.9.2b and OpenSSL 0.9.3: Major changes between OpenSSL 0.9.2b and OpenSSL 0.9.3 [24 May 1999]:
o Lots of enhancements and cleanups to the Configuration mechanism o Lots of enhancements and cleanups to the Configuration mechanism
o RSA OEAP related fixes o RSA OEAP related fixes
o Added `openssl ca -revoke' option for revoking a certificate o Added `openssl ca -revoke' option for revoking a certificate
@ -592,7 +713,7 @@
o Sparc assembler bignum implementation, optimized hash functions o Sparc assembler bignum implementation, optimized hash functions
o Option to disable selected ciphers o Option to disable selected ciphers
Major changes between OpenSSL 0.9.1c and OpenSSL 0.9.2b: Major changes between OpenSSL 0.9.1c and OpenSSL 0.9.2b [22 Mar 1999]:
o Fixed a security hole related to session resumption o Fixed a security hole related to session resumption
o Fixed RSA encryption routines for the p < q case o Fixed RSA encryption routines for the p < q case
o "ALL" in cipher lists now means "everything except NULL ciphers" o "ALL" in cipher lists now means "everything except NULL ciphers"
@ -614,7 +735,7 @@
o Lots of memory leak fixes. o Lots of memory leak fixes.
o Lots of bug fixes. o Lots of bug fixes.
Major changes between SSLeay 0.9.0b and OpenSSL 0.9.1c: Major changes between SSLeay 0.9.0b and OpenSSL 0.9.1c [23 Dec 1998]:
o Integration of the popular NO_RSA/NO_DSA patches o Integration of the popular NO_RSA/NO_DSA patches
o Initial support for compression inside the SSL record layer o Initial support for compression inside the SSL record layer
o Added BIO proxy and filtering functionality o Added BIO proxy and filtering functionality

View File

@ -197,3 +197,17 @@ reconfigure with additional no-sse2 [or 386] option passed to ./config.
We don't have framework to associate -ldl with no-dso, therefore the only We don't have framework to associate -ldl with no-dso, therefore the only
way is to edit Makefile right after ./config no-dso and remove -ldl from way is to edit Makefile right after ./config no-dso and remove -ldl from
EX_LIBS line. EX_LIBS line.
* hpux-parisc2-cc no-asm build fails with SEGV in ECDSA/DH.
Compiler bug, presumably at particular patch level. Remaining
hpux*-parisc*-cc configurations can be affected too. Drop optimization
level to +O2 when compiling bn_nist.o.
* solaris64-sparcv9-cc link failure
Solaris 8 ar can fail to maintain symbol table in .a, which results in
link failures. Apply 109147-09 or later or modify Makefile generated
by ./Configure solaris64-sparcv9-cc and replace RANLIB assignment with
RANLIB= /usr/ccs/bin/ar rs

42
README
View File

@ -1,5 +1,5 @@
OpenSSL 1.0.1 14 Mar 2012 OpenSSL 1.0.2-beta3 25 Sep 2014
Copyright (c) 1998-2011 The OpenSSL Project Copyright (c) 1998-2011 The OpenSSL Project
Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
@ -90,32 +90,6 @@
SSL/TLS Client and Server Tests SSL/TLS Client and Server Tests
Handling of S/MIME signed or encrypted mail Handling of S/MIME signed or encrypted mail
PATENTS
-------
Various companies hold various patents for various algorithms in various
locations around the world. _YOU_ are responsible for ensuring that your use
of any algorithms is legal by checking if there are any patents in your
country. The file contains some of the patents that we know about or are
rumored to exist. This is not a definitive list.
RSA Security holds software patents on the RC5 algorithm. If you
intend to use this cipher, you must contact RSA Security for
licensing conditions. Their web page is http://www.rsasecurity.com/.
RC4 is a trademark of RSA Security, so use of this label should perhaps
only be used with RSA Security's permission.
The IDEA algorithm is patented by Ascom in Austria, France, Germany, Italy,
Japan, the Netherlands, Spain, Sweden, Switzerland, UK and the USA. They
should be contacted if that algorithm is to be used; their web page is
http://www.ascom.ch/.
NTT and Mitsubishi have patents and pending patents on the Camellia
algorithm, but allow use at no charge without requiring an explicit
licensing agreement: http://info.isl.ntt.co.jp/crypt/eng/info/chiteki.html
INSTALLATION INSTALLATION
------------ ------------
@ -161,8 +135,7 @@
- Problem Description (steps that will reproduce the problem, if known) - Problem Description (steps that will reproduce the problem, if known)
- Stack Traceback (if the application dumps core) - Stack Traceback (if the application dumps core)
Report the bug to the OpenSSL project via the Request Tracker Email the report to:
(http://www.openssl.org/support/rt.html) by mail to:
openssl-bugs@openssl.org openssl-bugs@openssl.org
@ -170,10 +143,11 @@
or support queries. Just because something doesn't work the way you expect or support queries. Just because something doesn't work the way you expect
does not mean it is necessarily a bug in OpenSSL. does not mean it is necessarily a bug in OpenSSL.
Note that mail to openssl-bugs@openssl.org is recorded in the publicly Note that mail to openssl-bugs@openssl.org is recorded in the public
readable request tracker database and is forwarded to a public request tracker database (see https://www.openssl.org/support/rt.html
mailing list. Confidential mail may be sent to openssl-security@openssl.org for details) and also forwarded to a public mailing list. Confidential
(PGP key available from the key servers). mail may be sent to openssl-security@openssl.org (PGP key available from
the key servers).
HOW TO CONTRIBUTE TO OpenSSL HOW TO CONTRIBUTE TO OpenSSL
---------------------------- ----------------------------
@ -190,7 +164,7 @@
reason as to why that feature isn't implemented. reason as to why that feature isn't implemented.
Patches should be as up to date as possible, preferably relative to the Patches should be as up to date as possible, preferably relative to the
current CVS or the last snapshot. They should follow the coding style of current Git or the last snapshot. They should follow the coding style of
OpenSSL and compile without warnings. Some of the core team developer targets OpenSSL and compile without warnings. Some of the core team developer targets
can be used for testing purposes, (debug-steve64, debug-geoff etc). OpenSSL can be used for testing purposes, (debug-steve64, debug-geoff etc). OpenSSL
compiles on many varied platforms: try to ensure you only use portable compiles on many varied platforms: try to ensure you only use portable

155
STATUS
View File

@ -1,155 +0,0 @@
OpenSSL STATUS Last modified at
______________ $Date: 2012/03/14 12:14:06 $
DEVELOPMENT STATE
o OpenSSL 1.1.0: Under development...
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
o OpenSSL 0.9.8o: Released on June 1st, 2010
o OpenSSL 0.9.8n: Released on March 24th, 2010
o OpenSSL 0.9.8m: Released on February 25th, 2010
o OpenSSL 0.9.8l: Released on November 5th, 2009
o OpenSSL 0.9.8k: Released on March 25th, 2009
o OpenSSL 0.9.8j: Released on January 7th, 2009
o OpenSSL 0.9.8i: Released on September 15th, 2008
o OpenSSL 0.9.8h: Released on May 28th, 2008
o OpenSSL 0.9.8g: Released on October 19th, 2007
o OpenSSL 0.9.8f: Released on October 11th, 2007
o OpenSSL 0.9.8e: Released on February 23rd, 2007
o OpenSSL 0.9.8d: Released on September 28th, 2006
o OpenSSL 0.9.8c: Released on September 5th, 2006
o OpenSSL 0.9.8b: Released on May 4th, 2006
o OpenSSL 0.9.8a: Released on October 11th, 2005
o OpenSSL 0.9.8: Released on July 5th, 2005
o OpenSSL 0.9.7m: Released on February 23rd, 2007
o OpenSSL 0.9.7l: Released on September 28th, 2006
o OpenSSL 0.9.7k: Released on September 5th, 2006
o OpenSSL 0.9.7j: Released on May 4th, 2006
o OpenSSL 0.9.7i: Released on October 14th, 2005
o OpenSSL 0.9.7h: Released on October 11th, 2005
o OpenSSL 0.9.7g: Released on April 11th, 2005
o OpenSSL 0.9.7f: Released on March 22nd, 2005
o OpenSSL 0.9.7e: Released on October 25th, 2004
o OpenSSL 0.9.7d: Released on March 17th, 2004
o OpenSSL 0.9.7c: Released on September 30th, 2003
o OpenSSL 0.9.7b: Released on April 10th, 2003
o OpenSSL 0.9.7a: Released on February 19th, 2003
o OpenSSL 0.9.7: Released on December 31st, 2002
o OpenSSL 0.9.6m: Released on March 17th, 2004
o OpenSSL 0.9.6l: Released on November 4th, 2003
o OpenSSL 0.9.6k: Released on September 30th, 2003
o OpenSSL 0.9.6j: Released on April 10th, 2003
o OpenSSL 0.9.6i: Released on February 19th, 2003
o OpenSSL 0.9.6h: Released on December 5th, 2002
o OpenSSL 0.9.6g: Released on August 9th, 2002
o OpenSSL 0.9.6f: Released on August 8th, 2002
o OpenSSL 0.9.6e: Released on July 30th, 2002
o OpenSSL 0.9.6d: Released on May 9th, 2002
o OpenSSL 0.9.6c: Released on December 21st, 2001
o OpenSSL 0.9.6b: Released on July 9th, 2001
o OpenSSL 0.9.6a: Released on April 5th, 2001
o OpenSSL 0.9.6: Released on September 24th, 2000
o OpenSSL 0.9.5a: Released on April 1st, 2000
o OpenSSL 0.9.5: Released on February 28th, 2000
o OpenSSL 0.9.4: Released on August 09th, 1999
o OpenSSL 0.9.3a: Released on May 29th, 1999
o OpenSSL 0.9.3: Released on May 25th, 1999
o OpenSSL 0.9.2b: Released on March 22th, 1999
o OpenSSL 0.9.1c: Released on December 23th, 1998
[See also http://www.openssl.org/support/rt.html]
RELEASE SHOWSTOPPERS
o The Makefiles fail with some SysV makes.
o
AVAILABLE PATCHES
o
IN PROGRESS
o Steve is currently working on (in no particular order):
ASN1 code redesign, butchery, replacement.
OCSP
EVP cipher enhancement.
Enhanced certificate chain verification.
Private key, certificate and CRL API and implementation.
Developing and bugfixing PKCS#7 (S/MIME code).
Various X509 issues: character sets, certificate request extensions.
o Richard is currently working on:
Constification
Attribute Certificate support
Certificate Pair support
Storage Engines (primarly an LDAP storage engine)
Certificate chain validation with full RFC 3280 compatibility
NEEDS PATCH
o 0.9.8-dev: COMPLEMENTOFALL and COMPLEMENTOFDEFAULT do not
handle ECCdraft cipher suites correctly.
o apps/ca.c: "Sign the certificate?" - "n" creates empty certificate file
o "OpenSSL STATUS" is never up-to-date.
OPEN ISSUES
o The Makefile hierarchy and build mechanism is still not a round thing:
1. The config vs. Configure scripts
It's the same nasty situation as for Apache with APACI vs.
src/Configure. It confuses.
Suggestion: Merge Configure and config into a single configure
script with a Autoconf style interface ;-) and remove
Configure and config. Or even let us use GNU Autoconf
itself. Then we can avoid a lot of those platform checks
which are currently in Configure.
o Support for Shared Libraries has to be added at least
for the major Unix platforms. The details we can rip from the stuff
Ralf has done for the Apache src/Configure script. Ben wants the
solution to be really simple.
Status: Ralf will look how we can easily incorporate the
compiler PIC and linker DSO flags from Apache
into the OpenSSL Configure script.
Ulf: +1 for using GNU autoconf and libtool (but not automake,
which apparently is not flexible enough to generate
libcrypto)
WISHES
o Add variants of DH_generate_parameters() and BN_generate_prime() [etc?]
where the callback function can request that the function be aborted.
[Gregory Stark <ghstark@pobox.com>, <rayyang2000@yahoo.com>]
o SRP in TLS.
[wished by:
Dj <derek@yo.net>, Tom Wu <tom@arcot.com>,
Tom Holroyd <tomh@po.crl.go.jp>]
See http://search.ietf.org/internet-drafts/draft-ietf-tls-srp-00.txt
as well as http://www-cs-students.stanford.edu/~tjw/srp/.
Tom Holroyd tells us there is a SRP patch for OpenSSH at
http://members.tripod.com/professor_tom/archives/, that could
be useful.

958
TABLE

File diff suppressed because it is too large Load Diff

View File

@ -577,14 +577,15 @@ openssl.o: ../include/openssl/objects.h ../include/openssl/ocsp.h
openssl.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h openssl.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
openssl.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h openssl.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
openssl.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h openssl.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
openssl.o: ../include/openssl/pqueue.h ../include/openssl/safestack.h openssl.o: ../include/openssl/pqueue.h ../include/openssl/rand.h
openssl.o: ../include/openssl/sha.h ../include/openssl/srtp.h openssl.o: ../include/openssl/safestack.h ../include/openssl/sha.h
openssl.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h openssl.o: ../include/openssl/srtp.h ../include/openssl/ssl.h
openssl.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h openssl.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
openssl.o: ../include/openssl/stack.h ../include/openssl/symhacks.h openssl.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
openssl.o: ../include/openssl/tls1.h ../include/openssl/txt_db.h openssl.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
openssl.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h openssl.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
openssl.o: ../include/openssl/x509v3.h apps.h openssl.c progs.h s_apps.h openssl.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h
openssl.o: openssl.c progs.h s_apps.h
passwd.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h passwd.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
passwd.o: ../include/openssl/buffer.h ../include/openssl/conf.h passwd.o: ../include/openssl/buffer.h ../include/openssl/conf.h
passwd.o: ../include/openssl/crypto.h ../include/openssl/des.h passwd.o: ../include/openssl/crypto.h ../include/openssl/des.h

View File

@ -118,7 +118,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if !defined(OPENSSL_SYSNAME_WIN32) && !defined(NETWARE_CLIB) #if !defined(OPENSSL_SYSNAME_WIN32) && !defined(OPENSSL_SYSNAME_WINCE) && !defined(NETWARE_CLIB)
#include <strings.h> #include <strings.h>
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -275,6 +275,8 @@ int str2fmt(char *s)
return(FORMAT_PKCS12); return(FORMAT_PKCS12);
else if ((*s == 'E') || (*s == 'e')) else if ((*s == 'E') || (*s == 'e'))
return(FORMAT_ENGINE); return(FORMAT_ENGINE);
else if ((*s == 'H') || (*s == 'h'))
return FORMAT_HTTP;
else if ((*s == 'P') || (*s == 'p')) else if ((*s == 'P') || (*s == 'p'))
{ {
if (s[1] == 'V' || s[1] == 'v') if (s[1] == 'V' || s[1] == 'v')
@ -390,6 +392,8 @@ int chopup_args(ARGS *arg, char *buf, int *argc, char **argv[])
{ {
arg->count=20; arg->count=20;
arg->data=(char **)OPENSSL_malloc(sizeof(char *)*arg->count); arg->data=(char **)OPENSSL_malloc(sizeof(char *)*arg->count);
if (arg->data == NULL)
return 0;
} }
for (i=0; i<arg->count; i++) for (i=0; i<arg->count; i++)
arg->data[i]=NULL; arg->data[i]=NULL;
@ -586,12 +590,12 @@ int password_callback(char *buf, int bufsiz, int verify,
if (ok >= 0) if (ok >= 0)
ok = UI_add_input_string(ui,prompt,ui_flags,buf, ok = UI_add_input_string(ui,prompt,ui_flags,buf,
PW_MIN_LENGTH,BUFSIZ-1); PW_MIN_LENGTH,bufsiz-1);
if (ok >= 0 && verify) if (ok >= 0 && verify)
{ {
buff = (char *)OPENSSL_malloc(bufsiz); buff = (char *)OPENSSL_malloc(bufsiz);
ok = UI_add_verify_string(ui,prompt,ui_flags,buff, ok = UI_add_verify_string(ui,prompt,ui_flags,buff,
PW_MIN_LENGTH,BUFSIZ-1, buf); PW_MIN_LENGTH,bufsiz-1, buf);
} }
if (ok >= 0) if (ok >= 0)
do do
@ -783,12 +787,80 @@ static int load_pkcs12(BIO *err, BIO *in, const char *desc,
return ret; return ret;
} }
int load_cert_crl_http(const char *url, BIO *err,
X509 **pcert, X509_CRL **pcrl)
{
char *host = NULL, *port = NULL, *path = NULL;
BIO *bio = NULL;
OCSP_REQ_CTX *rctx = NULL;
int use_ssl, rv = 0;
if (!OCSP_parse_url(url, &host, &port, &path, &use_ssl))
goto err;
if (use_ssl)
{
if (err)
BIO_puts(err, "https not supported\n");
goto err;
}
bio = BIO_new_connect(host);
if (!bio || !BIO_set_conn_port(bio, port))
goto err;
rctx = OCSP_REQ_CTX_new(bio, 1024);
if (!rctx)
goto err;
if (!OCSP_REQ_CTX_http(rctx, "GET", path))
goto err;
if (!OCSP_REQ_CTX_add1_header(rctx, "Host", host))
goto err;
if (pcert)
{
do
{
rv = X509_http_nbio(rctx, pcert);
}
while (rv == -1);
}
else
{
do
{
rv = X509_CRL_http_nbio(rctx, pcrl);
} while (rv == -1);
}
err:
if (host)
OPENSSL_free(host);
if (path)
OPENSSL_free(path);
if (port)
OPENSSL_free(port);
if (bio)
BIO_free_all(bio);
if (rctx)
OCSP_REQ_CTX_free(rctx);
if (rv != 1)
{
if (bio && err)
BIO_printf(bio_err, "Error loading %s from %s\n",
pcert ? "certificate" : "CRL", url);
ERR_print_errors(bio_err);
}
return rv;
}
X509 *load_cert(BIO *err, const char *file, int format, X509 *load_cert(BIO *err, const char *file, int format,
const char *pass, ENGINE *e, const char *cert_descrip) const char *pass, ENGINE *e, const char *cert_descrip)
{ {
X509 *x=NULL; X509 *x=NULL;
BIO *cert; BIO *cert;
if (format == FORMAT_HTTP)
{
load_cert_crl_http(file, err, &x, NULL);
return x;
}
if ((cert=BIO_new(BIO_s_file())) == NULL) if ((cert=BIO_new(BIO_s_file())) == NULL)
{ {
ERR_print_errors(err); ERR_print_errors(err);
@ -859,6 +931,55 @@ end:
return(x); return(x);
} }
X509_CRL *load_crl(const char *infile, int format)
{
X509_CRL *x=NULL;
BIO *in=NULL;
if (format == FORMAT_HTTP)
{
load_cert_crl_http(infile, bio_err, NULL, &x);
return x;
}
in=BIO_new(BIO_s_file());
if (in == NULL)
{
ERR_print_errors(bio_err);
goto end;
}
if (infile == NULL)
BIO_set_fp(in,stdin,BIO_NOCLOSE);
else
{
if (BIO_read_filename(in,infile) <= 0)
{
perror(infile);
goto end;
}
}
if (format == FORMAT_ASN1)
x=d2i_X509_CRL_bio(in,NULL);
else if (format == FORMAT_PEM)
x=PEM_read_bio_X509_CRL(in,NULL,NULL,NULL);
else {
BIO_printf(bio_err,"bad input format specified for input crl\n");
goto end;
}
if (x == NULL)
{
BIO_printf(bio_err,"unable to load CRL\n");
ERR_print_errors(bio_err);
goto end;
}
end:
BIO_free(in);
return(x);
}
EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin, EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin,
const char *pass, ENGINE *e, const char *key_descrip) const char *pass, ENGINE *e, const char *key_descrip)
{ {
@ -1542,6 +1663,8 @@ char *make_config_name()
len=strlen(t)+strlen(OPENSSL_CONF)+2; len=strlen(t)+strlen(OPENSSL_CONF)+2;
p=OPENSSL_malloc(len); p=OPENSSL_malloc(len);
if (p == NULL)
return NULL;
BUF_strlcpy(p,t,len); BUF_strlcpy(p,t,len);
#ifndef OPENSSL_SYS_VMS #ifndef OPENSSL_SYS_VMS
BUF_strlcat(p,"/",len); BUF_strlcat(p,"/",len);
@ -2132,7 +2255,7 @@ X509_NAME *parse_name(char *subject, long chtype, int multirdn)
X509_NAME *n = NULL; X509_NAME *n = NULL;
int nid; int nid;
if (!buf || !ne_types || !ne_values) if (!buf || !ne_types || !ne_values || !mval)
{ {
BIO_printf(bio_err, "malloc error\n"); BIO_printf(bio_err, "malloc error\n");
goto error; goto error;
@ -2236,6 +2359,7 @@ X509_NAME *parse_name(char *subject, long chtype, int multirdn)
OPENSSL_free(ne_values); OPENSSL_free(ne_values);
OPENSSL_free(ne_types); OPENSSL_free(ne_types);
OPENSSL_free(buf); OPENSSL_free(buf);
OPENSSL_free(mval);
return n; return n;
error: error:
@ -2244,6 +2368,8 @@ error:
OPENSSL_free(ne_values); OPENSSL_free(ne_values);
if (ne_types) if (ne_types)
OPENSSL_free(ne_types); OPENSSL_free(ne_types);
if (mval)
OPENSSL_free(mval);
if (buf) if (buf)
OPENSSL_free(buf); OPENSSL_free(buf);
return NULL; return NULL;
@ -2259,6 +2385,9 @@ int args_verify(char ***pargs, int *pargc,
char **oldargs = *pargs; char **oldargs = *pargs;
char *arg = **pargs, *argn = (*pargs)[1]; char *arg = **pargs, *argn = (*pargs)[1];
time_t at_time = 0; time_t at_time = 0;
char *hostname = NULL;
char *email = NULL;
char *ipasc = NULL;
if (!strcmp(arg, "-policy")) if (!strcmp(arg, "-policy"))
{ {
if (!argn) if (!argn)
@ -2332,6 +2461,27 @@ int args_verify(char ***pargs, int *pargc,
} }
(*pargs)++; (*pargs)++;
} }
else if (strcmp(arg,"-verify_hostname") == 0)
{
if (!argn)
*badarg = 1;
hostname = argn;
(*pargs)++;
}
else if (strcmp(arg,"-verify_email") == 0)
{
if (!argn)
*badarg = 1;
email = argn;
(*pargs)++;
}
else if (strcmp(arg,"-verify_ip") == 0)
{
if (!argn)
*badarg = 1;
ipasc = argn;
(*pargs)++;
}
else if (!strcmp(arg, "-ignore_critical")) else if (!strcmp(arg, "-ignore_critical"))
flags |= X509_V_FLAG_IGNORE_CRITICAL; flags |= X509_V_FLAG_IGNORE_CRITICAL;
else if (!strcmp(arg, "-issuer_checks")) else if (!strcmp(arg, "-issuer_checks"))
@ -2358,6 +2508,16 @@ int args_verify(char ***pargs, int *pargc,
flags |= X509_V_FLAG_NOTIFY_POLICY; flags |= X509_V_FLAG_NOTIFY_POLICY;
else if (!strcmp(arg, "-check_ss_sig")) else if (!strcmp(arg, "-check_ss_sig"))
flags |= X509_V_FLAG_CHECK_SS_SIGNATURE; flags |= X509_V_FLAG_CHECK_SS_SIGNATURE;
else if (!strcmp(arg, "-trusted_first"))
flags |= X509_V_FLAG_TRUSTED_FIRST;
else if (!strcmp(arg, "-suiteB_128_only"))
flags |= X509_V_FLAG_SUITEB_128_LOS_ONLY;
else if (!strcmp(arg, "-suiteB_128"))
flags |= X509_V_FLAG_SUITEB_128_LOS;
else if (!strcmp(arg, "-suiteB_192"))
flags |= X509_V_FLAG_SUITEB_192_LOS;
else if (!strcmp(arg, "-partial_chain"))
flags |= X509_V_FLAG_PARTIAL_CHAIN;
else else
return 0; return 0;
@ -2389,6 +2549,15 @@ int args_verify(char ***pargs, int *pargc,
if (at_time) if (at_time)
X509_VERIFY_PARAM_set_time(*pm, at_time); X509_VERIFY_PARAM_set_time(*pm, at_time);
if (hostname && !X509_VERIFY_PARAM_set1_host(*pm, hostname, 0))
*badarg = 1;
if (email && !X509_VERIFY_PARAM_set1_email(*pm, email, 0))
*badarg = 1;
if (ipasc && !X509_VERIFY_PARAM_set1_ip_asc(*pm, ipasc))
*badarg = 1;
end: end:
(*pargs)++; (*pargs)++;
@ -2681,6 +2850,9 @@ void jpake_client_auth(BIO *out, BIO *conn, const char *secret)
BIO_puts(out, "JPAKE authentication succeeded, setting PSK\n"); BIO_puts(out, "JPAKE authentication succeeded, setting PSK\n");
if (psk_key)
OPENSSL_free(psk_key);
psk_key = BN_bn2hex(JPAKE_get_shared_key(ctx)); psk_key = BN_bn2hex(JPAKE_get_shared_key(ctx));
BIO_pop(bconn); BIO_pop(bconn);
@ -2710,6 +2882,9 @@ void jpake_server_auth(BIO *out, BIO *conn, const char *secret)
BIO_puts(out, "JPAKE authentication succeeded, setting PSK\n"); BIO_puts(out, "JPAKE authentication succeeded, setting PSK\n");
if (psk_key)
OPENSSL_free(psk_key);
psk_key = BN_bn2hex(JPAKE_get_shared_key(ctx)); psk_key = BN_bn2hex(JPAKE_get_shared_key(ctx));
BIO_pop(bconn); BIO_pop(bconn);
@ -2720,7 +2895,7 @@ void jpake_server_auth(BIO *out, BIO *conn, const char *secret)
#endif #endif
#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) #ifndef OPENSSL_NO_TLSEXT
/* next_protos_parse parses a comma separated list of strings into a string /* next_protos_parse parses a comma separated list of strings into a string
* in a format suitable for passing to SSL_CTX_set_next_protos_advertised. * in a format suitable for passing to SSL_CTX_set_next_protos_advertised.
* outlen: (output) set to the length of the resulting buffer on success. * outlen: (output) set to the length of the resulting buffer on success.
@ -2762,7 +2937,114 @@ unsigned char *next_protos_parse(unsigned short *outlen, const char *in)
*outlen = len + 1; *outlen = len + 1;
return out; return out;
} }
#endif /* !OPENSSL_NO_TLSEXT && !OPENSSL_NO_NEXTPROTONEG */ #endif /* ndef OPENSSL_NO_TLSEXT */
void print_cert_checks(BIO *bio, X509 *x,
const char *checkhost,
const char *checkemail,
const char *checkip)
{
if (x == NULL)
return;
if (checkhost)
{
BIO_printf(bio, "Hostname %s does%s match certificate\n",
checkhost,
X509_check_host(x, checkhost, 0, 0, NULL)
? "" : " NOT");
}
if (checkemail)
{
BIO_printf(bio, "Email %s does%s match certificate\n",
checkemail, X509_check_email(x, checkemail, 0,
0) ? "" : " NOT");
}
if (checkip)
{
BIO_printf(bio, "IP %s does%s match certificate\n",
checkip, X509_check_ip_asc(x, checkip,
0) ? "" : " NOT");
}
}
/* Get first http URL from a DIST_POINT structure */
static const char *get_dp_url(DIST_POINT *dp)
{
GENERAL_NAMES *gens;
GENERAL_NAME *gen;
int i, gtype;
ASN1_STRING *uri;
if (!dp->distpoint || dp->distpoint->type != 0)
return NULL;
gens = dp->distpoint->name.fullname;
for (i = 0; i < sk_GENERAL_NAME_num(gens); i++)
{
gen = sk_GENERAL_NAME_value(gens, i);
uri = GENERAL_NAME_get0_value(gen, &gtype);
if (gtype == GEN_URI && ASN1_STRING_length(uri) > 6)
{
char *uptr = (char *)ASN1_STRING_data(uri);
if (!strncmp(uptr, "http://", 7))
return uptr;
}
}
return NULL;
}
/* Look through a CRLDP structure and attempt to find an http URL to downloads
* a CRL from.
*/
static X509_CRL *load_crl_crldp(STACK_OF(DIST_POINT) *crldp)
{
int i;
const char *urlptr = NULL;
for (i = 0; i < sk_DIST_POINT_num(crldp); i++)
{
DIST_POINT *dp = sk_DIST_POINT_value(crldp, i);
urlptr = get_dp_url(dp);
if (urlptr)
return load_crl(urlptr, FORMAT_HTTP);
}
return NULL;
}
/* Example of downloading CRLs from CRLDP: not usable for real world
* as it always downloads, doesn't support non-blocking I/O and doesn't
* cache anything.
*/
static STACK_OF(X509_CRL) *crls_http_cb(X509_STORE_CTX *ctx, X509_NAME *nm)
{
X509 *x;
STACK_OF(X509_CRL) *crls = NULL;
X509_CRL *crl;
STACK_OF(DIST_POINT) *crldp;
x = X509_STORE_CTX_get_current_cert(ctx);
crldp = X509_get_ext_d2i(x, NID_crl_distribution_points, NULL, NULL);
crl = load_crl_crldp(crldp);
sk_DIST_POINT_pop_free(crldp, DIST_POINT_free);
if (!crl)
return NULL;
crls = sk_X509_CRL_new_null();
sk_X509_CRL_push(crls, crl);
/* Try to download delta CRL */
crldp = X509_get_ext_d2i(x, NID_freshest_crl, NULL, NULL);
crl = load_crl_crldp(crldp);
sk_DIST_POINT_pop_free(crldp, DIST_POINT_free);
if (crl)
sk_X509_CRL_push(crls, crl);
return crls;
}
void store_setup_crl_download(X509_STORE *st)
{
X509_STORE_set_lookup_crls_cb(st, crls_http_cb);
}
/* /*
* Platform-specific sections * Platform-specific sections
@ -2838,7 +3120,7 @@ double app_tminterval(int stop,int usertime)
if (proc==NULL) if (proc==NULL)
{ {
if (GetVersion() < 0x80000000) if (check_winnt())
proc = OpenProcess(PROCESS_QUERY_INFORMATION,FALSE, proc = OpenProcess(PROCESS_QUERY_INFORMATION,FALSE,
GetCurrentProcessId()); GetCurrentProcessId());
if (proc==NULL) proc = (HANDLE)-1; if (proc==NULL) proc = (HANDLE)-1;

View File

@ -188,6 +188,7 @@ extern BIO *bio_err;
do { CONF_modules_unload(1); destroy_ui_method(); \ do { CONF_modules_unload(1); destroy_ui_method(); \
OBJ_cleanup(); EVP_cleanup(); ENGINE_cleanup(); \ OBJ_cleanup(); EVP_cleanup(); ENGINE_cleanup(); \
CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); \ CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); \
RAND_cleanup(); \
ERR_free_strings(); zlib_cleanup();} while(0) ERR_free_strings(); zlib_cleanup();} while(0)
# else # else
# define apps_startup() \ # define apps_startup() \
@ -198,11 +199,12 @@ extern BIO *bio_err;
do { CONF_modules_unload(1); destroy_ui_method(); \ do { CONF_modules_unload(1); destroy_ui_method(); \
OBJ_cleanup(); EVP_cleanup(); \ OBJ_cleanup(); EVP_cleanup(); \
CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); \ CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); \
RAND_cleanup(); \
ERR_free_strings(); zlib_cleanup(); } while(0) ERR_free_strings(); zlib_cleanup(); } while(0)
# endif # endif
#endif #endif
#ifdef OPENSSL_SYSNAME_WIN32 #if defined(OPENSSL_SYSNAME_WIN32) || defined(OPENSSL_SYSNAME_WINCE)
# define openssl_fdset(a,b) FD_SET((unsigned int)a, b) # define openssl_fdset(a,b) FD_SET((unsigned int)a, b)
#else #else
# define openssl_fdset(a,b) FD_SET(a, b) # define openssl_fdset(a,b) FD_SET(a, b)
@ -245,6 +247,9 @@ int app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2);
int add_oid_section(BIO *err, CONF *conf); int add_oid_section(BIO *err, CONF *conf);
X509 *load_cert(BIO *err, const char *file, int format, X509 *load_cert(BIO *err, const char *file, int format,
const char *pass, ENGINE *e, const char *cert_descrip); const char *pass, ENGINE *e, const char *cert_descrip);
X509_CRL *load_crl(const char *infile, int format);
int load_cert_crl_http(const char *url, BIO *err,
X509 **pcert, X509_CRL **pcrl);
EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin, EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin,
const char *pass, ENGINE *e, const char *key_descrip); const char *pass, ENGINE *e, const char *key_descrip);
EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, int maybe_stdin, EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, int maybe_stdin,
@ -260,8 +265,9 @@ ENGINE *setup_engine(BIO *err, const char *engine, int debug);
#ifndef OPENSSL_NO_OCSP #ifndef OPENSSL_NO_OCSP
OCSP_RESPONSE *process_responder(BIO *err, OCSP_REQUEST *req, OCSP_RESPONSE *process_responder(BIO *err, OCSP_REQUEST *req,
char *host, char *path, char *port, int use_ssl, const char *host, const char *path,
STACK_OF(CONF_VALUE) *headers, const char *port, int use_ssl,
const STACK_OF(CONF_VALUE) *headers,
int req_timeout); int req_timeout);
#endif #endif
@ -331,9 +337,16 @@ void jpake_client_auth(BIO *out, BIO *conn, const char *secret);
void jpake_server_auth(BIO *out, BIO *conn, const char *secret); void jpake_server_auth(BIO *out, BIO *conn, const char *secret);
#endif #endif
#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) #ifndef OPENSSL_NO_TLSEXT
unsigned char *next_protos_parse(unsigned short *outlen, const char *in); unsigned char *next_protos_parse(unsigned short *outlen, const char *in);
#endif /* !OPENSSL_NO_TLSEXT && !OPENSSL_NO_NEXTPROTONEG */ #endif /* ndef OPENSSL_NO_TLSEXT */
void print_cert_checks(BIO *bio, X509 *x,
const char *checkhost,
const char *checkemail,
const char *checkip);
void store_setup_crl_download(X509_STORE *st);
#define FORMAT_UNDEF 0 #define FORMAT_UNDEF 0
#define FORMAT_ASN1 1 #define FORMAT_ASN1 1
@ -349,6 +362,7 @@ unsigned char *next_protos_parse(unsigned short *outlen, const char *in);
#define FORMAT_ASN1RSA 10 /* DER RSAPubicKey format */ #define FORMAT_ASN1RSA 10 /* DER RSAPubicKey format */
#define FORMAT_MSBLOB 11 /* MS Key blob format */ #define FORMAT_MSBLOB 11 /* MS Key blob format */
#define FORMAT_PVK 12 /* MS PVK file format */ #define FORMAT_PVK 12 /* MS PVK file format */
#define FORMAT_HTTP 13 /* Download using HTTP */
#define EXT_COPY_NONE 0 #define EXT_COPY_NONE 0
#define EXT_COPY_ADD 1 #define EXT_COPY_ADD 1

View File

@ -501,6 +501,12 @@ EF_ALIGNMENT=0;
infile= *(++argv); infile= *(++argv);
dorevoke=1; dorevoke=1;
} }
else if (strcmp(*argv,"-valid") == 0)
{
if (--argc < 1) goto bad;
infile= *(++argv);
dorevoke=2;
}
else if (strcmp(*argv,"-extensions") == 0) else if (strcmp(*argv,"-extensions") == 0)
{ {
if (--argc < 1) goto bad; if (--argc < 1) goto bad;
@ -1408,6 +1414,7 @@ bad:
if (!NCONF_get_number(conf,section, if (!NCONF_get_number(conf,section,
ENV_DEFAULT_CRL_HOURS, &crlhours)) ENV_DEFAULT_CRL_HOURS, &crlhours))
crlhours = 0; crlhours = 0;
ERR_clear_error();
} }
if ((crldays == 0) && (crlhours == 0) && (crlsec == 0)) if ((crldays == 0) && (crlhours == 0) && (crlsec == 0))
{ {
@ -1522,6 +1529,8 @@ bad:
NULL, e, infile); NULL, e, infile);
if (revcert == NULL) if (revcert == NULL)
goto err; goto err;
if (dorevoke == 2)
rev_type = -1;
j=do_revoke(revcert,db, rev_type, rev_arg); j=do_revoke(revcert,db, rev_type, rev_arg);
if (j <= 0) goto err; if (j <= 0) goto err;
X509_free(revcert); X509_free(revcert);
@ -1619,12 +1628,14 @@ static int certify(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
{ {
ok=0; ok=0;
BIO_printf(bio_err,"Signature verification problems....\n"); BIO_printf(bio_err,"Signature verification problems....\n");
ERR_print_errors(bio_err);
goto err; goto err;
} }
if (i == 0) if (i == 0)
{ {
ok=0; ok=0;
BIO_printf(bio_err,"Signature did not match the certificate request\n"); BIO_printf(bio_err,"Signature did not match the certificate request\n");
ERR_print_errors(bio_err);
goto err; goto err;
} }
else else
@ -2043,7 +2054,13 @@ again2:
if (enddate == NULL) if (enddate == NULL)
X509_time_adj_ex(X509_get_notAfter(ret),days, 0, NULL); X509_time_adj_ex(X509_get_notAfter(ret),days, 0, NULL);
else ASN1_TIME_set_string(X509_get_notAfter(ret),enddate); else
{
int tdays;
ASN1_TIME_set_string(X509_get_notAfter(ret),enddate);
ASN1_TIME_diff(&tdays, NULL, NULL, X509_get_notAfter(ret));
days = tdays;
}
if (!X509_set_subject_name(ret,subject)) goto err; if (!X509_set_subject_name(ret,subject)) goto err;
@ -2485,6 +2502,9 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
} }
/* Revoke Certificate */ /* Revoke Certificate */
if (type == -1)
ok = 1;
else
ok = do_revoke(x509,db, type, value); ok = do_revoke(x509,db, type, value);
goto err; goto err;
@ -2496,6 +2516,12 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
row[DB_name]); row[DB_name]);
goto err; goto err;
} }
else if (type == -1)
{
BIO_printf(bio_err,"ERROR:Already present, serial number %s\n",
row[DB_serial]);
goto err;
}
else if (rrow[DB_type][0]=='R') else if (rrow[DB_type][0]=='R')
{ {
BIO_printf(bio_err,"ERROR:Already revoked, serial number %s\n", BIO_printf(bio_err,"ERROR:Already revoked, serial number %s\n",
@ -2776,6 +2802,9 @@ char *make_revocation_str(int rev_type, char *rev_arg)
revtm = X509_gmtime_adj(NULL, 0); revtm = X509_gmtime_adj(NULL, 0);
if (!revtm)
return NULL;
i = revtm->length + 1; i = revtm->length + 1;
if (reason) i += strlen(reason) + 1; if (reason) i += strlen(reason) + 1;

View File

@ -85,6 +85,9 @@ int MAIN(int argc, char **argv)
{ {
int ret=1,i; int ret=1,i;
int verbose=0,Verbose=0; int verbose=0,Verbose=0;
#ifndef OPENSSL_NO_SSL_TRACE
int stdname = 0;
#endif
const char **pp; const char **pp;
const char *p; const char *p;
int badops=0; int badops=0;
@ -96,13 +99,7 @@ int MAIN(int argc, char **argv)
char buf[512]; char buf[512];
BIO *STDout=NULL; BIO *STDout=NULL;
#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
meth=SSLv23_server_method(); meth=SSLv23_server_method();
#elif !defined(OPENSSL_NO_SSL3)
meth=SSLv3_server_method();
#elif !defined(OPENSSL_NO_SSL2)
meth=SSLv2_server_method();
#endif
apps_startup(); apps_startup();
@ -126,6 +123,10 @@ int MAIN(int argc, char **argv)
verbose=1; verbose=1;
else if (strcmp(*argv,"-V") == 0) else if (strcmp(*argv,"-V") == 0)
verbose=Verbose=1; verbose=Verbose=1;
#ifndef OPENSSL_NO_SSL_TRACE
else if (strcmp(*argv,"-stdname") == 0)
stdname=verbose=1;
#endif
#ifndef OPENSSL_NO_SSL2 #ifndef OPENSSL_NO_SSL2
else if (strcmp(*argv,"-ssl2") == 0) else if (strcmp(*argv,"-ssl2") == 0)
meth=SSLv2_client_method(); meth=SSLv2_client_method();
@ -209,7 +210,15 @@ int MAIN(int argc, char **argv)
else else
BIO_printf(STDout, "0x%02X,0x%02X,0x%02X,0x%02X - ", id0, id1, id2, id3); /* whatever */ BIO_printf(STDout, "0x%02X,0x%02X,0x%02X,0x%02X - ", id0, id1, id2, id3); /* whatever */
} }
#ifndef OPENSSL_NO_SSL_TRACE
if (stdname)
{
const char *nm = SSL_CIPHER_standard_name(c);
if (nm == NULL)
nm = "UNKNOWN";
BIO_printf(STDout, "%s - ", nm);
}
#endif
BIO_puts(STDout,SSL_CIPHER_description(c,buf,sizeof buf)); BIO_puts(STDout,SSL_CIPHER_description(c,buf,sizeof buf));
} }
} }

View File

@ -74,6 +74,8 @@ static void receipt_request_print(BIO *out, CMS_ContentInfo *cms);
static CMS_ReceiptRequest *make_receipt_request(STACK_OF(OPENSSL_STRING) *rr_to, static CMS_ReceiptRequest *make_receipt_request(STACK_OF(OPENSSL_STRING) *rr_to,
int rr_allorfirst, int rr_allorfirst,
STACK_OF(OPENSSL_STRING) *rr_from); STACK_OF(OPENSSL_STRING) *rr_from);
static int cms_set_pkey_param(EVP_PKEY_CTX *pctx,
STACK_OF(OPENSSL_STRING) *param);
#define SMIME_OP 0x10 #define SMIME_OP 0x10
#define SMIME_IP 0x20 #define SMIME_IP 0x20
@ -97,6 +99,15 @@ static CMS_ReceiptRequest *make_receipt_request(STACK_OF(OPENSSL_STRING) *rr_to,
int verify_err = 0; int verify_err = 0;
typedef struct cms_key_param_st cms_key_param;
struct cms_key_param_st
{
int idx;
STACK_OF(OPENSSL_STRING)*param;
cms_key_param *next;
};
int MAIN(int, char **); int MAIN(int, char **);
int MAIN(int argc, char **argv) int MAIN(int argc, char **argv)
@ -111,7 +122,7 @@ int MAIN(int argc, char **argv)
STACK_OF(OPENSSL_STRING) *sksigners = NULL, *skkeys = NULL; STACK_OF(OPENSSL_STRING) *sksigners = NULL, *skkeys = NULL;
char *certfile = NULL, *keyfile = NULL, *contfile=NULL; char *certfile = NULL, *keyfile = NULL, *contfile=NULL;
char *certsoutfile = NULL; char *certsoutfile = NULL;
const EVP_CIPHER *cipher = NULL; const EVP_CIPHER *cipher = NULL, *wrap_cipher = NULL;
CMS_ContentInfo *cms = NULL, *rcms = NULL; CMS_ContentInfo *cms = NULL, *rcms = NULL;
X509_STORE *store = NULL; X509_STORE *store = NULL;
X509 *cert = NULL, *recip = NULL, *signer = NULL; X509 *cert = NULL, *recip = NULL, *signer = NULL;
@ -139,6 +150,8 @@ int MAIN(int argc, char **argv)
unsigned char *pwri_pass = NULL, *pwri_tmp = NULL; unsigned char *pwri_pass = NULL, *pwri_tmp = NULL;
size_t secret_keylen = 0, secret_keyidlen = 0; size_t secret_keylen = 0, secret_keyidlen = 0;
cms_key_param *key_first = NULL, *key_param = NULL;
ASN1_OBJECT *econtent_type = NULL; ASN1_OBJECT *econtent_type = NULL;
X509_VERIFY_PARAM *vpm = NULL; X509_VERIFY_PARAM *vpm = NULL;
@ -204,6 +217,8 @@ int MAIN(int argc, char **argv)
cipher = EVP_des_ede3_cbc(); cipher = EVP_des_ede3_cbc();
else if (!strcmp (*args, "-des")) else if (!strcmp (*args, "-des"))
cipher = EVP_des_cbc(); cipher = EVP_des_cbc();
else if (!strcmp (*args, "-des3-wrap"))
wrap_cipher = EVP_des_ede3_wrap();
#endif #endif
#ifndef OPENSSL_NO_SEED #ifndef OPENSSL_NO_SEED
else if (!strcmp (*args, "-seed")) else if (!strcmp (*args, "-seed"))
@ -224,6 +239,12 @@ int MAIN(int argc, char **argv)
cipher = EVP_aes_192_cbc(); cipher = EVP_aes_192_cbc();
else if (!strcmp(*args,"-aes256")) else if (!strcmp(*args,"-aes256"))
cipher = EVP_aes_256_cbc(); cipher = EVP_aes_256_cbc();
else if (!strcmp(*args,"-aes128-wrap"))
wrap_cipher = EVP_aes_128_wrap();
else if (!strcmp(*args,"-aes192-wrap"))
wrap_cipher = EVP_aes_192_wrap();
else if (!strcmp(*args,"-aes256-wrap"))
wrap_cipher = EVP_aes_256_wrap();
#endif #endif
#ifndef OPENSSL_NO_CAMELLIA #ifndef OPENSSL_NO_CAMELLIA
else if (!strcmp(*args,"-camellia128")) else if (!strcmp(*args,"-camellia128"))
@ -233,6 +254,8 @@ int MAIN(int argc, char **argv)
else if (!strcmp(*args,"-camellia256")) else if (!strcmp(*args,"-camellia256"))
cipher = EVP_camellia_256_cbc(); cipher = EVP_camellia_256_cbc();
#endif #endif
else if (!strcmp (*args, "-debug_decrypt"))
flags |= CMS_DEBUG_DECRYPT;
else if (!strcmp (*args, "-text")) else if (!strcmp (*args, "-text"))
flags |= CMS_TEXT; flags |= CMS_TEXT;
else if (!strcmp (*args, "-nointern")) else if (!strcmp (*args, "-nointern"))
@ -410,6 +433,19 @@ int MAIN(int argc, char **argv)
{ {
if (!args[1]) if (!args[1])
goto argerr; goto argerr;
if (operation == SMIME_ENCRYPT)
{
if (!encerts)
encerts = sk_X509_new_null();
cert = load_cert(bio_err,*++args,FORMAT_PEM,
NULL, e,
"recipient certificate file");
if (!cert)
goto end;
sk_X509_push(encerts, cert);
cert = NULL;
}
else
recipfile = *++args; recipfile = *++args;
} }
else if (!strcmp (*args, "-certsout")) else if (!strcmp (*args, "-certsout"))
@ -458,6 +494,43 @@ int MAIN(int argc, char **argv)
goto argerr; goto argerr;
keyform = str2fmt(*++args); keyform = str2fmt(*++args);
} }
else if (!strcmp (*args, "-keyopt"))
{
int keyidx = -1;
if (!args[1])
goto argerr;
if (operation == SMIME_ENCRYPT)
{
if (encerts)
keyidx += sk_X509_num(encerts);
}
else
{
if (keyfile || signerfile)
keyidx++;
if (skkeys)
keyidx += sk_OPENSSL_STRING_num(skkeys);
}
if (keyidx < 0)
{
BIO_printf(bio_err, "No key specified\n");
goto argerr;
}
if (key_param == NULL || key_param->idx != keyidx)
{
cms_key_param *nparam;
nparam = OPENSSL_malloc(sizeof(cms_key_param));
nparam->idx = keyidx;
nparam->param = sk_OPENSSL_STRING_new_null();
nparam->next = NULL;
if (key_first == NULL)
key_first = nparam;
else
key_param->next = nparam;
key_param = nparam;
}
sk_OPENSSL_STRING_push(key_param->param, *++args);
}
else if (!strcmp (*args, "-rctform")) else if (!strcmp (*args, "-rctform"))
{ {
if (!args[1]) if (!args[1])
@ -575,7 +648,7 @@ int MAIN(int argc, char **argv)
} }
else if (operation == SMIME_ENCRYPT) else if (operation == SMIME_ENCRYPT)
{ {
if (!*args && !secret_key && !pwri_pass) if (!*args && !secret_key && !pwri_pass && !encerts)
{ {
BIO_printf(bio_err, "No recipient(s) certificate(s) specified\n"); BIO_printf(bio_err, "No recipient(s) certificate(s) specified\n");
badarg = 1; badarg = 1;
@ -631,6 +704,7 @@ int MAIN(int argc, char **argv)
BIO_printf (bio_err, "-inform arg input format SMIME (default), PEM or DER\n"); BIO_printf (bio_err, "-inform arg input format SMIME (default), PEM or DER\n");
BIO_printf (bio_err, "-inkey file input private key (if not signer or recipient)\n"); BIO_printf (bio_err, "-inkey file input private key (if not signer or recipient)\n");
BIO_printf (bio_err, "-keyform arg input private key format (PEM or ENGINE)\n"); BIO_printf (bio_err, "-keyform arg input private key format (PEM or ENGINE)\n");
BIO_printf (bio_err, "-keyopt nm:v set public key parameters\n");
BIO_printf (bio_err, "-out file output file\n"); BIO_printf (bio_err, "-out file output file\n");
BIO_printf (bio_err, "-outform arg output format SMIME (default), PEM or DER\n"); BIO_printf (bio_err, "-outform arg output format SMIME (default), PEM or DER\n");
BIO_printf (bio_err, "-content file supply or override content for detached signature\n"); BIO_printf (bio_err, "-content file supply or override content for detached signature\n");
@ -716,7 +790,7 @@ int MAIN(int argc, char **argv)
goto end; goto end;
} }
if (*args) if (*args && !encerts)
encerts = sk_X509_new_null(); encerts = sk_X509_new_null();
while (*args) while (*args)
{ {
@ -910,10 +984,45 @@ int MAIN(int argc, char **argv)
} }
else if (operation == SMIME_ENCRYPT) else if (operation == SMIME_ENCRYPT)
{ {
int i;
flags |= CMS_PARTIAL; flags |= CMS_PARTIAL;
cms = CMS_encrypt(encerts, in, cipher, flags); cms = CMS_encrypt(NULL, in, cipher, flags);
if (!cms) if (!cms)
goto end; goto end;
for (i = 0; i < sk_X509_num(encerts); i++)
{
CMS_RecipientInfo *ri;
cms_key_param *kparam;
int tflags = flags;
X509 *x = sk_X509_value(encerts, i);
for(kparam = key_first; kparam; kparam = kparam->next)
{
if(kparam->idx == i)
{
tflags |= CMS_KEY_PARAM;
break;
}
}
ri = CMS_add1_recipient_cert(cms, x, tflags);
if (!ri)
goto end;
if (kparam)
{
EVP_PKEY_CTX *pctx;
pctx = CMS_RecipientInfo_get0_pkey_ctx(ri);
if (!cms_set_pkey_param(pctx, kparam->param))
goto end;
}
if (CMS_RecipientInfo_type(ri) == CMS_RECIPINFO_AGREE
&& wrap_cipher)
{
EVP_CIPHER_CTX *wctx;
wctx = CMS_RecipientInfo_kari_get0_ctx(ri);
EVP_EncryptInit_ex(wctx, wrap_cipher,
NULL, NULL, NULL);
}
}
if (secret_key) if (secret_key)
{ {
if (!CMS_add0_recipient_key(cms, NID_undef, if (!CMS_add0_recipient_key(cms, NID_undef,
@ -1002,8 +1111,11 @@ int MAIN(int argc, char **argv)
for (i = 0; i < sk_OPENSSL_STRING_num(sksigners); i++) for (i = 0; i < sk_OPENSSL_STRING_num(sksigners); i++)
{ {
CMS_SignerInfo *si; CMS_SignerInfo *si;
cms_key_param *kparam;
int tflags = flags;
signerfile = sk_OPENSSL_STRING_value(sksigners, i); signerfile = sk_OPENSSL_STRING_value(sksigners, i);
keyfile = sk_OPENSSL_STRING_value(skkeys, i); keyfile = sk_OPENSSL_STRING_value(skkeys, i);
signer = load_cert(bio_err, signerfile,FORMAT_PEM, NULL, signer = load_cert(bio_err, signerfile,FORMAT_PEM, NULL,
e, "signer certificate"); e, "signer certificate");
if (!signer) if (!signer)
@ -1012,9 +1124,24 @@ int MAIN(int argc, char **argv)
"signing key file"); "signing key file");
if (!key) if (!key)
goto end; goto end;
si = CMS_add1_signer(cms, signer, key, sign_md, flags); for(kparam = key_first; kparam; kparam = kparam->next)
{
if(kparam->idx == i)
{
tflags |= CMS_KEY_PARAM;
break;
}
}
si = CMS_add1_signer(cms, signer, key, sign_md, tflags);
if (!si) if (!si)
goto end; goto end;
if (kparam)
{
EVP_PKEY_CTX *pctx;
pctx = CMS_SignerInfo_get0_pkey_ctx(si);
if (!cms_set_pkey_param(pctx, kparam->param))
goto end;
}
if (rr && !CMS_add1_ReceiptRequest(si, rr)) if (rr && !CMS_add1_ReceiptRequest(si, rr))
goto end; goto end;
X509_free(signer); X509_free(signer);
@ -1039,6 +1166,8 @@ int MAIN(int argc, char **argv)
ret = 4; ret = 4;
if (operation == SMIME_DECRYPT) if (operation == SMIME_DECRYPT)
{ {
if (flags & CMS_DEBUG_DECRYPT)
CMS_decrypt(cms, NULL, NULL, NULL, NULL, flags);
if (secret_key) if (secret_key)
{ {
@ -1206,6 +1335,14 @@ end:
sk_OPENSSL_STRING_free(rr_to); sk_OPENSSL_STRING_free(rr_to);
if (rr_from) if (rr_from)
sk_OPENSSL_STRING_free(rr_from); sk_OPENSSL_STRING_free(rr_from);
for(key_param = key_first; key_param;)
{
cms_key_param *tparam;
sk_OPENSSL_STRING_free(key_param->param);
tparam = key_param->next;
OPENSSL_free(key_param);
key_param = tparam;
}
X509_STORE_free(store); X509_STORE_free(store);
X509_free(cert); X509_free(cert);
X509_free(recip); X509_free(recip);
@ -1390,4 +1527,25 @@ static CMS_ReceiptRequest *make_receipt_request(STACK_OF(OPENSSL_STRING) *rr_to,
return NULL; return NULL;
} }
static int cms_set_pkey_param(EVP_PKEY_CTX *pctx,
STACK_OF(OPENSSL_STRING) *param)
{
char *keyopt;
int i;
if (sk_OPENSSL_STRING_num(param) <= 0)
return 1;
for (i = 0; i < sk_OPENSSL_STRING_num(param); i++)
{
keyopt = sk_OPENSSL_STRING_value(param, i);
if (pkey_ctrl_string(pctx, keyopt) <= 0)
{
BIO_printf(bio_err, "parameter error \"%s\"\n",
keyopt);
ERR_print_errors(bio_err);
return 0;
}
}
return 1;
}
#endif #endif

View File

@ -81,6 +81,9 @@ static const char *crl_usage[]={
" -in arg - input file - default stdin\n", " -in arg - input file - default stdin\n",
" -out arg - output file - default stdout\n", " -out arg - output file - default stdout\n",
" -hash - print hash value\n", " -hash - print hash value\n",
#ifndef OPENSSL_NO_MD5
" -hash_old - print old-style (MD5) hash value\n",
#endif
" -fingerprint - print the crl fingerprint\n", " -fingerprint - print the crl fingerprint\n",
" -issuer - print issuer DN\n", " -issuer - print issuer DN\n",
" -lastupdate - lastUpdate field\n", " -lastupdate - lastUpdate field\n",
@ -93,7 +96,6 @@ static const char *crl_usage[]={
NULL NULL
}; };
static X509_CRL *load_crl(char *file, int format);
static BIO *bio_out=NULL; static BIO *bio_out=NULL;
int MAIN(int, char **); int MAIN(int, char **);
@ -103,11 +105,14 @@ int MAIN(int argc, char **argv)
unsigned long nmflag = 0; unsigned long nmflag = 0;
X509_CRL *x=NULL; X509_CRL *x=NULL;
char *CAfile = NULL, *CApath = NULL; char *CAfile = NULL, *CApath = NULL;
int ret=1,i,num,badops=0; int ret=1,i,num,badops=0,badsig=0;
BIO *out=NULL; BIO *out=NULL;
int informat,outformat; int informat,outformat, keyformat;
char *infile=NULL,*outfile=NULL; char *infile=NULL,*outfile=NULL, *crldiff = NULL, *keyfile = NULL;
int hash=0,issuer=0,lastupdate=0,nextupdate=0,noout=0,text=0; int hash=0,issuer=0,lastupdate=0,nextupdate=0,noout=0,text=0;
#ifndef OPENSSL_NO_MD5
int hash_old=0;
#endif
int fingerprint = 0, crlnumber = 0; int fingerprint = 0, crlnumber = 0;
const char **pp; const char **pp;
X509_STORE *store = NULL; X509_STORE *store = NULL;
@ -141,6 +146,7 @@ int MAIN(int argc, char **argv)
informat=FORMAT_PEM; informat=FORMAT_PEM;
outformat=FORMAT_PEM; outformat=FORMAT_PEM;
keyformat=FORMAT_PEM;
argc--; argc--;
argv++; argv++;
@ -169,6 +175,21 @@ int MAIN(int argc, char **argv)
if (--argc < 1) goto bad; if (--argc < 1) goto bad;
infile= *(++argv); infile= *(++argv);
} }
else if (strcmp(*argv,"-gendelta") == 0)
{
if (--argc < 1) goto bad;
crldiff= *(++argv);
}
else if (strcmp(*argv,"-key") == 0)
{
if (--argc < 1) goto bad;
keyfile= *(++argv);
}
else if (strcmp(*argv,"-keyform") == 0)
{
if (--argc < 1) goto bad;
keyformat=str2fmt(*(++argv));
}
else if (strcmp(*argv,"-out") == 0) else if (strcmp(*argv,"-out") == 0)
{ {
if (--argc < 1) goto bad; if (--argc < 1) goto bad;
@ -192,6 +213,10 @@ int MAIN(int argc, char **argv)
text = 1; text = 1;
else if (strcmp(*argv,"-hash") == 0) else if (strcmp(*argv,"-hash") == 0)
hash= ++num; hash= ++num;
#ifndef OPENSSL_NO_MD5
else if (strcmp(*argv,"-hash_old") == 0)
hash_old= ++num;
#endif
else if (strcmp(*argv,"-nameopt") == 0) else if (strcmp(*argv,"-nameopt") == 0)
{ {
if (--argc < 1) goto bad; if (--argc < 1) goto bad;
@ -209,6 +234,8 @@ int MAIN(int argc, char **argv)
fingerprint= ++num; fingerprint= ++num;
else if (strcmp(*argv,"-crlnumber") == 0) else if (strcmp(*argv,"-crlnumber") == 0)
crlnumber= ++num; crlnumber= ++num;
else if (strcmp(*argv,"-badsig") == 0)
badsig = 1;
else if ((md_alg=EVP_get_digestbyname(*argv + 1))) else if ((md_alg=EVP_get_digestbyname(*argv + 1)))
{ {
/* ok */ /* ok */
@ -276,6 +303,39 @@ bad:
else BIO_printf(bio_err, "verify OK\n"); else BIO_printf(bio_err, "verify OK\n");
} }
if (crldiff)
{
X509_CRL *newcrl, *delta;
if (!keyfile)
{
BIO_puts(bio_err, "Missing CRL signing key\n");
goto end;
}
newcrl = load_crl(crldiff,informat);
if (!newcrl)
goto end;
pkey = load_key(bio_err, keyfile, keyformat, 0, NULL, NULL,
"CRL signing key");
if (!pkey)
{
X509_CRL_free(newcrl);
goto end;
}
delta = X509_CRL_diff(x, newcrl, pkey, digest, 0);
X509_CRL_free(newcrl);
EVP_PKEY_free(pkey);
if (delta)
{
X509_CRL_free(x);
x = delta;
}
else
{
BIO_puts(bio_err, "Error creating delta CRL\n");
goto end;
}
}
if (num) if (num)
{ {
for (i=1; i<=num; i++) for (i=1; i<=num; i++)
@ -304,6 +364,14 @@ bad:
BIO_printf(bio_out,"%08lx\n", BIO_printf(bio_out,"%08lx\n",
X509_NAME_hash(X509_CRL_get_issuer(x))); X509_NAME_hash(X509_CRL_get_issuer(x)));
} }
#ifndef OPENSSL_NO_MD5
if (hash_old == i)
{
BIO_printf(bio_out,"%08lx\n",
X509_NAME_hash_old(
X509_CRL_get_issuer(x)));
}
#endif
if (lastupdate == i) if (lastupdate == i)
{ {
BIO_printf(bio_out,"lastUpdate="); BIO_printf(bio_out,"lastUpdate=");
@ -378,6 +446,9 @@ bad:
goto end; goto end;
} }
if (badsig)
x->signature->data[x->signature->length - 1] ^= 0x1;
if (outformat == FORMAT_ASN1) if (outformat == FORMAT_ASN1)
i=(int)i2d_X509_CRL_bio(out,x); i=(int)i2d_X509_CRL_bio(out,x);
else if (outformat == FORMAT_PEM) else if (outformat == FORMAT_PEM)
@ -390,6 +461,8 @@ bad:
if (!i) { BIO_printf(bio_err,"unable to write CRL\n"); goto end; } if (!i) { BIO_printf(bio_err,"unable to write CRL\n"); goto end; }
ret=0; ret=0;
end: end:
if (ret != 0)
ERR_print_errors(bio_err);
BIO_free_all(out); BIO_free_all(out);
BIO_free_all(bio_out); BIO_free_all(bio_out);
bio_out=NULL; bio_out=NULL;
@ -401,46 +474,3 @@ end:
apps_shutdown(); apps_shutdown();
OPENSSL_EXIT(ret); OPENSSL_EXIT(ret);
} }
static X509_CRL *load_crl(char *infile, int format)
{
X509_CRL *x=NULL;
BIO *in=NULL;
in=BIO_new(BIO_s_file());
if (in == NULL)
{
ERR_print_errors(bio_err);
goto end;
}
if (infile == NULL)
BIO_set_fp(in,stdin,BIO_NOCLOSE);
else
{
if (BIO_read_filename(in,infile) <= 0)
{
perror(infile);
goto end;
}
}
if (format == FORMAT_ASN1)
x=d2i_X509_CRL_bio(in,NULL);
else if (format == FORMAT_PEM)
x=PEM_read_bio_X509_CRL(in,NULL,NULL,NULL);
else {
BIO_printf(bio_err,"bad input format specified for input crl\n");
goto end;
}
if (x == NULL)
{
BIO_printf(bio_err,"unable to load CRL\n");
ERR_print_errors(bio_err);
goto end;
}
end:
BIO_free(in);
return(x);
}

View File

@ -141,7 +141,13 @@ int MAIN(int argc, char **argv)
{ {
if (--argc < 1) goto bad; if (--argc < 1) goto bad;
if(!certflst) certflst = sk_OPENSSL_STRING_new_null(); if(!certflst) certflst = sk_OPENSSL_STRING_new_null();
sk_OPENSSL_STRING_push(certflst,*(++argv)); if (!certflst)
goto end;
if (!sk_OPENSSL_STRING_push(certflst,*(++argv)))
{
sk_OPENSSL_STRING_free(certflst);
goto end;
}
} }
else else
{ {

View File

@ -103,7 +103,7 @@ int MAIN(int, char **);
int MAIN(int argc, char **argv) int MAIN(int argc, char **argv)
{ {
ENGINE *e = NULL; ENGINE *e = NULL, *impl = NULL;
unsigned char *buf=NULL; unsigned char *buf=NULL;
int i,err=1; int i,err=1;
const EVP_MD *md=NULL,*m; const EVP_MD *md=NULL,*m;
@ -124,6 +124,7 @@ int MAIN(int argc, char **argv)
char *passargin = NULL, *passin = NULL; char *passargin = NULL, *passin = NULL;
#ifndef OPENSSL_NO_ENGINE #ifndef OPENSSL_NO_ENGINE
char *engine=NULL; char *engine=NULL;
int engine_impl = 0;
#endif #endif
char *hmac_key=NULL; char *hmac_key=NULL;
char *mac_name=NULL; char *mac_name=NULL;
@ -209,6 +210,8 @@ int MAIN(int argc, char **argv)
engine= *(++argv); engine= *(++argv);
e = setup_engine(bio_err, engine, 0); e = setup_engine(bio_err, engine, 0);
} }
else if (strcmp(*argv,"-engine_impl") == 0)
engine_impl = 1;
#endif #endif
else if (strcmp(*argv,"-hex") == 0) else if (strcmp(*argv,"-hex") == 0)
out_bin = 0; out_bin = 0;
@ -216,10 +219,10 @@ int MAIN(int argc, char **argv)
out_bin = 1; out_bin = 1;
else if (strcmp(*argv,"-d") == 0) else if (strcmp(*argv,"-d") == 0)
debug=1; debug=1;
else if (strcmp(*argv,"-non-fips-allow") == 0)
non_fips_allow=1;
else if (!strcmp(*argv,"-fips-fingerprint")) else if (!strcmp(*argv,"-fips-fingerprint"))
hmac_key = "etaonrishdlcupfm"; hmac_key = "etaonrishdlcupfm";
else if (strcmp(*argv,"-non-fips-allow") == 0)
non_fips_allow=1;
else if (!strcmp(*argv,"-hmac")) else if (!strcmp(*argv,"-hmac"))
{ {
if (--argc < 1) if (--argc < 1)
@ -291,6 +294,11 @@ int MAIN(int argc, char **argv)
goto end; goto end;
} }
#ifndef OPENSSL_NO_ENGINE
if (engine_impl)
impl = e;
#endif
in=BIO_new(BIO_s_file()); in=BIO_new(BIO_s_file());
bmd=BIO_new(BIO_f_md()); bmd=BIO_new(BIO_f_md());
if (debug) if (debug)
@ -368,7 +376,7 @@ int MAIN(int argc, char **argv)
{ {
EVP_PKEY_CTX *mac_ctx = NULL; EVP_PKEY_CTX *mac_ctx = NULL;
int r = 0; int r = 0;
if (!init_gen_str(bio_err, &mac_ctx, mac_name,e, 0)) if (!init_gen_str(bio_err, &mac_ctx, mac_name, impl, 0))
goto mac_end; goto mac_end;
if (macopts) if (macopts)
{ {
@ -409,7 +417,7 @@ int MAIN(int argc, char **argv)
if (hmac_key) if (hmac_key)
{ {
sigkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, e, sigkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, impl,
(unsigned char *)hmac_key, -1); (unsigned char *)hmac_key, -1);
if (!sigkey) if (!sigkey)
goto end; goto end;
@ -427,9 +435,9 @@ int MAIN(int argc, char **argv)
goto end; goto end;
} }
if (do_verify) if (do_verify)
r = EVP_DigestVerifyInit(mctx, &pctx, md, e, sigkey); r = EVP_DigestVerifyInit(mctx, &pctx, md, impl, sigkey);
else else
r = EVP_DigestSignInit(mctx, &pctx, md, e, sigkey); r = EVP_DigestSignInit(mctx, &pctx, md, impl, sigkey);
if (!r) if (!r)
{ {
BIO_printf(bio_err, "Error setting context\n"); BIO_printf(bio_err, "Error setting context\n");
@ -456,9 +464,16 @@ int MAIN(int argc, char **argv)
/* we use md as a filter, reading from 'in' */ /* we use md as a filter, reading from 'in' */
else else
{ {
EVP_MD_CTX *mctx = NULL;
if (!BIO_get_md_ctx(bmd, &mctx))
{
BIO_printf(bio_err, "Error getting context\n");
ERR_print_errors(bio_err);
goto end;
}
if (md == NULL) if (md == NULL)
md = EVP_md5(); md = EVP_md5();
if (!BIO_set_md(bmd,md)) if (!EVP_DigestInit_ex(mctx, md, impl))
{ {
BIO_printf(bio_err, "Error setting digest %s\n", pname); BIO_printf(bio_err, "Error setting digest %s\n", pname);
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
@ -514,6 +529,7 @@ int MAIN(int argc, char **argv)
EVP_PKEY_asn1_get0_info(NULL, NULL, EVP_PKEY_asn1_get0_info(NULL, NULL,
NULL, NULL, &sig_name, ameth); NULL, NULL, &sig_name, ameth);
} }
if (md)
md_name = EVP_MD_name(md); md_name = EVP_MD_name(md);
} }
err = 0; err = 0;
@ -626,7 +642,12 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
else else
{ {
if (sig_name) if (sig_name)
BIO_printf(out, "%s-%s(%s)= ", sig_name, md_name, file); {
BIO_puts(out, sig_name);
if (md_name)
BIO_printf(out, "-%s", md_name);
BIO_printf(out, "(%s)= ", file);
}
else if (md_name) else if (md_name)
BIO_printf(out, "%s(%s)= ", md_name, file); BIO_printf(out, "%s(%s)= ", md_name, file);
else else

View File

@ -130,7 +130,7 @@
#undef PROG #undef PROG
#define PROG dhparam_main #define PROG dhparam_main
#define DEFBITS 512 #define DEFBITS 2048
/* -inform arg - input format - default PEM (DER or PEM) /* -inform arg - input format - default PEM (DER or PEM)
* -outform arg - output format - default PEM * -outform arg - output format - default PEM
@ -253,7 +253,7 @@ bad:
BIO_printf(bio_err," -C Output C code\n"); BIO_printf(bio_err," -C Output C code\n");
BIO_printf(bio_err," -2 generate parameters using 2 as the generator value\n"); BIO_printf(bio_err," -2 generate parameters using 2 as the generator value\n");
BIO_printf(bio_err," -5 generate parameters using 5 as the generator value\n"); BIO_printf(bio_err," -5 generate parameters using 5 as the generator value\n");
BIO_printf(bio_err," numbits number of bits in to generate (default 512)\n"); BIO_printf(bio_err," numbits number of bits in to generate (default 2048)\n");
#ifndef OPENSSL_NO_ENGINE #ifndef OPENSSL_NO_ENGINE
BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n"); BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n");
#endif #endif
@ -332,7 +332,6 @@ bad:
BIO_printf(bio_err,"This is going to take a long time\n"); BIO_printf(bio_err,"This is going to take a long time\n");
if(!dh || !DH_generate_parameters_ex(dh, num, g, &cb)) if(!dh || !DH_generate_parameters_ex(dh, num, g, &cb))
{ {
if(dh) DH_free(dh);
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
goto end; goto end;
} }
@ -513,7 +512,12 @@ bad:
if (outformat == FORMAT_ASN1) if (outformat == FORMAT_ASN1)
i=i2d_DHparams_bio(out,dh); i=i2d_DHparams_bio(out,dh);
else if (outformat == FORMAT_PEM) else if (outformat == FORMAT_PEM)
{
if (dh->q)
i=PEM_write_bio_DHxparams(out,dh);
else
i=PEM_write_bio_DHparams(out,dh); i=PEM_write_bio_DHparams(out,dh);
}
else { else {
BIO_printf(bio_err,"bad output format specified for outfile\n"); BIO_printf(bio_err,"bad output format specified for outfile\n");
goto end; goto end;

View File

@ -326,6 +326,7 @@ bad:
goto end; goto end;
} }
#endif #endif
ERR_print_errors(bio_err);
BIO_printf(bio_err,"Error, DSA key generation failed\n"); BIO_printf(bio_err,"Error, DSA key generation failed\n");
goto end; goto end;
} }
@ -429,13 +430,19 @@ bad:
assert(need_rand); assert(need_rand);
if ((dsakey=DSAparams_dup(dsa)) == NULL) goto end; if ((dsakey=DSAparams_dup(dsa)) == NULL) goto end;
if (!DSA_generate_key(dsakey)) goto end; if (!DSA_generate_key(dsakey))
{
ERR_print_errors(bio_err);
DSA_free(dsakey);
goto end;
}
if (outformat == FORMAT_ASN1) if (outformat == FORMAT_ASN1)
i=i2d_DSAPrivateKey_bio(out,dsakey); i=i2d_DSAPrivateKey_bio(out,dsakey);
else if (outformat == FORMAT_PEM) else if (outformat == FORMAT_PEM)
i=PEM_write_bio_DSAPrivateKey(out,dsakey,NULL,NULL,0,NULL,NULL); i=PEM_write_bio_DSAPrivateKey(out,dsakey,NULL,NULL,0,NULL,NULL);
else { else {
BIO_printf(bio_err,"bad output format specified for outfile\n"); BIO_printf(bio_err,"bad output format specified for outfile\n");
DSA_free(dsakey);
goto end; goto end;
} }
DSA_free(dsakey); DSA_free(dsakey);

View File

@ -105,7 +105,7 @@
* in the asn1 der encoding * in the asn1 der encoding
* possible values: named_curve (default) * possible values: named_curve (default)
* explicit * explicit
* -no_seed - if 'explicit' parameters are choosen do not use the seed * -no_seed - if 'explicit' parameters are chosen do not use the seed
* -genkey - generate ec key * -genkey - generate ec key
* -rand file - files to use for random number input * -rand file - files to use for random number input
* -engine e - use engine e, possibly a hardware device * -engine e - use engine e, possibly a hardware device
@ -286,7 +286,7 @@ bad:
BIO_printf(bio_err, " " BIO_printf(bio_err, " "
" explicit\n"); " explicit\n");
BIO_printf(bio_err, " -no_seed if 'explicit'" BIO_printf(bio_err, " -no_seed if 'explicit'"
" parameters are choosen do not" " parameters are chosen do not"
" use the seed\n"); " use the seed\n");
BIO_printf(bio_err, " -genkey generate ec" BIO_printf(bio_err, " -genkey generate ec"
" key\n"); " key\n");
@ -403,6 +403,9 @@ bad:
else else
nid = OBJ_sn2nid(curve_name); nid = OBJ_sn2nid(curve_name);
if (nid == 0)
nid = EC_curve_nist2nid(curve_name);
if (nid == 0) if (nid == 0)
{ {
BIO_printf(bio_err, "unknown curve name (%s)\n", BIO_printf(bio_err, "unknown curve name (%s)\n",

View File

@ -67,7 +67,9 @@
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/pem.h> #include <openssl/pem.h>
#ifndef OPENSSL_NO_COMP
#include <openssl/comp.h> #include <openssl/comp.h>
#endif
#include <ctype.h> #include <ctype.h>
int set_hex(char *in,unsigned char *out,int size); int set_hex(char *in,unsigned char *out,int size);
@ -331,6 +333,18 @@ bad:
setup_engine(bio_err, engine, 0); setup_engine(bio_err, engine, 0);
#endif #endif
if (cipher && EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER)
{
BIO_printf(bio_err, "AEAD ciphers not supported by the enc utility\n");
goto end;
}
if (cipher && (EVP_CIPHER_mode(cipher) == EVP_CIPH_XTS_MODE))
{
BIO_printf(bio_err, "Ciphers in XTS mode are not supported by the enc utility\n");
goto end;
}
if (md && (dgst=EVP_get_digestbyname(md)) == NULL) if (md && (dgst=EVP_get_digestbyname(md)) == NULL)
{ {
BIO_printf(bio_err,"%s is an unsupported message digest type\n",md); BIO_printf(bio_err,"%s is an unsupported message digest type\n",md);

View File

@ -78,7 +78,7 @@
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/pem.h> #include <openssl/pem.h>
#define DEFBITS 512 #define DEFBITS 2048
#undef PROG #undef PROG
#define PROG gendh_main #define PROG gendh_main

View File

@ -78,7 +78,7 @@
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#define DEFBITS 512 #define DEFBITS 2048
#undef PROG #undef PROG
#define PROG genrsa_main #define PROG genrsa_main

View File

@ -773,9 +773,12 @@ $ CCDEFS = "MONOLITH"
$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS $ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
$ CCEXTRAFLAGS = "" $ CCEXTRAFLAGS = ""
$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS $ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
$ CCDISABLEWARNINGS = "" !!! "LONGLONGTYPE,LONGLONGSUFX,FOUNDCR" $ CCDISABLEWARNINGS = "" !!! "MAYLOSEDATA3" !!! "LONGLONGTYPE,LONGLONGSUFX,FOUNDCR"
$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN - $ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. ""
CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," + USER_CCDISABLEWARNINGS $ THEN
$ IF CCDISABLEWARNINGS .NES. THEN CCDISABLEWARNINGS = CCDISABLEWARNINGS + ","
$ CCDISABLEWARNINGS = CCDISABLEWARNINGS + USER_CCDISABLEWARNINGS
$ ENDIF
$! $!
$! Check To See If We Have A ZLIB Option. $! Check To See If We Have A ZLIB Option.
$! $!
@ -1064,6 +1067,18 @@ $! Finish up the definition of CC.
$! $!
$ IF COMPILER .EQS. "DECC" $ IF COMPILER .EQS. "DECC"
$ THEN $ THEN
$! Not all compiler versions support MAYLOSEDATA3.
$ OPT_TEST = "MAYLOSEDATA3"
$ DEFINE /USER_MODE SYS$ERROR NL:
$ DEFINE /USER_MODE SYS$OUTPUT NL:
$ 'CC' /NOCROSS_REFERENCE /NOLIST /NOOBJECT -
/WARNINGS = DISABLE = ('OPT_TEST', EMPTYFILE) NL:
$ IF ($SEVERITY)
$ THEN
$ IF CCDISABLEWARNINGS .NES. "" THEN -
CCDISABLEWARNINGS = CCDISABLEWARNINGS+ ","
$ CCDISABLEWARNINGS = CCDISABLEWARNINGS+ OPT_TEST
$ ENDIF
$ IF CCDISABLEWARNINGS .NES. "" $ IF CCDISABLEWARNINGS .NES. ""
$ THEN $ THEN
$ CCDISABLEWARNINGS = " /WARNING=(DISABLE=(" + CCDISABLEWARNINGS + "))" $ CCDISABLEWARNINGS = " /WARNING=(DISABLE=(" + CCDISABLEWARNINGS + "))"

View File

@ -105,16 +105,16 @@ static int print_ocsp_summary(BIO *out, OCSP_BASICRESP *bs, OCSP_REQUEST *req,
long maxage); long maxage);
static int make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req, CA_DB *db, static int make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req, CA_DB *db,
X509 *ca, X509 *rcert, EVP_PKEY *rkey, X509 *ca, X509 *rcert, EVP_PKEY *rkey, const EVP_MD *md,
STACK_OF(X509) *rother, unsigned long flags, STACK_OF(X509) *rother, unsigned long flags,
int nmin, int ndays); int nmin, int ndays, int badsig);
static char **lookup_serial(CA_DB *db, ASN1_INTEGER *ser); static char **lookup_serial(CA_DB *db, ASN1_INTEGER *ser);
static BIO *init_responder(char *port); static BIO *init_responder(const char *port);
static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, char *port); static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, const char *port);
static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp); static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp);
static OCSP_RESPONSE *query_responder(BIO *err, BIO *cbio, char *path, static OCSP_RESPONSE *query_responder(BIO *err, BIO *cbio, const char *path,
STACK_OF(CONF_VALUE) *headers, const STACK_OF(CONF_VALUE) *headers,
OCSP_REQUEST *req, int req_timeout); OCSP_REQUEST *req, int req_timeout);
#undef PROG #undef PROG
@ -127,6 +127,7 @@ int MAIN(int argc, char **argv)
ENGINE *e = NULL; ENGINE *e = NULL;
char **args; char **args;
char *host = NULL, *port = NULL, *path = "/"; char *host = NULL, *port = NULL, *path = "/";
char *thost = NULL, *tport = NULL, *tpath = NULL;
char *reqin = NULL, *respin = NULL; char *reqin = NULL, *respin = NULL;
char *reqout = NULL, *respout = NULL; char *reqout = NULL, *respout = NULL;
char *signfile = NULL, *keyfile = NULL; char *signfile = NULL, *keyfile = NULL;
@ -148,12 +149,14 @@ int MAIN(int argc, char **argv)
long nsec = MAX_VALIDITY_PERIOD, maxage = -1; long nsec = MAX_VALIDITY_PERIOD, maxage = -1;
char *CAfile = NULL, *CApath = NULL; char *CAfile = NULL, *CApath = NULL;
X509_STORE *store = NULL; X509_STORE *store = NULL;
X509_VERIFY_PARAM *vpm = NULL;
STACK_OF(X509) *sign_other = NULL, *verify_other = NULL, *rother = NULL; STACK_OF(X509) *sign_other = NULL, *verify_other = NULL, *rother = NULL;
char *sign_certfile = NULL, *verify_certfile = NULL, *rcertfile = NULL; char *sign_certfile = NULL, *verify_certfile = NULL, *rcertfile = NULL;
unsigned long sign_flags = 0, verify_flags = 0, rflags = 0; unsigned long sign_flags = 0, verify_flags = 0, rflags = 0;
int ret = 1; int ret = 1;
int accept_count = -1; int accept_count = -1;
int badarg = 0; int badarg = 0;
int badsig = 0;
int i; int i;
int ignore_err = 0; int ignore_err = 0;
STACK_OF(OPENSSL_STRING) *reqnames = NULL; STACK_OF(OPENSSL_STRING) *reqnames = NULL;
@ -164,7 +167,7 @@ int MAIN(int argc, char **argv)
char *rca_filename = NULL; char *rca_filename = NULL;
CA_DB *rdb = NULL; CA_DB *rdb = NULL;
int nmin = 0, ndays = -1; int nmin = 0, ndays = -1;
const EVP_MD *cert_id_md = NULL; const EVP_MD *cert_id_md = NULL, *rsign_md = NULL;
if (bio_err == NULL) bio_err = BIO_new_fp(stderr, BIO_NOCLOSE); if (bio_err == NULL) bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
@ -204,6 +207,12 @@ int MAIN(int argc, char **argv)
} }
else if (!strcmp(*args, "-url")) else if (!strcmp(*args, "-url"))
{ {
if (thost)
OPENSSL_free(thost);
if (tport)
OPENSSL_free(tport);
if (tpath)
OPENSSL_free(tpath);
if (args[1]) if (args[1])
{ {
args++; args++;
@ -212,6 +221,9 @@ int MAIN(int argc, char **argv)
BIO_printf(bio_err, "Error parsing URL\n"); BIO_printf(bio_err, "Error parsing URL\n");
badarg = 1; badarg = 1;
} }
thost = host;
tport = port;
tpath = path;
} }
else badarg = 1; else badarg = 1;
} }
@ -271,6 +283,8 @@ int MAIN(int argc, char **argv)
verify_flags |= OCSP_TRUSTOTHER; verify_flags |= OCSP_TRUSTOTHER;
else if (!strcmp(*args, "-no_intern")) else if (!strcmp(*args, "-no_intern"))
verify_flags |= OCSP_NOINTERN; verify_flags |= OCSP_NOINTERN;
else if (!strcmp(*args, "-badsig"))
badsig = 1;
else if (!strcmp(*args, "-text")) else if (!strcmp(*args, "-text"))
{ {
req_text = 1; req_text = 1;
@ -353,6 +367,12 @@ int MAIN(int argc, char **argv)
} }
else badarg = 1; else badarg = 1;
} }
else if (args_verify(&args, NULL, &badarg, bio_err, &vpm))
{
if (badarg)
goto end;
continue;
}
else if (!strcmp (*args, "-validity_period")) else if (!strcmp (*args, "-validity_period"))
{ {
if (args[1]) if (args[1])
@ -558,6 +578,17 @@ int MAIN(int argc, char **argv)
} }
else badarg = 1; else badarg = 1;
} }
else if (!strcmp(*args, "-rmd"))
{
if (args[1])
{
args++;
rsign_md = EVP_get_digestbyname(*args);
if (!rsign_md)
badarg = 1;
}
else badarg = 1;
}
else if ((cert_id_md = EVP_get_digestbyname((*args)+1))==NULL) else if ((cert_id_md = EVP_get_digestbyname((*args)+1))==NULL)
{ {
badarg = 1; badarg = 1;
@ -617,7 +648,7 @@ int MAIN(int argc, char **argv)
BIO_printf (bio_err, "-ndays n number of days before next update\n"); BIO_printf (bio_err, "-ndays n number of days before next update\n");
BIO_printf (bio_err, "-resp_key_id identify reponse by signing certificate key ID\n"); BIO_printf (bio_err, "-resp_key_id identify reponse by signing certificate key ID\n");
BIO_printf (bio_err, "-nrequest n number of requests to accept (default unlimited)\n"); BIO_printf (bio_err, "-nrequest n number of requests to accept (default unlimited)\n");
BIO_printf (bio_err, "-<dgst alg> use specified digest in the request"); BIO_printf (bio_err, "-<dgst alg> use specified digest in the request\n");
goto end; goto end;
} }
@ -634,6 +665,9 @@ int MAIN(int argc, char **argv)
if (!req && reqin) if (!req && reqin)
{ {
if (!strcmp(reqin, "-"))
derbio = BIO_new_fp(stdin, BIO_NOCLOSE);
else
derbio = BIO_new_file(reqin, "rb"); derbio = BIO_new_file(reqin, "rb");
if (!derbio) if (!derbio)
{ {
@ -736,6 +770,9 @@ int MAIN(int argc, char **argv)
if (reqout) if (reqout)
{ {
if (!strcmp(reqout, "-"))
derbio = BIO_new_fp(stdout, BIO_NOCLOSE);
else
derbio = BIO_new_file(reqout, "wb"); derbio = BIO_new_file(reqout, "wb");
if(!derbio) if(!derbio)
{ {
@ -761,7 +798,7 @@ int MAIN(int argc, char **argv)
if (rdb) if (rdb)
{ {
i = make_ocsp_response(&resp, req, rdb, rca_cert, rsigner, rkey, rother, rflags, nmin, ndays); i = make_ocsp_response(&resp, req, rdb, rca_cert, rsigner, rkey,rsign_md, rother, rflags, nmin, ndays, badsig);
if (cbio) if (cbio)
send_ocsp_response(cbio, resp); send_ocsp_response(cbio, resp);
} }
@ -779,6 +816,9 @@ int MAIN(int argc, char **argv)
} }
else if (respin) else if (respin)
{ {
if (!strcmp(respin, "-"))
derbio = BIO_new_fp(stdin, BIO_NOCLOSE);
else
derbio = BIO_new_file(respin, "rb"); derbio = BIO_new_file(respin, "rb");
if (!derbio) if (!derbio)
{ {
@ -804,6 +844,9 @@ int MAIN(int argc, char **argv)
if (respout) if (respout)
{ {
if (!strcmp(respout, "-"))
derbio = BIO_new_fp(stdout, BIO_NOCLOSE);
else
derbio = BIO_new_file(respout, "wb"); derbio = BIO_new_file(respout, "wb");
if(!derbio) if(!derbio)
{ {
@ -844,6 +887,12 @@ int MAIN(int argc, char **argv)
resp = NULL; resp = NULL;
goto redo_accept; goto redo_accept;
} }
ret = 0;
goto end;
}
else if (ridx_filename)
{
ret = 0;
goto end; goto end;
} }
@ -851,6 +900,8 @@ int MAIN(int argc, char **argv)
store = setup_verify(bio_err, CAfile, CApath); store = setup_verify(bio_err, CAfile, CApath);
if (!store) if (!store)
goto end; goto end;
if (vpm)
X509_STORE_set1_param(store, vpm);
if (verify_certfile) if (verify_certfile)
{ {
verify_other = load_certs(bio_err, verify_certfile, FORMAT_PEM, verify_other = load_certs(bio_err, verify_certfile, FORMAT_PEM,
@ -866,6 +917,8 @@ int MAIN(int argc, char **argv)
goto end; goto end;
} }
ret = 0;
if (!noverify) if (!noverify)
{ {
if (req && ((i = OCSP_check_nonce(req, bs)) <= 0)) if (req && ((i = OCSP_check_nonce(req, bs)) <= 0))
@ -875,17 +928,17 @@ int MAIN(int argc, char **argv)
else else
{ {
BIO_printf(bio_err, "Nonce Verify error\n"); BIO_printf(bio_err, "Nonce Verify error\n");
ret = 1;
goto end; goto end;
} }
} }
i = OCSP_basic_verify(bs, verify_other, store, verify_flags); i = OCSP_basic_verify(bs, verify_other, store, verify_flags);
if (i < 0) i = OCSP_basic_verify(bs, NULL, store, 0);
if(i <= 0) if(i <= 0)
{ {
BIO_printf(bio_err, "Response Verify Failure\n"); BIO_printf(bio_err, "Response Verify Failure\n");
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
ret = 1;
} }
else else
BIO_printf(bio_err, "Response verify OK\n"); BIO_printf(bio_err, "Response verify OK\n");
@ -893,14 +946,14 @@ int MAIN(int argc, char **argv)
} }
if (!print_ocsp_summary(out, bs, req, reqnames, ids, nsec, maxage)) if (!print_ocsp_summary(out, bs, req, reqnames, ids, nsec, maxage))
goto end; ret = 1;
ret = 0;
end: end:
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
X509_free(signer); X509_free(signer);
X509_STORE_free(store); X509_STORE_free(store);
if (vpm)
X509_VERIFY_PARAM_free(vpm);
EVP_PKEY_free(key); EVP_PKEY_free(key);
EVP_PKEY_free(rkey); EVP_PKEY_free(rkey);
X509_free(issuer); X509_free(issuer);
@ -920,12 +973,12 @@ end:
sk_X509_pop_free(verify_other, X509_free); sk_X509_pop_free(verify_other, X509_free);
sk_CONF_VALUE_pop_free(headers, X509V3_conf_free); sk_CONF_VALUE_pop_free(headers, X509V3_conf_free);
if (use_ssl != -1) if (thost)
{ OPENSSL_free(thost);
OPENSSL_free(host); if (tport)
OPENSSL_free(port); OPENSSL_free(tport);
OPENSSL_free(path); if (tpath)
} OPENSSL_free(tpath);
OPENSSL_EXIT(ret); OPENSSL_EXIT(ret);
} }
@ -1051,9 +1104,10 @@ static int print_ocsp_summary(BIO *out, OCSP_BASICRESP *bs, OCSP_REQUEST *req,
static int make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req, CA_DB *db, static int make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req, CA_DB *db,
X509 *ca, X509 *rcert, EVP_PKEY *rkey, X509 *ca, X509 *rcert,
EVP_PKEY *rkey, const EVP_MD *rmd,
STACK_OF(X509) *rother, unsigned long flags, STACK_OF(X509) *rother, unsigned long flags,
int nmin, int ndays) int nmin, int ndays, int badsig)
{ {
ASN1_TIME *thisupd = NULL, *nextupd = NULL; ASN1_TIME *thisupd = NULL, *nextupd = NULL;
OCSP_CERTID *cid, *ca_id = NULL; OCSP_CERTID *cid, *ca_id = NULL;
@ -1142,7 +1196,10 @@ static int make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req, CA_DB *db
OCSP_copy_nonce(bs, req); OCSP_copy_nonce(bs, req);
OCSP_basic_sign(bs, rcert, rkey, NULL, rother, flags); OCSP_basic_sign(bs, rcert, rkey, rmd, rother, flags);
if (badsig)
bs->signature->data[bs->signature->length -1] ^= 0x1;
*resp = OCSP_response_create(OCSP_RESPONSE_STATUS_SUCCESSFUL, bs); *resp = OCSP_response_create(OCSP_RESPONSE_STATUS_SUCCESSFUL, bs);
@ -1176,7 +1233,7 @@ static char **lookup_serial(CA_DB *db, ASN1_INTEGER *ser)
/* Quick and dirty OCSP server: read in and parse input request */ /* Quick and dirty OCSP server: read in and parse input request */
static BIO *init_responder(char *port) static BIO *init_responder(const char *port)
{ {
BIO *acbio = NULL, *bufbio = NULL; BIO *acbio = NULL, *bufbio = NULL;
bufbio = BIO_new(BIO_f_buffer()); bufbio = BIO_new(BIO_f_buffer());
@ -1207,7 +1264,8 @@ static BIO *init_responder(char *port)
return NULL; return NULL;
} }
static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, char *port) static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio,
const char *port)
{ {
int have_post = 0, len; int have_post = 0, len;
OCSP_REQUEST *req = NULL; OCSP_REQUEST *req = NULL;
@ -1273,8 +1331,8 @@ static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp)
return 1; return 1;
} }
static OCSP_RESPONSE *query_responder(BIO *err, BIO *cbio, char *path, static OCSP_RESPONSE *query_responder(BIO *err, BIO *cbio, const char *path,
STACK_OF(CONF_VALUE) *headers, const STACK_OF(CONF_VALUE) *headers,
OCSP_REQUEST *req, int req_timeout) OCSP_REQUEST *req, int req_timeout)
{ {
int fd; int fd;
@ -1371,8 +1429,9 @@ static OCSP_RESPONSE *query_responder(BIO *err, BIO *cbio, char *path,
} }
OCSP_RESPONSE *process_responder(BIO *err, OCSP_REQUEST *req, OCSP_RESPONSE *process_responder(BIO *err, OCSP_REQUEST *req,
char *host, char *path, char *port, int use_ssl, const char *host, const char *path,
STACK_OF(CONF_VALUE) *headers, const char *port, int use_ssl,
const STACK_OF(CONF_VALUE) *headers,
int req_timeout) int req_timeout)
{ {
BIO *cbio = NULL; BIO *cbio = NULL;
@ -1409,7 +1468,7 @@ OCSP_RESPONSE *process_responder(BIO *err, OCSP_REQUEST *req,
} }
resp = query_responder(err, cbio, path, headers, req, req_timeout); resp = query_responder(err, cbio, path, headers, req, req_timeout);
if (!resp) if (!resp)
BIO_printf(bio_err, "Error querying OCSP responsder\n"); BIO_printf(bio_err, "Error querying OCSP responder\n");
end: end:
if (cbio) if (cbio)
BIO_free_all(cbio); BIO_free_all(cbio);

View File

@ -103,7 +103,7 @@ emailAddress = optional
#################################################################### ####################################################################
[ req ] [ req ]
default_bits = 1024 default_bits = 2048
default_keyfile = privkey.pem default_keyfile = privkey.pem
distinguished_name = req_distinguished_name distinguished_name = req_distinguished_name
attributes = req_attributes attributes = req_attributes

View File

@ -117,6 +117,7 @@
#include "apps.h" #include "apps.h"
#include <openssl/bio.h> #include <openssl/bio.h>
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include <openssl/rand.h>
#include <openssl/lhash.h> #include <openssl/lhash.h>
#include <openssl/conf.h> #include <openssl/conf.h>
#include <openssl/x509.h> #include <openssl/x509.h>

View File

@ -103,7 +103,7 @@ emailAddress = optional
#################################################################### ####################################################################
[ req ] [ req ]
default_bits = 1024 default_bits = 2048
default_keyfile = privkey.pem default_keyfile = privkey.pem
distinguished_name = req_distinguished_name distinguished_name = req_distinguished_name
attributes = req_attributes attributes = req_attributes

View File

@ -112,7 +112,7 @@ int MAIN(int argc, char **argv)
int maciter = PKCS12_DEFAULT_ITER; int maciter = PKCS12_DEFAULT_ITER;
int twopass = 0; int twopass = 0;
int keytype = 0; int keytype = 0;
int cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC; int cert_pbe;
int key_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC; int key_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
int ret = 1; int ret = 1;
int macver = 1; int macver = 1;
@ -130,6 +130,13 @@ int MAIN(int argc, char **argv)
apps_startup(); apps_startup();
#ifdef OPENSSL_FIPS
if (FIPS_mode())
cert_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
else
#endif
cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC;
enc = EVP_des_ede3_cbc(); enc = EVP_des_ede3_cbc();
if (bio_err == NULL ) bio_err = BIO_new_fp (stderr, BIO_NOCLOSE); if (bio_err == NULL ) bio_err = BIO_new_fp (stderr, BIO_NOCLOSE);

View File

@ -135,6 +135,22 @@ int MAIN(int argc, char **argv)
else else
badarg = 1; badarg = 1;
} }
else if (!strcmp(*args,"-v2prf"))
{
if (args[1])
{
args++;
pbe_nid=OBJ_txt2nid(*args);
if (!EVP_PBE_find(EVP_PBE_TYPE_PRF, pbe_nid, NULL, NULL, 0))
{
BIO_printf(bio_err,
"Unknown PRF algorithm %s\n", *args);
badarg = 1;
}
}
else
badarg = 1;
}
else if (!strcmp(*args,"-inform")) else if (!strcmp(*args,"-inform"))
{ {
if (args[1]) if (args[1])

View File

@ -107,16 +107,16 @@ FUNCTION functions[] = {
{FUNC_TYPE_GENERAL,"gendsa",gendsa_main}, {FUNC_TYPE_GENERAL,"gendsa",gendsa_main},
#endif #endif
{FUNC_TYPE_GENERAL,"genpkey",genpkey_main}, {FUNC_TYPE_GENERAL,"genpkey",genpkey_main},
#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3)) #if !defined(OPENSSL_NO_SOCK)
{FUNC_TYPE_GENERAL,"s_server",s_server_main}, {FUNC_TYPE_GENERAL,"s_server",s_server_main},
#endif #endif
#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3)) #if !defined(OPENSSL_NO_SOCK)
{FUNC_TYPE_GENERAL,"s_client",s_client_main}, {FUNC_TYPE_GENERAL,"s_client",s_client_main},
#endif #endif
#ifndef OPENSSL_NO_SPEED #ifndef OPENSSL_NO_SPEED
{FUNC_TYPE_GENERAL,"speed",speed_main}, {FUNC_TYPE_GENERAL,"speed",speed_main},
#endif #endif
#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3)) #if !defined(OPENSSL_NO_SOCK)
{FUNC_TYPE_GENERAL,"s_time",s_time_main}, {FUNC_TYPE_GENERAL,"s_time",s_time_main},
#endif #endif
{FUNC_TYPE_GENERAL,"version",version_main}, {FUNC_TYPE_GENERAL,"version",version_main},
@ -126,7 +126,7 @@ FUNCTION functions[] = {
#endif #endif
{FUNC_TYPE_GENERAL,"crl2pkcs7",crl2pkcs7_main}, {FUNC_TYPE_GENERAL,"crl2pkcs7",crl2pkcs7_main},
{FUNC_TYPE_GENERAL,"sess_id",sess_id_main}, {FUNC_TYPE_GENERAL,"sess_id",sess_id_main},
#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3)) #if !defined(OPENSSL_NO_SOCK)
{FUNC_TYPE_GENERAL,"ciphers",ciphers_main}, {FUNC_TYPE_GENERAL,"ciphers",ciphers_main},
#endif #endif
{FUNC_TYPE_GENERAL,"nseq",nseq_main}, {FUNC_TYPE_GENERAL,"nseq",nseq_main},

View File

@ -32,7 +32,7 @@ foreach (@ARGV)
push(@files,$_); push(@files,$_);
$str="\t{FUNC_TYPE_GENERAL,\"$_\",${_}_main},\n"; $str="\t{FUNC_TYPE_GENERAL,\"$_\",${_}_main},\n";
if (($_ =~ /^s_/) || ($_ =~ /^ciphers$/)) if (($_ =~ /^s_/) || ($_ =~ /^ciphers$/))
{ print "#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3))\n${str}#endif\n"; } { print "#if !defined(OPENSSL_NO_SOCK)\n${str}#endif\n"; }
elsif ( ($_ =~ /^speed$/)) elsif ( ($_ =~ /^speed$/))
{ print "#ifndef OPENSSL_NO_SPEED\n${str}#endif\n"; } { print "#ifndef OPENSSL_NO_SPEED\n${str}#endif\n"; }
elsif ( ($_ =~ /^engine$/)) elsif ( ($_ =~ /^engine$/))

View File

@ -644,6 +644,11 @@ bad:
if (inrand) if (inrand)
app_RAND_load_files(inrand); app_RAND_load_files(inrand);
if (!NCONF_get_number(req_conf,SECTION,BITS, &newkey))
{
newkey=DEFAULT_KEY_LENGTH;
}
if (keyalg) if (keyalg)
{ {
genctx = set_keygen_ctx(bio_err, keyalg, &pkey_type, &newkey, genctx = set_keygen_ctx(bio_err, keyalg, &pkey_type, &newkey,
@ -652,12 +657,6 @@ bad:
goto end; goto end;
} }
if (newkey <= 0)
{
if (!NCONF_get_number(req_conf,SECTION,BITS, &newkey))
newkey=DEFAULT_KEY_LENGTH;
}
if (newkey < MIN_KEY_LENGTH && (pkey_type == EVP_PKEY_RSA || pkey_type == EVP_PKEY_DSA)) if (newkey < MIN_KEY_LENGTH && (pkey_type == EVP_PKEY_RSA || pkey_type == EVP_PKEY_DSA))
{ {
BIO_printf(bio_err,"private key length is too short,\n"); BIO_printf(bio_err,"private key length is too short,\n");
@ -1490,7 +1489,13 @@ start:
#ifdef CHARSET_EBCDIC #ifdef CHARSET_EBCDIC
ebcdic2ascii(buf, buf, i); ebcdic2ascii(buf, buf, i);
#endif #endif
if(!req_check_len(i, n_min, n_max)) goto start; if(!req_check_len(i, n_min, n_max))
{
if (batch || value)
return 0;
goto start;
}
if (!X509_NAME_add_entry_by_NID(n,nid, chtype, if (!X509_NAME_add_entry_by_NID(n,nid, chtype,
(unsigned char *) buf, -1,-1,mval)) goto err; (unsigned char *) buf, -1,-1,mval)) goto err;
ret=1; ret=1;
@ -1549,7 +1554,12 @@ start:
#ifdef CHARSET_EBCDIC #ifdef CHARSET_EBCDIC
ebcdic2ascii(buf, buf, i); ebcdic2ascii(buf, buf, i);
#endif #endif
if(!req_check_len(i, n_min, n_max)) goto start; if(!req_check_len(i, n_min, n_max))
{
if (batch || value)
return 0;
goto start;
}
if(!X509_REQ_add1_attr_by_NID(req, nid, chtype, if(!X509_REQ_add1_attr_by_NID(req, nid, chtype,
(unsigned char *)buf, -1)) { (unsigned char *)buf, -1)) {
@ -1649,6 +1659,8 @@ static EVP_PKEY_CTX *set_keygen_ctx(BIO *err, const char *gstr, int *pkey_type,
keylen = atol(p + 1); keylen = atol(p + 1);
*pkeylen = keylen; *pkeylen = keylen;
} }
else
keylen = *pkeylen;
} }
else if (p) else if (p)
paramfile = p + 1; paramfile = p + 1;

View File

@ -148,14 +148,19 @@ typedef fd_mask fd_set;
#define PORT_STR "4433" #define PORT_STR "4433"
#define PROTOCOL "tcp" #define PROTOCOL "tcp"
int do_server(int port, int type, int *ret, int (*cb) (char *hostname, int s, unsigned char *context), unsigned char *context); int do_server(int port, int type, int *ret, int (*cb) (char *hostname, int s, int stype, unsigned char *context), unsigned char *context, int naccept);
#ifdef HEADER_X509_H #ifdef HEADER_X509_H
int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx); int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
#endif #endif
#ifdef HEADER_SSL_H #ifdef HEADER_SSL_H
int set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file); int set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file);
int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key); int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key,
STACK_OF(X509) *chain, int build_chain);
int ssl_print_sigalgs(BIO *out, SSL *s);
int ssl_print_point_formats(BIO *out, SSL *s);
int ssl_print_curves(BIO *out, SSL *s, int noshared);
#endif #endif
int ssl_print_tmp_key(BIO *out, SSL *s);
int init_client(int *sock, char *server, int port, int type); int init_client(int *sock, char *server, int port, int type);
int should_retry(int i); int should_retry(int i);
int extract_port(char *str, short *port_ptr); int extract_port(char *str, short *port_ptr);
@ -174,3 +179,23 @@ void MS_CALLBACK tlsext_cb(SSL *s, int client_server, int type,
int MS_CALLBACK generate_cookie_callback(SSL *ssl, unsigned char *cookie, unsigned int *cookie_len); int MS_CALLBACK generate_cookie_callback(SSL *ssl, unsigned char *cookie, unsigned int *cookie_len);
int MS_CALLBACK verify_cookie_callback(SSL *ssl, unsigned char *cookie, unsigned int cookie_len); int MS_CALLBACK verify_cookie_callback(SSL *ssl, unsigned char *cookie, unsigned int cookie_len);
typedef struct ssl_excert_st SSL_EXCERT;
void ssl_ctx_set_excert(SSL_CTX *ctx, SSL_EXCERT *exc);
void ssl_excert_free(SSL_EXCERT *exc);
int args_excert(char ***pargs, int *pargc,
int *badarg, BIO *err, SSL_EXCERT **pexc);
int load_excert(SSL_EXCERT **pexc, BIO *err);
void print_ssl_summary(BIO *bio, SSL *s);
#ifdef HEADER_SSL_H
int args_ssl(char ***pargs, int *pargc, SSL_CONF_CTX *cctx,
int *badarg, BIO *err, STACK_OF(OPENSSL_STRING) **pstr);
int args_ssl_call(SSL_CTX *ctx, BIO *err, SSL_CONF_CTX *cctx,
STACK_OF(OPENSSL_STRING) *str, int no_ecdhe, int no_jpake);
int ssl_ctx_add_crls(SSL_CTX *ctx, STACK_OF(X509_CRL) *crls, int crl_download);
int ssl_load_stores(SSL_CTX *ctx,
const char *vfyCApath, const char *vfyCAfile,
const char *chCApath, const char *chCAfile,
STACK_OF(X509_CRL) *crls, int crl_download);
#endif

View File

@ -125,6 +125,7 @@
#define COOKIE_SECRET_LENGTH 16 #define COOKIE_SECRET_LENGTH 16
int verify_depth=0; int verify_depth=0;
int verify_quiet=0;
int verify_error=X509_V_OK; int verify_error=X509_V_OK;
int verify_return_error=0; int verify_return_error=0;
unsigned char cookie_secret[COOKIE_SECRET_LENGTH]; unsigned char cookie_secret[COOKIE_SECRET_LENGTH];
@ -139,15 +140,19 @@ int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
err= X509_STORE_CTX_get_error(ctx); err= X509_STORE_CTX_get_error(ctx);
depth= X509_STORE_CTX_get_error_depth(ctx); depth= X509_STORE_CTX_get_error_depth(ctx);
if (!verify_quiet || !ok)
{
BIO_printf(bio_err,"depth=%d ",depth); BIO_printf(bio_err,"depth=%d ",depth);
if (err_cert) if (err_cert)
{ {
X509_NAME_print_ex(bio_err, X509_get_subject_name(err_cert), X509_NAME_print_ex(bio_err,
X509_get_subject_name(err_cert),
0, XN_FLAG_ONELINE); 0, XN_FLAG_ONELINE);
BIO_puts(bio_err, "\n"); BIO_puts(bio_err, "\n");
} }
else else
BIO_puts(bio_err, "<no cert>\n"); BIO_puts(bio_err, "<no cert>\n");
}
if (!ok) if (!ok)
{ {
BIO_printf(bio_err,"verify error:num=%d:%s\n",err, BIO_printf(bio_err,"verify error:num=%d:%s\n",err,
@ -185,12 +190,13 @@ int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
BIO_printf(bio_err,"\n"); BIO_printf(bio_err,"\n");
break; break;
case X509_V_ERR_NO_EXPLICIT_POLICY: case X509_V_ERR_NO_EXPLICIT_POLICY:
if (!verify_quiet)
policies_print(bio_err, ctx); policies_print(bio_err, ctx);
break; break;
} }
if (err == X509_V_OK && ok == 2) if (err == X509_V_OK && ok == 2 && !verify_quiet)
policies_print(bio_err, ctx); policies_print(bio_err, ctx);
if (ok && !verify_quiet)
BIO_printf(bio_err,"verify return:%d\n",ok); BIO_printf(bio_err,"verify return:%d\n",ok);
return(ok); return(ok);
} }
@ -250,8 +256,10 @@ int set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file)
return(1); return(1);
} }
int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key) int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key,
STACK_OF(X509) *chain, int build_chain)
{ {
int chflags = chain ? SSL_BUILD_CHAIN_FLAG_CHECK : 0;
if (cert == NULL) if (cert == NULL)
return 1; return 1;
if (SSL_CTX_use_certificate(ctx,cert) <= 0) if (SSL_CTX_use_certificate(ctx,cert) <= 0)
@ -260,6 +268,7 @@ int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key)
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
return 0; return 0;
} }
if (SSL_CTX_use_PrivateKey(ctx,key) <= 0) if (SSL_CTX_use_PrivateKey(ctx,key) <= 0)
{ {
BIO_printf(bio_err,"error setting private key\n"); BIO_printf(bio_err,"error setting private key\n");
@ -267,7 +276,6 @@ int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key)
return 0; return 0;
} }
/* Now we know that a key and cert have been set against /* Now we know that a key and cert have been set against
* the SSL context */ * the SSL context */
if (!SSL_CTX_check_private_key(ctx)) if (!SSL_CTX_check_private_key(ctx))
@ -275,9 +283,276 @@ int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key)
BIO_printf(bio_err,"Private key does not match the certificate public key\n"); BIO_printf(bio_err,"Private key does not match the certificate public key\n");
return 0; return 0;
} }
if (chain && !SSL_CTX_set1_chain(ctx, chain))
{
BIO_printf(bio_err,"error setting certificate chain\n");
ERR_print_errors(bio_err);
return 0;
}
if (build_chain && !SSL_CTX_build_cert_chain(ctx, chflags))
{
BIO_printf(bio_err,"error building certificate chain\n");
ERR_print_errors(bio_err);
return 0;
}
return 1; return 1;
} }
static void ssl_print_client_cert_types(BIO *bio, SSL *s)
{
const unsigned char *p;
int i;
int cert_type_num = SSL_get0_certificate_types(s, &p);
if (!cert_type_num)
return;
BIO_puts(bio, "Client Certificate Types: ");
for (i = 0; i < cert_type_num; i++)
{
unsigned char cert_type = p[i];
char *cname;
switch(cert_type)
{
case TLS_CT_RSA_SIGN:
cname = "RSA sign";
break;
case TLS_CT_DSS_SIGN:
cname = "DSA sign";
break;
case TLS_CT_RSA_FIXED_DH:
cname = "RSA fixed DH";
break;
case TLS_CT_DSS_FIXED_DH:
cname = "DSS fixed DH";
break;
case TLS_CT_ECDSA_SIGN:
cname = "ECDSA sign";
break;
case TLS_CT_RSA_FIXED_ECDH:
cname = "RSA fixed ECDH";
break;
case TLS_CT_ECDSA_FIXED_ECDH:
cname = "ECDSA fixed ECDH";
break;
case TLS_CT_GOST94_SIGN:
cname = "GOST94 Sign";
break;
case TLS_CT_GOST01_SIGN:
cname = "GOST01 Sign";
break;
default:
cname = NULL;
}
if (i)
BIO_puts(bio, ", ");
if (cname)
BIO_puts(bio, cname);
else
BIO_printf(bio, "UNKNOWN (%d),", cert_type);
}
BIO_puts(bio, "\n");
}
static int do_print_sigalgs(BIO *out, SSL *s, int shared)
{
int i, nsig, client;
client = SSL_is_server(s) ? 0 : 1;
if (shared)
nsig = SSL_get_shared_sigalgs(s, -1, NULL, NULL, NULL,
NULL, NULL);
else
nsig = SSL_get_sigalgs(s, -1, NULL, NULL, NULL, NULL, NULL);
if (nsig == 0)
return 1;
if (shared)
BIO_puts(out, "Shared ");
if (client)
BIO_puts(out, "Requested ");
BIO_puts(out, "Signature Algorithms: ");
for (i = 0; i < nsig; i++)
{
int hash_nid, sign_nid;
unsigned char rhash, rsign;
const char *sstr = NULL;
if (shared)
SSL_get_shared_sigalgs(s, i, &sign_nid, &hash_nid, NULL,
&rsign, &rhash);
else
SSL_get_sigalgs(s, i, &sign_nid, &hash_nid, NULL,
&rsign, &rhash);
if (i)
BIO_puts(out, ":");
if (sign_nid == EVP_PKEY_RSA)
sstr = "RSA";
else if(sign_nid == EVP_PKEY_DSA)
sstr = "DSA";
else if(sign_nid == EVP_PKEY_EC)
sstr = "ECDSA";
if (sstr)
BIO_printf(out,"%s+", sstr);
else
BIO_printf(out,"0x%02X+", (int)rsign);
if (hash_nid != NID_undef)
BIO_printf(out, "%s", OBJ_nid2sn(hash_nid));
else
BIO_printf(out,"0x%02X", (int)rhash);
}
BIO_puts(out, "\n");
return 1;
}
int ssl_print_sigalgs(BIO *out, SSL *s)
{
int mdnid;
if (!SSL_is_server(s))
ssl_print_client_cert_types(out, s);
do_print_sigalgs(out, s, 0);
do_print_sigalgs(out, s, 1);
if (SSL_get_peer_signature_nid(s, &mdnid))
BIO_printf(out, "Peer signing digest: %s\n", OBJ_nid2sn(mdnid));
return 1;
}
#ifndef OPENSSL_NO_EC
int ssl_print_point_formats(BIO *out, SSL *s)
{
int i, nformats;
const char *pformats;
nformats = SSL_get0_ec_point_formats(s, &pformats);
if (nformats <= 0)
return 1;
BIO_puts(out, "Supported Elliptic Curve Point Formats: ");
for (i = 0; i < nformats; i++, pformats++)
{
if (i)
BIO_puts(out, ":");
switch(*pformats)
{
case TLSEXT_ECPOINTFORMAT_uncompressed:
BIO_puts(out, "uncompressed");
break;
case TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime:
BIO_puts(out, "ansiX962_compressed_prime");
break;
case TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2:
BIO_puts(out, "ansiX962_compressed_char2");
break;
default:
BIO_printf(out, "unknown(%d)", (int)*pformats);
break;
}
}
if (nformats <= 0)
BIO_puts(out, "NONE");
BIO_puts(out, "\n");
return 1;
}
int ssl_print_curves(BIO *out, SSL *s, int noshared)
{
int i, ncurves, *curves, nid;
const char *cname;
ncurves = SSL_get1_curves(s, NULL);
if (ncurves <= 0)
return 1;
curves = OPENSSL_malloc(ncurves * sizeof(int));
SSL_get1_curves(s, curves);
BIO_puts(out, "Supported Elliptic Curves: ");
for (i = 0; i < ncurves; i++)
{
if (i)
BIO_puts(out, ":");
nid = curves[i];
/* If unrecognised print out hex version */
if (nid & TLSEXT_nid_unknown)
BIO_printf(out, "0x%04X", nid & 0xFFFF);
else
{
/* Use NIST name for curve if it exists */
cname = EC_curve_nid2nist(nid);
if (!cname)
cname = OBJ_nid2sn(nid);
BIO_printf(out, "%s", cname);
}
}
if (ncurves == 0)
BIO_puts(out, "NONE");
OPENSSL_free(curves);
if (noshared)
{
BIO_puts(out, "\n");
return 1;
}
BIO_puts(out, "\nShared Elliptic curves: ");
ncurves = SSL_get_shared_curve(s, -1);
for (i = 0; i < ncurves; i++)
{
if (i)
BIO_puts(out, ":");
nid = SSL_get_shared_curve(s, i);
cname = EC_curve_nid2nist(nid);
if (!cname)
cname = OBJ_nid2sn(nid);
BIO_printf(out, "%s", cname);
}
if (ncurves == 0)
BIO_puts(out, "NONE");
BIO_puts(out, "\n");
return 1;
}
#endif
int ssl_print_tmp_key(BIO *out, SSL *s)
{
EVP_PKEY *key;
if (!SSL_get_server_tmp_key(s, &key))
return 1;
BIO_puts(out, "Server Temp Key: ");
switch (EVP_PKEY_id(key))
{
case EVP_PKEY_RSA:
BIO_printf(out, "RSA, %d bits\n", EVP_PKEY_bits(key));
break;
case EVP_PKEY_DH:
BIO_printf(out, "DH, %d bits\n", EVP_PKEY_bits(key));
break;
#ifndef OPENSSL_NO_ECDH
case EVP_PKEY_EC:
{
EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key);
int nid;
const char *cname;
nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec));
EC_KEY_free(ec);
cname = EC_curve_nid2nist(nid);
if (!cname)
cname = OBJ_nid2sn(nid);
BIO_printf(out, "ECDH, %s, %d bits\n",
cname, EVP_PKEY_bits(key));
}
#endif
}
EVP_PKEY_free(key);
return 1;
}
long MS_CALLBACK bio_dump_callback(BIO *bio, int cmd, const char *argp, long MS_CALLBACK bio_dump_callback(BIO *bio, int cmd, const char *argp,
int argi, long argl, long ret) int argi, long argl, long ret)
{ {
@ -436,6 +711,8 @@ void MS_CALLBACK msg_cb(int write_p, int version, int content_type, const void *
if (version == SSL3_VERSION || if (version == SSL3_VERSION ||
version == TLS1_VERSION || version == TLS1_VERSION ||
version == TLS1_1_VERSION ||
version == TLS1_2_VERSION ||
version == DTLS1_VERSION || version == DTLS1_VERSION ||
version == DTLS1_BAD_VER) version == DTLS1_BAD_VER)
{ {
@ -745,6 +1022,10 @@ void MS_CALLBACK tlsext_cb(SSL *s, int client_server, int type,
break; break;
#endif #endif
case TLSEXT_TYPE_padding:
extname = "TLS padding";
break;
default: default:
extname = "unknown"; extname = "unknown";
break; break;
@ -926,3 +1207,551 @@ int MS_CALLBACK verify_cookie_callback(SSL *ssl, unsigned char *cookie, unsigned
return 0; return 0;
} }
/* Example of extended certificate handling. Where the standard support
* of one certificate per algorithm is not sufficient an application
* can decide which certificate(s) to use at runtime based on whatever
* criteria it deems appropriate.
*/
/* Linked list of certificates, keys and chains */
struct ssl_excert_st
{
int certform;
const char *certfile;
int keyform;
const char *keyfile;
const char *chainfile;
X509 *cert;
EVP_PKEY *key;
STACK_OF(X509) *chain;
int build_chain;
struct ssl_excert_st *next, *prev;
};
struct chain_flags
{
int flag;
const char *name;
};
struct chain_flags chain_flags_list[] =
{
{CERT_PKEY_VALID, "Overall Validity"},
{CERT_PKEY_SIGN, "Sign with EE key"},
{CERT_PKEY_EE_SIGNATURE, "EE signature"},
{CERT_PKEY_CA_SIGNATURE, "CA signature"},
{CERT_PKEY_EE_PARAM, "EE key parameters"},
{CERT_PKEY_CA_PARAM, "CA key parameters"},
{CERT_PKEY_EXPLICIT_SIGN, "Explicity sign with EE key"},
{CERT_PKEY_ISSUER_NAME, "Issuer Name"},
{CERT_PKEY_CERT_TYPE, "Certificate Type"},
{0, NULL}
};
static void print_chain_flags(BIO *out, int flags)
{
struct chain_flags *ctmp = chain_flags_list;
while(ctmp->name)
{
BIO_printf(out, "\t%s: %s\n", ctmp->name,
flags & ctmp->flag ? "OK" : "NOT OK");
ctmp++;
}
}
/* Very basic selection callback: just use any certificate chain
* reported as valid. More sophisticated could prioritise according
* to local policy.
*/
static int set_cert_cb(SSL *ssl, void *arg)
{
int i, rv;
SSL_EXCERT *exc = arg;
#ifdef CERT_CB_TEST_RETRY
static int retry_cnt;
if (retry_cnt < 5)
{
retry_cnt++;
fprintf(stderr, "Certificate callback retry test: count %d\n",
retry_cnt);
return -1;
}
#endif
SSL_certs_clear(ssl);
if (!exc)
return 1;
/* Go to end of list and traverse backwards since we prepend
* newer entries this retains the original order.
*/
while (exc->next)
exc = exc->next;
i = 0;
while(exc)
{
i++;
rv = SSL_check_chain(ssl, exc->cert, exc->key, exc->chain);
BIO_printf(bio_err, "Checking cert chain %d:\nSubject: ", i);
X509_NAME_print_ex(bio_err, X509_get_subject_name(exc->cert), 0,
XN_FLAG_ONELINE);
BIO_puts(bio_err, "\n");
print_chain_flags(bio_err, rv);
if (rv & CERT_PKEY_VALID)
{
SSL_use_certificate(ssl, exc->cert);
SSL_use_PrivateKey(ssl, exc->key);
/* NB: we wouldn't normally do this as it is
* not efficient building chains on each connection
* better to cache the chain in advance.
*/
if (exc->build_chain)
{
if (!SSL_build_cert_chain(ssl, 0))
return 0;
}
else if (exc->chain)
SSL_set1_chain(ssl, exc->chain);
}
exc = exc->prev;
}
return 1;
}
void ssl_ctx_set_excert(SSL_CTX *ctx, SSL_EXCERT *exc)
{
SSL_CTX_set_cert_cb(ctx, set_cert_cb, exc);
}
static int ssl_excert_prepend(SSL_EXCERT **pexc)
{
SSL_EXCERT *exc;
exc = OPENSSL_malloc(sizeof(SSL_EXCERT));
if (!exc)
return 0;
exc->certfile = NULL;
exc->keyfile = NULL;
exc->chainfile = NULL;
exc->cert = NULL;
exc->key = NULL;
exc->chain = NULL;
exc->prev = NULL;
exc->build_chain = 0;
exc->next = *pexc;
*pexc = exc;
if (exc->next)
{
exc->certform = exc->next->certform;
exc->keyform = exc->next->keyform;
exc->next->prev = exc;
}
else
{
exc->certform = FORMAT_PEM;
exc->keyform = FORMAT_PEM;
}
return 1;
}
void ssl_excert_free(SSL_EXCERT *exc)
{
SSL_EXCERT *curr;
while (exc)
{
if (exc->cert)
X509_free(exc->cert);
if (exc->key)
EVP_PKEY_free(exc->key);
if (exc->chain)
sk_X509_pop_free(exc->chain, X509_free);
curr = exc;
exc = exc->next;
OPENSSL_free(curr);
}
}
int load_excert(SSL_EXCERT **pexc, BIO *err)
{
SSL_EXCERT *exc = *pexc;
if (!exc)
return 1;
/* If nothing in list, free and set to NULL */
if (!exc->certfile && !exc->next)
{
ssl_excert_free(exc);
*pexc = NULL;
return 1;
}
for(; exc; exc=exc->next)
{
if (!exc->certfile)
{
BIO_printf(err, "Missing filename\n");
return 0;
}
exc->cert = load_cert(err, exc->certfile, exc->certform,
NULL, NULL, "Server Certificate");
if (!exc->cert)
return 0;
if (exc->keyfile)
exc->keyfile = exc->certfile;
exc->key = load_key(err, exc->certfile, exc->certform, 0,
NULL, NULL, "Server Certificate");
if (!exc->key)
return 0;
if (exc->chainfile)
{
exc->chain = load_certs(err,
exc->chainfile, FORMAT_PEM,
NULL, NULL,
"Server Chain");
if (!exc->chainfile)
return 0;
}
}
return 1;
}
int args_excert(char ***pargs, int *pargc,
int *badarg, BIO *err, SSL_EXCERT **pexc)
{
char *arg = **pargs, *argn = (*pargs)[1];
SSL_EXCERT *exc = *pexc;
int narg = 2;
if (!exc)
{
if (ssl_excert_prepend(&exc))
*pexc = exc;
else
{
BIO_printf(err, "Error initialising xcert\n");
*badarg = 1;
goto err;
}
}
if (strcmp(arg, "-xcert") == 0)
{
if (!argn)
{
*badarg = 1;
return 1;
}
if (exc->certfile && !ssl_excert_prepend(&exc))
{
BIO_printf(err, "Error adding xcert\n");
*badarg = 1;
goto err;
}
exc->certfile = argn;
}
else if (strcmp(arg,"-xkey") == 0)
{
if (!argn)
{
*badarg = 1;
return 1;
}
if (exc->keyfile)
{
BIO_printf(err, "Key already specified\n");
*badarg = 1;
return 1;
}
exc->keyfile = argn;
}
else if (strcmp(arg,"-xchain") == 0)
{
if (!argn)
{
*badarg = 1;
return 1;
}
if (exc->chainfile)
{
BIO_printf(err, "Chain already specified\n");
*badarg = 1;
return 1;
}
exc->chainfile = argn;
}
else if (strcmp(arg,"-xchain_build") == 0)
{
narg = 1;
exc->build_chain = 1;
}
else if (strcmp(arg,"-xcertform") == 0)
{
if (!argn)
{
*badarg = 1;
goto err;
}
exc->certform = str2fmt(argn);
}
else if (strcmp(arg,"-xkeyform") == 0)
{
if (!argn)
{
*badarg = 1;
goto err;
}
exc->keyform = str2fmt(argn);
}
else
return 0;
(*pargs) += narg;
if (pargc)
*pargc -= narg;
*pexc = exc;
return 1;
err:
ERR_print_errors(err);
ssl_excert_free(exc);
*pexc = NULL;
return 1;
}
static void print_raw_cipherlist(BIO *bio, SSL *s)
{
const unsigned char *rlist;
static const unsigned char scsv_id[] = {0, 0, 0xFF};
size_t i, rlistlen, num;
if (!SSL_is_server(s))
return;
num = SSL_get0_raw_cipherlist(s, NULL);
rlistlen = SSL_get0_raw_cipherlist(s, &rlist);
BIO_puts(bio, "Client cipher list: ");
for (i = 0; i < rlistlen; i += num, rlist += num)
{
const SSL_CIPHER *c = SSL_CIPHER_find(s, rlist);
if (i)
BIO_puts(bio, ":");
if (c)
BIO_puts(bio, SSL_CIPHER_get_name(c));
else if (!memcmp(rlist, scsv_id - num + 3, num))
BIO_puts(bio, "SCSV");
else
{
size_t j;
BIO_puts(bio, "0x");
for (j = 0; j < num; j++)
BIO_printf(bio, "%02X", rlist[j]);
}
}
BIO_puts(bio, "\n");
}
void print_ssl_summary(BIO *bio, SSL *s)
{
const SSL_CIPHER *c;
X509 *peer;
/*const char *pnam = SSL_is_server(s) ? "client" : "server";*/
BIO_printf(bio, "Protocol version: %s\n", SSL_get_version(s));
print_raw_cipherlist(bio, s);
c = SSL_get_current_cipher(s);
BIO_printf(bio,"Ciphersuite: %s\n", SSL_CIPHER_get_name(c));
do_print_sigalgs(bio, s, 0);
peer = SSL_get_peer_certificate(s);
if (peer)
{
int nid;
BIO_puts(bio, "Peer certificate: ");
X509_NAME_print_ex(bio, X509_get_subject_name(peer),
0, XN_FLAG_ONELINE);
BIO_puts(bio, "\n");
if (SSL_get_peer_signature_nid(s, &nid))
BIO_printf(bio, "Hash used: %s\n", OBJ_nid2sn(nid));
}
else
BIO_puts(bio, "No peer certificate\n");
if (peer)
X509_free(peer);
#ifndef OPENSSL_NO_EC
ssl_print_point_formats(bio, s);
if (SSL_is_server(s))
ssl_print_curves(bio, s, 1);
else
ssl_print_tmp_key(bio, s);
#else
if (!SSL_is_server(s))
ssl_print_tmp_key(bio, s);
#endif
}
int args_ssl(char ***pargs, int *pargc, SSL_CONF_CTX *cctx,
int *badarg, BIO *err, STACK_OF(OPENSSL_STRING) **pstr)
{
char *arg = **pargs, *argn = (*pargs)[1];
int rv;
/* Attempt to run SSL configuration command */
rv = SSL_CONF_cmd_argv(cctx, pargc, pargs);
/* If parameter not recognised just return */
if (rv == 0)
return 0;
/* see if missing argument error */
if (rv == -3)
{
BIO_printf(err, "%s needs an argument\n", arg);
*badarg = 1;
goto end;
}
/* Check for some other error */
if (rv < 0)
{
BIO_printf(err, "Error with command: \"%s %s\"\n",
arg, argn ? argn : "");
*badarg = 1;
goto end;
}
/* Store command and argument */
/* If only one argument processed store value as NULL */
if (rv == 1)
argn = NULL;
if (!*pstr)
*pstr = sk_OPENSSL_STRING_new_null();
if (!*pstr || !sk_OPENSSL_STRING_push(*pstr, arg) ||
!sk_OPENSSL_STRING_push(*pstr, argn))
{
BIO_puts(err, "Memory allocation failure\n");
goto end;
}
end:
if (*badarg)
ERR_print_errors(err);
return 1;
}
int args_ssl_call(SSL_CTX *ctx, BIO *err, SSL_CONF_CTX *cctx,
STACK_OF(OPENSSL_STRING) *str, int no_ecdhe, int no_jpake)
{
int i;
SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
for (i = 0; i < sk_OPENSSL_STRING_num(str); i+= 2)
{
const char *param = sk_OPENSSL_STRING_value(str, i);
const char *value = sk_OPENSSL_STRING_value(str, i + 1);
/* If no_ecdhe or named curve already specified don't need
* a default.
*/
if (!no_ecdhe && !strcmp(param, "-named_curve"))
no_ecdhe = 1;
#ifndef OPENSSL_NO_JPAKE
if (!no_jpake && !strcmp(param, "-cipher"))
{
BIO_puts(err, "JPAKE sets cipher to PSK\n");
return 0;
}
#endif
if (SSL_CONF_cmd(cctx, param, value) <= 0)
{
BIO_printf(err, "Error with command: \"%s %s\"\n",
param, value ? value : "");
ERR_print_errors(err);
return 0;
}
}
/* This is a special case to keep existing s_server functionality:
* if we don't have any curve specified *and* we haven't disabled
* ECDHE then use P-256.
*/
if (!no_ecdhe)
{
if (SSL_CONF_cmd(cctx, "-named_curve", "P-256") <= 0)
{
BIO_puts(err, "Error setting EC curve\n");
ERR_print_errors(err);
return 0;
}
}
#ifndef OPENSSL_NO_JPAKE
if (!no_jpake)
{
if (SSL_CONF_cmd(cctx, "-cipher", "PSK") <= 0)
{
BIO_puts(err, "Error setting cipher to PSK\n");
ERR_print_errors(err);
return 0;
}
}
#endif
if (!SSL_CONF_CTX_finish(cctx))
{
BIO_puts(err, "Error finishing context\n");
ERR_print_errors(err);
return 0;
}
return 1;
}
static int add_crls_store(X509_STORE *st, STACK_OF(X509_CRL) *crls)
{
X509_CRL *crl;
int i;
for (i = 0; i < sk_X509_CRL_num(crls); i++)
{
crl = sk_X509_CRL_value(crls, i);
X509_STORE_add_crl(st, crl);
}
return 1;
}
int ssl_ctx_add_crls(SSL_CTX *ctx, STACK_OF(X509_CRL) *crls, int crl_download)
{
X509_STORE *st;
st = SSL_CTX_get_cert_store(ctx);
add_crls_store(st, crls);
if (crl_download)
store_setup_crl_download(st);
return 1;
}
int ssl_load_stores(SSL_CTX *ctx,
const char *vfyCApath, const char *vfyCAfile,
const char *chCApath, const char *chCAfile,
STACK_OF(X509_CRL) *crls, int crl_download)
{
X509_STORE *vfy = NULL, *ch = NULL;
int rv = 0;
if (vfyCApath || vfyCAfile)
{
vfy = X509_STORE_new();
if (!X509_STORE_load_locations(vfy, vfyCAfile, vfyCApath))
goto err;
add_crls_store(vfy, crls);
SSL_CTX_set1_verify_cert_store(ctx, vfy);
if (crl_download)
store_setup_crl_download(vfy);
}
if (chCApath || chCAfile)
{
ch = X509_STORE_new();
if (!X509_STORE_load_locations(ch, chCAfile, chCApath))
goto err;
SSL_CTX_set1_chain_cert_store(ctx, ch);
}
rv = 1;
err:
if (vfy)
X509_STORE_free(vfy);
if (ch)
X509_STORE_free(ch);
return rv;
}

View File

@ -193,6 +193,7 @@ typedef unsigned int u_int;
extern int verify_depth; extern int verify_depth;
extern int verify_error; extern int verify_error;
extern int verify_return_error; extern int verify_return_error;
extern int verify_quiet;
#ifdef FIONBIO #ifdef FIONBIO
static int c_nbio=0; static int c_nbio=0;
@ -215,8 +216,10 @@ static void print_stuff(BIO *berr,SSL *con,int full);
static int ocsp_resp_cb(SSL *s, void *arg); static int ocsp_resp_cb(SSL *s, void *arg);
#endif #endif
static BIO *bio_c_out=NULL; static BIO *bio_c_out=NULL;
static BIO *bio_c_msg=NULL;
static int c_quiet=0; static int c_quiet=0;
static int c_ign_eof=0; static int c_ign_eof=0;
static int c_brief=0;
#ifndef OPENSSL_NO_PSK #ifndef OPENSSL_NO_PSK
/* Default PSK identity and key */ /* Default PSK identity and key */
@ -288,8 +291,12 @@ static void sc_usage(void)
BIO_printf(bio_err," -host host - use -connect instead\n"); BIO_printf(bio_err," -host host - use -connect instead\n");
BIO_printf(bio_err," -port port - use -connect instead\n"); BIO_printf(bio_err," -port port - use -connect instead\n");
BIO_printf(bio_err," -connect host:port - who to connect to (default is %s:%s)\n",SSL_HOST_NAME,PORT_STR); BIO_printf(bio_err," -connect host:port - who to connect to (default is %s:%s)\n",SSL_HOST_NAME,PORT_STR);
BIO_printf(bio_err," -checkhost host - check peer certificate matches \"host\"\n");
BIO_printf(bio_err," -checkemail email - check peer certificate matches \"email\"\n");
BIO_printf(bio_err," -checkip ipaddr - check peer certificate matches \"ipaddr\"\n");
BIO_printf(bio_err," -verify arg - turn on peer certificate verification\n"); BIO_printf(bio_err," -verify arg - turn on peer certificate verification\n");
BIO_printf(bio_err," -verify_return_error - return verification errors\n");
BIO_printf(bio_err," -cert arg - certificate file to use, PEM format assumed\n"); BIO_printf(bio_err," -cert arg - certificate file to use, PEM format assumed\n");
BIO_printf(bio_err," -certform arg - certificate format (PEM or DER) PEM default\n"); BIO_printf(bio_err," -certform arg - certificate format (PEM or DER) PEM default\n");
BIO_printf(bio_err," -key arg - Private key file to use, in cert file if\n"); BIO_printf(bio_err," -key arg - Private key file to use, in cert file if\n");
@ -300,6 +307,7 @@ static void sc_usage(void)
BIO_printf(bio_err," -CAfile arg - PEM format file of CA's\n"); BIO_printf(bio_err," -CAfile arg - PEM format file of CA's\n");
BIO_printf(bio_err," -reconnect - Drop and re-make the connection with the same Session-ID\n"); BIO_printf(bio_err," -reconnect - Drop and re-make the connection with the same Session-ID\n");
BIO_printf(bio_err," -pause - sleep(1) after each read(2) and write(2) system call\n"); BIO_printf(bio_err," -pause - sleep(1) after each read(2) and write(2) system call\n");
BIO_printf(bio_err," -prexit - print session information even on connection failure\n");
BIO_printf(bio_err," -showcerts - show all certificates in the chain\n"); BIO_printf(bio_err," -showcerts - show all certificates in the chain\n");
BIO_printf(bio_err," -debug - extra output\n"); BIO_printf(bio_err," -debug - extra output\n");
#ifdef WATT32 #ifdef WATT32
@ -357,10 +365,12 @@ static void sc_usage(void)
BIO_printf(bio_err," -tlsextdebug - hex dump of all TLS extensions received\n"); BIO_printf(bio_err," -tlsextdebug - hex dump of all TLS extensions received\n");
BIO_printf(bio_err," -status - request certificate status from server\n"); BIO_printf(bio_err," -status - request certificate status from server\n");
BIO_printf(bio_err," -no_ticket - disable use of RFC4507bis session tickets\n"); BIO_printf(bio_err," -no_ticket - disable use of RFC4507bis session tickets\n");
# if !defined(OPENSSL_NO_NEXTPROTONEG) BIO_printf(bio_err," -serverinfo types - send empty ClientHello extensions (comma-separated numbers)\n");
#endif
# ifndef OPENSSL_NO_NEXTPROTONEG
BIO_printf(bio_err," -nextprotoneg arg - enable NPN extension, considering named protocols supported (comma-separated list)\n"); BIO_printf(bio_err," -nextprotoneg arg - enable NPN extension, considering named protocols supported (comma-separated list)\n");
# endif # endif
#endif BIO_printf(bio_err," -alpn arg - enable ALPN extension, considering named protocols supported (comma-separated list)\n");
BIO_printf(bio_err," -legacy_renegotiation - enable use of legacy renegotiation (dangerous)\n"); BIO_printf(bio_err," -legacy_renegotiation - enable use of legacy renegotiation (dangerous)\n");
BIO_printf(bio_err," -use_srtp profiles - Offer SRTP key management with a colon-separated profile list\n"); BIO_printf(bio_err," -use_srtp profiles - Offer SRTP key management with a colon-separated profile list\n");
BIO_printf(bio_err," -keymatexport label - Export keying material using label\n"); BIO_printf(bio_err," -keymatexport label - Export keying material using label\n");
@ -536,7 +546,28 @@ static int next_proto_cb(SSL *s, unsigned char **out, unsigned char *outlen, con
ctx->status = SSL_select_next_proto(out, outlen, in, inlen, ctx->data, ctx->len); ctx->status = SSL_select_next_proto(out, outlen, in, inlen, ctx->data, ctx->len);
return SSL_TLSEXT_ERR_OK; return SSL_TLSEXT_ERR_OK;
} }
# endif # endif /* ndef OPENSSL_NO_NEXTPROTONEG */
static int serverinfo_cli_parse_cb(SSL* s, unsigned int ext_type,
const unsigned char* in, size_t inlen,
int* al, void* arg)
{
char pem_name[100];
unsigned char ext_buf[4 + 65536];
/* Reconstruct the type/len fields prior to extension data */
ext_buf[0] = ext_type >> 8;
ext_buf[1] = ext_type & 0xFF;
ext_buf[2] = inlen >> 8;
ext_buf[3] = inlen & 0xFF;
memcpy(ext_buf+4, in, inlen);
BIO_snprintf(pem_name, sizeof(pem_name), "SERVERINFO FOR EXTENSION %d",
ext_type);
PEM_write_bio(bio_c_out, pem_name, "", ext_buf, 4 + inlen);
return 1;
}
#endif #endif
enum enum
@ -553,7 +584,7 @@ int MAIN(int, char **);
int MAIN(int argc, char **argv) int MAIN(int argc, char **argv)
{ {
unsigned int off=0, clr=0; int build_chain = 0;
SSL *con=NULL; SSL *con=NULL;
#ifndef OPENSSL_NO_KRB5 #ifndef OPENSSL_NO_KRB5
KSSL_CTX *kctx; KSSL_CTX *kctx;
@ -566,13 +597,16 @@ int MAIN(int argc, char **argv)
short port=PORT; short port=PORT;
int full_log=1; int full_log=1;
char *host=SSL_HOST_NAME; char *host=SSL_HOST_NAME;
char *cert_file=NULL,*key_file=NULL; char *cert_file=NULL,*key_file=NULL,*chain_file=NULL;
int cert_format = FORMAT_PEM, key_format = FORMAT_PEM; int cert_format = FORMAT_PEM, key_format = FORMAT_PEM;
char *passarg = NULL, *pass = NULL; char *passarg = NULL, *pass = NULL;
X509 *cert = NULL; X509 *cert = NULL;
EVP_PKEY *key = NULL; EVP_PKEY *key = NULL;
char *CApath=NULL,*CAfile=NULL,*cipher=NULL; STACK_OF(X509) *chain = NULL;
int reconnect=0,badop=0,verify=SSL_VERIFY_NONE,bugs=0; char *CApath=NULL,*CAfile=NULL;
char *chCApath=NULL,*chCAfile=NULL;
char *vfyCApath=NULL,*vfyCAfile=NULL;
int reconnect=0,badop=0,verify=SSL_VERIFY_NONE;
int crlf=0; int crlf=0;
int write_tty,read_tty,write_ssl,read_ssl,tty_on,ssl_pending; int write_tty,read_tty,write_ssl,read_ssl,tty_on,ssl_pending;
SSL_CTX *ctx=NULL; SSL_CTX *ctx=NULL;
@ -606,6 +640,10 @@ int MAIN(int argc, char **argv)
# ifndef OPENSSL_NO_NEXTPROTONEG # ifndef OPENSSL_NO_NEXTPROTONEG
const char *next_proto_neg_in = NULL; const char *next_proto_neg_in = NULL;
# endif # endif
const char *alpn_in = NULL;
# define MAX_SI_TYPES 100
unsigned short serverinfo_types[MAX_SI_TYPES];
int serverinfo_types_count = 0;
#endif #endif
char *sess_in = NULL; char *sess_in = NULL;
char *sess_out = NULL; char *sess_out = NULL;
@ -614,13 +652,25 @@ int MAIN(int argc, char **argv)
int enable_timeouts = 0 ; int enable_timeouts = 0 ;
long socket_mtu = 0; long socket_mtu = 0;
#ifndef OPENSSL_NO_JPAKE #ifndef OPENSSL_NO_JPAKE
char *jpake_secret = NULL; static char *jpake_secret = NULL;
#define no_jpake !jpake_secret
#else
#define no_jpake 1
#endif #endif
#ifndef OPENSSL_NO_SRP #ifndef OPENSSL_NO_SRP
char * srppass = NULL; char * srppass = NULL;
int srp_lateuser = 0; int srp_lateuser = 0;
SRP_ARG srp_arg = {NULL,NULL,0,0,0,1024}; SRP_ARG srp_arg = {NULL,NULL,0,0,0,1024};
#endif #endif
SSL_EXCERT *exc = NULL;
SSL_CONF_CTX *cctx = NULL;
STACK_OF(OPENSSL_STRING) *ssl_args = NULL;
char *crl_file = NULL;
int crl_format = FORMAT_PEM;
int crl_download = 0;
STACK_OF(X509_CRL) *crls = NULL;
meth=SSLv23_client_method(); meth=SSLv23_client_method();
@ -638,6 +688,12 @@ int MAIN(int argc, char **argv)
if (!load_config(bio_err, NULL)) if (!load_config(bio_err, NULL))
goto end; goto end;
cctx = SSL_CONF_CTX_new();
if (!cctx)
goto end;
SSL_CONF_CTX_set_flags(cctx, SSL_CONF_FLAG_CLIENT);
SSL_CONF_CTX_set_flags(cctx, SSL_CONF_FLAG_CMDLINE);
if ( ((cbuf=OPENSSL_malloc(BUFSIZZ)) == NULL) || if ( ((cbuf=OPENSSL_malloc(BUFSIZZ)) == NULL) ||
((sbuf=OPENSSL_malloc(BUFSIZZ)) == NULL) || ((sbuf=OPENSSL_malloc(BUFSIZZ)) == NULL) ||
((mbuf=OPENSSL_malloc(BUFSIZZ)) == NULL)) ((mbuf=OPENSSL_malloc(BUFSIZZ)) == NULL))
@ -678,6 +734,7 @@ int MAIN(int argc, char **argv)
verify=SSL_VERIFY_PEER; verify=SSL_VERIFY_PEER;
if (--argc < 1) goto bad; if (--argc < 1) goto bad;
verify_depth=atoi(*(++argv)); verify_depth=atoi(*(++argv));
if (!c_quiet)
BIO_printf(bio_err,"verify depth is %d\n",verify_depth); BIO_printf(bio_err,"verify depth is %d\n",verify_depth);
} }
else if (strcmp(*argv,"-cert") == 0) else if (strcmp(*argv,"-cert") == 0)
@ -685,6 +742,13 @@ int MAIN(int argc, char **argv)
if (--argc < 1) goto bad; if (--argc < 1) goto bad;
cert_file= *(++argv); cert_file= *(++argv);
} }
else if (strcmp(*argv,"-CRL") == 0)
{
if (--argc < 1) goto bad;
crl_file= *(++argv);
}
else if (strcmp(*argv,"-crl_download") == 0)
crl_download = 1;
else if (strcmp(*argv,"-sess_out") == 0) else if (strcmp(*argv,"-sess_out") == 0)
{ {
if (--argc < 1) goto bad; if (--argc < 1) goto bad;
@ -700,6 +764,11 @@ int MAIN(int argc, char **argv)
if (--argc < 1) goto bad; if (--argc < 1) goto bad;
cert_format = str2fmt(*(++argv)); cert_format = str2fmt(*(++argv));
} }
else if (strcmp(*argv,"-CRLform") == 0)
{
if (--argc < 1) goto bad;
crl_format = str2fmt(*(++argv));
}
else if (args_verify(&argv, &argc, &badarg, bio_err, &vpm)) else if (args_verify(&argv, &argc, &badarg, bio_err, &vpm))
{ {
if (badarg) if (badarg)
@ -708,6 +777,26 @@ int MAIN(int argc, char **argv)
} }
else if (strcmp(*argv,"-verify_return_error") == 0) else if (strcmp(*argv,"-verify_return_error") == 0)
verify_return_error = 1; verify_return_error = 1;
else if (strcmp(*argv,"-verify_quiet") == 0)
verify_quiet = 1;
else if (strcmp(*argv,"-brief") == 0)
{
c_brief = 1;
verify_quiet = 1;
c_quiet = 1;
}
else if (args_excert(&argv, &argc, &badarg, bio_err, &exc))
{
if (badarg)
goto bad;
continue;
}
else if (args_ssl(&argv, &argc, cctx, &badarg, bio_err, &ssl_args))
{
if (badarg)
goto bad;
continue;
}
else if (strcmp(*argv,"-prexit") == 0) else if (strcmp(*argv,"-prexit") == 0)
prexit=1; prexit=1;
else if (strcmp(*argv,"-crlf") == 0) else if (strcmp(*argv,"-crlf") == 0)
@ -737,6 +826,15 @@ int MAIN(int argc, char **argv)
#endif #endif
else if (strcmp(*argv,"-msg") == 0) else if (strcmp(*argv,"-msg") == 0)
c_msg=1; c_msg=1;
else if (strcmp(*argv,"-msgfile") == 0)
{
if (--argc < 1) goto bad;
bio_c_msg = BIO_new_file(*(++argv), "w");
}
#ifndef OPENSSL_NO_SSL_TRACE
else if (strcmp(*argv,"-trace") == 0)
c_msg=2;
#endif
else if (strcmp(*argv,"-showcerts") == 0) else if (strcmp(*argv,"-showcerts") == 0)
c_showcerts=1; c_showcerts=1;
else if (strcmp(*argv,"-nbio_test") == 0) else if (strcmp(*argv,"-nbio_test") == 0)
@ -812,11 +910,21 @@ int MAIN(int argc, char **argv)
meth=TLSv1_client_method(); meth=TLSv1_client_method();
#endif #endif
#ifndef OPENSSL_NO_DTLS1 #ifndef OPENSSL_NO_DTLS1
else if (strcmp(*argv,"-dtls") == 0)
{
meth=DTLS_client_method();
socket_type=SOCK_DGRAM;
}
else if (strcmp(*argv,"-dtls1") == 0) else if (strcmp(*argv,"-dtls1") == 0)
{ {
meth=DTLSv1_client_method(); meth=DTLSv1_client_method();
socket_type=SOCK_DGRAM; socket_type=SOCK_DGRAM;
} }
else if (strcmp(*argv,"-dtls1_2") == 0)
{
meth=DTLSv1_2_client_method();
socket_type=SOCK_DGRAM;
}
else if (strcmp(*argv,"-timeout") == 0) else if (strcmp(*argv,"-timeout") == 0)
enable_timeouts=1; enable_timeouts=1;
else if (strcmp(*argv,"-mtu") == 0) else if (strcmp(*argv,"-mtu") == 0)
@ -825,8 +933,6 @@ int MAIN(int argc, char **argv)
socket_mtu = atol(*(++argv)); socket_mtu = atol(*(++argv));
} }
#endif #endif
else if (strcmp(*argv,"-bugs") == 0)
bugs=1;
else if (strcmp(*argv,"-keyform") == 0) else if (strcmp(*argv,"-keyform") == 0)
{ {
if (--argc < 1) goto bad; if (--argc < 1) goto bad;
@ -837,6 +943,11 @@ int MAIN(int argc, char **argv)
if (--argc < 1) goto bad; if (--argc < 1) goto bad;
passarg = *(++argv); passarg = *(++argv);
} }
else if (strcmp(*argv,"-cert_chain") == 0)
{
if (--argc < 1) goto bad;
chain_file= *(++argv);
}
else if (strcmp(*argv,"-key") == 0) else if (strcmp(*argv,"-key") == 0)
{ {
if (--argc < 1) goto bad; if (--argc < 1) goto bad;
@ -851,26 +962,34 @@ int MAIN(int argc, char **argv)
if (--argc < 1) goto bad; if (--argc < 1) goto bad;
CApath= *(++argv); CApath= *(++argv);
} }
else if (strcmp(*argv,"-chainCApath") == 0)
{
if (--argc < 1) goto bad;
chCApath= *(++argv);
}
else if (strcmp(*argv,"-verifyCApath") == 0)
{
if (--argc < 1) goto bad;
vfyCApath= *(++argv);
}
else if (strcmp(*argv,"-build_chain") == 0)
build_chain = 1;
else if (strcmp(*argv,"-CAfile") == 0) else if (strcmp(*argv,"-CAfile") == 0)
{ {
if (--argc < 1) goto bad; if (--argc < 1) goto bad;
CAfile= *(++argv); CAfile= *(++argv);
} }
else if (strcmp(*argv,"-no_tls1_2") == 0) else if (strcmp(*argv,"-chainCAfile") == 0)
off|=SSL_OP_NO_TLSv1_2; {
else if (strcmp(*argv,"-no_tls1_1") == 0) if (--argc < 1) goto bad;
off|=SSL_OP_NO_TLSv1_1; chCAfile= *(++argv);
else if (strcmp(*argv,"-no_tls1") == 0) }
off|=SSL_OP_NO_TLSv1; else if (strcmp(*argv,"-verifyCAfile") == 0)
else if (strcmp(*argv,"-no_ssl3") == 0) {
off|=SSL_OP_NO_SSLv3; if (--argc < 1) goto bad;
else if (strcmp(*argv,"-no_ssl2") == 0) vfyCAfile= *(++argv);
off|=SSL_OP_NO_SSLv2; }
else if (strcmp(*argv,"-no_comp") == 0)
{ off|=SSL_OP_NO_COMPRESSION; }
#ifndef OPENSSL_NO_TLSEXT #ifndef OPENSSL_NO_TLSEXT
else if (strcmp(*argv,"-no_ticket") == 0)
{ off|=SSL_OP_NO_TICKET; }
# ifndef OPENSSL_NO_NEXTPROTONEG # ifndef OPENSSL_NO_NEXTPROTONEG
else if (strcmp(*argv,"-nextprotoneg") == 0) else if (strcmp(*argv,"-nextprotoneg") == 0)
{ {
@ -878,20 +997,35 @@ int MAIN(int argc, char **argv)
next_proto_neg_in = *(++argv); next_proto_neg_in = *(++argv);
} }
# endif # endif
#endif else if (strcmp(*argv,"-alpn") == 0)
else if (strcmp(*argv,"-serverpref") == 0)
off|=SSL_OP_CIPHER_SERVER_PREFERENCE;
else if (strcmp(*argv,"-legacy_renegotiation") == 0)
off|=SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION;
else if (strcmp(*argv,"-legacy_server_connect") == 0)
{ off|=SSL_OP_LEGACY_SERVER_CONNECT; }
else if (strcmp(*argv,"-no_legacy_server_connect") == 0)
{ clr|=SSL_OP_LEGACY_SERVER_CONNECT; }
else if (strcmp(*argv,"-cipher") == 0)
{ {
if (--argc < 1) goto bad; if (--argc < 1) goto bad;
cipher= *(++argv); alpn_in = *(++argv);
} }
else if (strcmp(*argv,"-serverinfo") == 0)
{
char *c;
int start = 0;
int len;
if (--argc < 1) goto bad;
c = *(++argv);
serverinfo_types_count = 0;
len = strlen(c);
for (i = 0; i <= len; ++i)
{
if (i == len || c[i] == ',')
{
serverinfo_types[serverinfo_types_count]
= atoi(c+start);
serverinfo_types_count++;
start = i+1;
}
if (serverinfo_types_count == MAX_SI_TYPES)
break;
}
}
#endif
#ifdef FIONBIO #ifdef FIONBIO
else if (strcmp(*argv,"-nbio") == 0) else if (strcmp(*argv,"-nbio") == 0)
{ c_nbio=1; } { c_nbio=1; }
@ -987,12 +1121,6 @@ bad:
goto end; goto end;
} }
psk_identity = "JPAKE"; psk_identity = "JPAKE";
if (cipher)
{
BIO_printf(bio_err, "JPAKE sets cipher to PSK\n");
goto end;
}
cipher = "PSK";
} }
#endif #endif
@ -1065,6 +1193,37 @@ bad:
} }
} }
if (chain_file)
{
chain = load_certs(bio_err, chain_file,FORMAT_PEM,
NULL, e, "client certificate chain");
if (!chain)
goto end;
}
if (crl_file)
{
X509_CRL *crl;
crl = load_crl(crl_file, crl_format);
if (!crl)
{
BIO_puts(bio_err, "Error loading CRL\n");
ERR_print_errors(bio_err);
goto end;
}
crls = sk_X509_CRL_new_null();
if (!crls || !sk_X509_CRL_push(crls, crl))
{
BIO_puts(bio_err, "Error adding CRL\n");
ERR_print_errors(bio_err);
X509_CRL_free(crl);
goto end;
}
}
if (!load_excert(&exc, bio_err))
goto end;
if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL
&& !RAND_status()) && !RAND_status())
{ {
@ -1076,9 +1235,11 @@ bad:
if (bio_c_out == NULL) if (bio_c_out == NULL)
{ {
if (c_quiet && !c_debug && !c_msg) if (c_quiet && !c_debug)
{ {
bio_c_out=BIO_new(BIO_s_null()); bio_c_out=BIO_new(BIO_s_null());
if (c_msg && !bio_c_msg)
bio_c_msg=BIO_new_fp(stdout,BIO_NOCLOSE);
} }
else else
{ {
@ -1105,6 +1266,20 @@ bad:
if (vpm) if (vpm)
SSL_CTX_set1_param(ctx, vpm); SSL_CTX_set1_param(ctx, vpm);
if (!args_ssl_call(ctx, bio_err, cctx, ssl_args, 1, no_jpake))
{
ERR_print_errors(bio_err);
goto end;
}
if (!ssl_load_stores(ctx, vfyCApath, vfyCAfile, chCApath, chCAfile,
crls, crl_download))
{
BIO_printf(bio_err, "Error loading store locations\n");
ERR_print_errors(bio_err);
goto end;
}
#ifndef OPENSSL_NO_ENGINE #ifndef OPENSSL_NO_ENGINE
if (ssl_client_engine) if (ssl_client_engine)
{ {
@ -1133,38 +1308,49 @@ bad:
if (srtp_profiles != NULL) if (srtp_profiles != NULL)
SSL_CTX_set_tlsext_use_srtp(ctx, srtp_profiles); SSL_CTX_set_tlsext_use_srtp(ctx, srtp_profiles);
#endif #endif
if (bugs) if (exc) ssl_ctx_set_excert(ctx, exc);
SSL_CTX_set_options(ctx,SSL_OP_ALL|off);
else
SSL_CTX_set_options(ctx,off);
if (clr)
SSL_CTX_clear_options(ctx, clr);
/* DTLS: partial reads end up discarding unread UDP bytes :-( /* DTLS: partial reads end up discarding unread UDP bytes :-(
* Setting read ahead solves this problem. * Setting read ahead solves this problem.
*/ */
if (socket_type == SOCK_DGRAM) SSL_CTX_set_read_ahead(ctx, 1); if (socket_type == SOCK_DGRAM) SSL_CTX_set_read_ahead(ctx, 1);
#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) #if !defined(OPENSSL_NO_TLSEXT)
# if !defined(OPENSSL_NO_NEXTPROTONEG)
if (next_proto.data) if (next_proto.data)
SSL_CTX_set_next_proto_select_cb(ctx, next_proto_cb, &next_proto); SSL_CTX_set_next_proto_select_cb(ctx, next_proto_cb, &next_proto);
# endif # endif
if (alpn_in)
{
unsigned short alpn_len;
unsigned char *alpn = next_protos_parse(&alpn_len, alpn_in);
if (state) SSL_CTX_set_info_callback(ctx,apps_ssl_info_callback); if (alpn == NULL)
if (cipher != NULL) {
if(!SSL_CTX_set_cipher_list(ctx,cipher)) { BIO_printf(bio_err, "Error parsing -alpn argument\n");
BIO_printf(bio_err,"error setting cipher list\n");
ERR_print_errors(bio_err);
goto end; goto end;
} }
SSL_CTX_set_alpn_protos(ctx, alpn, alpn_len);
OPENSSL_free(alpn);
}
#endif
#ifndef OPENSSL_NO_TLSEXT
for (i = 0; i < serverinfo_types_count; i++)
{
SSL_CTX_add_client_custom_ext(ctx,
serverinfo_types[i],
NULL, NULL, NULL,
serverinfo_cli_parse_cb,
NULL);
}
#endif
if (state) SSL_CTX_set_info_callback(ctx,apps_ssl_info_callback);
#if 0 #if 0
else else
SSL_CTX_set_cipher_list(ctx,getenv("SSL_CIPHER")); SSL_CTX_set_cipher_list(ctx,getenv("SSL_CIPHER"));
#endif #endif
SSL_CTX_set_verify(ctx,verify,verify_callback); SSL_CTX_set_verify(ctx,verify,verify_callback);
if (!set_cert_key_stuff(ctx,cert,key))
goto end;
if ((!SSL_CTX_load_verify_locations(ctx,CAfile,CApath)) || if ((!SSL_CTX_load_verify_locations(ctx,CAfile,CApath)) ||
(!SSL_CTX_set_default_verify_paths(ctx))) (!SSL_CTX_set_default_verify_paths(ctx)))
@ -1174,6 +1360,10 @@ bad:
/* goto end; */ /* goto end; */
} }
ssl_ctx_add_crls(ctx, crls, crl_download);
if (!set_cert_key_stuff(ctx,cert,key,chain,build_chain))
goto end;
#ifndef OPENSSL_NO_TLSEXT #ifndef OPENSSL_NO_TLSEXT
if (servername != NULL) if (servername != NULL)
{ {
@ -1274,7 +1464,7 @@ re_start:
#endif #endif
if (c_Pause & 0x01) SSL_set_debug(con, 1); if (c_Pause & 0x01) SSL_set_debug(con, 1);
if ( SSL_version(con) == DTLS1_VERSION) if (socket_type == SOCK_DGRAM)
{ {
sbio=BIO_new_dgram(s,BIO_NOCLOSE); sbio=BIO_new_dgram(s,BIO_NOCLOSE);
@ -1327,8 +1517,13 @@ re_start:
} }
if (c_msg) if (c_msg)
{ {
#ifndef OPENSSL_NO_SSL_TRACE
if (c_msg == 2)
SSL_set_msg_callback(con, SSL_trace);
else
#endif
SSL_set_msg_callback(con, msg_cb); SSL_set_msg_callback(con, msg_cb);
SSL_set_msg_callback_arg(con, bio_c_out); SSL_set_msg_callback_arg(con, bio_c_msg ? bio_c_msg : bio_c_out);
} }
#ifndef OPENSSL_NO_TLSEXT #ifndef OPENSSL_NO_TLSEXT
if (c_tlsextdebug) if (c_tlsextdebug)
@ -1528,6 +1723,13 @@ SSL_set_tlsext_status_ids(con, ids);
else else
BIO_printf(bio_err, "Error writing session file %s\n", sess_out); BIO_printf(bio_err, "Error writing session file %s\n", sess_out);
} }
if (c_brief)
{
BIO_puts(bio_err,
"CONNECTION ESTABLISHED\n");
print_ssl_summary(bio_err, con);
}
print_stuff(bio_c_out,con,full_log); print_stuff(bio_c_out,con,full_log);
if (full_log > 0) full_log--; if (full_log > 0) full_log--;
@ -1790,6 +1992,9 @@ printf("read=%d pending=%d peek=%d\n",k,SSL_pending(con),SSL_peek(con,zbuf,10240
break; break;
case SSL_ERROR_SYSCALL: case SSL_ERROR_SYSCALL:
ret=get_last_socket_error(); ret=get_last_socket_error();
if (c_brief)
BIO_puts(bio_err, "CONNECTION CLOSED BY SERVER\n");
else
BIO_printf(bio_err,"read:errno=%d\n",ret); BIO_printf(bio_err,"read:errno=%d\n",ret);
goto shut; goto shut;
case SSL_ERROR_ZERO_RETURN: case SSL_ERROR_ZERO_RETURN:
@ -1890,13 +2095,32 @@ end:
print_stuff(bio_c_out,con,1); print_stuff(bio_c_out,con,1);
SSL_free(con); SSL_free(con);
} }
#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
if (next_proto.data)
OPENSSL_free(next_proto.data);
#endif
if (ctx != NULL) SSL_CTX_free(ctx); if (ctx != NULL) SSL_CTX_free(ctx);
if (cert) if (cert)
X509_free(cert); X509_free(cert);
if (crls)
sk_X509_CRL_pop_free(crls, X509_CRL_free);
if (key) if (key)
EVP_PKEY_free(key); EVP_PKEY_free(key);
if (chain)
sk_X509_pop_free(chain, X509_free);
if (pass) if (pass)
OPENSSL_free(pass); OPENSSL_free(pass);
if (vpm)
X509_VERIFY_PARAM_free(vpm);
ssl_excert_free(exc);
if (ssl_args)
sk_OPENSSL_STRING_free(ssl_args);
if (cctx)
SSL_CONF_CTX_free(cctx);
#ifndef OPENSSL_NO_JPAKE
if (jpake_secret && psk_key)
OPENSSL_free(psk_key);
#endif
if (cbuf != NULL) { OPENSSL_cleanse(cbuf,BUFSIZZ); OPENSSL_free(cbuf); } if (cbuf != NULL) { OPENSSL_cleanse(cbuf,BUFSIZZ); OPENSSL_free(cbuf); }
if (sbuf != NULL) { OPENSSL_cleanse(sbuf,BUFSIZZ); OPENSSL_free(sbuf); } if (sbuf != NULL) { OPENSSL_cleanse(sbuf,BUFSIZZ); OPENSSL_free(sbuf); }
if (mbuf != NULL) { OPENSSL_cleanse(mbuf,BUFSIZZ); OPENSSL_free(mbuf); } if (mbuf != NULL) { OPENSSL_cleanse(mbuf,BUFSIZZ); OPENSSL_free(mbuf); }
@ -1905,6 +2129,11 @@ end:
BIO_free(bio_c_out); BIO_free(bio_c_out);
bio_c_out=NULL; bio_c_out=NULL;
} }
if (bio_c_msg != NULL)
{
BIO_free(bio_c_msg);
bio_c_msg=NULL;
}
apps_shutdown(); apps_shutdown();
OPENSSL_EXIT(ret); OPENSSL_EXIT(ret);
} }
@ -2011,6 +2240,9 @@ static void print_stuff(BIO *bio, SSL *s, int full)
BIO_write(bio,"\n",1); BIO_write(bio,"\n",1);
} }
ssl_print_sigalgs(bio, s);
ssl_print_tmp_key(bio, s);
BIO_printf(bio,"---\nSSL handshake has read %ld bytes and written %ld bytes\n", BIO_printf(bio,"---\nSSL handshake has read %ld bytes and written %ld bytes\n",
BIO_number_read(SSL_get_rbio(s)), BIO_number_read(SSL_get_rbio(s)),
BIO_number_written(SSL_get_wbio(s))); BIO_number_written(SSL_get_wbio(s)));
@ -2050,7 +2282,8 @@ static void print_stuff(BIO *bio, SSL *s, int full)
} }
#endif #endif
#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) #if !defined(OPENSSL_NO_TLSEXT)
# if !defined(OPENSSL_NO_NEXTPROTONEG)
if (next_proto.status != -1) { if (next_proto.status != -1) {
const unsigned char *proto; const unsigned char *proto;
unsigned int proto_len; unsigned int proto_len;
@ -2060,6 +2293,20 @@ static void print_stuff(BIO *bio, SSL *s, int full)
BIO_write(bio, "\n", 1); BIO_write(bio, "\n", 1);
} }
# endif # endif
{
const unsigned char *proto;
unsigned int proto_len;
SSL_get0_alpn_selected(s, &proto, &proto_len);
if (proto_len > 0)
{
BIO_printf(bio, "ALPN protocol: ");
BIO_write(bio, proto, proto_len);
BIO_write(bio, "\n", 1);
}
else
BIO_printf(bio, "No ALPN negotiated\n");
}
#endif
{ {
SRTP_PROTECTION_PROFILE *srtp_profile=SSL_get_selected_srtp_profile(s); SRTP_PROTECTION_PROFILE *srtp_profile=SSL_get_selected_srtp_profile(s);

File diff suppressed because it is too large Load Diff

View File

@ -274,7 +274,7 @@ static int init_client_ip(int *sock, unsigned char ip[4], int port, int type)
{ {
i=0; i=0;
i=setsockopt(s,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i)); i=setsockopt(s,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i));
if (i < 0) { perror("keepalive"); return(0); } if (i < 0) { closesocket(s); perror("keepalive"); return(0); }
} }
#endif #endif
@ -284,7 +284,7 @@ static int init_client_ip(int *sock, unsigned char ip[4], int port, int type)
return(1); return(1);
} }
int do_server(int port, int type, int *ret, int (*cb)(char *hostname, int s, unsigned char *context), unsigned char *context) int do_server(int port, int type, int *ret, int (*cb)(char *hostname, int s, int stype, unsigned char *context), unsigned char *context, int naccept)
{ {
int sock; int sock;
char *name = NULL; char *name = NULL;
@ -310,11 +310,13 @@ int do_server(int port, int type, int *ret, int (*cb)(char *hostname, int s, uns
} }
else else
sock = accept_socket; sock = accept_socket;
i=(*cb)(name,sock, context); i=(*cb)(name,sock, type, context);
if (name != NULL) OPENSSL_free(name); if (name != NULL) OPENSSL_free(name);
if (type==SOCK_STREAM) if (type==SOCK_STREAM)
SHUTDOWN2(sock); SHUTDOWN2(sock);
if (i < 0) if (naccept != -1)
naccept--;
if (i < 0 || naccept == 0)
{ {
SHUTDOWN2(accept_socket); SHUTDOWN2(accept_socket);
return(i); return(i);
@ -450,6 +452,7 @@ redoit:
if ((*host=(char *)OPENSSL_malloc(strlen(h1->h_name)+1)) == NULL) if ((*host=(char *)OPENSSL_malloc(strlen(h1->h_name)+1)) == NULL)
{ {
perror("OPENSSL_malloc"); perror("OPENSSL_malloc");
closesocket(ret);
return(0); return(0);
} }
BUF_strlcpy(*host,h1->h_name,strlen(h1->h_name)+1); BUF_strlcpy(*host,h1->h_name,strlen(h1->h_name)+1);
@ -458,11 +461,13 @@ redoit:
if (h2 == NULL) if (h2 == NULL)
{ {
BIO_printf(bio_err,"gethostbyname failure\n"); BIO_printf(bio_err,"gethostbyname failure\n");
closesocket(ret);
return(0); return(0);
} }
if (h2->h_addrtype != AF_INET) if (h2->h_addrtype != AF_INET)
{ {
BIO_printf(bio_err,"gethostbyname addr is not AF_INET\n"); BIO_printf(bio_err,"gethostbyname addr is not AF_INET\n");
closesocket(ret);
return(0); return(0);
} }
} }

View File

@ -541,8 +541,8 @@ int MAIN(int argc, char **argv)
{ {
if (!cipher) if (!cipher)
{ {
#ifndef OPENSSL_NO_RC2 #ifndef OPENSSL_NO_DES
cipher = EVP_rc2_40_cbc(); cipher = EVP_des_ede3_cbc();
#else #else
BIO_printf(bio_err, "No cipher selected\n"); BIO_printf(bio_err, "No cipher selected\n");
goto end; goto end;
@ -704,6 +704,14 @@ int MAIN(int argc, char **argv)
p7 = PKCS7_sign(NULL, NULL, other, in, flags); p7 = PKCS7_sign(NULL, NULL, other, in, flags);
if (!p7) if (!p7)
goto end; goto end;
if (flags & PKCS7_NOCERTS)
{
for (i = 0; i < sk_X509_num(other); i++)
{
X509 *x = sk_X509_value(other, i);
PKCS7_add_certificate(p7, x);
}
}
} }
else else
flags |= PKCS7_REUSE_DIGEST; flags |= PKCS7_REUSE_DIGEST;

View File

@ -357,6 +357,7 @@ static void *KDF1_SHA1(const void *in, size_t inlen, void *out, size_t *outlen)
} }
#endif /* OPENSSL_NO_ECDH */ #endif /* OPENSSL_NO_ECDH */
static void multiblock_speed(const EVP_CIPHER *evp_cipher);
int MAIN(int, char **); int MAIN(int, char **);
@ -629,6 +630,7 @@ int MAIN(int argc, char **argv)
#ifndef NO_FORK #ifndef NO_FORK
int multi=0; int multi=0;
#endif #endif
int multiblock=0;
#ifndef TIMES #ifndef TIMES
usertime=-1; usertime=-1;
@ -777,6 +779,11 @@ int MAIN(int argc, char **argv)
j--; /* Otherwise, -mr gets confused with j--; /* Otherwise, -mr gets confused with
an algorithm. */ an algorithm. */
} }
else if (argc > 0 && !strcmp(*argv,"-mb"))
{
multiblock=1;
j--;
}
else else
#ifndef OPENSSL_NO_MD2 #ifndef OPENSSL_NO_MD2
if (strcmp(*argv,"md2") == 0) doit[D_MD2]=1; if (strcmp(*argv,"md2") == 0) doit[D_MD2]=1;
@ -1949,6 +1956,19 @@ int MAIN(int argc, char **argv)
if (doit[D_EVP]) if (doit[D_EVP])
{ {
#ifdef EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK
if (multiblock && evp_cipher)
{
if (!(EVP_CIPHER_flags(evp_cipher)&EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK))
{
fprintf(stderr,"%s is not multi-block capable\n",OBJ_nid2ln(evp_cipher->nid));
goto end;
}
multiblock_speed(evp_cipher);
mret=0;
goto end;
}
#endif
for (j=0; j<SIZE_NUM; j++) for (j=0; j<SIZE_NUM; j++)
{ {
if (evp_cipher) if (evp_cipher)
@ -2839,4 +2859,109 @@ static int do_multi(int multi)
return 1; return 1;
} }
#endif #endif
static void multiblock_speed(const EVP_CIPHER *evp_cipher)
{
static int mblengths[]={8*1024,2*8*1024,4*8*1024,8*8*1024,8*16*1024};
int j,count,num=sizeof(lengths)/sizeof(lengths[0]);
const char *alg_name;
unsigned char *inp,*out,no_key[32],no_iv[16];
EVP_CIPHER_CTX ctx;
double d=0.0;
inp = OPENSSL_malloc(mblengths[num-1]);
out = OPENSSL_malloc(mblengths[num-1]+1024);
EVP_CIPHER_CTX_init(&ctx);
EVP_EncryptInit_ex(&ctx,evp_cipher,NULL,no_key,no_iv);
EVP_CIPHER_CTX_ctrl(&ctx,EVP_CTRL_AEAD_SET_MAC_KEY,sizeof(no_key),no_key);
alg_name=OBJ_nid2ln(evp_cipher->nid);
for (j=0; j<num; j++)
{
print_message(alg_name,0,mblengths[j]);
Time_F(START);
for (count=0,run=1; run && count<0x7fffffff; count++)
{
unsigned char aad[13];
EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM mb_param;
size_t len = mblengths[j];
int packlen;
memset(aad,0,8);/* avoid uninitialized values */
aad[8] = 23; /* SSL3_RT_APPLICATION_DATA */
aad[9] = 3; /* version */
aad[10] = 2;
aad[11] = 0; /* length */
aad[12] = 0;
mb_param.out = NULL;
mb_param.inp = aad;
mb_param.len = len;
mb_param.interleave = 8;
packlen=EVP_CIPHER_CTX_ctrl(&ctx,
EVP_CTRL_TLS1_1_MULTIBLOCK_AAD,
sizeof(mb_param),&mb_param);
if (packlen>0)
{
mb_param.out = out;
mb_param.inp = inp;
mb_param.len = len;
EVP_CIPHER_CTX_ctrl(&ctx,
EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT,
sizeof(mb_param),&mb_param);
}
else
{
int pad;
RAND_bytes(out,16);
len+=16;
aad[11] = len>>8;
aad[12] = len;
pad=EVP_CIPHER_CTX_ctrl(&ctx,
EVP_CTRL_AEAD_TLS1_AAD,13,aad);
EVP_Cipher(&ctx,out,inp,len+pad);
}
}
d=Time_F(STOP);
BIO_printf(bio_err,mr ? "+R:%d:%s:%f\n"
: "%d %s's in %.2fs\n",count,"evp",d);
results[D_EVP][j]=((double)count)/d*mblengths[j];
}
if (mr)
{
fprintf(stdout,"+H");
for (j=0; j<num; j++)
fprintf(stdout,":%d",mblengths[j]);
fprintf(stdout,"\n");
fprintf(stdout,"+F:%d:%s",D_EVP,alg_name);
for (j=0; j<num; j++)
fprintf(stdout,":%.2f",results[D_EVP][j]);
fprintf(stdout,"\n");
}
else
{
fprintf(stdout,"The 'numbers' are in 1000s of bytes per second processed.\n");
fprintf(stdout,"type ");
for (j=0; j<num; j++)
fprintf(stdout,"%7d bytes",mblengths[j]);
fprintf(stdout,"\n");
fprintf(stdout,"%-24s",alg_name);
for (j=0; j<num; j++)
{
if (results[D_EVP][j] > 10000)
fprintf(stdout," %11.2fk",results[D_EVP][j]/1e3);
else
fprintf(stdout," %11.2f ",results[D_EVP][j]);
}
fprintf(stdout,"\n");
}
OPENSSL_free(inp);
OPENSSL_free(out);
}
#endif #endif

View File

@ -125,13 +125,13 @@ static int get_index(CA_DB *db, char* id, char type)
if (type == DB_SRP_INDEX) if (type == DB_SRP_INDEX)
for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++)
{ {
pp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, i); pp = sk_OPENSSL_PSTRING_value(db->db->data,i);
if (pp[DB_srptype][0] == DB_SRP_INDEX && !strcmp(id,pp[DB_srpid])) if (pp[DB_srptype][0] == DB_SRP_INDEX && !strcmp(id,pp[DB_srpid]))
return i; return i;
} }
else for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) else for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++)
{ {
pp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, i); pp = sk_OPENSSL_PSTRING_value(db->db->data,i);
if (pp[DB_srptype][0] != DB_SRP_INDEX && !strcmp(id,pp[DB_srpid])) if (pp[DB_srptype][0] != DB_SRP_INDEX && !strcmp(id,pp[DB_srpid]))
return i; return i;
@ -145,7 +145,7 @@ static void print_entry(CA_DB *db, BIO *bio, int indx, int verbose, char *s)
if (indx >= 0 && verbose) if (indx >= 0 && verbose)
{ {
int j; int j;
char **pp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, indx); char **pp = sk_OPENSSL_PSTRING_value(db->db->data, indx);
BIO_printf(bio, "%s \"%s\"\n", s, pp[DB_srpid]); BIO_printf(bio, "%s \"%s\"\n", s, pp[DB_srpid]);
for (j = 0; j < DB_NUMBER; j++) for (j = 0; j < DB_NUMBER; j++)
{ {
@ -163,7 +163,7 @@ static void print_user(CA_DB *db, BIO *bio, int userindex, int verbose)
{ {
if (verbose > 0) if (verbose > 0)
{ {
char **pp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, userindex); char **pp = sk_OPENSSL_PSTRING_value(db->db->data,userindex);
if (pp[DB_srptype][0] != 'I') if (pp[DB_srptype][0] != 'I')
{ {
@ -517,7 +517,7 @@ bad:
/* Lets check some fields */ /* Lets check some fields */
for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++)
{ {
pp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, i); pp = sk_OPENSSL_PSTRING_value(db->db->data, i);
if (pp[DB_srptype][0] == DB_SRP_INDEX) if (pp[DB_srptype][0] == DB_SRP_INDEX)
{ {
@ -533,7 +533,7 @@ bad:
if (gNindex >= 0) if (gNindex >= 0)
{ {
gNrow = (char **)sk_OPENSSL_PSTRING_value(db->db->data, gNindex); gNrow = sk_OPENSSL_PSTRING_value(db->db->data,gNindex);
print_entry(db, bio_err, gNindex, verbose > 1, "Default g and N"); print_entry(db, bio_err, gNindex, verbose > 1, "Default g and N");
} }
else if (maxgN > 0 && !SRP_get_default_gN(gN)) else if (maxgN > 0 && !SRP_get_default_gN(gN))
@ -587,7 +587,7 @@ bad:
if (userindex >= 0) if (userindex >= 0)
{ {
/* reactivation of a new user */ /* reactivation of a new user */
char **row = (char **)sk_OPENSSL_PSTRING_value(db->db->data, userindex); char **row = sk_OPENSSL_PSTRING_value(db->db->data, userindex);
BIO_printf(bio_err, "user \"%s\" reactivated.\n", user); BIO_printf(bio_err, "user \"%s\" reactivated.\n", user);
row[DB_srptype][0] = 'V'; row[DB_srptype][0] = 'V';
@ -634,7 +634,7 @@ bad:
else else
{ {
char **row = (char **)sk_OPENSSL_PSTRING_value(db->db->data, userindex); char **row = sk_OPENSSL_PSTRING_value(db->db->data, userindex);
char type = row[DB_srptype][0]; char type = row[DB_srptype][0];
if (type == 'v') if (type == 'v')
{ {
@ -689,7 +689,7 @@ bad:
} }
else else
{ {
char **xpp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, userindex); char **xpp = sk_OPENSSL_PSTRING_value(db->db->data,userindex);
BIO_printf(bio_err, "user \"%s\" revoked. t\n", user); BIO_printf(bio_err, "user \"%s\" revoked. t\n", user);
xpp[DB_srptype][0] = 'R'; xpp[DB_srptype][0] = 'R';
@ -714,7 +714,7 @@ bad:
/* Lets check some fields */ /* Lets check some fields */
for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++)
{ {
pp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, i); pp = sk_OPENSSL_PSTRING_value(db->db->data,i);
if (pp[DB_srptype][0] == 'v') if (pp[DB_srptype][0] == 'v')
{ {

View File

@ -88,6 +88,7 @@ int MAIN(int argc, char **argv)
X509_STORE *cert_ctx=NULL; X509_STORE *cert_ctx=NULL;
X509_LOOKUP *lookup=NULL; X509_LOOKUP *lookup=NULL;
X509_VERIFY_PARAM *vpm = NULL; X509_VERIFY_PARAM *vpm = NULL;
int crl_download = 0;
#ifndef OPENSSL_NO_ENGINE #ifndef OPENSSL_NO_ENGINE
char *engine=NULL; char *engine=NULL;
#endif #endif
@ -145,6 +146,8 @@ int MAIN(int argc, char **argv)
if (argc-- < 1) goto end; if (argc-- < 1) goto end;
crlfile= *(++argv); crlfile= *(++argv);
} }
else if (strcmp(*argv,"-crl_download") == 0)
crl_download = 1;
#ifndef OPENSSL_NO_ENGINE #ifndef OPENSSL_NO_ENGINE
else if (strcmp(*argv,"-engine") == 0) else if (strcmp(*argv,"-engine") == 0)
{ {
@ -222,11 +225,22 @@ int MAIN(int argc, char **argv)
goto end; goto end;
} }
if (argc < 1) check(cert_ctx, NULL, untrusted, trusted, crls, e);
else
for (i=0; i<argc; i++)
check(cert_ctx,argv[i], untrusted, trusted, crls, e);
ret = 0; ret = 0;
if (crl_download)
store_setup_crl_download(cert_ctx);
if (argc < 1)
{
if (1 != check(cert_ctx, NULL, untrusted, trusted, crls, e))
ret = -1;
}
else
{
for (i=0; i<argc; i++)
if (1 != check(cert_ctx,argv[i], untrusted, trusted, crls, e))
ret = -1;
}
end: end:
if (ret == 1) { if (ret == 1) {
BIO_printf(bio_err,"usage: verify [-verbose] [-CApath path] [-CAfile file] [-purpose purpose] [-crl_check]"); BIO_printf(bio_err,"usage: verify [-verbose] [-CApath path] [-CAfile file] [-purpose purpose] [-crl_check]");
@ -235,11 +249,14 @@ end:
BIO_printf(bio_err," [-engine e]"); BIO_printf(bio_err," [-engine e]");
#endif #endif
BIO_printf(bio_err," cert1 cert2 ...\n"); BIO_printf(bio_err," cert1 cert2 ...\n");
BIO_printf(bio_err,"recognized usages:\n"); BIO_printf(bio_err,"recognized usages:\n");
for(i = 0; i < X509_PURPOSE_get_count(); i++) { for(i = 0; i < X509_PURPOSE_get_count(); i++)
{
X509_PURPOSE *ptmp; X509_PURPOSE *ptmp;
ptmp = X509_PURPOSE_get0(i); ptmp = X509_PURPOSE_get0(i);
BIO_printf(bio_err, "\t%-10s\t%s\n", X509_PURPOSE_get0_sname(ptmp), BIO_printf(bio_err, "\t%-10s\t%s\n",
X509_PURPOSE_get0_sname(ptmp),
X509_PURPOSE_get0_name(ptmp)); X509_PURPOSE_get0_name(ptmp));
} }
} }
@ -249,7 +266,7 @@ end:
sk_X509_pop_free(trusted, X509_free); sk_X509_pop_free(trusted, X509_free);
sk_X509_CRL_pop_free(crls, X509_CRL_free); sk_X509_CRL_pop_free(crls, X509_CRL_free);
apps_shutdown(); apps_shutdown();
OPENSSL_EXIT(ret); OPENSSL_EXIT(ret < 0 ? 2 : ret);
} }
static int check(X509_STORE *ctx, char *file, static int check(X509_STORE *ctx, char *file,

View File

@ -150,6 +150,9 @@ static const char *x509_usage[]={
" -engine e - use engine e, possibly a hardware device.\n", " -engine e - use engine e, possibly a hardware device.\n",
#endif #endif
" -certopt arg - various certificate text options\n", " -certopt arg - various certificate text options\n",
" -checkhost host - check certificate matches \"host\"\n",
" -checkemail email - check certificate matches \"email\"\n",
" -checkip ipaddr - check certificate matches \"ipaddr\"\n",
NULL NULL
}; };
@ -163,6 +166,9 @@ static int x509_certify (X509_STORE *ctx,char *CAfile,const EVP_MD *digest,
CONF *conf, char *section, ASN1_INTEGER *sno); CONF *conf, char *section, ASN1_INTEGER *sno);
static int purpose_print(BIO *bio, X509 *cert, X509_PURPOSE *pt); static int purpose_print(BIO *bio, X509 *cert, X509_PURPOSE *pt);
static int reqfile=0; static int reqfile=0;
#ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
static int force_version=2;
#endif
int MAIN(int, char **); int MAIN(int, char **);
@ -174,15 +180,16 @@ int MAIN(int argc, char **argv)
X509 *x=NULL,*xca=NULL; X509 *x=NULL,*xca=NULL;
ASN1_OBJECT *objtmp; ASN1_OBJECT *objtmp;
STACK_OF(OPENSSL_STRING) *sigopts = NULL; STACK_OF(OPENSSL_STRING) *sigopts = NULL;
EVP_PKEY *Upkey=NULL,*CApkey=NULL; EVP_PKEY *Upkey=NULL,*CApkey=NULL, *fkey = NULL;
ASN1_INTEGER *sno = NULL; ASN1_INTEGER *sno = NULL;
int i,num,badops=0; int i,num,badops=0, badsig=0;
BIO *out=NULL; BIO *out=NULL;
BIO *STDout=NULL; BIO *STDout=NULL;
STACK_OF(ASN1_OBJECT) *trust = NULL, *reject = NULL; STACK_OF(ASN1_OBJECT) *trust = NULL, *reject = NULL;
int informat,outformat,keyformat,CAformat,CAkeyformat; int informat,outformat,keyformat,CAformat,CAkeyformat;
char *infile=NULL,*outfile=NULL,*keyfile=NULL,*CAfile=NULL; char *infile=NULL,*outfile=NULL,*keyfile=NULL,*CAfile=NULL;
char *CAkeyfile=NULL,*CAserial=NULL; char *CAkeyfile=NULL,*CAserial=NULL;
char *fkeyfile=NULL;
char *alias=NULL; char *alias=NULL;
int text=0,serial=0,subject=0,issuer=0,startdate=0,enddate=0; int text=0,serial=0,subject=0,issuer=0,startdate=0,enddate=0;
int next_serial=0; int next_serial=0;
@ -207,6 +214,9 @@ int MAIN(int argc, char **argv)
int need_rand = 0; int need_rand = 0;
int checkend=0,checkoffset=0; int checkend=0,checkoffset=0;
unsigned long nmflag = 0, certflag = 0; unsigned long nmflag = 0, certflag = 0;
char *checkhost = NULL;
char *checkemail = NULL;
char *checkip = NULL;
#ifndef OPENSSL_NO_ENGINE #ifndef OPENSSL_NO_ENGINE
char *engine=NULL; char *engine=NULL;
#endif #endif
@ -282,13 +292,20 @@ int MAIN(int argc, char **argv)
if (!sigopts || !sk_OPENSSL_STRING_push(sigopts, *(++argv))) if (!sigopts || !sk_OPENSSL_STRING_push(sigopts, *(++argv)))
goto bad; goto bad;
} }
#ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
else if (strcmp(*argv,"-force_version") == 0)
{
if (--argc < 1) goto bad;
force_version=atoi(*(++argv)) - 1;
}
#endif
else if (strcmp(*argv,"-days") == 0) else if (strcmp(*argv,"-days") == 0)
{ {
if (--argc < 1) goto bad; if (--argc < 1) goto bad;
days=atoi(*(++argv)); days=atoi(*(++argv));
if (days == 0) if (days == 0)
{ {
BIO_printf(STDout,"bad number of days\n"); BIO_printf(bio_err,"bad number of days\n");
goto bad; goto bad;
} }
} }
@ -347,6 +364,11 @@ int MAIN(int argc, char **argv)
if (!(sno = s2i_ASN1_INTEGER(NULL, *(++argv)))) if (!(sno = s2i_ASN1_INTEGER(NULL, *(++argv))))
goto bad; goto bad;
} }
else if (strcmp(*argv,"-force_pubkey") == 0)
{
if (--argc < 1) goto bad;
fkeyfile= *(++argv);
}
else if (strcmp(*argv,"-addtrust") == 0) else if (strcmp(*argv,"-addtrust") == 0)
{ {
if (--argc < 1) goto bad; if (--argc < 1) goto bad;
@ -450,6 +472,21 @@ int MAIN(int argc, char **argv)
checkoffset=atoi(*(++argv)); checkoffset=atoi(*(++argv));
checkend=1; checkend=1;
} }
else if (strcmp(*argv,"-checkhost") == 0)
{
if (--argc < 1) goto bad;
checkhost=*(++argv);
}
else if (strcmp(*argv,"-checkemail") == 0)
{
if (--argc < 1) goto bad;
checkemail=*(++argv);
}
else if (strcmp(*argv,"-checkip") == 0)
{
if (--argc < 1) goto bad;
checkip=*(++argv);
}
else if (strcmp(*argv,"-noout") == 0) else if (strcmp(*argv,"-noout") == 0)
noout= ++num; noout= ++num;
else if (strcmp(*argv,"-trustout") == 0) else if (strcmp(*argv,"-trustout") == 0)
@ -473,6 +510,8 @@ int MAIN(int argc, char **argv)
#endif #endif
else if (strcmp(*argv,"-ocspid") == 0) else if (strcmp(*argv,"-ocspid") == 0)
ocspid= ++num; ocspid= ++num;
else if (strcmp(*argv,"-badsig") == 0)
badsig = 1;
else if ((md_alg=EVP_get_digestbyname(*argv + 1))) else if ((md_alg=EVP_get_digestbyname(*argv + 1)))
{ {
/* ok */ /* ok */
@ -517,6 +556,13 @@ bad:
goto end; goto end;
} }
if (fkeyfile)
{
fkey = load_pubkey(bio_err, fkeyfile, keyformat, 0,
NULL, e, "Forced key");
if (fkey == NULL) goto end;
}
if ((CAkeyfile == NULL) && (CA_flag) && (CAformat == FORMAT_PEM)) if ((CAkeyfile == NULL) && (CA_flag) && (CAformat == FORMAT_PEM))
{ CAkeyfile=CAfile; } { CAkeyfile=CAfile; }
else if ((CA_flag) && (CAkeyfile == NULL)) else if ((CA_flag) && (CAkeyfile == NULL))
@ -653,11 +699,15 @@ bad:
X509_gmtime_adj(X509_get_notBefore(x),0); X509_gmtime_adj(X509_get_notBefore(x),0);
X509_time_adj_ex(X509_get_notAfter(x),days, 0, NULL); X509_time_adj_ex(X509_get_notAfter(x),days, 0, NULL);
if (fkey)
X509_set_pubkey(x, fkey);
else
{
pkey = X509_REQ_get_pubkey(req); pkey = X509_REQ_get_pubkey(req);
X509_set_pubkey(x,pkey); X509_set_pubkey(x,pkey);
EVP_PKEY_free(pkey); EVP_PKEY_free(pkey);
} }
}
else else
x=load_cert(bio_err,infile,informat,NULL,e,"Certificate"); x=load_cert(bio_err,infile,informat,NULL,e,"Certificate");
@ -912,7 +962,7 @@ bad:
} }
else if (text == i) else if (text == i)
{ {
X509_print_ex(out,x,nmflag, certflag); X509_print_ex(STDout,x,nmflag, certflag);
} }
else if (startdate == i) else if (startdate == i)
{ {
@ -1044,12 +1094,17 @@ bad:
goto end; goto end;
} }
print_cert_checks(STDout, x, checkhost, checkemail, checkip);
if (noout) if (noout)
{ {
ret=0; ret=0;
goto end; goto end;
} }
if (badsig)
x->signature->data[x->signature->length - 1] ^= 0x1;
if (outformat == FORMAT_ASN1) if (outformat == FORMAT_ASN1)
i=i2d_X509_bio(out,x); i=i2d_X509_bio(out,x);
else if (outformat == FORMAT_PEM) else if (outformat == FORMAT_PEM)
@ -1093,6 +1148,7 @@ end:
X509_free(xca); X509_free(xca);
EVP_PKEY_free(Upkey); EVP_PKEY_free(Upkey);
EVP_PKEY_free(CApkey); EVP_PKEY_free(CApkey);
EVP_PKEY_free(fkey);
if (sigopts) if (sigopts)
sk_OPENSSL_STRING_free(sigopts); sk_OPENSSL_STRING_free(sigopts);
X509_REQ_free(rq); X509_REQ_free(rq);
@ -1202,7 +1258,11 @@ static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest,
if (conf) if (conf)
{ {
X509V3_CTX ctx2; X509V3_CTX ctx2;
#ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
X509_set_version(x, force_version);
#else
X509_set_version(x,2); /* version 3 certificate */ X509_set_version(x,2); /* version 3 certificate */
#endif
X509V3_set_ctx(&ctx2, xca, x, NULL, NULL, 0); X509V3_set_ctx(&ctx2, xca, x, NULL, NULL, 0);
X509V3_set_nconf(&ctx2, conf); X509V3_set_nconf(&ctx2, conf);
if (!X509V3_EXT_add_nconf(conf, &ctx2, section, x)) goto end; if (!X509V3_EXT_add_nconf(conf, &ctx2, section, x)) goto end;
@ -1280,7 +1340,11 @@ static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext, const EVP_MD *dig
if (conf) if (conf)
{ {
X509V3_CTX ctx; X509V3_CTX ctx;
#ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
X509_set_version(x, force_version);
#else
X509_set_version(x,2); /* version 3 certificate */ X509_set_version(x,2); /* version 3 certificate */
#endif
X509V3_set_ctx(&ctx, x, x, NULL, NULL, 0); X509V3_set_ctx(&ctx, x, x, NULL, NULL, 0);
X509V3_set_nconf(&ctx, conf); X509V3_set_nconf(&ctx, conf);
if (!X509V3_EXT_add_nconf(conf, &ctx, section, x)) goto err; if (!X509V3_EXT_add_nconf(conf, &ctx, section, x)) goto err;

21
config
View File

@ -587,15 +587,33 @@ case "$GUESSOS" in
fi fi
;; ;;
ppc64-*-linux2) ppc64-*-linux2)
if [ -z "$KERNEL_BITS" ]; then
echo "WARNING! If you wish to build 64-bit library, then you have to" echo "WARNING! If you wish to build 64-bit library, then you have to"
echo " invoke './Configure linux-ppc64' *manually*." echo " invoke './Configure linux-ppc64' *manually*."
if [ "$TEST" = "false" -a -t 1 ]; then if [ "$TEST" = "false" -a -t 1 ]; then
echo " You have about 5 seconds to press Ctrl-C to abort." echo " You have about 5 seconds to press Ctrl-C to abort."
(trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1 (trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
fi fi
fi
if [ "$KERNEL_BITS" = "64" ]; then
OUT="linux-ppc64"
else
OUT="linux-ppc" OUT="linux-ppc"
(echo "__LP64__" | gcc -E -x c - 2>/dev/null | grep "^__LP64__" 2>&1 > /dev/null) || options="$options -m32"
fi
;; ;;
ppc64le-*-linux2) OUT="linux-ppc64le" ;;
ppc-*-linux2) OUT="linux-ppc" ;; ppc-*-linux2) OUT="linux-ppc" ;;
mips64*-*-linux2)
echo "WARNING! If you wish to build 64-bit library, then you have to"
echo " invoke './Configure linux64-mips64' *manually*."
if [ "$TEST" = "false" -a -t 1 ]; then
echo " You have about 5 seconds to press Ctrl-C to abort."
(trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
fi
OUT="linux-mips64"
;;
mips*-*-linux2) OUT="linux-mips32" ;;
ppc60x-*-vxworks*) OUT="vxworks-ppc60x" ;; ppc60x-*-vxworks*) OUT="vxworks-ppc60x" ;;
ppcgen-*-vxworks*) OUT="vxworks-ppcgen" ;; ppcgen-*-vxworks*) OUT="vxworks-ppcgen" ;;
pentium-*-vxworks*) OUT="vxworks-pentium" ;; pentium-*-vxworks*) OUT="vxworks-pentium" ;;
@ -644,6 +662,7 @@ case "$GUESSOS" in
armv[1-3]*-*-linux2) OUT="linux-generic32" ;; armv[1-3]*-*-linux2) OUT="linux-generic32" ;;
armv[7-9]*-*-linux2) OUT="linux-armv4"; options="$options -march=armv7-a" ;; armv[7-9]*-*-linux2) OUT="linux-armv4"; options="$options -march=armv7-a" ;;
arm*-*-linux2) OUT="linux-armv4" ;; arm*-*-linux2) OUT="linux-armv4" ;;
aarch64-*-linux2) OUT="linux-aarch64" ;;
sh*b-*-linux2) OUT="linux-generic32"; options="$options -DB_ENDIAN" ;; sh*b-*-linux2) OUT="linux-generic32"; options="$options -DB_ENDIAN" ;;
sh*-*-linux2) OUT="linux-generic32"; options="$options -DL_ENDIAN" ;; sh*-*-linux2) OUT="linux-generic32"; options="$options -DL_ENDIAN" ;;
m68k*-*-linux2) OUT="linux-generic32"; options="$options -DB_ENDIAN" ;; m68k*-*-linux2) OUT="linux-generic32"; options="$options -DB_ENDIAN" ;;
@ -739,7 +758,7 @@ case "$GUESSOS" in
libc=/usr/lib/libc.so libc=/usr/lib/libc.so
else # OpenBSD else # OpenBSD
# ld searches for highest libc.so.* and so do we # ld searches for highest libc.so.* and so do we
libc=`(ls /usr/lib/libc.so.* | tail -1) 2>/dev/null` libc=`(ls /usr/lib/libc.so.* /lib/libc.so.* | tail -1) 2>/dev/null`
fi fi
case "`(file -L $libc) 2>/dev/null`" in case "`(file -L $libc) 2>/dev/null`" in
*ELF*) OUT="BSD-x86-elf" ;; *ELF*) OUT="BSD-x86-elf" ;;

View File

@ -1,4 +1,3 @@
/* $LP: LPlib/source/LPdir_vms.c,v 1.20 2004/08/26 13:36:05 _cvs_levitte Exp $ */
/* /*
* Copyright (c) 2004, Richard Levitte <richard@levitte.org> * Copyright (c) 2004, Richard Levitte <richard@levitte.org>
* All rights reserved. * All rights reserved.
@ -88,6 +87,12 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
size_t filespeclen = strlen(directory); size_t filespeclen = strlen(directory);
char *filespec = NULL; char *filespec = NULL;
if (filespeclen == 0)
{
errno = ENOENT;
return 0;
}
/* MUST be a VMS directory specification! Let's estimate if it is. */ /* MUST be a VMS directory specification! Let's estimate if it is. */
if (directory[filespeclen-1] != ']' if (directory[filespeclen-1] != ']'
&& directory[filespeclen-1] != '>' && directory[filespeclen-1] != '>'

View File

@ -1,4 +1,3 @@
/* $LP: LPlib/source/LPdir_win.c,v 1.10 2004/08/26 13:36:05 _cvs_levitte Exp $ */
/* /*
* Copyright (c) 2004, Richard Levitte <richard@levitte.org> * Copyright (c) 2004, Richard Levitte <richard@levitte.org>
* All rights reserved. * All rights reserved.
@ -63,6 +62,16 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
errno = 0; errno = 0;
if (*ctx == NULL) if (*ctx == NULL)
{ {
const char *extdir = directory;
char *extdirbuf = NULL;
size_t dirlen = strlen (directory);
if (dirlen == 0)
{
errno = ENOENT;
return 0;
}
*ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX)); *ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX));
if (*ctx == NULL) if (*ctx == NULL)
{ {
@ -71,15 +80,35 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
} }
memset(*ctx, '\0', sizeof(LP_DIR_CTX)); memset(*ctx, '\0', sizeof(LP_DIR_CTX));
if (directory[dirlen-1] != '*')
{
extdirbuf = (char *)malloc(dirlen + 3);
if (extdirbuf == NULL)
{
free(*ctx);
*ctx = NULL;
errno = ENOMEM;
return 0;
}
if (directory[dirlen-1] != '/' && directory[dirlen-1] != '\\')
extdir = strcat(strcpy (extdirbuf,directory),"/*");
else
extdir = strcat(strcpy (extdirbuf,directory),"*");
}
if (sizeof(TCHAR) != sizeof(char)) if (sizeof(TCHAR) != sizeof(char))
{ {
TCHAR *wdir = NULL; TCHAR *wdir = NULL;
/* len_0 denotes string length *with* trailing 0 */ /* len_0 denotes string length *with* trailing 0 */
size_t index = 0,len_0 = strlen(directory) + 1; size_t index = 0,len_0 = strlen(extdir) + 1;
wdir = (TCHAR *)malloc(len_0 * sizeof(TCHAR)); wdir = (TCHAR *)calloc(len_0, sizeof(TCHAR));
if (wdir == NULL) if (wdir == NULL)
{ {
if (extdirbuf != NULL)
{
free (extdirbuf);
}
free(*ctx); free(*ctx);
*ctx = NULL; *ctx = NULL;
errno = ENOMEM; errno = ENOMEM;
@ -87,17 +116,23 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
} }
#ifdef LP_MULTIBYTE_AVAILABLE #ifdef LP_MULTIBYTE_AVAILABLE
if (!MultiByteToWideChar(CP_ACP, 0, directory, len_0, (WCHAR *)wdir, len_0)) if (!MultiByteToWideChar(CP_ACP, 0, extdir, len_0, (WCHAR *)wdir, len_0))
#endif #endif
for (index = 0; index < len_0; index++) for (index = 0; index < len_0; index++)
wdir[index] = (TCHAR)directory[index]; wdir[index] = (TCHAR)extdir[index];
(*ctx)->handle = FindFirstFile(wdir, &(*ctx)->ctx); (*ctx)->handle = FindFirstFile(wdir, &(*ctx)->ctx);
free(wdir); free(wdir);
} }
else else
(*ctx)->handle = FindFirstFile((TCHAR *)directory, &(*ctx)->ctx); {
(*ctx)->handle = FindFirstFile((TCHAR *)extdir, &(*ctx)->ctx);
}
if (extdirbuf != NULL)
{
free (extdirbuf);
}
if ((*ctx)->handle == INVALID_HANDLE_VALUE) if ((*ctx)->handle == INVALID_HANDLE_VALUE)
{ {
@ -114,7 +149,6 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
return 0; return 0;
} }
} }
if (sizeof(TCHAR) != sizeof(char)) if (sizeof(TCHAR) != sizeof(char))
{ {
TCHAR *wdir = (*ctx)->ctx.cFileName; TCHAR *wdir = (*ctx)->ctx.cFileName;

View File

@ -31,6 +31,7 @@ CPUID_OBJ=mem_clr.o
LIBS= LIBS=
GENERAL=Makefile README crypto-lib.com install.com GENERAL=Makefile README crypto-lib.com install.com
TEST=constant_time_test.c
LIB= $(TOP)/libcrypto.a LIB= $(TOP)/libcrypto.a
SHARED_LIB= libcrypto$(SHLIB_EXT) SHARED_LIB= libcrypto$(SHLIB_EXT)
@ -43,7 +44,8 @@ SRC= $(LIBSRC)
EXHEADER= crypto.h opensslv.h opensslconf.h ebcdic.h symhacks.h \ EXHEADER= crypto.h opensslv.h opensslconf.h ebcdic.h symhacks.h \
ossl_typ.h ossl_typ.h
HEADER= cryptlib.h buildinf.h md32_common.h o_time.h o_str.h o_dir.h $(EXHEADER) HEADER= cryptlib.h buildinf.h md32_common.h o_time.h o_str.h o_dir.h \
constant_time_locl.h $(EXHEADER)
ALL= $(GENERAL) $(SRC) $(HEADER) ALL= $(GENERAL) $(SRC) $(HEADER)
@ -77,7 +79,9 @@ ia64cpuid.s: ia64cpuid.S; $(CC) $(CFLAGS) -E ia64cpuid.S > $@
ppccpuid.s: ppccpuid.pl; $(PERL) ppccpuid.pl $(PERLASM_SCHEME) $@ ppccpuid.s: ppccpuid.pl; $(PERL) ppccpuid.pl $(PERLASM_SCHEME) $@
pariscid.s: pariscid.pl; $(PERL) pariscid.pl $(PERLASM_SCHEME) $@ pariscid.s: pariscid.pl; $(PERL) pariscid.pl $(PERLASM_SCHEME) $@
alphacpuid.s: alphacpuid.pl alphacpuid.s: alphacpuid.pl
$(PERL) $< | $(CC) -E - | tee $@ > /dev/null (preproc=$$$$.$@.S; trap "rm $$preproc" INT; \
$(PERL) alphacpuid.pl > $$preproc && \
$(CC) -E -P $$preproc > $@ && rm $$preproc)
testapps: testapps:
[ -z "$(THIS)" ] || ( if echo $(SDIRS) | fgrep ' des '; \ [ -z "$(THIS)" ] || ( if echo $(SDIRS) | fgrep ' des '; \
@ -89,7 +93,7 @@ subdirs:
@target=all; $(RECURSIVE_MAKE) @target=all; $(RECURSIVE_MAKE)
files: files:
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl "CPUID_OBJ=$(CPUID_OBJ)" Makefile >> $(TOP)/MINFO
@target=files; $(RECURSIVE_MAKE) @target=files; $(RECURSIVE_MAKE)
links: links:
@ -103,7 +107,7 @@ lib: $(LIB)
@touch lib @touch lib
$(LIB): $(LIBOBJ) $(LIB): $(LIBOBJ)
$(AR) $(LIB) $(LIBOBJ) $(AR) $(LIB) $(LIBOBJ)
[ -z "$(FIPSLIBDIR)" ] || $(AR) $(LIB) $(FIPSLIBDIR)fipscanister.o test -z "$(FIPSLIBDIR)" || $(AR) $(LIB) $(FIPSLIBDIR)fipscanister.o
$(RANLIB) $(LIB) || echo Never mind. $(RANLIB) $(LIB) || echo Never mind.
shared: buildinf.h lib subdirs shared: buildinf.h lib subdirs

View File

@ -3,3 +3,6 @@ Makefile.save
*.flc *.flc
semantic.cache semantic.cache
aes-*.s aes-*.s
aesni-*.s
bsaes-*.s
vpaes-*.s

View File

@ -65,12 +65,22 @@ aesni-x86_64.s: asm/aesni-x86_64.pl
$(PERL) asm/aesni-x86_64.pl $(PERLASM_SCHEME) > $@ $(PERL) asm/aesni-x86_64.pl $(PERLASM_SCHEME) > $@
aesni-sha1-x86_64.s: asm/aesni-sha1-x86_64.pl aesni-sha1-x86_64.s: asm/aesni-sha1-x86_64.pl
$(PERL) asm/aesni-sha1-x86_64.pl $(PERLASM_SCHEME) > $@ $(PERL) asm/aesni-sha1-x86_64.pl $(PERLASM_SCHEME) > $@
aesni-sha256-x86_64.s: asm/aesni-sha256-x86_64.pl
$(PERL) asm/aesni-sha256-x86_64.pl $(PERLASM_SCHEME) > $@
aesni-mb-x86_64.s: asm/aesni-mb-x86_64.pl
$(PERL) asm/aesni-mb-x86_64.pl $(PERLASM_SCHEME) > $@
aes-sparcv9.s: asm/aes-sparcv9.pl aes-sparcv9.s: asm/aes-sparcv9.pl
$(PERL) asm/aes-sparcv9.pl $(CFLAGS) > $@ $(PERL) asm/aes-sparcv9.pl $(CFLAGS) > $@
aest4-sparcv9.s: asm/aest4-sparcv9.pl
$(PERL) asm/aest4-sparcv9.pl $(CFLAGS) > $@
aes-ppc.s: asm/aes-ppc.pl aes-ppc.s: asm/aes-ppc.pl
$(PERL) asm/aes-ppc.pl $(PERLASM_SCHEME) $@ $(PERL) asm/aes-ppc.pl $(PERLASM_SCHEME) $@
vpaes-ppc.s: asm/vpaes-ppc.pl
$(PERL) asm/vpaes-ppc.pl $(PERLASM_SCHEME) $@
aesp8-ppc.s: asm/aesp8-ppc.pl
$(PERL) asm/aesp8-ppc.pl $(PERLASM_SCHEME) $@
aes-parisc.s: asm/aes-parisc.pl aes-parisc.s: asm/aes-parisc.pl
$(PERL) asm/aes-parisc.pl $(PERLASM_SCHEME) $@ $(PERL) asm/aes-parisc.pl $(PERLASM_SCHEME) $@
@ -78,12 +88,18 @@ aes-parisc.s: asm/aes-parisc.pl
aes-mips.S: asm/aes-mips.pl aes-mips.S: asm/aes-mips.pl
$(PERL) asm/aes-mips.pl $(PERLASM_SCHEME) $@ $(PERL) asm/aes-mips.pl $(PERLASM_SCHEME) $@
aesv8-armx.S: asm/aesv8-armx.pl
$(PERL) asm/aesv8-armx.pl $(PERLASM_SCHEME) $@
aesv8-armx.o: aesv8-armx.S
# GNU make "catch all" # GNU make "catch all"
aes-%.S: asm/aes-%.pl; $(PERL) $< $(PERLASM_SCHEME) > $@ aes-%.S: asm/aes-%.pl; $(PERL) $< $(PERLASM_SCHEME) > $@
aes-armv4.o: aes-armv4.S aes-armv4.o: aes-armv4.S
bsaes-%.S: asm/bsaes-%.pl; $(PERL) $< $(PERLASM_SCHEME) $@
bsaes-armv7.o: bsaes-armv7.S
files: files:
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl "AES_ENC=$(AES_ENC)" Makefile >> $(TOP)/MINFO
links: links:
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@ -147,7 +163,7 @@ aes_wrap.o: ../../e_os.h ../../include/openssl/aes.h
aes_wrap.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h aes_wrap.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
aes_wrap.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h aes_wrap.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
aes_wrap.o: ../../include/openssl/err.h ../../include/openssl/lhash.h aes_wrap.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
aes_wrap.o: ../../include/openssl/opensslconf.h aes_wrap.o: ../../include/openssl/modes.h ../../include/openssl/opensslconf.h
aes_wrap.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h aes_wrap.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
aes_wrap.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h aes_wrap.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
aes_wrap.o: ../../include/openssl/symhacks.h ../cryptlib.h aes_wrap.c aes_wrap.o: ../../include/openssl/symhacks.h ../cryptlib.h aes_wrap.c

View File

@ -53,207 +53,18 @@
#include "cryptlib.h" #include "cryptlib.h"
#include <openssl/aes.h> #include <openssl/aes.h>
#include <openssl/bio.h> #include <openssl/modes.h>
static const unsigned char default_iv[] = {
0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6,
};
int AES_wrap_key(AES_KEY *key, const unsigned char *iv, int AES_wrap_key(AES_KEY *key, const unsigned char *iv,
unsigned char *out, unsigned char *out,
const unsigned char *in, unsigned int inlen) const unsigned char *in, unsigned int inlen)
{ {
unsigned char *A, B[16], *R; return CRYPTO_128_wrap(key, iv, out, in, inlen, (block128_f)AES_encrypt);
unsigned int i, j, t;
if ((inlen & 0x7) || (inlen < 8))
return -1;
A = B;
t = 1;
memcpy(out + 8, in, inlen);
if (!iv)
iv = default_iv;
memcpy(A, iv, 8);
for (j = 0; j < 6; j++)
{
R = out + 8;
for (i = 0; i < inlen; i += 8, t++, R += 8)
{
memcpy(B + 8, R, 8);
AES_encrypt(B, B, key);
A[7] ^= (unsigned char)(t & 0xff);
if (t > 0xff)
{
A[6] ^= (unsigned char)((t >> 8) & 0xff);
A[5] ^= (unsigned char)((t >> 16) & 0xff);
A[4] ^= (unsigned char)((t >> 24) & 0xff);
}
memcpy(R, B + 8, 8);
}
}
memcpy(out, A, 8);
return inlen + 8;
} }
int AES_unwrap_key(AES_KEY *key, const unsigned char *iv, int AES_unwrap_key(AES_KEY *key, const unsigned char *iv,
unsigned char *out, unsigned char *out,
const unsigned char *in, unsigned int inlen) const unsigned char *in, unsigned int inlen)
{ {
unsigned char *A, B[16], *R; return CRYPTO_128_unwrap(key, iv, out, in, inlen, (block128_f)AES_decrypt);
unsigned int i, j, t;
inlen -= 8;
if (inlen & 0x7)
return -1;
if (inlen < 8)
return -1;
A = B;
t = 6 * (inlen >> 3);
memcpy(A, in, 8);
memcpy(out, in + 8, inlen);
for (j = 0; j < 6; j++)
{
R = out + inlen - 8;
for (i = 0; i < inlen; i += 8, t--, R -= 8)
{
A[7] ^= (unsigned char)(t & 0xff);
if (t > 0xff)
{
A[6] ^= (unsigned char)((t >> 8) & 0xff);
A[5] ^= (unsigned char)((t >> 16) & 0xff);
A[4] ^= (unsigned char)((t >> 24) & 0xff);
} }
memcpy(B + 8, R, 8);
AES_decrypt(B, B, key);
memcpy(R, B + 8, 8);
}
}
if (!iv)
iv = default_iv;
if (memcmp(A, iv, 8))
{
OPENSSL_cleanse(out, inlen);
return 0;
}
return inlen;
}
#ifdef AES_WRAP_TEST
int AES_wrap_unwrap_test(const unsigned char *kek, int keybits,
const unsigned char *iv,
const unsigned char *eout,
const unsigned char *key, int keylen)
{
unsigned char *otmp = NULL, *ptmp = NULL;
int r, ret = 0;
AES_KEY wctx;
otmp = OPENSSL_malloc(keylen + 8);
ptmp = OPENSSL_malloc(keylen);
if (!otmp || !ptmp)
return 0;
if (AES_set_encrypt_key(kek, keybits, &wctx))
goto err;
r = AES_wrap_key(&wctx, iv, otmp, key, keylen);
if (r <= 0)
goto err;
if (eout && memcmp(eout, otmp, keylen))
goto err;
if (AES_set_decrypt_key(kek, keybits, &wctx))
goto err;
r = AES_unwrap_key(&wctx, iv, ptmp, otmp, r);
if (memcmp(key, ptmp, keylen))
goto err;
ret = 1;
err:
if (otmp)
OPENSSL_free(otmp);
if (ptmp)
OPENSSL_free(ptmp);
return ret;
}
int main(int argc, char **argv)
{
static const unsigned char kek[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
};
static const unsigned char key[] = {
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
};
static const unsigned char e1[] = {
0x1f, 0xa6, 0x8b, 0x0a, 0x81, 0x12, 0xb4, 0x47,
0xae, 0xf3, 0x4b, 0xd8, 0xfb, 0x5a, 0x7b, 0x82,
0x9d, 0x3e, 0x86, 0x23, 0x71, 0xd2, 0xcf, 0xe5
};
static const unsigned char e2[] = {
0x96, 0x77, 0x8b, 0x25, 0xae, 0x6c, 0xa4, 0x35,
0xf9, 0x2b, 0x5b, 0x97, 0xc0, 0x50, 0xae, 0xd2,
0x46, 0x8a, 0xb8, 0xa1, 0x7a, 0xd8, 0x4e, 0x5d
};
static const unsigned char e3[] = {
0x64, 0xe8, 0xc3, 0xf9, 0xce, 0x0f, 0x5b, 0xa2,
0x63, 0xe9, 0x77, 0x79, 0x05, 0x81, 0x8a, 0x2a,
0x93, 0xc8, 0x19, 0x1e, 0x7d, 0x6e, 0x8a, 0xe7
};
static const unsigned char e4[] = {
0x03, 0x1d, 0x33, 0x26, 0x4e, 0x15, 0xd3, 0x32,
0x68, 0xf2, 0x4e, 0xc2, 0x60, 0x74, 0x3e, 0xdc,
0xe1, 0xc6, 0xc7, 0xdd, 0xee, 0x72, 0x5a, 0x93,
0x6b, 0xa8, 0x14, 0x91, 0x5c, 0x67, 0x62, 0xd2
};
static const unsigned char e5[] = {
0xa8, 0xf9, 0xbc, 0x16, 0x12, 0xc6, 0x8b, 0x3f,
0xf6, 0xe6, 0xf4, 0xfb, 0xe3, 0x0e, 0x71, 0xe4,
0x76, 0x9c, 0x8b, 0x80, 0xa3, 0x2c, 0xb8, 0x95,
0x8c, 0xd5, 0xd1, 0x7d, 0x6b, 0x25, 0x4d, 0xa1
};
static const unsigned char e6[] = {
0x28, 0xc9, 0xf4, 0x04, 0xc4, 0xb8, 0x10, 0xf4,
0xcb, 0xcc, 0xb3, 0x5c, 0xfb, 0x87, 0xf8, 0x26,
0x3f, 0x57, 0x86, 0xe2, 0xd8, 0x0e, 0xd3, 0x26,
0xcb, 0xc7, 0xf0, 0xe7, 0x1a, 0x99, 0xf4, 0x3b,
0xfb, 0x98, 0x8b, 0x9b, 0x7a, 0x02, 0xdd, 0x21
};
AES_KEY wctx, xctx;
int ret;
ret = AES_wrap_unwrap_test(kek, 128, NULL, e1, key, 16);
fprintf(stderr, "Key test result %d\n", ret);
ret = AES_wrap_unwrap_test(kek, 192, NULL, e2, key, 16);
fprintf(stderr, "Key test result %d\n", ret);
ret = AES_wrap_unwrap_test(kek, 256, NULL, e3, key, 16);
fprintf(stderr, "Key test result %d\n", ret);
ret = AES_wrap_unwrap_test(kek, 192, NULL, e4, key, 24);
fprintf(stderr, "Key test result %d\n", ret);
ret = AES_wrap_unwrap_test(kek, 256, NULL, e5, key, 24);
fprintf(stderr, "Key test result %d\n", ret);
ret = AES_wrap_unwrap_test(kek, 256, NULL, e6, key, 32);
fprintf(stderr, "Key test result %d\n", ret);
}
#endif

View File

@ -89,8 +89,10 @@ typedef unsigned long long u64;
#endif #endif
#undef ROTATE #undef ROTATE
#if defined(_MSC_VER) || defined(__ICC) #if defined(_MSC_VER)
# define ROTATE(a,n) _lrotl(a,n) # define ROTATE(a,n) _lrotl(a,n)
#elif defined(__ICC)
# define ROTATE(a,n) _rotl(a,n)
#elif defined(__GNUC__) && __GNUC__>=2 #elif defined(__GNUC__) && __GNUC__>=2
# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) # if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)
# define ROTATE(a,n) ({ register unsigned int ret; \ # define ROTATE(a,n) ({ register unsigned int ret; \

View File

@ -39,7 +39,7 @@
# but exhibits up to 10% improvement on other cores. # but exhibits up to 10% improvement on other cores.
# #
# Second version is "monolithic" replacement for aes_core.c, which in # Second version is "monolithic" replacement for aes_core.c, which in
# addition to AES_[de|en]crypt implements private_AES_set_[de|en]cryption_key. # addition to AES_[de|en]crypt implements AES_set_[de|en]cryption_key.
# This made it possible to implement little-endian variant of the # This made it possible to implement little-endian variant of the
# algorithm without modifying the base C code. Motivating factor for # algorithm without modifying the base C code. Motivating factor for
# the undertaken effort was that it appeared that in tight IA-32 # the undertaken effort was that it appeared that in tight IA-32
@ -103,11 +103,12 @@
# byte for 128-bit key. # byte for 128-bit key.
# #
# ECB encrypt ECB decrypt CBC large chunk # ECB encrypt ECB decrypt CBC large chunk
# P4 56[60] 84[100] 23 # P4 52[54] 83[95] 23
# AMD K8 48[44] 70[79] 18 # AMD K8 46[41] 66[70] 18
# PIII 41[50] 61[91] 24 # PIII 41[50] 60[77] 24
# Core 2 32[38] 45[70] 18.5 # Core 2 31[36] 45[64] 18.5
# Pentium 120 160 77 # Atom 76[100] 96[138] 60
# Pentium 115 150 77
# #
# Version 4.1 switches to compact S-box even in key schedule setup. # Version 4.1 switches to compact S-box even in key schedule setup.
# #
@ -242,7 +243,7 @@ $vertical_spin=0; # shift "verticaly" defaults to 0, because of
sub encvert() sub encvert()
{ my ($te,@s) = @_; { my ($te,@s) = @_;
my $v0 = $acc, $v1 = $key; my ($v0,$v1) = ($acc,$key);
&mov ($v0,$s[3]); # copy s3 &mov ($v0,$s[3]); # copy s3
&mov (&DWP(4,"esp"),$s[2]); # save s2 &mov (&DWP(4,"esp"),$s[2]); # save s2
@ -299,7 +300,7 @@ sub encvert()
# Another experimental routine, which features "horizontal spin," but # Another experimental routine, which features "horizontal spin," but
# eliminates one reference to stack. Strangely enough runs slower... # eliminates one reference to stack. Strangely enough runs slower...
sub enchoriz() sub enchoriz()
{ my $v0 = $key, $v1 = $acc; { my ($v0,$v1) = ($key,$acc);
&movz ($v0,&LB($s0)); # 3, 2, 1, 0* &movz ($v0,&LB($s0)); # 3, 2, 1, 0*
&rotr ($s2,8); # 8,11,10, 9 &rotr ($s2,8); # 8,11,10, 9
@ -427,7 +428,7 @@ sub sse_encbody()
###################################################################### ######################################################################
sub enccompact() sub enccompact()
{ my $Fn = mov; { my $Fn = \&mov;
while ($#_>5) { pop(@_); $Fn=sub{}; } while ($#_>5) { pop(@_); $Fn=sub{}; }
my ($i,$te,@s)=@_; my ($i,$te,@s)=@_;
my $tmp = $key; my $tmp = $key;
@ -476,24 +477,25 @@ sub enctransform()
my $tmp = $tbl; my $tmp = $tbl;
my $r2 = $key ; my $r2 = $key ;
&mov ($acc,$s[$i]); &and ($tmp,$s[$i]);
&and ($acc,0x80808080);
&mov ($tmp,$acc);
&shr ($tmp,7);
&lea ($r2,&DWP(0,$s[$i],$s[$i])); &lea ($r2,&DWP(0,$s[$i],$s[$i]));
&sub ($acc,$tmp); &mov ($acc,$tmp);
&shr ($tmp,7);
&and ($r2,0xfefefefe); &and ($r2,0xfefefefe);
&and ($acc,0x1b1b1b1b); &sub ($acc,$tmp);
&mov ($tmp,$s[$i]); &mov ($tmp,$s[$i]);
&and ($acc,0x1b1b1b1b);
&rotr ($tmp,16);
&xor ($acc,$r2); # r2 &xor ($acc,$r2); # r2
&mov ($r2,$s[$i]);
&xor ($s[$i],$acc); # r0 ^ r2 &xor ($s[$i],$acc); # r0 ^ r2
&rotr ($r2,16+8);
&xor ($acc,$tmp);
&rotl ($s[$i],24); &rotl ($s[$i],24);
&xor ($s[$i],$acc) # ROTATE(r2^r0,24) ^ r2 &xor ($acc,$r2);
&rotr ($tmp,16); &mov ($tmp,0x80808080) if ($i!=1);
&xor ($s[$i],$tmp); &xor ($s[$i],$acc); # ROTATE(r2^r0,24) ^ r2
&rotr ($tmp,8);
&xor ($s[$i],$tmp);
} }
&function_begin_B("_x86_AES_encrypt_compact"); &function_begin_B("_x86_AES_encrypt_compact");
@ -526,6 +528,7 @@ sub enctransform()
&enccompact(1,$tbl,$s1,$s2,$s3,$s0,1); &enccompact(1,$tbl,$s1,$s2,$s3,$s0,1);
&enccompact(2,$tbl,$s2,$s3,$s0,$s1,1); &enccompact(2,$tbl,$s2,$s3,$s0,$s1,1);
&enccompact(3,$tbl,$s3,$s0,$s1,$s2,1); &enccompact(3,$tbl,$s3,$s0,$s1,$s2,1);
&mov ($tbl,0x80808080);
&enctransform(2); &enctransform(2);
&enctransform(3); &enctransform(3);
&enctransform(0); &enctransform(0);
@ -607,82 +610,84 @@ sub sse_enccompact()
&pshufw ("mm5","mm4",0x0d); # 15,14,11,10 &pshufw ("mm5","mm4",0x0d); # 15,14,11,10
&movd ("eax","mm1"); # 5, 4, 1, 0 &movd ("eax","mm1"); # 5, 4, 1, 0
&movd ("ebx","mm5"); # 15,14,11,10 &movd ("ebx","mm5"); # 15,14,11,10
&mov ($__key,$key);
&movz ($acc,&LB("eax")); # 0 &movz ($acc,&LB("eax")); # 0
&movz ("ecx",&BP(-128,$tbl,$acc,1)); # 0
&pshufw ("mm2","mm0",0x0d); # 7, 6, 3, 2
&movz ("edx",&HB("eax")); # 1 &movz ("edx",&HB("eax")); # 1
&pshufw ("mm2","mm0",0x0d); # 7, 6, 3, 2
&movz ("ecx",&BP(-128,$tbl,$acc,1)); # 0
&movz ($key,&LB("ebx")); # 10
&movz ("edx",&BP(-128,$tbl,"edx",1)); # 1 &movz ("edx",&BP(-128,$tbl,"edx",1)); # 1
&shl ("edx",8); # 1
&shr ("eax",16); # 5, 4 &shr ("eax",16); # 5, 4
&shl ("edx",8); # 1
&movz ($acc,&LB("ebx")); # 10 &movz ($acc,&BP(-128,$tbl,$key,1)); # 10
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 10 &movz ($key,&HB("ebx")); # 11
&shl ($acc,16); # 10 &shl ($acc,16); # 10
&or ("ecx",$acc); # 10
&pshufw ("mm6","mm4",0x08); # 13,12, 9, 8 &pshufw ("mm6","mm4",0x08); # 13,12, 9, 8
&movz ($acc,&HB("ebx")); # 11 &or ("ecx",$acc); # 10
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 11 &movz ($acc,&BP(-128,$tbl,$key,1)); # 11
&movz ($key,&HB("eax")); # 5
&shl ($acc,24); # 11 &shl ($acc,24); # 11
&or ("edx",$acc); # 11
&shr ("ebx",16); # 15,14 &shr ("ebx",16); # 15,14
&or ("edx",$acc); # 11
&movz ($acc,&HB("eax")); # 5 &movz ($acc,&BP(-128,$tbl,$key,1)); # 5
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 5 &movz ($key,&HB("ebx")); # 15
&shl ($acc,8); # 5 &shl ($acc,8); # 5
&or ("ecx",$acc); # 5 &or ("ecx",$acc); # 5
&movz ($acc,&HB("ebx")); # 15 &movz ($acc,&BP(-128,$tbl,$key,1)); # 15
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 15 &movz ($key,&LB("eax")); # 4
&shl ($acc,24); # 15 &shl ($acc,24); # 15
&or ("ecx",$acc); # 15 &or ("ecx",$acc); # 15
&movd ("mm0","ecx"); # t[0] collected
&movz ($acc,&LB("eax")); # 4 &movz ($acc,&BP(-128,$tbl,$key,1)); # 4
&movz ("ecx",&BP(-128,$tbl,$acc,1)); # 4 &movz ($key,&LB("ebx")); # 14
&movd ("eax","mm2"); # 7, 6, 3, 2 &movd ("eax","mm2"); # 7, 6, 3, 2
&movz ($acc,&LB("ebx")); # 14 &movd ("mm0","ecx"); # t[0] collected
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 14 &movz ("ecx",&BP(-128,$tbl,$key,1)); # 14
&shl ($acc,16); # 14 &movz ($key,&HB("eax")); # 3
&shl ("ecx",16); # 14
&movd ("ebx","mm6"); # 13,12, 9, 8
&or ("ecx",$acc); # 14 &or ("ecx",$acc); # 14
&movd ("ebx","mm6"); # 13,12, 9, 8 &movz ($acc,&BP(-128,$tbl,$key,1)); # 3
&movz ($acc,&HB("eax")); # 3 &movz ($key,&HB("ebx")); # 9
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 3
&shl ($acc,24); # 3 &shl ($acc,24); # 3
&or ("ecx",$acc); # 3 &or ("ecx",$acc); # 3
&movz ($acc,&HB("ebx")); # 9 &movz ($acc,&BP(-128,$tbl,$key,1)); # 9
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 9 &movz ($key,&LB("ebx")); # 8
&shl ($acc,8); # 9 &shl ($acc,8); # 9
&or ("ecx",$acc); # 9
&movd ("mm1","ecx"); # t[1] collected
&movz ($acc,&LB("ebx")); # 8
&movz ("ecx",&BP(-128,$tbl,$acc,1)); # 8
&shr ("ebx",16); # 13,12 &shr ("ebx",16); # 13,12
&movz ($acc,&LB("eax")); # 2 &or ("ecx",$acc); # 9
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 2
&shl ($acc,16); # 2 &movz ($acc,&BP(-128,$tbl,$key,1)); # 8
&or ("ecx",$acc); # 2 &movz ($key,&LB("eax")); # 2
&shr ("eax",16); # 7, 6 &shr ("eax",16); # 7, 6
&movd ("mm1","ecx"); # t[1] collected
&movz ("ecx",&BP(-128,$tbl,$key,1)); # 2
&movz ($key,&HB("eax")); # 7
&shl ("ecx",16); # 2
&and ("eax",0xff); # 6
&or ("ecx",$acc); # 2
&punpckldq ("mm0","mm1"); # t[0,1] collected &punpckldq ("mm0","mm1"); # t[0,1] collected
&movz ($acc,&HB("eax")); # 7 &movz ($acc,&BP(-128,$tbl,$key,1)); # 7
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 7 &movz ($key,&HB("ebx")); # 13
&shl ($acc,24); # 7 &shl ($acc,24); # 7
&or ("ecx",$acc); # 7
&and ("eax",0xff); # 6
&movz ("eax",&BP(-128,$tbl,"eax",1)); # 6
&shl ("eax",16); # 6
&or ("edx","eax"); # 6
&movz ($acc,&HB("ebx")); # 13
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 13
&shl ($acc,8); # 13
&or ("ecx",$acc); # 13
&movd ("mm4","ecx"); # t[2] collected
&and ("ebx",0xff); # 12 &and ("ebx",0xff); # 12
&movz ("eax",&BP(-128,$tbl,"eax",1)); # 6
&or ("ecx",$acc); # 7
&shl ("eax",16); # 6
&movz ($acc,&BP(-128,$tbl,$key,1)); # 13
&or ("edx","eax"); # 6
&shl ($acc,8); # 13
&movz ("ebx",&BP(-128,$tbl,"ebx",1)); # 12 &movz ("ebx",&BP(-128,$tbl,"ebx",1)); # 12
&or ("ecx",$acc); # 13
&or ("edx","ebx"); # 12 &or ("edx","ebx"); # 12
&mov ($key,$__key);
&movd ("mm4","ecx"); # t[2] collected
&movd ("mm5","edx"); # t[3] collected &movd ("mm5","edx"); # t[3] collected
&punpckldq ("mm4","mm5"); # t[2,3] collected &punpckldq ("mm4","mm5"); # t[2,3] collected
@ -1222,7 +1227,7 @@ sub enclast()
###################################################################### ######################################################################
sub deccompact() sub deccompact()
{ my $Fn = mov; { my $Fn = \&mov;
while ($#_>5) { pop(@_); $Fn=sub{}; } while ($#_>5) { pop(@_); $Fn=sub{}; }
my ($i,$td,@s)=@_; my ($i,$td,@s)=@_;
my $tmp = $key; my $tmp = $key;
@ -1270,30 +1275,30 @@ sub dectransform()
my $tp4 = @s[($i+3)%4]; $tp4 = @s[3] if ($i==1); my $tp4 = @s[($i+3)%4]; $tp4 = @s[3] if ($i==1);
my $tp8 = $tbl; my $tp8 = $tbl;
&mov ($acc,$s[$i]); &mov ($tmp,0x80808080);
&and ($acc,0x80808080); &and ($tmp,$s[$i]);
&mov ($tmp,$acc); &mov ($acc,$tmp);
&shr ($tmp,7); &shr ($tmp,7);
&lea ($tp2,&DWP(0,$s[$i],$s[$i])); &lea ($tp2,&DWP(0,$s[$i],$s[$i]));
&sub ($acc,$tmp); &sub ($acc,$tmp);
&and ($tp2,0xfefefefe); &and ($tp2,0xfefefefe);
&and ($acc,0x1b1b1b1b); &and ($acc,0x1b1b1b1b);
&xor ($acc,$tp2); &xor ($tp2,$acc);
&mov ($tp2,$acc); &mov ($tmp,0x80808080);
&and ($acc,0x80808080); &and ($tmp,$tp2);
&mov ($tmp,$acc); &mov ($acc,$tmp);
&shr ($tmp,7); &shr ($tmp,7);
&lea ($tp4,&DWP(0,$tp2,$tp2)); &lea ($tp4,&DWP(0,$tp2,$tp2));
&sub ($acc,$tmp); &sub ($acc,$tmp);
&and ($tp4,0xfefefefe); &and ($tp4,0xfefefefe);
&and ($acc,0x1b1b1b1b); &and ($acc,0x1b1b1b1b);
&xor ($tp2,$s[$i]); # tp2^tp1 &xor ($tp2,$s[$i]); # tp2^tp1
&xor ($acc,$tp4); &xor ($tp4,$acc);
&mov ($tp4,$acc); &mov ($tmp,0x80808080);
&and ($acc,0x80808080); &and ($tmp,$tp4);
&mov ($tmp,$acc); &mov ($acc,$tmp);
&shr ($tmp,7); &shr ($tmp,7);
&lea ($tp8,&DWP(0,$tp4,$tp4)); &lea ($tp8,&DWP(0,$tp4,$tp4));
&sub ($acc,$tmp); &sub ($acc,$tmp);
@ -1305,13 +1310,13 @@ sub dectransform()
&xor ($s[$i],$tp2); &xor ($s[$i],$tp2);
&xor ($tp2,$tp8); &xor ($tp2,$tp8);
&rotl ($tp2,24);
&xor ($s[$i],$tp4); &xor ($s[$i],$tp4);
&xor ($tp4,$tp8); &xor ($tp4,$tp8);
&rotl ($tp4,16); &rotl ($tp2,24);
&xor ($s[$i],$tp8); # ^= tp8^(tp4^tp1)^(tp2^tp1) &xor ($s[$i],$tp8); # ^= tp8^(tp4^tp1)^(tp2^tp1)
&rotl ($tp8,8); &rotl ($tp4,16);
&xor ($s[$i],$tp2); # ^= ROTATE(tp8^tp2^tp1,24) &xor ($s[$i],$tp2); # ^= ROTATE(tp8^tp2^tp1,24)
&rotl ($tp8,8);
&xor ($s[$i],$tp4); # ^= ROTATE(tp8^tp4^tp1,16) &xor ($s[$i],$tp4); # ^= ROTATE(tp8^tp4^tp1,16)
&mov ($s[0],$__s0) if($i==2); #prefetch $s0 &mov ($s[0],$__s0) if($i==2); #prefetch $s0
&mov ($s[1],$__s1) if($i==3); #prefetch $s1 &mov ($s[1],$__s1) if($i==3); #prefetch $s1
@ -1389,85 +1394,87 @@ sub dectransform()
sub sse_deccompact() sub sse_deccompact()
{ {
&pshufw ("mm1","mm0",0x0c); # 7, 6, 1, 0 &pshufw ("mm1","mm0",0x0c); # 7, 6, 1, 0
&movd ("eax","mm1"); # 7, 6, 1, 0
&pshufw ("mm5","mm4",0x09); # 13,12,11,10 &pshufw ("mm5","mm4",0x09); # 13,12,11,10
&movz ($acc,&LB("eax")); # 0 &movd ("eax","mm1"); # 7, 6, 1, 0
&movz ("ecx",&BP(-128,$tbl,$acc,1)); # 0
&movd ("ebx","mm5"); # 13,12,11,10 &movd ("ebx","mm5"); # 13,12,11,10
&mov ($__key,$key);
&movz ($acc,&LB("eax")); # 0
&movz ("edx",&HB("eax")); # 1 &movz ("edx",&HB("eax")); # 1
&pshufw ("mm2","mm0",0x06); # 3, 2, 5, 4
&movz ("ecx",&BP(-128,$tbl,$acc,1)); # 0
&movz ($key,&LB("ebx")); # 10
&movz ("edx",&BP(-128,$tbl,"edx",1)); # 1 &movz ("edx",&BP(-128,$tbl,"edx",1)); # 1
&shr ("eax",16); # 7, 6
&shl ("edx",8); # 1 &shl ("edx",8); # 1
&pshufw ("mm2","mm0",0x06); # 3, 2, 5, 4 &movz ($acc,&BP(-128,$tbl,$key,1)); # 10
&movz ($acc,&LB("ebx")); # 10 &movz ($key,&HB("ebx")); # 11
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 10
&shl ($acc,16); # 10 &shl ($acc,16); # 10
&or ("ecx",$acc); # 10
&shr ("eax",16); # 7, 6
&movz ($acc,&HB("ebx")); # 11
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 11
&shl ($acc,24); # 11
&or ("edx",$acc); # 11
&shr ("ebx",16); # 13,12
&pshufw ("mm6","mm4",0x03); # 9, 8,15,14 &pshufw ("mm6","mm4",0x03); # 9, 8,15,14
&movz ($acc,&HB("eax")); # 7 &or ("ecx",$acc); # 10
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 7 &movz ($acc,&BP(-128,$tbl,$key,1)); # 11
&movz ($key,&HB("eax")); # 7
&shl ($acc,24); # 11
&shr ("ebx",16); # 13,12
&or ("edx",$acc); # 11
&movz ($acc,&BP(-128,$tbl,$key,1)); # 7
&movz ($key,&HB("ebx")); # 13
&shl ($acc,24); # 7 &shl ($acc,24); # 7
&or ("ecx",$acc); # 7 &or ("ecx",$acc); # 7
&movz ($acc,&HB("ebx")); # 13 &movz ($acc,&BP(-128,$tbl,$key,1)); # 13
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 13 &movz ($key,&LB("eax")); # 6
&shl ($acc,8); # 13 &shl ($acc,8); # 13
&or ("ecx",$acc); # 13
&movd ("mm0","ecx"); # t[0] collected
&movz ($acc,&LB("eax")); # 6
&movd ("eax","mm2"); # 3, 2, 5, 4 &movd ("eax","mm2"); # 3, 2, 5, 4
&movz ("ecx",&BP(-128,$tbl,$acc,1)); # 6 &or ("ecx",$acc); # 13
&shl ("ecx",16); # 6
&movz ($acc,&LB("ebx")); # 12 &movz ($acc,&BP(-128,$tbl,$key,1)); # 6
&movz ($key,&LB("ebx")); # 12
&shl ($acc,16); # 6
&movd ("ebx","mm6"); # 9, 8,15,14 &movd ("ebx","mm6"); # 9, 8,15,14
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 12 &movd ("mm0","ecx"); # t[0] collected
&movz ("ecx",&BP(-128,$tbl,$key,1)); # 12
&movz ($key,&LB("eax")); # 4
&or ("ecx",$acc); # 12 &or ("ecx",$acc); # 12
&movz ($acc,&LB("eax")); # 4 &movz ($acc,&BP(-128,$tbl,$key,1)); # 4
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 4 &movz ($key,&LB("ebx")); # 14
&or ("edx",$acc); # 4 &or ("edx",$acc); # 4
&movz ($acc,&LB("ebx")); # 14 &movz ($acc,&BP(-128,$tbl,$key,1)); # 14
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 14 &movz ($key,&HB("eax")); # 5
&shl ($acc,16); # 14 &shl ($acc,16); # 14
&or ("edx",$acc); # 14
&movd ("mm1","edx"); # t[1] collected
&movz ($acc,&HB("eax")); # 5
&movz ("edx",&BP(-128,$tbl,$acc,1)); # 5
&shl ("edx",8); # 5
&movz ($acc,&HB("ebx")); # 15
&shr ("eax",16); # 3, 2 &shr ("eax",16); # 3, 2
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 15 &or ("edx",$acc); # 14
&shl ($acc,24); # 15
&or ("edx",$acc); # 15 &movz ($acc,&BP(-128,$tbl,$key,1)); # 5
&movz ($key,&HB("ebx")); # 15
&shr ("ebx",16); # 9, 8 &shr ("ebx",16); # 9, 8
&shl ($acc,8); # 5
&movd ("mm1","edx"); # t[1] collected
&movz ("edx",&BP(-128,$tbl,$key,1)); # 15
&movz ($key,&HB("ebx")); # 9
&shl ("edx",24); # 15
&and ("ebx",0xff); # 8
&or ("edx",$acc); # 15
&punpckldq ("mm0","mm1"); # t[0,1] collected &punpckldq ("mm0","mm1"); # t[0,1] collected
&movz ($acc,&HB("ebx")); # 9 &movz ($acc,&BP(-128,$tbl,$key,1)); # 9
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 9 &movz ($key,&LB("eax")); # 2
&shl ($acc,8); # 9 &shl ($acc,8); # 9
&or ("ecx",$acc); # 9
&and ("ebx",0xff); # 8
&movz ("ebx",&BP(-128,$tbl,"ebx",1)); # 8
&or ("edx","ebx"); # 8
&movz ($acc,&LB("eax")); # 2
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 2
&shl ($acc,16); # 2
&or ("edx",$acc); # 2
&movd ("mm4","edx"); # t[2] collected
&movz ("eax",&HB("eax")); # 3 &movz ("eax",&HB("eax")); # 3
&movz ("ebx",&BP(-128,$tbl,"ebx",1)); # 8
&or ("ecx",$acc); # 9
&movz ($acc,&BP(-128,$tbl,$key,1)); # 2
&or ("edx","ebx"); # 8
&shl ($acc,16); # 2
&movz ("eax",&BP(-128,$tbl,"eax",1)); # 3 &movz ("eax",&BP(-128,$tbl,"eax",1)); # 3
&or ("edx",$acc); # 2
&shl ("eax",24); # 3 &shl ("eax",24); # 3
&or ("ecx","eax"); # 3 &or ("ecx","eax"); # 3
&mov ($key,$__key);
&movd ("mm4","edx"); # t[2] collected
&movd ("mm5","ecx"); # t[3] collected &movd ("mm5","ecx"); # t[3] collected
&punpckldq ("mm4","mm5"); # t[2,3] collected &punpckldq ("mm4","mm5"); # t[2,3] collected
@ -2182,7 +2189,7 @@ my $mark=&DWP(76+240,"esp"); # copy of aes_key->rounds
&xor ("eax","eax"); &xor ("eax","eax");
&align (4); &align (4);
&data_word(0xABF3F689); # rep stosd &data_word(0xABF3F689); # rep stosd
&set_label("skip_ezero") &set_label("skip_ezero");
&mov ("esp",$_esp); &mov ("esp",$_esp);
&popf (); &popf ();
&set_label("drop_out"); &set_label("drop_out");
@ -2302,7 +2309,7 @@ my $mark=&DWP(76+240,"esp"); # copy of aes_key->rounds
&xor ("eax","eax"); &xor ("eax","eax");
&align (4); &align (4);
&data_word(0xABF3F689); # rep stosd &data_word(0xABF3F689); # rep stosd
&set_label("skip_dzero") &set_label("skip_dzero");
&mov ("esp",$_esp); &mov ("esp",$_esp);
&popf (); &popf ();
&function_end_A(); &function_end_A();
@ -2865,32 +2872,32 @@ sub deckey()
{ my ($i,$key,$tp1,$tp2,$tp4,$tp8) = @_; { my ($i,$key,$tp1,$tp2,$tp4,$tp8) = @_;
my $tmp = $tbl; my $tmp = $tbl;
&mov ($acc,$tp1); &mov ($tmp,0x80808080);
&and ($acc,0x80808080); &and ($tmp,$tp1);
&mov ($tmp,$acc);
&shr ($tmp,7);
&lea ($tp2,&DWP(0,$tp1,$tp1)); &lea ($tp2,&DWP(0,$tp1,$tp1));
&mov ($acc,$tmp);
&shr ($tmp,7);
&sub ($acc,$tmp); &sub ($acc,$tmp);
&and ($tp2,0xfefefefe); &and ($tp2,0xfefefefe);
&and ($acc,0x1b1b1b1b); &and ($acc,0x1b1b1b1b);
&xor ($acc,$tp2); &xor ($tp2,$acc);
&mov ($tp2,$acc); &mov ($tmp,0x80808080);
&and ($acc,0x80808080); &and ($tmp,$tp2);
&mov ($tmp,$acc);
&shr ($tmp,7);
&lea ($tp4,&DWP(0,$tp2,$tp2)); &lea ($tp4,&DWP(0,$tp2,$tp2));
&mov ($acc,$tmp);
&shr ($tmp,7);
&sub ($acc,$tmp); &sub ($acc,$tmp);
&and ($tp4,0xfefefefe); &and ($tp4,0xfefefefe);
&and ($acc,0x1b1b1b1b); &and ($acc,0x1b1b1b1b);
&xor ($tp2,$tp1); # tp2^tp1 &xor ($tp2,$tp1); # tp2^tp1
&xor ($acc,$tp4); &xor ($tp4,$acc);
&mov ($tp4,$acc); &mov ($tmp,0x80808080);
&and ($acc,0x80808080); &and ($tmp,$tp4);
&mov ($tmp,$acc);
&shr ($tmp,7);
&lea ($tp8,&DWP(0,$tp4,$tp4)); &lea ($tp8,&DWP(0,$tp4,$tp4));
&mov ($acc,$tmp);
&shr ($tmp,7);
&xor ($tp4,$tp1); # tp4^tp1 &xor ($tp4,$tp1); # tp4^tp1
&sub ($acc,$tmp); &sub ($acc,$tmp);
&and ($tp8,0xfefefefe); &and ($tp8,0xfefefefe);

View File

@ -1,7 +1,7 @@
#!/usr/bin/env perl #!/usr/bin/env perl
# ==================================================================== # ====================================================================
# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL # Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
# project. The module is, however, dual licensed under OpenSSL and # project. The module is, however, dual licensed under OpenSSL and
# CRYPTOGAMS licenses depending on where you obtain it. For further # CRYPTOGAMS licenses depending on where you obtain it. For further
# details see http://www.openssl.org/~appro/cryptogams/. # details see http://www.openssl.org/~appro/cryptogams/.
@ -51,9 +51,23 @@ $key="r11";
$rounds="r12"; $rounds="r12";
$code=<<___; $code=<<___;
#ifndef __KERNEL__
# include "arm_arch.h" # include "arm_arch.h"
#else
# define __ARM_ARCH__ __LINUX_ARM_ARCH__
#endif
.text .text
#if __ARM_ARCH__<7
.code 32 .code 32
#else
.syntax unified
# ifdef __thumb2__
.thumb
# else
.code 32
# endif
#endif
.type AES_Te,%object .type AES_Te,%object
.align 5 .align 5
@ -167,7 +181,11 @@ AES_Te:
.type AES_encrypt,%function .type AES_encrypt,%function
.align 5 .align 5
AES_encrypt: AES_encrypt:
#if __ARM_ARCH__<7
sub r3,pc,#8 @ AES_encrypt sub r3,pc,#8 @ AES_encrypt
#else
adr r3,AES_encrypt
#endif
stmdb sp!,{r1,r4-r12,lr} stmdb sp!,{r1,r4-r12,lr}
mov $rounds,r0 @ inp mov $rounds,r0 @ inp
mov $key,r2 mov $key,r2
@ -408,11 +426,22 @@ _armv4_AES_encrypt:
.type private_AES_set_encrypt_key,%function .type private_AES_set_encrypt_key,%function
.align 5 .align 5
private_AES_set_encrypt_key: private_AES_set_encrypt_key:
_armv4_AES_set_encrypt_key:
#if __ARM_ARCH__<7
sub r3,pc,#8 @ AES_set_encrypt_key sub r3,pc,#8 @ AES_set_encrypt_key
#else
adr r3,private_AES_set_encrypt_key
#endif
teq r0,#0 teq r0,#0
#if __ARM_ARCH__>=7
itt eq @ Thumb2 thing, sanity check in ARM
#endif
moveq r0,#-1 moveq r0,#-1
beq .Labrt beq .Labrt
teq r2,#0 teq r2,#0
#if __ARM_ARCH__>=7
itt eq @ Thumb2 thing, sanity check in ARM
#endif
moveq r0,#-1 moveq r0,#-1
beq .Labrt beq .Labrt
@ -421,11 +450,14 @@ private_AES_set_encrypt_key:
teq r1,#192 teq r1,#192
beq .Lok beq .Lok
teq r1,#256 teq r1,#256
#if __ARM_ARCH__>=7
itt ne @ Thumb2 thing, sanity check in ARM
#endif
movne r0,#-1 movne r0,#-1
bne .Labrt bne .Labrt
.Lok: stmdb sp!,{r4-r12,lr} .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 $rounds,r0 @ inp
mov lr,r1 @ bits mov lr,r1 @ bits
@ -575,6 +607,9 @@ private_AES_set_encrypt_key:
str $s2,[$key,#-16] str $s2,[$key,#-16]
subs $rounds,$rounds,#1 subs $rounds,$rounds,#1
str $s3,[$key,#-12] str $s3,[$key,#-12]
#if __ARM_ARCH__>=7
itt eq @ Thumb2 thing, sanity check in ARM
#endif
subeq r2,$key,#216 subeq r2,$key,#216
beq .Ldone beq .Ldone
@ -644,6 +679,9 @@ private_AES_set_encrypt_key:
str $s2,[$key,#-24] str $s2,[$key,#-24]
subs $rounds,$rounds,#1 subs $rounds,$rounds,#1
str $s3,[$key,#-20] str $s3,[$key,#-20]
#if __ARM_ARCH__>=7
itt eq @ Thumb2 thing, sanity check in ARM
#endif
subeq r2,$key,#256 subeq r2,$key,#256
beq .Ldone beq .Ldone
@ -673,11 +711,17 @@ private_AES_set_encrypt_key:
str $i3,[$key,#-4] str $i3,[$key,#-4]
b .L256_loop b .L256_loop
.align 2
.Ldone: mov r0,#0 .Ldone: mov r0,#0
ldmia sp!,{r4-r12,lr} ldmia sp!,{r4-r12,lr}
.Labrt: tst lr,#1 .Labrt:
#if __ARM_ARCH__>=5
ret @ bx lr
#else
tst lr,#1
moveq pc,lr @ be binary compatible with V4, yet moveq pc,lr @ be binary compatible with V4, yet
bx lr @ interoperable with Thumb ISA:-) bx lr @ interoperable with Thumb ISA:-)
#endif
.size private_AES_set_encrypt_key,.-private_AES_set_encrypt_key .size private_AES_set_encrypt_key,.-private_AES_set_encrypt_key
.global private_AES_set_decrypt_key .global private_AES_set_decrypt_key
@ -685,36 +729,59 @@ private_AES_set_encrypt_key:
.align 5 .align 5
private_AES_set_decrypt_key: private_AES_set_decrypt_key:
str lr,[sp,#-4]! @ push lr str lr,[sp,#-4]! @ push lr
bl private_AES_set_encrypt_key bl _armv4_AES_set_encrypt_key
teq r0,#0 teq r0,#0
ldrne lr,[sp],#4 @ pop lr ldr lr,[sp],#4 @ pop lr
bne .Labrt bne .Labrt
stmdb sp!,{r4-r12} mov r0,r2 @ AES_set_encrypt_key preserves r2,
mov r1,r2 @ which is AES_KEY *key
b _armv4_AES_set_enc2dec_key
.size private_AES_set_decrypt_key,.-private_AES_set_decrypt_key
ldr $rounds,[r2,#240] @ AES_set_encrypt_key preserves r2, @ void AES_set_enc2dec_key(const AES_KEY *inp,AES_KEY *out)
mov $key,r2 @ which is AES_KEY *key .global AES_set_enc2dec_key
mov $i1,r2 .type AES_set_enc2dec_key,%function
add $i2,r2,$rounds,lsl#4 .align 5
AES_set_enc2dec_key:
_armv4_AES_set_enc2dec_key:
stmdb sp!,{r4-r12,lr}
.Linv: ldr $s0,[$i1] ldr $rounds,[r0,#240]
mov $i1,r0 @ input
add $i2,r0,$rounds,lsl#4
mov $key,r1 @ ouput
add $tbl,r1,$rounds,lsl#4
str $rounds,[r1,#240]
.Linv: ldr $s0,[$i1],#16
ldr $s1,[$i1,#-12]
ldr $s2,[$i1,#-8]
ldr $s3,[$i1,#-4]
ldr $t1,[$i2],#-16
ldr $t2,[$i2,#16+4]
ldr $t3,[$i2,#16+8]
ldr $i3,[$i2,#16+12]
str $s0,[$tbl],#-16
str $s1,[$tbl,#16+4]
str $s2,[$tbl,#16+8]
str $s3,[$tbl,#16+12]
str $t1,[$key],#16
str $t2,[$key,#-12]
str $t3,[$key,#-8]
str $i3,[$key,#-4]
teq $i1,$i2
bne .Linv
ldr $s0,[$i1]
ldr $s1,[$i1,#4] ldr $s1,[$i1,#4]
ldr $s2,[$i1,#8] ldr $s2,[$i1,#8]
ldr $s3,[$i1,#12] ldr $s3,[$i1,#12]
ldr $t1,[$i2] str $s0,[$key]
ldr $t2,[$i2,#4] str $s1,[$key,#4]
ldr $t3,[$i2,#8] str $s2,[$key,#8]
ldr $i3,[$i2,#12] str $s3,[$key,#12]
str $s0,[$i2],#-16 sub $key,$key,$rounds,lsl#3
str $s1,[$i2,#16+4]
str $s2,[$i2,#16+8]
str $s3,[$i2,#16+12]
str $t1,[$i1],#16
str $t2,[$i1,#-12]
str $t3,[$i1,#-8]
str $i3,[$i1,#-4]
teq $i1,$i2
bne .Linv
___ ___
$mask80=$i1; $mask80=$i1;
$mask1b=$i2; $mask1b=$i2;
@ -772,7 +839,7 @@ $code.=<<___;
moveq pc,lr @ be binary compatible with V4, yet moveq pc,lr @ be binary compatible with V4, yet
bx lr @ interoperable with Thumb ISA:-) bx lr @ interoperable with Thumb ISA:-)
#endif #endif
.size private_AES_set_decrypt_key,.-private_AES_set_decrypt_key .size AES_set_enc2dec_key,.-AES_set_enc2dec_key
.type AES_Td,%object .type AES_Td,%object
.align 5 .align 5
@ -882,7 +949,11 @@ AES_Td:
.type AES_decrypt,%function .type AES_decrypt,%function
.align 5 .align 5
AES_decrypt: AES_decrypt:
#if __ARM_ARCH__<7
sub r3,pc,#8 @ AES_decrypt sub r3,pc,#8 @ AES_decrypt
#else
adr r3,AES_decrypt
#endif
stmdb sp!,{r1,r4-r12,lr} stmdb sp!,{r1,r4-r12,lr}
mov $rounds,r0 @ inp mov $rounds,r0 @ inp
mov $key,r2 mov $key,r2
@ -1079,8 +1150,9 @@ _armv4_AES_decrypt:
ldrb $t3,[$tbl,$i3] @ Td4[s0>>0] ldrb $t3,[$tbl,$i3] @ Td4[s0>>0]
and $i3,lr,$s1,lsr#8 and $i3,lr,$s1,lsr#8
add $s1,$tbl,$s1,lsr#24
ldrb $i1,[$tbl,$i1] @ Td4[s1>>0] ldrb $i1,[$tbl,$i1] @ Td4[s1>>0]
ldrb $s1,[$tbl,$s1,lsr#24] @ Td4[s1>>24] ldrb $s1,[$s1] @ Td4[s1>>24]
ldrb $i2,[$tbl,$i2] @ Td4[s1>>16] ldrb $i2,[$tbl,$i2] @ Td4[s1>>16]
eor $s0,$i1,$s0,lsl#24 eor $s0,$i1,$s0,lsl#24
ldrb $i3,[$tbl,$i3] @ Td4[s1>>8] ldrb $i3,[$tbl,$i3] @ Td4[s1>>8]
@ -1093,7 +1165,8 @@ _armv4_AES_decrypt:
ldrb $i2,[$tbl,$i2] @ Td4[s2>>0] ldrb $i2,[$tbl,$i2] @ Td4[s2>>0]
and $i3,lr,$s2,lsr#16 and $i3,lr,$s2,lsr#16
ldrb $s2,[$tbl,$s2,lsr#24] @ Td4[s2>>24] add $s2,$tbl,$s2,lsr#24
ldrb $s2,[$s2] @ Td4[s2>>24]
eor $s0,$s0,$i1,lsl#8 eor $s0,$s0,$i1,lsl#8
ldrb $i3,[$tbl,$i3] @ Td4[s2>>16] ldrb $i3,[$tbl,$i3] @ Td4[s2>>16]
eor $s1,$i2,$s1,lsl#16 eor $s1,$i2,$s1,lsl#16
@ -1105,8 +1178,9 @@ _armv4_AES_decrypt:
ldrb $i2,[$tbl,$i2] @ Td4[s3>>8] ldrb $i2,[$tbl,$i2] @ Td4[s3>>8]
and $i3,lr,$s3 @ i2 and $i3,lr,$s3 @ i2
add $s3,$tbl,$s3,lsr#24
ldrb $i3,[$tbl,$i3] @ Td4[s3>>0] ldrb $i3,[$tbl,$i3] @ Td4[s3>>0]
ldrb $s3,[$tbl,$s3,lsr#24] @ Td4[s3>>24] ldrb $s3,[$s3] @ Td4[s3>>24]
eor $s0,$s0,$i1,lsl#16 eor $s0,$s0,$i1,lsl#16
ldr $i1,[$key,#0] ldr $i1,[$key,#0]
eor $s1,$s1,$i2,lsl#8 eor $s1,$s1,$i2,lsl#8
@ -1129,5 +1203,15 @@ _armv4_AES_decrypt:
___ ___
$code =~ s/\bbx\s+lr\b/.word\t0xe12fff1e/gm; # make it possible to compile with -march=armv4 $code =~ s/\bbx\s+lr\b/.word\t0xe12fff1e/gm; # make it possible to compile with -march=armv4
$code =~ s/\bret\b/bx\tlr/gm;
open SELF,$0;
while(<SELF>) {
next if (/^#!/);
last if (!s/^#/@/ and !/^$/);
print;
}
close SELF;
print $code; print $code;
close STDOUT; # enforce flush close STDOUT; # enforce flush

File diff suppressed because it is too large Load Diff

View File

@ -1016,6 +1016,7 @@ foreach (split("\n",$code)) {
: sprintf("extrd,u%s,%d,8,",$1,63-$2)/e; : sprintf("extrd,u%s,%d,8,",$1,63-$2)/e;
s/,\*/,/ if ($SIZE_T==4); s/,\*/,/ if ($SIZE_T==4);
s/\bbv\b(.*\(%r2\))/bve$1/ if ($SIZE_T==8);
print $_,"\n"; print $_,"\n";
} }
close STDOUT; close STDOUT;

View File

@ -45,6 +45,8 @@ if ($flavour =~ /64/) {
$PUSH ="stw"; $PUSH ="stw";
} else { die "nonsense $flavour"; } } else { die "nonsense $flavour"; }
$LITTLE_ENDIAN = ($flavour=~/le$/) ? $SIZE_T : 0;
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
( $xlate="${dir}ppc-xlate.pl" and -f $xlate ) or ( $xlate="${dir}ppc-xlate.pl" and -f $xlate ) or
( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or ( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or
@ -68,7 +70,7 @@ $key="r5";
$Tbl0="r3"; $Tbl0="r3";
$Tbl1="r6"; $Tbl1="r6";
$Tbl2="r7"; $Tbl2="r7";
$Tbl3="r2"; $Tbl3=$out; # stay away from "r2"; $out is offloaded to stack
$s0="r8"; $s0="r8";
$s1="r9"; $s1="r9";
@ -76,7 +78,7 @@ $s2="r10";
$s3="r11"; $s3="r11";
$t0="r12"; $t0="r12";
$t1="r13"; $t1="r0"; # stay away from "r13";
$t2="r14"; $t2="r14";
$t3="r15"; $t3="r15";
@ -100,9 +102,6 @@ $acc13="r29";
$acc14="r30"; $acc14="r30";
$acc15="r31"; $acc15="r31";
# stay away from TLS pointer
if ($SIZE_T==8) { die if ($t1 ne "r13"); $t1="r0"; }
else { die if ($Tbl3 ne "r2"); $Tbl3=$t0; $t0="r0"; }
$mask80=$Tbl2; $mask80=$Tbl2;
$mask1b=$Tbl3; $mask1b=$Tbl3;
@ -337,8 +336,7 @@ $code.=<<___;
$STU $sp,-$FRAME($sp) $STU $sp,-$FRAME($sp)
mflr r0 mflr r0
$PUSH $toc,`$FRAME-$SIZE_T*20`($sp) $PUSH $out,`$FRAME-$SIZE_T*19`($sp)
$PUSH r13,`$FRAME-$SIZE_T*19`($sp)
$PUSH r14,`$FRAME-$SIZE_T*18`($sp) $PUSH r14,`$FRAME-$SIZE_T*18`($sp)
$PUSH r15,`$FRAME-$SIZE_T*17`($sp) $PUSH r15,`$FRAME-$SIZE_T*17`($sp)
$PUSH r16,`$FRAME-$SIZE_T*16`($sp) $PUSH r16,`$FRAME-$SIZE_T*16`($sp)
@ -365,16 +363,61 @@ $code.=<<___;
bne Lenc_unaligned bne Lenc_unaligned
Lenc_unaligned_ok: Lenc_unaligned_ok:
___
$code.=<<___ if (!$LITTLE_ENDIAN);
lwz $s0,0($inp) lwz $s0,0($inp)
lwz $s1,4($inp) lwz $s1,4($inp)
lwz $s2,8($inp) lwz $s2,8($inp)
lwz $s3,12($inp) lwz $s3,12($inp)
___
$code.=<<___ if ($LITTLE_ENDIAN);
lwz $t0,0($inp)
lwz $t1,4($inp)
lwz $t2,8($inp)
lwz $t3,12($inp)
rotlwi $s0,$t0,8
rotlwi $s1,$t1,8
rotlwi $s2,$t2,8
rotlwi $s3,$t3,8
rlwimi $s0,$t0,24,0,7
rlwimi $s1,$t1,24,0,7
rlwimi $s2,$t2,24,0,7
rlwimi $s3,$t3,24,0,7
rlwimi $s0,$t0,24,16,23
rlwimi $s1,$t1,24,16,23
rlwimi $s2,$t2,24,16,23
rlwimi $s3,$t3,24,16,23
___
$code.=<<___;
bl LAES_Te bl LAES_Te
bl Lppc_AES_encrypt_compact bl Lppc_AES_encrypt_compact
$POP $out,`$FRAME-$SIZE_T*19`($sp)
___
$code.=<<___ if ($LITTLE_ENDIAN);
rotlwi $t0,$s0,8
rotlwi $t1,$s1,8
rotlwi $t2,$s2,8
rotlwi $t3,$s3,8
rlwimi $t0,$s0,24,0,7
rlwimi $t1,$s1,24,0,7
rlwimi $t2,$s2,24,0,7
rlwimi $t3,$s3,24,0,7
rlwimi $t0,$s0,24,16,23
rlwimi $t1,$s1,24,16,23
rlwimi $t2,$s2,24,16,23
rlwimi $t3,$s3,24,16,23
stw $t0,0($out)
stw $t1,4($out)
stw $t2,8($out)
stw $t3,12($out)
___
$code.=<<___ if (!$LITTLE_ENDIAN);
stw $s0,0($out) stw $s0,0($out)
stw $s1,4($out) stw $s1,4($out)
stw $s2,8($out) stw $s2,8($out)
stw $s3,12($out) stw $s3,12($out)
___
$code.=<<___;
b Lenc_done b Lenc_done
Lenc_unaligned: Lenc_unaligned:
@ -417,6 +460,7 @@ Lenc_xpage:
bl LAES_Te bl LAES_Te
bl Lppc_AES_encrypt_compact bl Lppc_AES_encrypt_compact
$POP $out,`$FRAME-$SIZE_T*19`($sp)
extrwi $acc00,$s0,8,0 extrwi $acc00,$s0,8,0
extrwi $acc01,$s0,8,8 extrwi $acc01,$s0,8,8
@ -449,8 +493,6 @@ Lenc_xpage:
Lenc_done: Lenc_done:
$POP r0,`$FRAME+$LRSAVE`($sp) $POP r0,`$FRAME+$LRSAVE`($sp)
$POP $toc,`$FRAME-$SIZE_T*20`($sp)
$POP r13,`$FRAME-$SIZE_T*19`($sp)
$POP r14,`$FRAME-$SIZE_T*18`($sp) $POP r14,`$FRAME-$SIZE_T*18`($sp)
$POP r15,`$FRAME-$SIZE_T*17`($sp) $POP r15,`$FRAME-$SIZE_T*17`($sp)
$POP r16,`$FRAME-$SIZE_T*16`($sp) $POP r16,`$FRAME-$SIZE_T*16`($sp)
@ -764,6 +806,7 @@ Lenc_compact_done:
blr blr
.long 0 .long 0
.byte 0,12,0x14,0,0,0,0,0 .byte 0,12,0x14,0,0,0,0,0
.size .AES_encrypt,.-.AES_encrypt
.globl .AES_decrypt .globl .AES_decrypt
.align 7 .align 7
@ -771,8 +814,7 @@ Lenc_compact_done:
$STU $sp,-$FRAME($sp) $STU $sp,-$FRAME($sp)
mflr r0 mflr r0
$PUSH $toc,`$FRAME-$SIZE_T*20`($sp) $PUSH $out,`$FRAME-$SIZE_T*19`($sp)
$PUSH r13,`$FRAME-$SIZE_T*19`($sp)
$PUSH r14,`$FRAME-$SIZE_T*18`($sp) $PUSH r14,`$FRAME-$SIZE_T*18`($sp)
$PUSH r15,`$FRAME-$SIZE_T*17`($sp) $PUSH r15,`$FRAME-$SIZE_T*17`($sp)
$PUSH r16,`$FRAME-$SIZE_T*16`($sp) $PUSH r16,`$FRAME-$SIZE_T*16`($sp)
@ -799,16 +841,61 @@ Lenc_compact_done:
bne Ldec_unaligned bne Ldec_unaligned
Ldec_unaligned_ok: Ldec_unaligned_ok:
___
$code.=<<___ if (!$LITTLE_ENDIAN);
lwz $s0,0($inp) lwz $s0,0($inp)
lwz $s1,4($inp) lwz $s1,4($inp)
lwz $s2,8($inp) lwz $s2,8($inp)
lwz $s3,12($inp) lwz $s3,12($inp)
___
$code.=<<___ if ($LITTLE_ENDIAN);
lwz $t0,0($inp)
lwz $t1,4($inp)
lwz $t2,8($inp)
lwz $t3,12($inp)
rotlwi $s0,$t0,8
rotlwi $s1,$t1,8
rotlwi $s2,$t2,8
rotlwi $s3,$t3,8
rlwimi $s0,$t0,24,0,7
rlwimi $s1,$t1,24,0,7
rlwimi $s2,$t2,24,0,7
rlwimi $s3,$t3,24,0,7
rlwimi $s0,$t0,24,16,23
rlwimi $s1,$t1,24,16,23
rlwimi $s2,$t2,24,16,23
rlwimi $s3,$t3,24,16,23
___
$code.=<<___;
bl LAES_Td bl LAES_Td
bl Lppc_AES_decrypt_compact bl Lppc_AES_decrypt_compact
$POP $out,`$FRAME-$SIZE_T*19`($sp)
___
$code.=<<___ if ($LITTLE_ENDIAN);
rotlwi $t0,$s0,8
rotlwi $t1,$s1,8
rotlwi $t2,$s2,8
rotlwi $t3,$s3,8
rlwimi $t0,$s0,24,0,7
rlwimi $t1,$s1,24,0,7
rlwimi $t2,$s2,24,0,7
rlwimi $t3,$s3,24,0,7
rlwimi $t0,$s0,24,16,23
rlwimi $t1,$s1,24,16,23
rlwimi $t2,$s2,24,16,23
rlwimi $t3,$s3,24,16,23
stw $t0,0($out)
stw $t1,4($out)
stw $t2,8($out)
stw $t3,12($out)
___
$code.=<<___ if (!$LITTLE_ENDIAN);
stw $s0,0($out) stw $s0,0($out)
stw $s1,4($out) stw $s1,4($out)
stw $s2,8($out) stw $s2,8($out)
stw $s3,12($out) stw $s3,12($out)
___
$code.=<<___;
b Ldec_done b Ldec_done
Ldec_unaligned: Ldec_unaligned:
@ -851,6 +938,7 @@ Ldec_xpage:
bl LAES_Td bl LAES_Td
bl Lppc_AES_decrypt_compact bl Lppc_AES_decrypt_compact
$POP $out,`$FRAME-$SIZE_T*19`($sp)
extrwi $acc00,$s0,8,0 extrwi $acc00,$s0,8,0
extrwi $acc01,$s0,8,8 extrwi $acc01,$s0,8,8
@ -883,8 +971,6 @@ Ldec_xpage:
Ldec_done: Ldec_done:
$POP r0,`$FRAME+$LRSAVE`($sp) $POP r0,`$FRAME+$LRSAVE`($sp)
$POP $toc,`$FRAME-$SIZE_T*20`($sp)
$POP r13,`$FRAME-$SIZE_T*19`($sp)
$POP r14,`$FRAME-$SIZE_T*18`($sp) $POP r14,`$FRAME-$SIZE_T*18`($sp)
$POP r15,`$FRAME-$SIZE_T*17`($sp) $POP r15,`$FRAME-$SIZE_T*17`($sp)
$POP r16,`$FRAME-$SIZE_T*16`($sp) $POP r16,`$FRAME-$SIZE_T*16`($sp)
@ -1355,6 +1441,7 @@ Ldec_compact_done:
blr blr
.long 0 .long 0
.byte 0,12,0x14,0,0,0,0,0 .byte 0,12,0x14,0,0,0,0,0
.size .AES_decrypt,.-.AES_decrypt
.asciz "AES for PPC, CRYPTOGAMS by <appro\@openssl.org>" .asciz "AES for PPC, CRYPTOGAMS by <appro\@openssl.org>"
.align 7 .align 7

View File

@ -783,6 +783,7 @@ $code.=<<___;
.type private_AES_set_encrypt_key,\@function .type private_AES_set_encrypt_key,\@function
.align 16 .align 16
private_AES_set_encrypt_key: private_AES_set_encrypt_key:
_s390x_AES_set_encrypt_key:
lghi $t0,0 lghi $t0,0
cl${g}r $inp,$t0 cl${g}r $inp,$t0
je .Lminus1 je .Lminus1
@ -836,7 +837,8 @@ $code.=<<___ if (!$softonly);
je 1f je 1f
lg %r1,24($inp) lg %r1,24($inp)
stg %r1,24($key) 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 st %r5,240($key) # save km code
lghi %r2,0 lghi %r2,0
br %r14 br %r14
@ -844,7 +846,7 @@ ___
$code.=<<___; $code.=<<___;
.align 16 .align 16
.Lekey_internal: .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 larl $tbl,AES_Te+2048
@ -904,8 +906,9 @@ $code.=<<___;
la $key,16($key) # key+=4 la $key,16($key) # key+=4
la $t3,4($t3) # i++ la $t3,4($t3) # i++
brct $rounds,.L128_loop brct $rounds,.L128_loop
lghi $t0,10
lghi %r2,0 lghi %r2,0
lm${g} %r6,%r13,6*$SIZE_T($sp) lm${g} %r4,%r13,4*$SIZE_T($sp)
br $ra br $ra
.align 16 .align 16
@ -952,8 +955,9 @@ $code.=<<___;
st $s2,32($key) st $s2,32($key)
st $s3,36($key) st $s3,36($key)
brct $rounds,.L192_continue brct $rounds,.L192_continue
lghi $t0,12
lghi %r2,0 lghi %r2,0
lm${g} %r6,%r13,6*$SIZE_T($sp) lm${g} %r4,%r13,4*$SIZE_T($sp)
br $ra br $ra
.align 16 .align 16
@ -1014,8 +1018,9 @@ $code.=<<___;
st $s2,40($key) st $s2,40($key)
st $s3,44($key) st $s3,44($key)
brct $rounds,.L256_continue brct $rounds,.L256_continue
lghi $t0,14
lghi %r2,0 lghi %r2,0
lm${g} %r6,%r13,6*$SIZE_T($sp) lm${g} %r4,%r13,4*$SIZE_T($sp)
br $ra br $ra
.align 16 .align 16
@ -1066,34 +1071,26 @@ $code.=<<___;
.type private_AES_set_decrypt_key,\@function .type private_AES_set_decrypt_key,\@function
.align 16 .align 16
private_AES_set_decrypt_key: private_AES_set_decrypt_key:
st${g} $key,4*$SIZE_T($sp) # I rely on AES_set_encrypt_key to #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! st${g} $ra,14*$SIZE_T($sp) # save non-volatile registers and $key!
bras $ra,AES_set_encrypt_key bras $ra,_s390x_AES_set_encrypt_key
l${g} $key,4*$SIZE_T($sp) #l${g} $key,4*$SIZE_T($sp)
l${g} $ra,14*$SIZE_T($sp) l${g} $ra,14*$SIZE_T($sp)
ltgr %r2,%r2 ltgr %r2,%r2
bnzr $ra bnzr $ra
___ ___
$code.=<<___ if (!$softonly); $code.=<<___ if (!$softonly);
l $t0,240($key) #l $t0,240($key)
lhi $t1,16 lhi $t1,16
cr $t0,$t1 cr $t0,$t1
jl .Lgo jl .Lgo
oill $t0,0x80 # set "decrypt" bit oill $t0,0x80 # set "decrypt" bit
st $t0,240($key) st $t0,240($key)
br $ra 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.=<<___; $code.=<<___;
.align 16
.Lgo: llgf $rounds,240($key) .Lgo: lgr $rounds,$t0 #llgf $rounds,240($key)
la $i1,0($key) la $i1,0($key)
sllg $i2,$rounds,4 sllg $i2,$rounds,4
la $i2,0($i2,$key) la $i2,0($i2,$key)
@ -1601,11 +1598,11 @@ $code.=<<___ if(1);
lghi $s1,0x7f lghi $s1,0x7f
nr $s1,%r0 nr $s1,%r0
lghi %r0,0 # query capability vector lghi %r0,0 # query capability vector
la %r1,2*$SIZE_T($sp) la %r1,$tweak-16($sp)
.long 0xb92e0042 # km %r4,%r2 .long 0xb92e0042 # km %r4,%r2
llihh %r1,0x8000 llihh %r1,0x8000
srlg %r1,%r1,32($s1) # check for 32+function code srlg %r1,%r1,32($s1) # check for 32+function code
ng %r1,2*$SIZE_T($sp) ng %r1,$tweak-16($sp)
lgr %r0,$s0 # restore the function code lgr %r0,$s0 # restore the function code
la %r1,0($key1) # restore $key1 la %r1,0($key1) # restore $key1
jz .Lxts_km_vanilla jz .Lxts_km_vanilla
@ -1631,7 +1628,7 @@ $code.=<<___ if(1);
lrvg $s0,$tweak+0($sp) # load the last tweak lrvg $s0,$tweak+0($sp) # load the last tweak
lrvg $s1,$tweak+8($sp) lrvg $s1,$tweak+8($sp)
stmg %r0,%r3,$tweak-32(%r1) # wipe copy of the key stmg %r0,%r3,$tweak-32($sp) # wipe copy of the key
nill %r0,0xffdf # switch back to original function code nill %r0,0xffdf # switch back to original function code
la %r1,0($key1) # restore pointer to $key1 la %r1,0($key1) # restore pointer to $key1
@ -1687,11 +1684,9 @@ $code.=<<___;
lghi $i1,0x87 lghi $i1,0x87
srag $i2,$s1,63 # broadcast upper bit srag $i2,$s1,63 # broadcast upper bit
ngr $i1,$i2 # rem ngr $i1,$i2 # rem
srlg $i2,$s0,63 # carry bit from lower half algr $s0,$s0
sllg $s0,$s0,1 alcgr $s1,$s1
sllg $s1,$s1,1
xgr $s0,$i1 xgr $s0,$i1
ogr $s1,$i2
.Lxts_km_start: .Lxts_km_start:
lrvgr $i1,$s0 # flip byte order lrvgr $i1,$s0 # flip byte order
lrvgr $i2,$s1 lrvgr $i2,$s1
@ -1748,11 +1743,9 @@ $code.=<<___;
lghi $i1,0x87 lghi $i1,0x87
srag $i2,$s1,63 # broadcast upper bit srag $i2,$s1,63 # broadcast upper bit
ngr $i1,$i2 # rem ngr $i1,$i2 # rem
srlg $i2,$s0,63 # carry bit from lower half algr $s0,$s0
sllg $s0,$s0,1 alcgr $s1,$s1
sllg $s1,$s1,1
xgr $s0,$i1 xgr $s0,$i1
ogr $s1,$i2
ltr $len,$len # clear zero flag ltr $len,$len # clear zero flag
br $ra br $ra
@ -1784,8 +1777,8 @@ $code.=<<___ if (!$softonly);
clr %r0,%r1 clr %r0,%r1
jl .Lxts_enc_software jl .Lxts_enc_software
st${g} $ra,5*$SIZE_T($sp)
stm${g} %r6,$s3,6*$SIZE_T($sp) stm${g} %r6,$s3,6*$SIZE_T($sp)
st${g} $ra,14*$SIZE_T($sp)
sllg $len,$len,4 # $len&=~15 sllg $len,$len,4 # $len&=~15
slgr $out,$inp slgr $out,$inp
@ -1833,9 +1826,9 @@ $code.=<<___ if (!$softonly);
stg $i2,8($i3) stg $i2,8($i3)
.Lxts_enc_km_done: .Lxts_enc_km_done:
l${g} $ra,14*$SIZE_T($sp) stg $sp,$tweak+0($sp) # wipe tweak
st${g} $sp,$tweak($sp) # wipe tweak stg $sp,$tweak+8($sp)
st${g} $sp,$tweak($sp) l${g} $ra,5*$SIZE_T($sp)
lm${g} %r6,$s3,6*$SIZE_T($sp) lm${g} %r6,$s3,6*$SIZE_T($sp)
br $ra br $ra
.align 16 .align 16
@ -1846,12 +1839,11 @@ $code.=<<___;
slgr $out,$inp slgr $out,$inp
xgr $s0,$s0 # clear upper half l${g} $s3,$stdframe($sp) # ivp
xgr $s1,$s1 llgf $s0,0($s3) # load iv
lrv $s0,$stdframe+4($sp) # load secno llgf $s1,4($s3)
lrv $s1,$stdframe+0($sp) llgf $s2,8($s3)
xgr $s2,$s2 llgf $s3,12($s3)
xgr $s3,$s3
stm${g} %r2,%r5,2*$SIZE_T($sp) stm${g} %r2,%r5,2*$SIZE_T($sp)
la $key,0($key2) la $key,0($key2)
larl $tbl,AES_Te larl $tbl,AES_Te
@ -1867,11 +1859,9 @@ $code.=<<___;
lghi %r1,0x87 lghi %r1,0x87
srag %r0,$s3,63 # broadcast upper bit srag %r0,$s3,63 # broadcast upper bit
ngr %r1,%r0 # rem ngr %r1,%r0 # rem
srlg %r0,$s1,63 # carry bit from lower half algr $s1,$s1
sllg $s1,$s1,1 alcgr $s3,$s3
sllg $s3,$s3,1
xgr $s1,%r1 xgr $s1,%r1
ogr $s3,%r0
lrvgr $s1,$s1 # flip byte order lrvgr $s1,$s1 # flip byte order
lrvgr $s3,$s3 lrvgr $s3,$s3
srlg $s0,$s1,32 # smash the tweak to 4x32-bits srlg $s0,$s1,32 # smash the tweak to 4x32-bits
@ -1920,11 +1910,9 @@ $code.=<<___;
lghi %r1,0x87 lghi %r1,0x87
srag %r0,$s3,63 # broadcast upper bit srag %r0,$s3,63 # broadcast upper bit
ngr %r1,%r0 # rem ngr %r1,%r0 # rem
srlg %r0,$s1,63 # carry bit from lower half algr $s1,$s1
sllg $s1,$s1,1 alcgr $s3,$s3
sllg $s3,$s3,1
xgr $s1,%r1 xgr $s1,%r1
ogr $s3,%r0
lrvgr $s1,$s1 # flip byte order lrvgr $s1,$s1 # flip byte order
lrvgr $s3,$s3 lrvgr $s3,$s3
srlg $s0,$s1,32 # smash the tweak to 4x32-bits srlg $s0,$s1,32 # smash the tweak to 4x32-bits
@ -1959,7 +1947,8 @@ $code.=<<___;
.size AES_xts_encrypt,.-AES_xts_encrypt .size AES_xts_encrypt,.-AES_xts_encrypt
___ ___
# void AES_xts_decrypt(const char *inp,char *out,size_t len, # void AES_xts_decrypt(const char *inp,char *out,size_t len,
# const AES_KEY *key1, const AES_KEY *key2,u64 secno); # const AES_KEY *key1, const AES_KEY *key2,
# const unsigned char iv[16]);
# #
$code.=<<___; $code.=<<___;
.globl AES_xts_decrypt .globl AES_xts_decrypt
@ -1991,8 +1980,8 @@ $code.=<<___ if (!$softonly);
clr %r0,%r1 clr %r0,%r1
jl .Lxts_dec_software jl .Lxts_dec_software
st${g} $ra,5*$SIZE_T($sp)
stm${g} %r6,$s3,6*$SIZE_T($sp) stm${g} %r6,$s3,6*$SIZE_T($sp)
st${g} $ra,14*$SIZE_T($sp)
nill $len,0xfff0 # $len&=~15 nill $len,0xfff0 # $len&=~15
slgr $out,$inp slgr $out,$inp
@ -2031,11 +2020,9 @@ $code.=<<___ if (!$softonly);
lghi $i1,0x87 lghi $i1,0x87
srag $i2,$s1,63 # broadcast upper bit srag $i2,$s1,63 # broadcast upper bit
ngr $i1,$i2 # rem ngr $i1,$i2 # rem
srlg $i2,$s0,63 # carry bit from lower half algr $s0,$s0
sllg $s0,$s0,1 alcgr $s1,$s1
sllg $s1,$s1,1
xgr $s0,$i1 xgr $s0,$i1
ogr $s1,$i2
lrvgr $i1,$s0 # flip byte order lrvgr $i1,$s0 # flip byte order
lrvgr $i2,$s1 lrvgr $i2,$s1
@ -2078,9 +2065,9 @@ $code.=<<___ if (!$softonly);
stg $s2,0($i3) stg $s2,0($i3)
stg $s3,8($i3) stg $s3,8($i3)
.Lxts_dec_km_done: .Lxts_dec_km_done:
l${g} $ra,14*$SIZE_T($sp) stg $sp,$tweak+0($sp) # wipe tweak
st${g} $sp,$tweak($sp) # wipe tweak stg $sp,$tweak+8($sp)
st${g} $sp,$tweak($sp) l${g} $ra,5*$SIZE_T($sp)
lm${g} %r6,$s3,6*$SIZE_T($sp) lm${g} %r6,$s3,6*$SIZE_T($sp)
br $ra br $ra
.align 16 .align 16
@ -2092,12 +2079,11 @@ $code.=<<___;
srlg $len,$len,4 srlg $len,$len,4
slgr $out,$inp slgr $out,$inp
xgr $s0,$s0 # clear upper half l${g} $s3,$stdframe($sp) # ivp
xgr $s1,$s1 llgf $s0,0($s3) # load iv
lrv $s0,$stdframe+4($sp) # load secno llgf $s1,4($s3)
lrv $s1,$stdframe+0($sp) llgf $s2,8($s3)
xgr $s2,$s2 llgf $s3,12($s3)
xgr $s3,$s3
stm${g} %r2,%r5,2*$SIZE_T($sp) stm${g} %r2,%r5,2*$SIZE_T($sp)
la $key,0($key2) la $key,0($key2)
larl $tbl,AES_Te larl $tbl,AES_Te
@ -2116,11 +2102,9 @@ $code.=<<___;
lghi %r1,0x87 lghi %r1,0x87
srag %r0,$s3,63 # broadcast upper bit srag %r0,$s3,63 # broadcast upper bit
ngr %r1,%r0 # rem ngr %r1,%r0 # rem
srlg %r0,$s1,63 # carry bit from lower half algr $s1,$s1
sllg $s1,$s1,1 alcgr $s3,$s3
sllg $s3,$s3,1
xgr $s1,%r1 xgr $s1,%r1
ogr $s3,%r0
lrvgr $s1,$s1 # flip byte order lrvgr $s1,$s1 # flip byte order
lrvgr $s3,$s3 lrvgr $s3,$s3
srlg $s0,$s1,32 # smash the tweak to 4x32-bits srlg $s0,$s1,32 # smash the tweak to 4x32-bits
@ -2159,11 +2143,9 @@ $code.=<<___;
lghi %r1,0x87 lghi %r1,0x87
srag %r0,$s3,63 # broadcast upper bit srag %r0,$s3,63 # broadcast upper bit
ngr %r1,%r0 # rem ngr %r1,%r0 # rem
srlg %r0,$s1,63 # carry bit from lower half algr $s1,$s1
sllg $s1,$s1,1 alcgr $s3,$s3
sllg $s3,$s3,1
xgr $s1,%r1 xgr $s1,%r1
ogr $s3,%r0
lrvgr $i2,$s1 # flip byte order lrvgr $i2,$s1 # flip byte order
lrvgr $i3,$s3 lrvgr $i3,$s3
stmg $i2,$i3,$tweak($sp) # save the 1st tweak stmg $i2,$i3,$tweak($sp) # save the 1st tweak
@ -2179,11 +2161,9 @@ $code.=<<___;
lghi %r1,0x87 lghi %r1,0x87
srag %r0,$s3,63 # broadcast upper bit srag %r0,$s3,63 # broadcast upper bit
ngr %r1,%r0 # rem ngr %r1,%r0 # rem
srlg %r0,$s1,63 # carry bit from lower half algr $s1,$s1
sllg $s1,$s1,1 alcgr $s3,$s3
sllg $s3,$s3,1
xgr $s1,%r1 xgr $s1,%r1
ogr $s3,%r0
lrvgr $s1,$s1 # flip byte order lrvgr $s1,$s1 # flip byte order
lrvgr $s3,$s3 lrvgr $s3,$s3
srlg $s0,$s1,32 # smash the tweak to 4x32-bits srlg $s0,$s1,32 # smash the tweak to 4x32-bits

View File

@ -19,9 +19,10 @@
# Performance in number of cycles per processed byte for 128-bit key: # Performance in number of cycles per processed byte for 128-bit key:
# #
# ECB encrypt ECB decrypt CBC large chunk # ECB encrypt ECB decrypt CBC large chunk
# AMD64 33 41 13.0 # AMD64 33 43 13.0
# EM64T 38 59 18.6(*) # EM64T 38 56 18.6(*)
# Core 2 30 43 14.5(*) # Core 2 30 42 14.5(*)
# Atom 65 86 32.1(*)
# #
# (*) with hyper-threading off # (*) with hyper-threading off
@ -36,7 +37,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or ( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
die "can't locate x86_64-xlate.pl"; die "can't locate x86_64-xlate.pl";
open STDOUT,"| $^X $xlate $flavour $output"; open OUT,"| \"$^X\" $xlate $flavour $output";
*STDOUT=*OUT;
$verticalspin=1; # unlike 32-bit version $verticalspin performs $verticalspin=1; # unlike 32-bit version $verticalspin performs
# ~15% better on both AMD and Intel cores # ~15% better on both AMD and Intel cores
@ -365,68 +367,66 @@ $code.=<<___;
movzb `&lo("$s0")`,$t0 movzb `&lo("$s0")`,$t0
movzb `&lo("$s1")`,$t1 movzb `&lo("$s1")`,$t1
movzb `&lo("$s2")`,$t2 movzb `&lo("$s2")`,$t2
movzb ($sbox,$t0,1),$t0
movzb ($sbox,$t1,1),$t1
movzb ($sbox,$t2,1),$t2
movzb `&lo("$s3")`,$t3 movzb `&lo("$s3")`,$t3
movzb `&hi("$s1")`,$acc0 movzb `&hi("$s1")`,$acc0
movzb `&hi("$s2")`,$acc1 movzb `&hi("$s2")`,$acc1
movzb ($sbox,$t3,1),$t3
movzb ($sbox,$acc0,1),$t4 #$t0
movzb ($sbox,$acc1,1),$t5 #$t1
movzb `&hi("$s3")`,$acc2
movzb `&hi("$s0")`,$acc0
shr \$16,$s2 shr \$16,$s2
movzb `&hi("$s3")`,$acc2
movzb ($sbox,$t0,1),$t0
movzb ($sbox,$t1,1),$t1
movzb ($sbox,$t2,1),$t2
movzb ($sbox,$t3,1),$t3
movzb ($sbox,$acc0,1),$t4 #$t0
movzb `&hi("$s0")`,$acc0
movzb ($sbox,$acc1,1),$t5 #$t1
movzb `&lo("$s2")`,$acc1
movzb ($sbox,$acc2,1),$acc2 #$t2 movzb ($sbox,$acc2,1),$acc2 #$t2
movzb ($sbox,$acc0,1),$acc0 #$t3 movzb ($sbox,$acc0,1),$acc0 #$t3
shr \$16,$s3
movzb `&lo("$s2")`,$acc1
shl \$8,$t4 shl \$8,$t4
shr \$16,$s3
shl \$8,$t5 shl \$8,$t5
movzb ($sbox,$acc1,1),$acc1 #$t0
xor $t4,$t0 xor $t4,$t0
xor $t5,$t1
movzb `&lo("$s3")`,$t4
shr \$16,$s0 shr \$16,$s0
movzb `&lo("$s3")`,$t4
shr \$16,$s1 shr \$16,$s1
movzb `&lo("$s0")`,$t5 xor $t5,$t1
shl \$8,$acc2 shl \$8,$acc2
shl \$8,$acc0 movzb `&lo("$s0")`,$t5
movzb ($sbox,$t4,1),$t4 #$t1 movzb ($sbox,$acc1,1),$acc1 #$t0
movzb ($sbox,$t5,1),$t5 #$t2
xor $acc2,$t2 xor $acc2,$t2
xor $acc0,$t3
shl \$8,$acc0
movzb `&lo("$s1")`,$acc2 movzb `&lo("$s1")`,$acc2
movzb `&hi("$s3")`,$acc0
shl \$16,$acc1 shl \$16,$acc1
movzb ($sbox,$acc2,1),$acc2 #$t3 xor $acc0,$t3
movzb ($sbox,$acc0,1),$acc0 #$t0 movzb ($sbox,$t4,1),$t4 #$t1
movzb `&hi("$s3")`,$acc0
movzb ($sbox,$t5,1),$t5 #$t2
xor $acc1,$t0 xor $acc1,$t0
movzb `&hi("$s0")`,$acc1
shr \$8,$s2 shr \$8,$s2
movzb `&hi("$s0")`,$acc1
shl \$16,$t4
shr \$8,$s1 shr \$8,$s1
shl \$16,$t5
xor $t4,$t1
movzb ($sbox,$acc2,1),$acc2 #$t3
movzb ($sbox,$acc0,1),$acc0 #$t0
movzb ($sbox,$acc1,1),$acc1 #$t1 movzb ($sbox,$acc1,1),$acc1 #$t1
movzb ($sbox,$s2,1),$s3 #$t3 movzb ($sbox,$s2,1),$s3 #$t3
movzb ($sbox,$s1,1),$s2 #$t2 movzb ($sbox,$s1,1),$s2 #$t2
shl \$16,$t4
shl \$16,$t5
shl \$16,$acc2
xor $t4,$t1
xor $t5,$t2
xor $acc2,$t3
shl \$16,$acc2
xor $t5,$t2
shl \$24,$acc0 shl \$24,$acc0
xor $acc2,$t3
shl \$24,$acc1 shl \$24,$acc1
shl \$24,$s3
xor $acc0,$t0 xor $acc0,$t0
shl \$24,$s2 shl \$24,$s3
xor $acc1,$t1 xor $acc1,$t1
shl \$24,$s2
mov $t0,$s0 mov $t0,$s0
mov $t1,$s1 mov $t1,$s1
xor $t2,$s2 xor $t2,$s2
@ -465,12 +465,12 @@ sub enctransform()
{ my ($t3,$r20,$r21)=($acc2,"%r8d","%r9d"); { my ($t3,$r20,$r21)=($acc2,"%r8d","%r9d");
$code.=<<___; $code.=<<___;
mov $s0,$acc0 mov \$0x80808080,$t0
mov $s1,$acc1 mov \$0x80808080,$t1
and \$0x80808080,$acc0 and $s0,$t0
and \$0x80808080,$acc1 and $s1,$t1
mov $acc0,$t0 mov $t0,$acc0
mov $acc1,$t1 mov $t1,$acc1
shr \$7,$t0 shr \$7,$t0
lea ($s0,$s0),$r20 lea ($s0,$s0),$r20
shr \$7,$t1 shr \$7,$t1
@ -488,25 +488,25 @@ $code.=<<___;
xor $r20,$s0 xor $r20,$s0
xor $r21,$s1 xor $r21,$s1
mov $s2,$acc0 mov \$0x80808080,$t2
mov $s3,$acc1
rol \$24,$s0 rol \$24,$s0
mov \$0x80808080,$t3
rol \$24,$s1 rol \$24,$s1
and \$0x80808080,$acc0 and $s2,$t2
and \$0x80808080,$acc1 and $s3,$t3
xor $r20,$s0 xor $r20,$s0
xor $r21,$s1 xor $r21,$s1
mov $acc0,$t2 mov $t2,$acc0
mov $acc1,$t3
ror \$16,$t0 ror \$16,$t0
mov $t3,$acc1
ror \$16,$t1 ror \$16,$t1
shr \$7,$t2
lea ($s2,$s2),$r20 lea ($s2,$s2),$r20
shr \$7,$t2
xor $t0,$s0 xor $t0,$s0
xor $t1,$s1
shr \$7,$t3 shr \$7,$t3
lea ($s3,$s3),$r21 xor $t1,$s1
ror \$8,$t0 ror \$8,$t0
lea ($s3,$s3),$r21
ror \$8,$t1 ror \$8,$t1
sub $t2,$acc0 sub $t2,$acc0
sub $t3,$acc1 sub $t3,$acc1
@ -522,23 +522,23 @@ $code.=<<___;
xor $acc0,$r20 xor $acc0,$r20
xor $acc1,$r21 xor $acc1,$r21
ror \$16,$t2
xor $r20,$s2 xor $r20,$s2
ror \$16,$t3
xor $r21,$s3 xor $r21,$s3
rol \$24,$s2 rol \$24,$s2
mov 0($sbox),$acc0 # prefetch Te4
rol \$24,$s3 rol \$24,$s3
xor $r20,$s2 xor $r20,$s2
xor $r21,$s3
mov 0($sbox),$acc0 # prefetch Te4
ror \$16,$t2
ror \$16,$t3
mov 64($sbox),$acc1 mov 64($sbox),$acc1
xor $t2,$s2 xor $r21,$s3
xor $t3,$s3
mov 128($sbox),$r20 mov 128($sbox),$r20
ror \$8,$t2
ror \$8,$t3
mov 192($sbox),$r21
xor $t2,$s2 xor $t2,$s2
ror \$8,$t2
xor $t3,$s3
ror \$8,$t3
xor $t2,$s2
mov 192($sbox),$r21
xor $t3,$s3 xor $t3,$s3
___ ___
} }
@ -935,70 +935,69 @@ $code.=<<___;
movzb `&lo("$s0")`,$t0 movzb `&lo("$s0")`,$t0
movzb `&lo("$s1")`,$t1 movzb `&lo("$s1")`,$t1
movzb `&lo("$s2")`,$t2 movzb `&lo("$s2")`,$t2
movzb ($sbox,$t0,1),$t0
movzb ($sbox,$t1,1),$t1
movzb ($sbox,$t2,1),$t2
movzb `&lo("$s3")`,$t3 movzb `&lo("$s3")`,$t3
movzb `&hi("$s3")`,$acc0 movzb `&hi("$s3")`,$acc0
movzb `&hi("$s0")`,$acc1 movzb `&hi("$s0")`,$acc1
movzb ($sbox,$t3,1),$t3 shr \$16,$s3
movzb ($sbox,$acc0,1),$t4 #$t0
movzb ($sbox,$acc1,1),$t5 #$t1
movzb `&hi("$s1")`,$acc2 movzb `&hi("$s1")`,$acc2
movzb ($sbox,$t0,1),$t0
movzb ($sbox,$t1,1),$t1
movzb ($sbox,$t2,1),$t2
movzb ($sbox,$t3,1),$t3
movzb ($sbox,$acc0,1),$t4 #$t0
movzb `&hi("$s2")`,$acc0 movzb `&hi("$s2")`,$acc0
shr \$16,$s2 movzb ($sbox,$acc1,1),$t5 #$t1
movzb ($sbox,$acc2,1),$acc2 #$t2 movzb ($sbox,$acc2,1),$acc2 #$t2
movzb ($sbox,$acc0,1),$acc0 #$t3 movzb ($sbox,$acc0,1),$acc0 #$t3
shr \$16,$s3
movzb `&lo("$s2")`,$acc1 shr \$16,$s2
shl \$8,$t4
shl \$8,$t5 shl \$8,$t5
movzb ($sbox,$acc1,1),$acc1 #$t0 shl \$8,$t4
xor $t4,$t0 movzb `&lo("$s2")`,$acc1
xor $t5,$t1
movzb `&lo("$s3")`,$t4
shr \$16,$s0 shr \$16,$s0
xor $t4,$t0
shr \$16,$s1 shr \$16,$s1
movzb `&lo("$s0")`,$t5 movzb `&lo("$s3")`,$t4
shl \$8,$acc2 shl \$8,$acc2
xor $t5,$t1
shl \$8,$acc0 shl \$8,$acc0
movzb ($sbox,$t4,1),$t4 #$t1 movzb `&lo("$s0")`,$t5
movzb ($sbox,$t5,1),$t5 #$t2 movzb ($sbox,$acc1,1),$acc1 #$t0
xor $acc2,$t2 xor $acc2,$t2
xor $acc0,$t3
movzb `&lo("$s1")`,$acc2 movzb `&lo("$s1")`,$acc2
movzb `&hi("$s1")`,$acc0
shl \$16,$acc1
movzb ($sbox,$acc2,1),$acc2 #$t3
movzb ($sbox,$acc0,1),$acc0 #$t0
xor $acc1,$t0
shl \$16,$acc1
xor $acc0,$t3
movzb ($sbox,$t4,1),$t4 #$t1
movzb `&hi("$s1")`,$acc0
movzb ($sbox,$acc2,1),$acc2 #$t3
xor $acc1,$t0
movzb ($sbox,$t5,1),$t5 #$t2
movzb `&hi("$s2")`,$acc1 movzb `&hi("$s2")`,$acc1
shl \$16,$acc2
shl \$16,$t4 shl \$16,$t4
shl \$16,$t5 shl \$16,$t5
movzb ($sbox,$acc1,1),$s1 #$t1 xor $acc2,$t3
movzb `&hi("$s3")`,$acc2
xor $t4,$t1 xor $t4,$t1
shr \$8,$s0
xor $t5,$t2 xor $t5,$t2
movzb `&hi("$s3")`,$acc1 movzb ($sbox,$acc0,1),$acc0 #$t0
shr \$8,$s0 movzb ($sbox,$acc1,1),$s1 #$t1
shl \$16,$acc2 movzb ($sbox,$acc2,1),$s2 #$t2
movzb ($sbox,$acc1,1),$s2 #$t2
movzb ($sbox,$s0,1),$s3 #$t3 movzb ($sbox,$s0,1),$s3 #$t3
xor $acc2,$t3
mov $t0,$s0
shl \$24,$acc0 shl \$24,$acc0
shl \$24,$s1 shl \$24,$s1
shl \$24,$s2 shl \$24,$s2
xor $acc0,$t0 xor $acc0,$s0
shl \$24,$s3 shl \$24,$s3
xor $t1,$s1 xor $t1,$s1
mov $t0,$s0
xor $t2,$s2 xor $t2,$s2
xor $t3,$s3 xor $t3,$s3
___ ___
@ -1013,12 +1012,12 @@ sub dectransform()
my $prefetch = shift; my $prefetch = shift;
$code.=<<___; $code.=<<___;
mov $tp10,$acc0 mov $mask80,$tp40
mov $tp18,$acc8 mov $mask80,$tp48
and $mask80,$acc0 and $tp10,$tp40
and $mask80,$acc8 and $tp18,$tp48
mov $acc0,$tp40 mov $tp40,$acc0
mov $acc8,$tp48 mov $tp48,$acc8
shr \$7,$tp40 shr \$7,$tp40
lea ($tp10,$tp10),$tp20 lea ($tp10,$tp10),$tp20
shr \$7,$tp48 shr \$7,$tp48
@ -1029,15 +1028,15 @@ $code.=<<___;
and $maskfe,$tp28 and $maskfe,$tp28
and $mask1b,$acc0 and $mask1b,$acc0
and $mask1b,$acc8 and $mask1b,$acc8
xor $tp20,$acc0 xor $acc0,$tp20
xor $tp28,$acc8 xor $acc8,$tp28
mov $acc0,$tp20 mov $mask80,$tp80
mov $acc8,$tp28 mov $mask80,$tp88
and $mask80,$acc0 and $tp20,$tp80
and $mask80,$acc8 and $tp28,$tp88
mov $acc0,$tp80 mov $tp80,$acc0
mov $acc8,$tp88 mov $tp88,$acc8
shr \$7,$tp80 shr \$7,$tp80
lea ($tp20,$tp20),$tp40 lea ($tp20,$tp20),$tp40
shr \$7,$tp88 shr \$7,$tp88
@ -1048,15 +1047,15 @@ $code.=<<___;
and $maskfe,$tp48 and $maskfe,$tp48
and $mask1b,$acc0 and $mask1b,$acc0
and $mask1b,$acc8 and $mask1b,$acc8
xor $tp40,$acc0 xor $acc0,$tp40
xor $tp48,$acc8 xor $acc8,$tp48
mov $acc0,$tp40 mov $mask80,$tp80
mov $acc8,$tp48 mov $mask80,$tp88
and $mask80,$acc0 and $tp40,$tp80
and $mask80,$acc8 and $tp48,$tp88
mov $acc0,$tp80 mov $tp80,$acc0
mov $acc8,$tp88 mov $tp88,$acc8
shr \$7,$tp80 shr \$7,$tp80
xor $tp10,$tp20 # tp2^=tp1 xor $tp10,$tp20 # tp2^=tp1
shr \$7,$tp88 shr \$7,$tp88
@ -1081,51 +1080,51 @@ $code.=<<___;
mov $tp10,$acc0 mov $tp10,$acc0
mov $tp18,$acc8 mov $tp18,$acc8
xor $tp80,$tp40 # tp4^tp1^=tp8 xor $tp80,$tp40 # tp4^tp1^=tp8
xor $tp88,$tp48 # tp4^tp1^=tp8
shr \$32,$acc0 shr \$32,$acc0
xor $tp88,$tp48 # tp4^tp1^=tp8
shr \$32,$acc8 shr \$32,$acc8
xor $tp20,$tp80 # tp8^=tp8^tp2^tp1=tp2^tp1 xor $tp20,$tp80 # tp8^=tp8^tp2^tp1=tp2^tp1
xor $tp28,$tp88 # tp8^=tp8^tp2^tp1=tp2^tp1
rol \$8,`&LO("$tp10")` # ROTATE(tp1^tp8,8) rol \$8,`&LO("$tp10")` # ROTATE(tp1^tp8,8)
xor $tp28,$tp88 # tp8^=tp8^tp2^tp1=tp2^tp1
rol \$8,`&LO("$tp18")` # ROTATE(tp1^tp8,8) rol \$8,`&LO("$tp18")` # ROTATE(tp1^tp8,8)
xor $tp40,$tp80 # tp2^tp1^=tp8^tp4^tp1=tp8^tp4^tp2 xor $tp40,$tp80 # tp2^tp1^=tp8^tp4^tp1=tp8^tp4^tp2
rol \$8,`&LO("$acc0")` # ROTATE(tp1^tp8,8)
xor $tp48,$tp88 # tp2^tp1^=tp8^tp4^tp1=tp8^tp4^tp2 xor $tp48,$tp88 # tp2^tp1^=tp8^tp4^tp1=tp8^tp4^tp2
rol \$8,`&LO("$acc0")` # ROTATE(tp1^tp8,8)
rol \$8,`&LO("$acc8")` # ROTATE(tp1^tp8,8) rol \$8,`&LO("$acc8")` # ROTATE(tp1^tp8,8)
xor `&LO("$tp80")`,`&LO("$tp10")` xor `&LO("$tp80")`,`&LO("$tp10")`
xor `&LO("$tp88")`,`&LO("$tp18")`
shr \$32,$tp80 shr \$32,$tp80
xor `&LO("$tp88")`,`&LO("$tp18")`
shr \$32,$tp88 shr \$32,$tp88
xor `&LO("$tp80")`,`&LO("$acc0")` xor `&LO("$tp80")`,`&LO("$acc0")`
xor `&LO("$tp88")`,`&LO("$acc8")` xor `&LO("$tp88")`,`&LO("$acc8")`
mov $tp20,$tp80 mov $tp20,$tp80
mov $tp28,$tp88
shr \$32,$tp80
shr \$32,$tp88
rol \$24,`&LO("$tp20")` # ROTATE(tp2^tp1^tp8,24) rol \$24,`&LO("$tp20")` # ROTATE(tp2^tp1^tp8,24)
mov $tp28,$tp88
rol \$24,`&LO("$tp28")` # ROTATE(tp2^tp1^tp8,24) rol \$24,`&LO("$tp28")` # ROTATE(tp2^tp1^tp8,24)
rol \$24,`&LO("$tp80")` # ROTATE(tp2^tp1^tp8,24) shr \$32,$tp80
rol \$24,`&LO("$tp88")` # ROTATE(tp2^tp1^tp8,24)
xor `&LO("$tp20")`,`&LO("$tp10")` xor `&LO("$tp20")`,`&LO("$tp10")`
shr \$32,$tp88
xor `&LO("$tp28")`,`&LO("$tp18")` xor `&LO("$tp28")`,`&LO("$tp18")`
rol \$24,`&LO("$tp80")` # ROTATE(tp2^tp1^tp8,24)
mov $tp40,$tp20 mov $tp40,$tp20
rol \$24,`&LO("$tp88")` # ROTATE(tp2^tp1^tp8,24)
mov $tp48,$tp28 mov $tp48,$tp28
shr \$32,$tp20
xor `&LO("$tp80")`,`&LO("$acc0")` xor `&LO("$tp80")`,`&LO("$acc0")`
shr \$32,$tp28
xor `&LO("$tp88")`,`&LO("$acc8")` xor `&LO("$tp88")`,`&LO("$acc8")`
`"mov 0($sbox),$mask80" if ($prefetch)` `"mov 0($sbox),$mask80" if ($prefetch)`
shr \$32,$tp20
shr \$32,$tp28
`"mov 64($sbox),$maskfe" if ($prefetch)`
rol \$16,`&LO("$tp40")` # ROTATE(tp4^tp1^tp8,16) rol \$16,`&LO("$tp40")` # ROTATE(tp4^tp1^tp8,16)
`"mov 64($sbox),$maskfe" if ($prefetch)`
rol \$16,`&LO("$tp48")` # ROTATE(tp4^tp1^tp8,16) rol \$16,`&LO("$tp48")` # ROTATE(tp4^tp1^tp8,16)
`"mov 128($sbox),$mask1b" if ($prefetch)` `"mov 128($sbox),$mask1b" if ($prefetch)`
rol \$16,`&LO("$tp20")` # ROTATE(tp4^tp1^tp8,16) rol \$16,`&LO("$tp20")` # ROTATE(tp4^tp1^tp8,16)
rol \$16,`&LO("$tp28")` # ROTATE(tp4^tp1^tp8,16)
`"mov 192($sbox),$tp80" if ($prefetch)` `"mov 192($sbox),$tp80" if ($prefetch)`
xor `&LO("$tp40")`,`&LO("$tp10")` xor `&LO("$tp40")`,`&LO("$tp10")`
rol \$16,`&LO("$tp28")` # ROTATE(tp4^tp1^tp8,16)
xor `&LO("$tp48")`,`&LO("$tp18")` xor `&LO("$tp48")`,`&LO("$tp18")`
`"mov 256($sbox),$tp88" if ($prefetch)` `"mov 256($sbox),$tp88" if ($prefetch)`
xor `&LO("$tp20")`,`&LO("$acc0")` xor `&LO("$tp20")`,`&LO("$acc0")`
@ -1301,10 +1300,6 @@ private_AES_set_encrypt_key:
call _x86_64_AES_set_encrypt_key call _x86_64_AES_set_encrypt_key
mov 8(%rsp),%r15
mov 16(%rsp),%r14
mov 24(%rsp),%r13
mov 32(%rsp),%r12
mov 40(%rsp),%rbp mov 40(%rsp),%rbp
mov 48(%rsp),%rbx mov 48(%rsp),%rbx
add \$56,%rsp add \$56,%rsp

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
#!/usr/bin/env perl #!/usr/bin/env perl
# ==================================================================== # ====================================================================
# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL # Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
# project. The module is, however, dual licensed under OpenSSL and # project. The module is, however, dual licensed under OpenSSL and
# CRYPTOGAMS licenses depending on where you obtain it. For further # CRYPTOGAMS licenses depending on where you obtain it. For further
# details see http://www.openssl.org/~appro/cryptogams/. # details see http://www.openssl.org/~appro/cryptogams/.
@ -43,6 +43,17 @@
# Add aesni_xts_[en|de]crypt. Westmere spends 1.50 cycles processing # Add aesni_xts_[en|de]crypt. Westmere spends 1.50 cycles processing
# one byte out of 8KB with 128-bit key, Sandy Bridge - 1.09. # one byte out of 8KB with 128-bit key, Sandy Bridge - 1.09.
######################################################################
# Current large-block performance in cycles per byte processed with
# 128-bit key (less is better).
#
# CBC en-/decrypt CTR XTS ECB
# Westmere 3.77/1.37 1.37 1.52 1.27
# * Bridge 5.07/0.98 0.99 1.09 0.91
# Haswell 4.44/0.80 0.97 1.03 0.72
# Atom 5.77/3.56 3.67 4.03 3.46
# Bulldozer 5.80/0.98 1.05 1.24 0.93
$PREFIX="aesni"; # if $PREFIX is set to "AES", the script $PREFIX="aesni"; # if $PREFIX is set to "AES", the script
# generates drop-in replacement for # generates drop-in replacement for
# crypto/aes/asm/aes-586.pl:-) # crypto/aes/asm/aes-586.pl:-)
@ -54,8 +65,8 @@ require "x86asm.pl";
&asm_init($ARGV[0],$0); &asm_init($ARGV[0],$0);
if ($PREFIX eq "aesni") { $movekey=*movups; } if ($PREFIX eq "aesni") { $movekey=\&movups; }
else { $movekey=*movups; } else { $movekey=\&movups; }
$len="eax"; $len="eax";
$rounds="ecx"; $rounds="ecx";
@ -196,37 +207,71 @@ sub aesni_generate1 # fully unrolled loop
# every *2nd* cycle. Thus 3x interleave was the one providing optimal # every *2nd* cycle. Thus 3x interleave was the one providing optimal
# utilization, i.e. when subroutine's throughput is virtually same as # utilization, i.e. when subroutine's throughput is virtually same as
# of non-interleaved subroutine [for number of input blocks up to 3]. # of non-interleaved subroutine [for number of input blocks up to 3].
# This is why it makes no sense to implement 2x subroutine. # This is why it originally made no sense to implement 2x subroutine.
# aes[enc|dec] latency in next processor generation is 8, but the # But times change and it became appropriate to spend extra 192 bytes
# instructions can be scheduled every cycle. Optimal interleave for # on 2x subroutine on Atom Silvermont account. For processors that
# new processor is therefore 8x, but it's unfeasible to accommodate it # can schedule aes[enc|dec] every cycle optimal interleave factor
# in XMM registers addreassable in 32-bit mode and therefore 6x is # equals to corresponding instructions latency. 8x is optimal for
# used instead... # * Bridge, but it's unfeasible to accommodate such implementation
# in XMM registers addreassable in 32-bit mode and therefore maximum
# of 6x is used instead...
sub aesni_generate2
{ my $p=shift;
&function_begin_B("_aesni_${p}rypt2");
&$movekey ($rndkey0,&QWP(0,$key));
&shl ($rounds,4);
&$movekey ($rndkey1,&QWP(16,$key));
&xorps ($inout0,$rndkey0);
&pxor ($inout1,$rndkey0);
&$movekey ($rndkey0,&QWP(32,$key));
&lea ($key,&DWP(32,$key,$rounds));
&neg ($rounds);
&add ($rounds,16);
&set_label("${p}2_loop");
eval"&aes${p} ($inout0,$rndkey1)";
eval"&aes${p} ($inout1,$rndkey1)";
&$movekey ($rndkey1,&QWP(0,$key,$rounds));
&add ($rounds,32);
eval"&aes${p} ($inout0,$rndkey0)";
eval"&aes${p} ($inout1,$rndkey0)";
&$movekey ($rndkey0,&QWP(-16,$key,$rounds));
&jnz (&label("${p}2_loop"));
eval"&aes${p} ($inout0,$rndkey1)";
eval"&aes${p} ($inout1,$rndkey1)";
eval"&aes${p}last ($inout0,$rndkey0)";
eval"&aes${p}last ($inout1,$rndkey0)";
&ret();
&function_end_B("_aesni_${p}rypt2");
}
sub aesni_generate3 sub aesni_generate3
{ my $p=shift; { my $p=shift;
&function_begin_B("_aesni_${p}rypt3"); &function_begin_B("_aesni_${p}rypt3");
&$movekey ($rndkey0,&QWP(0,$key)); &$movekey ($rndkey0,&QWP(0,$key));
&shr ($rounds,1); &shl ($rounds,4);
&$movekey ($rndkey1,&QWP(16,$key)); &$movekey ($rndkey1,&QWP(16,$key));
&lea ($key,&DWP(32,$key));
&xorps ($inout0,$rndkey0); &xorps ($inout0,$rndkey0);
&pxor ($inout1,$rndkey0); &pxor ($inout1,$rndkey0);
&pxor ($inout2,$rndkey0); &pxor ($inout2,$rndkey0);
&$movekey ($rndkey0,&QWP(0,$key)); &$movekey ($rndkey0,&QWP(32,$key));
&lea ($key,&DWP(32,$key,$rounds));
&neg ($rounds);
&add ($rounds,16);
&set_label("${p}3_loop"); &set_label("${p}3_loop");
eval"&aes${p} ($inout0,$rndkey1)"; eval"&aes${p} ($inout0,$rndkey1)";
eval"&aes${p} ($inout1,$rndkey1)"; eval"&aes${p} ($inout1,$rndkey1)";
&dec ($rounds);
eval"&aes${p} ($inout2,$rndkey1)"; eval"&aes${p} ($inout2,$rndkey1)";
&$movekey ($rndkey1,&QWP(16,$key)); &$movekey ($rndkey1,&QWP(0,$key,$rounds));
&add ($rounds,32);
eval"&aes${p} ($inout0,$rndkey0)"; eval"&aes${p} ($inout0,$rndkey0)";
eval"&aes${p} ($inout1,$rndkey0)"; eval"&aes${p} ($inout1,$rndkey0)";
&lea ($key,&DWP(32,$key));
eval"&aes${p} ($inout2,$rndkey0)"; eval"&aes${p} ($inout2,$rndkey0)";
&$movekey ($rndkey0,&QWP(0,$key)); &$movekey ($rndkey0,&QWP(-16,$key,$rounds));
&jnz (&label("${p}3_loop")); &jnz (&label("${p}3_loop"));
eval"&aes${p} ($inout0,$rndkey1)"; eval"&aes${p} ($inout0,$rndkey1)";
eval"&aes${p} ($inout1,$rndkey1)"; eval"&aes${p} ($inout1,$rndkey1)";
@ -248,27 +293,29 @@ sub aesni_generate4
&function_begin_B("_aesni_${p}rypt4"); &function_begin_B("_aesni_${p}rypt4");
&$movekey ($rndkey0,&QWP(0,$key)); &$movekey ($rndkey0,&QWP(0,$key));
&$movekey ($rndkey1,&QWP(16,$key)); &$movekey ($rndkey1,&QWP(16,$key));
&shr ($rounds,1); &shl ($rounds,4);
&lea ($key,&DWP(32,$key));
&xorps ($inout0,$rndkey0); &xorps ($inout0,$rndkey0);
&pxor ($inout1,$rndkey0); &pxor ($inout1,$rndkey0);
&pxor ($inout2,$rndkey0); &pxor ($inout2,$rndkey0);
&pxor ($inout3,$rndkey0); &pxor ($inout3,$rndkey0);
&$movekey ($rndkey0,&QWP(0,$key)); &$movekey ($rndkey0,&QWP(32,$key));
&lea ($key,&DWP(32,$key,$rounds));
&neg ($rounds);
&data_byte (0x0f,0x1f,0x40,0x00);
&add ($rounds,16);
&set_label("${p}4_loop"); &set_label("${p}4_loop");
eval"&aes${p} ($inout0,$rndkey1)"; eval"&aes${p} ($inout0,$rndkey1)";
eval"&aes${p} ($inout1,$rndkey1)"; eval"&aes${p} ($inout1,$rndkey1)";
&dec ($rounds);
eval"&aes${p} ($inout2,$rndkey1)"; eval"&aes${p} ($inout2,$rndkey1)";
eval"&aes${p} ($inout3,$rndkey1)"; eval"&aes${p} ($inout3,$rndkey1)";
&$movekey ($rndkey1,&QWP(16,$key)); &$movekey ($rndkey1,&QWP(0,$key,$rounds));
&add ($rounds,32);
eval"&aes${p} ($inout0,$rndkey0)"; eval"&aes${p} ($inout0,$rndkey0)";
eval"&aes${p} ($inout1,$rndkey0)"; eval"&aes${p} ($inout1,$rndkey0)";
&lea ($key,&DWP(32,$key));
eval"&aes${p} ($inout2,$rndkey0)"; eval"&aes${p} ($inout2,$rndkey0)";
eval"&aes${p} ($inout3,$rndkey0)"; eval"&aes${p} ($inout3,$rndkey0)";
&$movekey ($rndkey0,&QWP(0,$key)); &$movekey ($rndkey0,&QWP(-16,$key,$rounds));
&jnz (&label("${p}4_loop")); &jnz (&label("${p}4_loop"));
eval"&aes${p} ($inout0,$rndkey1)"; eval"&aes${p} ($inout0,$rndkey1)";
@ -289,43 +336,43 @@ sub aesni_generate6
&function_begin_B("_aesni_${p}rypt6"); &function_begin_B("_aesni_${p}rypt6");
&static_label("_aesni_${p}rypt6_enter"); &static_label("_aesni_${p}rypt6_enter");
&$movekey ($rndkey0,&QWP(0,$key)); &$movekey ($rndkey0,&QWP(0,$key));
&shr ($rounds,1); &shl ($rounds,4);
&$movekey ($rndkey1,&QWP(16,$key)); &$movekey ($rndkey1,&QWP(16,$key));
&lea ($key,&DWP(32,$key));
&xorps ($inout0,$rndkey0); &xorps ($inout0,$rndkey0);
&pxor ($inout1,$rndkey0); # pxor does better here &pxor ($inout1,$rndkey0); # pxor does better here
eval"&aes${p} ($inout0,$rndkey1)";
&pxor ($inout2,$rndkey0); &pxor ($inout2,$rndkey0);
eval"&aes${p} ($inout1,$rndkey1)"; eval"&aes${p} ($inout0,$rndkey1)";
&pxor ($inout3,$rndkey0); &pxor ($inout3,$rndkey0);
&dec ($rounds);
eval"&aes${p} ($inout2,$rndkey1)";
&pxor ($inout4,$rndkey0); &pxor ($inout4,$rndkey0);
eval"&aes${p} ($inout3,$rndkey1)"; eval"&aes${p} ($inout1,$rndkey1)";
&lea ($key,&DWP(32,$key,$rounds));
&neg ($rounds);
eval"&aes${p} ($inout2,$rndkey1)";
&pxor ($inout5,$rndkey0); &pxor ($inout5,$rndkey0);
&add ($rounds,16);
eval"&aes${p} ($inout3,$rndkey1)";
eval"&aes${p} ($inout4,$rndkey1)"; eval"&aes${p} ($inout4,$rndkey1)";
&$movekey ($rndkey0,&QWP(0,$key));
eval"&aes${p} ($inout5,$rndkey1)"; eval"&aes${p} ($inout5,$rndkey1)";
&$movekey ($rndkey0,&QWP(-16,$key,$rounds));
&jmp (&label("_aesni_${p}rypt6_enter")); &jmp (&label("_aesni_${p}rypt6_enter"));
&set_label("${p}6_loop",16); &set_label("${p}6_loop",16);
eval"&aes${p} ($inout0,$rndkey1)"; eval"&aes${p} ($inout0,$rndkey1)";
eval"&aes${p} ($inout1,$rndkey1)"; eval"&aes${p} ($inout1,$rndkey1)";
&dec ($rounds);
eval"&aes${p} ($inout2,$rndkey1)"; eval"&aes${p} ($inout2,$rndkey1)";
eval"&aes${p} ($inout3,$rndkey1)"; eval"&aes${p} ($inout3,$rndkey1)";
eval"&aes${p} ($inout4,$rndkey1)"; eval"&aes${p} ($inout4,$rndkey1)";
eval"&aes${p} ($inout5,$rndkey1)"; eval"&aes${p} ($inout5,$rndkey1)";
&set_label("_aesni_${p}rypt6_enter",16); &set_label("_aesni_${p}rypt6_enter");
&$movekey ($rndkey1,&QWP(16,$key)); &$movekey ($rndkey1,&QWP(0,$key,$rounds));
&add ($rounds,32);
eval"&aes${p} ($inout0,$rndkey0)"; eval"&aes${p} ($inout0,$rndkey0)";
eval"&aes${p} ($inout1,$rndkey0)"; eval"&aes${p} ($inout1,$rndkey0)";
&lea ($key,&DWP(32,$key));
eval"&aes${p} ($inout2,$rndkey0)"; eval"&aes${p} ($inout2,$rndkey0)";
eval"&aes${p} ($inout3,$rndkey0)"; eval"&aes${p} ($inout3,$rndkey0)";
eval"&aes${p} ($inout4,$rndkey0)"; eval"&aes${p} ($inout4,$rndkey0)";
eval"&aes${p} ($inout5,$rndkey0)"; eval"&aes${p} ($inout5,$rndkey0)";
&$movekey ($rndkey0,&QWP(0,$key)); &$movekey ($rndkey0,&QWP(-16,$key,$rounds));
&jnz (&label("${p}6_loop")); &jnz (&label("${p}6_loop"));
eval"&aes${p} ($inout0,$rndkey1)"; eval"&aes${p} ($inout0,$rndkey1)";
@ -343,6 +390,8 @@ sub aesni_generate6
&ret(); &ret();
&function_end_B("_aesni_${p}rypt6"); &function_end_B("_aesni_${p}rypt6");
} }
&aesni_generate2("enc") if ($PREFIX eq "aesni");
&aesni_generate2("dec");
&aesni_generate3("enc") if ($PREFIX eq "aesni"); &aesni_generate3("enc") if ($PREFIX eq "aesni");
&aesni_generate3("dec"); &aesni_generate3("dec");
&aesni_generate4("enc") if ($PREFIX eq "aesni"); &aesni_generate4("enc") if ($PREFIX eq "aesni");
@ -446,8 +495,7 @@ if ($PREFIX eq "aesni") {
&jmp (&label("ecb_ret")); &jmp (&label("ecb_ret"));
&set_label("ecb_enc_two",16); &set_label("ecb_enc_two",16);
&xorps ($inout2,$inout2); &call ("_aesni_encrypt2");
&call ("_aesni_encrypt3");
&movups (&QWP(0,$out),$inout0); &movups (&QWP(0,$out),$inout0);
&movups (&QWP(0x10,$out),$inout1); &movups (&QWP(0x10,$out),$inout1);
&jmp (&label("ecb_ret")); &jmp (&label("ecb_ret"));
@ -547,8 +595,7 @@ if ($PREFIX eq "aesni") {
&jmp (&label("ecb_ret")); &jmp (&label("ecb_ret"));
&set_label("ecb_dec_two",16); &set_label("ecb_dec_two",16);
&xorps ($inout2,$inout2); &call ("_aesni_decrypt2");
&call ("_aesni_decrypt3");
&movups (&QWP(0,$out),$inout0); &movups (&QWP(0,$out),$inout0);
&movups (&QWP(0x10,$out),$inout1); &movups (&QWP(0x10,$out),$inout1);
&jmp (&label("ecb_ret")); &jmp (&label("ecb_ret"));
@ -610,11 +657,13 @@ if ($PREFIX eq "aesni") {
&mov (&DWP(24,"esp"),$key_); &mov (&DWP(24,"esp"),$key_);
&mov (&DWP(28,"esp"),$key_); &mov (&DWP(28,"esp"),$key_);
&shr ($rounds,1); &shl ($rounds,4);
&mov ($rounds_,16);
&lea ($key_,&DWP(0,$key)); &lea ($key_,&DWP(0,$key));
&movdqa ($inout3,&QWP(0,"esp")); &movdqa ($inout3,&QWP(0,"esp"));
&movdqa ($inout0,$ivec); &movdqa ($inout0,$ivec);
&mov ($rounds_,$rounds); &lea ($key,&DWP(32,$key,$rounds));
&sub ($rounds_,$rounds);
&pshufb ($ivec,$inout3); &pshufb ($ivec,$inout3);
&set_label("ccm64_enc_outer"); &set_label("ccm64_enc_outer");
@ -625,33 +674,31 @@ if ($PREFIX eq "aesni") {
&xorps ($inout0,$rndkey0); &xorps ($inout0,$rndkey0);
&$movekey ($rndkey1,&QWP(16,$key_)); &$movekey ($rndkey1,&QWP(16,$key_));
&xorps ($rndkey0,$in0); &xorps ($rndkey0,$in0);
&lea ($key,&DWP(32,$key_));
&xorps ($cmac,$rndkey0); # cmac^=inp &xorps ($cmac,$rndkey0); # cmac^=inp
&$movekey ($rndkey0,&QWP(0,$key)); &$movekey ($rndkey0,&QWP(32,$key_));
&set_label("ccm64_enc2_loop"); &set_label("ccm64_enc2_loop");
&aesenc ($inout0,$rndkey1); &aesenc ($inout0,$rndkey1);
&dec ($rounds);
&aesenc ($cmac,$rndkey1); &aesenc ($cmac,$rndkey1);
&$movekey ($rndkey1,&QWP(16,$key)); &$movekey ($rndkey1,&QWP(0,$key,$rounds));
&add ($rounds,32);
&aesenc ($inout0,$rndkey0); &aesenc ($inout0,$rndkey0);
&lea ($key,&DWP(32,$key));
&aesenc ($cmac,$rndkey0); &aesenc ($cmac,$rndkey0);
&$movekey ($rndkey0,&QWP(0,$key)); &$movekey ($rndkey0,&QWP(-16,$key,$rounds));
&jnz (&label("ccm64_enc2_loop")); &jnz (&label("ccm64_enc2_loop"));
&aesenc ($inout0,$rndkey1); &aesenc ($inout0,$rndkey1);
&aesenc ($cmac,$rndkey1); &aesenc ($cmac,$rndkey1);
&paddq ($ivec,&QWP(16,"esp")); &paddq ($ivec,&QWP(16,"esp"));
&dec ($len);
&aesenclast ($inout0,$rndkey0); &aesenclast ($inout0,$rndkey0);
&aesenclast ($cmac,$rndkey0); &aesenclast ($cmac,$rndkey0);
&dec ($len);
&lea ($inp,&DWP(16,$inp)); &lea ($inp,&DWP(16,$inp));
&xorps ($in0,$inout0); # inp^=E(ivec) &xorps ($in0,$inout0); # inp^=E(ivec)
&movdqa ($inout0,$ivec); &movdqa ($inout0,$ivec);
&movups (&QWP(0,$out),$in0); # save output &movups (&QWP(0,$out),$in0); # save output
&lea ($out,&DWP(16,$out));
&pshufb ($inout0,$inout3); &pshufb ($inout0,$inout3);
&lea ($out,&DWP(16,$out));
&jnz (&label("ccm64_enc_outer")); &jnz (&label("ccm64_enc_outer"));
&mov ("esp",&DWP(48,"esp")); &mov ("esp",&DWP(48,"esp"));
@ -700,15 +747,19 @@ if ($PREFIX eq "aesni") {
{ &aesni_inline_generate1("enc"); } { &aesni_inline_generate1("enc"); }
else else
{ &call ("_aesni_encrypt1"); } { &call ("_aesni_encrypt1"); }
&shl ($rounds_,4);
&mov ($rounds,16);
&movups ($in0,&QWP(0,$inp)); # load inp &movups ($in0,&QWP(0,$inp)); # load inp
&paddq ($ivec,&QWP(16,"esp")); &paddq ($ivec,&QWP(16,"esp"));
&lea ($inp,&QWP(16,$inp)); &lea ($inp,&QWP(16,$inp));
&sub ($rounds,$rounds_);
&lea ($key,&DWP(32,$key_,$rounds_));
&mov ($rounds_,$rounds);
&jmp (&label("ccm64_dec_outer")); &jmp (&label("ccm64_dec_outer"));
&set_label("ccm64_dec_outer",16); &set_label("ccm64_dec_outer",16);
&xorps ($in0,$inout0); # inp ^= E(ivec) &xorps ($in0,$inout0); # inp ^= E(ivec)
&movdqa ($inout0,$ivec); &movdqa ($inout0,$ivec);
&mov ($rounds,$rounds_);
&movups (&QWP(0,$out),$in0); # save output &movups (&QWP(0,$out),$in0); # save output
&lea ($out,&DWP(16,$out)); &lea ($out,&DWP(16,$out));
&pshufb ($inout0,$inout3); &pshufb ($inout0,$inout3);
@ -717,34 +768,33 @@ if ($PREFIX eq "aesni") {
&jz (&label("ccm64_dec_break")); &jz (&label("ccm64_dec_break"));
&$movekey ($rndkey0,&QWP(0,$key_)); &$movekey ($rndkey0,&QWP(0,$key_));
&shr ($rounds,1); &mov ($rounds,$rounds_);
&$movekey ($rndkey1,&QWP(16,$key_)); &$movekey ($rndkey1,&QWP(16,$key_));
&xorps ($in0,$rndkey0); &xorps ($in0,$rndkey0);
&lea ($key,&DWP(32,$key_));
&xorps ($inout0,$rndkey0); &xorps ($inout0,$rndkey0);
&xorps ($cmac,$in0); # cmac^=out &xorps ($cmac,$in0); # cmac^=out
&$movekey ($rndkey0,&QWP(0,$key)); &$movekey ($rndkey0,&QWP(32,$key_));
&set_label("ccm64_dec2_loop"); &set_label("ccm64_dec2_loop");
&aesenc ($inout0,$rndkey1); &aesenc ($inout0,$rndkey1);
&dec ($rounds);
&aesenc ($cmac,$rndkey1); &aesenc ($cmac,$rndkey1);
&$movekey ($rndkey1,&QWP(16,$key)); &$movekey ($rndkey1,&QWP(0,$key,$rounds));
&add ($rounds,32);
&aesenc ($inout0,$rndkey0); &aesenc ($inout0,$rndkey0);
&lea ($key,&DWP(32,$key));
&aesenc ($cmac,$rndkey0); &aesenc ($cmac,$rndkey0);
&$movekey ($rndkey0,&QWP(0,$key)); &$movekey ($rndkey0,&QWP(-16,$key,$rounds));
&jnz (&label("ccm64_dec2_loop")); &jnz (&label("ccm64_dec2_loop"));
&movups ($in0,&QWP(0,$inp)); # load inp &movups ($in0,&QWP(0,$inp)); # load inp
&paddq ($ivec,&QWP(16,"esp")); &paddq ($ivec,&QWP(16,"esp"));
&aesenc ($inout0,$rndkey1); &aesenc ($inout0,$rndkey1);
&aesenc ($cmac,$rndkey1); &aesenc ($cmac,$rndkey1);
&lea ($inp,&QWP(16,$inp));
&aesenclast ($inout0,$rndkey0); &aesenclast ($inout0,$rndkey0);
&aesenclast ($cmac,$rndkey0); &aesenclast ($cmac,$rndkey0);
&lea ($inp,&QWP(16,$inp));
&jmp (&label("ccm64_dec_outer")); &jmp (&label("ccm64_dec_outer"));
&set_label("ccm64_dec_break",16); &set_label("ccm64_dec_break",16);
&mov ($rounds,&DWP(240,$key_));
&mov ($key,$key_); &mov ($key,$key_);
if ($inline) if ($inline)
{ &aesni_inline_generate1("enc",$cmac,$in0); } { &aesni_inline_generate1("enc",$cmac,$in0); }
@ -763,7 +813,7 @@ if ($PREFIX eq "aesni") {
# const char *ivec); # const char *ivec);
# #
# Handles only complete blocks, operates on 32-bit counter and # Handles only complete blocks, operates on 32-bit counter and
# does not update *ivec! (see engine/eng_aesni.c for details) # does not update *ivec! (see crypto/modes/ctr128.c for details)
# #
# stack layout: # stack layout:
# 0 pshufb mask # 0 pshufb mask
@ -810,66 +860,61 @@ if ($PREFIX eq "aesni") {
# compose 2 vectors of 3x32-bit counters # compose 2 vectors of 3x32-bit counters
&bswap ($rounds_); &bswap ($rounds_);
&pxor ($rndkey1,$rndkey1);
&pxor ($rndkey0,$rndkey0); &pxor ($rndkey0,$rndkey0);
&pxor ($rndkey1,$rndkey1);
&movdqa ($inout0,&QWP(0,"esp")); # load byte-swap mask &movdqa ($inout0,&QWP(0,"esp")); # load byte-swap mask
&pinsrd ($rndkey1,$rounds_,0); &pinsrd ($rndkey0,$rounds_,0);
&lea ($key_,&DWP(3,$rounds_)); &lea ($key_,&DWP(3,$rounds_));
&pinsrd ($rndkey0,$key_,0); &pinsrd ($rndkey1,$key_,0);
&inc ($rounds_); &inc ($rounds_);
&pinsrd ($rndkey1,$rounds_,1); &pinsrd ($rndkey0,$rounds_,1);
&inc ($key_); &inc ($key_);
&pinsrd ($rndkey0,$key_,1); &pinsrd ($rndkey1,$key_,1);
&inc ($rounds_); &inc ($rounds_);
&pinsrd ($rndkey1,$rounds_,2); &pinsrd ($rndkey0,$rounds_,2);
&inc ($key_); &inc ($key_);
&pinsrd ($rndkey0,$key_,2); &pinsrd ($rndkey1,$key_,2);
&movdqa (&QWP(48,"esp"),$rndkey1); # save 1st triplet &movdqa (&QWP(48,"esp"),$rndkey0); # save 1st triplet
&pshufb ($rndkey1,$inout0); # byte swap
&movdqa (&QWP(64,"esp"),$rndkey0); # save 2nd triplet
&pshufb ($rndkey0,$inout0); # byte swap &pshufb ($rndkey0,$inout0); # byte swap
&movdqu ($inout4,&QWP(0,$key)); # key[0]
&movdqa (&QWP(64,"esp"),$rndkey1); # save 2nd triplet
&pshufb ($rndkey1,$inout0); # byte swap
&pshufd ($inout0,$rndkey1,3<<6); # place counter to upper dword &pshufd ($inout0,$rndkey0,3<<6); # place counter to upper dword
&pshufd ($inout1,$rndkey1,2<<6); &pshufd ($inout1,$rndkey0,2<<6);
&cmp ($len,6); &cmp ($len,6);
&jb (&label("ctr32_tail")); &jb (&label("ctr32_tail"));
&movdqa (&QWP(32,"esp"),$inout5); # save counter-less ivec &pxor ($inout5,$inout4); # counter-less ivec^key[0]
&shr ($rounds,1); &shl ($rounds,4);
&mov ($rounds_,16);
&movdqa (&QWP(32,"esp"),$inout5); # save counter-less ivec^key[0]
&mov ($key_,$key); # backup $key &mov ($key_,$key); # backup $key
&mov ($rounds_,$rounds); # backup $rounds &sub ($rounds_,$rounds); # backup twisted $rounds
&lea ($key,&DWP(32,$key,$rounds));
&sub ($len,6); &sub ($len,6);
&jmp (&label("ctr32_loop6")); &jmp (&label("ctr32_loop6"));
&set_label("ctr32_loop6",16); &set_label("ctr32_loop6",16);
&pshufd ($inout2,$rndkey1,1<<6); # inlining _aesni_encrypt6's prologue gives ~6% improvement...
&movdqa ($rndkey1,&QWP(32,"esp")); # pull counter-less ivec &pshufd ($inout2,$rndkey0,1<<6);
&pshufd ($inout3,$rndkey0,3<<6); &movdqa ($rndkey0,&QWP(32,"esp")); # pull counter-less ivec
&por ($inout0,$rndkey1); # merge counter-less ivec &pshufd ($inout3,$rndkey1,3<<6);
&pshufd ($inout4,$rndkey0,2<<6); &pxor ($inout0,$rndkey0); # merge counter-less ivec
&por ($inout1,$rndkey1); &pshufd ($inout4,$rndkey1,2<<6);
&pshufd ($inout5,$rndkey0,1<<6);
&por ($inout2,$rndkey1);
&por ($inout3,$rndkey1);
&por ($inout4,$rndkey1);
&por ($inout5,$rndkey1);
# inlining _aesni_encrypt6's prologue gives ~4% improvement...
&$movekey ($rndkey0,&QWP(0,$key_));
&$movekey ($rndkey1,&QWP(16,$key_));
&lea ($key,&DWP(32,$key_));
&dec ($rounds);
&pxor ($inout0,$rndkey0);
&pxor ($inout1,$rndkey0); &pxor ($inout1,$rndkey0);
&aesenc ($inout0,$rndkey1); &pshufd ($inout5,$rndkey1,1<<6);
&$movekey ($rndkey1,&QWP(16,$key_));
&pxor ($inout2,$rndkey0); &pxor ($inout2,$rndkey0);
&aesenc ($inout1,$rndkey1);
&pxor ($inout3,$rndkey0); &pxor ($inout3,$rndkey0);
&aesenc ($inout2,$rndkey1); &aesenc ($inout0,$rndkey1);
&pxor ($inout4,$rndkey0); &pxor ($inout4,$rndkey0);
&aesenc ($inout3,$rndkey1);
&pxor ($inout5,$rndkey0); &pxor ($inout5,$rndkey0);
&aesenc ($inout1,$rndkey1);
&$movekey ($rndkey0,&QWP(32,$key_));
&mov ($rounds,$rounds_);
&aesenc ($inout2,$rndkey1);
&aesenc ($inout3,$rndkey1);
&aesenc ($inout4,$rndkey1); &aesenc ($inout4,$rndkey1);
&$movekey ($rndkey0,&QWP(0,$key));
&aesenc ($inout5,$rndkey1); &aesenc ($inout5,$rndkey1);
&call (&label("_aesni_encrypt6_enter")); &call (&label("_aesni_encrypt6_enter"));
@ -882,12 +927,12 @@ if ($PREFIX eq "aesni") {
&movups (&QWP(0,$out),$inout0); &movups (&QWP(0,$out),$inout0);
&movdqa ($rndkey0,&QWP(16,"esp")); # load increment &movdqa ($rndkey0,&QWP(16,"esp")); # load increment
&xorps ($inout2,$rndkey1); &xorps ($inout2,$rndkey1);
&movdqa ($rndkey1,&QWP(48,"esp")); # load 1st triplet &movdqa ($rndkey1,&QWP(64,"esp")); # load 2nd triplet
&movups (&QWP(0x10,$out),$inout1); &movups (&QWP(0x10,$out),$inout1);
&movups (&QWP(0x20,$out),$inout2); &movups (&QWP(0x20,$out),$inout2);
&paddd ($rndkey1,$rndkey0); # 1st triplet increment &paddd ($rndkey1,$rndkey0); # 2nd triplet increment
&paddd ($rndkey0,&QWP(64,"esp")); # 2nd triplet increment &paddd ($rndkey0,&QWP(48,"esp")); # 1st triplet increment
&movdqa ($inout0,&QWP(0,"esp")); # load byte swap mask &movdqa ($inout0,&QWP(0,"esp")); # load byte swap mask
&movups ($inout1,&QWP(0x30,$inp)); &movups ($inout1,&QWP(0x30,$inp));
@ -895,44 +940,44 @@ if ($PREFIX eq "aesni") {
&xorps ($inout3,$inout1); &xorps ($inout3,$inout1);
&movups ($inout1,&QWP(0x50,$inp)); &movups ($inout1,&QWP(0x50,$inp));
&lea ($inp,&DWP(0x60,$inp)); &lea ($inp,&DWP(0x60,$inp));
&movdqa (&QWP(48,"esp"),$rndkey1); # save 1st triplet &movdqa (&QWP(48,"esp"),$rndkey0); # save 1st triplet
&pshufb ($rndkey1,$inout0); # byte swap &pshufb ($rndkey0,$inout0); # byte swap
&xorps ($inout4,$inout2); &xorps ($inout4,$inout2);
&movups (&QWP(0x30,$out),$inout3); &movups (&QWP(0x30,$out),$inout3);
&xorps ($inout5,$inout1); &xorps ($inout5,$inout1);
&movdqa (&QWP(64,"esp"),$rndkey0); # save 2nd triplet &movdqa (&QWP(64,"esp"),$rndkey1); # save 2nd triplet
&pshufb ($rndkey0,$inout0); # byte swap &pshufb ($rndkey1,$inout0); # byte swap
&movups (&QWP(0x40,$out),$inout4); &movups (&QWP(0x40,$out),$inout4);
&pshufd ($inout0,$rndkey1,3<<6); &pshufd ($inout0,$rndkey0,3<<6);
&movups (&QWP(0x50,$out),$inout5); &movups (&QWP(0x50,$out),$inout5);
&lea ($out,&DWP(0x60,$out)); &lea ($out,&DWP(0x60,$out));
&mov ($rounds,$rounds_); &pshufd ($inout1,$rndkey0,2<<6);
&pshufd ($inout1,$rndkey1,2<<6);
&sub ($len,6); &sub ($len,6);
&jnc (&label("ctr32_loop6")); &jnc (&label("ctr32_loop6"));
&add ($len,6); &add ($len,6);
&jz (&label("ctr32_ret")); &jz (&label("ctr32_ret"));
&movdqu ($inout5,&QWP(0,$key_));
&mov ($key,$key_); &mov ($key,$key_);
&lea ($rounds,&DWP(1,"",$rounds,2)); # restore $rounds &pxor ($inout5,&QWP(32,"esp")); # restore count-less ivec
&movdqa ($inout5,&QWP(32,"esp")); # pull count-less ivec &mov ($rounds,&DWP(240,$key_)); # restore $rounds
&set_label("ctr32_tail"); &set_label("ctr32_tail");
&por ($inout0,$inout5); &por ($inout0,$inout5);
&cmp ($len,2); &cmp ($len,2);
&jb (&label("ctr32_one")); &jb (&label("ctr32_one"));
&pshufd ($inout2,$rndkey1,1<<6); &pshufd ($inout2,$rndkey0,1<<6);
&por ($inout1,$inout5); &por ($inout1,$inout5);
&je (&label("ctr32_two")); &je (&label("ctr32_two"));
&pshufd ($inout3,$rndkey0,3<<6); &pshufd ($inout3,$rndkey1,3<<6);
&por ($inout2,$inout5); &por ($inout2,$inout5);
&cmp ($len,4); &cmp ($len,4);
&jb (&label("ctr32_three")); &jb (&label("ctr32_three"));
&pshufd ($inout4,$rndkey0,2<<6); &pshufd ($inout4,$rndkey1,2<<6);
&por ($inout3,$inout5); &por ($inout3,$inout5);
&je (&label("ctr32_four")); &je (&label("ctr32_four"));
@ -970,7 +1015,7 @@ if ($PREFIX eq "aesni") {
&jmp (&label("ctr32_ret")); &jmp (&label("ctr32_ret"));
&set_label("ctr32_two",16); &set_label("ctr32_two",16);
&call ("_aesni_encrypt3"); &call ("_aesni_encrypt2");
&movups ($inout3,&QWP(0,$inp)); &movups ($inout3,&QWP(0,$inp));
&movups ($inout4,&QWP(0x10,$inp)); &movups ($inout4,&QWP(0x10,$inp));
&xorps ($inout0,$inout3); &xorps ($inout0,$inout3);
@ -1057,8 +1102,10 @@ if ($PREFIX eq "aesni") {
&sub ($len,16*6); &sub ($len,16*6);
&jc (&label("xts_enc_short")); &jc (&label("xts_enc_short"));
&shr ($rounds,1); &shl ($rounds,4);
&mov ($rounds_,$rounds); &mov ($rounds_,16);
&sub ($rounds_,$rounds);
&lea ($key,&DWP(32,$key,$rounds));
&jmp (&label("xts_enc_loop6")); &jmp (&label("xts_enc_loop6"));
&set_label("xts_enc_loop6",16); &set_label("xts_enc_loop6",16);
@ -1080,6 +1127,7 @@ if ($PREFIX eq "aesni") {
&pxor ($inout5,$tweak); &pxor ($inout5,$tweak);
# inline _aesni_encrypt6 prologue and flip xor with tweak and key[0] # inline _aesni_encrypt6 prologue and flip xor with tweak and key[0]
&mov ($rounds,$rounds_); # restore $rounds
&movdqu ($inout1,&QWP(16*1,$inp)); &movdqu ($inout1,&QWP(16*1,$inp));
&xorps ($inout0,$rndkey0); # input^=rndkey[0] &xorps ($inout0,$rndkey0); # input^=rndkey[0]
&movdqu ($inout2,&QWP(16*2,$inp)); &movdqu ($inout2,&QWP(16*2,$inp));
@ -1096,19 +1144,17 @@ if ($PREFIX eq "aesni") {
&pxor ($inout5,$rndkey1); &pxor ($inout5,$rndkey1);
&$movekey ($rndkey1,&QWP(16,$key_)); &$movekey ($rndkey1,&QWP(16,$key_));
&lea ($key,&DWP(32,$key_));
&pxor ($inout1,&QWP(16*1,"esp")); &pxor ($inout1,&QWP(16*1,"esp"));
&aesenc ($inout0,$rndkey1);
&pxor ($inout2,&QWP(16*2,"esp")); &pxor ($inout2,&QWP(16*2,"esp"));
&aesenc ($inout1,$rndkey1); &aesenc ($inout0,$rndkey1);
&pxor ($inout3,&QWP(16*3,"esp")); &pxor ($inout3,&QWP(16*3,"esp"));
&dec ($rounds);
&aesenc ($inout2,$rndkey1);
&pxor ($inout4,&QWP(16*4,"esp")); &pxor ($inout4,&QWP(16*4,"esp"));
&aesenc ($inout3,$rndkey1); &aesenc ($inout1,$rndkey1);
&pxor ($inout5,$rndkey0); &pxor ($inout5,$rndkey0);
&$movekey ($rndkey0,&QWP(32,$key_));
&aesenc ($inout2,$rndkey1);
&aesenc ($inout3,$rndkey1);
&aesenc ($inout4,$rndkey1); &aesenc ($inout4,$rndkey1);
&$movekey ($rndkey0,&QWP(0,$key));
&aesenc ($inout5,$rndkey1); &aesenc ($inout5,$rndkey1);
&call (&label("_aesni_encrypt6_enter")); &call (&label("_aesni_encrypt6_enter"));
@ -1135,13 +1181,12 @@ if ($PREFIX eq "aesni") {
&paddq ($tweak,$tweak); # &psllq($tweak,1); &paddq ($tweak,$tweak); # &psllq($tweak,1);
&pand ($twres,$twmask); # isolate carry and residue &pand ($twres,$twmask); # isolate carry and residue
&pcmpgtd($twtmp,$tweak); # broadcast upper bits &pcmpgtd($twtmp,$tweak); # broadcast upper bits
&mov ($rounds,$rounds_); # restore $rounds
&pxor ($tweak,$twres); &pxor ($tweak,$twres);
&sub ($len,16*6); &sub ($len,16*6);
&jnc (&label("xts_enc_loop6")); &jnc (&label("xts_enc_loop6"));
&lea ($rounds,&DWP(1,"",$rounds,2)); # restore $rounds &mov ($rounds,&DWP(240,$key_)); # restore $rounds
&mov ($key,$key_); # restore $key &mov ($key,$key_); # restore $key
&mov ($rounds_,$rounds); &mov ($rounds_,$rounds);
@ -1241,9 +1286,8 @@ if ($PREFIX eq "aesni") {
&lea ($inp,&DWP(16*2,$inp)); &lea ($inp,&DWP(16*2,$inp));
&xorps ($inout0,$inout3); # input^=tweak &xorps ($inout0,$inout3); # input^=tweak
&xorps ($inout1,$inout4); &xorps ($inout1,$inout4);
&xorps ($inout2,$inout2);
&call ("_aesni_encrypt3"); &call ("_aesni_encrypt2");
&xorps ($inout0,$inout3); # output^=tweak &xorps ($inout0,$inout3); # output^=tweak
&xorps ($inout1,$inout4); &xorps ($inout1,$inout4);
@ -1399,8 +1443,10 @@ if ($PREFIX eq "aesni") {
&sub ($len,16*6); &sub ($len,16*6);
&jc (&label("xts_dec_short")); &jc (&label("xts_dec_short"));
&shr ($rounds,1); &shl ($rounds,4);
&mov ($rounds_,$rounds); &mov ($rounds_,16);
&sub ($rounds_,$rounds);
&lea ($key,&DWP(32,$key,$rounds));
&jmp (&label("xts_dec_loop6")); &jmp (&label("xts_dec_loop6"));
&set_label("xts_dec_loop6",16); &set_label("xts_dec_loop6",16);
@ -1422,6 +1468,7 @@ if ($PREFIX eq "aesni") {
&pxor ($inout5,$tweak); &pxor ($inout5,$tweak);
# inline _aesni_encrypt6 prologue and flip xor with tweak and key[0] # inline _aesni_encrypt6 prologue and flip xor with tweak and key[0]
&mov ($rounds,$rounds_);
&movdqu ($inout1,&QWP(16*1,$inp)); &movdqu ($inout1,&QWP(16*1,$inp));
&xorps ($inout0,$rndkey0); # input^=rndkey[0] &xorps ($inout0,$rndkey0); # input^=rndkey[0]
&movdqu ($inout2,&QWP(16*2,$inp)); &movdqu ($inout2,&QWP(16*2,$inp));
@ -1438,19 +1485,17 @@ if ($PREFIX eq "aesni") {
&pxor ($inout5,$rndkey1); &pxor ($inout5,$rndkey1);
&$movekey ($rndkey1,&QWP(16,$key_)); &$movekey ($rndkey1,&QWP(16,$key_));
&lea ($key,&DWP(32,$key_));
&pxor ($inout1,&QWP(16*1,"esp")); &pxor ($inout1,&QWP(16*1,"esp"));
&aesdec ($inout0,$rndkey1);
&pxor ($inout2,&QWP(16*2,"esp")); &pxor ($inout2,&QWP(16*2,"esp"));
&aesdec ($inout1,$rndkey1); &aesdec ($inout0,$rndkey1);
&pxor ($inout3,&QWP(16*3,"esp")); &pxor ($inout3,&QWP(16*3,"esp"));
&dec ($rounds);
&aesdec ($inout2,$rndkey1);
&pxor ($inout4,&QWP(16*4,"esp")); &pxor ($inout4,&QWP(16*4,"esp"));
&aesdec ($inout3,$rndkey1); &aesdec ($inout1,$rndkey1);
&pxor ($inout5,$rndkey0); &pxor ($inout5,$rndkey0);
&$movekey ($rndkey0,&QWP(32,$key_));
&aesdec ($inout2,$rndkey1);
&aesdec ($inout3,$rndkey1);
&aesdec ($inout4,$rndkey1); &aesdec ($inout4,$rndkey1);
&$movekey ($rndkey0,&QWP(0,$key));
&aesdec ($inout5,$rndkey1); &aesdec ($inout5,$rndkey1);
&call (&label("_aesni_decrypt6_enter")); &call (&label("_aesni_decrypt6_enter"));
@ -1477,13 +1522,12 @@ if ($PREFIX eq "aesni") {
&paddq ($tweak,$tweak); # &psllq($tweak,1); &paddq ($tweak,$tweak); # &psllq($tweak,1);
&pand ($twres,$twmask); # isolate carry and residue &pand ($twres,$twmask); # isolate carry and residue
&pcmpgtd($twtmp,$tweak); # broadcast upper bits &pcmpgtd($twtmp,$tweak); # broadcast upper bits
&mov ($rounds,$rounds_); # restore $rounds
&pxor ($tweak,$twres); &pxor ($tweak,$twres);
&sub ($len,16*6); &sub ($len,16*6);
&jnc (&label("xts_dec_loop6")); &jnc (&label("xts_dec_loop6"));
&lea ($rounds,&DWP(1,"",$rounds,2)); # restore $rounds &mov ($rounds,&DWP(240,$key_)); # restore $rounds
&mov ($key,$key_); # restore $key &mov ($key,$key_); # restore $key
&mov ($rounds_,$rounds); &mov ($rounds_,$rounds);
@ -1584,7 +1628,7 @@ if ($PREFIX eq "aesni") {
&xorps ($inout0,$inout3); # input^=tweak &xorps ($inout0,$inout3); # input^=tweak
&xorps ($inout1,$inout4); &xorps ($inout1,$inout4);
&call ("_aesni_decrypt3"); &call ("_aesni_decrypt2");
&xorps ($inout0,$inout3); # output^=tweak &xorps ($inout0,$inout3); # output^=tweak
&xorps ($inout1,$inout4); &xorps ($inout1,$inout4);
@ -1816,7 +1860,7 @@ if ($PREFIX eq "aesni") {
&movups (&QWP(0x10,$out),$inout1); &movups (&QWP(0x10,$out),$inout1);
&lea ($inp,&DWP(0x60,$inp)); &lea ($inp,&DWP(0x60,$inp));
&movups (&QWP(0x20,$out),$inout2); &movups (&QWP(0x20,$out),$inout2);
&mov ($rounds,$rounds_) # restore $rounds &mov ($rounds,$rounds_); # restore $rounds
&movups (&QWP(0x30,$out),$inout3); &movups (&QWP(0x30,$out),$inout3);
&mov ($key,$key_); # restore $key &mov ($key,$key_); # restore $key
&movups (&QWP(0x40,$out),$inout4); &movups (&QWP(0x40,$out),$inout4);
@ -1884,8 +1928,7 @@ if ($PREFIX eq "aesni") {
&jmp (&label("cbc_dec_tail_collected")); &jmp (&label("cbc_dec_tail_collected"));
&set_label("cbc_dec_two",16); &set_label("cbc_dec_two",16);
&xorps ($inout2,$inout2); &call ("_aesni_decrypt2");
&call ("_aesni_decrypt3");
&xorps ($inout0,$ivec); &xorps ($inout0,$ivec);
&xorps ($inout1,$in0); &xorps ($inout1,$in0);
&movups (&QWP(0,$out),$inout0); &movups (&QWP(0,$out),$inout0);
@ -2015,7 +2058,7 @@ if ($PREFIX eq "aesni") {
&set_label("12rounds",16); &set_label("12rounds",16);
&movq ("xmm2",&QWP(16,"eax")); # remaining 1/3 of *userKey &movq ("xmm2",&QWP(16,"eax")); # remaining 1/3 of *userKey
&mov ($rounds,11); &mov ($rounds,11);
&$movekey (&QWP(-16,$key),"xmm0") # round 0 &$movekey (&QWP(-16,$key),"xmm0"); # round 0
&aeskeygenassist("xmm1","xmm2",0x01); # round 1,2 &aeskeygenassist("xmm1","xmm2",0x01); # round 1,2
&call (&label("key_192a_cold")); &call (&label("key_192a_cold"));
&aeskeygenassist("xmm1","xmm2",0x02); # round 2,3 &aeskeygenassist("xmm1","xmm2",0x02); # round 2,3
@ -2152,7 +2195,7 @@ if ($PREFIX eq "aesni") {
&mov ($key,&wparam(2)); &mov ($key,&wparam(2));
&call ("_aesni_set_encrypt_key"); &call ("_aesni_set_encrypt_key");
&mov ($key,&wparam(2)); &mov ($key,&wparam(2));
&shl ($rounds,4) # rounds-1 after _aesni_set_encrypt_key &shl ($rounds,4); # rounds-1 after _aesni_set_encrypt_key
&test ("eax","eax"); &test ("eax","eax");
&jnz (&label("dec_key_ret")); &jnz (&label("dec_key_ret"));
&lea ("eax",&DWP(16,$key,$rounds)); # end of key schedule &lea ("eax",&DWP(16,$key,$rounds)); # end of key schedule

File diff suppressed because it is too large Load Diff

1940
crypto/aes/asm/aesp8-ppc.pl Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,919 @@
#!/usr/bin/env perl
# ====================================================================
# Written by David S. Miller <davem@devemloft.net> and Andy Polyakov
# <appro@openssl.org>. The module is licensed under 2-clause BSD
# license. October 2012. All rights reserved.
# ====================================================================
######################################################################
# AES for SPARC T4.
#
# AES round instructions complete in 3 cycles and can be issued every
# cycle. It means that round calculations should take 4*rounds cycles,
# because any given round instruction depends on result of *both*
# previous instructions:
#
# |0 |1 |2 |3 |4
# |01|01|01|
# |23|23|23|
# |01|01|...
# |23|...
#
# Provided that fxor [with IV] takes 3 cycles to complete, critical
# path length for CBC encrypt would be 3+4*rounds, or in other words
# it should process one byte in at least (3+4*rounds)/16 cycles. This
# estimate doesn't account for "collateral" instructions, such as
# fetching input from memory, xor-ing it with zero-round key and
# storing the result. Yet, *measured* performance [for data aligned
# at 64-bit boundary!] deviates from this equation by less than 0.5%:
#
# 128-bit key 192- 256-
# CBC encrypt 2.70/2.90(*) 3.20/3.40 3.70/3.90
# (*) numbers after slash are for
# misaligned data.
#
# Out-of-order execution logic managed to fully overlap "collateral"
# instructions with those on critical path. Amazing!
#
# As with Intel AES-NI, question is if it's possible to improve
# performance of parallelizeable modes by interleaving round
# instructions. Provided round instruction latency and throughput
# optimal interleave factor is 2. But can we expect 2x performance
# improvement? Well, as round instructions can be issued one per
# cycle, they don't saturate the 2-way issue pipeline and therefore
# there is room for "collateral" calculations... Yet, 2x speed-up
# over CBC encrypt remains unattaintable:
#
# 128-bit key 192- 256-
# CBC decrypt 1.64/2.11 1.89/2.37 2.23/2.61
# CTR 1.64/2.08(*) 1.89/2.33 2.23/2.61
# (*) numbers after slash are for
# misaligned data.
#
# Estimates based on amount of instructions under assumption that
# round instructions are not pairable with any other instruction
# suggest that latter is the actual case and pipeline runs
# underutilized. It should be noted that T4 out-of-order execution
# logic is so capable that performance gain from 2x interleave is
# not even impressive, ~7-13% over non-interleaved code, largest
# for 256-bit keys.
# To anchor to something else, software implementation processes
# one byte in 29 cycles with 128-bit key on same processor. Intel
# Sandy Bridge encrypts byte in 5.07 cycles in CBC mode and decrypts
# in 0.93, naturally with AES-NI.
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
push(@INC,"${dir}","${dir}../../perlasm");
require "sparcv9_modes.pl";
&asm_init(@ARGV);
$::evp=1; # if $evp is set to 0, script generates module with
# AES_[en|de]crypt, AES_set_[en|de]crypt_key and AES_cbc_encrypt entry
# points. These however are not fully compatible with openssl/aes.h,
# because they expect AES_KEY to be aligned at 64-bit boundary. When
# used through EVP, alignment is arranged at EVP layer. Second thing
# that is arranged by EVP is at least 32-bit alignment of IV.
######################################################################
# single-round subroutines
#
{
my ($inp,$out,$key,$rounds,$tmp,$mask)=map("%o$_",(0..5));
$code.=<<___ if ($::abibits==64);
.register %g2,#scratch
.register %g3,#scratch
___
$code.=<<___;
.text
.globl aes_t4_encrypt
.align 32
aes_t4_encrypt:
andcc $inp, 7, %g1 ! is input aligned?
andn $inp, 7, $inp
ldx [$key + 0], %g4
ldx [$key + 8], %g5
ldx [$inp + 0], %o4
bz,pt %icc, 1f
ldx [$inp + 8], %o5
ldx [$inp + 16], $inp
sll %g1, 3, %g1
sub %g0, %g1, %o3
sllx %o4, %g1, %o4
sllx %o5, %g1, %g1
srlx %o5, %o3, %o5
srlx $inp, %o3, %o3
or %o5, %o4, %o4
or %o3, %g1, %o5
1:
ld [$key + 240], $rounds
ldd [$key + 16], %f12
ldd [$key + 24], %f14
xor %g4, %o4, %o4
xor %g5, %o5, %o5
movxtod %o4, %f0
movxtod %o5, %f2
srl $rounds, 1, $rounds
ldd [$key + 32], %f16
sub $rounds, 1, $rounds
ldd [$key + 40], %f18
add $key, 48, $key
.Lenc:
aes_eround01 %f12, %f0, %f2, %f4
aes_eround23 %f14, %f0, %f2, %f2
ldd [$key + 0], %f12
ldd [$key + 8], %f14
sub $rounds,1,$rounds
aes_eround01 %f16, %f4, %f2, %f0
aes_eround23 %f18, %f4, %f2, %f2
ldd [$key + 16], %f16
ldd [$key + 24], %f18
brnz,pt $rounds, .Lenc
add $key, 32, $key
andcc $out, 7, $tmp ! is output aligned?
aes_eround01 %f12, %f0, %f2, %f4
aes_eround23 %f14, %f0, %f2, %f2
aes_eround01_l %f16, %f4, %f2, %f0
aes_eround23_l %f18, %f4, %f2, %f2
bnz,pn %icc, 2f
nop
std %f0, [$out + 0]
retl
std %f2, [$out + 8]
2: alignaddrl $out, %g0, $out
mov 0xff, $mask
srl $mask, $tmp, $mask
faligndata %f0, %f0, %f4
faligndata %f0, %f2, %f6
faligndata %f2, %f2, %f8
stda %f4, [$out + $mask]0xc0 ! partial store
std %f6, [$out + 8]
add $out, 16, $out
orn %g0, $mask, $mask
retl
stda %f8, [$out + $mask]0xc0 ! partial store
.type aes_t4_encrypt,#function
.size aes_t4_encrypt,.-aes_t4_encrypt
.globl aes_t4_decrypt
.align 32
aes_t4_decrypt:
andcc $inp, 7, %g1 ! is input aligned?
andn $inp, 7, $inp
ldx [$key + 0], %g4
ldx [$key + 8], %g5
ldx [$inp + 0], %o4
bz,pt %icc, 1f
ldx [$inp + 8], %o5
ldx [$inp + 16], $inp
sll %g1, 3, %g1
sub %g0, %g1, %o3
sllx %o4, %g1, %o4
sllx %o5, %g1, %g1
srlx %o5, %o3, %o5
srlx $inp, %o3, %o3
or %o5, %o4, %o4
or %o3, %g1, %o5
1:
ld [$key + 240], $rounds
ldd [$key + 16], %f12
ldd [$key + 24], %f14
xor %g4, %o4, %o4
xor %g5, %o5, %o5
movxtod %o4, %f0
movxtod %o5, %f2
srl $rounds, 1, $rounds
ldd [$key + 32], %f16
sub $rounds, 1, $rounds
ldd [$key + 40], %f18
add $key, 48, $key
.Ldec:
aes_dround01 %f12, %f0, %f2, %f4
aes_dround23 %f14, %f0, %f2, %f2
ldd [$key + 0], %f12
ldd [$key + 8], %f14
sub $rounds,1,$rounds
aes_dround01 %f16, %f4, %f2, %f0
aes_dround23 %f18, %f4, %f2, %f2
ldd [$key + 16], %f16
ldd [$key + 24], %f18
brnz,pt $rounds, .Ldec
add $key, 32, $key
andcc $out, 7, $tmp ! is output aligned?
aes_dround01 %f12, %f0, %f2, %f4
aes_dround23 %f14, %f0, %f2, %f2
aes_dround01_l %f16, %f4, %f2, %f0
aes_dround23_l %f18, %f4, %f2, %f2
bnz,pn %icc, 2f
nop
std %f0, [$out + 0]
retl
std %f2, [$out + 8]
2: alignaddrl $out, %g0, $out
mov 0xff, $mask
srl $mask, $tmp, $mask
faligndata %f0, %f0, %f4
faligndata %f0, %f2, %f6
faligndata %f2, %f2, %f8
stda %f4, [$out + $mask]0xc0 ! partial store
std %f6, [$out + 8]
add $out, 16, $out
orn %g0, $mask, $mask
retl
stda %f8, [$out + $mask]0xc0 ! partial store
.type aes_t4_decrypt,#function
.size aes_t4_decrypt,.-aes_t4_decrypt
___
}
######################################################################
# key setup subroutines
#
{
my ($inp,$bits,$out,$tmp)=map("%o$_",(0..5));
$code.=<<___;
.globl aes_t4_set_encrypt_key
.align 32
aes_t4_set_encrypt_key:
.Lset_encrypt_key:
and $inp, 7, $tmp
alignaddr $inp, %g0, $inp
cmp $bits, 192
ldd [$inp + 0], %f0
bl,pt %icc,.L128
ldd [$inp + 8], %f2
be,pt %icc,.L192
ldd [$inp + 16], %f4
brz,pt $tmp, .L256aligned
ldd [$inp + 24], %f6
ldd [$inp + 32], %f8
faligndata %f0, %f2, %f0
faligndata %f2, %f4, %f2
faligndata %f4, %f6, %f4
faligndata %f6, %f8, %f6
.L256aligned:
___
for ($i=0; $i<6; $i++) {
$code.=<<___;
std %f0, [$out + `32*$i+0`]
aes_kexpand1 %f0, %f6, $i, %f0
std %f2, [$out + `32*$i+8`]
aes_kexpand2 %f2, %f0, %f2
std %f4, [$out + `32*$i+16`]
aes_kexpand0 %f4, %f2, %f4
std %f6, [$out + `32*$i+24`]
aes_kexpand2 %f6, %f4, %f6
___
}
$code.=<<___;
std %f0, [$out + `32*$i+0`]
aes_kexpand1 %f0, %f6, $i, %f0
std %f2, [$out + `32*$i+8`]
aes_kexpand2 %f2, %f0, %f2
std %f4, [$out + `32*$i+16`]
std %f6, [$out + `32*$i+24`]
std %f0, [$out + `32*$i+32`]
std %f2, [$out + `32*$i+40`]
mov 14, $tmp
st $tmp, [$out + 240]
retl
xor %o0, %o0, %o0
.align 16
.L192:
brz,pt $tmp, .L192aligned
nop
ldd [$inp + 24], %f6
faligndata %f0, %f2, %f0
faligndata %f2, %f4, %f2
faligndata %f4, %f6, %f4
.L192aligned:
___
for ($i=0; $i<7; $i++) {
$code.=<<___;
std %f0, [$out + `24*$i+0`]
aes_kexpand1 %f0, %f4, $i, %f0
std %f2, [$out + `24*$i+8`]
aes_kexpand2 %f2, %f0, %f2
std %f4, [$out + `24*$i+16`]
aes_kexpand2 %f4, %f2, %f4
___
}
$code.=<<___;
std %f0, [$out + `24*$i+0`]
aes_kexpand1 %f0, %f4, $i, %f0
std %f2, [$out + `24*$i+8`]
aes_kexpand2 %f2, %f0, %f2
std %f4, [$out + `24*$i+16`]
std %f0, [$out + `24*$i+24`]
std %f2, [$out + `24*$i+32`]
mov 12, $tmp
st $tmp, [$out + 240]
retl
xor %o0, %o0, %o0
.align 16
.L128:
brz,pt $tmp, .L128aligned
nop
ldd [$inp + 16], %f4
faligndata %f0, %f2, %f0
faligndata %f2, %f4, %f2
.L128aligned:
___
for ($i=0; $i<10; $i++) {
$code.=<<___;
std %f0, [$out + `16*$i+0`]
aes_kexpand1 %f0, %f2, $i, %f0
std %f2, [$out + `16*$i+8`]
aes_kexpand2 %f2, %f0, %f2
___
}
$code.=<<___;
std %f0, [$out + `16*$i+0`]
std %f2, [$out + `16*$i+8`]
mov 10, $tmp
st $tmp, [$out + 240]
retl
xor %o0, %o0, %o0
.type aes_t4_set_encrypt_key,#function
.size aes_t4_set_encrypt_key,.-aes_t4_set_encrypt_key
.globl aes_t4_set_decrypt_key
.align 32
aes_t4_set_decrypt_key:
mov %o7, %o5
call .Lset_encrypt_key
nop
mov %o5, %o7
sll $tmp, 4, $inp ! $tmp is number of rounds
add $tmp, 2, $tmp
add $out, $inp, $inp ! $inp=$out+16*rounds
srl $tmp, 2, $tmp ! $tmp=(rounds+2)/4
.Lkey_flip:
ldd [$out + 0], %f0
ldd [$out + 8], %f2
ldd [$out + 16], %f4
ldd [$out + 24], %f6
ldd [$inp + 0], %f8
ldd [$inp + 8], %f10
ldd [$inp - 16], %f12
ldd [$inp - 8], %f14
sub $tmp, 1, $tmp
std %f0, [$inp + 0]
std %f2, [$inp + 8]
std %f4, [$inp - 16]
std %f6, [$inp - 8]
std %f8, [$out + 0]
std %f10, [$out + 8]
std %f12, [$out + 16]
std %f14, [$out + 24]
add $out, 32, $out
brnz $tmp, .Lkey_flip
sub $inp, 32, $inp
retl
xor %o0, %o0, %o0
.type aes_t4_set_decrypt_key,#function
.size aes_t4_set_decrypt_key,.-aes_t4_set_decrypt_key
___
}
{{{
my ($inp,$out,$len,$key,$ivec,$enc)=map("%i$_",(0..5));
my ($ileft,$iright,$ooff,$omask,$ivoff)=map("%l$_",(1..7));
$code.=<<___;
.align 32
_aes128_encrypt_1x:
___
for ($i=0; $i<4; $i++) {
$code.=<<___;
aes_eround01 %f`16+8*$i+0`, %f0, %f2, %f4
aes_eround23 %f`16+8*$i+2`, %f0, %f2, %f2
aes_eround01 %f`16+8*$i+4`, %f4, %f2, %f0
aes_eround23 %f`16+8*$i+6`, %f4, %f2, %f2
___
}
$code.=<<___;
aes_eround01 %f48, %f0, %f2, %f4
aes_eround23 %f50, %f0, %f2, %f2
aes_eround01_l %f52, %f4, %f2, %f0
retl
aes_eround23_l %f54, %f4, %f2, %f2
.type _aes128_encrypt_1x,#function
.size _aes128_encrypt_1x,.-_aes128_encrypt_1x
.align 32
_aes128_encrypt_2x:
___
for ($i=0; $i<4; $i++) {
$code.=<<___;
aes_eround01 %f`16+8*$i+0`, %f0, %f2, %f8
aes_eround23 %f`16+8*$i+2`, %f0, %f2, %f2
aes_eround01 %f`16+8*$i+0`, %f4, %f6, %f10
aes_eround23 %f`16+8*$i+2`, %f4, %f6, %f6
aes_eround01 %f`16+8*$i+4`, %f8, %f2, %f0
aes_eround23 %f`16+8*$i+6`, %f8, %f2, %f2
aes_eround01 %f`16+8*$i+4`, %f10, %f6, %f4
aes_eround23 %f`16+8*$i+6`, %f10, %f6, %f6
___
}
$code.=<<___;
aes_eround01 %f48, %f0, %f2, %f8
aes_eround23 %f50, %f0, %f2, %f2
aes_eround01 %f48, %f4, %f6, %f10
aes_eround23 %f50, %f4, %f6, %f6
aes_eround01_l %f52, %f8, %f2, %f0
aes_eround23_l %f54, %f8, %f2, %f2
aes_eround01_l %f52, %f10, %f6, %f4
retl
aes_eround23_l %f54, %f10, %f6, %f6
.type _aes128_encrypt_2x,#function
.size _aes128_encrypt_2x,.-_aes128_encrypt_2x
.align 32
_aes128_loadkey:
ldx [$key + 0], %g4
ldx [$key + 8], %g5
___
for ($i=2; $i<22;$i++) { # load key schedule
$code.=<<___;
ldd [$key + `8*$i`], %f`12+2*$i`
___
}
$code.=<<___;
retl
nop
.type _aes128_loadkey,#function
.size _aes128_loadkey,.-_aes128_loadkey
_aes128_load_enckey=_aes128_loadkey
_aes128_load_deckey=_aes128_loadkey
___
&alg_cbc_encrypt_implement("aes",128);
if ($::evp) {
&alg_ctr32_implement("aes",128);
&alg_xts_implement("aes",128,"en");
&alg_xts_implement("aes",128,"de");
}
&alg_cbc_decrypt_implement("aes",128);
$code.=<<___;
.align 32
_aes128_decrypt_1x:
___
for ($i=0; $i<4; $i++) {
$code.=<<___;
aes_dround01 %f`16+8*$i+0`, %f0, %f2, %f4
aes_dround23 %f`16+8*$i+2`, %f0, %f2, %f2
aes_dround01 %f`16+8*$i+4`, %f4, %f2, %f0
aes_dround23 %f`16+8*$i+6`, %f4, %f2, %f2
___
}
$code.=<<___;
aes_dround01 %f48, %f0, %f2, %f4
aes_dround23 %f50, %f0, %f2, %f2
aes_dround01_l %f52, %f4, %f2, %f0
retl
aes_dround23_l %f54, %f4, %f2, %f2
.type _aes128_decrypt_1x,#function
.size _aes128_decrypt_1x,.-_aes128_decrypt_1x
.align 32
_aes128_decrypt_2x:
___
for ($i=0; $i<4; $i++) {
$code.=<<___;
aes_dround01 %f`16+8*$i+0`, %f0, %f2, %f8
aes_dround23 %f`16+8*$i+2`, %f0, %f2, %f2
aes_dround01 %f`16+8*$i+0`, %f4, %f6, %f10
aes_dround23 %f`16+8*$i+2`, %f4, %f6, %f6
aes_dround01 %f`16+8*$i+4`, %f8, %f2, %f0
aes_dround23 %f`16+8*$i+6`, %f8, %f2, %f2
aes_dround01 %f`16+8*$i+4`, %f10, %f6, %f4
aes_dround23 %f`16+8*$i+6`, %f10, %f6, %f6
___
}
$code.=<<___;
aes_dround01 %f48, %f0, %f2, %f8
aes_dround23 %f50, %f0, %f2, %f2
aes_dround01 %f48, %f4, %f6, %f10
aes_dround23 %f50, %f4, %f6, %f6
aes_dround01_l %f52, %f8, %f2, %f0
aes_dround23_l %f54, %f8, %f2, %f2
aes_dround01_l %f52, %f10, %f6, %f4
retl
aes_dround23_l %f54, %f10, %f6, %f6
.type _aes128_decrypt_2x,#function
.size _aes128_decrypt_2x,.-_aes128_decrypt_2x
___
$code.=<<___;
.align 32
_aes192_encrypt_1x:
___
for ($i=0; $i<5; $i++) {
$code.=<<___;
aes_eround01 %f`16+8*$i+0`, %f0, %f2, %f4
aes_eround23 %f`16+8*$i+2`, %f0, %f2, %f2
aes_eround01 %f`16+8*$i+4`, %f4, %f2, %f0
aes_eround23 %f`16+8*$i+6`, %f4, %f2, %f2
___
}
$code.=<<___;
aes_eround01 %f56, %f0, %f2, %f4
aes_eround23 %f58, %f0, %f2, %f2
aes_eround01_l %f60, %f4, %f2, %f0
retl
aes_eround23_l %f62, %f4, %f2, %f2
.type _aes192_encrypt_1x,#function
.size _aes192_encrypt_1x,.-_aes192_encrypt_1x
.align 32
_aes192_encrypt_2x:
___
for ($i=0; $i<5; $i++) {
$code.=<<___;
aes_eround01 %f`16+8*$i+0`, %f0, %f2, %f8
aes_eround23 %f`16+8*$i+2`, %f0, %f2, %f2
aes_eround01 %f`16+8*$i+0`, %f4, %f6, %f10
aes_eround23 %f`16+8*$i+2`, %f4, %f6, %f6
aes_eround01 %f`16+8*$i+4`, %f8, %f2, %f0
aes_eround23 %f`16+8*$i+6`, %f8, %f2, %f2
aes_eround01 %f`16+8*$i+4`, %f10, %f6, %f4
aes_eround23 %f`16+8*$i+6`, %f10, %f6, %f6
___
}
$code.=<<___;
aes_eround01 %f56, %f0, %f2, %f8
aes_eround23 %f58, %f0, %f2, %f2
aes_eround01 %f56, %f4, %f6, %f10
aes_eround23 %f58, %f4, %f6, %f6
aes_eround01_l %f60, %f8, %f2, %f0
aes_eround23_l %f62, %f8, %f2, %f2
aes_eround01_l %f60, %f10, %f6, %f4
retl
aes_eround23_l %f62, %f10, %f6, %f6
.type _aes192_encrypt_2x,#function
.size _aes192_encrypt_2x,.-_aes192_encrypt_2x
.align 32
_aes256_encrypt_1x:
aes_eround01 %f16, %f0, %f2, %f4
aes_eround23 %f18, %f0, %f2, %f2
ldd [$key + 208], %f16
ldd [$key + 216], %f18
aes_eround01 %f20, %f4, %f2, %f0
aes_eround23 %f22, %f4, %f2, %f2
ldd [$key + 224], %f20
ldd [$key + 232], %f22
___
for ($i=1; $i<6; $i++) {
$code.=<<___;
aes_eround01 %f`16+8*$i+0`, %f0, %f2, %f4
aes_eround23 %f`16+8*$i+2`, %f0, %f2, %f2
aes_eround01 %f`16+8*$i+4`, %f4, %f2, %f0
aes_eround23 %f`16+8*$i+6`, %f4, %f2, %f2
___
}
$code.=<<___;
aes_eround01 %f16, %f0, %f2, %f4
aes_eround23 %f18, %f0, %f2, %f2
ldd [$key + 16], %f16
ldd [$key + 24], %f18
aes_eround01_l %f20, %f4, %f2, %f0
aes_eround23_l %f22, %f4, %f2, %f2
ldd [$key + 32], %f20
retl
ldd [$key + 40], %f22
.type _aes256_encrypt_1x,#function
.size _aes256_encrypt_1x,.-_aes256_encrypt_1x
.align 32
_aes256_encrypt_2x:
aes_eround01 %f16, %f0, %f2, %f8
aes_eround23 %f18, %f0, %f2, %f2
aes_eround01 %f16, %f4, %f6, %f10
aes_eround23 %f18, %f4, %f6, %f6
ldd [$key + 208], %f16
ldd [$key + 216], %f18
aes_eround01 %f20, %f8, %f2, %f0
aes_eround23 %f22, %f8, %f2, %f2
aes_eround01 %f20, %f10, %f6, %f4
aes_eround23 %f22, %f10, %f6, %f6
ldd [$key + 224], %f20
ldd [$key + 232], %f22
___
for ($i=1; $i<6; $i++) {
$code.=<<___;
aes_eround01 %f`16+8*$i+0`, %f0, %f2, %f8
aes_eround23 %f`16+8*$i+2`, %f0, %f2, %f2
aes_eround01 %f`16+8*$i+0`, %f4, %f6, %f10
aes_eround23 %f`16+8*$i+2`, %f4, %f6, %f6
aes_eround01 %f`16+8*$i+4`, %f8, %f2, %f0
aes_eround23 %f`16+8*$i+6`, %f8, %f2, %f2
aes_eround01 %f`16+8*$i+4`, %f10, %f6, %f4
aes_eround23 %f`16+8*$i+6`, %f10, %f6, %f6
___
}
$code.=<<___;
aes_eround01 %f16, %f0, %f2, %f8
aes_eround23 %f18, %f0, %f2, %f2
aes_eround01 %f16, %f4, %f6, %f10
aes_eround23 %f18, %f4, %f6, %f6
ldd [$key + 16], %f16
ldd [$key + 24], %f18
aes_eround01_l %f20, %f8, %f2, %f0
aes_eround23_l %f22, %f8, %f2, %f2
aes_eround01_l %f20, %f10, %f6, %f4
aes_eround23_l %f22, %f10, %f6, %f6
ldd [$key + 32], %f20
retl
ldd [$key + 40], %f22
.type _aes256_encrypt_2x,#function
.size _aes256_encrypt_2x,.-_aes256_encrypt_2x
.align 32
_aes192_loadkey:
ldx [$key + 0], %g4
ldx [$key + 8], %g5
___
for ($i=2; $i<26;$i++) { # load key schedule
$code.=<<___;
ldd [$key + `8*$i`], %f`12+2*$i`
___
}
$code.=<<___;
retl
nop
.type _aes192_loadkey,#function
.size _aes192_loadkey,.-_aes192_loadkey
_aes256_loadkey=_aes192_loadkey
_aes192_load_enckey=_aes192_loadkey
_aes192_load_deckey=_aes192_loadkey
_aes256_load_enckey=_aes192_loadkey
_aes256_load_deckey=_aes192_loadkey
___
&alg_cbc_encrypt_implement("aes",256);
&alg_cbc_encrypt_implement("aes",192);
if ($::evp) {
&alg_ctr32_implement("aes",256);
&alg_xts_implement("aes",256,"en");
&alg_xts_implement("aes",256,"de");
&alg_ctr32_implement("aes",192);
}
&alg_cbc_decrypt_implement("aes",192);
&alg_cbc_decrypt_implement("aes",256);
$code.=<<___;
.align 32
_aes256_decrypt_1x:
aes_dround01 %f16, %f0, %f2, %f4
aes_dround23 %f18, %f0, %f2, %f2
ldd [$key + 208], %f16
ldd [$key + 216], %f18
aes_dround01 %f20, %f4, %f2, %f0
aes_dround23 %f22, %f4, %f2, %f2
ldd [$key + 224], %f20
ldd [$key + 232], %f22
___
for ($i=1; $i<6; $i++) {
$code.=<<___;
aes_dround01 %f`16+8*$i+0`, %f0, %f2, %f4
aes_dround23 %f`16+8*$i+2`, %f0, %f2, %f2
aes_dround01 %f`16+8*$i+4`, %f4, %f2, %f0
aes_dround23 %f`16+8*$i+6`, %f4, %f2, %f2
___
}
$code.=<<___;
aes_dround01 %f16, %f0, %f2, %f4
aes_dround23 %f18, %f0, %f2, %f2
ldd [$key + 16], %f16
ldd [$key + 24], %f18
aes_dround01_l %f20, %f4, %f2, %f0
aes_dround23_l %f22, %f4, %f2, %f2
ldd [$key + 32], %f20
retl
ldd [$key + 40], %f22
.type _aes256_decrypt_1x,#function
.size _aes256_decrypt_1x,.-_aes256_decrypt_1x
.align 32
_aes256_decrypt_2x:
aes_dround01 %f16, %f0, %f2, %f8
aes_dround23 %f18, %f0, %f2, %f2
aes_dround01 %f16, %f4, %f6, %f10
aes_dround23 %f18, %f4, %f6, %f6
ldd [$key + 208], %f16
ldd [$key + 216], %f18
aes_dround01 %f20, %f8, %f2, %f0
aes_dround23 %f22, %f8, %f2, %f2
aes_dround01 %f20, %f10, %f6, %f4
aes_dround23 %f22, %f10, %f6, %f6
ldd [$key + 224], %f20
ldd [$key + 232], %f22
___
for ($i=1; $i<6; $i++) {
$code.=<<___;
aes_dround01 %f`16+8*$i+0`, %f0, %f2, %f8
aes_dround23 %f`16+8*$i+2`, %f0, %f2, %f2
aes_dround01 %f`16+8*$i+0`, %f4, %f6, %f10
aes_dround23 %f`16+8*$i+2`, %f4, %f6, %f6
aes_dround01 %f`16+8*$i+4`, %f8, %f2, %f0
aes_dround23 %f`16+8*$i+6`, %f8, %f2, %f2
aes_dround01 %f`16+8*$i+4`, %f10, %f6, %f4
aes_dround23 %f`16+8*$i+6`, %f10, %f6, %f6
___
}
$code.=<<___;
aes_dround01 %f16, %f0, %f2, %f8
aes_dround23 %f18, %f0, %f2, %f2
aes_dround01 %f16, %f4, %f6, %f10
aes_dround23 %f18, %f4, %f6, %f6
ldd [$key + 16], %f16
ldd [$key + 24], %f18
aes_dround01_l %f20, %f8, %f2, %f0
aes_dround23_l %f22, %f8, %f2, %f2
aes_dround01_l %f20, %f10, %f6, %f4
aes_dround23_l %f22, %f10, %f6, %f6
ldd [$key + 32], %f20
retl
ldd [$key + 40], %f22
.type _aes256_decrypt_2x,#function
.size _aes256_decrypt_2x,.-_aes256_decrypt_2x
.align 32
_aes192_decrypt_1x:
___
for ($i=0; $i<5; $i++) {
$code.=<<___;
aes_dround01 %f`16+8*$i+0`, %f0, %f2, %f4
aes_dround23 %f`16+8*$i+2`, %f0, %f2, %f2
aes_dround01 %f`16+8*$i+4`, %f4, %f2, %f0
aes_dround23 %f`16+8*$i+6`, %f4, %f2, %f2
___
}
$code.=<<___;
aes_dround01 %f56, %f0, %f2, %f4
aes_dround23 %f58, %f0, %f2, %f2
aes_dround01_l %f60, %f4, %f2, %f0
retl
aes_dround23_l %f62, %f4, %f2, %f2
.type _aes192_decrypt_1x,#function
.size _aes192_decrypt_1x,.-_aes192_decrypt_1x
.align 32
_aes192_decrypt_2x:
___
for ($i=0; $i<5; $i++) {
$code.=<<___;
aes_dround01 %f`16+8*$i+0`, %f0, %f2, %f8
aes_dround23 %f`16+8*$i+2`, %f0, %f2, %f2
aes_dround01 %f`16+8*$i+0`, %f4, %f6, %f10
aes_dround23 %f`16+8*$i+2`, %f4, %f6, %f6
aes_dround01 %f`16+8*$i+4`, %f8, %f2, %f0
aes_dround23 %f`16+8*$i+6`, %f8, %f2, %f2
aes_dround01 %f`16+8*$i+4`, %f10, %f6, %f4
aes_dround23 %f`16+8*$i+6`, %f10, %f6, %f6
___
}
$code.=<<___;
aes_dround01 %f56, %f0, %f2, %f8
aes_dround23 %f58, %f0, %f2, %f2
aes_dround01 %f56, %f4, %f6, %f10
aes_dround23 %f58, %f4, %f6, %f6
aes_dround01_l %f60, %f8, %f2, %f0
aes_dround23_l %f62, %f8, %f2, %f2
aes_dround01_l %f60, %f10, %f6, %f4
retl
aes_dround23_l %f62, %f10, %f6, %f6
.type _aes192_decrypt_2x,#function
.size _aes192_decrypt_2x,.-_aes192_decrypt_2x
___
}}}
if (!$::evp) {
$code.=<<___;
.global AES_encrypt
AES_encrypt=aes_t4_encrypt
.global AES_decrypt
AES_decrypt=aes_t4_decrypt
.global AES_set_encrypt_key
.align 32
AES_set_encrypt_key:
andcc %o2, 7, %g0 ! check alignment
bnz,a,pn %icc, 1f
mov -1, %o0
brz,a,pn %o0, 1f
mov -1, %o0
brz,a,pn %o2, 1f
mov -1, %o0
andncc %o1, 0x1c0, %g0
bnz,a,pn %icc, 1f
mov -2, %o0
cmp %o1, 128
bl,a,pn %icc, 1f
mov -2, %o0
b aes_t4_set_encrypt_key
nop
1: retl
nop
.type AES_set_encrypt_key,#function
.size AES_set_encrypt_key,.-AES_set_encrypt_key
.global AES_set_decrypt_key
.align 32
AES_set_decrypt_key:
andcc %o2, 7, %g0 ! check alignment
bnz,a,pn %icc, 1f
mov -1, %o0
brz,a,pn %o0, 1f
mov -1, %o0
brz,a,pn %o2, 1f
mov -1, %o0
andncc %o1, 0x1c0, %g0
bnz,a,pn %icc, 1f
mov -2, %o0
cmp %o1, 128
bl,a,pn %icc, 1f
mov -2, %o0
b aes_t4_set_decrypt_key
nop
1: retl
nop
.type AES_set_decrypt_key,#function
.size AES_set_decrypt_key,.-AES_set_decrypt_key
___
my ($inp,$out,$len,$key,$ivec,$enc)=map("%o$_",(0..5));
$code.=<<___;
.globl AES_cbc_encrypt
.align 32
AES_cbc_encrypt:
ld [$key + 240], %g1
nop
brz $enc, .Lcbc_decrypt
cmp %g1, 12
bl,pt %icc, aes128_t4_cbc_encrypt
nop
be,pn %icc, aes192_t4_cbc_encrypt
nop
ba aes256_t4_cbc_encrypt
nop
.Lcbc_decrypt:
bl,pt %icc, aes128_t4_cbc_decrypt
nop
be,pn %icc, aes192_t4_cbc_decrypt
nop
ba aes256_t4_cbc_decrypt
nop
.type AES_cbc_encrypt,#function
.size AES_cbc_encrypt,.-AES_cbc_encrypt
___
}
$code.=<<___;
.asciz "AES for SPARC T4, David S. Miller, Andy Polyakov"
.align 4
___
&emit_assembler();
close STDOUT;

960
crypto/aes/asm/aesv8-armx.pl Executable file
View File

@ -0,0 +1,960 @@
#!/usr/bin/env perl
#
# ====================================================================
# Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
# project. The module is, however, dual licensed under OpenSSL and
# CRYPTOGAMS licenses depending on where you obtain it. For further
# details see http://www.openssl.org/~appro/cryptogams/.
# ====================================================================
#
# This module implements support for ARMv8 AES instructions. The
# module is endian-agnostic in sense that it supports both big- and
# little-endian cases. As does it support both 32- and 64-bit modes
# of operation. Latter is achieved by limiting amount of utilized
# registers to 16, which implies additional NEON load and integer
# instructions. This has no effect on mighty Apple A7, where results
# are literally equal to the theoretical estimates based on AES
# instruction latencies and issue rates. On Cortex-A53, an in-order
# execution core, this costs up to 10-15%, which is partially
# compensated by implementing dedicated code path for 128-bit
# CBC encrypt case. On Cortex-A57 parallelizable mode performance
# seems to be limited by sheer amount of NEON instructions...
#
# Performance in cycles per byte processed with 128-bit key:
#
# CBC enc CBC dec CTR
# Apple A7 2.39 1.20 1.20
# Cortex-A53 2.45 1.87 1.94
# Cortex-A57 3.64 1.34 1.32
$flavour = shift;
open STDOUT,">".shift;
$prefix="aes_v8";
$code=<<___;
#include "arm_arch.h"
#if __ARM_ARCH__>=7
.text
___
$code.=".arch armv8-a+crypto\n" if ($flavour =~ /64/);
$code.=".fpu neon\n.code 32\n" if ($flavour !~ /64/);
# Assembler mnemonics are an eclectic mix of 32- and 64-bit syntax,
# NEON is mostly 32-bit mnemonics, integer - mostly 64. Goal is to
# maintain both 32- and 64-bit codes within single module and
# transliterate common code to either flavour with regex vodoo.
#
{{{
my ($inp,$bits,$out,$ptr,$rounds)=("x0","w1","x2","x3","w12");
my ($zero,$rcon,$mask,$in0,$in1,$tmp,$key)=
$flavour=~/64/? map("q$_",(0..6)) : map("q$_",(0..3,8..10));
$code.=<<___;
.align 5
rcon:
.long 0x01,0x01,0x01,0x01
.long 0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d // rotate-n-splat
.long 0x1b,0x1b,0x1b,0x1b
.globl ${prefix}_set_encrypt_key
.type ${prefix}_set_encrypt_key,%function
.align 5
${prefix}_set_encrypt_key:
.Lenc_key:
___
$code.=<<___ if ($flavour =~ /64/);
stp x29,x30,[sp,#-16]!
add x29,sp,#0
___
$code.=<<___;
mov $ptr,#-1
cmp $inp,#0
b.eq .Lenc_key_abort
cmp $out,#0
b.eq .Lenc_key_abort
mov $ptr,#-2
cmp $bits,#128
b.lt .Lenc_key_abort
cmp $bits,#256
b.gt .Lenc_key_abort
tst $bits,#0x3f
b.ne .Lenc_key_abort
adr $ptr,rcon
cmp $bits,#192
veor $zero,$zero,$zero
vld1.8 {$in0},[$inp],#16
mov $bits,#8 // reuse $bits
vld1.32 {$rcon,$mask},[$ptr],#32
b.lt .Loop128
b.eq .L192
b .L256
.align 4
.Loop128:
vtbl.8 $key,{$in0},$mask
vext.8 $tmp,$zero,$in0,#12
vst1.32 {$in0},[$out],#16
aese $key,$zero
subs $bits,$bits,#1
veor $in0,$in0,$tmp
vext.8 $tmp,$zero,$tmp,#12
veor $in0,$in0,$tmp
vext.8 $tmp,$zero,$tmp,#12
veor $key,$key,$rcon
veor $in0,$in0,$tmp
vshl.u8 $rcon,$rcon,#1
veor $in0,$in0,$key
b.ne .Loop128
vld1.32 {$rcon},[$ptr]
vtbl.8 $key,{$in0},$mask
vext.8 $tmp,$zero,$in0,#12
vst1.32 {$in0},[$out],#16
aese $key,$zero
veor $in0,$in0,$tmp
vext.8 $tmp,$zero,$tmp,#12
veor $in0,$in0,$tmp
vext.8 $tmp,$zero,$tmp,#12
veor $key,$key,$rcon
veor $in0,$in0,$tmp
vshl.u8 $rcon,$rcon,#1
veor $in0,$in0,$key
vtbl.8 $key,{$in0},$mask
vext.8 $tmp,$zero,$in0,#12
vst1.32 {$in0},[$out],#16
aese $key,$zero
veor $in0,$in0,$tmp
vext.8 $tmp,$zero,$tmp,#12
veor $in0,$in0,$tmp
vext.8 $tmp,$zero,$tmp,#12
veor $key,$key,$rcon
veor $in0,$in0,$tmp
veor $in0,$in0,$key
vst1.32 {$in0},[$out]
add $out,$out,#0x50
mov $rounds,#10
b .Ldone
.align 4
.L192:
vld1.8 {$in1},[$inp],#8
vmov.i8 $key,#8 // borrow $key
vst1.32 {$in0},[$out],#16
vsub.i8 $mask,$mask,$key // adjust the mask
.Loop192:
vtbl.8 $key,{$in1},$mask
vext.8 $tmp,$zero,$in0,#12
vst1.32 {$in1},[$out],#8
aese $key,$zero
subs $bits,$bits,#1
veor $in0,$in0,$tmp
vext.8 $tmp,$zero,$tmp,#12
veor $in0,$in0,$tmp
vext.8 $tmp,$zero,$tmp,#12
veor $in0,$in0,$tmp
vdup.32 $tmp,${in0}[3]
veor $tmp,$tmp,$in1
veor $key,$key,$rcon
vext.8 $in1,$zero,$in1,#12
vshl.u8 $rcon,$rcon,#1
veor $in1,$in1,$tmp
veor $in0,$in0,$key
veor $in1,$in1,$key
vst1.32 {$in0},[$out],#16
b.ne .Loop192
mov $rounds,#12
add $out,$out,#0x20
b .Ldone
.align 4
.L256:
vld1.8 {$in1},[$inp]
mov $bits,#7
mov $rounds,#14
vst1.32 {$in0},[$out],#16
.Loop256:
vtbl.8 $key,{$in1},$mask
vext.8 $tmp,$zero,$in0,#12
vst1.32 {$in1},[$out],#16
aese $key,$zero
subs $bits,$bits,#1
veor $in0,$in0,$tmp
vext.8 $tmp,$zero,$tmp,#12
veor $in0,$in0,$tmp
vext.8 $tmp,$zero,$tmp,#12
veor $key,$key,$rcon
veor $in0,$in0,$tmp
vshl.u8 $rcon,$rcon,#1
veor $in0,$in0,$key
vst1.32 {$in0},[$out],#16
b.eq .Ldone
vdup.32 $key,${in0}[3] // just splat
vext.8 $tmp,$zero,$in1,#12
aese $key,$zero
veor $in1,$in1,$tmp
vext.8 $tmp,$zero,$tmp,#12
veor $in1,$in1,$tmp
vext.8 $tmp,$zero,$tmp,#12
veor $in1,$in1,$tmp
veor $in1,$in1,$key
b .Loop256
.Ldone:
str $rounds,[$out]
mov $ptr,#0
.Lenc_key_abort:
mov x0,$ptr // return value
`"ldr x29,[sp],#16" if ($flavour =~ /64/)`
ret
.size ${prefix}_set_encrypt_key,.-${prefix}_set_encrypt_key
.globl ${prefix}_set_decrypt_key
.type ${prefix}_set_decrypt_key,%function
.align 5
${prefix}_set_decrypt_key:
___
$code.=<<___ if ($flavour =~ /64/);
stp x29,x30,[sp,#-16]!
add x29,sp,#0
___
$code.=<<___ if ($flavour !~ /64/);
stmdb sp!,{r4,lr}
___
$code.=<<___;
bl .Lenc_key
cmp x0,#0
b.ne .Ldec_key_abort
sub $out,$out,#240 // restore original $out
mov x4,#-16
add $inp,$out,x12,lsl#4 // end of key schedule
vld1.32 {v0.16b},[$out]
vld1.32 {v1.16b},[$inp]
vst1.32 {v0.16b},[$inp],x4
vst1.32 {v1.16b},[$out],#16
.Loop_imc:
vld1.32 {v0.16b},[$out]
vld1.32 {v1.16b},[$inp]
aesimc v0.16b,v0.16b
aesimc v1.16b,v1.16b
vst1.32 {v0.16b},[$inp],x4
vst1.32 {v1.16b},[$out],#16
cmp $inp,$out
b.hi .Loop_imc
vld1.32 {v0.16b},[$out]
aesimc v0.16b,v0.16b
vst1.32 {v0.16b},[$inp]
eor x0,x0,x0 // return value
.Ldec_key_abort:
___
$code.=<<___ if ($flavour !~ /64/);
ldmia sp!,{r4,pc}
___
$code.=<<___ if ($flavour =~ /64/);
ldp x29,x30,[sp],#16
ret
___
$code.=<<___;
.size ${prefix}_set_decrypt_key,.-${prefix}_set_decrypt_key
___
}}}
{{{
sub gen_block () {
my $dir = shift;
my ($e,$mc) = $dir eq "en" ? ("e","mc") : ("d","imc");
my ($inp,$out,$key)=map("x$_",(0..2));
my $rounds="w3";
my ($rndkey0,$rndkey1,$inout)=map("q$_",(0..3));
$code.=<<___;
.globl ${prefix}_${dir}crypt
.type ${prefix}_${dir}crypt,%function
.align 5
${prefix}_${dir}crypt:
ldr $rounds,[$key,#240]
vld1.32 {$rndkey0},[$key],#16
vld1.8 {$inout},[$inp]
sub $rounds,$rounds,#2
vld1.32 {$rndkey1},[$key],#16
.Loop_${dir}c:
aes$e $inout,$rndkey0
vld1.32 {$rndkey0},[$key],#16
aes$mc $inout,$inout
subs $rounds,$rounds,#2
aes$e $inout,$rndkey1
vld1.32 {$rndkey1},[$key],#16
aes$mc $inout,$inout
b.gt .Loop_${dir}c
aes$e $inout,$rndkey0
vld1.32 {$rndkey0},[$key]
aes$mc $inout,$inout
aes$e $inout,$rndkey1
veor $inout,$inout,$rndkey0
vst1.8 {$inout},[$out]
ret
.size ${prefix}_${dir}crypt,.-${prefix}_${dir}crypt
___
}
&gen_block("en");
&gen_block("de");
}}}
{{{
my ($inp,$out,$len,$key,$ivp)=map("x$_",(0..4)); my $enc="w5";
my ($rounds,$cnt,$key_,$step,$step1)=($enc,"w6","x7","x8","x12");
my ($dat0,$dat1,$in0,$in1,$tmp0,$tmp1,$ivec,$rndlast)=map("q$_",(0..7));
my ($dat,$tmp,$rndzero_n_last)=($dat0,$tmp0,$tmp1);
### q8-q15 preloaded key schedule
$code.=<<___;
.globl ${prefix}_cbc_encrypt
.type ${prefix}_cbc_encrypt,%function
.align 5
${prefix}_cbc_encrypt:
___
$code.=<<___ if ($flavour =~ /64/);
stp x29,x30,[sp,#-16]!
add x29,sp,#0
___
$code.=<<___ if ($flavour !~ /64/);
mov ip,sp
stmdb sp!,{r4-r8,lr}
vstmdb sp!,{d8-d15} @ ABI specification says so
ldmia ip,{r4-r5} @ load remaining args
___
$code.=<<___;
subs $len,$len,#16
mov $step,#16
b.lo .Lcbc_abort
cclr $step,eq
cmp $enc,#0 // en- or decrypting?
ldr $rounds,[$key,#240]
and $len,$len,#-16
vld1.8 {$ivec},[$ivp]
vld1.8 {$dat},[$inp],$step
vld1.32 {q8-q9},[$key] // load key schedule...
sub $rounds,$rounds,#6
add $key_,$key,x5,lsl#4 // pointer to last 7 round keys
sub $rounds,$rounds,#2
vld1.32 {q10-q11},[$key_],#32
vld1.32 {q12-q13},[$key_],#32
vld1.32 {q14-q15},[$key_],#32
vld1.32 {$rndlast},[$key_]
add $key_,$key,#32
mov $cnt,$rounds
b.eq .Lcbc_dec
cmp $rounds,#2
veor $dat,$dat,$ivec
veor $rndzero_n_last,q8,$rndlast
b.eq .Lcbc_enc128
.Loop_cbc_enc:
aese $dat,q8
vld1.32 {q8},[$key_],#16
aesmc $dat,$dat
subs $cnt,$cnt,#2
aese $dat,q9
vld1.32 {q9},[$key_],#16
aesmc $dat,$dat
b.gt .Loop_cbc_enc
aese $dat,q8
aesmc $dat,$dat
subs $len,$len,#16
aese $dat,q9
aesmc $dat,$dat
cclr $step,eq
aese $dat,q10
aesmc $dat,$dat
add $key_,$key,#16
aese $dat,q11
aesmc $dat,$dat
vld1.8 {q8},[$inp],$step
aese $dat,q12
aesmc $dat,$dat
veor q8,q8,$rndzero_n_last
aese $dat,q13
aesmc $dat,$dat
vld1.32 {q9},[$key_],#16 // re-pre-load rndkey[1]
aese $dat,q14
aesmc $dat,$dat
aese $dat,q15
mov $cnt,$rounds
veor $ivec,$dat,$rndlast
vst1.8 {$ivec},[$out],#16
b.hs .Loop_cbc_enc
b .Lcbc_done
.align 5
.Lcbc_enc128:
vld1.32 {$in0-$in1},[$key_]
aese $dat,q8
aesmc $dat,$dat
b .Lenter_cbc_enc128
.Loop_cbc_enc128:
aese $dat,q8
aesmc $dat,$dat
vst1.8 {$ivec},[$out],#16
.Lenter_cbc_enc128:
aese $dat,q9
aesmc $dat,$dat
subs $len,$len,#16
aese $dat,$in0
aesmc $dat,$dat
cclr $step,eq
aese $dat,$in1
aesmc $dat,$dat
aese $dat,q10
aesmc $dat,$dat
aese $dat,q11
aesmc $dat,$dat
vld1.8 {q8},[$inp],$step
aese $dat,q12
aesmc $dat,$dat
aese $dat,q13
aesmc $dat,$dat
aese $dat,q14
aesmc $dat,$dat
veor q8,q8,$rndzero_n_last
aese $dat,q15
veor $ivec,$dat,$rndlast
b.hs .Loop_cbc_enc128
vst1.8 {$ivec},[$out],#16
b .Lcbc_done
___
{
my ($dat2,$in2,$tmp2)=map("q$_",(10,11,9));
$code.=<<___;
.align 5
.Lcbc_dec:
vld1.8 {$dat2},[$inp],#16
subs $len,$len,#32 // bias
add $cnt,$rounds,#2
vorr $in1,$dat,$dat
vorr $dat1,$dat,$dat
vorr $in2,$dat2,$dat2
b.lo .Lcbc_dec_tail
vorr $dat1,$dat2,$dat2
vld1.8 {$dat2},[$inp],#16
vorr $in0,$dat,$dat
vorr $in1,$dat1,$dat1
vorr $in2,$dat2,$dat2
.Loop3x_cbc_dec:
aesd $dat0,q8
aesd $dat1,q8
aesd $dat2,q8
vld1.32 {q8},[$key_],#16
aesimc $dat0,$dat0
aesimc $dat1,$dat1
aesimc $dat2,$dat2
subs $cnt,$cnt,#2
aesd $dat0,q9
aesd $dat1,q9
aesd $dat2,q9
vld1.32 {q9},[$key_],#16
aesimc $dat0,$dat0
aesimc $dat1,$dat1
aesimc $dat2,$dat2
b.gt .Loop3x_cbc_dec
aesd $dat0,q8
aesd $dat1,q8
aesd $dat2,q8
veor $tmp0,$ivec,$rndlast
aesimc $dat0,$dat0
aesimc $dat1,$dat1
aesimc $dat2,$dat2
veor $tmp1,$in0,$rndlast
aesd $dat0,q9
aesd $dat1,q9
aesd $dat2,q9
veor $tmp2,$in1,$rndlast
subs $len,$len,#0x30
aesimc $dat0,$dat0
aesimc $dat1,$dat1
aesimc $dat2,$dat2
vorr $ivec,$in2,$in2
mov.lo x6,$len // x6, $cnt, is zero at this point
aesd $dat0,q12
aesd $dat1,q12
aesd $dat2,q12
add $inp,$inp,x6 // $inp is adjusted in such way that
// at exit from the loop $dat1-$dat2
// are loaded with last "words"
aesimc $dat0,$dat0
aesimc $dat1,$dat1
aesimc $dat2,$dat2
mov $key_,$key
aesd $dat0,q13
aesd $dat1,q13
aesd $dat2,q13
vld1.8 {$in0},[$inp],#16
aesimc $dat0,$dat0
aesimc $dat1,$dat1
aesimc $dat2,$dat2
vld1.8 {$in1},[$inp],#16
aesd $dat0,q14
aesd $dat1,q14
aesd $dat2,q14
vld1.8 {$in2},[$inp],#16
aesimc $dat0,$dat0
aesimc $dat1,$dat1
aesimc $dat2,$dat2
vld1.32 {q8},[$key_],#16 // re-pre-load rndkey[0]
aesd $dat0,q15
aesd $dat1,q15
aesd $dat2,q15
add $cnt,$rounds,#2
veor $tmp0,$tmp0,$dat0
veor $tmp1,$tmp1,$dat1
veor $dat2,$dat2,$tmp2
vld1.32 {q9},[$key_],#16 // re-pre-load rndkey[1]
vorr $dat0,$in0,$in0
vst1.8 {$tmp0},[$out],#16
vorr $dat1,$in1,$in1
vst1.8 {$tmp1},[$out],#16
vst1.8 {$dat2},[$out],#16
vorr $dat2,$in2,$in2
b.hs .Loop3x_cbc_dec
cmn $len,#0x30
b.eq .Lcbc_done
nop
.Lcbc_dec_tail:
aesd $dat1,q8
aesd $dat2,q8
vld1.32 {q8},[$key_],#16
aesimc $dat1,$dat1
aesimc $dat2,$dat2
subs $cnt,$cnt,#2
aesd $dat1,q9
aesd $dat2,q9
vld1.32 {q9},[$key_],#16
aesimc $dat1,$dat1
aesimc $dat2,$dat2
b.gt .Lcbc_dec_tail
aesd $dat1,q8
aesd $dat2,q8
aesimc $dat1,$dat1
aesimc $dat2,$dat2
aesd $dat1,q9
aesd $dat2,q9
aesimc $dat1,$dat1
aesimc $dat2,$dat2
aesd $dat1,q12
aesd $dat2,q12
aesimc $dat1,$dat1
aesimc $dat2,$dat2
cmn $len,#0x20
aesd $dat1,q13
aesd $dat2,q13
aesimc $dat1,$dat1
aesimc $dat2,$dat2
veor $tmp1,$ivec,$rndlast
aesd $dat1,q14
aesd $dat2,q14
aesimc $dat1,$dat1
aesimc $dat2,$dat2
veor $tmp2,$in1,$rndlast
aesd $dat1,q15
aesd $dat2,q15
b.eq .Lcbc_dec_one
veor $tmp1,$tmp1,$dat1
veor $tmp2,$tmp2,$dat2
vorr $ivec,$in2,$in2
vst1.8 {$tmp1},[$out],#16
vst1.8 {$tmp2},[$out],#16
b .Lcbc_done
.Lcbc_dec_one:
veor $tmp1,$tmp1,$dat2
vorr $ivec,$in2,$in2
vst1.8 {$tmp1},[$out],#16
.Lcbc_done:
vst1.8 {$ivec},[$ivp]
.Lcbc_abort:
___
}
$code.=<<___ if ($flavour !~ /64/);
vldmia sp!,{d8-d15}
ldmia sp!,{r4-r8,pc}
___
$code.=<<___ if ($flavour =~ /64/);
ldr x29,[sp],#16
ret
___
$code.=<<___;
.size ${prefix}_cbc_encrypt,.-${prefix}_cbc_encrypt
___
}}}
{{{
my ($inp,$out,$len,$key,$ivp)=map("x$_",(0..4));
my ($rounds,$cnt,$key_)=("w5","w6","x7");
my ($ctr,$tctr0,$tctr1,$tctr2)=map("w$_",(8..10,12));
my $step="x12"; # aliases with $tctr2
my ($dat0,$dat1,$in0,$in1,$tmp0,$tmp1,$ivec,$rndlast)=map("q$_",(0..7));
my ($dat2,$in2,$tmp2)=map("q$_",(10,11,9));
my ($dat,$tmp)=($dat0,$tmp0);
### q8-q15 preloaded key schedule
$code.=<<___;
.globl ${prefix}_ctr32_encrypt_blocks
.type ${prefix}_ctr32_encrypt_blocks,%function
.align 5
${prefix}_ctr32_encrypt_blocks:
___
$code.=<<___ if ($flavour =~ /64/);
stp x29,x30,[sp,#-16]!
add x29,sp,#0
___
$code.=<<___ if ($flavour !~ /64/);
mov ip,sp
stmdb sp!,{r4-r10,lr}
vstmdb sp!,{d8-d15} @ ABI specification says so
ldr r4, [ip] @ load remaining arg
___
$code.=<<___;
ldr $rounds,[$key,#240]
ldr $ctr, [$ivp, #12]
vld1.32 {$dat0},[$ivp]
vld1.32 {q8-q9},[$key] // load key schedule...
sub $rounds,$rounds,#4
mov $step,#16
cmp $len,#2
add $key_,$key,x5,lsl#4 // pointer to last 5 round keys
sub $rounds,$rounds,#2
vld1.32 {q12-q13},[$key_],#32
vld1.32 {q14-q15},[$key_],#32
vld1.32 {$rndlast},[$key_]
add $key_,$key,#32
mov $cnt,$rounds
cclr $step,lo
#ifndef __ARMEB__
rev $ctr, $ctr
#endif
vorr $dat1,$dat0,$dat0
add $tctr1, $ctr, #1
vorr $dat2,$dat0,$dat0
add $ctr, $ctr, #2
vorr $ivec,$dat0,$dat0
rev $tctr1, $tctr1
vmov.32 ${dat1}[3],$tctr1
b.ls .Lctr32_tail
rev $tctr2, $ctr
sub $len,$len,#3 // bias
vmov.32 ${dat2}[3],$tctr2
b .Loop3x_ctr32
.align 4
.Loop3x_ctr32:
aese $dat0,q8
aese $dat1,q8
aese $dat2,q8
vld1.32 {q8},[$key_],#16
aesmc $dat0,$dat0
aesmc $dat1,$dat1
aesmc $dat2,$dat2
subs $cnt,$cnt,#2
aese $dat0,q9
aese $dat1,q9
aese $dat2,q9
vld1.32 {q9},[$key_],#16
aesmc $dat0,$dat0
aesmc $dat1,$dat1
aesmc $dat2,$dat2
b.gt .Loop3x_ctr32
aese $dat0,q8
aese $dat1,q8
aese $dat2,q8
mov $key_,$key
aesmc $tmp0,$dat0
vld1.8 {$in0},[$inp],#16
aesmc $tmp1,$dat1
aesmc $dat2,$dat2
vorr $dat0,$ivec,$ivec
aese $tmp0,q9
vld1.8 {$in1},[$inp],#16
aese $tmp1,q9
aese $dat2,q9
vorr $dat1,$ivec,$ivec
aesmc $tmp0,$tmp0
vld1.8 {$in2},[$inp],#16
aesmc $tmp1,$tmp1
aesmc $tmp2,$dat2
vorr $dat2,$ivec,$ivec
add $tctr0,$ctr,#1
aese $tmp0,q12
aese $tmp1,q12
aese $tmp2,q12
veor $in0,$in0,$rndlast
add $tctr1,$ctr,#2
aesmc $tmp0,$tmp0
aesmc $tmp1,$tmp1
aesmc $tmp2,$tmp2
veor $in1,$in1,$rndlast
add $ctr,$ctr,#3
aese $tmp0,q13
aese $tmp1,q13
aese $tmp2,q13
veor $in2,$in2,$rndlast
rev $tctr0,$tctr0
aesmc $tmp0,$tmp0
vld1.32 {q8},[$key_],#16 // re-pre-load rndkey[0]
aesmc $tmp1,$tmp1
aesmc $tmp2,$tmp2
vmov.32 ${dat0}[3], $tctr0
rev $tctr1,$tctr1
aese $tmp0,q14
aese $tmp1,q14
aese $tmp2,q14
vmov.32 ${dat1}[3], $tctr1
rev $tctr2,$ctr
aesmc $tmp0,$tmp0
aesmc $tmp1,$tmp1
aesmc $tmp2,$tmp2
vmov.32 ${dat2}[3], $tctr2
subs $len,$len,#3
aese $tmp0,q15
aese $tmp1,q15
aese $tmp2,q15
mov $cnt,$rounds
veor $in0,$in0,$tmp0
veor $in1,$in1,$tmp1
veor $in2,$in2,$tmp2
vld1.32 {q9},[$key_],#16 // re-pre-load rndkey[1]
vst1.8 {$in0},[$out],#16
vst1.8 {$in1},[$out],#16
vst1.8 {$in2},[$out],#16
b.hs .Loop3x_ctr32
adds $len,$len,#3
b.eq .Lctr32_done
cmp $len,#1
mov $step,#16
cclr $step,eq
.Lctr32_tail:
aese $dat0,q8
aese $dat1,q8
vld1.32 {q8},[$key_],#16
aesmc $dat0,$dat0
aesmc $dat1,$dat1
subs $cnt,$cnt,#2
aese $dat0,q9
aese $dat1,q9
vld1.32 {q9},[$key_],#16
aesmc $dat0,$dat0
aesmc $dat1,$dat1
b.gt .Lctr32_tail
aese $dat0,q8
aese $dat1,q8
aesmc $dat0,$dat0
aesmc $dat1,$dat1
aese $dat0,q9
aese $dat1,q9
aesmc $dat0,$dat0
aesmc $dat1,$dat1
vld1.8 {$in0},[$inp],$step
aese $dat0,q12
aese $dat1,q12
vld1.8 {$in1},[$inp]
aesmc $dat0,$dat0
aesmc $dat1,$dat1
aese $dat0,q13
aese $dat1,q13
aesmc $dat0,$dat0
aesmc $dat1,$dat1
aese $dat0,q14
aese $dat1,q14
veor $in0,$in0,$rndlast
aesmc $dat0,$dat0
aesmc $dat1,$dat1
veor $in1,$in1,$rndlast
aese $dat0,q15
aese $dat1,q15
cmp $len,#1
veor $in0,$in0,$dat0
veor $in1,$in1,$dat1
vst1.8 {$in0},[$out],#16
b.eq .Lctr32_done
vst1.8 {$in1},[$out]
.Lctr32_done:
___
$code.=<<___ if ($flavour !~ /64/);
vldmia sp!,{d8-d15}
ldmia sp!,{r4-r10,pc}
___
$code.=<<___ if ($flavour =~ /64/);
ldr x29,[sp],#16
ret
___
$code.=<<___;
.size ${prefix}_ctr32_encrypt_blocks,.-${prefix}_ctr32_encrypt_blocks
___
}}}
$code.=<<___;
#endif
___
########################################
if ($flavour =~ /64/) { ######## 64-bit code
my %opcode = (
"aesd" => 0x4e285800, "aese" => 0x4e284800,
"aesimc"=> 0x4e287800, "aesmc" => 0x4e286800 );
local *unaes = sub {
my ($mnemonic,$arg)=@_;
$arg =~ m/[qv]([0-9]+)[^,]*,\s*[qv]([0-9]+)/o &&
sprintf ".inst\t0x%08x\t//%s %s",
$opcode{$mnemonic}|$1|($2<<5),
$mnemonic,$arg;
};
foreach(split("\n",$code)) {
s/\`([^\`]*)\`/eval($1)/geo;
s/\bq([0-9]+)\b/"v".($1<8?$1:$1+8).".16b"/geo; # old->new registers
s/@\s/\/\//o; # old->new style commentary
#s/[v]?(aes\w+)\s+([qv].*)/unaes($1,$2)/geo or
s/cclr\s+([wx])([^,]+),\s*([a-z]+)/csel $1$2,$1zr,$1$2,$3/o or
s/mov\.([a-z]+)\s+([wx][0-9]+),\s*([wx][0-9]+)/csel $2,$3,$2,$1/o or
s/vmov\.i8/movi/o or # fix up legacy mnemonics
s/vext\.8/ext/o or
s/vrev32\.8/rev32/o or
s/vtst\.8/cmtst/o or
s/vshr/ushr/o or
s/^(\s+)v/$1/o or # strip off v prefix
s/\bbx\s+lr\b/ret/o;
# fix up remainig legacy suffixes
s/\.[ui]?8//o;
m/\],#8/o and s/\.16b/\.8b/go;
s/\.[ui]?32//o and s/\.16b/\.4s/go;
s/\.[ui]?64//o and s/\.16b/\.2d/go;
s/\.[42]([sd])\[([0-3])\]/\.$1\[$2\]/o;
print $_,"\n";
}
} else { ######## 32-bit code
my %opcode = (
"aesd" => 0xf3b00340, "aese" => 0xf3b00300,
"aesimc"=> 0xf3b003c0, "aesmc" => 0xf3b00380 );
local *unaes = sub {
my ($mnemonic,$arg)=@_;
if ($arg =~ m/[qv]([0-9]+)[^,]*,\s*[qv]([0-9]+)/o) {
my $word = $opcode{$mnemonic}|(($1&7)<<13)|(($1&8)<<19)
|(($2&7)<<1) |(($2&8)<<2);
# since ARMv7 instructions are always encoded little-endian.
# correct solution is to use .inst directive, but older
# assemblers don't implement it:-(
sprintf ".byte\t0x%02x,0x%02x,0x%02x,0x%02x\t@ %s %s",
$word&0xff,($word>>8)&0xff,
($word>>16)&0xff,($word>>24)&0xff,
$mnemonic,$arg;
}
};
sub unvtbl {
my $arg=shift;
$arg =~ m/q([0-9]+),\s*\{q([0-9]+)\},\s*q([0-9]+)/o &&
sprintf "vtbl.8 d%d,{q%d},d%d\n\t".
"vtbl.8 d%d,{q%d},d%d", 2*$1,$2,2*$3, 2*$1+1,$2,2*$3+1;
}
sub unvdup32 {
my $arg=shift;
$arg =~ m/q([0-9]+),\s*q([0-9]+)\[([0-3])\]/o &&
sprintf "vdup.32 q%d,d%d[%d]",$1,2*$2+($3>>1),$3&1;
}
sub unvmov32 {
my $arg=shift;
$arg =~ m/q([0-9]+)\[([0-3])\],(.*)/o &&
sprintf "vmov.32 d%d[%d],%s",2*$1+($2>>1),$2&1,$3;
}
foreach(split("\n",$code)) {
s/\`([^\`]*)\`/eval($1)/geo;
s/\b[wx]([0-9]+)\b/r$1/go; # new->old registers
s/\bv([0-9])\.[12468]+[bsd]\b/q$1/go; # new->old registers
s/\/\/\s?/@ /o; # new->old style commentary
# fix up remainig new-style suffixes
s/\{q([0-9]+)\},\s*\[(.+)\],#8/sprintf "{d%d},[$2]!",2*$1/eo or
s/\],#[0-9]+/]!/o;
s/[v]?(aes\w+)\s+([qv].*)/unaes($1,$2)/geo or
s/cclr\s+([^,]+),\s*([a-z]+)/mov$2 $1,#0/o or
s/vtbl\.8\s+(.*)/unvtbl($1)/geo or
s/vdup\.32\s+(.*)/unvdup32($1)/geo or
s/vmov\.32\s+(.*)/unvmov32($1)/geo or
s/^(\s+)b\./$1b/o or
s/^(\s+)mov\./$1mov/o or
s/^(\s+)ret/$1bx\tlr/o;
print $_,"\n";
}
}
close STDOUT;

File diff suppressed because it is too large Load Diff

View File

@ -38,8 +38,9 @@
# Emilia's this(*) difference # Emilia's this(*) difference
# #
# Core 2 9.30 8.69 +7% # Core 2 9.30 8.69 +7%
# Nehalem(**) 7.63 6.98 +9% # Nehalem(**) 7.63 6.88 +11%
# Atom 17.1 17.4 -2%(***) # Atom 17.1 16.4 +4%
# Silvermont - 12.9
# #
# (*) Comparison is not completely fair, because "this" is ECB, # (*) Comparison is not completely fair, because "this" is ECB,
# i.e. no extra processing such as counter values calculation # i.e. no extra processing such as counter values calculation
@ -50,14 +51,6 @@
# (**) Results were collected on Westmere, which is considered to # (**) Results were collected on Westmere, which is considered to
# be equivalent to Nehalem for this code. # be equivalent to Nehalem for this code.
# #
# (***) Slowdown on Atom is rather strange per se, because original
# implementation has a number of 9+-bytes instructions, which
# are bad for Atom front-end, and which I eliminated completely.
# In attempt to address deterioration sbox() was tested in FP
# SIMD "domain" (movaps instead of movdqa, xorps instead of
# pxor, etc.). While it resulted in nominal 4% improvement on
# Atom, it hurted Westmere by more than 2x factor.
#
# As for key schedule conversion subroutine. Interface to OpenSSL # As for key schedule conversion subroutine. Interface to OpenSSL
# relies on per-invocation on-the-fly conversion. This naturally # relies on per-invocation on-the-fly conversion. This naturally
# has impact on performance, especially for short inputs. Conversion # has impact on performance, especially for short inputs. Conversion
@ -67,7 +60,7 @@
# conversion conversion/8x block # conversion conversion/8x block
# Core 2 240 0.22 # Core 2 240 0.22
# Nehalem 180 0.20 # Nehalem 180 0.20
# Atom 430 0.19 # Atom 430 0.20
# #
# The ratio values mean that 128-byte blocks will be processed # The ratio values mean that 128-byte blocks will be processed
# 16-18% slower, 256-byte blocks - 9-10%, 384-byte blocks - 6-7%, # 16-18% slower, 256-byte blocks - 9-10%, 384-byte blocks - 6-7%,
@ -83,9 +76,10 @@
# Add decryption procedure. Performance in CPU cycles spent to decrypt # Add decryption procedure. Performance in CPU cycles spent to decrypt
# one byte out of 4096-byte buffer with 128-bit key is: # one byte out of 4096-byte buffer with 128-bit key is:
# #
# Core 2 11.0 # Core 2 9.98
# Nehalem 9.16 # Nehalem 7.80
# Atom 20.9 # Atom 17.9
# Silvermont 14.0
# #
# November 2011. # November 2011.
# #
@ -105,7 +99,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or ( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
die "can't locate x86_64-xlate.pl"; die "can't locate x86_64-xlate.pl";
open STDOUT,"| $^X $xlate $flavour $output"; open OUT,"| \"$^X\" $xlate $flavour $output";
*STDOUT=*OUT;
my ($inp,$out,$len,$key,$ivp)=("%rdi","%rsi","%rdx","%rcx"); my ($inp,$out,$len,$key,$ivp)=("%rdi","%rsi","%rdx","%rcx");
my @XMM=map("%xmm$_",(15,0..14)); # best on Atom, +10% over (0..15) my @XMM=map("%xmm$_",(15,0..14)); # best on Atom, +10% over (0..15)
@ -433,21 +428,21 @@ my $mask=pop;
$code.=<<___; $code.=<<___;
pxor 0x00($key),@x[0] pxor 0x00($key),@x[0]
pxor 0x10($key),@x[1] pxor 0x10($key),@x[1]
pshufb $mask,@x[0]
pxor 0x20($key),@x[2] pxor 0x20($key),@x[2]
pshufb $mask,@x[1]
pxor 0x30($key),@x[3] pxor 0x30($key),@x[3]
pshufb $mask,@x[2] pshufb $mask,@x[0]
pshufb $mask,@x[1]
pxor 0x40($key),@x[4] pxor 0x40($key),@x[4]
pshufb $mask,@x[3]
pxor 0x50($key),@x[5] pxor 0x50($key),@x[5]
pshufb $mask,@x[4] pshufb $mask,@x[2]
pshufb $mask,@x[3]
pxor 0x60($key),@x[6] pxor 0x60($key),@x[6]
pshufb $mask,@x[5]
pxor 0x70($key),@x[7] pxor 0x70($key),@x[7]
pshufb $mask,@x[4]
pshufb $mask,@x[5]
pshufb $mask,@x[6] pshufb $mask,@x[6]
lea 0x80($key),$key
pshufb $mask,@x[7] pshufb $mask,@x[7]
lea 0x80($key),$key
___ ___
} }
@ -455,6 +450,7 @@ sub MixColumns {
# modified to emit output in order suitable for feeding back to aesenc[last] # modified to emit output in order suitable for feeding back to aesenc[last]
my @x=@_[0..7]; my @x=@_[0..7];
my @t=@_[8..15]; my @t=@_[8..15];
my $inv=@_[16]; # optional
$code.=<<___; $code.=<<___;
pshufd \$0x93, @x[0], @t[0] # x0 <<< 32 pshufd \$0x93, @x[0], @t[0] # x0 <<< 32
pshufd \$0x93, @x[1], @t[1] pshufd \$0x93, @x[1], @t[1]
@ -496,7 +492,8 @@ $code.=<<___;
pxor @t[4], @t[0] pxor @t[4], @t[0]
pshufd \$0x4E, @x[2], @x[6] pshufd \$0x4E, @x[2], @x[6]
pxor @t[5], @t[1] pxor @t[5], @t[1]
___
$code.=<<___ if (!$inv);
pxor @t[3], @x[4] pxor @t[3], @x[4]
pxor @t[7], @x[5] pxor @t[7], @x[5]
pxor @t[6], @x[3] pxor @t[6], @x[3]
@ -504,9 +501,20 @@ $code.=<<___;
pxor @t[2], @x[6] pxor @t[2], @x[6]
movdqa @t[1], @x[7] movdqa @t[1], @x[7]
___ ___
$code.=<<___ if ($inv);
pxor @x[4], @t[3]
pxor @t[7], @x[5]
pxor @x[3], @t[6]
movdqa @t[0], @x[3]
pxor @t[2], @x[6]
movdqa @t[6], @x[2]
movdqa @t[1], @x[7]
movdqa @x[6], @x[4]
movdqa @t[3], @x[6]
___
} }
sub InvMixColumns { sub InvMixColumns_orig {
my @x=@_[0..7]; my @x=@_[0..7];
my @t=@_[8..15]; my @t=@_[8..15];
@ -660,6 +668,54 @@ $code.=<<___;
___ ___
} }
sub InvMixColumns {
my @x=@_[0..7];
my @t=@_[8..15];
# Thanks to Jussi Kivilinna for providing pointer to
#
# | 0e 0b 0d 09 | | 02 03 01 01 | | 05 00 04 00 |
# | 09 0e 0b 0d | = | 01 02 03 01 | x | 00 05 00 04 |
# | 0d 09 0e 0b | | 01 01 02 03 | | 04 00 05 00 |
# | 0b 0d 09 0e | | 03 01 01 02 | | 00 04 00 05 |
$code.=<<___;
# multiplication by 0x05-0x00-0x04-0x00
pshufd \$0x4E, @x[0], @t[0]
pshufd \$0x4E, @x[6], @t[6]
pxor @x[0], @t[0]
pshufd \$0x4E, @x[7], @t[7]
pxor @x[6], @t[6]
pshufd \$0x4E, @x[1], @t[1]
pxor @x[7], @t[7]
pshufd \$0x4E, @x[2], @t[2]
pxor @x[1], @t[1]
pshufd \$0x4E, @x[3], @t[3]
pxor @x[2], @t[2]
pxor @t[6], @x[0]
pxor @t[6], @x[1]
pshufd \$0x4E, @x[4], @t[4]
pxor @x[3], @t[3]
pxor @t[0], @x[2]
pxor @t[1], @x[3]
pshufd \$0x4E, @x[5], @t[5]
pxor @x[4], @t[4]
pxor @t[7], @x[1]
pxor @t[2], @x[4]
pxor @x[5], @t[5]
pxor @t[7], @x[2]
pxor @t[6], @x[3]
pxor @t[6], @x[4]
pxor @t[3], @x[5]
pxor @t[4], @x[6]
pxor @t[7], @x[4]
pxor @t[7], @x[5]
pxor @t[5], @x[7]
___
&MixColumns (@x,@t,1); # flipped 2<->3 and 4<->6
}
sub aesenc { # not used sub aesenc { # not used
my @b=@_[0..7]; my @b=@_[0..7];
my @t=@_[8..15]; my @t=@_[8..15];
@ -758,18 +814,18 @@ _bsaes_encrypt8:
movdqa 0x50($const), @XMM[8] # .LM0SR movdqa 0x50($const), @XMM[8] # .LM0SR
pxor @XMM[9], @XMM[0] # xor with round0 key pxor @XMM[9], @XMM[0] # xor with round0 key
pxor @XMM[9], @XMM[1] pxor @XMM[9], @XMM[1]
pshufb @XMM[8], @XMM[0]
pxor @XMM[9], @XMM[2] pxor @XMM[9], @XMM[2]
pshufb @XMM[8], @XMM[1]
pxor @XMM[9], @XMM[3] pxor @XMM[9], @XMM[3]
pshufb @XMM[8], @XMM[2] pshufb @XMM[8], @XMM[0]
pshufb @XMM[8], @XMM[1]
pxor @XMM[9], @XMM[4] pxor @XMM[9], @XMM[4]
pshufb @XMM[8], @XMM[3]
pxor @XMM[9], @XMM[5] pxor @XMM[9], @XMM[5]
pshufb @XMM[8], @XMM[4] pshufb @XMM[8], @XMM[2]
pshufb @XMM[8], @XMM[3]
pxor @XMM[9], @XMM[6] pxor @XMM[9], @XMM[6]
pshufb @XMM[8], @XMM[5]
pxor @XMM[9], @XMM[7] pxor @XMM[9], @XMM[7]
pshufb @XMM[8], @XMM[4]
pshufb @XMM[8], @XMM[5]
pshufb @XMM[8], @XMM[6] pshufb @XMM[8], @XMM[6]
pshufb @XMM[8], @XMM[7] pshufb @XMM[8], @XMM[7]
_bsaes_encrypt8_bitslice: _bsaes_encrypt8_bitslice:
@ -822,18 +878,18 @@ _bsaes_decrypt8:
movdqa -0x30($const), @XMM[8] # .LM0ISR movdqa -0x30($const), @XMM[8] # .LM0ISR
pxor @XMM[9], @XMM[0] # xor with round0 key pxor @XMM[9], @XMM[0] # xor with round0 key
pxor @XMM[9], @XMM[1] pxor @XMM[9], @XMM[1]
pshufb @XMM[8], @XMM[0]
pxor @XMM[9], @XMM[2] pxor @XMM[9], @XMM[2]
pshufb @XMM[8], @XMM[1]
pxor @XMM[9], @XMM[3] pxor @XMM[9], @XMM[3]
pshufb @XMM[8], @XMM[2] pshufb @XMM[8], @XMM[0]
pshufb @XMM[8], @XMM[1]
pxor @XMM[9], @XMM[4] pxor @XMM[9], @XMM[4]
pshufb @XMM[8], @XMM[3]
pxor @XMM[9], @XMM[5] pxor @XMM[9], @XMM[5]
pshufb @XMM[8], @XMM[4] pshufb @XMM[8], @XMM[2]
pshufb @XMM[8], @XMM[3]
pxor @XMM[9], @XMM[6] pxor @XMM[9], @XMM[6]
pshufb @XMM[8], @XMM[5]
pxor @XMM[9], @XMM[7] pxor @XMM[9], @XMM[7]
pshufb @XMM[8], @XMM[4]
pshufb @XMM[8], @XMM[5]
pshufb @XMM[8], @XMM[6] pshufb @XMM[8], @XMM[6]
pshufb @XMM[8], @XMM[7] pshufb @XMM[8], @XMM[7]
___ ___
@ -1875,21 +1931,21 @@ $code.=<<___;
movdqa -0x10(%r11), @XMM[8] # .LSWPUPM0SR movdqa -0x10(%r11), @XMM[8] # .LSWPUPM0SR
pxor @XMM[9], @XMM[0] # xor with round0 key pxor @XMM[9], @XMM[0] # xor with round0 key
pxor @XMM[9], @XMM[1] pxor @XMM[9], @XMM[1]
pshufb @XMM[8], @XMM[0]
pxor @XMM[9], @XMM[2] pxor @XMM[9], @XMM[2]
pshufb @XMM[8], @XMM[1]
pxor @XMM[9], @XMM[3] pxor @XMM[9], @XMM[3]
pshufb @XMM[8], @XMM[2] pshufb @XMM[8], @XMM[0]
pshufb @XMM[8], @XMM[1]
pxor @XMM[9], @XMM[4] pxor @XMM[9], @XMM[4]
pshufb @XMM[8], @XMM[3]
pxor @XMM[9], @XMM[5] pxor @XMM[9], @XMM[5]
pshufb @XMM[8], @XMM[4] pshufb @XMM[8], @XMM[2]
pshufb @XMM[8], @XMM[3]
pxor @XMM[9], @XMM[6] pxor @XMM[9], @XMM[6]
pshufb @XMM[8], @XMM[5]
pxor @XMM[9], @XMM[7] pxor @XMM[9], @XMM[7]
pshufb @XMM[8], @XMM[4]
pshufb @XMM[8], @XMM[5]
pshufb @XMM[8], @XMM[6] pshufb @XMM[8], @XMM[6]
lea .LBS0(%rip), %r11 # constants table
pshufb @XMM[8], @XMM[7] pshufb @XMM[8], @XMM[7]
lea .LBS0(%rip), %r11 # constants table
mov %ebx,%r10d # pass rounds mov %ebx,%r10d # pass rounds
call _bsaes_encrypt8_bitslice call _bsaes_encrypt8_bitslice
@ -2027,6 +2083,8 @@ ___
# const unsigned char iv[16]); # const unsigned char iv[16]);
# #
my ($twmask,$twres,$twtmp)=@XMM[13..15]; my ($twmask,$twres,$twtmp)=@XMM[13..15];
$arg6=~s/d$//;
$code.=<<___; $code.=<<___;
.globl bsaes_xts_encrypt .globl bsaes_xts_encrypt
.type bsaes_xts_encrypt,\@abi-omnipotent .type bsaes_xts_encrypt,\@abi-omnipotent

1512
crypto/aes/asm/vpaes-ppc.pl Normal file

File diff suppressed because it is too large Load Diff

View File

@ -27,9 +27,10 @@
# #
# aes-586.pl vpaes-x86.pl # aes-586.pl vpaes-x86.pl
# #
# Core 2(**) 29.1/42.3/18.3 22.0/25.6(***) # Core 2(**) 28.1/41.4/18.3 21.9/25.2(***)
# Nehalem 27.9/40.4/18.1 10.3/12.0 # Nehalem 27.9/40.4/18.1 10.2/11.9
# Atom 102./119./60.1 64.5/85.3(***) # Atom 70.7/92.1/60.1 61.1/75.4(***)
# Silvermont 45.4/62.9/24.1 49.2/61.1(***)
# #
# (*) "Hyper-threading" in the context refers rather to cache shared # (*) "Hyper-threading" in the context refers rather to cache shared
# among multiple cores, than to specifically Intel HTT. As vast # among multiple cores, than to specifically Intel HTT. As vast
@ -40,8 +41,8 @@
# (**) "Core 2" refers to initial 65nm design, a.k.a. Conroe. # (**) "Core 2" refers to initial 65nm design, a.k.a. Conroe.
# #
# (***) Less impressive improvement on Core 2 and Atom is due to slow # (***) Less impressive improvement on Core 2 and Atom is due to slow
# pshufb, yet it's respectable +32%/65% improvement on Core 2 # pshufb, yet it's respectable +28%/64% improvement on Core 2
# and +58%/40% on Atom (as implied, over "hyper-threading-safe" # and +15% on Atom (as implied, over "hyper-threading-safe"
# code path). # code path).
# #
# <appro@openssl.org> # <appro@openssl.org>
@ -183,35 +184,35 @@ $k_dsbo=0x2c0; # decryption sbox final output
&movdqa ("xmm1","xmm6") &movdqa ("xmm1","xmm6")
&movdqa ("xmm2",&QWP($k_ipt,$const)); &movdqa ("xmm2",&QWP($k_ipt,$const));
&pandn ("xmm1","xmm0"); &pandn ("xmm1","xmm0");
&movdqu ("xmm5",&QWP(0,$key));
&psrld ("xmm1",4);
&pand ("xmm0","xmm6"); &pand ("xmm0","xmm6");
&movdqu ("xmm5",&QWP(0,$key));
&pshufb ("xmm2","xmm0"); &pshufb ("xmm2","xmm0");
&movdqa ("xmm0",&QWP($k_ipt+16,$const)); &movdqa ("xmm0",&QWP($k_ipt+16,$const));
&pshufb ("xmm0","xmm1");
&pxor ("xmm2","xmm5"); &pxor ("xmm2","xmm5");
&pxor ("xmm0","xmm2"); &psrld ("xmm1",4);
&add ($key,16); &add ($key,16);
&pshufb ("xmm0","xmm1");
&lea ($base,&DWP($k_mc_backward,$const)); &lea ($base,&DWP($k_mc_backward,$const));
&pxor ("xmm0","xmm2");
&jmp (&label("enc_entry")); &jmp (&label("enc_entry"));
&set_label("enc_loop",16); &set_label("enc_loop",16);
# middle of middle round # middle of middle round
&movdqa ("xmm4",&QWP($k_sb1,$const)); # 4 : sb1u &movdqa ("xmm4",&QWP($k_sb1,$const)); # 4 : sb1u
&pshufb ("xmm4","xmm2"); # 4 = sb1u
&pxor ("xmm4","xmm5"); # 4 = sb1u + k
&movdqa ("xmm0",&QWP($k_sb1+16,$const));# 0 : sb1t &movdqa ("xmm0",&QWP($k_sb1+16,$const));# 0 : sb1t
&pshufb ("xmm4","xmm2"); # 4 = sb1u
&pshufb ("xmm0","xmm3"); # 0 = sb1t &pshufb ("xmm0","xmm3"); # 0 = sb1t
&pxor ("xmm0","xmm4"); # 0 = A &pxor ("xmm4","xmm5"); # 4 = sb1u + k
&movdqa ("xmm5",&QWP($k_sb2,$const)); # 4 : sb2u &movdqa ("xmm5",&QWP($k_sb2,$const)); # 4 : sb2u
&pshufb ("xmm5","xmm2"); # 4 = sb2u &pxor ("xmm0","xmm4"); # 0 = A
&movdqa ("xmm1",&QWP(-0x40,$base,$magic));# .Lk_mc_forward[] &movdqa ("xmm1",&QWP(-0x40,$base,$magic));# .Lk_mc_forward[]
&pshufb ("xmm5","xmm2"); # 4 = sb2u
&movdqa ("xmm2",&QWP($k_sb2+16,$const));# 2 : sb2t &movdqa ("xmm2",&QWP($k_sb2+16,$const));# 2 : sb2t
&pshufb ("xmm2","xmm3"); # 2 = sb2t
&pxor ("xmm2","xmm5"); # 2 = 2A
&movdqa ("xmm4",&QWP(0,$base,$magic)); # .Lk_mc_backward[] &movdqa ("xmm4",&QWP(0,$base,$magic)); # .Lk_mc_backward[]
&pshufb ("xmm2","xmm3"); # 2 = sb2t
&movdqa ("xmm3","xmm0"); # 3 = A &movdqa ("xmm3","xmm0"); # 3 = A
&pxor ("xmm2","xmm5"); # 2 = 2A
&pshufb ("xmm0","xmm1"); # 0 = B &pshufb ("xmm0","xmm1"); # 0 = B
&add ($key,16); # next key &add ($key,16); # next key
&pxor ("xmm0","xmm2"); # 0 = 2A+B &pxor ("xmm0","xmm2"); # 0 = 2A+B
@ -220,30 +221,30 @@ $k_dsbo=0x2c0; # decryption sbox final output
&pxor ("xmm3","xmm0"); # 3 = 2A+B+D &pxor ("xmm3","xmm0"); # 3 = 2A+B+D
&pshufb ("xmm0","xmm1"); # 0 = 2B+C &pshufb ("xmm0","xmm1"); # 0 = 2B+C
&and ($magic,0x30); # ... mod 4 &and ($magic,0x30); # ... mod 4
&pxor ("xmm0","xmm3"); # 0 = 2A+3B+C+D
&sub ($round,1); # nr-- &sub ($round,1); # nr--
&pxor ("xmm0","xmm3"); # 0 = 2A+3B+C+D
&set_label("enc_entry"); &set_label("enc_entry");
# top of round # top of round
&movdqa ("xmm1","xmm6"); # 1 : i &movdqa ("xmm1","xmm6"); # 1 : i
&movdqa ("xmm5",&QWP($k_inv+16,$const));# 2 : a/k
&pandn ("xmm1","xmm0"); # 1 = i<<4 &pandn ("xmm1","xmm0"); # 1 = i<<4
&psrld ("xmm1",4); # 1 = i &psrld ("xmm1",4); # 1 = i
&pand ("xmm0","xmm6"); # 0 = k &pand ("xmm0","xmm6"); # 0 = k
&movdqa ("xmm5",&QWP($k_inv+16,$const));# 2 : a/k
&pshufb ("xmm5","xmm0"); # 2 = a/k &pshufb ("xmm5","xmm0"); # 2 = a/k
&pxor ("xmm0","xmm1"); # 0 = j
&movdqa ("xmm3","xmm7"); # 3 : 1/i &movdqa ("xmm3","xmm7"); # 3 : 1/i
&pxor ("xmm0","xmm1"); # 0 = j
&pshufb ("xmm3","xmm1"); # 3 = 1/i &pshufb ("xmm3","xmm1"); # 3 = 1/i
&pxor ("xmm3","xmm5"); # 3 = iak = 1/i + a/k
&movdqa ("xmm4","xmm7"); # 4 : 1/j &movdqa ("xmm4","xmm7"); # 4 : 1/j
&pxor ("xmm3","xmm5"); # 3 = iak = 1/i + a/k
&pshufb ("xmm4","xmm0"); # 4 = 1/j &pshufb ("xmm4","xmm0"); # 4 = 1/j
&pxor ("xmm4","xmm5"); # 4 = jak = 1/j + a/k
&movdqa ("xmm2","xmm7"); # 2 : 1/iak &movdqa ("xmm2","xmm7"); # 2 : 1/iak
&pxor ("xmm4","xmm5"); # 4 = jak = 1/j + a/k
&pshufb ("xmm2","xmm3"); # 2 = 1/iak &pshufb ("xmm2","xmm3"); # 2 = 1/iak
&pxor ("xmm2","xmm0"); # 2 = io
&movdqa ("xmm3","xmm7"); # 3 : 1/jak &movdqa ("xmm3","xmm7"); # 3 : 1/jak
&movdqu ("xmm5",&QWP(0,$key)); &pxor ("xmm2","xmm0"); # 2 = io
&pshufb ("xmm3","xmm4"); # 3 = 1/jak &pshufb ("xmm3","xmm4"); # 3 = 1/jak
&movdqu ("xmm5",&QWP(0,$key));
&pxor ("xmm3","xmm1"); # 3 = jo &pxor ("xmm3","xmm1"); # 3 = jo
&jnz (&label("enc_loop")); &jnz (&label("enc_loop"));
@ -265,8 +266,8 @@ $k_dsbo=0x2c0; # decryption sbox final output
## Same API as encryption core. ## Same API as encryption core.
## ##
&function_begin_B("_vpaes_decrypt_core"); &function_begin_B("_vpaes_decrypt_core");
&mov ($round,&DWP(240,$key));
&lea ($base,&DWP($k_dsbd,$const)); &lea ($base,&DWP($k_dsbd,$const));
&mov ($round,&DWP(240,$key));
&movdqa ("xmm1","xmm6"); &movdqa ("xmm1","xmm6");
&movdqa ("xmm2",&QWP($k_dipt-$k_dsbd,$base)); &movdqa ("xmm2",&QWP($k_dipt-$k_dsbd,$base));
&pandn ("xmm1","xmm0"); &pandn ("xmm1","xmm0");
@ -292,62 +293,61 @@ $k_dsbo=0x2c0; # decryption sbox final output
## Inverse mix columns ## Inverse mix columns
## ##
&movdqa ("xmm4",&QWP(-0x20,$base)); # 4 : sb9u &movdqa ("xmm4",&QWP(-0x20,$base)); # 4 : sb9u
&movdqa ("xmm1",&QWP(-0x10,$base)); # 0 : sb9t
&pshufb ("xmm4","xmm2"); # 4 = sb9u &pshufb ("xmm4","xmm2"); # 4 = sb9u
&pxor ("xmm4","xmm0"); &pshufb ("xmm1","xmm3"); # 0 = sb9t
&movdqa ("xmm0",&QWP(-0x10,$base)); # 0 : sb9t &pxor ("xmm0","xmm4");
&pshufb ("xmm0","xmm3"); # 0 = sb9t
&pxor ("xmm0","xmm4"); # 0 = ch
&add ($key,16); # next round key
&pshufb ("xmm0","xmm5"); # MC ch
&movdqa ("xmm4",&QWP(0,$base)); # 4 : sbdu &movdqa ("xmm4",&QWP(0,$base)); # 4 : sbdu
&pxor ("xmm0","xmm1"); # 0 = ch
&movdqa ("xmm1",&QWP(0x10,$base)); # 0 : sbdt
&pshufb ("xmm4","xmm2"); # 4 = sbdu &pshufb ("xmm4","xmm2"); # 4 = sbdu
&pxor ("xmm4","xmm0"); # 4 = ch
&movdqa ("xmm0",&QWP(0x10,$base)); # 0 : sbdt
&pshufb ("xmm0","xmm3"); # 0 = sbdt
&pxor ("xmm0","xmm4"); # 0 = ch
&sub ($round,1); # nr--
&pshufb ("xmm0","xmm5"); # MC ch &pshufb ("xmm0","xmm5"); # MC ch
&pshufb ("xmm1","xmm3"); # 0 = sbdt
&pxor ("xmm0","xmm4"); # 4 = ch
&movdqa ("xmm4",&QWP(0x20,$base)); # 4 : sbbu &movdqa ("xmm4",&QWP(0x20,$base)); # 4 : sbbu
&pxor ("xmm0","xmm1"); # 0 = ch
&movdqa ("xmm1",&QWP(0x30,$base)); # 0 : sbbt
&pshufb ("xmm4","xmm2"); # 4 = sbbu &pshufb ("xmm4","xmm2"); # 4 = sbbu
&pxor ("xmm4","xmm0"); # 4 = ch
&movdqa ("xmm0",&QWP(0x30,$base)); # 0 : sbbt
&pshufb ("xmm0","xmm3"); # 0 = sbbt
&pxor ("xmm0","xmm4"); # 0 = ch
&pshufb ("xmm0","xmm5"); # MC ch &pshufb ("xmm0","xmm5"); # MC ch
&pshufb ("xmm1","xmm3"); # 0 = sbbt
&pxor ("xmm0","xmm4"); # 4 = ch
&movdqa ("xmm4",&QWP(0x40,$base)); # 4 : sbeu &movdqa ("xmm4",&QWP(0x40,$base)); # 4 : sbeu
&pshufb ("xmm4","xmm2"); # 4 = sbeu &pxor ("xmm0","xmm1"); # 0 = ch
&pxor ("xmm4","xmm0"); # 4 = ch &movdqa ("xmm1",&QWP(0x50,$base)); # 0 : sbet
&movdqa ("xmm0",&QWP(0x50,$base)); # 0 : sbet
&pshufb ("xmm0","xmm3"); # 0 = sbet
&pxor ("xmm0","xmm4"); # 0 = ch
&pshufb ("xmm4","xmm2"); # 4 = sbeu
&pshufb ("xmm0","xmm5"); # MC ch
&pshufb ("xmm1","xmm3"); # 0 = sbet
&pxor ("xmm0","xmm4"); # 4 = ch
&add ($key,16); # next round key
&palignr("xmm5","xmm5",12); &palignr("xmm5","xmm5",12);
&pxor ("xmm0","xmm1"); # 0 = ch
&sub ($round,1); # nr--
&set_label("dec_entry"); &set_label("dec_entry");
# top of round # top of round
&movdqa ("xmm1","xmm6"); # 1 : i &movdqa ("xmm1","xmm6"); # 1 : i
&pandn ("xmm1","xmm0"); # 1 = i<<4
&psrld ("xmm1",4); # 1 = i
&pand ("xmm0","xmm6"); # 0 = k
&movdqa ("xmm2",&QWP($k_inv+16,$const));# 2 : a/k &movdqa ("xmm2",&QWP($k_inv+16,$const));# 2 : a/k
&pandn ("xmm1","xmm0"); # 1 = i<<4
&pand ("xmm0","xmm6"); # 0 = k
&psrld ("xmm1",4); # 1 = i
&pshufb ("xmm2","xmm0"); # 2 = a/k &pshufb ("xmm2","xmm0"); # 2 = a/k
&pxor ("xmm0","xmm1"); # 0 = j
&movdqa ("xmm3","xmm7"); # 3 : 1/i &movdqa ("xmm3","xmm7"); # 3 : 1/i
&pxor ("xmm0","xmm1"); # 0 = j
&pshufb ("xmm3","xmm1"); # 3 = 1/i &pshufb ("xmm3","xmm1"); # 3 = 1/i
&pxor ("xmm3","xmm2"); # 3 = iak = 1/i + a/k
&movdqa ("xmm4","xmm7"); # 4 : 1/j &movdqa ("xmm4","xmm7"); # 4 : 1/j
&pxor ("xmm3","xmm2"); # 3 = iak = 1/i + a/k
&pshufb ("xmm4","xmm0"); # 4 = 1/j &pshufb ("xmm4","xmm0"); # 4 = 1/j
&pxor ("xmm4","xmm2"); # 4 = jak = 1/j + a/k &pxor ("xmm4","xmm2"); # 4 = jak = 1/j + a/k
&movdqa ("xmm2","xmm7"); # 2 : 1/iak &movdqa ("xmm2","xmm7"); # 2 : 1/iak
&pshufb ("xmm2","xmm3"); # 2 = 1/iak &pshufb ("xmm2","xmm3"); # 2 = 1/iak
&pxor ("xmm2","xmm0"); # 2 = io
&movdqa ("xmm3","xmm7"); # 3 : 1/jak &movdqa ("xmm3","xmm7"); # 3 : 1/jak
&pxor ("xmm2","xmm0"); # 2 = io
&pshufb ("xmm3","xmm4"); # 3 = 1/jak &pshufb ("xmm3","xmm4"); # 3 = 1/jak
&pxor ("xmm3","xmm1"); # 3 = jo
&movdqu ("xmm0",&QWP(0,$key)); &movdqu ("xmm0",&QWP(0,$key));
&pxor ("xmm3","xmm1"); # 3 = jo
&jnz (&label("dec_loop")); &jnz (&label("dec_loop"));
# middle of last round # middle of last round
@ -542,12 +542,12 @@ $k_dsbo=0x2c0; # decryption sbox final output
## %xmm0: b+c+d b+c b a ## %xmm0: b+c+d b+c b a
## ##
&function_begin_B("_vpaes_schedule_192_smear"); &function_begin_B("_vpaes_schedule_192_smear");
&pshufd ("xmm0","xmm6",0x80); # d c 0 0 -> c 0 0 0 &pshufd ("xmm1","xmm6",0x80); # d c 0 0 -> c 0 0 0
&pxor ("xmm6","xmm0"); # -> c+d c 0 0
&pshufd ("xmm0","xmm7",0xFE); # b a _ _ -> b b b a &pshufd ("xmm0","xmm7",0xFE); # b a _ _ -> b b b a
&pxor ("xmm6","xmm1"); # -> c+d c 0 0
&pxor ("xmm1","xmm1");
&pxor ("xmm6","xmm0"); # -> b+c+d b+c b a &pxor ("xmm6","xmm0"); # -> b+c+d b+c b a
&movdqa ("xmm0","xmm6"); &movdqa ("xmm0","xmm6");
&pxor ("xmm1","xmm1");
&movhlps("xmm6","xmm1"); # clobber low side with zeros &movhlps("xmm6","xmm1"); # clobber low side with zeros
&ret (); &ret ();
&function_end_B("_vpaes_schedule_192_smear"); &function_end_B("_vpaes_schedule_192_smear");
@ -843,6 +843,8 @@ $k_dsbo=0x2c0; # decryption sbox final output
&mov ($out,&wparam(1)); # out &mov ($out,&wparam(1)); # out
&mov ($round,&wparam(2)); # len &mov ($round,&wparam(2)); # len
&mov ($key,&wparam(3)); # key &mov ($key,&wparam(3)); # key
&sub ($round,16);
&jc (&label("cbc_abort"));
&lea ($base,&DWP(-56,"esp")); &lea ($base,&DWP(-56,"esp"));
&mov ($const,&wparam(4)); # ivp &mov ($const,&wparam(4)); # ivp
&and ($base,-16); &and ($base,-16);
@ -853,7 +855,6 @@ $k_dsbo=0x2c0; # decryption sbox final output
&mov (&DWP(48,"esp"),$base); &mov (&DWP(48,"esp"),$base);
&mov (&DWP(0,"esp"),$out); # save out &mov (&DWP(0,"esp"),$out); # save out
&sub ($round,16);
&mov (&DWP(4,"esp"),$key) # save key &mov (&DWP(4,"esp"),$key) # save key
&mov (&DWP(8,"esp"),$const); # save ivp &mov (&DWP(8,"esp"),$const); # save ivp
&mov ($out,$round); # $out works as $len &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 ($base,&DWP(8,"esp")); # restore ivp
&mov ("esp",&DWP(48,"esp")); &mov ("esp",&DWP(48,"esp"));
&movdqu (&QWP(0,$base),"xmm1"); # write IV &movdqu (&QWP(0,$base),"xmm1"); # write IV
&set_label("cbc_abort");
&function_end("${PREFIX}_cbc_encrypt"); &function_end("${PREFIX}_cbc_encrypt");
&asm_finish(); &asm_finish();

View File

@ -27,9 +27,10 @@
# #
# aes-x86_64.pl vpaes-x86_64.pl # aes-x86_64.pl vpaes-x86_64.pl
# #
# Core 2(**) 30.5/43.7/14.3 21.8/25.7(***) # Core 2(**) 29.6/41.1/14.3 21.9/25.2(***)
# Nehalem 30.5/42.2/14.6 9.8/11.8 # Nehalem 29.6/40.3/14.6 10.0/11.8
# Atom 63.9/79.0/32.1 64.0/84.8(***) # Atom 57.3/74.2/32.1 60.9/77.2(***)
# Silvermont 52.7/64.0/19.5 48.8/60.8(***)
# #
# (*) "Hyper-threading" in the context refers rather to cache shared # (*) "Hyper-threading" in the context refers rather to cache shared
# among multiple cores, than to specifically Intel HTT. As vast # among multiple cores, than to specifically Intel HTT. As vast
@ -40,7 +41,7 @@
# (**) "Core 2" refers to initial 65nm design, a.k.a. Conroe. # (**) "Core 2" refers to initial 65nm design, a.k.a. Conroe.
# #
# (***) Less impressive improvement on Core 2 and Atom is due to slow # (***) Less impressive improvement on Core 2 and Atom is due to slow
# pshufb, yet it's respectable +40%/78% improvement on Core 2 # pshufb, yet it's respectable +36%/62% improvement on Core 2
# (as implied, over "hyper-threading-safe" code path). # (as implied, over "hyper-threading-safe" code path).
# #
# <appro@openssl.org> # <appro@openssl.org>
@ -56,7 +57,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or ( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
die "can't locate x86_64-xlate.pl"; die "can't locate x86_64-xlate.pl";
open STDOUT,"| $^X $xlate $flavour $output"; open OUT,"| \"$^X\" $xlate $flavour $output";
*STDOUT=*OUT;
$PREFIX="vpaes"; $PREFIX="vpaes";
@ -94,8 +96,8 @@ _vpaes_encrypt_core:
movdqa .Lk_ipt+16(%rip), %xmm0 # ipthi movdqa .Lk_ipt+16(%rip), %xmm0 # ipthi
pshufb %xmm1, %xmm0 pshufb %xmm1, %xmm0
pxor %xmm5, %xmm2 pxor %xmm5, %xmm2
pxor %xmm2, %xmm0
add \$16, %r9 add \$16, %r9
pxor %xmm2, %xmm0
lea .Lk_mc_backward(%rip),%r10 lea .Lk_mc_backward(%rip),%r10
jmp .Lenc_entry jmp .Lenc_entry
@ -103,19 +105,19 @@ _vpaes_encrypt_core:
.Lenc_loop: .Lenc_loop:
# middle of middle round # middle of middle round
movdqa %xmm13, %xmm4 # 4 : sb1u movdqa %xmm13, %xmm4 # 4 : sb1u
pshufb %xmm2, %xmm4 # 4 = sb1u
pxor %xmm5, %xmm4 # 4 = sb1u + k
movdqa %xmm12, %xmm0 # 0 : sb1t movdqa %xmm12, %xmm0 # 0 : sb1t
pshufb %xmm2, %xmm4 # 4 = sb1u
pshufb %xmm3, %xmm0 # 0 = sb1t pshufb %xmm3, %xmm0 # 0 = sb1t
pxor %xmm4, %xmm0 # 0 = A pxor %xmm5, %xmm4 # 4 = sb1u + k
movdqa %xmm15, %xmm5 # 4 : sb2u movdqa %xmm15, %xmm5 # 4 : sb2u
pshufb %xmm2, %xmm5 # 4 = sb2u pxor %xmm4, %xmm0 # 0 = A
movdqa -0x40(%r11,%r10), %xmm1 # .Lk_mc_forward[] movdqa -0x40(%r11,%r10), %xmm1 # .Lk_mc_forward[]
pshufb %xmm2, %xmm5 # 4 = sb2u
movdqa (%r11,%r10), %xmm4 # .Lk_mc_backward[]
movdqa %xmm14, %xmm2 # 2 : sb2t movdqa %xmm14, %xmm2 # 2 : sb2t
pshufb %xmm3, %xmm2 # 2 = sb2t pshufb %xmm3, %xmm2 # 2 = sb2t
pxor %xmm5, %xmm2 # 2 = 2A
movdqa (%r11,%r10), %xmm4 # .Lk_mc_backward[]
movdqa %xmm0, %xmm3 # 3 = A movdqa %xmm0, %xmm3 # 3 = A
pxor %xmm5, %xmm2 # 2 = 2A
pshufb %xmm1, %xmm0 # 0 = B pshufb %xmm1, %xmm0 # 0 = B
add \$16, %r9 # next key add \$16, %r9 # next key
pxor %xmm2, %xmm0 # 0 = 2A+B pxor %xmm2, %xmm0 # 0 = 2A+B
@ -124,30 +126,30 @@ _vpaes_encrypt_core:
pxor %xmm0, %xmm3 # 3 = 2A+B+D pxor %xmm0, %xmm3 # 3 = 2A+B+D
pshufb %xmm1, %xmm0 # 0 = 2B+C pshufb %xmm1, %xmm0 # 0 = 2B+C
and \$0x30, %r11 # ... mod 4 and \$0x30, %r11 # ... mod 4
pxor %xmm3, %xmm0 # 0 = 2A+3B+C+D
sub \$1,%rax # nr-- sub \$1,%rax # nr--
pxor %xmm3, %xmm0 # 0 = 2A+3B+C+D
.Lenc_entry: .Lenc_entry:
# top of round # top of round
movdqa %xmm9, %xmm1 # 1 : i movdqa %xmm9, %xmm1 # 1 : i
movdqa %xmm11, %xmm5 # 2 : a/k
pandn %xmm0, %xmm1 # 1 = i<<4 pandn %xmm0, %xmm1 # 1 = i<<4
psrld \$4, %xmm1 # 1 = i psrld \$4, %xmm1 # 1 = i
pand %xmm9, %xmm0 # 0 = k pand %xmm9, %xmm0 # 0 = k
movdqa %xmm11, %xmm5 # 2 : a/k
pshufb %xmm0, %xmm5 # 2 = a/k pshufb %xmm0, %xmm5 # 2 = a/k
pxor %xmm1, %xmm0 # 0 = j
movdqa %xmm10, %xmm3 # 3 : 1/i movdqa %xmm10, %xmm3 # 3 : 1/i
pxor %xmm1, %xmm0 # 0 = j
pshufb %xmm1, %xmm3 # 3 = 1/i pshufb %xmm1, %xmm3 # 3 = 1/i
pxor %xmm5, %xmm3 # 3 = iak = 1/i + a/k
movdqa %xmm10, %xmm4 # 4 : 1/j movdqa %xmm10, %xmm4 # 4 : 1/j
pxor %xmm5, %xmm3 # 3 = iak = 1/i + a/k
pshufb %xmm0, %xmm4 # 4 = 1/j pshufb %xmm0, %xmm4 # 4 = 1/j
pxor %xmm5, %xmm4 # 4 = jak = 1/j + a/k
movdqa %xmm10, %xmm2 # 2 : 1/iak movdqa %xmm10, %xmm2 # 2 : 1/iak
pxor %xmm5, %xmm4 # 4 = jak = 1/j + a/k
pshufb %xmm3, %xmm2 # 2 = 1/iak pshufb %xmm3, %xmm2 # 2 = 1/iak
pxor %xmm0, %xmm2 # 2 = io
movdqa %xmm10, %xmm3 # 3 : 1/jak movdqa %xmm10, %xmm3 # 3 : 1/jak
movdqu (%r9), %xmm5 pxor %xmm0, %xmm2 # 2 = io
pshufb %xmm4, %xmm3 # 3 = 1/jak pshufb %xmm4, %xmm3 # 3 = 1/jak
movdqu (%r9), %xmm5
pxor %xmm1, %xmm3 # 3 = jo pxor %xmm1, %xmm3 # 3 = jo
jnz .Lenc_loop jnz .Lenc_loop
@ -200,62 +202,61 @@ _vpaes_decrypt_core:
## Inverse mix columns ## Inverse mix columns
## ##
movdqa -0x20(%r10),%xmm4 # 4 : sb9u movdqa -0x20(%r10),%xmm4 # 4 : sb9u
movdqa -0x10(%r10),%xmm1 # 0 : sb9t
pshufb %xmm2, %xmm4 # 4 = sb9u pshufb %xmm2, %xmm4 # 4 = sb9u
pxor %xmm0, %xmm4 pshufb %xmm3, %xmm1 # 0 = sb9t
movdqa -0x10(%r10),%xmm0 # 0 : sb9t pxor %xmm4, %xmm0
pshufb %xmm3, %xmm0 # 0 = sb9t
pxor %xmm4, %xmm0 # 0 = ch
add \$16, %r9 # next round key
pshufb %xmm5, %xmm0 # MC ch
movdqa 0x00(%r10),%xmm4 # 4 : sbdu movdqa 0x00(%r10),%xmm4 # 4 : sbdu
pxor %xmm1, %xmm0 # 0 = ch
movdqa 0x10(%r10),%xmm1 # 0 : sbdt
pshufb %xmm2, %xmm4 # 4 = sbdu pshufb %xmm2, %xmm4 # 4 = sbdu
pxor %xmm0, %xmm4 # 4 = ch
movdqa 0x10(%r10),%xmm0 # 0 : sbdt
pshufb %xmm3, %xmm0 # 0 = sbdt
pxor %xmm4, %xmm0 # 0 = ch
sub \$1,%rax # nr--
pshufb %xmm5, %xmm0 # MC ch pshufb %xmm5, %xmm0 # MC ch
pshufb %xmm3, %xmm1 # 0 = sbdt
pxor %xmm4, %xmm0 # 4 = ch
movdqa 0x20(%r10),%xmm4 # 4 : sbbu movdqa 0x20(%r10),%xmm4 # 4 : sbbu
pxor %xmm1, %xmm0 # 0 = ch
movdqa 0x30(%r10),%xmm1 # 0 : sbbt
pshufb %xmm2, %xmm4 # 4 = sbbu pshufb %xmm2, %xmm4 # 4 = sbbu
pxor %xmm0, %xmm4 # 4 = ch
movdqa 0x30(%r10),%xmm0 # 0 : sbbt
pshufb %xmm3, %xmm0 # 0 = sbbt
pxor %xmm4, %xmm0 # 0 = ch
pshufb %xmm5, %xmm0 # MC ch pshufb %xmm5, %xmm0 # MC ch
pshufb %xmm3, %xmm1 # 0 = sbbt
pxor %xmm4, %xmm0 # 4 = ch
movdqa 0x40(%r10),%xmm4 # 4 : sbeu movdqa 0x40(%r10),%xmm4 # 4 : sbeu
pshufb %xmm2, %xmm4 # 4 = sbeu pxor %xmm1, %xmm0 # 0 = ch
pxor %xmm0, %xmm4 # 4 = ch movdqa 0x50(%r10),%xmm1 # 0 : sbet
movdqa 0x50(%r10),%xmm0 # 0 : sbet
pshufb %xmm3, %xmm0 # 0 = sbet
pxor %xmm4, %xmm0 # 0 = ch
pshufb %xmm2, %xmm4 # 4 = sbeu
pshufb %xmm5, %xmm0 # MC ch
pshufb %xmm3, %xmm1 # 0 = sbet
pxor %xmm4, %xmm0 # 4 = ch
add \$16, %r9 # next round key
palignr \$12, %xmm5, %xmm5 palignr \$12, %xmm5, %xmm5
pxor %xmm1, %xmm0 # 0 = ch
sub \$1,%rax # nr--
.Ldec_entry: .Ldec_entry:
# top of round # top of round
movdqa %xmm9, %xmm1 # 1 : i movdqa %xmm9, %xmm1 # 1 : i
pandn %xmm0, %xmm1 # 1 = i<<4 pandn %xmm0, %xmm1 # 1 = i<<4
movdqa %xmm11, %xmm2 # 2 : a/k
psrld \$4, %xmm1 # 1 = i psrld \$4, %xmm1 # 1 = i
pand %xmm9, %xmm0 # 0 = k pand %xmm9, %xmm0 # 0 = k
movdqa %xmm11, %xmm2 # 2 : a/k
pshufb %xmm0, %xmm2 # 2 = a/k pshufb %xmm0, %xmm2 # 2 = a/k
pxor %xmm1, %xmm0 # 0 = j
movdqa %xmm10, %xmm3 # 3 : 1/i movdqa %xmm10, %xmm3 # 3 : 1/i
pxor %xmm1, %xmm0 # 0 = j
pshufb %xmm1, %xmm3 # 3 = 1/i pshufb %xmm1, %xmm3 # 3 = 1/i
pxor %xmm2, %xmm3 # 3 = iak = 1/i + a/k
movdqa %xmm10, %xmm4 # 4 : 1/j movdqa %xmm10, %xmm4 # 4 : 1/j
pxor %xmm2, %xmm3 # 3 = iak = 1/i + a/k
pshufb %xmm0, %xmm4 # 4 = 1/j pshufb %xmm0, %xmm4 # 4 = 1/j
pxor %xmm2, %xmm4 # 4 = jak = 1/j + a/k pxor %xmm2, %xmm4 # 4 = jak = 1/j + a/k
movdqa %xmm10, %xmm2 # 2 : 1/iak movdqa %xmm10, %xmm2 # 2 : 1/iak
pshufb %xmm3, %xmm2 # 2 = 1/iak pshufb %xmm3, %xmm2 # 2 = 1/iak
pxor %xmm0, %xmm2 # 2 = io
movdqa %xmm10, %xmm3 # 3 : 1/jak movdqa %xmm10, %xmm3 # 3 : 1/jak
pxor %xmm0, %xmm2 # 2 = io
pshufb %xmm4, %xmm3 # 3 = 1/jak pshufb %xmm4, %xmm3 # 3 = 1/jak
pxor %xmm1, %xmm3 # 3 = jo
movdqu (%r9), %xmm0 movdqu (%r9), %xmm0
pxor %xmm1, %xmm3 # 3 = jo
jnz .Ldec_loop jnz .Ldec_loop
# middle of last round # middle of last round
@ -263,7 +264,7 @@ _vpaes_decrypt_core:
pshufb %xmm2, %xmm4 # 4 = sbou pshufb %xmm2, %xmm4 # 4 = sbou
pxor %xmm0, %xmm4 # 4 = sb1u + k pxor %xmm0, %xmm4 # 4 = sb1u + k
movdqa 0x70(%r10), %xmm0 # 0 : sbot 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 pshufb %xmm3, %xmm0 # 0 = sb1t
pxor %xmm4, %xmm0 # 0 = A pxor %xmm4, %xmm0 # 0 = A
pshufb %xmm2, %xmm0 pshufb %xmm2, %xmm0
@ -463,12 +464,12 @@ _vpaes_schedule_core:
.type _vpaes_schedule_192_smear,\@abi-omnipotent .type _vpaes_schedule_192_smear,\@abi-omnipotent
.align 16 .align 16
_vpaes_schedule_192_smear: _vpaes_schedule_192_smear:
pshufd \$0x80, %xmm6, %xmm0 # d c 0 0 -> c 0 0 0 pshufd \$0x80, %xmm6, %xmm1 # d c 0 0 -> c 0 0 0
pxor %xmm0, %xmm6 # -> c+d c 0 0
pshufd \$0xFE, %xmm7, %xmm0 # b a _ _ -> b b b a pshufd \$0xFE, %xmm7, %xmm0 # b a _ _ -> b b b a
pxor %xmm1, %xmm6 # -> c+d c 0 0
pxor %xmm1, %xmm1
pxor %xmm0, %xmm6 # -> b+c+d b+c b a pxor %xmm0, %xmm6 # -> b+c+d b+c b a
movdqa %xmm6, %xmm0 movdqa %xmm6, %xmm0
pxor %xmm1, %xmm1
movhlps %xmm1, %xmm6 # clobber low side with zeros movhlps %xmm1, %xmm6 # clobber low side with zeros
ret ret
.size _vpaes_schedule_192_smear,.-_vpaes_schedule_192_smear .size _vpaes_schedule_192_smear,.-_vpaes_schedule_192_smear
@ -869,6 +870,8 @@ ${PREFIX}_cbc_encrypt:
___ ___
($len,$key)=($key,$len); ($len,$key)=($key,$len);
$code.=<<___; $code.=<<___;
sub \$16,$len
jc .Lcbc_abort
___ ___
$code.=<<___ if ($win64); $code.=<<___ if ($win64);
lea -0xb8(%rsp),%rsp lea -0xb8(%rsp),%rsp
@ -887,7 +890,6 @@ ___
$code.=<<___; $code.=<<___;
movdqu ($ivp),%xmm6 # load IV movdqu ($ivp),%xmm6 # load IV
sub $inp,$out sub $inp,$out
sub \$16,$len
call _vpaes_preheat call _vpaes_preheat
cmp \$0,${enc}d cmp \$0,${enc}d
je .Lcbc_dec_loop je .Lcbc_dec_loop
@ -932,6 +934,7 @@ $code.=<<___ if ($win64);
.Lcbc_epilogue: .Lcbc_epilogue:
___ ___
$code.=<<___; $code.=<<___;
.Lcbc_abort:
ret ret
.size ${PREFIX}_cbc_encrypt,.-${PREFIX}_cbc_encrypt .size ${PREFIX}_cbc_encrypt,.-${PREFIX}_cbc_encrypt
___ ___
@ -1057,7 +1060,7 @@ _vpaes_consts:
.Lk_dsbo: # decryption sbox final output .Lk_dsbo: # decryption sbox final output
.quad 0x1387EA537EF94000, 0xC7AA6DB9D4943E2D .quad 0x1387EA537EF94000, 0xC7AA6DB9D4943E2D
.quad 0x12D7560F93441D00, 0xCA4B8159D8C58E9C .quad 0x12D7560F93441D00, 0xCA4B8159D8C58E9C
.asciz "Vector Permutaion AES for x86_64/SSSE3, Mike Hamburg (Stanford University)" .asciz "Vector Permutation AES for x86_64/SSSE3, Mike Hamburg (Stanford University)"
.align 64 .align 64
.size _vpaes_consts,.-_vpaes_consts .size _vpaes_consts,.-_vpaes_consts
___ ___

46
crypto/arm64cpuid.S Normal file
View File

@ -0,0 +1,46 @@
#include "arm_arch.h"
.text
.arch armv8-a+crypto
.align 5
.global _armv7_neon_probe
.type _armv7_neon_probe,%function
_armv7_neon_probe:
orr v15.16b, v15.16b, v15.16b
ret
.size _armv7_neon_probe,.-_armv7_neon_probe
.global _armv7_tick
.type _armv7_tick,%function
_armv7_tick:
mrs x0, CNTVCT_EL0
ret
.size _armv7_tick,.-_armv7_tick
.global _armv8_aes_probe
.type _armv8_aes_probe,%function
_armv8_aes_probe:
aese v0.16b, v0.16b
ret
.size _armv8_aes_probe,.-_armv8_aes_probe
.global _armv8_sha1_probe
.type _armv8_sha1_probe,%function
_armv8_sha1_probe:
sha1h s0, s0
ret
.size _armv8_sha1_probe,.-_armv8_sha1_probe
.global _armv8_sha256_probe
.type _armv8_sha256_probe,%function
_armv8_sha256_probe:
sha256su0 v0.4s, v0.4s
ret
.size _armv8_sha256_probe,.-_armv8_sha256_probe
.global _armv8_pmull_probe
.type _armv8_pmull_probe,%function
_armv8_pmull_probe:
pmull v0.1q, v0.1d, v0.1d
ret
.size _armv8_pmull_probe,.-_armv8_pmull_probe

View File

@ -10,13 +10,24 @@
# define __ARMEL__ # define __ARMEL__
# endif # endif
# elif defined(__GNUC__) # elif defined(__GNUC__)
# if defined(__aarch64__)
# define __ARM_ARCH__ 8
# if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__
# define __ARMEB__
# else
# define __ARMEL__
# endif
/* /*
* Why doesn't gcc define __ARM_ARCH__? Instead it defines * Why doesn't gcc define __ARM_ARCH__? Instead it defines
* bunch of below macros. See all_architectires[] table in * bunch of below macros. See all_architectires[] table in
* gcc/config/arm/arm.c. On a side note it defines * gcc/config/arm/arm.c. On a side note it defines
* __ARMEL__/__ARMEB__ for little-/big-endian. * __ARMEL__/__ARMEB__ for little-/big-endian.
*/ */
# if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \ # elif defined(__ARM_ARCH)
# define __ARM_ARCH__ __ARM_ARCH
# elif defined(__ARM_ARCH_8A__)
# define __ARM_ARCH__ 8
# elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \
defined(__ARM_ARCH_7R__)|| defined(__ARM_ARCH_7M__) || \ defined(__ARM_ARCH_7R__)|| defined(__ARM_ARCH_7M__) || \
defined(__ARM_ARCH_7EM__) defined(__ARM_ARCH_7EM__)
# define __ARM_ARCH__ 7 # define __ARM_ARCH__ 7
@ -43,9 +54,13 @@
#if !__ASSEMBLER__ #if !__ASSEMBLER__
extern unsigned int OPENSSL_armcap_P; extern unsigned int OPENSSL_armcap_P;
#endif
#define ARMV7_NEON (1<<0) #define ARMV7_NEON (1<<0)
#define ARMV7_TICK (1<<1) #define ARMV7_TICK (1<<1)
#endif #define ARMV8_AES (1<<2)
#define ARMV8_SHA1 (1<<3)
#define ARMV8_SHA256 (1<<4)
#define ARMV8_PMULL (1<<5)
#endif #endif

View File

@ -19,19 +19,55 @@ static void ill_handler (int sig) { siglongjmp(ill_jmp,sig); }
* ARM compilers support inline assembler... * ARM compilers support inline assembler...
*/ */
void _armv7_neon_probe(void); void _armv7_neon_probe(void);
unsigned int _armv7_tick(void); void _armv8_aes_probe(void);
void _armv8_sha1_probe(void);
void _armv8_sha256_probe(void);
void _armv8_pmull_probe(void);
unsigned long _armv7_tick(void);
unsigned int OPENSSL_rdtsc(void) unsigned long OPENSSL_rdtsc(void)
{ {
if (OPENSSL_armcap_P|ARMV7_TICK) if (OPENSSL_armcap_P & ARMV7_TICK)
return _armv7_tick(); return _armv7_tick();
else else
return 0; return 0;
} }
/*
* Use a weak reference to getauxval() so we can use it if it is available but
* don't break the build if it is not.
*/
#if defined(__GNUC__) && __GNUC__>=2 #if defined(__GNUC__) && __GNUC__>=2
void OPENSSL_cpuid_setup(void) __attribute__((constructor)); void OPENSSL_cpuid_setup(void) __attribute__((constructor));
extern unsigned long getauxval(unsigned long type) __attribute__((weak));
#else
static unsigned long (*getauxval)(unsigned long) = NULL;
#endif #endif
/*
* ARM puts the the feature bits for Crypto Extensions in AT_HWCAP2, whereas
* AArch64 used AT_HWCAP.
*/
#if defined(__arm__) || defined (__arm)
# define HWCAP 16 /* AT_HWCAP */
# define HWCAP_NEON (1 << 12)
# define HWCAP_CE 26 /* AT_HWCAP2 */
# define HWCAP_CE_AES (1 << 0)
# define HWCAP_CE_PMULL (1 << 1)
# define HWCAP_CE_SHA1 (1 << 2)
# define HWCAP_CE_SHA256 (1 << 3)
#elif defined(__aarch64__)
# define HWCAP 16 /* AT_HWCAP */
# define HWCAP_NEON (1 << 1)
# define HWCAP_CE HWCAP
# define HWCAP_CE_AES (1 << 3)
# define HWCAP_CE_PMULL (1 << 4)
# define HWCAP_CE_SHA1 (1 << 5)
# define HWCAP_CE_SHA256 (1 << 6)
#endif
void OPENSSL_cpuid_setup(void) void OPENSSL_cpuid_setup(void)
{ {
char *e; char *e;
@ -44,7 +80,7 @@ void OPENSSL_cpuid_setup(void)
if ((e=getenv("OPENSSL_armcap"))) if ((e=getenv("OPENSSL_armcap")))
{ {
OPENSSL_armcap_P=strtoul(e,NULL,0); OPENSSL_armcap_P=(unsigned int)strtoul(e,NULL,0);
return; return;
} }
@ -64,10 +100,51 @@ void OPENSSL_cpuid_setup(void)
sigprocmask(SIG_SETMASK,&ill_act.sa_mask,&oset); sigprocmask(SIG_SETMASK,&ill_act.sa_mask,&oset);
sigaction(SIGILL,&ill_act,&ill_oact); sigaction(SIGILL,&ill_act,&ill_oact);
if (sigsetjmp(ill_jmp,1) == 0) if (getauxval != NULL)
{
if (getauxval(HWCAP) & HWCAP_NEON)
{
unsigned long hwcap = getauxval(HWCAP_CE);
OPENSSL_armcap_P |= ARMV7_NEON;
if (hwcap & HWCAP_CE_AES)
OPENSSL_armcap_P |= ARMV8_AES;
if (hwcap & HWCAP_CE_PMULL)
OPENSSL_armcap_P |= ARMV8_PMULL;
if (hwcap & HWCAP_CE_SHA1)
OPENSSL_armcap_P |= ARMV8_SHA1;
if (hwcap & HWCAP_CE_SHA256)
OPENSSL_armcap_P |= ARMV8_SHA256;
}
}
else if (sigsetjmp(ill_jmp,1) == 0)
{ {
_armv7_neon_probe(); _armv7_neon_probe();
OPENSSL_armcap_P |= ARMV7_NEON; OPENSSL_armcap_P |= ARMV7_NEON;
if (sigsetjmp(ill_jmp,1) == 0)
{
_armv8_pmull_probe();
OPENSSL_armcap_P |= ARMV8_PMULL|ARMV8_AES;
}
else if (sigsetjmp(ill_jmp,1) == 0)
{
_armv8_aes_probe();
OPENSSL_armcap_P |= ARMV8_AES;
}
if (sigsetjmp(ill_jmp,1) == 0)
{
_armv8_sha1_probe();
OPENSSL_armcap_P |= ARMV8_SHA1;
}
if (sigsetjmp(ill_jmp,1) == 0)
{
_armv8_sha256_probe();
OPENSSL_armcap_P |= ARMV8_SHA256;
}
} }
if (sigsetjmp(ill_jmp,1) == 0) if (sigsetjmp(ill_jmp,1) == 0)
{ {

View File

@ -7,17 +7,49 @@
.global _armv7_neon_probe .global _armv7_neon_probe
.type _armv7_neon_probe,%function .type _armv7_neon_probe,%function
_armv7_neon_probe: _armv7_neon_probe:
.word 0xf26ee1fe @ vorr q15,q15,q15 .byte 0xf0,0x01,0x60,0xf2 @ vorr q8,q8,q8
.word 0xe12fff1e @ bx lr .byte 0x1e,0xff,0x2f,0xe1 @ bx lr
.size _armv7_neon_probe,.-_armv7_neon_probe .size _armv7_neon_probe,.-_armv7_neon_probe
.global _armv7_tick .global _armv7_tick
.type _armv7_tick,%function .type _armv7_tick,%function
_armv7_tick: _armv7_tick:
mrc p15,0,r0,c9,c13,0 mrrc p15,1,r0,r1,c14 @ CNTVCT
#if __ARM_ARCH__>=5
bx lr
#else
.word 0xe12fff1e @ bx lr .word 0xe12fff1e @ bx lr
#endif
.size _armv7_tick,.-_armv7_tick .size _armv7_tick,.-_armv7_tick
.global _armv8_aes_probe
.type _armv8_aes_probe,%function
_armv8_aes_probe:
.byte 0x00,0x03,0xb0,0xf3 @ aese.8 q0,q0
.byte 0x1e,0xff,0x2f,0xe1 @ bx lr
.size _armv8_aes_probe,.-_armv8_aes_probe
.global _armv8_sha1_probe
.type _armv8_sha1_probe,%function
_armv8_sha1_probe:
.byte 0x40,0x0c,0x00,0xf2 @ sha1c.32 q0,q0,q0
.byte 0x1e,0xff,0x2f,0xe1 @ bx lr
.size _armv8_sha1_probe,.-_armv8_sha1_probe
.global _armv8_sha256_probe
.type _armv8_sha256_probe,%function
_armv8_sha256_probe:
.byte 0x40,0x0c,0x00,0xf3 @ sha256h.32 q0,q0,q0
.byte 0x1e,0xff,0x2f,0xe1 @ bx lr
.size _armv8_sha256_probe,.-_armv8_sha256_probe
.global _armv8_pmull_probe
.type _armv8_pmull_probe,%function
_armv8_pmull_probe:
.byte 0x00,0x0e,0xa0,0xf2 @ vmull.p64 q0,d0,d0
.byte 0x1e,0xff,0x2f,0xe1 @ bx lr
.size _armv8_pmull_probe,.-_armv8_pmull_probe
.align 5
.global OPENSSL_atomic_add .global OPENSSL_atomic_add
.type OPENSSL_atomic_add,%function .type OPENSSL_atomic_add,%function
OPENSSL_atomic_add: OPENSSL_atomic_add:
@ -28,7 +60,7 @@ OPENSSL_atomic_add:
cmp r2,#0 cmp r2,#0
bne .Ladd bne .Ladd
mov r0,r3 mov r0,r3
.word 0xe12fff1e @ bx lr bx lr
#else #else
stmdb sp!,{r4-r6,lr} stmdb sp!,{r4-r6,lr}
ldr r2,.Lspinlock ldr r2,.Lspinlock
@ -81,9 +113,13 @@ OPENSSL_cleanse:
adds r1,r1,#4 adds r1,r1,#4
bne .Little bne .Little
.Lcleanse_done: .Lcleanse_done:
#if __ARM_ARCH__>=5
bx lr
#else
tst lr,#1 tst lr,#1
moveq pc,lr moveq pc,lr
.word 0xe12fff1e @ bx lr .word 0xe12fff1e @ bx lr
#endif
.size OPENSSL_cleanse,.-OPENSSL_cleanse .size OPENSSL_cleanse,.-OPENSSL_cleanse
.global OPENSSL_wipe_cpu .global OPENSSL_wipe_cpu
@ -97,41 +133,53 @@ OPENSSL_wipe_cpu:
eor ip,ip,ip eor ip,ip,ip
tst r0,#1 tst r0,#1
beq .Lwipe_done beq .Lwipe_done
.word 0xf3000150 @ veor q0, q0, q0 .byte 0x50,0x01,0x00,0xf3 @ veor q0, q0, q0
.word 0xf3022152 @ veor q1, q1, q1 .byte 0x52,0x21,0x02,0xf3 @ veor q1, q1, q1
.word 0xf3044154 @ veor q2, q2, q2 .byte 0x54,0x41,0x04,0xf3 @ veor q2, q2, q2
.word 0xf3066156 @ veor q3, q3, q3 .byte 0x56,0x61,0x06,0xf3 @ veor q3, q3, q3
.word 0xf34001f0 @ veor q8, q8, q8 .byte 0xf0,0x01,0x40,0xf3 @ veor q8, q8, q8
.word 0xf34221f2 @ veor q9, q9, q9 .byte 0xf2,0x21,0x42,0xf3 @ veor q9, q9, q9
.word 0xf34441f4 @ veor q10, q10, q10 .byte 0xf4,0x41,0x44,0xf3 @ veor q10, q10, q10
.word 0xf34661f6 @ veor q11, q11, q11 .byte 0xf6,0x61,0x46,0xf3 @ veor q11, q11, q11
.word 0xf34881f8 @ veor q12, q12, q12 .byte 0xf8,0x81,0x48,0xf3 @ veor q12, q12, q12
.word 0xf34aa1fa @ veor q13, q13, q13 .byte 0xfa,0xa1,0x4a,0xf3 @ veor q13, q13, q13
.word 0xf34cc1fc @ veor q14, q14, q14 .byte 0xfc,0xc1,0x4c,0xf3 @ veor q14, q14, q14
.word 0xf34ee1fe @ veor q15, q15, q15 .byte 0xfe,0xe1,0x4e,0xf3 @ veor q14, q14, q14
.Lwipe_done: .Lwipe_done:
mov r0,sp mov r0,sp
#if __ARM_ARCH__>=5
bx lr
#else
tst lr,#1 tst lr,#1
moveq pc,lr moveq pc,lr
.word 0xe12fff1e @ bx lr .word 0xe12fff1e @ bx lr
#endif
.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu .size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
.global OPENSSL_instrument_bus .global OPENSSL_instrument_bus
.type OPENSSL_instrument_bus,%function .type OPENSSL_instrument_bus,%function
OPENSSL_instrument_bus: OPENSSL_instrument_bus:
eor r0,r0,r0 eor r0,r0,r0
#if __ARM_ARCH__>=5
bx lr
#else
tst lr,#1 tst lr,#1
moveq pc,lr moveq pc,lr
.word 0xe12fff1e @ bx lr .word 0xe12fff1e @ bx lr
#endif
.size OPENSSL_instrument_bus,.-OPENSSL_instrument_bus .size OPENSSL_instrument_bus,.-OPENSSL_instrument_bus
.global OPENSSL_instrument_bus2 .global OPENSSL_instrument_bus2
.type OPENSSL_instrument_bus2,%function .type OPENSSL_instrument_bus2,%function
OPENSSL_instrument_bus2: OPENSSL_instrument_bus2:
eor r0,r0,r0 eor r0,r0,r0
#if __ARM_ARCH__>=5
bx lr
#else
tst lr,#1 tst lr,#1
moveq pc,lr moveq pc,lr
.word 0xe12fff1e @ bx lr .word 0xe12fff1e @ bx lr
#endif
.size OPENSSL_instrument_bus2,.-OPENSSL_instrument_bus2 .size OPENSSL_instrument_bus2,.-OPENSSL_instrument_bus2
.align 5 .align 5

View File

@ -174,7 +174,7 @@ a_gentm.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
a_gentm.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h a_gentm.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
a_gentm.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h a_gentm.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
a_gentm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h a_gentm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
a_gentm.o: ../cryptlib.h ../o_time.h a_gentm.c a_gentm.o: ../cryptlib.h ../o_time.h a_gentm.c asn1_locl.h
a_i2d_fp.o: ../../e_os.h ../../include/openssl/asn1.h a_i2d_fp.o: ../../e_os.h ../../include/openssl/asn1.h
a_i2d_fp.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h a_i2d_fp.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
a_i2d_fp.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h a_i2d_fp.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
@ -275,6 +275,7 @@ a_time.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
a_time.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h a_time.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
a_time.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h a_time.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
a_time.o: ../../include/openssl/symhacks.h ../cryptlib.h ../o_time.h a_time.c a_time.o: ../../include/openssl/symhacks.h ../cryptlib.h ../o_time.h a_time.c
a_time.o: asn1_locl.h
a_type.o: ../../e_os.h ../../include/openssl/asn1.h a_type.o: ../../e_os.h ../../include/openssl/asn1.h
a_type.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h a_type.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
a_type.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h a_type.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
@ -291,7 +292,7 @@ a_utctm.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
a_utctm.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h a_utctm.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
a_utctm.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h a_utctm.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
a_utctm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h a_utctm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
a_utctm.o: ../cryptlib.h ../o_time.h a_utctm.c a_utctm.o: ../cryptlib.h ../o_time.h a_utctm.c asn1_locl.h
a_utf8.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h a_utf8.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
a_utf8.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h a_utf8.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
a_utf8.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h a_utf8.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h

View File

@ -57,6 +57,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <limits.h>
#include "cryptlib.h" #include "cryptlib.h"
#include <openssl/buffer.h> #include <openssl/buffer.h>
#include <openssl/asn1_mac.h> #include <openssl/asn1_mac.h>
@ -143,17 +144,11 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
BUF_MEM *b; BUF_MEM *b;
unsigned char *p; unsigned char *p;
int i; int i;
int ret=-1;
ASN1_const_CTX c; ASN1_const_CTX c;
int want=HEADER_SIZE; size_t want=HEADER_SIZE;
int eos=0; int eos=0;
#if defined(__GNUC__) && defined(__ia64) size_t off=0;
/* pathetic compiler bug in all known versions as of Nov. 2002 */ size_t len=0;
long off=0;
#else
int off=0;
#endif
int len=0;
b=BUF_MEM_new(); b=BUF_MEM_new();
if (b == NULL) if (b == NULL)
@ -169,7 +164,7 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
{ {
want-=(len-off); 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); ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE);
goto err; goto err;
@ -181,8 +176,15 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
goto err; goto err;
} }
if (i > 0) if (i > 0)
{
if (len+i < len)
{
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
goto err;
}
len+=i; len+=i;
} }
}
/* else data already loaded */ /* else data already loaded */
p=(unsigned char *)&(b->data[off]); p=(unsigned char *)&(b->data[off]);
@ -206,6 +208,11 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
{ {
/* no data body so go round again */ /* no data body so go round again */
eos++; eos++;
if (eos < 0)
{
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_HEADER_TOO_LONG);
goto err;
}
want=HEADER_SIZE; want=HEADER_SIZE;
} }
else if (eos && (c.slen == 0) && (c.tag == V_ASN1_EOC)) 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 else
{ {
/* suck in c.slen bytes of data */ /* suck in c.slen bytes of data */
want=(int)c.slen; want=c.slen;
if (want > (len-off)) if (want > (len-off))
{ {
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)) if (!BUF_MEM_grow_clean(b,len+want))
{ {
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE); 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); ASN1_R_NOT_ENOUGH_DATA);
goto err; goto err;
} }
/* This can't overflow because
* |len+want| didn't overflow. */
len+=i; 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) if (eos <= 0)
{ {
break; 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; *pb = b;
return off; return off;
err: err:
if (b != NULL) BUF_MEM_free(b); if (b != NULL) BUF_MEM_free(b);
return(ret); return -1;
} }

View File

@ -63,6 +63,7 @@
#include "cryptlib.h" #include "cryptlib.h"
#include "o_time.h" #include "o_time.h"
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include "asn1_locl.h"
#if 0 #if 0
@ -115,7 +116,7 @@ err:
#endif #endif
int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d) int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d)
{ {
static const int min[9]={ 0, 0, 1, 1, 0, 0, 0, 0, 0}; static const int min[9]={ 0, 0, 1, 1, 0, 0, 0, 0, 0};
static const int max[9]={99, 99,12,31,23,59,59,12,59}; static const int max[9]={99, 99,12,31,23,59,59,12,59};
@ -135,7 +136,12 @@ int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d)
{ {
if ((i == 6) && ((a[o] == 'Z') || if ((i == 6) && ((a[o] == 'Z') ||
(a[o] == '+') || (a[o] == '-'))) (a[o] == '+') || (a[o] == '-')))
{ i++; break; } {
i++;
if (tm)
tm->tm_sec = 0;
break;
}
if ((a[o] < '0') || (a[o] > '9')) goto err; if ((a[o] < '0') || (a[o] > '9')) goto err;
n= a[o]-'0'; n= a[o]-'0';
if (++o > l) goto err; if (++o > l) goto err;
@ -145,6 +151,33 @@ int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d)
if (++o > l) goto err; if (++o > l) goto err;
if ((n < min[i]) || (n > max[i])) goto err; if ((n < min[i]) || (n > max[i])) goto err;
if (tm)
{
switch(i)
{
case 0:
tm->tm_year = n * 100 - 1900;
break;
case 1:
tm->tm_year += n;
break;
case 2:
tm->tm_mon = n - 1;
break;
case 3:
tm->tm_mday = n;
break;
case 4:
tm->tm_hour = n;
break;
case 5:
tm->tm_min = n;
break;
case 6:
tm->tm_sec = n;
break;
}
}
} }
/* Optional fractional seconds: decimal point followed by one /* Optional fractional seconds: decimal point followed by one
* or more digits. * or more digits.
@ -163,6 +196,7 @@ int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d)
o++; o++;
else if ((a[o] == '+') || (a[o] == '-')) else if ((a[o] == '+') || (a[o] == '-'))
{ {
int offsign = a[o] == '-' ? -1 : 1, offset = 0;
o++; o++;
if (o+4 > l) goto err; if (o+4 > l) goto err;
for (i=7; i<9; i++) for (i=7; i<9; i++)
@ -173,10 +207,19 @@ int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d)
if ((a[o] < '0') || (a[o] > '9')) goto err; if ((a[o] < '0') || (a[o] > '9')) goto err;
n=(n*10)+ a[o]-'0'; n=(n*10)+ a[o]-'0';
if ((n < min[i]) || (n > max[i])) goto err; if ((n < min[i]) || (n > max[i])) goto err;
if (tm)
{
if (i == 7)
offset = n * 3600;
else if (i == 8)
offset += n * 60;
}
o++; o++;
} }
if (offset && !OPENSSL_gmtime_adj(tm, 0, offset * offsign))
return 0;
} }
else else if (a[o])
{ {
/* Missing time zone information. */ /* Missing time zone information. */
goto err; goto err;
@ -186,6 +229,11 @@ err:
return(0); return(0);
} }
int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *d)
{
return asn1_generalizedtime_to_tm(NULL, d);
}
int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str) int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str)
{ {
ASN1_GENERALIZEDTIME t; ASN1_GENERALIZEDTIME t;

View File

@ -116,7 +116,7 @@ int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp)
int pad=0,ret,i,neg; int pad=0,ret,i,neg;
unsigned char *p,*n,pb=0; unsigned char *p,*n,pb=0;
if ((a == NULL) || (a->data == NULL)) return(0); if (a == NULL) return(0);
neg=a->type & V_ASN1_NEG; neg=a->type & V_ASN1_NEG;
if (a->length == 0) if (a->length == 0)
ret=1; ret=1;

View File

@ -283,17 +283,29 @@ err:
ASN1err(ASN1_F_D2I_ASN1_OBJECT,i); ASN1err(ASN1_F_D2I_ASN1_OBJECT,i);
return(NULL); return(NULL);
} }
ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
long len) long len)
{ {
ASN1_OBJECT *ret=NULL; ASN1_OBJECT *ret=NULL;
const unsigned char *p; const unsigned char *p;
unsigned char *data; unsigned char *data;
int i; int i, length;
/* Sanity check OID encoding: can't have leading 0x80 in
* subidentifiers, see: X.690 8.19.2 /* Sanity check OID encoding.
* Need at least one content octet.
* MSB must be clear in the last octet.
* can't have leading 0x80 in subidentifiers, see: X.690 8.19.2
*/ */
for (i = 0, p = *pp; i < len; i++, p++) if (len <= 0 || len > INT_MAX || pp == NULL || (p = *pp) == NULL ||
p[len - 1] & 0x80)
{
ASN1err(ASN1_F_C2I_ASN1_OBJECT,ASN1_R_INVALID_OBJECT_ENCODING);
return NULL;
}
/* Now 0 < len <= INT_MAX, so the cast is safe. */
length = (int)len;
for (i = 0; i < length; i++, p++)
{ {
if (*p == 0x80 && (!i || !(p[-1] & 0x80))) if (*p == 0x80 && (!i || !(p[-1] & 0x80)))
{ {
@ -316,23 +328,23 @@ ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
data = (unsigned char *)ret->data; data = (unsigned char *)ret->data;
ret->data = NULL; ret->data = NULL;
/* once detached we can change it */ /* once detached we can change it */
if ((data == NULL) || (ret->length < len)) if ((data == NULL) || (ret->length < length))
{ {
ret->length=0; ret->length=0;
if (data != NULL) OPENSSL_free(data); if (data != NULL) OPENSSL_free(data);
data=(unsigned char *)OPENSSL_malloc(len ? (int)len : 1); data=(unsigned char *)OPENSSL_malloc(length);
if (data == NULL) if (data == NULL)
{ i=ERR_R_MALLOC_FAILURE; goto err; } { i=ERR_R_MALLOC_FAILURE; goto err; }
ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA; ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA;
} }
memcpy(data,p,(int)len); memcpy(data,p,length);
/* reattach data to object, after which it remains const */ /* reattach data to object, after which it remains const */
ret->data =data; ret->data =data;
ret->length=(int)len; ret->length=length;
ret->sn=NULL; ret->sn=NULL;
ret->ln=NULL; ret->ln=NULL;
/* ret->flags=ASN1_OBJECT_FLAG_DYNAMIC; we know it is dynamic */ /* ret->flags=ASN1_OBJECT_FLAG_DYNAMIC; we know it is dynamic */
p+=len; p+=length;
if (a != NULL) (*a)=ret; if (a != NULL) (*a)=ret;
*pp=p; *pp=p;

View File

@ -567,6 +567,8 @@ int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in)
if(mbflag == -1) return -1; if(mbflag == -1) return -1;
mbflag |= MBSTRING_FLAG; mbflag |= MBSTRING_FLAG;
stmp.data = NULL; stmp.data = NULL;
stmp.length = 0;
stmp.flags = 0;
ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag, B_ASN1_UTF8STRING); ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag, B_ASN1_UTF8STRING);
if(ret < 0) return ret; if(ret < 0) return ret;
*out = stmp.data; *out = stmp.data;

View File

@ -74,7 +74,7 @@ static int sk_table_cmp(const ASN1_STRING_TABLE * const *a,
* certain software (e.g. Netscape) has problems with them. * certain software (e.g. Netscape) has problems with them.
*/ */
static unsigned long global_mask = 0xFFFFFFFFL; static unsigned long global_mask = B_ASN1_UTF8STRING;
void ASN1_STRING_set_default_mask(unsigned long mask) void ASN1_STRING_set_default_mask(unsigned long mask)
{ {

View File

@ -66,6 +66,7 @@
#include "cryptlib.h" #include "cryptlib.h"
#include "o_time.h" #include "o_time.h"
#include <openssl/asn1t.h> #include <openssl/asn1t.h>
#include "asn1_locl.h"
IMPLEMENT_ASN1_MSTRING(ASN1_TIME, B_ASN1_TIME) IMPLEMENT_ASN1_MSTRING(ASN1_TIME, B_ASN1_TIME)
@ -196,3 +197,33 @@ int ASN1_TIME_set_string(ASN1_TIME *s, const char *str)
return 1; return 1;
} }
static int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *t)
{
if (t == NULL)
{
time_t now_t;
time(&now_t);
if (OPENSSL_gmtime(&now_t, tm))
return 1;
return 0;
}
if (t->type == V_ASN1_UTCTIME)
return asn1_utctime_to_tm(tm, t);
else if (t->type == V_ASN1_GENERALIZEDTIME)
return asn1_generalizedtime_to_tm(tm, t);
return 0;
}
int ASN1_TIME_diff(int *pday, int *psec,
const ASN1_TIME *from, const ASN1_TIME *to)
{
struct tm tm_from, tm_to;
if (!asn1_time_to_tm(&tm_from, from))
return 0;
if (!asn1_time_to_tm(&tm_to, to))
return 0;
return OPENSSL_gmtime_diff(pday, psec, &tm_from, &tm_to);
}

View File

@ -61,6 +61,7 @@
#include "cryptlib.h" #include "cryptlib.h"
#include "o_time.h" #include "o_time.h"
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include "asn1_locl.h"
#if 0 #if 0
int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a, unsigned char **pp) int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a, unsigned char **pp)
@ -112,7 +113,7 @@ err:
#endif #endif
int ASN1_UTCTIME_check(ASN1_UTCTIME *d) int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d)
{ {
static const int min[8]={ 0, 1, 1, 0, 0, 0, 0, 0}; static const int min[8]={ 0, 1, 1, 0, 0, 0, 0, 0};
static const int max[8]={99,12,31,23,59,59,12,59}; static const int max[8]={99,12,31,23,59,59,12,59};
@ -129,7 +130,12 @@ int ASN1_UTCTIME_check(ASN1_UTCTIME *d)
{ {
if ((i == 5) && ((a[o] == 'Z') || if ((i == 5) && ((a[o] == 'Z') ||
(a[o] == '+') || (a[o] == '-'))) (a[o] == '+') || (a[o] == '-')))
{ i++; break; } {
i++;
if (tm)
tm->tm_sec = 0;
break;
}
if ((a[o] < '0') || (a[o] > '9')) goto err; if ((a[o] < '0') || (a[o] > '9')) goto err;
n= a[o]-'0'; n= a[o]-'0';
if (++o > l) goto err; if (++o > l) goto err;
@ -139,11 +145,36 @@ int ASN1_UTCTIME_check(ASN1_UTCTIME *d)
if (++o > l) goto err; if (++o > l) goto err;
if ((n < min[i]) || (n > max[i])) goto err; if ((n < min[i]) || (n > max[i])) goto err;
if (tm)
{
switch(i)
{
case 0:
tm->tm_year = n < 50 ? n + 100 : n;
break;
case 1:
tm->tm_mon = n - 1;
break;
case 2:
tm->tm_mday = n;
break;
case 3:
tm->tm_hour = n;
break;
case 4:
tm->tm_min = n;
break;
case 5:
tm->tm_sec = n;
break;
}
}
} }
if (a[o] == 'Z') if (a[o] == 'Z')
o++; o++;
else if ((a[o] == '+') || (a[o] == '-')) else if ((a[o] == '+') || (a[o] == '-'))
{ {
int offsign = a[o] == '-' ? -1 : 1, offset = 0;
o++; o++;
if (o+4 > l) goto err; if (o+4 > l) goto err;
for (i=6; i<8; i++) for (i=6; i<8; i++)
@ -154,12 +185,26 @@ int ASN1_UTCTIME_check(ASN1_UTCTIME *d)
if ((a[o] < '0') || (a[o] > '9')) goto err; if ((a[o] < '0') || (a[o] > '9')) goto err;
n=(n*10)+ a[o]-'0'; n=(n*10)+ a[o]-'0';
if ((n < min[i]) || (n > max[i])) goto err; if ((n < min[i]) || (n > max[i])) goto err;
if (tm)
{
if (i == 6)
offset = n * 3600;
else if (i == 7)
offset += n * 60;
}
o++; o++;
} }
if (offset && !OPENSSL_gmtime_adj(tm, 0, offset * offsign))
return 0;
} }
return(o == l); return o == l;
err: err:
return(0); return 0;
}
int ASN1_UTCTIME_check(const ASN1_UTCTIME *d)
{
return asn1_utctime_to_tm(NULL, d);
} }
int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str) int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str)
@ -196,24 +241,29 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
struct tm *ts; struct tm *ts;
struct tm data; struct tm data;
size_t len = 20; size_t len = 20;
int free_s = 0;
if (s == NULL) if (s == NULL)
{
free_s = 1;
s=M_ASN1_UTCTIME_new(); s=M_ASN1_UTCTIME_new();
}
if (s == NULL) if (s == NULL)
return(NULL); goto err;
ts=OPENSSL_gmtime(&t, &data); ts=OPENSSL_gmtime(&t, &data);
if (ts == NULL) if (ts == NULL)
return(NULL); goto err;
if (offset_day || offset_sec) if (offset_day || offset_sec)
{ {
if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec)) if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
return NULL; goto err;
} }
if((ts->tm_year < 50) || (ts->tm_year >= 150)) if((ts->tm_year < 50) || (ts->tm_year >= 150))
return NULL; goto err;
p=(char *)s->data; p=(char *)s->data;
if ((p == NULL) || ((size_t)s->length < len)) if ((p == NULL) || ((size_t)s->length < len))
@ -222,7 +272,7 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
if (p == NULL) if (p == NULL)
{ {
ASN1err(ASN1_F_ASN1_UTCTIME_ADJ,ERR_R_MALLOC_FAILURE); ASN1err(ASN1_F_ASN1_UTCTIME_ADJ,ERR_R_MALLOC_FAILURE);
return(NULL); goto err;
} }
if (s->data != NULL) if (s->data != NULL)
OPENSSL_free(s->data); OPENSSL_free(s->data);
@ -237,44 +287,35 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
ebcdic2ascii(s->data, s->data, s->length); ebcdic2ascii(s->data, s->data, s->length);
#endif #endif
return(s); return(s);
err:
if (free_s && s)
M_ASN1_UTCTIME_free(s);
return NULL;
} }
int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t) int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t)
{ {
struct tm *tm; struct tm stm, ttm;
struct tm data; int day, sec;
int offset;
int year;
#define g2(p) (((p)[0]-'0')*10+(p)[1]-'0') if (!asn1_utctime_to_tm(&stm, s))
return -2;
if (s->data[12] == 'Z') if (!OPENSSL_gmtime(&t, &ttm))
offset=0; return -2;
else
{
offset = g2(s->data+13)*60+g2(s->data+15);
if (s->data[12] == '-')
offset = -offset;
}
t -= offset*60; /* FIXME: may overflow in extreme cases */ if (!OPENSSL_gmtime_diff(&day, &sec, &stm, &ttm))
return -2;
tm = OPENSSL_gmtime(&t, &data);
#define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1
year = g2(s->data);
if (year < 50)
year += 100;
return_cmp(year, tm->tm_year);
return_cmp(g2(s->data+2) - 1, tm->tm_mon);
return_cmp(g2(s->data+4), tm->tm_mday);
return_cmp(g2(s->data+6), tm->tm_hour);
return_cmp(g2(s->data+8), tm->tm_min);
return_cmp(g2(s->data+10), tm->tm_sec);
#undef g2
#undef return_cmp
if (day > 0)
return 1;
if (day < 0)
return -1;
if (sec > 0)
return 1;
if (sec < 0)
return -1;
return 0; return 0;
} }

View File

@ -140,6 +140,12 @@ int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a,
int mdnid, pknid; int mdnid, pknid;
if (!pkey)
{
ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ERR_R_PASSED_NULL_PARAMETER);
return -1;
}
EVP_MD_CTX_init(&ctx); EVP_MD_CTX_init(&ctx);
/* Convert signature OID into digest and public key OIDs */ /* Convert signature OID into digest and public key OIDs */

View File

@ -67,6 +67,7 @@
extern const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[]; extern const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[];
extern const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[]; extern const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[];
extern const EVP_PKEY_ASN1_METHOD dh_asn1_meth; extern const EVP_PKEY_ASN1_METHOD dh_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD dhx_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD eckey_asn1_meth; extern const EVP_PKEY_ASN1_METHOD eckey_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD hmac_asn1_meth; extern const EVP_PKEY_ASN1_METHOD hmac_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth; extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth;
@ -92,7 +93,10 @@ static const EVP_PKEY_ASN1_METHOD *standard_methods[] =
&eckey_asn1_meth, &eckey_asn1_meth,
#endif #endif
&hmac_asn1_meth, &hmac_asn1_meth,
&cmac_asn1_meth &cmac_asn1_meth,
#ifndef OPENSSL_NO_DH
&dhx_asn1_meth
#endif
}; };
typedef int sk_cmp_fn_type(const char * const *a, const char * const *b); typedef int sk_cmp_fn_type(const char * const *a, const char * const *b);
@ -258,7 +262,12 @@ int EVP_PKEY_asn1_add_alias(int to, int from)
if (!ameth) if (!ameth)
return 0; return 0;
ameth->pkey_base_id = to; ameth->pkey_base_id = to;
return EVP_PKEY_asn1_add0(ameth); if (!EVP_PKEY_asn1_add0(ameth))
{
EVP_PKEY_asn1_free(ameth);
return 0;
}
return 1;
} }
int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *ppkey_base_id, int *ppkey_flags, int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *ppkey_base_id, int *ppkey_flags,

View File

@ -208,14 +208,14 @@ typedef struct asn1_const_ctx_st
#define ASN1_OBJECT_FLAG_CRITICAL 0x02 /* critical x509v3 object id */ #define ASN1_OBJECT_FLAG_CRITICAL 0x02 /* critical x509v3 object id */
#define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04 /* internal use */ #define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04 /* internal use */
#define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08 /* internal use */ #define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08 /* internal use */
typedef struct asn1_object_st struct asn1_object_st
{ {
const char *sn,*ln; const char *sn,*ln;
int nid; int nid;
int length; int length;
const unsigned char *data; /* data remains const after init */ const unsigned char *data; /* data remains const after init */
int flags; /* Should we free this one */ int flags; /* Should we free this one */
} ASN1_OBJECT; };
#define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */ #define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */
/* This indicates that the ASN1_STRING is not a real value but just a place /* This indicates that the ASN1_STRING is not a real value but just a place
@ -839,7 +839,7 @@ int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);
DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED) DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)
int ASN1_UTCTIME_check(ASN1_UTCTIME *a); int ASN1_UTCTIME_check(const ASN1_UTCTIME *a);
ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t); ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t);
ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
int offset_day, long offset_sec); int offset_day, long offset_sec);
@ -849,11 +849,13 @@ int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s); time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s);
#endif #endif
int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a); int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a);
ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t); ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t);
ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
time_t t, int offset_day, long offset_sec); time_t t, int offset_day, long offset_sec);
int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str); int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);
int ASN1_TIME_diff(int *pday, int *psec,
const ASN1_TIME *from, const ASN1_TIME *to);
DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING) DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)
ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a); ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a);

View File

@ -305,7 +305,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
{ERR_REASON(ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE),"unknown public key type"}, {ERR_REASON(ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE),"unknown public key type"},
{ERR_REASON(ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM),"unknown signature algorithm"}, {ERR_REASON(ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM),"unknown signature algorithm"},
{ERR_REASON(ASN1_R_UNKNOWN_TAG) ,"unknown tag"}, {ERR_REASON(ASN1_R_UNKNOWN_TAG) ,"unknown tag"},
{ERR_REASON(ASN1_R_UNKOWN_FORMAT) ,"unkown format"}, {ERR_REASON(ASN1_R_UNKOWN_FORMAT) ,"unknown format"},
{ERR_REASON(ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE),"unsupported any defined by type"}, {ERR_REASON(ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE),"unsupported any defined by type"},
{ERR_REASON(ASN1_R_UNSUPPORTED_CIPHER) ,"unsupported cipher"}, {ERR_REASON(ASN1_R_UNSUPPORTED_CIPHER) ,"unsupported cipher"},
{ERR_REASON(ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM),"unsupported encryption algorithm"}, {ERR_REASON(ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM),"unsupported encryption algorithm"},

View File

@ -131,6 +131,9 @@ int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
*pclass=xclass; *pclass=xclass;
if (!asn1_get_length(&p,&inf,plength,(int)max)) goto err; if (!asn1_get_length(&p,&inf,plength,(int)max)) goto err;
if (inf && !(ret & V_ASN1_CONSTRUCTED))
goto err;
#if 0 #if 0
fprintf(stderr,"p=%d + *plength=%ld > omax=%ld + *pp=%d (%d > %d)\n", fprintf(stderr,"p=%d + *plength=%ld > omax=%ld + *pp=%d (%d > %d)\n",
(int)p,*plength,omax,(int)*pp,(int)(p+ *plength), (int)p,*plength,omax,(int)*pp,(int)(p+ *plength),

View File

@ -58,6 +58,9 @@
/* Internal ASN1 structures and functions: not for application use */ /* Internal ASN1 structures and functions: not for application use */
int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d);
int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d);
/* ASN1 print context structure */ /* ASN1 print context structure */
struct asn1_pctx_st struct asn1_pctx_st

View File

@ -667,6 +667,8 @@ static STACK_OF(MIME_HEADER) *mime_parse_hdr(BIO *bio)
int len, state, save_state = 0; int len, state, save_state = 0;
headers = sk_MIME_HEADER_new(mime_hdr_cmp); headers = sk_MIME_HEADER_new(mime_hdr_cmp);
if (!headers)
return NULL;
while ((len = BIO_gets(bio, linebuf, MAX_SMLEN)) > 0) { while ((len = BIO_gets(bio, linebuf, MAX_SMLEN)) > 0) {
/* If whitespace at line start then continuation line */ /* If whitespace at line start then continuation line */
if(mhdr && isspace((unsigned char)linebuf[0])) state = MIME_NAME; if(mhdr && isspace((unsigned char)linebuf[0])) state = MIME_NAME;

View File

@ -134,15 +134,23 @@ ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d, ASN1_STRING **oct)
if (!(octmp->length = i2d(obj, NULL))) { if (!(octmp->length = i2d(obj, NULL))) {
ASN1err(ASN1_F_ASN1_PACK_STRING,ASN1_R_ENCODE_ERROR); ASN1err(ASN1_F_ASN1_PACK_STRING,ASN1_R_ENCODE_ERROR);
return NULL; goto err;
} }
if (!(p = OPENSSL_malloc (octmp->length))) { if (!(p = OPENSSL_malloc (octmp->length))) {
ASN1err(ASN1_F_ASN1_PACK_STRING,ERR_R_MALLOC_FAILURE); ASN1err(ASN1_F_ASN1_PACK_STRING,ERR_R_MALLOC_FAILURE);
return NULL; goto err;
} }
octmp->data = p; octmp->data = p;
i2d (obj, &p); i2d (obj, &p);
return octmp; return octmp;
err:
if (!oct || !*oct)
{
ASN1_STRING_free(octmp);
if (oct)
*oct = NULL;
}
return NULL;
} }
#endif #endif

View File

@ -154,7 +154,10 @@ static int asn1_bio_new(BIO *b)
if (!ctx) if (!ctx)
return 0; return 0;
if (!asn1_bio_init(ctx, DEFAULT_ASN1_BUF_SIZE)) if (!asn1_bio_init(ctx, DEFAULT_ASN1_BUF_SIZE))
{
OPENSSL_free(ctx);
return 0; return 0;
}
b->init = 1; b->init = 1;
b->ptr = (char *)ctx; b->ptr = (char *)ctx;
b->flags = 0; b->flags = 0;

View File

@ -1,5 +1,8 @@
#!/usr/local/bin/perl -w #!/usr/local/bin/perl -w
# Written by Dr Stephen N Henson (steve@openssl.org).
# Licensed under the terms of the OpenSSL license.
use strict; use strict;
my ($i, @arr); my ($i, @arr);

Some files were not shown because too many files have changed in this diff Show More