Skip to content

Add a feature to parse SubjectPublicKeyInfo into (signature::Algorithm, SubjectPublicKey) - #378

Closed
marshallpierce wants to merge 5 commits into
briansmith:masterfrom
marshallpierce:port-webpki-spki-signature-verification
Closed

marshallpierce wants to merge 5 commits into
briansmith:masterfrom
marshallpierce:port-webpki-spki-signature-verification

Conversation

@marshallpierce

Copy link
Copy Markdown
Contributor

Not yet ready for merging. I wanted to start adding notes and questions, though.

Comment thread src/der.rs

pub fn bit_string_with_no_unused_bits<'a>(input: &mut untrusted::Reader<'a>)
-> Result<untrusted::Input<'a>,
error::Unspecified> {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning Unspecified here just gets turned into BadDER elsewhere... maybe in the future it would be nice to have DER-related functions return a DER error for easier mapping?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I filed #379 for this.

Comment thread src/lib.rs Outdated
)]
#![deny(
const_err,
dead_code,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just temporary while things are in flux.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: make sure this was reverted.

@@ -0,0 +1,21 @@
These files contain the binary DER encoding of the *values* of some

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied from webpki.

Comment thread src/signature/spki.rs Outdated

// XXX: Some of the BadDER tests should have better error codes, maybe?

// TODO need ECDSA_P256_SHA512 for these tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it intended to ever support P256 with SHA512? If not I'll just delete these (commented out) tests.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we probably won't support ECDSA_P256_SHA512 at this point.

A note about these tests: webpki is not developed to the same quality standard as ring yet, though we're hoping to change that. When I first shared it, the only thing I wanted to really make sure was that we did something reasonable for the signature verification part. We copied these chromium tests because that was the fastest way to ship the first webpki prototype.

Now in ring we should reconsider what we're doing w.r.t. testing this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was planning on scripting a few openssl invocations to generate keys of all the types in spki and all corresponding digests, generating sample signatures, and then writing tests to verify that signatures match/don't match as appropriate so that every algorithm/curve/digest flavor has at least some coverage. Open to suggestions, though!

Comment thread src/signature/spki.rs Outdated
Err(VerifyWithSPKIError::UnsupportedSignatureAlgorithm));
test_verify_signed_data_signature_outer!(
test_ecdsa_prime256v1_sha512_unused_bits_signature,
"ecdsa-prime256v1-sha512-unused-bits-signature.pem",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test deleted: the signature DER is invalid, so not relevant for signature validation since we can't decode the signature itself.

Comment thread src/signature/spki.rs Outdated
Err(VerifyWithSPKIError::UnsupportedSignatureAlgorithm));
test_verify_signed_data!(
test_ecdsa_prime256v1_sha512_using_rsa_algorithm,
"ecdsa-prime256v1-sha512-using-rsa-algorithm.pem",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test deleted: error is in Algorithm field, but that's not used for plain signature validation (only SignedData).

Comment thread src/signature/spki.rs Outdated
&spki::RSA_PKCS1_2048_8192_SHA1,
Err(VerifyWithSPKIError::UnsupportedSignatureAlgorithmForPublicKey));
test_verify_signed_data!(test_rsa_pkcs1_sha1_wrong_algorithm,
"rsa-pkcs1-sha1-wrong-algorithm.pem",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test deleted: error is in Algorithm, which we don't use

Comment thread src/signature/spki.rs Outdated
&spki::RSA_PKCS1_2048_8192_SHA256,
Err(VerifyWithSPKIError::InvalidSignatureForPublicKey));
// TODO this only tests DER decoding, not signature logic
test_parse_spki_bad_outer!(test_rsa_pkcs1_sha256_key_encoded_ber,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these parse_spki_bad_outer tests be moved to the DER module? It doesn't really have anything to do with signatures.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existence of those tests in webpki is just an artifact of history, really. I think we should just leave them all out of the ring test suite.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me. I'll check to make sure that functionality has some tests but if so I'll delete these.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There weren't tests that I saaw for that der method so I moved those tests over. This involved some mildly unpleasant compromises: I moved read_pem_section over to der::tests and used it from there for spki's testing needs. I felt it was worth it to not lose out on some real-world-ish test coverage for the various flavors of incorrect DER expressed by those tests, but I'll ditch 'em if you'd rather.

Comment thread src/signature/spki.rs Outdated
test_verify_signed_data!(
test_rsa_pkcs1_sha256_using_ecdsa_algorithm,
"rsa-pkcs1-sha256-using-ecdsa-algorithm.pem",
Err(VerifyWithSPKIError::UnsupportedSignatureAlgorithmForPublicKey));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test deleted: error in Algorithm

Comment thread src/signature/spki.rs Outdated
Err(VerifyWithSPKIError::UnsupportedSignatureAlgorithmForPublicKey));

