aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2007-10-05 17:09:10 +0000
committerDr. Stephen Henson <steve@openssl.org>2007-10-05 17:09:10 +0000
commitac1600c72a69a29f21505ded23862e7f58436653 (patch)
tree6c4923596eda182ac8152b92476b6cfb0f86dd69
parenteb4a1027ae459ad0bf6f9b5a81735d49654fbc07 (diff)
downloadopenssl-ac1600c72a69a29f21505ded23862e7f58436653.tar.gz
Add pqgver option.
-rw-r--r--fips-1.0/dsa/fips_dssvs.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/fips-1.0/dsa/fips_dssvs.c b/fips-1.0/dsa/fips_dssvs.c
index f234906ebd..4eec29e761 100644
--- a/fips-1.0/dsa/fips_dssvs.c
+++ b/fips-1.0/dsa/fips_dssvs.c
@@ -204,6 +204,76 @@ void pqg()
}
}
+void pqgver()
+ {
+ char buf[1024];
+ char lbuf[1024];
+ char *keyword, *value;
+ BIGNUM *p = NULL, *q = NULL, *g = NULL;
+ int counter, counter2;
+ unsigned long h, h2;
+ DSA *dsa=NULL;
+ int nmod=0;
+ unsigned char seed[1024];
+
+ while(fgets(buf,sizeof buf,stdin) != NULL)
+ {
+ if (!parse_line(&keyword, &value, lbuf, buf))
+ {
+ fputs(buf,stdout);
+ continue;
+ }
+ if(!strcmp(keyword,"[mod"))
+ nmod=atoi(value);
+ else if(!strcmp(keyword,"P"))
+ p=hex2bn(value);
+ else if(!strcmp(keyword,"Q"))
+ q=hex2bn(value);
+ else if(!strcmp(keyword,"G"))
+ g=hex2bn(value);
+ else if(!strcmp(keyword,"Seed"))
+ {
+ int slen = hex2bin(value, seed);
+ if (slen != 20)
+ {
+ fprintf(stderr, "Seed parse length error\n");
+ exit (1);
+ }
+ }
+ else if(!strcmp(keyword,"c"))
+ counter =atoi(buf+4);
+ else if(!strcmp(keyword,"H"))
+ {
+ h = atoi(value);
+ if (!p || !q || !g)
+ {
+ fprintf(stderr, "Parse Error\n");
+ exit (1);
+ }
+ pbn("P",p);
+ pbn("Q",q);
+ pbn("G",g);
+ pv("Seed",seed,20);
+ printf("c = %d\n",counter);
+ printf("H = %lx\n",h);
+ dsa=DSA_generate_parameters(nmod,seed,20,&counter2,&h2,NULL,NULL);
+ if (BN_cmp(dsa->p, p) || BN_cmp(dsa->q, q) || BN_cmp(dsa->g, g)
+ || (counter != counter2) || (h != h2))
+ printf("Result = F\n");
+ else
+ printf("Result = T\n");
+ BN_free(p);
+ BN_free(q);
+ BN_free(g);
+ p = NULL;
+ q = NULL;
+ g = NULL;
+ DSA_free(dsa);
+ dsa = NULL;
+ }
+ }
+ }
+
void keypair()
{
char buf[1024];
@@ -377,6 +447,8 @@ int main(int argc,char **argv)
primes();
else if(!strcmp(argv[1],"pqg"))
pqg();
+ else if(!strcmp(argv[1],"pqgver"))
+ pqgver();
else if(!strcmp(argv[1],"keypair"))
keypair();
else if(!strcmp(argv[1],"siggen"))