%PDF- %PDF-
Direktori : /proc/self/root/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ |
Current File : //proc/self/root/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdh.pyc |
� �ac @ s� d Z d d l m Z d d l m Z d d l m Z m Z d d d d d g Z d e f d � � YZ d e f d � � YZ d e f d � � YZ d e f d � � YZ d e f d � � YZ d S( sG Class for performing Elliptic-curve Diffie-Hellman (ECDH) operations. i ( t number_to_string( t INFINITY( t SigningKeyt VerifyingKeyt ECDHt NoKeyErrort NoCurveErrort InvalidCurveErrort InvalidSharedSecretErrorc B s e Z d Z RS( s3 ECDH. Key not found but it is needed for operation.( t __name__t __module__t __doc__( ( ( s? /opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdh.pyR s c B s e Z d Z RS( s3 ECDH. Curve not set but it is needed for operation.( R R R ( ( ( s? /opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdh.pyR s c B s e Z d Z RS( sF ECDH. Raised in case the public and private keys use different curves.( R R R ( ( ( s? /opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdh.pyR s c B s e Z d Z RS( sB ECDH. Raised in case the shared secret we obtained is an INFINITY.( R R R ( ( ( s? /opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdh.pyR s c B s� e Z d Z d d d d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z RS( s� Elliptic-curve Diffie-Hellman (ECDH). A key agreement protocol. Allows two parties, each having an elliptic-curve public-private key pair, to establish a shared secret over an insecure channel c C sK | | _ d | _ d | _ | r1 | j | � n | rG | j | � n d S( s ECDH init. Call can be initialised without parameters, then the first operation (loading either key) will set the used curve. All parameters must be ultimately set before shared secret calculation will be allowed. :param curve: curve for operations :type curve: Curve :param private_key: `my` private key for ECDH :type private_key: SigningKey :param public_key: `their` public key for ECDH :type public_key: VerifyingKey N( t curvet Nonet private_keyt public_keyt load_private_keyt load_received_public_key( t selfR R R ( ( s? /opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdh.pyt __init__. s c C s� | j s t d � � n | j s0 t d � � n | j j | j k oS | j k n sg t d � � n | j j | j j j } | t k r� t d � � n | j � S( Ns3 Private key needs to be set to create shared secrets2 Public key needs to be set to create shared secrets3 Curves for public key and private key is not equal.s! Invalid shared secret (INFINITY).( R R R R R t pubkeyt pointt privkeyt secret_multiplierR R t x( R t remote_public_keyt result( ( s? /opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdh.pyt _get_shared_secretF s (c C s | | _ d S( s� Set the working curve for ecdh operations. :param key_curve: curve from `curves` module :type key_curve: Curve N( R ( R t key_curve( ( s? /opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdh.pyt set_curveY s c C s4 | j s t d � � n | j t j d | j � � S( s Generate local private key for ecdh operation with curve that was set. :raises NoCurveError: Curve must be set before key generation. :return: public (verifying) key from this private key. :rtype: VerifyingKey object s* Curve must be set prior to key generation.R ( R R R R t generate( R ( ( s? /opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdh.pyt generate_private_keyb s c C sO | j s | j | _ n | j | j k r9 t d � � n | | _ | j j � S( s� Load private key from SigningKey (keys.py) object. Needs to have the same curve as was set with set_curve method. If curve is not set - it sets from this SigningKey :param private_key: Initialised SigningKey class :type private_key: SigningKey :raises InvalidCurveError: private_key curve not the same as self.curve :return: public (verifying) key from this private key. :rtype: VerifyingKey object s Curve mismatch.( R R R t get_verifying_key( R R ( ( s? /opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdh.pyR o s c C s7 | j s t d � � n | j t j | d | j �� S( s� Load private key from byte string. Uses current curve and checks if the provided key matches the curve of ECDH key agreement. Key loads via from_string method of SigningKey class :param private_key: private key in bytes string format :type private_key: :term:`bytes-like object` :raises NoCurveError: Curve must be set before loading. :return: public (verifying) key from this private key. :rtype: VerifyingKey object s$ Curve must be set prior to key load.R ( R R R R t from_string( R R ( ( s? /opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdh.pyt load_private_key_bytes� s c C s | j t j | � � S( s> Load private key from DER byte string. Compares the curve of the DER-encoded key with the ECDH set curve, uses the former if unset. Note, the only DER format supported is the RFC5915 Look at keys.py:SigningKey.from_der() :param private_key_der: string with the DER encoding of private ECDSA key :type private_key_der: string :raises InvalidCurveError: private_key curve not the same as self.curve :return: public (verifying) key from this private key. :rtype: VerifyingKey object ( R R t from_der( R t private_key_der( ( s? /opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdh.pyt load_private_key_der� s c C s | j t j | � � S( sc Load private key from PEM string. Compares the curve of the DER-encoded key with the ECDH set curve, uses the former if unset. Note, the only PEM format supported is the RFC5915 Look at keys.py:SigningKey.from_pem() it needs to have `EC PRIVATE KEY` section :param private_key_pem: string with PEM-encoded private ECDSA key :type private_key_pem: string :raises InvalidCurveError: private_key curve not the same as self.curve :return: public (verifying) key from this private key. :rtype: VerifyingKey object ( R R t from_pem( R t private_key_pem( ( s? /opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdh.pyt load_private_key_pem� s c C s | j j � S( s� Provides a public key that matches the local private key. Needs to be sent to the remote party. :return: public (verifying) key from local private key. :rtype: VerifyingKey object ( R R ( R ( ( s? /opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdh.pyt get_public_key� s c C sF | j s | j | _ n | j | j k r9 t d � � n | | _ d S( s Load public key from VerifyingKey (keys.py) object. Needs to have the same curve as set as current for ecdh operation. If curve is not set - it sets it from VerifyingKey. :param public_key: Initialised VerifyingKey class :type public_key: VerifyingKey :raises InvalidCurveError: public_key curve not the same as self.curve s Curve mismatch.N( R R R ( R R ( ( s? /opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdh.pyR � s c C s | j t j | | j � � S( sK Load public key from byte string. Uses current curve and checks if key length corresponds to the current curve. Key loads via from_string method of VerifyingKey class :param public_key_str: public key in bytes string format :type public_key_str: :term:`bytes-like object` ( R R R! R ( R t public_key_str( ( s? /opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdh.pyt load_received_public_key_bytes� s c C s | j t j | � � S( s� Load public key from DER byte string. Compares the curve of the DER-encoded key with the ECDH set curve, uses the former if unset. Note, the only DER format supported is the RFC5912 Look at keys.py:VerifyingKey.from_der() :param public_key_der: string with the DER encoding of public ECDSA key :type public_key_der: string :raises InvalidCurveError: public_key curve not the same as self.curve ( R R R# ( R t public_key_der( ( s? /opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdh.pyt load_received_public_key_der� s c C s | j t j | � � S( s� Load public key from PEM string. Compares the curve of the PEM-encoded key with the ECDH set curve, uses the former if unset. Note, the only PEM format supported is the RFC5912 Look at keys.py:VerifyingKey.from_pem() :param public_key_pem: string with PEM-encoded public ECDSA key :type public_key_pem: string :raises InvalidCurveError: public_key curve not the same as self.curve ( R R R&