
Wie überprüft man die Gültigkeit einer Datei mit OpenSSL und CMS?
Ich habe eine Datei (foo.bin) und eine Signatur (foo.bin.cms), die ein Zertifikat im x509-Format enthält.
Gibt es eine Möglichkeit, die Gültigkeit der Datei mit ihrem Zertifikat zu überprüfen?
Ich kann SHA256 von foo.bin innerhalb von foo.bin.cms finden.
foo.bin.cms kann auch mit ASN1 geöffnet werden. Kann aber keine Möglichkeit finden, die Datei mit dem OpenSSL-Befehl zu verifizieren.
Der OpenSSL-CMS-Verify-Befehl erfordert einen Pub.key, den ich nicht finden kann.
Antwort1
Für die CMS-Verifizierung ist möglicherweise ein Zertifikat erforderlich, aber nie ein öffentlicher Schlüssel als solcher. Es gibt viele Variationen im CMS-SignedData-Format (ganz zu schweigen von den anderen Arten von CMS-Daten) und Sie geben keine Details an, daher hier ein paar grundlegende Fälle:
$ openssl genpkey -algorithm ec -pkeyopt ec_paramgen_curve:P-256 -out sf1132354.key
$ openssl req -new -key sf1132354.key -x509 -days 365 -subj '/CN=Vladimir Putin' -out sf1132354.crt
$ printf 'hello and goodbye\r\n' >sf1132354.in
$ openssl sha256 <sf1132354.in
(stdin)= dc86ba13ac17e82ea9f0e8239f809d0596449dc3b59626b6ebd6178f27178af4
Diese Daten werden für alle unten aufgeführten Fälle verwendet. Beachten Sie, dass ich für die Daten die Zeilenenden CRLF verwendet habe. openssl cms
Standardmäßig wird die S/MIME-Kanonisierungsregel auch dann angewendet, wenn CMS und nicht S/MIME verwendet wird. Daher können andere Zeilenenden als CRLF Probleme verursachen.
$ openssl cms -sign -in sf1132354.in -inkey sf1132354.key -signer sf1132354.crt -md sha256 -outform der -out sf1132354.dety
$ openssl asn1parse -i -inform der <sf1132354.dety
0:d=0 hl=4 l= 839 cons: SEQUENCE
4:d=1 hl=2 l= 9 prim: OBJECT :pkcs7-signedData
15:d=1 hl=4 l= 824 cons: cont [ 0 ]
19:d=2 hl=4 l= 820 cons: SEQUENCE
23:d=3 hl=2 l= 1 prim: INTEGER :01
26:d=3 hl=2 l= 13 cons: SET
28:d=4 hl=2 l= 11 cons: SEQUENCE
30:d=5 hl=2 l= 9 prim: OBJECT :sha256
41:d=3 hl=2 l= 11 cons: SEQUENCE
43:d=4 hl=2 l= 9 prim: OBJECT :pkcs7-data
54:d=3 hl=4 l= 395 cons: cont [ 0 ]
58:d=4 hl=4 l= 391 cons: SEQUENCE
62:d=5 hl=4 l= 301 cons: SEQUENCE
66:d=6 hl=2 l= 3 cons: cont [ 0 ]
68:d=7 hl=2 l= 1 prim: INTEGER :02
71:d=6 hl=2 l= 20 prim: INTEGER :09D45914492F88F6E9812C905D2A0405C5769CCD
93:d=6 hl=2 l= 10 cons: SEQUENCE
95:d=7 hl=2 l= 8 prim: OBJECT :ecdsa-with-SHA256
105:d=6 hl=2 l= 25 cons: SEQUENCE
107:d=7 hl=2 l= 23 cons: SET
109:d=8 hl=2 l= 21 cons: SEQUENCE
111:d=9 hl=2 l= 3 prim: OBJECT :commonName
116:d=9 hl=2 l= 14 prim: UTF8STRING :Vladimir Putin
132:d=6 hl=2 l= 30 cons: SEQUENCE
134:d=7 hl=2 l= 13 prim: UTCTIME :230601075720Z
149:d=7 hl=2 l= 13 prim: UTCTIME :240531075720Z
164:d=6 hl=2 l= 25 cons: SEQUENCE
166:d=7 hl=2 l= 23 cons: SET
168:d=8 hl=2 l= 21 cons: SEQUENCE
170:d=9 hl=2 l= 3 prim: OBJECT :commonName
175:d=9 hl=2 l= 14 prim: UTF8STRING :Vladimir Putin
191:d=6 hl=2 l= 89 cons: SEQUENCE
193:d=7 hl=2 l= 19 cons: SEQUENCE
195:d=8 hl=2 l= 7 prim: OBJECT :id-ecPublicKey
204:d=8 hl=2 l= 8 prim: OBJECT :prime256v1
214:d=7 hl=2 l= 66 prim: BIT STRING
282:d=6 hl=2 l= 83 cons: cont [ 3 ]
284:d=7 hl=2 l= 81 cons: SEQUENCE
286:d=8 hl=2 l= 29 cons: SEQUENCE
288:d=9 hl=2 l= 3 prim: OBJECT :X509v3 Subject Key Identifier
293:d=9 hl=2 l= 22 prim: OCTET STRING [HEX DUMP]:0414AFBF46DE3CED60E2A5BBEA461C187C4FBE4D4654
317:d=8 hl=2 l= 31 cons: SEQUENCE
319:d=9 hl=2 l= 3 prim: OBJECT :X509v3 Authority Key Identifier
324:d=9 hl=2 l= 24 prim: OCTET STRING [HEX DUMP]:30168014AFBF46DE3CED60E2A5BBEA461C187C4FBE4D4654
350:d=8 hl=2 l= 15 cons: SEQUENCE
352:d=9 hl=2 l= 3 prim: OBJECT :X509v3 Basic Constraints
357:d=9 hl=2 l= 1 prim: BOOLEAN :255
360:d=9 hl=2 l= 5 prim: OCTET STRING [HEX DUMP]:30030101FF
367:d=5 hl=2 l= 10 cons: SEQUENCE
369:d=6 hl=2 l= 8 prim: OBJECT :ecdsa-with-SHA256
379:d=5 hl=2 l= 72 prim: BIT STRING
453:d=3 hl=4 l= 386 cons: SET
457:d=4 hl=4 l= 382 cons: SEQUENCE
461:d=5 hl=2 l= 1 prim: INTEGER :01
464:d=5 hl=2 l= 49 cons: SEQUENCE
466:d=6 hl=2 l= 25 cons: SEQUENCE
468:d=7 hl=2 l= 23 cons: SET
470:d=8 hl=2 l= 21 cons: SEQUENCE
472:d=9 hl=2 l= 3 prim: OBJECT :commonName
477:d=9 hl=2 l= 14 prim: UTF8STRING :Vladimir Putin
493:d=6 hl=2 l= 20 prim: INTEGER :09D45914492F88F6E9812C905D2A0405C5769CCD
515:d=5 hl=2 l= 11 cons: SEQUENCE
517:d=6 hl=2 l= 9 prim: OBJECT :sha256
528:d=5 hl=3 l= 228 cons: cont [ 0 ]
531:d=6 hl=2 l= 24 cons: SEQUENCE
533:d=7 hl=2 l= 9 prim: OBJECT :contentType
544:d=7 hl=2 l= 11 cons: SET
546:d=8 hl=2 l= 9 prim: OBJECT :pkcs7-data
557:d=6 hl=2 l= 28 cons: SEQUENCE
559:d=7 hl=2 l= 9 prim: OBJECT :signingTime
570:d=7 hl=2 l= 15 cons: SET
572:d=8 hl=2 l= 13 prim: UTCTIME :230601075746Z
587:d=6 hl=2 l= 47 cons: SEQUENCE
589:d=7 hl=2 l= 9 prim: OBJECT :messageDigest
600:d=7 hl=2 l= 34 cons: SET
602:d=8 hl=2 l= 32 prim: OCTET STRING [HEX DUMP]:DC86BA13AC17E82EA9F0E8239F809D0596449DC3B59626B6EBD6178F27178AF4
636:d=6 hl=2 l= 121 cons: SEQUENCE
638:d=7 hl=2 l= 9 prim: OBJECT :S/MIME Capabilities
649:d=7 hl=2 l= 108 cons: SET
651:d=8 hl=2 l= 106 cons: SEQUENCE
653:d=9 hl=2 l= 11 cons: SEQUENCE
655:d=10 hl=2 l= 9 prim: OBJECT :aes-256-cbc
666:d=9 hl=2 l= 11 cons: SEQUENCE
668:d=10 hl=2 l= 9 prim: OBJECT :aes-192-cbc
679:d=9 hl=2 l= 11 cons: SEQUENCE
681:d=10 hl=2 l= 9 prim: OBJECT :aes-128-cbc
692:d=9 hl=2 l= 10 cons: SEQUENCE
694:d=10 hl=2 l= 8 prim: OBJECT :des-ede3-cbc
704:d=9 hl=2 l= 14 cons: SEQUENCE
706:d=10 hl=2 l= 8 prim: OBJECT :rc2-cbc
716:d=10 hl=2 l= 2 prim: INTEGER :80
720:d=9 hl=2 l= 13 cons: SEQUENCE
722:d=10 hl=2 l= 8 prim: OBJECT :rc2-cbc
732:d=10 hl=2 l= 1 prim: INTEGER :40
735:d=9 hl=2 l= 7 cons: SEQUENCE
737:d=10 hl=2 l= 5 prim: OBJECT :des-cbc
744:d=9 hl=2 l= 13 cons: SEQUENCE
746:d=10 hl=2 l= 8 prim: OBJECT :rc2-cbc
756:d=10 hl=2 l= 1 prim: INTEGER :28
759:d=5 hl=2 l= 10 cons: SEQUENCE
761:d=6 hl=2 l= 8 prim: OBJECT :ecdsa-with-SHA256
771:d=5 hl=2 l= 70 prim: OCTET STRING [HEX DUMP]:30440220497700032BB7F3B6974C6653D926320E2DDC5616565119ED7E968C2B155635CF022030DDA85378C9002AA8E29949FC39A9FD333A9D62B52C8EBB0F73B5D21EE3720E
$ openssl cms -verify -in sf1132354.dety -inform der -content sf1132354.in -CAfile sf1132354.crt
hello and goodbye
Verification successful
$ openssl cms -verify -in sf1132354.dety -inform der -content sf1132354.in -noverify
hello and goodbye
Verification successful
Dies ist die Standardvariante für openssl cms -sign
: eine getrennte Signatur (Sie können sehen, dass ab Offset 41 kein eContent in den encapContentInfo vorhanden ist) mit signierten Attributen (Sie können dies ab Offset 528 sehen) und einer Kopie des Zertifikats des Unterzeichners (ab Offset 58). Wenn signierte Attribute vorhanden sind, führt der Überprüfungsvorgang normalerweise drei Dinge aus:
- Berechne den Hash der Daten (den ich angeben musste,
-content
da er nicht in den SignedData enthalten ist) und vergleiche ihn mit demmessageDigest
Attribut in signedattrs - Überprüfen Sie, ob die Signatur (bei Offset 759) die „kanonische“ Kodierung von SignedAttrs (d. h. mit dem durch SET OF ersetzten Context-3-Tag) unter dem öffentlichen Schlüssel im Zertifikat in der Nachricht bestätigt.
- Validieren Sie das in Schritt 2 verwendete Zertifikat anhand des Truststores (hier verwenden Sie
-CAfile
; es gibt kompliziertere Möglichkeiten, den Truststore anzugeben/zu erstellen, aber hier zeige ich nur die einfache)
Diese Kombination beweist, dass die Daten in der .in
Datei beim Empfänger/Verifizierer dieselben Daten sind, die vom Absender/Unterzeichner verwendet/beabsichtigt wurden, und dass sie nicht manipuliert oder anderweitig geändert wurden. Aber mit einem selbstsignierten Zertifikat wie hier beweist es NICHT, wer der Unterzeichner ist, oder dass Sie den von ihm signierten und gesendeten Daten vertrauen sollten; insbesondere behauptet dieses Zertifikat, ich sei Wladimir Putin, aber das bin ich nicht. Wirklich, ehrlich, das bin ich nicht – rufen Sie diese Angriffsdrohnen SCHNELL zurück :-}
Wenn der Unterzeichner ein von einer „echten“ (und ordnungsgemäß geführten) Zertifizierungsstelle ausgestelltes Zertifikat verwendet und der Prüfer dieses Zertifikat validiert hätte, hätte die Zertifizierungsstelle die Identität des „Eigentümers“ (Subjekt) des Zertifikats vor der Ausstellung geprüft. Durch diesen Vorgang wäre nicht nur sichergestellt, dass ich die vom Absender beabsichtigten Daten erhalten habe, sondern auch, dass es sich beim Absender um eine Person handelt, die ich identifizieren und der ich vertrauen kann, ob (und wie sehr) ich ihr vertrauen kann.
Der letzte (oxymoronisch wirkende) Befehl überspringt Schritt 3; er überprüft nur, ob die Daten mit den Signaturen übereinstimmen, und die Signatur (mit dem Schlüssel im Zertifikat) überprüft die Signaturen, validiert aber nicht das Zertifikat (und benötigt keinen Truststore). Dies beweist, dass Sie die Daten unverfälscht von derselben Partei erhalten haben, die die Signatur erstellt hat, aber diese Partei kann ein Angreifer gewesen sein und die Daten können gefälscht und bösartig sein, obwohl die Signatur verifiziert ist.
$ openssl cms -sign -in sf1132354.in -inkey sf1132354.key -signer sf1132354.crt -md sha256 -outform der -out sf1132354.detn -noattr
$ openssl asn1parse -i -inform der <sf1132354.detn
0:d=0 hl=4 l= 607 cons: SEQUENCE
4:d=1 hl=2 l= 9 prim: OBJECT :pkcs7-signedData
15:d=1 hl=4 l= 592 cons: cont [ 0 ]
19:d=2 hl=4 l= 588 cons: SEQUENCE
23:d=3 hl=2 l= 1 prim: INTEGER :01
26:d=3 hl=2 l= 13 cons: SET
28:d=4 hl=2 l= 11 cons: SEQUENCE
30:d=5 hl=2 l= 9 prim: OBJECT :sha256
41:d=3 hl=2 l= 11 cons: SEQUENCE
43:d=4 hl=2 l= 9 prim: OBJECT :pkcs7-data
54:d=3 hl=4 l= 395 cons: cont [ 0 ]
58:d=4 hl=4 l= 391 cons: SEQUENCE
62:d=5 hl=4 l= 301 cons: SEQUENCE
66:d=6 hl=2 l= 3 cons: cont [ 0 ]
68:d=7 hl=2 l= 1 prim: INTEGER :02
71:d=6 hl=2 l= 20 prim: INTEGER :09D45914492F88F6E9812C905D2A0405C5769CCD
93:d=6 hl=2 l= 10 cons: SEQUENCE
95:d=7 hl=2 l= 8 prim: OBJECT :ecdsa-with-SHA256
105:d=6 hl=2 l= 25 cons: SEQUENCE
107:d=7 hl=2 l= 23 cons: SET
109:d=8 hl=2 l= 21 cons: SEQUENCE
111:d=9 hl=2 l= 3 prim: OBJECT :commonName
116:d=9 hl=2 l= 14 prim: UTF8STRING :Vladimir Putin
132:d=6 hl=2 l= 30 cons: SEQUENCE
134:d=7 hl=2 l= 13 prim: UTCTIME :230601075720Z
149:d=7 hl=2 l= 13 prim: UTCTIME :240531075720Z
164:d=6 hl=2 l= 25 cons: SEQUENCE
166:d=7 hl=2 l= 23 cons: SET
168:d=8 hl=2 l= 21 cons: SEQUENCE
170:d=9 hl=2 l= 3 prim: OBJECT :commonName
175:d=9 hl=2 l= 14 prim: UTF8STRING :Vladimir Putin
191:d=6 hl=2 l= 89 cons: SEQUENCE
193:d=7 hl=2 l= 19 cons: SEQUENCE
195:d=8 hl=2 l= 7 prim: OBJECT :id-ecPublicKey
204:d=8 hl=2 l= 8 prim: OBJECT :prime256v1
214:d=7 hl=2 l= 66 prim: BIT STRING
282:d=6 hl=2 l= 83 cons: cont [ 3 ]
284:d=7 hl=2 l= 81 cons: SEQUENCE
286:d=8 hl=2 l= 29 cons: SEQUENCE
288:d=9 hl=2 l= 3 prim: OBJECT :X509v3 Subject Key Identifier
293:d=9 hl=2 l= 22 prim: OCTET STRING [HEX DUMP]:0414AFBF46DE3CED60E2A5BBEA461C187C4FBE4D4654
317:d=8 hl=2 l= 31 cons: SEQUENCE
319:d=9 hl=2 l= 3 prim: OBJECT :X509v3 Authority Key Identifier
324:d=9 hl=2 l= 24 prim: OCTET STRING [HEX DUMP]:30168014AFBF46DE3CED60E2A5BBEA461C187C4FBE4D4654
350:d=8 hl=2 l= 15 cons: SEQUENCE
352:d=9 hl=2 l= 3 prim: OBJECT :X509v3 Basic Constraints
357:d=9 hl=2 l= 1 prim: BOOLEAN :255
360:d=9 hl=2 l= 5 prim: OCTET STRING [HEX DUMP]:30030101FF
367:d=5 hl=2 l= 10 cons: SEQUENCE
369:d=6 hl=2 l= 8 prim: OBJECT :ecdsa-with-SHA256
379:d=5 hl=2 l= 72 prim: BIT STRING
453:d=3 hl=3 l= 155 cons: SET
456:d=4 hl=3 l= 152 cons: SEQUENCE
459:d=5 hl=2 l= 1 prim: INTEGER :01
462:d=5 hl=2 l= 49 cons: SEQUENCE
464:d=6 hl=2 l= 25 cons: SEQUENCE
466:d=7 hl=2 l= 23 cons: SET
468:d=8 hl=2 l= 21 cons: SEQUENCE
470:d=9 hl=2 l= 3 prim: OBJECT :commonName
475:d=9 hl=2 l= 14 prim: UTF8STRING :Vladimir Putin
491:d=6 hl=2 l= 20 prim: INTEGER :09D45914492F88F6E9812C905D2A0405C5769CCD
513:d=5 hl=2 l= 11 cons: SEQUENCE
515:d=6 hl=2 l= 9 prim: OBJECT :sha256
526:d=5 hl=2 l= 10 cons: SEQUENCE
528:d=6 hl=2 l= 8 prim: OBJECT :ecdsa-with-SHA256
538:d=5 hl=2 l= 71 prim: OCTET STRING [HEX DUMP]:3045022100B5B167CC707D015025C9631EEA3D351E6B53ABB5AE1280A975ABE5D6EB92A4F90220525F75DF118479B6E41A9983104E6B55D215E5A5C4DBBD41B66511A25278479E
$ openssl cms -verify -in sf1132354.detn -inform der -content sf1132354.in -CAfile sf1132354.crt
hello and goodbye
Verification successful
$ openssl cms -verify -in sf1132354.detn -inform der -content sf1132354.in -noverify
hello and goodbye
Verification successful
Diese Variante verwendet keine Signedattrs, daher wird die Zusammenfassung des Inhalts nirgendwo angezeigt und der Überprüfungsprozess ist anders:
- Überprüfen Sie die Signatur über dieInhalt(keine signierten Attribute) unter Verwendung des öffentlichen Schlüssels im Zertifikat
- Zertifikat validieren
... und jetzt -noverify
überspringt die Version Schritt 2 und führt nur Schritt 1 aus.
$ openssl cms -sign -in sf1132354.in -inkey sf1132354.key -signer sf1132354.crt -md sha256 -outform der -out sf1132354.envy -nodetach
$ openssl asn1parse -i -inform der <sf1132354.envy 0:d=0 hl=4 l= 862 cons: SEQUENCE
4:d=1 hl=2 l= 9 prim: OBJECT :pkcs7-signedData
15:d=1 hl=4 l= 847 cons: cont [ 0 ]
19:d=2 hl=4 l= 843 cons: SEQUENCE
23:d=3 hl=2 l= 1 prim: INTEGER :01
26:d=3 hl=2 l= 13 cons: SET
28:d=4 hl=2 l= 11 cons: SEQUENCE
30:d=5 hl=2 l= 9 prim: OBJECT :sha256
41:d=3 hl=2 l= 34 cons: SEQUENCE
43:d=4 hl=2 l= 9 prim: OBJECT :pkcs7-data
54:d=4 hl=2 l= 21 cons: cont [ 0 ]
56:d=5 hl=2 l= 19 prim: OCTET STRING :hello and goodbye
77:d=3 hl=4 l= 395 cons: cont [ 0 ]
81:d=4 hl=4 l= 391 cons: SEQUENCE
85:d=5 hl=4 l= 301 cons: SEQUENCE
89:d=6 hl=2 l= 3 cons: cont [ 0 ]
91:d=7 hl=2 l= 1 prim: INTEGER :02
94:d=6 hl=2 l= 20 prim: INTEGER :09D45914492F88F6E9812C905D2A0405C5769CCD
116:d=6 hl=2 l= 10 cons: SEQUENCE
118:d=7 hl=2 l= 8 prim: OBJECT :ecdsa-with-SHA256
128:d=6 hl=2 l= 25 cons: SEQUENCE
130:d=7 hl=2 l= 23 cons: SET
132:d=8 hl=2 l= 21 cons: SEQUENCE
134:d=9 hl=2 l= 3 prim: OBJECT :commonName
139:d=9 hl=2 l= 14 prim: UTF8STRING :Vladimir Putin
155:d=6 hl=2 l= 30 cons: SEQUENCE
157:d=7 hl=2 l= 13 prim: UTCTIME :230601075720Z
172:d=7 hl=2 l= 13 prim: UTCTIME :240531075720Z
187:d=6 hl=2 l= 25 cons: SEQUENCE
189:d=7 hl=2 l= 23 cons: SET
191:d=8 hl=2 l= 21 cons: SEQUENCE
193:d=9 hl=2 l= 3 prim: OBJECT :commonName
198:d=9 hl=2 l= 14 prim: UTF8STRING :Vladimir Putin
214:d=6 hl=2 l= 89 cons: SEQUENCE
216:d=7 hl=2 l= 19 cons: SEQUENCE
218:d=8 hl=2 l= 7 prim: OBJECT :id-ecPublicKey
227:d=8 hl=2 l= 8 prim: OBJECT :prime256v1
237:d=7 hl=2 l= 66 prim: BIT STRING
305:d=6 hl=2 l= 83 cons: cont [ 3 ]
307:d=7 hl=2 l= 81 cons: SEQUENCE
309:d=8 hl=2 l= 29 cons: SEQUENCE
311:d=9 hl=2 l= 3 prim: OBJECT :X509v3 Subject Key Identifier
316:d=9 hl=2 l= 22 prim: OCTET STRING [HEX DUMP]:0414AFBF46DE3CED60E2A5BBEA461C187C4FBE4D4654
340:d=8 hl=2 l= 31 cons: SEQUENCE
342:d=9 hl=2 l= 3 prim: OBJECT :X509v3 Authority Key Identifier
347:d=9 hl=2 l= 24 prim: OCTET STRING [HEX DUMP]:30168014AFBF46DE3CED60E2A5BBEA461C187C4FBE4D4654
373:d=8 hl=2 l= 15 cons: SEQUENCE
375:d=9 hl=2 l= 3 prim: OBJECT :X509v3 Basic Constraints
380:d=9 hl=2 l= 1 prim: BOOLEAN :255
383:d=9 hl=2 l= 5 prim: OCTET STRING [HEX DUMP]:30030101FF
390:d=5 hl=2 l= 10 cons: SEQUENCE
392:d=6 hl=2 l= 8 prim: OBJECT :ecdsa-with-SHA256
402:d=5 hl=2 l= 72 prim: BIT STRING
476:d=3 hl=4 l= 386 cons: SET
480:d=4 hl=4 l= 382 cons: SEQUENCE
484:d=5 hl=2 l= 1 prim: INTEGER :01
487:d=5 hl=2 l= 49 cons: SEQUENCE
489:d=6 hl=2 l= 25 cons: SEQUENCE
491:d=7 hl=2 l= 23 cons: SET
493:d=8 hl=2 l= 21 cons: SEQUENCE
495:d=9 hl=2 l= 3 prim: OBJECT :commonName
500:d=9 hl=2 l= 14 prim: UTF8STRING :Vladimir Putin
516:d=6 hl=2 l= 20 prim: INTEGER :09D45914492F88F6E9812C905D2A0405C5769CCD
538:d=5 hl=2 l= 11 cons: SEQUENCE
540:d=6 hl=2 l= 9 prim: OBJECT :sha256
551:d=5 hl=3 l= 228 cons: cont [ 0 ]
554:d=6 hl=2 l= 24 cons: SEQUENCE
556:d=7 hl=2 l= 9 prim: OBJECT :contentType
567:d=7 hl=2 l= 11 cons: SET
569:d=8 hl=2 l= 9 prim: OBJECT :pkcs7-data
580:d=6 hl=2 l= 28 cons: SEQUENCE
582:d=7 hl=2 l= 9 prim: OBJECT :signingTime
593:d=7 hl=2 l= 15 cons: SET
595:d=8 hl=2 l= 13 prim: UTCTIME :230601083230Z
610:d=6 hl=2 l= 47 cons: SEQUENCE
612:d=7 hl=2 l= 9 prim: OBJECT :messageDigest
623:d=7 hl=2 l= 34 cons: SET
625:d=8 hl=2 l= 32 prim: OCTET STRING [HEX DUMP]:DC86BA13AC17E82EA9F0E8239F809D0596449DC3B59626B6EBD6178F27178AF4
659:d=6 hl=2 l= 121 cons: SEQUENCE
661:d=7 hl=2 l= 9 prim: OBJECT :S/MIME Capabilities
672:d=7 hl=2 l= 108 cons: SET
674:d=8 hl=2 l= 106 cons: SEQUENCE
676:d=9 hl=2 l= 11 cons: SEQUENCE
678:d=10 hl=2 l= 9 prim: OBJECT :aes-256-cbc
689:d=9 hl=2 l= 11 cons: SEQUENCE
691:d=10 hl=2 l= 9 prim: OBJECT :aes-192-cbc
702:d=9 hl=2 l= 11 cons: SEQUENCE
704:d=10 hl=2 l= 9 prim: OBJECT :aes-128-cbc
715:d=9 hl=2 l= 10 cons: SEQUENCE
717:d=10 hl=2 l= 8 prim: OBJECT :des-ede3-cbc
727:d=9 hl=2 l= 14 cons: SEQUENCE
729:d=10 hl=2 l= 8 prim: OBJECT :rc2-cbc
739:d=10 hl=2 l= 2 prim: INTEGER :80
743:d=9 hl=2 l= 13 cons: SEQUENCE
745:d=10 hl=2 l= 8 prim: OBJECT :rc2-cbc
755:d=10 hl=2 l= 1 prim: INTEGER :40
758:d=9 hl=2 l= 7 cons: SEQUENCE
760:d=10 hl=2 l= 5 prim: OBJECT :des-cbc
767:d=9 hl=2 l= 13 cons: SEQUENCE
769:d=10 hl=2 l= 8 prim: OBJECT :rc2-cbc
779:d=10 hl=2 l= 1 prim: INTEGER :28
782:d=5 hl=2 l= 10 cons: SEQUENCE
784:d=6 hl=2 l= 8 prim: OBJECT :ecdsa-with-SHA256
794:d=5 hl=2 l= 70 prim: OCTET STRING [HEX DUMP]:3044022004297664781BFF7FF183FBA4F8536C83A3EA796690B810970DDC3C49E5F28FCC0220048A0A573AD584282DF8C2079AAC5E036B33E414F9B55762A16A49B60D176E68
$ openssl cms -verify -in sf1132354.envy -inform der -CAfile sf1132354.crt
hello and goodbye
Verification successful
$ openssl cms -verify -in sf1132354.envy -inform der -noverify
hello and goodbye
Verification successful
$ openssl cms -sign -in sf1132354.in -inkey sf1132354.key -signer sf1132354.crt -md sha256 -outform der -out sf1132354.envn -nodetach -noattr
$ openssl asn1parse -i -inform der <sf1132354.envn
0:d=0 hl=4 l= 629 cons: SEQUENCE
4:d=1 hl=2 l= 9 prim: OBJECT :pkcs7-signedData
15:d=1 hl=4 l= 614 cons: cont [ 0 ]
19:d=2 hl=4 l= 610 cons: SEQUENCE
23:d=3 hl=2 l= 1 prim: INTEGER :01
26:d=3 hl=2 l= 13 cons: SET
28:d=4 hl=2 l= 11 cons: SEQUENCE
30:d=5 hl=2 l= 9 prim: OBJECT :sha256
41:d=3 hl=2 l= 34 cons: SEQUENCE
43:d=4 hl=2 l= 9 prim: OBJECT :pkcs7-data
54:d=4 hl=2 l= 21 cons: cont [ 0 ]
56:d=5 hl=2 l= 19 prim: OCTET STRING :hello and goodbye
77:d=3 hl=4 l= 395 cons: cont [ 0 ]
81:d=4 hl=4 l= 391 cons: SEQUENCE
85:d=5 hl=4 l= 301 cons: SEQUENCE
89:d=6 hl=2 l= 3 cons: cont [ 0 ]
91:d=7 hl=2 l= 1 prim: INTEGER :02
94:d=6 hl=2 l= 20 prim: INTEGER :09D45914492F88F6E9812C905D2A0405C5769CCD
116:d=6 hl=2 l= 10 cons: SEQUENCE
118:d=7 hl=2 l= 8 prim: OBJECT :ecdsa-with-SHA256
128:d=6 hl=2 l= 25 cons: SEQUENCE
130:d=7 hl=2 l= 23 cons: SET
132:d=8 hl=2 l= 21 cons: SEQUENCE
134:d=9 hl=2 l= 3 prim: OBJECT :commonName
139:d=9 hl=2 l= 14 prim: UTF8STRING :Vladimir Putin
155:d=6 hl=2 l= 30 cons: SEQUENCE
157:d=7 hl=2 l= 13 prim: UTCTIME :230601075720Z
172:d=7 hl=2 l= 13 prim: UTCTIME :240531075720Z
187:d=6 hl=2 l= 25 cons: SEQUENCE
189:d=7 hl=2 l= 23 cons: SET
191:d=8 hl=2 l= 21 cons: SEQUENCE
193:d=9 hl=2 l= 3 prim: OBJECT :commonName
198:d=9 hl=2 l= 14 prim: UTF8STRING :Vladimir Putin
214:d=6 hl=2 l= 89 cons: SEQUENCE
216:d=7 hl=2 l= 19 cons: SEQUENCE
218:d=8 hl=2 l= 7 prim: OBJECT :id-ecPublicKey
227:d=8 hl=2 l= 8 prim: OBJECT :prime256v1
237:d=7 hl=2 l= 66 prim: BIT STRING
305:d=6 hl=2 l= 83 cons: cont [ 3 ]
307:d=7 hl=2 l= 81 cons: SEQUENCE
309:d=8 hl=2 l= 29 cons: SEQUENCE
311:d=9 hl=2 l= 3 prim: OBJECT :X509v3 Subject Key Identifier
316:d=9 hl=2 l= 22 prim: OCTET STRING [HEX DUMP]:0414AFBF46DE3CED60E2A5BBEA461C187C4FBE4D4654
340:d=8 hl=2 l= 31 cons: SEQUENCE
342:d=9 hl=2 l= 3 prim: OBJECT :X509v3 Authority Key Identifier
347:d=9 hl=2 l= 24 prim: OCTET STRING [HEX DUMP]:30168014AFBF46DE3CED60E2A5BBEA461C187C4FBE4D4654
373:d=8 hl=2 l= 15 cons: SEQUENCE
375:d=9 hl=2 l= 3 prim: OBJECT :X509v3 Basic Constraints
380:d=9 hl=2 l= 1 prim: BOOLEAN :255
383:d=9 hl=2 l= 5 prim: OCTET STRING [HEX DUMP]:30030101FF
390:d=5 hl=2 l= 10 cons: SEQUENCE
392:d=6 hl=2 l= 8 prim: OBJECT :ecdsa-with-SHA256
402:d=5 hl=2 l= 72 prim: BIT STRING
476:d=3 hl=3 l= 154 cons: SET
479:d=4 hl=3 l= 151 cons: SEQUENCE
482:d=5 hl=2 l= 1 prim: INTEGER :01
485:d=5 hl=2 l= 49 cons: SEQUENCE
487:d=6 hl=2 l= 25 cons: SEQUENCE
489:d=7 hl=2 l= 23 cons: SET
491:d=8 hl=2 l= 21 cons: SEQUENCE
493:d=9 hl=2 l= 3 prim: OBJECT :commonName
498:d=9 hl=2 l= 14 prim: UTF8STRING :Vladimir Putin
514:d=6 hl=2 l= 20 prim: INTEGER :09D45914492F88F6E9812C905D2A0405C5769CCD
536:d=5 hl=2 l= 11 cons: SEQUENCE
538:d=6 hl=2 l= 9 prim: OBJECT :sha256
549:d=5 hl=2 l= 10 cons: SEQUENCE
551:d=6 hl=2 l= 8 prim: OBJECT :ecdsa-with-SHA256
561:d=5 hl=2 l= 70 prim: OCTET STRING [HEX DUMP]:304402207D12A9C0281FF39ED3DA7C0966E1B153D70150B25976B7FEBF8C35B92986861902202C8FA05D23E2988C06FC3A973104E88195596D94340A43802202A266D6DEFB43
$ openssl cms -verify -in sf1132354.envn -inform der -CAfile sf1132354.crt
hello and goodbye
Verification successful
$ openssl cms -verify -in sf1132354.envn -inform der -noverify
hello and goodbye
Verification successful
Es handelt sich um „umhüllende“ (nicht abgetrennte) Signaturen, dieTunFügen Sie den Inhalt ein (bei Offset 56) und verwenden Sie Signedattrs bzw. verwenden Sie sie nicht. Die Überprüfung erfolgt wie in den beiden obigen Fällen, außer dass ich sie jetzt nicht angeben muss, -content
da der Inhalt in den SignedData enthalten ist.
Es gibt noch mehr Fälle, aber ich habe bereits mehr Zeit mit diesem A verbracht, als anderen gegenüber fair ist, also werde ich hier aufhören. Wenn Ihr Fall anders ist, geben Sie klar an, wie das ist, und ich werde versuchen, in ein paar Tagen darauf zurückzukommen.