I have a lot of binary files that contain some data that is signed using CMS.
The files have the form:
$ openssl cms -inform DER -in test.cms -cmsout -print
CMS_ContentInfo:
contentType: pkcs7-signedData (1.2.840.113549.1.7.2)
d.signedData:
version: 3
digestAlgorithms:
algorithm: sha256 (2.16.840.1.101.3.4.2.1)
parameter: <ABSENT>
encapContentInfo:
eContentType: pkcs7-data (1.2.840.113549.1.7.1)
eContent:
0000 - 21 3c 61 72 63 68 3e 0a-64 65 62 69 61 6e 2d !<arch>.debian-
000f - 62 69 6e 61 72 79 2f 20-20 XX XX XX XX XX XX binary/ XXXXXX
[…]
10d82ab - d7 00 28 00 00 ..(..
certificates:
<ABSENT>
crls:
<ABSENT>
signerInfos:
version: 3
d.subjectKeyIdentifier:
0000 - (DATA REMOVED FOR PRIVACY REASONS)
000f - (DATA REMOVED FOR PRIVACY REASONS)
digestAlgorithm:
algorithm: sha256 (2.16.840.1.101.3.4.2.1)
parameter: <ABSENT>
signedAttrs:
object: contentType (1.2.840.113549.1.9.3)
set:
OBJECT:pkcs7-data (1.2.840.113549.1.7.1)
object: signingTime (1.2.840.113549.1.9.5)
set:
UTCTIME: (SOMETIME) 2021 GMT
object: messageDigest (1.2.840.113549.1.9.4)
set:
OCTET STRING:
0000 - (DATA REMOVED FOR PRIVACY REASONS)
000d - (DATA REMOVED FOR PRIVACY REASONS)
001a - (DATA REMOVED FOR PRIVACY REASONS)
signatureAlgorithm:
algorithm: ecdsa-with-SHA256 (1.2.840.10045.4.3.2)
parameter: <ABSENT>
signature:
0000 - (DATA REMOVED FOR PRIVACY REASONS)
000f - (DATA REMOVED FOR PRIVACY REASONS)
001e - (DATA REMOVED FOR PRIVACY REASONS)
002d - (DATA REMOVED FOR PRIVACY REASONS)
003c - (DATA REMOVED FOR PRIVACY REASONS)
unsignedAttrs:
<ABSENT>
I'm currently not interested in the signature. Is there an elegant way to strip it?
I can build work-around code that tries to analyze the output above, grep
in the file and dd
parts of it but this seems rather ugly.
openssl cms -in file -inform der -verify -nosigs -noverify -out newfile
(oxymoronic though it appears)