Closed JRomainG closed 2 years ago
That output actually looks correct to me. This is the definition in RFC 5652:
EncryptedContentInfo ::= SEQUENCE {
contentType ContentType,
contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier,
encryptedContent [0] IMPLICIT EncryptedContent OPTIONAL }
The tag on the encryptedContent
field is marked as implicit, which means that the "inner" universal OCTET STRING
tag on EncryptedContent
is not actually encoded in BER. The [0]
tag takes its place.
But I'm mostly going off my memory of X.690 here, so take that with a grain of salt.
Thanks for the answer @MatthiasValvekens!
I performed some further tests, and it seems like you are indeed right. It seems like openssl asn1parse
simply doesn't show the content of the implicit field. Other commands, like openssl pkcs7
, do show it correctly though.
Description
Generating ASN.1 using the
.dump
function of anEncryptedContentInfo
object seems to yield invalid data.Version
I tried with the latest version from pip:
as well as by cloning the
master
branch from this repository. The bug seems to be present in both versions.Reproducing
I encountered this bug when using
EncryptedContentInfo
, and derived a minimal example using this class. I did not check if the same bug happens for other classes though.The output of this script is the following:
Parsing the dumped value using
openssl
shows a missing field (encrypted_content
):Using this parser seems to show that the field is indeed not properly encoded:
whereas it should probably be:
Would that be accurate or is there a misunderstanding on my part?