diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2012-10-04 13:27:11 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2012-10-04 13:27:11 +0000 |
commit | c616200172f922718c7200002470a48d31ec4fb5 (patch) | |
tree | 4e4444efb31b89b58de6c75e38e47584a7869179 /fips | |
parent | 7b899c10cd9ff366ef834615ecaabed8629edc06 (diff) |
Add support for Windows CE and C64+ to FIPS module.
Diffstat (limited to 'fips')
-rw-r--r-- | fips/aes/fips_aesavs.c | 22 | ||||
-rw-r--r-- | fips/aes/fips_gcmtest.c | 9 | ||||
-rw-r--r-- | fips/des/fips_desmovs.c | 6 | ||||
-rw-r--r-- | fips/dh/fips_dhvs.c | 2 | ||||
-rw-r--r-- | fips/dsa/fips_dsatest.c | 2 | ||||
-rw-r--r-- | fips/fips.c | 8 | ||||
-rw-r--r-- | fips/fips_canister.c | 9 | ||||
-rw-r--r-- | fips/fips_premain.c | 6 | ||||
-rw-r--r-- | fips/fips_premain.c.sha1 | 2 | ||||
-rw-r--r-- | fips/fipsalgtest.pl | 13 | ||||
-rw-r--r-- | fips/fipssyms.h | 1 | ||||
-rw-r--r-- | fips/rand/fips_rand.c | 22 |
12 files changed, 70 insertions, 32 deletions
diff --git a/fips/aes/fips_aesavs.c b/fips/aes/fips_aesavs.c index fecaf990c6..cc3ed6afb1 100644 --- a/fips/aes/fips_aesavs.c +++ b/fips/aes/fips_aesavs.c @@ -99,7 +99,7 @@ static int AESTest(EVP_CIPHER_CTX *ctx, { const EVP_CIPHER *cipher = NULL; - if (strcasecmp(amode, "CBC") == 0) + if (fips_strcasecmp(amode, "CBC") == 0) { switch (akeysz) { @@ -117,7 +117,7 @@ static int AESTest(EVP_CIPHER_CTX *ctx, } } - else if (strcasecmp(amode, "ECB") == 0) + else if (fips_strcasecmp(amode, "ECB") == 0) { switch (akeysz) { @@ -134,7 +134,7 @@ static int AESTest(EVP_CIPHER_CTX *ctx, break; } } - else if (strcasecmp(amode, "CFB128") == 0) + else if (fips_strcasecmp(amode, "CFB128") == 0) { switch (akeysz) { @@ -169,7 +169,7 @@ static int AESTest(EVP_CIPHER_CTX *ctx, break; } } - else if(!strcasecmp(amode,"CFB1")) + else if(!fips_strcasecmp(amode,"CFB1")) { switch (akeysz) { @@ -186,7 +186,7 @@ static int AESTest(EVP_CIPHER_CTX *ctx, break; } } - else if(!strcasecmp(amode,"CFB8")) + else if(!fips_strcasecmp(amode,"CFB8")) { switch (akeysz) { @@ -215,7 +215,7 @@ static int AESTest(EVP_CIPHER_CTX *ctx, } if (FIPS_cipherinit(ctx, cipher, aKey, iVec, dir) <= 0) return 0; - if(!strcasecmp(amode,"CFB1")) + if(!fips_strcasecmp(amode,"CFB1")) M_EVP_CIPHER_CTX_set_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS); if (dir) FIPS_cipher(ctx, ciphertext, plaintext, len); @@ -635,10 +635,8 @@ static int proc_file(char *rqfile, char *rspfile) char *xp, *pp = ibuf+2; int n; if (akeysz) - { /* insert current time & date */ - time_t rtim = time(0); - fputs("# ", rfp); - copy_line(ctime(&rtim), rfp); + { + copy_line(ibuf, rfp); } else { @@ -876,11 +874,11 @@ int main(int argc, char **argv) if (argc > 1) { - if (strcasecmp(argv[1], "-d") == 0) + if (fips_strcasecmp(argv[1], "-d") == 0) { d_opt = 1; } - else if (strcasecmp(argv[1], "-f") == 0) + else if (fips_strcasecmp(argv[1], "-f") == 0) { d_opt = 0; } diff --git a/fips/aes/fips_gcmtest.c b/fips/aes/fips_gcmtest.c index 9f50857fb9..30e4bcc0f4 100644 --- a/fips/aes/fips_gcmtest.c +++ b/fips/aes/fips_gcmtest.c @@ -75,10 +75,11 @@ int main(int argc, char **argv) #include "fips_utl.h" +static char buf[204800]; +static char lbuf[204800]; + static void gcmtest(FILE *in, FILE *out, int encrypt) { - char buf[2048]; - char lbuf[2048]; char *keyword, *value; int keylen = -1, ivlen = -1, aadlen = -1, taglen = -1, ptlen = -1; int rv; @@ -266,8 +267,6 @@ static void gcmtest(FILE *in, FILE *out, int encrypt) static void xtstest(FILE *in, FILE *out) { - char buf[204800]; - char lbuf[204800]; char *keyword, *value; int inlen = 0; int encrypt = 0; @@ -340,8 +339,6 @@ static void xtstest(FILE *in, FILE *out) static void ccmtest(FILE *in, FILE *out) { - char buf[200048]; - char lbuf[200048]; char *keyword, *value; long l; unsigned char *Key = NULL, *Nonce = NULL; diff --git a/fips/des/fips_desmovs.c b/fips/des/fips_desmovs.c index 2bbeb53459..0ffab89e2f 100644 --- a/fips/des/fips_desmovs.c +++ b/fips/des/fips_desmovs.c @@ -356,10 +356,8 @@ static int tproc_file(char *rqfile, char *rspfile) char *xp, *pp = ibuf+2; int n; if(*amode) - { /* insert current time & date */ - time_t rtim = time(0); - fputs("# ", rfp); - copy_line(ctime(&rtim), rfp); + { + copy_line(ibuf, rfp); } else { diff --git a/fips/dh/fips_dhvs.c b/fips/dh/fips_dhvs.c index 0fb52f79a4..a925e13c7d 100644 --- a/fips/dh/fips_dhvs.c +++ b/fips/dh/fips_dhvs.c @@ -286,7 +286,7 @@ int main(int argc, char **argv) return 0; parse_error: fprintf(stderr, "Error Parsing request file\n"); - exit(1); + return 1; } #endif diff --git a/fips/dsa/fips_dsatest.c b/fips/dsa/fips_dsatest.c index 3c95d176b8..3ea600e4ab 100644 --- a/fips/dsa/fips_dsatest.c +++ b/fips/dsa/fips_dsatest.c @@ -62,8 +62,10 @@ #include <stdlib.h> #include <string.h> #include <ctype.h> +#ifndef NO_SYS_TYPES_H #include <sys/types.h> #include <sys/stat.h> +#endif #include "e_os.h" diff --git a/fips/fips.c b/fips/fips.c index 36ac8d1b0c..8c9e187d7b 100644 --- a/fips/fips.c +++ b/fips/fips.c @@ -81,7 +81,7 @@ static int fips_started = 0; static int fips_is_owning_thread(void); static int fips_set_owning_thread(void); static int fips_clear_owning_thread(void); -static unsigned char *fips_signature_witness(void); +static const unsigned char *fips_signature_witness(void); #define fips_w_lock() CRYPTO_w_lock(CRYPTO_LOCK_FIPS) #define fips_w_unlock() CRYPTO_w_unlock(CRYPTO_LOCK_FIPS) @@ -148,6 +148,9 @@ void fips_set_selftest_fail(void) extern const void *FIPS_text_start(), *FIPS_text_end(); extern const unsigned char FIPS_rodata_start[], FIPS_rodata_end[]; +#ifdef _TMS320C6X +const +#endif unsigned char FIPS_signature [20] = { 0 }; __fips_constseg static const char FIPS_hmac_key[]="etaonrishdlcupfm"; @@ -413,9 +416,8 @@ int fips_clear_owning_thread(void) return ret; } -unsigned char *fips_signature_witness(void) +const unsigned char *fips_signature_witness(void) { - extern unsigned char FIPS_signature[]; return FIPS_signature; } diff --git a/fips/fips_canister.c b/fips/fips_canister.c index 7be48426d9..afe55a1bc7 100644 --- a/fips/fips_canister.c +++ b/fips/fips_canister.c @@ -35,6 +35,7 @@ const void *FIPS_text_end(void); (defined(__linux) && ((defined(__PPC__) && !defined(__PPC64__)) || \ defined(__arm__) || defined(__arm))) || \ (defined(__APPLE__) /* verified on all MacOS X & iOS flavors */)|| \ + (defined(_TMS320C6X)) || \ (defined(_WIN32) && defined(_MSC_VER)) # define FIPS_REF_POINT_IS_CROSS_COMPILER_AWARE # endif @@ -70,6 +71,10 @@ const unsigned int FIPS_text_startX[]= # pragma const_seg("fipsro$a") # pragma const_seg() __declspec(allocate("fipsro$a")) +# elif defined(_TMS320C6X) +# pragma CODE_SECTION(instruction_pointer,".fips_text:start") +# pragma CODE_SECTION(FIPS_ref_point,".fips_text:start") +# pragma DATA_SECTION(FIPS_rodata_start,".fips_const:start") # endif const unsigned int FIPS_rodata_start[]= { 0x46495053, 0x5f726f64, 0x6174615f, 0x73746172 }; @@ -87,6 +92,10 @@ const unsigned int FIPS_text_endX[]= # pragma const_seg("fipsro$z") # pragma const_seg() __declspec(allocate("fipsro$z")) +# elif defined(_TMS320C6X) +# pragma CODE_SECTION(instruction_pointer,".fips_text:end") +# pragma CODE_SECTION(FIPS_ref_point,".fips_text:end") +# pragma DATA_SECTION(FIPS_rodata_end,".fips_const:end") # endif const unsigned int FIPS_rodata_end[]= { 0x46495053, 0x5f726f64, 0x6174615f, 0x656e645b }; diff --git a/fips/fips_premain.c b/fips/fips_premain.c index 7dc5246006..c68b464e31 100644 --- a/fips/fips_premain.c +++ b/fips/fips_premain.c @@ -53,6 +53,12 @@ int lib$initialize(); globaldef int (*lib_init_ref)() = lib$initialize; # pragma __standard +#elif defined(_TMS320C6X) +# if defined(__TI_EABI__) + asm("\t.sect \".init_array\"\n\t.align 4\n\t.field FINGERPRINT_premain,32"); +# else + asm("\t.sect \".pinit\"\n\t.align 4\n\t.field _FINGERPRINT_premain,32"); +# endif #elif 0 The rest has to be taken care of through command line: diff --git a/fips/fips_premain.c.sha1 b/fips/fips_premain.c.sha1 index b9fb5dfc1d..4dbfbeae69 100644 --- a/fips/fips_premain.c.sha1 +++ b/fips/fips_premain.c.sha1 @@ -1 +1 @@ -HMAC-SHA1(fips_premain.c)= 1eaf66f76187877ff403708a2948d240f92736a0 +HMAC-SHA1(fips_premain.c)= 65b20c3cec235cec85af848e1cd2dfdfa101804a diff --git a/fips/fipsalgtest.pl b/fips/fipsalgtest.pl index 30cd9c0ebd..2e31335ae9 100644 --- a/fips/fipsalgtest.pl +++ b/fips/fipsalgtest.pl @@ -495,6 +495,7 @@ my $onedir = 0; my $filter = ""; my $tvdir; my $tprefix; +my $sfprefix = ""; my $debug = 0; my $quiet = 0; my $notest = 0; @@ -615,6 +616,9 @@ foreach (@ARGV) { elsif (/--script-tprefix=(.*)$/) { $stprefix = $1; } + elsif (/--script-fprefix=(.*)$/) { + $sfprefix = $1; + } elsif (/--mkdir=(.*)$/) { $mkcmd = $1; } @@ -1017,6 +1021,10 @@ END $out =~ s|/req/(\S+)\.req|/$rspdir/$1.rsp|; my $outdir = $out; $outdir =~ s|/[^/]*$||; + if ( !-d $outdir && ($outfile eq "" || $minimal_script)) { + print STDERR "DEBUG: Creating directory $outdir\n" if $debug; + mkdir($outdir) || die "Can't create directory $outdir"; + } if ($outfile ne "") { if ($win32) { $outdir =~ tr|/|\\|; @@ -1039,12 +1047,9 @@ END } $lastdir = $outdir; } - } elsif ( !-d $outdir ) { - print STDERR "DEBUG: Creating directory $outdir\n" if $debug; - mkdir($outdir) || die "Can't create directory $outdir"; } } - my $cmd = "$tcmd \"$req\" \"$out\""; + my $cmd = "$tcmd \"$sfprefix$req\" \"$sfprefix$out\""; print STDERR "DEBUG: running test $tname\n" if ( $debug && !$verify ); if ($outfile ne "") { if ($minimal_script) { diff --git a/fips/fipssyms.h b/fips/fipssyms.h index 5b1e188785..5719aeac2a 100644 --- a/fips/fipssyms.h +++ b/fips/fipssyms.h @@ -589,6 +589,7 @@ #define AES_encrypt fips_aes_encrypt #define AES_set_decrypt_key fips_aes_set_decrypt_key #define AES_set_encrypt_key fips_aes_set_encrypt_key +#define AES_ctr32_encrypt fips_aes_ctr32_encrypt #define BN_from_montgomery fips_bn_from_montgomery #define BN_num_bits_word FIPS_bn_num_bits_word #define DES_SPtrans fips_des_sptrans diff --git a/fips/rand/fips_rand.c b/fips/rand/fips_rand.c index f80c005758..9904d8aa6f 100644 --- a/fips/rand/fips_rand.c +++ b/fips/rand/fips_rand.c @@ -66,7 +66,7 @@ #include <openssl/aes.h> #include <openssl/err.h> #include <openssl/fips_rand.h> -#if !(defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS)) +#if !(defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYSNAME_DSPBIOS)) # include <sys/time.h> #endif #if defined(OPENSSL_SYS_VXWORKS) @@ -232,8 +232,13 @@ void FIPS_get_timevec(unsigned char *buf, unsigned long *pctr) { #ifdef OPENSSL_SYS_WIN32 FILETIME ft; +#ifdef _WIN32_WCE + SYSTEMTIME t; +#endif #elif defined(OPENSSL_SYS_VXWORKS) struct timespec ts; +#elif defined(OPENSSL_SYSNAME_DSPBIOS) + unsigned long long TSC, OPENSSL_rdtsc(); #else struct timeval tv; #endif @@ -243,7 +248,12 @@ void FIPS_get_timevec(unsigned char *buf, unsigned long *pctr) #endif #ifdef OPENSSL_SYS_WIN32 +#ifdef _WIN32_WCE + GetSystemTime(&t); + SystemTimeToFileTime(&t, &ft); +#else GetSystemTimeAsFileTime(&ft); +#endif buf[0] = (unsigned char) (ft.dwHighDateTime & 0xff); buf[1] = (unsigned char) ((ft.dwHighDateTime >> 8) & 0xff); buf[2] = (unsigned char) ((ft.dwHighDateTime >> 16) & 0xff); @@ -262,6 +272,16 @@ void FIPS_get_timevec(unsigned char *buf, unsigned long *pctr) 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); +#elif defined(OPENSSL_SYSNAME_DSPBIOS) + TSC = OPENSSL_rdtsc(); + buf[0] = (unsigned char) (TSC & 0xff); + buf[1] = (unsigned char) ((TSC >> 8) & 0xff); + buf[2] = (unsigned char) ((TSC >> 16) & 0xff); + buf[3] = (unsigned char) ((TSC >> 24) & 0xff); + buf[4] = (unsigned char) ((TSC >> 32) & 0xff); + buf[5] = (unsigned char) ((TSC >> 40) & 0xff); + buf[6] = (unsigned char) ((TSC >> 48) & 0xff); + buf[7] = (unsigned char) ((TSC >> 56) & 0xff); #else gettimeofday(&tv,NULL); buf[0] = (unsigned char) (tv.tv_sec & 0xff); |