From 2ec5ebb979d057c3a81198c7bbc758ff10ca1e7f Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Mon, 18 Apr 2005 00:22:40 +0000 Subject: [PATCH] Minor fips const-ification. --- fips/des/fips_des_locl.h | 2 +- fips/des/fips_set_key.c | 4 ++-- fips/dh/fips_dh_key.c | 2 +- fips/dsa/fips_dsa_ossl.c | 2 +- fips/dsa/fips_dsa_selftest.c | 6 +++--- fips/fipshashes.sha1 | 24 ++++++++++++------------ fips/rand/fips_rand.c | 4 ++-- fips/rand/fips_rand.h | 2 +- fips/rsa/fips_rsa_eay.c | 2 +- fips/rsa/fips_rsa_gen.c | 2 +- fips/rsa/fips_rsa_selftest.c | 22 +++++++++++----------- fips/sha1/fips_sha1_selftest.c | 2 +- fips/sha1/fips_sha1dgst.c | 2 +- fips/sha1/standalone.sha1 | 4 ++-- 14 files changed, 40 insertions(+), 40 deletions(-) diff --git a/fips/des/fips_des_locl.h b/fips/des/fips_des_locl.h index ef9323a6d6..5c466a5561 100644 --- a/fips/des/fips_des_locl.h +++ b/fips/des/fips_des_locl.h @@ -421,7 +421,7 @@ PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \ } -OPENSSL_EXTERN const DES_LONG DES_SPtrans[8][64]; +extern const DES_LONG DES_SPtrans[8][64]; void fcrypt_body(DES_LONG *out,DES_key_schedule *ks, DES_LONG Eswap0, DES_LONG Eswap1); diff --git a/fips/des/fips_set_key.c b/fips/des/fips_set_key.c index 1490a3cf54..a508ee5acb 100644 --- a/fips/des/fips_set_key.c +++ b/fips/des/fips_set_key.c @@ -118,7 +118,7 @@ int DES_check_key_parity(const_DES_cblock *key) * (and actual cblock values). */ #define NUM_WEAK_KEY 16 -static DES_cblock weak_keys[NUM_WEAK_KEY]={ +static const DES_cblock weak_keys[NUM_WEAK_KEY]={ /* weak keys */ {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01}, {0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE}, @@ -344,7 +344,7 @@ int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule) void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule) { - static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; + static const int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; register DES_LONG c,d,t,s,t2; register const unsigned char *in; register DES_LONG *k; diff --git a/fips/dh/fips_dh_key.c b/fips/dh/fips_dh_key.c index 41e3a661c0..4d26bb1619 100644 --- a/fips/dh/fips_dh_key.c +++ b/fips/dh/fips_dh_key.c @@ -86,7 +86,7 @@ int DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh) return dh->meth->compute_key(key, pub_key, dh); } -static DH_METHOD dh_ossl = { +static const DH_METHOD dh_ossl = { "OpenSSL DH Method", generate_key, compute_key, diff --git a/fips/dsa/fips_dsa_ossl.c b/fips/dsa/fips_dsa_ossl.c index 0ae5eb4b9e..2ed64c483e 100644 --- a/fips/dsa/fips_dsa_ossl.c +++ b/fips/dsa/fips_dsa_ossl.c @@ -83,7 +83,7 @@ static int dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); -static DSA_METHOD openssl_dsa_meth = { +static const DSA_METHOD openssl_dsa_meth = { "OpenSSL FIPS DSA method", dsa_do_sign, dsa_sign_setup, diff --git a/fips/dsa/fips_dsa_selftest.c b/fips/dsa/fips_dsa_selftest.c index 2c88f0af44..795fda9587 100644 --- a/fips/dsa/fips_dsa_selftest.c +++ b/fips/dsa/fips_dsa_selftest.c @@ -71,7 +71,7 @@ static unsigned char seed[20]={ 0x62,0xba,0x32,0x24,0xe0,0x42,0x7d,0xd3, }; -static unsigned char out_p[]={ +static const unsigned char out_p[]={ 0x8d,0xf2,0xa4,0x94,0x49,0x22,0x76,0xaa, 0x3d,0x25,0x75,0x9b,0xb0,0x68,0x69,0xcb, 0xea,0xc0,0xd8,0x3a,0xfb,0x8d,0x0c,0xf7, @@ -82,13 +82,13 @@ static unsigned char out_p[]={ 0xec,0x07,0x36,0xee,0x31,0xc8,0x02,0x91, }; -static unsigned char out_q[]={ +static const unsigned char out_q[]={ 0xc7,0x73,0x21,0x8c,0x73,0x7e,0xc8,0xee, 0x99,0x3b,0x4f,0x2d,0xed,0x30,0xf4,0x8e, 0xda,0xce,0x91,0x5f, }; -static unsigned char out_g[]={ +static const unsigned char out_g[]={ 0x62,0x6d,0x02,0x78,0x39,0xea,0x0a,0x13, 0x41,0x31,0x63,0xa5,0x5b,0x4c,0xb5,0x00, 0x29,0x9d,0x55,0x22,0x95,0x6c,0xef,0xcb, diff --git a/fips/fipshashes.sha1 b/fips/fipshashes.sha1 index a87ab9b3b0..9d2714dc98 100644 --- a/fips/fipshashes.sha1 +++ b/fips/fipshashes.sha1 @@ -9,22 +9,22 @@ HMAC-SHA1(aes/fips_aes_locl.h)= a98eb0aa449f1d95b8064e261b2ac2b1f328685e HMAC-SHA1(des/fips_des_enc.c)= 9527f8ea81602358f1aa11348237fdb1e9eeff32 HMAC-SHA1(des/asm/fips-dx86-elf.s)= 9570b03422ffbe5d3d090f91758ebfd46acd5d57 HMAC-SHA1(des/fips_des_selftest.c)= 3bc574e51647c5f5ab45d1007b2cf461d67764a9 -HMAC-SHA1(des/fips_set_key.c)= 2858450d3d9c8d4ab8edea683baa54fa34f3a605 -HMAC-SHA1(des/fips_des_locl.h)= 7053848e884df47f06de9f2248380b92e58ef4e5 +HMAC-SHA1(des/fips_set_key.c)= cd1ba25d29376849523a9ddc194c3156a8a7a913 +HMAC-SHA1(des/fips_des_locl.h)= e008da40dc6913e374edd66a20d44e1752f00583 HMAC-SHA1(dh/fips_dh_check.c)= 63347e2007e224381d4a7b6d871633889de72cf3 HMAC-SHA1(dh/fips_dh_gen.c)= 93fe69b758ca9d70d70cda1c57fff4eb5c668e85 -HMAC-SHA1(dh/fips_dh_key.c)= 7bf23b329a776953bbe7c30ebd7f9faf5249ddbe -HMAC-SHA1(dsa/fips_dsa_ossl.c)= d5f718695397fe56d6bb46f7c410794cb895e206 +HMAC-SHA1(dh/fips_dh_key.c)= a84970913f0eaa098fc4e48d4487b45ebe27bcc3 +HMAC-SHA1(dsa/fips_dsa_ossl.c)= e02fac446e5f89d22ffa0468fbc97d8dab7a5da8 HMAC-SHA1(dsa/fips_dsa_gen.c)= c252db14699f3ff641db052311da7d7521569c53 -HMAC-SHA1(dsa/fips_dsa_selftest.c)= 4bfc5d3a6b977527b053f3a03d0760a822a26135 -HMAC-SHA1(rand/fips_rand.c)= b86543ef1b33b66846b4ab91937e22781f341324 -HMAC-SHA1(rand/fips_rand.h)= 0567b1fe9b0efe034a537f335659b0b681809791 -HMAC-SHA1(rsa/fips_rsa_eay.c)= eabab59a2f11f3da4c21e1144efe1684f5e8f1ec -HMAC-SHA1(rsa/fips_rsa_gen.c)= 2e96773cfa8334590dcc238d32024408a2b13b18 -HMAC-SHA1(rsa/fips_rsa_selftest.c)= 70553a5212e86f65b068564946d39b738a201e22 -HMAC-SHA1(sha1/fips_sha1dgst.c)= 10575600a9540eb15188a7d3b0b031e60aedbc18 +HMAC-SHA1(dsa/fips_dsa_selftest.c)= 7c2ba8d82feda2aadc8b769a3b6c4c25a6356e01 +HMAC-SHA1(rand/fips_rand.c)= 29139e29f56f3ecd99f527af8742d5afb12f409a +HMAC-SHA1(rand/fips_rand.h)= bf009ea8963e79b1e414442ede9ae7010a03160b +HMAC-SHA1(rsa/fips_rsa_eay.c)= dc0c262df0a218b290192edb21639ced4532e857 +HMAC-SHA1(rsa/fips_rsa_gen.c)= 713d2e0d7a1a682b1794f1224b7afe01272ba755 +HMAC-SHA1(rsa/fips_rsa_selftest.c)= 8c915b5a4e354dcede93ba08c42858d4dd884e67 +HMAC-SHA1(sha1/fips_sha1dgst.c)= 867e990149be16fe9e758b916b5ffc9d9fa61afb HMAC-SHA1(sha1/fips_standalone_sha1.c)= 93203c569097189b47a0085bc9fc55193867d4ce -HMAC-SHA1(sha1/fips_sha1_selftest.c)= 98910a0c85eff1688bd7adb23e738dc75b39546e +HMAC-SHA1(sha1/fips_sha1_selftest.c)= bd5c6ece3ef96237440bb0c51c7cf2bd42d39483 HMAC-SHA1(sha1/asm/fips-sx86-elf.s)= ae66fb23ab8e1a2287e87a0a2dd30a4b9039fe63 HMAC-SHA1(sha1/fips_sha_locl.h)= c1b4c82eec5f0ee119658456690f3ea9d77ed1c5 HMAC-SHA1(sha1/fips_md32_common.h)= 08a057a7b94acf5df4301ea6c894ce14082e1ec4 diff --git a/fips/rand/fips_rand.c b/fips/rand/fips_rand.c index 745222b306..45cf1c5706 100644 --- a/fips/rand/fips_rand.c +++ b/fips/rand/fips_rand.c @@ -103,7 +103,7 @@ static void fips_rand_add(const void *buf, FIPS_RAND_SIZE_T num, double add_entr 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= +static const RAND_METHOD rand_fips_meth= { FIPS_rand_seed, fips_rand_bytes, @@ -115,7 +115,7 @@ static RAND_METHOD rand_fips_meth= static int second; -RAND_METHOD *FIPS_rand_method(void) +const RAND_METHOD *FIPS_rand_method(void) { return &rand_fips_meth; } diff --git a/fips/rand/fips_rand.h b/fips/rand/fips_rand.h index 1286b63ab2..093727240e 100644 --- a/fips/rand/fips_rand.h +++ b/fips/rand/fips_rand.h @@ -64,7 +64,7 @@ void FIPS_rand_seed(const void *buf, FIPS_RAND_SIZE_T num); /* NB: this returns true if _partially_ seeded */ int FIPS_rand_seeded(void); -RAND_METHOD *FIPS_rand_method(void); +const RAND_METHOD *FIPS_rand_method(void); #ifdef __cplusplus } diff --git a/fips/rsa/fips_rsa_eay.c b/fips/rsa/fips_rsa_eay.c index c571e2b1bf..7aa7e8ad41 100644 --- a/fips/rsa/fips_rsa_eay.c +++ b/fips/rsa/fips_rsa_eay.c @@ -76,7 +76,7 @@ static int RSA_eay_private_decrypt(FIPS_RSA_SIZE_T flen, const unsigned char *fr static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *i, RSA *rsa); static int RSA_eay_init(RSA *rsa); static int RSA_eay_finish(RSA *rsa); -static RSA_METHOD rsa_pkcs1_eay_meth={ +static const RSA_METHOD rsa_pkcs1_eay_meth={ "Eric Young's PKCS#1 RSA", RSA_eay_public_encrypt, RSA_eay_public_decrypt, /* signature verification */ diff --git a/fips/rsa/fips_rsa_gen.c b/fips/rsa/fips_rsa_gen.c index 71049fd60a..5c92163c6e 100644 --- a/fips/rsa/fips_rsa_gen.c +++ b/fips/rsa/fips_rsa_gen.c @@ -74,7 +74,7 @@ static int fips_check_rsa(RSA *rsa) unsigned char ctext[256]; unsigned char ptext[256]; /* The longest we can have with OAEP padding and a 512 bit key */ - static unsigned char original_ptext[] = + static const unsigned char original_ptext[] = "\x01\x23\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a\xbc\xde\xf0" "\x23\x45\x67\x89\xab\xcd"; diff --git a/fips/rsa/fips_rsa_selftest.c b/fips/rsa/fips_rsa_selftest.c index 4e3b9445fc..90f12ff3e9 100644 --- a/fips/rsa/fips_rsa_selftest.c +++ b/fips/rsa/fips_rsa_selftest.c @@ -81,9 +81,9 @@ static unsigned char n[] = static int setrsakey(RSA *key, unsigned char *c) { - static unsigned char e[] = "\x11"; + static const unsigned char e[] = "\x11"; - static unsigned char d[] = + static const unsigned char d[] = "\x00\xA5\xDA\xFC\x53\x41\xFA\xF2\x89\xC4\xB9\x88\xDB\x30\xC1\xCD" "\xF8\x3F\x31\x25\x1E\x06\x68\xB4\x27\x84\x81\x38\x01\x57\x96\x41" "\xB2\x94\x10\xB3\xC7\x99\x8D\x6B\xC4\x65\x74\x5E\x5C\x39\x26\x69" @@ -94,40 +94,40 @@ static int setrsakey(RSA *key, unsigned char *c) "\xAF\x94\x28\xC2\xB7\xB8\x88\x3F\xE4\x46\x3A\x4B\xC8\x5B\x1C\xB3" "\xC1"; - static unsigned char p[] = + static const unsigned char p[] = "\x00\xEE\xCF\xAE\x81\xB1\xB9\xB3\xC9\x08\x81\x0B\x10\xA1\xB5\x60" "\x01\x99\xEB\x9F\x44\xAE\xF4\xFD\xA4\x93\xB8\x1A\x9E\x3D\x84\xF6" "\x32\x12\x4E\xF0\x23\x6E\x5D\x1E\x3B\x7E\x28\xFA\xE7\xAA\x04\x0A" "\x2D\x5B\x25\x21\x76\x45\x9D\x1F\x39\x75\x41\xBA\x2A\x58\xFB\x65" "\x99"; - static unsigned char q[] = + static const unsigned char q[] = "\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9" "\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5A\x0F\x20\x35\x02\x8B\x9D" "\x86\x98\x40\xB4\x16\x66\xB4\x2E\x92\xEA\x0D\xA3\xB4\x32\x04\xB5" "\xCF\xCE\x33\x52\x52\x4D\x04\x16\xA5\xA4\x41\xE7\x00\xAF\x46\x15" "\x03"; - static unsigned char dmp1[] = + static const unsigned char dmp1[] = "\x54\x49\x4C\xA6\x3E\xBA\x03\x37\xE4\xE2\x40\x23\xFC\xD6\x9A\x5A" "\xEB\x07\xDD\xDC\x01\x83\xA4\xD0\xAC\x9B\x54\xB0\x51\xF2\xB1\x3E" "\xD9\x49\x09\x75\xEA\xB7\x74\x14\xFF\x59\xC1\xF7\x69\x2E\x9A\x2E" "\x20\x2B\x38\xFC\x91\x0A\x47\x41\x74\xAD\xC9\x3C\x1F\x67\xC9\x81"; - static unsigned char dmq1[] = + static const unsigned char dmq1[] = "\x47\x1E\x02\x90\xFF\x0A\xF0\x75\x03\x51\xB7\xF8\x78\x86\x4C\xA9" "\x61\xAD\xBD\x3A\x8A\x7E\x99\x1C\x5C\x05\x56\xA9\x4C\x31\x46\xA7" "\xF9\x80\x3F\x8F\x6F\x8A\xE3\x42\xE9\x31\xFD\x8A\xE4\x7A\x22\x0D" "\x1B\x99\xA4\x95\x84\x98\x07\xFE\x39\xF9\x24\x5A\x98\x36\xDA\x3D"; - static unsigned char iqmp[] = + static const unsigned char iqmp[] = "\x00\xB0\x6C\x4F\xDA\xBB\x63\x01\x19\x8D\x26\x5B\xDB\xAE\x94\x23" "\xB3\x80\xF2\x71\xF7\x34\x53\x88\x50\x93\x07\x7F\xCD\x39\xE2\x11" "\x9F\xC9\x86\x32\x15\x4F\x58\x83\xB1\x67\xA9\x67\xBF\x40\x2B\x4E" "\x9E\x2E\x0F\x96\x56\xE6\x98\xEA\x36\x66\xED\xFB\x25\x79\x80\x39" "\xF7"; - static unsigned char ctext_ex[] = + static const unsigned char ctext_ex[] = "\x42\x4b\xc9\x51\x61\xd4\xca\xa0\x18\x6c\x4d\xca\x61\x8f\x2d\x07" "\x8c\x63\xc5\x6b\xa2\x4c\x32\xb1\xda\xb7\xdd\x32\xb6\x51\x68\xc3" "\x6e\x98\x46\xd6\xbb\x1a\xd5\x99\x05\x92\x7c\xd7\xbc\x08\x9e\xe4" @@ -152,7 +152,7 @@ int FIPS_selftest_rsa() unsigned char expected_ctext[256]; unsigned char ctext[256]; unsigned char ptext[256]; - static unsigned char original_ptext[] = + static const unsigned char original_ptext[] = "\x01\x23\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a\xbc\xde\xf0" "\x23\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a\xbc\xde\xf0\x12" "\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a\xbc\xde\xf0\x12\x34" @@ -163,10 +163,10 @@ int FIPS_selftest_rsa() "\xef\x12\x34\x56\x78\x9a\xbc\xde\xf0\x12\x34\x56\x78\x9a\xbc\xde" "\xf0\x12\x34\x56\x78\x9a\xbc\xde\xf0\x12\x34\x56\x78\x9a\xbc\xde"; unsigned char md[SHA_DIGEST_LENGTH]; - unsigned char mdkat[SHA_DIGEST_LENGTH] = + static const unsigned char mdkat[SHA_DIGEST_LENGTH] = "\x2d\x57\x1d\x6f\x5c\x37\xf9\xf0\x3b\xb4\x3c\xe8\x2c\x4c\xb3\x04" "\x75\xa2\x0e\xfb"; - unsigned char ctextkat[] = + static const unsigned char ctextkat[] = "\x3e\xc5\x0a\xbe\x29\xa2\xca\x9a\x35\x14\x17\x26\xa4\x0f\xa3\x03" "\x65\xb5\x37\xf5\x6a\xaa\xb\xf\x2c\x0d\x8\xc0\x73\x8\x3c\x88\x85" "\x36\x68\x16\xfe\x2f\x59\x77\x7e\x2a\x76\x9a\xc7\x27\x19\x9b\x54" diff --git a/fips/sha1/fips_sha1_selftest.c b/fips/sha1/fips_sha1_selftest.c index 248539acb0..0dd26c5564 100644 --- a/fips/sha1/fips_sha1_selftest.c +++ b/fips/sha1/fips_sha1_selftest.c @@ -53,7 +53,7 @@ #include #ifdef OPENSSL_FIPS -static char *test[]= +static const char * const test[]= { "", "abc", diff --git a/fips/sha1/fips_sha1dgst.c b/fips/sha1/fips_sha1dgst.c index dc2ce7daf0..fe4ebcb31c 100644 --- a/fips/sha1/fips_sha1dgst.c +++ b/fips/sha1/fips_sha1dgst.c @@ -65,7 +65,7 @@ #include #ifdef OPENSSL_FIPS -const char *SHA1_version="SHA1" OPENSSL_VERSION_PTEXT; +const char SHA1_version[]="SHA1" OPENSSL_VERSION_PTEXT; /* The implementation is in fips_md32_common.h */ #include "fips_sha_locl.h" diff --git a/fips/sha1/standalone.sha1 b/fips/sha1/standalone.sha1 index eca3b9d79f..d929a1e6d2 100644 --- a/fips/sha1/standalone.sha1 +++ b/fips/sha1/standalone.sha1 @@ -1,5 +1,5 @@ -HMAC-SHA1(fips_sha1dgst.c)= 10575600a9540eb15188a7d3b0b031e60aedbc18 -HMAC-SHA1(fips_sha1_selftest.c)= 98910a0c85eff1688bd7adb23e738dc75b39546e +HMAC-SHA1(fips_sha1dgst.c)= 867e990149be16fe9e758b916b5ffc9d9fa61afb +HMAC-SHA1(fips_sha1_selftest.c)= bd5c6ece3ef96237440bb0c51c7cf2bd42d39483 HMAC-SHA1(asm/fips-sx86-elf.s)= ae66fb23ab8e1a2287e87a0a2dd30a4b9039fe63 HMAC-SHA1(fips_standalone_sha1.c)= 93203c569097189b47a0085bc9fc55193867d4ce HMAC-SHA1(fips_sha_locl.h)= c1b4c82eec5f0ee119658456690f3ea9d77ed1c5 -- 2.25.1