pyasn1-alt-modules 0.4.5__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 (195) hide show
  1. pyasn1_alt_modules/__init__.py +2 -0
  2. pyasn1_alt_modules/opentypemap.py +19 -0
  3. pyasn1_alt_modules/pem.py +66 -0
  4. pyasn1_alt_modules/rfc1155.py +97 -0
  5. pyasn1_alt_modules/rfc1157.py +127 -0
  6. pyasn1_alt_modules/rfc1901.py +23 -0
  7. pyasn1_alt_modules/rfc1902.py +130 -0
  8. pyasn1_alt_modules/rfc1905.py +136 -0
  9. pyasn1_alt_modules/rfc2040.py +50 -0
  10. pyasn1_alt_modules/rfc2251.py +564 -0
  11. pyasn1_alt_modules/rfc2314.py +68 -0
  12. pyasn1_alt_modules/rfc2315.py +325 -0
  13. pyasn1_alt_modules/rfc2437.py +70 -0
  14. pyasn1_alt_modules/rfc2459.py +1340 -0
  15. pyasn1_alt_modules/rfc2511.py +303 -0
  16. pyasn1_alt_modules/rfc2528.py +34 -0
  17. pyasn1_alt_modules/rfc2560.py +226 -0
  18. pyasn1_alt_modules/rfc2631.py +37 -0
  19. pyasn1_alt_modules/rfc2634.py +342 -0
  20. pyasn1_alt_modules/rfc2743.py +60 -0
  21. pyasn1_alt_modules/rfc2876.py +61 -0
  22. pyasn1_alt_modules/rfc2898.py +72 -0
  23. pyasn1_alt_modules/rfc2985.py +593 -0
  24. pyasn1_alt_modules/rfc2986.py +76 -0
  25. pyasn1_alt_modules/rfc3058.py +48 -0
  26. pyasn1_alt_modules/rfc3114.py +80 -0
  27. pyasn1_alt_modules/rfc3125.py +469 -0
  28. pyasn1_alt_modules/rfc3161.py +142 -0
  29. pyasn1_alt_modules/rfc3217.py +42 -0
  30. pyasn1_alt_modules/rfc3274.py +62 -0
  31. pyasn1_alt_modules/rfc3279.py +264 -0
  32. pyasn1_alt_modules/rfc3280.py +1544 -0
  33. pyasn1_alt_modules/rfc3281.py +332 -0
  34. pyasn1_alt_modules/rfc3370.py +142 -0
  35. pyasn1_alt_modules/rfc3412.py +54 -0
  36. pyasn1_alt_modules/rfc3414.py +29 -0
  37. pyasn1_alt_modules/rfc3447.py +46 -0
  38. pyasn1_alt_modules/rfc3537.py +44 -0
  39. pyasn1_alt_modules/rfc3546.py +23 -0
  40. pyasn1_alt_modules/rfc3560.py +74 -0
  41. pyasn1_alt_modules/rfc3565.py +59 -0
  42. pyasn1_alt_modules/rfc3657.py +69 -0
  43. pyasn1_alt_modules/rfc3709.py +230 -0
  44. pyasn1_alt_modules/rfc3739.py +207 -0
  45. pyasn1_alt_modules/rfc3770.py +77 -0
  46. pyasn1_alt_modules/rfc3779.py +139 -0
  47. pyasn1_alt_modules/rfc3820.py +66 -0
  48. pyasn1_alt_modules/rfc3852.py +707 -0
  49. pyasn1_alt_modules/rfc3874.py +29 -0
  50. pyasn1_alt_modules/rfc4010.py +58 -0
  51. pyasn1_alt_modules/rfc4043.py +45 -0
  52. pyasn1_alt_modules/rfc4055.py +285 -0
  53. pyasn1_alt_modules/rfc4056.py +56 -0
  54. pyasn1_alt_modules/rfc4059.py +101 -0
  55. pyasn1_alt_modules/rfc4073.py +62 -0
  56. pyasn1_alt_modules/rfc4108.py +355 -0
  57. pyasn1_alt_modules/rfc4210.py +807 -0
  58. pyasn1_alt_modules/rfc4211.py +420 -0
  59. pyasn1_alt_modules/rfc4231.py +38 -0
  60. pyasn1_alt_modules/rfc4262.py +37 -0
  61. pyasn1_alt_modules/rfc4334.py +78 -0
  62. pyasn1_alt_modules/rfc4357.py +485 -0
  63. pyasn1_alt_modules/rfc4366.py +23 -0
  64. pyasn1_alt_modules/rfc4387.py +23 -0
  65. pyasn1_alt_modules/rfc4476.py +99 -0
  66. pyasn1_alt_modules/rfc4490.py +119 -0
  67. pyasn1_alt_modules/rfc4491.py +44 -0
  68. pyasn1_alt_modules/rfc4683.py +76 -0
  69. pyasn1_alt_modules/rfc4985.py +52 -0
  70. pyasn1_alt_modules/rfc4998.py +125 -0
  71. pyasn1_alt_modules/rfc5035.py +206 -0
  72. pyasn1_alt_modules/rfc5055.py +763 -0
  73. pyasn1_alt_modules/rfc5083.py +55 -0
  74. pyasn1_alt_modules/rfc5084.py +94 -0
  75. pyasn1_alt_modules/rfc5126.py +578 -0
  76. pyasn1_alt_modules/rfc5208.py +73 -0
  77. pyasn1_alt_modules/rfc5275.py +404 -0
  78. pyasn1_alt_modules/rfc5276.py +82 -0
  79. pyasn1_alt_modules/rfc5280.py +1666 -0
  80. pyasn1_alt_modules/rfc5480.py +190 -0
  81. pyasn1_alt_modules/rfc5544.py +127 -0
  82. pyasn1_alt_modules/rfc5636.py +117 -0
  83. pyasn1_alt_modules/rfc5639.py +49 -0
  84. pyasn1_alt_modules/rfc5649.py +33 -0
  85. pyasn1_alt_modules/rfc5652.py +763 -0
  86. pyasn1_alt_modules/rfc5697.py +64 -0
  87. pyasn1_alt_modules/rfc5698.py +159 -0
  88. pyasn1_alt_modules/rfc5751.py +127 -0
  89. pyasn1_alt_modules/rfc5752.py +52 -0
  90. pyasn1_alt_modules/rfc5753.py +163 -0
  91. pyasn1_alt_modules/rfc5755.py +400 -0
  92. pyasn1_alt_modules/rfc5913.py +46 -0
  93. pyasn1_alt_modules/rfc5914.py +119 -0
  94. pyasn1_alt_modules/rfc5915.py +32 -0
  95. pyasn1_alt_modules/rfc5916.py +39 -0
  96. pyasn1_alt_modules/rfc5917.py +59 -0
  97. pyasn1_alt_modules/rfc5924.py +19 -0
  98. pyasn1_alt_modules/rfc5934.py +786 -0
  99. pyasn1_alt_modules/rfc5940.py +62 -0
  100. pyasn1_alt_modules/rfc5958.py +100 -0
  101. pyasn1_alt_modules/rfc5990.py +238 -0
  102. pyasn1_alt_modules/rfc6010.py +92 -0
  103. pyasn1_alt_modules/rfc6019.py +46 -0
  104. pyasn1_alt_modules/rfc6031.py +469 -0
  105. pyasn1_alt_modules/rfc6032.py +71 -0
  106. pyasn1_alt_modules/rfc6066.py +25 -0
  107. pyasn1_alt_modules/rfc6120.py +46 -0
  108. pyasn1_alt_modules/rfc6170.py +17 -0
  109. pyasn1_alt_modules/rfc6187.py +22 -0
  110. pyasn1_alt_modules/rfc6210.py +45 -0
  111. pyasn1_alt_modules/rfc6211.py +75 -0
  112. pyasn1_alt_modules/rfc6402.py +643 -0
  113. pyasn1_alt_modules/rfc6482.py +77 -0
  114. pyasn1_alt_modules/rfc6484.py +17 -0
  115. pyasn1_alt_modules/rfc6486.py +70 -0
  116. pyasn1_alt_modules/rfc6487.py +22 -0
  117. pyasn1_alt_modules/rfc6492.py +41 -0
  118. pyasn1_alt_modules/rfc6493.py +24 -0
  119. pyasn1_alt_modules/rfc6494.py +23 -0
  120. pyasn1_alt_modules/rfc6664.py +151 -0
  121. pyasn1_alt_modules/rfc6955.py +112 -0
  122. pyasn1_alt_modules/rfc6960.py +234 -0
  123. pyasn1_alt_modules/rfc6962.py +52 -0
  124. pyasn1_alt_modules/rfc7030.py +70 -0
  125. pyasn1_alt_modules/rfc7191.py +267 -0
  126. pyasn1_alt_modules/rfc7229.py +29 -0
  127. pyasn1_alt_modules/rfc7292.py +359 -0
  128. pyasn1_alt_modules/rfc7296.py +32 -0
  129. pyasn1_alt_modules/rfc7508.py +92 -0
  130. pyasn1_alt_modules/rfc7585.py +53 -0
  131. pyasn1_alt_modules/rfc7633.py +40 -0
  132. pyasn1_alt_modules/rfc7693.py +66 -0
  133. pyasn1_alt_modules/rfc7773.py +54 -0
  134. pyasn1_alt_modules/rfc7836.py +65 -0
  135. pyasn1_alt_modules/rfc7894.py +100 -0
  136. pyasn1_alt_modules/rfc7906.py +739 -0
  137. pyasn1_alt_modules/rfc7914.py +55 -0
  138. pyasn1_alt_modules/rfc8017.py +159 -0
  139. pyasn1_alt_modules/rfc8018.py +269 -0
  140. pyasn1_alt_modules/rfc8103.py +36 -0
  141. pyasn1_alt_modules/rfc8209.py +20 -0
  142. pyasn1_alt_modules/rfc8226.py +151 -0
  143. pyasn1_alt_modules/rfc8358.py +54 -0
  144. pyasn1_alt_modules/rfc8360.py +46 -0
  145. pyasn1_alt_modules/rfc8398.py +55 -0
  146. pyasn1_alt_modules/rfc8410.py +43 -0
  147. pyasn1_alt_modules/rfc8418.py +36 -0
  148. pyasn1_alt_modules/rfc8419.py +70 -0
  149. pyasn1_alt_modules/rfc8479.py +48 -0
  150. pyasn1_alt_modules/rfc8494.py +80 -0
  151. pyasn1_alt_modules/rfc8520.py +66 -0
  152. pyasn1_alt_modules/rfc8619.py +45 -0
  153. pyasn1_alt_modules/rfc8649.py +42 -0
  154. pyasn1_alt_modules/rfc8692.py +79 -0
  155. pyasn1_alt_modules/rfc8696.py +108 -0
  156. pyasn1_alt_modules/rfc8702.py +109 -0
  157. pyasn1_alt_modules/rfc8708.py +43 -0
  158. pyasn1_alt_modules/rfc8737.py +36 -0
  159. pyasn1_alt_modules/rfc8769.py +21 -0
  160. pyasn1_alt_modules/rfc8894.py +52 -0
  161. pyasn1_alt_modules/rfc8951.py +42 -0
  162. pyasn1_alt_modules/rfc8954.py +238 -0
  163. pyasn1_alt_modules/rfc8994.py +52 -0
  164. pyasn1_alt_modules/rfc8995.py +39 -0
  165. pyasn1_alt_modules/rfc9044.py +80 -0
  166. pyasn1_alt_modules/rfc9092.py +35 -0
  167. pyasn1_alt_modules/rfc9118.py +82 -0
  168. pyasn1_alt_modules/rfc9174.py +55 -0
  169. pyasn1_alt_modules/rfc9189.py +74 -0
  170. pyasn1_alt_modules/rfc9215.py +228 -0
  171. pyasn1_alt_modules/rfc9286.py +78 -0
  172. pyasn1_alt_modules/rfc9289.py +22 -0
  173. pyasn1_alt_modules/rfc9310.py +46 -0
  174. pyasn1_alt_modules/rfc9323.py +129 -0
  175. pyasn1_alt_modules/rfc9336.py +20 -0
  176. pyasn1_alt_modules/rfc9337.py +74 -0
  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 +731 -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/rfc9579.py +89 -0
  185. pyasn1_alt_modules/rfc9582.py +107 -0
  186. pyasn1_alt_modules/rfc9598.py +52 -0
  187. pyasn1_alt_modules/rfc9608.py +35 -0
  188. pyasn1_alt_modules/rfc9629.py +100 -0
  189. pyasn1_alt_modules/rfc9654.py +241 -0
  190. pyasn1_alt_modules-0.4.5.dist-info/LICENSE.txt +25 -0
  191. pyasn1_alt_modules-0.4.5.dist-info/METADATA +34 -0
  192. pyasn1_alt_modules-0.4.5.dist-info/RECORD +195 -0
  193. pyasn1_alt_modules-0.4.5.dist-info/WHEEL +5 -0
  194. pyasn1_alt_modules-0.4.5.dist-info/top_level.txt +1 -0
  195. pyasn1_alt_modules-0.4.5.dist-info/zip-safe +1 -0
