Graybyt3 Was Here
Linux host1.absolutelystunningcenterpieces.com 3.10.0-957.21.3.el7.x86_64 #1 SMP Tue Jun 18 16:35:19 UTC 2019 x86_64
Apache
69.167.136.200
/
opt
/
alt
/
python38
/
lib
/
python3.8
/
site-packages
/
urllib3
/
contrib
/
_securetransport
/
__pycache__
[ HOME ]
Exec
Submit
low_level.cpython-38.pyc
U ��`T6 � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl m Z mZmZ e� dej�Zdd� Zdd � Zd d� Zdd � Zdd� Zd&dd�Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zddd d!d"d#�Zd$d%� ZdS )'a� Low-level helpers for the SecureTransport bindings. These are Python functions that are not directly related to the high-level APIs but are necessary to get them to work. They include a whole bunch of low-level CoreFoundation messing about and memory management. The concerns in this module are almost entirely about trying to avoid memory leaks and providing appropriate and useful assistance to the higher-level code. � N� )�CFConst�CoreFoundation�Securitys; -----BEGIN CERTIFICATE----- (.*?) -----END CERTIFICATE-----c C s t �t j| t| ��S )zv Given a bytestring, create a CFData object from it. This CFData object must be CFReleased by the caller. )r �CFDataCreate�kCFAllocatorDefault�len)Z bytestring� r �[/opt/alt/python38/lib/python3.8/site-packages/urllib3/contrib/_securetransport/low_level.py�_cf_data_from_bytes s �r c C sZ t | �}dd� | D �}dd� | D �}tj| |� }tj| |� }t�tj|||tjtj�S )zK Given a list of Python tuples, create an associated CFDictionary. c s s | ]}|d V qdS )r Nr ��.0�tr r r � <genexpr>, s z-_cf_dictionary_from_tuples.<locals>.<genexpr>c s s | ]}|d V qdS )r Nr r r r r r - s )r r � CFTypeRefZCFDictionaryCreater ZkCFTypeDictionaryKeyCallBacksZkCFTypeDictionaryValueCallBacks)ZtuplesZdictionary_size�keys�valuesZcf_keysZ cf_valuesr r r �_cf_dictionary_from_tuples% s �r c C s t �| �}t�tj|tj�}|S )zi Given a Python binary data, create a CFString. The string must be CFReleased by the caller. )�ctypesZc_char_pr ZCFStringCreateWithCStringr r �kCFStringEncodingUTF8)Zpy_bstrZc_str�cf_strr r r �_cfstr; s �r c C s� d}zdt �t jdt�t j��}|s*td��| D ]6}t|�}|sFtd��zt � ||� W 5 t �|� X q.W n@ t k r� } z"|r�t �|� t�d|f ��W 5 d}~X Y nX |S )z� Given a list of Python binary data, create an associated CFMutableArray. The array must be CFReleased by the caller. Raises an ssl.SSLError on failure. Nr �Unable to allocate memory!zUnable to allocate array: %s) r �CFArrayCreateMutabler r �byref�kCFTypeArrayCallBacks�MemoryErrorr � CFRelease�CFArrayAppendValue� BaseException�ssl�SSLError)ZlstZcf_arr�itemr �er r r �_create_cfstring_arrayI s* � "r$ c C sn t �| t �t j��}t�|tj�}|dkrXt �d�}t� ||dtj�}|sRt d��|j}|dk rj|�d�}|S )z� Creates a Unicode string from a CFString object. Used entirely for error reporting. Yes, it annoys me quite a lot that this function is this complex. Ni z'Error copying C string from CFStringRef�utf-8) r �castZPOINTERZc_void_pr ZCFStringGetCStringPtrr r Zcreate_string_bufferZCFStringGetCString�OSError�value�decode)r( Zvalue_as_void_p�string�buffer�resultr r r �_cf_string_to_unicodeh s&