Compare commits

...

3 Commits

Author SHA1 Message Date
Dr. Stephen Henson
0b603bcc34 VxWorks support. 2011-09-25 18:11:42 +00:00
Dr. Stephen Henson
8de14571d6 Update rand and dsa algorithm test programs so they can support command
line filenames and no longer require redirection, which some platforms
don't support.
2011-09-25 17:11:53 +00:00
Dr. Stephen Henson
f47d923d83 Fix fingerprint size to include null terminator. 2011-09-25 17:10:16 +00:00
13 changed files with 256 additions and 116 deletions

View File

@@ -524,6 +524,8 @@ my %table=(
"OS2-EMX", "gcc::::::::", "OS2-EMX", "gcc::::::::",
##### VxWorks for various targets ##### 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-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","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:::::", "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:::::",

View File

@@ -254,7 +254,7 @@
# endif # endif
#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 # define HAVE_FORK 1
#endif #endif

6
config
View File

@@ -362,6 +362,10 @@ case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
NONSTOP_KERNEL*) NONSTOP_KERNEL*)
echo "nsr-tandem-nsk"; exit 0; echo "nsr-tandem-nsk"; exit 0;
;; ;;
vxworks*)
echo "${MACHINE}-whatever-vxworks"; exit 0;
;;
esac esac
# #
@@ -524,6 +528,8 @@ case "$GUESSOS" in
OUT="linux-ppc64" OUT="linux-ppc64"
;; ;;
ppc-*-linux2) OUT="linux-ppc" ;; ppc-*-linux2) OUT="linux-ppc" ;;
ppc60x-*-vxworks*) OUT="vxworks-ppc60x" ;;
ppcgen-*-vxworks*) OUT="vxworks-ppcgen" ;;
ia64-*-linux?) OUT="linux-ia64" ;; ia64-*-linux?) OUT="linux-ia64" ;;
sparc64-*-linux2) sparc64-*-linux2)
OUT="linux64-sparcv9" ;; OUT="linux64-sparcv9" ;;

View File

@@ -323,8 +323,43 @@ int RAND_poll(void)
#if defined(OPENSSL_SYS_VXWORKS) #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) 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 #endif

View File

