403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.15.5.27
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/lib/python3.6/site-packages/asn1crypto/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.6/site-packages/asn1crypto/__pycache__/keys.cpython-36.opt-1.pyc
3

��Zq��@s�dZddlmZmZmZmZddlZddlZddlm	Z	m
Z
mZmZm
Z
mZmZddlmZddlmZmZmZddlmZmZmZmZdd	lmZmZmZmZm Z m!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 �Z0Gdd�de(�Z1Gdd�de(�Z2Gdd�de(�Z3Gdd�d�Z4Gdd�de%e4�Z5Gdd�de$e4�Z6Gdd�de �Z7Gdd �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-d.�d.e#�Z?Gd/d0�d0e�Z@Gd1d2�d2e �ZAGd3d4�d4e(�ZBGd5d6�d6e(�ZCGd7d8�d8e(�ZDGd9d:�d:e*�ZEGd;d<�d<e#�ZFGd=d>�d>ee(�ZGGd?d@�d@e(�ZHGdAdB�dBe(�ZIGdCdD�dDe(�ZJGdEdF�dFe(�ZKGdGdH�dHe#�ZLGdIdJ�dJee(�ZMGdKdL�dLe(�ZNdS)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�RSAESOAEPParams)�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/�/usr/lib/python3.6/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/r0r1Bsr1c@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/r0r3Jsr3c
@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-r3rr1r.r/r/r/r0r5Vsr5c@s eZdZdZdefdefgZdS)�RSAPublicKeyz=
    Source: https://tools.ietf.org/html/rfc3447#page-44
    r7r8N)r*r+r,r-rr.r/r/r/r0r:isr:c@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
    r6�p�q�g�
public_key�private_keyN)r*r+r,r-rr.r/r/r/r0r;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.
    cCsjttjtj|d�d��}ttjtj|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/r0�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)
        rrrCNrB��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_lenrKrLr/r/r0�	to_coords�s	z_ECPoint.to_coordsN)r*r+r,r-�classmethodrMrVr/r/r/r0rA�srAc@seZdZdS)�ECPointN)r*r+r,r/r/r/r0rX�srXc@seZdZdS)�ECPointBitStringN)r*r+r,r/r/r/r0rY�srYc@seZdZdZdddd�ZdS)�SpecifiedECDomainVersionz:
    Source: http://www.secg.org/sec1-v2.pdf page 104
    ZecdpVer1ZecdpVer2ZecdpVer3)rrB�N)r*r+r,r-r4r/r/r/r0rZ�srZc@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-r4r/r/r/r0r\�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-r4r/r/r/r0r_�sr_c@s&eZdZdZdefdefdefgZdS)�Pentanomialz:
    Source: http://www.secg.org/sec1-v2.pdf page 102
    Zk1Zk2Zk3N)r*r+r,r-rr.r/r/r/r0rc�srcc@s6eZdZdZdefdefdefgZdZe	ee
d�ZdS)�CharacteristicTwoz`
    Original Name: Characteristic-two
    Source: http://www.secg.org/sec1-v2.pdf page 101
    �m�basis�
parameters)r`rarbN)rfrg)r*r+r,r-rr_rr.�	_oid_pairrrc�
_oid_specsr/r/r/r0rds
rdc@s.eZdZdZdefdefgZdZee	d�Z
dS)�FieldIDz:
    Source: http://www.secg.org/sec1-v2.pdf page 100
    �
field_typerg)r]r^N)rkrg)r*r+r,r-r\rr.rhrrdrir/r/r/r0rjs
rjc@s,eZdZdZdefdefdeddifgZdS)�Curvez:
    Source: http://www.secg.org/sec1-v2.pdf page 104
    �a�b�seedr9TN)r*r+r,r-rrr.r/r/r/r0rl-srlc
@sJeZdZdZdefdefdefdefdefdedd	ifd
e	dd	ifgZ
dS)�SpecifiedECDomainz:
    Source: http://www.secg.org/sec1-v2.pdf page 103
    r6�field_id�curve�base�orderZcofactorr9T�hashN)r*r+r,r-rZrjrlrXrrr.r/r/r/r0rp9srpc)@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-r4r/r/r/r0rvIsRrvc@s&eZdZdZdefdefdefgZdS)�ECDomainParametersz:
    Source: http://www.secg.org/sec1-v2.pdf page 102
    �	specified�named�implicit_caN)r*r+r,r-rprvrZ
_alternativesr/r/r/r0r|�sr|c@seZdZdZddiZdS)�ECPrivateKeyVersionzR
    Original Name: None
    Source: http://www.secg.org/sec1-v2.pdf page 108
    rZ
ecPrivkeyVer1N)r*r+r,r-r4r/r/r/r0r��sr�c@s<eZdZdZdefdefdeddd�fded	dd�fgZd
S)�ECPrivateKeyz:
    Source: http://www.secg.org/sec1-v2.pdf page 108
    r6r@rgrT)Zexplicitr9r?rN)	r*r+r,r-r�rr|rYr.r/r/r/r0r��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/r0r��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/r0r��sr�c@seZdZdZeZdS)�
Attributesz<
    Source: https://tools.ietf.org/html/rfc5208#page-3
    N)r*r+r,r-r�r2r/r/r/r0r��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-r4r/r/r/r0r��sr�c@s4eZdZdZdefdeddifgZdZee	d�Z
dS)	�PrivateKeyAlgorithmzm
    Original Name: PrivateKeyAlgorithmIdentifier
    Source: https://tools.ietf.org/html/rfc5208#page-3
    �	algorithmrgr9T)r�r�N)r�rg)r*r+r,r-r�rr.rhr�r|rir/r/r/r0r��sr�c@s�eZdZdZdefdefdefdeddd�fgZd	d
�Z	de	iZ
dZdZdZ
dZedd
��Zdd�Zdd�Zedd��Zedd��Zedd��Zedd��Zedd��Zedd��Zedd��Zed d!��ZdS)"�PrivateKeyInfoz<
    Source: https://tools.ietf.org/html/rfc5208#page-3
    r6�private_key_algorithmr@Z
attributesrT)Zimplicitr9cCs|ddj}tttd�|S)Nr�r�)r�r�r�)rPr5rr�)rTr�r/r/r0�_private_key_spec�s
z PrivateKeyInfo._private_key_specNcCsDt|t�r*t|t�r*ttdt|����|dkrNt|t�sFtj|�}t�}n�|dkr�t|t	�sjt	j|�}t
�}|d|d<|d|d<|d|d<|d}|d}nH|d	kr�t|t�s�tj|�}n|j�}|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�rgzU
                algorithm must be one of "rsa", "dsa", "ec", not %s
                r�rr6r�)�
isinstancerr�	TypeErrorrrr5�loadrr;r�r��copyrS�reprr�r��
_algorithmr�_public_key)rJr@r��paramsr?Zprivate_key_algo�	containerr/r/r0�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��}|ddjdj�\}}t
|||�}n6|dk�r>|d k�r*ttd|���tttttd�|}||djdj}	tj|	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�rgr>r@r<r�r7r8)r7r8r�rz�
                    Unable to compute public key for EC key using Implicit CA
                    parameters
                    r}rqrkr^z�
                        Unable to compute public key for EC key over a
                        characteristic two field
                        rrrmrnrsr~rwrxryrzr{z�
                        Unable to compute public key for EC named curve %s,
                        parameters not currently included
                        )rwrxryrzr{N)rwrxryrzr{)r�r�powrP�parsedr:rrrSrrr%�chosenrVr
rrr	r
rrYrMrKrL)
rTr��keyZ
curve_typeZdetailsrrZbase_xZbase_yZ
base_pointZpublic_pointr/r/r0�_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�rgrr<r=r>)r6r<r=r>r?r@r�r?N)r�r�r;r?)rTr��outputr/r/r0r�s 	





zPrivateKeyInfo.unwrapcCsP|jdkrttd|jj����|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�rgrN)r�rSr�upperr��namerP)rTr�r��valuer/r/r0rr�s

zPrivateKeyInfo.curvecCsL|jdkrttd|jj����tj|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�rgr=rB���sha1�sha2)r�rSrr�rFrHrP)rT�byte_lenr/r/r0�	hash_algo�s
zPrivateKeyInfo.hash_algocCs |jdkr|ddj|_|jS)zO
        :return:
            A unicode string of "rsa", "dsa" or "ec"
        Nr�r�)r�rP)rTr/r/r0r��s
zPrivateKeyInfo.algorithmcCs�|jdkr�|jdkr&|djdj}n8|jdkrD|dddj}n|jd	kr^|djdj}ttjtj|d
���|_|jd}|dkr�|jd|7_|jS)
zU
        :return:
            The bit size of the private key, as an integer
        Nr�r@r7r�r�rgr<r�rBr�r)�	_bit_sizer�r�rPrErFrGrH)rTr(r7r/r/r0�bit_size�s




zPrivateKeyInfo.bit_sizecCsttj|jd��S)zV
        :return:
            The byte size of the private key, as an integer
        r�)rErFrGr�)rTr/r/r0�	byte_size
szPrivateKeyInfo.byte_sizecCsR|jdkrL|jdkrB|dj}|dr6|dj�|_qL|j�|_n
|j�|_|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�)rTr�r/r/r0r?s



zPrivateKeyInfo.public_keycCs t|j|ddd�|jd��S)z\
        :return:
            A PublicKeyInfo object derived from this private key.
        r�rg)r�rg)r�r?)�
PublicKeyInfor�r?)rTr/r/r0�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}|jd�}||7}nr|jdkr�|}nb|jdk�r>d|jddj}|jd�}|d|jddj7}|d|jddj7}||7}t|t	��rT|jd�}t
j|�j�|_|jS)aY
        Creates a fingerprint that can be compared with a public key to see if
        the two form a pair.

        This fingerprint is not compatible 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�rgr@r�z%d:%dr7r8r�z%d:%d:%d:%dr<r=r>r�r?r~z%s:zutf-8rr}rq�:rrrmrn)
�_fingerprintr�r�rPr?r�r��encoder�r�hashlib�sha256�digest)rTr�r��to_hashr?r/r/r0�fingerprint9sD









zPrivateKeyInfo.fingerprint)r*r+r,r-rr�r r�r.r��_spec_callbacksr�r�r�r�rWr�r�r�propertyrrr�r�r�r�r?r�r�r/r/r/r0r��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/r0r�vsr�c@s eZdZdZdefdefgZdS)�ValidationParmsz=
    Source: https://tools.ietf.org/html/rfc3279#page-10
    roZpgen_counterN)r*r+r,r-rrr.r/r/r/r0r��sr�c@s>eZdZdZdefdefdefdeddifdeddifgZd	S)
�DomainParametersz=
    Source: https://tools.ietf.org/html/rfc3279#page-10
    r<r>r=�jr9TZvalidation_paramsN)r*r+r,r-rr�r.r/r/r/r0r��sr�c@s eZdZdZdddddd�ZdS)	�PublicKeyAlgorithmIdzM
    Original Name: None
    Source: https://tools.ietf.org/html/rfc3279
    r��
rsaes_oaepr�r��dh)z1.2.840.113549.1.1.1z1.2.840.113549.1.1.7z1.2.840.10040.4.1z1.2.840.10045.2.1z1.2.840.10046.2.1N)r*r+r,r-r4r/r/r/r0r��sr�c@s8eZdZdZdefdeddifgZdZee	e
ed�ZdS)	�PublicKeyAlgorithmzd
    Original Name: AlgorithmIdentifier
    Source: https://tools.ietf.org/html/rfc5280#page-18
    r�rgr9T)r�r�r�r�N)r�rg)
r*r+r,r-r�rr.rhr�r|r�rrir/r/r/r0r��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}ttttdftd�|S)Nr�)r�r�r�r�r�)rPr:rrY)rTr�r/r/r0�_public_key_spec�szPublicKeyInfo._public_key_specNcCs�t|t�r*t|t�r*ttdt|����|dkrDttdt|����t�}t	|�|d<t
�|d<|�}||d<t|t�r�|j�j�}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�rgr?)r�rrr�rrrSr�r�r�rr��dumpr!)rJr?r�Zalgor�r/r/r0r��s"

zPublicKeyInfo.wrapcCsB|jdkr|djS|jj�}|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?ZECZanrmzj
            Only RSA public keys may be unwrapped - this key is %s %s public
            key
            N)r�r�r�rSr)rT�key_typeZa_anr/r/r0rs	


zPublicKeyInfo.unwrapcCsP|jdkrttd|jj����|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�rgrN)r�rSrr�r�r�rP)rTr�r�r�r/r/r0rr's

zPublicKeyInfo.curvecCs^|jdkrttd|jj����|dd}|jdkr8dStj|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�rgNr=rBr�r�r�r�)r�rSrr�rPrFrH)rTrgr�r/r/r0r�Is

zPublicKeyInfo.hash_algocCs |jdkr|ddj|_|jS)zO
        :return:
            A unicode string of "rsa", "dsa" or "ec"
        Nr�)r�rP)rTr/r/r0r�hs
zPublicKeyInfo.algorithmcCs�|jdkr�|jdkr2t|dj�ddd|_nt|jdkrN|djdj}n|jd	krj|d
ddj}ttjtj|d���|_|jd}|d
kr�|jd|7_|jS)zT
        :return:
            The bit size of the public key, as an integer
        Nr�r?rrBr�r�r7r�r�rgr<r)	r�r�rQrPr�rErFrGrH)rTr(r7r/r/r0r�ss




zPublicKeyInfo.bit_sizecCsttj|jd��S)zU
        :return:
            The byte size of the public key, as an integer
        r�)rErFrGr�)rTr/r/r0r��szPublicKeyInfo.byte_sizecCs(|jdkr"tjt|d��j�|_|jS)ze
        :return:
            The SHA1 hash of the DER-encoded bytes of this public key info
        Nr?)�_sha1r�r�rr�)rTr/r/r0r��s
zPublicKeyInfo.sha1cCs(|jdkr"tjt|d��j�|_|jS)zh
        :return:
            The SHA-256 hash of the DER-encoded bytes of this public key info
        Nr?)�_sha256r�r�rr�)rTr/r/r0r��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}|jd�}||j7}nv|jdkr�|j}nd|jdk�r>d|jddj}|jd�}|d|jddj7}|d|jddj7}||j7}t|t��rT|jd�}tj	|�j
�|_|jS)aZ
        Creates a fingerprint that can be compared with a private key to see if
        the two form a pair.

        This fingerprint is not compatible 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�rgr�r?z%d:%dr7r8r�z%d:%d:%d:%dr<r=r>r�r~z%s:zutf-8rr}rqr�rrrmrn)r�rPr�r�r�r�r�rr�r�r�)rTr�r�r�r�r/r/r0r��sB








zPublicKeyInfo.fingerprint)r*r+r,r-r�r!r.r�r�r�r�r�r�r�rWr�rr�rrr�r�r�r�r�r�r�r/r/r/r0r��s(

+"	r�)Or-Z
__future__rrrrr�rFZ_elliptic_curverrr	r
rrr
Z_errorsrZ_typesrrrZalgosrrrrZcorerrrrrrrrrrr r!r"r#r$�utilr%r&r'r1r3r5r:r;rArXrYrZr\r_rcrdrjrlrprvr|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r/r/r/r0�<module>sZ$	DF
7



Youez - 2016 - github.com/yon3zu
LinuXploit