Skip to content

CMS with encrypted detached data #2419

@ratal

Description

@ratal

Hi
I would need to encrypt data, not envelopped in CMS (need to split in blocks, etc. for specific purposes) while keeping the CMS for recipient to decrypt it later.
With openssl command line it is possible to:
openssl cms -encrypt -in <file_not_encrypted> -outform DER -out <metadata.der> -recip <certificate.pem> > <encrypted_file.bin>
However, the cms encrypt(certs: &StackRef<X509>, data: &[u8], cipher: Cipher, flags: CMSOptions) -> Result<CmsContentInfo, ErrorStack> do not allow to return encrypted data of mutate buffer containing encrypted data.

Looking at openssl library documentation for CMS_encrypt:
The data being encrypted is included in the CMS_ContentInfo structure, unless CMS_DETACHED is set in which case it is omitted. This is rarely used in practice and is not supported by SMIME_write_CMS().

Where does come from the limitation? Is it rust openssl crate or openssl library? If openssl, I do not get why you can do in command line but not supported from library, because it is rarely used..

Should I consider workaround, like envelopping in CMS to then later extract it and replace to empty type, or propose a pull request?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions