| Server IP : 185.88.153.241 / Your IP : 216.73.217.115 Web Server : LiteSpeed System : Linux server312.bertina.biz 3.10.0-962.3.2.lve1.5.88.el7.x86_64 #1 SMP Fri Sep 26 14:06:42 UTC 2025 x86_64 User : ( 1405) PHP Version : 7.0.33 Disable Function : mail, apache_child_terminate, apache_setenv, define_syslog_variables, escapeshellarg, escapeshellcmd, exec, fp, highlight_file, ini_alter, ini_restore, inject_code, mysql_pconnect, openlog, passthru, phpAds_remoteInfo, phpAds_XmlRpc, phpAds_xmlrpcDecode, phpAds_xmlrpcEncode, popen, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, proc_close, proc_get_status, proc_nice, proc_open, proc_terminate, shell_exec, syslog, system, xmlrpc_entity_decode, show_source,dl,leak,crack_check,crack_closedict,crack_getlastmessage,crack_opendict,symlink,link,escapeshellarg,parse_ini_file, ln, show_source, pclose, parse_perms, mysql_list_dbs,stream_select,mysql_list_dbs,socket_select,socket_create,socket_create_listen,socket_create_pair,socket_listen,socket_accept,socket_bind,socket_strerror,socket_clear_error,socket_close,socket_connect,socket_get_option,socket_getpeername,socket_getsockname,socket_last_error,socket_read,socket_recv,socket_recvfrom,socket_send,socket_sendto,socket_set_block,socket_set_nonblock,socket_set_option,socket_shutdown,socket_write,readlink,pfsockopen,pcntl_exec,pcntl_fork,pcntl_signal,pcntl_waitpid,pcntl_wexitstatus, pcntl_wifexited, pcntl_wifsignaled, pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,fpassthru, posix_access, posix_ctermid, posix_errno, posix_get_last_error, posix_getcwd, posix_getgrnam, posix_getgroups, posix_getlogin, posix_getpgrp, posix_getpwnam, posix_getpwuid, posix_getrlimit, posix_getsid, posix_initgroups, posix_isatty, posix_mknod, posix_setegid, posix_seteuid, posix_strerror, posix_times, posix_ttyname, diskfreespace, disk_free_space, disk_total_space, sys_getloadavg,get_current_user MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /opt/cloudlinux/venv/lib64/python3.11/site-packages/cryptography/ |
Upload File : |
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
from __future__ import annotations
import enum
import sys
import types
import typing
import warnings
# We use a UserWarning subclass, instead of DeprecationWarning, because CPython
# decided deprecation warnings should be invisble by default.
class CryptographyDeprecationWarning(UserWarning):
pass
# Several APIs were deprecated with no specific end-of-life date because of the
# ubiquity of their use. They should not be removed until we agree on when that
# cycle ends.
DeprecatedIn36 = CryptographyDeprecationWarning
DeprecatedIn37 = CryptographyDeprecationWarning
DeprecatedIn40 = CryptographyDeprecationWarning
DeprecatedIn41 = CryptographyDeprecationWarning
def _check_bytes(name: str, value: bytes) -> None:
if not isinstance(value, bytes):
raise TypeError(f"{name} must be bytes")
def _check_byteslike(name: str, value: bytes) -> None:
try:
memoryview(value)
except TypeError:
raise TypeError(f"{name} must be bytes-like")
def int_to_bytes(integer: int, length: typing.Optional[int] = None) -> bytes:
return integer.to_bytes(
length or (integer.bit_length() + 7) // 8 or 1, "big"
)
def _extract_buffer_length(obj: typing.Any) -> typing.Tuple[typing.Any, int]:
from cryptography.hazmat.bindings._rust import _openssl
buf = _openssl.ffi.from_buffer(obj)
return buf, int(_openssl.ffi.cast("uintptr_t", buf))
class InterfaceNotImplemented(Exception):
pass
class _DeprecatedValue:
def __init__(self, value: object, message: str, warning_class):
self.value = value
self.message = message
self.warning_class = warning_class
class _ModuleWithDeprecations(types.ModuleType):
def __init__(self, module: types.ModuleType):
super().__init__(module.__name__)
self.__dict__["_module"] = module
def __getattr__(self, attr: str) -> object:
obj = getattr(self._module, attr)
if isinstance(obj, _DeprecatedValue):
warnings.warn(obj.message, obj.warning_class, stacklevel=2)
obj = obj.value
return obj
def __setattr__(self, attr: str, value: object) -> None:
setattr(self._module, attr, value)
def __delattr__(self, attr: str) -> None:
obj = getattr(self._module, attr)
if isinstance(obj, _DeprecatedValue):
warnings.warn(obj.message, obj.warning_class, stacklevel=2)
delattr(self._module, attr)
def __dir__(self) -> typing.Sequence[str]:
return ["_module"] + dir(self._module)
def deprecated(
value: object,
module_name: str,
message: str,
warning_class: typing.Type[Warning],
name: typing.Optional[str] = None,
) -> _DeprecatedValue:
module = sys.modules[module_name]
if not isinstance(module, _ModuleWithDeprecations):
sys.modules[module_name] = module = _ModuleWithDeprecations(module)
dv = _DeprecatedValue(value, message, warning_class)
# Maintain backwards compatibility with `name is None` for pyOpenSSL.
if name is not None:
setattr(module, name, dv)
return dv
def cached_property(func: typing.Callable) -> property:
cached_name = f"_cached_{func}"
sentinel = object()
def inner(instance: object):
cache = getattr(instance, cached_name, sentinel)
if cache is not sentinel:
return cache
result = func(instance)
setattr(instance, cached_name, result)
return result
return property(inner)
# Python 3.10 changed representation of enums. We use well-defined object
# representation and string representation from Python 3.9.
class Enum(enum.Enum):
def __repr__(self) -> str:
return f"<{self.__class__.__name__}.{self._name_}: {self._value_!r}>"
def __str__(self) -> str:
return f"{self.__class__.__name__}.{self._name_}"