Skip to content

Commit

Permalink
Signature verification test. Enable all tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Laurie committed Apr 4, 2004
1 parent 16d5c92 commit 08198b1
Show file tree
Hide file tree
Showing 9 changed files with 1,429 additions and 110 deletions.
5 changes: 3 additions & 2 deletions fips/dsa/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ A=../testvectors/dsa/rsp
fips_test: top_fips_dssvs
-rm -rf $A
mkdir $A
# ./fips_dssvs pqg < $Q/PQGGen.req > $A/PQGGen.rsp
# ./fips_dssvs keypair < $Q/KeyPair.req > $A/KeyPair.rsp
./fips_dssvs pqg < $Q/PQGGen.req > $A/PQGGen.rsp
./fips_dssvs keypair < $Q/KeyPair.req > $A/KeyPair.rsp
./fips_dssvs siggen < $Q/SigGen.req > $A/SigGen.rsp
./fips_dssvs sigver < $Q/SigVer.req > $A/SigVer.rsp

lint:
lint -DLINT $(INCLUDES) $(SRC)>fluff
Expand Down
71 changes: 69 additions & 2 deletions fips/dsa/fips_dssvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ int hex2bin(const char *in, unsigned char *out)
return n2;
}

BIGNUM *hex2bn(const char *in)
{
BIGNUM *p=BN_new();

BN_hex2bn(&p,in);

return p;
}

int bin2hex(const unsigned char *in,int len,char *out)
{
int n1, n2;
Expand Down Expand Up @@ -206,6 +215,64 @@ void siggen()
}
}

void sigver()
{
DSA *dsa=NULL;
char buf[1024];
int nmod=0;
unsigned char hash[20];
DSA_SIG *sig=DSA_SIG_new();

while(fgets(buf,sizeof buf,stdin) != NULL)
{
if(!strncmp(buf,"[mod = ",7))
{
nmod=atoi(buf+7);
if(dsa)
DSA_free(dsa);
dsa=DSA_new();
}
else if(!strncmp(buf,"P = ",4))
dsa->p=hex2bn(buf+4);
else if(!strncmp(buf,"Q = ",4))
dsa->q=hex2bn(buf+4);
else if(!strncmp(buf,"G = ",4))
{
dsa->g=hex2bn(buf+4);

printf("[mod = %d]\n\n",nmod);
pbn("P",dsa->p);
pbn("Q",dsa->q);
pbn("G",dsa->g);
putc('\n',stdout);
}
else if(!strncmp(buf,"Msg = ",6))
{
unsigned char msg[1024];
int n;

n=hex2bin(buf+6,msg);
pv("Msg",msg,n);
SHA1(msg,n,hash);
}
else if(!strncmp(buf,"Y = ",4))
dsa->pub_key=hex2bn(buf+4);
else if(!strncmp(buf,"R = ",4))
sig->r=hex2bn(buf+4);
else if(!strncmp(buf,"S = ",4))
{
sig->s=hex2bn(buf+4);

pbn("Y",dsa->pub_key);
pbn("R",sig->r);
pbn("S",sig->s);
printf("Result = %c\n",DSA_do_verify(hash,sizeof hash,sig,dsa)
? 'T' : 'F');
putc('\n',stdout);
}
}
}

int main(int argc,char **argv)
{
if(argc != 2)
Expand All @@ -227,8 +294,8 @@ int main(int argc,char **argv)
keypair();
else if(!strcmp(argv[1],"siggen"))
siggen();
// else if(!strcmp(argv[1],"versig"))
// versig();
else if(!strcmp(argv[1],"sigver"))
sigver();
else
{
fprintf(stderr,"Don't know how to %s.\n",argv[1]);
Expand Down
41 changes: 41 additions & 0 deletions fips/testvectors/dsa/req/KeyPair.req
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# CAVS 3.0
# "KeyPair" information for "Open SSL DSA"
# Mod sizes selected: 512 576 640 704 768 832 896 960 1024
# Generated on Fri Apr 02 12:11:47 2004

[mod = 512]

N = 10

[mod = 576]

N = 10

[mod = 640]

N = 10

[mod = 704]

N = 10

[mod = 768]

N = 10

[mod = 832]

N = 10

[mod = 896]

N = 10

[mod = 960]

N = 10

[mod = 1024]

N = 10

41 changes: 41 additions & 0 deletions fips/testvectors/dsa/req/PQGGen.req
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# CAVS 3.0
# "PQGGen" information for "Open SSL DSA"
# Mod sizes selected: 512 576 640 704 768 832 896 960 1024
# Generated on Fri Apr 02 09:32:59 2004

[mod = 512]

N = 5

[mod = 576]

N = 5

[mod = 640]

N = 5

[mod = 704]

N = 5

[mod = 768]

N = 5

[mod = 832]

N = 5

[mod = 896]

N = 5

[mod = 960]

N = 5

[mod = 1024]

N = 5

338 changes: 338 additions & 0 deletions fips/testvectors/dsa/req/PQGVer.req

Large diffs are not rendered by default.

203 changes: 203 additions & 0 deletions fips/testvectors/dsa/req/SigGen.req

Large diffs are not rendered by default.

734 changes: 734 additions & 0 deletions fips/testvectors/dsa/req/SigVer.req

Large diffs are not rendered by default.

20 changes: 0 additions & 20 deletions fips/testvectors/dsa/req/pqg.req

This file was deleted.

86 changes: 0 additions & 86 deletions fips/testvectors/dsa/req/prime.req

This file was deleted.

0 comments on commit 08198b1

Please sign in to comment.