
    Bwg&                         d dl mZmZmZmZ d dlZd dlZd dlZd dlZddl	m
Z
mZ ddlmZ ddlmZmZ g dZ ej$                         ZddddZd	 Zd
 ZddZd Zd Zd Zd Zy)    )unicode_literalsdivisionabsolute_importprint_functionN   )str_cls	type_name)LibraryNotFoundError)__version____version_info__)r   r   backendffi
load_order
use_ctypesuse_openssluse_winlegacy)r   backend_configr   c                  t   t         d   	t         d   S t        5  t         d   t         d   cddd       S t        j                  dk(  r.t        j                         d   dk  r
dt         d<   n0dt         d<   n&t        j                  dk(  r
d	t         d<   n	d
t         d<   t         d   cddd       S # 1 sw Y   yxY w)zs
    :return:
        A unicode string of the backend being used: "openssl", "mac", "win",
        "winlegacy"
    r   Nwin32r      	winlegacywindarwinmacopenssl)_module_values_backend_locksysplatformgetwindowsversion     H/var/www/horilla/myenv/lib/python3.12/site-packages/oscrypto/__init__.pyr   r   "   s     i ,i((	 ))$0!),) ) <<7"$$&q)A-,7y),1y)\\X%(-N9%(1N9%i() ) )s   B.A/B..B7c                      t               dk7  ri S t        d   	t        d   S t        5  t        d   t        d   cddd       S i t        d<   t        d   cddd       S # 1 sw Y   yxY w)z
    :return:
        A dict of config info for the backend. Only currently used by "openssl",
        it may contains zero or more of the following keys:
         - "libcrypto_path"
         - "libssl_path"
    r   r   N)r   r   r   r!   r"   r#   _backend_configr%   >   sx     yI	&'3.//	 0*+7!"230 0 ,.'(./0 0 0s   AAA(c                    t        | t              st        dt        |       z        t        |t              st        dt        |      z        t        j
                  j                  |       st        d| z        t        j
                  j                  |      st        d|z        |Tt        |t              st        dt        |      z        t        j
                  j                  |      st        d|z        t        5  | ||d}t        d	   d
k(  rt        d   |k(  r
	 ddd       yt        d	   t        d      d
t        d	<   |t        d<   ddd       y# 1 sw Y   yxY w)a  
    Forces using OpenSSL dynamic libraries on OS X (.dylib) or Windows (.dll),
    or using a specific dynamic library on Linux/BSD (.so).

    This can also be used to configure oscrypto to use LibreSSL dynamic
    libraries.

    This method must be called before any oscrypto submodules are imported.

    :param libcrypto_path:
        A unicode string of the file path to the OpenSSL/LibreSSL libcrypto
        dynamic library.

    :param libssl_path:
        A unicode string of the file path to the OpenSSL/LibreSSL libssl
        dynamic library.

    :param trust_list_path:
        An optional unicode string of the path to a file containing
        OpenSSL-compatible CA certificates in PEM format. If this is not
        provided and the platform is OS X or Windows, the system trust roots
        will be exported from the OS and used for all TLS connections.

    :raises:
        ValueError - when one of the paths is not a unicode string
        OSError - when the trust_list_path does not exist on the filesystem
        oscrypto.errors.LibraryNotFoundError - when one of the path does not exist on the filesystem
        RuntimeError - when this function is called after another part of oscrypto has been imported
    z/libcrypto_path must be a unicode string, not %sz,libssl_path must be a unicode string, not %szlibcrypto does not exist at %szlibssl does not exist at %sNz0trust_list_path must be a unicode string, not %sz$trust_list_path does not exist at %s)libcrypto_pathlibssl_pathtrust_list_pathr   r   r   zRAnother part of oscrypto has already been imported, unable to force use of OpenSSL)
isinstancer   
ValueErrorr	   ospathexistsr
   OSErrorr   r   RuntimeError)r'   r(   r)   