// Chromium's PSS test are for parameter combinations we don't support.
test_verify_signed_data!(test_rsa_pss_sha1_salt20_using_pss_key_no_params,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PSS tests deleted: no point in a bunch more tests that only check that 1024 bit keys aren't supported...

Comment thread src/signature/spki.rs Outdated
/// A signature algorithm.
pub struct SignatureAlgorithm {
public_key_alg_id: AlgorithmIdentifier,
signature_alg_id: AlgorithmIdentifier,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field is now unused since we don't need to select algorithms by digest. What do you think is the right abstraction? Should we remove this field (and all the associated constants)? Leave it, but document its use in SignedData?
It seems good to have some way to represent signature info, but I'm not sure how widely applicable those signature alg OIDs are.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the right thing to remove signature_alg_id. That means that webpki would have to continue to define all of these things, as a wrapper around ring::signature::spki::SignatureAlgorithm and signature_alg_id.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a good idea to rename SignatureAlgorithm to AlgorithmIdentifier, leaving the Signature part implied by the fact that it is nested in ring::signature.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll work on that. A shame that "Signature" is overloaded both to be the general concept, the noun, and also the creation (as opposed to verification) of the thing...

Also, ICYMI, I made a few comments on an individual commit as I was massaging the tests that show as outdated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AlgorithmIdentifier was already claimed in spki so I went with Algorithm.

@briansmith

Copy link
Copy Markdown
Owner

Note that in 0.7.x I'll be moving lots (most? almost all) of ring tests to tests/ because they're really integration tests. In particular, all tests that only use the public API will move to tests/. It seems like it would be great to do this from the beginning for this new feature.

@coveralls

coveralls commented Dec 15, 2016 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.03%) to 93.232% when pulling 044cef4 on marshallpierce:port-webpki-spki-signature-verification into 53fd7f9 on briansmith:master.

2 similar comments
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.03%) to 93.232% when pulling 044cef4 on marshallpierce:port-webpki-spki-signature-verification into 53fd7f9 on briansmith:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.03%) to 93.232% when pulling 044cef4 on marshallpierce:port-webpki-spki-signature-verification into 53fd7f9 on briansmith:master.

@coveralls

coveralls commented Dec 15, 2016 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.03%) to 93.235% when pulling 3ce8805 on marshallpierce:port-webpki-spki-signature-verification into 53fd7f9 on briansmith:master.

2 similar comments
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.03%) to 93.235% when pulling 3ce8805 on marshallpierce:port-webpki-spki-signature-verification into 53fd7f9 on briansmith:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.03%) to 93.235% when pulling 3ce8805 on marshallpierce:port-webpki-spki-signature-verification into 53fd7f9 on briansmith:master.

@coveralls

coveralls commented Dec 15, 2016 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.03%) to 93.235% when pulling 3ce8805 on marshallpierce:port-webpki-spki-signature-verification into 53fd7f9 on briansmith:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.03%) to 93.235% when pulling 3ce8805 on marshallpierce:port-webpki-spki-signature-verification into 53fd7f9 on briansmith:master.

1 similar comment
@coveralls

coveralls commented Dec 15, 2016 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.03%) to 93.235% when pulling 3ce8805 on marshallpierce:port-webpki-spki-signature-verification into 53fd7f9 on briansmith:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.03%) to 93.235% when pulling 3ce8805 on marshallpierce:port-webpki-spki-signature-verification into 53fd7f9 on briansmith:master.

