aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRenĂ© Korthaus <[email protected]>2016-11-15 09:33:26 +0100
committerRenĂ© Korthaus <[email protected]>2016-11-15 09:33:26 +0100
commitb3ee964237bccf71bf0e75d725ae3118c8f91bf3 (patch)
tree3a2df22564ce58c53516d3c4178050aed825d478 /src
parentda497797cc7de2b64b63006a0108f785e4a360c1 (diff)
Add test vectors for HKDF-Expand and HKDF-Extract
Diffstat (limited to 'src')
-rw-r--r--src/lib/kdf/kdf.cpp4
-rw-r--r--src/tests/data/kdf/hkdf.vec162
2 files changed, 142 insertions, 24 deletions
diff --git a/src/lib/kdf/kdf.cpp b/src/lib/kdf/kdf.cpp
index 501f81717..e48a3463c 100644
--- a/src/lib/kdf/kdf.cpp
+++ b/src/lib/kdf/kdf.cpp
@@ -78,7 +78,7 @@ std::unique_ptr<KDF> KDF::create(const std::string& algo_spec,
}
}
- if(req.algo_name() == "HKDF_Extract" && req.arg_count() == 1)
+ if(req.algo_name() == "HKDF-Extract" && req.arg_count() == 1)
{
if(provider.empty() || provider == "base")
{
@@ -86,7 +86,7 @@ std::unique_ptr<KDF> KDF::create(const std::string& algo_spec,
}
}
- if(req.algo_name() == "HKDF_Expand" && req.arg_count() == 1)
+ if(req.algo_name() == "HKDF-Expand" && req.arg_count() == 1)
{
if(provider.empty() || provider == "base")
{
diff --git a/src/tests/data/kdf/hkdf.vec b/src/tests/data/kdf/hkdf.vec
index 64b7ad660..da63cd558 100644
--- a/src/tests/data/kdf/hkdf.vec
+++ b/src/tests/data/kdf/hkdf.vec
@@ -1,44 +1,43 @@
-# Data from RFC 5869
+# SHA-1 and SHA-256 data from RFC 5869
+# SHA-512 data from https://www.kullo.net/blog/hkdf-sha-512-test-vectors/
[HKDF(SHA-1)]
Salt = 000102030405060708090A0B0C
Label = F0F1F2F3F4F5F6F7F8F9
OutputLen = 42
-Secret = 0B0B0B0B0B0B0B0B0B0B0B
-Output = 085A01EA1B10F36933068B56EFA5AD81A4F14B822F5B091568A9CDD4F155FDA2C22E422478D305F3F896
+Secret = 0B0B0B0B0B0B0B0B0B0B0B
+Output = 085A01EA1B10F36933068B56EFA5AD81A4F14B822F5B091568A9CDD4F155FDA2C22E422478D305F3F896
Salt = 606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAF
Label = B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF
-OutputLen = 82
-Secret = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F
-Output = 0BD770A74D1160F7C9F12CD5912A06EBFF6ADCAE899D92191FE4305673BA2FFE8FA3F1A4E5AD79F3F334B3B202B2173C486EA37CE3D397ED034C7F9DFEB15C5E927336D0441F4C4300E2CFF0D0900B52D3B4
+OutputLen = 82
+Secret = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F
+Output = 0BD770A74D1160F7C9F12CD5912A06EBFF6ADCAE899D92191FE4305673BA2FFE8FA3F1A4E5AD79F3F334B3B202B2173C486EA37CE3D397ED034C7F9DFEB15C5E927336D0441F4C4300E2CFF0D0900B52D3B4
OutputLen = 42
-Secret = 0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B
-Output = 0AC1AF7002B3D761D1E55298DA9D0506B9AE52057220A306E07B6B87E8DF21D0EA00033DE03984D34918
+Secret = 0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B
+Output = 0AC1AF7002B3D761D1E55298DA9D0506B9AE52057220A306E07B6B87E8DF21D0EA00033DE03984D34918
-OutputLen = 42
-Secret = 0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C
-Output = 2C91117204D745F3500D636A62F64F0AB3BAE548AA53D423B0D1F27EBBA6F5E5673A081D70CCE7ACFC48
+OutputLen = 42
+Secret = 0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C
+Output = 2C91117204D745F3500D636A62F64F0AB3BAE548AA53D423B0D1F27EBBA6F5E5673A081D70CCE7ACFC48
[HKDF(SHA-256)]
Salt = 000102030405060708090A0B0C
Label = F0F1F2F3F4F5F6F7F8F9
-OutputLen = 42
-Secret = 0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B
-Output = 3CB25F25FAACD57A90434F64D0362F2A2D2D0A90CF1A5A4C5DB02D56ECC4C5BF34007208D5B887185865
+OutputLen = 42
+Secret = 0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B
+Output = 3CB25F25FAACD57A90434F64D0362F2A2D2D0A90CF1A5A4C5DB02D56ECC4C5BF34007208D5B887185865
Salt = 606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAF
Label = B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF
-OutputLen = 82
-Secret = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F
-Output = B11E398DC80327A1C8E7F78C596A49344F012EDA2D4EFAD8A050CC4C19AFA97C59045A99CAC7827271CB41C65E590E09DA3275600C2F09B8367793A9ACA3DB71CC30C58179EC3E87C14C01D5C1F3434F1D87
-
-OutputLen = 42
-Secret = 0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B
-Output = 8DA4E775A563C18F715F802A063C5A31B8A11F5C5EE1879EC3454E5F3C738D2D9D201395FAA4B61A96C8
+OutputLen = 82
+Secret = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F
+Output = B11E398DC80327A1C8E7F78C596A49344F012EDA2D4EFAD8A050CC4C19AFA97C59045A99CAC7827271CB41C65E590E09DA3275600C2F09B8367793A9ACA3DB71CC30C58179EC3E87C14C01D5C1F3434F1D87
-# From https://www.kullo.net/blog/hkdf-sha-512-test-vectors/
+OutputLen = 42
+Secret = 0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B
+Output = 8DA4E775A563C18F715F802A063C5A31B8A11F5C5EE1879EC3454E5F3C738D2D9D201395FAA4B61A96C8
[HKDF(SHA-512)]
Salt = 000102030405060708090A0B0C
@@ -66,3 +65,122 @@ Output = 7413E8997E020610FBF6823F2CE14BFF01875DB1CA55F68CFCF3954DC8AFF53559BD5E3
OutputLen = 42
Secret = 0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C
Output = 1407D46013D98BC6DECEFCFEE55F0F90B0C7F63D68EB1A80EAF07E953CFC0A3A5240A155D6E4DAA965BB
+
+[HKDF-Extract(SHA-1)]
+Salt = 000102030405060708090A0B0C
+OutputLen = 20
+Secret = 0B0B0B0B0B0B0B0B0B0B0B
+Output = 9B6C18C432A7BF8F0E71C8EB88F4B30BAA2BA243
+
+Salt = 606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAF
+OutputLen = 20
+Secret = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F
+Output = 8ADAE09A2A307059478D309B26C4115A224CFAF6
+
+OutputLen = 20
+Secret = 0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B
+Output = DA8C8A73C7FA77288EC6F5E7C297786AA0D32D01
+
+OutputLen = 20
+Secret = 0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C
+Output = 2ADCCADA18779E7C2077AD2EB19D3F3E731385DD
+
+[HKDF-Extract(SHA-256)]
+Salt = 000102030405060708090A0B0C
+OutputLen = 42
+Secret = 0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B
+Output = 077709362C2E32DF0DDC3F0DC47BBA6390B6C73BB50F9C3122EC844AD7C2B3E5
+
+Salt = 606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAF
+OutputLen = 82
+Secret = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F
+Output = 06A6B88C5853361A06104C9CEB35B45CEF760014904671014A193F40C15FC244
+
+IKM = 0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B
+OutputLen = 42
+Secret = 0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B
+Output = 19EF24A32C717B167F33A91D6F648BDF96596776AFDB6377AC434C1C293CCB04
+
+[HKDF-Extract(SHA-512)]
+Salt = 000102030405060708090A0B0C
+OutputLen = 64
+Secret = 0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B
+Output = 665799823737DED04A88E47E54A5890BB2C3D247C7A4254A8E61350723590A26C36238127D8661B88CF80EF802D57E2F7CEBCF1E00E083848BE19929C61B4237
+
+Salt = 606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAF
+OutputLen = 64
+Secret = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F
+Output = 35672542907D4E142C00E84499E74E1DE08BE86535F924E022804AD775DDE27EC86CD1E5B7D178C74489BDBEB30712BEB82D4F97416C5A94EA81EBDF3E629E4A
+
+OutputLen = 64
+Secret = 0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B
+Output = FD200C4987AC491313BD4A2A13287121247239E11C9EF82802044B66EF357E5B194498D0682611382348572A7B1611DE54764094286320578A863F36562B0DF6
+
+Salt = 000102030405060708090A0B0C
+OutputLen = 64
+Secret = 0B0B0B0B0B0B0B0B0B0B0B
+Output = 67409C9CAC28B52EE9FAD91C2FDA999F7CA22E3434F0AE772863836568AD6A7F10CF113BFDDD560129A594A8F52385C2D661D785D29CE93A11400C920683181D
+
+OutputLen = 64
+Secret = 0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C
+Output = 5346B376BF3AA9F84F8F6ED5B1C4F489172E244DAC303D12F68ECC766EA600AA88495E7FB605803122FA136924A840B1F0719D2D5F68E29B242299D758ED680C
+
+[HKDF-Expand(SHA-1)]
+IKM = 0B0B0B0B0B0B0B0B0B0B0B
+XTS = 000102030405060708090A0B0C
+Salt = F0F1F2F3F4F5F6F7F8F9
+OutputLen = 42
+Secret = 9B6C18C432A7BF8F0E71C8EB88F4B30BAA2BA243
+Output = 085A01EA1B10F36933068B56EFA5AD81A4F14B822F5B091568A9CDD4F155FDA2C22E422478D305F3F896
+
+Salt = B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF
+OutputLen = 82
+Secret = 8ADAE09A2A307059478D309B26C4115A224CFAF6
+Output = 0BD770A74D1160F7C9F12CD5912A06EBFF6ADCAE899D92191FE4305673BA2FFE8FA3F1A4E5AD79F3F334B3B202B2173C486EA37CE3D397ED034C7F9DFEB15C5E927336D0441F4C4300E2CFF0D0900B52D3B4
+
+OutputLen = 42
+Secret = DA8C8A73C7FA77288EC6F5E7C297786AA0D32D01
+Output = 0AC1AF7002B3D761D1E55298DA9D0506B9AE52057220A306E07B6B87E8DF21D0EA00033DE03984D34918
+
+OutputLen = 42
+Secret = 2ADCCADA18779E7C2077AD2EB19D3F3E731385DD
+Output = 2C91117204D745F3500D636A62F64F0AB3BAE548AA53D423B0D1F27EBBA6F5E5673A081D70CCE7ACFC48
+
+[HKDF-Expand(SHA-256)]
+Salt = F0F1F2F3F4F5F6F7F8F9
+OutputLen = 42
+Secret = 077709362C2E32DF0DDC3F0DC47BBA6390B6C73BB50F9C3122EC844AD7C2B3E5
+Output = 3CB25F25FAACD57A90434F64D0362F2A2D2D0A90CF1A5A4C5DB02D56ECC4C5BF34007208D5B887185865
+
+Salt = B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF
+OutputLen = 82
+Secret = 06A6B88C5853361A06104C9CEB35B45CEF760014904671014A193F40C15FC244
+Output = B11E398DC80327A1C8E7F78C596A49344F012EDA2D4EFAD8A050CC4C19AFA97C59045A99CAC7827271CB41C65E590E09DA3275600C2F09B8367793A9ACA3DB71CC30C58179EC3E87C14C01D5C1F3434F1D87
+
+OutputLen = 42
+Secret = 19EF24A32C717B167F33A91D6F648BDF96596776AFDB6377AC434C1C293CCB04
+Output = 8DA4E775A563C18F715F802A063C5A31B8A11F5C5EE1879EC3454E5F3C738D2D9D201395FAA4B61A96C8
+
+[HKDF-Expand(SHA-512)]
+Salt = F0F1F2F3F4F5F6F7F8F9
+OutputLen = 42
+Secret = 665799823737DED04A88E47E54A5890BB2C3D247C7A4254A8E61350723590A26C36238127D8661B88CF80EF802D57E2F7CEBCF1E00E083848BE19929C61B4237
+Output = 832390086CDA71FB47625BB5CEB168E4C8E26A1A16ED34D9FC7FE92C1481579338DA362CB8D9F925D7CB
+
+Salt = B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF
+OutputLen = 82
+Secret = 35672542907D4E142C00E84499E74E1DE08BE86535F924E022804AD775DDE27EC86CD1E5B7D178C74489BDBEB30712BEB82D4F97416C5A94EA81EBDF3E629E4A
+Output = CE6C97192805B346E6161E821ED165673B84F400A2B514B2FE23D84CD189DDF1B695B48CBD1C8388441137B3CE28F16AA64BA33BA466B24DF6CFCB021ECFF235F6A2056CE3AF1DE44D572097A8505D9E7A93
+
+OutputLen = 42
+Secret = FD200C4987AC491313BD4A2A13287121247239E11C9EF82802044B66EF357E5B194498D0682611382348572A7B1611DE54764094286320578A863F36562B0DF6
+Output = F5FA02B18298A72A8C23898A8703472C6EB179DC204C03425C970E3B164BF90FFF22D04836D0E2343BAC
+
+Salt = F0F1F2F3F4F5F6F7F8F9
+OutputLen = 42
+Secret = 67409C9CAC28B52EE9FAD91C2FDA999F7CA22E3434F0AE772863836568AD6A7F10CF113BFDDD560129A594A8F52385C2D661D785D29CE93A11400C920683181D
+Output = 7413E8997E020610FBF6823F2CE14BFF01875DB1CA55F68CFCF3954DC8AFF53559BD5E3028B080F7C068
+
+OutputLen = 42
+Secret = 5346B376BF3AA9F84F8F6ED5B1C4F489172E244DAC303D12F68ECC766EA600AA88495E7FB605803122FA136924A840B1F0719D2D5F68E29B242299D758ED680C
+Output = 1407D46013D98BC6DECEFCFEE55F0F90B0C7F63D68EB1A80EAF07E953CFC0A3A5240A155D6E4DAA965BB \ No newline at end of file