diff options
author | René Korthaus <[email protected]> | 2016-12-20 18:29:00 +0100 |
---|---|---|
committer | René Korthaus <[email protected]> | 2017-01-02 10:39:37 +0100 |
commit | cea400532dde96207a383912060cf0a2f4a247f5 (patch) | |
tree | 206a082a1c41f5a21c311ef5d8795fd62ea9b673 /src/tests/test_dh.cpp | |
parent | 6e4bd1f365a98517397aa11a44006c9ebd934bec (diff) |
Add positive DH test vectors from NIST CAVP
Diffstat (limited to 'src/tests/test_dh.cpp')
-rw-r--r-- | src/tests/test_dh.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/tests/test_dh.cpp b/src/tests/test_dh.cpp index 93ac25cee..3b33a962d 100644 --- a/src/tests/test_dh.cpp +++ b/src/tests/test_dh.cpp @@ -25,7 +25,7 @@ class Diffie_Hellman_KAT_Tests : public PK_Key_Agreement_Test "Diffie-Hellman", "pubkey/dh.vec", "P,G,X,Y,Msg,OutLen,K", - "KDF") + "Q,KDF") {} std::string default_kdf(const VarMap&) const override { return "Raw"; } @@ -35,8 +35,17 @@ class Diffie_Hellman_KAT_Tests : public PK_Key_Agreement_Test const Botan::BigInt p = get_req_bn(vars, "P"); const Botan::BigInt g = get_req_bn(vars, "G"); const Botan::BigInt x = get_req_bn(vars, "X"); + const Botan::BigInt q = get_opt_bn(vars, "Q", 0); - const Botan::DL_Group grp(p, g); + Botan::DL_Group grp; + if(q == 0) + { + grp = Botan::DL_Group(p, g); + } + else + { + grp = Botan::DL_Group(p, q, g); + } std::unique_ptr<Botan::Private_Key> key(new Botan::DH_PrivateKey(Test::rng(), grp, x)); return key; |