X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=bigint%2Fbigint.h;h=0966f971f6eedc4fd054acd06dead2b0c9a75f94;hb=fdbda6486df88be6ac2ba948f21e84c396499535;hp=7a7702f077fb22a7b35b9c05442eefab078d33da;hpb=ca25e57ca6a74d6e26cad823d45fcc4604689fa1;p=avr-crypto-lib.git diff --git a/bigint/bigint.h b/bigint/bigint.h index 7a7702f..0966f97 100644 --- a/bigint/bigint.h +++ b/bigint/bigint.h @@ -1,6 +1,6 @@ /* bigint.h */ /* - This file is part of the AVR-Crypto-Lib. + This file is part of the ARM-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -30,18 +30,28 @@ #include -#define BIGINT_FBS_MASK 0x07 /* the last three bits indicate which is the first bit set */ +typedef uint8_t bigint_word_t; +typedef uint16_t bigint_wordplus_t; +typedef int16_t bigint_wordplus_signed_t; +#define BIGINT_WORD_SIZE 8 + +#define BIGINT_FBS_MASK (BIGINT_WORD_SIZE-1) /* the last five bits indicate which is the first bit set */ #define BIGINT_NEG_MASK 0x80 /* this bit indicates a negative value */ typedef struct{ - uint16_t length_B; + uint16_t length_W; uint8_t info; - uint8_t *wordv; /* word vector, pointing to the LSB */ + bigint_word_t *wordv; /* word vector, pointing to the LSB */ }bigint_t; + /******************************************************************************/ void bigint_adjust(bigint_t* a); +uint32_t bigint_get_first_set_bit(const bigint_t* a); +uint32_t bigint_get_last_set_bit(const bigint_t* a); +uint16_t bigint_length_b(const bigint_t* a); +uint16_t bigint_length_B(const bigint_t* a); void bigint_copy(bigint_t* dest, const bigint_t* src); void bigint_add_u(bigint_t* dest, const bigint_t* a, const bigint_t* b); void bigint_add_scale_u(bigint_t* dest, const bigint_t* a, uint16_t scale); @@ -61,8 +71,8 @@ void bigint_sub_u_bitscale(bigint_t* a, const bigint_t* b, uint16_t bitscale); void bigint_reduce(bigint_t* a, const bigint_t* r); void bigint_expmod_u(bigint_t* dest, const bigint_t* a, const bigint_t* exp, const bigint_t* r); void bigint_gcdext(bigint_t* gcd, bigint_t* a, bigint_t* b, const bigint_t* x, const bigint_t* y); -void bigint_inverse(bigint_t* dest, bigint_t* a, bigint_t* m); - +void bigint_inverse(bigint_t* dest, const bigint_t* a, const bigint_t* m); +void bigint_changeendianess(bigint_t* a); /******************************************************************************/ #endif /*BIGINT_H_*/