summaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_intern.c
diff options
context:
space:
mode:
authorEmilia Kasper <emilia@openssl.org>2015-04-27 16:21:48 +0200
committerEmilia Kasper <emilia@openssl.org>2015-04-27 16:21:48 +0200
commite22d2199e2a5cc9b243f45c2b633d1e31fadecd7 (patch)
tree2ebd9a0e6c7f9125e4dd1d395af4652ad30c40f8 /crypto/bn/bn_intern.c
parent2f5997b7b9dc6b4206780ecadcb3de2eac88216e (diff)
Error checking and memory leak fixes in NISTZ256.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/bn/bn_intern.c')
-rw-r--r--crypto/bn/bn_intern.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/crypto/bn/bn_intern.c b/crypto/bn/bn_intern.c
index cf2b33630e..32ad50523d 100644
--- a/crypto/bn/bn_intern.c
+++ b/crypto/bn/bn_intern.c
@@ -233,11 +233,20 @@ void bn_set_static_words(BIGNUM *a, BN_ULONG *words, int size)
a->dmax = a->top = size;
a->neg = 0;
a->flags |= BN_FLG_STATIC_DATA;
+ bn_correct_top(a);
}
-void bn_set_data(BIGNUM *a, const void *data, size_t size)
+int bn_set_words(BIGNUM *a, BN_ULONG *words, int num_words)
{
- memcpy(a->d, data, size);
+ if (bn_wexpand(a, num_words) == NULL) {
+ BNerr(BN_F_BN_SET_WORDS, ERR_R_MALLOC_FAILURE);
+ return 0;
+ }
+
+ memcpy(a->d, words, sizeof(BN_ULONG) * num_words);
+ a->top = num_words;
+ bn_correct_top(a);
+ return 1;
}
size_t bn_sizeof_BIGNUM(void)