Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
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.

rfc5751.py 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. # This file is being contributed to pyasn1-modules software.
  2. #
  3. # Created by Russ Housley with assistance from asn1ate v.0.6.0.
  4. #
  5. # Copyright (c) 2019, Vigil Security, LLC
  6. # License: http://snmplabs.com/pyasn1/license.html
  7. #
  8. # S/MIME Version 3.2 Message Specification
  9. #
  10. # ASN.1 source from:
  11. # https://www.rfc-editor.org/rfc/rfc5751.txt
  12. from pyasn1.type import namedtype
  13. from pyasn1.type import opentype
  14. from pyasn1.type import tag
  15. from pyasn1.type import univ
  16. from pyasn1_modules import rfc5652
  17. from pyasn1_modules import rfc8018
  18. def _OID(*components):
  19. output = []
  20. for x in tuple(components):
  21. if isinstance(x, univ.ObjectIdentifier):
  22. output.extend(list(x))
  23. else:
  24. output.append(int(x))
  25. return univ.ObjectIdentifier(output)
  26. # Imports from RFC 5652 and RFC 8018
  27. IssuerAndSerialNumber = rfc5652.IssuerAndSerialNumber
  28. RecipientKeyIdentifier = rfc5652.RecipientKeyIdentifier
  29. SubjectKeyIdentifier = rfc5652.SubjectKeyIdentifier
  30. rc2CBC = rfc8018.rc2CBC
  31. # S/MIME Capabilities Attribute
  32. smimeCapabilities = univ.ObjectIdentifier('1.2.840.113549.1.9.15')
  33. smimeCapabilityMap = { }
  34. class SMIMECapability(univ.Sequence):
  35. pass
  36. SMIMECapability.componentType = namedtype.NamedTypes(
  37. namedtype.NamedType('capabilityID', univ.ObjectIdentifier()),
  38. namedtype.OptionalNamedType('parameters', univ.Any(),
  39. openType=opentype.OpenType('capabilityID', smimeCapabilityMap))
  40. )
  41. class SMIMECapabilities(univ.SequenceOf):
  42. pass
  43. SMIMECapabilities.componentType = SMIMECapability()
  44. class SMIMECapabilitiesParametersForRC2CBC(univ.Integer):
  45. # which carries the RC2 Key Length (number of bits)
  46. pass
  47. # S/MIME Encryption Key Preference Attribute
  48. id_smime = univ.ObjectIdentifier('1.2.840.113549.1.9.16')
  49. id_aa = _OID(id_smime, 2)
  50. id_aa_encrypKeyPref = _OID(id_aa, 11)
  51. class SMIMEEncryptionKeyPreference(univ.Choice):
  52. pass
  53. SMIMEEncryptionKeyPreference.componentType = namedtype.NamedTypes(
  54. namedtype.NamedType('issuerAndSerialNumber',
  55. IssuerAndSerialNumber().subtype(implicitTag=tag.Tag(
  56. tag.tagClassContext, tag.tagFormatSimple, 0))),
  57. namedtype.NamedType('receipentKeyId',
  58. # Yes, 'receipentKeyId' is spelled incorrectly, but kept
  59. # this way for alignment with the ASN.1 module in the RFC.
  60. RecipientKeyIdentifier().subtype(implicitTag=tag.Tag(
  61. tag.tagClassContext, tag.tagFormatSimple, 1))),
  62. namedtype.NamedType('subjectAltKeyIdentifier',
  63. SubjectKeyIdentifier().subtype(implicitTag=tag.Tag(
  64. tag.tagClassContext, tag.tagFormatSimple, 2)))
  65. )
  66. # The Prefer Binary Inside SMIMECapabilities attribute
  67. id_cap = _OID(id_smime, 11)
  68. id_cap_preferBinaryInside = _OID(id_cap, 1)
  69. # CMS Attribute Map
  70. _cmsAttributesMapUpdate = {
  71. smimeCapabilities: SMIMECapabilities(),
  72. id_aa_encrypKeyPref: SMIMEEncryptionKeyPreference(),
  73. }
  74. rfc5652.cmsAttributesMap.update(_cmsAttributesMapUpdate)
  75. # SMIMECapabilities Attribute Map
  76. #
  77. # Do not include OIDs in the dictionary when the parameters are absent.
  78. _smimeCapabilityMapUpdate = {
  79. rc2CBC: SMIMECapabilitiesParametersForRC2CBC(),
  80. }
  81. smimeCapabilityMap.update(_smimeCapabilityMapUpdate)