Skip to content

Commit

Permalink
Remove X25519 scalar mult test
Browse files Browse the repository at this point in the history
This was equivalent in operation to the standard X25519 key agreement
test, just in a different format. Move the test data there.
  • Loading branch information
randombit committed Apr 12, 2024
1 parent a7d0ae6 commit 81db0c6
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 100 deletions.
79 changes: 0 additions & 79 deletions src/tests/data/pubkey/c25519_scalar.vec

This file was deleted.

78 changes: 78 additions & 0 deletions src/tests/data/pubkey/x25519.vec
Original file line number Diff line number Diff line change
Expand Up @@ -361,3 +361,81 @@ Secret = 58083dd261ad91eff952322ec824c682ffffffffffffffffffffffffffffff5f
CounterKey = 2eae5ec3dd494e9f2d37d258f873a8e6e9d0dbd1e383ef64d98bb91b3e0be035
K = 2eae5ec3dd494e9f2d37d258f873a8e6e9d0dbd1e383ef64d98bb91b3e0be035

# scalarmult1 from libsodium
Secret = 77076D0A7318A57D3C16C17251B26645DF4C2F87EBC0992AB177FBA51DB92C2A
CounterKey = 0900000000000000000000000000000000000000000000000000000000000000
K = 8520F0098930A754748B7DDCB43EF75A0DBF3A0D26381AF4EBA4A98EAA9B4E6A

# scalarmult2
Secret = 5DAB087E624A8A4B79E17F8B83800EE66F3BB1292618B6FD1C2F8B27FF88E0EB
CounterKey = 0900000000000000000000000000000000000000000000000000000000000000
K = DE9EDB7D7B7DC1B4D35B61C2ECE435373F8343C85B78674DADFC7E146F882B4F

# scalarmult5
Secret = 77076D0A7318A57D3C16C17251B26645DF4C2F87EBC0992AB177FBA51DB92C2A
CounterKey = DE9EDB7D7B7DC1B4D35B61C2ECE435373F8343C85B78674DADFC7E146F882B4F
K = 4A5D9D5BA4CE2DE1728E3BF480350F25E07E21C947D19E3376F09B3C1E161742

# scalarmult6
Secret = 5DAB087E624A8A4B79E17F8B83800EE66F3BB1292618B6FD1C2F8B27FF88E0EB
CounterKey = 8520F0098930A754748B7DDCB43EF75A0DBF3A0D26381AF4EBA4A98EAA9B4E6A
K = 4A5D9D5BA4CE2DE1728E3BF480350F25E07E21C947D19E3376F09B3C1E161742

# test-noncanon from donna
Secret = 0100000000000000000000000000000000000000000000000000000000000000
CounterKey = 2500000000000000000000000000000000000000000000000000000000000000
K = 3C7777CAF997B264416077665B4E229D0B9548DC0CD81998DDCDC5C8533C797F

Secret = 0100000000000000000000000000000000000000000000000000000000000000
CounterKey = FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
K = B32D1362C248D62FE62619CFF04DD43DB73FFC1B6308EDE30B78D87380F1E834

# Following values generated at random by curve25519-donna

Secret = D55FF01DA1262795A4E50E607F87B80DCCD447A6EE0F6CD8D25177F79575744D
CounterKey = 0900000000000000000000000000000000000000000000000000000000000000
K = D5BDC7055ABA7855692CC861009E3AE6B6339329826B11F8B92E5ADAEB85335E

Secret = 0224D9367436089D81B1150DFC748EC851F9A41389E21C8C1181E01BA1760C23
CounterKey = 0900000000000000000000000000000000000000000000000000000000000000
K = AD7E1E41C6AC0544F949EB76D71C75120ADD345C44384BDD830974D2DD329644

Secret = D55FF01DA1262795A4E50E607F87B80DCCD447A6EE0F6CD8D25177F79575744D
CounterKey = AD7E1E41C6AC0544F949EB76D71C75120ADD345C44384BDD830974D2DD329644
K = FC343E1965225D8666F4AE8E70E04039D21C603F7CE7F17C0CC8440C62C03575

