diff options
Diffstat (limited to 'src')
55 files changed, 2573 insertions, 108 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/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/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/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/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/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/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_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/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/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/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/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); |