Commit 4cc2bbab authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

Make fips algorithm test utilities use RESP_EOL for end of line character(s).

This should be CRLF even under *nix.
parent 04c3aa5c
Loading
Loading
Loading
Loading
+12 −11
Original line number Diff line number Diff line
@@ -283,7 +283,7 @@ static int do_mct(char *amode,
	/* printf("Iteration %d\n", i); */
	if (i > 0)
	    {
	    fprintf(rfp,"COUNT = %d\n",i);
	    fprintf(rfp,"COUNT = %d" RESP_EOL ,i);
	    OutputValue("KEY",key[i],nkeysz,rfp,0);
	    if (imode != ECB)  /* ECB */
		OutputValue("IV",iv[i],AES_BLOCK_SIZE,rfp,0);
@@ -419,7 +419,7 @@ static int do_mct(char *amode,
	/* Output Ciphertext | Plaintext */
	OutputValue(t_tag[dir],dir ? ctext[j] : ptext[j],len,rfp,
		    imode == CFB1);
	fprintf(rfp, "\n");  /* add separator */
	fprintf(rfp, RESP_EOL);  /* add separator */

	/* Compute next KEY */
	if (dir == XENCRYPT)
@@ -622,7 +622,7 @@ static int proc_file(char *rqfile, char *rspfile)
		    }
		else
		    {
		    fputs(ibuf, rfp);
		    copy_line(ibuf, rfp);
		    ++ step;
		    }
		}
@@ -638,11 +638,12 @@ static int proc_file(char *rqfile, char *rspfile)
		if (akeysz)
		    { /* insert current time & date */
		    time_t rtim = time(0);
		    fprintf(rfp, "# %s", ctime(&rtim));
		    fputs("# ", rfp);
		    copy_line(ctime(&rtim), rfp);
		    }
		else
		    {
		    fputs(ibuf, rfp);
		    copy_line(ibuf, rfp);
		    if (strncmp(pp, "AESVS ", 6) == 0)
			{
			strcpy(algo, "AES");
@@ -674,7 +675,7 @@ static int proc_file(char *rqfile, char *rspfile)
	case 1:  /* [ENCRYPT] | [DECRYPT] */
	    if (ibuf[0] == '[')
		{
		fputs(ibuf, rfp);
		copy_line(ibuf, rfp);
		++step;
		if (fips_strncasecmp(ibuf, "[ENCRYPT]", 9) == 0)
		    dir = 1;
@@ -697,7 +698,7 @@ static int proc_file(char *rqfile, char *rspfile)
		step = 2;

	case 2: /* KEY = xxxx */
	    fputs(ibuf, rfp);
	    copy_line(ibuf, rfp);
	    if(*ibuf == '\n')
		break;
	    if(!fips_strncasecmp(ibuf,"COUNT = ",8))
@@ -729,7 +730,7 @@ static int proc_file(char *rqfile, char *rspfile)
	    break;

	case 3: /* IV = xxxx */
	    fputs(ibuf, rfp);
	    copy_line(ibuf, rfp);
	    if (fips_strncasecmp(ibuf, "IV = ", 5) != 0)
		{
		printf("Missing IV\n");
@@ -750,7 +751,7 @@ static int proc_file(char *rqfile, char *rspfile)
	    break;

	case 4: /* PLAINTEXT = xxxx */
	    fputs(ibuf, rfp);
	    copy_line(ibuf, rfp);
	    if (fips_strncasecmp(ibuf, "PLAINTEXT = ", 12) != 0)
		{
		printf("Missing PLAINTEXT\n");
@@ -794,7 +795,7 @@ static int proc_file(char *rqfile, char *rspfile)
	    break;

	case 5: /* CIPHERTEXT = xxxx */
	    fputs(ibuf, rfp);
	    copy_line(ibuf, rfp);
	    if (fips_strncasecmp(ibuf, "CIPHERTEXT = ", 13) != 0)
		{
		printf("Missing KEY\n");
@@ -839,7 +840,7 @@ static int proc_file(char *rqfile, char *rspfile)
		}
	    else if (strcmp(atest, "MCT") != 0)
		{ /* MCT already added terminating nl */
		fputs(ibuf, rfp);
		copy_line(ibuf, rfp);
		}
	    step = 1;
	    break;
+3 −3
Original line number Diff line number Diff line
@@ -243,7 +243,7 @@ static void gcmtest(FILE *in, FILE *out, int encrypt)
				}
			rv = FIPS_cipher(&ctx, NULL, NULL, 0);
			if (rv < 0)
				fprintf(out, "FAIL\n");
				fprintf(out, "FAIL" RESP_EOL);
			else
				OutputValue("PT", pt, ptlen, out, 0);
			if (iv)
@@ -479,11 +479,11 @@ static void ccmtest(FILE *in, FILE *out)
				{
				if (rv == 0)
					Payload[0] = 0;
				fputs("Result = Pass\n", out);
				fputs("Result = Pass" RESP_EOL, out);
				OutputValue("Payload", Payload, len, out, 0);
				}
			else
				fputs("Result = Fail\n", out);
				fputs("Result = Fail" RESP_EOL, out);
			OPENSSL_free(CT);
			OPENSSL_free(Payload);
			CT = Payload = NULL;
+3 −3
Original line number Diff line number Diff line
@@ -464,7 +464,7 @@ static int print_cmac_gen(const EVP_CIPHER *cipher, FILE *out,
		fputs("Mac = ", out);
		for (i = 0; i < Tlen; i++)
			fprintf(out, "%02x", res[i]);
		fputs("\n", out);
		fputs(RESP_EOL, out);
		rc = 1;
		}
	CMAC_CTX_free(cmac_ctx);
@@ -502,9 +502,9 @@ static int print_cmac_ver(const EVP_CIPHER *cipher, FILE *out,
	else
		{
		if (!memcmp(Mac, res, Maclen))
			fputs("Result = P\n", out);
			fputs("Result = P" RESP_EOL, out);
		else
			fputs("Result = F\n", out);
			fputs("Result = F" RESP_EOL, out);
		}
	CMAC_CTX_free(cmac_ctx);
	return rc;
+14 −13
Original line number Diff line number Diff line
@@ -186,7 +186,7 @@ static void do_mct(char *amode,
	EVP_CIPHER_CTX ctx;
	FIPS_cipher_ctx_init(&ctx);

	fprintf(rfp,"\nCOUNT = %d\n",i);
	fprintf(rfp,RESP_EOL "COUNT = %d" RESP_EOL,i);
	if(kp == 1)
	    OutputValue("KEY",akey,8,rfp,0);
	else
@@ -341,7 +341,7 @@ static int proc_file(char *rqfile, char *rspfile)
		    }
		else
		    {
		    fputs(ibuf, rfp);
		    copy_line(ibuf, rfp);
		    ++ step;
		    }
		}
@@ -357,11 +357,12 @@ static int proc_file(char *rqfile, char *rspfile)
		if(*amode)
		    { /* insert current time & date */
		    time_t rtim = time(0);
		    fprintf(rfp, "# %s", ctime(&rtim));
		    fputs("# ", rfp);
		    copy_line(ctime(&rtim), rfp);
		    }
		else
		    {
		    fputs(ibuf, rfp);
		    copy_line(ibuf, rfp);
		    if(!strncmp(pp,"INVERSE ",8) || !strncmp(pp,"DES ",4)
		       || !strncmp(pp,"TDES ",5)
		       || !strncmp(pp,"PERMUTATION ",12)
@@ -397,7 +398,7 @@ static int proc_file(char *rqfile, char *rspfile)
		break;
	    if (ibuf[0] == '[')
		{
		fputs(ibuf, rfp);
		copy_line(ibuf, rfp);
		++step;
		if (fips_strncasecmp(ibuf, "[ENCRYPT]", 9) == 0)
		    dir = 1;
@@ -422,17 +423,17 @@ static int proc_file(char *rqfile, char *rspfile)
	case 2: /* KEY = xxxx */
	    if(*ibuf == '\n')
		{
	        fputs(ibuf, rfp);
	        copy_line(ibuf, rfp);
		break;
                }
	    if(!fips_strncasecmp(ibuf,"COUNT = ",8))
		{
	        fputs(ibuf, rfp);
	        copy_line(ibuf, rfp);
		break;
                }
	    if(!fips_strncasecmp(ibuf,"COUNT=",6))
		{
	        fputs(ibuf, rfp);
	        copy_line(ibuf, rfp);
		break;
                }
	    if(!fips_strncasecmp(ibuf,"NumKeys = ",10))
@@ -441,7 +442,7 @@ static int proc_file(char *rqfile, char *rspfile)
		break;
		}
	    if (echo) 
	    	fputs(ibuf, rfp);
	    	copy_line(ibuf, rfp);
	    if(!fips_strncasecmp(ibuf,"KEY = ",6))
		{
		akeysz=64;
@@ -497,7 +498,7 @@ static int proc_file(char *rqfile, char *rspfile)

	case 3: /* IV = xxxx */
	    if (echo)
	    	fputs(ibuf, rfp);
	    	copy_line(ibuf, rfp);
	    if (fips_strncasecmp(ibuf, "IV = ", 5) != 0)
		{
		printf("Missing IV\n");
@@ -519,7 +520,7 @@ static int proc_file(char *rqfile, char *rspfile)

	case 4: /* PLAINTEXT = xxxx */
	    if (echo)
	    	fputs(ibuf, rfp);
	    	copy_line(ibuf, rfp);
	    if (fips_strncasecmp(ibuf, "PLAINTEXT = ", 12) != 0)
		{
		printf("Missing PLAINTEXT\n");
@@ -562,7 +563,7 @@ static int proc_file(char *rqfile, char *rspfile)

	case 5: /* CIPHERTEXT = xxxx */
	    if (echo)
	    	fputs(ibuf, rfp);
	    	copy_line(ibuf, rfp);
	    if (fips_strncasecmp(ibuf, "CIPHERTEXT = ", 13) != 0)
		{
		printf("Missing KEY\n");
@@ -608,7 +609,7 @@ static int proc_file(char *rqfile, char *rspfile)
		}
	    else if (strcmp(atest, "MCT") != 0)
		{ /* MCT already added terminating nl */
		fputs(ibuf, rfp);
		copy_line(ibuf, rfp);
		}
	    step = 1;
	    break;
+16 −17
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ static void primes(FILE *in, FILE *out)

	    pp=BN_new();
	    do_hex2bn(&pp,value);
	    fprintf(out, "result= %c\n",
	    fprintf(out, "result= %c" RESP_EOL,
		   BN_is_prime_ex(pp,20,NULL,NULL) ? 'P' : 'F');
	    }	    
	}
@@ -190,13 +190,12 @@ static void pqg(FILE *in, FILE *out)
				seed, M_EVP_MD_size(md), out, 0);
		if (!dsa2)
			{
			fprintf(out, "c = %d\n",counter);
			fprintf(out, "H = %lx\n\n",h);
			fprintf(out, "c = %d" RESP_EOL, counter);
			fprintf(out, "H = %lx" RESP_EOL RESP_EOL,h);
			}
		else
			{
			fprintf(out, "counter = %d\n",counter);
			fputs("\n", out);
			fprintf(out, "counter = %d" RESP_EOL RESP_EOL, counter);
			}
		}
	    }
@@ -343,16 +342,16 @@ static void pqgver(FILE *in, FILE *out)
	    if (idx >= 0)
		{
		if (BN_cmp(dsa->g, g))
			fprintf(out, "Result = F\n");
			fprintf(out, "Result = F" RESP_EOL);
		else
			fprintf(out, "Result = P\n");
			fprintf(out, "Result = P" RESP_EOL);
		}
            else if (BN_cmp(dsa->p, p) || BN_cmp(dsa->q, q) || 
		(!part_test &&
		((BN_cmp(dsa->g, g) || (counter != counter2) || (h != h2)))))
	    	fprintf(out, "Result = F\n");
	    	fprintf(out, "Result = F" RESP_EOL);
	    else
	    	fprintf(out, "Result = P\n");
	    	fprintf(out, "Result = P" RESP_EOL);
	    BN_free(p);
	    BN_free(q);
	    BN_free(g);
@@ -470,13 +469,13 @@ static void keyver(FILE *in, FILE *out)
			paramcheck = -1;
		}
	    if (paramcheck != 1)
	   	fprintf(out, "Result = F\n");
	   	fprintf(out, "Result = F" RESP_EOL);
	    else
		{
		if (!BN_mod_exp(Y2, g, X, p, ctx) || BN_cmp(Y2, Y))
	    		fprintf(out, "Result = F\n");
	    		fprintf(out, "Result = F" RESP_EOL);
	        else
	    		fprintf(out, "Result = P\n");
	    		fprintf(out, "Result = P" RESP_EOL);
		}
	    BN_free(X);
	    BN_free(Y);
@@ -537,7 +536,7 @@ static void keypair(FILE *in, FILE *out)
	    do_bn_print_name(out, "P",dsa->p);
	    do_bn_print_name(out, "Q",dsa->q);
	    do_bn_print_name(out, "G",dsa->g);
	    fputs("\n", out);
	    fputs(RESP_EOL, out);

	    while(n--)
		{
@@ -546,7 +545,7 @@ static void keypair(FILE *in, FILE *out)

		do_bn_print_name(out, "X",dsa->priv_key);
		do_bn_print_name(out, "Y",dsa->pub_key);
	    	fputs("\n", out);
	    	fputs(RESP_EOL, out);
		}
	    }
	}
@@ -594,7 +593,7 @@ static void siggen(FILE *in, FILE *out)
	    do_bn_print_name(out, "P",dsa->p);
	    do_bn_print_name(out, "Q",dsa->q);
	    do_bn_print_name(out, "G",dsa->g);
	    fputs("\n", out);
	    fputs(RESP_EOL, out);
	    }
	else if(!strcmp(keyword,"Msg"))
	    {
@@ -616,7 +615,7 @@ static void siggen(FILE *in, FILE *out)

	    do_bn_print_name(out, "R",sig->r);
	    do_bn_print_name(out, "S",sig->s);
	    fputs("\n", out);
	    fputs(RESP_EOL, out);
	    FIPS_dsa_sig_free(sig);
	    FIPS_md_ctx_cleanup(&mctx);
	    }
@@ -685,7 +684,7 @@ static void sigver(FILE *in, FILE *out)
	    no_err = 0;
	    FIPS_md_ctx_cleanup(&mctx);
	
	    fprintf(out, "Result = %c\n\n", r == 1 ? 'P' : 'F');
	    fprintf(out, "Result = %c" RESP_EOL RESP_EOL, r == 1 ? 'P' : 'F');
	    }
	}
    }
Loading