Pete Bentley | a5c947b | 2019-08-09 14:24:27 +0000 | [diff] [blame^] | 1 | /******************************************************************************************** |
| 2 | * SIDH: an efficient supersingular isogeny cryptography library |
| 3 | * |
| 4 | * Abstract: API header file for SIKE |
| 5 | *********************************************************************************************/ |
| 6 | |
| 7 | #ifndef SIKE_H_ |
| 8 | #define SIKE_H_ |
| 9 | |
| 10 | #include <stdint.h> |
| 11 | #include <openssl/base.h> |
| 12 | |
| 13 | #if defined(__cplusplus) |
| 14 | extern "C" { |
| 15 | #endif |
| 16 | |
| 17 | /* SIKE |
| 18 | * |
| 19 | * SIKE is a isogeny based post-quantum key encapsulation mechanism. Description of the |
| 20 | * algorithm is provided in [SIKE]. This implementation uses 434-bit field size. The code |
| 21 | * is based on "Additional_Implementations" from PQC NIST submission package which can |
| 22 | * be found here: |
| 23 | * https://csrc.nist.gov/CSRC/media/Projects/Post-Quantum-Cryptography/documents/round-1/submissions/SIKE.zip |
| 24 | * |
| 25 | * [SIKE] https://sike.org/files/SIDH-spec.pdf |
| 26 | */ |
| 27 | |
| 28 | // SIKE_PUB_BYTESZ is the number of bytes in a public key. |
| 29 | #define SIKE_PUB_BYTESZ 330 |
| 30 | // SIKE_PRV_BYTESZ is the number of bytes in a private key. |
| 31 | #define SIKE_PRV_BYTESZ 28 |
| 32 | // SIKE_SS_BYTESZ is the number of bytes in a shared key. |
| 33 | #define SIKE_SS_BYTESZ 16 |
| 34 | // SIKE_MSG_BYTESZ is the number of bytes in a random bit string concatenated |
| 35 | // with the public key (see 1.4 of SIKE). |
| 36 | #define SIKE_MSG_BYTESZ 16 |
| 37 | // SIKE_SS_BYTESZ is the number of bytes in a ciphertext. |
| 38 | #define SIKE_CT_BYTESZ (SIKE_PUB_BYTESZ + SIKE_MSG_BYTESZ) |
| 39 | |
| 40 | // SIKE_keypair outputs a public and secret key. Internally it uses BN_rand() as |
| 41 | // an entropy source. In case of success function returns 1, otherwise 0. |
| 42 | OPENSSL_EXPORT int SIKE_keypair( |
| 43 | uint8_t out_priv[SIKE_PRV_BYTESZ], |
| 44 | uint8_t out_pub[SIKE_PUB_BYTESZ]); |
| 45 | |
| 46 | // SIKE_encaps generates and encrypts a random session key, writing those values to |
| 47 | // |out_shared_key| and |out_ciphertext|, respectively. |
| 48 | OPENSSL_EXPORT void SIKE_encaps( |
| 49 | uint8_t out_shared_key[SIKE_SS_BYTESZ], |
| 50 | uint8_t out_ciphertext[SIKE_CT_BYTESZ], |
| 51 | const uint8_t pub_key[SIKE_PUB_BYTESZ]); |
| 52 | |
| 53 | // SIKE_decaps outputs a random session key, writing it to |out_shared_key|. |
| 54 | OPENSSL_EXPORT void SIKE_decaps( |
| 55 | uint8_t out_shared_key[SIKE_SS_BYTESZ], |
| 56 | const uint8_t ciphertext[SIKE_CT_BYTESZ], |
| 57 | const uint8_t pub_key[SIKE_PUB_BYTESZ], |
| 58 | const uint8_t priv_key[SIKE_PRV_BYTESZ]); |
| 59 | |
| 60 | #if defined(__cplusplus) |
| 61 | } |
| 62 | #endif |
| 63 | |
| 64 | #endif |