1 /* 2 * Copyright (C) 2021 - This file is part of libecc project 3 * 4 * Authors: 5 * Ryad BENADJILA <ryadbenadjila@gmail.com> 6 * Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr> 7 * 8 * This software is licensed under a dual BSD and GPL v2 license. 9 * See LICENSE file at the root folder of the project. 10 */ 11 #ifndef __EC_MONTGOMERY_H__ 12 #define __EC_MONTGOMERY_H__ 13 14 #include <libecc/nn/nn.h> 15 #include <libecc/fp/fp.h> 16 #include <libecc/fp/fp_add.h> 17 #include <libecc/fp/fp_mul.h> 18 #include <libecc/fp/fp_mul_redc1.h> 19 20 typedef struct { 21 fp A; 22 fp B; 23 nn order; 24 word_t magic; 25 } ec_montgomery_crv; 26 27 typedef ec_montgomery_crv *ec_montgomery_crv_t; 28 typedef const ec_montgomery_crv *ec_montgomery_crv_src_t; 29 30 ATTRIBUTE_WARN_UNUSED_RET int ec_montgomery_crv_check_initialized(ec_montgomery_crv_src_t crv); 31 ATTRIBUTE_WARN_UNUSED_RET int ec_montgomery_crv_init(ec_montgomery_crv_t crv, fp_src_t a, fp_src_t b, nn_src_t order); 32 void ec_montgomery_crv_uninit(ec_montgomery_crv_t crv); 33 34 #endif /* __EC_MONTGOMERY_H__ */ 35