@@ -0,0 +1,2 @@
1
+ # http://www.python.org/dev/peps/pep-0396/
2
+ __version__ = '0.4.5'
@@ -0,0 +1,19 @@
1
+ #
2
+ # This file is part of pyasn1-alt-modules software.
3
+ #
4
+ # This very simple manager for opentype maps allows various related
5
+ # ASN.1 modules to share the same maps.
6
+ #
7
+ # Created by Russ Housley
8
+ # Copyright (c) 2021-2024, Vigil Security, LLC
9
+ # License: http://vigilsec.com/pyasn1-alt-modules-license.txt
10
+ #
11
+
12
+ from collections import defaultdict
13
+
14
+ map_of_opentype_maps = defaultdict(dict)
15
+
16
+
17
+ def get (map_name):
18
+ """Get the named opentype map, creating an empty one if needed."""
19
+ return map_of_opentype_maps[map_name]
@@ -0,0 +1,66 @@
1
+ #
2
+ # This file is part of pyasn1-alt-modules software.
3
+ #
4
+ # Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
5
+ # Copyright (c) 2021-2024, Vigil Security, LLC
6
+ # License: http://vigilsec.com/pyasn1-alt-modules-license.txt
7
+ #
8
+ import base64
9
+ import sys
10
+
11
+ stSpam, stHam, stDump = 0, 1, 2
12
+
13
+
14
+ # The markers parameters is in form ('start1', 'stop1'), ('start2', 'stop2')...
15
+ # Return is (marker-index, substrate)
16
+ def readPemBlocksFromFile(fileObj, *markers):
17
+ startMarkers = dict(map(lambda x: (x[1], x[0]),
18
+ enumerate(map(lambda y: y[0], markers))))
19
+ stopMarkers = dict(map(lambda x: (x[1], x[0]),
20
+ enumerate(map(lambda y: y[1], markers))))
21
+ idx = -1
22
+ substrate = ''
23
+ certLines = []
24
+ state = stSpam
25
+ while True:
26
+ certLine = fileObj.readline()
27
+ if not certLine:
28
+ break
29
+ certLine = certLine.strip()
30
+ if state == stSpam:
31
+ if certLine in startMarkers:
32
+ certLines = []
33
+ idx = startMarkers[certLine]
34
+ state = stHam
35
+ continue
36
+ if state == stHam:
37
+ if certLine in stopMarkers and stopMarkers[certLine] == idx:
38
+ state = stDump
39
+ else:
40
+ certLines.append(certLine)
41
+ if state == stDump:
42
+ if sys.version_info[0] <= 2:
43
+ substrate = ''.join([base64.b64decode(x) for x in certLines])
44
+ else:
45
+ substrate = ''.encode().join([base64.b64decode(x.encode()) for x in certLines])
46
+ break
47
+ return idx, substrate
48
+
49
+
50
+ # Backward compatibility routine
51
+ def readPemFromFile(fileObj,
52
+ startMarker='-----BEGIN CERTIFICATE-----',
53
+ endMarker='-----END CERTIFICATE-----'):
54
+ idx, substrate = readPemBlocksFromFile(fileObj, (startMarker, endMarker))
55
+ return substrate
56
+
57
+
58
+ def readBase64fromText(text):
59
+ if sys.version_info[0] <= 2:
60
+ return base64.b64decode(text)
61
+ else:
62
+ return base64.b64decode(text.encode())
63
+
64
+
65
+ def readBase64FromFile(fileObj):
66
+ return readBase64fromText(fileObj.read())
@@ -0,0 +1,97 @@
1
+ #
2
+ # This file is part of pyasn1-alt-modules software.
3
+ #
4
+ # Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
5
+ # Copyright (c) 2021-2024, Vigil Security, LLC
6
+ # License: http://vigilsec.com/pyasn1-alt-modules-license.txt
7
+ #
8
+ # SNMPv1 message syntax
9
+ #
10
+ # ASN.1 source from:
11
+ # http://www.ietf.org/rfc/rfc1155.txt
12
+ #
13
+ # Sample captures from:
14
+ # http://wiki.wireshark.org/SampleCaptures/
15
+ #
16
+ from pyasn1.type import constraint
17
+ from pyasn1.type import namedtype
18
+ from pyasn1.type import tag
19
+ from pyasn1.type import univ
20
+
21
+
22
+ class ObjectName(univ.ObjectIdentifier):
23
+ pass
24
+
25
+
26
+ class SimpleSyntax(univ.Choice):
27
+ componentType = namedtype.NamedTypes(
28
+ namedtype.NamedType('number', univ.Integer()),
29
+ namedtype.NamedType('string', univ.OctetString()),
30
+ namedtype.NamedType('object', univ.ObjectIdentifier()),
31
+ namedtype.NamedType('empty', univ.Null())
32
+ )
33
+
34
+
35
+ class IpAddress(univ.OctetString):
36
+ tagSet = univ.OctetString.tagSet.tagImplicitly(
37
+ tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0)
38
+ )
39
+ subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueSizeConstraint(
40
+ 4, 4
41
+ )
42
+
43
+
44
+ class NetworkAddress(univ.Choice):
45
+ componentType = namedtype.NamedTypes(
46
+ namedtype.NamedType('internet', IpAddress())
47
+ )
48
+
49
+
50
+ class Counter(univ.Integer):
51
+ tagSet = univ.Integer.tagSet.tagImplicitly(
52
+ tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 1)
53
+ )
54
+ subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint(
55
+ 0, 4294967295
56
+ )
57
+
58
+
59
+ class Gauge(univ.Integer):
60
+ tagSet = univ.Integer.tagSet.tagImplicitly(
61
+ tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 2)
62
+ )
63
+ subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint(
64
+ 0, 4294967295
65
+ )
66
+
67
+
68
+ class TimeTicks(univ.Integer):
69
+ tagSet = univ.Integer.tagSet.tagImplicitly(
70
+ tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 3)
71
+ )
72
+ subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint(
73
+ 0, 4294967295
74
+ )
75
+
76
+
77
+ class Opaque(univ.OctetString):
78
+ tagSet = univ.OctetString.tagSet.tagImplicitly(
79
+ tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 4)
80
+ )
81
+
82
+
83
+ class ApplicationSyntax(univ.Choice):
84
+ componentType = namedtype.NamedTypes(
85
+ namedtype.NamedType('address', NetworkAddress()),
86
+ namedtype.NamedType('counter', Counter()),
87
+ namedtype.NamedType('gauge', Gauge()),
88
+ namedtype.NamedType('ticks', TimeTicks()),
89
+ namedtype.NamedType('arbitrary', Opaque())
90
+ )
91
+
92
+
93
+ class ObjectSyntax(univ.Choice):
94
+ componentType = namedtype.NamedTypes(
95
+ namedtype.NamedType('simple', SimpleSyntax()),
96
+ namedtype.NamedType('application-wide', ApplicationSyntax())
97
+ )
@@ -0,0 +1,127 @@
1
+ #
2
+ # This file is part of pyasn1-alt-modules software.
3
+ #
4
+ # Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
5
+ # Copyright (c) 2021-2024, Vigil Security, LLC
6
+ # License: http://vigilsec.com/pyasn1-alt-modules-license.txt
7
+ #
8
+ # SNMPv1 message syntax
9
+ #
10
+ # ASN.1 source from:
11
+ # http://www.ietf.org/rfc/rfc1157.txt
12
+ #
13
+ # Sample captures from:
14
+ # http://wiki.wireshark.org/SampleCaptures/
15
+ #
16
+ from pyasn1.type import namedtype
17
+ from pyasn1.type import namedval
18
+ from pyasn1.type import tag
19
+ from pyasn1.type import univ
20
+
21
+ from pyasn1_alt_modules import rfc1155
22
+
23
+
24
+ class Version(univ.Integer):
25
+ namedValues = namedval.NamedValues(
26
+ ('version-1', 0)
27
+ )
28
+ defaultValue = 0
29
+
30
+
31
+ class Community(univ.OctetString):
32
+ pass
33
+
34
+
35
+ class RequestID(univ.Integer):
36
+ pass
37
+
38
+
39
+ class ErrorStatus(univ.Integer):
40
+ namedValues = namedval.NamedValues(
41
+ ('noError', 0),
42
+ ('tooBig', 1),
43
+ ('noSuchName', 2),
44
+ ('badValue', 3),
45
+ ('readOnly', 4),
46
+ ('genErr', 5)
47
+ )
48
+
49
+
50
+ class ErrorIndex(univ.Integer):
51
+ pass
52
+
53
+
54
+ class VarBind(univ.Sequence):
55
+ componentType = namedtype.NamedTypes(
56
+ namedtype.NamedType('name', rfc1155.ObjectName()),
57
+ namedtype.NamedType('value', rfc1155.ObjectSyntax())
58
+ )
59
+
60
+
61
+ class VarBindList(univ.SequenceOf):
62
+ componentType = VarBind()
63
+
64
+
65
+ class _RequestBase(univ.Sequence):
66
+ componentType = namedtype.NamedTypes(
67
+ namedtype.NamedType('request-id', RequestID()),
68
+ namedtype.NamedType('error-status', ErrorStatus()),
69
+ namedtype.NamedType('error-index', ErrorIndex()),
70
+ namedtype.NamedType('variable-bindings', VarBindList())
71
+ )
72
+
73
+
74
+ class GetRequestPDU(_RequestBase):
75
+ tagSet = _RequestBase.tagSet.tagImplicitly(
76
+ tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)
77
+ )
78
+
79
+
80
+ class GetNextRequestPDU(_RequestBase):
81
+ tagSet = _RequestBase.tagSet.tagImplicitly(
82
+ tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1)
83
+ )
84
+
85
+
86
+ class GetResponsePDU(_RequestBase):
87
+ tagSet = _RequestBase.tagSet.tagImplicitly(
88
+ tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2)
89
+ )
90
+
91
+
92
+ class SetRequestPDU(_RequestBase):
93
+ tagSet = _RequestBase.tagSet.tagImplicitly(
94
+ tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3)
95
+ )
96
+
97
+
98
+ class TrapPDU(univ.Sequence):
99
+ componentType = namedtype.NamedTypes(
100
+ namedtype.NamedType('enterprise', univ.ObjectIdentifier()),
101
+ namedtype.NamedType('agent-addr', rfc1155.NetworkAddress()),
102
+ namedtype.NamedType('generic-trap', univ.Integer().clone(
103
+ namedValues=namedval.NamedValues(('coldStart', 0), ('warmStart', 1), ('linkDown', 2), ('linkUp', 3),
104
+ ('authenticationFailure', 4), ('egpNeighborLoss', 5),
105
+ ('enterpriseSpecific', 6)))),
106
+ namedtype.NamedType('specific-trap', univ.Integer()),
107
+ namedtype.NamedType('time-stamp', rfc1155.TimeTicks()),
108
+ namedtype.NamedType('variable-bindings', VarBindList())
109
+ )
110
+
111
+
112
+ class Pdus(univ.Choice):
113
+ componentType = namedtype.NamedTypes(
114
+ namedtype.NamedType('get-request', GetRequestPDU()),
115
+ namedtype.NamedType('get-next-request', GetNextRequestPDU()),
116
+ namedtype.NamedType('get-response', GetResponsePDU()),
117
+ namedtype.NamedType('set-request', SetRequestPDU()),
118
+ namedtype.NamedType('trap', TrapPDU())
119
+ )
120
+
121
+
122
+ class Message(univ.Sequence):
123
+ componentType = namedtype.NamedTypes(
124
+ namedtype.NamedType('version', Version()),
125
+ namedtype.NamedType('community', Community()),
126
+ namedtype.NamedType('data', Pdus())
127
+ )
@@ -0,0 +1,23 @@
1
+ #
2
+ # This file is part of pyasn1-alt-modules software.
3
+ #
4
+ # Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
5
+ # Copyright (c) 2021-2024, Vigil Security, LLC
6
+ # License: http://vigilsec.com/pyasn1-alt-modules-license.txt
7
+ #
8
+ # SNMPv2c message syntax
9
+ #
10
+ # ASN.1 source from:
11
+ # http://www.ietf.org/rfc/rfc1901.txt
12
+ #
13
+ from pyasn1.type import namedtype
14
+ from pyasn1.type import namedval
15
+ from pyasn1.type import univ
16
+
17
+
18
+ class Message(univ.Sequence):
19
+ componentType = namedtype.NamedTypes(
20
+ namedtype.NamedType('version', univ.Integer(namedValues=namedval.NamedValues(('version-2c', 1)))),
21
+ namedtype.NamedType('community', univ.OctetString()),
22
+ namedtype.NamedType('data', univ.Any())
23
+ )
@@ -0,0 +1,130 @@
1
+ #
2
+ # This file is part of pyasn1-alt-modules software.
3
+ #
4
+ # Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
5
+ # Copyright (c) 2021-2024, Vigil Security, LLC
6
+ # License: http://vigilsec.com/pyasn1-alt-modules-license.txt
7
+ #
8
+ # SNMPv2c message syntax
9
+ #
10
+ # ASN.1 source from:
11
+ # http://www.ietf.org/rfc/rfc1902.txt
12
+ #
13
+ from pyasn1.type import constraint
14
+ from pyasn1.type import namedtype
15
+ from pyasn1.type import tag
16
+ from pyasn1.type import univ
17
+
18
+
19
+ class Integer(univ.Integer):
20
+ subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint(
21
+ -2147483648, 2147483647
22
+ )
23
+
24
+
25
+ class Integer32(univ.Integer):
26
+ subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint(
27
+ -2147483648, 2147483647
28
+ )
29
+
30
+
31
+ class OctetString(univ.OctetString):
32
+ subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueSizeConstraint(
33
+ 0, 65535
34
+ )
35
+
36
+
37
+ class IpAddress(univ.OctetString):
38
+ tagSet = univ.OctetString.tagSet.tagImplicitly(
39
+ tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x00)
40
+ )
41
+ subtypeSpec = univ.OctetString.subtypeSpec + constraint.ValueSizeConstraint(
42
+ 4, 4
43
+ )
44
+
45
+
46
+ class Counter32(univ.Integer):
47
+ tagSet = univ.Integer.tagSet.tagImplicitly(
48
+ tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x01)
49
+ )
50
+ subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint(
51
+ 0, 4294967295
52
+ )
53
+
54
+
55
+ class Gauge32(univ.Integer):
56
+ tagSet = univ.Integer.tagSet.tagImplicitly(
57
+ tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x02)
58
+ )
59
+ subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint(
60
+ 0, 4294967295
61
+ )
62
+
63
+
64
+ class Unsigned32(univ.Integer):
65
+ tagSet = univ.Integer.tagSet.tagImplicitly(
66
+ tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x02)
67
+ )
68
+ subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint(
69
+ 0, 4294967295
70
+ )
71
+
72
+
73
+ class TimeTicks(univ.Integer):
74
+ tagSet = univ.Integer.tagSet.tagImplicitly(
75
+ tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x03)
76
+ )
77
+ subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint(
78
+ 0, 4294967295
79
+ )
80
+
81
+
82
+ class Opaque(univ.OctetString):
83
+ tagSet = univ.OctetString.tagSet.tagImplicitly(
84
+ tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x04)
85
+ )
86
+
87
+
88
+ class Counter64(univ.Integer):
89
+ tagSet = univ.Integer.tagSet.tagImplicitly(
90
+ tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x06)
91
+ )
92
+ subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint(
93
+ 0, 18446744073709551615
94
+ )
95
+
96
+
97
+ class Bits(univ.OctetString):
98
+ pass
99
+
100
+
101
+ class ObjectName(univ.ObjectIdentifier):
102
+ pass
103
+
104
+
105
+ class SimpleSyntax(univ.Choice):
106
+ componentType = namedtype.NamedTypes(
107
+ namedtype.NamedType('integer-value', Integer()),
108
+ namedtype.NamedType('string-value', OctetString()),
109
+ namedtype.NamedType('objectID-value', univ.ObjectIdentifier())
110
+ )
111
+
112
+
113
+ class ApplicationSyntax(univ.Choice):
114
+ componentType = namedtype.NamedTypes(
115
+ namedtype.NamedType('ipAddress-value', IpAddress()),
116
+ namedtype.NamedType('counter-value', Counter32()),
117
+ namedtype.NamedType('timeticks-value', TimeTicks()),
118
+ namedtype.NamedType('arbitrary-value', Opaque()),
119
+ namedtype.NamedType('big-counter-value', Counter64()),
120
+ # This conflicts with Counter32
121
+ # namedtype.NamedType('unsigned-integer-value', Unsigned32()),
122
+ namedtype.NamedType('gauge32-value', Gauge32())
123
+ ) # BITS misplaced?
124
+
125
+
126
+ class ObjectSyntax(univ.Choice):
127
+ componentType = namedtype.NamedTypes(
128
+ namedtype.NamedType('simple', SimpleSyntax()),
129
+ namedtype.NamedType('application-wide', ApplicationSyntax())
130
+ )
@@ -0,0 +1,136 @@
1
+ #
2
+ # This file is part of pyasn1-alt-modules software.
3
+ #
4
+ # Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
5
+ # Copyright (c) 2021-2024, Vigil Security, LLC
6
+ # License: http://vigilsec.com/pyasn1-alt-modules-license.txt
7
+ #
8
+ # SNMPv2c PDU syntax
9
+ #
10
+ # ASN.1 source from:
11
+ # http://www.ietf.org/rfc/rfc1905.txt
12
+ #
13
+ from pyasn1.type import constraint
14
+ from pyasn1.type import namedtype
15
+ from pyasn1.type import namedval
16
+ from pyasn1.type import tag
17
+ from pyasn1.type import univ
18
+
19
+ from pyasn1_alt_modules import rfc1902
20
+
21
+ max_bindings = rfc1902.Integer(2147483647)
22
+
23
+
24
+ class _BindValue(univ.Choice):
25
+ componentType = namedtype.NamedTypes(
26
+ namedtype.NamedType('value', rfc1902.ObjectSyntax()),
27
+ namedtype.NamedType('unSpecified', univ.Null()),
28
+ namedtype.NamedType('noSuchObject',
29
+ univ.Null().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
30
+ namedtype.NamedType('noSuchInstance',
31
+ univ.Null().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
32
+ namedtype.NamedType('endOfMibView',
33
+ univ.Null().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
34
+ )
35
+
36
+
37
+ class VarBind(univ.Sequence):
38
+ componentType = namedtype.NamedTypes(
39
+ namedtype.NamedType('name', rfc1902.ObjectName()),
40
+ namedtype.NamedType('', _BindValue())
41
+ )
42
+
43
+
44
+ class VarBindList(univ.SequenceOf):
45
+ componentType = VarBind()
46
+ sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(
47
+ 0, max_bindings
48
+ )
49
+
50
+
51
+ class PDU(univ.Sequence):
52
+ componentType = namedtype.NamedTypes(
53
+ namedtype.NamedType('request-id', rfc1902.Integer32()),
54
+ namedtype.NamedType('error-status', univ.Integer(
55
+ namedValues=namedval.NamedValues(('noError', 0), ('tooBig', 1), ('noSuchName', 2), ('badValue', 3),
56
+ ('readOnly', 4), ('genErr', 5), ('noAccess', 6), ('wrongType', 7),
57
+ ('wrongLength', 8), ('wrongEncoding', 9), ('wrongValue', 10),
58
+ ('noCreation', 11), ('inconsistentValue', 12), ('resourceUnavailable', 13),
59
+ ('commitFailed', 14), ('undoFailed', 15), ('authorizationError', 16),
60
+ ('notWritable', 17), ('inconsistentName', 18)))),
61
+ namedtype.NamedType('error-index',
62
+ univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, max_bindings))),
63
+ namedtype.NamedType('variable-bindings', VarBindList())
64
+ )
65
+
66
+
67
+ class BulkPDU(univ.Sequence):
68
+ componentType = namedtype.NamedTypes(
69
+ namedtype.NamedType('request-id', rfc1902.Integer32()),
70
+ namedtype.NamedType('non-repeaters',
71
+ univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, max_bindings))),
72
+ namedtype.NamedType('max-repetitions',
73
+ univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, max_bindings))),
74
+ namedtype.NamedType('variable-bindings', VarBindList())
75
+ )
76
+
77
+
78
+ class GetRequestPDU(PDU):
79
+ tagSet = PDU.tagSet.tagImplicitly(
80
+ tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)
81
+ )
82
+
83
+
84
+ class GetNextRequestPDU(PDU):
85
+ tagSet = PDU.tagSet.tagImplicitly(
86
+ tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1)
87
+ )
88
+
89
+
90
+ class ResponsePDU(PDU):
91
+ tagSet = PDU.tagSet.tagImplicitly(
92
+ tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2)
93
+ )
94
+
95
+
96
+ class SetRequestPDU(PDU):
97
+ tagSet = PDU.tagSet.tagImplicitly(
98
+ tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3)
99
+ )
100
+
101
+
102
+ class GetBulkRequestPDU(BulkPDU):
103
+ tagSet = PDU.tagSet.tagImplicitly(
104
+ tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 5)
105
+ )
106
+
107
+
108
+ class InformRequestPDU(PDU):
109
+ tagSet = PDU.tagSet.tagImplicitly(
110
+ tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 6)
111
+ )
112
+
113
+
114
+ class SNMPv2TrapPDU(PDU):
115
+ tagSet = PDU.tagSet.tagImplicitly(
116
+ tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 7)
117
+ )
118
+
119
+
120
+ class ReportPDU(PDU):
121
+ tagSet = PDU.tagSet.tagImplicitly(
122
+ tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 8)
123
+ )
124
+
125
+
126
+ class PDUs(univ.Choice):
127
+ componentType = namedtype.NamedTypes(
128
+ namedtype.NamedType('get-request', GetRequestPDU()),
129
+ namedtype.NamedType('get-next-request', GetNextRequestPDU()),
130
+ namedtype.NamedType('get-bulk-request', GetBulkRequestPDU()),
131
+ namedtype.NamedType('response', ResponsePDU()),
132
+ namedtype.NamedType('set-request', SetRequestPDU()),
133
+ namedtype.NamedType('inform-request', InformRequestPDU()),
134
+ namedtype.NamedType('snmpV2-trap', SNMPv2TrapPDU()),
135
+ namedtype.NamedType('report', ReportPDU())
136
+ )
@@ -0,0 +1,50 @@
1
+ #
2
+ # This file is part of pyasn1-alt-modules software.
3
+ #
4
+ # Created by Russ Housley.
5
+ # Modified by Russ Housley to include the opentypemap manager and
6
+ # update the S/MIME Capability map.
7
+ #
8
+ # Copyright (c) 2021-2024, Vigil Security, LLC
9
+ # License: http://vigilsec.com/pyasn1-alt-modules-license.txt
10
+ #
11
+ # Identifiers for RC5
12
+ #
13
+ # ASN.1 source from:
14
+ # https://www.rfc-editor.org/rfc/rfc2040.txt
15
+ # https://www.rfc-editor.org/rfc/rfc8018.txt
16
+ #
17
+
18
+ from pyasn1_alt_modules import rfc5280
19
+ from pyasn1_alt_modules import rfc8018
20
+ from pyasn1_alt_modules import opentypemap
21
+
22
+ algorithmIdentifierMap = opentypemap.get('algorithmIdentifierMap')
23
+
24
+ smimeCapabilityMap = opentypemap.get('smimeCapabilityMap')
25
+
26
+
27
+ # The same RC5 object identifiers are defined in RFC 8018
28
+
29
+ encryptionAlgorithm = rfc8018.encryptionAlgorithm
30
+
31
+ rc5_CBC = encryptionAlgorithm + (8, )
32
+
33
+ rc5_CBC_PAD = rfc8018.rc5_CBC_PAD
34
+
35
+
36
+ # The RC5 CBC parameters are defined in RFC 8018
37
+
38
+ RC5_CBC_Parameters = rfc8018.RC5_CBC_Parameters
39
+
40
+
41
+ # Update the Algorithm Identifier Map and the S/MIME Capability Map
42
+ # for the one not already handled by importing rfc8018.
43
+
44
+ _algorithmIdentifierMapUpdate = {
45
+ rc5_CBC: RC5_CBC_Parameters(),
46
+ }
47
+
48
+ algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate)
49
+
50
+ smimeCapabilityMap.update(_algorithmIdentifierMapUpdate)