diff options
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); |
