summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormiod <>2014-04-13 15:16:38 +0000
committermiod <>2014-04-13 15:16:38 +0000
commitfea4fc3d16f04ff054803f9276895492961ab5e2 (patch)
tree5120067244554214f4a55a9b6f4ab44bca0a0438
parent293732ea9d538daf81033ab02d62cbe188088510 (diff)
downloadopenbsd-fea4fc3d16f04ff054803f9276895492961ab5e2.tar.gz
openbsd-fea4fc3d16f04ff054803f9276895492961ab5e2.tar.bz2
openbsd-fea4fc3d16f04ff054803f9276895492961ab5e2.zip
Import OpenSSL 1.0.1g
-rw-r--r--src/lib/libcrypto/ecdh/Makefile17
-rw-r--r--src/lib/libcrypto/engine/eng_rdrand.c1
-rw-r--r--src/lib/libcrypto/mdc2/mdc2dgst.c2
-rw-r--r--src/lib/libcrypto/modes/Makefile5
-rw-r--r--src/lib/libcrypto/perlasm/x86masm.pl1
-rw-r--r--src/lib/libcrypto/rc5/asm/rc5-586.pl3
-rw-r--r--src/lib/libcrypto/rc5/rc5_ecb.c80
-rw-r--r--src/lib/libcrypto/rc5/rc5_enc.c215
-rw-r--r--src/lib/libcrypto/rc5/rc5_skey.c113
-rw-r--r--src/lib/libcrypto/rc5/rc5cfb64.c122
-rw-r--r--src/lib/libcrypto/rc5/rc5ofb64.c111
-rw-r--r--src/lib/libcrypto/rc5/rc5speed.c277
-rw-r--r--src/lib/libcrypto/srp/srp_grps.h816
-rw-r--r--src/lib/libcrypto/srp/srp_lib.c18
-rw-r--r--src/lib/libcrypto/srp/srp_vfy.c5
-rw-r--r--src/lib/libssl/src/apps/cms.c4
-rw-r--r--src/lib/libssl/src/apps/ecparam.c4
-rw-r--r--src/lib/libssl/src/apps/srp.c30
-rw-r--r--src/lib/libssl/src/crypto/aes/asm/aes-mips.pl20
-rw-r--r--src/lib/libssl/src/crypto/aes/asm/aes-parisc.pl3
-rw-r--r--src/lib/libssl/src/crypto/aes/asm/aes-s390x.pl95
-rwxr-xr-xsrc/lib/libssl/src/crypto/aes/asm/aes-x86_64.pl3
-rw-r--r--src/lib/libssl/src/crypto/aes/asm/aesni-sha1-x86_64.pl3
-rw-r--r--src/lib/libssl/src/crypto/aes/asm/aesni-x86_64.pl3
-rw-r--r--src/lib/libssl/src/crypto/aes/asm/bsaes-x86_64.pl76
-rw-r--r--src/lib/libssl/src/crypto/aes/asm/vpaes-x86_64.pl5
-rw-r--r--src/lib/libssl/src/crypto/armcap.c2
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_dgram.c91
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/mips-mont.pl2
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/mips.pl46
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/modexp512-x86_64.pl3
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/parisc-mont.pl4
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/x86_64-gf2m.pl3
-rwxr-xr-xsrc/lib/libssl/src/crypto/bn/asm/x86_64-mont.pl3
-rwxr-xr-xsrc/lib/libssl/src/crypto/bn/asm/x86_64-mont5.pl7
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_nist.c55
-rw-r--r--src/lib/libssl/src/crypto/camellia/asm/cmll-x86_64.pl3
-rw-r--r--src/lib/libssl/src/crypto/cms/cms_cd.c2
-rw-r--r--src/lib/libssl/src/crypto/cms/cms_enc.c2
-rw-r--r--src/lib/libssl/src/crypto/cms/cms_lib.c4
-rw-r--r--src/lib/libssl/src/crypto/ec/ec2_mult.c27
-rw-r--r--src/lib/libssl/src/crypto/ec/ec_ameth.c2
-rw-r--r--src/lib/libssl/src/crypto/ec/ec_asn1.c6
-rw-r--r--src/lib/libssl/src/crypto/ec/ec_key.c13
-rw-r--r--src/lib/libssl/src/crypto/ec/ec_pmeth.c2
-rw-r--r--src/lib/libssl/src/crypto/ecdh/Makefile17
-rw-r--r--src/lib/libssl/src/crypto/ecdh/ech_key.c3
-rw-r--r--src/lib/libssl/src/crypto/ecdh/ech_lib.c11
-rw-r--r--src/lib/libssl/src/crypto/ecdsa/ecs_lib.c11
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_rdrand.c1
-rw-r--r--src/lib/libssl/src/crypto/evp/e_aes_cbc_hmac_sha1.c217
-rwxr-xr-xsrc/lib/libssl/src/crypto/md5/asm/md5-x86_64.pl3
-rw-r--r--src/lib/libssl/src/crypto/mdc2/mdc2dgst.c2
-rw-r--r--src/lib/libssl/src/crypto/modes/Makefile5
-rw-r--r--src/lib/libssl/src/crypto/modes/asm/ghash-alpha.pl25
-rw-r--r--src/lib/libssl/src/crypto/modes/asm/ghash-parisc.pl1
-rw-r--r--src/lib/libssl/src/crypto/modes/asm/ghash-x86.pl6
-rw-r--r--src/lib/libssl/src/crypto/modes/asm/ghash-x86_64.pl3
-rw-r--r--src/lib/libssl/src/crypto/modes/cbc128.c25
-rw-r--r--src/lib/libssl/src/crypto/modes/ccm128.c2
-rw-r--r--src/lib/libssl/src/crypto/modes/cts128.c28
-rw-r--r--src/lib/libssl/src/crypto/modes/gcm128.c196
-rw-r--r--src/lib/libssl/src/crypto/modes/modes_lcl.h9
-rw-r--r--src/lib/libssl/src/crypto/pariscid.pl41
-rw-r--r--src/lib/libssl/src/crypto/perlasm/x86masm.pl1
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/bio_pk7.c2
-rw-r--r--src/lib/libssl/src/crypto/ppccap.c11
-rw-r--r--src/lib/libssl/src/crypto/rc4/asm/rc4-md5-x86_64.pl3
-rw-r--r--src/lib/libssl/src/crypto/rc4/asm/rc4-parisc.pl3
-rwxr-xr-xsrc/lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl3
-rw-r--r--src/lib/libssl/src/crypto/rc5/asm/rc5-586.pl3
-rw-r--r--src/lib/libssl/src/crypto/rc5/rc5_ecb.c80
-rw-r--r--src/lib/libssl/src/crypto/rc5/rc5_enc.c215
-rw-r--r--src/lib/libssl/src/crypto/rc5/rc5_skey.c113
-rw-r--r--src/lib/libssl/src/crypto/rc5/rc5cfb64.c122
-rw-r--r--src/lib/libssl/src/crypto/rc5/rc5ofb64.c111
-rw-r--r--src/lib/libssl/src/crypto/rc5/rc5speed.c277
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_ameth.c8
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_pmeth.c2
-rw-r--r--src/lib/libssl/src/crypto/sha/asm/sha1-armv4-large.pl2
-rw-r--r--src/lib/libssl/src/crypto/sha/asm/sha1-parisc.pl3
-rw-r--r--src/lib/libssl/src/crypto/sha/asm/sha1-sparcv9a.pl2
-rwxr-xr-xsrc/lib/libssl/src/crypto/sha/asm/sha1-x86_64.pl7
-rw-r--r--src/lib/libssl/src/crypto/sha/asm/sha512-586.pl16
-rw-r--r--src/lib/libssl/src/crypto/sha/asm/sha512-mips.pl2
-rwxr-xr-xsrc/lib/libssl/src/crypto/sha/asm/sha512-parisc.pl2
-rwxr-xr-xsrc/lib/libssl/src/crypto/sha/asm/sha512-x86_64.pl3
-rw-r--r--src/lib/libssl/src/crypto/sha/sha256.c6
-rw-r--r--src/lib/libssl/src/crypto/sha/sha512.c9
-rw-r--r--src/lib/libssl/src/crypto/sparccpuid.S4
-rw-r--r--src/lib/libssl/src/crypto/srp/srp_grps.h816
-rw-r--r--src/lib/libssl/src/crypto/srp/srp_lib.c18
-rw-r--r--src/lib/libssl/src/crypto/srp/srp_vfy.c5
-rw-r--r--src/lib/libssl/src/crypto/whrlpool/asm/wp-mmx.pl2
-rw-r--r--src/lib/libssl/src/crypto/whrlpool/asm/wp-x86_64.pl3
-rw-r--r--src/lib/libssl/src/crypto/x86_64cpuid.pl3
-rw-r--r--src/lib/libssl/src/crypto/x86cpuid.pl6
-rw-r--r--src/lib/libssl/src/demos/cms/cms_comp.c2
-rw-r--r--src/lib/libssl/src/demos/cms/cms_dec.c2
-rw-r--r--src/lib/libssl/src/demos/cms/cms_sign.c2
-rw-r--r--src/lib/libssl/src/doc/apps/ec.pod2
-rw-r--r--src/lib/libssl/src/doc/apps/ts.pod4
-rw-r--r--src/lib/libssl/src/doc/apps/tsget.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_BLINDING_new.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_PKEY_CTX_ctrl.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_PKEY_decrypt.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_PKEY_derive.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_PKEY_encrypt.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_PKEY_get_default_digest.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_PKEY_keygen.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_PKEY_sign.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_PKEY_verify.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_PKEY_verify_recover.pod103
-rw-r--r--src/lib/libssl/src/doc/crypto/X509_STORE_CTX_get_error.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/X509_VERIFY_PARAM_set_flags.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/ecdsa.pod10
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_use_psk_identity_hint.pod4
-rw-r--r--src/lib/libssl/src/engines/ccgost/gost89.c14
-rw-r--r--src/lib/libssl/src/engines/ccgost/gost89.h4
-rw-r--r--src/lib/libssl/src/engines/ccgost/gost_crypt.c29
-rw-r--r--src/lib/libssl/src/engines/ccgost/gost_eng.c17
-rw-r--r--src/lib/libssl/src/engines/ccgost/gost_lcl.h4
-rw-r--r--src/lib/libssl/src/engines/ccgost/gosthash.c21
-rw-r--r--src/lib/libssl/src/engines/e_capi.c5
-rw-r--r--src/lib/libssl/src/ssl/d1_both.c39
-rw-r--r--src/lib/libssl/src/ssl/d1_clnt.c36
-rw-r--r--src/lib/libssl/src/ssl/d1_enc.c59
-rw-r--r--src/lib/libssl/src/ssl/d1_lib.c1
-rw-r--r--src/lib/libssl/src/ssl/d1_pkt.c98
-rw-r--r--src/lib/libssl/src/ssl/d1_srtp.c5
-rw-r--r--src/lib/libssl/src/ssl/d1_srvr.c29
-rw-r--r--src/lib/libssl/src/ssl/dtls1.h8
-rw-r--r--src/lib/libssl/src/ssl/tls_srp.c3
-rw-r--r--src/lib/libssl/src/test/cms-test.pl4
134 files changed, 3912 insertions, 1395 deletions
diff --git a/src/lib/libcrypto/ecdh/Makefile b/src/lib/libcrypto/ecdh/Makefile
index 65d8904ee8..ba05fea05c 100644
--- a/src/lib/libcrypto/ecdh/Makefile
+++ b/src/lib/libcrypto/ecdh/Makefile
@@ -84,17 +84,12 @@ ech_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
84ech_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 84ech_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
85ech_err.o: ech_err.c 85ech_err.o: ech_err.c
86ech_key.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 86ech_key.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
87ech_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 87ech_key.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
88ech_key.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 88ech_key.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
89ech_key.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 89ech_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
90ech_key.o: ../../include/openssl/engine.h ../../include/openssl/evp.h 90ech_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
91ech_key.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 91ech_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
92ech_key.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 92ech_key.o: ech_key.c ech_locl.h
93ech_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
94ech_key.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
95ech_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
96ech_key.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
97ech_key.o: ../../include/openssl/x509_vfy.h ech_key.c ech_locl.h
98ech_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 93ech_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
99ech_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 94ech_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
100ech_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 95ech_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
diff --git a/src/lib/libcrypto/engine/eng_rdrand.c b/src/lib/libcrypto/engine/eng_rdrand.c
index a9ba5ae6f9..4e9e91d54b 100644
--- a/src/lib/libcrypto/engine/eng_rdrand.c
+++ b/src/lib/libcrypto/engine/eng_rdrand.c
@@ -104,6 +104,7 @@ static int bind_helper(ENGINE *e)
104 { 104 {
105 if (!ENGINE_set_id(e, engine_e_rdrand_id) || 105 if (!ENGINE_set_id(e, engine_e_rdrand_id) ||
106 !ENGINE_set_name(e, engine_e_rdrand_name) || 106 !ENGINE_set_name(e, engine_e_rdrand_name) ||
107 !ENGINE_set_flags(e, ENGINE_FLAGS_NO_REGISTER_ALL) ||
107 !ENGINE_set_init_function(e, rdrand_init) || 108 !ENGINE_set_init_function(e, rdrand_init) ||
108 !ENGINE_set_RAND(e, &rdrand_meth) ) 109 !ENGINE_set_RAND(e, &rdrand_meth) )
109 return 0; 110 return 0;
diff --git a/src/lib/libcrypto/mdc2/mdc2dgst.c b/src/lib/libcrypto/mdc2/mdc2dgst.c
index b74bb1a759..d66ed6a1c6 100644
--- a/src/lib/libcrypto/mdc2/mdc2dgst.c
+++ b/src/lib/libcrypto/mdc2/mdc2dgst.c
@@ -59,9 +59,9 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62#include <openssl/crypto.h>
62#include <openssl/des.h> 63#include <openssl/des.h>
63#include <openssl/mdc2.h> 64#include <openssl/mdc2.h>
64#include <openssl/crypto.h>
65 65
66#undef c2l 66#undef c2l
67#define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \ 67#define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \
diff --git a/src/lib/libcrypto/modes/Makefile b/src/lib/libcrypto/modes/Makefile
index c825b12f25..3d8bafd571 100644
--- a/src/lib/libcrypto/modes/Makefile
+++ b/src/lib/libcrypto/modes/Makefile
@@ -53,7 +53,10 @@ ghash-x86_64.s: asm/ghash-x86_64.pl
53ghash-sparcv9.s: asm/ghash-sparcv9.pl 53ghash-sparcv9.s: asm/ghash-sparcv9.pl
54 $(PERL) asm/ghash-sparcv9.pl $@ $(CFLAGS) 54 $(PERL) asm/ghash-sparcv9.pl $@ $(CFLAGS)
55ghash-alpha.s: asm/ghash-alpha.pl 55ghash-alpha.s: asm/ghash-alpha.pl
56 $(PERL) $< | $(CC) -E - | tee $@ > /dev/null 56 (preproc=/tmp/$$$$.$@; trap "rm $$preproc" INT; \
57 $(PERL) asm/ghash-alpha.pl > $$preproc && \
58 $(CC) -E $$preproc > $@ && rm $$preproc)
59
57ghash-parisc.s: asm/ghash-parisc.pl 60ghash-parisc.s: asm/ghash-parisc.pl
58 $(PERL) asm/ghash-parisc.pl $(PERLASM_SCHEME) $@ 61 $(PERL) asm/ghash-parisc.pl $(PERLASM_SCHEME) $@
59 62
diff --git a/src/lib/libcrypto/perlasm/x86masm.pl b/src/lib/libcrypto/perlasm/x86masm.pl
index 96b1b73e1a..f937d07c87 100644
--- a/src/lib/libcrypto/perlasm/x86masm.pl
+++ b/src/lib/libcrypto/perlasm/x86masm.pl
@@ -33,6 +33,7 @@ sub ::generic
33sub ::call { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); } 33sub ::call { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); }
34sub ::call_ptr { &::emit("call",@_); } 34sub ::call_ptr { &::emit("call",@_); }
35sub ::jmp_ptr { &::emit("jmp",@_); } 35sub ::jmp_ptr { &::emit("jmp",@_); }
36sub ::lock { &::data_byte(0xf0); }
36 37
37sub get_mem 38sub get_mem
38{ my($size,$addr,$reg1,$reg2,$idx)=@_; 39{ my($size,$addr,$reg1,$reg2,$idx)=@_;
diff --git a/src/lib/libcrypto/rc5/asm/rc5-586.pl b/src/lib/libcrypto/rc5/asm/rc5-586.pl
index edff1d1e64..61ac6effc6 100644
--- a/src/lib/libcrypto/rc5/asm/rc5-586.pl
+++ b/src/lib/libcrypto/rc5/asm/rc5-586.pl
@@ -1,6 +1,7 @@
1#!/usr/local/bin/perl 1#!/usr/local/bin/perl
2 2
3push(@INC,"perlasm","../../perlasm"); 3$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
4push(@INC,"${dir}","${dir}../../perlasm");
4require "x86asm.pl"; 5require "x86asm.pl";
5require "cbc.pl"; 6require "cbc.pl";
6 7
diff --git a/src/lib/libcrypto/rc5/rc5_ecb.c b/src/lib/libcrypto/rc5/rc5_ecb.c
new file mode 100644
index 0000000000..e72b535507
--- /dev/null
+++ b/src/lib/libcrypto/rc5/rc5_ecb.c
@@ -0,0 +1,80 @@
1/* crypto/rc5/rc5_ecb.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <openssl/rc5.h>
60#include "rc5_locl.h"
61#include <openssl/opensslv.h>
62
63const char RC5_version[]="RC5" OPENSSL_VERSION_PTEXT;
64
65void RC5_32_ecb_encrypt(const unsigned char *in, unsigned char *out,
66 RC5_32_KEY *ks, int encrypt)
67 {
68 unsigned long l,d[2];
69
70 c2l(in,l); d[0]=l;
71 c2l(in,l); d[1]=l;
72 if (encrypt)
73 RC5_32_encrypt(d,ks);
74 else
75 RC5_32_decrypt(d,ks);
76 l=d[0]; l2c(l,out);
77 l=d[1]; l2c(l,out);
78 l=d[0]=d[1]=0;
79 }
80
diff --git a/src/lib/libcrypto/rc5/rc5_enc.c b/src/lib/libcrypto/rc5/rc5_enc.c
new file mode 100644
index 0000000000..f327d32a76
--- /dev/null
+++ b/src/lib/libcrypto/rc5/rc5_enc.c
@@ -0,0 +1,215 @@
1/* crypto/rc5/rc5_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <openssl/rc5.h>
61#include "rc5_locl.h"
62
63void RC5_32_cbc_encrypt(const unsigned char *in, unsigned char *out,
64 long length, RC5_32_KEY *ks, unsigned char *iv,
65 int encrypt)
66 {
67 register unsigned long tin0,tin1;
68 register unsigned long tout0,tout1,xor0,xor1;
69 register long l=length;
70 unsigned long tin[2];
71
72 if (encrypt)
73 {
74 c2l(iv,tout0);
75 c2l(iv,tout1);
76 iv-=8;
77 for (l-=8; l>=0; l-=8)
78 {
79 c2l(in,tin0);
80 c2l(in,tin1);
81 tin0^=tout0;
82 tin1^=tout1;
83 tin[0]=tin0;
84 tin[1]=tin1;
85 RC5_32_encrypt(tin,ks);
86 tout0=tin[0]; l2c(tout0,out);
87 tout1=tin[1]; l2c(tout1,out);
88 }
89 if (l != -8)
90 {
91 c2ln(in,tin0,tin1,l+8);
92 tin0^=tout0;
93 tin1^=tout1;
94 tin[0]=tin0;
95 tin[1]=tin1;
96 RC5_32_encrypt(tin,ks);
97 tout0=tin[0]; l2c(tout0,out);
98 tout1=tin[1]; l2c(tout1,out);
99 }
100 l2c(tout0,iv);
101 l2c(tout1,iv);
102 }
103 else
104 {
105 c2l(iv,xor0);
106 c2l(iv,xor1);
107 iv-=8;
108 for (l-=8; l>=0; l-=8)
109 {
110 c2l(in,tin0); tin[0]=tin0;
111 c2l(in,tin1); tin[1]=tin1;
112 RC5_32_decrypt(tin,ks);
113 tout0=tin[0]^xor0;
114 tout1=tin[1]^xor1;
115 l2c(tout0,out);
116 l2c(tout1,out);
117 xor0=tin0;
118 xor1=tin1;
119 }
120 if (l != -8)
121 {
122 c2l(in,tin0); tin[0]=tin0;
123 c2l(in,tin1); tin[1]=tin1;
124 RC5_32_decrypt(tin,ks);
125 tout0=tin[0]^xor0;
126 tout1=tin[1]^xor1;
127 l2cn(tout0,tout1,out,l+8);
128 xor0=tin0;
129 xor1=tin1;
130 }
131 l2c(xor0,iv);
132 l2c(xor1,iv);
133 }
134 tin0=tin1=tout0=tout1=xor0=xor1=0;
135 tin[0]=tin[1]=0;
136 }
137
138void RC5_32_encrypt(unsigned long *d, RC5_32_KEY *key)
139 {
140 RC5_32_INT a,b,*s;
141
142 s=key->data;
143
144 a=d[0]+s[0];
145 b=d[1]+s[1];
146 E_RC5_32(a,b,s, 2);
147 E_RC5_32(a,b,s, 4);
148 E_RC5_32(a,b,s, 6);
149 E_RC5_32(a,b,s, 8);
150 E_RC5_32(a,b,s,10);
151 E_RC5_32(a,b,s,12);
152 E_RC5_32(a,b,s,14);
153 E_RC5_32(a,b,s,16);
154 if (key->rounds == 12)
155 {
156 E_RC5_32(a,b,s,18);
157 E_RC5_32(a,b,s,20);
158 E_RC5_32(a,b,s,22);
159 E_RC5_32(a,b,s,24);
160 }
161 else if (key->rounds == 16)
162 {
163 /* Do a full expansion to avoid a jump */
164 E_RC5_32(a,b,s,18);
165 E_RC5_32(a,b,s,20);
166 E_RC5_32(a,b,s,22);
167 E_RC5_32(a,b,s,24);
168 E_RC5_32(a,b,s,26);
169 E_RC5_32(a,b,s,28);
170 E_RC5_32(a,b,s,30);
171 E_RC5_32(a,b,s,32);
172 }
173 d[0]=a;
174 d[1]=b;
175 }
176
177void RC5_32_decrypt(unsigned long *d, RC5_32_KEY *key)
178 {
179 RC5_32_INT a,b,*s;
180
181 s=key->data;
182
183 a=d[0];
184 b=d[1];
185 if (key->rounds == 16)
186 {
187 D_RC5_32(a,b,s,32);
188 D_RC5_32(a,b,s,30);
189 D_RC5_32(a,b,s,28);
190 D_RC5_32(a,b,s,26);
191 /* Do a full expansion to avoid a jump */
192 D_RC5_32(a,b,s,24);
193 D_RC5_32(a,b,s,22);
194 D_RC5_32(a,b,s,20);
195 D_RC5_32(a,b,s,18);
196 }
197 else if (key->rounds == 12)
198 {
199 D_RC5_32(a,b,s,24);
200 D_RC5_32(a,b,s,22);
201 D_RC5_32(a,b,s,20);
202 D_RC5_32(a,b,s,18);
203 }
204 D_RC5_32(a,b,s,16);
205 D_RC5_32(a,b,s,14);
206 D_RC5_32(a,b,s,12);
207 D_RC5_32(a,b,s,10);
208 D_RC5_32(a,b,s, 8);
209 D_RC5_32(a,b,s, 6);
210 D_RC5_32(a,b,s, 4);
211 D_RC5_32(a,b,s, 2);
212 d[0]=a-s[0];
213 d[1]=b-s[1];
214 }
215
diff --git a/src/lib/libcrypto/rc5/rc5_skey.c b/src/lib/libcrypto/rc5/rc5_skey.c
new file mode 100644
index 0000000000..a2e00a41c5
--- /dev/null
+++ b/src/lib/libcrypto/rc5/rc5_skey.c
@@ -0,0 +1,113 @@
1/* crypto/rc5/rc5_skey.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <openssl/rc5.h>
60#include "rc5_locl.h"
61
62void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,
63 int rounds)
64 {
65 RC5_32_INT L[64],l,ll,A,B,*S,k;
66 int i,j,m,c,t,ii,jj;
67
68 if ( (rounds != RC5_16_ROUNDS) &&
69 (rounds != RC5_12_ROUNDS) &&
70 (rounds != RC5_8_ROUNDS))
71 rounds=RC5_16_ROUNDS;
72
73 key->rounds=rounds;
74 S= &(key->data[0]);
75 j=0;
76 for (i=0; i<=(len-8); i+=8)
77 {
78 c2l(data,l);
79 L[j++]=l;
80 c2l(data,l);
81 L[j++]=l;
82 }
83 ii=len-i;
84 if (ii)
85 {
86 k=len&0x07;
87 c2ln(data,l,ll,k);
88 L[j+0]=l;
89 L[j+1]=ll;
90 }
91
92 c=(len+3)/4;
93 t=(rounds+1)*2;
94 S[0]=RC5_32_P;
95 for (i=1; i<t; i++)
96 S[i]=(S[i-1]+RC5_32_Q)&RC5_32_MASK;
97
98 j=(t>c)?t:c;
99 j*=3;
100 ii=jj=0;
101 A=B=0;
102 for (i=0; i<j; i++)
103 {
104 k=(S[ii]+A+B)&RC5_32_MASK;
105 A=S[ii]=ROTATE_l32(k,3);
106 m=(int)(A+B);
107 k=(L[jj]+A+B)&RC5_32_MASK;
108 B=L[jj]=ROTATE_l32(k,m);
109 if (++ii >= t) ii=0;
110 if (++jj >= c) jj=0;
111 }
112 }
113
diff --git a/src/lib/libcrypto/rc5/rc5cfb64.c b/src/lib/libcrypto/rc5/rc5cfb64.c
new file mode 100644
index 0000000000..3a8b60bc7a
--- /dev/null
+++ b/src/lib/libcrypto/rc5/rc5cfb64.c
@@ -0,0 +1,122 @@
1/* crypto/rc5/rc5cfb64.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <openssl/rc5.h>
60#include "rc5_locl.h"
61
62/* The input and output encrypted as though 64bit cfb mode is being
63 * used. The extra state information to record how much of the
64 * 64bit block we have used is contained in *num;
65 */
66
67void RC5_32_cfb64_encrypt(const unsigned char *in, unsigned char *out,
68 long length, RC5_32_KEY *schedule,
69 unsigned char *ivec, int *num, int encrypt)
70 {
71 register unsigned long v0,v1,t;
72 register int n= *num;
73 register long l=length;
74 unsigned long ti[2];
75 unsigned char *iv,c,cc;
76
77 iv=(unsigned char *)ivec;
78 if (encrypt)
79 {
80 while (l--)
81 {
82 if (n == 0)
83 {
84 c2l(iv,v0); ti[0]=v0;
85 c2l(iv,v1); ti[1]=v1;
86 RC5_32_encrypt((unsigned long *)ti,schedule);
87 iv=(unsigned char *)ivec;
88 t=ti[0]; l2c(t,iv);
89 t=ti[1]; l2c(t,iv);
90 iv=(unsigned char *)ivec;
91 }
92 c= *(in++)^iv[n];
93 *(out++)=c;
94 iv[n]=c;
95 n=(n+1)&0x07;
96 }
97 }
98 else
99 {
100 while (l--)
101 {
102 if (n == 0)
103 {
104 c2l(iv,v0); ti[0]=v0;
105 c2l(iv,v1); ti[1]=v1;
106 RC5_32_encrypt((unsigned long *)ti,schedule);
107 iv=(unsigned char *)ivec;
108 t=ti[0]; l2c(t,iv);
109 t=ti[1]; l2c(t,iv);
110 iv=(unsigned char *)ivec;
111 }
112 cc= *(in++);
113 c=iv[n];
114 iv[n]=cc;
115 *(out++)=c^cc;
116 n=(n+1)&0x07;
117 }
118 }
119 v0=v1=ti[0]=ti[1]=t=c=cc=0;
120 *num=n;
121 }
122
diff --git a/src/lib/libcrypto/rc5/rc5ofb64.c b/src/lib/libcrypto/rc5/rc5ofb64.c
new file mode 100644
index 0000000000..d412215f3c
--- /dev/null
+++ b/src/lib/libcrypto/rc5/rc5ofb64.c
@@ -0,0 +1,111 @@
1/* crypto/rc5/rc5ofb64.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <openssl/rc5.h>
60#include "rc5_locl.h"
61
62/* The input and output encrypted as though 64bit ofb mode is being
63 * used. The extra state information to record how much of the
64 * 64bit block we have used is contained in *num;
65 */
66void RC5_32_ofb64_encrypt(const unsigned char *in, unsigned char *out,
67 long length, RC5_32_KEY *schedule,
68 unsigned char *ivec, int *num)
69 {
70 register unsigned long v0,v1,t;
71 register int n= *num;
72 register long l=length;
73 unsigned char d[8];
74 register char *dp;
75 unsigned long ti[2];
76 unsigned char *iv;
77 int save=0;
78
79 iv=(unsigned char *)ivec;
80 c2l(iv,v0);
81 c2l(iv,v1);
82 ti[0]=v0;
83 ti[1]=v1;
84 dp=(char *)d;
85 l2c(v0,dp);
86 l2c(v1,dp);
87 while (l--)
88 {
89 if (n == 0)
90 {
91 RC5_32_encrypt((unsigned long *)ti,schedule);
92 dp=(char *)d;
93 t=ti[0]; l2c(t,dp);
94 t=ti[1]; l2c(t,dp);
95 save++;
96 }
97 *(out++)= *(in++)^d[n];
98 n=(n+1)&0x07;
99 }
100 if (save)
101 {
102 v0=ti[0];
103 v1=ti[1];
104 iv=(unsigned char *)ivec;
105 l2c(v0,iv);
106 l2c(v1,iv);
107 }
108 t=v0=v1=ti[0]=ti[1]=0;
109 *num=n;
110 }
111
diff --git a/src/lib/libcrypto/rc5/rc5speed.c b/src/lib/libcrypto/rc5/rc5speed.c
new file mode 100644
index 0000000000..8e363be535
--- /dev/null
+++ b/src/lib/libcrypto/rc5/rc5speed.c
@@ -0,0 +1,277 @@
1/* crypto/rc5/rc5speed.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
61
62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES
64#endif
65
66#include <stdio.h>
67
68#include <openssl/e_os2.h>
69#include OPENSSL_UNISTD_IO
70OPENSSL_DECLARE_EXIT
71
72#ifndef OPENSSL_SYS_NETWARE
73#include <signal.h>
74#endif
75
76#ifndef _IRIX
77#include <time.h>
78#endif
79#ifdef TIMES
80#include <sys/types.h>
81#include <sys/times.h>
82#endif
83
84/* Depending on the VMS version, the tms structure is perhaps defined.
85 The __TMS macro will show if it was. If it wasn't defined, we should
86 undefine TIMES, since that tells the rest of the program how things
87 should be handled. -- Richard Levitte */
88#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
89#undef TIMES
90#endif
91
92#ifndef TIMES
93#include <sys/timeb.h>
94#endif
95
96#if defined(sun) || defined(__ultrix)
97#define _POSIX_SOURCE
98#include <limits.h>
99#include <sys/param.h>
100#endif
101
102#include <openssl/rc5.h>
103
104/* The following if from times(3) man page. It may need to be changed */
105#ifndef HZ
106#ifndef CLK_TCK
107#define HZ 100.0
108#else /* CLK_TCK */
109#define HZ ((double)CLK_TCK)
110#endif
111#endif
112
113#define BUFSIZE ((long)1024)
114long run=0;
115
116double Time_F(int s);
117#ifdef SIGALRM
118#if defined(__STDC__) || defined(sgi) || defined(_AIX)
119#define SIGRETTYPE void
120#else
121#define SIGRETTYPE int
122#endif
123
124SIGRETTYPE sig_done(int sig);
125SIGRETTYPE sig_done(int sig)
126 {
127 signal(SIGALRM,sig_done);
128 run=0;
129#ifdef LINT
130 sig=sig;
131#endif
132 }
133#endif
134
135#define START 0
136#define STOP 1
137
138double Time_F(int s)
139 {
140 double ret;
141#ifdef TIMES
142 static struct tms tstart,tend;
143
144 if (s == START)
145 {
146 times(&tstart);
147 return(0);
148 }
149 else
150 {
151 times(&tend);
152 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
153 return((ret == 0.0)?1e-6:ret);
154 }
155#else /* !times() */
156 static struct timeb tstart,tend;
157 long i;
158
159 if (s == START)
160 {
161 ftime(&tstart);
162 return(0);
163 }
164 else
165 {
166 ftime(&tend);
167 i=(long)tend.millitm-(long)tstart.millitm;
168 ret=((double)(tend.time-tstart.time))+((double)i)/1e3;
169 return((ret == 0.0)?1e-6:ret);
170 }
171#endif
172 }
173
174int main(int argc, char **argv)
175 {
176 long count;
177 static unsigned char buf[BUFSIZE];
178 static unsigned char key[] ={
179 0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
180 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10,
181 };
182 RC5_32_KEY sch;
183 double a,b,c,d;
184#ifndef SIGALRM
185 long ca,cb,cc;
186#endif
187
188#ifndef TIMES
189 printf("To get the most accurate results, try to run this\n");
190 printf("program when this computer is idle.\n");
191#endif
192
193#ifndef SIGALRM
194 printf("First we calculate the approximate speed ...\n");
195 RC5_32_set_key(&sch,16,key,12);
196 count=10;
197 do {
198 long i;
199 unsigned long data[2];
200
201 count*=2;
202 Time_F(START);
203 for (i=count; i; i--)
204 RC5_32_encrypt(data,&sch);
205 d=Time_F(STOP);
206 } while (d < 3.0);
207 ca=count/512;
208 cb=count;
209 cc=count*8/BUFSIZE+1;
210 printf("Doing RC5_32_set_key %ld times\n",ca);
211#define COND(d) (count != (d))
212#define COUNT(d) (d)
213#else
214#define COND(c) (run)
215#define COUNT(d) (count)
216 signal(SIGALRM,sig_done);
217 printf("Doing RC5_32_set_key for 10 seconds\n");
218 alarm(10);
219#endif
220
221 Time_F(START);
222 for (count=0,run=1; COND(ca); count+=4)
223 {
224 RC5_32_set_key(&sch,16,key,12);
225 RC5_32_set_key(&sch,16,key,12);
226 RC5_32_set_key(&sch,16,key,12);
227 RC5_32_set_key(&sch,16,key,12);
228 }
229 d=Time_F(STOP);
230 printf("%ld RC5_32_set_key's in %.2f seconds\n",count,d);
231 a=((double)COUNT(ca))/d;
232
233#ifdef SIGALRM
234 printf("Doing RC5_32_encrypt's for 10 seconds\n");
235 alarm(10);
236#else
237 printf("Doing RC5_32_encrypt %ld times\n",cb);
238#endif
239 Time_F(START);
240 for (count=0,run=1; COND(cb); count+=4)
241 {
242 unsigned long data[2];
243
244 RC5_32_encrypt(data,&sch);
245 RC5_32_encrypt(data,&sch);
246 RC5_32_encrypt(data,&sch);
247 RC5_32_encrypt(data,&sch);
248 }
249 d=Time_F(STOP);
250 printf("%ld RC5_32_encrypt's in %.2f second\n",count,d);
251 b=((double)COUNT(cb)*8)/d;
252
253#ifdef SIGALRM
254 printf("Doing RC5_32_cbc_encrypt on %ld byte blocks for 10 seconds\n",
255 BUFSIZE);
256 alarm(10);
257#else
258 printf("Doing RC5_32_cbc_encrypt %ld times on %ld byte blocks\n",cc,
259 BUFSIZE);
260#endif
261 Time_F(START);
262 for (count=0,run=1; COND(cc); count++)
263 RC5_32_cbc_encrypt(buf,buf,BUFSIZE,&sch,
264 &(key[0]),RC5_ENCRYPT);
265 d=Time_F(STOP);
266 printf("%ld RC5_32_cbc_encrypt's of %ld byte blocks in %.2f second\n",
267 count,BUFSIZE,d);
268 c=((double)COUNT(cc)*BUFSIZE)/d;
269
270 printf("RC5_32/12/16 set_key per sec = %12.2f (%9.3fuS)\n",a,1.0e6/a);
271 printf("RC5_32/12/16 raw ecb bytes per sec = %12.2f (%9.3fuS)\n",b,8.0e6/b);
272 printf("RC5_32/12/16 cbc bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c);
273 exit(0);
274#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
275 return(0);
276#endif
277 }
diff --git a/src/lib/libcrypto/srp/srp_grps.h b/src/lib/libcrypto/srp/srp_grps.h
index d77c9fff4b..8e3c35e3f5 100644
--- a/src/lib/libcrypto/srp/srp_grps.h
+++ b/src/lib/libcrypto/srp/srp_grps.h
@@ -1,22 +1,22 @@
1/* start of generated data */ 1/* start of generated data */
2 2
3static BN_ULONG bn_group_1024_value[] = { 3static BN_ULONG bn_group_1024_value[] = {
4 bn_pack4(9FC6,1D2F,C0EB,06E3), 4 bn_pack4(0x9FC6,0x1D2F,0xC0EB,0x06E3),
5 bn_pack4(FD51,38FE,8376,435B), 5 bn_pack4(0xFD51,0x38FE,0x8376,0x435B),
6 bn_pack4(2FD4,CBF4,976E,AA9A), 6 bn_pack4(0x2FD4,0xCBF4,0x976E,0xAA9A),
7 bn_pack4(68ED,BC3C,0572,6CC0), 7 bn_pack4(0x68ED,0xBC3C,0x0572,0x6CC0),
8 bn_pack4(C529,F566,660E,57EC), 8 bn_pack4(0xC529,0xF566,0x660E,0x57EC),
9 bn_pack4(8255,9B29,7BCF,1885), 9 bn_pack4(0x8255,0x9B29,0x7BCF,0x1885),
10 bn_pack4(CE8E,F4AD,69B1,5D49), 10 bn_pack4(0xCE8E,0xF4AD,0x69B1,0x5D49),
11 bn_pack4(5DC7,D7B4,6154,D6B6), 11 bn_pack4(0x5DC7,0xD7B4,0x6154,0xD6B6),
12 bn_pack4(8E49,5C1D,6089,DAD1), 12 bn_pack4(0x8E49,0x5C1D,0x6089,0xDAD1),
13 bn_pack4(E0D5,D8E2,50B9,8BE4), 13 bn_pack4(0xE0D5,0xD8E2,0x50B9,0x8BE4),
14 bn_pack4(383B,4813,D692,C6E0), 14 bn_pack4(0x383B,0x4813,0xD692,0xC6E0),
15 bn_pack4(D674,DF74,96EA,81D3), 15 bn_pack4(0xD674,0xDF74,0x96EA,0x81D3),
16 bn_pack4(9EA2,314C,9C25,6576), 16 bn_pack4(0x9EA2,0x314C,0x9C25,0x6576),
17 bn_pack4(6072,6187,75FF,3C0B), 17 bn_pack4(0x6072,0x6187,0x75FF,0x3C0B),
18 bn_pack4(9C33,F80A,FA8F,C5E8), 18 bn_pack4(0x9C33,0xF80A,0xFA8F,0xC5E8),
19 bn_pack4(EEAF,0AB9,ADB3,8DD6) 19 bn_pack4(0xEEAF,0x0AB9,0xADB3,0x8DD6)
20}; 20};
21static BIGNUM bn_group_1024 = { 21static BIGNUM bn_group_1024 = {
22 bn_group_1024_value, 22 bn_group_1024_value,
@@ -27,30 +27,30 @@ static BIGNUM bn_group_1024 = {
27}; 27};
28 28
29static BN_ULONG bn_group_1536_value[] = { 29static BN_ULONG bn_group_1536_value[] = {
30 bn_pack4(CF76,E3FE,D135,F9BB), 30 bn_pack4(0xCF76,0xE3FE,0xD135,0xF9BB),
31 bn_pack4(1518,0F93,499A,234D), 31 bn_pack4(0x1518,0x0F93,0x499A,0x234D),
32 bn_pack4(8CE7,A28C,2442,C6F3), 32 bn_pack4(0x8CE7,0xA28C,0x2442,0xC6F3),
33 bn_pack4(5A02,1FFF,5E91,479E), 33 bn_pack4(0x5A02,0x1FFF,0x5E91,0x479E),
34 bn_pack4(7F8A,2FE9,B8B5,292E), 34 bn_pack4(0x7F8A,0x2FE9,0xB8B5,0x292E),
35 bn_pack4(837C,264A,E3A9,BEB8), 35 bn_pack4(0x837C,0x264A,0xE3A9,0xBEB8),
36 bn_pack4(E442,734A,F7CC,B7AE), 36 bn_pack4(0xE442,0x734A,0xF7CC,0xB7AE),
37 bn_pack4(6577,2E43,7D6C,7F8C), 37 bn_pack4(0x6577,0x2E43,0x7D6C,0x7F8C),
38 bn_pack4(DB2F,D53D,24B7,C486), 38 bn_pack4(0xDB2F,0xD53D,0x24B7,0xC486),
39 bn_pack4(6EDF,0195,3934,9627), 39 bn_pack4(0x6EDF,0x0195,0x3934,0x9627),
40 bn_pack4(158B,FD3E,2B9C,8CF5), 40 bn_pack4(0x158B,0xFD3E,0x2B9C,0x8CF5),
41 bn_pack4(764E,3F4B,53DD,9DA1), 41 bn_pack4(0x764E,0x3F4B,0x53DD,0x9DA1),
42 bn_pack4(4754,8381,DBC5,B1FC), 42 bn_pack4(0x4754,0x8381,0xDBC5,0xB1FC),
43 bn_pack4(9B60,9E0B,E3BA,B63D), 43 bn_pack4(0x9B60,0x9E0B,0xE3BA,0xB63D),
44 bn_pack4(8134,B1C8,B979,8914), 44 bn_pack4(0x8134,0xB1C8,0xB979,0x8914),
45 bn_pack4(DF02,8A7C,EC67,F0D0), 45 bn_pack4(0xDF02,0x8A7C,0xEC67,0xF0D0),
46 bn_pack4(80B6,55BB,9A22,E8DC), 46 bn_pack4(0x80B6,0x55BB,0x9A22,0xE8DC),
47 bn_pack4(1558,903B,A0D0,F843), 47 bn_pack4(0x1558,0x903B,0xA0D0,0xF843),
48 bn_pack4(51C6,A94B,E460,7A29), 48 bn_pack4(0x51C6,0xA94B,0xE460,0x7A29),
49 bn_pack4(5F4F,5F55,6E27,CBDE), 49 bn_pack4(0x5F4F,0x5F55,0x6E27,0xCBDE),
50 bn_pack4(BEEE,A961,4B19,CC4D), 50 bn_pack4(0xBEEE,0xA961,0x4B19,0xCC4D),
51 bn_pack4(DBA5,1DF4,99AC,4C80), 51 bn_pack4(0xDBA5,0x1DF4,0x99AC,0x4C80),
52 bn_pack4(B1F1,2A86,17A4,7BBB), 52 bn_pack4(0xB1F1,0x2A86,0x17A4,0x7BBB),
53 bn_pack4(9DEF,3CAF,B939,277A) 53 bn_pack4(0x9DEF,0x3CAF,0xB939,0x277A)
54}; 54};
55static BIGNUM bn_group_1536 = { 55static BIGNUM bn_group_1536 = {
56 bn_group_1536_value, 56 bn_group_1536_value,
@@ -61,38 +61,38 @@ static BIGNUM bn_group_1536 = {
61}; 61};
62 62
63static BN_ULONG bn_group_2048_value[] = { 63static BN_ULONG bn_group_2048_value[] = {
64 bn_pack4(0FA7,111F,9E4A,FF73), 64 bn_pack4(0x0FA7,0x111F,0x9E4A,0xFF73),
65 bn_pack4(9B65,E372,FCD6,8EF2), 65 bn_pack4(0x9B65,0xE372,0xFCD6,0x8EF2),
66 bn_pack4(35DE,236D,525F,5475), 66 bn_pack4(0x35DE,0x236D,0x525F,0x5475),
67 bn_pack4(94B5,C803,D89F,7AE4), 67 bn_pack4(0x94B5,0xC803,0xD89F,0x7AE4),
68 bn_pack4(71AE,35F8,E9DB,FBB6), 68 bn_pack4(0x71AE,0x35F8,0xE9DB,0xFBB6),
69 bn_pack4(2A56,98F3,A8D0,C382), 69 bn_pack4(0x2A56,0x98F3,0xA8D0,0xC382),
70 bn_pack4(9CCC,041C,7BC3,08D8), 70 bn_pack4(0x9CCC,0x041C,0x7BC3,0x08D8),
71 bn_pack4(AF87,4E73,03CE,5329), 71 bn_pack4(0xAF87,0x4E73,0x03CE,0x5329),
72 bn_pack4(6160,2790,04E5,7AE6), 72 bn_pack4(0x6160,0x2790,0x04E5,0x7AE6),
73 bn_pack4(032C,FBDB,F52F,B378), 73 bn_pack4(0x032C,0xFBDB,0xF52F,0xB378),
74 bn_pack4(5EA7,7A27,75D2,ECFA), 74 bn_pack4(0x5EA7,0x7A27,0x75D2,0xECFA),
75 bn_pack4(5445,23B5,24B0,D57D), 75 bn_pack4(0x5445,0x23B5,0x24B0,0xD57D),
76 bn_pack4(5B9D,32E6,88F8,7748), 76 bn_pack4(0x5B9D,0x32E6,0x88F8,0x7748),
77 bn_pack4(F1D2,B907,8717,461A), 77 bn_pack4(0xF1D2,0xB907,0x8717,0x461A),
78 bn_pack4(76BD,207A,436C,6481), 78 bn_pack4(0x76BD,0x207A,0x436C,0x6481),
79 bn_pack4(CA97,B43A,23FB,8016), 79 bn_pack4(0xCA97,0xB43A,0x23FB,0x8016),
80 bn_pack4(1D28,1E44,6B14,773B), 80 bn_pack4(0x1D28,0x1E44,0x6B14,0x773B),
81 bn_pack4(7359,D041,D5C3,3EA7), 81 bn_pack4(0x7359,0xD041,0xD5C3,0x3EA7),
82 bn_pack4(A80D,740A,DBF4,FF74), 82 bn_pack4(0xA80D,0x740A,0xDBF4,0xFF74),
83 bn_pack4(55F9,7993,EC97,5EEA), 83 bn_pack4(0x55F9,0x7993,0xEC97,0x5EEA),
84 bn_pack4(2918,A996,2F0B,93B8), 84 bn_pack4(0x2918,0xA996,0x2F0B,0x93B8),
85 bn_pack4(661A,05FB,D5FA,AAE8), 85 bn_pack4(0x661A,0x05FB,0xD5FA,0xAAE8),
86 bn_pack4(CF60,9517,9A16,3AB3), 86 bn_pack4(0xCF60,0x9517,0x9A16,0x3AB3),
87 bn_pack4(E808,3969,EDB7,67B0), 87 bn_pack4(0xE808,0x3969,0xEDB7,0x67B0),
88 bn_pack4(CD7F,48A9,DA04,FD50), 88 bn_pack4(0xCD7F,0x48A9,0xDA04,0xFD50),
89 bn_pack4(D523,12AB,4B03,310D), 89 bn_pack4(0xD523,0x12AB,0x4B03,0x310D),
90 bn_pack4(8193,E075,7767,A13D), 90 bn_pack4(0x8193,0xE075,0x7767,0xA13D),
91 bn_pack4(A373,29CB,B4A0,99ED), 91 bn_pack4(0xA373,0x29CB,0xB4A0,0x99ED),
92 bn_pack4(FC31,9294,3DB5,6050), 92 bn_pack4(0xFC31,0x9294,0x3DB5,0x6050),
93 bn_pack4(AF72,B665,1987,EE07), 93 bn_pack4(0xAF72,0xB665,0x1987,0xEE07),
94 bn_pack4(F166,DE5E,1389,582F), 94 bn_pack4(0xF166,0xDE5E,0x1389,0x582F),
95 bn_pack4(AC6B,DB41,324A,9A9B) 95 bn_pack4(0xAC6B,0xDB41,0x324A,0x9A9B)
96}; 96};
97static BIGNUM bn_group_2048 = { 97static BIGNUM bn_group_2048 = {
98 bn_group_2048_value, 98 bn_group_2048_value,
@@ -103,54 +103,54 @@ static BIGNUM bn_group_2048 = {
103}; 103};
104 104
105static BN_ULONG bn_group_3072_value[] = { 105static BN_ULONG bn_group_3072_value[] = {
106 bn_pack4(FFFF,FFFF,FFFF,FFFF), 106 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF),
107 bn_pack4(4B82,D120,A93A,D2CA), 107 bn_pack4(0x4B82,0xD120,0xA93A,0xD2CA),
108 bn_pack4(43DB,5BFC,E0FD,108E), 108 bn_pack4(0x43DB,0x5BFC,0xE0FD,0x108E),
109 bn_pack4(08E2,4FA0,74E5,AB31), 109 bn_pack4(0x08E2,0x4FA0,0x74E5,0xAB31),
110 bn_pack4(7709,88C0,BAD9,46E2), 110 bn_pack4(0x7709,0x88C0,0xBAD9,0x46E2),
111 bn_pack4(BBE1,1757,7A61,5D6C), 111 bn_pack4(0xBBE1,0x1757,0x7A61,0x5D6C),
112 bn_pack4(521F,2B18,177B,200C), 112 bn_pack4(0x521F,0x2B18,0x177B,0x200C),
113 bn_pack4(D876,0273,3EC8,6A64), 113 bn_pack4(0xD876,0x0273,0x3EC8,0x6A64),
114 bn_pack4(F12F,FA06,D98A,0864), 114 bn_pack4(0xF12F,0xFA06,0xD98A,0x0864),
115 bn_pack4(CEE3,D226,1AD2,EE6B), 115 bn_pack4(0xCEE3,0xD226,0x1AD2,0xEE6B),
116 bn_pack4(1E8C,94E0,4A25,619D), 116 bn_pack4(0x1E8C,0x94E0,0x4A25,0x619D),
117 bn_pack4(ABF5,AE8C,DB09,33D7), 117 bn_pack4(0xABF5,0xAE8C,0xDB09,0x33D7),
118 bn_pack4(B397,0F85,A6E1,E4C7), 118 bn_pack4(0xB397,0x0F85,0xA6E1,0xE4C7),
119 bn_pack4(8AEA,7157,5D06,0C7D), 119 bn_pack4(0x8AEA,0x7157,0x5D06,0x0C7D),
120 bn_pack4(ECFB,8504,58DB,EF0A), 120 bn_pack4(0xECFB,0x8504,0x58DB,0xEF0A),
121 bn_pack4(A855,21AB,DF1C,BA64), 121 bn_pack4(0xA855,0x21AB,0xDF1C,0xBA64),
122 bn_pack4(AD33,170D,0450,7A33), 122 bn_pack4(0xAD33,0x170D,0x0450,0x7A33),
123 bn_pack4(1572,8E5A,8AAA,C42D), 123 bn_pack4(0x1572,0x8E5A,0x8AAA,0xC42D),
124 bn_pack4(15D2,2618,98FA,0510), 124 bn_pack4(0x15D2,0x2618,0x98FA,0x0510),
125 bn_pack4(3995,497C,EA95,6AE5), 125 bn_pack4(0x3995,0x497C,0xEA95,0x6AE5),
126 bn_pack4(DE2B,CBF6,9558,1718), 126 bn_pack4(0xDE2B,0xCBF6,0x9558,0x1718),
127 bn_pack4(B5C5,5DF0,6F4C,52C9), 127 bn_pack4(0xB5C5,0x5DF0,0x6F4C,0x52C9),
128 bn_pack4(9B27,83A2,EC07,A28F), 128 bn_pack4(0x9B27,0x83A2,0xEC07,0xA28F),
129 bn_pack4(E39E,772C,180E,8603), 129 bn_pack4(0xE39E,0x772C,0x180E,0x8603),
130 bn_pack4(3290,5E46,2E36,CE3B), 130 bn_pack4(0x3290,0x5E46,0x2E36,0xCE3B),
131 bn_pack4(F174,6C08,CA18,217C), 131 bn_pack4(0xF174,0x6C08,0xCA18,0x217C),
132 bn_pack4(670C,354E,4ABC,9804), 132 bn_pack4(0x670C,0x354E,0x4ABC,0x9804),
133 bn_pack4(9ED5,2907,7096,966D), 133 bn_pack4(0x9ED5,0x2907,0x7096,0x966D),
134 bn_pack4(1C62,F356,2085,52BB), 134 bn_pack4(0x1C62,0xF356,0x2085,0x52BB),
135 bn_pack4(8365,5D23,DCA3,AD96), 135 bn_pack4(0x8365,0x5D23,0xDCA3,0xAD96),
136 bn_pack4(6916,3FA8,FD24,CF5F), 136 bn_pack4(0x6916,0x3FA8,0xFD24,0xCF5F),
137 bn_pack4(98DA,4836,1C55,D39A), 137 bn_pack4(0x98DA,0x4836,0x1C55,0xD39A),
138 bn_pack4(C200,7CB8,A163,BF05), 138 bn_pack4(0xC200,0x7CB8,0xA163,0xBF05),
139 bn_pack4(4928,6651,ECE4,5B3D), 139 bn_pack4(0x4928,0x6651,0xECE4,0x5B3D),
140 bn_pack4(AE9F,2411,7C4B,1FE6), 140 bn_pack4(0xAE9F,0x2411,0x7C4B,0x1FE6),
141 bn_pack4(EE38,6BFB,5A89,9FA5), 141 bn_pack4(0xEE38,0x6BFB,0x5A89,0x9FA5),
142 bn_pack4(0BFF,5CB6,F406,B7ED), 142 bn_pack4(0x0BFF,0x5CB6,0xF406,0xB7ED),
143 bn_pack4(F44C,42E9,A637,ED6B), 143 bn_pack4(0xF44C,0x42E9,0xA637,0xED6B),
144 bn_pack4(E485,B576,625E,7EC6), 144 bn_pack4(0xE485,0xB576,0x625E,0x7EC6),
145 bn_pack4(4FE1,356D,6D51,C245), 145 bn_pack4(0x4FE1,0x356D,0x6D51,0xC245),
146 bn_pack4(302B,0A6D,F25F,1437), 146 bn_pack4(0x302B,0x0A6D,0xF25F,0x1437),
147 bn_pack4(EF95,19B3,CD3A,431B), 147 bn_pack4(0xEF95,0x19B3,0xCD3A,0x431B),
148 bn_pack4(514A,0879,8E34,04DD), 148 bn_pack4(0x514A,0x0879,0x8E34,0x04DD),
149 bn_pack4(020B,BEA6,3B13,9B22), 149 bn_pack4(0x020B,0xBEA6,0x3B13,0x9B22),
150 bn_pack4(2902,4E08,8A67,CC74), 150 bn_pack4(0x2902,0x4E08,0x8A67,0xCC74),
151 bn_pack4(C4C6,628B,80DC,1CD1), 151 bn_pack4(0xC4C6,0x628B,0x80DC,0x1CD1),
152 bn_pack4(C90F,DAA2,2168,C234), 152 bn_pack4(0xC90F,0xDAA2,0x2168,0xC234),
153 bn_pack4(FFFF,FFFF,FFFF,FFFF) 153 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF)
154}; 154};
155static BIGNUM bn_group_3072 = { 155static BIGNUM bn_group_3072 = {
156 bn_group_3072_value, 156 bn_group_3072_value,
@@ -161,70 +161,70 @@ static BIGNUM bn_group_3072 = {
161}; 161};
162 162
163static BN_ULONG bn_group_4096_value[] = { 163static BN_ULONG bn_group_4096_value[] = {
164 bn_pack4(FFFF,FFFF,FFFF,FFFF), 164 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF),
165 bn_pack4(4DF4,35C9,3406,3199), 165 bn_pack4(0x4DF4,0x35C9,0x3406,0x3199),
166 bn_pack4(86FF,B7DC,90A6,C08F), 166 bn_pack4(0x86FF,0xB7DC,0x90A6,0xC08F),
167 bn_pack4(93B4,EA98,8D8F,DDC1), 167 bn_pack4(0x93B4,0xEA98,0x8D8F,0xDDC1),
168 bn_pack4(D006,9127,D5B0,5AA9), 168 bn_pack4(0xD006,0x9127,0xD5B0,0x5AA9),
169 bn_pack4(B81B,DD76,2170,481C), 169 bn_pack4(0xB81B,0xDD76,0x2170,0x481C),
170 bn_pack4(1F61,2970,CEE2,D7AF), 170 bn_pack4(0x1F61,0x2970,0xCEE2,0xD7AF),
171 bn_pack4(233B,A186,515B,E7ED), 171 bn_pack4(0x233B,0xA186,0x515B,0xE7ED),
172 bn_pack4(99B2,964F,A090,C3A2), 172 bn_pack4(0x99B2,0x964F,0xA090,0xC3A2),
173 bn_pack4(287C,5947,4E6B,C05D), 173 bn_pack4(0x287C,0x5947,0x4E6B,0xC05D),
174 bn_pack4(2E8E,FC14,1FBE,CAA6), 174 bn_pack4(0x2E8E,0xFC14,0x1FBE,0xCAA6),
175 bn_pack4(DBBB,C2DB,04DE,8EF9), 175 bn_pack4(0xDBBB,0xC2DB,0x04DE,0x8EF9),
176 bn_pack4(2583,E9CA,2AD4,4CE8), 176 bn_pack4(0x2583,0xE9CA,0x2AD4,0x4CE8),
177 bn_pack4(1A94,6834,B615,0BDA), 177 bn_pack4(0x1A94,0x6834,0xB615,0x0BDA),
178 bn_pack4(99C3,2718,6AF4,E23C), 178 bn_pack4(0x99C3,0x2718,0x6AF4,0xE23C),
179 bn_pack4(8871,9A10,BDBA,5B26), 179 bn_pack4(0x8871,0x9A10,0xBDBA,0x5B26),
180 bn_pack4(1A72,3C12,A787,E6D7), 180 bn_pack4(0x1A72,0x3C12,0xA787,0xE6D7),
181 bn_pack4(4B82,D120,A921,0801), 181 bn_pack4(0x4B82,0xD120,0xA921,0x0801),
182 bn_pack4(43DB,5BFC,E0FD,108E), 182 bn_pack4(0x43DB,0x5BFC,0xE0FD,0x108E),
183 bn_pack4(08E2,4FA0,74E5,AB31), 183 bn_pack4(0x08E2,0x4FA0,0x74E5,0xAB31),
184 bn_pack4(7709,88C0,BAD9,46E2), 184 bn_pack4(0x7709,0x88C0,0xBAD9,0x46E2),
185 bn_pack4(BBE1,1757,7A61,5D6C), 185 bn_pack4(0xBBE1,0x1757,0x7A61,0x5D6C),
186 bn_pack4(521F,2B18,177B,200C), 186 bn_pack4(0x521F,0x2B18,0x177B,0x200C),
187 bn_pack4(D876,0273,3EC8,6A64), 187 bn_pack4(0xD876,0x0273,0x3EC8,0x6A64),
188 bn_pack4(F12F,FA06,D98A,0864), 188 bn_pack4(0xF12F,0xFA06,0xD98A,0x0864),
189 bn_pack4(CEE3,D226,1AD2,EE6B), 189 bn_pack4(0xCEE3,0xD226,0x1AD2,0xEE6B),
190 bn_pack4(1E8C,94E0,4A25,619D), 190 bn_pack4(0x1E8C,0x94E0,0x4A25,0x619D),
191 bn_pack4(ABF5,AE8C,DB09,33D7), 191 bn_pack4(0xABF5,0xAE8C,0xDB09,0x33D7),
192 bn_pack4(B397,0F85,A6E1,E4C7), 192 bn_pack4(0xB397,0x0F85,0xA6E1,0xE4C7),
193 bn_pack4(8AEA,7157,5D06,0C7D), 193 bn_pack4(0x8AEA,0x7157,0x5D06,0x0C7D),
194 bn_pack4(ECFB,8504,58DB,EF0A), 194 bn_pack4(0xECFB,0x8504,0x58DB,0xEF0A),
195 bn_pack4(A855,21AB,DF1C,BA64), 195 bn_pack4(0xA855,0x21AB,0xDF1C,0xBA64),
196 bn_pack4(AD33,170D,0450,7A33), 196 bn_pack4(0xAD33,0x170D,0x0450,0x7A33),
197 bn_pack4(1572,8E5A,8AAA,C42D), 197 bn_pack4(0x1572,0x8E5A,0x8AAA,0xC42D),
198 bn_pack4(15D2,2618,98FA,0510), 198 bn_pack4(0x15D2,0x2618,0x98FA,0x0510),
199 bn_pack4(3995,497C,EA95,6AE5), 199 bn_pack4(0x3995,0x497C,0xEA95,0x6AE5),
200 bn_pack4(DE2B,CBF6,9558,1718), 200 bn_pack4(0xDE2B,0xCBF6,0x9558,0x1718),
201 bn_pack4(B5C5,5DF0,6F4C,52C9), 201 bn_pack4(0xB5C5,0x5DF0,0x6F4C,0x52C9),
202 bn_pack4(9B27,83A2,EC07,A28F), 202 bn_pack4(0x9B27,0x83A2,0xEC07,0xA28F),
203 bn_pack4(E39E,772C,180E,8603), 203 bn_pack4(0xE39E,0x772C,0x180E,0x8603),
204 bn_pack4(3290,5E46,2E36,CE3B), 204 bn_pack4(0x3290,0x5E46,0x2E36,0xCE3B),
205 bn_pack4(F174,6C08,CA18,217C), 205 bn_pack4(0xF174,0x6C08,0xCA18,0x217C),
206 bn_pack4(670C,354E,4ABC,9804), 206 bn_pack4(0x670C,0x354E,0x4ABC,0x9804),
207 bn_pack4(9ED5,2907,7096,966D), 207 bn_pack4(0x9ED5,0x2907,0x7096,0x966D),
208 bn_pack4(1C62,F356,2085,52BB), 208 bn_pack4(0x1C62,0xF356,0x2085,0x52BB),
209 bn_pack4(8365,5D23,DCA3,AD96), 209 bn_pack4(0x8365,0x5D23,0xDCA3,0xAD96),
210 bn_pack4(6916,3FA8,FD24,CF5F), 210 bn_pack4(0x6916,0x3FA8,0xFD24,0xCF5F),
211 bn_pack4(98DA,4836,1C55,D39A), 211 bn_pack4(0x98DA,0x4836,0x1C55,0xD39A),
212 bn_pack4(C200,7CB8,A163,BF05), 212 bn_pack4(0xC200,0x7CB8,0xA163,0xBF05),
213 bn_pack4(4928,6651,ECE4,5B3D), 213 bn_pack4(0x4928,0x6651,0xECE4,0x5B3D),
214 bn_pack4(AE9F,2411,7C4B,1FE6), 214 bn_pack4(0xAE9F,0x2411,0x7C4B,0x1FE6),
215 bn_pack4(EE38,6BFB,5A89,9FA5), 215 bn_pack4(0xEE38,0x6BFB,0x5A89,0x9FA5),
216 bn_pack4(0BFF,5CB6,F406,B7ED), 216 bn_pack4(0x0BFF,0x5CB6,0xF406,0xB7ED),
217 bn_pack4(F44C,42E9,A637,ED6B), 217 bn_pack4(0xF44C,0x42E9,0xA637,0xED6B),
218 bn_pack4(E485,B576,625E,7EC6), 218 bn_pack4(0xE485,0xB576,0x625E,0x7EC6),
219 bn_pack4(4FE1,356D,6D51,C245), 219 bn_pack4(0x4FE1,0x356D,0x6D51,0xC245),
220 bn_pack4(302B,0A6D,F25F,1437), 220 bn_pack4(0x302B,0x0A6D,0xF25F,0x1437),
221 bn_pack4(EF95,19B3,CD3A,431B), 221 bn_pack4(0xEF95,0x19B3,0xCD3A,0x431B),
222 bn_pack4(514A,0879,8E34,04DD), 222 bn_pack4(0x514A,0x0879,0x8E34,0x04DD),
223 bn_pack4(020B,BEA6,3B13,9B22), 223 bn_pack4(0x020B,0xBEA6,0x3B13,0x9B22),
224 bn_pack4(2902,4E08,8A67,CC74), 224 bn_pack4(0x2902,0x4E08,0x8A67,0xCC74),
225 bn_pack4(C4C6,628B,80DC,1CD1), 225 bn_pack4(0xC4C6,0x628B,0x80DC,0x1CD1),
226 bn_pack4(C90F,DAA2,2168,C234), 226 bn_pack4(0xC90F,0xDAA2,0x2168,0xC234),
227 bn_pack4(FFFF,FFFF,FFFF,FFFF) 227 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF)
228}; 228};
229static BIGNUM bn_group_4096 = { 229static BIGNUM bn_group_4096 = {
230 bn_group_4096_value, 230 bn_group_4096_value,
@@ -235,102 +235,102 @@ static BIGNUM bn_group_4096 = {
235}; 235};
236 236
237static BN_ULONG bn_group_6144_value[] = { 237static BN_ULONG bn_group_6144_value[] = {
238 bn_pack4(FFFF,FFFF,FFFF,FFFF), 238 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF),
239 bn_pack4(E694,F91E,6DCC,4024), 239 bn_pack4(0xE694,0xF91E,0x6DCC,0x4024),
240 bn_pack4(12BF,2D5B,0B74,74D6), 240 bn_pack4(0x12BF,0x2D5B,0x0B74,0x74D6),
241 bn_pack4(043E,8F66,3F48,60EE), 241 bn_pack4(0x043E,0x8F66,0x3F48,0x60EE),
242 bn_pack4(387F,E8D7,6E3C,0468), 242 bn_pack4(0x387F,0xE8D7,0x6E3C,0x0468),
243 bn_pack4(DA56,C9EC,2EF2,9632), 243 bn_pack4(0xDA56,0xC9EC,0x2EF2,0x9632),
244 bn_pack4(EB19,CCB1,A313,D55C), 244 bn_pack4(0xEB19,0xCCB1,0xA313,0xD55C),
245 bn_pack4(F550,AA3D,8A1F,BFF0), 245 bn_pack4(0xF550,0xAA3D,0x8A1F,0xBFF0),
246 bn_pack4(06A1,D58B,B7C5,DA76), 246 bn_pack4(0x06A1,0xD58B,0xB7C5,0xDA76),
247 bn_pack4(A797,15EE,F29B,E328), 247 bn_pack4(0xA797,0x15EE,0xF29B,0xE328),
248 bn_pack4(14CC,5ED2,0F80,37E0), 248 bn_pack4(0x14CC,0x5ED2,0x0F80,0x37E0),
249 bn_pack4(CC8F,6D7E,BF48,E1D8), 249 bn_pack4(0xCC8F,0x6D7E,0xBF48,0xE1D8),
250 bn_pack4(4BD4,07B2,2B41,54AA), 250 bn_pack4(0x4BD4,0x07B2,0x2B41,0x54AA),
251 bn_pack4(0F1D,45B7,FF58,5AC5), 251 bn_pack4(0x0F1D,0x45B7,0xFF58,0x5AC5),
252 bn_pack4(23A9,7A7E,36CC,88BE), 252 bn_pack4(0x23A9,0x7A7E,0x36CC,0x88BE),
253 bn_pack4(59E7,C97F,BEC7,E8F3), 253 bn_pack4(0x59E7,0xC97F,0xBEC7,0xE8F3),
254 bn_pack4(B5A8,4031,900B,1C9E), 254 bn_pack4(0xB5A8,0x4031,0x900B,0x1C9E),
255 bn_pack4(D55E,702F,4698,0C82), 255 bn_pack4(0xD55E,0x702F,0x4698,0x0C82),
256 bn_pack4(F482,D7CE,6E74,FEF6), 256 bn_pack4(0xF482,0xD7CE,0x6E74,0xFEF6),
257 bn_pack4(F032,EA15,D172,1D03), 257 bn_pack4(0xF032,0xEA15,0xD172,0x1D03),
258 bn_pack4(5983,CA01,C64B,92EC), 258 bn_pack4(0x5983,0xCA01,0xC64B,0x92EC),
259 bn_pack4(6FB8,F401,378C,D2BF), 259 bn_pack4(0x6FB8,0xF401,0x378C,0xD2BF),
260 bn_pack4(3320,5151,2BD7,AF42), 260 bn_pack4(0x3320,0x5151,0x2BD7,0xAF42),
261 bn_pack4(DB7F,1447,E6CC,254B), 261 bn_pack4(0xDB7F,0x1447,0xE6CC,0x254B),
262 bn_pack4(44CE,6CBA,CED4,BB1B), 262 bn_pack4(0x44CE,0x6CBA,0xCED4,0xBB1B),
263 bn_pack4(DA3E,DBEB,CF9B,14ED), 263 bn_pack4(0xDA3E,0xDBEB,0xCF9B,0x14ED),
264 bn_pack4(1797,27B0,865A,8918), 264 bn_pack4(0x1797,0x27B0,0x865A,0x8918),
265 bn_pack4(B06A,53ED,9027,D831), 265 bn_pack4(0xB06A,0x53ED,0x9027,0xD831),
266 bn_pack4(E5DB,382F,4130,01AE), 266 bn_pack4(0xE5DB,0x382F,0x4130,0x01AE),
267 bn_pack4(F8FF,9406,AD9E,530E), 267 bn_pack4(0xF8FF,0x9406,0xAD9E,0x530E),
268 bn_pack4(C975,1E76,3DBA,37BD), 268 bn_pack4(0xC975,0x1E76,0x3DBA,0x37BD),
269 bn_pack4(C1D4,DCB2,6026,46DE), 269 bn_pack4(0xC1D4,0xDCB2,0x6026,0x46DE),
270 bn_pack4(36C3,FAB4,D27C,7026), 270 bn_pack4(0x36C3,0xFAB4,0xD27C,0x7026),
271 bn_pack4(4DF4,35C9,3402,8492), 271 bn_pack4(0x4DF4,0x35C9,0x3402,0x8492),
272 bn_pack4(86FF,B7DC,90A6,C08F), 272 bn_pack4(0x86FF,0xB7DC,0x90A6,0xC08F),
273 bn_pack4(93B4,EA98,8D8F,DDC1), 273 bn_pack4(0x93B4,0xEA98,0x8D8F,0xDDC1),
274 bn_pack4(D006,9127,D5B0,5AA9), 274 bn_pack4(0xD006,0x9127,0xD5B0,0x5AA9),
275 bn_pack4(B81B,DD76,2170,481C), 275 bn_pack4(0xB81B,0xDD76,0x2170,0x481C),
276 bn_pack4(1F61,2970,CEE2,D7AF), 276 bn_pack4(0x1F61,0x2970,0xCEE2,0xD7AF),
277 bn_pack4(233B,A186,515B,E7ED), 277 bn_pack4(0x233B,0xA186,0x515B,0xE7ED),
278 bn_pack4(99B2,964F,A090,C3A2), 278 bn_pack4(0x99B2,0x964F,0xA090,0xC3A2),
279 bn_pack4(287C,5947,4E6B,C05D), 279 bn_pack4(0x287C,0x5947,0x4E6B,0xC05D),
280 bn_pack4(2E8E,FC14,1FBE,CAA6), 280 bn_pack4(0x2E8E,0xFC14,0x1FBE,0xCAA6),
281 bn_pack4(DBBB,C2DB,04DE,8EF9), 281 bn_pack4(0xDBBB,0xC2DB,0x04DE,0x8EF9),
282 bn_pack4(2583,E9CA,2AD4,4CE8), 282 bn_pack4(0x2583,0xE9CA,0x2AD4,0x4CE8),
283 bn_pack4(1A94,6834,B615,0BDA), 283 bn_pack4(0x1A94,0x6834,0xB615,0x0BDA),
284 bn_pack4(99C3,2718,6AF4,E23C), 284 bn_pack4(0x99C3,0x2718,0x6AF4,0xE23C),
285 bn_pack4(8871,9A10,BDBA,5B26), 285 bn_pack4(0x8871,0x9A10,0xBDBA,0x5B26),
286 bn_pack4(1A72,3C12,A787,E6D7), 286 bn_pack4(0x1A72,0x3C12,0xA787,0xE6D7),
287 bn_pack4(4B82,D120,A921,0801), 287 bn_pack4(0x4B82,0xD120,0xA921,0x0801),
288 bn_pack4(43DB,5BFC,E0FD,108E), 288 bn_pack4(0x43DB,0x5BFC,0xE0FD,0x108E),
289 bn_pack4(08E2,4FA0,74E5,AB31), 289 bn_pack4(0x08E2,0x4FA0,0x74E5,0xAB31),
290 bn_pack4(7709,88C0,BAD9,46E2), 290 bn_pack4(0x7709,0x88C0,0xBAD9,0x46E2),
291 bn_pack4(BBE1,1757,7A61,5D6C), 291 bn_pack4(0xBBE1,0x1757,0x7A61,0x5D6C),
292 bn_pack4(521F,2B18,177B,200C), 292 bn_pack4(0x521F,0x2B18,0x177B,0x200C),
293 bn_pack4(D876,0273,3EC8,6A64), 293 bn_pack4(0xD876,0x0273,0x3EC8,0x6A64),
294 bn_pack4(F12F,FA06,D98A,0864), 294 bn_pack4(0xF12F,0xFA06,0xD98A,0x0864),
295 bn_pack4(CEE3,D226,1AD2,EE6B), 295 bn_pack4(0xCEE3,0xD226,0x1AD2,0xEE6B),
296 bn_pack4(1E8C,94E0,4A25,619D), 296 bn_pack4(0x1E8C,0x94E0,0x4A25,0x619D),
297 bn_pack4(ABF5,AE8C,DB09,33D7), 297 bn_pack4(0xABF5,0xAE8C,0xDB09,0x33D7),
298 bn_pack4(B397,0F85,A6E1,E4C7), 298 bn_pack4(0xB397,0x0F85,0xA6E1,0xE4C7),
299 bn_pack4(8AEA,7157,5D06,0C7D), 299 bn_pack4(0x8AEA,0x7157,0x5D06,0x0C7D),
300 bn_pack4(ECFB,8504,58DB,EF0A), 300 bn_pack4(0xECFB,0x8504,0x58DB,0xEF0A),
301 bn_pack4(A855,21AB,DF1C,BA64), 301 bn_pack4(0xA855,0x21AB,0xDF1C,0xBA64),
302 bn_pack4(AD33,170D,0450,7A33), 302 bn_pack4(0xAD33,0x170D,0x0450,0x7A33),
303 bn_pack4(1572,8E5A,8AAA,C42D), 303 bn_pack4(0x1572,0x8E5A,0x8AAA,0xC42D),
304 bn_pack4(15D2,2618,98FA,0510), 304 bn_pack4(0x15D2,0x2618,0x98FA,0x0510),
305 bn_pack4(3995,497C,EA95,6AE5), 305 bn_pack4(0x3995,0x497C,0xEA95,0x6AE5),
306 bn_pack4(DE2B,CBF6,9558,1718), 306 bn_pack4(0xDE2B,0xCBF6,0x9558,0x1718),
307 bn_pack4(B5C5,5DF0,6F4C,52C9), 307 bn_pack4(0xB5C5,0x5DF0,0x6F4C,0x52C9),
308 bn_pack4(9B27,83A2,EC07,A28F), 308 bn_pack4(0x9B27,0x83A2,0xEC07,0xA28F),
309 bn_pack4(E39E,772C,180E,8603), 309 bn_pack4(0xE39E,0x772C,0x180E,0x8603),
310 bn_pack4(3290,5E46,2E36,CE3B), 310 bn_pack4(0x3290,0x5E46,0x2E36,0xCE3B),
311 bn_pack4(F174,6C08,CA18,217C), 311 bn_pack4(0xF174,0x6C08,0xCA18,0x217C),
312 bn_pack4(670C,354E,4ABC,9804), 312 bn_pack4(0x670C,0x354E,0x4ABC,0x9804),
313 bn_pack4(9ED5,2907,7096,966D), 313 bn_pack4(0x9ED5,0x2907,0x7096,0x966D),
314 bn_pack4(1C62,F356,2085,52BB), 314 bn_pack4(0x1C62,0xF356,0x2085,0x52BB),
315 bn_pack4(8365,5D23,DCA3,AD96), 315 bn_pack4(0x8365,0x5D23,0xDCA3,0xAD96),
316 bn_pack4(6916,3FA8,FD24,CF5F), 316 bn_pack4(0x6916,0x3FA8,0xFD24,0xCF5F),
317 bn_pack4(98DA,4836,1C55,D39A), 317 bn_pack4(0x98DA,0x4836,0x1C55,0xD39A),
318 bn_pack4(C200,7CB8,A163,BF05), 318 bn_pack4(0xC200,0x7CB8,0xA163,0xBF05),
319 bn_pack4(4928,6651,ECE4,5B3D), 319 bn_pack4(0x4928,0x6651,0xECE4,0x5B3D),
320 bn_pack4(AE9F,2411,7C4B,1FE6), 320 bn_pack4(0xAE9F,0x2411,0x7C4B,0x1FE6),
321 bn_pack4(EE38,6BFB,5A89,9FA5), 321 bn_pack4(0xEE38,0x6BFB,0x5A89,0x9FA5),
322 bn_pack4(0BFF,5CB6,F406,B7ED), 322 bn_pack4(0x0BFF,0x5CB6,0xF406,0xB7ED),
323 bn_pack4(F44C,42E9,A637,ED6B), 323 bn_pack4(0xF44C,0x42E9,0xA637,0xED6B),
324 bn_pack4(E485,B576,625E,7EC6), 324 bn_pack4(0xE485,0xB576,0x625E,0x7EC6),
325 bn_pack4(4FE1,356D,6D51,C245), 325 bn_pack4(0x4FE1,0x356D,0x6D51,0xC245),
326 bn_pack4(302B,0A6D,F25F,1437), 326 bn_pack4(0x302B,0x0A6D,0xF25F,0x1437),
327 bn_pack4(EF95,19B3,CD3A,431B), 327 bn_pack4(0xEF95,0x19B3,0xCD3A,0x431B),
328 bn_pack4(514A,0879,8E34,04DD), 328 bn_pack4(0x514A,0x0879,0x8E34,0x04DD),
329 bn_pack4(020B,BEA6,3B13,9B22), 329 bn_pack4(0x020B,0xBEA6,0x3B13,0x9B22),
330 bn_pack4(2902,4E08,8A67,CC74), 330 bn_pack4(0x2902,0x4E08,0x8A67,0xCC74),
331 bn_pack4(C4C6,628B,80DC,1CD1), 331 bn_pack4(0xC4C6,0x628B,0x80DC,0x1CD1),
332 bn_pack4(C90F,DAA2,2168,C234), 332 bn_pack4(0xC90F,0xDAA2,0x2168,0xC234),
333 bn_pack4(FFFF,FFFF,FFFF,FFFF) 333 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF)
334}; 334};
335static BIGNUM bn_group_6144 = { 335static BIGNUM bn_group_6144 = {
336 bn_group_6144_value, 336 bn_group_6144_value,
@@ -341,134 +341,134 @@ static BIGNUM bn_group_6144 = {
341}; 341};
342 342
343static BN_ULONG bn_group_8192_value[] = { 343static BN_ULONG bn_group_8192_value[] = {
344 bn_pack4(FFFF,FFFF,FFFF,FFFF), 344 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF),
345 bn_pack4(60C9,80DD,98ED,D3DF), 345 bn_pack4(0x60C9,0x80DD,0x98ED,0xD3DF),
346 bn_pack4(C81F,56E8,80B9,6E71), 346 bn_pack4(0xC81F,0x56E8,0x80B9,0x6E71),
347 bn_pack4(9E30,50E2,7656,94DF), 347 bn_pack4(0x9E30,0x50E2,0x7656,0x94DF),
348 bn_pack4(9558,E447,5677,E9AA), 348 bn_pack4(0x9558,0xE447,0x5677,0xE9AA),
349 bn_pack4(C919,0DA6,FC02,6E47), 349 bn_pack4(0xC919,0x0DA6,0xFC02,0x6E47),
350 bn_pack4(889A,002E,D5EE,382B), 350 bn_pack4(0x889A,0x002E,0xD5EE,0x382B),
351 bn_pack4(4009,438B,481C,6CD7), 351 bn_pack4(0x4009,0x438B,0x481C,0x6CD7),
352 bn_pack4(3590,46F4,EB87,9F92), 352 bn_pack4(0x3590,0x46F4,0xEB87,0x9F92),
353 bn_pack4(FAF3,6BC3,1ECF,A268), 353 bn_pack4(0xFAF3,0x6BC3,0x1ECF,0xA268),
354 bn_pack4(B1D5,10BD,7EE7,4D73), 354 bn_pack4(0xB1D5,0x10BD,0x7EE7,0x4D73),
355 bn_pack4(F9AB,4819,5DED,7EA1), 355 bn_pack4(0xF9AB,0x4819,0x5DED,0x7EA1),
356 bn_pack4(64F3,1CC5,0846,851D), 356 bn_pack4(0x64F3,0x1CC5,0x0846,0x851D),
357 bn_pack4(4597,E899,A025,5DC1), 357 bn_pack4(0x4597,0xE899,0xA025,0x5DC1),
358 bn_pack4(DF31,0EE0,74AB,6A36), 358 bn_pack4(0xDF31,0x0EE0,0x74AB,0x6A36),
359 bn_pack4(6D2A,13F8,3F44,F82D), 359 bn_pack4(0x6D2A,0x13F8,0x3F44,0xF82D),
360 bn_pack4(062B,3CF5,B3A2,78A6), 360 bn_pack4(0x062B,0x3CF5,0xB3A2,0x78A6),
361 bn_pack4(7968,3303,ED5B,DD3A), 361 bn_pack4(0x7968,0x3303,0xED5B,0xDD3A),
362 bn_pack4(FA9D,4B7F,A2C0,87E8), 362 bn_pack4(0xFA9D,0x4B7F,0xA2C0,0x87E8),
363 bn_pack4(4BCB,C886,2F83,85DD), 363 bn_pack4(0x4BCB,0xC886,0x2F83,0x85DD),
364 bn_pack4(3473,FC64,6CEA,306B), 364 bn_pack4(0x3473,0xFC64,0x6CEA,0x306B),
365 bn_pack4(13EB,57A8,1A23,F0C7), 365 bn_pack4(0x13EB,0x57A8,0x1A23,0xF0C7),
366 bn_pack4(2222,2E04,A403,7C07), 366 bn_pack4(0x2222,0x2E04,0xA403,0x7C07),
367 bn_pack4(E3FD,B8BE,FC84,8AD9), 367 bn_pack4(0xE3FD,0xB8BE,0xFC84,0x8AD9),
368 bn_pack4(238F,16CB,E39D,652D), 368 bn_pack4(0x238F,0x16CB,0xE39D,0x652D),
369 bn_pack4(3423,B474,2BF1,C978), 369 bn_pack4(0x3423,0xB474,0x2BF1,0xC978),
370 bn_pack4(3AAB,639C,5AE4,F568), 370 bn_pack4(0x3AAB,0x639C,0x5AE4,0xF568),
371 bn_pack4(2576,F693,6BA4,2466), 371 bn_pack4(0x2576,0xF693,0x6BA4,0x2466),
372 bn_pack4(741F,A7BF,8AFC,47ED), 372 bn_pack4(0x741F,0xA7BF,0x8AFC,0x47ED),
373 bn_pack4(3BC8,32B6,8D9D,D300), 373 bn_pack4(0x3BC8,0x32B6,0x8D9D,0xD300),
374 bn_pack4(D8BE,C4D0,73B9,31BA), 374 bn_pack4(0xD8BE,0xC4D0,0x73B9,0x31BA),
375 bn_pack4(3877,7CB6,A932,DF8C), 375 bn_pack4(0x3877,0x7CB6,0xA932,0xDF8C),
376 bn_pack4(74A3,926F,12FE,E5E4), 376 bn_pack4(0x74A3,0x926F,0x12FE,0xE5E4),
377 bn_pack4(E694,F91E,6DBE,1159), 377 bn_pack4(0xE694,0xF91E,0x6DBE,0x1159),
378 bn_pack4(12BF,2D5B,0B74,74D6), 378 bn_pack4(0x12BF,0x2D5B,0x0B74,0x74D6),
379 bn_pack4(043E,8F66,3F48,60EE), 379 bn_pack4(0x043E,0x8F66,0x3F48,0x60EE),
380 bn_pack4(387F,E8D7,6E3C,0468), 380 bn_pack4(0x387F,0xE8D7,0x6E3C,0x0468),
381 bn_pack4(DA56,C9EC,2EF2,9632), 381 bn_pack4(0xDA56,0xC9EC,0x2EF2,0x9632),
382 bn_pack4(EB19,CCB1,A313,D55C), 382 bn_pack4(0xEB19,0xCCB1,0xA313,0xD55C),
383 bn_pack4(F550,AA3D,8A1F,BFF0), 383 bn_pack4(0xF550,0xAA3D,0x8A1F,0xBFF0),
384 bn_pack4(06A1,D58B,B7C5,DA76), 384 bn_pack4(0x06A1,0xD58B,0xB7C5,0xDA76),
385 bn_pack4(A797,15EE,F29B,E328), 385 bn_pack4(0xA797,0x15EE,0xF29B,0xE328),
386 bn_pack4(14CC,5ED2,0F80,37E0), 386 bn_pack4(0x14CC,0x5ED2,0x0F80,0x37E0),
387 bn_pack4(CC8F,6D7E,BF48,E1D8), 387 bn_pack4(0xCC8F,0x6D7E,0xBF48,0xE1D8),
388 bn_pack4(4BD4,07B2,2B41,54AA), 388 bn_pack4(0x4BD4,0x07B2,0x2B41,0x54AA),
389 bn_pack4(0F1D,45B7,FF58,5AC5), 389 bn_pack4(0x0F1D,0x45B7,0xFF58,0x5AC5),
390 bn_pack4(23A9,7A7E,36CC,88BE), 390 bn_pack4(0x23A9,0x7A7E,0x36CC,0x88BE),
391 bn_pack4(59E7,C97F,BEC7,E8F3), 391 bn_pack4(0x59E7,0xC97F,0xBEC7,0xE8F3),
392 bn_pack4(B5A8,4031,900B,1C9E), 392 bn_pack4(0xB5A8,0x4031,0x900B,0x1C9E),
393 bn_pack4(D55E,702F,4698,0C82), 393 bn_pack4(0xD55E,0x702F,0x4698,0x0C82),
394 bn_pack4(F482,D7CE,6E74,FEF6), 394 bn_pack4(0xF482,0xD7CE,0x6E74,0xFEF6),
395 bn_pack4(F032,EA15,D172,1D03), 395 bn_pack4(0xF032,0xEA15,0xD172,0x1D03),
396 bn_pack4(5983,CA01,C64B,92EC), 396 bn_pack4(0x5983,0xCA01,0xC64B,0x92EC),
397 bn_pack4(6FB8,F401,378C,D2BF), 397 bn_pack4(0x6FB8,0xF401,0x378C,0xD2BF),
398 bn_pack4(3320,5151,2BD7,AF42), 398 bn_pack4(0x3320,0x5151,0x2BD7,0xAF42),
399 bn_pack4(DB7F,1447,E6CC,254B), 399 bn_pack4(0xDB7F,0x1447,0xE6CC,0x254B),
400 bn_pack4(44CE,6CBA,CED4,BB1B), 400 bn_pack4(0x44CE,0x6CBA,0xCED4,0xBB1B),
401 bn_pack4(DA3E,DBEB,CF9B,14ED), 401 bn_pack4(0xDA3E,0xDBEB,0xCF9B,0x14ED),
402 bn_pack4(1797,27B0,865A,8918), 402 bn_pack4(0x1797,0x27B0,0x865A,0x8918),
403 bn_pack4(B06A,53ED,9027,D831), 403 bn_pack4(0xB06A,0x53ED,0x9027,0xD831),
404 bn_pack4(E5DB,382F,4130,01AE), 404 bn_pack4(0xE5DB,0x382F,0x4130,0x01AE),
405 bn_pack4(F8FF,9406,AD9E,530E), 405 bn_pack4(0xF8FF,0x9406,0xAD9E,0x530E),
406 bn_pack4(C975,1E76,3DBA,37BD), 406 bn_pack4(0xC975,0x1E76,0x3DBA,0x37BD),
407 bn_pack4(C1D4,DCB2,6026,46DE), 407 bn_pack4(0xC1D4,0xDCB2,0x6026,0x46DE),
408 bn_pack4(36C3,FAB4,D27C,7026), 408 bn_pack4(0x36C3,0xFAB4,0xD27C,0x7026),
409 bn_pack4(4DF4,35C9,3402,8492), 409 bn_pack4(0x4DF4,0x35C9,0x3402,0x8492),
410 bn_pack4(86FF,B7DC,90A6,C08F), 410 bn_pack4(0x86FF,0xB7DC,0x90A6,0xC08F),
411 bn_pack4(93B4,EA98,8D8F,DDC1), 411 bn_pack4(0x93B4,0xEA98,0x8D8F,0xDDC1),
412 bn_pack4(D006,9127,D5B0,5AA9), 412 bn_pack4(0xD006,0x9127,0xD5B0,0x5AA9),
413 bn_pack4(B81B,DD76,2170,481C), 413 bn_pack4(0xB81B,0xDD76,0x2170,0x481C),
414 bn_pack4(1F61,2970,CEE2,D7AF), 414 bn_pack4(0x1F61,0x2970,0xCEE2,0xD7AF),
415 bn_pack4(233B,A186,515B,E7ED), 415 bn_pack4(0x233B,0xA186,0x515B,0xE7ED),
416 bn_pack4(99B2,964F,A090,C3A2), 416 bn_pack4(0x99B2,0x964F,0xA090,0xC3A2),
417 bn_pack4(287C,5947,4E6B,C05D), 417 bn_pack4(0x287C,0x5947,0x4E6B,0xC05D),
418 bn_pack4(2E8E,FC14,1FBE,CAA6), 418 bn_pack4(0x2E8E,0xFC14,0x1FBE,0xCAA6),
419 bn_pack4(DBBB,C2DB,04DE,8EF9), 419 bn_pack4(0xDBBB,0xC2DB,0x04DE,0x8EF9),
420 bn_pack4(2583,E9CA,2AD4,4CE8), 420 bn_pack4(0x2583,0xE9CA,0x2AD4,0x4CE8),
421 bn_pack4(1A94,6834,B615,0BDA), 421 bn_pack4(0x1A94,0x6834,0xB615,0x0BDA),
422 bn_pack4(99C3,2718,6AF4,E23C), 422 bn_pack4(0x99C3,0x2718,0x6AF4,0xE23C),
423 bn_pack4(8871,9A10,BDBA,5B26), 423 bn_pack4(0x8871,0x9A10,0xBDBA,0x5B26),
424 bn_pack4(1A72,3C12,A787,E6D7), 424 bn_pack4(0x1A72,0x3C12,0xA787,0xE6D7),
425 bn_pack4(4B82,D120,A921,0801), 425 bn_pack4(0x4B82,0xD120,0xA921,0x0801),
426 bn_pack4(43DB,5BFC,E0FD,108E), 426 bn_pack4(0x43DB,0x5BFC,0xE0FD,0x108E),
427 bn_pack4(08E2,4FA0,74E5,AB31), 427 bn_pack4(0x08E2,0x4FA0,0x74E5,0xAB31),
428 bn_pack4(7709,88C0,BAD9,46E2), 428 bn_pack4(0x7709,0x88C0,0xBAD9,0x46E2),
429 bn_pack4(BBE1,1757,7A61,5D6C), 429 bn_pack4(0xBBE1,0x1757,0x7A61,0x5D6C),
430 bn_pack4(521F,2B18,177B,200C), 430 bn_pack4(0x521F,0x2B18,0x177B,0x200C),
431 bn_pack4(D876,0273,3EC8,6A64), 431 bn_pack4(0xD876,0x0273,0x3EC8,0x6A64),
432 bn_pack4(F12F,FA06,D98A,0864), 432 bn_pack4(0xF12F,0xFA06,0xD98A,0x0864),
433 bn_pack4(CEE3,D226,1AD2,EE6B), 433 bn_pack4(0xCEE3,0xD226,0x1AD2,0xEE6B),
434 bn_pack4(1E8C,94E0,4A25,619D), 434 bn_pack4(0x1E8C,0x94E0,0x4A25,0x619D),
435 bn_pack4(ABF5,AE8C,DB09,33D7), 435 bn_pack4(0xABF5,0xAE8C,0xDB09,0x33D7),
436 bn_pack4(B397,0F85,A6E1,E4C7), 436 bn_pack4(0xB397,0x0F85,0xA6E1,0xE4C7),
437 bn_pack4(8AEA,7157,5D06,0C7D), 437 bn_pack4(0x8AEA,0x7157,0x5D06,0x0C7D),
438 bn_pack4(ECFB,8504,58DB,EF0A), 438 bn_pack4(0xECFB,0x8504,0x58DB,0xEF0A),
439 bn_pack4(A855,21AB,DF1C,BA64), 439 bn_pack4(0xA855,0x21AB,0xDF1C,0xBA64),
440 bn_pack4(AD33,170D,0450,7A33), 440 bn_pack4(0xAD33,0x170D,0x0450,0x7A33),
441 bn_pack4(1572,8E5A,8AAA,C42D), 441 bn_pack4(0x1572,0x8E5A,0x8AAA,0xC42D),
442 bn_pack4(15D2,2618,98FA,0510), 442 bn_pack4(0x15D2,0x2618,0x98FA,0x0510),
443 bn_pack4(3995,497C,EA95,6AE5), 443 bn_pack4(0x3995,0x497C,0xEA95,0x6AE5),
444 bn_pack4(DE2B,CBF6,9558,1718), 444 bn_pack4(0xDE2B,0xCBF6,0x9558,0x1718),
445 bn_pack4(B5C5,5DF0,6F4C,52C9), 445 bn_pack4(0xB5C5,0x5DF0,0x6F4C,0x52C9),
446 bn_pack4(9B27,83A2,EC07,A28F), 446 bn_pack4(0x9B27,0x83A2,0xEC07,0xA28F),
447 bn_pack4(E39E,772C,180E,8603), 447 bn_pack4(0xE39E,0x772C,0x180E,0x8603),
448 bn_pack4(3290,5E46,2E36,CE3B), 448 bn_pack4(0x3290,0x5E46,0x2E36,0xCE3B),
449 bn_pack4(F174,6C08,CA18,217C), 449 bn_pack4(0xF174,0x6C08,0xCA18,0x217C),
450 bn_pack4(670C,354E,4ABC,9804), 450 bn_pack4(0x670C,0x354E,0x4ABC,0x9804),
451 bn_pack4(9ED5,2907,7096,966D), 451 bn_pack4(0x9ED5,0x2907,0x7096,0x966D),
452 bn_pack4(1C62,F356,2085,52BB), 452 bn_pack4(0x1C62,0xF356,0x2085,0x52BB),
453 bn_pack4(8365,5D23,DCA3,AD96), 453 bn_pack4(0x8365,0x5D23,0xDCA3,0xAD96),
454 bn_pack4(6916,3FA8,FD24,CF5F), 454 bn_pack4(0x6916,0x3FA8,0xFD24,0xCF5F),
455 bn_pack4(98DA,4836,1C55,D39A), 455 bn_pack4(0x98DA,0x4836,0x1C55,0xD39A),
456 bn_pack4(C200,7CB8,A163,BF05), 456 bn_pack4(0xC200,0x7CB8,0xA163,0xBF05),
457 bn_pack4(4928,6651,ECE4,5B3D), 457 bn_pack4(0x4928,0x6651,0xECE4,0x5B3D),
458 bn_pack4(AE9F,2411,7C4B,1FE6), 458 bn_pack4(0xAE9F,0x2411,0x7C4B,0x1FE6),
459 bn_pack4(EE38,6BFB,5A89,9FA5), 459 bn_pack4(0xEE38,0x6BFB,0x5A89,0x9FA5),
460 bn_pack4(0BFF,5CB6,F406,B7ED), 460 bn_pack4(0x0BFF,0x5CB6,0xF406,0xB7ED),
461 bn_pack4(F44C,42E9,A637,ED6B), 461 bn_pack4(0xF44C,0x42E9,0xA637,0xED6B),
462 bn_pack4(E485,B576,625E,7EC6), 462 bn_pack4(0xE485,0xB576,0x625E,0x7EC6),
463 bn_pack4(4FE1,356D,6D51,C245), 463 bn_pack4(0x4FE1,0x356D,0x6D51,0xC245),
464 bn_pack4(302B,0A6D,F25F,1437), 464 bn_pack4(0x302B,0x0A6D,0xF25F,0x1437),
465 bn_pack4(EF95,19B3,CD3A,431B), 465 bn_pack4(0xEF95,0x19B3,0xCD3A,0x431B),
466 bn_pack4(514A,0879,8E34,04DD), 466 bn_pack4(0x514A,0x0879,0x8E34,0x04DD),
467 bn_pack4(020B,BEA6,3B13,9B22), 467 bn_pack4(0x020B,0xBEA6,0x3B13,0x9B22),
468 bn_pack4(2902,4E08,8A67,CC74), 468 bn_pack4(0x2902,0x4E08,0x8A67,0xCC74),
469 bn_pack4(C4C6,628B,80DC,1CD1), 469 bn_pack4(0xC4C6,0x628B,0x80DC,0x1CD1),
470 bn_pack4(C90F,DAA2,2168,C234), 470 bn_pack4(0xC90F,0xDAA2,0x2168,0xC234),
471 bn_pack4(FFFF,FFFF,FFFF,FFFF) 471 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF)
472}; 472};
473static BIGNUM bn_group_8192 = { 473static BIGNUM bn_group_8192 = {
474 bn_group_8192_value, 474 bn_group_8192_value,
diff --git a/src/lib/libcrypto/srp/srp_lib.c b/src/lib/libcrypto/srp/srp_lib.c
index 92cea98dcd..7c1dcc5111 100644
--- a/src/lib/libcrypto/srp/srp_lib.c
+++ b/src/lib/libcrypto/srp/srp_lib.c
@@ -63,13 +63,17 @@
63#include <openssl/evp.h> 63#include <openssl/evp.h>
64 64
65#if (BN_BYTES == 8) 65#if (BN_BYTES == 8)
66#define bn_pack4(a1,a2,a3,a4) 0x##a1##a2##a3##a4##ul 66# if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
67#endif 67# define bn_pack4(a1,a2,a3,a4) ((a1##UI64<<48)|(a2##UI64<<32)|(a3##UI64<<16)|a4##UI64)
68#if (BN_BYTES == 4) 68# elif defined(__arch64__)
69#define bn_pack4(a1,a2,a3,a4) 0x##a3##a4##ul, 0x##a1##a2##ul 69# define bn_pack4(a1,a2,a3,a4) ((a1##UL<<48)|(a2##UL<<32)|(a3##UL<<16)|a4##UL)
70#endif 70# else
71#if (BN_BYTES == 2) 71# define bn_pack4(a1,a2,a3,a4) ((a1##ULL<<48)|(a2##ULL<<32)|(a3##ULL<<16)|a4##ULL)
72#define bn_pack4(a1,a2,a3,a4) 0x##a4##u,0x##a3##u,0x##a2##u,0x##a1##u 72# endif
73#elif (BN_BYTES == 4)
74# define bn_pack4(a1,a2,a3,a4) ((a3##UL<<16)|a4##UL), ((a1##UL<<16)|a2##UL)
75#else
76# error "unsupported BN_BYTES"
73#endif 77#endif
74 78
75 79
diff --git a/src/lib/libcrypto/srp/srp_vfy.c b/src/lib/libcrypto/srp/srp_vfy.c
index c8be907d7f..4a3d13edf6 100644
--- a/src/lib/libcrypto/srp/srp_vfy.c
+++ b/src/lib/libcrypto/srp/srp_vfy.c
@@ -390,7 +390,7 @@ int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file)
390 } 390 }
391 for (i = 0; i < sk_OPENSSL_PSTRING_num(tmpdb->data); i++) 391 for (i = 0; i < sk_OPENSSL_PSTRING_num(tmpdb->data); i++)
392 { 392 {
393 pp = (char **)sk_OPENSSL_PSTRING_value(tmpdb->data,i); 393 pp = sk_OPENSSL_PSTRING_value(tmpdb->data,i);
394 if (pp[DB_srptype][0] == DB_SRP_INDEX) 394 if (pp[DB_srptype][0] == DB_SRP_INDEX)
395 { 395 {
396 /*we add this couple in the internal Stack */ 396 /*we add this couple in the internal Stack */
@@ -581,7 +581,8 @@ char *SRP_create_verifier(const char *user, const char *pass, char **salt,
581 if (*salt == NULL) 581 if (*salt == NULL)
582 { 582 {
583 char *tmp_salt; 583 char *tmp_salt;
584 if ((tmp_salt = (char *)OPENSSL_malloc(SRP_RANDOM_SALT_LEN * 2)) == NULL) 584
585 if ((tmp_salt = OPENSSL_malloc(SRP_RANDOM_SALT_LEN * 2)) == NULL)
585 { 586 {
586 OPENSSL_free(vf); 587 OPENSSL_free(vf);
587 goto err; 588 goto err;
diff --git a/src/lib/libssl/src/apps/cms.c b/src/lib/libssl/src/apps/cms.c
index d754140987..5f77f8fbb0 100644
--- a/src/lib/libssl/src/apps/cms.c
+++ b/src/lib/libssl/src/apps/cms.c
@@ -233,6 +233,8 @@ int MAIN(int argc, char **argv)
233 else if (!strcmp(*args,"-camellia256")) 233 else if (!strcmp(*args,"-camellia256"))
234 cipher = EVP_camellia_256_cbc(); 234 cipher = EVP_camellia_256_cbc();
235#endif 235#endif
236 else if (!strcmp (*args, "-debug_decrypt"))
237 flags |= CMS_DEBUG_DECRYPT;
236 else if (!strcmp (*args, "-text")) 238 else if (!strcmp (*args, "-text"))
237 flags |= CMS_TEXT; 239 flags |= CMS_TEXT;
238 else if (!strcmp (*args, "-nointern")) 240 else if (!strcmp (*args, "-nointern"))
@@ -1039,6 +1041,8 @@ int MAIN(int argc, char **argv)
1039 ret = 4; 1041 ret = 4;
1040 if (operation == SMIME_DECRYPT) 1042 if (operation == SMIME_DECRYPT)
1041 { 1043 {
1044 if (flags & CMS_DEBUG_DECRYPT)
1045 CMS_decrypt(cms, NULL, NULL, NULL, NULL, flags);
1042 1046
1043 if (secret_key) 1047 if (secret_key)
1044 { 1048 {
diff --git a/src/lib/libssl/src/apps/ecparam.c b/src/lib/libssl/src/apps/ecparam.c
index 465480bedd..976ebef12b 100644
--- a/src/lib/libssl/src/apps/ecparam.c
+++ b/src/lib/libssl/src/apps/ecparam.c
@@ -105,7 +105,7 @@
105 * in the asn1 der encoding 105 * in the asn1 der encoding
106 * possible values: named_curve (default) 106 * possible values: named_curve (default)
107 * explicit 107 * explicit
108 * -no_seed - if 'explicit' parameters are choosen do not use the seed 108 * -no_seed - if 'explicit' parameters are chosen do not use the seed
109 * -genkey - generate ec key 109 * -genkey - generate ec key
110 * -rand file - files to use for random number input 110 * -rand file - files to use for random number input
111 * -engine e - use engine e, possibly a hardware device 111 * -engine e - use engine e, possibly a hardware device
@@ -286,7 +286,7 @@ bad:
286 BIO_printf(bio_err, " " 286 BIO_printf(bio_err, " "
287 " explicit\n"); 287 " explicit\n");
288 BIO_printf(bio_err, " -no_seed if 'explicit'" 288 BIO_printf(bio_err, " -no_seed if 'explicit'"
289 " parameters are choosen do not" 289 " parameters are chosen do not"
290 " use the seed\n"); 290 " use the seed\n");
291 BIO_printf(bio_err, " -genkey generate ec" 291 BIO_printf(bio_err, " -genkey generate ec"
292 " key\n"); 292 " key\n");
diff --git a/src/lib/libssl/src/apps/srp.c b/src/lib/libssl/src/apps/srp.c
index 80e1b8a660..9c7ae184db 100644
--- a/src/lib/libssl/src/apps/srp.c
+++ b/src/lib/libssl/src/apps/srp.c
@@ -125,13 +125,13 @@ static int get_index(CA_DB *db, char* id, char type)
125 if (type == DB_SRP_INDEX) 125 if (type == DB_SRP_INDEX)
126 for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) 126 for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++)
127 { 127 {
128 pp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, i); 128 pp = sk_OPENSSL_PSTRING_value(db->db->data,i);
129 if (pp[DB_srptype][0] == DB_SRP_INDEX && !strcmp(id, pp[DB_srpid])) 129 if (pp[DB_srptype][0] == DB_SRP_INDEX && !strcmp(id,pp[DB_srpid]))
130 return i; 130 return i;
131 } 131 }
132 else for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) 132 else for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++)
133 { 133 {
134 pp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, i); 134 pp = sk_OPENSSL_PSTRING_value(db->db->data,i);
135 135
136 if (pp[DB_srptype][0] != DB_SRP_INDEX && !strcmp(id,pp[DB_srpid])) 136 if (pp[DB_srptype][0] != DB_SRP_INDEX && !strcmp(id,pp[DB_srpid]))
137 return i; 137 return i;
@@ -145,7 +145,7 @@ static void print_entry(CA_DB *db, BIO *bio, int indx, int verbose, char *s)
145 if (indx >= 0 && verbose) 145 if (indx >= 0 && verbose)
146 { 146 {
147 int j; 147 int j;
148 char **pp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, indx); 148 char **pp = sk_OPENSSL_PSTRING_value(db->db->data, indx);
149 BIO_printf(bio, "%s \"%s\"\n", s, pp[DB_srpid]); 149 BIO_printf(bio, "%s \"%s\"\n", s, pp[DB_srpid]);
150 for (j = 0; j < DB_NUMBER; j++) 150 for (j = 0; j < DB_NUMBER; j++)
151 { 151 {
@@ -163,7 +163,7 @@ static void print_user(CA_DB *db, BIO *bio, int userindex, int verbose)
163 { 163 {
164 if (verbose > 0) 164 if (verbose > 0)
165 { 165 {
166 char **pp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, userindex); 166 char **pp = sk_OPENSSL_PSTRING_value(db->db->data,userindex);
167 167
168 if (pp[DB_srptype][0] != 'I') 168 if (pp[DB_srptype][0] != 'I')
169 { 169 {
@@ -517,7 +517,7 @@ bad:
517 /* Lets check some fields */ 517 /* Lets check some fields */
518 for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) 518 for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++)
519 { 519 {
520 pp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, i); 520 pp = sk_OPENSSL_PSTRING_value(db->db->data, i);
521 521
522 if (pp[DB_srptype][0] == DB_SRP_INDEX) 522 if (pp[DB_srptype][0] == DB_SRP_INDEX)
523 { 523 {
@@ -533,8 +533,8 @@ bad:
533 533
534 if (gNindex >= 0) 534 if (gNindex >= 0)
535 { 535 {
536 gNrow = (char **)sk_OPENSSL_PSTRING_value(db->db->data, gNindex); 536 gNrow = sk_OPENSSL_PSTRING_value(db->db->data,gNindex);
537 print_entry(db, bio_err, gNindex, verbose > 1, "Default g and N") ; 537 print_entry(db, bio_err, gNindex, verbose > 1, "Default g and N");
538 } 538 }
539 else if (maxgN > 0 && !SRP_get_default_gN(gN)) 539 else if (maxgN > 0 && !SRP_get_default_gN(gN))
540 { 540 {
@@ -587,7 +587,7 @@ bad:
587 if (userindex >= 0) 587 if (userindex >= 0)
588 { 588 {
589 /* reactivation of a new user */ 589 /* reactivation of a new user */
590 char **row = (char **)sk_OPENSSL_PSTRING_value(db->db->data, userindex); 590 char **row = sk_OPENSSL_PSTRING_value(db->db->data, userindex);
591 BIO_printf(bio_err, "user \"%s\" reactivated.\n", user); 591 BIO_printf(bio_err, "user \"%s\" reactivated.\n", user);
592 row[DB_srptype][0] = 'V'; 592 row[DB_srptype][0] = 'V';
593 593
@@ -634,7 +634,7 @@ bad:
634 else 634 else
635 { 635 {
636 636
637 char **row = (char **)sk_OPENSSL_PSTRING_value(db->db->data, userindex); 637 char **row = sk_OPENSSL_PSTRING_value(db->db->data, userindex);
638 char type = row[DB_srptype][0]; 638 char type = row[DB_srptype][0];
639 if (type == 'v') 639 if (type == 'v')
640 { 640 {
@@ -664,9 +664,9 @@ bad:
664 664
665 if (!(gNid=srp_create_user(user,&(row[DB_srpverifier]), &(row[DB_srpsalt]),gNrow?gNrow[DB_srpsalt]:NULL, gNrow?gNrow[DB_srpverifier]:NULL, passout, bio_err,verbose))) 665 if (!(gNid=srp_create_user(user,&(row[DB_srpverifier]), &(row[DB_srpsalt]),gNrow?gNrow[DB_srpsalt]:NULL, gNrow?gNrow[DB_srpverifier]:NULL, passout, bio_err,verbose)))
666 { 666 {
667 BIO_printf(bio_err, "Cannot create srp verifier for user \"%s\", operation abandoned.\n", user); 667 BIO_printf(bio_err, "Cannot create srp verifier for user \"%s\", operation abandoned.\n", user);
668 errors++; 668 errors++;
669 goto err; 669 goto err;
670 } 670 }
671 671
672 row[DB_srptype][0] = 'v'; 672 row[DB_srptype][0] = 'v';
@@ -689,7 +689,7 @@ bad:
689 } 689 }
690 else 690 else
691 { 691 {
692 char **xpp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, userindex); 692 char **xpp = sk_OPENSSL_PSTRING_value(db->db->data,userindex);
693 BIO_printf(bio_err, "user \"%s\" revoked. t\n", user); 693 BIO_printf(bio_err, "user \"%s\" revoked. t\n", user);
694 694
695 xpp[DB_srptype][0] = 'R'; 695 xpp[DB_srptype][0] = 'R';
@@ -714,7 +714,7 @@ bad:
714 /* Lets check some fields */ 714 /* Lets check some fields */
715 for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) 715 for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++)
716 { 716 {
717 pp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, i); 717 pp = sk_OPENSSL_PSTRING_value(db->db->data,i);
718 718
719 if (pp[DB_srptype][0] == 'v') 719 if (pp[DB_srptype][0] == 'v')
720 { 720 {
diff --git a/src/lib/libssl/src/crypto/aes/asm/aes-mips.pl b/src/lib/libssl/src/crypto/aes/asm/aes-mips.pl
index 2ce6deffc8..e52395421b 100644
--- a/src/lib/libssl/src/crypto/aes/asm/aes-mips.pl
+++ b/src/lib/libssl/src/crypto/aes/asm/aes-mips.pl
@@ -1036,9 +1036,9 @@ _mips_AES_set_encrypt_key:
1036 nop 1036 nop
1037.end _mips_AES_set_encrypt_key 1037.end _mips_AES_set_encrypt_key
1038 1038
1039.globl AES_set_encrypt_key 1039.globl private_AES_set_encrypt_key
1040.ent AES_set_encrypt_key 1040.ent private_AES_set_encrypt_key
1041AES_set_encrypt_key: 1041private_AES_set_encrypt_key:
1042 .frame $sp,$FRAMESIZE,$ra 1042 .frame $sp,$FRAMESIZE,$ra
1043 .mask $SAVED_REGS_MASK,-$SZREG 1043 .mask $SAVED_REGS_MASK,-$SZREG
1044 .set noreorder 1044 .set noreorder
@@ -1060,7 +1060,7 @@ $code.=<<___ if ($flavour =~ /nubi/i); # optimize non-nubi prologue
1060___ 1060___
1061$code.=<<___ if ($flavour !~ /o32/i); # non-o32 PIC-ification 1061$code.=<<___ if ($flavour !~ /o32/i); # non-o32 PIC-ification
1062 .cplocal $Tbl 1062 .cplocal $Tbl
1063 .cpsetup $pf,$zero,AES_set_encrypt_key 1063 .cpsetup $pf,$zero,private_AES_set_encrypt_key
1064___ 1064___
1065$code.=<<___; 1065$code.=<<___;
1066 .set reorder 1066 .set reorder
@@ -1083,7 +1083,7 @@ ___
1083$code.=<<___; 1083$code.=<<___;
1084 jr $ra 1084 jr $ra
1085 $PTR_ADD $sp,$FRAMESIZE 1085 $PTR_ADD $sp,$FRAMESIZE
1086.end AES_set_encrypt_key 1086.end private_AES_set_encrypt_key
1087___ 1087___
1088 1088
1089my ($head,$tail)=($inp,$bits); 1089my ($head,$tail)=($inp,$bits);
@@ -1091,9 +1091,9 @@ my ($tp1,$tp2,$tp4,$tp8,$tp9,$tpb,$tpd,$tpe)=($a4,$a5,$a6,$a7,$s0,$s1,$s2,$s3);
1091my ($m,$x80808080,$x7f7f7f7f,$x1b1b1b1b)=($at,$t0,$t1,$t2); 1091my ($m,$x80808080,$x7f7f7f7f,$x1b1b1b1b)=($at,$t0,$t1,$t2);
1092$code.=<<___; 1092$code.=<<___;
1093.align 5 1093.align 5
1094.globl AES_set_decrypt_key 1094.globl private_AES_set_decrypt_key
1095.ent AES_set_decrypt_key 1095.ent private_AES_set_decrypt_key
1096AES_set_decrypt_key: 1096private_AES_set_decrypt_key:
1097 .frame $sp,$FRAMESIZE,$ra 1097 .frame $sp,$FRAMESIZE,$ra
1098 .mask $SAVED_REGS_MASK,-$SZREG 1098 .mask $SAVED_REGS_MASK,-$SZREG
1099 .set noreorder 1099 .set noreorder
@@ -1115,7 +1115,7 @@ $code.=<<___ if ($flavour =~ /nubi/i); # optimize non-nubi prologue
1115___ 1115___
1116$code.=<<___ if ($flavour !~ /o32/i); # non-o32 PIC-ification 1116$code.=<<___ if ($flavour !~ /o32/i); # non-o32 PIC-ification
1117 .cplocal $Tbl 1117 .cplocal $Tbl
1118 .cpsetup $pf,$zero,AES_set_decrypt_key 1118 .cpsetup $pf,$zero,private_AES_set_decrypt_key
1119___ 1119___
1120$code.=<<___; 1120$code.=<<___;
1121 .set reorder 1121 .set reorder
@@ -1226,7 +1226,7 @@ ___
1226$code.=<<___; 1226$code.=<<___;
1227 jr $ra 1227 jr $ra
1228 $PTR_ADD $sp,$FRAMESIZE 1228 $PTR_ADD $sp,$FRAMESIZE
1229.end AES_set_decrypt_key 1229.end private_AES_set_decrypt_key
1230___ 1230___
1231}}} 1231}}}
1232 1232
diff --git a/src/lib/libssl/src/crypto/aes/asm/aes-parisc.pl b/src/lib/libssl/src/crypto/aes/asm/aes-parisc.pl
index c36b6a2270..714dcfbbe3 100644
--- a/src/lib/libssl/src/crypto/aes/asm/aes-parisc.pl
+++ b/src/lib/libssl/src/crypto/aes/asm/aes-parisc.pl
@@ -1015,7 +1015,8 @@ foreach (split("\n",$code)) {
1015 $SIZE_T==4 ? sprintf("extru%s,%d,8,",$1,31-$2) 1015 $SIZE_T==4 ? sprintf("extru%s,%d,8,",$1,31-$2)
1016 : sprintf("extrd,u%s,%d,8,",$1,63-$2)/e; 1016 : sprintf("extrd,u%s,%d,8,",$1,63-$2)/e;
1017 1017
1018 s/,\*/,/ if ($SIZE_T==4); 1018 s/,\*/,/ if ($SIZE_T==4);
1019 s/\bbv\b(.*\(%r2\))/bve$1/ if ($SIZE_T==8);
1019 print $_,"\n"; 1020 print $_,"\n";
1020} 1021}
1021close STDOUT; 1022close STDOUT;
diff --git a/src/lib/libssl/src/crypto/aes/asm/aes-s390x.pl b/src/lib/libssl/src/crypto/aes/asm/aes-s390x.pl
index 445a1e6762..e75dcd0315 100644
--- a/src/lib/libssl/src/crypto/aes/asm/aes-s390x.pl
+++ b/src/lib/libssl/src/crypto/aes/asm/aes-s390x.pl
@@ -1598,11 +1598,11 @@ $code.=<<___ if(1);
1598 lghi $s1,0x7f 1598 lghi $s1,0x7f
1599 nr $s1,%r0 1599 nr $s1,%r0
1600 lghi %r0,0 # query capability vector 1600 lghi %r0,0 # query capability vector
1601 la %r1,2*$SIZE_T($sp) 1601 la %r1,$tweak-16($sp)
1602 .long 0xb92e0042 # km %r4,%r2 1602 .long 0xb92e0042 # km %r4,%r2
1603 llihh %r1,0x8000 1603 llihh %r1,0x8000
1604 srlg %r1,%r1,32($s1) # check for 32+function code 1604 srlg %r1,%r1,32($s1) # check for 32+function code
1605 ng %r1,2*$SIZE_T($sp) 1605 ng %r1,$tweak-16($sp)
1606 lgr %r0,$s0 # restore the function code 1606 lgr %r0,$s0 # restore the function code
1607 la %r1,0($key1) # restore $key1 1607 la %r1,0($key1) # restore $key1
1608 jz .Lxts_km_vanilla 1608 jz .Lxts_km_vanilla
@@ -1628,7 +1628,7 @@ $code.=<<___ if(1);
1628 1628
1629 lrvg $s0,$tweak+0($sp) # load the last tweak 1629 lrvg $s0,$tweak+0($sp) # load the last tweak
1630 lrvg $s1,$tweak+8($sp) 1630 lrvg $s1,$tweak+8($sp)
1631 stmg %r0,%r3,$tweak-32(%r1) # wipe copy of the key 1631 stmg %r0,%r3,$tweak-32($sp) # wipe copy of the key
1632 1632
1633 nill %r0,0xffdf # switch back to original function code 1633 nill %r0,0xffdf # switch back to original function code
1634 la %r1,0($key1) # restore pointer to $key1 1634 la %r1,0($key1) # restore pointer to $key1
@@ -1684,11 +1684,9 @@ $code.=<<___;
1684 lghi $i1,0x87 1684 lghi $i1,0x87
1685 srag $i2,$s1,63 # broadcast upper bit 1685 srag $i2,$s1,63 # broadcast upper bit
1686 ngr $i1,$i2 # rem 1686 ngr $i1,$i2 # rem
1687 srlg $i2,$s0,63 # carry bit from lower half 1687 algr $s0,$s0
1688 sllg $s0,$s0,1 1688 alcgr $s1,$s1
1689 sllg $s1,$s1,1
1690 xgr $s0,$i1 1689 xgr $s0,$i1
1691 ogr $s1,$i2
1692.Lxts_km_start: 1690.Lxts_km_start:
1693 lrvgr $i1,$s0 # flip byte order 1691 lrvgr $i1,$s0 # flip byte order
1694 lrvgr $i2,$s1 1692 lrvgr $i2,$s1
@@ -1745,11 +1743,9 @@ $code.=<<___;
1745 lghi $i1,0x87 1743 lghi $i1,0x87
1746 srag $i2,$s1,63 # broadcast upper bit 1744 srag $i2,$s1,63 # broadcast upper bit
1747 ngr $i1,$i2 # rem 1745 ngr $i1,$i2 # rem
1748 srlg $i2,$s0,63 # carry bit from lower half 1746 algr $s0,$s0
1749 sllg $s0,$s0,1 1747 alcgr $s1,$s1
1750 sllg $s1,$s1,1
1751 xgr $s0,$i1 1748 xgr $s0,$i1
1752 ogr $s1,$i2
1753 1749
1754 ltr $len,$len # clear zero flag 1750 ltr $len,$len # clear zero flag
1755 br $ra 1751 br $ra
@@ -1781,8 +1777,8 @@ $code.=<<___ if (!$softonly);
1781 clr %r0,%r1 1777 clr %r0,%r1
1782 jl .Lxts_enc_software 1778 jl .Lxts_enc_software
1783 1779
1780 st${g} $ra,5*$SIZE_T($sp)
1784 stm${g} %r6,$s3,6*$SIZE_T($sp) 1781 stm${g} %r6,$s3,6*$SIZE_T($sp)
1785 st${g} $ra,14*$SIZE_T($sp)
1786 1782
1787 sllg $len,$len,4 # $len&=~15 1783 sllg $len,$len,4 # $len&=~15
1788 slgr $out,$inp 1784 slgr $out,$inp
@@ -1830,9 +1826,9 @@ $code.=<<___ if (!$softonly);
1830 stg $i2,8($i3) 1826 stg $i2,8($i3)
1831 1827
1832.Lxts_enc_km_done: 1828.Lxts_enc_km_done:
1833 l${g} $ra,14*$SIZE_T($sp) 1829 stg $sp,$tweak+0($sp) # wipe tweak
1834 st${g} $sp,$tweak($sp) # wipe tweak 1830 stg $sp,$tweak+8($sp)
1835 st${g} $sp,$tweak($sp) 1831 l${g} $ra,5*$SIZE_T($sp)
1836 lm${g} %r6,$s3,6*$SIZE_T($sp) 1832 lm${g} %r6,$s3,6*$SIZE_T($sp)
1837 br $ra 1833 br $ra
1838.align 16 1834.align 16
@@ -1843,12 +1839,11 @@ $code.=<<___;
1843 1839
1844 slgr $out,$inp 1840 slgr $out,$inp
1845 1841
1846 xgr $s0,$s0 # clear upper half 1842 l${g} $s3,$stdframe($sp) # ivp
1847 xgr $s1,$s1 1843 llgf $s0,0($s3) # load iv
1848 lrv $s0,$stdframe+4($sp) # load secno 1844 llgf $s1,4($s3)
1849 lrv $s1,$stdframe+0($sp) 1845 llgf $s2,8($s3)
1850 xgr $s2,$s2 1846 llgf $s3,12($s3)
1851 xgr $s3,$s3
1852 stm${g} %r2,%r5,2*$SIZE_T($sp) 1847 stm${g} %r2,%r5,2*$SIZE_T($sp)
1853 la $key,0($key2) 1848 la $key,0($key2)
1854 larl $tbl,AES_Te 1849 larl $tbl,AES_Te
@@ -1864,11 +1859,9 @@ $code.=<<___;
1864 lghi %r1,0x87 1859 lghi %r1,0x87
1865 srag %r0,$s3,63 # broadcast upper bit 1860 srag %r0,$s3,63 # broadcast upper bit
1866 ngr %r1,%r0 # rem 1861 ngr %r1,%r0 # rem
1867 srlg %r0,$s1,63 # carry bit from lower half 1862 algr $s1,$s1
1868 sllg $s1,$s1,1 1863 alcgr $s3,$s3
1869 sllg $s3,$s3,1
1870 xgr $s1,%r1 1864 xgr $s1,%r1
1871 ogr $s3,%r0
1872 lrvgr $s1,$s1 # flip byte order 1865 lrvgr $s1,$s1 # flip byte order
1873 lrvgr $s3,$s3 1866 lrvgr $s3,$s3
1874 srlg $s0,$s1,32 # smash the tweak to 4x32-bits 1867 srlg $s0,$s1,32 # smash the tweak to 4x32-bits
@@ -1917,11 +1910,9 @@ $code.=<<___;
1917 lghi %r1,0x87 1910 lghi %r1,0x87
1918 srag %r0,$s3,63 # broadcast upper bit 1911 srag %r0,$s3,63 # broadcast upper bit
1919 ngr %r1,%r0 # rem 1912 ngr %r1,%r0 # rem
1920 srlg %r0,$s1,63 # carry bit from lower half 1913 algr $s1,$s1
1921 sllg $s1,$s1,1 1914 alcgr $s3,$s3
1922 sllg $s3,$s3,1
1923 xgr $s1,%r1 1915 xgr $s1,%r1
1924 ogr $s3,%r0
1925 lrvgr $s1,$s1 # flip byte order 1916 lrvgr $s1,$s1 # flip byte order
1926 lrvgr $s3,$s3 1917 lrvgr $s3,$s3
1927 srlg $s0,$s1,32 # smash the tweak to 4x32-bits 1918 srlg $s0,$s1,32 # smash the tweak to 4x32-bits
@@ -1956,7 +1947,8 @@ $code.=<<___;
1956.size AES_xts_encrypt,.-AES_xts_encrypt 1947.size AES_xts_encrypt,.-AES_xts_encrypt
1957___ 1948___
1958# void AES_xts_decrypt(const char *inp,char *out,size_t len, 1949# void AES_xts_decrypt(const char *inp,char *out,size_t len,
1959# const AES_KEY *key1, const AES_KEY *key2,u64 secno); 1950# const AES_KEY *key1, const AES_KEY *key2,
1951# const unsigned char iv[16]);
1960# 1952#
1961$code.=<<___; 1953$code.=<<___;
1962.globl AES_xts_decrypt 1954.globl AES_xts_decrypt
@@ -1988,8 +1980,8 @@ $code.=<<___ if (!$softonly);
1988 clr %r0,%r1 1980 clr %r0,%r1
1989 jl .Lxts_dec_software 1981 jl .Lxts_dec_software
1990 1982
1983 st${g} $ra,5*$SIZE_T($sp)
1991 stm${g} %r6,$s3,6*$SIZE_T($sp) 1984 stm${g} %r6,$s3,6*$SIZE_T($sp)
1992 st${g} $ra,14*$SIZE_T($sp)
1993 1985
1994 nill $len,0xfff0 # $len&=~15 1986 nill $len,0xfff0 # $len&=~15
1995 slgr $out,$inp 1987 slgr $out,$inp
@@ -2028,11 +2020,9 @@ $code.=<<___ if (!$softonly);
2028 lghi $i1,0x87 2020 lghi $i1,0x87
2029 srag $i2,$s1,63 # broadcast upper bit 2021 srag $i2,$s1,63 # broadcast upper bit
2030 ngr $i1,$i2 # rem 2022 ngr $i1,$i2 # rem
2031 srlg $i2,$s0,63 # carry bit from lower half 2023 algr $s0,$s0
2032 sllg $s0,$s0,1 2024 alcgr $s1,$s1
2033 sllg $s1,$s1,1
2034 xgr $s0,$i1 2025 xgr $s0,$i1
2035 ogr $s1,$i2
2036 lrvgr $i1,$s0 # flip byte order 2026 lrvgr $i1,$s0 # flip byte order
2037 lrvgr $i2,$s1 2027 lrvgr $i2,$s1
2038 2028
@@ -2075,9 +2065,9 @@ $code.=<<___ if (!$softonly);
2075 stg $s2,0($i3) 2065 stg $s2,0($i3)
2076 stg $s3,8($i3) 2066 stg $s3,8($i3)
2077.Lxts_dec_km_done: 2067.Lxts_dec_km_done:
2078 l${g} $ra,14*$SIZE_T($sp) 2068 stg $sp,$tweak+0($sp) # wipe tweak
2079 st${g} $sp,$tweak($sp) # wipe tweak 2069 stg $sp,$tweak+8($sp)
2080 st${g} $sp,$tweak($sp) 2070 l${g} $ra,5*$SIZE_T($sp)
2081 lm${g} %r6,$s3,6*$SIZE_T($sp) 2071 lm${g} %r6,$s3,6*$SIZE_T($sp)
2082 br $ra 2072 br $ra
2083.align 16 2073.align 16
@@ -2089,12 +2079,11 @@ $code.=<<___;
2089 srlg $len,$len,4 2079 srlg $len,$len,4
2090 slgr $out,$inp 2080 slgr $out,$inp
2091 2081
2092 xgr $s0,$s0 # clear upper half 2082 l${g} $s3,$stdframe($sp) # ivp
2093 xgr $s1,$s1 2083 llgf $s0,0($s3) # load iv
2094 lrv $s0,$stdframe+4($sp) # load secno 2084 llgf $s1,4($s3)
2095 lrv $s1,$stdframe+0($sp) 2085 llgf $s2,8($s3)
2096 xgr $s2,$s2 2086 llgf $s3,12($s3)
2097 xgr $s3,$s3
2098 stm${g} %r2,%r5,2*$SIZE_T($sp) 2087 stm${g} %r2,%r5,2*$SIZE_T($sp)
2099 la $key,0($key2) 2088 la $key,0($key2)
2100 larl $tbl,AES_Te 2089 larl $tbl,AES_Te
@@ -2113,11 +2102,9 @@ $code.=<<___;
2113 lghi %r1,0x87 2102 lghi %r1,0x87
2114 srag %r0,$s3,63 # broadcast upper bit 2103 srag %r0,$s3,63 # broadcast upper bit
2115 ngr %r1,%r0 # rem 2104 ngr %r1,%r0 # rem
2116 srlg %r0,$s1,63 # carry bit from lower half 2105 algr $s1,$s1
2117 sllg $s1,$s1,1 2106 alcgr $s3,$s3
2118 sllg $s3,$s3,1
2119 xgr $s1,%r1 2107 xgr $s1,%r1
2120 ogr $s3,%r0
2121 lrvgr $s1,$s1 # flip byte order 2108 lrvgr $s1,$s1 # flip byte order
2122 lrvgr $s3,$s3 2109 lrvgr $s3,$s3
2123 srlg $s0,$s1,32 # smash the tweak to 4x32-bits 2110 srlg $s0,$s1,32 # smash the tweak to 4x32-bits
@@ -2156,11 +2143,9 @@ $code.=<<___;
2156 lghi %r1,0x87 2143 lghi %r1,0x87
2157 srag %r0,$s3,63 # broadcast upper bit 2144 srag %r0,$s3,63 # broadcast upper bit
2158 ngr %r1,%r0 # rem 2145 ngr %r1,%r0 # rem
2159 srlg %r0,$s1,63 # carry bit from lower half 2146 algr $s1,$s1
2160 sllg $s1,$s1,1 2147 alcgr $s3,$s3
2161 sllg $s3,$s3,1
2162 xgr $s1,%r1 2148 xgr $s1,%r1
2163 ogr $s3,%r0
2164 lrvgr $i2,$s1 # flip byte order 2149 lrvgr $i2,$s1 # flip byte order
2165 lrvgr $i3,$s3 2150 lrvgr $i3,$s3
2166 stmg $i2,$i3,$tweak($sp) # save the 1st tweak 2151 stmg $i2,$i3,$tweak($sp) # save the 1st tweak
@@ -2176,11 +2161,9 @@ $code.=<<___;
2176 lghi %r1,0x87 2161 lghi %r1,0x87
2177 srag %r0,$s3,63 # broadcast upper bit 2162 srag %r0,$s3,63 # broadcast upper bit
2178 ngr %r1,%r0 # rem 2163 ngr %r1,%r0 # rem
2179 srlg %r0,$s1,63 # carry bit from lower half 2164 algr $s1,$s1
2180 sllg $s1,$s1,1 2165 alcgr $s3,$s3
2181 sllg $s3,$s3,1
2182 xgr $s1,%r1 2166 xgr $s1,%r1
2183 ogr $s3,%r0
2184 lrvgr $s1,$s1 # flip byte order 2167 lrvgr $s1,$s1 # flip byte order
2185 lrvgr $s3,$s3 2168 lrvgr $s3,$s3
2186 srlg $s0,$s1,32 # smash the tweak to 4x32-bits 2169 srlg $s0,$s1,32 # smash the tweak to 4x32-bits
diff --git a/src/lib/libssl/src/crypto/aes/asm/aes-x86_64.pl b/src/lib/libssl/src/crypto/aes/asm/aes-x86_64.pl
index 48fa857d5b..34cbb5d844 100755
--- a/src/lib/libssl/src/crypto/aes/asm/aes-x86_64.pl
+++ b/src/lib/libssl/src/crypto/aes/asm/aes-x86_64.pl
@@ -36,7 +36,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
36( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or 36( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
37die "can't locate x86_64-xlate.pl"; 37die "can't locate x86_64-xlate.pl";
38 38
39open STDOUT,"| $^X $xlate $flavour $output"; 39open OUT,"| \"$^X\" $xlate $flavour $output";
40*STDOUT=*OUT;
40 41
41$verticalspin=1; # unlike 32-bit version $verticalspin performs 42$verticalspin=1; # unlike 32-bit version $verticalspin performs
42 # ~15% better on both AMD and Intel cores 43 # ~15% better on both AMD and Intel cores
diff --git a/src/lib/libssl/src/crypto/aes/asm/aesni-sha1-x86_64.pl b/src/lib/libssl/src/crypto/aes/asm/aesni-sha1-x86_64.pl
index c6f6b3334a..3c8f6c19e7 100644
--- a/src/lib/libssl/src/crypto/aes/asm/aesni-sha1-x86_64.pl
+++ b/src/lib/libssl/src/crypto/aes/asm/aesni-sha1-x86_64.pl
@@ -69,7 +69,8 @@ $avx=1 if (!$avx && $win64 && ($flavour =~ /masm/ || $ENV{ASM} =~ /ml64/) &&
69 `ml64 2>&1` =~ /Version ([0-9]+)\./ && 69 `ml64 2>&1` =~ /Version ([0-9]+)\./ &&
70 $1>=10); 70 $1>=10);
71 71
72open STDOUT,"| $^X $xlate $flavour $output"; 72open OUT,"| \"$^X\" $xlate $flavour $output";
73*STDOUT=*OUT;
73 74
74# void aesni_cbc_sha1_enc(const void *inp, 75# void aesni_cbc_sha1_enc(const void *inp,
75# void *out, 76# void *out,
diff --git a/src/lib/libssl/src/crypto/aes/asm/aesni-x86_64.pl b/src/lib/libssl/src/crypto/aes/asm/aesni-x86_64.pl
index 499f3b3f42..0dbb194b8d 100644
--- a/src/lib/libssl/src/crypto/aes/asm/aesni-x86_64.pl
+++ b/src/lib/libssl/src/crypto/aes/asm/aesni-x86_64.pl
@@ -172,7 +172,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
172( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or 172( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
173die "can't locate x86_64-xlate.pl"; 173die "can't locate x86_64-xlate.pl";
174 174
175open STDOUT,"| $^X $xlate $flavour $output"; 175open OUT,"| \"$^X\" $xlate $flavour $output";
176*STDOUT=*OUT;
176 177
177$movkey = $PREFIX eq "aesni" ? "movups" : "movups"; 178$movkey = $PREFIX eq "aesni" ? "movups" : "movups";
178@_4args=$win64? ("%rcx","%rdx","%r8", "%r9") : # Win64 order 179@_4args=$win64? ("%rcx","%rdx","%r8", "%r9") : # Win64 order
diff --git a/src/lib/libssl/src/crypto/aes/asm/bsaes-x86_64.pl b/src/lib/libssl/src/crypto/aes/asm/bsaes-x86_64.pl
index c9c6312fa7..41b90f0844 100644
--- a/src/lib/libssl/src/crypto/aes/asm/bsaes-x86_64.pl
+++ b/src/lib/libssl/src/crypto/aes/asm/bsaes-x86_64.pl
@@ -83,9 +83,9 @@
83# Add decryption procedure. Performance in CPU cycles spent to decrypt 83# Add decryption procedure. Performance in CPU cycles spent to decrypt
84# one byte out of 4096-byte buffer with 128-bit key is: 84# one byte out of 4096-byte buffer with 128-bit key is:
85# 85#
86# Core 2 11.0 86# Core 2 9.83
87# Nehalem 9.16 87# Nehalem 7.74
88# Atom 20.9 88# Atom 19.0
89# 89#
90# November 2011. 90# November 2011.
91# 91#
@@ -105,7 +105,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
105( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or 105( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
106die "can't locate x86_64-xlate.pl"; 106die "can't locate x86_64-xlate.pl";
107 107
108open STDOUT,"| $^X $xlate $flavour $output"; 108open OUT,"| \"$^X\" $xlate $flavour $output";
109*STDOUT=*OUT;
109 110
110my ($inp,$out,$len,$key,$ivp)=("%rdi","%rsi","%rdx","%rcx"); 111my ($inp,$out,$len,$key,$ivp)=("%rdi","%rsi","%rdx","%rcx");
111my @XMM=map("%xmm$_",(15,0..14)); # best on Atom, +10% over (0..15) 112my @XMM=map("%xmm$_",(15,0..14)); # best on Atom, +10% over (0..15)
@@ -455,6 +456,7 @@ sub MixColumns {
455# modified to emit output in order suitable for feeding back to aesenc[last] 456# modified to emit output in order suitable for feeding back to aesenc[last]
456my @x=@_[0..7]; 457my @x=@_[0..7];
457my @t=@_[8..15]; 458my @t=@_[8..15];
459my $inv=@_[16]; # optional
458$code.=<<___; 460$code.=<<___;
459 pshufd \$0x93, @x[0], @t[0] # x0 <<< 32 461 pshufd \$0x93, @x[0], @t[0] # x0 <<< 32
460 pshufd \$0x93, @x[1], @t[1] 462 pshufd \$0x93, @x[1], @t[1]
@@ -496,7 +498,8 @@ $code.=<<___;
496 pxor @t[4], @t[0] 498 pxor @t[4], @t[0]
497 pshufd \$0x4E, @x[2], @x[6] 499 pshufd \$0x4E, @x[2], @x[6]
498 pxor @t[5], @t[1] 500 pxor @t[5], @t[1]
499 501___
502$code.=<<___ if (!$inv);
500 pxor @t[3], @x[4] 503 pxor @t[3], @x[4]
501 pxor @t[7], @x[5] 504 pxor @t[7], @x[5]
502 pxor @t[6], @x[3] 505 pxor @t[6], @x[3]
@@ -504,9 +507,20 @@ $code.=<<___;
504 pxor @t[2], @x[6] 507 pxor @t[2], @x[6]
505 movdqa @t[1], @x[7] 508 movdqa @t[1], @x[7]
506___ 509___
510$code.=<<___ if ($inv);
511 pxor @x[4], @t[3]
512 pxor @t[7], @x[5]
513 pxor @x[3], @t[6]
514 movdqa @t[0], @x[3]
515 pxor @t[2], @x[6]
516 movdqa @t[6], @x[2]
517 movdqa @t[1], @x[7]
518 movdqa @x[6], @x[4]
519 movdqa @t[3], @x[6]
520___
507} 521}
508 522
509sub InvMixColumns { 523sub InvMixColumns_orig {
510my @x=@_[0..7]; 524my @x=@_[0..7];
511my @t=@_[8..15]; 525my @t=@_[8..15];
512 526
@@ -660,6 +674,54 @@ $code.=<<___;
660___ 674___
661} 675}
662 676
677sub InvMixColumns {
678my @x=@_[0..7];
679my @t=@_[8..15];
680
681# Thanks to Jussi Kivilinna for providing pointer to
682#
683# | 0e 0b 0d 09 | | 02 03 01 01 | | 05 00 04 00 |
684# | 09 0e 0b 0d | = | 01 02 03 01 | x | 00 05 00 04 |
685# | 0d 09 0e 0b | | 01 01 02 03 | | 04 00 05 00 |
686# | 0b 0d 09 0e | | 03 01 01 02 | | 00 04 00 05 |
687
688$code.=<<___;
689 # multiplication by 0x05-0x00-0x04-0x00
690 pshufd \$0x4E, @x[0], @t[0]
691 pshufd \$0x4E, @x[6], @t[6]
692 pxor @x[0], @t[0]
693 pshufd \$0x4E, @x[7], @t[7]
694 pxor @x[6], @t[6]
695 pshufd \$0x4E, @x[1], @t[1]
696 pxor @x[7], @t[7]
697 pshufd \$0x4E, @x[2], @t[2]
698 pxor @x[1], @t[1]
699 pshufd \$0x4E, @x[3], @t[3]
700 pxor @x[2], @t[2]
701 pxor @t[6], @x[0]
702 pxor @t[6], @x[1]
703 pshufd \$0x4E, @x[4], @t[4]
704 pxor @x[3], @t[3]
705 pxor @t[0], @x[2]
706 pxor @t[1], @x[3]
707 pshufd \$0x4E, @x[5], @t[5]
708 pxor @x[4], @t[4]
709 pxor @t[7], @x[1]
710 pxor @t[2], @x[4]
711 pxor @x[5], @t[5]
712
713 pxor @t[7], @x[2]
714 pxor @t[6], @x[3]
715 pxor @t[6], @x[4]
716 pxor @t[3], @x[5]
717 pxor @t[4], @x[6]
718 pxor @t[7], @x[4]
719 pxor @t[7], @x[5]
720 pxor @t[5], @x[7]
721___
722 &MixColumns (@x,@t,1); # flipped 2<->3 and 4<->6
723}
724
663sub aesenc { # not used 725sub aesenc { # not used
664my @b=@_[0..7]; 726my @b=@_[0..7];
665my @t=@_[8..15]; 727my @t=@_[8..15];
@@ -2027,6 +2089,8 @@ ___
2027# const unsigned char iv[16]); 2089# const unsigned char iv[16]);
2028# 2090#
2029my ($twmask,$twres,$twtmp)=@XMM[13..15]; 2091my ($twmask,$twres,$twtmp)=@XMM[13..15];
2092$arg6=~s/d$//;
2093
2030$code.=<<___; 2094$code.=<<___;
2031.globl bsaes_xts_encrypt 2095.globl bsaes_xts_encrypt
2032.type bsaes_xts_encrypt,\@abi-omnipotent 2096.type bsaes_xts_encrypt,\@abi-omnipotent
diff --git a/src/lib/libssl/src/crypto/aes/asm/vpaes-x86_64.pl b/src/lib/libssl/src/crypto/aes/asm/vpaes-x86_64.pl
index 37998db5e1..bd7f45b850 100644
--- a/src/lib/libssl/src/crypto/aes/asm/vpaes-x86_64.pl
+++ b/src/lib/libssl/src/crypto/aes/asm/vpaes-x86_64.pl
@@ -56,7 +56,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
56( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or 56( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
57die "can't locate x86_64-xlate.pl"; 57die "can't locate x86_64-xlate.pl";
58 58
59open STDOUT,"| $^X $xlate $flavour $output"; 59open OUT,"| \"$^X\" $xlate $flavour $output";
60*STDOUT=*OUT;
60 61
61$PREFIX="vpaes"; 62$PREFIX="vpaes";
62 63
@@ -1059,7 +1060,7 @@ _vpaes_consts:
1059.Lk_dsbo: # decryption sbox final output 1060.Lk_dsbo: # decryption sbox final output
1060 .quad 0x1387EA537EF94000, 0xC7AA6DB9D4943E2D 1061 .quad 0x1387EA537EF94000, 0xC7AA6DB9D4943E2D
1061 .quad 0x12D7560F93441D00, 0xCA4B8159D8C58E9C 1062 .quad 0x12D7560F93441D00, 0xCA4B8159D8C58E9C
1062.asciz "Vector Permutaion AES for x86_64/SSSE3, Mike Hamburg (Stanford University)" 1063.asciz "Vector Permutation AES for x86_64/SSSE3, Mike Hamburg (Stanford University)"
1063.align 64 1064.align 64
1064.size _vpaes_consts,.-_vpaes_consts 1065.size _vpaes_consts,.-_vpaes_consts
1065___ 1066___
diff --git a/src/lib/libssl/src/crypto/armcap.c b/src/lib/libssl/src/crypto/armcap.c
index 5258d2fbdd..9abaf396e5 100644
--- a/src/lib/libssl/src/crypto/armcap.c
+++ b/src/lib/libssl/src/crypto/armcap.c
@@ -23,7 +23,7 @@ unsigned int _armv7_tick(void);
23 23
24unsigned int OPENSSL_rdtsc(void) 24unsigned int OPENSSL_rdtsc(void)
25 { 25 {
26 if (OPENSSL_armcap_P|ARMV7_TICK) 26 if (OPENSSL_armcap_P & ARMV7_TICK)
27 return _armv7_tick(); 27 return _armv7_tick();
28 else 28 else
29 return 0; 29 return 0;
diff --git a/src/lib/libssl/src/crypto/bio/bss_dgram.c b/src/lib/libssl/src/crypto/bio/bss_dgram.c
index 1b1e4bec81..54c012c47d 100644
--- a/src/lib/libssl/src/crypto/bio/bss_dgram.c
+++ b/src/lib/libssl/src/crypto/bio/bss_dgram.c
@@ -77,10 +77,20 @@
77#define OPENSSL_SCTP_FORWARD_CUM_TSN_CHUNK_TYPE 0xc0 77#define OPENSSL_SCTP_FORWARD_CUM_TSN_CHUNK_TYPE 0xc0
78#endif 78#endif
79 79
80#ifdef OPENSSL_SYS_LINUX 80#if defined(OPENSSL_SYS_LINUX) && !defined(IP_MTU)
81#define IP_MTU 14 /* linux is lame */ 81#define IP_MTU 14 /* linux is lame */
82#endif 82#endif
83 83
84#if defined(__FreeBSD__) && defined(IN6_IS_ADDR_V4MAPPED)
85/* Standard definition causes type-punning problems. */
86#undef IN6_IS_ADDR_V4MAPPED
87#define s6_addr32 __u6_addr.__u6_addr32
88#define IN6_IS_ADDR_V4MAPPED(a) \
89 (((a)->s6_addr32[0] == 0) && \
90 ((a)->s6_addr32[1] == 0) && \
91 ((a)->s6_addr32[2] == htonl(0x0000ffff)))
92#endif
93
84#ifdef WATT32 94#ifdef WATT32
85#define sock_write SockWrite /* Watt-32 uses same names */ 95#define sock_write SockWrite /* Watt-32 uses same names */
86#define sock_read SockRead 96#define sock_read SockRead
@@ -255,7 +265,7 @@ static void dgram_adjust_rcv_timeout(BIO *b)
255 { 265 {
256#if defined(SO_RCVTIMEO) 266#if defined(SO_RCVTIMEO)
257 bio_dgram_data *data = (bio_dgram_data *)b->ptr; 267 bio_dgram_data *data = (bio_dgram_data *)b->ptr;
258 int sz = sizeof(int); 268 union { size_t s; int i; } sz = {0};
259 269
260 /* Is a timer active? */ 270 /* Is a timer active? */
261 if (data->next_timeout.tv_sec > 0 || data->next_timeout.tv_usec > 0) 271 if (data->next_timeout.tv_sec > 0 || data->next_timeout.tv_usec > 0)
@@ -265,8 +275,10 @@ static void dgram_adjust_rcv_timeout(BIO *b)
265 /* Read current socket timeout */ 275 /* Read current socket timeout */
266#ifdef OPENSSL_SYS_WINDOWS 276#ifdef OPENSSL_SYS_WINDOWS
267 int timeout; 277 int timeout;
278
279 sz.i = sizeof(timeout);
268 if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, 280 if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
269 (void*)&timeout, &sz) < 0) 281 (void*)&timeout, &sz.i) < 0)
270 { perror("getsockopt"); } 282 { perror("getsockopt"); }
271 else 283 else
272 { 284 {
@@ -274,9 +286,12 @@ static void dgram_adjust_rcv_timeout(BIO *b)
274 data->socket_timeout.tv_usec = (timeout % 1000) * 1000; 286 data->socket_timeout.tv_usec = (timeout % 1000) * 1000;
275 } 287 }
276#else 288#else
289 sz.i = sizeof(data->socket_timeout);
277 if ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, 290 if ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
278 &(data->socket_timeout), (void *)&sz) < 0) 291 &(data->socket_timeout), (void *)&sz) < 0)
279 { perror("getsockopt"); } 292 { perror("getsockopt"); }
293 else if (sizeof(sz.s)!=sizeof(sz.i) && sz.i==0)
294 OPENSSL_assert(sz.s<=sizeof(data->socket_timeout));
280#endif 295#endif
281 296
282 /* Get current time */ 297 /* Get current time */
@@ -445,11 +460,10 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
445 int *ip; 460 int *ip;
446 struct sockaddr *to = NULL; 461 struct sockaddr *to = NULL;
447 bio_dgram_data *data = NULL; 462 bio_dgram_data *data = NULL;
448#if defined(IP_MTU_DISCOVER) || defined(IP_MTU) 463#if defined(OPENSSL_SYS_LINUX) && (defined(IP_MTU_DISCOVER) || defined(IP_MTU))
449 long sockopt_val = 0; 464 int sockopt_val = 0;
450 unsigned int sockopt_len = 0; 465 socklen_t sockopt_len; /* assume that system supporting IP_MTU is
451#endif 466 * modern enough to define socklen_t */
452#ifdef OPENSSL_SYS_LINUX
453 socklen_t addr_len; 467 socklen_t addr_len;
454 union { 468 union {
455 struct sockaddr sa; 469 struct sockaddr sa;
@@ -531,7 +545,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
531 break; 545 break;
532 /* (Linux)kernel sets DF bit on outgoing IP packets */ 546 /* (Linux)kernel sets DF bit on outgoing IP packets */
533 case BIO_CTRL_DGRAM_MTU_DISCOVER: 547 case BIO_CTRL_DGRAM_MTU_DISCOVER:
534#ifdef OPENSSL_SYS_LINUX 548#if defined(OPENSSL_SYS_LINUX) && defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DO)
535 addr_len = (socklen_t)sizeof(addr); 549 addr_len = (socklen_t)sizeof(addr);
536 memset((void *)&addr, 0, sizeof(addr)); 550 memset((void *)&addr, 0, sizeof(addr));
537 if (getsockname(b->num, &addr.sa, &addr_len) < 0) 551 if (getsockname(b->num, &addr.sa, &addr_len) < 0)
@@ -539,7 +553,6 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
539 ret = 0; 553 ret = 0;
540 break; 554 break;
541 } 555 }
542 sockopt_len = sizeof(sockopt_val);
543 switch (addr.sa.sa_family) 556 switch (addr.sa.sa_family)
544 { 557 {
545 case AF_INET: 558 case AF_INET:
@@ -548,7 +561,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
548 &sockopt_val, sizeof(sockopt_val))) < 0) 561 &sockopt_val, sizeof(sockopt_val))) < 0)
549 perror("setsockopt"); 562 perror("setsockopt");
550 break; 563 break;
551#if OPENSSL_USE_IPV6 && defined(IPV6_MTU_DISCOVER) 564#if OPENSSL_USE_IPV6 && defined(IPV6_MTU_DISCOVER) && defined(IPV6_PMTUDISC_DO)
552 case AF_INET6: 565 case AF_INET6:
553 sockopt_val = IPV6_PMTUDISC_DO; 566 sockopt_val = IPV6_PMTUDISC_DO;
554 if ((ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_MTU_DISCOVER, 567 if ((ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_MTU_DISCOVER,
@@ -565,7 +578,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
565 break; 578 break;
566#endif 579#endif
567 case BIO_CTRL_DGRAM_QUERY_MTU: 580 case BIO_CTRL_DGRAM_QUERY_MTU:
568#ifdef OPENSSL_SYS_LINUX 581#if defined(OPENSSL_SYS_LINUX) && defined(IP_MTU)
569 addr_len = (socklen_t)sizeof(addr); 582 addr_len = (socklen_t)sizeof(addr);
570 memset((void *)&addr, 0, sizeof(addr)); 583 memset((void *)&addr, 0, sizeof(addr));
571 if (getsockname(b->num, &addr.sa, &addr_len) < 0) 584 if (getsockname(b->num, &addr.sa, &addr_len) < 0)
@@ -727,12 +740,15 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
727#endif 740#endif
728 break; 741 break;
729 case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT: 742 case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT:
730#ifdef OPENSSL_SYS_WINDOWS
731 { 743 {
732 int timeout, sz = sizeof(timeout); 744 union { size_t s; int i; } sz = {0};
745#ifdef OPENSSL_SYS_WINDOWS
746 int timeout;
733 struct timeval *tv = (struct timeval *)ptr; 747 struct timeval *tv = (struct timeval *)ptr;
748
749 sz.i = sizeof(timeout);
734 if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, 750 if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
735 (void*)&timeout, &sz) < 0) 751 (void*)&timeout, &sz.i) < 0)
736 { perror("getsockopt"); ret = -1; } 752 { perror("getsockopt"); ret = -1; }
737 else 753 else
738 { 754 {
@@ -740,12 +756,20 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
740 tv->tv_usec = (timeout % 1000) * 1000; 756 tv->tv_usec = (timeout % 1000) * 1000;
741 ret = sizeof(*tv); 757 ret = sizeof(*tv);
742 } 758 }
743 }
744#else 759#else
760 sz.i = sizeof(struct timeval);
745 if ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, 761 if ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
746 ptr, (void *)&ret) < 0) 762 ptr, (void *)&sz) < 0)
747 { perror("getsockopt"); ret = -1; } 763 { perror("getsockopt"); ret = -1; }
764 else if (sizeof(sz.s)!=sizeof(sz.i) && sz.i==0)
765 {
766 OPENSSL_assert(sz.s<=sizeof(struct timeval));
767 ret = (int)sz.s;
768 }
769 else
770 ret = sz.i;
748#endif 771#endif
772 }
749 break; 773 break;
750#endif 774#endif
751#if defined(SO_SNDTIMEO) 775#if defined(SO_SNDTIMEO)
@@ -765,12 +789,15 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
765#endif 789#endif
766 break; 790 break;
767 case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT: 791 case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT:
768#ifdef OPENSSL_SYS_WINDOWS
769 { 792 {
770 int timeout, sz = sizeof(timeout); 793 union { size_t s; int i; } sz = {0};
794#ifdef OPENSSL_SYS_WINDOWS
795 int timeout;
771 struct timeval *tv = (struct timeval *)ptr; 796 struct timeval *tv = (struct timeval *)ptr;
797
798 sz.i = sizeof(timeout);
772 if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, 799 if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO,
773 (void*)&timeout, &sz) < 0) 800 (void*)&timeout, &sz.i) < 0)
774 { perror("getsockopt"); ret = -1; } 801 { perror("getsockopt"); ret = -1; }
775 else 802 else
776 { 803 {
@@ -778,12 +805,20 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
778 tv->tv_usec = (timeout % 1000) * 1000; 805 tv->tv_usec = (timeout % 1000) * 1000;
779 ret = sizeof(*tv); 806 ret = sizeof(*tv);
780 } 807 }
781 }
782#else 808#else
809 sz.i = sizeof(struct timeval);
783 if ( getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, 810 if ( getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO,
784 ptr, (void *)&ret) < 0) 811 ptr, (void *)&sz) < 0)
785 { perror("getsockopt"); ret = -1; } 812 { perror("getsockopt"); ret = -1; }
813 else if (sizeof(sz.s)!=sizeof(sz.i) && sz.i==0)
814 {
815 OPENSSL_assert(sz.s<=sizeof(struct timeval));
816 ret = (int)sz.s;
817 }
818 else
819 ret = sz.i;
786#endif 820#endif
821 }
787 break; 822 break;
788#endif 823#endif
789 case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP: 824 case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP:
@@ -871,8 +906,8 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
871 memset(authchunks, 0, sizeof(sockopt_len)); 906 memset(authchunks, 0, sizeof(sockopt_len));
872 ret = getsockopt(fd, IPPROTO_SCTP, SCTP_LOCAL_AUTH_CHUNKS, authchunks, &sockopt_len); 907 ret = getsockopt(fd, IPPROTO_SCTP, SCTP_LOCAL_AUTH_CHUNKS, authchunks, &sockopt_len);
873 OPENSSL_assert(ret >= 0); 908 OPENSSL_assert(ret >= 0);
874 909
875 for (p = (unsigned char*) authchunks + sizeof(sctp_assoc_t); 910 for (p = (unsigned char*) authchunks->gauth_chunks;
876 p < (unsigned char*) authchunks + sockopt_len; 911 p < (unsigned char*) authchunks + sockopt_len;
877 p += sizeof(uint8_t)) 912 p += sizeof(uint8_t))
878 { 913 {
@@ -955,7 +990,6 @@ static int dgram_sctp_free(BIO *a)
955#ifdef SCTP_AUTHENTICATION_EVENT 990#ifdef SCTP_AUTHENTICATION_EVENT
956void dgram_sctp_handle_auth_free_key_event(BIO *b, union sctp_notification *snp) 991void dgram_sctp_handle_auth_free_key_event(BIO *b, union sctp_notification *snp)
957 { 992 {
958 unsigned int sockopt_len = 0;
959 int ret; 993 int ret;
960 struct sctp_authkey_event* authkeyevent = &snp->sn_auth_event; 994 struct sctp_authkey_event* authkeyevent = &snp->sn_auth_event;
961 995
@@ -965,9 +999,8 @@ void dgram_sctp_handle_auth_free_key_event(BIO *b, union sctp_notification *snp)
965 999
966 /* delete key */ 1000 /* delete key */
967 authkeyid.scact_keynumber = authkeyevent->auth_keynumber; 1001 authkeyid.scact_keynumber = authkeyevent->auth_keynumber;
968 sockopt_len = sizeof(struct sctp_authkeyid);
969 ret = setsockopt(b->num, IPPROTO_SCTP, SCTP_AUTH_DELETE_KEY, 1002 ret = setsockopt(b->num, IPPROTO_SCTP, SCTP_AUTH_DELETE_KEY,
970 &authkeyid, sockopt_len); 1003 &authkeyid, sizeof(struct sctp_authkeyid));
971 } 1004 }
972 } 1005 }
973#endif 1006#endif
@@ -1164,7 +1197,7 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
1164 ii = getsockopt(b->num, IPPROTO_SCTP, SCTP_PEER_AUTH_CHUNKS, authchunks, &optlen); 1197 ii = getsockopt(b->num, IPPROTO_SCTP, SCTP_PEER_AUTH_CHUNKS, authchunks, &optlen);
1165 OPENSSL_assert(ii >= 0); 1198 OPENSSL_assert(ii >= 0);
1166 1199
1167 for (p = (unsigned char*) authchunks + sizeof(sctp_assoc_t); 1200 for (p = (unsigned char*) authchunks->gauth_chunks;
1168 p < (unsigned char*) authchunks + optlen; 1201 p < (unsigned char*) authchunks + optlen;
1169 p += sizeof(uint8_t)) 1202 p += sizeof(uint8_t))
1170 { 1203 {
@@ -1298,7 +1331,7 @@ static long dgram_sctp_ctrl(BIO *b, int cmd, long num, void *ptr)
1298 { 1331 {
1299 long ret=1; 1332 long ret=1;
1300 bio_dgram_sctp_data *data = NULL; 1333 bio_dgram_sctp_data *data = NULL;
1301 unsigned int sockopt_len = 0; 1334 socklen_t sockopt_len = 0;
1302 struct sctp_authkeyid authkeyid; 1335 struct sctp_authkeyid authkeyid;
1303 struct sctp_authkey *authkey; 1336 struct sctp_authkey *authkey;
1304 1337
diff --git a/src/lib/libssl/src/crypto/bn/asm/mips-mont.pl b/src/lib/libssl/src/crypto/bn/asm/mips-mont.pl
index b944a12b8e..caae04ed3a 100644
--- a/src/lib/libssl/src/crypto/bn/asm/mips-mont.pl
+++ b/src/lib/libssl/src/crypto/bn/asm/mips-mont.pl
@@ -133,7 +133,7 @@ $code.=<<___;
133 bnez $at,1f 133 bnez $at,1f
134 li $t0,0 134 li $t0,0
135 slt $at,$num,17 # on in-order CPU 135 slt $at,$num,17 # on in-order CPU
136 bnezl $at,bn_mul_mont_internal 136 bnez $at,bn_mul_mont_internal
137 nop 137 nop
1381: jr $ra 1381: jr $ra
139 li $a0,0 139 li $a0,0
diff --git a/src/lib/libssl/src/crypto/bn/asm/mips.pl b/src/lib/libssl/src/crypto/bn/asm/mips.pl
index c162a3ec23..d2f3ef7bbf 100644
--- a/src/lib/libssl/src/crypto/bn/asm/mips.pl
+++ b/src/lib/libssl/src/crypto/bn/asm/mips.pl
@@ -140,10 +140,10 @@ $code.=<<___;
140 .set reorder 140 .set reorder
141 li $minus4,-4 141 li $minus4,-4
142 and $ta0,$a2,$minus4 142 and $ta0,$a2,$minus4
143 $LD $t0,0($a1)
144 beqz $ta0,.L_bn_mul_add_words_tail 143 beqz $ta0,.L_bn_mul_add_words_tail
145 144
146.L_bn_mul_add_words_loop: 145.L_bn_mul_add_words_loop:
146 $LD $t0,0($a1)
147 $MULTU $t0,$a3 147 $MULTU $t0,$a3
148 $LD $t1,0($a0) 148 $LD $t1,0($a0)
149 $LD $t2,$BNSZ($a1) 149 $LD $t2,$BNSZ($a1)
@@ -200,10 +200,9 @@ $code.=<<___;
200 $ADDU $v0,$ta2 200 $ADDU $v0,$ta2
201 sltu $at,$ta3,$at 201 sltu $at,$ta3,$at
202 $ST $ta3,-$BNSZ($a0) 202 $ST $ta3,-$BNSZ($a0)
203 $ADDU $v0,$at
204 .set noreorder 203 .set noreorder
205 bgtzl $ta0,.L_bn_mul_add_words_loop 204 bgtz $ta0,.L_bn_mul_add_words_loop
206 $LD $t0,0($a1) 205 $ADDU $v0,$at
207 206
208 beqz $a2,.L_bn_mul_add_words_return 207 beqz $a2,.L_bn_mul_add_words_return
209 nop 208 nop
@@ -300,10 +299,10 @@ $code.=<<___;
300 .set reorder 299 .set reorder
301 li $minus4,-4 300 li $minus4,-4
302 and $ta0,$a2,$minus4 301 and $ta0,$a2,$minus4
303 $LD $t0,0($a1)
304 beqz $ta0,.L_bn_mul_words_tail 302 beqz $ta0,.L_bn_mul_words_tail
305 303
306.L_bn_mul_words_loop: 304.L_bn_mul_words_loop:
305 $LD $t0,0($a1)
307 $MULTU $t0,$a3 306 $MULTU $t0,$a3
308 $LD $t2,$BNSZ($a1) 307 $LD $t2,$BNSZ($a1)
309 $LD $ta0,2*$BNSZ($a1) 308 $LD $ta0,2*$BNSZ($a1)
@@ -341,10 +340,9 @@ $code.=<<___;
341 $ADDU $v0,$at 340 $ADDU $v0,$at
342 sltu $ta3,$v0,$at 341 sltu $ta3,$v0,$at
343 $ST $v0,-$BNSZ($a0) 342 $ST $v0,-$BNSZ($a0)
344 $ADDU $v0,$ta3,$ta2
345 .set noreorder 343 .set noreorder
346 bgtzl $ta0,.L_bn_mul_words_loop 344 bgtz $ta0,.L_bn_mul_words_loop
347 $LD $t0,0($a1) 345 $ADDU $v0,$ta3,$ta2
348 346
349 beqz $a2,.L_bn_mul_words_return 347 beqz $a2,.L_bn_mul_words_return
350 nop 348 nop
@@ -429,10 +427,10 @@ $code.=<<___;
429 .set reorder 427 .set reorder
430 li $minus4,-4 428 li $minus4,-4
431 and $ta0,$a2,$minus4 429 and $ta0,$a2,$minus4
432 $LD $t0,0($a1)
433 beqz $ta0,.L_bn_sqr_words_tail 430 beqz $ta0,.L_bn_sqr_words_tail
434 431
435.L_bn_sqr_words_loop: 432.L_bn_sqr_words_loop:
433 $LD $t0,0($a1)
436 $MULTU $t0,$t0 434 $MULTU $t0,$t0
437 $LD $t2,$BNSZ($a1) 435 $LD $t2,$BNSZ($a1)
438 $LD $ta0,2*$BNSZ($a1) 436 $LD $ta0,2*$BNSZ($a1)
@@ -463,11 +461,10 @@ $code.=<<___;
463 mflo $ta3 461 mflo $ta3
464 mfhi $ta2 462 mfhi $ta2
465 $ST $ta3,-2*$BNSZ($a0) 463 $ST $ta3,-2*$BNSZ($a0)
466 $ST $ta2,-$BNSZ($a0)
467 464
468 .set noreorder 465 .set noreorder
469 bgtzl $ta0,.L_bn_sqr_words_loop 466 bgtz $ta0,.L_bn_sqr_words_loop
470 $LD $t0,0($a1) 467 $ST $ta2,-$BNSZ($a0)
471 468
472 beqz $a2,.L_bn_sqr_words_return 469 beqz $a2,.L_bn_sqr_words_return
473 nop 470 nop
@@ -547,10 +544,10 @@ $code.=<<___;
547 .set reorder 544 .set reorder
548 li $minus4,-4 545 li $minus4,-4
549 and $at,$a3,$minus4 546 and $at,$a3,$minus4
550 $LD $t0,0($a1)
551 beqz $at,.L_bn_add_words_tail 547 beqz $at,.L_bn_add_words_tail
552 548
553.L_bn_add_words_loop: 549.L_bn_add_words_loop:
550 $LD $t0,0($a1)
554 $LD $ta0,0($a2) 551 $LD $ta0,0($a2)
555 subu $a3,4 552 subu $a3,4
556 $LD $t1,$BNSZ($a1) 553 $LD $t1,$BNSZ($a1)
@@ -589,11 +586,10 @@ $code.=<<___;
589 $ADDU $t3,$ta3,$v0 586 $ADDU $t3,$ta3,$v0
590 sltu $v0,$t3,$ta3 587 sltu $v0,$t3,$ta3
591 $ST $t3,-$BNSZ($a0) 588 $ST $t3,-$BNSZ($a0)
592 $ADDU $v0,$t9
593 589
594 .set noreorder 590 .set noreorder
595 bgtzl $at,.L_bn_add_words_loop 591 bgtz $at,.L_bn_add_words_loop
596 $LD $t0,0($a1) 592 $ADDU $v0,$t9
597 593
598 beqz $a3,.L_bn_add_words_return 594 beqz $a3,.L_bn_add_words_return
599 nop 595 nop
@@ -679,10 +675,10 @@ $code.=<<___;
679 .set reorder 675 .set reorder
680 li $minus4,-4 676 li $minus4,-4
681 and $at,$a3,$minus4 677 and $at,$a3,$minus4
682 $LD $t0,0($a1)
683 beqz $at,.L_bn_sub_words_tail 678 beqz $at,.L_bn_sub_words_tail
684 679
685.L_bn_sub_words_loop: 680.L_bn_sub_words_loop:
681 $LD $t0,0($a1)
686 $LD $ta0,0($a2) 682 $LD $ta0,0($a2)
687 subu $a3,4 683 subu $a3,4
688 $LD $t1,$BNSZ($a1) 684 $LD $t1,$BNSZ($a1)
@@ -722,11 +718,10 @@ $code.=<<___;
722 $SUBU $t3,$ta3,$v0 718 $SUBU $t3,$ta3,$v0
723 sgtu $v0,$t3,$ta3 719 sgtu $v0,$t3,$ta3
724 $ST $t3,-$BNSZ($a0) 720 $ST $t3,-$BNSZ($a0)
725 $ADDU $v0,$t9
726 721
727 .set noreorder 722 .set noreorder
728 bgtzl $at,.L_bn_sub_words_loop 723 bgtz $at,.L_bn_sub_words_loop
729 $LD $t0,0($a1) 724 $ADDU $v0,$t9
730 725
731 beqz $a3,.L_bn_sub_words_return 726 beqz $a3,.L_bn_sub_words_return
732 nop 727 nop
@@ -819,7 +814,7 @@ ___
819$code.=<<___; 814$code.=<<___;
820 .set reorder 815 .set reorder
821 move $ta3,$ra 816 move $ta3,$ra
822 bal bn_div_words 817 bal bn_div_words_internal
823 move $ra,$ta3 818 move $ra,$ta3
824 $MULTU $ta2,$v0 819 $MULTU $ta2,$v0
825 $LD $t2,-2*$BNSZ($a3) 820 $LD $t2,-2*$BNSZ($a3)
@@ -840,8 +835,9 @@ $code.=<<___;
840 sltu $ta0,$a1,$a2 835 sltu $ta0,$a1,$a2
841 or $t8,$ta0 836 or $t8,$ta0
842 .set noreorder 837 .set noreorder
843 beqzl $at,.L_bn_div_3_words_inner_loop 838 beqz $at,.L_bn_div_3_words_inner_loop
844 $SUBU $v0,1 839 $SUBU $v0,1
840 $ADDU $v0,1
845 .set reorder 841 .set reorder
846.L_bn_div_3_words_inner_loop_done: 842.L_bn_div_3_words_inner_loop_done:
847 .set noreorder 843 .set noreorder
@@ -902,7 +898,8 @@ $code.=<<___;
902 and $t2,$a0 898 and $t2,$a0
903 $SRL $at,$a1,$t1 899 $SRL $at,$a1,$t1
904 .set noreorder 900 .set noreorder
905 bnezl $t2,.+8 901 beqz $t2,.+12
902 nop
906 break 6 # signal overflow 903 break 6 # signal overflow
907 .set reorder 904 .set reorder
908 $SLL $a0,$t9 905 $SLL $a0,$t9
@@ -917,7 +914,8 @@ $code.=<<___;
917 $SRL $DH,$a2,4*$BNSZ # bits 914 $SRL $DH,$a2,4*$BNSZ # bits
918 sgeu $at,$a0,$a2 915 sgeu $at,$a0,$a2
919 .set noreorder 916 .set noreorder
920 bnezl $at,.+8 917 beqz $at,.+12
918 nop
921 $SUBU $a0,$a2 919 $SUBU $a0,$a2
922 .set reorder 920 .set reorder
923 921
diff --git a/src/lib/libssl/src/crypto/bn/asm/modexp512-x86_64.pl b/src/lib/libssl/src/crypto/bn/asm/modexp512-x86_64.pl
index 54aeb01921..bfd6e97541 100644
--- a/src/lib/libssl/src/crypto/bn/asm/modexp512-x86_64.pl
+++ b/src/lib/libssl/src/crypto/bn/asm/modexp512-x86_64.pl
@@ -68,7 +68,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
68( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or 68( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
69die "can't locate x86_64-xlate.pl"; 69die "can't locate x86_64-xlate.pl";
70 70
71open STDOUT,"| $^X $xlate $flavour $output"; 71open OUT,"| \"$^X\" $xlate $flavour $output";
72*STDOUT=*OUT;
72 73
73use strict; 74use strict;
74my $code=".text\n\n"; 75my $code=".text\n\n";
diff --git a/src/lib/libssl/src/crypto/bn/asm/parisc-mont.pl b/src/lib/libssl/src/crypto/bn/asm/parisc-mont.pl
index 4a766a87fb..c02ef6f014 100644
--- a/src/lib/libssl/src/crypto/bn/asm/parisc-mont.pl
+++ b/src/lib/libssl/src/crypto/bn/asm/parisc-mont.pl
@@ -40,7 +40,7 @@
40# of arithmetic operations, most notably multiplications. It requires 40# of arithmetic operations, most notably multiplications. It requires
41# more memory references, most notably to tp[num], but this doesn't 41# more memory references, most notably to tp[num], but this doesn't
42# seem to exhaust memory port capacity. And indeed, dedicated PA-RISC 42# seem to exhaust memory port capacity. And indeed, dedicated PA-RISC
43# 2.0 code path, provides virtually same performance as pa-risc2[W].s: 43# 2.0 code path provides virtually same performance as pa-risc2[W].s:
44# it's ~10% better for shortest key length and ~10% worse for longest 44# it's ~10% better for shortest key length and ~10% worse for longest
45# one. 45# one.
46# 46#
@@ -988,6 +988,8 @@ foreach (split("\n",$code)) {
988 # assemble 2.0 instructions in 32-bit mode... 988 # assemble 2.0 instructions in 32-bit mode...
989 s/^\s+([a-z]+)([\S]*)\s+([\S]*)/&assemble($1,$2,$3)/e if ($BN_SZ==4); 989 s/^\s+([a-z]+)([\S]*)\s+([\S]*)/&assemble($1,$2,$3)/e if ($BN_SZ==4);
990 990
991 s/\bbv\b/bve/gm if ($SIZE_T==8);
992
991 print $_,"\n"; 993 print $_,"\n";
992} 994}
993close STDOUT; 995close STDOUT;
diff --git a/src/lib/libssl/src/crypto/bn/asm/x86_64-gf2m.pl b/src/lib/libssl/src/crypto/bn/asm/x86_64-gf2m.pl
index 1658acbbdd..226c66c35e 100644
--- a/src/lib/libssl/src/crypto/bn/asm/x86_64-gf2m.pl
+++ b/src/lib/libssl/src/crypto/bn/asm/x86_64-gf2m.pl
@@ -31,7 +31,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
31( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or 31( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
32die "can't locate x86_64-xlate.pl"; 32die "can't locate x86_64-xlate.pl";
33 33
34open STDOUT,"| $^X $xlate $flavour $output"; 34open OUT,"| \"$^X\" $xlate $flavour $output";
35*STDOUT=*OUT;
35 36
36($lo,$hi)=("%rax","%rdx"); $a=$lo; 37($lo,$hi)=("%rax","%rdx"); $a=$lo;
37($i0,$i1)=("%rsi","%rdi"); 38($i0,$i1)=("%rsi","%rdi");
diff --git a/src/lib/libssl/src/crypto/bn/asm/x86_64-mont.pl b/src/lib/libssl/src/crypto/bn/asm/x86_64-mont.pl
index 5d79b35e1c..17fb94c84c 100755
--- a/src/lib/libssl/src/crypto/bn/asm/x86_64-mont.pl
+++ b/src/lib/libssl/src/crypto/bn/asm/x86_64-mont.pl
@@ -40,7 +40,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
40( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or 40( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
41die "can't locate x86_64-xlate.pl"; 41die "can't locate x86_64-xlate.pl";
42 42
43open STDOUT,"| $^X $xlate $flavour $output"; 43open OUT,"| \"$^X\" $xlate $flavour $output";
44*STDOUT=*OUT;
44 45
45# int bn_mul_mont( 46# int bn_mul_mont(
46$rp="%rdi"; # BN_ULONG *rp, 47$rp="%rdi"; # BN_ULONG *rp,
diff --git a/src/lib/libssl/src/crypto/bn/asm/x86_64-mont5.pl b/src/lib/libssl/src/crypto/bn/asm/x86_64-mont5.pl
index 057cda28aa..dae0fe2453 100755
--- a/src/lib/libssl/src/crypto/bn/asm/x86_64-mont5.pl
+++ b/src/lib/libssl/src/crypto/bn/asm/x86_64-mont5.pl
@@ -28,7 +28,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
28( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or 28( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
29die "can't locate x86_64-xlate.pl"; 29die "can't locate x86_64-xlate.pl";
30 30
31open STDOUT,"| $^X $xlate $flavour $output"; 31open OUT,"| \"$^X\" $xlate $flavour $output";
32*STDOUT=*OUT;
32 33
33# int bn_mul_mont_gather5( 34# int bn_mul_mont_gather5(
34$rp="%rdi"; # BN_ULONG *rp, 35$rp="%rdi"; # BN_ULONG *rp,
@@ -900,8 +901,8 @@ $code.=<<___;
900 jnz .Lgather 901 jnz .Lgather
901___ 902___
902$code.=<<___ if ($win64); 903$code.=<<___ if ($win64);
903 movaps %xmm6,(%rsp) 904 movaps (%rsp),%xmm6
904 movaps %xmm7,0x10(%rsp) 905 movaps 0x10(%rsp),%xmm7
905 lea 0x28(%rsp),%rsp 906 lea 0x28(%rsp),%rsp
906___ 907___
907$code.=<<___; 908$code.=<<___;
diff --git a/src/lib/libssl/src/crypto/bn/bn_nist.c b/src/lib/libssl/src/crypto/bn/bn_nist.c
index 43caee4770..e22968d4a3 100644
--- a/src/lib/libssl/src/crypto/bn/bn_nist.c
+++ b/src/lib/libssl/src/crypto/bn/bn_nist.c
@@ -286,26 +286,25 @@ const BIGNUM *BN_get0_nist_prime_521(void)
286 } 286 }
287 287
288 288
289static void nist_cp_bn_0(BN_ULONG *buf, BN_ULONG *a, int top, int max) 289static void nist_cp_bn_0(BN_ULONG *dst, const BN_ULONG *src, int top, int max)
290 { 290 {
291 int i; 291 int i;
292 BN_ULONG *_tmp1 = (buf), *_tmp2 = (a);
293 292
294#ifdef BN_DEBUG 293#ifdef BN_DEBUG
295 OPENSSL_assert(top <= max); 294 OPENSSL_assert(top <= max);
296#endif 295#endif
297 for (i = (top); i != 0; i--) 296 for (i = 0; i < top; i++)
298 *_tmp1++ = *_tmp2++; 297 dst[i] = src[i];
299 for (i = (max) - (top); i != 0; i--) 298 for (; i < max; i++)
300 *_tmp1++ = (BN_ULONG) 0; 299 dst[i] = 0;
301 } 300 }
302 301
303static void nist_cp_bn(BN_ULONG *buf, BN_ULONG *a, int top) 302static void nist_cp_bn(BN_ULONG *dst, const BN_ULONG *src, int top)
304 { 303 {
305 int i; 304 int i;
306 BN_ULONG *_tmp1 = (buf), *_tmp2 = (a); 305
307 for (i = (top); i != 0; i--) 306 for (i = 0; i < top; i++)
308 *_tmp1++ = *_tmp2++; 307 dst[i] = src[i];
309 } 308 }
310 309
311#if BN_BITS2 == 64 310#if BN_BITS2 == 64
@@ -451,8 +450,9 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
451 */ 450 */
452 mask = 0-(PTR_SIZE_INT)bn_sub_words(c_d,r_d,_nist_p_192[0],BN_NIST_192_TOP); 451 mask = 0-(PTR_SIZE_INT)bn_sub_words(c_d,r_d,_nist_p_192[0],BN_NIST_192_TOP);
453 mask &= 0-(PTR_SIZE_INT)carry; 452 mask &= 0-(PTR_SIZE_INT)carry;
453 res = c_d;
454 res = (BN_ULONG *) 454 res = (BN_ULONG *)
455 (((PTR_SIZE_INT)c_d&~mask) | ((PTR_SIZE_INT)r_d&mask)); 455 (((PTR_SIZE_INT)res&~mask) | ((PTR_SIZE_INT)r_d&mask));
456 nist_cp_bn(r_d, res, BN_NIST_192_TOP); 456 nist_cp_bn(r_d, res, BN_NIST_192_TOP);
457 r->top = BN_NIST_192_TOP; 457 r->top = BN_NIST_192_TOP;
458 bn_correct_top(r); 458 bn_correct_top(r);
@@ -479,8 +479,11 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
479 int top = a->top, i; 479 int top = a->top, i;
480 int carry; 480 int carry;
481 BN_ULONG *r_d, *a_d = a->d; 481 BN_ULONG *r_d, *a_d = a->d;
482 BN_ULONG buf[BN_NIST_224_TOP], 482 union {
483 c_d[BN_NIST_224_TOP], 483 BN_ULONG bn[BN_NIST_224_TOP];
484 unsigned int ui[BN_NIST_224_TOP*sizeof(BN_ULONG)/sizeof(unsigned int)];
485 } buf;
486 BN_ULONG c_d[BN_NIST_224_TOP],
484 *res; 487 *res;
485 PTR_SIZE_INT mask; 488 PTR_SIZE_INT mask;
486 union { bn_addsub_f f; PTR_SIZE_INT p; } u; 489 union { bn_addsub_f f; PTR_SIZE_INT p; } u;
@@ -519,18 +522,18 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
519 /* copy upper 256 bits of 448 bit number ... */ 522 /* copy upper 256 bits of 448 bit number ... */
520 nist_cp_bn_0(c_d, a_d + (BN_NIST_224_TOP-1), top - (BN_NIST_224_TOP-1), BN_NIST_224_TOP); 523 nist_cp_bn_0(c_d, a_d + (BN_NIST_224_TOP-1), top - (BN_NIST_224_TOP-1), BN_NIST_224_TOP);
521 /* ... and right shift by 32 to obtain upper 224 bits */ 524 /* ... and right shift by 32 to obtain upper 224 bits */
522 nist_set_224(buf, c_d, 14, 13, 12, 11, 10, 9, 8); 525 nist_set_224(buf.bn, c_d, 14, 13, 12, 11, 10, 9, 8);
523 /* truncate lower part to 224 bits too */ 526 /* truncate lower part to 224 bits too */
524 r_d[BN_NIST_224_TOP-1] &= BN_MASK2l; 527 r_d[BN_NIST_224_TOP-1] &= BN_MASK2l;
525#else 528#else
526 nist_cp_bn_0(buf, a_d + BN_NIST_224_TOP, top - BN_NIST_224_TOP, BN_NIST_224_TOP); 529 nist_cp_bn_0(buf.bn, a_d + BN_NIST_224_TOP, top - BN_NIST_224_TOP, BN_NIST_224_TOP);
527#endif 530#endif
528 531
529#if defined(NIST_INT64) && BN_BITS2!=64 532#if defined(NIST_INT64) && BN_BITS2!=64
530 { 533 {
531 NIST_INT64 acc; /* accumulator */ 534 NIST_INT64 acc; /* accumulator */
532 unsigned int *rp=(unsigned int *)r_d; 535 unsigned int *rp=(unsigned int *)r_d;
533 const unsigned int *bp=(const unsigned int *)buf; 536 const unsigned int *bp=(const unsigned int *)buf.ui;
534 537
535 acc = rp[0]; acc -= bp[7-7]; 538 acc = rp[0]; acc -= bp[7-7];
536 acc -= bp[11-7]; rp[0] = (unsigned int)acc; acc >>= 32; 539 acc -= bp[11-7]; rp[0] = (unsigned int)acc; acc >>= 32;
@@ -565,13 +568,13 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
565 { 568 {
566 BN_ULONG t_d[BN_NIST_224_TOP]; 569 BN_ULONG t_d[BN_NIST_224_TOP];
567 570
568 nist_set_224(t_d, buf, 10, 9, 8, 7, 0, 0, 0); 571 nist_set_224(t_d, buf.bn, 10, 9, 8, 7, 0, 0, 0);
569 carry = (int)bn_add_words(r_d, r_d, t_d, BN_NIST_224_TOP); 572 carry = (int)bn_add_words(r_d, r_d, t_d, BN_NIST_224_TOP);
570 nist_set_224(t_d, buf, 0, 13, 12, 11, 0, 0, 0); 573 nist_set_224(t_d, buf.bn, 0, 13, 12, 11, 0, 0, 0);
571 carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_224_TOP); 574 carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_224_TOP);
572 nist_set_224(t_d, buf, 13, 12, 11, 10, 9, 8, 7); 575 nist_set_224(t_d, buf.bn, 13, 12, 11, 10, 9, 8, 7);
573 carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_224_TOP); 576 carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_224_TOP);
574 nist_set_224(t_d, buf, 0, 0, 0, 0, 13, 12, 11); 577 nist_set_224(t_d, buf.bn, 0, 0, 0, 0, 13, 12, 11);
575 carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_224_TOP); 578 carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_224_TOP);
576 579
577#if BN_BITS2==64 580#if BN_BITS2==64
@@ -606,7 +609,8 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
606 /* otherwise it's effectively same as in BN_nist_mod_192... */ 609 /* otherwise it's effectively same as in BN_nist_mod_192... */
607 mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_224[0],BN_NIST_224_TOP); 610 mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_224[0],BN_NIST_224_TOP);
608 mask &= 0-(PTR_SIZE_INT)carry; 611 mask &= 0-(PTR_SIZE_INT)carry;
609 res = (BN_ULONG *)(((PTR_SIZE_INT)c_d&~mask) | 612 res = c_d;
613 res = (BN_ULONG *)(((PTR_SIZE_INT)res&~mask) |
610 ((PTR_SIZE_INT)r_d&mask)); 614 ((PTR_SIZE_INT)r_d&mask));
611 nist_cp_bn(r_d, res, BN_NIST_224_TOP); 615 nist_cp_bn(r_d, res, BN_NIST_224_TOP);
612 r->top = BN_NIST_224_TOP; 616 r->top = BN_NIST_224_TOP;
@@ -805,7 +809,8 @@ int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
805 809
806 mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_256[0],BN_NIST_256_TOP); 810 mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_256[0],BN_NIST_256_TOP);
807 mask &= 0-(PTR_SIZE_INT)carry; 811 mask &= 0-(PTR_SIZE_INT)carry;
808 res = (BN_ULONG *)(((PTR_SIZE_INT)c_d&~mask) | 812 res = c_d;
813 res = (BN_ULONG *)(((PTR_SIZE_INT)res&~mask) |
809 ((PTR_SIZE_INT)r_d&mask)); 814 ((PTR_SIZE_INT)r_d&mask));
810 nist_cp_bn(r_d, res, BN_NIST_256_TOP); 815 nist_cp_bn(r_d, res, BN_NIST_256_TOP);
811 r->top = BN_NIST_256_TOP; 816 r->top = BN_NIST_256_TOP;
@@ -1026,7 +1031,8 @@ int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
1026 1031
1027 mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_384[0],BN_NIST_384_TOP); 1032 mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_384[0],BN_NIST_384_TOP);
1028 mask &= 0-(PTR_SIZE_INT)carry; 1033 mask &= 0-(PTR_SIZE_INT)carry;
1029 res = (BN_ULONG *)(((PTR_SIZE_INT)c_d&~mask) | 1034 res = c_d;
1035 res = (BN_ULONG *)(((PTR_SIZE_INT)res&~mask) |
1030 ((PTR_SIZE_INT)r_d&mask)); 1036 ((PTR_SIZE_INT)r_d&mask));
1031 nist_cp_bn(r_d, res, BN_NIST_384_TOP); 1037 nist_cp_bn(r_d, res, BN_NIST_384_TOP);
1032 r->top = BN_NIST_384_TOP; 1038 r->top = BN_NIST_384_TOP;
@@ -1092,7 +1098,8 @@ int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
1092 1098
1093 bn_add_words(r_d,r_d,t_d,BN_NIST_521_TOP); 1099 bn_add_words(r_d,r_d,t_d,BN_NIST_521_TOP);
1094 mask = 0-(PTR_SIZE_INT)bn_sub_words(t_d,r_d,_nist_p_521,BN_NIST_521_TOP); 1100 mask = 0-(PTR_SIZE_INT)bn_sub_words(t_d,r_d,_nist_p_521,BN_NIST_521_TOP);
1095 res = (BN_ULONG *)(((PTR_SIZE_INT)t_d&~mask) | 1101 res = t_d;
1102 res = (BN_ULONG *)(((PTR_SIZE_INT)res&~mask) |
1096 ((PTR_SIZE_INT)r_d&mask)); 1103 ((PTR_SIZE_INT)r_d&mask));
1097 nist_cp_bn(r_d,res,BN_NIST_521_TOP); 1104 nist_cp_bn(r_d,res,BN_NIST_521_TOP);
1098 r->top = BN_NIST_521_TOP; 1105 r->top = BN_NIST_521_TOP;
diff --git a/src/lib/libssl/src/crypto/camellia/asm/cmll-x86_64.pl b/src/lib/libssl/src/crypto/camellia/asm/cmll-x86_64.pl
index 76955e4726..9f4b82fa48 100644
--- a/src/lib/libssl/src/crypto/camellia/asm/cmll-x86_64.pl
+++ b/src/lib/libssl/src/crypto/camellia/asm/cmll-x86_64.pl
@@ -40,7 +40,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
40( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or 40( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
41die "can't locate x86_64-xlate.pl"; 41die "can't locate x86_64-xlate.pl";
42 42
43open STDOUT,"| $^X $xlate $flavour $output"; 43open OUT,"| \"$^X\" $xlate $flavour $output";
44*STDOUT=*OUT;
44 45
45sub hi() { my $r=shift; $r =~ s/%[er]([a-d])x/%\1h/; $r; } 46sub hi() { my $r=shift; $r =~ s/%[er]([a-d])x/%\1h/; $r; }
46sub lo() { my $r=shift; $r =~ s/%[er]([a-d])x/%\1l/; 47sub lo() { my $r=shift; $r =~ s/%[er]([a-d])x/%\1l/;
diff --git a/src/lib/libssl/src/crypto/cms/cms_cd.c b/src/lib/libssl/src/crypto/cms/cms_cd.c
index a5fc2c4e2b..2021688101 100644
--- a/src/lib/libssl/src/crypto/cms/cms_cd.c
+++ b/src/lib/libssl/src/crypto/cms/cms_cd.c
@@ -58,7 +58,9 @@
58#include <openssl/err.h> 58#include <openssl/err.h>
59#include <openssl/cms.h> 59#include <openssl/cms.h>
60#include <openssl/bio.h> 60#include <openssl/bio.h>
61#ifndef OPENSSL_NO_COMP
61#include <openssl/comp.h> 62#include <openssl/comp.h>
63#endif
62#include "cms_lcl.h" 64#include "cms_lcl.h"
63 65
64DECLARE_ASN1_ITEM(CMS_CompressedData) 66DECLARE_ASN1_ITEM(CMS_CompressedData)
diff --git a/src/lib/libssl/src/crypto/cms/cms_enc.c b/src/lib/libssl/src/crypto/cms/cms_enc.c
index f873ce3794..bebeaf29c7 100644
--- a/src/lib/libssl/src/crypto/cms/cms_enc.c
+++ b/src/lib/libssl/src/crypto/cms/cms_enc.c
@@ -74,7 +74,7 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec)
74 X509_ALGOR *calg = ec->contentEncryptionAlgorithm; 74 X509_ALGOR *calg = ec->contentEncryptionAlgorithm;
75 unsigned char iv[EVP_MAX_IV_LENGTH], *piv = NULL; 75 unsigned char iv[EVP_MAX_IV_LENGTH], *piv = NULL;
76 unsigned char *tkey = NULL; 76 unsigned char *tkey = NULL;
77 size_t tkeylen; 77 size_t tkeylen = 0;
78 78
79 int ok = 0; 79 int ok = 0;
80 80
diff --git a/src/lib/libssl/src/crypto/cms/cms_lib.c b/src/lib/libssl/src/crypto/cms/cms_lib.c
index f88e8f3b52..ba08279a04 100644
--- a/src/lib/libssl/src/crypto/cms/cms_lib.c
+++ b/src/lib/libssl/src/crypto/cms/cms_lib.c
@@ -411,9 +411,7 @@ int cms_DigestAlgorithm_find_ctx(EVP_MD_CTX *mctx, BIO *chain,
411 * algorithm OID instead of digest. 411 * algorithm OID instead of digest.
412 */ 412 */
413 || EVP_MD_pkey_type(EVP_MD_CTX_md(mtmp)) == nid) 413 || EVP_MD_pkey_type(EVP_MD_CTX_md(mtmp)) == nid)
414 {
415 return EVP_MD_CTX_copy_ex(mctx, mtmp); 414 return EVP_MD_CTX_copy_ex(mctx, mtmp);
416 }
417 chain = BIO_next(chain); 415 chain = BIO_next(chain);
418 } 416 }
419 } 417 }
@@ -467,8 +465,6 @@ int CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert)
467 pcerts = cms_get0_certificate_choices(cms); 465 pcerts = cms_get0_certificate_choices(cms);
468 if (!pcerts) 466 if (!pcerts)
469 return 0; 467 return 0;
470 if (!pcerts)
471 return 0;
472 for (i = 0; i < sk_CMS_CertificateChoices_num(*pcerts); i++) 468 for (i = 0; i < sk_CMS_CertificateChoices_num(*pcerts); i++)
473 { 469 {
474 cch = sk_CMS_CertificateChoices_value(*pcerts, i); 470 cch = sk_CMS_CertificateChoices_value(*pcerts, i);
diff --git a/src/lib/libssl/src/crypto/ec/ec2_mult.c b/src/lib/libssl/src/crypto/ec/ec2_mult.c
index 26f4a783fc..1c575dc47a 100644
--- a/src/lib/libssl/src/crypto/ec/ec2_mult.c
+++ b/src/lib/libssl/src/crypto/ec/ec2_mult.c
@@ -208,11 +208,15 @@ static int gf2m_Mxy(const EC_GROUP *group, const BIGNUM *x, const BIGNUM *y, BIG
208 return ret; 208 return ret;
209 } 209 }
210 210
211
211/* Computes scalar*point and stores the result in r. 212/* Computes scalar*point and stores the result in r.
212 * point can not equal r. 213 * point can not equal r.
213 * Uses algorithm 2P of 214 * Uses a modified algorithm 2P of
214 * Lopez, J. and Dahab, R. "Fast multiplication on elliptic curves over 215 * Lopez, J. and Dahab, R. "Fast multiplication on elliptic curves over
215 * GF(2^m) without precomputation" (CHES '99, LNCS 1717). 216 * GF(2^m) without precomputation" (CHES '99, LNCS 1717).
217 *
218 * To protect against side-channel attack the function uses constant time swap,
219 * avoiding conditional branches.
216 */ 220 */
217static int ec_GF2m_montgomery_point_multiply(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, 221static int ec_GF2m_montgomery_point_multiply(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
218 const EC_POINT *point, BN_CTX *ctx) 222 const EC_POINT *point, BN_CTX *ctx)
@@ -246,6 +250,11 @@ static int ec_GF2m_montgomery_point_multiply(const EC_GROUP *group, EC_POINT *r,
246 x2 = &r->X; 250 x2 = &r->X;
247 z2 = &r->Y; 251 z2 = &r->Y;
248 252
253 bn_wexpand(x1, group->field.top);
254 bn_wexpand(z1, group->field.top);
255 bn_wexpand(x2, group->field.top);
256 bn_wexpand(z2, group->field.top);
257
249 if (!BN_GF2m_mod_arr(x1, &point->X, group->poly)) goto err; /* x1 = x */ 258 if (!BN_GF2m_mod_arr(x1, &point->X, group->poly)) goto err; /* x1 = x */
250 if (!BN_one(z1)) goto err; /* z1 = 1 */ 259 if (!BN_one(z1)) goto err; /* z1 = 1 */
251 if (!group->meth->field_sqr(group, z2, x1, ctx)) goto err; /* z2 = x1^2 = x^2 */ 260 if (!group->meth->field_sqr(group, z2, x1, ctx)) goto err; /* z2 = x1^2 = x^2 */
@@ -270,16 +279,12 @@ static int ec_GF2m_montgomery_point_multiply(const EC_GROUP *group, EC_POINT *r,
270 word = scalar->d[i]; 279 word = scalar->d[i];
271 while (mask) 280 while (mask)
272 { 281 {
273 if (word & mask) 282 BN_consttime_swap(word & mask, x1, x2, group->field.top);
274 { 283 BN_consttime_swap(word & mask, z1, z2, group->field.top);
275 if (!gf2m_Madd(group, &point->X, x1, z1, x2, z2, ctx)) goto err; 284 if (!gf2m_Madd(group, &point->X, x2, z2, x1, z1, ctx)) goto err;
276 if (!gf2m_Mdouble(group, x2, z2, ctx)) goto err; 285 if (!gf2m_Mdouble(group, x1, z1, ctx)) goto err;
277 } 286 BN_consttime_swap(word & mask, x1, x2, group->field.top);
278 else 287 BN_consttime_swap(word & mask, z1, z2, group->field.top);
279 {
280 if (!gf2m_Madd(group, &point->X, x2, z2, x1, z1, ctx)) goto err;
281 if (!gf2m_Mdouble(group, x1, z1, ctx)) goto err;
282 }
283 mask >>= 1; 288 mask >>= 1;
284 } 289 }
285 mask = BN_TBIT; 290 mask = BN_TBIT;
diff --git a/src/lib/libssl/src/crypto/ec/ec_ameth.c b/src/lib/libssl/src/crypto/ec/ec_ameth.c
index 83909c1853..0ce4524076 100644
--- a/src/lib/libssl/src/crypto/ec/ec_ameth.c
+++ b/src/lib/libssl/src/crypto/ec/ec_ameth.c
@@ -88,7 +88,7 @@ static int eckey_param2type(int *pptype, void **ppval, EC_KEY *ec_key)
88 if (!pstr) 88 if (!pstr)
89 return 0; 89 return 0;
90 pstr->length = i2d_ECParameters(ec_key, &pstr->data); 90 pstr->length = i2d_ECParameters(ec_key, &pstr->data);
91 if (pstr->length < 0) 91 if (pstr->length <= 0)
92 { 92 {
93 ASN1_STRING_free(pstr); 93 ASN1_STRING_free(pstr);
94 ECerr(EC_F_ECKEY_PARAM2TYPE, ERR_R_EC_LIB); 94 ECerr(EC_F_ECKEY_PARAM2TYPE, ERR_R_EC_LIB);
diff --git a/src/lib/libssl/src/crypto/ec/ec_asn1.c b/src/lib/libssl/src/crypto/ec/ec_asn1.c
index 175eec5342..145807b611 100644
--- a/src/lib/libssl/src/crypto/ec/ec_asn1.c
+++ b/src/lib/libssl/src/crypto/ec/ec_asn1.c
@@ -89,7 +89,8 @@ int EC_GROUP_get_trinomial_basis(const EC_GROUP *group, unsigned int *k)
89 if (group == NULL) 89 if (group == NULL)
90 return 0; 90 return 0;
91 91
92 if (EC_GROUP_method_of(group)->group_set_curve != ec_GF2m_simple_group_set_curve 92 if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) !=
93 NID_X9_62_characteristic_two_field
93 || !((group->poly[0] != 0) && (group->poly[1] != 0) && (group->poly[2] == 0))) 94 || !((group->poly[0] != 0) && (group->poly[1] != 0) && (group->poly[2] == 0)))
94 { 95 {
95 ECerr(EC_F_EC_GROUP_GET_TRINOMIAL_BASIS, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 96 ECerr(EC_F_EC_GROUP_GET_TRINOMIAL_BASIS, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
@@ -107,7 +108,8 @@ int EC_GROUP_get_pentanomial_basis(const EC_GROUP *group, unsigned int *k1,
107 if (group == NULL) 108 if (group == NULL)
108 return 0; 109 return 0;
109 110
110 if (EC_GROUP_method_of(group)->group_set_curve != ec_GF2m_simple_group_set_curve 111 if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) !=
112 NID_X9_62_characteristic_two_field
111 || !((group->poly[0] != 0) && (group->poly[1] != 0) && (group->poly[2] != 0) && (group->poly[3] != 0) && (group->poly[4] == 0))) 113 || !((group->poly[0] != 0) && (group->poly[1] != 0) && (group->poly[2] != 0) && (group->poly[3] != 0) && (group->poly[4] == 0)))
112 { 114 {
113 ECerr(EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 115 ECerr(EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
diff --git a/src/lib/libssl/src/crypto/ec/ec_key.c b/src/lib/libssl/src/crypto/ec/ec_key.c
index bf9fd2dc2c..7fa247593d 100644
--- a/src/lib/libssl/src/crypto/ec/ec_key.c
+++ b/src/lib/libssl/src/crypto/ec/ec_key.c
@@ -520,18 +520,27 @@ void EC_KEY_set_conv_form(EC_KEY *key, point_conversion_form_t cform)
520void *EC_KEY_get_key_method_data(EC_KEY *key, 520void *EC_KEY_get_key_method_data(EC_KEY *key,
521 void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)) 521 void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *))
522 { 522 {
523 return EC_EX_DATA_get_data(key->method_data, dup_func, free_func, clear_free_func); 523 void *ret;
524
525 CRYPTO_r_lock(CRYPTO_LOCK_EC);
526 ret = EC_EX_DATA_get_data(key->method_data, dup_func, free_func, clear_free_func);
527 CRYPTO_r_unlock(CRYPTO_LOCK_EC);
528
529 return ret;
524 } 530 }
525 531
526void EC_KEY_insert_key_method_data(EC_KEY *key, void *data, 532void *EC_KEY_insert_key_method_data(EC_KEY *key, void *data,
527 void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)) 533 void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *))
528 { 534 {
529 EC_EXTRA_DATA *ex_data; 535 EC_EXTRA_DATA *ex_data;
536
530 CRYPTO_w_lock(CRYPTO_LOCK_EC); 537 CRYPTO_w_lock(CRYPTO_LOCK_EC);
531 ex_data = EC_EX_DATA_get_data(key->method_data, dup_func, free_func, clear_free_func); 538 ex_data = EC_EX_DATA_get_data(key->method_data, dup_func, free_func, clear_free_func);
532 if (ex_data == NULL) 539 if (ex_data == NULL)
533 EC_EX_DATA_set_data(&key->method_data, data, dup_func, free_func, clear_free_func); 540 EC_EX_DATA_set_data(&key->method_data, data, dup_func, free_func, clear_free_func);
534 CRYPTO_w_unlock(CRYPTO_LOCK_EC); 541 CRYPTO_w_unlock(CRYPTO_LOCK_EC);
542
543 return ex_data;
535 } 544 }
536 545
537void EC_KEY_set_asn1_flag(EC_KEY *key, int flag) 546void EC_KEY_set_asn1_flag(EC_KEY *key, int flag)
diff --git a/src/lib/libssl/src/crypto/ec/ec_pmeth.c b/src/lib/libssl/src/crypto/ec/ec_pmeth.c
index d1ed66c37e..66ee397d86 100644
--- a/src/lib/libssl/src/crypto/ec/ec_pmeth.c
+++ b/src/lib/libssl/src/crypto/ec/ec_pmeth.c
@@ -188,7 +188,7 @@ static int pkey_ec_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen)
188 188
189 pubkey = EC_KEY_get0_public_key(ctx->peerkey->pkey.ec); 189 pubkey = EC_KEY_get0_public_key(ctx->peerkey->pkey.ec);
190 190
191 /* NB: unlike PKS#3 DH, if *outlen is less than maximum size this is 191 /* NB: unlike PKCS#3 DH, if *outlen is less than maximum size this is
192 * not an error, the result is truncated. 192 * not an error, the result is truncated.
193 */ 193 */
194 194
diff --git a/src/lib/libssl/src/crypto/ecdh/Makefile b/src/lib/libssl/src/crypto/ecdh/Makefile
index 65d8904ee8..ba05fea05c 100644
--- a/src/lib/libssl/src/crypto/ecdh/Makefile
+++ b/src/lib/libssl/src/crypto/ecdh/Makefile
@@ -84,17 +84,12 @@ ech_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
84ech_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 84ech_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
85ech_err.o: ech_err.c 85ech_err.o: ech_err.c
86ech_key.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 86ech_key.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
87ech_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 87ech_key.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
88ech_key.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 88ech_key.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
89ech_key.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 89ech_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
90ech_key.o: ../../include/openssl/engine.h ../../include/openssl/evp.h 90ech_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
91ech_key.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 91ech_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
92ech_key.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 92ech_key.o: ech_key.c ech_locl.h
93ech_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
94ech_key.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
95ech_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
96ech_key.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
97ech_key.o: ../../include/openssl/x509_vfy.h ech_key.c ech_locl.h
98ech_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 93ech_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
99ech_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 94ech_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
100ech_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 95ech_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
diff --git a/src/lib/libssl/src/crypto/ecdh/ech_key.c b/src/lib/libssl/src/crypto/ecdh/ech_key.c
index f44da9298b..2988899ea2 100644
--- a/src/lib/libssl/src/crypto/ecdh/ech_key.c
+++ b/src/lib/libssl/src/crypto/ecdh/ech_key.c
@@ -68,9 +68,6 @@
68 */ 68 */
69 69
70#include "ech_locl.h" 70#include "ech_locl.h"
71#ifndef OPENSSL_NO_ENGINE
72#include <openssl/engine.h>
73#endif
74 71
75int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, 72int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
76 EC_KEY *eckey, 73 EC_KEY *eckey,
diff --git a/src/lib/libssl/src/crypto/ecdh/ech_lib.c b/src/lib/libssl/src/crypto/ecdh/ech_lib.c
index dadbfd3c49..0644431b75 100644
--- a/src/lib/libssl/src/crypto/ecdh/ech_lib.c
+++ b/src/lib/libssl/src/crypto/ecdh/ech_lib.c
@@ -222,8 +222,15 @@ ECDH_DATA *ecdh_check(EC_KEY *key)
222 ecdh_data = (ECDH_DATA *)ecdh_data_new(); 222 ecdh_data = (ECDH_DATA *)ecdh_data_new();
223 if (ecdh_data == NULL) 223 if (ecdh_data == NULL)
224 return NULL; 224 return NULL;
225 EC_KEY_insert_key_method_data(key, (void *)ecdh_data, 225 data = EC_KEY_insert_key_method_data(key, (void *)ecdh_data,
226 ecdh_data_dup, ecdh_data_free, ecdh_data_free); 226 ecdh_data_dup, ecdh_data_free, ecdh_data_free);
227 if (data != NULL)
228 {
229 /* Another thread raced us to install the key_method
230 * data and won. */
231 ecdh_data_free(ecdh_data);
232 ecdh_data = (ECDH_DATA *)data;
233 }
227 } 234 }
228 else 235 else
229 ecdh_data = (ECDH_DATA *)data; 236 ecdh_data = (ECDH_DATA *)data;
diff --git a/src/lib/libssl/src/crypto/ecdsa/ecs_lib.c b/src/lib/libssl/src/crypto/ecdsa/ecs_lib.c
index e477da430b..814a6bf404 100644
--- a/src/lib/libssl/src/crypto/ecdsa/ecs_lib.c
+++ b/src/lib/libssl/src/crypto/ecdsa/ecs_lib.c
@@ -200,8 +200,15 @@ ECDSA_DATA *ecdsa_check(EC_KEY *key)
200 ecdsa_data = (ECDSA_DATA *)ecdsa_data_new(); 200 ecdsa_data = (ECDSA_DATA *)ecdsa_data_new();
201 if (ecdsa_data == NULL) 201 if (ecdsa_data == NULL)
202 return NULL; 202 return NULL;
203 EC_KEY_insert_key_method_data(key, (void *)ecdsa_data, 203 data = EC_KEY_insert_key_method_data(key, (void *)ecdsa_data,
204 ecdsa_data_dup, ecdsa_data_free, ecdsa_data_free); 204 ecdsa_data_dup, ecdsa_data_free, ecdsa_data_free);
205 if (data != NULL)
206 {
207 /* Another thread raced us to install the key_method
208 * data and won. */
209 ecdsa_data_free(ecdsa_data);
210 ecdsa_data = (ECDSA_DATA *)data;
211 }
205 } 212 }
206 else 213 else
207 ecdsa_data = (ECDSA_DATA *)data; 214 ecdsa_data = (ECDSA_DATA *)data;
diff --git a/src/lib/libssl/src/crypto/engine/eng_rdrand.c b/src/lib/libssl/src/crypto/engine/eng_rdrand.c
index a9ba5ae6f9..4e9e91d54b 100644
--- a/src/lib/libssl/src/crypto/engine/eng_rdrand.c
+++ b/src/lib/libssl/src/crypto/engine/eng_rdrand.c
@@ -104,6 +104,7 @@ static int bind_helper(ENGINE *e)
104 { 104 {
105 if (!ENGINE_set_id(e, engine_e_rdrand_id) || 105 if (!ENGINE_set_id(e, engine_e_rdrand_id) ||
106 !ENGINE_set_name(e, engine_e_rdrand_name) || 106 !ENGINE_set_name(e, engine_e_rdrand_name) ||
107 !ENGINE_set_flags(e, ENGINE_FLAGS_NO_REGISTER_ALL) ||
107 !ENGINE_set_init_function(e, rdrand_init) || 108 !ENGINE_set_init_function(e, rdrand_init) ||
108 !ENGINE_set_RAND(e, &rdrand_meth) ) 109 !ENGINE_set_RAND(e, &rdrand_meth) )
109 return 0; 110 return 0;
diff --git a/src/lib/libssl/src/crypto/evp/e_aes_cbc_hmac_sha1.c b/src/lib/libssl/src/crypto/evp/e_aes_cbc_hmac_sha1.c
index 710fb79baf..fb2c884a78 100644
--- a/src/lib/libssl/src/crypto/evp/e_aes_cbc_hmac_sha1.c
+++ b/src/lib/libssl/src/crypto/evp/e_aes_cbc_hmac_sha1.c
@@ -1,5 +1,5 @@
1/* ==================================================================== 1/* ====================================================================
2 * Copyright (c) 2011 The OpenSSL Project. All rights reserved. 2 * Copyright (c) 2011-2013 The OpenSSL Project. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
@@ -90,6 +90,10 @@ typedef struct
90 defined(_M_AMD64) || defined(_M_X64) || \ 90 defined(_M_AMD64) || defined(_M_X64) || \
91 defined(__INTEL__) ) 91 defined(__INTEL__) )
92 92
93#if defined(__GNUC__) && __GNUC__>=2 && !defined(PEDANTIC)
94# define BSWAP(x) ({ unsigned int r=(x); asm ("bswapl %0":"=r"(r):"0"(r)); r; })
95#endif
96
93extern unsigned int OPENSSL_ia32cap_P[2]; 97extern unsigned int OPENSSL_ia32cap_P[2];
94#define AESNI_CAPABLE (1<<(57-32)) 98#define AESNI_CAPABLE (1<<(57-32))
95 99
@@ -167,6 +171,9 @@ static void sha1_update(SHA_CTX *c,const void *data,size_t len)
167 SHA1_Update(c,ptr,res); 171 SHA1_Update(c,ptr,res);
168} 172}
169 173
174#ifdef SHA1_Update
175#undef SHA1_Update
176#endif
170#define SHA1_Update sha1_update 177#define SHA1_Update sha1_update
171 178
172static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 179static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
@@ -184,6 +191,8 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
184 sha_off = SHA_CBLOCK-key->md.num; 191 sha_off = SHA_CBLOCK-key->md.num;
185#endif 192#endif
186 193
194 key->payload_length = NO_PAYLOAD_LENGTH;
195
187 if (len%AES_BLOCK_SIZE) return 0; 196 if (len%AES_BLOCK_SIZE) return 0;
188 197
189 if (ctx->encrypt) { 198 if (ctx->encrypt) {
@@ -234,47 +243,211 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
234 &key->ks,ctx->iv,1); 243 &key->ks,ctx->iv,1);
235 } 244 }
236 } else { 245 } else {
237 unsigned char mac[SHA_DIGEST_LENGTH]; 246 union { unsigned int u[SHA_DIGEST_LENGTH/sizeof(unsigned int)];
247 unsigned char c[32+SHA_DIGEST_LENGTH]; } mac, *pmac;
248
249 /* arrange cache line alignment */
250 pmac = (void *)(((size_t)mac.c+31)&((size_t)0-32));
238 251
239 /* decrypt HMAC|padding at once */ 252 /* decrypt HMAC|padding at once */
240 aesni_cbc_encrypt(in,out,len, 253 aesni_cbc_encrypt(in,out,len,
241 &key->ks,ctx->iv,0); 254 &key->ks,ctx->iv,0);
242 255
243 if (plen) { /* "TLS" mode of operation */ 256 if (plen) { /* "TLS" mode of operation */
244 /* figure out payload length */ 257 size_t inp_len, mask, j, i;
245 if (len<(size_t)(out[len-1]+1+SHA_DIGEST_LENGTH)) 258 unsigned int res, maxpad, pad, bitlen;
246 return 0; 259 int ret = 1;
247 260 union { unsigned int u[SHA_LBLOCK];
248 len -= (out[len-1]+1+SHA_DIGEST_LENGTH); 261 unsigned char c[SHA_CBLOCK]; }
262 *data = (void *)key->md.data;
249 263
250 if ((key->aux.tls_aad[plen-4]<<8|key->aux.tls_aad[plen-3]) 264 if ((key->aux.tls_aad[plen-4]<<8|key->aux.tls_aad[plen-3])
251 >= TLS1_1_VERSION) { 265 >= TLS1_1_VERSION)
252 len -= AES_BLOCK_SIZE;
253 iv = AES_BLOCK_SIZE; 266 iv = AES_BLOCK_SIZE;
254 }
255 267
256 key->aux.tls_aad[plen-2] = len>>8; 268 if (len<(iv+SHA_DIGEST_LENGTH+1))
257 key->aux.tls_aad[plen-1] = len; 269 return 0;
270
271 /* omit explicit iv */
272 out += iv;
273 len -= iv;
274
275 /* figure out payload length */
276 pad = out[len-1];
277 maxpad = len-(SHA_DIGEST_LENGTH+1);
278 maxpad |= (255-maxpad)>>(sizeof(maxpad)*8-8);
279 maxpad &= 255;
280
281 inp_len = len - (SHA_DIGEST_LENGTH+pad+1);
282 mask = (0-((inp_len-len)>>(sizeof(inp_len)*8-1)));
283 inp_len &= mask;
284 ret &= (int)mask;
285
286 key->aux.tls_aad[plen-2] = inp_len>>8;
287 key->aux.tls_aad[plen-1] = inp_len;
258 288
259 /* calculate HMAC and verify it */ 289 /* calculate HMAC */
260 key->md = key->head; 290 key->md = key->head;
261 SHA1_Update(&key->md,key->aux.tls_aad,plen); 291 SHA1_Update(&key->md,key->aux.tls_aad,plen);
262 SHA1_Update(&key->md,out+iv,len);
263 SHA1_Final(mac,&key->md);
264 292
293#if 1
294 len -= SHA_DIGEST_LENGTH; /* amend mac */
295 if (len>=(256+SHA_CBLOCK)) {
296 j = (len-(256+SHA_CBLOCK))&(0-SHA_CBLOCK);
297 j += SHA_CBLOCK-key->md.num;
298 SHA1_Update(&key->md,out,j);
299 out += j;
300 len -= j;
301 inp_len -= j;
302 }
303
304 /* but pretend as if we hashed padded payload */
305 bitlen = key->md.Nl+(inp_len<<3); /* at most 18 bits */
306#ifdef BSWAP
307 bitlen = BSWAP(bitlen);
308#else
309 mac.c[0] = 0;
310 mac.c[1] = (unsigned char)(bitlen>>16);
311 mac.c[2] = (unsigned char)(bitlen>>8);
312 mac.c[3] = (unsigned char)bitlen;
313 bitlen = mac.u[0];
314#endif
315
316 pmac->u[0]=0;
317 pmac->u[1]=0;
318 pmac->u[2]=0;
319 pmac->u[3]=0;
320 pmac->u[4]=0;
321
322 for (res=key->md.num, j=0;j<len;j++) {
323 size_t c = out[j];
324 mask = (j-inp_len)>>(sizeof(j)*8-8);
325 c &= mask;
326 c |= 0x80&~mask&~((inp_len-j)>>(sizeof(j)*8-8));
327 data->c[res++]=(unsigned char)c;
328
329 if (res!=SHA_CBLOCK) continue;
330
331 /* j is not incremented yet */
332 mask = 0-((inp_len+7-j)>>(sizeof(j)*8-1));
333 data->u[SHA_LBLOCK-1] |= bitlen&mask;
334 sha1_block_data_order(&key->md,data,1);
335 mask &= 0-((j-inp_len-72)>>(sizeof(j)*8-1));
336 pmac->u[0] |= key->md.h0 & mask;
337 pmac->u[1] |= key->md.h1 & mask;
338 pmac->u[2] |= key->md.h2 & mask;
339 pmac->u[3] |= key->md.h3 & mask;
340 pmac->u[4] |= key->md.h4 & mask;
341 res=0;
342 }
343
344 for(i=res;i<SHA_CBLOCK;i++,j++) data->c[i]=0;
345
346 if (res>SHA_CBLOCK-8) {
347 mask = 0-((inp_len+8-j)>>(sizeof(j)*8-1));
348 data->u[SHA_LBLOCK-1] |= bitlen&mask;
349 sha1_block_data_order(&key->md,data,1);
350 mask &= 0-((j-inp_len-73)>>(sizeof(j)*8-1));
351 pmac->u[0] |= key->md.h0 & mask;
352 pmac->u[1] |= key->md.h1 & mask;
353 pmac->u[2] |= key->md.h2 & mask;
354 pmac->u[3] |= key->md.h3 & mask;
355 pmac->u[4] |= key->md.h4 & mask;
356
357 memset(data,0,SHA_CBLOCK);
358 j+=64;
359 }
360 data->u[SHA_LBLOCK-1] = bitlen;
361 sha1_block_data_order(&key->md,data,1);
362 mask = 0-((j-inp_len-73)>>(sizeof(j)*8-1));
363 pmac->u[0] |= key->md.h0 & mask;
364 pmac->u[1] |= key->md.h1 & mask;
365 pmac->u[2] |= key->md.h2 & mask;
366 pmac->u[3] |= key->md.h3 & mask;
367 pmac->u[4] |= key->md.h4 & mask;
368
369#ifdef BSWAP
370 pmac->u[0] = BSWAP(pmac->u[0]);
371 pmac->u[1] = BSWAP(pmac->u[1]);
372 pmac->u[2] = BSWAP(pmac->u[2]);
373 pmac->u[3] = BSWAP(pmac->u[3]);
374 pmac->u[4] = BSWAP(pmac->u[4]);
375#else
376 for (i=0;i<5;i++) {
377 res = pmac->u[i];
378 pmac->c[4*i+0]=(unsigned char)(res>>24);
379 pmac->c[4*i+1]=(unsigned char)(res>>16);
380 pmac->c[4*i+2]=(unsigned char)(res>>8);
381 pmac->c[4*i+3]=(unsigned char)res;
382 }
383#endif
384 len += SHA_DIGEST_LENGTH;
385#else
386 SHA1_Update(&key->md,out,inp_len);
387 res = key->md.num;
388 SHA1_Final(pmac->c,&key->md);
389
390 {
391 unsigned int inp_blocks, pad_blocks;
392
393 /* but pretend as if we hashed padded payload */
394 inp_blocks = 1+((SHA_CBLOCK-9-res)>>(sizeof(res)*8-1));
395 res += (unsigned int)(len-inp_len);
396 pad_blocks = res / SHA_CBLOCK;
397 res %= SHA_CBLOCK;
398 pad_blocks += 1+((SHA_CBLOCK-9-res)>>(sizeof(res)*8-1));
399 for (;inp_blocks<pad_blocks;inp_blocks++)
400 sha1_block_data_order(&key->md,data,1);
401 }
402#endif
265 key->md = key->tail; 403 key->md = key->tail;
266 SHA1_Update(&key->md,mac,SHA_DIGEST_LENGTH); 404 SHA1_Update(&key->md,pmac->c,SHA_DIGEST_LENGTH);
267 SHA1_Final(mac,&key->md); 405 SHA1_Final(pmac->c,&key->md);
268 406
269 if (memcmp(out+iv+len,mac,SHA_DIGEST_LENGTH)) 407 /* verify HMAC */
270 return 0; 408 out += inp_len;
409 len -= inp_len;
410#if 1
411 {
412 unsigned char *p = out+len-1-maxpad-SHA_DIGEST_LENGTH;
413 size_t off = out-p;
414 unsigned int c, cmask;
415
416 maxpad += SHA_DIGEST_LENGTH;
417 for (res=0,i=0,j=0;j<maxpad;j++) {
418 c = p[j];
419 cmask = ((int)(j-off-SHA_DIGEST_LENGTH))>>(sizeof(int)*8-1);
420 res |= (c^pad)&~cmask; /* ... and padding */
421 cmask &= ((int)(off-1-j))>>(sizeof(int)*8-1);
422 res |= (c^pmac->c[i])&cmask;
423 i += 1&cmask;
424 }
425 maxpad -= SHA_DIGEST_LENGTH;
426
427 res = 0-((0-res)>>(sizeof(res)*8-1));
428 ret &= (int)~res;
429 }
430#else
431 for (res=0,i=0;i<SHA_DIGEST_LENGTH;i++)
432 res |= out[i]^pmac->c[i];
433 res = 0-((0-res)>>(sizeof(res)*8-1));
434 ret &= (int)~res;
435
436 /* verify padding */
437 pad = (pad&~res) | (maxpad&res);
438 out = out+len-1-pad;
439 for (res=0,i=0;i<pad;i++)
440 res |= out[i]^pad;
441
442 res = (0-res)>>(sizeof(res)*8-1);
443 ret &= (int)~res;
444#endif
445 return ret;
271 } else { 446 } else {
272 SHA1_Update(&key->md,out,len); 447 SHA1_Update(&key->md,out,len);
273 } 448 }
274 } 449 }
275 450
276 key->payload_length = NO_PAYLOAD_LENGTH;
277
278 return 1; 451 return 1;
279 } 452 }
280 453
@@ -309,6 +482,8 @@ static int aesni_cbc_hmac_sha1_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void
309 SHA1_Init(&key->tail); 482 SHA1_Init(&key->tail);
310 SHA1_Update(&key->tail,hmac_key,sizeof(hmac_key)); 483 SHA1_Update(&key->tail,hmac_key,sizeof(hmac_key));
311 484
485 OPENSSL_cleanse(hmac_key,sizeof(hmac_key));
486
312 return 1; 487 return 1;
313 } 488 }
314 case EVP_CTRL_AEAD_TLS1_AAD: 489 case EVP_CTRL_AEAD_TLS1_AAD:
diff --git a/src/lib/libssl/src/crypto/md5/asm/md5-x86_64.pl b/src/lib/libssl/src/crypto/md5/asm/md5-x86_64.pl
index 867885435e..f11224d172 100755
--- a/src/lib/libssl/src/crypto/md5/asm/md5-x86_64.pl
+++ b/src/lib/libssl/src/crypto/md5/asm/md5-x86_64.pl
@@ -120,7 +120,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; my $dir=$1; my $xlate;
120die "can't locate x86_64-xlate.pl"; 120die "can't locate x86_64-xlate.pl";
121 121
122no warnings qw(uninitialized); 122no warnings qw(uninitialized);
123open STDOUT,"| $^X $xlate $flavour $output"; 123open OUT,"| \"$^X\" $xlate $flavour $output";
124*STDOUT=*OUT;
124 125
125$code .= <<EOF; 126$code .= <<EOF;
126.text 127.text
diff --git a/src/lib/libssl/src/crypto/mdc2/mdc2dgst.c b/src/lib/libssl/src/crypto/mdc2/mdc2dgst.c
index b74bb1a759..d66ed6a1c6 100644
--- a/src/lib/libssl/src/crypto/mdc2/mdc2dgst.c
+++ b/src/lib/libssl/src/crypto/mdc2/mdc2dgst.c
@@ -59,9 +59,9 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62#include <openssl/crypto.h>
62#include <openssl/des.h> 63#include <openssl/des.h>
63#include <openssl/mdc2.h> 64#include <openssl/mdc2.h>
64#include <openssl/crypto.h>
65 65
66#undef c2l 66#undef c2l
67#define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \ 67#define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \
diff --git a/src/lib/libssl/src/crypto/modes/Makefile b/src/lib/libssl/src/crypto/modes/Makefile
index c825b12f25..3d8bafd571 100644
--- a/src/lib/libssl/src/crypto/modes/Makefile
+++ b/src/lib/libssl/src/crypto/modes/Makefile
@@ -53,7 +53,10 @@ ghash-x86_64.s: asm/ghash-x86_64.pl
53ghash-sparcv9.s: asm/ghash-sparcv9.pl 53ghash-sparcv9.s: asm/ghash-sparcv9.pl
54 $(PERL) asm/ghash-sparcv9.pl $@ $(CFLAGS) 54 $(PERL) asm/ghash-sparcv9.pl $@ $(CFLAGS)
55ghash-alpha.s: asm/ghash-alpha.pl 55ghash-alpha.s: asm/ghash-alpha.pl
56 $(PERL) $< | $(CC) -E - | tee $@ > /dev/null 56 (preproc=/tmp/$$$$.$@; trap "rm $$preproc" INT; \
57 $(PERL) asm/ghash-alpha.pl > $$preproc && \
58 $(CC) -E $$preproc > $@ && rm $$preproc)
59
57ghash-parisc.s: asm/ghash-parisc.pl 60ghash-parisc.s: asm/ghash-parisc.pl
58 $(PERL) asm/ghash-parisc.pl $(PERLASM_SCHEME) $@ 61 $(PERL) asm/ghash-parisc.pl $(PERLASM_SCHEME) $@
59 62
diff --git a/src/lib/libssl/src/crypto/modes/asm/ghash-alpha.pl b/src/lib/libssl/src/crypto/modes/asm/ghash-alpha.pl
index 6358b2750f..aa36029386 100644
--- a/src/lib/libssl/src/crypto/modes/asm/ghash-alpha.pl
+++ b/src/lib/libssl/src/crypto/modes/asm/ghash-alpha.pl
@@ -266,8 +266,8 @@ gcm_gmult_4bit:
266 ldq $Xlo,8($Xi) 266 ldq $Xlo,8($Xi)
267 ldq $Xhi,0($Xi) 267 ldq $Xhi,0($Xi)
268 268
269 br $rem_4bit,.Lpic1 269 bsr $t0,picmeup
270.Lpic1: lda $rem_4bit,rem_4bit-.Lpic1($rem_4bit) 270 nop
271___ 271___
272 272
273 &loop(); 273 &loop();
@@ -341,8 +341,8 @@ gcm_ghash_4bit:
341 ldq $Xhi,0($Xi) 341 ldq $Xhi,0($Xi)
342 ldq $Xlo,8($Xi) 342 ldq $Xlo,8($Xi)
343 343
344 br $rem_4bit,.Lpic2 344 bsr $t0,picmeup
345.Lpic2: lda $rem_4bit,rem_4bit-.Lpic2($rem_4bit) 345 nop
346 346
347.Louter: 347.Louter:
348 extql $inhi,$inp,$inhi 348 extql $inhi,$inp,$inhi
@@ -436,11 +436,20 @@ $code.=<<___;
436.end gcm_ghash_4bit 436.end gcm_ghash_4bit
437 437
438.align 4 438.align 4
439.ent picmeup
440picmeup:
441 .frame sp,0,$t0
442 .prologue 0
443 br $rem_4bit,.Lpic
444.Lpic: lda $rem_4bit,12($rem_4bit)
445 ret ($t0)
446.end picmeup
447 nop
439rem_4bit: 448rem_4bit:
440 .quad 0x0000<<48, 0x1C20<<48, 0x3840<<48, 0x2460<<48 449 .long 0,0x0000<<16, 0,0x1C20<<16, 0,0x3840<<16, 0,0x2460<<16
441 .quad 0x7080<<48, 0x6CA0<<48, 0x48C0<<48, 0x54E0<<48 450 .long 0,0x7080<<16, 0,0x6CA0<<16, 0,0x48C0<<16, 0,0x54E0<<16
442 .quad 0xE100<<48, 0xFD20<<48, 0xD940<<48, 0xC560<<48 451 .long 0,0xE100<<16, 0,0xFD20<<16, 0,0xD940<<16, 0,0xC560<<16
443 .quad 0x9180<<48, 0x8DA0<<48, 0xA9C0<<48, 0xB5E0<<48 452 .long 0,0x9180<<16, 0,0x8DA0<<16, 0,0xA9C0<<16, 0,0xB5E0<<16
444.ascii "GHASH for Alpha, CRYPTOGAMS by <appro\@openssl.org>" 453.ascii "GHASH for Alpha, CRYPTOGAMS by <appro\@openssl.org>"
445.align 4 454.align 4
446 455
diff --git a/src/lib/libssl/src/crypto/modes/asm/ghash-parisc.pl b/src/lib/libssl/src/crypto/modes/asm/ghash-parisc.pl
index 8c7454ee93..d5ad96b403 100644
--- a/src/lib/libssl/src/crypto/modes/asm/ghash-parisc.pl
+++ b/src/lib/libssl/src/crypto/modes/asm/ghash-parisc.pl
@@ -724,6 +724,7 @@ foreach (split("\n",$code)) {
724 s/cmpb,\*/comb,/; 724 s/cmpb,\*/comb,/;
725 s/,\*/,/; 725 s/,\*/,/;
726 } 726 }
727 s/\bbv\b/bve/ if ($SIZE_T==8);
727 print $_,"\n"; 728 print $_,"\n";
728} 729}
729 730
diff --git a/src/lib/libssl/src/crypto/modes/asm/ghash-x86.pl b/src/lib/libssl/src/crypto/modes/asm/ghash-x86.pl
index 6b09669d47..83c727e07f 100644
--- a/src/lib/libssl/src/crypto/modes/asm/ghash-x86.pl
+++ b/src/lib/libssl/src/crypto/modes/asm/ghash-x86.pl
@@ -635,7 +635,7 @@ sub mmx_loop() {
635 { my @lo = ("mm0","mm1","mm2"); 635 { my @lo = ("mm0","mm1","mm2");
636 my @hi = ("mm3","mm4","mm5"); 636 my @hi = ("mm3","mm4","mm5");
637 my @tmp = ("mm6","mm7"); 637 my @tmp = ("mm6","mm7");
638 my $off1=0,$off2=0,$i; 638 my ($off1,$off2,$i) = (0,0,);
639 639
640 &add ($Htbl,128); # optimize for size 640 &add ($Htbl,128); # optimize for size
641 &lea ("edi",&DWP(16+128,"esp")); 641 &lea ("edi",&DWP(16+128,"esp"));
@@ -883,7 +883,7 @@ sub reduction_alg9 { # 17/13 times faster than Intel version
883my ($Xhi,$Xi) = @_; 883my ($Xhi,$Xi) = @_;
884 884
885 # 1st phase 885 # 1st phase
886 &movdqa ($T1,$Xi) # 886 &movdqa ($T1,$Xi); #
887 &psllq ($Xi,1); 887 &psllq ($Xi,1);
888 &pxor ($Xi,$T1); # 888 &pxor ($Xi,$T1); #
889 &psllq ($Xi,5); # 889 &psllq ($Xi,5); #
@@ -1019,7 +1019,7 @@ my ($Xhi,$Xi) = @_;
1019 &movdqa ($Xhn,$Xn); 1019 &movdqa ($Xhn,$Xn);
1020 &pxor ($Xhi,$T1); # "Ii+Xi", consume early 1020 &pxor ($Xhi,$T1); # "Ii+Xi", consume early
1021 1021
1022 &movdqa ($T1,$Xi) #&reduction_alg9($Xhi,$Xi); 1st phase 1022 &movdqa ($T1,$Xi); #&reduction_alg9($Xhi,$Xi); 1st phase
1023 &psllq ($Xi,1); 1023 &psllq ($Xi,1);
1024 &pxor ($Xi,$T1); # 1024 &pxor ($Xi,$T1); #
1025 &psllq ($Xi,5); # 1025 &psllq ($Xi,5); #
diff --git a/src/lib/libssl/src/crypto/modes/asm/ghash-x86_64.pl b/src/lib/libssl/src/crypto/modes/asm/ghash-x86_64.pl
index a5ae180882..38d779edbc 100644
--- a/src/lib/libssl/src/crypto/modes/asm/ghash-x86_64.pl
+++ b/src/lib/libssl/src/crypto/modes/asm/ghash-x86_64.pl
@@ -50,7 +50,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
50( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or 50( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
51die "can't locate x86_64-xlate.pl"; 51die "can't locate x86_64-xlate.pl";
52 52
53open STDOUT,"| $^X $xlate $flavour $output"; 53open OUT,"| \"$^X\" $xlate $flavour $output";
54*STDOUT=*OUT;
54 55
55# common register layout 56# common register layout
56$nlo="%rax"; 57$nlo="%rax";
diff --git a/src/lib/libssl/src/crypto/modes/cbc128.c b/src/lib/libssl/src/crypto/modes/cbc128.c
index 3d3782cbe1..0e54f75470 100644
--- a/src/lib/libssl/src/crypto/modes/cbc128.c
+++ b/src/lib/libssl/src/crypto/modes/cbc128.c
@@ -117,7 +117,7 @@ void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,
117 unsigned char ivec[16], block128_f block) 117 unsigned char ivec[16], block128_f block)
118{ 118{
119 size_t n; 119 size_t n;
120 union { size_t align; unsigned char c[16]; } tmp; 120 union { size_t t[16/sizeof(size_t)]; unsigned char c[16]; } tmp;
121 121
122 assert(in && out && key && ivec); 122 assert(in && out && key && ivec);
123 123
@@ -137,11 +137,13 @@ void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,
137 out += 16; 137 out += 16;
138 } 138 }
139 } 139 }
140 else { 140 else if (16%sizeof(size_t) == 0) { /* always true */
141 while (len>=16) { 141 while (len>=16) {
142 size_t *out_t=(size_t *)out, *iv_t=(size_t *)iv;
143
142 (*block)(in, out, key); 144 (*block)(in, out, key);
143 for(n=0; n<16; n+=sizeof(size_t)) 145 for(n=0; n<16/sizeof(size_t); n++)
144 *(size_t *)(out+n) ^= *(size_t *)(iv+n); 146 out_t[n] ^= iv_t[n];
145 iv = in; 147 iv = in;
146 len -= 16; 148 len -= 16;
147 in += 16; 149 in += 16;
@@ -165,15 +167,16 @@ void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,
165 out += 16; 167 out += 16;
166 } 168 }
167 } 169 }
168 else { 170 else if (16%sizeof(size_t) == 0) { /* always true */
169 size_t c;
170 while (len>=16) { 171 while (len>=16) {
172 size_t c, *out_t=(size_t *)out, *ivec_t=(size_t *)ivec;
173 const size_t *in_t=(const size_t *)in;
174
171 (*block)(in, tmp.c, key); 175 (*block)(in, tmp.c, key);
172 for(n=0; n<16; n+=sizeof(size_t)) { 176 for(n=0; n<16/sizeof(size_t); n++) {
173 c = *(size_t *)(in+n); 177 c = in_t[n];
174 *(size_t *)(out+n) = 178 out_t[n] = tmp.t[n] ^ ivec_t[n];
175 *(size_t *)(tmp.c+n) ^ *(size_t *)(ivec+n); 179 ivec_t[n] = c;
176 *(size_t *)(ivec+n) = c;
177 } 180 }
178 len -= 16; 181 len -= 16;
179 in += 16; 182 in += 16;
diff --git a/src/lib/libssl/src/crypto/modes/ccm128.c b/src/lib/libssl/src/crypto/modes/ccm128.c
index c9b35e5b35..3ce11d0d98 100644
--- a/src/lib/libssl/src/crypto/modes/ccm128.c
+++ b/src/lib/libssl/src/crypto/modes/ccm128.c
@@ -87,7 +87,7 @@ int CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx,
87 ctx->nonce.c[11] = (u8)(mlen>>(32%(sizeof(mlen)*8))); 87 ctx->nonce.c[11] = (u8)(mlen>>(32%(sizeof(mlen)*8)));
88 } 88 }
89 else 89 else
90 *(u32*)(&ctx->nonce.c[8]) = 0; 90 ctx->nonce.u[1] = 0;
91 91
92 ctx->nonce.c[12] = (u8)(mlen>>24); 92 ctx->nonce.c[12] = (u8)(mlen>>24);
93 ctx->nonce.c[13] = (u8)(mlen>>16); 93 ctx->nonce.c[13] = (u8)(mlen>>16);
diff --git a/src/lib/libssl/src/crypto/modes/cts128.c b/src/lib/libssl/src/crypto/modes/cts128.c
index c0e1f3696c..2d583de6f6 100644
--- a/src/lib/libssl/src/crypto/modes/cts128.c
+++ b/src/lib/libssl/src/crypto/modes/cts128.c
@@ -108,12 +108,8 @@ size_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out,
108 (*cbc)(in,out-16,residue,key,ivec,1); 108 (*cbc)(in,out-16,residue,key,ivec,1);
109 memcpy(out,tmp.c,residue); 109 memcpy(out,tmp.c,residue);
110#else 110#else
111 { 111 memset(tmp.c,0,sizeof(tmp));
112 size_t n;
113 for (n=0; n<16; n+=sizeof(size_t))
114 *(size_t *)(tmp.c+n) = 0;
115 memcpy(tmp.c,in,residue); 112 memcpy(tmp.c,in,residue);
116 }
117 memcpy(out,out-16,residue); 113 memcpy(out,out-16,residue);
118 (*cbc)(tmp.c,out-16,16,key,ivec,1); 114 (*cbc)(tmp.c,out-16,16,key,ivec,1);
119#endif 115#endif
@@ -144,12 +140,8 @@ size_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out,
144#if defined(CBC_HANDLES_TRUNCATED_IO) 140#if defined(CBC_HANDLES_TRUNCATED_IO)
145 (*cbc)(in,out-16+residue,residue,key,ivec,1); 141 (*cbc)(in,out-16+residue,residue,key,ivec,1);
146#else 142#else
147 { 143 memset(tmp.c,0,sizeof(tmp));
148 size_t n;
149 for (n=0; n<16; n+=sizeof(size_t))
150 *(size_t *)(tmp.c+n) = 0;
151 memcpy(tmp.c,in,residue); 144 memcpy(tmp.c,in,residue);
152 }
153 (*cbc)(tmp.c,out-16+residue,16,key,ivec,1); 145 (*cbc)(tmp.c,out-16+residue,16,key,ivec,1);
154#endif 146#endif
155 return len+residue; 147 return len+residue;
@@ -177,8 +169,7 @@ size_t CRYPTO_cts128_decrypt_block(const unsigned char *in, unsigned char *out,
177 169
178 (*block)(in,tmp.c+16,key); 170 (*block)(in,tmp.c+16,key);
179 171
180 for (n=0; n<16; n+=sizeof(size_t)) 172 memcpy(tmp.c,tmp.c+16,16);
181 *(size_t *)(tmp.c+n) = *(size_t *)(tmp.c+16+n);
182 memcpy(tmp.c,in+16,residue); 173 memcpy(tmp.c,in+16,residue);
183 (*block)(tmp.c,tmp.c,key); 174 (*block)(tmp.c,tmp.c,key);
184 175
@@ -220,8 +211,7 @@ size_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in, unsigned char *o
220 211
221 (*block)(in+residue,tmp.c+16,key); 212 (*block)(in+residue,tmp.c+16,key);
222 213
223 for (n=0; n<16; n+=sizeof(size_t)) 214 memcpy(tmp.c,tmp.c+16,16);
224 *(size_t *)(tmp.c+n) = *(size_t *)(tmp.c+16+n);
225 memcpy(tmp.c,in,residue); 215 memcpy(tmp.c,in,residue);
226 (*block)(tmp.c,tmp.c,key); 216 (*block)(tmp.c,tmp.c,key);
227 217
@@ -240,7 +230,7 @@ size_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in, unsigned char *o
240size_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out, 230size_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out,
241 size_t len, const void *key, 231 size_t len, const void *key,
242 unsigned char ivec[16], cbc128_f cbc) 232 unsigned char ivec[16], cbc128_f cbc)
243{ size_t residue, n; 233{ size_t residue;
244 union { size_t align; unsigned char c[32]; } tmp; 234 union { size_t align; unsigned char c[32]; } tmp;
245 235
246 assert (in && out && key && ivec); 236 assert (in && out && key && ivec);
@@ -257,8 +247,7 @@ size_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out,
257 out += len; 247 out += len;
258 } 248 }
259 249
260 for (n=16; n<32; n+=sizeof(size_t)) 250 memset(tmp.c,0,sizeof(tmp));
261 *(size_t *)(tmp.c+n) = 0;
262 /* this places in[16] at &tmp.c[16] and decrypted block at &tmp.c[0] */ 251 /* this places in[16] at &tmp.c[16] and decrypted block at &tmp.c[0] */
263 (*cbc)(in,tmp.c,16,key,tmp.c+16,0); 252 (*cbc)(in,tmp.c,16,key,tmp.c+16,0);
264 253
@@ -275,7 +264,7 @@ size_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out,
275size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out, 264size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out,
276 size_t len, const void *key, 265 size_t len, const void *key,
277 unsigned char ivec[16], cbc128_f cbc) 266 unsigned char ivec[16], cbc128_f cbc)
278{ size_t residue, n; 267{ size_t residue;
279 union { size_t align; unsigned char c[32]; } tmp; 268 union { size_t align; unsigned char c[32]; } tmp;
280 269
281 assert (in && out && key && ivec); 270 assert (in && out && key && ivec);
@@ -297,8 +286,7 @@ size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out,
297 out += len; 286 out += len;
298 } 287 }
299 288
300 for (n=16; n<32; n+=sizeof(size_t)) 289 memset(tmp.c,0,sizeof(tmp));
301 *(size_t *)(tmp.c+n) = 0;
302 /* this places in[16] at &tmp.c[16] and decrypted block at &tmp.c[0] */ 290 /* this places in[16] at &tmp.c[16] and decrypted block at &tmp.c[0] */
303 (*cbc)(in+residue,tmp.c,16,key,tmp.c+16,0); 291 (*cbc)(in+residue,tmp.c,16,key,tmp.c+16,0);
304 292
diff --git a/src/lib/libssl/src/crypto/modes/gcm128.c b/src/lib/libssl/src/crypto/modes/gcm128.c
index 7d6d034970..e1dc2b0f47 100644
--- a/src/lib/libssl/src/crypto/modes/gcm128.c
+++ b/src/lib/libssl/src/crypto/modes/gcm128.c
@@ -723,7 +723,7 @@ void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx,void *key,block128_f block)
723# endif 723# endif
724 gcm_init_4bit(ctx->Htable,ctx->H.u); 724 gcm_init_4bit(ctx->Htable,ctx->H.u);
725# if defined(GHASH_ASM_X86) /* x86 only */ 725# if defined(GHASH_ASM_X86) /* x86 only */
726# if defined(OPENSSL_IA32_SSE2) 726# if defined(OPENSSL_IA32_SSE2)
727 if (OPENSSL_ia32cap_P[0]&(1<<25)) { /* check SSE bit */ 727 if (OPENSSL_ia32cap_P[0]&(1<<25)) { /* check SSE bit */
728# else 728# else
729 if (OPENSSL_ia32cap_P[0]&(1<<23)) { /* check MMX bit */ 729 if (OPENSSL_ia32cap_P[0]&(1<<23)) { /* check MMX bit */
@@ -810,7 +810,11 @@ void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx,const unsigned char *iv,size_t len)
810 GCM_MUL(ctx,Yi); 810 GCM_MUL(ctx,Yi);
811 811
812 if (is_endian.little) 812 if (is_endian.little)
813#ifdef BSWAP4
814 ctr = BSWAP4(ctx->Yi.d[3]);
815#else
813 ctr = GETU32(ctx->Yi.c+12); 816 ctr = GETU32(ctx->Yi.c+12);
817#endif
814 else 818 else
815 ctr = ctx->Yi.d[3]; 819 ctr = ctx->Yi.d[3];
816 } 820 }
@@ -818,7 +822,11 @@ void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx,const unsigned char *iv,size_t len)
818 (*ctx->block)(ctx->Yi.c,ctx->EK0.c,ctx->key); 822 (*ctx->block)(ctx->Yi.c,ctx->EK0.c,ctx->key);
819 ++ctr; 823 ++ctr;
820 if (is_endian.little) 824 if (is_endian.little)
825#ifdef BSWAP4
826 ctx->Yi.d[3] = BSWAP4(ctr);
827#else
821 PUTU32(ctx->Yi.c+12,ctr); 828 PUTU32(ctx->Yi.c+12,ctr);
829#endif
822 else 830 else
823 ctx->Yi.d[3] = ctr; 831 ctx->Yi.d[3] = ctr;
824} 832}
@@ -913,7 +921,11 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
913 } 921 }
914 922
915 if (is_endian.little) 923 if (is_endian.little)
924#ifdef BSWAP4
925 ctr = BSWAP4(ctx->Yi.d[3]);
926#else
916 ctr = GETU32(ctx->Yi.c+12); 927 ctr = GETU32(ctx->Yi.c+12);
928#endif
917 else 929 else
918 ctr = ctx->Yi.d[3]; 930 ctr = ctx->Yi.d[3];
919 931
@@ -941,15 +953,21 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
941 size_t j=GHASH_CHUNK; 953 size_t j=GHASH_CHUNK;
942 954
943 while (j) { 955 while (j) {
956 size_t *out_t=(size_t *)out;
957 const size_t *in_t=(const size_t *)in;
958
944 (*block)(ctx->Yi.c,ctx->EKi.c,key); 959 (*block)(ctx->Yi.c,ctx->EKi.c,key);
945 ++ctr; 960 ++ctr;
946 if (is_endian.little) 961 if (is_endian.little)
962#ifdef BSWAP4
963 ctx->Yi.d[3] = BSWAP4(ctr);
964#else
947 PUTU32(ctx->Yi.c+12,ctr); 965 PUTU32(ctx->Yi.c+12,ctr);
966#endif
948 else 967 else
949 ctx->Yi.d[3] = ctr; 968 ctx->Yi.d[3] = ctr;
950 for (i=0; i<16; i+=sizeof(size_t)) 969 for (i=0; i<16/sizeof(size_t); ++i)
951 *(size_t *)(out+i) = 970 out_t[i] = in_t[i] ^ ctx->EKi.t[i];
952 *(size_t *)(in+i)^*(size_t *)(ctx->EKi.c+i);
953 out += 16; 971 out += 16;
954 in += 16; 972 in += 16;
955 j -= 16; 973 j -= 16;
@@ -961,15 +979,21 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
961 size_t j=i; 979 size_t j=i;
962 980
963 while (len>=16) { 981 while (len>=16) {
982 size_t *out_t=(size_t *)out;
983 const size_t *in_t=(const size_t *)in;
984
964 (*block)(ctx->Yi.c,ctx->EKi.c,key); 985 (*block)(ctx->Yi.c,ctx->EKi.c,key);
965 ++ctr; 986 ++ctr;
966 if (is_endian.little) 987 if (is_endian.little)
988#ifdef BSWAP4
989 ctx->Yi.d[3] = BSWAP4(ctr);
990#else
967 PUTU32(ctx->Yi.c+12,ctr); 991 PUTU32(ctx->Yi.c+12,ctr);
992#endif
968 else 993 else
969 ctx->Yi.d[3] = ctr; 994 ctx->Yi.d[3] = ctr;
970 for (i=0; i<16; i+=sizeof(size_t)) 995 for (i=0; i<16/sizeof(size_t); ++i)
971 *(size_t *)(out+i) = 996 out_t[i] = in_t[i] ^ ctx->EKi.t[i];
972 *(size_t *)(in+i)^*(size_t *)(ctx->EKi.c+i);
973 out += 16; 997 out += 16;
974 in += 16; 998 in += 16;
975 len -= 16; 999 len -= 16;
@@ -978,16 +1002,22 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
978 } 1002 }
979#else 1003#else
980 while (len>=16) { 1004 while (len>=16) {
1005 size_t *out_t=(size_t *)out;
1006 const size_t *in_t=(const size_t *)in;
1007
981 (*block)(ctx->Yi.c,ctx->EKi.c,key); 1008 (*block)(ctx->Yi.c,ctx->EKi.c,key);
982 ++ctr; 1009 ++ctr;
983 if (is_endian.little) 1010 if (is_endian.little)
1011#ifdef BSWAP4
1012 ctx->Yi.d[3] = BSWAP4(ctr);
1013#else
984 PUTU32(ctx->Yi.c+12,ctr); 1014 PUTU32(ctx->Yi.c+12,ctr);
1015#endif
985 else 1016 else
986 ctx->Yi.d[3] = ctr; 1017 ctx->Yi.d[3] = ctr;
987 for (i=0; i<16; i+=sizeof(size_t)) 1018 for (i=0; i<16/sizeof(size_t); ++i)
988 *(size_t *)(ctx->Xi.c+i) ^= 1019 ctx->Xi.t[i] ^=
989 *(size_t *)(out+i) = 1020 out_t[i] = in_t[i]^ctx->EKi.t[i];
990 *(size_t *)(in+i)^*(size_t *)(ctx->EKi.c+i);
991 GCM_MUL(ctx,Xi); 1021 GCM_MUL(ctx,Xi);
992 out += 16; 1022 out += 16;
993 in += 16; 1023 in += 16;
@@ -998,7 +1028,11 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
998 (*block)(ctx->Yi.c,ctx->EKi.c,key); 1028 (*block)(ctx->Yi.c,ctx->EKi.c,key);
999 ++ctr; 1029 ++ctr;
1000 if (is_endian.little) 1030 if (is_endian.little)
1031#ifdef BSWAP4
1032 ctx->Yi.d[3] = BSWAP4(ctr);
1033#else
1001 PUTU32(ctx->Yi.c+12,ctr); 1034 PUTU32(ctx->Yi.c+12,ctr);
1035#endif
1002 else 1036 else
1003 ctx->Yi.d[3] = ctr; 1037 ctx->Yi.d[3] = ctr;
1004 while (len--) { 1038 while (len--) {
@@ -1016,7 +1050,11 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
1016 (*block)(ctx->Yi.c,ctx->EKi.c,key); 1050 (*block)(ctx->Yi.c,ctx->EKi.c,key);
1017 ++ctr; 1051 ++ctr;
1018 if (is_endian.little) 1052 if (is_endian.little)
1053#ifdef BSWAP4
1054 ctx->Yi.d[3] = BSWAP4(ctr);
1055#else
1019 PUTU32(ctx->Yi.c+12,ctr); 1056 PUTU32(ctx->Yi.c+12,ctr);
1057#endif
1020 else 1058 else
1021 ctx->Yi.d[3] = ctr; 1059 ctx->Yi.d[3] = ctr;
1022 } 1060 }
@@ -1060,7 +1098,11 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,
1060 } 1098 }
1061 1099
1062 if (is_endian.little) 1100 if (is_endian.little)
1101#ifdef BSWAP4
1102 ctr = BSWAP4(ctx->Yi.d[3]);
1103#else
1063 ctr = GETU32(ctx->Yi.c+12); 1104 ctr = GETU32(ctx->Yi.c+12);
1105#endif
1064 else 1106 else
1065 ctr = ctx->Yi.d[3]; 1107 ctr = ctx->Yi.d[3];
1066 1108
@@ -1091,15 +1133,21 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,
1091 1133
1092 GHASH(ctx,in,GHASH_CHUNK); 1134 GHASH(ctx,in,GHASH_CHUNK);
1093 while (j) { 1135 while (j) {
1136 size_t *out_t=(size_t *)out;
1137 const size_t *in_t=(const size_t *)in;
1138
1094 (*block)(ctx->Yi.c,ctx->EKi.c,key); 1139 (*block)(ctx->Yi.c,ctx->EKi.c,key);
1095 ++ctr; 1140 ++ctr;
1096 if (is_endian.little) 1141 if (is_endian.little)
1142#ifdef BSWAP4
1143 ctx->Yi.d[3] = BSWAP4(ctr);
1144#else
1097 PUTU32(ctx->Yi.c+12,ctr); 1145 PUTU32(ctx->Yi.c+12,ctr);
1146#endif
1098 else 1147 else
1099 ctx->Yi.d[3] = ctr; 1148 ctx->Yi.d[3] = ctr;
1100 for (i=0; i<16; i+=sizeof(size_t)) 1149 for (i=0; i<16/sizeof(size_t); ++i)
1101 *(size_t *)(out+i) = 1150 out_t[i] = in_t[i]^ctx->EKi.t[i];
1102 *(size_t *)(in+i)^*(size_t *)(ctx->EKi.c+i);
1103 out += 16; 1151 out += 16;
1104 in += 16; 1152 in += 16;
1105 j -= 16; 1153 j -= 16;
@@ -1109,15 +1157,21 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,
1109 if ((i = (len&(size_t)-16))) { 1157 if ((i = (len&(size_t)-16))) {
1110 GHASH(ctx,in,i); 1158 GHASH(ctx,in,i);
1111 while (len>=16) { 1159 while (len>=16) {
1160 size_t *out_t=(size_t *)out;
1161 const size_t *in_t=(const size_t *)in;
1162
1112 (*block)(ctx->Yi.c,ctx->EKi.c,key); 1163 (*block)(ctx->Yi.c,ctx->EKi.c,key);
1113 ++ctr; 1164 ++ctr;
1114 if (is_endian.little) 1165 if (is_endian.little)
1166#ifdef BSWAP4
1167 ctx->Yi.d[3] = BSWAP4(ctr);
1168#else
1115 PUTU32(ctx->Yi.c+12,ctr); 1169 PUTU32(ctx->Yi.c+12,ctr);
1170#endif
1116 else 1171 else
1117 ctx->Yi.d[3] = ctr; 1172 ctx->Yi.d[3] = ctr;
1118 for (i=0; i<16; i+=sizeof(size_t)) 1173 for (i=0; i<16/sizeof(size_t); ++i)
1119 *(size_t *)(out+i) = 1174 out_t[i] = in_t[i]^ctx->EKi.t[i];
1120 *(size_t *)(in+i)^*(size_t *)(ctx->EKi.c+i);
1121 out += 16; 1175 out += 16;
1122 in += 16; 1176 in += 16;
1123 len -= 16; 1177 len -= 16;
@@ -1125,16 +1179,23 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,
1125 } 1179 }
1126#else 1180#else
1127 while (len>=16) { 1181 while (len>=16) {
1182 size_t *out_t=(size_t *)out;
1183 const size_t *in_t=(const size_t *)in;
1184
1128 (*block)(ctx->Yi.c,ctx->EKi.c,key); 1185 (*block)(ctx->Yi.c,ctx->EKi.c,key);
1129 ++ctr; 1186 ++ctr;
1130 if (is_endian.little) 1187 if (is_endian.little)
1188#ifdef BSWAP4
1189 ctx->Yi.d[3] = BSWAP4(ctr);
1190#else
1131 PUTU32(ctx->Yi.c+12,ctr); 1191 PUTU32(ctx->Yi.c+12,ctr);
1192#endif
1132 else 1193 else
1133 ctx->Yi.d[3] = ctr; 1194 ctx->Yi.d[3] = ctr;
1134 for (i=0; i<16; i+=sizeof(size_t)) { 1195 for (i=0; i<16/sizeof(size_t); ++i) {
1135 size_t c = *(size_t *)(in+i); 1196 size_t c = in[i];
1136 *(size_t *)(out+i) = c^*(size_t *)(ctx->EKi.c+i); 1197 out[i] = c^ctx->EKi.t[i];
1137 *(size_t *)(ctx->Xi.c+i) ^= c; 1198 ctx->Xi.t[i] ^= c;
1138 } 1199 }
1139 GCM_MUL(ctx,Xi); 1200 GCM_MUL(ctx,Xi);
1140 out += 16; 1201 out += 16;
@@ -1146,7 +1207,11 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,
1146 (*block)(ctx->Yi.c,ctx->EKi.c,key); 1207 (*block)(ctx->Yi.c,ctx->EKi.c,key);
1147 ++ctr; 1208 ++ctr;
1148 if (is_endian.little) 1209 if (is_endian.little)
1210#ifdef BSWAP4
1211 ctx->Yi.d[3] = BSWAP4(ctr);
1212#else
1149 PUTU32(ctx->Yi.c+12,ctr); 1213 PUTU32(ctx->Yi.c+12,ctr);
1214#endif
1150 else 1215 else
1151 ctx->Yi.d[3] = ctr; 1216 ctx->Yi.d[3] = ctr;
1152 while (len--) { 1217 while (len--) {
@@ -1167,7 +1232,11 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,
1167 (*block)(ctx->Yi.c,ctx->EKi.c,key); 1232 (*block)(ctx->Yi.c,ctx->EKi.c,key);
1168 ++ctr; 1233 ++ctr;
1169 if (is_endian.little) 1234 if (is_endian.little)
1235#ifdef BSWAP4
1236 ctx->Yi.d[3] = BSWAP4(ctr);
1237#else
1170 PUTU32(ctx->Yi.c+12,ctr); 1238 PUTU32(ctx->Yi.c+12,ctr);
1239#endif
1171 else 1240 else
1172 ctx->Yi.d[3] = ctr; 1241 ctx->Yi.d[3] = ctr;
1173 } 1242 }
@@ -1212,7 +1281,11 @@ int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx,
1212 } 1281 }
1213 1282
1214 if (is_endian.little) 1283 if (is_endian.little)
1284#ifdef BSWAP4
1285 ctr = BSWAP4(ctx->Yi.d[3]);
1286#else
1215 ctr = GETU32(ctx->Yi.c+12); 1287 ctr = GETU32(ctx->Yi.c+12);
1288#endif
1216 else 1289 else
1217 ctr = ctx->Yi.d[3]; 1290 ctr = ctx->Yi.d[3];
1218 1291
@@ -1234,7 +1307,11 @@ int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx,
1234 (*stream)(in,out,GHASH_CHUNK/16,key,ctx->Yi.c); 1307 (*stream)(in,out,GHASH_CHUNK/16,key,ctx->Yi.c);
1235 ctr += GHASH_CHUNK/16; 1308 ctr += GHASH_CHUNK/16;
1236 if (is_endian.little) 1309 if (is_endian.little)
1310#ifdef BSWAP4
1311 ctx->Yi.d[3] = BSWAP4(ctr);
1312#else
1237 PUTU32(ctx->Yi.c+12,ctr); 1313 PUTU32(ctx->Yi.c+12,ctr);
1314#endif
1238 else 1315 else
1239 ctx->Yi.d[3] = ctr; 1316 ctx->Yi.d[3] = ctr;
1240 GHASH(ctx,out,GHASH_CHUNK); 1317 GHASH(ctx,out,GHASH_CHUNK);
@@ -1249,7 +1326,11 @@ int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx,
1249 (*stream)(in,out,j,key,ctx->Yi.c); 1326 (*stream)(in,out,j,key,ctx->Yi.c);
1250 ctr += (unsigned int)j; 1327 ctr += (unsigned int)j;
1251 if (is_endian.little) 1328 if (is_endian.little)
1329#ifdef BSWAP4
1330 ctx->Yi.d[3] = BSWAP4(ctr);
1331#else
1252 PUTU32(ctx->Yi.c+12,ctr); 1332 PUTU32(ctx->Yi.c+12,ctr);
1333#endif
1253 else 1334 else
1254 ctx->Yi.d[3] = ctr; 1335 ctx->Yi.d[3] = ctr;
1255 in += i; 1336 in += i;
@@ -1269,7 +1350,11 @@ int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx,
1269 (*ctx->block)(ctx->Yi.c,ctx->EKi.c,key); 1350 (*ctx->block)(ctx->Yi.c,ctx->EKi.c,key);
1270 ++ctr; 1351 ++ctr;
1271 if (is_endian.little) 1352 if (is_endian.little)
1353#ifdef BSWAP4
1354 ctx->Yi.d[3] = BSWAP4(ctr);
1355#else
1272 PUTU32(ctx->Yi.c+12,ctr); 1356 PUTU32(ctx->Yi.c+12,ctr);
1357#endif
1273 else 1358 else
1274 ctx->Yi.d[3] = ctr; 1359 ctx->Yi.d[3] = ctr;
1275 while (len--) { 1360 while (len--) {
@@ -1311,7 +1396,11 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx,
1311 } 1396 }
1312 1397
1313 if (is_endian.little) 1398 if (is_endian.little)
1399#ifdef BSWAP4
1400 ctr = BSWAP4(ctx->Yi.d[3]);
1401#else
1314 ctr = GETU32(ctx->Yi.c+12); 1402 ctr = GETU32(ctx->Yi.c+12);
1403#endif
1315 else 1404 else
1316 ctr = ctx->Yi.d[3]; 1405 ctr = ctx->Yi.d[3];
1317 1406
@@ -1336,7 +1425,11 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx,
1336 (*stream)(in,out,GHASH_CHUNK/16,key,ctx->Yi.c); 1425 (*stream)(in,out,GHASH_CHUNK/16,key,ctx->Yi.c);
1337 ctr += GHASH_CHUNK/16; 1426 ctr += GHASH_CHUNK/16;
1338 if (is_endian.little) 1427 if (is_endian.little)
1428#ifdef BSWAP4
1429 ctx->Yi.d[3] = BSWAP4(ctr);
1430#else
1339 PUTU32(ctx->Yi.c+12,ctr); 1431 PUTU32(ctx->Yi.c+12,ctr);
1432#endif
1340 else 1433 else
1341 ctx->Yi.d[3] = ctr; 1434 ctx->Yi.d[3] = ctr;
1342 out += GHASH_CHUNK; 1435 out += GHASH_CHUNK;
@@ -1362,7 +1455,11 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx,
1362 (*stream)(in,out,j,key,ctx->Yi.c); 1455 (*stream)(in,out,j,key,ctx->Yi.c);
1363 ctr += (unsigned int)j; 1456 ctr += (unsigned int)j;
1364 if (is_endian.little) 1457 if (is_endian.little)
1458#ifdef BSWAP4
1459 ctx->Yi.d[3] = BSWAP4(ctr);
1460#else
1365 PUTU32(ctx->Yi.c+12,ctr); 1461 PUTU32(ctx->Yi.c+12,ctr);
1462#endif
1366 else 1463 else
1367 ctx->Yi.d[3] = ctr; 1464 ctx->Yi.d[3] = ctr;
1368 out += i; 1465 out += i;
@@ -1373,7 +1470,11 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx,
1373 (*ctx->block)(ctx->Yi.c,ctx->EKi.c,key); 1470 (*ctx->block)(ctx->Yi.c,ctx->EKi.c,key);
1374 ++ctr; 1471 ++ctr;
1375 if (is_endian.little) 1472 if (is_endian.little)
1473#ifdef BSWAP4
1474 ctx->Yi.d[3] = BSWAP4(ctr);
1475#else
1376 PUTU32(ctx->Yi.c+12,ctr); 1476 PUTU32(ctx->Yi.c+12,ctr);
1477#endif
1377 else 1478 else
1378 ctx->Yi.d[3] = ctr; 1479 ctx->Yi.d[3] = ctr;
1379 while (len--) { 1480 while (len--) {
@@ -1398,7 +1499,7 @@ int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx,const unsigned char *tag,
1398 void (*gcm_gmult_p)(u64 Xi[2],const u128 Htable[16]) = ctx->gmult; 1499 void (*gcm_gmult_p)(u64 Xi[2],const u128 Htable[16]) = ctx->gmult;
1399#endif 1500#endif
1400 1501
1401 if (ctx->mres) 1502 if (ctx->mres || ctx->ares)
1402 GCM_MUL(ctx,Xi); 1503 GCM_MUL(ctx,Xi);
1403 1504
1404 if (is_endian.little) { 1505 if (is_endian.little) {
@@ -1669,6 +1770,46 @@ static const u8 IV18[]={0x93,0x13,0x22,0x5d,0xf8,0x84,0x06,0xe5,0x55,0x90,0x9c,0
1669 0xa2,0x41,0x89,0x97,0x20,0x0e,0xf8,0x2e,0x44,0xae,0x7e,0x3f}, 1770 0xa2,0x41,0x89,0x97,0x20,0x0e,0xf8,0x2e,0x44,0xae,0x7e,0x3f},
1670 T18[]= {0xa4,0x4a,0x82,0x66,0xee,0x1c,0x8e,0xb0,0xc8,0xb5,0xd4,0xcf,0x5a,0xe9,0xf1,0x9a}; 1771 T18[]= {0xa4,0x4a,0x82,0x66,0xee,0x1c,0x8e,0xb0,0xc8,0xb5,0xd4,0xcf,0x5a,0xe9,0xf1,0x9a};
1671 1772
1773/* Test Case 19 */
1774#define K19 K1
1775#define P19 P1
1776#define IV19 IV1
1777#define C19 C1
1778static const u8 A19[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a,
1779 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72,
1780 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25,
1781 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39,0x1a,0xaf,0xd2,0x55,
1782 0x52,0x2d,0xc1,0xf0,0x99,0x56,0x7d,0x07,0xf4,0x7f,0x37,0xa3,0x2a,0x84,0x42,0x7d,
1783 0x64,0x3a,0x8c,0xdc,0xbf,0xe5,0xc0,0xc9,0x75,0x98,0xa2,0xbd,0x25,0x55,0xd1,0xaa,
1784 0x8c,0xb0,0x8e,0x48,0x59,0x0d,0xbb,0x3d,0xa7,0xb0,0x8b,0x10,0x56,0x82,0x88,0x38,
1785 0xc5,0xf6,0x1e,0x63,0x93,0xba,0x7a,0x0a,0xbc,0xc9,0xf6,0x62,0x89,0x80,0x15,0xad},
1786 T19[]= {0x5f,0xea,0x79,0x3a,0x2d,0x6f,0x97,0x4d,0x37,0xe6,0x8e,0x0c,0xb8,0xff,0x94,0x92};
1787
1788/* Test Case 20 */
1789#define K20 K1
1790#define A20 A1
1791static const u8 IV20[64]={0xff,0xff,0xff,0xff}, /* this results in 0xff in counter LSB */
1792 P20[288],
1793 C20[]= {0x56,0xb3,0x37,0x3c,0xa9,0xef,0x6e,0x4a,0x2b,0x64,0xfe,0x1e,0x9a,0x17,0xb6,0x14,
1794 0x25,0xf1,0x0d,0x47,0xa7,0x5a,0x5f,0xce,0x13,0xef,0xc6,0xbc,0x78,0x4a,0xf2,0x4f,
1795 0x41,0x41,0xbd,0xd4,0x8c,0xf7,0xc7,0x70,0x88,0x7a,0xfd,0x57,0x3c,0xca,0x54,0x18,
1796 0xa9,0xae,0xff,0xcd,0x7c,0x5c,0xed,0xdf,0xc6,0xa7,0x83,0x97,0xb9,0xa8,0x5b,0x49,
1797 0x9d,0xa5,0x58,0x25,0x72,0x67,0xca,0xab,0x2a,0xd0,0xb2,0x3c,0xa4,0x76,0xa5,0x3c,
1798 0xb1,0x7f,0xb4,0x1c,0x4b,0x8b,0x47,0x5c,0xb4,0xf3,0xf7,0x16,0x50,0x94,0xc2,0x29,
1799 0xc9,0xe8,0xc4,0xdc,0x0a,0x2a,0x5f,0xf1,0x90,0x3e,0x50,0x15,0x11,0x22,0x13,0x76,
1800 0xa1,0xcd,0xb8,0x36,0x4c,0x50,0x61,0xa2,0x0c,0xae,0x74,0xbc,0x4a,0xcd,0x76,0xce,
1801 0xb0,0xab,0xc9,0xfd,0x32,0x17,0xef,0x9f,0x8c,0x90,0xbe,0x40,0x2d,0xdf,0x6d,0x86,
1802 0x97,0xf4,0xf8,0x80,0xdf,0xf1,0x5b,0xfb,0x7a,0x6b,0x28,0x24,0x1e,0xc8,0xfe,0x18,
1803 0x3c,0x2d,0x59,0xe3,0xf9,0xdf,0xff,0x65,0x3c,0x71,0x26,0xf0,0xac,0xb9,0xe6,0x42,
1804 0x11,0xf4,0x2b,0xae,0x12,0xaf,0x46,0x2b,0x10,0x70,0xbe,0xf1,0xab,0x5e,0x36,0x06,
1805 0x87,0x2c,0xa1,0x0d,0xee,0x15,0xb3,0x24,0x9b,0x1a,0x1b,0x95,0x8f,0x23,0x13,0x4c,
1806 0x4b,0xcc,0xb7,0xd0,0x32,0x00,0xbc,0xe4,0x20,0xa2,0xf8,0xeb,0x66,0xdc,0xf3,0x64,
1807 0x4d,0x14,0x23,0xc1,0xb5,0x69,0x90,0x03,0xc1,0x3e,0xce,0xf4,0xbf,0x38,0xa3,0xb6,
1808 0x0e,0xed,0xc3,0x40,0x33,0xba,0xc1,0x90,0x27,0x83,0xdc,0x6d,0x89,0xe2,0xe7,0x74,
1809 0x18,0x8a,0x43,0x9c,0x7e,0xbc,0xc0,0x67,0x2d,0xbd,0xa4,0xdd,0xcf,0xb2,0x79,0x46,
1810 0x13,0xb0,0xbe,0x41,0x31,0x5e,0xf7,0x78,0x70,0x8a,0x70,0xee,0x7d,0x75,0x16,0x5c},
1811 T20[]= {0x8b,0x30,0x7f,0x6b,0x33,0x28,0x6d,0x0a,0xb0,0x26,0xa9,0xed,0x3f,0xe1,0xe8,0x5f};
1812
1672#define TEST_CASE(n) do { \ 1813#define TEST_CASE(n) do { \
1673 u8 out[sizeof(P##n)]; \ 1814 u8 out[sizeof(P##n)]; \
1674 AES_set_encrypt_key(K##n,sizeof(K##n)*8,&key); \ 1815 AES_set_encrypt_key(K##n,sizeof(K##n)*8,&key); \
@@ -1713,6 +1854,8 @@ int main()
1713 TEST_CASE(16); 1854 TEST_CASE(16);
1714 TEST_CASE(17); 1855 TEST_CASE(17);
1715 TEST_CASE(18); 1856 TEST_CASE(18);
1857 TEST_CASE(19);
1858 TEST_CASE(20);
1716 1859
1717#ifdef OPENSSL_CPUID_OBJ 1860#ifdef OPENSSL_CPUID_OBJ
1718 { 1861 {
@@ -1743,11 +1886,16 @@ int main()
1743 ctr_t/(double)sizeof(buf), 1886 ctr_t/(double)sizeof(buf),
1744 (gcm_t-ctr_t)/(double)sizeof(buf)); 1887 (gcm_t-ctr_t)/(double)sizeof(buf));
1745#ifdef GHASH 1888#ifdef GHASH
1746 GHASH(&ctx,buf.c,sizeof(buf)); 1889 {
1890 void (*gcm_ghash_p)(u64 Xi[2],const u128 Htable[16],
1891 const u8 *inp,size_t len) = ctx.ghash;
1892
1893 GHASH((&ctx),buf.c,sizeof(buf));
1747 start = OPENSSL_rdtsc(); 1894 start = OPENSSL_rdtsc();
1748 for (i=0;i<100;++i) GHASH(&ctx,buf.c,sizeof(buf)); 1895 for (i=0;i<100;++i) GHASH((&ctx),buf.c,sizeof(buf));
1749 gcm_t = OPENSSL_rdtsc() - start; 1896 gcm_t = OPENSSL_rdtsc() - start;
1750 printf("%.2f\n",gcm_t/(double)sizeof(buf)/(double)i); 1897 printf("%.2f\n",gcm_t/(double)sizeof(buf)/(double)i);
1898 }
1751#endif 1899#endif
1752 } 1900 }
1753#endif 1901#endif
diff --git a/src/lib/libssl/src/crypto/modes/modes_lcl.h b/src/lib/libssl/src/crypto/modes/modes_lcl.h
index b6dc3c336f..9d83e12844 100644
--- a/src/lib/libssl/src/crypto/modes/modes_lcl.h
+++ b/src/lib/libssl/src/crypto/modes/modes_lcl.h
@@ -29,10 +29,7 @@ typedef unsigned char u8;
29#if defined(__i386) || defined(__i386__) || \ 29#if defined(__i386) || defined(__i386__) || \
30 defined(__x86_64) || defined(__x86_64__) || \ 30 defined(__x86_64) || defined(__x86_64__) || \
31 defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || \ 31 defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || \
32 defined(__s390__) || defined(__s390x__) || \ 32 defined(__s390__) || defined(__s390x__)
33 ( (defined(__arm__) || defined(__arm)) && \
34 (defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \
35 defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__)) )
36# undef STRICT_ALIGNMENT 33# undef STRICT_ALIGNMENT
37#endif 34#endif
38 35
@@ -101,8 +98,8 @@ typedef struct { u64 hi,lo; } u128;
101 98
102struct gcm128_context { 99struct gcm128_context {
103 /* Following 6 names follow names in GCM specification */ 100 /* Following 6 names follow names in GCM specification */
104 union { u64 u[2]; u32 d[4]; u8 c[16]; } Yi,EKi,EK0,len, 101 union { u64 u[2]; u32 d[4]; u8 c[16]; size_t t[16/sizeof(size_t)]; }
105 Xi,H; 102 Yi,EKi,EK0,len,Xi,H;
106 /* Relative position of Xi, H and pre-computed Htable is used 103 /* Relative position of Xi, H and pre-computed Htable is used
107 * in some assembler modules, i.e. don't change the order! */ 104 * in some assembler modules, i.e. don't change the order! */
108#if TABLE_BITS==8 105#if TABLE_BITS==8
diff --git a/src/lib/libssl/src/crypto/pariscid.pl b/src/lib/libssl/src/crypto/pariscid.pl
index 477ec9b87d..bfc56fdc7f 100644
--- a/src/lib/libssl/src/crypto/pariscid.pl
+++ b/src/lib/libssl/src/crypto/pariscid.pl
@@ -97,33 +97,33 @@ OPENSSL_cleanse
97 .PROC 97 .PROC
98 .CALLINFO NO_CALLS 98 .CALLINFO NO_CALLS
99 .ENTRY 99 .ENTRY
100 cmpib,*= 0,$len,Ldone 100 cmpib,*= 0,$len,L\$done
101 nop 101 nop
102 cmpib,*>>= 15,$len,Little 102 cmpib,*>>= 15,$len,L\$ittle
103 ldi $SIZE_T-1,%r1 103 ldi $SIZE_T-1,%r1
104 104
105Lalign 105L\$align
106 and,*<> $inp,%r1,%r28 106 and,*<> $inp,%r1,%r28
107 b,n Laligned 107 b,n L\$aligned
108 stb %r0,0($inp) 108 stb %r0,0($inp)
109 ldo -1($len),$len 109 ldo -1($len),$len
110 b Lalign 110 b L\$align
111 ldo 1($inp),$inp 111 ldo 1($inp),$inp
112 112
113Laligned 113L\$aligned
114 andcm $len,%r1,%r28 114 andcm $len,%r1,%r28
115Lot 115L\$ot
116 $ST %r0,0($inp) 116 $ST %r0,0($inp)
117 addib,*<> -$SIZE_T,%r28,Lot 117 addib,*<> -$SIZE_T,%r28,L\$ot
118 ldo $SIZE_T($inp),$inp 118 ldo $SIZE_T($inp),$inp
119 119
120 and,*<> $len,%r1,$len 120 and,*<> $len,%r1,$len
121 b,n Ldone 121 b,n L\$done
122Little 122L\$ittle
123 stb %r0,0($inp) 123 stb %r0,0($inp)
124 addib,*<> -1,$len,Little 124 addib,*<> -1,$len,L\$ittle
125 ldo 1($inp),$inp 125 ldo 1($inp),$inp
126Ldone 126L\$done
127 bv ($rp) 127 bv ($rp)
128 .EXIT 128 .EXIT
129 nop 129 nop
@@ -151,7 +151,7 @@ OPENSSL_instrument_bus
151 ldw 0($out),$tick 151 ldw 0($out),$tick
152 add $diff,$tick,$tick 152 add $diff,$tick,$tick
153 stw $tick,0($out) 153 stw $tick,0($out)
154Loop 154L\$oop
155 mfctl %cr16,$tick 155 mfctl %cr16,$tick
156 sub $tick,$lasttick,$diff 156 sub $tick,$lasttick,$diff
157 copy $tick,$lasttick 157 copy $tick,$lasttick
@@ -161,7 +161,7 @@ Loop
161 add $diff,$tick,$tick 161 add $diff,$tick,$tick
162 stw $tick,0($out) 162 stw $tick,0($out)
163 163
164 addib,<> -1,$cnt,Loop 164 addib,<> -1,$cnt,L\$oop
165 addi 4,$out,$out 165 addi 4,$out,$out
166 166
167 bv ($rp) 167 bv ($rp)
@@ -190,14 +190,14 @@ OPENSSL_instrument_bus2
190 mfctl %cr16,$tick 190 mfctl %cr16,$tick
191 sub $tick,$lasttick,$diff 191 sub $tick,$lasttick,$diff
192 copy $tick,$lasttick 192 copy $tick,$lasttick
193Loop2 193L\$oop2
194 copy $diff,$lastdiff 194 copy $diff,$lastdiff
195 fdc 0($out) 195 fdc 0($out)
196 ldw 0($out),$tick 196 ldw 0($out),$tick
197 add $diff,$tick,$tick 197 add $diff,$tick,$tick
198 stw $tick,0($out) 198 stw $tick,0($out)
199 199
200 addib,= -1,$max,Ldone2 200 addib,= -1,$max,L\$done2
201 nop 201 nop
202 202
203 mfctl %cr16,$tick 203 mfctl %cr16,$tick
@@ -208,17 +208,18 @@ Loop2
208 208
209 ldi 1,%r1 209 ldi 1,%r1
210 xor %r1,$tick,$tick 210 xor %r1,$tick,$tick
211 addb,<> $tick,$cnt,Loop2 211 addb,<> $tick,$cnt,L\$oop2
212 shladd,l $tick,2,$out,$out 212 shladd,l $tick,2,$out,$out
213Ldone2 213L\$done2
214 bv ($rp) 214 bv ($rp)
215 .EXIT 215 .EXIT
216 add $rv,$cnt,$rv 216 add $rv,$cnt,$rv
217 .PROCEND 217 .PROCEND
218___ 218___
219} 219}
220$code =~ s/cmpib,\*/comib,/gm if ($SIZE_T==4); 220$code =~ s/cmpib,\*/comib,/gm if ($SIZE_T==4);
221$code =~ s/,\*/,/gm if ($SIZE_T==4); 221$code =~ s/,\*/,/gm if ($SIZE_T==4);
222$code =~ s/\bbv\b/bve/gm if ($SIZE_T==8);
222print $code; 223print $code;
223close STDOUT; 224close STDOUT;
224 225
diff --git a/src/lib/libssl/src/crypto/perlasm/x86masm.pl b/src/lib/libssl/src/crypto/perlasm/x86masm.pl
index 96b1b73e1a..f937d07c87 100644
--- a/src/lib/libssl/src/crypto/perlasm/x86masm.pl
+++ b/src/lib/libssl/src/crypto/perlasm/x86masm.pl
@@ -33,6 +33,7 @@ sub ::generic
33sub ::call { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); } 33sub ::call { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); }
34sub ::call_ptr { &::emit("call",@_); } 34sub ::call_ptr { &::emit("call",@_); }
35sub ::jmp_ptr { &::emit("jmp",@_); } 35sub ::jmp_ptr { &::emit("jmp",@_); }
36sub ::lock { &::data_byte(0xf0); }
36 37
37sub get_mem 38sub get_mem
38{ my($size,$addr,$reg1,$reg2,$idx)=@_; 39{ my($size,$addr,$reg1,$reg2,$idx)=@_;
diff --git a/src/lib/libssl/src/crypto/pkcs7/bio_pk7.c b/src/lib/libssl/src/crypto/pkcs7/bio_pk7.c
index c8d06d6cdc..0fd31e730f 100644
--- a/src/lib/libssl/src/crypto/pkcs7/bio_pk7.c
+++ b/src/lib/libssl/src/crypto/pkcs7/bio_pk7.c
@@ -56,7 +56,7 @@
56#include <openssl/pkcs7.h> 56#include <openssl/pkcs7.h>
57#include <openssl/bio.h> 57#include <openssl/bio.h>
58 58
59#ifndef OPENSSL_SYSNAME_NETWARE 59#if !defined(OPENSSL_SYSNAME_NETWARE) && !defined(OPENSSL_SYSNAME_VXWORKS)
60#include <memory.h> 60#include <memory.h>
61#endif 61#endif
62#include <stdio.h> 62#include <stdio.h>
diff --git a/src/lib/libssl/src/crypto/ppccap.c b/src/lib/libssl/src/crypto/ppccap.c
index ab89ccaa12..f71ba66aa3 100644
--- a/src/lib/libssl/src/crypto/ppccap.c
+++ b/src/lib/libssl/src/crypto/ppccap.c
@@ -3,6 +3,7 @@
3#include <string.h> 3#include <string.h>
4#include <setjmp.h> 4#include <setjmp.h>
5#include <signal.h> 5#include <signal.h>
6#include <unistd.h>
6#include <crypto.h> 7#include <crypto.h>
7#include <openssl/bn.h> 8#include <openssl/bn.h>
8 9
@@ -53,6 +54,7 @@ static sigjmp_buf ill_jmp;
53static void ill_handler (int sig) { siglongjmp(ill_jmp,sig); } 54static void ill_handler (int sig) { siglongjmp(ill_jmp,sig); }
54 55
55void OPENSSL_ppc64_probe(void); 56void OPENSSL_ppc64_probe(void);
57void OPENSSL_altivec_probe(void);
56 58
57void OPENSSL_cpuid_setup(void) 59void OPENSSL_cpuid_setup(void)
58 { 60 {
@@ -82,6 +84,15 @@ void OPENSSL_cpuid_setup(void)
82 84
83 OPENSSL_ppccap_P = 0; 85 OPENSSL_ppccap_P = 0;
84 86
87#if defined(_AIX)
88 if (sizeof(size_t)==4
89# if defined(_SC_AIX_KERNEL_BITMODE)
90 && sysconf(_SC_AIX_KERNEL_BITMODE)!=64
91# endif
92 )
93 return;
94#endif
95
85 memset(&ill_act,0,sizeof(ill_act)); 96 memset(&ill_act,0,sizeof(ill_act));
86 ill_act.sa_handler = ill_handler; 97 ill_act.sa_handler = ill_handler;
87 ill_act.sa_mask = all_masked; 98 ill_act.sa_mask = all_masked;
diff --git a/src/lib/libssl/src/crypto/rc4/asm/rc4-md5-x86_64.pl b/src/lib/libssl/src/crypto/rc4/asm/rc4-md5-x86_64.pl
index 7f684092d4..272fa91e1a 100644
--- a/src/lib/libssl/src/crypto/rc4/asm/rc4-md5-x86_64.pl
+++ b/src/lib/libssl/src/crypto/rc4/asm/rc4-md5-x86_64.pl
@@ -51,7 +51,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; my $dir=$1; my $xlate;
51( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or 51( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
52die "can't locate x86_64-xlate.pl"; 52die "can't locate x86_64-xlate.pl";
53 53
54open STDOUT,"| $^X $xlate $flavour $output"; 54open OUT,"| \"$^X\" $xlate $flavour $output";
55*STDOUT=*OUT;
55 56
56my ($dat,$in0,$out,$ctx,$inp,$len, $func,$nargs); 57my ($dat,$in0,$out,$ctx,$inp,$len, $func,$nargs);
57 58
diff --git a/src/lib/libssl/src/crypto/rc4/asm/rc4-parisc.pl b/src/lib/libssl/src/crypto/rc4/asm/rc4-parisc.pl
index 9165067080..ad7e65651c 100644
--- a/src/lib/libssl/src/crypto/rc4/asm/rc4-parisc.pl
+++ b/src/lib/libssl/src/crypto/rc4/asm/rc4-parisc.pl
@@ -307,7 +307,8 @@ L\$opts
307 .STRINGZ "RC4 for PA-RISC, CRYPTOGAMS by <appro\@openssl.org>" 307 .STRINGZ "RC4 for PA-RISC, CRYPTOGAMS by <appro\@openssl.org>"
308___ 308___
309$code =~ s/\`([^\`]*)\`/eval $1/gem; 309$code =~ s/\`([^\`]*)\`/eval $1/gem;
310$code =~ s/cmpib,\*/comib,/gm if ($SIZE_T==4); 310$code =~ s/cmpib,\*/comib,/gm if ($SIZE_T==4);
311$code =~ s/\bbv\b/bve/gm if ($SIZE_T==8);
311 312
312print $code; 313print $code;
313close STDOUT; 314close STDOUT;
diff --git a/src/lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl b/src/lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl
index d6eac205e9..75750dbf33 100755
--- a/src/lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl
+++ b/src/lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl
@@ -112,7 +112,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
112( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or 112( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
113die "can't locate x86_64-xlate.pl"; 113die "can't locate x86_64-xlate.pl";
114 114
115open STDOUT,"| $^X $xlate $flavour $output"; 115open OUT,"| \"$^X\" $xlate $flavour $output";
116*STDOUT=*OUT;
116 117
117$dat="%rdi"; # arg1 118$dat="%rdi"; # arg1
118$len="%rsi"; # arg2 119$len="%rsi"; # arg2
diff --git a/src/lib/libssl/src/crypto/rc5/asm/rc5-586.pl b/src/lib/libssl/src/crypto/rc5/asm/rc5-586.pl
index edff1d1e64..61ac6effc6 100644
--- a/src/lib/libssl/src/crypto/rc5/asm/rc5-586.pl
+++ b/src/lib/libssl/src/crypto/rc5/asm/rc5-586.pl
@@ -1,6 +1,7 @@
1#!/usr/local/bin/perl 1#!/usr/local/bin/perl
2 2
3push(@INC,"perlasm","../../perlasm"); 3$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
4push(@INC,"${dir}","${dir}../../perlasm");
4require "x86asm.pl"; 5require "x86asm.pl";
5require "cbc.pl"; 6require "cbc.pl";
6 7
diff --git a/src/lib/libssl/src/crypto/rc5/rc5_ecb.c b/src/lib/libssl/src/crypto/rc5/rc5_ecb.c
new file mode 100644
index 0000000000..e72b535507
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc5/rc5_ecb.c
@@ -0,0 +1,80 @@
1/* crypto/rc5/rc5_ecb.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <openssl/rc5.h>
60#include "rc5_locl.h"
61#include <openssl/opensslv.h>
62
63const char RC5_version[]="RC5" OPENSSL_VERSION_PTEXT;
64
65void RC5_32_ecb_encrypt(const unsigned char *in, unsigned char *out,
66 RC5_32_KEY *ks, int encrypt)
67 {
68 unsigned long l,d[2];
69
70 c2l(in,l); d[0]=l;
71 c2l(in,l); d[1]=l;
72 if (encrypt)
73 RC5_32_encrypt(d,ks);
74 else
75 RC5_32_decrypt(d,ks);
76 l=d[0]; l2c(l,out);
77 l=d[1]; l2c(l,out);
78 l=d[0]=d[1]=0;
79 }
80
diff --git a/src/lib/libssl/src/crypto/rc5/rc5_enc.c b/src/lib/libssl/src/crypto/rc5/rc5_enc.c
new file mode 100644
index 0000000000..f327d32a76
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc5/rc5_enc.c
@@ -0,0 +1,215 @@
1/* crypto/rc5/rc5_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <openssl/rc5.h>
61#include "rc5_locl.h"
62
63void RC5_32_cbc_encrypt(const unsigned char *in, unsigned char *out,
64 long length, RC5_32_KEY *ks, unsigned char *iv,
65 int encrypt)
66 {
67 register unsigned long tin0,tin1;
68 register unsigned long tout0,tout1,xor0,xor1;
69 register long l=length;
70 unsigned long tin[2];
71
72 if (encrypt)
73 {
74 c2l(iv,tout0);
75 c2l(iv,tout1);
76 iv-=8;
77 for (l-=8; l>=0; l-=8)
78 {
79 c2l(in,tin0);
80 c2l(in,tin1);
81 tin0^=tout0;
82 tin1^=tout1;
83 tin[0]=tin0;
84 tin[1]=tin1;
85 RC5_32_encrypt(tin,ks);
86 tout0=tin[0]; l2c(tout0,out);
87 tout1=tin[1]; l2c(tout1,out);
88 }
89 if (l != -8)
90 {
91 c2ln(in,tin0,tin1,l+8);
92 tin0^=tout0;
93 tin1^=tout1;
94 tin[0]=tin0;
95 tin[1]=tin1;
96 RC5_32_encrypt(tin,ks);
97 tout0=tin[0]; l2c(tout0,out);
98 tout1=tin[1]; l2c(tout1,out);
99 }
100 l2c(tout0,iv);
101 l2c(tout1,iv);
102 }
103 else
104 {
105 c2l(iv,xor0);
106 c2l(iv,xor1);
107 iv-=8;
108 for (l-=8; l>=0; l-=8)
109 {
110 c2l(in,tin0); tin[0]=tin0;
111 c2l(in,tin1); tin[1]=tin1;
112 RC5_32_decrypt(tin,ks);
113 tout0=tin[0]^xor0;
114 tout1=tin[1]^xor1;
115 l2c(tout0,out);
116 l2c(tout1,out);
117 xor0=tin0;
118 xor1=tin1;
119 }
120 if (l != -8)
121 {
122 c2l(in,tin0); tin[0]=tin0;
123 c2l(in,tin1); tin[1]=tin1;
124 RC5_32_decrypt(tin,ks);
125 tout0=tin[0]^xor0;
126 tout1=tin[1]^xor1;
127 l2cn(tout0,tout1,out,l+8);
128 xor0=tin0;
129 xor1=tin1;
130 }
131 l2c(xor0,iv);
132 l2c(xor1,iv);
133 }
134 tin0=tin1=tout0=tout1=xor0=xor1=0;
135 tin[0]=tin[1]=0;
136 }
137
138void RC5_32_encrypt(unsigned long *d, RC5_32_KEY *key)
139 {
140 RC5_32_INT a,b,*s;
141
142 s=key->data;
143
144 a=d[0]+s[0];
145 b=d[1]+s[1];
146 E_RC5_32(a,b,s, 2);
147 E_RC5_32(a,b,s, 4);
148 E_RC5_32(a,b,s, 6);
149 E_RC5_32(a,b,s, 8);
150 E_RC5_32(a,b,s,10);
151 E_RC5_32(a,b,s,12);
152 E_RC5_32(a,b,s,14);
153 E_RC5_32(a,b,s,16);
154 if (key->rounds == 12)
155 {
156 E_RC5_32(a,b,s,18);
157 E_RC5_32(a,b,s,20);
158 E_RC5_32(a,b,s,22);
159 E_RC5_32(a,b,s,24);
160 }
161 else if (key->rounds == 16)
162 {
163 /* Do a full expansion to avoid a jump */
164 E_RC5_32(a,b,s,18);
165 E_RC5_32(a,b,s,20);
166 E_RC5_32(a,b,s,22);
167 E_RC5_32(a,b,s,24);
168 E_RC5_32(a,b,s,26);
169 E_RC5_32(a,b,s,28);
170 E_RC5_32(a,b,s,30);
171 E_RC5_32(a,b,s,32);
172 }
173 d[0]=a;
174 d[1]=b;
175 }
176
177void RC5_32_decrypt(unsigned long *d, RC5_32_KEY *key)
178 {
179 RC5_32_INT a,b,*s;
180
181 s=key->data;
182
183 a=d[0];
184 b=d[1];
185 if (key->rounds == 16)
186 {
187 D_RC5_32(a,b,s,32);
188 D_RC5_32(a,b,s,30);
189 D_RC5_32(a,b,s,28);
190 D_RC5_32(a,b,s,26);
191 /* Do a full expansion to avoid a jump */
192 D_RC5_32(a,b,s,24);
193 D_RC5_32(a,b,s,22);
194 D_RC5_32(a,b,s,20);
195 D_RC5_32(a,b,s,18);
196 }
197 else if (key->rounds == 12)
198 {
199 D_RC5_32(a,b,s,24);
200 D_RC5_32(a,b,s,22);
201 D_RC5_32(a,b,s,20);
202 D_RC5_32(a,b,s,18);
203 }
204 D_RC5_32(a,b,s,16);
205 D_RC5_32(a,b,s,14);
206 D_RC5_32(a,b,s,12);
207 D_RC5_32(a,b,s,10);
208 D_RC5_32(a,b,s, 8);
209 D_RC5_32(a,b,s, 6);
210 D_RC5_32(a,b,s, 4);
211 D_RC5_32(a,b,s, 2);
212 d[0]=a-s[0];
213 d[1]=b-s[1];
214 }
215
diff --git a/src/lib/libssl/src/crypto/rc5/rc5_skey.c b/src/lib/libssl/src/crypto/rc5/rc5_skey.c
new file mode 100644
index 0000000000..a2e00a41c5
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc5/rc5_skey.c
@@ -0,0 +1,113 @@
1/* crypto/rc5/rc5_skey.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <openssl/rc5.h>
60#include "rc5_locl.h"
61
62void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,
63 int rounds)
64 {
65 RC5_32_INT L[64],l,ll,A,B,*S,k;
66 int i,j,m,c,t,ii,jj;
67
68 if ( (rounds != RC5_16_ROUNDS) &&
69 (rounds != RC5_12_ROUNDS) &&
70 (rounds != RC5_8_ROUNDS))
71 rounds=RC5_16_ROUNDS;
72
73 key->rounds=rounds;
74 S= &(key->data[0]);
75 j=0;
76 for (i=0; i<=(len-8); i+=8)
77 {
78 c2l(data,l);
79 L[j++]=l;
80 c2l(data,l);
81 L[j++]=l;
82 }
83 ii=len-i;
84 if (ii)
85 {
86 k=len&0x07;
87 c2ln(data,l,ll,k);
88 L[j+0]=l;
89 L[j+1]=ll;
90 }
91
92 c=(len+3)/4;
93 t=(rounds+1)*2;
94 S[0]=RC5_32_P;
95 for (i=1; i<t; i++)
96 S[i]=(S[i-1]+RC5_32_Q)&RC5_32_MASK;
97
98 j=(t>c)?t:c;
99 j*=3;
100 ii=jj=0;
101 A=B=0;
102 for (i=0; i<j; i++)
103 {
104 k=(S[ii]+A+B)&RC5_32_MASK;
105 A=S[ii]=ROTATE_l32(k,3);
106 m=(int)(A+B);
107 k=(L[jj]+A+B)&RC5_32_MASK;
108 B=L[jj]=ROTATE_l32(k,m);
109 if (++ii >= t) ii=0;
110 if (++jj >= c) jj=0;
111 }
112 }
113
diff --git a/src/lib/libssl/src/crypto/rc5/rc5cfb64.c b/src/lib/libssl/src/crypto/rc5/rc5cfb64.c
new file mode 100644
index 0000000000..3a8b60bc7a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc5/rc5cfb64.c
@@ -0,0 +1,122 @@
1/* crypto/rc5/rc5cfb64.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <openssl/rc5.h>
60#include "rc5_locl.h"
61
62/* The input and output encrypted as though 64bit cfb mode is being
63 * used. The extra state information to record how much of the
64 * 64bit block we have used is contained in *num;
65 */
66
67void RC5_32_cfb64_encrypt(const unsigned char *in, unsigned char *out,
68 long length, RC5_32_KEY *schedule,
69 unsigned char *ivec, int *num, int encrypt)
70 {
71 register unsigned long v0,v1,t;
72 register int n= *num;
73 register long l=length;
74 unsigned long ti[2];
75 unsigned char *iv,c,cc;
76
77 iv=(unsigned char *)ivec;
78 if (encrypt)
79 {
80 while (l--)
81 {
82 if (n == 0)
83 {
84 c2l(iv,v0); ti[0]=v0;
85 c2l(iv,v1); ti[1]=v1;
86 RC5_32_encrypt((unsigned long *)ti,schedule);
87 iv=(unsigned char *)ivec;
88 t=ti[0]; l2c(t,iv);
89 t=ti[1]; l2c(t,iv);
90 iv=(unsigned char *)ivec;
91 }
92 c= *(in++)^iv[n];
93 *(out++)=c;
94 iv[n]=c;
95 n=(n+1)&0x07;
96 }
97 }
98 else
99 {
100 while (l--)
101 {
102 if (n == 0)
103 {
104 c2l(iv,v0); ti[0]=v0;
105 c2l(iv,v1); ti[1]=v1;
106 RC5_32_encrypt((unsigned long *)ti,schedule);
107 iv=(unsigned char *)ivec;
108 t=ti[0]; l2c(t,iv);
109 t=ti[1]; l2c(t,iv);
110 iv=(unsigned char *)ivec;
111 }
112 cc= *(in++);
113 c=iv[n];
114 iv[n]=cc;
115 *(out++)=c^cc;
116 n=(n+1)&0x07;
117 }
118 }
119 v0=v1=ti[0]=ti[1]=t=c=cc=0;
120 *num=n;
121 }
122
diff --git a/src/lib/libssl/src/crypto/rc5/rc5ofb64.c b/src/lib/libssl/src/crypto/rc5/rc5ofb64.c
new file mode 100644
index 0000000000..d412215f3c
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc5/rc5ofb64.c
@@ -0,0 +1,111 @@
1/* crypto/rc5/rc5ofb64.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <openssl/rc5.h>
60#include "rc5_locl.h"
61
62/* The input and output encrypted as though 64bit ofb mode is being
63 * used. The extra state information to record how much of the
64 * 64bit block we have used is contained in *num;
65 */
66void RC5_32_ofb64_encrypt(const unsigned char *in, unsigned char *out,
67 long length, RC5_32_KEY *schedule,
68 unsigned char *ivec, int *num)
69 {
70 register unsigned long v0,v1,t;
71 register int n= *num;
72 register long l=length;
73 unsigned char d[8];
74 register char *dp;
75 unsigned long ti[2];
76 unsigned char *iv;
77 int save=0;
78
79 iv=(unsigned char *)ivec;
80 c2l(iv,v0);
81 c2l(iv,v1);
82 ti[0]=v0;
83 ti[1]=v1;
84 dp=(char *)d;
85 l2c(v0,dp);
86 l2c(v1,dp);
87 while (l--)
88 {
89 if (n == 0)
90 {
91 RC5_32_encrypt((unsigned long *)ti,schedule);
92 dp=(char *)d;
93 t=ti[0]; l2c(t,dp);
94 t=ti[1]; l2c(t,dp);
95 save++;
96 }
97 *(out++)= *(in++)^d[n];
98 n=(n+1)&0x07;
99 }
100 if (save)
101 {
102 v0=ti[0];
103 v1=ti[1];
104 iv=(unsigned char *)ivec;
105 l2c(v0,iv);
106 l2c(v1,iv);
107 }
108 t=v0=v1=ti[0]=ti[1]=0;
109 *num=n;
110 }
111
diff --git a/src/lib/libssl/src/crypto/rc5/rc5speed.c b/src/lib/libssl/src/crypto/rc5/rc5speed.c
new file mode 100644
index 0000000000..8e363be535
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc5/rc5speed.c
@@ -0,0 +1,277 @@
1/* crypto/rc5/rc5speed.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
61
62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES
64#endif
65
66#include <stdio.h>
67
68#include <openssl/e_os2.h>
69#include OPENSSL_UNISTD_IO
70OPENSSL_DECLARE_EXIT
71
72#ifndef OPENSSL_SYS_NETWARE
73#include <signal.h>
74#endif
75
76#ifndef _IRIX
77#include <time.h>
78#endif
79#ifdef TIMES
80#include <sys/types.h>
81#include <sys/times.h>
82#endif
83
84/* Depending on the VMS version, the tms structure is perhaps defined.
85 The __TMS macro will show if it was. If it wasn't defined, we should
86 undefine TIMES, since that tells the rest of the program how things
87 should be handled. -- Richard Levitte */
88#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
89#undef TIMES
90#endif
91
92#ifndef TIMES
93#include <sys/timeb.h>
94#endif
95
96#if defined(sun) || defined(__ultrix)
97#define _POSIX_SOURCE
98#include <limits.h>
99#include <sys/param.h>
100#endif
101
102#include <openssl/rc5.h>
103
104/* The following if from times(3) man page. It may need to be changed */
105#ifndef HZ
106#ifndef CLK_TCK
107#define HZ 100.0
108#else /* CLK_TCK */
109#define HZ ((double)CLK_TCK)
110#endif
111#endif
112
113#define BUFSIZE ((long)1024)
114long run=0;
115
116double Time_F(int s);
117#ifdef SIGALRM
118#if defined(__STDC__) || defined(sgi) || defined(_AIX)
119#define SIGRETTYPE void
120#else
121#define SIGRETTYPE int
122#endif
123
124SIGRETTYPE sig_done(int sig);
125SIGRETTYPE sig_done(int sig)
126 {
127 signal(SIGALRM,sig_done);
128 run=0;
129#ifdef LINT
130 sig=sig;
131#endif
132 }
133#endif
134
135#define START 0
136#define STOP 1
137
138double Time_F(int s)
139 {
140 double ret;
141#ifdef TIMES
142 static struct tms tstart,tend;
143
144 if (s == START)
145 {
146 times(&tstart);
147 return(0);
148 }
149 else
150 {
151 times(&tend);
152 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
153 return((ret == 0.0)?1e-6:ret);
154 }
155#else /* !times() */
156 static struct timeb tstart,tend;
157 long i;
158
159 if (s == START)
160 {
161 ftime(&tstart);
162 return(0);
163 }
164 else
165 {
166 ftime(&tend);
167 i=(long)tend.millitm-(long)tstart.millitm;
168 ret=((double)(tend.time-tstart.time))+((double)i)/1e3;
169 return((ret == 0.0)?1e-6:ret);
170 }
171#endif
172 }
173
174int main(int argc, char **argv)
175 {
176 long count;
177 static unsigned char buf[BUFSIZE];
178 static unsigned char key[] ={
179 0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
180 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10,
181 };
182 RC5_32_KEY sch;
183 double a,b,c,d;
184#ifndef SIGALRM
185 long ca,cb,cc;
186#endif
187
188#ifndef TIMES
189 printf("To get the most accurate results, try to run this\n");
190 printf("program when this computer is idle.\n");
191#endif
192
193#ifndef SIGALRM
194 printf("First we calculate the approximate speed ...\n");
195 RC5_32_set_key(&sch,16,key,12);
196 count=10;
197 do {
198 long i;
199 unsigned long data[2];
200
201 count*=2;
202 Time_F(START);
203 for (i=count; i; i--)
204 RC5_32_encrypt(data,&sch);
205 d=Time_F(STOP);
206 } while (d < 3.0);
207 ca=count/512;
208 cb=count;
209 cc=count*8/BUFSIZE+1;
210 printf("Doing RC5_32_set_key %ld times\n",ca);
211#define COND(d) (count != (d))
212#define COUNT(d) (d)
213#else
214#define COND(c) (run)
215#define COUNT(d) (count)
216 signal(SIGALRM,sig_done);
217 printf("Doing RC5_32_set_key for 10 seconds\n");
218 alarm(10);
219#endif
220
221 Time_F(START);
222 for (count=0,run=1; COND(ca); count+=4)
223 {
224 RC5_32_set_key(&sch,16,key,12);
225 RC5_32_set_key(&sch,16,key,12);
226 RC5_32_set_key(&sch,16,key,12);
227 RC5_32_set_key(&sch,16,key,12);
228 }
229 d=Time_F(STOP);
230 printf("%ld RC5_32_set_key's in %.2f seconds\n",count,d);
231 a=((double)COUNT(ca))/d;
232
233#ifdef SIGALRM
234 printf("Doing RC5_32_encrypt's for 10 seconds\n");
235 alarm(10);
236#else
237 printf("Doing RC5_32_encrypt %ld times\n",cb);
238#endif
239 Time_F(START);
240 for (count=0,run=1; COND(cb); count+=4)
241 {
242 unsigned long data[2];
243
244 RC5_32_encrypt(data,&sch);
245 RC5_32_encrypt(data,&sch);
246 RC5_32_encrypt(data,&sch);
247 RC5_32_encrypt(data,&sch);
248 }
249 d=Time_F(STOP);
250 printf("%ld RC5_32_encrypt's in %.2f second\n",count,d);
251 b=((double)COUNT(cb)*8)/d;
252
253#ifdef SIGALRM
254 printf("Doing RC5_32_cbc_encrypt on %ld byte blocks for 10 seconds\n",
255 BUFSIZE);
256 alarm(10);
257#else
258 printf("Doing RC5_32_cbc_encrypt %ld times on %ld byte blocks\n",cc,
259 BUFSIZE);
260#endif
261 Time_F(START);
262 for (count=0,run=1; COND(cc); count++)
263 RC5_32_cbc_encrypt(buf,buf,BUFSIZE,&sch,
264 &(key[0]),RC5_ENCRYPT);
265 d=Time_F(STOP);
266 printf("%ld RC5_32_cbc_encrypt's of %ld byte blocks in %.2f second\n",
267 count,BUFSIZE,d);
268 c=((double)COUNT(cc)*BUFSIZE)/d;
269
270 printf("RC5_32/12/16 set_key per sec = %12.2f (%9.3fuS)\n",a,1.0e6/a);
271 printf("RC5_32/12/16 raw ecb bytes per sec = %12.2f (%9.3fuS)\n",b,8.0e6/b);
272 printf("RC5_32/12/16 cbc bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c);
273 exit(0);
274#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
275 return(0);
276#endif
277 }
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_ameth.c b/src/lib/libssl/src/crypto/rsa/rsa_ameth.c
index 2460910ab2..5a2062f903 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_ameth.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_ameth.c
@@ -351,27 +351,27 @@ static int rsa_pss_param_print(BIO *bp, RSA_PSS_PARAMS *pss,
351 351
352 if (!BIO_indent(bp, indent, 128)) 352 if (!BIO_indent(bp, indent, 128))
353 goto err; 353 goto err;
354 if (BIO_puts(bp, "Salt Length: ") <= 0) 354 if (BIO_puts(bp, "Salt Length: 0x") <= 0)
355 goto err; 355 goto err;
356 if (pss->saltLength) 356 if (pss->saltLength)
357 { 357 {
358 if (i2a_ASN1_INTEGER(bp, pss->saltLength) <= 0) 358 if (i2a_ASN1_INTEGER(bp, pss->saltLength) <= 0)
359 goto err; 359 goto err;
360 } 360 }
361 else if (BIO_puts(bp, "20 (default)") <= 0) 361 else if (BIO_puts(bp, "0x14 (default)") <= 0)
362 goto err; 362 goto err;
363 BIO_puts(bp, "\n"); 363 BIO_puts(bp, "\n");
364 364
365 if (!BIO_indent(bp, indent, 128)) 365 if (!BIO_indent(bp, indent, 128))
366 goto err; 366 goto err;
367 if (BIO_puts(bp, "Trailer Field: ") <= 0) 367 if (BIO_puts(bp, "Trailer Field: 0x") <= 0)
368 goto err; 368 goto err;
369 if (pss->trailerField) 369 if (pss->trailerField)
370 { 370 {
371 if (i2a_ASN1_INTEGER(bp, pss->trailerField) <= 0) 371 if (i2a_ASN1_INTEGER(bp, pss->trailerField) <= 0)
372 goto err; 372 goto err;
373 } 373 }
374 else if (BIO_puts(bp, "0xbc (default)") <= 0) 374 else if (BIO_puts(bp, "BC (default)") <= 0)
375 goto err; 375 goto err;
376 BIO_puts(bp, "\n"); 376 BIO_puts(bp, "\n");
377 377
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_pmeth.c b/src/lib/libssl/src/crypto/rsa/rsa_pmeth.c
index 5b2ecf56ad..157aa5c41d 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_pmeth.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_pmeth.c
@@ -611,6 +611,8 @@ static int pkey_rsa_ctrl_str(EVP_PKEY_CTX *ctx,
611 pm = RSA_NO_PADDING; 611 pm = RSA_NO_PADDING;
612 else if (!strcmp(value, "oeap")) 612 else if (!strcmp(value, "oeap"))
613 pm = RSA_PKCS1_OAEP_PADDING; 613 pm = RSA_PKCS1_OAEP_PADDING;
614 else if (!strcmp(value, "oaep"))
615 pm = RSA_PKCS1_OAEP_PADDING;
614 else if (!strcmp(value, "x931")) 616 else if (!strcmp(value, "x931"))
615 pm = RSA_X931_PADDING; 617 pm = RSA_X931_PADDING;
616 else if (!strcmp(value, "pss")) 618 else if (!strcmp(value, "pss"))
diff --git a/src/lib/libssl/src/crypto/sha/asm/sha1-armv4-large.pl b/src/lib/libssl/src/crypto/sha/asm/sha1-armv4-large.pl
index fe8207f77f..33da3e0e3c 100644
--- a/src/lib/libssl/src/crypto/sha/asm/sha1-armv4-large.pl
+++ b/src/lib/libssl/src/crypto/sha/asm/sha1-armv4-large.pl
@@ -177,6 +177,7 @@ for($i=0;$i<5;$i++) {
177$code.=<<___; 177$code.=<<___;
178 teq $Xi,sp 178 teq $Xi,sp
179 bne .L_00_15 @ [((11+4)*5+2)*3] 179 bne .L_00_15 @ [((11+4)*5+2)*3]
180 sub sp,sp,#25*4
180___ 181___
181 &BODY_00_15(@V); unshift(@V,pop(@V)); 182 &BODY_00_15(@V); unshift(@V,pop(@V));
182 &BODY_16_19(@V); unshift(@V,pop(@V)); 183 &BODY_16_19(@V); unshift(@V,pop(@V));
@@ -186,7 +187,6 @@ ___
186$code.=<<___; 187$code.=<<___;
187 188
188 ldr $K,.LK_20_39 @ [+15+16*4] 189 ldr $K,.LK_20_39 @ [+15+16*4]
189 sub sp,sp,#25*4
190 cmn sp,#0 @ [+3], clear carry to denote 20_39 190 cmn sp,#0 @ [+3], clear carry to denote 20_39
191.L_20_39_or_60_79: 191.L_20_39_or_60_79:
192___ 192___
diff --git a/src/lib/libssl/src/crypto/sha/asm/sha1-parisc.pl b/src/lib/libssl/src/crypto/sha/asm/sha1-parisc.pl
index 6d7bf495b2..6e5a328a6f 100644
--- a/src/lib/libssl/src/crypto/sha/asm/sha1-parisc.pl
+++ b/src/lib/libssl/src/crypto/sha/asm/sha1-parisc.pl
@@ -254,6 +254,7 @@ $code.=<<___;
254___ 254___
255 255
256$code =~ s/\`([^\`]*)\`/eval $1/gem; 256$code =~ s/\`([^\`]*)\`/eval $1/gem;
257$code =~ s/,\*/,/gm if ($SIZE_T==4); 257$code =~ s/,\*/,/gm if ($SIZE_T==4);
258$code =~ s/\bbv\b/bve/gm if ($SIZE_T==8);
258print $code; 259print $code;
259close STDOUT; 260close STDOUT;
diff --git a/src/lib/libssl/src/crypto/sha/asm/sha1-sparcv9a.pl b/src/lib/libssl/src/crypto/sha/asm/sha1-sparcv9a.pl
index 85e8d68086..e65291bbd9 100644
--- a/src/lib/libssl/src/crypto/sha/asm/sha1-sparcv9a.pl
+++ b/src/lib/libssl/src/crypto/sha/asm/sha1-sparcv9a.pl
@@ -549,7 +549,7 @@ ___
549# programmer detect if current CPU is VIS capable at run-time. 549# programmer detect if current CPU is VIS capable at run-time.
550sub unvis { 550sub unvis {
551my ($mnemonic,$rs1,$rs2,$rd)=@_; 551my ($mnemonic,$rs1,$rs2,$rd)=@_;
552my $ref,$opf; 552my ($ref,$opf);
553my %visopf = ( "fmul8ulx16" => 0x037, 553my %visopf = ( "fmul8ulx16" => 0x037,
554 "faligndata" => 0x048, 554 "faligndata" => 0x048,
555 "fpadd32" => 0x052, 555 "fpadd32" => 0x052,
diff --git a/src/lib/libssl/src/crypto/sha/asm/sha1-x86_64.pl b/src/lib/libssl/src/crypto/sha/asm/sha1-x86_64.pl
index f27c1e3fb0..f15c7ec39b 100755
--- a/src/lib/libssl/src/crypto/sha/asm/sha1-x86_64.pl
+++ b/src/lib/libssl/src/crypto/sha/asm/sha1-x86_64.pl
@@ -82,7 +82,8 @@ $avx=1 if (!$avx && $win64 && ($flavour =~ /masm/ || $ENV{ASM} =~ /ml64/) &&
82 `ml64 2>&1` =~ /Version ([0-9]+)\./ && 82 `ml64 2>&1` =~ /Version ([0-9]+)\./ &&
83 $1>=10); 83 $1>=10);
84 84
85open STDOUT,"| $^X $xlate $flavour $output"; 85open OUT,"| \"$^X\" $xlate $flavour $output";
86*STDOUT=*OUT;
86 87
87$ctx="%rdi"; # 1st arg 88$ctx="%rdi"; # 1st arg
88$inp="%rsi"; # 2nd arg 89$inp="%rsi"; # 2nd arg
@@ -744,7 +745,7 @@ $code.=<<___;
744 mov %rdi,$ctx # reassigned argument 745 mov %rdi,$ctx # reassigned argument
745 mov %rsi,$inp # reassigned argument 746 mov %rsi,$inp # reassigned argument
746 mov %rdx,$num # reassigned argument 747 mov %rdx,$num # reassigned argument
747 vzeroall 748 vzeroupper
748 749
749 shl \$6,$num 750 shl \$6,$num
750 add $inp,$num 751 add $inp,$num
@@ -1037,7 +1038,7 @@ ___
1037 &Xtail_avx(\&body_20_39); 1038 &Xtail_avx(\&body_20_39);
1038 1039
1039$code.=<<___; 1040$code.=<<___;
1040 vzeroall 1041 vzeroupper
1041 1042
1042 add 0($ctx),$A # update context 1043 add 0($ctx),$A # update context
1043 add 4($ctx),@T[0] 1044 add 4($ctx),@T[0]
diff --git a/src/lib/libssl/src/crypto/sha/asm/sha512-586.pl b/src/lib/libssl/src/crypto/sha/asm/sha512-586.pl
index 5b9f3337ad..7eab6a5b88 100644
--- a/src/lib/libssl/src/crypto/sha/asm/sha512-586.pl
+++ b/src/lib/libssl/src/crypto/sha/asm/sha512-586.pl
@@ -142,9 +142,9 @@ sub BODY_00_15_x86 {
142 &mov ("edx",$Ehi); 142 &mov ("edx",$Ehi);
143 &mov ("esi","ecx"); 143 &mov ("esi","ecx");
144 144
145 &shr ("ecx",9) # lo>>9 145 &shr ("ecx",9); # lo>>9
146 &mov ("edi","edx"); 146 &mov ("edi","edx");
147 &shr ("edx",9) # hi>>9 147 &shr ("edx",9); # hi>>9
148 &mov ("ebx","ecx"); 148 &mov ("ebx","ecx");
149 &shl ("esi",14); # lo<<14 149 &shl ("esi",14); # lo<<14
150 &mov ("eax","edx"); 150 &mov ("eax","edx");
@@ -207,9 +207,9 @@ sub BODY_00_15_x86 {
207 &mov ($Dhi,"ebx"); 207 &mov ($Dhi,"ebx");
208 &mov ("esi","ecx"); 208 &mov ("esi","ecx");
209 209
210 &shr ("ecx",2) # lo>>2 210 &shr ("ecx",2); # lo>>2
211 &mov ("edi","edx"); 211 &mov ("edi","edx");
212 &shr ("edx",2) # hi>>2 212 &shr ("edx",2); # hi>>2
213 &mov ("ebx","ecx"); 213 &mov ("ebx","ecx");
214 &shl ("esi",4); # lo<<4 214 &shl ("esi",4); # lo<<4
215 &mov ("eax","edx"); 215 &mov ("eax","edx");
@@ -452,9 +452,9 @@ if ($sse2) {
452 &mov ("edx",&DWP(8*(9+15+16-1)+4,"esp")); 452 &mov ("edx",&DWP(8*(9+15+16-1)+4,"esp"));
453 &mov ("esi","ecx"); 453 &mov ("esi","ecx");
454 454
455 &shr ("ecx",1) # lo>>1 455 &shr ("ecx",1); # lo>>1
456 &mov ("edi","edx"); 456 &mov ("edi","edx");
457 &shr ("edx",1) # hi>>1 457 &shr ("edx",1); # hi>>1
458 &mov ("eax","ecx"); 458 &mov ("eax","ecx");
459 &shl ("esi",24); # lo<<24 459 &shl ("esi",24); # lo<<24
460 &mov ("ebx","edx"); 460 &mov ("ebx","edx");
@@ -488,9 +488,9 @@ if ($sse2) {
488 &mov ("edx",&DWP(8*(9+15+16-14)+4,"esp")); 488 &mov ("edx",&DWP(8*(9+15+16-14)+4,"esp"));
489 &mov ("esi","ecx"); 489 &mov ("esi","ecx");
490 490
491 &shr ("ecx",6) # lo>>6 491 &shr ("ecx",6); # lo>>6
492 &mov ("edi","edx"); 492 &mov ("edi","edx");
493 &shr ("edx",6) # hi>>6 493 &shr ("edx",6); # hi>>6
494 &mov ("eax","ecx"); 494 &mov ("eax","ecx");
495 &shl ("esi",3); # lo<<3 495 &shl ("esi",3); # lo<<3
496 &mov ("ebx","edx"); 496 &mov ("ebx","edx");
diff --git a/src/lib/libssl/src/crypto/sha/asm/sha512-mips.pl b/src/lib/libssl/src/crypto/sha/asm/sha512-mips.pl
index ba5b250890..ffa053bb7d 100644
--- a/src/lib/libssl/src/crypto/sha/asm/sha512-mips.pl
+++ b/src/lib/libssl/src/crypto/sha/asm/sha512-mips.pl
@@ -351,7 +351,7 @@ $code.=<<___;
351 $ST $G,6*$SZ($ctx) 351 $ST $G,6*$SZ($ctx)
352 $ST $H,7*$SZ($ctx) 352 $ST $H,7*$SZ($ctx)
353 353
354 bnel $inp,@X[15],.Loop 354 bne $inp,@X[15],.Loop
355 $PTR_SUB $Ktbl,`($rounds-16)*$SZ` # rewind $Ktbl 355 $PTR_SUB $Ktbl,`($rounds-16)*$SZ` # rewind $Ktbl
356 356
357 $REG_L $ra,$FRAMESIZE-1*$SZREG($sp) 357 $REG_L $ra,$FRAMESIZE-1*$SZREG($sp)
diff --git a/src/lib/libssl/src/crypto/sha/asm/sha512-parisc.pl b/src/lib/libssl/src/crypto/sha/asm/sha512-parisc.pl
index e24ee58ae9..fc0e15b3c0 100755
--- a/src/lib/libssl/src/crypto/sha/asm/sha512-parisc.pl
+++ b/src/lib/libssl/src/crypto/sha/asm/sha512-parisc.pl
@@ -785,6 +785,8 @@ foreach (split("\n",$code)) {
785 785
786 s/cmpb,\*/comb,/ if ($SIZE_T==4); 786 s/cmpb,\*/comb,/ if ($SIZE_T==4);
787 787
788 s/\bbv\b/bve/ if ($SIZE_T==8);
789
788 print $_,"\n"; 790 print $_,"\n";
789} 791}
790 792
diff --git a/src/lib/libssl/src/crypto/sha/asm/sha512-x86_64.pl b/src/lib/libssl/src/crypto/sha/asm/sha512-x86_64.pl
index f611a2d898..8d51678557 100755
--- a/src/lib/libssl/src/crypto/sha/asm/sha512-x86_64.pl
+++ b/src/lib/libssl/src/crypto/sha/asm/sha512-x86_64.pl
@@ -51,7 +51,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
51( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or 51( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
52die "can't locate x86_64-xlate.pl"; 52die "can't locate x86_64-xlate.pl";
53 53
54open STDOUT,"| $^X $xlate $flavour $output"; 54open OUT,"| \"$^X\" $xlate $flavour $output";
55*STDOUT=*OUT;
55 56
56if ($output =~ /512/) { 57if ($output =~ /512/) {
57 $func="sha512_block_data_order"; 58 $func="sha512_block_data_order";
diff --git a/src/lib/libssl/src/crypto/sha/sha256.c b/src/lib/libssl/src/crypto/sha/sha256.c
index f88d3d6dad..4eae074849 100644
--- a/src/lib/libssl/src/crypto/sha/sha256.c
+++ b/src/lib/libssl/src/crypto/sha/sha256.c
@@ -88,17 +88,17 @@ int SHA224_Final (unsigned char *md, SHA256_CTX *c)
88 switch ((c)->md_len) \ 88 switch ((c)->md_len) \
89 { case SHA224_DIGEST_LENGTH: \ 89 { case SHA224_DIGEST_LENGTH: \
90 for (nn=0;nn<SHA224_DIGEST_LENGTH/4;nn++) \ 90 for (nn=0;nn<SHA224_DIGEST_LENGTH/4;nn++) \
91 { ll=(c)->h[nn]; HOST_l2c(ll,(s)); } \ 91 { ll=(c)->h[nn]; (void)HOST_l2c(ll,(s)); } \
92 break; \ 92 break; \
93 case SHA256_DIGEST_LENGTH: \ 93 case SHA256_DIGEST_LENGTH: \
94 for (nn=0;nn<SHA256_DIGEST_LENGTH/4;nn++) \ 94 for (nn=0;nn<SHA256_DIGEST_LENGTH/4;nn++) \
95 { ll=(c)->h[nn]; HOST_l2c(ll,(s)); } \ 95 { ll=(c)->h[nn]; (void)HOST_l2c(ll,(s)); } \
96 break; \ 96 break; \
97 default: \ 97 default: \
98 if ((c)->md_len > SHA256_DIGEST_LENGTH) \ 98 if ((c)->md_len > SHA256_DIGEST_LENGTH) \
99 return 0; \ 99 return 0; \
100 for (nn=0;nn<(c)->md_len/4;nn++) \ 100 for (nn=0;nn<(c)->md_len/4;nn++) \
101 { ll=(c)->h[nn]; HOST_l2c(ll,(s)); } \ 101 { ll=(c)->h[nn]; (void)HOST_l2c(ll,(s)); } \
102 break; \ 102 break; \
103 } \ 103 } \
104 } while (0) 104 } while (0)
diff --git a/src/lib/libssl/src/crypto/sha/sha512.c b/src/lib/libssl/src/crypto/sha/sha512.c
index 50dd7dc744..50c229ddeb 100644
--- a/src/lib/libssl/src/crypto/sha/sha512.c
+++ b/src/lib/libssl/src/crypto/sha/sha512.c
@@ -232,7 +232,14 @@ int SHA384_Update (SHA512_CTX *c, const void *data, size_t len)
232{ return SHA512_Update (c,data,len); } 232{ return SHA512_Update (c,data,len); }
233 233
234void SHA512_Transform (SHA512_CTX *c, const unsigned char *data) 234void SHA512_Transform (SHA512_CTX *c, const unsigned char *data)
235{ sha512_block_data_order (c,data,1); } 235 {
236#ifndef SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA
237 if ((size_t)data%sizeof(c->u.d[0]) != 0)
238 memcpy(c->u.p,data,sizeof(c->u.p)),
239 data = c->u.p;
240#endif
241 sha512_block_data_order (c,data,1);
242 }
236 243
237unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md) 244unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md)
238 { 245 {
diff --git a/src/lib/libssl/src/crypto/sparccpuid.S b/src/lib/libssl/src/crypto/sparccpuid.S
index ae61f7f5ce..0cc247e489 100644
--- a/src/lib/libssl/src/crypto/sparccpuid.S
+++ b/src/lib/libssl/src/crypto/sparccpuid.S
@@ -235,10 +235,10 @@ _sparcv9_rdtick:
235.global _sparcv9_vis1_probe 235.global _sparcv9_vis1_probe
236.align 8 236.align 8
237_sparcv9_vis1_probe: 237_sparcv9_vis1_probe:
238 .word 0x81b00d80 !fxor %f0,%f0,%f0
239 add %sp,BIAS+2,%o1 238 add %sp,BIAS+2,%o1
240 retl
241 .word 0xc19a5a40 !ldda [%o1]ASI_FP16_P,%f0 239 .word 0xc19a5a40 !ldda [%o1]ASI_FP16_P,%f0
240 retl
241 .word 0x81b00d80 !fxor %f0,%f0,%f0
242.type _sparcv9_vis1_probe,#function 242.type _sparcv9_vis1_probe,#function
243.size _sparcv9_vis1_probe,.-_sparcv9_vis1_probe 243.size _sparcv9_vis1_probe,.-_sparcv9_vis1_probe
244 244
diff --git a/src/lib/libssl/src/crypto/srp/srp_grps.h b/src/lib/libssl/src/crypto/srp/srp_grps.h
index d77c9fff4b..8e3c35e3f5 100644
--- a/src/lib/libssl/src/crypto/srp/srp_grps.h
+++ b/src/lib/libssl/src/crypto/srp/srp_grps.h
@@ -1,22 +1,22 @@
1/* start of generated data */ 1/* start of generated data */
2 2
3static BN_ULONG bn_group_1024_value[] = { 3static BN_ULONG bn_group_1024_value[] = {
4 bn_pack4(9FC6,1D2F,C0EB,06E3), 4 bn_pack4(0x9FC6,0x1D2F,0xC0EB,0x06E3),
5 bn_pack4(FD51,38FE,8376,435B), 5 bn_pack4(0xFD51,0x38FE,0x8376,0x435B),
6 bn_pack4(2FD4,CBF4,976E,AA9A), 6 bn_pack4(0x2FD4,0xCBF4,0x976E,0xAA9A),
7 bn_pack4(68ED,BC3C,0572,6CC0), 7 bn_pack4(0x68ED,0xBC3C,0x0572,0x6CC0),
8 bn_pack4(C529,F566,660E,57EC), 8 bn_pack4(0xC529,0xF566,0x660E,0x57EC),
9 bn_pack4(8255,9B29,7BCF,1885), 9 bn_pack4(0x8255,0x9B29,0x7BCF,0x1885),
10 bn_pack4(CE8E,F4AD,69B1,5D49), 10 bn_pack4(0xCE8E,0xF4AD,0x69B1,0x5D49),
11 bn_pack4(5DC7,D7B4,6154,D6B6), 11 bn_pack4(0x5DC7,0xD7B4,0x6154,0xD6B6),
12 bn_pack4(8E49,5C1D,6089,DAD1), 12 bn_pack4(0x8E49,0x5C1D,0x6089,0xDAD1),
13 bn_pack4(E0D5,D8E2,50B9,8BE4), 13 bn_pack4(0xE0D5,0xD8E2,0x50B9,0x8BE4),
14 bn_pack4(383B,4813,D692,C6E0), 14 bn_pack4(0x383B,0x4813,0xD692,0xC6E0),
15 bn_pack4(D674,DF74,96EA,81D3), 15 bn_pack4(0xD674,0xDF74,0x96EA,0x81D3),
16 bn_pack4(9EA2,314C,9C25,6576), 16 bn_pack4(0x9EA2,0x314C,0x9C25,0x6576),
17 bn_pack4(6072,6187,75FF,3C0B), 17 bn_pack4(0x6072,0x6187,0x75FF,0x3C0B),
18 bn_pack4(9C33,F80A,FA8F,C5E8), 18 bn_pack4(0x9C33,0xF80A,0xFA8F,0xC5E8),
19 bn_pack4(EEAF,0AB9,ADB3,8DD6) 19 bn_pack4(0xEEAF,0x0AB9,0xADB3,0x8DD6)
20}; 20};
21static BIGNUM bn_group_1024 = { 21static BIGNUM bn_group_1024 = {
22 bn_group_1024_value, 22 bn_group_1024_value,
@@ -27,30 +27,30 @@ static BIGNUM bn_group_1024 = {
27}; 27};
28 28
29static BN_ULONG bn_group_1536_value[] = { 29static BN_ULONG bn_group_1536_value[] = {
30 bn_pack4(CF76,E3FE,D135,F9BB), 30 bn_pack4(0xCF76,0xE3FE,0xD135,0xF9BB),
31 bn_pack4(1518,0F93,499A,234D), 31 bn_pack4(0x1518,0x0F93,0x499A,0x234D),
32 bn_pack4(8CE7,A28C,2442,C6F3), 32 bn_pack4(0x8CE7,0xA28C,0x2442,0xC6F3),
33 bn_pack4(5A02,1FFF,5E91,479E), 33 bn_pack4(0x5A02,0x1FFF,0x5E91,0x479E),
34 bn_pack4(7F8A,2FE9,B8B5,292E), 34 bn_pack4(0x7F8A,0x2FE9,0xB8B5,0x292E),
35 bn_pack4(837C,264A,E3A9,BEB8), 35 bn_pack4(0x837C,0x264A,0xE3A9,0xBEB8),
36 bn_pack4(E442,734A,F7CC,B7AE), 36 bn_pack4(0xE442,0x734A,0xF7CC,0xB7AE),
37 bn_pack4(6577,2E43,7D6C,7F8C), 37 bn_pack4(0x6577,0x2E43,0x7D6C,0x7F8C),
38 bn_pack4(DB2F,D53D,24B7,C486), 38 bn_pack4(0xDB2F,0xD53D,0x24B7,0xC486),
39 bn_pack4(6EDF,0195,3934,9627), 39 bn_pack4(0x6EDF,0x0195,0x3934,0x9627),
40 bn_pack4(158B,FD3E,2B9C,8CF5), 40 bn_pack4(0x158B,0xFD3E,0x2B9C,0x8CF5),
41 bn_pack4(764E,3F4B,53DD,9DA1), 41 bn_pack4(0x764E,0x3F4B,0x53DD,0x9DA1),
42 bn_pack4(4754,8381,DBC5,B1FC), 42 bn_pack4(0x4754,0x8381,0xDBC5,0xB1FC),
43 bn_pack4(9B60,9E0B,E3BA,B63D), 43 bn_pack4(0x9B60,0x9E0B,0xE3BA,0xB63D),
44 bn_pack4(8134,B1C8,B979,8914), 44 bn_pack4(0x8134,0xB1C8,0xB979,0x8914),
45 bn_pack4(DF02,8A7C,EC67,F0D0), 45 bn_pack4(0xDF02,0x8A7C,0xEC67,0xF0D0),
46 bn_pack4(80B6,55BB,9A22,E8DC), 46 bn_pack4(0x80B6,0x55BB,0x9A22,0xE8DC),
47 bn_pack4(1558,903B,A0D0,F843), 47 bn_pack4(0x1558,0x903B,0xA0D0,0xF843),
48 bn_pack4(51C6,A94B,E460,7A29), 48 bn_pack4(0x51C6,0xA94B,0xE460,0x7A29),
49 bn_pack4(5F4F,5F55,6E27,CBDE), 49 bn_pack4(0x5F4F,0x5F55,0x6E27,0xCBDE),
50 bn_pack4(BEEE,A961,4B19,CC4D), 50 bn_pack4(0xBEEE,0xA961,0x4B19,0xCC4D),
51 bn_pack4(DBA5,1DF4,99AC,4C80), 51 bn_pack4(0xDBA5,0x1DF4,0x99AC,0x4C80),
52 bn_pack4(B1F1,2A86,17A4,7BBB), 52 bn_pack4(0xB1F1,0x2A86,0x17A4,0x7BBB),
53 bn_pack4(9DEF,3CAF,B939,277A) 53 bn_pack4(0x9DEF,0x3CAF,0xB939,0x277A)
54}; 54};
55static BIGNUM bn_group_1536 = { 55static BIGNUM bn_group_1536 = {
56 bn_group_1536_value, 56 bn_group_1536_value,
@@ -61,38 +61,38 @@ static BIGNUM bn_group_1536 = {
61}; 61};
62 62
63static BN_ULONG bn_group_2048_value[] = { 63static BN_ULONG bn_group_2048_value[] = {
64 bn_pack4(0FA7,111F,9E4A,FF73), 64 bn_pack4(0x0FA7,0x111F,0x9E4A,0xFF73),
65 bn_pack4(9B65,E372,FCD6,8EF2), 65 bn_pack4(0x9B65,0xE372,0xFCD6,0x8EF2),
66 bn_pack4(35DE,236D,525F,5475), 66 bn_pack4(0x35DE,0x236D,0x525F,0x5475),
67 bn_pack4(94B5,C803,D89F,7AE4), 67 bn_pack4(0x94B5,0xC803,0xD89F,0x7AE4),
68 bn_pack4(71AE,35F8,E9DB,FBB6), 68 bn_pack4(0x71AE,0x35F8,0xE9DB,0xFBB6),
69 bn_pack4(2A56,98F3,A8D0,C382), 69 bn_pack4(0x2A56,0x98F3,0xA8D0,0xC382),
70 bn_pack4(9CCC,041C,7BC3,08D8), 70 bn_pack4(0x9CCC,0x041C,0x7BC3,0x08D8),
71 bn_pack4(AF87,4E73,03CE,5329), 71 bn_pack4(0xAF87,0x4E73,0x03CE,0x5329),
72 bn_pack4(6160,2790,04E5,7AE6), 72 bn_pack4(0x6160,0x2790,0x04E5,0x7AE6),
73 bn_pack4(032C,FBDB,F52F,B378), 73 bn_pack4(0x032C,0xFBDB,0xF52F,0xB378),
74 bn_pack4(5EA7,7A27,75D2,ECFA), 74 bn_pack4(0x5EA7,0x7A27,0x75D2,0xECFA),
75 bn_pack4(5445,23B5,24B0,D57D), 75 bn_pack4(0x5445,0x23B5,0x24B0,0xD57D),
76 bn_pack4(5B9D,32E6,88F8,7748), 76 bn_pack4(0x5B9D,0x32E6,0x88F8,0x7748),
77 bn_pack4(F1D2,B907,8717,461A), 77 bn_pack4(0xF1D2,0xB907,0x8717,0x461A),
78 bn_pack4(76BD,207A,436C,6481), 78 bn_pack4(0x76BD,0x207A,0x436C,0x6481),
79 bn_pack4(CA97,B43A,23FB,8016), 79 bn_pack4(0xCA97,0xB43A,0x23FB,0x8016),
80 bn_pack4(1D28,1E44,6B14,773B), 80 bn_pack4(0x1D28,0x1E44,0x6B14,0x773B),
81 bn_pack4(7359,D041,D5C3,3EA7), 81 bn_pack4(0x7359,0xD041,0xD5C3,0x3EA7),
82 bn_pack4(A80D,740A,DBF4,FF74), 82 bn_pack4(0xA80D,0x740A,0xDBF4,0xFF74),
83 bn_pack4(55F9,7993,EC97,5EEA), 83 bn_pack4(0x55F9,0x7993,0xEC97,0x5EEA),
84 bn_pack4(2918,A996,2F0B,93B8), 84 bn_pack4(0x2918,0xA996,0x2F0B,0x93B8),
85 bn_pack4(661A,05FB,D5FA,AAE8), 85 bn_pack4(0x661A,0x05FB,0xD5FA,0xAAE8),
86 bn_pack4(CF60,9517,9A16,3AB3), 86 bn_pack4(0xCF60,0x9517,0x9A16,0x3AB3),
87 bn_pack4(E808,3969,EDB7,67B0), 87 bn_pack4(0xE808,0x3969,0xEDB7,0x67B0),
88 bn_pack4(CD7F,48A9,DA04,FD50), 88 bn_pack4(0xCD7F,0x48A9,0xDA04,0xFD50),
89 bn_pack4(D523,12AB,4B03,310D), 89 bn_pack4(0xD523,0x12AB,0x4B03,0x310D),
90 bn_pack4(8193,E075,7767,A13D), 90 bn_pack4(0x8193,0xE075,0x7767,0xA13D),
91 bn_pack4(A373,29CB,B4A0,99ED), 91 bn_pack4(0xA373,0x29CB,0xB4A0,0x99ED),
92 bn_pack4(FC31,9294,3DB5,6050), 92 bn_pack4(0xFC31,0x9294,0x3DB5,0x6050),
93 bn_pack4(AF72,B665,1987,EE07), 93 bn_pack4(0xAF72,0xB665,0x1987,0xEE07),
94 bn_pack4(F166,DE5E,1389,582F), 94 bn_pack4(0xF166,0xDE5E,0x1389,0x582F),
95 bn_pack4(AC6B,DB41,324A,9A9B) 95 bn_pack4(0xAC6B,0xDB41,0x324A,0x9A9B)
96}; 96};
97static BIGNUM bn_group_2048 = { 97static BIGNUM bn_group_2048 = {
98 bn_group_2048_value, 98 bn_group_2048_value,
@@ -103,54 +103,54 @@ static BIGNUM bn_group_2048 = {
103}; 103};
104 104
105static BN_ULONG bn_group_3072_value[] = { 105static BN_ULONG bn_group_3072_value[] = {
106 bn_pack4(FFFF,FFFF,FFFF,FFFF), 106 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF),
107 bn_pack4(4B82,D120,A93A,D2CA), 107 bn_pack4(0x4B82,0xD120,0xA93A,0xD2CA),
108 bn_pack4(43DB,5BFC,E0FD,108E), 108 bn_pack4(0x43DB,0x5BFC,0xE0FD,0x108E),
109 bn_pack4(08E2,4FA0,74E5,AB31), 109 bn_pack4(0x08E2,0x4FA0,0x74E5,0xAB31),
110 bn_pack4(7709,88C0,BAD9,46E2), 110 bn_pack4(0x7709,0x88C0,0xBAD9,0x46E2),
111 bn_pack4(BBE1,1757,7A61,5D6C), 111 bn_pack4(0xBBE1,0x1757,0x7A61,0x5D6C),
112 bn_pack4(521F,2B18,177B,200C), 112 bn_pack4(0x521F,0x2B18,0x177B,0x200C),
113 bn_pack4(D876,0273,3EC8,6A64), 113 bn_pack4(0xD876,0x0273,0x3EC8,0x6A64),
114 bn_pack4(F12F,FA06,D98A,0864), 114 bn_pack4(0xF12F,0xFA06,0xD98A,0x0864),
115 bn_pack4(CEE3,D226,1AD2,EE6B), 115 bn_pack4(0xCEE3,0xD226,0x1AD2,0xEE6B),
116 bn_pack4(1E8C,94E0,4A25,619D), 116 bn_pack4(0x1E8C,0x94E0,0x4A25,0x619D),
117 bn_pack4(ABF5,AE8C,DB09,33D7), 117 bn_pack4(0xABF5,0xAE8C,0xDB09,0x33D7),
118 bn_pack4(B397,0F85,A6E1,E4C7), 118 bn_pack4(0xB397,0x0F85,0xA6E1,0xE4C7),
119 bn_pack4(8AEA,7157,5D06,0C7D), 119 bn_pack4(0x8AEA,0x7157,0x5D06,0x0C7D),
120 bn_pack4(ECFB,8504,58DB,EF0A), 120 bn_pack4(0xECFB,0x8504,0x58DB,0xEF0A),
121 bn_pack4(A855,21AB,DF1C,BA64), 121 bn_pack4(0xA855,0x21AB,0xDF1C,0xBA64),
122 bn_pack4(AD33,170D,0450,7A33), 122 bn_pack4(0xAD33,0x170D,0x0450,0x7A33),
123 bn_pack4(1572,8E5A,8AAA,C42D), 123 bn_pack4(0x1572,0x8E5A,0x8AAA,0xC42D),
124 bn_pack4(15D2,2618,98FA,0510), 124 bn_pack4(0x15D2,0x2618,0x98FA,0x0510),
125 bn_pack4(3995,497C,EA95,6AE5), 125 bn_pack4(0x3995,0x497C,0xEA95,0x6AE5),
126 bn_pack4(DE2B,CBF6,9558,1718), 126 bn_pack4(0xDE2B,0xCBF6,0x9558,0x1718),
127 bn_pack4(B5C5,5DF0,6F4C,52C9), 127 bn_pack4(0xB5C5,0x5DF0,0x6F4C,0x52C9),
128 bn_pack4(9B27,83A2,EC07,A28F), 128 bn_pack4(0x9B27,0x83A2,0xEC07,0xA28F),
129 bn_pack4(E39E,772C,180E,8603), 129 bn_pack4(0xE39E,0x772C,0x180E,0x8603),
130 bn_pack4(3290,5E46,2E36,CE3B), 130 bn_pack4(0x3290,0x5E46,0x2E36,0xCE3B),
131 bn_pack4(F174,6C08,CA18,217C), 131 bn_pack4(0xF174,0x6C08,0xCA18,0x217C),
132 bn_pack4(670C,354E,4ABC,9804), 132 bn_pack4(0x670C,0x354E,0x4ABC,0x9804),
133 bn_pack4(9ED5,2907,7096,966D), 133 bn_pack4(0x9ED5,0x2907,0x7096,0x966D),
134 bn_pack4(1C62,F356,2085,52BB), 134 bn_pack4(0x1C62,0xF356,0x2085,0x52BB),
135 bn_pack4(8365,5D23,DCA3,AD96), 135 bn_pack4(0x8365,0x5D23,0xDCA3,0xAD96),
136 bn_pack4(6916,3FA8,FD24,CF5F), 136 bn_pack4(0x6916,0x3FA8,0xFD24,0xCF5F),
137 bn_pack4(98DA,4836,1C55,D39A), 137 bn_pack4(0x98DA,0x4836,0x1C55,0xD39A),
138 bn_pack4(C200,7CB8,A163,BF05), 138 bn_pack4(0xC200,0x7CB8,0xA163,0xBF05),
139 bn_pack4(4928,6651,ECE4,5B3D), 139 bn_pack4(0x4928,0x6651,0xECE4,0x5B3D),
140 bn_pack4(AE9F,2411,7C4B,1FE6), 140 bn_pack4(0xAE9F,0x2411,0x7C4B,0x1FE6),
141 bn_pack4(EE38,6BFB,5A89,9FA5), 141 bn_pack4(0xEE38,0x6BFB,0x5A89,0x9FA5),
142 bn_pack4(0BFF,5CB6,F406,B7ED), 142 bn_pack4(0x0BFF,0x5CB6,0xF406,0xB7ED),
143 bn_pack4(F44C,42E9,A637,ED6B), 143 bn_pack4(0xF44C,0x42E9,0xA637,0xED6B),
144 bn_pack4(E485,B576,625E,7EC6), 144 bn_pack4(0xE485,0xB576,0x625E,0x7EC6),
145 bn_pack4(4FE1,356D,6D51,C245), 145 bn_pack4(0x4FE1,0x356D,0x6D51,0xC245),
146 bn_pack4(302B,0A6D,F25F,1437), 146 bn_pack4(0x302B,0x0A6D,0xF25F,0x1437),
147 bn_pack4(EF95,19B3,CD3A,431B), 147 bn_pack4(0xEF95,0x19B3,0xCD3A,0x431B),
148 bn_pack4(514A,0879,8E34,04DD), 148 bn_pack4(0x514A,0x0879,0x8E34,0x04DD),
149 bn_pack4(020B,BEA6,3B13,9B22), 149 bn_pack4(0x020B,0xBEA6,0x3B13,0x9B22),
150 bn_pack4(2902,4E08,8A67,CC74), 150 bn_pack4(0x2902,0x4E08,0x8A67,0xCC74),
151 bn_pack4(C4C6,628B,80DC,1CD1), 151 bn_pack4(0xC4C6,0x628B,0x80DC,0x1CD1),
152 bn_pack4(C90F,DAA2,2168,C234), 152 bn_pack4(0xC90F,0xDAA2,0x2168,0xC234),
153 bn_pack4(FFFF,FFFF,FFFF,FFFF) 153 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF)
154}; 154};
155static BIGNUM bn_group_3072 = { 155static BIGNUM bn_group_3072 = {
156 bn_group_3072_value, 156 bn_group_3072_value,
@@ -161,70 +161,70 @@ static BIGNUM bn_group_3072 = {
161}; 161};
162 162
163static BN_ULONG bn_group_4096_value[] = { 163static BN_ULONG bn_group_4096_value[] = {
164 bn_pack4(FFFF,FFFF,FFFF,FFFF), 164 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF),
165 bn_pack4(4DF4,35C9,3406,3199), 165 bn_pack4(0x4DF4,0x35C9,0x3406,0x3199),
166 bn_pack4(86FF,B7DC,90A6,C08F), 166 bn_pack4(0x86FF,0xB7DC,0x90A6,0xC08F),
167 bn_pack4(93B4,EA98,8D8F,DDC1), 167 bn_pack4(0x93B4,0xEA98,0x8D8F,0xDDC1),
168 bn_pack4(D006,9127,D5B0,5AA9), 168 bn_pack4(0xD006,0x9127,0xD5B0,0x5AA9),
169 bn_pack4(B81B,DD76,2170,481C), 169 bn_pack4(0xB81B,0xDD76,0x2170,0x481C),
170 bn_pack4(1F61,2970,CEE2,D7AF), 170 bn_pack4(0x1F61,0x2970,0xCEE2,0xD7AF),
171 bn_pack4(233B,A186,515B,E7ED), 171 bn_pack4(0x233B,0xA186,0x515B,0xE7ED),
172 bn_pack4(99B2,964F,A090,C3A2), 172 bn_pack4(0x99B2,0x964F,0xA090,0xC3A2),
173 bn_pack4(287C,5947,4E6B,C05D), 173 bn_pack4(0x287C,0x5947,0x4E6B,0xC05D),
174 bn_pack4(2E8E,FC14,1FBE,CAA6), 174 bn_pack4(0x2E8E,0xFC14,0x1FBE,0xCAA6),
175 bn_pack4(DBBB,C2DB,04DE,8EF9), 175 bn_pack4(0xDBBB,0xC2DB,0x04DE,0x8EF9),
176 bn_pack4(2583,E9CA,2AD4,4CE8), 176 bn_pack4(0x2583,0xE9CA,0x2AD4,0x4CE8),
177 bn_pack4(1A94,6834,B615,0BDA), 177 bn_pack4(0x1A94,0x6834,0xB615,0x0BDA),
178 bn_pack4(99C3,2718,6AF4,E23C), 178 bn_pack4(0x99C3,0x2718,0x6AF4,0xE23C),
179 bn_pack4(8871,9A10,BDBA,5B26), 179 bn_pack4(0x8871,0x9A10,0xBDBA,0x5B26),
180 bn_pack4(1A72,3C12,A787,E6D7), 180 bn_pack4(0x1A72,0x3C12,0xA787,0xE6D7),
181 bn_pack4(4B82,D120,A921,0801), 181 bn_pack4(0x4B82,0xD120,0xA921,0x0801),
182 bn_pack4(43DB,5BFC,E0FD,108E), 182 bn_pack4(0x43DB,0x5BFC,0xE0FD,0x108E),
183 bn_pack4(08E2,4FA0,74E5,AB31), 183 bn_pack4(0x08E2,0x4FA0,0x74E5,0xAB31),
184 bn_pack4(7709,88C0,BAD9,46E2), 184 bn_pack4(0x7709,0x88C0,0xBAD9,0x46E2),
185 bn_pack4(BBE1,1757,7A61,5D6C), 185 bn_pack4(0xBBE1,0x1757,0x7A61,0x5D6C),
186 bn_pack4(521F,2B18,177B,200C), 186 bn_pack4(0x521F,0x2B18,0x177B,0x200C),
187 bn_pack4(D876,0273,3EC8,6A64), 187 bn_pack4(0xD876,0x0273,0x3EC8,0x6A64),
188 bn_pack4(F12F,FA06,D98A,0864), 188 bn_pack4(0xF12F,0xFA06,0xD98A,0x0864),
189 bn_pack4(CEE3,D226,1AD2,EE6B), 189 bn_pack4(0xCEE3,0xD226,0x1AD2,0xEE6B),
190 bn_pack4(1E8C,94E0,4A25,619D), 190 bn_pack4(0x1E8C,0x94E0,0x4A25,0x619D),
191 bn_pack4(ABF5,AE8C,DB09,33D7), 191 bn_pack4(0xABF5,0xAE8C,0xDB09,0x33D7),
192 bn_pack4(B397,0F85,A6E1,E4C7), 192 bn_pack4(0xB397,0x0F85,0xA6E1,0xE4C7),
193 bn_pack4(8AEA,7157,5D06,0C7D), 193 bn_pack4(0x8AEA,0x7157,0x5D06,0x0C7D),
194 bn_pack4(ECFB,8504,58DB,EF0A), 194 bn_pack4(0xECFB,0x8504,0x58DB,0xEF0A),
195 bn_pack4(A855,21AB,DF1C,BA64), 195 bn_pack4(0xA855,0x21AB,0xDF1C,0xBA64),
196 bn_pack4(AD33,170D,0450,7A33), 196 bn_pack4(0xAD33,0x170D,0x0450,0x7A33),
197 bn_pack4(1572,8E5A,8AAA,C42D), 197 bn_pack4(0x1572,0x8E5A,0x8AAA,0xC42D),
198 bn_pack4(15D2,2618,98FA,0510), 198 bn_pack4(0x15D2,0x2618,0x98FA,0x0510),
199 bn_pack4(3995,497C,EA95,6AE5), 199 bn_pack4(0x3995,0x497C,0xEA95,0x6AE5),
200 bn_pack4(DE2B,CBF6,9558,1718), 200 bn_pack4(0xDE2B,0xCBF6,0x9558,0x1718),
201 bn_pack4(B5C5,5DF0,6F4C,52C9), 201 bn_pack4(0xB5C5,0x5DF0,0x6F4C,0x52C9),
202 bn_pack4(9B27,83A2,EC07,A28F), 202 bn_pack4(0x9B27,0x83A2,0xEC07,0xA28F),
203 bn_pack4(E39E,772C,180E,8603), 203 bn_pack4(0xE39E,0x772C,0x180E,0x8603),
204 bn_pack4(3290,5E46,2E36,CE3B), 204 bn_pack4(0x3290,0x5E46,0x2E36,0xCE3B),
205 bn_pack4(F174,6C08,CA18,217C), 205 bn_pack4(0xF174,0x6C08,0xCA18,0x217C),
206 bn_pack4(670C,354E,4ABC,9804), 206 bn_pack4(0x670C,0x354E,0x4ABC,0x9804),
207 bn_pack4(9ED5,2907,7096,966D), 207 bn_pack4(0x9ED5,0x2907,0x7096,0x966D),
208 bn_pack4(1C62,F356,2085,52BB), 208 bn_pack4(0x1C62,0xF356,0x2085,0x52BB),
209 bn_pack4(8365,5D23,DCA3,AD96), 209 bn_pack4(0x8365,0x5D23,0xDCA3,0xAD96),
210 bn_pack4(6916,3FA8,FD24,CF5F), 210 bn_pack4(0x6916,0x3FA8,0xFD24,0xCF5F),
211 bn_pack4(98DA,4836,1C55,D39A), 211 bn_pack4(0x98DA,0x4836,0x1C55,0xD39A),
212 bn_pack4(C200,7CB8,A163,BF05), 212 bn_pack4(0xC200,0x7CB8,0xA163,0xBF05),
213 bn_pack4(4928,6651,ECE4,5B3D), 213 bn_pack4(0x4928,0x6651,0xECE4,0x5B3D),
214 bn_pack4(AE9F,2411,7C4B,1FE6), 214 bn_pack4(0xAE9F,0x2411,0x7C4B,0x1FE6),
215 bn_pack4(EE38,6BFB,5A89,9FA5), 215 bn_pack4(0xEE38,0x6BFB,0x5A89,0x9FA5),
216 bn_pack4(0BFF,5CB6,F406,B7ED), 216 bn_pack4(0x0BFF,0x5CB6,0xF406,0xB7ED),
217 bn_pack4(F44C,42E9,A637,ED6B), 217 bn_pack4(0xF44C,0x42E9,0xA637,0xED6B),
218 bn_pack4(E485,B576,625E,7EC6), 218 bn_pack4(0xE485,0xB576,0x625E,0x7EC6),
219 bn_pack4(4FE1,356D,6D51,C245), 219 bn_pack4(0x4FE1,0x356D,0x6D51,0xC245),
220 bn_pack4(302B,0A6D,F25F,1437), 220 bn_pack4(0x302B,0x0A6D,0xF25F,0x1437),
221 bn_pack4(EF95,19B3,CD3A,431B), 221 bn_pack4(0xEF95,0x19B3,0xCD3A,0x431B),
222 bn_pack4(514A,0879,8E34,04DD), 222 bn_pack4(0x514A,0x0879,0x8E34,0x04DD),
223 bn_pack4(020B,BEA6,3B13,9B22), 223 bn_pack4(0x020B,0xBEA6,0x3B13,0x9B22),
224 bn_pack4(2902,4E08,8A67,CC74), 224 bn_pack4(0x2902,0x4E08,0x8A67,0xCC74),
225 bn_pack4(C4C6,628B,80DC,1CD1), 225 bn_pack4(0xC4C6,0x628B,0x80DC,0x1CD1),
226 bn_pack4(C90F,DAA2,2168,C234), 226 bn_pack4(0xC90F,0xDAA2,0x2168,0xC234),
227 bn_pack4(FFFF,FFFF,FFFF,FFFF) 227 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF)
228}; 228};
229static BIGNUM bn_group_4096 = { 229static BIGNUM bn_group_4096 = {
230 bn_group_4096_value, 230 bn_group_4096_value,
@@ -235,102 +235,102 @@ static BIGNUM bn_group_4096 = {
235}; 235};
236 236
237static BN_ULONG bn_group_6144_value[] = { 237static BN_ULONG bn_group_6144_value[] = {
238 bn_pack4(FFFF,FFFF,FFFF,FFFF), 238 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF),
239 bn_pack4(E694,F91E,6DCC,4024), 239 bn_pack4(0xE694,0xF91E,0x6DCC,0x4024),
240 bn_pack4(12BF,2D5B,0B74,74D6), 240 bn_pack4(0x12BF,0x2D5B,0x0B74,0x74D6),
241 bn_pack4(043E,8F66,3F48,60EE), 241 bn_pack4(0x043E,0x8F66,0x3F48,0x60EE),
242 bn_pack4(387F,E8D7,6E3C,0468), 242 bn_pack4(0x387F,0xE8D7,0x6E3C,0x0468),
243 bn_pack4(DA56,C9EC,2EF2,9632), 243 bn_pack4(0xDA56,0xC9EC,0x2EF2,0x9632),
244 bn_pack4(EB19,CCB1,A313,D55C), 244 bn_pack4(0xEB19,0xCCB1,0xA313,0xD55C),
245 bn_pack4(F550,AA3D,8A1F,BFF0), 245 bn_pack4(0xF550,0xAA3D,0x8A1F,0xBFF0),
246 bn_pack4(06A1,D58B,B7C5,DA76), 246 bn_pack4(0x06A1,0xD58B,0xB7C5,0xDA76),
247 bn_pack4(A797,15EE,F29B,E328), 247 bn_pack4(0xA797,0x15EE,0xF29B,0xE328),
248 bn_pack4(14CC,5ED2,0F80,37E0), 248 bn_pack4(0x14CC,0x5ED2,0x0F80,0x37E0),
249 bn_pack4(CC8F,6D7E,BF48,E1D8), 249 bn_pack4(0xCC8F,0x6D7E,0xBF48,0xE1D8),
250 bn_pack4(4BD4,07B2,2B41,54AA), 250 bn_pack4(0x4BD4,0x07B2,0x2B41,0x54AA),
251 bn_pack4(0F1D,45B7,FF58,5AC5), 251 bn_pack4(0x0F1D,0x45B7,0xFF58,0x5AC5),
252 bn_pack4(23A9,7A7E,36CC,88BE), 252 bn_pack4(0x23A9,0x7A7E,0x36CC,0x88BE),
253 bn_pack4(59E7,C97F,BEC7,E8F3), 253 bn_pack4(0x59E7,0xC97F,0xBEC7,0xE8F3),
254 bn_pack4(B5A8,4031,900B,1C9E), 254 bn_pack4(0xB5A8,0x4031,0x900B,0x1C9E),
255 bn_pack4(D55E,702F,4698,0C82), 255 bn_pack4(0xD55E,0x702F,0x4698,0x0C82),
256 bn_pack4(F482,D7CE,6E74,FEF6), 256 bn_pack4(0xF482,0xD7CE,0x6E74,0xFEF6),
257 bn_pack4(F032,EA15,D172,1D03), 257 bn_pack4(0xF032,0xEA15,0xD172,0x1D03),
258 bn_pack4(5983,CA01,C64B,92EC), 258 bn_pack4(0x5983,0xCA01,0xC64B,0x92EC),
259 bn_pack4(6FB8,F401,378C,D2BF), 259 bn_pack4(0x6FB8,0xF401,0x378C,0xD2BF),
260 bn_pack4(3320,5151,2BD7,AF42), 260 bn_pack4(0x3320,0x5151,0x2BD7,0xAF42),
261 bn_pack4(DB7F,1447,E6CC,254B), 261 bn_pack4(0xDB7F,0x1447,0xE6CC,0x254B),
262 bn_pack4(44CE,6CBA,CED4,BB1B), 262 bn_pack4(0x44CE,0x6CBA,0xCED4,0xBB1B),
263 bn_pack4(DA3E,DBEB,CF9B,14ED), 263 bn_pack4(0xDA3E,0xDBEB,0xCF9B,0x14ED),
264 bn_pack4(1797,27B0,865A,8918), 264 bn_pack4(0x1797,0x27B0,0x865A,0x8918),
265 bn_pack4(B06A,53ED,9027,D831), 265 bn_pack4(0xB06A,0x53ED,0x9027,0xD831),
266 bn_pack4(E5DB,382F,4130,01AE), 266 bn_pack4(0xE5DB,0x382F,0x4130,0x01AE),
267 bn_pack4(F8FF,9406,AD9E,530E), 267 bn_pack4(0xF8FF,0x9406,0xAD9E,0x530E),
268 bn_pack4(C975,1E76,3DBA,37BD), 268 bn_pack4(0xC975,0x1E76,0x3DBA,0x37BD),
269 bn_pack4(C1D4,DCB2,6026,46DE), 269 bn_pack4(0xC1D4,0xDCB2,0x6026,0x46DE),
270 bn_pack4(36C3,FAB4,D27C,7026), 270 bn_pack4(0x36C3,0xFAB4,0xD27C,0x7026),
271 bn_pack4(4DF4,35C9,3402,8492), 271 bn_pack4(0x4DF4,0x35C9,0x3402,0x8492),
272 bn_pack4(86FF,B7DC,90A6,C08F), 272 bn_pack4(0x86FF,0xB7DC,0x90A6,0xC08F),
273 bn_pack4(93B4,EA98,8D8F,DDC1), 273 bn_pack4(0x93B4,0xEA98,0x8D8F,0xDDC1),
274 bn_pack4(D006,9127,D5B0,5AA9), 274 bn_pack4(0xD006,0x9127,0xD5B0,0x5AA9),
275 bn_pack4(B81B,DD76,2170,481C), 275 bn_pack4(0xB81B,0xDD76,0x2170,0x481C),
276 bn_pack4(1F61,2970,CEE2,D7AF), 276 bn_pack4(0x1F61,0x2970,0xCEE2,0xD7AF),
277 bn_pack4(233B,A186,515B,E7ED), 277 bn_pack4(0x233B,0xA186,0x515B,0xE7ED),
278 bn_pack4(99B2,964F,A090,C3A2), 278 bn_pack4(0x99B2,0x964F,0xA090,0xC3A2),
279 bn_pack4(287C,5947,4E6B,C05D), 279 bn_pack4(0x287C,0x5947,0x4E6B,0xC05D),
280 bn_pack4(2E8E,FC14,1FBE,CAA6), 280 bn_pack4(0x2E8E,0xFC14,0x1FBE,0xCAA6),
281 bn_pack4(DBBB,C2DB,04DE,8EF9), 281 bn_pack4(0xDBBB,0xC2DB,0x04DE,0x8EF9),
282 bn_pack4(2583,E9CA,2AD4,4CE8), 282 bn_pack4(0x2583,0xE9CA,0x2AD4,0x4CE8),
283 bn_pack4(1A94,6834,B615,0BDA), 283 bn_pack4(0x1A94,0x6834,0xB615,0x0BDA),
284 bn_pack4(99C3,2718,6AF4,E23C), 284 bn_pack4(0x99C3,0x2718,0x6AF4,0xE23C),
285 bn_pack4(8871,9A10,BDBA,5B26), 285 bn_pack4(0x8871,0x9A10,0xBDBA,0x5B26),
286 bn_pack4(1A72,3C12,A787,E6D7), 286 bn_pack4(0x1A72,0x3C12,0xA787,0xE6D7),
287 bn_pack4(4B82,D120,A921,0801), 287 bn_pack4(0x4B82,0xD120,0xA921,0x0801),
288 bn_pack4(43DB,5BFC,E0FD,108E), 288 bn_pack4(0x43DB,0x5BFC,0xE0FD,0x108E),
289 bn_pack4(08E2,4FA0,74E5,AB31), 289 bn_pack4(0x08E2,0x4FA0,0x74E5,0xAB31),
290 bn_pack4(7709,88C0,BAD9,46E2), 290 bn_pack4(0x7709,0x88C0,0xBAD9,0x46E2),
291 bn_pack4(BBE1,1757,7A61,5D6C), 291 bn_pack4(0xBBE1,0x1757,0x7A61,0x5D6C),
292 bn_pack4(521F,2B18,177B,200C), 292 bn_pack4(0x521F,0x2B18,0x177B,0x200C),
293 bn_pack4(D876,0273,3EC8,6A64), 293 bn_pack4(0xD876,0x0273,0x3EC8,0x6A64),
294 bn_pack4(F12F,FA06,D98A,0864), 294 bn_pack4(0xF12F,0xFA06,0xD98A,0x0864),
295 bn_pack4(CEE3,D226,1AD2,EE6B), 295 bn_pack4(0xCEE3,0xD226,0x1AD2,0xEE6B),
296 bn_pack4(1E8C,94E0,4A25,619D), 296 bn_pack4(0x1E8C,0x94E0,0x4A25,0x619D),
297 bn_pack4(ABF5,AE8C,DB09,33D7), 297 bn_pack4(0xABF5,0xAE8C,0xDB09,0x33D7),
298 bn_pack4(B397,0F85,A6E1,E4C7), 298 bn_pack4(0xB397,0x0F85,0xA6E1,0xE4C7),
299 bn_pack4(8AEA,7157,5D06,0C7D), 299 bn_pack4(0x8AEA,0x7157,0x5D06,0x0C7D),
300 bn_pack4(ECFB,8504,58DB,EF0A), 300 bn_pack4(0xECFB,0x8504,0x58DB,0xEF0A),
301 bn_pack4(A855,21AB,DF1C,BA64), 301 bn_pack4(0xA855,0x21AB,0xDF1C,0xBA64),
302 bn_pack4(AD33,170D,0450,7A33), 302 bn_pack4(0xAD33,0x170D,0x0450,0x7A33),
303 bn_pack4(1572,8E5A,8AAA,C42D), 303 bn_pack4(0x1572,0x8E5A,0x8AAA,0xC42D),
304 bn_pack4(15D2,2618,98FA,0510), 304 bn_pack4(0x15D2,0x2618,0x98FA,0x0510),
305 bn_pack4(3995,497C,EA95,6AE5), 305 bn_pack4(0x3995,0x497C,0xEA95,0x6AE5),
306 bn_pack4(DE2B,CBF6,9558,1718), 306 bn_pack4(0xDE2B,0xCBF6,0x9558,0x1718),
307 bn_pack4(B5C5,5DF0,6F4C,52C9), 307 bn_pack4(0xB5C5,0x5DF0,0x6F4C,0x52C9),
308 bn_pack4(9B27,83A2,EC07,A28F), 308 bn_pack4(0x9B27,0x83A2,0xEC07,0xA28F),
309 bn_pack4(E39E,772C,180E,8603), 309 bn_pack4(0xE39E,0x772C,0x180E,0x8603),
310 bn_pack4(3290,5E46,2E36,CE3B), 310 bn_pack4(0x3290,0x5E46,0x2E36,0xCE3B),
311 bn_pack4(F174,6C08,CA18,217C), 311 bn_pack4(0xF174,0x6C08,0xCA18,0x217C),
312 bn_pack4(670C,354E,4ABC,9804), 312 bn_pack4(0x670C,0x354E,0x4ABC,0x9804),
313 bn_pack4(9ED5,2907,7096,966D), 313 bn_pack4(0x9ED5,0x2907,0x7096,0x966D),
314 bn_pack4(1C62,F356,2085,52BB), 314 bn_pack4(0x1C62,0xF356,0x2085,0x52BB),
315 bn_pack4(8365,5D23,DCA3,AD96), 315 bn_pack4(0x8365,0x5D23,0xDCA3,0xAD96),
316 bn_pack4(6916,3FA8,FD24,CF5F), 316 bn_pack4(0x6916,0x3FA8,0xFD24,0xCF5F),
317 bn_pack4(98DA,4836,1C55,D39A), 317 bn_pack4(0x98DA,0x4836,0x1C55,0xD39A),
318 bn_pack4(C200,7CB8,A163,BF05), 318 bn_pack4(0xC200,0x7CB8,0xA163,0xBF05),
319 bn_pack4(4928,6651,ECE4,5B3D), 319 bn_pack4(0x4928,0x6651,0xECE4,0x5B3D),
320 bn_pack4(AE9F,2411,7C4B,1FE6), 320 bn_pack4(0xAE9F,0x2411,0x7C4B,0x1FE6),
321 bn_pack4(EE38,6BFB,5A89,9FA5), 321 bn_pack4(0xEE38,0x6BFB,0x5A89,0x9FA5),
322 bn_pack4(0BFF,5CB6,F406,B7ED), 322 bn_pack4(0x0BFF,0x5CB6,0xF406,0xB7ED),
323 bn_pack4(F44C,42E9,A637,ED6B), 323 bn_pack4(0xF44C,0x42E9,0xA637,0xED6B),
324 bn_pack4(E485,B576,625E,7EC6), 324 bn_pack4(0xE485,0xB576,0x625E,0x7EC6),
325 bn_pack4(4FE1,356D,6D51,C245), 325 bn_pack4(0x4FE1,0x356D,0x6D51,0xC245),
326 bn_pack4(302B,0A6D,F25F,1437), 326 bn_pack4(0x302B,0x0A6D,0xF25F,0x1437),
327 bn_pack4(EF95,19B3,CD3A,431B), 327 bn_pack4(0xEF95,0x19B3,0xCD3A,0x431B),
328 bn_pack4(514A,0879,8E34,04DD), 328 bn_pack4(0x514A,0x0879,0x8E34,0x04DD),
329 bn_pack4(020B,BEA6,3B13,9B22), 329 bn_pack4(0x020B,0xBEA6,0x3B13,0x9B22),
330 bn_pack4(2902,4E08,8A67,CC74), 330 bn_pack4(0x2902,0x4E08,0x8A67,0xCC74),
331 bn_pack4(C4C6,628B,80DC,1CD1), 331 bn_pack4(0xC4C6,0x628B,0x80DC,0x1CD1),
332 bn_pack4(C90F,DAA2,2168,C234), 332 bn_pack4(0xC90F,0xDAA2,0x2168,0xC234),
333 bn_pack4(FFFF,FFFF,FFFF,FFFF) 333 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF)
334}; 334};
335static BIGNUM bn_group_6144 = { 335static BIGNUM bn_group_6144 = {
336 bn_group_6144_value, 336 bn_group_6144_value,
@@ -341,134 +341,134 @@ static BIGNUM bn_group_6144 = {
341}; 341};
342 342
343static BN_ULONG bn_group_8192_value[] = { 343static BN_ULONG bn_group_8192_value[] = {
344 bn_pack4(FFFF,FFFF,FFFF,FFFF), 344 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF),
345 bn_pack4(60C9,80DD,98ED,D3DF), 345 bn_pack4(0x60C9,0x80DD,0x98ED,0xD3DF),
346 bn_pack4(C81F,56E8,80B9,6E71), 346 bn_pack4(0xC81F,0x56E8,0x80B9,0x6E71),
347 bn_pack4(9E30,50E2,7656,94DF), 347 bn_pack4(0x9E30,0x50E2,0x7656,0x94DF),
348 bn_pack4(9558,E447,5677,E9AA), 348 bn_pack4(0x9558,0xE447,0x5677,0xE9AA),
349 bn_pack4(C919,0DA6,FC02,6E47), 349 bn_pack4(0xC919,0x0DA6,0xFC02,0x6E47),
350 bn_pack4(889A,002E,D5EE,382B), 350 bn_pack4(0x889A,0x002E,0xD5EE,0x382B),
351 bn_pack4(4009,438B,481C,6CD7), 351 bn_pack4(0x4009,0x438B,0x481C,0x6CD7),
352 bn_pack4(3590,46F4,EB87,9F92), 352 bn_pack4(0x3590,0x46F4,0xEB87,0x9F92),
353 bn_pack4(FAF3,6BC3,1ECF,A268), 353 bn_pack4(0xFAF3,0x6BC3,0x1ECF,0xA268),
354 bn_pack4(B1D5,10BD,7EE7,4D73), 354 bn_pack4(0xB1D5,0x10BD,0x7EE7,0x4D73),
355 bn_pack4(F9AB,4819,5DED,7EA1), 355 bn_pack4(0xF9AB,0x4819,0x5DED,0x7EA1),
356 bn_pack4(64F3,1CC5,0846,851D), 356 bn_pack4(0x64F3,0x1CC5,0x0846,0x851D),
357 bn_pack4(4597,E899,A025,5DC1), 357 bn_pack4(0x4597,0xE899,0xA025,0x5DC1),
358 bn_pack4(DF31,0EE0,74AB,6A36), 358 bn_pack4(0xDF31,0x0EE0,0x74AB,0x6A36),
359 bn_pack4(6D2A,13F8,3F44,F82D), 359 bn_pack4(0x6D2A,0x13F8,0x3F44,0xF82D),
360 bn_pack4(062B,3CF5,B3A2,78A6), 360 bn_pack4(0x062B,0x3CF5,0xB3A2,0x78A6),
361 bn_pack4(7968,3303,ED5B,DD3A), 361 bn_pack4(0x7968,0x3303,0xED5B,0xDD3A),
362 bn_pack4(FA9D,4B7F,A2C0,87E8), 362 bn_pack4(0xFA9D,0x4B7F,0xA2C0,0x87E8),
363 bn_pack4(4BCB,C886,2F83,85DD), 363 bn_pack4(0x4BCB,0xC886,0x2F83,0x85DD),
364 bn_pack4(3473,FC64,6CEA,306B), 364 bn_pack4(0x3473,0xFC64,0x6CEA,0x306B),
365 bn_pack4(13EB,57A8,1A23,F0C7), 365 bn_pack4(0x13EB,0x57A8,0x1A23,0xF0C7),
366 bn_pack4(2222,2E04,A403,7C07), 366 bn_pack4(0x2222,0x2E04,0xA403,0x7C07),
367 bn_pack4(E3FD,B8BE,FC84,8AD9), 367 bn_pack4(0xE3FD,0xB8BE,0xFC84,0x8AD9),
368 bn_pack4(238F,16CB,E39D,652D), 368 bn_pack4(0x238F,0x16CB,0xE39D,0x652D),
369 bn_pack4(3423,B474,2BF1,C978), 369 bn_pack4(0x3423,0xB474,0x2BF1,0xC978),
370 bn_pack4(3AAB,639C,5AE4,F568), 370 bn_pack4(0x3AAB,0x639C,0x5AE4,0xF568),
371 bn_pack4(2576,F693,6BA4,2466), 371 bn_pack4(0x2576,0xF693,0x6BA4,0x2466),
372 bn_pack4(741F,A7BF,8AFC,47ED), 372 bn_pack4(0x741F,0xA7BF,0x8AFC,0x47ED),
373 bn_pack4(3BC8,32B6,8D9D,D300), 373 bn_pack4(0x3BC8,0x32B6,0x8D9D,0xD300),
374 bn_pack4(D8BE,C4D0,73B9,31BA), 374 bn_pack4(0xD8BE,0xC4D0,0x73B9,0x31BA),
375 bn_pack4(3877,7CB6,A932,DF8C), 375 bn_pack4(0x3877,0x7CB6,0xA932,0xDF8C),
376 bn_pack4(74A3,926F,12FE,E5E4), 376 bn_pack4(0x74A3,0x926F,0x12FE,0xE5E4),
377 bn_pack4(E694,F91E,6DBE,1159), 377 bn_pack4(0xE694,0xF91E,0x6DBE,0x1159),
378 bn_pack4(12BF,2D5B,0B74,74D6), 378 bn_pack4(0x12BF,0x2D5B,0x0B74,0x74D6),
379 bn_pack4(043E,8F66,3F48,60EE), 379 bn_pack4(0x043E,0x8F66,0x3F48,0x60EE),
380 bn_pack4(387F,E8D7,6E3C,0468), 380 bn_pack4(0x387F,0xE8D7,0x6E3C,0x0468),
381 bn_pack4(DA56,C9EC,2EF2,9632), 381 bn_pack4(0xDA56,0xC9EC,0x2EF2,0x9632),
382 bn_pack4(EB19,CCB1,A313,D55C), 382 bn_pack4(0xEB19,0xCCB1,0xA313,0xD55C),
383 bn_pack4(F550,AA3D,8A1F,BFF0), 383 bn_pack4(0xF550,0xAA3D,0x8A1F,0xBFF0),
384 bn_pack4(06A1,D58B,B7C5,DA76), 384 bn_pack4(0x06A1,0xD58B,0xB7C5,0xDA76),
385 bn_pack4(A797,15EE,F29B,E328), 385 bn_pack4(0xA797,0x15EE,0xF29B,0xE328),
386 bn_pack4(14CC,5ED2,0F80,37E0), 386 bn_pack4(0x14CC,0x5ED2,0x0F80,0x37E0),
387 bn_pack4(CC8F,6D7E,BF48,E1D8), 387 bn_pack4(0xCC8F,0x6D7E,0xBF48,0xE1D8),
388 bn_pack4(4BD4,07B2,2B41,54AA), 388 bn_pack4(0x4BD4,0x07B2,0x2B41,0x54AA),
389 bn_pack4(0F1D,45B7,FF58,5AC5), 389 bn_pack4(0x0F1D,0x45B7,0xFF58,0x5AC5),
390 bn_pack4(23A9,7A7E,36CC,88BE), 390 bn_pack4(0x23A9,0x7A7E,0x36CC,0x88BE),
391 bn_pack4(59E7,C97F,BEC7,E8F3), 391 bn_pack4(0x59E7,0xC97F,0xBEC7,0xE8F3),
392 bn_pack4(B5A8,4031,900B,1C9E), 392 bn_pack4(0xB5A8,0x4031,0x900B,0x1C9E),
393 bn_pack4(D55E,702F,4698,0C82), 393 bn_pack4(0xD55E,0x702F,0x4698,0x0C82),
394 bn_pack4(F482,D7CE,6E74,FEF6), 394 bn_pack4(0xF482,0xD7CE,0x6E74,0xFEF6),
395 bn_pack4(F032,EA15,D172,1D03), 395 bn_pack4(0xF032,0xEA15,0xD172,0x1D03),
396 bn_pack4(5983,CA01,C64B,92EC), 396 bn_pack4(0x5983,0xCA01,0xC64B,0x92EC),
397 bn_pack4(6FB8,F401,378C,D2BF), 397 bn_pack4(0x6FB8,0xF401,0x378C,0xD2BF),
398 bn_pack4(3320,5151,2BD7,AF42), 398 bn_pack4(0x3320,0x5151,0x2BD7,0xAF42),
399 bn_pack4(DB7F,1447,E6CC,254B), 399 bn_pack4(0xDB7F,0x1447,0xE6CC,0x254B),
400 bn_pack4(44CE,6CBA,CED4,BB1B), 400 bn_pack4(0x44CE,0x6CBA,0xCED4,0xBB1B),
401 bn_pack4(DA3E,DBEB,CF9B,14ED), 401 bn_pack4(0xDA3E,0xDBEB,0xCF9B,0x14ED),
402 bn_pack4(1797,27B0,865A,8918), 402 bn_pack4(0x1797,0x27B0,0x865A,0x8918),
403 bn_pack4(B06A,53ED,9027,D831), 403 bn_pack4(0xB06A,0x53ED,0x9027,0xD831),
404 bn_pack4(E5DB,382F,4130,01AE), 404 bn_pack4(0xE5DB,0x382F,0x4130,0x01AE),
405 bn_pack4(F8FF,9406,AD9E,530E), 405 bn_pack4(0xF8FF,0x9406,0xAD9E,0x530E),
406 bn_pack4(C975,1E76,3DBA,37BD), 406 bn_pack4(0xC975,0x1E76,0x3DBA,0x37BD),
407 bn_pack4(C1D4,DCB2,6026,46DE), 407 bn_pack4(0xC1D4,0xDCB2,0x6026,0x46DE),
408 bn_pack4(36C3,FAB4,D27C,7026), 408 bn_pack4(0x36C3,0xFAB4,0xD27C,0x7026),
409 bn_pack4(4DF4,35C9,3402,8492), 409 bn_pack4(0x4DF4,0x35C9,0x3402,0x8492),
410 bn_pack4(86FF,B7DC,90A6,C08F), 410 bn_pack4(0x86FF,0xB7DC,0x90A6,0xC08F),
411 bn_pack4(93B4,EA98,8D8F,DDC1), 411 bn_pack4(0x93B4,0xEA98,0x8D8F,0xDDC1),
412 bn_pack4(D006,9127,D5B0,5AA9), 412 bn_pack4(0xD006,0x9127,0xD5B0,0x5AA9),
413 bn_pack4(B81B,DD76,2170,481C), 413 bn_pack4(0xB81B,0xDD76,0x2170,0x481C),
414 bn_pack4(1F61,2970,CEE2,D7AF), 414 bn_pack4(0x1F61,0x2970,0xCEE2,0xD7AF),
415 bn_pack4(233B,A186,515B,E7ED), 415 bn_pack4(0x233B,0xA186,0x515B,0xE7ED),
416 bn_pack4(99B2,964F,A090,C3A2), 416 bn_pack4(0x99B2,0x964F,0xA090,0xC3A2),
417 bn_pack4(287C,5947,4E6B,C05D), 417 bn_pack4(0x287C,0x5947,0x4E6B,0xC05D),
418 bn_pack4(2E8E,FC14,1FBE,CAA6), 418 bn_pack4(0x2E8E,0xFC14,0x1FBE,0xCAA6),
419 bn_pack4(DBBB,C2DB,04DE,8EF9), 419 bn_pack4(0xDBBB,0xC2DB,0x04DE,0x8EF9),
420 bn_pack4(2583,E9CA,2AD4,4CE8), 420 bn_pack4(0x2583,0xE9CA,0x2AD4,0x4CE8),
421 bn_pack4(1A94,6834,B615,0BDA), 421 bn_pack4(0x1A94,0x6834,0xB615,0x0BDA),
422 bn_pack4(99C3,2718,6AF4,E23C), 422 bn_pack4(0x99C3,0x2718,0x6AF4,0xE23C),
423 bn_pack4(8871,9A10,BDBA,5B26), 423 bn_pack4(0x8871,0x9A10,0xBDBA,0x5B26),
424 bn_pack4(1A72,3C12,A787,E6D7), 424 bn_pack4(0x1A72,0x3C12,0xA787,0xE6D7),
425 bn_pack4(4B82,D120,A921,0801), 425 bn_pack4(0x4B82,0xD120,0xA921,0x0801),
426 bn_pack4(43DB,5BFC,E0FD,108E), 426 bn_pack4(0x43DB,0x5BFC,0xE0FD,0x108E),
427 bn_pack4(08E2,4FA0,74E5,AB31), 427 bn_pack4(0x08E2,0x4FA0,0x74E5,0xAB31),
428 bn_pack4(7709,88C0,BAD9,46E2), 428 bn_pack4(0x7709,0x88C0,0xBAD9,0x46E2),
429 bn_pack4(BBE1,1757,7A61,5D6C), 429 bn_pack4(0xBBE1,0x1757,0x7A61,0x5D6C),
430 bn_pack4(521F,2B18,177B,200C), 430 bn_pack4(0x521F,0x2B18,0x177B,0x200C),
431 bn_pack4(D876,0273,3EC8,6A64), 431 bn_pack4(0xD876,0x0273,0x3EC8,0x6A64),
432 bn_pack4(F12F,FA06,D98A,0864), 432 bn_pack4(0xF12F,0xFA06,0xD98A,0x0864),
433 bn_pack4(CEE3,D226,1AD2,EE6B), 433 bn_pack4(0xCEE3,0xD226,0x1AD2,0xEE6B),
434 bn_pack4(1E8C,94E0,4A25,619D), 434 bn_pack4(0x1E8C,0x94E0,0x4A25,0x619D),
435 bn_pack4(ABF5,AE8C,DB09,33D7), 435 bn_pack4(0xABF5,0xAE8C,0xDB09,0x33D7),
436 bn_pack4(B397,0F85,A6E1,E4C7), 436 bn_pack4(0xB397,0x0F85,0xA6E1,0xE4C7),
437 bn_pack4(8AEA,7157,5D06,0C7D), 437 bn_pack4(0x8AEA,0x7157,0x5D06,0x0C7D),
438 bn_pack4(ECFB,8504,58DB,EF0A), 438 bn_pack4(0xECFB,0x8504,0x58DB,0xEF0A),
439 bn_pack4(A855,21AB,DF1C,BA64), 439 bn_pack4(0xA855,0x21AB,0xDF1C,0xBA64),
440 bn_pack4(AD33,170D,0450,7A33), 440 bn_pack4(0xAD33,0x170D,0x0450,0x7A33),
441 bn_pack4(1572,8E5A,8AAA,C42D), 441 bn_pack4(0x1572,0x8E5A,0x8AAA,0xC42D),
442 bn_pack4(15D2,2618,98FA,0510), 442 bn_pack4(0x15D2,0x2618,0x98FA,0x0510),
443 bn_pack4(3995,497C,EA95,6AE5), 443 bn_pack4(0x3995,0x497C,0xEA95,0x6AE5),
444 bn_pack4(DE2B,CBF6,9558,1718), 444 bn_pack4(0xDE2B,0xCBF6,0x9558,0x1718),
445 bn_pack4(B5C5,5DF0,6F4C,52C9), 445 bn_pack4(0xB5C5,0x5DF0,0x6F4C,0x52C9),
446 bn_pack4(9B27,83A2,EC07,A28F), 446 bn_pack4(0x9B27,0x83A2,0xEC07,0xA28F),
447 bn_pack4(E39E,772C,180E,8603), 447 bn_pack4(0xE39E,0x772C,0x180E,0x8603),
448 bn_pack4(3290,5E46,2E36,CE3B), 448 bn_pack4(0x3290,0x5E46,0x2E36,0xCE3B),
449 bn_pack4(F174,6C08,CA18,217C), 449 bn_pack4(0xF174,0x6C08,0xCA18,0x217C),
450 bn_pack4(670C,354E,4ABC,9804), 450 bn_pack4(0x670C,0x354E,0x4ABC,0x9804),
451 bn_pack4(9ED5,2907,7096,966D), 451 bn_pack4(0x9ED5,0x2907,0x7096,0x966D),
452 bn_pack4(1C62,F356,2085,52BB), 452 bn_pack4(0x1C62,0xF356,0x2085,0x52BB),
453 bn_pack4(8365,5D23,DCA3,AD96), 453 bn_pack4(0x8365,0x5D23,0xDCA3,0xAD96),
454 bn_pack4(6916,3FA8,FD24,CF5F), 454 bn_pack4(0x6916,0x3FA8,0xFD24,0xCF5F),
455 bn_pack4(98DA,4836,1C55,D39A), 455 bn_pack4(0x98DA,0x4836,0x1C55,0xD39A),
456 bn_pack4(C200,7CB8,A163,BF05), 456 bn_pack4(0xC200,0x7CB8,0xA163,0xBF05),
457 bn_pack4(4928,6651,ECE4,5B3D), 457 bn_pack4(0x4928,0x6651,0xECE4,0x5B3D),
458 bn_pack4(AE9F,2411,7C4B,1FE6), 458 bn_pack4(0xAE9F,0x2411,0x7C4B,0x1FE6),
459 bn_pack4(EE38,6BFB,5A89,9FA5), 459 bn_pack4(0xEE38,0x6BFB,0x5A89,0x9FA5),
460 bn_pack4(0BFF,5CB6,F406,B7ED), 460 bn_pack4(0x0BFF,0x5CB6,0xF406,0xB7ED),
461 bn_pack4(F44C,42E9,A637,ED6B), 461 bn_pack4(0xF44C,0x42E9,0xA637,0xED6B),
462 bn_pack4(E485,B576,625E,7EC6), 462 bn_pack4(0xE485,0xB576,0x625E,0x7EC6),
463 bn_pack4(4FE1,356D,6D51,C245), 463 bn_pack4(0x4FE1,0x356D,0x6D51,0xC245),
464 bn_pack4(302B,0A6D,F25F,1437), 464 bn_pack4(0x302B,0x0A6D,0xF25F,0x1437),
465 bn_pack4(EF95,19B3,CD3A,431B), 465 bn_pack4(0xEF95,0x19B3,0xCD3A,0x431B),
466 bn_pack4(514A,0879,8E34,04DD), 466 bn_pack4(0x514A,0x0879,0x8E34,0x04DD),
467 bn_pack4(020B,BEA6,3B13,9B22), 467 bn_pack4(0x020B,0xBEA6,0x3B13,0x9B22),
468 bn_pack4(2902,4E08,8A67,CC74), 468 bn_pack4(0x2902,0x4E08,0x8A67,0xCC74),
469 bn_pack4(C4C6,628B,80DC,1CD1), 469 bn_pack4(0xC4C6,0x628B,0x80DC,0x1CD1),
470 bn_pack4(C90F,DAA2,2168,C234), 470 bn_pack4(0xC90F,0xDAA2,0x2168,0xC234),
471 bn_pack4(FFFF,FFFF,FFFF,FFFF) 471 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF)
472}; 472};
473static BIGNUM bn_group_8192 = { 473static BIGNUM bn_group_8192 = {
474 bn_group_8192_value, 474 bn_group_8192_value,
diff --git a/src/lib/libssl/src/crypto/srp/srp_lib.c b/src/lib/libssl/src/crypto/srp/srp_lib.c
index 92cea98dcd..7c1dcc5111 100644
--- a/src/lib/libssl/src/crypto/srp/srp_lib.c
+++ b/src/lib/libssl/src/crypto/srp/srp_lib.c
@@ -63,13 +63,17 @@
63#include <openssl/evp.h> 63#include <openssl/evp.h>
64 64
65#if (BN_BYTES == 8) 65#if (BN_BYTES == 8)
66#define bn_pack4(a1,a2,a3,a4) 0x##a1##a2##a3##a4##ul 66# if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
67#endif 67# define bn_pack4(a1,a2,a3,a4) ((a1##UI64<<48)|(a2##UI64<<32)|(a3##UI64<<16)|a4##UI64)
68#if (BN_BYTES == 4) 68# elif defined(__arch64__)
69#define bn_pack4(a1,a2,a3,a4) 0x##a3##a4##ul, 0x##a1##a2##ul 69# define bn_pack4(a1,a2,a3,a4) ((a1##UL<<48)|(a2##UL<<32)|(a3##UL<<16)|a4##UL)
70#endif 70# else
71#if (BN_BYTES == 2) 71# define bn_pack4(a1,a2,a3,a4) ((a1##ULL<<48)|(a2##ULL<<32)|(a3##ULL<<16)|a4##ULL)
72#define bn_pack4(a1,a2,a3,a4) 0x##a4##u,0x##a3##u,0x##a2##u,0x##a1##u 72# endif
73#elif (BN_BYTES == 4)
74# define bn_pack4(a1,a2,a3,a4) ((a3##UL<<16)|a4##UL), ((a1##UL<<16)|a2##UL)
75#else
76# error "unsupported BN_BYTES"
73#endif 77#endif
74 78
75 79
diff --git a/src/lib/libssl/src/crypto/srp/srp_vfy.c b/src/lib/libssl/src/crypto/srp/srp_vfy.c
index c8be907d7f..4a3d13edf6 100644
--- a/src/lib/libssl/src/crypto/srp/srp_vfy.c
+++ b/src/lib/libssl/src/crypto/srp/srp_vfy.c
@@ -390,7 +390,7 @@ int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file)
390 } 390 }
391 for (i = 0; i < sk_OPENSSL_PSTRING_num(tmpdb->data); i++) 391 for (i = 0; i < sk_OPENSSL_PSTRING_num(tmpdb->data); i++)
392 { 392 {
393 pp = (char **)sk_OPENSSL_PSTRING_value(tmpdb->data,i); 393 pp = sk_OPENSSL_PSTRING_value(tmpdb->data,i);
394 if (pp[DB_srptype][0] == DB_SRP_INDEX) 394 if (pp[DB_srptype][0] == DB_SRP_INDEX)
395 { 395 {
396 /*we add this couple in the internal Stack */ 396 /*we add this couple in the internal Stack */
@@ -581,7 +581,8 @@ char *SRP_create_verifier(const char *user, const char *pass, char **salt,
581 if (*salt == NULL) 581 if (*salt == NULL)
582 { 582 {
583 char *tmp_salt; 583 char *tmp_salt;
584 if ((tmp_salt = (char *)OPENSSL_malloc(SRP_RANDOM_SALT_LEN * 2)) == NULL) 584
585 if ((tmp_salt = OPENSSL_malloc(SRP_RANDOM_SALT_LEN * 2)) == NULL)
585 { 586 {
586 OPENSSL_free(vf); 587 OPENSSL_free(vf);
587 goto err; 588 goto err;
diff --git a/src/lib/libssl/src/crypto/whrlpool/asm/wp-mmx.pl b/src/lib/libssl/src/crypto/whrlpool/asm/wp-mmx.pl
index 32cf16380b..cb2381c22b 100644
--- a/src/lib/libssl/src/crypto/whrlpool/asm/wp-mmx.pl
+++ b/src/lib/libssl/src/crypto/whrlpool/asm/wp-mmx.pl
@@ -119,7 +119,7 @@ $tbl="ebp";
119 &mov ("eax",&DWP(0,"esp")); 119 &mov ("eax",&DWP(0,"esp"));
120 &mov ("ebx",&DWP(4,"esp")); 120 &mov ("ebx",&DWP(4,"esp"));
121for($i=0;$i<8;$i++) { 121for($i=0;$i<8;$i++) {
122 my $func = ($i==0)? movq : pxor; 122 my $func = ($i==0)? \&movq : \&pxor;
123 &movb (&LB("ecx"),&LB("eax")); 123 &movb (&LB("ecx"),&LB("eax"));
124 &movb (&LB("edx"),&HB("eax")); 124 &movb (&LB("edx"),&HB("eax"));
125 &scale ("esi","ecx"); 125 &scale ("esi","ecx");
diff --git a/src/lib/libssl/src/crypto/whrlpool/asm/wp-x86_64.pl b/src/lib/libssl/src/crypto/whrlpool/asm/wp-x86_64.pl
index 87c0843dc1..24b2ff60c3 100644
--- a/src/lib/libssl/src/crypto/whrlpool/asm/wp-x86_64.pl
+++ b/src/lib/libssl/src/crypto/whrlpool/asm/wp-x86_64.pl
@@ -41,7 +41,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; my $dir=$1; my $xlate;
41( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or 41( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
42die "can't locate x86_64-xlate.pl"; 42die "can't locate x86_64-xlate.pl";
43 43
44open STDOUT,"| $^X $xlate $flavour $output"; 44open OUT,"| \"$^X\" $xlate $flavour $output";
45*STDOUT=*OUT;
45 46
46sub L() { $code.=".byte ".join(',',@_)."\n"; } 47sub L() { $code.=".byte ".join(',',@_)."\n"; }
47sub LL(){ $code.=".byte ".join(',',@_).",".join(',',@_)."\n"; } 48sub LL(){ $code.=".byte ".join(',',@_).",".join(',',@_)."\n"; }
diff --git a/src/lib/libssl/src/crypto/x86_64cpuid.pl b/src/lib/libssl/src/crypto/x86_64cpuid.pl
index 7b7b93b223..6ebfd017ea 100644
--- a/src/lib/libssl/src/crypto/x86_64cpuid.pl
+++ b/src/lib/libssl/src/crypto/x86_64cpuid.pl
@@ -11,7 +11,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
11( $xlate="${dir}perlasm/x86_64-xlate.pl" and -f $xlate) or 11( $xlate="${dir}perlasm/x86_64-xlate.pl" and -f $xlate) or
12die "can't locate x86_64-xlate.pl"; 12die "can't locate x86_64-xlate.pl";
13 13
14open STDOUT,"| $^X $xlate $flavour $output"; 14open OUT,"| \"$^X\" $xlate $flavour $output";
15*STDOUT=*OUT;
15 16
16($arg1,$arg2,$arg3,$arg4)=$win64?("%rcx","%rdx","%r8", "%r9") : # Win64 order 17($arg1,$arg2,$arg3,$arg4)=$win64?("%rcx","%rdx","%r8", "%r9") : # Win64 order
17 ("%rdi","%rsi","%rdx","%rcx"); # Unix order 18 ("%rdi","%rsi","%rdx","%rcx"); # Unix order
diff --git a/src/lib/libssl/src/crypto/x86cpuid.pl b/src/lib/libssl/src/crypto/x86cpuid.pl
index 39fd8f2293..b270b44337 100644
--- a/src/lib/libssl/src/crypto/x86cpuid.pl
+++ b/src/lib/libssl/src/crypto/x86cpuid.pl
@@ -67,6 +67,7 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
67 &inc ("esi"); # number of cores 67 &inc ("esi"); # number of cores
68 68
69 &mov ("eax",1); 69 &mov ("eax",1);
70 &xor ("ecx","ecx");
70 &cpuid (); 71 &cpuid ();
71 &bt ("edx",28); 72 &bt ("edx",28);
72 &jnc (&label("generic")); 73 &jnc (&label("generic"));
@@ -91,6 +92,7 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
91 92
92&set_label("nocacheinfo"); 93&set_label("nocacheinfo");
93 &mov ("eax",1); 94 &mov ("eax",1);
95 &xor ("ecx","ecx");
94 &cpuid (); 96 &cpuid ();
95 &and ("edx",0xbfefffff); # force reserved bits #20, #30 to 0 97 &and ("edx",0xbfefffff); # force reserved bits #20, #30 to 0
96 &cmp ("ebp",0); 98 &cmp ("ebp",0);
@@ -165,7 +167,7 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
165 &jnz (&label("nohalt")); # not enough privileges 167 &jnz (&label("nohalt")); # not enough privileges
166 168
167 &pushf (); 169 &pushf ();
168 &pop ("eax") 170 &pop ("eax");
169 &bt ("eax",9); 171 &bt ("eax",9);
170 &jnc (&label("nohalt")); # interrupts are disabled 172 &jnc (&label("nohalt")); # interrupts are disabled
171 173
@@ -280,7 +282,7 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
280# arguments is 1 or 2! 282# arguments is 1 or 2!
281&function_begin_B("OPENSSL_indirect_call"); 283&function_begin_B("OPENSSL_indirect_call");
282 { 284 {
283 my $i,$max=7; # $max has to be chosen as 4*n-1 285 my ($max,$i)=(7,); # $max has to be chosen as 4*n-1
284 # in order to preserve eventual 286 # in order to preserve eventual
285 # stack alignment 287 # stack alignment
286 &push ("ebp"); 288 &push ("ebp");
diff --git a/src/lib/libssl/src/demos/cms/cms_comp.c b/src/lib/libssl/src/demos/cms/cms_comp.c
index b7943e813b..01bf092546 100644
--- a/src/lib/libssl/src/demos/cms/cms_comp.c
+++ b/src/lib/libssl/src/demos/cms/cms_comp.c
@@ -10,7 +10,7 @@ int main(int argc, char **argv)
10 int ret = 1; 10 int ret = 1;
11 11
12 /* 12 /*
13 * On OpenSSL 0.9.9 only: 13 * On OpenSSL 1.0.0+ only:
14 * for streaming set CMS_STREAM 14 * for streaming set CMS_STREAM
15 */ 15 */
16 int flags = CMS_STREAM; 16 int flags = CMS_STREAM;
diff --git a/src/lib/libssl/src/demos/cms/cms_dec.c b/src/lib/libssl/src/demos/cms/cms_dec.c
index 7ddf653269..9fee0a3ebf 100644
--- a/src/lib/libssl/src/demos/cms/cms_dec.c
+++ b/src/lib/libssl/src/demos/cms/cms_dec.c
@@ -47,7 +47,7 @@ int main(int argc, char **argv)
47 goto err; 47 goto err;
48 48
49 /* Decrypt S/MIME message */ 49 /* Decrypt S/MIME message */
50 if (!CMS_decrypt(cms, rkey, rcert, out, NULL, 0)) 50 if (!CMS_decrypt(cms, rkey, rcert, NULL, out, 0))
51 goto err; 51 goto err;
52 52
53 ret = 0; 53 ret = 0;
diff --git a/src/lib/libssl/src/demos/cms/cms_sign.c b/src/lib/libssl/src/demos/cms/cms_sign.c
index 42f762034b..6823c34a0e 100644
--- a/src/lib/libssl/src/demos/cms/cms_sign.c
+++ b/src/lib/libssl/src/demos/cms/cms_sign.c
@@ -12,7 +12,7 @@ int main(int argc, char **argv)
12 int ret = 1; 12 int ret = 1;
13 13
14 /* For simple S/MIME signing use CMS_DETACHED. 14 /* For simple S/MIME signing use CMS_DETACHED.
15 * On OpenSSL 0.9.9 only: 15 * On OpenSSL 1.0.0 only:
16 * for streaming detached set CMS_DETACHED|CMS_STREAM 16 * for streaming detached set CMS_DETACHED|CMS_STREAM
17 * for streaming non-detached set CMS_STREAM 17 * for streaming non-detached set CMS_STREAM
18 */ 18 */
diff --git a/src/lib/libssl/src/doc/apps/ec.pod b/src/lib/libssl/src/doc/apps/ec.pod
index ba6dc4689b..5c7b45d4e7 100644
--- a/src/lib/libssl/src/doc/apps/ec.pod
+++ b/src/lib/libssl/src/doc/apps/ec.pod
@@ -41,7 +41,7 @@ PKCS#8 private key format use the B<pkcs8> command.
41 41
42This specifies the input format. The B<DER> option with a private key uses 42This specifies the input format. The B<DER> option with a private key uses
43an ASN.1 DER encoded SEC1 private key. When used with a public key it 43an ASN.1 DER encoded SEC1 private key. When used with a public key it
44uses the SubjectPublicKeyInfo structur as specified in RFC 3280. 44uses the SubjectPublicKeyInfo structure as specified in RFC 3280.
45The B<PEM> form is the default format: it consists of the B<DER> format base64 45The B<PEM> form is the default format: it consists of the B<DER> format base64
46encoded with additional header and footer lines. In the case of a private key 46encoded with additional header and footer lines. In the case of a private key
47PKCS#8 format is also accepted. 47PKCS#8 format is also accepted.
diff --git a/src/lib/libssl/src/doc/apps/ts.pod b/src/lib/libssl/src/doc/apps/ts.pod
index 7fb6caa96e..d6aa47d314 100644
--- a/src/lib/libssl/src/doc/apps/ts.pod
+++ b/src/lib/libssl/src/doc/apps/ts.pod
@@ -352,7 +352,7 @@ switch always overrides the settings in the config file.
352 352
353This is the main section and it specifies the name of another section 353This is the main section and it specifies the name of another section
354that contains all the options for the B<-reply> command. This default 354that contains all the options for the B<-reply> command. This default
355section can be overriden with the B<-section> command line switch. (Optional) 355section can be overridden with the B<-section> command line switch. (Optional)
356 356
357=item B<oid_file> 357=item B<oid_file>
358 358
@@ -453,7 +453,7 @@ included. Default is no. (Optional)
453=head1 ENVIRONMENT VARIABLES 453=head1 ENVIRONMENT VARIABLES
454 454
455B<OPENSSL_CONF> contains the path of the configuration file and can be 455B<OPENSSL_CONF> contains the path of the configuration file and can be
456overriden by the B<-config> command line option. 456overridden by the B<-config> command line option.
457 457
458=head1 EXAMPLES 458=head1 EXAMPLES
459 459
diff --git a/src/lib/libssl/src/doc/apps/tsget.pod b/src/lib/libssl/src/doc/apps/tsget.pod
index b05957beea..56db985c4b 100644
--- a/src/lib/libssl/src/doc/apps/tsget.pod
+++ b/src/lib/libssl/src/doc/apps/tsget.pod
@@ -124,7 +124,7 @@ The name of an EGD socket to get random data from. (Optional)
124=item [request]... 124=item [request]...
125 125
126List of files containing B<RFC 3161> DER-encoded time stamp requests. If no 126List of files containing B<RFC 3161> DER-encoded time stamp requests. If no
127requests are specifed only one request will be sent to the server and it will be 127requests are specified only one request will be sent to the server and it will be
128read from the standard input. (Optional) 128read from the standard input. (Optional)
129 129
130=back 130=back
diff --git a/src/lib/libssl/src/doc/crypto/BN_BLINDING_new.pod b/src/lib/libssl/src/doc/crypto/BN_BLINDING_new.pod
index 5f51fdb470..da06e44461 100644
--- a/src/lib/libssl/src/doc/crypto/BN_BLINDING_new.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_BLINDING_new.pod
@@ -48,7 +48,7 @@ necessary parameters are set, by re-creating the blinding parameters.
48 48
49BN_BLINDING_convert_ex() multiplies B<n> with the blinding factor B<A>. 49BN_BLINDING_convert_ex() multiplies B<n> with the blinding factor B<A>.
50If B<r> is not NULL a copy the inverse blinding factor B<Ai> will be 50If B<r> is not NULL a copy the inverse blinding factor B<Ai> will be
51returned in B<r> (this is useful if a B<RSA> object is shared amoung 51returned in B<r> (this is useful if a B<RSA> object is shared among
52several threads). BN_BLINDING_invert_ex() multiplies B<n> with the 52several threads). BN_BLINDING_invert_ex() multiplies B<n> with the
53inverse blinding factor B<Ai>. If B<r> is not NULL it will be used as 53inverse blinding factor B<Ai>. If B<r> is not NULL it will be used as
54the inverse blinding. 54the inverse blinding.
diff --git a/src/lib/libssl/src/doc/crypto/EVP_PKEY_CTX_ctrl.pod b/src/lib/libssl/src/doc/crypto/EVP_PKEY_CTX_ctrl.pod
index f2f455990f..13b91f1e6e 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_PKEY_CTX_ctrl.pod
+++ b/src/lib/libssl/src/doc/crypto/EVP_PKEY_CTX_ctrl.pod
@@ -117,7 +117,7 @@ L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>,
117L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>, 117L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>,
118L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>, 118L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
119L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>, 119L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
120L<EVP_PKEY_verifyrecover(3)|EVP_PKEY_verifyrecover(3)>, 120L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
121L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)> 121L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)>
122L<EVP_PKEY_keygen(3)|EVP_PKEY_keygen(3)> 122L<EVP_PKEY_keygen(3)|EVP_PKEY_keygen(3)>
123 123
diff --git a/src/lib/libssl/src/doc/crypto/EVP_PKEY_decrypt.pod b/src/lib/libssl/src/doc/crypto/EVP_PKEY_decrypt.pod
index 42b2a8c44e..847983237b 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_PKEY_decrypt.pod
+++ b/src/lib/libssl/src/doc/crypto/EVP_PKEY_decrypt.pod
@@ -83,7 +83,7 @@ L<EVP_PKEY_CTX_new(3)|EVP_PKEY_CTX_new(3)>,
83L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>, 83L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>,
84L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>, 84L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
85L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>, 85L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
86L<EVP_PKEY_verifyrecover(3)|EVP_PKEY_verifyrecover(3)>, 86L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
87L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)> 87L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)>
88 88
89=head1 HISTORY 89=head1 HISTORY
diff --git a/src/lib/libssl/src/doc/crypto/EVP_PKEY_derive.pod b/src/lib/libssl/src/doc/crypto/EVP_PKEY_derive.pod
index d9d6d76c72..27464be571 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_PKEY_derive.pod
+++ b/src/lib/libssl/src/doc/crypto/EVP_PKEY_derive.pod
@@ -84,7 +84,7 @@ L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>,
84L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>, 84L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>,
85L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>, 85L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
86L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>, 86L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
87L<EVP_PKEY_verifyrecover(3)|EVP_PKEY_verifyrecover(3)>, 87L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
88 88
89=head1 HISTORY 89=head1 HISTORY
90 90
diff --git a/src/lib/libssl/src/doc/crypto/EVP_PKEY_encrypt.pod b/src/lib/libssl/src/doc/crypto/EVP_PKEY_encrypt.pod
index 91c9c5d0a5..e495a81242 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_PKEY_encrypt.pod
+++ b/src/lib/libssl/src/doc/crypto/EVP_PKEY_encrypt.pod
@@ -83,7 +83,7 @@ L<EVP_PKEY_CTX_new(3)|EVP_PKEY_CTX_new(3)>,
83L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>, 83L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>,
84L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>, 84L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
85L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>, 85L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
86L<EVP_PKEY_verifyrecover(3)|EVP_PKEY_verifyrecover(3)>, 86L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
87L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)> 87L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)>
88 88
89=head1 HISTORY 89=head1 HISTORY
diff --git a/src/lib/libssl/src/doc/crypto/EVP_PKEY_get_default_digest.pod b/src/lib/libssl/src/doc/crypto/EVP_PKEY_get_default_digest.pod
index 1a9c7954c5..8ff597d44a 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_PKEY_get_default_digest.pod
+++ b/src/lib/libssl/src/doc/crypto/EVP_PKEY_get_default_digest.pod
@@ -32,7 +32,7 @@ public key algorithm.
32L<EVP_PKEY_CTX_new(3)|EVP_PKEY_CTX_new(3)>, 32L<EVP_PKEY_CTX_new(3)|EVP_PKEY_CTX_new(3)>,
33L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>, 33L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
34L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>, 34L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
35L<EVP_PKEY_verifyrecover(3)|EVP_PKEY_verifyrecover(3)>, 35L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
36 36
37=head1 HISTORY 37=head1 HISTORY
38 38
diff --git a/src/lib/libssl/src/doc/crypto/EVP_PKEY_keygen.pod b/src/lib/libssl/src/doc/crypto/EVP_PKEY_keygen.pod
index 37c6fe9503..fd431ace6d 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_PKEY_keygen.pod
+++ b/src/lib/libssl/src/doc/crypto/EVP_PKEY_keygen.pod
@@ -151,7 +151,7 @@ L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>,
151L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>, 151L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>,
152L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>, 152L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
153L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>, 153L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
154L<EVP_PKEY_verifyrecover(3)|EVP_PKEY_verifyrecover(3)>, 154L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
155L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)> 155L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)>
156 156
157=head1 HISTORY 157=head1 HISTORY
diff --git a/src/lib/libssl/src/doc/crypto/EVP_PKEY_sign.pod b/src/lib/libssl/src/doc/crypto/EVP_PKEY_sign.pod
index 2fb52c3486..a044f2c131 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_PKEY_sign.pod
+++ b/src/lib/libssl/src/doc/crypto/EVP_PKEY_sign.pod
@@ -86,7 +86,7 @@ L<EVP_PKEY_CTX_new(3)|EVP_PKEY_CTX_new(3)>,
86L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>, 86L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>,
87L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>, 87L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>,
88L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>, 88L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
89L<EVP_PKEY_verifyrecover(3)|EVP_PKEY_verifyrecover(3)>, 89L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
90L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)> 90L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)>
91 91
92=head1 HISTORY 92=head1 HISTORY
diff --git a/src/lib/libssl/src/doc/crypto/EVP_PKEY_verify.pod b/src/lib/libssl/src/doc/crypto/EVP_PKEY_verify.pod
index f93e5fc6c3..90612ba2f0 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_PKEY_verify.pod
+++ b/src/lib/libssl/src/doc/crypto/EVP_PKEY_verify.pod
@@ -81,7 +81,7 @@ L<EVP_PKEY_CTX_new(3)|EVP_PKEY_CTX_new(3)>,
81L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>, 81L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>,
82L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>, 82L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>,
83L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>, 83L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
84L<EVP_PKEY_verifyrecover(3)|EVP_PKEY_verifyrecover(3)>, 84L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
85L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)> 85L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)>
86 86
87=head1 HISTORY 87=head1 HISTORY
diff --git a/src/lib/libssl/src/doc/crypto/EVP_PKEY_verify_recover.pod b/src/lib/libssl/src/doc/crypto/EVP_PKEY_verify_recover.pod
new file mode 100644
index 0000000000..23a28a9c43
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/EVP_PKEY_verify_recover.pod
@@ -0,0 +1,103 @@
1=pod
2
3=head1 NAME
4
5EVP_PKEY_verify_recover_init, EVP_PKEY_verify_recover - recover signature using a public key algorithm
6
7=head1 SYNOPSIS
8
9 #include <openssl/evp.h>
10
11 int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx);
12 int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,
13 unsigned char *rout, size_t *routlen,
14 const unsigned char *sig, size_t siglen);
15
16=head1 DESCRIPTION
17
18The EVP_PKEY_verify_recover_init() function initializes a public key algorithm
19context using key B<pkey> for a verify recover operation.
20
21The EVP_PKEY_verify_recover() function recovers signed data
22using B<ctx>. The signature is specified using the B<sig> and
23B<siglen> parameters. If B<rout> is B<NULL> then the maximum size of the output
24buffer is written to the B<routlen> parameter. If B<rout> is not B<NULL> then
25before the call the B<routlen> parameter should contain the length of the
26B<rout> buffer, if the call is successful recovered data is written to
27B<rout> and the amount of data written to B<routlen>.
28
29=head1 NOTES
30
31Normally an application is only interested in whether a signature verification
32operation is successful in those cases the EVP_verify() function should be
33used.
34
35Sometimes however it is useful to obtain the data originally signed using a
36signing operation. Only certain public key algorithms can recover a signature
37in this way (for example RSA in PKCS padding mode).
38
39After the call to EVP_PKEY_verify_recover_init() algorithm specific control
40operations can be performed to set any appropriate parameters for the
41operation.
42
43The function EVP_PKEY_verify_recover() can be called more than once on the same
44context if several operations are performed using the same parameters.
45
46=head1 RETURN VALUES
47
48EVP_PKEY_verify_recover_init() and EVP_PKEY_verify_recover() return 1 for success
49and 0 or a negative value for failure. In particular a return value of -2
50indicates the operation is not supported by the public key algorithm.
51
52=head1 EXAMPLE
53
54Recover digest originally signed using PKCS#1 and SHA256 digest:
55
56 #include <openssl/evp.h>
57 #include <openssl/rsa.h>
58
59 EVP_PKEY_CTX *ctx;
60 unsigned char *rout, *sig;
61 size_t routlen, siglen;
62 EVP_PKEY *verify_key;
63 /* NB: assumes verify_key, sig and siglen are already set up
64 * and that verify_key is an RSA public key
65 */
66 ctx = EVP_PKEY_CTX_new(verify_key);
67 if (!ctx)
68 /* Error occurred */
69 if (EVP_PKEY_verify_recover_init(ctx) <= 0)
70 /* Error */
71 if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0)
72 /* Error */
73 if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0)
74 /* Error */
75
76 /* Determine buffer length */
77 if (EVP_PKEY_verify_recover(ctx, NULL, &routlen, sig, siglen) <= 0)
78 /* Error */
79
80 rout = OPENSSL_malloc(routlen);
81
82 if (!rout)
83 /* malloc failure */
84
85 if (EVP_PKEY_verify_recover(ctx, rout, &routlen, sig, siglen) <= 0)
86 /* Error */
87
88 /* Recovered data is routlen bytes written to buffer rout */
89
90=head1 SEE ALSO
91
92L<EVP_PKEY_CTX_new(3)|EVP_PKEY_CTX_new(3)>,
93L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>,
94L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>,
95L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
96L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
97L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)>
98
99=head1 HISTORY
100
101These functions were first added to OpenSSL 1.0.0.
102
103=cut
diff --git a/src/lib/libssl/src/doc/crypto/X509_STORE_CTX_get_error.pod b/src/lib/libssl/src/doc/crypto/X509_STORE_CTX_get_error.pod
index a883f6c097..60e8332ae9 100644
--- a/src/lib/libssl/src/doc/crypto/X509_STORE_CTX_get_error.pod
+++ b/src/lib/libssl/src/doc/crypto/X509_STORE_CTX_get_error.pod
@@ -278,6 +278,8 @@ happen if extended CRL checking is enabled.
278an application specific error. This will never be returned unless explicitly 278an application specific error. This will never be returned unless explicitly
279set by an application. 279set by an application.
280 280
281=back
282
281=head1 NOTES 283=head1 NOTES
282 284
283The above functions should be used instead of directly referencing the fields 285The above functions should be used instead of directly referencing the fields
diff --git a/src/lib/libssl/src/doc/crypto/X509_VERIFY_PARAM_set_flags.pod b/src/lib/libssl/src/doc/crypto/X509_VERIFY_PARAM_set_flags.pod
index b68eece033..46cac2bea2 100644
--- a/src/lib/libssl/src/doc/crypto/X509_VERIFY_PARAM_set_flags.pod
+++ b/src/lib/libssl/src/doc/crypto/X509_VERIFY_PARAM_set_flags.pod
@@ -113,7 +113,7 @@ a special status code is set to the verification callback. This permits it
113to examine the valid policy tree and perform additional checks or simply 113to examine the valid policy tree and perform additional checks or simply
114log it for debugging purposes. 114log it for debugging purposes.
115 115
116By default some addtional features such as indirect CRLs and CRLs signed by 116By default some additional features such as indirect CRLs and CRLs signed by
117different keys are disabled. If B<X509_V_FLAG_EXTENDED_CRL_SUPPORT> is set 117different keys are disabled. If B<X509_V_FLAG_EXTENDED_CRL_SUPPORT> is set
118they are enabled. 118they are enabled.
119 119
diff --git a/src/lib/libssl/src/doc/crypto/ecdsa.pod b/src/lib/libssl/src/doc/crypto/ecdsa.pod
index 20edff97ff..59a5916de1 100644
--- a/src/lib/libssl/src/doc/crypto/ecdsa.pod
+++ b/src/lib/libssl/src/doc/crypto/ecdsa.pod
@@ -95,7 +95,7 @@ is ignored.
95 95
96ECDSA_verify() verifies that the signature in B<sig> of size 96ECDSA_verify() verifies that the signature in B<sig> of size
97B<siglen> is a valid ECDSA signature of the hash value 97B<siglen> is a valid ECDSA signature of the hash value
98value B<dgst> of size B<dgstlen> using the public key B<eckey>. 98B<dgst> of size B<dgstlen> using the public key B<eckey>.
99The parameter B<type> is ignored. 99The parameter B<type> is ignored.
100 100
101ECDSA_do_sign() is wrapper function for ECDSA_do_sign_ex with B<kinv> 101ECDSA_do_sign() is wrapper function for ECDSA_do_sign_ex with B<kinv>
@@ -131,16 +131,12 @@ specific)
131 131
132 int ret; 132 int ret;
133 ECDSA_SIG *sig; 133 ECDSA_SIG *sig;
134 EC_KEY *eckey = EC_KEY_new(); 134 EC_KEY *eckey;
135 eckey = EC_KEY_new_by_curve_name(NID_secp192k1);
135 if (eckey == NULL) 136 if (eckey == NULL)
136 { 137 {
137 /* error */ 138 /* error */
138 } 139 }
139 key->group = EC_GROUP_new_by_nid(NID_secp192k1);
140 if (key->group == NULL)
141 {
142 /* error */
143 }
144 if (!EC_KEY_generate_key(eckey)) 140 if (!EC_KEY_generate_key(eckey))
145 { 141 {
146 /* error */ 142 /* error */
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_use_psk_identity_hint.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_use_psk_identity_hint.pod
index b80e25be7e..7e60df5ba8 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_use_psk_identity_hint.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_use_psk_identity_hint.pod
@@ -81,6 +81,8 @@ SSL_CTX_use_psk_identity_hint() and SSL_use_psk_identity_hint() return
81 81
82Return values from the server callback are interpreted as follows: 82Return values from the server callback are interpreted as follows:
83 83
84=over 4
85
84=item > 0 86=item > 0
85 87
86PSK identity was found and the server callback has provided the PSK 88PSK identity was found and the server callback has provided the PSK
@@ -99,4 +101,6 @@ completely.
99PSK identity was not found. An "unknown_psk_identity" alert message 101PSK identity was not found. An "unknown_psk_identity" alert message
100will be sent and the connection setup fails. 102will be sent and the connection setup fails.
101 103
104=back
105
102=cut 106=cut
diff --git a/src/lib/libssl/src/engines/ccgost/gost89.c b/src/lib/libssl/src/engines/ccgost/gost89.c
index 7ebae0f71f..b0568c6b3c 100644
--- a/src/lib/libssl/src/engines/ccgost/gost89.c
+++ b/src/lib/libssl/src/engines/ccgost/gost89.c
@@ -369,7 +369,13 @@ int gost_mac(gost_ctx *ctx,int mac_len,const unsigned char *data,
369 memset(buf2,0,8); 369 memset(buf2,0,8);
370 memcpy(buf2,data+i,data_len-i); 370 memcpy(buf2,data+i,data_len-i);
371 mac_block(ctx,buffer,buf2); 371 mac_block(ctx,buffer,buf2);
372 } 372 i+=8;
373 }
374 if (i==8)
375 {
376 memset(buf2,0,8);
377 mac_block(ctx,buffer,buf2);
378 }
373 get_mac(buffer,mac_len,mac); 379 get_mac(buffer,mac_len,mac);
374 return 1; 380 return 1;
375 } 381 }
@@ -389,7 +395,13 @@ int gost_mac_iv(gost_ctx *ctx,int mac_len,const unsigned char *iv,const unsigned
389 memset(buf2,0,8); 395 memset(buf2,0,8);
390 memcpy(buf2,data+i,data_len-i); 396 memcpy(buf2,data+i,data_len-i);
391 mac_block(ctx,buffer,buf2); 397 mac_block(ctx,buffer,buf2);
398 i+=8;
392 } 399 }
400 if (i==8)
401 {
402 memset(buf2,0,8);
403 mac_block(ctx,buffer,buf2);
404 }
393 get_mac(buffer,mac_len,mac); 405 get_mac(buffer,mac_len,mac);
394 return 1; 406 return 1;
395 } 407 }
diff --git a/src/lib/libssl/src/engines/ccgost/gost89.h b/src/lib/libssl/src/engines/ccgost/gost89.h
index 2157852519..8da2407b03 100644
--- a/src/lib/libssl/src/engines/ccgost/gost89.h
+++ b/src/lib/libssl/src/engines/ccgost/gost89.h
@@ -87,10 +87,6 @@ extern gost_subst_block Gost28147_CryptoProParamSetB;
87extern gost_subst_block Gost28147_CryptoProParamSetC; 87extern gost_subst_block Gost28147_CryptoProParamSetC;
88extern gost_subst_block Gost28147_CryptoProParamSetD; 88extern gost_subst_block Gost28147_CryptoProParamSetD;
89extern const byte CryptoProKeyMeshingKey[]; 89extern const byte CryptoProKeyMeshingKey[];
90#if __LONG_MAX__ > 2147483647L
91typedef unsigned int word32; 90typedef unsigned int word32;
92#else
93typedef unsigned long word32;
94#endif
95 91
96#endif 92#endif
diff --git a/src/lib/libssl/src/engines/ccgost/gost_crypt.c b/src/lib/libssl/src/engines/ccgost/gost_crypt.c
index cde58c0e9b..52aef15acf 100644
--- a/src/lib/libssl/src/engines/ccgost/gost_crypt.c
+++ b/src/lib/libssl/src/engines/ccgost/gost_crypt.c
@@ -11,6 +11,14 @@
11#include <openssl/rand.h> 11#include <openssl/rand.h>
12#include "e_gost_err.h" 12#include "e_gost_err.h"
13#include "gost_lcl.h" 13#include "gost_lcl.h"
14
15#if !defined(CCGOST_DEBUG) && !defined(DEBUG)
16# ifndef NDEBUG
17# define NDEBUG
18# endif
19#endif
20#include <assert.h>
21
14static int gost_cipher_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, 22static int gost_cipher_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
15 const unsigned char *iv, int enc); 23 const unsigned char *iv, int enc);
16static int gost_cipher_init_cpa(EVP_CIPHER_CTX *ctx, const unsigned char *key, 24static int gost_cipher_init_cpa(EVP_CIPHER_CTX *ctx, const unsigned char *key,
@@ -206,12 +214,13 @@ int gost_cipher_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
206static void gost_crypt_mesh (void *ctx,unsigned char *iv,unsigned char *buf) 214static void gost_crypt_mesh (void *ctx,unsigned char *iv,unsigned char *buf)
207 { 215 {
208 struct ossl_gost_cipher_ctx *c = ctx; 216 struct ossl_gost_cipher_ctx *c = ctx;
209 if (c->count&&c->key_meshing && c->count%1024==0) 217 assert(c->count%8 == 0 && c->count <= 1024);
218 if (c->key_meshing && c->count==1024)
210 { 219 {
211 cryptopro_key_meshing(&(c->cctx),iv); 220 cryptopro_key_meshing(&(c->cctx),iv);
212 } 221 }
213 gostcrypt(&(c->cctx),iv,buf); 222 gostcrypt(&(c->cctx),iv,buf);
214 c->count+=8; 223 c->count = c->count%1024 + 8;
215 } 224 }
216 225
217static void gost_cnt_next (void *ctx, unsigned char *iv, unsigned char *buf) 226static void gost_cnt_next (void *ctx, unsigned char *iv, unsigned char *buf)
@@ -219,7 +228,8 @@ static void gost_cnt_next (void *ctx, unsigned char *iv, unsigned char *buf)
219 struct ossl_gost_cipher_ctx *c = ctx; 228 struct ossl_gost_cipher_ctx *c = ctx;
220 word32 g,go; 229 word32 g,go;
221 unsigned char buf1[8]; 230 unsigned char buf1[8];
222 if (c->count && c->key_meshing && c->count %1024 ==0) 231 assert(c->count%8 == 0 && c->count <= 1024);
232 if (c->key_meshing && c->count==1024)
223 { 233 {
224 cryptopro_key_meshing(&(c->cctx),iv); 234 cryptopro_key_meshing(&(c->cctx),iv);
225 } 235 }
@@ -248,7 +258,7 @@ static void gost_cnt_next (void *ctx, unsigned char *iv, unsigned char *buf)
248 buf1[7]=(unsigned char)((g>>24)&0xff); 258 buf1[7]=(unsigned char)((g>>24)&0xff);
249 memcpy(iv,buf1,8); 259 memcpy(iv,buf1,8);
250 gostcrypt(&(c->cctx),buf1,buf); 260 gostcrypt(&(c->cctx),buf1,buf);
251 c->count +=8; 261 c->count = c->count%1024 + 8;
252 } 262 }
253 263
254/* GOST encryption in CFB mode */ 264/* GOST encryption in CFB mode */
@@ -511,12 +521,13 @@ static void mac_block_mesh(struct ossl_gost_imit_ctx *c,const unsigned char *dat
511 * interpret internal state of MAC algorithm as iv during keymeshing 521 * interpret internal state of MAC algorithm as iv during keymeshing
512 * (but does initialize internal state from iv in key transport 522 * (but does initialize internal state from iv in key transport
513 */ 523 */
514 if (c->key_meshing&& c->count && c->count %1024 ==0) 524 assert(c->count%8 == 0 && c->count <= 1024);
525 if (c->key_meshing && c->count==1024)
515 { 526 {
516 cryptopro_key_meshing(&(c->cctx),buffer); 527 cryptopro_key_meshing(&(c->cctx),buffer);
517 } 528 }
518 mac_block(&(c->cctx),c->buffer,data); 529 mac_block(&(c->cctx),c->buffer,data);
519 c->count +=8; 530 c->count = c->count%1024 + 8;
520 } 531 }
521 532
522int gost_imit_update(EVP_MD_CTX *ctx, const void *data, size_t count) 533int gost_imit_update(EVP_MD_CTX *ctx, const void *data, size_t count)
@@ -565,6 +576,12 @@ int gost_imit_final(EVP_MD_CTX *ctx,unsigned char *md)
565 GOSTerr(GOST_F_GOST_IMIT_FINAL, GOST_R_MAC_KEY_NOT_SET); 576 GOSTerr(GOST_F_GOST_IMIT_FINAL, GOST_R_MAC_KEY_NOT_SET);
566 return 0; 577 return 0;
567 } 578 }
579 if (c->count==0 && c->bytes_left)
580 {
581 unsigned char buffer[8];
582 memset(buffer, 0, 8);
583 gost_imit_update(ctx, buffer, 8);
584 }
568 if (c->bytes_left) 585 if (c->bytes_left)
569 { 586 {
570 int i; 587 int i;
diff --git a/src/lib/libssl/src/engines/ccgost/gost_eng.c b/src/lib/libssl/src/engines/ccgost/gost_eng.c
index d2cbe3b831..8f29bf6f85 100644
--- a/src/lib/libssl/src/engines/ccgost/gost_eng.c
+++ b/src/lib/libssl/src/engines/ccgost/gost_eng.c
@@ -64,6 +64,13 @@ static int gost_engine_finish(ENGINE *e)
64static int gost_engine_destroy(ENGINE *e) 64static int gost_engine_destroy(ENGINE *e)
65 { 65 {
66 gost_param_free(); 66 gost_param_free();
67
68 pmeth_GostR3410_94 = NULL;
69 pmeth_GostR3410_2001 = NULL;
70 pmeth_Gost28147_MAC = NULL;
71 ameth_GostR3410_94 = NULL;
72 ameth_GostR3410_2001 = NULL;
73 ameth_Gost28147_MAC = NULL;
67 return 1; 74 return 1;
68 } 75 }
69 76
@@ -71,6 +78,11 @@ static int bind_gost (ENGINE *e,const char *id)
71 { 78 {
72 int ret = 0; 79 int ret = 0;
73 if (id && strcmp(id, engine_gost_id)) return 0; 80 if (id && strcmp(id, engine_gost_id)) return 0;
81 if (ameth_GostR3410_94)
82 {
83 printf("GOST engine already loaded\n");
84 goto end;
85 }
74 86
75 if (!ENGINE_set_id(e, engine_gost_id)) 87 if (!ENGINE_set_id(e, engine_gost_id))
76 { 88 {
@@ -263,7 +275,10 @@ static ENGINE *engine_gost(void)
263 275
264void ENGINE_load_gost(void) 276void ENGINE_load_gost(void)
265 { 277 {
266 ENGINE *toadd =engine_gost(); 278 ENGINE *toadd;
279 if (pmeth_GostR3410_94)
280 return;
281 toadd = engine_gost();
267 if (!toadd) return; 282 if (!toadd) return;
268 ENGINE_add(toadd); 283 ENGINE_add(toadd);
269 ENGINE_free(toadd); 284 ENGINE_free(toadd);
diff --git a/src/lib/libssl/src/engines/ccgost/gost_lcl.h b/src/lib/libssl/src/engines/ccgost/gost_lcl.h
index 437a48cc86..00aa42cea4 100644
--- a/src/lib/libssl/src/engines/ccgost/gost_lcl.h
+++ b/src/lib/libssl/src/engines/ccgost/gost_lcl.h
@@ -136,7 +136,7 @@ extern EVP_MD imit_gost_cpa;
136/* Cipher context used for EVP_CIPHER operation */ 136/* Cipher context used for EVP_CIPHER operation */
137struct ossl_gost_cipher_ctx { 137struct ossl_gost_cipher_ctx {
138 int paramNID; 138 int paramNID;
139 off_t count; 139 unsigned int count;
140 int key_meshing; 140 int key_meshing;
141 gost_ctx cctx; 141 gost_ctx cctx;
142}; 142};
@@ -151,7 +151,7 @@ struct ossl_gost_imit_ctx {
151 gost_ctx cctx; 151 gost_ctx cctx;
152 unsigned char buffer[8]; 152 unsigned char buffer[8];
153 unsigned char partial_block[8]; 153 unsigned char partial_block[8];
154 off_t count; 154 unsigned int count;
155 int key_meshing; 155 int key_meshing;
156 int bytes_left; 156 int bytes_left;
157 int key_set; 157 int key_set;
diff --git a/src/lib/libssl/src/engines/ccgost/gosthash.c b/src/lib/libssl/src/engines/ccgost/gosthash.c
index a5c0662ffc..91b2ce8829 100644
--- a/src/lib/libssl/src/engines/ccgost/gosthash.c
+++ b/src/lib/libssl/src/engines/ccgost/gosthash.c
@@ -42,7 +42,7 @@ static void circle_xor8 (const byte *w, byte *k)
42 byte buf[8]; 42 byte buf[8];
43 int i; 43 int i;
44 memcpy(buf,w,8); 44 memcpy(buf,w,8);
45 memcpy(k,w+8,24); 45 memmove(k,w+8,24);
46 for(i=0;i<8;i++) 46 for(i=0;i<8;i++)
47 k[i+24]=buf[i]^k[i]; 47 k[i+24]=buf[i]^k[i];
48 } 48 }
@@ -180,8 +180,6 @@ int start_hash(gost_hash_ctx *ctx)
180 */ 180 */
181int hash_block(gost_hash_ctx *ctx,const byte *block, size_t length) 181int hash_block(gost_hash_ctx *ctx,const byte *block, size_t length)
182 { 182 {
183 const byte *curptr=block;
184 const byte *barrier=block+(length-32);/* Last byte we can safely hash*/
185 if (ctx->left) 183 if (ctx->left)
186 { 184 {
187 /*There are some bytes from previous step*/ 185 /*There are some bytes from previous step*/
@@ -196,24 +194,25 @@ int hash_block(gost_hash_ctx *ctx,const byte *block, size_t length)
196 { 194 {
197 return 1; 195 return 1;
198 } 196 }
199 curptr=block+add_bytes; 197 block+=add_bytes;
198 length-=add_bytes;
200 hash_step(ctx->cipher_ctx,ctx->H,ctx->remainder); 199 hash_step(ctx->cipher_ctx,ctx->H,ctx->remainder);
201 add_blocks(32,ctx->S,ctx->remainder); 200 add_blocks(32,ctx->S,ctx->remainder);
202 ctx->len+=32; 201 ctx->len+=32;
203 ctx->left=0; 202 ctx->left=0;
204 } 203 }
205 while (curptr<=barrier) 204 while (length>=32)
206 { 205 {
207 hash_step(ctx->cipher_ctx,ctx->H,curptr); 206 hash_step(ctx->cipher_ctx,ctx->H,block);
208 207
209 add_blocks(32,ctx->S,curptr); 208 add_blocks(32,ctx->S,block);
210 ctx->len+=32; 209 ctx->len+=32;
211 curptr+=32; 210 block+=32;
211 length-=32;
212 } 212 }
213 if (curptr!=block+length) 213 if (length)
214 { 214 {
215 ctx->left=block+length-curptr; 215 memcpy(ctx->remainder,block,ctx->left=length);
216 memcpy(ctx->remainder,curptr,ctx->left);
217 } 216 }
218 return 1; 217 return 1;
219 } 218 }
diff --git a/src/lib/libssl/src/engines/e_capi.c b/src/lib/libssl/src/engines/e_capi.c
index bfedde0eb0..c1085b56cd 100644
--- a/src/lib/libssl/src/engines/e_capi.c
+++ b/src/lib/libssl/src/engines/e_capi.c
@@ -1432,10 +1432,13 @@ static PCCERT_CONTEXT capi_find_cert(CAPI_CTX *ctx, const char *id, HCERTSTORE h
1432static CAPI_KEY *capi_get_key(CAPI_CTX *ctx, const char *contname, char *provname, DWORD ptype, DWORD keyspec) 1432static CAPI_KEY *capi_get_key(CAPI_CTX *ctx, const char *contname, char *provname, DWORD ptype, DWORD keyspec)
1433 { 1433 {
1434 CAPI_KEY *key; 1434 CAPI_KEY *key;
1435 DWORD dwFlags = 0;
1435 key = OPENSSL_malloc(sizeof(CAPI_KEY)); 1436 key = OPENSSL_malloc(sizeof(CAPI_KEY));
1436 CAPI_trace(ctx, "capi_get_key, contname=%s, provname=%s, type=%d\n", 1437 CAPI_trace(ctx, "capi_get_key, contname=%s, provname=%s, type=%d\n",
1437 contname, provname, ptype); 1438 contname, provname, ptype);
1438 if (!CryptAcquireContextA(&key->hprov, contname, provname, ptype, 0)) 1439 if(ctx->store_flags & CERT_SYSTEM_STORE_LOCAL_MACHINE)
1440 dwFlags = CRYPT_MACHINE_KEYSET;
1441 if (!CryptAcquireContextA(&key->hprov, contname, provname, ptype, dwFlags))
1439 { 1442 {
1440 CAPIerr(CAPI_F_CAPI_GET_KEY, CAPI_R_CRYPTACQUIRECONTEXT_ERROR); 1443 CAPIerr(CAPI_F_CAPI_GET_KEY, CAPI_R_CRYPTACQUIRECONTEXT_ERROR);
1441 capi_addlasterror(); 1444 capi_addlasterror();
diff --git a/src/lib/libssl/src/ssl/d1_both.c b/src/lib/libssl/src/ssl/d1_both.c
index de8bab873f..2e8cf681ed 100644
--- a/src/lib/libssl/src/ssl/d1_both.c
+++ b/src/lib/libssl/src/ssl/d1_both.c
@@ -214,6 +214,12 @@ dtls1_hm_fragment_new(unsigned long frag_len, int reassembly)
214static void 214static void
215dtls1_hm_fragment_free(hm_fragment *frag) 215dtls1_hm_fragment_free(hm_fragment *frag)
216 { 216 {
217
218 if (frag->msg_header.is_ccs)
219 {
220 EVP_CIPHER_CTX_free(frag->msg_header.saved_retransmit_state.enc_write_ctx);
221 EVP_MD_CTX_destroy(frag->msg_header.saved_retransmit_state.write_hash);
222 }
217 if (frag->fragment) OPENSSL_free(frag->fragment); 223 if (frag->fragment) OPENSSL_free(frag->fragment);
218 if (frag->reassembly) OPENSSL_free(frag->reassembly); 224 if (frag->reassembly) OPENSSL_free(frag->reassembly);
219 OPENSSL_free(frag); 225 OPENSSL_free(frag);
@@ -313,9 +319,10 @@ int dtls1_do_write(SSL *s, int type)
313 s->init_off -= DTLS1_HM_HEADER_LENGTH; 319 s->init_off -= DTLS1_HM_HEADER_LENGTH;
314 s->init_num += DTLS1_HM_HEADER_LENGTH; 320 s->init_num += DTLS1_HM_HEADER_LENGTH;
315 321
316 /* write atleast DTLS1_HM_HEADER_LENGTH bytes */ 322 if ( s->init_num > curr_mtu)
317 if ( len <= DTLS1_HM_HEADER_LENGTH) 323 len = curr_mtu;
318 len += DTLS1_HM_HEADER_LENGTH; 324 else
325 len = s->init_num;
319 } 326 }
320 327
321 dtls1_fix_message_header(s, frag_off, 328 dtls1_fix_message_header(s, frag_off,
@@ -1452,26 +1459,36 @@ dtls1_process_heartbeat(SSL *s)
1452 unsigned int payload; 1459 unsigned int payload;
1453 unsigned int padding = 16; /* Use minimum padding */ 1460 unsigned int padding = 16; /* Use minimum padding */
1454 1461
1455 /* Read type and payload length first */
1456 hbtype = *p++;
1457 n2s(p, payload);
1458 pl = p;
1459
1460 if (s->msg_callback) 1462 if (s->msg_callback)
1461 s->msg_callback(0, s->version, TLS1_RT_HEARTBEAT, 1463 s->msg_callback(0, s->version, TLS1_RT_HEARTBEAT,
1462 &s->s3->rrec.data[0], s->s3->rrec.length, 1464 &s->s3->rrec.data[0], s->s3->rrec.length,
1463 s, s->msg_callback_arg); 1465 s, s->msg_callback_arg);
1464 1466
1467 /* Read type and payload length first */
1468 if (1 + 2 + 16 > s->s3->rrec.length)
1469 return 0; /* silently discard */
1470 hbtype = *p++;
1471 n2s(p, payload);
1472 if (1 + 2 + payload + 16 > s->s3->rrec.length)
1473 return 0; /* silently discard per RFC 6520 sec. 4 */
1474 pl = p;
1475
1465 if (hbtype == TLS1_HB_REQUEST) 1476 if (hbtype == TLS1_HB_REQUEST)
1466 { 1477 {
1467 unsigned char *buffer, *bp; 1478 unsigned char *buffer, *bp;
1479 unsigned int write_length = 1 /* heartbeat type */ +
1480 2 /* heartbeat length */ +
1481 payload + padding;
1468 int r; 1482 int r;
1469 1483
1484 if (write_length > SSL3_RT_MAX_PLAIN_LENGTH)
1485 return 0;
1486
1470 /* Allocate memory for the response, size is 1 byte 1487 /* Allocate memory for the response, size is 1 byte
1471 * message type, plus 2 bytes payload length, plus 1488 * message type, plus 2 bytes payload length, plus
1472 * payload, plus padding 1489 * payload, plus padding
1473 */ 1490 */
1474 buffer = OPENSSL_malloc(1 + 2 + payload + padding); 1491 buffer = OPENSSL_malloc(write_length);
1475 bp = buffer; 1492 bp = buffer;
1476 1493
1477 /* Enter response type, length and copy payload */ 1494 /* Enter response type, length and copy payload */
@@ -1482,11 +1499,11 @@ dtls1_process_heartbeat(SSL *s)
1482 /* Random padding */ 1499 /* Random padding */
1483 RAND_pseudo_bytes(bp, padding); 1500 RAND_pseudo_bytes(bp, padding);
1484 1501
1485 r = dtls1_write_bytes(s, TLS1_RT_HEARTBEAT, buffer, 3 + payload + padding); 1502 r = dtls1_write_bytes(s, TLS1_RT_HEARTBEAT, buffer, write_length);
1486 1503
1487 if (r >= 0 && s->msg_callback) 1504 if (r >= 0 && s->msg_callback)
1488 s->msg_callback(1, s->version, TLS1_RT_HEARTBEAT, 1505 s->msg_callback(1, s->version, TLS1_RT_HEARTBEAT,
1489 buffer, 3 + payload + padding, 1506 buffer, write_length,
1490 s, s->msg_callback_arg); 1507 s, s->msg_callback_arg);
1491 1508
1492 OPENSSL_free(buffer); 1509 OPENSSL_free(buffer);
diff --git a/src/lib/libssl/src/ssl/d1_clnt.c b/src/lib/libssl/src/ssl/d1_clnt.c
index a6ed09c51d..48e5e06bde 100644
--- a/src/lib/libssl/src/ssl/d1_clnt.c
+++ b/src/lib/libssl/src/ssl/d1_clnt.c
@@ -538,13 +538,6 @@ int dtls1_connect(SSL *s)
538 SSL3_ST_CW_CHANGE_A,SSL3_ST_CW_CHANGE_B); 538 SSL3_ST_CW_CHANGE_A,SSL3_ST_CW_CHANGE_B);
539 if (ret <= 0) goto end; 539 if (ret <= 0) goto end;
540 540
541#ifndef OPENSSL_NO_SCTP
542 /* Change to new shared key of SCTP-Auth,
543 * will be ignored if no SCTP used.
544 */
545 BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL);
546#endif
547
548 s->state=SSL3_ST_CW_FINISHED_A; 541 s->state=SSL3_ST_CW_FINISHED_A;
549 s->init_num=0; 542 s->init_num=0;
550 543
@@ -571,6 +564,16 @@ int dtls1_connect(SSL *s)
571 goto end; 564 goto end;
572 } 565 }
573 566
567#ifndef OPENSSL_NO_SCTP
568 if (s->hit)
569 {
570 /* Change to new shared key of SCTP-Auth,
571 * will be ignored if no SCTP used.
572 */
573 BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL);
574 }
575#endif
576
574 dtls1_reset_seq_numbers(s, SSL3_CC_WRITE); 577 dtls1_reset_seq_numbers(s, SSL3_CC_WRITE);
575 break; 578 break;
576 579
@@ -613,6 +616,13 @@ int dtls1_connect(SSL *s)
613 } 616 }
614 else 617 else
615 { 618 {
619#ifndef OPENSSL_NO_SCTP
620 /* Change to new shared key of SCTP-Auth,
621 * will be ignored if no SCTP used.
622 */
623 BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL);
624#endif
625
616#ifndef OPENSSL_NO_TLSEXT 626#ifndef OPENSSL_NO_TLSEXT
617 /* Allow NewSessionTicket if ticket expected */ 627 /* Allow NewSessionTicket if ticket expected */
618 if (s->tlsext_ticket_expected) 628 if (s->tlsext_ticket_expected)
@@ -773,7 +783,7 @@ int dtls1_client_hello(SSL *s)
773 unsigned char *buf; 783 unsigned char *buf;
774 unsigned char *p,*d; 784 unsigned char *p,*d;
775 unsigned int i,j; 785 unsigned int i,j;
776 unsigned long Time,l; 786 unsigned long l;
777 SSL_COMP *comp; 787 SSL_COMP *comp;
778 788
779 buf=(unsigned char *)s->init_buf->data; 789 buf=(unsigned char *)s->init_buf->data;
@@ -798,13 +808,11 @@ int dtls1_client_hello(SSL *s)
798 808
799 /* if client_random is initialized, reuse it, we are 809 /* if client_random is initialized, reuse it, we are
800 * required to use same upon reply to HelloVerify */ 810 * required to use same upon reply to HelloVerify */
801 for (i=0;p[i]=='\0' && i<sizeof(s->s3->client_random);i++) ; 811 for (i=0;p[i]=='\0' && i<sizeof(s->s3->client_random);i++)
812 ;
802 if (i==sizeof(s->s3->client_random)) 813 if (i==sizeof(s->s3->client_random))
803 { 814 ssl_fill_hello_random(s, 0, p,
804 Time=(unsigned long)time(NULL); /* Time */ 815 sizeof(s->s3->client_random));
805 l2n(Time,p);
806 RAND_pseudo_bytes(p,sizeof(s->s3->client_random)-4);
807 }
808 816
809 /* Do the message type and length last */ 817 /* Do the message type and length last */
810 d=p= &(buf[DTLS1_HM_HEADER_LENGTH]); 818 d=p= &(buf[DTLS1_HM_HEADER_LENGTH]);
diff --git a/src/lib/libssl/src/ssl/d1_enc.c b/src/lib/libssl/src/ssl/d1_enc.c
index 07a5e97ce5..712c4647f2 100644
--- a/src/lib/libssl/src/ssl/d1_enc.c
+++ b/src/lib/libssl/src/ssl/d1_enc.c
@@ -126,20 +126,28 @@
126#include <openssl/des.h> 126#include <openssl/des.h>
127#endif 127#endif
128 128
129/* dtls1_enc encrypts/decrypts the record in |s->wrec| / |s->rrec|, respectively.
130 *
131 * Returns:
132 * 0: (in non-constant time) if the record is publically invalid (i.e. too
133 * short etc).
134 * 1: if the record's padding is valid / the encryption was successful.
135 * -1: if the record's padding/AEAD-authenticator is invalid or, if sending,
136 * an internal error occured. */
129int dtls1_enc(SSL *s, int send) 137int dtls1_enc(SSL *s, int send)
130 { 138 {
131 SSL3_RECORD *rec; 139 SSL3_RECORD *rec;
132 EVP_CIPHER_CTX *ds; 140 EVP_CIPHER_CTX *ds;
133 unsigned long l; 141 unsigned long l;
134 int bs,i,ii,j,k,n=0; 142 int bs,i,j,k,mac_size=0;
135 const EVP_CIPHER *enc; 143 const EVP_CIPHER *enc;
136 144
137 if (send) 145 if (send)
138 { 146 {
139 if (EVP_MD_CTX_md(s->write_hash)) 147 if (EVP_MD_CTX_md(s->write_hash))
140 { 148 {
141 n=EVP_MD_CTX_size(s->write_hash); 149 mac_size=EVP_MD_CTX_size(s->write_hash);
142 if (n < 0) 150 if (mac_size < 0)
143 return -1; 151 return -1;
144 } 152 }
145 ds=s->enc_write_ctx; 153 ds=s->enc_write_ctx;
@@ -164,9 +172,8 @@ int dtls1_enc(SSL *s, int send)
164 { 172 {
165 if (EVP_MD_CTX_md(s->read_hash)) 173 if (EVP_MD_CTX_md(s->read_hash))
166 { 174 {
167 n=EVP_MD_CTX_size(s->read_hash); 175 mac_size=EVP_MD_CTX_size(s->read_hash);
168 if (n < 0) 176 OPENSSL_assert(mac_size >= 0);
169 return -1;
170 } 177 }
171 ds=s->enc_read_ctx; 178 ds=s->enc_read_ctx;
172 rec= &(s->s3->rrec); 179 rec= &(s->s3->rrec);
@@ -231,7 +238,7 @@ int dtls1_enc(SSL *s, int send)
231 if (!send) 238 if (!send)
232 { 239 {
233 if (l == 0 || l%bs != 0) 240 if (l == 0 || l%bs != 0)
234 return -1; 241 return 0;
235 } 242 }
236 243
237 EVP_Cipher(ds,rec->data,rec->input,l); 244 EVP_Cipher(ds,rec->data,rec->input,l);
@@ -246,43 +253,7 @@ int dtls1_enc(SSL *s, int send)
246#endif /* KSSL_DEBUG */ 253#endif /* KSSL_DEBUG */
247 254
248 if ((bs != 1) && !send) 255 if ((bs != 1) && !send)
249 { 256 return tls1_cbc_remove_padding(s, rec, bs, mac_size);
250 ii=i=rec->data[l-1]; /* padding_length */
251 i++;
252 if (s->options&SSL_OP_TLS_BLOCK_PADDING_BUG)
253 {
254 /* First packet is even in size, so check */
255 if ((memcmp(s->s3->read_sequence,
256 "\0\0\0\0\0\0\0\0",8) == 0) && !(ii & 1))
257 s->s3->flags|=TLS1_FLAGS_TLS_PADDING_BUG;
258 if (s->s3->flags & TLS1_FLAGS_TLS_PADDING_BUG)
259 i--;
260 }
261 /* TLS 1.0 does not bound the number of padding bytes by the block size.
262 * All of them must have value 'padding_length'. */
263 if (i + bs > (int)rec->length)
264 {
265 /* Incorrect padding. SSLerr() and ssl3_alert are done
266 * by caller: we don't want to reveal whether this is
267 * a decryption error or a MAC verification failure
268 * (see http://www.openssl.org/~bodo/tls-cbc.txt)
269 */
270 return -1;
271 }
272 for (j=(int)(l-i); j<(int)l; j++)
273 {
274 if (rec->data[j] != ii)
275 {
276 /* Incorrect padding */
277 return -1;
278 }
279 }
280 rec->length-=i;
281
282 rec->data += bs; /* skip the implicit IV */
283 rec->input += bs;
284 rec->length -= bs;
285 }
286 } 257 }
287 return(1); 258 return(1);
288 } 259 }
diff --git a/src/lib/libssl/src/ssl/d1_lib.c b/src/lib/libssl/src/ssl/d1_lib.c
index f61f718183..106939f241 100644
--- a/src/lib/libssl/src/ssl/d1_lib.c
+++ b/src/lib/libssl/src/ssl/d1_lib.c
@@ -196,6 +196,7 @@ void dtls1_free(SSL *s)
196 pqueue_free(s->d1->buffered_app_data.q); 196 pqueue_free(s->d1->buffered_app_data.q);
197 197
198 OPENSSL_free(s->d1); 198 OPENSSL_free(s->d1);
199 s->d1 = NULL;
199 } 200 }
200 201
201void dtls1_clear(SSL *s) 202void dtls1_clear(SSL *s)
diff --git a/src/lib/libssl/src/ssl/d1_pkt.c b/src/lib/libssl/src/ssl/d1_pkt.c
index 987af60835..8186462d4a 100644
--- a/src/lib/libssl/src/ssl/d1_pkt.c
+++ b/src/lib/libssl/src/ssl/d1_pkt.c
@@ -376,15 +376,11 @@ static int
376dtls1_process_record(SSL *s) 376dtls1_process_record(SSL *s)
377{ 377{
378 int i,al; 378 int i,al;
379 int clear=0;
380 int enc_err; 379 int enc_err;
381 SSL_SESSION *sess; 380 SSL_SESSION *sess;
382 SSL3_RECORD *rr; 381 SSL3_RECORD *rr;
383 unsigned int mac_size; 382 unsigned int mac_size, orig_len;
384 unsigned char md[EVP_MAX_MD_SIZE]; 383 unsigned char md[EVP_MAX_MD_SIZE];
385 int decryption_failed_or_bad_record_mac = 0;
386 unsigned char *mac = NULL;
387
388 384
389 rr= &(s->s3->rrec); 385 rr= &(s->s3->rrec);
390 sess = s->session; 386 sess = s->session;
@@ -416,12 +412,16 @@ dtls1_process_record(SSL *s)
416 rr->data=rr->input; 412 rr->data=rr->input;
417 413
418 enc_err = s->method->ssl3_enc->enc(s,0); 414 enc_err = s->method->ssl3_enc->enc(s,0);
419 if (enc_err <= 0) 415 /* enc_err is:
416 * 0: (in non-constant time) if the record is publically invalid.
417 * 1: if the padding is valid
418 * -1: if the padding is invalid */
419 if (enc_err == 0)
420 { 420 {
421 /* To minimize information leaked via timing, we will always 421 /* For DTLS we simply ignore bad packets. */
422 * perform all computations before discarding the message. 422 rr->length = 0;
423 */ 423 s->packet_length = 0;
424 decryption_failed_or_bad_record_mac = 1; 424 goto err;
425 } 425 }
426 426
427#ifdef TLS_DEBUG 427#ifdef TLS_DEBUG
@@ -431,45 +431,62 @@ printf("\n");
431#endif 431#endif
432 432
433 /* r->length is now the compressed data plus mac */ 433 /* r->length is now the compressed data plus mac */
434 if ( (sess == NULL) || 434 if ((sess != NULL) &&
435 (s->enc_read_ctx == NULL) || 435 (s->enc_read_ctx != NULL) &&
436 (s->read_hash == NULL)) 436 (EVP_MD_CTX_md(s->read_hash) != NULL))
437 clear=1;
438
439 if (!clear)
440 { 437 {
441 /* !clear => s->read_hash != NULL => mac_size != -1 */ 438 /* s->read_hash != NULL => mac_size != -1 */
442 int t; 439 unsigned char *mac = NULL;
443 t=EVP_MD_CTX_size(s->read_hash); 440 unsigned char mac_tmp[EVP_MAX_MD_SIZE];
444 OPENSSL_assert(t >= 0); 441 mac_size=EVP_MD_CTX_size(s->read_hash);
445 mac_size=t; 442 OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE);
446 443
447 if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+mac_size) 444 /* kludge: *_cbc_remove_padding passes padding length in rr->type */
445 orig_len = rr->length+((unsigned int)rr->type>>8);
446
447 /* orig_len is the length of the record before any padding was
448 * removed. This is public information, as is the MAC in use,
449 * therefore we can safely process the record in a different
450 * amount of time if it's too short to possibly contain a MAC.
451 */
452 if (orig_len < mac_size ||
453 /* CBC records must have a padding length byte too. */
454 (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE &&
455 orig_len < mac_size+1))
448 { 456 {
449#if 0 /* OK only for stream ciphers (then rr->length is visible from ciphertext anyway) */ 457 al=SSL_AD_DECODE_ERROR;
450 al=SSL_AD_RECORD_OVERFLOW; 458 SSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_LENGTH_TOO_SHORT);
451 SSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG);
452 goto f_err; 459 goto f_err;
453#else
454 decryption_failed_or_bad_record_mac = 1;
455#endif
456 } 460 }
457 /* check the MAC for rr->input (it's in mac_size bytes at the tail) */ 461
458 if (rr->length >= mac_size) 462 if (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE)
459 { 463 {
464 /* We update the length so that the TLS header bytes
465 * can be constructed correctly but we need to extract
466 * the MAC in constant time from within the record,
467 * without leaking the contents of the padding bytes.
468 * */
469 mac = mac_tmp;
470 ssl3_cbc_copy_mac(mac_tmp, rr, mac_size, orig_len);
460 rr->length -= mac_size; 471 rr->length -= mac_size;
461 mac = &rr->data[rr->length];
462 } 472 }
463 else 473 else
464 rr->length = 0;
465 i=s->method->ssl3_enc->mac(s,md,0);
466 if (i < 0 || mac == NULL || memcmp(md, mac, mac_size) != 0)
467 { 474 {
468 decryption_failed_or_bad_record_mac = 1; 475 /* In this case there's no padding, so |orig_len|
476 * equals |rec->length| and we checked that there's
477 * enough bytes for |mac_size| above. */
478 rr->length -= mac_size;
479 mac = &rr->data[rr->length];
469 } 480 }
481
482 i=s->method->ssl3_enc->mac(s,md,0 /* not send */);
483 if (i < 0 || mac == NULL || CRYPTO_memcmp(md, mac, (size_t)mac_size) != 0)
484 enc_err = -1;
485 if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+mac_size)
486 enc_err = -1;
470 } 487 }
471 488
472 if (decryption_failed_or_bad_record_mac) 489 if (enc_err < 0)
473 { 490 {
474 /* decryption failed, silently discard message */ 491 /* decryption failed, silently discard message */
475 rr->length = 0; 492 rr->length = 0;
@@ -830,6 +847,12 @@ start:
830 } 847 }
831 } 848 }
832 849
850 if (s->d1->listen && rr->type != SSL3_RT_HANDSHAKE)
851 {
852 rr->length = 0;
853 goto start;
854 }
855
833 /* we now have a packet which can be read and processed */ 856 /* we now have a packet which can be read and processed */
834 857
835 if (s->s3->change_cipher_spec /* set when we receive ChangeCipherSpec, 858 if (s->s3->change_cipher_spec /* set when we receive ChangeCipherSpec,
@@ -1034,6 +1057,7 @@ start:
1034 !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) && 1057 !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) &&
1035 !s->s3->renegotiate) 1058 !s->s3->renegotiate)
1036 { 1059 {
1060 s->d1->handshake_read_seq++;
1037 s->new_session = 1; 1061 s->new_session = 1;
1038 ssl3_renegotiate(s); 1062 ssl3_renegotiate(s);
1039 if (ssl3_renegotiate_check(s)) 1063 if (ssl3_renegotiate_check(s))
diff --git a/src/lib/libssl/src/ssl/d1_srtp.c b/src/lib/libssl/src/ssl/d1_srtp.c
index 928935bd8b..ab9c41922c 100644
--- a/src/lib/libssl/src/ssl/d1_srtp.c
+++ b/src/lib/libssl/src/ssl/d1_srtp.c
@@ -115,11 +115,12 @@
115 Copyright (C) 2011, RTFM, Inc. 115 Copyright (C) 2011, RTFM, Inc.
116*/ 116*/
117 117
118#ifndef OPENSSL_NO_SRTP
119
120#include <stdio.h> 118#include <stdio.h>
121#include <openssl/objects.h> 119#include <openssl/objects.h>
122#include "ssl_locl.h" 120#include "ssl_locl.h"
121
122#ifndef OPENSSL_NO_SRTP
123
123#include "srtp.h" 124#include "srtp.h"
124 125
125 126
diff --git a/src/lib/libssl/src/ssl/d1_srvr.c b/src/lib/libssl/src/ssl/d1_srvr.c
index 29421da9aa..9975e20873 100644
--- a/src/lib/libssl/src/ssl/d1_srvr.c
+++ b/src/lib/libssl/src/ssl/d1_srvr.c
@@ -276,10 +276,11 @@ int dtls1_accept(SSL *s)
276 case SSL3_ST_SW_HELLO_REQ_B: 276 case SSL3_ST_SW_HELLO_REQ_B:
277 277
278 s->shutdown=0; 278 s->shutdown=0;
279 dtls1_clear_record_buffer(s);
279 dtls1_start_timer(s); 280 dtls1_start_timer(s);
280 ret=dtls1_send_hello_request(s); 281 ret=dtls1_send_hello_request(s);
281 if (ret <= 0) goto end; 282 if (ret <= 0) goto end;
282 s->s3->tmp.next_state=SSL3_ST_SW_HELLO_REQ_C; 283 s->s3->tmp.next_state=SSL3_ST_SR_CLNT_HELLO_A;
283 s->state=SSL3_ST_SW_FLUSH; 284 s->state=SSL3_ST_SW_FLUSH;
284 s->init_num=0; 285 s->init_num=0;
285 286
@@ -721,10 +722,13 @@ int dtls1_accept(SSL *s)
721 if (ret <= 0) goto end; 722 if (ret <= 0) goto end;
722 723
723#ifndef OPENSSL_NO_SCTP 724#ifndef OPENSSL_NO_SCTP
724 /* Change to new shared key of SCTP-Auth, 725 if (!s->hit)
725 * will be ignored if no SCTP used. 726 {
726 */ 727 /* Change to new shared key of SCTP-Auth,
727 BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL); 728 * will be ignored if no SCTP used.
729 */
730 BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL);
731 }
728#endif 732#endif
729 733
730 s->state=SSL3_ST_SW_FINISHED_A; 734 s->state=SSL3_ST_SW_FINISHED_A;
@@ -749,7 +753,16 @@ int dtls1_accept(SSL *s)
749 if (ret <= 0) goto end; 753 if (ret <= 0) goto end;
750 s->state=SSL3_ST_SW_FLUSH; 754 s->state=SSL3_ST_SW_FLUSH;
751 if (s->hit) 755 if (s->hit)
756 {
752 s->s3->tmp.next_state=SSL3_ST_SR_FINISHED_A; 757 s->s3->tmp.next_state=SSL3_ST_SR_FINISHED_A;
758
759#ifndef OPENSSL_NO_SCTP
760 /* Change to new shared key of SCTP-Auth,
761 * will be ignored if no SCTP used.
762 */
763 BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL);
764#endif
765 }
753 else 766 else
754 { 767 {
755 s->s3->tmp.next_state=SSL_ST_OK; 768 s->s3->tmp.next_state=SSL_ST_OK;
@@ -912,15 +925,13 @@ int dtls1_send_server_hello(SSL *s)
912 unsigned char *p,*d; 925 unsigned char *p,*d;
913 int i; 926 int i;
914 unsigned int sl; 927 unsigned int sl;
915 unsigned long l,Time; 928 unsigned long l;
916 929
917 if (s->state == SSL3_ST_SW_SRVR_HELLO_A) 930 if (s->state == SSL3_ST_SW_SRVR_HELLO_A)
918 { 931 {
919 buf=(unsigned char *)s->init_buf->data; 932 buf=(unsigned char *)s->init_buf->data;
920 p=s->s3->server_random; 933 p=s->s3->server_random;
921 Time=(unsigned long)time(NULL); /* Time */ 934 ssl_fill_hello_random(s, 1, p, SSL3_RANDOM_SIZE);
922 l2n(Time,p);
923 RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-4);
924 /* Do the message type and length last */ 935 /* Do the message type and length last */
925 d=p= &(buf[DTLS1_HM_HEADER_LENGTH]); 936 d=p= &(buf[DTLS1_HM_HEADER_LENGTH]);
926 937
diff --git a/src/lib/libssl/src/ssl/dtls1.h b/src/lib/libssl/src/ssl/dtls1.h
index 5008bf6081..e65d501191 100644
--- a/src/lib/libssl/src/ssl/dtls1.h
+++ b/src/lib/libssl/src/ssl/dtls1.h
@@ -57,8 +57,8 @@
57 * 57 *
58 */ 58 */
59 59
60#ifndef HEADER_DTLS1_H 60#ifndef HEADER_DTLS1_H
61#define HEADER_DTLS1_H 61#define HEADER_DTLS1_H
62 62
63#include <openssl/buffer.h> 63#include <openssl/buffer.h>
64#include <openssl/pqueue.h> 64#include <openssl/pqueue.h>
@@ -72,8 +72,12 @@
72#elif defined(OPENSSL_SYS_NETWARE) && !defined(_WINSOCK2API_) 72#elif defined(OPENSSL_SYS_NETWARE) && !defined(_WINSOCK2API_)
73#include <sys/timeval.h> 73#include <sys/timeval.h>
74#else 74#else
75#if defined(OPENSSL_SYS_VXWORKS)
76#include <sys/times.h>
77#else
75#include <sys/time.h> 78#include <sys/time.h>
76#endif 79#endif
80#endif
77 81
78#ifdef __cplusplus 82#ifdef __cplusplus
79extern "C" { 83extern "C" {
diff --git a/src/lib/libssl/src/ssl/tls_srp.c b/src/lib/libssl/src/ssl/tls_srp.c
index 8512c4daf6..2315a7c0a2 100644
--- a/src/lib/libssl/src/ssl/tls_srp.c
+++ b/src/lib/libssl/src/ssl/tls_srp.c
@@ -242,7 +242,8 @@ int SSL_srp_server_param_with_username(SSL *s, int *ad)
242 (s->srp_ctx.v == NULL)) 242 (s->srp_ctx.v == NULL))
243 return SSL3_AL_FATAL; 243 return SSL3_AL_FATAL;
244 244
245 RAND_bytes(b, sizeof(b)); 245 if (RAND_bytes(b, sizeof(b)) <= 0)
246 return SSL3_AL_FATAL;
246 s->srp_ctx.b = BN_bin2bn(b,sizeof(b),NULL); 247 s->srp_ctx.b = BN_bin2bn(b,sizeof(b),NULL);
247 OPENSSL_cleanse(b,sizeof(b)); 248 OPENSSL_cleanse(b,sizeof(b));
248 249
diff --git a/src/lib/libssl/src/test/cms-test.pl b/src/lib/libssl/src/test/cms-test.pl
index c938bcf00d..dfef799be2 100644
--- a/src/lib/libssl/src/test/cms-test.pl
+++ b/src/lib/libssl/src/test/cms-test.pl
@@ -415,8 +415,10 @@ sub run_smime_tests {
415} 415}
416 416
417sub cmp_files { 417sub cmp_files {
418 use FileHandle;
418 my ( $f1, $f2 ) = @_; 419 my ( $f1, $f2 ) = @_;
419 my ( $fp1, $fp2 ); 420 my $fp1 = FileHandle->new();
421 my $fp2 = FileHandle->new();
420 422
421 my ( $rd1, $rd2 ); 423 my ( $rd1, $rd2 );
422 424