Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specs for multiple PCKS7 signatures #26

Open
ct-clearhaus opened this issue Jul 2, 2018 · 5 comments
Open

Specs for multiple PCKS7 signatures #26

ct-clearhaus opened this issue Jul 2, 2018 · 5 comments

Comments

@ct-clearhaus
Copy link
Member

By adjusting PedicelPay::Backend#sign to err if the token already has a signature, I notice that only 4 specs fail, namely

rspec ./spec/lib/pedicel/ec_spec.rb:85 # Pedicel::EC #validate_signature errs if transaction_id has been changed
rspec ./spec/lib/pedicel/ec_spec.rb:93 # Pedicel::EC #validate_signature errs if ephemeral_public_key has been changed
rspec ./spec/lib/pedicel/ec_spec.rb:101 # Pedicel::EC #validate_signature errs if encrypted_data has been changed
rspec ./spec/lib/pedicel/ec_spec.rb:109 # Pedicel::EC #validate_signature errs if application_data has been changed

But by removing the if token.signature section completely makes the specs succeed. Thus, it seems it's not used anywhere that pedicel-pay support adding to the PKCS7 signature.

I think we should test this. However, I also think the default behaviour in PedicelPay::Backend#sign should be to overwrite the signature; there could be a overwrite: true default flag.

@kse-clearhaus WDYT?

@ct-clearhaus
Copy link
Member Author

See clearhaus/pedicel-pay#7 for the adjustment of pedicel-pay I have in mind 🙂

@kse-clearhaus
Copy link
Contributor

I think the overwrite: true parameter makes sense, since this is most likely the use case. I prefer replace, though.

The case that we want to catch, is if a non Apple-signed signature is added, we don't want to accidentally use that and accept that as a valid signature.
But as we already check if we (erroneously) accept a signature with a different root certificate, I don't think a new test is required.

@ct-clearhaus
Copy link
Member Author

It's renamed to replace; I merged and made another release of pedicel-pay 🙂

IRL discussion:

But doesn't "Verify the signature as follows" state that there must be exactly one signer?

Well, not necessarily, since one PKCS7 signature can have multiple signers (cf. https://tools.ietf.org/html/rfc5652#section-5.1).

We could even read it as

If there's just one signer that signed it "within a few minutes", then it's all good.

but we've decided that we accept it only when there's exactly one signer. And since we do this, we could move the check earlier and fail slightly less weird.

This piece of code should be hit by a test no matter what.

@kse-clearhaus
Copy link
Contributor

A pull request related to this is #27.

@ct-clearhaus
Copy link
Member Author

A pull request related to this is #27.

Agreed. However, we still miss a test to hit the code that makes pedicel err when multiple signers is present in the signature.

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

No branches or pull requests

2 participants