%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/util.pyc

�
�ac@ s�ddlmZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZmZddl
mZddlmZd*Zeje�Zejdkr�d�Zn	d
�Zejdkr�d�Zn	d�Zd�Zdd�Zdd+d��YZd�Zd�Zd�Zed�Zed�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d �Z&d!�Z'd"�Z(d#�Z)d$�Z*d%e+fd&��YZ,d'�Z-d(�Z.d)�Z/dS(,i����(tdivisionN(tsha256(tPY3tint2bytetbtnexti(tder(tnormalise_bytesiiHi='t3cC s-ttj|d��djt|�d�S(s-Convert a bytestring to string of 0's and 1'stbigii(tbintintt
from_bytestzfilltlen(tent_256((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pytentropy_to_bitsscC sdjd�|D��S(s-Convert a bytestring to string of 0's and 1'stcs s.|]$}tt|��djd�VqdS(iiN(R
tordR
(t.0tx((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pys	<genexpr>s(tjoin(R((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pyRss2.7cC stt|��dS(Ni(RR
(R((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pyt
bit_length scC s|j�pdS(Ni(R(R((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pyR#scC sdtd|�dS(Nis%xi(R(torder((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pytorderlen'scC s�|dkst�|dkr*tj}nt|d�}|dd}x\tr�||�}t|�}t|| dd�d}d|ko�|knrK|SqKWdS(sReturn a random integer k such that 1 <= k < order, uniformly
    distributed across that range. Worst case should be a mean of 2 loops at
    (2**k)+2.

    Note that this function is not declared to be forwards-compatible: we may
    change the behavior in future releases. The entropy= argument (which
    should get a callable that behaves like os.urandom) can be used to
    achieve stability within a given release (for repeatable unit tests), but
    should not be used as a long-term-compatible key generation algorithm.
    iiitbaseiN(tAssertionErrortNonetosturandomRtTrueRR(Rtentropytupper_2t	upper_256Rtent_2trand_num((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pyt	randrange+s	tPRNGcB s#eZd�Zd�Zd�ZRS(cC s|j|�|_dS(N(tblock_generatort	generator(tselftseed((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pyt__init__IscC sIgt|�D]}t|j�^q
}tr8t|�Sdj|�SdS(NR(trangeRR'RtbytesR(R(tnumbytestita((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pyt__call__Ls(
cc sSd}xFtrNx/td||fj��j�D]}|Vq2W|d7}q	WdS(Nis
prng-%d-%si(RRtencodetdigest(R(R)tcountertbyte((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pyR&Ts
	)	(t__name__t
__module__R*R0R&(((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pyR%Cs		cC sut|�dt|��}ttj|�d�|dd}d|koW|knsqtd||f��|S(Niii(R%RRtbinasciithexlifyR(R)RRtnumber((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pyt%randrange_from_seed__overshoot_modulo\s$1cC sd|>dS(Ni((tnumbits((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pytlsb_of_onesiscC sAttj|dd�d�}|d}|d}|||fS(Niii(Rtmathtlog(RtbitsR,t	extrabits((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pytbits_and_bytesms 

cC s�t|�\}}}|r(|d7}n||�j�| }d|t|�|}dttj|�d�}d|ko�|kns�t�|S(Nisi(RAR2RRR7R8R(R)RthashmodR?t_bytesR@RR9((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pyt#randrange_from_seed__truncate_bytess
"cC s�ttj|dd�d�}|dd}||�j�| }d|t|�|}d||}|r�tt|d�t|�@�|d}ndttj	|�d�}d|ko�|kns�t
�|S(Niiiisii(RR=R>R2RRRR<R7R8R(R)RRBR?tmaxbytesRttopbitsR9((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pyt"randrange_from_seed__truncate_bits�s +"cC s�|dkst�t|�\}}}t|�}x{tr�td�}|rstt|d��t|�@�}nt|||��d}d|ko�|knr6|Sq6WdS(NiR(	RRAR%RRRRR<tstring_to_number(R)RR?R,R@tgeneratet	extrabytetguess((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pyt randrange_from_seed__trytryagain�s	%cC skt|�}dtd|�d}tj||j��}t|�|ksgtt|�|f��|S(Ns%0iR(RtstrR7t	unhexlifyR1RR(tnumRtltfmt_strtstring((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pytnumber_to_string�s
*cC sEt|�}dtd|�d}tj||j��}|| S(Ns%0iR(RRMR7RNR1(RORRPRQRR((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pytnumber_to_string_crop�scC sttj|�d�S(Ni(RR7R8(RR((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pyRH�scC sLt|�}t|�|ks6tt|�|f��ttj|�d�S(Ni(RRRRR7R8(RRRRP((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pytstring_to_number_fixedlen�s*cC s(t||�}t||�}||fS(N(RS(trtsRtr_strts_str((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pytsigencode_strings�scC s t|||�\}}||S(s�
    Encode the signature to raw format (:term:`raw encoding`)

    It's expected that this function will be used as a `sigencode=` parameter
    in :func:`ecdsa.keys.SigningKey.sign` method.

    :param int r: first parameter of the signature
    :param int s: second parameter of the signature
    :param int order: the order of the curve over which the signature was
        computed

    :return: raw encoding of ECDSA signature
    :rtype: bytes
    (RZ(RVRWRRXRY((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pytsigencode_string�scC s"tjtj|�tj|��S(s�
    Encode the signature into the ECDSA-Sig-Value structure using :term:`DER`.

    Encodes the signature to the following :term:`ASN.1` structure::

        Ecdsa-Sig-Value ::= SEQUENCE {
            r       INTEGER,
            s       INTEGER
        }

    It's expected that this function will be used as a `sigencode=` parameter
    in :func:`ecdsa.keys.SigningKey.sign` method.

    :param int r: first parameter of the signature
    :param int s: second parameter of the signature
    :param int order: the order of the curve over which the signature was
        computed

    :return: DER encoding of ECDSA signature
    :rtype: bytes
    (Rtencode_sequencetencode_integer(RVRWR((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pyt
sigencode_der�scC s-||dkr||}nt|||�S(Ni(RZ(RVRWR((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pytsigencode_strings_canonizes
cC s-||dkr||}nt|||�S(Ni(R[(RVRWR((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pytsigencode_string_canonize	s
cC s-||dkr||}nt|||�S(Ni(R^(RVRWR((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pytsigencode_der_canonizes
tMalformedSignaturecB seZdZRS(sB
    Raised by decoding functions when the signature is malformed.

    Malformed in this context means that the relevant strings or integers
    do not match what a signature over provided curve would create. Either
    because the byte strings have incorrect lengths or because the encoded
    values are too large.
    (R5R6t__doc__(((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pyRbscC s�t|�}t|�}t|�d|ksStdjd|t|����nt|| |�}t|||�}||fS(s�
    Decoder for :term:`raw encoding`  of ECDSA signatures.

    raw encoding is a simple concatenation of the two integers that comprise
    the signature, with each encoded using the same amount of bytes depending
    on curve size/order.

    It's expected that this function will be used as the `sigdecode=`
    parameter to the :func:`ecdsa.keys.VerifyingKey.verify` method.

    :param signature: encoded signature
    :type signature: bytes like object
    :param order: order of the curve over which the signature was computed
    :type order: int

    :raises MalformedSignature: when the encoding of the signature is invalid

    :return: tuple with decoded 'r' and 's' values of signature
    :rtype: tuple of ints
    isWInvalid length of signature, expected {0} bytes long, provided string is {1} bytes long(RRRRbtformatRU(t	signatureRRPRVRW((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pytsigdecode_string"scC s�t|�dks0tdjt|����n|\}}t|�}t|�}t|�}t|�|ks�tdj|t|����nt|�|ks�tdj|t|����nt||�}t||�}||fS(s�
    Decode the signature from two strings.

    First string needs to be a big endian encoding of 'r', second needs to
    be a big endian encoding of the 's' parameter of an ECDSA signature.

    It's expected that this function will be used as the `sigdecode=`
    parameter to the :func:`ecdsa.keys.VerifyingKey.verify` method.

    :param list rs_strings: list of two bytes-like objects, each encoding one
        parameter of signature
    :param int order: order of the curve over which the signature was computed

    :raises MalformedSignature: when the encoding of the signature is invalid

    :return: tuple with decoded 'r' and 's' values of signature
    :rtype: tuple of ints
    is3Invalid number of strings provided: {0}, expected 2sjInvalid length of first string ('r' parameter), expected {0} bytes long, provided string is {1} bytes longskInvalid length of second string ('s' parameter), expected {0} bytes long, provided string is {1} bytes long(RRbRdRRRU(t
rs_stringsRRXRYRPRVRW((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pytsigdecode_stringsCs&cC s�t|�}tj|�\}}|dkrLtjdtj|���ntj|�\}}tj|�\}}|dkr�tjdtj|���n||fS(s�
    Decoder for DER format of ECDSA signatures.

    DER format of signature is one that uses the :term:`ASN.1` :term:`DER`
    rules to encode it as a sequence of two integers::

        Ecdsa-Sig-Value ::= SEQUENCE {
            r       INTEGER,
            s       INTEGER
        }

    It's expected that this function will be used as as the `sigdecode=`
    parameter to the :func:`ecdsa.keys.VerifyingKey.verify` method.

    :param sig_der: encoded signature
    :type sig_der: bytes like object
    :param order: order of the curve over which the signature was computed
    :type order: int

    :raises UnexpectedDER: when the encoding of signature is invalid

    :return: tuple with decoded 'r' and 's' values of signature
    :rtype: tuple of ints
    Rstrailing junk after DER sig: %ss#trailing junk after DER numbers: %s(RRtremove_sequencet
UnexpectedDERR7R8tremove_integer(tsig_derRRgtemptyRVtrestRW((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pyt
sigdecode_derms		(iiiHi='ii((0t
__future__RRR=R7tsysthashlibRtsixRRRRRRt_compatRtoid_ecPublicKeyt
encode_oidtencoded_oid_ecPublicKeytversionRRRRR$R%R:R<RARDRGRLRSRTRHRURZR[R^R_R`Rat	ExceptionRbRfRhRo(((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/util.pyt<module>sN"				
							
						
	!	*

Zerion Mini Shell 1.0