diff --git a/test/lisp/net/gnutls-tests.el b/test/lisp/net/gnutls-tests.el index cb911577385..0f2f39aad67 100644 --- a/test/lisp/net/gnutls-tests.el +++ b/test/lisp/net/gnutls-tests.el @@ -181,16 +181,46 @@ test-gnutls-003-hashes-hmacs (skip-unless (memq 'macs (gnutls-available-p))) (setq gnutls-tests-message-prefix "HMAC verification: ") (let ((macs (gnutls-macs))) - (dolist (test '(("f5c5021e60d9686fef3bb0414275fe4163bece61d9a95fec7a273746a437b986" "hello\n" "test" SHA256) + (dolist (test `(("f5c5021e60d9686fef3bb0414275fe4163bece61d9a95fec7a273746a437b986" "hello\n" "test" SHA256) ("46b75292b81002fd873e89c532a1b8545d6efc9822ee938feba6de2723161a67" "more and more data goes into a file to exceed the buffer size" "test" SHA256) ("81568ba71fa2c5f33cc84bf362466988f98eba3735479100b4e8908acad87ac4" "more and more data goes into a file to exceed the buffer size" "very long key goes here to exceed the key size" SHA256) ("4bc830005783a73b8112f4bd5f4aa5f92e05b51e9b55c0cd6f9a7bee48371def" "more and more data goes into a file to exceed the buffer size" "" "SHA256") ; check string ID for HMAC - ("4bc830005783a73b8112f4bd5f4aa5f92e05b51e9b55c0cd6f9a7bee48371def" "more and more data goes into a file to exceed the buffer size" "" SHA256))) - (pcase-let ((`(,hash ,input ,key ,mac) test)) + ("4bc830005783a73b8112f4bd5f4aa5f92e05b51e9b55c0cd6f9a7bee48371def" "more and more data goes into a file to exceed the buffer size" "" SHA256) + ("f5c5021e60d9686fef3bb0414275fe4163bece61d9a95fec7a273746a437b986" "hello\n" "test" SHA256 "nonce") + ("46b75292b81002fd873e89c532a1b8545d6efc9822ee938feba6de2723161a67" "more and more data goes into a file to exceed the buffer size" "test" SHA256 "nonce should not affect result") + ("81568ba71fa2c5f33cc84bf362466988f98eba3735479100b4e8908acad87ac4" "more and more data goes into a file to exceed the buffer size" "very long key goes here to exceed the key size" SHA256 "nonce should not affect result") + ("4bc830005783a73b8112f4bd5f4aa5f92e05b51e9b55c0cd6f9a7bee48371def" "more and more data goes into a file to exceed the buffer size" "" "SHA256" "nonce should not affect result") ; check string ID for HMAC + ("4bc830005783a73b8112f4bd5f4aa5f92e05b51e9b55c0cd6f9a7bee48371def" "more and more data goes into a file to exceed the buffer size" "" SHA256 "nonce should not affect result") + ("5300130ed12a31956a2da19bb2b292817955382c25dbe7c04d85e95b7c6db642c15fb7df3a4a235f85c8e15c8107ab43c909f1ebf6a0458992943d3f7fc90637" "hello\n" "test" SHA512) + ("5b2b459e89ecd204beb959dc6214a4c4b7da20bfc4c8adacf9615bddd0b2b8d2e950409e4703de11f02e50852edfb3cfbdaf8795e0ebf0ad50cf15e29150d234" "more and more data goes into a file to exceed the buffer size" "test" SHA512) + ("04d903bacae136010b21cefda8eb930b0016b2854994ff891e1f728c4b6f38e433481308c5713ea9137b003ade1f509bb96180ef5b6db5f5c82336245954674c" "more and more data goes into a file to exceed the buffer size" "very long key goes here to exceed the key size" SHA512) + ("5d6e0645c03fa26e5e55f6e7a2c8dc66927f4a5b93b4fe6f17188941364b689cba09fe088d9a74a7dff5a2a1f104aa87e3b8db6b4eb16739c635893ea1aa5752" "more and more data goes into a file to exceed the buffer size" "" "SHA512") ; check string ID for HMAC + ("5d6e0645c03fa26e5e55f6e7a2c8dc66927f4a5b93b4fe6f17188941364b689cba09fe088d9a74a7dff5a2a1f104aa87e3b8db6b4eb16739c635893ea1aa5752" "more and more data goes into a file to exceed the buffer size" "" SHA512) + ("5300130ed12a31956a2da19bb2b292817955382c25dbe7c04d85e95b7c6db642c15fb7df3a4a235f85c8e15c8107ab43c909f1ebf6a0458992943d3f7fc90637" "hello\n" "test" SHA512 "nonce") + ("5b2b459e89ecd204beb959dc6214a4c4b7da20bfc4c8adacf9615bddd0b2b8d2e950409e4703de11f02e50852edfb3cfbdaf8795e0ebf0ad50cf15e29150d234" "more and more data goes into a file to exceed the buffer size" "test" SHA512 "nonce should not affect result") + ("04d903bacae136010b21cefda8eb930b0016b2854994ff891e1f728c4b6f38e433481308c5713ea9137b003ade1f509bb96180ef5b6db5f5c82336245954674c" "more and more data goes into a file to exceed the buffer size" "very long key goes here to exceed the key size" SHA512 "nonce should not affect result") + ("5d6e0645c03fa26e5e55f6e7a2c8dc66927f4a5b93b4fe6f17188941364b689cba09fe088d9a74a7dff5a2a1f104aa87e3b8db6b4eb16739c635893ea1aa5752" "more and more data goes into a file to exceed the buffer size" "" "SHA512" "nonce should not affect result") ; check string ID for HMAC + ("5d6e0645c03fa26e5e55f6e7a2c8dc66927f4a5b93b4fe6f17188941364b689cba09fe088d9a74a7dff5a2a1f104aa87e3b8db6b4eb16739c635893ea1aa5752" "more and more data goes into a file to exceed the buffer size" "" SHA512 "nonce should not affect result") + + ;; GMAC tests (from NIST) + ("250327c674aaf477aef2675748cf6971" "" ,(decode-hex-string "11754cd72aec309bf52f7687212e8957") AES-GMAC-128 ,(decode-hex-string "3c819d9a9bed087615030b65")) + ("250327c674aaf477aef2675748cf6971" "" ,(decode-hex-string "11754cd72aec309bf52f7687212e8957") "AES-GMAC-128" ,(decode-hex-string "3c819d9a9bed087615030b65")) + ("209fcc8d3675ed938e9c7166709dd946" ,(decode-hex-string "7a43ec1d9c0a5a78a0b16533a6213cab") ,(decode-hex-string "77be63708971c4e240d1cb79e8d77feb") AES-GMAC-128 ,(decode-hex-string "e0e00f19fed7ba0136a797f3")) + ("209fcc8d3675ed938e9c7166709dd946" ,(decode-hex-string "7a43ec1d9c0a5a78a0b16533a6213cab") ,(decode-hex-string "77be63708971c4e240d1cb79e8d77feb") "AES-GMAC-128" ,(decode-hex-string "e0e00f19fed7ba0136a797f3")) + ("f149e2b5f0adaa9842ca5f45b768a8fc" "" ,(decode-hex-string "aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539") AES-GMAC-192 ,(decode-hex-string "ab2265b4c168955561f04315")) + ("f149e2b5f0adaa9842ca5f45b768a8fc" "" ,(decode-hex-string "aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539") "AES-GMAC-192" ,(decode-hex-string "ab2265b4c168955561f04315")) + ("204bdb1bd62154bf08922aaa54eed705" ,(decode-hex-string "8b5c124bef6e2f0fe4d8c95cd5fa4cf1") ,(decode-hex-string "41c5da8667ef725220ffe39ae0ac590ac9fca729ab60ada0") AES-GMAC-192 ,(decode-hex-string "05ad13a5e2c2ab667e1a6fbc")) + ("204bdb1bd62154bf08922aaa54eed705" ,(decode-hex-string "8b5c124bef6e2f0fe4d8c95cd5fa4cf1") ,(decode-hex-string "41c5da8667ef725220ffe39ae0ac590ac9fca729ab60ada0") "AES-GMAC-192" ,(decode-hex-string "05ad13a5e2c2ab667e1a6fbc")) + ("bdc1ac884d332457a1d2664f168c76f0" "" ,(decode-hex-string "b52c505a37d78eda5dd34f20c22540ea1b58963cf8e5bf8ffa85f9f2492505b4") AES-GMAC-256 ,(decode-hex-string "516c33929df5a3284ff463d7")) + ("bdc1ac884d332457a1d2664f168c76f0" "" ,(decode-hex-string "b52c505a37d78eda5dd34f20c22540ea1b58963cf8e5bf8ffa85f9f2492505b4") "AES-GMAC-256" ,(decode-hex-string "516c33929df5a3284ff463d7")) + ("3e5d486aa2e30b22e040b85723a06e76" ,(decode-hex-string "b96baa8c1c75a671bfb2d08d06be5f36") ,(decode-hex-string "78dc4e0aaf52d935c3c01eea57428f00ca1fd475f5da86a49c8dd73d68c8e223") AES-GMAC-256 ,(decode-hex-string "d79cf22d504cc793c3fb6c8a")) + ("3e5d486aa2e30b22e040b85723a06e76" ,(decode-hex-string "b96baa8c1c75a671bfb2d08d06be5f36") ,(decode-hex-string "78dc4e0aaf52d935c3c01eea57428f00ca1fd475f5da86a49c8dd73d68c8e223") "AES-GMAC-256" ,(decode-hex-string "d79cf22d504cc793c3fb6c8a")))) + + (pcase-let ((`(,hash ,input ,key ,mac ,nonce) test)) (let ((plist (cdr (assq mac macs))) result) (gnutls-tests-message "%s %S" mac plist) - (setq result (encode-hex-string (gnutls-hash-mac mac (copy-sequence key) input))) + (setq result (encode-hex-string (gnutls-hash-mac mac (copy-sequence key) input nonce))) (gnutls-tests-message "%S => result %S" test result) (should (string-equal result hash)))))))