aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/ed25519/ed25519.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-06-20 21:11:49 -0400
committerJack Lloyd <[email protected]>2019-06-20 21:11:49 -0400
commit1643bb636febbbc375c8cbd294fa4309d608428f (patch)
treeaeeffbd50e484955ea998f225904cb44c021b228 /src/lib/pubkey/ed25519/ed25519.cpp
parentfaf77d28e2f33555a058372567bc646f9c014a36 (diff)
parent2b38ded27cc0f7883b8611db5b76fe677bbe2bc9 (diff)
Merge GH #2000 Add RFC 8032 compatible Ed25519ph
Diffstat (limited to 'src/lib/pubkey/ed25519/ed25519.cpp')
-rw-r--r--src/lib/pubkey/ed25519/ed25519.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/pubkey/ed25519/ed25519.cpp b/src/lib/pubkey/ed25519/ed25519.cpp
index b75028041..624f82657 100644
--- a/src/lib/pubkey/ed25519/ed25519.cpp
+++ b/src/lib/pubkey/ed25519/ed25519.cpp
@@ -34,8 +34,9 @@ void ed25519_gen_keypair(uint8_t* pk, uint8_t* sk, const uint8_t seed[32])
}
void ed25519_sign(uint8_t sig[64],
- const uint8_t* m, size_t mlen,
- const uint8_t* sk)
+ const uint8_t m[], size_t mlen,
+ const uint8_t sk[64],
+ const uint8_t domain_sep[], size_t domain_sep_len)
{
uint8_t az[64];
uint8_t nonce[64];
@@ -49,6 +50,7 @@ void ed25519_sign(uint8_t sig[64],
az[31] &= 63;
az[31] |= 64;
+ sha.update(domain_sep, domain_sep_len);
sha.update(az + 32, 32);
sha.update(m, mlen);
sha.final(nonce);
@@ -56,6 +58,7 @@ void ed25519_sign(uint8_t sig[64],
sc_reduce(nonce);
ge_scalarmult_base(sig, nonce);
+ sha.update(domain_sep, domain_sep_len);
sha.update(sig, 32);
sha.update(sk + 32, 32);
sha.update(m, mlen);
@@ -67,7 +70,8 @@ void ed25519_sign(uint8_t sig[64],
bool ed25519_verify(const uint8_t* m, size_t mlen,
const uint8_t sig[64],
- const uint8_t* pk)
+ const uint8_t* pk,
+ const uint8_t domain_sep[], size_t domain_sep_len)
{
uint8_t h[64];
uint8_t rcheck[32];
@@ -83,6 +87,7 @@ bool ed25519_verify(const uint8_t* m, size_t mlen,
return false;
}
+ sha.update(domain_sep, domain_sep_len);
sha.update(sig, 32);
sha.update(pk, 32);
sha.update(m, mlen);