versions of DSA signature functions.
static int fips_check_dsa(DSA *dsa)
{
static const unsigned char str1[]="12345678901234567890";
- unsigned char sig[256];
- unsigned int siglen;
+ int r = 0;
+ DSA_SIG *sig;
- DSA_sign(0, str1, 20, sig, &siglen, dsa);
- if(DSA_verify(0, str1, 20, sig, siglen, dsa) != 1)
+ sig = DSA_do_sign(str1, 20, dsa);
+
+ if (sig)
+ {
+ r = DSA_do_verify(str1, 20, sig, dsa);
+ DSA_SIG_free(sig);
+ }
+
+ if(r != 1)
{
FIPSerr(FIPS_F_FIPS_CHECK_DSA,FIPS_R_PAIRWISE_TEST_FAILED);
return 0;
BN_sub(s,s,dsa->q);
if (!BN_mod_mul(s,s,kinv,dsa->q,ctx)) goto err;
- ret=DSA_SIG_new();
+ ret= DSA_SIG_new();
if (ret == NULL) goto err;
ret->r = r;
ret->s = s;
int counter,i,j;
unsigned char buf[256];
unsigned long h;
- unsigned char sig[256];
- unsigned int siglen;
+
+ DSA_SIG *sig = NULL;
dsa=DSA_generate_parameters(512,seed,20,&counter,&h,NULL,NULL);
return 0;
}
DSA_generate_key(dsa);
- DSA_sign(0, str1, 20, sig, &siglen, dsa);
- if(DSA_verify(0, str1, 20, sig, siglen, dsa) != 1)
+ sig = DSA_do_sign(str1, 20, dsa);
+
+ if (sig)
+ {
+ i = DSA_do_verify(str1, 20, sig, dsa);
+ DSA_SIG_free(sig);
+ OPENSSL_free(sig);
+ }
+ else
+ i = 0;
+
+ if (i != 1)
{
FIPSerr(FIPS_F_FIPS_SELFTEST_DSA,FIPS_R_SELFTEST_FAILED);
return 0;
int counter,ret=0,i,j;
unsigned char buf[256];
unsigned long h;
- unsigned char sig[256];
- unsigned int siglen;
+ DSA_SIG *sig = NULL;
if (bio_err == NULL)
bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
- ERR_load_crypto_strings();
FIPS_set_prng_key(rnd_key1,rnd_key2);
RAND_seed(rnd_seed, sizeof rnd_seed);
BIO_printf(bio_err,"\ncounter=%d h=%d\n",counter,h);
if (dsa == NULL) goto end;
- DSA_print(bio_err,dsa,0);
+ /*DSA_print(bio_err,dsa,0);*/
if (counter != 105)
{
BIO_printf(bio_err,"counter should be 105\n");
goto end;
}
DSA_generate_key(dsa);
- DSA_sign(0, str1, 20, sig, &siglen, dsa);
- if (DSA_verify(0, str1, 20, sig, siglen, dsa) == 1)
+
+ sig = DSA_do_sign(str1, 20, dsa);
+
+ if (sig)
+ {
+ i = DSA_do_verify(str1, 20, sig, dsa);
+ DSA_SIG_free(sig);
+ }
+ else
+ i = 0;
+ if (i == 1)
ret=1;
end:
if (!ret)
char *keyword, *value;
int nmod=0;
unsigned char hash[20];
- DSA_SIG *sig=DSA_SIG_new();
+ DSA_SIG sg, *sig = &sg;
+
+ sig->r = NULL;
+ sig->s = NULL;
while(fgets(buf,sizeof buf,stdin) != NULL)
{
}
if(!FIPS_mode_set(1))
{
- ERR_load_crypto_strings();
ERR_print_errors(BIO_new_fp(stderr,BIO_NOCLOSE));
exit(1);
}
int FIPS_selftest()
{
- ERR_load_crypto_strings();
return FIPS_selftest_sha1()
&& FIPS_selftest_hmac()
{
DSA *dsa = NULL;
unsigned char dgst[] = "etaonrishdlc";
- unsigned char sig[256];
- unsigned int siglen;
+ DSA_SIG *sig = NULL;
+ int r = 0;
ERR_clear_error();
dsa = DSA_generate_parameters(512,NULL,0,NULL,NULL,NULL,NULL);
return 0;
if (!DSA_generate_key(dsa))
return 0;
- if ( DSA_sign(0,dgst,sizeof(dgst) - 1,sig,&siglen,dsa) != 1 )
- return 0;
- if ( DSA_verify(0,dgst,sizeof(dgst) - 1,sig,siglen,dsa) != 1 )
+ sig = DSA_do_sign(dgst,sizeof(dgst) - 1,dsa);
+ if (sig)
+ {
+ r = DSA_do_verify(dgst,sizeof(dgst) - 1,sig,dsa);
+ DSA_SIG_free(sig);
+ }
+ if (r != 1)
return 0;
DSA_free(dsa);
return 1;
}
if (!FIPS_mode_set(1))
{
- ERR_load_crypto_strings();
ERR_print_errors(BIO_new_fp(stderr,BIO_NOCLOSE));
printf("Power-up self test failed\n");
exit(1);
printf("2. Automatic power-up self test...");
if (!FIPS_mode_set(1))
{
- ERR_load_crypto_strings();
ERR_print_errors(BIO_new_fp(stderr,BIO_NOCLOSE));
printf(Fail("FAILED!\n"));
exit(1);
int ret = 1;
- ERR_load_crypto_strings();
-
err = BIO_new_fp(stderr, BIO_NOCLOSE);
if (!err)
/*double d; */
long d;
- ERR_load_crypto_strings();
RAND_set_rand_method(FIPS_rand_method());
run_test(&t1);
}
if(!FIPS_mode_set(1))
{
- ERR_load_crypto_strings();
ERR_print_errors(BIO_new_fp(stderr,BIO_NOCLOSE));
exit(1);
}
BIO *in = NULL, *out = NULL, *err = NULL;
int ret = 1;
- ERR_load_crypto_strings();
err = BIO_new_fp(stderr, BIO_NOCLOSE);
BIO *in = NULL, *out = NULL, *err = NULL;
int ret = 1, Saltlen = -1;
- ERR_load_crypto_strings();
err = BIO_new_fp(stderr, BIO_NOCLOSE);
unsigned char *sigbuf = NULL;
int i, siglen;
/* EVP_PKEY structure */
- EVP_PKEY *key = NULL;
+ EVP_PKEY pk;
EVP_MD_CTX ctx;
- key = EVP_PKEY_new();
- if (!key)
- goto error;
- if (!EVP_PKEY_set1_RSA(key, rsa))
- goto error;
+ pk.type = EVP_PKEY_RSA;
+ pk.pkey.rsa = rsa;
- siglen = EVP_PKEY_size(key);
+ siglen = RSA_size(rsa);
sigbuf = OPENSSL_malloc(siglen);
if (!sigbuf)
goto error;
goto error;
if (!EVP_SignUpdate(&ctx, Msg, Msglen))
goto error;
- if (!EVP_SignFinal(&ctx, sigbuf, (unsigned int *)&siglen, key))
+ if (!EVP_SignFinal(&ctx, sigbuf, (unsigned int *)&siglen, &pk))
goto error;
}
ret = 1;
error:
- if (key)
- EVP_PKEY_free(key);
return ret;
}
int ret = 1;
int Saltlen = -1;
- ERR_load_crypto_strings();
err = BIO_new_fp(stderr, BIO_NOCLOSE);
int ret = 0, r;
/* Setup RSA and EVP_PKEY structures */
RSA *rsa_pubkey = NULL;
- EVP_PKEY *pubkey = NULL;
+ EVP_PKEY pk;
EVP_MD_CTX ctx;
unsigned char *buf = NULL;
rsa_pubkey = RSA_new();
- pubkey = EVP_PKEY_new();
- if (!rsa_pubkey || !pubkey)
+ if (!rsa_pubkey)
goto error;
rsa_pubkey->n = BN_dup(n);
rsa_pubkey->e = BN_dup(e);
if (!rsa_pubkey->n || !rsa_pubkey->e)
goto error;
- if (!EVP_PKEY_set1_RSA(pubkey, rsa_pubkey))
- goto error;
+ pk.type = EVP_PKEY_RSA;
+ pk.pkey.rsa = rsa_pubkey;
EVP_MD_CTX_init(&ctx);
if (!EVP_VerifyUpdate(&ctx, Msg, Msglen))
goto error;
- r = EVP_VerifyFinal(&ctx, S, Slen, pubkey);
+ r = EVP_VerifyFinal(&ctx, S, Slen, &pk);
}
error:
if (rsa_pubkey)
RSA_free(rsa_pubkey);
- if (pubkey)
- EVP_PKEY_free(pubkey);
if (buf)
OPENSSL_free(buf);
int ret = 1;
- ERR_load_crypto_strings();
-
err = BIO_new_fp(stderr, BIO_NOCLOSE);
if (!err)