3 similar comments
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.03%) to 93.235% when pulling 3ce8805 on marshallpierce:port-webpki-spki-signature-verification into 53fd7f9 on briansmith:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.03%) to 93.235% when pulling 3ce8805 on marshallpierce:port-webpki-spki-signature-verification into 53fd7f9 on briansmith:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.03%) to 93.235% when pulling 3ce8805 on marshallpierce:port-webpki-spki-signature-verification into 53fd7f9 on briansmith:master.

Comment thread src/signature/spki.rs Outdated
// with SHA-1) say that parameters must be omitted. RFC 4055 Section 5 and RFC
// 3279 Section 2.2.1 both say that parameters for RSA must be encoded as NULL;
// we relax that requirement by allowing the NULL to be omitted, to match all
// the other signature algorithms we support and for compatibility.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment still relevant? The RSA_ENCRYPTION alg id has this structure:

    0:d=0  hl=2 l=   9 prim: OBJECT            :rsaEncryption
   11:d=0  hl=2 l=   0 prim: NULL

It looks like we do require the NULL...

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that comment is referring to signature algorithm identifiers, not key algorithm identifiers, so it won't apply in any case since we remove signature_alg_id in a later commit. And yes, it appears to be outdated. I just removed it in webpki: briansmith/webpki@2419bb7 and it should be removed here as well.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was out of date. I removed the comment in briansmith/webpki@2419bb7.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, removed.

