You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Explicitly tagged ("doubly-constructed"?) sequences do seem to be a thing:
ContentInfo ::=SEQUENCE {
contentType ContentType,
content [0] EXPLICITANY DEFINED BY contentType }
EnvelopedData ::=SEQUENCE { -- this is content when contentType is 1.2.840.113549.1.7.3
version CMSVersion,
originatorInfo [0] IMPLICIT OriginatorInfo OPTIONAL,
recipientInfos RecipientInfos,
encryptedContentInfo EncryptedContentInfo,
unprotectedAttrs [1] IMPLICIT UnprotectedAttributes OPTIONAL }
However, the current codebase chokes on them:
fromCrypto.Util.asn1import*importemail.parserimportsubprocesscmd= ['openssl', 'cms', '-encrypt', '-pwri_password', 'lol123']
plaintext='Plaintext Message'.encode()
m, err=subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate(plaintext)
asserterrisNone, err.decode()
m_der=email.parser.BytesParser().parsebytes(m).get_payload(decode=True)
print(m_der.hex())
m_obj=DerSequence().decode(m_der)
taggedEnvelopedData_der=m_obj[1]
envelopedData_obj=Nonetry:
envelopedData_obj=DerSequence().decode(taggedEnvelopedData_der)
exceptValueError:
print("Couldn't parse it as a Sequence!")
try:
envelopedData_obj=DerOctetString().decode(taggedEnvelopedData_der)
exceptValueError:
print("Couldn't parse it as an Octet String!")
ifenvelopedData_objisNone:
print("Falling back on instantiating a DerObject, then taking the payload.")
print("The tag octet we can't seem to cope with is 0x%02x."%taggedEnvelopedData_der[0])
_envelopedData_obj=DerObject().decode(taggedEnvelopedData_der)
envelopedData_obj=DerSequence().decode(_envelopedData_obj.payload)
taggedEnvelopedData_obj=DerSequence(envelopedData_obj, explicit=0) # This line is what's currently erroring outasserttaggedEnvelopedData_obj.encode() ==taggedEnvelopedData_der, "If you're seeing this message, something unexpected has gone wrong"
This might prove an issue for CMS support, which is on the future roadmap / wishlist.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Explicitly tagged ("doubly-constructed"?) sequences do seem to be a thing:
However, the current codebase chokes on them:
This might prove an issue for CMS support, which is on the future roadmap / wishlist.
Beta Was this translation helpful? Give feedback.
All reactions