wbond | e91513e | 2015-06-03 14:52:18 -0400 | [diff] [blame] | 1 | # coding: utf-8 |
wbond | ea25fc2 | 2015-06-19 15:07:04 -0400 | [diff] [blame] | 2 | |
| 3 | """ |
| 4 | ASN.1 type classes for PDF signature structures. Adds extra oid mapping and |
| 5 | value parsing to asn1crypto.x509.Extension() and asn1crypto.xms.CMSAttribute(). |
| 6 | """ |
| 7 | |
wbond | 6b66ab5 | 2015-06-21 10:26:45 -0400 | [diff] [blame] | 8 | from __future__ import unicode_literals, division, absolute_import, print_function |
wbond | e91513e | 2015-06-03 14:52:18 -0400 | [diff] [blame] | 9 | |
| 10 | from .cms import CMSAttributeType, CMSAttribute |
| 11 | from .core import ( |
| 12 | Boolean, |
| 13 | Integer, |
| 14 | Null, |
| 15 | ObjectIdentifier, |
| 16 | OctetString, |
| 17 | Sequence, |
wbond | 5d11964 | 2015-12-04 11:29:20 -0500 | [diff] [blame] | 18 | SequenceOf, |
wbond | e91513e | 2015-06-03 14:52:18 -0400 | [diff] [blame] | 19 | SetOf, |
| 20 | ) |
| 21 | from .crl import CertificateList |
| 22 | from .ocsp import OCSPResponse |
wbond | 5cf77ba | 2015-10-08 09:47:34 -0400 | [diff] [blame] | 23 | from .x509 import ( |
| 24 | Extension, |
| 25 | ExtensionId, |
| 26 | GeneralName, |
| 27 | KeyPurposeId, |
| 28 | ) |
wbond | e91513e | 2015-06-03 14:52:18 -0400 | [diff] [blame] | 29 | |
| 30 | |
wbond | e91513e | 2015-06-03 14:52:18 -0400 | [diff] [blame] | 31 | class AdobeArchiveRevInfo(Sequence): |
| 32 | _fields = [ |
| 33 | ('version', Integer) |
| 34 | ] |
| 35 | |
| 36 | |
| 37 | class AdobeTimestamp(Sequence): |
| 38 | _fields = [ |
| 39 | ('version', Integer), |
| 40 | ('location', GeneralName), |
wbond | 2ebcfea | 2016-07-10 21:41:24 -0400 | [diff] [blame] | 41 | ('requires_auth', Boolean, {'optional': True, 'default': False}), |
wbond | e91513e | 2015-06-03 14:52:18 -0400 | [diff] [blame] | 42 | ] |
| 43 | |
| 44 | |
| 45 | class OtherRevInfo(Sequence): |
| 46 | _fields = [ |
| 47 | ('type', ObjectIdentifier), |
| 48 | ('value', OctetString), |
| 49 | ] |
| 50 | |
| 51 | |
wbond | 5d11964 | 2015-12-04 11:29:20 -0500 | [diff] [blame] | 52 | class SequenceOfCertificateList(SequenceOf): |
| 53 | _child_spec = CertificateList |
| 54 | |
| 55 | |
| 56 | class SequenceOfOCSPResponse(SequenceOf): |
| 57 | _child_spec = OCSPResponse |
| 58 | |
| 59 | |
| 60 | class SequenceOfOtherRevInfo(SequenceOf): |
| 61 | _child_spec = OtherRevInfo |
| 62 | |
| 63 | |
wbond | e91513e | 2015-06-03 14:52:18 -0400 | [diff] [blame] | 64 | class RevocationInfoArchival(Sequence): |
| 65 | _fields = [ |
wbond | d62ed9a | 2017-09-15 07:13:52 -0400 | [diff] [blame] | 66 | ('crl', SequenceOfCertificateList, {'explicit': 0, 'optional': True}), |
| 67 | ('ocsp', SequenceOfOCSPResponse, {'explicit': 1, 'optional': True}), |
| 68 | ('other_rev_info', SequenceOfOtherRevInfo, {'explicit': 2, 'optional': True}), |
wbond | e91513e | 2015-06-03 14:52:18 -0400 | [diff] [blame] | 69 | ] |
| 70 | |
| 71 | |
| 72 | class SetOfRevocationInfoArchival(SetOf): |
| 73 | _child_spec = RevocationInfoArchival |
| 74 | |
| 75 | |
wbond | a26664f | 2015-10-07 11:57:35 -0400 | [diff] [blame] | 76 | ExtensionId._map['1.2.840.113583.1.1.9.2'] = 'adobe_archive_rev_info' |
| 77 | ExtensionId._map['1.2.840.113583.1.1.9.1'] = 'adobe_timestamp' |
| 78 | ExtensionId._map['1.2.840.113583.1.1.10'] = 'adobe_ppklite_credential' |
| 79 | Extension._oid_specs['adobe_archive_rev_info'] = AdobeArchiveRevInfo |
| 80 | Extension._oid_specs['adobe_timestamp'] = AdobeTimestamp |
| 81 | Extension._oid_specs['adobe_ppklite_credential'] = Null |
| 82 | KeyPurposeId._map['1.2.840.113583.1.1.5'] = 'pdf_signing' |
| 83 | CMSAttributeType._map['1.2.840.113583.1.1.8'] = 'adobe_revocation_info_archival' |
| 84 | CMSAttribute._oid_specs['adobe_revocation_info_archival'] = SetOfRevocationInfoArchival |