new_configs       r#   r   r   U   sQ   > ng.JYWeMffggk7+G)T_J``aa77>>.)"#Cn#TUU77>>+&"#@;#NOO"/73OR[\kRllmmww~~o.@?RSS	 6,&.

 )$	1nEU6VZd6d6 6 )$0stt$-y!+5'(6 6 6s    E.&EE&c                  <   t         j                  dk7  r;t        j                         xs t         j                  } | dk(  rd} t        d| z        t        5  t
        d   dk(  r
	 ddd       yt
        d   t        d      dt
        d<   ddd       y# 1 sw Y   yxY w)	as  
    Forces use of the legacy Windows CryptoAPI. This should only be used on
    Windows XP or for testing. It is less full-featured than the Cryptography
    Next Generation (CNG) API, and as a result the elliptic curve and PSS
    padding features are implemented in pure Python. This isn't ideal, but it
    a shim for end-user client code. No one is going to run a server on Windows
    XP anyway, right?!

    :raises:
        EnvironmentError - when this function is called on an operating system other than Windows
        RuntimeError - when this function is called after another part of oscrypto has been imported
    r   DarwinzOS Xz9The winlegacy backend can only be used on Windows, not %sr   r   NzcAnother part of oscrypto has already been imported, unable to force use of Windows legacy CryptoAPI)r   r   systemEnvironmentErrorr   r   r0   )plats    r#   r   r      s     ||w 0CLL8DZ]aabb	 	0)$3	0 	0 )$0u  %0y!	0 	0 	0s   B,BBc                      t         5  t        d   dk(  r
	 ddd       yt        d   t        d      dt        d<   ddd       y# 1 sw Y   yxY w)z
    Forces use of ctypes instead of cffi for the FFI layer

    :raises:
        RuntimeError - when this function is called after another part of oscrypto has been imported
    r   ctypesNr   zQAnother part of oscrypto has already been imported, unable to force use of ctypes)r   r   r0   r!   r"   r#   r   r      s_     
 	)% H,	) 	) )$0c  !)u	) 	) 	)s   AAAc                      t         d   	t         d   S t        5  	 ddl} dt         d<   t         d   cddd       S # t        $ r dt         d<   Y &w xY w# 1 sw Y   yxY w)zh
    Returns the FFI module being used

    :return:
        A unicode string of "cffi" or "ctypes"
    r   Nr   cffir8   )r   r   r:   ImportError)r:   s    r#   r   r      sn     e(e$$	 %	-$*N5! e$% %  	-$,N5!	-	% %s+   A:AAAAAAc                  
    g dS )a)  
    Returns a list of the module and sub-module names for oscrypto in
    dependency load order, for the sake of live reloading code

    :return:
        A list of unicode strings of module names, as they would appear in
        sys.modules, ordered by which module should be reloaded first
    )Ezoscrypto._asn1zoscrypto._cipher_suiteszoscrypto._errorszoscrypto._intzoscrypto._typeszoscrypto.errorszoscrypto.versionoscryptozoscrypto._ffizoscrypto._pkcs12zoscrypto._pkcs5zoscrypto._randzoscrypto._tlszoscrypto._linux_bsd.trust_listz!oscrypto._mac._common_crypto_cffiz#oscrypto._mac._common_crypto_ctypeszoscrypto._mac._common_cryptoz#oscrypto._mac._core_foundation_cffiz%oscrypto._mac._core_foundation_ctypeszoscrypto._mac._core_foundationzoscrypto._mac._security_cffizoscrypto._mac._security_ctypeszoscrypto._mac._securityzoscrypto._mac.trust_listzoscrypto._mac.utilz!oscrypto._openssl._libcrypto_cffiz#oscrypto._openssl._libcrypto_ctypeszoscrypto._openssl._libcryptozoscrypto._openssl._libssl_cffiz oscrypto._openssl._libssl_ctypeszoscrypto._openssl._libsslzoscrypto._openssl.utilzoscrypto._win._cng_cffizoscrypto._win._cng_ctypeszoscrypto._win._cngzoscrypto._win._decodezoscrypto._win._advapi32_cffizoscrypto._win._advapi32_ctypeszoscrypto._win._advapi32zoscrypto._win._kernel32_cffizoscrypto._win._kernel32_ctypeszoscrypto._win._kernel32zoscrypto._win._secur32_cffizoscrypto._win._secur32_ctypeszoscrypto._win._secur32zoscrypto._win._crypt32_cffizoscrypto._win._crypt32_ctypeszoscrypto._win._crypt32zoscrypto._win.trust_listzoscrypto._win.utilzoscrypto.trust_listzoscrypto.utilzoscrypto.kdfzoscrypto._mac.symmetriczoscrypto._openssl.symmetriczoscrypto._win.symmetriczoscrypto.symmetriczoscrypto._asymmetriczoscrypto._ecdsazoscrypto._pkcs1zoscrypto._mac.asymmetriczoscrypto._openssl.asymmetriczoscrypto._win.asymmetriczoscrypto.asymmetriczoscrypto.keyszoscrypto._mac.tlszoscrypto._openssl.tlszoscrypto._win.tlszoscrypto.tlsr!   r!   r"   r#   r   r      s    F Fr"   )N)
__future__r   r   r   r   r,   r   r   	threading_typesr   r	   errorsr
   versionr   r   __all__Lockr   r   r   r%   r   r   r   r   r   r!   r"   r#   <module>rE      sm    R R 	  
  & ( 2	 	 )80.?6D0@)(%*Pr"   