diff options
author | Nikias Bassen | 2022-02-09 04:04:36 +0100 |
---|---|---|
committer | Nikias Bassen | 2022-02-09 04:04:36 +0100 |
commit | e41dbc3ddbe30a414e73fa25d9c7c304ffe6989e (patch) | |
tree | 599c99a2f32bc18f1e9ebc740d0a12d71c49bb10 /3rd_party/ed25519/sign.c | |
parent | ee9104bcb8d494b579e122a2dcc94a2b79d38e4b (diff) | |
download | libimobiledevice-e41dbc3ddbe30a414e73fa25d9c7c304ffe6989e.tar.gz libimobiledevice-e41dbc3ddbe30a414e73fa25d9c7c304ffe6989e.tar.bz2 |
Add support for wireless pairing
Diffstat (limited to '3rd_party/ed25519/sign.c')
-rw-r--r-- | 3rd_party/ed25519/sign.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/3rd_party/ed25519/sign.c b/3rd_party/ed25519/sign.c new file mode 100644 index 0000000..199a839 --- /dev/null +++ b/3rd_party/ed25519/sign.c @@ -0,0 +1,31 @@ +#include "ed25519.h" +#include "sha512.h" +#include "ge.h" +#include "sc.h" + + +void ed25519_sign(unsigned char *signature, const unsigned char *message, size_t message_len, const unsigned char *public_key, const unsigned char *private_key) { + sha512_context hash; + unsigned char hram[64]; + unsigned char r[64]; + ge_p3 R; + + + sha512_init(&hash); + sha512_update(&hash, private_key + 32, 32); + sha512_update(&hash, message, message_len); + sha512_final(&hash, r); + + sc_reduce(r); + ge_scalarmult_base(&R, r); + ge_p3_tobytes(signature, &R); + + sha512_init(&hash); + sha512_update(&hash, signature, 32); + sha512_update(&hash, public_key, 32); + sha512_update(&hash, message, message_len); + sha512_final(&hash, hram); + + sc_reduce(hram); + sc_muladd(signature + 32, hram, private_key, r); +} |