1 /* Copyright 2016 Brian Smith. 2 * 3 * Permission to use, copy, modify, and/or distribute this software for any 4 * purpose with or without fee is hereby granted, provided that the above 5 * copyright notice and this permission notice appear in all copies. 6 * 7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES 8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 10 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 12 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 13 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ 14 15 #ifndef RING_LIMBS_H 16 #define RING_LIMBS_H 17 18 #include <GFp/base.h> 19 20 #include "../internal.h" 21 22 typedef crypto_word Limb; 23 24 #define LIMB_BITS CRYPTO_WORD_BITS 25 #define LIMB_HIGH_BIT ((Limb)(1) << (LIMB_BITS - 1)) 26 27 28 Limb LIMBS_are_zero(const Limb a[], size_t num_limbs); 29 Limb LIMBS_are_even(const Limb a[], size_t num_limbs); 30 Limb LIMBS_equal(const Limb a[], const Limb b[], size_t num_limbs); 31 Limb LIMBS_equal_limb(const Limb a[], Limb b, size_t num_limbs); 32 void LIMBS_reduce_once(Limb r[], const Limb m[], size_t num_limbs); 33 void LIMBS_add_mod(Limb r[], const Limb a[], const Limb b[], const Limb m[], 34 size_t num_limbs); 35 void LIMBS_sub_mod(Limb r[], const Limb a[], const Limb b[], const Limb m[], 36 size_t num_limbs); 37 void LIMBS_shl_mod(Limb r[], const Limb a[], const Limb m[], size_t num_limbs); 38 Limb GFp_limbs_mul_add_limb(Limb r[], const Limb a[], Limb b, size_t num_limbs); 39 40 #endif /* RING_LIMBS_H */ 41