@@ -56,8 +56,6 @@
* [including the GNU Public Licence.] * [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 <errno.h>
#include <stdio.h> #include <stdio.h>
@@ -69,6 +67,10 @@
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/buffer.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 #ifdef OPENSSL_SYS_VMS
#include <unixio.h> #include <unixio.h>
#endif #endif

View File

@@ -122,7 +122,9 @@
* sigaction and fileno included. -pedantic would be more appropriate for * sigaction and fileno included. -pedantic would be more appropriate for
* the intended purposes, but we can't prevent users from adding -ansi. * 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 <signal.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>

View File

@@ -20,35 +20,15 @@ int main()
#include "fips_utl.h" #include "fips_utl.h"
static void pbn(const char *name, BIGNUM *bn) void primes(FILE *in, FILE *out)
{
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()
{ {
char buf[10240]; char buf[10240];
char lbuf[10240]; char lbuf[10240];
char *keyword, *value; 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)) if (!parse_line(&keyword, &value, lbuf, buf))
continue; continue;
if(!strcmp(keyword,"Prime")) if(!strcmp(keyword,"Prime"))
@@ -57,24 +37,24 @@ void primes()
pp=BN_new(); pp=BN_new();
do_hex2bn(&pp,value); do_hex2bn(&pp,value);
printf("result= %c\n", fprintf(out, "result= %c\n",
BN_is_prime_ex(pp,20,NULL,NULL) ? 'P' : 'F'); BN_is_prime_ex(pp,20,NULL,NULL) ? 'P' : 'F');
} }
} }
} }
void pqg() void pqg(FILE *in, FILE *out)
{ {
char buf[1024]; char buf[1024];
char lbuf[1024]; char lbuf[1024];
char *keyword, *value; char *keyword, *value;
int nmod=0; int nmod=0;
while(fgets(buf,sizeof buf,stdin) != NULL) while(fgets(buf,sizeof buf,in) != NULL)
{ {
if (!parse_line(&keyword, &value, lbuf, buf)) if (!parse_line(&keyword, &value, lbuf, buf))
{ {
fputs(buf,stdout); fputs(buf,out);
continue; continue;
} }
if(!strcmp(keyword,"[mod")) if(!strcmp(keyword,"[mod"))
@@ -83,7 +63,7 @@ void pqg()
{ {
int n=atoi(value); int n=atoi(value);
printf("[mod = %d]\n\n",nmod); fprintf(out, "[mod = %d]\n\n",nmod);
while(n--) while(n--)
{ {
@@ -98,22 +78,22 @@ void pqg()
do_print_errors(); do_print_errors();
exit(1); exit(1);
} }
pbn("P",dsa->p); do_bn_print_name(out, "P",dsa->p);
pbn("Q",dsa->q); do_bn_print_name(out, "Q",dsa->q);
pbn("G",dsa->g); do_bn_print_name(out, "G",dsa->g);
pv("Seed",seed,20); OutputValue("Seed",seed,20, out, 0);
printf("c = %d\n",counter); fprintf(out, "c = %d\n",counter);
printf("H = %lx\n",h); fprintf(out, "H = %lx\n",h);
putc('\n',stdout); fputs("\n", out);
} }
} }
else else
fputs(buf,stdout); fputs(buf,out);
} }
} }
void pqgver() void pqgver(FILE *in, FILE *out)
{ {
char buf[1024]; char buf[1024];
char lbuf[1024]; char lbuf[1024];
@@ -125,11 +105,11 @@ void pqgver()
int nmod=0; int nmod=0;
unsigned char seed[1024]; 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)) if (!parse_line(&keyword, &value, lbuf, buf))
{ {
fputs(buf,stdout); fputs(buf,out);
continue; continue;
} }
if(!strcmp(keyword,"[mod")) if(!strcmp(keyword,"[mod"))
@@ -159,12 +139,12 @@ void pqgver()
fprintf(stderr, "Parse Error\n"); fprintf(stderr, "Parse Error\n");
exit (1); exit (1);
} }
pbn("P",p); do_bn_print_name(out, "P",p);
pbn("Q",q); do_bn_print_name(out, "Q",q);
pbn("G",g); do_bn_print_name(out, "G",g);
pv("Seed",seed,20); OutputValue("Seed",seed,20, out, 0);
printf("c = %d\n",counter); fprintf(out, "c = %d\n",counter);
printf("H = %lx\n",h); fprintf(out, "H = %lx\n",h);
dsa = FIPS_dsa_new(); dsa = FIPS_dsa_new();
if (!DSA_generate_parameters_ex(dsa, nmod,seed,20 ,&counter2,&h2,NULL)) 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) if (BN_cmp(dsa->p, p) || BN_cmp(dsa->q, q) || BN_cmp(dsa->g, g)
|| (counter != counter2) || (h != h2)) || (counter != counter2) || (h != h2))
printf("Result = F\n"); fprintf(out, "Result = F\n");
else else
printf("Result = T\n"); fprintf(out, "Result = T\n");
BN_free(p); BN_free(p);
BN_free(q); BN_free(q);
BN_free(g); BN_free(g);
@@ -189,18 +169,18 @@ void pqgver()
} }
void keypair() void keypair(FILE *in, FILE *out)
{ {
char buf[1024]; char buf[1024];
char lbuf[1024]; char lbuf[1024];
char *keyword, *value; char *keyword, *value;
int nmod=0; int nmod=0;
while(fgets(buf,sizeof buf,stdin) != NULL) while(fgets(buf,sizeof buf,in) != NULL)
{ {
if (!parse_line(&keyword, &value, lbuf, buf)) if (!parse_line(&keyword, &value, lbuf, buf))
{ {
fputs(buf,stdout); fputs(buf,out);
continue; continue;
} }
if(!strcmp(keyword,"[mod")) if(!strcmp(keyword,"[mod"))
@@ -210,17 +190,17 @@ void keypair()
DSA *dsa; DSA *dsa;
int n=atoi(value); int n=atoi(value);
printf("[mod = %d]\n\n",nmod); fprintf(out, "[mod = %d]\n\n",nmod);
dsa = FIPS_dsa_new(); dsa = FIPS_dsa_new();
if (!DSA_generate_parameters_ex(dsa, nmod,NULL,0,NULL,NULL,NULL)) if (!DSA_generate_parameters_ex(dsa, nmod,NULL,0,NULL,NULL,NULL))
{ {
do_print_errors(); do_print_errors();
exit(1); exit(1);
} }
pbn("P",dsa->p); do_bn_print_name(out, "P",dsa->p);
pbn("Q",dsa->q); do_bn_print_name(out, "Q",dsa->q);
pbn("G",dsa->g); do_bn_print_name(out, "G",dsa->g);
putc('\n',stdout); fputs("\n", out);
while(n--) while(n--)
{ {
@@ -230,15 +210,15 @@ void keypair()
exit(1); exit(1);
} }
pbn("X",dsa->priv_key); do_bn_print_name(out, "X",dsa->priv_key);
pbn("Y",dsa->pub_key); do_bn_print_name(out, "Y",dsa->pub_key);
putc('\n',stdout); fputs("\n", out);
} }
} }
} }
} }
void siggen() void siggen(FILE *in, FILE *out)
{ {
char buf[1024]; char buf[1024];
char lbuf[1024]; char lbuf[1024];
@@ -246,17 +226,17 @@ void siggen()
int nmod=0; int nmod=0;
DSA *dsa=NULL; DSA *dsa=NULL;
while(fgets(buf,sizeof buf,stdin) != NULL) while(fgets(buf,sizeof buf,in) != NULL)
{ {
if (!parse_line(&keyword, &value, lbuf, buf)) if (!parse_line(&keyword, &value, lbuf, buf))
{ {
fputs(buf,stdout); fputs(buf,out);
continue; continue;
} }
if(!strcmp(keyword,"[mod")) if(!strcmp(keyword,"[mod"))
{ {
nmod=atoi(value); nmod=atoi(value);
printf("[mod = %d]\n\n",nmod); fprintf(out, "[mod = %d]\n\n",nmod);
if (dsa) if (dsa)
FIPS_dsa_free(dsa); FIPS_dsa_free(dsa);
dsa = FIPS_dsa_new(); dsa = FIPS_dsa_new();
@@ -265,10 +245,10 @@ void siggen()
do_print_errors(); do_print_errors();
exit(1); exit(1);
} }
pbn("P",dsa->p); do_bn_print_name(out, "P",dsa->p);
pbn("Q",dsa->q); do_bn_print_name(out, "Q",dsa->q);
pbn("G",dsa->g); do_bn_print_name(out, "G",dsa->g);
putc('\n',stdout); fputs("\n", out);
} }
else if(!strcmp(keyword,"Msg")) else if(!strcmp(keyword,"Msg"))
{ {
@@ -282,7 +262,7 @@ void siggen()
EVP_MD_CTX_init(&mctx); EVP_MD_CTX_init(&mctx);
n=hex2bin(value,msg); n=hex2bin(value,msg);
pv("Msg",msg,n); OutputValue("Msg",msg,n, out, 0);
if (!DSA_generate_key(dsa)) if (!DSA_generate_key(dsa))
{ {
@@ -291,7 +271,7 @@ void siggen()
} }
pk.type = EVP_PKEY_DSA; pk.type = EVP_PKEY_DSA;
pk.pkey.dsa = 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_SignInit_ex(&mctx, EVP_dss1(), NULL);
EVP_SignUpdate(&mctx, msg, n); EVP_SignUpdate(&mctx, msg, n);
@@ -300,9 +280,9 @@ void siggen()
sig = DSA_SIG_new(); sig = DSA_SIG_new();
FIPS_dsa_sig_decode(sig, sbuf, slen); FIPS_dsa_sig_decode(sig, sbuf, slen);
pbn("R",sig->r); do_bn_print_name(out, "R",sig->r);
pbn("S",sig->s); do_bn_print_name(out, "S",sig->s);
putc('\n',stdout); fputs("\n", out);
DSA_SIG_free(sig); DSA_SIG_free(sig);
EVP_MD_CTX_cleanup(&mctx); EVP_MD_CTX_cleanup(&mctx);
} }
@@ -311,7 +291,7 @@ void siggen()
FIPS_dsa_free(dsa); FIPS_dsa_free(dsa);
} }
void sigver() void sigver(FILE *in, FILE *out)
{ {
DSA *dsa=NULL; DSA *dsa=NULL;
char buf[1024]; char buf[1024];
@@ -325,11 +305,11 @@ void sigver()
sig->r = NULL; sig->r = NULL;
sig->s = 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)) if (!parse_line(&keyword, &value, lbuf, buf))
{ {
fputs(buf,stdout); fputs(buf,out);
continue; continue;
} }
if(!strcmp(keyword,"[mod")) if(!strcmp(keyword,"[mod"))
@@ -347,16 +327,16 @@ void sigver()
{ {
dsa->g=hex2bn(value); dsa->g=hex2bn(value);
printf("[mod = %d]\n\n",nmod); fprintf(out, "[mod = %d]\n\n",nmod);
pbn("P",dsa->p); do_bn_print_name(out, "P",dsa->p);
pbn("Q",dsa->q); do_bn_print_name(out, "Q",dsa->q);
pbn("G",dsa->g); do_bn_print_name(out, "G",dsa->g);
putc('\n',stdout); fputs("\n", out);
} }
else if(!strcmp(keyword,"Msg")) else if(!strcmp(keyword,"Msg"))
{ {
n=hex2bin(value,msg); n=hex2bin(value,msg);
pv("Msg",msg,n); OutputValue("Msg",msg,n, out, 0);
} }
else if(!strcmp(keyword,"Y")) else if(!strcmp(keyword,"Y"))
dsa->pub_key=hex2bn(value); dsa->pub_key=hex2bn(value);
@@ -374,9 +354,9 @@ void sigver()
pk.pkey.dsa = dsa; pk.pkey.dsa = dsa;
sig->s=hex2bn(value); sig->s=hex2bn(value);
pbn("Y",dsa->pub_key); do_bn_print_name(out, "Y",dsa->pub_key);
pbn("R",sig->r); do_bn_print_name(out, "R",sig->r);
pbn("S",sig->s); do_bn_print_name(out, "S",sig->s);
slen = FIPS_dsa_sig_encode(sigbuf, sig); slen = FIPS_dsa_sig_encode(sigbuf, sig);
EVP_VerifyInit_ex(&mctx, EVP_dss1(), NULL); EVP_VerifyInit_ex(&mctx, EVP_dss1(), NULL);
@@ -384,17 +364,38 @@ void sigver()
r = EVP_VerifyFinal(&mctx, sigbuf, slen, &pk); r = EVP_VerifyFinal(&mctx, sigbuf, slen, &pk);
EVP_MD_CTX_cleanup(&mctx); EVP_MD_CTX_cleanup(&mctx);
printf("Result = %c\n", r == 1 ? 'P' : 'F'); fprintf(out, "Result = %c\n", r == 1 ? 'P' : 'F');
putc('\n',stdout); fputs("\n", out);
} }
} }
} }
int main(int argc,char **argv) 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); exit(1);
} }
if(!FIPS_mode_set(1)) if(!FIPS_mode_set(1))
@@ -403,23 +404,29 @@ int main(int argc,char **argv)
exit(1); exit(1);
} }
if(!strcmp(argv[1],"prime")) if(!strcmp(argv[1],"prime"))
primes(); primes(in, out);
else if(!strcmp(argv[1],"pqg")) else if(!strcmp(argv[1],"pqg"))
pqg(); pqg(in, out);
else if(!strcmp(argv[1],"pqgver")) else if(!strcmp(argv[1],"pqgver"))
pqgver(); pqgver(in, out);
else if(!strcmp(argv[1],"keypair")) else if(!strcmp(argv[1],"keypair"))
keypair(); keypair(in, out);
else if(!strcmp(argv[1],"siggen")) else if(!strcmp(argv[1],"siggen"))
siggen(); siggen(in, out);
else if(!strcmp(argv[1],"sigver")) else if(!strcmp(argv[1],"sigver"))
sigver(); sigver(in, out);
else else
{ {
fprintf(stderr,"Don't know how to %s.\n",argv[1]); fprintf(stderr,"Don't know how to %s.\n",argv[1]);
exit(1); exit(1);
} }
if (argc == 4)
{
fclose(in);
fclose(out);
}
return 0; return 0;
} }