@marshallpierce
marshallpierce force-pushed the port-webpki-spki-signature-verification branch from df359e3 to 899d57e Compare December 19, 2016 20:10
Comment thread tests/test-data/gen-test-signatures.sh Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know what you think of this approach. I wanted to have some simple sanity checks that basic signature validation for all the supported algorithm combinations, and this seemed like a simple way to get that (assuming openssl's output is correct, of course).

Comment thread tests/test-data/gen-test-signatures.sh Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

openssl's CLI doesn't support PSS signatures AFAICT but there's some C in http://openssl.6102.n7.nabble.com/RSASSA-PSS-Signature-Question-td22572.html that should be a good start to making a little single-purpose tool we can use for generating signatures.

Comment thread tests/spki_tests.rs Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was in the original tests; I'm not sure what it means at this point

Comment thread tests/spki_tests.rs Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is using the various inputs, signatures, etc generated by the gen-test-signatures.sh script to test success and failure modes for a given mode.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your comment in the PR about this using the gen-test-signature.sh script output as the inputs for the tests should be a comment in this file somewhere, perhaps at the top of the file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread tests/spki_tests.rs Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No ECDSA signing support yet, so we don't have an equivalent ECDSA "sign then verify the signature" scenario.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the rsa_sign_and_verify_spki tests essential for covering the code? Normally we don't add this kind of test because, for example, we want all the verification tests to run even when RSA signing isn't enabled. Or, in other words, if this test is testing something important about signature verification then we need to find a way to do it even when RSA signing is disabled and also for ECDSA and EdDSA, but if it testing something important about signature verification then it seems like we should remove it and/or defer it. WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the tests are essential. The other tests verify signatures generated with openssl's CLI, which does work and is certainly valuable from an interop perspective. However, it felt comforting to verify that using SPKI pub keys also works with signatures that ring generates, given that RSA signature generation is probabilistic so ring will not generate the same signatures as the openssl ones. I'd also be happy to add support for the other algorithms, but until ECDSA signing is supported, RSA is as far as I can go. For EdDSA, spki.rs doesn't currently have any algorithms for that suite; is that planned/desired?

Anyway, if the somewhat vague value proposition is not compelling, it wouldn't break my heart to remove the rsa sign-and-verify tests.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, if the somewhat vague value proposition is not compelling, it wouldn't break my heart to remove the rsa sign-and-verify tests.

I suggest we pull them out for now and maybe put them in another PR so we can measure the code coverage without them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, the tests are in spki-rsa-sign-and-verify-tests for posterity.

Comment thread tests/spki_tests.rs Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signature::RSAKeyPair::from_der fails when loading this 8192-bit key.

Comment thread tests/spki_tests.rs Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy-and-paste of equivalent code in der tests

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I understand that we need to copy/paste because these integration tests need to be run against the production version of ring, and we don't want these common functions to be part of the public ring API. Let's add a comment explaining this to this file.

Another way to do this, which I prefer, would be to put the common logic in a separate source file, e.g. tests/der_tests_common.rs, and then include! that file in ring::der::tests and in this file. WDYT?

Otherwise, we at least need to add some comments "Keep this in sync with the copy in <other file's relative path>" to both src/der.rs and this file, for each item that is duplicated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the include! approach. While I'm in there I might as well solve #452 because it will be trivial.

Comment thread src/signature/spki.rs Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like in webpki it was convenient to carry around just the inner two components of SPKI, but the file that people would tend to load from an openssl exported key would start with the top level sequence. Both seem like pretty valid things to loosely call "SPKI". Thoughts on how to handle this? Two functions? Helper function to strip the outer layer of DER?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand you correctly, the current webpki strips the outermost SEQUENCE in a higher-level function and saves the insides, and only the inside parts are passed to the verification function. However, you're also saying ring's new verification function that takes SPKIs needs to strip the SEQUENCE itself. It would be nice if webpki could pass the entire SEQUENCE to the ring verification function so that two different functions aren't needed. Am I understanding things correctly?

If so, the webpki code can be changed to something like this:

...
let spki_begin reader.mark();
try!(der::nested(... der::SEQUENCE, |spki| Ok(())));
let spki_end = reader.mark();
let spki = try!(reader.get_input_between_marks(spki_begin, spki_end));
...

Then spki would contain the outer later of the sequence. In fact, this logic should probably be encapsulated in ring::der as a function called something like expect_tag_and_get_tlv().

Then webpki could just use the public ring function, IIUC. WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're on the same page, but just to be sure I'll elaborate.

Tracing the data flow up from verify_signed_data:

EndEntityCert::verify_is_valid_tls_server_cert // top of call stack, takes a &[TrustAnchor] 
verify_cert::build_chain // takes a &[TrustAnchor] 
verify_cert::check_signatures // called on TrustAnchor.spki
signed_data::verify_signed_data 
signed_data::verify_signature // function now in ring

And TrustAnchor is created in trust_anchor_util::parse_cert_v1 with an spki of:

let spki =
                    try!(der::expect_tag_and_get_value(tbs,
                                                       der::Tag::Sequence));

or via trust_anchor_from_cert in parse_cert_internal with identical code.

webpki's representation of spki as just the contents of the sequence is sensible because it saves a few mostly-meaningless bytes, especially when all the code that uses it is internal.

I think the choices are as follows:

  1. Leave webpki's representation as it is, and have ring's function continue to expect that as input. For users that haven't already stripped off the outer sequence (as when they're loading a key from a file), document the verification function to explain that expect_tag_and_get_value should be called first on the DER.
  2. Switch webpki to keep the complete SPKI DER internally, and switch ring's function accordingly. Now both webpki and average joes working with a public key have no intervening steps to process the key data from the point of loading the bytes. This is nice cleanliness-wise, but costs a few bytes of memory to hang onto the key, and a few cycles for every verification to strip off the sequence.

Ironically given how I started this feature request, I'm slightly inclined towards the former choice given the low-level nature and performance sensitivity of this library, but the latter is also pleasingly tidy. Either seems quite defensible, though. I think you're suggesting going with the second option; is that right?

@coveralls

coveralls commented Dec 20, 2016 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.3%) to 92.922% when pulling 757f052ebc113f10ca2f7793e647f6122d23489a on marshallpierce:port-webpki-spki-signature-verification into 53fd7f9 on briansmith:master.

1 similar comment
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.3%) to 92.922% when pulling 757f052ebc113f10ca2f7793e647f6122d23489a on marshallpierce:port-webpki-spki-signature-verification into 53fd7f9 on briansmith:master.

