3 L]@sddlmZmZmZddlZddlZddlZddlmZddl m Z ddl m Z m Z mZmZddZdd Zd d Zd d ZddZddZddZddZddZdS))absolute_importdivisionprint_functionN)utils)UnsupportedAlgorithm)dsaeced25519rsac Cs|jdd}t|dkr td|d}|dkr6t}n2|dkrDt}n$|dkrRt}n|d kr`t}ntd |d }ytj |}Wnt k rtd YnXt |\}}||krtd||||S)N z7Key is not in the proper format or contains extra data.rsssh-rsasssh-dssecdsa-sha2-nistp256ecdsa-sha2-nistp384ecdsa-sha2-nistp521s ssh-ed25519zKey type is not supported.z Key is not in the proper format.z:Key header and key body contain different key type values.)r rr) splitlen ValueError_load_ssh_rsa_public_key_load_ssh_dss_public_key_load_ssh_ecdsa_public_key_load_ssh_ed25519_public_keyrbase64 b64decode TypeError_ssh_read_next_string) databackend key_partskey_typeloaderZkey_body decoded_dataZinner_key_typerestr#Z/tmp/pip-install-wfra5znf/cryptography/cryptography/hazmat/primitives/serialization/ssh.pyload_ssh_public_keys2   r%cCs6t|\}}t|\}}|r$tdtj||j|S)NzKey body contains extra bytes.)_ssh_read_next_mpintrr ZRSAPublicNumbers public_key)rr!rer"nr#r#r$r8s   rc Cs`t|\}}t|\}}t|\}}t|\}}|rIN)rrstructunpack)rZstr_lenr#r#r$rts  rcCs t|\}}tj|ddd|fS)ze Reads the next mpint from the data. Currently, all mpints are interpreted as unsigned. bigF) byteordersigned)rrZint_from_bytes)rZ mpint_datar"r#r#r$r&s r&cCstjdt||S)Nz>I)r3packr)rr#r#r$_ssh_write_stringsr9cCs*tj|}tj|dd@r"d|}t|S)Nr)rZ int_to_bytesr/r0r9)valuerr#r#r$_ssh_write_mpints r=) __future__rrrrr3r/Z cryptographyrZcryptography.exceptionsrZ)cryptography.hazmat.primitives.asymmetricrrr r r%rrrrrr&r9r=r#r#r#r$s  '