diff options
Diffstat (limited to 'libcmix-bignum')
| -rw-r--r-- | libcmix-bignum/bignum.h | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/libcmix-bignum/bignum.h b/libcmix-bignum/bignum.h index 02efcf7..4c9d3da 100644 --- a/libcmix-bignum/bignum.h +++ b/libcmix-bignum/bignum.h @@ -7,16 +7,31 @@ extern "C" { #endif +/*! + * \file + */ + +/*! + * \brief The bignum_error enum + */ enum bignum_error { NoError = 0, error = -1 }; +/*! + * \brief cMix internal bignum representation. + */ struct Bignum { - unsigned char* data; - size_t len; + unsigned char* data; ///< Pointer to the start of the bignum. + size_t len; ///< The length of the data array. }; +/*! + * \brief allocate_bignum. Reserves space for a len size Bignum. + * \param len The length of the bignum data array. + * \return The Bignum array just allocated. + */ struct Bignum allocate_bignum(size_t len) { return (struct Bignum){ (unsigned char*) malloc(len), @@ -24,14 +39,31 @@ struct Bignum allocate_bignum(size_t len) { }; } +/*! + * \brief free_bignum. Counterpart to allocate_bignum. + * \param b The bignum to free + */ void free_bignum(struct Bignum* b) { free(b->data); b->data = 0; b->len = 0; } +/*! + * \brief get_curve25519_mod. Conveniance for now, but this returns the mod of curve25519 algorith (2^255-19) + * \param result The bignum to store the modulus in, has to be preallocated. + * \return Error status code based on backend errors. + */ extern enum bignum_error get_curve25519_mod(struct Bignum* result); +/*! + * \brief multiply_mod Multiplies 2 bignums module mod and stores the result in result. + * \param result Preallocated Bignum where the result will be stored. + * \param lh Lefthand of Multiplication. + * \param rh Righthand of Multiplaction. + * \param mod The modulus. + * \return Error status code based on backend errors. + */ extern enum bignum_error multiply_mod(struct Bignum* result, struct Bignum const lh, struct Bignum const rh, struct Bignum const mod); |
