• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# coding: utf-8
2
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
8from __future__ import unicode_literals, division, absolute_import, print_function
9
10from .cms import CMSAttributeType, CMSAttribute
11from .core import (
12    Boolean,
13    Integer,
14    Null,
15    ObjectIdentifier,
16    OctetString,
17    Sequence,
18    SequenceOf,
19    SetOf,
20)
21from .crl import CertificateList
22from .ocsp import OCSPResponse
23from .x509 import (
24    Extension,
25    ExtensionId,
26    GeneralName,
27    KeyPurposeId,
28)
29
30
31class AdobeArchiveRevInfo(Sequence):
32    _fields = [
33        ('version', Integer)
34    ]
35
36
37class AdobeTimestamp(Sequence):
38    _fields = [
39        ('version', Integer),
40        ('location', GeneralName),
41        ('requires_auth', Boolean, {'optional': True, 'default': False}),
42    ]
43
44
45class OtherRevInfo(Sequence):
46    _fields = [
47        ('type', ObjectIdentifier),
48        ('value', OctetString),
49    ]
50
51
52class 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
64class RevocationInfoArchival(Sequence):
65    _fields = [
66        ('crl', SequenceOfCertificateList, {'explicit': 0, 'optional': True}),
67        ('ocsp', SequenceOfOCSPResponse, {'explicit': 1, 'optional': True}),
68        ('other_rev_info', SequenceOfOtherRevInfo, {'explicit': 2, 'optional': True}),
69    ]
70
71
72class SetOfRevocationInfoArchival(SetOf):
73    _child_spec = RevocationInfoArchival
74
75
76ExtensionId._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
85