관리-도구
편집 파일: low_level.cpython-36.opt-1.pyc
3 nf�\�/ � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddlm Z m Z mZ ejdej �Zdd� Zdd � Zd d� Zddd �Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� 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� )�Security�CoreFoundation�CFConsts; -----BEGIN CERTIFICATE----- (.*?) -----END CERTIFICATE-----c C s t jt 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 �/usr/lib/python3.6/low_level.py�_cf_data_from_bytes s r c C sZ t | �}dd� | D �}dd� | D �}tj| |� }tj| |� }tjtj|||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 r - s )r r � CFTypeRefZCFDictionaryCreater ZkCFTypeDictionaryKeyCallBacksZkCFTypeDictionaryValueCallBacks)ZtuplesZdictionary_size�keys�valuesZcf_keysZ cf_valuesr r r �_cf_dictionary_from_tuples% s r c C sn t j| t jt j��}tj|tj�}|dkrXt jd�}tj ||dtj�}|sRt d��|j}|dk rj|jd�}|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 CFStringRefzutf-8) �ctypes�castZPOINTERZc_void_pr ZCFStringGetCStringPtrr ZkCFStringEncodingUTF8Zcreate_string_bufferZCFStringGetCString�OSError�value�decode)r Zvalue_as_void_p�string�buffer�resultr r r �_cf_string_to_unicode; s"