Secret = 0224D9367436089D81B1150DFC748EC851F9A41389E21C8C1181E01BA1760C23
CounterKey = D5BDC7055ABA7855692CC861009E3AE6B6339329826B11F8B92E5ADAEB85335E
K = FC343E1965225D8666F4AE8E70E04039D21C603F7CE7F17C0CC8440C62C03575

Secret = 65A06F749B010EA5738CDEBE3EF65F38C17A13F8CCC5B0AE51B5091D845C6DEB
CounterKey = 0900000000000000000000000000000000000000000000000000000000000000
K = B84AEDDA6C2CD17CCB62D94E3238E7093BA77D15BE4C563D1B11EA3C2EECA87F

Secret = 92B158501611EF8521C101E28629130427B42D2DA65E9EC9387B94BC2F08B806
CounterKey = 0900000000000000000000000000000000000000000000000000000000000000
K = 06479EC3C771D635F54787DEA334149E07E20957127C816E3059258428C17970

Secret = 65A06F749B010EA5738CDEBE3EF65F38C17A13F8CCC5B0AE51B5091D845C6DEB
CounterKey = 06479EC3C771D635F54787DEA334149E07E20957127C816E3059258428C17970
K = 47C69389596EA49AEE14F4259250808385C37F4EBBD6AA176779BFEB8042D834

Secret = 92B158501611EF8521C101E28629130427B42D2DA65E9EC9387B94BC2F08B806
CounterKey = B84AEDDA6C2CD17CCB62D94E3238E7093BA77D15BE4C563D1B11EA3C2EECA87F
K = 47C69389596EA49AEE14F4259250808385C37F4EBBD6AA176779BFEB8042D834

Secret = 2D7B885AA77351153994425725F35AFB84D9729DECA3D9D832570569C973566E
CounterKey = 0900000000000000000000000000000000000000000000000000000000000000
K = 93928FCC20DFEA2AF6CA8B1268192B68D87FDA744FD67FCFAEF84165C504597C

Secret = E3B07D96E4B5F3D265ACFE950707B62B053F2FD5CCF20D662F62AB09ED2AC325
CounterKey = 0900000000000000000000000000000000000000000000000000000000000000
K = 68B7894FF03386C8C1907847866CD771519163D002FA7C3360650186A22F7263

Secret = 2D7B885AA77351153994425725F35AFB84D9729DECA3D9D832570569C973566E
CounterKey = 68B7894FF03386C8C1907847866CD771519163D002FA7C3360650186A22F7263
K = 0BE4BB615F362A21A28A404631F6832DD1019A7145C020031614D8B6F697983A

Secret = E3B07D96E4B5F3D265ACFE950707B62B053F2FD5CCF20D662F62AB09ED2AC325
CounterKey = 93928FCC20DFEA2AF6CA8B1268192B68D87FDA744FD67FCFAEF84165C504597C
K = 0BE4BB615F362A21A28A404631F6832DD1019A7145C020031614D8B6F697983A
21 changes: 0 additions & 21 deletions src/tests/test_x25519.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,6 @@ namespace Botan_Tests {

#if defined(BOTAN_HAS_X25519)

class X25519_Sclarmult_Tests final : public Text_Based_Test {
public:
X25519_Sclarmult_Tests() : Text_Based_Test("pubkey/c25519_scalar.vec", "Secret,Basepoint,Out") {}

Test::Result run_one_test(const std::string& /*header*/, const VarMap& vars) override {
Test::Result result("X25519 scalarmult");

const std::vector<uint8_t> secret = vars.get_req_bin("Secret");
const std::vector<uint8_t> basepoint = vars.get_req_bin("Basepoint");
const std::vector<uint8_t> expected = vars.get_req_bin("Out");

std::vector<uint8_t> got(32);
Botan::curve25519_donna(got.data(), secret.data(), basepoint.data());

result.test_eq("basemult", got, expected);
return result;
}
};

BOTAN_REGISTER_TEST("pubkey", "x25519_scalar", X25519_Sclarmult_Tests);

class X25519_Agreement_Tests final : public PK_Key_Agreement_Test {
public:
X25519_Agreement_Tests() : PK_Key_Agreement_Test("X25519", "pubkey/x25519.vec", "Secret,CounterKey,K") {}
Expand Down

0 comments on commit 81db0c6

Please sign in to comment.