summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto
diff options
context:
space:
mode:
authordjm <>2009-01-09 12:14:11 +0000
committerdjm <>2009-01-09 12:14:11 +0000
commit30562050421d947c3eb3c10edde6e87730b17471 (patch)
treea92ed8bb9450f2391bf3955cbfb87d5f3cf9e051 /src/lib/libcrypto
parentd895739bce8a14b03d66ef79acb062db0e1d7b41 (diff)
parenta0fdc9ec41594852f67ec77dfad9cb06bacc4186 (diff)
downloadopenbsd-30562050421d947c3eb3c10edde6e87730b17471.tar.gz
openbsd-30562050421d947c3eb3c10edde6e87730b17471.tar.bz2
openbsd-30562050421d947c3eb3c10edde6e87730b17471.zip
This commit was generated by cvs2git to track changes on a CVS vendor
branch.
Diffstat (limited to 'src/lib/libcrypto')
-rwxr-xr-xsrc/lib/libcrypto/aes/asm/aes-x86_64.pl7
-rw-r--r--src/lib/libcrypto/asn1/asn1_gen.c2
-rw-r--r--src/lib/libcrypto/bn/bn_x931p.c40
-rw-r--r--src/lib/libcrypto/buffer/buf_str.c116
-rw-r--r--src/lib/libcrypto/camellia/camellia.h5
-rw-r--r--src/lib/libcrypto/camellia/cmll_misc.c13
-rw-r--r--src/lib/libcrypto/cms/cms_sd.c2
-rw-r--r--src/lib/libcrypto/ec/ec_key.c16
-rw-r--r--src/lib/libcrypto/engine/eng_padlock.c4
-rw-r--r--src/lib/libcrypto/evp/e_camellia.c2
-rw-r--r--src/lib/libcrypto/o_init.c86
-rw-r--r--src/lib/libcrypto/rsa/rsa_pss.c6
-rw-r--r--src/lib/libcrypto/rsa/rsa_x931.c2
-rw-r--r--src/lib/libcrypto/sha/sha256.c10
-rw-r--r--src/lib/libcrypto/sha/sha512.c12
-rw-r--r--src/lib/libcrypto/x509/x509_vpm.c2
-rw-r--r--src/lib/libcrypto/x509v3/pcy_cache.c2
-rw-r--r--src/lib/libcrypto/x509v3/pcy_int.h2
-rw-r--r--src/lib/libcrypto/x509v3/pcy_lib.c2
-rw-r--r--src/lib/libcrypto/x509v3/pcy_map.c2
-rw-r--r--src/lib/libcrypto/x509v3/pcy_node.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_ncons.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_pcons.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_pmaps.c2
24 files changed, 282 insertions, 59 deletions
diff --git a/src/lib/libcrypto/aes/asm/aes-x86_64.pl b/src/lib/libcrypto/aes/asm/aes-x86_64.pl
index 44e0bf8cae..f616f1751f 100755
--- a/src/lib/libcrypto/aes/asm/aes-x86_64.pl
+++ b/src/lib/libcrypto/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/libcrypto/asn1/asn1_gen.c b/src/lib/libcrypto/asn1/asn1_gen.c
index 26c832781e..2da38292c8 100644
--- a/src/lib/libcrypto/asn1/asn1_gen.c
+++ b/src/lib/libcrypto/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/libcrypto/bn/bn_x931p.c b/src/lib/libcrypto/bn/bn_x931p.c
index c64410dd3a..04c5c874ec 100644
--- a/src/lib/libcrypto/bn/bn_x931p.c
+++ b/src/lib/libcrypto/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
72static int bn_x931_derive_pi(BIGNUM *pi, const BIGNUM *Xpi, BN_CTX *ctx, 69static 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
101int BN_X931_derive_prime(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, 96int 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
251int BN_X931_generate_prime(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, 243int 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/libcrypto/buffer/buf_str.c b/src/lib/libcrypto/buffer/buf_str.c
new file mode 100644
index 0000000000..28dd1e401e
--- /dev/null
+++ b/src/lib/libcrypto/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
60char *BUF_strdup(const char *str)
61 {
62 if (str == NULL) return(NULL);
63 return BUF_strndup(str, strlen(str));
64 }
65
66char *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
82void *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
97size_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
110size_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/libcrypto/camellia/camellia.h b/src/lib/libcrypto/camellia/camellia.h
index 3c8a359543..b8a8b6e10b 100644
--- a/src/lib/libcrypto/camellia/camellia.h
+++ b/src/lib/libcrypto/camellia/camellia.h
@@ -87,6 +87,11 @@ struct camellia_key_st
87 87
88typedef struct camellia_key_st CAMELLIA_KEY; 88typedef struct camellia_key_st CAMELLIA_KEY;
89 89
90#ifdef OPENSSL_FIPS
91int private_Camellia_set_key(const unsigned char *userKey, const int bits,
92 CAMELLIA_KEY *key);
93#endif
94
90int Camellia_set_key(const unsigned char *userKey, const int bits, 95int 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/libcrypto/camellia/cmll_misc.c b/src/lib/libcrypto/camellia/cmll_misc.c
index f1047b54e0..2cd7aba9bb 100644
--- a/src/lib/libcrypto/camellia/cmll_misc.c
+++ b/src/lib/libcrypto/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
56const char CAMELLIA_version[]="CAMELLIA" OPENSSL_VERSION_PTEXT; 60const char CAMELLIA_version[]="CAMELLIA" OPENSSL_VERSION_PTEXT;
57 61
58int Camellia_set_key(const unsigned char *userKey, const int bits, 62int 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 }
70int 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/libcrypto/cms/cms_sd.c b/src/lib/libcrypto/cms/cms_sd.c
index 591bfbec33..cdac3b870d 100644
--- a/src/lib/libcrypto/cms/cms_sd.c
+++ b/src/lib/libcrypto/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/libcrypto/ec/ec_key.c b/src/lib/libcrypto/ec/ec_key.c
index 3d6c900b95..12fb0e6d6d 100644
--- a/src/lib/libcrypto/ec/ec_key.c
+++ b/src/lib/libcrypto/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)
366err: 360err:
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/libcrypto/engine/eng_padlock.c b/src/lib/libcrypto/engine/eng_padlock.c
index 1ba9d85db4..743558ab33 100644
--- a/src/lib/libcrypto/engine/eng_padlock.c
+++ b/src/lib/libcrypto/engine/eng_padlock.c
@@ -234,8 +234,8 @@ padlock_bind_fn(ENGINE *e, const char *id)
234 return 1; 234 return 1;
235} 235}
236 236
237IMPLEMENT_DYNAMIC_CHECK_FN (); 237IMPLEMENT_DYNAMIC_CHECK_FN ()
238IMPLEMENT_DYNAMIC_BIND_FN (padlock_bind_fn); 238IMPLEMENT_DYNAMIC_BIND_FN (padlock_bind_fn)
239#endif /* DYNAMIC_ENGINE */ 239#endif /* DYNAMIC_ENGINE */
240 240
241/* ===== Here comes the "real" engine ===== */ 241/* ===== Here comes the "real" engine ===== */
diff --git a/src/lib/libcrypto/evp/e_camellia.c b/src/lib/libcrypto/evp/e_camellia.c
index a7b40d1c60..365d397164 100644
--- a/src/lib/libcrypto/evp/e_camellia.c
+++ b/src/lib/libcrypto/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
98IMPLEMENT_CAMELLIA_CFBR(128,1) 98IMPLEMENT_CAMELLIA_CFBR(128,1)
99IMPLEMENT_CAMELLIA_CFBR(192,1) 99IMPLEMENT_CAMELLIA_CFBR(192,1)
diff --git a/src/lib/libcrypto/o_init.c b/src/lib/libcrypto/o_init.c
new file mode 100644
index 0000000000..00ed65a6cf
--- /dev/null
+++ b/src/lib/libcrypto/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
66void 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/libcrypto/rsa/rsa_pss.c b/src/lib/libcrypto/rsa/rsa_pss.c
index e19d18c5b9..9b993aca49 100644
--- a/src/lib/libcrypto/rsa/rsa_pss.c
+++ b/src/lib/libcrypto/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/libcrypto/rsa/rsa_x931.c b/src/lib/libcrypto/rsa/rsa_x931.c
index e918654176..21548e37ed 100644
--- a/src/lib/libcrypto/rsa/rsa_x931.c
+++ b/src/lib/libcrypto/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/libcrypto/sha/sha256.c b/src/lib/libcrypto/sha/sha256.c
index 867f90cc97..3256a83e98 100644
--- a/src/lib/libcrypto/sha/sha256.c
+++ b/src/lib/libcrypto/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
17const char SHA256_version[]="SHA-256" OPENSSL_VERSION_PTEXT; 21const char SHA256_version[]="SHA-256" OPENSSL_VERSION_PTEXT;
18 22
19int SHA224_Init (SHA256_CTX *c) 23int 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
30int SHA256_Init (SHA256_CTX *c) 37int 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/libcrypto/sha/sha512.c b/src/lib/libcrypto/sha/sha512.c
index 987fc07c99..f5ed468b85 100644
--- a/src/lib/libcrypto/sha/sha512.c
+++ b/src/lib/libcrypto/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
62int SHA384_Init (SHA512_CTX *c) 66int 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
77int SHA512_Init (SHA512_CTX *c) 84int 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/libcrypto/x509/x509_vpm.c b/src/lib/libcrypto/x509/x509_vpm.c
index e9db6d62a7..c92e65936f 100644
--- a/src/lib/libcrypto/x509/x509_vpm.c
+++ b/src/lib/libcrypto/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/libcrypto/x509v3/pcy_cache.c b/src/lib/libcrypto/x509v3/pcy_cache.c
index c18beb89f5..1030931b71 100644
--- a/src/lib/libcrypto/x509v3/pcy_cache.c
+++ b/src/lib/libcrypto/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/libcrypto/x509v3/pcy_int.h b/src/lib/libcrypto/x509v3/pcy_int.h
index ba62a209da..3780de4fcd 100644
--- a/src/lib/libcrypto/x509v3/pcy_int.h
+++ b/src/lib/libcrypto/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/libcrypto/x509v3/pcy_lib.c b/src/lib/libcrypto/x509v3/pcy_lib.c
index dae4840bc5..93bfd92703 100644
--- a/src/lib/libcrypto/x509v3/pcy_lib.c
+++ b/src/lib/libcrypto/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/libcrypto/x509v3/pcy_map.c b/src/lib/libcrypto/x509v3/pcy_map.c
index 35221e8ba8..f28796e6d4 100644
--- a/src/lib/libcrypto/x509v3/pcy_map.c
+++ b/src/lib/libcrypto/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/libcrypto/x509v3/pcy_node.c b/src/lib/libcrypto/x509v3/pcy_node.c
index dcc1554e29..6587cb05ab 100644
--- a/src/lib/libcrypto/x509v3/pcy_node.c
+++ b/src/lib/libcrypto/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/libcrypto/x509v3/v3_ncons.c b/src/lib/libcrypto/x509v3/v3_ncons.c
index 42e7f5a879..4e706be3e1 100644
--- a/src/lib/libcrypto/x509v3/v3_ncons.c
+++ b/src/lib/libcrypto/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/libcrypto/x509v3/v3_pcons.c b/src/lib/libcrypto/x509v3/v3_pcons.c
index 13248c2ada..86c0ff70e6 100644
--- a/src/lib/libcrypto/x509v3/v3_pcons.c
+++ b/src/lib/libcrypto/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/libcrypto/x509v3/v3_pmaps.c b/src/lib/libcrypto/x509v3/v3_pmaps.c
index 626303264f..da03bbc35d 100644
--- a/src/lib/libcrypto/x509v3/v3_pmaps.c
+++ b/src/lib/libcrypto/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/* ====================================================================