%PDF- %PDF-
Mini Shell

Mini Shell

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

�
�ac@s}dZddlmZmZddlmZddlmZddlmZde	fd��YZ
d	e	fd
��YZdefd��YZ
d
efd��YZdefd��YZd�Zd�Zd�Zd�ZdZdZdZdZdZejeded�Zejeeedede�ZdZdZdZdZd Zejeded�Zejeeedede�Zd!Zd"Zd#Zd$Zd%Zejeded�Z eje eedede�Z!d&Zd'Zd(Zd)Zd*Zejeded�Z"eje"eedede�Z#d+Zd,Zd-Zd.Zd/Zejeded�Z$eje$eedede�Z%d0Z&d1Zd2Zd3Zd4Zd5Zejee&ed�Z'eje'eedede�Z(d6Z&d7Zd8Zd9Zd:Zd;Z)ejee&ed�Z*eje*eede)de�Z+d<Z&d=Zd>Zd?Zd@ZdAZ)ejee&ed�Z,eje,eede)de�Z-dBZ&dCZdDZdEZdFZdGZ)ejee&ed�Z.eje.eede)de�Z/dHZ&dIZdJZdKZdLZdMZ)ejee&ed�Z0eje0eede)de�Z1dNZ&dOZdPZdQZdRZdSZ)ejee&ed�Z2eje2eede)de�Z3dTZ&dUZdVZdWZdXZdYZ)ejee&ed�Z4eje4eede)de�Z5dZZ&d[Zd\Zd]Zd^Zd_Z)ejee&ed�Z6eje6eede)de�Z7d`S(as�
Implementation of Elliptic-Curve Digital Signatures.

Classes and methods for elliptic-curve signatures:
private keys, public keys, signatures,
NIST prime-modulus curves with modulus lengths of
192, 224, 256, 384, and 521 bits.

Example:

  # (In real-life applications, you would probably want to
  # protect against defects in SystemRandom.)
  from random import SystemRandom
  randrange = SystemRandom().randrange

  # Generate a public/private key pair using the NIST Curve P-192:

  g = generator_192
  n = g.order()
  secret = randrange( 1, n )
  pubkey = Public_key( g, g * secret )
  privkey = Private_key( pubkey, secret )

  # Signing a hash value:

  hash = randrange( 1, n )
  signature = privkey.sign( hash, randrange( 1, n ) )

  # Verifying a signature for a hash value:

  if pubkey.verifies( hash, signature ):
    print_("Demo verification succeeded.")
  else:
    print_("*** Demo verification failed.")

  # Verification fails if the hash value is modified:

  if pubkey.verifies( hash-1, signature ):
    print_("**** Demo verification failed to reject tampered hash.")
  else:
    print_("Demo verification correctly rejected tampered hash.")

Version of 2009.05.16.

Revision history:
      2005.12.31 - Initial version.
      2008.11.25 - Substantial revisions introducing new classes.
      2009.05.16 - Warn against using random.randrange in real applications.
      2009.05.17 - Use random.SystemRandom by default.