View File

@@ -174,6 +174,8 @@ void *FIPS_ref_point()
# else # else
return (void *)FIPS_ref_point; return (void *)FIPS_ref_point;
# endif # endif
#elif defined(__vxworks)
return (void *)FIPS_ref_point;
/* /*
* In case you wonder why there is no #ifdef __linux. All Linux targets * In case you wonder why there is no #ifdef __linux. All Linux targets
* are GCC-based and therefore are covered by instruction_pointer above * are GCC-based and therefore are covered by instruction_pointer above

View File

@@ -68,7 +68,7 @@
#define HMAC_SHA1_SIG "?have to make sure this string is unique" #define HMAC_SHA1_SIG "?have to make sure this string is unique"
#endif #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')) #define atox(c) ((c)>='a'?((c)-'a'+10):((c)>='A'?(c)-'A'+10:(c)-'0'))

View File

@@ -1 +1 @@
HMAC-SHA1(fips_premain.c)= 9e5ddba185ac446e0cf36fcf8e1b3acffe5d0b2c HMAC-SHA1(fips_premain.c)= dab2842517034a42dfdb21a285d4f0f4d7f6f920

View File

@@ -294,6 +294,10 @@ foreach (@ARGV)
{ {
$win32 = 1; $win32 = 1;
} }
if ($_ eq "--vxworks")
{
$vxworks = 1;
}
elsif ($_ eq "--onedir") elsif ($_ eq "--onedir")
{ {
$onedir = 1; $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; $tvdir = "." unless defined $tvdir;
if ($win32) if ($win32)
@@ -356,6 +365,21 @@ rem Test vector run script
rem Auto generated by mkfipsscr.pl script rem Auto generated by mkfipsscr.pl script
rem Do not edit 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 END
} }
@@ -457,6 +481,16 @@ sub test_dir
echo Running tests in $req echo Running tests in $req
if exist "$rsp" rd /s /q "$rsp" if exist "$rsp" rd /s /q "$rsp"
md "$rsp" md "$rsp"
END
}
elsif ($vxworks)
{
print OUT <<END;
echo Running tests in "$req"
rm -r "$rsp"
mkdir "$rsp"
END END
} }
else else
@@ -484,6 +518,10 @@ sub test_line
$rsp =~ 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 else
{ {
print OUT <<END; print OUT <<END;
@@ -518,7 +556,11 @@ END
{ {
$req =~ tr|/|\\|; $req =~ tr|/|\\|;
$rsp =~ 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 else
{ {

View File

@@ -64,8 +64,11 @@
#include <openssl/aes.h> #include <openssl/aes.h>
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/fips_rand.h> #include <openssl/fips_rand.h>
#ifndef OPENSSL_SYS_WIN32 #if !(defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS))
#include <sys/time.h> # include <sys/time.h>
#endif
#if defined(OPENSSL_SYS_VXWORKS)
# include <time.h>
#endif #endif
#include <assert.h> #include <assert.h>
#ifndef OPENSSL_SYS_WIN32 #ifndef OPENSSL_SYS_WIN32
@@ -223,6 +226,8 @@ static void fips_get_dt(FIPS_PRNG_CTX *ctx)
{ {
#ifdef OPENSSL_SYS_WIN32 #ifdef OPENSSL_SYS_WIN32
FILETIME ft; FILETIME ft;
#elif defined(OPENSSL_SYS_VXWORKS)
struct timespec ts;
#else #else
struct timeval tv; struct timeval tv;
#endif #endif
@@ -242,6 +247,16 @@ static void fips_get_dt(FIPS_PRNG_CTX *ctx)
buf[5] = (unsigned char) ((ft.dwLowDateTime >> 8) & 0xff); buf[5] = (unsigned char) ((ft.dwLowDateTime >> 8) & 0xff);
buf[6] = (unsigned char) ((ft.dwLowDateTime >> 16) & 0xff); buf[6] = (unsigned char) ((ft.dwLowDateTime >> 16) & 0xff);
buf[7] = (unsigned char) ((ft.dwLowDateTime >> 24) & 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 #else
gettimeofday(&tv,NULL); gettimeofday(&tv,NULL);
buf[0] = (unsigned char) (tv.tv_sec & 0xff); buf[0] = (unsigned char) (tv.tv_sec & 0xff);

View File

@@ -30,7 +30,7 @@ int main()
#include "fips_utl.h" #include "fips_utl.h"
void vst() void vst(FILE *in, FILE *out)
{ {
unsigned char *key = NULL; unsigned char *key = NULL;
unsigned char *v = NULL; unsigned char *v = NULL;
@@ -43,9 +43,9 @@ void vst()
keylen = 0; 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)) if(!strncmp(buf,"[AES 128-Key]", 13))
keylen = 16; keylen = 16;
else if(!strncmp(buf,"[AES 192-Key]", 13)) else if(!strncmp(buf,"[AES 192-Key]", 13))
@@ -96,7 +96,7 @@ void vst()
return; return;
} }
pv("R",ret,16); OutputValue("R",ret,16, out, 0);
OPENSSL_free(key); OPENSSL_free(key);
key = NULL; key = NULL;
OPENSSL_free(dt); OPENSSL_free(dt);
@@ -107,7 +107,7 @@ void vst()
} }
} }
void mct() void mct(FILE *in, FILE *out)
{ {
unsigned char *key = NULL; unsigned char *key = NULL;
unsigned char *v = NULL; unsigned char *v = NULL;
@@ -121,9 +121,9 @@ void mct()
keylen = 0; 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)) if(!strncmp(buf,"[AES 128-Key]", 13))
keylen = 16; keylen = 16;
else if(!strncmp(buf,"[AES 192-Key]", 13)) 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); OPENSSL_free(key);
key = NULL; key = NULL;
OPENSSL_free(dt); OPENSSL_free(dt);
@@ -197,7 +197,28 @@ void mct()
int main(int argc,char **argv) 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]); fprintf(stderr,"%s [mct|vst]\n",argv[0]);
exit(1); exit(1);
@@ -215,15 +236,21 @@ int main(int argc,char **argv)
exit(1); exit(1);
} }
if(!strcmp(argv[1],"mct")) if(!strcmp(argv[1],"mct"))
mct(); mct(in, out);
else if(!strcmp(argv[1],"vst")) else if(!strcmp(argv[1],"vst"))
vst(); vst(in, out);
else else
{ {
fprintf(stderr,"Don't know how to %s.\n",argv[1]); fprintf(stderr,"Don't know how to %s.\n",argv[1]);
exit(1); exit(1);
} }
if (argc == 4)
{
fclose(in);
fclose(out);
}
return 0; return 0;
} }
#endif #endif