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.

rfc5275.py 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  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. # An Internet Attribute Certificate Profile for Authorization
  10. #
  11. # ASN.1 source from:
  12. # https://www.rfc-editor.org/rfc/rfc5275.txt
  13. #
  14. from pyasn1.type import constraint
  15. from pyasn1.type import namedtype
  16. from pyasn1.type import namedval
  17. from pyasn1.type import opentype
  18. from pyasn1.type import tag
  19. from pyasn1.type import univ
  20. from pyasn1.type import useful
  21. from pyasn1_modules import rfc3565
  22. from pyasn1_modules import rfc5280
  23. from pyasn1_modules import rfc5652
  24. from pyasn1_modules import rfc5751
  25. from pyasn1_modules import rfc5755
  26. MAX = float('inf')
  27. # Initialize the map for GLAQueryRequests and GLAQueryResponses
  28. glaQueryRRMap = { }
  29. # Imports from RFC 3565
  30. id_aes128_wrap = rfc3565.id_aes128_wrap
  31. # Imports from RFC 5280
  32. AlgorithmIdentifier = rfc5280.AlgorithmIdentifier
  33. Certificate = rfc5280.Certificate
  34. GeneralName = rfc5280.GeneralName
  35. # Imports from RFC 5652
  36. CertificateSet = rfc5652.CertificateSet
  37. KEKIdentifier = rfc5652.KEKIdentifier
  38. RecipientInfos = rfc5652.RecipientInfos
  39. # Imports from RFC 5751
  40. SMIMECapability = rfc5751.SMIMECapability
  41. # Imports from RFC 5755
  42. AttributeCertificate = rfc5755.AttributeCertificate
  43. # The GL symmetric key distribution object identifier arc
  44. id_skd = univ.ObjectIdentifier((1, 2, 840, 113549, 1, 9, 16, 8,))
  45. # The GL Use KEK control attribute
  46. id_skd_glUseKEK = id_skd + (1,)
  47. class Certificates(univ.Sequence):
  48. componentType = namedtype.NamedTypes(
  49. namedtype.OptionalNamedType('pKC',
  50. Certificate().subtype(implicitTag=tag.Tag(
  51. tag.tagClassContext, tag.tagFormatSimple, 0))),
  52. namedtype.OptionalNamedType('aC',
  53. univ.SequenceOf(componentType=AttributeCertificate()).subtype(
  54. subtypeSpec=constraint.ValueSizeConstraint(1, MAX)).subtype(
  55. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
  56. namedtype.OptionalNamedType('certPath',
  57. CertificateSet().subtype(implicitTag=tag.Tag(
  58. tag.tagClassContext, tag.tagFormatSimple, 2)))
  59. )
  60. class GLInfo(univ.Sequence):
  61. componentType = namedtype.NamedTypes(
  62. namedtype.NamedType('glName', GeneralName()),
  63. namedtype.NamedType('glAddress', GeneralName())
  64. )
  65. class GLOwnerInfo(univ.Sequence):
  66. componentType = namedtype.NamedTypes(
  67. namedtype.NamedType('glOwnerName', GeneralName()),
  68. namedtype.NamedType('glOwnerAddress', GeneralName()),
  69. namedtype.OptionalNamedType('certificates', Certificates())
  70. )
  71. class GLAdministration(univ.Integer):
  72. namedValues = namedval.NamedValues(
  73. ('unmanaged', 0),
  74. ('managed', 1),
  75. ('closed', 2)
  76. )
  77. requested_algorithm = SMIMECapability().subtype(
  78. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))
  79. requested_algorithm['capabilityID'] = id_aes128_wrap
  80. class GLKeyAttributes(univ.Sequence):
  81. componentType = namedtype.NamedTypes(
  82. namedtype.DefaultedNamedType('rekeyControlledByGLO',
  83. univ.Boolean().subtype(value=0,
  84. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  85. namedtype.DefaultedNamedType('recipientsNotMutuallyAware',
  86. univ.Boolean().subtype(value=1,
  87. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
  88. namedtype.DefaultedNamedType('duration',
  89. univ.Integer().subtype(value=0,
  90. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
  91. namedtype.DefaultedNamedType('generationCounter',
  92. univ.Integer().subtype(value=2,
  93. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
  94. namedtype.DefaultedNamedType('requestedAlgorithm', requested_algorithm)
  95. )
  96. class GLUseKEK(univ.Sequence):
  97. componentType = namedtype.NamedTypes(
  98. namedtype.NamedType('glInfo', GLInfo()),
  99. namedtype.NamedType('glOwnerInfo',
  100. univ.SequenceOf(componentType=GLOwnerInfo()).subtype(
  101. subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
  102. namedtype.DefaultedNamedType('glAdministration',
  103. GLAdministration().subtype(value=1)),
  104. namedtype.OptionalNamedType('glKeyAttributes', GLKeyAttributes())
  105. )
  106. # The Delete GL control attribute
  107. id_skd_glDelete = id_skd + (2,)
  108. class DeleteGL(GeneralName):
  109. pass
  110. # The Add GL Member control attribute
  111. id_skd_glAddMember = id_skd + (3,)
  112. class GLMember(univ.Sequence):
  113. componentType = namedtype.NamedTypes(
  114. namedtype.NamedType('glMemberName', GeneralName()),
  115. namedtype.OptionalNamedType('glMemberAddress', GeneralName()),
  116. namedtype.OptionalNamedType('certificates', Certificates())
  117. )
  118. class GLAddMember(univ.Sequence):
  119. componentType = namedtype.NamedTypes(
  120. namedtype.NamedType('glName', GeneralName()),
  121. namedtype.NamedType('glMember', GLMember())
  122. )
  123. # The Delete GL Member control attribute
  124. id_skd_glDeleteMember = id_skd + (4,)
  125. class GLDeleteMember(univ.Sequence):
  126. componentType = namedtype.NamedTypes(
  127. namedtype.NamedType('glName', GeneralName()),
  128. namedtype.NamedType('glMemberToDelete', GeneralName())
  129. )
  130. # The GL Rekey control attribute
  131. id_skd_glRekey = id_skd + (5,)
  132. class GLNewKeyAttributes(univ.Sequence):
  133. componentType = namedtype.NamedTypes(
  134. namedtype.OptionalNamedType('rekeyControlledByGLO',
  135. univ.Boolean().subtype(implicitTag=tag.Tag(
  136. tag.tagClassContext, tag.tagFormatSimple, 0))),
  137. namedtype.OptionalNamedType('recipientsNotMutuallyAware',
  138. univ.Boolean().subtype(implicitTag=tag.Tag(
  139. tag.tagClassContext, tag.tagFormatSimple, 1))),
  140. namedtype.OptionalNamedType('duration',
  141. univ.Integer().subtype(implicitTag=tag.Tag(
  142. tag.tagClassContext, tag.tagFormatSimple, 2))),
  143. namedtype.OptionalNamedType('generationCounter',
  144. univ.Integer().subtype(implicitTag=tag.Tag(
  145. tag.tagClassContext, tag.tagFormatSimple, 3))),
  146. namedtype.OptionalNamedType('requestedAlgorithm',
  147. AlgorithmIdentifier().subtype(implicitTag=tag.Tag(
  148. tag.tagClassContext, tag.tagFormatSimple, 4)))
  149. )
  150. class GLRekey(univ.Sequence):
  151. componentType = namedtype.NamedTypes(
  152. namedtype.NamedType('glName', GeneralName()),
  153. namedtype.OptionalNamedType('glAdministration', GLAdministration()),
  154. namedtype.OptionalNamedType('glNewKeyAttributes', GLNewKeyAttributes()),
  155. namedtype.OptionalNamedType('glRekeyAllGLKeys', univ.Boolean())
  156. )
  157. # The Add and Delete GL Owner control attributes
  158. id_skd_glAddOwner = id_skd + (6,)
  159. id_skd_glRemoveOwner = id_skd + (7,)
  160. class GLOwnerAdministration(univ.Sequence):
  161. componentType = namedtype.NamedTypes(
  162. namedtype.NamedType('glName', GeneralName()),
  163. namedtype.NamedType('glOwnerInfo', GLOwnerInfo())
  164. )
  165. # The GL Key Compromise control attribute
  166. id_skd_glKeyCompromise = id_skd + (8,)
  167. class GLKCompromise(GeneralName):
  168. pass
  169. # The GL Key Refresh control attribute
  170. id_skd_glkRefresh = id_skd + (9,)
  171. class Date(univ.Sequence):
  172. componentType = namedtype.NamedTypes(
  173. namedtype.NamedType('start', useful.GeneralizedTime()),
  174. namedtype.OptionalNamedType('end', useful.GeneralizedTime())
  175. )
  176. class GLKRefresh(univ.Sequence):
  177. componentType = namedtype.NamedTypes(
  178. namedtype.NamedType('glName', GeneralName()),
  179. namedtype.NamedType('dates',
  180. univ.SequenceOf(componentType=Date()).subtype(
  181. subtypeSpec=constraint.ValueSizeConstraint(1, MAX)))
  182. )
  183. # The GLA Query Request control attribute
  184. id_skd_glaQueryRequest = id_skd + (11,)
  185. class GLAQueryRequest(univ.Sequence):
  186. componentType = namedtype.NamedTypes(
  187. namedtype.NamedType('glaRequestType', univ.ObjectIdentifier()),
  188. namedtype.NamedType('glaRequestValue', univ.Any(),
  189. openType=opentype.OpenType('glaRequestType', glaQueryRRMap))
  190. )
  191. # The GLA Query Response control attribute
  192. id_skd_glaQueryResponse = id_skd + (12,)
  193. class GLAQueryResponse(univ.Sequence):
  194. componentType = namedtype.NamedTypes(
  195. namedtype.NamedType('glaResponseType', univ.ObjectIdentifier()),
  196. namedtype.NamedType('glaResponseValue', univ.Any(),
  197. openType=opentype.OpenType('glaResponseType', glaQueryRRMap))
  198. )
  199. # The GLA Request/Response (glaRR) arc for glaRequestType/glaResponseType
  200. id_cmc_glaRR = univ.ObjectIdentifier((1, 3, 6, 1, 5, 5, 7, 7, 99,))
  201. # The Algorithm Request
  202. id_cmc_gla_skdAlgRequest = id_cmc_glaRR + (1,)
  203. class SKDAlgRequest(univ.Null):
  204. pass
  205. # The Algorithm Response
  206. id_cmc_gla_skdAlgResponse = id_cmc_glaRR + (2,)
  207. SMIMECapabilities = rfc5751.SMIMECapabilities
  208. # The control attribute to request an updated certificate to the GLA and
  209. # the control attribute to return an updated certificate to the GLA
  210. id_skd_glProvideCert = id_skd + (13,)
  211. id_skd_glManageCert = id_skd + (14,)
  212. class GLManageCert(univ.Sequence):
  213. componentType = namedtype.NamedTypes(
  214. namedtype.NamedType('glName', GeneralName()),
  215. namedtype.NamedType('glMember', GLMember())
  216. )
  217. # The control attribute to distribute the GL shared KEK
  218. id_skd_glKey = id_skd + (15,)
  219. class GLKey(univ.Sequence):
  220. componentType = namedtype.NamedTypes(
  221. namedtype.NamedType('glName', GeneralName()),
  222. namedtype.NamedType('glIdentifier', KEKIdentifier()),
  223. namedtype.NamedType('glkWrapped', RecipientInfos()),
  224. namedtype.NamedType('glkAlgorithm', AlgorithmIdentifier()),
  225. namedtype.NamedType('glkNotBefore', useful.GeneralizedTime()),
  226. namedtype.NamedType('glkNotAfter', useful.GeneralizedTime())
  227. )
  228. # The CMC error types
  229. id_cet_skdFailInfo = univ.ObjectIdentifier((1, 3, 6, 1, 5, 5, 7, 15, 1,))
  230. class SKDFailInfo(univ.Integer):
  231. namedValues = namedval.NamedValues(
  232. ('unspecified', 0),
  233. ('closedGL', 1),
  234. ('unsupportedDuration', 2),
  235. ('noGLACertificate', 3),
  236. ('invalidCert', 4),
  237. ('unsupportedAlgorithm', 5),
  238. ('noGLONameMatch', 6),
  239. ('invalidGLName', 7),
  240. ('nameAlreadyInUse', 8),
  241. ('noSpam', 9),
  242. ('alreadyAMember', 11),
  243. ('notAMember', 12),
  244. ('alreadyAnOwner', 13),
  245. ('notAnOwner', 14)
  246. )
  247. # Update the map for GLAQueryRequests and GLAQueryResponses
  248. _glaQueryRRMapUpdate = {
  249. id_cmc_gla_skdAlgRequest: univ.Null(""),
  250. id_cmc_gla_skdAlgResponse: SMIMECapabilities(),
  251. }
  252. glaQueryRRMap.update(_glaQueryRRMapUpdate)
  253. # Update the map for CMC control attributes; since CMS Attributes and
  254. # CMC Controls both use 'attrType', one map is used for both
  255. _cmcControlAttributesMapUpdate = {
  256. id_skd_glUseKEK: GLUseKEK(),
  257. id_skd_glDelete: DeleteGL(),
  258. id_skd_glAddMember: GLAddMember(),
  259. id_skd_glDeleteMember: GLDeleteMember(),
  260. id_skd_glRekey: GLRekey(),
  261. id_skd_glAddOwner: GLOwnerAdministration(),
  262. id_skd_glRemoveOwner: GLOwnerAdministration(),
  263. id_skd_glKeyCompromise: GLKCompromise(),
  264. id_skd_glkRefresh: GLKRefresh(),
  265. id_skd_glaQueryRequest: GLAQueryRequest(),
  266. id_skd_glaQueryResponse: GLAQueryResponse(),
  267. id_skd_glProvideCert: GLManageCert(),
  268. id_skd_glManageCert: GLManageCert(),
  269. id_skd_glKey: GLKey(),
  270. }
  271. rfc5652.cmsAttributesMap.update(_cmcControlAttributesMapUpdate)