Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- bertvenv/lib/python3.10/site-packages/h2/__pycache__/config.cpython-310.pyc +0 -0
- bertvenv/lib/python3.10/site-packages/h2/__pycache__/connection.cpython-310.pyc +0 -0
- bertvenv/lib/python3.10/site-packages/h2/__pycache__/errors.cpython-310.pyc +0 -0
- bertvenv/lib/python3.10/site-packages/h2/__pycache__/events.cpython-310.pyc +0 -0
- bertvenv/lib/python3.10/site-packages/h2/__pycache__/settings.cpython-310.pyc +0 -0
- bertvenv/lib/python3.10/site-packages/h2/__pycache__/stream.cpython-310.pyc +0 -0
- bertvenv/lib/python3.10/site-packages/h2/__pycache__/utilities.cpython-310.pyc +0 -0
- bertvenv/lib/python3.10/site-packages/h2/__pycache__/windows.cpython-310.pyc +0 -0
- bertvenv/lib/python3.10/site-packages/h2/config.py +212 -0
- bertvenv/lib/python3.10/site-packages/h2/connection.py +2110 -0
- bertvenv/lib/python3.10/site-packages/h2/events.py +679 -0
- bertvenv/lib/python3.10/site-packages/h2/windows.py +133 -0
- bertvenv/lib/python3.10/site-packages/multiprocess/tests/__init__.py +0 -0
- bertvenv/lib/python3.10/site-packages/packaging-25.0.dist-info/INSTALLER +1 -0
- bertvenv/lib/python3.10/site-packages/packaging-25.0.dist-info/METADATA +105 -0
- bertvenv/lib/python3.10/site-packages/packaging-25.0.dist-info/RECORD +40 -0
- bertvenv/lib/python3.10/site-packages/packaging-25.0.dist-info/WHEEL +4 -0
- bertvenv/lib/python3.10/site-packages/packaging-25.0.dist-info/licenses/LICENSE +3 -0
- bertvenv/lib/python3.10/site-packages/packaging-25.0.dist-info/licenses/LICENSE.APACHE +177 -0
- bertvenv/lib/python3.10/site-packages/packaging-25.0.dist-info/licenses/LICENSE.BSD +23 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/__init__.py +2 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/pem.py +58 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc1157.py +126 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc1901.py +22 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc1905.py +135 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc2314.py +48 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc2315.py +294 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc2437.py +69 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc2459.py +1339 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc2560.py +225 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc2631.py +37 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc2634.py +336 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc2876.py +56 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3114.py +77 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3279.py +260 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3280.py +1543 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3281.py +331 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3414.py +28 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3537.py +34 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3560.py +74 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3709.py +207 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3820.py +65 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3852.py +706 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc4043.py +43 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc4055.py +258 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc4108.py +350 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc4476.py +93 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc4490.py +113 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc4491.py +44 -0
- bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc4683.py +72 -0
bertvenv/lib/python3.10/site-packages/h2/__pycache__/config.cpython-310.pyc
ADDED
|
Binary file (8.85 kB). View file
|
|
|
bertvenv/lib/python3.10/site-packages/h2/__pycache__/connection.cpython-310.pyc
ADDED
|
Binary file (60.9 kB). View file
|
|
|
bertvenv/lib/python3.10/site-packages/h2/__pycache__/errors.cpython-310.pyc
ADDED
|
Binary file (1.53 kB). View file
|
|
|
bertvenv/lib/python3.10/site-packages/h2/__pycache__/events.cpython-310.pyc
ADDED
|
Binary file (20.4 kB). View file
|
|
|
bertvenv/lib/python3.10/site-packages/h2/__pycache__/settings.cpython-310.pyc
ADDED
|
Binary file (10.3 kB). View file
|
|
|
bertvenv/lib/python3.10/site-packages/h2/__pycache__/stream.cpython-310.pyc
ADDED
|
Binary file (36.4 kB). View file
|
|
|
bertvenv/lib/python3.10/site-packages/h2/__pycache__/utilities.cpython-310.pyc
ADDED
|
Binary file (18.2 kB). View file
|
|
|
bertvenv/lib/python3.10/site-packages/h2/__pycache__/windows.cpython-310.pyc
ADDED
|
Binary file (5.23 kB). View file
|
|
|
bertvenv/lib/python3.10/site-packages/h2/config.py
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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~~~~~~
|
| 4 |
+
|
| 5 |
+
Objects for controlling the configuration of the HTTP/2 stack.
|
| 6 |
+
"""
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import sys
|
| 10 |
+
from typing import Any
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class _BooleanConfigOption:
|
| 14 |
+
"""
|
| 15 |
+
Descriptor for handling a boolean config option. This will block
|
| 16 |
+
attempts to set boolean config options to non-bools.
|
| 17 |
+
"""
|
| 18 |
+
|
| 19 |
+
def __init__(self, name: str) -> None:
|
| 20 |
+
self.name = name
|
| 21 |
+
self.attr_name = f"_{self.name}"
|
| 22 |
+
|
| 23 |
+
def __get__(self, instance: Any, owner: Any) -> bool:
|
| 24 |
+
return getattr(instance, self.attr_name) # type: ignore
|
| 25 |
+
|
| 26 |
+
def __set__(self, instance: Any, value: bool) -> None:
|
| 27 |
+
if not isinstance(value, bool):
|
| 28 |
+
msg = f"{self.name} must be a bool"
|
| 29 |
+
raise ValueError(msg) # noqa: TRY004
|
| 30 |
+
setattr(instance, self.attr_name, value)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
class DummyLogger:
|
| 34 |
+
"""
|
| 35 |
+
A Logger object that does not actual logging, hence a DummyLogger.
|
| 36 |
+
|
| 37 |
+
For the class the log operation is merely a no-op. The intent is to avoid
|
| 38 |
+
conditionals being sprinkled throughout the h2 code for calls to
|
| 39 |
+
logging functions when no logger is passed into the corresponding object.
|
| 40 |
+
"""
|
| 41 |
+
|
| 42 |
+
def __init__(self, *vargs) -> None: # type: ignore
|
| 43 |
+
pass
|
| 44 |
+
|
| 45 |
+
def debug(self, *vargs, **kwargs) -> None: # type: ignore
|
| 46 |
+
"""
|
| 47 |
+
No-op logging. Only level needed for now.
|
| 48 |
+
"""
|
| 49 |
+
|
| 50 |
+
def trace(self, *vargs, **kwargs) -> None: # type: ignore
|
| 51 |
+
"""
|
| 52 |
+
No-op logging. Only level needed for now.
|
| 53 |
+
"""
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
class OutputLogger:
|
| 57 |
+
"""
|
| 58 |
+
A Logger object that prints to stderr or any other file-like object.
|
| 59 |
+
|
| 60 |
+
This class is provided for convenience and not part of the stable API.
|
| 61 |
+
|
| 62 |
+
:param file: A file-like object passed to the print function.
|
| 63 |
+
Defaults to ``sys.stderr``.
|
| 64 |
+
:param trace: Enables trace-level output. Defaults to ``False``.
|
| 65 |
+
"""
|
| 66 |
+
|
| 67 |
+
def __init__(self, file=None, trace_level=False) -> None: # type: ignore
|
| 68 |
+
super().__init__()
|
| 69 |
+
self.file = file or sys.stderr
|
| 70 |
+
self.trace_level = trace_level
|
| 71 |
+
|
| 72 |
+
def debug(self, fmtstr, *args) -> None: # type: ignore
|
| 73 |
+
print(f"h2 (debug): {fmtstr % args}", file=self.file)
|
| 74 |
+
|
| 75 |
+
def trace(self, fmtstr, *args) -> None: # type: ignore
|
| 76 |
+
if self.trace_level:
|
| 77 |
+
print(f"h2 (trace): {fmtstr % args}", file=self.file)
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
class H2Configuration:
|
| 81 |
+
"""
|
| 82 |
+
An object that controls the way a single HTTP/2 connection behaves.
|
| 83 |
+
|
| 84 |
+
This object allows the users to customize behaviour. In particular, it
|
| 85 |
+
allows users to enable or disable optional features, or to otherwise handle
|
| 86 |
+
various unusual behaviours.
|
| 87 |
+
|
| 88 |
+
This object has very little behaviour of its own: it mostly just ensures
|
| 89 |
+
that configuration is self-consistent.
|
| 90 |
+
|
| 91 |
+
:param client_side: Whether this object is to be used on the client side of
|
| 92 |
+
a connection, or on the server side. Affects the logic used by the
|
| 93 |
+
state machine, the default settings values, the allowable stream IDs,
|
| 94 |
+
and several other properties. Defaults to ``True``.
|
| 95 |
+
:type client_side: ``bool``
|
| 96 |
+
|
| 97 |
+
:param header_encoding: Controls whether the headers emitted by this object
|
| 98 |
+
in events are transparently decoded to ``unicode`` strings, and what
|
| 99 |
+
encoding is used to do that decoding. This defaults to ``None``,
|
| 100 |
+
meaning that headers will be returned as bytes. To automatically
|
| 101 |
+
decode headers (that is, to return them as unicode strings), this can
|
| 102 |
+
be set to the string name of any encoding, e.g. ``'utf-8'``.
|
| 103 |
+
|
| 104 |
+
.. versionchanged:: 3.0.0
|
| 105 |
+
Changed default value from ``'utf-8'`` to ``None``
|
| 106 |
+
|
| 107 |
+
:type header_encoding: ``str``, ``False``, or ``None``
|
| 108 |
+
|
| 109 |
+
:param validate_outbound_headers: Controls whether the headers emitted
|
| 110 |
+
by this object are validated against the rules in RFC 7540.
|
| 111 |
+
Disabling this setting will cause outbound header validation to
|
| 112 |
+
be skipped, and allow the object to emit headers that may be illegal
|
| 113 |
+
according to RFC 7540. Defaults to ``True``.
|
| 114 |
+
:type validate_outbound_headers: ``bool``
|
| 115 |
+
|
| 116 |
+
:param normalize_outbound_headers: Controls whether the headers emitted
|
| 117 |
+
by this object are normalized before sending. Disabling this setting
|
| 118 |
+
will cause outbound header normalization to be skipped, and allow
|
| 119 |
+
the object to emit headers that may be illegal according to
|
| 120 |
+
RFC 7540. Defaults to ``True``.
|
| 121 |
+
:type normalize_outbound_headers: ``bool``
|
| 122 |
+
|
| 123 |
+
:param split_outbound_cookies: Controls whether the outbound cookie
|
| 124 |
+
headers are split before sending or not. According to RFC 7540
|
| 125 |
+
- 8.1.2.5 the outbound header cookie headers may be split to improve
|
| 126 |
+
headers compression. Default is ``False``.
|
| 127 |
+
:type split_outbound_cookies: ``bool``
|
| 128 |
+
|
| 129 |
+
:param validate_inbound_headers: Controls whether the headers received
|
| 130 |
+
by this object are validated against the rules in RFC 7540.
|
| 131 |
+
Disabling this setting will cause inbound header validation to
|
| 132 |
+
be skipped, and allow the object to receive headers that may be illegal
|
| 133 |
+
according to RFC 7540. Defaults to ``True``.
|
| 134 |
+
:type validate_inbound_headers: ``bool``
|
| 135 |
+
|
| 136 |
+
:param normalize_inbound_headers: Controls whether the headers received by
|
| 137 |
+
this object are normalized according to the rules of RFC 7540.
|
| 138 |
+
Disabling this setting may lead to h2 emitting header blocks that
|
| 139 |
+
some RFCs forbid, e.g. with multiple cookie fields.
|
| 140 |
+
|
| 141 |
+
.. versionadded:: 3.0.0
|
| 142 |
+
|
| 143 |
+
:type normalize_inbound_headers: ``bool``
|
| 144 |
+
|
| 145 |
+
:param logger: A logger that conforms to the requirements for this module,
|
| 146 |
+
those being no I/O and no context switches, which is needed in order
|
| 147 |
+
to run in asynchronous operation.
|
| 148 |
+
|
| 149 |
+
.. versionadded:: 2.6.0
|
| 150 |
+
|
| 151 |
+
:type logger: ``logging.Logger``
|
| 152 |
+
"""
|
| 153 |
+
|
| 154 |
+
client_side = _BooleanConfigOption("client_side")
|
| 155 |
+
validate_outbound_headers = _BooleanConfigOption(
|
| 156 |
+
"validate_outbound_headers",
|
| 157 |
+
)
|
| 158 |
+
normalize_outbound_headers = _BooleanConfigOption(
|
| 159 |
+
"normalize_outbound_headers",
|
| 160 |
+
)
|
| 161 |
+
split_outbound_cookies = _BooleanConfigOption(
|
| 162 |
+
"split_outbound_cookies",
|
| 163 |
+
)
|
| 164 |
+
validate_inbound_headers = _BooleanConfigOption(
|
| 165 |
+
"validate_inbound_headers",
|
| 166 |
+
)
|
| 167 |
+
normalize_inbound_headers = _BooleanConfigOption(
|
| 168 |
+
"normalize_inbound_headers",
|
| 169 |
+
)
|
| 170 |
+
|
| 171 |
+
def __init__(self,
|
| 172 |
+
client_side: bool = True,
|
| 173 |
+
header_encoding: bool | str | None = None,
|
| 174 |
+
validate_outbound_headers: bool = True,
|
| 175 |
+
normalize_outbound_headers: bool = True,
|
| 176 |
+
split_outbound_cookies: bool = False,
|
| 177 |
+
validate_inbound_headers: bool = True,
|
| 178 |
+
normalize_inbound_headers: bool = True,
|
| 179 |
+
logger: DummyLogger | OutputLogger | None = None) -> None:
|
| 180 |
+
self.client_side = client_side
|
| 181 |
+
self.header_encoding = header_encoding
|
| 182 |
+
self.validate_outbound_headers = validate_outbound_headers
|
| 183 |
+
self.normalize_outbound_headers = normalize_outbound_headers
|
| 184 |
+
self.split_outbound_cookies = split_outbound_cookies
|
| 185 |
+
self.validate_inbound_headers = validate_inbound_headers
|
| 186 |
+
self.normalize_inbound_headers = normalize_inbound_headers
|
| 187 |
+
self.logger = logger or DummyLogger(__name__)
|
| 188 |
+
|
| 189 |
+
@property
|
| 190 |
+
def header_encoding(self) -> bool | str | None:
|
| 191 |
+
"""
|
| 192 |
+
Controls whether the headers emitted by this object in events are
|
| 193 |
+
transparently decoded to ``unicode`` strings, and what encoding is used
|
| 194 |
+
to do that decoding. This defaults to ``None``, meaning that headers
|
| 195 |
+
will be returned as bytes. To automatically decode headers (that is, to
|
| 196 |
+
return them as unicode strings), this can be set to the string name of
|
| 197 |
+
any encoding, e.g. ``'utf-8'``.
|
| 198 |
+
"""
|
| 199 |
+
return self._header_encoding
|
| 200 |
+
|
| 201 |
+
@header_encoding.setter
|
| 202 |
+
def header_encoding(self, value: bool | str | None) -> None:
|
| 203 |
+
"""
|
| 204 |
+
Enforces constraints on the value of header encoding.
|
| 205 |
+
"""
|
| 206 |
+
if not isinstance(value, (bool, str, type(None))):
|
| 207 |
+
msg = "header_encoding must be bool, string, or None"
|
| 208 |
+
raise ValueError(msg) # noqa: TRY004
|
| 209 |
+
if value is True:
|
| 210 |
+
msg = "header_encoding cannot be True"
|
| 211 |
+
raise ValueError(msg)
|
| 212 |
+
self._header_encoding = value
|
bertvenv/lib/python3.10/site-packages/h2/connection.py
ADDED
|
@@ -0,0 +1,2110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
h2/connection
|
| 3 |
+
~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
An implementation of a HTTP/2 connection.
|
| 6 |
+
"""
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import base64
|
| 10 |
+
from enum import Enum, IntEnum
|
| 11 |
+
from typing import TYPE_CHECKING, Any, Callable
|
| 12 |
+
|
| 13 |
+
from hpack.exceptions import HPACKError, OversizedHeaderListError
|
| 14 |
+
from hpack.hpack import Decoder, Encoder
|
| 15 |
+
from hyperframe.exceptions import InvalidPaddingError
|
| 16 |
+
from hyperframe.frame import (
|
| 17 |
+
AltSvcFrame,
|
| 18 |
+
ContinuationFrame,
|
| 19 |
+
DataFrame,
|
| 20 |
+
ExtensionFrame,
|
| 21 |
+
Frame,
|
| 22 |
+
GoAwayFrame,
|
| 23 |
+
HeadersFrame,
|
| 24 |
+
PingFrame,
|
| 25 |
+
PriorityFrame,
|
| 26 |
+
PushPromiseFrame,
|
| 27 |
+
RstStreamFrame,
|
| 28 |
+
SettingsFrame,
|
| 29 |
+
WindowUpdateFrame,
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
from .config import H2Configuration
|
| 33 |
+
from .errors import ErrorCodes, _error_code_from_int
|
| 34 |
+
from .events import (
|
| 35 |
+
AlternativeServiceAvailable,
|
| 36 |
+
ConnectionTerminated,
|
| 37 |
+
Event,
|
| 38 |
+
InformationalResponseReceived,
|
| 39 |
+
PingAckReceived,
|
| 40 |
+
PingReceived,
|
| 41 |
+
PriorityUpdated,
|
| 42 |
+
RemoteSettingsChanged,
|
| 43 |
+
RequestReceived,
|
| 44 |
+
ResponseReceived,
|
| 45 |
+
SettingsAcknowledged,
|
| 46 |
+
TrailersReceived,
|
| 47 |
+
UnknownFrameReceived,
|
| 48 |
+
WindowUpdated,
|
| 49 |
+
)
|
| 50 |
+
from .exceptions import (
|
| 51 |
+
DenialOfServiceError,
|
| 52 |
+
FlowControlError,
|
| 53 |
+
FrameTooLargeError,
|
| 54 |
+
NoAvailableStreamIDError,
|
| 55 |
+
NoSuchStreamError,
|
| 56 |
+
ProtocolError,
|
| 57 |
+
RFC1122Error,
|
| 58 |
+
StreamClosedError,
|
| 59 |
+
StreamIDTooLowError,
|
| 60 |
+
TooManyStreamsError,
|
| 61 |
+
)
|
| 62 |
+
from .frame_buffer import FrameBuffer
|
| 63 |
+
from .settings import ChangedSetting, SettingCodes, Settings
|
| 64 |
+
from .stream import H2Stream, StreamClosedBy
|
| 65 |
+
from .utilities import SizeLimitDict, guard_increment_window
|
| 66 |
+
from .windows import WindowManager
|
| 67 |
+
|
| 68 |
+
if TYPE_CHECKING: # pragma: no cover
|
| 69 |
+
from collections.abc import Iterable
|
| 70 |
+
|
| 71 |
+
from hpack.struct import Header, HeaderWeaklyTyped
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
class ConnectionState(Enum):
|
| 75 |
+
IDLE = 0
|
| 76 |
+
CLIENT_OPEN = 1
|
| 77 |
+
SERVER_OPEN = 2
|
| 78 |
+
CLOSED = 3
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
class ConnectionInputs(Enum):
|
| 82 |
+
SEND_HEADERS = 0
|
| 83 |
+
SEND_PUSH_PROMISE = 1
|
| 84 |
+
SEND_DATA = 2
|
| 85 |
+
SEND_GOAWAY = 3
|
| 86 |
+
SEND_WINDOW_UPDATE = 4
|
| 87 |
+
SEND_PING = 5
|
| 88 |
+
SEND_SETTINGS = 6
|
| 89 |
+
SEND_RST_STREAM = 7
|
| 90 |
+
SEND_PRIORITY = 8
|
| 91 |
+
RECV_HEADERS = 9
|
| 92 |
+
RECV_PUSH_PROMISE = 10
|
| 93 |
+
RECV_DATA = 11
|
| 94 |
+
RECV_GOAWAY = 12
|
| 95 |
+
RECV_WINDOW_UPDATE = 13
|
| 96 |
+
RECV_PING = 14
|
| 97 |
+
RECV_SETTINGS = 15
|
| 98 |
+
RECV_RST_STREAM = 16
|
| 99 |
+
RECV_PRIORITY = 17
|
| 100 |
+
SEND_ALTERNATIVE_SERVICE = 18 # Added in 2.3.0
|
| 101 |
+
RECV_ALTERNATIVE_SERVICE = 19 # Added in 2.3.0
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
class AllowedStreamIDs(IntEnum):
|
| 105 |
+
EVEN = 0
|
| 106 |
+
ODD = 1
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
class H2ConnectionStateMachine:
|
| 110 |
+
"""
|
| 111 |
+
A single HTTP/2 connection state machine.
|
| 112 |
+
|
| 113 |
+
This state machine, while defined in its own class, is logically part of
|
| 114 |
+
the H2Connection class also defined in this file. The state machine itself
|
| 115 |
+
maintains very little state directly, instead focusing entirely on managing
|
| 116 |
+
state transitions.
|
| 117 |
+
"""
|
| 118 |
+
|
| 119 |
+
# For the purposes of this state machine we treat HEADERS and their
|
| 120 |
+
# associated CONTINUATION frames as a single jumbo frame. The protocol
|
| 121 |
+
# allows/requires this by preventing other frames from being interleved in
|
| 122 |
+
# between HEADERS/CONTINUATION frames.
|
| 123 |
+
#
|
| 124 |
+
# The _transitions dictionary contains a mapping of tuples of
|
| 125 |
+
# (state, input) to tuples of (side_effect_function, end_state). This map
|
| 126 |
+
# contains all allowed transitions: anything not in this map is invalid
|
| 127 |
+
# and immediately causes a transition to ``closed``.
|
| 128 |
+
|
| 129 |
+
_transitions = {
|
| 130 |
+
# State: idle
|
| 131 |
+
(ConnectionState.IDLE, ConnectionInputs.SEND_HEADERS):
|
| 132 |
+
(None, ConnectionState.CLIENT_OPEN),
|
| 133 |
+
(ConnectionState.IDLE, ConnectionInputs.RECV_HEADERS):
|
| 134 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 135 |
+
(ConnectionState.IDLE, ConnectionInputs.SEND_SETTINGS):
|
| 136 |
+
(None, ConnectionState.IDLE),
|
| 137 |
+
(ConnectionState.IDLE, ConnectionInputs.RECV_SETTINGS):
|
| 138 |
+
(None, ConnectionState.IDLE),
|
| 139 |
+
(ConnectionState.IDLE, ConnectionInputs.SEND_WINDOW_UPDATE):
|
| 140 |
+
(None, ConnectionState.IDLE),
|
| 141 |
+
(ConnectionState.IDLE, ConnectionInputs.RECV_WINDOW_UPDATE):
|
| 142 |
+
(None, ConnectionState.IDLE),
|
| 143 |
+
(ConnectionState.IDLE, ConnectionInputs.SEND_PING):
|
| 144 |
+
(None, ConnectionState.IDLE),
|
| 145 |
+
(ConnectionState.IDLE, ConnectionInputs.RECV_PING):
|
| 146 |
+
(None, ConnectionState.IDLE),
|
| 147 |
+
(ConnectionState.IDLE, ConnectionInputs.SEND_GOAWAY):
|
| 148 |
+
(None, ConnectionState.CLOSED),
|
| 149 |
+
(ConnectionState.IDLE, ConnectionInputs.RECV_GOAWAY):
|
| 150 |
+
(None, ConnectionState.CLOSED),
|
| 151 |
+
(ConnectionState.IDLE, ConnectionInputs.SEND_PRIORITY):
|
| 152 |
+
(None, ConnectionState.IDLE),
|
| 153 |
+
(ConnectionState.IDLE, ConnectionInputs.RECV_PRIORITY):
|
| 154 |
+
(None, ConnectionState.IDLE),
|
| 155 |
+
(ConnectionState.IDLE, ConnectionInputs.SEND_ALTERNATIVE_SERVICE):
|
| 156 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 157 |
+
(ConnectionState.IDLE, ConnectionInputs.RECV_ALTERNATIVE_SERVICE):
|
| 158 |
+
(None, ConnectionState.CLIENT_OPEN),
|
| 159 |
+
|
| 160 |
+
# State: open, client side.
|
| 161 |
+
(ConnectionState.CLIENT_OPEN, ConnectionInputs.SEND_HEADERS):
|
| 162 |
+
(None, ConnectionState.CLIENT_OPEN),
|
| 163 |
+
(ConnectionState.CLIENT_OPEN, ConnectionInputs.SEND_DATA):
|
| 164 |
+
(None, ConnectionState.CLIENT_OPEN),
|
| 165 |
+
(ConnectionState.CLIENT_OPEN, ConnectionInputs.SEND_GOAWAY):
|
| 166 |
+
(None, ConnectionState.CLOSED),
|
| 167 |
+
(ConnectionState.CLIENT_OPEN, ConnectionInputs.SEND_WINDOW_UPDATE):
|
| 168 |
+
(None, ConnectionState.CLIENT_OPEN),
|
| 169 |
+
(ConnectionState.CLIENT_OPEN, ConnectionInputs.SEND_PING):
|
| 170 |
+
(None, ConnectionState.CLIENT_OPEN),
|
| 171 |
+
(ConnectionState.CLIENT_OPEN, ConnectionInputs.SEND_SETTINGS):
|
| 172 |
+
(None, ConnectionState.CLIENT_OPEN),
|
| 173 |
+
(ConnectionState.CLIENT_OPEN, ConnectionInputs.SEND_PRIORITY):
|
| 174 |
+
(None, ConnectionState.CLIENT_OPEN),
|
| 175 |
+
(ConnectionState.CLIENT_OPEN, ConnectionInputs.RECV_HEADERS):
|
| 176 |
+
(None, ConnectionState.CLIENT_OPEN),
|
| 177 |
+
(ConnectionState.CLIENT_OPEN, ConnectionInputs.RECV_PUSH_PROMISE):
|
| 178 |
+
(None, ConnectionState.CLIENT_OPEN),
|
| 179 |
+
(ConnectionState.CLIENT_OPEN, ConnectionInputs.RECV_DATA):
|
| 180 |
+
(None, ConnectionState.CLIENT_OPEN),
|
| 181 |
+
(ConnectionState.CLIENT_OPEN, ConnectionInputs.RECV_GOAWAY):
|
| 182 |
+
(None, ConnectionState.CLOSED),
|
| 183 |
+
(ConnectionState.CLIENT_OPEN, ConnectionInputs.RECV_WINDOW_UPDATE):
|
| 184 |
+
(None, ConnectionState.CLIENT_OPEN),
|
| 185 |
+
(ConnectionState.CLIENT_OPEN, ConnectionInputs.RECV_PING):
|
| 186 |
+
(None, ConnectionState.CLIENT_OPEN),
|
| 187 |
+
(ConnectionState.CLIENT_OPEN, ConnectionInputs.RECV_SETTINGS):
|
| 188 |
+
(None, ConnectionState.CLIENT_OPEN),
|
| 189 |
+
(ConnectionState.CLIENT_OPEN, ConnectionInputs.SEND_RST_STREAM):
|
| 190 |
+
(None, ConnectionState.CLIENT_OPEN),
|
| 191 |
+
(ConnectionState.CLIENT_OPEN, ConnectionInputs.RECV_RST_STREAM):
|
| 192 |
+
(None, ConnectionState.CLIENT_OPEN),
|
| 193 |
+
(ConnectionState.CLIENT_OPEN, ConnectionInputs.RECV_PRIORITY):
|
| 194 |
+
(None, ConnectionState.CLIENT_OPEN),
|
| 195 |
+
(ConnectionState.CLIENT_OPEN,
|
| 196 |
+
ConnectionInputs.RECV_ALTERNATIVE_SERVICE):
|
| 197 |
+
(None, ConnectionState.CLIENT_OPEN),
|
| 198 |
+
|
| 199 |
+
# State: open, server side.
|
| 200 |
+
(ConnectionState.SERVER_OPEN, ConnectionInputs.SEND_HEADERS):
|
| 201 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 202 |
+
(ConnectionState.SERVER_OPEN, ConnectionInputs.SEND_PUSH_PROMISE):
|
| 203 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 204 |
+
(ConnectionState.SERVER_OPEN, ConnectionInputs.SEND_DATA):
|
| 205 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 206 |
+
(ConnectionState.SERVER_OPEN, ConnectionInputs.SEND_GOAWAY):
|
| 207 |
+
(None, ConnectionState.CLOSED),
|
| 208 |
+
(ConnectionState.SERVER_OPEN, ConnectionInputs.SEND_WINDOW_UPDATE):
|
| 209 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 210 |
+
(ConnectionState.SERVER_OPEN, ConnectionInputs.SEND_PING):
|
| 211 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 212 |
+
(ConnectionState.SERVER_OPEN, ConnectionInputs.SEND_SETTINGS):
|
| 213 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 214 |
+
(ConnectionState.SERVER_OPEN, ConnectionInputs.SEND_PRIORITY):
|
| 215 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 216 |
+
(ConnectionState.SERVER_OPEN, ConnectionInputs.RECV_HEADERS):
|
| 217 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 218 |
+
(ConnectionState.SERVER_OPEN, ConnectionInputs.RECV_DATA):
|
| 219 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 220 |
+
(ConnectionState.SERVER_OPEN, ConnectionInputs.RECV_GOAWAY):
|
| 221 |
+
(None, ConnectionState.CLOSED),
|
| 222 |
+
(ConnectionState.SERVER_OPEN, ConnectionInputs.RECV_WINDOW_UPDATE):
|
| 223 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 224 |
+
(ConnectionState.SERVER_OPEN, ConnectionInputs.RECV_PING):
|
| 225 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 226 |
+
(ConnectionState.SERVER_OPEN, ConnectionInputs.RECV_SETTINGS):
|
| 227 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 228 |
+
(ConnectionState.SERVER_OPEN, ConnectionInputs.RECV_PRIORITY):
|
| 229 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 230 |
+
(ConnectionState.SERVER_OPEN, ConnectionInputs.SEND_RST_STREAM):
|
| 231 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 232 |
+
(ConnectionState.SERVER_OPEN, ConnectionInputs.RECV_RST_STREAM):
|
| 233 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 234 |
+
(ConnectionState.SERVER_OPEN,
|
| 235 |
+
ConnectionInputs.SEND_ALTERNATIVE_SERVICE):
|
| 236 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 237 |
+
(ConnectionState.SERVER_OPEN,
|
| 238 |
+
ConnectionInputs.RECV_ALTERNATIVE_SERVICE):
|
| 239 |
+
(None, ConnectionState.SERVER_OPEN),
|
| 240 |
+
|
| 241 |
+
# State: closed
|
| 242 |
+
(ConnectionState.CLOSED, ConnectionInputs.SEND_GOAWAY):
|
| 243 |
+
(None, ConnectionState.CLOSED),
|
| 244 |
+
(ConnectionState.CLOSED, ConnectionInputs.RECV_GOAWAY):
|
| 245 |
+
(None, ConnectionState.CLOSED),
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
def __init__(self) -> None:
|
| 249 |
+
self.state = ConnectionState.IDLE
|
| 250 |
+
|
| 251 |
+
def process_input(self, input_: ConnectionInputs) -> list[Event]:
|
| 252 |
+
"""
|
| 253 |
+
Process a specific input in the state machine.
|
| 254 |
+
"""
|
| 255 |
+
if not isinstance(input_, ConnectionInputs):
|
| 256 |
+
msg = "Input must be an instance of ConnectionInputs"
|
| 257 |
+
raise ValueError(msg) # noqa: TRY004
|
| 258 |
+
|
| 259 |
+
try:
|
| 260 |
+
func, target_state = self._transitions[(self.state, input_)]
|
| 261 |
+
except KeyError as e:
|
| 262 |
+
old_state = self.state
|
| 263 |
+
self.state = ConnectionState.CLOSED
|
| 264 |
+
msg = f"Invalid input {input_} in state {old_state}"
|
| 265 |
+
raise ProtocolError(msg) from e
|
| 266 |
+
else:
|
| 267 |
+
self.state = target_state
|
| 268 |
+
if func is not None: # pragma: no cover
|
| 269 |
+
return func()
|
| 270 |
+
|
| 271 |
+
return []
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
class H2Connection:
|
| 275 |
+
"""
|
| 276 |
+
A low-level HTTP/2 connection object. This handles building and receiving
|
| 277 |
+
frames and maintains both connection and per-stream state for all streams
|
| 278 |
+
on this connection.
|
| 279 |
+
|
| 280 |
+
This wraps a HTTP/2 Connection state machine implementation, ensuring that
|
| 281 |
+
frames can only be sent/received when the connection is in a valid state.
|
| 282 |
+
It also builds stream state machines on demand to ensure that the
|
| 283 |
+
constraints of those state machines are met as well. Attempts to create
|
| 284 |
+
frames that cannot be sent will raise a ``ProtocolError``.
|
| 285 |
+
|
| 286 |
+
.. versionchanged:: 2.3.0
|
| 287 |
+
Added the ``header_encoding`` keyword argument.
|
| 288 |
+
|
| 289 |
+
.. versionchanged:: 2.5.0
|
| 290 |
+
Added the ``config`` keyword argument. Deprecated the ``client_side``
|
| 291 |
+
and ``header_encoding`` parameters.
|
| 292 |
+
|
| 293 |
+
.. versionchanged:: 3.0.0
|
| 294 |
+
Removed deprecated parameters and properties.
|
| 295 |
+
|
| 296 |
+
:param config: The configuration for the HTTP/2 connection.
|
| 297 |
+
|
| 298 |
+
.. versionadded:: 2.5.0
|
| 299 |
+
|
| 300 |
+
:type config: :class:`H2Configuration <h2.config.H2Configuration>`
|
| 301 |
+
"""
|
| 302 |
+
|
| 303 |
+
# The initial maximum outbound frame size. This can be changed by receiving
|
| 304 |
+
# a settings frame.
|
| 305 |
+
DEFAULT_MAX_OUTBOUND_FRAME_SIZE = 65535
|
| 306 |
+
|
| 307 |
+
# The initial maximum inbound frame size. This is somewhat arbitrarily
|
| 308 |
+
# chosen.
|
| 309 |
+
DEFAULT_MAX_INBOUND_FRAME_SIZE = 2**24
|
| 310 |
+
|
| 311 |
+
# The highest acceptable stream ID.
|
| 312 |
+
HIGHEST_ALLOWED_STREAM_ID = 2**31 - 1
|
| 313 |
+
|
| 314 |
+
# The largest acceptable window increment.
|
| 315 |
+
MAX_WINDOW_INCREMENT = 2**31 - 1
|
| 316 |
+
|
| 317 |
+
# The initial default value of SETTINGS_MAX_HEADER_LIST_SIZE.
|
| 318 |
+
DEFAULT_MAX_HEADER_LIST_SIZE = 2**16
|
| 319 |
+
|
| 320 |
+
# Keep in memory limited amount of results for streams closes
|
| 321 |
+
MAX_CLOSED_STREAMS = 2**16
|
| 322 |
+
|
| 323 |
+
def __init__(self, config: H2Configuration | None = None) -> None:
|
| 324 |
+
self.state_machine = H2ConnectionStateMachine()
|
| 325 |
+
self.streams: dict[int, H2Stream] = {}
|
| 326 |
+
self.highest_inbound_stream_id = 0
|
| 327 |
+
self.highest_outbound_stream_id = 0
|
| 328 |
+
self.encoder = Encoder()
|
| 329 |
+
self.decoder = Decoder()
|
| 330 |
+
|
| 331 |
+
# This won't always actually do anything: for versions of HPACK older
|
| 332 |
+
# than 2.3.0 it does nothing. However, we have to try!
|
| 333 |
+
self.decoder.max_header_list_size = self.DEFAULT_MAX_HEADER_LIST_SIZE
|
| 334 |
+
|
| 335 |
+
#: The configuration for this HTTP/2 connection object.
|
| 336 |
+
#:
|
| 337 |
+
#: .. versionadded:: 2.5.0
|
| 338 |
+
self.config = config or H2Configuration(client_side=True)
|
| 339 |
+
|
| 340 |
+
# Objects that store settings, including defaults.
|
| 341 |
+
#
|
| 342 |
+
# We set the MAX_CONCURRENT_STREAMS value to 100 because its default is
|
| 343 |
+
# unbounded, and that's a dangerous default because it allows
|
| 344 |
+
# essentially unbounded resources to be allocated regardless of how
|
| 345 |
+
# they will be used. 100 should be suitable for the average
|
| 346 |
+
# application. This default obviously does not apply to the remote
|
| 347 |
+
# peer's settings: the remote peer controls them!
|
| 348 |
+
#
|
| 349 |
+
# We also set MAX_HEADER_LIST_SIZE to a reasonable value. This is to
|
| 350 |
+
# advertise our defence against CVE-2016-6581. However, not all
|
| 351 |
+
# versions of HPACK will let us do it. That's ok: we should at least
|
| 352 |
+
# suggest that we're not vulnerable.
|
| 353 |
+
self.local_settings = Settings(
|
| 354 |
+
client=self.config.client_side,
|
| 355 |
+
initial_values={
|
| 356 |
+
SettingCodes.MAX_CONCURRENT_STREAMS: 100,
|
| 357 |
+
SettingCodes.MAX_HEADER_LIST_SIZE:
|
| 358 |
+
self.DEFAULT_MAX_HEADER_LIST_SIZE,
|
| 359 |
+
},
|
| 360 |
+
)
|
| 361 |
+
self.remote_settings = Settings(client=not self.config.client_side)
|
| 362 |
+
|
| 363 |
+
# The current value of the connection flow control windows on the
|
| 364 |
+
# connection.
|
| 365 |
+
self.outbound_flow_control_window = (
|
| 366 |
+
self.remote_settings.initial_window_size
|
| 367 |
+
)
|
| 368 |
+
|
| 369 |
+
#: The maximum size of a frame that can be emitted by this peer, in
|
| 370 |
+
#: bytes.
|
| 371 |
+
self.max_outbound_frame_size = self.remote_settings.max_frame_size
|
| 372 |
+
|
| 373 |
+
#: The maximum size of a frame that can be received by this peer, in
|
| 374 |
+
#: bytes.
|
| 375 |
+
self.max_inbound_frame_size = self.local_settings.max_frame_size
|
| 376 |
+
|
| 377 |
+
# Buffer for incoming data.
|
| 378 |
+
self.incoming_buffer = FrameBuffer(server=not self.config.client_side)
|
| 379 |
+
|
| 380 |
+
# A private variable to store a sequence of received header frames
|
| 381 |
+
# until completion.
|
| 382 |
+
self._header_frames: list[Frame] = []
|
| 383 |
+
|
| 384 |
+
# Data that needs to be sent.
|
| 385 |
+
self._data_to_send = bytearray()
|
| 386 |
+
|
| 387 |
+
# Keeps track of how streams are closed.
|
| 388 |
+
# Used to ensure that we don't blow up in the face of frames that were
|
| 389 |
+
# in flight when a RST_STREAM was sent.
|
| 390 |
+
# Also used to determine whether we should consider a frame received
|
| 391 |
+
# while a stream is closed as either a stream error or a connection
|
| 392 |
+
# error.
|
| 393 |
+
self._closed_streams: dict[int, StreamClosedBy | None] = SizeLimitDict(
|
| 394 |
+
size_limit=self.MAX_CLOSED_STREAMS,
|
| 395 |
+
)
|
| 396 |
+
|
| 397 |
+
# The flow control window manager for the connection.
|
| 398 |
+
self._inbound_flow_control_window_manager = WindowManager(
|
| 399 |
+
max_window_size=self.local_settings.initial_window_size,
|
| 400 |
+
)
|
| 401 |
+
|
| 402 |
+
# When in doubt use dict-dispatch.
|
| 403 |
+
self._frame_dispatch_table: dict[type[Frame], Callable] = { # type: ignore
|
| 404 |
+
HeadersFrame: self._receive_headers_frame,
|
| 405 |
+
PushPromiseFrame: self._receive_push_promise_frame,
|
| 406 |
+
SettingsFrame: self._receive_settings_frame,
|
| 407 |
+
DataFrame: self._receive_data_frame,
|
| 408 |
+
WindowUpdateFrame: self._receive_window_update_frame,
|
| 409 |
+
PingFrame: self._receive_ping_frame,
|
| 410 |
+
RstStreamFrame: self._receive_rst_stream_frame,
|
| 411 |
+
PriorityFrame: self._receive_priority_frame,
|
| 412 |
+
GoAwayFrame: self._receive_goaway_frame,
|
| 413 |
+
ContinuationFrame: self._receive_naked_continuation,
|
| 414 |
+
AltSvcFrame: self._receive_alt_svc_frame,
|
| 415 |
+
ExtensionFrame: self._receive_unknown_frame,
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
def _prepare_for_sending(self, frames: list[Frame]) -> None:
|
| 419 |
+
if not frames:
|
| 420 |
+
return
|
| 421 |
+
self._data_to_send += b"".join(f.serialize() for f in frames)
|
| 422 |
+
assert all(f.body_len <= self.max_outbound_frame_size for f in frames)
|
| 423 |
+
|
| 424 |
+
def _open_streams(self, remainder: int) -> int:
|
| 425 |
+
"""
|
| 426 |
+
A common method of counting number of open streams. Returns the number
|
| 427 |
+
of streams that are open *and* that have (stream ID % 2) == remainder.
|
| 428 |
+
While it iterates, also deletes any closed streams.
|
| 429 |
+
"""
|
| 430 |
+
count = 0
|
| 431 |
+
to_delete = []
|
| 432 |
+
|
| 433 |
+
for stream_id, stream in self.streams.items():
|
| 434 |
+
if stream.open and (stream_id % 2 == remainder):
|
| 435 |
+
count += 1
|
| 436 |
+
elif stream.closed:
|
| 437 |
+
to_delete.append(stream_id)
|
| 438 |
+
|
| 439 |
+
for stream_id in to_delete:
|
| 440 |
+
stream = self.streams.pop(stream_id)
|
| 441 |
+
self._closed_streams[stream_id] = stream.closed_by
|
| 442 |
+
|
| 443 |
+
return count
|
| 444 |
+
|
| 445 |
+
@property
|
| 446 |
+
def open_outbound_streams(self) -> int:
|
| 447 |
+
"""
|
| 448 |
+
The current number of open outbound streams.
|
| 449 |
+
"""
|
| 450 |
+
outbound_numbers = int(self.config.client_side)
|
| 451 |
+
return self._open_streams(outbound_numbers)
|
| 452 |
+
|
| 453 |
+
@property
|
| 454 |
+
def open_inbound_streams(self) -> int:
|
| 455 |
+
"""
|
| 456 |
+
The current number of open inbound streams.
|
| 457 |
+
"""
|
| 458 |
+
inbound_numbers = int(not self.config.client_side)
|
| 459 |
+
return self._open_streams(inbound_numbers)
|
| 460 |
+
|
| 461 |
+
@property
|
| 462 |
+
def inbound_flow_control_window(self) -> int:
|
| 463 |
+
"""
|
| 464 |
+
The size of the inbound flow control window for the connection. This is
|
| 465 |
+
rarely publicly useful: instead, use :meth:`remote_flow_control_window
|
| 466 |
+
<h2.connection.H2Connection.remote_flow_control_window>`. This
|
| 467 |
+
shortcut is largely present to provide a shortcut to this data.
|
| 468 |
+
"""
|
| 469 |
+
return self._inbound_flow_control_window_manager.current_window_size
|
| 470 |
+
|
| 471 |
+
def _begin_new_stream(self, stream_id: int, allowed_ids: AllowedStreamIDs) -> H2Stream:
|
| 472 |
+
"""
|
| 473 |
+
Initiate a new stream.
|
| 474 |
+
|
| 475 |
+
.. versionchanged:: 2.0.0
|
| 476 |
+
Removed this function from the public API.
|
| 477 |
+
|
| 478 |
+
:param stream_id: The ID of the stream to open.
|
| 479 |
+
:param allowed_ids: What kind of stream ID is allowed.
|
| 480 |
+
"""
|
| 481 |
+
self.config.logger.debug(
|
| 482 |
+
"Attempting to initiate stream ID %d", stream_id,
|
| 483 |
+
)
|
| 484 |
+
outbound = self._stream_id_is_outbound(stream_id)
|
| 485 |
+
highest_stream_id = (
|
| 486 |
+
self.highest_outbound_stream_id if outbound else
|
| 487 |
+
self.highest_inbound_stream_id
|
| 488 |
+
)
|
| 489 |
+
|
| 490 |
+
if stream_id <= highest_stream_id:
|
| 491 |
+
raise StreamIDTooLowError(stream_id, highest_stream_id)
|
| 492 |
+
|
| 493 |
+
if (stream_id % 2) != int(allowed_ids):
|
| 494 |
+
msg = "Invalid stream ID for peer."
|
| 495 |
+
raise ProtocolError(msg)
|
| 496 |
+
|
| 497 |
+
s = H2Stream(
|
| 498 |
+
stream_id,
|
| 499 |
+
config=self.config,
|
| 500 |
+
inbound_window_size=self.local_settings.initial_window_size,
|
| 501 |
+
outbound_window_size=self.remote_settings.initial_window_size,
|
| 502 |
+
)
|
| 503 |
+
self.config.logger.debug("Stream ID %d created", stream_id)
|
| 504 |
+
s.max_outbound_frame_size = self.max_outbound_frame_size
|
| 505 |
+
|
| 506 |
+
self.streams[stream_id] = s
|
| 507 |
+
self.config.logger.debug("Current streams: %s", self.streams.keys())
|
| 508 |
+
|
| 509 |
+
if outbound:
|
| 510 |
+
self.highest_outbound_stream_id = stream_id
|
| 511 |
+
else:
|
| 512 |
+
self.highest_inbound_stream_id = stream_id
|
| 513 |
+
|
| 514 |
+
return s
|
| 515 |
+
|
| 516 |
+
def initiate_connection(self) -> None:
|
| 517 |
+
"""
|
| 518 |
+
Provides any data that needs to be sent at the start of the connection.
|
| 519 |
+
Must be called for both clients and servers.
|
| 520 |
+
"""
|
| 521 |
+
self.config.logger.debug("Initializing connection")
|
| 522 |
+
self.state_machine.process_input(ConnectionInputs.SEND_SETTINGS)
|
| 523 |
+
if self.config.client_side:
|
| 524 |
+
preamble = b"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"
|
| 525 |
+
else:
|
| 526 |
+
preamble = b""
|
| 527 |
+
|
| 528 |
+
f = SettingsFrame(0)
|
| 529 |
+
for setting, value in self.local_settings.items():
|
| 530 |
+
f.settings[setting] = value
|
| 531 |
+
self.config.logger.debug(
|
| 532 |
+
"Send Settings frame: %s", self.local_settings,
|
| 533 |
+
)
|
| 534 |
+
|
| 535 |
+
self._data_to_send += preamble + f.serialize()
|
| 536 |
+
|
| 537 |
+
def initiate_upgrade_connection(self, settings_header: bytes | None = None) -> bytes | None:
|
| 538 |
+
"""
|
| 539 |
+
Call to initialise the connection object for use with an upgraded
|
| 540 |
+
HTTP/2 connection (i.e. a connection negotiated using the
|
| 541 |
+
``Upgrade: h2c`` HTTP header).
|
| 542 |
+
|
| 543 |
+
This method differs from :meth:`initiate_connection
|
| 544 |
+
<h2.connection.H2Connection.initiate_connection>` in several ways.
|
| 545 |
+
Firstly, it handles the additional SETTINGS frame that is sent in the
|
| 546 |
+
``HTTP2-Settings`` header field. When called on a client connection,
|
| 547 |
+
this method will return a bytestring that the caller can put in the
|
| 548 |
+
``HTTP2-Settings`` field they send on their initial request. When
|
| 549 |
+
called on a server connection, the user **must** provide the value they
|
| 550 |
+
received from the client in the ``HTTP2-Settings`` header field to the
|
| 551 |
+
``settings_header`` argument, which will be used appropriately.
|
| 552 |
+
|
| 553 |
+
Additionally, this method sets up stream 1 in a half-closed state
|
| 554 |
+
appropriate for this side of the connection, to reflect the fact that
|
| 555 |
+
the request is already complete.
|
| 556 |
+
|
| 557 |
+
Finally, this method also prepares the appropriate preamble to be sent
|
| 558 |
+
after the upgrade.
|
| 559 |
+
|
| 560 |
+
.. versionadded:: 2.3.0
|
| 561 |
+
|
| 562 |
+
:param settings_header: (optional, server-only): The value of the
|
| 563 |
+
``HTTP2-Settings`` header field received from the client.
|
| 564 |
+
:type settings_header: ``bytes``
|
| 565 |
+
|
| 566 |
+
:returns: For clients, a bytestring to put in the ``HTTP2-Settings``.
|
| 567 |
+
For servers, returns nothing.
|
| 568 |
+
:rtype: ``bytes`` or ``None``
|
| 569 |
+
"""
|
| 570 |
+
self.config.logger.debug(
|
| 571 |
+
"Upgrade connection. Current settings: %s", self.local_settings,
|
| 572 |
+
)
|
| 573 |
+
|
| 574 |
+
frame_data = None
|
| 575 |
+
# Begin by getting the preamble in place.
|
| 576 |
+
self.initiate_connection()
|
| 577 |
+
|
| 578 |
+
if self.config.client_side:
|
| 579 |
+
f = SettingsFrame(0)
|
| 580 |
+
for setting, value in self.local_settings.items():
|
| 581 |
+
f.settings[setting] = value
|
| 582 |
+
|
| 583 |
+
frame_data = f.serialize_body()
|
| 584 |
+
frame_data = base64.urlsafe_b64encode(frame_data)
|
| 585 |
+
elif settings_header:
|
| 586 |
+
# We have a settings header from the client. This needs to be
|
| 587 |
+
# applied, but we want to throw away the ACK. We do this by
|
| 588 |
+
# inserting the data into a Settings frame and then passing it to
|
| 589 |
+
# the state machine, but ignoring the return value.
|
| 590 |
+
settings_header = base64.urlsafe_b64decode(settings_header)
|
| 591 |
+
f = SettingsFrame(0)
|
| 592 |
+
f.parse_body(memoryview(settings_header))
|
| 593 |
+
self._receive_settings_frame(f)
|
| 594 |
+
|
| 595 |
+
# Set up appropriate state. Stream 1 in a half-closed state:
|
| 596 |
+
# half-closed(local) for clients, half-closed(remote) for servers.
|
| 597 |
+
# Additionally, we need to set up the Connection state machine.
|
| 598 |
+
connection_input = (
|
| 599 |
+
ConnectionInputs.SEND_HEADERS if self.config.client_side
|
| 600 |
+
else ConnectionInputs.RECV_HEADERS
|
| 601 |
+
)
|
| 602 |
+
self.config.logger.debug("Process input %s", connection_input)
|
| 603 |
+
self.state_machine.process_input(connection_input)
|
| 604 |
+
|
| 605 |
+
# Set up stream 1.
|
| 606 |
+
self._begin_new_stream(stream_id=1, allowed_ids=AllowedStreamIDs.ODD)
|
| 607 |
+
self.streams[1].upgrade(self.config.client_side)
|
| 608 |
+
return frame_data
|
| 609 |
+
|
| 610 |
+
def _get_or_create_stream(self, stream_id: int, allowed_ids: AllowedStreamIDs) -> H2Stream:
|
| 611 |
+
"""
|
| 612 |
+
Gets a stream by its stream ID. Will create one if one does not already
|
| 613 |
+
exist. Use allowed_ids to circumvent the usual stream ID rules for
|
| 614 |
+
clients and servers.
|
| 615 |
+
|
| 616 |
+
.. versionchanged:: 2.0.0
|
| 617 |
+
Removed this function from the public API.
|
| 618 |
+
"""
|
| 619 |
+
try:
|
| 620 |
+
return self.streams[stream_id]
|
| 621 |
+
except KeyError:
|
| 622 |
+
return self._begin_new_stream(stream_id, allowed_ids)
|
| 623 |
+
|
| 624 |
+
def _get_stream_by_id(self, stream_id: int | None) -> H2Stream:
|
| 625 |
+
"""
|
| 626 |
+
Gets a stream by its stream ID. Raises NoSuchStreamError if the stream
|
| 627 |
+
ID does not correspond to a known stream and is higher than the current
|
| 628 |
+
maximum: raises if it is lower than the current maximum.
|
| 629 |
+
|
| 630 |
+
.. versionchanged:: 2.0.0
|
| 631 |
+
Removed this function from the public API.
|
| 632 |
+
"""
|
| 633 |
+
if not stream_id:
|
| 634 |
+
raise NoSuchStreamError(-1) # pragma: no cover
|
| 635 |
+
try:
|
| 636 |
+
return self.streams[stream_id]
|
| 637 |
+
except KeyError as e:
|
| 638 |
+
outbound = self._stream_id_is_outbound(stream_id)
|
| 639 |
+
highest_stream_id = (
|
| 640 |
+
self.highest_outbound_stream_id if outbound else
|
| 641 |
+
self.highest_inbound_stream_id
|
| 642 |
+
)
|
| 643 |
+
|
| 644 |
+
if stream_id > highest_stream_id:
|
| 645 |
+
raise NoSuchStreamError(stream_id) from e
|
| 646 |
+
raise StreamClosedError(stream_id) from e
|
| 647 |
+
|
| 648 |
+
def get_next_available_stream_id(self) -> int:
|
| 649 |
+
"""
|
| 650 |
+
Returns an integer suitable for use as the stream ID for the next
|
| 651 |
+
stream created by this endpoint. For server endpoints, this stream ID
|
| 652 |
+
will be even. For client endpoints, this stream ID will be odd. If no
|
| 653 |
+
stream IDs are available, raises :class:`NoAvailableStreamIDError
|
| 654 |
+
<h2.exceptions.NoAvailableStreamIDError>`.
|
| 655 |
+
|
| 656 |
+
.. warning:: The return value from this function does not change until
|
| 657 |
+
the stream ID has actually been used by sending or pushing
|
| 658 |
+
headers on that stream. For that reason, it should be
|
| 659 |
+
called as close as possible to the actual use of the
|
| 660 |
+
stream ID.
|
| 661 |
+
|
| 662 |
+
.. versionadded:: 2.0.0
|
| 663 |
+
|
| 664 |
+
:raises: :class:`NoAvailableStreamIDError
|
| 665 |
+
<h2.exceptions.NoAvailableStreamIDError>`
|
| 666 |
+
:returns: The next free stream ID this peer can use to initiate a
|
| 667 |
+
stream.
|
| 668 |
+
:rtype: ``int``
|
| 669 |
+
"""
|
| 670 |
+
# No streams have been opened yet, so return the lowest allowed stream
|
| 671 |
+
# ID.
|
| 672 |
+
if not self.highest_outbound_stream_id:
|
| 673 |
+
next_stream_id = 1 if self.config.client_side else 2
|
| 674 |
+
else:
|
| 675 |
+
next_stream_id = self.highest_outbound_stream_id + 2
|
| 676 |
+
self.config.logger.debug(
|
| 677 |
+
"Next available stream ID %d", next_stream_id,
|
| 678 |
+
)
|
| 679 |
+
if next_stream_id > self.HIGHEST_ALLOWED_STREAM_ID:
|
| 680 |
+
msg = "Exhausted allowed stream IDs"
|
| 681 |
+
raise NoAvailableStreamIDError(msg)
|
| 682 |
+
|
| 683 |
+
return next_stream_id
|
| 684 |
+
|
| 685 |
+
def send_headers(self,
|
| 686 |
+
stream_id: int,
|
| 687 |
+
headers: Iterable[HeaderWeaklyTyped],
|
| 688 |
+
end_stream: bool = False,
|
| 689 |
+
priority_weight: int | None = None,
|
| 690 |
+
priority_depends_on: int | None = None,
|
| 691 |
+
priority_exclusive: bool | None = None) -> None:
|
| 692 |
+
"""
|
| 693 |
+
Send headers on a given stream.
|
| 694 |
+
|
| 695 |
+
This function can be used to send request or response headers: the kind
|
| 696 |
+
that are sent depends on whether this connection has been opened as a
|
| 697 |
+
client or server connection, and whether the stream was opened by the
|
| 698 |
+
remote peer or not.
|
| 699 |
+
|
| 700 |
+
If this is a client connection, calling ``send_headers`` will send the
|
| 701 |
+
headers as a request. It will also implicitly open the stream being
|
| 702 |
+
used. If this is a client connection and ``send_headers`` has *already*
|
| 703 |
+
been called, this will send trailers instead.
|
| 704 |
+
|
| 705 |
+
If this is a server connection, calling ``send_headers`` will send the
|
| 706 |
+
headers as a response. It is a protocol error for a server to open a
|
| 707 |
+
stream by sending headers. If this is a server connection and
|
| 708 |
+
``send_headers`` has *already* been called, this will send trailers
|
| 709 |
+
instead.
|
| 710 |
+
|
| 711 |
+
When acting as a server, you may call ``send_headers`` any number of
|
| 712 |
+
times allowed by the following rules, in this order:
|
| 713 |
+
|
| 714 |
+
- zero or more times with ``(':status', '1XX')`` (where ``1XX`` is a
|
| 715 |
+
placeholder for any 100-level status code).
|
| 716 |
+
- once with any other status header.
|
| 717 |
+
- zero or one time for trailers.
|
| 718 |
+
|
| 719 |
+
That is, you are allowed to send as many informational responses as you
|
| 720 |
+
like, followed by one complete response and zero or one HTTP trailer
|
| 721 |
+
blocks.
|
| 722 |
+
|
| 723 |
+
Clients may send one or two header blocks: one request block, and
|
| 724 |
+
optionally one trailer block.
|
| 725 |
+
|
| 726 |
+
If it is important to send HPACK "never indexed" header fields (as
|
| 727 |
+
defined in `RFC 7451 Section 7.1.3
|
| 728 |
+
<https://tools.ietf.org/html/rfc7541#section-7.1.3>`_), the user may
|
| 729 |
+
instead provide headers using the HPACK library's :class:`HeaderTuple
|
| 730 |
+
<hpack:hpack.HeaderTuple>` and :class:`NeverIndexedHeaderTuple
|
| 731 |
+
<hpack:hpack.NeverIndexedHeaderTuple>` objects.
|
| 732 |
+
|
| 733 |
+
This method also allows users to prioritize the stream immediately,
|
| 734 |
+
by sending priority information on the HEADERS frame directly. To do
|
| 735 |
+
this, any one of ``priority_weight``, ``priority_depends_on``, or
|
| 736 |
+
``priority_exclusive`` must be set to a value that is not ``None``. For
|
| 737 |
+
more information on the priority fields, see :meth:`prioritize
|
| 738 |
+
<h2.connection.H2Connection.prioritize>`.
|
| 739 |
+
|
| 740 |
+
.. warning:: In HTTP/2, it is mandatory that all the HTTP/2 special
|
| 741 |
+
headers (that is, ones whose header keys begin with ``:``) appear
|
| 742 |
+
at the start of the header block, before any normal headers.
|
| 743 |
+
|
| 744 |
+
.. versionchanged:: 2.3.0
|
| 745 |
+
Added support for using :class:`HeaderTuple
|
| 746 |
+
<hpack:hpack.HeaderTuple>` objects to store headers.
|
| 747 |
+
|
| 748 |
+
.. versionchanged:: 2.4.0
|
| 749 |
+
Added the ability to provide priority keyword arguments:
|
| 750 |
+
``priority_weight``, ``priority_depends_on``, and
|
| 751 |
+
``priority_exclusive``.
|
| 752 |
+
|
| 753 |
+
:param stream_id: The stream ID to send the headers on. If this stream
|
| 754 |
+
does not currently exist, it will be created.
|
| 755 |
+
:type stream_id: ``int``
|
| 756 |
+
|
| 757 |
+
:param headers: The request/response headers to send.
|
| 758 |
+
:type headers: An iterable of two tuples of bytestrings or
|
| 759 |
+
:class:`HeaderTuple <hpack:hpack.HeaderTuple>` objects.
|
| 760 |
+
|
| 761 |
+
:param end_stream: Whether this headers frame should end the stream
|
| 762 |
+
immediately (that is, whether no more data will be sent after this
|
| 763 |
+
frame). Defaults to ``False``.
|
| 764 |
+
:type end_stream: ``bool``
|
| 765 |
+
|
| 766 |
+
:param priority_weight: Sets the priority weight of the stream. See
|
| 767 |
+
:meth:`prioritize <h2.connection.H2Connection.prioritize>` for more
|
| 768 |
+
about how this field works. Defaults to ``None``, which means that
|
| 769 |
+
no priority information will be sent.
|
| 770 |
+
:type priority_weight: ``int`` or ``None``
|
| 771 |
+
|
| 772 |
+
:param priority_depends_on: Sets which stream this one depends on for
|
| 773 |
+
priority purposes. See :meth:`prioritize
|
| 774 |
+
<h2.connection.H2Connection.prioritize>` for more about how this
|
| 775 |
+
field works. Defaults to ``None``, which means that no priority
|
| 776 |
+
information will be sent.
|
| 777 |
+
:type priority_depends_on: ``int`` or ``None``
|
| 778 |
+
|
| 779 |
+
:param priority_exclusive: Sets whether this stream exclusively depends
|
| 780 |
+
on the stream given in ``priority_depends_on`` for priority
|
| 781 |
+
purposes. See :meth:`prioritize
|
| 782 |
+
<h2.connection.H2Connection.prioritize>` for more about how this
|
| 783 |
+
field workds. Defaults to ``None``, which means that no priority
|
| 784 |
+
information will be sent.
|
| 785 |
+
:type priority_depends_on: ``bool`` or ``None``
|
| 786 |
+
|
| 787 |
+
:returns: Nothing
|
| 788 |
+
"""
|
| 789 |
+
self.config.logger.debug(
|
| 790 |
+
"Send headers on stream ID %d", stream_id,
|
| 791 |
+
)
|
| 792 |
+
|
| 793 |
+
# Check we can open the stream.
|
| 794 |
+
if stream_id not in self.streams:
|
| 795 |
+
max_open_streams = self.remote_settings.max_concurrent_streams
|
| 796 |
+
value = self.open_outbound_streams # take a copy due to the property accessor having side affects
|
| 797 |
+
if (value + 1) > max_open_streams:
|
| 798 |
+
msg = f"Max outbound streams is {max_open_streams}, {value} open"
|
| 799 |
+
raise TooManyStreamsError(msg)
|
| 800 |
+
|
| 801 |
+
self.state_machine.process_input(ConnectionInputs.SEND_HEADERS)
|
| 802 |
+
stream = self._get_or_create_stream(
|
| 803 |
+
stream_id, AllowedStreamIDs(self.config.client_side),
|
| 804 |
+
)
|
| 805 |
+
|
| 806 |
+
frames: list[Frame] = []
|
| 807 |
+
frames.extend(stream.send_headers(
|
| 808 |
+
headers, self.encoder, end_stream,
|
| 809 |
+
))
|
| 810 |
+
|
| 811 |
+
# We may need to send priority information.
|
| 812 |
+
priority_present = (
|
| 813 |
+
(priority_weight is not None) or
|
| 814 |
+
(priority_depends_on is not None) or
|
| 815 |
+
(priority_exclusive is not None)
|
| 816 |
+
)
|
| 817 |
+
|
| 818 |
+
if priority_present:
|
| 819 |
+
if not self.config.client_side:
|
| 820 |
+
msg = "Servers SHOULD NOT prioritize streams."
|
| 821 |
+
raise RFC1122Error(msg)
|
| 822 |
+
|
| 823 |
+
headers_frame = frames[0]
|
| 824 |
+
assert isinstance(headers_frame, HeadersFrame)
|
| 825 |
+
|
| 826 |
+
headers_frame.flags.add("PRIORITY")
|
| 827 |
+
frames[0] = _add_frame_priority(
|
| 828 |
+
headers_frame,
|
| 829 |
+
priority_weight,
|
| 830 |
+
priority_depends_on,
|
| 831 |
+
priority_exclusive,
|
| 832 |
+
)
|
| 833 |
+
|
| 834 |
+
self._prepare_for_sending(frames)
|
| 835 |
+
|
| 836 |
+
def send_data(self,
|
| 837 |
+
stream_id: int,
|
| 838 |
+
data: bytes | memoryview,
|
| 839 |
+
end_stream: bool = False,
|
| 840 |
+
pad_length: Any = None) -> None:
|
| 841 |
+
"""
|
| 842 |
+
Send data on a given stream.
|
| 843 |
+
|
| 844 |
+
This method does no breaking up of data: if the data is larger than the
|
| 845 |
+
value returned by :meth:`local_flow_control_window
|
| 846 |
+
<h2.connection.H2Connection.local_flow_control_window>` for this stream
|
| 847 |
+
then a :class:`FlowControlError <h2.exceptions.FlowControlError>` will
|
| 848 |
+
be raised. If the data is larger than :data:`max_outbound_frame_size
|
| 849 |
+
<h2.connection.H2Connection.max_outbound_frame_size>` then a
|
| 850 |
+
:class:`FrameTooLargeError <h2.exceptions.FrameTooLargeError>` will be
|
| 851 |
+
raised.
|
| 852 |
+
|
| 853 |
+
h2 does this to avoid buffering the data internally. If the user
|
| 854 |
+
has more data to send than h2 will allow, consider breaking it up
|
| 855 |
+
and buffering it externally.
|
| 856 |
+
|
| 857 |
+
:param stream_id: The ID of the stream on which to send the data.
|
| 858 |
+
:type stream_id: ``int``
|
| 859 |
+
:param data: The data to send on the stream.
|
| 860 |
+
:type data: ``bytes``
|
| 861 |
+
:param end_stream: (optional) Whether this is the last data to be sent
|
| 862 |
+
on the stream. Defaults to ``False``.
|
| 863 |
+
:type end_stream: ``bool``
|
| 864 |
+
:param pad_length: (optional) Length of the padding to apply to the
|
| 865 |
+
data frame. Defaults to ``None`` for no use of padding. Note that
|
| 866 |
+
a value of ``0`` results in padding of length ``0``
|
| 867 |
+
(with the "padding" flag set on the frame).
|
| 868 |
+
|
| 869 |
+
.. versionadded:: 2.6.0
|
| 870 |
+
|
| 871 |
+
:type pad_length: ``int``
|
| 872 |
+
:returns: Nothing
|
| 873 |
+
"""
|
| 874 |
+
self.config.logger.debug(
|
| 875 |
+
"Send data on stream ID %d with len %d", stream_id, len(data),
|
| 876 |
+
)
|
| 877 |
+
frame_size = len(data)
|
| 878 |
+
if pad_length is not None:
|
| 879 |
+
if not isinstance(pad_length, int):
|
| 880 |
+
msg = "pad_length must be an int"
|
| 881 |
+
raise TypeError(msg)
|
| 882 |
+
if pad_length < 0 or pad_length > 255:
|
| 883 |
+
msg = "pad_length must be within range: [0, 255]"
|
| 884 |
+
raise ValueError(msg)
|
| 885 |
+
# Account for padding bytes plus the 1-byte padding length field.
|
| 886 |
+
frame_size += pad_length + 1
|
| 887 |
+
self.config.logger.debug(
|
| 888 |
+
"Frame size on stream ID %d is %d", stream_id, frame_size,
|
| 889 |
+
)
|
| 890 |
+
|
| 891 |
+
if frame_size > self.local_flow_control_window(stream_id):
|
| 892 |
+
msg = f"Cannot send {frame_size} bytes, flow control window is {self.local_flow_control_window(stream_id)}"
|
| 893 |
+
raise FlowControlError(msg)
|
| 894 |
+
if frame_size > self.max_outbound_frame_size:
|
| 895 |
+
msg = f"Cannot send frame size {frame_size}, max frame size is {self.max_outbound_frame_size}"
|
| 896 |
+
raise FrameTooLargeError(msg)
|
| 897 |
+
|
| 898 |
+
self.state_machine.process_input(ConnectionInputs.SEND_DATA)
|
| 899 |
+
frames = self.streams[stream_id].send_data(
|
| 900 |
+
data, end_stream, pad_length=pad_length,
|
| 901 |
+
)
|
| 902 |
+
|
| 903 |
+
self._prepare_for_sending(frames)
|
| 904 |
+
|
| 905 |
+
self.outbound_flow_control_window -= frame_size
|
| 906 |
+
self.config.logger.debug(
|
| 907 |
+
"Outbound flow control window size is %d",
|
| 908 |
+
self.outbound_flow_control_window,
|
| 909 |
+
)
|
| 910 |
+
assert self.outbound_flow_control_window >= 0
|
| 911 |
+
|
| 912 |
+
def end_stream(self, stream_id: int) -> None:
|
| 913 |
+
"""
|
| 914 |
+
Cleanly end a given stream.
|
| 915 |
+
|
| 916 |
+
This method ends a stream by sending an empty DATA frame on that stream
|
| 917 |
+
with the ``END_STREAM`` flag set.
|
| 918 |
+
|
| 919 |
+
:param stream_id: The ID of the stream to end.
|
| 920 |
+
:type stream_id: ``int``
|
| 921 |
+
:returns: Nothing
|
| 922 |
+
"""
|
| 923 |
+
self.config.logger.debug("End stream ID %d", stream_id)
|
| 924 |
+
self.state_machine.process_input(ConnectionInputs.SEND_DATA)
|
| 925 |
+
frames = self.streams[stream_id].end_stream()
|
| 926 |
+
self._prepare_for_sending(frames)
|
| 927 |
+
|
| 928 |
+
def increment_flow_control_window(self, increment: int, stream_id: int | None = None) -> None:
|
| 929 |
+
"""
|
| 930 |
+
Increment a flow control window, optionally for a single stream. Allows
|
| 931 |
+
the remote peer to send more data.
|
| 932 |
+
|
| 933 |
+
.. versionchanged:: 2.0.0
|
| 934 |
+
Rejects attempts to increment the flow control window by out of
|
| 935 |
+
range values with a ``ValueError``.
|
| 936 |
+
|
| 937 |
+
:param increment: The amount to increment the flow control window by.
|
| 938 |
+
:type increment: ``int``
|
| 939 |
+
:param stream_id: (optional) The ID of the stream that should have its
|
| 940 |
+
flow control window opened. If not present or ``None``, the
|
| 941 |
+
connection flow control window will be opened instead.
|
| 942 |
+
:type stream_id: ``int`` or ``None``
|
| 943 |
+
:returns: Nothing
|
| 944 |
+
:raises: ``ValueError``
|
| 945 |
+
"""
|
| 946 |
+
if not (1 <= increment <= self.MAX_WINDOW_INCREMENT):
|
| 947 |
+
msg = f"Flow control increment must be between 1 and {self.MAX_WINDOW_INCREMENT}"
|
| 948 |
+
raise ValueError(msg)
|
| 949 |
+
|
| 950 |
+
self.state_machine.process_input(ConnectionInputs.SEND_WINDOW_UPDATE)
|
| 951 |
+
|
| 952 |
+
if stream_id is not None:
|
| 953 |
+
stream = self.streams[stream_id]
|
| 954 |
+
frames = stream.increase_flow_control_window(
|
| 955 |
+
increment,
|
| 956 |
+
)
|
| 957 |
+
|
| 958 |
+
self.config.logger.debug(
|
| 959 |
+
"Increase stream ID %d flow control window by %d",
|
| 960 |
+
stream_id, increment,
|
| 961 |
+
)
|
| 962 |
+
else:
|
| 963 |
+
self._inbound_flow_control_window_manager.window_opened(increment)
|
| 964 |
+
f = WindowUpdateFrame(0)
|
| 965 |
+
f.window_increment = increment
|
| 966 |
+
frames = [f]
|
| 967 |
+
|
| 968 |
+
self.config.logger.debug(
|
| 969 |
+
"Increase connection flow control window by %d", increment,
|
| 970 |
+
)
|
| 971 |
+
|
| 972 |
+
self._prepare_for_sending(frames)
|
| 973 |
+
|
| 974 |
+
def push_stream(self,
|
| 975 |
+
stream_id: int,
|
| 976 |
+
promised_stream_id: int,
|
| 977 |
+
request_headers: Iterable[HeaderWeaklyTyped]) -> None:
|
| 978 |
+
"""
|
| 979 |
+
Push a response to the client by sending a PUSH_PROMISE frame.
|
| 980 |
+
|
| 981 |
+
If it is important to send HPACK "never indexed" header fields (as
|
| 982 |
+
defined in `RFC 7451 Section 7.1.3
|
| 983 |
+
<https://tools.ietf.org/html/rfc7541#section-7.1.3>`_), the user may
|
| 984 |
+
instead provide headers using the HPACK library's :class:`HeaderTuple
|
| 985 |
+
<hpack:hpack.HeaderTuple>` and :class:`NeverIndexedHeaderTuple
|
| 986 |
+
<hpack:hpack.NeverIndexedHeaderTuple>` objects.
|
| 987 |
+
|
| 988 |
+
:param stream_id: The ID of the stream that this push is a response to.
|
| 989 |
+
:type stream_id: ``int``
|
| 990 |
+
:param promised_stream_id: The ID of the stream that the pushed
|
| 991 |
+
response will be sent on.
|
| 992 |
+
:type promised_stream_id: ``int``
|
| 993 |
+
:param request_headers: The headers of the request that the pushed
|
| 994 |
+
response will be responding to.
|
| 995 |
+
:type request_headers: An iterable of two tuples of bytestrings or
|
| 996 |
+
:class:`HeaderTuple <hpack:hpack.HeaderTuple>` objects.
|
| 997 |
+
:returns: Nothing
|
| 998 |
+
"""
|
| 999 |
+
self.config.logger.debug(
|
| 1000 |
+
"Send Push Promise frame on stream ID %d", stream_id,
|
| 1001 |
+
)
|
| 1002 |
+
|
| 1003 |
+
if not self.remote_settings.enable_push:
|
| 1004 |
+
msg = "Remote peer has disabled stream push"
|
| 1005 |
+
raise ProtocolError(msg)
|
| 1006 |
+
|
| 1007 |
+
self.state_machine.process_input(ConnectionInputs.SEND_PUSH_PROMISE)
|
| 1008 |
+
stream = self._get_stream_by_id(stream_id)
|
| 1009 |
+
|
| 1010 |
+
# We need to prevent users pushing streams in response to streams that
|
| 1011 |
+
# they themselves have already pushed: see #163 and RFC 7540 § 6.6. The
|
| 1012 |
+
# easiest way to do that is to assert that the stream_id is not even:
|
| 1013 |
+
# this shortcut works because only servers can push and the state
|
| 1014 |
+
# machine will enforce this.
|
| 1015 |
+
if (stream_id % 2) == 0:
|
| 1016 |
+
msg = "Cannot recursively push streams."
|
| 1017 |
+
raise ProtocolError(msg)
|
| 1018 |
+
|
| 1019 |
+
new_stream = self._begin_new_stream(
|
| 1020 |
+
promised_stream_id, AllowedStreamIDs.EVEN,
|
| 1021 |
+
)
|
| 1022 |
+
self.streams[promised_stream_id] = new_stream
|
| 1023 |
+
|
| 1024 |
+
frames = stream.push_stream_in_band(
|
| 1025 |
+
promised_stream_id, request_headers, self.encoder,
|
| 1026 |
+
)
|
| 1027 |
+
new_frames = new_stream.locally_pushed()
|
| 1028 |
+
self._prepare_for_sending(frames + new_frames)
|
| 1029 |
+
|
| 1030 |
+
def ping(self, opaque_data: bytes | str) -> None:
|
| 1031 |
+
"""
|
| 1032 |
+
Send a PING frame.
|
| 1033 |
+
|
| 1034 |
+
:param opaque_data: A bytestring of length 8 that will be sent in the
|
| 1035 |
+
PING frame.
|
| 1036 |
+
:returns: Nothing
|
| 1037 |
+
"""
|
| 1038 |
+
self.config.logger.debug("Send Ping frame")
|
| 1039 |
+
|
| 1040 |
+
if not isinstance(opaque_data, bytes) or len(opaque_data) != 8:
|
| 1041 |
+
msg = f"Invalid value for ping data: {opaque_data!r}"
|
| 1042 |
+
raise ValueError(msg)
|
| 1043 |
+
|
| 1044 |
+
self.state_machine.process_input(ConnectionInputs.SEND_PING)
|
| 1045 |
+
f = PingFrame(0)
|
| 1046 |
+
f.opaque_data = opaque_data
|
| 1047 |
+
self._prepare_for_sending([f])
|
| 1048 |
+
|
| 1049 |
+
def reset_stream(self, stream_id: int, error_code: ErrorCodes | int = 0) -> None:
|
| 1050 |
+
"""
|
| 1051 |
+
Reset a stream.
|
| 1052 |
+
|
| 1053 |
+
This method forcibly closes a stream by sending a RST_STREAM frame for
|
| 1054 |
+
a given stream. This is not a graceful closure. To gracefully end a
|
| 1055 |
+
stream, try the :meth:`end_stream
|
| 1056 |
+
<h2.connection.H2Connection.end_stream>` method.
|
| 1057 |
+
|
| 1058 |
+
:param stream_id: The ID of the stream to reset.
|
| 1059 |
+
:type stream_id: ``int``
|
| 1060 |
+
:param error_code: (optional) The error code to use to reset the
|
| 1061 |
+
stream. Defaults to :data:`ErrorCodes.NO_ERROR
|
| 1062 |
+
<h2.errors.ErrorCodes.NO_ERROR>`.
|
| 1063 |
+
:type error_code: ``int``
|
| 1064 |
+
:returns: Nothing
|
| 1065 |
+
"""
|
| 1066 |
+
self.config.logger.debug("Reset stream ID %d", stream_id)
|
| 1067 |
+
self.state_machine.process_input(ConnectionInputs.SEND_RST_STREAM)
|
| 1068 |
+
stream = self._get_stream_by_id(stream_id)
|
| 1069 |
+
frames = stream.reset_stream(error_code)
|
| 1070 |
+
self._prepare_for_sending(frames)
|
| 1071 |
+
|
| 1072 |
+
def close_connection(self,
|
| 1073 |
+
error_code: ErrorCodes | int = 0,
|
| 1074 |
+
additional_data: bytes | None = None,
|
| 1075 |
+
last_stream_id: int | None = None) -> None:
|
| 1076 |
+
"""
|
| 1077 |
+
Close a connection, emitting a GOAWAY frame.
|
| 1078 |
+
|
| 1079 |
+
.. versionchanged:: 2.4.0
|
| 1080 |
+
Added ``additional_data`` and ``last_stream_id`` arguments.
|
| 1081 |
+
|
| 1082 |
+
:param error_code: (optional) The error code to send in the GOAWAY
|
| 1083 |
+
frame.
|
| 1084 |
+
:param additional_data: (optional) Additional debug data indicating
|
| 1085 |
+
a reason for closing the connection. Must be a bytestring.
|
| 1086 |
+
:param last_stream_id: (optional) The last stream which was processed
|
| 1087 |
+
by the sender. Defaults to ``highest_inbound_stream_id``.
|
| 1088 |
+
:returns: Nothing
|
| 1089 |
+
"""
|
| 1090 |
+
self.config.logger.debug("Close connection")
|
| 1091 |
+
self.state_machine.process_input(ConnectionInputs.SEND_GOAWAY)
|
| 1092 |
+
|
| 1093 |
+
# Additional_data must be bytes
|
| 1094 |
+
if additional_data is not None:
|
| 1095 |
+
assert isinstance(additional_data, bytes)
|
| 1096 |
+
|
| 1097 |
+
if last_stream_id is None:
|
| 1098 |
+
last_stream_id = self.highest_inbound_stream_id
|
| 1099 |
+
|
| 1100 |
+
f = GoAwayFrame(
|
| 1101 |
+
stream_id=0,
|
| 1102 |
+
last_stream_id=last_stream_id,
|
| 1103 |
+
error_code=error_code,
|
| 1104 |
+
additional_data=(additional_data or b""),
|
| 1105 |
+
)
|
| 1106 |
+
self._prepare_for_sending([f])
|
| 1107 |
+
|
| 1108 |
+
def update_settings(self, new_settings: dict[SettingCodes | int, int]) -> None:
|
| 1109 |
+
"""
|
| 1110 |
+
Update the local settings. This will prepare and emit the appropriate
|
| 1111 |
+
SETTINGS frame.
|
| 1112 |
+
|
| 1113 |
+
:param new_settings: A dictionary of {setting: new value}
|
| 1114 |
+
"""
|
| 1115 |
+
self.config.logger.debug(
|
| 1116 |
+
"Update connection settings to %s", new_settings,
|
| 1117 |
+
)
|
| 1118 |
+
self.state_machine.process_input(ConnectionInputs.SEND_SETTINGS)
|
| 1119 |
+
self.local_settings.update(new_settings)
|
| 1120 |
+
s = SettingsFrame(0)
|
| 1121 |
+
s.settings = new_settings
|
| 1122 |
+
self._prepare_for_sending([s])
|
| 1123 |
+
|
| 1124 |
+
def advertise_alternative_service(self,
|
| 1125 |
+
field_value: bytes | str,
|
| 1126 |
+
origin: bytes | None = None,
|
| 1127 |
+
stream_id: int | None = None) -> None:
|
| 1128 |
+
"""
|
| 1129 |
+
Notify a client about an available Alternative Service.
|
| 1130 |
+
|
| 1131 |
+
An Alternative Service is defined in `RFC 7838
|
| 1132 |
+
<https://tools.ietf.org/html/rfc7838>`_. An Alternative Service
|
| 1133 |
+
notification informs a client that a given origin is also available
|
| 1134 |
+
elsewhere.
|
| 1135 |
+
|
| 1136 |
+
Alternative Services can be advertised in two ways. Firstly, they can
|
| 1137 |
+
be advertised explicitly: that is, a server can say "origin X is also
|
| 1138 |
+
available at Y". To advertise like this, set the ``origin`` argument
|
| 1139 |
+
and not the ``stream_id`` argument. Alternatively, they can be
|
| 1140 |
+
advertised implicitly: that is, a server can say "the origin you're
|
| 1141 |
+
contacting on stream X is also available at Y". To advertise like this,
|
| 1142 |
+
set the ``stream_id`` argument and not the ``origin`` argument.
|
| 1143 |
+
|
| 1144 |
+
The explicit method of advertising can be done as long as the
|
| 1145 |
+
connection is active. The implicit method can only be done after the
|
| 1146 |
+
client has sent the request headers and before the server has sent the
|
| 1147 |
+
response headers: outside of those points, h2 will forbid sending
|
| 1148 |
+
the Alternative Service advertisement by raising a ProtocolError.
|
| 1149 |
+
|
| 1150 |
+
The ``field_value`` parameter is specified in RFC 7838. h2 does
|
| 1151 |
+
not validate or introspect this argument: the user is required to
|
| 1152 |
+
ensure that it's well-formed. ``field_value`` corresponds to RFC 7838's
|
| 1153 |
+
"Alternative Service Field Value".
|
| 1154 |
+
|
| 1155 |
+
.. note:: It is strongly preferred to use the explicit method of
|
| 1156 |
+
advertising Alternative Services. The implicit method of
|
| 1157 |
+
advertising Alternative Services has a number of subtleties
|
| 1158 |
+
and can lead to inconsistencies between the server and
|
| 1159 |
+
client. h2 allows both mechanisms, but caution is
|
| 1160 |
+
strongly advised.
|
| 1161 |
+
|
| 1162 |
+
.. versionadded:: 2.3.0
|
| 1163 |
+
|
| 1164 |
+
:param field_value: The RFC 7838 Alternative Service Field Value. This
|
| 1165 |
+
argument is not introspected by h2: the user is responsible
|
| 1166 |
+
for ensuring that it is well-formed.
|
| 1167 |
+
:type field_value: ``bytes``
|
| 1168 |
+
|
| 1169 |
+
:param origin: The origin/authority to which the Alternative Service
|
| 1170 |
+
being advertised applies. Must not be provided at the same time as
|
| 1171 |
+
``stream_id``.
|
| 1172 |
+
:type origin: ``bytes`` or ``None``
|
| 1173 |
+
|
| 1174 |
+
:param stream_id: The ID of the stream which was sent to the authority
|
| 1175 |
+
for which this Alternative Service advertisement applies. Must not
|
| 1176 |
+
be provided at the same time as ``origin``.
|
| 1177 |
+
:type stream_id: ``int`` or ``None``
|
| 1178 |
+
|
| 1179 |
+
:returns: Nothing.
|
| 1180 |
+
"""
|
| 1181 |
+
if not isinstance(field_value, bytes):
|
| 1182 |
+
msg = "Field must be bytestring."
|
| 1183 |
+
raise ValueError(msg) # noqa: TRY004
|
| 1184 |
+
|
| 1185 |
+
if origin is not None and stream_id is not None:
|
| 1186 |
+
msg = "Must not provide both origin and stream_id"
|
| 1187 |
+
raise ValueError(msg)
|
| 1188 |
+
|
| 1189 |
+
self.state_machine.process_input(
|
| 1190 |
+
ConnectionInputs.SEND_ALTERNATIVE_SERVICE,
|
| 1191 |
+
)
|
| 1192 |
+
|
| 1193 |
+
if origin is not None:
|
| 1194 |
+
# This ALTSVC is sent on stream zero.
|
| 1195 |
+
f = AltSvcFrame(stream_id=0)
|
| 1196 |
+
f.origin = origin
|
| 1197 |
+
f.field = field_value
|
| 1198 |
+
frames: list[Frame] = [f]
|
| 1199 |
+
else:
|
| 1200 |
+
stream = self._get_stream_by_id(stream_id)
|
| 1201 |
+
frames = stream.advertise_alternative_service(field_value)
|
| 1202 |
+
|
| 1203 |
+
self._prepare_for_sending(frames)
|
| 1204 |
+
|
| 1205 |
+
def prioritize(self,
|
| 1206 |
+
stream_id: int,
|
| 1207 |
+
weight: int | None = None,
|
| 1208 |
+
depends_on: int | None = None,
|
| 1209 |
+
exclusive: bool | None = None) -> None:
|
| 1210 |
+
"""
|
| 1211 |
+
Notify a server about the priority of a stream.
|
| 1212 |
+
|
| 1213 |
+
Stream priorities are a form of guidance to a remote server: they
|
| 1214 |
+
inform the server about how important a given response is, so that the
|
| 1215 |
+
server may allocate its resources (e.g. bandwidth, CPU time, etc.)
|
| 1216 |
+
accordingly. This exists to allow clients to ensure that the most
|
| 1217 |
+
important data arrives earlier, while less important data does not
|
| 1218 |
+
starve out the more important data.
|
| 1219 |
+
|
| 1220 |
+
Stream priorities are explained in depth in `RFC 7540 Section 5.3
|
| 1221 |
+
<https://tools.ietf.org/html/rfc7540#section-5.3>`_.
|
| 1222 |
+
|
| 1223 |
+
This method updates the priority information of a single stream. It may
|
| 1224 |
+
be called well before a stream is actively in use, or well after a
|
| 1225 |
+
stream is closed.
|
| 1226 |
+
|
| 1227 |
+
.. warning:: RFC 7540 allows for servers to change the priority of
|
| 1228 |
+
streams. However, h2 **does not** allow server
|
| 1229 |
+
stacks to do this. This is because most clients do not
|
| 1230 |
+
adequately know how to respond when provided conflicting
|
| 1231 |
+
priority information, and relatively little utility is
|
| 1232 |
+
provided by making that functionality available.
|
| 1233 |
+
|
| 1234 |
+
.. note:: h2 **does not** maintain any information about the
|
| 1235 |
+
RFC 7540 priority tree. That means that h2 does not
|
| 1236 |
+
prevent incautious users from creating invalid priority
|
| 1237 |
+
trees, particularly by creating priority loops. While some
|
| 1238 |
+
basic error checking is provided by h2, users are
|
| 1239 |
+
strongly recommended to understand their prioritisation
|
| 1240 |
+
strategies before using the priority tools here.
|
| 1241 |
+
|
| 1242 |
+
.. note:: Priority information is strictly advisory. Servers are
|
| 1243 |
+
allowed to disregard it entirely. Avoid relying on the idea
|
| 1244 |
+
that your priority signaling will definitely be obeyed.
|
| 1245 |
+
|
| 1246 |
+
.. versionadded:: 2.4.0
|
| 1247 |
+
|
| 1248 |
+
:param stream_id: The ID of the stream to prioritize.
|
| 1249 |
+
:type stream_id: ``int``
|
| 1250 |
+
|
| 1251 |
+
:param weight: The weight to give the stream. Defaults to ``16``, the
|
| 1252 |
+
default weight of any stream. May be any value between ``1`` and
|
| 1253 |
+
``256`` inclusive. The relative weight of a stream indicates what
|
| 1254 |
+
proportion of available resources will be allocated to that
|
| 1255 |
+
stream.
|
| 1256 |
+
:type weight: ``int``
|
| 1257 |
+
|
| 1258 |
+
:param depends_on: The ID of the stream on which this stream depends.
|
| 1259 |
+
This stream will only be progressed if it is impossible to
|
| 1260 |
+
progress the parent stream (the one on which this one depends).
|
| 1261 |
+
Passing the value ``0`` means that this stream does not depend on
|
| 1262 |
+
any other. Defaults to ``0``.
|
| 1263 |
+
:type depends_on: ``int``
|
| 1264 |
+
|
| 1265 |
+
:param exclusive: Whether this stream is an exclusive dependency of its
|
| 1266 |
+
"parent" stream (i.e. the stream given by ``depends_on``). If a
|
| 1267 |
+
stream is an exclusive dependency of another, that means that all
|
| 1268 |
+
previously-set children of the parent are moved to become children
|
| 1269 |
+
of the new exclusively-dependent stream. Defaults to ``False``.
|
| 1270 |
+
:type exclusive: ``bool``
|
| 1271 |
+
"""
|
| 1272 |
+
if not self.config.client_side:
|
| 1273 |
+
msg = "Servers SHOULD NOT prioritize streams."
|
| 1274 |
+
raise RFC1122Error(msg)
|
| 1275 |
+
|
| 1276 |
+
self.state_machine.process_input(
|
| 1277 |
+
ConnectionInputs.SEND_PRIORITY,
|
| 1278 |
+
)
|
| 1279 |
+
|
| 1280 |
+
frame = PriorityFrame(stream_id)
|
| 1281 |
+
frame_prio = _add_frame_priority(frame, weight, depends_on, exclusive)
|
| 1282 |
+
|
| 1283 |
+
self._prepare_for_sending([frame_prio])
|
| 1284 |
+
|
| 1285 |
+
def local_flow_control_window(self, stream_id: int) -> int:
|
| 1286 |
+
"""
|
| 1287 |
+
Returns the maximum amount of data that can be sent on stream
|
| 1288 |
+
``stream_id``.
|
| 1289 |
+
|
| 1290 |
+
This value will never be larger than the total data that can be sent on
|
| 1291 |
+
the connection: even if the given stream allows more data, the
|
| 1292 |
+
connection window provides a logical maximum to the amount of data that
|
| 1293 |
+
can be sent.
|
| 1294 |
+
|
| 1295 |
+
The maximum data that can be sent in a single data frame on a stream
|
| 1296 |
+
is either this value, or the maximum frame size, whichever is
|
| 1297 |
+
*smaller*.
|
| 1298 |
+
|
| 1299 |
+
:param stream_id: The ID of the stream whose flow control window is
|
| 1300 |
+
being queried.
|
| 1301 |
+
:type stream_id: ``int``
|
| 1302 |
+
:returns: The amount of data in bytes that can be sent on the stream
|
| 1303 |
+
before the flow control window is exhausted.
|
| 1304 |
+
:rtype: ``int``
|
| 1305 |
+
"""
|
| 1306 |
+
stream = self._get_stream_by_id(stream_id)
|
| 1307 |
+
return min(
|
| 1308 |
+
self.outbound_flow_control_window,
|
| 1309 |
+
stream.outbound_flow_control_window,
|
| 1310 |
+
)
|
| 1311 |
+
|
| 1312 |
+
def remote_flow_control_window(self, stream_id: int) -> int:
|
| 1313 |
+
"""
|
| 1314 |
+
Returns the maximum amount of data the remote peer can send on stream
|
| 1315 |
+
``stream_id``.
|
| 1316 |
+
|
| 1317 |
+
This value will never be larger than the total data that can be sent on
|
| 1318 |
+
the connection: even if the given stream allows more data, the
|
| 1319 |
+
connection window provides a logical maximum to the amount of data that
|
| 1320 |
+
can be sent.
|
| 1321 |
+
|
| 1322 |
+
The maximum data that can be sent in a single data frame on a stream
|
| 1323 |
+
is either this value, or the maximum frame size, whichever is
|
| 1324 |
+
*smaller*.
|
| 1325 |
+
|
| 1326 |
+
:param stream_id: The ID of the stream whose flow control window is
|
| 1327 |
+
being queried.
|
| 1328 |
+
:type stream_id: ``int``
|
| 1329 |
+
:returns: The amount of data in bytes that can be received on the
|
| 1330 |
+
stream before the flow control window is exhausted.
|
| 1331 |
+
:rtype: ``int``
|
| 1332 |
+
"""
|
| 1333 |
+
stream = self._get_stream_by_id(stream_id)
|
| 1334 |
+
return min(
|
| 1335 |
+
self.inbound_flow_control_window,
|
| 1336 |
+
stream.inbound_flow_control_window,
|
| 1337 |
+
)
|
| 1338 |
+
|
| 1339 |
+
def acknowledge_received_data(self, acknowledged_size: int, stream_id: int) -> None:
|
| 1340 |
+
"""
|
| 1341 |
+
Inform the :class:`H2Connection <h2.connection.H2Connection>` that a
|
| 1342 |
+
certain number of flow-controlled bytes have been processed, and that
|
| 1343 |
+
the space should be handed back to the remote peer at an opportune
|
| 1344 |
+
time.
|
| 1345 |
+
|
| 1346 |
+
.. versionadded:: 2.5.0
|
| 1347 |
+
|
| 1348 |
+
:param acknowledged_size: The total *flow-controlled size* of the data
|
| 1349 |
+
that has been processed. Note that this must include the amount of
|
| 1350 |
+
padding that was sent with that data.
|
| 1351 |
+
:type acknowledged_size: ``int``
|
| 1352 |
+
:param stream_id: The ID of the stream on which this data was received.
|
| 1353 |
+
:type stream_id: ``int``
|
| 1354 |
+
:returns: Nothing
|
| 1355 |
+
:rtype: ``None``
|
| 1356 |
+
"""
|
| 1357 |
+
self.config.logger.debug(
|
| 1358 |
+
"Ack received data on stream ID %d with size %d",
|
| 1359 |
+
stream_id, acknowledged_size,
|
| 1360 |
+
)
|
| 1361 |
+
if stream_id <= 0:
|
| 1362 |
+
msg = f"Stream ID {stream_id} is not valid for acknowledge_received_data"
|
| 1363 |
+
raise ValueError(msg)
|
| 1364 |
+
if acknowledged_size < 0:
|
| 1365 |
+
msg = "Cannot acknowledge negative data"
|
| 1366 |
+
raise ValueError(msg)
|
| 1367 |
+
|
| 1368 |
+
frames: list[Frame] = []
|
| 1369 |
+
|
| 1370 |
+
conn_manager = self._inbound_flow_control_window_manager
|
| 1371 |
+
conn_increment = conn_manager.process_bytes(acknowledged_size)
|
| 1372 |
+
if conn_increment:
|
| 1373 |
+
f = WindowUpdateFrame(0)
|
| 1374 |
+
f.window_increment = conn_increment
|
| 1375 |
+
frames.append(f)
|
| 1376 |
+
|
| 1377 |
+
try:
|
| 1378 |
+
stream = self._get_stream_by_id(stream_id)
|
| 1379 |
+
except StreamClosedError:
|
| 1380 |
+
# The stream is already gone. We're not worried about incrementing
|
| 1381 |
+
# the window in this case.
|
| 1382 |
+
pass
|
| 1383 |
+
else:
|
| 1384 |
+
# No point incrementing the windows of closed streams.
|
| 1385 |
+
if stream.open:
|
| 1386 |
+
frames.extend(
|
| 1387 |
+
stream.acknowledge_received_data(acknowledged_size),
|
| 1388 |
+
)
|
| 1389 |
+
|
| 1390 |
+
self._prepare_for_sending(frames)
|
| 1391 |
+
|
| 1392 |
+
def data_to_send(self, amount: int | None = None) -> bytes:
|
| 1393 |
+
"""
|
| 1394 |
+
Returns some data for sending out of the internal data buffer.
|
| 1395 |
+
|
| 1396 |
+
This method is analogous to ``read`` on a file-like object, but it
|
| 1397 |
+
doesn't block. Instead, it returns as much data as the user asks for,
|
| 1398 |
+
or less if that much data is not available. It does not perform any
|
| 1399 |
+
I/O, and so uses a different name.
|
| 1400 |
+
|
| 1401 |
+
:param amount: (optional) The maximum amount of data to return. If not
|
| 1402 |
+
set, or set to ``None``, will return as much data as possible.
|
| 1403 |
+
:type amount: ``int``
|
| 1404 |
+
:returns: A bytestring containing the data to send on the wire.
|
| 1405 |
+
:rtype: ``bytes``
|
| 1406 |
+
"""
|
| 1407 |
+
if amount is None:
|
| 1408 |
+
data = bytes(self._data_to_send)
|
| 1409 |
+
self._data_to_send = bytearray()
|
| 1410 |
+
return data
|
| 1411 |
+
data = bytes(self._data_to_send[:amount])
|
| 1412 |
+
self._data_to_send = self._data_to_send[amount:]
|
| 1413 |
+
return data
|
| 1414 |
+
|
| 1415 |
+
def clear_outbound_data_buffer(self) -> None:
|
| 1416 |
+
"""
|
| 1417 |
+
Clears the outbound data buffer, such that if this call was immediately
|
| 1418 |
+
followed by a call to
|
| 1419 |
+
:meth:`data_to_send <h2.connection.H2Connection.data_to_send>`, that
|
| 1420 |
+
call would return no data.
|
| 1421 |
+
|
| 1422 |
+
This method should not normally be used, but is made available to avoid
|
| 1423 |
+
exposing implementation details.
|
| 1424 |
+
"""
|
| 1425 |
+
self._data_to_send = bytearray()
|
| 1426 |
+
|
| 1427 |
+
def _acknowledge_settings(self) -> list[Frame]:
|
| 1428 |
+
"""
|
| 1429 |
+
Acknowledge settings that have been received.
|
| 1430 |
+
|
| 1431 |
+
.. versionchanged:: 2.0.0
|
| 1432 |
+
Removed from public API, removed useless ``event`` parameter, made
|
| 1433 |
+
automatic.
|
| 1434 |
+
|
| 1435 |
+
:returns: Nothing
|
| 1436 |
+
"""
|
| 1437 |
+
self.state_machine.process_input(ConnectionInputs.SEND_SETTINGS)
|
| 1438 |
+
|
| 1439 |
+
changes = self.remote_settings.acknowledge()
|
| 1440 |
+
|
| 1441 |
+
if SettingCodes.INITIAL_WINDOW_SIZE in changes:
|
| 1442 |
+
setting = changes[SettingCodes.INITIAL_WINDOW_SIZE]
|
| 1443 |
+
self._flow_control_change_from_settings(
|
| 1444 |
+
setting.original_value,
|
| 1445 |
+
setting.new_value,
|
| 1446 |
+
)
|
| 1447 |
+
|
| 1448 |
+
# HEADER_TABLE_SIZE changes by the remote part affect our encoder: cf.
|
| 1449 |
+
# RFC 7540 Section 6.5.2.
|
| 1450 |
+
if SettingCodes.HEADER_TABLE_SIZE in changes:
|
| 1451 |
+
setting = changes[SettingCodes.HEADER_TABLE_SIZE]
|
| 1452 |
+
self.encoder.header_table_size = setting.new_value
|
| 1453 |
+
|
| 1454 |
+
if SettingCodes.MAX_FRAME_SIZE in changes:
|
| 1455 |
+
setting = changes[SettingCodes.MAX_FRAME_SIZE]
|
| 1456 |
+
self.max_outbound_frame_size = setting.new_value
|
| 1457 |
+
for stream in self.streams.values():
|
| 1458 |
+
stream.max_outbound_frame_size = setting.new_value
|
| 1459 |
+
|
| 1460 |
+
f = SettingsFrame(0)
|
| 1461 |
+
f.flags.add("ACK")
|
| 1462 |
+
return [f]
|
| 1463 |
+
|
| 1464 |
+
def _flow_control_change_from_settings(self, old_value: int | None, new_value: int) -> None:
|
| 1465 |
+
"""
|
| 1466 |
+
Update flow control windows in response to a change in the value of
|
| 1467 |
+
SETTINGS_INITIAL_WINDOW_SIZE.
|
| 1468 |
+
|
| 1469 |
+
When this setting is changed, it automatically updates all flow control
|
| 1470 |
+
windows by the delta in the settings values. Note that it does not
|
| 1471 |
+
increment the *connection* flow control window, per section 6.9.2 of
|
| 1472 |
+
RFC 7540.
|
| 1473 |
+
"""
|
| 1474 |
+
delta = new_value - (old_value or 0)
|
| 1475 |
+
|
| 1476 |
+
for stream in self.streams.values():
|
| 1477 |
+
stream.outbound_flow_control_window = guard_increment_window(
|
| 1478 |
+
stream.outbound_flow_control_window,
|
| 1479 |
+
delta,
|
| 1480 |
+
)
|
| 1481 |
+
|
| 1482 |
+
def _inbound_flow_control_change_from_settings(self, old_value: int | None, new_value: int) -> None:
|
| 1483 |
+
"""
|
| 1484 |
+
Update remote flow control windows in response to a change in the value
|
| 1485 |
+
of SETTINGS_INITIAL_WINDOW_SIZE.
|
| 1486 |
+
|
| 1487 |
+
When this setting is changed, it automatically updates all remote flow
|
| 1488 |
+
control windows by the delta in the settings values.
|
| 1489 |
+
"""
|
| 1490 |
+
delta = new_value - (old_value or 0)
|
| 1491 |
+
|
| 1492 |
+
for stream in self.streams.values():
|
| 1493 |
+
stream._inbound_flow_control_change_from_settings(delta)
|
| 1494 |
+
|
| 1495 |
+
def receive_data(self, data: bytes) -> list[Event]:
|
| 1496 |
+
"""
|
| 1497 |
+
Pass some received HTTP/2 data to the connection for handling.
|
| 1498 |
+
|
| 1499 |
+
:param data: The data received from the remote peer on the network.
|
| 1500 |
+
:type data: ``bytes``
|
| 1501 |
+
:returns: A list of events that the remote peer triggered by sending
|
| 1502 |
+
this data.
|
| 1503 |
+
"""
|
| 1504 |
+
self.config.logger.trace(
|
| 1505 |
+
"Process received data on connection. Received data: %r", data,
|
| 1506 |
+
)
|
| 1507 |
+
|
| 1508 |
+
events: list[Event] = []
|
| 1509 |
+
self.incoming_buffer.add_data(data)
|
| 1510 |
+
self.incoming_buffer.max_frame_size = self.max_inbound_frame_size
|
| 1511 |
+
|
| 1512 |
+
try:
|
| 1513 |
+
for frame in self.incoming_buffer:
|
| 1514 |
+
events.extend(self._receive_frame(frame))
|
| 1515 |
+
except InvalidPaddingError as e:
|
| 1516 |
+
self._terminate_connection(ErrorCodes.PROTOCOL_ERROR)
|
| 1517 |
+
msg = "Received frame with invalid padding."
|
| 1518 |
+
raise ProtocolError(msg) from e
|
| 1519 |
+
except ProtocolError as e:
|
| 1520 |
+
# For whatever reason, receiving the frame caused a protocol error.
|
| 1521 |
+
# We should prepare to emit a GoAway frame before throwing the
|
| 1522 |
+
# exception up further. No need for an event: the exception will
|
| 1523 |
+
# do fine.
|
| 1524 |
+
self._terminate_connection(e.error_code)
|
| 1525 |
+
raise
|
| 1526 |
+
|
| 1527 |
+
return events
|
| 1528 |
+
|
| 1529 |
+
def _receive_frame(self, frame: Frame) -> list[Event]:
|
| 1530 |
+
"""
|
| 1531 |
+
Handle a frame received on the connection.
|
| 1532 |
+
|
| 1533 |
+
.. versionchanged:: 2.0.0
|
| 1534 |
+
Removed from the public API.
|
| 1535 |
+
"""
|
| 1536 |
+
events: list[Event]
|
| 1537 |
+
self.config.logger.trace("Received frame: %s", repr(frame))
|
| 1538 |
+
try:
|
| 1539 |
+
# I don't love using __class__ here, maybe reconsider it.
|
| 1540 |
+
frames, events = self._frame_dispatch_table[frame.__class__](frame)
|
| 1541 |
+
except StreamClosedError as e:
|
| 1542 |
+
# If the stream was closed by RST_STREAM, we just send a RST_STREAM
|
| 1543 |
+
# to the remote peer. Otherwise, this is a connection error, and so
|
| 1544 |
+
# we will re-raise to trigger one.
|
| 1545 |
+
if self._stream_is_closed_by_reset(e.stream_id):
|
| 1546 |
+
f = RstStreamFrame(e.stream_id)
|
| 1547 |
+
f.error_code = e.error_code
|
| 1548 |
+
self._prepare_for_sending([f])
|
| 1549 |
+
events = e._events
|
| 1550 |
+
else:
|
| 1551 |
+
raise
|
| 1552 |
+
except StreamIDTooLowError as e:
|
| 1553 |
+
# The stream ID seems invalid. This may happen when the closed
|
| 1554 |
+
# stream has been cleaned up, or when the remote peer has opened a
|
| 1555 |
+
# new stream with a higher stream ID than this one, forcing it
|
| 1556 |
+
# closed implicitly.
|
| 1557 |
+
#
|
| 1558 |
+
# Check how the stream was closed: depending on the mechanism, it
|
| 1559 |
+
# is either a stream error or a connection error.
|
| 1560 |
+
if self._stream_is_closed_by_reset(e.stream_id):
|
| 1561 |
+
# Closed by RST_STREAM is a stream error.
|
| 1562 |
+
f = RstStreamFrame(e.stream_id)
|
| 1563 |
+
f.error_code = ErrorCodes.STREAM_CLOSED
|
| 1564 |
+
self._prepare_for_sending([f])
|
| 1565 |
+
events = []
|
| 1566 |
+
elif self._stream_is_closed_by_end(e.stream_id):
|
| 1567 |
+
# Closed by END_STREAM is a connection error.
|
| 1568 |
+
raise StreamClosedError(e.stream_id) from e
|
| 1569 |
+
else:
|
| 1570 |
+
# Closed implicitly, also a connection error, but of type
|
| 1571 |
+
# PROTOCOL_ERROR.
|
| 1572 |
+
raise
|
| 1573 |
+
else:
|
| 1574 |
+
self._prepare_for_sending(frames)
|
| 1575 |
+
|
| 1576 |
+
return events
|
| 1577 |
+
|
| 1578 |
+
def _terminate_connection(self, error_code: ErrorCodes) -> None:
|
| 1579 |
+
"""
|
| 1580 |
+
Terminate the connection early. Used in error handling blocks to send
|
| 1581 |
+
GOAWAY frames.
|
| 1582 |
+
"""
|
| 1583 |
+
f = GoAwayFrame(0)
|
| 1584 |
+
f.last_stream_id = self.highest_inbound_stream_id
|
| 1585 |
+
f.error_code = error_code
|
| 1586 |
+
self.state_machine.process_input(ConnectionInputs.SEND_GOAWAY)
|
| 1587 |
+
self._prepare_for_sending([f])
|
| 1588 |
+
|
| 1589 |
+
def _receive_headers_frame(self, frame: HeadersFrame) -> tuple[list[Frame], list[Event]]:
|
| 1590 |
+
"""
|
| 1591 |
+
Receive a headers frame on the connection.
|
| 1592 |
+
"""
|
| 1593 |
+
# If necessary, check we can open the stream. Also validate that the
|
| 1594 |
+
# stream ID is valid.
|
| 1595 |
+
if frame.stream_id not in self.streams:
|
| 1596 |
+
max_open_streams = self.local_settings.max_concurrent_streams
|
| 1597 |
+
value = self.open_inbound_streams # take a copy due to the property accessor having side affects
|
| 1598 |
+
if (value + 1) > max_open_streams:
|
| 1599 |
+
msg = f"Max inbound streams is {max_open_streams}, {value} open"
|
| 1600 |
+
raise TooManyStreamsError(msg)
|
| 1601 |
+
|
| 1602 |
+
# Let's decode the headers. We handle headers as bytes internally up
|
| 1603 |
+
# until we hang them off the event, at which point we may optionally
|
| 1604 |
+
# convert them to unicode.
|
| 1605 |
+
headers = _decode_headers(self.decoder, frame.data)
|
| 1606 |
+
|
| 1607 |
+
events = self.state_machine.process_input(
|
| 1608 |
+
ConnectionInputs.RECV_HEADERS,
|
| 1609 |
+
)
|
| 1610 |
+
stream = self._get_or_create_stream(
|
| 1611 |
+
frame.stream_id, AllowedStreamIDs(not self.config.client_side),
|
| 1612 |
+
)
|
| 1613 |
+
frames, stream_events = stream.receive_headers(
|
| 1614 |
+
headers,
|
| 1615 |
+
"END_STREAM" in frame.flags,
|
| 1616 |
+
self.config.header_encoding,
|
| 1617 |
+
)
|
| 1618 |
+
|
| 1619 |
+
if "PRIORITY" in frame.flags:
|
| 1620 |
+
p_frames, p_events = self._receive_priority_frame(frame)
|
| 1621 |
+
expected_frame_types = (RequestReceived, ResponseReceived, TrailersReceived, InformationalResponseReceived)
|
| 1622 |
+
assert isinstance(stream_events[0], expected_frame_types)
|
| 1623 |
+
assert isinstance(p_events[0], PriorityUpdated)
|
| 1624 |
+
stream_events[0].priority_updated = p_events[0]
|
| 1625 |
+
stream_events.extend(p_events)
|
| 1626 |
+
assert not p_frames
|
| 1627 |
+
|
| 1628 |
+
return frames, events + stream_events
|
| 1629 |
+
|
| 1630 |
+
def _receive_push_promise_frame(self, frame: PushPromiseFrame) -> tuple[list[Frame], list[Event]]:
|
| 1631 |
+
"""
|
| 1632 |
+
Receive a push-promise frame on the connection.
|
| 1633 |
+
"""
|
| 1634 |
+
if not self.local_settings.enable_push:
|
| 1635 |
+
msg = "Received pushed stream"
|
| 1636 |
+
raise ProtocolError(msg)
|
| 1637 |
+
|
| 1638 |
+
pushed_headers = _decode_headers(self.decoder, frame.data)
|
| 1639 |
+
|
| 1640 |
+
events = self.state_machine.process_input(
|
| 1641 |
+
ConnectionInputs.RECV_PUSH_PROMISE,
|
| 1642 |
+
)
|
| 1643 |
+
|
| 1644 |
+
try:
|
| 1645 |
+
stream = self._get_stream_by_id(frame.stream_id)
|
| 1646 |
+
except NoSuchStreamError as e:
|
| 1647 |
+
# We need to check if the parent stream was reset by us. If it was
|
| 1648 |
+
# then we presume that the PUSH_PROMISE was in flight when we reset
|
| 1649 |
+
# the parent stream. Rather than accept the new stream, just reset
|
| 1650 |
+
# it.
|
| 1651 |
+
#
|
| 1652 |
+
# If this was closed naturally, however, we should call this a
|
| 1653 |
+
# PROTOCOL_ERROR: pushing a stream on a naturally closed stream is
|
| 1654 |
+
# a real problem because it creates a brand new stream that the
|
| 1655 |
+
# remote peer now believes exists.
|
| 1656 |
+
if (self._stream_closed_by(frame.stream_id) ==
|
| 1657 |
+
StreamClosedBy.SEND_RST_STREAM):
|
| 1658 |
+
f = RstStreamFrame(frame.promised_stream_id)
|
| 1659 |
+
f.error_code = ErrorCodes.REFUSED_STREAM
|
| 1660 |
+
return [f], events
|
| 1661 |
+
|
| 1662 |
+
msg = "Attempted to push on closed stream."
|
| 1663 |
+
raise ProtocolError(msg) from e
|
| 1664 |
+
|
| 1665 |
+
# We need to prevent peers pushing streams in response to streams that
|
| 1666 |
+
# they themselves have already pushed: see #163 and RFC 7540 § 6.6. The
|
| 1667 |
+
# easiest way to do that is to assert that the stream_id is not even:
|
| 1668 |
+
# this shortcut works because only servers can push and the state
|
| 1669 |
+
# machine will enforce this.
|
| 1670 |
+
if (frame.stream_id % 2) == 0:
|
| 1671 |
+
msg = "Cannot recursively push streams."
|
| 1672 |
+
raise ProtocolError(msg)
|
| 1673 |
+
|
| 1674 |
+
try:
|
| 1675 |
+
frames, stream_events = stream.receive_push_promise_in_band(
|
| 1676 |
+
frame.promised_stream_id,
|
| 1677 |
+
pushed_headers,
|
| 1678 |
+
self.config.header_encoding,
|
| 1679 |
+
)
|
| 1680 |
+
except StreamClosedError:
|
| 1681 |
+
# The parent stream was reset by us, so we presume that
|
| 1682 |
+
# PUSH_PROMISE was in flight when we reset the parent stream.
|
| 1683 |
+
# So we just reset the new stream.
|
| 1684 |
+
f = RstStreamFrame(frame.promised_stream_id)
|
| 1685 |
+
f.error_code = ErrorCodes.REFUSED_STREAM
|
| 1686 |
+
return [f], events
|
| 1687 |
+
|
| 1688 |
+
new_stream = self._begin_new_stream(
|
| 1689 |
+
frame.promised_stream_id, AllowedStreamIDs.EVEN,
|
| 1690 |
+
)
|
| 1691 |
+
self.streams[frame.promised_stream_id] = new_stream
|
| 1692 |
+
new_stream.remotely_pushed(pushed_headers)
|
| 1693 |
+
|
| 1694 |
+
return frames, events + stream_events
|
| 1695 |
+
|
| 1696 |
+
def _handle_data_on_closed_stream(self,
|
| 1697 |
+
events: list[Event],
|
| 1698 |
+
exc: StreamClosedError,
|
| 1699 |
+
frame: DataFrame) -> tuple[list[Frame], list[Event]]:
|
| 1700 |
+
# This stream is already closed - and yet we received a DATA frame.
|
| 1701 |
+
# The received DATA frame counts towards the connection flow window.
|
| 1702 |
+
# We need to manually to acknowledge the DATA frame to update the flow
|
| 1703 |
+
# window of the connection. Otherwise the whole connection stalls due
|
| 1704 |
+
# the inbound flow window being 0.
|
| 1705 |
+
frames: list[Frame] = []
|
| 1706 |
+
conn_manager = self._inbound_flow_control_window_manager
|
| 1707 |
+
conn_increment = conn_manager.process_bytes(
|
| 1708 |
+
frame.flow_controlled_length,
|
| 1709 |
+
)
|
| 1710 |
+
|
| 1711 |
+
if conn_increment:
|
| 1712 |
+
window_update_frame = WindowUpdateFrame(0)
|
| 1713 |
+
window_update_frame.window_increment = conn_increment
|
| 1714 |
+
frames.append(window_update_frame)
|
| 1715 |
+
self.config.logger.debug(
|
| 1716 |
+
"Received DATA frame on closed stream %d - "
|
| 1717 |
+
"auto-emitted a WINDOW_UPDATE by %d",
|
| 1718 |
+
frame.stream_id, conn_increment,
|
| 1719 |
+
)
|
| 1720 |
+
|
| 1721 |
+
rst_stream_frame = RstStreamFrame(exc.stream_id)
|
| 1722 |
+
rst_stream_frame.error_code = exc.error_code
|
| 1723 |
+
frames.append(rst_stream_frame)
|
| 1724 |
+
self.config.logger.debug(
|
| 1725 |
+
"Stream %s already CLOSED or cleaned up - auto-emitted a RST_FRAME",
|
| 1726 |
+
frame.stream_id,
|
| 1727 |
+
)
|
| 1728 |
+
return frames, events + exc._events
|
| 1729 |
+
|
| 1730 |
+
def _receive_data_frame(self, frame: DataFrame) -> tuple[list[Frame], list[Event]]:
|
| 1731 |
+
"""
|
| 1732 |
+
Receive a data frame on the connection.
|
| 1733 |
+
"""
|
| 1734 |
+
flow_controlled_length = frame.flow_controlled_length
|
| 1735 |
+
|
| 1736 |
+
events = self.state_machine.process_input(
|
| 1737 |
+
ConnectionInputs.RECV_DATA,
|
| 1738 |
+
)
|
| 1739 |
+
self._inbound_flow_control_window_manager.window_consumed(
|
| 1740 |
+
flow_controlled_length,
|
| 1741 |
+
)
|
| 1742 |
+
|
| 1743 |
+
try:
|
| 1744 |
+
stream = self._get_stream_by_id(frame.stream_id)
|
| 1745 |
+
frames, stream_events = stream.receive_data(
|
| 1746 |
+
frame.data,
|
| 1747 |
+
"END_STREAM" in frame.flags,
|
| 1748 |
+
flow_controlled_length,
|
| 1749 |
+
)
|
| 1750 |
+
except StreamClosedError as e:
|
| 1751 |
+
# This stream is either marked as CLOSED or already gone from our
|
| 1752 |
+
# internal state.
|
| 1753 |
+
return self._handle_data_on_closed_stream(events, e, frame)
|
| 1754 |
+
|
| 1755 |
+
return frames, events + stream_events
|
| 1756 |
+
|
| 1757 |
+
def _receive_settings_frame(self, frame: SettingsFrame) -> tuple[list[Frame], list[Event]]:
|
| 1758 |
+
"""
|
| 1759 |
+
Receive a SETTINGS frame on the connection.
|
| 1760 |
+
"""
|
| 1761 |
+
events = self.state_machine.process_input(
|
| 1762 |
+
ConnectionInputs.RECV_SETTINGS,
|
| 1763 |
+
)
|
| 1764 |
+
|
| 1765 |
+
# This is an ack of the local settings.
|
| 1766 |
+
if "ACK" in frame.flags:
|
| 1767 |
+
changed_settings = self._local_settings_acked()
|
| 1768 |
+
ack_event = SettingsAcknowledged()
|
| 1769 |
+
ack_event.changed_settings = changed_settings
|
| 1770 |
+
events.append(ack_event)
|
| 1771 |
+
return [], events
|
| 1772 |
+
|
| 1773 |
+
# Add the new settings.
|
| 1774 |
+
self.remote_settings.update(frame.settings)
|
| 1775 |
+
events.append(
|
| 1776 |
+
RemoteSettingsChanged.from_settings(
|
| 1777 |
+
self.remote_settings, frame.settings,
|
| 1778 |
+
),
|
| 1779 |
+
)
|
| 1780 |
+
frames = self._acknowledge_settings()
|
| 1781 |
+
|
| 1782 |
+
return frames, events
|
| 1783 |
+
|
| 1784 |
+
def _receive_window_update_frame(self, frame: WindowUpdateFrame) -> tuple[list[Frame], list[Event]]:
|
| 1785 |
+
"""
|
| 1786 |
+
Receive a WINDOW_UPDATE frame on the connection.
|
| 1787 |
+
"""
|
| 1788 |
+
# hyperframe will take care of validating the window_increment.
|
| 1789 |
+
# If we reach in here, we can assume a valid value.
|
| 1790 |
+
|
| 1791 |
+
events = self.state_machine.process_input(
|
| 1792 |
+
ConnectionInputs.RECV_WINDOW_UPDATE,
|
| 1793 |
+
)
|
| 1794 |
+
|
| 1795 |
+
if frame.stream_id:
|
| 1796 |
+
try:
|
| 1797 |
+
stream = self._get_stream_by_id(frame.stream_id)
|
| 1798 |
+
frames, stream_events = stream.receive_window_update(
|
| 1799 |
+
frame.window_increment,
|
| 1800 |
+
)
|
| 1801 |
+
except StreamClosedError:
|
| 1802 |
+
return [], events
|
| 1803 |
+
else:
|
| 1804 |
+
# Increment our local flow control window.
|
| 1805 |
+
self.outbound_flow_control_window = guard_increment_window(
|
| 1806 |
+
self.outbound_flow_control_window,
|
| 1807 |
+
frame.window_increment,
|
| 1808 |
+
)
|
| 1809 |
+
|
| 1810 |
+
# FIXME: Should we split this into one event per active stream?
|
| 1811 |
+
window_updated_event = WindowUpdated(stream_id=0, delta=frame.window_increment)
|
| 1812 |
+
stream_events = [window_updated_event]
|
| 1813 |
+
frames = []
|
| 1814 |
+
|
| 1815 |
+
return frames, events + stream_events
|
| 1816 |
+
|
| 1817 |
+
def _receive_ping_frame(self, frame: PingFrame) -> tuple[list[Frame], list[Event]]:
|
| 1818 |
+
"""
|
| 1819 |
+
Receive a PING frame on the connection.
|
| 1820 |
+
"""
|
| 1821 |
+
events = self.state_machine.process_input(
|
| 1822 |
+
ConnectionInputs.RECV_PING,
|
| 1823 |
+
)
|
| 1824 |
+
frames: list[Frame] = []
|
| 1825 |
+
|
| 1826 |
+
evt: PingReceived | PingAckReceived
|
| 1827 |
+
if "ACK" in frame.flags:
|
| 1828 |
+
evt = PingAckReceived(ping_data=frame.opaque_data)
|
| 1829 |
+
else:
|
| 1830 |
+
evt = PingReceived(ping_data=frame.opaque_data)
|
| 1831 |
+
|
| 1832 |
+
# automatically ACK the PING with the same 'opaque data'
|
| 1833 |
+
f = PingFrame(0)
|
| 1834 |
+
f.flags.add("ACK")
|
| 1835 |
+
f.opaque_data = frame.opaque_data
|
| 1836 |
+
frames.append(f)
|
| 1837 |
+
|
| 1838 |
+
events.append(evt)
|
| 1839 |
+
|
| 1840 |
+
return frames, events
|
| 1841 |
+
|
| 1842 |
+
def _receive_rst_stream_frame(self, frame: RstStreamFrame) -> tuple[list[Frame], list[Event]]:
|
| 1843 |
+
"""
|
| 1844 |
+
Receive a RST_STREAM frame on the connection.
|
| 1845 |
+
"""
|
| 1846 |
+
events = self.state_machine.process_input(
|
| 1847 |
+
ConnectionInputs.RECV_RST_STREAM,
|
| 1848 |
+
)
|
| 1849 |
+
try:
|
| 1850 |
+
stream = self._get_stream_by_id(frame.stream_id)
|
| 1851 |
+
except NoSuchStreamError:
|
| 1852 |
+
# The stream is missing. That's ok, we just do nothing here.
|
| 1853 |
+
stream_frames: list[Frame] = []
|
| 1854 |
+
stream_events: list[Event] = []
|
| 1855 |
+
else:
|
| 1856 |
+
stream_frames, stream_events = stream.stream_reset(frame)
|
| 1857 |
+
|
| 1858 |
+
return stream_frames, events + stream_events
|
| 1859 |
+
|
| 1860 |
+
def _receive_priority_frame(self, frame: HeadersFrame | PriorityFrame) -> tuple[list[Frame], list[Event]]:
|
| 1861 |
+
"""
|
| 1862 |
+
Receive a PRIORITY frame on the connection.
|
| 1863 |
+
"""
|
| 1864 |
+
events = self.state_machine.process_input(
|
| 1865 |
+
ConnectionInputs.RECV_PRIORITY,
|
| 1866 |
+
)
|
| 1867 |
+
|
| 1868 |
+
event = PriorityUpdated()
|
| 1869 |
+
event.stream_id = frame.stream_id
|
| 1870 |
+
event.depends_on = frame.depends_on
|
| 1871 |
+
event.exclusive = frame.exclusive
|
| 1872 |
+
|
| 1873 |
+
# Weight is an integer between 1 and 256, but the byte only allows
|
| 1874 |
+
# 0 to 255: add one.
|
| 1875 |
+
event.weight = frame.stream_weight + 1
|
| 1876 |
+
|
| 1877 |
+
# A stream may not depend on itself.
|
| 1878 |
+
if event.depends_on == frame.stream_id:
|
| 1879 |
+
msg = f"Stream {frame.stream_id} may not depend on itself"
|
| 1880 |
+
raise ProtocolError(msg)
|
| 1881 |
+
events.append(event)
|
| 1882 |
+
|
| 1883 |
+
return [], events
|
| 1884 |
+
|
| 1885 |
+
def _receive_goaway_frame(self, frame: GoAwayFrame) -> tuple[list[Frame], list[Event]]:
|
| 1886 |
+
"""
|
| 1887 |
+
Receive a GOAWAY frame on the connection.
|
| 1888 |
+
"""
|
| 1889 |
+
events = self.state_machine.process_input(
|
| 1890 |
+
ConnectionInputs.RECV_GOAWAY,
|
| 1891 |
+
)
|
| 1892 |
+
|
| 1893 |
+
# Clear the outbound data buffer: we cannot send further data now.
|
| 1894 |
+
self.clear_outbound_data_buffer()
|
| 1895 |
+
|
| 1896 |
+
# Fire an appropriate ConnectionTerminated event.
|
| 1897 |
+
new_event = ConnectionTerminated()
|
| 1898 |
+
new_event.error_code = _error_code_from_int(frame.error_code)
|
| 1899 |
+
new_event.last_stream_id = frame.last_stream_id
|
| 1900 |
+
new_event.additional_data = (frame.additional_data
|
| 1901 |
+
if frame.additional_data else None)
|
| 1902 |
+
events.append(new_event)
|
| 1903 |
+
|
| 1904 |
+
return [], events
|
| 1905 |
+
|
| 1906 |
+
def _receive_naked_continuation(self, frame: ContinuationFrame) -> None:
|
| 1907 |
+
"""
|
| 1908 |
+
A naked CONTINUATION frame has been received. This is always an error,
|
| 1909 |
+
but the type of error it is depends on the state of the stream and must
|
| 1910 |
+
transition the state of the stream, so we need to pass it to the
|
| 1911 |
+
appropriate stream.
|
| 1912 |
+
"""
|
| 1913 |
+
stream = self._get_stream_by_id(frame.stream_id)
|
| 1914 |
+
stream.receive_continuation()
|
| 1915 |
+
msg = "Should not be reachable" # pragma: no cover
|
| 1916 |
+
raise AssertionError(msg) # pragma: no cover
|
| 1917 |
+
|
| 1918 |
+
def _receive_alt_svc_frame(self, frame: AltSvcFrame) -> tuple[list[Frame], list[Event]]:
|
| 1919 |
+
"""
|
| 1920 |
+
An ALTSVC frame has been received. This frame, specified in RFC 7838,
|
| 1921 |
+
is used to advertise alternative places where the same service can be
|
| 1922 |
+
reached.
|
| 1923 |
+
|
| 1924 |
+
This frame can optionally be received either on a stream or on stream
|
| 1925 |
+
0, and its semantics are different in each case.
|
| 1926 |
+
"""
|
| 1927 |
+
events = self.state_machine.process_input(
|
| 1928 |
+
ConnectionInputs.RECV_ALTERNATIVE_SERVICE,
|
| 1929 |
+
)
|
| 1930 |
+
frames = []
|
| 1931 |
+
|
| 1932 |
+
if frame.stream_id:
|
| 1933 |
+
# Given that it makes no sense to receive ALTSVC on a stream
|
| 1934 |
+
# before that stream has been opened with a HEADERS frame, the
|
| 1935 |
+
# ALTSVC frame cannot create a stream. If the stream is not
|
| 1936 |
+
# present, we simply ignore the frame.
|
| 1937 |
+
try:
|
| 1938 |
+
stream = self._get_stream_by_id(frame.stream_id)
|
| 1939 |
+
except (NoSuchStreamError, StreamClosedError):
|
| 1940 |
+
pass
|
| 1941 |
+
else:
|
| 1942 |
+
stream_frames, stream_events = stream.receive_alt_svc(frame)
|
| 1943 |
+
frames.extend(stream_frames)
|
| 1944 |
+
events.extend(stream_events)
|
| 1945 |
+
else:
|
| 1946 |
+
# This frame is sent on stream 0. The origin field on the frame
|
| 1947 |
+
# must be present, though if it isn't it's not a ProtocolError
|
| 1948 |
+
# (annoyingly), we just need to ignore it.
|
| 1949 |
+
if not frame.origin:
|
| 1950 |
+
return frames, events
|
| 1951 |
+
|
| 1952 |
+
# If we're a server, we want to ignore this (RFC 7838 says so).
|
| 1953 |
+
if not self.config.client_side:
|
| 1954 |
+
return frames, events
|
| 1955 |
+
|
| 1956 |
+
event = AlternativeServiceAvailable()
|
| 1957 |
+
event.origin = frame.origin
|
| 1958 |
+
event.field_value = frame.field
|
| 1959 |
+
events.append(event)
|
| 1960 |
+
|
| 1961 |
+
return frames, events
|
| 1962 |
+
|
| 1963 |
+
def _receive_unknown_frame(self, frame: ExtensionFrame) -> tuple[list[Frame], list[Event]]:
|
| 1964 |
+
"""
|
| 1965 |
+
We have received a frame that we do not understand. This is almost
|
| 1966 |
+
certainly an extension frame, though it's impossible to be entirely
|
| 1967 |
+
sure.
|
| 1968 |
+
|
| 1969 |
+
RFC 7540 § 5.5 says that we MUST ignore unknown frame types: so we
|
| 1970 |
+
do. We do notify the user that we received one, however.
|
| 1971 |
+
"""
|
| 1972 |
+
# All we do here is log.
|
| 1973 |
+
self.config.logger.debug(
|
| 1974 |
+
"Received unknown extension frame (ID %d)", frame.stream_id,
|
| 1975 |
+
)
|
| 1976 |
+
event = UnknownFrameReceived(frame=frame)
|
| 1977 |
+
return [], [event]
|
| 1978 |
+
|
| 1979 |
+
def _local_settings_acked(self) -> dict[SettingCodes | int, ChangedSetting]:
|
| 1980 |
+
"""
|
| 1981 |
+
Handle the local settings being ACKed, update internal state.
|
| 1982 |
+
"""
|
| 1983 |
+
changes = self.local_settings.acknowledge()
|
| 1984 |
+
|
| 1985 |
+
if SettingCodes.INITIAL_WINDOW_SIZE in changes:
|
| 1986 |
+
setting = changes[SettingCodes.INITIAL_WINDOW_SIZE]
|
| 1987 |
+
self._inbound_flow_control_change_from_settings(
|
| 1988 |
+
setting.original_value,
|
| 1989 |
+
setting.new_value,
|
| 1990 |
+
)
|
| 1991 |
+
|
| 1992 |
+
if SettingCodes.MAX_HEADER_LIST_SIZE in changes:
|
| 1993 |
+
setting = changes[SettingCodes.MAX_HEADER_LIST_SIZE]
|
| 1994 |
+
self.decoder.max_header_list_size = setting.new_value
|
| 1995 |
+
|
| 1996 |
+
if SettingCodes.MAX_FRAME_SIZE in changes:
|
| 1997 |
+
setting = changes[SettingCodes.MAX_FRAME_SIZE]
|
| 1998 |
+
self.max_inbound_frame_size = setting.new_value
|
| 1999 |
+
|
| 2000 |
+
if SettingCodes.HEADER_TABLE_SIZE in changes:
|
| 2001 |
+
setting = changes[SettingCodes.HEADER_TABLE_SIZE]
|
| 2002 |
+
# This is safe across all hpack versions: some versions just won't
|
| 2003 |
+
# respect it.
|
| 2004 |
+
self.decoder.max_allowed_table_size = setting.new_value
|
| 2005 |
+
|
| 2006 |
+
return changes
|
| 2007 |
+
|
| 2008 |
+
def _stream_id_is_outbound(self, stream_id: int) -> bool:
|
| 2009 |
+
"""
|
| 2010 |
+
Returns ``True`` if the stream ID corresponds to an outbound stream
|
| 2011 |
+
(one initiated by this peer), returns ``False`` otherwise.
|
| 2012 |
+
"""
|
| 2013 |
+
return (stream_id % 2 == int(self.config.client_side))
|
| 2014 |
+
|
| 2015 |
+
def _stream_closed_by(self, stream_id: int) -> StreamClosedBy | None:
|
| 2016 |
+
"""
|
| 2017 |
+
Returns how the stream was closed.
|
| 2018 |
+
|
| 2019 |
+
The return value will be either a member of
|
| 2020 |
+
``h2.stream.StreamClosedBy`` or ``None``. If ``None``, the stream was
|
| 2021 |
+
closed implicitly by the peer opening a stream with a higher stream ID
|
| 2022 |
+
before opening this one.
|
| 2023 |
+
"""
|
| 2024 |
+
if stream_id in self.streams:
|
| 2025 |
+
return self.streams[stream_id].closed_by
|
| 2026 |
+
if stream_id in self._closed_streams:
|
| 2027 |
+
return self._closed_streams[stream_id]
|
| 2028 |
+
return None
|
| 2029 |
+
|
| 2030 |
+
def _stream_is_closed_by_reset(self, stream_id: int) -> bool:
|
| 2031 |
+
"""
|
| 2032 |
+
Returns ``True`` if the stream was closed by sending or receiving a
|
| 2033 |
+
RST_STREAM frame. Returns ``False`` otherwise.
|
| 2034 |
+
"""
|
| 2035 |
+
return self._stream_closed_by(stream_id) in (
|
| 2036 |
+
StreamClosedBy.RECV_RST_STREAM, StreamClosedBy.SEND_RST_STREAM,
|
| 2037 |
+
)
|
| 2038 |
+
|
| 2039 |
+
def _stream_is_closed_by_end(self, stream_id: int) -> bool:
|
| 2040 |
+
"""
|
| 2041 |
+
Returns ``True`` if the stream was closed by sending or receiving an
|
| 2042 |
+
END_STREAM flag in a HEADERS or DATA frame. Returns ``False``
|
| 2043 |
+
otherwise.
|
| 2044 |
+
"""
|
| 2045 |
+
return self._stream_closed_by(stream_id) in (
|
| 2046 |
+
StreamClosedBy.RECV_END_STREAM, StreamClosedBy.SEND_END_STREAM,
|
| 2047 |
+
)
|
| 2048 |
+
|
| 2049 |
+
|
| 2050 |
+
def _add_frame_priority(frame: PriorityFrame | HeadersFrame,
|
| 2051 |
+
weight: int | None = None,
|
| 2052 |
+
depends_on: int | None = None,
|
| 2053 |
+
exclusive: bool | None = None) -> PriorityFrame | HeadersFrame:
|
| 2054 |
+
"""
|
| 2055 |
+
Adds priority data to a given frame. Does not change any flags set on that
|
| 2056 |
+
frame: if the caller is adding priority information to a HEADERS frame they
|
| 2057 |
+
must set that themselves.
|
| 2058 |
+
|
| 2059 |
+
This method also deliberately sets defaults for anything missing.
|
| 2060 |
+
|
| 2061 |
+
This method validates the input values.
|
| 2062 |
+
"""
|
| 2063 |
+
# A stream may not depend on itself.
|
| 2064 |
+
if depends_on == frame.stream_id:
|
| 2065 |
+
msg = f"Stream {frame.stream_id} may not depend on itself"
|
| 2066 |
+
raise ProtocolError(msg)
|
| 2067 |
+
|
| 2068 |
+
# Weight must be between 1 and 256.
|
| 2069 |
+
if weight is not None:
|
| 2070 |
+
if weight > 256 or weight < 1:
|
| 2071 |
+
msg = f"Weight must be between 1 and 256, not {weight}"
|
| 2072 |
+
raise ProtocolError(msg)
|
| 2073 |
+
# Weight is an integer between 1 and 256, but the byte only allows
|
| 2074 |
+
# 0 to 255: subtract one.
|
| 2075 |
+
weight -= 1
|
| 2076 |
+
|
| 2077 |
+
# Set defaults for anything not provided.
|
| 2078 |
+
weight = weight if weight is not None else 15
|
| 2079 |
+
depends_on = depends_on if depends_on is not None else 0
|
| 2080 |
+
exclusive = exclusive if exclusive is not None else False
|
| 2081 |
+
|
| 2082 |
+
frame.stream_weight = weight
|
| 2083 |
+
frame.depends_on = depends_on
|
| 2084 |
+
frame.exclusive = exclusive
|
| 2085 |
+
|
| 2086 |
+
return frame
|
| 2087 |
+
|
| 2088 |
+
|
| 2089 |
+
def _decode_headers(decoder: Decoder, encoded_header_block: bytes) -> Iterable[Header]:
|
| 2090 |
+
"""
|
| 2091 |
+
Decode a HPACK-encoded header block, translating HPACK exceptions into
|
| 2092 |
+
sensible h2 errors.
|
| 2093 |
+
|
| 2094 |
+
This only ever returns bytestring headers: h2 may emit them as
|
| 2095 |
+
unicode later, but internally it processes them as bytestrings only.
|
| 2096 |
+
"""
|
| 2097 |
+
try:
|
| 2098 |
+
return decoder.decode(encoded_header_block, raw=True)
|
| 2099 |
+
except OversizedHeaderListError as e:
|
| 2100 |
+
# This is a symptom of a HPACK bomb attack: the user has
|
| 2101 |
+
# disregarded our requirements on how large a header block we'll
|
| 2102 |
+
# accept.
|
| 2103 |
+
msg = f"Oversized header block: {e}"
|
| 2104 |
+
raise DenialOfServiceError(msg) from e
|
| 2105 |
+
except (HPACKError, IndexError, TypeError, UnicodeDecodeError) as e:
|
| 2106 |
+
# We should only need HPACKError here, but versions of HPACK older
|
| 2107 |
+
# than 2.1.0 throw all three others as well. For maximum
|
| 2108 |
+
# compatibility, catch all of them.
|
| 2109 |
+
msg = f"Error decoding header block: {e}"
|
| 2110 |
+
raise ProtocolError(msg) from e
|
bertvenv/lib/python3.10/site-packages/h2/events.py
ADDED
|
@@ -0,0 +1,679 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
h2/events
|
| 3 |
+
~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Defines Event types for HTTP/2.
|
| 6 |
+
|
| 7 |
+
Events are returned by the H2 state machine to allow implementations to keep
|
| 8 |
+
track of events triggered by receiving data. Each time data is provided to the
|
| 9 |
+
H2 state machine it processes the data and returns a list of Event objects.
|
| 10 |
+
"""
|
| 11 |
+
from __future__ import annotations
|
| 12 |
+
|
| 13 |
+
import binascii
|
| 14 |
+
import sys
|
| 15 |
+
from dataclasses import dataclass
|
| 16 |
+
from typing import TYPE_CHECKING, Any
|
| 17 |
+
|
| 18 |
+
from .settings import ChangedSetting, SettingCodes, Settings, _setting_code_from_int
|
| 19 |
+
|
| 20 |
+
if TYPE_CHECKING: # pragma: no cover
|
| 21 |
+
from hpack.struct import Header
|
| 22 |
+
from hyperframe.frame import Frame
|
| 23 |
+
|
| 24 |
+
from .errors import ErrorCodes
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
if sys.version_info < (3, 10): # pragma: no cover
|
| 28 |
+
kw_only: dict[str, bool] = {}
|
| 29 |
+
else: # pragma: no cover
|
| 30 |
+
kw_only = {"kw_only": True}
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
_LAZY_INIT: Any = object()
|
| 34 |
+
"""
|
| 35 |
+
Some h2 events are instantiated by the state machine, but its attributes are
|
| 36 |
+
subsequently populated by H2Stream. To make this work with strict type annotations
|
| 37 |
+
on the events, they are temporarily set to this placeholder value.
|
| 38 |
+
This value should never be exposed to users.
|
| 39 |
+
"""
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class Event:
|
| 43 |
+
"""
|
| 44 |
+
Base class for h2 events.
|
| 45 |
+
"""
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
@dataclass(**kw_only)
|
| 49 |
+
class RequestReceived(Event):
|
| 50 |
+
"""
|
| 51 |
+
The RequestReceived event is fired whenever all of a request's headers
|
| 52 |
+
are received. This event carries the HTTP headers for the given request
|
| 53 |
+
and the stream ID of the new stream.
|
| 54 |
+
|
| 55 |
+
In HTTP/2, headers may be sent as a HEADERS frame followed by zero or more
|
| 56 |
+
CONTINUATION frames with the final frame setting the END_HEADERS flag.
|
| 57 |
+
This event is fired after the entire sequence is received.
|
| 58 |
+
|
| 59 |
+
.. versionchanged:: 2.3.0
|
| 60 |
+
Changed the type of ``headers`` to :class:`HeaderTuple
|
| 61 |
+
<hpack:hpack.HeaderTuple>`. This has no effect on current users.
|
| 62 |
+
|
| 63 |
+
.. versionchanged:: 2.4.0
|
| 64 |
+
Added ``stream_ended`` and ``priority_updated`` properties.
|
| 65 |
+
"""
|
| 66 |
+
|
| 67 |
+
stream_id: int
|
| 68 |
+
"""The Stream ID for the stream this request was made on."""
|
| 69 |
+
|
| 70 |
+
headers: list[Header] = _LAZY_INIT
|
| 71 |
+
"""The request headers."""
|
| 72 |
+
|
| 73 |
+
stream_ended: StreamEnded | None = None
|
| 74 |
+
"""
|
| 75 |
+
If this request also ended the stream, the associated
|
| 76 |
+
:class:`StreamEnded <h2.events.StreamEnded>` event will be available
|
| 77 |
+
here.
|
| 78 |
+
|
| 79 |
+
.. versionadded:: 2.4.0
|
| 80 |
+
"""
|
| 81 |
+
|
| 82 |
+
priority_updated: PriorityUpdated | None = None
|
| 83 |
+
"""
|
| 84 |
+
If this request also had associated priority information, the
|
| 85 |
+
associated :class:`PriorityUpdated <h2.events.PriorityUpdated>`
|
| 86 |
+
event will be available here.
|
| 87 |
+
|
| 88 |
+
.. versionadded:: 2.4.0
|
| 89 |
+
"""
|
| 90 |
+
|
| 91 |
+
def __repr__(self) -> str:
|
| 92 |
+
return f"<RequestReceived stream_id:{self.stream_id}, headers:{self.headers}>"
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
@dataclass(**kw_only)
|
| 96 |
+
class ResponseReceived(Event):
|
| 97 |
+
"""
|
| 98 |
+
The ResponseReceived event is fired whenever response headers are received.
|
| 99 |
+
This event carries the HTTP headers for the given response and the stream
|
| 100 |
+
ID of the new stream.
|
| 101 |
+
|
| 102 |
+
.. versionchanged:: 2.3.0
|
| 103 |
+
Changed the type of ``headers`` to :class:`HeaderTuple
|
| 104 |
+
<hpack:hpack.HeaderTuple>`. This has no effect on current users.
|
| 105 |
+
|
| 106 |
+
.. versionchanged:: 2.4.0
|
| 107 |
+
Added ``stream_ended`` and ``priority_updated`` properties.
|
| 108 |
+
"""
|
| 109 |
+
|
| 110 |
+
stream_id: int
|
| 111 |
+
"""The Stream ID for the stream this response was made on."""
|
| 112 |
+
|
| 113 |
+
headers: list[Header] = _LAZY_INIT
|
| 114 |
+
"""The response headers."""
|
| 115 |
+
|
| 116 |
+
stream_ended: StreamEnded | None = None
|
| 117 |
+
"""
|
| 118 |
+
If this response also ended the stream, the associated
|
| 119 |
+
:class:`StreamEnded <h2.events.StreamEnded>` event will be available
|
| 120 |
+
here.
|
| 121 |
+
|
| 122 |
+
.. versionadded:: 2.4.0
|
| 123 |
+
"""
|
| 124 |
+
|
| 125 |
+
priority_updated: PriorityUpdated | None = None
|
| 126 |
+
"""
|
| 127 |
+
If this response also had associated priority information, the
|
| 128 |
+
associated :class:`PriorityUpdated <h2.events.PriorityUpdated>`
|
| 129 |
+
event will be available here.
|
| 130 |
+
|
| 131 |
+
.. versionadded:: 2.4.0
|
| 132 |
+
"""
|
| 133 |
+
|
| 134 |
+
def __repr__(self) -> str:
|
| 135 |
+
return f"<ResponseReceived stream_id:{self.stream_id}, headers:{self.headers}>"
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
@dataclass(**kw_only)
|
| 139 |
+
class TrailersReceived(Event):
|
| 140 |
+
"""
|
| 141 |
+
The TrailersReceived event is fired whenever trailers are received on a
|
| 142 |
+
stream. Trailers are a set of headers sent after the body of the
|
| 143 |
+
request/response, and are used to provide information that wasn't known
|
| 144 |
+
ahead of time (e.g. content-length). This event carries the HTTP header
|
| 145 |
+
fields that form the trailers and the stream ID of the stream on which they
|
| 146 |
+
were received.
|
| 147 |
+
|
| 148 |
+
.. versionchanged:: 2.3.0
|
| 149 |
+
Changed the type of ``headers`` to :class:`HeaderTuple
|
| 150 |
+
<hpack:hpack.HeaderTuple>`. This has no effect on current users.
|
| 151 |
+
|
| 152 |
+
.. versionchanged:: 2.4.0
|
| 153 |
+
Added ``stream_ended`` and ``priority_updated`` properties.
|
| 154 |
+
"""
|
| 155 |
+
|
| 156 |
+
stream_id: int
|
| 157 |
+
"""The Stream ID for the stream on which these trailers were received."""
|
| 158 |
+
|
| 159 |
+
headers: list[Header] = _LAZY_INIT
|
| 160 |
+
"""The trailers themselves."""
|
| 161 |
+
|
| 162 |
+
stream_ended: StreamEnded | None = None
|
| 163 |
+
"""
|
| 164 |
+
Trailers always end streams. This property has the associated
|
| 165 |
+
:class:`StreamEnded <h2.events.StreamEnded>` in it.
|
| 166 |
+
|
| 167 |
+
.. versionadded:: 2.4.0
|
| 168 |
+
"""
|
| 169 |
+
|
| 170 |
+
priority_updated: PriorityUpdated | None = None
|
| 171 |
+
"""
|
| 172 |
+
If the trailers also set associated priority information, the
|
| 173 |
+
associated :class:`PriorityUpdated <h2.events.PriorityUpdated>`
|
| 174 |
+
event will be available here.
|
| 175 |
+
|
| 176 |
+
.. versionadded:: 2.4.0
|
| 177 |
+
"""
|
| 178 |
+
|
| 179 |
+
def __repr__(self) -> str:
|
| 180 |
+
return f"<TrailersReceived stream_id:{self.stream_id}, headers:{self.headers}>"
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
class _HeadersSent(Event):
|
| 184 |
+
"""
|
| 185 |
+
The _HeadersSent event is fired whenever headers are sent.
|
| 186 |
+
|
| 187 |
+
This is an internal event, used to determine validation steps on
|
| 188 |
+
outgoing header blocks.
|
| 189 |
+
"""
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
class _ResponseSent(_HeadersSent):
|
| 194 |
+
"""
|
| 195 |
+
The _ResponseSent event is fired whenever response headers are sent
|
| 196 |
+
on a stream.
|
| 197 |
+
|
| 198 |
+
This is an internal event, used to determine validation steps on
|
| 199 |
+
outgoing header blocks.
|
| 200 |
+
"""
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
class _RequestSent(_HeadersSent):
|
| 205 |
+
"""
|
| 206 |
+
The _RequestSent event is fired whenever request headers are sent
|
| 207 |
+
on a stream.
|
| 208 |
+
|
| 209 |
+
This is an internal event, used to determine validation steps on
|
| 210 |
+
outgoing header blocks.
|
| 211 |
+
"""
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
class _TrailersSent(_HeadersSent):
|
| 216 |
+
"""
|
| 217 |
+
The _TrailersSent event is fired whenever trailers are sent on a
|
| 218 |
+
stream. Trailers are a set of headers sent after the body of the
|
| 219 |
+
request/response, and are used to provide information that wasn't known
|
| 220 |
+
ahead of time (e.g. content-length).
|
| 221 |
+
|
| 222 |
+
This is an internal event, used to determine validation steps on
|
| 223 |
+
outgoing header blocks.
|
| 224 |
+
"""
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
class _PushedRequestSent(_HeadersSent):
|
| 229 |
+
"""
|
| 230 |
+
The _PushedRequestSent event is fired whenever pushed request headers are
|
| 231 |
+
sent.
|
| 232 |
+
|
| 233 |
+
This is an internal event, used to determine validation steps on outgoing
|
| 234 |
+
header blocks.
|
| 235 |
+
"""
|
| 236 |
+
|
| 237 |
+
|
| 238 |
+
@dataclass(**kw_only)
|
| 239 |
+
class InformationalResponseReceived(Event):
|
| 240 |
+
"""
|
| 241 |
+
The InformationalResponseReceived event is fired when an informational
|
| 242 |
+
response (that is, one whose status code is a 1XX code) is received from
|
| 243 |
+
the remote peer.
|
| 244 |
+
|
| 245 |
+
The remote peer may send any number of these, from zero upwards. These
|
| 246 |
+
responses are most commonly sent in response to requests that have the
|
| 247 |
+
``expect: 100-continue`` header field present. Most users can safely
|
| 248 |
+
ignore this event unless you are intending to use the
|
| 249 |
+
``expect: 100-continue`` flow, or are for any reason expecting a different
|
| 250 |
+
1XX status code.
|
| 251 |
+
|
| 252 |
+
.. versionadded:: 2.2.0
|
| 253 |
+
|
| 254 |
+
.. versionchanged:: 2.3.0
|
| 255 |
+
Changed the type of ``headers`` to :class:`HeaderTuple
|
| 256 |
+
<hpack:hpack.HeaderTuple>`. This has no effect on current users.
|
| 257 |
+
|
| 258 |
+
.. versionchanged:: 2.4.0
|
| 259 |
+
Added ``priority_updated`` property.
|
| 260 |
+
"""
|
| 261 |
+
|
| 262 |
+
stream_id: int
|
| 263 |
+
"""The Stream ID for the stream this informational response was made on."""
|
| 264 |
+
|
| 265 |
+
headers: list[Header] = _LAZY_INIT
|
| 266 |
+
"""The headers for this informational response."""
|
| 267 |
+
|
| 268 |
+
priority_updated: PriorityUpdated | None = None
|
| 269 |
+
"""
|
| 270 |
+
If this response also had associated priority information, the
|
| 271 |
+
associated :class:`PriorityUpdated <h2.events.PriorityUpdated>`
|
| 272 |
+
event will be available here.
|
| 273 |
+
|
| 274 |
+
.. versionadded:: 2.4.0
|
| 275 |
+
"""
|
| 276 |
+
|
| 277 |
+
def __repr__(self) -> str:
|
| 278 |
+
return f"<InformationalResponseReceived stream_id:{self.stream_id}, headers:{self.headers}>"
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
@dataclass(**kw_only)
|
| 282 |
+
class DataReceived(Event):
|
| 283 |
+
"""
|
| 284 |
+
The DataReceived event is fired whenever data is received on a stream from
|
| 285 |
+
the remote peer. The event carries the data itself, and the stream ID on
|
| 286 |
+
which the data was received.
|
| 287 |
+
|
| 288 |
+
.. versionchanged:: 2.4.0
|
| 289 |
+
Added ``stream_ended`` property.
|
| 290 |
+
"""
|
| 291 |
+
|
| 292 |
+
stream_id: int
|
| 293 |
+
"""The Stream ID for the stream this data was received on."""
|
| 294 |
+
|
| 295 |
+
data: bytes = _LAZY_INIT
|
| 296 |
+
"""The data itself."""
|
| 297 |
+
|
| 298 |
+
flow_controlled_length: int = _LAZY_INIT
|
| 299 |
+
"""
|
| 300 |
+
The amount of data received that counts against the flow control
|
| 301 |
+
window. Note that padding counts against the flow control window, so
|
| 302 |
+
when adjusting flow control you should always use this field rather
|
| 303 |
+
than ``len(data)``.
|
| 304 |
+
"""
|
| 305 |
+
|
| 306 |
+
stream_ended: StreamEnded | None = None
|
| 307 |
+
"""
|
| 308 |
+
If this data chunk also completed the stream, the associated
|
| 309 |
+
:class:`StreamEnded <h2.events.StreamEnded>` event will be available
|
| 310 |
+
here.
|
| 311 |
+
|
| 312 |
+
.. versionadded:: 2.4.0
|
| 313 |
+
"""
|
| 314 |
+
|
| 315 |
+
def __repr__(self) -> str:
|
| 316 |
+
return (
|
| 317 |
+
"<DataReceived stream_id:{}, "
|
| 318 |
+
"flow_controlled_length:{}, "
|
| 319 |
+
"data:{}>".format(
|
| 320 |
+
self.stream_id,
|
| 321 |
+
self.flow_controlled_length,
|
| 322 |
+
_bytes_representation(self.data[:20]) if self.data else "",
|
| 323 |
+
)
|
| 324 |
+
)
|
| 325 |
+
|
| 326 |
+
|
| 327 |
+
@dataclass(**kw_only)
|
| 328 |
+
class WindowUpdated(Event):
|
| 329 |
+
"""
|
| 330 |
+
The WindowUpdated event is fired whenever a flow control window changes
|
| 331 |
+
size. HTTP/2 defines flow control windows for connections and streams: this
|
| 332 |
+
event fires for both connections and streams. The event carries the ID of
|
| 333 |
+
the stream to which it applies (set to zero if the window update applies to
|
| 334 |
+
the connection), and the delta in the window size.
|
| 335 |
+
"""
|
| 336 |
+
|
| 337 |
+
stream_id: int
|
| 338 |
+
"""
|
| 339 |
+
The Stream ID of the stream whose flow control window was changed.
|
| 340 |
+
May be ``0`` if the connection window was changed.
|
| 341 |
+
"""
|
| 342 |
+
|
| 343 |
+
delta: int = _LAZY_INIT
|
| 344 |
+
"""
|
| 345 |
+
The window delta.
|
| 346 |
+
"""
|
| 347 |
+
|
| 348 |
+
def __repr__(self) -> str:
|
| 349 |
+
return f"<WindowUpdated stream_id:{self.stream_id}, delta:{self.delta}>"
|
| 350 |
+
|
| 351 |
+
|
| 352 |
+
class RemoteSettingsChanged(Event):
|
| 353 |
+
"""
|
| 354 |
+
The RemoteSettingsChanged event is fired whenever the remote peer changes
|
| 355 |
+
its settings. It contains a complete inventory of changed settings,
|
| 356 |
+
including their previous values.
|
| 357 |
+
|
| 358 |
+
In HTTP/2, settings changes need to be acknowledged. h2 automatically
|
| 359 |
+
acknowledges settings changes for efficiency. However, it is possible that
|
| 360 |
+
the caller may not be happy with the changed setting.
|
| 361 |
+
|
| 362 |
+
When this event is received, the caller should confirm that the new
|
| 363 |
+
settings are acceptable. If they are not acceptable, the user should close
|
| 364 |
+
the connection with the error code :data:`PROTOCOL_ERROR
|
| 365 |
+
<h2.errors.ErrorCodes.PROTOCOL_ERROR>`.
|
| 366 |
+
|
| 367 |
+
.. versionchanged:: 2.0.0
|
| 368 |
+
Prior to this version the user needed to acknowledge settings changes.
|
| 369 |
+
This is no longer the case: h2 now automatically acknowledges
|
| 370 |
+
them.
|
| 371 |
+
"""
|
| 372 |
+
|
| 373 |
+
def __init__(self) -> None:
|
| 374 |
+
#: A dictionary of setting byte to
|
| 375 |
+
#: :class:`ChangedSetting <h2.settings.ChangedSetting>`, representing
|
| 376 |
+
#: the changed settings.
|
| 377 |
+
self.changed_settings: dict[int, ChangedSetting] = {}
|
| 378 |
+
|
| 379 |
+
@classmethod
|
| 380 |
+
def from_settings(cls,
|
| 381 |
+
old_settings: Settings | dict[int, int],
|
| 382 |
+
new_settings: dict[int, int]) -> RemoteSettingsChanged:
|
| 383 |
+
"""
|
| 384 |
+
Build a RemoteSettingsChanged event from a set of changed settings.
|
| 385 |
+
|
| 386 |
+
:param old_settings: A complete collection of old settings, in the form
|
| 387 |
+
of a dictionary of ``{setting: value}``.
|
| 388 |
+
:param new_settings: All the changed settings and their new values, in
|
| 389 |
+
the form of a dictionary of ``{setting: value}``.
|
| 390 |
+
"""
|
| 391 |
+
e = cls()
|
| 392 |
+
for setting, new_value in new_settings.items():
|
| 393 |
+
s = _setting_code_from_int(setting)
|
| 394 |
+
original_value = old_settings.get(s)
|
| 395 |
+
change = ChangedSetting(s, original_value, new_value)
|
| 396 |
+
e.changed_settings[s] = change
|
| 397 |
+
|
| 398 |
+
return e
|
| 399 |
+
|
| 400 |
+
def __repr__(self) -> str:
|
| 401 |
+
return "<RemoteSettingsChanged changed_settings:{{{}}}>".format(
|
| 402 |
+
", ".join(repr(cs) for cs in self.changed_settings.values()),
|
| 403 |
+
)
|
| 404 |
+
|
| 405 |
+
|
| 406 |
+
@dataclass(**kw_only)
|
| 407 |
+
class PingReceived(Event):
|
| 408 |
+
"""
|
| 409 |
+
The PingReceived event is fired whenever a PING is received. It contains
|
| 410 |
+
the 'opaque data' of the PING frame. A ping acknowledgment with the same
|
| 411 |
+
'opaque data' is automatically emitted after receiving a ping.
|
| 412 |
+
|
| 413 |
+
.. versionadded:: 3.1.0
|
| 414 |
+
"""
|
| 415 |
+
|
| 416 |
+
ping_data: bytes
|
| 417 |
+
"""The data included on the ping."""
|
| 418 |
+
|
| 419 |
+
def __repr__(self) -> str:
|
| 420 |
+
return f"<PingReceived ping_data:{_bytes_representation(self.ping_data)}>"
|
| 421 |
+
|
| 422 |
+
|
| 423 |
+
@dataclass(**kw_only)
|
| 424 |
+
class PingAckReceived(Event):
|
| 425 |
+
"""
|
| 426 |
+
The PingAckReceived event is fired whenever a PING acknowledgment is
|
| 427 |
+
received. It contains the 'opaque data' of the PING+ACK frame, allowing the
|
| 428 |
+
user to correlate PINGs and calculate RTT.
|
| 429 |
+
|
| 430 |
+
.. versionadded:: 3.1.0
|
| 431 |
+
|
| 432 |
+
.. versionchanged:: 4.0.0
|
| 433 |
+
Removed deprecated but equivalent ``PingAcknowledged``.
|
| 434 |
+
"""
|
| 435 |
+
|
| 436 |
+
ping_data: bytes
|
| 437 |
+
"""The data included on the ping."""
|
| 438 |
+
|
| 439 |
+
def __repr__(self) -> str:
|
| 440 |
+
return f"<PingAckReceived ping_data:{_bytes_representation(self.ping_data)}>"
|
| 441 |
+
|
| 442 |
+
|
| 443 |
+
@dataclass(**kw_only)
|
| 444 |
+
class StreamEnded(Event):
|
| 445 |
+
"""
|
| 446 |
+
The StreamEnded event is fired whenever a stream is ended by a remote
|
| 447 |
+
party. The stream may not be fully closed if it has not been closed
|
| 448 |
+
locally, but no further data or headers should be expected on that stream.
|
| 449 |
+
"""
|
| 450 |
+
|
| 451 |
+
stream_id: int
|
| 452 |
+
"""The Stream ID of the stream that was closed."""
|
| 453 |
+
|
| 454 |
+
def __repr__(self) -> str:
|
| 455 |
+
return f"<StreamEnded stream_id:{self.stream_id}>"
|
| 456 |
+
|
| 457 |
+
|
| 458 |
+
@dataclass(**kw_only)
|
| 459 |
+
class StreamReset(Event):
|
| 460 |
+
"""
|
| 461 |
+
The StreamReset event is fired in two situations. The first is when the
|
| 462 |
+
remote party forcefully resets the stream. The second is when the remote
|
| 463 |
+
party has made a protocol error which only affects a single stream. In this
|
| 464 |
+
case, h2 will terminate the stream early and return this event.
|
| 465 |
+
|
| 466 |
+
.. versionchanged:: 2.0.0
|
| 467 |
+
This event is now fired when h2 automatically resets a stream.
|
| 468 |
+
"""
|
| 469 |
+
|
| 470 |
+
stream_id: int
|
| 471 |
+
"""
|
| 472 |
+
The Stream ID of the stream that was reset.
|
| 473 |
+
"""
|
| 474 |
+
|
| 475 |
+
error_code: ErrorCodes | int = _LAZY_INIT
|
| 476 |
+
"""
|
| 477 |
+
The error code given.
|
| 478 |
+
"""
|
| 479 |
+
|
| 480 |
+
remote_reset: bool = True
|
| 481 |
+
"""
|
| 482 |
+
Whether the remote peer sent a RST_STREAM or we did.
|
| 483 |
+
"""
|
| 484 |
+
|
| 485 |
+
def __repr__(self) -> str:
|
| 486 |
+
return f"<StreamReset stream_id:{self.stream_id}, error_code:{self.error_code!s}, remote_reset:{self.remote_reset}>"
|
| 487 |
+
|
| 488 |
+
|
| 489 |
+
class PushedStreamReceived(Event):
|
| 490 |
+
"""
|
| 491 |
+
The PushedStreamReceived event is fired whenever a pushed stream has been
|
| 492 |
+
received from a remote peer. The event carries on it the new stream ID, the
|
| 493 |
+
ID of the parent stream, and the request headers pushed by the remote peer.
|
| 494 |
+
"""
|
| 495 |
+
|
| 496 |
+
def __init__(self) -> None:
|
| 497 |
+
#: The Stream ID of the stream created by the push.
|
| 498 |
+
self.pushed_stream_id: int | None = None
|
| 499 |
+
|
| 500 |
+
#: The Stream ID of the stream that the push is related to.
|
| 501 |
+
self.parent_stream_id: int | None = None
|
| 502 |
+
|
| 503 |
+
#: The request headers, sent by the remote party in the push.
|
| 504 |
+
self.headers: list[Header] | None = None
|
| 505 |
+
|
| 506 |
+
def __repr__(self) -> str:
|
| 507 |
+
return (
|
| 508 |
+
f"<PushedStreamReceived pushed_stream_id:{self.pushed_stream_id}, parent_stream_id:{self.parent_stream_id}, "
|
| 509 |
+
f"headers:{self.headers}>"
|
| 510 |
+
)
|
| 511 |
+
|
| 512 |
+
|
| 513 |
+
class SettingsAcknowledged(Event):
|
| 514 |
+
"""
|
| 515 |
+
The SettingsAcknowledged event is fired whenever a settings ACK is received
|
| 516 |
+
from the remote peer. The event carries on it the settings that were
|
| 517 |
+
acknowedged, in the same format as
|
| 518 |
+
:class:`h2.events.RemoteSettingsChanged`.
|
| 519 |
+
"""
|
| 520 |
+
|
| 521 |
+
def __init__(self) -> None:
|
| 522 |
+
#: A dictionary of setting byte to
|
| 523 |
+
#: :class:`ChangedSetting <h2.settings.ChangedSetting>`, representing
|
| 524 |
+
#: the changed settings.
|
| 525 |
+
self.changed_settings: dict[SettingCodes | int, ChangedSetting] = {}
|
| 526 |
+
|
| 527 |
+
def __repr__(self) -> str:
|
| 528 |
+
s = ", ".join(repr(cs) for cs in self.changed_settings.values())
|
| 529 |
+
return f"<SettingsAcknowledged changed_settings:{{{s}}}>"
|
| 530 |
+
|
| 531 |
+
|
| 532 |
+
class PriorityUpdated(Event):
|
| 533 |
+
"""
|
| 534 |
+
The PriorityUpdated event is fired whenever a stream sends updated priority
|
| 535 |
+
information. This can occur when the stream is opened, or at any time
|
| 536 |
+
during the stream lifetime.
|
| 537 |
+
|
| 538 |
+
This event is purely advisory, and does not need to be acted on.
|
| 539 |
+
|
| 540 |
+
.. versionadded:: 2.0.0
|
| 541 |
+
"""
|
| 542 |
+
|
| 543 |
+
def __init__(self) -> None:
|
| 544 |
+
#: The ID of the stream whose priority information is being updated.
|
| 545 |
+
self.stream_id: int | None = None
|
| 546 |
+
|
| 547 |
+
#: The new stream weight. May be the same as the original stream
|
| 548 |
+
#: weight. An integer between 1 and 256.
|
| 549 |
+
self.weight: int | None = None
|
| 550 |
+
|
| 551 |
+
#: The stream ID this stream now depends on. May be ``0``.
|
| 552 |
+
self.depends_on: int | None = None
|
| 553 |
+
|
| 554 |
+
#: Whether the stream *exclusively* depends on the parent stream. If it
|
| 555 |
+
#: does, this stream should inherit the current children of its new
|
| 556 |
+
#: parent.
|
| 557 |
+
self.exclusive: bool | None = None
|
| 558 |
+
|
| 559 |
+
def __repr__(self) -> str:
|
| 560 |
+
return (
|
| 561 |
+
f"<PriorityUpdated stream_id:{self.stream_id}, weight:{self.weight}, depends_on:{self.depends_on}, "
|
| 562 |
+
f"exclusive:{self.exclusive}>"
|
| 563 |
+
)
|
| 564 |
+
|
| 565 |
+
|
| 566 |
+
class ConnectionTerminated(Event):
|
| 567 |
+
"""
|
| 568 |
+
The ConnectionTerminated event is fired when a connection is torn down by
|
| 569 |
+
the remote peer using a GOAWAY frame. Once received, no further action may
|
| 570 |
+
be taken on the connection: a new connection must be established.
|
| 571 |
+
"""
|
| 572 |
+
|
| 573 |
+
def __init__(self) -> None:
|
| 574 |
+
#: The error code cited when tearing down the connection. Should be
|
| 575 |
+
#: one of :class:`ErrorCodes <h2.errors.ErrorCodes>`, but may not be if
|
| 576 |
+
#: unknown HTTP/2 extensions are being used.
|
| 577 |
+
self.error_code: ErrorCodes | int | None = None
|
| 578 |
+
|
| 579 |
+
#: The stream ID of the last stream the remote peer saw. This can
|
| 580 |
+
#: provide an indication of what data, if any, never reached the remote
|
| 581 |
+
#: peer and so can safely be resent.
|
| 582 |
+
self.last_stream_id: int | None = None
|
| 583 |
+
|
| 584 |
+
#: Additional debug data that can be appended to GOAWAY frame.
|
| 585 |
+
self.additional_data: bytes | None = None
|
| 586 |
+
|
| 587 |
+
def __repr__(self) -> str:
|
| 588 |
+
return (
|
| 589 |
+
"<ConnectionTerminated error_code:{!s}, last_stream_id:{}, "
|
| 590 |
+
"additional_data:{}>".format(
|
| 591 |
+
self.error_code,
|
| 592 |
+
self.last_stream_id,
|
| 593 |
+
_bytes_representation(
|
| 594 |
+
self.additional_data[:20]
|
| 595 |
+
if self.additional_data else None),
|
| 596 |
+
)
|
| 597 |
+
)
|
| 598 |
+
|
| 599 |
+
|
| 600 |
+
class AlternativeServiceAvailable(Event):
|
| 601 |
+
"""
|
| 602 |
+
The AlternativeServiceAvailable event is fired when the remote peer
|
| 603 |
+
advertises an `RFC 7838 <https://tools.ietf.org/html/rfc7838>`_ Alternative
|
| 604 |
+
Service using an ALTSVC frame.
|
| 605 |
+
|
| 606 |
+
This event always carries the origin to which the ALTSVC information
|
| 607 |
+
applies. That origin is either supplied by the server directly, or inferred
|
| 608 |
+
by h2 from the ``:authority`` pseudo-header field that was sent by
|
| 609 |
+
the user when initiating a given stream.
|
| 610 |
+
|
| 611 |
+
This event also carries what RFC 7838 calls the "Alternative Service Field
|
| 612 |
+
Value", which is formatted like a HTTP header field and contains the
|
| 613 |
+
relevant alternative service information. h2 does not parse or in any
|
| 614 |
+
way modify that information: the user is required to do that.
|
| 615 |
+
|
| 616 |
+
This event can only be fired on the client end of a connection.
|
| 617 |
+
|
| 618 |
+
.. versionadded:: 2.3.0
|
| 619 |
+
"""
|
| 620 |
+
|
| 621 |
+
def __init__(self) -> None:
|
| 622 |
+
#: The origin to which the alternative service field value applies.
|
| 623 |
+
#: This field is either supplied by the server directly, or inferred by
|
| 624 |
+
#: h2 from the ``:authority`` pseudo-header field that was sent
|
| 625 |
+
#: by the user when initiating the stream on which the frame was
|
| 626 |
+
#: received.
|
| 627 |
+
self.origin: bytes | None = None
|
| 628 |
+
|
| 629 |
+
#: The ALTSVC field value. This contains information about the HTTP
|
| 630 |
+
#: alternative service being advertised by the server. h2 does
|
| 631 |
+
#: not parse this field: it is left exactly as sent by the server. The
|
| 632 |
+
#: structure of the data in this field is given by `RFC 7838 Section 3
|
| 633 |
+
#: <https://tools.ietf.org/html/rfc7838#section-3>`_.
|
| 634 |
+
self.field_value: bytes | None = None
|
| 635 |
+
|
| 636 |
+
def __repr__(self) -> str:
|
| 637 |
+
return (
|
| 638 |
+
"<AlternativeServiceAvailable origin:{}, field_value:{}>".format(
|
| 639 |
+
(self.origin or b"").decode("utf-8", "ignore"),
|
| 640 |
+
(self.field_value or b"").decode("utf-8", "ignore"),
|
| 641 |
+
)
|
| 642 |
+
)
|
| 643 |
+
|
| 644 |
+
|
| 645 |
+
@dataclass(**kw_only)
|
| 646 |
+
class UnknownFrameReceived(Event):
|
| 647 |
+
"""
|
| 648 |
+
The UnknownFrameReceived event is fired when the remote peer sends a frame
|
| 649 |
+
that h2 does not understand. This occurs primarily when the remote
|
| 650 |
+
peer is employing HTTP/2 extensions that h2 doesn't know anything
|
| 651 |
+
about.
|
| 652 |
+
|
| 653 |
+
RFC 7540 requires that HTTP/2 implementations ignore these frames. h2
|
| 654 |
+
does so. However, this event is fired to allow implementations to perform
|
| 655 |
+
special processing on those frames if needed (e.g. if the implementation
|
| 656 |
+
is capable of handling the frame itself).
|
| 657 |
+
|
| 658 |
+
.. versionadded:: 2.7.0
|
| 659 |
+
"""
|
| 660 |
+
|
| 661 |
+
frame: Frame
|
| 662 |
+
|
| 663 |
+
def __repr__(self) -> str:
|
| 664 |
+
return "<UnknownFrameReceived>"
|
| 665 |
+
|
| 666 |
+
|
| 667 |
+
def _bytes_representation(data: bytes | None) -> str | None:
|
| 668 |
+
"""
|
| 669 |
+
Converts a bytestring into something that is safe to print on all Python
|
| 670 |
+
platforms.
|
| 671 |
+
|
| 672 |
+
This function is relatively expensive, so it should not be called on the
|
| 673 |
+
mainline of the code. It's safe to use in things like object repr methods
|
| 674 |
+
though.
|
| 675 |
+
"""
|
| 676 |
+
if data is None:
|
| 677 |
+
return None
|
| 678 |
+
|
| 679 |
+
return binascii.hexlify(data).decode("ascii")
|
bertvenv/lib/python3.10/site-packages/h2/windows.py
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
h2/windows
|
| 3 |
+
~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Defines tools for managing HTTP/2 flow control windows.
|
| 6 |
+
|
| 7 |
+
The objects defined in this module are used to automatically manage HTTP/2
|
| 8 |
+
flow control windows. Specifically, they keep track of what the size of the
|
| 9 |
+
window is, how much data has been consumed from that window, and how much data
|
| 10 |
+
the user has already used. It then implements a basic algorithm that attempts
|
| 11 |
+
to manage the flow control window without user input, trying to ensure that it
|
| 12 |
+
does not emit too many WINDOW_UPDATE frames.
|
| 13 |
+
"""
|
| 14 |
+
from __future__ import annotations
|
| 15 |
+
|
| 16 |
+
from .exceptions import FlowControlError
|
| 17 |
+
|
| 18 |
+
# The largest acceptable value for a HTTP/2 flow control window.
|
| 19 |
+
LARGEST_FLOW_CONTROL_WINDOW = 2**31 - 1
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class WindowManager:
|
| 23 |
+
"""
|
| 24 |
+
A basic HTTP/2 window manager.
|
| 25 |
+
|
| 26 |
+
:param max_window_size: The maximum size of the flow control window.
|
| 27 |
+
:type max_window_size: ``int``
|
| 28 |
+
"""
|
| 29 |
+
|
| 30 |
+
def __init__(self, max_window_size: int) -> None:
|
| 31 |
+
assert max_window_size <= LARGEST_FLOW_CONTROL_WINDOW
|
| 32 |
+
self.max_window_size = max_window_size
|
| 33 |
+
self.current_window_size = max_window_size
|
| 34 |
+
self._bytes_processed = 0
|
| 35 |
+
|
| 36 |
+
def window_consumed(self, size: int) -> None:
|
| 37 |
+
"""
|
| 38 |
+
We have received a certain number of bytes from the remote peer. This
|
| 39 |
+
necessarily shrinks the flow control window!
|
| 40 |
+
|
| 41 |
+
:param size: The number of flow controlled bytes we received from the
|
| 42 |
+
remote peer.
|
| 43 |
+
:type size: ``int``
|
| 44 |
+
:returns: Nothing.
|
| 45 |
+
:rtype: ``None``
|
| 46 |
+
"""
|
| 47 |
+
self.current_window_size -= size
|
| 48 |
+
if self.current_window_size < 0:
|
| 49 |
+
msg = "Flow control window shrunk below 0"
|
| 50 |
+
raise FlowControlError(msg)
|
| 51 |
+
|
| 52 |
+
def window_opened(self, size: int) -> None:
|
| 53 |
+
"""
|
| 54 |
+
The flow control window has been incremented, either because of manual
|
| 55 |
+
flow control management or because of the user changing the flow
|
| 56 |
+
control settings. This can have the effect of increasing what we
|
| 57 |
+
consider to be the "maximum" flow control window size.
|
| 58 |
+
|
| 59 |
+
This does not increase our view of how many bytes have been processed,
|
| 60 |
+
only of how much space is in the window.
|
| 61 |
+
|
| 62 |
+
:param size: The increment to the flow control window we received.
|
| 63 |
+
:type size: ``int``
|
| 64 |
+
:returns: Nothing
|
| 65 |
+
:rtype: ``None``
|
| 66 |
+
"""
|
| 67 |
+
self.current_window_size += size
|
| 68 |
+
|
| 69 |
+
if self.current_window_size > LARGEST_FLOW_CONTROL_WINDOW:
|
| 70 |
+
msg = f"Flow control window mustn't exceed {LARGEST_FLOW_CONTROL_WINDOW}"
|
| 71 |
+
raise FlowControlError(msg)
|
| 72 |
+
|
| 73 |
+
self.max_window_size = max(self.current_window_size, self.max_window_size)
|
| 74 |
+
|
| 75 |
+
def process_bytes(self, size: int) -> int | None:
|
| 76 |
+
"""
|
| 77 |
+
The application has informed us that it has processed a certain number
|
| 78 |
+
of bytes. This may cause us to want to emit a window update frame. If
|
| 79 |
+
we do want to emit a window update frame, this method will return the
|
| 80 |
+
number of bytes that we should increment the window by.
|
| 81 |
+
|
| 82 |
+
:param size: The number of flow controlled bytes that the application
|
| 83 |
+
has processed.
|
| 84 |
+
:type size: ``int``
|
| 85 |
+
:returns: The number of bytes to increment the flow control window by,
|
| 86 |
+
or ``None``.
|
| 87 |
+
:rtype: ``int`` or ``None``
|
| 88 |
+
"""
|
| 89 |
+
self._bytes_processed += size
|
| 90 |
+
return self._maybe_update_window()
|
| 91 |
+
|
| 92 |
+
def _maybe_update_window(self) -> int | None:
|
| 93 |
+
"""
|
| 94 |
+
Run the algorithm.
|
| 95 |
+
|
| 96 |
+
Our current algorithm can be described like this.
|
| 97 |
+
|
| 98 |
+
1. If no bytes have been processed, we immediately return 0. There is
|
| 99 |
+
no meaningful way for us to hand space in the window back to the
|
| 100 |
+
remote peer, so let's not even try.
|
| 101 |
+
2. If there is no space in the flow control window, and we have
|
| 102 |
+
processed at least 1024 bytes (or 1/4 of the window, if the window
|
| 103 |
+
is smaller), we will emit a window update frame. This is to avoid
|
| 104 |
+
the risk of blocking a stream altogether.
|
| 105 |
+
3. If there is space in the flow control window, and we have processed
|
| 106 |
+
at least 1/2 of the window worth of bytes, we will emit a window
|
| 107 |
+
update frame. This is to minimise the number of window update frames
|
| 108 |
+
we have to emit.
|
| 109 |
+
|
| 110 |
+
In a healthy system with large flow control windows, this will
|
| 111 |
+
irregularly emit WINDOW_UPDATE frames. This prevents us starving the
|
| 112 |
+
connection by emitting eleventy bajillion WINDOW_UPDATE frames,
|
| 113 |
+
especially in situations where the remote peer is sending a lot of very
|
| 114 |
+
small DATA frames.
|
| 115 |
+
"""
|
| 116 |
+
# TODO: Can the window be smaller than 1024 bytes? If not, we can
|
| 117 |
+
# streamline this algorithm.
|
| 118 |
+
if not self._bytes_processed:
|
| 119 |
+
return None
|
| 120 |
+
|
| 121 |
+
max_increment = (self.max_window_size - self.current_window_size)
|
| 122 |
+
increment = 0
|
| 123 |
+
|
| 124 |
+
# Note that, even though we may increment less than _bytes_processed,
|
| 125 |
+
# we still want to set it to zero whenever we emit an increment. This
|
| 126 |
+
# is because we'll always increment up to the maximum we can.
|
| 127 |
+
if ((self.current_window_size == 0) and (
|
| 128 |
+
self._bytes_processed > min(1024, self.max_window_size // 4))) or self._bytes_processed >= (self.max_window_size // 2):
|
| 129 |
+
increment = min(self._bytes_processed, max_increment)
|
| 130 |
+
self._bytes_processed = 0
|
| 131 |
+
|
| 132 |
+
self.current_window_size += increment
|
| 133 |
+
return increment
|
bertvenv/lib/python3.10/site-packages/multiprocess/tests/__init__.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
bertvenv/lib/python3.10/site-packages/packaging-25.0.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
bertvenv/lib/python3.10/site-packages/packaging-25.0.dist-info/METADATA
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.4
|
| 2 |
+
Name: packaging
|
| 3 |
+
Version: 25.0
|
| 4 |
+
Summary: Core utilities for Python packages
|
| 5 |
+
Author-email: Donald Stufft <donald@stufft.io>
|
| 6 |
+
Requires-Python: >=3.8
|
| 7 |
+
Description-Content-Type: text/x-rst
|
| 8 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 9 |
+
Classifier: Intended Audience :: Developers
|
| 10 |
+
Classifier: License :: OSI Approved :: Apache Software License
|
| 11 |
+
Classifier: License :: OSI Approved :: BSD License
|
| 12 |
+
Classifier: Programming Language :: Python
|
| 13 |
+
Classifier: Programming Language :: Python :: 3
|
| 14 |
+
Classifier: Programming Language :: Python :: 3 :: Only
|
| 15 |
+
Classifier: Programming Language :: Python :: 3.8
|
| 16 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 17 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 18 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 19 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 20 |
+
Classifier: Programming Language :: Python :: 3.13
|
| 21 |
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
| 22 |
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
| 23 |
+
Classifier: Typing :: Typed
|
| 24 |
+
License-File: LICENSE
|
| 25 |
+
License-File: LICENSE.APACHE
|
| 26 |
+
License-File: LICENSE.BSD
|
| 27 |
+
Project-URL: Documentation, https://packaging.pypa.io/
|
| 28 |
+
Project-URL: Source, https://github.com/pypa/packaging
|
| 29 |
+
|
| 30 |
+
packaging
|
| 31 |
+
=========
|
| 32 |
+
|
| 33 |
+
.. start-intro
|
| 34 |
+
|
| 35 |
+
Reusable core utilities for various Python Packaging
|
| 36 |
+
`interoperability specifications <https://packaging.python.org/specifications/>`_.
|
| 37 |
+
|
| 38 |
+
This library provides utilities that implement the interoperability
|
| 39 |
+
specifications which have clearly one correct behaviour (eg: :pep:`440`)
|
| 40 |
+
or benefit greatly from having a single shared implementation (eg: :pep:`425`).
|
| 41 |
+
|
| 42 |
+
.. end-intro
|
| 43 |
+
|
| 44 |
+
The ``packaging`` project includes the following: version handling, specifiers,
|
| 45 |
+
markers, requirements, tags, utilities.
|
| 46 |
+
|
| 47 |
+
Documentation
|
| 48 |
+
-------------
|
| 49 |
+
|
| 50 |
+
The `documentation`_ provides information and the API for the following:
|
| 51 |
+
|
| 52 |
+
- Version Handling
|
| 53 |
+
- Specifiers
|
| 54 |
+
- Markers
|
| 55 |
+
- Requirements
|
| 56 |
+
- Tags
|
| 57 |
+
- Utilities
|
| 58 |
+
|
| 59 |
+
Installation
|
| 60 |
+
------------
|
| 61 |
+
|
| 62 |
+
Use ``pip`` to install these utilities::
|
| 63 |
+
|
| 64 |
+
pip install packaging
|
| 65 |
+
|
| 66 |
+
The ``packaging`` library uses calendar-based versioning (``YY.N``).
|
| 67 |
+
|
| 68 |
+
Discussion
|
| 69 |
+
----------
|
| 70 |
+
|
| 71 |
+
If you run into bugs, you can file them in our `issue tracker`_.
|
| 72 |
+
|
| 73 |
+
You can also join ``#pypa`` on Freenode to ask questions or get involved.
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
.. _`documentation`: https://packaging.pypa.io/
|
| 77 |
+
.. _`issue tracker`: https://github.com/pypa/packaging/issues
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
Code of Conduct
|
| 81 |
+
---------------
|
| 82 |
+
|
| 83 |
+
Everyone interacting in the packaging project's codebases, issue trackers, chat
|
| 84 |
+
rooms, and mailing lists is expected to follow the `PSF Code of Conduct`_.
|
| 85 |
+
|
| 86 |
+
.. _PSF Code of Conduct: https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md
|
| 87 |
+
|
| 88 |
+
Contributing
|
| 89 |
+
------------
|
| 90 |
+
|
| 91 |
+
The ``CONTRIBUTING.rst`` file outlines how to contribute to this project as
|
| 92 |
+
well as how to report a potential security issue. The documentation for this
|
| 93 |
+
project also covers information about `project development`_ and `security`_.
|
| 94 |
+
|
| 95 |
+
.. _`project development`: https://packaging.pypa.io/en/latest/development/
|
| 96 |
+
.. _`security`: https://packaging.pypa.io/en/latest/security/
|
| 97 |
+
|
| 98 |
+
Project History
|
| 99 |
+
---------------
|
| 100 |
+
|
| 101 |
+
Please review the ``CHANGELOG.rst`` file or the `Changelog documentation`_ for
|
| 102 |
+
recent changes and project history.
|
| 103 |
+
|
| 104 |
+
.. _`Changelog documentation`: https://packaging.pypa.io/en/latest/changelog/
|
| 105 |
+
|
bertvenv/lib/python3.10/site-packages/packaging-25.0.dist-info/RECORD
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
packaging-25.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 2 |
+
packaging-25.0.dist-info/METADATA,sha256=W2EaYJw4_vw9YWv0XSCuyY-31T8kXayp4sMPyFx6woI,3281
|
| 3 |
+
packaging-25.0.dist-info/RECORD,,
|
| 4 |
+
packaging-25.0.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
| 5 |
+
packaging-25.0.dist-info/licenses/LICENSE,sha256=ytHvW9NA1z4HS6YU0m996spceUDD2MNIUuZcSQlobEg,197
|
| 6 |
+
packaging-25.0.dist-info/licenses/LICENSE.APACHE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
|
| 7 |
+
packaging-25.0.dist-info/licenses/LICENSE.BSD,sha256=tw5-m3QvHMb5SLNMFqo5_-zpQZY2S8iP8NIYDwAo-sU,1344
|
| 8 |
+
packaging/__init__.py,sha256=_0cDiPVf2S-bNfVmZguxxzmrIYWlyASxpqph4qsJWUc,494
|
| 9 |
+
packaging/__pycache__/__init__.cpython-310.pyc,,
|
| 10 |
+
packaging/__pycache__/_elffile.cpython-310.pyc,,
|
| 11 |
+
packaging/__pycache__/_manylinux.cpython-310.pyc,,
|
| 12 |
+
packaging/__pycache__/_musllinux.cpython-310.pyc,,
|
| 13 |
+
packaging/__pycache__/_parser.cpython-310.pyc,,
|
| 14 |
+
packaging/__pycache__/_structures.cpython-310.pyc,,
|
| 15 |
+
packaging/__pycache__/_tokenizer.cpython-310.pyc,,
|
| 16 |
+
packaging/__pycache__/markers.cpython-310.pyc,,
|
| 17 |
+
packaging/__pycache__/metadata.cpython-310.pyc,,
|
| 18 |
+
packaging/__pycache__/requirements.cpython-310.pyc,,
|
| 19 |
+
packaging/__pycache__/specifiers.cpython-310.pyc,,
|
| 20 |
+
packaging/__pycache__/tags.cpython-310.pyc,,
|
| 21 |
+
packaging/__pycache__/utils.cpython-310.pyc,,
|
| 22 |
+
packaging/__pycache__/version.cpython-310.pyc,,
|
| 23 |
+
packaging/_elffile.py,sha256=UkrbDtW7aeq3qqoAfU16ojyHZ1xsTvGke_WqMTKAKd0,3286
|
| 24 |
+
packaging/_manylinux.py,sha256=t4y_-dTOcfr36gLY-ztiOpxxJFGO2ikC11HgfysGxiM,9596
|
| 25 |
+
packaging/_musllinux.py,sha256=p9ZqNYiOItGee8KcZFeHF_YcdhVwGHdK6r-8lgixvGQ,2694
|
| 26 |
+
packaging/_parser.py,sha256=gYfnj0pRHflVc4RHZit13KNTyN9iiVcU2RUCGi22BwM,10221
|
| 27 |
+
packaging/_structures.py,sha256=q3eVNmbWJGG_S0Dit_S3Ao8qQqz_5PYTXFAKBZe5yr4,1431
|
| 28 |
+
packaging/_tokenizer.py,sha256=OYzt7qKxylOAJ-q0XyK1qAycyPRYLfMPdGQKRXkZWyI,5310
|
| 29 |
+
packaging/licenses/__init__.py,sha256=VsK4o27CJXWfTi8r2ybJmsBoCdhpnBWuNrskaCVKP7U,5715
|
| 30 |
+
packaging/licenses/__pycache__/__init__.cpython-310.pyc,,
|
| 31 |
+
packaging/licenses/__pycache__/_spdx.cpython-310.pyc,,
|
| 32 |
+
packaging/licenses/_spdx.py,sha256=oAm1ztPFwlsmCKe7lAAsv_OIOfS1cWDu9bNBkeu-2ns,48398
|
| 33 |
+
packaging/markers.py,sha256=P0we27jm1xUzgGMJxBjtUFCIWeBxTsMeJTOJ6chZmAY,12049
|
| 34 |
+
packaging/metadata.py,sha256=8IZErqQQnNm53dZZuYq4FGU4_dpyinMeH1QFBIWIkfE,34739
|
| 35 |
+
packaging/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 36 |
+
packaging/requirements.py,sha256=gYyRSAdbrIyKDY66ugIDUQjRMvxkH2ALioTmX3tnL6o,2947
|
| 37 |
+
packaging/specifiers.py,sha256=gtPu5DTc-F9baLq3FTGEK6dPhHGCuwwZetaY0PSV2gs,40055
|
| 38 |
+
packaging/tags.py,sha256=41s97W9Zatrq2Ed7Rc3qeBDaHe8pKKvYq2mGjwahfXk,22745
|
| 39 |
+
packaging/utils.py,sha256=0F3Hh9OFuRgrhTgGZUl5K22Fv1YP2tZl1z_2gO6kJiA,5050
|
| 40 |
+
packaging/version.py,sha256=olfyuk_DPbflNkJ4wBWetXQ17c74x3DB501degUv7DY,16676
|
bertvenv/lib/python3.10/site-packages/packaging-25.0.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: flit 3.12.0
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py3-none-any
|
bertvenv/lib/python3.10/site-packages/packaging-25.0.dist-info/licenses/LICENSE
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
This software is made available under the terms of *either* of the licenses
|
| 2 |
+
found in LICENSE.APACHE or LICENSE.BSD. Contributions to this software is made
|
| 3 |
+
under the terms of *both* these licenses.
|
bertvenv/lib/python3.10/site-packages/packaging-25.0.dist-info/licenses/LICENSE.APACHE
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Apache License
|
| 3 |
+
Version 2.0, January 2004
|
| 4 |
+
http://www.apache.org/licenses/
|
| 5 |
+
|
| 6 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 7 |
+
|
| 8 |
+
1. Definitions.
|
| 9 |
+
|
| 10 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 11 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 12 |
+
|
| 13 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 14 |
+
the copyright owner that is granting the License.
|
| 15 |
+
|
| 16 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 17 |
+
other entities that control, are controlled by, or are under common
|
| 18 |
+
control with that entity. For the purposes of this definition,
|
| 19 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 20 |
+
direction or management of such entity, whether by contract or
|
| 21 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 22 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 23 |
+
|
| 24 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 25 |
+
exercising permissions granted by this License.
|
| 26 |
+
|
| 27 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 28 |
+
including but not limited to software source code, documentation
|
| 29 |
+
source, and configuration files.
|
| 30 |
+
|
| 31 |
+
"Object" form shall mean any form resulting from mechanical
|
| 32 |
+
transformation or translation of a Source form, including but
|
| 33 |
+
not limited to compiled object code, generated documentation,
|
| 34 |
+
and conversions to other media types.
|
| 35 |
+
|
| 36 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 37 |
+
Object form, made available under the License, as indicated by a
|
| 38 |
+
copyright notice that is included in or attached to the work
|
| 39 |
+
(an example is provided in the Appendix below).
|
| 40 |
+
|
| 41 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 42 |
+
form, that is based on (or derived from) the Work and for which the
|
| 43 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 44 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 45 |
+
of this License, Derivative Works shall not include works that remain
|
| 46 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 47 |
+
the Work and Derivative Works thereof.
|
| 48 |
+
|
| 49 |
+
"Contribution" shall mean any work of authorship, including
|
| 50 |
+
the original version of the Work and any modifications or additions
|
| 51 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 52 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 53 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 54 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 55 |
+
means any form of electronic, verbal, or written communication sent
|
| 56 |
+
to the Licensor or its representatives, including but not limited to
|
| 57 |
+
communication on electronic mailing lists, source code control systems,
|
| 58 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 59 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 60 |
+
excluding communication that is conspicuously marked or otherwise
|
| 61 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 62 |
+
|
| 63 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 64 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 65 |
+
subsequently incorporated within the Work.
|
| 66 |
+
|
| 67 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 68 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 69 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 70 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 71 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 72 |
+
Work and such Derivative Works in Source or Object form.
|
| 73 |
+
|
| 74 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 75 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 76 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 77 |
+
(except as stated in this section) patent license to make, have made,
|
| 78 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 79 |
+
where such license applies only to those patent claims licensable
|
| 80 |
+
by such Contributor that are necessarily infringed by their
|
| 81 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 82 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 83 |
+
institute patent litigation against any entity (including a
|
| 84 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 85 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 86 |
+
or contributory patent infringement, then any patent licenses
|
| 87 |
+
granted to You under this License for that Work shall terminate
|
| 88 |
+
as of the date such litigation is filed.
|
| 89 |
+
|
| 90 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 91 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 92 |
+
modifications, and in Source or Object form, provided that You
|
| 93 |
+
meet the following conditions:
|
| 94 |
+
|
| 95 |
+
(a) You must give any other recipients of the Work or
|
| 96 |
+
Derivative Works a copy of this License; and
|
| 97 |
+
|
| 98 |
+
(b) You must cause any modified files to carry prominent notices
|
| 99 |
+
stating that You changed the files; and
|
| 100 |
+
|
| 101 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 102 |
+
that You distribute, all copyright, patent, trademark, and
|
| 103 |
+
attribution notices from the Source form of the Work,
|
| 104 |
+
excluding those notices that do not pertain to any part of
|
| 105 |
+
the Derivative Works; and
|
| 106 |
+
|
| 107 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 108 |
+
distribution, then any Derivative Works that You distribute must
|
| 109 |
+
include a readable copy of the attribution notices contained
|
| 110 |
+
within such NOTICE file, excluding those notices that do not
|
| 111 |
+
pertain to any part of the Derivative Works, in at least one
|
| 112 |
+
of the following places: within a NOTICE text file distributed
|
| 113 |
+
as part of the Derivative Works; within the Source form or
|
| 114 |
+
documentation, if provided along with the Derivative Works; or,
|
| 115 |
+
within a display generated by the Derivative Works, if and
|
| 116 |
+
wherever such third-party notices normally appear. The contents
|
| 117 |
+
of the NOTICE file are for informational purposes only and
|
| 118 |
+
do not modify the License. You may add Your own attribution
|
| 119 |
+
notices within Derivative Works that You distribute, alongside
|
| 120 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 121 |
+
that such additional attribution notices cannot be construed
|
| 122 |
+
as modifying the License.
|
| 123 |
+
|
| 124 |
+
You may add Your own copyright statement to Your modifications and
|
| 125 |
+
may provide additional or different license terms and conditions
|
| 126 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 127 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 128 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 129 |
+
the conditions stated in this License.
|
| 130 |
+
|
| 131 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 132 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 133 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 134 |
+
this License, without any additional terms or conditions.
|
| 135 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 136 |
+
the terms of any separate license agreement you may have executed
|
| 137 |
+
with Licensor regarding such Contributions.
|
| 138 |
+
|
| 139 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 140 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 141 |
+
except as required for reasonable and customary use in describing the
|
| 142 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 143 |
+
|
| 144 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 145 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 146 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 147 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 148 |
+
implied, including, without limitation, any warranties or conditions
|
| 149 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 150 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 151 |
+
appropriateness of using or redistributing the Work and assume any
|
| 152 |
+
risks associated with Your exercise of permissions under this License.
|
| 153 |
+
|
| 154 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 155 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 156 |
+
unless required by applicable law (such as deliberate and grossly
|
| 157 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 158 |
+
liable to You for damages, including any direct, indirect, special,
|
| 159 |
+
incidental, or consequential damages of any character arising as a
|
| 160 |
+
result of this License or out of the use or inability to use the
|
| 161 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 162 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 163 |
+
other commercial damages or losses), even if such Contributor
|
| 164 |
+
has been advised of the possibility of such damages.
|
| 165 |
+
|
| 166 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 167 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 168 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 169 |
+
or other liability obligations and/or rights consistent with this
|
| 170 |
+
License. However, in accepting such obligations, You may act only
|
| 171 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 172 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 173 |
+
defend, and hold each Contributor harmless for any liability
|
| 174 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 175 |
+
of your accepting any such warranty or additional liability.
|
| 176 |
+
|
| 177 |
+
END OF TERMS AND CONDITIONS
|
bertvenv/lib/python3.10/site-packages/packaging-25.0.dist-info/licenses/LICENSE.BSD
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (c) Donald Stufft and individual contributors.
|
| 2 |
+
All rights reserved.
|
| 3 |
+
|
| 4 |
+
Redistribution and use in source and binary forms, with or without
|
| 5 |
+
modification, are permitted provided that the following conditions are met:
|
| 6 |
+
|
| 7 |
+
1. Redistributions of source code must retain the above copyright notice,
|
| 8 |
+
this list of conditions and the following disclaimer.
|
| 9 |
+
|
| 10 |
+
2. Redistributions in binary form must reproduce the above copyright
|
| 11 |
+
notice, this list of conditions and the following disclaimer in the
|
| 12 |
+
documentation and/or other materials provided with the distribution.
|
| 13 |
+
|
| 14 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
| 15 |
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
| 16 |
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| 17 |
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
| 18 |
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 19 |
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
| 20 |
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
| 21 |
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
| 22 |
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 23 |
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/__init__.py
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# http://www.python.org/dev/peps/pep-0396/
|
| 2 |
+
__version__ = '0.4.2'
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/pem.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# This file is part of pyasn1-modules software.
|
| 3 |
+
#
|
| 4 |
+
# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
|
| 5 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 6 |
+
#
|
| 7 |
+
import base64
|
| 8 |
+
|
| 9 |
+
stSpam, stHam, stDump = 0, 1, 2
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
# The markers parameters is in form ('start1', 'stop1'), ('start2', 'stop2')...
|
| 13 |
+
# Return is (marker-index, substrate)
|
| 14 |
+
def readPemBlocksFromFile(fileObj, *markers):
|
| 15 |
+
startMarkers = dict(map(lambda x: (x[1], x[0]),
|
| 16 |
+
enumerate(map(lambda y: y[0], markers))))
|
| 17 |
+
stopMarkers = dict(map(lambda x: (x[1], x[0]),
|
| 18 |
+
enumerate(map(lambda y: y[1], markers))))
|
| 19 |
+
idx = -1
|
| 20 |
+
substrate = ''
|
| 21 |
+
certLines = []
|
| 22 |
+
state = stSpam
|
| 23 |
+
while True:
|
| 24 |
+
certLine = fileObj.readline()
|
| 25 |
+
if not certLine:
|
| 26 |
+
break
|
| 27 |
+
certLine = certLine.strip()
|
| 28 |
+
if state == stSpam:
|
| 29 |
+
if certLine in startMarkers:
|
| 30 |
+
certLines = []
|
| 31 |
+
idx = startMarkers[certLine]
|
| 32 |
+
state = stHam
|
| 33 |
+
continue
|
| 34 |
+
if state == stHam:
|
| 35 |
+
if certLine in stopMarkers and stopMarkers[certLine] == idx:
|
| 36 |
+
state = stDump
|
| 37 |
+
else:
|
| 38 |
+
certLines.append(certLine)
|
| 39 |
+
if state == stDump:
|
| 40 |
+
substrate = ''.encode().join([base64.b64decode(x.encode()) for x in certLines])
|
| 41 |
+
break
|
| 42 |
+
return idx, substrate
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
# Backward compatibility routine
|
| 46 |
+
def readPemFromFile(fileObj,
|
| 47 |
+
startMarker='-----BEGIN CERTIFICATE-----',
|
| 48 |
+
endMarker='-----END CERTIFICATE-----'):
|
| 49 |
+
idx, substrate = readPemBlocksFromFile(fileObj, (startMarker, endMarker))
|
| 50 |
+
return substrate
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def readBase64fromText(text):
|
| 54 |
+
return base64.b64decode(text.encode())
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def readBase64FromFile(fileObj):
|
| 58 |
+
return readBase64fromText(fileObj.read())
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc1157.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# This file is part of pyasn1-modules software.
|
| 3 |
+
#
|
| 4 |
+
# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
|
| 5 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 6 |
+
#
|
| 7 |
+
# SNMPv1 message syntax
|
| 8 |
+
#
|
| 9 |
+
# ASN.1 source from:
|
| 10 |
+
# http://www.ietf.org/rfc/rfc1157.txt
|
| 11 |
+
#
|
| 12 |
+
# Sample captures from:
|
| 13 |
+
# http://wiki.wireshark.org/SampleCaptures/
|
| 14 |
+
#
|
| 15 |
+
from pyasn1.type import namedtype
|
| 16 |
+
from pyasn1.type import namedval
|
| 17 |
+
from pyasn1.type import tag
|
| 18 |
+
from pyasn1.type import univ
|
| 19 |
+
|
| 20 |
+
from pyasn1_modules import rfc1155
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class Version(univ.Integer):
|
| 24 |
+
namedValues = namedval.NamedValues(
|
| 25 |
+
('version-1', 0)
|
| 26 |
+
)
|
| 27 |
+
defaultValue = 0
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class Community(univ.OctetString):
|
| 31 |
+
pass
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
class RequestID(univ.Integer):
|
| 35 |
+
pass
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
class ErrorStatus(univ.Integer):
|
| 39 |
+
namedValues = namedval.NamedValues(
|
| 40 |
+
('noError', 0),
|
| 41 |
+
('tooBig', 1),
|
| 42 |
+
('noSuchName', 2),
|
| 43 |
+
('badValue', 3),
|
| 44 |
+
('readOnly', 4),
|
| 45 |
+
('genErr', 5)
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
class ErrorIndex(univ.Integer):
|
| 50 |
+
pass
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
class VarBind(univ.Sequence):
|
| 54 |
+
componentType = namedtype.NamedTypes(
|
| 55 |
+
namedtype.NamedType('name', rfc1155.ObjectName()),
|
| 56 |
+
namedtype.NamedType('value', rfc1155.ObjectSyntax())
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
class VarBindList(univ.SequenceOf):
|
| 61 |
+
componentType = VarBind()
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
class _RequestBase(univ.Sequence):
|
| 65 |
+
componentType = namedtype.NamedTypes(
|
| 66 |
+
namedtype.NamedType('request-id', RequestID()),
|
| 67 |
+
namedtype.NamedType('error-status', ErrorStatus()),
|
| 68 |
+
namedtype.NamedType('error-index', ErrorIndex()),
|
| 69 |
+
namedtype.NamedType('variable-bindings', VarBindList())
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
class GetRequestPDU(_RequestBase):
|
| 74 |
+
tagSet = _RequestBase.tagSet.tagImplicitly(
|
| 75 |
+
tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
class GetNextRequestPDU(_RequestBase):
|
| 80 |
+
tagSet = _RequestBase.tagSet.tagImplicitly(
|
| 81 |
+
tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1)
|
| 82 |
+
)
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
class GetResponsePDU(_RequestBase):
|
| 86 |
+
tagSet = _RequestBase.tagSet.tagImplicitly(
|
| 87 |
+
tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2)
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
class SetRequestPDU(_RequestBase):
|
| 92 |
+
tagSet = _RequestBase.tagSet.tagImplicitly(
|
| 93 |
+
tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3)
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
class TrapPDU(univ.Sequence):
|
| 98 |
+
componentType = namedtype.NamedTypes(
|
| 99 |
+
namedtype.NamedType('enterprise', univ.ObjectIdentifier()),
|
| 100 |
+
namedtype.NamedType('agent-addr', rfc1155.NetworkAddress()),
|
| 101 |
+
namedtype.NamedType('generic-trap', univ.Integer().clone(
|
| 102 |
+
namedValues=namedval.NamedValues(('coldStart', 0), ('warmStart', 1), ('linkDown', 2), ('linkUp', 3),
|
| 103 |
+
('authenticationFailure', 4), ('egpNeighborLoss', 5),
|
| 104 |
+
('enterpriseSpecific', 6)))),
|
| 105 |
+
namedtype.NamedType('specific-trap', univ.Integer()),
|
| 106 |
+
namedtype.NamedType('time-stamp', rfc1155.TimeTicks()),
|
| 107 |
+
namedtype.NamedType('variable-bindings', VarBindList())
|
| 108 |
+
)
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
class Pdus(univ.Choice):
|
| 112 |
+
componentType = namedtype.NamedTypes(
|
| 113 |
+
namedtype.NamedType('get-request', GetRequestPDU()),
|
| 114 |
+
namedtype.NamedType('get-next-request', GetNextRequestPDU()),
|
| 115 |
+
namedtype.NamedType('get-response', GetResponsePDU()),
|
| 116 |
+
namedtype.NamedType('set-request', SetRequestPDU()),
|
| 117 |
+
namedtype.NamedType('trap', TrapPDU())
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
class Message(univ.Sequence):
|
| 122 |
+
componentType = namedtype.NamedTypes(
|
| 123 |
+
namedtype.NamedType('version', Version()),
|
| 124 |
+
namedtype.NamedType('community', Community()),
|
| 125 |
+
namedtype.NamedType('data', Pdus())
|
| 126 |
+
)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc1901.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# This file is part of pyasn1-modules software.
|
| 3 |
+
#
|
| 4 |
+
# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
|
| 5 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 6 |
+
#
|
| 7 |
+
# SNMPv2c message syntax
|
| 8 |
+
#
|
| 9 |
+
# ASN.1 source from:
|
| 10 |
+
# http://www.ietf.org/rfc/rfc1901.txt
|
| 11 |
+
#
|
| 12 |
+
from pyasn1.type import namedtype
|
| 13 |
+
from pyasn1.type import namedval
|
| 14 |
+
from pyasn1.type import univ
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class Message(univ.Sequence):
|
| 18 |
+
componentType = namedtype.NamedTypes(
|
| 19 |
+
namedtype.NamedType('version', univ.Integer(namedValues=namedval.NamedValues(('version-2c', 1)))),
|
| 20 |
+
namedtype.NamedType('community', univ.OctetString()),
|
| 21 |
+
namedtype.NamedType('data', univ.Any())
|
| 22 |
+
)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc1905.py
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# This file is part of pyasn1-modules software.
|
| 3 |
+
#
|
| 4 |
+
# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
|
| 5 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 6 |
+
#
|
| 7 |
+
# SNMPv2c PDU syntax
|
| 8 |
+
#
|
| 9 |
+
# ASN.1 source from:
|
| 10 |
+
# http://www.ietf.org/rfc/rfc1905.txt
|
| 11 |
+
#
|
| 12 |
+
from pyasn1.type import constraint
|
| 13 |
+
from pyasn1.type import namedtype
|
| 14 |
+
from pyasn1.type import namedval
|
| 15 |
+
from pyasn1.type import tag
|
| 16 |
+
from pyasn1.type import univ
|
| 17 |
+
|
| 18 |
+
from pyasn1_modules import rfc1902
|
| 19 |
+
|
| 20 |
+
max_bindings = rfc1902.Integer(2147483647)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class _BindValue(univ.Choice):
|
| 24 |
+
componentType = namedtype.NamedTypes(
|
| 25 |
+
namedtype.NamedType('value', rfc1902.ObjectSyntax()),
|
| 26 |
+
namedtype.NamedType('unSpecified', univ.Null()),
|
| 27 |
+
namedtype.NamedType('noSuchObject',
|
| 28 |
+
univ.Null().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 29 |
+
namedtype.NamedType('noSuchInstance',
|
| 30 |
+
univ.Null().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 31 |
+
namedtype.NamedType('endOfMibView',
|
| 32 |
+
univ.Null().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
class VarBind(univ.Sequence):
|
| 37 |
+
componentType = namedtype.NamedTypes(
|
| 38 |
+
namedtype.NamedType('name', rfc1902.ObjectName()),
|
| 39 |
+
namedtype.NamedType('', _BindValue())
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
class VarBindList(univ.SequenceOf):
|
| 44 |
+
componentType = VarBind()
|
| 45 |
+
sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(
|
| 46 |
+
0, max_bindings
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
class PDU(univ.Sequence):
|
| 51 |
+
componentType = namedtype.NamedTypes(
|
| 52 |
+
namedtype.NamedType('request-id', rfc1902.Integer32()),
|
| 53 |
+
namedtype.NamedType('error-status', univ.Integer(
|
| 54 |
+
namedValues=namedval.NamedValues(('noError', 0), ('tooBig', 1), ('noSuchName', 2), ('badValue', 3),
|
| 55 |
+
('readOnly', 4), ('genErr', 5), ('noAccess', 6), ('wrongType', 7),
|
| 56 |
+
('wrongLength', 8), ('wrongEncoding', 9), ('wrongValue', 10),
|
| 57 |
+
('noCreation', 11), ('inconsistentValue', 12), ('resourceUnavailable', 13),
|
| 58 |
+
('commitFailed', 14), ('undoFailed', 15), ('authorizationError', 16),
|
| 59 |
+
('notWritable', 17), ('inconsistentName', 18)))),
|
| 60 |
+
namedtype.NamedType('error-index',
|
| 61 |
+
univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, max_bindings))),
|
| 62 |
+
namedtype.NamedType('variable-bindings', VarBindList())
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
class BulkPDU(univ.Sequence):
|
| 67 |
+
componentType = namedtype.NamedTypes(
|
| 68 |
+
namedtype.NamedType('request-id', rfc1902.Integer32()),
|
| 69 |
+
namedtype.NamedType('non-repeaters',
|
| 70 |
+
univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, max_bindings))),
|
| 71 |
+
namedtype.NamedType('max-repetitions',
|
| 72 |
+
univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, max_bindings))),
|
| 73 |
+
namedtype.NamedType('variable-bindings', VarBindList())
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
class GetRequestPDU(PDU):
|
| 78 |
+
tagSet = PDU.tagSet.tagImplicitly(
|
| 79 |
+
tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
class GetNextRequestPDU(PDU):
|
| 84 |
+
tagSet = PDU.tagSet.tagImplicitly(
|
| 85 |
+
tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1)
|
| 86 |
+
)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
class ResponsePDU(PDU):
|
| 90 |
+
tagSet = PDU.tagSet.tagImplicitly(
|
| 91 |
+
tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2)
|
| 92 |
+
)
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
class SetRequestPDU(PDU):
|
| 96 |
+
tagSet = PDU.tagSet.tagImplicitly(
|
| 97 |
+
tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3)
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
class GetBulkRequestPDU(BulkPDU):
|
| 102 |
+
tagSet = PDU.tagSet.tagImplicitly(
|
| 103 |
+
tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 5)
|
| 104 |
+
)
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
class InformRequestPDU(PDU):
|
| 108 |
+
tagSet = PDU.tagSet.tagImplicitly(
|
| 109 |
+
tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 6)
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
class SNMPv2TrapPDU(PDU):
|
| 114 |
+
tagSet = PDU.tagSet.tagImplicitly(
|
| 115 |
+
tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 7)
|
| 116 |
+
)
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
class ReportPDU(PDU):
|
| 120 |
+
tagSet = PDU.tagSet.tagImplicitly(
|
| 121 |
+
tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 8)
|
| 122 |
+
)
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
class PDUs(univ.Choice):
|
| 126 |
+
componentType = namedtype.NamedTypes(
|
| 127 |
+
namedtype.NamedType('get-request', GetRequestPDU()),
|
| 128 |
+
namedtype.NamedType('get-next-request', GetNextRequestPDU()),
|
| 129 |
+
namedtype.NamedType('get-bulk-request', GetBulkRequestPDU()),
|
| 130 |
+
namedtype.NamedType('response', ResponsePDU()),
|
| 131 |
+
namedtype.NamedType('set-request', SetRequestPDU()),
|
| 132 |
+
namedtype.NamedType('inform-request', InformRequestPDU()),
|
| 133 |
+
namedtype.NamedType('snmpV2-trap', SNMPv2TrapPDU()),
|
| 134 |
+
namedtype.NamedType('report', ReportPDU())
|
| 135 |
+
)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc2314.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# This file is part of pyasn1-modules software.
|
| 3 |
+
#
|
| 4 |
+
# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
|
| 5 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 6 |
+
#
|
| 7 |
+
# PKCS#10 syntax
|
| 8 |
+
#
|
| 9 |
+
# ASN.1 source from:
|
| 10 |
+
# http://tools.ietf.org/html/rfc2314
|
| 11 |
+
#
|
| 12 |
+
# Sample captures could be obtained with "openssl req" command
|
| 13 |
+
#
|
| 14 |
+
from pyasn1_modules.rfc2459 import *
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class Attributes(univ.SetOf):
|
| 18 |
+
componentType = Attribute()
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class Version(univ.Integer):
|
| 22 |
+
pass
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class CertificationRequestInfo(univ.Sequence):
|
| 26 |
+
componentType = namedtype.NamedTypes(
|
| 27 |
+
namedtype.NamedType('version', Version()),
|
| 28 |
+
namedtype.NamedType('subject', Name()),
|
| 29 |
+
namedtype.NamedType('subjectPublicKeyInfo', SubjectPublicKeyInfo()),
|
| 30 |
+
namedtype.NamedType('attributes',
|
| 31 |
+
Attributes().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class Signature(univ.BitString):
|
| 36 |
+
pass
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
class SignatureAlgorithmIdentifier(AlgorithmIdentifier):
|
| 40 |
+
pass
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
class CertificationRequest(univ.Sequence):
|
| 44 |
+
componentType = namedtype.NamedTypes(
|
| 45 |
+
namedtype.NamedType('certificationRequestInfo', CertificationRequestInfo()),
|
| 46 |
+
namedtype.NamedType('signatureAlgorithm', SignatureAlgorithmIdentifier()),
|
| 47 |
+
namedtype.NamedType('signature', Signature())
|
| 48 |
+
)
|
b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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# This file is part of pyasn1-modules software.
|
| 3 |
+
#
|
| 4 |
+
# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
|
| 5 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 6 |
+
#
|
| 7 |
+
# PKCS#7 message syntax
|
| 8 |
+
#
|
| 9 |
+
# ASN.1 source from:
|
| 10 |
+
# https://opensource.apple.com/source/Security/Security-55179.1/libsecurity_asn1/asn1/pkcs7.asn.auto.html
|
| 11 |
+
#
|
| 12 |
+
# Sample captures from:
|
| 13 |
+
# openssl crl2pkcs7 -nocrl -certfile cert1.cer -out outfile.p7b
|
| 14 |
+
#
|
| 15 |
+
from pyasn1_modules.rfc2459 import *
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class Attribute(univ.Sequence):
|
| 19 |
+
componentType = namedtype.NamedTypes(
|
| 20 |
+
namedtype.NamedType('type', AttributeType()),
|
| 21 |
+
namedtype.NamedType('values', univ.SetOf(componentType=AttributeValue()))
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class AttributeValueAssertion(univ.Sequence):
|
| 26 |
+
componentType = namedtype.NamedTypes(
|
| 27 |
+
namedtype.NamedType('attributeType', AttributeType()),
|
| 28 |
+
namedtype.NamedType('attributeValue', AttributeValue(),
|
| 29 |
+
openType=opentype.OpenType('type', certificateAttributesMap))
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
pkcs_7 = univ.ObjectIdentifier('1.2.840.113549.1.7')
|
| 34 |
+
data = univ.ObjectIdentifier('1.2.840.113549.1.7.1')
|
| 35 |
+
signedData = univ.ObjectIdentifier('1.2.840.113549.1.7.2')
|
| 36 |
+
envelopedData = univ.ObjectIdentifier('1.2.840.113549.1.7.3')
|
| 37 |
+
signedAndEnvelopedData = univ.ObjectIdentifier('1.2.840.113549.1.7.4')
|
| 38 |
+
digestedData = univ.ObjectIdentifier('1.2.840.113549.1.7.5')
|
| 39 |
+
encryptedData = univ.ObjectIdentifier('1.2.840.113549.1.7.6')
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class ContentType(univ.ObjectIdentifier):
|
| 43 |
+
pass
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
class ContentEncryptionAlgorithmIdentifier(AlgorithmIdentifier):
|
| 47 |
+
pass
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
class EncryptedContent(univ.OctetString):
|
| 51 |
+
pass
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
contentTypeMap = {}
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class EncryptedContentInfo(univ.Sequence):
|
| 58 |
+
componentType = namedtype.NamedTypes(
|
| 59 |
+
namedtype.NamedType('contentType', ContentType()),
|
| 60 |
+
namedtype.NamedType('contentEncryptionAlgorithm', ContentEncryptionAlgorithmIdentifier()),
|
| 61 |
+
namedtype.OptionalNamedType(
|
| 62 |
+
'encryptedContent', EncryptedContent().subtype(
|
| 63 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)
|
| 64 |
+
),
|
| 65 |
+
openType=opentype.OpenType('contentType', contentTypeMap)
|
| 66 |
+
)
|
| 67 |
+
)
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
class Version(univ.Integer): # overrides x509.Version
|
| 71 |
+
pass
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
class EncryptedData(univ.Sequence):
|
| 75 |
+
componentType = namedtype.NamedTypes(
|
| 76 |
+
namedtype.NamedType('version', Version()),
|
| 77 |
+
namedtype.NamedType('encryptedContentInfo', EncryptedContentInfo())
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
class DigestAlgorithmIdentifier(AlgorithmIdentifier):
|
| 82 |
+
pass
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
class DigestAlgorithmIdentifiers(univ.SetOf):
|
| 86 |
+
componentType = DigestAlgorithmIdentifier()
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
class Digest(univ.OctetString):
|
| 90 |
+
pass
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
class ContentInfo(univ.Sequence):
|
| 94 |
+
componentType = namedtype.NamedTypes(
|
| 95 |
+
namedtype.NamedType('contentType', ContentType()),
|
| 96 |
+
namedtype.OptionalNamedType(
|
| 97 |
+
'content',
|
| 98 |
+
univ.Any().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)),
|
| 99 |
+
openType=opentype.OpenType('contentType', contentTypeMap)
|
| 100 |
+
)
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
class DigestedData(univ.Sequence):
|
| 105 |
+
componentType = namedtype.NamedTypes(
|
| 106 |
+
namedtype.NamedType('version', Version()),
|
| 107 |
+
namedtype.NamedType('digestAlgorithm', DigestAlgorithmIdentifier()),
|
| 108 |
+
namedtype.NamedType('contentInfo', ContentInfo()),
|
| 109 |
+
namedtype.NamedType('digest', Digest())
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
class IssuerAndSerialNumber(univ.Sequence):
|
| 114 |
+
componentType = namedtype.NamedTypes(
|
| 115 |
+
namedtype.NamedType('issuer', Name()),
|
| 116 |
+
namedtype.NamedType('serialNumber', CertificateSerialNumber())
|
| 117 |
+
)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
class KeyEncryptionAlgorithmIdentifier(AlgorithmIdentifier):
|
| 121 |
+
pass
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
class EncryptedKey(univ.OctetString):
|
| 125 |
+
pass
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
class RecipientInfo(univ.Sequence):
|
| 129 |
+
componentType = namedtype.NamedTypes(
|
| 130 |
+
namedtype.NamedType('version', Version()),
|
| 131 |
+
namedtype.NamedType('issuerAndSerialNumber', IssuerAndSerialNumber()),
|
| 132 |
+
namedtype.NamedType('keyEncryptionAlgorithm', KeyEncryptionAlgorithmIdentifier()),
|
| 133 |
+
namedtype.NamedType('encryptedKey', EncryptedKey())
|
| 134 |
+
)
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
class RecipientInfos(univ.SetOf):
|
| 138 |
+
componentType = RecipientInfo()
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
class Attributes(univ.SetOf):
|
| 142 |
+
componentType = Attribute()
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
class ExtendedCertificateInfo(univ.Sequence):
|
| 146 |
+
componentType = namedtype.NamedTypes(
|
| 147 |
+
namedtype.NamedType('version', Version()),
|
| 148 |
+
namedtype.NamedType('certificate', Certificate()),
|
| 149 |
+
namedtype.NamedType('attributes', Attributes())
|
| 150 |
+
)
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
class SignatureAlgorithmIdentifier(AlgorithmIdentifier):
|
| 154 |
+
pass
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
class Signature(univ.BitString):
|
| 158 |
+
pass
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
class ExtendedCertificate(univ.Sequence):
|
| 162 |
+
componentType = namedtype.NamedTypes(
|
| 163 |
+
namedtype.NamedType('extendedCertificateInfo', ExtendedCertificateInfo()),
|
| 164 |
+
namedtype.NamedType('signatureAlgorithm', SignatureAlgorithmIdentifier()),
|
| 165 |
+
namedtype.NamedType('signature', Signature())
|
| 166 |
+
)
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
class ExtendedCertificateOrCertificate(univ.Choice):
|
| 170 |
+
componentType = namedtype.NamedTypes(
|
| 171 |
+
namedtype.NamedType('certificate', Certificate()),
|
| 172 |
+
namedtype.NamedType('extendedCertificate', ExtendedCertificate().subtype(
|
| 173 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))
|
| 174 |
+
)
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
class ExtendedCertificatesAndCertificates(univ.SetOf):
|
| 178 |
+
componentType = ExtendedCertificateOrCertificate()
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
class SerialNumber(univ.Integer):
|
| 182 |
+
pass
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
class CRLEntry(univ.Sequence):
|
| 186 |
+
componentType = namedtype.NamedTypes(
|
| 187 |
+
namedtype.NamedType('userCertificate', SerialNumber()),
|
| 188 |
+
namedtype.NamedType('revocationDate', useful.UTCTime())
|
| 189 |
+
)
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
class TBSCertificateRevocationList(univ.Sequence):
|
| 193 |
+
componentType = namedtype.NamedTypes(
|
| 194 |
+
namedtype.NamedType('signature', AlgorithmIdentifier()),
|
| 195 |
+
namedtype.NamedType('issuer', Name()),
|
| 196 |
+
namedtype.NamedType('lastUpdate', useful.UTCTime()),
|
| 197 |
+
namedtype.NamedType('nextUpdate', useful.UTCTime()),
|
| 198 |
+
namedtype.OptionalNamedType('revokedCertificates', univ.SequenceOf(componentType=CRLEntry()))
|
| 199 |
+
)
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
class CertificateRevocationList(univ.Sequence):
|
| 203 |
+
componentType = namedtype.NamedTypes(
|
| 204 |
+
namedtype.NamedType('tbsCertificateRevocationList', TBSCertificateRevocationList()),
|
| 205 |
+
namedtype.NamedType('signatureAlgorithm', AlgorithmIdentifier()),
|
| 206 |
+
namedtype.NamedType('signature', univ.BitString())
|
| 207 |
+
)
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
class CertificateRevocationLists(univ.SetOf):
|
| 211 |
+
componentType = CertificateRevocationList()
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
class DigestEncryptionAlgorithmIdentifier(AlgorithmIdentifier):
|
| 215 |
+
pass
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
class EncryptedDigest(univ.OctetString):
|
| 219 |
+
pass
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
class SignerInfo(univ.Sequence):
|
| 223 |
+
componentType = namedtype.NamedTypes(
|
| 224 |
+
namedtype.NamedType('version', Version()),
|
| 225 |
+
namedtype.NamedType('issuerAndSerialNumber', IssuerAndSerialNumber()),
|
| 226 |
+
namedtype.NamedType('digestAlgorithm', DigestAlgorithmIdentifier()),
|
| 227 |
+
namedtype.OptionalNamedType('authenticatedAttributes', Attributes().subtype(
|
| 228 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 229 |
+
namedtype.NamedType('digestEncryptionAlgorithm', DigestEncryptionAlgorithmIdentifier()),
|
| 230 |
+
namedtype.NamedType('encryptedDigest', EncryptedDigest()),
|
| 231 |
+
namedtype.OptionalNamedType('unauthenticatedAttributes', Attributes().subtype(
|
| 232 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1)))
|
| 233 |
+
)
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
class SignerInfos(univ.SetOf):
|
| 237 |
+
componentType = SignerInfo()
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
class SignedAndEnvelopedData(univ.Sequence):
|
| 241 |
+
componentType = namedtype.NamedTypes(
|
| 242 |
+
namedtype.NamedType('version', Version()),
|
| 243 |
+
namedtype.NamedType('recipientInfos', RecipientInfos()),
|
| 244 |
+
namedtype.NamedType('digestAlgorithms', DigestAlgorithmIdentifiers()),
|
| 245 |
+
namedtype.NamedType('encryptedContentInfo', EncryptedContentInfo()),
|
| 246 |
+
namedtype.OptionalNamedType('certificates', ExtendedCertificatesAndCertificates().subtype(
|
| 247 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 248 |
+
namedtype.OptionalNamedType('crls', CertificateRevocationLists().subtype(
|
| 249 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),
|
| 250 |
+
namedtype.NamedType('signerInfos', SignerInfos())
|
| 251 |
+
)
|
| 252 |
+
|
| 253 |
+
|
| 254 |
+
class EnvelopedData(univ.Sequence):
|
| 255 |
+
componentType = namedtype.NamedTypes(
|
| 256 |
+
namedtype.NamedType('version', Version()),
|
| 257 |
+
namedtype.NamedType('recipientInfos', RecipientInfos()),
|
| 258 |
+
namedtype.NamedType('encryptedContentInfo', EncryptedContentInfo())
|
| 259 |
+
)
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
class DigestInfo(univ.Sequence):
|
| 263 |
+
componentType = namedtype.NamedTypes(
|
| 264 |
+
namedtype.NamedType('digestAlgorithm', DigestAlgorithmIdentifier()),
|
| 265 |
+
namedtype.NamedType('digest', Digest())
|
| 266 |
+
)
|
| 267 |
+
|
| 268 |
+
|
| 269 |
+
class SignedData(univ.Sequence):
|
| 270 |
+
componentType = namedtype.NamedTypes(
|
| 271 |
+
namedtype.NamedType('version', Version()),
|
| 272 |
+
namedtype.OptionalNamedType('digestAlgorithms', DigestAlgorithmIdentifiers()),
|
| 273 |
+
namedtype.NamedType('contentInfo', ContentInfo()),
|
| 274 |
+
namedtype.OptionalNamedType('certificates', ExtendedCertificatesAndCertificates().subtype(
|
| 275 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 276 |
+
namedtype.OptionalNamedType('crls', CertificateRevocationLists().subtype(
|
| 277 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),
|
| 278 |
+
namedtype.OptionalNamedType('signerInfos', SignerInfos())
|
| 279 |
+
)
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
class Data(univ.OctetString):
|
| 283 |
+
pass
|
| 284 |
+
|
| 285 |
+
_contentTypeMapUpdate = {
|
| 286 |
+
data: Data(),
|
| 287 |
+
signedData: SignedData(),
|
| 288 |
+
envelopedData: EnvelopedData(),
|
| 289 |
+
signedAndEnvelopedData: SignedAndEnvelopedData(),
|
| 290 |
+
digestedData: DigestedData(),
|
| 291 |
+
encryptedData: EncryptedData()
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
contentTypeMap.update(_contentTypeMapUpdate)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc2437.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# This file is part of pyasn1-modules software.
|
| 3 |
+
#
|
| 4 |
+
# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
|
| 5 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 6 |
+
#
|
| 7 |
+
# PKCS#1 syntax
|
| 8 |
+
#
|
| 9 |
+
# ASN.1 source from:
|
| 10 |
+
# ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2.asn
|
| 11 |
+
#
|
| 12 |
+
# Sample captures could be obtained with "openssl genrsa" command
|
| 13 |
+
#
|
| 14 |
+
from pyasn1.type import namedtype
|
| 15 |
+
from pyasn1.type import tag
|
| 16 |
+
from pyasn1.type import univ
|
| 17 |
+
|
| 18 |
+
from pyasn1_modules.rfc2459 import AlgorithmIdentifier
|
| 19 |
+
|
| 20 |
+
pkcs_1 = univ.ObjectIdentifier('1.2.840.113549.1.1')
|
| 21 |
+
rsaEncryption = univ.ObjectIdentifier('1.2.840.113549.1.1.1')
|
| 22 |
+
md2WithRSAEncryption = univ.ObjectIdentifier('1.2.840.113549.1.1.2')
|
| 23 |
+
md4WithRSAEncryption = univ.ObjectIdentifier('1.2.840.113549.1.1.3')
|
| 24 |
+
md5WithRSAEncryption = univ.ObjectIdentifier('1.2.840.113549.1.1.4')
|
| 25 |
+
sha1WithRSAEncryption = univ.ObjectIdentifier('1.2.840.113549.1.1.5')
|
| 26 |
+
rsaOAEPEncryptionSET = univ.ObjectIdentifier('1.2.840.113549.1.1.6')
|
| 27 |
+
id_RSAES_OAEP = univ.ObjectIdentifier('1.2.840.113549.1.1.7')
|
| 28 |
+
id_mgf1 = univ.ObjectIdentifier('1.2.840.113549.1.1.8')
|
| 29 |
+
id_pSpecified = univ.ObjectIdentifier('1.2.840.113549.1.1.9')
|
| 30 |
+
id_sha1 = univ.ObjectIdentifier('1.3.14.3.2.26')
|
| 31 |
+
|
| 32 |
+
MAX = float('inf')
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class Version(univ.Integer):
|
| 36 |
+
pass
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
class RSAPrivateKey(univ.Sequence):
|
| 40 |
+
componentType = namedtype.NamedTypes(
|
| 41 |
+
namedtype.NamedType('version', Version()),
|
| 42 |
+
namedtype.NamedType('modulus', univ.Integer()),
|
| 43 |
+
namedtype.NamedType('publicExponent', univ.Integer()),
|
| 44 |
+
namedtype.NamedType('privateExponent', univ.Integer()),
|
| 45 |
+
namedtype.NamedType('prime1', univ.Integer()),
|
| 46 |
+
namedtype.NamedType('prime2', univ.Integer()),
|
| 47 |
+
namedtype.NamedType('exponent1', univ.Integer()),
|
| 48 |
+
namedtype.NamedType('exponent2', univ.Integer()),
|
| 49 |
+
namedtype.NamedType('coefficient', univ.Integer())
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
class RSAPublicKey(univ.Sequence):
|
| 54 |
+
componentType = namedtype.NamedTypes(
|
| 55 |
+
namedtype.NamedType('modulus', univ.Integer()),
|
| 56 |
+
namedtype.NamedType('publicExponent', univ.Integer())
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
# XXX defaults not set
|
| 61 |
+
class RSAES_OAEP_params(univ.Sequence):
|
| 62 |
+
componentType = namedtype.NamedTypes(
|
| 63 |
+
namedtype.NamedType('hashFunc', AlgorithmIdentifier().subtype(
|
| 64 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 65 |
+
namedtype.NamedType('maskGenFunc', AlgorithmIdentifier().subtype(
|
| 66 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),
|
| 67 |
+
namedtype.NamedType('pSourceFunc', AlgorithmIdentifier().subtype(
|
| 68 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2)))
|
| 69 |
+
)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc2459.py
ADDED
|
@@ -0,0 +1,1339 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# This file is part of pyasn1-modules software.
|
| 3 |
+
#
|
| 4 |
+
# Updated by Russ Housley to resolve the TODO regarding the Certificate
|
| 5 |
+
# Policies Certificate Extension.
|
| 6 |
+
#
|
| 7 |
+
# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
|
| 8 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 9 |
+
#
|
| 10 |
+
# X.509 message syntax
|
| 11 |
+
#
|
| 12 |
+
# ASN.1 source from:
|
| 13 |
+
# http://www.trl.ibm.com/projects/xml/xss4j/data/asn1/grammars/x509.asn
|
| 14 |
+
# http://www.ietf.org/rfc/rfc2459.txt
|
| 15 |
+
#
|
| 16 |
+
# Sample captures from:
|
| 17 |
+
# http://wiki.wireshark.org/SampleCaptures/
|
| 18 |
+
#
|
| 19 |
+
from pyasn1.type import char
|
| 20 |
+
from pyasn1.type import constraint
|
| 21 |
+
from pyasn1.type import namedtype
|
| 22 |
+
from pyasn1.type import namedval
|
| 23 |
+
from pyasn1.type import opentype
|
| 24 |
+
from pyasn1.type import tag
|
| 25 |
+
from pyasn1.type import univ
|
| 26 |
+
from pyasn1.type import useful
|
| 27 |
+
|
| 28 |
+
MAX = float('inf')
|
| 29 |
+
|
| 30 |
+
#
|
| 31 |
+
# PKIX1Explicit88
|
| 32 |
+
#
|
| 33 |
+
|
| 34 |
+
# Upper Bounds
|
| 35 |
+
ub_name = univ.Integer(32768)
|
| 36 |
+
ub_common_name = univ.Integer(64)
|
| 37 |
+
ub_locality_name = univ.Integer(128)
|
| 38 |
+
ub_state_name = univ.Integer(128)
|
| 39 |
+
ub_organization_name = univ.Integer(64)
|
| 40 |
+
ub_organizational_unit_name = univ.Integer(64)
|
| 41 |
+
ub_title = univ.Integer(64)
|
| 42 |
+
ub_match = univ.Integer(128)
|
| 43 |
+
ub_emailaddress_length = univ.Integer(128)
|
| 44 |
+
ub_common_name_length = univ.Integer(64)
|
| 45 |
+
ub_country_name_alpha_length = univ.Integer(2)
|
| 46 |
+
ub_country_name_numeric_length = univ.Integer(3)
|
| 47 |
+
ub_domain_defined_attributes = univ.Integer(4)
|
| 48 |
+
ub_domain_defined_attribute_type_length = univ.Integer(8)
|
| 49 |
+
ub_domain_defined_attribute_value_length = univ.Integer(128)
|
| 50 |
+
ub_domain_name_length = univ.Integer(16)
|
| 51 |
+
ub_extension_attributes = univ.Integer(256)
|
| 52 |
+
ub_e163_4_number_length = univ.Integer(15)
|
| 53 |
+
ub_e163_4_sub_address_length = univ.Integer(40)
|
| 54 |
+
ub_generation_qualifier_length = univ.Integer(3)
|
| 55 |
+
ub_given_name_length = univ.Integer(16)
|
| 56 |
+
ub_initials_length = univ.Integer(5)
|
| 57 |
+
ub_integer_options = univ.Integer(256)
|
| 58 |
+
ub_numeric_user_id_length = univ.Integer(32)
|
| 59 |
+
ub_organization_name_length = univ.Integer(64)
|
| 60 |
+
ub_organizational_unit_name_length = univ.Integer(32)
|
| 61 |
+
ub_organizational_units = univ.Integer(4)
|
| 62 |
+
ub_pds_name_length = univ.Integer(16)
|
| 63 |
+
ub_pds_parameter_length = univ.Integer(30)
|
| 64 |
+
ub_pds_physical_address_lines = univ.Integer(6)
|
| 65 |
+
ub_postal_code_length = univ.Integer(16)
|
| 66 |
+
ub_surname_length = univ.Integer(40)
|
| 67 |
+
ub_terminal_id_length = univ.Integer(24)
|
| 68 |
+
ub_unformatted_address_length = univ.Integer(180)
|
| 69 |
+
ub_x121_address_length = univ.Integer(16)
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
class UniversalString(char.UniversalString):
|
| 73 |
+
pass
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
class BMPString(char.BMPString):
|
| 77 |
+
pass
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
class UTF8String(char.UTF8String):
|
| 81 |
+
pass
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
id_pkix = univ.ObjectIdentifier('1.3.6.1.5.5.7')
|
| 85 |
+
id_pe = univ.ObjectIdentifier('1.3.6.1.5.5.7.1')
|
| 86 |
+
id_qt = univ.ObjectIdentifier('1.3.6.1.5.5.7.2')
|
| 87 |
+
id_kp = univ.ObjectIdentifier('1.3.6.1.5.5.7.3')
|
| 88 |
+
id_ad = univ.ObjectIdentifier('1.3.6.1.5.5.7.48')
|
| 89 |
+
|
| 90 |
+
id_qt_cps = univ.ObjectIdentifier('1.3.6.1.5.5.7.2.1')
|
| 91 |
+
id_qt_unotice = univ.ObjectIdentifier('1.3.6.1.5.5.7.2.2')
|
| 92 |
+
|
| 93 |
+
id_ad_ocsp = univ.ObjectIdentifier('1.3.6.1.5.5.7.48.1')
|
| 94 |
+
id_ad_caIssuers = univ.ObjectIdentifier('1.3.6.1.5.5.7.48.2')
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
id_at = univ.ObjectIdentifier('2.5.4')
|
| 100 |
+
id_at_name = univ.ObjectIdentifier('2.5.4.41')
|
| 101 |
+
# preserve misspelled variable for compatibility
|
| 102 |
+
id_at_sutname = id_at_surname = univ.ObjectIdentifier('2.5.4.4')
|
| 103 |
+
id_at_givenName = univ.ObjectIdentifier('2.5.4.42')
|
| 104 |
+
id_at_initials = univ.ObjectIdentifier('2.5.4.43')
|
| 105 |
+
id_at_generationQualifier = univ.ObjectIdentifier('2.5.4.44')
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
class X520name(univ.Choice):
|
| 109 |
+
componentType = namedtype.NamedTypes(
|
| 110 |
+
namedtype.NamedType('teletexString',
|
| 111 |
+
char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
|
| 112 |
+
namedtype.NamedType('printableString',
|
| 113 |
+
char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
|
| 114 |
+
namedtype.NamedType('universalString',
|
| 115 |
+
char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
|
| 116 |
+
namedtype.NamedType('utf8String',
|
| 117 |
+
char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
|
| 118 |
+
namedtype.NamedType('bmpString',
|
| 119 |
+
char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name)))
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
id_at_commonName = univ.ObjectIdentifier('2.5.4.3')
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
class X520CommonName(univ.Choice):
|
| 127 |
+
componentType = namedtype.NamedTypes(
|
| 128 |
+
namedtype.NamedType('teletexString', char.TeletexString().subtype(
|
| 129 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),
|
| 130 |
+
namedtype.NamedType('printableString', char.PrintableString().subtype(
|
| 131 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),
|
| 132 |
+
namedtype.NamedType('universalString', char.UniversalString().subtype(
|
| 133 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),
|
| 134 |
+
namedtype.NamedType('utf8String',
|
| 135 |
+
char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),
|
| 136 |
+
namedtype.NamedType('bmpString',
|
| 137 |
+
char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name)))
|
| 138 |
+
)
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
id_at_localityName = univ.ObjectIdentifier('2.5.4.7')
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
class X520LocalityName(univ.Choice):
|
| 145 |
+
componentType = namedtype.NamedTypes(
|
| 146 |
+
namedtype.NamedType('teletexString', char.TeletexString().subtype(
|
| 147 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),
|
| 148 |
+
namedtype.NamedType('printableString', char.PrintableString().subtype(
|
| 149 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),
|
| 150 |
+
namedtype.NamedType('universalString', char.UniversalString().subtype(
|
| 151 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),
|
| 152 |
+
namedtype.NamedType('utf8String',
|
| 153 |
+
char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),
|
| 154 |
+
namedtype.NamedType('bmpString',
|
| 155 |
+
char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name)))
|
| 156 |
+
)
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
id_at_stateOrProvinceName = univ.ObjectIdentifier('2.5.4.8')
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
class X520StateOrProvinceName(univ.Choice):
|
| 163 |
+
componentType = namedtype.NamedTypes(
|
| 164 |
+
namedtype.NamedType('teletexString',
|
| 165 |
+
char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),
|
| 166 |
+
namedtype.NamedType('printableString', char.PrintableString().subtype(
|
| 167 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),
|
| 168 |
+
namedtype.NamedType('universalString', char.UniversalString().subtype(
|
| 169 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),
|
| 170 |
+
namedtype.NamedType('utf8String',
|
| 171 |
+
char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),
|
| 172 |
+
namedtype.NamedType('bmpString',
|
| 173 |
+
char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name)))
|
| 174 |
+
)
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
id_at_organizationName = univ.ObjectIdentifier('2.5.4.10')
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
class X520OrganizationName(univ.Choice):
|
| 181 |
+
componentType = namedtype.NamedTypes(
|
| 182 |
+
namedtype.NamedType('teletexString', char.TeletexString().subtype(
|
| 183 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
|
| 184 |
+
namedtype.NamedType('printableString', char.PrintableString().subtype(
|
| 185 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
|
| 186 |
+
namedtype.NamedType('universalString', char.UniversalString().subtype(
|
| 187 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
|
| 188 |
+
namedtype.NamedType('utf8String', char.UTF8String().subtype(
|
| 189 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
|
| 190 |
+
namedtype.NamedType('bmpString', char.BMPString().subtype(
|
| 191 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name)))
|
| 192 |
+
)
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
id_at_organizationalUnitName = univ.ObjectIdentifier('2.5.4.11')
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
class X520OrganizationalUnitName(univ.Choice):
|
| 199 |
+
componentType = namedtype.NamedTypes(
|
| 200 |
+
namedtype.NamedType('teletexString', char.TeletexString().subtype(
|
| 201 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),
|
| 202 |
+
namedtype.NamedType('printableString', char.PrintableString().subtype(
|
| 203 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),
|
| 204 |
+
namedtype.NamedType('universalString', char.UniversalString().subtype(
|
| 205 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),
|
| 206 |
+
namedtype.NamedType('utf8String', char.UTF8String().subtype(
|
| 207 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),
|
| 208 |
+
namedtype.NamedType('bmpString', char.BMPString().subtype(
|
| 209 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name)))
|
| 210 |
+
)
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
id_at_title = univ.ObjectIdentifier('2.5.4.12')
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
class X520Title(univ.Choice):
|
| 217 |
+
componentType = namedtype.NamedTypes(
|
| 218 |
+
namedtype.NamedType('teletexString',
|
| 219 |
+
char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),
|
| 220 |
+
namedtype.NamedType('printableString',
|
| 221 |
+
char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),
|
| 222 |
+
namedtype.NamedType('universalString',
|
| 223 |
+
char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),
|
| 224 |
+
namedtype.NamedType('utf8String',
|
| 225 |
+
char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),
|
| 226 |
+
namedtype.NamedType('bmpString',
|
| 227 |
+
char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title)))
|
| 228 |
+
)
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
id_at_dnQualifier = univ.ObjectIdentifier('2.5.4.46')
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
class X520dnQualifier(char.PrintableString):
|
| 235 |
+
pass
|
| 236 |
+
|
| 237 |
+
|
| 238 |
+
id_at_countryName = univ.ObjectIdentifier('2.5.4.6')
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
class X520countryName(char.PrintableString):
|
| 242 |
+
subtypeSpec = char.PrintableString.subtypeSpec + constraint.ValueSizeConstraint(2, 2)
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
pkcs_9 = univ.ObjectIdentifier('1.2.840.113549.1.9')
|
| 246 |
+
|
| 247 |
+
emailAddress = univ.ObjectIdentifier('1.2.840.113549.1.9.1')
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
class Pkcs9email(char.IA5String):
|
| 251 |
+
subtypeSpec = char.IA5String.subtypeSpec + constraint.ValueSizeConstraint(1, ub_emailaddress_length)
|
| 252 |
+
|
| 253 |
+
|
| 254 |
+
# ----
|
| 255 |
+
|
| 256 |
+
class DSAPrivateKey(univ.Sequence):
|
| 257 |
+
"""PKIX compliant DSA private key structure"""
|
| 258 |
+
componentType = namedtype.NamedTypes(
|
| 259 |
+
namedtype.NamedType('version', univ.Integer(namedValues=namedval.NamedValues(('v1', 0)))),
|
| 260 |
+
namedtype.NamedType('p', univ.Integer()),
|
| 261 |
+
namedtype.NamedType('q', univ.Integer()),
|
| 262 |
+
namedtype.NamedType('g', univ.Integer()),
|
| 263 |
+
namedtype.NamedType('public', univ.Integer()),
|
| 264 |
+
namedtype.NamedType('private', univ.Integer())
|
| 265 |
+
)
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
# ----
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
class DirectoryString(univ.Choice):
|
| 272 |
+
componentType = namedtype.NamedTypes(
|
| 273 |
+
namedtype.NamedType('teletexString',
|
| 274 |
+
char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
|
| 275 |
+
namedtype.NamedType('printableString',
|
| 276 |
+
char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
|
| 277 |
+
namedtype.NamedType('universalString',
|
| 278 |
+
char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
|
| 279 |
+
namedtype.NamedType('utf8String',
|
| 280 |
+
char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
|
| 281 |
+
namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
|
| 282 |
+
namedtype.NamedType('ia5String', char.IA5String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX)))
|
| 283 |
+
# hm, this should not be here!? XXX
|
| 284 |
+
)
|
| 285 |
+
|
| 286 |
+
|
| 287 |
+
# certificate and CRL specific structures begin here
|
| 288 |
+
|
| 289 |
+
class AlgorithmIdentifier(univ.Sequence):
|
| 290 |
+
componentType = namedtype.NamedTypes(
|
| 291 |
+
namedtype.NamedType('algorithm', univ.ObjectIdentifier()),
|
| 292 |
+
namedtype.OptionalNamedType('parameters', univ.Any())
|
| 293 |
+
)
|
| 294 |
+
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
# Algorithm OIDs and parameter structures
|
| 298 |
+
|
| 299 |
+
pkcs_1 = univ.ObjectIdentifier('1.2.840.113549.1.1')
|
| 300 |
+
rsaEncryption = univ.ObjectIdentifier('1.2.840.113549.1.1.1')
|
| 301 |
+
md2WithRSAEncryption = univ.ObjectIdentifier('1.2.840.113549.1.1.2')
|
| 302 |
+
md5WithRSAEncryption = univ.ObjectIdentifier('1.2.840.113549.1.1.4')
|
| 303 |
+
sha1WithRSAEncryption = univ.ObjectIdentifier('1.2.840.113549.1.1.5')
|
| 304 |
+
id_dsa_with_sha1 = univ.ObjectIdentifier('1.2.840.10040.4.3')
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
class Dss_Sig_Value(univ.Sequence):
|
| 308 |
+
componentType = namedtype.NamedTypes(
|
| 309 |
+
namedtype.NamedType('r', univ.Integer()),
|
| 310 |
+
namedtype.NamedType('s', univ.Integer())
|
| 311 |
+
)
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
dhpublicnumber = univ.ObjectIdentifier('1.2.840.10046.2.1')
|
| 315 |
+
|
| 316 |
+
|
| 317 |
+
class ValidationParms(univ.Sequence):
|
| 318 |
+
componentType = namedtype.NamedTypes(
|
| 319 |
+
namedtype.NamedType('seed', univ.BitString()),
|
| 320 |
+
namedtype.NamedType('pgenCounter', univ.Integer())
|
| 321 |
+
)
|
| 322 |
+
|
| 323 |
+
|
| 324 |
+
class DomainParameters(univ.Sequence):
|
| 325 |
+
componentType = namedtype.NamedTypes(
|
| 326 |
+
namedtype.NamedType('p', univ.Integer()),
|
| 327 |
+
namedtype.NamedType('g', univ.Integer()),
|
| 328 |
+
namedtype.NamedType('q', univ.Integer()),
|
| 329 |
+
namedtype.NamedType('j', univ.Integer()),
|
| 330 |
+
namedtype.OptionalNamedType('validationParms', ValidationParms())
|
| 331 |
+
)
|
| 332 |
+
|
| 333 |
+
|
| 334 |
+
id_dsa = univ.ObjectIdentifier('1.2.840.10040.4.1')
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
class Dss_Parms(univ.Sequence):
|
| 338 |
+
componentType = namedtype.NamedTypes(
|
| 339 |
+
namedtype.NamedType('p', univ.Integer()),
|
| 340 |
+
namedtype.NamedType('q', univ.Integer()),
|
| 341 |
+
namedtype.NamedType('g', univ.Integer())
|
| 342 |
+
)
|
| 343 |
+
|
| 344 |
+
|
| 345 |
+
# x400 address syntax starts here
|
| 346 |
+
|
| 347 |
+
teletex_domain_defined_attributes = univ.Integer(6)
|
| 348 |
+
|
| 349 |
+
|
| 350 |
+
class TeletexDomainDefinedAttribute(univ.Sequence):
|
| 351 |
+
componentType = namedtype.NamedTypes(
|
| 352 |
+
namedtype.NamedType('type', char.TeletexString().subtype(
|
| 353 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_type_length))),
|
| 354 |
+
namedtype.NamedType('value', char.TeletexString())
|
| 355 |
+
)
|
| 356 |
+
|
| 357 |
+
|
| 358 |
+
class TeletexDomainDefinedAttributes(univ.SequenceOf):
|
| 359 |
+
componentType = TeletexDomainDefinedAttribute()
|
| 360 |
+
sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, ub_domain_defined_attributes)
|
| 361 |
+
|
| 362 |
+
|
| 363 |
+
terminal_type = univ.Integer(23)
|
| 364 |
+
|
| 365 |
+
|
| 366 |
+
class TerminalType(univ.Integer):
|
| 367 |
+
subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueSizeConstraint(0, ub_integer_options)
|
| 368 |
+
namedValues = namedval.NamedValues(
|
| 369 |
+
('telex', 3),
|
| 370 |
+
('teletelex', 4),
|
| 371 |
+
('g3-facsimile', 5),
|
| 372 |
+
('g4-facsimile', 6),
|
| 373 |
+
('ia5-terminal', 7),
|
| 374 |
+
('videotex', 8)
|
| 375 |
+
)
|
| 376 |
+
|
| 377 |
+
|
| 378 |
+
class PresentationAddress(univ.Sequence):
|
| 379 |
+
componentType = namedtype.NamedTypes(
|
| 380 |
+
namedtype.OptionalNamedType('pSelector', univ.OctetString().subtype(
|
| 381 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 382 |
+
namedtype.OptionalNamedType('sSelector', univ.OctetString().subtype(
|
| 383 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 384 |
+
namedtype.OptionalNamedType('tSelector', univ.OctetString().subtype(
|
| 385 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
|
| 386 |
+
namedtype.OptionalNamedType('nAddresses', univ.SetOf(componentType=univ.OctetString()).subtype(
|
| 387 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3),
|
| 388 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
|
| 389 |
+
)
|
| 390 |
+
|
| 391 |
+
|
| 392 |
+
extended_network_address = univ.Integer(22)
|
| 393 |
+
|
| 394 |
+
|
| 395 |
+
class E163_4_address(univ.Sequence):
|
| 396 |
+
componentType = namedtype.NamedTypes(
|
| 397 |
+
namedtype.NamedType('number', char.NumericString().subtype(
|
| 398 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_e163_4_number_length),
|
| 399 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 400 |
+
namedtype.OptionalNamedType('sub-address', char.NumericString().subtype(
|
| 401 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_e163_4_sub_address_length),
|
| 402 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 403 |
+
)
|
| 404 |
+
|
| 405 |
+
|
| 406 |
+
class ExtendedNetworkAddress(univ.Choice):
|
| 407 |
+
componentType = namedtype.NamedTypes(
|
| 408 |
+
namedtype.NamedType('e163-4-address', E163_4_address()),
|
| 409 |
+
namedtype.NamedType('psap-address', PresentationAddress().subtype(
|
| 410 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
|
| 411 |
+
)
|
| 412 |
+
|
| 413 |
+
|
| 414 |
+
class PDSParameter(univ.Set):
|
| 415 |
+
componentType = namedtype.NamedTypes(
|
| 416 |
+
namedtype.OptionalNamedType('printable-string', char.PrintableString().subtype(
|
| 417 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length))),
|
| 418 |
+
namedtype.OptionalNamedType('teletex-string', char.TeletexString().subtype(
|
| 419 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length)))
|
| 420 |
+
)
|
| 421 |
+
|
| 422 |
+
|
| 423 |
+
local_postal_attributes = univ.Integer(21)
|
| 424 |
+
|
| 425 |
+
|
| 426 |
+
class LocalPostalAttributes(PDSParameter):
|
| 427 |
+
pass
|
| 428 |
+
|
| 429 |
+
|
| 430 |
+
class UniquePostalName(PDSParameter):
|
| 431 |
+
pass
|
| 432 |
+
|
| 433 |
+
|
| 434 |
+
unique_postal_name = univ.Integer(20)
|
| 435 |
+
|
| 436 |
+
poste_restante_address = univ.Integer(19)
|
| 437 |
+
|
| 438 |
+
|
| 439 |
+
class PosteRestanteAddress(PDSParameter):
|
| 440 |
+
pass
|
| 441 |
+
|
| 442 |
+
|
| 443 |
+
post_office_box_address = univ.Integer(18)
|
| 444 |
+
|
| 445 |
+
|
| 446 |
+
class PostOfficeBoxAddress(PDSParameter):
|
| 447 |
+
pass
|
| 448 |
+
|
| 449 |
+
|
| 450 |
+
street_address = univ.Integer(17)
|
| 451 |
+
|
| 452 |
+
|
| 453 |
+
class StreetAddress(PDSParameter):
|
| 454 |
+
pass
|
| 455 |
+
|
| 456 |
+
|
| 457 |
+
class UnformattedPostalAddress(univ.Set):
|
| 458 |
+
componentType = namedtype.NamedTypes(
|
| 459 |
+
namedtype.OptionalNamedType('printable-address', univ.SequenceOf(componentType=char.PrintableString().subtype(
|
| 460 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length)).subtype(
|
| 461 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_physical_address_lines)))),
|
| 462 |
+
namedtype.OptionalNamedType('teletex-string', char.TeletexString().subtype(
|
| 463 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_unformatted_address_length)))
|
| 464 |
+
)
|
| 465 |
+
|
| 466 |
+
|
| 467 |
+
physical_delivery_office_name = univ.Integer(10)
|
| 468 |
+
|
| 469 |
+
|
| 470 |
+
class PhysicalDeliveryOfficeName(PDSParameter):
|
| 471 |
+
pass
|
| 472 |
+
|
| 473 |
+
|
| 474 |
+
physical_delivery_office_number = univ.Integer(11)
|
| 475 |
+
|
| 476 |
+
|
| 477 |
+
class PhysicalDeliveryOfficeNumber(PDSParameter):
|
| 478 |
+
pass
|
| 479 |
+
|
| 480 |
+
|
| 481 |
+
extension_OR_address_components = univ.Integer(12)
|
| 482 |
+
|
| 483 |
+
|
| 484 |
+
class ExtensionORAddressComponents(PDSParameter):
|
| 485 |
+
pass
|
| 486 |
+
|
| 487 |
+
|
| 488 |
+
physical_delivery_personal_name = univ.Integer(13)
|
| 489 |
+
|
| 490 |
+
|
| 491 |
+
class PhysicalDeliveryPersonalName(PDSParameter):
|
| 492 |
+
pass
|
| 493 |
+
|
| 494 |
+
|
| 495 |
+
physical_delivery_organization_name = univ.Integer(14)
|
| 496 |
+
|
| 497 |
+
|
| 498 |
+
class PhysicalDeliveryOrganizationName(PDSParameter):
|
| 499 |
+
pass
|
| 500 |
+
|
| 501 |
+
|
| 502 |
+
extension_physical_delivery_address_components = univ.Integer(15)
|
| 503 |
+
|
| 504 |
+
|
| 505 |
+
class ExtensionPhysicalDeliveryAddressComponents(PDSParameter):
|
| 506 |
+
pass
|
| 507 |
+
|
| 508 |
+
|
| 509 |
+
unformatted_postal_address = univ.Integer(16)
|
| 510 |
+
|
| 511 |
+
postal_code = univ.Integer(9)
|
| 512 |
+
|
| 513 |
+
|
| 514 |
+
class PostalCode(univ.Choice):
|
| 515 |
+
componentType = namedtype.NamedTypes(
|
| 516 |
+
namedtype.NamedType('numeric-code', char.NumericString().subtype(
|
| 517 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_postal_code_length))),
|
| 518 |
+
namedtype.NamedType('printable-code', char.PrintableString().subtype(
|
| 519 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_postal_code_length)))
|
| 520 |
+
)
|
| 521 |
+
|
| 522 |
+
|
| 523 |
+
class PhysicalDeliveryCountryName(univ.Choice):
|
| 524 |
+
componentType = namedtype.NamedTypes(
|
| 525 |
+
namedtype.NamedType('x121-dcc-code', char.NumericString().subtype(
|
| 526 |
+
subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_numeric_length,
|
| 527 |
+
ub_country_name_numeric_length))),
|
| 528 |
+
namedtype.NamedType('iso-3166-alpha2-code', char.PrintableString().subtype(
|
| 529 |
+
subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_alpha_length, ub_country_name_alpha_length)))
|
| 530 |
+
)
|
| 531 |
+
|
| 532 |
+
|
| 533 |
+
class PDSName(char.PrintableString):
|
| 534 |
+
subtypeSpec = char.PrintableString.subtypeSpec + constraint.ValueSizeConstraint(1, ub_pds_name_length)
|
| 535 |
+
|
| 536 |
+
|
| 537 |
+
physical_delivery_country_name = univ.Integer(8)
|
| 538 |
+
|
| 539 |
+
|
| 540 |
+
class TeletexOrganizationalUnitName(char.TeletexString):
|
| 541 |
+
subtypeSpec = char.TeletexString.subtypeSpec + constraint.ValueSizeConstraint(1, ub_organizational_unit_name_length)
|
| 542 |
+
|
| 543 |
+
|
| 544 |
+
pds_name = univ.Integer(7)
|
| 545 |
+
|
| 546 |
+
teletex_organizational_unit_names = univ.Integer(5)
|
| 547 |
+
|
| 548 |
+
|
| 549 |
+
class TeletexOrganizationalUnitNames(univ.SequenceOf):
|
| 550 |
+
componentType = TeletexOrganizationalUnitName()
|
| 551 |
+
sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, ub_organizational_units)
|
| 552 |
+
|
| 553 |
+
|
| 554 |
+
teletex_personal_name = univ.Integer(4)
|
| 555 |
+
|
| 556 |
+
|
| 557 |
+
class TeletexPersonalName(univ.Set):
|
| 558 |
+
componentType = namedtype.NamedTypes(
|
| 559 |
+
namedtype.NamedType('surname', char.TeletexString().subtype(
|
| 560 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_surname_length),
|
| 561 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 562 |
+
namedtype.OptionalNamedType('given-name', char.TeletexString().subtype(
|
| 563 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_given_name_length),
|
| 564 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 565 |
+
namedtype.OptionalNamedType('initials', char.TeletexString().subtype(
|
| 566 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_initials_length),
|
| 567 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
|
| 568 |
+
namedtype.OptionalNamedType('generation-qualifier', char.TeletexString().subtype(
|
| 569 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_generation_qualifier_length),
|
| 570 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
|
| 571 |
+
)
|
| 572 |
+
|
| 573 |
+
|
| 574 |
+
teletex_organization_name = univ.Integer(3)
|
| 575 |
+
|
| 576 |
+
|
| 577 |
+
class TeletexOrganizationName(char.TeletexString):
|
| 578 |
+
subtypeSpec = char.TeletexString.subtypeSpec + constraint.ValueSizeConstraint(1, ub_organization_name_length)
|
| 579 |
+
|
| 580 |
+
|
| 581 |
+
teletex_common_name = univ.Integer(2)
|
| 582 |
+
|
| 583 |
+
|
| 584 |
+
class TeletexCommonName(char.TeletexString):
|
| 585 |
+
subtypeSpec = char.TeletexString.subtypeSpec + constraint.ValueSizeConstraint(1, ub_common_name_length)
|
| 586 |
+
|
| 587 |
+
|
| 588 |
+
class CommonName(char.PrintableString):
|
| 589 |
+
subtypeSpec = char.PrintableString.subtypeSpec + constraint.ValueSizeConstraint(1, ub_common_name_length)
|
| 590 |
+
|
| 591 |
+
|
| 592 |
+
common_name = univ.Integer(1)
|
| 593 |
+
|
| 594 |
+
|
| 595 |
+
class ExtensionAttribute(univ.Sequence):
|
| 596 |
+
componentType = namedtype.NamedTypes(
|
| 597 |
+
namedtype.NamedType('extension-attribute-type', univ.Integer().subtype(
|
| 598 |
+
subtypeSpec=constraint.ValueSizeConstraint(0, ub_extension_attributes),
|
| 599 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 600 |
+
namedtype.NamedType('extension-attribute-value',
|
| 601 |
+
univ.Any().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 602 |
+
)
|
| 603 |
+
|
| 604 |
+
|
| 605 |
+
class ExtensionAttributes(univ.SetOf):
|
| 606 |
+
componentType = ExtensionAttribute()
|
| 607 |
+
sizeSpec = univ.SetOf.sizeSpec + constraint.ValueSizeConstraint(1, ub_extension_attributes)
|
| 608 |
+
|
| 609 |
+
|
| 610 |
+
class BuiltInDomainDefinedAttribute(univ.Sequence):
|
| 611 |
+
componentType = namedtype.NamedTypes(
|
| 612 |
+
namedtype.NamedType('type', char.PrintableString().subtype(
|
| 613 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_type_length))),
|
| 614 |
+
namedtype.NamedType('value', char.PrintableString().subtype(
|
| 615 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_value_length)))
|
| 616 |
+
)
|
| 617 |
+
|
| 618 |
+
|
| 619 |
+
class BuiltInDomainDefinedAttributes(univ.SequenceOf):
|
| 620 |
+
componentType = BuiltInDomainDefinedAttribute()
|
| 621 |
+
sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, ub_domain_defined_attributes)
|
| 622 |
+
|
| 623 |
+
|
| 624 |
+
class OrganizationalUnitName(char.PrintableString):
|
| 625 |
+
subtypeSpec = char.PrintableString.subtypeSpec + constraint.ValueSizeConstraint(1, ub_organizational_unit_name_length)
|
| 626 |
+
|
| 627 |
+
|
| 628 |
+
class OrganizationalUnitNames(univ.SequenceOf):
|
| 629 |
+
componentType = OrganizationalUnitName()
|
| 630 |
+
sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, ub_organizational_units)
|
| 631 |
+
|
| 632 |
+
|
| 633 |
+
class PersonalName(univ.Set):
|
| 634 |
+
componentType = namedtype.NamedTypes(
|
| 635 |
+
namedtype.NamedType('surname', char.PrintableString().subtype(
|
| 636 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_surname_length),
|
| 637 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 638 |
+
namedtype.OptionalNamedType('given-name', char.PrintableString().subtype(
|
| 639 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_given_name_length),
|
| 640 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 641 |
+
namedtype.OptionalNamedType('initials', char.PrintableString().subtype(
|
| 642 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_initials_length),
|
| 643 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
|
| 644 |
+
namedtype.OptionalNamedType('generation-qualifier', char.PrintableString().subtype(
|
| 645 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_generation_qualifier_length),
|
| 646 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
|
| 647 |
+
)
|
| 648 |
+
|
| 649 |
+
|
| 650 |
+
class NumericUserIdentifier(char.NumericString):
|
| 651 |
+
subtypeSpec = char.NumericString.subtypeSpec + constraint.ValueSizeConstraint(1, ub_numeric_user_id_length)
|
| 652 |
+
|
| 653 |
+
|
| 654 |
+
class OrganizationName(char.PrintableString):
|
| 655 |
+
subtypeSpec = char.PrintableString.subtypeSpec + constraint.ValueSizeConstraint(1, ub_organization_name_length)
|
| 656 |
+
|
| 657 |
+
|
| 658 |
+
class PrivateDomainName(univ.Choice):
|
| 659 |
+
componentType = namedtype.NamedTypes(
|
| 660 |
+
namedtype.NamedType('numeric', char.NumericString().subtype(
|
| 661 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_name_length))),
|
| 662 |
+
namedtype.NamedType('printable', char.PrintableString().subtype(
|
| 663 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_name_length)))
|
| 664 |
+
)
|
| 665 |
+
|
| 666 |
+
|
| 667 |
+
class TerminalIdentifier(char.PrintableString):
|
| 668 |
+
subtypeSpec = char.PrintableString.subtypeSpec + constraint.ValueSizeConstraint(1, ub_terminal_id_length)
|
| 669 |
+
|
| 670 |
+
|
| 671 |
+
class X121Address(char.NumericString):
|
| 672 |
+
subtypeSpec = char.NumericString.subtypeSpec + constraint.ValueSizeConstraint(1, ub_x121_address_length)
|
| 673 |
+
|
| 674 |
+
|
| 675 |
+
class NetworkAddress(X121Address):
|
| 676 |
+
pass
|
| 677 |
+
|
| 678 |
+
|
| 679 |
+
class AdministrationDomainName(univ.Choice):
|
| 680 |
+
tagSet = univ.Choice.tagSet.tagExplicitly(
|
| 681 |
+
tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 2)
|
| 682 |
+
)
|
| 683 |
+
componentType = namedtype.NamedTypes(
|
| 684 |
+
namedtype.NamedType('numeric', char.NumericString().subtype(
|
| 685 |
+
subtypeSpec=constraint.ValueSizeConstraint(0, ub_domain_name_length))),
|
| 686 |
+
namedtype.NamedType('printable', char.PrintableString().subtype(
|
| 687 |
+
subtypeSpec=constraint.ValueSizeConstraint(0, ub_domain_name_length)))
|
| 688 |
+
)
|
| 689 |
+
|
| 690 |
+
|
| 691 |
+
class CountryName(univ.Choice):
|
| 692 |
+
tagSet = univ.Choice.tagSet.tagExplicitly(
|
| 693 |
+
tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 1)
|
| 694 |
+
)
|
| 695 |
+
componentType = namedtype.NamedTypes(
|
| 696 |
+
namedtype.NamedType('x121-dcc-code', char.NumericString().subtype(
|
| 697 |
+
subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_numeric_length,
|
| 698 |
+
ub_country_name_numeric_length))),
|
| 699 |
+
namedtype.NamedType('iso-3166-alpha2-code', char.PrintableString().subtype(
|
| 700 |
+
subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_alpha_length, ub_country_name_alpha_length)))
|
| 701 |
+
)
|
| 702 |
+
|
| 703 |
+
|
| 704 |
+
class BuiltInStandardAttributes(univ.Sequence):
|
| 705 |
+
componentType = namedtype.NamedTypes(
|
| 706 |
+
namedtype.OptionalNamedType('country-name', CountryName()),
|
| 707 |
+
namedtype.OptionalNamedType('administration-domain-name', AdministrationDomainName()),
|
| 708 |
+
namedtype.OptionalNamedType('network-address', NetworkAddress().subtype(
|
| 709 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 710 |
+
namedtype.OptionalNamedType('terminal-identifier', TerminalIdentifier().subtype(
|
| 711 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 712 |
+
namedtype.OptionalNamedType('private-domain-name', PrivateDomainName().subtype(
|
| 713 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
|
| 714 |
+
namedtype.OptionalNamedType('organization-name', OrganizationName().subtype(
|
| 715 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
|
| 716 |
+
namedtype.OptionalNamedType('numeric-user-identifier', NumericUserIdentifier().subtype(
|
| 717 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))),
|
| 718 |
+
namedtype.OptionalNamedType('personal-name', PersonalName().subtype(
|
| 719 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 5))),
|
| 720 |
+
namedtype.OptionalNamedType('organizational-unit-names', OrganizationalUnitNames().subtype(
|
| 721 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6)))
|
| 722 |
+
)
|
| 723 |
+
|
| 724 |
+
|
| 725 |
+
class ORAddress(univ.Sequence):
|
| 726 |
+
componentType = namedtype.NamedTypes(
|
| 727 |
+
namedtype.NamedType('built-in-standard-attributes', BuiltInStandardAttributes()),
|
| 728 |
+
namedtype.OptionalNamedType('built-in-domain-defined-attributes', BuiltInDomainDefinedAttributes()),
|
| 729 |
+
namedtype.OptionalNamedType('extension-attributes', ExtensionAttributes())
|
| 730 |
+
)
|
| 731 |
+
|
| 732 |
+
|
| 733 |
+
#
|
| 734 |
+
# PKIX1Implicit88
|
| 735 |
+
#
|
| 736 |
+
|
| 737 |
+
id_ce_invalidityDate = univ.ObjectIdentifier('2.5.29.24')
|
| 738 |
+
|
| 739 |
+
|
| 740 |
+
class InvalidityDate(useful.GeneralizedTime):
|
| 741 |
+
pass
|
| 742 |
+
|
| 743 |
+
|
| 744 |
+
id_holdinstruction_none = univ.ObjectIdentifier('2.2.840.10040.2.1')
|
| 745 |
+
id_holdinstruction_callissuer = univ.ObjectIdentifier('2.2.840.10040.2.2')
|
| 746 |
+
id_holdinstruction_reject = univ.ObjectIdentifier('2.2.840.10040.2.3')
|
| 747 |
+
|
| 748 |
+
holdInstruction = univ.ObjectIdentifier('2.2.840.10040.2')
|
| 749 |
+
|
| 750 |
+
id_ce_holdInstructionCode = univ.ObjectIdentifier('2.5.29.23')
|
| 751 |
+
|
| 752 |
+
|
| 753 |
+
class HoldInstructionCode(univ.ObjectIdentifier):
|
| 754 |
+
pass
|
| 755 |
+
|
| 756 |
+
|
| 757 |
+
id_ce_cRLReasons = univ.ObjectIdentifier('2.5.29.21')
|
| 758 |
+
|
| 759 |
+
|
| 760 |
+
class CRLReason(univ.Enumerated):
|
| 761 |
+
namedValues = namedval.NamedValues(
|
| 762 |
+
('unspecified', 0),
|
| 763 |
+
('keyCompromise', 1),
|
| 764 |
+
('cACompromise', 2),
|
| 765 |
+
('affiliationChanged', 3),
|
| 766 |
+
('superseded', 4),
|
| 767 |
+
('cessationOfOperation', 5),
|
| 768 |
+
('certificateHold', 6),
|
| 769 |
+
('removeFromCRL', 8)
|
| 770 |
+
)
|
| 771 |
+
|
| 772 |
+
|
| 773 |
+
id_ce_cRLNumber = univ.ObjectIdentifier('2.5.29.20')
|
| 774 |
+
|
| 775 |
+
|
| 776 |
+
class CRLNumber(univ.Integer):
|
| 777 |
+
subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueSizeConstraint(0, MAX)
|
| 778 |
+
|
| 779 |
+
|
| 780 |
+
class BaseCRLNumber(CRLNumber):
|
| 781 |
+
pass
|
| 782 |
+
|
| 783 |
+
|
| 784 |
+
id_kp_serverAuth = univ.ObjectIdentifier('1.3.6.1.5.5.7.3.1')
|
| 785 |
+
id_kp_clientAuth = univ.ObjectIdentifier('1.3.6.1.5.5.7.3.2')
|
| 786 |
+
id_kp_codeSigning = univ.ObjectIdentifier('1.3.6.1.5.5.7.3.3')
|
| 787 |
+
id_kp_emailProtection = univ.ObjectIdentifier('1.3.6.1.5.5.7.3.4')
|
| 788 |
+
id_kp_ipsecEndSystem = univ.ObjectIdentifier('1.3.6.1.5.5.7.3.5')
|
| 789 |
+
id_kp_ipsecTunnel = univ.ObjectIdentifier('1.3.6.1.5.5.7.3.6')
|
| 790 |
+
id_kp_ipsecUser = univ.ObjectIdentifier('1.3.6.1.5.5.7.3.7')
|
| 791 |
+
id_kp_timeStamping = univ.ObjectIdentifier('1.3.6.1.5.5.7.3.8')
|
| 792 |
+
id_pe_authorityInfoAccess = univ.ObjectIdentifier('1.3.6.1.5.5.7.1.1')
|
| 793 |
+
id_ce_extKeyUsage = univ.ObjectIdentifier('2.5.29.37')
|
| 794 |
+
|
| 795 |
+
|
| 796 |
+
class KeyPurposeId(univ.ObjectIdentifier):
|
| 797 |
+
pass
|
| 798 |
+
|
| 799 |
+
|
| 800 |
+
class ExtKeyUsageSyntax(univ.SequenceOf):
|
| 801 |
+
componentType = KeyPurposeId()
|
| 802 |
+
sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, MAX)
|
| 803 |
+
|
| 804 |
+
|
| 805 |
+
class ReasonFlags(univ.BitString):
|
| 806 |
+
namedValues = namedval.NamedValues(
|
| 807 |
+
('unused', 0),
|
| 808 |
+
('keyCompromise', 1),
|
| 809 |
+
('cACompromise', 2),
|
| 810 |
+
('affiliationChanged', 3),
|
| 811 |
+
('superseded', 4),
|
| 812 |
+
('cessationOfOperation', 5),
|
| 813 |
+
('certificateHold', 6)
|
| 814 |
+
)
|
| 815 |
+
|
| 816 |
+
|
| 817 |
+
class SkipCerts(univ.Integer):
|
| 818 |
+
subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueSizeConstraint(0, MAX)
|
| 819 |
+
|
| 820 |
+
|
| 821 |
+
id_ce_policyConstraints = univ.ObjectIdentifier('2.5.29.36')
|
| 822 |
+
|
| 823 |
+
|
| 824 |
+
class PolicyConstraints(univ.Sequence):
|
| 825 |
+
componentType = namedtype.NamedTypes(
|
| 826 |
+
namedtype.OptionalNamedType('requireExplicitPolicy', SkipCerts().subtype(
|
| 827 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 828 |
+
namedtype.OptionalNamedType('inhibitPolicyMapping', SkipCerts().subtype(
|
| 829 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1)))
|
| 830 |
+
)
|
| 831 |
+
|
| 832 |
+
|
| 833 |
+
id_ce_basicConstraints = univ.ObjectIdentifier('2.5.29.19')
|
| 834 |
+
|
| 835 |
+
|
| 836 |
+
class BasicConstraints(univ.Sequence):
|
| 837 |
+
componentType = namedtype.NamedTypes(
|
| 838 |
+
namedtype.DefaultedNamedType('cA', univ.Boolean(False)),
|
| 839 |
+
namedtype.OptionalNamedType('pathLenConstraint',
|
| 840 |
+
univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, MAX)))
|
| 841 |
+
)
|
| 842 |
+
|
| 843 |
+
|
| 844 |
+
id_ce_subjectDirectoryAttributes = univ.ObjectIdentifier('2.5.29.9')
|
| 845 |
+
|
| 846 |
+
|
| 847 |
+
class EDIPartyName(univ.Sequence):
|
| 848 |
+
componentType = namedtype.NamedTypes(
|
| 849 |
+
namedtype.OptionalNamedType('nameAssigner', DirectoryString().subtype(
|
| 850 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 851 |
+
namedtype.NamedType('partyName',
|
| 852 |
+
DirectoryString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 853 |
+
)
|
| 854 |
+
|
| 855 |
+
|
| 856 |
+
|
| 857 |
+
id_ce_deltaCRLIndicator = univ.ObjectIdentifier('2.5.29.27')
|
| 858 |
+
|
| 859 |
+
|
| 860 |
+
|
| 861 |
+
class BaseDistance(univ.Integer):
|
| 862 |
+
subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint(0, MAX)
|
| 863 |
+
|
| 864 |
+
|
| 865 |
+
id_ce_cRLDistributionPoints = univ.ObjectIdentifier('2.5.29.31')
|
| 866 |
+
|
| 867 |
+
|
| 868 |
+
id_ce_issuingDistributionPoint = univ.ObjectIdentifier('2.5.29.28')
|
| 869 |
+
|
| 870 |
+
|
| 871 |
+
|
| 872 |
+
|
| 873 |
+
id_ce_nameConstraints = univ.ObjectIdentifier('2.5.29.30')
|
| 874 |
+
|
| 875 |
+
|
| 876 |
+
class DisplayText(univ.Choice):
|
| 877 |
+
componentType = namedtype.NamedTypes(
|
| 878 |
+
namedtype.NamedType('visibleString',
|
| 879 |
+
char.VisibleString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 200))),
|
| 880 |
+
namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 200))),
|
| 881 |
+
namedtype.NamedType('utf8String', char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 200)))
|
| 882 |
+
)
|
| 883 |
+
|
| 884 |
+
|
| 885 |
+
class NoticeReference(univ.Sequence):
|
| 886 |
+
componentType = namedtype.NamedTypes(
|
| 887 |
+
namedtype.NamedType('organization', DisplayText()),
|
| 888 |
+
namedtype.NamedType('noticeNumbers', univ.SequenceOf(componentType=univ.Integer()))
|
| 889 |
+
)
|
| 890 |
+
|
| 891 |
+
|
| 892 |
+
class UserNotice(univ.Sequence):
|
| 893 |
+
componentType = namedtype.NamedTypes(
|
| 894 |
+
namedtype.OptionalNamedType('noticeRef', NoticeReference()),
|
| 895 |
+
namedtype.OptionalNamedType('explicitText', DisplayText())
|
| 896 |
+
)
|
| 897 |
+
|
| 898 |
+
|
| 899 |
+
class CPSuri(char.IA5String):
|
| 900 |
+
pass
|
| 901 |
+
|
| 902 |
+
|
| 903 |
+
class PolicyQualifierId(univ.ObjectIdentifier):
|
| 904 |
+
subtypeSpec = univ.ObjectIdentifier.subtypeSpec + constraint.SingleValueConstraint(id_qt_cps, id_qt_unotice)
|
| 905 |
+
|
| 906 |
+
|
| 907 |
+
class CertPolicyId(univ.ObjectIdentifier):
|
| 908 |
+
pass
|
| 909 |
+
|
| 910 |
+
|
| 911 |
+
class PolicyQualifierInfo(univ.Sequence):
|
| 912 |
+
componentType = namedtype.NamedTypes(
|
| 913 |
+
namedtype.NamedType('policyQualifierId', PolicyQualifierId()),
|
| 914 |
+
namedtype.NamedType('qualifier', univ.Any())
|
| 915 |
+
)
|
| 916 |
+
|
| 917 |
+
|
| 918 |
+
id_ce_certificatePolicies = univ.ObjectIdentifier('2.5.29.32')
|
| 919 |
+
|
| 920 |
+
|
| 921 |
+
class PolicyInformation(univ.Sequence):
|
| 922 |
+
componentType = namedtype.NamedTypes(
|
| 923 |
+
namedtype.NamedType('policyIdentifier', CertPolicyId()),
|
| 924 |
+
namedtype.OptionalNamedType('policyQualifiers', univ.SequenceOf(componentType=PolicyQualifierInfo()).subtype(
|
| 925 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, MAX)))
|
| 926 |
+
)
|
| 927 |
+
|
| 928 |
+
|
| 929 |
+
class CertificatePolicies(univ.SequenceOf):
|
| 930 |
+
componentType = PolicyInformation()
|
| 931 |
+
sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, MAX)
|
| 932 |
+
|
| 933 |
+
|
| 934 |
+
id_ce_policyMappings = univ.ObjectIdentifier('2.5.29.33')
|
| 935 |
+
|
| 936 |
+
|
| 937 |
+
class PolicyMapping(univ.Sequence):
|
| 938 |
+
componentType = namedtype.NamedTypes(
|
| 939 |
+
namedtype.NamedType('issuerDomainPolicy', CertPolicyId()),
|
| 940 |
+
namedtype.NamedType('subjectDomainPolicy', CertPolicyId())
|
| 941 |
+
)
|
| 942 |
+
|
| 943 |
+
|
| 944 |
+
class PolicyMappings(univ.SequenceOf):
|
| 945 |
+
componentType = PolicyMapping()
|
| 946 |
+
sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, MAX)
|
| 947 |
+
|
| 948 |
+
|
| 949 |
+
id_ce_privateKeyUsagePeriod = univ.ObjectIdentifier('2.5.29.16')
|
| 950 |
+
|
| 951 |
+
|
| 952 |
+
class PrivateKeyUsagePeriod(univ.Sequence):
|
| 953 |
+
componentType = namedtype.NamedTypes(
|
| 954 |
+
namedtype.OptionalNamedType('notBefore', useful.GeneralizedTime().subtype(
|
| 955 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 956 |
+
namedtype.OptionalNamedType('notAfter', useful.GeneralizedTime().subtype(
|
| 957 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 958 |
+
)
|
| 959 |
+
|
| 960 |
+
|
| 961 |
+
id_ce_keyUsage = univ.ObjectIdentifier('2.5.29.15')
|
| 962 |
+
|
| 963 |
+
|
| 964 |
+
class KeyUsage(univ.BitString):
|
| 965 |
+
namedValues = namedval.NamedValues(
|
| 966 |
+
('digitalSignature', 0),
|
| 967 |
+
('nonRepudiation', 1),
|
| 968 |
+
('keyEncipherment', 2),
|
| 969 |
+
('dataEncipherment', 3),
|
| 970 |
+
('keyAgreement', 4),
|
| 971 |
+
('keyCertSign', 5),
|
| 972 |
+
('cRLSign', 6),
|
| 973 |
+
('encipherOnly', 7),
|
| 974 |
+
('decipherOnly', 8)
|
| 975 |
+
)
|
| 976 |
+
|
| 977 |
+
|
| 978 |
+
id_ce = univ.ObjectIdentifier('2.5.29')
|
| 979 |
+
|
| 980 |
+
id_ce_authorityKeyIdentifier = univ.ObjectIdentifier('2.5.29.35')
|
| 981 |
+
|
| 982 |
+
|
| 983 |
+
class KeyIdentifier(univ.OctetString):
|
| 984 |
+
pass
|
| 985 |
+
|
| 986 |
+
|
| 987 |
+
id_ce_subjectKeyIdentifier = univ.ObjectIdentifier('2.5.29.14')
|
| 988 |
+
|
| 989 |
+
|
| 990 |
+
class SubjectKeyIdentifier(KeyIdentifier):
|
| 991 |
+
pass
|
| 992 |
+
|
| 993 |
+
|
| 994 |
+
id_ce_certificateIssuer = univ.ObjectIdentifier('2.5.29.29')
|
| 995 |
+
|
| 996 |
+
|
| 997 |
+
id_ce_subjectAltName = univ.ObjectIdentifier('2.5.29.17')
|
| 998 |
+
|
| 999 |
+
|
| 1000 |
+
id_ce_issuerAltName = univ.ObjectIdentifier('2.5.29.18')
|
| 1001 |
+
|
| 1002 |
+
|
| 1003 |
+
class AttributeValue(univ.Any):
|
| 1004 |
+
pass
|
| 1005 |
+
|
| 1006 |
+
|
| 1007 |
+
class AttributeType(univ.ObjectIdentifier):
|
| 1008 |
+
pass
|
| 1009 |
+
|
| 1010 |
+
certificateAttributesMap = {}
|
| 1011 |
+
|
| 1012 |
+
|
| 1013 |
+
class AttributeTypeAndValue(univ.Sequence):
|
| 1014 |
+
componentType = namedtype.NamedTypes(
|
| 1015 |
+
namedtype.NamedType('type', AttributeType()),
|
| 1016 |
+
namedtype.NamedType('value', AttributeValue(),
|
| 1017 |
+
openType=opentype.OpenType('type', certificateAttributesMap))
|
| 1018 |
+
)
|
| 1019 |
+
|
| 1020 |
+
|
| 1021 |
+
class Attribute(univ.Sequence):
|
| 1022 |
+
componentType = namedtype.NamedTypes(
|
| 1023 |
+
namedtype.NamedType('type', AttributeType()),
|
| 1024 |
+
namedtype.NamedType('vals', univ.SetOf(componentType=AttributeValue()))
|
| 1025 |
+
)
|
| 1026 |
+
|
| 1027 |
+
|
| 1028 |
+
class SubjectDirectoryAttributes(univ.SequenceOf):
|
| 1029 |
+
componentType = Attribute()
|
| 1030 |
+
sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, MAX)
|
| 1031 |
+
|
| 1032 |
+
|
| 1033 |
+
class RelativeDistinguishedName(univ.SetOf):
|
| 1034 |
+
componentType = AttributeTypeAndValue()
|
| 1035 |
+
|
| 1036 |
+
|
| 1037 |
+
class RDNSequence(univ.SequenceOf):
|
| 1038 |
+
componentType = RelativeDistinguishedName()
|
| 1039 |
+
|
| 1040 |
+
|
| 1041 |
+
class Name(univ.Choice):
|
| 1042 |
+
componentType = namedtype.NamedTypes(
|
| 1043 |
+
namedtype.NamedType('', RDNSequence())
|
| 1044 |
+
)
|
| 1045 |
+
|
| 1046 |
+
class CertificateSerialNumber(univ.Integer):
|
| 1047 |
+
pass
|
| 1048 |
+
|
| 1049 |
+
|
| 1050 |
+
class AnotherName(univ.Sequence):
|
| 1051 |
+
componentType = namedtype.NamedTypes(
|
| 1052 |
+
namedtype.NamedType('type-id', univ.ObjectIdentifier()),
|
| 1053 |
+
namedtype.NamedType('value',
|
| 1054 |
+
univ.Any().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
|
| 1055 |
+
)
|
| 1056 |
+
|
| 1057 |
+
|
| 1058 |
+
class GeneralName(univ.Choice):
|
| 1059 |
+
componentType = namedtype.NamedTypes(
|
| 1060 |
+
namedtype.NamedType('otherName',
|
| 1061 |
+
AnotherName().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 1062 |
+
namedtype.NamedType('rfc822Name',
|
| 1063 |
+
char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 1064 |
+
namedtype.NamedType('dNSName',
|
| 1065 |
+
char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
|
| 1066 |
+
namedtype.NamedType('x400Address',
|
| 1067 |
+
ORAddress().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
|
| 1068 |
+
namedtype.NamedType('directoryName',
|
| 1069 |
+
Name().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))),
|
| 1070 |
+
namedtype.NamedType('ediPartyName',
|
| 1071 |
+
EDIPartyName().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 5))),
|
| 1072 |
+
namedtype.NamedType('uniformResourceIdentifier',
|
| 1073 |
+
char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6))),
|
| 1074 |
+
namedtype.NamedType('iPAddress', univ.OctetString().subtype(
|
| 1075 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))),
|
| 1076 |
+
namedtype.NamedType('registeredID', univ.ObjectIdentifier().subtype(
|
| 1077 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 8)))
|
| 1078 |
+
)
|
| 1079 |
+
|
| 1080 |
+
|
| 1081 |
+
class GeneralNames(univ.SequenceOf):
|
| 1082 |
+
componentType = GeneralName()
|
| 1083 |
+
sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, MAX)
|
| 1084 |
+
|
| 1085 |
+
|
| 1086 |
+
class AccessDescription(univ.Sequence):
|
| 1087 |
+
componentType = namedtype.NamedTypes(
|
| 1088 |
+
namedtype.NamedType('accessMethod', univ.ObjectIdentifier()),
|
| 1089 |
+
namedtype.NamedType('accessLocation', GeneralName())
|
| 1090 |
+
)
|
| 1091 |
+
|
| 1092 |
+
|
| 1093 |
+
class AuthorityInfoAccessSyntax(univ.SequenceOf):
|
| 1094 |
+
componentType = AccessDescription()
|
| 1095 |
+
sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, MAX)
|
| 1096 |
+
|
| 1097 |
+
|
| 1098 |
+
class AuthorityKeyIdentifier(univ.Sequence):
|
| 1099 |
+
componentType = namedtype.NamedTypes(
|
| 1100 |
+
namedtype.OptionalNamedType('keyIdentifier', KeyIdentifier().subtype(
|
| 1101 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 1102 |
+
namedtype.OptionalNamedType('authorityCertIssuer', GeneralNames().subtype(
|
| 1103 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 1104 |
+
namedtype.OptionalNamedType('authorityCertSerialNumber', CertificateSerialNumber().subtype(
|
| 1105 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
|
| 1106 |
+
)
|
| 1107 |
+
|
| 1108 |
+
|
| 1109 |
+
class DistributionPointName(univ.Choice):
|
| 1110 |
+
componentType = namedtype.NamedTypes(
|
| 1111 |
+
namedtype.NamedType('fullName', GeneralNames().subtype(
|
| 1112 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 1113 |
+
namedtype.NamedType('nameRelativeToCRLIssuer', RelativeDistinguishedName().subtype(
|
| 1114 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1)))
|
| 1115 |
+
)
|
| 1116 |
+
|
| 1117 |
+
|
| 1118 |
+
class DistributionPoint(univ.Sequence):
|
| 1119 |
+
componentType = namedtype.NamedTypes(
|
| 1120 |
+
namedtype.OptionalNamedType('distributionPoint', DistributionPointName().subtype(
|
| 1121 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 1122 |
+
namedtype.OptionalNamedType('reasons', ReasonFlags().subtype(
|
| 1123 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 1124 |
+
namedtype.OptionalNamedType('cRLIssuer', GeneralNames().subtype(
|
| 1125 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2)))
|
| 1126 |
+
)
|
| 1127 |
+
|
| 1128 |
+
|
| 1129 |
+
class CRLDistPointsSyntax(univ.SequenceOf):
|
| 1130 |
+
componentType = DistributionPoint()
|
| 1131 |
+
sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, MAX)
|
| 1132 |
+
|
| 1133 |
+
|
| 1134 |
+
class IssuingDistributionPoint(univ.Sequence):
|
| 1135 |
+
componentType = namedtype.NamedTypes(
|
| 1136 |
+
namedtype.OptionalNamedType('distributionPoint', DistributionPointName().subtype(
|
| 1137 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 1138 |
+
namedtype.NamedType('onlyContainsUserCerts', univ.Boolean(False).subtype(
|
| 1139 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 1140 |
+
namedtype.NamedType('onlyContainsCACerts', univ.Boolean(False).subtype(
|
| 1141 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
|
| 1142 |
+
namedtype.OptionalNamedType('onlySomeReasons', ReasonFlags().subtype(
|
| 1143 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
|
| 1144 |
+
namedtype.NamedType('indirectCRL', univ.Boolean(False).subtype(
|
| 1145 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4)))
|
| 1146 |
+
)
|
| 1147 |
+
|
| 1148 |
+
|
| 1149 |
+
class GeneralSubtree(univ.Sequence):
|
| 1150 |
+
componentType = namedtype.NamedTypes(
|
| 1151 |
+
namedtype.NamedType('base', GeneralName()),
|
| 1152 |
+
namedtype.DefaultedNamedType('minimum', BaseDistance(0).subtype(
|
| 1153 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 1154 |
+
namedtype.OptionalNamedType('maximum', BaseDistance().subtype(
|
| 1155 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1)))
|
| 1156 |
+
)
|
| 1157 |
+
|
| 1158 |
+
|
| 1159 |
+
class GeneralSubtrees(univ.SequenceOf):
|
| 1160 |
+
componentType = GeneralSubtree()
|
| 1161 |
+
sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, MAX)
|
| 1162 |
+
|
| 1163 |
+
|
| 1164 |
+
class NameConstraints(univ.Sequence):
|
| 1165 |
+
componentType = namedtype.NamedTypes(
|
| 1166 |
+
namedtype.OptionalNamedType('permittedSubtrees', GeneralSubtrees().subtype(
|
| 1167 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 1168 |
+
namedtype.OptionalNamedType('excludedSubtrees', GeneralSubtrees().subtype(
|
| 1169 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1)))
|
| 1170 |
+
)
|
| 1171 |
+
|
| 1172 |
+
|
| 1173 |
+
class CertificateIssuer(GeneralNames):
|
| 1174 |
+
pass
|
| 1175 |
+
|
| 1176 |
+
|
| 1177 |
+
class SubjectAltName(GeneralNames):
|
| 1178 |
+
pass
|
| 1179 |
+
|
| 1180 |
+
|
| 1181 |
+
class IssuerAltName(GeneralNames):
|
| 1182 |
+
pass
|
| 1183 |
+
|
| 1184 |
+
|
| 1185 |
+
certificateExtensionsMap = {}
|
| 1186 |
+
|
| 1187 |
+
|
| 1188 |
+
class Extension(univ.Sequence):
|
| 1189 |
+
componentType = namedtype.NamedTypes(
|
| 1190 |
+
namedtype.NamedType('extnID', univ.ObjectIdentifier()),
|
| 1191 |
+
namedtype.DefaultedNamedType('critical', univ.Boolean('False')),
|
| 1192 |
+
namedtype.NamedType('extnValue', univ.OctetString(),
|
| 1193 |
+
openType=opentype.OpenType('extnID', certificateExtensionsMap))
|
| 1194 |
+
)
|
| 1195 |
+
|
| 1196 |
+
|
| 1197 |
+
class Extensions(univ.SequenceOf):
|
| 1198 |
+
componentType = Extension()
|
| 1199 |
+
sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, MAX)
|
| 1200 |
+
|
| 1201 |
+
|
| 1202 |
+
class SubjectPublicKeyInfo(univ.Sequence):
|
| 1203 |
+
componentType = namedtype.NamedTypes(
|
| 1204 |
+
namedtype.NamedType('algorithm', AlgorithmIdentifier()),
|
| 1205 |
+
namedtype.NamedType('subjectPublicKey', univ.BitString())
|
| 1206 |
+
)
|
| 1207 |
+
|
| 1208 |
+
|
| 1209 |
+
class UniqueIdentifier(univ.BitString):
|
| 1210 |
+
pass
|
| 1211 |
+
|
| 1212 |
+
|
| 1213 |
+
class Time(univ.Choice):
|
| 1214 |
+
componentType = namedtype.NamedTypes(
|
| 1215 |
+
namedtype.NamedType('utcTime', useful.UTCTime()),
|
| 1216 |
+
namedtype.NamedType('generalTime', useful.GeneralizedTime())
|
| 1217 |
+
)
|
| 1218 |
+
|
| 1219 |
+
|
| 1220 |
+
class Validity(univ.Sequence):
|
| 1221 |
+
componentType = namedtype.NamedTypes(
|
| 1222 |
+
namedtype.NamedType('notBefore', Time()),
|
| 1223 |
+
namedtype.NamedType('notAfter', Time())
|
| 1224 |
+
)
|
| 1225 |
+
|
| 1226 |
+
|
| 1227 |
+
class Version(univ.Integer):
|
| 1228 |
+
namedValues = namedval.NamedValues(
|
| 1229 |
+
('v1', 0), ('v2', 1), ('v3', 2)
|
| 1230 |
+
)
|
| 1231 |
+
|
| 1232 |
+
|
| 1233 |
+
class TBSCertificate(univ.Sequence):
|
| 1234 |
+
componentType = namedtype.NamedTypes(
|
| 1235 |
+
namedtype.DefaultedNamedType('version', Version('v1').subtype(
|
| 1236 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 1237 |
+
namedtype.NamedType('serialNumber', CertificateSerialNumber()),
|
| 1238 |
+
namedtype.NamedType('signature', AlgorithmIdentifier()),
|
| 1239 |
+
namedtype.NamedType('issuer', Name()),
|
| 1240 |
+
namedtype.NamedType('validity', Validity()),
|
| 1241 |
+
namedtype.NamedType('subject', Name()),
|
| 1242 |
+
namedtype.NamedType('subjectPublicKeyInfo', SubjectPublicKeyInfo()),
|
| 1243 |
+
namedtype.OptionalNamedType('issuerUniqueID', UniqueIdentifier().subtype(
|
| 1244 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 1245 |
+
namedtype.OptionalNamedType('subjectUniqueID', UniqueIdentifier().subtype(
|
| 1246 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
|
| 1247 |
+
namedtype.OptionalNamedType('extensions', Extensions().subtype(
|
| 1248 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
|
| 1249 |
+
)
|
| 1250 |
+
|
| 1251 |
+
|
| 1252 |
+
class Certificate(univ.Sequence):
|
| 1253 |
+
componentType = namedtype.NamedTypes(
|
| 1254 |
+
namedtype.NamedType('tbsCertificate', TBSCertificate()),
|
| 1255 |
+
namedtype.NamedType('signatureAlgorithm', AlgorithmIdentifier()),
|
| 1256 |
+
namedtype.NamedType('signatureValue', univ.BitString())
|
| 1257 |
+
)
|
| 1258 |
+
|
| 1259 |
+
# CRL structures
|
| 1260 |
+
|
| 1261 |
+
class RevokedCertificate(univ.Sequence):
|
| 1262 |
+
componentType = namedtype.NamedTypes(
|
| 1263 |
+
namedtype.NamedType('userCertificate', CertificateSerialNumber()),
|
| 1264 |
+
namedtype.NamedType('revocationDate', Time()),
|
| 1265 |
+
namedtype.OptionalNamedType('crlEntryExtensions', Extensions())
|
| 1266 |
+
)
|
| 1267 |
+
|
| 1268 |
+
|
| 1269 |
+
class TBSCertList(univ.Sequence):
|
| 1270 |
+
componentType = namedtype.NamedTypes(
|
| 1271 |
+
namedtype.OptionalNamedType('version', Version()),
|
| 1272 |
+
namedtype.NamedType('signature', AlgorithmIdentifier()),
|
| 1273 |
+
namedtype.NamedType('issuer', Name()),
|
| 1274 |
+
namedtype.NamedType('thisUpdate', Time()),
|
| 1275 |
+
namedtype.OptionalNamedType('nextUpdate', Time()),
|
| 1276 |
+
namedtype.OptionalNamedType('revokedCertificates', univ.SequenceOf(componentType=RevokedCertificate())),
|
| 1277 |
+
namedtype.OptionalNamedType('crlExtensions', Extensions().subtype(
|
| 1278 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))
|
| 1279 |
+
)
|
| 1280 |
+
|
| 1281 |
+
|
| 1282 |
+
class CertificateList(univ.Sequence):
|
| 1283 |
+
componentType = namedtype.NamedTypes(
|
| 1284 |
+
namedtype.NamedType('tbsCertList', TBSCertList()),
|
| 1285 |
+
namedtype.NamedType('signatureAlgorithm', AlgorithmIdentifier()),
|
| 1286 |
+
namedtype.NamedType('signature', univ.BitString())
|
| 1287 |
+
)
|
| 1288 |
+
|
| 1289 |
+
# map of AttributeType -> AttributeValue
|
| 1290 |
+
|
| 1291 |
+
_certificateAttributesMapUpdate = {
|
| 1292 |
+
id_at_name: X520name(),
|
| 1293 |
+
id_at_surname: X520name(),
|
| 1294 |
+
id_at_givenName: X520name(),
|
| 1295 |
+
id_at_initials: X520name(),
|
| 1296 |
+
id_at_generationQualifier: X520name(),
|
| 1297 |
+
id_at_commonName: X520CommonName(),
|
| 1298 |
+
id_at_localityName: X520LocalityName(),
|
| 1299 |
+
id_at_stateOrProvinceName: X520StateOrProvinceName(),
|
| 1300 |
+
id_at_organizationName: X520OrganizationName(),
|
| 1301 |
+
id_at_organizationalUnitName: X520OrganizationalUnitName(),
|
| 1302 |
+
id_at_title: X520Title(),
|
| 1303 |
+
id_at_dnQualifier: X520dnQualifier(),
|
| 1304 |
+
id_at_countryName: X520countryName(),
|
| 1305 |
+
emailAddress: Pkcs9email(),
|
| 1306 |
+
}
|
| 1307 |
+
|
| 1308 |
+
certificateAttributesMap.update(_certificateAttributesMapUpdate)
|
| 1309 |
+
|
| 1310 |
+
|
| 1311 |
+
# map of Certificate Extension OIDs to Extensions
|
| 1312 |
+
|
| 1313 |
+
_certificateExtensionsMapUpdate = {
|
| 1314 |
+
id_ce_authorityKeyIdentifier: AuthorityKeyIdentifier(),
|
| 1315 |
+
id_ce_subjectKeyIdentifier: SubjectKeyIdentifier(),
|
| 1316 |
+
id_ce_keyUsage: KeyUsage(),
|
| 1317 |
+
id_ce_privateKeyUsagePeriod: PrivateKeyUsagePeriod(),
|
| 1318 |
+
id_ce_certificatePolicies: CertificatePolicies(),
|
| 1319 |
+
id_ce_policyMappings: PolicyMappings(),
|
| 1320 |
+
id_ce_subjectAltName: SubjectAltName(),
|
| 1321 |
+
id_ce_issuerAltName: IssuerAltName(),
|
| 1322 |
+
id_ce_subjectDirectoryAttributes: SubjectDirectoryAttributes(),
|
| 1323 |
+
id_ce_basicConstraints: BasicConstraints(),
|
| 1324 |
+
id_ce_nameConstraints: NameConstraints(),
|
| 1325 |
+
id_ce_policyConstraints: PolicyConstraints(),
|
| 1326 |
+
id_ce_extKeyUsage: ExtKeyUsageSyntax(),
|
| 1327 |
+
id_ce_cRLDistributionPoints: CRLDistPointsSyntax(),
|
| 1328 |
+
id_pe_authorityInfoAccess: AuthorityInfoAccessSyntax(),
|
| 1329 |
+
id_ce_cRLNumber: univ.Integer(),
|
| 1330 |
+
id_ce_deltaCRLIndicator: BaseCRLNumber(),
|
| 1331 |
+
id_ce_issuingDistributionPoint: IssuingDistributionPoint(),
|
| 1332 |
+
id_ce_cRLReasons: CRLReason(),
|
| 1333 |
+
id_ce_holdInstructionCode: univ.ObjectIdentifier(),
|
| 1334 |
+
id_ce_invalidityDate: useful.GeneralizedTime(),
|
| 1335 |
+
id_ce_certificateIssuer: GeneralNames(),
|
| 1336 |
+
}
|
| 1337 |
+
|
| 1338 |
+
certificateExtensionsMap.update(_certificateExtensionsMapUpdate)
|
| 1339 |
+
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc2560.py
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# This file is part of pyasn1-modules software.
|
| 3 |
+
#
|
| 4 |
+
# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
|
| 5 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 6 |
+
#
|
| 7 |
+
# OCSP request/response syntax
|
| 8 |
+
#
|
| 9 |
+
# Derived from a minimal OCSP library (RFC2560) code written by
|
| 10 |
+
# Bud P. Bruegger <bud@ancitel.it>
|
| 11 |
+
# Copyright: Ancitel, S.p.a, Rome, Italy
|
| 12 |
+
# License: BSD
|
| 13 |
+
#
|
| 14 |
+
|
| 15 |
+
#
|
| 16 |
+
# current limitations:
|
| 17 |
+
# * request and response works only for a single certificate
|
| 18 |
+
# * only some values are parsed out of the response
|
| 19 |
+
# * the request does't set a nonce nor signature
|
| 20 |
+
# * there is no signature validation of the response
|
| 21 |
+
# * dates are left as strings in GeneralizedTime format -- datetime.datetime
|
| 22 |
+
# would be nicer
|
| 23 |
+
#
|
| 24 |
+
from pyasn1.type import namedtype
|
| 25 |
+
from pyasn1.type import namedval
|
| 26 |
+
from pyasn1.type import tag
|
| 27 |
+
from pyasn1.type import univ
|
| 28 |
+
from pyasn1.type import useful
|
| 29 |
+
|
| 30 |
+
from pyasn1_modules import rfc2459
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
# Start of OCSP module definitions
|
| 34 |
+
|
| 35 |
+
# This should be in directory Authentication Framework (X.509) module
|
| 36 |
+
|
| 37 |
+
class CRLReason(univ.Enumerated):
|
| 38 |
+
namedValues = namedval.NamedValues(
|
| 39 |
+
('unspecified', 0),
|
| 40 |
+
('keyCompromise', 1),
|
| 41 |
+
('cACompromise', 2),
|
| 42 |
+
('affiliationChanged', 3),
|
| 43 |
+
('superseded', 4),
|
| 44 |
+
('cessationOfOperation', 5),
|
| 45 |
+
('certificateHold', 6),
|
| 46 |
+
('removeFromCRL', 8),
|
| 47 |
+
('privilegeWithdrawn', 9),
|
| 48 |
+
('aACompromise', 10)
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
# end of directory Authentication Framework (X.509) module
|
| 53 |
+
|
| 54 |
+
# This should be in PKIX Certificate Extensions module
|
| 55 |
+
|
| 56 |
+
class GeneralName(univ.OctetString):
|
| 57 |
+
pass
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
# end of PKIX Certificate Extensions module
|
| 61 |
+
|
| 62 |
+
id_kp_OCSPSigning = univ.ObjectIdentifier((1, 3, 6, 1, 5, 5, 7, 3, 9))
|
| 63 |
+
id_pkix_ocsp = univ.ObjectIdentifier((1, 3, 6, 1, 5, 5, 7, 48, 1))
|
| 64 |
+
id_pkix_ocsp_basic = univ.ObjectIdentifier((1, 3, 6, 1, 5, 5, 7, 48, 1, 1))
|
| 65 |
+
id_pkix_ocsp_nonce = univ.ObjectIdentifier((1, 3, 6, 1, 5, 5, 7, 48, 1, 2))
|
| 66 |
+
id_pkix_ocsp_crl = univ.ObjectIdentifier((1, 3, 6, 1, 5, 5, 7, 48, 1, 3))
|
| 67 |
+
id_pkix_ocsp_response = univ.ObjectIdentifier((1, 3, 6, 1, 5, 5, 7, 48, 1, 4))
|
| 68 |
+
id_pkix_ocsp_nocheck = univ.ObjectIdentifier((1, 3, 6, 1, 5, 5, 7, 48, 1, 5))
|
| 69 |
+
id_pkix_ocsp_archive_cutoff = univ.ObjectIdentifier((1, 3, 6, 1, 5, 5, 7, 48, 1, 6))
|
| 70 |
+
id_pkix_ocsp_service_locator = univ.ObjectIdentifier((1, 3, 6, 1, 5, 5, 7, 48, 1, 7))
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
class AcceptableResponses(univ.SequenceOf):
|
| 74 |
+
componentType = univ.ObjectIdentifier()
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
class ArchiveCutoff(useful.GeneralizedTime):
|
| 78 |
+
pass
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
class UnknownInfo(univ.Null):
|
| 82 |
+
pass
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
class RevokedInfo(univ.Sequence):
|
| 86 |
+
componentType = namedtype.NamedTypes(
|
| 87 |
+
namedtype.NamedType('revocationTime', useful.GeneralizedTime()),
|
| 88 |
+
namedtype.OptionalNamedType('revocationReason', CRLReason().subtype(
|
| 89 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
|
| 90 |
+
)
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
class CertID(univ.Sequence):
|
| 94 |
+
componentType = namedtype.NamedTypes(
|
| 95 |
+
namedtype.NamedType('hashAlgorithm', rfc2459.AlgorithmIdentifier()),
|
| 96 |
+
namedtype.NamedType('issuerNameHash', univ.OctetString()),
|
| 97 |
+
namedtype.NamedType('issuerKeyHash', univ.OctetString()),
|
| 98 |
+
namedtype.NamedType('serialNumber', rfc2459.CertificateSerialNumber())
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
class CertStatus(univ.Choice):
|
| 103 |
+
componentType = namedtype.NamedTypes(
|
| 104 |
+
namedtype.NamedType('good',
|
| 105 |
+
univ.Null().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 106 |
+
namedtype.NamedType('revoked',
|
| 107 |
+
RevokedInfo().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 108 |
+
namedtype.NamedType('unknown',
|
| 109 |
+
UnknownInfo().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
class SingleResponse(univ.Sequence):
|
| 114 |
+
componentType = namedtype.NamedTypes(
|
| 115 |
+
namedtype.NamedType('certID', CertID()),
|
| 116 |
+
namedtype.NamedType('certStatus', CertStatus()),
|
| 117 |
+
namedtype.NamedType('thisUpdate', useful.GeneralizedTime()),
|
| 118 |
+
namedtype.OptionalNamedType('nextUpdate', useful.GeneralizedTime().subtype(
|
| 119 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 120 |
+
namedtype.OptionalNamedType('singleExtensions', rfc2459.Extensions().subtype(
|
| 121 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 122 |
+
)
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
class KeyHash(univ.OctetString):
|
| 126 |
+
pass
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
class ResponderID(univ.Choice):
|
| 130 |
+
componentType = namedtype.NamedTypes(
|
| 131 |
+
namedtype.NamedType('byName',
|
| 132 |
+
rfc2459.Name().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 133 |
+
namedtype.NamedType('byKey',
|
| 134 |
+
KeyHash().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
|
| 135 |
+
)
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
class Version(univ.Integer):
|
| 139 |
+
namedValues = namedval.NamedValues(('v1', 0))
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
class ResponseData(univ.Sequence):
|
| 143 |
+
componentType = namedtype.NamedTypes(
|
| 144 |
+
namedtype.DefaultedNamedType('version', Version('v1').subtype(
|
| 145 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 146 |
+
namedtype.NamedType('responderID', ResponderID()),
|
| 147 |
+
namedtype.NamedType('producedAt', useful.GeneralizedTime()),
|
| 148 |
+
namedtype.NamedType('responses', univ.SequenceOf(componentType=SingleResponse())),
|
| 149 |
+
namedtype.OptionalNamedType('responseExtensions', rfc2459.Extensions().subtype(
|
| 150 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 151 |
+
)
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
class BasicOCSPResponse(univ.Sequence):
|
| 155 |
+
componentType = namedtype.NamedTypes(
|
| 156 |
+
namedtype.NamedType('tbsResponseData', ResponseData()),
|
| 157 |
+
namedtype.NamedType('signatureAlgorithm', rfc2459.AlgorithmIdentifier()),
|
| 158 |
+
namedtype.NamedType('signature', univ.BitString()),
|
| 159 |
+
namedtype.OptionalNamedType('certs', univ.SequenceOf(componentType=rfc2459.Certificate()).subtype(
|
| 160 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
|
| 161 |
+
)
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
class ResponseBytes(univ.Sequence):
|
| 165 |
+
componentType = namedtype.NamedTypes(
|
| 166 |
+
namedtype.NamedType('responseType', univ.ObjectIdentifier()),
|
| 167 |
+
namedtype.NamedType('response', univ.OctetString())
|
| 168 |
+
)
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
class OCSPResponseStatus(univ.Enumerated):
|
| 172 |
+
namedValues = namedval.NamedValues(
|
| 173 |
+
('successful', 0),
|
| 174 |
+
('malformedRequest', 1),
|
| 175 |
+
('internalError', 2),
|
| 176 |
+
('tryLater', 3),
|
| 177 |
+
('undefinedStatus', 4), # should never occur
|
| 178 |
+
('sigRequired', 5),
|
| 179 |
+
('unauthorized', 6)
|
| 180 |
+
)
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
class OCSPResponse(univ.Sequence):
|
| 184 |
+
componentType = namedtype.NamedTypes(
|
| 185 |
+
namedtype.NamedType('responseStatus', OCSPResponseStatus()),
|
| 186 |
+
namedtype.OptionalNamedType('responseBytes', ResponseBytes().subtype(
|
| 187 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
|
| 188 |
+
)
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
class Request(univ.Sequence):
|
| 192 |
+
componentType = namedtype.NamedTypes(
|
| 193 |
+
namedtype.NamedType('reqCert', CertID()),
|
| 194 |
+
namedtype.OptionalNamedType('singleRequestExtensions', rfc2459.Extensions().subtype(
|
| 195 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
|
| 196 |
+
)
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
class Signature(univ.Sequence):
|
| 200 |
+
componentType = namedtype.NamedTypes(
|
| 201 |
+
namedtype.NamedType('signatureAlgorithm', rfc2459.AlgorithmIdentifier()),
|
| 202 |
+
namedtype.NamedType('signature', univ.BitString()),
|
| 203 |
+
namedtype.OptionalNamedType('certs', univ.SequenceOf(componentType=rfc2459.Certificate()).subtype(
|
| 204 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
|
| 205 |
+
)
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
class TBSRequest(univ.Sequence):
|
| 209 |
+
componentType = namedtype.NamedTypes(
|
| 210 |
+
namedtype.DefaultedNamedType('version', Version('v1').subtype(
|
| 211 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 212 |
+
namedtype.OptionalNamedType('requestorName', GeneralName().subtype(
|
| 213 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 214 |
+
namedtype.NamedType('requestList', univ.SequenceOf(componentType=Request())),
|
| 215 |
+
namedtype.OptionalNamedType('requestExtensions', rfc2459.Extensions().subtype(
|
| 216 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
|
| 217 |
+
)
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
class OCSPRequest(univ.Sequence):
|
| 221 |
+
componentType = namedtype.NamedTypes(
|
| 222 |
+
namedtype.NamedType('tbsRequest', TBSRequest()),
|
| 223 |
+
namedtype.OptionalNamedType('optionalSignature', Signature().subtype(
|
| 224 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
|
| 225 |
+
)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc2631.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
# Diffie-Hellman Key Agreement
|
| 10 |
+
#
|
| 11 |
+
# ASN.1 source from:
|
| 12 |
+
# https://www.rfc-editor.org/rfc/rfc2631.txt
|
| 13 |
+
# https://www.rfc-editor.org/errata/eid5897
|
| 14 |
+
#
|
| 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 KeySpecificInfo(univ.Sequence):
|
| 23 |
+
componentType = namedtype.NamedTypes(
|
| 24 |
+
namedtype.NamedType('algorithm', univ.ObjectIdentifier()),
|
| 25 |
+
namedtype.NamedType('counter', univ.OctetString().subtype(
|
| 26 |
+
subtypeSpec=constraint.ValueSizeConstraint(4, 4)))
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class OtherInfo(univ.Sequence):
|
| 31 |
+
componentType = namedtype.NamedTypes(
|
| 32 |
+
namedtype.NamedType('keyInfo', KeySpecificInfo()),
|
| 33 |
+
namedtype.OptionalNamedType('partyAInfo', univ.OctetString().subtype(
|
| 34 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 35 |
+
namedtype.NamedType('suppPubInfo', univ.OctetString().subtype(
|
| 36 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
|
| 37 |
+
)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc2634.py
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 a map for use with opentypes.
|
| 6 |
+
#
|
| 7 |
+
# Copyright (c) 2019, Vigil Security, LLC
|
| 8 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 9 |
+
#
|
| 10 |
+
# Enhanced Security Services for S/MIME
|
| 11 |
+
#
|
| 12 |
+
# ASN.1 source from:
|
| 13 |
+
# https://www.rfc-editor.org/rfc/rfc2634.txt
|
| 14 |
+
#
|
| 15 |
+
|
| 16 |
+
from pyasn1.type import char
|
| 17 |
+
from pyasn1.type import constraint
|
| 18 |
+
from pyasn1.type import namedval
|
| 19 |
+
from pyasn1.type import namedtype
|
| 20 |
+
from pyasn1.type import tag
|
| 21 |
+
from pyasn1.type import univ
|
| 22 |
+
from pyasn1.type import useful
|
| 23 |
+
|
| 24 |
+
from pyasn1_modules import rfc5652
|
| 25 |
+
from pyasn1_modules import rfc5280
|
| 26 |
+
|
| 27 |
+
MAX = float('inf')
|
| 28 |
+
|
| 29 |
+
ContentType = rfc5652.ContentType
|
| 30 |
+
|
| 31 |
+
IssuerAndSerialNumber = rfc5652.IssuerAndSerialNumber
|
| 32 |
+
|
| 33 |
+
SubjectKeyIdentifier = rfc5652.SubjectKeyIdentifier
|
| 34 |
+
|
| 35 |
+
PolicyInformation = rfc5280.PolicyInformation
|
| 36 |
+
|
| 37 |
+
GeneralNames = rfc5280.GeneralNames
|
| 38 |
+
|
| 39 |
+
CertificateSerialNumber = rfc5280.CertificateSerialNumber
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
# Signing Certificate Attribute
|
| 43 |
+
# Warning: It is better to use SigningCertificateV2 from RFC 5035
|
| 44 |
+
|
| 45 |
+
id_aa_signingCertificate = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.12')
|
| 46 |
+
|
| 47 |
+
class Hash(univ.OctetString):
|
| 48 |
+
pass # SHA-1 hash of entire certificate; RFC 5035 supports other hash algorithms
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
class IssuerSerial(univ.Sequence):
|
| 52 |
+
pass
|
| 53 |
+
|
| 54 |
+
IssuerSerial.componentType = namedtype.NamedTypes(
|
| 55 |
+
namedtype.NamedType('issuer', GeneralNames()),
|
| 56 |
+
namedtype.NamedType('serialNumber', CertificateSerialNumber())
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
class ESSCertID(univ.Sequence):
|
| 61 |
+
pass
|
| 62 |
+
|
| 63 |
+
ESSCertID.componentType = namedtype.NamedTypes(
|
| 64 |
+
namedtype.NamedType('certHash', Hash()),
|
| 65 |
+
namedtype.OptionalNamedType('issuerSerial', IssuerSerial())
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
class SigningCertificate(univ.Sequence):
|
| 70 |
+
pass
|
| 71 |
+
|
| 72 |
+
SigningCertificate.componentType = namedtype.NamedTypes(
|
| 73 |
+
namedtype.NamedType('certs', univ.SequenceOf(
|
| 74 |
+
componentType=ESSCertID())),
|
| 75 |
+
namedtype.OptionalNamedType('policies', univ.SequenceOf(
|
| 76 |
+
componentType=PolicyInformation()))
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
# Mail List Expansion History Attribute
|
| 81 |
+
|
| 82 |
+
id_aa_mlExpandHistory = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.3')
|
| 83 |
+
|
| 84 |
+
ub_ml_expansion_history = univ.Integer(64)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
class EntityIdentifier(univ.Choice):
|
| 88 |
+
pass
|
| 89 |
+
|
| 90 |
+
EntityIdentifier.componentType = namedtype.NamedTypes(
|
| 91 |
+
namedtype.NamedType('issuerAndSerialNumber', IssuerAndSerialNumber()),
|
| 92 |
+
namedtype.NamedType('subjectKeyIdentifier', SubjectKeyIdentifier())
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
class MLReceiptPolicy(univ.Choice):
|
| 97 |
+
pass
|
| 98 |
+
|
| 99 |
+
MLReceiptPolicy.componentType = namedtype.NamedTypes(
|
| 100 |
+
namedtype.NamedType('none', univ.Null().subtype(implicitTag=tag.Tag(
|
| 101 |
+
tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 102 |
+
namedtype.NamedType('insteadOf', univ.SequenceOf(
|
| 103 |
+
componentType=GeneralNames()).subtype(
|
| 104 |
+
sizeSpec=constraint.ValueSizeConstraint(1, MAX)).subtype(
|
| 105 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 106 |
+
namedtype.NamedType('inAdditionTo', univ.SequenceOf(
|
| 107 |
+
componentType=GeneralNames()).subtype(
|
| 108 |
+
sizeSpec=constraint.ValueSizeConstraint(1, MAX)).subtype(
|
| 109 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
class MLData(univ.Sequence):
|
| 114 |
+
pass
|
| 115 |
+
|
| 116 |
+
MLData.componentType = namedtype.NamedTypes(
|
| 117 |
+
namedtype.NamedType('mailListIdentifier', EntityIdentifier()),
|
| 118 |
+
namedtype.NamedType('expansionTime', useful.GeneralizedTime()),
|
| 119 |
+
namedtype.OptionalNamedType('mlReceiptPolicy', MLReceiptPolicy())
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
+
class MLExpansionHistory(univ.SequenceOf):
|
| 123 |
+
pass
|
| 124 |
+
|
| 125 |
+
MLExpansionHistory.componentType = MLData()
|
| 126 |
+
MLExpansionHistory.sizeSpec = constraint.ValueSizeConstraint(1, ub_ml_expansion_history)
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
# ESS Security Label Attribute
|
| 130 |
+
|
| 131 |
+
id_aa_securityLabel = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.2')
|
| 132 |
+
|
| 133 |
+
ub_privacy_mark_length = univ.Integer(128)
|
| 134 |
+
|
| 135 |
+
ub_security_categories = univ.Integer(64)
|
| 136 |
+
|
| 137 |
+
ub_integer_options = univ.Integer(256)
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
class ESSPrivacyMark(univ.Choice):
|
| 141 |
+
pass
|
| 142 |
+
|
| 143 |
+
ESSPrivacyMark.componentType = namedtype.NamedTypes(
|
| 144 |
+
namedtype.NamedType('pString', char.PrintableString().subtype(
|
| 145 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_privacy_mark_length))),
|
| 146 |
+
namedtype.NamedType('utf8String', char.UTF8String().subtype(
|
| 147 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, MAX)))
|
| 148 |
+
)
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
class SecurityClassification(univ.Integer):
|
| 152 |
+
pass
|
| 153 |
+
|
| 154 |
+
SecurityClassification.subtypeSpec=constraint.ValueRangeConstraint(0, ub_integer_options)
|
| 155 |
+
|
| 156 |
+
SecurityClassification.namedValues = namedval.NamedValues(
|
| 157 |
+
('unmarked', 0),
|
| 158 |
+
('unclassified', 1),
|
| 159 |
+
('restricted', 2),
|
| 160 |
+
('confidential', 3),
|
| 161 |
+
('secret', 4),
|
| 162 |
+
('top-secret', 5)
|
| 163 |
+
)
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
class SecurityPolicyIdentifier(univ.ObjectIdentifier):
|
| 167 |
+
pass
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
class SecurityCategory(univ.Sequence):
|
| 171 |
+
pass
|
| 172 |
+
|
| 173 |
+
SecurityCategory.componentType = namedtype.NamedTypes(
|
| 174 |
+
namedtype.NamedType('type', univ.ObjectIdentifier().subtype(
|
| 175 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 176 |
+
namedtype.NamedType('value', univ.Any().subtype(implicitTag=tag.Tag(
|
| 177 |
+
tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 178 |
+
)
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
class SecurityCategories(univ.SetOf):
|
| 182 |
+
pass
|
| 183 |
+
|
| 184 |
+
SecurityCategories.componentType = SecurityCategory()
|
| 185 |
+
SecurityCategories.sizeSpec = constraint.ValueSizeConstraint(1, ub_security_categories)
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
class ESSSecurityLabel(univ.Set):
|
| 189 |
+
pass
|
| 190 |
+
|
| 191 |
+
ESSSecurityLabel.componentType = namedtype.NamedTypes(
|
| 192 |
+
namedtype.NamedType('security-policy-identifier', SecurityPolicyIdentifier()),
|
| 193 |
+
namedtype.OptionalNamedType('security-classification', SecurityClassification()),
|
| 194 |
+
namedtype.OptionalNamedType('privacy-mark', ESSPrivacyMark()),
|
| 195 |
+
namedtype.OptionalNamedType('security-categories', SecurityCategories())
|
| 196 |
+
)
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
# Equivalent Labels Attribute
|
| 200 |
+
|
| 201 |
+
id_aa_equivalentLabels = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.9')
|
| 202 |
+
|
| 203 |
+
class EquivalentLabels(univ.SequenceOf):
|
| 204 |
+
pass
|
| 205 |
+
|
| 206 |
+
EquivalentLabels.componentType = ESSSecurityLabel()
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
# Content Identifier Attribute
|
| 210 |
+
|
| 211 |
+
id_aa_contentIdentifier = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.7')
|
| 212 |
+
|
| 213 |
+
class ContentIdentifier(univ.OctetString):
|
| 214 |
+
pass
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
# Content Reference Attribute
|
| 218 |
+
|
| 219 |
+
id_aa_contentReference = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.10')
|
| 220 |
+
|
| 221 |
+
class ContentReference(univ.Sequence):
|
| 222 |
+
pass
|
| 223 |
+
|
| 224 |
+
ContentReference.componentType = namedtype.NamedTypes(
|
| 225 |
+
namedtype.NamedType('contentType', ContentType()),
|
| 226 |
+
namedtype.NamedType('signedContentIdentifier', ContentIdentifier()),
|
| 227 |
+
namedtype.NamedType('originatorSignatureValue', univ.OctetString())
|
| 228 |
+
)
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
# Message Signature Digest Attribute
|
| 232 |
+
|
| 233 |
+
id_aa_msgSigDigest = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.5')
|
| 234 |
+
|
| 235 |
+
class MsgSigDigest(univ.OctetString):
|
| 236 |
+
pass
|
| 237 |
+
|
| 238 |
+
|
| 239 |
+
# Content Hints Attribute
|
| 240 |
+
|
| 241 |
+
id_aa_contentHint = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.4')
|
| 242 |
+
|
| 243 |
+
class ContentHints(univ.Sequence):
|
| 244 |
+
pass
|
| 245 |
+
|
| 246 |
+
ContentHints.componentType = namedtype.NamedTypes(
|
| 247 |
+
namedtype.OptionalNamedType('contentDescription', char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
|
| 248 |
+
namedtype.NamedType('contentType', ContentType())
|
| 249 |
+
)
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
# Receipt Request Attribute
|
| 253 |
+
|
| 254 |
+
class AllOrFirstTier(univ.Integer):
|
| 255 |
+
pass
|
| 256 |
+
|
| 257 |
+
AllOrFirstTier.namedValues = namedval.NamedValues(
|
| 258 |
+
('allReceipts', 0),
|
| 259 |
+
('firstTierRecipients', 1)
|
| 260 |
+
)
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
class ReceiptsFrom(univ.Choice):
|
| 264 |
+
pass
|
| 265 |
+
|
| 266 |
+
ReceiptsFrom.componentType = namedtype.NamedTypes(
|
| 267 |
+
namedtype.NamedType('allOrFirstTier', AllOrFirstTier().subtype(
|
| 268 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 269 |
+
namedtype.NamedType('receiptList', univ.SequenceOf(
|
| 270 |
+
componentType=GeneralNames()).subtype(implicitTag=tag.Tag(
|
| 271 |
+
tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 272 |
+
)
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
id_aa_receiptRequest = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.1')
|
| 276 |
+
|
| 277 |
+
ub_receiptsTo = univ.Integer(16)
|
| 278 |
+
|
| 279 |
+
class ReceiptRequest(univ.Sequence):
|
| 280 |
+
pass
|
| 281 |
+
|
| 282 |
+
ReceiptRequest.componentType = namedtype.NamedTypes(
|
| 283 |
+
namedtype.NamedType('signedContentIdentifier', ContentIdentifier()),
|
| 284 |
+
namedtype.NamedType('receiptsFrom', ReceiptsFrom()),
|
| 285 |
+
namedtype.NamedType('receiptsTo', univ.SequenceOf(componentType=GeneralNames()).subtype(sizeSpec=constraint.ValueSizeConstraint(1, ub_receiptsTo)))
|
| 286 |
+
)
|
| 287 |
+
|
| 288 |
+
# Receipt Content Type
|
| 289 |
+
|
| 290 |
+
class ESSVersion(univ.Integer):
|
| 291 |
+
pass
|
| 292 |
+
|
| 293 |
+
ESSVersion.namedValues = namedval.NamedValues(
|
| 294 |
+
('v1', 1)
|
| 295 |
+
)
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
id_ct_receipt = univ.ObjectIdentifier('1.2.840.113549.1.9.16.1.1')
|
| 299 |
+
|
| 300 |
+
class Receipt(univ.Sequence):
|
| 301 |
+
pass
|
| 302 |
+
|
| 303 |
+
Receipt.componentType = namedtype.NamedTypes(
|
| 304 |
+
namedtype.NamedType('version', ESSVersion()),
|
| 305 |
+
namedtype.NamedType('contentType', ContentType()),
|
| 306 |
+
namedtype.NamedType('signedContentIdentifier', ContentIdentifier()),
|
| 307 |
+
namedtype.NamedType('originatorSignatureValue', univ.OctetString())
|
| 308 |
+
)
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
# Map of Attribute Type to the Attribute structure is added to the
|
| 312 |
+
# ones that are in rfc5652.py
|
| 313 |
+
|
| 314 |
+
_cmsAttributesMapUpdate = {
|
| 315 |
+
id_aa_signingCertificate: SigningCertificate(),
|
| 316 |
+
id_aa_mlExpandHistory: MLExpansionHistory(),
|
| 317 |
+
id_aa_securityLabel: ESSSecurityLabel(),
|
| 318 |
+
id_aa_equivalentLabels: EquivalentLabels(),
|
| 319 |
+
id_aa_contentIdentifier: ContentIdentifier(),
|
| 320 |
+
id_aa_contentReference: ContentReference(),
|
| 321 |
+
id_aa_msgSigDigest: MsgSigDigest(),
|
| 322 |
+
id_aa_contentHint: ContentHints(),
|
| 323 |
+
id_aa_receiptRequest: ReceiptRequest(),
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
rfc5652.cmsAttributesMap.update(_cmsAttributesMapUpdate)
|
| 327 |
+
|
| 328 |
+
|
| 329 |
+
# Map of Content Type OIDs to Content Types is added to the
|
| 330 |
+
# ones that are in rfc5652.py
|
| 331 |
+
|
| 332 |
+
_cmsContentTypesMapUpdate = {
|
| 333 |
+
id_ct_receipt: Receipt(),
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
rfc5652.cmsContentTypesMap.update(_cmsContentTypesMapUpdate)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc2876.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
# KEA and SKIPJACK Algorithms in CMS
|
| 10 |
+
#
|
| 11 |
+
# ASN.1 source from:
|
| 12 |
+
# https://www.rfc-editor.org/rfc/rfc2876.txt
|
| 13 |
+
#
|
| 14 |
+
|
| 15 |
+
from pyasn1.type import namedtype
|
| 16 |
+
from pyasn1.type import univ
|
| 17 |
+
|
| 18 |
+
from pyasn1_modules import rfc5280
|
| 19 |
+
from pyasn1_modules import rfc5751
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
id_fortezzaConfidentialityAlgorithm = univ.ObjectIdentifier('2.16.840.1.101.2.1.1.4')
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
id_fortezzaWrap80 = univ.ObjectIdentifier('2.16.840.1.101.2.1.1.23')
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
id_kEAKeyEncryptionAlgorithm = univ.ObjectIdentifier('2.16.840.1.101.2.1.1.24')
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
id_keyExchangeAlgorithm = univ.ObjectIdentifier('2.16.840.1.101.2.1.1.22')
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
class Skipjack_Parm(univ.Sequence):
|
| 35 |
+
componentType = namedtype.NamedTypes(
|
| 36 |
+
namedtype.NamedType('initialization-vector', univ.OctetString())
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
# Update the Algorithm Identifier map in rfc5280.py.
|
| 41 |
+
|
| 42 |
+
_algorithmIdentifierMapUpdate = {
|
| 43 |
+
id_fortezzaConfidentialityAlgorithm: Skipjack_Parm(),
|
| 44 |
+
id_kEAKeyEncryptionAlgorithm: rfc5280.AlgorithmIdentifier(),
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
# Update the SMIMECapabilities Attribute map in rfc5751.py
|
| 51 |
+
|
| 52 |
+
_smimeCapabilityMapUpdate = {
|
| 53 |
+
id_kEAKeyEncryptionAlgorithm: rfc5280.AlgorithmIdentifier(),
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
rfc5751.smimeCapabilityMap.update(_smimeCapabilityMapUpdate)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3114.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
# TEST Company Classification Policies
|
| 10 |
+
#
|
| 11 |
+
# ASN.1 source from:
|
| 12 |
+
# https://www.rfc-editor.org/rfc/rfc3114.txt
|
| 13 |
+
#
|
| 14 |
+
|
| 15 |
+
from pyasn1.type import char
|
| 16 |
+
from pyasn1.type import namedval
|
| 17 |
+
from pyasn1.type import univ
|
| 18 |
+
|
| 19 |
+
from pyasn1_modules import rfc5755
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
id_smime = univ.ObjectIdentifier((1, 2, 840, 113549, 1, 9, 16, ))
|
| 23 |
+
|
| 24 |
+
id_tsp = id_smime + (7, )
|
| 25 |
+
|
| 26 |
+
id_tsp_TEST_Amoco = id_tsp + (1, )
|
| 27 |
+
|
| 28 |
+
class Amoco_SecurityClassification(univ.Integer):
|
| 29 |
+
namedValues = namedval.NamedValues(
|
| 30 |
+
('amoco-general', 6),
|
| 31 |
+
('amoco-confidential', 7),
|
| 32 |
+
('amoco-highly-confidential', 8)
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
id_tsp_TEST_Caterpillar = id_tsp + (2, )
|
| 37 |
+
|
| 38 |
+
class Caterpillar_SecurityClassification(univ.Integer):
|
| 39 |
+
namedValues = namedval.NamedValues(
|
| 40 |
+
('caterpillar-public', 6),
|
| 41 |
+
('caterpillar-green', 7),
|
| 42 |
+
('caterpillar-yellow', 8),
|
| 43 |
+
('caterpillar-red', 9)
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
id_tsp_TEST_Whirlpool = id_tsp + (3, )
|
| 48 |
+
|
| 49 |
+
class Whirlpool_SecurityClassification(univ.Integer):
|
| 50 |
+
namedValues = namedval.NamedValues(
|
| 51 |
+
('whirlpool-public', 6),
|
| 52 |
+
('whirlpool-internal', 7),
|
| 53 |
+
('whirlpool-confidential', 8)
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
id_tsp_TEST_Whirlpool_Categories = id_tsp + (4, )
|
| 58 |
+
|
| 59 |
+
class SecurityCategoryValues(univ.SequenceOf):
|
| 60 |
+
componentType = char.UTF8String()
|
| 61 |
+
|
| 62 |
+
# Example SecurityCategoryValues: "LAW DEPARTMENT USE ONLY"
|
| 63 |
+
# Example SecurityCategoryValues: "HUMAN RESOURCES USE ONLY"
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
# Also, the privacy mark in the security label can contain a string,
|
| 67 |
+
# such as: "ATTORNEY-CLIENT PRIVILEGED INFORMATION"
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
# Map of security category type OIDs to security category added
|
| 71 |
+
# to the ones that are in rfc5755.py
|
| 72 |
+
|
| 73 |
+
_securityCategoryMapUpdate = {
|
| 74 |
+
id_tsp_TEST_Whirlpool_Categories: SecurityCategoryValues(),
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
rfc5755.securityCategoryMap.update(_securityCategoryMapUpdate)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3279.py
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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s.com/pyasn1/license.html
|
| 6 |
+
#
|
| 7 |
+
# Modified by Russ Housley to add maps for use with opentypes.
|
| 8 |
+
#
|
| 9 |
+
# Algorithms and Identifiers for Internet X.509 Certificates and CRLs
|
| 10 |
+
#
|
| 11 |
+
# Derived from RFC 3279:
|
| 12 |
+
# https://www.rfc-editor.org/rfc/rfc3279.txt
|
| 13 |
+
#
|
| 14 |
+
from pyasn1.type import namedtype
|
| 15 |
+
from pyasn1.type import namedval
|
| 16 |
+
from pyasn1.type import univ
|
| 17 |
+
|
| 18 |
+
from pyasn1_modules import rfc5280
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def _OID(*components):
|
| 22 |
+
output = []
|
| 23 |
+
for x in tuple(components):
|
| 24 |
+
if isinstance(x, univ.ObjectIdentifier):
|
| 25 |
+
output.extend(list(x))
|
| 26 |
+
else:
|
| 27 |
+
output.append(int(x))
|
| 28 |
+
|
| 29 |
+
return univ.ObjectIdentifier(output)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
md2 = _OID(1, 2, 840, 113549, 2, 2)
|
| 33 |
+
md5 = _OID(1, 2, 840, 113549, 2, 5)
|
| 34 |
+
id_sha1 = _OID(1, 3, 14, 3, 2, 26)
|
| 35 |
+
id_dsa = _OID(1, 2, 840, 10040, 4, 1)
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
class DSAPublicKey(univ.Integer):
|
| 39 |
+
pass
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class Dss_Parms(univ.Sequence):
|
| 43 |
+
componentType = namedtype.NamedTypes(
|
| 44 |
+
namedtype.NamedType('p', univ.Integer()),
|
| 45 |
+
namedtype.NamedType('q', univ.Integer()),
|
| 46 |
+
namedtype.NamedType('g', univ.Integer())
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
id_dsa_with_sha1 = _OID(1, 2, 840, 10040, 4, 3)
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
class Dss_Sig_Value(univ.Sequence):
|
| 54 |
+
componentType = namedtype.NamedTypes(
|
| 55 |
+
namedtype.NamedType('r', univ.Integer()),
|
| 56 |
+
namedtype.NamedType('s', univ.Integer())
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
pkcs_1 = _OID(1, 2, 840, 113549, 1, 1)
|
| 61 |
+
rsaEncryption = _OID(pkcs_1, 1)
|
| 62 |
+
md2WithRSAEncryption = _OID(pkcs_1, 2)
|
| 63 |
+
md5WithRSAEncryption = _OID(pkcs_1, 4)
|
| 64 |
+
sha1WithRSAEncryption = _OID(pkcs_1, 5)
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
class RSAPublicKey(univ.Sequence):
|
| 68 |
+
componentType = namedtype.NamedTypes(
|
| 69 |
+
namedtype.NamedType('modulus', univ.Integer()),
|
| 70 |
+
namedtype.NamedType('publicExponent', univ.Integer())
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
dhpublicnumber = _OID(1, 2, 840, 10046, 2, 1)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
class DHPublicKey(univ.Integer):
|
| 78 |
+
pass
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
class ValidationParms(univ.Sequence):
|
| 82 |
+
componentType = namedtype.NamedTypes(
|
| 83 |
+
namedtype.NamedType('seed', univ.BitString()),
|
| 84 |
+
namedtype.NamedType('pgenCounter', univ.Integer())
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
class DomainParameters(univ.Sequence):
|
| 89 |
+
componentType = namedtype.NamedTypes(
|
| 90 |
+
namedtype.NamedType('p', univ.Integer()),
|
| 91 |
+
namedtype.NamedType('g', univ.Integer()),
|
| 92 |
+
namedtype.NamedType('q', univ.Integer()),
|
| 93 |
+
namedtype.OptionalNamedType('j', univ.Integer()),
|
| 94 |
+
namedtype.OptionalNamedType('validationParms', ValidationParms())
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
id_keyExchangeAlgorithm = _OID(2, 16, 840, 1, 101, 2, 1, 1, 22)
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
class KEA_Parms_Id(univ.OctetString):
|
| 102 |
+
pass
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
ansi_X9_62 = _OID(1, 2, 840, 10045)
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
class FieldID(univ.Sequence):
|
| 109 |
+
componentType = namedtype.NamedTypes(
|
| 110 |
+
namedtype.NamedType('fieldType', univ.ObjectIdentifier()),
|
| 111 |
+
namedtype.NamedType('parameters', univ.Any())
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
id_ecSigType = _OID(ansi_X9_62, 4)
|
| 116 |
+
ecdsa_with_SHA1 = _OID(id_ecSigType, 1)
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
class ECDSA_Sig_Value(univ.Sequence):
|
| 120 |
+
componentType = namedtype.NamedTypes(
|
| 121 |
+
namedtype.NamedType('r', univ.Integer()),
|
| 122 |
+
namedtype.NamedType('s', univ.Integer())
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
id_fieldType = _OID(ansi_X9_62, 1)
|
| 127 |
+
prime_field = _OID(id_fieldType, 1)
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
class Prime_p(univ.Integer):
|
| 131 |
+
pass
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
characteristic_two_field = _OID(id_fieldType, 2)
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
class Characteristic_two(univ.Sequence):
|
| 138 |
+
componentType = namedtype.NamedTypes(
|
| 139 |
+
namedtype.NamedType('m', univ.Integer()),
|
| 140 |
+
namedtype.NamedType('basis', univ.ObjectIdentifier()),
|
| 141 |
+
namedtype.NamedType('parameters', univ.Any())
|
| 142 |
+
)
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
id_characteristic_two_basis = _OID(characteristic_two_field, 3)
|
| 146 |
+
gnBasis = _OID(id_characteristic_two_basis, 1)
|
| 147 |
+
tpBasis = _OID(id_characteristic_two_basis, 2)
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
class Trinomial(univ.Integer):
|
| 151 |
+
pass
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
ppBasis = _OID(id_characteristic_two_basis, 3)
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
class Pentanomial(univ.Sequence):
|
| 158 |
+
componentType = namedtype.NamedTypes(
|
| 159 |
+
namedtype.NamedType('k1', univ.Integer()),
|
| 160 |
+
namedtype.NamedType('k2', univ.Integer()),
|
| 161 |
+
namedtype.NamedType('k3', univ.Integer())
|
| 162 |
+
)
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
class FieldElement(univ.OctetString):
|
| 166 |
+
pass
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
class ECPoint(univ.OctetString):
|
| 170 |
+
pass
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
class Curve(univ.Sequence):
|
| 174 |
+
componentType = namedtype.NamedTypes(
|
| 175 |
+
namedtype.NamedType('a', FieldElement()),
|
| 176 |
+
namedtype.NamedType('b', FieldElement()),
|
| 177 |
+
namedtype.OptionalNamedType('seed', univ.BitString())
|
| 178 |
+
)
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
class ECPVer(univ.Integer):
|
| 182 |
+
namedValues = namedval.NamedValues(
|
| 183 |
+
('ecpVer1', 1)
|
| 184 |
+
)
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
class ECParameters(univ.Sequence):
|
| 188 |
+
componentType = namedtype.NamedTypes(
|
| 189 |
+
namedtype.NamedType('version', ECPVer()),
|
| 190 |
+
namedtype.NamedType('fieldID', FieldID()),
|
| 191 |
+
namedtype.NamedType('curve', Curve()),
|
| 192 |
+
namedtype.NamedType('base', ECPoint()),
|
| 193 |
+
namedtype.NamedType('order', univ.Integer()),
|
| 194 |
+
namedtype.OptionalNamedType('cofactor', univ.Integer())
|
| 195 |
+
)
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
class EcpkParameters(univ.Choice):
|
| 199 |
+
componentType = namedtype.NamedTypes(
|
| 200 |
+
namedtype.NamedType('ecParameters', ECParameters()),
|
| 201 |
+
namedtype.NamedType('namedCurve', univ.ObjectIdentifier()),
|
| 202 |
+
namedtype.NamedType('implicitlyCA', univ.Null())
|
| 203 |
+
)
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
id_publicKeyType = _OID(ansi_X9_62, 2)
|
| 207 |
+
id_ecPublicKey = _OID(id_publicKeyType, 1)
|
| 208 |
+
|
| 209 |
+
ellipticCurve = _OID(ansi_X9_62, 3)
|
| 210 |
+
|
| 211 |
+
c_TwoCurve = _OID(ellipticCurve, 0)
|
| 212 |
+
c2pnb163v1 = _OID(c_TwoCurve, 1)
|
| 213 |
+
c2pnb163v2 = _OID(c_TwoCurve, 2)
|
| 214 |
+
c2pnb163v3 = _OID(c_TwoCurve, 3)
|
| 215 |
+
c2pnb176w1 = _OID(c_TwoCurve, 4)
|
| 216 |
+
c2tnb191v1 = _OID(c_TwoCurve, 5)
|
| 217 |
+
c2tnb191v2 = _OID(c_TwoCurve, 6)
|
| 218 |
+
c2tnb191v3 = _OID(c_TwoCurve, 7)
|
| 219 |
+
c2onb191v4 = _OID(c_TwoCurve, 8)
|
| 220 |
+
c2onb191v5 = _OID(c_TwoCurve, 9)
|
| 221 |
+
c2pnb208w1 = _OID(c_TwoCurve, 10)
|
| 222 |
+
c2tnb239v1 = _OID(c_TwoCurve, 11)
|
| 223 |
+
c2tnb239v2 = _OID(c_TwoCurve, 12)
|
| 224 |
+
c2tnb239v3 = _OID(c_TwoCurve, 13)
|
| 225 |
+
c2onb239v4 = _OID(c_TwoCurve, 14)
|
| 226 |
+
c2onb239v5 = _OID(c_TwoCurve, 15)
|
| 227 |
+
c2pnb272w1 = _OID(c_TwoCurve, 16)
|
| 228 |
+
c2pnb304w1 = _OID(c_TwoCurve, 17)
|
| 229 |
+
c2tnb359v1 = _OID(c_TwoCurve, 18)
|
| 230 |
+
c2pnb368w1 = _OID(c_TwoCurve, 19)
|
| 231 |
+
c2tnb431r1 = _OID(c_TwoCurve, 20)
|
| 232 |
+
|
| 233 |
+
primeCurve = _OID(ellipticCurve, 1)
|
| 234 |
+
prime192v1 = _OID(primeCurve, 1)
|
| 235 |
+
prime192v2 = _OID(primeCurve, 2)
|
| 236 |
+
prime192v3 = _OID(primeCurve, 3)
|
| 237 |
+
prime239v1 = _OID(primeCurve, 4)
|
| 238 |
+
prime239v2 = _OID(primeCurve, 5)
|
| 239 |
+
prime239v3 = _OID(primeCurve, 6)
|
| 240 |
+
prime256v1 = _OID(primeCurve, 7)
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
# Map of Algorithm Identifier OIDs to Parameters added to the
|
| 244 |
+
# ones in rfc5280.py. Do not add OIDs with absent paramaters.
|
| 245 |
+
|
| 246 |
+
_algorithmIdentifierMapUpdate = {
|
| 247 |
+
md2: univ.Null(""),
|
| 248 |
+
md5: univ.Null(""),
|
| 249 |
+
id_sha1: univ.Null(""),
|
| 250 |
+
id_dsa: Dss_Parms(),
|
| 251 |
+
rsaEncryption: univ.Null(""),
|
| 252 |
+
md2WithRSAEncryption: univ.Null(""),
|
| 253 |
+
md5WithRSAEncryption: univ.Null(""),
|
| 254 |
+
sha1WithRSAEncryption: univ.Null(""),
|
| 255 |
+
dhpublicnumber: DomainParameters(),
|
| 256 |
+
id_keyExchangeAlgorithm: KEA_Parms_Id(),
|
| 257 |
+
id_ecPublicKey: EcpkParameters(),
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3280.py
ADDED
|
@@ -0,0 +1,1543 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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asn1-modules software.
|
| 4 |
+
#
|
| 5 |
+
# Created by Stanisław Pitucha with asn1ate tool.
|
| 6 |
+
# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
|
| 7 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 8 |
+
#
|
| 9 |
+
# Internet X.509 Public Key Infrastructure Certificate and Certificate
|
| 10 |
+
# Revocation List (CRL) Profile
|
| 11 |
+
#
|
| 12 |
+
# ASN.1 source from:
|
| 13 |
+
# http://www.ietf.org/rfc/rfc3280.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.type import useful
|
| 22 |
+
|
| 23 |
+
MAX = float('inf')
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def _OID(*components):
|
| 27 |
+
output = []
|
| 28 |
+
for x in tuple(components):
|
| 29 |
+
if isinstance(x, univ.ObjectIdentifier):
|
| 30 |
+
output.extend(list(x))
|
| 31 |
+
else:
|
| 32 |
+
output.append(int(x))
|
| 33 |
+
|
| 34 |
+
return univ.ObjectIdentifier(output)
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
unformatted_postal_address = univ.Integer(16)
|
| 38 |
+
|
| 39 |
+
ub_organizational_units = univ.Integer(4)
|
| 40 |
+
|
| 41 |
+
ub_organizational_unit_name_length = univ.Integer(32)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class OrganizationalUnitName(char.PrintableString):
|
| 45 |
+
pass
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
OrganizationalUnitName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organizational_unit_name_length)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
class OrganizationalUnitNames(univ.SequenceOf):
|
| 52 |
+
pass
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
OrganizationalUnitNames.componentType = OrganizationalUnitName()
|
| 56 |
+
OrganizationalUnitNames.sizeSpec = constraint.ValueSizeConstraint(1, ub_organizational_units)
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
class AttributeType(univ.ObjectIdentifier):
|
| 60 |
+
pass
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
id_at = _OID(2, 5, 4)
|
| 64 |
+
|
| 65 |
+
id_at_name = _OID(id_at, 41)
|
| 66 |
+
|
| 67 |
+
ub_pds_parameter_length = univ.Integer(30)
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
class PDSParameter(univ.Set):
|
| 71 |
+
pass
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
PDSParameter.componentType = namedtype.NamedTypes(
|
| 75 |
+
namedtype.OptionalNamedType('printable-string', char.PrintableString().subtype(
|
| 76 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length))),
|
| 77 |
+
namedtype.OptionalNamedType('teletex-string', char.TeletexString().subtype(
|
| 78 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length)))
|
| 79 |
+
)
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
class PhysicalDeliveryOrganizationName(PDSParameter):
|
| 83 |
+
pass
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
ub_organization_name_length = univ.Integer(64)
|
| 87 |
+
|
| 88 |
+
ub_domain_defined_attribute_type_length = univ.Integer(8)
|
| 89 |
+
|
| 90 |
+
ub_domain_defined_attribute_value_length = univ.Integer(128)
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
class TeletexDomainDefinedAttribute(univ.Sequence):
|
| 94 |
+
pass
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
TeletexDomainDefinedAttribute.componentType = namedtype.NamedTypes(
|
| 98 |
+
namedtype.NamedType('type', char.TeletexString().subtype(
|
| 99 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_type_length))),
|
| 100 |
+
namedtype.NamedType('value', char.TeletexString().subtype(
|
| 101 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_value_length)))
|
| 102 |
+
)
|
| 103 |
+
|
| 104 |
+
id_pkix = _OID(1, 3, 6, 1, 5, 5, 7)
|
| 105 |
+
|
| 106 |
+
id_qt = _OID(id_pkix, 2)
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
class PresentationAddress(univ.Sequence):
|
| 110 |
+
pass
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
PresentationAddress.componentType = namedtype.NamedTypes(
|
| 114 |
+
namedtype.OptionalNamedType('pSelector', univ.OctetString().subtype(
|
| 115 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 116 |
+
namedtype.OptionalNamedType('sSelector', univ.OctetString().subtype(
|
| 117 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 118 |
+
namedtype.OptionalNamedType('tSelector', univ.OctetString().subtype(
|
| 119 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
|
| 120 |
+
namedtype.NamedType('nAddresses', univ.SetOf(componentType=univ.OctetString()).subtype(
|
| 121 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
|
| 122 |
+
)
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
class AlgorithmIdentifier(univ.Sequence):
|
| 126 |
+
pass
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
AlgorithmIdentifier.componentType = namedtype.NamedTypes(
|
| 130 |
+
namedtype.NamedType('algorithm', univ.ObjectIdentifier()),
|
| 131 |
+
namedtype.OptionalNamedType('parameters', univ.Any())
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
class UniqueIdentifier(univ.BitString):
|
| 136 |
+
pass
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
class Extension(univ.Sequence):
|
| 140 |
+
pass
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
Extension.componentType = namedtype.NamedTypes(
|
| 144 |
+
namedtype.NamedType('extnID', univ.ObjectIdentifier()),
|
| 145 |
+
namedtype.DefaultedNamedType('critical', univ.Boolean().subtype(value=0)),
|
| 146 |
+
namedtype.NamedType('extnValue', univ.OctetString())
|
| 147 |
+
)
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
class Extensions(univ.SequenceOf):
|
| 151 |
+
pass
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
Extensions.componentType = Extension()
|
| 155 |
+
Extensions.sizeSpec = constraint.ValueSizeConstraint(1, MAX)
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
class CertificateSerialNumber(univ.Integer):
|
| 159 |
+
pass
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
class SubjectPublicKeyInfo(univ.Sequence):
|
| 163 |
+
pass
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
SubjectPublicKeyInfo.componentType = namedtype.NamedTypes(
|
| 167 |
+
namedtype.NamedType('algorithm', AlgorithmIdentifier()),
|
| 168 |
+
namedtype.NamedType('subjectPublicKey', univ.BitString())
|
| 169 |
+
)
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
class Time(univ.Choice):
|
| 173 |
+
pass
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
Time.componentType = namedtype.NamedTypes(
|
| 177 |
+
namedtype.NamedType('utcTime', useful.UTCTime()),
|
| 178 |
+
namedtype.NamedType('generalTime', useful.GeneralizedTime())
|
| 179 |
+
)
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
class Validity(univ.Sequence):
|
| 183 |
+
pass
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
Validity.componentType = namedtype.NamedTypes(
|
| 187 |
+
namedtype.NamedType('notBefore', Time()),
|
| 188 |
+
namedtype.NamedType('notAfter', Time())
|
| 189 |
+
)
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
class Version(univ.Integer):
|
| 193 |
+
pass
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
Version.namedValues = namedval.NamedValues(
|
| 197 |
+
('v1', 0),
|
| 198 |
+
('v2', 1),
|
| 199 |
+
('v3', 2)
|
| 200 |
+
)
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
class AttributeValue(univ.Any):
|
| 204 |
+
pass
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
class AttributeTypeAndValue(univ.Sequence):
|
| 208 |
+
pass
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
AttributeTypeAndValue.componentType = namedtype.NamedTypes(
|
| 212 |
+
namedtype.NamedType('type', AttributeType()),
|
| 213 |
+
namedtype.NamedType('value', AttributeValue())
|
| 214 |
+
)
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
class RelativeDistinguishedName(univ.SetOf):
|
| 218 |
+
pass
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
RelativeDistinguishedName.componentType = AttributeTypeAndValue()
|
| 222 |
+
RelativeDistinguishedName.sizeSpec = constraint.ValueSizeConstraint(1, MAX)
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
class RDNSequence(univ.SequenceOf):
|
| 226 |
+
pass
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
RDNSequence.componentType = RelativeDistinguishedName()
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
class Name(univ.Choice):
|
| 233 |
+
pass
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
Name.componentType = namedtype.NamedTypes(
|
| 237 |
+
namedtype.NamedType('rdnSequence', RDNSequence())
|
| 238 |
+
)
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
class TBSCertificate(univ.Sequence):
|
| 242 |
+
pass
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
TBSCertificate.componentType = namedtype.NamedTypes(
|
| 246 |
+
namedtype.DefaultedNamedType('version',
|
| 247 |
+
Version().subtype(explicitTag=tag.Tag(tag.tagClassContext,
|
| 248 |
+
tag.tagFormatSimple, 0)).subtype(value="v1")),
|
| 249 |
+
namedtype.NamedType('serialNumber', CertificateSerialNumber()),
|
| 250 |
+
namedtype.NamedType('signature', AlgorithmIdentifier()),
|
| 251 |
+
namedtype.NamedType('issuer', Name()),
|
| 252 |
+
namedtype.NamedType('validity', Validity()),
|
| 253 |
+
namedtype.NamedType('subject', Name()),
|
| 254 |
+
namedtype.NamedType('subjectPublicKeyInfo', SubjectPublicKeyInfo()),
|
| 255 |
+
namedtype.OptionalNamedType('issuerUniqueID', UniqueIdentifier().subtype(
|
| 256 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 257 |
+
namedtype.OptionalNamedType('subjectUniqueID', UniqueIdentifier().subtype(
|
| 258 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
|
| 259 |
+
namedtype.OptionalNamedType('extensions',
|
| 260 |
+
Extensions().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
|
| 261 |
+
)
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
class Certificate(univ.Sequence):
|
| 265 |
+
pass
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
Certificate.componentType = namedtype.NamedTypes(
|
| 269 |
+
namedtype.NamedType('tbsCertificate', TBSCertificate()),
|
| 270 |
+
namedtype.NamedType('signatureAlgorithm', AlgorithmIdentifier()),
|
| 271 |
+
namedtype.NamedType('signature', univ.BitString())
|
| 272 |
+
)
|
| 273 |
+
|
| 274 |
+
ub_surname_length = univ.Integer(40)
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
class TeletexOrganizationName(char.TeletexString):
|
| 278 |
+
pass
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
TeletexOrganizationName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organization_name_length)
|
| 282 |
+
|
| 283 |
+
ub_e163_4_sub_address_length = univ.Integer(40)
|
| 284 |
+
|
| 285 |
+
teletex_common_name = univ.Integer(2)
|
| 286 |
+
|
| 287 |
+
ub_country_name_alpha_length = univ.Integer(2)
|
| 288 |
+
|
| 289 |
+
ub_country_name_numeric_length = univ.Integer(3)
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
class CountryName(univ.Choice):
|
| 293 |
+
pass
|
| 294 |
+
|
| 295 |
+
|
| 296 |
+
CountryName.tagSet = univ.Choice.tagSet.tagExplicitly(tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 1))
|
| 297 |
+
CountryName.componentType = namedtype.NamedTypes(
|
| 298 |
+
namedtype.NamedType('x121-dcc-code', char.NumericString().subtype(
|
| 299 |
+
subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_numeric_length, ub_country_name_numeric_length))),
|
| 300 |
+
namedtype.NamedType('iso-3166-alpha2-code', char.PrintableString().subtype(
|
| 301 |
+
subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_alpha_length, ub_country_name_alpha_length)))
|
| 302 |
+
)
|
| 303 |
+
|
| 304 |
+
extension_OR_address_components = univ.Integer(12)
|
| 305 |
+
|
| 306 |
+
id_at_dnQualifier = _OID(id_at, 46)
|
| 307 |
+
|
| 308 |
+
ub_e163_4_number_length = univ.Integer(15)
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
class ExtendedNetworkAddress(univ.Choice):
|
| 312 |
+
pass
|
| 313 |
+
|
| 314 |
+
|
| 315 |
+
ExtendedNetworkAddress.componentType = namedtype.NamedTypes(
|
| 316 |
+
namedtype.NamedType('e163-4-address', univ.Sequence(componentType=namedtype.NamedTypes(
|
| 317 |
+
namedtype.NamedType('number', char.NumericString().subtype(
|
| 318 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_e163_4_number_length)).subtype(
|
| 319 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 320 |
+
namedtype.OptionalNamedType('sub-address', char.NumericString().subtype(
|
| 321 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_e163_4_sub_address_length)).subtype(
|
| 322 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 323 |
+
))
|
| 324 |
+
),
|
| 325 |
+
namedtype.NamedType('psap-address', PresentationAddress().subtype(
|
| 326 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))
|
| 327 |
+
)
|
| 328 |
+
|
| 329 |
+
terminal_type = univ.Integer(23)
|
| 330 |
+
|
| 331 |
+
id_domainComponent = _OID(0, 9, 2342, 19200300, 100, 1, 25)
|
| 332 |
+
|
| 333 |
+
ub_state_name = univ.Integer(128)
|
| 334 |
+
|
| 335 |
+
|
| 336 |
+
class X520StateOrProvinceName(univ.Choice):
|
| 337 |
+
pass
|
| 338 |
+
|
| 339 |
+
|
| 340 |
+
X520StateOrProvinceName.componentType = namedtype.NamedTypes(
|
| 341 |
+
namedtype.NamedType('teletexString',
|
| 342 |
+
char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),
|
| 343 |
+
namedtype.NamedType('printableString',
|
| 344 |
+
char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),
|
| 345 |
+
namedtype.NamedType('universalString',
|
| 346 |
+
char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),
|
| 347 |
+
namedtype.NamedType('utf8String',
|
| 348 |
+
char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),
|
| 349 |
+
namedtype.NamedType('bmpString',
|
| 350 |
+
char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name)))
|
| 351 |
+
)
|
| 352 |
+
|
| 353 |
+
ub_organization_name = univ.Integer(64)
|
| 354 |
+
|
| 355 |
+
|
| 356 |
+
class X520OrganizationName(univ.Choice):
|
| 357 |
+
pass
|
| 358 |
+
|
| 359 |
+
|
| 360 |
+
X520OrganizationName.componentType = namedtype.NamedTypes(
|
| 361 |
+
namedtype.NamedType('teletexString', char.TeletexString().subtype(
|
| 362 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
|
| 363 |
+
namedtype.NamedType('printableString', char.PrintableString().subtype(
|
| 364 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
|
| 365 |
+
namedtype.NamedType('universalString', char.UniversalString().subtype(
|
| 366 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
|
| 367 |
+
namedtype.NamedType('utf8String',
|
| 368 |
+
char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
|
| 369 |
+
namedtype.NamedType('bmpString',
|
| 370 |
+
char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name)))
|
| 371 |
+
)
|
| 372 |
+
|
| 373 |
+
ub_emailaddress_length = univ.Integer(128)
|
| 374 |
+
|
| 375 |
+
|
| 376 |
+
class ExtensionPhysicalDeliveryAddressComponents(PDSParameter):
|
| 377 |
+
pass
|
| 378 |
+
|
| 379 |
+
|
| 380 |
+
id_at_surname = _OID(id_at, 4)
|
| 381 |
+
|
| 382 |
+
ub_common_name_length = univ.Integer(64)
|
| 383 |
+
|
| 384 |
+
id_ad = _OID(id_pkix, 48)
|
| 385 |
+
|
| 386 |
+
ub_numeric_user_id_length = univ.Integer(32)
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
class NumericUserIdentifier(char.NumericString):
|
| 390 |
+
pass
|
| 391 |
+
|
| 392 |
+
|
| 393 |
+
NumericUserIdentifier.subtypeSpec = constraint.ValueSizeConstraint(1, ub_numeric_user_id_length)
|
| 394 |
+
|
| 395 |
+
|
| 396 |
+
class OrganizationName(char.PrintableString):
|
| 397 |
+
pass
|
| 398 |
+
|
| 399 |
+
|
| 400 |
+
OrganizationName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organization_name_length)
|
| 401 |
+
|
| 402 |
+
ub_domain_name_length = univ.Integer(16)
|
| 403 |
+
|
| 404 |
+
|
| 405 |
+
class AdministrationDomainName(univ.Choice):
|
| 406 |
+
pass
|
| 407 |
+
|
| 408 |
+
|
| 409 |
+
AdministrationDomainName.tagSet = univ.Choice.tagSet.tagExplicitly(
|
| 410 |
+
tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 2))
|
| 411 |
+
AdministrationDomainName.componentType = namedtype.NamedTypes(
|
| 412 |
+
namedtype.NamedType('numeric', char.NumericString().subtype(
|
| 413 |
+
subtypeSpec=constraint.ValueSizeConstraint(0, ub_domain_name_length))),
|
| 414 |
+
namedtype.NamedType('printable', char.PrintableString().subtype(
|
| 415 |
+
subtypeSpec=constraint.ValueSizeConstraint(0, ub_domain_name_length)))
|
| 416 |
+
)
|
| 417 |
+
|
| 418 |
+
|
| 419 |
+
class PrivateDomainName(univ.Choice):
|
| 420 |
+
pass
|
| 421 |
+
|
| 422 |
+
|
| 423 |
+
PrivateDomainName.componentType = namedtype.NamedTypes(
|
| 424 |
+
namedtype.NamedType('numeric', char.NumericString().subtype(
|
| 425 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_name_length))),
|
| 426 |
+
namedtype.NamedType('printable', char.PrintableString().subtype(
|
| 427 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_name_length)))
|
| 428 |
+
)
|
| 429 |
+
|
| 430 |
+
ub_generation_qualifier_length = univ.Integer(3)
|
| 431 |
+
|
| 432 |
+
ub_given_name_length = univ.Integer(16)
|
| 433 |
+
|
| 434 |
+
ub_initials_length = univ.Integer(5)
|
| 435 |
+
|
| 436 |
+
|
| 437 |
+
class PersonalName(univ.Set):
|
| 438 |
+
pass
|
| 439 |
+
|
| 440 |
+
|
| 441 |
+
PersonalName.componentType = namedtype.NamedTypes(
|
| 442 |
+
namedtype.NamedType('surname', char.PrintableString().subtype(
|
| 443 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_surname_length)).subtype(
|
| 444 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 445 |
+
namedtype.OptionalNamedType('given-name', char.PrintableString().subtype(
|
| 446 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_given_name_length)).subtype(
|
| 447 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 448 |
+
namedtype.OptionalNamedType('initials', char.PrintableString().subtype(
|
| 449 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_initials_length)).subtype(
|
| 450 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
|
| 451 |
+
namedtype.OptionalNamedType('generation-qualifier', char.PrintableString().subtype(
|
| 452 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_generation_qualifier_length)).subtype(
|
| 453 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
|
| 454 |
+
)
|
| 455 |
+
|
| 456 |
+
ub_terminal_id_length = univ.Integer(24)
|
| 457 |
+
|
| 458 |
+
|
| 459 |
+
class TerminalIdentifier(char.PrintableString):
|
| 460 |
+
pass
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
TerminalIdentifier.subtypeSpec = constraint.ValueSizeConstraint(1, ub_terminal_id_length)
|
| 464 |
+
|
| 465 |
+
ub_x121_address_length = univ.Integer(16)
|
| 466 |
+
|
| 467 |
+
|
| 468 |
+
class X121Address(char.NumericString):
|
| 469 |
+
pass
|
| 470 |
+
|
| 471 |
+
|
| 472 |
+
X121Address.subtypeSpec = constraint.ValueSizeConstraint(1, ub_x121_address_length)
|
| 473 |
+
|
| 474 |
+
|
| 475 |
+
class NetworkAddress(X121Address):
|
| 476 |
+
pass
|
| 477 |
+
|
| 478 |
+
|
| 479 |
+
class BuiltInStandardAttributes(univ.Sequence):
|
| 480 |
+
pass
|
| 481 |
+
|
| 482 |
+
|
| 483 |
+
BuiltInStandardAttributes.componentType = namedtype.NamedTypes(
|
| 484 |
+
namedtype.OptionalNamedType('country-name', CountryName()),
|
| 485 |
+
namedtype.OptionalNamedType('administration-domain-name', AdministrationDomainName()),
|
| 486 |
+
namedtype.OptionalNamedType('network-address', NetworkAddress().subtype(
|
| 487 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 488 |
+
namedtype.OptionalNamedType('terminal-identifier', TerminalIdentifier().subtype(
|
| 489 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 490 |
+
namedtype.OptionalNamedType('private-domain-name', PrivateDomainName().subtype(
|
| 491 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2))),
|
| 492 |
+
namedtype.OptionalNamedType('organization-name', OrganizationName().subtype(
|
| 493 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
|
| 494 |
+
namedtype.OptionalNamedType('numeric-user-identifier', NumericUserIdentifier().subtype(
|
| 495 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))),
|
| 496 |
+
namedtype.OptionalNamedType('personal-name', PersonalName().subtype(
|
| 497 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 5))),
|
| 498 |
+
namedtype.OptionalNamedType('organizational-unit-names', OrganizationalUnitNames().subtype(
|
| 499 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6)))
|
| 500 |
+
)
|
| 501 |
+
|
| 502 |
+
ub_domain_defined_attributes = univ.Integer(4)
|
| 503 |
+
|
| 504 |
+
|
| 505 |
+
class BuiltInDomainDefinedAttribute(univ.Sequence):
|
| 506 |
+
pass
|
| 507 |
+
|
| 508 |
+
|
| 509 |
+
BuiltInDomainDefinedAttribute.componentType = namedtype.NamedTypes(
|
| 510 |
+
namedtype.NamedType('type', char.PrintableString().subtype(
|
| 511 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_type_length))),
|
| 512 |
+
namedtype.NamedType('value', char.PrintableString().subtype(
|
| 513 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_value_length)))
|
| 514 |
+
)
|
| 515 |
+
|
| 516 |
+
|
| 517 |
+
class BuiltInDomainDefinedAttributes(univ.SequenceOf):
|
| 518 |
+
pass
|
| 519 |
+
|
| 520 |
+
|
| 521 |
+
BuiltInDomainDefinedAttributes.componentType = BuiltInDomainDefinedAttribute()
|
| 522 |
+
BuiltInDomainDefinedAttributes.sizeSpec = constraint.ValueSizeConstraint(1, ub_domain_defined_attributes)
|
| 523 |
+
|
| 524 |
+
ub_extension_attributes = univ.Integer(256)
|
| 525 |
+
|
| 526 |
+
|
| 527 |
+
class ExtensionAttribute(univ.Sequence):
|
| 528 |
+
pass
|
| 529 |
+
|
| 530 |
+
|
| 531 |
+
ExtensionAttribute.componentType = namedtype.NamedTypes(
|
| 532 |
+
namedtype.NamedType('extension-attribute-type', univ.Integer().subtype(
|
| 533 |
+
subtypeSpec=constraint.ValueRangeConstraint(0, ub_extension_attributes)).subtype(
|
| 534 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 535 |
+
namedtype.NamedType('extension-attribute-value',
|
| 536 |
+
univ.Any().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 537 |
+
)
|
| 538 |
+
|
| 539 |
+
|
| 540 |
+
class ExtensionAttributes(univ.SetOf):
|
| 541 |
+
pass
|
| 542 |
+
|
| 543 |
+
|
| 544 |
+
ExtensionAttributes.componentType = ExtensionAttribute()
|
| 545 |
+
ExtensionAttributes.sizeSpec = constraint.ValueSizeConstraint(1, ub_extension_attributes)
|
| 546 |
+
|
| 547 |
+
|
| 548 |
+
class ORAddress(univ.Sequence):
|
| 549 |
+
pass
|
| 550 |
+
|
| 551 |
+
|
| 552 |
+
ORAddress.componentType = namedtype.NamedTypes(
|
| 553 |
+
namedtype.NamedType('built-in-standard-attributes', BuiltInStandardAttributes()),
|
| 554 |
+
namedtype.OptionalNamedType('built-in-domain-defined-attributes', BuiltInDomainDefinedAttributes()),
|
| 555 |
+
namedtype.OptionalNamedType('extension-attributes', ExtensionAttributes())
|
| 556 |
+
)
|
| 557 |
+
|
| 558 |
+
id_pe = _OID(id_pkix, 1)
|
| 559 |
+
|
| 560 |
+
ub_title = univ.Integer(64)
|
| 561 |
+
|
| 562 |
+
|
| 563 |
+
class X520Title(univ.Choice):
|
| 564 |
+
pass
|
| 565 |
+
|
| 566 |
+
|
| 567 |
+
X520Title.componentType = namedtype.NamedTypes(
|
| 568 |
+
namedtype.NamedType('teletexString',
|
| 569 |
+
char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),
|
| 570 |
+
namedtype.NamedType('printableString',
|
| 571 |
+
char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),
|
| 572 |
+
namedtype.NamedType('universalString',
|
| 573 |
+
char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),
|
| 574 |
+
namedtype.NamedType('utf8String',
|
| 575 |
+
char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),
|
| 576 |
+
namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title)))
|
| 577 |
+
)
|
| 578 |
+
|
| 579 |
+
id_at_organizationalUnitName = _OID(id_at, 11)
|
| 580 |
+
|
| 581 |
+
|
| 582 |
+
class EmailAddress(char.IA5String):
|
| 583 |
+
pass
|
| 584 |
+
|
| 585 |
+
|
| 586 |
+
EmailAddress.subtypeSpec = constraint.ValueSizeConstraint(1, ub_emailaddress_length)
|
| 587 |
+
|
| 588 |
+
physical_delivery_country_name = univ.Integer(8)
|
| 589 |
+
|
| 590 |
+
id_at_givenName = _OID(id_at, 42)
|
| 591 |
+
|
| 592 |
+
|
| 593 |
+
class TeletexCommonName(char.TeletexString):
|
| 594 |
+
pass
|
| 595 |
+
|
| 596 |
+
|
| 597 |
+
TeletexCommonName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_common_name_length)
|
| 598 |
+
|
| 599 |
+
id_qt_cps = _OID(id_qt, 1)
|
| 600 |
+
|
| 601 |
+
|
| 602 |
+
class LocalPostalAttributes(PDSParameter):
|
| 603 |
+
pass
|
| 604 |
+
|
| 605 |
+
|
| 606 |
+
class StreetAddress(PDSParameter):
|
| 607 |
+
pass
|
| 608 |
+
|
| 609 |
+
|
| 610 |
+
id_kp = _OID(id_pkix, 3)
|
| 611 |
+
|
| 612 |
+
|
| 613 |
+
class DirectoryString(univ.Choice):
|
| 614 |
+
pass
|
| 615 |
+
|
| 616 |
+
|
| 617 |
+
DirectoryString.componentType = namedtype.NamedTypes(
|
| 618 |
+
namedtype.NamedType('teletexString',
|
| 619 |
+
char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
|
| 620 |
+
namedtype.NamedType('printableString',
|
| 621 |
+
char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
|
| 622 |
+
namedtype.NamedType('universalString',
|
| 623 |
+
char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
|
| 624 |
+
namedtype.NamedType('utf8String', char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
|
| 625 |
+
namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX)))
|
| 626 |
+
)
|
| 627 |
+
|
| 628 |
+
|
| 629 |
+
class DomainComponent(char.IA5String):
|
| 630 |
+
pass
|
| 631 |
+
|
| 632 |
+
|
| 633 |
+
id_at_initials = _OID(id_at, 43)
|
| 634 |
+
|
| 635 |
+
id_qt_unotice = _OID(id_qt, 2)
|
| 636 |
+
|
| 637 |
+
ub_pds_name_length = univ.Integer(16)
|
| 638 |
+
|
| 639 |
+
|
| 640 |
+
class PDSName(char.PrintableString):
|
| 641 |
+
pass
|
| 642 |
+
|
| 643 |
+
|
| 644 |
+
PDSName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_pds_name_length)
|
| 645 |
+
|
| 646 |
+
|
| 647 |
+
class PosteRestanteAddress(PDSParameter):
|
| 648 |
+
pass
|
| 649 |
+
|
| 650 |
+
|
| 651 |
+
class DistinguishedName(RDNSequence):
|
| 652 |
+
pass
|
| 653 |
+
|
| 654 |
+
|
| 655 |
+
class CommonName(char.PrintableString):
|
| 656 |
+
pass
|
| 657 |
+
|
| 658 |
+
|
| 659 |
+
CommonName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_common_name_length)
|
| 660 |
+
|
| 661 |
+
ub_serial_number = univ.Integer(64)
|
| 662 |
+
|
| 663 |
+
|
| 664 |
+
class X520SerialNumber(char.PrintableString):
|
| 665 |
+
pass
|
| 666 |
+
|
| 667 |
+
|
| 668 |
+
X520SerialNumber.subtypeSpec = constraint.ValueSizeConstraint(1, ub_serial_number)
|
| 669 |
+
|
| 670 |
+
id_at_generationQualifier = _OID(id_at, 44)
|
| 671 |
+
|
| 672 |
+
ub_organizational_unit_name = univ.Integer(64)
|
| 673 |
+
|
| 674 |
+
id_ad_ocsp = _OID(id_ad, 1)
|
| 675 |
+
|
| 676 |
+
|
| 677 |
+
class TeletexOrganizationalUnitName(char.TeletexString):
|
| 678 |
+
pass
|
| 679 |
+
|
| 680 |
+
|
| 681 |
+
TeletexOrganizationalUnitName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organizational_unit_name_length)
|
| 682 |
+
|
| 683 |
+
|
| 684 |
+
class TeletexPersonalName(univ.Set):
|
| 685 |
+
pass
|
| 686 |
+
|
| 687 |
+
|
| 688 |
+
TeletexPersonalName.componentType = namedtype.NamedTypes(
|
| 689 |
+
namedtype.NamedType('surname', char.TeletexString().subtype(
|
| 690 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_surname_length)).subtype(
|
| 691 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 692 |
+
namedtype.OptionalNamedType('given-name', char.TeletexString().subtype(
|
| 693 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_given_name_length)).subtype(
|
| 694 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 695 |
+
namedtype.OptionalNamedType('initials', char.TeletexString().subtype(
|
| 696 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_initials_length)).subtype(
|
| 697 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
|
| 698 |
+
namedtype.OptionalNamedType('generation-qualifier', char.TeletexString().subtype(
|
| 699 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_generation_qualifier_length)).subtype(
|
| 700 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
|
| 701 |
+
)
|
| 702 |
+
|
| 703 |
+
|
| 704 |
+
class TeletexDomainDefinedAttributes(univ.SequenceOf):
|
| 705 |
+
pass
|
| 706 |
+
|
| 707 |
+
|
| 708 |
+
TeletexDomainDefinedAttributes.componentType = TeletexDomainDefinedAttribute()
|
| 709 |
+
TeletexDomainDefinedAttributes.sizeSpec = constraint.ValueSizeConstraint(1, ub_domain_defined_attributes)
|
| 710 |
+
|
| 711 |
+
|
| 712 |
+
class TBSCertList(univ.Sequence):
|
| 713 |
+
pass
|
| 714 |
+
|
| 715 |
+
|
| 716 |
+
TBSCertList.componentType = namedtype.NamedTypes(
|
| 717 |
+
namedtype.OptionalNamedType('version', Version()),
|
| 718 |
+
namedtype.NamedType('signature', AlgorithmIdentifier()),
|
| 719 |
+
namedtype.NamedType('issuer', Name()),
|
| 720 |
+
namedtype.NamedType('thisUpdate', Time()),
|
| 721 |
+
namedtype.OptionalNamedType('nextUpdate', Time()),
|
| 722 |
+
namedtype.OptionalNamedType('revokedCertificates',
|
| 723 |
+
univ.SequenceOf(componentType=univ.Sequence(componentType=namedtype.NamedTypes(
|
| 724 |
+
namedtype.NamedType('userCertificate', CertificateSerialNumber()),
|
| 725 |
+
namedtype.NamedType('revocationDate', Time()),
|
| 726 |
+
namedtype.OptionalNamedType('crlEntryExtensions', Extensions())
|
| 727 |
+
))
|
| 728 |
+
)),
|
| 729 |
+
namedtype.OptionalNamedType('crlExtensions',
|
| 730 |
+
Extensions().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
|
| 731 |
+
)
|
| 732 |
+
|
| 733 |
+
local_postal_attributes = univ.Integer(21)
|
| 734 |
+
|
| 735 |
+
pkcs_9 = _OID(1, 2, 840, 113549, 1, 9)
|
| 736 |
+
|
| 737 |
+
|
| 738 |
+
class PhysicalDeliveryCountryName(univ.Choice):
|
| 739 |
+
pass
|
| 740 |
+
|
| 741 |
+
|
| 742 |
+
PhysicalDeliveryCountryName.componentType = namedtype.NamedTypes(
|
| 743 |
+
namedtype.NamedType('x121-dcc-code', char.NumericString().subtype(
|
| 744 |
+
subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_numeric_length, ub_country_name_numeric_length))),
|
| 745 |
+
namedtype.NamedType('iso-3166-alpha2-code', char.PrintableString().subtype(
|
| 746 |
+
subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_alpha_length, ub_country_name_alpha_length)))
|
| 747 |
+
)
|
| 748 |
+
|
| 749 |
+
ub_name = univ.Integer(32768)
|
| 750 |
+
|
| 751 |
+
|
| 752 |
+
class X520name(univ.Choice):
|
| 753 |
+
pass
|
| 754 |
+
|
| 755 |
+
|
| 756 |
+
X520name.componentType = namedtype.NamedTypes(
|
| 757 |
+
namedtype.NamedType('teletexString',
|
| 758 |
+
char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
|
| 759 |
+
namedtype.NamedType('printableString',
|
| 760 |
+
char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
|
| 761 |
+
namedtype.NamedType('universalString',
|
| 762 |
+
char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
|
| 763 |
+
namedtype.NamedType('utf8String',
|
| 764 |
+
char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
|
| 765 |
+
namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name)))
|
| 766 |
+
)
|
| 767 |
+
|
| 768 |
+
id_emailAddress = _OID(pkcs_9, 1)
|
| 769 |
+
|
| 770 |
+
|
| 771 |
+
class TerminalType(univ.Integer):
|
| 772 |
+
pass
|
| 773 |
+
|
| 774 |
+
|
| 775 |
+
TerminalType.namedValues = namedval.NamedValues(
|
| 776 |
+
('telex', 3),
|
| 777 |
+
('teletex', 4),
|
| 778 |
+
('g3-facsimile', 5),
|
| 779 |
+
('g4-facsimile', 6),
|
| 780 |
+
('ia5-terminal', 7),
|
| 781 |
+
('videotex', 8)
|
| 782 |
+
)
|
| 783 |
+
|
| 784 |
+
|
| 785 |
+
class X520OrganizationalUnitName(univ.Choice):
|
| 786 |
+
pass
|
| 787 |
+
|
| 788 |
+
|
| 789 |
+
X520OrganizationalUnitName.componentType = namedtype.NamedTypes(
|
| 790 |
+
namedtype.NamedType('teletexString', char.TeletexString().subtype(
|
| 791 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),
|
| 792 |
+
namedtype.NamedType('printableString', char.PrintableString().subtype(
|
| 793 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),
|
| 794 |
+
namedtype.NamedType('universalString', char.UniversalString().subtype(
|
| 795 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),
|
| 796 |
+
namedtype.NamedType('utf8String', char.UTF8String().subtype(
|
| 797 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),
|
| 798 |
+
namedtype.NamedType('bmpString', char.BMPString().subtype(
|
| 799 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name)))
|
| 800 |
+
)
|
| 801 |
+
|
| 802 |
+
id_at_commonName = _OID(id_at, 3)
|
| 803 |
+
|
| 804 |
+
pds_name = univ.Integer(7)
|
| 805 |
+
|
| 806 |
+
post_office_box_address = univ.Integer(18)
|
| 807 |
+
|
| 808 |
+
ub_locality_name = univ.Integer(128)
|
| 809 |
+
|
| 810 |
+
|
| 811 |
+
class X520LocalityName(univ.Choice):
|
| 812 |
+
pass
|
| 813 |
+
|
| 814 |
+
|
| 815 |
+
X520LocalityName.componentType = namedtype.NamedTypes(
|
| 816 |
+
namedtype.NamedType('teletexString',
|
| 817 |
+
char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),
|
| 818 |
+
namedtype.NamedType('printableString', char.PrintableString().subtype(
|
| 819 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),
|
| 820 |
+
namedtype.NamedType('universalString', char.UniversalString().subtype(
|
| 821 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),
|
| 822 |
+
namedtype.NamedType('utf8String',
|
| 823 |
+
char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),
|
| 824 |
+
namedtype.NamedType('bmpString',
|
| 825 |
+
char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name)))
|
| 826 |
+
)
|
| 827 |
+
|
| 828 |
+
id_ad_timeStamping = _OID(id_ad, 3)
|
| 829 |
+
|
| 830 |
+
id_at_countryName = _OID(id_at, 6)
|
| 831 |
+
|
| 832 |
+
physical_delivery_personal_name = univ.Integer(13)
|
| 833 |
+
|
| 834 |
+
teletex_personal_name = univ.Integer(4)
|
| 835 |
+
|
| 836 |
+
teletex_organizational_unit_names = univ.Integer(5)
|
| 837 |
+
|
| 838 |
+
|
| 839 |
+
class PhysicalDeliveryPersonalName(PDSParameter):
|
| 840 |
+
pass
|
| 841 |
+
|
| 842 |
+
|
| 843 |
+
ub_postal_code_length = univ.Integer(16)
|
| 844 |
+
|
| 845 |
+
|
| 846 |
+
class PostalCode(univ.Choice):
|
| 847 |
+
pass
|
| 848 |
+
|
| 849 |
+
|
| 850 |
+
PostalCode.componentType = namedtype.NamedTypes(
|
| 851 |
+
namedtype.NamedType('numeric-code', char.NumericString().subtype(
|
| 852 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_postal_code_length))),
|
| 853 |
+
namedtype.NamedType('printable-code', char.PrintableString().subtype(
|
| 854 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_postal_code_length)))
|
| 855 |
+
)
|
| 856 |
+
|
| 857 |
+
|
| 858 |
+
class X520countryName(char.PrintableString):
|
| 859 |
+
pass
|
| 860 |
+
|
| 861 |
+
|
| 862 |
+
X520countryName.subtypeSpec = constraint.ValueSizeConstraint(2, 2)
|
| 863 |
+
|
| 864 |
+
postal_code = univ.Integer(9)
|
| 865 |
+
|
| 866 |
+
id_ad_caRepository = _OID(id_ad, 5)
|
| 867 |
+
|
| 868 |
+
extension_physical_delivery_address_components = univ.Integer(15)
|
| 869 |
+
|
| 870 |
+
|
| 871 |
+
class PostOfficeBoxAddress(PDSParameter):
|
| 872 |
+
pass
|
| 873 |
+
|
| 874 |
+
|
| 875 |
+
class PhysicalDeliveryOfficeName(PDSParameter):
|
| 876 |
+
pass
|
| 877 |
+
|
| 878 |
+
|
| 879 |
+
id_at_title = _OID(id_at, 12)
|
| 880 |
+
|
| 881 |
+
id_at_serialNumber = _OID(id_at, 5)
|
| 882 |
+
|
| 883 |
+
id_ad_caIssuers = _OID(id_ad, 2)
|
| 884 |
+
|
| 885 |
+
ub_integer_options = univ.Integer(256)
|
| 886 |
+
|
| 887 |
+
|
| 888 |
+
class CertificateList(univ.Sequence):
|
| 889 |
+
pass
|
| 890 |
+
|
| 891 |
+
|
| 892 |
+
CertificateList.componentType = namedtype.NamedTypes(
|
| 893 |
+
namedtype.NamedType('tbsCertList', TBSCertList()),
|
| 894 |
+
namedtype.NamedType('signatureAlgorithm', AlgorithmIdentifier()),
|
| 895 |
+
namedtype.NamedType('signature', univ.BitString())
|
| 896 |
+
)
|
| 897 |
+
|
| 898 |
+
|
| 899 |
+
class PhysicalDeliveryOfficeNumber(PDSParameter):
|
| 900 |
+
pass
|
| 901 |
+
|
| 902 |
+
|
| 903 |
+
class TeletexOrganizationalUnitNames(univ.SequenceOf):
|
| 904 |
+
pass
|
| 905 |
+
|
| 906 |
+
|
| 907 |
+
TeletexOrganizationalUnitNames.componentType = TeletexOrganizationalUnitName()
|
| 908 |
+
TeletexOrganizationalUnitNames.sizeSpec = constraint.ValueSizeConstraint(1, ub_organizational_units)
|
| 909 |
+
|
| 910 |
+
physical_delivery_office_name = univ.Integer(10)
|
| 911 |
+
|
| 912 |
+
ub_common_name = univ.Integer(64)
|
| 913 |
+
|
| 914 |
+
|
| 915 |
+
class ExtensionORAddressComponents(PDSParameter):
|
| 916 |
+
pass
|
| 917 |
+
|
| 918 |
+
|
| 919 |
+
ub_pseudonym = univ.Integer(128)
|
| 920 |
+
|
| 921 |
+
poste_restante_address = univ.Integer(19)
|
| 922 |
+
|
| 923 |
+
id_at_organizationName = _OID(id_at, 10)
|
| 924 |
+
|
| 925 |
+
physical_delivery_office_number = univ.Integer(11)
|
| 926 |
+
|
| 927 |
+
id_at_pseudonym = _OID(id_at, 65)
|
| 928 |
+
|
| 929 |
+
|
| 930 |
+
class X520CommonName(univ.Choice):
|
| 931 |
+
pass
|
| 932 |
+
|
| 933 |
+
|
| 934 |
+
X520CommonName.componentType = namedtype.NamedTypes(
|
| 935 |
+
namedtype.NamedType('teletexString',
|
| 936 |
+
char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),
|
| 937 |
+
namedtype.NamedType('printableString',
|
| 938 |
+
char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),
|
| 939 |
+
namedtype.NamedType('universalString',
|
| 940 |
+
char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),
|
| 941 |
+
namedtype.NamedType('utf8String',
|
| 942 |
+
char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),
|
| 943 |
+
namedtype.NamedType('bmpString',
|
| 944 |
+
char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name)))
|
| 945 |
+
)
|
| 946 |
+
|
| 947 |
+
physical_delivery_organization_name = univ.Integer(14)
|
| 948 |
+
|
| 949 |
+
|
| 950 |
+
class X520dnQualifier(char.PrintableString):
|
| 951 |
+
pass
|
| 952 |
+
|
| 953 |
+
|
| 954 |
+
id_at_stateOrProvinceName = _OID(id_at, 8)
|
| 955 |
+
|
| 956 |
+
common_name = univ.Integer(1)
|
| 957 |
+
|
| 958 |
+
id_at_localityName = _OID(id_at, 7)
|
| 959 |
+
|
| 960 |
+
ub_match = univ.Integer(128)
|
| 961 |
+
|
| 962 |
+
ub_unformatted_address_length = univ.Integer(180)
|
| 963 |
+
|
| 964 |
+
|
| 965 |
+
class Attribute(univ.Sequence):
|
| 966 |
+
pass
|
| 967 |
+
|
| 968 |
+
|
| 969 |
+
Attribute.componentType = namedtype.NamedTypes(
|
| 970 |
+
namedtype.NamedType('type', AttributeType()),
|
| 971 |
+
namedtype.NamedType('values', univ.SetOf(componentType=AttributeValue()))
|
| 972 |
+
)
|
| 973 |
+
|
| 974 |
+
extended_network_address = univ.Integer(22)
|
| 975 |
+
|
| 976 |
+
unique_postal_name = univ.Integer(20)
|
| 977 |
+
|
| 978 |
+
ub_pds_physical_address_lines = univ.Integer(6)
|
| 979 |
+
|
| 980 |
+
|
| 981 |
+
class UnformattedPostalAddress(univ.Set):
|
| 982 |
+
pass
|
| 983 |
+
|
| 984 |
+
|
| 985 |
+
UnformattedPostalAddress.componentType = namedtype.NamedTypes(
|
| 986 |
+
namedtype.OptionalNamedType('printable-address', univ.SequenceOf(componentType=char.PrintableString().subtype(
|
| 987 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length)))),
|
| 988 |
+
namedtype.OptionalNamedType('teletex-string', char.TeletexString().subtype(
|
| 989 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, ub_unformatted_address_length)))
|
| 990 |
+
)
|
| 991 |
+
|
| 992 |
+
|
| 993 |
+
class UniquePostalName(PDSParameter):
|
| 994 |
+
pass
|
| 995 |
+
|
| 996 |
+
|
| 997 |
+
class X520Pseudonym(univ.Choice):
|
| 998 |
+
pass
|
| 999 |
+
|
| 1000 |
+
|
| 1001 |
+
X520Pseudonym.componentType = namedtype.NamedTypes(
|
| 1002 |
+
namedtype.NamedType('teletexString',
|
| 1003 |
+
char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),
|
| 1004 |
+
namedtype.NamedType('printableString',
|
| 1005 |
+
char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),
|
| 1006 |
+
namedtype.NamedType('universalString',
|
| 1007 |
+
char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),
|
| 1008 |
+
namedtype.NamedType('utf8String',
|
| 1009 |
+
char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),
|
| 1010 |
+
namedtype.NamedType('bmpString',
|
| 1011 |
+
char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym)))
|
| 1012 |
+
)
|
| 1013 |
+
|
| 1014 |
+
teletex_organization_name = univ.Integer(3)
|
| 1015 |
+
|
| 1016 |
+
teletex_domain_defined_attributes = univ.Integer(6)
|
| 1017 |
+
|
| 1018 |
+
street_address = univ.Integer(17)
|
| 1019 |
+
|
| 1020 |
+
id_kp_OCSPSigning = _OID(id_kp, 9)
|
| 1021 |
+
|
| 1022 |
+
id_ce = _OID(2, 5, 29)
|
| 1023 |
+
|
| 1024 |
+
id_ce_certificatePolicies = _OID(id_ce, 32)
|
| 1025 |
+
|
| 1026 |
+
|
| 1027 |
+
class EDIPartyName(univ.Sequence):
|
| 1028 |
+
pass
|
| 1029 |
+
|
| 1030 |
+
|
| 1031 |
+
EDIPartyName.componentType = namedtype.NamedTypes(
|
| 1032 |
+
namedtype.OptionalNamedType('nameAssigner', DirectoryString().subtype(
|
| 1033 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 1034 |
+
namedtype.NamedType('partyName',
|
| 1035 |
+
DirectoryString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 1036 |
+
)
|
| 1037 |
+
|
| 1038 |
+
|
| 1039 |
+
class AnotherName(univ.Sequence):
|
| 1040 |
+
pass
|
| 1041 |
+
|
| 1042 |
+
|
| 1043 |
+
AnotherName.componentType = namedtype.NamedTypes(
|
| 1044 |
+
namedtype.NamedType('type-id', univ.ObjectIdentifier()),
|
| 1045 |
+
namedtype.NamedType('value', univ.Any().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
|
| 1046 |
+
)
|
| 1047 |
+
|
| 1048 |
+
|
| 1049 |
+
class GeneralName(univ.Choice):
|
| 1050 |
+
pass
|
| 1051 |
+
|
| 1052 |
+
|
| 1053 |
+
GeneralName.componentType = namedtype.NamedTypes(
|
| 1054 |
+
namedtype.NamedType('otherName',
|
| 1055 |
+
AnotherName().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 1056 |
+
namedtype.NamedType('rfc822Name',
|
| 1057 |
+
char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 1058 |
+
namedtype.NamedType('dNSName',
|
| 1059 |
+
char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
|
| 1060 |
+
namedtype.NamedType('x400Address',
|
| 1061 |
+
ORAddress().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
|
| 1062 |
+
namedtype.NamedType('directoryName',
|
| 1063 |
+
Name().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 4))),
|
| 1064 |
+
namedtype.NamedType('ediPartyName',
|
| 1065 |
+
EDIPartyName().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 5))),
|
| 1066 |
+
namedtype.NamedType('uniformResourceIdentifier',
|
| 1067 |
+
char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6))),
|
| 1068 |
+
namedtype.NamedType('iPAddress',
|
| 1069 |
+
univ.OctetString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))),
|
| 1070 |
+
namedtype.NamedType('registeredID', univ.ObjectIdentifier().subtype(
|
| 1071 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 8)))
|
| 1072 |
+
)
|
| 1073 |
+
|
| 1074 |
+
|
| 1075 |
+
class GeneralNames(univ.SequenceOf):
|
| 1076 |
+
pass
|
| 1077 |
+
|
| 1078 |
+
|
| 1079 |
+
GeneralNames.componentType = GeneralName()
|
| 1080 |
+
GeneralNames.sizeSpec = constraint.ValueSizeConstraint(1, MAX)
|
| 1081 |
+
|
| 1082 |
+
|
| 1083 |
+
class IssuerAltName(GeneralNames):
|
| 1084 |
+
pass
|
| 1085 |
+
|
| 1086 |
+
|
| 1087 |
+
id_ce_cRLDistributionPoints = _OID(id_ce, 31)
|
| 1088 |
+
|
| 1089 |
+
|
| 1090 |
+
class CertPolicyId(univ.ObjectIdentifier):
|
| 1091 |
+
pass
|
| 1092 |
+
|
| 1093 |
+
|
| 1094 |
+
class PolicyMappings(univ.SequenceOf):
|
| 1095 |
+
pass
|
| 1096 |
+
|
| 1097 |
+
|
| 1098 |
+
PolicyMappings.componentType = univ.Sequence(componentType=namedtype.NamedTypes(
|
| 1099 |
+
namedtype.NamedType('issuerDomainPolicy', CertPolicyId()),
|
| 1100 |
+
namedtype.NamedType('subjectDomainPolicy', CertPolicyId())
|
| 1101 |
+
))
|
| 1102 |
+
|
| 1103 |
+
PolicyMappings.sizeSpec = constraint.ValueSizeConstraint(1, MAX)
|
| 1104 |
+
|
| 1105 |
+
|
| 1106 |
+
class PolicyQualifierId(univ.ObjectIdentifier):
|
| 1107 |
+
pass
|
| 1108 |
+
|
| 1109 |
+
|
| 1110 |
+
holdInstruction = _OID(2, 2, 840, 10040, 2)
|
| 1111 |
+
|
| 1112 |
+
id_ce_subjectDirectoryAttributes = _OID(id_ce, 9)
|
| 1113 |
+
|
| 1114 |
+
id_holdinstruction_callissuer = _OID(holdInstruction, 2)
|
| 1115 |
+
|
| 1116 |
+
|
| 1117 |
+
class SubjectDirectoryAttributes(univ.SequenceOf):
|
| 1118 |
+
pass
|
| 1119 |
+
|
| 1120 |
+
|
| 1121 |
+
SubjectDirectoryAttributes.componentType = Attribute()
|
| 1122 |
+
SubjectDirectoryAttributes.sizeSpec = constraint.ValueSizeConstraint(1, MAX)
|
| 1123 |
+
|
| 1124 |
+
anyPolicy = _OID(id_ce_certificatePolicies, 0)
|
| 1125 |
+
|
| 1126 |
+
id_ce_subjectAltName = _OID(id_ce, 17)
|
| 1127 |
+
|
| 1128 |
+
id_kp_emailProtection = _OID(id_kp, 4)
|
| 1129 |
+
|
| 1130 |
+
|
| 1131 |
+
class ReasonFlags(univ.BitString):
|
| 1132 |
+
pass
|
| 1133 |
+
|
| 1134 |
+
|
| 1135 |
+
ReasonFlags.namedValues = namedval.NamedValues(
|
| 1136 |
+
('unused', 0),
|
| 1137 |
+
('keyCompromise', 1),
|
| 1138 |
+
('cACompromise', 2),
|
| 1139 |
+
('affiliationChanged', 3),
|
| 1140 |
+
('superseded', 4),
|
| 1141 |
+
('cessationOfOperation', 5),
|
| 1142 |
+
('certificateHold', 6),
|
| 1143 |
+
('privilegeWithdrawn', 7),
|
| 1144 |
+
('aACompromise', 8)
|
| 1145 |
+
)
|
| 1146 |
+
|
| 1147 |
+
|
| 1148 |
+
class DistributionPointName(univ.Choice):
|
| 1149 |
+
pass
|
| 1150 |
+
|
| 1151 |
+
|
| 1152 |
+
DistributionPointName.componentType = namedtype.NamedTypes(
|
| 1153 |
+
namedtype.NamedType('fullName',
|
| 1154 |
+
GeneralNames().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 1155 |
+
namedtype.NamedType('nameRelativeToCRLIssuer', RelativeDistinguishedName().subtype(
|
| 1156 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 1157 |
+
)
|
| 1158 |
+
|
| 1159 |
+
|
| 1160 |
+
class DistributionPoint(univ.Sequence):
|
| 1161 |
+
pass
|
| 1162 |
+
|
| 1163 |
+
|
| 1164 |
+
DistributionPoint.componentType = namedtype.NamedTypes(
|
| 1165 |
+
namedtype.OptionalNamedType('distributionPoint', DistributionPointName().subtype(
|
| 1166 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 1167 |
+
namedtype.OptionalNamedType('reasons', ReasonFlags().subtype(
|
| 1168 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 1169 |
+
namedtype.OptionalNamedType('cRLIssuer', GeneralNames().subtype(
|
| 1170 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
|
| 1171 |
+
)
|
| 1172 |
+
|
| 1173 |
+
id_ce_keyUsage = _OID(id_ce, 15)
|
| 1174 |
+
|
| 1175 |
+
|
| 1176 |
+
class PolicyQualifierInfo(univ.Sequence):
|
| 1177 |
+
pass
|
| 1178 |
+
|
| 1179 |
+
|
| 1180 |
+
PolicyQualifierInfo.componentType = namedtype.NamedTypes(
|
| 1181 |
+
namedtype.NamedType('policyQualifierId', PolicyQualifierId()),
|
| 1182 |
+
namedtype.NamedType('qualifier', univ.Any())
|
| 1183 |
+
)
|
| 1184 |
+
|
| 1185 |
+
|
| 1186 |
+
class PolicyInformation(univ.Sequence):
|
| 1187 |
+
pass
|
| 1188 |
+
|
| 1189 |
+
|
| 1190 |
+
PolicyInformation.componentType = namedtype.NamedTypes(
|
| 1191 |
+
namedtype.NamedType('policyIdentifier', CertPolicyId()),
|
| 1192 |
+
namedtype.OptionalNamedType('policyQualifiers', univ.SequenceOf(componentType=PolicyQualifierInfo()))
|
| 1193 |
+
)
|
| 1194 |
+
|
| 1195 |
+
|
| 1196 |
+
class CertificatePolicies(univ.SequenceOf):
|
| 1197 |
+
pass
|
| 1198 |
+
|
| 1199 |
+
|
| 1200 |
+
CertificatePolicies.componentType = PolicyInformation()
|
| 1201 |
+
CertificatePolicies.sizeSpec = constraint.ValueSizeConstraint(1, MAX)
|
| 1202 |
+
|
| 1203 |
+
id_ce_basicConstraints = _OID(id_ce, 19)
|
| 1204 |
+
|
| 1205 |
+
|
| 1206 |
+
class HoldInstructionCode(univ.ObjectIdentifier):
|
| 1207 |
+
pass
|
| 1208 |
+
|
| 1209 |
+
|
| 1210 |
+
class KeyPurposeId(univ.ObjectIdentifier):
|
| 1211 |
+
pass
|
| 1212 |
+
|
| 1213 |
+
|
| 1214 |
+
class ExtKeyUsageSyntax(univ.SequenceOf):
|
| 1215 |
+
pass
|
| 1216 |
+
|
| 1217 |
+
|
| 1218 |
+
ExtKeyUsageSyntax.componentType = KeyPurposeId()
|
| 1219 |
+
ExtKeyUsageSyntax.sizeSpec = constraint.ValueSizeConstraint(1, MAX)
|
| 1220 |
+
|
| 1221 |
+
|
| 1222 |
+
class SubjectAltName(GeneralNames):
|
| 1223 |
+
pass
|
| 1224 |
+
|
| 1225 |
+
|
| 1226 |
+
class BasicConstraints(univ.Sequence):
|
| 1227 |
+
pass
|
| 1228 |
+
|
| 1229 |
+
|
| 1230 |
+
BasicConstraints.componentType = namedtype.NamedTypes(
|
| 1231 |
+
namedtype.DefaultedNamedType('cA', univ.Boolean().subtype(value=0)),
|
| 1232 |
+
namedtype.OptionalNamedType('pathLenConstraint',
|
| 1233 |
+
univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, MAX)))
|
| 1234 |
+
)
|
| 1235 |
+
|
| 1236 |
+
|
| 1237 |
+
class SkipCerts(univ.Integer):
|
| 1238 |
+
pass
|
| 1239 |
+
|
| 1240 |
+
|
| 1241 |
+
SkipCerts.subtypeSpec = constraint.ValueRangeConstraint(0, MAX)
|
| 1242 |
+
|
| 1243 |
+
|
| 1244 |
+
class InhibitAnyPolicy(SkipCerts):
|
| 1245 |
+
pass
|
| 1246 |
+
|
| 1247 |
+
|
| 1248 |
+
class CRLNumber(univ.Integer):
|
| 1249 |
+
pass
|
| 1250 |
+
|
| 1251 |
+
|
| 1252 |
+
CRLNumber.subtypeSpec = constraint.ValueRangeConstraint(0, MAX)
|
| 1253 |
+
|
| 1254 |
+
|
| 1255 |
+
class BaseCRLNumber(CRLNumber):
|
| 1256 |
+
pass
|
| 1257 |
+
|
| 1258 |
+
|
| 1259 |
+
class KeyIdentifier(univ.OctetString):
|
| 1260 |
+
pass
|
| 1261 |
+
|
| 1262 |
+
|
| 1263 |
+
class AuthorityKeyIdentifier(univ.Sequence):
|
| 1264 |
+
pass
|
| 1265 |
+
|
| 1266 |
+
|
| 1267 |
+
AuthorityKeyIdentifier.componentType = namedtype.NamedTypes(
|
| 1268 |
+
namedtype.OptionalNamedType('keyIdentifier', KeyIdentifier().subtype(
|
| 1269 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 1270 |
+
namedtype.OptionalNamedType('authorityCertIssuer', GeneralNames().subtype(
|
| 1271 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 1272 |
+
namedtype.OptionalNamedType('authorityCertSerialNumber', CertificateSerialNumber().subtype(
|
| 1273 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
|
| 1274 |
+
)
|
| 1275 |
+
|
| 1276 |
+
id_ce_nameConstraints = _OID(id_ce, 30)
|
| 1277 |
+
|
| 1278 |
+
id_kp_serverAuth = _OID(id_kp, 1)
|
| 1279 |
+
|
| 1280 |
+
id_ce_freshestCRL = _OID(id_ce, 46)
|
| 1281 |
+
|
| 1282 |
+
id_ce_cRLReasons = _OID(id_ce, 21)
|
| 1283 |
+
|
| 1284 |
+
|
| 1285 |
+
class CRLDistributionPoints(univ.SequenceOf):
|
| 1286 |
+
pass
|
| 1287 |
+
|
| 1288 |
+
|
| 1289 |
+
CRLDistributionPoints.componentType = DistributionPoint()
|
| 1290 |
+
CRLDistributionPoints.sizeSpec = constraint.ValueSizeConstraint(1, MAX)
|
| 1291 |
+
|
| 1292 |
+
|
| 1293 |
+
class FreshestCRL(CRLDistributionPoints):
|
| 1294 |
+
pass
|
| 1295 |
+
|
| 1296 |
+
|
| 1297 |
+
id_ce_inhibitAnyPolicy = _OID(id_ce, 54)
|
| 1298 |
+
|
| 1299 |
+
|
| 1300 |
+
class CRLReason(univ.Enumerated):
|
| 1301 |
+
pass
|
| 1302 |
+
|
| 1303 |
+
|
| 1304 |
+
CRLReason.namedValues = namedval.NamedValues(
|
| 1305 |
+
('unspecified', 0),
|
| 1306 |
+
('keyCompromise', 1),
|
| 1307 |
+
('cACompromise', 2),
|
| 1308 |
+
('affiliationChanged', 3),
|
| 1309 |
+
('superseded', 4),
|
| 1310 |
+
('cessationOfOperation', 5),
|
| 1311 |
+
('certificateHold', 6),
|
| 1312 |
+
('removeFromCRL', 8),
|
| 1313 |
+
('privilegeWithdrawn', 9),
|
| 1314 |
+
('aACompromise', 10)
|
| 1315 |
+
)
|
| 1316 |
+
|
| 1317 |
+
|
| 1318 |
+
class BaseDistance(univ.Integer):
|
| 1319 |
+
pass
|
| 1320 |
+
|
| 1321 |
+
|
| 1322 |
+
BaseDistance.subtypeSpec = constraint.ValueRangeConstraint(0, MAX)
|
| 1323 |
+
|
| 1324 |
+
|
| 1325 |
+
class GeneralSubtree(univ.Sequence):
|
| 1326 |
+
pass
|
| 1327 |
+
|
| 1328 |
+
|
| 1329 |
+
GeneralSubtree.componentType = namedtype.NamedTypes(
|
| 1330 |
+
namedtype.NamedType('base', GeneralName()),
|
| 1331 |
+
namedtype.DefaultedNamedType('minimum', BaseDistance().subtype(
|
| 1332 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)).subtype(value=0)),
|
| 1333 |
+
namedtype.OptionalNamedType('maximum', BaseDistance().subtype(
|
| 1334 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 1335 |
+
)
|
| 1336 |
+
|
| 1337 |
+
|
| 1338 |
+
class GeneralSubtrees(univ.SequenceOf):
|
| 1339 |
+
pass
|
| 1340 |
+
|
| 1341 |
+
|
| 1342 |
+
GeneralSubtrees.componentType = GeneralSubtree()
|
| 1343 |
+
GeneralSubtrees.sizeSpec = constraint.ValueSizeConstraint(1, MAX)
|
| 1344 |
+
|
| 1345 |
+
|
| 1346 |
+
class NameConstraints(univ.Sequence):
|
| 1347 |
+
pass
|
| 1348 |
+
|
| 1349 |
+
|
| 1350 |
+
NameConstraints.componentType = namedtype.NamedTypes(
|
| 1351 |
+
namedtype.OptionalNamedType('permittedSubtrees', GeneralSubtrees().subtype(
|
| 1352 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 1353 |
+
namedtype.OptionalNamedType('excludedSubtrees', GeneralSubtrees().subtype(
|
| 1354 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 1355 |
+
)
|
| 1356 |
+
|
| 1357 |
+
id_pe_authorityInfoAccess = _OID(id_pe, 1)
|
| 1358 |
+
|
| 1359 |
+
id_pe_subjectInfoAccess = _OID(id_pe, 11)
|
| 1360 |
+
|
| 1361 |
+
id_ce_certificateIssuer = _OID(id_ce, 29)
|
| 1362 |
+
|
| 1363 |
+
id_ce_invalidityDate = _OID(id_ce, 24)
|
| 1364 |
+
|
| 1365 |
+
|
| 1366 |
+
class DirectoryString(univ.Choice):
|
| 1367 |
+
pass
|
| 1368 |
+
|
| 1369 |
+
|
| 1370 |
+
DirectoryString.componentType = namedtype.NamedTypes(
|
| 1371 |
+
namedtype.NamedType('any', univ.Any())
|
| 1372 |
+
)
|
| 1373 |
+
|
| 1374 |
+
id_ce_authorityKeyIdentifier = _OID(id_ce, 35)
|
| 1375 |
+
|
| 1376 |
+
|
| 1377 |
+
class AccessDescription(univ.Sequence):
|
| 1378 |
+
pass
|
| 1379 |
+
|
| 1380 |
+
|
| 1381 |
+
AccessDescription.componentType = namedtype.NamedTypes(
|
| 1382 |
+
namedtype.NamedType('accessMethod', univ.ObjectIdentifier()),
|
| 1383 |
+
namedtype.NamedType('accessLocation', GeneralName())
|
| 1384 |
+
)
|
| 1385 |
+
|
| 1386 |
+
|
| 1387 |
+
class AuthorityInfoAccessSyntax(univ.SequenceOf):
|
| 1388 |
+
pass
|
| 1389 |
+
|
| 1390 |
+
|
| 1391 |
+
AuthorityInfoAccessSyntax.componentType = AccessDescription()
|
| 1392 |
+
AuthorityInfoAccessSyntax.sizeSpec = constraint.ValueSizeConstraint(1, MAX)
|
| 1393 |
+
|
| 1394 |
+
id_ce_issuingDistributionPoint = _OID(id_ce, 28)
|
| 1395 |
+
|
| 1396 |
+
|
| 1397 |
+
class CPSuri(char.IA5String):
|
| 1398 |
+
pass
|
| 1399 |
+
|
| 1400 |
+
|
| 1401 |
+
class DisplayText(univ.Choice):
|
| 1402 |
+
pass
|
| 1403 |
+
|
| 1404 |
+
|
| 1405 |
+
DisplayText.componentType = namedtype.NamedTypes(
|
| 1406 |
+
namedtype.NamedType('ia5String', char.IA5String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 200))),
|
| 1407 |
+
namedtype.NamedType('visibleString',
|
| 1408 |
+
char.VisibleString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 200))),
|
| 1409 |
+
namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 200))),
|
| 1410 |
+
namedtype.NamedType('utf8String', char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 200)))
|
| 1411 |
+
)
|
| 1412 |
+
|
| 1413 |
+
|
| 1414 |
+
class NoticeReference(univ.Sequence):
|
| 1415 |
+
pass
|
| 1416 |
+
|
| 1417 |
+
|
| 1418 |
+
NoticeReference.componentType = namedtype.NamedTypes(
|
| 1419 |
+
namedtype.NamedType('organization', DisplayText()),
|
| 1420 |
+
namedtype.NamedType('noticeNumbers', univ.SequenceOf(componentType=univ.Integer()))
|
| 1421 |
+
)
|
| 1422 |
+
|
| 1423 |
+
|
| 1424 |
+
class UserNotice(univ.Sequence):
|
| 1425 |
+
pass
|
| 1426 |
+
|
| 1427 |
+
|
| 1428 |
+
UserNotice.componentType = namedtype.NamedTypes(
|
| 1429 |
+
namedtype.OptionalNamedType('noticeRef', NoticeReference()),
|
| 1430 |
+
namedtype.OptionalNamedType('explicitText', DisplayText())
|
| 1431 |
+
)
|
| 1432 |
+
|
| 1433 |
+
|
| 1434 |
+
class PrivateKeyUsagePeriod(univ.Sequence):
|
| 1435 |
+
pass
|
| 1436 |
+
|
| 1437 |
+
|
| 1438 |
+
PrivateKeyUsagePeriod.componentType = namedtype.NamedTypes(
|
| 1439 |
+
namedtype.OptionalNamedType('notBefore', useful.GeneralizedTime().subtype(
|
| 1440 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 1441 |
+
namedtype.OptionalNamedType('notAfter', useful.GeneralizedTime().subtype(
|
| 1442 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 1443 |
+
)
|
| 1444 |
+
|
| 1445 |
+
id_ce_subjectKeyIdentifier = _OID(id_ce, 14)
|
| 1446 |
+
|
| 1447 |
+
|
| 1448 |
+
class CertificateIssuer(GeneralNames):
|
| 1449 |
+
pass
|
| 1450 |
+
|
| 1451 |
+
|
| 1452 |
+
class InvalidityDate(useful.GeneralizedTime):
|
| 1453 |
+
pass
|
| 1454 |
+
|
| 1455 |
+
|
| 1456 |
+
class SubjectInfoAccessSyntax(univ.SequenceOf):
|
| 1457 |
+
pass
|
| 1458 |
+
|
| 1459 |
+
|
| 1460 |
+
SubjectInfoAccessSyntax.componentType = AccessDescription()
|
| 1461 |
+
SubjectInfoAccessSyntax.sizeSpec = constraint.ValueSizeConstraint(1, MAX)
|
| 1462 |
+
|
| 1463 |
+
|
| 1464 |
+
class KeyUsage(univ.BitString):
|
| 1465 |
+
pass
|
| 1466 |
+
|
| 1467 |
+
|
| 1468 |
+
KeyUsage.namedValues = namedval.NamedValues(
|
| 1469 |
+
('digitalSignature', 0),
|
| 1470 |
+
('nonRepudiation', 1),
|
| 1471 |
+
('keyEncipherment', 2),
|
| 1472 |
+
('dataEncipherment', 3),
|
| 1473 |
+
('keyAgreement', 4),
|
| 1474 |
+
('keyCertSign', 5),
|
| 1475 |
+
('cRLSign', 6),
|
| 1476 |
+
('encipherOnly', 7),
|
| 1477 |
+
('decipherOnly', 8)
|
| 1478 |
+
)
|
| 1479 |
+
|
| 1480 |
+
id_ce_extKeyUsage = _OID(id_ce, 37)
|
| 1481 |
+
|
| 1482 |
+
anyExtendedKeyUsage = _OID(id_ce_extKeyUsage, 0)
|
| 1483 |
+
|
| 1484 |
+
id_ce_privateKeyUsagePeriod = _OID(id_ce, 16)
|
| 1485 |
+
|
| 1486 |
+
id_ce_policyMappings = _OID(id_ce, 33)
|
| 1487 |
+
|
| 1488 |
+
id_ce_cRLNumber = _OID(id_ce, 20)
|
| 1489 |
+
|
| 1490 |
+
id_ce_policyConstraints = _OID(id_ce, 36)
|
| 1491 |
+
|
| 1492 |
+
id_holdinstruction_none = _OID(holdInstruction, 1)
|
| 1493 |
+
|
| 1494 |
+
id_holdinstruction_reject = _OID(holdInstruction, 3)
|
| 1495 |
+
|
| 1496 |
+
id_kp_timeStamping = _OID(id_kp, 8)
|
| 1497 |
+
|
| 1498 |
+
|
| 1499 |
+
class PolicyConstraints(univ.Sequence):
|
| 1500 |
+
pass
|
| 1501 |
+
|
| 1502 |
+
|
| 1503 |
+
PolicyConstraints.componentType = namedtype.NamedTypes(
|
| 1504 |
+
namedtype.OptionalNamedType('requireExplicitPolicy',
|
| 1505 |
+
SkipCerts().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 1506 |
+
namedtype.OptionalNamedType('inhibitPolicyMapping',
|
| 1507 |
+
SkipCerts().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 1508 |
+
)
|
| 1509 |
+
|
| 1510 |
+
|
| 1511 |
+
class SubjectKeyIdentifier(KeyIdentifier):
|
| 1512 |
+
pass
|
| 1513 |
+
|
| 1514 |
+
|
| 1515 |
+
id_kp_clientAuth = _OID(id_kp, 2)
|
| 1516 |
+
|
| 1517 |
+
id_ce_deltaCRLIndicator = _OID(id_ce, 27)
|
| 1518 |
+
|
| 1519 |
+
id_ce_issuerAltName = _OID(id_ce, 18)
|
| 1520 |
+
|
| 1521 |
+
id_kp_codeSigning = _OID(id_kp, 3)
|
| 1522 |
+
|
| 1523 |
+
id_ce_holdInstructionCode = _OID(id_ce, 23)
|
| 1524 |
+
|
| 1525 |
+
|
| 1526 |
+
class IssuingDistributionPoint(univ.Sequence):
|
| 1527 |
+
pass
|
| 1528 |
+
|
| 1529 |
+
|
| 1530 |
+
IssuingDistributionPoint.componentType = namedtype.NamedTypes(
|
| 1531 |
+
namedtype.OptionalNamedType('distributionPoint', DistributionPointName().subtype(
|
| 1532 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 1533 |
+
namedtype.DefaultedNamedType('onlyContainsUserCerts', univ.Boolean().subtype(
|
| 1534 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)).subtype(value=0)),
|
| 1535 |
+
namedtype.DefaultedNamedType('onlyContainsCACerts', univ.Boolean().subtype(
|
| 1536 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)).subtype(value=0)),
|
| 1537 |
+
namedtype.OptionalNamedType('onlySomeReasons', ReasonFlags().subtype(
|
| 1538 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
|
| 1539 |
+
namedtype.DefaultedNamedType('indirectCRL', univ.Boolean().subtype(
|
| 1540 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4)).subtype(value=0)),
|
| 1541 |
+
namedtype.DefaultedNamedType('onlyContainsAttributeCerts', univ.Boolean().subtype(
|
| 1542 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 5)).subtype(value=0))
|
| 1543 |
+
)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3281.py
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding: utf-8
|
| 2 |
+
#
|
| 3 |
+
# This file is part of pyasn1-modules software.
|
| 4 |
+
#
|
| 5 |
+
# Created by Stanisław Pitucha with asn1ate tool.
|
| 6 |
+
# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
|
| 7 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 8 |
+
#
|
| 9 |
+
# An Internet Attribute Certificate Profile for Authorization
|
| 10 |
+
#
|
| 11 |
+
# ASN.1 source from:
|
| 12 |
+
# http://www.ietf.org/rfc/rfc3281.txt
|
| 13 |
+
#
|
| 14 |
+
from pyasn1.type import char
|
| 15 |
+
from pyasn1.type import constraint
|
| 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 |
+
from pyasn1.type import useful
|
| 21 |
+
|
| 22 |
+
from pyasn1_modules import rfc3280
|
| 23 |
+
|
| 24 |
+
MAX = float('inf')
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _buildOid(*components):
|
| 28 |
+
output = []
|
| 29 |
+
for x in tuple(components):
|
| 30 |
+
if isinstance(x, univ.ObjectIdentifier):
|
| 31 |
+
output.extend(list(x))
|
| 32 |
+
else:
|
| 33 |
+
output.append(int(x))
|
| 34 |
+
|
| 35 |
+
return univ.ObjectIdentifier(output)
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
class ObjectDigestInfo(univ.Sequence):
|
| 39 |
+
pass
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
ObjectDigestInfo.componentType = namedtype.NamedTypes(
|
| 43 |
+
namedtype.NamedType('digestedObjectType', univ.Enumerated(
|
| 44 |
+
namedValues=namedval.NamedValues(('publicKey', 0), ('publicKeyCert', 1), ('otherObjectTypes', 2)))),
|
| 45 |
+
namedtype.OptionalNamedType('otherObjectTypeID', univ.ObjectIdentifier()),
|
| 46 |
+
namedtype.NamedType('digestAlgorithm', rfc3280.AlgorithmIdentifier()),
|
| 47 |
+
namedtype.NamedType('objectDigest', univ.BitString())
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
class IssuerSerial(univ.Sequence):
|
| 52 |
+
pass
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
IssuerSerial.componentType = namedtype.NamedTypes(
|
| 56 |
+
namedtype.NamedType('issuer', rfc3280.GeneralNames()),
|
| 57 |
+
namedtype.NamedType('serial', rfc3280.CertificateSerialNumber()),
|
| 58 |
+
namedtype.OptionalNamedType('issuerUID', rfc3280.UniqueIdentifier())
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
class TargetCert(univ.Sequence):
|
| 63 |
+
pass
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
TargetCert.componentType = namedtype.NamedTypes(
|
| 67 |
+
namedtype.NamedType('targetCertificate', IssuerSerial()),
|
| 68 |
+
namedtype.OptionalNamedType('targetName', rfc3280.GeneralName()),
|
| 69 |
+
namedtype.OptionalNamedType('certDigestInfo', ObjectDigestInfo())
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
class Target(univ.Choice):
|
| 74 |
+
pass
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
Target.componentType = namedtype.NamedTypes(
|
| 78 |
+
namedtype.NamedType('targetName', rfc3280.GeneralName().subtype(
|
| 79 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 80 |
+
namedtype.NamedType('targetGroup', rfc3280.GeneralName().subtype(
|
| 81 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 82 |
+
namedtype.NamedType('targetCert',
|
| 83 |
+
TargetCert().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2)))
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
class Targets(univ.SequenceOf):
|
| 88 |
+
pass
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
Targets.componentType = Target()
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
class ProxyInfo(univ.SequenceOf):
|
| 95 |
+
pass
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
ProxyInfo.componentType = Targets()
|
| 99 |
+
|
| 100 |
+
id_at_role = _buildOid(rfc3280.id_at, 72)
|
| 101 |
+
|
| 102 |
+
id_pe_aaControls = _buildOid(rfc3280.id_pe, 6)
|
| 103 |
+
|
| 104 |
+
id_ce_targetInformation = _buildOid(rfc3280.id_ce, 55)
|
| 105 |
+
|
| 106 |
+
id_pe_ac_auditIdentity = _buildOid(rfc3280.id_pe, 4)
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
class ClassList(univ.BitString):
|
| 110 |
+
pass
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
ClassList.namedValues = namedval.NamedValues(
|
| 114 |
+
('unmarked', 0),
|
| 115 |
+
('unclassified', 1),
|
| 116 |
+
('restricted', 2),
|
| 117 |
+
('confidential', 3),
|
| 118 |
+
('secret', 4),
|
| 119 |
+
('topSecret', 5)
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
class SecurityCategory(univ.Sequence):
|
| 124 |
+
pass
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
SecurityCategory.componentType = namedtype.NamedTypes(
|
| 128 |
+
namedtype.NamedType('type', univ.ObjectIdentifier().subtype(
|
| 129 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 130 |
+
namedtype.NamedType('value', univ.Any().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 131 |
+
)
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
class Clearance(univ.Sequence):
|
| 135 |
+
pass
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
Clearance.componentType = namedtype.NamedTypes(
|
| 139 |
+
namedtype.NamedType('policyId', univ.ObjectIdentifier().subtype(
|
| 140 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 141 |
+
namedtype.DefaultedNamedType('classList',
|
| 142 |
+
ClassList().subtype(implicitTag=tag.Tag(tag.tagClassContext,
|
| 143 |
+
tag.tagFormatSimple, 1)).subtype(
|
| 144 |
+
value="unclassified")),
|
| 145 |
+
namedtype.OptionalNamedType('securityCategories', univ.SetOf(componentType=SecurityCategory()).subtype(
|
| 146 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
|
| 147 |
+
)
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
class AttCertVersion(univ.Integer):
|
| 151 |
+
pass
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
AttCertVersion.namedValues = namedval.NamedValues(
|
| 155 |
+
('v2', 1)
|
| 156 |
+
)
|
| 157 |
+
|
| 158 |
+
id_aca = _buildOid(rfc3280.id_pkix, 10)
|
| 159 |
+
|
| 160 |
+
id_at_clearance = _buildOid(2, 5, 1, 5, 55)
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
class AttrSpec(univ.SequenceOf):
|
| 164 |
+
pass
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
AttrSpec.componentType = univ.ObjectIdentifier()
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
class AAControls(univ.Sequence):
|
| 171 |
+
pass
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
AAControls.componentType = namedtype.NamedTypes(
|
| 175 |
+
namedtype.OptionalNamedType('pathLenConstraint',
|
| 176 |
+
univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, MAX))),
|
| 177 |
+
namedtype.OptionalNamedType('permittedAttrs',
|
| 178 |
+
AttrSpec().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 179 |
+
namedtype.OptionalNamedType('excludedAttrs',
|
| 180 |
+
AttrSpec().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 181 |
+
namedtype.DefaultedNamedType('permitUnSpecified', univ.Boolean().subtype(value=1))
|
| 182 |
+
)
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
class AttCertValidityPeriod(univ.Sequence):
|
| 186 |
+
pass
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
AttCertValidityPeriod.componentType = namedtype.NamedTypes(
|
| 190 |
+
namedtype.NamedType('notBeforeTime', useful.GeneralizedTime()),
|
| 191 |
+
namedtype.NamedType('notAfterTime', useful.GeneralizedTime())
|
| 192 |
+
)
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
id_aca_authenticationInfo = _buildOid(id_aca, 1)
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
class V2Form(univ.Sequence):
|
| 199 |
+
pass
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
V2Form.componentType = namedtype.NamedTypes(
|
| 203 |
+
namedtype.OptionalNamedType('issuerName', rfc3280.GeneralNames()),
|
| 204 |
+
namedtype.OptionalNamedType('baseCertificateID', IssuerSerial().subtype(
|
| 205 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 206 |
+
namedtype.OptionalNamedType('objectDigestInfo', ObjectDigestInfo().subtype(
|
| 207 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1)))
|
| 208 |
+
)
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
class AttCertIssuer(univ.Choice):
|
| 212 |
+
pass
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
AttCertIssuer.componentType = namedtype.NamedTypes(
|
| 216 |
+
namedtype.NamedType('v1Form', rfc3280.GeneralNames()),
|
| 217 |
+
namedtype.NamedType('v2Form',
|
| 218 |
+
V2Form().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))
|
| 219 |
+
)
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
class Holder(univ.Sequence):
|
| 223 |
+
pass
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
Holder.componentType = namedtype.NamedTypes(
|
| 227 |
+
namedtype.OptionalNamedType('baseCertificateID', IssuerSerial().subtype(
|
| 228 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 229 |
+
namedtype.OptionalNamedType('entityName', rfc3280.GeneralNames().subtype(
|
| 230 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 231 |
+
namedtype.OptionalNamedType('objectDigestInfo', ObjectDigestInfo().subtype(
|
| 232 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2)))
|
| 233 |
+
)
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
class AttributeCertificateInfo(univ.Sequence):
|
| 237 |
+
pass
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
AttributeCertificateInfo.componentType = namedtype.NamedTypes(
|
| 241 |
+
namedtype.NamedType('version', AttCertVersion()),
|
| 242 |
+
namedtype.NamedType('holder', Holder()),
|
| 243 |
+
namedtype.NamedType('issuer', AttCertIssuer()),
|
| 244 |
+
namedtype.NamedType('signature', rfc3280.AlgorithmIdentifier()),
|
| 245 |
+
namedtype.NamedType('serialNumber', rfc3280.CertificateSerialNumber()),
|
| 246 |
+
namedtype.NamedType('attrCertValidityPeriod', AttCertValidityPeriod()),
|
| 247 |
+
namedtype.NamedType('attributes', univ.SequenceOf(componentType=rfc3280.Attribute())),
|
| 248 |
+
namedtype.OptionalNamedType('issuerUniqueID', rfc3280.UniqueIdentifier()),
|
| 249 |
+
namedtype.OptionalNamedType('extensions', rfc3280.Extensions())
|
| 250 |
+
)
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
class AttributeCertificate(univ.Sequence):
|
| 254 |
+
pass
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
AttributeCertificate.componentType = namedtype.NamedTypes(
|
| 258 |
+
namedtype.NamedType('acinfo', AttributeCertificateInfo()),
|
| 259 |
+
namedtype.NamedType('signatureAlgorithm', rfc3280.AlgorithmIdentifier()),
|
| 260 |
+
namedtype.NamedType('signatureValue', univ.BitString())
|
| 261 |
+
)
|
| 262 |
+
|
| 263 |
+
id_mod = _buildOid(rfc3280.id_pkix, 0)
|
| 264 |
+
|
| 265 |
+
id_mod_attribute_cert = _buildOid(id_mod, 12)
|
| 266 |
+
|
| 267 |
+
id_aca_accessIdentity = _buildOid(id_aca, 2)
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
class RoleSyntax(univ.Sequence):
|
| 271 |
+
pass
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
RoleSyntax.componentType = namedtype.NamedTypes(
|
| 275 |
+
namedtype.OptionalNamedType('roleAuthority', rfc3280.GeneralNames().subtype(
|
| 276 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 277 |
+
namedtype.NamedType('roleName',
|
| 278 |
+
rfc3280.GeneralName().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 279 |
+
)
|
| 280 |
+
|
| 281 |
+
id_aca_chargingIdentity = _buildOid(id_aca, 3)
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
class ACClearAttrs(univ.Sequence):
|
| 285 |
+
pass
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
ACClearAttrs.componentType = namedtype.NamedTypes(
|
| 289 |
+
namedtype.NamedType('acIssuer', rfc3280.GeneralName()),
|
| 290 |
+
namedtype.NamedType('acSerial', univ.Integer()),
|
| 291 |
+
namedtype.NamedType('attrs', univ.SequenceOf(componentType=rfc3280.Attribute()))
|
| 292 |
+
)
|
| 293 |
+
|
| 294 |
+
id_aca_group = _buildOid(id_aca, 4)
|
| 295 |
+
|
| 296 |
+
id_pe_ac_proxying = _buildOid(rfc3280.id_pe, 10)
|
| 297 |
+
|
| 298 |
+
|
| 299 |
+
class SvceAuthInfo(univ.Sequence):
|
| 300 |
+
pass
|
| 301 |
+
|
| 302 |
+
|
| 303 |
+
SvceAuthInfo.componentType = namedtype.NamedTypes(
|
| 304 |
+
namedtype.NamedType('service', rfc3280.GeneralName()),
|
| 305 |
+
namedtype.NamedType('ident', rfc3280.GeneralName()),
|
| 306 |
+
namedtype.OptionalNamedType('authInfo', univ.OctetString())
|
| 307 |
+
)
|
| 308 |
+
|
| 309 |
+
|
| 310 |
+
class IetfAttrSyntax(univ.Sequence):
|
| 311 |
+
pass
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
IetfAttrSyntax.componentType = namedtype.NamedTypes(
|
| 315 |
+
namedtype.OptionalNamedType(
|
| 316 |
+
'policyAuthority', rfc3280.GeneralNames().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))
|
| 317 |
+
),
|
| 318 |
+
namedtype.NamedType(
|
| 319 |
+
'values', univ.SequenceOf(
|
| 320 |
+
componentType=univ.Choice(
|
| 321 |
+
componentType=namedtype.NamedTypes(
|
| 322 |
+
namedtype.NamedType('octets', univ.OctetString()),
|
| 323 |
+
namedtype.NamedType('oid', univ.ObjectIdentifier()),
|
| 324 |
+
namedtype.NamedType('string', char.UTF8String())
|
| 325 |
+
)
|
| 326 |
+
)
|
| 327 |
+
)
|
| 328 |
+
)
|
| 329 |
+
)
|
| 330 |
+
|
| 331 |
+
id_aca_encAttrs = _buildOid(id_aca, 6)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3414.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# This file is part of pyasn1-modules software.
|
| 3 |
+
#
|
| 4 |
+
# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
|
| 5 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 6 |
+
#
|
| 7 |
+
# SNMPv3 message syntax
|
| 8 |
+
#
|
| 9 |
+
# ASN.1 source from:
|
| 10 |
+
# http://www.ietf.org/rfc/rfc3414.txt
|
| 11 |
+
#
|
| 12 |
+
from pyasn1.type import constraint
|
| 13 |
+
from pyasn1.type import namedtype
|
| 14 |
+
from pyasn1.type import univ
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class UsmSecurityParameters(univ.Sequence):
|
| 18 |
+
componentType = namedtype.NamedTypes(
|
| 19 |
+
namedtype.NamedType('msgAuthoritativeEngineID', univ.OctetString()),
|
| 20 |
+
namedtype.NamedType('msgAuthoritativeEngineBoots',
|
| 21 |
+
univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 2147483647))),
|
| 22 |
+
namedtype.NamedType('msgAuthoritativeEngineTime',
|
| 23 |
+
univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 2147483647))),
|
| 24 |
+
namedtype.NamedType('msgUserName',
|
| 25 |
+
univ.OctetString().subtype(subtypeSpec=constraint.ValueSizeConstraint(0, 32))),
|
| 26 |
+
namedtype.NamedType('msgAuthenticationParameters', univ.OctetString()),
|
| 27 |
+
namedtype.NamedType('msgPrivacyParameters', univ.OctetString())
|
| 28 |
+
)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3537.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# This file is part of pyasn1-modules software.
|
| 3 |
+
#
|
| 4 |
+
# Created by Russ Housley.
|
| 5 |
+
#
|
| 6 |
+
# Copyright (c) 2019, Vigil Security, LLC
|
| 7 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 8 |
+
#
|
| 9 |
+
# SEED Encryption Algorithm in CMS
|
| 10 |
+
#
|
| 11 |
+
# ASN.1 source from:
|
| 12 |
+
# https://www.rfc-editor.org/rfc/rfc4010.txt
|
| 13 |
+
#
|
| 14 |
+
|
| 15 |
+
from pyasn1.type import constraint
|
| 16 |
+
from pyasn1.type import univ
|
| 17 |
+
|
| 18 |
+
from pyasn1_modules import rfc5280
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
id_alg_HMACwith3DESwrap = univ.ObjectIdentifier('1.2.840.113549.1.9.16.3.11')
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
id_alg_HMACwithAESwrap = univ.ObjectIdentifier('1.2.840.113549.1.9.16.3.12')
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
# Update the Algorithm Identifier map in rfc5280.py.
|
| 28 |
+
|
| 29 |
+
_algorithmIdentifierMapUpdate = {
|
| 30 |
+
id_alg_HMACwith3DESwrap: univ.Null(""),
|
| 31 |
+
id_alg_HMACwithAESwrap: univ.Null(""),
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3560.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# This file is part of pyasn1-modules software.
|
| 3 |
+
#
|
| 4 |
+
# Created by Russ Housley.
|
| 5 |
+
#
|
| 6 |
+
# Copyright (c) 2019, Vigil Security, LLC
|
| 7 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 8 |
+
#
|
| 9 |
+
# RSAES-OAEP Key Transport Algorithm in CMS
|
| 10 |
+
#
|
| 11 |
+
# Notice that all of the things needed in RFC 3560 are also defined
|
| 12 |
+
# in RFC 4055. So, they are all pulled from the RFC 4055 module into
|
| 13 |
+
# this one so that people looking a RFC 3560 can easily find them.
|
| 14 |
+
#
|
| 15 |
+
# ASN.1 source from:
|
| 16 |
+
# https://www.rfc-editor.org/rfc/rfc3560.txt
|
| 17 |
+
#
|
| 18 |
+
|
| 19 |
+
from pyasn1_modules import rfc4055
|
| 20 |
+
|
| 21 |
+
id_sha1 = rfc4055.id_sha1
|
| 22 |
+
|
| 23 |
+
id_sha256 = rfc4055.id_sha256
|
| 24 |
+
|
| 25 |
+
id_sha384 = rfc4055.id_sha384
|
| 26 |
+
|
| 27 |
+
id_sha512 = rfc4055.id_sha512
|
| 28 |
+
|
| 29 |
+
id_mgf1 = rfc4055.id_mgf1
|
| 30 |
+
|
| 31 |
+
rsaEncryption = rfc4055.rsaEncryption
|
| 32 |
+
|
| 33 |
+
id_RSAES_OAEP = rfc4055.id_RSAES_OAEP
|
| 34 |
+
|
| 35 |
+
id_pSpecified = rfc4055.id_pSpecified
|
| 36 |
+
|
| 37 |
+
sha1Identifier = rfc4055.sha1Identifier
|
| 38 |
+
|
| 39 |
+
sha256Identifier = rfc4055.sha256Identifier
|
| 40 |
+
|
| 41 |
+
sha384Identifier = rfc4055.sha384Identifier
|
| 42 |
+
|
| 43 |
+
sha512Identifier = rfc4055.sha512Identifier
|
| 44 |
+
|
| 45 |
+
mgf1SHA1Identifier = rfc4055.mgf1SHA1Identifier
|
| 46 |
+
|
| 47 |
+
mgf1SHA256Identifier = rfc4055.mgf1SHA256Identifier
|
| 48 |
+
|
| 49 |
+
mgf1SHA384Identifier = rfc4055.mgf1SHA384Identifier
|
| 50 |
+
|
| 51 |
+
mgf1SHA512Identifier = rfc4055.mgf1SHA512Identifier
|
| 52 |
+
|
| 53 |
+
pSpecifiedEmptyIdentifier = rfc4055.pSpecifiedEmptyIdentifier
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
class RSAES_OAEP_params(rfc4055.RSAES_OAEP_params):
|
| 57 |
+
pass
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
rSAES_OAEP_Default_Params = RSAES_OAEP_params()
|
| 61 |
+
|
| 62 |
+
rSAES_OAEP_Default_Identifier = rfc4055.rSAES_OAEP_Default_Identifier
|
| 63 |
+
|
| 64 |
+
rSAES_OAEP_SHA256_Params = rfc4055.rSAES_OAEP_SHA256_Params
|
| 65 |
+
|
| 66 |
+
rSAES_OAEP_SHA256_Identifier = rfc4055.rSAES_OAEP_SHA256_Identifier
|
| 67 |
+
|
| 68 |
+
rSAES_OAEP_SHA384_Params = rfc4055.rSAES_OAEP_SHA384_Params
|
| 69 |
+
|
| 70 |
+
rSAES_OAEP_SHA384_Identifier = rfc4055.rSAES_OAEP_SHA384_Identifier
|
| 71 |
+
|
| 72 |
+
rSAES_OAEP_SHA512_Params = rfc4055.rSAES_OAEP_SHA512_Params
|
| 73 |
+
|
| 74 |
+
rSAES_OAEP_SHA512_Identifier = rfc4055.rSAES_OAEP_SHA512_Identifier
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3709.py
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 16 |
+
from pyasn1.type import char
|
| 17 |
+
from pyasn1.type import constraint
|
| 18 |
+
from pyasn1.type import namedtype
|
| 19 |
+
from pyasn1.type import namedval
|
| 20 |
+
from pyasn1.type import tag
|
| 21 |
+
from pyasn1.type import univ
|
| 22 |
+
|
| 23 |
+
from pyasn1_modules import rfc5280
|
| 24 |
+
from pyasn1_modules import rfc6170
|
| 25 |
+
|
| 26 |
+
MAX = float('inf')
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class HashAlgAndValue(univ.Sequence):
|
| 30 |
+
pass
|
| 31 |
+
|
| 32 |
+
HashAlgAndValue.componentType = namedtype.NamedTypes(
|
| 33 |
+
namedtype.NamedType('hashAlg', rfc5280.AlgorithmIdentifier()),
|
| 34 |
+
namedtype.NamedType('hashValue', univ.OctetString())
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
class LogotypeDetails(univ.Sequence):
|
| 39 |
+
pass
|
| 40 |
+
|
| 41 |
+
LogotypeDetails.componentType = namedtype.NamedTypes(
|
| 42 |
+
namedtype.NamedType('mediaType', char.IA5String()),
|
| 43 |
+
namedtype.NamedType('logotypeHash', univ.SequenceOf(
|
| 44 |
+
componentType=HashAlgAndValue()).subtype(
|
| 45 |
+
sizeSpec=constraint.ValueSizeConstraint(1, MAX))),
|
| 46 |
+
namedtype.NamedType('logotypeURI', univ.SequenceOf(
|
| 47 |
+
componentType=char.IA5String()).subtype(
|
| 48 |
+
sizeSpec=constraint.ValueSizeConstraint(1, MAX)))
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
class LogotypeAudioInfo(univ.Sequence):
|
| 53 |
+
pass
|
| 54 |
+
|
| 55 |
+
LogotypeAudioInfo.componentType = namedtype.NamedTypes(
|
| 56 |
+
namedtype.NamedType('fileSize', univ.Integer()),
|
| 57 |
+
namedtype.NamedType('playTime', univ.Integer()),
|
| 58 |
+
namedtype.NamedType('channels', univ.Integer()),
|
| 59 |
+
namedtype.OptionalNamedType('sampleRate', univ.Integer().subtype(
|
| 60 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
|
| 61 |
+
namedtype.OptionalNamedType('language', char.IA5String().subtype(
|
| 62 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4)))
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
class LogotypeAudio(univ.Sequence):
|
| 67 |
+
pass
|
| 68 |
+
|
| 69 |
+
LogotypeAudio.componentType = namedtype.NamedTypes(
|
| 70 |
+
namedtype.NamedType('audioDetails', LogotypeDetails()),
|
| 71 |
+
namedtype.OptionalNamedType('audioInfo', LogotypeAudioInfo())
|
| 72 |
+
)
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
class LogotypeImageType(univ.Integer):
|
| 76 |
+
pass
|
| 77 |
+
|
| 78 |
+
LogotypeImageType.namedValues = namedval.NamedValues(
|
| 79 |
+
('grayScale', 0),
|
| 80 |
+
('color', 1)
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
class LogotypeImageResolution(univ.Choice):
|
| 85 |
+
pass
|
| 86 |
+
|
| 87 |
+
LogotypeImageResolution.componentType = namedtype.NamedTypes(
|
| 88 |
+
namedtype.NamedType('numBits',
|
| 89 |
+
univ.Integer().subtype(implicitTag=tag.Tag(
|
| 90 |
+
tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 91 |
+
namedtype.NamedType('tableSize',
|
| 92 |
+
univ.Integer().subtype(implicitTag=tag.Tag(
|
| 93 |
+
tag.tagClassContext, tag.tagFormatSimple, 2)))
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
class LogotypeImageInfo(univ.Sequence):
|
| 98 |
+
pass
|
| 99 |
+
|
| 100 |
+
LogotypeImageInfo.componentType = namedtype.NamedTypes(
|
| 101 |
+
namedtype.DefaultedNamedType('type', LogotypeImageType().subtype(
|
| 102 |
+
implicitTag=tag.Tag(tag.tagClassContext,
|
| 103 |
+
tag.tagFormatSimple, 0)).subtype(value='color')),
|
| 104 |
+
namedtype.NamedType('fileSize', univ.Integer()),
|
| 105 |
+
namedtype.NamedType('xSize', univ.Integer()),
|
| 106 |
+
namedtype.NamedType('ySize', univ.Integer()),
|
| 107 |
+
namedtype.OptionalNamedType('resolution', LogotypeImageResolution()),
|
| 108 |
+
namedtype.OptionalNamedType('language', char.IA5String().subtype(
|
| 109 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4)))
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
class LogotypeImage(univ.Sequence):
|
| 114 |
+
pass
|
| 115 |
+
|
| 116 |
+
LogotypeImage.componentType = namedtype.NamedTypes(
|
| 117 |
+
namedtype.NamedType('imageDetails', LogotypeDetails()),
|
| 118 |
+
namedtype.OptionalNamedType('imageInfo', LogotypeImageInfo())
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
class LogotypeData(univ.Sequence):
|
| 123 |
+
pass
|
| 124 |
+
|
| 125 |
+
LogotypeData.componentType = namedtype.NamedTypes(
|
| 126 |
+
namedtype.OptionalNamedType('image', univ.SequenceOf(
|
| 127 |
+
componentType=LogotypeImage())),
|
| 128 |
+
namedtype.OptionalNamedType('audio', univ.SequenceOf(
|
| 129 |
+
componentType=LogotypeAudio()).subtype(
|
| 130 |
+
implicitTag=tag.Tag(tag.tagClassContext,
|
| 131 |
+
tag.tagFormatSimple, 1)))
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
class LogotypeReference(univ.Sequence):
|
| 136 |
+
pass
|
| 137 |
+
|
| 138 |
+
LogotypeReference.componentType = namedtype.NamedTypes(
|
| 139 |
+
namedtype.NamedType('refStructHash', univ.SequenceOf(
|
| 140 |
+
componentType=HashAlgAndValue()).subtype(
|
| 141 |
+
sizeSpec=constraint.ValueSizeConstraint(1, MAX))),
|
| 142 |
+
namedtype.NamedType('refStructURI', univ.SequenceOf(
|
| 143 |
+
componentType=char.IA5String()).subtype(
|
| 144 |
+
sizeSpec=constraint.ValueSizeConstraint(1, MAX)))
|
| 145 |
+
)
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
class LogotypeInfo(univ.Choice):
|
| 149 |
+
pass
|
| 150 |
+
|
| 151 |
+
LogotypeInfo.componentType = namedtype.NamedTypes(
|
| 152 |
+
namedtype.NamedType('direct',
|
| 153 |
+
LogotypeData().subtype(implicitTag=tag.Tag(tag.tagClassContext,
|
| 154 |
+
tag.tagFormatConstructed, 0))),
|
| 155 |
+
namedtype.NamedType('indirect', LogotypeReference().subtype(
|
| 156 |
+
implicitTag=tag.Tag(tag.tagClassContext,
|
| 157 |
+
tag.tagFormatConstructed, 1)))
|
| 158 |
+
)
|
| 159 |
+
|
| 160 |
+
# Other logotype type and associated object identifiers
|
| 161 |
+
|
| 162 |
+
id_logo_background = univ.ObjectIdentifier('1.3.6.1.5.5.7.20.2')
|
| 163 |
+
|
| 164 |
+
id_logo_loyalty = univ.ObjectIdentifier('1.3.6.1.5.5.7.20.1')
|
| 165 |
+
|
| 166 |
+
id_logo_certImage = rfc6170.id_logo_certImage
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
class OtherLogotypeInfo(univ.Sequence):
|
| 170 |
+
pass
|
| 171 |
+
|
| 172 |
+
OtherLogotypeInfo.componentType = namedtype.NamedTypes(
|
| 173 |
+
namedtype.NamedType('logotypeType', univ.ObjectIdentifier()),
|
| 174 |
+
namedtype.NamedType('info', LogotypeInfo())
|
| 175 |
+
)
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
# Logotype Certificate Extension
|
| 179 |
+
|
| 180 |
+
id_pe_logotype = univ.ObjectIdentifier('1.3.6.1.5.5.7.1.12')
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
class LogotypeExtn(univ.Sequence):
|
| 184 |
+
pass
|
| 185 |
+
|
| 186 |
+
LogotypeExtn.componentType = namedtype.NamedTypes(
|
| 187 |
+
namedtype.OptionalNamedType('communityLogos', univ.SequenceOf(
|
| 188 |
+
componentType=LogotypeInfo()).subtype(
|
| 189 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 190 |
+
namedtype.OptionalNamedType('issuerLogo', LogotypeInfo().subtype(
|
| 191 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),
|
| 192 |
+
namedtype.OptionalNamedType('subjectLogo', LogotypeInfo().subtype(
|
| 193 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2))),
|
| 194 |
+
namedtype.OptionalNamedType('otherLogos', univ.SequenceOf(
|
| 195 |
+
componentType=OtherLogotypeInfo()).subtype(explicitTag=tag.Tag(
|
| 196 |
+
tag.tagClassContext, tag.tagFormatSimple, 3)))
|
| 197 |
+
)
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
# Map of Certificate Extension OIDs to Extensions added to the
|
| 201 |
+
# ones that are in rfc5280.py
|
| 202 |
+
|
| 203 |
+
_certificateExtensionsMapUpdate = {
|
| 204 |
+
id_pe_logotype: LogotypeExtn(),
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
rfc5280.certificateExtensionsMap.update(_certificateExtensionsMapUpdate)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3820.py
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
# Diffie-Hellman Key Agreement
|
| 10 |
+
#
|
| 11 |
+
# ASN.1 source from:
|
| 12 |
+
# https://www.rfc-editor.org/rfc/rfc3820.txt
|
| 13 |
+
#
|
| 14 |
+
|
| 15 |
+
from pyasn1.type import namedtype
|
| 16 |
+
from pyasn1.type import univ
|
| 17 |
+
|
| 18 |
+
from pyasn1_modules import rfc5280
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class ProxyCertPathLengthConstraint(univ.Integer):
|
| 23 |
+
pass
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class ProxyPolicy(univ.Sequence):
|
| 27 |
+
componentType = namedtype.NamedTypes(
|
| 28 |
+
namedtype.NamedType('policyLanguage', univ.ObjectIdentifier()),
|
| 29 |
+
namedtype.OptionalNamedType('policy', univ.OctetString())
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
class ProxyCertInfoExtension(univ.Sequence):
|
| 34 |
+
componentType = namedtype.NamedTypes(
|
| 35 |
+
namedtype.OptionalNamedType('pCPathLenConstraint',
|
| 36 |
+
ProxyCertPathLengthConstraint()),
|
| 37 |
+
namedtype.NamedType('proxyPolicy', ProxyPolicy())
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
id_pkix = univ.ObjectIdentifier((1, 3, 6, 1, 5, 5, 7, ))
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
id_pe = id_pkix + (1, )
|
| 45 |
+
|
| 46 |
+
id_pe_proxyCertInfo = id_pe + (14, )
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
id_ppl = id_pkix + (21, )
|
| 50 |
+
|
| 51 |
+
id_ppl_anyLanguage = id_ppl + (0, )
|
| 52 |
+
|
| 53 |
+
id_ppl_inheritAll = id_ppl + (1, )
|
| 54 |
+
|
| 55 |
+
id_ppl_independent = id_ppl + (2, )
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
# Map of Certificate Extension OIDs to Extensions added to the
|
| 59 |
+
# ones that are in rfc5280.py
|
| 60 |
+
|
| 61 |
+
_certificateExtensionsMapUpdate = {
|
| 62 |
+
id_pe_proxyCertInfo: ProxyCertInfoExtension(),
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
rfc5280.certificateExtensionsMap.update(_certificateExtensionsMapUpdate)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc3852.py
ADDED
|
@@ -0,0 +1,706 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding: utf-8
|
| 2 |
+
#
|
| 3 |
+
# This file is part of pyasn1-modules software.
|
| 4 |
+
#
|
| 5 |
+
# Created by Stanisław Pitucha with asn1ate tool.
|
| 6 |
+
# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
|
| 7 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 8 |
+
#
|
| 9 |
+
# Cryptographic Message Syntax (CMS)
|
| 10 |
+
#
|
| 11 |
+
# ASN.1 source from:
|
| 12 |
+
# http://www.ietf.org/rfc/rfc3852.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 tag
|
| 18 |
+
from pyasn1.type import univ
|
| 19 |
+
from pyasn1.type import useful
|
| 20 |
+
|
| 21 |
+
from pyasn1_modules import rfc3280
|
| 22 |
+
from pyasn1_modules import rfc3281
|
| 23 |
+
|
| 24 |
+
MAX = float('inf')
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _buildOid(*components):
|
| 28 |
+
output = []
|
| 29 |
+
for x in tuple(components):
|
| 30 |
+
if isinstance(x, univ.ObjectIdentifier):
|
| 31 |
+
output.extend(list(x))
|
| 32 |
+
else:
|
| 33 |
+
output.append(int(x))
|
| 34 |
+
|
| 35 |
+
return univ.ObjectIdentifier(output)
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
class AttributeValue(univ.Any):
|
| 39 |
+
pass
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class Attribute(univ.Sequence):
|
| 43 |
+
pass
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
Attribute.componentType = namedtype.NamedTypes(
|
| 47 |
+
namedtype.NamedType('attrType', univ.ObjectIdentifier()),
|
| 48 |
+
namedtype.NamedType('attrValues', univ.SetOf(componentType=AttributeValue()))
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
class SignedAttributes(univ.SetOf):
|
| 53 |
+
pass
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
SignedAttributes.componentType = Attribute()
|
| 57 |
+
SignedAttributes.sizeSpec = constraint.ValueSizeConstraint(1, MAX)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
class OtherRevocationInfoFormat(univ.Sequence):
|
| 61 |
+
pass
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
OtherRevocationInfoFormat.componentType = namedtype.NamedTypes(
|
| 65 |
+
namedtype.NamedType('otherRevInfoFormat', univ.ObjectIdentifier()),
|
| 66 |
+
namedtype.NamedType('otherRevInfo', univ.Any())
|
| 67 |
+
)
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
class RevocationInfoChoice(univ.Choice):
|
| 71 |
+
pass
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
RevocationInfoChoice.componentType = namedtype.NamedTypes(
|
| 75 |
+
namedtype.NamedType('crl', rfc3280.CertificateList()),
|
| 76 |
+
namedtype.NamedType('other', OtherRevocationInfoFormat().subtype(
|
| 77 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1)))
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
class RevocationInfoChoices(univ.SetOf):
|
| 82 |
+
pass
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
RevocationInfoChoices.componentType = RevocationInfoChoice()
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
class OtherKeyAttribute(univ.Sequence):
|
| 89 |
+
pass
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
OtherKeyAttribute.componentType = namedtype.NamedTypes(
|
| 93 |
+
namedtype.NamedType('keyAttrId', univ.ObjectIdentifier()),
|
| 94 |
+
namedtype.OptionalNamedType('keyAttr', univ.Any())
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
id_signedData = _buildOid(1, 2, 840, 113549, 1, 7, 2)
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
class KeyEncryptionAlgorithmIdentifier(rfc3280.AlgorithmIdentifier):
|
| 101 |
+
pass
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
class EncryptedKey(univ.OctetString):
|
| 105 |
+
pass
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
class CMSVersion(univ.Integer):
|
| 109 |
+
pass
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
CMSVersion.namedValues = namedval.NamedValues(
|
| 113 |
+
('v0', 0),
|
| 114 |
+
('v1', 1),
|
| 115 |
+
('v2', 2),
|
| 116 |
+
('v3', 3),
|
| 117 |
+
('v4', 4),
|
| 118 |
+
('v5', 5)
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
class KEKIdentifier(univ.Sequence):
|
| 123 |
+
pass
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
KEKIdentifier.componentType = namedtype.NamedTypes(
|
| 127 |
+
namedtype.NamedType('keyIdentifier', univ.OctetString()),
|
| 128 |
+
namedtype.OptionalNamedType('date', useful.GeneralizedTime()),
|
| 129 |
+
namedtype.OptionalNamedType('other', OtherKeyAttribute())
|
| 130 |
+
)
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
class KEKRecipientInfo(univ.Sequence):
|
| 134 |
+
pass
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
KEKRecipientInfo.componentType = namedtype.NamedTypes(
|
| 138 |
+
namedtype.NamedType('version', CMSVersion()),
|
| 139 |
+
namedtype.NamedType('kekid', KEKIdentifier()),
|
| 140 |
+
namedtype.NamedType('keyEncryptionAlgorithm', KeyEncryptionAlgorithmIdentifier()),
|
| 141 |
+
namedtype.NamedType('encryptedKey', EncryptedKey())
|
| 142 |
+
)
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
class KeyDerivationAlgorithmIdentifier(rfc3280.AlgorithmIdentifier):
|
| 146 |
+
pass
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
class PasswordRecipientInfo(univ.Sequence):
|
| 150 |
+
pass
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
PasswordRecipientInfo.componentType = namedtype.NamedTypes(
|
| 154 |
+
namedtype.NamedType('version', CMSVersion()),
|
| 155 |
+
namedtype.OptionalNamedType('keyDerivationAlgorithm', KeyDerivationAlgorithmIdentifier().subtype(
|
| 156 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 157 |
+
namedtype.NamedType('keyEncryptionAlgorithm', KeyEncryptionAlgorithmIdentifier()),
|
| 158 |
+
namedtype.NamedType('encryptedKey', EncryptedKey())
|
| 159 |
+
)
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
class OtherRecipientInfo(univ.Sequence):
|
| 163 |
+
pass
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
OtherRecipientInfo.componentType = namedtype.NamedTypes(
|
| 167 |
+
namedtype.NamedType('oriType', univ.ObjectIdentifier()),
|
| 168 |
+
namedtype.NamedType('oriValue', univ.Any())
|
| 169 |
+
)
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
class IssuerAndSerialNumber(univ.Sequence):
|
| 173 |
+
pass
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
IssuerAndSerialNumber.componentType = namedtype.NamedTypes(
|
| 177 |
+
namedtype.NamedType('issuer', rfc3280.Name()),
|
| 178 |
+
namedtype.NamedType('serialNumber', rfc3280.CertificateSerialNumber())
|
| 179 |
+
)
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
class SubjectKeyIdentifier(univ.OctetString):
|
| 183 |
+
pass
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
class RecipientKeyIdentifier(univ.Sequence):
|
| 187 |
+
pass
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
RecipientKeyIdentifier.componentType = namedtype.NamedTypes(
|
| 191 |
+
namedtype.NamedType('subjectKeyIdentifier', SubjectKeyIdentifier()),
|
| 192 |
+
namedtype.OptionalNamedType('date', useful.GeneralizedTime()),
|
| 193 |
+
namedtype.OptionalNamedType('other', OtherKeyAttribute())
|
| 194 |
+
)
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
class KeyAgreeRecipientIdentifier(univ.Choice):
|
| 198 |
+
pass
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
KeyAgreeRecipientIdentifier.componentType = namedtype.NamedTypes(
|
| 202 |
+
namedtype.NamedType('issuerAndSerialNumber', IssuerAndSerialNumber()),
|
| 203 |
+
namedtype.NamedType('rKeyId', RecipientKeyIdentifier().subtype(
|
| 204 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))
|
| 205 |
+
)
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
class RecipientEncryptedKey(univ.Sequence):
|
| 209 |
+
pass
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
RecipientEncryptedKey.componentType = namedtype.NamedTypes(
|
| 213 |
+
namedtype.NamedType('rid', KeyAgreeRecipientIdentifier()),
|
| 214 |
+
namedtype.NamedType('encryptedKey', EncryptedKey())
|
| 215 |
+
)
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
class RecipientEncryptedKeys(univ.SequenceOf):
|
| 219 |
+
pass
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
RecipientEncryptedKeys.componentType = RecipientEncryptedKey()
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
class UserKeyingMaterial(univ.OctetString):
|
| 226 |
+
pass
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
class OriginatorPublicKey(univ.Sequence):
|
| 230 |
+
pass
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
OriginatorPublicKey.componentType = namedtype.NamedTypes(
|
| 234 |
+
namedtype.NamedType('algorithm', rfc3280.AlgorithmIdentifier()),
|
| 235 |
+
namedtype.NamedType('publicKey', univ.BitString())
|
| 236 |
+
)
|
| 237 |
+
|
| 238 |
+
|
| 239 |
+
class OriginatorIdentifierOrKey(univ.Choice):
|
| 240 |
+
pass
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
OriginatorIdentifierOrKey.componentType = namedtype.NamedTypes(
|
| 244 |
+
namedtype.NamedType('issuerAndSerialNumber', IssuerAndSerialNumber()),
|
| 245 |
+
namedtype.NamedType('subjectKeyIdentifier', SubjectKeyIdentifier().subtype(
|
| 246 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 247 |
+
namedtype.NamedType('originatorKey', OriginatorPublicKey().subtype(
|
| 248 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1)))
|
| 249 |
+
)
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
class KeyAgreeRecipientInfo(univ.Sequence):
|
| 253 |
+
pass
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
KeyAgreeRecipientInfo.componentType = namedtype.NamedTypes(
|
| 257 |
+
namedtype.NamedType('version', CMSVersion()),
|
| 258 |
+
namedtype.NamedType('originator', OriginatorIdentifierOrKey().subtype(
|
| 259 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 260 |
+
namedtype.OptionalNamedType('ukm', UserKeyingMaterial().subtype(
|
| 261 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 262 |
+
namedtype.NamedType('keyEncryptionAlgorithm', KeyEncryptionAlgorithmIdentifier()),
|
| 263 |
+
namedtype.NamedType('recipientEncryptedKeys', RecipientEncryptedKeys())
|
| 264 |
+
)
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
class RecipientIdentifier(univ.Choice):
|
| 268 |
+
pass
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
RecipientIdentifier.componentType = namedtype.NamedTypes(
|
| 272 |
+
namedtype.NamedType('issuerAndSerialNumber', IssuerAndSerialNumber()),
|
| 273 |
+
namedtype.NamedType('subjectKeyIdentifier', SubjectKeyIdentifier().subtype(
|
| 274 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
|
| 275 |
+
)
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
class KeyTransRecipientInfo(univ.Sequence):
|
| 279 |
+
pass
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
KeyTransRecipientInfo.componentType = namedtype.NamedTypes(
|
| 283 |
+
namedtype.NamedType('version', CMSVersion()),
|
| 284 |
+
namedtype.NamedType('rid', RecipientIdentifier()),
|
| 285 |
+
namedtype.NamedType('keyEncryptionAlgorithm', KeyEncryptionAlgorithmIdentifier()),
|
| 286 |
+
namedtype.NamedType('encryptedKey', EncryptedKey())
|
| 287 |
+
)
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
class RecipientInfo(univ.Choice):
|
| 291 |
+
pass
|
| 292 |
+
|
| 293 |
+
|
| 294 |
+
RecipientInfo.componentType = namedtype.NamedTypes(
|
| 295 |
+
namedtype.NamedType('ktri', KeyTransRecipientInfo()),
|
| 296 |
+
namedtype.NamedType('kari', KeyAgreeRecipientInfo().subtype(
|
| 297 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),
|
| 298 |
+
namedtype.NamedType('kekri', KEKRecipientInfo().subtype(
|
| 299 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2))),
|
| 300 |
+
namedtype.NamedType('pwri', PasswordRecipientInfo().subtype(
|
| 301 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3))),
|
| 302 |
+
namedtype.NamedType('ori', OtherRecipientInfo().subtype(
|
| 303 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 4)))
|
| 304 |
+
)
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
class RecipientInfos(univ.SetOf):
|
| 308 |
+
pass
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
RecipientInfos.componentType = RecipientInfo()
|
| 312 |
+
RecipientInfos.sizeSpec = constraint.ValueSizeConstraint(1, MAX)
|
| 313 |
+
|
| 314 |
+
|
| 315 |
+
class DigestAlgorithmIdentifier(rfc3280.AlgorithmIdentifier):
|
| 316 |
+
pass
|
| 317 |
+
|
| 318 |
+
|
| 319 |
+
class Signature(univ.BitString):
|
| 320 |
+
pass
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
class SignerIdentifier(univ.Choice):
|
| 324 |
+
pass
|
| 325 |
+
|
| 326 |
+
|
| 327 |
+
SignerIdentifier.componentType = namedtype.NamedTypes(
|
| 328 |
+
namedtype.NamedType('issuerAndSerialNumber', IssuerAndSerialNumber()),
|
| 329 |
+
namedtype.NamedType('subjectKeyIdentifier', SubjectKeyIdentifier().subtype(
|
| 330 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
|
| 331 |
+
)
|
| 332 |
+
|
| 333 |
+
|
| 334 |
+
class UnprotectedAttributes(univ.SetOf):
|
| 335 |
+
pass
|
| 336 |
+
|
| 337 |
+
|
| 338 |
+
UnprotectedAttributes.componentType = Attribute()
|
| 339 |
+
UnprotectedAttributes.sizeSpec = constraint.ValueSizeConstraint(1, MAX)
|
| 340 |
+
|
| 341 |
+
|
| 342 |
+
class ContentType(univ.ObjectIdentifier):
|
| 343 |
+
pass
|
| 344 |
+
|
| 345 |
+
|
| 346 |
+
class EncryptedContent(univ.OctetString):
|
| 347 |
+
pass
|
| 348 |
+
|
| 349 |
+
|
| 350 |
+
class ContentEncryptionAlgorithmIdentifier(rfc3280.AlgorithmIdentifier):
|
| 351 |
+
pass
|
| 352 |
+
|
| 353 |
+
|
| 354 |
+
class EncryptedContentInfo(univ.Sequence):
|
| 355 |
+
pass
|
| 356 |
+
|
| 357 |
+
|
| 358 |
+
EncryptedContentInfo.componentType = namedtype.NamedTypes(
|
| 359 |
+
namedtype.NamedType('contentType', ContentType()),
|
| 360 |
+
namedtype.NamedType('contentEncryptionAlgorithm', ContentEncryptionAlgorithmIdentifier()),
|
| 361 |
+
namedtype.OptionalNamedType('encryptedContent', EncryptedContent().subtype(
|
| 362 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
|
| 363 |
+
)
|
| 364 |
+
|
| 365 |
+
|
| 366 |
+
class EncryptedData(univ.Sequence):
|
| 367 |
+
pass
|
| 368 |
+
|
| 369 |
+
|
| 370 |
+
EncryptedData.componentType = namedtype.NamedTypes(
|
| 371 |
+
namedtype.NamedType('version', CMSVersion()),
|
| 372 |
+
namedtype.NamedType('encryptedContentInfo', EncryptedContentInfo()),
|
| 373 |
+
namedtype.OptionalNamedType('unprotectedAttrs', UnprotectedAttributes().subtype(
|
| 374 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 375 |
+
)
|
| 376 |
+
|
| 377 |
+
id_contentType = _buildOid(1, 2, 840, 113549, 1, 9, 3)
|
| 378 |
+
|
| 379 |
+
id_data = _buildOid(1, 2, 840, 113549, 1, 7, 1)
|
| 380 |
+
|
| 381 |
+
id_messageDigest = _buildOid(1, 2, 840, 113549, 1, 9, 4)
|
| 382 |
+
|
| 383 |
+
|
| 384 |
+
class DigestAlgorithmIdentifiers(univ.SetOf):
|
| 385 |
+
pass
|
| 386 |
+
|
| 387 |
+
|
| 388 |
+
DigestAlgorithmIdentifiers.componentType = DigestAlgorithmIdentifier()
|
| 389 |
+
|
| 390 |
+
|
| 391 |
+
class EncapsulatedContentInfo(univ.Sequence):
|
| 392 |
+
pass
|
| 393 |
+
|
| 394 |
+
|
| 395 |
+
EncapsulatedContentInfo.componentType = namedtype.NamedTypes(
|
| 396 |
+
namedtype.NamedType('eContentType', ContentType()),
|
| 397 |
+
namedtype.OptionalNamedType('eContent', univ.OctetString().subtype(
|
| 398 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
|
| 399 |
+
)
|
| 400 |
+
|
| 401 |
+
|
| 402 |
+
class Digest(univ.OctetString):
|
| 403 |
+
pass
|
| 404 |
+
|
| 405 |
+
|
| 406 |
+
class DigestedData(univ.Sequence):
|
| 407 |
+
pass
|
| 408 |
+
|
| 409 |
+
|
| 410 |
+
DigestedData.componentType = namedtype.NamedTypes(
|
| 411 |
+
namedtype.NamedType('version', CMSVersion()),
|
| 412 |
+
namedtype.NamedType('digestAlgorithm', DigestAlgorithmIdentifier()),
|
| 413 |
+
namedtype.NamedType('encapContentInfo', EncapsulatedContentInfo()),
|
| 414 |
+
namedtype.NamedType('digest', Digest())
|
| 415 |
+
)
|
| 416 |
+
|
| 417 |
+
|
| 418 |
+
class ContentInfo(univ.Sequence):
|
| 419 |
+
pass
|
| 420 |
+
|
| 421 |
+
|
| 422 |
+
ContentInfo.componentType = namedtype.NamedTypes(
|
| 423 |
+
namedtype.NamedType('contentType', ContentType()),
|
| 424 |
+
namedtype.NamedType('content', univ.Any().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
|
| 425 |
+
)
|
| 426 |
+
|
| 427 |
+
|
| 428 |
+
class UnauthAttributes(univ.SetOf):
|
| 429 |
+
pass
|
| 430 |
+
|
| 431 |
+
|
| 432 |
+
UnauthAttributes.componentType = Attribute()
|
| 433 |
+
UnauthAttributes.sizeSpec = constraint.ValueSizeConstraint(1, MAX)
|
| 434 |
+
|
| 435 |
+
|
| 436 |
+
class ExtendedCertificateInfo(univ.Sequence):
|
| 437 |
+
pass
|
| 438 |
+
|
| 439 |
+
|
| 440 |
+
ExtendedCertificateInfo.componentType = namedtype.NamedTypes(
|
| 441 |
+
namedtype.NamedType('version', CMSVersion()),
|
| 442 |
+
namedtype.NamedType('certificate', rfc3280.Certificate()),
|
| 443 |
+
namedtype.NamedType('attributes', UnauthAttributes())
|
| 444 |
+
)
|
| 445 |
+
|
| 446 |
+
|
| 447 |
+
class SignatureAlgorithmIdentifier(rfc3280.AlgorithmIdentifier):
|
| 448 |
+
pass
|
| 449 |
+
|
| 450 |
+
|
| 451 |
+
class ExtendedCertificate(univ.Sequence):
|
| 452 |
+
pass
|
| 453 |
+
|
| 454 |
+
|
| 455 |
+
ExtendedCertificate.componentType = namedtype.NamedTypes(
|
| 456 |
+
namedtype.NamedType('extendedCertificateInfo', ExtendedCertificateInfo()),
|
| 457 |
+
namedtype.NamedType('signatureAlgorithm', SignatureAlgorithmIdentifier()),
|
| 458 |
+
namedtype.NamedType('signature', Signature())
|
| 459 |
+
)
|
| 460 |
+
|
| 461 |
+
|
| 462 |
+
class OtherCertificateFormat(univ.Sequence):
|
| 463 |
+
pass
|
| 464 |
+
|
| 465 |
+
|
| 466 |
+
OtherCertificateFormat.componentType = namedtype.NamedTypes(
|
| 467 |
+
namedtype.NamedType('otherCertFormat', univ.ObjectIdentifier()),
|
| 468 |
+
namedtype.NamedType('otherCert', univ.Any())
|
| 469 |
+
)
|
| 470 |
+
|
| 471 |
+
|
| 472 |
+
class AttributeCertificateV2(rfc3281.AttributeCertificate):
|
| 473 |
+
pass
|
| 474 |
+
|
| 475 |
+
|
| 476 |
+
class AttCertVersionV1(univ.Integer):
|
| 477 |
+
pass
|
| 478 |
+
|
| 479 |
+
|
| 480 |
+
AttCertVersionV1.namedValues = namedval.NamedValues(
|
| 481 |
+
('v1', 0)
|
| 482 |
+
)
|
| 483 |
+
|
| 484 |
+
|
| 485 |
+
class AttributeCertificateInfoV1(univ.Sequence):
|
| 486 |
+
pass
|
| 487 |
+
|
| 488 |
+
|
| 489 |
+
AttributeCertificateInfoV1.componentType = namedtype.NamedTypes(
|
| 490 |
+
namedtype.DefaultedNamedType('version', AttCertVersionV1().subtype(value="v1")),
|
| 491 |
+
namedtype.NamedType(
|
| 492 |
+
'subject', univ.Choice(
|
| 493 |
+
componentType=namedtype.NamedTypes(
|
| 494 |
+
namedtype.NamedType('baseCertificateID', rfc3281.IssuerSerial().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 495 |
+
namedtype.NamedType('subjectName', rfc3280.GeneralNames().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 496 |
+
)
|
| 497 |
+
)
|
| 498 |
+
),
|
| 499 |
+
namedtype.NamedType('issuer', rfc3280.GeneralNames()),
|
| 500 |
+
namedtype.NamedType('signature', rfc3280.AlgorithmIdentifier()),
|
| 501 |
+
namedtype.NamedType('serialNumber', rfc3280.CertificateSerialNumber()),
|
| 502 |
+
namedtype.NamedType('attCertValidityPeriod', rfc3281.AttCertValidityPeriod()),
|
| 503 |
+
namedtype.NamedType('attributes', univ.SequenceOf(componentType=rfc3280.Attribute())),
|
| 504 |
+
namedtype.OptionalNamedType('issuerUniqueID', rfc3280.UniqueIdentifier()),
|
| 505 |
+
namedtype.OptionalNamedType('extensions', rfc3280.Extensions())
|
| 506 |
+
)
|
| 507 |
+
|
| 508 |
+
|
| 509 |
+
class AttributeCertificateV1(univ.Sequence):
|
| 510 |
+
pass
|
| 511 |
+
|
| 512 |
+
|
| 513 |
+
AttributeCertificateV1.componentType = namedtype.NamedTypes(
|
| 514 |
+
namedtype.NamedType('acInfo', AttributeCertificateInfoV1()),
|
| 515 |
+
namedtype.NamedType('signatureAlgorithm', rfc3280.AlgorithmIdentifier()),
|
| 516 |
+
namedtype.NamedType('signature', univ.BitString())
|
| 517 |
+
)
|
| 518 |
+
|
| 519 |
+
|
| 520 |
+
class CertificateChoices(univ.Choice):
|
| 521 |
+
pass
|
| 522 |
+
|
| 523 |
+
|
| 524 |
+
CertificateChoices.componentType = namedtype.NamedTypes(
|
| 525 |
+
namedtype.NamedType('certificate', rfc3280.Certificate()),
|
| 526 |
+
namedtype.NamedType('extendedCertificate', ExtendedCertificate().subtype(
|
| 527 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 528 |
+
namedtype.NamedType('v1AttrCert', AttributeCertificateV1().subtype(
|
| 529 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 530 |
+
namedtype.NamedType('v2AttrCert', AttributeCertificateV2().subtype(
|
| 531 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
|
| 532 |
+
namedtype.NamedType('other', OtherCertificateFormat().subtype(
|
| 533 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3)))
|
| 534 |
+
)
|
| 535 |
+
|
| 536 |
+
|
| 537 |
+
class CertificateSet(univ.SetOf):
|
| 538 |
+
pass
|
| 539 |
+
|
| 540 |
+
|
| 541 |
+
CertificateSet.componentType = CertificateChoices()
|
| 542 |
+
|
| 543 |
+
|
| 544 |
+
class MessageAuthenticationCode(univ.OctetString):
|
| 545 |
+
pass
|
| 546 |
+
|
| 547 |
+
|
| 548 |
+
class UnsignedAttributes(univ.SetOf):
|
| 549 |
+
pass
|
| 550 |
+
|
| 551 |
+
|
| 552 |
+
UnsignedAttributes.componentType = Attribute()
|
| 553 |
+
UnsignedAttributes.sizeSpec = constraint.ValueSizeConstraint(1, MAX)
|
| 554 |
+
|
| 555 |
+
|
| 556 |
+
class SignatureValue(univ.OctetString):
|
| 557 |
+
pass
|
| 558 |
+
|
| 559 |
+
|
| 560 |
+
class SignerInfo(univ.Sequence):
|
| 561 |
+
pass
|
| 562 |
+
|
| 563 |
+
|
| 564 |
+
SignerInfo.componentType = namedtype.NamedTypes(
|
| 565 |
+
namedtype.NamedType('version', CMSVersion()),
|
| 566 |
+
namedtype.NamedType('sid', SignerIdentifier()),
|
| 567 |
+
namedtype.NamedType('digestAlgorithm', DigestAlgorithmIdentifier()),
|
| 568 |
+
namedtype.OptionalNamedType('signedAttrs', SignedAttributes().subtype(
|
| 569 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 570 |
+
namedtype.NamedType('signatureAlgorithm', SignatureAlgorithmIdentifier()),
|
| 571 |
+
namedtype.NamedType('signature', SignatureValue()),
|
| 572 |
+
namedtype.OptionalNamedType('unsignedAttrs', UnsignedAttributes().subtype(
|
| 573 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 574 |
+
)
|
| 575 |
+
|
| 576 |
+
|
| 577 |
+
class SignerInfos(univ.SetOf):
|
| 578 |
+
pass
|
| 579 |
+
|
| 580 |
+
|
| 581 |
+
SignerInfos.componentType = SignerInfo()
|
| 582 |
+
|
| 583 |
+
|
| 584 |
+
class SignedData(univ.Sequence):
|
| 585 |
+
pass
|
| 586 |
+
|
| 587 |
+
|
| 588 |
+
SignedData.componentType = namedtype.NamedTypes(
|
| 589 |
+
namedtype.NamedType('version', CMSVersion()),
|
| 590 |
+
namedtype.NamedType('digestAlgorithms', DigestAlgorithmIdentifiers()),
|
| 591 |
+
namedtype.NamedType('encapContentInfo', EncapsulatedContentInfo()),
|
| 592 |
+
namedtype.OptionalNamedType('certificates', CertificateSet().subtype(
|
| 593 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 594 |
+
namedtype.OptionalNamedType('crls', RevocationInfoChoices().subtype(
|
| 595 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 596 |
+
namedtype.NamedType('signerInfos', SignerInfos())
|
| 597 |
+
)
|
| 598 |
+
|
| 599 |
+
|
| 600 |
+
class MessageAuthenticationCodeAlgorithm(rfc3280.AlgorithmIdentifier):
|
| 601 |
+
pass
|
| 602 |
+
|
| 603 |
+
|
| 604 |
+
class MessageDigest(univ.OctetString):
|
| 605 |
+
pass
|
| 606 |
+
|
| 607 |
+
|
| 608 |
+
class Time(univ.Choice):
|
| 609 |
+
pass
|
| 610 |
+
|
| 611 |
+
|
| 612 |
+
Time.componentType = namedtype.NamedTypes(
|
| 613 |
+
namedtype.NamedType('utcTime', useful.UTCTime()),
|
| 614 |
+
namedtype.NamedType('generalTime', useful.GeneralizedTime())
|
| 615 |
+
)
|
| 616 |
+
|
| 617 |
+
|
| 618 |
+
class OriginatorInfo(univ.Sequence):
|
| 619 |
+
pass
|
| 620 |
+
|
| 621 |
+
|
| 622 |
+
OriginatorInfo.componentType = namedtype.NamedTypes(
|
| 623 |
+
namedtype.OptionalNamedType('certs', CertificateSet().subtype(
|
| 624 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 625 |
+
namedtype.OptionalNamedType('crls', RevocationInfoChoices().subtype(
|
| 626 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 627 |
+
)
|
| 628 |
+
|
| 629 |
+
|
| 630 |
+
class AuthAttributes(univ.SetOf):
|
| 631 |
+
pass
|
| 632 |
+
|
| 633 |
+
|
| 634 |
+
AuthAttributes.componentType = Attribute()
|
| 635 |
+
AuthAttributes.sizeSpec = constraint.ValueSizeConstraint(1, MAX)
|
| 636 |
+
|
| 637 |
+
|
| 638 |
+
class AuthenticatedData(univ.Sequence):
|
| 639 |
+
pass
|
| 640 |
+
|
| 641 |
+
|
| 642 |
+
AuthenticatedData.componentType = namedtype.NamedTypes(
|
| 643 |
+
namedtype.NamedType('version', CMSVersion()),
|
| 644 |
+
namedtype.OptionalNamedType('originatorInfo', OriginatorInfo().subtype(
|
| 645 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 646 |
+
namedtype.NamedType('recipientInfos', RecipientInfos()),
|
| 647 |
+
namedtype.NamedType('macAlgorithm', MessageAuthenticationCodeAlgorithm()),
|
| 648 |
+
namedtype.OptionalNamedType('digestAlgorithm', DigestAlgorithmIdentifier().subtype(
|
| 649 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
|
| 650 |
+
namedtype.NamedType('encapContentInfo', EncapsulatedContentInfo()),
|
| 651 |
+
namedtype.OptionalNamedType('authAttrs', AuthAttributes().subtype(
|
| 652 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
|
| 653 |
+
namedtype.NamedType('mac', MessageAuthenticationCode()),
|
| 654 |
+
namedtype.OptionalNamedType('unauthAttrs', UnauthAttributes().subtype(
|
| 655 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
|
| 656 |
+
)
|
| 657 |
+
|
| 658 |
+
id_ct_contentInfo = _buildOid(1, 2, 840, 113549, 1, 9, 16, 1, 6)
|
| 659 |
+
|
| 660 |
+
id_envelopedData = _buildOid(1, 2, 840, 113549, 1, 7, 3)
|
| 661 |
+
|
| 662 |
+
|
| 663 |
+
class EnvelopedData(univ.Sequence):
|
| 664 |
+
pass
|
| 665 |
+
|
| 666 |
+
|
| 667 |
+
EnvelopedData.componentType = namedtype.NamedTypes(
|
| 668 |
+
namedtype.NamedType('version', CMSVersion()),
|
| 669 |
+
namedtype.OptionalNamedType('originatorInfo', OriginatorInfo().subtype(
|
| 670 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 671 |
+
namedtype.NamedType('recipientInfos', RecipientInfos()),
|
| 672 |
+
namedtype.NamedType('encryptedContentInfo', EncryptedContentInfo()),
|
| 673 |
+
namedtype.OptionalNamedType('unprotectedAttrs', UnprotectedAttributes().subtype(
|
| 674 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 675 |
+
)
|
| 676 |
+
|
| 677 |
+
|
| 678 |
+
class Countersignature(SignerInfo):
|
| 679 |
+
pass
|
| 680 |
+
|
| 681 |
+
|
| 682 |
+
id_digestedData = _buildOid(1, 2, 840, 113549, 1, 7, 5)
|
| 683 |
+
|
| 684 |
+
id_signingTime = _buildOid(1, 2, 840, 113549, 1, 9, 5)
|
| 685 |
+
|
| 686 |
+
|
| 687 |
+
class ExtendedCertificateOrCertificate(univ.Choice):
|
| 688 |
+
pass
|
| 689 |
+
|
| 690 |
+
|
| 691 |
+
ExtendedCertificateOrCertificate.componentType = namedtype.NamedTypes(
|
| 692 |
+
namedtype.NamedType('certificate', rfc3280.Certificate()),
|
| 693 |
+
namedtype.NamedType('extendedCertificate', ExtendedCertificate().subtype(
|
| 694 |
+
implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))
|
| 695 |
+
)
|
| 696 |
+
|
| 697 |
+
id_encryptedData = _buildOid(1, 2, 840, 113549, 1, 7, 6)
|
| 698 |
+
|
| 699 |
+
id_ct_authData = _buildOid(1, 2, 840, 113549, 1, 9, 16, 1, 2)
|
| 700 |
+
|
| 701 |
+
|
| 702 |
+
class SigningTime(Time):
|
| 703 |
+
pass
|
| 704 |
+
|
| 705 |
+
|
| 706 |
+
id_countersignature = _buildOid(1, 2, 840, 113549, 1, 9, 6)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc4043.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
# Internet X.509 Public Key Infrastructure Permanent Identifier
|
| 10 |
+
#
|
| 11 |
+
# ASN.1 source from:
|
| 12 |
+
# https://www.rfc-editor.org/rfc/rfc4043.txt
|
| 13 |
+
#
|
| 14 |
+
|
| 15 |
+
from pyasn1.type import char
|
| 16 |
+
from pyasn1.type import namedtype
|
| 17 |
+
from pyasn1.type import univ
|
| 18 |
+
|
| 19 |
+
from pyasn1_modules import rfc5280
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
id_pkix = univ.ObjectIdentifier((1, 3, 6, 1, 5, 5, 7, ))
|
| 23 |
+
|
| 24 |
+
id_on = id_pkix + (8, )
|
| 25 |
+
|
| 26 |
+
id_on_permanentIdentifier = id_on + (3, )
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class PermanentIdentifier(univ.Sequence):
|
| 30 |
+
componentType = namedtype.NamedTypes(
|
| 31 |
+
namedtype.OptionalNamedType('identifierValue', char.UTF8String()),
|
| 32 |
+
namedtype.OptionalNamedType('assigner', univ.ObjectIdentifier())
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
# Map of Other Name OIDs to Other Name is added to the
|
| 37 |
+
# ones that are in rfc5280.py
|
| 38 |
+
|
| 39 |
+
_anotherNameMapUpdate = {
|
| 40 |
+
id_on_permanentIdentifier: PermanentIdentifier(),
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
rfc5280.anotherNameMap.update(_anotherNameMapUpdate)
|
bertv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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# This file is part of pyasn1-modules software.
|
| 3 |
+
#
|
| 4 |
+
# Created by Russ Housley with a very small amount of assistance from
|
| 5 |
+
# asn1ate v.0.6.0.
|
| 6 |
+
# Modified by Russ Housley to add maps for opentypes.
|
| 7 |
+
#
|
| 8 |
+
# Copyright (c) 2019, Vigil Security, LLC
|
| 9 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 10 |
+
#
|
| 11 |
+
# Additional Algorithms and Identifiers for RSA Cryptography
|
| 12 |
+
# for use in Certificates and CRLs
|
| 13 |
+
#
|
| 14 |
+
# ASN.1 source from:
|
| 15 |
+
# https://www.rfc-editor.org/rfc/rfc4055.txt
|
| 16 |
+
#
|
| 17 |
+
from pyasn1.type import namedtype
|
| 18 |
+
from pyasn1.type import tag
|
| 19 |
+
from pyasn1.type import univ
|
| 20 |
+
|
| 21 |
+
from pyasn1_modules import rfc5280
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def _OID(*components):
|
| 25 |
+
output = []
|
| 26 |
+
for x in tuple(components):
|
| 27 |
+
if isinstance(x, univ.ObjectIdentifier):
|
| 28 |
+
output.extend(list(x))
|
| 29 |
+
else:
|
| 30 |
+
output.append(int(x))
|
| 31 |
+
return univ.ObjectIdentifier(output)
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
id_sha1 = _OID(1, 3, 14, 3, 2, 26)
|
| 35 |
+
|
| 36 |
+
id_sha256 = _OID(2, 16, 840, 1, 101, 3, 4, 2, 1)
|
| 37 |
+
|
| 38 |
+
id_sha384 = _OID(2, 16, 840, 1, 101, 3, 4, 2, 2)
|
| 39 |
+
|
| 40 |
+
id_sha512 = _OID(2, 16, 840, 1, 101, 3, 4, 2, 3)
|
| 41 |
+
|
| 42 |
+
id_sha224 = _OID(2, 16, 840, 1, 101, 3, 4, 2, 4)
|
| 43 |
+
|
| 44 |
+
rsaEncryption = _OID(1, 2, 840, 113549, 1, 1, 1)
|
| 45 |
+
|
| 46 |
+
id_mgf1 = _OID(1, 2, 840, 113549, 1, 1, 8)
|
| 47 |
+
|
| 48 |
+
id_RSAES_OAEP = _OID(1, 2, 840, 113549, 1, 1, 7)
|
| 49 |
+
|
| 50 |
+
id_pSpecified = _OID(1, 2, 840, 113549, 1, 1, 9)
|
| 51 |
+
|
| 52 |
+
id_RSASSA_PSS = _OID(1, 2, 840, 113549, 1, 1, 10)
|
| 53 |
+
|
| 54 |
+
sha256WithRSAEncryption = _OID(1, 2, 840, 113549, 1, 1, 11)
|
| 55 |
+
|
| 56 |
+
sha384WithRSAEncryption = _OID(1, 2, 840, 113549, 1, 1, 12)
|
| 57 |
+
|
| 58 |
+
sha512WithRSAEncryption = _OID(1, 2, 840, 113549, 1, 1, 13)
|
| 59 |
+
|
| 60 |
+
sha224WithRSAEncryption = _OID(1, 2, 840, 113549, 1, 1, 14)
|
| 61 |
+
|
| 62 |
+
sha1Identifier = rfc5280.AlgorithmIdentifier()
|
| 63 |
+
sha1Identifier['algorithm'] = id_sha1
|
| 64 |
+
sha1Identifier['parameters'] = univ.Null("")
|
| 65 |
+
|
| 66 |
+
sha224Identifier = rfc5280.AlgorithmIdentifier()
|
| 67 |
+
sha224Identifier['algorithm'] = id_sha224
|
| 68 |
+
sha224Identifier['parameters'] = univ.Null("")
|
| 69 |
+
|
| 70 |
+
sha256Identifier = rfc5280.AlgorithmIdentifier()
|
| 71 |
+
sha256Identifier['algorithm'] = id_sha256
|
| 72 |
+
sha256Identifier['parameters'] = univ.Null("")
|
| 73 |
+
|
| 74 |
+
sha384Identifier = rfc5280.AlgorithmIdentifier()
|
| 75 |
+
sha384Identifier['algorithm'] = id_sha384
|
| 76 |
+
sha384Identifier['parameters'] = univ.Null("")
|
| 77 |
+
|
| 78 |
+
sha512Identifier = rfc5280.AlgorithmIdentifier()
|
| 79 |
+
sha512Identifier['algorithm'] = id_sha512
|
| 80 |
+
sha512Identifier['parameters'] = univ.Null("")
|
| 81 |
+
|
| 82 |
+
mgf1SHA1Identifier = rfc5280.AlgorithmIdentifier()
|
| 83 |
+
mgf1SHA1Identifier['algorithm'] = id_mgf1
|
| 84 |
+
mgf1SHA1Identifier['parameters'] = sha1Identifier
|
| 85 |
+
|
| 86 |
+
mgf1SHA224Identifier = rfc5280.AlgorithmIdentifier()
|
| 87 |
+
mgf1SHA224Identifier['algorithm'] = id_mgf1
|
| 88 |
+
mgf1SHA224Identifier['parameters'] = sha224Identifier
|
| 89 |
+
|
| 90 |
+
mgf1SHA256Identifier = rfc5280.AlgorithmIdentifier()
|
| 91 |
+
mgf1SHA256Identifier['algorithm'] = id_mgf1
|
| 92 |
+
mgf1SHA256Identifier['parameters'] = sha256Identifier
|
| 93 |
+
|
| 94 |
+
mgf1SHA384Identifier = rfc5280.AlgorithmIdentifier()
|
| 95 |
+
mgf1SHA384Identifier['algorithm'] = id_mgf1
|
| 96 |
+
mgf1SHA384Identifier['parameters'] = sha384Identifier
|
| 97 |
+
|
| 98 |
+
mgf1SHA512Identifier = rfc5280.AlgorithmIdentifier()
|
| 99 |
+
mgf1SHA512Identifier['algorithm'] = id_mgf1
|
| 100 |
+
mgf1SHA512Identifier['parameters'] = sha512Identifier
|
| 101 |
+
|
| 102 |
+
pSpecifiedEmptyIdentifier = rfc5280.AlgorithmIdentifier()
|
| 103 |
+
pSpecifiedEmptyIdentifier['algorithm'] = id_pSpecified
|
| 104 |
+
pSpecifiedEmptyIdentifier['parameters'] = univ.OctetString(value='')
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
class RSAPublicKey(univ.Sequence):
|
| 108 |
+
pass
|
| 109 |
+
|
| 110 |
+
RSAPublicKey.componentType = namedtype.NamedTypes(
|
| 111 |
+
namedtype.NamedType('modulus', univ.Integer()),
|
| 112 |
+
namedtype.NamedType('publicExponent', univ.Integer())
|
| 113 |
+
)
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
class HashAlgorithm(rfc5280.AlgorithmIdentifier):
|
| 117 |
+
pass
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
class MaskGenAlgorithm(rfc5280.AlgorithmIdentifier):
|
| 121 |
+
pass
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
class RSAES_OAEP_params(univ.Sequence):
|
| 125 |
+
pass
|
| 126 |
+
|
| 127 |
+
RSAES_OAEP_params.componentType = namedtype.NamedTypes(
|
| 128 |
+
namedtype.OptionalNamedType('hashFunc', rfc5280.AlgorithmIdentifier().subtype(
|
| 129 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 130 |
+
namedtype.OptionalNamedType('maskGenFunc', rfc5280.AlgorithmIdentifier().subtype(
|
| 131 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),
|
| 132 |
+
namedtype.OptionalNamedType('pSourceFunc', rfc5280.AlgorithmIdentifier().subtype(
|
| 133 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2)))
|
| 134 |
+
)
|
| 135 |
+
|
| 136 |
+
rSAES_OAEP_Default_Params = RSAES_OAEP_params()
|
| 137 |
+
|
| 138 |
+
rSAES_OAEP_Default_Identifier = rfc5280.AlgorithmIdentifier()
|
| 139 |
+
rSAES_OAEP_Default_Identifier['algorithm'] = id_RSAES_OAEP
|
| 140 |
+
rSAES_OAEP_Default_Identifier['parameters'] = rSAES_OAEP_Default_Params
|
| 141 |
+
|
| 142 |
+
rSAES_OAEP_SHA224_Params = RSAES_OAEP_params()
|
| 143 |
+
rSAES_OAEP_SHA224_Params['hashFunc'] = sha224Identifier.subtype(
|
| 144 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0), cloneValueFlag=True)
|
| 145 |
+
rSAES_OAEP_SHA224_Params['maskGenFunc'] = mgf1SHA224Identifier.subtype(
|
| 146 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1), cloneValueFlag=True)
|
| 147 |
+
|
| 148 |
+
rSAES_OAEP_SHA224_Identifier = rfc5280.AlgorithmIdentifier()
|
| 149 |
+
rSAES_OAEP_SHA224_Identifier['algorithm'] = id_RSAES_OAEP
|
| 150 |
+
rSAES_OAEP_SHA224_Identifier['parameters'] = rSAES_OAEP_SHA224_Params
|
| 151 |
+
|
| 152 |
+
rSAES_OAEP_SHA256_Params = RSAES_OAEP_params()
|
| 153 |
+
rSAES_OAEP_SHA256_Params['hashFunc'] = sha256Identifier.subtype(
|
| 154 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0), cloneValueFlag=True)
|
| 155 |
+
rSAES_OAEP_SHA256_Params['maskGenFunc'] = mgf1SHA256Identifier.subtype(
|
| 156 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1), cloneValueFlag=True)
|
| 157 |
+
|
| 158 |
+
rSAES_OAEP_SHA256_Identifier = rfc5280.AlgorithmIdentifier()
|
| 159 |
+
rSAES_OAEP_SHA256_Identifier['algorithm'] = id_RSAES_OAEP
|
| 160 |
+
rSAES_OAEP_SHA256_Identifier['parameters'] = rSAES_OAEP_SHA256_Params
|
| 161 |
+
|
| 162 |
+
rSAES_OAEP_SHA384_Params = RSAES_OAEP_params()
|
| 163 |
+
rSAES_OAEP_SHA384_Params['hashFunc'] = sha384Identifier.subtype(
|
| 164 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0), cloneValueFlag=True)
|
| 165 |
+
rSAES_OAEP_SHA384_Params['maskGenFunc'] = mgf1SHA384Identifier.subtype(
|
| 166 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1), cloneValueFlag=True)
|
| 167 |
+
|
| 168 |
+
rSAES_OAEP_SHA384_Identifier = rfc5280.AlgorithmIdentifier()
|
| 169 |
+
rSAES_OAEP_SHA384_Identifier['algorithm'] = id_RSAES_OAEP
|
| 170 |
+
rSAES_OAEP_SHA384_Identifier['parameters'] = rSAES_OAEP_SHA384_Params
|
| 171 |
+
|
| 172 |
+
rSAES_OAEP_SHA512_Params = RSAES_OAEP_params()
|
| 173 |
+
rSAES_OAEP_SHA512_Params['hashFunc'] = sha512Identifier.subtype(
|
| 174 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0), cloneValueFlag=True)
|
| 175 |
+
rSAES_OAEP_SHA512_Params['maskGenFunc'] = mgf1SHA512Identifier.subtype(
|
| 176 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1), cloneValueFlag=True)
|
| 177 |
+
|
| 178 |
+
rSAES_OAEP_SHA512_Identifier = rfc5280.AlgorithmIdentifier()
|
| 179 |
+
rSAES_OAEP_SHA512_Identifier['algorithm'] = id_RSAES_OAEP
|
| 180 |
+
rSAES_OAEP_SHA512_Identifier['parameters'] = rSAES_OAEP_SHA512_Params
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
class RSASSA_PSS_params(univ.Sequence):
|
| 184 |
+
pass
|
| 185 |
+
|
| 186 |
+
RSASSA_PSS_params.componentType = namedtype.NamedTypes(
|
| 187 |
+
namedtype.OptionalNamedType('hashAlgorithm', rfc5280.AlgorithmIdentifier().subtype(
|
| 188 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
|
| 189 |
+
namedtype.OptionalNamedType('maskGenAlgorithm', rfc5280.AlgorithmIdentifier().subtype(
|
| 190 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),
|
| 191 |
+
namedtype.DefaultedNamedType('saltLength', univ.Integer(value=20).subtype(
|
| 192 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
|
| 193 |
+
namedtype.DefaultedNamedType('trailerField', univ.Integer(value=1).subtype(
|
| 194 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
|
| 195 |
+
)
|
| 196 |
+
|
| 197 |
+
rSASSA_PSS_Default_Params = RSASSA_PSS_params()
|
| 198 |
+
|
| 199 |
+
rSASSA_PSS_Default_Identifier = rfc5280.AlgorithmIdentifier()
|
| 200 |
+
rSASSA_PSS_Default_Identifier['algorithm'] = id_RSASSA_PSS
|
| 201 |
+
rSASSA_PSS_Default_Identifier['parameters'] = rSASSA_PSS_Default_Params
|
| 202 |
+
|
| 203 |
+
rSASSA_PSS_SHA224_Params = RSASSA_PSS_params()
|
| 204 |
+
rSASSA_PSS_SHA224_Params['hashAlgorithm'] = sha224Identifier.subtype(
|
| 205 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0), cloneValueFlag=True)
|
| 206 |
+
rSASSA_PSS_SHA224_Params['maskGenAlgorithm'] = mgf1SHA224Identifier.subtype(
|
| 207 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1), cloneValueFlag=True)
|
| 208 |
+
|
| 209 |
+
rSASSA_PSS_SHA224_Identifier = rfc5280.AlgorithmIdentifier()
|
| 210 |
+
rSASSA_PSS_SHA224_Identifier['algorithm'] = id_RSASSA_PSS
|
| 211 |
+
rSASSA_PSS_SHA224_Identifier['parameters'] = rSASSA_PSS_SHA224_Params
|
| 212 |
+
|
| 213 |
+
rSASSA_PSS_SHA256_Params = RSASSA_PSS_params()
|
| 214 |
+
rSASSA_PSS_SHA256_Params['hashAlgorithm'] = sha256Identifier.subtype(
|
| 215 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0), cloneValueFlag=True)
|
| 216 |
+
rSASSA_PSS_SHA256_Params['maskGenAlgorithm'] = mgf1SHA256Identifier.subtype(
|
| 217 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1), cloneValueFlag=True)
|
| 218 |
+
|
| 219 |
+
rSASSA_PSS_SHA256_Identifier = rfc5280.AlgorithmIdentifier()
|
| 220 |
+
rSASSA_PSS_SHA256_Identifier['algorithm'] = id_RSASSA_PSS
|
| 221 |
+
rSASSA_PSS_SHA256_Identifier['parameters'] = rSASSA_PSS_SHA256_Params
|
| 222 |
+
|
| 223 |
+
rSASSA_PSS_SHA384_Params = RSASSA_PSS_params()
|
| 224 |
+
rSASSA_PSS_SHA384_Params['hashAlgorithm'] = sha384Identifier.subtype(
|
| 225 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0), cloneValueFlag=True)
|
| 226 |
+
rSASSA_PSS_SHA384_Params['maskGenAlgorithm'] = mgf1SHA384Identifier.subtype(
|
| 227 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1), cloneValueFlag=True)
|
| 228 |
+
|
| 229 |
+
rSASSA_PSS_SHA384_Identifier = rfc5280.AlgorithmIdentifier()
|
| 230 |
+
rSASSA_PSS_SHA384_Identifier['algorithm'] = id_RSASSA_PSS
|
| 231 |
+
rSASSA_PSS_SHA384_Identifier['parameters'] = rSASSA_PSS_SHA384_Params
|
| 232 |
+
|
| 233 |
+
rSASSA_PSS_SHA512_Params = RSASSA_PSS_params()
|
| 234 |
+
rSASSA_PSS_SHA512_Params['hashAlgorithm'] = sha512Identifier.subtype(
|
| 235 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0), cloneValueFlag=True)
|
| 236 |
+
rSASSA_PSS_SHA512_Params['maskGenAlgorithm'] = mgf1SHA512Identifier.subtype(
|
| 237 |
+
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1), cloneValueFlag=True)
|
| 238 |
+
|
| 239 |
+
rSASSA_PSS_SHA512_Identifier = rfc5280.AlgorithmIdentifier()
|
| 240 |
+
rSASSA_PSS_SHA512_Identifier['algorithm'] = id_RSASSA_PSS
|
| 241 |
+
rSASSA_PSS_SHA512_Identifier['parameters'] = rSASSA_PSS_SHA512_Params
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
# Update the Algorithm Identifier map
|
| 245 |
+
|
| 246 |
+
_algorithmIdentifierMapUpdate = {
|
| 247 |
+
id_sha1: univ.Null(),
|
| 248 |
+
id_sha224: univ.Null(),
|
| 249 |
+
id_sha256: univ.Null(),
|
| 250 |
+
id_sha384: univ.Null(),
|
| 251 |
+
id_sha512: univ.Null(),
|
| 252 |
+
id_mgf1: rfc5280.AlgorithmIdentifier(),
|
| 253 |
+
id_pSpecified: univ.OctetString(),
|
| 254 |
+
id_RSAES_OAEP: RSAES_OAEP_params(),
|
| 255 |
+
id_RSASSA_PSS: RSASSA_PSS_params(),
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc4108.py
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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| 4 |
+
# Created by Russ Housley with assistance from asn1ate v.0.6.0.
|
| 5 |
+
# Modified by Russ Housley to add items from the verified errata.
|
| 6 |
+
# Modified by Russ Housley to add maps for use with opentypes.
|
| 7 |
+
#
|
| 8 |
+
# Copyright (c) 2019, Vigil Security, LLC
|
| 9 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 10 |
+
#
|
| 11 |
+
# CMS Firmware Wrapper
|
| 12 |
+
#
|
| 13 |
+
# ASN.1 source from:
|
| 14 |
+
# https://www.rfc-editor.org/rfc/rfc4108.txt
|
| 15 |
+
# https://www.rfc-editor.org/errata_search.php?rfc=4108
|
| 16 |
+
#
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
from pyasn1.type import univ, char, namedtype, namedval, tag, constraint, useful
|
| 20 |
+
|
| 21 |
+
from pyasn1_modules import rfc5280
|
| 22 |
+
from pyasn1_modules import rfc5652
|
| 23 |
+
|
| 24 |
+
MAX = float('inf')
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class HardwareSerialEntry(univ.Choice):
|
| 28 |
+
pass
|
| 29 |
+
|
| 30 |
+
HardwareSerialEntry.componentType = namedtype.NamedTypes(
|
| 31 |
+
namedtype.NamedType('all', univ.Null()),
|
| 32 |
+
namedtype.NamedType('single', univ.OctetString()),
|
| 33 |
+
namedtype.NamedType('block', univ.Sequence(componentType=namedtype.NamedTypes(
|
| 34 |
+
namedtype.NamedType('low', univ.OctetString()),
|
| 35 |
+
namedtype.NamedType('high', univ.OctetString())
|
| 36 |
+
))
|
| 37 |
+
)
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
class HardwareModules(univ.Sequence):
|
| 42 |
+
pass
|
| 43 |
+
|
| 44 |
+
HardwareModules.componentType = namedtype.NamedTypes(
|
| 45 |
+
namedtype.NamedType('hwType', univ.ObjectIdentifier()),
|
| 46 |
+
namedtype.NamedType('hwSerialEntries', univ.SequenceOf(componentType=HardwareSerialEntry()))
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
class CommunityIdentifier(univ.Choice):
|
| 51 |
+
pass
|
| 52 |
+
|
| 53 |
+
CommunityIdentifier.componentType = namedtype.NamedTypes(
|
| 54 |
+
namedtype.NamedType('communityOID', univ.ObjectIdentifier()),
|
| 55 |
+
namedtype.NamedType('hwModuleList', HardwareModules())
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
class PreferredPackageIdentifier(univ.Sequence):
|
| 61 |
+
pass
|
| 62 |
+
|
| 63 |
+
PreferredPackageIdentifier.componentType = namedtype.NamedTypes(
|
| 64 |
+
namedtype.NamedType('fwPkgID', univ.ObjectIdentifier()),
|
| 65 |
+
namedtype.NamedType('verNum', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, MAX)))
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
class PreferredOrLegacyPackageIdentifier(univ.Choice):
|
| 70 |
+
pass
|
| 71 |
+
|
| 72 |
+
PreferredOrLegacyPackageIdentifier.componentType = namedtype.NamedTypes(
|
| 73 |
+
namedtype.NamedType('preferred', PreferredPackageIdentifier()),
|
| 74 |
+
namedtype.NamedType('legacy', univ.OctetString())
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
class CurrentFWConfig(univ.Sequence):
|
| 79 |
+
pass
|
| 80 |
+
|
| 81 |
+
CurrentFWConfig.componentType = namedtype.NamedTypes(
|
| 82 |
+
namedtype.OptionalNamedType('fwPkgType', univ.Integer()),
|
| 83 |
+
namedtype.NamedType('fwPkgName', PreferredOrLegacyPackageIdentifier())
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
class PreferredOrLegacyStalePackageIdentifier(univ.Choice):
|
| 88 |
+
pass
|
| 89 |
+
|
| 90 |
+
PreferredOrLegacyStalePackageIdentifier.componentType = namedtype.NamedTypes(
|
| 91 |
+
namedtype.NamedType('preferredStaleVerNum', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, MAX))),
|
| 92 |
+
namedtype.NamedType('legacyStaleVersion', univ.OctetString())
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
class FirmwarePackageLoadErrorCode(univ.Enumerated):
|
| 97 |
+
pass
|
| 98 |
+
|
| 99 |
+
FirmwarePackageLoadErrorCode.namedValues = namedval.NamedValues(
|
| 100 |
+
('decodeFailure', 1),
|
| 101 |
+
('badContentInfo', 2),
|
| 102 |
+
('badSignedData', 3),
|
| 103 |
+
('badEncapContent', 4),
|
| 104 |
+
('badCertificate', 5),
|
| 105 |
+
('badSignerInfo', 6),
|
| 106 |
+
('badSignedAttrs', 7),
|
| 107 |
+
('badUnsignedAttrs', 8),
|
| 108 |
+
('missingContent', 9),
|
| 109 |
+
('noTrustAnchor', 10),
|
| 110 |
+
('notAuthorized', 11),
|
| 111 |
+
('badDigestAlgorithm', 12),
|
| 112 |
+
('badSignatureAlgorithm', 13),
|
| 113 |
+
('unsupportedKeySize', 14),
|
| 114 |
+
('signatureFailure', 15),
|
| 115 |
+
('contentTypeMismatch', 16),
|
| 116 |
+
('badEncryptedData', 17),
|
| 117 |
+
('unprotectedAttrsPresent', 18),
|
| 118 |
+
('badEncryptContent', 19),
|
| 119 |
+
('badEncryptAlgorithm', 20),
|
| 120 |
+
('missingCiphertext', 21),
|
| 121 |
+
('noDecryptKey', 22),
|
| 122 |
+
('decryptFailure', 23),
|
| 123 |
+
('badCompressAlgorithm', 24),
|
| 124 |
+
('missingCompressedContent', 25),
|
| 125 |
+
('decompressFailure', 26),
|
| 126 |
+
('wrongHardware', 27),
|
| 127 |
+
('stalePackage', 28),
|
| 128 |
+
('notInCommunity', 29),
|
| 129 |
+
('unsupportedPackageType', 30),
|
| 130 |
+
('missingDependency', 31),
|
| 131 |
+
('wrongDependencyVersion', 32),
|
| 132 |
+
('insufficientMemory', 33),
|
| 133 |
+
('badFirmware', 34),
|
| 134 |
+
('unsupportedParameters', 35),
|
| 135 |
+
('breaksDependency', 36),
|
| 136 |
+
('otherError', 99)
|
| 137 |
+
)
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
class VendorLoadErrorCode(univ.Integer):
|
| 141 |
+
pass
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
# Wrapped Firmware Key Unsigned Attribute and Object Identifier
|
| 145 |
+
|
| 146 |
+
id_aa_wrappedFirmwareKey = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.39')
|
| 147 |
+
|
| 148 |
+
class WrappedFirmwareKey(rfc5652.EnvelopedData):
|
| 149 |
+
pass
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
# Firmware Package Information Signed Attribute and Object Identifier
|
| 153 |
+
|
| 154 |
+
id_aa_firmwarePackageInfo = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.42')
|
| 155 |
+
|
| 156 |
+
class FirmwarePackageInfo(univ.Sequence):
|
| 157 |
+
pass
|
| 158 |
+
|
| 159 |
+
FirmwarePackageInfo.componentType = namedtype.NamedTypes(
|
| 160 |
+
namedtype.OptionalNamedType('fwPkgType', univ.Integer()),
|
| 161 |
+
namedtype.OptionalNamedType('dependencies', univ.SequenceOf(componentType=PreferredOrLegacyPackageIdentifier()))
|
| 162 |
+
)
|
| 163 |
+
|
| 164 |
+
FirmwarePackageInfo.sizeSpec = univ.Sequence.sizeSpec + constraint.ValueSizeConstraint(1, 2)
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
# Community Identifiers Signed Attribute and Object Identifier
|
| 168 |
+
|
| 169 |
+
id_aa_communityIdentifiers = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.40')
|
| 170 |
+
|
| 171 |
+
class CommunityIdentifiers(univ.SequenceOf):
|
| 172 |
+
pass
|
| 173 |
+
|
| 174 |
+
CommunityIdentifiers.componentType = CommunityIdentifier()
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
# Implemented Compression Algorithms Signed Attribute and Object Identifier
|
| 178 |
+
|
| 179 |
+
id_aa_implCompressAlgs = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.43')
|
| 180 |
+
|
| 181 |
+
class ImplementedCompressAlgorithms(univ.SequenceOf):
|
| 182 |
+
pass
|
| 183 |
+
|
| 184 |
+
ImplementedCompressAlgorithms.componentType = univ.ObjectIdentifier()
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
# Implemented Cryptographic Algorithms Signed Attribute and Object Identifier
|
| 188 |
+
|
| 189 |
+
id_aa_implCryptoAlgs = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.38')
|
| 190 |
+
|
| 191 |
+
class ImplementedCryptoAlgorithms(univ.SequenceOf):
|
| 192 |
+
pass
|
| 193 |
+
|
| 194 |
+
ImplementedCryptoAlgorithms.componentType = univ.ObjectIdentifier()
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
# Decrypt Key Identifier Signed Attribute and Object Identifier
|
| 198 |
+
|
| 199 |
+
id_aa_decryptKeyID = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.37')
|
| 200 |
+
|
| 201 |
+
class DecryptKeyIdentifier(univ.OctetString):
|
| 202 |
+
pass
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
# Target Hardware Identifier Signed Attribute and Object Identifier
|
| 206 |
+
|
| 207 |
+
id_aa_targetHardwareIDs = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.36')
|
| 208 |
+
|
| 209 |
+
class TargetHardwareIdentifiers(univ.SequenceOf):
|
| 210 |
+
pass
|
| 211 |
+
|
| 212 |
+
TargetHardwareIdentifiers.componentType = univ.ObjectIdentifier()
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
# Firmware Package Identifier Signed Attribute and Object Identifier
|
| 216 |
+
|
| 217 |
+
id_aa_firmwarePackageID = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.35')
|
| 218 |
+
|
| 219 |
+
class FirmwarePackageIdentifier(univ.Sequence):
|
| 220 |
+
pass
|
| 221 |
+
|
| 222 |
+
FirmwarePackageIdentifier.componentType = namedtype.NamedTypes(
|
| 223 |
+
namedtype.NamedType('name', PreferredOrLegacyPackageIdentifier()),
|
| 224 |
+
namedtype.OptionalNamedType('stale', PreferredOrLegacyStalePackageIdentifier())
|
| 225 |
+
)
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
# Firmware Package Message Digest Signed Attribute and Object Identifier
|
| 229 |
+
|
| 230 |
+
id_aa_fwPkgMessageDigest = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.41')
|
| 231 |
+
|
| 232 |
+
class FirmwarePackageMessageDigest(univ.Sequence):
|
| 233 |
+
pass
|
| 234 |
+
|
| 235 |
+
FirmwarePackageMessageDigest.componentType = namedtype.NamedTypes(
|
| 236 |
+
namedtype.NamedType('algorithm', rfc5280.AlgorithmIdentifier()),
|
| 237 |
+
namedtype.NamedType('msgDigest', univ.OctetString())
|
| 238 |
+
)
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
# Firmware Package Load Error Report Content Type and Object Identifier
|
| 242 |
+
|
| 243 |
+
class FWErrorVersion(univ.Integer):
|
| 244 |
+
pass
|
| 245 |
+
|
| 246 |
+
FWErrorVersion.namedValues = namedval.NamedValues(
|
| 247 |
+
('v1', 1)
|
| 248 |
+
)
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
id_ct_firmwareLoadError = univ.ObjectIdentifier('1.2.840.113549.1.9.16.1.18')
|
| 252 |
+
|
| 253 |
+
class FirmwarePackageLoadError(univ.Sequence):
|
| 254 |
+
pass
|
| 255 |
+
|
| 256 |
+
FirmwarePackageLoadError.componentType = namedtype.NamedTypes(
|
| 257 |
+
namedtype.DefaultedNamedType('version', FWErrorVersion().subtype(value='v1')),
|
| 258 |
+
namedtype.NamedType('hwType', univ.ObjectIdentifier()),
|
| 259 |
+
namedtype.NamedType('hwSerialNum', univ.OctetString()),
|
| 260 |
+
namedtype.NamedType('errorCode', FirmwarePackageLoadErrorCode()),
|
| 261 |
+
namedtype.OptionalNamedType('vendorErrorCode', VendorLoadErrorCode()),
|
| 262 |
+
namedtype.OptionalNamedType('fwPkgName', PreferredOrLegacyPackageIdentifier()),
|
| 263 |
+
namedtype.OptionalNamedType('config', univ.SequenceOf(componentType=CurrentFWConfig()).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 264 |
+
)
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
# Firmware Package Load Receipt Content Type and Object Identifier
|
| 268 |
+
|
| 269 |
+
class FWReceiptVersion(univ.Integer):
|
| 270 |
+
pass
|
| 271 |
+
|
| 272 |
+
FWReceiptVersion.namedValues = namedval.NamedValues(
|
| 273 |
+
('v1', 1)
|
| 274 |
+
)
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
id_ct_firmwareLoadReceipt = univ.ObjectIdentifier('1.2.840.113549.1.9.16.1.17')
|
| 278 |
+
|
| 279 |
+
class FirmwarePackageLoadReceipt(univ.Sequence):
|
| 280 |
+
pass
|
| 281 |
+
|
| 282 |
+
FirmwarePackageLoadReceipt.componentType = namedtype.NamedTypes(
|
| 283 |
+
namedtype.DefaultedNamedType('version', FWReceiptVersion().subtype(value='v1')),
|
| 284 |
+
namedtype.NamedType('hwType', univ.ObjectIdentifier()),
|
| 285 |
+
namedtype.NamedType('hwSerialNum', univ.OctetString()),
|
| 286 |
+
namedtype.NamedType('fwPkgName', PreferredOrLegacyPackageIdentifier()),
|
| 287 |
+
namedtype.OptionalNamedType('trustAnchorKeyID', univ.OctetString()),
|
| 288 |
+
namedtype.OptionalNamedType('decryptKeyID', univ.OctetString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
|
| 289 |
+
)
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
# Firmware Package Content Type and Object Identifier
|
| 293 |
+
|
| 294 |
+
id_ct_firmwarePackage = univ.ObjectIdentifier('1.2.840.113549.1.9.16.1.16')
|
| 295 |
+
|
| 296 |
+
class FirmwarePkgData(univ.OctetString):
|
| 297 |
+
pass
|
| 298 |
+
|
| 299 |
+
|
| 300 |
+
# Other Name syntax for Hardware Module Name
|
| 301 |
+
|
| 302 |
+
id_on_hardwareModuleName = univ.ObjectIdentifier('1.3.6.1.5.5.7.8.4')
|
| 303 |
+
|
| 304 |
+
class HardwareModuleName(univ.Sequence):
|
| 305 |
+
pass
|
| 306 |
+
|
| 307 |
+
HardwareModuleName.componentType = namedtype.NamedTypes(
|
| 308 |
+
namedtype.NamedType('hwType', univ.ObjectIdentifier()),
|
| 309 |
+
namedtype.NamedType('hwSerialNum', univ.OctetString())
|
| 310 |
+
)
|
| 311 |
+
|
| 312 |
+
|
| 313 |
+
# Map of Attribute Type OIDs to Attributes is added to the
|
| 314 |
+
# ones that are in rfc5652.py
|
| 315 |
+
|
| 316 |
+
_cmsAttributesMapUpdate = {
|
| 317 |
+
id_aa_wrappedFirmwareKey: WrappedFirmwareKey(),
|
| 318 |
+
id_aa_firmwarePackageInfo: FirmwarePackageInfo(),
|
| 319 |
+
id_aa_communityIdentifiers: CommunityIdentifiers(),
|
| 320 |
+
id_aa_implCompressAlgs: ImplementedCompressAlgorithms(),
|
| 321 |
+
id_aa_implCryptoAlgs: ImplementedCryptoAlgorithms(),
|
| 322 |
+
id_aa_decryptKeyID: DecryptKeyIdentifier(),
|
| 323 |
+
id_aa_targetHardwareIDs: TargetHardwareIdentifiers(),
|
| 324 |
+
id_aa_firmwarePackageID: FirmwarePackageIdentifier(),
|
| 325 |
+
id_aa_fwPkgMessageDigest: FirmwarePackageMessageDigest(),
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
rfc5652.cmsAttributesMap.update(_cmsAttributesMapUpdate)
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
# Map of Content Type OIDs to Content Types is added to the
|
| 332 |
+
# ones that are in rfc5652.py
|
| 333 |
+
|
| 334 |
+
_cmsContentTypesMapUpdate = {
|
| 335 |
+
id_ct_firmwareLoadError: FirmwarePackageLoadError(),
|
| 336 |
+
id_ct_firmwareLoadReceipt: FirmwarePackageLoadReceipt(),
|
| 337 |
+
id_ct_firmwarePackage: FirmwarePkgData(),
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
rfc5652.cmsContentTypesMap.update(_cmsContentTypesMapUpdate)
|
| 341 |
+
|
| 342 |
+
|
| 343 |
+
# Map of Other Name OIDs to Other Name is added to the
|
| 344 |
+
# ones that are in rfc5280.py
|
| 345 |
+
|
| 346 |
+
_anotherNameMapUpdate = {
|
| 347 |
+
id_on_hardwareModuleName: HardwareModuleName(),
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
rfc5280.anotherNameMap.update(_anotherNameMapUpdate)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc4476.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
# Attribute Certificate Policies Extension
|
| 10 |
+
#
|
| 11 |
+
# ASN.1 source from:
|
| 12 |
+
# https://www.rfc-editor.org/rfc/rfc4476.txt
|
| 13 |
+
#
|
| 14 |
+
|
| 15 |
+
from pyasn1.type import char
|
| 16 |
+
from pyasn1.type import constraint
|
| 17 |
+
from pyasn1.type import namedtype
|
| 18 |
+
from pyasn1.type import univ
|
| 19 |
+
|
| 20 |
+
from pyasn1_modules import rfc5280
|
| 21 |
+
|
| 22 |
+
MAX = float('inf')
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
# Imports from RFC 5280
|
| 26 |
+
|
| 27 |
+
PolicyQualifierId = rfc5280.PolicyQualifierId
|
| 28 |
+
|
| 29 |
+
PolicyQualifierInfo = rfc5280.PolicyQualifierInfo
|
| 30 |
+
|
| 31 |
+
UserNotice = rfc5280.UserNotice
|
| 32 |
+
|
| 33 |
+
id_pkix = rfc5280.id_pkix
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
# Object Identifiers
|
| 37 |
+
|
| 38 |
+
id_pe = id_pkix + (1,)
|
| 39 |
+
|
| 40 |
+
id_pe_acPolicies = id_pe + (15,)
|
| 41 |
+
|
| 42 |
+
id_qt = id_pkix + (2,)
|
| 43 |
+
|
| 44 |
+
id_qt_acps = id_qt + (4,)
|
| 45 |
+
|
| 46 |
+
id_qt_acunotice = id_qt + (5,)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
# Attribute Certificate Policies Extension
|
| 50 |
+
|
| 51 |
+
class ACUserNotice(UserNotice):
|
| 52 |
+
pass
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
class ACPSuri(char.IA5String):
|
| 56 |
+
pass
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
class AcPolicyId(univ.ObjectIdentifier):
|
| 60 |
+
pass
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
class PolicyInformation(univ.Sequence):
|
| 64 |
+
componentType = namedtype.NamedTypes(
|
| 65 |
+
namedtype.NamedType('policyIdentifier', AcPolicyId()),
|
| 66 |
+
namedtype.OptionalNamedType('policyQualifiers',
|
| 67 |
+
univ.SequenceOf(componentType=PolicyQualifierInfo()).subtype(
|
| 68 |
+
subtypeSpec=constraint.ValueSizeConstraint(1, MAX)))
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
class AcPoliciesSyntax(univ.SequenceOf):
|
| 73 |
+
componentType = PolicyInformation()
|
| 74 |
+
subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
# Update the policy qualifier map in rfc5280.py
|
| 78 |
+
|
| 79 |
+
_policyQualifierInfoMapUpdate = {
|
| 80 |
+
id_qt_acps: ACPSuri(),
|
| 81 |
+
id_qt_acunotice: UserNotice(),
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
rfc5280.policyQualifierInfoMap.update(_policyQualifierInfoMapUpdate)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
# Update the certificate extension map in rfc5280.py
|
| 88 |
+
|
| 89 |
+
_certificateExtensionsMapUpdate = {
|
| 90 |
+
id_pe_acPolicies: AcPoliciesSyntax(),
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
rfc5280.certificateExtensionsMap.update(_certificateExtensionsMapUpdate)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc4490.py
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 16 |
+
|
| 17 |
+
from pyasn1.type import univ, char, namedtype, namedval, tag, constraint, useful
|
| 18 |
+
|
| 19 |
+
from pyasn1_modules import rfc4357
|
| 20 |
+
from pyasn1_modules import rfc5280
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
# Imports from RFC 4357
|
| 24 |
+
|
| 25 |
+
id_CryptoPro_algorithms = rfc4357.id_CryptoPro_algorithms
|
| 26 |
+
|
| 27 |
+
id_GostR3410_94 = rfc4357.id_GostR3410_94
|
| 28 |
+
|
| 29 |
+
id_GostR3410_2001 = rfc4357.id_GostR3410_2001
|
| 30 |
+
|
| 31 |
+
Gost28147_89_ParamSet = rfc4357.Gost28147_89_ParamSet
|
| 32 |
+
|
| 33 |
+
Gost28147_89_EncryptedKey = rfc4357.Gost28147_89_EncryptedKey
|
| 34 |
+
|
| 35 |
+
GostR3410_94_PublicKeyParameters = rfc4357.GostR3410_94_PublicKeyParameters
|
| 36 |
+
|
| 37 |
+
GostR3410_2001_PublicKeyParameters = rfc4357.GostR3410_2001_PublicKeyParameters
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
# Imports from RFC 5280
|
| 41 |
+
|
| 42 |
+
SubjectPublicKeyInfo = rfc5280.SubjectPublicKeyInfo
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
# CMS/PKCS#7 key agreement algorithms & parameters
|
| 46 |
+
|
| 47 |
+
class Gost28147_89_KeyWrapParameters(univ.Sequence):
|
| 48 |
+
componentType = namedtype.NamedTypes(
|
| 49 |
+
namedtype.NamedType('encryptionParamSet', Gost28147_89_ParamSet()),
|
| 50 |
+
namedtype.OptionalNamedType('ukm', univ.OctetString().subtype(
|
| 51 |
+
subtypeSpec=constraint.ValueSizeConstraint(8, 8)))
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
id_Gost28147_89_CryptoPro_KeyWrap = id_CryptoPro_algorithms + (13, 1, )
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
id_Gost28147_89_None_KeyWrap = id_CryptoPro_algorithms + (13, 0, )
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
id_GostR3410_2001_CryptoPro_ESDH = id_CryptoPro_algorithms + (96, )
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
id_GostR3410_94_CryptoPro_ESDH = id_CryptoPro_algorithms + (97, )
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
# CMS/PKCS#7 key transport algorithms & parameters
|
| 68 |
+
|
| 69 |
+
id_GostR3410_2001_KeyTransportSMIMECapability = id_GostR3410_2001
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
id_GostR3410_94_KeyTransportSMIMECapability = id_GostR3410_94
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
class GostR3410_TransportParameters(univ.Sequence):
|
| 76 |
+
componentType = namedtype.NamedTypes(
|
| 77 |
+
namedtype.NamedType('encryptionParamSet', Gost28147_89_ParamSet()),
|
| 78 |
+
namedtype.OptionalNamedType('ephemeralPublicKey',
|
| 79 |
+
SubjectPublicKeyInfo().subtype(implicitTag=tag.Tag(
|
| 80 |
+
tag.tagClassContext, tag.tagFormatSimple, 0))),
|
| 81 |
+
namedtype.NamedType('ukm', univ.OctetString().subtype(
|
| 82 |
+
subtypeSpec=constraint.ValueSizeConstraint(8, 8)))
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
class GostR3410_KeyTransport(univ.Sequence):
|
| 86 |
+
componentType = namedtype.NamedTypes(
|
| 87 |
+
namedtype.NamedType('sessionEncryptedKey', Gost28147_89_EncryptedKey()),
|
| 88 |
+
namedtype.OptionalNamedType('transportParameters',
|
| 89 |
+
GostR3410_TransportParameters().subtype(implicitTag=tag.Tag(
|
| 90 |
+
tag.tagClassContext, tag.tagFormatConstructed, 0)))
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
# GOST R 34.10-94 signature algorithm & parameters
|
| 95 |
+
|
| 96 |
+
class GostR3410_94_Signature(univ.OctetString):
|
| 97 |
+
subtypeSpec = constraint.ValueSizeConstraint(64, 64)
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
# GOST R 34.10-2001 signature algorithms and parameters
|
| 101 |
+
|
| 102 |
+
class GostR3410_2001_Signature(univ.OctetString):
|
| 103 |
+
subtypeSpec = constraint.ValueSizeConstraint(64, 64)
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
# Update the Algorithm Identifier map in rfc5280.py
|
| 107 |
+
|
| 108 |
+
_algorithmIdentifierMapUpdate = {
|
| 109 |
+
id_Gost28147_89_CryptoPro_KeyWrap: Gost28147_89_KeyWrapParameters(),
|
| 110 |
+
id_Gost28147_89_None_KeyWrap: Gost28147_89_KeyWrapParameters(),
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate)
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc4491.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# This file is part of pyasn1-modules software.
|
| 3 |
+
#
|
| 4 |
+
# Created by Russ Housley.
|
| 5 |
+
#
|
| 6 |
+
# Copyright (c) 2019, Vigil Security, LLC
|
| 7 |
+
# License: http://snmplabs.com/pyasn1/license.html
|
| 8 |
+
#
|
| 9 |
+
# Using the GOST R 34.10-94, GOST R 34.10-2001, and GOST R 34.11-94
|
| 10 |
+
# Algorithms with Certificates and CRLs
|
| 11 |
+
#
|
| 12 |
+
# ASN.1 source from:
|
| 13 |
+
# https://www.rfc-editor.org/rfc/rfc4491.txt
|
| 14 |
+
#
|
| 15 |
+
|
| 16 |
+
from pyasn1_modules import rfc4357
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Signature Algorithm GOST R 34.10-94
|
| 20 |
+
|
| 21 |
+
id_GostR3411_94_with_GostR3410_94 = rfc4357.id_GostR3411_94_with_GostR3410_94
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
# Signature Algorithm GOST R 34.10-2001
|
| 25 |
+
|
| 26 |
+
id_GostR3411_94_with_GostR3410_2001 = rfc4357.id_GostR3411_94_with_GostR3410_2001
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
# GOST R 34.10-94 Keys
|
| 30 |
+
|
| 31 |
+
id_GostR3410_94 = rfc4357.id_GostR3410_94
|
| 32 |
+
|
| 33 |
+
GostR3410_2001_PublicKey = rfc4357.GostR3410_2001_PublicKey
|
| 34 |
+
|
| 35 |
+
GostR3410_2001_PublicKeyParameters = rfc4357.GostR3410_2001_PublicKeyParameters
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
# GOST R 34.10-2001 Keys
|
| 39 |
+
|
| 40 |
+
id_GostR3410_2001 = rfc4357.id_GostR3410_2001
|
| 41 |
+
|
| 42 |
+
GostR3410_94_PublicKey = rfc4357.GostR3410_94_PublicKey
|
| 43 |
+
|
| 44 |
+
GostR3410_94_PublicKeyParameters = rfc4357.GostR3410_94_PublicKeyParameters
|
bertvenv/lib/python3.10/site-packages/pyasn1_modules/rfc4683.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
# Subject Identification Method (SIM)
|
| 10 |
+
#
|
| 11 |
+
# ASN.1 source from:
|
| 12 |
+
# https://www.rfc-editor.org/rfc/rfc4683.txt
|
| 13 |
+
# https://www.rfc-editor.org/errata/eid1047
|
| 14 |
+
#
|
| 15 |
+
|
| 16 |
+
from pyasn1.type import char
|
| 17 |
+
from pyasn1.type import namedtype
|
| 18 |
+
from pyasn1.type import univ
|
| 19 |
+
|
| 20 |
+
from pyasn1_modules import rfc5280
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
# Used to compute the PEPSI value
|
| 24 |
+
|
| 25 |
+
class HashContent(univ.Sequence):
|
| 26 |
+
componentType = namedtype.NamedTypes(
|
| 27 |
+
namedtype.NamedType('userPassword', char.UTF8String()),
|
| 28 |
+
namedtype.NamedType('authorityRandom', univ.OctetString()),
|
| 29 |
+
namedtype.NamedType('identifierType', univ.ObjectIdentifier()),
|
| 30 |
+
namedtype.NamedType('identifier', char.UTF8String())
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
# Used to encode the PEPSI value as the SIM Other Name
|
| 35 |
+
|
| 36 |
+
id_pkix = rfc5280.id_pkix
|
| 37 |
+
|
| 38 |
+
id_on = id_pkix + (8,)
|
| 39 |
+
|
| 40 |
+
id_on_SIM = id_on + (6,)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
class SIM(univ.Sequence):
|
| 44 |
+
componentType = namedtype.NamedTypes(
|
| 45 |
+
namedtype.NamedType('hashAlg', rfc5280.AlgorithmIdentifier()),
|
| 46 |
+
namedtype.NamedType('authorityRandom', univ.OctetString()),
|
| 47 |
+
namedtype.NamedType('pEPSI', univ.OctetString())
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
# Used to encrypt the PEPSI value during certificate request
|
| 52 |
+
|
| 53 |
+
id_pkip = id_pkix + (5,)
|
| 54 |
+
|
| 55 |
+
id_regEPEPSI = id_pkip + (3,)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
class EncryptedPEPSI(univ.Sequence):
|
| 59 |
+
componentType = namedtype.NamedTypes(
|
| 60 |
+
namedtype.NamedType('identifierType', univ.ObjectIdentifier()),
|
| 61 |
+
namedtype.NamedType('identifier', char.UTF8String()),
|
| 62 |
+
namedtype.NamedType('sIM', SIM())
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
# Update the map of Other Name OIDs to Other Names in rfc5280.py
|
| 67 |
+
|
| 68 |
+
_anotherNameMapUpdate = {
|
| 69 |
+
id_on_SIM: SIM(),
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
rfc5280.anotherNameMap.update(_anotherNameMapUpdate)
|