pyasn1-alt-modules 0.4.2__py2.py3-none-any.whl → 0.4.4__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyasn1-alt-modules might be problematic. Click here for more details.

Files changed (192) hide show
  1. pyasn1_alt_modules/__init__.py +1 -1
  2. pyasn1_alt_modules/opentypemap.py +1 -1
  3. pyasn1_alt_modules/pem.py +1 -1
  4. pyasn1_alt_modules/rfc1155.py +1 -1
  5. pyasn1_alt_modules/rfc1157.py +1 -1
  6. pyasn1_alt_modules/rfc1901.py +1 -1
  7. pyasn1_alt_modules/rfc1902.py +1 -1
  8. pyasn1_alt_modules/rfc1905.py +1 -1
  9. pyasn1_alt_modules/rfc2040.py +1 -1
  10. pyasn1_alt_modules/rfc2251.py +1 -1
  11. pyasn1_alt_modules/rfc2314.py +1 -1
  12. pyasn1_alt_modules/rfc2315.py +1 -1
  13. pyasn1_alt_modules/rfc2437.py +1 -1
  14. pyasn1_alt_modules/rfc2459.py +1 -1
  15. pyasn1_alt_modules/rfc2511.py +1 -1
  16. pyasn1_alt_modules/rfc2528.py +1 -1
  17. pyasn1_alt_modules/rfc2560.py +1 -1
  18. pyasn1_alt_modules/rfc2631.py +1 -1
  19. pyasn1_alt_modules/rfc2634.py +1 -1
  20. pyasn1_alt_modules/rfc2743.py +1 -1
  21. pyasn1_alt_modules/rfc2876.py +1 -1
  22. pyasn1_alt_modules/rfc2898.py +1 -1
  23. pyasn1_alt_modules/rfc2985.py +1 -1
  24. pyasn1_alt_modules/rfc2986.py +1 -1
  25. pyasn1_alt_modules/rfc3058.py +1 -1
  26. pyasn1_alt_modules/rfc3114.py +1 -1
  27. pyasn1_alt_modules/rfc3125.py +1 -1
  28. pyasn1_alt_modules/rfc3161.py +1 -1
  29. pyasn1_alt_modules/rfc3217.py +1 -1
  30. pyasn1_alt_modules/rfc3274.py +1 -1
  31. pyasn1_alt_modules/rfc3279.py +1 -1
  32. pyasn1_alt_modules/rfc3280.py +1 -1
  33. pyasn1_alt_modules/rfc3281.py +1 -1
  34. pyasn1_alt_modules/rfc3370.py +1 -1
  35. pyasn1_alt_modules/rfc3412.py +1 -1
  36. pyasn1_alt_modules/rfc3414.py +1 -1
  37. pyasn1_alt_modules/rfc3447.py +1 -1
  38. pyasn1_alt_modules/rfc3537.py +1 -1
  39. pyasn1_alt_modules/rfc3546.py +23 -0
  40. pyasn1_alt_modules/rfc3560.py +1 -1
  41. pyasn1_alt_modules/rfc3565.py +1 -1
  42. pyasn1_alt_modules/rfc3657.py +1 -1
  43. pyasn1_alt_modules/rfc3709.py +1 -1
  44. pyasn1_alt_modules/rfc3739.py +6 -3
  45. pyasn1_alt_modules/rfc3770.py +1 -1
  46. pyasn1_alt_modules/rfc3779.py +1 -1
  47. pyasn1_alt_modules/rfc3820.py +1 -1
  48. pyasn1_alt_modules/rfc3852.py +1 -1
  49. pyasn1_alt_modules/rfc3874.py +1 -1
  50. pyasn1_alt_modules/rfc4010.py +1 -1
  51. pyasn1_alt_modules/rfc4043.py +1 -1
  52. pyasn1_alt_modules/rfc4055.py +1 -1
  53. pyasn1_alt_modules/rfc4056.py +1 -1
  54. pyasn1_alt_modules/rfc4059.py +1 -1
  55. pyasn1_alt_modules/rfc4073.py +1 -1
  56. pyasn1_alt_modules/rfc4108.py +1 -1
  57. pyasn1_alt_modules/rfc4210.py +1 -1
  58. pyasn1_alt_modules/rfc4211.py +1 -1
  59. pyasn1_alt_modules/rfc4231.py +1 -1
  60. pyasn1_alt_modules/rfc4262.py +1 -1
  61. pyasn1_alt_modules/rfc4334.py +1 -1
  62. pyasn1_alt_modules/rfc4357.py +1 -1
  63. pyasn1_alt_modules/rfc4366.py +23 -0
  64. pyasn1_alt_modules/rfc4387.py +1 -1
  65. pyasn1_alt_modules/rfc4476.py +1 -1
  66. pyasn1_alt_modules/rfc4490.py +1 -1
  67. pyasn1_alt_modules/rfc4491.py +1 -1
  68. pyasn1_alt_modules/rfc4683.py +1 -1
  69. pyasn1_alt_modules/rfc4985.py +1 -1
  70. pyasn1_alt_modules/rfc4998.py +1 -1
  71. pyasn1_alt_modules/rfc5035.py +1 -1
  72. pyasn1_alt_modules/rfc5055.py +1 -1
  73. pyasn1_alt_modules/rfc5083.py +1 -1
  74. pyasn1_alt_modules/rfc5084.py +1 -1
  75. pyasn1_alt_modules/rfc5126.py +1 -1
  76. pyasn1_alt_modules/rfc5208.py +1 -1
  77. pyasn1_alt_modules/rfc5275.py +1 -1
  78. pyasn1_alt_modules/rfc5276.py +1 -1
  79. pyasn1_alt_modules/rfc5280.py +3 -2
  80. pyasn1_alt_modules/rfc5480.py +1 -1
  81. pyasn1_alt_modules/rfc5544.py +1 -1
  82. pyasn1_alt_modules/rfc5636.py +1 -1
  83. pyasn1_alt_modules/rfc5639.py +1 -1
  84. pyasn1_alt_modules/rfc5649.py +1 -1
  85. pyasn1_alt_modules/rfc5652.py +1 -1
  86. pyasn1_alt_modules/rfc5697.py +1 -1
  87. pyasn1_alt_modules/rfc5698.py +1 -1
  88. pyasn1_alt_modules/rfc5751.py +1 -1
  89. pyasn1_alt_modules/rfc5752.py +1 -1
  90. pyasn1_alt_modules/rfc5753.py +1 -1
  91. pyasn1_alt_modules/rfc5755.py +1 -1
  92. pyasn1_alt_modules/rfc5913.py +1 -1
  93. pyasn1_alt_modules/rfc5914.py +1 -1
  94. pyasn1_alt_modules/rfc5915.py +1 -1
  95. pyasn1_alt_modules/rfc5916.py +1 -1
  96. pyasn1_alt_modules/rfc5917.py +1 -1
  97. pyasn1_alt_modules/rfc5924.py +1 -1
  98. pyasn1_alt_modules/rfc5934.py +1 -1
  99. pyasn1_alt_modules/rfc5940.py +1 -1
  100. pyasn1_alt_modules/rfc5958.py +1 -1
  101. pyasn1_alt_modules/rfc5990.py +1 -1
  102. pyasn1_alt_modules/rfc6010.py +1 -1
  103. pyasn1_alt_modules/rfc6019.py +1 -1
  104. pyasn1_alt_modules/rfc6031.py +1 -1
  105. pyasn1_alt_modules/rfc6032.py +1 -1
  106. pyasn1_alt_modules/rfc6066.py +1 -1
  107. pyasn1_alt_modules/rfc6120.py +1 -1
  108. pyasn1_alt_modules/rfc6170.py +1 -1
  109. pyasn1_alt_modules/rfc6187.py +1 -1
  110. pyasn1_alt_modules/rfc6210.py +1 -1
  111. pyasn1_alt_modules/rfc6211.py +1 -1
  112. pyasn1_alt_modules/rfc6402.py +1 -1
  113. pyasn1_alt_modules/rfc6482.py +1 -1
  114. pyasn1_alt_modules/rfc6484.py +1 -1
  115. pyasn1_alt_modules/rfc6486.py +1 -1
  116. pyasn1_alt_modules/rfc6487.py +1 -1
  117. pyasn1_alt_modules/rfc6492.py +1 -1
  118. pyasn1_alt_modules/rfc6493.py +1 -1
  119. pyasn1_alt_modules/rfc6494.py +1 -1
  120. pyasn1_alt_modules/rfc6664.py +1 -1
  121. pyasn1_alt_modules/rfc6955.py +1 -1
  122. pyasn1_alt_modules/rfc6960.py +1 -1
  123. pyasn1_alt_modules/rfc6962.py +1 -1
  124. pyasn1_alt_modules/rfc7030.py +1 -1
  125. pyasn1_alt_modules/rfc7191.py +1 -1
  126. pyasn1_alt_modules/rfc7229.py +1 -1
  127. pyasn1_alt_modules/rfc7292.py +1 -1
  128. pyasn1_alt_modules/rfc7296.py +1 -1
  129. pyasn1_alt_modules/rfc7508.py +1 -1
  130. pyasn1_alt_modules/rfc7585.py +1 -1
  131. pyasn1_alt_modules/rfc7633.py +1 -1
  132. pyasn1_alt_modules/rfc7693.py +1 -1
  133. pyasn1_alt_modules/rfc7773.py +1 -1
  134. pyasn1_alt_modules/rfc7836.py +1 -1
  135. pyasn1_alt_modules/rfc7894.py +1 -1
  136. pyasn1_alt_modules/rfc7906.py +1 -1
  137. pyasn1_alt_modules/rfc7914.py +1 -1
  138. pyasn1_alt_modules/rfc8017.py +1 -1
  139. pyasn1_alt_modules/rfc8018.py +1 -1
  140. pyasn1_alt_modules/rfc8103.py +1 -1
  141. pyasn1_alt_modules/rfc8209.py +1 -1
  142. pyasn1_alt_modules/rfc8226.py +1 -1
  143. pyasn1_alt_modules/rfc8358.py +1 -1
  144. pyasn1_alt_modules/rfc8360.py +1 -1
  145. pyasn1_alt_modules/rfc8398.py +1 -1
  146. pyasn1_alt_modules/rfc8410.py +1 -1
  147. pyasn1_alt_modules/rfc8418.py +1 -1
  148. pyasn1_alt_modules/rfc8419.py +1 -1
  149. pyasn1_alt_modules/rfc8479.py +1 -1
  150. pyasn1_alt_modules/rfc8494.py +1 -1
  151. pyasn1_alt_modules/rfc8520.py +1 -1
  152. pyasn1_alt_modules/rfc8619.py +1 -1
  153. pyasn1_alt_modules/rfc8649.py +1 -1
  154. pyasn1_alt_modules/rfc8692.py +1 -1
  155. pyasn1_alt_modules/rfc8696.py +1 -1
  156. pyasn1_alt_modules/rfc8702.py +1 -1
  157. pyasn1_alt_modules/rfc8708.py +1 -1
  158. pyasn1_alt_modules/rfc8737.py +1 -1
  159. pyasn1_alt_modules/rfc8769.py +1 -1
  160. pyasn1_alt_modules/rfc8894.py +1 -1
  161. pyasn1_alt_modules/rfc8951.py +1 -1
  162. pyasn1_alt_modules/rfc8954.py +238 -0
  163. pyasn1_alt_modules/rfc8994.py +1 -1
  164. pyasn1_alt_modules/rfc8995.py +1 -1
  165. pyasn1_alt_modules/rfc9044.py +1 -1
  166. pyasn1_alt_modules/rfc9092.py +1 -1
  167. pyasn1_alt_modules/rfc9118.py +1 -1
  168. pyasn1_alt_modules/rfc9174.py +1 -1
  169. pyasn1_alt_modules/rfc9189.py +1 -1
  170. pyasn1_alt_modules/rfc9215.py +11 -1
  171. pyasn1_alt_modules/rfc9286.py +1 -1
  172. pyasn1_alt_modules/rfc9289.py +1 -1
  173. pyasn1_alt_modules/rfc9310.py +1 -1
  174. pyasn1_alt_modules/rfc9323.py +1 -1
  175. pyasn1_alt_modules/rfc9336.py +1 -1
  176. pyasn1_alt_modules/rfc9337.py +1 -1
  177. pyasn1_alt_modules/rfc9345.py +36 -0
  178. pyasn1_alt_modules/rfc9385.py +22 -0
  179. pyasn1_alt_modules/rfc9399.py +59 -0
  180. pyasn1_alt_modules/rfc9480.py +717 -0
  181. pyasn1_alt_modules/rfc9481.py +224 -0
  182. pyasn1_alt_modules/rfc9509.py +24 -0
  183. pyasn1_alt_modules/rfc9548.py +23 -0
  184. {pyasn1_alt_modules-0.4.2.dist-info → pyasn1_alt_modules-0.4.4.dist-info}/LICENSE.txt +1 -1
  185. {pyasn1_alt_modules-0.4.2.dist-info → pyasn1_alt_modules-0.4.4.dist-info}/METADATA +7 -7
  186. pyasn1_alt_modules-0.4.4.dist-info/RECORD +189 -0
  187. {pyasn1_alt_modules-0.4.2.dist-info → pyasn1_alt_modules-0.4.4.dist-info}/WHEEL +1 -1
  188. pyasn1_alt_modules/addon.py +0 -284
  189. pyasn1_alt_modules/rfc5794.py +0 -391
  190. pyasn1_alt_modules-0.4.2.dist-info/RECORD +0 -181
  191. {pyasn1_alt_modules-0.4.2.dist-info → pyasn1_alt_modules-0.4.4.dist-info}/top_level.txt +0 -0
  192. {pyasn1_alt_modules-0.4.2.dist-info → pyasn1_alt_modules-0.4.4.dist-info}/zip-safe +0 -0
