Moved eel and eapml under the contrib folder.
This commit is contained in:
250
contrib/ise_library/text/encryption/eel/tests/aes_test.e
Normal file
250
contrib/ise_library/text/encryption/eel/tests/aes_test.e
Normal file
@@ -0,0 +1,250 @@
|
||||
note
|
||||
description: "Objects that ..."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
quote: "The best government is the one that charges you the least blackmail for leaving you alone. - Thomas Rudmose-Brown (1996)"
|
||||
|
||||
class
|
||||
AES_TEST
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
|
||||
feature
|
||||
test_vector_256
|
||||
local
|
||||
key_data: SPECIAL [NATURAL_8]
|
||||
key: AES_KEY
|
||||
cipher_text: SPECIAL [NATURAL_8]
|
||||
plain: SPECIAL [NATURAL_8]
|
||||
vector: SPECIAL [NATURAL_8]
|
||||
solution: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key_data.make_filled (0, 32)
|
||||
key_data [0] := 0x00
|
||||
key_data [1] := 0x01
|
||||
key_data [2] := 0x02
|
||||
key_data [3] := 0x03
|
||||
key_data [4] := 0x04
|
||||
key_data [5] := 0x05
|
||||
key_data [6] := 0x06
|
||||
key_data [7] := 0x07
|
||||
key_data [8] := 0x08
|
||||
key_data [9] := 0x09
|
||||
key_data [10] := 0x0a
|
||||
key_data [11] := 0x0b
|
||||
key_data [12] := 0x0c
|
||||
key_data [13] := 0x0d
|
||||
key_data [14] := 0x0e
|
||||
key_data [15] := 0x0f
|
||||
key_data [16] := 0x10
|
||||
key_data [17] := 0x11
|
||||
key_data [18] := 0x12
|
||||
key_data [19] := 0x13
|
||||
key_data [20] := 0x14
|
||||
key_data [21] := 0x15
|
||||
key_data [22] := 0x16
|
||||
key_data [23] := 0x17
|
||||
key_data [24] := 0x18
|
||||
key_data [25] := 0x19
|
||||
key_data [26] := 0x1a
|
||||
key_data [27] := 0x1b
|
||||
key_data [28] := 0x1c
|
||||
key_data [29] := 0x1d
|
||||
key_data [30] := 0x1e
|
||||
key_data [31] := 0x1f
|
||||
create key.make (key_data)
|
||||
create solution.make_filled (0, 16)
|
||||
solution [0] := 0x8e
|
||||
solution [1] := 0xa2
|
||||
solution [2] := 0xb7
|
||||
solution [3] := 0xca
|
||||
solution [4] := 0x51
|
||||
solution [5] := 0x67
|
||||
solution [6] := 0x45
|
||||
solution [7] := 0xbf
|
||||
solution [8] := 0xea
|
||||
solution [9] := 0xfc
|
||||
solution [10] := 0x49
|
||||
solution [11] := 0x90
|
||||
solution [12] := 0x4b
|
||||
solution [13] := 0x49
|
||||
solution [14] := 0x60
|
||||
solution [15] := 0x89
|
||||
create vector.make_filled (0, 16)
|
||||
vector [0] := 0x00
|
||||
vector [1] := 0x11
|
||||
vector [2] := 0x22
|
||||
vector [3] := 0x33
|
||||
vector [4] := 0x44
|
||||
vector [5] := 0x55
|
||||
vector [6] := 0x66
|
||||
vector [7] := 0x77
|
||||
vector [8] := 0x88
|
||||
vector [9] := 0x99
|
||||
vector [10] := 0xaa
|
||||
vector [11] := 0xbb
|
||||
vector [12] := 0xcc
|
||||
vector [13] := 0xdd
|
||||
vector [14] := 0xee
|
||||
vector [15] := 0xff
|
||||
create cipher_text.make_filled (0, 16)
|
||||
key.encrypt (vector, 0, cipher_text, 0)
|
||||
correct := cipher_text.same_items (solution, 0, 0, 16)
|
||||
assert ("test vector 256 1", correct)
|
||||
create plain.make_filled (0, 16)
|
||||
key.decrypt (cipher_text, 0, plain, 0)
|
||||
correct := plain.same_items (vector, 0, 0, 16)
|
||||
assert ("test vector 256 2", correct)
|
||||
end
|
||||
|
||||
test_vector_192
|
||||
local
|
||||
key_data: SPECIAL [NATURAL_8]
|
||||
key: AES_KEY
|
||||
cipher_text: SPECIAL [NATURAL_8]
|
||||
plain: SPECIAL [NATURAL_8]
|
||||
vector: SPECIAL [NATURAL_8]
|
||||
solution: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key_data.make_filled (0, 24)
|
||||
key_data [0] := 0x00
|
||||
key_data [1] := 0x01
|
||||
key_data [2] := 0x02
|
||||
key_data [3] := 0x03
|
||||
key_data [4] := 0x04
|
||||
key_data [5] := 0x05
|
||||
key_data [6] := 0x06
|
||||
key_data [7] := 0x07
|
||||
key_data [8] := 0x08
|
||||
key_data [9] := 0x09
|
||||
key_data [10] := 0x0a
|
||||
key_data [11] := 0x0b
|
||||
key_data [12] := 0x0c
|
||||
key_data [13] := 0x0d
|
||||
key_data [14] := 0x0e
|
||||
key_data [15] := 0x0f
|
||||
key_data [16] := 0x10
|
||||
key_data [17] := 0x11
|
||||
key_data [18] := 0x12
|
||||
key_data [19] := 0x13
|
||||
key_data [20] := 0x14
|
||||
key_data [21] := 0x15
|
||||
key_data [22] := 0x16
|
||||
key_data [23] := 0x17
|
||||
create key.make (key_data)
|
||||
create solution.make_filled (0, 16)
|
||||
solution [0] := 0xdd
|
||||
solution [1] := 0xa9
|
||||
solution [2] := 0x7c
|
||||
solution [3] := 0xa4
|
||||
solution [4] := 0x86
|
||||
solution [5] := 0x4c
|
||||
solution [6] := 0xdf
|
||||
solution [7] := 0xe0
|
||||
solution [8] := 0x6e
|
||||
solution [9] := 0xaf
|
||||
solution [10] := 0x70
|
||||
solution [11] := 0xa0
|
||||
solution [12] := 0xec
|
||||
solution [13] := 0x0d
|
||||
solution [14] := 0x71
|
||||
solution [15] := 0x91
|
||||
create vector.make_filled (0, 16)
|
||||
vector [0] := 0x00
|
||||
vector [1] := 0x11
|
||||
vector [2] := 0x22
|
||||
vector [3] := 0x33
|
||||
vector [4] := 0x44
|
||||
vector [5] := 0x55
|
||||
vector [6] := 0x66
|
||||
vector [7] := 0x77
|
||||
vector [8] := 0x88
|
||||
vector [9] := 0x99
|
||||
vector [10] := 0xaa
|
||||
vector [11] := 0xbb
|
||||
vector [12] := 0xcc
|
||||
vector [13] := 0xdd
|
||||
vector [14] := 0xee
|
||||
vector [15] := 0xff
|
||||
create cipher_text.make_filled (0, 16)
|
||||
key.encrypt (vector, 0, cipher_text, 0)
|
||||
correct := cipher_text.same_items (solution, 0, 0, 16)
|
||||
assert ("test vector 192 1", correct)
|
||||
create plain.make_filled (0, 16)
|
||||
key.decrypt (cipher_text, 0, plain, 0)
|
||||
correct := vector.same_items (plain, 0, 0, 16)
|
||||
assert ("test vector 192 2", correct)
|
||||
end
|
||||
|
||||
test_vector_128
|
||||
local
|
||||
aes: AES_KEY
|
||||
cipher_text: SPECIAL [NATURAL_8]
|
||||
plain: SPECIAL [NATURAL_8]
|
||||
vector_1: SPECIAL [NATURAL_8]
|
||||
solution: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_128
|
||||
create solution.make_filled (0, 16)
|
||||
solution [0] := 0x39
|
||||
solution [1] := 0x25
|
||||
solution [2] := 0x84
|
||||
solution [3] := 0x1d
|
||||
solution [4] := 0x02
|
||||
solution [5] := 0xdc
|
||||
solution [6] := 0x09
|
||||
solution [7] := 0xfb
|
||||
solution [8] := 0xdc
|
||||
solution [9] := 0x11
|
||||
solution [10] := 0x85
|
||||
solution [11] := 0x97
|
||||
solution [12] := 0x19
|
||||
solution [13] := 0x6a
|
||||
solution [14] := 0x0b
|
||||
solution [15] := 0x32
|
||||
create vector_1.make_filled (0, 16)
|
||||
vector_1 [0] := 0x32
|
||||
vector_1 [1] := 0x43
|
||||
vector_1 [2] := 0xf6
|
||||
vector_1 [3] := 0xa8
|
||||
vector_1 [4] := 0x88
|
||||
vector_1 [5] := 0x5a
|
||||
vector_1 [6] := 0x30
|
||||
vector_1 [7] := 0x8d
|
||||
vector_1 [8] := 0x31
|
||||
vector_1 [9] := 0x31
|
||||
vector_1 [10] := 0x98
|
||||
vector_1 [11] := 0xa2
|
||||
vector_1 [12] := 0xe0
|
||||
vector_1 [13] := 0x37
|
||||
vector_1 [14] := 0x07
|
||||
vector_1 [15] := 0x34
|
||||
create cipher_text.make_filled (0, 16)
|
||||
aes.encrypt (vector_1, 0, cipher_text, 0)
|
||||
correct := cipher_text.same_items (solution, 0, 0, 16)
|
||||
assert ("test vector 128 1", correct)
|
||||
create plain.make_filled (0, 16)
|
||||
aes.decrypt (cipher_text, 0, plain, 0)
|
||||
correct := vector_1.same_items (plain, 0, 0, 16)
|
||||
assert ("test vector 128 2", correct)
|
||||
end
|
||||
|
||||
test_keys
|
||||
local
|
||||
key1: AES_KEY
|
||||
key2: AES_KEY
|
||||
key3: AES_KEY
|
||||
do
|
||||
create key1.make_spec_128
|
||||
assert ("test keys 1", key1.spec_128_bit_schedule)
|
||||
create key2.make_spec_196
|
||||
assert ("test keys 2", key2.spec_196_bit_schedule)
|
||||
create key3.make_spec_256
|
||||
assert ("test keys 3", key3.spec_256_bit_schedule)
|
||||
end
|
||||
end
|
||||
226
contrib/ise_library/text/encryption/eel/tests/cbc_test.e
Normal file
226
contrib/ise_library/text/encryption/eel/tests/cbc_test.e
Normal file
@@ -0,0 +1,226 @@
|
||||
note
|
||||
description: "Tests Cipher Block Chaining mode"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
quote: "Government is the great fiction, through which everybody endeavors to live at the expense of everybody else. - Frederic Bastiat"
|
||||
|
||||
class
|
||||
CBC_TEST
|
||||
|
||||
inherit
|
||||
MODE_TEST_DATA
|
||||
undefine
|
||||
default_create
|
||||
end
|
||||
EQA_TEST_SET
|
||||
redefine
|
||||
on_prepare
|
||||
end
|
||||
|
||||
feature {NONE}
|
||||
on_prepare
|
||||
local
|
||||
ciphertext: INTEGER_X
|
||||
do
|
||||
make_data
|
||||
create ciphertext.make_from_hex_string ("7649abac8119b246cee98e9b12e9197d")
|
||||
create ciphertext_1_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_1_128, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("5086cb9b507219ee95db113a917678b2")
|
||||
create ciphertext_2_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_2_128, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("73bed6b8e3c1743b7116e69e22229516")
|
||||
create ciphertext_3_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_3_128, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("3ff1caa1681fac09120eca307586e1a7")
|
||||
create ciphertext_4_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_4_128, 0, 15)
|
||||
|
||||
create ciphertext.make_from_hex_string ("4f021db243bc633d7178183a9fa071e8")
|
||||
create ciphertext_1_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_1_196, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("b4d9ada9ad7dedf4e5e738763f69145a")
|
||||
create ciphertext_2_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_2_196, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("571b242012fb7ae07fa9baac3df102e0")
|
||||
create ciphertext_3_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_3_196, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("08b0e27988598881d920a9e64f5615cd")
|
||||
create ciphertext_4_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_4_196, 0, 15)
|
||||
|
||||
create ciphertext.make_from_hex_string ("f58c4c04d6e5f1ba779eabfb5f7bfbd6")
|
||||
create ciphertext_1_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_1_256, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("9cfc4e967edb808d679f777bc6702c7d")
|
||||
create ciphertext_2_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_2_256, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("39f23369a9d9bacfa530e26304231461")
|
||||
create ciphertext_3_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_3_256, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("b2eb05e2c39be9fcda6c19078c6a9d1b")
|
||||
create ciphertext_4_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_4_256, 0, 15)
|
||||
end
|
||||
|
||||
feature
|
||||
ciphertext_1_128: SPECIAL [NATURAL_8]
|
||||
ciphertext_2_128: SPECIAL [NATURAL_8]
|
||||
ciphertext_3_128: SPECIAL [NATURAL_8]
|
||||
ciphertext_4_128: SPECIAL [NATURAL_8]
|
||||
|
||||
ciphertext_1_196: SPECIAL [NATURAL_8]
|
||||
ciphertext_2_196: SPECIAL [NATURAL_8]
|
||||
ciphertext_3_196: SPECIAL [NATURAL_8]
|
||||
ciphertext_4_196: SPECIAL [NATURAL_8]
|
||||
|
||||
ciphertext_1_256: SPECIAL [NATURAL_8]
|
||||
ciphertext_2_256: SPECIAL [NATURAL_8]
|
||||
ciphertext_3_256: SPECIAL [NATURAL_8]
|
||||
ciphertext_4_256: SPECIAL [NATURAL_8]
|
||||
|
||||
test_encryption_128
|
||||
local
|
||||
cbc: CBC_ENCRYPTION
|
||||
aes: AES_KEY
|
||||
ciphertext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_128
|
||||
create ciphertext.make_filled (0, 16)
|
||||
create cbc.make (aes, iv, 0)
|
||||
cbc.encrypt_block (block_1, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_1_128, 0, 0, 16)
|
||||
assert ("test encryption 128 1", correct)
|
||||
cbc.encrypt_block (block_2, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_2_128, 0, 0, 16)
|
||||
assert ("test encryption 128 2", correct)
|
||||
cbc.encrypt_block (block_3, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_3_128, 0, 0, 16)
|
||||
assert ("test encryption 128 3", correct)
|
||||
cbc.encrypt_block (block_4, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_4_128, 0, 0, 16)
|
||||
assert ("test encryption 128 4", correct)
|
||||
end
|
||||
|
||||
test_decryption_128
|
||||
local
|
||||
cbc: CBC_DECRYPTION
|
||||
aes: AES_KEY
|
||||
plaintext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_128
|
||||
create plaintext.make_filled (0, 16)
|
||||
create cbc.make (aes, iv, 0)
|
||||
cbc.decrypt_block (ciphertext_1_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_1, 0, 0, 16)
|
||||
assert ("test decryption 128 1", correct)
|
||||
cbc.decrypt_block (ciphertext_2_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_2, 0, 0, 16)
|
||||
assert ("test decryption 128 2", correct)
|
||||
cbc.decrypt_block (ciphertext_3_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_3, 0, 0, 16)
|
||||
assert ("test decryption 128 3", correct)
|
||||
cbc.decrypt_block (ciphertext_4_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_4, 0, 0, 16)
|
||||
assert ("test decryption 128 4", correct)
|
||||
end
|
||||
|
||||
test_encryption_196
|
||||
local
|
||||
cbc: CBC_ENCRYPTION
|
||||
aes: AES_KEY
|
||||
ciphertext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_196
|
||||
create ciphertext.make_filled (0, 16)
|
||||
create cbc.make (aes, iv, 0)
|
||||
cbc.encrypt_block (block_1, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_1_196, 0, 0, 16)
|
||||
assert ("test encryption 196 1", correct)
|
||||
cbc.encrypt_block (block_2, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_2_196, 0, 0, 16)
|
||||
assert ("test encryption 196 2", correct)
|
||||
cbc.encrypt_block (block_3, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_3_196, 0, 0, 16)
|
||||
assert ("test encryption 196 3", correct)
|
||||
cbc.encrypt_block (block_4, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_4_196, 0, 0, 16)
|
||||
assert ("test encryption 196 4", correct)
|
||||
end
|
||||
|
||||
test_decryption_196
|
||||
local
|
||||
cbc: CBC_DECRYPTION
|
||||
aes: AES_KEY
|
||||
plaintext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_196
|
||||
create plaintext.make_filled (0, 16)
|
||||
create cbc.make (aes, iv, 0)
|
||||
cbc.decrypt_block (ciphertext_1_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_1, 0, 0, 16)
|
||||
assert ("test decryption 196 1", correct)
|
||||
cbc.decrypt_block (ciphertext_2_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_2, 0, 0, 16)
|
||||
assert ("test decryption 196 2", correct)
|
||||
cbc.decrypt_block (ciphertext_3_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_3, 0, 0, 16)
|
||||
assert ("test decryption 196 3", correct)
|
||||
cbc.decrypt_block (ciphertext_4_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_4, 0, 0, 16)
|
||||
assert ("test decryption 196 4", correct)
|
||||
end
|
||||
|
||||
test_encryption_256
|
||||
local
|
||||
cbc: CBC_ENCRYPTION
|
||||
aes: AES_KEY
|
||||
ciphertext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_256
|
||||
create ciphertext.make_filled (0, 16)
|
||||
create cbc.make (aes, iv, 0)
|
||||
cbc.encrypt_block (block_1, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_1_256, 0, 0, 16)
|
||||
assert ("test encryption 256 1", correct)
|
||||
cbc.encrypt_block (block_2, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_2_256, 0, 0, 16)
|
||||
assert ("test encryption 256 2", correct)
|
||||
cbc.encrypt_block (block_3, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_3_256, 0, 0, 16)
|
||||
assert ("test encryption 256 3", correct)
|
||||
cbc.encrypt_block (block_4, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_4_256, 0, 0, 16)
|
||||
assert ("test encryption 256 4", correct)
|
||||
end
|
||||
|
||||
test_decryption_256
|
||||
local
|
||||
cbc: CBC_DECRYPTION
|
||||
aes: AES_KEY
|
||||
plaintext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_256
|
||||
create plaintext.make_filled (0, 16)
|
||||
create cbc.make (aes, iv, 0)
|
||||
cbc.decrypt_block (ciphertext_1_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_1, 0, 0, 16)
|
||||
assert ("test decryption 256 1", correct)
|
||||
cbc.decrypt_block (ciphertext_2_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_2, 0, 0, 16)
|
||||
assert ("test decryption 256 2", correct)
|
||||
cbc.decrypt_block (ciphertext_3_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_3, 0, 0, 16)
|
||||
assert ("test decryption 256 3", correct)
|
||||
cbc.decrypt_block (ciphertext_4_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_4, 0, 0, 16)
|
||||
assert ("test decryption 256 4", correct)
|
||||
end
|
||||
end
|
||||
226
contrib/ise_library/text/encryption/eel/tests/cfb_test.e
Normal file
226
contrib/ise_library/text/encryption/eel/tests/cfb_test.e
Normal file
@@ -0,0 +1,226 @@
|
||||
note
|
||||
description: "Tests Cipher Feedback mode"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
quote: "Liberty is the only thing you cannot have unless you are willing to give it to others. - William Allen White"
|
||||
|
||||
class
|
||||
CFB_TEST
|
||||
|
||||
inherit
|
||||
MODE_TEST_DATA
|
||||
undefine
|
||||
default_create
|
||||
end
|
||||
EQA_TEST_SET
|
||||
redefine
|
||||
on_prepare
|
||||
end
|
||||
|
||||
feature {NONE}
|
||||
on_prepare
|
||||
local
|
||||
ciphertext: INTEGER_X
|
||||
do
|
||||
make_data
|
||||
create ciphertext.make_from_hex_string ("3b3fd92eb72dad20333449f8e83cfb4a")
|
||||
create ciphertext_1_128_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_1_128_128, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("c8a64537a0b3a93fcde3cdad9f1ce58b")
|
||||
create ciphertext_2_128_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_2_128_128, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("26751f67a3cbb140b1808cf187a4f4df")
|
||||
create ciphertext_3_128_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_3_128_128, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("c04b05357c5d1c0eeac4c66f9ff7f2e6")
|
||||
create ciphertext_4_128_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_4_128_128, 0, 15)
|
||||
|
||||
create ciphertext.make_from_hex_string ("cdc80d6fddf18cab34c25909c99a4174")
|
||||
create ciphertext_1_128_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_1_128_196, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("67ce7f7f81173621961a2b70171d3d7a")
|
||||
create ciphertext_2_128_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_2_128_196, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("2e1e8a1dd59b88b1c8e60fed1efac4c9")
|
||||
create ciphertext_3_128_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_3_128_196, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("c05f9f9ca9834fa042ae8fba584b09ff")
|
||||
create ciphertext_4_128_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_4_128_196, 0, 15)
|
||||
|
||||
create ciphertext.make_from_hex_string ("dc7e84bfda79164b7ecd8486985d3860")
|
||||
create ciphertext_1_128_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_1_128_256, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("39ffed143b28b1c832113c6331e5407b")
|
||||
create ciphertext_2_128_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_2_128_256, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("df10132415e54b92a13ed0a8267ae2f9")
|
||||
create ciphertext_3_128_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_3_128_256, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("75a385741ab9cef82031623d55b1e471")
|
||||
create ciphertext_4_128_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_4_128_256, 0, 15)
|
||||
end
|
||||
|
||||
feature
|
||||
ciphertext_1_128_128: SPECIAL [NATURAL_8]
|
||||
ciphertext_2_128_128: SPECIAL [NATURAL_8]
|
||||
ciphertext_3_128_128: SPECIAL [NATURAL_8]
|
||||
ciphertext_4_128_128: SPECIAL [NATURAL_8]
|
||||
|
||||
ciphertext_1_128_196: SPECIAL [NATURAL_8]
|
||||
ciphertext_2_128_196: SPECIAL [NATURAL_8]
|
||||
ciphertext_3_128_196: SPECIAL [NATURAL_8]
|
||||
ciphertext_4_128_196: SPECIAL [NATURAL_8]
|
||||
|
||||
ciphertext_1_128_256: SPECIAL [NATURAL_8]
|
||||
ciphertext_2_128_256: SPECIAL [NATURAL_8]
|
||||
ciphertext_3_128_256: SPECIAL [NATURAL_8]
|
||||
ciphertext_4_128_256: SPECIAL [NATURAL_8]
|
||||
|
||||
test_encryption_128_128
|
||||
local
|
||||
cfb: CFB_ENCRYPTION
|
||||
aes: AES_KEY
|
||||
ciphertext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_128
|
||||
create ciphertext.make_filled (0, 16)
|
||||
create cfb.make (aes, iv, 0, 16)
|
||||
cfb.encrypt_block (block_1, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_1_128_128, 0, 0, 16)
|
||||
assert ("test encryption 128 128 1", correct)
|
||||
cfb.encrypt_block (block_2, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_2_128_128, 0, 0, 16)
|
||||
assert ("test encryption 128 128 2", correct)
|
||||
cfb.encrypt_block (block_3, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_3_128_128, 0, 0, 16)
|
||||
assert ("test encryption 128 128 3", correct)
|
||||
cfb.encrypt_block (block_4, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_4_128_128, 0, 0, 16)
|
||||
assert ("test encryption 128 128 4", correct)
|
||||
end
|
||||
|
||||
test_decryption_128_128
|
||||
local
|
||||
cfb: CFB_DECRYPTION
|
||||
aes: AES_KEY
|
||||
plaintext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_128
|
||||
create plaintext.make_filled (0, 16)
|
||||
create cfb.make (aes, iv, 0, 16)
|
||||
cfb.decrypt_block (ciphertext_1_128_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_1, 0, 0, 16)
|
||||
assert ("test decryption 128 128 1", correct)
|
||||
cfb.decrypt_block (ciphertext_2_128_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_2, 0, 0, 16)
|
||||
assert ("test decryption 128 128 2", correct)
|
||||
cfb.decrypt_block (ciphertext_3_128_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_3, 0, 0, 16)
|
||||
assert ("test decryption 128 128 3", correct)
|
||||
cfb.decrypt_block (ciphertext_4_128_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_4, 0, 0, 16)
|
||||
assert ("test decryption 128 128 4", correct)
|
||||
end
|
||||
|
||||
test_encryption_128_196
|
||||
local
|
||||
cfb: CFB_ENCRYPTION
|
||||
aes: AES_KEY
|
||||
ciphertext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_196
|
||||
create ciphertext.make_filled (0, 16)
|
||||
create cfb.make (aes, iv, 0, 16)
|
||||
cfb.encrypt_block (block_1, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_1_128_196, 0, 0, 16)
|
||||
assert ("test encryption 128 196 1", correct)
|
||||
cfb.encrypt_block (block_2, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_2_128_196, 0, 0, 16)
|
||||
assert ("test encryption 128 196 2", correct)
|
||||
cfb.encrypt_block (block_3, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_3_128_196, 0, 0, 16)
|
||||
assert ("test encryption 128 196 3", correct)
|
||||
cfb.encrypt_block (block_4, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_4_128_196, 0, 0, 16)
|
||||
assert ("test encryption 128 196 4", correct)
|
||||
end
|
||||
|
||||
test_decryption_128_196
|
||||
local
|
||||
cfb: CFB_DECRYPTION
|
||||
aes: AES_KEY
|
||||
plaintext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_196
|
||||
create plaintext.make_filled (0, 16)
|
||||
create cfb.make (aes, iv, 0, 16)
|
||||
cfb.decrypt_block (ciphertext_1_128_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_1, 0, 0, 16)
|
||||
assert ("test decryption 128 196 1", correct)
|
||||
cfb.decrypt_block (ciphertext_2_128_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_2, 0, 0, 16)
|
||||
assert ("test decryption 128 196 2", correct)
|
||||
cfb.decrypt_block (ciphertext_3_128_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_3, 0, 0, 16)
|
||||
assert ("test decryption 128 196 3", correct)
|
||||
cfb.decrypt_block (ciphertext_4_128_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_4, 0, 0, 16)
|
||||
assert ("test decryption 128 196 4", correct)
|
||||
end
|
||||
|
||||
test_encryption_128_256
|
||||
local
|
||||
cfb: CFB_ENCRYPTION
|
||||
aes: AES_KEY
|
||||
ciphertext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_256
|
||||
create ciphertext.make_filled (0, 16)
|
||||
create cfb.make (aes, iv, 0, 16)
|
||||
cfb.encrypt_block (block_1, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_1_128_256, 0, 0, 16)
|
||||
assert ("test encryption 128 256 1", correct)
|
||||
cfb.encrypt_block (block_2, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_2_128_256, 0, 0, 16)
|
||||
assert ("test encryption 128 256 2", correct)
|
||||
cfb.encrypt_block (block_3, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_3_128_256, 0, 0, 16)
|
||||
assert ("test encryption 128 256 3", correct)
|
||||
cfb.encrypt_block (block_4, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_4_128_256, 0, 0, 16)
|
||||
assert ("test encryption 128 256 4", correct)
|
||||
end
|
||||
|
||||
test_decryption_128_256
|
||||
local
|
||||
cfb: CFB_DECRYPTION
|
||||
aes: AES_KEY
|
||||
plaintext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_256
|
||||
create plaintext.make_filled (0, 16)
|
||||
create cfb.make (aes, iv, 0, 16)
|
||||
cfb.decrypt_block (ciphertext_1_128_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_1, 0, 0, 16)
|
||||
assert ("test decryption 128 256 1", correct)
|
||||
cfb.decrypt_block (ciphertext_2_128_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_2, 0, 0, 16)
|
||||
assert ("test decryption 128 256 2", correct)
|
||||
cfb.decrypt_block (ciphertext_3_128_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_3, 0, 0, 16)
|
||||
assert ("test decryption 128 256 3", correct)
|
||||
cfb.decrypt_block (ciphertext_4_128_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_4, 0, 0, 16)
|
||||
assert ("test decryption 128 256 4", correct)
|
||||
end
|
||||
end
|
||||
226
contrib/ise_library/text/encryption/eel/tests/ctr_test.e
Normal file
226
contrib/ise_library/text/encryption/eel/tests/ctr_test.e
Normal file
@@ -0,0 +1,226 @@
|
||||
note
|
||||
description: "Tests Counter mode"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
quote: "We contend that for a nation to try to tax itself into prosperity is like a man standing in a bucket and trying to lift himself up by the handle. - Winston Churchill (1903)"
|
||||
|
||||
class
|
||||
CTR_TEST
|
||||
|
||||
inherit
|
||||
MODE_TEST_DATA
|
||||
undefine
|
||||
default_create
|
||||
end
|
||||
EQA_TEST_SET
|
||||
redefine
|
||||
on_prepare
|
||||
end
|
||||
|
||||
feature {NONE}
|
||||
on_prepare
|
||||
local
|
||||
ciphertext: INTEGER_X
|
||||
do
|
||||
make_data
|
||||
create ciphertext.make_from_hex_string ("874d6191b620e3261bef6864990db6ce")
|
||||
create ciphertext_1_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_1_128, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("9806f66b7970fdff8617187bb9fffdff")
|
||||
create ciphertext_2_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_2_128, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("5ae4df3edbd5d35e5b4f09020db03eab")
|
||||
create ciphertext_3_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_3_128, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("1e031dda2fbe03d1792170a0f3009cee")
|
||||
create ciphertext_4_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_4_128, 0, 15)
|
||||
|
||||
create ciphertext.make_from_hex_string ("1abc932417521ca24f2b0459fe7e6e0b")
|
||||
create ciphertext_1_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_1_196, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("090339ec0aa6faefd5ccc2c6f4ce8e94")
|
||||
create ciphertext_2_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_2_196, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("1e36b26bd1ebc670d1bd1d665620abf7")
|
||||
create ciphertext_3_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_3_196, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("4f78a7f6d29809585a97daec58c6b050")
|
||||
create ciphertext_4_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_4_196, 0, 15)
|
||||
|
||||
create ciphertext.make_from_hex_string ("601ec313775789a5b7a7f504bbf3d228")
|
||||
create ciphertext_1_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_1_256, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("f443e3ca4d62b59aca84e990cacaf5c5")
|
||||
create ciphertext_2_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_2_256, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("2b0930daa23de94ce87017ba2d84988d")
|
||||
create ciphertext_3_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_3_256, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("dfc9c58db67aada613c2dd08457941a6")
|
||||
create ciphertext_4_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_4_256, 0, 15)
|
||||
end
|
||||
|
||||
feature
|
||||
ciphertext_1_128: SPECIAL [NATURAL_8]
|
||||
ciphertext_2_128: SPECIAL [NATURAL_8]
|
||||
ciphertext_3_128: SPECIAL [NATURAL_8]
|
||||
ciphertext_4_128: SPECIAL [NATURAL_8]
|
||||
|
||||
ciphertext_1_196: SPECIAL [NATURAL_8]
|
||||
ciphertext_2_196: SPECIAL [NATURAL_8]
|
||||
ciphertext_3_196: SPECIAL [NATURAL_8]
|
||||
ciphertext_4_196: SPECIAL [NATURAL_8]
|
||||
|
||||
ciphertext_1_256: SPECIAL [NATURAL_8]
|
||||
ciphertext_2_256: SPECIAL [NATURAL_8]
|
||||
ciphertext_3_256: SPECIAL [NATURAL_8]
|
||||
ciphertext_4_256: SPECIAL [NATURAL_8]
|
||||
|
||||
test_encryption_128
|
||||
local
|
||||
ctr: CTR_ENCRYPTION
|
||||
aes: AES_KEY
|
||||
ciphertext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_128
|
||||
create ciphertext.make_filled (0, 16)
|
||||
create ctr.make (aes, iv_counter)
|
||||
ctr.encrypt_block (block_1, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_1_128, 0, 0, 16)
|
||||
assert ("test encryption 128 1", correct)
|
||||
ctr.encrypt_block (block_2, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_2_128, 0, 0, 16)
|
||||
assert ("test encryption 128 2", correct)
|
||||
ctr.encrypt_block (block_3, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_3_128, 0, 0, 16)
|
||||
assert ("test encryption 128 3", correct)
|
||||
ctr.encrypt_block (block_4, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_4_128, 0, 0, 16)
|
||||
assert ("test encryption 128 4", correct)
|
||||
end
|
||||
|
||||
test_decryption_128
|
||||
local
|
||||
ctr: CTR_DECRYPTION
|
||||
aes: AES_KEY
|
||||
plaintext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_128
|
||||
create plaintext.make_filled (0, 16)
|
||||
create ctr.make (aes, iv_counter)
|
||||
ctr.decrypt_block (ciphertext_1_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_1, 0, 0, 16)
|
||||
assert ("test decryption 128 1", correct)
|
||||
ctr.decrypt_block (ciphertext_2_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_2, 0, 0, 16)
|
||||
assert ("test decryption 128 2", correct)
|
||||
ctr.decrypt_block (ciphertext_3_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_3, 0, 0, 16)
|
||||
assert ("test decryption 128 3", correct)
|
||||
ctr.decrypt_block (ciphertext_4_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_4, 0, 0, 16)
|
||||
assert ("test decryption 128 4", correct)
|
||||
end
|
||||
|
||||
test_encryption_196
|
||||
local
|
||||
ctr: CTR_ENCRYPTION
|
||||
aes: AES_KEY
|
||||
ciphertext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_196
|
||||
create ciphertext.make_filled (0, 16)
|
||||
create ctr.make (aes, iv_counter)
|
||||
ctr.encrypt_block (block_1, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_1_196, 0, 0, 16)
|
||||
assert ("test encryption 196 1", correct)
|
||||
ctr.encrypt_block (block_2, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_2_196, 0, 0, 16)
|
||||
assert ("test encryption 196 2", correct)
|
||||
ctr.encrypt_block (block_3, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_3_196, 0, 0, 16)
|
||||
assert ("test encryption 196 3", correct)
|
||||
ctr.encrypt_block (block_4, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_4_196, 0, 0, 16)
|
||||
assert ("test encryption 196 4", correct)
|
||||
end
|
||||
|
||||
test_decryption_196
|
||||
local
|
||||
ctr: CTR_DECRYPTION
|
||||
aes: AES_KEY
|
||||
plaintext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_196
|
||||
create plaintext.make_filled (0, 16)
|
||||
create ctr.make (aes, iv_counter)
|
||||
ctr.decrypt_block (ciphertext_1_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_1, 0, 0, 16)
|
||||
assert ("test decryption 196 1", correct)
|
||||
ctr.decrypt_block (ciphertext_2_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_2, 0, 0, 16)
|
||||
assert ("test decryption 196 2", correct)
|
||||
ctr.decrypt_block (ciphertext_3_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_3, 0, 0, 16)
|
||||
assert ("test decryption 196 3", correct)
|
||||
ctr.decrypt_block (ciphertext_4_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_4, 0, 0, 16)
|
||||
assert ("test decryption 196 4", correct)
|
||||
end
|
||||
|
||||
test_encryption_256
|
||||
local
|
||||
ctr: CTR_ENCRYPTION
|
||||
aes: AES_KEY
|
||||
ciphertext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_256
|
||||
create ciphertext.make_filled (0, 16)
|
||||
create ctr.make (aes, iv_counter)
|
||||
ctr.encrypt_block (block_1, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_1_256, 0, 0, 16)
|
||||
assert ("test encryption 256 1", correct)
|
||||
ctr.encrypt_block (block_2, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_2_256, 0, 0, 16)
|
||||
assert ("test encryption 256 2", correct)
|
||||
ctr.encrypt_block (block_3, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_3_256, 0, 0, 16)
|
||||
assert ("test encryption 256 3", correct)
|
||||
ctr.encrypt_block (block_4, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_4_256, 0, 0, 16)
|
||||
assert ("test encryption 256 4", correct)
|
||||
end
|
||||
|
||||
test_decryption_256
|
||||
local
|
||||
ctr: CTR_DECRYPTION
|
||||
aes: AES_KEY
|
||||
plaintext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_256
|
||||
create plaintext.make_filled (0, 16)
|
||||
create ctr.make (aes, iv_counter)
|
||||
ctr.decrypt_block (ciphertext_1_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_1, 0, 0, 16)
|
||||
assert ("test decryption 256 1", correct)
|
||||
ctr.decrypt_block (ciphertext_2_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_2, 0, 0, 16)
|
||||
assert ("test decryption 256 2", correct)
|
||||
ctr.decrypt_block (ciphertext_3_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_3, 0, 0, 16)
|
||||
assert ("test decryption 256 3", correct)
|
||||
ctr.decrypt_block (ciphertext_4_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_4, 0, 0, 16)
|
||||
assert ("test decryption 256 4", correct)
|
||||
end
|
||||
end
|
||||
52
contrib/ise_library/text/encryption/eel/tests/der_test.e
Normal file
52
contrib/ise_library/text/encryption/eel/tests/der_test.e
Normal file
@@ -0,0 +1,52 @@
|
||||
note
|
||||
description: "Tests DER encoding facilities"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
quote: "Nothing can destroy a government more quickly than its failure to observe its own laws, or worse, its disregard of the charter of its own existence - U.S. Supreme Court Justice Tom C. Clark - Mapp vs. Ohio"
|
||||
|
||||
class
|
||||
DER_TEST
|
||||
|
||||
inherit
|
||||
DER_FACILITIES
|
||||
undefine
|
||||
default_create
|
||||
end
|
||||
|
||||
EQA_TEST_SET
|
||||
|
||||
feature
|
||||
-- test_big_int
|
||||
-- local
|
||||
-- int: INTEGER_X
|
||||
-- sink: ARRAY_DER_SINK
|
||||
-- target: ARRAY [NATURAL_8]
|
||||
-- answer: ARRAY [NATURAL_8]
|
||||
-- do
|
||||
-- create int.make_from_hex_string ("02F40E7E 2221F295 DE297117 B7F3D62F 5C6A97FF CB8CEFF1 CD6BA8CE 4A9A18AD 84FFABBD 8EFA5933 2BE7AD67 56A66E29 4AFD185A 78FF12AA 520E4DE7 39BACA0C 7FFEFF7F 2955727A 02F40E7E 2221F295 DE297117 B7F3D62F 5C6A97FF CB8CEFF1 CD6BA8CE 4A9A18AD 84FFABBD 8EFA5933 2BE7AD67 56A66E29 4AFD185A 78FF12AA 520E4DE7 39BACA0C 7FFEFF7F 2955727A")
|
||||
-- create target.make (1, 0)
|
||||
-- create sink.make (target)
|
||||
-- create answer.make (1, 1 + 1 + 4 + 36 * 4)
|
||||
-- encode_integer (sink, int)
|
||||
-- assert ("test big int 1", target.count = answer.count)
|
||||
-- assert ("test big int 2", target.same_items (answer))
|
||||
-- end
|
||||
|
||||
-- test_small_int
|
||||
-- local
|
||||
-- int: INTEGER_X
|
||||
-- sink: ARRAY_DER_SINK
|
||||
-- target: ARRAY [NATURAL_8]
|
||||
-- answer: ARRAY [NATURAL_8]
|
||||
-- do
|
||||
-- create int.make_from_natural (0x738243)
|
||||
-- create target.make (1, 0)
|
||||
-- create sink.make (target)
|
||||
-- create answer.make (1, 1 + 1 + 3)
|
||||
-- answer [1] := 0x2 answer [2] := 0x3 answer [3] := 0x73 answer [4] := 0x82 answer [5] := 0x43
|
||||
-- encode_integer (sink, int)
|
||||
-- assert ("test small int 1", target.count = answer.count)
|
||||
-- assert ("test small int 2", target.same_items (answer))
|
||||
-- end
|
||||
end
|
||||
407
contrib/ise_library/text/encryption/eel/tests/ec_test.e
Normal file
407
contrib/ise_library/text/encryption/eel/tests/ec_test.e
Normal file
@@ -0,0 +1,407 @@
|
||||
note
|
||||
description : "Tests basic Elliptical Curve library functionality"
|
||||
author : "Colin LeMahieu"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
quote: "Giving money and power to government is like giving whiskey and car keys to teenage boys. - P.J. O'Rourke"
|
||||
|
||||
class
|
||||
EC_TEST
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
|
||||
feature -- Polynomial math
|
||||
test_sec_multiply
|
||||
local
|
||||
curve: EC_CURVE_FP
|
||||
g: EC_POINT_FP
|
||||
d: INTEGER_X
|
||||
q: EC_POINT_FP
|
||||
q_x_solution: INTEGER_X
|
||||
q_y_solution: INTEGER_X
|
||||
q_solution: EC_POINT_FP
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create curve.make_sec_p160r1
|
||||
create g.make_sec_p160r1
|
||||
create d.make_from_hex_string ("AA374FFC 3CE144E6 B0733079 72CB6D57 B2A4E982")
|
||||
q := g.product_value (d, curve)
|
||||
create q_x_solution.make_from_string ("466448783855397898016055842232266600516272889280")
|
||||
create q_y_solution.make_from_string ("1110706324081757720403272427311003102474457754220")
|
||||
create q_solution.make_curve_x_y (create {EC_FIELD_ELEMENT_FP}.make_p_x (q_x_solution), create {EC_FIELD_ELEMENT_FP}.make_p_x (q_y_solution))
|
||||
correct := q ~ q_solution
|
||||
assert ("test sec multiply", correct)
|
||||
end
|
||||
|
||||
test_sec_sign
|
||||
local
|
||||
h: INTEGER_X
|
||||
e: INTEGER_X
|
||||
k: INTEGER_X
|
||||
g: EC_POINT_FP
|
||||
r: EC_POINT_FP
|
||||
r_x_solution: INTEGER_X
|
||||
r_y_solution: INTEGER_X
|
||||
r_solution: EC_POINT_FP
|
||||
curve: EC_CURVE_FP
|
||||
correct: BOOLEAN
|
||||
s: INTEGER_X
|
||||
d: INTEGER_X
|
||||
s_solution: INTEGER_X
|
||||
n: INTEGER_X
|
||||
do
|
||||
create n.make_from_hex_string ("01 00000000 00000000 0001F4C8 F927AED3 CA752257")
|
||||
create d.make_from_hex_string ("AA374FFC 3CE144E6 B0733079 72CB6D57 B2A4E982")
|
||||
create h.make_from_hex_string ("A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D")
|
||||
create curve.make_sec_p160r1
|
||||
create g.make_sec_p160r1
|
||||
create k.make_from_string ("702232148019446860144825009548118511996283736794")
|
||||
r := g.product_value (k, curve)
|
||||
create r_x_solution.make_from_string ("1176954224688105769566774212902092897866168635793")
|
||||
create r_y_solution.make_from_string ("1130322298812061698910820170565981471918861336822")
|
||||
create r_solution.make_curve_x_y (create {EC_FIELD_ELEMENT_FP}.make_p_x (r_x_solution), create {EC_FIELD_ELEMENT_FP}.make_p_x (r_y_solution))
|
||||
correct := r_solution ~ r
|
||||
assert ("test sec sign 1", correct)
|
||||
e := h
|
||||
s := (k.inverse_value (n) * (e + d * r.x.x)) \\ n
|
||||
create s_solution.make_from_string ("299742580584132926933316745664091704165278518100")
|
||||
correct := s ~ s_solution
|
||||
assert ("test sec sign 2", correct)
|
||||
end
|
||||
|
||||
test_set_verify
|
||||
local
|
||||
h: INTEGER_X
|
||||
e: INTEGER_X
|
||||
s: INTEGER_X
|
||||
r: INTEGER_X
|
||||
n: INTEGER_X
|
||||
u1: INTEGER_X
|
||||
u2: INTEGER_X
|
||||
g: EC_POINT_FP
|
||||
q: EC_POINT_FP
|
||||
q_x: INTEGER_X
|
||||
q_y: INTEGER_X
|
||||
curve: EC_CURVE_FP
|
||||
r_point: EC_POINT_FP
|
||||
r_x_solution: INTEGER_X
|
||||
r_y_solution: INTEGER_X
|
||||
gu: EC_POINT_FP
|
||||
gu_x_solution: INTEGER_X
|
||||
gu_y_solution: INTEGER_X
|
||||
qu: EC_POINT_FP
|
||||
qu_x_solution: INTEGER_X
|
||||
qu_y_solution: INTEGER_X
|
||||
correct: BOOLEAN
|
||||
v: INTEGER_X
|
||||
u1_solution: INTEGER_X
|
||||
u2_solution: INTEGER_X
|
||||
do
|
||||
create h.make_from_hex_string ("A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D")
|
||||
create n.make_from_hex_string ("01 00000000 00000000 0001F4C8 F927AED3 CA752257")
|
||||
create g.make_sec_p160r1
|
||||
create r.make_from_string ("1176954224688105769566774212902092897866168635793")
|
||||
create s.make_from_string ("299742580584132926933316745664091704165278518100")
|
||||
create curve.make_sec_p160r1
|
||||
create q_x.make_from_string ("466448783855397898016055842232266600516272889280")
|
||||
create q_y.make_from_string ("1110706324081757720403272427311003102474457754220")
|
||||
create q.make_curve_x_y (create {EC_FIELD_ELEMENT_FP}.make_p_x (q_x), create {EC_FIELD_ELEMENT_FP}.make_p_x (q_y))
|
||||
create gu_x_solution.make_from_string ("559637225459801172484164154368876326912482639549")
|
||||
create gu_y_solution.make_from_string ("1427364757892877133166464896740210315153233662312")
|
||||
create qu_x_solution.make_from_string ("1096326382299378890940501642113021093797486469420")
|
||||
create qu_y_solution.make_from_string ("1361206527591198621565826173236094337930170472426")
|
||||
create r_x_solution.make_from_string ("1176954224688105769566774212902092897866168635793")
|
||||
create r_y_solution.make_from_string ("1130322298812061698910820170565981471918861336822")
|
||||
create u1_solution.make_from_string ("126492345237556041805390442445971246551226394866")
|
||||
create u2_solution.make_from_string ("642136937233451268764953375477669732399252982122")
|
||||
e := h
|
||||
u1 := e * s.inverse_value (n) \\ n
|
||||
correct := u1 ~ u1_solution
|
||||
assert ("test set verify 1", correct)
|
||||
u2 := r * s.inverse_value (n) \\ n
|
||||
correct := u2 ~ u2_solution
|
||||
assert ("test set verify 2", correct)
|
||||
gu := g.product_value (u1, curve)
|
||||
correct := gu.x.x ~ gu_x_solution
|
||||
assert ("test set verify 3", correct)
|
||||
correct := gu.y.x ~ gu_y_solution
|
||||
assert ("test set verify 4", correct)
|
||||
qu := q.product_value (u2, curve)
|
||||
correct := qu.x.x ~ qu_x_solution
|
||||
assert ("test set verify 5", correct)
|
||||
correct := qu.y.x ~ qu_y_solution
|
||||
assert ("test set verify 6", correct)
|
||||
r_point := gu.plus_value (qu, curve)
|
||||
correct := r_x_solution ~ r_point.x.x
|
||||
assert ("test set verify 7", correct)
|
||||
correct := r_y_solution ~ r_point.y.x
|
||||
assert ("test set verify 8", correct)
|
||||
v := r_point.x.x \\ n
|
||||
correct := v ~ r
|
||||
assert ("test set verify 9", correct)
|
||||
end
|
||||
|
||||
feature -- Prime reflexive tests
|
||||
test_reflexive_2
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
i: INTEGER
|
||||
do
|
||||
from
|
||||
i := 0
|
||||
until
|
||||
i > 10
|
||||
loop
|
||||
create key.make_sec_p112r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test reflexive 2 iteration: " + i.out, correct)
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
|
||||
test_reflexive
|
||||
local
|
||||
key1: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create message.make_from_string ("968236873715988614170569073515315707566766479517")
|
||||
create key1.make_p521
|
||||
signature := key1.private.sign (message)
|
||||
correct := key1.public.verify (message, signature)
|
||||
assert ("test reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_p112r1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_p112r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec p112r1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_p112r2_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_p112r2
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec p112r2 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_p128r1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_p128r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec p128r1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_p128r2_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_p128r2
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec p128r2 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_p160k1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_p160k1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec p160k1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_p160r1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_p160r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec p160r1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_p160r2_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_p160r2
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec p160r2 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_p192k1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_p192k1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec p192k1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_p192r1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_p192r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec p192r1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_p224k1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_p224k1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec p224k1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_p224r1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_p224r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec p224r1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_p256k1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_p256k1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec p256k1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_p256r1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_p256r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec p256r1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_p384r1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_p384r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec p384r1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_p521r1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_p521r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec p521r1 relfexive", correct)
|
||||
end
|
||||
|
||||
test_agreement
|
||||
local
|
||||
key1: EC_KEY_PAIR
|
||||
key2: EC_KEY_PAIR
|
||||
e1_agreement: INTEGER_X
|
||||
e2_agreement: INTEGER_X
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key1.make_p521
|
||||
create key2.make_p521
|
||||
e1_agreement := key1.private.agreement (key2.public)
|
||||
e2_agreement := key2.private.agreement (key1.public)
|
||||
correct := e1_agreement ~ e2_agreement
|
||||
assert ("test agreement", correct)
|
||||
end
|
||||
end
|
||||
227
contrib/ise_library/text/encryption/eel/tests/ecb_test.e
Normal file
227
contrib/ise_library/text/encryption/eel/tests/ecb_test.e
Normal file
@@ -0,0 +1,227 @@
|
||||
note
|
||||
description: "Tests Electronic Codebook mode"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
quote: "Ask not what you can do for your country; ask what your government is doing to you. - Joseph Sobran (1990)"
|
||||
|
||||
class
|
||||
ECB_TEST
|
||||
|
||||
inherit
|
||||
MODE_TEST_DATA
|
||||
undefine
|
||||
default_create
|
||||
end
|
||||
|
||||
EQA_TEST_SET
|
||||
redefine
|
||||
on_prepare
|
||||
end
|
||||
|
||||
feature {NONE}
|
||||
on_prepare
|
||||
local
|
||||
ciphertext: INTEGER_X
|
||||
do
|
||||
make_data
|
||||
create ciphertext.make_from_hex_string ("3ad77bb40d7a3660a89ecaf32466ef97")
|
||||
create ciphertext_1_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_1_128, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("f5d3d58503b9699de785895a96fdbaaf")
|
||||
create ciphertext_2_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_2_128, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("43b1cd7f598ece23881b00e3ed030688")
|
||||
create ciphertext_3_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_3_128, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("7b0c785e27e8ad3f8223207104725dd4")
|
||||
create ciphertext_4_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_4_128, 0, 15)
|
||||
|
||||
create ciphertext.make_from_hex_string ("bd334f1d6e45f25ff712a214571fa5cc")
|
||||
create ciphertext_1_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_1_196, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("974104846d0ad3ad7734ecb3ecee4eef")
|
||||
create ciphertext_2_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_2_196, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("ef7afd2270e2e60adce0ba2face6444e")
|
||||
create ciphertext_3_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_3_196, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("9a4b41ba738d6c72fb16691603c18e0e")
|
||||
create ciphertext_4_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_4_196, 0, 15)
|
||||
|
||||
create ciphertext.make_from_hex_string ("f3eed1bdb5d2a03c064b5a7e3db181f8")
|
||||
create ciphertext_1_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_1_256, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("591ccb10d410ed26dc5ba74a31362870")
|
||||
create ciphertext_2_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_2_256, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("b6ed21b99ca6f4f9f153e7b1beafed1d")
|
||||
create ciphertext_3_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_3_256, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("23304b7a39f9f3ff067d8d8f9e24ecc7")
|
||||
create ciphertext_4_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_4_256, 0, 15)
|
||||
end
|
||||
|
||||
feature
|
||||
ciphertext_1_128: SPECIAL [NATURAL_8]
|
||||
ciphertext_2_128: SPECIAL [NATURAL_8]
|
||||
ciphertext_3_128: SPECIAL [NATURAL_8]
|
||||
ciphertext_4_128: SPECIAL [NATURAL_8]
|
||||
|
||||
ciphertext_1_196: SPECIAL [NATURAL_8]
|
||||
ciphertext_2_196: SPECIAL [NATURAL_8]
|
||||
ciphertext_3_196: SPECIAL [NATURAL_8]
|
||||
ciphertext_4_196: SPECIAL [NATURAL_8]
|
||||
|
||||
ciphertext_1_256: SPECIAL [NATURAL_8]
|
||||
ciphertext_2_256: SPECIAL [NATURAL_8]
|
||||
ciphertext_3_256: SPECIAL [NATURAL_8]
|
||||
ciphertext_4_256: SPECIAL [NATURAL_8]
|
||||
|
||||
test_encryption_128
|
||||
local
|
||||
ecb: ECB_ENCRYPTION
|
||||
aes: AES_KEY
|
||||
ciphertext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_128
|
||||
create ciphertext.make_filled (0, 16)
|
||||
create ecb.make (aes)
|
||||
ecb.encrypt_block (block_1, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_1_128, 0, 0, 16)
|
||||
assert ("test encryption 128 1", correct)
|
||||
ecb.encrypt_block (block_2, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_2_128, 0, 0, 16)
|
||||
assert ("test encryption 128 2", correct)
|
||||
ecb.encrypt_block (block_3, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_3_128, 0, 0, 16)
|
||||
assert ("test encryption 128 3", correct)
|
||||
ecb.encrypt_block (block_4, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_4_128, 0, 0, 16)
|
||||
assert ("test encryption 128 4", correct)
|
||||
end
|
||||
|
||||
test_decryption_128
|
||||
local
|
||||
ecb: ECB_DECRYPTION
|
||||
aes: AES_KEY
|
||||
plaintext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_128
|
||||
create plaintext.make_filled (0, 16)
|
||||
create ecb.make (aes)
|
||||
ecb.decrypt_block (ciphertext_1_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_1, 0, 0, 16)
|
||||
assert ("test decryption 128 1", correct)
|
||||
ecb.decrypt_block (ciphertext_2_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_2, 0, 0, 16)
|
||||
assert ("test decryption 128 2", correct)
|
||||
ecb.decrypt_block (ciphertext_3_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_3, 0, 0, 16)
|
||||
assert ("test decryption 128 3", correct)
|
||||
ecb.decrypt_block (ciphertext_4_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_4, 0, 0, 16)
|
||||
assert ("test decryption 128 4", correct)
|
||||
end
|
||||
|
||||
test_encryption_196
|
||||
local
|
||||
ecb: ECB_ENCRYPTION
|
||||
aes: AES_KEY
|
||||
ciphertext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_196
|
||||
create ciphertext.make_filled (0, 16)
|
||||
create ecb.make (aes)
|
||||
ecb.encrypt_block (block_1, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_1_196, 0, 0, 16)
|
||||
assert ("test encryption 196 1", correct)
|
||||
ecb.encrypt_block (block_2, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_2_196, 0, 0, 16)
|
||||
assert ("test encryption 196 2", correct)
|
||||
ecb.encrypt_block (block_3, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_3_196, 0, 0, 16)
|
||||
assert ("test encryption 196 3", correct)
|
||||
ecb.encrypt_block (block_4, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_4_196, 0, 0, 16)
|
||||
assert ("test encryption 196 4", correct)
|
||||
end
|
||||
|
||||
test_decryption_196
|
||||
local
|
||||
ecb: ECB_DECRYPTION
|
||||
aes: AES_KEY
|
||||
plaintext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_196
|
||||
create plaintext.make_filled (0, 16)
|
||||
create ecb.make (aes)
|
||||
ecb.decrypt_block (ciphertext_1_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_1, 0, 0, 16)
|
||||
assert ("test decryption 196 1", correct)
|
||||
ecb.decrypt_block (ciphertext_2_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_2, 0, 0, 16)
|
||||
assert ("test decryption 196 2", correct)
|
||||
ecb.decrypt_block (ciphertext_3_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_3, 0, 0, 16)
|
||||
assert ("test decryption 196 3", correct)
|
||||
ecb.decrypt_block (ciphertext_4_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_4, 0, 0, 16)
|
||||
assert ("test decryption 196 4", correct)
|
||||
end
|
||||
|
||||
test_encryption_256
|
||||
local
|
||||
ecb: ECB_ENCRYPTION
|
||||
aes: AES_KEY
|
||||
ciphertext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_256
|
||||
create ciphertext.make_filled (0, 16)
|
||||
create ecb.make (aes)
|
||||
ecb.encrypt_block (block_1, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_1_256, 0, 0, 16)
|
||||
assert ("test encryption 256 1", correct)
|
||||
ecb.encrypt_block (block_2, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_2_256, 0, 0, 16)
|
||||
assert ("test encryption 256 2", correct)
|
||||
ecb.encrypt_block (block_3, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_3_256, 0, 0, 16)
|
||||
assert ("test encryption 256 3", correct)
|
||||
ecb.encrypt_block (block_4, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_4_256, 0, 0, 16)
|
||||
assert ("test encryption 256 4", correct)
|
||||
end
|
||||
|
||||
test_decryption_256
|
||||
local
|
||||
ecb: ECB_DECRYPTION
|
||||
aes: AES_KEY
|
||||
plaintext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_256
|
||||
create plaintext.make_filled (0, 16)
|
||||
create ecb.make (aes)
|
||||
ecb.decrypt_block (ciphertext_1_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_1, 0, 0, 16)
|
||||
assert ("test decryption 256 1", correct)
|
||||
ecb.decrypt_block (ciphertext_2_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_2, 0, 0, 16)
|
||||
assert ("test decryption 256 2", correct)
|
||||
ecb.decrypt_block (ciphertext_3_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_3, 0, 0, 16)
|
||||
assert ("test decryption 256 3", correct)
|
||||
ecb.decrypt_block (ciphertext_4_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_4, 0, 0, 16)
|
||||
assert ("test decryption 256 4", correct)
|
||||
end
|
||||
end
|
||||
110
contrib/ise_library/text/encryption/eel/tests/hmac_sha256_test.e
Normal file
110
contrib/ise_library/text/encryption/eel/tests/hmac_sha256_test.e
Normal file
@@ -0,0 +1,110 @@
|
||||
note
|
||||
description: "Summary description for {HMAC_SHA256_TEST}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
HMAC_SHA256_TEST
|
||||
|
||||
inherit
|
||||
|
||||
EQA_TEST_SET
|
||||
|
||||
feature
|
||||
|
||||
test_empty
|
||||
local
|
||||
hmac: HMAC_SHA256
|
||||
do
|
||||
create hmac.make (create {INTEGER_X}.make_from_hex_string ("0"))
|
||||
hmac.finish
|
||||
hmac.reset
|
||||
hmac.finish
|
||||
end
|
||||
|
||||
test_rfc_4231_1
|
||||
local
|
||||
hmac: HMAC_SHA256
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create hmac.make (create {INTEGER_X}.make_from_hex_string ("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"))
|
||||
hmac.sink_string ("Hi There")
|
||||
hmac.finish
|
||||
create expected.make_from_hex_string ("b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7")
|
||||
assert ("test_rfc_4231_1", hmac.hmac ~ expected)
|
||||
end
|
||||
|
||||
test_rfc_4231_2
|
||||
local
|
||||
hmac: HMAC_SHA256
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create hmac.make (create {INTEGER_X}.make_from_hex_string ("4a656665"))
|
||||
hmac.sink_string ("what do ya want for nothing?")
|
||||
hmac.finish
|
||||
create expected.make_from_hex_string ("5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843")
|
||||
assert ("test_rfc_4231_2", hmac.hmac ~ expected)
|
||||
end
|
||||
|
||||
test_rfc_4231_2_ascii
|
||||
local
|
||||
hmac: HMAC_SHA256
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create hmac.make_ascii_key ("Jefe")
|
||||
hmac.sink_string ("what do ya want for nothing?")
|
||||
hmac.finish
|
||||
create expected.make_from_hex_string ("5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843")
|
||||
assert ("test_rfc_4231_2", hmac.hmac ~ expected)
|
||||
end
|
||||
|
||||
test_rfc_4231_3
|
||||
local
|
||||
hmac: HMAC_SHA256
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create hmac.make (create {INTEGER_X}.make_from_hex_string ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
|
||||
hmac.sink_string (create {STRING_8}.make_filled ('%/221/', 50))
|
||||
hmac.finish
|
||||
create expected.make_from_hex_string ("773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe")
|
||||
assert ("test_rfc_4231_3", hmac.hmac ~ expected)
|
||||
end
|
||||
|
||||
test_rfc_4231_4
|
||||
local
|
||||
hmac: HMAC_SHA256
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create hmac.make (create {INTEGER_X}.make_from_hex_string ("0102030405060708090a0b0c0d0e0f10111213141516171819"))
|
||||
hmac.sink_string (create {STRING_8}.make_filled ('%/205/', 50))
|
||||
hmac.finish
|
||||
create expected.make_from_hex_string ("82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b")
|
||||
assert ("test_rfc_4231_4", hmac.hmac ~ expected)
|
||||
end
|
||||
|
||||
test_rfc_4231_6
|
||||
local
|
||||
hmac: HMAC_SHA256
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create hmac.make (create {INTEGER_X}.make_from_hex_string ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
|
||||
hmac.sink_string ("Test Using Larger Than Block-Size Key - Hash Key First")
|
||||
hmac.finish
|
||||
create expected.make_from_hex_string ("60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54")
|
||||
assert ("test_rfc_4231_6", hmac.hmac ~ expected)
|
||||
end
|
||||
|
||||
test_rfc_4231_7
|
||||
local
|
||||
hmac: HMAC_SHA256
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create hmac.make (create {INTEGER_X}.make_from_hex_string ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
|
||||
hmac.sink_string ("This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.")
|
||||
hmac.finish
|
||||
create expected.make_from_hex_string ("9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2")
|
||||
assert ("test_rfc_4231_7", hmac.hmac ~ expected)
|
||||
end
|
||||
|
||||
end
|
||||
136
contrib/ise_library/text/encryption/eel/tests/md5_test.e
Normal file
136
contrib/ise_library/text/encryption/eel/tests/md5_test.e
Normal file
@@ -0,0 +1,136 @@
|
||||
note
|
||||
description: "Summary description for {MD5_TEST}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
quote: "Give me liberty or give me death! - Patrick Henry"
|
||||
|
||||
class
|
||||
MD5_TEST
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
|
||||
feature
|
||||
test_million_a
|
||||
local
|
||||
md5: MD5
|
||||
count: INTEGER_32
|
||||
do
|
||||
create md5.make
|
||||
from
|
||||
count := 1
|
||||
until
|
||||
count > 1_000_000
|
||||
loop
|
||||
md5.sink_character ('a')
|
||||
count := count + 1
|
||||
end
|
||||
end
|
||||
|
||||
test_alphabet
|
||||
local
|
||||
md5: MD5
|
||||
output: SPECIAL [NATURAL_8]
|
||||
solution: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create solution.make_filled (0, 16)
|
||||
solution [0] := 0xc3
|
||||
solution [1] := 0xfc
|
||||
solution [2] := 0xd3
|
||||
solution [3] := 0xd7
|
||||
solution [4] := 0x61
|
||||
solution [5] := 0x92
|
||||
solution [6] := 0xe4
|
||||
solution [7] := 0x00
|
||||
solution [8] := 0x7d
|
||||
solution [9] := 0xfb
|
||||
solution [10] := 0x49
|
||||
solution [11] := 0x6c
|
||||
solution [12] := 0xca
|
||||
solution [13] := 0x67
|
||||
solution [14] := 0xe1
|
||||
solution [15] := 0x3b
|
||||
create output.make_filled (0, 16)
|
||||
create md5.make
|
||||
md5.sink_string ("abcdefghijklmnopqrstuvwxyz")
|
||||
md5.do_final (output, 0)
|
||||
correct := solution.same_items (output, 0, 0, 16)
|
||||
assert ("test alphabet", correct)
|
||||
end
|
||||
|
||||
test_empty
|
||||
local
|
||||
md5: MD5
|
||||
output: SPECIAL [NATURAL_8]
|
||||
do
|
||||
create output.make_filled (0, 16)
|
||||
create md5.make
|
||||
md5.do_final (output, 0)
|
||||
end
|
||||
|
||||
test_a
|
||||
local
|
||||
md5: MD5
|
||||
output: SPECIAL [NATURAL_8]
|
||||
solution: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create solution.make_filled (0, 16)
|
||||
solution [0] := 0x0c
|
||||
solution [1] := 0xc1
|
||||
solution [2] := 0x75
|
||||
solution [3] := 0xb9
|
||||
solution [4] := 0xc0
|
||||
solution [5] := 0xf1
|
||||
solution [6] := 0xb6
|
||||
solution [7] := 0xa8
|
||||
solution [8] := 0x31
|
||||
solution [9] := 0xc3
|
||||
solution [10] := 0x99
|
||||
solution [11] := 0xe2
|
||||
solution [12] := 0x69
|
||||
solution [13] := 0x77
|
||||
solution [14] := 0x26
|
||||
solution [15] := 0x61
|
||||
create output.make_filled (0, 16)
|
||||
create md5.make
|
||||
md5.sink_string ("a")
|
||||
md5.do_final (output, 0)
|
||||
correct := solution.same_items (output, 0, 0, 16)
|
||||
assert ("test a", correct)
|
||||
end
|
||||
|
||||
test_abc
|
||||
local
|
||||
md5: MD5
|
||||
output: SPECIAL [NATURAL_8]
|
||||
solution: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create solution.make_filled (0, 16)
|
||||
solution [0] := 0x90
|
||||
solution [1] := 0x01
|
||||
solution [2] := 0x50
|
||||
solution [3] := 0x98
|
||||
solution [4] := 0x3c
|
||||
solution [5] := 0xd2
|
||||
solution [6] := 0x4f
|
||||
solution [7] := 0xb0
|
||||
solution [8] := 0xd6
|
||||
solution [9] := 0x96
|
||||
solution [10] := 0x3f
|
||||
solution [11] := 0x7d
|
||||
solution [12] := 0x28
|
||||
solution [13] := 0xe1
|
||||
solution [14] := 0x7f
|
||||
solution [15] := 0x72
|
||||
create output.make_filled (0, 16)
|
||||
create md5.make
|
||||
md5.sink_string ("abc")
|
||||
md5.do_final (output, 0)
|
||||
correct := solution.same_items (output, 0, 0, 16)
|
||||
assert ("test abc", correct)
|
||||
end
|
||||
end
|
||||
226
contrib/ise_library/text/encryption/eel/tests/ofb_test.e
Normal file
226
contrib/ise_library/text/encryption/eel/tests/ofb_test.e
Normal file
@@ -0,0 +1,226 @@
|
||||
note
|
||||
description: "Tests Output Feedback mode"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
quote: "Government is actually the worst failure of civilized man. There has never been a really good one, and even those that are most tolerable are arbitrary, cruel, grasping, and unintelligent. - H. L. Mencken"
|
||||
|
||||
class
|
||||
OFB_TEST
|
||||
|
||||
inherit
|
||||
MODE_TEST_DATA
|
||||
undefine
|
||||
default_create
|
||||
end
|
||||
EQA_TEST_SET
|
||||
redefine
|
||||
on_prepare
|
||||
end
|
||||
|
||||
feature {NONE}
|
||||
on_prepare
|
||||
local
|
||||
ciphertext: INTEGER_X
|
||||
do
|
||||
make_data
|
||||
create ciphertext.make_from_hex_string ("3b3fd92eb72dad20333449f8e83cfb4a")
|
||||
create ciphertext_1_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_1_128, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("7789508d16918f03f53c52dac54ed825")
|
||||
create ciphertext_2_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_2_128, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("9740051e9c5fecf64344f7a82260edcc")
|
||||
create ciphertext_3_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_3_128, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("304c6528f659c77866a510d9c1d6ae5e")
|
||||
create ciphertext_4_128.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_4_128, 0, 15)
|
||||
|
||||
create ciphertext.make_from_hex_string ("cdc80d6fddf18cab34c25909c99a4174")
|
||||
create ciphertext_1_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_1_196, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("fcc28b8d4c63837c09e81700c1100401")
|
||||
create ciphertext_2_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_2_196, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("8d9a9aeac0f6596f559c6d4daf59a5f2")
|
||||
create ciphertext_3_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_3_196, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("6d9f200857ca6c3e9cac524bd9acc92a")
|
||||
create ciphertext_4_196.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_4_196, 0, 15)
|
||||
|
||||
create ciphertext.make_from_hex_string ("dc7e84bfda79164b7ecd8486985d3860")
|
||||
create ciphertext_1_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_1_256, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("4febdc6740d20b3ac88f6ad82a4fb08d")
|
||||
create ciphertext_2_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_2_256, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("71ab47a086e86eedf39d1c5bba97c408")
|
||||
create ciphertext_3_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_3_256, 0, 15)
|
||||
create ciphertext.make_from_hex_string ("0126141d67f37be8538f5a8be740e484")
|
||||
create ciphertext_4_256.make_filled (0, 16)
|
||||
ciphertext.to_fixed_width_byte_array (ciphertext_4_256, 0, 15)
|
||||
end
|
||||
|
||||
feature
|
||||
ciphertext_1_128: SPECIAL [NATURAL_8]
|
||||
ciphertext_2_128: SPECIAL [NATURAL_8]
|
||||
ciphertext_3_128: SPECIAL [NATURAL_8]
|
||||
ciphertext_4_128: SPECIAL [NATURAL_8]
|
||||
|
||||
ciphertext_1_196: SPECIAL [NATURAL_8]
|
||||
ciphertext_2_196: SPECIAL [NATURAL_8]
|
||||
ciphertext_3_196: SPECIAL [NATURAL_8]
|
||||
ciphertext_4_196: SPECIAL [NATURAL_8]
|
||||
|
||||
ciphertext_1_256: SPECIAL [NATURAL_8]
|
||||
ciphertext_2_256: SPECIAL [NATURAL_8]
|
||||
ciphertext_3_256: SPECIAL [NATURAL_8]
|
||||
ciphertext_4_256: SPECIAL [NATURAL_8]
|
||||
|
||||
test_encryption_128
|
||||
local
|
||||
ofb: OFB_ENCRYPTION
|
||||
aes: AES_KEY
|
||||
ciphertext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_128
|
||||
create ciphertext.make_filled (0, 16)
|
||||
create ofb.make (aes, iv, 0)
|
||||
ofb.encrypt_block (block_1, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_1_128, 0, 0, 16)
|
||||
assert ("test encryption 128 1", correct)
|
||||
ofb.encrypt_block (block_2, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_2_128, 0, 0, 16)
|
||||
assert ("test encryption 128 2", correct)
|
||||
ofb.encrypt_block (block_3, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_3_128, 0, 0, 16)
|
||||
assert ("test encryption 128 3", correct)
|
||||
ofb.encrypt_block (block_4, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_4_128, 0, 0, 16)
|
||||
assert ("test encryption 128 4", correct)
|
||||
end
|
||||
|
||||
test_decryption_128
|
||||
local
|
||||
ofb: OFB_DECRYPTION
|
||||
aes: AES_KEY
|
||||
plaintext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_128
|
||||
create plaintext.make_filled (0, 16)
|
||||
create ofb.make (aes, iv, 0)
|
||||
ofb.decrypt_block (ciphertext_1_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_1, 0, 0, 16)
|
||||
assert ("test decryption 128 1", correct)
|
||||
ofb.decrypt_block (ciphertext_2_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_2, 0, 0, 16)
|
||||
assert ("test decryption 128 2", correct)
|
||||
ofb.decrypt_block (ciphertext_3_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_3, 0, 0, 16)
|
||||
assert ("test decryption 128 3", correct)
|
||||
ofb.decrypt_block (ciphertext_4_128, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_4, 0, 0, 16)
|
||||
assert ("test decryption 128 4", correct)
|
||||
end
|
||||
|
||||
test_encryption_196
|
||||
local
|
||||
ofb: OFB_ENCRYPTION
|
||||
aes: AES_KEY
|
||||
ciphertext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_196
|
||||
create ciphertext.make_filled (0, 16)
|
||||
create ofb.make (aes, iv, 0)
|
||||
ofb.encrypt_block (block_1, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_1_196, 0, 0, 16)
|
||||
assert ("test encryption 196 1", correct)
|
||||
ofb.encrypt_block (block_2, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_2_196, 0, 0, 16)
|
||||
assert ("test encryption 196 2", correct)
|
||||
ofb.encrypt_block (block_3, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_3_196, 0, 0, 16)
|
||||
assert ("test encryption 196 3", correct)
|
||||
ofb.encrypt_block (block_4, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_4_196, 0, 0, 16)
|
||||
assert ("test encryption 196 4", correct)
|
||||
end
|
||||
|
||||
test_decryption_196
|
||||
local
|
||||
ofb: OFB_DECRYPTION
|
||||
aes: AES_KEY
|
||||
plaintext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_196
|
||||
create plaintext.make_filled (0, 16)
|
||||
create ofb.make (aes, iv, 0)
|
||||
ofb.decrypt_block (ciphertext_1_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_1, 0, 0, 16)
|
||||
assert ("test decryption 196 1", correct)
|
||||
ofb.decrypt_block (ciphertext_2_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_2, 0, 0, 16)
|
||||
assert ("test decryption 196 2", correct)
|
||||
ofb.decrypt_block (ciphertext_3_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_3, 0, 0, 16)
|
||||
assert ("test decryption 196 3", correct)
|
||||
ofb.decrypt_block (ciphertext_4_196, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_4, 0, 0, 16)
|
||||
assert ("test decryption 196 4", correct)
|
||||
end
|
||||
|
||||
test_encryption_256
|
||||
local
|
||||
ofb: OFB_ENCRYPTION
|
||||
aes: AES_KEY
|
||||
ciphertext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_256
|
||||
create ciphertext.make_filled (0, 16)
|
||||
create ofb.make (aes, iv, 0)
|
||||
ofb.encrypt_block (block_1, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_1_256, 0, 0, 16)
|
||||
assert ("test encryption 256 1", correct)
|
||||
ofb.encrypt_block (block_2, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_2_256, 0, 0, 16)
|
||||
assert ("test encryption 256 2", correct)
|
||||
ofb.encrypt_block (block_3, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_3_256, 0, 0, 16)
|
||||
assert ("test encryption 256 3", correct)
|
||||
ofb.encrypt_block (block_4, 0, ciphertext, 0)
|
||||
correct := ciphertext.same_items (ciphertext_4_256, 0, 0, 16)
|
||||
assert ("test encryption 256 4", correct)
|
||||
end
|
||||
|
||||
test_decryption_256
|
||||
local
|
||||
cbc: OFB_DECRYPTION
|
||||
aes: AES_KEY
|
||||
plaintext: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create aes.make_spec_256
|
||||
create plaintext.make_filled (0, 16)
|
||||
create cbc.make (aes, iv, 0)
|
||||
cbc.decrypt_block (ciphertext_1_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_1, 0, 0, 16)
|
||||
assert ("test decryption 256 1", correct)
|
||||
cbc.decrypt_block (ciphertext_2_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_2, 0, 0, 16)
|
||||
assert ("test decryption 256 2", correct)
|
||||
cbc.decrypt_block (ciphertext_3_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_3, 0, 0, 16)
|
||||
assert ("test decryption 256 3", correct)
|
||||
cbc.decrypt_block (ciphertext_4_256, 0, plaintext, 0)
|
||||
correct := plaintext.same_items (block_4, 0, 0, 16)
|
||||
assert ("test decryption 256 4", correct)
|
||||
end
|
||||
end
|
||||
89
contrib/ise_library/text/encryption/eel/tests/rsa_test.e
Normal file
89
contrib/ise_library/text/encryption/eel/tests/rsa_test.e
Normal file
@@ -0,0 +1,89 @@
|
||||
note
|
||||
description: "Summary description for {RSA_TEST}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
quote: "When buying and selling are controlled by legislation, the first things to be bought and sold are legislators. - P.J. O'Rourke"
|
||||
|
||||
class
|
||||
RSA_TEST
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
|
||||
feature
|
||||
test_small
|
||||
local
|
||||
private: RSA_PRIVATE_KEY
|
||||
public: RSA_PUBLIC_KEY
|
||||
message: INTEGER_X
|
||||
ciphertext: INTEGER_X
|
||||
plaintext: INTEGER_X
|
||||
do
|
||||
create private.make (61, 53, 3233, 17)
|
||||
create public.make (3233, 17)
|
||||
assert ("test small 1", private.d.to_integer = 2753)
|
||||
create message.make_from_integer (123)
|
||||
ciphertext := public.encrypt (message)
|
||||
assert ("test small 2", ciphertext.to_integer = 855)
|
||||
plaintext := private.decrypt (ciphertext)
|
||||
assert ("test small 3", plaintext.to_integer = 123)
|
||||
end
|
||||
|
||||
test_1024_reflexive
|
||||
local
|
||||
key_pair: RSA_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
cipher: INTEGER_X
|
||||
plain: INTEGER_X
|
||||
signature: INTEGER_X
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key_pair.make (1024)
|
||||
create message.make_random (128)
|
||||
cipher := key_pair.public.encrypt (message)
|
||||
plain := key_pair.private.decrypt (cipher)
|
||||
assert ("test 1024 reflexive 1", plain ~ message)
|
||||
signature := key_pair.private.sign (message)
|
||||
correct := key_pair.public.verify (message, signature)
|
||||
assert ("test 1024 reflexive 2", correct)
|
||||
end
|
||||
|
||||
test_2048_reflexive
|
||||
local
|
||||
key_pair: RSA_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
cipher: INTEGER_X
|
||||
plain: INTEGER_X
|
||||
signature: INTEGER_X
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key_pair.make (2048)
|
||||
create message.make_random (128)
|
||||
cipher := key_pair.public.encrypt (message)
|
||||
plain := key_pair.private.decrypt (cipher)
|
||||
assert ("test 2048 reflexive 1", plain ~ message)
|
||||
signature := key_pair.private.sign (message)
|
||||
correct := key_pair.public.verify (message, signature)
|
||||
assert ("test 2048 reflexive 2", correct)
|
||||
end
|
||||
|
||||
test_4096_reflexive
|
||||
local
|
||||
key_pair: RSA_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
cipher: INTEGER_X
|
||||
plain: INTEGER_X
|
||||
signature: INTEGER_X
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key_pair.make (4096)
|
||||
create message.make_random (128)
|
||||
cipher := key_pair.public.encrypt (message)
|
||||
plain := key_pair.private.decrypt (cipher)
|
||||
assert ("test 4096 reflexive 1", plain ~ message)
|
||||
signature := key_pair.private.sign (message)
|
||||
correct := key_pair.public.verify (message, signature)
|
||||
assert ("test 4096 reflexive 2", correct)
|
||||
end
|
||||
end
|
||||
169
contrib/ise_library/text/encryption/eel/tests/sha1_test.e
Normal file
169
contrib/ise_library/text/encryption/eel/tests/sha1_test.e
Normal file
@@ -0,0 +1,169 @@
|
||||
note
|
||||
description: "Summary description for {SHA1_TEST}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
quote: "We must have government, but we must watch them like a hawk. - Millicent Fenwick (1983)"
|
||||
|
||||
class
|
||||
SHA1_TEST
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
|
||||
feature
|
||||
test_long
|
||||
local
|
||||
sha1: SHA1
|
||||
output: SPECIAL [NATURAL_8]
|
||||
solution: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
i: INTEGER
|
||||
do
|
||||
create sha1.make
|
||||
create output.make_filled (0, 20)
|
||||
create solution.make_filled (0, 20)
|
||||
solution [0] := 0x34
|
||||
solution [1] := 0xaa
|
||||
solution [2] := 0x97
|
||||
solution [3] := 0x3c
|
||||
solution [4] := 0xd4
|
||||
solution [5] := 0xc4
|
||||
solution [6] := 0xda
|
||||
solution [7] := 0xa4
|
||||
solution [8] := 0xf6
|
||||
solution [9] := 0x1e
|
||||
solution [10] := 0xeb
|
||||
solution [11] := 0x2b
|
||||
solution [12] := 0xdb
|
||||
solution [13] := 0xad
|
||||
solution [14] := 0x27
|
||||
solution [15] := 0x31
|
||||
solution [16] := 0x65
|
||||
solution [17] := 0x34
|
||||
solution [18] := 0x01
|
||||
solution [19] := 0x6f
|
||||
from
|
||||
i := 1
|
||||
until
|
||||
i > 1_000_000
|
||||
loop
|
||||
sha1.sink_character ('a')
|
||||
i := i + 1
|
||||
variant
|
||||
1_000_000 - i + 1
|
||||
end
|
||||
sha1.do_final (output, 0)
|
||||
correct := solution.same_items (output, 0, 0, 20)
|
||||
assert ("test long", correct)
|
||||
end
|
||||
|
||||
test_multi
|
||||
local
|
||||
sha1: SHA1
|
||||
output: SPECIAL [NATURAL_8]
|
||||
solution: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create sha1.make
|
||||
create output.make_filled (0, 20)
|
||||
create solution.make_filled (0, 20)
|
||||
solution [0] := 0x84
|
||||
solution [1] := 0x98
|
||||
solution [2] := 0x3e
|
||||
solution [3] := 0x44
|
||||
solution [4] := 0x1c
|
||||
solution [5] := 0x3b
|
||||
solution [6] := 0xd2
|
||||
solution [7] := 0x6e
|
||||
solution [8] := 0xba
|
||||
solution [9] := 0xae
|
||||
solution [10] := 0x4a
|
||||
solution [11] := 0xa1
|
||||
solution [12] := 0xf9
|
||||
solution [13] := 0x51
|
||||
solution [14] := 0x29
|
||||
solution [15] := 0xe5
|
||||
solution [16] := 0xe5
|
||||
solution [17] := 0x46
|
||||
solution [18] := 0x70
|
||||
solution [19] := 0xf1
|
||||
sha1.sink_string ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")
|
||||
sha1.do_final (output, 0)
|
||||
correct := solution.same_items (output, 0, 0, 20)
|
||||
assert ("test multi", correct)
|
||||
end
|
||||
|
||||
test_abc
|
||||
local
|
||||
sha1: SHA1
|
||||
output: SPECIAL [NATURAL_8]
|
||||
solution: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create sha1.make
|
||||
create output.make_filled (0, 20)
|
||||
create solution.make_filled (0, 20)
|
||||
solution [0] := 0xa9
|
||||
solution [1] := 0x99
|
||||
solution [2] := 0x3e
|
||||
solution [3] := 0x36
|
||||
solution [4] := 0x47
|
||||
solution [5] := 0x06
|
||||
solution [6] := 0x81
|
||||
solution [7] := 0x6a
|
||||
solution [8] := 0xba
|
||||
solution [9] := 0x3e
|
||||
solution [10] := 0x25
|
||||
solution [11] := 0x71
|
||||
solution [12] := 0x78
|
||||
solution [13] := 0x50
|
||||
solution [14] := 0xc2
|
||||
solution [15] := 0x6c
|
||||
solution [16] := 0x9c
|
||||
solution [17] := 0xd0
|
||||
solution [18] := 0xd8
|
||||
solution [19] := 0x9d
|
||||
sha1.update (('a').code.to_natural_8)
|
||||
sha1.update (('b').code.to_natural_8)
|
||||
sha1.update (('c').code.to_natural_8)
|
||||
sha1.do_final (output, 0)
|
||||
correct := solution.same_items (output, 0, 0, 20)
|
||||
assert ("test abc", correct)
|
||||
end
|
||||
|
||||
test_empty
|
||||
local
|
||||
sha1: SHA1
|
||||
output: SPECIAL [NATURAL_8]
|
||||
solution: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create sha1.make
|
||||
create output.make_filled (0, 20)
|
||||
create solution.make_filled (0, 20)
|
||||
solution [0] := 0xda
|
||||
solution [1] := 0x39
|
||||
solution [2] := 0xa3
|
||||
solution [3] := 0xee
|
||||
solution [4] := 0x5e
|
||||
solution [5] := 0x6b
|
||||
solution [6] := 0x4b
|
||||
solution [7] := 0x0d
|
||||
solution [8] := 0x32
|
||||
solution [9] := 0x55
|
||||
solution [10] := 0xbf
|
||||
solution [11] := 0xef
|
||||
solution [12] := 0x95
|
||||
solution [13] := 0x60
|
||||
solution [14] := 0x18
|
||||
solution [15] := 0x90
|
||||
solution [16] := 0xaf
|
||||
solution [17] := 0xd8
|
||||
solution [18] := 0x07
|
||||
solution [19] := 0x09
|
||||
sha1.do_final (output, 0)
|
||||
correct := solution.same_items (output, 0, 0, 20)
|
||||
assert ("test empty", correct)
|
||||
end
|
||||
end
|
||||
170
contrib/ise_library/text/encryption/eel/tests/sha256_test.e
Normal file
170
contrib/ise_library/text/encryption/eel/tests/sha256_test.e
Normal file
@@ -0,0 +1,170 @@
|
||||
note
|
||||
description: "Summary description for {SHA256_TEST}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
quote: "A little government and a little luck are necessary in life, but only a fool trusts either of them. - P. J. O'Rourke"
|
||||
|
||||
class
|
||||
SHA256_TEST
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
|
||||
feature
|
||||
test_long
|
||||
local
|
||||
sha256: SHA256
|
||||
output: SPECIAL [NATURAL_8]
|
||||
solution: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
i: INTEGER
|
||||
do
|
||||
create sha256.make
|
||||
create output.make_filled (0, 32)
|
||||
create solution.make_filled (0, 32)
|
||||
solution [0] := 0xcd
|
||||
solution [1] := 0xc7
|
||||
solution [2] := 0x6e
|
||||
solution [3] := 0x5c
|
||||
solution [4] := 0x99
|
||||
solution [5] := 0x14
|
||||
solution [6] := 0xfb
|
||||
solution [7] := 0x92
|
||||
solution [8] := 0x81
|
||||
solution [9] := 0xa1
|
||||
solution [10] := 0xc7
|
||||
solution [11] := 0xe2
|
||||
solution [12] := 0x84
|
||||
solution [13] := 0xd7
|
||||
solution [14] := 0x3e
|
||||
solution [15] := 0x67
|
||||
solution [16] := 0xf1
|
||||
solution [17] := 0x80
|
||||
solution [18] := 0x9a
|
||||
solution [19] := 0x48
|
||||
solution [20] := 0xa4
|
||||
solution [21] := 0x97
|
||||
solution [22] := 0x20
|
||||
solution [23] := 0x0e
|
||||
solution [24] := 0x04
|
||||
solution [25] := 0x6d
|
||||
solution [26] := 0x39
|
||||
solution [27] := 0xcc
|
||||
solution [28] := 0xc7
|
||||
solution [29] := 0x11
|
||||
solution [30] := 0x2c
|
||||
solution [31] := 0xd0
|
||||
from
|
||||
i := 1
|
||||
until
|
||||
i > 1_000_000
|
||||
loop
|
||||
sha256.sink_character ('a')
|
||||
i := i + 1
|
||||
variant
|
||||
1_000_000 - i + 1
|
||||
end
|
||||
sha256.do_final (output, 0)
|
||||
correct := solution.same_items (output, 0, 0, 32)
|
||||
assert ("test long", correct)
|
||||
end
|
||||
|
||||
test_multi
|
||||
local
|
||||
sha256: SHA256
|
||||
output: SPECIAL [NATURAL_8]
|
||||
solution: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create sha256.make
|
||||
create output.make_filled (0, 32)
|
||||
create solution.make_filled (0, 32)
|
||||
solution [0] := 0x24
|
||||
solution [1] := 0x8d
|
||||
solution [2] := 0x6a
|
||||
solution [3] := 0x61
|
||||
solution [4] := 0xd2
|
||||
solution [5] := 0x06
|
||||
solution [6] := 0x38
|
||||
solution [7] := 0xb8
|
||||
solution [8] := 0xe5
|
||||
solution [9] := 0xc0
|
||||
solution [10] := 0x26
|
||||
solution [11] := 0x93
|
||||
solution [12] := 0x0c
|
||||
solution [13] := 0x3e
|
||||
solution [14] := 0x60
|
||||
solution [15] := 0x39
|
||||
solution [16] := 0xa3
|
||||
solution [17] := 0x3c
|
||||
solution [18] := 0xe4
|
||||
solution [19] := 0x59
|
||||
solution [20] := 0x64
|
||||
solution [21] := 0xff
|
||||
solution [22] := 0x21
|
||||
solution [23] := 0x67
|
||||
solution [24] := 0xf6
|
||||
solution [25] := 0xec
|
||||
solution [26] := 0xed
|
||||
solution [27] := 0xd4
|
||||
solution [28] := 0x19
|
||||
solution [29] := 0xdb
|
||||
solution [30] := 0x06
|
||||
solution [31] := 0xc1
|
||||
sha256.sink_string ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")
|
||||
sha256.do_final (output, 0)
|
||||
correct := solution.same_items (output, 0, 0, 32)
|
||||
assert ("test multi", correct)
|
||||
end
|
||||
|
||||
test_abc
|
||||
local
|
||||
sha256: SHA256
|
||||
output: SPECIAL [NATURAL_8]
|
||||
solution: SPECIAL [NATURAL_8]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create sha256.make
|
||||
create output.make_filled (0, 32)
|
||||
create solution.make_filled (0, 32)
|
||||
solution [0] := 0xba
|
||||
solution [1] := 0x78
|
||||
solution [2] := 0x16
|
||||
solution [3] := 0xbf
|
||||
solution [4] := 0x8f
|
||||
solution [5] := 0x01
|
||||
solution [6] := 0xcf
|
||||
solution [7] := 0xea
|
||||
solution [8] := 0x41
|
||||
solution [9] := 0x41
|
||||
solution [10] := 0x40
|
||||
solution [11] := 0xde
|
||||
solution [12] := 0x5d
|
||||
solution [13] := 0xae
|
||||
solution [14] := 0x22
|
||||
solution [15] := 0x23
|
||||
solution [16] := 0xb0
|
||||
solution [17] := 0x03
|
||||
solution [18] := 0x61
|
||||
solution [19] := 0xa3
|
||||
solution [20] := 0x96
|
||||
solution [21] := 0x17
|
||||
solution [22] := 0x7a
|
||||
solution [23] := 0x9c
|
||||
solution [24] := 0xb4
|
||||
solution [25] := 0x10
|
||||
solution [26] := 0xff
|
||||
solution [27] := 0x61
|
||||
solution [28] := 0xf2
|
||||
solution [29] := 0x00
|
||||
solution [30] := 0x15
|
||||
solution [31] := 0xad
|
||||
sha256.update (('a').code.to_natural_8)
|
||||
sha256.update (('b').code.to_natural_8)
|
||||
sha256.update (('c').code.to_natural_8)
|
||||
sha256.do_final (output, 0)
|
||||
correct := solution.same_items (output, 0, 0, 32)
|
||||
assert ("test abc", correct)
|
||||
end
|
||||
end
|
||||
95
contrib/ise_library/text/encryption/eel/tests/test.e
Normal file
95
contrib/ise_library/text/encryption/eel/tests/test.e
Normal file
@@ -0,0 +1,95 @@
|
||||
note
|
||||
description : "tests application root class"
|
||||
date : "$Date: 2008-12-29 15:41:59 -0800 (Mon, 29 Dec 2008) $"
|
||||
revision : "$Revision: 76432 $"
|
||||
|
||||
class
|
||||
TEST
|
||||
|
||||
inherit
|
||||
ARGUMENTS
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
local
|
||||
key_pair: RSA_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
cipher: INTEGER_X
|
||||
plain: INTEGER_X
|
||||
signature: INTEGER_X
|
||||
correct: BOOLEAN
|
||||
do
|
||||
io.put_string ("Creating keypair%N")
|
||||
create key_pair.make (1024)
|
||||
io.put_string ("Created keypair%N")
|
||||
create message.make_random (128)
|
||||
cipher := key_pair.public.encrypt (message)
|
||||
plain := key_pair.private.decrypt (cipher)
|
||||
io.put_string ("Checked encryption%N")
|
||||
signature := key_pair.private.sign (message)
|
||||
correct := key_pair.public.verify (message, signature)
|
||||
io.put_string ("Checked signing%N")
|
||||
end
|
||||
|
||||
make_2
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
i: INTEGER
|
||||
do
|
||||
create key.make_sec_t113r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
from
|
||||
i := 0
|
||||
until
|
||||
i > 100
|
||||
loop
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
|
||||
test_sec_t_multiply
|
||||
local
|
||||
d: INTEGER_X
|
||||
g: EC_POINT_F2M
|
||||
curve: EC_CURVE_F2M
|
||||
q: EC_POINT_F2M
|
||||
q_x_solution: INTEGER_X
|
||||
q_y_solution: INTEGER_X
|
||||
q_solution: EC_POINT_F2M
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create d.make_from_hex_string ("00000003 A41434AA 99C2EF40 C8495B2E D9739CB2 155A1E0D")
|
||||
create g.make_sec_t163k1
|
||||
create curve.make_sec_t163k1
|
||||
create q_x_solution.make_from_hex_string ("00000003 7D529FA3 7E42195F 10111127 FFB2BB38 644806BC")
|
||||
create q_y_solution.make_from_hex_string ("00000004 47026EEE 8B34157F 3EB51BE5 185D2BE0 249ED776")
|
||||
create q_solution.make_curve_x_y (create {EC_FIELD_ELEMENT_F2M}.make (q_x_solution), create {EC_FIELD_ELEMENT_F2M}.make (q_y_solution))
|
||||
q := g.product_value (d, curve)
|
||||
correct := q ~ q_solution
|
||||
end
|
||||
|
||||
test1: detachable AES_TEST
|
||||
test2: detachable CBC_TEST
|
||||
test3: detachable CFB_TEST
|
||||
test4: detachable CTR_TEST
|
||||
test5: detachable DER_TEST
|
||||
test6: detachable ECB_TEST
|
||||
test7: detachable EC_TEST
|
||||
test8: detachable MD5_TEST
|
||||
test9: detachable OFB_TEST
|
||||
test10: detachable RSA_TEST
|
||||
test11: detachable SHA1_TEST
|
||||
test12: detachable SHA256_TEST
|
||||
test13: detachable TEST_EC_BINARY
|
||||
test14: detachable HMAC_SHA256_TEST
|
||||
|
||||
end
|
||||
194
contrib/ise_library/text/encryption/eel/tests/test.e.orig
Normal file
194
contrib/ise_library/text/encryption/eel/tests/test.e.orig
Normal file
@@ -0,0 +1,194 @@
|
||||
<<<<<<< local
|
||||
note
|
||||
description : "tests application root class"
|
||||
date : "$Date: 2008-12-29 15:41:59 -0800 (Mon, 29 Dec 2008) $"
|
||||
revision : "$Revision: 76432 $"
|
||||
|
||||
class
|
||||
TEST
|
||||
|
||||
inherit
|
||||
ARGUMENTS
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
local
|
||||
key_pair: RSA_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
cipher: INTEGER_X
|
||||
plain: INTEGER_X
|
||||
signature: INTEGER_X
|
||||
correct: BOOLEAN
|
||||
i: INTEGER
|
||||
do
|
||||
i := +1
|
||||
io.put_string ("Creating keypair%N")
|
||||
create key_pair.make (1024)
|
||||
io.put_string ("Created keypair%N")
|
||||
create message.make_random (128)
|
||||
cipher := key_pair.public.encrypt (message)
|
||||
plain := key_pair.private.decrypt (cipher)
|
||||
io.put_string ("Checked encryption%N")
|
||||
signature := key_pair.private.sign (message)
|
||||
correct := key_pair.public.verify (message, signature)
|
||||
io.put_string ("Checked signing%N")
|
||||
end
|
||||
|
||||
make_2
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
i: INTEGER
|
||||
do
|
||||
create key.make_sec_t113r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
from
|
||||
i := 0
|
||||
until
|
||||
i > 100
|
||||
loop
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
|
||||
test_sec_t_multiply
|
||||
local
|
||||
d: INTEGER_X
|
||||
g: EC_POINT_F2M
|
||||
curve: EC_CURVE_F2M
|
||||
q: EC_POINT_F2M
|
||||
q_x_solution: INTEGER_X
|
||||
q_y_solution: INTEGER_X
|
||||
q_solution: EC_POINT_F2M
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create d.make_from_hex_string ("00000003 A41434AA 99C2EF40 C8495B2E D9739CB2 155A1E0D")
|
||||
create g.make_sec_t163k1
|
||||
create curve.make_sec_t163k1
|
||||
create q_x_solution.make_from_hex_string ("00000003 7D529FA3 7E42195F 10111127 FFB2BB38 644806BC")
|
||||
create q_y_solution.make_from_hex_string ("00000004 47026EEE 8B34157F 3EB51BE5 185D2BE0 249ED776")
|
||||
create q_solution.make_curve_x_y (create {EC_FIELD_ELEMENT_F2M}.make (q_x_solution), create {EC_FIELD_ELEMENT_F2M}.make (q_y_solution))
|
||||
q := g.product_value (d, curve)
|
||||
correct := q ~ q_solution
|
||||
end
|
||||
|
||||
test1: detachable AES_TEST
|
||||
test2: detachable CBC_TEST
|
||||
test3: detachable CFB_TEST
|
||||
test4: detachable CTR_TEST
|
||||
test5: detachable DER_TEST
|
||||
test6: detachable ECB_TEST
|
||||
test7: detachable EC_TEST
|
||||
test8: detachable MD5_TEST
|
||||
test9: detachable OFB_TEST
|
||||
test10: detachable RSA_TEST
|
||||
test11: detachable SHA1_TEST
|
||||
test12: detachable SHA256_TEST
|
||||
test13: detachable TEST_EC_BINARY
|
||||
|
||||
end
|
||||
=======
|
||||
note
|
||||
description : "tests application root class"
|
||||
date : "$Date: 2008-12-29 15:41:59 -0800 (Mon, 29 Dec 2008) $"
|
||||
revision : "$Revision: 76432 $"
|
||||
|
||||
class
|
||||
TEST
|
||||
|
||||
inherit
|
||||
ARGUMENTS
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
local
|
||||
key_pair: RSA_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
cipher: INTEGER_X
|
||||
plain: INTEGER_X
|
||||
signature: INTEGER_X
|
||||
correct: BOOLEAN
|
||||
do
|
||||
io.put_string ("Creating keypair%N")
|
||||
create key_pair.make (1024)
|
||||
io.put_string ("Created keypair%N")
|
||||
create message.make_random (128)
|
||||
cipher := key_pair.public.encrypt (message)
|
||||
plain := key_pair.private.decrypt (cipher)
|
||||
io.put_string ("Checked encryption%N")
|
||||
signature := key_pair.private.sign (message)
|
||||
correct := key_pair.public.verify (message, signature)
|
||||
io.put_string ("Checked signing%N")
|
||||
end
|
||||
|
||||
make_2
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
i: INTEGER
|
||||
do
|
||||
create key.make_sec_t113r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
from
|
||||
i := 0
|
||||
until
|
||||
i > 100
|
||||
loop
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
|
||||
test_sec_t_multiply
|
||||
local
|
||||
d: INTEGER_X
|
||||
g: EC_POINT_F2M
|
||||
curve: EC_CURVE_F2M
|
||||
q: EC_POINT_F2M
|
||||
q_x_solution: INTEGER_X
|
||||
q_y_solution: INTEGER_X
|
||||
q_solution: EC_POINT_F2M
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create d.make_from_hex_string ("00000003 A41434AA 99C2EF40 C8495B2E D9739CB2 155A1E0D")
|
||||
create g.make_sec_t163k1
|
||||
create curve.make_sec_t163k1
|
||||
create q_x_solution.make_from_hex_string ("00000003 7D529FA3 7E42195F 10111127 FFB2BB38 644806BC")
|
||||
create q_y_solution.make_from_hex_string ("00000004 47026EEE 8B34157F 3EB51BE5 185D2BE0 249ED776")
|
||||
create q_solution.make_curve_x_y (create {EC_FIELD_ELEMENT_F2M}.make (q_x_solution), create {EC_FIELD_ELEMENT_F2M}.make (q_y_solution))
|
||||
q := g.product_value (d, curve)
|
||||
correct := q ~ q_solution
|
||||
end
|
||||
|
||||
test1: detachable AES_TEST
|
||||
test2: detachable CBC_TEST
|
||||
test3: detachable CFB_TEST
|
||||
test4: detachable CTR_TEST
|
||||
test5: detachable DER_TEST
|
||||
test6: detachable ECB_TEST
|
||||
test7: detachable EC_TEST
|
||||
test8: detachable MD5_TEST
|
||||
test9: detachable OFB_TEST
|
||||
test10: detachable RSA_TEST
|
||||
test11: detachable SHA1_TEST
|
||||
test12: detachable SHA256_TEST
|
||||
test13: detachable TEST_EC_BINARY
|
||||
test14: detachable HMAC_SHA256_TEST
|
||||
|
||||
end
|
||||
>>>>>>> other
|
||||
493
contrib/ise_library/text/encryption/eel/tests/test_ec_binary.e
Normal file
493
contrib/ise_library/text/encryption/eel/tests/test_ec_binary.e
Normal file
@@ -0,0 +1,493 @@
|
||||
note
|
||||
description: "Summary description for {TEST_EC_BINARY}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
TEST_EC_BINARY
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
|
||||
feature -- Binary math
|
||||
|
||||
test_sec_t_multiply
|
||||
local
|
||||
d: INTEGER_X
|
||||
g: EC_POINT_F2M
|
||||
curve: EC_CURVE_F2M
|
||||
q: EC_POINT_F2M
|
||||
q_x_solution: INTEGER_X
|
||||
q_y_solution: INTEGER_X
|
||||
q_solution: EC_POINT_F2M
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create d.make_from_hex_string ("00000003 A41434AA 99C2EF40 C8495B2E D9739CB2 155A1E0D")
|
||||
create g.make_sec_t163k1
|
||||
create curve.make_sec_t163k1
|
||||
create q_x_solution.make_from_hex_string ("00000003 7D529FA3 7E42195F 10111127 FFB2BB38 644806BC")
|
||||
create q_y_solution.make_from_hex_string ("00000004 47026EEE 8B34157F 3EB51BE5 185D2BE0 249ED776")
|
||||
create q_solution.make_curve_x_y (create {EC_FIELD_ELEMENT_F2M}.make (q_x_solution), create {EC_FIELD_ELEMENT_F2M}.make (q_y_solution))
|
||||
q := g.product_value (d, curve)
|
||||
correct := q ~ q_solution
|
||||
assert ("test sec t multiply", correct)
|
||||
end
|
||||
|
||||
test_sec_t_sign
|
||||
local
|
||||
d: INTEGER_X
|
||||
k: INTEGER_X
|
||||
e: INTEGER_X
|
||||
r_x_solution: INTEGER_X
|
||||
r_y_solution: INTEGER_X
|
||||
r_solution: EC_POINT_F2M
|
||||
curve: EC_CURVE_F2M
|
||||
r: INTEGER_X
|
||||
s: INTEGER_X
|
||||
s_solution: INTEGER_X
|
||||
r_point: EC_POINT_F2M
|
||||
r_int_solution: INTEGER_X
|
||||
correct: BOOLEAN
|
||||
g: EC_POINT_F2M
|
||||
do
|
||||
create curve.make_sec_t163k1
|
||||
create g.make_sec_t163k1
|
||||
create d.make_from_hex_string ("00000003 A41434AA 99C2EF40 C8495B2E D9739CB2 155A1E0D")
|
||||
create k.make_from_string ("936523985789236956265265265235675811949404040044")
|
||||
create r_x_solution.make_from_hex_string ("00000004 994D2C41 AA30E529 52B0A94E C6511328 C502DA9B")
|
||||
create r_y_solution.make_from_hex_string ("00000003 1FC936D7 3163B858 BBC5326D 77C19839 46405264")
|
||||
create e.make_from_hex_string ("A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D")
|
||||
create r_int_solution.make_from_hex_string ("994D2C41 AA30E529 52AEA846 2370471B 2B0A34AC")
|
||||
create s_solution.make_from_hex_string ("00000001 52F95CA1 5DA1997A 8C449E00 CD2AA2AC CB988D7F")
|
||||
create r_solution.make_curve_x_y (create {EC_FIELD_ELEMENT_F2M}.make (r_x_solution), create {EC_FIELD_ELEMENT_F2M}.make (r_y_solution))
|
||||
r_point := g.product_value (k, curve)
|
||||
correct := r_point ~ r_solution
|
||||
assert ("test set t sign 1", correct)
|
||||
r := r_point.x.x \\ curve.n
|
||||
correct := r_int_solution ~ r
|
||||
assert ("test set t sign 2", correct)
|
||||
s := (k.inverse_value (curve.n) * (r * d + e)) \\ curve.n
|
||||
correct := s ~ s_solution
|
||||
assert ("test set t sign 3", correct)
|
||||
end
|
||||
|
||||
test_sec_t_verify
|
||||
local
|
||||
q: EC_POINT_F2M
|
||||
d: INTEGER_X
|
||||
curve: EC_CURVE_F2M
|
||||
e: INTEGER_X
|
||||
r: INTEGER_X
|
||||
s: INTEGER_X
|
||||
u1: INTEGER_X
|
||||
u2: INTEGER_X
|
||||
u1_solution: INTEGER_X
|
||||
u2_solution: INTEGER_X
|
||||
correct: BOOLEAN
|
||||
u1g: EC_POINT_F2M
|
||||
u1g_solution: EC_POINT_F2M
|
||||
u1g_x: INTEGER_X
|
||||
u1g_y: INTEGER_X
|
||||
u2q: EC_POINT_F2M
|
||||
u2q_solution: EC_POINT_F2M
|
||||
u2q_x: INTEGER_X
|
||||
u2q_y: INTEGER_X
|
||||
r_x: INTEGER_X
|
||||
r_y: INTEGER_X
|
||||
r_solution: EC_POINT_F2M
|
||||
r_point: EC_POINT_F2M
|
||||
g: EC_POINT_F2M
|
||||
v: INTEGER_X
|
||||
do
|
||||
create curve.make_sec_t163k1
|
||||
create d.make_from_hex_string ("00000003 A41434AA 99C2EF40 C8495B2E D9739CB2 155A1E0D")
|
||||
create r.make_from_hex_string ("994D2C41 AA30E529 52AEA846 2370471B 2B0A34AC")
|
||||
create s.make_from_hex_string ("00000001 52F95CA1 5DA1997A 8C449E00 CD2AA2AC CB988D7F")
|
||||
create e.make_from_hex_string ("A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D")
|
||||
create u1_solution.make_from_string ("5658067548292182333034494350975093404971930311298")
|
||||
create u2_solution.make_from_string ("2390570840421010673757367220187439778211658217319")
|
||||
create u1g_x.make_from_hex_string ("00000005 1B4B9235 90399545 34D77469 AC7434D7 45BE784D")
|
||||
create u1g_y.make_from_hex_string ("00000001 C657D070 935987CA 79976B31 6ED2F533 41058956")
|
||||
create u2q_x.make_from_hex_string ("07FD04AF 05DCAF73 39F6F89C 52EF27FE 94699AED")
|
||||
create u2q_y.make_from_hex_string ("AA84BE48 C0F1256F A31AAADD F4ADDDD5 AD1F0E14")
|
||||
create r_x.make_from_hex_string ("00000004 994D2C41 AA30E529 52B0A94E C6511328 C502DA9B")
|
||||
create r_y.make_from_hex_string ("00000003 1FC936D7 3163B858 BBC5326D 77C19839 46405264")
|
||||
create u1g_solution.make_curve_x_y (create {EC_FIELD_ELEMENT_F2M}.make (u1g_x), create {EC_FIELD_ELEMENT_F2M}.make (u1g_y))
|
||||
create u2q_solution.make_curve_x_y (create {EC_FIELD_ELEMENT_F2M}.make (u2q_x), create {EC_FIELD_ELEMENT_F2M}.make (u2q_y))
|
||||
create r_solution.make_curve_x_y (create {EC_FIELD_ELEMENT_F2M}.make (r_x), create {EC_FIELD_ELEMENT_F2M}.make (r_y))
|
||||
create g.make_sec_t163k1
|
||||
q := g.product_value (d, curve)
|
||||
u1 := (e * s.inverse_value (curve.n) \\ curve.n)
|
||||
u2 := (r * s.inverse_value (curve.n) \\ curve.n)
|
||||
correct := u1 ~ u1_solution
|
||||
assert ("test sec t verify 1", correct)
|
||||
correct := u2 ~ u2_solution
|
||||
assert ("test sec t verify 2", correct)
|
||||
u1g := g.product_value (u1, curve)
|
||||
correct := u1g ~ u1g_solution
|
||||
assert ("test sec t verify 3", correct)
|
||||
u2q := q.product_value (u2, curve)
|
||||
correct := u2q ~ u2q_solution
|
||||
assert ("test sec t verify 4", correct)
|
||||
r_point := u1g.plus_value (u2q, curve)
|
||||
correct := r_point ~ r_solution
|
||||
v := r_point.x.x \\ curve.n
|
||||
correct := v ~ r
|
||||
assert ("test sec t verify 5", correct)
|
||||
end
|
||||
feature --Polynomial reflexive tests
|
||||
test_sec_t113r1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_t113r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec t113r1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_t113r2_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_t113r2
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec t113r2 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_t131r1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_t131r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec t131r1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_t131r2_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_t131r2
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec t131r2 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_t163k1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_t163k1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec t163k1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_t163r1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_t163r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec t163r1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_t163r2_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_t163r2
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec t163r2 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_t193r1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_t193r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec t193r1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_t193r2_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_t193r2
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec t193r2 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_t233k1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_t233k1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec t233k1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_t233r1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_t233r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec t233r1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_t239k1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_t239k1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec t239k1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_t283k1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_t283k1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec t283k1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_t283r1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_t283r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec t283r1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_t409k1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_t409k1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec t409k1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_t409r1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_t409r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec t409r1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_t571k1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_t571k1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec t571k1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_sec_t571r1_reflexive
|
||||
local
|
||||
key: EC_KEY_PAIR
|
||||
message: INTEGER_X
|
||||
signature: TUPLE [r: INTEGER_X s: INTEGER_X]
|
||||
correct: BOOLEAN
|
||||
do
|
||||
create key.make_sec_t571r1
|
||||
create message.make_random_max (key.private.params.n)
|
||||
signature := key.private.sign (message)
|
||||
correct := key.public.verify (message, signature)
|
||||
assert ("test sec t571r1 reflexive", correct)
|
||||
end
|
||||
|
||||
test_reduce_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
a: INTEGER_X
|
||||
b: INTEGER_X
|
||||
n: INTEGER_X
|
||||
curve: EC_CURVE_F2M
|
||||
element: EC_FIELD_ELEMENT_F2M
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create expected.make_from_hex_string ("13b6c2e54bb8c935c13fab54639da")
|
||||
create one.make_from_hex_string ("54505401551104100555400451414110050100000151441011150550")
|
||||
create a.make_from_hex_string ("3088250ca6e7c7fe649ce85820f7")
|
||||
create b.make_from_hex_string ("e8bee4d3e2260744188be0e9c723")
|
||||
create n.make_from_hex_string ("100000000000000d9ccec8a39e56f")
|
||||
create curve.make (0x71, 9, 0, 0, a, b, n)
|
||||
create element.make (one)
|
||||
element.reduce (one, curve)
|
||||
assert ("test reduce 1", one ~ expected)
|
||||
end
|
||||
|
||||
test_square_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
a: INTEGER_X
|
||||
b: INTEGER_X
|
||||
n: INTEGER_X
|
||||
curve: EC_CURVE_F2M
|
||||
element: EC_FIELD_ELEMENT_F2M
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create one.make_from_hex_string ("ece1f5243f82d99431001da4573c")
|
||||
create expected.make_from_hex_string ("13b6c2e54bb8c935c13fab54639da")
|
||||
create a.make_from_hex_string ("3088250ca6e7c7fe649ce85820f7")
|
||||
create b.make_from_hex_string ("e8bee4d3e2260744188be0e9c723")
|
||||
create n.make_from_hex_string ("100000000000000d9ccec8a39e56f")
|
||||
create curve.make (0x71, 9, 0, 0, a, b, n)
|
||||
create element.make (one)
|
||||
element.square (curve)
|
||||
assert ("test square 1", element.x ~ expected)
|
||||
end
|
||||
|
||||
test_square_2
|
||||
local
|
||||
parameters: EC_DOMAIN_PARAMETERS_F2M
|
||||
one: INTEGER_X
|
||||
element: EC_FIELD_ELEMENT_F2M
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create one.make_from_hex_string ("3 ffffffff ffffffff ffffffff ffffffff")
|
||||
create expected.make_from_hex_string ("aaaaaaaaaaaaaaaaaaaaaaaaaaaabfee")
|
||||
create parameters.make_sec_t131r1
|
||||
create element.make (one)
|
||||
element.square (parameters.curve)
|
||||
assert ("test square 2", element.x ~ expected)
|
||||
end
|
||||
|
||||
test_square_3
|
||||
local
|
||||
parameters: EC_DOMAIN_PARAMETERS_F2M
|
||||
one: INTEGER_X
|
||||
element: EC_FIELD_ELEMENT_F2M
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create parameters.make_sec_t131r1
|
||||
create one.make_from_hex_string ("b11acac3b1c28415a4e733010375a5b8")
|
||||
create expected.make_from_hex_string ("18b11dd51ffe1f2aeef0ec79fae0b67f7")
|
||||
create element.make (one)
|
||||
element.square (parameters.curve)
|
||||
assert ("test square 3", element.x ~ expected)
|
||||
end
|
||||
|
||||
test_product_1
|
||||
local
|
||||
curve: EC_CURVE_F2M
|
||||
one: EC_POINT_F2M
|
||||
expected: EC_POINT_F2M
|
||||
multiplicand: INTEGER_X
|
||||
do
|
||||
create one.make_curve_x_y (create {INTEGER_X}.make_from_hex_string ("9d73616f35f4ab1407d73562c10f"), create {INTEGER_X}.make_from_hex_string ("a52830277958ee84d1315ed31886"))
|
||||
create expected.make_curve_x_y (create {INTEGER_X}.make_from_hex_string ("1a42d8acf7568670dfd067fde38ff"), create {INTEGER_X}.make_from_hex_string ("11747870124d247a94b527a2fbc2e"))
|
||||
create multiplicand.make_from_hex_string ("a077518c809013ae8ec6baecd515")
|
||||
create curve.make (0x71, 9, 0, 0, create {INTEGER_X}.make_from_hex_string ("3088250ca6e7c7fe649ce85820f7"), create {INTEGER_X}.make_from_hex_string ("e8bee4d3e2260744188be0e9c723"), create {INTEGER_X}.make_from_hex_string ("100000000000000d9ccec8a39e56f"))
|
||||
one.product (multiplicand, curve)
|
||||
assert ("test product 1", one ~ expected)
|
||||
end
|
||||
|
||||
test_product_2
|
||||
local
|
||||
curve: EC_CURVE_F2M
|
||||
one: EC_FIELD_ELEMENT_F2M
|
||||
expected: EC_FIELD_ELEMENT_F2M
|
||||
multiplicand: INTEGER_X
|
||||
do
|
||||
create one.make (create {INTEGER_X}.make_from_hex_string ("a52830277958ee84d1315ed31886"))
|
||||
create multiplicand.make_from_hex_string ("fa499cd55090de5385193e34792c")
|
||||
create expected.make (create {INTEGER_X}.make_from_hex_string ("7192944b0a76728036d728c69633"))
|
||||
create curve.make (0x71, 9, 0, 0, create {INTEGER_X}.make_from_hex_string ("3088250ca6e7c7fe649ce85820f7"), create {INTEGER_X}.make_from_hex_string ("e8bee4d3e2260744188be0e9c723"), create {INTEGER_X}.make_from_hex_string ("100000000000000d9ccec8a39e56f"))
|
||||
one.product (multiplicand, curve)
|
||||
assert ("test product 2", one ~ expected)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
note
|
||||
description: "Summary description for {TEST_EC_FIELD_ELEMENT_F2M}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
TEST_EC_FIELD_ELEMENT_F2M
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
|
||||
feature
|
||||
end
|
||||
30
contrib/ise_library/text/encryption/eel/tests/tests-safe.ecf
Normal file
30
contrib/ise_library/text/encryption/eel/tests/tests-safe.ecf
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-6-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-6-0 http://www.eiffel.com/developers/xml/configuration-1-6-0.xsd" name="tests" uuid="73782579-06F8-4FFA-937C-47F830EA38F3">
|
||||
<target name="tests">
|
||||
<root class="TEST" feature="make"/>
|
||||
<option profile="false" warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="standard">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<variable name="eapml_scan_type" value="vc"/>
|
||||
<variable name="eapml_limb_type" value="natural_32"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="eapml" location="..\..\eapml\eapml-safe.ecf"/>
|
||||
<library name="eel" location="..\eel-safe.ecf" readonly="false">
|
||||
<option>
|
||||
<assertions precondition="true"/>
|
||||
</option>
|
||||
</library>
|
||||
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
|
||||
<cluster name="tests" location=".\" recursive="true">
|
||||
<option>
|
||||
<assertions precondition="true"/>
|
||||
</option>
|
||||
<file_rule>
|
||||
<exclude>/.hg$</exclude>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
</system>
|
||||
30
contrib/ise_library/text/encryption/eel/tests/tests.ecf
Normal file
30
contrib/ise_library/text/encryption/eel/tests/tests.ecf
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-6-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-6-0 http://www.eiffel.com/developers/xml/configuration-1-6-0.xsd" name="tests" uuid="73782579-06F8-4FFA-937C-47F830EA38F3">
|
||||
<target name="tests">
|
||||
<root class="TEST" feature="make"/>
|
||||
<option profile="false" warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="none" syntax="standard">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<variable name="eapml_scan_type" value="gcc"/>
|
||||
<variable name="eapml_limb_type" value="natural_32"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="eapml" location="..\..\eapml\eapml.ecf"/>
|
||||
<library name="eel" location="..\eel.ecf" readonly="false">
|
||||
<option>
|
||||
<assertions precondition="true"/>
|
||||
</option>
|
||||
</library>
|
||||
<library name="testing" location="$ISE_LIBRARY\library\testing\testing.ecf"/>
|
||||
<cluster name="tests" location=".\" recursive="true">
|
||||
<option>
|
||||
<assertions precondition="true"/>
|
||||
</option>
|
||||
<file_rule>
|
||||
<exclude>/.svn$</exclude>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.hg$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
</system>
|
||||
1
contrib/ise_library/text/encryption/eel/tests/tests.rc
Normal file
1
contrib/ise_library/text/encryption/eel/tests/tests.rc
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user