Update any code that was using deprecated functions so that everything builds
and links with OPENSSL_NO_DEPRECATED defined.
This commit is contained in:
parent
9d473aa2e4
commit
2aaec9cced
4
CHANGES
4
CHANGES
@ -5,7 +5,9 @@
|
|||||||
Changes between 0.9.7c and 0.9.8 [xx XXX xxxx]
|
Changes between 0.9.7c and 0.9.8 [xx XXX xxxx]
|
||||||
|
|
||||||
*) Ensure that deprecated functions do not get compiled when
|
*) Ensure that deprecated functions do not get compiled when
|
||||||
OPENSSL_NO_DEPRECATED is defined.
|
OPENSSL_NO_DEPRECATED is defined. Some "openssl" subcommands and a few of
|
||||||
|
the self-tests were still using deprecated key-generation functions so
|
||||||
|
these have been updated also.
|
||||||
[Geoff Thorpe]
|
[Geoff Thorpe]
|
||||||
|
|
||||||
*) Reorganise PKCS#7 code to separate the digest location functionality
|
*) Reorganise PKCS#7 code to separate the digest location functionality
|
||||||
|
@ -142,7 +142,7 @@
|
|||||||
* -C
|
* -C
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void MS_CALLBACK dh_cb(int p, int n, void *arg);
|
static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb);
|
||||||
|
|
||||||
int MAIN(int, char **);
|
int MAIN(int, char **);
|
||||||
|
|
||||||
@ -294,6 +294,8 @@ bad:
|
|||||||
|
|
||||||
if(num) {
|
if(num) {
|
||||||
|
|
||||||
|
BN_GENCB cb;
|
||||||
|
BN_GENCB_set(&cb, dh_cb, bio_err);
|
||||||
if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL)
|
if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL)
|
||||||
{
|
{
|
||||||
BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
|
BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
|
||||||
@ -305,12 +307,13 @@ bad:
|
|||||||
#ifndef OPENSSL_NO_DSA
|
#ifndef OPENSSL_NO_DSA
|
||||||
if (dsaparam)
|
if (dsaparam)
|
||||||
{
|
{
|
||||||
DSA *dsa;
|
DSA *dsa = DSA_new();
|
||||||
|
|
||||||
BIO_printf(bio_err,"Generating DSA parameters, %d bit long prime\n",num);
|
BIO_printf(bio_err,"Generating DSA parameters, %d bit long prime\n",num);
|
||||||
dsa = DSA_generate_parameters(num, NULL, 0, NULL, NULL, dh_cb, bio_err);
|
if(!dsa || !DSA_generate_parameters_ex(dsa, num,
|
||||||
if (dsa == NULL)
|
NULL, 0, NULL, NULL, &cb))
|
||||||
{
|
{
|
||||||
|
if(dsa) DSA_free(dsa);
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
@ -326,12 +329,12 @@ bad:
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
dh = DH_new();
|
||||||
BIO_printf(bio_err,"Generating DH parameters, %d bit long safe prime, generator %d\n",num,g);
|
BIO_printf(bio_err,"Generating DH parameters, %d bit long safe prime, generator %d\n",num,g);
|
||||||
BIO_printf(bio_err,"This is going to take a long time\n");
|
BIO_printf(bio_err,"This is going to take a long time\n");
|
||||||
dh=DH_generate_parameters(num,g,dh_cb,bio_err);
|
if(!dh || !DH_generate_parameters_ex(dh, num, g, &cb))
|
||||||
|
|
||||||
if (dh == NULL)
|
|
||||||
{
|
{
|
||||||
|
if(dh) DH_free(dh);
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
@ -534,7 +537,7 @@ end:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dh_cb is identical to dsa_cb in apps/dsaparam.c */
|
/* dh_cb is identical to dsa_cb in apps/dsaparam.c */
|
||||||
static void MS_CALLBACK dh_cb(int p, int n, void *arg)
|
static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb)
|
||||||
{
|
{
|
||||||
char c='*';
|
char c='*';
|
||||||
|
|
||||||
@ -542,11 +545,12 @@ static void MS_CALLBACK dh_cb(int p, int n, void *arg)
|
|||||||
if (p == 1) c='+';
|
if (p == 1) c='+';
|
||||||
if (p == 2) c='*';
|
if (p == 2) c='*';
|
||||||
if (p == 3) c='\n';
|
if (p == 3) c='\n';
|
||||||
BIO_write((BIO *)arg,&c,1);
|
BIO_write(cb->arg,&c,1);
|
||||||
(void)BIO_flush((BIO *)arg);
|
(void)BIO_flush(cb->arg);
|
||||||
#ifdef LINT
|
#ifdef LINT
|
||||||
p=n;
|
p=n;
|
||||||
#endif
|
#endif
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
15
apps/gendh.c
15
apps/gendh.c
@ -81,12 +81,13 @@
|
|||||||
#undef PROG
|
#undef PROG
|
||||||
#define PROG gendh_main
|
#define PROG gendh_main
|
||||||
|
|
||||||
static void MS_CALLBACK dh_cb(int p, int n, void *arg);
|
static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb);
|
||||||
|
|
||||||
int MAIN(int, char **);
|
int MAIN(int, char **);
|
||||||
|
|
||||||
int MAIN(int argc, char **argv)
|
int MAIN(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
BN_GENCB cb;
|
||||||
#ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
ENGINE *e = NULL;
|
ENGINE *e = NULL;
|
||||||
#endif
|
#endif
|
||||||
@ -102,6 +103,7 @@ int MAIN(int argc, char **argv)
|
|||||||
|
|
||||||
apps_startup();
|
apps_startup();
|
||||||
|
|
||||||
|
BN_GENCB_set(&cb, dh_cb, bio_err);
|
||||||
if (bio_err == NULL)
|
if (bio_err == NULL)
|
||||||
if ((bio_err=BIO_new(BIO_s_file())) != NULL)
|
if ((bio_err=BIO_new(BIO_s_file())) != NULL)
|
||||||
BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
|
BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
|
||||||
@ -199,9 +201,9 @@ bad:
|
|||||||
|
|
||||||
BIO_printf(bio_err,"Generating DH parameters, %d bit long safe prime, generator %d\n",num,g);
|
BIO_printf(bio_err,"Generating DH parameters, %d bit long safe prime, generator %d\n",num,g);
|
||||||
BIO_printf(bio_err,"This is going to take a long time\n");
|
BIO_printf(bio_err,"This is going to take a long time\n");
|
||||||
dh=DH_generate_parameters(num,g,dh_cb,bio_err);
|
|
||||||
|
|
||||||
if (dh == NULL) goto end;
|
if(((dh = DH_new()) == NULL) || !DH_generate_parameters_ex(dh, num, g, &cb))
|
||||||
|
goto end;
|
||||||
|
|
||||||
app_RAND_write_file(NULL, bio_err);
|
app_RAND_write_file(NULL, bio_err);
|
||||||
|
|
||||||
@ -217,7 +219,7 @@ end:
|
|||||||
OPENSSL_EXIT(ret);
|
OPENSSL_EXIT(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MS_CALLBACK dh_cb(int p, int n, void *arg)
|
static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb)
|
||||||
{
|
{
|
||||||
char c='*';
|
char c='*';
|
||||||
|
|
||||||
@ -225,10 +227,11 @@ static void MS_CALLBACK dh_cb(int p, int n, void *arg)
|
|||||||
if (p == 1) c='+';
|
if (p == 1) c='+';
|
||||||
if (p == 2) c='*';
|
if (p == 2) c='*';
|
||||||
if (p == 3) c='\n';
|
if (p == 3) c='\n';
|
||||||
BIO_write((BIO *)arg,&c,1);
|
BIO_write(cb->arg,&c,1);
|
||||||
(void)BIO_flush((BIO *)arg);
|
(void)BIO_flush(cb->arg);
|
||||||
#ifdef LINT
|
#ifdef LINT
|
||||||
p=n;
|
p=n;
|
||||||
#endif
|
#endif
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -81,12 +81,13 @@
|
|||||||
#undef PROG
|
#undef PROG
|
||||||
#define PROG genrsa_main
|
#define PROG genrsa_main
|
||||||
|
|
||||||
static void MS_CALLBACK genrsa_cb(int p, int n, void *arg);
|
static int MS_CALLBACK genrsa_cb(int p, int n, BN_GENCB *cb);
|
||||||
|
|
||||||
int MAIN(int, char **);
|
int MAIN(int, char **);
|
||||||
|
|
||||||
int MAIN(int argc, char **argv)
|
int MAIN(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
BN_GENCB cb;
|
||||||
#ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
ENGINE *e = NULL;
|
ENGINE *e = NULL;
|
||||||
#endif
|
#endif
|
||||||
@ -105,6 +106,7 @@ int MAIN(int argc, char **argv)
|
|||||||
BIO *out=NULL;
|
BIO *out=NULL;
|
||||||
|
|
||||||
apps_startup();
|
apps_startup();
|
||||||
|
BN_GENCB_set(&cb, genrsa_cb, bio_err);
|
||||||
|
|
||||||
if (bio_err == NULL)
|
if (bio_err == NULL)
|
||||||
if ((bio_err=BIO_new(BIO_s_file())) != NULL)
|
if ((bio_err=BIO_new(BIO_s_file())) != NULL)
|
||||||
@ -239,7 +241,9 @@ bad:
|
|||||||
|
|
||||||
BIO_printf(bio_err,"Generating RSA private key, %d bit long modulus\n",
|
BIO_printf(bio_err,"Generating RSA private key, %d bit long modulus\n",
|
||||||
num);
|
num);
|
||||||
rsa=RSA_generate_key(num,f4,genrsa_cb,bio_err);
|
|
||||||
|
if(((rsa = RSA_new()) == NULL) || !RSA_generate_key_ex(rsa, num, f4, &cb))
|
||||||
|
goto err;
|
||||||
|
|
||||||
app_RAND_write_file(NULL, bio_err);
|
app_RAND_write_file(NULL, bio_err);
|
||||||
|
|
||||||
@ -277,7 +281,7 @@ err:
|
|||||||
OPENSSL_EXIT(ret);
|
OPENSSL_EXIT(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MS_CALLBACK genrsa_cb(int p, int n, void *arg)
|
static int MS_CALLBACK genrsa_cb(int p, int n, BN_GENCB *cb)
|
||||||
{
|
{
|
||||||
char c='*';
|
char c='*';
|
||||||
|
|
||||||
@ -285,11 +289,12 @@ static void MS_CALLBACK genrsa_cb(int p, int n, void *arg)
|
|||||||
if (p == 1) c='+';
|
if (p == 1) c='+';
|
||||||
if (p == 2) c='*';
|
if (p == 2) c='*';
|
||||||
if (p == 3) c='\n';
|
if (p == 3) c='\n';
|
||||||
BIO_write((BIO *)arg,&c,1);
|
BIO_write(cb->arg,&c,1);
|
||||||
(void)BIO_flush((BIO *)arg);
|
(void)BIO_flush(cb->arg);
|
||||||
#ifdef LINT
|
#ifdef LINT
|
||||||
p=n;
|
p=n;
|
||||||
#endif
|
#endif
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
#else /* !OPENSSL_NO_RSA */
|
#else /* !OPENSSL_NO_RSA */
|
||||||
|
|
||||||
|
20
apps/req.c
20
apps/req.c
@ -135,7 +135,7 @@ static int add_attribute_object(X509_REQ *req, char *text,
|
|||||||
static int add_DN_object(X509_NAME *n, char *text, char *def, char *value,
|
static int add_DN_object(X509_NAME *n, char *text, char *def, char *value,
|
||||||
int nid,int n_min,int n_max, unsigned long chtype, int mval);
|
int nid,int n_min,int n_max, unsigned long chtype, int mval);
|
||||||
#ifndef OPENSSL_NO_RSA
|
#ifndef OPENSSL_NO_RSA
|
||||||
static void MS_CALLBACK req_cb(int p,int n,void *arg);
|
static int MS_CALLBACK req_cb(int p, int n, BN_GENCB *cb);
|
||||||
#endif
|
#endif
|
||||||
static int req_check_len(int len,int n_min,int n_max);
|
static int req_check_len(int len,int n_min,int n_max);
|
||||||
static int check_end(char *str, char *end);
|
static int check_end(char *str, char *end);
|
||||||
@ -712,6 +712,8 @@ bad:
|
|||||||
|
|
||||||
if (newreq && (pkey == NULL))
|
if (newreq && (pkey == NULL))
|
||||||
{
|
{
|
||||||
|
BN_GENCB cb;
|
||||||
|
BN_GENCB_set(&cb, req_cb, bio_err);
|
||||||
char *randfile = NCONF_get_string(req_conf,SECTION,"RANDFILE");
|
char *randfile = NCONF_get_string(req_conf,SECTION,"RANDFILE");
|
||||||
if (randfile == NULL)
|
if (randfile == NULL)
|
||||||
ERR_clear_error();
|
ERR_clear_error();
|
||||||
@ -740,11 +742,14 @@ bad:
|
|||||||
#ifndef OPENSSL_NO_RSA
|
#ifndef OPENSSL_NO_RSA
|
||||||
if (pkey_type == TYPE_RSA)
|
if (pkey_type == TYPE_RSA)
|
||||||
{
|
{
|
||||||
if (!EVP_PKEY_assign_RSA(pkey,
|
RSA *rsa = RSA_new();
|
||||||
RSA_generate_key(newkey,0x10001,
|
if(!rsa || !RSA_generate_key_ex(rsa, newkey, 0x10001, &cb) ||
|
||||||
req_cb,bio_err)))
|
!EVP_PKEY_assign_RSA(pkey, rsa))
|
||||||
|
{
|
||||||
|
if(rsa) RSA_free(rsa);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifndef OPENSSL_NO_DSA
|
#ifndef OPENSSL_NO_DSA
|
||||||
@ -1610,7 +1615,7 @@ err:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_RSA
|
#ifndef OPENSSL_NO_RSA
|
||||||
static void MS_CALLBACK req_cb(int p, int n, void *arg)
|
static int MS_CALLBACK req_cb(int p, int n, BN_GENCB *cb)
|
||||||
{
|
{
|
||||||
char c='*';
|
char c='*';
|
||||||
|
|
||||||
@ -1618,11 +1623,12 @@ static void MS_CALLBACK req_cb(int p, int n, void *arg)
|
|||||||
if (p == 1) c='+';
|
if (p == 1) c='+';
|
||||||
if (p == 2) c='*';
|
if (p == 2) c='*';
|
||||||
if (p == 3) c='\n';
|
if (p == 3) c='\n';
|
||||||
BIO_write((BIO *)arg,&c,1);
|
BIO_write(cb->arg,&c,1);
|
||||||
(void)BIO_flush((BIO *)arg);
|
(void)BIO_flush(cb->arg);
|
||||||
#ifdef LINT
|
#ifdef LINT
|
||||||
p=n;
|
p=n;
|
||||||
#endif
|
#endif
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1785,7 +1785,12 @@ static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength)
|
|||||||
BIO_printf(bio_err,"Generating temp (%d bit) RSA key...",keylength);
|
BIO_printf(bio_err,"Generating temp (%d bit) RSA key...",keylength);
|
||||||
(void)BIO_flush(bio_err);
|
(void)BIO_flush(bio_err);
|
||||||
}
|
}
|
||||||
rsa_tmp=RSA_generate_key(keylength,RSA_F4,NULL,NULL);
|
if(((rsa_tmp = RSA_new()) == NULL) || !RSA_generate_key_ex(
|
||||||
|
rsa_tmp, keylength,RSA_F4,NULL))
|
||||||
|
{
|
||||||
|
if(rsa_tmp) RSA_free(rsa_tmp);
|
||||||
|
rsa_tmp = NULL;
|
||||||
|
}
|
||||||
if (!s_quiet)
|
if (!s_quiet)
|
||||||
{
|
{
|
||||||
BIO_printf(bio_err,"\n");
|
BIO_printf(bio_err,"\n");
|
||||||
|
@ -1502,7 +1502,7 @@ int test_gf2m_mod_solve_quad(BIO *bp,BN_CTX *ctx)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void genprime_cb(int p, int n, void *arg)
|
static int genprime_cb(int p, int n, BN_GENCB *arg)
|
||||||
{
|
{
|
||||||
char c='*';
|
char c='*';
|
||||||
|
|
||||||
@ -1512,12 +1512,12 @@ static void genprime_cb(int p, int n, void *arg)
|
|||||||
if (p == 3) c='\n';
|
if (p == 3) c='\n';
|
||||||
putc(c, stderr);
|
putc(c, stderr);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
(void)n;
|
return 1;
|
||||||
(void)arg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_kron(BIO *bp, BN_CTX *ctx)
|
int test_kron(BIO *bp, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
|
BN_GENCB cb;
|
||||||
BIGNUM *a,*b,*r,*t;
|
BIGNUM *a,*b,*r,*t;
|
||||||
int i;
|
int i;
|
||||||
int legendre, kronecker;
|
int legendre, kronecker;
|
||||||
@ -1529,6 +1529,8 @@ int test_kron(BIO *bp, BN_CTX *ctx)
|
|||||||
t = BN_new();
|
t = BN_new();
|
||||||
if (a == NULL || b == NULL || r == NULL || t == NULL) goto err;
|
if (a == NULL || b == NULL || r == NULL || t == NULL) goto err;
|
||||||
|
|
||||||
|
BN_GENCB_set(&cb, genprime_cb, NULL);
|
||||||
|
|
||||||
/* We test BN_kronecker(a, b, ctx) just for b odd (Jacobi symbol).
|
/* We test BN_kronecker(a, b, ctx) just for b odd (Jacobi symbol).
|
||||||
* In this case we know that if b is prime, then BN_kronecker(a, b, ctx)
|
* In this case we know that if b is prime, then BN_kronecker(a, b, ctx)
|
||||||
* is congruent to $a^{(b-1)/2}$, modulo $b$ (Legendre symbol).
|
* is congruent to $a^{(b-1)/2}$, modulo $b$ (Legendre symbol).
|
||||||
@ -1538,7 +1540,7 @@ int test_kron(BIO *bp, BN_CTX *ctx)
|
|||||||
* don't want to test whether b is prime but whether BN_kronecker
|
* don't want to test whether b is prime but whether BN_kronecker
|
||||||
* works.) */
|
* works.) */
|
||||||
|
|
||||||
if (!BN_generate_prime(b, 512, 0, NULL, NULL, genprime_cb, NULL)) goto err;
|
if (!BN_generate_prime_ex(b, 512, 0, NULL, NULL, &cb)) goto err;
|
||||||
b->neg = rand_neg();
|
b->neg = rand_neg();
|
||||||
putc('\n', stderr);
|
putc('\n', stderr);
|
||||||
|
|
||||||
@ -1606,6 +1608,7 @@ int test_kron(BIO *bp, BN_CTX *ctx)
|
|||||||
|
|
||||||
int test_sqrt(BIO *bp, BN_CTX *ctx)
|
int test_sqrt(BIO *bp, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
|
BN_GENCB cb;
|
||||||
BIGNUM *a,*p,*r;
|
BIGNUM *a,*p,*r;
|
||||||
int i, j;
|
int i, j;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -1615,6 +1618,8 @@ int test_sqrt(BIO *bp, BN_CTX *ctx)
|
|||||||
r = BN_new();
|
r = BN_new();
|
||||||
if (a == NULL || p == NULL || r == NULL) goto err;
|
if (a == NULL || p == NULL || r == NULL) goto err;
|
||||||
|
|
||||||
|
BN_GENCB_set(&cb, genprime_cb, NULL);
|
||||||
|
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
if (i < 8)
|
if (i < 8)
|
||||||
@ -1628,7 +1633,7 @@ int test_sqrt(BIO *bp, BN_CTX *ctx)
|
|||||||
if (!BN_set_word(a, 32)) goto err;
|
if (!BN_set_word(a, 32)) goto err;
|
||||||
if (!BN_set_word(r, 2*i + 1)) goto err;
|
if (!BN_set_word(r, 2*i + 1)) goto err;
|
||||||
|
|
||||||
if (!BN_generate_prime(p, 256, 0, a, r, genprime_cb, NULL)) goto err;
|
if (!BN_generate_prime_ex(p, 256, 0, a, r, &cb)) goto err;
|
||||||
putc('\n', stderr);
|
putc('\n', stderr);
|
||||||
}
|
}
|
||||||
p->neg = rand_neg();
|
p->neg = rand_neg();
|
||||||
|
@ -89,12 +89,13 @@ int main(int argc, char *argv[])
|
|||||||
#define MS_CALLBACK
|
#define MS_CALLBACK
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void MS_CALLBACK cb(int p, int n, void *arg);
|
static int MS_CALLBACK cb(int p, int n, BN_GENCB *arg);
|
||||||
|
|
||||||
static const char rnd_seed[] = "string to make the random number generator think it has entropy";
|
static const char rnd_seed[] = "string to make the random number generator think it has entropy";
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
BN_GENCB _cb;
|
||||||
DH *a;
|
DH *a;
|
||||||
DH *b=NULL;
|
DH *b=NULL;
|
||||||
char buf[12];
|
char buf[12];
|
||||||
@ -116,8 +117,10 @@ int main(int argc, char *argv[])
|
|||||||
if (out == NULL) EXIT(1);
|
if (out == NULL) EXIT(1);
|
||||||
BIO_set_fp(out,stdout,BIO_NOCLOSE);
|
BIO_set_fp(out,stdout,BIO_NOCLOSE);
|
||||||
|
|
||||||
a=DH_generate_parameters(64,DH_GENERATOR_5,cb,out);
|
BN_GENCB_set(&_cb, &cb, out);
|
||||||
if (a == NULL) goto err;
|
if(((a = DH_new()) == NULL) || !DH_generate_parameters_ex(a, 64,
|
||||||
|
DH_GENERATOR_5, &_cb))
|
||||||
|
goto err;
|
||||||
|
|
||||||
if (!DH_check(a, &i)) goto err;
|
if (!DH_check(a, &i)) goto err;
|
||||||
if (i & DH_CHECK_P_NOT_PRIME)
|
if (i & DH_CHECK_P_NOT_PRIME)
|
||||||
@ -201,7 +204,7 @@ err:
|
|||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MS_CALLBACK cb(int p, int n, void *arg)
|
static int MS_CALLBACK cb(int p, int n, BN_GENCB *arg)
|
||||||
{
|
{
|
||||||
char c='*';
|
char c='*';
|
||||||
|
|
||||||
@ -209,10 +212,11 @@ static void MS_CALLBACK cb(int p, int n, void *arg)
|
|||||||
if (p == 1) c='+';
|
if (p == 1) c='+';
|
||||||
if (p == 2) c='*';
|
if (p == 2) c='*';
|
||||||
if (p == 3) c='\n';
|
if (p == 3) c='\n';
|
||||||
BIO_write((BIO *)arg,&c,1);
|
BIO_write(arg->arg,&c,1);
|
||||||
(void)BIO_flush((BIO *)arg);
|
(void)BIO_flush(arg->arg);
|
||||||
#ifdef LINT
|
#ifdef LINT
|
||||||
p=n;
|
p=n;
|
||||||
#endif
|
#endif
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -90,7 +90,7 @@ int main(int argc, char *argv[])
|
|||||||
#define MS_CALLBACK
|
#define MS_CALLBACK
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void MS_CALLBACK dsa_cb(int p, int n, void *arg);
|
static int MS_CALLBACK dsa_cb(int p, int n, BN_GENCB *arg);
|
||||||
|
|
||||||
/* seed, out_p, out_q, out_g are taken from the updated Appendix 5 to
|
/* seed, out_p, out_q, out_g are taken from the updated Appendix 5 to
|
||||||
* FIPS PUB 186 and also appear in Appendix 5 to FIPS PIB 186-1 */
|
* FIPS PUB 186 and also appear in Appendix 5 to FIPS PIB 186-1 */
|
||||||
@ -135,6 +135,7 @@ static BIO *bio_err=NULL;
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
BN_GENCB cb;
|
||||||
DSA *dsa=NULL;
|
DSA *dsa=NULL;
|
||||||
int counter,ret=0,i,j;
|
int counter,ret=0,i,j;
|
||||||
unsigned char buf[256];
|
unsigned char buf[256];
|
||||||
@ -154,7 +155,10 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
BIO_printf(bio_err,"test generation of DSA parameters\n");
|
BIO_printf(bio_err,"test generation of DSA parameters\n");
|
||||||
|
|
||||||
dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb,bio_err);
|
BN_GENCB_set(&cb, dsa_cb, bio_err);
|
||||||
|
if(((dsa = DSA_new()) == NULL) || !DSA_generate_parameters_ex(dsa, 512,
|
||||||
|
seed, 20, &counter, &h, &cb))
|
||||||
|
goto end;
|
||||||
|
|
||||||
BIO_printf(bio_err,"seed\n");
|
BIO_printf(bio_err,"seed\n");
|
||||||
for (i=0; i<20; i+=4)
|
for (i=0; i<20; i+=4)
|
||||||
@ -221,13 +225,7 @@ end:
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cb_exit(int ec)
|
static int MS_CALLBACK dsa_cb(int p, int n, BN_GENCB *arg)
|
||||||
{
|
|
||||||
EXIT(ec);
|
|
||||||
return(0); /* To keep some compilers quiet */
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
|
|
||||||
{
|
{
|
||||||
char c='*';
|
char c='*';
|
||||||
static int ok=0,num=0;
|
static int ok=0,num=0;
|
||||||
@ -236,13 +234,14 @@ static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
|
|||||||
if (p == 1) c='+';
|
if (p == 1) c='+';
|
||||||
if (p == 2) { c='*'; ok++; }
|
if (p == 2) { c='*'; ok++; }
|
||||||
if (p == 3) c='\n';
|
if (p == 3) c='\n';
|
||||||
BIO_write(arg,&c,1);
|
BIO_write(arg->arg,&c,1);
|
||||||
(void)BIO_flush(arg);
|
(void)BIO_flush(arg->arg);
|
||||||
|
|
||||||
if (!ok && (p == 0) && (num > 1))
|
if (!ok && (p == 0) && (num > 1))
|
||||||
{
|
{
|
||||||
BIO_printf((BIO *)arg,"error in dsatest\n");
|
BIO_printf((BIO *)arg,"error in dsatest\n");
|
||||||
cb_exit(1);
|
return 0;
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user