MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: machen (1008)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/cryptutil.pyo
�
d�bc@s�ddlZddlZddlZddlZddlZddlmZmZddl	m
Z
ddljj
Z
ddljjjZdZdefd��YZdS(i����N(tustrt
bytebuffer(t
CryptErrors6{0} cms -decrypt -inform DER -inkey {1} -in /dev/stdint	CryptUtilcBskeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZRS(cCs
||_dS(N(topenssl_cmd(tselfR((sJ/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/cryptutil.pyt__init__%scCs�|jddddddddd	d
|d|g}ytj|�WnAtjk
r�}dj|||j|j�}tj|�nXd
S(sV
        Create ssl certificate for https communication with endpoint server.
        treqs-x509s-nodess-subjs/CN=LinuxTransports-dayst730s-newkeysrsa:2048s-keyouts-outsFFailed to create {0} and {1} certificates.
[stdout]
{2}

[stderr]
{3}
N(	Rt	shellutiltrun_commandtCommandErrortformattstdouttstderrtloggerterror(Rtprv_filetcrt_filetcmdtcmd_errtmsg((sJ/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/cryptutil.pytgen_transport_cert(scCs_tjj|�s*ttjd|��n1|jdd|dg}tj|dt	�}|SdS(NsFile not foundtrsas-ins-puboutt	log_error(
tostpathtexiststIOErrorterrnotENOENTRR	R
tTrue(Rt	file_nameRtpub((sJ/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/cryptutil.pytget_pubkey_from_prv5s
cCsbtjj|�s*ttjd|��n4|jdd|ddg}tj|dt	�}|SdS(NsFile not foundtx509s-ins-pubkeys-nooutR(
RRRRRRRR	R
R(RR RR!((sJ/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/cryptutil.pytget_pubkey_from_crt=s
cCs�tjj|�s*ttjd|��nY|jdd|ddg}tj|�}|j	�j
d�djdd	�j�}|SdS(
NsFile not foundR#s-ins-fingerprints-nooutt=it:t(
RRRRRRRR	R
trstriptsplittreplacetupper(RR Rt
thumbprint((sJ/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/cryptutil.pytget_thumbprint_from_crtEs+c
Cs�tjj|�s*ttjd|��n�tjj|�sTttjd|��n�yMtj|jddd|d|d|g	|jddd	d
d|gg�Wn8tj	k
r�}t
jd||j|j
|j�nXdS(
NsFile not foundtcmss-decrypts-ins-inkeys-reciptpkcs12s-nodess	-passwordspass:s-outsBFailed to decrypt {0} (return code: {1})
[stdout]
{2}
[stderr]
{3}(RRRRRRR	trun_pipeRRRRt
returncodeR
R(Rtp7m_filettrans_prv_filettrans_cert_filetpem_filet
command_error((sJ/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/cryptutil.pytdecrypt_p7mNs!&	c
Csht|d��S}ddddd|g}ytj|d|dt�Wntjk
r]nXWdQXdS(	Ntabs
ssh-keygens-is-mtPKCS8s-fR
R(topenR	R
RR(Rt
input_filetoutput_filetfile_outR((sJ/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/cryptutil.pyt
crt_to_ssh\scCs�|jd�}g|D]}|jd�s|^q}dj|�}yYddlm}tj|�}|j|�dd}|j|j|��d}|d}|d}	t	�}
|
j
tjdt
d	���|
j
d	�|
j
tjdt
|j|	����|
j
|j|	��|
j
tjdt
|j|��d��|
j
d
�|
j
|j|��tjt|
��}td|ddd
�SWntk
r�}	td��nXdS(Ns
s----R'i����(tdecoderiis>Isssh-rsatsssh-rsa tencodingsutf-8sFailed to load pyasn1.codec.der(R)t
startswithtjointpyasn1.codec.derR?tbase64t	b64decodetdecodet
bits_to_bytest	bytearraytextendtstructtpacktlentnum_to_bytest	b64encodeRRtImportErrorR(Rtpubkeytlinestxtbase64_encodedtder_decodertder_encodedtkeytntetkeydatatkeydata_base64((sJ/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/cryptutil.pytasn1_to_sshes.(

	
(,
cCs?t�}x%|r0|j|d@�|dL}qW|j�|S(s;
        Pack number into bytes.  Retun as string.
        i�i(RItappendtreverse(Rtnumtresult((sJ/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/cryptutil.pyRNs		
cCspd}t�}d}xN|D]F}|||>B}|d}|dkr|j|�d}d}qqWt|�S(sG
        Convert an array contains bits, [0,1] to a byte array
        iiii����(RIR]tbytes(Rtbitstindext
byte_arraytcurrtbit((sJ/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/cryptutil.pyRH�s	



c
Cs�yhtj|�}tj|j|�jd�}tj|d|dtj	dt
dt
�}|jd�SWnUtjk
r�}tj
|jdd|j��n"tk
r�}td	|��nXdS(
Nt tinputRtencode_inputt
encode_outputsutf-16sopenssl cms -decrypttoutputsError decoding secret(RERFtDECRYPT_SECRET_CMDRRR)R	R
t
subprocesstSTDOUTtFalseRGRtCalledProcessErrorR1R
t	ExceptionR(Rtencrypted_passwordtprivate_keytdecodedtargsRkR6RY((sJ/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/cryptutil.pytdecrypt_secret�s*!(
t__name__t
__module__RRR"R$R-R7R>R\RNRHRv(((sJ/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/cryptutil.pyR$s		
										(RERRKtos.pathRRmtazurelinuxagent.common.futureRRt azurelinuxagent.common.exceptionRtazurelinuxagent.common.loggertcommonRt&azurelinuxagent.common.utils.shellutiltutilsR	RltobjectR(((sJ/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/cryptutil.pyt<module>s