@coveralls

coveralls commented Dec 20, 2016 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.3%) to 92.922% when pulling 757f052ebc113f10ca2f7793e647f6122d23489a on marshallpierce:port-webpki-spki-signature-verification into 53fd7f9 on briansmith:master.

@coveralls

coveralls commented Dec 20, 2016 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.3%) to 92.922% when pulling 757f052ebc113f10ca2f7793e647f6122d23489a on marshallpierce:port-webpki-spki-signature-verification into 53fd7f9 on briansmith:master.

1 similar comment
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.3%) to 92.922% when pulling 757f052ebc113f10ca2f7793e647f6122d23489a on marshallpierce:port-webpki-spki-signature-verification into 53fd7f9 on briansmith:master.

@briansmith briansmith added this to the 0.7.1 milestone Dec 22, 2016
@briansmith

Copy link
Copy Markdown
Owner

I think you're suggesting going with the second option; is that right?

Yes. If people are building other DER-parsing things, they might have to do the awkward thing I propose for webpki, but we could just make that less awkward in the future, if so.

@marshallpierce marshallpierce left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is now pretty close to done. There are a handful of comments that could use your input, especially the failure to load 8192-bit keypairs.

Comment thread tests/spki_tests.rs Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it planned to support RSA SHA1 signatures? If not I'll remove the todo.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do support verifying RSA PKCS#1 SHA-1 signatures but not RSA PSS SHA-1 signatures. We don't support signing with SHA-1 at all.

Comment thread tests/spki_tests.rs Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it planned to expose PSS modes for the 3072-8192bit key RSA algorithm? If not I'll remove this todo.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go ahead and remove that comment. I am not sure what we're doing with the 3072_8192 stuff yet.

Comment thread tests/spki_tests.rs Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From here on are tests that existed already in webpki's version of this code

Comment thread src/signature/spki.rs Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this field public because it seemed like it might be generally useful.

Comment thread src/signature/spki.rs Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one I didn't make public because I'm not sure why anyone outside this library would need it. But on the other hand, it feels odd to have one private field in a public struct...

Comment thread src/signature/spki.rs Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one I made public because now people need to access it to use with the result of parse_spki.

Comment thread src/der.rs Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are failing on android because the files are not present. I'll see if I can track down why.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like travis.sh needs to copy over the chromium *.pem files like it copies over the txt test files. However, the current setup also isn't running integration tests (like the new spki ones) since it only copies over target/(release|debug)/ring-* and the test file for spki is target/(release|debug)/signature_spki_tests-*.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Android tests are now running all test targets.

@marshallpierce
marshallpierce force-pushed the port-webpki-spki-signature-verification branch from 2d16fd1 to f3c8538 Compare February 9, 2017 18:52
@coveralls

coveralls commented Feb 10, 2017 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.2%) to 93.32% when pulling fe5cb4cbf152e3e5adb21ae7b4f40f5a85ee7d55 on marshallpierce:port-webpki-spki-signature-verification into a891756 on briansmith:master.

@coveralls

coveralls commented Feb 10, 2017 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.3%) to 93.268% when pulling fe5cb4cbf152e3e5adb21ae7b4f40f5a85ee7d55 on marshallpierce:port-webpki-spki-signature-verification into a891756 on briansmith:master.

@briansmith briansmith changed the title Port webpki spki signature verification Add a feature to parse SubjectPublicKeyInfo into (signature::Algorithm, SubjectPublicKey) Mar 7, 2017
@briansmith

Copy link
Copy Markdown
Owner

Hi, I'm getting caught up on my PRs now and Id like to review and merge this but I'm not certain what the state of this is. I think we had some agreement to replace ring::signature::spki::verify() with a parse_spki() function, but the current PR doesn't seem to do that.

Please rebase the changes on top of the current master (I just tested it myself locally and there was only one conflict). Also, please clean up the commits by folding fixes into the commits they fix. For example, fold the "Fix a comment typo;" commit into the commit that introduced the typo. Similarly, instead of having a commit that introduces the new verify() function and then a commit that changes it to parse_spki(), let's just go straight to parse_spki().

