Compare commits
5 Commits
OpenSSL-fi
...
OpenSSL-fi
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0b603bcc34 | ||
![]() |
8de14571d6 | ||
![]() |
f47d923d83 | ||
![]() |
6d0a5219aa | ||
![]() |
63fc9883c5 |
@@ -358,6 +358,9 @@ my %table=(
|
||||
"linux-alpha-ccc","ccc:-fast -readonly_strings -DL_ENDIAN -DTERMIO::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${no_asm}",
|
||||
"linux-alpha+bwx-ccc","ccc:-fast -readonly_strings -DL_ENDIAN -DTERMIO::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${no_asm}",
|
||||
|
||||
# Android: Linux but without -DTERMIO and pointers to headers and libs.
|
||||
"android","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
|
||||
#### *BSD [do see comment about ${BSDthreads} above!]
|
||||
"BSD-generic32","gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"BSD-x86", "gcc:-DL_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer -Wall::${BSDthreads}:::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}:dlfcn:bsd-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
@@ -521,6 +524,8 @@ my %table=(
|
||||
"OS2-EMX", "gcc::::::::",
|
||||
|
||||
##### VxWorks for various targets
|
||||
"vxworks-ppc60x","ccppc:-D_REENTRANT -mrtp -mhard-float -mstrict-align -fno-implicit-fp -DPPC32_fp60x -O2 -fstrength-reduce -fno-builtin -fno-strict-aliasing -Wall -DCPU=PPC32 -DTOOL_FAMILY=gnu -DTOOL=gnu -I\$(WIND_BASE)/target/usr/h -I\$(WIND_BASE)/target/usr/h/wrn/coreip:::VXWORKS:-Wl,--defsym,__wrs_rtp_base=0xe0000000 -L \$(WIND_BASE)/target/usr/lib/ppc/PPC32/common:::linux_ppc32.o:::::::::::::::ranlibppc:",
|
||||
"vxworks-ppcgen","ccppc:-D_REENTRANT -mrtp -msoft-float -mstrict-align -O1 -fno-builtin -fno-strict-aliasing -Wall -DCPU=PPC32 -DTOOL_FAMILY=gnu -DTOOL=gnu -I\$(WIND_BASE)/target/usr/h -I\$(WIND_BASE)/target/usr/h/wrn/coreip:::VXWORKS:-Wl,--defsym,__wrs_rtp_base=0xe0000000 -L \$(WIND_BASE)/target/usr/lib/ppc/PPC32/sfcommon:::linux_ppc32.o:::::::::::::::ranlibppc:",
|
||||
"vxworks-ppc405","ccppc:-g -msoft-float -mlongcall -DCPU=PPC405 -I\$(WIND_BASE)/target/h:::VXWORKS:-r:::::",
|
||||
"vxworks-ppc750","ccppc:-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h \$(DEBUG_FLAG):::VXWORKS:-r:::::",
|
||||
"vxworks-ppc750-debug","ccppc:-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DDEBUG -g:::VXWORKS:-r:::::",
|
||||
|
@@ -254,7 +254,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_OS2) && !defined(OPENSSL_SYS_NETWARE)
|
||||
#if !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_OS2) && !defined(OPENSSL_SYS_NETWARE) && !defined(OPENSSL_SYS_VXWORKS)
|
||||
# define HAVE_FORK 1
|
||||
#endif
|
||||
|
||||
|
6
config
6
config
@@ -362,6 +362,10 @@ case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
|
||||
NONSTOP_KERNEL*)
|
||||
echo "nsr-tandem-nsk"; exit 0;
|
||||
;;
|
||||
|
||||
vxworks*)
|
||||
echo "${MACHINE}-whatever-vxworks"; exit 0;
|
||||
;;
|
||||
esac
|
||||
|
||||
#
|
||||
@@ -524,6 +528,8 @@ case "$GUESSOS" in
|
||||
OUT="linux-ppc64"
|
||||
;;
|
||||
ppc-*-linux2) OUT="linux-ppc" ;;
|
||||
ppc60x-*-vxworks*) OUT="vxworks-ppc60x" ;;
|
||||
ppcgen-*-vxworks*) OUT="vxworks-ppcgen" ;;
|
||||
ia64-*-linux?) OUT="linux-ia64" ;;
|
||||
sparc64-*-linux2)
|
||||
OUT="linux64-sparcv9" ;;
|
||||
|
@@ -54,6 +54,7 @@ bn_mul_mont:
|
||||
push %r14
|
||||
push %r15
|
||||
|
||||
mov ${num}d,${num}d
|
||||
lea 2($num),%rax
|
||||
mov %rsp,%rbp
|
||||
neg %rax
|
||||
|
@@ -323,8 +323,43 @@ int RAND_poll(void)
|
||||
|
||||
|
||||
#if defined(OPENSSL_SYS_VXWORKS)
|
||||
/* Note: the existence of /dev/urandom on VxWorks platforms is uncommon
|
||||
* however we check for one and use it if found for those cases where
|
||||
* it is present. */
|
||||
int RAND_poll(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
unsigned long l;
|
||||
#ifdef DEVRANDOM
|
||||
unsigned char buf[ENTROPY_NEEDED];
|
||||
int n = 0, r, fd;
|
||||
|
||||
if ((fd = open("/dev/urandom", O_RDONLY, 0)) >= 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
r = read(fd,(unsigned char *)buf+n, ENTROPY_NEEDED-n);
|
||||
if (r > 0)
|
||||
n += r;
|
||||
}
|
||||
while ((r > 0 || errno == EINTR) && n < ENTROPY_NEEDED);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
||||
if (n > 0)
|
||||
{
|
||||
RAND_add(buf,sizeof buf,(double)n);
|
||||
OPENSSL_cleanse(buf,n);
|
||||
}
|
||||
#endif
|
||||
|
||||
l=time(NULL);
|
||||
RAND_add(&l,sizeof(l),0.0);
|
||||
|
||||
#if defined(DEVRANDOM)
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@@ -56,8 +56,6 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/* We need to define this to get macros like S_IFBLK and S_IFCHR */
|
||||
#define _XOPEN_SOURCE 500
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
@@ -69,6 +67,10 @@
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/buffer.h>
|
||||
|
||||
#if !defined(OPENSSL_SYS_VXWORKS)
|
||||
/* We need to define this to get macros like S_IFBLK and S_IFCHR */
|
||||
# define _XOPEN_SOURCE 500
|
||||
#endif
|
||||
#ifdef OPENSSL_SYS_VMS
|
||||
#include <unixio.h>
|
||||
#endif
|
||||
|
@@ -122,7 +122,9 @@
|
||||
* sigaction and fileno included. -pedantic would be more appropriate for
|
||||
* the intended purposes, but we can't prevent users from adding -ansi.
|
||||
*/
|
||||
#define _POSIX_C_SOURCE 1
|
||||
#if !defined(OPENSSL_SYS_VXWORKS)
|
||||
# define _POSIX_C_SOURCE 1
|
||||
#endif
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@@ -20,35 +20,15 @@ int main()
|
||||
|
||||
#include "fips_utl.h"
|
||||
|
||||
static void pbn(const char *name, BIGNUM *bn)
|
||||
{
|
||||
int len, i;
|
||||
unsigned char *tmp;
|
||||
len = BN_num_bytes(bn);
|
||||
tmp = OPENSSL_malloc(len);
|
||||
if (!tmp)
|
||||
{
|
||||
fprintf(stderr, "Memory allocation error\n");
|
||||
return;
|
||||
}
|
||||
BN_bn2bin(bn, tmp);
|
||||
printf("%s = ", name);
|
||||
for (i = 0; i < len; i++)
|
||||
printf("%02X", tmp[i]);
|
||||
fputs("\n", stdout);
|
||||
OPENSSL_free(tmp);
|
||||
return;
|
||||
}
|
||||
|
||||
void primes()
|
||||
void primes(FILE *in, FILE *out)
|
||||
{
|
||||
char buf[10240];
|
||||
char lbuf[10240];
|
||||
char *keyword, *value;
|
||||
|
||||
while(fgets(buf,sizeof buf,stdin) != NULL)
|
||||
while(fgets(buf,sizeof buf,in) != NULL)
|
||||
{
|
||||
fputs(buf,stdout);
|
||||
fputs(buf,out);
|
||||
if (!parse_line(&keyword, &value, lbuf, buf))
|
||||
continue;
|
||||
if(!strcmp(keyword,"Prime"))
|
||||
@@ -57,24 +37,24 @@ void primes()
|
||||
|
||||
pp=BN_new();
|
||||
do_hex2bn(&pp,value);
|
||||
printf("result= %c\n",
|
||||
fprintf(out, "result= %c\n",
|
||||
BN_is_prime_ex(pp,20,NULL,NULL) ? 'P' : 'F');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pqg()
|
||||
void pqg(FILE *in, FILE *out)
|
||||
{
|
||||
char buf[1024];
|
||||
char lbuf[1024];
|
||||
char *keyword, *value;
|
||||
int nmod=0;
|
||||
|
||||
while(fgets(buf,sizeof buf,stdin) != NULL)
|
||||
while(fgets(buf,sizeof buf,in) != NULL)
|
||||
{
|
||||
if (!parse_line(&keyword, &value, lbuf, buf))
|
||||
{
|
||||
fputs(buf,stdout);
|
||||
fputs(buf,out);
|
||||
continue;
|
||||
}
|
||||
if(!strcmp(keyword,"[mod"))
|
||||
@@ -83,7 +63,7 @@ void pqg()
|
||||
{
|
||||
int n=atoi(value);
|
||||
|
||||
printf("[mod = %d]\n\n",nmod);
|
||||
fprintf(out, "[mod = %d]\n\n",nmod);
|
||||
|
||||
while(n--)
|
||||
{
|
||||
@@ -98,22 +78,22 @@ void pqg()
|
||||
do_print_errors();
|
||||
exit(1);
|
||||
}
|
||||
pbn("P",dsa->p);
|
||||
pbn("Q",dsa->q);
|
||||
pbn("G",dsa->g);
|
||||
pv("Seed",seed,20);
|
||||
printf("c = %d\n",counter);
|
||||
printf("H = %lx\n",h);
|
||||
putc('\n',stdout);
|
||||
do_bn_print_name(out, "P",dsa->p);
|
||||
do_bn_print_name(out, "Q",dsa->q);
|
||||
do_bn_print_name(out, "G",dsa->g);
|
||||
OutputValue("Seed",seed,20, out, 0);
|
||||
fprintf(out, "c = %d\n",counter);
|
||||
fprintf(out, "H = %lx\n",h);
|
||||
fputs("\n", out);
|
||||
}
|
||||
}
|
||||
else
|
||||
fputs(buf,stdout);
|
||||
fputs(buf,out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void pqgver()
|
||||
void pqgver(FILE *in, FILE *out)
|
||||
{
|
||||
char buf[1024];
|
||||
char lbuf[1024];
|
||||
@@ -125,11 +105,11 @@ void pqgver()
|
||||
int nmod=0;
|
||||
unsigned char seed[1024];
|
||||
|
||||
while(fgets(buf,sizeof buf,stdin) != NULL)
|
||||
while(fgets(buf,sizeof buf,in) != NULL)
|
||||
{
|
||||
if (!parse_line(&keyword, &value, lbuf, buf))
|
||||
{
|
||||
fputs(buf,stdout);
|
||||
fputs(buf,out);
|
||||
continue;
|
||||
}
|
||||
if(!strcmp(keyword,"[mod"))
|
||||
@@ -159,12 +139,12 @@ void pqgver()
|
||||
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);
|
||||
do_bn_print_name(out, "P",p);
|
||||
do_bn_print_name(out, "Q",q);
|
||||
do_bn_print_name(out, "G",g);
|
||||
OutputValue("Seed",seed,20, out, 0);
|
||||
fprintf(out, "c = %d\n",counter);
|
||||
fprintf(out, "H = %lx\n",h);
|
||||
dsa = FIPS_dsa_new();
|
||||
if (!DSA_generate_parameters_ex(dsa, nmod,seed,20 ,&counter2,&h2,NULL))
|
||||
{
|
||||
@@ -173,9 +153,9 @@ void pqgver()
|
||||
}
|
||||
if (BN_cmp(dsa->p, p) || BN_cmp(dsa->q, q) || BN_cmp(dsa->g, g)
|
||||
|| (counter != counter2) || (h != h2))
|
||||
printf("Result = F\n");
|
||||
fprintf(out, "Result = F\n");
|
||||
else
|
||||
printf("Result = T\n");
|
||||
fprintf(out, "Result = T\n");
|
||||
BN_free(p);
|
||||
BN_free(q);
|
||||
BN_free(g);
|
||||
@@ -189,18 +169,18 @@ void pqgver()
|
||||
}
|
||||
|
||||
|
||||
void keypair()
|
||||
void keypair(FILE *in, FILE *out)
|
||||
{
|
||||
char buf[1024];
|
||||
char lbuf[1024];
|
||||
char *keyword, *value;
|
||||
int nmod=0;
|
||||
|
||||
while(fgets(buf,sizeof buf,stdin) != NULL)
|
||||
while(fgets(buf,sizeof buf,in) != NULL)
|
||||
{
|
||||
if (!parse_line(&keyword, &value, lbuf, buf))
|
||||
{
|
||||
fputs(buf,stdout);
|
||||
fputs(buf,out);
|
||||
continue;
|
||||
}
|
||||
if(!strcmp(keyword,"[mod"))
|
||||
@@ -210,17 +190,17 @@ void keypair()
|
||||
DSA *dsa;
|
||||
int n=atoi(value);
|
||||
|
||||
printf("[mod = %d]\n\n",nmod);
|
||||
fprintf(out, "[mod = %d]\n\n",nmod);
|
||||
dsa = FIPS_dsa_new();
|
||||
if (!DSA_generate_parameters_ex(dsa, nmod,NULL,0,NULL,NULL,NULL))
|
||||
{
|
||||
do_print_errors();
|
||||
exit(1);
|
||||
}
|
||||
pbn("P",dsa->p);
|
||||
pbn("Q",dsa->q);
|
||||
pbn("G",dsa->g);
|
||||
putc('\n',stdout);
|
||||
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);
|
||||
|
||||
while(n--)
|
||||
{
|
||||
@@ -230,15 +210,15 @@ void keypair()
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pbn("X",dsa->priv_key);
|
||||
pbn("Y",dsa->pub_key);
|
||||
putc('\n',stdout);
|
||||
do_bn_print_name(out, "X",dsa->priv_key);
|
||||
do_bn_print_name(out, "Y",dsa->pub_key);
|
||||
fputs("\n", out);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void siggen()
|
||||
void siggen(FILE *in, FILE *out)
|
||||
{
|
||||
char buf[1024];
|
||||
char lbuf[1024];
|
||||
@@ -246,17 +226,17 @@ void siggen()
|
||||
int nmod=0;
|
||||
DSA *dsa=NULL;
|
||||
|
||||
while(fgets(buf,sizeof buf,stdin) != NULL)
|
||||
while(fgets(buf,sizeof buf,in) != NULL)
|
||||
{
|
||||
if (!parse_line(&keyword, &value, lbuf, buf))
|
||||
{
|
||||
fputs(buf,stdout);
|
||||
fputs(buf,out);
|
||||
continue;
|
||||
}
|
||||
if(!strcmp(keyword,"[mod"))
|
||||
{
|
||||
nmod=atoi(value);
|
||||
printf("[mod = %d]\n\n",nmod);
|
||||
fprintf(out, "[mod = %d]\n\n",nmod);
|
||||
if (dsa)
|
||||
FIPS_dsa_free(dsa);
|
||||
dsa = FIPS_dsa_new();
|
||||
@@ -265,10 +245,10 @@ void siggen()
|
||||
do_print_errors();
|
||||
exit(1);
|
||||
}
|
||||
pbn("P",dsa->p);
|
||||
pbn("Q",dsa->q);
|
||||
pbn("G",dsa->g);
|
||||
putc('\n',stdout);
|
||||
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);
|
||||
}
|
||||
else if(!strcmp(keyword,"Msg"))
|
||||
{
|
||||
@@ -282,7 +262,7 @@ void siggen()
|
||||
EVP_MD_CTX_init(&mctx);
|
||||
|
||||
n=hex2bin(value,msg);
|
||||
pv("Msg",msg,n);
|
||||
OutputValue("Msg",msg,n, out, 0);
|
||||
|
||||
if (!DSA_generate_key(dsa))
|
||||
{
|
||||
@@ -291,7 +271,7 @@ void siggen()
|
||||
}
|
||||
pk.type = EVP_PKEY_DSA;
|
||||
pk.pkey.dsa = dsa;
|
||||
pbn("Y",dsa->pub_key);
|
||||
do_bn_print_name(out, "Y",dsa->pub_key);
|
||||
|
||||
EVP_SignInit_ex(&mctx, EVP_dss1(), NULL);
|
||||
EVP_SignUpdate(&mctx, msg, n);
|
||||
@@ -300,9 +280,9 @@ void siggen()
|
||||
sig = DSA_SIG_new();
|
||||
FIPS_dsa_sig_decode(sig, sbuf, slen);
|
||||
|
||||
pbn("R",sig->r);
|
||||
pbn("S",sig->s);
|
||||
putc('\n',stdout);
|
||||
do_bn_print_name(out, "R",sig->r);
|
||||
do_bn_print_name(out, "S",sig->s);
|
||||
fputs("\n", out);
|
||||
DSA_SIG_free(sig);
|
||||
EVP_MD_CTX_cleanup(&mctx);
|
||||
}
|
||||
@@ -311,7 +291,7 @@ void siggen()
|
||||
FIPS_dsa_free(dsa);
|
||||
}
|
||||
|
||||
void sigver()
|
||||
void sigver(FILE *in, FILE *out)
|
||||
{
|
||||
DSA *dsa=NULL;
|
||||
char buf[1024];
|
||||
@@ -325,11 +305,11 @@ void sigver()
|
||||
sig->r = NULL;
|
||||
sig->s = NULL;
|
||||
|
||||
while(fgets(buf,sizeof buf,stdin) != NULL)
|
||||
while(fgets(buf,sizeof buf,in) != NULL)
|
||||
{
|
||||
if (!parse_line(&keyword, &value, lbuf, buf))
|
||||
{
|
||||
fputs(buf,stdout);
|
||||
fputs(buf,out);
|
||||
continue;
|
||||
}
|
||||
if(!strcmp(keyword,"[mod"))
|
||||
@@ -347,16 +327,16 @@ void sigver()
|
||||
{
|
||||
dsa->g=hex2bn(value);
|
||||
|
||||
printf("[mod = %d]\n\n",nmod);
|
||||
pbn("P",dsa->p);
|
||||
pbn("Q",dsa->q);
|
||||
pbn("G",dsa->g);
|
||||
putc('\n',stdout);
|
||||
fprintf(out, "[mod = %d]\n\n",nmod);
|
||||
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);
|
||||
}
|
||||
else if(!strcmp(keyword,"Msg"))
|
||||
{
|
||||
n=hex2bin(value,msg);
|
||||
pv("Msg",msg,n);
|
||||
OutputValue("Msg",msg,n, out, 0);
|
||||
}
|
||||
else if(!strcmp(keyword,"Y"))
|
||||
dsa->pub_key=hex2bn(value);
|
||||
@@ -374,9 +354,9 @@ void sigver()
|
||||
pk.pkey.dsa = dsa;
|
||||
sig->s=hex2bn(value);
|
||||
|
||||
pbn("Y",dsa->pub_key);
|
||||
pbn("R",sig->r);
|
||||
pbn("S",sig->s);
|
||||
do_bn_print_name(out, "Y",dsa->pub_key);
|
||||
do_bn_print_name(out, "R",sig->r);
|
||||
do_bn_print_name(out, "S",sig->s);
|
||||
|
||||
slen = FIPS_dsa_sig_encode(sigbuf, sig);
|
||||
EVP_VerifyInit_ex(&mctx, EVP_dss1(), NULL);
|
||||
@@ -384,17 +364,38 @@ void sigver()
|
||||
r = EVP_VerifyFinal(&mctx, sigbuf, slen, &pk);
|
||||
EVP_MD_CTX_cleanup(&mctx);
|
||||
|
||||
printf("Result = %c\n", r == 1 ? 'P' : 'F');
|
||||
putc('\n',stdout);
|
||||
fprintf(out, "Result = %c\n", r == 1 ? 'P' : 'F');
|
||||
fputs("\n", out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc,char **argv)
|
||||
{
|
||||
if(argc != 2)
|
||||
FILE *in, *out;
|
||||
if (argc == 4)
|
||||
{
|
||||
fprintf(stderr,"%s [prime|pqg]\n",argv[0]);
|
||||
in = fopen(argv[2], "r");
|
||||
if (!in)
|
||||
{
|
||||
fprintf(stderr, "Error opening input file\n");
|
||||
exit(1);
|
||||
}
|
||||
out = fopen(argv[3], "w");
|
||||
if (!out)
|
||||
{
|
||||
fprintf(stderr, "Error opening output file\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else if (argc == 2)
|
||||
{
|
||||
in = stdin;
|
||||
out = stdout;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"%s [prime|pqg|pqgver|keypair|siggen|sigver]\n",argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
if(!FIPS_mode_set(1))
|
||||
@@ -403,23 +404,29 @@ int main(int argc,char **argv)
|
||||
exit(1);
|
||||
}
|
||||
if(!strcmp(argv[1],"prime"))
|
||||
primes();
|
||||
primes(in, out);
|
||||
else if(!strcmp(argv[1],"pqg"))
|
||||
pqg();
|
||||
pqg(in, out);
|
||||
else if(!strcmp(argv[1],"pqgver"))
|
||||
pqgver();
|
||||
pqgver(in, out);
|
||||
else if(!strcmp(argv[1],"keypair"))
|
||||
keypair();
|
||||
keypair(in, out);
|
||||
else if(!strcmp(argv[1],"siggen"))
|
||||
siggen();
|
||||
siggen(in, out);
|
||||
else if(!strcmp(argv[1],"sigver"))
|
||||
sigver();
|
||||
sigver(in, out);
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"Don't know how to %s.\n",argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (argc == 4)
|
||||
{
|
||||
fclose(in);
|
||||
fclose(out);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -19,6 +19,7 @@
|
||||
(defined(__linux) && (defined(__arm) || defined(__arm__))) || \
|
||||
(defined(__i386) || defined(__i386__)) || \
|
||||
(defined(__x86_64) || defined(__x86_64__)) || \
|
||||
defined(__ANDROID__) || \
|
||||
(defined(vax) || defined(__vax__))
|
||||
# define POINTER_TO_FUNCTION_IS_POINTER_TO_1ST_INSTRUCTION
|
||||
# endif
|
||||
@@ -173,6 +174,8 @@ void *FIPS_ref_point()
|
||||
# else
|
||||
return (void *)FIPS_ref_point;
|
||||
# endif
|
||||
#elif defined(__vxworks)
|
||||
return (void *)FIPS_ref_point;
|
||||
/*
|
||||
* In case you wonder why there is no #ifdef __linux. All Linux targets
|
||||
* are GCC-based and therefore are covered by instruction_pointer above
|
||||
|
@@ -68,7 +68,7 @@
|
||||
#define HMAC_SHA1_SIG "?have to make sure this string is unique"
|
||||
#endif
|
||||
|
||||
static const unsigned char FINGERPRINT_ascii_value[40] = HMAC_SHA1_SIG;
|
||||
static const unsigned char FINGERPRINT_ascii_value[41] = HMAC_SHA1_SIG;
|
||||
|
||||
#define atox(c) ((c)>='a'?((c)-'a'+10):((c)>='A'?(c)-'A'+10:(c)-'0'))
|
||||
|
||||
|
@@ -1 +1 @@
|
||||
HMAC-SHA1(fips_premain.c)= 9e5ddba185ac446e0cf36fcf8e1b3acffe5d0b2c
|
||||
HMAC-SHA1(fips_premain.c)= dab2842517034a42dfdb21a285d4f0f4d7f6f920
|
||||
|
@@ -294,6 +294,10 @@ foreach (@ARGV)
|
||||
{
|
||||
$win32 = 1;
|
||||
}
|
||||
if ($_ eq "--vxworks")
|
||||
{
|
||||
$vxworks = 1;
|
||||
}
|
||||
elsif ($_ eq "--onedir")
|
||||
{
|
||||
$onedir = 1;
|
||||
@@ -332,6 +336,11 @@ foreach (@ARGV)
|
||||
}
|
||||
}
|
||||
|
||||
if ($win32 && $vxworks) {
|
||||
print STDERR "Can't specify both --win32 and --vxworks\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$tvdir = "." unless defined $tvdir;
|
||||
|
||||
if ($win32)
|
||||
@@ -356,6 +365,21 @@ rem Test vector run script
|
||||
rem Auto generated by mkfipsscr.pl script
|
||||
rem Do not edit
|
||||
|
||||
END
|
||||
|
||||
}
|
||||
elsif ($vxworks)
|
||||
{
|
||||
# Always assume onedir.
|
||||
$tprefix = "" unless defined $tprefix;
|
||||
$outfile = "fipstests" unless defined $outfile;
|
||||
open(OUT, ">$outfile");
|
||||
|
||||
print OUT <<END;
|
||||
# Test vector run script
|
||||
# Auto generated by mkfipsscr.pl script
|
||||
# Do not edit
|
||||
|
||||
END
|
||||
|
||||
}
|
||||
@@ -457,6 +481,16 @@ sub test_dir
|
||||
echo Running tests in $req
|
||||
if exist "$rsp" rd /s /q "$rsp"
|
||||
md "$rsp"
|
||||
END
|
||||
}
|
||||
elsif ($vxworks)
|
||||
{
|
||||
print OUT <<END;
|
||||
|
||||
echo Running tests in "$req"
|
||||
rm -r "$rsp"
|
||||
mkdir "$rsp"
|
||||
|
||||
END
|
||||
}
|
||||
else
|
||||
@@ -484,6 +518,10 @@ sub test_line
|
||||
$rsp =~ tr|/|\\|;
|
||||
print OUT "$tprefix$tcmd \"$req\" \"$rsp\"\n";
|
||||
}
|
||||
elsif ($vxworks)
|
||||
{
|
||||
print OUT "run $tprefix$tcmd \"$req\" \"$rsp\"\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print OUT <<END;
|
||||
@@ -518,7 +556,11 @@ END
|
||||
{
|
||||
$req =~ tr|/|\\|;
|
||||
$rsp =~ tr|/|\\|;
|
||||
print OUT "$tprefix$tcmd < \"$req\" > \"$rsp\"\n";
|
||||
print OUT "$tprefix$tcmd < \"$req\" > \"$rsp\"\n";
|
||||
}
|
||||
elsif ($vxworks)
|
||||
{
|
||||
print OUT "run $tprefix$tcmd \"$req\" \"$rsp\"\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -64,8 +64,11 @@
|
||||
#include <openssl/aes.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/fips_rand.h>
|
||||
#ifndef OPENSSL_SYS_WIN32
|
||||
#include <sys/time.h>
|
||||
#if !(defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS))
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
#if defined(OPENSSL_SYS_VXWORKS)
|
||||
# include <time.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#ifndef OPENSSL_SYS_WIN32
|
||||
@@ -223,6 +226,8 @@ static void fips_get_dt(FIPS_PRNG_CTX *ctx)
|
||||
{
|
||||
#ifdef OPENSSL_SYS_WIN32
|
||||
FILETIME ft;
|
||||
#elif defined(OPENSSL_SYS_VXWORKS)
|
||||
struct timespec ts;
|
||||
#else
|
||||
struct timeval tv;
|
||||
#endif
|
||||
@@ -242,6 +247,16 @@ static void fips_get_dt(FIPS_PRNG_CTX *ctx)
|
||||
buf[5] = (unsigned char) ((ft.dwLowDateTime >> 8) & 0xff);
|
||||
buf[6] = (unsigned char) ((ft.dwLowDateTime >> 16) & 0xff);
|
||||
buf[7] = (unsigned char) ((ft.dwLowDateTime >> 24) & 0xff);
|
||||
#elif defined(OPENSSL_SYS_VXWORKS)
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
buf[0] = (unsigned char) (ts.tv_sec & 0xff);
|
||||
buf[1] = (unsigned char) ((ts.tv_sec >> 8) & 0xff);
|
||||
buf[2] = (unsigned char) ((ts.tv_sec >> 16) & 0xff);
|
||||
buf[3] = (unsigned char) ((ts.tv_sec >> 24) & 0xff);
|
||||
buf[4] = (unsigned char) (ts.tv_nsec & 0xff);
|
||||
buf[5] = (unsigned char) ((ts.tv_nsec >> 8) & 0xff);
|
||||
buf[6] = (unsigned char) ((ts.tv_nsec >> 16) & 0xff);
|
||||
buf[7] = (unsigned char) ((ts.tv_nsec >> 24) & 0xff);
|
||||
#else
|
||||
gettimeofday(&tv,NULL);
|
||||
buf[0] = (unsigned char) (tv.tv_sec & 0xff);
|
||||
|
@@ -30,7 +30,7 @@ int main()
|
||||
|
||||
#include "fips_utl.h"
|
||||
|
||||
void vst()
|
||||
void vst(FILE *in, FILE *out)
|
||||
{
|
||||
unsigned char *key = NULL;
|
||||
unsigned char *v = NULL;
|
||||
@@ -43,9 +43,9 @@ void vst()
|
||||
|
||||
keylen = 0;
|
||||
|
||||
while(fgets(buf,sizeof buf,stdin) != NULL)
|
||||
while(fgets(buf,sizeof buf,in) != NULL)
|
||||
{
|
||||
fputs(buf,stdout);
|
||||
fputs(buf,out);
|
||||
if(!strncmp(buf,"[AES 128-Key]", 13))
|
||||
keylen = 16;
|
||||
else if(!strncmp(buf,"[AES 192-Key]", 13))
|
||||
@@ -96,7 +96,7 @@ void vst()
|
||||
return;
|
||||
}
|
||||
|
||||
pv("R",ret,16);
|
||||
OutputValue("R",ret,16, out, 0);
|
||||
OPENSSL_free(key);
|
||||
key = NULL;
|
||||
OPENSSL_free(dt);
|
||||
@@ -107,7 +107,7 @@ void vst()
|
||||
}
|
||||
}
|
||||
|
||||
void mct()
|
||||
void mct(FILE *in, FILE *out)
|
||||
{
|
||||
unsigned char *key = NULL;
|
||||
unsigned char *v = NULL;
|
||||
@@ -121,9 +121,9 @@ void mct()
|
||||
|
||||
keylen = 0;
|
||||
|
||||
while(fgets(buf,sizeof buf,stdin) != NULL)
|
||||
while(fgets(buf,sizeof buf,in) != NULL)
|
||||
{
|
||||
fputs(buf,stdout);
|
||||
fputs(buf,out);
|
||||
if(!strncmp(buf,"[AES 128-Key]", 13))
|
||||
keylen = 16;
|
||||
else if(!strncmp(buf,"[AES 192-Key]", 13))
|
||||
@@ -184,7 +184,7 @@ void mct()
|
||||
}
|
||||
}
|
||||
|
||||
pv("R",ret,16);
|
||||
OutputValue("R",ret,16, out, 0);
|
||||
OPENSSL_free(key);
|
||||
key = NULL;
|
||||
OPENSSL_free(dt);
|
||||
@@ -197,7 +197,28 @@ void mct()
|
||||
|
||||
int main(int argc,char **argv)
|
||||
{
|
||||
if(argc != 2)
|
||||
FILE *in, *out;
|
||||
if (argc == 4)
|
||||
{
|
||||
in = fopen(argv[2], "r");
|
||||
if (!in)
|
||||
{
|
||||
fprintf(stderr, "Error opening input file\n");
|
||||
exit(1);
|
||||
}
|
||||
out = fopen(argv[3], "w");
|
||||
if (!out)
|
||||
{
|
||||
fprintf(stderr, "Error opening output file\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else if (argc == 2)
|
||||
{
|
||||
in = stdin;
|
||||
out = stdout;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"%s [mct|vst]\n",argv[0]);
|
||||
exit(1);
|
||||
@@ -215,15 +236,21 @@ int main(int argc,char **argv)
|
||||
exit(1);
|
||||
}
|
||||
if(!strcmp(argv[1],"mct"))
|
||||
mct();
|
||||
mct(in, out);
|
||||
else if(!strcmp(argv[1],"vst"))
|
||||
vst();
|
||||
vst(in, out);
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"Don't know how to %s.\n",argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (argc == 4)
|
||||
{
|
||||
fclose(in);
|
||||
fclose(out);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@@ -149,7 +149,7 @@ if ($FLAVOR =~ /CE/)
|
||||
else
|
||||
{
|
||||
$ex_libs.=' gdi32.lib advapi32.lib user32.lib';
|
||||
$ex_libs.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/);
|
||||
$ex_libs.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/ and `cl 2>&1` =~ /14\.00\.4[0-9]{4}\./);
|
||||
}
|
||||
|
||||
# As native NT API is pure UNICODE, our WIN-NT build defaults to UNICODE,
|
||||
@@ -331,7 +331,7 @@ sub do_lib_rule
|
||||
|
||||
if ($name eq "")
|
||||
{
|
||||
$ex.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/);
|
||||
$ex_libs.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/ and `cl 2>&1` =~ /14\.00\.4[0-9]{4}\./);
|
||||
}
|
||||
elsif ($FLAVOR =~ /CE/)
|
||||
{
|
||||
@@ -341,7 +341,7 @@ sub do_lib_rule
|
||||
{
|
||||
$ex.=' unicows.lib' if ($FLAVOR =~ /NT/);
|
||||
$ex.=' wsock32.lib gdi32.lib advapi32.lib user32.lib';
|
||||
$ex.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/);
|
||||
$ex_libs.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/ and `cl 2>&1` =~ /14\.00\.4[0-9]{4}\./);
|
||||
}
|
||||
$ex.=" $zlib_lib" if $zlib_opt == 1 && $target =~ /O_CRYPTO/;
|
||||
|
||||
|
Reference in New Issue
Block a user