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>2015-06-27 21:56:25 +0300
committerAdam Langley <agl@google.com>2015-07-08 01:50:53 +0300
commit74f711083dc88c7344f33f1bca7019da4e376758 (patch)
tree6c690df3028dcfccbd65b448393d9a8732c2c98a /tool/speed.cc
parentc0e245a546b15c6b4219d2f3d5455e417cddc782 (diff)
Parse RSAPrivateKey with CBS.
This removes the version field from RSA and instead handles versioning as part of parsing. (As a bonus, we now correctly limit multi-prime RSA to version 1 keys.) Most consumers are also converted. old_rsa_priv_{de,en}code are left alone for now. Those hooks are passed in parameters which match the old d2i/i2d pattern (they're only used in d2i_PrivateKey and i2d_PrivateKey). Include a test which, among other things, checks that public keys being serialized as private keys are handled properly. BUG=499653 Change-Id: Icdd5f0382c4a84f9c8867024f29756e1a306ba08 Reviewed-on: https://boringssl-review.googlesource.com/5273 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'tool/speed.cc')
-rw-r--r--tool/speed.cc20
1 files changed, 9 insertions, 11 deletions
diff --git a/tool/speed.cc b/tool/speed.cc
index 6c788ac4..307b0b97 100644
--- a/tool/speed.cc
+++ b/tool/speed.cc
@@ -407,9 +407,9 @@ bool Speed(const std::vector<std::string> &args) {
selected = args[0];
}
- RSA *key = NULL;
- const uint8_t *inp = kDERRSAPrivate2048;
- if (NULL == d2i_RSAPrivateKey(&key, &inp, kDERRSAPrivate2048Len)) {
+ RSA *key = RSA_private_key_from_bytes(kDERRSAPrivate2048,
+ kDERRSAPrivate2048Len);
+ if (key == NULL) {
fprintf(stderr, "Failed to parse RSA key.\n");
ERR_print_errors_fp(stderr);
return false;
@@ -420,10 +420,9 @@ bool Speed(const std::vector<std::string> &args) {
}
RSA_free(key);
- key = NULL;
-
- inp = kDERRSAPrivate3Prime2048;
- if (NULL == d2i_RSAPrivateKey(&key, &inp, kDERRSAPrivate3Prime2048Len)) {
+ key = RSA_private_key_from_bytes(kDERRSAPrivate3Prime2048,
+ kDERRSAPrivate3Prime2048Len);
+ if (key == NULL) {
fprintf(stderr, "Failed to parse RSA key.\n");
ERR_print_errors_fp(stderr);
return false;
@@ -434,10 +433,9 @@ bool Speed(const std::vector<std::string> &args) {
}
RSA_free(key);
- key = NULL;
-
- inp = kDERRSAPrivate4096;
- if (NULL == d2i_RSAPrivateKey(&key, &inp, kDERRSAPrivate4096Len)) {
+ key = RSA_private_key_from_bytes(kDERRSAPrivate4096,
+ kDERRSAPrivate4096Len);
+ if (key == NULL) {
fprintf(stderr, "Failed to parse 4096-bit RSA key.\n");
ERR_print_errors_fp(stderr);
return 1;