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.

rfc3709.py 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. # Modified by Russ Housley to add maps for use with opentypes.
  6. #
  7. # Copyright (c) 2019, Vigil Security, LLC
  8. # License: http://snmplabs.com/pyasn1/license.html
  9. #
  10. # Logotypes in X.509 Certificates
  11. #
  12. # ASN.1 source from:
  13. # https://www.rfc-editor.org/rfc/rfc3709.txt
  14. #
  15. from pyasn1.type import char
  16. from pyasn1.type import constraint
  17. from pyasn1.type import namedtype
  18. from pyasn1.type import namedval
  19. from pyasn1.type import tag
  20. from pyasn1.type import univ
  21. from pyasn1_modules import rfc5280
  22. from pyasn1_modules import rfc6170
  23. MAX = float('inf')
  24. class HashAlgAndValue(univ.Sequence):
  25. pass
  26. HashAlgAndValue.componentType = namedtype.NamedTypes(
  27. namedtype.NamedType('hashAlg', rfc5280.AlgorithmIdentifier()),
  28. namedtype.NamedType('hashValue', univ.OctetString())
  29. )
  30. class LogotypeDetails(univ.Sequence):
  31. pass
  32. LogotypeDetails.componentType = namedtype.NamedTypes(
  33. namedtype.NamedType('mediaType', char.IA5String()),
  34. namedtype.NamedType('logotypeHash', univ.SequenceOf(
  35. componentType=HashAlgAndValue()).subtype(
  36. sizeSpec=constraint.ValueSizeConstraint(1, MAX))),
  37. namedtype.NamedType('logotypeURI', univ.SequenceOf(
  38. componentType=char.IA5String()).subtype(
  39. sizeSpec=constraint.ValueSizeConstraint(1, MAX)))
  40. )
  41. class LogotypeAudioInfo(univ.Sequence):
  42. pass
  43. LogotypeAudioInfo.componentType = namedtype.NamedTypes(
  44. namedtype.NamedType('fileSize', univ.Integer()),
  45. namedtype.NamedType('playTime', univ.Integer()),
  46. namedtype.NamedType('channels', univ.Integer()),
  47. namedtype.OptionalNamedType('sampleRate', univ.Integer().subtype(
  48. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
  49. namedtype.OptionalNamedType('language', char.IA5String().subtype(
  50. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4)))
  51. )
  52. class LogotypeAudio(univ.Sequence):
  53. pass
  54. LogotypeAudio.componentType = namedtype.NamedTypes(
  55. namedtype.NamedType('audioDetails', LogotypeDetails()),
  56. namedtype.OptionalNamedType('audioInfo', LogotypeAudioInfo())
  57. )
  58. class LogotypeImageType(univ.Integer):
  59. pass
  60. LogotypeImageType.namedValues = namedval.NamedValues(
  61. ('grayScale', 0),
  62. ('color', 1)
  63. )
  64. class LogotypeImageResolution(univ.Choice):
  65. pass
  66. LogotypeImageResolution.componentType = namedtype.NamedTypes(
  67. namedtype.NamedType('numBits',
  68. univ.Integer().subtype(implicitTag=tag.Tag(
  69. tag.tagClassContext, tag.tagFormatSimple, 1))),
  70. namedtype.NamedType('tableSize',
  71. univ.Integer().subtype(implicitTag=tag.Tag(
  72. tag.tagClassContext, tag.tagFormatSimple, 2)))
  73. )
  74. class LogotypeImageInfo(univ.Sequence):
  75. pass
  76. LogotypeImageInfo.componentType = namedtype.NamedTypes(
  77. namedtype.DefaultedNamedType('type', LogotypeImageType().subtype(
  78. implicitTag=tag.Tag(tag.tagClassContext,
  79. tag.tagFormatSimple, 0)).subtype(value='color')),
  80. namedtype.NamedType('fileSize', univ.Integer()),
  81. namedtype.NamedType('xSize', univ.Integer()),
  82. namedtype.NamedType('ySize', univ.Integer()),
  83. namedtype.OptionalNamedType('resolution', LogotypeImageResolution()),
  84. namedtype.OptionalNamedType('language', char.IA5String().subtype(
  85. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4)))
  86. )
  87. class LogotypeImage(univ.Sequence):
  88. pass
  89. LogotypeImage.componentType = namedtype.NamedTypes(
  90. namedtype.NamedType('imageDetails', LogotypeDetails()),
  91. namedtype.OptionalNamedType('imageInfo', LogotypeImageInfo())
  92. )
  93. class LogotypeData(univ.Sequence):
  94. pass
  95. LogotypeData.componentType = namedtype.NamedTypes(
  96. namedtype.OptionalNamedType('image', univ.SequenceOf(
  97. componentType=LogotypeImage())),
  98. namedtype.OptionalNamedType('audio', univ.SequenceOf(
  99. componentType=LogotypeAudio()).subtype(
  100. implicitTag=tag.Tag(tag.tagClassContext,
  101. tag.tagFormatSimple, 1)))
  102. )
  103. class LogotypeReference(univ.Sequence):
  104. pass
  105. LogotypeReference.componentType = namedtype.NamedTypes(
  106. namedtype.NamedType('refStructHash', univ.SequenceOf(
  107. componentType=HashAlgAndValue()).subtype(
  108. sizeSpec=constraint.ValueSizeConstraint(1, MAX))),
  109. namedtype.NamedType('refStructURI', univ.SequenceOf(
  110. componentType=char.IA5String()).subtype(
  111. sizeSpec=constraint.ValueSizeConstraint(1, MAX)))
  112. )
  113. class LogotypeInfo(univ.Choice):
  114. pass
  115. LogotypeInfo.componentType = namedtype.NamedTypes(
  116. namedtype.NamedType('direct',
  117. LogotypeData().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  118. tag.tagFormatConstructed, 0))),
  119. namedtype.NamedType('indirect', LogotypeReference().subtype(
  120. implicitTag=tag.Tag(tag.tagClassContext,
  121. tag.tagFormatConstructed, 1)))
  122. )
  123. # Other logotype type and associated object identifiers
  124. id_logo_background = univ.ObjectIdentifier('1.3.6.1.5.5.7.20.2')
  125. id_logo_loyalty = univ.ObjectIdentifier('1.3.6.1.5.5.7.20.1')
  126. id_logo_certImage = rfc6170.id_logo_certImage
  127. class OtherLogotypeInfo(univ.Sequence):
  128. pass
  129. OtherLogotypeInfo.componentType = namedtype.NamedTypes(
  130. namedtype.NamedType('logotypeType', univ.ObjectIdentifier()),
  131. namedtype.NamedType('info', LogotypeInfo())
  132. )
  133. # Logotype Certificate Extension
  134. id_pe_logotype = univ.ObjectIdentifier('1.3.6.1.5.5.7.1.12')
  135. class LogotypeExtn(univ.Sequence):
  136. pass
  137. LogotypeExtn.componentType = namedtype.NamedTypes(
  138. namedtype.OptionalNamedType('communityLogos', univ.SequenceOf(
  139. componentType=LogotypeInfo()).subtype(
  140. explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  141. namedtype.OptionalNamedType('issuerLogo', LogotypeInfo().subtype(
  142. explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),
  143. namedtype.OptionalNamedType('subjectLogo', LogotypeInfo().subtype(
  144. explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2))),
  145. namedtype.OptionalNamedType('otherLogos', univ.SequenceOf(
  146. componentType=OtherLogotypeInfo()).subtype(explicitTag=tag.Tag(
  147. tag.tagClassContext, tag.tagFormatSimple, 3)))
  148. )
  149. # Map of Certificate Extension OIDs to Extensions added to the
  150. # ones that are in rfc5280.py
  151. _certificateExtensionsMapUpdate = {
  152. id_pe_logotype: LogotypeExtn(),
  153. }
  154. rfc5280.certificateExtensionsMap.update(_certificateExtensionsMapUpdate)