// // rsa.h // c-libp2p // // Created by John Jones on 11/3/16. // Copyright © 2016 JMJAtlanta. All rights reserved. // #ifndef rsa_h #define rsa_h struct RsaPublicKey { unsigned long long modulus; unsigned long long exponent; }; struct CRTValue { unsigned long long exponent; unsigned long long coefficient; unsigned long long r; }; struct PrecomputedValues { unsigned long long dp; unsigned long long dq; unsigned long long q_inv; struct CRTValue** crt_values; }; struct RsaPrivateKey { /* The old struct RsaPublicKey public_key; unsigned long long private_exponent; unsigned long long prime1; unsigned long long prime2; struct PrecomputedValues precomputed_values; */ unsigned long long QP; unsigned long long DQ; unsigned long long DP; unsigned long long Q; unsigned long long P; unsigned long long D; unsigned long long E; unsigned long long N; }; /** * generate a new private key * @param private_key the new private key * @param num_bits_for_keypair the size of the key (1024 minimum) * @returns true(1) on success */ int crypto_rsa_generate_keypair(struct RsaPrivateKey* private_key, unsigned long num_bits_for_keypair); /** * convert a struct RsaPublicKey into a stream of bytes compatible with x509 PKI * @param public_key the public key struct * @param bytes the results * @param bytes_size the length of the results */ int crypto_rsa_public_key_bytes(struct RsaPublicKey* public_key, char** bytes, unsigned long long* bytes_size); #endif /* rsa_h */