* major minor fix final patch/beta)
*/
#define OPENSSL_VERSION_NUMBER 0x00907050L
+#ifdef OPENSSL_FIPS
+#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.7e-fips-dev XX xxx XXXX"
+#else
#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.7e-dev XX xxx XXXX"
+#endif
#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
extern "C" {
#endif
+#if defined(OPENSSL_FIPS)
+#define FIPS_RAND_SIZE_T int
+#endif
+
typedef struct rand_meth_st
{
void (*seed)(const void *buf, int num);
#error SHA is disabled.
#endif
+#if defined(OPENSSL_FIPS)
+#define FIPS_SHA_SIZE_T unsigned long
+#endif
+
/*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* ! SHA_LONG has to be at least 32 bits wide. If it's wider, then !
-HMAC-SHA1(fips_rand.c)= 58be68c405269c9a4c35ee19642c4da982374769
-HMAC-SHA1(fips_rand.h)= 889afc9a526fe59138326134950b733627a7e9cf
+HMAC-SHA1(fips_rand.c)= 9371bac9e8929fe26327383f6e7fb11f06671565
+HMAC-SHA1(fips_rand.h)= 0567b1fe9b0efe034a537f335659b0b681809791
#define SEED_SIZE 8
static unsigned char seed[SEED_SIZE];
-static int n_seed;
-static int o_seed;
+static FIPS_RAND_SIZE_T n_seed;
+static FIPS_RAND_SIZE_T o_seed;
static DES_cblock key1;
static DES_cblock key2;
static DES_key_schedule ks1,ks2;
#endif
static void fips_rand_cleanup(void);
-static void fips_rand_add(const void *buf, int num, double add_entropy);
-static int fips_rand_bytes(unsigned char *buf, int num);
+static void fips_rand_add(const void *buf, FIPS_RAND_SIZE_T num, double add_entropy);
+static int fips_rand_bytes(unsigned char *buf, FIPS_RAND_SIZE_T num);
static int fips_rand_status(void);
static RAND_METHOD rand_fips_meth=
n_seed=0;
}
-void FIPS_rand_seed(const void *buf_, int num)
+void FIPS_rand_seed(const void *buf_, FIPS_RAND_SIZE_T num)
{
const char *buf=buf_;
- int n;
+ FIPS_RAND_SIZE_T n;
static int init;
/* If the key hasn't been set, we can't seed! */
*/
for(n=0 ; n < num ; )
{
- int t=num-n;
+ FIPS_RAND_SIZE_T t=num-n;
if(o_seed+t > sizeof seed)
t=sizeof seed-o_seed;
CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
}
-static void fips_rand_add(const void *buf, int num, double add_entropy)
+static void fips_rand_add(const void *buf, FIPS_RAND_SIZE_T num, double add_entropy)
{
FIPS_rand_seed(buf,num);
}
-static int fips_rand_bytes(unsigned char *buf,int num)
+static int fips_rand_bytes(unsigned char *buf,FIPS_RAND_SIZE_T num)
{
- int n;
+ FIPS_RAND_SIZE_T n;
unsigned char timeseed[8];
unsigned char intermediate[SEED_SIZE];
unsigned char output[SEED_SIZE];
return 0;
}
+#ifdef FIPS_RAND_MAX_SIZE_T
+ if (num > FIPS_RAND_MAX_SIZE_T)
+ {
+#ifdef RAND_R_PRNG_ASKING_FOR_TOO_MUCH
+ RANDerr(RAND_F_FIPS_RAND_BYTES,RAND_R_PRNG_ASKING_FOR_TOO_MUCH);
+ return 0;
+#else
+ return -1; /* signal "not supported" condition */
+#endif
+ }
+#endif
+
#ifndef GETPID_IS_MEANINGLESS
pid=getpid();
if(pid != seed_pid)
for(n=0 ; n < num ; )
{
unsigned char t[SEED_SIZE];
- int l;
+ FIPS_RAND_SIZE_T l;
/* now generate a full 64 bits of "randomness" */
for(l=0 ; l < sizeof t ; ++l)
if(second && !memcmp(output,previous,sizeof previous))
{
RANDerr(RAND_F_FIPS_RAND_BYTES,RAND_R_PRNG_STUCK);
+ CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
return 0;
}
memcpy(previous,output,sizeof previous);
CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
- return num;
+ return 1;
}
static int fips_rand_status(void)
void FIPS_set_prng_key(const unsigned char k1[8],const unsigned char k2[8]);
void FIPS_test_mode(int test,const unsigned char faketime[8]);
-void FIPS_rand_seed(const void *buf, int num);
+void FIPS_rand_seed(const void *buf, FIPS_RAND_SIZE_T num);
/* NB: this returns true if _partially_ seeded */
int FIPS_rand_seeded(void);
FIPS_test_mode(1,t->time);
RAND_seed(t->seed,sizeof t->seed);
- if(RAND_bytes(buf,8) != 8)
+ if(RAND_bytes(buf,8) <= 0)
{
ERR_print_errors_fp(stderr);
exit(2);
}
compare(buf,t->block1,8);
for(n=0 ; n < 99 ; ++n)
- if(RAND_bytes(buf,8) != 8)
+ if(RAND_bytes(buf,8) <= 0)
{
ERR_print_errors_fp(stderr);
exit(2);
HMAC-SHA1(fips_sha1dgst.c)= 10575600a9540eb15188a7d3b0b031e60aedbc18
HMAC-SHA1(fips_sha1_selftest.c)= 98910a0c85eff1688bd7adb23e738dc75b39546e
HMAC-SHA1(asm/sx86-elf.s)= 6286cba0ea3b071e67ab5c1e607d1387de6a871d
-HMAC-SHA1(fips_sha_locl.h)= 199ceca9016ba5514997ce1fcd22be7d4f66e9b5
-HMAC-SHA1(fips_md32_common.h)= 5bd82fd4f27c9c9f5164dafbb617272fa5c96521
+HMAC-SHA1(fips_sha_locl.h)= b793c80946d1029a630844393e294b27f61b1485
+HMAC-SHA1(fips_md32_common.h)= cd86b0f4a9a22552dce8db3ae5f2614e54a61f15
*/
#undef ROTATE
#ifndef PEDANTIC
-# if 0 /* defined(_MSC_VER) */
+# if defined(_MSC_VER) || defined(__ICC)
# define ROTATE(a,n) _lrotl(a,n)
# elif defined(__MWERKS__)
# if defined(__POWERPC__)
* Time for some action:-)
*/
-int HASH_UPDATE (HASH_CTX *c, const void *data_, unsigned long len)
+int HASH_UPDATE (HASH_CTX *c, const void *data_, FIPS_SHA_SIZE_T len)
{
const unsigned char *data=data_;
register HASH_LONG * p;
- register unsigned long l;
+ register HASH_LONG l;
int sw,sc,ew,ec;
if(FIPS_selftest_fail)
if (len==0) return 1;
- l=(c->Nl+(len<<3))&0xffffffffL;
+ l=(c->Nl+(((HASH_LONG)len)<<3))&0xffffffffUL;
/* 95-05-24 eay Fixed a bug with the overflow handling, thanks to
* Wei Dai <weidai@eskimo.com> for pointing it out. */
if (l < c->Nl) /* overflow */
if ((((unsigned long)data)%4) == 0)
{
/* data is properly aligned so that we can cast it: */
- HASH_BLOCK_DATA_ORDER_ALIGNED (c,(HASH_LONG *)data,sw);
+ HASH_BLOCK_DATA_ORDER_ALIGNED (c,(const HASH_LONG *)data,sw);
sw*=HASH_CBLOCK;
data+=sw;
len-=sw;
#if defined(HASH_BLOCK_DATA_ORDER_ALIGNED)
if ((((unsigned long)data)%4) == 0)
/* data is properly aligned so that we can cast it: */
- HASH_BLOCK_DATA_ORDER_ALIGNED (c,(HASH_LONG *)data,1);
+ HASH_BLOCK_DATA_ORDER_ALIGNED (c,(const HASH_LONG *)data,1);
else
#if !defined(HASH_BLOCK_DATA_ORDER)
{
# define HASH_BLOCK_DATA_ORDER sha_block_data_order
# define Xupdate(a,ix,ia,ib,ic,id) (ix=(a)=(ia^ib^ic^id))
- void sha_block_host_order (SHA_CTX *c, const void *p,int num);
- void sha_block_data_order (SHA_CTX *c, const void *p,int num);
+ void sha_block_host_order (SHA_CTX *c, const void *p,FIPS_SHA_SIZE_T num);
+ void sha_block_data_order (SHA_CTX *c, const void *p,FIPS_SHA_SIZE_T num);
#elif defined(SHA_1)
# define HASH_BLOCK_DATA_ORDER_ALIGNED sha1_block_asm_data_order
# endif
# endif
- void sha1_block_host_order (SHA_CTX *c, const void *p,int num);
- void sha1_block_data_order (SHA_CTX *c, const void *p,int num);
+ void sha1_block_host_order (SHA_CTX *c, const void *p,FIPS_SHA_SIZE_T num);
+ void sha1_block_data_order (SHA_CTX *c, const void *p,FIPS_SHA_SIZE_T num);
#else
# error "Either SHA_0 or SHA_1 must be defined."
#endif
#ifndef DONT_IMPLEMENT_BLOCK_HOST_ORDER
-void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, int num)
+void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, FIPS_SHA_SIZE_T num)
{
const SHA_LONG *W=d;
register unsigned MD32_REG_T A,B,C,D,E,T;
#endif
#ifndef DONT_IMPLEMENT_BLOCK_DATA_ORDER
-void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, int num)
+void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, FIPS_SHA_SIZE_T num)
{
const unsigned char *data=p;
register unsigned MD32_REG_T A,B,C,D,E,T,l;
HMAC-SHA1(fips_sha1_selftest.c)= 98910a0c85eff1688bd7adb23e738dc75b39546e
HMAC-SHA1(asm/sx86-elf.s)= 6286cba0ea3b071e67ab5c1e607d1387de6a871d
HMAC-SHA1(fips_standalone_sha1.c)= c17f83ccfe601558b33b6df27d2d82887b8c9dc2
-HMAC-SHA1(fips_sha_locl.h)= 199ceca9016ba5514997ce1fcd22be7d4f66e9b5
-HMAC-SHA1(fips_md32_common.h)= 5bd82fd4f27c9c9f5164dafbb617272fa5c96521
+HMAC-SHA1(fips_sha_locl.h)= b793c80946d1029a630844393e294b27f61b1485
+HMAC-SHA1(fips_md32_common.h)= cd86b0f4a9a22552dce8db3ae5f2614e54a61f15