blob: b72c886ce5e5b33c2e17951a1d5b9c14c66e4e75 [file] [log] [blame]
wbonde91513e2015-06-03 14:52:18 -04001# coding: utf-8
wbondea25fc22015-06-19 15:07:04 -04002
3"""
4ASN.1 type classes for PDF signature structures. Adds extra oid mapping and
5value parsing to asn1crypto.x509.Extension() and asn1crypto.xms.CMSAttribute().
6"""
7
wbond6b66ab52015-06-21 10:26:45 -04008from __future__ import unicode_literals, division, absolute_import, print_function
wbonde91513e2015-06-03 14:52:18 -04009
10from .cms import CMSAttributeType, CMSAttribute
11from .core import (
12 Boolean,
13 Integer,
14 Null,
15 ObjectIdentifier,
16 OctetString,
17 Sequence,
wbond5d119642015-12-04 11:29:20 -050018 SequenceOf,
wbonde91513e2015-06-03 14:52:18 -040019 SetOf,
20)
21from .crl import CertificateList
22from .ocsp import OCSPResponse
wbond5cf77ba2015-10-08 09:47:34 -040023from .x509 import (
24 Extension,
25 ExtensionId,
26 GeneralName,
27 KeyPurposeId,
28)
wbonde91513e2015-06-03 14:52:18 -040029
30
wbonde91513e2015-06-03 14:52:18 -040031class AdobeArchiveRevInfo(Sequence):
32 _fields = [
33 ('version', Integer)
34 ]
35
36
37class AdobeTimestamp(Sequence):
38 _fields = [
39 ('version', Integer),
40 ('location', GeneralName),
wbond2ebcfea2016-07-10 21:41:24 -040041 ('requires_auth', Boolean, {'optional': True, 'default': False}),
wbonde91513e2015-06-03 14:52:18 -040042 ]
43
44
45class OtherRevInfo(Sequence):
46 _fields = [
47 ('type', ObjectIdentifier),
48 ('value', OctetString),
49 ]
50
51
wbond5d119642015-12-04 11:29:20 -050052class SequenceOfCertificateList(SequenceOf):
53 _child_spec = CertificateList
54
55
56class SequenceOfOCSPResponse(SequenceOf):
57 _child_spec = OCSPResponse
58
59
60class SequenceOfOtherRevInfo(SequenceOf):
61 _child_spec = OtherRevInfo
62
63
wbonde91513e2015-06-03 14:52:18 -040064class RevocationInfoArchival(Sequence):
65 _fields = [
wbondd62ed9a2017-09-15 07:13:52 -040066 ('crl', SequenceOfCertificateList, {'explicit': 0, 'optional': True}),
67 ('ocsp', SequenceOfOCSPResponse, {'explicit': 1, 'optional': True}),
68 ('other_rev_info', SequenceOfOtherRevInfo, {'explicit': 2, 'optional': True}),
wbonde91513e2015-06-03 14:52:18 -040069 ]
70
71
72class SetOfRevocationInfoArchival(SetOf):
73 _child_spec = RevocationInfoArchival
74
75
wbonda26664f2015-10-07 11:57:35 -040076ExtensionId._map['1.2.840.113583.1.1.9.2'] = 'adobe_archive_rev_info'
77ExtensionId._map['1.2.840.113583.1.1.9.1'] = 'adobe_timestamp'
78ExtensionId._map['1.2.840.113583.1.1.10'] = 'adobe_ppklite_credential'
79Extension._oid_specs['adobe_archive_rev_info'] = AdobeArchiveRevInfo
80Extension._oid_specs['adobe_timestamp'] = AdobeTimestamp
81Extension._oid_specs['adobe_ppklite_credential'] = Null
82KeyPurposeId._map['1.2.840.113583.1.1.5'] = 'pdf_signing'
83CMSAttributeType._map['1.2.840.113583.1.1.8'] = 'adobe_revocation_info_archival'
84CMSAttribute._oid_specs['adobe_revocation_info_archival'] = SetOfRevocationInfoArchival