diff options
| author | J08nY | 2020-02-28 15:03:36 +0100 |
|---|---|---|
| committer | J08nY | 2020-02-28 15:03:36 +0100 |
| commit | b387d00511a03dc20e15ac55fcbf07f3dfa79ce0 (patch) | |
| tree | 6f7c7cb0168366b2862a6e42e20067652cbc443b /pyecsca/codegen/bn | |
| parent | 4eafe2d49fc7406861609c5af12b850741bbe5a0 (diff) | |
| download | pyecsca-codegen-b387d00511a03dc20e15ac55fcbf07f3dfa79ce0.tar.gz pyecsca-codegen-b387d00511a03dc20e15ac55fcbf07f3dfa79ce0.tar.zst pyecsca-codegen-b387d00511a03dc20e15ac55fcbf07f3dfa79ce0.zip | |
Update libtommath, use multi init and clear.
Diffstat (limited to 'pyecsca/codegen/bn')
| -rw-r--r-- | pyecsca/codegen/bn/bn.c | 6 | ||||
| -rw-r--r-- | pyecsca/codegen/bn/bn.h | 8 |
2 files changed, 8 insertions, 6 deletions
diff --git a/pyecsca/codegen/bn/bn.c b/pyecsca/codegen/bn/bn.c index 930dea7..1247c5d 100644 --- a/pyecsca/codegen/bn/bn.c +++ b/pyecsca/codegen/bn/bn.c @@ -14,15 +14,15 @@ void bn_clear(bn_t *bn) { mp_clear(bn); } -int bn_from_bin(const uint8_t *data, size_t size, bn_t *out) { +bn_err bn_from_bin(const uint8_t *data, size_t size, bn_t *out) { return mp_from_ubin(out, data, size); } -int bn_from_hex(const char *data, bn_t *out) { +bn_err bn_from_hex(const char *data, bn_t *out) { return mp_read_radix(out, data, 16); } -int bn_from_int(unsigned int value, bn_t *out) { +bn_err bn_from_int(unsigned int value, bn_t *out) { if (sizeof(unsigned int) == 8) { mp_set_u64(out, value); } else { diff --git a/pyecsca/codegen/bn/bn.h b/pyecsca/codegen/bn/bn.h index 02b3e93..862b67c 100644 --- a/pyecsca/codegen/bn/bn.h +++ b/pyecsca/codegen/bn/bn.h @@ -34,12 +34,14 @@ typedef struct { } wnaf_t; bn_err bn_init(bn_t *bn); +#define bn_init_multi mp_init_multi bn_err bn_copy(const bn_t *from, bn_t *to); void bn_clear(bn_t *bn); +#define bn_clear_multi mp_clear_multi -int bn_from_bin(const uint8_t *data, size_t size, bn_t *out); -int bn_from_hex(const char *data, bn_t *out); -int bn_from_int(unsigned int value, bn_t *out); +bn_err bn_from_bin(const uint8_t *data, size_t size, bn_t *out); +bn_err bn_from_hex(const char *data, bn_t *out); +bn_err bn_from_int(unsigned int value, bn_t *out); bn_err bn_to_binpad(const bn_t *one, uint8_t *data, size_t size); bn_err bn_to_bin(const bn_t *one, uint8_t *data); |
