summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto
diff options
context:
space:
mode:
authormarkus <>2002-09-05 22:12:12 +0000
committermarkus <>2002-09-05 22:12:12 +0000
commite08fb7998d733407336e83a299f140b0c1d2fcd3 (patch)
tree64de5de3b0be4adfc5050b6f785b6975c564b730 /src/lib/libcrypto
parentb200d1ec45aafc7c92b197a4b605e34834d74f1d (diff)
downloadopenbsd-e08fb7998d733407336e83a299f140b0c1d2fcd3.tar.gz
openbsd-e08fb7998d733407336e83a299f140b0c1d2fcd3.tar.bz2
openbsd-e08fb7998d733407336e83a299f140b0c1d2fcd3.zip
merge with 0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto')
-rw-r--r--src/lib/libcrypto/asn1/a_utctm.c3
-rw-r--r--src/lib/libcrypto/des/fcrypt.c8
-rw-r--r--src/lib/libcrypto/des/read_pwd.c2
-rw-r--r--src/lib/libcrypto/dsa/dsa_key.c4
-rw-r--r--src/lib/libcrypto/dsa/dsa_ossl.c56
-rw-r--r--src/lib/libcrypto/engine/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/engine/eng_all.c5
-rw-r--r--src/lib/libcrypto/engine/engine.h2
-rw-r--r--src/lib/libcrypto/evp/evp_test.c4
-rw-r--r--src/lib/libcrypto/objects/Makefile.ssl1
-rw-r--r--src/lib/libcrypto/objects/obj_dat.pl3
-rw-r--r--src/lib/libcrypto/rand/randfile.c14
-rw-r--r--src/lib/libcrypto/util/domd4
13 files changed, 31 insertions, 77 deletions
diff --git a/src/lib/libcrypto/asn1/a_utctm.c b/src/lib/libcrypto/asn1/a_utctm.c
index dbb4a42c9d..ed2d827db2 100644
--- a/src/lib/libcrypto/asn1/a_utctm.c
+++ b/src/lib/libcrypto/asn1/a_utctm.c
@@ -222,7 +222,6 @@ ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
222int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t) 222int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t)
223 { 223 {
224 struct tm *tm; 224 struct tm *tm;
225 struct tm data;
226 int offset; 225 int offset;
227 int year; 226 int year;
228 227
@@ -239,7 +238,7 @@ int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t)
239 238
240 t -= offset*60; /* FIXME: may overflow in extreme cases */ 239 t -= offset*60; /* FIXME: may overflow in extreme cases */
241 240
242 tm = OPENSSL_gmtime(&t, &data); 241 { struct tm data; tm = OPENSSL_gmtime(&t, &data); }
243 242
244#define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1 243#define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1
245 year = g2(s->data); 244 year = g2(s->data);
diff --git a/src/lib/libcrypto/des/fcrypt.c b/src/lib/libcrypto/des/fcrypt.c
index 387d97f28d..2758c32656 100644
--- a/src/lib/libcrypto/des/fcrypt.c
+++ b/src/lib/libcrypto/des/fcrypt.c
@@ -1,5 +1,13 @@
1/* NOCW */ 1/* NOCW */
2#include <stdio.h> 2#include <stdio.h>
3#ifdef _OSD_POSIX
4#ifndef CHARSET_EBCDIC
5#define CHARSET_EBCDIC 1
6#endif
7#endif
8#ifdef CHARSET_EBCDIC
9#include <openssl/ebcdic.h>
10#endif
3 11
4/* This version of crypt has been developed from my MIT compatible 12/* This version of crypt has been developed from my MIT compatible
5 * DES library. 13 * DES library.
diff --git a/src/lib/libcrypto/des/read_pwd.c b/src/lib/libcrypto/des/read_pwd.c
index 54e0e2e6b6..00000190f8 100644
--- a/src/lib/libcrypto/des/read_pwd.c
+++ b/src/lib/libcrypto/des/read_pwd.c
@@ -211,7 +211,7 @@ static int noecho_fgets(char *buf, int size, FILE *tty);
211#endif 211#endif
212static jmp_buf save; 212static jmp_buf save;
213 213
214int _ossl_old_des_read_pw_string(char *buf, int length, const char *prompt, 214int des_read_pw_string(char *buf, int length, const char *prompt,
215 int verify) 215 int verify)
216 { 216 {
217 char buff[BUFSIZ]; 217 char buff[BUFSIZ];
diff --git a/src/lib/libcrypto/dsa/dsa_key.c b/src/lib/libcrypto/dsa/dsa_key.c
index bf718c1c6d..ef87c3e637 100644
--- a/src/lib/libcrypto/dsa/dsa_key.c
+++ b/src/lib/libcrypto/dsa/dsa_key.c
@@ -64,8 +64,6 @@
64#include <openssl/dsa.h> 64#include <openssl/dsa.h>
65#include <openssl/rand.h> 65#include <openssl/rand.h>
66 66
67extern int __BN_rand_range(BIGNUM *r, BIGNUM *range);
68
69int DSA_generate_key(DSA *dsa) 67int DSA_generate_key(DSA *dsa)
70 { 68 {
71 int ok=0; 69 int ok=0;
@@ -82,7 +80,7 @@ int DSA_generate_key(DSA *dsa)
82 priv_key=dsa->priv_key; 80 priv_key=dsa->priv_key;
83 81
84 do 82 do
85 if (!__BN_rand_range(priv_key,dsa->q)) goto err; 83 if (!BN_rand_range(priv_key,dsa->q)) goto err;
86 while (BN_is_zero(priv_key)); 84 while (BN_is_zero(priv_key));
87 85
88 if (dsa->pub_key == NULL) 86 if (dsa->pub_key == NULL)
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c
index 07addc94d9..37dd5fc994 100644
--- a/src/lib/libcrypto/dsa/dsa_ossl.c
+++ b/src/lib/libcrypto/dsa/dsa_ossl.c
@@ -66,8 +66,6 @@
66#include <openssl/asn1.h> 66#include <openssl/asn1.h>
67#include <openssl/engine.h> 67#include <openssl/engine.h>
68 68
69int __BN_rand_range(BIGNUM *r, BIGNUM *range);
70
71static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); 69static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
72static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); 70static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp);
73static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, 71static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
@@ -193,7 +191,7 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
193 191
194 /* Get random k */ 192 /* Get random k */
195 do 193 do
196 if (!__BN_rand_range(&k, dsa->q)) goto err; 194 if (!BN_rand_range(&k, dsa->q)) goto err;
197 while (BN_is_zero(&k)); 195 while (BN_is_zero(&k));
198 196
199 if ((dsa->method_mont_p == NULL) && (dsa->flags & DSA_FLAG_CACHE_MONT_P)) 197 if ((dsa->method_mont_p == NULL) && (dsa->flags & DSA_FLAG_CACHE_MONT_P))
@@ -344,55 +342,3 @@ static int dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
344{ 342{
345 return BN_mod_exp_mont(r, a, p, m, ctx, m_ctx); 343 return BN_mod_exp_mont(r, a, p, m, ctx, m_ctx);
346} 344}
347
348
349/* random number r: 0 <= r < range */
350int __BN_rand_range(BIGNUM *r, BIGNUM *range)
351 {
352 int n;
353
354 if (range->neg || BN_is_zero(range))
355 {
356 /* BNerr(BN_F_BN_RAND_RANGE, BN_R_INVALID_RANGE); */
357 return 0;
358 }
359
360 n = BN_num_bits(range); /* n > 0 */
361
362 if (n == 1)
363 {
364 if (!BN_zero(r)) return 0;
365 }
366 else if (BN_is_bit_set(range, n - 2))
367 {
368 do
369 {
370 /* range = 11..._2, so each iteration succeeds with probability >= .75 */
371 if (!BN_rand(r, n, -1, 0)) return 0;
372 }
373 while (BN_cmp(r, range) >= 0);
374 }
375 else
376 {
377 /* range = 10..._2,
378 * so 3*range (= 11..._2) is exactly one bit longer than range */
379 do
380 {
381 if (!BN_rand(r, n + 1, -1, 0)) return 0;
382 /* If r < 3*range, use r := r MOD range
383 * (which is either r, r - range, or r - 2*range).
384 * Otherwise, iterate once more.
385 * Since 3*range = 11..._2, each iteration succeeds with
386 * probability >= .75. */
387 if (BN_cmp(r ,range) >= 0)
388 {
389 if (!BN_sub(r, r, range)) return 0;
390 if (BN_cmp(r, range) >= 0)
391 if (!BN_sub(r, r, range)) return 0;
392 }
393 }
394 while (BN_cmp(r, range) >= 0);
395 }
396
397 return 1;
398 }
diff --git a/src/lib/libcrypto/engine/Makefile.ssl b/src/lib/libcrypto/engine/Makefile.ssl
index 8ee3b7d2dd..5172028f93 100644
--- a/src/lib/libcrypto/engine/Makefile.ssl
+++ b/src/lib/libcrypto/engine/Makefile.ssl
@@ -74,7 +74,7 @@ tags:
74 74
75errors: 75errors:
76 $(PERL) $(TOP)/util/mkerr.pl -conf hw.ec \ 76 $(PERL) $(TOP)/util/mkerr.pl -conf hw.ec \
77 -nostatic -staticloader -write hw_*.c 77 -nostatic -staticloader -write hw_*.c; \
78 78
79tests: 79tests:
80 80
diff --git a/src/lib/libcrypto/engine/eng_all.c b/src/lib/libcrypto/engine/eng_all.c
index a35b3db9e8..bc50465422 100644
--- a/src/lib/libcrypto/engine/eng_all.c
+++ b/src/lib/libcrypto/engine/eng_all.c
@@ -96,6 +96,9 @@ void ENGINE_load_builtin_engines(void)
96#ifndef OPENSSL_NO_HW_SUREWARE 96#ifndef OPENSSL_NO_HW_SUREWARE
97 ENGINE_load_sureware(); 97 ENGINE_load_sureware();
98#endif 98#endif
99#ifndef OPENSSL_NO_HW_4758_CCA
100 ENGINE_load_4758cca();
101#endif
99#ifdef OPENSSL_OPENBSD_DEV_CRYPTO 102#ifdef OPENSSL_OPENBSD_DEV_CRYPTO
100 ENGINE_load_openbsd_dev_crypto(); 103 ENGINE_load_openbsd_dev_crypto();
101#endif 104#endif
@@ -114,5 +117,3 @@ void ENGINE_setup_openbsd(void) {
114 openbsd_default_loaded=1; 117 openbsd_default_loaded=1;
115} 118}
116#endif 119#endif
117
118
diff --git a/src/lib/libcrypto/engine/engine.h b/src/lib/libcrypto/engine/engine.h
index 97f5de9e12..fd17ff616d 100644
--- a/src/lib/libcrypto/engine/engine.h
+++ b/src/lib/libcrypto/engine/engine.h
@@ -312,7 +312,7 @@ void ENGINE_load_builtin_engines(void);
312#ifdef __OpenBSD__ 312#ifdef __OpenBSD__
313void ENGINE_load_cryptodev(void); 313void ENGINE_load_cryptodev(void);
314#endif 314#endif
315 315
316/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation 316/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation
317 * "registry" handling. */ 317 * "registry" handling. */
318unsigned int ENGINE_get_table_flags(void); 318unsigned int ENGINE_get_table_flags(void);
diff --git a/src/lib/libcrypto/evp/evp_test.c b/src/lib/libcrypto/evp/evp_test.c
index 90294ef686..1bfffb34cf 100644
--- a/src/lib/libcrypto/evp/evp_test.c
+++ b/src/lib/libcrypto/evp/evp_test.c
@@ -118,7 +118,7 @@ static char *sstrsep(char **string, const char *delim)
118 } 118 }
119 119
120static unsigned char *ustrsep(char **p,const char *sep) 120static unsigned char *ustrsep(char **p,const char *sep)
121 { return (unsigned char *)sstrsep(p,sep); } 121 { return (unsigned char *)sstrsep((char **)p,sep); }
122 122
123static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, 123static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn,
124 const unsigned char *iv,int in, 124 const unsigned char *iv,int in,
@@ -358,7 +358,7 @@ int main(int argc,char **argv)
358 p[-1] = '\0'; 358 p[-1] = '\0';
359 encdec = -1; 359 encdec = -1;
360 } else { 360 } else {
361 encdec = atoi(sstrsep(&p,"\n")); 361 encdec = atoi(strsep(&p,"\n"));
362 } 362 }
363 363
364 364
diff --git a/src/lib/libcrypto/objects/Makefile.ssl b/src/lib/libcrypto/objects/Makefile.ssl
index 1e990107d3..a9f01ffc0d 100644
--- a/src/lib/libcrypto/objects/Makefile.ssl
+++ b/src/lib/libcrypto/objects/Makefile.ssl
@@ -15,6 +15,7 @@ MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) 15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
17AR= ar r 17AR= ar r
18PERL= perl
18 19
19CFLAGS= $(INCLUDES) $(CFLAG) 20CFLAGS= $(INCLUDES) $(CFLAG)
20 21
diff --git a/src/lib/libcrypto/objects/obj_dat.pl b/src/lib/libcrypto/objects/obj_dat.pl
index 85ab209809..d0371661f9 100644
--- a/src/lib/libcrypto/objects/obj_dat.pl
+++ b/src/lib/libcrypto/objects/obj_dat.pl
@@ -1,4 +1,7 @@
1#!/usr/local/bin/perl 1#!/usr/local/bin/perl
2
3# fixes bug in floating point emulation on sparc64 when
4# this script produces off-by-one output on sparc64
2use integer; 5use integer;
3 6
4sub obj_cmp 7sub obj_cmp
diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c
index 4b221e08f5..1c3e68ef31 100644
--- a/src/lib/libcrypto/rand/randfile.c
+++ b/src/lib/libcrypto/rand/randfile.c
@@ -99,12 +99,11 @@ int RAND_load_file(const char *file, long bytes)
99 if (file == NULL) return(0); 99 if (file == NULL) return(0);
100 100
101 i=stat(file,&sb); 101 i=stat(file,&sb);
102 if (i < 0) { 102 /* If the state fails, put some crap in anyway */
103 /* If the state fails, put some crap in anyway */ 103 RAND_add(&sb,sizeof(sb),0);
104 RAND_add(&sb,sizeof(sb),0); 104 if (i < 0) return(0);
105 return(0);
106 }
107 if (bytes == 0) return(ret); 105 if (bytes == 0) return(ret);
106
108 in=fopen(file,"rb"); 107 in=fopen(file,"rb");
109 if (in == NULL) goto err; 108 if (in == NULL) goto err;
110 if (sb.st_mode & (S_IFBLK | S_IFCHR)) { 109 if (sb.st_mode & (S_IFBLK | S_IFCHR)) {
@@ -218,12 +217,12 @@ err:
218 217
219const char *RAND_file_name(char *buf, size_t size) 218const char *RAND_file_name(char *buf, size_t size)
220 { 219 {
221 char *s = NULL; 220 char *s=NULL;
222 int ok = 0; 221 int ok = 0;
223 struct stat sb; 222 struct stat sb;
224 223
225 if (issetugid() == 0) 224 if (issetugid() == 0)
226 s = getenv("RANDFILE"); 225 s=getenv("RANDFILE");
227 if (s != NULL && *s && strlen(s) + 1 < size) 226 if (s != NULL && *s && strlen(s) + 1 < size)
228 { 227 {
229 strlcpy(buf,s,size); 228 strlcpy(buf,s,size);
@@ -272,4 +271,3 @@ const char *RAND_file_name(char *buf, size_t size)
272#endif 271#endif
273 return(buf); 272 return(buf);
274 } 273 }
275
diff --git a/src/lib/libcrypto/util/domd b/src/lib/libcrypto/util/domd
index 8cbe383c16..aa99cb0523 100644
--- a/src/lib/libcrypto/util/domd
+++ b/src/lib/libcrypto/util/domd
@@ -18,11 +18,11 @@ if [ "$MAKEDEPEND" = "gcc" ]; then
18 sed -e '/^# DO NOT DELETE.*/,$d' < Makefile.ssl > Makefile.tmp 18 sed -e '/^# DO NOT DELETE.*/,$d' < Makefile.ssl > Makefile.tmp
19 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' >> Makefile.tmp 19 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' >> Makefile.tmp
20 gcc -D OPENSSL_DOING_MAKEDEPEND -M $@ >> Makefile.tmp 20 gcc -D OPENSSL_DOING_MAKEDEPEND -M $@ >> Makefile.tmp
21 ${PERL} $TOP/util/clean-depend.pl < Makefile.tmp > Makefile.new 21 perl $TOP/util/clean-depend.pl < Makefile.tmp > Makefile.new
22 rm -f Makefile.tmp 22 rm -f Makefile.tmp
23else 23else
24 ${MAKEDEPEND} -D OPENSSL_DOING_MAKEDEPEND -f Makefile.ssl $@ 24 ${MAKEDEPEND} -D OPENSSL_DOING_MAKEDEPEND -f Makefile.ssl $@
25 ${PERL} $TOP/util/clean-depend.pl < Makefile.ssl > Makefile.new 25 perl $TOP/util/clean-depend.pl < Makefile.ssl > Makefile.new
26fi 26fi
27mv Makefile.new Makefile.ssl 27mv Makefile.new Makefile.ssl
28# unfake the presence of Kerberos 28# unfake the presence of Kerberos