| 1 | #include <sodium.h> |
| 2 | |
| 3 | #include <xeddsa.h> |
| 4 | |
| 5 | /** |
| 6 | * Perform Diffie-Hellman key agreement on Curve25519, also known as X25519. Re-export of libsodiums/ref10s |
| 7 | * `crypto_scalarmult_curve25519` function for convenience. |
| 8 | * |
| 9 | * @param shared_secret (out): The shared secret. |
| 10 | * @param priv (in): The private key partaking in the key agreement. |
| 11 | * @param curve25519_pub (in): The public key partaking in the key agreement. |
| 12 | * @return 0 in case of success, -1 if the public key was rejected due to suboptimal security propierties or |
| 13 | * if the shared secret consists of only zeros. |
| 14 | */ |
| 15 | int x25519(uint8_t* shared_secret, const uint8_t* priv, const uint8_t* curve25519_pub) { |
| 16 | return crypto_scalarmult_curve25519(shared_secret, priv, curve25519_pub); |
| 17 | } |