Skip to content

Support signing Firefox Addons - #14

Open
jvehent wants to merge 105 commits into
fullsailor:masterfrom
mozilla-services:master
Open

Support signing Firefox Addons#14
jvehent wants to merge 105 commits into
fullsailor:masterfrom
mozilla-services:master

Conversation

@jvehent

@jvehent jvehent commented Feb 27, 2017

Copy link
Copy Markdown
Contributor

This is a massive pull request, and I would understand if you do not want to merge it, but I thought I should share it and leave it up to you.

I am using this package to sign Firefox addons, and had to fix a number of limitations as well as add support for certificate chains for this to happen. I also added support for ECDSA and SHA2 algorithms. The code has been restructured in separate files to help with readability, and tests that use OpenSSL helped me make sure the PKCS7 structures are compatible with other implementations.

Ultimately, I think we'll keep referring to our fork from go.mozilla.org/pkcs7, since this is a sensitive piece of code for us, but would love to maintain upstream compatibility as much as possible.

Note: I couldn't figure out how to address the README changes. I might have to drop that patch.

jvehent and others added 21 commits February 6, 2017 12:31
Support S/MIME detached signatures, and improve tests
Add more checks around BER processing, fixes #2
This patch adds the ability to both sign and verify
signatures that contain a certificate chain. The root
of the chain is expected to be provided separately via
an x509.CertPool passed to the Verifier.

The added FirefoxAddon test case uses a certificate
chain to check the addon signature against the Firefox
Root CA.
Adding RSA SHA1-SHA512 support
Minor fixes to implement addon signing in firefox
Added support for encrypting using a pre-shared key
Implement crypto.Signer to support keys where the private part is kept in, for example, a hardware module.
Implement crypto.Signer for pkcs11/hsm support
@jvehent jvehent mentioned this pull request Jul 5, 2017
vanbroup and others added 8 commits July 19, 2017 22:27
The private key might not always be availible to determine the Encryption Algorithm, for example when the key is stored in hardware. This change brings the pkcs7 package in-line with the go crypto packages by using the crypto.Singer interface to obtain the public key.
Use public key for getOIDForEncryptionAlgorithm
This patch add a new method SetDigestAlgorithm to set the digest
algorihm used when signing data. It also exports all the OIDs to make
them usable outside the package, which artificially inflates the size
of this change.
Make the signing digest algorithm configurable
VJftw and others added 30 commits January 28, 2020 00:13
Fix go.mod module address
Replace travis CI with Github Actions.
ignore DSA tests on unsupported golang versions
Go 1.10 is more strict about Asn.1 annotations. This removes the incorrect “explicit” annotation from encryptedContentInfo.EncryptedContent.

I’m also using openssl to generate the fixture now so that we aren’t testing with our own output for `Decrypt()`

Cherry-pick upstream fullsailor@cddbb99
…ontent

Fix failure to parse enveloped data in Go 1.10
The test now validates a chain against a fixed time
that is known to be valid for the entire certificate chain.
Also fix an error in the same test with date/time parsing.
Fix FirefoxAddon test to not use current time.
Fix indefinite length asn1 parsing
encodeIndent was only there for debugging and not currently used for anything.
This was causing some projects downstream to fail testing with -race enabled.
+ Added `-race` to go test and made ber.go tests run in parallel
Fix race condition with unused code
`pkcs7.Parse()` could panic with out-of-bounds slice/index reads when given certain tiny malformed BER inputs, instead of returning an error (CWE-125 / CWE-193).
`readObject()` in ber.go guarded its cursor with `offset > berLen` rather than `>=`, letting `offset` reach `berLen` and still pass, so the subsequent `ber[offset]` read one past the end of the slice. The long-form length branch also sliced `ber[offset:offset+numberOfBytes]` with no upper-bound check.

- Change the high-tag-number guards to `offset >= berLen`
- Add an `offset+numberOfBytes > berLen` check before reading the long-form length octets.

Malformed inputs such as {1F 80}, {1F 05}, {30 81}, and {30 84 01} now return an error instead of panicking. Valid BER/DER, including empty definite-length objects and high-tag-number tags, is unaffected.

Add regression tests covering the malformed inputs (via ber2der and the exported `Parse` entry point) and a positive round-trip test for high-tag-number encodings.
Fix out-of-bounds panic in ber2der on malformed BER input
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.