|
Server : Apache System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64 User : njnconst ( 1116) PHP Version : 8.4.18 Disable Function : NONE Directory : /usr/lib/python2.7/site-packages/asn1crypto/ |
Upload File : |
�
y�\c @` s� d Z 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 m
Z
d d l m Z
m Z m Z e j d k r� d d l m Z n d d l m Z d
� Z d d � Z d � Z e d
� Z d S( uq
Encoding DER to PEM and decoding PEM to DER. Exports the following items:
- armor()
- detect()
- unarmor()
i ( t unicode_literalst divisiont absolute_importt print_functionNi ( t unwrap( t type_namet str_clst byte_clsi ( t StringIO( t BytesIOc C` sU t | t � s- t t d t | � � � � n | j d � d k pT | j d � d k S( u�
Detect if a byte string seems to contain a PEM-encoded block
:param byte_string:
A byte string to look through
:return:
A boolean, indicating if a PEM-encoded block is contained in the byte
string
uC
byte_string must be a byte string, not %s
s
-----BEGINi����s
---- BEGIN( t
isinstanceR t TypeErrorR t
_type_namet find( t byte_string( ( s4 /tmp/pip-install-A1qMVe/asn1crypto/asn1crypto/pem.pyt detect s
c C` s� t | t � s. t t d t | � � � � n t | t � s[ t t d t | � � � � n | j � j d � } t � } | j d � | j | � | j d � | rxX | D]P } | j | j d � � | j d � | j | | j d � � | j d � q� W| j d � n t
j | � } t | � } d } x? | | k rs| j | | | d !� | j d � | d 7} q5W| j d
� | j | � | j d � | j
� S( u
Armors a DER-encoded byte string in PEM
:param type_name:
A unicode string that will be capitalized and placed in the header
and footer of the block. E.g. "CERTIFICATE", "PRIVATE KEY", etc. This
will appear as "-----BEGIN CERTIFICATE-----" and
"-----END CERTIFICATE-----".
:param der_bytes:
A byte string to be armored
:param headers:
An OrderedDict of the header lines to write after the BEGIN line
:return:
A byte string of the PEM block
uA
der_bytes must be a byte string, not %s
uD
type_name must be a unicode string, not %s
u asciis -----BEGIN s -----
s : s
i i@ s -----END ( R
R R R R R t uppert encodeR t writet base64t b64encodet lent getvalue( R t der_bytest headerst outputt keyt b64_bytest b64_lent i( ( s4 /tmp/pip-install-A1qMVe/asn1crypto/asn1crypto/pem.pyt armor2 s<