Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@chromium.org>2014-11-11 01:28:53 +0300
committerAdam Langley <agl@google.com>2014-11-11 02:04:52 +0300
commitf2f3cfedb798a45a0605cc8c0a4e157f0119bb04 (patch)
tree59e7e1201a291124b197de2114fee3aff110628e /crypto/ecdsa
parentb145c8140b4335d523f79b52929e05e047a05c06 (diff)
Use BN_bn2bin_padded rather than doing math to figure out leading zeros.
Saves doing it ad-hoc all the time. Change-Id: Ic1a1180f56eec37c19799649bb8f18237bd617f8 Reviewed-on: https://boringssl-review.googlesource.com/2241 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/ecdsa')
-rw-r--r--crypto/ecdsa/ecdsa_test.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/crypto/ecdsa/ecdsa_test.c b/crypto/ecdsa/ecdsa_test.c
index 523cbdfd..127d76f9 100644
--- a/crypto/ecdsa/ecdsa_test.c
+++ b/crypto/ecdsa/ecdsa_test.c
@@ -217,14 +217,15 @@ int test_builtin(BIO *out) {
goto builtin_err;
}
buf_len = 2 * bn_len;
- raw_buf = OPENSSL_malloc(buf_len);
+ raw_buf = OPENSSL_malloc(2 * bn_len);
if (raw_buf == NULL) {
goto builtin_err;
}
/* Pad the bignums with leading zeroes. */
- memset(raw_buf, 0, buf_len);
- BN_bn2bin(ecdsa_sig->r, raw_buf + bn_len - r_len);
- BN_bn2bin(ecdsa_sig->s, raw_buf + buf_len - s_len);
+ if (!BN_bn2bin_padded(raw_buf, bn_len, ecdsa_sig->r) ||
+ !BN_bn2bin_padded(raw_buf + bn_len, bn_len, ecdsa_sig->s)) {
+ goto builtin_err;
+ }
/* Modify a single byte in the buffer. */
offset = raw_buf[10] % buf_len;