Commit 957ec6cd authored by Michael Hamburg's avatar Michael Hamburg

restore shared secret benchmarks

parent f92d14e0
......@@ -63,7 +63,7 @@ public:
/** @brief Serialization size. */
inline size_t serSize() const NOEXCEPT { return SER_BYTES; }
/* TODO: verify_strobe? */
/* TODO: verify_strobe */
/** @brief Verify a message */
inline void verify(
......
......@@ -290,10 +290,10 @@ static void macro() {
printf("\nMacro-benchmarks for %s:\n", Group::name());
printf("Crypto benchmarks:\n");
SpongeRng rng(Block("macro rng seed"));
PublicKey<Group> p1((NOINIT())), p2((NOINIT()));
PrivateKey<Group> s1((NOINIT())), s2((NOINIT()));
PrivateKey<Group> s1((NOINIT())), s2(rng);
PublicKey<Group> p1((NOINIT())), p2(s2);
SecureBuffer message = rng.read(5), sig;
SecureBuffer message = rng.read(5), sig, ss;
for (Benchmark b("Create private key",1); b.iter(); ) {
s1 = PrivateKey<Group>(rng);
......@@ -310,6 +310,10 @@ static void macro() {
try { p1.verify(message, sig); } catch (CryptoException) {}
}
for (Benchmark b("SharedSecret",1); b.iter(); ) {
ss = s1.sharedSecret(p2,32,true);
}
printf("\nProtocol benchmarks:\n");
SpongeRng clientRng(Block("client rng seed"));
SpongeRng serverRng(Block("server rng seed"));
......
......@@ -335,7 +335,15 @@ static void test_crypto() {
SecureBuffer message = rng.read(i);
SecureBuffer sig(priv1.sign(message));
pub1.verify(message, sig);
SecureBuffer s1(priv1.sharedSecret(pub2,32,true));
SecureBuffer s2(priv2.sharedSecret(pub1,32,false));
if (memcmp(s1.data(),s2.data(),s1.size())) {
test.fail();
printf(" Shared secrets disagree.");
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment