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.

rfc5480.py 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. # Modified by Russ Housley to add maps for opentypes.
  5. #
  6. # Copyright (c) 2019, Vigil Security, LLC
  7. # License: http://snmplabs.com/pyasn1/license.html
  8. #
  9. # Elliptic Curve Cryptography Subject Public Key Information
  10. #
  11. # ASN.1 source from:
  12. # https://www.rfc-editor.org/rfc/rfc5480.txt
  13. # What can be imported from rfc4055.py ?
  14. from pyasn1.type import namedtype
  15. from pyasn1.type import univ
  16. from pyasn1_modules import rfc3279
  17. from pyasn1_modules import rfc5280
  18. # These structures are the same as RFC 3279.
  19. DHPublicKey = rfc3279.DHPublicKey
  20. DSAPublicKey = rfc3279.DSAPublicKey
  21. ValidationParms = rfc3279.ValidationParms
  22. DomainParameters = rfc3279.DomainParameters
  23. ECDSA_Sig_Value = rfc3279.ECDSA_Sig_Value
  24. ECPoint = rfc3279.ECPoint
  25. KEA_Parms_Id = rfc3279.KEA_Parms_Id
  26. RSAPublicKey = rfc3279.RSAPublicKey
  27. # RFC 5480 changed the names of these structures from RFC 3279.
  28. DSS_Parms = rfc3279.Dss_Parms
  29. DSA_Sig_Value = rfc3279.Dss_Sig_Value
  30. # RFC 3279 defines a more complex alternative for ECParameters.
  31. # RFC 5480 narrows the definition to a single CHOICE: namedCurve.
  32. class ECParameters(univ.Choice):
  33. pass
  34. ECParameters.componentType = namedtype.NamedTypes(
  35. namedtype.NamedType('namedCurve', univ.ObjectIdentifier())
  36. )
  37. # OIDs for Message Digest Algorithms
  38. id_md2 = univ.ObjectIdentifier('1.2.840.113549.2.2')
  39. id_md5 = univ.ObjectIdentifier('1.2.840.113549.2.5')
  40. id_sha1 = univ.ObjectIdentifier('1.3.14.3.2.26')
  41. id_sha224 = univ.ObjectIdentifier('2.16.840.1.101.3.4.2.4')
  42. id_sha256 = univ.ObjectIdentifier('2.16.840.1.101.3.4.2.1')
  43. id_sha384 = univ.ObjectIdentifier('2.16.840.1.101.3.4.2.2')
  44. id_sha512 = univ.ObjectIdentifier('2.16.840.1.101.3.4.2.3')
  45. # OID for RSA PK Algorithm and Key
  46. rsaEncryption = univ.ObjectIdentifier('1.2.840.113549.1.1.1')
  47. # OID for DSA PK Algorithm, Key, and Parameters
  48. id_dsa = univ.ObjectIdentifier('1.2.840.10040.4.1')
  49. # OID for Diffie-Hellman PK Algorithm, Key, and Parameters
  50. dhpublicnumber = univ.ObjectIdentifier('1.2.840.10046.2.1')
  51. # OID for KEA PK Algorithm and Parameters
  52. id_keyExchangeAlgorithm = univ.ObjectIdentifier('2.16.840.1.101.2.1.1.22')
  53. # OIDs for Elliptic Curve Algorithm ID, Key, and Parameters
  54. # Note that ECDSA keys always use this OID
  55. id_ecPublicKey = univ.ObjectIdentifier('1.2.840.10045.2.1')
  56. id_ecDH = univ.ObjectIdentifier('1.3.132.1.12')
  57. id_ecMQV = univ.ObjectIdentifier('1.3.132.1.13')
  58. # OIDs for RSA Signature Algorithms
  59. md2WithRSAEncryption = univ.ObjectIdentifier('1.2.840.113549.1.1.2')
  60. md5WithRSAEncryption = univ.ObjectIdentifier('1.2.840.113549.1.1.4')
  61. sha1WithRSAEncryption = univ.ObjectIdentifier('1.2.840.113549.1.1.5')
  62. # OIDs for DSA Signature Algorithms
  63. id_dsa_with_sha1 = univ.ObjectIdentifier('1.2.840.10040.4.3')
  64. id_dsa_with_sha224 = univ.ObjectIdentifier('2.16.840.1.101.3.4.3.1')
  65. id_dsa_with_sha256 = univ.ObjectIdentifier('2.16.840.1.101.3.4.3.2')
  66. # OIDs for ECDSA Signature Algorithms
  67. ecdsa_with_SHA1 = univ.ObjectIdentifier('1.2.840.10045.4.1')
  68. ecdsa_with_SHA224 = univ.ObjectIdentifier('1.2.840.10045.4.3.1')
  69. ecdsa_with_SHA256 = univ.ObjectIdentifier('1.2.840.10045.4.3.2')
  70. ecdsa_with_SHA384 = univ.ObjectIdentifier('1.2.840.10045.4.3.3')
  71. ecdsa_with_SHA512 = univ.ObjectIdentifier('1.2.840.10045.4.3.4')
  72. # OIDs for Named Elliptic Curves
  73. secp192r1 = univ.ObjectIdentifier('1.2.840.10045.3.1.1')
  74. sect163k1 = univ.ObjectIdentifier('1.3.132.0.1')
  75. sect163r2 = univ.ObjectIdentifier('1.3.132.0.15')
  76. secp224r1 = univ.ObjectIdentifier('1.3.132.0.33')
  77. sect233k1 = univ.ObjectIdentifier('1.3.132.0.26')
  78. sect233r1 = univ.ObjectIdentifier('1.3.132.0.27')
  79. secp256r1 = univ.ObjectIdentifier('1.2.840.10045.3.1.7')
  80. sect283k1 = univ.ObjectIdentifier('1.3.132.0.16')
  81. sect283r1 = univ.ObjectIdentifier('1.3.132.0.17')
  82. secp384r1 = univ.ObjectIdentifier('1.3.132.0.34')
  83. sect409k1 = univ.ObjectIdentifier('1.3.132.0.36')
  84. sect409r1 = univ.ObjectIdentifier('1.3.132.0.37')
  85. secp521r1 = univ.ObjectIdentifier('1.3.132.0.35')
  86. sect571k1 = univ.ObjectIdentifier('1.3.132.0.38')
  87. sect571r1 = univ.ObjectIdentifier('1.3.132.0.39')
  88. # Map of Algorithm Identifier OIDs to Parameters
  89. # The algorithm is not included if the parameters MUST be absent
  90. _algorithmIdentifierMapUpdate = {
  91. rsaEncryption: univ.Null(),
  92. md2WithRSAEncryption: univ.Null(),
  93. md5WithRSAEncryption: univ.Null(),
  94. sha1WithRSAEncryption: univ.Null(),
  95. id_dsa: DSS_Parms(),
  96. dhpublicnumber: DomainParameters(),
  97. id_keyExchangeAlgorithm: KEA_Parms_Id(),
  98. id_ecPublicKey: ECParameters(),
  99. id_ecDH: ECParameters(),
  100. id_ecMQV: ECParameters(),
  101. }
  102. # Add these Algorithm Identifier map entries to the ones in rfc5280.py
  103. rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate)