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

�
�ac@s�dZddlZddlmZddlmZmZddlmZddlm	Z	ddlm
Z
dd	lmZdd
lm
Z
mZddlmZmZddlmZdd
lmZmZmZddlmZmZddlmZmZmZddlmZdddddgZdefd��YZ defd��YZ!de"fd��YZ#de$fd��YZ%de$fd��YZ&dS(sm

Primary classes for performing signing and verification operations.

.. glossary::

    raw encoding
        Conversion of public, private keys and signatures (which in
        mathematical sense are integers or pairs of integers) to strings of
        bytes that does not use any special tags or encoding rules.
        For any given curve, all keys of the same type or signatures will be
        encoded to byte strings of the same length. In more formal sense,
        the integers are encoded as big-endian, constant length byte strings,
        where the string length is determined by the curve order (e.g.
        for NIST256p the order is 256 bits long, so the private key will be 32
        bytes long while public key will be 64 bytes long). The encoding of a
        single integer is zero-padded on the left if the numerical value is
        low. In case of public keys and signatures, which are comprised of two
        integers, the integers are simply concatenated.

    uncompressed
        The most common formatting specified in PKIX standards. Specified in
        X9.62 and SEC1 standards. The only difference between it and
        :term:`raw encoding` is the prepending of a 0x04 byte. Thus an
        uncompressed NIST256p public key encoding will be 65 bytes long.

    compressed
        The public point representation that uses half of bytes of the
        :term:`uncompressed` encoding (rounded up). It uses the first byte of
        the encoding to specify the sign of the y coordinate and encodes the
        x coordinate as-is. The first byte of the encoding is equal to
        0x02 or 0x03. Compressed encoding of NIST256p public key will be 33
        bytes long.

    hybrid
        A combination of :term:`uncompressed` and :term:`compressed` encodings.
        Both x and y coordinates are stored just as in :term:`compressed`
        encoding, but the first byte reflects the sign of the y coordinate. The
        first byte of the encoding will be equal to 0x06 or 0x7. Hybrid
        encoding of NIST256p public key will be 65 bytes long.

    PEM
        The acronym stands for Privacy Enhanced Email, but currently it is used
        primarily as the way to encode :term:`DER` objects into text that can
        be either easily copy-pasted or transferred over email.
        It uses headers like ``-----BEGIN <type of contents>-----`` and footers
        like ``-----END <type of contents>-----`` to separate multiple
        types of objects in the same file or the object from the surrounding
        comments. The actual object stored is base64 encoded.

    DER
        Distinguished Encoding Rules, the way to encode :term:`ASN.1` objects
        deterministically and uniquely into byte strings.

    ASN.1
        Abstract Syntax Notation 1 is a standard description language for
        specifying serialisation and deserialisation of data structures in a
        portable and cross-platform way.

    bytes-like object
        All the types that implement the buffer protocol. That includes
        ``str`` (only on python2), ``bytes``, ``bytesarray``, ``array.array`
        and ``memoryview`` of those objects.
        Please note that ``array.array` serialisation (converting it to byte
        string) is endianess dependant! Signature computed over ``array.array``
        of integers on a big-endian system will not be verified on a
        little-endian system and vice-versa.
i����N(tsha1(tPY3tbi(tecdsa(tder(trfc6979(t
ellipticcurve(tNIST192pt
find_curve(tsquare_root_mod_primetSquareRootError(tRSZeroError(tstring_to_numbertnumber_to_stringt	randrange(tsigencode_stringtsigdecode_string(toid_ecPublicKeytencoded_oid_ecPublicKeytMalformedSignature(tnormalise_bytestBadSignatureErrortBadDigestErrortVerifyingKeyt
SigningKeytMalformedPointErrorcBseZdZRS(sl
    Raised when verification of signature failed.

    Will be raised irrespective of reason of the failure:

    * the calculated or provided hash does not match the signature
    * the signature does not match the curve/public key
    * the encoding of the signature is malformed
    * the size of the signature does not match the curve of the VerifyingKey
    (t__name__t
__module__t__doc__(((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyRYs
cBseZdZRS(s<Raised in case the selected hash is too large for the curve.(RRR(((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyRhscBseZdZRS(sBRaised in case the encoding of private or public key is malformed.(RRR(((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyRnscBs=eZdZdd�Zd�Zd�Zeee	e
d��Zd�Ze
d��Ze
d��Zed��Zeee	e
d	��Zee	d
��Zee	d��Zee	ed��Zee	ed
��Zd�Zd�Zd�Zdd�Zdd�Zdd�Zded�Zeed�ZRS(s�
    Class for handling keys that can verify signatures (public keys).

    :ivar ecdsa.curves.Curve curve: The Curve over which all the cryptographic
        operations will take place
    :ivar default_hashfunc: the function that will be used for hashing the
        data. Should implement the same API as hashlib.sha1
    :vartype default_hashfunc: callable
    :ivar pubkey: the actual public key
    :vartype pubkey: ecdsa.ecdsa.Public_key
    cCs4|std��nd|_d|_d|_dS(s>Unsupported, please use one of the classmethods to initialise.s2Please use VerifyingKey.generate() to construct meN(t	TypeErrortNonetcurvetdefault_hashfunctpubkey(tselft_error__please_use_generate((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyt__init__�s
		cCs.|jd�}dj||j|j�j�S(Nt
compresseds+VerifyingKey.from_string({0!r}, {1!r}, {2})(t	to_stringtformatRR tname(R"tpub_key((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyt__repr__�scCs5t|t�r1|j|jko0|j|jkStS(s9Return True if the points are identical, False otherwise.(t
isinstanceRRR!tNotImplemented(R"tother((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyt__eq__�scCs�|dt�}t|tj�s6tjj|�}n||_||_ytj|j	||�|_
Wn tjk
r�td��nX|j
|j
_
|S(s�
        Initialise the object from a Point object.

        This is a low-level method, generally you will not want to use it.

        :param point: The point to wrap around, the actual public key
        :type point: ecdsa.ellipticcurve.Point
        :param curve: The curve on which the point needs to reside, defaults
            to NIST192p
        :type curve: ecdsa.curves.Curve
        :param hashfunc: The default hash function that will be used for
            verification, needs to implement the same interface
            as hashlib.sha1
        :type hashfunc: callable
        :type bool validate_point: whether to check if the point lies on curve
            should always be used if the public point is not a result
            of our own calculation

        :raises MalformedPointError: if the public point does not lie on the
            curve

        :return: Initialised VerifyingKey object
        :rtype: VerifyingKey
        R#sPoint does not lie on the curve(tTrueR+RtPointJacobitfrom_affineRR Rt
Public_keyt	generatorR!tInvalidPointErrorRtorder(tclstpointRthashfunctvalidate_pointR"((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pytfrom_public_point�s		cCs%tjj|jjt�|j_dS(N(RR0R1R!R7R/(R"((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyt
precompute�s	cCs�|j}t|�|jks$t�||j }||j}t|�|jkrbtd��nt|�|jkr�td��nt|�}t|�}tj|j	||d|�S(s�
        Decode public point from :term:`raw encoding`.

        :term:`raw encoding` is the same as the :term:`uncompressed` encoding,
        but without the 0x04 byte at the beginning.
        sUnexpected length of encoded xsUnexpected length of encoded yi(
R5tlentverifying_key_lengthtAssertionErrortbaselenRRRR0R(tstringRR5txstystxty((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyt_from_raw_encoding�s	

c
Cs |d td�td�fkr1td��n|d td�k}t|d�}|j}|jj�}t|d|�|jj�||jj�|}yt||�}Wn"t	k
r�}td|��nX|t
|d@�kr�||}	n|}	tj|j||	d|�S(s-Decode public point from compressed encoding.isss#Malformed compressed point encodingis0Encoding does not correspond to a point on curve(
RRRR5RtptpowtaR	R
tboolRR0(
R@Rtis_evenRCR5RFtalphatbetateRD((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyt_from_compressed�s "	4
cCs�|d td�td�fks(t�|j|d|�}|r�|j�d@rj|d td�ks�|j�d@r�|d td�kr�td��n|S(s)Decode public point from hybrid encoding.isss"Inconsistent hybrid point encoding(RR>RERDR(R6R@RR9R7((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyt_from_hybrid�s(&'cCst|�}t|�}||jkr<|j||�}n�||jdkr�|d td�td�fkr�|j|||�}q|d td�kr�|j|d|�}qtd��n@||jdkr�|j||�}ntdj	|j
���|j||||�S(s�
        Initialise the object from byte encoding of public key.

        The method does accept and automatically detect the type of point
        encoding used. It supports the :term:`raw encoding`,
        :term:`uncompressed`, :term:`compressed` and :term:`hybrid` encodings.

        Note, while the method is named "from_string" it's a misnomer from
        Python 2 days when there were no binary strings. In Python 3 the
        input needs to be a bytes-like object.

        :param string: single point encoding of the public key
        :type string: :term:`bytes-like object`
        :param curve: the curve on which the public key is expected to lie
        :type curve: ecdsa.curves.Curve
        :param hashfunc: The default hash function that will be used for
            verification, needs to implement the same interface as hashlib.sha1
        :type hashfunc: callable
        :param validate_point: whether to verify that the point lies on the
            provided curve or not, defaults to True
        :type validate_point: bool

        :raises MalformedPointError: if the public point does not lie on the
            curve or the encoding is invalid

        :return: Initialised VerifyingKey object
        :rtype: VerifyingKey
        issss*Invalid X9.62 encoding of the public pointsWLength of string does not match lengths of any of the supported encodings of {0} curve.(RR<R=RERRORR?RNR'R(R:(R6R@RR8R9tsig_lenR7((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pytfrom_string�s$"cCs|jtj|�d|�S(s�
        Initialise from public key stored in :term:`PEM` format.

        The PEM header of the key should be ``BEGIN PUBLIC KEY``.

        See the :func:`~VerifyingKey.from_der()` method for details of the
        format supported.

        Note: only a single PEM object encoding is supported in provided
        string.

        :param string: text with PEM-encoded public ECDSA key
        :type string: str

        :return: Initialised VerifyingKey object
        :rtype: VerifyingKey
        R8(tfrom_derRtunpem(R6R@R8((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pytfrom_pem4scCsit|�}tj|�\}}|dkrLtjdtj|���ntj|�\}}tj|�\}}tj|�\}	}|dkr�tjdtj|���n|tks�tjdj|���nt	|	�}
tj
|d�\}}|dkr,tjdtj|���nt|�|
jkrStjd��n|j
||
d|�S(	s�
        Initialise the key stored in :term:`DER` format.

        The expected format of the key is the SubjectPublicKeyInfo structure
        from RFC5912 (for RSA keys, it's known as the PKCS#1 format)::

           SubjectPublicKeyInfo {PUBLIC-KEY: IOSet} ::= SEQUENCE {
               algorithm        AlgorithmIdentifier {PUBLIC-KEY, {IOSet}},
               subjectPublicKey BIT STRING
           }

        Note: only public EC keys are supported by this method. The
        SubjectPublicKeyInfo.algorithm.algorithm field must specify
        id-ecPublicKey (see RFC3279).

        Only the named curve encoding is supported, thus the
        SubjectPublicKeyInfo.algorithm.parameters field needs to be an
        object identifier. A sequence in that field indicates an explicit
        parameter curve encoding, this format is not supported. A NULL object
        in that field indicates an "implicitlyCA" encoding, where the curve
        parameters come from CA certificate, those, again, are not supported.

        :param string: binary string with the DER encoding of public ECDSA key
        :type string: bytes-like object

        :return: Initialised VerifyingKey object
        :rtype: VerifyingKey
        ts"trailing junk after DER pubkey: %ss*trailing junk after DER pubkey objects: %ss3Unexpected object identifier in DER encoding: {0!r}is*trailing junk after pubkey pointstring: %ss"Malformed encoding of public pointR8(RRtremove_sequencet
UnexpectedDERtbinasciithexlifyt
remove_objectRR'Rtremove_bitstringR<R=RQ(R6R@R8ts1temptyts2tpoint_str_bitstringtoid_pktrestt	oid_curveRt	point_str((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyRRIs,			cCs=t|�}||�j�}|j|||d|d|�S(s
        Return keys that can be used as verifiers of the provided signature.

        Tries to recover the public key that can be used to verify the
        signature, usually returns two keys like that.

        :param signature: the byte string with the encoded signature
        :type signature: bytes-like object
        :param data: the data to be hashed for signature verification
        :type data: bytes-like object
        :param curve: the curve over which the signature was performed
        :type curve: ecdsa.curves.Curve
        :param hashfunc: The default hash function that will be used for
            verification, needs to implement the same interface as hashlib.sha1
        :type hashfunc: callable
        :param sigdecode: Callable to define the way the signature needs to
            be decoded to an object, needs to handle `signature` as the
            first parameter, the curve order (an int) as the second and return
            a tuple with two integers, "r" as the first one and "s" as the
            second one. See :func:`ecdsa.util.sigdecode_string` and
            :func:`ecdsa.util.sigdecode_der` for examples.
        :type sigdecode: callable

        :return: Initialised VerifyingKey objects
        :rtype: list of VerifyingKey
        R8t	sigdecode(Rtdigestt$from_public_key_recovery_with_digest(R6t	signaturetdataRR8RdRe((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pytfrom_public_key_recovery�s
cCs�|j}|||j��\}}tj||�}	t|�}t|�}
|	j|
|�}g|D]}|j|j||�^qg}
|
S(s
        Return keys that can be used as verifiers of the provided signature.

        Tries to recover the public key that can be used to verify the
        signature, usually returns two keys like that.

        :param signature: the byte string with the encoded signature
        :type signature: bytes-like object
        :param digest: the hash value of the message signed by the signature
        :type digest: bytes-like object
        :param curve: the curve over which the signature was performed
        :type curve: ecdsa.curves.Curve
        :param hashfunc: The default hash function that will be used for
            verification, needs to implement the same interface as hashlib.sha1
        :type hashfunc: callable
        :param sigdecode: Callable to define the way the signature needs to
            be decoded to an object, needs to handle `signature` as the
            first parameter, the curve order (an int) as the second and return
            a tuple with two integers, "r" as the first one and "s" as the
            second one. See :func:`ecdsa.util.sigdecode_string` and
            :func:`ecdsa.util.sigdecode_der` for examples.
        :type sigdecode: callable


        :return: Initialised VerifyingKey object
        :rtype: VerifyingKey
        (	R3R5Rt	SignatureRRtrecover_public_keysR:R7(R6RgReRR8RdR3trtstsigtdigest_as_numbertpkstpktverifying_keys((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyRf�s	(cCsJ|jj}t|jjj�|�}t|jjj�|�}||S(s3Convert the public key to the :term:`raw encoding`.(R!R5R
R7RCRD(R"R5tx_strty_str((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyt_raw_encode�scCs]|jj}t|jjj�|�}|jjj�d@rKtd�|Std�|SdS(s1Encode the public point into the compressed form.issN(R!R5R
R7RCRDR(R"R5Rs((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyt_compressed_encode�s
cCsB|j�}|jjj�d@r0td�|Std�|SdS(s-Encode the public point into the hybrid form.issN(RuR!R7RDR(R"traw_enc((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyt_hybrid_encode�strawcCsl|dkst�|dkr(|j�S|dkrHtd�|j�S|dkr^|j�S|j�SdS(s
        Convert the public key to a byte string.

        The method by default uses the :term:`raw encoding` (specified
        by `encoding="raw"`. It can also output keys in :term:`uncompressed`,
        :term:`compressed` and :term:`hybrid` formats.

        Remember that the curve identification is not part of the encoding
        so to decode the point using :func:`~VerifyingKey.from_string`, curve
        needs to be specified.

        Note: while the method is called "to_string", it's a misnomer from
        Python 2 days when character strings and byte strings shared type.
        On Python 3 the returned type will be `bytes`.

        :return: :term:`raw encoding` of the public key (public point) on the
            curve
        :rtype: bytes
        RytuncompressedR%thybridsN(RyRzR%R{(R>RuRRxRv(R"tencoding((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyR&�s

RzcCstj|j|�d�S(s�
        Convert the public key to the :term:`PEM` format.

        The PEM header of the key will be ``BEGIN PUBLIC KEY``.

        The format of the key is described in the
        :func:`~VerifyingKey.from_der()` method.
        This method supports only "named curve" encoding of keys.

        :param str point_encoding: specification of the encoding format
            of public keys. "uncompressed" is most portable, "compressed" is
            smallest. "hybrid" is uncommon and unsupported by most
            implementations, it is as big as "uncompressed".

        :return: portable encoding of the public key
        :rtype: str
        s
PUBLIC KEY(Rttopemtto_der(R"tpoint_encoding((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pytto_pemscCsX|dkrtd��n|j|�}tjtjt|jj�tj|d��S(sF
        Convert the public key to the :term:`DER` format.

        The format of the key is described in the
        :func:`~VerifyingKey.from_der()` method.
        This method supports only "named curve" encoding of keys.

        :param str point_encoding: specification of the encoding format
            of public keys. "uncompressed" is most portable, "compressed" is
            smallest. "hybrid" is uncommon and unsupported by most
            implementations, it is as big as "uncompressed".

        :return: DER encoding of the public key
        :rtype: bytes
        Rys%raw point_encoding not allowed in DERi(t
ValueErrorR&Rtencode_sequenceRRtencoded_oidtencode_bitstring(R"RRc((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyR~scCsCt|�}|p|j}||�j�}|j|||t�S(s�
        Verify a signature made over provided data.

        Will hash `data` to verify the signature.

        By default expects signature in :term:`raw encoding`. Can also be used
        to verify signatures in ASN.1 DER encoding by using
        :func:`ecdsa.util.sigdecode_der`
        as the `sigdecode` parameter.

        :param signature: encoding of the signature
        :type signature: sigdecode method dependant
        :param data: data signed by the `signature`, will be hashed using
            `hashfunc`, if specified, or default hash function
        :type data: bytes like object
        :param hashfunc: The default hash function that will be used for
            verification, needs to implement the same interface as hashlib.sha1
        :type hashfunc: callable
        :param sigdecode: Callable to define the way the signature needs to
            be decoded to an object, needs to handle `signature` as the
            first parameter, the curve order (an int) as the second and return
            a tuple with two integers, "r" as the first one and "s" as the
            second one. See :func:`ecdsa.util.sigdecode_string` and
            :func:`ecdsa.util.sigdecode_der` for examples.
        :type sigdecode: callable

        :raises BadSignatureError: if the signature is invalid or malformed

        :return: True if the verification was successful
        :rtype: bool
        (RR Ret
verify_digestR/(R"RgRhR8RdRe((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pytverify3s#c
Cs�t|�}|r%||jj }nt|�|jjkrftd|jjdt|�f��nt|�}y|||jj�\}}Wn+t	j
tfk
r�}td|��nXt
j||�}	|jj||	�r�tStd��dS(s%
        Verify a signature made over provided hash value.

        By default expects signature in :term:`raw encoding`. Can also be used
        to verify signatures in ASN.1 DER encoding by using
        :func:`ecdsa.util.sigdecode_der`
        as the `sigdecode` parameter.

        :param signature: encoding of the signature
        :type signature: sigdecode method dependant
        :param digest: raw hash value that the signature authenticates.
        :type digest: bytes like object
        :param sigdecode: Callable to define the way the signature needs to
            be decoded to an object, needs to handle `signature` as the
            first parameter, the curve order (an int) as the second and return
            a tuple with two integers, "r" as the first one and "s" as the
            second one. See :func:`ecdsa.util.sigdecode_string` and
            :func:`ecdsa.util.sigdecode_der` for examples.
        :type sigdecode: callable
        :param bool allow_truncate: if True, the provided digest can have
            bigger bit-size than the order of the curve, the extra bits (at
            the end of the digest) will be truncated. Use it when verifying
            SHA-384 output using NIST256p or in similar situations.

        :raises BadSignatureError: if the signature is invalid or malformed
        :raises BadDigestError: if the provided digest is too big for the curve
            associated with this VerifyingKey and allow_truncate was not set

        :return: True if the verification was successful
        :rtype: bool
        s1this curve (%s) is too short for your digest (%d)is!Malformed formatting of signaturesSignature verification failedN(RRR?R<RR(RR!R5RRWRRRRjtverifiesR/(
R"RgReRdtallow_truncatetnumberRlRmRMRn((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyR�\s #	N( RRRRR$R*R.tclassmethodRRR/R:R;tstaticmethodRERNRORQRTRRRRiRfRuRvRxR&R�R~R�tFalseR�(((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyRtsB			&	37!)				(cBseZdZdd�Zd�Zeeded��Z	eeed��Z
eeed��Zeed��Zeed��Z
d�Zd	d
�Zd	d�Zd�Zded
d�Zded
ed�Zddedd�Zdeded�Zddd�ZRS(s<
    Class for handling keys that can create signatures (private keys).

    :ivar ecdsa.curves.Curve curve: The Curve over which all the cryptographic
        operations will take place
    :ivar default_hashfunc: the function that will be used for hashing the
        data. Should implement the same API as hashlib.sha1
    :ivar int baselen: the length of a :term:`raw encoding` of private key
    :ivar ecdsa.keys.VerifyingKey verifying_key: the public key
        associated with this private key
    :ivar ecdsa.ecdsa.Private_key privkey: the actual private key
    cCsF|std��nd|_d|_d|_d|_d|_dS(s>Unsupported, please use one of the classmethods to initialise.s0Please use SigningKey.generate() to construct meN(RRRR R?t
verifying_keytprivkey(R"R#((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyR$�s				cCsGt|t�rC|j|jkoB|j|jkoB|j|jkStS(s9Return True if the points are identical, False otherwise.(R+RRR�R�R,(R"R-((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyR.�s
cCs%t|j|�}|j|||�S(s�
        Generate a random private key.

        :param curve: The curve on which the point needs to reside, defaults
            to NIST192p
        :type curve: ecdsa.curves.Curve
        :param entropy: Source of randomness for generating the private keys,
            should provide cryptographically secure random numbers if the keys
            need to be secure. Uses os.urandom() by default.
        :type entropy: callable
        :param hashfunc: The default hash function that will be used for
            signing, needs to implement the same interface
            as hashlib.sha1
        :type hashfunc: callable

        :return: Initialised SigningKey object
        :rtype: SigningKey
        (RR5tfrom_secret_exponent(R6RtentropyR8tsecexp((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pytgenerate�scCs�|dt�}||_||_|j|_|j}d|koM|knsjtdj|���n|j|}t|d�r�|j	�}nt
j|||t�|_
|j
j}tj||�|_||j_|S(s�
        Create a private key from a random integer.

        Note: it's a low level method, it's recommended to use the
        :func:`~SigningKey.generate` method to create private keys.

        :param int secexp: secret multiplier (the actual private key in ECDSA).
            Needs to be an integer between 1 and the curve order.
        :param curve: The curve on which the point needs to reside
        :type curve: ecdsa.curves.Curve
        :param hashfunc: The default hash function that will be used for
            signing, needs to implement the same interface
            as hashlib.sha1
        :type hashfunc: callable

        :raises MalformedPointError: when the provided secexp is too large
            or too small for the curve selected
        :raises RuntimeError: if the generation of public key from private
            key failed

        :return: Initialised SigningKey object
        :rtype: SigningKey
        R#is<Invalid value for secexp, expected integer between 1 and {0}tscale(R/RR R?R5RR'R3thasattrR�RR:R�R�R!RtPrivate_keyR�(R6R�RR8R"tntpubkey_pointR!((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyR��s$			
cCsdt|�}t|�|jkrEtdjt|�|j���nt|�}|j|||�S(s�
        Decode the private key from :term:`raw encoding`.

        Note: the name of this method is a misnomer coming from days of
        Python 2, when binary strings and character strings shared a type.
        In Python 3, the expected type is `bytes`.

        :param string: the raw encoding of the private key
        :type string: bytes like object
        :param curve: The curve on which the point needs to reside
        :type curve: ecdsa.curves.Curve
        :param hashfunc: The default hash function that will be used for
            signing, needs to implement the same interface
            as hashlib.sha1
        :type hashfunc: callable

        :raises MalformedPointError: if the length of encoding doesn't match
            the provided curve or the encoded values is too large
        :raises RuntimeError: if the generation of public key from private
            key failed

        :return: Initialised SigningKey object
        :rtype: SigningKey
        s9Invalid length of private key, received {0}, expected {1}(RR<R?RR'RR�(R6R@RR8R�((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyRQ�scCsVtr$t|t�r$|j�}n||jtd��}|jtj|�|�S(s�
        Initialise from key stored in :term:`PEM` format.

        Note, the only PEM format supported is the un-encrypted RFC5915
        (the sslay format) supported by OpenSSL, the more common PKCS#8 format
        is NOT supported (see:
        https://github.com/warner/python-ecdsa/issues/113 )

        ``openssl ec -in pkcs8.pem -out sslay.pem`` can be used to
        convert PKCS#8 file to this legacy format.

        The legacy format files have the header with the string
        ``BEGIN EC PRIVATE KEY``.
        Encrypted files (ones that include the string
        ``Proc-Type: 4,ENCRYPTED``
        right after the PEM header) are not supported.

        See :func:`~SigningKey.from_der` for ASN.1 syntax of the objects in
        this files.

        :param string: text with PEM-encoded private ECDSA key
        :type string: str

        :raises MalformedPointError: if the length of encoding doesn't match
            the provided curve or the encoded values is too large
        :raises RuntimeError: if the generation of public key from private
            key failed
        :raises UnexpectedDER: if the encoding of the PEM file is incorrect

        :return: Initialised VerifyingKey object
        :rtype: VerifyingKey
        s-----BEGIN EC PRIVATE KEY-----(	RR+tstrtencodetindexRRRRRS(R6R@R8tprivkey_pem((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyRTs$cCsvt|�}tj|�\}}|td�krRtjdtj|���ntj|�\}}|dkr�tjd|��ntj|�\}}tj	|�\}}}|dkr�tjd|��ntj
|�\}	}|td�krtjdtj|���nt|	�}
t|�|
j
krctd�|
j
t|�|}n|j||
|�S(	s�
        Initialise from key stored in :term:`DER` format.

        Note, the only DER format supported is the RFC5915
        (the sslay format) supported by OpenSSL, the more common PKCS#8 format
        is NOT supported (see:
        https://github.com/warner/python-ecdsa/issues/113 )

        ``openssl ec -in pkcs8.pem -outform der -out sslay.der`` can be
        used to convert PKCS#8 file to this legacy format.

        The encoding of the ASN.1 object in those files follows following
        syntax specified in RFC5915::

            ECPrivateKey ::= SEQUENCE {
              version        INTEGER { ecPrivkeyVer1(1) }} (ecPrivkeyVer1),
              privateKey     OCTET STRING,
              parameters [0] ECParameters {{ NamedCurve }} OPTIONAL,
              publicKey  [1] BIT STRING OPTIONAL
            }

        The only format supported for the `parameters` field is the named
        curve method. Explicit encoding of curve parameters is not supported.

        While `parameters` field is defined as optional, this implementation
        requires its presence for correct parsing of the keys.

        `publicKey` field is ignored completely (errors, if any, in it will
        be undetected).

        :param string: binary string with DER-encoded private ECDSA key
        :type string: bytes like object

        :raises MalformedPointError: if the length of encoding doesn't match
            the provided curve or the encoded values is too large
        :raises RuntimeError: if the generation of public key from private
            key failed
        :raises UnexpectedDER: if the encoding of the DER file is incorrect

        :return: Initialised VerifyingKey object
        :rtype: VerifyingKey
        RUs#trailing junk after DER privkey: %sis,expected '1' at start of DER privkey, got %dis%expected tag 0 in DER privkey, got %ds-trailing junk after DER privkey curve_oid: %ss(RRRVRRWRXRYtremove_integertremove_octet_stringtremove_constructedRZRR<R?RQ(R6R@R8RmR]tonetprivkey_strttagt
curve_oid_strt	curve_oidR((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyRR?s,,		
	
	$cCs%|jj}t||jj�}|S(sK
        Convert the private key to :term:`raw encoding`.

        Note: while the method is named "to_string", its name comes from
        Python 2 days, when binary and character strings used the same type.
        The type used in Python 3 is `bytes`.

        :return: raw encoding of private key
        :rtype: bytes
        (R�tsecret_multiplierR
R5(R"R�Rm((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyR&�sRzcCstj|j|�d�S(s�
        Convert the private key to the :term:`PEM` format.

        See :func:`~SigningKey.from_pem` method for format description.

        Only the named curve format is supported.
        The public key will be included in generated string.

        The PEM header will specify ``BEGIN EC PRIVATE KEY``

        :param str point_encoding: format to use for encoding public point

        :return: PEM encoded private key
        :rtype: str
        sEC PRIVATE KEY(RR}R~(R"R((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyR��sc	Cs�|dkrtd��n|j�j|�}tjtjd�tj|j��tjd|jj	�tjdtj
|d���S(s�
        Convert the private key to the :term:`DER` format.

        See :func:`~SigningKey.from_der` method for format specification.

        Only the named curve format is supported.
        The public key will be included in the generated string.

        :param str point_encoding: format to use for encoding public point

        :return: DER encoded private key
        :rtype: bytes
        Rysraw encoding not allowed in DERii(R�tget_verifying_keyR&RR�tencode_integertencode_octet_stringtencode_constructedRR�R�(R"Rt
encoded_vk((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyR~�scCs|jS(s 
        Return the VerifyingKey associated with this private key.

        Equivalent to reading the `verifying_key` field of an instance.

        :return: a public key that can be used to verify the signatures made
            with this SigningKey
        :rtype: VerifyingKey
        (R�(R"((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyR��s
RUc
Cs^|p|j}t|�}t|�}||�j�}|j|d|d|d|dt�S(s�
        Create signature over data using the deterministic RFC6679 algorithm.

        The data will be hashed using the `hashfunc` function before signing.

        This is the recommended method for performing signatures when hashing
        of data is necessary.

        :param data: data to be hashed and computed signature over
        :type data: bytes like object
        :param hashfunc: hash function to use for computing the signature,
            if unspecified, the default hash function selected during
            object initialisation will be used (see
            `VerifyingKey.default_hashfunc`). The object needs to implement
            the same interface as hashlib.sha1.
        :type hashfunc: callable
        :param sigencode: function used to encode the signature.
            The function needs to accept three parameters: the two integers
            that are the signature and the order of the curve over which the
            signature was computed. It needs to return an encoded signature.
            See `ecdsa.util.sigencode_string` and `ecdsa.util.sigencode_der`
            as examples of such functions.
        :type sigencode: callable
        :param extra_entropy: additional data that will be fed into the random
            number generator used in the RFC6979 process. Entirely optional.
        :type extra_entropy: bytes like object

        :return: encoded signature over `data`
        :rtype: bytes or sigencode function dependant type
        R8t	sigencodet
extra_entropyR�(R RRetsign_digest_deterministicR/(R"RhR8R�R�Re((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pytsign_deterministic�s!c
	Cs�|jj}|p|j}t|�}t|�}d�}d}x�tr�tj|jjj	�|||d|d|�}	y/|j
|d|d|	d|�\}
}}PWqEtk
r�|d7}qEXqEW||
||�S(	sK
        Create signature for digest using the deterministic RFC6679 algorithm.

        `digest` should be the output of cryptographically secure hash function
        like SHA256 or SHA-3-256.

        This is the recommended method for performing signatures when no
        hashing of data is necessary.

        :param digest: hash of data that will be signed
        :type digest: bytes like object
        :param hashfunc: hash function to use for computing the random "k"
            value from RFC6979 process,
            if unspecified, the default hash function selected during
            object initialisation will be used (see
            `VerifyingKey.default_hashfunc`). The object needs to implement
            the same interface as hashlib.sha1.
        :type hashfunc: callable
        :param sigencode: function used to encode the signature.
            The function needs to accept three parameters: the two integers
            that are the signature and the order of the curve over which the
            signature was computed. It needs to return an encoded signature.
            See `ecdsa.util.sigencode_string` and `ecdsa.util.sigencode_der`
            as examples of such functions.
        :type sigencode: callable
        :param extra_entropy: additional data that will be fed into the random
            number generator used in the RFC6979 process. Entirely optional.
        :type extra_entropy: bytes like object
        :param bool allow_truncate: if True, the provided digest can have
            bigger bit-size than the order of the curve, the extra bits (at
            the end of the digest) will be truncated. Use it when signing
            SHA-384 output using NIST256p or in similar situations.

        :return: encoded signature for the `digest` hash
        :rtype: bytes or sigencode function dependant type
        cSs
|||fS(N((RlRmR5((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyt
simple_r_s.sit	retry_genR�R�tkR�i(R�R�R RR/Rt
generate_kRR3R5tsign_digestR(
R"ReR8R�R�R�R�R�R�R�RlRmR5((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyR�s&'		
cCsI|p|j}t|�}||�j�}|j||||dt�S(s7	
        Create signature over data using the probabilistic ECDSA algorithm.

        This method uses the standard ECDSA algorithm that requires a
        cryptographically secure random number generator.

        It's recommended to use the :func:`~SigningKey.sign_deterministic`
        method instead of this one.

        :param data: data that will be hashed for signing
        :type data: bytes like object
        :param callable entropy: randomness source, os.urandom by default
        :param hashfunc: hash function to use for hashing the provided `data`.
            If unspecified the default hash function selected during
            object initialisation will be used (see
            `VerifyingKey.default_hashfunc`).
            Should behave like hashlib.sha1. The output length of the
            hash (in bytes) must not be longer than the length of the curve
            order (rounded up to the nearest byte), so using SHA256 with
            NIST256p is ok, but SHA256 with NIST192p is not. (In the 2**-96ish
            unlikely event of a hash output larger than the curve order, the
            hash will effectively be wrapped mod n).
            Use hashfunc=hashlib.sha1 to match openssl's -ecdsa-with-SHA1 mode,
            or hashfunc=hashlib.sha256 for openssl-1.0.0's -ecdsa-with-SHA256.
        :type hashfunc: callable
        :param sigencode: function used to encode the signature.
            The function needs to accept three parameters: the two integers
            that are the signature and the order of the curve over which the
            signature was computed. It needs to return an encoded signature.
            See `ecdsa.util.sigencode_string` and `ecdsa.util.sigencode_der`
            as examples of such functions.
        :type sigencode: callable
        :param int k: a pre-selected nonce for calculating the signature.
            In typical use cases, it should be set to None (the default) to
            allow its generation from an entropy source.

        :raises RSZeroError: in the unlikely event when "r" parameter or
            "s" parameter is equal 0 as that would leak the key. Calee should
            try a better entropy source or different 'k' in such case.

        :return: encoded signature of the hash of `data`
        :rtype: bytes or sigencode function dependant type
        R�(R RReR�R/(R"RhR�R8R�R�th((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pytsignAs-c	Cs�t|�}|r%||jj }nt|�|jjkrftd|jjdt|�f��nt|�}|j|||�\}}||||jj	�S(s%
        Create signature over digest using the probabilistic ECDSA algorithm.

        This method uses the standard ECDSA algorithm that requires a
        cryptographically secure random number generator.

        This method does not hash the input.

        It's recommended to use the
        :func:`~SigningKey.sign_digest_deterministic` method
        instead of this one.

        :param digest: hash value that will be signed
        :type digest: bytes like object
        :param callable entropy: randomness source, os.urandom by default
        :param sigencode: function used to encode the signature.
            The function needs to accept three parameters: the two integers
            that are the signature and the order of the curve over which the
            signature was computed. It needs to return an encoded signature.
            See `ecdsa.util.sigencode_string` and `ecdsa.util.sigencode_der`
            as examples of such functions.
        :type sigencode: callable
        :param int k: a pre-selected nonce for calculating the signature.
            In typical use cases, it should be set to None (the default) to
            allow its generation from an entropy source.
        :param bool allow_truncate: if True, the provided digest can have
            bigger bit-size than the order of the curve, the extra bits (at
            the end of the digest) will be truncated. Use it when signing
            SHA-384 output using NIST256p or in similar situations.

        :raises RSZeroError: in the unlikely event when "r" parameter or
            "s" parameter is equal 0 as that would leak the key. Calee should
            try a better entropy source in such case.

        :return: encoded signature for the `digest` hash
        :rtype: bytes or sigencode function dependant type
        s1this curve (%s) is too short for your digest (%d)i(
RRR?R<RR(Rtsign_numberR�R5(	R"ReR�R�R�R�R�RlRm((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyR�ss'	cCsw|jj}|dk	r!|}nt||�}d|koG|knsRt�|jj||�}|j|jfS(s4
        Sign an integer directly.

        Note, this is a low level method, usually you will want to use
        :func:`~SigningKey.sign_deterministic` or
        :func:`~SigningKey.sign_digest_deterministic`.

        :param int number: number to sign using the probabilistic ECDSA
            algorithm.
        :param callable entropy: entropy source, os.urandom by default
        :param int k: pre-selected nonce for signature operation. If unset
            it will be selected at random using the entropy source.

        :raises RSZeroError: in the unlikely event when "r" parameter or
            "s" parameter is equal 0 as that would leak the key. Calee should
            try a different 'k' in such case.

        :return: the "r" and "s" parameters of the signature
        :rtype: tuple of ints
        iN(R�R5RRR>R�RlRm(R"R�R�R�R5t_kRn((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyR��s	"N(RRRRR$R.R�RRR�R�RQRTRRR&R�R~R�RR�R�R�R�R�R�(((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyR�s8
	+!(O		(=11('RRXthashlibRtsixRRRURRRRtcurvesRRtnumbertheoryR	R
RtutilRR
RRRRRRt_compatRt__all__t	ExceptionRRR>RtobjectRR(((s?/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/keys.pyt<module>Cs.	��

Zerion Mini Shell 1.0