repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
XX-Net | code/default/lib/noarch/tlslite/handshakehelpers.py | .py | # Authors:
# Karel Srot
#
# See the LICENSE file for legal information regarding use of this file.
"""Class with various handshake helpers."""
from .extensions import PaddingExtension, PreSharedKeyExtension
from .utils.cryptomath import derive_secret, secureHMAC, HKDF_expand_label
from .utils.constanttime import ct... | 165 | 6,721 |
XX-Net | code/default/lib/noarch/tlslite/errors.py | .py | # Authors:
# Trevor Perrin
# Dave Baggett (Arcode Corporation) - Added TLSUnsupportedError.
#
# See the LICENSE file for legal information regarding use of this file.
"""Exception classes."""
import socket
from .constants import AlertDescription, AlertLevel
class BaseTLSException(Exception):
"""
Metacla... | 286 | 6,838 |
XX-Net | code/default/lib/noarch/tlslite/bufferedsocket.py | .py | # Copyright (c) 2016, Hubert Kario
#
# See the LICENSE file for legal information regarding use of this file.
"""Wrapper around the socket.socket interface that provides buffering"""
from collections import deque
class BufferedSocket(object):
"""
Socket that will buffer reads and writes to a real socket obj... | 98 | 2,836 |
XX-Net | code/default/lib/noarch/tlslite/recordlayer.py | .py | # Copyright (c) 2014, Hubert Kario
#
# See the LICENSE file for legal information regarding use of this file.
"""Implementation of the TLS Record Layer protocol"""
import socket
import errno
import copy
try:
# in python 3 the native zip() returns iterator
from itertools import izip
except ImportError:
izi... | 1,360 | 51,706 |
XX-Net | code/default/lib/noarch/tlslite/tlsrecordlayer.py | .py | # Authors:
# Trevor Perrin
# Google (adapted by Sam Rushing) - NPN support
# Google - minimal padding
# Martin von Loewis - python 3 port
# Yngve Pettersen (ported by Paul Sokolovsky) - TLS 1.2
# Hubert Kario
#
# See the LICENSE file for legal information regarding use of this file.
"""Helper class for TL... | 1,457 | 60,747 |
XX-Net | code/default/lib/noarch/tlslite/x509.py | .py | # Authors:
# Trevor Perrin
# Google - parsing subject field
#
# See the LICENSE file for legal information regarding use of this file.
"""Class representing an X.509 certificate."""
from ecdsa.keys import VerifyingKey
from .utils.asn1parser import ASN1Parser
from .utils.cryptomath import *
from .utils.keyfactory... | 288 | 10,386 |
XX-Net | code/default/lib/noarch/tlslite/basedb.py | .py | # Authors:
# Trevor Perrin
# Martin von Loewis - python 3 port
#
# See the LICENSE file for legal information regarding use of this file.
"""Base class for SharedKeyDB and VerifierDB."""
try:
import anydbm
except ImportError:
# Python 3
import dbm as anydbm
import threading
import time
import logging... | 143 | 4,092 |
XX-Net | code/default/lib/noarch/tlslite/handshakesettings.py | .py | # Authors:
# Trevor Perrin
# Dave Baggett (Arcode Corporation) - cleanup handling of constants
# Yngve Pettersen (ported by Paul Sokolovsky) - TLS 1.2
#
# See the LICENSE file for legal information regarding use of this file.
"""Class for setting handshake parameters."""
from .constants import CertificateType
f... | 770 | 32,163 |
XX-Net | code/default/lib/noarch/tlslite/__init__.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""TLS Lite is a free python library that implements SSL and TLS. TLS Lite
supports RSA and SRP ciphersuites. TLS Lite is pure python, however it can use
other libraries for faster crypto operations. TLS Lite integrates wi... | 27 | 878 |
XX-Net | code/default/lib/noarch/tlslite/ocsp.py | .py | """Class for handling primary OCSP responses"""
from .utils.asn1parser import ASN1Parser
from .utils.cryptomath import bytesToNumber, numBytes, secureHash
from .x509 import X509
from .signed import SignedObject
from .errors import TLSIllegalParameterException
class OCSPRespStatus(object):
""" OCSP response status... | 165 | 5,933 |
XX-Net | code/default/lib/noarch/tlslite/tlsconnection.py | .py | # Authors:
# Trevor Perrin
# Google - added reqCAs parameter
# Google (adapted by Sam Rushing and Marcelo Fernandez) - NPN support
# Google - FALLBACK_SCSV
# Dimitris Moraitis - Anon ciphersuites
# Martin von Loewis - python 3 port
# Yngve Pettersen (ported by Paul Sokolovsky) - TLS 1.2
# Hubert Kario -... | 4,632 | 212,930 |
XX-Net | code/default/lib/noarch/tlslite/constants.py | .py | # Authors:
# Trevor Perrin
# Google - defining ClientCertificateType
# Google (adapted by Sam Rushing) - NPN support
# Dimitris Moraitis - Anon ciphersuites
# Dave Baggett (Arcode Corporation) - canonicalCipherName
# Yngve Pettersen (ported by Paul Sokolovsky) - TLS 1.2
#
# See the LICENSE file for legal i... | 1,641 | 66,441 |
XX-Net | code/default/lib/noarch/tlslite/verifierdb.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""Class for storing SRP password verifiers."""
from .utils.cryptomath import *
from .utils.compat import *
from tlslite import mathtls
from .basedb import BaseDB
class VerifierDB(BaseDB):
"""This class represent an ... | 101 | 3,702 |
XX-Net | code/default/lib/noarch/tlslite/extensions.py | .py | # Copyright (c) 2014, 2015 Hubert Kario
#
# See the LICENSE file for legal information regarding use of this file.
""" Helper package for handling TLS extensions encountered in ClientHello
and ServerHello messages.
"""
from __future__ import generators
from collections import namedtuple
from .utils.codec import Write... | 2,252 | 71,529 |
XX-Net | code/default/lib/noarch/tlslite/defragmenter.py | .py | # Copyright (c) 2015, Hubert Kario
#
# See the LICENSE file for legal information regarding use of this file.
"""Helper package for handling fragmentation of messages."""
from __future__ import generators
from .utils.codec import Parser
from .utils.deprecations import deprecated_attrs, deprecated_params
@deprecate... | 129 | 4,430 |
XX-Net | code/default/lib/noarch/tlslite/messages.py | .py | # Authors:
# Trevor Perrin
# Google - handling CertificateRequest.certificate_types
# Google (adapted by Sam Rushing and Marcelo Fernandez) - NPN support
# Dimitris Moraitis - Anon ciphersuites
# Yngve Pettersen (ported by Paul Sokolovsky) - TLS 1.2
# Hubert Kario - 'extensions' cleanup
#
# See the LICENSE ... | 2,417 | 79,447 |
XX-Net | code/default/lib/noarch/tlslite/checker.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""Class for post-handshake certificate checking."""
from .x509 import X509
from .x509certchain import X509CertChain
from .errors import *
class Checker(object):
"""
This class is passed to a handshake function ... | 79 | 2,725 |
XX-Net | code/default/lib/noarch/tlslite/handshakehashes.py | .py | # Copyright (c) 2015, Hubert Kario
#
# See the LICENSE file for legal information regarding use of this file.
"""Handling cryptographic hashes for handshake protocol"""
from .utils.compat import compat26Str, compatHMAC
from .utils.cryptomath import MD5, SHA1
from .utils import tlshashlib as hashlib
class HandshakeHas... | 116 | 4,137 |
XX-Net | code/default/lib/noarch/tlslite/mathtls.py | .py | # Authors:
# Trevor Perrin
# Dave Baggett (Arcode Corporation) - MD5 support for MAC_SSL
# Yngve Pettersen (ported by Paul Sokolovsky) - TLS 1.2
# Hubert Kario - SHA384 PRF
#
# See the LICENSE file for legal information regarding use of this file.
"""Miscellaneous helper functions."""
from .utils.compat impo... | 983 | 45,528 |
XX-Net | code/default/lib/noarch/tlslite/session.py | .py | # Authors:
# Trevor Perrin
# Dave Baggett (Arcode Corporation) - canonicalCipherName
#
# See the LICENSE file for legal information regarding use of this file.
"""Class representing a TLS session."""
from .utils.compat import *
from .mathtls import *
from .constants import *
class Session(object):
"""
T... | 183 | 6,906 |
XX-Net | code/default/lib/noarch/tlslite/messagesocket.py | .py | # vim: set fileencoding=utf8
#
# Copyright © 2015, Hubert Kario
#
# See the LICENSE file for legal information regarding use of this file.
"""Wrapper of TLS RecordLayer providing message-level abstraction"""
from .recordlayer import RecordLayer
from .constants import ContentType
from .messages import RecordHeader3, M... | 188 | 6,250 |
XX-Net | code/default/lib/noarch/tlslite/keyexchange.py | .py | # Authors:
# Hubert Kario (2015)
#
# See the LICENSE file for legal information regarding use of this file.
"""Handling of cryptographic operations for key exchange"""
import ecdsa
from .mathtls import goodGroupParameters, makeK, makeU, makeX, \
paramStrength, RFC7919_GROUPS, calc_key
from .errors import TLS... | 1,030 | 43,331 |
XX-Net | code/default/lib/noarch/tlslite/signed.py | .py | """Base class that represents any signed object"""
from .utils.cryptomath import numBytes
RSA_SIGNATURE_HASHES = ["sha512", "sha384", "sha256", "sha224", "sha1"]
ALL_RSA_SIGNATURE_HASHES = RSA_SIGNATURE_HASHES + ["md5"]
RSA_SCHEMES = ["pss", "pkcs1"]
class SignatureSettings(object):
def __init__(self, min_key_s... | 88 | 3,545 |
XX-Net | code/default/lib/noarch/tlslite/x509certchain.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""Class representing an X.509 certificate chain."""
from .utils import cryptomath
from .utils.tackwrapper import *
from .utils.pem import *
from .x509 import X509
class X509CertChain(object):
"""This class represent... | 108 | 3,323 |
XX-Net | code/default/lib/noarch/tlslite/sessioncache.py | .py | # Authors:
# Trevor Perrin
# Martin von Loewis - python 3 port
# Mirko Dziadzka - bugfix
#
# See the LICENSE file for legal information regarding use of this file.
"""Class for caching TLS sessions."""
import threading
import time
class SessionCache(object):
"""This class is used by the server to cache TL... | 104 | 3,552 |
XX-Net | code/default/lib/noarch/tlslite/dh.py | .py | # Author:
# Hubert Kario
"""Handling of Diffie-Hellman parameter files."""
from .utils.asn1parser import ASN1Parser
from .utils.pem import dePem
from .utils.cryptomath import bytesToNumber
def parseBinary(data):
"""
Parse DH parameters from ASN.1 DER encoded binary string.
:param bytes data: DH para... | 43 | 914 |
XX-Net | code/default/lib/noarch/tlslite/utils/asn1parser.py | .py | # Author: Trevor Perrin
# Patch from Google adding getChildBytes()
#
# See the LICENSE file for legal information regarding use of this file.
"""Abstract Syntax Notation One (ASN.1) parsing"""
from .codec import Parser
class ASN1Type(object):
"""
Class that represents the ASN.1 type bit octet.
Consists ... | 141 | 3,802 |
XX-Net | code/default/lib/noarch/tlslite/utils/lists.py | .py | # Authors:
# Hubert Kario (2016)
#
# See the LICENSE file for legal information regarding use of this file.
"""Helper functions for handling lists"""
from itertools import chain
def getFirstMatching(values, matches):
"""
Return the first element in :py:obj:`values` that is also in
:py:obj:`matches`.
... | 50 | 1,549 |
XX-Net | code/default/lib/noarch/tlslite/utils/chacha20_poly1305.py | .py | # Copyright (c) 2015, Hubert Kario
#
# See the LICENSE file for legal information regarding use of this file.
"""Pure Python implementation of ChaCha20/Poly1305 AEAD cipher
Implementation that follows RFC 7539 and draft-ietf-tls-chacha20-poly1305-00
"""
from __future__ import division
from .constanttime import ct_com... | 95 | 3,123 |
XX-Net | code/default/lib/noarch/tlslite/utils/format_output.py | .py | # Author: Milan Lysonek
#
# See the LICENSE file for legal information regarding use of this file.
"""Helper functions for output formatting"""
def none_as_unknown(text, number):
"""
Return text if text isn't None or empty, otherwise return 'unknown(number)'
:type text: str
:param text: string, that... | 20 | 483 |
XX-Net | code/default/lib/noarch/tlslite/utils/pem.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
from .compat import *
import binascii
#This code is shared with tackpy (somewhat), so I'd rather make minimal
#changes, and preserve the use of a2b_base64 throughout.
def dePem(s, name):
"""Decode a PEM string into a... | 100 | 3,667 |
XX-Net | code/default/lib/noarch/tlslite/utils/keyfactory.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""Factory functions for asymmetric cryptography."""
from .compat import *
from .rsakey import RSAKey
from .python_rsakey import Python_RSAKey
from .python_ecdsakey import Python_ECDSAKey
from .python_dsakey import Pytho... | 279 | 10,460 |
XX-Net | code/default/lib/noarch/tlslite/utils/pycrypto_aes.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""PyCrypto AES implementation."""
from .cryptomath import *
from .aes import *
if pycryptoLoaded:
import Crypto.Cipher.AES
def new(key, mode, IV):
return PyCrypto_AES(key, mode, IV)
class PyCrypto_... | 30 | 840 |
XX-Net | code/default/lib/noarch/tlslite/utils/openssl_tripledes.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""OpenSSL/M2Crypto 3DES implementation."""
from .cryptomath import *
from .tripledes import *
if m2cryptoLoaded:
def new(key, mode, IV):
return OpenSSL_TripleDES(key, mode, IV)
class OpenSSL_TripleDES(... | 52 | 1,801 |
XX-Net | code/default/lib/noarch/tlslite/utils/ecc.py | .py | # Copyright (c) 2015, Hubert Kario
#
# See the LICENSE file for legal information regarding use of this file.
"""Methods for dealing with ECC points"""
from .codec import Parser, Writer, DecodeError
from .cryptomath import bytesToNumber, numberToByteArray, numBytes
from .compat import ecdsaAllCurves
import ecdsa
def... | 72 | 2,676 |
XX-Net | code/default/lib/noarch/tlslite/utils/rijndael.py | .py | # Authors:
# Bram Cohen
# Trevor Perrin - various changes
#
# See the LICENSE file for legal information regarding use of this file.
# Also see Bram Cohen's statement below
"""
A pure python (slow) implementation of rijndael with a decent interface
To include -
from rijndael import Rijndael
To do a key setup -
... | 1,106 | 53,143 |
XX-Net | code/default/lib/noarch/tlslite/utils/openssl_rc4.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""OpenSSL/M2Crypto RC4 implementation."""
from .cryptomath import *
from .rc4 import RC4
if m2cryptoLoaded:
def new(key):
return OpenSSL_RC4(key)
class OpenSSL_RC4(RC4):
def __init__(self, key... | 29 | 709 |
XX-Net | code/default/lib/noarch/tlslite/utils/dsakey.py | .py | """Abstract class for DSA."""
class DSAKey(object):
"""This is an abstract base class for DSA keys.
Particular implementations of DSA keys, such as
:py:class:`~.python_dsakey.Python_DSAKey`
... more coming
inherit from this.
To create or parse an DSA key, don't use one of these classes
di... | 112 | 3,144 |
XX-Net | code/default/lib/noarch/tlslite/utils/python_key.py | .py |
from .python_rsakey import Python_RSAKey
from .python_ecdsakey import Python_ECDSAKey
from .python_dsakey import Python_DSAKey
from .python_eddsakey import Python_EdDSAKey
from .pem import dePem, pemSniff
from .asn1parser import ASN1Parser
from .cryptomath import bytesToNumber
from .compat import compatHMAC
from ecds... | 273 | 11,034 |
XX-Net | code/default/lib/noarch/tlslite/utils/python_aesgcm.py | .py | # Author: Google
# See the LICENSE file for legal information regarding use of this file.
"""Pure-Python AES-GCM implementation."""
from .aesgcm import AESGCM
from .rijndael import Rijndael
def new(key):
return AESGCM(key, "python", Rijndael(key, 16).encrypt)
| 12 | 268 |
XX-Net | code/default/lib/noarch/tlslite/utils/aes.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""Abstract class for AES."""
class AES(object):
def __init__(self, key, mode, IV, implementation):
if len(key) not in (16, 24, 32):
raise AssertionError()
if mode not in [2, 6]:
... | 40 | 1,222 |
XX-Net | code/default/lib/noarch/tlslite/utils/deprecations.py | .py | # Copyright (c) 2018 Hubert Kario
#
# See the LICENSE file for legal information regarding use of this file.
"""Methods for deprecating old names for arguments or attributes."""
import warnings
import inspect
from functools import wraps
def deprecated_class_name(old_name,
warn="Class name '{... | 219 | 8,742 |
XX-Net | code/default/lib/noarch/tlslite/utils/rsakey.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""Abstract class for RSA."""
from .cryptomath import *
from . import tlshashlib as hashlib
from ..errors import MaskTooLongError, MessageTooLongError, EncodingError, \
InvalidSignature, UnknownRSAType
from .constantt... | 688 | 26,348 |
XX-Net | code/default/lib/noarch/tlslite/utils/poly1305.py | .py | # Copyright (c) 2015, Hubert Kario
#
# See the LICENSE file for legal information regarding use of this file.
"""Implementation of Poly1305 authenticator for RFC 7539"""
from .cryptomath import divceil
class Poly1305(object):
"""Poly1305 authenticator"""
P = 0x3fffffffffffffffffffffffffffffffb # 2^130-5
... | 50 | 1,504 |
XX-Net | code/default/lib/noarch/tlslite/utils/__init__.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""Toolkit for crypto and other stuff."""
__all__ = ["aes",
"asn1parser",
"cipherfactory",
"codec",
"cryptomath",
"datefuncs",
"compat",
"keyfac... | 33 | 837 |
XX-Net | code/default/lib/noarch/tlslite/utils/tlshmac.py | .py | # Author: Hubert Kario (c) 2019
# see LICENCE file for legal information regarding use of this file
"""
HMAC module that works in FIPS mode.
Note that this makes this code FIPS non-compliant!
"""
# Because we are extending the hashlib module, we need to import all its
# fields to suppport the same uses
from . import... | 89 | 3,079 |
XX-Net | code/default/lib/noarch/tlslite/utils/pycrypto_tripledes.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""PyCrypto 3DES implementation."""
from .cryptomath import *
from .tripledes import *
if pycryptoLoaded:
import Crypto.Cipher.DES3
def new(key, mode, IV):
return PyCrypto_TripleDES(key, mode, IV)
c... | 29 | 872 |
XX-Net | code/default/lib/noarch/tlslite/utils/pycrypto_aesgcm.py | .py | # Author: Google
# See the LICENSE file for legal information regarding use of this file.
"""PyCrypto AES-GCM implementation."""
from .cryptomath import *
from .aesgcm import AESGCM
if pycryptoLoaded:
import Crypto.Cipher.AES
def new(key):
cipher = Crypto.Cipher.AES.new(bytes(key))
def encry... | 17 | 446 |
XX-Net | code/default/lib/noarch/tlslite/utils/pycrypto_rsakey.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""PyCrypto RSA implementation."""
from __future__ import print_function
import sys
from .cryptomath import *
from .rsakey import *
from .python_rsakey import Python_RSAKey
from .compat import compatLong
if pycryptoLoa... | 72 | 2,644 |
XX-Net | code/default/lib/noarch/tlslite/utils/python_rc4.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""Pure-Python RC4 implementation."""
from .rc4 import RC4
from .cryptomath import *
def new(key):
return Python_RC4(key)
class Python_RC4(RC4):
def __init__(self, keyBytes):
RC4.__init__(self, keyBytes,... | 42 | 1,073 |
XX-Net | code/default/lib/noarch/tlslite/utils/chacha.py | .py | # Copyright (c) 2015, Hubert Kario
#
# See the LICENSE file for legal information regarding use of this file.
"""Pure Python implementation of ChaCha cipher
Implementation that follows RFC 7539 closely.
"""
from __future__ import division
from .compat import compat26Str
import copy
import struct
try:
# in Python ... | 158 | 4,821 |
XX-Net | code/default/lib/noarch/tlslite/utils/aesccm.py | .py | # Copyright (c) 2019 Ivan Nikolchev
#
# See the LICENSE file for legal information regarding use of this file.
#
from __future__ import division
from tlslite.utils.cryptomath import numberToByteArray
from tlslite.utils import python_aes
class AESCCM(object):
# AES-CCM implementation per RFC3610
def __init__... | 156 | 4,966 |
XX-Net | code/default/lib/noarch/tlslite/utils/python_aes.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""Pure-Python AES implementation."""
from .aes import AES
from .rijndael import Rijndael
from .cryptomath import bytesToNumber, numberToByteArray
__all__ = ['new', 'Python_AES']
def new(key, mode, IV):
# IV argume... | 120 | 3,667 |
XX-Net | code/default/lib/noarch/tlslite/utils/dns_utils.py | .py | # Copyright (c) 2017 Hubert Kario
#
# See the LICENSE file for legal information regarding use of this file.
"""Utilities for handling DNS hostnames"""
import re
def is_valid_hostname(hostname):
"""
Check if the parameter is a valid hostname.
:type hostname: str or bytearray
:param hostname: string... | 43 | 1,468 |
XX-Net | code/default/lib/noarch/tlslite/utils/python_rsakey.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""Pure-Python RSA implementation."""
import threading
from .cryptomath import *
from .rsakey import *
from .pem import *
from .deprecations import deprecated_params
if GMPY2_LOADED:
from gmpy2 import mpz
elif gmpyLoad... | 152 | 4,691 |
XX-Net | code/default/lib/noarch/tlslite/utils/datefuncs.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
import os
#Functions for manipulating datetime objects
#CCYY-MM-DDThh:mm:ssZ
def parseDateClass(s):
year, month, day = s.split("-")
day, tail = day[:2], day[2:]
hour, minute, second = tail[1:].split(":")
s... | 78 | 2,278 |
XX-Net | code/default/lib/noarch/tlslite/utils/openssl_aesgcm.py | .py | # Author: Ivan Nikolchev
# See the LICENSE file for legal information regarding use of this file.
"""AESGCM with CTR from m2crypto"""
from tlslite.utils.cryptomath import m2cryptoLoaded
from tlslite.utils.aesgcm import AESGCM
from tlslite.utils import openssl_aes
from tlslite.utils.rijndael import Rijndael
if m2cryp... | 21 | 664 |
XX-Net | code/default/lib/noarch/tlslite/utils/openssl_aesccm.py | .py | # Author: Ivan Nikolchev
# See the LICENSE file for legal information regarding use of this file.
"""AESCCM with CTR and CBC from m2crypto"""
from tlslite.utils.cryptomath import m2cryptoLoaded
from tlslite.utils.aesccm import AESCCM
from tlslite.utils import openssl_aes
if m2cryptoLoaded:
def new(key, tagLengt... | 22 | 733 |
XX-Net | code/default/lib/noarch/tlslite/utils/eddsakey.py | .py | # Author: Hubert Kario
# See the LICENSE file for legal information regarding use of this file.
"""Abstract class for EdDSA."""
class EdDSAKey(object):
"""This is an abstract base class for EdDSA keys.
Particular implementations of EdDSA keys, such as
:py:class:`~.python_eddsakey.Python_EdDSAKey`
..... | 157 | 4,766 |
XX-Net | code/default/lib/noarch/tlslite/utils/python_dsakey.py | .py | # Author: Frantisek Krenzelok
"""Pure-Python RSA implementation."""
from ecdsa.der import encode_sequence, encode_integer, \
remove_sequence, remove_integer
from .cryptomath import getRandomNumber, getRandomPrime, \
powMod, numBits, bytesToNumber, invMod, \
secureHash, GMPY2_LOADED, gmpyLoaded
from ... | 136 | 3,777 |
XX-Net | code/default/lib/noarch/tlslite/utils/ecdsakey.py | .py | # Author: Stanislav Zidek
# See the LICENSE file for legal information regarding use of this file.
"""Abstract class for ECDSA."""
from .cryptomath import secureHash
class ECDSAKey(object):
"""This is an abstract base class for ECDSA keys.
Particular implementations of ECDSA keys, such as
:py:class:`~.... | 182 | 5,590 |
XX-Net | code/default/lib/noarch/tlslite/utils/cipherfactory.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""Factory functions for symmetric cryptography."""
import os
from tlslite.utils import python_aes
from tlslite.utils import python_aesgcm
from tlslite.utils import python_aesccm
from tlslite.utils import python_chacha20... | 211 | 5,957 |
XX-Net | code/default/lib/noarch/tlslite/utils/cryptomath.py | .py | # Authors:
# Trevor Perrin
# Martin von Loewis - python 3 port
# Yngve Pettersen (ported by Paul Sokolovsky) - TLS 1.2
#
# See the LICENSE file for legal information regarding use of this file.
"""cryptomath module
This module has basic math/crypto code."""
from __future__ import print_function
import os
impor... | 431 | 12,585 |
XX-Net | code/default/lib/noarch/tlslite/utils/compat.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""Miscellaneous functions to mask Python version differences."""
import sys
import re
import os
import platform
import math
import binascii
import traceback
import time
import ecdsa
if sys.version_info >= (3,0):
de... | 232 | 7,229 |
XX-Net | code/default/lib/noarch/tlslite/utils/python_aesccm.py | .py | # Author: Ivan Nikolchev
# See the LICENSE file for legal information regarding use of this file.
""" Pure Python AES-CCM implementation."""
from tlslite.utils.aesccm import AESCCM
def new(key, tagLength=16):
return AESCCM(key, "python", bytearray(16), tagLength)
| 10 | 271 |
XX-Net | code/default/lib/noarch/tlslite/utils/python_eddsakey.py | .py | # Author Hubert Kario, copyright 2021
from .eddsakey import EdDSAKey
from ecdsa.keys import BadSignatureError
from ecdsa.der import UnexpectedDER
from .cryptomath import numBits
from .compat import compatHMAC
class Python_EdDSAKey(EdDSAKey):
"""
Concrete implementation of EdDSA object backed by python-ecdsa.... | 65 | 2,101 |
XX-Net | code/default/lib/noarch/tlslite/utils/openssl_aes.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""OpenSSL/M2Crypto AES implementation."""
from .cryptomath import *
from .aes import *
from .python_aes import Python_AES_CTR
if m2cryptoLoaded:
def new(key, mode, IV):
# IV argument name is a part of the i... | 136 | 4,539 |
XX-Net | code/default/lib/noarch/tlslite/utils/python_chacha20_poly1305.py | .py | # Author: Hubert Kario (c) 2015
#
# See the LICENSE file for legal information regarding use of this file.
"""Pure-Python ChaCha20/Poly1305 implementation."""
from .chacha20_poly1305 import CHACHA20_POLY1305
def new(key):
"""Return an AEAD cipher implementation"""
return CHACHA20_POLY1305(key, "python")
| 12 | 316 |
XX-Net | code/default/lib/noarch/tlslite/utils/pycrypto_rc4.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""PyCrypto RC4 implementation."""
from .cryptomath import *
from .rc4 import *
if pycryptoLoaded:
import Crypto.Cipher.ARC4
def new(key):
return PyCrypto_RC4(key)
class PyCrypto_RC4(RC4):
... | 28 | 764 |
XX-Net | code/default/lib/noarch/tlslite/utils/tlshashlib.py | .py | # Author: Hubert Kario (c) 2015
# see LICENCE file for legal information regarding use of this file
"""hashlib that handles FIPS mode."""
# Because we are extending the hashlib module, we need to import all its
# fields to suppport the same uses
# pylint: disable=unused-wildcard-import, wildcard-import
from hashlib i... | 33 | 1,024 |
XX-Net | code/default/lib/noarch/tlslite/utils/openssl_rsakey.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""OpenSSL/M2Crypto RSA implementation."""
from .cryptomath import *
from .rsakey import *
from .python_rsakey import Python_RSAKey
from .compat import compatAscii2Bytes, compat_b2a
#copied from M2Crypto.util.py, so whe... | 184 | 7,073 |
XX-Net | code/default/lib/noarch/tlslite/utils/x25519.py | .py | # Authors:
# Hubert Kario (2017)
#
# See the LICENSE file for legal information regarding use of this file.
"""Handling X25519 and X448 curve based key agreement protocol."""
from .cryptomath import bytesToNumber, numberToByteArray, divceil
# the names of the variables come directly from RFC 7748 so changing them
#... | 137 | 3,255 |
XX-Net | code/default/lib/noarch/tlslite/utils/python_tripledes.py | .py | #################################################
# Documentation #
#################################################
# Author: Todd Whiteman
# Date: 16th March, 2009
# Verion: 2.0.0
# License: Public Domain - free to do as you wish
# Homepage: http://twhiteman.netfirms.com/Des... | 492 | 16,932 |
XX-Net | code/default/lib/noarch/tlslite/utils/python_ecdsakey.py | .py | # Author Hubert Kario, copyright 2019
from .ecdsakey import ECDSAKey
from ecdsa.curves import curves
from ecdsa.util import sigencode_der, sigdecode_der
from ecdsa.keys import VerifyingKey, SigningKey, BadSignatureError
from ecdsa.ellipticcurve import Point
from ecdsa.der import UnexpectedDER
from . import tlshashlib
... | 96 | 3,388 |
XX-Net | code/default/lib/noarch/tlslite/utils/tackwrapper.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
try:
from tack.structures.Tack import Tack
from tack.structures.TackExtension import TackExtension
from tack.tls.TlsCertificate import TlsCertificate
tackpyLoaded = True
except ImportError:
tackpyL... | 12 | 334 |
XX-Net | code/default/lib/noarch/tlslite/utils/codec.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""Classes for reading/writing binary data (such as TLS records)."""
from __future__ import division
import sys
import struct
from struct import pack
from .compat import bytes_to_int
class DecodeError(SyntaxError):
... | 466 | 15,543 |
XX-Net | code/default/lib/noarch/tlslite/utils/rc4.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""Abstract class for RC4."""
class RC4(object):
def __init__(self, keyBytes, implementation):
if len(keyBytes) < 16 or len(keyBytes) > 256:
raise ValueError()
self.isBlockCipher = False
... | 21 | 561 |
XX-Net | code/default/lib/noarch/tlslite/utils/constanttime.py | .py | # Copyright (c) 2015, Hubert Kario
#
# See the LICENSE file for legal information regarding use of this file.
"""Various constant time functions for processing sensitive data"""
from __future__ import division
from .compat import compatHMAC
import hmac
def ct_lt_u32(val_a, val_b):
"""
Returns 1 if val_a < va... | 219 | 6,399 |
XX-Net | code/default/lib/noarch/tlslite/utils/aesgcm.py | .py | # Author: Google
# See the LICENSE file for legal information regarding use of this file.
# GCM derived from Go's implementation in crypto/cipher.
#
# https://golang.org/src/crypto/cipher/gcm.go
# GCM works over elements of the field GF(2^128), each of which is a 128-bit
# polynomial. Throughout this implementation, ... | 194 | 6,866 |
XX-Net | code/default/lib/noarch/tlslite/utils/tripledes.py | .py | # Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.
"""Abstract class for 3DES."""
class TripleDES(object):
def __init__(self, key, mode, IV, implementation):
if len(key) != 24:
raise ValueError()
if mode != 2:
raise ValueError()... | 29 | 870 |
XX-Net | code/default/lib/win32/win_inet_pton.py | .py | # This software released into the public domain. Anyone is free to copy,
# modify, publish, use, compile, sell, or distribute this software,
# either in source code form or as a compiled binary, for any purpose,
# commercial or non-commercial, and by any means.
import socket
import ctypes
import os
import utils
clas... | 88 | 2,809 |
XX-Net | code/default/lib/win32/win32elevate.py | .py | '''
Copyright (c) 2013 by JustAMan at GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distr... | 210 | 8,681 |
XX-Net | code/default/lib/win32/win32_proxy_manager.py | .py | import winreg as winreg
from ctypes import *
from ctypes.wintypes import *
LPWSTR = POINTER(WCHAR)
HINTERNET = LPVOID
INTERNET_OPTION_REFRESH = 37
INTERNET_OPTION_SETTINGS_CHANGED = 39
INTERNET_OPTION_PER_CONNECTION_OPTION = 75
INTERNET_PER_CONN_FLAGS = 1
INTERNET_PER_CONN_PROXY_SERVER = 2
INTERNET_PER_CONN_PROXY_BYP... | 140 | 5,149 |
XX-Net | code/default/lib/win32/systray/traybar.py | .py | import os
from .win32_adapter import *
import threading
import uuid
class SysTrayIcon(object):
QUIT = 'QUIT'
SPECIAL_ACTIONS = [QUIT]
FIRST_ID = 1023
def __init__(self,
icon,
hover_text,
menu_options=None,
on_quit=None,
... | 286 | 11,060 |
XX-Net | code/default/lib/win32/systray/win32_adapter.py | .py | import ctypes
import locale
RegisterWindowMessage = ctypes.windll.user32.RegisterWindowMessageA
LoadCursor = ctypes.windll.user32.LoadCursorA
LoadIcon = ctypes.windll.user32.LoadIconA
LoadImage = ctypes.windll.user32.LoadImageA
RegisterClass = ctypes.windll.user32.RegisterClassA
CreateWindowEx = ctypes.windll.user32.C... | 210 | 6,987 |
XX-Net | code/default/lib/tests/test_http_client.py | .py | import os
import unittest
import time
import utils
import json
import simple_http_client
import tempfile
class HttpClientTest(unittest.TestCase):
def test_get(self):
client = simple_http_client.Client(timeout=10)
url = "https://raw.githubusercontent.com/XX-net/XX-Net/master/code/default/x_tunnel/l... | 78 | 2,560 |
XX-Net | code/default/lib/tests/test_queue.py | .py | import time
import threading
from unittest import TestCase
# from simple_queue import Queue
from queue import Queue
class TestSimpleQueue(TestCase):
@staticmethod
def pub(q, x):
time.sleep(2)
print("put x")
q.put(x)
def test_basic(self):
q1 = Queue()
q1.put("a")
... | 25 | 496 |
XX-Net | code/default/lib/tests/test_http_server.py | .py | import unittest
import utils
import simple_http_client
import simple_http_server
class HttpClientTest(unittest.TestCase):
def test_get(self):
server = simple_http_server.HTTPServer(('', 8880), simple_http_server.TestHttpServer, ".")
server.start()
client = simple_http_client.Client(timeou... | 20 | 542 |
XX-Net | code/default/lib/tests/stress_boringssl2.py | .py |
import socket
from boringssl import lib as bssl, ffi
class SSLConnection(object):
BIO_CLOSE = 1
def __init__(self, context, sock, ip_str=None, sni=None, on_close=None):
self._context = context
self._sock = sock
# self.ip_str = utils.to_bytes(ip_str)
self.sni = sni
se... | 144 | 4,182 |
XX-Net | code/default/lib/tests/test_utils.py | .py | import unittest
import utils
import re
def split_the_ip(ip_str):
# ips = utils.to_str(ip_str).split(":")[0:-1]
# ip = ":".join(ips)
ip_pattern = r'(?P<ip>(\d{1,3}\.){3}\d{1,3}|(\[[0-9a-fA-F:]+\])):(?P<port>\d+)'
match = re.match(ip_pattern, ip_str)
ip_address = match.group('ip')
if '[' in ip... | 74 | 2,289 |
XX-Net | code/default/lib/tests/stress_boringssl.py | .py | import sys
import os
current_path = os.path.dirname(os.path.abspath(__file__))
local_path = os.path.abspath(os.path.join(current_path, os.pardir))
root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir))
python_path = root_path
sys.path.append(root_path)
sys.path.append(local_path)
noarch_lib = ... | 71 | 2,096 |
XX-Net | code/default/smart_router/local/pipe_socks.py | .py | import threading
import time
import sys
import socket
import errno
from xx_six import BlockingIOError
import utils
import selectors2 as selectors
from . import global_var as g
from xlog import getLogger
xlog = getLogger("smart_router")
class PipeSocks(object):
def __init__(self, buf_size=16*1024):
self.... | 397 | 15,717 |
XX-Net | code/default/smart_router/local/socket_wrap.py | .py | import time
from xlog import getLogger
xlog = getLogger("smart_router")
class SocketWrap(object):
def __init__(self, sock, ip=None, port=None, host="", target=""):
self._sock = sock
self.ip = ip
self.port = port
self.host = host
self.target = target
self.recved_da... | 83 | 2,223 |
XX-Net | code/default/smart_router/local/dns_server.py | .py | #!/usr/bin/env python
# coding:utf-8
import os
import sys
import threading
import socket
import time
import select
import struct
current_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir))
top_path = os.path.abspath(os.path.join(root_path, os... | 237 | 8,650 |
XX-Net | code/default/smart_router/local/ip_region.py | .py | #!/usr/bin/env python
# coding: utf-8
import os
import struct
import sys
import socket
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
current_path = os.path.dirname(os.path.abspath(__file__))
launcher_path = os.path.abspath( os.path.join(current_path, os.pardir, os.par... | 285 | 9,876 |
XX-Net | code/default/smart_router/local/gfwlist.py | .py | #!/usr/bin/env python
# coding:utf-8
import os
import sys
import base64
import re
import socket
import struct
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
current_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath(os.path.join(current_path... | 258 | 8,188 |
XX-Net | code/default/smart_router/local/proxy_handler.py | .py | import time
import socket
import struct
import json
try:
from urllib.parse import urlparse
from urllib.parse import parse_qs
except ImportError:
from urlparse import urlparse
from . import pac_server
from . import global_var as g
from .socket_wrap import SocketWrap
import utils
from .smart_route import ha... | 409 | 13,590 |
XX-Net | code/default/smart_router/local/dns_query.py | .py | #!/usr/bin/env python
# coding:utf-8
# public DNS servers https://en.wikipedia.org/wiki/Public_recursive_name_server
import json
import os
import sys
import threading
import socket
import time
import re
import ssl
import random
import struct
import subprocess
current_path = os.path.dirname(os.path.abspath(__file__))... | 740 | 24,277 |
XX-Net | code/default/smart_router/local/connect_manager.py | .py | import os
import sys
import socket
import operator
import time
import threading
import struct
import utils
if __name__ == '__main__':
current_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath(os.path.join(current_path, os.pardir))
python_path = root_path
noarch_lib = os.pat... | 178 | 6,338 |
XX-Net | code/default/smart_router/local/__init__.py | .py | import os
import sys
current_path = os.path.dirname(os.path.abspath(__file__))
launcher_path = os.path.abspath( os.path.join(current_path, os.pardir, os.pardir, "launcher"))
root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir))
import env_info
data_path = os.path.join(env_info.data_path, "sma... | 189 | 5,450 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.