diff options
author | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2013-10-13 12:42:32 +0300 |
---|---|---|
committer | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2013-11-04 16:05:17 +0200 |
commit | d50a88d1e29124d038196fec6082fd093e922604 (patch) | |
tree | b3b8704b99d1cef6e0f2abdcd436d62fddb69de7 /cipher | |
parent | d4697862266f3c96b6946dc92139dd8f3e81e5f6 (diff) | |
download | libgcrypt-d50a88d1e29124d038196fec6082fd093e922604.tar.gz |
Make test vectors 'static const'
* cipher/arcfour.c (selftest): Change test vectors to 'static const'.
* cipher/blowfish.c (selftest): Ditto.
* cipher/camellia-glue.c (selftest): Ditto.
* cipher/cast5.c (selftest): Ditto.
* cipher/des.c (selftest): Ditto.
* cipher/rijndael.c (selftest): Ditto.
* tests/basic.c (cipher_cbc_mac_cipher, check_aes128_cbc_cts_cipher)
(check_ctr_cipher, check_cfb_cipher, check_ofb_cipher)
(check_ccm_cipher, check_stream_cipher)
(check_stream_cipher_large_block, check_bulk_cipher_modes)
(check_ciphers, check_digests, check_hmac, check_pubkey_sign)
(check_pubkey_sign_ecdsa, check_pubkey_crypt, check_pubkey): Ditto.
--
Some test vectors have been defined without 'static' and thus end up being
initialized on runtime. Change these to 'static'. Also change test vectors
const where possible.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher')
-rw-r--r-- | cipher/arcfour.c | 4 | ||||
-rw-r--r-- | cipher/blowfish.c | 9 | ||||
-rw-r--r-- | cipher/camellia-glue.c | 14 | ||||
-rw-r--r-- | cipher/cast5.c | 9 | ||||
-rw-r--r-- | cipher/des.c | 3 | ||||
-rw-r--r-- | cipher/rijndael.c | 2 |
6 files changed, 24 insertions, 17 deletions
diff --git a/cipher/arcfour.c b/cipher/arcfour.c index e8a54843..89936f42 100644 --- a/cipher/arcfour.c +++ b/cipher/arcfour.c @@ -159,9 +159,9 @@ selftest(void) /* Test vector from Cryptlib labeled there: "from the State/Commerce Department". */ - static byte key_1[] = + static const byte key_1[] = { 0x61, 0x8A, 0x63, 0xD2, 0xFB }; - static byte plaintext_1[] = + static const byte plaintext_1[] = { 0xDC, 0xEE, 0x4C, 0xF9, 0x2C }; static const byte ciphertext_1[] = { 0xF1, 0x38, 0x29, 0xC9, 0xDE }; diff --git a/cipher/blowfish.c b/cipher/blowfish.c index 3b6bf6b9..84fa9d3d 100644 --- a/cipher/blowfish.c +++ b/cipher/blowfish.c @@ -822,9 +822,12 @@ selftest(void) BLOWFISH_context c; byte plain[] = "BLOWFISH"; byte buffer[8]; - byte plain3[] = { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10 }; - byte key3[] = { 0x41, 0x79, 0x6E, 0xA0, 0x52, 0x61, 0x6E, 0xE4 }; - byte cipher3[] = { 0xE1, 0x13, 0xF4, 0x10, 0x2C, 0xFC, 0xCE, 0x43 }; + static const byte plain3[] = + { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10 }; + static const byte key3[] = + { 0x41, 0x79, 0x6E, 0xA0, 0x52, 0x61, 0x6E, 0xE4 }; + static const byte cipher3[] = + { 0xE1, 0x13, 0xF4, 0x10, 0x2C, 0xFC, 0xCE, 0x43 }; const char *r; bf_setkey( (void *) &c, diff --git a/cipher/camellia-glue.c b/cipher/camellia-glue.c index 8c217a76..42b62d2c 100644 --- a/cipher/camellia-glue.c +++ b/cipher/camellia-glue.c @@ -582,38 +582,38 @@ selftest(void) const char *r; /* These test vectors are from RFC-3713 */ - const byte plaintext[]= + static const byte plaintext[]= { 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10 }; - const byte key_128[]= + static const byte key_128[]= { 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10 }; - const byte ciphertext_128[]= + static const byte ciphertext_128[]= { 0x67,0x67,0x31,0x38,0x54,0x96,0x69,0x73, 0x08,0x57,0x06,0x56,0x48,0xea,0xbe,0x43 }; - const byte key_192[]= + static const byte key_192[]= { 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xfe,0xdc,0xba,0x98, 0x76,0x54,0x32,0x10,0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77 }; - const byte ciphertext_192[]= + static const byte ciphertext_192[]= { 0xb4,0x99,0x34,0x01,0xb3,0xe9,0x96,0xf8, 0x4e,0xe5,0xce,0xe7,0xd7,0x9b,0x09,0xb9 }; - const byte key_256[]= + static const byte key_256[]= { 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xfe,0xdc,0xba, 0x98,0x76,0x54,0x32,0x10,0x00,0x11,0x22,0x33,0x44,0x55, 0x66,0x77,0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff }; - const byte ciphertext_256[]= + static const byte ciphertext_256[]= { 0x9a,0xcc,0x23,0x7d,0xff,0x16,0xd7,0x6c, 0x20,0xef,0x7c,0x91,0x9e,0x3a,0x75,0x09 diff --git a/cipher/cast5.c b/cipher/cast5.c index 0df7886d..8d141831 100644 --- a/cipher/cast5.c +++ b/cipher/cast5.c @@ -796,10 +796,13 @@ static const char* selftest(void) { CAST5_context c; - byte key[16] = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78, + static const byte key[16] = + { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78, 0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9A }; - byte plain[8] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }; - byte cipher[8]= { 0x23, 0x8B, 0x4F, 0xE5, 0x84, 0x7E, 0x44, 0xB2 }; + static const byte plain[8] = + { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }; + static const byte cipher[8] = + { 0x23, 0x8B, 0x4F, 0xE5, 0x84, 0x7E, 0x44, 0xB2 }; byte buffer[8]; const char *r; diff --git a/cipher/des.c b/cipher/des.c index 3464d53d..6611fd3b 100644 --- a/cipher/des.c +++ b/cipher/des.c @@ -893,7 +893,8 @@ selftest (void) * thanks to Jeroen C. van Gelderen. */ { - struct { byte key[24]; byte plain[8]; byte cipher[8]; } testdata[] = { + static const struct { byte key[24]; byte plain[8]; byte cipher[8]; } + testdata[] = { { { 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01 }, diff --git a/cipher/rijndael.c b/cipher/rijndael.c index e8733c93..b8cc18ba 100644 --- a/cipher/rijndael.c +++ b/cipher/rijndael.c @@ -2308,7 +2308,7 @@ selftest (void) static const char * selftest_fips_128_38a (int requested_mode) { - struct tv + static const struct tv { int mode; const unsigned char key[16]; |