@@ -1,284 +0,0 @@
1
- #
2
- # This file is part of pyasn1-alt-modules software.
3
- #
4
- # This is for things that ought to be part of pyasn1, but contributions
5
- # are no longer being merged and released. Therefore, this module is
6
- # used to make additions at runtime.
7
- #
8
- # Created by Russ Housley
9
- # Copyright (c) 2021-2022, Vigil Security, LLC
10
- # License: http://vigilsec.com/pyasn1-alt-modules-license.txt
11
- #
12
-
13
- from pyasn1.type import base
14
- from pyasn1.type import constraint
15
- from pyasn1.type import error
16
- from pyasn1.type import tag
17
-
18
- from pyasn1.codec.ber import encoder
19
- from pyasn1.codec.ber import decoder
20
-
21
- from pyasn1.compat.octets import isStringType, octs2ints
22
-
23
-
24
- # ----------------------------------------------------------------------
25
- #
26
- # Implementation of the ASN.1 RELATIVE-OID typ1
27
- #
28
- # ----------------------------------------------------------------------
29
-
30
-
31
- # ----------------------------------------------------------------------
32
- # This would be better implemented in pyasn1.type.univ
33
- # ----------------------------------------------------------------------
34
-
35
- class RelativeOID(base.SimpleAsn1Type):
36
- """Create |ASN.1| schema or value object.
37
-
38
- |ASN.1| class is based on :class:`~pyasn1.type.base.SimpleAsn1Type`, its
39
- objects are immutable and duck-type Python :class:`tuple` objects
40
- (tuple of non-negative integers).
41
-
42
- Keyword Args
43
- ------------
44
- value: :class:`tuple`, :class:`str` or |ASN.1| object
45
- Python sequence of :class:`int` or :class:`str` literal or |ASN.1| object.
46
- If `value` is not given, schema object will be created.
47
-
48
- tagSet: :py:class:`~pyasn1.type.tag.TagSet`
49
- Object representing non-default ASN.1 tag(s)
50
-
51
- subtypeSpec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
52
- Object representing non-default ASN.1 subtype constraint(s). Constraints
53
- verification for |ASN.1| type occurs automatically on object
54
- instantiation.
55
-
56
- Raises
57
- ------
58
- ~pyasn1.error.ValueConstraintError, ~pyasn1.error.PyAsn1Error
59
- On constraint violation or bad initializer.
60
-
61
- Examples
62
- --------
63
- .. code-block:: python
64
-
65
- class RelOID(RelativeOID):
66
- '''
67
- ASN.1 specification:
68
-
69
- id-pad-null RELATIVE-OID ::= { 0 }
70
- id-pad-once RELATIVE-OID ::= { 5 6 }
71
- id-pad-twice RELATIVE-OID ::= { 5 6 7 }
72
- '''
73
- id_pad_null = RelOID('0')
74
- id_pad_once = RelOID('5.6')
75
- id_pad_twice = id_pad_once + (7,)
76
- """
77
- #: Set (on class, not on instance) or return a
78
- #: :py:class:`~pyasn1.type.tag.TagSet` object representing ASN.1 tag(s)
79
- #: associated with |ASN.1| type.
80
- tagSet = tag.initTagSet(
81
- tag.Tag(tag.tagClassUniversal, tag.tagFormatSimple, 0x0d)
82
- )
83
-
84
- #: Set (on class, not on instance) or return a
85
- #: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection` object
86
- #: imposing constraints on |ASN.1| type initialization values.
87
- subtypeSpec = constraint.ConstraintsIntersection()
88
-
89
- # Optimization for faster codec lookup
90
- typeId = base.SimpleAsn1Type.getTypeId()
91
-
92
- def __add__(self, other):
93
- return self.clone(self._value + other)
94
-
95
- def __radd__(self, other):
96
- return self.clone(other + self._value)
97
-
98
- def asTuple(self):
99
- return self._value
100
-
101
- # Sequence object protocol
102
-
103
- def __len__(self):
104
- return len(self._value)
105
-
106
- def __getitem__(self, i):
107
- if i.__class__ is slice:
108
- return self.clone(self._value[i])
109
- else:
110
- return self._value[i]
111
-
112
- def __iter__(self):
113
- return iter(self._value)
114
-
115
- def __contains__(self, value):
116
- return value in self._value
117
-
118
- def index(self, suboid):
119
- return self._value.index(suboid)
120
-
121
- def isPrefixOf(self, other):
122
- """Indicate if this |ASN.1| object is a prefix of other |ASN.1| object.
123
-
124
- Parameters
125
- ----------
126
- other: |ASN.1| object
127
- |ASN.1| object
128
-
129
- Returns
130
- -------
131
- : :class:`bool`
132
- :obj:`True` if this |ASN.1| object is a parent (e.g. prefix) of the other |ASN.1| object
133
- or :obj:`False` otherwise.
134
- """
135
- l = len(self)
136
- if l <= len(other):
137
- if self._value[:l] == other[:l]:
138
- return True
139
- return False
140
-
141
- def prettyIn(self, value):
142
- if isinstance(value, RelativeOID):
143
- return tuple(value)
144
- elif isStringType(value):
145
- if '-' in value:
146
- raise error.PyAsn1Error(
147
- 'Malformed RELATIVE-OID %s at %s: %s' % (value, self.__class__.__name__, sys.exc_info()[1])
148
- )
149
- try:
150
- return tuple([int(subOid) for subOid in value.split('.') if subOid])
151
- except ValueError:
152
- raise error.PyAsn1Error(
153
- 'Malformed RELATIVE-OID %s at %s: %s' % (value, self.__class__.__name__, sys.exc_info()[1])
154
- )
155
-
156
- try:
157
- tupleOfInts = tuple([int(subOid) for subOid in value if subOid >= 0])
158
-
159
- except (ValueError, TypeError):
160
- raise error.PyAsn1Error(
161
- 'Malformed RELATIVE-OID %s at %s: %s' % (value, self.__class__.__name__, sys.exc_info()[1])
162
- )
163
-
164
- if len(tupleOfInts) == len(value):
165
- return tupleOfInts
166
-
167
- raise error.PyAsn1Error('Malformed RELATIVE-OID %s at %s' % (value, self.__class__.__name__))
168
-
169
- def prettyOut(self, value):
170
- return '.'.join([str(x) for x in value])
171
-
172
-
173
- # ----------------------------------------------------------------------
174
- # This would be better implemented in pyasn1.type.codec.ber.encoder
175
- # ----------------------------------------------------------------------
176
-
177
- class RelativeOIDEncoder(encoder.AbstractItemEncoder):
178
- supportIndefLenMode = False
179
-
180
- def encodeValue(self, value, asn1Spec, encodeFun, **options):
181
- if asn1Spec is not None:
182
- value = asn1Spec.clone(value)
183
-
184
- octets = ()
185
-
186
- # Cycle through subIds
187
- for subOid in value.asTuple():
188
- if 0 <= subOid <= 127:
189
- # Optimize for the common case
190
- octets += (subOid,)
191
-
192
- elif subOid > 127:
193
- # Pack large Sub-Object IDs
194
- res = (subOid & 0x7f,)
195
- subOid >>= 7
196
-
197
- while subOid:
198
- res = (0x80 | (subOid & 0x7f),) + res
199
- subOid >>= 7
200
-
201
- # Add packed Sub-Object ID to resulted RELATIVE-OID
202
- octets += res
203
-
204
- else:
205
- raise error.PyAsn1Error('Negative RELATIVE-OID arc %s at %s' % (subOid, value))
206
-
207
- return octets, False, False
208
-
209
-
210
-
211
- # ----------------------------------------------------------------------
212
- # Additions to the TAG_MAP and TYPE_MAP in pyasn1.type.codec.ber.encoder
213
- # ----------------------------------------------------------------------
214
-
215
- if RelativeOID.tagSet not in encoder.TAG_MAP:
216
- encoder.TAG_MAP.update(
217
- { RelativeOID.tagSet: RelativeOIDEncoder(), } )
218
-
219
- if RelativeOID.typeId not in encoder.TYPE_MAP:
220
- encoder.TYPE_MAP.update(
221
- { RelativeOID.typeId: RelativeOIDEncoder(), } )
222
-
223
-
224
- # ----------------------------------------------------------------------
225
- # This would be better implemented in pyasn1.type.codec.ber.decoder
226
- # ----------------------------------------------------------------------
227
-
228
- class RelativeOIDPayloadDecoder(decoder.AbstractSimplePayloadDecoder):
229
- protoComponent = RelativeOID(())
230
-
231
- def valueDecoder(self, substrate, asn1Spec,
232
- tagSet=None, length=None, state=None,
233
- decodeFun=None, substrateFun=None,
234
- **options):
235
- if tagSet[0].tagFormat != tag.tagFormatSimple:
236
- raise error.PyAsn1Error('Simple tag format expected')
237
-
238
- for chunk in readFromStream(substrate, length, options):
239
- if isinstance(chunk, SubstrateUnderrunError):
240
- yield chunk
241
-
242
- if not chunk:
243
- raise error.PyAsn1Error('Empty substrate')
244
-
245
- chunk = octs2ints(chunk)
246
-
247
- reloid = ()
248
- index = 0
249
- substrateLen = len(chunk)
250
- while index < substrateLen:
251
- subId = chunk[index]
252
- index += 1
253
- if subId < 128:
254
- reloid += (subId,)
255
- elif subId > 128:
256
- # Construct subid from a number of octets
257
- nextSubId = subId
258
- subId = 0
259
- while nextSubId >= 128:
260
- subId = (subId << 7) + (nextSubId & 0x7F)
261
- if index >= substrateLen:
262
- raise error.SubstrateUnderrunError(
263
- 'Short substrate for sub-OID past %s' % (reloid,)
264
- )
265
- nextSubId = chunk[index]
266
- index += 1
267
- reloid += ((subId << 7) + nextSubId,)
268
- elif subId == 128:
269
- # ASN.1 spec forbids leading zeros (0x80) in OID
270
- # encoding, tolerating it opens a vulnerability. See page 7 of
271
- # https://www.esat.kuleuven.be/cosic/publications/article-1432.pdf
272
- raise error.PyAsn1Error('Invalid octet 0x80 in RELATIVE-OID encoding')
273
-
274
- yield self._createComponent(asn1Spec, tagSet, reloid, **options)
275
-
276
-
277
- # ----------------------------------------------------------------------
278
- # Additions to the TAG_MAP in pyasn1.type.codec.ber.decoder
279
- # ----------------------------------------------------------------------
280
-
281
- if RelativeOID.tagSet not in decoder.TAG_MAP:
282
- decoder.TAG_MAP.update(
283
- { RelativeOID.tagSet: RelativeOIDPayloadDecoder(), } )
284
-
@@ -1,391 +0,0 @@
1
- #
2
- # This file is part of pyasn1-alt-modules software.
3
- #
4
- # Created by Russ Housley.
5
- #
6
- # Copyright (c) 2020-2022, Vigil Security, LLC
7
- # License: http://vigilsec.com/pyasn1-alt-modules-license.txt
8
- #
9
- # The ARIA Encryption Algorithm
10
- #
11
- # ASN.1 source from:
12
- # https://www.rfc-editor.org/rfc/rfc5794.txt
13
- # https://www.rfc-editor.org/errata/eid2064
14
- #
15
-
16
- from pyasn1.type import constraint
17
- from pyasn1.type import namedtype
18
- from pyasn1.type import univ
19
-
20
- from pyasn1_alt_modules import addon
21
- from pyasn1_alt_modules import rfc5280
22
-
23
-
24
- # Import from RFC 5280
25
-
26
- AlgorithmIdentifier = rfc5280.AlgorithmIdentifier
27
-
28
-
29
- # Object Identifiers
30
-
31
- OID = univ.ObjectIdentifier
32
-
33
-
34
- id_algorithm = univ.ObjectIdentifier((1, 2, 410, 200046, 1,))
35
-
36
- id_sea = id_algorithm + (1,)
37
-
38
- id_pad = id_algorithm + (2,)
39
-
40
-
41
- id_aria128_ecb = id_sea + (1,)
42
-
43
- id_aria128_cbc = id_sea + (2,)
44
-
45
- id_aria128_cfb = id_sea + (3,)
46
-
47
- id_aria128_ofb = id_sea + (4,)
48
-
49
- id_aria128_ctr = id_sea + (5,)
50
-
51
- id_aria192_ecb = id_sea + (6,)
52
-
53
- id_aria192_cbc = id_sea + (7,)
54
-
55
- id_aria192_cfb = id_sea + (8,)
56
-
57
- id_aria192_ofb = id_sea + (9,)
58
-
59
- id_aria192_ctr = id_sea + (10,)
60
-
61
- id_aria256_ecb = id_sea + (11,)
62
-
63
- id_aria256_cbc = id_sea + (12,)
64
-
65
- id_aria256_cfb = id_sea + (13,)
66
-
67
- id_aria256_ofb = id_sea + (14,)
68
-
69
- id_aria256_ctr = id_sea + (15,)
70
-
71
- id_aria128_cmac = id_sea + (21,)
72
-
73
- id_aria192_cmac = id_sea + (22,)
74
-
75
- id_aria256_cmac = id_sea + (23,)
76
-
77
- id_aria128_ocb2 = id_sea + (31,)
78
-
79
- id_aria192_ocb2 = id_sea + (32,)
80
-
81
- id_aria256_ocb2 = id_sea + (33,)
82
-
83
- id_aria128_gcm = id_sea + (34,)
84
-
85
- id_aria192_gcm = id_sea + (35,)
86
-
87
- id_aria256_gcm = id_sea + (36,)
88
-
89
- id_aria128_ccm = id_sea + (37,)
90
-
91
- id_aria192_ccm = id_sea + (38,)
92
-
93
- id_aria256_ccm = id_sea + (39,)
94
-
95
- id_aria128_kw = id_sea + (40,)
96
-
97
- id_aria192_kw = id_sea + (41,)
98
-
99
- id_aria256_kw = id_sea + (42,)
100
-
101
- id_aria128_kwp = id_sea + (43,)
102
-
103
- id_aria192_kwp = id_sea + (44,)
104
-
105
- id_aria256_kwp = id_sea + (45,)
106
-
107
-
108
- # Relative OIDs
109
-
110
- id_pad_null = addon.RelativeOID('0') # no padding algorithms identified
111
-
112
- id_pad_1 = addon.RelativeOID('1') # padding method 2 of ISO/IEC 9797-1:1999
113
-
114
-
115
- # Parameters
116
-
117
- class AriaPadAlgo(univ.Choice):
118
- componentType = namedtype.NamedTypes(
119
- namedtype.NamedType('specifiedPadAlgo', addon.RelativeOID()),
120
- namedtype.NamedType('generalPadAlgo', univ.ObjectIdentifier())
121
- )
122
-
123
-
124
- default_aria_pad_algo_null = AriaPadAlgo()
125
- default_aria_pad_algo_null['specifiedPadAlgo'] = id_pad_null
126
-
127
-
128
- default_aria_pad_algo_1 = AriaPadAlgo()
129
- default_aria_pad_algo_1['specifiedPadAlgo'] = id_pad_1
130
-
131
-
132
- class AriaEcbParameters(univ.Sequence):
133
- componentType = namedtype.NamedTypes(
134
- namedtype.DefaultedNamedType('padAlgo', default_aria_pad_algo_null)
135
- )
136
-
137
-
138
- class AriaCbcParameters(univ.Sequence):
139
- componentType = namedtype.NamedTypes(
140
- namedtype.DefaultedNamedType('m', univ.Integer().subtype(value=1)),
141
- namedtype.DefaultedNamedType('padAlgo', default_aria_pad_algo_1)
142
- )
143
-
144
-
145
- class AriaCfbParameters(univ.Sequence):
146
- componentType = namedtype.NamedTypes(
147
- namedtype.NamedType('r', univ.Integer()), # 128<=r<=128*1024
148
- namedtype.NamedType('k', univ.Integer()), # 1<=k<=128
149
- namedtype.NamedType('j', univ.Integer()), # 1<=j<=k
150
- namedtype.DefaultedNamedType('padAlgo', default_aria_pad_algo_null)
151
- )
152
-
153
-
154
- class AriaOfbParameters(univ.Sequence):
155
- componentType = namedtype.NamedTypes(
156
- namedtype.NamedType('j', univ.Integer()), # 1<=j<=128
157
- namedtype.DefaultedNamedType('padAlgo', default_aria_pad_algo_null)
158
- )
159
-
160
-
161
- class AriaCtrParameters(univ.Sequence):
162
- componentType = namedtype.NamedTypes(
163
- namedtype.NamedType('j', univ.Integer()), # 1<=j<=128
164
- namedtype.DefaultedNamedType('padAlgo', default_aria_pad_algo_null)
165
- )
166
-
167
-
168
- class AriaCmacParameters(univ.Integer):
169
- pass
170
-
171
-
172
- class AriaOcb2Parameters(univ.Integer):
173
- pass
174
-
175
-
176
- class AriaGcmParameters(univ.Sequence):
177
- componentType = namedtype.NamedTypes(
178
- namedtype.NamedType('s', univ.Integer()),
179
- namedtype.NamedType('t', univ.Integer())
180
- )
181
-
182
-
183
- class AriaCcmParameters(univ.Sequence):
184
- componentType = namedtype.NamedTypes(
185
- namedtype.NamedType('w', univ.Integer().subtype(
186
- subtypeSpec=constraint.SingleValueConstraint(
187
- 2, 3, 4, 5, 6, 7, 8))),
188
- namedtype.NamedType('t', univ.Integer().subtype(
189
- subtypeSpec=constraint.SingleValueConstraint(
190
- 32, 48, 64, 80, 96, 112, 128)))
191
- )
192
-
193
-
194
- # Algorithm Identifiers
195
-
196
- class AriaModeOfOperation(AlgorithmIdentifier):
197
- pass
198
-
199
-
200
- aria128ecb = AlgorithmIdentifier()
201
- aria128ecb['algorithm'] = id_aria128_ecb
202
- aria128ecb['parameters'] = AriaEcbParameters()
203
-
204
-
205
- aria128cbc = AlgorithmIdentifier()
206
- aria128cbc['algorithm'] = id_aria128_cbc
207
- aria128cbc['parameters'] = AriaCbcParameters()
208
-
209
-
210
- aria128cfb = AlgorithmIdentifier()
211
- aria128cfb['algorithm'] = id_aria128_cfb
212
- aria128cfb['parameters'] = AriaCfbParameters()
213
-
214
-
215
- aria128ofb = AlgorithmIdentifier()
216
- aria128ofb['algorithm'] = id_aria128_ofb
217
- aria128ofb['parameters'] = AriaOfbParameters()
218
-
219
-
220
- aria128ctr = AlgorithmIdentifier()
221
- aria128ctr['algorithm'] = id_aria128_ctr
222
- aria128ctr['parameters'] = AriaCtrParameters()
223
-
224
-
225
- aria192ecb = AlgorithmIdentifier()
226
- aria192ecb['algorithm'] = id_aria192_ecb
227
- aria192ecb['parameters'] = AriaEcbParameters()
228
-
229
-
230
- aria192cbc = AlgorithmIdentifier()
231
- aria192cbc['algorithm'] = id_aria192_cbc
232
- aria192cbc['parameters'] = AriaCbcParameters()
233
-
234
-
235
- aria192cfb = AlgorithmIdentifier()
236
- aria192cfb['algorithm'] = id_aria192_cfb
237
- aria192cfb['parameters'] = AriaCfbParameters()
238
-
239
-
240
- aria192ofb = AlgorithmIdentifier()
241
- aria192ofb['algorithm'] = id_aria192_ofb
242
- aria192ofb['parameters'] = AriaOfbParameters()
243
-
244
-
245
- aria192ctr = AlgorithmIdentifier()
246
- aria192ctr['algorithm'] = id_aria192_ctr
247
- aria192ctr['parameters'] = AriaCtrParameters()
248
-
249
-
250
- aria256ecb = AlgorithmIdentifier()
251
- aria256ecb['algorithm'] = id_aria256_ecb
252
- aria256ecb['parameters'] = AriaEcbParameters()
253
-
254
-
255
- aria256cbc = AlgorithmIdentifier()
256
- aria256cbc['algorithm'] = id_aria256_cbc
257
- aria256cbc['parameters'] = AriaCbcParameters()
258
-
259
-
260
- aria256cfb = AlgorithmIdentifier()
261
- aria256cfb['algorithm'] = id_aria256_cfb
262
- aria256cfb['parameters'] = AriaCfbParameters()
263
-
264
-
265
- aria256ofb = AlgorithmIdentifier()
266
- aria256ofb['algorithm'] = id_aria256_ofb
267
- aria256ofb['parameters'] = AriaOfbParameters()
268
-
269
-
270
- aria256ctr = AlgorithmIdentifier()
271
- aria256ctr['algorithm'] = id_aria256_ctr
272
- aria256ctr['parameters'] = AriaCtrParameters()
273
-
274
-
275
- aria128cmac = AlgorithmIdentifier()
276
- aria128cmac['algorithm'] = id_aria128_cmac
277
- aria128cmac['parameters'] = AriaCmacParameters()
278
-
279
-
280
- aria192cmac = AlgorithmIdentifier()
281
- aria192cmac['algorithm'] = id_aria192_cmac
282
- aria192cmac['parameters'] = AriaCmacParameters()
283
-
284
-
285
- aria256cmac = AlgorithmIdentifier()
286
- aria256cmac['algorithm'] = id_aria256_cmac
287
- aria256cmac['parameters'] = AriaCmacParameters()
288
-
289
-
290
- aria128ocb2 = AlgorithmIdentifier()
291
- aria128ocb2['algorithm'] = id_aria128_ocb2
292
- aria128ocb2['parameters'] = AriaOcb2Parameters()
293
-
294
-
295
- aria192ocb2 = AlgorithmIdentifier()
296
- aria192ocb2['algorithm'] = id_aria192_ocb2
297
- aria192ocb2['parameters'] = AriaOcb2Parameters()
298
-
299
-
300
- aria256ocb2 = AlgorithmIdentifier()
301
- aria256ocb2['algorithm'] = id_aria256_ocb2
302
- aria256ocb2['parameters'] = AriaOcb2Parameters()
303
-
304
-
305
- aria128gcm = AlgorithmIdentifier()
306
- aria128gcm['algorithm'] = id_aria128_gcm
307
- aria128gcm['parameters'] = AriaGcmParameters()
308
-
309
-
310
- aria192gcm = AlgorithmIdentifier()
311
- aria192gcm['algorithm'] = id_aria192_gcm
312
- aria192gcm['parameters'] = AriaGcmParameters()
313
-
314
-
315
- aria256gcm = AlgorithmIdentifier()
316
- aria256gcm['algorithm'] = id_aria256_gcm
317
- aria256gcm['parameters'] = AriaGcmParameters()
318
-
319
-
320
- aria128ccm = AlgorithmIdentifier()
321
- aria128ccm['algorithm'] = id_aria128_ccm
322
- aria128ccm['parameters'] = AriaCcmParameters()
323
-
324
-
325
- aria192ccm = AlgorithmIdentifier()
326
- aria192ccm['algorithm'] = id_aria192_ccm
327
- aria192ccm['parameters'] = AriaCcmParameters()
328
-
329
-
330
- aria256ccm = AlgorithmIdentifier()
331
- aria256ccm['algorithm'] = id_aria256_ccm
332
- aria256ccm['parameters'] = AriaCcmParameters()
333
-
334
-
335
- aria128kw = AlgorithmIdentifier()
336
- aria128kw['algorithm'] = id_aria128_kw
337
-
338
-
339
- aria192kw = AlgorithmIdentifier()
340
- aria192kw['algorithm'] = id_aria192_kw
341
-
342
-
343
- aria256kw = AlgorithmIdentifier()
344
- aria256kw['algorithm'] = id_aria256_kw
345
-
346
-
347
- aria128kwp = AlgorithmIdentifier()
348
- aria128kwp['algorithm'] = id_aria128_kwp
349
-
350
-
351
- aria192kwp = AlgorithmIdentifier()
352
- aria192kwp['algorithm'] = id_aria192_kwp
353
-
354
-
355
- aria256kwp = AlgorithmIdentifier()
356
- aria256kwp['algorithm'] = id_aria256_kwp
357
-
358
-
359
- # Update the Algorithm Identifier map in rfc5280.py
360
-
361
- _algorithmIdentifierMapUpdate = {
362
- id_aria128_ecb: AriaEcbParameters(),
363
- id_aria128_cbc: AriaCbcParameters(),
364
- id_aria128_cfb: AriaCfbParameters(),
365
- id_aria128_ofb: AriaOfbParameters(),
366
- id_aria128_ctr: AriaCtrParameters(),
367
- id_aria192_ecb: AriaEcbParameters(),
368
- id_aria192_cbc: AriaCbcParameters(),
369
- id_aria192_cfb: AriaCfbParameters(),
370
- id_aria192_ofb: AriaOfbParameters(),
371
- id_aria192_ctr: AriaCtrParameters(),
372
- id_aria256_ecb: AriaEcbParameters(),
373
- id_aria256_cbc: AriaCbcParameters(),
374
- id_aria256_cfb: AriaCfbParameters(),
375
- id_aria256_ofb: AriaOfbParameters(),
376
- id_aria256_ctr: AriaCtrParameters(),
377
- id_aria128_cmac: AriaCmacParameters(),
378
- id_aria192_cmac: AriaCmacParameters(),
379
- id_aria256_cmac: AriaCmacParameters(),
380
- id_aria128_ocb2: AriaOcb2Parameters(),
381
- id_aria192_ocb2: AriaOcb2Parameters(),
382
- id_aria256_ocb2: AriaOcb2Parameters(),
383
- id_aria128_gcm: AriaGcmParameters(),
384
- id_aria192_gcm: AriaGcmParameters(),
385
- id_aria256_gcm: AriaGcmParameters(),
386
- id_aria128_ccm: AriaCcmParameters(),
387
- id_aria192_ccm: AriaCcmParameters(),
388
- id_aria256_ccm: AriaCcmParameters(),
389
- }
390
-
391
- rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate)