ADDED tests/test_vectors/KDF/HKDF-SHA1.test Index: tests/test_vectors/KDF/HKDF-SHA1.test ================================================================== --- /dev/null +++ tests/test_vectors/KDF/HKDF-SHA1.test @@ -0,0 +1,63 @@ +# Auto generated from "HKDF-SHA1.txt" +package require tls +package require tcltest + +tcltest::testConstraint HKDF [expr {[lsearch -nocase [tls::kdfs] HKDF] > -1}] + +tcltest::test KDF_HKDF-SHA1-1.1 {HKDF-SHA1} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA1 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b] -info [binary decode hex f0f1f2f3f4f5f6f7f8f9] -salt [binary decode hex 000102030405060708090a0b0c] -size 42]} \ + -match exact -result 085a01ea1b10f36933068b56efa5ad81a4f14b822f5b091568a9cdd4f155fda2c22e422478d305f3f896 + +tcltest::test KDF_HKDF-SHA1-1.2 {HKDF-SHA1} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA1 -key [binary decode hex 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f] -info [binary decode hex b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff] -salt [binary decode hex 606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf] -size 82]} \ + -match exact -result 0bd770a74d1160f7c9f12cd5912a06ebff6adcae899d92191fe4305673ba2ffe8fa3f1a4e5ad79f3f334b3b202b2173c486ea37ce3d397ed034c7f9dfeb15c5e927336d0441f4c4300e2cff0d0900b52d3b4 + +tcltest::test KDF_HKDF-SHA1-1.3 {HKDF-SHA1} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA1 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b] -size 42]} \ + -match exact -result 0ac1af7002b3d761d1e55298da9d0506b9ae52057220a306e07b6b87e8df21d0ea00033de03984d34918 + +tcltest::test KDF_HKDF-SHA1-1.4 {HKDF-SHA1} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA1 -key [binary decode hex 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c] -size 42]} \ + -match exact -result 2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081d70cce7acfc48 + +tcltest::test KDF_HKDF-SHA1-1.5 {HKDF-SHA1} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA1 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b] -info [binary decode hex f0f1f2f3f4f5f6f7f8f9] -salt [binary decode hex 000102030405060708090a0b0c] -size 42]} \ + -match exact -result d6000ffb5b50bd3970b260017798fb9c8df9ce2e2c16b6cd709cca07dc3cf9cf26d6c6d750d0aaf5ac94 + +tcltest::test KDF_HKDF-SHA1-1.6 {HKDF-SHA1} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA1 -key [binary decode hex 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f] -info [binary decode hex b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff] -salt [binary decode hex 606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf] -size 82]} \ + -match exact -result 0bd770a74d1160f7c9f12cd5912a06ebff6adcae899d92191fe4305673ba2ffe8fa3f1a4e5ad79f3f334b3b202b2173c486ea37ce3d397ed034c7f9dfeb15c5e927336d0441f4c4300e2cff0d0900b52d3b4 + +tcltest::test KDF_HKDF-SHA1-1.7 {HKDF-SHA1} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA1 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b] -size 42]} \ + -match exact -result 0ac1af7002b3d761d1e55298da9d0506b9ae52057220a306e07b6b87e8df21d0ea00033de03984d34918 + +tcltest::test KDF_HKDF-SHA1-1.8 {HKDF-SHA1} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA1 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b] -info [binary decode hex f0f1f2f3f4f5f6f7f8f9] -salt [binary decode hex 000102030405060708090a0b0c] -size 42]} \ + -match exact -result 085a01ea1b10f36933068b56efa5ad81a4f14b822f5b091568a9cdd4f155fda2c22e422478d305f3f896 + +tcltest::test KDF_HKDF-SHA1-1.9 {HKDF-SHA1} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA1 -key [binary decode hex 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c] -size 42]} \ + -match exact -result 2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081d70cce7acfc48 + +# Cleanup +::tcltest::cleanupTests +return ADDED tests/test_vectors/KDF/HKDF-SHA1.txt Index: tests/test_vectors/KDF/HKDF-SHA1.txt ================================================================== --- /dev/null +++ tests/test_vectors/KDF/HKDF-SHA1.txt @@ -0,0 +1,119 @@ +# HKDF-SHA1 +# From https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values +# and RFC 6234 SHA and SHA-based HMAC and HKDF +# and RFC 5869 HKDF + +# HashLen denotes the length of the hash function output in octets +# Salt = optional salt value (a non-secret random value); if not provided, it is set to a string of HashLen zeros. +# IKM = key +# PRK = pseudorandom key (extract output) +# info = optional context and application specific information (can be 0 length) +# L = length of output keying material in octets (<= 255*HashLen) +# OKM = output keying material (of L octets) + +# RFC 5869 - A.4. Test Case 4, Basic test case with SHA-1 +Hash = SHA1 +Klen = 11 +IKM = 0b0b0b0b0b0b0b0b0b0b0b +Slen = 13 +salt = 000102030405060708090a0b0c +Ilen = 10 +info = f0f1f2f3f4f5f6f7f8f9 +L = 42 +PRK = 9b6c18c432a7bf8f0e71c8eb88f4b30baa2ba243 +OKM = 085a01ea1b10f36933068b56efa5ad81a4f14b822f5b091568a9cdd4f155fda2c22e422478d305f3f896 + +# RFC 5869 - A.5. Test Case 5, Test with SHA-1 and longer inputs/outputs +Hash = SHA1 +Klen = 80 +IKM = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f +Slen = 80 +salt = 606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf +Ilen = 80 +info = b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff +L = 82 +PRK = 8adae09a2a307059478d309b26c4115a224cfaf6 +OKM = 0bd770a74d1160f7c9f12cd5912a06ebff6adcae899d92191fe4305673ba2ffe8fa3f1a4e5ad79f3f334b3b202b2173c486ea37ce3d397ed034c7f9dfeb15c5e927336d0441f4c4300e2cff0d0900b52d3b4 + +# RFC 5869 - A.6. Test Case 6, Test with SHA-1 and zero-length salt/info +Hash = SHA1 +Klen = 22 +IKM = 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b +Slen = 0 +salt = +Ilen = 0 +info = +L = 42 +PRK = da8c8a73c7fa77288ec6f5e7c297786aa0d32d01 +OKM = 0ac1af7002b3d761d1e55298da9d0506b9ae52057220a306e07b6b87e8df21d0ea00033de03984d34918 + +# RFC 5869 - A.7. Test Case 7, Test with SHA-1, salt not provided (defaults to HashLen zero octets), zero-length info +Hash = SHA1 +Klen = 22 +IKM = 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c +Slen = 0 +salt = +Ilen = 0 +info = +L = 42 +PRK = 2adccada18779e7c2077ad2eb19d3f3e731385dd +OKM = 2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081d70cce7acfc48 + +######### +# from https://github.com/brycx/Test-Vector-Generation/blob/master/HKDF/hkdf-hmac-sha2-test-vectors.md +######### + +# RFC 5869 - A.1. Test Case 1, Basic test case with SHA-256 +Hash = SHA1 +Klen = 22 +IKM = 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b +Slen = 13 +salt = 000102030405060708090a0b0c +Ilen = 10 +info = f0f1f2f3f4f5f6f7f8f9 +L = 42 +OKM = d6000ffb5b50bd3970b260017798fb9c8df9ce2e2c16b6cd709cca07dc3cf9cf26d6c6d750d0aaf5ac94 + +# RFC 5869 - A.2. Test Case 2, Test with SHA-256 and longer inputs/outputs +Hash = SHA1 +Klen = 80 +IKM = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f +Slen = 80 +salt = 606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf +Ilen = 80 +info = b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff +L = 82 +OKM = 0bd770a74d1160f7c9f12cd5912a06ebff6adcae899d92191fe4305673ba2ffe8fa3f1a4e5ad79f3f334b3b202b2173c486ea37ce3d397ed034c7f9dfeb15c5e927336d0441f4c4300e2cff0d0900b52d3b4 + +# RFC 5869 - A.3. Test Case 3, Test with SHA-256 and zero-length salt/info +Hash = SHA1 +Klen = 22 +IKM = 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b +Slen = 0 +salt = +Ilen = 0 +info = +L = 42 +OKM = 0ac1af7002b3d761d1e55298da9d0506b9ae52057220a306e07b6b87e8df21d0ea00033de03984d34918 + +# RFC 5869 - A.4. Test Case 4, Basic test case with SHA-1 +Hash = SHA1 +Klen = 11 +IKM = 0b0b0b0b0b0b0b0b0b0b0b +Slen = 13 +salt = 000102030405060708090a0b0c +Ilen = 10 +info = f0f1f2f3f4f5f6f7f8f9 +L = 42 +OKM = 085a01ea1b10f36933068b56efa5ad81a4f14b822f5b091568a9cdd4f155fda2c22e422478d305f3f896 + +# RFC 5869 - A.7. Test Case 7, Test with SHA-1, salt not provided (defaults to HashLen zero octets), zero-length info +Hash = SHA1 +Klen = 22 +IKM = 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c +Slen = 0 +salt = +Ilen = 0 +info = +L = 42 +OKM = 2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081d70cce7acfc48 ADDED tests/test_vectors/KDF/HKDF-SHA224.test Index: tests/test_vectors/KDF/HKDF-SHA224.test ================================================================== --- /dev/null +++ tests/test_vectors/KDF/HKDF-SHA224.test @@ -0,0 +1,39 @@ +# Auto generated from "HKDF-SHA224.txt" +package require tls +package require tcltest + +tcltest::testConstraint HKDF [expr {[lsearch -nocase [tls::kdfs] HKDF] > -1}] + +tcltest::test KDF_HKDF-SHA224-1.1 {HKDF-SHA224} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA224 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b] -info [binary decode hex f0f1f2f3f4f5f6f7f8f9] -salt [binary decode hex 000102030405060708090a0b0c] -size 42]} \ + -match exact -result 2f21cd7cbc818ca5c561b933728e2e08e154a87e1432399a820dee13aa222d0cee6152fa539ab70f8e80 + +tcltest::test KDF_HKDF-SHA224-1.2 {HKDF-SHA224} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA224 -key [binary decode hex 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f] -info [binary decode hex b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff] -salt [binary decode hex 606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf] -size 82]} \ + -match exact -result 3e49703c243a3894916349b52a8f55c7c160452f97b2870f04ba924ba9056ab351765b04207231158dcb03d0c7d427cb2b7e060179459f9daffee05e8705113f7bc45b4f452601d884df6dfd4ff9dacfde69 + +tcltest::test KDF_HKDF-SHA224-1.3 {HKDF-SHA224} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA224 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b] -size 42]} \ + -match exact -result 2a268083ea787e06604a5845f1a53544dd7847bd6fb74adfcc1178baac5a0fe74076f8935971c00c2b19 + +tcltest::test KDF_HKDF-SHA224-1.4 {HKDF-SHA224} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA224 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b] -info [binary decode hex f0f1f2f3f4f5f6f7f8f9] -salt [binary decode hex 000102030405060708090a0b0c] -size 42]} \ + -match exact -result 7fc8ae0335ed468cef56be091f6478a1aae84c0da54ce5176aa38946c79e210ea32a4487e2138405c340 + +tcltest::test KDF_HKDF-SHA224-1.5 {HKDF-SHA224} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA224 -key [binary decode hex 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c] -size 42]} \ + -match exact -result ca8401e645b3a58e00992857fe0038cb1bf8dc51edf052336c08f3bed682c83e77803cdd16d156bb8a30 + +# Cleanup +::tcltest::cleanupTests +return ADDED tests/test_vectors/KDF/HKDF-SHA224.txt Index: tests/test_vectors/KDF/HKDF-SHA224.txt ================================================================== --- /dev/null +++ tests/test_vectors/KDF/HKDF-SHA224.txt @@ -0,0 +1,61 @@ +# HKDF-SHA224 +# From https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values +# and RFC 6234 SHA and SHA-based HMAC and HKDF +# and RFC 5869 HKDF +# SHA2 from https://github.com/brycx/Test-Vector-Generation/blob/master/HKDF/hkdf-hmac-sha2-test-vectors.md + +# RFC 5869 - A.1. Test Case 1, Basic test case with SHA-256 +Hash = SHA224 +Klen = 22 +IKM = 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b +Slen = 13 +salt = 000102030405060708090a0b0c +Ilen = 10 +info = f0f1f2f3f4f5f6f7f8f9 +L = 42 +OKM = 2f21cd7cbc818ca5c561b933728e2e08e154a87e1432399a820dee13aa222d0cee6152fa539ab70f8e80 + +# RFC 5869 - A.2. Test Case 2, Test with SHA-256 and longer inputs/outputs +Hash = SHA224 +Klen = 80 +IKM = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f +Slen = 80 +salt = 606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf +Ilen = 80 +info = b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff +L = 82 +OKM = 3e49703c243a3894916349b52a8f55c7c160452f97b2870f04ba924ba9056ab351765b04207231158dcb03d0c7d427cb2b7e060179459f9daffee05e8705113f7bc45b4f452601d884df6dfd4ff9dacfde69 + +# RFC 5869 - A.3. Test Case 3, Test with SHA-256 and zero-length salt/info +Hash = SHA224 +Klen = 22 +IKM = 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b +Slen = 0 +salt = +Ilen = 0 +info = +L = 42 +OKM = 2a268083ea787e06604a5845f1a53544dd7847bd6fb74adfcc1178baac5a0fe74076f8935971c00c2b19 + +# RFC 5869 - A.4. Test Case 4, Basic test case with SHA-1 +Hash = SHA224 +Klen = 11 +IKM = 0b0b0b0b0b0b0b0b0b0b0b +Slen = 13 +salt = 000102030405060708090a0b0c +Ilen = 10 +info = f0f1f2f3f4f5f6f7f8f9 +L = 42 +OKM = 7fc8ae0335ed468cef56be091f6478a1aae84c0da54ce5176aa38946c79e210ea32a4487e2138405c340 + +# RFC 5869 - A.7. Test Case 7, Test with SHA-1, salt not provided (defaults to HashLen zero octets), zero-length info +Hash = SHA224 +Klen = 22 +IKM = 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c +Slen = 0 +salt = +Ilen = 0 +info = +L = 42 +OKM = ca8401e645b3a58e00992857fe0038cb1bf8dc51edf052336c08f3bed682c83e77803cdd16d156bb8a30 + ADDED tests/test_vectors/KDF/HKDF-SHA256.test Index: tests/test_vectors/KDF/HKDF-SHA256.test ================================================================== --- /dev/null +++ tests/test_vectors/KDF/HKDF-SHA256.test @@ -0,0 +1,57 @@ +# Auto generated from "HKDF-SHA256.txt" +package require tls +package require tcltest + +tcltest::testConstraint HKDF [expr {[lsearch -nocase [tls::kdfs] HKDF] > -1}] + +tcltest::test KDF_HKDF-SHA256-1.1 {HKDF-SHA256} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA256 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b] -info [binary decode hex f0f1f2f3f4f5f6f7f8f9] -salt [binary decode hex 000102030405060708090a0b0c] -size 42]} \ + -match exact -result 3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865 + +tcltest::test KDF_HKDF-SHA256-1.2 {HKDF-SHA256} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA256 -key [binary decode hex 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f] -info [binary decode hex b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff] -salt [binary decode hex 606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf] -size 82]} \ + -match exact -result b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87 + +tcltest::test KDF_HKDF-SHA256-1.3 {HKDF-SHA256} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA256 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b] -size 42]} \ + -match exact -result 8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8 + +tcltest::test KDF_HKDF-SHA256-1.4 {HKDF-SHA256} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA256 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b] -info [binary decode hex f0f1f2f3f4f5f6f7f8f9] -salt [binary decode hex 000102030405060708090a0b0c] -size 42]} \ + -match exact -result 3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865 + +tcltest::test KDF_HKDF-SHA256-1.5 {HKDF-SHA256} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA256 -key [binary decode hex 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f] -info [binary decode hex b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff] -salt [binary decode hex 606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf] -size 82]} \ + -match exact -result b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87 + +tcltest::test KDF_HKDF-SHA256-1.6 {HKDF-SHA256} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA256 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b] -size 42]} \ + -match exact -result 8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8 + +tcltest::test KDF_HKDF-SHA256-1.7 {HKDF-SHA256} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA256 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b] -info [binary decode hex f0f1f2f3f4f5f6f7f8f9] -salt [binary decode hex 000102030405060708090a0b0c] -size 42]} \ + -match exact -result 58dce10d5801cdfda831726bfebcb743d14a7ee83aa057a93d59b0a1317ff09d105ccecf535692b14dd5 + +tcltest::test KDF_HKDF-SHA256-1.8 {HKDF-SHA256} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA256 -key [binary decode hex 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c] -size 42]} \ + -match exact -result 596899179ab1bc00a7c03786ff43ee535004be2bb9be68bc1406636f54bd338a66a237ba2acbcee3c9a7 + +# Cleanup +::tcltest::cleanupTests +return ADDED tests/test_vectors/KDF/HKDF-SHA256.txt Index: tests/test_vectors/KDF/HKDF-SHA256.txt ================================================================== --- /dev/null +++ tests/test_vectors/KDF/HKDF-SHA256.txt @@ -0,0 +1,99 @@ +# HKDF-SHA256 +# From https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values +# and RFC 6234 SHA and SHA-based HMAC and HKDF +# and RFC 5869 HKDF +# SHA2 from https://github.com/brycx/Test-Vector-Generation/blob/master/HKDF/hkdf-hmac-sha2-test-vectors.md + +# RFC 5869 - A.1. Test Case 1, Basic test case with SHA-256 +Hash = SHA256 +Klen = 22 +IKM = 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b +Slen = 13 +salt = 000102030405060708090a0b0c +Ilen = 10 +info = f0f1f2f3f4f5f6f7f8f9 +L = 42 +PRK = 077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5 +OKM = 3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865 + +# RFC 5869 - A.2. Test Case 2, Test with SHA-256 and longer inputs/outputs +Hash = SHA256 +Klen = 80 +IKM = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f +Slen = 80 +salt = 606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf +Ilen = 80 +info = b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff +L = 82 +PRK = 06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244 +OKM = b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87 + +# RFC 5869 - A.3. Test Case 3, Test with SHA-256 and zero-length salt/info +Hash = SHA256 +Klen = 22 +IKM = 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b +Slen = 0 +salt = +Ilen = 0 +info = +L = 42 +PRK = 19ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04 +OKM = 8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8 + + + +# RFC 5869 - A.1. Test Case 1, Basic test case with SHA-256 +Hash = SHA256 +Klen = 22 +IKM = 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b +Slen = 13 +salt = 000102030405060708090a0b0c +Ilen = 10 +info = f0f1f2f3f4f5f6f7f8f9 +L = 42 +OKM = 3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865 + +# RFC 5869 - A.2. Test Case 2, Test with SHA-256 and longer inputs/outputs +Hash = SHA256 +Klen = 80 +IKM = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f +Slen = 80 +salt = 606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf +Ilen = 80 +info = b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff +L = 82 +OKM = b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87 + +# RFC 5869 - A.3. Test Case 3, Test with SHA-256 and zero-length salt/info +Hash = SHA256 +Klen = 22 +IKM = 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b +Slen = 0 +salt = +Ilen = 0 +info = +L = 42 +OKM = 8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8 + +# RFC 5869 - A.4. Test Case 4, Basic test case with SHA-1 +Hash = SHA256 +Klen = 11 +IKM = 0b0b0b0b0b0b0b0b0b0b0b +Slen = 13 +salt = 000102030405060708090a0b0c +Ilen = 10 +info = f0f1f2f3f4f5f6f7f8f9 +L = 42 +OKM = 58dce10d5801cdfda831726bfebcb743d14a7ee83aa057a93d59b0a1317ff09d105ccecf535692b14dd5 + +# RFC 5869 - A.7. Test Case 7, Test with SHA-1, salt not provided (defaults to HashLen zero octets), zero-length info +Hash = SHA256 +Klen = 22 +IKM = 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c +Slen = 0 +salt = +Ilen = 0 +info = +L = 42 +OKM = 596899179ab1bc00a7c03786ff43ee535004be2bb9be68bc1406636f54bd338a66a237ba2acbcee3c9a7 + ADDED tests/test_vectors/KDF/HKDF-SHA384.test Index: tests/test_vectors/KDF/HKDF-SHA384.test ================================================================== --- /dev/null +++ tests/test_vectors/KDF/HKDF-SHA384.test @@ -0,0 +1,39 @@ +# Auto generated from "HKDF-SHA384.txt" +package require tls +package require tcltest + +tcltest::testConstraint HKDF [expr {[lsearch -nocase [tls::kdfs] HKDF] > -1}] + +tcltest::test KDF_HKDF-SHA384-1.1 {HKDF-SHA384} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA384 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b] -info [binary decode hex f0f1f2f3f4f5f6f7f8f9] -salt [binary decode hex 000102030405060708090a0b0c] -size 42]} \ + -match exact -result 9b5097a86038b805309076a44b3a9f38063e25b516dcbf369f394cfab43685f748b6457763e4f0204fc5 + +tcltest::test KDF_HKDF-SHA384-1.2 {HKDF-SHA384} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA384 -key [binary decode hex 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f] -info [binary decode hex b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff] -salt [binary decode hex 606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf] -size 82]} \ + -match exact -result 484ca052b8cc724fd1c4ec64d57b4e818c7e25a8e0f4569ed72a6a05fe0649eebf69f8d5c832856bf4e4fbc17967d54975324a94987f7f41835817d8994fdbd6f4c09c5500dca24a56222fea53d8967a8b2e + +tcltest::test KDF_HKDF-SHA384-1.3 {HKDF-SHA384} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA384 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b] -size 42]} \ + -match exact -result c8c96e710f89b0d7990bca68bcdec8cf854062e54c73a7abc743fade9b242daacc1cea5670415b52849c + +tcltest::test KDF_HKDF-SHA384-1.4 {HKDF-SHA384} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA384 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b] -info [binary decode hex f0f1f2f3f4f5f6f7f8f9] -salt [binary decode hex 000102030405060708090a0b0c] -size 42]} \ + -match exact -result fb7e6743eb42cde96f1b70778952ab7548cafe53249f7ffe1497a1635b201ff185b93e951992d858f11a + +tcltest::test KDF_HKDF-SHA384-1.5 {HKDF-SHA384} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA384 -key [binary decode hex 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c] -size 42]} \ + -match exact -result 6ad7c726c84009546a76e0545df266787e2b2cd6ca4373a1f31450a7bdf9482bfab811f554200ead8f53 + +# Cleanup +::tcltest::cleanupTests +return ADDED tests/test_vectors/KDF/HKDF-SHA384.txt Index: tests/test_vectors/KDF/HKDF-SHA384.txt ================================================================== --- /dev/null +++ tests/test_vectors/KDF/HKDF-SHA384.txt @@ -0,0 +1,61 @@ +# HKDF-SHA384 +# From https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values +# and RFC 6234 SHA and SHA-based HMAC and HKDF +# and RFC 5869 HKDF +# SHA2 from https://github.com/brycx/Test-Vector-Generation/blob/master/HKDF/hkdf-hmac-sha2-test-vectors.md + +# RFC 5869 - A.1. Test Case 1, Basic test case with SHA-256 +Hash = SHA384 +Klen = 22 +IKM = 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b +Slen = 13 +salt = 000102030405060708090a0b0c +Ilen = 10 +info = f0f1f2f3f4f5f6f7f8f9 +L = 42 +OKM = 9b5097a86038b805309076a44b3a9f38063e25b516dcbf369f394cfab43685f748b6457763e4f0204fc5 + +# RFC 5869 - A.2. Test Case 2, Test with SHA-256 and longer inputs/outputs +Hash = SHA384 +Klen = 80 +IKM = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f +Slen = 80 +salt = 606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf +Ilen = 80 +info = b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff +L = 82 +OKM = 484ca052b8cc724fd1c4ec64d57b4e818c7e25a8e0f4569ed72a6a05fe0649eebf69f8d5c832856bf4e4fbc17967d54975324a94987f7f41835817d8994fdbd6f4c09c5500dca24a56222fea53d8967a8b2e + +# RFC 5869 - A.3. Test Case 3, Test with SHA-256 and zero-length salt/info +Hash = SHA384 +Klen = 22 +IKM = 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b +Slen = 0 +salt = +Ilen = 0 +info = +L = 42 +OKM = c8c96e710f89b0d7990bca68bcdec8cf854062e54c73a7abc743fade9b242daacc1cea5670415b52849c + +# RFC 5869 - A.4. Test Case 4, Basic test case with SHA-1 +Hash = SHA384 +Klen = 11 +IKM = 0b0b0b0b0b0b0b0b0b0b0b +Slen = 13 +salt = 000102030405060708090a0b0c +Ilen = 10 +info = f0f1f2f3f4f5f6f7f8f9 +L = 42 +OKM = fb7e6743eb42cde96f1b70778952ab7548cafe53249f7ffe1497a1635b201ff185b93e951992d858f11a + +# RFC 5869 - A.7. Test Case 7, Test with SHA-1, salt not provided (defaults to HashLen zero octets), zero-length info +Hash = SHA384 +Klen = 22 +IKM = 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c +Slen = 0 +salt = +Ilen = 0 +info = +L = 42 +OKM = 6ad7c726c84009546a76e0545df266787e2b2cd6ca4373a1f31450a7bdf9482bfab811f554200ead8f53 + ADDED tests/test_vectors/KDF/HKDF-SHA512.test Index: tests/test_vectors/KDF/HKDF-SHA512.test ================================================================== --- /dev/null +++ tests/test_vectors/KDF/HKDF-SHA512.test @@ -0,0 +1,39 @@ +# Auto generated from "HKDF-SHA512.txt" +package require tls +package require tcltest + +tcltest::testConstraint HKDF [expr {[lsearch -nocase [tls::kdfs] HKDF] > -1}] + +tcltest::test KDF_HKDF-SHA512-1.1 {HKDF-SHA512} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA512 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b] -info [binary decode hex f0f1f2f3f4f5f6f7f8f9] -salt [binary decode hex 000102030405060708090a0b0c] -size 42]} \ + -match exact -result 832390086cda71fb47625bb5ceb168e4c8e26a1a16ed34d9fc7fe92c1481579338da362cb8d9f925d7cb + +tcltest::test KDF_HKDF-SHA512-1.2 {HKDF-SHA512} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA512 -key [binary decode hex 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f] -info [binary decode hex b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff] -salt [binary decode hex 606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf] -size 82]} \ + -match exact -result ce6c97192805b346e6161e821ed165673b84f400a2b514b2fe23d84cd189ddf1b695b48cbd1c8388441137b3ce28f16aa64ba33ba466b24df6cfcb021ecff235f6a2056ce3af1de44d572097a8505d9e7a93 + +tcltest::test KDF_HKDF-SHA512-1.3 {HKDF-SHA512} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA512 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b] -size 42]} \ + -match exact -result f5fa02b18298a72a8c23898a8703472c6eb179dc204c03425c970e3b164bf90fff22d04836d0e2343bac + +tcltest::test KDF_HKDF-SHA512-1.4 {HKDF-SHA512} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA512 -key [binary decode hex 0b0b0b0b0b0b0b0b0b0b0b] -info [binary decode hex f0f1f2f3f4f5f6f7f8f9] -salt [binary decode hex 000102030405060708090a0b0c] -size 42]} \ + -match exact -result 7413e8997e020610fbf6823f2ce14bff01875db1ca55f68cfcf3954dc8aff53559bd5e3028b080f7c068 + +tcltest::test KDF_HKDF-SHA512-1.5 {HKDF-SHA512} \ + -constraints HKDF \ + -setup {} \ + -body {binary encode hex [tls::hkdf -digest SHA512 -key [binary decode hex 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c] -size 42]} \ + -match exact -result 1407d46013d98bc6decefcfee55f0f90b0c7f63d68eb1a80eaf07e953cfc0a3a5240a155d6e4daa965bb + +# Cleanup +::tcltest::cleanupTests +return ADDED tests/test_vectors/KDF/HKDF-SHA512.txt Index: tests/test_vectors/KDF/HKDF-SHA512.txt ================================================================== --- /dev/null +++ tests/test_vectors/KDF/HKDF-SHA512.txt @@ -0,0 +1,61 @@ +# HKDF-SHA512 +# From https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values +# and RFC 6234 SHA and SHA-based HMAC and HKDF +# and RFC 5869 HKDF +# SHA2 from https://github.com/brycx/Test-Vector-Generation/blob/master/HKDF/hkdf-hmac-sha2-test-vectors.md + +# RFC 5869 - A.1. Test Case 1, Basic test case with SHA-256 +Hash = SHA512 +Klen = 22 +IKM = 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b +Slen = 13 +salt = 000102030405060708090a0b0c +Ilen = 10 +info = f0f1f2f3f4f5f6f7f8f9 +L = 42 +OKM = 832390086cda71fb47625bb5ceb168e4c8e26a1a16ed34d9fc7fe92c1481579338da362cb8d9f925d7cb + +# RFC 5869 - A.2. Test Case 2, Test with SHA-256 and longer inputs/outputs +Hash = SHA512 +Klen = 80 +IKM = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f +Slen = 80 +salt = 606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf +Ilen = 80 +info = b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff +L = 82 +OKM = ce6c97192805b346e6161e821ed165673b84f400a2b514b2fe23d84cd189ddf1b695b48cbd1c8388441137b3ce28f16aa64ba33ba466b24df6cfcb021ecff235f6a2056ce3af1de44d572097a8505d9e7a93 + +# RFC 5869 - A.3. Test Case 3, Test with SHA-256 and zero-length salt/info +Hash = SHA512 +Klen = 22 +IKM = 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b +Slen = 0 +salt = +Ilen = 0 +info = +L = 42 +OKM = f5fa02b18298a72a8c23898a8703472c6eb179dc204c03425c970e3b164bf90fff22d04836d0e2343bac + +# RFC 5869 - A.4. Test Case 4, Basic test case with SHA-1 +Hash = SHA512 +Klen = 11 +IKM = 0b0b0b0b0b0b0b0b0b0b0b +Slen = 13 +salt = 000102030405060708090a0b0c +Ilen = 10 +info = f0f1f2f3f4f5f6f7f8f9 +L = 42 +OKM = 7413e8997e020610fbf6823f2ce14bff01875db1ca55f68cfcf3954dc8aff53559bd5e3028b080f7c068 + +# RFC 5869 - A.7. Test Case 7, Test with SHA-1, salt not provided (defaults to HashLen zero octets), zero-length info +Hash = SHA512 +Klen = 22 +IKM = 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c +Slen = 0 +salt = +Ilen = 0 +info = +L = 42 +OKM = 1407d46013d98bc6decefcfee55f0f90b0c7f63d68eb1a80eaf07e953cfc0a3a5240a155d6e4daa965bb + ADDED tests/test_vectors/KDF/PBKDF2-SHA1.test Index: tests/test_vectors/KDF/PBKDF2-SHA1.test ================================================================== --- /dev/null +++ tests/test_vectors/KDF/PBKDF2-SHA1.test @@ -0,0 +1,45 @@ +# Auto generated from "PBKDF2-SHA1.txt" +package require tls +package require tcltest + +tcltest::testConstraint PBKDF2 [expr {[lsearch -nocase [tls::kdfs] PBKDF2] > -1}] + +tcltest::test KDF_PBKDF2-SHA1-1.1 {PBKDF2-SHA1} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA1 -password "password" -salt "salt" -iterations 1 -size 20]} \ + -match exact -result 0c60c80f961f0e71f3a9b524af6012062fe037a6 + +tcltest::test KDF_PBKDF2-SHA1-1.2 {PBKDF2-SHA1} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA1 -password "password" -salt "salt" -iterations 2 -size 20]} \ + -match exact -result ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957 + +tcltest::test KDF_PBKDF2-SHA1-1.3 {PBKDF2-SHA1} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA1 -password "password" -salt "salt" -iterations 4096 -size 20]} \ + -match exact -result 4b007901b765489abead49d926f721d065a429c1 + +tcltest::test KDF_PBKDF2-SHA1-1.4 {PBKDF2-SHA1} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA1 -password "password" -salt "salt" -iterations 16777216 -size 20]} \ + -match exact -result eefe3d61cd4da4e4e9945b3d6ba2158c2634e984 + +tcltest::test KDF_PBKDF2-SHA1-1.5 {PBKDF2-SHA1} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA1 -password "passwordPASSWORDpassword" -salt "saltSALTsaltSALTsaltSALTsaltSALTsalt" -iterations 4096 -size 25]} \ + -match exact -result 3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038 + +tcltest::test KDF_PBKDF2-SHA1-1.6 {PBKDF2-SHA1} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA1 -password "pass\0word" -salt "sa\0lt" -iterations 4096 -size 16]} \ + -match exact -result 56fa6aa75548099dcc37d7f03425e0c3 + +# Cleanup +::tcltest::cleanupTests +return ADDED tests/test_vectors/KDF/PBKDF2-SHA1.txt Index: tests/test_vectors/KDF/PBKDF2-SHA1.txt ================================================================== --- /dev/null +++ tests/test_vectors/KDF/PBKDF2-SHA1.txt @@ -0,0 +1,62 @@ +# PBKDF2 +# From RFC 6070 - PBKDF2 with HMAC SHA-1 + +# Test Case 1 +Hash = SHA1 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 1 +dkLen = 20 +DK = 0c60c80f961f0e71f3a9b524af6012062fe037a6 + +# Test Case 2 +Hash = SHA1 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 2 +dkLen = 20 +DK = ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957 + +# Test Case 3 +Hash = SHA1 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 4096 +dkLen = 20 +DK = 4b007901b765489abead49d926f721d065a429c1 + +# Test Case 4 +Hash = SHA1 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 16777216 +dkLen = 20 +DK = eefe3d61cd4da4e4e9945b3d6ba2158c2634e984 + +# Test Case 5 +Hash = SHA1 +Plen = 24 +Slen = 36 +P = "passwordPASSWORDpassword" +S = "saltSALTsaltSALTsaltSALTsaltSALTsalt" +c = 4096 +dkLen = 25 +DK = 3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038 + +# Test Case 6 +Hash = SHA1 +Plen = 9 +Slen = 5 +P = "pass\0word" +S = "sa\0lt" +c = 4096 +dkLen = 16 +DK = 56fa6aa75548099dcc37d7f03425e0c3 ADDED tests/test_vectors/KDF/PBKDF2-SHA224.test Index: tests/test_vectors/KDF/PBKDF2-SHA224.test ================================================================== --- /dev/null +++ tests/test_vectors/KDF/PBKDF2-SHA224.test @@ -0,0 +1,57 @@ +# Auto generated from "PBKDF2-SHA224.txt" +package require tls +package require tcltest + +tcltest::testConstraint PBKDF2 [expr {[lsearch -nocase [tls::kdfs] PBKDF2] > -1}] + +tcltest::test KDF_PBKDF2-SHA224-1.1 {PBKDF2-SHA224} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA224 -password "password" -salt "salt" -iterations 1 -size 20]} \ + -match exact -result 3c198cbdb9464b7857966bd05b7bc92bc1cc4e6e + +tcltest::test KDF_PBKDF2-SHA224-1.2 {PBKDF2-SHA224} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA224 -password "password" -salt "salt" -iterations 2 -size 20]} \ + -match exact -result 93200ffa96c5776d38fa10abdf8f5bfc0054b971 + +tcltest::test KDF_PBKDF2-SHA224-1.3 {PBKDF2-SHA224} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA224 -password "password" -salt "salt" -iterations 4096 -size 20]} \ + -match exact -result 218c453bf90635bd0a21a75d172703ff6108ef60 + +tcltest::test KDF_PBKDF2-SHA224-1.4 {PBKDF2-SHA224} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA224 -password "password" -salt "salt" -iterations 16777216 -size 20]} \ + -match exact -result b49925184cb4b559f365e94fcafcd4cdb9f7aef4 + +tcltest::test KDF_PBKDF2-SHA224-1.5 {PBKDF2-SHA224} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA224 -password "passwordPASSWORDpassword" -salt "saltSALTsaltSALTsaltSALTsaltSALTsalt" -iterations 4096 -size 25]} \ + -match exact -result 056c4ba438ded91fc14e0594e6f52b87e1f3690c0dc0fbc057 + +tcltest::test KDF_PBKDF2-SHA224-1.6 {PBKDF2-SHA224} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA224 -password "pass\0word" -salt "sa\0lt" -iterations 4096 -size 16]} \ + -match exact -result 9b4011b641f40a2a500a31d4a392d15c + +tcltest::test KDF_PBKDF2-SHA224-1.7 {PBKDF2-SHA224} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA224 -password "passwd" -salt "salt" -iterations 1 -size 128]} \ + -match exact -result e55bd77cfc18b012ac6362e22d7cdf77c4b03879a6af51fbf0045bc32a03e7f0d829d26b765bff0ca5873e07a8e85804ff4a17683ed706130d51657456bc0ebd07c35ca0675b3113ad9c33fe48a5eb9e9dc6c6a8cf5cf6de1318b414dbe667bfaeb863ef8399ff4a732520dab4ba82336513a25077ddfc11fc618c11efaf04ae + +tcltest::test KDF_PBKDF2-SHA224-1.8 {PBKDF2-SHA224} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA224 -password "Password" -salt "sa\0lt" -iterations 4096 -size 256]} \ + -match exact -result a329a360c825e12e454ad8633a842a06ba1456907770779d1fa4e0b61a5b1c6ce02e71de74ae433bbf14b907690d008d0cab5b01c976c1e627b027a9a809fd001082c809650344ecfcdebdf0d64b92cb1e869bf91b75517ea36918127b1eccc4cac145fb965071292a6dfa388d8ad893d2541f83a0dac1c55d2d90709963b066de985e92974e87b7d8c0e8026d96684bb0425203919b4792962b065e2b2b815ba888b8428ae51f57a74f637a658e27cf5fbc5593e85f775a1f81660850a723e2eb565f30dfc2cf2973ad57ec95b89c0979c7bab81c11d8987540a32badb2f7bbe4ff21a4f0d91dbd911b88ddd928603fd27b0ede994ee99edd2c04667b82067f + +# Cleanup +::tcltest::cleanupTests +return ADDED tests/test_vectors/KDF/PBKDF2-SHA224.txt Index: tests/test_vectors/KDF/PBKDF2-SHA224.txt ================================================================== --- /dev/null +++ tests/test_vectors/KDF/PBKDF2-SHA224.txt @@ -0,0 +1,92 @@ +# PBKDF2 +# From RFC 6070 - PBKDF2 with HMAC SHA-1 +# SHA2 from https://github.com/brycx/Test-Vector-Generation/blob/master/PBKDF2/pbkdf2-hmac-sha2-test-vectors.md + +# Test Case 1 +Hash = SHA224 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 1 +dkLen = 20 +DK = 3c198cbdb9464b7857966bd05b7bc92bc1cc4e6e + +# Test Case 2 +Hash = SHA224 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 2 +dkLen = 20 +DK = 93200ffa96c5776d38fa10abdf8f5bfc0054b971 + +# Test Case 3 +Hash = SHA224 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 4096 +dkLen = 20 +DK = 218c453bf90635bd0a21a75d172703ff6108ef60 + +# Test Case 4 +Hash = SHA224 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 16777216 +dkLen = 20 +DK = b49925184cb4b559f365e94fcafcd4cdb9f7aef4 + +# Test Case 5 +Hash = SHA224 +Plen = 24 +Slen = 36 +P = "passwordPASSWORDpassword" +S = "saltSALTsaltSALTsaltSALTsaltSALTsalt" +c = 4096 +dkLen = 25 +DK = 056c4ba438ded91fc14e0594e6f52b87e1f3690c0dc0fbc057 + +# Test Case 6 +Hash = SHA224 +Plen = 9 +Slen = 5 +P = "pass\0word" +S = "sa\0lt" +c = 4096 +dkLen = 16 +DK = 9b4011b641f40a2a500a31d4a392d15c + +# Test Case 7 +Hash = SHA224 +Plen = 6 +Slen = 4 +P = "passwd" +S = "salt" +c = 1 +dkLen = 128 +DK = e55bd77cfc18b012ac6362e22d7cdf77c4b03879a6af51fbf0045bc32a03e7f0d829d26b765bff0ca5873e07a8e85804ff4a17683ed706130d51657456bc0ebd07c35ca0675b3113ad9c33fe48a5eb9e9dc6c6a8cf5cf6de1318b414dbe667bfaeb863ef8399ff4a732520dab4ba82336513a25077ddfc11fc618c11efaf04ae + +# Test Case 8 +Hash = SHA224 +Plen = 6 +Slen = 4 +P = "Password" +S = "NaCl" +c = 80000 +dkLen = 128 +DK = bebbdf809d53fc84531d0abe06679a8c8526fde47b47245634186908335857334a7578543f9241726d845ee8e575105e4a733b5dcaefa7560af3d028eccf95937535918dbaa84269fc0586711e7a5b9dc0d4c28fc7a89469db7ff5829b8fc1ef709d7ef95c6c7db24cece88f7c1408c8e7cee55c84db0eebb8d8e41 +# Test Case 9 +Hash = SHA224 +Plen = 6 +Slen = 4 +P = "Password" +S = "sa\0lt" +c = 4096 +dkLen = 256 +DK = a329a360c825e12e454ad8633a842a06ba1456907770779d1fa4e0b61a5b1c6ce02e71de74ae433bbf14b907690d008d0cab5b01c976c1e627b027a9a809fd001082c809650344ecfcdebdf0d64b92cb1e869bf91b75517ea36918127b1eccc4cac145fb965071292a6dfa388d8ad893d2541f83a0dac1c55d2d90709963b066de985e92974e87b7d8c0e8026d96684bb0425203919b4792962b065e2b2b815ba888b8428ae51f57a74f637a658e27cf5fbc5593e85f775a1f81660850a723e2eb565f30dfc2cf2973ad57ec95b89c0979c7bab81c11d8987540a32badb2f7bbe4ff21a4f0d91dbd911b88ddd928603fd27b0ede994ee99edd2c04667b82067f ADDED tests/test_vectors/KDF/PBKDF2-SHA256.test Index: tests/test_vectors/KDF/PBKDF2-SHA256.test ================================================================== --- /dev/null +++ tests/test_vectors/KDF/PBKDF2-SHA256.test @@ -0,0 +1,75 @@ +# Auto generated from "PBKDF2-SHA256.txt" +package require tls +package require tcltest + +tcltest::testConstraint PBKDF2 [expr {[lsearch -nocase [tls::kdfs] PBKDF2] > -1}] + +tcltest::test KDF_PBKDF2-SHA256-1.1 {PBKDF2-SHA256} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA256 -password "password" -salt "salt" -iterations 1 -size 20]} \ + -match exact -result 120fb6cffcf8b32c43e7225256c4f837a86548c9 + +tcltest::test KDF_PBKDF2-SHA256-1.2 {PBKDF2-SHA256} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA256 -password "password" -salt "salt" -iterations 2 -size 20]} \ + -match exact -result ae4d0c95af6b46d32d0adff928f06dd02a303f8e + +tcltest::test KDF_PBKDF2-SHA256-1.3 {PBKDF2-SHA256} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA256 -password "password" -salt "salt" -iterations 4096 -size 20]} \ + -match exact -result c5e478d59288c841aa530db6845c4c8d962893a0 + +tcltest::test KDF_PBKDF2-SHA256-1.4 {PBKDF2-SHA256} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA256 -password "password" -salt "salt" -iterations 16777216 -size 20]} \ + -match exact -result cf81c66fe8cfc04d1f31ecb65dab4089f7f179e8 + +tcltest::test KDF_PBKDF2-SHA256-1.5 {PBKDF2-SHA256} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA256 -password "passwordPASSWORDpassword" -salt "saltSALTsaltSALTsaltSALTsaltSALTsalt" -iterations 4096 -size 25]} \ + -match exact -result 348c89dbcbd32b2f32d814b8116e84cf2b17347ebc1800181c + +tcltest::test KDF_PBKDF2-SHA256-1.6 {PBKDF2-SHA256} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA256 -password "pass\0word" -salt "sa\0lt" -iterations 4096 -size 16]} \ + -match exact -result 89b69d0516f829893c696226650a8687 + +tcltest::test KDF_PBKDF2-SHA256-1.7 {PBKDF2-SHA256} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA256 -password "passwd" -salt "salt" -iterations 1 -size 128]} \ + -match exact -result 55ac046e56e3089fec1691c22544b605f94185216dde0465e68b9d57c20dacbc49ca9cccf179b645991664b39d77ef317c71b845b1e30bd509112041d3a19783c294e850150390e1160c34d62e9665d659ae49d314510fc98274cc79681968104b8f89237e69b2d549111868658be62f59bd715cac44a1147ed5317c9bae6b2a + +tcltest::test KDF_PBKDF2-SHA256-1.8 {PBKDF2-SHA256} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA256 -password "Password" -salt "NaCl" -iterations 80000 -size 128]} \ + -match exact -result 4ddcd8f60b98be21830cee5ef22701f9641a4418d04c0414aeff08876b34ab56a1d425a1225833549adb841b51c9b3176a272bdebba1d078478f62b397f33c8d62aae85a11cdde829d89cb6ffd1ab0e63a981f8747d2f2f9fe5874165c83c168d2eed1d2d5ca4052dec2be5715623da019b8c0ec87dc36aa751c38f9893d15c3 + +tcltest::test KDF_PBKDF2-SHA256-1.9 {PBKDF2-SHA256} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA256 -password "Password" -salt "sa\0lt" -iterations 4096 -size 256]} \ + -match exact -result 436c82c6af9010bb0fdb274791934ac7dee21745dd11fb57bb90112ab187c495ad82df776ad7cefb606f34fedca59baa5922a57f3e91bc0e11960da7ec87ed0471b456a0808b60dff757b7d313d4068bf8d337a99caede24f3248f87d1bf16892b70b076a07dd163a8a09db788ae34300ff2f2d0a92c9e678186183622a636f4cbce15680dfea46f6d224e51c299d4946aa2471133a649288eef3e4227b609cf203dba65e9fa69e63d35b6ff435ff51664cbd6773d72ebc341d239f0084b004388d6afa504eee6719a7ae1bb9daf6b7628d851fab335f1d13948e8ee6f7ab033a32df447f8d0950809a70066605d6960847ed436fa52cdfbcf261b44d2a87061 + +tcltest::test KDF_PBKDF2-SHA256-1.10 {PBKDF2-SHA256} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA256 -password "passwd" -salt "salt" -iterations 1 -size 64]} \ + -match exact -result 55ac046e56e3089fec1691c22544b605f94185216dde0465e68b9d57c20dacbc49ca9cccf179b645991664b39d77ef317c71b845b1e30bd509112041d3a19783 + +tcltest::test KDF_PBKDF2-SHA256-1.11 {PBKDF2-SHA256} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA256 -password "Password" -salt "NaCl" -iterations 80000 -size 64]} \ + -match exact -result 4ddcd8f60b98be21830cee5ef22701f9641a4418d04c0414aeff08876b34ab56a1d425a1225833549adb841b51c9b3176a272bdebba1d078478f62b397f33c8d + +# Cleanup +::tcltest::cleanupTests +return ADDED tests/test_vectors/KDF/PBKDF2-SHA256.txt Index: tests/test_vectors/KDF/PBKDF2-SHA256.txt ================================================================== --- /dev/null +++ tests/test_vectors/KDF/PBKDF2-SHA256.txt @@ -0,0 +1,114 @@ +# PBKDF2 +# From RFC 6070 - PBKDF2 with HMAC SHA-1 +# SHA2 from https://github.com/brycx/Test-Vector-Generation/blob/master/PBKDF2/pbkdf2-hmac-sha2-test-vectors.md +# and RFC 7914 scrypt + +# Test Case 1 +Hash = SHA256 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 1 +dkLen = 20 +DK = 120fb6cffcf8b32c43e7225256c4f837a86548c9 + +# Test Case 2 +Hash = SHA256 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 2 +dkLen = 20 +DK = ae4d0c95af6b46d32d0adff928f06dd02a303f8e + +# Test Case 3 +Hash = SHA256 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 4096 +dkLen = 20 +DK = c5e478d59288c841aa530db6845c4c8d962893a0 + +# Test Case 4 +Hash = SHA256 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 16777216 +dkLen = 20 +DK = cf81c66fe8cfc04d1f31ecb65dab4089f7f179e8 + +# Test Case 5 +Hash = SHA224 +Plen = 24 +Slen = 36 +P = "passwordPASSWORDpassword" +S = "saltSALTsaltSALTsaltSALTsaltSALTsalt" +c = 4096 +dkLen = 25 +DK = 348c89dbcbd32b2f32d814b8116e84cf2b17347ebc1800181c + +# Test Case 6 +Hash = SHA224 +Plen = 9 +Slen = 5 +P = "pass\0word" +S = "sa\0lt" +c = 4096 +dkLen = 16 +DK = 89b69d0516f829893c696226650a8687 + +# Test Case 7 +Hash = SHA224 +Plen = 6 +Slen = 4 +P = "passwd" +S = "salt" +c = 1 +dkLen = 128 +DK = 55ac046e56e3089fec1691c22544b605f94185216dde0465e68b9d57c20dacbc49ca9cccf179b645991664b39d77ef317c71b845b1e30bd509112041d3a19783c294e850150390e1160c34d62e9665d659ae49d314510fc98274cc79681968104b8f89237e69b2d549111868658be62f59bd715cac44a1147ed5317c9bae6b2a + +# Test Case 8 +Hash = SHA224 +Plen = 8 +Slen = 4 +P = "Password" +S = "NaCl" +c = 80000 +dkLen = 128 +DK = 4ddcd8f60b98be21830cee5ef22701f9641a4418d04c0414aeff08876b34ab56a1d425a1225833549adb841b51c9b3176a272bdebba1d078478f62b397f33c8d62aae85a11cdde829d89cb6ffd1ab0e63a981f8747d2f2f9fe5874165c83c168d2eed1d2d5ca4052dec2be5715623da019b8c0ec87dc36aa751c38f9893d15c3 + +# Test Case 9 +Hash = SHA224 +Plen = 8 +Slen = 4 +P = "Password" +S = "sa\0lt" +c = 4096 +dkLen = 256 +DK = 436c82c6af9010bb0fdb274791934ac7dee21745dd11fb57bb90112ab187c495ad82df776ad7cefb606f34fedca59baa5922a57f3e91bc0e11960da7ec87ed0471b456a0808b60dff757b7d313d4068bf8d337a99caede24f3248f87d1bf16892b70b076a07dd163a8a09db788ae34300ff2f2d0a92c9e678186183622a636f4cbce15680dfea46f6d224e51c299d4946aa2471133a649288eef3e4227b609cf203dba65e9fa69e63d35b6ff435ff51664cbd6773d72ebc341d239f0084b004388d6afa504eee6719a7ae1bb9daf6b7628d851fab335f1d13948e8ee6f7ab033a32df447f8d0950809a70066605d6960847ed436fa52cdfbcf261b44d2a87061 + +# RFC 7914 Test Case 1 +Hash = SHA256 +Plen = 6 +Slen = 4 +P = "passwd" +S = "salt" +c = 1 +dkLen = 64 +DK = 55ac046e56e3089fec1691c22544b605f94185216dde0465e68b9d57c20dacbc49ca9cccf179b645991664b39d77ef317c71b845b1e30bd509112041d3a19783 + +# RFC 7914 Test Case 2 +Hash = SHA256 +Plen = 8 +Slen = 4 +P = "Password" +S = "NaCl" +c = 80000 +dkLen = 64 +DK = 4ddcd8f60b98be21830cee5ef22701f9641a4418d04c0414aeff08876b34ab56a1d425a1225833549adb841b51c9b3176a272bdebba1d078478f62b397f33c8d ADDED tests/test_vectors/KDF/PBKDF2-SHA384.test Index: tests/test_vectors/KDF/PBKDF2-SHA384.test ================================================================== --- /dev/null +++ tests/test_vectors/KDF/PBKDF2-SHA384.test @@ -0,0 +1,63 @@ +# Auto generated from "PBKDF2-SHA384.txt" +package require tls +package require tcltest + +tcltest::testConstraint PBKDF2 [expr {[lsearch -nocase [tls::kdfs] PBKDF2] > -1}] + +tcltest::test KDF_PBKDF2-SHA384-1.1 {PBKDF2-SHA384} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA384 -password "password" -salt "salt" -iterations 1 -size 20]} \ + -match exact -result c0e14f06e49e32d73f9f52ddf1d0c5c719160923 + +tcltest::test KDF_PBKDF2-SHA384-1.2 {PBKDF2-SHA384} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA384 -password "password" -salt "salt" -iterations 2 -size 20]} \ + -match exact -result 54f775c6d790f21930459162fc535dbf04a93918 + +tcltest::test KDF_PBKDF2-SHA384-1.3 {PBKDF2-SHA384} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA384 -password "password" -salt "salt" -iterations 4096 -size 20]} \ + -match exact -result 559726be38db125bc85ed7895f6e3cf574c7a01c + +tcltest::test KDF_PBKDF2-SHA384-1.4 {PBKDF2-SHA384} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA384 -password "password" -salt "salt" -iterations 16777216 -size 20]} \ + -match exact -result a7fdb349ba2bfa6bf647bb0161bae1320df27e64 + +tcltest::test KDF_PBKDF2-SHA384-1.5 {PBKDF2-SHA384} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA384 -password "passwordPASSWORDpassword" -salt "saltSALTsaltSALTsaltSALTsaltSALTsalt" -iterations 4096 -size 25]} \ + -match exact -result 819143ad66df9a552559b9e131c52ae6c5c1b0eed18f4d283b + +tcltest::test KDF_PBKDF2-SHA384-1.6 {PBKDF2-SHA384} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA384 -password "pass\0word" -salt "sa\0lt" -iterations 4096 -size 16]} \ + -match exact -result a3f00ac8657e095f8e0823d232fc60b3 + +tcltest::test KDF_PBKDF2-SHA384-1.7 {PBKDF2-SHA384} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA384 -password "passwd" -salt "salt" -iterations 1 -size 128]} \ + -match exact -result cd3443723a41cf1460cca9efeede428a8898a82d2ad4d1fc5cca08ed3f4d3cb47a62a70b3cb9ce65dcbfb9fb9d425027a8be69b53e2a22674b0939e5e0a682f76d21f449ad184562a3bc4c519b4d048de6d8e0999fb88770f95e40185e19fc8b68767417ccc064f47a455d045b3bafda7e81b97ad0e4c5581af1aa27871cd5e4 + +tcltest::test KDF_PBKDF2-SHA384-1.8 {PBKDF2-SHA384} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA384 -password "Password" -salt "NaCl" -iterations 80000 -size 128]} \ + -match exact -result 11c198987730fa113458053cd5cc9b51d7024a35f9134f1ee8740923c901aab23bbaea43686981b6e6a9f4130a1401daeeec74060246ebac958f3cfc3c65579b6e3d08b94ade5fc257a6902a0a1664b8dbd5a8ae2af70438931d3f3679abffc7a17770582f1ee413cc0d9914ce5f8143c8a7dc9c43fbc31e3d41b2030fb73c02 + +tcltest::test KDF_PBKDF2-SHA384-1.9 {PBKDF2-SHA384} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA384 -password "Password" -salt "sa\0lt" -iterations 4096 -size 256]} \ + -match exact -result cf6f194aaf4e970afea1f41169045029e34759e124a670b5f73053da552a190ad2d7085533b8b22901f0e3caeeb431ba673468f981352dfcbe517699db791777cf52346a460b093c59ea300fb18daee270e2ea8473806da1663cebe7438b51fe56ba832c13d88ad5b2e46404457c34cc6ad8e5cd8707a1acfa737f3617628a5983d8d10fa16a92652cfa736d4610132710a517c216cc3252e6c2b8aae0275d04a49756fa5bf1bb067bc367d1b8c80c3df7dc22ee74b4be4150871624bfdde3f86f5fbd4e0828af7d5a4f01b5605e54471435d827eaecf199db315ae60d1a6350105c0e1a71b40518a4a66ebba4792a511f8f52aeac961ebea215f8fb89ba998b + +# Cleanup +::tcltest::cleanupTests +return ADDED tests/test_vectors/KDF/PBKDF2-SHA384.txt Index: tests/test_vectors/KDF/PBKDF2-SHA384.txt ================================================================== --- /dev/null +++ tests/test_vectors/KDF/PBKDF2-SHA384.txt @@ -0,0 +1,93 @@ +# PBKDF2 +# From RFC 6070 - PBKDF2 with HMAC SHA-1 +# SHA2 from https://github.com/brycx/Test-Vector-Generation/blob/master/PBKDF2/pbkdf2-hmac-sha2-test-vectors.md + +# Test Case 1 +Hash = SHA384 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 1 +dkLen = 20 +DK = c0e14f06e49e32d73f9f52ddf1d0c5c719160923 + +# Test Case 2 +Hash = SHA384 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 2 +dkLen = 20 +DK = 54f775c6d790f21930459162fc535dbf04a93918 + +# Test Case 3 +Hash = SHA384 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 4096 +dkLen = 20 +DK = 559726be38db125bc85ed7895f6e3cf574c7a01c + +# Test Case 4 +Hash = SHA384 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 16777216 +dkLen = 20 +DK = a7fdb349ba2bfa6bf647bb0161bae1320df27e64 + +# Test Case 5 +Hash = SHA384 +Plen = 24 +Slen = 36 +P = "passwordPASSWORDpassword" +S = "saltSALTsaltSALTsaltSALTsaltSALTsalt" +c = 4096 +dkLen = 25 +DK = 819143ad66df9a552559b9e131c52ae6c5c1b0eed18f4d283b + +# Test Case 6 +Hash = SHA384 +Plen = 9 +Slen = 5 +P = "pass\0word" +S = "sa\0lt" +c = 4096 +dkLen = 16 +DK = a3f00ac8657e095f8e0823d232fc60b3 + +# Test Case 7 +Hash = SHA384 +Plen = 6 +Slen = 4 +P = "passwd" +S = "salt" +c = 1 +dkLen = 128 +DK = cd3443723a41cf1460cca9efeede428a8898a82d2ad4d1fc5cca08ed3f4d3cb47a62a70b3cb9ce65dcbfb9fb9d425027a8be69b53e2a22674b0939e5e0a682f76d21f449ad184562a3bc4c519b4d048de6d8e0999fb88770f95e40185e19fc8b68767417ccc064f47a455d045b3bafda7e81b97ad0e4c5581af1aa27871cd5e4 + +# Test Case 8 +Hash = SHA384 +Plen = 6 +Slen = 4 +P = "Password" +S = "NaCl" +c = 80000 +dkLen = 128 +DK = 11c198987730fa113458053cd5cc9b51d7024a35f9134f1ee8740923c901aab23bbaea43686981b6e6a9f4130a1401daeeec74060246ebac958f3cfc3c65579b6e3d08b94ade5fc257a6902a0a1664b8dbd5a8ae2af70438931d3f3679abffc7a17770582f1ee413cc0d9914ce5f8143c8a7dc9c43fbc31e3d41b2030fb73c02 + +# Test Case 9 +Hash = SHA384 +Plen = 6 +Slen = 4 +P = "Password" +S = "sa\0lt" +c = 4096 +dkLen = 256 +DK = cf6f194aaf4e970afea1f41169045029e34759e124a670b5f73053da552a190ad2d7085533b8b22901f0e3caeeb431ba673468f981352dfcbe517699db791777cf52346a460b093c59ea300fb18daee270e2ea8473806da1663cebe7438b51fe56ba832c13d88ad5b2e46404457c34cc6ad8e5cd8707a1acfa737f3617628a5983d8d10fa16a92652cfa736d4610132710a517c216cc3252e6c2b8aae0275d04a49756fa5bf1bb067bc367d1b8c80c3df7dc22ee74b4be4150871624bfdde3f86f5fbd4e0828af7d5a4f01b5605e54471435d827eaecf199db315ae60d1a6350105c0e1a71b40518a4a66ebba4792a511f8f52aeac961ebea215f8fb89ba998b ADDED tests/test_vectors/KDF/PBKDF2-SHA512.test Index: tests/test_vectors/KDF/PBKDF2-SHA512.test ================================================================== --- /dev/null +++ tests/test_vectors/KDF/PBKDF2-SHA512.test @@ -0,0 +1,63 @@ +# Auto generated from "PBKDF2-SHA512.txt" +package require tls +package require tcltest + +tcltest::testConstraint PBKDF2 [expr {[lsearch -nocase [tls::kdfs] PBKDF2] > -1}] + +tcltest::test KDF_PBKDF2-SHA512-1.1 {PBKDF2-SHA512} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA512 -password "password" -salt "salt" -iterations 1 -size 20]} \ + -match exact -result 867f70cf1ade02cff3752599a3a53dc4af34c7a6 + +tcltest::test KDF_PBKDF2-SHA512-1.2 {PBKDF2-SHA512} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA512 -password "password" -salt "salt" -iterations 2 -size 20]} \ + -match exact -result e1d9c16aa681708a45f5c7c4e215ceb66e011a2e + +tcltest::test KDF_PBKDF2-SHA512-1.3 {PBKDF2-SHA512} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA512 -password "password" -salt "salt" -iterations 4096 -size 20]} \ + -match exact -result d197b1b33db0143e018b12f3d1d1479e6cdebdcc + +tcltest::test KDF_PBKDF2-SHA512-1.4 {PBKDF2-SHA512} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA512 -password "password" -salt "salt" -iterations 16777216 -size 20]} \ + -match exact -result 6180a3ceabab45cc3964112c811e0131bca93a35 + +tcltest::test KDF_PBKDF2-SHA512-1.5 {PBKDF2-SHA512} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA512 -password "passwordPASSWORDpassword" -salt "saltSALTsaltSALTsaltSALTsaltSALTsalt" -iterations 4096 -size 25]} \ + -match exact -result 8c0511f4c6e597c6ac6315d8f0362e225f3c501495ba23b868 + +tcltest::test KDF_PBKDF2-SHA512-1.6 {PBKDF2-SHA512} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA512 -password "pass\0word" -salt "sa\0lt" -iterations 4096 -size 16]} \ + -match exact -result 9d9e9c4cd21fe4be24d5b8244c759665 + +tcltest::test KDF_PBKDF2-SHA512-1.7 {PBKDF2-SHA512} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA512 -password "passwd" -salt "salt" -iterations 1 -size 128]} \ + -match exact -result c74319d99499fc3e9013acff597c23c5baf0a0bec5634c46b8352b793e324723d55caa76b2b25c43402dcfdc06cdcf66f95b7d0429420b39520006749c51a04ef3eb99e576617395a178ba33214793e48045132928a9e9bf2661769fdc668f31798597aaf6da70dd996a81019726084d70f152baed8aafe2227c07636c6ddece + +tcltest::test KDF_PBKDF2-SHA512-1.8 {PBKDF2-SHA512} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA512 -password "Password" -salt "NaCl" -iterations 80000 -size 128]} \ + -match exact -result e6337d6fbeb645c794d4a9b5b75b7b30dac9ac50376a91df1f4460f6060d5addb2c1fd1f84409abacc67de7eb4056e6bb06c2d82c3ef4ccd1bded0f675ed97c65c33d39f81248454327aa6d03fd049fc5cbb2b5e6dac08e8ace996cdc960b1bd4530b7e754773d75f67a733fdb99baf6470e42ffcb753c15c352d4800fb6f9d6 + +tcltest::test KDF_PBKDF2-SHA512-1.9 {PBKDF2-SHA512} \ + -constraints PBKDF2 \ + -setup {} \ + -body {binary encode hex [tls::pbkdf2 -digest SHA512 -password "Password" -salt "sa\0lt" -iterations 4096 -size 256]} \ + -match exact -result 10176fb32cb98cd7bb31e2bb5c8f6e425c103333a2e496058e3fd2bd88f657485c89ef92daa0668316bc23ebd1ef88f6dd14157b2320b5d54b5f26377c5dc279b1dcdec044bd6f91b166917c80e1e99ef861b1d2c7bce1b961178125fb86867f6db489a2eae0022e7bc9cf421f044319fac765d70cb89b45c214590e2ffb2c2b565ab3b9d07571fde0027b1dc57f8fd25afa842c1056dd459af4074d7510a0c020b914a5e202445d4d3f151070589dd6a2554fc506018c4f001df6239643dc86771286ae4910769d8385531bba57544d63c3640b90c98f1445ebdd129475e02086b600f0beb5b05cc6ca9b3633b452b7dad634e9336f56ec4c3ac0b4fe54ced8 + +# Cleanup +::tcltest::cleanupTests +return ADDED tests/test_vectors/KDF/PBKDF2-SHA512.txt Index: tests/test_vectors/KDF/PBKDF2-SHA512.txt ================================================================== --- /dev/null +++ tests/test_vectors/KDF/PBKDF2-SHA512.txt @@ -0,0 +1,94 @@ +# PBKDF2 +# From RFC 6070 - PBKDF2 with HMAC SHA-1 +# SHA2 from https://github.com/brycx/Test-Vector-Generation/blob/master/PBKDF2/pbkdf2-hmac-sha2-test-vectors.md + +# Test Case 1 +Hash = SHA512 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 1 +dkLen = 20 +DK = 867f70cf1ade02cff3752599a3a53dc4af34c7a6 + +# Test Case 2 +Hash = SHA512 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 2 +dkLen = 20 +DK = e1d9c16aa681708a45f5c7c4e215ceb66e011a2e + +# Test Case 3 +Hash = SHA512 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 4096 +dkLen = 20 +DK = d197b1b33db0143e018b12f3d1d1479e6cdebdcc + +# Test Case 4 +Hash = SHA512 +Plen = 8 +Slen = 4 +P = "password" +S = "salt" +c = 16777216 +dkLen = 20 +DK = 6180a3ceabab45cc3964112c811e0131bca93a35 + +# Test Case 5 +Hash = SHA512 +Plen = 24 +Slen = 36 +P = "passwordPASSWORDpassword" +S = "saltSALTsaltSALTsaltSALTsaltSALTsalt" +c = 4096 +dkLen = 25 +DK = 8c0511f4c6e597c6ac6315d8f0362e225f3c501495ba23b868 + +# Test Case 6 +Hash = SHA512 +Plen = 9 +Slen = 5 +P = "pass\0word" +S = "sa\0lt" +c = 4096 +dkLen = 16 +DK = 9d9e9c4cd21fe4be24d5b8244c759665 + +# Test Case 7 +Hash = SHA512 +Plen = 6 +Slen = 4 +P = "passwd" +S = "salt" +c = 1 +dkLen = 128 +DK = c74319d99499fc3e9013acff597c23c5baf0a0bec5634c46b8352b793e324723d55caa76b2b25c43402dcfdc06cdcf66f95b7d0429420b39520006749c51a04ef3eb99e576617395a178ba33214793e48045132928a9e9bf2661769fdc668f31798597aaf6da70dd996a81019726084d70f152baed8aafe2227c07636c6ddece + +# Test Case 8 +Hash = SHA512 +Plen = 6 +Slen = 4 +P = "Password" +S = "NaCl" +c = 80000 +dkLen = 128 +DK = e6337d6fbeb645c794d4a9b5b75b7b30dac9ac50376a91df1f4460f6060d5addb2c1fd1f84409abacc67de7eb4056e6bb06c2d82c3ef4ccd1bded0f675ed97c65c33d39f81248454327aa6d03fd049fc5cbb2b5e6dac08e8ace996cdc960b1bd4530b7e754773d75f67a733fdb99baf6470e42ffcb753c15c352d4800fb6f9d6 + +# Test Case 9 +Hash = SHA512 +Plen = 6 +Slen = 4 +P = "Password" +S = "sa\0lt" +c = 4096 +dkLen = 256 +DK = 10176fb32cb98cd7bb31e2bb5c8f6e425c103333a2e496058e3fd2bd88f657485c89ef92daa0668316bc23ebd1ef88f6dd14157b2320b5d54b5f26377c5dc279b1dcdec044bd6f91b166917c80e1e99ef861b1d2c7bce1b961178125fb86867f6db489a2eae0022e7bc9cf421f044319fac765d70cb89b45c214590e2ffb2c2b565ab3b9d07571fde0027b1dc57f8fd25afa842c1056dd459af4074d7510a0c020b914a5e202445d4d3f151070589dd6a2554fc506018c4f001df6239643dc86771286ae4910769d8385531bba57544d63c3640b90c98f1445ebdd129475e02086b600f0beb5b05cc6ca9b3633b452b7dad634e9336f56ec4c3ac0b4fe54ced8 + ADDED tests/test_vectors/KDF/Scrypt.test Index: tests/test_vectors/KDF/Scrypt.test ================================================================== --- /dev/null +++ tests/test_vectors/KDF/Scrypt.test @@ -0,0 +1,33 @@ +# Auto generated from "Scrypt.txt" +package require tls +package require tcltest + +tcltest::testConstraint Scrypt [expr {[lsearch -nocase [tls::kdfs] Scrypt] > -1}] + +tcltest::test KDF_Scrypt-1.1 {Scrypt} \ + -constraints Scrypt \ + -setup {} \ + -body {binary encode hex [tls::scrypt -password "" -salt "" -size 64 -N 16 -r 1 -p 1]} \ + -match exact -result 77d6576238657b203b19ca42c18a0497f16b4844e3074ae8dfdffa3fede21442fcd0069ded0948f8326a753a0fc81f17e8d3e0fb2e0d3628cf35e20c38d18906 + +tcltest::test KDF_Scrypt-1.2 {Scrypt} \ + -constraints Scrypt \ + -setup {} \ + -body {binary encode hex [tls::scrypt -password "password" -salt "NaCl" -size 64 -N 1024 -r 8 -p 16]} \ + -match exact -result fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b3731622eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640 + +tcltest::test KDF_Scrypt-1.3 {Scrypt} \ + -constraints Scrypt \ + -setup {} \ + -body {binary encode hex [tls::scrypt -password "pleaseletmein" -salt "SodiumChloride" -size 64 -N 16384 -r 8 -p 1]} \ + -match exact -result 7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2d5432955613f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887 + +tcltest::test KDF_Scrypt-1.4 {Scrypt} \ + -constraints Scrypt \ + -setup {} \ + -body {binary encode hex [tls::scrypt -password "pleaseletmein" -salt "SodiumChloride" -size 64 -N 1048576 -r 8 -p 1]} \ + -match exact -result 2101cb9b6a511aaeaddbbe09cf70f881ec568d574a2ffd4dabe5ee9820adaa478e56fd8f4ba5d09ffa1c6d927c40f4c337304049e8a952fbcbf45c6fa77a41a4 + +# Cleanup +::tcltest::cleanupTests +return ADDED tests/test_vectors/KDF/Scrypt.txt Index: tests/test_vectors/KDF/Scrypt.txt ================================================================== --- /dev/null +++ tests/test_vectors/KDF/Scrypt.txt @@ -0,0 +1,47 @@ +# scrypt +# From RFC 7914 scrypt + +# Test Case 1 +Plen = 0 +Slen = 0 +P = "" +S = "" +N = 16 +r = 1 +p = 1 +dkLen = 64 +DK = 77d6576238657b203b19ca42c18a0497f16b4844e3074ae8dfdffa3fede21442fcd0069ded0948f8326a753a0fc81f17e8d3e0fb2e0d3628cf35e20c38d18906 + +# Test Case 2 +Plen = 8 +Slen = 4 +P = "password" +S = "NaCl" +N = 1024 +r = 8 +p = 16 +dkLen = 64 +DK = fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b3731622eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640 + +# Test Case 3 +Plen = 13 +Slen = 14 +P = "pleaseletmein" +S = "SodiumChloride" +N = 16384 +r = 8 +p = 1 +dkLen = 64 +DK = 7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2d5432955613f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887 + +# Test Case 4 +Plen = 13 +Slen = 14 +P = "pleaseletmein" +S = "SodiumChloride" +N = 1048576 +r = 8 +p = 1 +dkLen = 64 +DK = 2101cb9b6a511aaeaddbbe09cf70f881ec568d574a2ffd4dabe5ee9820adaa478e56fd8f4ba5d09ffa1c6d927c40f4c337304049e8a952fbcbf45c6fa77a41a4 + ADDED tests/test_vectors/KDF/make_test.tcl Index: tests/test_vectors/KDF/make_test.tcl ================================================================== --- /dev/null +++ tests/test_vectors/KDF/make_test.tcl @@ -0,0 +1,160 @@ +# +# Test Vectors +# + +# +# Create test case and output to test file +# +proc do_test {group tail file_num tc kdf digest params} { + array set config $params + + # Test info + set line [format "tcltest::test %s-%d.%d {%s}" $group $file_num $tc $tail] + append line " \\\n\t" + + # Test constraints + append line [format "-constraints %s" $kdf] + append line " \\\n\t" + + # Test setup + append line "-setup {} \\\n\t" + + # Test body parameters + set cmd [format "tls::%s" [string tolower $kdf]] + if {$digest ne ""} { + append cmd " -digest " $digest + } + foreach {param names type} [list -key [list IKM Key key] s -info [list I info] s -password [list P] s \ + -salt [list S salt] s -iterations [list c] i -size [list L dkLen dklen] i \ + -N [list N] i -r [list r] i -p [list p] i] { + foreach name $names { + if {[info exists config($name)]} { + set data $config($name) + # Handle hex string + if {$type eq "s" && [string length $data] > 0 && [string index $data 0] ne "\""} { + set data [format {[binary decode hex %s]} $data] + } + if {[string length $data] > 0} { + append cmd " " $param " " $data + } + } + } + } + + # Test body + append line "-body \{binary encode hex \[" $cmd "\]\} \\\n\t" + + # Test cleanup + #append line "-cleanup {} \\n\t" + + # Test result + set result "" + foreach name [list OKM DK Output] { + if {[info exists config($name)]} { + set result $config($name) + } + } + + append line [format {-match exact -result %s} $result] + + # Return codes + #append line { -returnCodes 0} + return $line +} + +# +# Parse test vector file and get test cases config info +# +proc parse {group filename file_num} { + set tc 0 + + # Open input file + if {[catch {open $filename r} ch]} { + return -code error $ch + } + set tail [file rootname [file tail $filename]] + + # Open output file + if {[catch {open [format "%s.test" [file rootname $filename]] w} out]} { + return -code error $ch + } + + # Get digest + lassign [split [string map [list "_" "-"] $tail] "-"] kdf digest + set params [list] + + # Add config info + puts $out [format "# Auto generated from \"%s\"" [file tail $filename]] + puts $out "package require tls" + puts $out "package require tcltest\n" + puts $out [format "tcltest::testConstraint %s %s" $kdf \ + [format {[expr {[lsearch -nocase [tls::kdfs] %s] > -1}]} $kdf]] + puts $out "" + + # Process file + while {![eof $ch]} { + gets $ch line + set line [string trim $line] + set len [string length $line] + + if {[string index $line 0] in [list "#" "\["]} { + # Skip comments and info lines + continue + + } elseif {$len == 0} { + if {[llength $params] > 0} { + # Do test if end of params + puts $out [do_test $group $tail $file_num [incr tc] $kdf $digest $params] + puts $out "" + set params [list] + } else { + # Empty line + } + + } else { + # Append args to params + set index [string first "=" $line] + if {$index > -1} { + set key [string trim [string range $line 0 [expr {$index - 1}]]] + set value [string trim [string range $line [expr {$index + 1}] end]] + lappend params $key $value + } + } + } + + # Handle last test case + if {[llength $params] > 0} { + puts $out [do_test $group $tail $file_num [incr tc] $kdf $digest $params] + puts $out "" + } + + # Cleanup + puts $out "# Cleanup\n::tcltest::cleanupTests\nreturn" + close $ch + close $out +} + +# +# Read all config files in directory +# +proc main {path} { + set file_num 0 + set group [file rootname [file tail $path]] + + foreach filename [glob -directory $path *.txt *ShortMsg.rsp *LongMsg.rsp] { + puts [format "Processing %s" $filename] + set tail [file tail $filename] + if {[string match -nocase "Readme.txt" $tail] || [string match -nocase "*Monte.txt" $tail]} { + continue + } + + set tail [file rootname [file tail $filename]] + set digest [string map [list LongMsg "" ShortMsg "" Monte "" "_" "-"] $tail] + set id [format "%s_%s" $group $digest] + set test_num [incr test_ids($id)] + parse $id $filename $test_num + } +} + +main [pwd] +exit