/var/opt/nydus/ops/oscrypto/__pycache__
NameSizeModeActions
asymmetric.cpython-312.pyc117610644editdlrm
errors.cpython-312.pyc34960644editdlrm
kdf.cpython-312.pyc83310644editdlrm
keys.cpython-312.pyc7080644editdlrm
symmetric.cpython-312.pyc10880644editdlrm
tls.cpython-312.pyc6220644editdlrm
trust_list.cpython-312.pyc134620644editdlrm
util.cpython-312.pyc19390644editdlrm
version.cpython-312.pyc3650644editdlrm
_asn1.cpython-312.pyc21380644editdlrm
_asymmetric.cpython-312.pyc320300644editdlrm
_cipher_suites.cpython-312.pyc222960644editdlrm
_ecdsa.cpython-312.pyc222560644editdlrm
_errors.cpython-312.pyc12870644editdlrm
_ffi.cpython-312.pyc170820644editdlrm
_int.cpython-312.pyc9780644editdlrm
_pkcs1.cpython-312.pyc210960644editdlrm
_pkcs5.cpython-312.pyc41870644editdlrm
_pkcs12.cpython-312.pyc57770644editdlrm
_rand.cpython-312.pyc14390644editdlrm
_tls.cpython-312.pyc173070644editdlrm
_types.cpython-312.pyc14140644editdlrm
__init__.cpython-312.pyc99950644editdlrm
Edit: /var/opt/nydus/ops/oscrypto/__pycache__/_asymmetric.cpython-312.pyc (32030B)
N jxhddlmZmZmZmZddlZddlZddlZddlZddl m Z m Z m Z m Z mZmZmZmZmZmZmZmZmZmZmZddlmZmZmZddlmZmZm Z m!Z!m"Z"ddl#m$Z$ddl%m&Z&dd l'm(Z(m)Z)m*Z*Gd d Z+Gd d Z,GddZ-dZ.dZ/e e!ee"edZ0dZ1dZ2ddZ3ddZ4dZ5dZ6dZ7dZ8y))unicode_literalsdivisionabsolute_importprint_functionN)CertBag Certificate DSAPrivateKey ECPrivateKey EncryptedDataEncryptedPrivateKeyInfoInteger OctetStringPfxPrivateKeyInfo PublicKeyInfo RSAPrivateKey RSAPublicKey SafeContentsunarmor)pbkdf1pbkdf2 pkcs12_kdf)aes_cbc_pkcs7_decryptdes_cbc_pkcs5_decryptrc2_cbc_pkcs5_decrypt rc4_decrypttripledes_cbc_pkcs5_decrypt)constant_compare)pretty_message)byte_clsstr_cls type_namecZeZdZdZdZdZedZedZedZ edZ y)_PrivateKeyBaseNc |jdk(r|jdjS|jdk(r\|jdd}td|d|d|d |jj |jdjd S|jd k(rM|jdj}|jdd|d<|jj |d <|Sy )a. Unwraps the private key into an asn1crypto.keys.RSAPrivateKey, asn1crypto.keys.DSAPrivateKey or asn1crypto.keys.ECPrivateKey object :return: An asn1crypto.keys.RSAPrivateKey, asn1crypto.keys.DSAPrivateKey or asn1crypto.keys.ECPrivateKey object rsa private_keydsaprivate_key_algorithm parametersrpqgversionr,r-r. public_keyr(ecr1N) algorithmasn1parsedr r1unwrap)selfparamsoutputs E/opt/nydus/tmp/pip-target-a90h98xg/lib/python/oscrypto/_asymmetric.pyr6z_PrivateKeyBase.unwrap-s >>U "99]+22 2 >>U "YY67 EF C[C[C["oo446#yy7>> "  >>T !YY}-44F#'99-D#El#SF< #'??#9#9#;F< M "c.|jjSzO :return: A unicode string of "rsa", "dsa" or "ec" r4r3r7s r:r3z_PrivateKeyBase.algorithmKyy"""r;c4|jjdSH :return: A unicode string of EC curve name rr4curver?s r:rEz_PrivateKeyBase.curveTyyq!!r;c.|jjSzS :return: The number of bits in the key, as an integer r4bit_sizer?s r:rJz_PrivateKeyBase.bit_size]yy!!!r;c.|jjSzT :return: The number of bytes in the key, as an integer r4 byte_sizer?s r:rOz_PrivateKeyBase.byte_sizefr@r;) __name__ __module__ __qualname__r4 _fingerprintr6propertyr3rErJrOr;r:r%r%(sa DL<##""""##r;r%cjeZdZdZdZdZedZedZedZ edZ edZ y)_PublicKeyBaseNcp|jdk(r|jdS|jdjS)a7 Unwraps a public key into an asn1crypto.keys.RSAPublicKey, asn1crypto.core.Integer (for DSA) or asn1crypto.keys.ECPointBitString object :return: An asn1crypto.keys.RSAPublicKey, asn1crypto.core.Integer or asn1crypto.keys.ECPointBitString object r2r1)r3r4r5r?s r:r6z_PublicKeyBase.unwrapus4 >>T !99\* *yy&---r;ch|jt|jd|_|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) N)rSr4r?s r: fingerprintz_PublicKeyBase.fingerprints/    $ ,TYY =D    r;c.|jjSr=r>r?s r:r3z_PublicKeyBase.algorithmr@r;c4|jjdSrBrDr?s r:rEz_PublicKeyBase.curverFr;c.|jjSrHrIr?s r:rJz_PublicKeyBase.bit_sizerKr;c.|jjSrMrNr?s r:rOz_PublicKeyBase.byte_sizer@r;) rPrQrRr4rSr6rTrZr3rErJrOrUr;r:rWrWpsu DL .!!"##""""##r;rWcPeZdZdZedZedZedZedZy)_CertificateBaseNc.|jjSr=)r1r3r?s r:r3z_CertificateBase.algorithm(((r;c.|jjS)rC)r1rEr?s r:rEz_CertificateBase.curves$$$r;c.|jjS)zZ :return: The number of bits in the public key, as an integer )r1rJr?s r:rJz_CertificateBase.bit_sizes'''r;c.|jjS)z[ :return: The number of bytes in the public key, as an integer )r1rOr?s r:rOz_CertificateBase.byte_sizerbr;) rPrQrRr4rTr3rErJrOrUr;r:r`r`sU D ))%%(())r;r`c|j}|dk(s|dk(r|djS|dk(rj|dd}|dj}td|d|d |d tt |d j |j |dj |d S|d k(r|dj}|dd|d<|St d |jz)a Unwraps an asn1crypto.keys.PrivateKeyInfo object into an asn1crypto.keys.RSAPrivateKey, asn1crypto.keys.DSAPrivateKey or asn1crypto.keys.ECPrivateKey. :param key_info: An asn1crypto.keys.PrivateKeyInfo object :return: One of: - asn1crypto.keys.RSAPrivateKey - asn1crypto.keys.DSAPrivateKey - asn1crypto.keys.ECPrivateKey r' rsassa_pssr(r)r*r+rr,r-r.r/r2z#Unsupported key_info.algorithm "%s")r3r5r rpownative ValueError)key_infokey_algr8r5s r:_unwrap_private_key_informs   G%7l2 &---%12<@-(//!#s "" s ""# "   $-(//'(?@N| :X=O=OO PPr;ct|tr|dj}|jdk(r#d|dj|djfz}n|jdk(r|dd}t t |d j|djj|d j}d |d j|d j|d j|jfz}n}|jd k(rn|dj}|5||j}|jdjj}d|jdz}|jd}||z }ttr|jd}tj|jSt|tr+|jdk(r1|dj}d|dj|djfz}n|jdk(rR|dj}|dd}d |d j|d j|d j|jfz}nF|jd k(r7|dj}d|jdz}|jd}||z }ttr|jd}tj|jSt!t#dt%|)a5 Returns a fingerprint used for correlating public keys and private keys :param key_object: An asn1crypto.keys.PrivateKeyInfo or asn1crypto.keys.PublicKeyInfo :raises: ValueError - when the key_object is not of the proper type ;return: A byte string fingerprint r(r'z%d:%dmoduluspublic_exponentr)r*r+r.r,z %d:%d:%d:%dr-r2r1z%s:rzutf-8r3z key_object must be an instance of the asn1crypto.keys.PrivateKeyInfo or asn1crypto.keys.PublicKeyInfo classes, not %s ) isinstancerr5r3rirrhr1r4rEencoder"hashlibsha256digestrrjr r#) key_objectload_private_keykeyto_hashr8r1public_key_objects r:rSrSs*n-'..   5 (I%%%&--!G  ! !U * 78FF s ""=)0077s """J $s ""s ""s ""!! 'G ! !T )\*11J! %5Z$@$K$K!.33LAHHOO j..q11GnnW-G z !G gw 'nnW-G~~g&--//*m,   5 (\*11CI%%%&--!G  ! !U *\*11C ,\:F#s ""s ""s "" 'G ! !T )#L188Jj..q11GnnW-G z !G gw 'nnW-G~~g&--// ^ *  r;)rc2rc4des tripledesaesct|tsttdt |d}t j d|Ct|\}}}|dk(rttd|dk(rtj|dS||dk(r$ tj|}|j|S||dk(r tj|}|d d }|Std #t$rYnwxYw tj|}|jtj|dS#t$rYwxYw#t$r Ytd wxYw) a Loads a public key from a DER or PEM-formatted file. Supports RSA, DSA and EC public keys. For RSA keys, both the old RSAPublicKey and SubjectPublicKeyInfo structures are supported. Also allows extracting a public key from an X.509 certificate. :param data: A byte string to load the public key from :raises: ValueError - when the data does not appear to contain a public key :return: An asn1crypto.keys.PublicKeyInfo object < data must be a byte string, not %s N\s*----- private keyz The data specified does not appear to be a public key or certificate, but rather a private key r' public key certificatetbs_certificatesubject_public_key_infozQThe data specified does not appear to be a known public key or certificate format)rqr! TypeErrorr r#rematch _unarmor_pemrjrwraploadrirr )datakey_typealgopkirpk parsed_certrks r: parse_publicr~s" dH %  dO    H xx d#/+D1$ } $^  5= %%dE2 28|3 $$T*C JJJ8}4 %**40K"#456OPHO h ii'    ##D)C JJ %%c51 1      h ii s6"C'=D=' C32C376D.. D:9D:= EEct|tsttdt |d}t j d|At|\}}}|dk(rttd|dk(rttd||dk(r tj|Sttd #t$rYwxYw) a@ Loads a certificate from a DER or PEM-formatted file. Supports X.509 certificates only. :param data: A byte string to load the certificate from :raises: ValueError - when the data does not appear to contain a certificate :return: An asn1crypto.x509.Certificate object rNrrz The data specified does not appear to be a certificate, but rather a private key rz The data specified does not appear to be a certificate, but rather a public key rzU The data specified does not appear to be a known certificate format ) rqr!rr r#rrrrjr r)rr_s r:parse_certificaters dH %  dO    H xx d#/(.!T } $^  | #^ 8}4 ##D) ) ^     sB99 CCc|t|tsttdt ||.t|ts ttdt |d}t j d|Bt||\}}}|dk(rttd|dk(rttd tj|}|j|S#t$rYnwxYw tj|}|d }|d j}t|||}tj|}|j|S#t$rYnwxYw tj|} | jtj| d S#t$rYnwxYw t!j|} | jtj| d S#t$rYnwxYw t#j|} | jtj| d S#t$rYnwxYwttd)a% Loads a private key from a DER or PEM-formatted file. Supports RSA, DSA and EC private keys. Works with the follow formats: - RSAPrivateKey (PKCS#1) - ECPrivateKey (SECG SEC1 V2) - DSAPrivateKey (OpenSSL) - PrivateKeyInfo (RSA/DSA/EC - PKCS#8) - EncryptedPrivateKeyInfo (RSA/DSA/EC - PKCS#8) - Encrypted RSAPrivateKey (PEM only, OpenSSL) - Encrypted DSAPrivateKey (PEM only, OpenSSL) - Encrypted ECPrivateKey (PEM only, OpenSSL) :param data: A byte string to load the private key from :param password: The password to unencrypt the private key :raises: ValueError - when the data does not appear to contain a private key, or the password is invalid :return: An asn1crypto.keys.PrivateKeyInfo object rH password must be a byte string, not %s r;rrz The data specified does not appear to be a private key, but rather a public key rz The data specified does not appear to be a private key, but rather a certificate encryption_algorithmencrypted_datar'r)r2zU The data specified does not appear to be a known private key format )rqr!rr r#rrrrjrrrir _decrypt_encrypted_datarrr r ) rpasswordrrrparsed_wrapperencryption_algorithm_infordecrypted_datar5s r: parse_privatersW6 dH %  dO    (H-N(#   xx d#/(x8!T | #^  } $^  !!$'       055d;$23I$J!'(89@@01JN\de!!.1      ##D) ""6511     ##D) ""6511     ""4( ""6400     ^  s[:"C C)(C)-AE EE6F FF6G G G $6H H'&H'ct|\}}}d}tj||}|stt d|j d}|j }|tgdvr/|j dj}d|t|||fS|j} d}| dk(rd} n | d k(rd } d }| ||fS) a3 Removes PEM-encoding from a public key, private key or certificate. If the private key is encrypted, the password will be used to decrypt it. :param data: A byte string of the PEM-encoded data :param password: A byte string of the encryption password, or None :return: A 3-element tuple in the format: (key_type, algorithm, der_bytes). The key_type will be a unicode string of "public key", "private key" or "certificate". The algorithm will be a unicode string of "rsa", "dsa" or "ec". zc^((DSA|EC|RSA) PRIVATE KEY|ENCRYPTED PRIVATE KEY|PRIVATE KEY|PUBLIC KEY|RSA PUBLIC KEY|CERTIFICATE)zx data does not seem to contain a PEM-encoded certificate, private key or public key r)zRSA PRIVATE KEYzDSA PRIVATE KEYzEC PRIVATE KEYrNzencrypted private keyzrsa public keyrr') rrrrjr groupstripsetlower_unarmor_pem_openssl_private) rr object_typeheaders der_bytes type_regex armor_type pem_headerrrs r:rrvs$'.dm#K)vJ*k2J     !!!$J ::|d}|jddk7r#|jjd\}}nd}|s|S|r$tj|j d}|j }iddd dd d d d d ddddddddddddddddddd dd dd ddddd|}tj||ddzj}|t|kDr>|tj||z|ddzjz }|t|kDr>|d|}iddd dd dd dd ddddddddddddddddddd dd dd dd d!d!d|} t| } | dk(r | ||S| |||S)"a Parses a PKCS#1 private key, or encrypted private key :param headers: A dict of "Name: Value" lines from right after the PEM header :param data: A byte string of the DER-encoded PKCS#1 private key :param password: A byte string of the password to use if the private key is encrypted :return: A byte string of the DER-encoded private key NzDEK-Info,RC4asciiz aes-128-cbczaes-128z aes-192-cbczaes-192z aes-256-cbc zaes-256r|zrc4-64zrc4-40z rc2-64-cbcz rc2-40-cbczrc2-cbcr{z des-ede3-cbczdes-ede3des3z des-ede-cbc)zdes-cbcr}rrr~r}) findrsplitbinascii unhexlifyrrrrsmd5rulen crypto_funcs) rrrenc_algo enc_iv_hexenc_ivr8enc_key_lengthenc_key enc_algo_name decrypt_funcs r:rrs"HJ FW$ ;;s r !#)<<>#7#7#< HjH  ##J$5$5g$>?~~Hr2 r 2  r  2  r ! ! a a 2 r  B !" r#$'()N,kk(VAa[0188:G 3w< '7;;w1F1QK?@GGII 3w< 'a'Gu5 u 5  u  5  u % % e e 5 u   K  !" {#$'()M* .LGT** v ..r;cnt|tsttdt ||.t|ts ttdt |d}i}i}t j |}|d}|djdk7rttd|j}|d }|r|d d d j} d ddddddd| } t| ||dj|dj| d} tt| } tj| |dj| j!} |d dj}t#| |s td|D]}|d}t|t$rt'|j||||2t|t(r6|d}|d}|dj}t+|||}t'|||||xttdt-|j/}t-|j/}t1t3||z}d}d}g}t5|dk\r,|d}||}||}|Dcgc] }||k7s ||}}|||fSt5|dkDr*t1t3|j/d}||}t5|dkDr-t1t3|j/d}||}||=t5|dkDr%t1t3|j7d }|||fScc}w)!aY Parses a PKCS#12 ANS.1 DER-encoded structure and extracts certs and keys :param data: A byte string of a DER-encoded PKCS#12 file :param password: A byte string of the password to any encrypted data :param load_private_key: A callable that will accept a byte string and return an oscrypto.asymmetric.PrivateKey object :raises: ValueError - when any of the parameters are of the wrong type or value OSError - when an error is returned by one of the OS decryption functions :return: A three-element tuple of: 1. An asn1crypto.keys.PrivateKeyInfo object 2. An asn1crypto.x509.Certificate object 3. A list of zero or more asn1crypto.x509.Certificate objects that are "extra" certificates, possibly intermediates from the cert chain rNrr; auth_safe content_typerzV Only password-protected PKCS12 files are currently supported mac_datamacdigest_algorithmr3r0@)sha1sha224rtsha384sha512 sha512_224 sha512_256mac_salt iterationscontentruzPassword provided is invalidencrypted_content_infocontent_encryption_algorithmencrypted_contentz[ Public-key-based PKCS12 files are not currently supported rrc.|jjSN)subjecthuman_friendly)cs r:z_parse_pkcs12..sAYAYr;)rx)rqr!rr r#rrrirjauthenticated_safergetattrrshmacnewcontentsrurr_parse_safe_contentsr rrkeyssortedlistrvalues)rrrwcerts private_keyspfxrrrmac_algo key_lengthmac_keyhash_mod computed_hmac stored_hmac content_inforrrrdecrypted_contentkey_fingerprintscert_fingerprintscommon_fingerprintsrxcert other_certsrZf first_keys r: _parse_pkcs12rs4 dH %  dO    (H-N(#   EL ((4.CK I ''61    //:HE?#56{CJJ      Z ' ' \ " ) )   7H-)I*>*G*GRYY[ uoh/66  {;;< <* y) g{ +  hP` a  /%,-E%F "(>?](^ % 67J K R R  78QSdfn o  !2E<Sc d^ !+,<,,./EJJL) &69J&J!KL C DK 1$)!, ;'[!).CA!{2BuQx CT;'' <14 1 1 345a8 9% 5zA~4 -.q1 Y )  5zA~T%,,.17YZ { ##Ds . L29L2c@t|trtj|}|D]}|d}t|trG|dj dk(s+|dj }|dd}|dj |t|d<_t|tr||t||<t|trF|d} |d j } t| | |} tj| } | |t| |<t|trt|||||y) a& Parses a SafeContents PKCS#12 ANS.1 structure and extracts certs and keys :param safe_contents: A byte string of ber-encoded SafeContents, or a asn1crypto.pkcs12.SafeContents parsed object :param certs: A dict to store certificates in :param keys: A dict to store keys in :param password: A byte string of the password to any encrypted data :param load_private_key: A callable that will accept a byte string and return an oscrypto.asymmetric.PrivateKey object bag_valuecert_idx509 cert_valuerrNrr) rqr!rrrrir5rSrr rr) safe_contentsrrrrwsafe_bagrrpublic_key_inforencrypted_key_bytesdecrypted_key_bytesr(s r:rrs&,-*$))-8 ![) i )#**f4 .55"&'8"9:S"T=F|=T=[=[l?D9:  > 2FOLi1AB C  #: ;(12H(I %"+,<"="D"D "9:SUhjr"s (--.ABKHSLk3CD E  < 0 E<K[ \ 1"r;c2t|j}|jdk(rr|jdk(rtt dt |j ||j|j|j}|j}||||}|S|jdk(rPt|j ||j|j|jdz}|dd}|dd}||||}|S|jdk(rt|j ||j|j|jd }|jd k(r |||}|St|j ||j|j|jd }||||}S) al Decrypts encrypted ASN.1 data :param encryption_algorithm_info: An instance of asn1crypto.pkcs5.Pkcs5EncryptionAlgorithm :param encrypted_content: A byte string of the encrypted content :param password: A byte string of the encrypted content's password :return: A byte string of the decrypted plaintext rrc5zc PBES2 encryption scheme utilizing RC5 encryption is not supported rrrrrrr|r)rencryption_cipherkdfrjr rkdf_hmackdf_saltkdf_iterationsr encryption_ivrrencryption_block_size)rrrrrr plaintextderived_outputs r:rrs" 9 K KLL!$$0 $ 6 6% ?^   % . .  % . . % 4 4 % 0 0  +88 *;VD P M # & &( 2 % . .  % . . % 4 4 % 0 01 4  !1%"% *;VD 6 3 # & &, 6 % . .  % . . % 4 4 % 0 0   % 6 6% ?$W.?@I  )22)22)88)?? F%W.?HI r;r)9 __future__rrrrrsrrr_asn1rr r r r r rrrrrrrrrrrrr symmetricrrrrrutilr_errorsr _typesr!r"r#r%rWr`rmrSrrrrrrrrrrUr;r:rsRR $,+##00E#E#PH#H#V&)&)R*QZaJ !  ,  FjR7trj0'fX/vG$T1hNr;