From b967e761616ea0568cb89a54efcf55335d86d65d Mon Sep 17 00:00:00 2001 From: "rrelyea%redhat.com" Date: Thu, 11 Oct 2012 00:34:33 +0000 Subject: [PATCH] Bug 373108 - Implement AES Galois Counter Mode (GCM) r=wtc,emaldona git-svn-id: svn://10.0.0.236/trunk@264319 18797224-902f-48f8-a5cc-f745e15eee43 --- .../tests/aes_cts/aes-cts-type-1-vectors.txt | 47 ++++++++++++++++++ .../cmd/bltest/tests/aes_cts/aes_cts_0.txt | 6 +++ .../cmd/bltest/tests/aes_cts/aes_cts_1.txt | 6 +++ .../cmd/bltest/tests/aes_cts/aes_cts_2.txt | 6 +++ .../cmd/bltest/tests/aes_cts/aes_cts_3.txt | 6 +++ .../cmd/bltest/tests/aes_cts/aes_cts_4.txt | 6 +++ .../cmd/bltest/tests/aes_cts/aes_cts_5.txt | 6 +++ .../nss/cmd/bltest/tests/aes_cts/ciphertext0 | 1 + .../nss/cmd/bltest/tests/aes_cts/ciphertext1 | 1 + .../nss/cmd/bltest/tests/aes_cts/ciphertext2 | 1 + .../nss/cmd/bltest/tests/aes_cts/ciphertext3 | 1 + .../nss/cmd/bltest/tests/aes_cts/ciphertext4 | 1 + .../nss/cmd/bltest/tests/aes_cts/ciphertext5 | 2 + .../security/nss/cmd/bltest/tests/aes_cts/iv0 | Bin 0 -> 34 bytes .../security/nss/cmd/bltest/tests/aes_cts/iv1 | Bin 0 -> 34 bytes .../security/nss/cmd/bltest/tests/aes_cts/iv2 | Bin 0 -> 34 bytes .../security/nss/cmd/bltest/tests/aes_cts/iv3 | Bin 0 -> 34 bytes .../security/nss/cmd/bltest/tests/aes_cts/iv4 | Bin 0 -> 34 bytes .../security/nss/cmd/bltest/tests/aes_cts/iv5 | Bin 0 -> 34 bytes .../nss/cmd/bltest/tests/aes_cts/key0 | 1 + .../nss/cmd/bltest/tests/aes_cts/key1 | 1 + .../nss/cmd/bltest/tests/aes_cts/key2 | 1 + .../nss/cmd/bltest/tests/aes_cts/key3 | 1 + .../nss/cmd/bltest/tests/aes_cts/key4 | 1 + .../nss/cmd/bltest/tests/aes_cts/key5 | 1 + .../nss/cmd/bltest/tests/aes_cts/mktst.sh | 9 ++++ .../nss/cmd/bltest/tests/aes_cts/numtests | 1 + .../nss/cmd/bltest/tests/aes_cts/plaintext0 | 1 + .../nss/cmd/bltest/tests/aes_cts/plaintext1 | 1 + .../nss/cmd/bltest/tests/aes_cts/plaintext2 | 1 + .../nss/cmd/bltest/tests/aes_cts/plaintext3 | 1 + .../nss/cmd/bltest/tests/aes_cts/plaintext4 | 1 + .../nss/cmd/bltest/tests/aes_cts/plaintext5 | 1 + mozilla/security/nss/lib/freebl/cts.c | 18 +++---- 34 files changed, 120 insertions(+), 10 deletions(-) create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/aes-cts-type-1-vectors.txt create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_0.txt create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_1.txt create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_2.txt create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_3.txt create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_4.txt create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_5.txt create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext0 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext1 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext2 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext3 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext4 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext5 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/iv0 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/iv1 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/iv2 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/iv3 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/iv4 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/iv5 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/key0 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/key1 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/key2 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/key3 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/key4 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/key5 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/mktst.sh create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/numtests create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext0 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext1 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext2 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext3 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext4 create mode 100644 mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext5 diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes-cts-type-1-vectors.txt b/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes-cts-type-1-vectors.txt new file mode 100644 index 00000000000..b107586769a --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes-cts-type-1-vectors.txt @@ -0,0 +1,47 @@ +# Raeburn Standards Track [Page 12] +# +# RFC 3962 AES Encryption for Kerberos 5 February 2005 +# +# Some test vectors for CBC with ciphertext stealing, using an initial +# vector of all-zero. +# +# Original Test vectors were for AES CTS-3 (Kerberos). These test vectors have been modified for AES CTS-1 (NIST) +# + +Key: 63 68 69 63 6b 65 6e 20 74 65 72 69 79 61 6b 69 +IV: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +Input: 49 20 77 6f 75 6c 64 20 6c 69 6b 65 20 74 68 65 20 +Output: 97 c6 35 35 68 f2 bf 8c b4 d8 a5 80 36 2d a7 ff 7f +Next IV: c6 35 35 68 f2 bf 8c b4 d8 a5 80 36 2d a7 ff 7f + +Key: 63 68 69 63 6b 65 6e 20 74 65 72 69 79 61 6b 69 +IV: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +Input: 49 20 77 6f 75 6c 64 20 6c 69 6b 65 20 74 68 65 20 47 65 6e 65 72 61 6c 20 47 61 75 27 73 20 +Output: 97 68 72 68 d6 ec cc c0 c0 7b 25 e2 5e cf e5 fc 00 78 3e 0e fd b2 c1 d4 45 d4 c8 ef f7 ed 22 +Next IV: fc 00 78 3e 0e fd b2 c1 d4 45 d4 c8 ef f7 ed 22 + +Key: 63 68 69 63 6b 65 6e 20 74 65 72 69 79 61 6b 69 +IV: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +Input: 49 20 77 6f 75 6c 64 20 6c 69 6b 65 20 74 68 65 20 47 65 6e 65 72 61 6c 20 47 61 75 27 73 20 43 +Output: 97 68 72 68 d6 ec cc c0 c0 7b 25 e2 5e cf e5 84 39 31 25 23 a7 86 62 d5 be 7f cb cc 98 eb f5 a8 +Next IV: 39 31 25 23 a7 86 62 d5 be 7f cb cc 98 eb f5 a8 + +Key: 63 68 69 63 6b 65 6e 20 74 65 72 69 79 61 6b 69 +IV: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +Input: 49 20 77 6f 75 6c 64 20 6c 69 6b 65 20 74 68 65 20 47 65 6e 65 72 61 6c 20 47 61 75 27 73 20 43 68 69 63 6b 65 6e 2c 20 70 6c 65 61 73 65 2c +Output: 97 68 72 68 d6 ec cc c0 c0 7b 25 e2 5e cf e5 84 39 31 25 23 a7 86 62 d5 be 7f cb cc 98 eb f5 b3 ff fd 94 0c 16 a1 8c 1b 55 49 d2 f8 38 02 9e +Next IV: b3 ff fd 94 0c 16 a1 8c 1b 55 49 d2 f8 38 02 9e + +Key: 63 68 69 63 6b 65 6e 20 74 65 72 69 79 61 6b 69 +IV: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +Input: 49 20 77 6f 75 6c 64 20 6c 69 6b 65 20 74 68 65 20 47 65 6e 65 72 61 6c 20 47 61 75 27 73 20 43 68 69 63 6b 65 6e 2c 20 70 6c 65 61 73 65 2c 20 +Output: 97 68 72 68 d6 ec cc c0 c0 7b 25 e2 5e cf e5 84 39 31 25 23 a7 86 62 d5 be 7f cb cc 98 eb f5 a8 9d ad 8b bb 96 c4 cd c0 3b c1 03 e1 a1 94 bb d8 +Next IV: 9d ad 8b bb 96 c4 cd c0 3b c1 03 e1 a1 94 bb d8 + +Key: 63 68 69 63 6b 65 6e 20 74 65 72 69 79 61 6b 69 +IV: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +Input: 49 20 77 6f 75 6c 64 20 6c 69 6b 65 20 74 68 65 20 47 65 6e 65 72 61 6c 20 47 61 75 27 73 20 43 68 69 63 6b 65 6e 2c 20 70 6c 65 61 73 65 2c 20 61 6e 64 20 77 6f 6e 74 6f 6e 20 73 6f 75 70 2e +Output: 97 68 72 68 d6 ec cc c0 c0 7b 25 e2 5e cf e5 84 39 31 25 23 a7 86 62 d5 be 7f cb cc 98 eb f5 a8 9d ad 8b bb 96 c4 cd c0 3b c1 03 e1 a1 94 bb d8 48 07 ef e8 36 ee 89 a5 26 73 0d bc 2f 7b c8 40 +Next IV: 48 07 ef e8 36 ee 89 a5 26 73 0d bc 2f 7b c8 40 + + diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_0.txt b/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_0.txt new file mode 100644 index 00000000000..fa28439b318 --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_0.txt @@ -0,0 +1,6 @@ +Key: 63 68 69 63 6b 65 6e 20 74 65 72 69 79 61 6b 69 +IV: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +Input: 49 20 77 6f 75 6c 64 20 6c 69 6b 65 20 74 68 65 20 +Output: 97 c6 35 35 68 f2 bf 8c b4 d8 a5 80 36 2d a7 ff 7f +Next IV: c6 35 35 68 f2 bf 8c b4 d8 a5 80 36 2d a7 ff 7f + diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_1.txt b/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_1.txt new file mode 100644 index 00000000000..dae97358a78 --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_1.txt @@ -0,0 +1,6 @@ +Key: 63 68 69 63 6b 65 6e 20 74 65 72 69 79 61 6b 69 +IV: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +Input: 49 20 77 6f 75 6c 64 20 6c 69 6b 65 20 74 68 65 20 47 65 6e 65 72 61 6c 20 47 61 75 27 73 20 +Output: 97 68 72 68 d6 ec cc c0 c0 7b 25 e2 5e cf e5 fc 00 78 3e 0e fd b2 c1 d4 45 d4 c8 ef f7 ed 22 +Next IV: fc 00 78 3e 0e fd b2 c1 d4 45 d4 c8 ef f7 ed 22 + diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_2.txt b/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_2.txt new file mode 100644 index 00000000000..df892892e2d --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_2.txt @@ -0,0 +1,6 @@ +Key: 63 68 69 63 6b 65 6e 20 74 65 72 69 79 61 6b 69 +IV: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +Input: 49 20 77 6f 75 6c 64 20 6c 69 6b 65 20 74 68 65 20 47 65 6e 65 72 61 6c 20 47 61 75 27 73 20 43 +Output: 97 68 72 68 d6 ec cc c0 c0 7b 25 e2 5e cf e5 84 39 31 25 23 a7 86 62 d5 be 7f cb cc 98 eb f5 a8 +Next IV: 39 31 25 23 a7 86 62 d5 be 7f cb cc 98 eb f5 a8 + diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_3.txt b/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_3.txt new file mode 100644 index 00000000000..11e68e0c887 --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_3.txt @@ -0,0 +1,6 @@ +Key: 63 68 69 63 6b 65 6e 20 74 65 72 69 79 61 6b 69 +IV: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +Input: 49 20 77 6f 75 6c 64 20 6c 69 6b 65 20 74 68 65 20 47 65 6e 65 72 61 6c 20 47 61 75 27 73 20 43 68 69 63 6b 65 6e 2c 20 70 6c 65 61 73 65 2c +Output: 97 68 72 68 d6 ec cc c0 c0 7b 25 e2 5e cf e5 84 39 31 25 23 a7 86 62 d5 be 7f cb cc 98 eb f5 b3 ff fd 94 0c 16 a1 8c 1b 55 49 d2 f8 38 02 9e +Next IV: b3 ff fd 94 0c 16 a1 8c 1b 55 49 d2 f8 38 02 9e + diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_4.txt b/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_4.txt new file mode 100644 index 00000000000..b5dc5ae3fdf --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_4.txt @@ -0,0 +1,6 @@ +Key: 63 68 69 63 6b 65 6e 20 74 65 72 69 79 61 6b 69 +IV: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +Input: 49 20 77 6f 75 6c 64 20 6c 69 6b 65 20 74 68 65 20 47 65 6e 65 72 61 6c 20 47 61 75 27 73 20 43 68 69 63 6b 65 6e 2c 20 70 6c 65 61 73 65 2c 20 +Output: 97 68 72 68 d6 ec cc c0 c0 7b 25 e2 5e cf e5 84 39 31 25 23 a7 86 62 d5 be 7f cb cc 98 eb f5 a8 9d ad 8b bb 96 c4 cd c0 3b c1 03 e1 a1 94 bb d8 +Next IV: 9d ad 8b bb 96 c4 cd c0 3b c1 03 e1 a1 94 bb d8 + diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_5.txt b/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_5.txt new file mode 100644 index 00000000000..db837f92721 --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/aes_cts_5.txt @@ -0,0 +1,6 @@ +Key: 63 68 69 63 6b 65 6e 20 74 65 72 69 79 61 6b 69 +IV: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +Input: 49 20 77 6f 75 6c 64 20 6c 69 6b 65 20 74 68 65 20 47 65 6e 65 72 61 6c 20 47 61 75 27 73 20 43 68 69 63 6b 65 6e 2c 20 70 6c 65 61 73 65 2c 20 61 6e 64 20 77 6f 6e 74 6f 6e 20 73 6f 75 70 2e +Output: 97 68 72 68 d6 ec cc c0 c0 7b 25 e2 5e cf e5 84 39 31 25 23 a7 86 62 d5 be 7f cb cc 98 eb f5 a8 9d ad 8b bb 96 c4 cd c0 3b c1 03 e1 a1 94 bb d8 48 07 ef e8 36 ee 89 a5 26 73 0d bc 2f 7b c8 40 +Next IV: 48 07 ef e8 36 ee 89 a5 26 73 0d bc 2f 7b c8 40 + diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext0 b/mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext0 new file mode 100644 index 00000000000..bcfdc10da65 --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext0 @@ -0,0 +1 @@ +l8Y1NWjyv4y02KWANi2n/38= diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext1 b/mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext1 new file mode 100644 index 00000000000..66560807c9c --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext1 @@ -0,0 +1 @@ +l2hyaNbszMDAeyXiXs/l/AB4Pg79ssHURdTI7/ftIg== diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext2 b/mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext2 new file mode 100644 index 00000000000..336d705c97c --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext2 @@ -0,0 +1 @@ +l2hyaNbszMDAeyXiXs/lhDkxJSOnhmLVvn/LzJjr9ag= diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext3 b/mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext3 new file mode 100644 index 00000000000..7c53d4002af --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext3 @@ -0,0 +1 @@ +l2hyaNbszMDAeyXiXs/lhDkxJSOnhmLVvn/LzJjr9bP//ZQMFqGMG1VJ0vg4Ap4= diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext4 b/mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext4 new file mode 100644 index 00000000000..ef31331c853 --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext4 @@ -0,0 +1 @@ +l2hyaNbszMDAeyXiXs/lhDkxJSOnhmLVvn/LzJjr9aidrYu7lsTNwDvBA+GhlLvY diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext5 b/mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext5 new file mode 100644 index 00000000000..0ead1433714 --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/ciphertext5 @@ -0,0 +1,2 @@ +l2hyaNbszMDAeyXiXs/lhDkxJSOnhmLVvn/LzJjr9aidrYu7lsTNwDvBA+GhlLvY +SAfv6DbuiaUmcw28L3vIQA== diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/iv0 b/mozilla/security/nss/cmd/bltest/tests/aes_cts/iv0 new file mode 100644 index 0000000000000000000000000000000000000000..4bdfab8333086af48b9ece6d1f9db9aa9a07cdff GIT binary patch literal 34 dcmZQzKm~jZ$4pH#KJD+>a${+OneOuc^#Dwl2^|0c literal 0 HcmV?d00001 diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/iv1 b/mozilla/security/nss/cmd/bltest/tests/aes_cts/iv1 new file mode 100644 index 0000000000000000000000000000000000000000..3e8c8e9e6b97306f58059d6807b665465bc3bc64 GIT binary patch literal 34 ecmZQzKm~jZe;6w4`2KD>c*XU~iTB^%DggjZ*a_(X literal 0 HcmV?d00001 diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/iv2 b/mozilla/security/nss/cmd/bltest/tests/aes_cts/iv2 new file mode 100644 index 0000000000000000000000000000000000000000..b4bbc2e76fb0ee149bce3609e147cae594ccf0d4 GIT binary patch literal 34 dcmZQzKm~jZmWHaz%iEH!?yEn2X2$EUD*!$l2^jzY literal 0 HcmV?d00001 diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/iv3 b/mozilla/security/nss/cmd/bltest/tests/aes_cts/iv3 new file mode 100644 index 0000000000000000000000000000000000000000..c065e8362dc47e875113249f9a575f490363087a GIT binary patch literal 34 dcmZQzKm~jZoB#iv!Xvh@M>^E=(hm!!c>qgx2mAm4 literal 0 HcmV?d00001 diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/iv4 b/mozilla/security/nss/cmd/bltest/tests/aes_cts/iv4 new file mode 100644 index 0000000000000000000000000000000000000000..ba11a0ec02ff240e50a83121b4c2b60eed06e3a3 GIT binary patch literal 34 ecmZQzKm~jZbJuq7o_6Hy0qcXz4;N0^eFFeigbFSI literal 0 HcmV?d00001 diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/iv5 b/mozilla/security/nss/cmd/bltest/tests/aes_cts/iv5 new file mode 100644 index 0000000000000000000000000000000000000000..213a4bd3c7541d93cdc6bd0427ca28cc3cb2c062 GIT binary patch literal 34 dcmZQzKm~jZ9_;U5n7!* key$i + grep "IV" $file | sed -e 's;IV:;;' | hex > iv$i + grep "Input" $file | sed -e 's;Input:;;' | hex > plaintext$i + grep "Output" $file | sed -e 's;Output:;;' | hex | btoa > ciphertext$i +done diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/numtests b/mozilla/security/nss/cmd/bltest/tests/aes_cts/numtests new file mode 100644 index 00000000000..1e8b3149621 --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/numtests @@ -0,0 +1 @@ +6 diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext0 b/mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext0 new file mode 100644 index 00000000000..3f35c974a18 --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext0 @@ -0,0 +1 @@ +I would like the \ No newline at end of file diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext1 b/mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext1 new file mode 100644 index 00000000000..39754487114 --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext1 @@ -0,0 +1 @@ +I would like the General Gau's \ No newline at end of file diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext2 b/mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext2 new file mode 100644 index 00000000000..d0664ea0dbf --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext2 @@ -0,0 +1 @@ +I would like the General Gau's C \ No newline at end of file diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext3 b/mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext3 new file mode 100644 index 00000000000..563970bfa55 --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext3 @@ -0,0 +1 @@ +I would like the General Gau's Chicken, please, \ No newline at end of file diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext4 b/mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext4 new file mode 100644 index 00000000000..b908471e320 --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext4 @@ -0,0 +1 @@ +I would like the General Gau's Chicken, please, \ No newline at end of file diff --git a/mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext5 b/mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext5 new file mode 100644 index 00000000000..5e4c069476b --- /dev/null +++ b/mozilla/security/nss/cmd/bltest/tests/aes_cts/plaintext5 @@ -0,0 +1 @@ +I would like the General Gau's Chicken, please, and wonton soup. \ No newline at end of file diff --git a/mozilla/security/nss/lib/freebl/cts.c b/mozilla/security/nss/lib/freebl/cts.c index 4061de9e69d..74cdc0beaf0 100644 --- a/mozilla/security/nss/lib/freebl/cts.c +++ b/mozilla/security/nss/lib/freebl/cts.c @@ -115,7 +115,7 @@ CTS_EncryptUpdate(CTSContext *cts, unsigned char *outbuf, if (rv != SECSuccess) { return SECFailure; } - PORT_Assert(*outlen == fullblocks); + *outlen = fullblocks; /* AES low level doesn't set outlen */ inbuf += fullblocks; inlen -= fullblocks; if (inlen == 0) { @@ -140,7 +140,6 @@ CTS_EncryptUpdate(CTSContext *cts, unsigned char *outbuf, blocksize, blocksize); PORT_Memset(lastBlock, 0, blocksize); if (rv == SECSuccess) { - PORT_Assert(tmp == blocksize); *outlen = written + blocksize; } return rv; @@ -208,19 +207,19 @@ CTS_DecryptUpdate(CTSContext *cts, unsigned char *outbuf, * the comment for encrypt. NOTE2: since we can't modify inbuf unless * inbuf and outbuf overlap, just copy inbuf to outbuf and modify it there */ - pad = blocksize + (inlen - fullblocks); - if (pad != blocksize) { + pad = inlen - fullblocks; + if (pad != 0) { if (inbuf != outbuf) { memcpy(outbuf, inbuf, inlen); /* keep the names so we logically know how we are using the * buffers */ inbuf = outbuf; } - memcpy(lastBlock, inbuf+inlen-blocksize-pad, blocksize); + memcpy(lastBlock, inbuf+inlen-blocksize, blocksize); /* we know inbuf == outbuf now, inbuf is declared const and can't * be the target, so use outbuf for the target here */ - memcpy(outbuf+inlen-blocksize-pad, inbuf+inlen-pad, pad); - memcpy(outbuf+inlen-blocksize, lastBlock, blocksize); + memcpy(outbuf+inlen-pad, inbuf+inlen-blocksize-pad, pad); + memcpy(outbuf+inlen-blocksize-pad, lastBlock, blocksize); } /* save the previous to last block so we can undo the misordered * chaining */ @@ -233,7 +232,7 @@ CTS_DecryptUpdate(CTSContext *cts, unsigned char *outbuf, if (rv != SECSuccess) { return SECFailure; } - PORT_Assert(*outlen == fullblocks); + *outlen = fullblocks; /* AES low level doesn't set outlen */ inbuf += fullblocks; inlen -= fullblocks; if (inlen == 0) { @@ -275,7 +274,7 @@ CTS_DecryptUpdate(CTSContext *cts, unsigned char *outbuf, PORT_Memcpy(outbuf, lastBlock, inlen); *outlen += inlen; /* copy Cn-1* into last buf to recover Cn-1 */ - PORT_Memcpy(lastBlock, Cn-1, inlen); + PORT_Memcpy(lastBlock, Cn_1, inlen); /* note: because Cn and Cn-1 were out of order, our pointer to Pn also * points to where Pn-1 needs to reside. From here on out read Pn in * the code as really Pn-1. */ @@ -284,7 +283,6 @@ CTS_DecryptUpdate(CTSContext *cts, unsigned char *outbuf, if (rv != SECSuccess) { return SECFailure; } - PORT_Assert(tmpLen == blocksize); /* make up for the out of order CBC decryption */ XOR_BLOCK(Pn, Cn_2, blocksize); XOR_BLOCK(Pn, Cn, blocksize);