aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/math/mp/mp_core.h
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-02-25 12:23:41 -0500
committerJack Lloyd <[email protected]>2018-02-25 12:23:41 -0500
commit4536e240238d0b0ecb896c11978b58df108a6ad3 (patch)
tree451605f4f7a3a64b919fcd2f9460f13a87fef3c4 /src/lib/math/mp/mp_core.h
parent896fd7d5d3ef2c4d546fbf0fecb1b1201d022202 (diff)
Pass workspace size to various bigint_ functions
These functions made assumptions about the workspace size available, which if incorrect would cause memory corruption. Since the length is always available at the caller, just provide it and avoid problems.
Diffstat (limited to 'src/lib/math/mp/mp_core.h')
-rw-r--r--src/lib/math/mp/mp_core.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/lib/math/mp/mp_core.h b/src/lib/math/mp/mp_core.h
index 06f87015f..9efcec952 100644
--- a/src/lib/math/mp/mp_core.h
+++ b/src/lib/math/mp/mp_core.h
@@ -132,21 +132,22 @@ void bigint_linmul3(word z[], const word x[], size_t x_size, word y);
void bigint_monty_redc(word z[],
const word p[], size_t p_size,
word p_dash,
- word workspace[]);
+ word workspace[],
+ size_t ws_size);
/*
* Montgomery Multiplication
*/
void bigint_monty_mul(BigInt& z, const BigInt& x, const BigInt& y,
const word p[], size_t p_size, word p_dash,
- word workspace[]);
+ word workspace[], size_t ws_size);
/*
* Montgomery Squaring
*/
void bigint_monty_sqr(BigInt& z, const BigInt& x,
const word p[], size_t p_size, word p_dash,
- word workspace[]);
+ word workspace[], size_t ws_size);
/**
* Compare x and y
@@ -182,15 +183,17 @@ void bigint_comba_sqr16(word out[32], const word in[16]);
/*
* High Level Multiplication/Squaring Interfaces
*/
-void bigint_mul(BigInt& z, const BigInt& x, const BigInt& y, word workspace[]);
+void bigint_mul(BigInt& z, const BigInt& x, const BigInt& y,
+ word workspace[], size_t ws_size);
void bigint_mul(word z[], size_t z_size,
const word x[], size_t x_size, size_t x_sw,
const word y[], size_t y_size, size_t y_sw,
- word workspace[]);
+ word workspace[], size_t ws_size);
-void bigint_sqr(word z[], size_t z_size, word workspace[],
- const word x[], size_t x_size, size_t x_sw);
+void bigint_sqr(word z[], size_t z_size,
+ const word x[], size_t x_size, size_t x_sw,
+ word workspace[], size_t ws_size);
}