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.

rfc4490.py 3.3KB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #
  2. # This file is part of pyasn1-modules software.
  3. #
  4. # Created by Russ Housley with assistance from asn1ate v.0.6.0.
  5. #
  6. # Copyright (c) 2019, Vigil Security, LLC
  7. # License: http://snmplabs.com/pyasn1/license.html
  8. #
  9. # Using the GOST 28147-89, GOST R 34.11-94, GOST R 34.10-94, and
  10. # GOST R 34.10-2001 Algorithms with the CMS
  11. #
  12. # ASN.1 source from:
  13. # https://www.rfc-editor.org/rfc/rfc4490.txt
  14. #
  15. from pyasn1.type import univ, char, namedtype, namedval, tag, constraint, useful
  16. from pyasn1_modules import rfc4357
  17. from pyasn1_modules import rfc5280
  18. # Imports from RFC 4357
  19. id_CryptoPro_algorithms = rfc4357.id_CryptoPro_algorithms
  20. id_GostR3410_94 = rfc4357.id_GostR3410_94
  21. id_GostR3410_2001 = rfc4357.id_GostR3410_2001
  22. Gost28147_89_ParamSet = rfc4357.Gost28147_89_ParamSet
  23. Gost28147_89_EncryptedKey = rfc4357.Gost28147_89_EncryptedKey
  24. GostR3410_94_PublicKeyParameters = rfc4357.GostR3410_94_PublicKeyParameters
  25. GostR3410_2001_PublicKeyParameters = rfc4357.GostR3410_2001_PublicKeyParameters
  26. # Imports from RFC 5280
  27. SubjectPublicKeyInfo = rfc5280.SubjectPublicKeyInfo
  28. # CMS/PKCS#7 key agreement algorithms & parameters
  29. class Gost28147_89_KeyWrapParameters(univ.Sequence):
  30. componentType = namedtype.NamedTypes(
  31. namedtype.NamedType('encryptionParamSet', Gost28147_89_ParamSet()),
  32. namedtype.OptionalNamedType('ukm', univ.OctetString().subtype(
  33. subtypeSpec=constraint.ValueSizeConstraint(8, 8)))
  34. )
  35. id_Gost28147_89_CryptoPro_KeyWrap = id_CryptoPro_algorithms + (13, 1, )
  36. id_Gost28147_89_None_KeyWrap = id_CryptoPro_algorithms + (13, 0, )
  37. id_GostR3410_2001_CryptoPro_ESDH = id_CryptoPro_algorithms + (96, )
  38. id_GostR3410_94_CryptoPro_ESDH = id_CryptoPro_algorithms + (97, )
  39. # CMS/PKCS#7 key transport algorithms & parameters
  40. id_GostR3410_2001_KeyTransportSMIMECapability = id_GostR3410_2001
  41. id_GostR3410_94_KeyTransportSMIMECapability = id_GostR3410_94
  42. class GostR3410_TransportParameters(univ.Sequence):
  43. componentType = namedtype.NamedTypes(
  44. namedtype.NamedType('encryptionParamSet', Gost28147_89_ParamSet()),
  45. namedtype.OptionalNamedType('ephemeralPublicKey',
  46. SubjectPublicKeyInfo().subtype(implicitTag=tag.Tag(
  47. tag.tagClassContext, tag.tagFormatSimple, 0))),
  48. namedtype.NamedType('ukm', univ.OctetString().subtype(
  49. subtypeSpec=constraint.ValueSizeConstraint(8, 8)))
  50. )
  51. class GostR3410_KeyTransport(univ.Sequence):
  52. componentType = namedtype.NamedTypes(
  53. namedtype.NamedType('sessionEncryptedKey', Gost28147_89_EncryptedKey()),
  54. namedtype.OptionalNamedType('transportParameters',
  55. GostR3410_TransportParameters().subtype(implicitTag=tag.Tag(
  56. tag.tagClassContext, tag.tagFormatConstructed, 0)))
  57. )
  58. # GOST R 34.10-94 signature algorithm & parameters
  59. class GostR3410_94_Signature(univ.OctetString):
  60. subtypeSpec = constraint.ValueSizeConstraint(64, 64)
  61. # GOST R 34.10-2001 signature algorithms and parameters
  62. class GostR3410_2001_Signature(univ.OctetString):
  63. subtypeSpec = constraint.ValueSizeConstraint(64, 64)
  64. # Update the Algorithm Identifier map in rfc5280.py
  65. _algorithmIdentifierMapUpdate = {
  66. id_Gost28147_89_CryptoPro_KeyWrap: Gost28147_89_KeyWrapParameters(),
  67. id_Gost28147_89_None_KeyWrap: Gost28147_89_KeyWrapParameters(),
  68. }
  69. rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate)