aboutsummaryrefslogtreecommitdiff
path: root/crypto/dsa
diff options
context:
space:
mode:
authorRalf S. Engelschall <rse@openssl.org>1998-12-21 10:56:39 +0000
committerRalf S. Engelschall <rse@openssl.org>1998-12-21 10:56:39 +0000
commit58964a492275ca9a59a0cd9c8155cb2491b4b909 (patch)
treec7b16876a5789463bbbb468ef4829c8129b3d718 /crypto/dsa
parentd02b48c63a58ea4367a0e905979f140b7d090f86 (diff)
downloadopenssl-58964a492275ca9a59a0cd9c8155cb2491b4b909.zip
openssl-58964a492275ca9a59a0cd9c8155cb2491b4b909.tar.gz
openssl-58964a492275ca9a59a0cd9c8155cb2491b4b909.tar.bz2
Import of old SSLeay release: SSLeay 0.9.0b
Diffstat (limited to 'crypto/dsa')
-rw-r--r--crypto/dsa/Makefile.ssl2
-rw-r--r--crypto/dsa/dsa.h12
-rw-r--r--crypto/dsa/dsa_err.c10
-rw-r--r--crypto/dsa/dsa_gen.c27
-rw-r--r--crypto/dsa/dsa_key.c2
-rw-r--r--crypto/dsa/dsa_lib.c7
-rw-r--r--crypto/dsa/dsa_sign.c2
-rw-r--r--crypto/dsa/dsa_vrf.c2
-rw-r--r--crypto/dsa/dsagen.c11
-rw-r--r--crypto/dsa/dsatest.c22
10 files changed, 57 insertions, 40 deletions
diff --git a/crypto/dsa/Makefile.ssl b/crypto/dsa/Makefile.ssl
index 7b9c9cf..2cc4ddb 100644
--- a/crypto/dsa/Makefile.ssl
+++ b/crypto/dsa/Makefile.ssl
@@ -79,6 +79,6 @@ clean:
errors:
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
- perl ../err/err_genc.pl $(ERR).h $(ERRC).c
+ perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/crypto/dsa/dsa.h b/crypto/dsa/dsa.h
index e5dfafe..1ca87c1 100644
--- a/crypto/dsa/dsa.h
+++ b/crypto/dsa/dsa.h
@@ -1,5 +1,5 @@
/* crypto/dsa/dsa.h */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -106,7 +106,6 @@ typedef struct dsa_st
DSA * DSA_new(void);
int DSA_size(DSA *);
- /* DSA * DSA_generate_key(int bits, void (*callback)()); */
/* next 4 return -1 on error */
int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp);
int DSA_sign(int type,unsigned char *dgst,int dlen,
@@ -121,7 +120,8 @@ DSA * d2i_DSAPublicKey(DSA **a, unsigned char **pp, long length);
DSA * d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length);
DSA * d2i_DSAparams(DSA **a, unsigned char **pp, long length);
DSA * DSA_generate_parameters(int bits, unsigned char *seed,int seed_len,
- int *counter_ret, unsigned long *h_ret,void (*callback)());
+ int *counter_ret, unsigned long *h_ret,void
+ (*callback)(),char *cb_arg);
int DSA_generate_key(DSA *a);
int i2d_DSAPublicKey(DSA *a, unsigned char **pp);
int i2d_DSAPrivateKey(DSA *a, unsigned char **pp);
@@ -131,12 +131,12 @@ int i2d_DSAparams(DSA *a,unsigned char **pp);
int DSAparams_print(BIO *bp, DSA *x);
int DSA_print(BIO *bp, DSA *x, int off);
#endif
-#ifndef WIN16
+#ifndef NO_FP_API
int DSAparams_print_fp(FILE *fp, DSA *x);
int DSA_print_fp(FILE *bp, DSA *x, int off);
#endif
-int DSA_is_prime(BIGNUM *q,void (*callback)());
+int DSA_is_prime(BIGNUM *q,void (*callback)(),char *cb_arg);
#else
@@ -163,7 +163,7 @@ int DSA_is_prime();
int DSAparams_print();
int DSA_print();
-#ifndef WIN16
+#ifndef NO_FP_API
int DSAparams_print_fp();
int DSA_print_fp();
#endif
diff --git a/crypto/dsa/dsa_err.c b/crypto/dsa/dsa_err.c
index ec0699d..318e9f3 100644
--- a/crypto/dsa/dsa_err.c
+++ b/crypto/dsa/dsa_err.c
@@ -60,6 +60,7 @@
#include "dsa.h"
/* BEGIN ERROR CODES */
+#ifndef NO_ERR
static ERR_STRING_DATA DSA_str_functs[]=
{
{ERR_PACK(0,DSA_F_DSAPARAMS_PRINT,0), "DSAparams_print"},
@@ -80,14 +81,19 @@ static ERR_STRING_DATA DSA_str_reasons[]=
{0,NULL},
};
+#endif
+
void ERR_load_DSA_strings()
{
static int init=1;
- if (init)
- {
+ if (init);
+ {;
init=0;
+#ifndef NO_ERR
ERR_load_strings(ERR_LIB_DSA,DSA_str_functs);
ERR_load_strings(ERR_LIB_DSA,DSA_str_reasons);
+#endif
+
}
}
diff --git a/crypto/dsa/dsa_gen.c b/crypto/dsa/dsa_gen.c
index 2b80104..d7d30bf 100644
--- a/crypto/dsa/dsa_gen.c
+++ b/crypto/dsa/dsa_gen.c
@@ -1,5 +1,5 @@
/* crypto/dsa/dsa_gen.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -72,13 +72,15 @@
#include "dsa.h"
#include "rand.h"
-DSA *DSA_generate_parameters(bits,seed_in,seed_len,counter_ret,h_ret,callback)
+DSA *DSA_generate_parameters(bits,seed_in,seed_len,counter_ret,h_ret,callback,
+ cb_arg)
int bits;
unsigned char *seed_in;
int seed_len;
int *counter_ret;
unsigned long *h_ret;
void (*callback)();
+char *cb_arg;
{
int ok=0;
unsigned char seed[SHA_DIGEST_LENGTH];
@@ -120,7 +122,7 @@ void (*callback)();
for (;;)
{
/* step 1 */
- if (callback != NULL) callback(0,m++);
+ if (callback != NULL) callback(0,m++,cb_arg);
if (!seed_len)
RAND_bytes(seed,SHA_DIGEST_LENGTH);
@@ -147,13 +149,13 @@ void (*callback)();
if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,q)) abort();
/* step 4 */
- if (DSA_is_prime(q,callback) > 0) break;
+ if (DSA_is_prime(q,callback,cb_arg) > 0) break;
/* do a callback call */
/* step 5 */
}
- if (callback != NULL) callback(2,0);
- if (callback != NULL) callback(3,0);
+ if (callback != NULL) callback(2,0,cb_arg);
+ if (callback != NULL) callback(3,0,cb_arg);
/* step 6 */
counter=0;
@@ -196,7 +198,7 @@ void (*callback)();
if (BN_cmp(p,test) >= 0)
{
/* step 11 */
- if (DSA_is_prime(p,callback) > 0)
+ if (DSA_is_prime(p,callback,cb_arg) > 0)
goto end;
}
@@ -206,11 +208,11 @@ void (*callback)();
/* step 14 */
if (counter >= 4096) break;
- if (callback != NULL) callback(0,counter);
+ if (callback != NULL) callback(0,counter,cb_arg);
}
}
end:
- if (callback != NULL) callback(2,1);
+ if (callback != NULL) callback(2,1,cb_arg);
/* We now need to gernerate g */
/* Set r0=(p-1)/q */
@@ -227,7 +229,7 @@ end:
h++;
}
- if (callback != NULL) callback(3,1);
+ if (callback != NULL) callback(3,1,cb_arg);
ok=1;
err:
@@ -249,9 +251,10 @@ err:
return(ok?ret:NULL);
}
-int DSA_is_prime(w, callback)
+int DSA_is_prime(w, callback,cb_arg)
BIGNUM *w;
void (*callback)();
+char *cb_arg;
{
int ok= -1,j,i,n;
BN_CTX *ctx=NULL,*ctx2=NULL;
@@ -310,7 +313,7 @@ void (*callback)();
}
if (!BN_mod_mul(z,z,z,w,ctx)) goto err;
- if (callback != NULL) callback(1,j);
+ if (callback != NULL) callback(1,j,cb_arg);
}
}
diff --git a/crypto/dsa/dsa_key.c b/crypto/dsa/dsa_key.c
index 2c70248..d51ed93 100644
--- a/crypto/dsa/dsa_key.c
+++ b/crypto/dsa/dsa_key.c
@@ -1,5 +1,5 @@
/* crypto/dsa/dsa_key.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
diff --git a/crypto/dsa/dsa_lib.c b/crypto/dsa/dsa_lib.c
index e666db0..b647257 100644
--- a/crypto/dsa/dsa_lib.c
+++ b/crypto/dsa/dsa_lib.c
@@ -1,5 +1,5 @@
/* crypto/dsa/dsa_lib.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -64,7 +64,7 @@
#include "dsa.h"
#include "asn1.h"
-char *DSA_version="\0DSA part of SSLeay 0.8.1b 29-Jun-1998";
+char *DSA_version="\0DSA part of SSLeay 0.9.0b 29-Jun-1998";
DSA *DSA_new()
{
@@ -101,6 +101,9 @@ DSA *r;
if (r == NULL) return;
i=CRYPTO_add(&r->references,-1,CRYPTO_LOCK_DSA);
+#ifdef REF_PRINT
+ REF_PRINT("DSA",r);
+#endif
if (i > 0) return;
#ifdef REF_CHECK
if (i < 0)
diff --git a/crypto/dsa/dsa_sign.c b/crypto/dsa/dsa_sign.c
index ebb758f..6ca1c31 100644
--- a/crypto/dsa/dsa_sign.c
+++ b/crypto/dsa/dsa_sign.c
@@ -1,5 +1,5 @@
/* crypto/dsa/dsa_sign.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
diff --git a/crypto/dsa/dsa_vrf.c b/crypto/dsa/dsa_vrf.c
index a217f86..0f86098 100644
--- a/crypto/dsa/dsa_vrf.c
+++ b/crypto/dsa/dsa_vrf.c
@@ -1,5 +1,5 @@
/* crypto/dsa/dsa_vrf.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
diff --git a/crypto/dsa/dsagen.c b/crypto/dsa/dsagen.c
index 3422d87..20335de 100644
--- a/crypto/dsa/dsagen.c
+++ b/crypto/dsa/dsagen.c
@@ -1,5 +1,5 @@
/* crypto/dsa/dsagen.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -98,8 +98,15 @@ main()
unsigned char seed_buf[20];
DSA *dsa;
int counter,h;
+ BIO *bio_err=NULL;
+
+ if (bio_err == NULL)
+ bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
memcpy(seed_buf,seed,20);
- dsa=DSA_generate_key(1024,seed,20,&counter,&h,cb);
+ dsa=DSA_generate_parameters(1024,seed,20,&counter,&h,cb);
+
+ if (dsa == NULL)
+ DSA_print(bio_err,dsa,0);
}
diff --git a/crypto/dsa/dsatest.c b/crypto/dsa/dsatest.c
index 894d2db..39bb712 100644
--- a/crypto/dsa/dsatest.c
+++ b/crypto/dsa/dsatest.c
@@ -1,5 +1,5 @@
/* crypto/dsa/dsatest.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -61,16 +61,12 @@
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef WIN16
-#define APPS_WIN16
-#endif
#include "crypto.h"
#include "rand.h"
#include "bio.h"
#include "err.h"
#include "dsa.h"
-
-#ifdef WIN16
+#ifdef WINDOWS
#include "../bio/bss_file.c"
#endif
@@ -81,7 +77,7 @@
#endif
#ifndef NOPROTO
-static void MS_CALLBACK dsa_cb(int p, int n);
+static void MS_CALLBACK dsa_cb(int p, int n, char *arg);
#else
static void MS_CALLBACK dsa_cb();
#endif
@@ -135,7 +131,8 @@ char **argv;
BIO_printf(bio_err,"test generation of DSA parameters\n");
BIO_printf(bio_err,"expect '.*' followed by 5 lines of '.'s and '+'s\n");
- dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb);
+ dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb,
+ (char *)bio_err);
BIO_printf(bio_err,"seed\n");
for (i=0; i<20; i+=4)
@@ -192,9 +189,10 @@ end:
return(0);
}
-static void MS_CALLBACK dsa_cb(p, n)
+static void MS_CALLBACK dsa_cb(p, n, arg)
int p;
int n;
+char *arg;
{
char c='*';
static int ok=0,num=0;
@@ -203,12 +201,12 @@ int n;
if (p == 1) c='+';
if (p == 2) { c='*'; ok++; }
if (p == 3) c='\n';
- BIO_write(bio_err,&c,1);
- BIO_flush(bio_err);
+ BIO_write((BIO *)arg,&c,1);
+ BIO_flush((BIO *)arg);
if (!ok && (p == 0) && (num > 1))
{
- BIO_printf(bio_err,"error in dsatest\n");
+ BIO_printf((BIO *)arg,"error in dsatest\n");
exit(1);
}
}