Skip to content

Commit

Permalink
Allow to decrypt legacy payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
ConsulFirmin committed Aug 11, 2023
1 parent b35c703 commit 00ba149
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion decrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,22 @@ func (eci encryptedContentInfo) decrypt(key []byte) ([]byte, error) {

_, err := asn1.Unmarshal(paramBytes, &params)
if err != nil {
return nil, err

// Test legacy (and faulty) ASN.1 structure to allow
// libraries depending on older pkcs7 releases to still
// function.
paramsLegacy := struct {
Nonce []byte `asn1:"tag:4"`
ICVLen int
}{}

_, err := asn1.Unmarshal(paramBytes, &paramsLegacy)
if err != nil {
return nil, err
}

params.Nonce = paramsLegacy.Nonce
params.ICVLen = paramsLegacy.ICVLen
}

gcm, err := cipher.NewGCM(block)
Expand Down

0 comments on commit 00ba149

Please sign in to comment.