You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.2 KiB

4 years ago
  1. # coding: utf-8
  2. """
  3. ASN.1 type classes for PDF signature structures. Adds extra oid mapping and
  4. value parsing to asn1crypto.x509.Extension() and asn1crypto.xms.CMSAttribute().
  5. """
  6. from __future__ import unicode_literals, division, absolute_import, print_function
  7. from .cms import CMSAttributeType, CMSAttribute
  8. from .core import (
  9. Boolean,
  10. Integer,
  11. Null,
  12. ObjectIdentifier,
  13. OctetString,
  14. Sequence,
  15. SequenceOf,
  16. SetOf,
  17. )
  18. from .crl import CertificateList
  19. from .ocsp import OCSPResponse
  20. from .x509 import (
  21. Extension,
  22. ExtensionId,
  23. GeneralName,
  24. KeyPurposeId,
  25. )
  26. class AdobeArchiveRevInfo(Sequence):
  27. _fields = [
  28. ('version', Integer)
  29. ]
  30. class AdobeTimestamp(Sequence):
  31. _fields = [
  32. ('version', Integer),
  33. ('location', GeneralName),
  34. ('requires_auth', Boolean, {'optional': True, 'default': False}),
  35. ]
  36. class OtherRevInfo(Sequence):
  37. _fields = [
  38. ('type', ObjectIdentifier),
  39. ('value', OctetString),
  40. ]
  41. class SequenceOfCertificateList(SequenceOf):
  42. _child_spec = CertificateList
  43. class SequenceOfOCSPResponse(SequenceOf):
  44. _child_spec = OCSPResponse
  45. class SequenceOfOtherRevInfo(SequenceOf):
  46. _child_spec = OtherRevInfo
  47. class RevocationInfoArchival(Sequence):
  48. _fields = [
  49. ('crl', SequenceOfCertificateList, {'explicit': 0, 'optional': True}),
  50. ('ocsp', SequenceOfOCSPResponse, {'explicit': 1, 'optional': True}),
  51. ('other_rev_info', SequenceOfOtherRevInfo, {'explicit': 2, 'optional': True}),
  52. ]
  53. class SetOfRevocationInfoArchival(SetOf):
  54. _child_spec = RevocationInfoArchival
  55. ExtensionId._map['1.2.840.113583.1.1.9.2'] = 'adobe_archive_rev_info'
  56. ExtensionId._map['1.2.840.113583.1.1.9.1'] = 'adobe_timestamp'
  57. ExtensionId._map['1.2.840.113583.1.1.10'] = 'adobe_ppklite_credential'
  58. Extension._oid_specs['adobe_archive_rev_info'] = AdobeArchiveRevInfo
  59. Extension._oid_specs['adobe_timestamp'] = AdobeTimestamp
  60. Extension._oid_specs['adobe_ppklite_credential'] = Null
  61. KeyPurposeId._map['1.2.840.113583.1.1.5'] = 'pdf_signing'
  62. CMSAttributeType._map['1.2.840.113583.1.1.8'] = 'adobe_revocation_info_archival'
  63. CMSAttribute._oid_specs['adobe_revocation_info_archival'] = SetOfRevocationInfoArchival