I know that rewriting the PRs is a PITA (I do it all the time), but it's going to be too hard and time consuming for me to review the PR in its current state, and the harder it is to review the longer it will take me to find time to merge it.

Thanks!

contents of signed_data.rs, plus one der support function. webpki::Error
was moved over and renamed to VerifyWithSPKIError (with some unused
options trimmed), but otherwise modifications were limited to getting
names resolving in the new structure.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
@marshallpierce
marshallpierce force-pushed the port-webpki-spki-signature-verification branch from fe5cb4c to a002497 Compare March 7, 2017 15:34
…ication (not signature or digest algorithm selection, etc).

Inapplicable tests deleted.
Remove now-unused code for handling SignedData.
Delete tests that would requre ECDSA p256 SHA512 as that will not be supported.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
… signing

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
…licable here

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
Rename SignatureAlgorithm to just Algorithm, and add some comments

Generate test data, keys, and signatures for a variety of rsa and ecdsa parameters.
Add integration tests for RSA and ECDSA spki signature verification.
Move pem decoding logic to a helper module in `tests/common`.

Turn warnings back on.

Copy third-party/chromium/**.pem into android work dir.
Tweak how the android build pushes test binaries into the emulator.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
@marshallpierce
marshallpierce force-pushed the port-webpki-spki-signature-verification branch from a002497 to e93d02f Compare March 7, 2017 16:32
@marshallpierce

Copy link
Copy Markdown
Contributor Author

Perhaps your local clone is out of date, or I'm misunderstanding what you're after? parse_spki is there: https://github.com/briansmith/ring/pull/378/files#diff-b66c7d2261ee98e3b53d332a09c4e037R49

I've rebased and squashed so that the interstitial form of verify no longer exists.

@coveralls

coveralls commented Mar 8, 2017 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.3%) to 93.462% when pulling e93d02f on marshallpierce:port-webpki-spki-signature-verification into d48469d on briansmith:master.

@coveralls

coveralls commented Mar 8, 2017 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.3%) to 93.462% when pulling e93d02f on marshallpierce:port-webpki-spki-signature-verification into d48469d on briansmith:master.

@briansmith briansmith left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, it looks like maybe you just recently updated this PR? It happens that I've been working through it locally and I made some non-trivial changes to it, so I'm not sure your most recent changes are going to be captured in the PR. Mostly my modifications involve just getting rid of the moving of the tests from one place to another because they were unwieldy to review. I also suggest a change to the API. I also modified the webpki crate to use this code and made some modifications based on that experience. Please check out https://github.com/briansmith/ring/tree/port-webpki-spki-signature-verification and LMK what you think.

Comment thread src/der.rs Outdated

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When merging, I reformatting this and also moved it ahead of nonnegative_integer so that all the integer-parsing code stays grouped together.

Comment thread Cargo.toml

[target.'cfg(any(target_os = "redox", all(unix, not(any(target_os = "macos", target_os = "ios")))))'.dependencies]
lazy_static = "0.2.1"
[dev-dependencies]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When merging this, I put a blank line ahead of this new section.

Comment thread .gitignore

# JetBrains Junk
.idea
*.iml

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I merged an earlier version of this change already, since .gitignore already contains these exact lines underneath "# Cargo Junk" below, so I removed this part of the change.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and removed annotate_test_data.py during merging since I really don't expect us to be using it in the future.

@briansmith briansmith modified the milestones: 0.7.n, 0.8.n Apr 10, 2017
@marshallpierce

Copy link
Copy Markdown
Contributor Author

Sorry I haven't gotten to this; I probably won't have time to go through your changes any time soon. I'm happy to let you do what you like with this PR's code as you see fit to make it usable for webpki, etc.

@briansmith

Copy link
Copy Markdown
Owner

Sorry I haven't gotten to this; I probably won't have time to go through your changes any time soon. I'm happy to let you do what you like with this PR's code as you see fit to make it usable for webpki, etc.

Thanks for your work on this. I'm going to close this issue and use what we learned from this to implement the feature later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants