Skip to content

Commit

Permalink
Add support of the 1000 bytes chunking of asn1-octets to unmarshal th…
Browse files Browse the repository at this point in the history
…e rest until its completeted.
  • Loading branch information
gataka committed Aug 22, 2018
1 parent 8306686 commit aa5eda5
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions pkcs7.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,24 @@ func parseSignedData(data []byte) (*PKCS7, error) {
}
// Compound octet string
if compound.IsCompound {
if _, err = asn1.Unmarshal(compound.Bytes, &content); err != nil {
bytesToMarshal := compound.Bytes
restOfCompound, err := asn1.Unmarshal(bytesToMarshal, &content)
if err != nil {
return nil, err
}
for {
if len(restOfCompound) > 0 {
var contentPart []byte
bytesToMarshal = restOfCompound
restOfCompound, err = asn1.Unmarshal(bytesToMarshal, &contentPart)
if err != nil {
return nil, err
}
content = append(content, contentPart...)
} else {
break
}
}
} else {
// assuming this is tag 04
content = compound.Bytes
Expand Down Expand Up @@ -301,8 +316,8 @@ func getHashForOID(oid asn1.ObjectIdentifier) (crypto.Hash, error) {
switch {
case oid.Equal(oidDigestAlgorithmSHA1):
return crypto.SHA1, nil
case oid.Equal(oidSHA256):
return crypto.SHA256, nil
case oid.Equal(oidSHA256):
return crypto.SHA256, nil
}
return crypto.Hash(0), ErrUnsupportedAlgorithm
}
Expand Down

0 comments on commit aa5eda5

Please sign in to comment.