Commit 08198b1b authored by Ben Laurie's avatar Ben Laurie
Browse files

Signature verification test. Enable all tests.

parent 16d5c926
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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
+69 −2
Original line number Diff line number Diff line
@@ -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;
@@ -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)
@@ -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]);
+41 −0
Original line number Diff line number Diff line
#  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 −0
Original line number Diff line number Diff line
#  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 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading