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
path: root/crypto
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@google.com>2016-02-17 21:20:28 +0300
committerAdam Langley <agl@google.com>2016-02-17 21:28:05 +0300
commitf4ef9b517ec8a0858036c5dd4418428e795fec3e (patch)
tree318146c1269afc422f791d6b4d3590f0d8636966 /crypto
parent9cd7fbdac6f102e4680028247b85910c68cc3c51 (diff)
otherPrimeInfos is not optional in version 1 RSAPrivateKeys.
Currently, we correctly refuse to parse version 0 multi-prime keys, but we still parse version 1 two-prime keys. Both should be rejected. I missed an additional clause in the spec originally. It seems otherPrimeInfos is marked OPTIONAL not because it is actually optional, but because they wanted the two RSAPrivateKey forms to share one definition. The prose rules following the definition imply that otherPrimeInfos' presence is entirely determined by the version: * version is the version number, for compatibility with future revisions of this document. It shall be 0 for this version of the document, unless multi-prime is used, in which case it shall be 1. Version ::= INTEGER { two-prime(0), multi(1) } (CONSTRAINED BY {-- version must be multi if otherPrimeInfos present --}) and: * otherPrimeInfos contains the information for the additional primes r_3, ..., r_u, in order. It shall be omitted if version is 0 and shall contain at least one instance of OtherPrimeInfo if version is 1. Change-Id: I458232a2e20ed68fddcc39c4c45333f33441f70b Reviewed-on: https://boringssl-review.googlesource.com/7143 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/rsa/rsa_asn1.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/crypto/rsa/rsa_asn1.c b/crypto/rsa/rsa_asn1.c
index 83bae4d5..36f6ee0c 100644
--- a/crypto/rsa/rsa_asn1.c
+++ b/crypto/rsa/rsa_asn1.c
@@ -233,9 +233,11 @@ RSA *RSA_parse_private_key(CBS *cbs) {
goto err;
}
- /* Multi-prime RSA requires a newer version. */
- if (version == kVersionMulti &&
- CBS_peek_asn1_tag(&child, CBS_ASN1_SEQUENCE)) {
+ if (version == kVersionMulti) {
+ /* Although otherPrimeInfos is written as OPTIONAL in RFC 3447, it later
+ * says "[otherPrimeInfos] shall be omitted if version is 0 and shall
+ * contain at least one instance of OtherPrimeInfo if version is 1. The
+ * OPTIONAL is just so both versions share a single definition. */
CBS other_prime_infos;
if (!CBS_get_asn1(&child, &other_prime_infos, CBS_ASN1_SEQUENCE) ||
CBS_len(&other_prime_infos) == 0) {