diff options
| author | djm <> | 2009-01-09 12:14:08 +0000 |
|---|---|---|
| committer | djm <> | 2009-01-09 12:14:08 +0000 |
| commit | fdf9113d3582e152f49094152c69cf4fc2313cea (patch) | |
| tree | f4ffce3b31816b285b9a3a6c153e63bf437e6d1b /src | |
| parent | eb31e19ff683f462ecfa1aae307aa7c98f6d682b (diff) | |
| download | openbsd-fdf9113d3582e152f49094152c69cf4fc2313cea.tar.gz openbsd-fdf9113d3582e152f49094152c69cf4fc2313cea.tar.bz2 openbsd-fdf9113d3582e152f49094152c69cf4fc2313cea.zip | |
import openssl-0.9.8j
Diffstat (limited to 'src')
79 files changed, 3434 insertions, 606 deletions
diff --git a/src/lib/libcrypto/camellia/Makefile b/src/lib/libcrypto/camellia/Makefile index 1579de5ce5..dfb12951fd 100644 --- a/src/lib/libcrypto/camellia/Makefile +++ b/src/lib/libcrypto/camellia/Makefile | |||
| @@ -41,7 +41,7 @@ top: | |||
| 41 | all: lib | 41 | all: lib |
| 42 | 42 | ||
| 43 | lib: $(LIBOBJ) | 43 | lib: $(LIBOBJ) |
| 44 | $(AR) $(LIB) $(LIBOBJ) | 44 | $(ARX) $(LIB) $(LIBOBJ) |
| 45 | $(RANLIB) $(LIB) || echo Never mind. | 45 | $(RANLIB) $(LIB) || echo Never mind. |
| 46 | @touch lib | 46 | @touch lib |
| 47 | 47 | ||
diff --git a/src/lib/libcrypto/cms/Makefile b/src/lib/libcrypto/cms/Makefile index e39c310b6c..1c137e0cff 100644 --- a/src/lib/libcrypto/cms/Makefile +++ b/src/lib/libcrypto/cms/Makefile | |||
| @@ -37,7 +37,7 @@ test: | |||
| 37 | all: lib | 37 | all: lib |
| 38 | 38 | ||
| 39 | lib: $(LIBOBJ) | 39 | lib: $(LIBOBJ) |
| 40 | $(AR) $(LIB) $(LIBOBJ) | 40 | $(ARX) $(LIB) $(LIBOBJ) |
| 41 | $(RANLIB) $(LIB) || echo Never mind. | 41 | $(RANLIB) $(LIB) || echo Never mind. |
| 42 | @touch lib | 42 | @touch lib |
| 43 | 43 | ||
diff --git a/src/lib/libcrypto/ecdh/Makefile b/src/lib/libcrypto/ecdh/Makefile index 95aa69fea5..7a7b618eeb 100644 --- a/src/lib/libcrypto/ecdh/Makefile +++ b/src/lib/libcrypto/ecdh/Makefile | |||
| @@ -34,7 +34,7 @@ top: | |||
| 34 | all: lib | 34 | all: lib |
| 35 | 35 | ||
| 36 | lib: $(LIBOBJ) | 36 | lib: $(LIBOBJ) |
| 37 | $(AR) $(LIB) $(LIBOBJ) | 37 | $(ARX) $(LIB) $(LIBOBJ) |
| 38 | $(RANLIB) $(LIB) || echo Never mind. | 38 | $(RANLIB) $(LIB) || echo Never mind. |
| 39 | @touch lib | 39 | @touch lib |
| 40 | 40 | ||
| @@ -84,20 +84,31 @@ ech_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | |||
| 84 | ech_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 84 | ech_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 85 | ech_err.o: ech_err.c | 85 | ech_err.o: ech_err.c |
| 86 | ech_key.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 86 | ech_key.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 87 | ech_key.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | 87 | ech_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 88 | ech_key.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h | 88 | ech_key.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h |
| 89 | ech_key.o: ../../include/openssl/engine.h ../../include/openssl/opensslconf.h | 89 | ech_key.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h |
| 90 | ech_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 90 | ech_key.o: ../../include/openssl/engine.h ../../include/openssl/evp.h |
| 91 | ech_key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 91 | ech_key.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h |
| 92 | ech_key.o: ../../include/openssl/symhacks.h ech_key.c ech_locl.h | 92 | ech_key.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
| 93 | ech_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 94 | ech_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 95 | ech_key.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 96 | ech_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 97 | ech_key.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 98 | ech_key.o: ech_key.c ech_locl.h | ||
| 93 | ech_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 99 | ech_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 94 | ech_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | 100 | ech_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 95 | ech_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h | 101 | ech_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h |
| 102 | ech_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h | ||
| 96 | ech_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h | 103 | ech_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h |
| 97 | ech_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | 104 | ech_lib.o: ../../include/openssl/evp.h ../../include/openssl/fips.h |
| 105 | ech_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 106 | ech_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 98 | ech_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 107 | ech_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 99 | ech_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 108 | ech_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h |
| 100 | ech_lib.o: ../../include/openssl/symhacks.h ech_lib.c ech_locl.h | 109 | ech_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
| 110 | ech_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 111 | ech_lib.o: ../../include/openssl/x509_vfy.h ech_lib.c ech_locl.h | ||
| 101 | ech_ossl.o: ../../e_os.h ../../include/openssl/asn1.h | 112 | ech_ossl.o: ../../e_os.h ../../include/openssl/asn1.h |
| 102 | ech_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | 113 | ech_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h |
| 103 | ech_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 114 | ech_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
diff --git a/src/lib/libcrypto/ecdsa/Makefile b/src/lib/libcrypto/ecdsa/Makefile index 16a93cd3ae..4865f3c8d6 100644 --- a/src/lib/libcrypto/ecdsa/Makefile +++ b/src/lib/libcrypto/ecdsa/Makefile | |||
| @@ -34,7 +34,7 @@ top: | |||
| 34 | all: lib | 34 | all: lib |
| 35 | 35 | ||
| 36 | lib: $(LIBOBJ) | 36 | lib: $(LIBOBJ) |
| 37 | $(AR) $(LIB) $(LIBOBJ) | 37 | $(ARX) $(LIB) $(LIBOBJ) |
| 38 | $(RANLIB) $(LIB) || echo Never mind. | 38 | $(RANLIB) $(LIB) || echo Never mind. |
| 39 | @touch lib | 39 | @touch lib |
| 40 | 40 | ||
| @@ -92,13 +92,18 @@ ecs_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | |||
| 92 | ecs_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 92 | ecs_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 93 | ecs_err.o: ecs_err.c | 93 | ecs_err.o: ecs_err.c |
| 94 | ecs_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 94 | ecs_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 95 | ecs_lib.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h | 95 | ecs_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h |
| 96 | ecs_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h | 96 | ecs_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h |
| 97 | ecs_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h | ||
| 97 | ecs_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h | 98 | ecs_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h |
| 98 | ecs_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | 99 | ecs_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
| 100 | ecs_lib.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h | ||
| 101 | ecs_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 99 | ecs_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | 102 | ecs_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
| 100 | ecs_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | 103 | ecs_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h |
| 104 | ecs_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 101 | ecs_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 105 | ecs_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 106 | ecs_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 102 | ecs_lib.o: ecs_lib.c ecs_locl.h | 107 | ecs_lib.o: ecs_lib.c ecs_locl.h |
| 103 | ecs_ossl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 108 | ecs_ossl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 104 | ecs_ossl.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h | 109 | ecs_ossl.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h |
| @@ -110,16 +115,28 @@ ecs_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | |||
| 110 | ecs_ossl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 115 | ecs_ossl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h |
| 111 | ecs_ossl.o: ../../include/openssl/symhacks.h ecs_locl.h ecs_ossl.c | 116 | ecs_ossl.o: ../../include/openssl/symhacks.h ecs_locl.h ecs_ossl.c |
| 112 | ecs_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 117 | ecs_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 113 | ecs_sign.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | 118 | ecs_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 114 | ecs_sign.o: ../../include/openssl/ec.h ../../include/openssl/ecdsa.h | 119 | ecs_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h |
| 115 | ecs_sign.o: ../../include/openssl/engine.h ../../include/openssl/opensslconf.h | 120 | ecs_sign.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h |
| 121 | ecs_sign.o: ../../include/openssl/engine.h ../../include/openssl/evp.h | ||
| 122 | ecs_sign.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h | ||
| 123 | ecs_sign.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 124 | ecs_sign.o: ../../include/openssl/opensslconf.h | ||
| 116 | ecs_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 125 | ecs_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 117 | ecs_sign.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 126 | ecs_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h |
| 118 | ecs_sign.o: ../../include/openssl/symhacks.h ecs_locl.h ecs_sign.c | 127 | ecs_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
| 128 | ecs_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 129 | ecs_sign.o: ../../include/openssl/x509_vfy.h ecs_locl.h ecs_sign.c | ||
| 119 | ecs_vrf.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 130 | ecs_vrf.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 120 | ecs_vrf.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | 131 | ecs_vrf.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 121 | ecs_vrf.o: ../../include/openssl/ec.h ../../include/openssl/ecdsa.h | 132 | ecs_vrf.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h |
| 122 | ecs_vrf.o: ../../include/openssl/engine.h ../../include/openssl/opensslconf.h | 133 | ecs_vrf.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h |
| 123 | ecs_vrf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 134 | ecs_vrf.o: ../../include/openssl/engine.h ../../include/openssl/evp.h |
| 124 | ecs_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 135 | ecs_vrf.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h |
| 125 | ecs_vrf.o: ../../include/openssl/symhacks.h ecs_locl.h ecs_vrf.c | 136 | ecs_vrf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
| 137 | ecs_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 138 | ecs_vrf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 139 | ecs_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 140 | ecs_vrf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 141 | ecs_vrf.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 142 | ecs_vrf.o: ecs_locl.h ecs_vrf.c | ||
diff --git a/src/lib/libcrypto/fips_err.h b/src/lib/libcrypto/fips_err.h new file mode 100644 index 0000000000..b328616858 --- /dev/null +++ b/src/lib/libcrypto/fips_err.h | |||
| @@ -0,0 +1,137 @@ | |||
| 1 | /* crypto/fips_err.h */ | ||
| 2 | /* ==================================================================== | ||
| 3 | * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. | ||
| 4 | * | ||
| 5 | * Redistribution and use in source and binary forms, with or without | ||
| 6 | * modification, are permitted provided that the following conditions | ||
| 7 | * are met: | ||
| 8 | * | ||
| 9 | * 1. Redistributions of source code must retain the above copyright | ||
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * | ||
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer in | ||
| 14 | * the documentation and/or other materials provided with the | ||
| 15 | * distribution. | ||
| 16 | * | ||
| 17 | * 3. All advertising materials mentioning features or use of this | ||
| 18 | * software must display the following acknowledgment: | ||
| 19 | * "This product includes software developed by the OpenSSL Project | ||
| 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 21 | * | ||
| 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 23 | * endorse or promote products derived from this software without | ||
| 24 | * prior written permission. For written permission, please contact | ||
| 25 | * openssl-core@OpenSSL.org. | ||
| 26 | * | ||
| 27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 28 | * nor may "OpenSSL" appear in their names without prior written | ||
| 29 | * permission of the OpenSSL Project. | ||
| 30 | * | ||
| 31 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 32 | * acknowledgment: | ||
| 33 | * "This product includes software developed by the OpenSSL Project | ||
| 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 35 | * | ||
| 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 54 | */ | ||
| 55 | |||
| 56 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes | ||
| 57 | * made to it will be overwritten when the script next updates this file, | ||
| 58 | * only reason strings will be preserved. | ||
| 59 | */ | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include <openssl/err.h> | ||
| 63 | #include <openssl/fips.h> | ||
| 64 | |||
| 65 | /* BEGIN ERROR CODES */ | ||
| 66 | #ifndef OPENSSL_NO_ERR | ||
| 67 | |||
| 68 | #define ERR_FUNC(func) ERR_PACK(ERR_LIB_FIPS,func,0) | ||
| 69 | #define ERR_REASON(reason) ERR_PACK(ERR_LIB_FIPS,0,reason) | ||
| 70 | |||
| 71 | static ERR_STRING_DATA FIPS_str_functs[]= | ||
| 72 | { | ||
| 73 | {ERR_FUNC(FIPS_F_DH_BUILTIN_GENPARAMS), "DH_BUILTIN_GENPARAMS"}, | ||
| 74 | {ERR_FUNC(FIPS_F_DSA_BUILTIN_PARAMGEN), "DSA_BUILTIN_PARAMGEN"}, | ||
| 75 | {ERR_FUNC(FIPS_F_DSA_DO_SIGN), "DSA_do_sign"}, | ||
| 76 | {ERR_FUNC(FIPS_F_DSA_DO_VERIFY), "DSA_do_verify"}, | ||
| 77 | {ERR_FUNC(FIPS_F_EVP_CIPHERINIT_EX), "EVP_CipherInit_ex"}, | ||
| 78 | {ERR_FUNC(FIPS_F_EVP_DIGESTINIT_EX), "EVP_DigestInit_ex"}, | ||
| 79 | {ERR_FUNC(FIPS_F_FIPS_CHECK_DSA), "FIPS_CHECK_DSA"}, | ||
| 80 | {ERR_FUNC(FIPS_F_FIPS_CHECK_INCORE_FINGERPRINT), "FIPS_CHECK_INCORE_FINGERPRINT"}, | ||
| 81 | {ERR_FUNC(FIPS_F_FIPS_CHECK_RSA), "FIPS_CHECK_RSA"}, | ||
| 82 | {ERR_FUNC(FIPS_F_FIPS_DSA_CHECK), "FIPS_DSA_CHECK"}, | ||
| 83 | {ERR_FUNC(FIPS_F_FIPS_MODE_SET), "FIPS_mode_set"}, | ||
| 84 | {ERR_FUNC(FIPS_F_FIPS_PKEY_SIGNATURE_TEST), "fips_pkey_signature_test"}, | ||
| 85 | {ERR_FUNC(FIPS_F_FIPS_SELFTEST_AES), "FIPS_selftest_aes"}, | ||
| 86 | {ERR_FUNC(FIPS_F_FIPS_SELFTEST_DES), "FIPS_selftest_des"}, | ||
| 87 | {ERR_FUNC(FIPS_F_FIPS_SELFTEST_DSA), "FIPS_selftest_dsa"}, | ||
| 88 | {ERR_FUNC(FIPS_F_FIPS_SELFTEST_HMAC), "FIPS_selftest_hmac"}, | ||
| 89 | {ERR_FUNC(FIPS_F_FIPS_SELFTEST_RNG), "FIPS_selftest_rng"}, | ||
| 90 | {ERR_FUNC(FIPS_F_FIPS_SELFTEST_SHA1), "FIPS_selftest_sha1"}, | ||
| 91 | {ERR_FUNC(FIPS_F_HASH_FINAL), "HASH_FINAL"}, | ||
| 92 | {ERR_FUNC(FIPS_F_RSA_BUILTIN_KEYGEN), "RSA_BUILTIN_KEYGEN"}, | ||
| 93 | {ERR_FUNC(FIPS_F_RSA_EAY_PRIVATE_DECRYPT), "RSA_EAY_PRIVATE_DECRYPT"}, | ||
| 94 | {ERR_FUNC(FIPS_F_RSA_EAY_PRIVATE_ENCRYPT), "RSA_EAY_PRIVATE_ENCRYPT"}, | ||
| 95 | {ERR_FUNC(FIPS_F_RSA_EAY_PUBLIC_DECRYPT), "RSA_EAY_PUBLIC_DECRYPT"}, | ||
| 96 | {ERR_FUNC(FIPS_F_RSA_EAY_PUBLIC_ENCRYPT), "RSA_EAY_PUBLIC_ENCRYPT"}, | ||
| 97 | {ERR_FUNC(FIPS_F_RSA_X931_GENERATE_KEY_EX), "RSA_X931_generate_key_ex"}, | ||
| 98 | {ERR_FUNC(FIPS_F_SSLEAY_RAND_BYTES), "SSLEAY_RAND_BYTES"}, | ||
| 99 | {0,NULL} | ||
| 100 | }; | ||
| 101 | |||
| 102 | static ERR_STRING_DATA FIPS_str_reasons[]= | ||
| 103 | { | ||
| 104 | {ERR_REASON(FIPS_R_CANNOT_READ_EXE) ,"cannot read exe"}, | ||
| 105 | {ERR_REASON(FIPS_R_CANNOT_READ_EXE_DIGEST),"cannot read exe digest"}, | ||
| 106 | {ERR_REASON(FIPS_R_CONTRADICTING_EVIDENCE),"contradicting evidence"}, | ||
| 107 | {ERR_REASON(FIPS_R_EXE_DIGEST_DOES_NOT_MATCH),"exe digest does not match"}, | ||
| 108 | {ERR_REASON(FIPS_R_FINGERPRINT_DOES_NOT_MATCH),"fingerprint does not match"}, | ||
| 109 | {ERR_REASON(FIPS_R_FINGERPRINT_DOES_NOT_MATCH_NONPIC_RELOCATED),"fingerprint does not match nonpic relocated"}, | ||
| 110 | {ERR_REASON(FIPS_R_FINGERPRINT_DOES_NOT_MATCH_SEGMENT_ALIASING),"fingerprint does not match segment aliasing"}, | ||
| 111 | {ERR_REASON(FIPS_R_FIPS_MODE_ALREADY_SET),"fips mode already set"}, | ||
| 112 | {ERR_REASON(FIPS_R_FIPS_SELFTEST_FAILED) ,"fips selftest failed"}, | ||
| 113 | {ERR_REASON(FIPS_R_INVALID_KEY_LENGTH) ,"invalid key length"}, | ||
| 114 | {ERR_REASON(FIPS_R_KEY_TOO_SHORT) ,"key too short"}, | ||
| 115 | {ERR_REASON(FIPS_R_NON_FIPS_METHOD) ,"non fips method"}, | ||
| 116 | {ERR_REASON(FIPS_R_PAIRWISE_TEST_FAILED) ,"pairwise test failed"}, | ||
| 117 | {ERR_REASON(FIPS_R_RSA_DECRYPT_ERROR) ,"rsa decrypt error"}, | ||
| 118 | {ERR_REASON(FIPS_R_RSA_ENCRYPT_ERROR) ,"rsa encrypt error"}, | ||
| 119 | {ERR_REASON(FIPS_R_SELFTEST_FAILED) ,"selftest failed"}, | ||
| 120 | {ERR_REASON(FIPS_R_TEST_FAILURE) ,"test failure"}, | ||
| 121 | {ERR_REASON(FIPS_R_UNSUPPORTED_PLATFORM) ,"unsupported platform"}, | ||
| 122 | {0,NULL} | ||
| 123 | }; | ||
| 124 | |||
| 125 | #endif | ||
| 126 | |||
| 127 | void ERR_load_FIPS_strings(void) | ||
| 128 | { | ||
| 129 | #ifndef OPENSSL_NO_ERR | ||
| 130 | |||
| 131 | if (ERR_func_error_string(FIPS_str_functs[0].error) == NULL) | ||
| 132 | { | ||
| 133 | ERR_load_strings(0,FIPS_str_functs); | ||
| 134 | ERR_load_strings(0,FIPS_str_reasons); | ||
| 135 | } | ||
| 136 | #endif | ||
| 137 | } | ||
diff --git a/src/lib/libcrypto/jpake/Makefile b/src/lib/libcrypto/jpake/Makefile new file mode 100644 index 0000000000..a4a1402f2e --- /dev/null +++ b/src/lib/libcrypto/jpake/Makefile | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | DIR=jpake | ||
| 2 | TOP=../.. | ||
| 3 | |||
| 4 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
| 5 | |||
| 6 | LIB=$(TOP)/libcrypto.a | ||
| 7 | LIBOBJ=jpake.o jpake_err.o | ||
| 8 | LIBSRC=jpake.c jpake_err.c | ||
| 9 | |||
| 10 | EXHEADER=jpake.h | ||
| 11 | TEST=jpaketest.c | ||
| 12 | |||
| 13 | top: | ||
| 14 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
| 15 | |||
| 16 | all: lib | ||
| 17 | |||
| 18 | lib: $(LIBOBJ) | ||
| 19 | $(ARX) $(LIB) $(LIBOBJ) | ||
| 20 | $(RANLIB) $(LIB) || echo Never mind. | ||
| 21 | @touch lib | ||
| 22 | |||
| 23 | links: | ||
| 24 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) | ||
| 25 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) | ||
| 26 | |||
| 27 | install: | ||
| 28 | @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile... | ||
| 29 | @headerlist="$(EXHEADER)"; for i in $$headerlist ; \ | ||
| 30 | do \ | ||
| 31 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ | ||
| 32 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ | ||
| 33 | done; | ||
| 34 | |||
| 35 | depend: | ||
| 36 | @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile... | ||
| 37 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) | ||
| 38 | |||
| 39 | dclean: | ||
| 40 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
| 41 | mv -f Makefile.new $(MAKEFILE) | ||
| 42 | |||
| 43 | clean: | ||
| 44 | rm -f *.s *.o *.obj des lib tags core .pure .nfs* *.old *.bak fluff | ||
| 45 | |||
| 46 | jpaketest: top jpaketest.c $(LIB) | ||
| 47 | $(CC) $(CFLAGS) -Wall -Werror -g -o jpaketest jpaketest.c $(LIB) | ||
| 48 | # DO NOT DELETE THIS LINE -- make depend depends on it. | ||
| 49 | |||
| 50 | jpake.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 51 | jpake.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | ||
| 52 | jpake.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 53 | jpake.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 54 | jpake.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | ||
| 55 | jpake.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 56 | jpake.o: ../../include/openssl/symhacks.h jpake.c jpake.h | ||
| 57 | jpake_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 58 | jpake_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | ||
| 59 | jpake_err.o: ../../include/openssl/err.h ../../include/openssl/jpake.h | ||
| 60 | jpake_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 61 | jpake_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 62 | jpake_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 63 | jpake_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 64 | jpake_err.o: jpake_err.c | ||
diff --git a/src/lib/libcrypto/jpake/jpake.c b/src/lib/libcrypto/jpake/jpake.c new file mode 100644 index 0000000000..577b7ef375 --- /dev/null +++ b/src/lib/libcrypto/jpake/jpake.c | |||
| @@ -0,0 +1,483 @@ | |||
| 1 | #include "jpake.h" | ||
| 2 | |||
| 3 | #include <openssl/crypto.h> | ||
| 4 | #include <openssl/sha.h> | ||
| 5 | #include <openssl/err.h> | ||
| 6 | #include <memory.h> | ||
| 7 | #include <assert.h> | ||
| 8 | |||
| 9 | /* | ||
| 10 | * In the definition, (xa, xb, xc, xd) are Alice's (x1, x2, x3, x4) or | ||
| 11 | * Bob's (x3, x4, x1, x2). If you see what I mean. | ||
| 12 | */ | ||
| 13 | |||
| 14 | typedef struct | ||
| 15 | { | ||
| 16 | char *name; /* Must be unique */ | ||
| 17 | char *peer_name; | ||
| 18 | BIGNUM *p; | ||
| 19 | BIGNUM *g; | ||
| 20 | BIGNUM *q; | ||
| 21 | BIGNUM *gxc; /* Alice's g^{x3} or Bob's g^{x1} */ | ||
| 22 | BIGNUM *gxd; /* Alice's g^{x4} or Bob's g^{x2} */ | ||
| 23 | } JPAKE_CTX_PUBLIC; | ||
| 24 | |||
| 25 | struct JPAKE_CTX | ||
| 26 | { | ||
| 27 | JPAKE_CTX_PUBLIC p; | ||
| 28 | BIGNUM *secret; /* The shared secret */ | ||
| 29 | BN_CTX *ctx; | ||
| 30 | BIGNUM *xa; /* Alice's x1 or Bob's x3 */ | ||
| 31 | BIGNUM *xb; /* Alice's x2 or Bob's x4 */ | ||
| 32 | BIGNUM *key; /* The calculated (shared) key */ | ||
| 33 | }; | ||
| 34 | |||
| 35 | static void JPAKE_ZKP_init(JPAKE_ZKP *zkp) | ||
| 36 | { | ||
| 37 | zkp->gr = BN_new(); | ||
| 38 | zkp->b = BN_new(); | ||
| 39 | } | ||
| 40 | |||
| 41 | static void JPAKE_ZKP_release(JPAKE_ZKP *zkp) | ||
| 42 | { | ||
| 43 | BN_free(zkp->b); | ||
| 44 | BN_free(zkp->gr); | ||
| 45 | } | ||
| 46 | |||
| 47 | /* Two birds with one stone - make the global name as expected */ | ||
| 48 | #define JPAKE_STEP_PART_init JPAKE_STEP2_init | ||
| 49 | #define JPAKE_STEP_PART_release JPAKE_STEP2_release | ||
| 50 | |||
| 51 | void JPAKE_STEP_PART_init(JPAKE_STEP_PART *p) | ||
| 52 | { | ||
| 53 | p->gx = BN_new(); | ||
| 54 | JPAKE_ZKP_init(&p->zkpx); | ||
| 55 | } | ||
| 56 | |||
| 57 | void JPAKE_STEP_PART_release(JPAKE_STEP_PART *p) | ||
| 58 | { | ||
| 59 | JPAKE_ZKP_release(&p->zkpx); | ||
| 60 | BN_free(p->gx); | ||
| 61 | } | ||
| 62 | |||
| 63 | void JPAKE_STEP1_init(JPAKE_STEP1 *s1) | ||
| 64 | { | ||
| 65 | JPAKE_STEP_PART_init(&s1->p1); | ||
| 66 | JPAKE_STEP_PART_init(&s1->p2); | ||
| 67 | } | ||
| 68 | |||
| 69 | void JPAKE_STEP1_release(JPAKE_STEP1 *s1) | ||
| 70 | { | ||
| 71 | JPAKE_STEP_PART_release(&s1->p2); | ||
| 72 | JPAKE_STEP_PART_release(&s1->p1); | ||
| 73 | } | ||
| 74 | |||
| 75 | static void JPAKE_CTX_init(JPAKE_CTX *ctx, const char *name, | ||
| 76 | const char *peer_name, const BIGNUM *p, | ||
| 77 | const BIGNUM *g, const BIGNUM *q, | ||
| 78 | const BIGNUM *secret) | ||
| 79 | { | ||
| 80 | ctx->p.name = OPENSSL_strdup(name); | ||
| 81 | ctx->p.peer_name = OPENSSL_strdup(peer_name); | ||
| 82 | ctx->p.p = BN_dup(p); | ||
| 83 | ctx->p.g = BN_dup(g); | ||
| 84 | ctx->p.q = BN_dup(q); | ||
| 85 | ctx->secret = BN_dup(secret); | ||
| 86 | |||
| 87 | ctx->p.gxc = BN_new(); | ||
| 88 | ctx->p.gxd = BN_new(); | ||
| 89 | |||
| 90 | ctx->xa = BN_new(); | ||
| 91 | ctx->xb = BN_new(); | ||
| 92 | ctx->key = BN_new(); | ||
| 93 | ctx->ctx = BN_CTX_new(); | ||
| 94 | } | ||
| 95 | |||
| 96 | static void JPAKE_CTX_release(JPAKE_CTX *ctx) | ||
| 97 | { | ||
| 98 | BN_CTX_free(ctx->ctx); | ||
| 99 | BN_clear_free(ctx->key); | ||
| 100 | BN_clear_free(ctx->xb); | ||
| 101 | BN_clear_free(ctx->xa); | ||
| 102 | |||
| 103 | BN_free(ctx->p.gxd); | ||
| 104 | BN_free(ctx->p.gxc); | ||
| 105 | |||
| 106 | BN_clear_free(ctx->secret); | ||
| 107 | BN_free(ctx->p.q); | ||
| 108 | BN_free(ctx->p.g); | ||
| 109 | BN_free(ctx->p.p); | ||
| 110 | OPENSSL_free(ctx->p.peer_name); | ||
| 111 | OPENSSL_free(ctx->p.name); | ||
| 112 | |||
| 113 | memset(ctx, '\0', sizeof *ctx); | ||
| 114 | } | ||
| 115 | |||
| 116 | JPAKE_CTX *JPAKE_CTX_new(const char *name, const char *peer_name, | ||
| 117 | const BIGNUM *p, const BIGNUM *g, const BIGNUM *q, | ||
| 118 | const BIGNUM *secret) | ||
| 119 | { | ||
| 120 | JPAKE_CTX *ctx = OPENSSL_malloc(sizeof *ctx); | ||
| 121 | |||
| 122 | JPAKE_CTX_init(ctx, name, peer_name, p, g, q, secret); | ||
| 123 | |||
| 124 | return ctx; | ||
| 125 | } | ||
| 126 | |||
| 127 | void JPAKE_CTX_free(JPAKE_CTX *ctx) | ||
| 128 | { | ||
| 129 | JPAKE_CTX_release(ctx); | ||
| 130 | OPENSSL_free(ctx); | ||
| 131 | } | ||
| 132 | |||
| 133 | static void hashlength(SHA_CTX *sha, size_t l) | ||
| 134 | { | ||
| 135 | unsigned char b[2]; | ||
| 136 | |||
| 137 | assert(l <= 0xffff); | ||
| 138 | b[0] = l >> 8; | ||
| 139 | b[1] = l&0xff; | ||
| 140 | SHA1_Update(sha, b, 2); | ||
| 141 | } | ||
| 142 | |||
| 143 | static void hashstring(SHA_CTX *sha, const char *string) | ||
| 144 | { | ||
| 145 | size_t l = strlen(string); | ||
| 146 | |||
| 147 | hashlength(sha, l); | ||
| 148 | SHA1_Update(sha, string, l); | ||
| 149 | } | ||
| 150 | |||
| 151 | static void hashbn(SHA_CTX *sha, const BIGNUM *bn) | ||
| 152 | { | ||
| 153 | size_t l = BN_num_bytes(bn); | ||
| 154 | unsigned char *bin = OPENSSL_malloc(l); | ||
| 155 | |||
| 156 | hashlength(sha, l); | ||
| 157 | BN_bn2bin(bn, bin); | ||
| 158 | SHA1_Update(sha, bin, l); | ||
| 159 | OPENSSL_free(bin); | ||
| 160 | } | ||
| 161 | |||
| 162 | /* h=hash(g, g^r, g^x, name) */ | ||
| 163 | static void zkp_hash(BIGNUM *h, const BIGNUM *zkpg, const JPAKE_STEP_PART *p, | ||
| 164 | const char *proof_name) | ||
| 165 | { | ||
| 166 | unsigned char md[SHA_DIGEST_LENGTH]; | ||
| 167 | SHA_CTX sha; | ||
| 168 | |||
| 169 | /* | ||
| 170 | * XXX: hash should not allow moving of the boundaries - Java code | ||
| 171 | * is flawed in this respect. Length encoding seems simplest. | ||
| 172 | */ | ||
| 173 | SHA1_Init(&sha); | ||
| 174 | hashbn(&sha, zkpg); | ||
| 175 | assert(!BN_is_zero(p->zkpx.gr)); | ||
| 176 | hashbn(&sha, p->zkpx.gr); | ||
| 177 | hashbn(&sha, p->gx); | ||
| 178 | hashstring(&sha, proof_name); | ||
| 179 | SHA1_Final(md, &sha); | ||
| 180 | BN_bin2bn(md, SHA_DIGEST_LENGTH, h); | ||
| 181 | } | ||
| 182 | |||
| 183 | /* | ||
| 184 | * Prove knowledge of x | ||
| 185 | * Note that p->gx has already been calculated | ||
| 186 | */ | ||
| 187 | static void generate_zkp(JPAKE_STEP_PART *p, const BIGNUM *x, | ||
| 188 | const BIGNUM *zkpg, JPAKE_CTX *ctx) | ||
| 189 | { | ||
| 190 | BIGNUM *r = BN_new(); | ||
| 191 | BIGNUM *h = BN_new(); | ||
| 192 | BIGNUM *t = BN_new(); | ||
| 193 | |||
| 194 | /* | ||
| 195 | * r in [0,q) | ||
| 196 | * XXX: Java chooses r in [0, 2^160) - i.e. distribution not uniform | ||
| 197 | */ | ||
| 198 | BN_rand_range(r, ctx->p.q); | ||
| 199 | /* g^r */ | ||
| 200 | BN_mod_exp(p->zkpx.gr, zkpg, r, ctx->p.p, ctx->ctx); | ||
| 201 | |||
| 202 | /* h=hash... */ | ||
| 203 | zkp_hash(h, zkpg, p, ctx->p.name); | ||
| 204 | |||
| 205 | /* b = r - x*h */ | ||
| 206 | BN_mod_mul(t, x, h, ctx->p.q, ctx->ctx); | ||
| 207 | BN_mod_sub(p->zkpx.b, r, t, ctx->p.q, ctx->ctx); | ||
| 208 | |||
| 209 | /* cleanup */ | ||
| 210 | BN_free(t); | ||
| 211 | BN_free(h); | ||
| 212 | BN_free(r); | ||
| 213 | } | ||
| 214 | |||
| 215 | static int verify_zkp(const JPAKE_STEP_PART *p, const BIGNUM *zkpg, | ||
| 216 | JPAKE_CTX *ctx) | ||
| 217 | { | ||
| 218 | BIGNUM *h = BN_new(); | ||
| 219 | BIGNUM *t1 = BN_new(); | ||
| 220 | BIGNUM *t2 = BN_new(); | ||
| 221 | BIGNUM *t3 = BN_new(); | ||
| 222 | int ret = 0; | ||
| 223 | |||
| 224 | zkp_hash(h, zkpg, p, ctx->p.peer_name); | ||
| 225 | |||
| 226 | /* t1 = g^b */ | ||
| 227 | BN_mod_exp(t1, zkpg, p->zkpx.b, ctx->p.p, ctx->ctx); | ||
| 228 | /* t2 = (g^x)^h = g^{hx} */ | ||
| 229 | BN_mod_exp(t2, p->gx, h, ctx->p.p, ctx->ctx); | ||
| 230 | /* t3 = t1 * t2 = g^{hx} * g^b = g^{hx+b} = g^r (allegedly) */ | ||
| 231 | BN_mod_mul(t3, t1, t2, ctx->p.p, ctx->ctx); | ||
| 232 | |||
| 233 | /* verify t3 == g^r */ | ||
| 234 | if(BN_cmp(t3, p->zkpx.gr) == 0) | ||
| 235 | ret = 1; | ||
| 236 | else | ||
| 237 | JPAKEerr(JPAKE_F_VERIFY_ZKP, JPAKE_R_ZKP_VERIFY_FAILED); | ||
| 238 | |||
| 239 | /* cleanup */ | ||
| 240 | BN_free(t3); | ||
| 241 | BN_free(t2); | ||
| 242 | BN_free(t1); | ||
| 243 | BN_free(h); | ||
| 244 | |||
| 245 | return ret; | ||
| 246 | } | ||
| 247 | |||
| 248 | static void generate_step_part(JPAKE_STEP_PART *p, const BIGNUM *x, | ||
| 249 | const BIGNUM *g, JPAKE_CTX *ctx) | ||
| 250 | { | ||
| 251 | BN_mod_exp(p->gx, g, x, ctx->p.p, ctx->ctx); | ||
| 252 | generate_zkp(p, x, g, ctx); | ||
| 253 | } | ||
| 254 | |||
| 255 | /* Generate each party's random numbers. xa is in [0, q), xb is in [1, q). */ | ||
| 256 | static void genrand(JPAKE_CTX *ctx) | ||
| 257 | { | ||
| 258 | BIGNUM *qm1; | ||
| 259 | |||
| 260 | /* xa in [0, q) */ | ||
| 261 | BN_rand_range(ctx->xa, ctx->p.q); | ||
| 262 | |||
| 263 | /* q-1 */ | ||
| 264 | qm1 = BN_new(); | ||
| 265 | BN_copy(qm1, ctx->p.q); | ||
| 266 | BN_sub_word(qm1, 1); | ||
| 267 | |||
| 268 | /* ... and xb in [0, q-1) */ | ||
| 269 | BN_rand_range(ctx->xb, qm1); | ||
| 270 | /* [1, q) */ | ||
| 271 | BN_add_word(ctx->xb, 1); | ||
| 272 | |||
| 273 | /* cleanup */ | ||
| 274 | BN_free(qm1); | ||
| 275 | } | ||
| 276 | |||
| 277 | int JPAKE_STEP1_generate(JPAKE_STEP1 *send, JPAKE_CTX *ctx) | ||
| 278 | { | ||
| 279 | genrand(ctx); | ||
| 280 | generate_step_part(&send->p1, ctx->xa, ctx->p.g, ctx); | ||
| 281 | generate_step_part(&send->p2, ctx->xb, ctx->p.g, ctx); | ||
| 282 | |||
| 283 | return 1; | ||
| 284 | } | ||
| 285 | |||
| 286 | int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received) | ||
| 287 | { | ||
| 288 | /* verify their ZKP(xc) */ | ||
| 289 | if(!verify_zkp(&received->p1, ctx->p.g, ctx)) | ||
| 290 | { | ||
| 291 | JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_VERIFY_X3_FAILED); | ||
| 292 | return 0; | ||
| 293 | } | ||
| 294 | |||
| 295 | /* verify their ZKP(xd) */ | ||
| 296 | if(!verify_zkp(&received->p2, ctx->p.g, ctx)) | ||
| 297 | { | ||
| 298 | JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_VERIFY_X4_FAILED); | ||
| 299 | return 0; | ||
| 300 | } | ||
| 301 | |||
| 302 | /* g^xd != 1 */ | ||
| 303 | if(BN_is_one(received->p2.gx)) | ||
| 304 | { | ||
| 305 | JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_G_TO_THE_X4_IS_ONE); | ||
| 306 | return 0; | ||
| 307 | } | ||
| 308 | |||
| 309 | /* Save the bits we need for later */ | ||
| 310 | BN_copy(ctx->p.gxc, received->p1.gx); | ||
| 311 | BN_copy(ctx->p.gxd, received->p2.gx); | ||
| 312 | |||
| 313 | return 1; | ||
| 314 | } | ||
| 315 | |||
| 316 | |||
| 317 | int JPAKE_STEP2_generate(JPAKE_STEP2 *send, JPAKE_CTX *ctx) | ||
| 318 | { | ||
| 319 | BIGNUM *t1 = BN_new(); | ||
| 320 | BIGNUM *t2 = BN_new(); | ||
| 321 | |||
| 322 | /* | ||
| 323 | * X = g^{(xa + xc + xd) * xb * s} | ||
| 324 | * t1 = g^xa | ||
| 325 | */ | ||
| 326 | BN_mod_exp(t1, ctx->p.g, ctx->xa, ctx->p.p, ctx->ctx); | ||
| 327 | /* t2 = t1 * g^{xc} = g^{xa} * g^{xc} = g^{xa + xc} */ | ||
| 328 | BN_mod_mul(t2, t1, ctx->p.gxc, ctx->p.p, ctx->ctx); | ||
| 329 | /* t1 = t2 * g^{xd} = g^{xa + xc + xd} */ | ||
| 330 | BN_mod_mul(t1, t2, ctx->p.gxd, ctx->p.p, ctx->ctx); | ||
| 331 | /* t2 = xb * s */ | ||
| 332 | BN_mod_mul(t2, ctx->xb, ctx->secret, ctx->p.q, ctx->ctx); | ||
| 333 | |||
| 334 | /* | ||
| 335 | * ZKP(xb * s) | ||
| 336 | * XXX: this is kinda funky, because we're using | ||
| 337 | * | ||
| 338 | * g' = g^{xa + xc + xd} | ||
| 339 | * | ||
| 340 | * as the generator, which means X is g'^{xb * s} | ||
| 341 | * X = t1^{t2} = t1^{xb * s} = g^{(xa + xc + xd) * xb * s} | ||
| 342 | */ | ||
| 343 | generate_step_part(send, t2, t1, ctx); | ||
| 344 | |||
| 345 | /* cleanup */ | ||
| 346 | BN_free(t1); | ||
| 347 | BN_free(t2); | ||
| 348 | |||
| 349 | return 1; | ||
| 350 | } | ||
| 351 | |||
| 352 | /* gx = g^{xc + xa + xb} * xd * s */ | ||
| 353 | static int compute_key(JPAKE_CTX *ctx, const BIGNUM *gx) | ||
| 354 | { | ||
| 355 | BIGNUM *t1 = BN_new(); | ||
| 356 | BIGNUM *t2 = BN_new(); | ||
| 357 | BIGNUM *t3 = BN_new(); | ||
| 358 | |||
| 359 | /* | ||
| 360 | * K = (gx/g^{xb * xd * s})^{xb} | ||
| 361 | * = (g^{(xc + xa + xb) * xd * s - xb * xd *s})^{xb} | ||
| 362 | * = (g^{(xa + xc) * xd * s})^{xb} | ||
| 363 | * = g^{(xa + xc) * xb * xd * s} | ||
| 364 | * [which is the same regardless of who calculates it] | ||
| 365 | */ | ||
| 366 | |||
| 367 | /* t1 = (g^{xd})^{xb} = g^{xb * xd} */ | ||
| 368 | BN_mod_exp(t1, ctx->p.gxd, ctx->xb, ctx->p.p, ctx->ctx); | ||
| 369 | /* t2 = -s = q-s */ | ||
| 370 | BN_sub(t2, ctx->p.q, ctx->secret); | ||
| 371 | /* t3 = t1^t2 = g^{-xb * xd * s} */ | ||
| 372 | BN_mod_exp(t3, t1, t2, ctx->p.p, ctx->ctx); | ||
| 373 | /* t1 = gx * t3 = X/g^{xb * xd * s} */ | ||
| 374 | BN_mod_mul(t1, gx, t3, ctx->p.p, ctx->ctx); | ||
| 375 | /* K = t1^{xb} */ | ||
| 376 | BN_mod_exp(ctx->key, t1, ctx->xb, ctx->p.p, ctx->ctx); | ||
| 377 | |||
| 378 | /* cleanup */ | ||
| 379 | BN_free(t3); | ||
| 380 | BN_free(t2); | ||
| 381 | BN_free(t1); | ||
| 382 | |||
| 383 | return 1; | ||
| 384 | } | ||
| 385 | |||
| 386 | int JPAKE_STEP2_process(JPAKE_CTX *ctx, const JPAKE_STEP2 *received) | ||
| 387 | { | ||
| 388 | BIGNUM *t1 = BN_new(); | ||
| 389 | BIGNUM *t2 = BN_new(); | ||
| 390 | int ret = 0; | ||
| 391 | |||
| 392 | /* | ||
| 393 | * g' = g^{xc + xa + xb} [from our POV] | ||
| 394 | * t1 = xa + xb | ||
| 395 | */ | ||
| 396 | BN_mod_add(t1, ctx->xa, ctx->xb, ctx->p.q, ctx->ctx); | ||
| 397 | /* t2 = g^{t1} = g^{xa+xb} */ | ||
| 398 | BN_mod_exp(t2, ctx->p.g, t1, ctx->p.p, ctx->ctx); | ||
| 399 | /* t1 = g^{xc} * t2 = g^{xc + xa + xb} */ | ||
| 400 | BN_mod_mul(t1, ctx->p.gxc, t2, ctx->p.p, ctx->ctx); | ||
| 401 | |||
| 402 | if(verify_zkp(received, t1, ctx)) | ||
| 403 | ret = 1; | ||
| 404 | else | ||
| 405 | JPAKEerr(JPAKE_F_JPAKE_STEP2_PROCESS, JPAKE_R_VERIFY_B_FAILED); | ||
| 406 | |||
| 407 | compute_key(ctx, received->gx); | ||
| 408 | |||
| 409 | /* cleanup */ | ||
| 410 | BN_free(t2); | ||
| 411 | BN_free(t1); | ||
| 412 | |||
| 413 | return ret; | ||
| 414 | } | ||
| 415 | |||
| 416 | static void quickhashbn(unsigned char *md, const BIGNUM *bn) | ||
| 417 | { | ||
| 418 | SHA_CTX sha; | ||
| 419 | |||
| 420 | SHA1_Init(&sha); | ||
| 421 | hashbn(&sha, bn); | ||
| 422 | SHA1_Final(md, &sha); | ||
| 423 | } | ||
| 424 | |||
| 425 | void JPAKE_STEP3A_init(JPAKE_STEP3A *s3a) | ||
| 426 | {} | ||
| 427 | |||
| 428 | int JPAKE_STEP3A_generate(JPAKE_STEP3A *send, JPAKE_CTX *ctx) | ||
| 429 | { | ||
| 430 | quickhashbn(send->hhk, ctx->key); | ||
| 431 | SHA1(send->hhk, sizeof send->hhk, send->hhk); | ||
| 432 | |||
| 433 | return 1; | ||
| 434 | } | ||
| 435 | |||
| 436 | int JPAKE_STEP3A_process(JPAKE_CTX *ctx, const JPAKE_STEP3A *received) | ||
| 437 | { | ||
| 438 | unsigned char hhk[SHA_DIGEST_LENGTH]; | ||
| 439 | |||
| 440 | quickhashbn(hhk, ctx->key); | ||
| 441 | SHA1(hhk, sizeof hhk, hhk); | ||
| 442 | if(memcmp(hhk, received->hhk, sizeof hhk)) | ||
| 443 | { | ||
| 444 | JPAKEerr(JPAKE_F_JPAKE_STEP3A_PROCESS, JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH); | ||
| 445 | return 0; | ||
| 446 | } | ||
| 447 | return 1; | ||
| 448 | } | ||
| 449 | |||
| 450 | void JPAKE_STEP3A_release(JPAKE_STEP3A *s3a) | ||
| 451 | {} | ||
| 452 | |||
| 453 | void JPAKE_STEP3B_init(JPAKE_STEP3B *s3b) | ||
| 454 | {} | ||
| 455 | |||
| 456 | int JPAKE_STEP3B_generate(JPAKE_STEP3B *send, JPAKE_CTX *ctx) | ||
| 457 | { | ||
| 458 | quickhashbn(send->hk, ctx->key); | ||
| 459 | |||
| 460 | return 1; | ||
| 461 | } | ||
| 462 | |||
| 463 | int JPAKE_STEP3B_process(JPAKE_CTX *ctx, const JPAKE_STEP3B *received) | ||
| 464 | { | ||
| 465 | unsigned char hk[SHA_DIGEST_LENGTH]; | ||
| 466 | |||
| 467 | quickhashbn(hk, ctx->key); | ||
| 468 | if(memcmp(hk, received->hk, sizeof hk)) | ||
| 469 | { | ||
| 470 | JPAKEerr(JPAKE_F_JPAKE_STEP3B_PROCESS, JPAKE_R_HASH_OF_KEY_MISMATCH); | ||
| 471 | return 0; | ||
| 472 | } | ||
| 473 | return 1; | ||
| 474 | } | ||
| 475 | |||
| 476 | void JPAKE_STEP3B_release(JPAKE_STEP3B *s3b) | ||
| 477 | {} | ||
| 478 | |||
| 479 | const BIGNUM *JPAKE_get_shared_key(JPAKE_CTX *ctx) | ||
| 480 | { | ||
| 481 | return ctx->key; | ||
| 482 | } | ||
| 483 | |||
diff --git a/src/lib/libcrypto/jpake/jpake.h b/src/lib/libcrypto/jpake/jpake.h new file mode 100644 index 0000000000..693ea188cb --- /dev/null +++ b/src/lib/libcrypto/jpake/jpake.h | |||
| @@ -0,0 +1,129 @@ | |||
| 1 | /* | ||
| 2 | * Implement J-PAKE, as described in | ||
| 3 | * http://grouper.ieee.org/groups/1363/Research/contributions/hao-ryan-2008.pdf | ||
| 4 | * | ||
| 5 | * With hints from http://www.cl.cam.ac.uk/~fh240/software/JPAKE2.java. | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef HEADER_JPAKE_H | ||
| 9 | #define HEADER_JPAKE_H | ||
| 10 | |||
| 11 | #include <openssl/opensslconf.h> | ||
| 12 | |||
| 13 | #ifdef OPENSSL_NO_JPAKE | ||
| 14 | #error JPAKE is disabled. | ||
| 15 | #endif | ||
| 16 | |||
| 17 | #ifdef __cplusplus | ||
| 18 | extern "C" { | ||
| 19 | #endif | ||
| 20 | |||
| 21 | #include <openssl/bn.h> | ||
| 22 | #include <openssl/sha.h> | ||
| 23 | |||
| 24 | typedef struct JPAKE_CTX JPAKE_CTX; | ||
| 25 | |||
| 26 | /* Note that "g" in the ZKPs is not necessarily the J-PAKE g. */ | ||
| 27 | typedef struct | ||
| 28 | { | ||
| 29 | BIGNUM *gr; /* g^r (r random) */ | ||
| 30 | BIGNUM *b; /* b = r - x*h, h=hash(g, g^r, g^x, name) */ | ||
| 31 | } JPAKE_ZKP; | ||
| 32 | |||
| 33 | typedef struct | ||
| 34 | { | ||
| 35 | BIGNUM *gx; /* g^x in step 1, g^(xa + xc + xd) * xb * s in step 2 */ | ||
| 36 | JPAKE_ZKP zkpx; /* ZKP(x) or ZKP(xb * s) */ | ||
| 37 | } JPAKE_STEP_PART; | ||
| 38 | |||
| 39 | typedef struct | ||
| 40 | { | ||
| 41 | JPAKE_STEP_PART p1; /* g^x3, ZKP(x3) or g^x1, ZKP(x1) */ | ||
| 42 | JPAKE_STEP_PART p2; /* g^x4, ZKP(x4) or g^x2, ZKP(x2) */ | ||
| 43 | } JPAKE_STEP1; | ||
| 44 | |||
| 45 | typedef JPAKE_STEP_PART JPAKE_STEP2; | ||
| 46 | |||
| 47 | typedef struct | ||
| 48 | { | ||
| 49 | unsigned char hhk[SHA_DIGEST_LENGTH]; | ||
| 50 | } JPAKE_STEP3A; | ||
| 51 | |||
| 52 | typedef struct | ||
| 53 | { | ||
| 54 | unsigned char hk[SHA_DIGEST_LENGTH]; | ||
| 55 | } JPAKE_STEP3B; | ||
| 56 | |||
| 57 | /* Parameters are copied */ | ||
| 58 | JPAKE_CTX *JPAKE_CTX_new(const char *name, const char *peer_name, | ||
| 59 | const BIGNUM *p, const BIGNUM *g, const BIGNUM *q, | ||
| 60 | const BIGNUM *secret); | ||
| 61 | void JPAKE_CTX_free(JPAKE_CTX *ctx); | ||
| 62 | |||
| 63 | /* | ||
| 64 | * Note that JPAKE_STEP1 can be used multiple times before release | ||
| 65 | * without another init. | ||
| 66 | */ | ||
| 67 | void JPAKE_STEP1_init(JPAKE_STEP1 *s1); | ||
| 68 | int JPAKE_STEP1_generate(JPAKE_STEP1 *send, JPAKE_CTX *ctx); | ||
| 69 | int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received); | ||
| 70 | void JPAKE_STEP1_release(JPAKE_STEP1 *s1); | ||
| 71 | |||
| 72 | /* | ||
| 73 | * Note that JPAKE_STEP2 can be used multiple times before release | ||
| 74 | * without another init. | ||
| 75 | */ | ||
| 76 | void JPAKE_STEP2_init(JPAKE_STEP2 *s2); | ||
| 77 | int JPAKE_STEP2_generate(JPAKE_STEP2 *send, JPAKE_CTX *ctx); | ||
| 78 | int JPAKE_STEP2_process(JPAKE_CTX *ctx, const JPAKE_STEP2 *received); | ||
| 79 | void JPAKE_STEP2_release(JPAKE_STEP2 *s2); | ||
| 80 | |||
| 81 | /* | ||
| 82 | * Optionally verify the shared key. If the shared secrets do not | ||
| 83 | * match, the two ends will disagree about the shared key, but | ||
| 84 | * otherwise the protocol will succeed. | ||
| 85 | */ | ||
| 86 | void JPAKE_STEP3A_init(JPAKE_STEP3A *s3a); | ||
| 87 | int JPAKE_STEP3A_generate(JPAKE_STEP3A *send, JPAKE_CTX *ctx); | ||
| 88 | int JPAKE_STEP3A_process(JPAKE_CTX *ctx, const JPAKE_STEP3A *received); | ||
| 89 | void JPAKE_STEP3A_release(JPAKE_STEP3A *s3a); | ||
| 90 | |||
| 91 | void JPAKE_STEP3B_init(JPAKE_STEP3B *s3b); | ||
| 92 | int JPAKE_STEP3B_generate(JPAKE_STEP3B *send, JPAKE_CTX *ctx); | ||
| 93 | int JPAKE_STEP3B_process(JPAKE_CTX *ctx, const JPAKE_STEP3B *received); | ||
| 94 | void JPAKE_STEP3B_release(JPAKE_STEP3B *s3b); | ||
| 95 | |||
| 96 | /* | ||
| 97 | * the return value belongs to the library and will be released when | ||
| 98 | * ctx is released, and will change when a new handshake is performed. | ||
| 99 | */ | ||
| 100 | const BIGNUM *JPAKE_get_shared_key(JPAKE_CTX *ctx); | ||
| 101 | |||
| 102 | /* BEGIN ERROR CODES */ | ||
| 103 | /* The following lines are auto generated by the script mkerr.pl. Any changes | ||
| 104 | * made after this point may be overwritten when the script is next run. | ||
| 105 | */ | ||
| 106 | void ERR_load_JPAKE_strings(void); | ||
| 107 | |||
| 108 | /* Error codes for the JPAKE functions. */ | ||
| 109 | |||
| 110 | /* Function codes. */ | ||
| 111 | #define JPAKE_F_JPAKE_STEP1_PROCESS 101 | ||
| 112 | #define JPAKE_F_JPAKE_STEP2_PROCESS 102 | ||
| 113 | #define JPAKE_F_JPAKE_STEP3A_PROCESS 103 | ||
| 114 | #define JPAKE_F_JPAKE_STEP3B_PROCESS 104 | ||
| 115 | #define JPAKE_F_VERIFY_ZKP 100 | ||
| 116 | |||
| 117 | /* Reason codes. */ | ||
| 118 | #define JPAKE_R_G_TO_THE_X4_IS_ONE 105 | ||
| 119 | #define JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH 106 | ||
| 120 | #define JPAKE_R_HASH_OF_KEY_MISMATCH 107 | ||
| 121 | #define JPAKE_R_VERIFY_B_FAILED 102 | ||
| 122 | #define JPAKE_R_VERIFY_X3_FAILED 103 | ||
| 123 | #define JPAKE_R_VERIFY_X4_FAILED 104 | ||
| 124 | #define JPAKE_R_ZKP_VERIFY_FAILED 100 | ||
| 125 | |||
| 126 | #ifdef __cplusplus | ||
| 127 | } | ||
| 128 | #endif | ||
| 129 | #endif | ||
diff --git a/src/lib/libcrypto/jpake/jpake_err.c b/src/lib/libcrypto/jpake/jpake_err.c new file mode 100644 index 0000000000..1b95067967 --- /dev/null +++ b/src/lib/libcrypto/jpake/jpake_err.c | |||
| @@ -0,0 +1,105 @@ | |||
| 1 | /* crypto/jpake/jpake_err.c */ | ||
| 2 | /* ==================================================================== | ||
| 3 | * Copyright (c) 1999-2008 The OpenSSL Project. All rights reserved. | ||
| 4 | * | ||
| 5 | * Redistribution and use in source and binary forms, with or without | ||
| 6 | * modification, are permitted provided that the following conditions | ||
| 7 | * are met: | ||
| 8 | * | ||
| 9 | * 1. Redistributions of source code must retain the above copyright | ||
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * | ||
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer in | ||
| 14 | * the documentation and/or other materials provided with the | ||
| 15 | * distribution. | ||
| 16 | * | ||
| 17 | * 3. All advertising materials mentioning features or use of this | ||
| 18 | * software must display the following acknowledgment: | ||
| 19 | * "This product includes software developed by the OpenSSL Project | ||
| 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 21 | * | ||
| 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 23 | * endorse or promote products derived from this software without | ||
| 24 | * prior written permission. For written permission, please contact | ||
| 25 | * openssl-core@OpenSSL.org. | ||
| 26 | * | ||
| 27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 28 | * nor may "OpenSSL" appear in their names without prior written | ||
| 29 | * permission of the OpenSSL Project. | ||
| 30 | * | ||
| 31 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 32 | * acknowledgment: | ||
| 33 | * "This product includes software developed by the OpenSSL Project | ||
| 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 35 | * | ||
| 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 54 | */ | ||
| 55 | |||
| 56 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes | ||
| 57 | * made to it will be overwritten when the script next updates this file, | ||
| 58 | * only reason strings will be preserved. | ||
| 59 | */ | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include <openssl/err.h> | ||
| 63 | #include <openssl/jpake.h> | ||
| 64 | |||
| 65 | /* BEGIN ERROR CODES */ | ||
| 66 | #ifndef OPENSSL_NO_ERR | ||
| 67 | |||
| 68 | #define ERR_FUNC(func) ERR_PACK(ERR_LIB_JPAKE,func,0) | ||
| 69 | #define ERR_REASON(reason) ERR_PACK(ERR_LIB_JPAKE,0,reason) | ||
| 70 | |||
| 71 | static ERR_STRING_DATA JPAKE_str_functs[]= | ||
| 72 | { | ||
| 73 | {ERR_FUNC(JPAKE_F_JPAKE_STEP1_PROCESS), "JPAKE_STEP1_process"}, | ||
| 74 | {ERR_FUNC(JPAKE_F_JPAKE_STEP2_PROCESS), "JPAKE_STEP2_process"}, | ||
| 75 | {ERR_FUNC(JPAKE_F_JPAKE_STEP3A_PROCESS), "JPAKE_STEP3A_process"}, | ||
| 76 | {ERR_FUNC(JPAKE_F_JPAKE_STEP3B_PROCESS), "JPAKE_STEP3B_process"}, | ||
| 77 | {ERR_FUNC(JPAKE_F_VERIFY_ZKP), "VERIFY_ZKP"}, | ||
| 78 | {0,NULL} | ||
| 79 | }; | ||
| 80 | |||
| 81 | static ERR_STRING_DATA JPAKE_str_reasons[]= | ||
| 82 | { | ||
| 83 | {ERR_REASON(JPAKE_R_G_TO_THE_X4_IS_ONE) ,"g to the x4 is one"}, | ||
| 84 | {ERR_REASON(JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH),"hash of hash of key mismatch"}, | ||
| 85 | {ERR_REASON(JPAKE_R_HASH_OF_KEY_MISMATCH),"hash of key mismatch"}, | ||
| 86 | {ERR_REASON(JPAKE_R_VERIFY_B_FAILED) ,"verify b failed"}, | ||
| 87 | {ERR_REASON(JPAKE_R_VERIFY_X3_FAILED) ,"verify x3 failed"}, | ||
| 88 | {ERR_REASON(JPAKE_R_VERIFY_X4_FAILED) ,"verify x4 failed"}, | ||
| 89 | {ERR_REASON(JPAKE_R_ZKP_VERIFY_FAILED) ,"zkp verify failed"}, | ||
| 90 | {0,NULL} | ||
| 91 | }; | ||
| 92 | |||
| 93 | #endif | ||
| 94 | |||
| 95 | void ERR_load_JPAKE_strings(void) | ||
| 96 | { | ||
| 97 | #ifndef OPENSSL_NO_ERR | ||
| 98 | |||
| 99 | if (ERR_func_error_string(JPAKE_str_functs[0].error) == NULL) | ||
| 100 | { | ||
| 101 | ERR_load_strings(0,JPAKE_str_functs); | ||
| 102 | ERR_load_strings(0,JPAKE_str_reasons); | ||
| 103 | } | ||
| 104 | #endif | ||
| 105 | } | ||
diff --git a/src/lib/libcrypto/jpake/jpaketest.c b/src/lib/libcrypto/jpake/jpaketest.c new file mode 100644 index 0000000000..792fc49eb4 --- /dev/null +++ b/src/lib/libcrypto/jpake/jpaketest.c | |||
| @@ -0,0 +1,192 @@ | |||
| 1 | #include <openssl/opensslconf.h> | ||
| 2 | |||
| 3 | #ifdef OPENSSL_NO_JPAKE | ||
| 4 | |||
| 5 | #include <stdio.h> | ||
| 6 | |||
| 7 | int main(int argc, char *argv[]) | ||
| 8 | { | ||
| 9 | printf("No J-PAKE support\n"); | ||
| 10 | return(0); | ||
| 11 | } | ||
| 12 | |||
| 13 | #else | ||
| 14 | |||
| 15 | #include <openssl/jpake.h> | ||
| 16 | #include <openssl/err.h> | ||
| 17 | |||
| 18 | static void showbn(const char *name, const BIGNUM *bn) | ||
| 19 | { | ||
| 20 | fputs(name, stdout); | ||
| 21 | fputs(" = ", stdout); | ||
| 22 | BN_print_fp(stdout, bn); | ||
| 23 | putc('\n', stdout); | ||
| 24 | } | ||
| 25 | |||
| 26 | static int run_jpake(JPAKE_CTX *alice, JPAKE_CTX *bob) | ||
| 27 | { | ||
| 28 | JPAKE_STEP1 alice_s1; | ||
| 29 | JPAKE_STEP1 bob_s1; | ||
| 30 | JPAKE_STEP2 alice_s2; | ||
| 31 | JPAKE_STEP2 bob_s2; | ||
| 32 | JPAKE_STEP3A alice_s3a; | ||
| 33 | JPAKE_STEP3B bob_s3b; | ||
| 34 | |||
| 35 | /* Alice -> Bob: step 1 */ | ||
| 36 | puts("A->B s1"); | ||
| 37 | JPAKE_STEP1_init(&alice_s1); | ||
| 38 | JPAKE_STEP1_generate(&alice_s1, alice); | ||
| 39 | if(!JPAKE_STEP1_process(bob, &alice_s1)) | ||
| 40 | { | ||
| 41 | printf("Bob fails to process Alice's step 1\n"); | ||
| 42 | ERR_print_errors_fp(stdout); | ||
| 43 | return 1; | ||
| 44 | } | ||
| 45 | JPAKE_STEP1_release(&alice_s1); | ||
| 46 | |||
| 47 | /* Bob -> Alice: step 1 */ | ||
| 48 | puts("B->A s1"); | ||
| 49 | JPAKE_STEP1_init(&bob_s1); | ||
| 50 | JPAKE_STEP1_generate(&bob_s1, bob); | ||
| 51 | if(!JPAKE_STEP1_process(alice, &bob_s1)) | ||
| 52 | { | ||
| 53 | printf("Alice fails to process Bob's step 1\n"); | ||
| 54 | ERR_print_errors_fp(stdout); | ||
| 55 | return 2; | ||
| 56 | } | ||
| 57 | JPAKE_STEP1_release(&bob_s1); | ||
| 58 | |||
| 59 | /* Alice -> Bob: step 2 */ | ||
| 60 | puts("A->B s2"); | ||
| 61 | JPAKE_STEP2_init(&alice_s2); | ||
| 62 | JPAKE_STEP2_generate(&alice_s2, alice); | ||
| 63 | if(!JPAKE_STEP2_process(bob, &alice_s2)) | ||
| 64 | { | ||
| 65 | printf("Bob fails to process Alice's step 2\n"); | ||
| 66 | ERR_print_errors_fp(stdout); | ||
| 67 | return 3; | ||
| 68 | } | ||
| 69 | JPAKE_STEP2_release(&alice_s2); | ||
| 70 | |||
| 71 | /* Bob -> Alice: step 2 */ | ||
| 72 | puts("B->A s2"); | ||
| 73 | JPAKE_STEP2_init(&bob_s2); | ||
| 74 | JPAKE_STEP2_generate(&bob_s2, bob); | ||
| 75 | if(!JPAKE_STEP2_process(alice, &bob_s2)) | ||
| 76 | { | ||
| 77 | printf("Alice fails to process Bob's step 2\n"); | ||
| 78 | ERR_print_errors_fp(stdout); | ||
| 79 | return 4; | ||
| 80 | } | ||
| 81 | JPAKE_STEP2_release(&bob_s2); | ||
| 82 | |||
| 83 | showbn("Alice's key", JPAKE_get_shared_key(alice)); | ||
| 84 | showbn("Bob's key ", JPAKE_get_shared_key(bob)); | ||
| 85 | |||
| 86 | /* Alice -> Bob: step 3a */ | ||
| 87 | puts("A->B s3a"); | ||
| 88 | JPAKE_STEP3A_init(&alice_s3a); | ||
| 89 | JPAKE_STEP3A_generate(&alice_s3a, alice); | ||
| 90 | if(!JPAKE_STEP3A_process(bob, &alice_s3a)) | ||
| 91 | { | ||
| 92 | printf("Bob fails to process Alice's step 3a\n"); | ||
| 93 | ERR_print_errors_fp(stdout); | ||
| 94 | return 5; | ||
| 95 | } | ||
| 96 | JPAKE_STEP3A_release(&alice_s3a); | ||
| 97 | |||
| 98 | /* Bob -> Alice: step 3b */ | ||
| 99 | puts("B->A s3b"); | ||
| 100 | JPAKE_STEP3B_init(&bob_s3b); | ||
| 101 | JPAKE_STEP3B_generate(&bob_s3b, bob); | ||
| 102 | if(!JPAKE_STEP3B_process(alice, &bob_s3b)) | ||
| 103 | { | ||
| 104 | printf("Alice fails to process Bob's step 3b\n"); | ||
| 105 | ERR_print_errors_fp(stdout); | ||
| 106 | return 6; | ||
| 107 | } | ||
| 108 | JPAKE_STEP3B_release(&bob_s3b); | ||
| 109 | |||
| 110 | return 0; | ||
| 111 | } | ||
| 112 | |||
| 113 | int main(int argc, char **argv) | ||
| 114 | { | ||
| 115 | JPAKE_CTX *alice; | ||
| 116 | JPAKE_CTX *bob; | ||
| 117 | BIGNUM *p = NULL; | ||
| 118 | BIGNUM *g = NULL; | ||
| 119 | BIGNUM *q = NULL; | ||
| 120 | BIGNUM *secret = BN_new(); | ||
| 121 | BIO *bio_err; | ||
| 122 | |||
| 123 | bio_err = BIO_new_fp(stderr, BIO_NOCLOSE); | ||
| 124 | |||
| 125 | CRYPTO_malloc_debug_init(); | ||
| 126 | CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL); | ||
| 127 | CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); | ||
| 128 | |||
| 129 | ERR_load_crypto_strings(); | ||
| 130 | |||
| 131 | /* | ||
| 132 | BN_hex2bn(&p, "fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b76b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c7"); | ||
| 133 | BN_hex2bn(&g, "f7e1a085d69b3ddecbbcab5c36b857b97994afbbfa3aea82f9574c0b3d0782675159578ebad4594fe67107108180b449167123e84c281613b7cf09328cc8a6e13c167a8b547c8d28e0a3ae1e2bb3a675916ea37f0bfa213562f1fb627a01243bcca4f1bea8519089a883dfe15ae59f06928b665e807b552564014c3bfecf492a"); | ||
| 134 | BN_hex2bn(&q, "9760508f15230bccb292b982a2eb840bf0581cf5"); | ||
| 135 | */ | ||
| 136 | /* | ||
| 137 | p = BN_new(); | ||
| 138 | BN_generate_prime(p, 1024, 1, NULL, NULL, NULL, NULL); | ||
| 139 | */ | ||
| 140 | /* Use a safe prime for p (that we found earlier) */ | ||
| 141 | BN_hex2bn(&p, "F9E5B365665EA7A05A9C534502780FEE6F1AB5BD4F49947FD036DBD7E905269AF46EF28B0FC07487EE4F5D20FB3C0AF8E700F3A2FA3414970CBED44FEDFF80CE78D800F184BB82435D137AADA2C6C16523247930A63B85661D1FC817A51ACD96168E95898A1F83A79FFB529368AA7833ABD1B0C3AEDDB14D2E1A2F71D99F763F"); | ||
| 142 | showbn("p", p); | ||
| 143 | g = BN_new(); | ||
| 144 | BN_set_word(g, 2); | ||
| 145 | showbn("g", g); | ||
| 146 | q = BN_new(); | ||
| 147 | BN_rshift1(q, p); | ||
| 148 | showbn("q", q); | ||
| 149 | |||
| 150 | BN_rand(secret, 32, -1, 0); | ||
| 151 | |||
| 152 | /* A normal run, expect this to work... */ | ||
| 153 | alice = JPAKE_CTX_new("Alice", "Bob", p, g, q, secret); | ||
| 154 | bob = JPAKE_CTX_new("Bob", "Alice", p, g, q, secret); | ||
| 155 | |||
| 156 | if(run_jpake(alice, bob) != 0) | ||
| 157 | { | ||
| 158 | fprintf(stderr, "Plain JPAKE run failed\n"); | ||
| 159 | return 1; | ||
| 160 | } | ||
| 161 | |||
| 162 | JPAKE_CTX_free(bob); | ||
| 163 | JPAKE_CTX_free(alice); | ||
| 164 | |||
| 165 | /* Now give Alice and Bob different secrets */ | ||
| 166 | alice = JPAKE_CTX_new("Alice", "Bob", p, g, q, secret); | ||
| 167 | BN_add_word(secret, 1); | ||
| 168 | bob = JPAKE_CTX_new("Bob", "Alice", p, g, q, secret); | ||
| 169 | |||
| 170 | if(run_jpake(alice, bob) != 5) | ||
| 171 | { | ||
| 172 | fprintf(stderr, "Mismatched secret JPAKE run failed\n"); | ||
| 173 | return 1; | ||
| 174 | } | ||
| 175 | |||
| 176 | JPAKE_CTX_free(bob); | ||
| 177 | JPAKE_CTX_free(alice); | ||
| 178 | |||
| 179 | BN_free(secret); | ||
| 180 | BN_free(q); | ||
| 181 | BN_free(g); | ||
| 182 | BN_free(p); | ||
| 183 | |||
| 184 | CRYPTO_cleanup_all_ex_data(); | ||
| 185 | ERR_remove_state(0); | ||
| 186 | ERR_free_strings(); | ||
| 187 | CRYPTO_mem_leaks(bio_err); | ||
| 188 | |||
| 189 | return 0; | ||
| 190 | } | ||
| 191 | |||
| 192 | #endif | ||
diff --git a/src/lib/libcrypto/pqueue/Makefile b/src/lib/libcrypto/pqueue/Makefile index d0c39d25ce..36bfc349aa 100644 --- a/src/lib/libcrypto/pqueue/Makefile +++ b/src/lib/libcrypto/pqueue/Makefile | |||
| @@ -33,7 +33,7 @@ top: | |||
| 33 | all: lib | 33 | all: lib |
| 34 | 34 | ||
| 35 | lib: $(LIBOBJ) | 35 | lib: $(LIBOBJ) |
| 36 | $(AR) $(LIB) $(LIBOBJ) | 36 | $(ARX) $(LIB) $(LIBOBJ) |
| 37 | $(RANLIB) $(LIB) || echo Never mind. | 37 | $(RANLIB) $(LIB) || echo Never mind. |
| 38 | @touch lib | 38 | @touch lib |
| 39 | 39 | ||
diff --git a/src/lib/libcrypto/seed/Makefile b/src/lib/libcrypto/seed/Makefile index f9de27b288..ffaeb84218 100644 --- a/src/lib/libcrypto/seed/Makefile +++ b/src/lib/libcrypto/seed/Makefile | |||
| @@ -34,7 +34,7 @@ top: | |||
| 34 | all: lib | 34 | all: lib |
| 35 | 35 | ||
| 36 | lib: $(LIBOBJ) | 36 | lib: $(LIBOBJ) |
| 37 | $(AR) $(LIB) $(LIBOBJ) | 37 | $(ARX) $(LIB) $(LIBOBJ) |
| 38 | $(RANLIB) $(LIB) || echo Never mind. | 38 | $(RANLIB) $(LIB) || echo Never mind. |
| 39 | @touch lib | 39 | @touch lib |
| 40 | 40 | ||
diff --git a/src/lib/libcrypto/store/Makefile b/src/lib/libcrypto/store/Makefile index 0dcfd7857a..c9f5d001a3 100644 --- a/src/lib/libcrypto/store/Makefile +++ b/src/lib/libcrypto/store/Makefile | |||
| @@ -35,7 +35,7 @@ top: | |||
| 35 | all: lib | 35 | all: lib |
| 36 | 36 | ||
| 37 | lib: $(LIBOBJ) | 37 | lib: $(LIBOBJ) |
| 38 | $(AR) $(LIB) $(LIBOBJ) | 38 | $(ARX) $(LIB) $(LIBOBJ) |
| 39 | $(RANLIB) $(LIB) || echo Never mind. | 39 | $(RANLIB) $(LIB) || echo Never mind. |
| 40 | @touch lib | 40 | @touch lib |
| 41 | 41 | ||
| @@ -89,14 +89,14 @@ str_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | |||
| 89 | str_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h | 89 | str_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h |
| 90 | str_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h | 90 | str_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h |
| 91 | str_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 91 | str_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
| 92 | str_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | 92 | str_lib.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h |
| 93 | str_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 93 | str_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
| 94 | str_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 94 | str_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
| 95 | str_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h | 95 | str_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h |
| 96 | str_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 96 | str_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h |
| 97 | str_lib.o: ../../include/openssl/store.h ../../include/openssl/symhacks.h | 97 | str_lib.o: ../../include/openssl/stack.h ../../include/openssl/store.h |
| 98 | str_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | 98 | str_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h |
| 99 | str_lib.o: str_lib.c str_locl.h | 99 | str_lib.o: ../../include/openssl/x509_vfy.h str_lib.c str_locl.h |
| 100 | str_mem.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h | 100 | str_mem.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h |
| 101 | str_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | 101 | str_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h |
| 102 | str_mem.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | 102 | str_mem.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h |
diff --git a/src/lib/libcrypto/util/copy.pl b/src/lib/libcrypto/util/copy.pl index e20b45530a..eba6d5815e 100644 --- a/src/lib/libcrypto/util/copy.pl +++ b/src/lib/libcrypto/util/copy.pl | |||
| @@ -8,9 +8,16 @@ use Fcntl; | |||
| 8 | # Perl script 'copy' comment. On Windows the built in "copy" command also | 8 | # Perl script 'copy' comment. On Windows the built in "copy" command also |
| 9 | # copies timestamps: this messes up Makefile dependencies. | 9 | # copies timestamps: this messes up Makefile dependencies. |
| 10 | 10 | ||
| 11 | my $stripcr = 0; | ||
| 12 | |||
| 11 | my $arg; | 13 | my $arg; |
| 12 | 14 | ||
| 13 | foreach $arg (@ARGV) { | 15 | foreach $arg (@ARGV) { |
| 16 | if ($arg eq "-stripcr") | ||
| 17 | { | ||
| 18 | $stripcr = 1; | ||
| 19 | next; | ||
| 20 | } | ||
| 14 | $arg =~ s|\\|/|g; # compensate for bug/feature in cygwin glob... | 21 | $arg =~ s|\\|/|g; # compensate for bug/feature in cygwin glob... |
| 15 | foreach (glob $arg) | 22 | foreach (glob $arg) |
| 16 | { | 23 | { |
| @@ -49,6 +56,10 @@ foreach (@filelist) | |||
| 49 | || die "Can't Open $dfile"; | 56 | || die "Can't Open $dfile"; |
| 50 | while (sysread IN, $buf, 10240) | 57 | while (sysread IN, $buf, 10240) |
| 51 | { | 58 | { |
| 59 | if ($stripcr) | ||
| 60 | { | ||
| 61 | $buf =~ tr/\015//d; | ||
| 62 | } | ||
| 52 | syswrite(OUT, $buf, length($buf)); | 63 | syswrite(OUT, $buf, length($buf)); |
| 53 | } | 64 | } |
| 54 | close(IN); | 65 | close(IN); |
diff --git a/src/lib/libcrypto/x509v3/v3_addr.c b/src/lib/libcrypto/x509v3/v3_addr.c index ed9847b307..a37f844d3c 100644 --- a/src/lib/libcrypto/x509v3/v3_addr.c +++ b/src/lib/libcrypto/x509v3/v3_addr.c | |||
| @@ -594,10 +594,10 @@ static IPAddressOrRanges *make_prefix_or_range(IPAddrBlocks *addr, | |||
| 594 | return NULL; | 594 | return NULL; |
| 595 | switch (afi) { | 595 | switch (afi) { |
| 596 | case IANA_AFI_IPV4: | 596 | case IANA_AFI_IPV4: |
| 597 | sk_IPAddressOrRange_set_cmp_func(aors, v4IPAddressOrRange_cmp); | 597 | (void)sk_IPAddressOrRange_set_cmp_func(aors, v4IPAddressOrRange_cmp); |
| 598 | break; | 598 | break; |
| 599 | case IANA_AFI_IPV6: | 599 | case IANA_AFI_IPV6: |
| 600 | sk_IPAddressOrRange_set_cmp_func(aors, v6IPAddressOrRange_cmp); | 600 | (void)sk_IPAddressOrRange_set_cmp_func(aors, v6IPAddressOrRange_cmp); |
| 601 | break; | 601 | break; |
| 602 | } | 602 | } |
| 603 | f->ipAddressChoice->type = IPAddressChoice_addressesOrRanges; | 603 | f->ipAddressChoice->type = IPAddressChoice_addressesOrRanges; |
| @@ -854,7 +854,7 @@ static int IPAddressOrRanges_canonize(IPAddressOrRanges *aors, | |||
| 854 | if (!make_addressRange(&merged, a_min, b_max, length)) | 854 | if (!make_addressRange(&merged, a_min, b_max, length)) |
| 855 | return 0; | 855 | return 0; |
| 856 | sk_IPAddressOrRange_set(aors, i, merged); | 856 | sk_IPAddressOrRange_set(aors, i, merged); |
| 857 | sk_IPAddressOrRange_delete(aors, i + 1); | 857 | (void)sk_IPAddressOrRange_delete(aors, i + 1); |
| 858 | IPAddressOrRange_free(a); | 858 | IPAddressOrRange_free(a); |
| 859 | IPAddressOrRange_free(b); | 859 | IPAddressOrRange_free(b); |
| 860 | --i; | 860 | --i; |
| @@ -878,6 +878,7 @@ int v3_addr_canonize(IPAddrBlocks *addr) | |||
| 878 | v3_addr_get_afi(f))) | 878 | v3_addr_get_afi(f))) |
| 879 | return 0; | 879 | return 0; |
| 880 | } | 880 | } |
| 881 | (void)sk_IPAddressFamily_set_cmp_func(addr, IPAddressFamily_cmp); | ||
| 881 | sk_IPAddressFamily_sort(addr); | 882 | sk_IPAddressFamily_sort(addr); |
| 882 | assert(v3_addr_is_canonical(addr)); | 883 | assert(v3_addr_is_canonical(addr)); |
| 883 | return 1; | 884 | return 1; |
| @@ -1122,7 +1123,7 @@ int v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b) | |||
| 1122 | return 1; | 1123 | return 1; |
| 1123 | if (b == NULL || v3_addr_inherits(a) || v3_addr_inherits(b)) | 1124 | if (b == NULL || v3_addr_inherits(a) || v3_addr_inherits(b)) |
| 1124 | return 0; | 1125 | return 0; |
| 1125 | sk_IPAddressFamily_set_cmp_func(b, IPAddressFamily_cmp); | 1126 | (void)sk_IPAddressFamily_set_cmp_func(b, IPAddressFamily_cmp); |
| 1126 | for (i = 0; i < sk_IPAddressFamily_num(a); i++) { | 1127 | for (i = 0; i < sk_IPAddressFamily_num(a); i++) { |
| 1127 | IPAddressFamily *fa = sk_IPAddressFamily_value(a, i); | 1128 | IPAddressFamily *fa = sk_IPAddressFamily_value(a, i); |
| 1128 | int j = sk_IPAddressFamily_find(b, fa); | 1129 | int j = sk_IPAddressFamily_find(b, fa); |
| @@ -1183,7 +1184,7 @@ static int v3_addr_validate_path_internal(X509_STORE_CTX *ctx, | |||
| 1183 | } | 1184 | } |
| 1184 | if (!v3_addr_is_canonical(ext)) | 1185 | if (!v3_addr_is_canonical(ext)) |
| 1185 | validation_err(X509_V_ERR_INVALID_EXTENSION); | 1186 | validation_err(X509_V_ERR_INVALID_EXTENSION); |
| 1186 | sk_IPAddressFamily_set_cmp_func(ext, IPAddressFamily_cmp); | 1187 | (void)sk_IPAddressFamily_set_cmp_func(ext, IPAddressFamily_cmp); |
| 1187 | if ((child = sk_IPAddressFamily_dup(ext)) == NULL) { | 1188 | if ((child = sk_IPAddressFamily_dup(ext)) == NULL) { |
| 1188 | X509V3err(X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL, ERR_R_MALLOC_FAILURE); | 1189 | X509V3err(X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL, ERR_R_MALLOC_FAILURE); |
| 1189 | ret = 0; | 1190 | ret = 0; |
| @@ -1209,7 +1210,7 @@ static int v3_addr_validate_path_internal(X509_STORE_CTX *ctx, | |||
| 1209 | } | 1210 | } |
| 1210 | continue; | 1211 | continue; |
| 1211 | } | 1212 | } |
| 1212 | sk_IPAddressFamily_set_cmp_func(x->rfc3779_addr, IPAddressFamily_cmp); | 1213 | (void)sk_IPAddressFamily_set_cmp_func(x->rfc3779_addr, IPAddressFamily_cmp); |
| 1213 | for (j = 0; j < sk_IPAddressFamily_num(child); j++) { | 1214 | for (j = 0; j < sk_IPAddressFamily_num(child); j++) { |
| 1214 | IPAddressFamily *fc = sk_IPAddressFamily_value(child, j); | 1215 | IPAddressFamily *fc = sk_IPAddressFamily_value(child, j); |
| 1215 | int k = sk_IPAddressFamily_find(x->rfc3779_addr, fc); | 1216 | int k = sk_IPAddressFamily_find(x->rfc3779_addr, fc); |
diff --git a/src/lib/libcrypto/x509v3/v3_asid.c b/src/lib/libcrypto/x509v3/v3_asid.c index 271930f967..abd497ed1f 100644 --- a/src/lib/libcrypto/x509v3/v3_asid.c +++ b/src/lib/libcrypto/x509v3/v3_asid.c | |||
| @@ -466,7 +466,7 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice) | |||
| 466 | break; | 466 | break; |
| 467 | } | 467 | } |
| 468 | ASIdOrRange_free(b); | 468 | ASIdOrRange_free(b); |
| 469 | sk_ASIdOrRange_delete(choice->u.asIdsOrRanges, i + 1); | 469 | (void)sk_ASIdOrRange_delete(choice->u.asIdsOrRanges, i + 1); |
| 470 | i--; | 470 | i--; |
| 471 | continue; | 471 | continue; |
| 472 | } | 472 | } |
diff --git a/src/lib/libssl/src/Makefile.shared b/src/lib/libssl/src/Makefile.shared index 97035a3c01..3183436ac6 100644 --- a/src/lib/libssl/src/Makefile.shared +++ b/src/lib/libssl/src/Makefile.shared | |||
| @@ -101,15 +101,13 @@ LINK_SO= \ | |||
| 101 | LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \ | 101 | LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \ |
| 102 | SHAREDCMD="$${SHAREDCMD:-$(CC)}"; \ | 102 | SHAREDCMD="$${SHAREDCMD:-$(CC)}"; \ |
| 103 | SHAREDFLAGS="$${SHAREDFLAGS:-$(CFLAGS) $(SHARED_LDFLAGS)}"; \ | 103 | SHAREDFLAGS="$${SHAREDFLAGS:-$(CFLAGS) $(SHARED_LDFLAGS)}"; \ |
| 104 | nm -Pg $$SHOBJECTS | grep ' [BDT] ' | cut -f1 -d' ' > lib$(LIBNAME).exp; \ | ||
| 105 | LIBPATH=`for x in $$LIBDEPS; do if echo $$x | grep '^ *-L' > /dev/null 2>&1; then echo $$x | sed -e 's/^ *-L//'; fi; done | uniq`; \ | 104 | LIBPATH=`for x in $$LIBDEPS; do if echo $$x | grep '^ *-L' > /dev/null 2>&1; then echo $$x | sed -e 's/^ *-L//'; fi; done | uniq`; \ |
| 106 | LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \ | 105 | LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \ |
| 107 | LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \ | 106 | LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \ |
| 108 | $${SHAREDCMD} $${SHAREDFLAGS} \ | 107 | $${SHAREDCMD} $${SHAREDFLAGS} \ |
| 109 | -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \ | 108 | -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \ |
| 110 | $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS \ | 109 | $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS \ |
| 111 | ) && $(SYMLINK_SO); \ | 110 | ) && $(SYMLINK_SO) |
| 112 | ( $(SET_X); rm -f lib$(LIBNAME).exp ) | ||
| 113 | 111 | ||
| 114 | SYMLINK_SO= \ | 112 | SYMLINK_SO= \ |
| 115 | if [ -n "$$INHIBIT_SYMLINKS" ]; then :; else \ | 113 | if [ -n "$$INHIBIT_SYMLINKS" ]; then :; else \ |
| @@ -202,8 +200,10 @@ link_app.bsd: | |||
| 202 | # to use native NSModule(3) API and refers to dlfcn as termporary hack. | 200 | # to use native NSModule(3) API and refers to dlfcn as termporary hack. |
| 203 | link_o.darwin: | 201 | link_o.darwin: |
| 204 | @ $(CALC_VERSIONS); \ | 202 | @ $(CALC_VERSIONS); \ |
| 205 | SHLIB=lib$(LIBNAME); \ | 203 | SHLIB=`expr "$$THIS" : '.*/\([^/\.]*\)\.'`; \ |
| 206 | SHLIB_SUFFIX=.so; \ | 204 | SHLIB=$${SHLIB:-lib$(LIBNAME)}; \ |
| 205 | SHLIB_SUFFIX=`expr "$$THIS" : '.*\(\.[^\.]*\)$$'`; \ | ||
| 206 | SHLIB_SUFFIX=$${SHLIB_SUFFIX:-.so}; \ | ||
| 207 | ALLSYMSFLAGS='-all_load'; \ | 207 | ALLSYMSFLAGS='-all_load'; \ |
| 208 | NOALLSYMSFLAGS=''; \ | 208 | NOALLSYMSFLAGS=''; \ |
| 209 | SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS)"; \ | 209 | SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS)"; \ |
| @@ -491,23 +491,23 @@ link_app.hpux: | |||
| 491 | 491 | ||
| 492 | link_o.aix: | 492 | link_o.aix: |
| 493 | @ $(CALC_VERSIONS); \ | 493 | @ $(CALC_VERSIONS); \ |
| 494 | OBJECT_MODE=`expr x$(SHARED_LDFLAGS) : 'x\-[a-z]*\(64\)'` || :; \ | 494 | OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || :; \ |
| 495 | OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \ | 495 | OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \ |
| 496 | SHLIB=lib$(LIBNAME).so; \ | 496 | SHLIB=lib$(LIBNAME).so; \ |
| 497 | SHLIB_SUFFIX=; \ | 497 | SHLIB_SUFFIX=; \ |
| 498 | ALLSYMSFLAGS=''; \ | 498 | ALLSYMSFLAGS=''; \ |
| 499 | NOALLSYMSFLAGS=''; \ | 499 | NOALLSYMSFLAGS=''; \ |
| 500 | SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-G,-bexpall,-bnolibpath,-bM:SRE'; \ | 500 | SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \ |
| 501 | $(LINK_SO_O); | 501 | $(LINK_SO_O); |
| 502 | link_a.aix: | 502 | link_a.aix: |
| 503 | @ $(CALC_VERSIONS); \ | 503 | @ $(CALC_VERSIONS); \ |
| 504 | OBJECT_MODE=`expr x$(SHARED_LDFLAGS) : 'x\-[a-z]*\(64\)'` || : ; \ | 504 | OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || : ; \ |
| 505 | OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \ | 505 | OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \ |
| 506 | SHLIB=lib$(LIBNAME).so; \ | 506 | SHLIB=lib$(LIBNAME).so; \ |
| 507 | SHLIB_SUFFIX=; \ | 507 | SHLIB_SUFFIX=; \ |
| 508 | ALLSYMSFLAGS='-bnogc'; \ | 508 | ALLSYMSFLAGS='-bnogc'; \ |
| 509 | NOALLSYMSFLAGS=''; \ | 509 | NOALLSYMSFLAGS=''; \ |
| 510 | SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-G,-bexpall,-bnolibpath,-bM:SRE'; \ | 510 | SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \ |
| 511 | $(LINK_SO_A_VIA_O) | 511 | $(LINK_SO_A_VIA_O) |
| 512 | link_app.aix: | 512 | link_app.aix: |
| 513 | LDFLAGS="$(CFLAGS) -Wl,-brtl,-blibpath:$(LIBRPATH):$${LIBPATH:-/usr/lib:/lib}"; \ | 513 | LDFLAGS="$(CFLAGS) -Wl,-brtl,-blibpath:$(LIBRPATH):$${LIBPATH:-/usr/lib:/lib}"; \ |
diff --git a/src/lib/libssl/src/crypto/aes/asm/aes-586.pl b/src/lib/libssl/src/crypto/aes/asm/aes-586.pl index 89fa261794..3bc46a968e 100644 --- a/src/lib/libssl/src/crypto/aes/asm/aes-586.pl +++ b/src/lib/libssl/src/crypto/aes/asm/aes-586.pl | |||
| @@ -955,8 +955,9 @@ my $mark=&DWP(60+240,"esp"); #copy of aes_key->rounds | |||
| 955 | 955 | ||
| 956 | &align (4); | 956 | &align (4); |
| 957 | &set_label("enc_tail"); | 957 | &set_label("enc_tail"); |
| 958 | &push ($key eq "edi" ? $key : ""); # push ivp | 958 | &mov ($s0,$key eq "edi" ? $key : ""); |
| 959 | &mov ($key,$_out); # load out | 959 | &mov ($key,$_out); # load out |
| 960 | &push ($s0); # push ivp | ||
| 960 | &mov ($s1,16); | 961 | &mov ($s1,16); |
| 961 | &sub ($s1,$s2); | 962 | &sub ($s1,$s2); |
| 962 | &cmp ($key,$acc); # compare with inp | 963 | &cmp ($key,$acc); # compare with inp |
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 44e0bf8cae..f616f1751f 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 | |||
| @@ -1198,19 +1198,20 @@ AES_cbc_encrypt: | |||
| 1198 | ret | 1198 | ret |
| 1199 | .align 4 | 1199 | .align 4 |
| 1200 | .Lcbc_enc_tail: | 1200 | .Lcbc_enc_tail: |
| 1201 | cmp $inp,$out | 1201 | mov %rax,%r11 |
| 1202 | je .Lcbc_enc_in_place | 1202 | mov %rcx,%r12 |
| 1203 | mov %r10,%rcx | 1203 | mov %r10,%rcx |
| 1204 | mov $inp,%rsi | 1204 | mov $inp,%rsi |
| 1205 | mov $out,%rdi | 1205 | mov $out,%rdi |
| 1206 | .long 0xF689A4F3 # rep movsb | 1206 | .long 0xF689A4F3 # rep movsb |
| 1207 | .Lcbc_enc_in_place: | ||
| 1208 | mov \$16,%rcx # zero tail | 1207 | mov \$16,%rcx # zero tail |
| 1209 | sub %r10,%rcx | 1208 | sub %r10,%rcx |
| 1210 | xor %rax,%rax | 1209 | xor %rax,%rax |
| 1211 | .long 0xF689AAF3 # rep stosb | 1210 | .long 0xF689AAF3 # rep stosb |
| 1212 | mov $out,$inp # this is not a mistake! | 1211 | mov $out,$inp # this is not a mistake! |
| 1213 | movq \$16,$_len # len=16 | 1212 | movq \$16,$_len # len=16 |
| 1213 | mov %r11,%rax | ||
| 1214 | mov %r12,%rcx | ||
| 1214 | jmp .Lcbc_enc_loop # one more spin... | 1215 | jmp .Lcbc_enc_loop # one more spin... |
| 1215 | #----------------------------- DECRYPT -----------------------------# | 1216 | #----------------------------- DECRYPT -----------------------------# |
| 1216 | .align 16 | 1217 | .align 16 |
diff --git a/src/lib/libssl/src/crypto/asn1/asn1_gen.c b/src/lib/libssl/src/crypto/asn1/asn1_gen.c index 26c832781e..2da38292c8 100644 --- a/src/lib/libssl/src/crypto/asn1/asn1_gen.c +++ b/src/lib/libssl/src/crypto/asn1/asn1_gen.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* asn1_gen.c */ | 1 | /* asn1_gen.c */ |
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2002. | 3 | * project 2002. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
diff --git a/src/lib/libssl/src/crypto/asn1/asn_mime.c b/src/lib/libssl/src/crypto/asn1/asn_mime.c index fe7c4ec7ab..bc80b20d63 100644 --- a/src/lib/libssl/src/crypto/asn1/asn_mime.c +++ b/src/lib/libssl/src/crypto/asn1/asn_mime.c | |||
| @@ -526,6 +526,8 @@ int SMIME_text(BIO *in, BIO *out) | |||
| 526 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); | 526 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
| 527 | while ((len = BIO_read(in, iobuf, sizeof(iobuf))) > 0) | 527 | while ((len = BIO_read(in, iobuf, sizeof(iobuf))) > 0) |
| 528 | BIO_write(out, iobuf, len); | 528 | BIO_write(out, iobuf, len); |
| 529 | if (len < 0) | ||
| 530 | return 0; | ||
| 529 | return 1; | 531 | return 1; |
| 530 | } | 532 | } |
| 531 | 533 | ||
diff --git a/src/lib/libssl/src/crypto/bio/bss_dgram.c b/src/lib/libssl/src/crypto/bio/bss_dgram.c index ea2c3fff63..c3da6dc82f 100644 --- a/src/lib/libssl/src/crypto/bio/bss_dgram.c +++ b/src/lib/libssl/src/crypto/bio/bss_dgram.c | |||
| @@ -82,7 +82,7 @@ static int dgram_new(BIO *h); | |||
| 82 | static int dgram_free(BIO *data); | 82 | static int dgram_free(BIO *data); |
| 83 | static int dgram_clear(BIO *bio); | 83 | static int dgram_clear(BIO *bio); |
| 84 | 84 | ||
| 85 | int BIO_dgram_should_retry(int s); | 85 | static int BIO_dgram_should_retry(int s); |
| 86 | 86 | ||
| 87 | static BIO_METHOD methods_dgramp= | 87 | static BIO_METHOD methods_dgramp= |
| 88 | { | 88 | { |
| @@ -345,30 +345,90 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
| 345 | 345 | ||
| 346 | memcpy(&(data->peer), to, sizeof(struct sockaddr)); | 346 | memcpy(&(data->peer), to, sizeof(struct sockaddr)); |
| 347 | break; | 347 | break; |
| 348 | #if defined(SO_RCVTIMEO) | ||
| 348 | case BIO_CTRL_DGRAM_SET_RECV_TIMEOUT: | 349 | case BIO_CTRL_DGRAM_SET_RECV_TIMEOUT: |
| 350 | #ifdef OPENSSL_SYS_WINDOWS | ||
| 351 | { | ||
| 352 | struct timeval *tv = (struct timeval *)ptr; | ||
| 353 | int timeout = tv->tv_sec * 1000 + tv->tv_usec/1000; | ||
| 354 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | ||
| 355 | (void*)&timeout, sizeof(timeout)) < 0) | ||
| 356 | { perror("setsockopt"); ret = -1; } | ||
| 357 | } | ||
| 358 | #else | ||
| 349 | if ( setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, ptr, | 359 | if ( setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, ptr, |
| 350 | sizeof(struct timeval)) < 0) | 360 | sizeof(struct timeval)) < 0) |
| 351 | { perror("setsockopt"); ret = -1; } | 361 | { perror("setsockopt"); ret = -1; } |
| 362 | #endif | ||
| 352 | break; | 363 | break; |
| 353 | case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT: | 364 | case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT: |
| 365 | #ifdef OPENSSL_SYS_WINDOWS | ||
| 366 | { | ||
| 367 | int timeout, sz = sizeof(timeout); | ||
| 368 | struct timeval *tv = (struct timeval *)ptr; | ||
| 369 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | ||
| 370 | (void*)&timeout, &sz) < 0) | ||
| 371 | { perror("getsockopt"); ret = -1; } | ||
| 372 | else | ||
| 373 | { | ||
| 374 | tv->tv_sec = timeout / 1000; | ||
| 375 | tv->tv_usec = (timeout % 1000) * 1000; | ||
| 376 | ret = sizeof(*tv); | ||
| 377 | } | ||
| 378 | } | ||
| 379 | #else | ||
| 354 | if ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | 380 | if ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, |
| 355 | ptr, (void *)&ret) < 0) | 381 | ptr, (void *)&ret) < 0) |
| 356 | { perror("getsockopt"); ret = -1; } | 382 | { perror("getsockopt"); ret = -1; } |
| 383 | #endif | ||
| 357 | break; | 384 | break; |
| 385 | #endif | ||
| 386 | #if defined(SO_SNDTIMEO) | ||
| 358 | case BIO_CTRL_DGRAM_SET_SEND_TIMEOUT: | 387 | case BIO_CTRL_DGRAM_SET_SEND_TIMEOUT: |
| 388 | #ifdef OPENSSL_SYS_WINDOWS | ||
| 389 | { | ||
| 390 | struct timeval *tv = (struct timeval *)ptr; | ||
| 391 | int timeout = tv->tv_sec * 1000 + tv->tv_usec/1000; | ||
| 392 | if (setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, | ||
| 393 | (void*)&timeout, sizeof(timeout)) < 0) | ||
| 394 | { perror("setsockopt"); ret = -1; } | ||
| 395 | } | ||
| 396 | #else | ||
| 359 | if ( setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, ptr, | 397 | if ( setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, ptr, |
| 360 | sizeof(struct timeval)) < 0) | 398 | sizeof(struct timeval)) < 0) |
| 361 | { perror("setsockopt"); ret = -1; } | 399 | { perror("setsockopt"); ret = -1; } |
| 400 | #endif | ||
| 362 | break; | 401 | break; |
| 363 | case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT: | 402 | case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT: |
| 403 | #ifdef OPENSSL_SYS_WINDOWS | ||
| 404 | { | ||
| 405 | int timeout, sz = sizeof(timeout); | ||
| 406 | struct timeval *tv = (struct timeval *)ptr; | ||
| 407 | if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, | ||
| 408 | (void*)&timeout, &sz) < 0) | ||
| 409 | { perror("getsockopt"); ret = -1; } | ||
| 410 | else | ||
| 411 | { | ||
| 412 | tv->tv_sec = timeout / 1000; | ||
| 413 | tv->tv_usec = (timeout % 1000) * 1000; | ||
| 414 | ret = sizeof(*tv); | ||
| 415 | } | ||
| 416 | } | ||
| 417 | #else | ||
| 364 | if ( getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, | 418 | if ( getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, |
| 365 | ptr, (void *)&ret) < 0) | 419 | ptr, (void *)&ret) < 0) |
| 366 | { perror("getsockopt"); ret = -1; } | 420 | { perror("getsockopt"); ret = -1; } |
| 421 | #endif | ||
| 367 | break; | 422 | break; |
| 423 | #endif | ||
| 368 | case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP: | 424 | case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP: |
| 369 | /* fall-through */ | 425 | /* fall-through */ |
| 370 | case BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP: | 426 | case BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP: |
| 427 | #ifdef OPENSSL_SYS_WINDOWS | ||
| 428 | if ( data->_errno == WSAETIMEDOUT) | ||
| 429 | #else | ||
| 371 | if ( data->_errno == EAGAIN) | 430 | if ( data->_errno == EAGAIN) |
| 431 | #endif | ||
| 372 | { | 432 | { |
| 373 | ret = 1; | 433 | ret = 1; |
| 374 | data->_errno = 0; | 434 | data->_errno = 0; |
| @@ -403,7 +463,7 @@ static int dgram_puts(BIO *bp, const char *str) | |||
| 403 | return(ret); | 463 | return(ret); |
| 404 | } | 464 | } |
| 405 | 465 | ||
| 406 | int BIO_dgram_should_retry(int i) | 466 | static int BIO_dgram_should_retry(int i) |
| 407 | { | 467 | { |
| 408 | int err; | 468 | int err; |
| 409 | 469 | ||
diff --git a/src/lib/libssl/src/crypto/bn/bn_gf2m.c b/src/lib/libssl/src/crypto/bn/bn_gf2m.c index 6a793857e1..306f029f27 100644 --- a/src/lib/libssl/src/crypto/bn/bn_gf2m.c +++ b/src/lib/libssl/src/crypto/bn/bn_gf2m.c | |||
| @@ -384,7 +384,11 @@ int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[]) | |||
| 384 | if (zz == 0) break; | 384 | if (zz == 0) break; |
| 385 | d1 = BN_BITS2 - d0; | 385 | d1 = BN_BITS2 - d0; |
| 386 | 386 | ||
| 387 | if (d0) z[dN] = (z[dN] << d1) >> d1; /* clear up the top d1 bits */ | 387 | /* clear up the top d1 bits */ |
| 388 | if (d0) | ||
| 389 | z[dN] = (z[dN] << d1) >> d1; | ||
| 390 | else | ||
| 391 | z[dN] = 0; | ||
| 388 | z[0] ^= zz; /* reduction t^0 component */ | 392 | z[0] ^= zz; /* reduction t^0 component */ |
| 389 | 393 | ||
| 390 | for (k = 1; p[k] != 0; k++) | 394 | for (k = 1; p[k] != 0; k++) |
diff --git a/src/lib/libssl/src/crypto/bn/bn_nist.c b/src/lib/libssl/src/crypto/bn/bn_nist.c index e14232fdbb..2ca5b01391 100644 --- a/src/lib/libssl/src/crypto/bn/bn_nist.c +++ b/src/lib/libssl/src/crypto/bn/bn_nist.c | |||
| @@ -59,109 +59,266 @@ | |||
| 59 | #include "bn_lcl.h" | 59 | #include "bn_lcl.h" |
| 60 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
| 61 | 61 | ||
| 62 | |||
| 62 | #define BN_NIST_192_TOP (192+BN_BITS2-1)/BN_BITS2 | 63 | #define BN_NIST_192_TOP (192+BN_BITS2-1)/BN_BITS2 |
| 63 | #define BN_NIST_224_TOP (224+BN_BITS2-1)/BN_BITS2 | 64 | #define BN_NIST_224_TOP (224+BN_BITS2-1)/BN_BITS2 |
| 64 | #define BN_NIST_256_TOP (256+BN_BITS2-1)/BN_BITS2 | 65 | #define BN_NIST_256_TOP (256+BN_BITS2-1)/BN_BITS2 |
| 65 | #define BN_NIST_384_TOP (384+BN_BITS2-1)/BN_BITS2 | 66 | #define BN_NIST_384_TOP (384+BN_BITS2-1)/BN_BITS2 |
| 66 | #define BN_NIST_521_TOP (521+BN_BITS2-1)/BN_BITS2 | 67 | #define BN_NIST_521_TOP (521+BN_BITS2-1)/BN_BITS2 |
| 67 | 68 | ||
| 69 | /* pre-computed tables are "carry-less" values of modulus*(i+1) */ | ||
| 68 | #if BN_BITS2 == 64 | 70 | #if BN_BITS2 == 64 |
| 69 | static const BN_ULONG _nist_p_192[] = | 71 | static const BN_ULONG _nist_p_192[][BN_NIST_192_TOP] = { |
| 70 | {0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFEULL, | 72 | {0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFEULL,0xFFFFFFFFFFFFFFFFULL}, |
| 71 | 0xFFFFFFFFFFFFFFFFULL}; | 73 | {0xFFFFFFFFFFFFFFFEULL,0xFFFFFFFFFFFFFFFDULL,0xFFFFFFFFFFFFFFFFULL}, |
| 72 | static const BN_ULONG _nist_p_224[] = | 74 | {0xFFFFFFFFFFFFFFFDULL,0xFFFFFFFFFFFFFFFCULL,0xFFFFFFFFFFFFFFFFULL} |
| 75 | }; | ||
| 76 | static const BN_ULONG _nist_p_192_sqr[] = { | ||
| 77 | 0x0000000000000001ULL,0x0000000000000002ULL,0x0000000000000001ULL, | ||
| 78 | 0xFFFFFFFFFFFFFFFEULL,0xFFFFFFFFFFFFFFFDULL,0xFFFFFFFFFFFFFFFFULL | ||
| 79 | }; | ||
| 80 | static const BN_ULONG _nist_p_224[][BN_NIST_224_TOP] = { | ||
| 73 | {0x0000000000000001ULL,0xFFFFFFFF00000000ULL, | 81 | {0x0000000000000001ULL,0xFFFFFFFF00000000ULL, |
| 74 | 0xFFFFFFFFFFFFFFFFULL,0x00000000FFFFFFFFULL}; | 82 | 0xFFFFFFFFFFFFFFFFULL,0x00000000FFFFFFFFULL}, |
| 75 | static const BN_ULONG _nist_p_256[] = | 83 | {0x0000000000000002ULL,0xFFFFFFFE00000000ULL, |
| 84 | 0xFFFFFFFFFFFFFFFFULL,0x00000001FFFFFFFFULL} /* this one is "carry-full" */ | ||
| 85 | }; | ||
| 86 | static const BN_ULONG _nist_p_224_sqr[] = { | ||
| 87 | 0x0000000000000001ULL,0xFFFFFFFE00000000ULL, | ||
| 88 | 0xFFFFFFFFFFFFFFFFULL,0x0000000200000000ULL, | ||
| 89 | 0x0000000000000000ULL,0xFFFFFFFFFFFFFFFEULL, | ||
| 90 | 0xFFFFFFFFFFFFFFFFULL | ||
| 91 | }; | ||
| 92 | static const BN_ULONG _nist_p_256[][BN_NIST_256_TOP] = { | ||
| 76 | {0xFFFFFFFFFFFFFFFFULL,0x00000000FFFFFFFFULL, | 93 | {0xFFFFFFFFFFFFFFFFULL,0x00000000FFFFFFFFULL, |
| 77 | 0x0000000000000000ULL,0xFFFFFFFF00000001ULL}; | 94 | 0x0000000000000000ULL,0xFFFFFFFF00000001ULL}, |
| 78 | static const BN_ULONG _nist_p_384[] = | 95 | {0xFFFFFFFFFFFFFFFEULL,0x00000001FFFFFFFFULL, |
| 79 | {0x00000000FFFFFFFFULL,0xFFFFFFFF00000000ULL, | 96 | 0x0000000000000000ULL,0xFFFFFFFE00000002ULL}, |
| 80 | 0xFFFFFFFFFFFFFFFEULL,0xFFFFFFFFFFFFFFFFULL, | 97 | {0xFFFFFFFFFFFFFFFDULL,0x00000002FFFFFFFFULL, |
| 81 | 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}; | 98 | 0x0000000000000000ULL,0xFFFFFFFD00000003ULL}, |
| 99 | {0xFFFFFFFFFFFFFFFCULL,0x00000003FFFFFFFFULL, | ||
| 100 | 0x0000000000000000ULL,0xFFFFFFFC00000004ULL}, | ||
| 101 | {0xFFFFFFFFFFFFFFFBULL,0x00000004FFFFFFFFULL, | ||
| 102 | 0x0000000000000000ULL,0xFFFFFFFB00000005ULL}, | ||
| 103 | }; | ||
| 104 | static const BN_ULONG _nist_p_256_sqr[] = { | ||
| 105 | 0x0000000000000001ULL,0xFFFFFFFE00000000ULL, | ||
| 106 | 0xFFFFFFFFFFFFFFFFULL,0x00000001FFFFFFFEULL, | ||
| 107 | 0x00000001FFFFFFFEULL,0x00000001FFFFFFFEULL, | ||
| 108 | 0xFFFFFFFE00000001ULL,0xFFFFFFFE00000002ULL | ||
| 109 | }; | ||
| 110 | static const BN_ULONG _nist_p_384[][BN_NIST_384_TOP] = { | ||
| 111 | {0x00000000FFFFFFFFULL,0xFFFFFFFF00000000ULL,0xFFFFFFFFFFFFFFFEULL, | ||
| 112 | 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, | ||
| 113 | {0x00000001FFFFFFFEULL,0xFFFFFFFE00000000ULL,0xFFFFFFFFFFFFFFFDULL, | ||
| 114 | 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, | ||
| 115 | {0x00000002FFFFFFFDULL,0xFFFFFFFD00000000ULL,0xFFFFFFFFFFFFFFFCULL, | ||
| 116 | 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, | ||
| 117 | {0x00000003FFFFFFFCULL,0xFFFFFFFC00000000ULL,0xFFFFFFFFFFFFFFFBULL, | ||
| 118 | 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, | ||
| 119 | {0x00000004FFFFFFFBULL,0xFFFFFFFB00000000ULL,0xFFFFFFFFFFFFFFFAULL, | ||
| 120 | 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, | ||
| 121 | }; | ||
| 122 | static const BN_ULONG _nist_p_384_sqr[] = { | ||
| 123 | 0xFFFFFFFE00000001ULL,0x0000000200000000ULL,0xFFFFFFFE00000000ULL, | ||
| 124 | 0x0000000200000000ULL,0x0000000000000001ULL,0x0000000000000000ULL, | ||
| 125 | 0x00000001FFFFFFFEULL,0xFFFFFFFE00000000ULL,0xFFFFFFFFFFFFFFFDULL, | ||
| 126 | 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL | ||
| 127 | }; | ||
| 82 | static const BN_ULONG _nist_p_521[] = | 128 | static const BN_ULONG _nist_p_521[] = |
| 83 | {0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL, | 129 | {0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL, |
| 84 | 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL, | 130 | 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL, |
| 85 | 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL, | 131 | 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL, |
| 86 | 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL, | 132 | 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL, |
| 87 | 0x00000000000001FFULL}; | 133 | 0x00000000000001FFULL}; |
| 134 | static const BN_ULONG _nist_p_521_sqr[] = { | ||
| 135 | 0x0000000000000001ULL,0x0000000000000000ULL,0x0000000000000000ULL, | ||
| 136 | 0x0000000000000000ULL,0x0000000000000000ULL,0x0000000000000000ULL, | ||
| 137 | 0x0000000000000000ULL,0x0000000000000000ULL,0xFFFFFFFFFFFFFC00ULL, | ||
| 138 | 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL, | ||
| 139 | 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL, | ||
| 140 | 0xFFFFFFFFFFFFFFFFULL,0x000000000003FFFFULL | ||
| 141 | }; | ||
| 88 | #elif BN_BITS2 == 32 | 142 | #elif BN_BITS2 == 32 |
| 89 | static const BN_ULONG _nist_p_192[] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFE, | 143 | static const BN_ULONG _nist_p_192[][BN_NIST_192_TOP] = { |
| 90 | 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}; | 144 | {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFE,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}, |
| 91 | static const BN_ULONG _nist_p_224[] = {0x00000001,0x00000000,0x00000000, | 145 | {0xFFFFFFFE,0xFFFFFFFF,0xFFFFFFFD,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}, |
| 92 | 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}; | 146 | {0xFFFFFFFD,0xFFFFFFFF,0xFFFFFFFC,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF} |
| 93 | static const BN_ULONG _nist_p_256[] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF, | 147 | }; |
| 94 | 0x00000000,0x00000000,0x00000000,0x00000001,0xFFFFFFFF}; | 148 | static const BN_ULONG _nist_p_192_sqr[] = { |
| 95 | static const BN_ULONG _nist_p_384[] = {0xFFFFFFFF,0x00000000,0x00000000, | 149 | 0x00000001,0x00000000,0x00000002,0x00000000,0x00000001,0x00000000, |
| 96 | 0xFFFFFFFF,0xFFFFFFFE,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF, | 150 | 0xFFFFFFFE,0xFFFFFFFF,0xFFFFFFFD,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF |
| 97 | 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}; | 151 | }; |
| 152 | static const BN_ULONG _nist_p_224[][BN_NIST_224_TOP] = { | ||
| 153 | {0x00000001,0x00000000,0x00000000,0xFFFFFFFF, | ||
| 154 | 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}, | ||
| 155 | {0x00000002,0x00000000,0x00000000,0xFFFFFFFE, | ||
| 156 | 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF} | ||
| 157 | }; | ||
| 158 | static const BN_ULONG _nist_p_224_sqr[] = { | ||
| 159 | 0x00000001,0x00000000,0x00000000,0xFFFFFFFE, | ||
| 160 | 0xFFFFFFFF,0xFFFFFFFF,0x00000000,0x00000002, | ||
| 161 | 0x00000000,0x00000000,0xFFFFFFFE,0xFFFFFFFF, | ||
| 162 | 0xFFFFFFFF,0xFFFFFFFF | ||
| 163 | }; | ||
| 164 | static const BN_ULONG _nist_p_256[][BN_NIST_256_TOP] = { | ||
| 165 | {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0x00000000, | ||
| 166 | 0x00000000,0x00000000,0x00000001,0xFFFFFFFF}, | ||
| 167 | {0xFFFFFFFE,0xFFFFFFFF,0xFFFFFFFF,0x00000001, | ||
| 168 | 0x00000000,0x00000000,0x00000002,0xFFFFFFFE}, | ||
| 169 | {0xFFFFFFFD,0xFFFFFFFF,0xFFFFFFFF,0x00000002, | ||
| 170 | 0x00000000,0x00000000,0x00000003,0xFFFFFFFD}, | ||
| 171 | {0xFFFFFFFC,0xFFFFFFFF,0xFFFFFFFF,0x00000003, | ||
| 172 | 0x00000000,0x00000000,0x00000004,0xFFFFFFFC}, | ||
| 173 | {0xFFFFFFFB,0xFFFFFFFF,0xFFFFFFFF,0x00000004, | ||
| 174 | 0x00000000,0x00000000,0x00000005,0xFFFFFFFB}, | ||
| 175 | }; | ||
| 176 | static const BN_ULONG _nist_p_256_sqr[] = { | ||
| 177 | 0x00000001,0x00000000,0x00000000,0xFFFFFFFE, | ||
| 178 | 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFE,0x00000001, | ||
| 179 | 0xFFFFFFFE,0x00000001,0xFFFFFFFE,0x00000001, | ||
| 180 | 0x00000001,0xFFFFFFFE,0x00000002,0xFFFFFFFE | ||
| 181 | }; | ||
| 182 | static const BN_ULONG _nist_p_384[][BN_NIST_384_TOP] = { | ||
| 183 | {0xFFFFFFFF,0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFE,0xFFFFFFFF, | ||
| 184 | 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}, | ||
| 185 | {0xFFFFFFFE,0x00000001,0x00000000,0xFFFFFFFE,0xFFFFFFFD,0xFFFFFFFF, | ||
| 186 | 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}, | ||
| 187 | {0xFFFFFFFD,0x00000002,0x00000000,0xFFFFFFFD,0xFFFFFFFC,0xFFFFFFFF, | ||
| 188 | 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}, | ||
| 189 | {0xFFFFFFFC,0x00000003,0x00000000,0xFFFFFFFC,0xFFFFFFFB,0xFFFFFFFF, | ||
| 190 | 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}, | ||
| 191 | {0xFFFFFFFB,0x00000004,0x00000000,0xFFFFFFFB,0xFFFFFFFA,0xFFFFFFFF, | ||
| 192 | 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}, | ||
| 193 | }; | ||
| 194 | static const BN_ULONG _nist_p_384_sqr[] = { | ||
| 195 | 0x00000001,0xFFFFFFFE,0x00000000,0x00000002,0x00000000,0xFFFFFFFE, | ||
| 196 | 0x00000000,0x00000002,0x00000001,0x00000000,0x00000000,0x00000000, | ||
| 197 | 0xFFFFFFFE,0x00000001,0x00000000,0xFFFFFFFE,0xFFFFFFFD,0xFFFFFFFF, | ||
| 198 | 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF | ||
| 199 | }; | ||
| 98 | static const BN_ULONG _nist_p_521[] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF, | 200 | static const BN_ULONG _nist_p_521[] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF, |
| 99 | 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF, | 201 | 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF, |
| 100 | 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF, | 202 | 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF, |
| 101 | 0xFFFFFFFF,0x000001FF}; | 203 | 0xFFFFFFFF,0x000001FF}; |
| 204 | static const BN_ULONG _nist_p_521_sqr[] = { | ||
| 205 | 0x00000001,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, | ||
| 206 | 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, | ||
| 207 | 0x00000000,0x00000000,0x00000000,0x00000000,0xFFFFFC00,0xFFFFFFFF, | ||
| 208 | 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF, | ||
| 209 | 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF, | ||
| 210 | 0xFFFFFFFF,0xFFFFFFFF,0x0003FFFF | ||
| 211 | }; | ||
| 212 | #else | ||
| 213 | #error "unsupported BN_BITS2" | ||
| 102 | #endif | 214 | #endif |
| 103 | 215 | ||
| 216 | |||
| 217 | static const BIGNUM _bignum_nist_p_192 = | ||
| 218 | { | ||
| 219 | (BN_ULONG *)_nist_p_192[0], | ||
| 220 | BN_NIST_192_TOP, | ||
| 221 | BN_NIST_192_TOP, | ||
| 222 | 0, | ||
| 223 | BN_FLG_STATIC_DATA | ||
| 224 | }; | ||
| 225 | |||
| 226 | static const BIGNUM _bignum_nist_p_224 = | ||
| 227 | { | ||
| 228 | (BN_ULONG *)_nist_p_224[0], | ||
| 229 | BN_NIST_224_TOP, | ||
| 230 | BN_NIST_224_TOP, | ||
| 231 | 0, | ||
| 232 | BN_FLG_STATIC_DATA | ||
| 233 | }; | ||
| 234 | |||
| 235 | static const BIGNUM _bignum_nist_p_256 = | ||
| 236 | { | ||
| 237 | (BN_ULONG *)_nist_p_256[0], | ||
| 238 | BN_NIST_256_TOP, | ||
| 239 | BN_NIST_256_TOP, | ||
| 240 | 0, | ||
| 241 | BN_FLG_STATIC_DATA | ||
| 242 | }; | ||
| 243 | |||
| 244 | static const BIGNUM _bignum_nist_p_384 = | ||
| 245 | { | ||
| 246 | (BN_ULONG *)_nist_p_384[0], | ||
| 247 | BN_NIST_384_TOP, | ||
| 248 | BN_NIST_384_TOP, | ||
| 249 | 0, | ||
| 250 | BN_FLG_STATIC_DATA | ||
| 251 | }; | ||
| 252 | |||
| 253 | static const BIGNUM _bignum_nist_p_521 = | ||
| 254 | { | ||
| 255 | (BN_ULONG *)_nist_p_521, | ||
| 256 | BN_NIST_521_TOP, | ||
| 257 | BN_NIST_521_TOP, | ||
| 258 | 0, | ||
| 259 | BN_FLG_STATIC_DATA | ||
| 260 | }; | ||
| 261 | |||
| 262 | |||
| 104 | const BIGNUM *BN_get0_nist_prime_192(void) | 263 | const BIGNUM *BN_get0_nist_prime_192(void) |
| 105 | { | 264 | { |
| 106 | static BIGNUM const_nist_192 = { (BN_ULONG *)_nist_p_192, | 265 | return &_bignum_nist_p_192; |
| 107 | BN_NIST_192_TOP, BN_NIST_192_TOP, 0, BN_FLG_STATIC_DATA }; | ||
| 108 | return &const_nist_192; | ||
| 109 | } | 266 | } |
| 110 | 267 | ||
| 111 | const BIGNUM *BN_get0_nist_prime_224(void) | 268 | const BIGNUM *BN_get0_nist_prime_224(void) |
| 112 | { | 269 | { |
| 113 | static BIGNUM const_nist_224 = { (BN_ULONG *)_nist_p_224, | 270 | return &_bignum_nist_p_224; |
| 114 | BN_NIST_224_TOP, BN_NIST_224_TOP, 0, BN_FLG_STATIC_DATA }; | ||
| 115 | return &const_nist_224; | ||
| 116 | } | 271 | } |
| 117 | 272 | ||
| 118 | const BIGNUM *BN_get0_nist_prime_256(void) | 273 | const BIGNUM *BN_get0_nist_prime_256(void) |
| 119 | { | 274 | { |
| 120 | static BIGNUM const_nist_256 = { (BN_ULONG *)_nist_p_256, | 275 | return &_bignum_nist_p_256; |
| 121 | BN_NIST_256_TOP, BN_NIST_256_TOP, 0, BN_FLG_STATIC_DATA }; | ||
| 122 | return &const_nist_256; | ||
| 123 | } | 276 | } |
| 124 | 277 | ||
| 125 | const BIGNUM *BN_get0_nist_prime_384(void) | 278 | const BIGNUM *BN_get0_nist_prime_384(void) |
| 126 | { | 279 | { |
| 127 | static BIGNUM const_nist_384 = { (BN_ULONG *)_nist_p_384, | 280 | return &_bignum_nist_p_384; |
| 128 | BN_NIST_384_TOP, BN_NIST_384_TOP, 0, BN_FLG_STATIC_DATA }; | ||
| 129 | return &const_nist_384; | ||
| 130 | } | 281 | } |
| 131 | 282 | ||
| 132 | const BIGNUM *BN_get0_nist_prime_521(void) | 283 | const BIGNUM *BN_get0_nist_prime_521(void) |
| 133 | { | 284 | { |
| 134 | static BIGNUM const_nist_521 = { (BN_ULONG *)_nist_p_521, | 285 | return &_bignum_nist_p_521; |
| 135 | BN_NIST_521_TOP, BN_NIST_521_TOP, 0, BN_FLG_STATIC_DATA }; | ||
| 136 | return &const_nist_521; | ||
| 137 | } | 286 | } |
| 138 | 287 | ||
| 139 | #define BN_NIST_ADD_ONE(a) while (!(*(a)=(*(a)+1)&BN_MASK2)) ++(a); | ||
| 140 | 288 | ||
| 141 | static void nist_cp_bn_0(BN_ULONG *buf, BN_ULONG *a, int top, int max) | 289 | static void nist_cp_bn_0(BN_ULONG *buf, BN_ULONG *a, int top, int max) |
| 142 | { | 290 | { |
| 143 | int i; | 291 | int i; |
| 144 | BN_ULONG *_tmp1 = (buf), *_tmp2 = (a); | 292 | BN_ULONG *_tmp1 = (buf), *_tmp2 = (a); |
| 145 | for (i = (top); i != 0; i--) | 293 | |
| 146 | *_tmp1++ = *_tmp2++; | 294 | #ifdef BN_DEBUG |
| 147 | for (i = (max) - (top); i != 0; i--) | 295 | OPENSSL_assert(top <= max); |
| 148 | *_tmp1++ = (BN_ULONG) 0; | 296 | #endif |
| 149 | } | 297 | for (i = (top); i != 0; i--) |
| 298 | *_tmp1++ = *_tmp2++; | ||
| 299 | for (i = (max) - (top); i != 0; i--) | ||
| 300 | *_tmp1++ = (BN_ULONG) 0; | ||
| 301 | } | ||
| 150 | 302 | ||
| 151 | static void nist_cp_bn(BN_ULONG *buf, BN_ULONG *a, int top) | 303 | static void nist_cp_bn(BN_ULONG *buf, BN_ULONG *a, int top) |
| 152 | { | 304 | { |
| 153 | int i; | 305 | int i; |
| 154 | BN_ULONG *_tmp1 = (buf), *_tmp2 = (a); | 306 | BN_ULONG *_tmp1 = (buf), *_tmp2 = (a); |
| 155 | for (i = (top); i != 0; i--) | 307 | for (i = (top); i != 0; i--) |
| 156 | *_tmp1++ = *_tmp2++; | 308 | *_tmp1++ = *_tmp2++; |
| 157 | } | 309 | } |
| 158 | 310 | ||
| 159 | #if BN_BITS2 == 64 | 311 | #if BN_BITS2 == 64 |
| 160 | #define bn_cp_64(to, n, from, m) (to)[n] = (m>=0)?((from)[m]):0; | 312 | #define bn_cp_64(to, n, from, m) (to)[n] = (m>=0)?((from)[m]):0; |
| 161 | #define bn_64_set_0(to, n) (to)[n] = (BN_ULONG)0; | 313 | #define bn_64_set_0(to, n) (to)[n] = (BN_ULONG)0; |
| 162 | /* TBD */ | 314 | /* |
| 163 | #define bn_cp_32(to, n, from, m) (to)[n] = (m>=0)?((from)[m]):0; | 315 | * two following macros are implemented under assumption that they |
| 164 | #define bn_32_set_0(to, n) (to)[n] = (BN_ULONG)0; | 316 | * are called in a sequence with *ascending* n, i.e. as they are... |
| 317 | */ | ||
| 318 | #define bn_cp_32_naked(to, n, from, m) (((n)&1)?(to[(n)/2]|=((m)&1)?(from[(m)/2]&BN_MASK2h):(from[(m)/2]<<32))\ | ||
| 319 | :(to[(n)/2] =((m)&1)?(from[(m)/2]>>32):(from[(m)/2]&BN_MASK2l))) | ||
| 320 | #define bn_32_set_0(to, n) (((n)&1)?(to[(n)/2]&=BN_MASK2l):(to[(n)/2]=0)); | ||
| 321 | #define bn_cp_32(to,n,from,m) ((m)>=0)?bn_cp_32_naked(to,n,from,m):bn_32_set_0(to,n) | ||
| 165 | #else | 322 | #else |
| 166 | #define bn_cp_64(to, n, from, m) \ | 323 | #define bn_cp_64(to, n, from, m) \ |
| 167 | { \ | 324 | { \ |
| @@ -182,9 +339,9 @@ static void nist_cp_bn(BN_ULONG *buf, BN_ULONG *a, int top) | |||
| 182 | 339 | ||
| 183 | #define nist_set_192(to, from, a1, a2, a3) \ | 340 | #define nist_set_192(to, from, a1, a2, a3) \ |
| 184 | { \ | 341 | { \ |
| 185 | if (a3 != 0) bn_cp_64(to, 0, from, (a3) - 3) else bn_64_set_0(to, 0)\ | 342 | bn_cp_64(to, 0, from, (a3) - 3) \ |
| 186 | bn_cp_64(to, 1, from, (a2) - 3) \ | 343 | bn_cp_64(to, 1, from, (a2) - 3) \ |
| 187 | if (a1 != 0) bn_cp_64(to, 2, from, (a1) - 3) else bn_64_set_0(to, 2)\ | 344 | bn_cp_64(to, 2, from, (a1) - 3) \ |
| 188 | } | 345 | } |
| 189 | 346 | ||
| 190 | int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | 347 | int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, |
| @@ -198,6 +355,16 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
| 198 | c_d[BN_NIST_192_TOP], | 355 | c_d[BN_NIST_192_TOP], |
| 199 | *res; | 356 | *res; |
| 200 | size_t mask; | 357 | size_t mask; |
| 358 | static const BIGNUM _bignum_nist_p_192_sqr = { | ||
| 359 | (BN_ULONG *)_nist_p_192_sqr, | ||
| 360 | sizeof(_nist_p_192_sqr)/sizeof(_nist_p_192_sqr[0]), | ||
| 361 | sizeof(_nist_p_192_sqr)/sizeof(_nist_p_192_sqr[0]), | ||
| 362 | 0,BN_FLG_STATIC_DATA }; | ||
| 363 | |||
| 364 | field = &_bignum_nist_p_192; /* just to make sure */ | ||
| 365 | |||
| 366 | if (BN_is_negative(a) || BN_ucmp(a,&_bignum_nist_p_192_sqr)>=0) | ||
| 367 | return BN_nnmod(r, a, field, ctx); | ||
| 201 | 368 | ||
| 202 | i = BN_ucmp(field, a); | 369 | i = BN_ucmp(field, a); |
| 203 | if (i == 0) | 370 | if (i == 0) |
| @@ -208,9 +375,6 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
| 208 | else if (i > 0) | 375 | else if (i > 0) |
| 209 | return (r == a) ? 1 : (BN_copy(r ,a) != NULL); | 376 | return (r == a) ? 1 : (BN_copy(r ,a) != NULL); |
| 210 | 377 | ||
| 211 | if (top == BN_NIST_192_TOP) | ||
| 212 | return BN_usub(r, a, field); | ||
| 213 | |||
| 214 | if (r != a) | 378 | if (r != a) |
| 215 | { | 379 | { |
| 216 | if (!bn_wexpand(r, BN_NIST_192_TOP)) | 380 | if (!bn_wexpand(r, BN_NIST_192_TOP)) |
| @@ -224,23 +388,26 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
| 224 | nist_cp_bn_0(buf, a_d + BN_NIST_192_TOP, top - BN_NIST_192_TOP, BN_NIST_192_TOP); | 388 | nist_cp_bn_0(buf, a_d + BN_NIST_192_TOP, top - BN_NIST_192_TOP, BN_NIST_192_TOP); |
| 225 | 389 | ||
| 226 | nist_set_192(t_d, buf, 0, 3, 3); | 390 | nist_set_192(t_d, buf, 0, 3, 3); |
| 227 | carry = bn_add_words(r_d, r_d, t_d, BN_NIST_192_TOP); | 391 | carry = (int)bn_add_words(r_d, r_d, t_d, BN_NIST_192_TOP); |
| 228 | mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_192,BN_NIST_192_TOP); | ||
| 229 | mask = ~mask | (0-(size_t)carry); | ||
| 230 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 231 | |||
| 232 | nist_set_192(t_d, buf, 4, 4, 0); | 392 | nist_set_192(t_d, buf, 4, 4, 0); |
| 233 | carry = bn_add_words(r_d, res, t_d, BN_NIST_192_TOP); | 393 | carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_192_TOP); |
| 234 | mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_192,BN_NIST_192_TOP); | ||
| 235 | mask = ~mask | (0-(size_t)carry); | ||
| 236 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 237 | |||
| 238 | nist_set_192(t_d, buf, 5, 5, 5) | 394 | nist_set_192(t_d, buf, 5, 5, 5) |
| 239 | carry = bn_add_words(r_d, res, t_d, BN_NIST_192_TOP); | 395 | carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_192_TOP); |
| 240 | mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_192,BN_NIST_192_TOP); | ||
| 241 | mask = ~mask | (0-(size_t)carry); | ||
| 242 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 243 | 396 | ||
| 397 | if (carry > 0) | ||
| 398 | carry = (int)bn_sub_words(r_d,r_d,_nist_p_192[carry-1],BN_NIST_192_TOP); | ||
| 399 | else | ||
| 400 | carry = 1; | ||
| 401 | |||
| 402 | /* | ||
| 403 | * we need 'if (carry==0 || result>=modulus) result-=modulus;' | ||
| 404 | * as comparison implies subtraction, we can write | ||
| 405 | * 'tmp=result-modulus; if (!carry || !borrow) result=tmp;' | ||
| 406 | * this is what happens below, but without explicit if:-) a. | ||
| 407 | */ | ||
| 408 | mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_192[0],BN_NIST_192_TOP); | ||
| 409 | mask &= 0-(size_t)carry; | ||
| 410 | res = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask)); | ||
| 244 | nist_cp_bn(r_d, res, BN_NIST_192_TOP); | 411 | nist_cp_bn(r_d, res, BN_NIST_192_TOP); |
| 245 | r->top = BN_NIST_192_TOP; | 412 | r->top = BN_NIST_192_TOP; |
| 246 | bn_correct_top(r); | 413 | bn_correct_top(r); |
| @@ -248,21 +415,22 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
| 248 | return 1; | 415 | return 1; |
| 249 | } | 416 | } |
| 250 | 417 | ||
| 418 | typedef BN_ULONG (*bn_addsub_f)(BN_ULONG *,const BN_ULONG *,const BN_ULONG *,int); | ||
| 419 | |||
| 251 | #define nist_set_224(to, from, a1, a2, a3, a4, a5, a6, a7) \ | 420 | #define nist_set_224(to, from, a1, a2, a3, a4, a5, a6, a7) \ |
| 252 | { \ | 421 | { \ |
| 253 | if (a7 != 0) bn_cp_32(to, 0, from, (a7) - 7) else bn_32_set_0(to, 0)\ | 422 | bn_cp_32(to, 0, from, (a7) - 7) \ |
| 254 | if (a6 != 0) bn_cp_32(to, 1, from, (a6) - 7) else bn_32_set_0(to, 1)\ | 423 | bn_cp_32(to, 1, from, (a6) - 7) \ |
| 255 | if (a5 != 0) bn_cp_32(to, 2, from, (a5) - 7) else bn_32_set_0(to, 2)\ | 424 | bn_cp_32(to, 2, from, (a5) - 7) \ |
| 256 | if (a4 != 0) bn_cp_32(to, 3, from, (a4) - 7) else bn_32_set_0(to, 3)\ | 425 | bn_cp_32(to, 3, from, (a4) - 7) \ |
| 257 | if (a3 != 0) bn_cp_32(to, 4, from, (a3) - 7) else bn_32_set_0(to, 4)\ | 426 | bn_cp_32(to, 4, from, (a3) - 7) \ |
| 258 | if (a2 != 0) bn_cp_32(to, 5, from, (a2) - 7) else bn_32_set_0(to, 5)\ | 427 | bn_cp_32(to, 5, from, (a2) - 7) \ |
| 259 | if (a1 != 0) bn_cp_32(to, 6, from, (a1) - 7) else bn_32_set_0(to, 6)\ | 428 | bn_cp_32(to, 6, from, (a1) - 7) \ |
| 260 | } | 429 | } |
| 261 | 430 | ||
| 262 | int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | 431 | int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, |
| 263 | BN_CTX *ctx) | 432 | BN_CTX *ctx) |
| 264 | { | 433 | { |
| 265 | #if BN_BITS2 == 32 | ||
| 266 | int top = a->top, i; | 434 | int top = a->top, i; |
| 267 | int carry; | 435 | int carry; |
| 268 | BN_ULONG *r_d, *a_d = a->d; | 436 | BN_ULONG *r_d, *a_d = a->d; |
| @@ -271,6 +439,18 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
| 271 | c_d[BN_NIST_224_TOP], | 439 | c_d[BN_NIST_224_TOP], |
| 272 | *res; | 440 | *res; |
| 273 | size_t mask; | 441 | size_t mask; |
| 442 | union { bn_addsub_f f; size_t p; } u; | ||
| 443 | static const BIGNUM _bignum_nist_p_224_sqr = { | ||
| 444 | (BN_ULONG *)_nist_p_224_sqr, | ||
| 445 | sizeof(_nist_p_224_sqr)/sizeof(_nist_p_224_sqr[0]), | ||
| 446 | sizeof(_nist_p_224_sqr)/sizeof(_nist_p_224_sqr[0]), | ||
| 447 | 0,BN_FLG_STATIC_DATA }; | ||
| 448 | |||
| 449 | |||
| 450 | field = &_bignum_nist_p_224; /* just to make sure */ | ||
| 451 | |||
| 452 | if (BN_is_negative(a) || BN_ucmp(a,&_bignum_nist_p_224_sqr)>=0) | ||
| 453 | return BN_nnmod(r, a, field, ctx); | ||
| 274 | 454 | ||
| 275 | i = BN_ucmp(field, a); | 455 | i = BN_ucmp(field, a); |
| 276 | if (i == 0) | 456 | if (i == 0) |
| @@ -281,9 +461,6 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
| 281 | else if (i > 0) | 461 | else if (i > 0) |
| 282 | return (r == a)? 1 : (BN_copy(r ,a) != NULL); | 462 | return (r == a)? 1 : (BN_copy(r ,a) != NULL); |
| 283 | 463 | ||
| 284 | if (top == BN_NIST_224_TOP) | ||
| 285 | return BN_usub(r, a, field); | ||
| 286 | |||
| 287 | if (r != a) | 464 | if (r != a) |
| 288 | { | 465 | { |
| 289 | if (!bn_wexpand(r, BN_NIST_224_TOP)) | 466 | if (!bn_wexpand(r, BN_NIST_224_TOP)) |
| @@ -294,67 +471,77 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
| 294 | else | 471 | else |
| 295 | r_d = a_d; | 472 | r_d = a_d; |
| 296 | 473 | ||
| 474 | #if BN_BITS2==64 | ||
| 475 | /* copy upper 256 bits of 448 bit number ... */ | ||
| 476 | nist_cp_bn_0(t_d, a_d + (BN_NIST_224_TOP-1), top - (BN_NIST_224_TOP-1), BN_NIST_224_TOP); | ||
| 477 | /* ... and right shift by 32 to obtain upper 224 bits */ | ||
| 478 | nist_set_224(buf, t_d, 14, 13, 12, 11, 10, 9, 8); | ||
| 479 | /* truncate lower part to 224 bits too */ | ||
| 480 | r_d[BN_NIST_224_TOP-1] &= BN_MASK2l; | ||
| 481 | #else | ||
| 297 | nist_cp_bn_0(buf, a_d + BN_NIST_224_TOP, top - BN_NIST_224_TOP, BN_NIST_224_TOP); | 482 | nist_cp_bn_0(buf, a_d + BN_NIST_224_TOP, top - BN_NIST_224_TOP, BN_NIST_224_TOP); |
| 298 | 483 | #endif | |
| 299 | nist_set_224(t_d, buf, 10, 9, 8, 7, 0, 0, 0); | 484 | nist_set_224(t_d, buf, 10, 9, 8, 7, 0, 0, 0); |
| 300 | carry = bn_add_words(r_d, r_d, t_d, BN_NIST_224_TOP); | 485 | carry = (int)bn_add_words(r_d, r_d, t_d, BN_NIST_224_TOP); |
| 301 | mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_224,BN_NIST_224_TOP); | ||
| 302 | mask = ~mask | (0-(size_t)carry); | ||
| 303 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 304 | |||
| 305 | nist_set_224(t_d, buf, 0, 13, 12, 11, 0, 0, 0); | 486 | nist_set_224(t_d, buf, 0, 13, 12, 11, 0, 0, 0); |
| 306 | carry = bn_add_words(r_d, res, t_d, BN_NIST_224_TOP); | 487 | carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_224_TOP); |
| 307 | mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_224,BN_NIST_224_TOP); | ||
| 308 | mask = ~mask | (0-(size_t)carry); | ||
| 309 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 310 | |||
| 311 | nist_set_224(t_d, buf, 13, 12, 11, 10, 9, 8, 7); | 488 | nist_set_224(t_d, buf, 13, 12, 11, 10, 9, 8, 7); |
| 312 | #if BRANCH_FREE | 489 | carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_224_TOP); |
| 313 | carry = bn_sub_words(r_d, res, t_d, BN_NIST_224_TOP); | ||
| 314 | bn_add_words(c_d,r_d,_nist_p_224,BN_NIST_224_TOP); | ||
| 315 | mask = 0-(size_t)carry; | ||
| 316 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 317 | #else | ||
| 318 | if (bn_sub_words(r_d, res, t_d, BN_NIST_224_TOP)) | ||
| 319 | bn_add_words(r_d,r_d,_nist_p_224,BN_NIST_224_TOP); | ||
| 320 | #endif | ||
| 321 | nist_set_224(t_d, buf, 0, 0, 0, 0, 13, 12, 11); | 490 | nist_set_224(t_d, buf, 0, 0, 0, 0, 13, 12, 11); |
| 322 | #if BRANCH_FREE | 491 | carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_224_TOP); |
| 323 | carry = bn_sub_words(r_d, res, t_d, BN_NIST_224_TOP); | ||
| 324 | bn_add_words(c_d,r_d,_nist_p_224,BN_NIST_224_TOP); | ||
| 325 | mask = 0-(size_t)carry; | ||
| 326 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 327 | 492 | ||
| 328 | nist_cp_bn(r_d, res, BN_NIST_224_TOP); | 493 | #if BN_BITS2==64 |
| 329 | #else | 494 | carry = (int)(r_d[BN_NIST_224_TOP-1]>>32); |
| 330 | if (bn_sub_words(r_d, r_d, t_d, BN_NIST_224_TOP)) | 495 | #endif |
| 331 | bn_add_words(r_d,r_d,_nist_p_224,BN_NIST_224_TOP); | 496 | u.f = bn_sub_words; |
| 497 | if (carry > 0) | ||
| 498 | { | ||
| 499 | carry = (int)bn_sub_words(r_d,r_d,_nist_p_224[carry-1],BN_NIST_224_TOP); | ||
| 500 | #if BN_BITS2==64 | ||
| 501 | carry=(int)(~(r_d[BN_NIST_224_TOP-1]>>32))&1; | ||
| 332 | #endif | 502 | #endif |
| 503 | } | ||
| 504 | else if (carry < 0) | ||
| 505 | { | ||
| 506 | /* it's a bit more comlicated logic in this case. | ||
| 507 | * if bn_add_words yields no carry, then result | ||
| 508 | * has to be adjusted by unconditionally *adding* | ||
| 509 | * the modulus. but if it does, then result has | ||
| 510 | * to be compared to the modulus and conditionally | ||
| 511 | * adjusted by *subtracting* the latter. */ | ||
| 512 | carry = (int)bn_add_words(r_d,r_d,_nist_p_224[-carry-1],BN_NIST_224_TOP); | ||
| 513 | mask = 0-(size_t)carry; | ||
| 514 | u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask); | ||
| 515 | } | ||
| 516 | else | ||
| 517 | carry = 1; | ||
| 518 | |||
| 519 | /* otherwise it's effectively same as in BN_nist_mod_192... */ | ||
| 520 | mask = 0-(size_t)(*u.f)(c_d,r_d,_nist_p_224[0],BN_NIST_224_TOP); | ||
| 521 | mask &= 0-(size_t)carry; | ||
| 522 | res = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask)); | ||
| 523 | nist_cp_bn(r_d, res, BN_NIST_224_TOP); | ||
| 333 | r->top = BN_NIST_224_TOP; | 524 | r->top = BN_NIST_224_TOP; |
| 334 | bn_correct_top(r); | 525 | bn_correct_top(r); |
| 335 | 526 | ||
| 336 | return 1; | 527 | return 1; |
| 337 | #else /* BN_BITS!=32 */ | ||
| 338 | return 0; | ||
| 339 | #endif | ||
| 340 | } | 528 | } |
| 341 | 529 | ||
| 342 | #define nist_set_256(to, from, a1, a2, a3, a4, a5, a6, a7, a8) \ | 530 | #define nist_set_256(to, from, a1, a2, a3, a4, a5, a6, a7, a8) \ |
| 343 | { \ | 531 | { \ |
| 344 | if (a8 != 0) bn_cp_32(to, 0, from, (a8) - 8) else bn_32_set_0(to, 0)\ | 532 | bn_cp_32(to, 0, from, (a8) - 8) \ |
| 345 | if (a7 != 0) bn_cp_32(to, 1, from, (a7) - 8) else bn_32_set_0(to, 1)\ | 533 | bn_cp_32(to, 1, from, (a7) - 8) \ |
| 346 | if (a6 != 0) bn_cp_32(to, 2, from, (a6) - 8) else bn_32_set_0(to, 2)\ | 534 | bn_cp_32(to, 2, from, (a6) - 8) \ |
| 347 | if (a5 != 0) bn_cp_32(to, 3, from, (a5) - 8) else bn_32_set_0(to, 3)\ | 535 | bn_cp_32(to, 3, from, (a5) - 8) \ |
| 348 | if (a4 != 0) bn_cp_32(to, 4, from, (a4) - 8) else bn_32_set_0(to, 4)\ | 536 | bn_cp_32(to, 4, from, (a4) - 8) \ |
| 349 | if (a3 != 0) bn_cp_32(to, 5, from, (a3) - 8) else bn_32_set_0(to, 5)\ | 537 | bn_cp_32(to, 5, from, (a3) - 8) \ |
| 350 | if (a2 != 0) bn_cp_32(to, 6, from, (a2) - 8) else bn_32_set_0(to, 6)\ | 538 | bn_cp_32(to, 6, from, (a2) - 8) \ |
| 351 | if (a1 != 0) bn_cp_32(to, 7, from, (a1) - 8) else bn_32_set_0(to, 7)\ | 539 | bn_cp_32(to, 7, from, (a1) - 8) \ |
| 352 | } | 540 | } |
| 353 | 541 | ||
| 354 | int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | 542 | int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, |
| 355 | BN_CTX *ctx) | 543 | BN_CTX *ctx) |
| 356 | { | 544 | { |
| 357 | #if BN_BITS2 == 32 | ||
| 358 | int i, top = a->top; | 545 | int i, top = a->top; |
| 359 | int carry = 0; | 546 | int carry = 0; |
| 360 | register BN_ULONG *a_d = a->d, *r_d; | 547 | register BN_ULONG *a_d = a->d, *r_d; |
| @@ -363,6 +550,17 @@ int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
| 363 | c_d[BN_NIST_256_TOP], | 550 | c_d[BN_NIST_256_TOP], |
| 364 | *res; | 551 | *res; |
| 365 | size_t mask; | 552 | size_t mask; |
| 553 | union { bn_addsub_f f; size_t p; } u; | ||
| 554 | static const BIGNUM _bignum_nist_p_256_sqr = { | ||
| 555 | (BN_ULONG *)_nist_p_256_sqr, | ||
| 556 | sizeof(_nist_p_256_sqr)/sizeof(_nist_p_256_sqr[0]), | ||
| 557 | sizeof(_nist_p_256_sqr)/sizeof(_nist_p_256_sqr[0]), | ||
| 558 | 0,BN_FLG_STATIC_DATA }; | ||
| 559 | |||
| 560 | field = &_bignum_nist_p_256; /* just to make sure */ | ||
| 561 | |||
| 562 | if (BN_is_negative(a) || BN_ucmp(a,&_bignum_nist_p_256_sqr)>=0) | ||
| 563 | return BN_nnmod(r, a, field, ctx); | ||
| 366 | 564 | ||
| 367 | i = BN_ucmp(field, a); | 565 | i = BN_ucmp(field, a); |
| 368 | if (i == 0) | 566 | if (i == 0) |
| @@ -373,9 +571,6 @@ int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
| 373 | else if (i > 0) | 571 | else if (i > 0) |
| 374 | return (r == a)? 1 : (BN_copy(r ,a) != NULL); | 572 | return (r == a)? 1 : (BN_copy(r ,a) != NULL); |
| 375 | 573 | ||
| 376 | if (top == BN_NIST_256_TOP) | ||
| 377 | return BN_usub(r, a, field); | ||
| 378 | |||
| 379 | if (r != a) | 574 | if (r != a) |
| 380 | { | 575 | { |
| 381 | if (!bn_wexpand(r, BN_NIST_256_TOP)) | 576 | if (!bn_wexpand(r, BN_NIST_256_TOP)) |
| @@ -391,111 +586,84 @@ int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
| 391 | /*S1*/ | 586 | /*S1*/ |
| 392 | nist_set_256(t_d, buf, 15, 14, 13, 12, 11, 0, 0, 0); | 587 | nist_set_256(t_d, buf, 15, 14, 13, 12, 11, 0, 0, 0); |
| 393 | /*S2*/ | 588 | /*S2*/ |
| 394 | nist_set_256(c_d,buf, 0, 15, 14, 13, 12, 0, 0, 0); | 589 | nist_set_256(c_d, buf, 0, 15, 14, 13, 12, 0, 0, 0); |
| 395 | carry = bn_add_words(t_d, t_d, c_d, BN_NIST_256_TOP); | 590 | carry = (int)bn_add_words(t_d, t_d, c_d, BN_NIST_256_TOP); |
| 396 | mask = 0-(size_t)bn_sub_words(c_d,t_d,_nist_p_256,BN_NIST_256_TOP); | 591 | /* left shift */ |
| 397 | mask = ~mask | (0-(size_t)carry); | 592 | { |
| 398 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)t_d&~mask)); | 593 | register BN_ULONG *ap,t,c; |
| 399 | 594 | ap = t_d; | |
| 400 | carry = bn_add_words(t_d, res, res, BN_NIST_256_TOP); | 595 | c=0; |
| 401 | mask = 0-(size_t)bn_sub_words(c_d,t_d,_nist_p_256,BN_NIST_256_TOP); | 596 | for (i = BN_NIST_256_TOP; i != 0; --i) |
| 402 | mask = ~mask | (0-(size_t)carry); | 597 | { |
| 403 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)t_d&~mask)); | 598 | t= *ap; |
| 404 | 599 | *(ap++)=((t<<1)|c)&BN_MASK2; | |
| 405 | carry = bn_add_words(r_d, r_d, res, BN_NIST_256_TOP); | 600 | c=(t & BN_TBIT)?1:0; |
| 406 | mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_256,BN_NIST_256_TOP); | 601 | } |
| 407 | mask = ~mask | (0-(size_t)carry); | 602 | carry <<= 1; |
| 408 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | 603 | carry |= c; |
| 409 | 604 | } | |
| 605 | carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP); | ||
| 410 | /*S3*/ | 606 | /*S3*/ |
| 411 | nist_set_256(t_d, buf, 15, 14, 0, 0, 0, 10, 9, 8); | 607 | nist_set_256(t_d, buf, 15, 14, 0, 0, 0, 10, 9, 8); |
| 412 | carry = bn_add_words(r_d, res, t_d, BN_NIST_256_TOP); | 608 | carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP); |
| 413 | mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_256,BN_NIST_256_TOP); | ||
| 414 | mask = ~mask | (0-(size_t)carry); | ||
| 415 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 416 | |||
| 417 | /*S4*/ | 609 | /*S4*/ |
| 418 | nist_set_256(t_d, buf, 8, 13, 15, 14, 13, 11, 10, 9); | 610 | nist_set_256(t_d, buf, 8, 13, 15, 14, 13, 11, 10, 9); |
| 419 | carry = bn_add_words(r_d, res, t_d, BN_NIST_256_TOP); | 611 | carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP); |
| 420 | mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_256,BN_NIST_256_TOP); | ||
| 421 | mask = ~mask | (0-(size_t)carry); | ||
| 422 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 423 | |||
| 424 | /*D1*/ | 612 | /*D1*/ |
| 425 | nist_set_256(t_d, buf, 10, 8, 0, 0, 0, 13, 12, 11); | 613 | nist_set_256(t_d, buf, 10, 8, 0, 0, 0, 13, 12, 11); |
| 426 | #if BRANCH_FREE | 614 | carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP); |
| 427 | carry = bn_sub_words(r_d, res, t_d, BN_NIST_256_TOP); | ||
| 428 | bn_add_words(c_d,r_d,_nist_p_256,BN_NIST_256_TOP); | ||
| 429 | mask = 0-(size_t)carry; | ||
| 430 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 431 | #else | ||
| 432 | if (bn_sub_words(r_d, res, t_d, BN_NIST_256_TOP)) | ||
| 433 | bn_add_words(r_d,r_d,_nist_p_256,BN_NIST_256_TOP); | ||
| 434 | #endif | ||
| 435 | /*D2*/ | 615 | /*D2*/ |
| 436 | nist_set_256(t_d, buf, 11, 9, 0, 0, 15, 14, 13, 12); | 616 | nist_set_256(t_d, buf, 11, 9, 0, 0, 15, 14, 13, 12); |
| 437 | #if BRANCH_FREE | 617 | carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP); |
| 438 | carry = bn_sub_words(r_d, res, t_d, BN_NIST_256_TOP); | ||
| 439 | bn_add_words(c_d,r_d,_nist_p_256,BN_NIST_256_TOP); | ||
| 440 | mask = 0-(size_t)carry; | ||
| 441 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 442 | #else | ||
| 443 | if (bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP)) | ||
| 444 | bn_add_words(r_d,r_d,_nist_p_256,BN_NIST_256_TOP); | ||
| 445 | #endif | ||
| 446 | /*D3*/ | 618 | /*D3*/ |
| 447 | nist_set_256(t_d, buf, 12, 0, 10, 9, 8, 15, 14, 13); | 619 | nist_set_256(t_d, buf, 12, 0, 10, 9, 8, 15, 14, 13); |
| 448 | #if BRANCH_FREE | 620 | carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP); |
| 449 | carry = bn_sub_words(r_d, res, t_d, BN_NIST_256_TOP); | ||
| 450 | bn_add_words(c_d,r_d,_nist_p_256,BN_NIST_256_TOP); | ||
| 451 | mask = 0-(size_t)carry; | ||
| 452 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 453 | #else | ||
| 454 | if (bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP)) | ||
| 455 | bn_add_words(r_d,r_d,_nist_p_256,BN_NIST_256_TOP); | ||
| 456 | #endif | ||
| 457 | /*D4*/ | 621 | /*D4*/ |
| 458 | nist_set_256(t_d, buf, 13, 0, 11, 10, 9, 0, 15, 14); | 622 | nist_set_256(t_d, buf, 13, 0, 11, 10, 9, 0, 15, 14); |
| 459 | #if BRANCH_FREE | 623 | carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP); |
| 460 | carry = bn_sub_words(r_d, res, t_d, BN_NIST_256_TOP); | ||
| 461 | bn_add_words(c_d,r_d,_nist_p_256,BN_NIST_256_TOP); | ||
| 462 | mask = 0-(size_t)carry; | ||
| 463 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 464 | 624 | ||
| 465 | nist_cp_bn(r_d, res, BN_NIST_384_TOP); | 625 | /* see BN_nist_mod_224 for explanation */ |
| 466 | #else | 626 | u.f = bn_sub_words; |
| 467 | if (bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP)) | 627 | if (carry > 0) |
| 468 | bn_add_words(r_d,r_d,_nist_p_256,BN_NIST_256_TOP); | 628 | carry = (int)bn_sub_words(r_d,r_d,_nist_p_256[carry-1],BN_NIST_256_TOP); |
| 469 | #endif | 629 | else if (carry < 0) |
| 630 | { | ||
| 631 | carry = (int)bn_add_words(r_d,r_d,_nist_p_256[-carry-1],BN_NIST_256_TOP); | ||
| 632 | mask = 0-(size_t)carry; | ||
| 633 | u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask); | ||
| 634 | } | ||
| 635 | else | ||
| 636 | carry = 1; | ||
| 637 | |||
| 638 | mask = 0-(size_t)(*u.f)(c_d,r_d,_nist_p_256[0],BN_NIST_256_TOP); | ||
| 639 | mask &= 0-(size_t)carry; | ||
| 640 | res = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask)); | ||
| 641 | nist_cp_bn(r_d, res, BN_NIST_256_TOP); | ||
| 470 | r->top = BN_NIST_256_TOP; | 642 | r->top = BN_NIST_256_TOP; |
| 471 | bn_correct_top(r); | 643 | bn_correct_top(r); |
| 472 | 644 | ||
| 473 | return 1; | 645 | return 1; |
| 474 | #else /* BN_BITS!=32 */ | ||
| 475 | return 0; | ||
| 476 | #endif | ||
| 477 | } | 646 | } |
| 478 | 647 | ||
| 479 | #define nist_set_384(to,from,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \ | 648 | #define nist_set_384(to,from,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \ |
| 480 | { \ | 649 | { \ |
| 481 | if (a12 != 0) bn_cp_32(to, 0, from, (a12) - 12) else bn_32_set_0(to, 0)\ | 650 | bn_cp_32(to, 0, from, (a12) - 12) \ |
| 482 | if (a11 != 0) bn_cp_32(to, 1, from, (a11) - 12) else bn_32_set_0(to, 1)\ | 651 | bn_cp_32(to, 1, from, (a11) - 12) \ |
| 483 | if (a10 != 0) bn_cp_32(to, 2, from, (a10) - 12) else bn_32_set_0(to, 2)\ | 652 | bn_cp_32(to, 2, from, (a10) - 12) \ |
| 484 | if (a9 != 0) bn_cp_32(to, 3, from, (a9) - 12) else bn_32_set_0(to, 3)\ | 653 | bn_cp_32(to, 3, from, (a9) - 12) \ |
| 485 | if (a8 != 0) bn_cp_32(to, 4, from, (a8) - 12) else bn_32_set_0(to, 4)\ | 654 | bn_cp_32(to, 4, from, (a8) - 12) \ |
| 486 | if (a7 != 0) bn_cp_32(to, 5, from, (a7) - 12) else bn_32_set_0(to, 5)\ | 655 | bn_cp_32(to, 5, from, (a7) - 12) \ |
| 487 | if (a6 != 0) bn_cp_32(to, 6, from, (a6) - 12) else bn_32_set_0(to, 6)\ | 656 | bn_cp_32(to, 6, from, (a6) - 12) \ |
| 488 | if (a5 != 0) bn_cp_32(to, 7, from, (a5) - 12) else bn_32_set_0(to, 7)\ | 657 | bn_cp_32(to, 7, from, (a5) - 12) \ |
| 489 | if (a4 != 0) bn_cp_32(to, 8, from, (a4) - 12) else bn_32_set_0(to, 8)\ | 658 | bn_cp_32(to, 8, from, (a4) - 12) \ |
| 490 | if (a3 != 0) bn_cp_32(to, 9, from, (a3) - 12) else bn_32_set_0(to, 9)\ | 659 | bn_cp_32(to, 9, from, (a3) - 12) \ |
| 491 | if (a2 != 0) bn_cp_32(to, 10, from, (a2) - 12) else bn_32_set_0(to, 10)\ | 660 | bn_cp_32(to, 10, from, (a2) - 12) \ |
| 492 | if (a1 != 0) bn_cp_32(to, 11, from, (a1) - 12) else bn_32_set_0(to, 11)\ | 661 | bn_cp_32(to, 11, from, (a1) - 12) \ |
| 493 | } | 662 | } |
| 494 | 663 | ||
| 495 | int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | 664 | int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, |
| 496 | BN_CTX *ctx) | 665 | BN_CTX *ctx) |
| 497 | { | 666 | { |
| 498 | #if BN_BITS2 == 32 | ||
| 499 | int i, top = a->top; | 667 | int i, top = a->top; |
| 500 | int carry = 0; | 668 | int carry = 0; |
| 501 | register BN_ULONG *r_d, *a_d = a->d; | 669 | register BN_ULONG *r_d, *a_d = a->d; |
| @@ -504,6 +672,18 @@ int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
| 504 | c_d[BN_NIST_384_TOP], | 672 | c_d[BN_NIST_384_TOP], |
| 505 | *res; | 673 | *res; |
| 506 | size_t mask; | 674 | size_t mask; |
| 675 | union { bn_addsub_f f; size_t p; } u; | ||
| 676 | static const BIGNUM _bignum_nist_p_384_sqr = { | ||
| 677 | (BN_ULONG *)_nist_p_384_sqr, | ||
| 678 | sizeof(_nist_p_384_sqr)/sizeof(_nist_p_384_sqr[0]), | ||
| 679 | sizeof(_nist_p_384_sqr)/sizeof(_nist_p_384_sqr[0]), | ||
| 680 | 0,BN_FLG_STATIC_DATA }; | ||
| 681 | |||
| 682 | |||
| 683 | field = &_bignum_nist_p_384; /* just to make sure */ | ||
| 684 | |||
| 685 | if (BN_is_negative(a) || BN_ucmp(a,&_bignum_nist_p_384_sqr)>=0) | ||
| 686 | return BN_nnmod(r, a, field, ctx); | ||
| 507 | 687 | ||
| 508 | i = BN_ucmp(field, a); | 688 | i = BN_ucmp(field, a); |
| 509 | if (i == 0) | 689 | if (i == 0) |
| @@ -514,9 +694,6 @@ int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
| 514 | else if (i > 0) | 694 | else if (i > 0) |
| 515 | return (r == a)? 1 : (BN_copy(r ,a) != NULL); | 695 | return (r == a)? 1 : (BN_copy(r ,a) != NULL); |
| 516 | 696 | ||
| 517 | if (top == BN_NIST_384_TOP) | ||
| 518 | return BN_usub(r, a, field); | ||
| 519 | |||
| 520 | if (r != a) | 697 | if (r != a) |
| 521 | { | 698 | { |
| 522 | if (!bn_wexpand(r, BN_NIST_384_TOP)) | 699 | if (!bn_wexpand(r, BN_NIST_384_TOP)) |
| @@ -544,149 +721,116 @@ int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
| 544 | } | 721 | } |
| 545 | *ap=c; | 722 | *ap=c; |
| 546 | } | 723 | } |
| 547 | carry = bn_add_words(r_d+(128/BN_BITS2), r_d+(128/BN_BITS2), | 724 | carry = (int)bn_add_words(r_d+(128/BN_BITS2), r_d+(128/BN_BITS2), |
| 548 | t_d, BN_NIST_256_TOP); | 725 | t_d, BN_NIST_256_TOP); |
| 549 | /* | ||
| 550 | * we need if (result>=modulus) subtract(result,modulus); | ||
| 551 | * in n-bit space this can be expressed as | ||
| 552 | * if (carry || result>=modulus) subtract(result,modulus); | ||
| 553 | * the catch is that comparison implies subtraction and | ||
| 554 | * therefore one can write tmp=subtract(result,modulus); | ||
| 555 | * and then if(carry || !borrow) result=tmp; this's what | ||
| 556 | * happens below, but without explicit if:-) a. | ||
| 557 | */ | ||
| 558 | mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_384,BN_NIST_384_TOP); | ||
| 559 | mask = ~mask | (0-(size_t)carry); | ||
| 560 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 561 | |||
| 562 | /*S2 */ | 726 | /*S2 */ |
| 563 | carry = bn_add_words(r_d, res, buf, BN_NIST_384_TOP); | 727 | carry += (int)bn_add_words(r_d, r_d, buf, BN_NIST_384_TOP); |
| 564 | mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_384,BN_NIST_384_TOP); | ||
| 565 | mask = ~mask | (0-(size_t)carry); | ||
| 566 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 567 | |||
| 568 | /*S3*/ | 728 | /*S3*/ |
| 569 | nist_set_384(t_d,buf,20,19,18,17,16,15,14,13,12,23,22,21); | 729 | nist_set_384(t_d,buf,20,19,18,17,16,15,14,13,12,23,22,21); |
| 570 | carry = bn_add_words(r_d, res, t_d, BN_NIST_384_TOP); | 730 | carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP); |
| 571 | mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_384,BN_NIST_384_TOP); | ||
| 572 | mask = ~mask | (0-(size_t)carry); | ||
| 573 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 574 | |||
| 575 | /*S4*/ | 731 | /*S4*/ |
| 576 | nist_set_384(t_d,buf,19,18,17,16,15,14,13,12,20,0,23,0); | 732 | nist_set_384(t_d,buf,19,18,17,16,15,14,13,12,20,0,23,0); |
| 577 | carry = bn_add_words(r_d, res, t_d, BN_NIST_384_TOP); | 733 | carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP); |
| 578 | mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_384,BN_NIST_384_TOP); | ||
| 579 | mask = ~mask | (0-(size_t)carry); | ||
| 580 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 581 | |||
| 582 | /*S5*/ | 734 | /*S5*/ |
| 583 | nist_set_384(t_d, buf,0,0,0,0,23,22,21,20,0,0,0,0); | 735 | nist_set_384(t_d, buf,0,0,0,0,23,22,21,20,0,0,0,0); |
| 584 | carry = bn_add_words(r_d, res, t_d, BN_NIST_384_TOP); | 736 | carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP); |
| 585 | mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_384,BN_NIST_384_TOP); | ||
| 586 | mask = ~mask | (0-(size_t)carry); | ||
| 587 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 588 | |||
| 589 | /*S6*/ | 737 | /*S6*/ |
| 590 | nist_set_384(t_d,buf,0,0,0,0,0,0,23,22,21,0,0,20); | 738 | nist_set_384(t_d,buf,0,0,0,0,0,0,23,22,21,0,0,20); |
| 591 | carry = bn_add_words(r_d, res, t_d, BN_NIST_384_TOP); | 739 | carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP); |
| 592 | mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_384,BN_NIST_384_TOP); | ||
| 593 | mask = ~mask | (0-(size_t)carry); | ||
| 594 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 595 | |||
| 596 | /*D1*/ | 740 | /*D1*/ |
| 597 | nist_set_384(t_d,buf,22,21,20,19,18,17,16,15,14,13,12,23); | 741 | nist_set_384(t_d,buf,22,21,20,19,18,17,16,15,14,13,12,23); |
| 598 | #if BRANCH_FREE | 742 | carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP); |
| 599 | carry = bn_sub_words(r_d, res, t_d, BN_NIST_384_TOP); | ||
| 600 | bn_add_words(c_d,r_d,_nist_p_384,BN_NIST_384_TOP); | ||
| 601 | mask = 0-(size_t)carry; | ||
| 602 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 603 | #else | ||
| 604 | if (bn_sub_words(r_d, res, t_d, BN_NIST_384_TOP)) | ||
| 605 | bn_add_words(r_d,r_d,_nist_p_384,BN_NIST_384_TOP); | ||
| 606 | #endif | ||
| 607 | /*D2*/ | 743 | /*D2*/ |
| 608 | nist_set_384(t_d,buf,0,0,0,0,0,0,0,23,22,21,20,0); | 744 | nist_set_384(t_d,buf,0,0,0,0,0,0,0,23,22,21,20,0); |
| 609 | #if BRANCH_FREE | 745 | carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP); |
| 610 | carry = bn_sub_words(r_d, res, t_d, BN_NIST_384_TOP); | ||
| 611 | bn_add_words(c_d,r_d,_nist_p_384,BN_NIST_384_TOP); | ||
| 612 | mask = 0-(size_t)carry; | ||
| 613 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | ||
| 614 | #else | ||
| 615 | if (bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP)) | ||
| 616 | bn_add_words(r_d,r_d,_nist_p_384,BN_NIST_384_TOP); | ||
| 617 | #endif | ||
| 618 | /*D3*/ | 746 | /*D3*/ |
| 619 | nist_set_384(t_d,buf,0,0,0,0,0,0,0,23,23,0,0,0); | 747 | nist_set_384(t_d,buf,0,0,0,0,0,0,0,23,23,0,0,0); |
| 620 | #if BRANCH_FREE | 748 | carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP); |
| 621 | carry = bn_sub_words(r_d, res, t_d, BN_NIST_384_TOP); | 749 | |
| 622 | bn_add_words(c_d,r_d,_nist_p_384,BN_NIST_384_TOP); | 750 | /* see BN_nist_mod_224 for explanation */ |
| 623 | mask = 0-(size_t)carry; | 751 | u.f = bn_sub_words; |
| 624 | res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); | 752 | if (carry > 0) |
| 753 | carry = (int)bn_sub_words(r_d,r_d,_nist_p_384[carry-1],BN_NIST_384_TOP); | ||
| 754 | else if (carry < 0) | ||
| 755 | { | ||
| 756 | carry = (int)bn_add_words(r_d,r_d,_nist_p_384[-carry-1],BN_NIST_384_TOP); | ||
| 757 | mask = 0-(size_t)carry; | ||
| 758 | u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask); | ||
| 759 | } | ||
| 760 | else | ||
| 761 | carry = 1; | ||
| 625 | 762 | ||
| 763 | mask = 0-(size_t)(*u.f)(c_d,r_d,_nist_p_384[0],BN_NIST_384_TOP); | ||
| 764 | mask &= 0-(size_t)carry; | ||
| 765 | res = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask)); | ||
| 626 | nist_cp_bn(r_d, res, BN_NIST_384_TOP); | 766 | nist_cp_bn(r_d, res, BN_NIST_384_TOP); |
| 627 | #else | ||
| 628 | if (bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP)) | ||
| 629 | bn_add_words(r_d,r_d,_nist_p_384,BN_NIST_384_TOP); | ||
| 630 | #endif | ||
| 631 | r->top = BN_NIST_384_TOP; | 767 | r->top = BN_NIST_384_TOP; |
| 632 | bn_correct_top(r); | 768 | bn_correct_top(r); |
| 633 | 769 | ||
| 634 | return 1; | 770 | return 1; |
| 635 | #else /* BN_BITS!=32 */ | ||
| 636 | return 0; | ||
| 637 | #endif | ||
| 638 | } | 771 | } |
| 639 | 772 | ||
| 773 | #define BN_NIST_521_RSHIFT (521%BN_BITS2) | ||
| 774 | #define BN_NIST_521_LSHIFT (BN_BITS2-BN_NIST_521_RSHIFT) | ||
| 775 | #define BN_NIST_521_TOP_MASK ((BN_ULONG)BN_MASK2>>BN_NIST_521_LSHIFT) | ||
| 776 | |||
| 640 | int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | 777 | int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, |
| 641 | BN_CTX *ctx) | 778 | BN_CTX *ctx) |
| 642 | { | 779 | { |
| 643 | #if BN_BITS2 == 64 | 780 | int top = a->top, i; |
| 644 | #define BN_NIST_521_TOP_MASK (BN_ULONG)0x1FF | 781 | BN_ULONG *r_d, *a_d = a->d, |
| 645 | #elif BN_BITS2 == 32 | 782 | t_d[BN_NIST_521_TOP], |
| 646 | #define BN_NIST_521_TOP_MASK (BN_ULONG)0x1FF | 783 | val,tmp,*res; |
| 647 | #endif | 784 | size_t mask; |
| 648 | int top, ret = 0; | 785 | static const BIGNUM _bignum_nist_p_521_sqr = { |
| 649 | BN_ULONG *r_d; | 786 | (BN_ULONG *)_nist_p_521_sqr, |
| 650 | BIGNUM *tmp; | 787 | sizeof(_nist_p_521_sqr)/sizeof(_nist_p_521_sqr[0]), |
| 651 | 788 | sizeof(_nist_p_521_sqr)/sizeof(_nist_p_521_sqr[0]), | |
| 652 | /* check whether a reduction is necessary */ | 789 | 0,BN_FLG_STATIC_DATA }; |
| 653 | top = a->top; | ||
| 654 | if (top < BN_NIST_521_TOP || ( top == BN_NIST_521_TOP && | ||
| 655 | (!(a->d[BN_NIST_521_TOP-1] & ~(BN_NIST_521_TOP_MASK))))) | ||
| 656 | return (r == a)? 1 : (BN_copy(r ,a) != NULL); | ||
| 657 | 790 | ||
| 658 | BN_CTX_start(ctx); | 791 | field = &_bignum_nist_p_521; /* just to make sure */ |
| 659 | tmp = BN_CTX_get(ctx); | ||
| 660 | if (!tmp) | ||
| 661 | goto err; | ||
| 662 | 792 | ||
| 663 | if (!bn_wexpand(tmp, BN_NIST_521_TOP)) | 793 | if (BN_is_negative(a) || BN_ucmp(a,&_bignum_nist_p_521_sqr)>=0) |
| 664 | goto err; | 794 | return BN_nnmod(r, a, field, ctx); |
| 665 | nist_cp_bn(tmp->d, a->d, BN_NIST_521_TOP); | ||
| 666 | 795 | ||
| 667 | tmp->top = BN_NIST_521_TOP; | 796 | i = BN_ucmp(field, a); |
| 668 | tmp->d[BN_NIST_521_TOP-1] &= BN_NIST_521_TOP_MASK; | 797 | if (i == 0) |
| 669 | bn_correct_top(tmp); | 798 | { |
| 799 | BN_zero(r); | ||
| 800 | return 1; | ||
| 801 | } | ||
| 802 | else if (i > 0) | ||
| 803 | return (r == a)? 1 : (BN_copy(r ,a) != NULL); | ||
| 670 | 804 | ||
| 671 | if (!BN_rshift(r, a, 521)) | 805 | if (r != a) |
| 672 | goto err; | 806 | { |
| 807 | if (!bn_wexpand(r,BN_NIST_521_TOP)) | ||
| 808 | return 0; | ||
| 809 | r_d = r->d; | ||
| 810 | nist_cp_bn(r_d,a_d, BN_NIST_521_TOP); | ||
| 811 | } | ||
| 812 | else | ||
| 813 | r_d = a_d; | ||
| 673 | 814 | ||
| 674 | if (!BN_uadd(r, tmp, r)) | 815 | /* upper 521 bits, copy ... */ |
| 675 | goto err; | 816 | nist_cp_bn_0(t_d,a_d + (BN_NIST_521_TOP-1), top - (BN_NIST_521_TOP-1),BN_NIST_521_TOP); |
| 676 | top = r->top; | 817 | /* ... and right shift */ |
| 677 | r_d = r->d; | 818 | for (val=t_d[0],i=0; i<BN_NIST_521_TOP-1; i++) |
| 678 | if (top == BN_NIST_521_TOP && | ||
| 679 | (r_d[BN_NIST_521_TOP-1] & ~(BN_NIST_521_TOP_MASK))) | ||
| 680 | { | 819 | { |
| 681 | BN_NIST_ADD_ONE(r_d) | 820 | tmp = val>>BN_NIST_521_RSHIFT; |
| 682 | r->d[BN_NIST_521_TOP-1] &= BN_NIST_521_TOP_MASK; | 821 | val = t_d[i+1]; |
| 822 | t_d[i] = (tmp | val<<BN_NIST_521_LSHIFT) & BN_MASK2; | ||
| 683 | } | 823 | } |
| 824 | t_d[i] = val>>BN_NIST_521_RSHIFT; | ||
| 825 | /* lower 521 bits */ | ||
| 826 | r_d[i] &= BN_NIST_521_TOP_MASK; | ||
| 827 | |||
| 828 | bn_add_words(r_d,r_d,t_d,BN_NIST_521_TOP); | ||
| 829 | mask = 0-(size_t)bn_sub_words(t_d,r_d,_nist_p_521,BN_NIST_521_TOP); | ||
| 830 | res = (BN_ULONG *)(((size_t)t_d&~mask) | ((size_t)r_d&mask)); | ||
| 831 | nist_cp_bn(r_d,res,BN_NIST_521_TOP); | ||
| 832 | r->top = BN_NIST_521_TOP; | ||
| 684 | bn_correct_top(r); | 833 | bn_correct_top(r); |
| 685 | 834 | ||
| 686 | ret = 1; | 835 | return 1; |
| 687 | err: | ||
| 688 | BN_CTX_end(ctx); | ||
| 689 | |||
| 690 | bn_check_top(r); | ||
| 691 | return ret; | ||
| 692 | } | 836 | } |
diff --git a/src/lib/libssl/src/crypto/bn/bn_x931p.c b/src/lib/libssl/src/crypto/bn/bn_x931p.c index c64410dd3a..04c5c874ec 100644 --- a/src/lib/libssl/src/crypto/bn/bn_x931p.c +++ b/src/lib/libssl/src/crypto/bn/bn_x931p.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* bn_x931p.c */ | 1 | /* bn_x931p.c */ |
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2005. | 3 | * project 2005. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
| @@ -59,18 +59,15 @@ | |||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <openssl/bn.h> | 60 | #include <openssl/bn.h> |
| 61 | 61 | ||
| 62 | #ifdef OPENSSL_FIPS | ||
| 63 | |||
| 64 | /* X9.31 routines for prime derivation */ | 62 | /* X9.31 routines for prime derivation */ |
| 65 | 63 | ||
| 66 | |||
| 67 | /* X9.31 prime derivation. This is used to generate the primes pi | 64 | /* X9.31 prime derivation. This is used to generate the primes pi |
| 68 | * (p1, p2, q1, q2) from a parameter Xpi by checking successive odd | 65 | * (p1, p2, q1, q2) from a parameter Xpi by checking successive odd |
| 69 | * integers. | 66 | * integers. |
| 70 | */ | 67 | */ |
| 71 | 68 | ||
| 72 | static int bn_x931_derive_pi(BIGNUM *pi, const BIGNUM *Xpi, BN_CTX *ctx, | 69 | static int bn_x931_derive_pi(BIGNUM *pi, const BIGNUM *Xpi, BN_CTX *ctx, |
| 73 | void (*cb)(int, int, void *), void *cb_arg) | 70 | BN_GENCB *cb) |
| 74 | { | 71 | { |
| 75 | int i = 0; | 72 | int i = 0; |
| 76 | if (!BN_copy(pi, Xpi)) | 73 | if (!BN_copy(pi, Xpi)) |
| @@ -80,16 +77,14 @@ static int bn_x931_derive_pi(BIGNUM *pi, const BIGNUM *Xpi, BN_CTX *ctx, | |||
| 80 | for(;;) | 77 | for(;;) |
| 81 | { | 78 | { |
| 82 | i++; | 79 | i++; |
| 83 | if (cb) | 80 | BN_GENCB_call(cb, 0, i); |
| 84 | cb(0, i, cb_arg); | ||
| 85 | /* NB 27 MR is specificed in X9.31 */ | 81 | /* NB 27 MR is specificed in X9.31 */ |
| 86 | if (BN_is_prime_fasttest(pi, 27, cb, ctx, cb_arg, 1)) | 82 | if (BN_is_prime_fasttest_ex(pi, 27, ctx, 1, cb)) |
| 87 | break; | 83 | break; |
| 88 | if (!BN_add_word(pi, 2)) | 84 | if (!BN_add_word(pi, 2)) |
| 89 | return 0; | 85 | return 0; |
| 90 | } | 86 | } |
| 91 | if (cb) | 87 | BN_GENCB_call(cb, 2, i); |
| 92 | cb(2, i, cb_arg); | ||
| 93 | return 1; | 88 | return 1; |
| 94 | } | 89 | } |
| 95 | 90 | ||
| @@ -98,10 +93,9 @@ static int bn_x931_derive_pi(BIGNUM *pi, const BIGNUM *Xpi, BN_CTX *ctx, | |||
| 98 | * not NULL they will be returned too: this is needed for testing. | 93 | * not NULL they will be returned too: this is needed for testing. |
| 99 | */ | 94 | */ |
| 100 | 95 | ||
| 101 | int BN_X931_derive_prime(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, | 96 | int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, |
| 102 | void (*cb)(int, int, void *), void *cb_arg, | ||
| 103 | const BIGNUM *Xp, const BIGNUM *Xp1, const BIGNUM *Xp2, | 97 | const BIGNUM *Xp, const BIGNUM *Xp1, const BIGNUM *Xp2, |
| 104 | const BIGNUM *e, BN_CTX *ctx) | 98 | const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb) |
| 105 | { | 99 | { |
| 106 | int ret = 0; | 100 | int ret = 0; |
| 107 | 101 | ||
| @@ -124,10 +118,10 @@ int BN_X931_derive_prime(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, | |||
| 124 | 118 | ||
| 125 | pm1 = BN_CTX_get(ctx); | 119 | pm1 = BN_CTX_get(ctx); |
| 126 | 120 | ||
| 127 | if (!bn_x931_derive_pi(p1, Xp1, ctx, cb, cb_arg)) | 121 | if (!bn_x931_derive_pi(p1, Xp1, ctx, cb)) |
| 128 | goto err; | 122 | goto err; |
| 129 | 123 | ||
| 130 | if (!bn_x931_derive_pi(p2, Xp2, ctx, cb, cb_arg)) | 124 | if (!bn_x931_derive_pi(p2, Xp2, ctx, cb)) |
| 131 | goto err; | 125 | goto err; |
| 132 | 126 | ||
| 133 | if (!BN_mul(p1p2, p1, p2, ctx)) | 127 | if (!BN_mul(p1p2, p1, p2, ctx)) |
| @@ -166,8 +160,7 @@ int BN_X931_derive_prime(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, | |||
| 166 | for (;;) | 160 | for (;;) |
| 167 | { | 161 | { |
| 168 | int i = 1; | 162 | int i = 1; |
| 169 | if (cb) | 163 | BN_GENCB_call(cb, 0, i++); |
| 170 | cb(0, i++, cb_arg); | ||
| 171 | if (!BN_copy(pm1, p)) | 164 | if (!BN_copy(pm1, p)) |
| 172 | goto err; | 165 | goto err; |
| 173 | if (!BN_sub_word(pm1, 1)) | 166 | if (!BN_sub_word(pm1, 1)) |
| @@ -179,14 +172,13 @@ int BN_X931_derive_prime(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, | |||
| 179 | * offering similar or better guarantees 50 MR is considerably | 172 | * offering similar or better guarantees 50 MR is considerably |
| 180 | * better. | 173 | * better. |
| 181 | */ | 174 | */ |
| 182 | && BN_is_prime_fasttest(p, 50, cb, ctx, cb_arg, 1)) | 175 | && BN_is_prime_fasttest_ex(p, 50, ctx, 1, cb)) |
| 183 | break; | 176 | break; |
| 184 | if (!BN_add(p, p, p1p2)) | 177 | if (!BN_add(p, p, p1p2)) |
| 185 | goto err; | 178 | goto err; |
| 186 | } | 179 | } |
| 187 | 180 | ||
| 188 | if (cb) | 181 | BN_GENCB_call(cb, 3, 0); |
| 189 | cb(3, 0, cb_arg); | ||
| 190 | 182 | ||
| 191 | ret = 1; | 183 | ret = 1; |
| 192 | 184 | ||
| @@ -248,11 +240,11 @@ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx) | |||
| 248 | * are generated using the previous function and supplied as input. | 240 | * are generated using the previous function and supplied as input. |
| 249 | */ | 241 | */ |
| 250 | 242 | ||
| 251 | int BN_X931_generate_prime(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, | 243 | int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, |
| 252 | BIGNUM *Xp1, BIGNUM *Xp2, | 244 | BIGNUM *Xp1, BIGNUM *Xp2, |
| 253 | const BIGNUM *Xp, | 245 | const BIGNUM *Xp, |
| 254 | const BIGNUM *e, BN_CTX *ctx, | 246 | const BIGNUM *e, BN_CTX *ctx, |
| 255 | void (*cb)(int, int, void *), void *cb_arg) | 247 | BN_GENCB *cb) |
| 256 | { | 248 | { |
| 257 | int ret = 0; | 249 | int ret = 0; |
| 258 | 250 | ||
| @@ -266,8 +258,7 @@ int BN_X931_generate_prime(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, | |||
| 266 | goto error; | 258 | goto error; |
| 267 | if (!BN_rand(Xp2, 101, 0, 0)) | 259 | if (!BN_rand(Xp2, 101, 0, 0)) |
| 268 | goto error; | 260 | goto error; |
| 269 | if (!BN_X931_derive_prime(p, p1, p2, cb, cb_arg, | 261 | if (!BN_X931_derive_prime_ex(p, p1, p2, Xp, Xp1, Xp2, e, ctx, cb)) |
| 270 | Xp, Xp1, Xp2, e, ctx)) | ||
| 271 | goto error; | 262 | goto error; |
| 272 | 263 | ||
| 273 | ret = 1; | 264 | ret = 1; |
| @@ -279,4 +270,3 @@ int BN_X931_generate_prime(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, | |||
| 279 | 270 | ||
| 280 | } | 271 | } |
| 281 | 272 | ||
| 282 | #endif | ||
diff --git a/src/lib/libssl/src/crypto/buffer/buf_str.c b/src/lib/libssl/src/crypto/buffer/buf_str.c new file mode 100644 index 0000000000..28dd1e401e --- /dev/null +++ b/src/lib/libssl/src/crypto/buffer/buf_str.c | |||
| @@ -0,0 +1,116 @@ | |||
| 1 | /* crypto/buffer/buf_str.c */ | ||
| 2 | /* ==================================================================== | ||
| 3 | * Copyright (c) 2007 The OpenSSL Project. All rights reserved. | ||
| 4 | * | ||
| 5 | * Redistribution and use in source and binary forms, with or without | ||
| 6 | * modification, are permitted provided that the following conditions | ||
| 7 | * are met: | ||
| 8 | * | ||
| 9 | * 1. Redistributions of source code must retain the above copyright | ||
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * | ||
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer in | ||
| 14 | * the documentation and/or other materials provided with the | ||
| 15 | * distribution. | ||
| 16 | * | ||
| 17 | * 3. All advertising materials mentioning features or use of this | ||
| 18 | * software must display the following acknowledgment: | ||
| 19 | * "This product includes software developed by the OpenSSL Project | ||
| 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 21 | * | ||
| 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 23 | * endorse or promote products derived from this software without | ||
| 24 | * prior written permission. For written permission, please contact | ||
| 25 | * licensing@OpenSSL.org. | ||
| 26 | * | ||
| 27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 28 | * nor may "OpenSSL" appear in their names without prior written | ||
| 29 | * permission of the OpenSSL Project. | ||
| 30 | * | ||
| 31 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 32 | * acknowledgment: | ||
| 33 | * "This product includes software developed by the OpenSSL Project | ||
| 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 35 | * | ||
| 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 54 | */ | ||
| 55 | |||
| 56 | #include <stdio.h> | ||
| 57 | #include "cryptlib.h" | ||
| 58 | #include <openssl/buffer.h> | ||
| 59 | |||
| 60 | char *BUF_strdup(const char *str) | ||
| 61 | { | ||
| 62 | if (str == NULL) return(NULL); | ||
| 63 | return BUF_strndup(str, strlen(str)); | ||
| 64 | } | ||
| 65 | |||
| 66 | char *BUF_strndup(const char *str, size_t siz) | ||
| 67 | { | ||
| 68 | char *ret; | ||
| 69 | |||
| 70 | if (str == NULL) return(NULL); | ||
| 71 | |||
| 72 | ret=OPENSSL_malloc(siz+1); | ||
| 73 | if (ret == NULL) | ||
| 74 | { | ||
| 75 | BUFerr(BUF_F_BUF_STRNDUP,ERR_R_MALLOC_FAILURE); | ||
| 76 | return(NULL); | ||
| 77 | } | ||
| 78 | BUF_strlcpy(ret,str,siz+1); | ||
| 79 | return(ret); | ||
| 80 | } | ||
| 81 | |||
| 82 | void *BUF_memdup(const void *data, size_t siz) | ||
| 83 | { | ||
| 84 | void *ret; | ||
| 85 | |||
| 86 | if (data == NULL) return(NULL); | ||
| 87 | |||
| 88 | ret=OPENSSL_malloc(siz); | ||
| 89 | if (ret == NULL) | ||
| 90 | { | ||
| 91 | BUFerr(BUF_F_BUF_MEMDUP,ERR_R_MALLOC_FAILURE); | ||
| 92 | return(NULL); | ||
| 93 | } | ||
| 94 | return memcpy(ret, data, siz); | ||
| 95 | } | ||
| 96 | |||
| 97 | size_t BUF_strlcpy(char *dst, const char *src, size_t size) | ||
| 98 | { | ||
| 99 | size_t l = 0; | ||
| 100 | for(; size > 1 && *src; size--) | ||
| 101 | { | ||
| 102 | *dst++ = *src++; | ||
| 103 | l++; | ||
| 104 | } | ||
| 105 | if (size) | ||
| 106 | *dst = '\0'; | ||
| 107 | return l + strlen(src); | ||
| 108 | } | ||
| 109 | |||
| 110 | size_t BUF_strlcat(char *dst, const char *src, size_t size) | ||
| 111 | { | ||
| 112 | size_t l = 0; | ||
| 113 | for(; size > 0 && *dst; size--, dst++) | ||
| 114 | l++; | ||
| 115 | return l + BUF_strlcpy(dst, src, size); | ||
| 116 | } | ||
diff --git a/src/lib/libssl/src/crypto/camellia/Makefile b/src/lib/libssl/src/crypto/camellia/Makefile index 1579de5ce5..dfb12951fd 100644 --- a/src/lib/libssl/src/crypto/camellia/Makefile +++ b/src/lib/libssl/src/crypto/camellia/Makefile | |||
| @@ -41,7 +41,7 @@ top: | |||
| 41 | all: lib | 41 | all: lib |
| 42 | 42 | ||
| 43 | lib: $(LIBOBJ) | 43 | lib: $(LIBOBJ) |
| 44 | $(AR) $(LIB) $(LIBOBJ) | 44 | $(ARX) $(LIB) $(LIBOBJ) |
| 45 | $(RANLIB) $(LIB) || echo Never mind. | 45 | $(RANLIB) $(LIB) || echo Never mind. |
| 46 | @touch lib | 46 | @touch lib |
| 47 | 47 | ||
diff --git a/src/lib/libssl/src/crypto/camellia/camellia.h b/src/lib/libssl/src/crypto/camellia/camellia.h index 3c8a359543..b8a8b6e10b 100644 --- a/src/lib/libssl/src/crypto/camellia/camellia.h +++ b/src/lib/libssl/src/crypto/camellia/camellia.h | |||
| @@ -87,6 +87,11 @@ struct camellia_key_st | |||
| 87 | 87 | ||
| 88 | typedef struct camellia_key_st CAMELLIA_KEY; | 88 | typedef struct camellia_key_st CAMELLIA_KEY; |
| 89 | 89 | ||
| 90 | #ifdef OPENSSL_FIPS | ||
| 91 | int private_Camellia_set_key(const unsigned char *userKey, const int bits, | ||
| 92 | CAMELLIA_KEY *key); | ||
| 93 | #endif | ||
| 94 | |||
| 90 | int Camellia_set_key(const unsigned char *userKey, const int bits, | 95 | int Camellia_set_key(const unsigned char *userKey, const int bits, |
| 91 | CAMELLIA_KEY *key); | 96 | CAMELLIA_KEY *key); |
| 92 | 97 | ||
diff --git a/src/lib/libssl/src/crypto/camellia/cmll_misc.c b/src/lib/libssl/src/crypto/camellia/cmll_misc.c index f1047b54e0..2cd7aba9bb 100644 --- a/src/lib/libssl/src/crypto/camellia/cmll_misc.c +++ b/src/lib/libssl/src/crypto/camellia/cmll_misc.c | |||
| @@ -52,11 +52,24 @@ | |||
| 52 | #include <openssl/opensslv.h> | 52 | #include <openssl/opensslv.h> |
| 53 | #include <openssl/camellia.h> | 53 | #include <openssl/camellia.h> |
| 54 | #include "cmll_locl.h" | 54 | #include "cmll_locl.h" |
| 55 | #include <openssl/crypto.h> | ||
| 56 | #ifdef OPENSSL_FIPS | ||
| 57 | #include <openssl/fips.h> | ||
| 58 | #endif | ||
| 55 | 59 | ||
| 56 | const char CAMELLIA_version[]="CAMELLIA" OPENSSL_VERSION_PTEXT; | 60 | const char CAMELLIA_version[]="CAMELLIA" OPENSSL_VERSION_PTEXT; |
| 57 | 61 | ||
| 58 | int Camellia_set_key(const unsigned char *userKey, const int bits, | 62 | int Camellia_set_key(const unsigned char *userKey, const int bits, |
| 59 | CAMELLIA_KEY *key) | 63 | CAMELLIA_KEY *key) |
| 64 | #ifdef OPENSSL_FIPS | ||
| 65 | { | ||
| 66 | if (FIPS_mode()) | ||
| 67 | FIPS_BAD_ABORT(CAMELLIA) | ||
| 68 | return private_Camellia_set_key(userKey, bits, key); | ||
| 69 | } | ||
| 70 | int private_Camellia_set_key(const unsigned char *userKey, const int bits, | ||
| 71 | CAMELLIA_KEY *key) | ||
| 72 | #endif | ||
| 60 | { | 73 | { |
| 61 | if (!userKey || !key) | 74 | if (!userKey || !key) |
| 62 | { | 75 | { |
diff --git a/src/lib/libssl/src/crypto/cms/Makefile b/src/lib/libssl/src/crypto/cms/Makefile index e39c310b6c..1c137e0cff 100644 --- a/src/lib/libssl/src/crypto/cms/Makefile +++ b/src/lib/libssl/src/crypto/cms/Makefile | |||
| @@ -37,7 +37,7 @@ test: | |||
| 37 | all: lib | 37 | all: lib |
| 38 | 38 | ||
| 39 | lib: $(LIBOBJ) | 39 | lib: $(LIBOBJ) |
| 40 | $(AR) $(LIB) $(LIBOBJ) | 40 | $(ARX) $(LIB) $(LIBOBJ) |
| 41 | $(RANLIB) $(LIB) || echo Never mind. | 41 | $(RANLIB) $(LIB) || echo Never mind. |
| 42 | @touch lib | 42 | @touch lib |
| 43 | 43 | ||
diff --git a/src/lib/libssl/src/crypto/cms/cms_sd.c b/src/lib/libssl/src/crypto/cms/cms_sd.c index 591bfbec33..cdac3b870d 100644 --- a/src/lib/libssl/src/crypto/cms/cms_sd.c +++ b/src/lib/libssl/src/crypto/cms/cms_sd.c | |||
| @@ -830,7 +830,7 @@ int CMS_SignerInfo_verify(CMS_SignerInfo *si) | |||
| 830 | cms_fixup_mctx(&mctx, si->pkey); | 830 | cms_fixup_mctx(&mctx, si->pkey); |
| 831 | r = EVP_VerifyFinal(&mctx, | 831 | r = EVP_VerifyFinal(&mctx, |
| 832 | si->signature->data, si->signature->length, si->pkey); | 832 | si->signature->data, si->signature->length, si->pkey); |
| 833 | if (!r) | 833 | if (r <= 0) |
| 834 | CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY, CMS_R_VERIFICATION_FAILURE); | 834 | CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY, CMS_R_VERIFICATION_FAILURE); |
| 835 | err: | 835 | err: |
| 836 | EVP_MD_CTX_cleanup(&mctx); | 836 | EVP_MD_CTX_cleanup(&mctx); |
diff --git a/src/lib/libssl/src/crypto/cms/cms_smime.c b/src/lib/libssl/src/crypto/cms/cms_smime.c index f79c504e91..b9463f9abb 100644 --- a/src/lib/libssl/src/crypto/cms/cms_smime.c +++ b/src/lib/libssl/src/crypto/cms/cms_smime.c | |||
| @@ -68,7 +68,10 @@ static int cms_copy_content(BIO *out, BIO *in, unsigned int flags) | |||
| 68 | if (out == NULL) | 68 | if (out == NULL) |
| 69 | tmpout = BIO_new(BIO_s_null()); | 69 | tmpout = BIO_new(BIO_s_null()); |
| 70 | else if (flags & CMS_TEXT) | 70 | else if (flags & CMS_TEXT) |
| 71 | { | ||
| 71 | tmpout = BIO_new(BIO_s_mem()); | 72 | tmpout = BIO_new(BIO_s_mem()); |
| 73 | BIO_set_mem_eof_return(tmpout, 0); | ||
| 74 | } | ||
| 72 | else | 75 | else |
| 73 | tmpout = out; | 76 | tmpout = out; |
| 74 | 77 | ||
| @@ -89,11 +92,13 @@ static int cms_copy_content(BIO *out, BIO *in, unsigned int flags) | |||
| 89 | if (!BIO_get_cipher_status(in)) | 92 | if (!BIO_get_cipher_status(in)) |
| 90 | goto err; | 93 | goto err; |
| 91 | } | 94 | } |
| 95 | if (i < 0) | ||
| 96 | goto err; | ||
| 92 | break; | 97 | break; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| 95 | if (tmpout) | 100 | if (tmpout && (BIO_write(tmpout, buf, i) != i)) |
| 96 | BIO_write(tmpout, buf, i); | 101 | goto err; |
| 97 | } | 102 | } |
| 98 | 103 | ||
| 99 | if(flags & CMS_TEXT) | 104 | if(flags & CMS_TEXT) |
diff --git a/src/lib/libssl/src/crypto/ec/ec_key.c b/src/lib/libssl/src/crypto/ec/ec_key.c index 3d6c900b95..12fb0e6d6d 100644 --- a/src/lib/libssl/src/crypto/ec/ec_key.c +++ b/src/lib/libssl/src/crypto/ec/ec_key.c | |||
| @@ -296,7 +296,7 @@ int EC_KEY_check_key(const EC_KEY *eckey) | |||
| 296 | { | 296 | { |
| 297 | int ok = 0; | 297 | int ok = 0; |
| 298 | BN_CTX *ctx = NULL; | 298 | BN_CTX *ctx = NULL; |
| 299 | BIGNUM *order = NULL; | 299 | const BIGNUM *order = NULL; |
| 300 | EC_POINT *point = NULL; | 300 | EC_POINT *point = NULL; |
| 301 | 301 | ||
| 302 | if (!eckey || !eckey->group || !eckey->pub_key) | 302 | if (!eckey || !eckey->group || !eckey->pub_key) |
| @@ -307,8 +307,6 @@ int EC_KEY_check_key(const EC_KEY *eckey) | |||
| 307 | 307 | ||
| 308 | if ((ctx = BN_CTX_new()) == NULL) | 308 | if ((ctx = BN_CTX_new()) == NULL) |
| 309 | goto err; | 309 | goto err; |
| 310 | if ((order = BN_new()) == NULL) | ||
| 311 | goto err; | ||
| 312 | if ((point = EC_POINT_new(eckey->group)) == NULL) | 310 | if ((point = EC_POINT_new(eckey->group)) == NULL) |
| 313 | goto err; | 311 | goto err; |
| 314 | 312 | ||
| @@ -319,17 +317,13 @@ int EC_KEY_check_key(const EC_KEY *eckey) | |||
| 319 | goto err; | 317 | goto err; |
| 320 | } | 318 | } |
| 321 | /* testing whether pub_key * order is the point at infinity */ | 319 | /* testing whether pub_key * order is the point at infinity */ |
| 322 | if (!EC_GROUP_get_order(eckey->group, order, ctx)) | 320 | order = &eckey->group->order; |
| 321 | if (BN_is_zero(order)) | ||
| 323 | { | 322 | { |
| 324 | ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_INVALID_GROUP_ORDER); | 323 | ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_INVALID_GROUP_ORDER); |
| 325 | goto err; | 324 | goto err; |
| 326 | } | 325 | } |
| 327 | if (!EC_POINT_copy(point, eckey->pub_key)) | 326 | if (!EC_POINT_mul(eckey->group, point, NULL, eckey->pub_key, order, ctx)) |
| 328 | { | ||
| 329 | ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_EC_LIB); | ||
| 330 | goto err; | ||
| 331 | } | ||
| 332 | if (!EC_POINT_mul(eckey->group, point, order, NULL, NULL, ctx)) | ||
| 333 | { | 327 | { |
| 334 | ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_EC_LIB); | 328 | ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_EC_LIB); |
| 335 | goto err; | 329 | goto err; |
| @@ -366,8 +360,6 @@ int EC_KEY_check_key(const EC_KEY *eckey) | |||
| 366 | err: | 360 | err: |
| 367 | if (ctx != NULL) | 361 | if (ctx != NULL) |
| 368 | BN_CTX_free(ctx); | 362 | BN_CTX_free(ctx); |
| 369 | if (order != NULL) | ||
| 370 | BN_free(order); | ||
| 371 | if (point != NULL) | 363 | if (point != NULL) |
| 372 | EC_POINT_free(point); | 364 | EC_POINT_free(point); |
| 373 | return(ok); | 365 | return(ok); |
diff --git a/src/lib/libssl/src/crypto/ecdh/Makefile b/src/lib/libssl/src/crypto/ecdh/Makefile index 95aa69fea5..7a7b618eeb 100644 --- a/src/lib/libssl/src/crypto/ecdh/Makefile +++ b/src/lib/libssl/src/crypto/ecdh/Makefile | |||
| @@ -34,7 +34,7 @@ top: | |||
| 34 | all: lib | 34 | all: lib |
| 35 | 35 | ||
| 36 | lib: $(LIBOBJ) | 36 | lib: $(LIBOBJ) |
| 37 | $(AR) $(LIB) $(LIBOBJ) | 37 | $(ARX) $(LIB) $(LIBOBJ) |
| 38 | $(RANLIB) $(LIB) || echo Never mind. | 38 | $(RANLIB) $(LIB) || echo Never mind. |
| 39 | @touch lib | 39 | @touch lib |
| 40 | 40 | ||
| @@ -84,20 +84,31 @@ ech_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | |||
| 84 | ech_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 84 | ech_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 85 | ech_err.o: ech_err.c | 85 | ech_err.o: ech_err.c |
| 86 | ech_key.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 86 | ech_key.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 87 | ech_key.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | 87 | ech_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 88 | ech_key.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h | 88 | ech_key.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h |
| 89 | ech_key.o: ../../include/openssl/engine.h ../../include/openssl/opensslconf.h | 89 | ech_key.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h |
| 90 | ech_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 90 | ech_key.o: ../../include/openssl/engine.h ../../include/openssl/evp.h |
| 91 | ech_key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 91 | ech_key.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h |
| 92 | ech_key.o: ../../include/openssl/symhacks.h ech_key.c ech_locl.h | 92 | ech_key.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
| 93 | ech_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 94 | ech_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 95 | ech_key.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 96 | ech_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 97 | ech_key.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 98 | ech_key.o: ech_key.c ech_locl.h | ||
| 93 | ech_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 99 | ech_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 94 | ech_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | 100 | ech_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 95 | ech_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h | 101 | ech_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h |
| 102 | ech_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h | ||
| 96 | ech_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h | 103 | ech_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h |
| 97 | ech_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | 104 | ech_lib.o: ../../include/openssl/evp.h ../../include/openssl/fips.h |
| 105 | ech_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 106 | ech_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 98 | ech_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 107 | ech_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 99 | ech_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 108 | ech_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h |
| 100 | ech_lib.o: ../../include/openssl/symhacks.h ech_lib.c ech_locl.h | 109 | ech_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
| 110 | ech_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 111 | ech_lib.o: ../../include/openssl/x509_vfy.h ech_lib.c ech_locl.h | ||
| 101 | ech_ossl.o: ../../e_os.h ../../include/openssl/asn1.h | 112 | ech_ossl.o: ../../e_os.h ../../include/openssl/asn1.h |
| 102 | ech_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | 113 | ech_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h |
| 103 | ech_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 114 | ech_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
diff --git a/src/lib/libssl/src/crypto/ecdsa/Makefile b/src/lib/libssl/src/crypto/ecdsa/Makefile index 16a93cd3ae..4865f3c8d6 100644 --- a/src/lib/libssl/src/crypto/ecdsa/Makefile +++ b/src/lib/libssl/src/crypto/ecdsa/Makefile | |||
| @@ -34,7 +34,7 @@ top: | |||
| 34 | all: lib | 34 | all: lib |
| 35 | 35 | ||
| 36 | lib: $(LIBOBJ) | 36 | lib: $(LIBOBJ) |
| 37 | $(AR) $(LIB) $(LIBOBJ) | 37 | $(ARX) $(LIB) $(LIBOBJ) |
| 38 | $(RANLIB) $(LIB) || echo Never mind. | 38 | $(RANLIB) $(LIB) || echo Never mind. |
| 39 | @touch lib | 39 | @touch lib |
| 40 | 40 | ||
| @@ -92,13 +92,18 @@ ecs_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | |||
| 92 | ecs_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 92 | ecs_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 93 | ecs_err.o: ecs_err.c | 93 | ecs_err.o: ecs_err.c |
| 94 | ecs_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 94 | ecs_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 95 | ecs_lib.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h | 95 | ecs_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h |
| 96 | ecs_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h | 96 | ecs_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h |
| 97 | ecs_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h | ||
| 97 | ecs_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h | 98 | ecs_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h |
| 98 | ecs_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | 99 | ecs_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
| 100 | ecs_lib.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h | ||
| 101 | ecs_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 99 | ecs_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | 102 | ecs_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
| 100 | ecs_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | 103 | ecs_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h |
| 104 | ecs_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 101 | ecs_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 105 | ecs_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 106 | ecs_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 102 | ecs_lib.o: ecs_lib.c ecs_locl.h | 107 | ecs_lib.o: ecs_lib.c ecs_locl.h |
| 103 | ecs_ossl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 108 | ecs_ossl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 104 | ecs_ossl.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h | 109 | ecs_ossl.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h |
| @@ -110,16 +115,28 @@ ecs_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | |||
| 110 | ecs_ossl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 115 | ecs_ossl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h |
| 111 | ecs_ossl.o: ../../include/openssl/symhacks.h ecs_locl.h ecs_ossl.c | 116 | ecs_ossl.o: ../../include/openssl/symhacks.h ecs_locl.h ecs_ossl.c |
| 112 | ecs_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 117 | ecs_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 113 | ecs_sign.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | 118 | ecs_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 114 | ecs_sign.o: ../../include/openssl/ec.h ../../include/openssl/ecdsa.h | 119 | ecs_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h |
| 115 | ecs_sign.o: ../../include/openssl/engine.h ../../include/openssl/opensslconf.h | 120 | ecs_sign.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h |
| 121 | ecs_sign.o: ../../include/openssl/engine.h ../../include/openssl/evp.h | ||
| 122 | ecs_sign.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h | ||
| 123 | ecs_sign.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 124 | ecs_sign.o: ../../include/openssl/opensslconf.h | ||
| 116 | ecs_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 125 | ecs_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 117 | ecs_sign.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 126 | ecs_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h |
| 118 | ecs_sign.o: ../../include/openssl/symhacks.h ecs_locl.h ecs_sign.c | 127 | ecs_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
| 128 | ecs_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 129 | ecs_sign.o: ../../include/openssl/x509_vfy.h ecs_locl.h ecs_sign.c | ||
| 119 | ecs_vrf.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 130 | ecs_vrf.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 120 | ecs_vrf.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | 131 | ecs_vrf.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 121 | ecs_vrf.o: ../../include/openssl/ec.h ../../include/openssl/ecdsa.h | 132 | ecs_vrf.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h |
| 122 | ecs_vrf.o: ../../include/openssl/engine.h ../../include/openssl/opensslconf.h | 133 | ecs_vrf.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h |
| 123 | ecs_vrf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 134 | ecs_vrf.o: ../../include/openssl/engine.h ../../include/openssl/evp.h |
| 124 | ecs_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 135 | ecs_vrf.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h |
| 125 | ecs_vrf.o: ../../include/openssl/symhacks.h ecs_locl.h ecs_vrf.c | 136 | ecs_vrf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
| 137 | ecs_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 138 | ecs_vrf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 139 | ecs_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 140 | ecs_vrf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 141 | ecs_vrf.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 142 | ecs_vrf.o: ecs_locl.h ecs_vrf.c | ||
diff --git a/src/lib/libssl/src/crypto/evp/e_camellia.c b/src/lib/libssl/src/crypto/evp/e_camellia.c index a7b40d1c60..365d397164 100644 --- a/src/lib/libssl/src/crypto/evp/e_camellia.c +++ b/src/lib/libssl/src/crypto/evp/e_camellia.c | |||
| @@ -93,7 +93,7 @@ IMPLEMENT_BLOCK_CIPHER(camellia_256, ks, Camellia, EVP_CAMELLIA_KEY, | |||
| 93 | EVP_CIPHER_get_asn1_iv, | 93 | EVP_CIPHER_get_asn1_iv, |
| 94 | NULL) | 94 | NULL) |
| 95 | 95 | ||
| 96 | #define IMPLEMENT_CAMELLIA_CFBR(ksize,cbits) IMPLEMENT_CFBR(camellia,Camellia,EVP_CAMELLIA_KEY,ks,ksize,cbits,16) | 96 | #define IMPLEMENT_CAMELLIA_CFBR(ksize,cbits) IMPLEMENT_CFBR(camellia,Camellia,EVP_CAMELLIA_KEY,ks,ksize,cbits,16,0) |
| 97 | 97 | ||
| 98 | IMPLEMENT_CAMELLIA_CFBR(128,1) | 98 | IMPLEMENT_CAMELLIA_CFBR(128,1) |
| 99 | IMPLEMENT_CAMELLIA_CFBR(192,1) | 99 | IMPLEMENT_CAMELLIA_CFBR(192,1) |
diff --git a/src/lib/libssl/src/crypto/fips_err.h b/src/lib/libssl/src/crypto/fips_err.h new file mode 100644 index 0000000000..b328616858 --- /dev/null +++ b/src/lib/libssl/src/crypto/fips_err.h | |||
| @@ -0,0 +1,137 @@ | |||
| 1 | /* crypto/fips_err.h */ | ||
| 2 | /* ==================================================================== | ||
| 3 | * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. | ||
| 4 | * | ||
| 5 | * Redistribution and use in source and binary forms, with or without | ||
| 6 | * modification, are permitted provided that the following conditions | ||
| 7 | * are met: | ||
| 8 | * | ||
| 9 | * 1. Redistributions of source code must retain the above copyright | ||
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * | ||
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer in | ||
| 14 | * the documentation and/or other materials provided with the | ||
| 15 | * distribution. | ||
| 16 | * | ||
| 17 | * 3. All advertising materials mentioning features or use of this | ||
| 18 | * software must display the following acknowledgment: | ||
| 19 | * "This product includes software developed by the OpenSSL Project | ||
| 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 21 | * | ||
| 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 23 | * endorse or promote products derived from this software without | ||
| 24 | * prior written permission. For written permission, please contact | ||
| 25 | * openssl-core@OpenSSL.org. | ||
| 26 | * | ||
| 27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 28 | * nor may "OpenSSL" appear in their names without prior written | ||
| 29 | * permission of the OpenSSL Project. | ||
| 30 | * | ||
| 31 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 32 | * acknowledgment: | ||
| 33 | * "This product includes software developed by the OpenSSL Project | ||
| 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 35 | * | ||
| 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 54 | */ | ||
| 55 | |||
| 56 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes | ||
| 57 | * made to it will be overwritten when the script next updates this file, | ||
| 58 | * only reason strings will be preserved. | ||
| 59 | */ | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include <openssl/err.h> | ||
| 63 | #include <openssl/fips.h> | ||
| 64 | |||
| 65 | /* BEGIN ERROR CODES */ | ||
| 66 | #ifndef OPENSSL_NO_ERR | ||
| 67 | |||
| 68 | #define ERR_FUNC(func) ERR_PACK(ERR_LIB_FIPS,func,0) | ||
| 69 | #define ERR_REASON(reason) ERR_PACK(ERR_LIB_FIPS,0,reason) | ||
| 70 | |||
| 71 | static ERR_STRING_DATA FIPS_str_functs[]= | ||
| 72 | { | ||
| 73 | {ERR_FUNC(FIPS_F_DH_BUILTIN_GENPARAMS), "DH_BUILTIN_GENPARAMS"}, | ||
| 74 | {ERR_FUNC(FIPS_F_DSA_BUILTIN_PARAMGEN), "DSA_BUILTIN_PARAMGEN"}, | ||
| 75 | {ERR_FUNC(FIPS_F_DSA_DO_SIGN), "DSA_do_sign"}, | ||
| 76 | {ERR_FUNC(FIPS_F_DSA_DO_VERIFY), "DSA_do_verify"}, | ||
| 77 | {ERR_FUNC(FIPS_F_EVP_CIPHERINIT_EX), "EVP_CipherInit_ex"}, | ||
| 78 | {ERR_FUNC(FIPS_F_EVP_DIGESTINIT_EX), "EVP_DigestInit_ex"}, | ||
| 79 | {ERR_FUNC(FIPS_F_FIPS_CHECK_DSA), "FIPS_CHECK_DSA"}, | ||
| 80 | {ERR_FUNC(FIPS_F_FIPS_CHECK_INCORE_FINGERPRINT), "FIPS_CHECK_INCORE_FINGERPRINT"}, | ||
| 81 | {ERR_FUNC(FIPS_F_FIPS_CHECK_RSA), "FIPS_CHECK_RSA"}, | ||
| 82 | {ERR_FUNC(FIPS_F_FIPS_DSA_CHECK), "FIPS_DSA_CHECK"}, | ||
| 83 | {ERR_FUNC(FIPS_F_FIPS_MODE_SET), "FIPS_mode_set"}, | ||
| 84 | {ERR_FUNC(FIPS_F_FIPS_PKEY_SIGNATURE_TEST), "fips_pkey_signature_test"}, | ||
| 85 | {ERR_FUNC(FIPS_F_FIPS_SELFTEST_AES), "FIPS_selftest_aes"}, | ||
| 86 | {ERR_FUNC(FIPS_F_FIPS_SELFTEST_DES), "FIPS_selftest_des"}, | ||
| 87 | {ERR_FUNC(FIPS_F_FIPS_SELFTEST_DSA), "FIPS_selftest_dsa"}, | ||
| 88 | {ERR_FUNC(FIPS_F_FIPS_SELFTEST_HMAC), "FIPS_selftest_hmac"}, | ||
| 89 | {ERR_FUNC(FIPS_F_FIPS_SELFTEST_RNG), "FIPS_selftest_rng"}, | ||
| 90 | {ERR_FUNC(FIPS_F_FIPS_SELFTEST_SHA1), "FIPS_selftest_sha1"}, | ||
| 91 | {ERR_FUNC(FIPS_F_HASH_FINAL), "HASH_FINAL"}, | ||
| 92 | {ERR_FUNC(FIPS_F_RSA_BUILTIN_KEYGEN), "RSA_BUILTIN_KEYGEN"}, | ||
| 93 | {ERR_FUNC(FIPS_F_RSA_EAY_PRIVATE_DECRYPT), "RSA_EAY_PRIVATE_DECRYPT"}, | ||
| 94 | {ERR_FUNC(FIPS_F_RSA_EAY_PRIVATE_ENCRYPT), "RSA_EAY_PRIVATE_ENCRYPT"}, | ||
| 95 | {ERR_FUNC(FIPS_F_RSA_EAY_PUBLIC_DECRYPT), "RSA_EAY_PUBLIC_DECRYPT"}, | ||
| 96 | {ERR_FUNC(FIPS_F_RSA_EAY_PUBLIC_ENCRYPT), "RSA_EAY_PUBLIC_ENCRYPT"}, | ||
| 97 | {ERR_FUNC(FIPS_F_RSA_X931_GENERATE_KEY_EX), "RSA_X931_generate_key_ex"}, | ||
| 98 | {ERR_FUNC(FIPS_F_SSLEAY_RAND_BYTES), "SSLEAY_RAND_BYTES"}, | ||
| 99 | {0,NULL} | ||
| 100 | }; | ||
| 101 | |||
| 102 | static ERR_STRING_DATA FIPS_str_reasons[]= | ||
| 103 | { | ||
| 104 | {ERR_REASON(FIPS_R_CANNOT_READ_EXE) ,"cannot read exe"}, | ||
| 105 | {ERR_REASON(FIPS_R_CANNOT_READ_EXE_DIGEST),"cannot read exe digest"}, | ||
| 106 | {ERR_REASON(FIPS_R_CONTRADICTING_EVIDENCE),"contradicting evidence"}, | ||
| 107 | {ERR_REASON(FIPS_R_EXE_DIGEST_DOES_NOT_MATCH),"exe digest does not match"}, | ||
| 108 | {ERR_REASON(FIPS_R_FINGERPRINT_DOES_NOT_MATCH),"fingerprint does not match"}, | ||
| 109 | {ERR_REASON(FIPS_R_FINGERPRINT_DOES_NOT_MATCH_NONPIC_RELOCATED),"fingerprint does not match nonpic relocated"}, | ||
| 110 | {ERR_REASON(FIPS_R_FINGERPRINT_DOES_NOT_MATCH_SEGMENT_ALIASING),"fingerprint does not match segment aliasing"}, | ||
| 111 | {ERR_REASON(FIPS_R_FIPS_MODE_ALREADY_SET),"fips mode already set"}, | ||
| 112 | {ERR_REASON(FIPS_R_FIPS_SELFTEST_FAILED) ,"fips selftest failed"}, | ||
| 113 | {ERR_REASON(FIPS_R_INVALID_KEY_LENGTH) ,"invalid key length"}, | ||
| 114 | {ERR_REASON(FIPS_R_KEY_TOO_SHORT) ,"key too short"}, | ||
| 115 | {ERR_REASON(FIPS_R_NON_FIPS_METHOD) ,"non fips method"}, | ||
| 116 | {ERR_REASON(FIPS_R_PAIRWISE_TEST_FAILED) ,"pairwise test failed"}, | ||
| 117 | {ERR_REASON(FIPS_R_RSA_DECRYPT_ERROR) ,"rsa decrypt error"}, | ||
| 118 | {ERR_REASON(FIPS_R_RSA_ENCRYPT_ERROR) ,"rsa encrypt error"}, | ||
| 119 | {ERR_REASON(FIPS_R_SELFTEST_FAILED) ,"selftest failed"}, | ||
| 120 | {ERR_REASON(FIPS_R_TEST_FAILURE) ,"test failure"}, | ||
| 121 | {ERR_REASON(FIPS_R_UNSUPPORTED_PLATFORM) ,"unsupported platform"}, | ||
| 122 | {0,NULL} | ||
| 123 | }; | ||
| 124 | |||
| 125 | #endif | ||
| 126 | |||
| 127 | void ERR_load_FIPS_strings(void) | ||
| 128 | { | ||
| 129 | #ifndef OPENSSL_NO_ERR | ||
| 130 | |||
| 131 | if (ERR_func_error_string(FIPS_str_functs[0].error) == NULL) | ||
| 132 | { | ||
| 133 | ERR_load_strings(0,FIPS_str_functs); | ||
| 134 | ERR_load_strings(0,FIPS_str_reasons); | ||
| 135 | } | ||
| 136 | #endif | ||
| 137 | } | ||
diff --git a/src/lib/libssl/src/crypto/jpake/Makefile b/src/lib/libssl/src/crypto/jpake/Makefile new file mode 100644 index 0000000000..a4a1402f2e --- /dev/null +++ b/src/lib/libssl/src/crypto/jpake/Makefile | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | DIR=jpake | ||
| 2 | TOP=../.. | ||
| 3 | |||
| 4 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
| 5 | |||
| 6 | LIB=$(TOP)/libcrypto.a | ||
| 7 | LIBOBJ=jpake.o jpake_err.o | ||
| 8 | LIBSRC=jpake.c jpake_err.c | ||
| 9 | |||
| 10 | EXHEADER=jpake.h | ||
| 11 | TEST=jpaketest.c | ||
| 12 | |||
| 13 | top: | ||
| 14 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
| 15 | |||
| 16 | all: lib | ||
| 17 | |||
| 18 | lib: $(LIBOBJ) | ||
| 19 | $(ARX) $(LIB) $(LIBOBJ) | ||
| 20 | $(RANLIB) $(LIB) || echo Never mind. | ||
| 21 | @touch lib | ||
| 22 | |||
| 23 | links: | ||
| 24 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) | ||
| 25 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) | ||
| 26 | |||
| 27 | install: | ||
| 28 | @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile... | ||
| 29 | @headerlist="$(EXHEADER)"; for i in $$headerlist ; \ | ||
| 30 | do \ | ||
| 31 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ | ||
| 32 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ | ||
| 33 | done; | ||
| 34 | |||
| 35 | depend: | ||
| 36 | @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile... | ||
| 37 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) | ||
| 38 | |||
| 39 | dclean: | ||
| 40 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
| 41 | mv -f Makefile.new $(MAKEFILE) | ||
| 42 | |||
| 43 | clean: | ||
| 44 | rm -f *.s *.o *.obj des lib tags core .pure .nfs* *.old *.bak fluff | ||
| 45 | |||
| 46 | jpaketest: top jpaketest.c $(LIB) | ||
| 47 | $(CC) $(CFLAGS) -Wall -Werror -g -o jpaketest jpaketest.c $(LIB) | ||
| 48 | # DO NOT DELETE THIS LINE -- make depend depends on it. | ||
| 49 | |||
| 50 | jpake.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 51 | jpake.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | ||
| 52 | jpake.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 53 | jpake.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 54 | jpake.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | ||
| 55 | jpake.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 56 | jpake.o: ../../include/openssl/symhacks.h jpake.c jpake.h | ||
| 57 | jpake_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 58 | jpake_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | ||
| 59 | jpake_err.o: ../../include/openssl/err.h ../../include/openssl/jpake.h | ||
| 60 | jpake_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 61 | jpake_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 62 | jpake_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 63 | jpake_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 64 | jpake_err.o: jpake_err.c | ||
diff --git a/src/lib/libssl/src/crypto/jpake/jpake.c b/src/lib/libssl/src/crypto/jpake/jpake.c new file mode 100644 index 0000000000..577b7ef375 --- /dev/null +++ b/src/lib/libssl/src/crypto/jpake/jpake.c | |||
| @@ -0,0 +1,483 @@ | |||
| 1 | #include "jpake.h" | ||
| 2 | |||
| 3 | #include <openssl/crypto.h> | ||
| 4 | #include <openssl/sha.h> | ||
| 5 | #include <openssl/err.h> | ||
| 6 | #include <memory.h> | ||
| 7 | #include <assert.h> | ||
| 8 | |||
| 9 | /* | ||
| 10 | * In the definition, (xa, xb, xc, xd) are Alice's (x1, x2, x3, x4) or | ||
| 11 | * Bob's (x3, x4, x1, x2). If you see what I mean. | ||
| 12 | */ | ||
| 13 | |||
| 14 | typedef struct | ||
| 15 | { | ||
| 16 | char *name; /* Must be unique */ | ||
| 17 | char *peer_name; | ||
| 18 | BIGNUM *p; | ||
| 19 | BIGNUM *g; | ||
| 20 | BIGNUM *q; | ||
| 21 | BIGNUM *gxc; /* Alice's g^{x3} or Bob's g^{x1} */ | ||
| 22 | BIGNUM *gxd; /* Alice's g^{x4} or Bob's g^{x2} */ | ||
| 23 | } JPAKE_CTX_PUBLIC; | ||
| 24 | |||
| 25 | struct JPAKE_CTX | ||
| 26 | { | ||
| 27 | JPAKE_CTX_PUBLIC p; | ||
| 28 | BIGNUM *secret; /* The shared secret */ | ||
| 29 | BN_CTX *ctx; | ||
| 30 | BIGNUM *xa; /* Alice's x1 or Bob's x3 */ | ||
| 31 | BIGNUM *xb; /* Alice's x2 or Bob's x4 */ | ||
| 32 | BIGNUM *key; /* The calculated (shared) key */ | ||
| 33 | }; | ||
| 34 | |||
| 35 | static void JPAKE_ZKP_init(JPAKE_ZKP *zkp) | ||
| 36 | { | ||
| 37 | zkp->gr = BN_new(); | ||
| 38 | zkp->b = BN_new(); | ||
| 39 | } | ||
| 40 | |||
| 41 | static void JPAKE_ZKP_release(JPAKE_ZKP *zkp) | ||
| 42 | { | ||
| 43 | BN_free(zkp->b); | ||
| 44 | BN_free(zkp->gr); | ||
| 45 | } | ||
| 46 | |||
| 47 | /* Two birds with one stone - make the global name as expected */ | ||
| 48 | #define JPAKE_STEP_PART_init JPAKE_STEP2_init | ||
| 49 | #define JPAKE_STEP_PART_release JPAKE_STEP2_release | ||
| 50 | |||
| 51 | void JPAKE_STEP_PART_init(JPAKE_STEP_PART *p) | ||
| 52 | { | ||
| 53 | p->gx = BN_new(); | ||
| 54 | JPAKE_ZKP_init(&p->zkpx); | ||
| 55 | } | ||
| 56 | |||
| 57 | void JPAKE_STEP_PART_release(JPAKE_STEP_PART *p) | ||
| 58 | { | ||
| 59 | JPAKE_ZKP_release(&p->zkpx); | ||
| 60 | BN_free(p->gx); | ||
| 61 | } | ||
| 62 | |||
| 63 | void JPAKE_STEP1_init(JPAKE_STEP1 *s1) | ||
| 64 | { | ||
| 65 | JPAKE_STEP_PART_init(&s1->p1); | ||
| 66 | JPAKE_STEP_PART_init(&s1->p2); | ||
| 67 | } | ||
| 68 | |||
| 69 | void JPAKE_STEP1_release(JPAKE_STEP1 *s1) | ||
| 70 | { | ||
| 71 | JPAKE_STEP_PART_release(&s1->p2); | ||
| 72 | JPAKE_STEP_PART_release(&s1->p1); | ||
| 73 | } | ||
| 74 | |||
| 75 | static void JPAKE_CTX_init(JPAKE_CTX *ctx, const char *name, | ||
| 76 | const char *peer_name, const BIGNUM *p, | ||
| 77 | const BIGNUM *g, const BIGNUM *q, | ||
| 78 | const BIGNUM *secret) | ||
| 79 | { | ||
| 80 | ctx->p.name = OPENSSL_strdup(name); | ||
| 81 | ctx->p.peer_name = OPENSSL_strdup(peer_name); | ||
| 82 | ctx->p.p = BN_dup(p); | ||
| 83 | ctx->p.g = BN_dup(g); | ||
| 84 | ctx->p.q = BN_dup(q); | ||
| 85 | ctx->secret = BN_dup(secret); | ||
| 86 | |||
| 87 | ctx->p.gxc = BN_new(); | ||
| 88 | ctx->p.gxd = BN_new(); | ||
| 89 | |||
| 90 | ctx->xa = BN_new(); | ||
| 91 | ctx->xb = BN_new(); | ||
| 92 | ctx->key = BN_new(); | ||
| 93 | ctx->ctx = BN_CTX_new(); | ||
| 94 | } | ||
| 95 | |||
| 96 | static void JPAKE_CTX_release(JPAKE_CTX *ctx) | ||
| 97 | { | ||
| 98 | BN_CTX_free(ctx->ctx); | ||
| 99 | BN_clear_free(ctx->key); | ||
| 100 | BN_clear_free(ctx->xb); | ||
| 101 | BN_clear_free(ctx->xa); | ||
| 102 | |||
| 103 | BN_free(ctx->p.gxd); | ||
| 104 | BN_free(ctx->p.gxc); | ||
| 105 | |||
| 106 | BN_clear_free(ctx->secret); | ||
| 107 | BN_free(ctx->p.q); | ||
| 108 | BN_free(ctx->p.g); | ||
| 109 | BN_free(ctx->p.p); | ||
| 110 | OPENSSL_free(ctx->p.peer_name); | ||
| 111 | OPENSSL_free(ctx->p.name); | ||
| 112 | |||
| 113 | memset(ctx, '\0', sizeof *ctx); | ||
| 114 | } | ||
| 115 | |||
| 116 | JPAKE_CTX *JPAKE_CTX_new(const char *name, const char *peer_name, | ||
| 117 | const BIGNUM *p, const BIGNUM *g, const BIGNUM *q, | ||
| 118 | const BIGNUM *secret) | ||
| 119 | { | ||
| 120 | JPAKE_CTX *ctx = OPENSSL_malloc(sizeof *ctx); | ||
| 121 | |||
| 122 | JPAKE_CTX_init(ctx, name, peer_name, p, g, q, secret); | ||
| 123 | |||
| 124 | return ctx; | ||
| 125 | } | ||
| 126 | |||
| 127 | void JPAKE_CTX_free(JPAKE_CTX *ctx) | ||
| 128 | { | ||
| 129 | JPAKE_CTX_release(ctx); | ||
| 130 | OPENSSL_free(ctx); | ||
| 131 | } | ||
| 132 | |||
| 133 | static void hashlength(SHA_CTX *sha, size_t l) | ||
| 134 | { | ||
| 135 | unsigned char b[2]; | ||
| 136 | |||
| 137 | assert(l <= 0xffff); | ||
| 138 | b[0] = l >> 8; | ||
| 139 | b[1] = l&0xff; | ||
| 140 | SHA1_Update(sha, b, 2); | ||
| 141 | } | ||
| 142 | |||
| 143 | static void hashstring(SHA_CTX *sha, const char *string) | ||
| 144 | { | ||
| 145 | size_t l = strlen(string); | ||
| 146 | |||
| 147 | hashlength(sha, l); | ||
| 148 | SHA1_Update(sha, string, l); | ||
| 149 | } | ||
| 150 | |||
| 151 | static void hashbn(SHA_CTX *sha, const BIGNUM *bn) | ||
| 152 | { | ||
| 153 | size_t l = BN_num_bytes(bn); | ||
| 154 | unsigned char *bin = OPENSSL_malloc(l); | ||
| 155 | |||
| 156 | hashlength(sha, l); | ||
| 157 | BN_bn2bin(bn, bin); | ||
| 158 | SHA1_Update(sha, bin, l); | ||
| 159 | OPENSSL_free(bin); | ||
| 160 | } | ||
| 161 | |||
| 162 | /* h=hash(g, g^r, g^x, name) */ | ||
| 163 | static void zkp_hash(BIGNUM *h, const BIGNUM *zkpg, const JPAKE_STEP_PART *p, | ||
| 164 | const char *proof_name) | ||
| 165 | { | ||
| 166 | unsigned char md[SHA_DIGEST_LENGTH]; | ||
| 167 | SHA_CTX sha; | ||
| 168 | |||
| 169 | /* | ||
| 170 | * XXX: hash should not allow moving of the boundaries - Java code | ||
| 171 | * is flawed in this respect. Length encoding seems simplest. | ||
| 172 | */ | ||
| 173 | SHA1_Init(&sha); | ||
| 174 | hashbn(&sha, zkpg); | ||
| 175 | assert(!BN_is_zero(p->zkpx.gr)); | ||
| 176 | hashbn(&sha, p->zkpx.gr); | ||
| 177 | hashbn(&sha, p->gx); | ||
| 178 | hashstring(&sha, proof_name); | ||
| 179 | SHA1_Final(md, &sha); | ||
| 180 | BN_bin2bn(md, SHA_DIGEST_LENGTH, h); | ||
| 181 | } | ||
| 182 | |||
| 183 | /* | ||
| 184 | * Prove knowledge of x | ||
| 185 | * Note that p->gx has already been calculated | ||
| 186 | */ | ||
| 187 | static void generate_zkp(JPAKE_STEP_PART *p, const BIGNUM *x, | ||
| 188 | const BIGNUM *zkpg, JPAKE_CTX *ctx) | ||
| 189 | { | ||
| 190 | BIGNUM *r = BN_new(); | ||
| 191 | BIGNUM *h = BN_new(); | ||
| 192 | BIGNUM *t = BN_new(); | ||
| 193 | |||
| 194 | /* | ||
| 195 | * r in [0,q) | ||
| 196 | * XXX: Java chooses r in [0, 2^160) - i.e. distribution not uniform | ||
| 197 | */ | ||
| 198 | BN_rand_range(r, ctx->p.q); | ||
| 199 | /* g^r */ | ||
| 200 | BN_mod_exp(p->zkpx.gr, zkpg, r, ctx->p.p, ctx->ctx); | ||
| 201 | |||
| 202 | /* h=hash... */ | ||
| 203 | zkp_hash(h, zkpg, p, ctx->p.name); | ||
| 204 | |||
| 205 | /* b = r - x*h */ | ||
| 206 | BN_mod_mul(t, x, h, ctx->p.q, ctx->ctx); | ||
| 207 | BN_mod_sub(p->zkpx.b, r, t, ctx->p.q, ctx->ctx); | ||
| 208 | |||
| 209 | /* cleanup */ | ||
| 210 | BN_free(t); | ||
| 211 | BN_free(h); | ||
| 212 | BN_free(r); | ||
| 213 | } | ||
| 214 | |||
| 215 | static int verify_zkp(const JPAKE_STEP_PART *p, const BIGNUM *zkpg, | ||
| 216 | JPAKE_CTX *ctx) | ||
| 217 | { | ||
| 218 | BIGNUM *h = BN_new(); | ||
| 219 | BIGNUM *t1 = BN_new(); | ||
| 220 | BIGNUM *t2 = BN_new(); | ||
| 221 | BIGNUM *t3 = BN_new(); | ||
| 222 | int ret = 0; | ||
| 223 | |||
| 224 | zkp_hash(h, zkpg, p, ctx->p.peer_name); | ||
| 225 | |||
| 226 | /* t1 = g^b */ | ||
| 227 | BN_mod_exp(t1, zkpg, p->zkpx.b, ctx->p.p, ctx->ctx); | ||
| 228 | /* t2 = (g^x)^h = g^{hx} */ | ||
| 229 | BN_mod_exp(t2, p->gx, h, ctx->p.p, ctx->ctx); | ||
| 230 | /* t3 = t1 * t2 = g^{hx} * g^b = g^{hx+b} = g^r (allegedly) */ | ||
| 231 | BN_mod_mul(t3, t1, t2, ctx->p.p, ctx->ctx); | ||
| 232 | |||
| 233 | /* verify t3 == g^r */ | ||
| 234 | if(BN_cmp(t3, p->zkpx.gr) == 0) | ||
| 235 | ret = 1; | ||
| 236 | else | ||
| 237 | JPAKEerr(JPAKE_F_VERIFY_ZKP, JPAKE_R_ZKP_VERIFY_FAILED); | ||
| 238 | |||
| 239 | /* cleanup */ | ||
| 240 | BN_free(t3); | ||
| 241 | BN_free(t2); | ||
| 242 | BN_free(t1); | ||
| 243 | BN_free(h); | ||
| 244 | |||
| 245 | return ret; | ||
| 246 | } | ||
| 247 | |||
| 248 | static void generate_step_part(JPAKE_STEP_PART *p, const BIGNUM *x, | ||
| 249 | const BIGNUM *g, JPAKE_CTX *ctx) | ||
| 250 | { | ||
| 251 | BN_mod_exp(p->gx, g, x, ctx->p.p, ctx->ctx); | ||
| 252 | generate_zkp(p, x, g, ctx); | ||
| 253 | } | ||
| 254 | |||
| 255 | /* Generate each party's random numbers. xa is in [0, q), xb is in [1, q). */ | ||
| 256 | static void genrand(JPAKE_CTX *ctx) | ||
| 257 | { | ||
| 258 | BIGNUM *qm1; | ||
| 259 | |||
| 260 | /* xa in [0, q) */ | ||
| 261 | BN_rand_range(ctx->xa, ctx->p.q); | ||
| 262 | |||
| 263 | /* q-1 */ | ||
| 264 | qm1 = BN_new(); | ||
| 265 | BN_copy(qm1, ctx->p.q); | ||
| 266 | BN_sub_word(qm1, 1); | ||
| 267 | |||
| 268 | /* ... and xb in [0, q-1) */ | ||
| 269 | BN_rand_range(ctx->xb, qm1); | ||
| 270 | /* [1, q) */ | ||
| 271 | BN_add_word(ctx->xb, 1); | ||
| 272 | |||
| 273 | /* cleanup */ | ||
| 274 | BN_free(qm1); | ||
| 275 | } | ||
| 276 | |||
| 277 | int JPAKE_STEP1_generate(JPAKE_STEP1 *send, JPAKE_CTX *ctx) | ||
| 278 | { | ||
| 279 | genrand(ctx); | ||
| 280 | generate_step_part(&send->p1, ctx->xa, ctx->p.g, ctx); | ||
| 281 | generate_step_part(&send->p2, ctx->xb, ctx->p.g, ctx); | ||
| 282 | |||
| 283 | return 1; | ||
| 284 | } | ||
| 285 | |||
| 286 | int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received) | ||
| 287 | { | ||
| 288 | /* verify their ZKP(xc) */ | ||
| 289 | if(!verify_zkp(&received->p1, ctx->p.g, ctx)) | ||
| 290 | { | ||
| 291 | JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_VERIFY_X3_FAILED); | ||
| 292 | return 0; | ||
| 293 | } | ||
| 294 | |||
| 295 | /* verify their ZKP(xd) */ | ||
| 296 | if(!verify_zkp(&received->p2, ctx->p.g, ctx)) | ||
| 297 | { | ||
| 298 | JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_VERIFY_X4_FAILED); | ||
| 299 | return 0; | ||
| 300 | } | ||
| 301 | |||
| 302 | /* g^xd != 1 */ | ||
| 303 | if(BN_is_one(received->p2.gx)) | ||
| 304 | { | ||
| 305 | JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_G_TO_THE_X4_IS_ONE); | ||
| 306 | return 0; | ||
| 307 | } | ||
| 308 | |||
| 309 | /* Save the bits we need for later */ | ||
| 310 | BN_copy(ctx->p.gxc, received->p1.gx); | ||
| 311 | BN_copy(ctx->p.gxd, received->p2.gx); | ||
| 312 | |||
| 313 | return 1; | ||
| 314 | } | ||
| 315 | |||
| 316 | |||
| 317 | int JPAKE_STEP2_generate(JPAKE_STEP2 *send, JPAKE_CTX *ctx) | ||
| 318 | { | ||
| 319 | BIGNUM *t1 = BN_new(); | ||
| 320 | BIGNUM *t2 = BN_new(); | ||
| 321 | |||
| 322 | /* | ||
| 323 | * X = g^{(xa + xc + xd) * xb * s} | ||
| 324 | * t1 = g^xa | ||
| 325 | */ | ||
| 326 | BN_mod_exp(t1, ctx->p.g, ctx->xa, ctx->p.p, ctx->ctx); | ||
| 327 | /* t2 = t1 * g^{xc} = g^{xa} * g^{xc} = g^{xa + xc} */ | ||
| 328 | BN_mod_mul(t2, t1, ctx->p.gxc, ctx->p.p, ctx->ctx); | ||
| 329 | /* t1 = t2 * g^{xd} = g^{xa + xc + xd} */ | ||
| 330 | BN_mod_mul(t1, t2, ctx->p.gxd, ctx->p.p, ctx->ctx); | ||
| 331 | /* t2 = xb * s */ | ||
| 332 | BN_mod_mul(t2, ctx->xb, ctx->secret, ctx->p.q, ctx->ctx); | ||
| 333 | |||
| 334 | /* | ||
| 335 | * ZKP(xb * s) | ||
| 336 | * XXX: this is kinda funky, because we're using | ||
| 337 | * | ||
| 338 | * g' = g^{xa + xc + xd} | ||
| 339 | * | ||
| 340 | * as the generator, which means X is g'^{xb * s} | ||
| 341 | * X = t1^{t2} = t1^{xb * s} = g^{(xa + xc + xd) * xb * s} | ||
| 342 | */ | ||
| 343 | generate_step_part(send, t2, t1, ctx); | ||
| 344 | |||
| 345 | /* cleanup */ | ||
| 346 | BN_free(t1); | ||
| 347 | BN_free(t2); | ||
| 348 | |||
| 349 | return 1; | ||
| 350 | } | ||
| 351 | |||
| 352 | /* gx = g^{xc + xa + xb} * xd * s */ | ||
| 353 | static int compute_key(JPAKE_CTX *ctx, const BIGNUM *gx) | ||
| 354 | { | ||
| 355 | BIGNUM *t1 = BN_new(); | ||
| 356 | BIGNUM *t2 = BN_new(); | ||
| 357 | BIGNUM *t3 = BN_new(); | ||
| 358 | |||
| 359 | /* | ||
| 360 | * K = (gx/g^{xb * xd * s})^{xb} | ||
| 361 | * = (g^{(xc + xa + xb) * xd * s - xb * xd *s})^{xb} | ||
| 362 | * = (g^{(xa + xc) * xd * s})^{xb} | ||
| 363 | * = g^{(xa + xc) * xb * xd * s} | ||
| 364 | * [which is the same regardless of who calculates it] | ||
| 365 | */ | ||
| 366 | |||
| 367 | /* t1 = (g^{xd})^{xb} = g^{xb * xd} */ | ||
| 368 | BN_mod_exp(t1, ctx->p.gxd, ctx->xb, ctx->p.p, ctx->ctx); | ||
| 369 | /* t2 = -s = q-s */ | ||
| 370 | BN_sub(t2, ctx->p.q, ctx->secret); | ||
| 371 | /* t3 = t1^t2 = g^{-xb * xd * s} */ | ||
| 372 | BN_mod_exp(t3, t1, t2, ctx->p.p, ctx->ctx); | ||
| 373 | /* t1 = gx * t3 = X/g^{xb * xd * s} */ | ||
| 374 | BN_mod_mul(t1, gx, t3, ctx->p.p, ctx->ctx); | ||
| 375 | /* K = t1^{xb} */ | ||
| 376 | BN_mod_exp(ctx->key, t1, ctx->xb, ctx->p.p, ctx->ctx); | ||
| 377 | |||
| 378 | /* cleanup */ | ||
| 379 | BN_free(t3); | ||
| 380 | BN_free(t2); | ||
| 381 | BN_free(t1); | ||
| 382 | |||
| 383 | return 1; | ||
| 384 | } | ||
| 385 | |||
| 386 | int JPAKE_STEP2_process(JPAKE_CTX *ctx, const JPAKE_STEP2 *received) | ||
| 387 | { | ||
| 388 | BIGNUM *t1 = BN_new(); | ||
| 389 | BIGNUM *t2 = BN_new(); | ||
| 390 | int ret = 0; | ||
| 391 | |||
| 392 | /* | ||
| 393 | * g' = g^{xc + xa + xb} [from our POV] | ||
| 394 | * t1 = xa + xb | ||
| 395 | */ | ||
| 396 | BN_mod_add(t1, ctx->xa, ctx->xb, ctx->p.q, ctx->ctx); | ||
| 397 | /* t2 = g^{t1} = g^{xa+xb} */ | ||
| 398 | BN_mod_exp(t2, ctx->p.g, t1, ctx->p.p, ctx->ctx); | ||
| 399 | /* t1 = g^{xc} * t2 = g^{xc + xa + xb} */ | ||
| 400 | BN_mod_mul(t1, ctx->p.gxc, t2, ctx->p.p, ctx->ctx); | ||
| 401 | |||
| 402 | if(verify_zkp(received, t1, ctx)) | ||
| 403 | ret = 1; | ||
| 404 | else | ||
| 405 | JPAKEerr(JPAKE_F_JPAKE_STEP2_PROCESS, JPAKE_R_VERIFY_B_FAILED); | ||
| 406 | |||
| 407 | compute_key(ctx, received->gx); | ||
| 408 | |||
| 409 | /* cleanup */ | ||
| 410 | BN_free(t2); | ||
| 411 | BN_free(t1); | ||
| 412 | |||
| 413 | return ret; | ||
| 414 | } | ||
| 415 | |||
| 416 | static void quickhashbn(unsigned char *md, const BIGNUM *bn) | ||
| 417 | { | ||
| 418 | SHA_CTX sha; | ||
| 419 | |||
| 420 | SHA1_Init(&sha); | ||
| 421 | hashbn(&sha, bn); | ||
| 422 | SHA1_Final(md, &sha); | ||
| 423 | } | ||
| 424 | |||
| 425 | void JPAKE_STEP3A_init(JPAKE_STEP3A *s3a) | ||
| 426 | {} | ||
| 427 | |||
| 428 | int JPAKE_STEP3A_generate(JPAKE_STEP3A *send, JPAKE_CTX *ctx) | ||
| 429 | { | ||
| 430 | quickhashbn(send->hhk, ctx->key); | ||
| 431 | SHA1(send->hhk, sizeof send->hhk, send->hhk); | ||
| 432 | |||
| 433 | return 1; | ||
| 434 | } | ||
| 435 | |||
| 436 | int JPAKE_STEP3A_process(JPAKE_CTX *ctx, const JPAKE_STEP3A *received) | ||
| 437 | { | ||
| 438 | unsigned char hhk[SHA_DIGEST_LENGTH]; | ||
| 439 | |||
| 440 | quickhashbn(hhk, ctx->key); | ||
| 441 | SHA1(hhk, sizeof hhk, hhk); | ||
| 442 | if(memcmp(hhk, received->hhk, sizeof hhk)) | ||
| 443 | { | ||
| 444 | JPAKEerr(JPAKE_F_JPAKE_STEP3A_PROCESS, JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH); | ||
| 445 | return 0; | ||
| 446 | } | ||
| 447 | return 1; | ||
| 448 | } | ||
| 449 | |||
| 450 | void JPAKE_STEP3A_release(JPAKE_STEP3A *s3a) | ||
| 451 | {} | ||
| 452 | |||
| 453 | void JPAKE_STEP3B_init(JPAKE_STEP3B *s3b) | ||
| 454 | {} | ||
| 455 | |||
| 456 | int JPAKE_STEP3B_generate(JPAKE_STEP3B *send, JPAKE_CTX *ctx) | ||
| 457 | { | ||
| 458 | quickhashbn(send->hk, ctx->key); | ||
| 459 | |||
| 460 | return 1; | ||
| 461 | } | ||
| 462 | |||
| 463 | int JPAKE_STEP3B_process(JPAKE_CTX *ctx, const JPAKE_STEP3B *received) | ||
| 464 | { | ||
| 465 | unsigned char hk[SHA_DIGEST_LENGTH]; | ||
| 466 | |||
| 467 | quickhashbn(hk, ctx->key); | ||
| 468 | if(memcmp(hk, received->hk, sizeof hk)) | ||
| 469 | { | ||
| 470 | JPAKEerr(JPAKE_F_JPAKE_STEP3B_PROCESS, JPAKE_R_HASH_OF_KEY_MISMATCH); | ||
| 471 | return 0; | ||
| 472 | } | ||
| 473 | return 1; | ||
| 474 | } | ||
| 475 | |||
| 476 | void JPAKE_STEP3B_release(JPAKE_STEP3B *s3b) | ||
| 477 | {} | ||
| 478 | |||
| 479 | const BIGNUM *JPAKE_get_shared_key(JPAKE_CTX *ctx) | ||
| 480 | { | ||
| 481 | return ctx->key; | ||
| 482 | } | ||
| 483 | |||
diff --git a/src/lib/libssl/src/crypto/jpake/jpake.h b/src/lib/libssl/src/crypto/jpake/jpake.h new file mode 100644 index 0000000000..693ea188cb --- /dev/null +++ b/src/lib/libssl/src/crypto/jpake/jpake.h | |||
| @@ -0,0 +1,129 @@ | |||
| 1 | /* | ||
| 2 | * Implement J-PAKE, as described in | ||
| 3 | * http://grouper.ieee.org/groups/1363/Research/contributions/hao-ryan-2008.pdf | ||
| 4 | * | ||
| 5 | * With hints from http://www.cl.cam.ac.uk/~fh240/software/JPAKE2.java. | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef HEADER_JPAKE_H | ||
| 9 | #define HEADER_JPAKE_H | ||
| 10 | |||
| 11 | #include <openssl/opensslconf.h> | ||
| 12 | |||
| 13 | #ifdef OPENSSL_NO_JPAKE | ||
| 14 | #error JPAKE is disabled. | ||
| 15 | #endif | ||
| 16 | |||
| 17 | #ifdef __cplusplus | ||
| 18 | extern "C" { | ||
| 19 | #endif | ||
| 20 | |||
| 21 | #include <openssl/bn.h> | ||
| 22 | #include <openssl/sha.h> | ||
| 23 | |||
| 24 | typedef struct JPAKE_CTX JPAKE_CTX; | ||
| 25 | |||
| 26 | /* Note that "g" in the ZKPs is not necessarily the J-PAKE g. */ | ||
| 27 | typedef struct | ||
| 28 | { | ||
| 29 | BIGNUM *gr; /* g^r (r random) */ | ||
| 30 | BIGNUM *b; /* b = r - x*h, h=hash(g, g^r, g^x, name) */ | ||
| 31 | } JPAKE_ZKP; | ||
| 32 | |||
| 33 | typedef struct | ||
| 34 | { | ||
| 35 | BIGNUM *gx; /* g^x in step 1, g^(xa + xc + xd) * xb * s in step 2 */ | ||
| 36 | JPAKE_ZKP zkpx; /* ZKP(x) or ZKP(xb * s) */ | ||
| 37 | } JPAKE_STEP_PART; | ||
| 38 | |||
| 39 | typedef struct | ||
| 40 | { | ||
| 41 | JPAKE_STEP_PART p1; /* g^x3, ZKP(x3) or g^x1, ZKP(x1) */ | ||
| 42 | JPAKE_STEP_PART p2; /* g^x4, ZKP(x4) or g^x2, ZKP(x2) */ | ||
| 43 | } JPAKE_STEP1; | ||
| 44 | |||
| 45 | typedef JPAKE_STEP_PART JPAKE_STEP2; | ||
| 46 | |||
| 47 | typedef struct | ||
| 48 | { | ||
| 49 | unsigned char hhk[SHA_DIGEST_LENGTH]; | ||
| 50 | } JPAKE_STEP3A; | ||
| 51 | |||
| 52 | typedef struct | ||
| 53 | { | ||
| 54 | unsigned char hk[SHA_DIGEST_LENGTH]; | ||
| 55 | } JPAKE_STEP3B; | ||
| 56 | |||
| 57 | /* Parameters are copied */ | ||
| 58 | JPAKE_CTX *JPAKE_CTX_new(const char *name, const char *peer_name, | ||
| 59 | const BIGNUM *p, const BIGNUM *g, const BIGNUM *q, | ||
| 60 | const BIGNUM *secret); | ||
| 61 | void JPAKE_CTX_free(JPAKE_CTX *ctx); | ||
| 62 | |||
| 63 | /* | ||
| 64 | * Note that JPAKE_STEP1 can be used multiple times before release | ||
| 65 | * without another init. | ||
| 66 | */ | ||
| 67 | void JPAKE_STEP1_init(JPAKE_STEP1 *s1); | ||
| 68 | int JPAKE_STEP1_generate(JPAKE_STEP1 *send, JPAKE_CTX *ctx); | ||
| 69 | int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received); | ||
| 70 | void JPAKE_STEP1_release(JPAKE_STEP1 *s1); | ||
| 71 | |||
| 72 | /* | ||
| 73 | * Note that JPAKE_STEP2 can be used multiple times before release | ||
| 74 | * without another init. | ||
| 75 | */ | ||
| 76 | void JPAKE_STEP2_init(JPAKE_STEP2 *s2); | ||
| 77 | int JPAKE_STEP2_generate(JPAKE_STEP2 *send, JPAKE_CTX *ctx); | ||
| 78 | int JPAKE_STEP2_process(JPAKE_CTX *ctx, const JPAKE_STEP2 *received); | ||
| 79 | void JPAKE_STEP2_release(JPAKE_STEP2 *s2); | ||
| 80 | |||
| 81 | /* | ||
| 82 | * Optionally verify the shared key. If the shared secrets do not | ||
| 83 | * match, the two ends will disagree about the shared key, but | ||
| 84 | * otherwise the protocol will succeed. | ||
| 85 | */ | ||
| 86 | void JPAKE_STEP3A_init(JPAKE_STEP3A *s3a); | ||
| 87 | int JPAKE_STEP3A_generate(JPAKE_STEP3A *send, JPAKE_CTX *ctx); | ||
| 88 | int JPAKE_STEP3A_process(JPAKE_CTX *ctx, const JPAKE_STEP3A *received); | ||
| 89 | void JPAKE_STEP3A_release(JPAKE_STEP3A *s3a); | ||
| 90 | |||
| 91 | void JPAKE_STEP3B_init(JPAKE_STEP3B *s3b); | ||
| 92 | int JPAKE_STEP3B_generate(JPAKE_STEP3B *send, JPAKE_CTX *ctx); | ||
| 93 | int JPAKE_STEP3B_process(JPAKE_CTX *ctx, const JPAKE_STEP3B *received); | ||
| 94 | void JPAKE_STEP3B_release(JPAKE_STEP3B *s3b); | ||
| 95 | |||
| 96 | /* | ||
| 97 | * the return value belongs to the library and will be released when | ||
| 98 | * ctx is released, and will change when a new handshake is performed. | ||
| 99 | */ | ||
| 100 | const BIGNUM *JPAKE_get_shared_key(JPAKE_CTX *ctx); | ||
| 101 | |||
| 102 | /* BEGIN ERROR CODES */ | ||
| 103 | /* The following lines are auto generated by the script mkerr.pl. Any changes | ||
| 104 | * made after this point may be overwritten when the script is next run. | ||
| 105 | */ | ||
| 106 | void ERR_load_JPAKE_strings(void); | ||
| 107 | |||
| 108 | /* Error codes for the JPAKE functions. */ | ||
| 109 | |||
| 110 | /* Function codes. */ | ||
| 111 | #define JPAKE_F_JPAKE_STEP1_PROCESS 101 | ||
| 112 | #define JPAKE_F_JPAKE_STEP2_PROCESS 102 | ||
| 113 | #define JPAKE_F_JPAKE_STEP3A_PROCESS 103 | ||
| 114 | #define JPAKE_F_JPAKE_STEP3B_PROCESS 104 | ||
| 115 | #define JPAKE_F_VERIFY_ZKP 100 | ||
| 116 | |||
| 117 | /* Reason codes. */ | ||
| 118 | #define JPAKE_R_G_TO_THE_X4_IS_ONE 105 | ||
| 119 | #define JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH 106 | ||
| 120 | #define JPAKE_R_HASH_OF_KEY_MISMATCH 107 | ||
| 121 | #define JPAKE_R_VERIFY_B_FAILED 102 | ||
| 122 | #define JPAKE_R_VERIFY_X3_FAILED 103 | ||
| 123 | #define JPAKE_R_VERIFY_X4_FAILED 104 | ||
| 124 | #define JPAKE_R_ZKP_VERIFY_FAILED 100 | ||
| 125 | |||
| 126 | #ifdef __cplusplus | ||
| 127 | } | ||
| 128 | #endif | ||
| 129 | #endif | ||
diff --git a/src/lib/libssl/src/crypto/jpake/jpake_err.c b/src/lib/libssl/src/crypto/jpake/jpake_err.c new file mode 100644 index 0000000000..1b95067967 --- /dev/null +++ b/src/lib/libssl/src/crypto/jpake/jpake_err.c | |||
| @@ -0,0 +1,105 @@ | |||
| 1 | /* crypto/jpake/jpake_err.c */ | ||
| 2 | /* ==================================================================== | ||
| 3 | * Copyright (c) 1999-2008 The OpenSSL Project. All rights reserved. | ||
| 4 | * | ||
| 5 | * Redistribution and use in source and binary forms, with or without | ||
| 6 | * modification, are permitted provided that the following conditions | ||
| 7 | * are met: | ||
| 8 | * | ||
| 9 | * 1. Redistributions of source code must retain the above copyright | ||
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * | ||
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer in | ||
| 14 | * the documentation and/or other materials provided with the | ||
| 15 | * distribution. | ||
| 16 | * | ||
| 17 | * 3. All advertising materials mentioning features or use of this | ||
| 18 | * software must display the following acknowledgment: | ||
| 19 | * "This product includes software developed by the OpenSSL Project | ||
| 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 21 | * | ||
| 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 23 | * endorse or promote products derived from this software without | ||
| 24 | * prior written permission. For written permission, please contact | ||
| 25 | * openssl-core@OpenSSL.org. | ||
| 26 | * | ||
| 27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 28 | * nor may "OpenSSL" appear in their names without prior written | ||
| 29 | * permission of the OpenSSL Project. | ||
| 30 | * | ||
| 31 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 32 | * acknowledgment: | ||
| 33 | * "This product includes software developed by the OpenSSL Project | ||
| 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 35 | * | ||
| 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 54 | */ | ||
| 55 | |||
| 56 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes | ||
| 57 | * made to it will be overwritten when the script next updates this file, | ||
| 58 | * only reason strings will be preserved. | ||
| 59 | */ | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include <openssl/err.h> | ||
| 63 | #include <openssl/jpake.h> | ||
| 64 | |||
| 65 | /* BEGIN ERROR CODES */ | ||
| 66 | #ifndef OPENSSL_NO_ERR | ||
| 67 | |||
| 68 | #define ERR_FUNC(func) ERR_PACK(ERR_LIB_JPAKE,func,0) | ||
| 69 | #define ERR_REASON(reason) ERR_PACK(ERR_LIB_JPAKE,0,reason) | ||
| 70 | |||
| 71 | static ERR_STRING_DATA JPAKE_str_functs[]= | ||
| 72 | { | ||
| 73 | {ERR_FUNC(JPAKE_F_JPAKE_STEP1_PROCESS), "JPAKE_STEP1_process"}, | ||
| 74 | {ERR_FUNC(JPAKE_F_JPAKE_STEP2_PROCESS), "JPAKE_STEP2_process"}, | ||
| 75 | {ERR_FUNC(JPAKE_F_JPAKE_STEP3A_PROCESS), "JPAKE_STEP3A_process"}, | ||
| 76 | {ERR_FUNC(JPAKE_F_JPAKE_STEP3B_PROCESS), "JPAKE_STEP3B_process"}, | ||
| 77 | {ERR_FUNC(JPAKE_F_VERIFY_ZKP), "VERIFY_ZKP"}, | ||
| 78 | {0,NULL} | ||
| 79 | }; | ||
| 80 | |||
| 81 | static ERR_STRING_DATA JPAKE_str_reasons[]= | ||
| 82 | { | ||
| 83 | {ERR_REASON(JPAKE_R_G_TO_THE_X4_IS_ONE) ,"g to the x4 is one"}, | ||
| 84 | {ERR_REASON(JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH),"hash of hash of key mismatch"}, | ||
| 85 | {ERR_REASON(JPAKE_R_HASH_OF_KEY_MISMATCH),"hash of key mismatch"}, | ||
| 86 | {ERR_REASON(JPAKE_R_VERIFY_B_FAILED) ,"verify b failed"}, | ||
| 87 | {ERR_REASON(JPAKE_R_VERIFY_X3_FAILED) ,"verify x3 failed"}, | ||
| 88 | {ERR_REASON(JPAKE_R_VERIFY_X4_FAILED) ,"verify x4 failed"}, | ||
| 89 | {ERR_REASON(JPAKE_R_ZKP_VERIFY_FAILED) ,"zkp verify failed"}, | ||
| 90 | {0,NULL} | ||
| 91 | }; | ||
| 92 | |||
| 93 | #endif | ||
| 94 | |||
| 95 | void ERR_load_JPAKE_strings(void) | ||
| 96 | { | ||
| 97 | #ifndef OPENSSL_NO_ERR | ||
| 98 | |||
| 99 | if (ERR_func_error_string(JPAKE_str_functs[0].error) == NULL) | ||
| 100 | { | ||
| 101 | ERR_load_strings(0,JPAKE_str_functs); | ||
| 102 | ERR_load_strings(0,JPAKE_str_reasons); | ||
| 103 | } | ||
| 104 | #endif | ||
| 105 | } | ||
diff --git a/src/lib/libssl/src/crypto/jpake/jpaketest.c b/src/lib/libssl/src/crypto/jpake/jpaketest.c new file mode 100644 index 0000000000..792fc49eb4 --- /dev/null +++ b/src/lib/libssl/src/crypto/jpake/jpaketest.c | |||
| @@ -0,0 +1,192 @@ | |||
| 1 | #include <openssl/opensslconf.h> | ||
| 2 | |||
| 3 | #ifdef OPENSSL_NO_JPAKE | ||
| 4 | |||
| 5 | #include <stdio.h> | ||
| 6 | |||
| 7 | int main(int argc, char *argv[]) | ||
| 8 | { | ||
| 9 | printf("No J-PAKE support\n"); | ||
| 10 | return(0); | ||
| 11 | } | ||
| 12 | |||
| 13 | #else | ||
| 14 | |||
| 15 | #include <openssl/jpake.h> | ||
| 16 | #include <openssl/err.h> | ||
| 17 | |||
| 18 | static void showbn(const char *name, const BIGNUM *bn) | ||
| 19 | { | ||
| 20 | fputs(name, stdout); | ||
| 21 | fputs(" = ", stdout); | ||
| 22 | BN_print_fp(stdout, bn); | ||
| 23 | putc('\n', stdout); | ||
| 24 | } | ||
| 25 | |||
| 26 | static int run_jpake(JPAKE_CTX *alice, JPAKE_CTX *bob) | ||
| 27 | { | ||
| 28 | JPAKE_STEP1 alice_s1; | ||
| 29 | JPAKE_STEP1 bob_s1; | ||
| 30 | JPAKE_STEP2 alice_s2; | ||
| 31 | JPAKE_STEP2 bob_s2; | ||
| 32 | JPAKE_STEP3A alice_s3a; | ||
| 33 | JPAKE_STEP3B bob_s3b; | ||
| 34 | |||
| 35 | /* Alice -> Bob: step 1 */ | ||
| 36 | puts("A->B s1"); | ||
| 37 | JPAKE_STEP1_init(&alice_s1); | ||
| 38 | JPAKE_STEP1_generate(&alice_s1, alice); | ||
| 39 | if(!JPAKE_STEP1_process(bob, &alice_s1)) | ||
| 40 | { | ||
| 41 | printf("Bob fails to process Alice's step 1\n"); | ||
| 42 | ERR_print_errors_fp(stdout); | ||
| 43 | return 1; | ||
| 44 | } | ||
| 45 | JPAKE_STEP1_release(&alice_s1); | ||
| 46 | |||
| 47 | /* Bob -> Alice: step 1 */ | ||
| 48 | puts("B->A s1"); | ||
| 49 | JPAKE_STEP1_init(&bob_s1); | ||
| 50 | JPAKE_STEP1_generate(&bob_s1, bob); | ||
| 51 | if(!JPAKE_STEP1_process(alice, &bob_s1)) | ||
| 52 | { | ||
| 53 | printf("Alice fails to process Bob's step 1\n"); | ||
| 54 | ERR_print_errors_fp(stdout); | ||
| 55 | return 2; | ||
| 56 | } | ||
| 57 | JPAKE_STEP1_release(&bob_s1); | ||
| 58 | |||
| 59 | /* Alice -> Bob: step 2 */ | ||
| 60 | puts("A->B s2"); | ||
| 61 | JPAKE_STEP2_init(&alice_s2); | ||
| 62 | JPAKE_STEP2_generate(&alice_s2, alice); | ||
| 63 | if(!JPAKE_STEP2_process(bob, &alice_s2)) | ||
| 64 | { | ||
| 65 | printf("Bob fails to process Alice's step 2\n"); | ||
| 66 | ERR_print_errors_fp(stdout); | ||
| 67 | return 3; | ||
| 68 | } | ||
| 69 | JPAKE_STEP2_release(&alice_s2); | ||
| 70 | |||
| 71 | /* Bob -> Alice: step 2 */ | ||
| 72 | puts("B->A s2"); | ||
| 73 | JPAKE_STEP2_init(&bob_s2); | ||
| 74 | JPAKE_STEP2_generate(&bob_s2, bob); | ||
| 75 | if(!JPAKE_STEP2_process(alice, &bob_s2)) | ||
| 76 | { | ||
| 77 | printf("Alice fails to process Bob's step 2\n"); | ||
| 78 | ERR_print_errors_fp(stdout); | ||
| 79 | return 4; | ||
| 80 | } | ||
| 81 | JPAKE_STEP2_release(&bob_s2); | ||
| 82 | |||
| 83 | showbn("Alice's key", JPAKE_get_shared_key(alice)); | ||
| 84 | showbn("Bob's key ", JPAKE_get_shared_key(bob)); | ||
| 85 | |||
| 86 | /* Alice -> Bob: step 3a */ | ||
| 87 | puts("A->B s3a"); | ||
| 88 | JPAKE_STEP3A_init(&alice_s3a); | ||
| 89 | JPAKE_STEP3A_generate(&alice_s3a, alice); | ||
| 90 | if(!JPAKE_STEP3A_process(bob, &alice_s3a)) | ||
| 91 | { | ||
| 92 | printf("Bob fails to process Alice's step 3a\n"); | ||
| 93 | ERR_print_errors_fp(stdout); | ||
| 94 | return 5; | ||
| 95 | } | ||
| 96 | JPAKE_STEP3A_release(&alice_s3a); | ||
| 97 | |||
| 98 | /* Bob -> Alice: step 3b */ | ||
| 99 | puts("B->A s3b"); | ||
| 100 | JPAKE_STEP3B_init(&bob_s3b); | ||
| 101 | JPAKE_STEP3B_generate(&bob_s3b, bob); | ||
| 102 | if(!JPAKE_STEP3B_process(alice, &bob_s3b)) | ||
| 103 | { | ||
| 104 | printf("Alice fails to process Bob's step 3b\n"); | ||
| 105 | ERR_print_errors_fp(stdout); | ||
| 106 | return 6; | ||
| 107 | } | ||
| 108 | JPAKE_STEP3B_release(&bob_s3b); | ||
| 109 | |||
| 110 | return 0; | ||
| 111 | } | ||
| 112 | |||
| 113 | int main(int argc, char **argv) | ||
| 114 | { | ||
| 115 | JPAKE_CTX *alice; | ||
| 116 | JPAKE_CTX *bob; | ||
| 117 | BIGNUM *p = NULL; | ||
| 118 | BIGNUM *g = NULL; | ||
| 119 | BIGNUM *q = NULL; | ||
| 120 | BIGNUM *secret = BN_new(); | ||
| 121 | BIO *bio_err; | ||
| 122 | |||
| 123 | bio_err = BIO_new_fp(stderr, BIO_NOCLOSE); | ||
| 124 | |||
| 125 | CRYPTO_malloc_debug_init(); | ||
| 126 | CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL); | ||
| 127 | CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); | ||
| 128 | |||
| 129 | ERR_load_crypto_strings(); | ||
| 130 | |||
| 131 | /* | ||
| 132 | BN_hex2bn(&p, "fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b76b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c7"); | ||
| 133 | BN_hex2bn(&g, "f7e1a085d69b3ddecbbcab5c36b857b97994afbbfa3aea82f9574c0b3d0782675159578ebad4594fe67107108180b449167123e84c281613b7cf09328cc8a6e13c167a8b547c8d28e0a3ae1e2bb3a675916ea37f0bfa213562f1fb627a01243bcca4f1bea8519089a883dfe15ae59f06928b665e807b552564014c3bfecf492a"); | ||
| 134 | BN_hex2bn(&q, "9760508f15230bccb292b982a2eb840bf0581cf5"); | ||
| 135 | */ | ||
| 136 | /* | ||
| 137 | p = BN_new(); | ||
| 138 | BN_generate_prime(p, 1024, 1, NULL, NULL, NULL, NULL); | ||
| 139 | */ | ||
| 140 | /* Use a safe prime for p (that we found earlier) */ | ||
| 141 | BN_hex2bn(&p, "F9E5B365665EA7A05A9C534502780FEE6F1AB5BD4F49947FD036DBD7E905269AF46EF28B0FC07487EE4F5D20FB3C0AF8E700F3A2FA3414970CBED44FEDFF80CE78D800F184BB82435D137AADA2C6C16523247930A63B85661D1FC817A51ACD96168E95898A1F83A79FFB529368AA7833ABD1B0C3AEDDB14D2E1A2F71D99F763F"); | ||
| 142 | showbn("p", p); | ||
| 143 | g = BN_new(); | ||
| 144 | BN_set_word(g, 2); | ||
| 145 | showbn("g", g); | ||
| 146 | q = BN_new(); | ||
| 147 | BN_rshift1(q, p); | ||
| 148 | showbn("q", q); | ||
| 149 | |||
| 150 | BN_rand(secret, 32, -1, 0); | ||
| 151 | |||
| 152 | /* A normal run, expect this to work... */ | ||
| 153 | alice = JPAKE_CTX_new("Alice", "Bob", p, g, q, secret); | ||
| 154 | bob = JPAKE_CTX_new("Bob", "Alice", p, g, q, secret); | ||
| 155 | |||
| 156 | if(run_jpake(alice, bob) != 0) | ||
| 157 | { | ||
| 158 | fprintf(stderr, "Plain JPAKE run failed\n"); | ||
| 159 | return 1; | ||
| 160 | } | ||
| 161 | |||
| 162 | JPAKE_CTX_free(bob); | ||
| 163 | JPAKE_CTX_free(alice); | ||
| 164 | |||
| 165 | /* Now give Alice and Bob different secrets */ | ||
| 166 | alice = JPAKE_CTX_new("Alice", "Bob", p, g, q, secret); | ||
| 167 | BN_add_word(secret, 1); | ||
| 168 | bob = JPAKE_CTX_new("Bob", "Alice", p, g, q, secret); | ||
| 169 | |||
| 170 | if(run_jpake(alice, bob) != 5) | ||
| 171 | { | ||
| 172 | fprintf(stderr, "Mismatched secret JPAKE run failed\n"); | ||
| 173 | return 1; | ||
| 174 | } | ||
| 175 | |||
| 176 | JPAKE_CTX_free(bob); | ||
| 177 | JPAKE_CTX_free(alice); | ||
| 178 | |||
| 179 | BN_free(secret); | ||
| 180 | BN_free(q); | ||
| 181 | BN_free(g); | ||
| 182 | BN_free(p); | ||
| 183 | |||
| 184 | CRYPTO_cleanup_all_ex_data(); | ||
| 185 | ERR_remove_state(0); | ||
| 186 | ERR_free_strings(); | ||
| 187 | CRYPTO_mem_leaks(bio_err); | ||
| 188 | |||
| 189 | return 0; | ||
| 190 | } | ||
| 191 | |||
| 192 | #endif | ||
diff --git a/src/lib/libssl/src/crypto/o_init.c b/src/lib/libssl/src/crypto/o_init.c new file mode 100644 index 0000000000..00ed65a6cf --- /dev/null +++ b/src/lib/libssl/src/crypto/o_init.c | |||
| @@ -0,0 +1,86 @@ | |||
| 1 | /* o_init.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | ||
| 3 | * project. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 2007 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * openssl-core@openssl.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <e_os.h> | ||
| 60 | #include <openssl/err.h> | ||
| 61 | |||
| 62 | /* Perform any essential OpenSSL initialization operations. | ||
| 63 | * Currently only sets FIPS callbacks | ||
| 64 | */ | ||
| 65 | |||
| 66 | void OPENSSL_init(void) | ||
| 67 | { | ||
| 68 | #ifdef OPENSSL_FIPS | ||
| 69 | static int done = 0; | ||
| 70 | if (!done) | ||
| 71 | { | ||
| 72 | int_ERR_lib_init(); | ||
| 73 | #ifdef CRYPTO_MDEBUG | ||
| 74 | CRYPTO_malloc_debug_init(); | ||
| 75 | #endif | ||
| 76 | #ifdef OPENSSL_ENGINE | ||
| 77 | int_EVP_MD_init_engine_callbacks(); | ||
| 78 | int_EVP_CIPHER_init_engine_callbacks(); | ||
| 79 | int_RAND_init_engine_callbacks(); | ||
| 80 | #endif | ||
| 81 | done = 1; | ||
| 82 | } | ||
| 83 | #endif | ||
| 84 | } | ||
| 85 | |||
| 86 | |||
diff --git a/src/lib/libssl/src/crypto/pqueue/Makefile b/src/lib/libssl/src/crypto/pqueue/Makefile index d0c39d25ce..36bfc349aa 100644 --- a/src/lib/libssl/src/crypto/pqueue/Makefile +++ b/src/lib/libssl/src/crypto/pqueue/Makefile | |||
| @@ -33,7 +33,7 @@ top: | |||
| 33 | all: lib | 33 | all: lib |
| 34 | 34 | ||
| 35 | lib: $(LIBOBJ) | 35 | lib: $(LIBOBJ) |
| 36 | $(AR) $(LIB) $(LIBOBJ) | 36 | $(ARX) $(LIB) $(LIBOBJ) |
| 37 | $(RANLIB) $(LIB) || echo Never mind. | 37 | $(RANLIB) $(LIB) || echo Never mind. |
| 38 | @touch lib | 38 | @touch lib |
| 39 | 39 | ||
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 2d47320485..00c6fa28aa 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 | |||
| @@ -359,6 +359,8 @@ ___ | |||
| 359 | 359 | ||
| 360 | $code =~ s/#([bwd])/$1/gm; | 360 | $code =~ s/#([bwd])/$1/gm; |
| 361 | 361 | ||
| 362 | $code =~ s/RC4_set_key/private_RC4_set_key/g if ($ENV{FIPSCANLIB} ne ""); | ||
| 363 | |||
| 362 | print $code; | 364 | print $code; |
| 363 | 365 | ||
| 364 | close STDOUT; | 366 | close STDOUT; |
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_pss.c b/src/lib/libssl/src/crypto/rsa/rsa_pss.c index e19d18c5b9..9b993aca49 100644 --- a/src/lib/libssl/src/crypto/rsa/rsa_pss.c +++ b/src/lib/libssl/src/crypto/rsa/rsa_pss.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* rsa_pss.c */ | 1 | /* rsa_pss.c */ |
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2005. | 3 | * project 2005. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
| @@ -81,7 +81,7 @@ int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash, | |||
| 81 | EVP_MD_CTX ctx; | 81 | EVP_MD_CTX ctx; |
| 82 | unsigned char H_[EVP_MAX_MD_SIZE]; | 82 | unsigned char H_[EVP_MAX_MD_SIZE]; |
| 83 | 83 | ||
| 84 | hLen = EVP_MD_size(Hash); | 84 | hLen = M_EVP_MD_size(Hash); |
| 85 | /* | 85 | /* |
| 86 | * Negative sLen has special meanings: | 86 | * Negative sLen has special meanings: |
| 87 | * -1 sLen == hLen | 87 | * -1 sLen == hLen |
| @@ -176,7 +176,7 @@ int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM, | |||
| 176 | unsigned char *H, *salt = NULL, *p; | 176 | unsigned char *H, *salt = NULL, *p; |
| 177 | EVP_MD_CTX ctx; | 177 | EVP_MD_CTX ctx; |
| 178 | 178 | ||
| 179 | hLen = EVP_MD_size(Hash); | 179 | hLen = M_EVP_MD_size(Hash); |
| 180 | /* | 180 | /* |
| 181 | * Negative sLen has special meanings: | 181 | * Negative sLen has special meanings: |
| 182 | * -1 sLen == hLen | 182 | * -1 sLen == hLen |
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_x931.c b/src/lib/libssl/src/crypto/rsa/rsa_x931.c index e918654176..21548e37ed 100644 --- a/src/lib/libssl/src/crypto/rsa/rsa_x931.c +++ b/src/lib/libssl/src/crypto/rsa/rsa_x931.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* rsa_x931.c */ | 1 | /* rsa_x931.c */ |
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2005. | 3 | * project 2005. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
diff --git a/src/lib/libssl/src/crypto/seed/Makefile b/src/lib/libssl/src/crypto/seed/Makefile index f9de27b288..ffaeb84218 100644 --- a/src/lib/libssl/src/crypto/seed/Makefile +++ b/src/lib/libssl/src/crypto/seed/Makefile | |||
| @@ -34,7 +34,7 @@ top: | |||
| 34 | all: lib | 34 | all: lib |
| 35 | 35 | ||
| 36 | lib: $(LIBOBJ) | 36 | lib: $(LIBOBJ) |
| 37 | $(AR) $(LIB) $(LIBOBJ) | 37 | $(ARX) $(LIB) $(LIBOBJ) |
| 38 | $(RANLIB) $(LIB) || echo Never mind. | 38 | $(RANLIB) $(LIB) || echo Never mind. |
| 39 | @touch lib | 39 | @touch lib |
| 40 | 40 | ||
diff --git a/src/lib/libssl/src/crypto/sha/sha256.c b/src/lib/libssl/src/crypto/sha/sha256.c index 867f90cc97..3256a83e98 100644 --- a/src/lib/libssl/src/crypto/sha/sha256.c +++ b/src/lib/libssl/src/crypto/sha/sha256.c | |||
| @@ -12,12 +12,19 @@ | |||
| 12 | 12 | ||
| 13 | #include <openssl/crypto.h> | 13 | #include <openssl/crypto.h> |
| 14 | #include <openssl/sha.h> | 14 | #include <openssl/sha.h> |
| 15 | #ifdef OPENSSL_FIPS | ||
| 16 | #include <openssl/fips.h> | ||
| 17 | #endif | ||
| 18 | |||
| 15 | #include <openssl/opensslv.h> | 19 | #include <openssl/opensslv.h> |
| 16 | 20 | ||
| 17 | const char SHA256_version[]="SHA-256" OPENSSL_VERSION_PTEXT; | 21 | const char SHA256_version[]="SHA-256" OPENSSL_VERSION_PTEXT; |
| 18 | 22 | ||
| 19 | int SHA224_Init (SHA256_CTX *c) | 23 | int SHA224_Init (SHA256_CTX *c) |
| 20 | { | 24 | { |
| 25 | #ifdef OPENSSL_FIPS | ||
| 26 | FIPS_selftest_check(); | ||
| 27 | #endif | ||
| 21 | c->h[0]=0xc1059ed8UL; c->h[1]=0x367cd507UL; | 28 | c->h[0]=0xc1059ed8UL; c->h[1]=0x367cd507UL; |
| 22 | c->h[2]=0x3070dd17UL; c->h[3]=0xf70e5939UL; | 29 | c->h[2]=0x3070dd17UL; c->h[3]=0xf70e5939UL; |
| 23 | c->h[4]=0xffc00b31UL; c->h[5]=0x68581511UL; | 30 | c->h[4]=0xffc00b31UL; c->h[5]=0x68581511UL; |
| @@ -29,6 +36,9 @@ int SHA224_Init (SHA256_CTX *c) | |||
| 29 | 36 | ||
| 30 | int SHA256_Init (SHA256_CTX *c) | 37 | int SHA256_Init (SHA256_CTX *c) |
| 31 | { | 38 | { |
| 39 | #ifdef OPENSSL_FIPS | ||
| 40 | FIPS_selftest_check(); | ||
| 41 | #endif | ||
| 32 | c->h[0]=0x6a09e667UL; c->h[1]=0xbb67ae85UL; | 42 | c->h[0]=0x6a09e667UL; c->h[1]=0xbb67ae85UL; |
| 33 | c->h[2]=0x3c6ef372UL; c->h[3]=0xa54ff53aUL; | 43 | c->h[2]=0x3c6ef372UL; c->h[3]=0xa54ff53aUL; |
| 34 | c->h[4]=0x510e527fUL; c->h[5]=0x9b05688cUL; | 44 | c->h[4]=0x510e527fUL; c->h[5]=0x9b05688cUL; |
diff --git a/src/lib/libssl/src/crypto/sha/sha512.c b/src/lib/libssl/src/crypto/sha/sha512.c index 987fc07c99..f5ed468b85 100644 --- a/src/lib/libssl/src/crypto/sha/sha512.c +++ b/src/lib/libssl/src/crypto/sha/sha512.c | |||
| @@ -5,6 +5,10 @@ | |||
| 5 | * ==================================================================== | 5 | * ==================================================================== |
| 6 | */ | 6 | */ |
| 7 | #include <openssl/opensslconf.h> | 7 | #include <openssl/opensslconf.h> |
| 8 | #ifdef OPENSSL_FIPS | ||
| 9 | #include <openssl/fips.h> | ||
| 10 | #endif | ||
| 11 | |||
| 8 | #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA512) | 12 | #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA512) |
| 9 | /* | 13 | /* |
| 10 | * IMPLEMENTATION NOTES. | 14 | * IMPLEMENTATION NOTES. |
| @@ -61,6 +65,9 @@ const char SHA512_version[]="SHA-512" OPENSSL_VERSION_PTEXT; | |||
| 61 | 65 | ||
| 62 | int SHA384_Init (SHA512_CTX *c) | 66 | int SHA384_Init (SHA512_CTX *c) |
| 63 | { | 67 | { |
| 68 | #ifdef OPENSSL_FIPS | ||
| 69 | FIPS_selftest_check(); | ||
| 70 | #endif | ||
| 64 | c->h[0]=U64(0xcbbb9d5dc1059ed8); | 71 | c->h[0]=U64(0xcbbb9d5dc1059ed8); |
| 65 | c->h[1]=U64(0x629a292a367cd507); | 72 | c->h[1]=U64(0x629a292a367cd507); |
| 66 | c->h[2]=U64(0x9159015a3070dd17); | 73 | c->h[2]=U64(0x9159015a3070dd17); |
| @@ -76,6 +83,9 @@ int SHA384_Init (SHA512_CTX *c) | |||
| 76 | 83 | ||
| 77 | int SHA512_Init (SHA512_CTX *c) | 84 | int SHA512_Init (SHA512_CTX *c) |
| 78 | { | 85 | { |
| 86 | #ifdef OPENSSL_FIPS | ||
| 87 | FIPS_selftest_check(); | ||
| 88 | #endif | ||
| 79 | c->h[0]=U64(0x6a09e667f3bcc908); | 89 | c->h[0]=U64(0x6a09e667f3bcc908); |
| 80 | c->h[1]=U64(0xbb67ae8584caa73b); | 90 | c->h[1]=U64(0xbb67ae8584caa73b); |
| 81 | c->h[2]=U64(0x3c6ef372fe94f82b); | 91 | c->h[2]=U64(0x3c6ef372fe94f82b); |
| @@ -327,7 +337,7 @@ static const SHA_LONG64 K512[80] = { | |||
| 327 | ((SHA_LONG64)hi)<<32|lo; }) | 337 | ((SHA_LONG64)hi)<<32|lo; }) |
| 328 | # else | 338 | # else |
| 329 | # define PULL64(x) ({ const unsigned int *p=(const unsigned int *)(&(x));\ | 339 | # define PULL64(x) ({ const unsigned int *p=(const unsigned int *)(&(x));\ |
| 330 | unsigned int hi=p[0],lo=p[1]; \ | 340 | unsigned int hi=p[0],lo=p[1]; \ |
| 331 | asm ("bswapl %0; bswapl %1;" \ | 341 | asm ("bswapl %0; bswapl %1;" \ |
| 332 | : "=r"(lo),"=r"(hi) \ | 342 | : "=r"(lo),"=r"(hi) \ |
| 333 | : "0"(lo),"1"(hi)); \ | 343 | : "0"(lo),"1"(hi)); \ |
diff --git a/src/lib/libssl/src/crypto/store/Makefile b/src/lib/libssl/src/crypto/store/Makefile index 0dcfd7857a..c9f5d001a3 100644 --- a/src/lib/libssl/src/crypto/store/Makefile +++ b/src/lib/libssl/src/crypto/store/Makefile | |||
| @@ -35,7 +35,7 @@ top: | |||
| 35 | all: lib | 35 | all: lib |
| 36 | 36 | ||
| 37 | lib: $(LIBOBJ) | 37 | lib: $(LIBOBJ) |
| 38 | $(AR) $(LIB) $(LIBOBJ) | 38 | $(ARX) $(LIB) $(LIBOBJ) |
| 39 | $(RANLIB) $(LIB) || echo Never mind. | 39 | $(RANLIB) $(LIB) || echo Never mind. |
| 40 | @touch lib | 40 | @touch lib |
| 41 | 41 | ||
| @@ -89,14 +89,14 @@ str_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | |||
| 89 | str_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h | 89 | str_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h |
| 90 | str_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h | 90 | str_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h |
| 91 | str_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 91 | str_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
| 92 | str_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | 92 | str_lib.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h |
| 93 | str_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 93 | str_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
| 94 | str_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 94 | str_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
| 95 | str_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h | 95 | str_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h |
| 96 | str_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 96 | str_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h |
| 97 | str_lib.o: ../../include/openssl/store.h ../../include/openssl/symhacks.h | 97 | str_lib.o: ../../include/openssl/stack.h ../../include/openssl/store.h |
| 98 | str_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | 98 | str_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h |
| 99 | str_lib.o: str_lib.c str_locl.h | 99 | str_lib.o: ../../include/openssl/x509_vfy.h str_lib.c str_locl.h |
| 100 | str_mem.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h | 100 | str_mem.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h |
| 101 | str_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | 101 | str_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h |
| 102 | str_mem.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | 102 | str_mem.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h |
diff --git a/src/lib/libssl/src/crypto/x509/x509_vpm.c b/src/lib/libssl/src/crypto/x509/x509_vpm.c index e9db6d62a7..c92e65936f 100644 --- a/src/lib/libssl/src/crypto/x509/x509_vpm.c +++ b/src/lib/libssl/src/crypto/x509/x509_vpm.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* x509_vpm.c */ | 1 | /* x509_vpm.c */ |
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2004. | 3 | * project 2004. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
diff --git a/src/lib/libssl/src/crypto/x509v3/pcy_cache.c b/src/lib/libssl/src/crypto/x509v3/pcy_cache.c index c18beb89f5..1030931b71 100644 --- a/src/lib/libssl/src/crypto/x509v3/pcy_cache.c +++ b/src/lib/libssl/src/crypto/x509v3/pcy_cache.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* pcy_cache.c */ | 1 | /* pcy_cache.c */ |
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2004. | 3 | * project 2004. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
diff --git a/src/lib/libssl/src/crypto/x509v3/pcy_data.c b/src/lib/libssl/src/crypto/x509v3/pcy_data.c index 614d2b4935..fb392b901f 100644 --- a/src/lib/libssl/src/crypto/x509v3/pcy_data.c +++ b/src/lib/libssl/src/crypto/x509v3/pcy_data.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* pcy_data.c */ | 1 | /* pcy_data.c */ |
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2004. | 3 | * project 2004. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
| @@ -87,6 +87,12 @@ X509_POLICY_DATA *policy_data_new(POLICYINFO *policy, ASN1_OBJECT *id, int crit) | |||
| 87 | X509_POLICY_DATA *ret; | 87 | X509_POLICY_DATA *ret; |
| 88 | if (!policy && !id) | 88 | if (!policy && !id) |
| 89 | return NULL; | 89 | return NULL; |
| 90 | if (id) | ||
| 91 | { | ||
| 92 | id = OBJ_dup(id); | ||
| 93 | if (!id) | ||
| 94 | return NULL; | ||
| 95 | } | ||
| 90 | ret = OPENSSL_malloc(sizeof(X509_POLICY_DATA)); | 96 | ret = OPENSSL_malloc(sizeof(X509_POLICY_DATA)); |
| 91 | if (!ret) | 97 | if (!ret) |
| 92 | return NULL; | 98 | return NULL; |
| @@ -94,6 +100,8 @@ X509_POLICY_DATA *policy_data_new(POLICYINFO *policy, ASN1_OBJECT *id, int crit) | |||
| 94 | if (!ret->expected_policy_set) | 100 | if (!ret->expected_policy_set) |
| 95 | { | 101 | { |
| 96 | OPENSSL_free(ret); | 102 | OPENSSL_free(ret); |
| 103 | if (id) | ||
| 104 | ASN1_OBJECT_free(id); | ||
| 97 | return NULL; | 105 | return NULL; |
| 98 | } | 106 | } |
| 99 | 107 | ||
diff --git a/src/lib/libssl/src/crypto/x509v3/pcy_int.h b/src/lib/libssl/src/crypto/x509v3/pcy_int.h index ba62a209da..3780de4fcd 100644 --- a/src/lib/libssl/src/crypto/x509v3/pcy_int.h +++ b/src/lib/libssl/src/crypto/x509v3/pcy_int.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* pcy_int.h */ | 1 | /* pcy_int.h */ |
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2004. | 3 | * project 2004. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
diff --git a/src/lib/libssl/src/crypto/x509v3/pcy_lib.c b/src/lib/libssl/src/crypto/x509v3/pcy_lib.c index dae4840bc5..93bfd92703 100644 --- a/src/lib/libssl/src/crypto/x509v3/pcy_lib.c +++ b/src/lib/libssl/src/crypto/x509v3/pcy_lib.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* pcy_lib.c */ | 1 | /* pcy_lib.c */ |
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2004. | 3 | * project 2004. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
diff --git a/src/lib/libssl/src/crypto/x509v3/pcy_map.c b/src/lib/libssl/src/crypto/x509v3/pcy_map.c index 35221e8ba8..f28796e6d4 100644 --- a/src/lib/libssl/src/crypto/x509v3/pcy_map.c +++ b/src/lib/libssl/src/crypto/x509v3/pcy_map.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* pcy_map.c */ | 1 | /* pcy_map.c */ |
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2004. | 3 | * project 2004. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
diff --git a/src/lib/libssl/src/crypto/x509v3/pcy_node.c b/src/lib/libssl/src/crypto/x509v3/pcy_node.c index dcc1554e29..6587cb05ab 100644 --- a/src/lib/libssl/src/crypto/x509v3/pcy_node.c +++ b/src/lib/libssl/src/crypto/x509v3/pcy_node.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* pcy_node.c */ | 1 | /* pcy_node.c */ |
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2004. | 3 | * project 2004. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
diff --git a/src/lib/libssl/src/crypto/x509v3/pcy_tree.c b/src/lib/libssl/src/crypto/x509v3/pcy_tree.c index 4fda1d419a..6c87a7f506 100644 --- a/src/lib/libssl/src/crypto/x509v3/pcy_tree.c +++ b/src/lib/libssl/src/crypto/x509v3/pcy_tree.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* pcy_tree.c */ | 1 | /* pcy_tree.c */ |
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2004. | 3 | * project 2004. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
| @@ -130,9 +130,9 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs, | |||
| 130 | ret = 2; | 130 | ret = 2; |
| 131 | if (explicit_policy > 0) | 131 | if (explicit_policy > 0) |
| 132 | { | 132 | { |
| 133 | explicit_policy--; | 133 | if (!(x->ex_flags & EXFLAG_SI)) |
| 134 | if (!(x->ex_flags & EXFLAG_SS) | 134 | explicit_policy--; |
| 135 | && (cache->explicit_skip != -1) | 135 | if ((cache->explicit_skip != -1) |
| 136 | && (cache->explicit_skip < explicit_policy)) | 136 | && (cache->explicit_skip < explicit_policy)) |
| 137 | explicit_policy = cache->explicit_skip; | 137 | explicit_policy = cache->explicit_skip; |
| 138 | } | 138 | } |
| @@ -197,13 +197,14 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs, | |||
| 197 | /* Any matching allowed if certificate is self | 197 | /* Any matching allowed if certificate is self |
| 198 | * issued and not the last in the chain. | 198 | * issued and not the last in the chain. |
| 199 | */ | 199 | */ |
| 200 | if (!(x->ex_flags & EXFLAG_SS) || (i == 0)) | 200 | if (!(x->ex_flags & EXFLAG_SI) || (i == 0)) |
| 201 | level->flags |= X509_V_FLAG_INHIBIT_ANY; | 201 | level->flags |= X509_V_FLAG_INHIBIT_ANY; |
| 202 | } | 202 | } |
| 203 | else | 203 | else |
| 204 | { | 204 | { |
| 205 | any_skip--; | 205 | if (!(x->ex_flags & EXFLAG_SI)) |
| 206 | if ((cache->any_skip > 0) | 206 | any_skip--; |
| 207 | if ((cache->any_skip >= 0) | ||
| 207 | && (cache->any_skip < any_skip)) | 208 | && (cache->any_skip < any_skip)) |
| 208 | any_skip = cache->any_skip; | 209 | any_skip = cache->any_skip; |
| 209 | } | 210 | } |
| @@ -213,7 +214,7 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs, | |||
| 213 | else | 214 | else |
| 214 | { | 215 | { |
| 215 | map_skip--; | 216 | map_skip--; |
| 216 | if ((cache->map_skip > 0) | 217 | if ((cache->map_skip >= 0) |
| 217 | && (cache->map_skip < map_skip)) | 218 | && (cache->map_skip < map_skip)) |
| 218 | map_skip = cache->map_skip; | 219 | map_skip = cache->map_skip; |
| 219 | } | 220 | } |
| @@ -310,7 +311,8 @@ static int tree_link_any(X509_POLICY_LEVEL *curr, | |||
| 310 | 311 | ||
| 311 | if (data == NULL) | 312 | if (data == NULL) |
| 312 | return 0; | 313 | return 0; |
| 313 | data->qualifier_set = curr->anyPolicy->data->qualifier_set; | 314 | /* Curr may not have anyPolicy */ |
| 315 | data->qualifier_set = cache->anyPolicy->qualifier_set; | ||
| 314 | data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS; | 316 | data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS; |
| 315 | if (!level_add_node(curr, data, node, tree)) | 317 | if (!level_add_node(curr, data, node, tree)) |
| 316 | { | 318 | { |
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_addr.c b/src/lib/libssl/src/crypto/x509v3/v3_addr.c index ed9847b307..a37f844d3c 100644 --- a/src/lib/libssl/src/crypto/x509v3/v3_addr.c +++ b/src/lib/libssl/src/crypto/x509v3/v3_addr.c | |||
| @@ -594,10 +594,10 @@ static IPAddressOrRanges *make_prefix_or_range(IPAddrBlocks *addr, | |||
| 594 | return NULL; | 594 | return NULL; |
| 595 | switch (afi) { | 595 | switch (afi) { |
| 596 | case IANA_AFI_IPV4: | 596 | case IANA_AFI_IPV4: |
| 597 | sk_IPAddressOrRange_set_cmp_func(aors, v4IPAddressOrRange_cmp); | 597 | (void)sk_IPAddressOrRange_set_cmp_func(aors, v4IPAddressOrRange_cmp); |
| 598 | break; | 598 | break; |
| 599 | case IANA_AFI_IPV6: | 599 | case IANA_AFI_IPV6: |
| 600 | sk_IPAddressOrRange_set_cmp_func(aors, v6IPAddressOrRange_cmp); | 600 | (void)sk_IPAddressOrRange_set_cmp_func(aors, v6IPAddressOrRange_cmp); |
| 601 | break; | 601 | break; |
| 602 | } | 602 | } |
| 603 | f->ipAddressChoice->type = IPAddressChoice_addressesOrRanges; | 603 | f->ipAddressChoice->type = IPAddressChoice_addressesOrRanges; |
| @@ -854,7 +854,7 @@ static int IPAddressOrRanges_canonize(IPAddressOrRanges *aors, | |||
| 854 | if (!make_addressRange(&merged, a_min, b_max, length)) | 854 | if (!make_addressRange(&merged, a_min, b_max, length)) |
| 855 | return 0; | 855 | return 0; |
| 856 | sk_IPAddressOrRange_set(aors, i, merged); | 856 | sk_IPAddressOrRange_set(aors, i, merged); |
| 857 | sk_IPAddressOrRange_delete(aors, i + 1); | 857 | (void)sk_IPAddressOrRange_delete(aors, i + 1); |
| 858 | IPAddressOrRange_free(a); | 858 | IPAddressOrRange_free(a); |
| 859 | IPAddressOrRange_free(b); | 859 | IPAddressOrRange_free(b); |
| 860 | --i; | 860 | --i; |
| @@ -878,6 +878,7 @@ int v3_addr_canonize(IPAddrBlocks *addr) | |||
| 878 | v3_addr_get_afi(f))) | 878 | v3_addr_get_afi(f))) |
| 879 | return 0; | 879 | return 0; |
| 880 | } | 880 | } |
| 881 | (void)sk_IPAddressFamily_set_cmp_func(addr, IPAddressFamily_cmp); | ||
| 881 | sk_IPAddressFamily_sort(addr); | 882 | sk_IPAddressFamily_sort(addr); |
| 882 | assert(v3_addr_is_canonical(addr)); | 883 | assert(v3_addr_is_canonical(addr)); |
| 883 | return 1; | 884 | return 1; |
| @@ -1122,7 +1123,7 @@ int v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b) | |||
| 1122 | return 1; | 1123 | return 1; |
| 1123 | if (b == NULL || v3_addr_inherits(a) || v3_addr_inherits(b)) | 1124 | if (b == NULL || v3_addr_inherits(a) || v3_addr_inherits(b)) |
| 1124 | return 0; | 1125 | return 0; |
| 1125 | sk_IPAddressFamily_set_cmp_func(b, IPAddressFamily_cmp); | 1126 | (void)sk_IPAddressFamily_set_cmp_func(b, IPAddressFamily_cmp); |
| 1126 | for (i = 0; i < sk_IPAddressFamily_num(a); i++) { | 1127 | for (i = 0; i < sk_IPAddressFamily_num(a); i++) { |
| 1127 | IPAddressFamily *fa = sk_IPAddressFamily_value(a, i); | 1128 | IPAddressFamily *fa = sk_IPAddressFamily_value(a, i); |
| 1128 | int j = sk_IPAddressFamily_find(b, fa); | 1129 | int j = sk_IPAddressFamily_find(b, fa); |
| @@ -1183,7 +1184,7 @@ static int v3_addr_validate_path_internal(X509_STORE_CTX *ctx, | |||
| 1183 | } | 1184 | } |
| 1184 | if (!v3_addr_is_canonical(ext)) | 1185 | if (!v3_addr_is_canonical(ext)) |
| 1185 | validation_err(X509_V_ERR_INVALID_EXTENSION); | 1186 | validation_err(X509_V_ERR_INVALID_EXTENSION); |
| 1186 | sk_IPAddressFamily_set_cmp_func(ext, IPAddressFamily_cmp); | 1187 | (void)sk_IPAddressFamily_set_cmp_func(ext, IPAddressFamily_cmp); |
| 1187 | if ((child = sk_IPAddressFamily_dup(ext)) == NULL) { | 1188 | if ((child = sk_IPAddressFamily_dup(ext)) == NULL) { |
| 1188 | X509V3err(X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL, ERR_R_MALLOC_FAILURE); | 1189 | X509V3err(X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL, ERR_R_MALLOC_FAILURE); |
| 1189 | ret = 0; | 1190 | ret = 0; |
| @@ -1209,7 +1210,7 @@ static int v3_addr_validate_path_internal(X509_STORE_CTX *ctx, | |||
| 1209 | } | 1210 | } |
| 1210 | continue; | 1211 | continue; |
| 1211 | } | 1212 | } |
| 1212 | sk_IPAddressFamily_set_cmp_func(x->rfc3779_addr, IPAddressFamily_cmp); | 1213 | (void)sk_IPAddressFamily_set_cmp_func(x->rfc3779_addr, IPAddressFamily_cmp); |
| 1213 | for (j = 0; j < sk_IPAddressFamily_num(child); j++) { | 1214 | for (j = 0; j < sk_IPAddressFamily_num(child); j++) { |
| 1214 | IPAddressFamily *fc = sk_IPAddressFamily_value(child, j); | 1215 | IPAddressFamily *fc = sk_IPAddressFamily_value(child, j); |
| 1215 | int k = sk_IPAddressFamily_find(x->rfc3779_addr, fc); | 1216 | int k = sk_IPAddressFamily_find(x->rfc3779_addr, fc); |
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_asid.c b/src/lib/libssl/src/crypto/x509v3/v3_asid.c index 271930f967..abd497ed1f 100644 --- a/src/lib/libssl/src/crypto/x509v3/v3_asid.c +++ b/src/lib/libssl/src/crypto/x509v3/v3_asid.c | |||
| @@ -466,7 +466,7 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice) | |||
| 466 | break; | 466 | break; |
| 467 | } | 467 | } |
| 468 | ASIdOrRange_free(b); | 468 | ASIdOrRange_free(b); |
| 469 | sk_ASIdOrRange_delete(choice->u.asIdsOrRanges, i + 1); | 469 | (void)sk_ASIdOrRange_delete(choice->u.asIdsOrRanges, i + 1); |
| 470 | i--; | 470 | i--; |
| 471 | continue; | 471 | continue; |
| 472 | } | 472 | } |
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_ncons.c b/src/lib/libssl/src/crypto/x509v3/v3_ncons.c index 42e7f5a879..4e706be3e1 100644 --- a/src/lib/libssl/src/crypto/x509v3/v3_ncons.c +++ b/src/lib/libssl/src/crypto/x509v3/v3_ncons.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* v3_ncons.c */ | 1 | /* v3_ncons.c */ |
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project. | 3 | * project. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_pcons.c b/src/lib/libssl/src/crypto/x509v3/v3_pcons.c index 13248c2ada..86c0ff70e6 100644 --- a/src/lib/libssl/src/crypto/x509v3/v3_pcons.c +++ b/src/lib/libssl/src/crypto/x509v3/v3_pcons.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* v3_pcons.c */ | 1 | /* v3_pcons.c */ |
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project. | 3 | * project. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_pmaps.c b/src/lib/libssl/src/crypto/x509v3/v3_pmaps.c index 626303264f..da03bbc35d 100644 --- a/src/lib/libssl/src/crypto/x509v3/v3_pmaps.c +++ b/src/lib/libssl/src/crypto/x509v3/v3_pmaps.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* v3_pmaps.c */ | 1 | /* v3_pmaps.c */ |
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project. | 3 | * project. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
diff --git a/src/lib/libssl/src/engines/Makefile b/src/lib/libssl/src/engines/Makefile index 88f8390d0e..002d40c964 100644 --- a/src/lib/libssl/src/engines/Makefile +++ b/src/lib/libssl/src/engines/Makefile | |||
| @@ -20,7 +20,7 @@ TEST= | |||
| 20 | APPS= | 20 | APPS= |
| 21 | 21 | ||
| 22 | LIB=$(TOP)/libcrypto.a | 22 | LIB=$(TOP)/libcrypto.a |
| 23 | LIBNAMES= 4758cca aep atalla cswift gmp chil nuron sureware ubsec | 23 | LIBNAMES= 4758cca aep atalla cswift gmp chil nuron sureware ubsec capi |
| 24 | 24 | ||
| 25 | LIBSRC= e_4758cca.c \ | 25 | LIBSRC= e_4758cca.c \ |
| 26 | e_aep.c \ | 26 | e_aep.c \ |
| @@ -30,7 +30,8 @@ LIBSRC= e_4758cca.c \ | |||
| 30 | e_chil.c \ | 30 | e_chil.c \ |
| 31 | e_nuron.c \ | 31 | e_nuron.c \ |
| 32 | e_sureware.c \ | 32 | e_sureware.c \ |
| 33 | e_ubsec.c | 33 | e_ubsec.c \ |
| 34 | e_capi.c | ||
| 34 | LIBOBJ= e_4758cca.o \ | 35 | LIBOBJ= e_4758cca.o \ |
| 35 | e_aep.o \ | 36 | e_aep.o \ |
| 36 | e_atalla.o \ | 37 | e_atalla.o \ |
| @@ -39,7 +40,8 @@ LIBOBJ= e_4758cca.o \ | |||
| 39 | e_chil.o \ | 40 | e_chil.o \ |
| 40 | e_nuron.o \ | 41 | e_nuron.o \ |
| 41 | e_sureware.o \ | 42 | e_sureware.o \ |
| 42 | e_ubsec.o | 43 | e_ubsec.o \ |
| 44 | e_capi.o | ||
| 43 | 45 | ||
| 44 | SRC= $(LIBSRC) | 46 | SRC= $(LIBSRC) |
| 45 | 47 | ||
| @@ -52,7 +54,8 @@ HEADER= e_4758cca_err.c e_4758cca_err.h \ | |||
| 52 | e_chil_err.c e_chil_err.h \ | 54 | e_chil_err.c e_chil_err.h \ |
| 53 | e_nuron_err.c e_nuron_err.h \ | 55 | e_nuron_err.c e_nuron_err.h \ |
| 54 | e_sureware_err.c e_sureware_err.h \ | 56 | e_sureware_err.c e_sureware_err.h \ |
| 55 | e_ubsec_err.c e_ubsec_err.h | 57 | e_ubsec_err.c e_ubsec_err.h \ |
| 58 | e_capi_err.c e_capi_err.h | ||
| 56 | 59 | ||
| 57 | ALL= $(GENERAL) $(SRC) $(HEADER) | 60 | ALL= $(GENERAL) $(SRC) $(HEADER) |
| 58 | 61 | ||
| @@ -143,38 +146,61 @@ e_4758cca.o: ../include/openssl/crypto.h ../include/openssl/dso.h | |||
| 143 | e_4758cca.o: ../include/openssl/e_os2.h ../include/openssl/ec.h | 146 | e_4758cca.o: ../include/openssl/e_os2.h ../include/openssl/ec.h |
| 144 | e_4758cca.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h | 147 | e_4758cca.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h |
| 145 | e_4758cca.o: ../include/openssl/engine.h ../include/openssl/err.h | 148 | e_4758cca.o: ../include/openssl/engine.h ../include/openssl/err.h |
| 146 | e_4758cca.o: ../include/openssl/evp.h ../include/openssl/lhash.h | 149 | e_4758cca.o: ../include/openssl/evp.h ../include/openssl/fips.h |
| 147 | e_4758cca.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h | 150 | e_4758cca.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h |
| 148 | e_4758cca.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h | 151 | e_4758cca.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h |
| 149 | e_4758cca.o: ../include/openssl/ossl_typ.h ../include/openssl/pkcs7.h | 152 | e_4758cca.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h |
| 150 | e_4758cca.o: ../include/openssl/rand.h ../include/openssl/rsa.h | 153 | e_4758cca.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h |
| 151 | e_4758cca.o: ../include/openssl/safestack.h ../include/openssl/sha.h | 154 | e_4758cca.o: ../include/openssl/rsa.h ../include/openssl/safestack.h |
| 152 | e_4758cca.o: ../include/openssl/stack.h ../include/openssl/symhacks.h | 155 | e_4758cca.o: ../include/openssl/sha.h ../include/openssl/stack.h |
| 153 | e_4758cca.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h | 156 | e_4758cca.o: ../include/openssl/symhacks.h ../include/openssl/x509.h |
| 154 | e_4758cca.o: e_4758cca.c e_4758cca_err.c e_4758cca_err.h | 157 | e_4758cca.o: ../include/openssl/x509_vfy.h e_4758cca.c e_4758cca_err.c |
| 155 | e_4758cca.o: vendor_defns/hw_4758_cca.h | 158 | e_4758cca.o: e_4758cca_err.h vendor_defns/hw_4758_cca.h |
| 156 | e_aep.o: ../include/openssl/asn1.h ../include/openssl/bio.h | 159 | e_aep.o: ../include/openssl/asn1.h ../include/openssl/bio.h |
| 157 | e_aep.o: ../include/openssl/bn.h ../include/openssl/buffer.h | 160 | e_aep.o: ../include/openssl/bn.h ../include/openssl/buffer.h |
| 158 | e_aep.o: ../include/openssl/crypto.h ../include/openssl/dh.h | 161 | e_aep.o: ../include/openssl/crypto.h ../include/openssl/dh.h |
| 159 | e_aep.o: ../include/openssl/dsa.h ../include/openssl/dso.h | 162 | e_aep.o: ../include/openssl/dsa.h ../include/openssl/dso.h |
| 160 | e_aep.o: ../include/openssl/e_os2.h ../include/openssl/engine.h | 163 | e_aep.o: ../include/openssl/e_os2.h ../include/openssl/ec.h |
| 161 | e_aep.o: ../include/openssl/err.h ../include/openssl/lhash.h | 164 | e_aep.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h |
| 162 | e_aep.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h | 165 | e_aep.o: ../include/openssl/engine.h ../include/openssl/err.h |
| 163 | e_aep.o: ../include/openssl/ossl_typ.h ../include/openssl/rsa.h | 166 | e_aep.o: ../include/openssl/evp.h ../include/openssl/fips.h |
| 164 | e_aep.o: ../include/openssl/safestack.h ../include/openssl/stack.h | 167 | e_aep.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h |
| 165 | e_aep.o: ../include/openssl/symhacks.h e_aep.c e_aep_err.c e_aep_err.h | 168 | e_aep.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h |
| 166 | e_aep.o: vendor_defns/aep.h | 169 | e_aep.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h |
| 170 | e_aep.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h | ||
| 171 | e_aep.o: ../include/openssl/safestack.h ../include/openssl/sha.h | ||
| 172 | e_aep.o: ../include/openssl/stack.h ../include/openssl/symhacks.h | ||
| 173 | e_aep.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h e_aep.c | ||
| 174 | e_aep.o: e_aep_err.c e_aep_err.h vendor_defns/aep.h | ||
| 167 | e_atalla.o: ../include/openssl/asn1.h ../include/openssl/bio.h | 175 | e_atalla.o: ../include/openssl/asn1.h ../include/openssl/bio.h |
| 168 | e_atalla.o: ../include/openssl/bn.h ../include/openssl/buffer.h | 176 | e_atalla.o: ../include/openssl/bn.h ../include/openssl/buffer.h |
| 169 | e_atalla.o: ../include/openssl/crypto.h ../include/openssl/dh.h | 177 | e_atalla.o: ../include/openssl/crypto.h ../include/openssl/dh.h |
| 170 | e_atalla.o: ../include/openssl/dsa.h ../include/openssl/dso.h | 178 | e_atalla.o: ../include/openssl/dsa.h ../include/openssl/dso.h |
| 171 | e_atalla.o: ../include/openssl/e_os2.h ../include/openssl/engine.h | 179 | e_atalla.o: ../include/openssl/e_os2.h ../include/openssl/ec.h |
| 172 | e_atalla.o: ../include/openssl/err.h ../include/openssl/lhash.h | 180 | e_atalla.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h |
| 173 | e_atalla.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h | 181 | e_atalla.o: ../include/openssl/engine.h ../include/openssl/err.h |
| 174 | e_atalla.o: ../include/openssl/ossl_typ.h ../include/openssl/rsa.h | 182 | e_atalla.o: ../include/openssl/evp.h ../include/openssl/fips.h |
| 175 | e_atalla.o: ../include/openssl/safestack.h ../include/openssl/stack.h | 183 | e_atalla.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h |
| 176 | e_atalla.o: ../include/openssl/symhacks.h e_atalla.c e_atalla_err.c | 184 | e_atalla.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h |
| 177 | e_atalla.o: e_atalla_err.h vendor_defns/atalla.h | 185 | e_atalla.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h |
| 186 | e_atalla.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h | ||
| 187 | e_atalla.o: ../include/openssl/safestack.h ../include/openssl/sha.h | ||
| 188 | e_atalla.o: ../include/openssl/stack.h ../include/openssl/symhacks.h | ||
| 189 | e_atalla.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h e_atalla.c | ||
| 190 | e_atalla.o: e_atalla_err.c e_atalla_err.h vendor_defns/atalla.h | ||
| 191 | e_capi.o: ../include/openssl/asn1.h ../include/openssl/bio.h | ||
| 192 | e_capi.o: ../include/openssl/bn.h ../include/openssl/buffer.h | ||
| 193 | e_capi.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h | ||
| 194 | e_capi.o: ../include/openssl/ec.h ../include/openssl/ecdh.h | ||
| 195 | e_capi.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h | ||
| 196 | e_capi.o: ../include/openssl/evp.h ../include/openssl/fips.h | ||
| 197 | e_capi.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h | ||
| 198 | e_capi.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h | ||
| 199 | e_capi.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h | ||
| 200 | e_capi.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h | ||
| 201 | e_capi.o: ../include/openssl/safestack.h ../include/openssl/sha.h | ||
| 202 | e_capi.o: ../include/openssl/stack.h ../include/openssl/symhacks.h | ||
| 203 | e_capi.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h e_capi.c | ||
| 178 | e_chil.o: ../include/openssl/asn1.h ../include/openssl/bio.h | 204 | e_chil.o: ../include/openssl/asn1.h ../include/openssl/bio.h |
| 179 | e_chil.o: ../include/openssl/bn.h ../include/openssl/buffer.h | 205 | e_chil.o: ../include/openssl/bn.h ../include/openssl/buffer.h |
| 180 | e_chil.o: ../include/openssl/crypto.h ../include/openssl/dh.h | 206 | e_chil.o: ../include/openssl/crypto.h ../include/openssl/dh.h |
| @@ -182,42 +208,63 @@ e_chil.o: ../include/openssl/dso.h ../include/openssl/e_os2.h | |||
| 182 | e_chil.o: ../include/openssl/ec.h ../include/openssl/ecdh.h | 208 | e_chil.o: ../include/openssl/ec.h ../include/openssl/ecdh.h |
| 183 | e_chil.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h | 209 | e_chil.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h |
| 184 | e_chil.o: ../include/openssl/err.h ../include/openssl/evp.h | 210 | e_chil.o: ../include/openssl/err.h ../include/openssl/evp.h |
| 185 | e_chil.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h | 211 | e_chil.o: ../include/openssl/fips.h ../include/openssl/lhash.h |
| 186 | e_chil.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h | 212 | e_chil.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h |
| 187 | e_chil.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h | 213 | e_chil.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h |
| 188 | e_chil.o: ../include/openssl/pem.h ../include/openssl/pem2.h | 214 | e_chil.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h |
| 189 | e_chil.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h | 215 | e_chil.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h |
| 190 | e_chil.o: ../include/openssl/rsa.h ../include/openssl/safestack.h | 216 | e_chil.o: ../include/openssl/rand.h ../include/openssl/rsa.h |
| 191 | e_chil.o: ../include/openssl/sha.h ../include/openssl/stack.h | 217 | e_chil.o: ../include/openssl/safestack.h ../include/openssl/sha.h |
| 192 | e_chil.o: ../include/openssl/symhacks.h ../include/openssl/ui.h | 218 | e_chil.o: ../include/openssl/stack.h ../include/openssl/symhacks.h |
| 193 | e_chil.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h e_chil.c | 219 | e_chil.o: ../include/openssl/ui.h ../include/openssl/x509.h |
| 194 | e_chil.o: e_chil_err.c e_chil_err.h vendor_defns/hwcryptohook.h | 220 | e_chil.o: ../include/openssl/x509_vfy.h e_chil.c e_chil_err.c e_chil_err.h |
| 221 | e_chil.o: vendor_defns/hwcryptohook.h | ||
| 195 | e_cswift.o: ../include/openssl/asn1.h ../include/openssl/bio.h | 222 | e_cswift.o: ../include/openssl/asn1.h ../include/openssl/bio.h |
| 196 | e_cswift.o: ../include/openssl/bn.h ../include/openssl/buffer.h | 223 | e_cswift.o: ../include/openssl/bn.h ../include/openssl/buffer.h |
| 197 | e_cswift.o: ../include/openssl/crypto.h ../include/openssl/dh.h | 224 | e_cswift.o: ../include/openssl/crypto.h ../include/openssl/dh.h |
| 198 | e_cswift.o: ../include/openssl/dsa.h ../include/openssl/dso.h | 225 | e_cswift.o: ../include/openssl/dsa.h ../include/openssl/dso.h |
| 199 | e_cswift.o: ../include/openssl/e_os2.h ../include/openssl/engine.h | 226 | e_cswift.o: ../include/openssl/e_os2.h ../include/openssl/ec.h |
| 200 | e_cswift.o: ../include/openssl/err.h ../include/openssl/lhash.h | 227 | e_cswift.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h |
| 201 | e_cswift.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h | 228 | e_cswift.o: ../include/openssl/engine.h ../include/openssl/err.h |
| 202 | e_cswift.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h | 229 | e_cswift.o: ../include/openssl/evp.h ../include/openssl/fips.h |
| 230 | e_cswift.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h | ||
| 231 | e_cswift.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h | ||
| 232 | e_cswift.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h | ||
| 233 | e_cswift.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h | ||
| 203 | e_cswift.o: ../include/openssl/rsa.h ../include/openssl/safestack.h | 234 | e_cswift.o: ../include/openssl/rsa.h ../include/openssl/safestack.h |
| 204 | e_cswift.o: ../include/openssl/stack.h ../include/openssl/symhacks.h e_cswift.c | 235 | e_cswift.o: ../include/openssl/sha.h ../include/openssl/stack.h |
| 205 | e_cswift.o: e_cswift_err.c e_cswift_err.h vendor_defns/cswift.h | 236 | e_cswift.o: ../include/openssl/symhacks.h ../include/openssl/x509.h |
| 206 | e_gmp.o: ../include/openssl/buffer.h ../include/openssl/crypto.h | 237 | e_cswift.o: ../include/openssl/x509_vfy.h e_cswift.c e_cswift_err.c |
| 207 | e_gmp.o: ../include/openssl/e_os2.h ../include/openssl/engine.h | 238 | e_cswift.o: e_cswift_err.h vendor_defns/cswift.h |
| 208 | e_gmp.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h | 239 | e_gmp.o: ../include/openssl/asn1.h ../include/openssl/bio.h |
| 209 | e_gmp.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h | 240 | e_gmp.o: ../include/openssl/bn.h ../include/openssl/buffer.h |
| 210 | e_gmp.o: ../include/openssl/stack.h ../include/openssl/symhacks.h e_gmp.c | 241 | e_gmp.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h |
| 242 | e_gmp.o: ../include/openssl/ec.h ../include/openssl/ecdh.h | ||
| 243 | e_gmp.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h | ||
| 244 | e_gmp.o: ../include/openssl/evp.h ../include/openssl/fips.h | ||
| 245 | e_gmp.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h | ||
| 246 | e_gmp.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h | ||
| 247 | e_gmp.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h | ||
| 248 | e_gmp.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h | ||
| 249 | e_gmp.o: ../include/openssl/safestack.h ../include/openssl/sha.h | ||
| 250 | e_gmp.o: ../include/openssl/stack.h ../include/openssl/symhacks.h | ||
| 251 | e_gmp.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h e_gmp.c | ||
| 211 | e_nuron.o: ../include/openssl/asn1.h ../include/openssl/bio.h | 252 | e_nuron.o: ../include/openssl/asn1.h ../include/openssl/bio.h |
| 212 | e_nuron.o: ../include/openssl/bn.h ../include/openssl/buffer.h | 253 | e_nuron.o: ../include/openssl/bn.h ../include/openssl/buffer.h |
| 213 | e_nuron.o: ../include/openssl/crypto.h ../include/openssl/dh.h | 254 | e_nuron.o: ../include/openssl/crypto.h ../include/openssl/dh.h |
| 214 | e_nuron.o: ../include/openssl/dsa.h ../include/openssl/dso.h | 255 | e_nuron.o: ../include/openssl/dsa.h ../include/openssl/dso.h |
| 215 | e_nuron.o: ../include/openssl/e_os2.h ../include/openssl/engine.h | 256 | e_nuron.o: ../include/openssl/e_os2.h ../include/openssl/ec.h |
| 216 | e_nuron.o: ../include/openssl/err.h ../include/openssl/lhash.h | 257 | e_nuron.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h |
| 217 | e_nuron.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h | 258 | e_nuron.o: ../include/openssl/engine.h ../include/openssl/err.h |
| 218 | e_nuron.o: ../include/openssl/ossl_typ.h ../include/openssl/rsa.h | 259 | e_nuron.o: ../include/openssl/evp.h ../include/openssl/fips.h |
| 219 | e_nuron.o: ../include/openssl/safestack.h ../include/openssl/stack.h | 260 | e_nuron.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h |
| 220 | e_nuron.o: ../include/openssl/symhacks.h e_nuron.c e_nuron_err.c e_nuron_err.h | 261 | e_nuron.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h |
| 262 | e_nuron.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h | ||
| 263 | e_nuron.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h | ||
| 264 | e_nuron.o: ../include/openssl/safestack.h ../include/openssl/sha.h | ||
| 265 | e_nuron.o: ../include/openssl/stack.h ../include/openssl/symhacks.h | ||
| 266 | e_nuron.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h e_nuron.c | ||
| 267 | e_nuron.o: e_nuron_err.c e_nuron_err.h | ||
| 221 | e_sureware.o: ../include/openssl/asn1.h ../include/openssl/bio.h | 268 | e_sureware.o: ../include/openssl/asn1.h ../include/openssl/bio.h |
| 222 | e_sureware.o: ../include/openssl/bn.h ../include/openssl/buffer.h | 269 | e_sureware.o: ../include/openssl/bn.h ../include/openssl/buffer.h |
| 223 | e_sureware.o: ../include/openssl/crypto.h ../include/openssl/dh.h | 270 | e_sureware.o: ../include/openssl/crypto.h ../include/openssl/dh.h |
| @@ -225,25 +272,30 @@ e_sureware.o: ../include/openssl/dsa.h ../include/openssl/dso.h | |||
| 225 | e_sureware.o: ../include/openssl/e_os2.h ../include/openssl/ec.h | 272 | e_sureware.o: ../include/openssl/e_os2.h ../include/openssl/ec.h |
| 226 | e_sureware.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h | 273 | e_sureware.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h |
| 227 | e_sureware.o: ../include/openssl/engine.h ../include/openssl/err.h | 274 | e_sureware.o: ../include/openssl/engine.h ../include/openssl/err.h |
| 228 | e_sureware.o: ../include/openssl/evp.h ../include/openssl/lhash.h | 275 | e_sureware.o: ../include/openssl/evp.h ../include/openssl/fips.h |
| 229 | e_sureware.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h | 276 | e_sureware.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h |
| 230 | e_sureware.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h | 277 | e_sureware.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h |
| 231 | e_sureware.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h | 278 | e_sureware.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h |
| 232 | e_sureware.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h | 279 | e_sureware.o: ../include/openssl/pem.h ../include/openssl/pem2.h |
| 233 | e_sureware.o: ../include/openssl/rand.h ../include/openssl/rsa.h | 280 | e_sureware.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h |
| 234 | e_sureware.o: ../include/openssl/safestack.h ../include/openssl/sha.h | 281 | e_sureware.o: ../include/openssl/rsa.h ../include/openssl/safestack.h |
| 235 | e_sureware.o: ../include/openssl/stack.h ../include/openssl/symhacks.h | 282 | e_sureware.o: ../include/openssl/sha.h ../include/openssl/stack.h |
| 236 | e_sureware.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h | 283 | e_sureware.o: ../include/openssl/symhacks.h ../include/openssl/x509.h |
| 237 | e_sureware.o: e_sureware.c e_sureware_err.c e_sureware_err.h | 284 | e_sureware.o: ../include/openssl/x509_vfy.h e_sureware.c e_sureware_err.c |
| 238 | e_sureware.o: vendor_defns/sureware.h | 285 | e_sureware.o: e_sureware_err.h vendor_defns/sureware.h |
| 239 | e_ubsec.o: ../include/openssl/asn1.h ../include/openssl/bio.h | 286 | e_ubsec.o: ../include/openssl/asn1.h ../include/openssl/bio.h |
| 240 | e_ubsec.o: ../include/openssl/bn.h ../include/openssl/buffer.h | 287 | e_ubsec.o: ../include/openssl/bn.h ../include/openssl/buffer.h |
| 241 | e_ubsec.o: ../include/openssl/crypto.h ../include/openssl/dh.h | 288 | e_ubsec.o: ../include/openssl/crypto.h ../include/openssl/dh.h |
| 242 | e_ubsec.o: ../include/openssl/dsa.h ../include/openssl/dso.h | 289 | e_ubsec.o: ../include/openssl/dsa.h ../include/openssl/dso.h |
| 243 | e_ubsec.o: ../include/openssl/e_os2.h ../include/openssl/engine.h | 290 | e_ubsec.o: ../include/openssl/e_os2.h ../include/openssl/ec.h |
| 244 | e_ubsec.o: ../include/openssl/err.h ../include/openssl/lhash.h | 291 | e_ubsec.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h |
| 245 | e_ubsec.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h | 292 | e_ubsec.o: ../include/openssl/engine.h ../include/openssl/err.h |
| 246 | e_ubsec.o: ../include/openssl/ossl_typ.h ../include/openssl/rsa.h | 293 | e_ubsec.o: ../include/openssl/evp.h ../include/openssl/fips.h |
| 247 | e_ubsec.o: ../include/openssl/safestack.h ../include/openssl/stack.h | 294 | e_ubsec.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h |
| 248 | e_ubsec.o: ../include/openssl/symhacks.h e_ubsec.c e_ubsec_err.c e_ubsec_err.h | 295 | e_ubsec.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h |
| 249 | e_ubsec.o: vendor_defns/hw_ubsec.h | 296 | e_ubsec.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h |
| 297 | e_ubsec.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h | ||
| 298 | e_ubsec.o: ../include/openssl/safestack.h ../include/openssl/sha.h | ||
| 299 | e_ubsec.o: ../include/openssl/stack.h ../include/openssl/symhacks.h | ||
| 300 | e_ubsec.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h e_ubsec.c | ||
| 301 | e_ubsec.o: e_ubsec_err.c e_ubsec_err.h vendor_defns/hw_ubsec.h | ||
diff --git a/src/lib/libssl/src/engines/e_aep.c b/src/lib/libssl/src/engines/e_aep.c index ffdc354cdc..e24e4b424e 100644 --- a/src/lib/libssl/src/engines/e_aep.c +++ b/src/lib/libssl/src/engines/e_aep.c | |||
| @@ -867,10 +867,12 @@ static AEP_RV aep_get_connection(AEP_CONNECTION_HNDL_PTR phConnection) | |||
| 867 | 867 | ||
| 868 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 868 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
| 869 | 869 | ||
| 870 | #ifndef NETWARE_CLIB | 870 | #ifdef NETWARE_CLIB |
| 871 | curr_pid = getpid(); | ||
| 872 | #else | ||
| 873 | curr_pid = GetThreadID(); | 871 | curr_pid = GetThreadID(); |
| 872 | #elif defined(_WIN32) | ||
| 873 | curr_pid = _getpid(); | ||
| 874 | #else | ||
| 875 | curr_pid = getpid(); | ||
| 874 | #endif | 876 | #endif |
| 875 | 877 | ||
| 876 | /*Check if this is the first time this is being called from the current | 878 | /*Check if this is the first time this is being called from the current |
diff --git a/src/lib/libssl/src/engines/e_chil.c b/src/lib/libssl/src/engines/e_chil.c index 26108caa64..e1847622ea 100644 --- a/src/lib/libssl/src/engines/e_chil.c +++ b/src/lib/libssl/src/engines/e_chil.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* crypto/engine/e_chil.c -*- mode: C; c-file-style: "eay" -*- */ | 1 | /* crypto/engine/e_chil.c -*- mode: C; c-file-style: "eay" -*- */ |
| 2 | /* Written by Richard Levitte (richard@levitte.org), Geoff Thorpe | 2 | /* Written by Richard Levitte (richard@levitte.org), Geoff Thorpe |
| 3 | * (geoff@geoffthorpe.net) and Dr Stephen N Henson (shenson@bigfoot.com) | 3 | * (geoff@geoffthorpe.net) and Dr Stephen N Henson (steve@openssl.org) |
| 4 | * for the OpenSSL project 2000. | 4 | * for the OpenSSL project 2000. |
| 5 | */ | 5 | */ |
| 6 | /* ==================================================================== | 6 | /* ==================================================================== |
| @@ -164,11 +164,11 @@ static const ENGINE_CMD_DEFN hwcrhk_cmd_defns[] = { | |||
| 164 | ENGINE_CMD_FLAG_STRING}, | 164 | ENGINE_CMD_FLAG_STRING}, |
| 165 | {HWCRHK_CMD_FORK_CHECK, | 165 | {HWCRHK_CMD_FORK_CHECK, |
| 166 | "FORK_CHECK", | 166 | "FORK_CHECK", |
| 167 | "Turns fork() checking on or off (boolean)", | 167 | "Turns fork() checking on (non-zero) or off (zero)", |
| 168 | ENGINE_CMD_FLAG_NUMERIC}, | 168 | ENGINE_CMD_FLAG_NUMERIC}, |
| 169 | {HWCRHK_CMD_THREAD_LOCKING, | 169 | {HWCRHK_CMD_THREAD_LOCKING, |
| 170 | "THREAD_LOCKING", | 170 | "THREAD_LOCKING", |
| 171 | "Turns thread-safe locking on or off (boolean)", | 171 | "Turns thread-safe locking on (zero) or off (non-zero)", |
| 172 | ENGINE_CMD_FLAG_NUMERIC}, | 172 | ENGINE_CMD_FLAG_NUMERIC}, |
| 173 | {HWCRHK_CMD_SET_USER_INTERFACE, | 173 | {HWCRHK_CMD_SET_USER_INTERFACE, |
| 174 | "SET_USER_INTERFACE", | 174 | "SET_USER_INTERFACE", |
| @@ -589,12 +589,6 @@ static int hwcrhk_init(ENGINE *e) | |||
| 589 | hwcrhk_globals.mutex_release = hwcrhk_mutex_unlock; | 589 | hwcrhk_globals.mutex_release = hwcrhk_mutex_unlock; |
| 590 | hwcrhk_globals.mutex_destroy = hwcrhk_mutex_destroy; | 590 | hwcrhk_globals.mutex_destroy = hwcrhk_mutex_destroy; |
| 591 | } | 591 | } |
| 592 | else if (CRYPTO_get_locking_callback() != NULL) | ||
| 593 | { | ||
| 594 | HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_LOCKING_MISSING); | ||
| 595 | ERR_add_error_data(1,"You HAVE to add dynamic locking callbacks via CRYPTO_set_dynlock_{create,lock,destroy}_callback()"); | ||
| 596 | goto err; | ||
| 597 | } | ||
| 598 | } | 592 | } |
| 599 | 593 | ||
| 600 | /* Try and get a context - if not, we may have a DSO but no | 594 | /* Try and get a context - if not, we may have a DSO but no |
diff --git a/src/lib/libssl/src/engines/e_chil_err.c b/src/lib/libssl/src/engines/e_chil_err.c index 3fec95a272..c5983b2fd5 100644 --- a/src/lib/libssl/src/engines/e_chil_err.c +++ b/src/lib/libssl/src/engines/e_chil_err.c | |||
| @@ -90,7 +90,6 @@ static ERR_STRING_DATA HWCRHK_str_reasons[]= | |||
| 90 | {ERR_REASON(HWCRHK_R_CHIL_ERROR) ,"chil error"}, | 90 | {ERR_REASON(HWCRHK_R_CHIL_ERROR) ,"chil error"}, |
| 91 | {ERR_REASON(HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED),"ctrl command not implemented"}, | 91 | {ERR_REASON(HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED),"ctrl command not implemented"}, |
| 92 | {ERR_REASON(HWCRHK_R_DSO_FAILURE) ,"dso failure"}, | 92 | {ERR_REASON(HWCRHK_R_DSO_FAILURE) ,"dso failure"}, |
| 93 | {ERR_REASON(HWCRHK_R_LOCKING_MISSING) ,"locking missing"}, | ||
| 94 | {ERR_REASON(HWCRHK_R_MISSING_KEY_COMPONENTS),"missing key components"}, | 93 | {ERR_REASON(HWCRHK_R_MISSING_KEY_COMPONENTS),"missing key components"}, |
| 95 | {ERR_REASON(HWCRHK_R_NOT_INITIALISED) ,"not initialised"}, | 94 | {ERR_REASON(HWCRHK_R_NOT_INITIALISED) ,"not initialised"}, |
| 96 | {ERR_REASON(HWCRHK_R_NOT_LOADED) ,"not loaded"}, | 95 | {ERR_REASON(HWCRHK_R_NOT_LOADED) ,"not loaded"}, |
diff --git a/src/lib/libssl/src/engines/e_chil_err.h b/src/lib/libssl/src/engines/e_chil_err.h index 051854950a..3c42a02393 100644 --- a/src/lib/libssl/src/engines/e_chil_err.h +++ b/src/lib/libssl/src/engines/e_chil_err.h | |||
| @@ -88,7 +88,6 @@ static void ERR_HWCRHK_error(int function, int reason, char *file, int line); | |||
| 88 | #define HWCRHK_R_CHIL_ERROR 102 | 88 | #define HWCRHK_R_CHIL_ERROR 102 |
| 89 | #define HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED 103 | 89 | #define HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED 103 |
| 90 | #define HWCRHK_R_DSO_FAILURE 104 | 90 | #define HWCRHK_R_DSO_FAILURE 104 |
| 91 | #define HWCRHK_R_LOCKING_MISSING 114 | ||
| 92 | #define HWCRHK_R_MISSING_KEY_COMPONENTS 105 | 91 | #define HWCRHK_R_MISSING_KEY_COMPONENTS 105 |
| 93 | #define HWCRHK_R_NOT_INITIALISED 106 | 92 | #define HWCRHK_R_NOT_INITIALISED 106 |
| 94 | #define HWCRHK_R_NOT_LOADED 107 | 93 | #define HWCRHK_R_NOT_LOADED 107 |
diff --git a/src/lib/libssl/src/engines/e_gmp.c b/src/lib/libssl/src/engines/e_gmp.c index e62e6fcd07..a1a2d2bda6 100644 --- a/src/lib/libssl/src/engines/e_gmp.c +++ b/src/lib/libssl/src/engines/e_gmp.c | |||
| @@ -451,9 +451,13 @@ static int e_gmp_rsa_mod_exp(BIGNUM *r, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) | |||
| 451 | } | 451 | } |
| 452 | #endif | 452 | #endif |
| 453 | 453 | ||
| 454 | #endif /* !OPENSSL_NO_GMP */ | ||
| 455 | |||
| 454 | /* This stuff is needed if this ENGINE is being compiled into a self-contained | 456 | /* This stuff is needed if this ENGINE is being compiled into a self-contained |
| 455 | * shared-library. */ | 457 | * shared-library. */ |
| 456 | #ifndef ENGINE_NO_DYNAMIC_SUPPORT | 458 | #ifndef OPENSSL_NO_DYNAMIC_ENGINE |
| 459 | IMPLEMENT_DYNAMIC_CHECK_FN() | ||
| 460 | #ifndef OPENSSL_NO_GMP | ||
| 457 | static int bind_fn(ENGINE *e, const char *id) | 461 | static int bind_fn(ENGINE *e, const char *id) |
| 458 | { | 462 | { |
| 459 | if(id && (strcmp(id, engine_e_gmp_id) != 0)) | 463 | if(id && (strcmp(id, engine_e_gmp_id) != 0)) |
| @@ -462,10 +466,11 @@ static int bind_fn(ENGINE *e, const char *id) | |||
| 462 | return 0; | 466 | return 0; |
| 463 | return 1; | 467 | return 1; |
| 464 | } | 468 | } |
| 465 | IMPLEMENT_DYNAMIC_CHECK_FN() | ||
| 466 | IMPLEMENT_DYNAMIC_BIND_FN(bind_fn) | 469 | IMPLEMENT_DYNAMIC_BIND_FN(bind_fn) |
| 467 | #endif /* ENGINE_DYNAMIC_SUPPORT */ | 470 | #else |
| 471 | OPENSSL_EXPORT | ||
| 472 | int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { return 0; } | ||
| 473 | #endif | ||
| 474 | #endif /* OPENSSL_NO_DYNAMIC_ENGINE */ | ||
| 468 | 475 | ||
| 469 | #endif /* !OPENSSL_NO_GMP */ | ||
| 470 | #endif /* !OPENSSL_NO_HW */ | 476 | #endif /* !OPENSSL_NO_HW */ |
| 471 | |||
diff --git a/src/lib/libssl/src/ssl/d1_clnt.c b/src/lib/libssl/src/ssl/d1_clnt.c index 5e59dc845a..49c6760d19 100644 --- a/src/lib/libssl/src/ssl/d1_clnt.c +++ b/src/lib/libssl/src/ssl/d1_clnt.c | |||
| @@ -1095,8 +1095,7 @@ int dtls1_send_client_certificate(SSL *s) | |||
| 1095 | * ssl->rwstate=SSL_X509_LOOKUP; return(-1); | 1095 | * ssl->rwstate=SSL_X509_LOOKUP; return(-1); |
| 1096 | * We then get retied later */ | 1096 | * We then get retied later */ |
| 1097 | i=0; | 1097 | i=0; |
| 1098 | if (s->ctx->client_cert_cb != NULL) | 1098 | i = ssl_do_client_cert_cb(s, &x509, &pkey); |
| 1099 | i=s->ctx->client_cert_cb(s,&(x509),&(pkey)); | ||
| 1100 | if (i < 0) | 1099 | if (i < 0) |
| 1101 | { | 1100 | { |
| 1102 | s->rwstate=SSL_X509_LOOKUP; | 1101 | s->rwstate=SSL_X509_LOOKUP; |
diff --git a/src/lib/libssl/src/ssl/d1_enc.c b/src/lib/libssl/src/ssl/d1_enc.c index cbff7495c5..cf3332e4e4 100644 --- a/src/lib/libssl/src/ssl/d1_enc.c +++ b/src/lib/libssl/src/ssl/d1_enc.c | |||
| @@ -115,12 +115,16 @@ | |||
| 115 | 115 | ||
| 116 | #include <stdio.h> | 116 | #include <stdio.h> |
| 117 | #include "ssl_locl.h" | 117 | #include "ssl_locl.h" |
| 118 | #ifndef OPENSSL_NO_COMP | ||
| 118 | #include <openssl/comp.h> | 119 | #include <openssl/comp.h> |
| 120 | #endif | ||
| 119 | #include <openssl/evp.h> | 121 | #include <openssl/evp.h> |
| 120 | #include <openssl/hmac.h> | 122 | #include <openssl/hmac.h> |
| 121 | #include <openssl/md5.h> | 123 | #include <openssl/md5.h> |
| 122 | #include <openssl/rand.h> | 124 | #include <openssl/rand.h> |
| 123 | 125 | #ifdef KSSL_DEBUG | |
| 126 | #include <openssl/des.h> | ||
| 127 | #endif | ||
| 124 | 128 | ||
| 125 | int dtls1_enc(SSL *s, int send) | 129 | int dtls1_enc(SSL *s, int send) |
| 126 | { | 130 | { |
| @@ -202,10 +206,11 @@ int dtls1_enc(SSL *s, int send) | |||
| 202 | { | 206 | { |
| 203 | unsigned long ui; | 207 | unsigned long ui; |
| 204 | printf("EVP_Cipher(ds=%p,rec->data=%p,rec->input=%p,l=%ld) ==>\n", | 208 | printf("EVP_Cipher(ds=%p,rec->data=%p,rec->input=%p,l=%ld) ==>\n", |
| 205 | ds,rec->data,rec->input,l); | 209 | (void *)ds,rec->data,rec->input,l); |
| 206 | printf("\tEVP_CIPHER_CTX: %d buf_len, %d key_len [%d %d], %d iv_len\n", | 210 | printf("\tEVP_CIPHER_CTX: %d buf_len, %d key_len [%ld %ld], %d iv_len\n", |
| 207 | ds->buf_len, ds->cipher->key_len, | 211 | ds->buf_len, ds->cipher->key_len, |
| 208 | DES_KEY_SZ, DES_SCHEDULE_SZ, | 212 | (unsigned long)DES_KEY_SZ, |
| 213 | (unsigned long)DES_SCHEDULE_SZ, | ||
| 209 | ds->cipher->iv_len); | 214 | ds->cipher->iv_len); |
| 210 | printf("\t\tIV: "); | 215 | printf("\t\tIV: "); |
| 211 | for (i=0; i<ds->cipher->iv_len; i++) printf("%02X", ds->iv[i]); | 216 | for (i=0; i<ds->cipher->iv_len; i++) printf("%02X", ds->iv[i]); |
| @@ -230,10 +235,10 @@ int dtls1_enc(SSL *s, int send) | |||
| 230 | 235 | ||
| 231 | #ifdef KSSL_DEBUG | 236 | #ifdef KSSL_DEBUG |
| 232 | { | 237 | { |
| 233 | unsigned long i; | 238 | unsigned long ki; |
| 234 | printf("\trec->data="); | 239 | printf("\trec->data="); |
| 235 | for (i=0; i<l; i++) | 240 | for (ki=0; ki<l; ki++) |
| 236 | printf(" %02x", rec->data[i]); printf("\n"); | 241 | printf(" %02x", rec->data[ki]); printf("\n"); |
| 237 | } | 242 | } |
| 238 | #endif /* KSSL_DEBUG */ | 243 | #endif /* KSSL_DEBUG */ |
| 239 | 244 | ||
diff --git a/src/lib/libssl/src/ssl/d1_lib.c b/src/lib/libssl/src/ssl/d1_lib.c index fc088b4148..3568e97a87 100644 --- a/src/lib/libssl/src/ssl/d1_lib.c +++ b/src/lib/libssl/src/ssl/d1_lib.c | |||
| @@ -106,6 +106,7 @@ int dtls1_new(SSL *s) | |||
| 106 | pq_64bit_init(&(d1->bitmap.map)); | 106 | pq_64bit_init(&(d1->bitmap.map)); |
| 107 | pq_64bit_init(&(d1->bitmap.max_seq_num)); | 107 | pq_64bit_init(&(d1->bitmap.max_seq_num)); |
| 108 | 108 | ||
| 109 | d1->next_bitmap.length = d1->bitmap.length; | ||
| 109 | pq_64bit_init(&(d1->next_bitmap.map)); | 110 | pq_64bit_init(&(d1->next_bitmap.map)); |
| 110 | pq_64bit_init(&(d1->next_bitmap.max_seq_num)); | 111 | pq_64bit_init(&(d1->next_bitmap.max_seq_num)); |
| 111 | 112 | ||
diff --git a/src/lib/libssl/src/ssl/d1_pkt.c b/src/lib/libssl/src/ssl/d1_pkt.c index 377696deac..eb56cf987b 100644 --- a/src/lib/libssl/src/ssl/d1_pkt.c +++ b/src/lib/libssl/src/ssl/d1_pkt.c | |||
| @@ -597,6 +597,7 @@ again: | |||
| 597 | /* check whether this is a repeat, or aged record */ | 597 | /* check whether this is a repeat, or aged record */ |
| 598 | if ( ! dtls1_record_replay_check(s, bitmap, &(rr->seq_num))) | 598 | if ( ! dtls1_record_replay_check(s, bitmap, &(rr->seq_num))) |
| 599 | { | 599 | { |
| 600 | rr->length = 0; | ||
| 600 | s->packet_length=0; /* dump this record */ | 601 | s->packet_length=0; /* dump this record */ |
| 601 | goto again; /* get another record */ | 602 | goto again; /* get another record */ |
| 602 | } | 603 | } |
| @@ -811,6 +812,14 @@ start: | |||
| 811 | * may be fragmented--don't always expect dest_maxlen bytes */ | 812 | * may be fragmented--don't always expect dest_maxlen bytes */ |
| 812 | if ( rr->length < dest_maxlen) | 813 | if ( rr->length < dest_maxlen) |
| 813 | { | 814 | { |
| 815 | #ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE | ||
| 816 | /* | ||
| 817 | * for normal alerts rr->length is 2, while | ||
| 818 | * dest_maxlen is 7 if we were to handle this | ||
| 819 | * non-existing alert... | ||
| 820 | */ | ||
| 821 | FIX ME | ||
| 822 | #endif | ||
| 814 | s->rstate=SSL_ST_READ_HEADER; | 823 | s->rstate=SSL_ST_READ_HEADER; |
| 815 | rr->length = 0; | 824 | rr->length = 0; |
| 816 | goto start; | 825 | goto start; |
| @@ -1251,7 +1260,7 @@ int dtls1_write_bytes(SSL *s, int type, const void *buf_, int len) | |||
| 1251 | else | 1260 | else |
| 1252 | s->s3->wnum += i; | 1261 | s->s3->wnum += i; |
| 1253 | 1262 | ||
| 1254 | return tot + i; | 1263 | return i; |
| 1255 | } | 1264 | } |
| 1256 | 1265 | ||
| 1257 | int do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len, int create_empty_fragment) | 1266 | int do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len, int create_empty_fragment) |
| @@ -1576,7 +1585,7 @@ int dtls1_dispatch_alert(SSL *s) | |||
| 1576 | { | 1585 | { |
| 1577 | int i,j; | 1586 | int i,j; |
| 1578 | void (*cb)(const SSL *ssl,int type,int val)=NULL; | 1587 | void (*cb)(const SSL *ssl,int type,int val)=NULL; |
| 1579 | unsigned char buf[2 + 2 + 3]; /* alert level + alert desc + message seq +frag_off */ | 1588 | unsigned char buf[DTLS1_AL_HEADER_LENGTH]; |
| 1580 | unsigned char *ptr = &buf[0]; | 1589 | unsigned char *ptr = &buf[0]; |
| 1581 | 1590 | ||
| 1582 | s->s3->alert_dispatch=0; | 1591 | s->s3->alert_dispatch=0; |
| @@ -1585,6 +1594,7 @@ int dtls1_dispatch_alert(SSL *s) | |||
| 1585 | *ptr++ = s->s3->send_alert[0]; | 1594 | *ptr++ = s->s3->send_alert[0]; |
| 1586 | *ptr++ = s->s3->send_alert[1]; | 1595 | *ptr++ = s->s3->send_alert[1]; |
| 1587 | 1596 | ||
| 1597 | #ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE | ||
| 1588 | if (s->s3->send_alert[1] == DTLS1_AD_MISSING_HANDSHAKE_MESSAGE) | 1598 | if (s->s3->send_alert[1] == DTLS1_AD_MISSING_HANDSHAKE_MESSAGE) |
| 1589 | { | 1599 | { |
| 1590 | s2n(s->d1->handshake_read_seq, ptr); | 1600 | s2n(s->d1->handshake_read_seq, ptr); |
| @@ -1600,6 +1610,7 @@ int dtls1_dispatch_alert(SSL *s) | |||
| 1600 | #endif | 1610 | #endif |
| 1601 | l2n3(s->d1->r_msg_hdr.frag_off, ptr); | 1611 | l2n3(s->d1->r_msg_hdr.frag_off, ptr); |
| 1602 | } | 1612 | } |
| 1613 | #endif | ||
| 1603 | 1614 | ||
| 1604 | i = do_dtls1_write(s, SSL3_RT_ALERT, &buf[0], sizeof(buf), 0); | 1615 | i = do_dtls1_write(s, SSL3_RT_ALERT, &buf[0], sizeof(buf), 0); |
| 1605 | if (i <= 0) | 1616 | if (i <= 0) |
| @@ -1609,8 +1620,11 @@ int dtls1_dispatch_alert(SSL *s) | |||
| 1609 | } | 1620 | } |
| 1610 | else | 1621 | else |
| 1611 | { | 1622 | { |
| 1612 | if ( s->s3->send_alert[0] == SSL3_AL_FATAL || | 1623 | if (s->s3->send_alert[0] == SSL3_AL_FATAL |
| 1613 | s->s3->send_alert[1] == DTLS1_AD_MISSING_HANDSHAKE_MESSAGE) | 1624 | #ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE |
| 1625 | || s->s3->send_alert[1] == DTLS1_AD_MISSING_HANDSHAKE_MESSAGE | ||
| 1626 | #endif | ||
| 1627 | ) | ||
| 1614 | (void)BIO_flush(s->wbio); | 1628 | (void)BIO_flush(s->wbio); |
| 1615 | 1629 | ||
| 1616 | if (s->msg_callback) | 1630 | if (s->msg_callback) |
diff --git a/src/lib/libssl/src/ssl/d1_srvr.c b/src/lib/libssl/src/ssl/d1_srvr.c index 927b01f3c4..0bbf8ae7f3 100644 --- a/src/lib/libssl/src/ssl/d1_srvr.c +++ b/src/lib/libssl/src/ssl/d1_srvr.c | |||
| @@ -732,7 +732,7 @@ int dtls1_send_server_hello(SSL *s) | |||
| 732 | 732 | ||
| 733 | d = dtls1_set_message_header(s, d, SSL3_MT_SERVER_HELLO, l, 0, l); | 733 | d = dtls1_set_message_header(s, d, SSL3_MT_SERVER_HELLO, l, 0, l); |
| 734 | 734 | ||
| 735 | s->state=SSL3_ST_CW_CLNT_HELLO_B; | 735 | s->state=SSL3_ST_SW_SRVR_HELLO_B; |
| 736 | /* number of bytes to write */ | 736 | /* number of bytes to write */ |
| 737 | s->init_num=p-buf; | 737 | s->init_num=p-buf; |
| 738 | s->init_off=0; | 738 | s->init_off=0; |
| @@ -741,7 +741,7 @@ int dtls1_send_server_hello(SSL *s) | |||
| 741 | dtls1_buffer_message(s, 0); | 741 | dtls1_buffer_message(s, 0); |
| 742 | } | 742 | } |
| 743 | 743 | ||
| 744 | /* SSL3_ST_CW_CLNT_HELLO_B */ | 744 | /* SSL3_ST_SW_SRVR_HELLO_B */ |
| 745 | return(dtls1_do_write(s,SSL3_RT_HANDSHAKE)); | 745 | return(dtls1_do_write(s,SSL3_RT_HANDSHAKE)); |
| 746 | } | 746 | } |
| 747 | 747 | ||
| @@ -765,7 +765,7 @@ int dtls1_send_server_done(SSL *s) | |||
| 765 | dtls1_buffer_message(s, 0); | 765 | dtls1_buffer_message(s, 0); |
| 766 | } | 766 | } |
| 767 | 767 | ||
| 768 | /* SSL3_ST_CW_CLNT_HELLO_B */ | 768 | /* SSL3_ST_SW_SRVR_DONE_B */ |
| 769 | return(dtls1_do_write(s,SSL3_RT_HANDSHAKE)); | 769 | return(dtls1_do_write(s,SSL3_RT_HANDSHAKE)); |
| 770 | } | 770 | } |
| 771 | 771 | ||
diff --git a/src/lib/libssl/src/ssl/dtls1.h b/src/lib/libssl/src/ssl/dtls1.h index a663cf85f2..f159d37110 100644 --- a/src/lib/libssl/src/ssl/dtls1.h +++ b/src/lib/libssl/src/ssl/dtls1.h | |||
| @@ -70,7 +70,10 @@ extern "C" { | |||
| 70 | #define DTLS1_VERSION 0xFEFF | 70 | #define DTLS1_VERSION 0xFEFF |
| 71 | #define DTLS1_BAD_VER 0x0100 | 71 | #define DTLS1_BAD_VER 0x0100 |
| 72 | 72 | ||
| 73 | #if 0 | ||
| 74 | /* this alert description is not specified anywhere... */ | ||
| 73 | #define DTLS1_AD_MISSING_HANDSHAKE_MESSAGE 110 | 75 | #define DTLS1_AD_MISSING_HANDSHAKE_MESSAGE 110 |
| 76 | #endif | ||
| 74 | 77 | ||
| 75 | /* lengths of messages */ | 78 | /* lengths of messages */ |
| 76 | #define DTLS1_COOKIE_LENGTH 32 | 79 | #define DTLS1_COOKIE_LENGTH 32 |
| @@ -84,7 +87,11 @@ extern "C" { | |||
| 84 | 87 | ||
| 85 | #define DTLS1_CCS_HEADER_LENGTH 1 | 88 | #define DTLS1_CCS_HEADER_LENGTH 1 |
| 86 | 89 | ||
| 90 | #ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE | ||
| 87 | #define DTLS1_AL_HEADER_LENGTH 7 | 91 | #define DTLS1_AL_HEADER_LENGTH 7 |
| 92 | #else | ||
| 93 | #define DTLS1_AL_HEADER_LENGTH 2 | ||
| 94 | #endif | ||
| 88 | 95 | ||
| 89 | 96 | ||
| 90 | typedef struct dtls1_bitmap_st | 97 | typedef struct dtls1_bitmap_st |
diff --git a/src/lib/libssl/src/test/igetest.c b/src/lib/libssl/src/test/igetest.c index 95452d0965..a2578d09c5 100644 --- a/src/lib/libssl/src/test/igetest.c +++ b/src/lib/libssl/src/test/igetest.c | |||
| @@ -190,7 +190,7 @@ static struct bi_ige_test const bi_ige_test_vectors[] = { | |||
| 190 | 190 | ||
| 191 | static int run_test_vectors(void) | 191 | static int run_test_vectors(void) |
| 192 | { | 192 | { |
| 193 | int n; | 193 | unsigned int n; |
| 194 | int errs = 0; | 194 | int errs = 0; |
| 195 | 195 | ||
| 196 | for(n=0 ; n < sizeof(ige_test_vectors)/sizeof(ige_test_vectors[0]) ; ++n) | 196 | for(n=0 ; n < sizeof(ige_test_vectors)/sizeof(ige_test_vectors[0]) ; ++n) |
| @@ -292,7 +292,7 @@ int main(int argc, char **argv) | |||
| 292 | unsigned char iv[AES_BLOCK_SIZE*4]; | 292 | unsigned char iv[AES_BLOCK_SIZE*4]; |
| 293 | unsigned char saved_iv[AES_BLOCK_SIZE*4]; | 293 | unsigned char saved_iv[AES_BLOCK_SIZE*4]; |
| 294 | int err = 0; | 294 | int err = 0; |
| 295 | int n; | 295 | unsigned int n; |
| 296 | unsigned matches; | 296 | unsigned matches; |
| 297 | 297 | ||
| 298 | assert(BIG_TEST_SIZE >= TEST_SIZE); | 298 | assert(BIG_TEST_SIZE >= TEST_SIZE); |
diff --git a/src/lib/libssl/src/util/copy.pl b/src/lib/libssl/src/util/copy.pl index e20b45530a..eba6d5815e 100644 --- a/src/lib/libssl/src/util/copy.pl +++ b/src/lib/libssl/src/util/copy.pl | |||
| @@ -8,9 +8,16 @@ use Fcntl; | |||
| 8 | # Perl script 'copy' comment. On Windows the built in "copy" command also | 8 | # Perl script 'copy' comment. On Windows the built in "copy" command also |
| 9 | # copies timestamps: this messes up Makefile dependencies. | 9 | # copies timestamps: this messes up Makefile dependencies. |
| 10 | 10 | ||
| 11 | my $stripcr = 0; | ||
| 12 | |||
| 11 | my $arg; | 13 | my $arg; |
| 12 | 14 | ||
| 13 | foreach $arg (@ARGV) { | 15 | foreach $arg (@ARGV) { |
| 16 | if ($arg eq "-stripcr") | ||
| 17 | { | ||
| 18 | $stripcr = 1; | ||
| 19 | next; | ||
| 20 | } | ||
| 14 | $arg =~ s|\\|/|g; # compensate for bug/feature in cygwin glob... | 21 | $arg =~ s|\\|/|g; # compensate for bug/feature in cygwin glob... |
| 15 | foreach (glob $arg) | 22 | foreach (glob $arg) |
| 16 | { | 23 | { |
| @@ -49,6 +56,10 @@ foreach (@filelist) | |||
| 49 | || die "Can't Open $dfile"; | 56 | || die "Can't Open $dfile"; |
| 50 | while (sysread IN, $buf, 10240) | 57 | while (sysread IN, $buf, 10240) |
| 51 | { | 58 | { |
| 59 | if ($stripcr) | ||
| 60 | { | ||
| 61 | $buf =~ tr/\015//d; | ||
| 62 | } | ||
| 52 | syswrite(OUT, $buf, length($buf)); | 63 | syswrite(OUT, $buf, length($buf)); |
| 53 | } | 64 | } |
| 54 | close(IN); | 65 | close(IN); |
diff --git a/src/lib/libssl/test/igetest.c b/src/lib/libssl/test/igetest.c index 95452d0965..a2578d09c5 100644 --- a/src/lib/libssl/test/igetest.c +++ b/src/lib/libssl/test/igetest.c | |||
| @@ -190,7 +190,7 @@ static struct bi_ige_test const bi_ige_test_vectors[] = { | |||
| 190 | 190 | ||
| 191 | static int run_test_vectors(void) | 191 | static int run_test_vectors(void) |
| 192 | { | 192 | { |
| 193 | int n; | 193 | unsigned int n; |
| 194 | int errs = 0; | 194 | int errs = 0; |
| 195 | 195 | ||
| 196 | for(n=0 ; n < sizeof(ige_test_vectors)/sizeof(ige_test_vectors[0]) ; ++n) | 196 | for(n=0 ; n < sizeof(ige_test_vectors)/sizeof(ige_test_vectors[0]) ; ++n) |
| @@ -292,7 +292,7 @@ int main(int argc, char **argv) | |||
| 292 | unsigned char iv[AES_BLOCK_SIZE*4]; | 292 | unsigned char iv[AES_BLOCK_SIZE*4]; |
| 293 | unsigned char saved_iv[AES_BLOCK_SIZE*4]; | 293 | unsigned char saved_iv[AES_BLOCK_SIZE*4]; |
| 294 | int err = 0; | 294 | int err = 0; |
| 295 | int n; | 295 | unsigned int n; |
| 296 | unsigned matches; | 296 | unsigned matches; |
| 297 | 297 | ||
| 298 | assert(BIG_TEST_SIZE >= TEST_SIZE); | 298 | assert(BIG_TEST_SIZE >= TEST_SIZE); |
