This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
79
unikernel/duniverse/mirage-crypto/ec/native/np384_stubs.c
Normal file
79
unikernel/duniverse/mirage-crypto/ec/native/np384_stubs.c
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
#include "mirage_crypto.h"
|
||||
|
||||
/* Microsoft compiler does not support 128-bit integers. Drop down to
|
||||
* 32-bit for MSVC.
|
||||
*/
|
||||
#if defined(ARCH_64BIT) && !defined(_MSC_VER)
|
||||
#include "np384_64.h"
|
||||
#define LIMBS 6
|
||||
#define WORD uint64_t
|
||||
#define WORDSIZE 64
|
||||
#else
|
||||
#include "np384_32.h"
|
||||
#define LIMBS 12
|
||||
#define WORD uint32_t
|
||||
#define WORDSIZE 32
|
||||
#endif
|
||||
|
||||
#define LEN_PRIME 384
|
||||
#define CURVE_DESCRIPTION fiat_np384
|
||||
|
||||
#include "inversion_template.h"
|
||||
|
||||
#include <caml/memory.h>
|
||||
|
||||
CAMLprim value mc_np384_inv(value out, value in)
|
||||
{
|
||||
CAMLparam2(out, in);
|
||||
inversion((WORD*)Bytes_val(out), (const WORD*)String_val(in));
|
||||
CAMLreturn(Val_unit);
|
||||
}
|
||||
|
||||
CAMLprim value mc_np384_mul(value out, value a, value b)
|
||||
{
|
||||
CAMLparam3(out, a, b);
|
||||
fiat_np384_mul((WORD*)Bytes_val(out), (const WORD*)String_val(a), (const WORD*)String_val(b));
|
||||
CAMLreturn(Val_unit);
|
||||
}
|
||||
|
||||
CAMLprim value mc_np384_add(value out, value a, value b)
|
||||
{
|
||||
CAMLparam3(out, a, b);
|
||||
fiat_np384_add((WORD*)Bytes_val(out), (const WORD*)String_val(a), (const WORD*)String_val(b));
|
||||
CAMLreturn(Val_unit);
|
||||
}
|
||||
|
||||
CAMLprim value mc_np384_one(value out)
|
||||
{
|
||||
CAMLparam1(out);
|
||||
fiat_np384_set_one((WORD*)Bytes_val(out));
|
||||
CAMLreturn(Val_unit);
|
||||
}
|
||||
|
||||
CAMLprim value mc_np384_from_bytes(value out, value in)
|
||||
{
|
||||
CAMLparam2(out, in);
|
||||
fiat_np384_from_bytes((WORD*)Bytes_val(out), _st_uint8(in));
|
||||
CAMLreturn(Val_unit);
|
||||
}
|
||||
|
||||
CAMLprim value mc_np384_to_bytes(value out, value in)
|
||||
{
|
||||
CAMLparam2(out, in);
|
||||
fiat_np384_to_bytes(Bytes_val(out), (const WORD*)String_val(in));
|
||||
CAMLreturn(Val_unit);
|
||||
}
|
||||
|
||||
CAMLprim value mc_np384_from_montgomery(value out, value in)
|
||||
{
|
||||
CAMLparam2(out, in);
|
||||
fiat_np384_from_montgomery((WORD*)Bytes_val(out), (const WORD*)String_val(in));
|
||||
CAMLreturn(Val_unit);
|
||||
}
|
||||
|
||||
CAMLprim value mc_np384_to_montgomery(value out, value in)
|
||||
{
|
||||
CAMLparam2(out, in);
|
||||
fiat_np384_to_montgomery((WORD*)Bytes_val(out), (const WORD*)String_val(in));
|
||||
CAMLreturn(Val_unit);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue