403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.144.230.138
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 :  /opt/alt/python37/lib/python3.7/site-packages/asn1crypto/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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
    �prime�exponent�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/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.
    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/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_byte�	remainingZ	field_lenrKrLr/r/r0�	to_coords�s	z_ECPoint.to_coordsN)r*r+r,r-�classmethodrMrWr/r/r/r0rA�srAc@seZdZdS)�ECPointN)r*r+r,r/r/r/r0rY�srYc@seZdZdS)�ECPointBitStringN)r*r+r,r/r/r/r0rZ�srZc@seZdZdZdddd�ZdS)�SpecifiedECDomainVersionz:
    Source: http://www.secg.org/sec1-v2.pdf page 104
    ZecdpVer1ZecdpVer2ZecdpVer3)rrB�N)r*r+r,r-r4r/r/r/r0r[�sr[c@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/r0rd�srdc@s6eZdZdZdefdefdefgZdZe	ee
d�ZdS)�CharacteristicTwoz`
    Original Name: Characteristic-two
    Source: http://www.secg.org/sec1-v2.pdf page 101
    �m�basis�
parameters)rgrh)rarbrcN)r*r+r,r-rr`rr.�	_oid_pairrrd�
_oid_specsr/r/r/r0res
rec@s.eZdZdZdefdefgZdZee	d�Z
dS)�FieldIDz:
    Source: http://www.secg.org/sec1-v2.pdf page 100
    �
field_typerh)rlrh)r^r_N)r*r+r,r-r]rr.rirrerjr/r/r/r0rks
rkc@s,eZdZdZdefdefdeddifgZdS)�Curvez:
    Source: http://www.secg.org/sec1-v2.pdf page 104
    �a�b�seedr9TN)r*r+r,r-rrr.r/r/r/r0rm-srmc
@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-r[rkrmrYrrr.r/r/r/r0rq9srqc)@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/r0rwIsRrwc@s&eZdZdZdefdefdefgZdS)�ECDomainParametersz:
    Source: http://www.secg.org/sec1-v2.pdf page 102
    �	specified�named�implicit_caN)r*r+r,r-rqrwrZ
_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@eZdZdZdefdefdedddd�fd	edd
dd�fgZdS)�ECPrivateKeyz:
    Source: http://www.secg.org/sec1-v2.pdf page 108
    r6r@rh�explicitrT)�tag_type�tagr9r?rN)	r*r+r,r-r�rr}rZr.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
    �	algorithmrhr9T)r�rh)r�r�N)r*r+r,r-r�rr.rir�r}rjr/r/r/r0r��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
    r6�private_key_algorithmr@Z
attributesZimplicitrT)r�r�r9cCs|ddj}tttd�|S)Nr�r�)r�r�r�)rPr5rr�)rTr�r/r/r0�_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�rhzU
                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��}|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�rhr>r@r<r�r7r8)r7r8r�r�z�
                    Unable to compute public key for EC key using Implicit CA
                    parameters
                    r~rrrlr_z�
                        Unable to compute public key for EC key over a
                        characteristic two field
                        rsrnrortr)rxryrzr{r|z�
                        Unable to compute public key for EC named curve %s,
                        parameters not currently included
                        N)r�r�powrP�parsedr:rsrSrrr$�chosenrWr
rrr	r
rrZrMrKrL)
rTr��keyZ
curve_type�detailsrsZbase_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�rhrr<r=r>)r6r<r=r>r?r@r�r?N)r�r�r;r?)rTr��outputr/r/r0r�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�rhr�N)r�rSr�upperr��namerP)rTr�r��valuer/r/r0rs�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�rhr=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}tt�t�|d
���|_|jd}|dkr�|jd|7_|jS)
zU
        :return:
            The bit size of the private key, as an integer
        Nr�r@r7r�r�rhr<r�rBr�r)�	_bit_sizer�r�rPrErFrGrH)rTr'r7r/r/r0�bit_size�s




zPrivateKeyInfo.bit_sizecCstt�|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|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�)rTr�r/r/r0r?s



zPrivateKeyInfo.public_keycCs t|j|ddd�|jd��S)z\
        :return:
            A PublicKeyInfo object derived from this private key.
        r�rh)r�rh)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}|�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�rhr@r�z%d:%dr7r8r�z%d:%d:%d:%dr<r=r>r�r?rz%s:zutf-8r�r~rr�:rsrnro)
�_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�rr�r.r��_spec_callbacksr�r�r�r�rXr�r�r�propertyrsr�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
    rpZ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@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-r4r/r/r/r0r��s
r�c@s6eZdZdZdefdeddifgZdZee	e
d�ZdS)	�PublicKeyAlgorithmzd
    Original Name: AlgorithmIdentifier
    Source: https://tools.ietf.org/html/rfc5280#page-18
    r�rhr9T)r�rh)r�r�r�N)r*r+r,r-r�rr.rir�r}r�rjr/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}tttdftd�|S)Nr�)r�r�r�r�)rPr:rrZ)rTr�r/r/r0�_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�rhr?)r�rrr�rrrSr�r�r�rr��dumpr )rJr?r�Zalgor�r/r/r0r��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?ZECZanrnzj
            Only RSA public keys may be unwrapped - this key is %s %s public
            key
            N)r�r�r�rSr)rT�key_typeZa_anr/r/r0r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�rhr�N)r�rSrr�r�r�rP)rTr�r�r�r/r/r0rs#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�rhNr=rBr�r�r�r�)r�rSrr�rPrFrH)rTrhr�r/r/r0r�Es

zPublicKeyInfo.hash_algocCs |jdkr|ddj|_|jS)zO
        :return:
            A unicode string of "rsa", "dsa" or "ec"
        Nr�)r�rP)rTr/r/r0r�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?rrBr�r�r7r�r�rhr<r)	r�r�rQrPr�rErFrGrH)rTr'r7r/r/r0r�os




zPublicKeyInfo.bit_sizecCstt�|jd��S)zU
        :return:
            The byte size of the public key, as an integer
        r�)rErFrGr�)rTr/r/r0r��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�)rTr/r/r0r��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�)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}|�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�rhr�r?z%d:%dr7r8r�z%d:%d:%d:%dr<r=r>r�rz%s:zutf-8r�r~rrr�rsrnro)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�rXr�rr�rsr�r�r�r�r�r�r�r/r/r/r0r��s(
+"	r�)Nr-�
__future__rrrrr�rFZ_elliptic_curverrr	r
rrr
Z_errorsr�_typesrrrZalgosrrr�corerrrrrrrrrrrr r!r"r#�utilr$r%r&r1r3r5r:r;rArYrZr[r]r`rdrerkrmrqrwr}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