From 4f2c980343b321e7fccf48190c32bfb4bca426f4 Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Tue, 4 Oct 2016 12:18:35 +0200 Subject: Added a bignum library to abstract possible implementations. --- libcmix-bignum/bignum.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 libcmix-bignum/bignum.h (limited to 'libcmix-bignum/bignum.h') diff --git a/libcmix-bignum/bignum.h b/libcmix-bignum/bignum.h new file mode 100644 index 0000000..02efcf7 --- /dev/null +++ b/libcmix-bignum/bignum.h @@ -0,0 +1,40 @@ +#pragma once + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +enum bignum_error { + NoError = 0, + error = -1 +}; + +struct Bignum { + unsigned char* data; + size_t len; +}; + +struct Bignum allocate_bignum(size_t len) { + return (struct Bignum){ + (unsigned char*) malloc(len), + len + }; +} + +void free_bignum(struct Bignum* b) { + free(b->data); + b->data = 0; + b->len = 0; +} + +extern enum bignum_error get_curve25519_mod(struct Bignum* result); + +extern enum bignum_error multiply_mod(struct Bignum* result, struct Bignum const lh, struct Bignum const rh, struct Bignum const mod); + + +#ifdef __cplusplus +} +#endif \ No newline at end of file -- cgit v1.2.3-70-g09d2