%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python37/lib/python3.7/site-packages/asn1crypto/__pycache__/
Upload File :
Create Path :
Current File : //opt/alt/python37/lib/python3.7/site-packages/asn1crypto/__pycache__/keys.cpython-37.pyc

B

���W��@s�dZddlmZmZmZmZddlZddlZddlm	Z	m
Z
mZmZm
Z
mZmZddlmZddlmZmZmZddlmZmZmZdd	lmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)dd
l*m+Z+m,Z,Gdd�de'�Z-Gd
d�de(�Z.Gdd�de�Z/Gdd�de'�Z0Gdd�de'�Z1Gdd�de'�Z2Gdd�d�Z3Gdd�de$e3�Z4Gdd�de#e3�Z5Gdd�de�Z6Gdd �d e"�Z7Gd!d"�d"e"�Z8Gd#d$�d$e'�Z9Gd%d&�d&e'�Z:Gd'd(�d(e'�Z;Gd)d*�d*e'�Z<Gd+d,�d,e'�Z=Gd-d.�d.e"�Z>Gd/d0�d0e�Z?Gd1d2�d2e�Z@Gd3d4�d4e'�ZAGd5d6�d6e'�ZBGd7d8�d8e'�ZCGd9d:�d:e)�ZDGd;d<�d<e"�ZEGd=d>�d>ee'�ZFGd?d@�d@e'�ZGGdAdB�dBe'�ZHGdCdD�dDe'�ZIGdEdF�dFe'�ZJGdGdH�dHe"�ZKGdIdJ�dJee'�ZLGdKdL�dLe'�ZMdS)Ma'
ASN.1 type classes for public and private keys. Exports the following items:

 - DSAPrivateKey()
 - ECPrivateKey()
 - EncryptedPrivateKeyInfo()
 - PrivateKeyInfo()
 - PublicKeyInfo()
 - RSAPrivateKey()
 - RSAPublicKey()

Other type classes are defined that help compose the types listed above.
�)�unicode_literals�division�absolute_import�print_functionN�)�SECP192R1_BASE_POINT�SECP224R1_BASE_POINT�SECP256R1_BASE_POINT�SECP384R1_BASE_POINT�SECP521R1_BASE_POINT�
PrimeCurve�
PrimePoint)�unwrap)�	type_name�str_cls�byte_cls)�_ForceNullParameters�DigestAlgorithm�EncryptionAlgorithm)�Any�	Asn1Value�	BitString�Choice�Integer�IntegerOctetString�Null�ObjectIdentifier�OctetBitString�OctetString�ParsableOctetString�ParsableOctetBitString�Sequence�
SequenceOf�SetOf)�int_from_bytes�int_to_bytesc@s&eZdZdZdefdefdefgZdS)�OtherPrimeInfoz=
    Source: https://tools.ietf.org/html/rfc3447#page-46
    �primeZexponent�coefficientN)�__name__�
__module__�__qualname__�__doc__r�_fields�r.r.�@/opt/alt/python37/lib/python3.7/site-packages/asn1crypto/keys.pyr&6sr&c@seZdZdZeZdS)�OtherPrimeInfosz=
    Source: https://tools.ietf.org/html/rfc3447#page-46
    N)r)r*r+r,r&�_child_specr.r.r.r/r0Bsr0c@seZdZdZddd�ZdS)�RSAPrivateKeyVersionzX
    Original Name: Version
    Source: https://tools.ietf.org/html/rfc3447#page-45
    z	two-primeZmulti)rrN)r)r*r+r,�_mapr.r.r.r/r2Jsr2c
@sVeZdZdZdefdefdefdefdefdefdefd	efd
efdedd
ifg
ZdS)�
RSAPrivateKeyz=
    Source: https://tools.ietf.org/html/rfc3447#page-45
    �version�modulus�public_exponentZprivate_exponentZprime1Zprime2Z	exponent1Z	exponent2r(Zother_prime_infos�optionalTN)r)r*r+r,r2rr0r-r.r.r.r/r4Vsr4c@s eZdZdZdefdefgZdS)�RSAPublicKeyz=
    Source: https://tools.ietf.org/html/rfc3447#page-44
    r6r7N)r)r*r+r,rr-r.r.r.r/r9isr9c@s8eZdZdZdefdefdefdefdefdefgZdS)	�
DSAPrivateKeya&
    The ASN.1 structure that OpenSSL uses to store a DSA private key that is
    not part of a PKCS#8 structure. Reversed engineered from english-language
    description on linked OpenSSL documentation page.

    Original Name: None
    Source: https://www.openssl.org/docs/apps/dsa.html
    r5�p�q�g�
public_key�private_keyN)r)r*r+r,rr-r.r.r.r/r:tsr:c@s$eZdZdZedd��Zdd�ZdS)�_ECPointa

    In both PublicKeyInfo and PrivateKeyInfo, the EC public key is a byte
    string that is encoded as a bit string. This class adds convenience
    methods for converting to and from the byte string to a pair of integers
    that are the X and Y coordinates.
    cCsjtt�t�|d�d��}tt�t�|d�d��}t||�}d}|t||d�7}|t||d�7}||�S)a
        Creates an ECPoint object from the X and Y integer coordinates of the
        point

        :param x:
            The X coordinate, as an integer

        :param y:
            The Y coordinate, as an integer

        :return:
            An ECPoint object
        �g @�)�width)�int�math�ceil�log�maxr%)�cls�x�yZx_bytesZy_bytesZ	num_bytesZbyte_stringr.r.r/�from_coords�s
z_ECPoint.from_coordscCs�|j}|dd�}|dkrZ|dd�}t|�d}t|d|��}t||d��}||fS|tddg�krvttd���ttd	���dS)
z�
        Returns the X and Y coordinates for this EC point, as native Python
        integers

        :return:
            A 2-element tuple containing integers (X, Y)
        rrrBNrA��zQ
                Invalid EC public key - first byte is incorrect
                z|
            Compressed representations of EC public keys are not supported due
            to patent US6252960
            )�native�lenr$�set�
ValueErrorr)�self�dataZ
first_byteZ	remainingZ	field_lenrJrKr.r.r/�	to_coords�s	z_ECPoint.to_coordsN)r)r*r+r,�classmethodrLrUr.r.r.r/r@�sr@c@seZdZdS)�ECPointN)r)r*r+r.r.r.r/rW�srWc@seZdZdS)�ECPointBitStringN)r)r*r+r.r.r.r/rX�srXc@seZdZdZdddd�ZdS)�SpecifiedECDomainVersionz:
    Source: http://www.secg.org/sec1-v2.pdf page 104
    ZecdpVer1ZecdpVer2ZecdpVer3)rrA�N)r)r*r+r,r3r.r.r.r/rY�srYc@seZdZdZddd�ZdS)�	FieldTypezR
    Original Name: None
    Source: http://www.secg.org/sec1-v2.pdf page 101
    �prime_field�characteristic_two_field)z1.2.840.10045.1.1z1.2.840.10045.1.2N)r)r*r+r,r3r.r.r.r/r[�sr[c@seZdZdZdddd�ZdS)�CharacteristicTwoBasiszR
    Original Name: None
    Source: http://www.secg.org/sec1-v2.pdf page 102
    �gn_basis�tp_basis�pp_basis)z1.2.840.10045.1.2.1.1z1.2.840.10045.1.2.1.2z1.2.840.10045.1.2.1.3N)r)r*r+r,r3r.r.r.r/r^�sr^c@s&eZdZdZdefdefdefgZdS)�Pentanomialz:
    Source: http://www.secg.org/sec1-v2.pdf page 102
    Zk1Zk2Zk3N)r)r*r+r,rr-r.r.r.r/rb�srbc@s6eZdZdZdefdefdefgZdZe	ee
d�ZdS)�CharacteristicTwoz`
    Original Name: Characteristic-two
    Source: http://www.secg.org/sec1-v2.pdf page 101
    �m�basis�
parameters)rerf)r_r`raN)r)r*r+r,rr^rr-�	_oid_pairrrb�
_oid_specsr.r.r.r/rcs
rcc@s.eZdZdZdefdefgZdZee	d�Z
dS)�FieldIDz:
    Source: http://www.secg.org/sec1-v2.pdf page 100
    �
field_typerf)rjrf)r\r]N)r)r*r+r,r[rr-rgrrcrhr.r.r.r/ris
ric@s,eZdZdZdefdefdeddifgZdS)�Curvez:
    Source: http://www.secg.org/sec1-v2.pdf page 104
    �a�b�seedr8TN)r)r*r+r,rrr-r.r.r.r/rk-srkc
@sJeZdZdZdefdefdefdefdefdedd	ifd
e	dd	ifgZ
dS)�SpecifiedECDomainz:
    Source: http://www.secg.org/sec1-v2.pdf page 103
    r5�field_id�curve�base�orderZcofactorr8T�hashN)r)r*r+r,rYrirkrWrrr-r.r.r.r/ro9sroc)@sfeZdZdZdddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*�(Zd+S),�
NamedCurvez�
    Various named curves

    Original Name: None
    Source: https://tools.ietf.org/html/rfc3279#page-23,
            https://tools.ietf.org/html/rfc5480#page-5
    Z
c2pnb163v1Z
c2pnb163v2Z
c2pnb163v3Z
c2pnb176w1Z
c2tnb191v1Z
c2tnb191v2Z
c2tnb191v3Z
c2onb191v4Z
c2onb191v5Z
c2pnb208w1Z
c2tnb239v1Z
c2tnb239v2Z
c2tnb239v3Z
c2onb239v4Z
c2onb239v5Z
c2pnb272w1Z
c2pnb304w1Z
c2tnb359v1Z
c2pnb368w1Z
c2tnb431r1Z
prime192v2Z
prime192v3Z
prime239v1Z
prime239v2Z
prime239v3Z	sect163k1Z	sect163r2�	secp192r1�	secp224r1Z	sect233k1�	secp256r1Z	sect233r1Z	sect283k1Z	sect283r1�	secp384r1Z	sect409k1Z	sect409r1�	secp521r1Z	sect571k1Z	sect571r1)(z1.2.840.10045.3.0.1z1.2.840.10045.3.0.2z1.2.840.10045.3.0.3z1.2.840.10045.3.0.4z1.2.840.10045.3.0.5z1.2.840.10045.3.0.6z1.2.840.10045.3.0.7z1.2.840.10045.3.0.8z1.2.840.10045.3.0.9z1.2.840.10045.3.0.10z1.2.840.10045.3.0.11z1.2.840.10045.3.0.12z1.2.840.10045.3.0.13z1.2.840.10045.3.0.14z1.2.840.10045.3.0.15z1.2.840.10045.3.0.16z1.2.840.10045.3.0.17z1.2.840.10045.3.0.18z1.2.840.10045.3.0.19z1.2.840.10045.3.0.20z1.2.840.10045.3.1.2z1.2.840.10045.3.1.3z1.2.840.10045.3.1.4z1.2.840.10045.3.1.5z1.2.840.10045.3.1.6z1.3.132.0.1z1.3.132.0.15z1.2.840.10045.3.1.1z1.3.132.0.33z1.3.132.0.26z1.2.840.10045.3.1.7z1.3.132.0.27z1.3.132.0.16z1.3.132.0.17z1.3.132.0.34z1.3.132.0.36z1.3.132.0.37z1.3.132.0.35z1.3.132.0.38z1.3.132.0.39N)r)r*r+r,r3r.r.r.r/ruIsRruc@s&eZdZdZdefdefdefgZdS)�ECDomainParametersz:
    Source: http://www.secg.org/sec1-v2.pdf page 102
    �	specified�named�implicit_caN)r)r*r+r,rorurZ
_alternativesr.r.r.r/r{�sr{c@seZdZdZddiZdS)�ECPrivateKeyVersionzR
    Original Name: None
    Source: http://www.secg.org/sec1-v2.pdf page 108
    rZ
ecPrivkeyVer1N)r)r*r+r,r3r.r.r.r/r�src	@s@eZdZdZdefdefdedddd�fd	edd
dd�fgZdS)�ECPrivateKeyz:
    Source: http://www.secg.org/sec1-v2.pdf page 108
    r5r?rfZexplicitrT)�tag_type�tagr8r>rN)	r)r*r+r,rrr{rXr-r.r.r.r/r��s
r�c@s&eZdZdZdefdefdefgZdS)�	DSAParamsz�
    Parameters for a DSA public or private key

    Original Name: Dss-Parms
    Source: https://tools.ietf.org/html/rfc3279#page-9
    r;r<r=N)r)r*r+r,rr-r.r.r.r/r��sr�c@s&eZdZdZdefdedeifgZdS)�	Attributezq
    Source: https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-X.501-198811-S!!PDF-E&type=items page 8
    �type�values�specN)r)r*r+r,rr#rr-r.r.r.r/r��sr�c@seZdZdZeZdS)�
Attributesz<
    Source: https://tools.ietf.org/html/rfc5208#page-3
    N)r)r*r+r,r�r1r.r.r.r/r��sr�c@seZdZdZdddd�ZdS)�PrivateKeyAlgorithmIdz�
    These OIDs for various public keys are reused when storing private keys
    inside of a PKCS#8 structure

    Original Name: None
    Source: https://tools.ietf.org/html/rfc3279
    �rsa�dsa�ec)z1.2.840.113549.1.1.1z1.2.840.10040.4.1z1.2.840.10045.2.1N)r)r*r+r,r3r.r.r.r/r��sr�c@s4eZdZdZdefdeddifgZdZee	d�Z
dS)	�PrivateKeyAlgorithmzm
    Original Name: PrivateKeyAlgorithmIdentifier
    Source: https://tools.ietf.org/html/rfc5208#page-3
    �	algorithmrfr8T)r�rf)r�r�N)r)r*r+r,r�rr-rgr�r{rhr.r.r.r/r��sr�c	@s�eZdZdZdefdefdefdedddd	�fgZd
d�Z	de	iZ
dZdZdZ
dZed
d��Zdd�Zdd�Zedd��Zedd��Zedd��Zedd��Zedd��Zedd��Zedd ��Zed!d"��ZdS)#�PrivateKeyInfoz<
    Source: https://tools.ietf.org/html/rfc5208#page-3
    r5�private_key_algorithmr?Z
attributesZimplicitrT)r�r�r8cCs|ddj}tttd�|S)Nr�r�)r�r�r�)rOr4rr�)rSr�r.r.r/�_private_key_spec�s
z PrivateKeyInfo._private_key_specNcCs@t|t�s&t|t�s&ttdt|����|dkrJt|t�sBt�|�}t�}n�|dkr�t|t	�sft	�|�}t
�}|d|d<|d|d<|d|d<|d}|d}nH|d	kr�t|t�s�t�|�}n|��}|d
}|d
=nt
tdt|����t�}t|�|d<||d
<|�}||_td
�|d<||d<||d<|dk�r<||_|S)a'
        Wraps a private key in a PrivateKeyInfo structure

        :param private_key:
            A byte string or Asn1Value object of the private key

        :param algorithm:
            A unicode string of "rsa", "dsa" or "ec"

        :return:
            A PrivateKeyInfo object
        zX
                private_key must be a byte string or Asn1Value, not %s
                r�r�r;r<r=r>r?r�rfzU
                algorithm must be one of "rsa", "dsa", "ec", not %s
                r�rr5r�)�
isinstancerr�	TypeErrorrrr4�loadrr:r�r��copyrR�reprr�r��
_algorithmr�_public_key)rIr?r��paramsr>Zprivate_key_algo�	containerr.r.r/�wrapsJ






zPrivateKeyInfo.wrapc
Csf|jdkr:|dd}tt|dj|djj|dj��S|jdkrd|dj}t|d|d	d
��S|jdk�rb|j\}}|dkr�ttd
���|dk�r|dddkr�ttd���t	|ddt
|dd�t
|dd��}|ddjd��\}}t
|||�}n6|dk�r>|dk�r*ttd|���tttttd�|}||djdj}	t�|	j|	j�SdS)z�
        Computes the public key corresponding to the current private key.

        :return:
            For RSA keys, an RSAPublicKey object. For DSA keys, an Integer
            object. For EC keys, an ECPointBitString.
        r�r�rfr=r?r;r�r6r7)r6r7r�r~z�
                    Unable to compute public key for EC key using Implicit CA
                    parameters
                    r|rprjr]z�
                        Unable to compute public key for EC key over a
                        characteristic two field
                        rqrlrmrrr})rvrwrxryrzz�
                        Unable to compute public key for EC named curve %s,
                        parameters not currently included
                        N)r�r�powrO�parsedr9rqrRrrr$�chosenrUr
rrr	r
rrXrLrJrK)
rSr��keyZ
curve_typeZdetailsrqZbase_xZbase_yZ
base_pointZpublic_pointr.r.r/�_compute_public_keyLsN	








z"PrivateKeyInfo._compute_public_keycCs�|jdkr|djS|jdkrT|dd}td|d|d|d	|j|djd
��S|jdkr�|dj}|dd|d<|j|d<|Sd
S)z�
        Unwraps the private key into an RSAPrivateKey, DSAPrivateKey or
        ECPrivateKey object

        :return:
            An RSAPrivateKey, DSAPrivateKey or ECPrivateKey object
        r�r?r�r�rfrr;r<r=)r5r;r<r=r>r?r�r>N)r�r�r:r>)rSr��outputr.r.r/r�s 	





zPrivateKeyInfo.unwrapcCsP|jdkrttd|j�����|dd}|j}|jdkr@d}n|j}|j|fS)a#
        Returns information about the curve used for an EC key

        :raises:
            ValueError - when the key is not an EC key

        :return:
            A two-element tuple, with the first element being a unicode string
            of "implicit_ca", "specified" or "named". If the first element is
            "implicit_ca", the second is None. If "specified", the second is
            an OrderedDict that is the native version of SpecifiedECDomain. If
            "named", the second is a unicode string of the curve name.
        r�zK
                Only EC keys have a curve, this key is %s
                r�rfr~N)r�rRr�upperr��namerO)rSr�r��valuer.r.r/rq�s

zPrivateKeyInfo.curvecCsL|jdkrttd|j�����t�|dddjd�d}|dkrHd	Sd
S)z�
        Returns the name of the family of hash algorithms used to generate a
        DSA key

        :raises:
            ValueError - when the key is not a DSA key

        :return:
            A unicode string of "sha1" or "sha2"
        r�zt
                Only DSA keys are generated using a hash algorithm, this key is
                %s
                r�rfr<rA���sha1�sha2)r�rRrr�rErGrO)rS�byte_lenr.r.r/�	hash_algo�s
zPrivateKeyInfo.hash_algocCs |jdkr|ddj|_|jS)zO
        :return:
            A unicode string of "rsa", "dsa" or "ec"
        Nr�r�)r�rO)rSr.r.r/r��s
zPrivateKeyInfo.algorithmcCs�|jdkr�|jdkr&|djdj}n8|jdkrD|dddj}n|jd	kr^|djdj}tt�t�|d
���|_|jd}|dkr�|jd|7_|jS)
zU
        :return:
            The bit size of the private key, as an integer
        Nr�r?r6r�r�rfr;r�rAr�r)�	_bit_sizer�r�rOrDrErFrG)rSr'r6r.r.r/�bit_size�s




zPrivateKeyInfo.bit_sizecCstt�|jd��S)zV
        :return:
            The byte size of the private key, as an integer
        r�)rDrErFr�)rSr.r.r/�	byte_size
szPrivateKeyInfo.byte_sizecCsR|jdkrL|jdkrB|dj}|dr6|d��|_qL|��|_n
|��|_|jS)z�
        :return:
            If an RSA key, an RSAPublicKey object. If a DSA key, an Integer
            object. If an EC key, an ECPointBitString object.
        Nr�r?r>)r�r�r��untagr�)rSr�r.r.r/r>s



zPrivateKeyInfo.public_keycCs t|j|ddd�|jd��S)z\
        :return:
            A PublicKeyInfo object derived from this private key.
        r�rf)r�rf)r�r>)�
PublicKeyInfor�r>)rSr.r.r/�public_key_info*szPrivateKeyInfo.public_key_infocCsj|jdk�rd|dd}|dj}|jdkrFd|dj|djf}n�|jd	kr||j}d
|dj|dj|d
j|jf}n�|jdk�r>|dj}|dkr�|jj}|jdkr�d|jj}|�d�}||7}nr|jdkr�|}nb|jdk�r>d|jddj}|�d�}|d|jddj7}|d|jddj7}||7}t|t	��rT|�d�}t
�|���|_|jS)aZ
        Creates a fingerprint that can be compared with a public key to see if
        the two form a pair.

        This fingerprint is not compatiable with fingerprints generated by any
        other software.

        :return:
            A byte string that is a sha256 hash of selected components (based
            on the key type)
        Nr�rfr?r�z%d:%dr6r7r�z%d:%d:%d:%dr;r<r=r�r>r}z%s:zutf-8r~r|rp�:rqrlrm)
�_fingerprintr�r�rOr>r�r��encoder�r�hashlib�sha256�digest)rSr�r��to_hashr>r.r.r/�fingerprint9sD









zPrivateKeyInfo.fingerprint)r)r*r+r,rr�rr�r-r��_spec_callbacksr�r�r�r�rVr�r�r�propertyrqr�r�r�r�r>r�r�r.r.r.r/r��s,	DI"	r�c@s eZdZdZdefdefgZdS)�EncryptedPrivateKeyInfoz<
    Source: https://tools.ietf.org/html/rfc5208#page-4
    Zencryption_algorithmZencrypted_dataN)r)r*r+r,rrr-r.r.r.r/r�vsr�c@s eZdZdZdefdefgZdS)�ValidationParmsz=
    Source: https://tools.ietf.org/html/rfc3279#page-10
    rnZpgen_counterN)r)r*r+r,rrr-r.r.r.r/r��sr�c@s>eZdZdZdefdefdefdeddifdeddifgZd	S)
�DomainParametersz=
    Source: https://tools.ietf.org/html/rfc3279#page-10
    r;r=r<�jr8TZvalidation_paramsN)r)r*r+r,rr�r-r.r.r.r/r��sr�c@seZdZdZddddd�ZdS)�PublicKeyAlgorithmIdzM
    Original Name: None
    Source: https://tools.ietf.org/html/rfc3279
    r�r�r��dh)z1.2.840.113549.1.1.1z1.2.840.10040.4.1z1.2.840.10045.2.1z1.2.840.10046.2.1N)r)r*r+r,r3r.r.r.r/r��s
r�c@s6eZdZdZdefdeddifgZdZee	e
d�ZdS)	�PublicKeyAlgorithmzd
    Original Name: AlgorithmIdentifier
    Source: https://tools.ietf.org/html/rfc5280#page-18
    r�rfr8T)r�rf)r�r�r�N)r)r*r+r,r�rr-rgr�r{r�rhr.r.r.r/r��sr�c@s�eZdZdZdefdefgZdd�ZdeiZdZ	dZ
dZdZdZ
edd��Zd	d
�Zedd��Zed
d��Zedd��Zedd��Zedd��Zedd��Zedd��Zedd��ZdS)r�ze
    Original Name: SubjectPublicKeyInfo
    Source: https://tools.ietf.org/html/rfc5280#page-17
    r�r>cCs$|ddj}tttdftd�|S)Nr�)r�r�r�r�)rOr9rrX)rSr�r.r.r/�_public_key_spec�szPublicKeyInfo._public_key_specNcCs�t|t�s&t|t�s&ttdt|����|dkr@ttdt|����t�}t	|�|d<t
�|d<|�}||d<t|t�r�|����}t
|�|d<|S)a
        Wraps a public key in a PublicKeyInfo structure

        :param public_key:
            A byte string or Asn1Value object of the public key

        :param algorithm:
            A unicode string of "rsa"

        :return:
            A PublicKeyInfo object
        zW
                public_key must be a byte string or Asn1Value, not %s
                r�z>
                algorithm must "rsa", not %s
                r�rfr>)r�rrr�rrrRr�r�r�rr��dumpr )rIr>r�Zalgor�r.r.r/r��s"

zPublicKeyInfo.wrapcCsB|jdkr|djS|j��}|dkr*dnd}ttd||���dS)z�
        Unwraps an RSA public key into an RSAPublicKey object. Does not support
        DSA or EC public keys since they do not have an unwrapped form.

        :return:
            An RSAPublicKey object
        r�r>ZECZanrlzj
            Only RSA public keys may be unwrapped - this key is %s %s public
            key
            N)r�r�r�rRr)rS�key_typeZa_anr.r.r/rs	


zPublicKeyInfo.unwrapcCsP|jdkrttd|j�����|dd}|j}|jdkr@d}n|j}|j|fS)a#
        Returns information about the curve used for an EC key

        :raises:
            ValueError - when the key is not an EC key

        :return:
            A two-element tuple, with the first element being a unicode string
            of "implicit_ca", "specified" or "named". If the first element is
            "implicit_ca", the second is None. If "specified", the second is
            an OrderedDict that is the native version of SpecifiedECDomain. If
            "named", the second is a unicode string of the curve name.
        r�zK
                Only EC keys have a curve, this key is %s
                r�rfr~N)r�rRrr�r�r�rO)rSr�r�r�r.r.r/rq#s

zPublicKeyInfo.curvecCs^|jdkrttd|j�����|dd}|jdkr8dSt�|djd�d}|d	krZd
SdS)a#
        Returns the name of the family of hash algorithms used to generate a
        DSA key

        :raises:
            ValueError - when the key is not a DSA key

        :return:
            A unicode string of "sha1" or "sha2" or None if no parameters are
            present
        r�zt
                Only DSA keys are generated using a hash algorithm, this key is
                %s
                r�rfNr<rAr�r�r�r�)r�rRrr�rOrErG)rSrfr�r.r.r/r�Es

zPublicKeyInfo.hash_algocCs |jdkr|ddj|_|jS)zO
        :return:
            A unicode string of "rsa", "dsa" or "ec"
        Nr�)r�rO)rSr.r.r/r�ds
zPublicKeyInfo.algorithmcCs�|jdkr�|jdkr2t|dj�ddd|_nt|jdkrN|djdj}n|jd	krj|d
ddj}tt�t�|d���|_|jd}|d
kr�|jd|7_|jS)zT
        :return:
            The bit size of the public key, as an integer
        Nr�r>rrAr�r�r6r�r�rfr;r)	r�r�rPrOr�rDrErFrG)rSr'r6r.r.r/r�os




zPublicKeyInfo.bit_sizecCstt�|jd��S)zU
        :return:
            The byte size of the public key, as an integer
        r�)rDrErFr�)rSr.r.r/r��szPublicKeyInfo.byte_sizecCs(|jdkr"t�t|d����|_|jS)ze
        :return:
            The SHA1 hash of the DER-encoded bytes of this public key info
        Nr>)�_sha1r�r�rr�)rSr.r.r/r��s
zPublicKeyInfo.sha1cCs(|jdkr"t�t|d����|_|jS)zh
        :return:
            The SHA-256 hash of the DER-encoded bytes of this public key info
        Nr>)�_sha256r�r�rr�)rSr.r.r/r��s
zPublicKeyInfo.sha256cCsj|jdk�rd|ddj}|dd}|dkrR|dj}d|dj|djf}n�|d	kr�|dj}d
|dj|dj|d
j|jf}n�|dk�r>|d}|jdkr�d|jj}|�d�}||j7}nv|jdkr�|j}nd|jdk�r>d|jddj}|�d�}|d|jddj7}|d|jddj7}||j7}t|t��rT|�d�}t�	|��
�|_|jS)a[
        Creates a fingerprint that can be compared with a private key to see if
        the two form a pair.

        This fingerprint is not compatiable with fingerprints generated by any
        other software.

        :return:
            A byte string that is a sha256 hash of selected components (based
            on the key type)
        Nr�rfr�r>z%d:%dr6r7r�z%d:%d:%d:%dr;r<r=r�r}z%s:zutf-8r~r|rpr�rqrlrm)r�rOr�r�r�r�r�rr�r�r�)rSr�r�r�r�r.r.r/r��sB








zPublicKeyInfo.fingerprint)r)r*r+r,r�r r-r�r�r�r�r�r�r�rVr�rr�rqr�r�r�r�r�r�r�r.r.r.r/r��s(
+"	r�)Nr,Z
__future__rrrrr�rEZ_elliptic_curverrr	r
rrr
Z_errorsrZ_typesrrrZalgosrrrZcorerrrrrrrrrrrr r!r"r#�utilr$r%r&r0r2r4r9r:r@rWrXrYr[r^rbrcrirkrorur{rr�r�r�r�r�r�r�r�r�r�r�r�r�r.r.r.r/�<module>sZ$	DF
7



Zerion Mini Shell 1.0