Written in 2005 by Peter Pearson and placed in the public domain.
i����(tint2bytetbi(t
ellipticcurve(tnumbertheory(t
bit_lengthtRSZeroErrorcBseZRS((t__name__t
__module__(((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdsa.pyR>stInvalidPointErrorcBseZRS((RR(((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdsa.pyRBst	SignaturecBs eZdZd�Zd�ZRS(sECDSA signature.
  cCs||_||_dS(N(trts(tselfR
R((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdsa.pyt__init__Is	cCs[|j�}|j�}|j}|j}|}|}t|d|j��|j�||j�|j�}	tj	|	|j��}
|
ddkr�|
n
|j�|
}t
j|||d|�}tj||�|||||}
t
||
�}t
j|||d|�}tj||�|||||}t
||�}||gS(s�Returns two public keys for which the signature is valid
    hash is signed hash
    generator is the used generator of the signature
    iiii(tcurvetorderR
RtpowtptaRRtsquare_root_mod_primeRtPointJacobitinverse_modt
Public_key(Rthasht	generatorRtnR
RtetxtalphatbetatytR1tQ1tPk1tR2tQ2tPk2((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdsa.pytrecover_public_keysMs 		:&''(RRt__doc__R
R%(((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdsa.pyR	Fs	RcBs,eZdZed�Zd�Zd�ZRS(sPublic key for ECDSA.
  cCs|j�|_||_||_|j�}|jj�}d|j�koY|kns�d|j�ko||knr�td��n|r�|jj|j�|j��r�td��n|s�td��n|r|jj	�dkr||t
jkrtd��ndS(se
    Low level ECDSA public key object.

    :param generator: the Point that generates the group (the base point)
    :param point: the Point that defines the public key
    :param bool verify: if True check if point is valid point on curve

    :raises InvalidPointError: if the point parameters are invalid or
        point does not lie on the curve
    is)The public point has x or y out of range.sPoint does not lie on the curves Generator point must have order.isGenerator point order is bad.N(RRtpointRRRRRtcontains_pointtcofactorRtINFINITY(RRR'tverifyRR((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdsa.pyR
os		F(cCs5t|t�r1|j|jko0|j|jkStS(N(t
isinstanceRRR'tNotImplemented(Rtother((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdsa.pyt__eq__�scCs�|j}|j�}|j}|j}|dksC||dkrGtS|dksc||dkrgtStj||�}|||}|||}	t|d�r�|j||j	|	�}
n|||	|j	}
|
j
�|}||kS(scVerify that signature is a valid signature of hash.
    Return True if the signature is valid.
    itmul_add(RRR
RtFalseRRthasattrR0R'R(RRt	signaturetGRR
Rtctu1tu2txytv((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdsa.pytverifies�s 			(RRR&tTrueR
R/R:(((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdsa.pyRks	tPrivate_keycBs)eZdZd�Zd�Zd�ZRS(sPrivate key for ECDSA.
  cCs||_||_dS(sQpublic_key is of class Public_key;
    secret_multiplier is a large integer.
    N(t
public_keytsecret_multiplier(RR=R>((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdsa.pyR
�s	cCs5t|t�r1|j|jko0|j|jkStS(N(R,R<R=R>R-(RR.((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdsa.pyR/�scCs�|jj}|j�}||}||}||}t|�t|�kr[||}n
||}|j�|}	|	dkr�td��ntj||�||j|	||}
|
dkr�td��nt	|	|
�S(s�Return a signature for the provided hash, using the provided
    random nonce.  It is absolutely vital that random_k be an unpredictable
    number in the range [1, self.public_key.point.order()-1].  If
    an attacker can guess random_k, he can compute our private key from a
    single signature.  Also, if an attacker knows a few high-order
    bits (or a few low-order bits) of random_k, he can compute our private
    key from many signatures.  The generation of nonces with adequate
    cryptographic strength is very difficult and far beyond the scope
    of this comment.

    May raise RuntimeError, in which case retrying with a new
    random value k is in order.
    is!amazingly unlucky random number rs!amazingly unlucky random number s(
R=RRRRRRRR>R	(RRtrandom_kR4Rtktkstkttp1R
R((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdsa.pytsign�s 




(RRR&R
R/RD(((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdsa.pyR<�s		cCs|dkst�|dkr(td�Sg}x1|ra|d@}|jt|��|dL}q1W|j�td�j|�S(s7Convert integer x into a string of bytes, as per X9.62.isi�it(tAssertionErrorRtappendRtreversetjoin(Rtresulttordinal((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdsa.pyt
int_to_string�s
	

cCsGd}x:|D]2}t|t�s1t|�}nd||}q
W|S(s8Convert a string of bytes into an integer, as per X9.62.ii(R,tinttord(RRJR5((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdsa.pyt
string_to_int�s
cCs,ddlm}t|t|��j��S(smConvert an integer into a string of bytes, compute
     its SHA-1 hash, and convert the result to an integer.i����(tsha1(thashlibRPRORLtdigest(tmRP((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdsa.pytdigest_integer�scCs�|j�}|j�}|j�}d|ko;|kns^d|koX|knrbtS|j||�sxtS|j�dkr�|tj|||d�tjkr�tSt	S(s=Is (x,y) a valid public key based on the specified generator?ii(
RRRR1R(R)RRR*R;(RRRRRR((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdsa.pytpoint_is_valids:
l
�������������l
1(�i�&^#a�;�������l
�9��{�u��D�j�Sg9�g(Bl
��+�'1t�:�_|v!a�:@m�l
H�<�^�W]�dZ{cx��W\Iqi����Rl���������?l=*�8%���(��������?l��FeY8��w�-X"PVd�/�%�PP!-l!�"X�!#BX�t�J9!'�|�%�V�A�-l4~
f�&Dv�@h�!�f�E0m9_qlM/l������?@��lQ%�x+�Oh�bi+}s�����@��lK`�O�pq^cv
3,�e<
1�U�]>{|R�*��Zl�B11e	%:f=K`�wr�H�7g�HK8�hkl�Q~o��]�l+f�Ug+<�)Z?�8�O�?q!�Ol�����~�����������������ls)��e`g�w�l
X_[n�lv|�������������l�*�'�#.T��Ebc+�Z'@=D 1 "(�?7N2Z�_+��|��S/1fl�
�d�x�R��joyU8T(	:�ss�"�n�Z�L�8k�&�"_�Ul_�!�uR��/�sX0
@qa�N�Q�N�B&J��xS8KJ�E�Y�
�	K%�ll#�����������������������������������l#	dp"z\}[�z�3"n�Z;PK�#
`�7�r�o�C�Q������������������l#?�VQ(zO�%b�95~c�te1oR{�V��;�LHw>�l�-rZE]�"Sr�&Ga9}*Fl#f=��x�K�)H-apY$3^Q�	n�%k�{;/K!u{4-{�?$�O��d8�V1�l�3s:�l#Pf�?�Q�E$XN�!85aZ��U��WL9�YL��h�z
�f�$Du13otc!�%�pMxjRr`iil/|����������������l��-l�O�
�9�6�M:WZEuw>?3�yl�T!v?B>b�A�P)��("8p�'�U�x�I;m:HlAAl 3z�~�i�9nW�~��������lC�Q_v�S��W8]u@�b��lX^�0#Wdo�"�i�!�51ylb**N`�-�z�w,8s_�<�l�[y{�kZcDqR���^+�l!c�-�]�4t(�0G
zG�OYl	|�<%�"�w,8s_�<�l
�(4
�W\�P��a�c���l
�%~_QP�S�k�hA9�#�Q�=GQil
�bPC�r~x[1z$�Q�MmTLv�0l
�_n&!qzQ	[qXSIm�z#
l
�St�~�3. )0
�/�8�z��4Kl
�,�5
DG_��S��Q�MmTLv�0lC�g)!�-CST�)�&0�p`s�J�<)l@�p�M�6&]&D�x��1'b	"�L�`	l�@�}�'�>yu��a�hu%`0�4d"�&�5l}@%\�;�`t1�I'#�>�2G�P�r�R5dl�(lM[U�is)
	�fNq
�<�,w�J*l�OK�r�n�D�"4f}hu%`0�4d"�&�5l�5af-RJ�F�[Ip*@�g�uA�3�~
�Z}l�cpf^��W
B�?�.�f�3OhIR:6.�&lwS�>t ���$��nrvBT0�C7U{h�+�)lb2�5�N"R#<�wxxo�/o�?AZ�2�J�r\W�l�i^S�`Ee�=�D�;�I;BQh0BY�X�p|~Tl�V�.
:�yo4,�(��qvBT0�C7U{h�+�)l�{�V�I�?!,�fZ�V�O�9*
wgO�u��a�>�Z0nl�qc�R�z�b3��i)UR	z~M��S�x�w�� 
l'.fc�J�f�B}{\IOoh�}~�_<�4/<<ao�Z9�5l�s44|q��
�C�6�(D�	 o�7�#b^�Rp1Om�t�;l�]RE�},�U��c�jcE4�t`�d��I@+�9���Ol�	mU�4��P�1$-#%�}~�_<�4/<<ao�Z9�5l&(�EtF%�NZ�R�R��#�>/9q�D�GQ�BA_8V@ G�!cc�C�lL�t[�UCy;�@Z|U�V�u@�bT�A�>�/��[�*�3��3�n�(	lSlbL8:'�dJ�i�#"n�e�+A�
U{�8/��C�{�u%NQA9l/��K=|�j�Z

p�h!z2xW~�=�)�_�QG�~_
Tc*�?�34xd:lSxL
0r]##(R"�?*`N���b�*?Wt\K�Tp>�:>leeRHA\1�o�+[�'K�2s3�1�
U{�8/��C�{�u%NQA9l#��o51
>�{X~�i�5�5.&�w�T'	*�.�-xGa*WDBE~�F�K)3
a-'F<��E1#apl"#w-�uM@�]\W�-( �g|p+�dW�5�y�c�+N/D|�E�919��P:%P5u5oa;S]rT�{l#�Ht0YSERhX0�K�@(fG�+	m�*M�&�MM}��@Sf9f�Atr�Y�0��'�qjN�g"q�m��Ul#"xsy&�Y�fK
��6|_�rNnC
U��8�;@Sw�C6XEvZ8�m'�1�t"DY6l�d]l#��u<xhFg@
�Ke�.�N(b^R�ei�R$o�2#~ �*Tc^)�	�{�`{N�+�L1+]8�{l#iR9
Z<,�-�B`�XG X�e3�$*S .>U��@Sf9f�Atr�Y�0��'�qjN�g"q�m��UN(8R&tsixRRRERRtutilRtRuntimeErrorRRtobjectR	RR<RLRORTRUt_pt_rt_bt_Gxt_GytCurveFpt	curve_192RR;t
generator_192t	curve_224t
generator_224t	curve_256t
generator_256t	curve_384t
generator_384t	curve_521t
generator_521t_atcurve_secp256k1tgenerator_secp256k1t_qtcurve_brainpoolp160r1tgenerator_brainpoolp160r1tcurve_brainpoolp192r1tgenerator_brainpoolp192r1tcurve_brainpoolp224r1tgenerator_brainpoolp224r1tcurve_brainpoolp256r1tgenerator_brainpoolp256r1tcurve_brainpoolp320r1tgenerator_brainpoolp320r1tcurve_brainpoolp384r1tgenerator_brainpoolp384r1tcurve_brainpoolp512r1tgenerator_brainpoolp512r1(((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/ecdsa/ecdsa.pyt<module>6s�%C8		
		

Zerion Mini Shell 1.0