+
    Dfj|                       R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIHtH	t	H
t
 ^ RIHtHt ^ RIHt ^ RIt^ RIHtHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHtHt ^ RIHtHtH t H!t!H"t" ^ RI#H$t$H%t%H&t& ^ RI'H(t(H)t) ^ RIH*t* ^ RI+H,t,H-t- ^ RI.H/t/ ^ RI0H1t1 ^ RI2H3t3H4t4 ^ RI5H6t6  ^ RI7H8t8H9t9 R]Pz                  ! 4       R]P|                  ! 4       R]P~                  ! 4       /t@RRRRRR/tA] P                  tB] P                  tC ! R R ]D4      tE ! R! R"]D4      tF ! R# R$]D4      tG ! R% R&]D4      tH ! R' R(]4      tI ! R) R*]D4      tJR+ tK ! R, R-4      tLR/R. ltMR#   ]: d    ^ RI7H;t8H<t9  Li ; i)0z0
Handling of RSA, DSA, ECDSA, and Ed25519 keys.
)annotationsN)	b64encodedecodebytesencodebytes)md5sha256)Any)NamedConstantNames)utils)InvalidSignature)default_backend)hashesserialization)dsaeced25519paddingrsa)Cipher
algorithmsmodes)load_pem_private_keyload_ssh_public_key)Literal)commonsexpy)int_to_bytes)	randbytes)	iterbytesnativeString)_mutuallyExclusiveArguments)decode_dss_signatureencode_dss_signature)decode_rfc6979_signatureencode_rfc6979_signature   ecdsa-sha2-nistp256s   ecdsa-sha2-nistp384s   ecdsa-sha2-nistp521s	   secp256r1s   nistp256s	   secp384r1s   nistp384s	   secp521r1s   nistp521c                      ] tR t^DtRtRtR# )BadKeyErrorz^
Raised when a key isn't what we expected from it.

XXX: we really need to check for bad keys
 N__name__
__module____qualname____firstlineno____doc____static_attributes__r)       8/usr/lib/python3/dist-packages/twisted/conch/ssh/keys.pyr(   r(   D   s    r1   r(   c                      ] tR t^LtRtRtR# )BadSignatureAlgorithmErrorz]
Raised when a public key signature algorithm name isn't defined for this
public key format.
r)   Nr*   r)   r1   r2   r4   r4   L       r1   r4   c                      ] tR t^StRtRtR# )EncryptedKeyErrorzV
Raised when an encrypted key is presented to fromString/fromFile without
a password.
r)   Nr*   r)   r1   r2   r7   r7   S   r5   r1   r7   c                      ] tR t^ZtRtRtR# )BadFingerPrintFormatzK
Raises when unsupported fingerprint formats are presented to fingerprint.
r)   Nr*   r)   r1   r2   r9   r9   Z   s    r1   r9   c                  6    ] tR t^`tRt]! 4       t]! 4       tRtR# )FingerprintFormatsa  
Constants representing the supported formats of key fingerprints.

@cvar MD5_HEX: Named constant representing fingerprint format generated
    using md5[RFC1321] algorithm in hexadecimal encoding.
@type MD5_HEX: L{constantly.NamedConstant}

@cvar SHA256_BASE64: Named constant representing fingerprint format
    generated using sha256[RFC4634] algorithm in base64 encoding
@type SHA256_BASE64: L{constantly.NamedConstant}
r)   N)	r+   r,   r-   r.   r/   r	   MD5_HEXSHA256_BASE64r0   r)   r1   r2   r;   r;   `   s    
 oG!OMr1   r;   c                      ] tR t^qtRtRtR# )PassphraseNormalizationErrorz
Raised when a passphrase contains Unicode characters that cannot be
normalized using the available Unicode character database.
r)   Nr*   r)   r1   r2   r?   r?   q   r5   r1   r?   c                   \        V \        4      '       dk   \        ;QJ d    R V  4       F  '       g   K   RM	  RM! R V  4       4      '       d   \        4       h\        P
                  ! RV 4      P                  R4      # V # )a  
Normalize a passphrase, which may be Unicode.

If the passphrase is Unicode, this follows the requirements of U{NIST
800-63B, section
5.1.1.2<https://pages.nist.gov/800-63-3/sp800-63b.html#memsecretver>}
for Unicode characters in memorized secrets: it applies the
Normalization Process for Stabilized Strings using NFKC normalization.
The passphrase is then encoded using UTF-8.

@type passphrase: L{bytes} or L{unicode} or L{None}
@param passphrase: The passphrase to normalize.

@return: The normalized passphrase, if any.
@rtype: L{bytes} or L{None}
@raises PassphraseNormalizationError: if the passphrase is Unicode and
cannot be normalized using the available Unicode character database.
c              3  T   "   T F  p\         P                  ! V4      R 8H  x  K   	  R# 5i)CnN)unicodedatacategory).0cs   & r2   	<genexpr>'_normalizePassphrase.<locals>.<genexpr>   s      C
1{##A&$.
s   &(TFNFKCzUTF-8)
isinstancestranyr?   rC   	normalizeencode
passphrases   &r2   _normalizePassphraserQ   x   sc    & *c"" 3C
C333C
CCC /00$$VZ8??HHr1   c                  B   ] tR t^tRt]R4R l4       t]R4R l4       t]R 4       t]R 4       t	]R 4       t
]R 4       t]R	 4       t]R
 4       t]R 4       t]R 4       t]R 4       t]R 4       t]R5R l4       t]R6R l4       t]R6R l4       t]R6R l4       t]R6R l4       tR tR R ltR R ltR tR t]P:                  3R ltR R ltR t R t!R  t"R! t#R" R# lt$R$ t%R% t&]'! R&R'.R&R(..4      R5R) l4       t(R6R* lt)R4R+ lt*R6R, lt+R7R- lt,R. t-R/ t.R6R0 R1 llt/R2 t0R3t1R# )8Keya]  
An object representing a key.  A key can be either a public or
private key.  A public key can verify a signature; a private key can
create or verify a signature.  To generate a string that can be stored
on disk, use the toString method.  If you have a private key, but want
the string representation of the public key, use Key.public().toString().
Nc                    \        VR4      ;_uu_ 4       pV P                  VP                  4       W#4      uuRRR4       #   + '       g   i     R# ; i)a  
Load a key from a file.

@param filename: The path to load key data from.

@type type: L{str} or L{None}
@param type: A string describing the format the key data is in, or
L{None} to attempt detection of the type.

@type passphrase: L{bytes} or L{None}
@param passphrase: The passphrase the key is encrypted with, or L{None}
if there is no encryption.

@rtype: L{Key}
@return: The loaded key.
rbN)open
fromStringread)clsfilenametyperP   fs   &&&& r2   fromFileKey.fromFile   s6    $ (D!!Q>>!&&(D= "!!!s    A  A	c                   \        V\        4      '       d   VP                  R4      p\        V4      pVf   V P	                  V4      pVf   \        RV: 24      h\        V RVP                  4        2R4      pVf   \        RV 24      hVP                  P                  ^8X  d   V'       d   \        R4      hV! V4      # V! W4      # )a  
Return a Key object corresponding to the string data.
type is optionally the type of string, matching a _fromString_*
method.  Otherwise, the _guessStringType() classmethod will be used
to guess a type.  If the key is encrypted, passphrase is used as
the decryption key.

@type data: L{bytes}
@param data: The key data.

@type type: L{str} or L{None}
@param type: A string describing the format the key data is in, or
L{None} to attempt detection of the type.

@type passphrase: L{bytes} or L{None}
@param passphrase: The passphrase the key is encrypted with, or L{None}
if there is no encryption.

@rtype: L{Key}
@return: The loaded key.
utf-8Nzcannot guess the type of _fromString_zno _fromString method for zkey not encrypted)
rJ   rK   rN   rQ   _guessStringTyper(   getattrupper__code__co_argcount)rY   datar[   rP   methods   &&&& r2   rW   Key.fromString   s    . dC  ;;w'D)*5
<''-D< 9$BCCTZZ\N;TB> :4&ABB??&&!+!"566$<$++r1   c                   \         P                  ! V4      w  r#VR8X  dN   \         P                  ! V^4      w  rEpV ! \        P                  ! WE4      P                  \        4       4      4      # VR8X  dg   \         P                  ! V^4      w  rgrpV ! \        P                  ! V	\        P                  ! WgVR7      R7      P                  \        4       4      4      # V\        9   dN   V ! \        P                  P                  \        V,          \         P                  ! V^4      ^,          4      4      # VR8X  d9   V P                  \         P                  ! V^4      ^,          RR7      p
RV
n        V
# VR9   dJ   \         P                  ! V4      w  rV P!                  V4      p
VP#                  R	4      '       d   RV
n        V
# \%        R
V 24      h)a  
Return a public key object corresponding to this public key blob.
The format of a RSA public key blob is::
    string 'ssh-rsa'
    integer e
    integer n

The format of a DSA public key blob is::
    string 'ssh-dss'
    integer p
    integer q
    integer g
    integer y

The format of ECDSA-SHA2-* public key blob is::
    string 'ecdsa-sha2-[identifier]'
    integer x
    integer y

    identifier is the standard NIST curve name.

The format of an Ed25519 public key blob is::
    string 'ssh-ed25519'
    string a

@type blob: L{bytes}
@param blob: The key data.

@return: A new key.
@rtype: L{twisted.conch.ssh.keys.Key}
@raises BadKeyError: if the key type (the first string) is unknown.
   ssh-rsa   ssh-dsspqgyparameter_numbers"   sk-ecdsa-sha2-nistp256@openssh.comr&   )encodedPointcurveTs   sk-ssh-unknown blob type: )   ssh-ed25519   sk-ssh-ed25519@openssh.com)r   getNSgetMPr   RSAPublicNumbers
public_keyr   r   DSAPublicNumbersDSAParameterNumbers_curveTabler   EllipticCurvePublicKeyfrom_encoded_point_fromECEncodedPoint_sk_fromEd25519Components
startswithr(   )rY   blobkeyTyperestenrn   ro   rp   rr   	keyObjectas   &&          r2   _fromString_BLOBKey._fromString_BLOB   s   D T*j dA.JA$s++A1<<_=NOPPj %||D!4A!$$3+B+BQq+Q*_./  k!))<<(&,,tQ*?*B  ;;//#\\$215, 0 I !IMEEll4(GA2215I!!*-- $	/y9::r1   c                   \         P                  ! V4      w  r#VR8X  d1   \         P                  ! V^4      w  rErgrpV P                  WEWhV	R7      # VR8X  d0   \         P                  ! V^4      w  rrrV P	                  WWVR7      # V\
        9   d   \
        V,          p\         P                  ! V^4      w  rpV\        VP                  P                  R4      ,          8w  d   \        RV: RV: 24      h\         P                  ! V4      w  rV P                  WVR7      # VR	8X  d8   \         P                  ! V^4      w  pppVR
,          pV P                  VVR7      # \        RV 24      h)a  
Return a private key object corresponding to this private key blob.
The blob formats are as follows:

RSA keys::
    string 'ssh-rsa'
    integer n
    integer e
    integer d
    integer u
    integer p
    integer q

DSA keys::
    string 'ssh-dss'
    integer p
    integer q
    integer g
    integer y
    integer x

EC keys::
    string 'ecdsa-sha2-[identifier]'
    string identifier
    string q
    integer privateValue

    identifier is the standard NIST curve name.

Ed25519 keys::
    string 'ssh-ed25519'
    string a
    string k || a


@type blob: L{bytes}
@param blob: The key data.

@return: A new key.
@rtype: L{twisted.conch.ssh.keys.Key}
@raises BadKeyError: if
    * the key type (the first string) is unknown
    * the curve name of an ECDSA key does not match the key type
rk   r   r   drn   ro   rl   rr   rp   rn   ro   xasciizECDSA curve name z does not match key type )ru   rv   privateValuerx   :N    N)krw   )r   rz   r{   _fromRSAComponents_fromDSAComponentsr   
_secToNistnamerN   r(   r   r   )rY   r   r   r   r   r   r   urn   ro   rp   rr   r   rv   	curveNamer   r   combinedr   s   &&                 r2   _fromString_PRIVATE_BLOBKey._fromString_PRIVATE_BLOB$  sd   \ T*j %+\\$%:"A!d))Aa)BB
""(,,tQ"7A!))Aa)BB#(E!'dA!6I$Juzz'8'8'ABB!!*G5  "(d!3L**L +   & !'T1 5AxA--a1-55 3G9=>>r1   c                    VP                  R4      '       d   V ! \        V\        4       4      4      # \        VP	                  4       ^,          4      pV P                  V4      # )aL  
Return a public key object corresponding to this OpenSSH public key
string.  The format of an OpenSSH public key string is::
    <key type> <base64-encoded public key blob>

@type data: L{bytes}
@param data: The key data.

@return: A new key.
@rtype: L{twisted.conch.ssh.keys.Key}
@raises BadKeyError: if the blob type is unknown.
s
   ecdsa-sha2)r   r   r   r   splitr   )rY   rg   r   s   && r2   _fromString_PUBLIC_OPENSSHKey._fromString_PUBLIC_OPENSSHo  sN      ??=))*41BCDD4::<?+##D))r1   c           	        VP                  4       P                  4       p\        RP                  V^R 4      4      pVP	                  R4      '       g   \        R4      hV\        R4      R p\        P                  ! V^4      w  rVrx\        P                  ! RVR,          4      ^ ,          p	V	^8w  d   \        R4      h\        P                  ! VR,          ^4      w  rp
VR	8w  Eda   V'       g   \        R
4      hVR9   d/   \        P                  p^p\        VR,          4      ^,          pTpM\        RV: 24      hVR8X  da   \        P                  ! V4      w  pp\        P                  ! RVR,          4      ^ ,          p\        P                   ! VVW,           VRR7      pM\        RV: 24      h\        V4      V,          ^ 8w  d   \        R4      h\#        V! VRV 4      \$        P&                  ! VWV,            4      \)        4       R7      P+                  4       pVP-                  V4      VP/                  4       ,           pMVR	8w  d   \        RV: R24      hTp\        P                  ! RVR,          4      ^ ,          p\        P                  ! RVR,          4      ^ ,          pVV8w  d   \        RVV3,          4      hV P1                  VR,          4      # )a  
Return a private key object corresponding to this OpenSSH private key
string, in the "openssh-key-v1" format introduced in OpenSSH 6.5.

The format of an openssh-key-v1 private key string is::
    -----BEGIN OPENSSH PRIVATE KEY-----
    <base64-encoded SSH protocol string>
    -----END OPENSSH PRIVATE KEY-----

The SSH protocol string is as described in
U{PROTOCOL.key<https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.key>}.

@type data: L{bytes}
@param data: The key data.

@type passphrase: L{bytes} or L{None}
@param passphrase: The passphrase the key is encrypted with, or L{None}
if it is not encrypted.

@return: A new key.
@rtype: L{twisted.conch.ssh.keys.Key}
@raises BadKeyError: if
    * a passphrase is provided for an unencrypted key
    * the SSH protocol encoding is incorrect
@raises EncryptedKeyError: if
    * a passphrase is not provided for an encrypted key
r1      openssh-key-v1 z"unknown OpenSSH private key formatN!L:N   NzDonly OpenSSH private key files containing a single key are supportedr   NN   none0Passphrase must be provided for an encrypted key:      Nzunknown encryption type    bcryptT)ignore_few_roundszunknown KDF type zbad paddingbackendzprivate key specifies KDF z but no cipher:r      Nz#check values do not match: %d != %d:r   NN)s
   aes128-ctrs
   aes192-ctr
   aes256-ctr)strip
splitlinesr   joinr   r(   lenr   rz   structunpackr7   r   AESintbcryptkdfr   r   CTRr   	decryptorupdatefinalizer   )rY   rg   rP   lineskeyListcipherr   
kdfOptionsr   r   _encPrivKeyListalgorithmClass	blockSizekeySizeivSizesaltroundsdecKeyr   privKeyListcheck1check2s   &&&                    r2   _fromPrivateOpenSSH_v1Key._fromPrivateOpenSSH_v1  s   : 

'')chhuQr{34!!"566BCC#1245(.Wa(@%ZMM$R)!,6- 
  &||DHa81W'I  FF!+	fSk*a/"!$<VJ"GHHi#\\*5
dtT"X6q9$&* "$5cW"=>>N#i/A5!-00vhw/0		&V+;<=') ik	 
 $**>:Y=O=O=QQKg~!GJL  )Kt[_5a8t[%56q9VCvvFVVWW++KO<<r1   c                ,   VP                  4       P                  4       pV^ ,          ^R pV'       g   RpVR9   d    \        W\        4       4      pT ! T4      # \        RV 24      h  \         d    \        R4      h\         d    \        R4      hi ; i)a  
Return a private key object corresponding to this OpenSSH private key
string, in the old PEM-based format.

The format of a PEM-based OpenSSH private key string is::
    -----BEGIN <key type> PRIVATE KEY-----
    [Proc-Type: 4,ENCRYPTED
    DEK-Info: DES-EDE3-CBC,<initialization value>]
    <base64-encoded ASN.1 structure>
    ------END <key type> PRIVATE KEY------

The ASN.1 structure of a RSA key is::
    (0, n, e, d, p, q)

The ASN.1 structure of a DSA key is::
    (0, p, q, g, y, x)

The ASN.1 structure of a ECDSA key is::
    (ECParameters, OID, NULL)

@type data: L{bytes}
@param data: The key data.

@type passphrase: L{bytes} or L{None}
@param passphrase: The passphrase the key is encrypted with, or L{None}
if it is not encrypted.

@return: A new key.
@rtype: L{twisted.conch.ssh.keys.Key}
@raises BadKeyError: if
    * a passphrase is provided for an unencrypted key
    * the ASN.1 encoding is incorrect
@raises EncryptedKeyError: if
    * a passphrase is not provided for an encrypted key
Nr   z&Failed to decode key (Bad Passphrase?)unknown key type )s   ECs   RSAs   DSA)r   r   r   r   	TypeErrorr7   
ValueErrorr(   )rY   rg   rP   r   kindkeys   &&&   r2   _fromPrivateOpenSSH_PEMKey._fromPrivateOpenSSH_PEM  s    J 

'')Qx3 J**L*4_=NO s8O 1$899  'F   L!"JKKLs   A' 'BBc                    VP                  4       P                  4       ^ ,          ^R R8X  d   V P                  W4      # V P                  W4      # )ax  
Return a private key object corresponding to this OpenSSH private key
string.  If the key is encrypted, passphrase MUST be provided.
Providing a passphrase for an unencrypted key is an error.

@type data: L{bytes}
@param data: The key data.

@type passphrase: L{bytes} or L{None}
@param passphrase: The passphrase the key is encrypted with, or L{None}
if it is not encrypted.

@return: A new key.
@rtype: L{twisted.conch.ssh.keys.Key}
@raises BadKeyError: if
    * a passphrase is provided for an unencrypted key
    * the encoding is incorrect
@raises EncryptedKeyError: if
    * a passphrase is not provided for an encrypted key
s   OPENSSHr   )r   r   r   r   )rY   rg   rP   s   &&&r2   _fromString_PRIVATE_OPENSSHKey._fromString_PRIVATE_OPENSSH  sK    , ::<""$Q'3/:=--d?? ..t@@r1   c                2   \         P                  ! \        V^R 4      4      pV^ ,          R8X  g   Q h/ pV^,          R,           F8  w  rA\        P                  ! \        P
                  ! V4      4      ^ ,          W4&   K:  	  V^,          ^ ,          R8X  d2   V P                  VR,          VR,          VR,          VR,          R7      # V^,          ^ ,          R	8X  d"   V P                  VR
,          VR,          R7      # \        RV^,          ^ ,           24      h)a  
Return a public key corresponding to this LSH public key string.
The LSH public key string format is::
    <s-expression: ('public-key', (<key type>, (<name, <value>)+))>

The names for a RSA (key type 'rsa-pkcs1-sha1') key are: n, e.
The names for a DSA (key type 'dsa') key are: y, g, p, q.

@type data: L{bytes}
@param data: The key data.

@return: A new key.
@rtype: L{twisted.conch.ssh.keys.Key}
@raises BadKeyError: if the key type is unknown

   public-key   NN   dsa   y   g   p   q)rr   rp   rn   ro      rsa-pkcs1-sha1   n   e)r   r   unknown lsh key type r   )	r   parser   r   r{   NSr   r   r(   rY   rg   sexpkdr   s   &&   r2   _fromString_PUBLIC_LSHKey._fromString_PUBLIC_LSH3  s    " {{;tAbz23Aw-'''q'"++JD||FIIdO4Q7BH &71:))T(bh"T(bh *   !WQZ,,))BtH4)AA 5d1gaj\BCCr1   c                6   \         P                  ! V4      pV^ ,          R8X  g   Q h/ pV^,          R,           F8  w  rA\        P                  ! \        P                  ! V4      4      ^ ,          W4&   K:  	  V^,          ^ ,          R8X  dZ   \        V4      ^8X  g   Q \        V4      4       hV P                  VR,          VR,          VR,          VR,          VR,          R	7      # V^,          ^ ,          R
8X  d   \        V4      ^8X  g   Q \        V4      4       hVR,          VR,          8  d   VR,          VR,          uVR&   VR&   V P                  VR,          VR,          VR,          VR,          VR,          R7      # \        RV^,          ^ ,           24      h)a  
Return a private key corresponding to this LSH private key string.
The LSH private key string format is::
    <s-expression: ('private-key', (<key type>, (<name>, <value>)+))>

The names for a RSA (key type 'rsa-pkcs1-sha1') key are: n, e, d, p, q.
The names for a DSA (key type 'dsa') key are: y, g, p, q, x.

@type data: L{bytes}
@param data: The key data.

@return: A new key.
@rtype: L{twisted.conch.ssh.keys.Key}
@raises BadKeyError: if the key type is unknown
   private-keyr   r   r   r   r   r      xr   	   rsa-pkcs1r   r      dr   r   )	r   r   r   r{   r   r   r   r   r(   r   s   &&   r2   _fromString_PRIVATE_LSHKey._fromString_PRIVATE_LSHS  sg   " {{4 Aw.(((q'"++JD||FIIdO4Q7BH &71:r7a<(R(<))T(bh"T(bh"T( *   !WQZ<'r7a<(R(<$x"T("%'Xr$x"4"T())T(bh"T(bh"T( *  
  5d1gaj\BCCr1   c           	        \         P                  ! V4      w  r!VR8X  d   \         P                  ! V4      w  r1\         P                  ! V4      w  rA\         P                  ! V4      w  rQ\         P                  ! V4      w  ra\         P                  ! V4      w  rqV P                  WeW4VR7      # VR8X  d   \         P                  ! V4      w  r\         P                  ! V4      w  r\         P                  ! V4      w  r\         P                  ! V4      w  r\         P                  ! V4      w  r1\         P                  ! V4      w  rAV P	                  WWWKR7      # \        RV 24      h)a'  
Return a private key object corresponsing to the Secure Shell Key
Agent v3 format.

The SSH Key Agent v3 format for a RSA key is::
    string 'ssh-rsa'
    integer e
    integer d
    integer n
    integer u
    integer p
    integer q

The SSH Key Agent v3 format for a DSA key is::
    string 'ssh-dss'
    integer p
    integer q
    integer g
    integer y
    integer x

@type data: L{bytes}
@param data: The key data.

@return: A new key.
@rtype: L{twisted.conch.ssh.keys.Key}
@raises BadKeyError: if the key type (the first string) is unknown
rl   r   rk   )r   r   r   rn   ro   r   r   )r   rz   r{   r   r   r(   )rY   rg   r   rn   ro   rp   rr   r   r   r   r   r   s   &&          r2   _fromString_AGENTV3Key._fromString_AGENTV3y  s   < T*j ll4(GAll4(GAll4(GAll4(GAll4(GA))Aa)BB
"ll4(GAll4(GAll4(GAll4(GAll4(GAll4(GA))Aa)GG 1';<<r1   c                T   VP                  R4      '       g   VP                  R4      '       d   R# VP                  R4      '       g   VP                  R4      '       d   \        R4      hVP                  R4      '       g   VP                  R4      '       d   R# VP                  R	4      '       d   R
# VP                  R4      '       d   R# VP                  R4      '       d   R# VP                  R4      '       g]   VP                  R4      '       gF   VP                  R4      '       g/   VP                  R4      '       g   VP                  R4      '       dQ   \        P                  ! V4      w  r#^ pV'       d$   V^,          p\        P                  ! V4      w  r#K+  V^8  d   R# R# R# )zz
Guess the type of key in data.  The types map to _fromString_*
methods.

@type data: L{bytes}
@param data: The key data.
s   ssh-   ecdsa-sha2-public_opensshs   sk-ecdsa-sha2-nistp256-cert-v01s   sk-ssh-ed25519-cert-v01z(certificate based keys are not supporteds   sk-ecdsa-sha2-nistp256s   sk-ssh-ed25519s
   -----BEGINprivate_openssh   {
public_lsh   (private_lshs      ssh-s
      ecdsa-s      ssh-ed25519s&      "sk-ecdsa-sha2-nistp256@openssh.coms      sk-ssh-ed25519@openssh.comagentv3r   N)r   r(   r   rz   r{   )rY   rg   ignoredr   counts   &&   r2   rb   Key._guessStringType  sO    ??7##t~'F'F# ??=>>$//&C
 C
 HII??455:
 :
 $??=))$??4  ??4    OO344899=>>QRRLMM"LL.MGE
 &T 2qy  Nr1   c                `   \         P                  ! W!R7      pVf   VP                  \        4       4      pMr\         P                  ! VVV\         P
                  ! W44      \         P                  ! W54      \         P                  ! WE4      VR7      p	V	P                  \        4       4      pV ! V4      # )aL  
Build a key from RSA numerical components.

@type n: L{int}
@param n: The 'n' RSA variable.

@type e: L{int}
@param e: The 'e' RSA variable.

@type d: L{int} or L{None}
@param d: The 'd' RSA variable (optional for a public key).

@type p: L{int} or L{None}
@param p: The 'p' RSA variable (optional for a public key).

@type q: L{int} or L{None}
@param q: The 'q' RSA variable (optional for a public key).

@type u: L{int} or L{None}
@param u: The 'u' RSA variable. Ignored, as its value is determined by
p and q.

@rtype: L{Key}
@return: An RSA key constructed from the values as given.
)r   r   )rn   ro   r   dmp1dmq1iqmppublic_numbers)	r   r|   r}   r   RSAPrivateNumbersrsa_crt_dmp1rsa_crt_dmq1rsa_crt_iqmpprivate_key)
rY   r   r   r   rn   ro   r   publicNumbersr   privateNumberss
   &&&&&&&   r2   r   Key._fromRSAComponents  s    6 ,,q69%001BCI 22%%a+%%a+%%a+,N '22?3DEI9~r1   c           	     
   \         P                  ! V\         P                  ! W#VR7      R7      pVf   VP                  \	        4       4      pM0\         P
                  ! WVR7      pVP                  \	        4       4      pV ! V4      # )a  
Build a key from DSA numerical components.

@type y: L{int}
@param y: The 'y' DSA variable.

@type p: L{int}
@param p: The 'p' DSA variable.

@type q: L{int}
@param q: The 'q' DSA variable.

@type g: L{int}
@param g: The 'g' DSA variable.

@type x: L{int} or L{None}
@param x: The 'x' DSA variable (optional for a public key)

@rtype: L{Key}
@return: A DSA key constructed from the values as given.
rm   rq   )r   r  )r   r~   r   r}   r   DSAPrivateNumbersr  )	rY   rr   rn   ro   rp   r   r  r   r  s	   &&&&&&   r2   r   Key._fromDSAComponents  sm    . ,,3#:#:Qq#I
 9%001BCI 22QUN&22?3DEI9~r1   c                    \         P                  ! W\        V,          R7      pVf   VP                  \	        4       4      pM0\         P
                  ! WER7      pVP                  \	        4       4      pV ! V4      # )a[  
Build a key from EC components.

@param x: The affine x component of the public point used for verifying.
@type x: L{int}

@param y: The affine y component of the public point used for verifying.
@type y: L{int}

@param curve: NIST name of elliptic curve.
@type curve: L{bytes}

@param privateValue: The private value.
@type privateValue: L{int}
)r   rr   rv   )private_valuer  )r   EllipticCurvePublicNumbersr   r}   r   EllipticCurvePrivateNumbersr  )rY   r   rr   rv   r   r  r   r  s   &&&&&   r2   _fromECComponentsKey._fromECComponents/  sk    $ 55K.
 %001BCI;;*N '22?3DEI9~r1   c                    Vf-   \         P                  P                  \        V,          V4      pM+\         P                  ! V\        V,          \        4       4      pV ! V4      # )a  
Build a key from an EC encoded point.

@param encodedPoint: The public point encoded as in SEC 1 v2.0
section 2.3.3.
@type encodedPoint: L{bytes}

@param curve: NIST name of elliptic curve.
@type curve: L{bytes}

@param privateValue: The private value.
@type privateValue: L{int}
)r   r   r   r   derive_private_keyr   )rY   ru   rv   r   r   s   &&&& r2   r   Key._fromECEncodedPointO  sW      11DDE"LI --k%0/2CI 9~r1   c                    \         e	   \        f   \        R4      hVf   \         P                  V4      pM\        P	                  V4      pV ! V4      # )zBuild a key from Ed25519 components.

@param a: The Ed25519 public key, as defined in RFC 8032 section
    5.1.5.
@type a: L{bytes}

@param k: The Ed25519 private key, as defined in RFC 8032 section
    5.1.5.
@type k: L{bytes}
z)Ed25519 keys not supported on this system)Ed25519PublicKeyEd25519PrivateKeyr(   from_public_bytesfrom_private_bytes)rY   r   r   r   s   &&& r2   r   Key._fromEd25519Componentsk  sK     #'8'@IJJ9(::1=I)<<Q?I9~r1   c                     Wn         RV n        R# )z
Initialize with a private or public
C{cryptography.hazmat.primitives.asymmetric} key.

@param keyObject: Low level key.
@type keyObject: C{cryptography.hazmat.primitives.asymmetric} key.
FN
_keyObjectr   )selfr   s   &&r2   __init__Key.__init__  s     $r1   c                    V ^8  d   QhRRRR/# )   otherobjectreturnboolr)   )formats   "r2   __annotate__Key.__annotate__  s     " "F "t "r1   c                    \        V\        4      '       dK   V P                  4       VP                  4       8H  ;'       d"    V P                  4       VP                  4       8H  # \        # )z>
Return True if other represents an object with the same key.
)rJ   rS   r[   rg   NotImplemented)r.  r3  s   &&r2   __eq__
Key.__eq__  sG     eS!!99;%**,.NN499;%**,3NN!!r1   c                   V ^8  d   QhRR/# )r2  r5  rK   r)   )r7  s   "r2   r8  r9    s     *$ *$# *$r1   c                :   V P                  4       R8X  d   V P                  4       pVR,          P                  R4      pV P                  4       '       d   RVRR  R2pM	RVRR  R2p\	        VP                  4       4       F)  w  rEVR8X  d   VRV 2,          pK  VR	V R
V 2,          pK+  	  VR,           # R\        V P                  4       4      : RV P                  4       ;'       d    R;'       g    R: RV P                  4       : R2.p\	        V P                  4       P                  4       4       F  w  rEVP                  RV R24       V P                  4       R8X  d   TM\        P                  ! V4      R,          pV'       g   KX  VR,          pVR,          pRp	\        V4       F  p
V	\        V
4      R R2,           p	K  	  \        V4      ^8  d   V	RR p	VP                  RV	,           4       Ku  	  VR,          R,           VR&   R	P                  V4      # )z0
Return a pretty representation of this object.
ECrv   r`   z<Elliptic Curve Public Key (Nz bits)z<Elliptic Curve Private Key (z	
curve:
	
z:
	z>
< z
Public KeyzPrivate Keyz (zattr :Ed25519r   :N   N:rF  NN 02x	>r   )r[   rg   decodeisPublicsorteditemsr    sizeappendr   MPr   ordr   r   )r.  rg   r   outr   vr   bymorF   s   &          r2   __repr__Key.__repr__  s    99;$99;D=''0D}}4T"#YKvF5d23i[Gtzz|,<\$00CRs%s++C	 - ; ( !-MMO44EEEIIK	E tyy{0023uQCq\*))+2Q		!R8Hb3ACBA&q\3q6#,a 00 *1v{crFLL* 4 b	CE"I99U##r1   c                    \        V P                  \        P                  \        P
                  \        P                  \        P                  34      # )zT
Check if this instance is a public key.

@return: C{True} if this is a public key.
)
rJ   r-  r   RSAPublicKeyr   DSAPublicKeyr   r   r   r&  r.  s   &r2   rM  Key.isPublic  sA     OO    ))((	
 	
r1   c                x    V P                  4       '       d   V # \        V P                  P                  4       4      # )z
Returns a version of this key containing only the public key data.
If this is a public key, this may or may not be the same object
as self.

@rtype: L{Key}
@return: A public key.
)rM  rS   r-  r}   r^  s   &r2   public
Key.public  s,     ==??Kt11344r1   c           
        V\         P                  J d:   \        \        \	        V P                  4       4      P                  4       4      4      # V\         P                  J dm   \        RP                  \        \        V P                  4       4      P                  4       4       Uu. uF  p\        P                  ! V4      NK  	  up4      4      # \        RV 24      hu upi )a  
The fingerprint of a public key consists of the output of the
message-digest algorithm in the specified format.
Supported formats include L{FingerprintFormats.MD5_HEX} and
L{FingerprintFormats.SHA256_BASE64}

The input to the algorithm is the public key data as specified by [RFC4253].

The output of sha256[RFC4634] algorithm is presented to the
user in the form of base64 encoded sha256 hashes.
Example: C{US5jTUa0kgX5ZxdqaGF0yGRu8EgKXHNmoT8jHKo1StM=}

The output of the MD5[RFC1321](default) algorithm is presented to the user as
a sequence of 16 octets printed as hexadecimal with lowercase letters
and separated by colons.
Example: C{c1:b1:30:29:d7:b8:de:6c:97:77:10:d7:46:41:63:87}

@param format: Format for fingerprint generation. Consists
    hash function and representation format.
    Default is L{FingerprintFormats.MD5_HEX}

@since: 8.2

@return: the user presentation of this L{Key}'s fingerprint, as a
string.

@rtype: L{str}
   :z Unsupported fingerprint format: )r;   r=   r    r   r   r   digestr<   r   r   r   binasciihexlifyr9   )r.  r7  r   s   && r2   fingerprintKey.fingerprint  s    : '555	&*=*D*D*F GHH)111		2;C		<L<S<S<U2VW2VQX%%a(2VW  ')I&'RSS	 Xs   $Cc                   V ^8  d   QhRR/# )r2  r5  z&Literal['RSA', 'DSA', 'EC', 'Ed25519']r)   )r7  s   "r2   r8  r9    s     O O< Or1   c                   \        V P                  \        P                  \        P                  34      '       d   R# \        V P                  \
        P                  \
        P                  34      '       d   R# \        V P                  \        P                  \        P                  34      '       d   R# \        V P                  \        P                  \        P                  34      '       d   R# \        RV P                  : 24      h)z
Return the type of the object we wrap.  Currently this can only be
'RSA', 'DSA', 'EC', or 'Ed25519'.

@rtype: L{str}
@raises RuntimeError: If the object type is unknown.
RSADSAr@  rE  zunknown type of object: )rJ   r-  r   r\  RSAPrivateKeyr   r]  DSAPrivateKeyr   r   EllipticCurvePrivateKeyr   r&  r'  RuntimeErrorr^  s   &r2   r[   Key.type  s     doo(8(8#:K:K'LMM#*:*:C<M<M)NOOOOb779S9ST
 
 OOg668Q8QR
 
 !9$//9LMNNr1   c                >   V P                   '       d   V P                  4       R8X  d   R# R# V P                  4       R8X  dB   R\        V P                  P                  P
                  P                  R4      ,          ,           # RRRR	R
R/V P                  4       ,          # )a  
Get the type of the object we wrap as defined in the SSH protocol,
defined in RFC 4253, Section 6.6 and RFC 8332, section 4 (this is a
public key format name, not a public key algorithm name). Currently
this can only be b'ssh-rsa', b'ssh-dss', b'ecdsa-sha2-[identifier]'
or b'ssh-ed25519'.

identifier is the standard NIST curve name

@return: The key type format.
@rtype: L{bytes}
r@  rt   ry   r  r   rl  rk   rm  rl   rE  rx   )r   r[   r   r-  rv   r   rN   r^  s   &r2   sshTypeKey.sshType  s     888yy{d"<
 199;$DOO,A,A,F,F,M,Mg,V!WW
 ::~
 ))+	 	r1   c                V    V P                  4       R8X  d   . RO# V P                  4       .# )z
Get the public key signature algorithms supported by this key.

@return: A list of supported public key signature algorithm names.
@rtype: L{list} of L{bytes}
rl  )   rsa-sha2-512   rsa-sha2-256rk   )r[   rt  r^  s   &r2   supportedSignatureAlgorithms Key.supportedSignatureAlgorithms@  s'     99;%AALLN##r1   c           	     P   V P                  4       R8X  dt   WP                  4       8X  d^   V P                  4       pVR8:  d   \        P                  ! 4       # VR8:  d   \        P
                  ! 4       # \        P                  ! 4       # R# V P                  4       R8X  d   \        P                  ! 4       # R\        P                  ! 4       R\        P                  ! 4       R\        P                  ! 4       R	\        P                  ! 4       /P                  V P                  4       V34      # )
z
Return a hash algorithm for this key type given an SSH signature
algorithm name, or L{None} if no such hash algorithm is defined for
this key type.
r@     i  NrE  )rl  rk   )rl  rx  )rl  rw  )rm  rl   )	r[   rt  rP  r   SHA256SHA384SHA512SHA1get)r.  signatureTyper   s   && r2   _getHashAlgorithmKey._getHashAlgorithmL  s     99;$.))+c>!==?*^!==?*!==?*99;)#==?"  $fmmo$fmmo	

 #tyy{M*
+	,r1   c                    V P                   f   ^ # V P                  4       R8X  d!   V P                   P                  P                  # V P                  4       R8X  d   R# V P                   P                  # )zV
Return the size of the object we wrap.

@return: The size of the key.
@rtype: L{int}
r@  rE  r|  )r-  r[   rv   key_sizer^  s   &r2   rP  Key.sizei  sV     ??"YY[D ??((111YY[I%'''r1   c                   V ^8  d   QhRR/# )r2  r5  zdict[str, Any]r)   )r7  s   "r2   r8  r9  x  s     JJ JJn JJr1   c                	   \        V P                  \        P                  4      '       d5   V P                  P	                  4       pRVP
                  RVP                  /# \        V P                  \        P                  4      '       d   V P                  P                  4       pRVP                  P
                  RVP                  P                  RVP                  RVP                  RVP                  R\        P                  ! VP                  VP                  4      /# \        V P                  \        P                  4      '       dk   V P                  P	                  4       pRVP                  RVP                   P"                  RVP                   P                  RVP                   P                  /# \        V P                  \        P$                  4      '       d   V P                  P                  4       pR	VP&                  RVP                  P                  RVP                  P                   P"                  RVP                  P                   P                  RVP                  P                   P                  /# \        V P                  \(        P*                  4      '       dE   V P                  P	                  4       pR	VP&                  RVP                  R
V P-                  4       /# \        V P                  \(        P.                  4      '       de   V P                  P                  4       pR	VP                  P&                  RVP                  P                  RVP0                  R
V P-                  4       /# \        V P                  \2        P4                  4      '       dO   RV P                  P7                  \8        P:                  P<                  \8        P>                  P<                  4      /# \        V P                  \2        P@                  4      '       d   RV P                  PC                  4       P7                  \8        P:                  P<                  \8        P>                  P<                  4      RV P                  PE                  \8        P:                  P<                  \8        PF                  P<                  \8        PH                  ! 4       4      /# \K        RV P                   24      h)zG
Return the values of the public key as a dictionary.

@rtype: L{dict}
r   r   r   rn   ro   r   rr   rp   r   rv   r   r   r   zUnexpected key type: )&rJ   r-  r   r\  r  r   r   rn  private_numbersr   rn   ro   r  r   r]  rr   rs   rp   ro  r   r   r   rt  rp  r  r   r&  public_bytesr   EncodingRawPublicFormatr'  r}   private_bytesPrivateFormatNoEncryptionrq  )r.  rsa_pub_numbersrsa_priv_numbersdsa_pub_numbersdsa_priv_numbersec_pub_numbersec_priv_numberss   &      r2   rg   Key.datax  s    doos'7'788"oo<<>O_&&_&&  ):):;;#>>@%4466%4466%''%''%''S%%&6&8&8:J:L:LM  )9)9::"oo<<>O_&&_6688_6688_6688	  ):):;;#>>@%''%4466%44FFHH%44FFHH%44FFHH  )B)BCC!__;;=N^%%^%% 
 )C)CDD"oo==?O_3355_3355 = =	  )A)ABBT__11!**..0J0J0N0N 
 )B)BCCT__//1>>!**..0J0J0N0N T__22!**..!//33!..0		 	 !6t6GHIIr1   c                   V P                  4       pV P                  4       pVR8X  d[   \        P                  ! R4      \        P                  ! VR,          4      ,           \        P                  ! VR,          4      ,           # VR8X  d   \        P                  ! R4      \        P                  ! VR,          4      ,           \        P                  ! VR,          4      ,           \        P                  ! VR	,          4      ,           \        P                  ! VR
,          4      ,           # VR8X  d   V P
                  P                  P                  ^,           ^,          p\        P                  ! VR,          4      \        P                  ! VR,          RR 4      ,           \        P                  ! R\        P                  ! VR,          V4      ,           \        P                  ! VR
,          V4      ,           4      ,           # VR8X  d9   \        P                  ! R4      \        P                  ! VR,          4      ,           # \        RV 24      h)a  
Return the public key blob for this key. The blob is the
over-the-wire format for public keys.

SECSH-TRANS RFC 4253 Section 6.6.

RSA keys::
    string 'ssh-rsa'
    integer e
    integer n

DSA keys::
    string 'ssh-dss'
    integer p
    integer q
    integer g
    integer y

EC keys::
    string 'ecdsa-sha2-[identifier]'
    integer x
    integer y

    identifier is the standard NIST curve name

Ed25519 keys::
    string 'ssh-ed25519'
    string a

@rtype: L{bytes}
rl  rk   r   r   rm  rl   rn   ro   rp   rr   r@  rv   N   r   rE  rx   r   unknown key type: )r[   rg   r   r   rR  r-  rv   r  r   r   r(   )r.  r[   rg   
byteLengths   &   r2   r   Key.blob  s   @ yy{yy{5=99Z(699T#Y+??&))DQTIBVVVU]		*%))DI&'))DI&' ))DI&' ))DI&	' T\////881<BJ		$w-())DM"#./0))((cJ?@((cJ?@ Y99^,vyyc/CCC 24&9::r1   c                   V P                  4       pV P                  4       pVR8X  Ed   \        P                  ! VR,          VR,          4      p\        P
                  ! R4      \        P                  ! VR,          4      ,           \        P                  ! VR,          4      ,           \        P                  ! VR,          4      ,           \        P                  ! V4      ,           \        P                  ! VR,          4      ,           \        P                  ! VR,          4      ,           # VR8X  d   \        P
                  ! R	4      \        P                  ! VR,          4      ,           \        P                  ! VR,          4      ,           \        P                  ! VR
,          4      ,           \        P                  ! VR,          4      ,           \        P                  ! VR,          4      ,           # VR8X  d   V P                  P                  4       P                  \        P                  P                  \        P                  P                  4      p\        P
                  ! VR,          4      \        P
                  ! VR,          RR 4      ,           \        P
                  ! V4      ,           \        P                  ! VR,          4      ,           # VR8X  di   \        P
                  ! R4      \        P
                  ! VR,          4      ,           \        P
                  ! VR,          VR,          ,           4      ,           # \        RV 24      h)aI  
Return the private key blob for this key. The blob is the
over-the-wire format for private keys:

Specification in OpenSSH PROTOCOL.agent

RSA keys::

    string 'ssh-rsa'
    integer n
    integer e
    integer d
    integer u
    integer p
    integer q

DSA keys::

    string 'ssh-dss'
    integer p
    integer q
    integer g
    integer y
    integer x

EC keys::

    string 'ecdsa-sha2-[identifier]'
    integer x
    integer y
    integer privateValue

    identifier is the NIST standard curve name.

Ed25519 keys::

    string 'ssh-ed25519'
    string a
    string k || a
rl  rn   ro   rk   r   r   r   rm  rl   rp   rr   r   r@  rv   Nr   rE  rx   r   r   r  r  )r[   rg   r   r  r   r   rR  r-  r}   r  r   r  X962r  UncompressedPointr(   )r.  r[   rg   r  encPubs   &    r2   privateBlobKey.privateBlob   sZ   R yy{yy{5=##DItCy9D		*%))DI&'))DI&' ))DI&' ))D/	"
 ))DI&' ))DI&' U]		*%))DI&'))DI&' ))DI&' ))DI&	'
 ))DI&' T\__//1>>&&++**<<F
 		$w-())DM"#./0))F#$ ))D012 Y		.)))DI&'))DIS	123  24&9::r1   extracommentrP   c                R   Ve9   \         P                  ! R\        ^R7       V P                  4       '       d   TpMTp\	        V\
        4      '       d   VP                  R4      p\        V4      p\        V RVP                  4        2R4      pVf   \        RV 24      hV! W4VR7      # )aB  
Create a string representation of this key.  If the key is a private
key and you want the representation of its public key, use
C{key.public().toString()}.  type maps to a _toString_* method.

@param type: The type of string to emit.  Currently supported values
    are C{'OPENSSH'}, C{'LSH'}, and C{'AGENTV3'}.
@type type: L{str}

@param extra: Any extra data supported by the selected format which
    is not part of the key itself.  For public OpenSSH keys, this is
    a comment.  For private OpenSSH keys, this is a passphrase to
    encrypt with.  (Deprecated since Twisted 20.3.0; use C{comment}
    or C{passphrase} as appropriate instead.)
@type extra: L{bytes} or L{unicode} or L{None}

@param subtype: A subtype of the requested C{type} to emit.  Only
    supported for private OpenSSH keys, for which the currently
    supported subtypes are C{'PEM'} and C{'v1'}.  If not given, an
    appropriate default is used.
@type subtype: L{str} or L{None}

@param comment: A comment to include with the key.  Only supported
    for OpenSSH keys.

    Present since Twisted 20.3.0.

@type comment: L{bytes} or L{unicode} or L{None}

@param passphrase: A passphrase to encrypt the key with.  Only
    supported for private OpenSSH keys.

    Present since Twisted 20.3.0.

@type passphrase: L{bytes} or L{unicode} or L{None}

@rtype: L{bytes}
NzThe 'extra' argument to twisted.conch.ssh.keys.Key.toString was deprecated in Twisted 20.3.0; use 'comment' or 'passphrase' instead.)
stacklevelr`   
_toString_r  )subtyper  rP   )warningswarnDeprecationWarningrM  rJ   rK   rN   rQ   rc   rd   r(   )r.  r[   r  r  r  rP   rh   s   &&&&&& r2   toStringKey.toStringS  s    Z MMI # }}"
gs##nnW-G)*5
DJJL>:DA> 24&9::g:NNr1   c                   V P                  4       R8X  ds   V'       g   RpV P                  P                  \        P                  P
                  \        P                  P
                  4      R,           V,           P                  4       # \        V P                  4       4      P                  RR4      pV'       g   RpV P                  4       R,           V,           R,           V,           P                  4       # )z
Return a public OpenSSH key string.

See _fromString_PUBLIC_OPENSSH for the string format.

@type comment: L{bytes} or L{None}
@param comment: A comment to include with the key, or L{None} to
omit the comment.
r@  r1          
)r[   r-  r  r   r  OpenSSHr  r   r   r   replacert  )r.  r  b64Datas   && r2   _toPublicOpenSSHKey._toPublicOpenSSH  s     99;$,,!**22M4N4N4V4V  	
 eg diik*225#>G%/$6@GGIIr1   c           	        V'       dw   \         P                  pRpRpVP                  ^,          p^ pTp\        P                  ! V4      p	^dp
\
        P                  ! V	4      \        P                  ! RV
4      ,           pMRpRp^pRp\        P                  ! ^4      pW,           V P                  4       ,           \
        P                  ! T;'       g    R4      ,           p^ p\        V4      V,          '       d&   V^,          pV\        V^,          34      ,          pK=  V'       d   \        P                  ! VX	XX,           ^d4      p\        X! VRV 4      \        P                   ! WWx,            4      \#        4       R7      P%                  4       pVP'                  V4      VP)                  4       ,           pMTpR\
        P                  ! V4      ,           \
        P                  ! V4      ,           \
        P                  ! V4      ,           \        P                  ! R^4      ,           \
        P                  ! V P+                  4       4      ,           \
        P                  ! V4      ,           p\-        V4      P/                  R	R4      pR
.\1        ^ \        V4      ^@4       Uu. uF  pVVV^@,            NK  	  up,           R.,           pR	P3                  V4      R	,           # u upi )a  
Return a private OpenSSH key string, in the "openssh-key-v1" format
introduced in OpenSSH 6.5.

See _fromPrivateOpenSSH_v1 for the string format.

@type passphrase: L{bytes} or L{None}
@param passphrase: The passphrase to encrypt the key with, or L{None}
if it is not encrypted.
r   r   r   r   r1   Nr   r   r  s#   -----BEGIN OPENSSH PRIVATE KEY-----s!   -----END OPENSSH PRIVATE KEY-----)r   r   
block_sizer   secureRandomr   r   r   packr  r   bytesr   r   r   r   r   r   	encryptorr   r   r   r   r  ranger   )r.  r  rP   r   
cipherNamekdfNamer   r   r   r   r   r   checkr   padByteencKeyr  r   r   r  ir   s   &&&                   r2   _toPrivateOpenSSH_v1Key._toPrivateOpenSSH_v1  se      ^^F&JG))Q.IGF))&1DF46;;tV+DDJ JGIJ&&q)md&6&6&88699W^^PS;TT+**qLG5'D.!233KZZ
D'F2BCHFvhw'(		&7+;<=') ik	 
 '--k:Y=O=O=QQN(Nii
#$ii ! ii
#$ kk$"	#
 ii		$% ii'( 	 d#++E3734,1!S\2,FG,Fqwq1r6",FGH345 	
 zz% 5(( Hs    Kc                r   V'       g   \         P                  ! 4       pM\         P                  ! V4      pV P                  4       R8w  dN   V P                  P                  \         P                  P                  \         P                  P                  V4      # V P                  4       R8X  g   Q h\        R4      h)z
Return a private OpenSSH key string, in the old PEM-based format.

See _fromPrivateOpenSSH_PEM for the string format.

@type passphrase: L{bytes} or L{None}
@param passphrase: The passphrase to encrypt the key with, or L{None}
if it is not encrypted.
rE  zBcannot serialize Ed25519 key to OpenSSH PEM format; use v1 instead)r   r  BestAvailableEncryptionr[   r-  r  r  PEMr  TraditionalOpenSSLr   )r.  rP   r  s   && r2   _toPrivateOpenSSH_PEMKey._toPrivateOpenSSH_PEM  s     %224I%==jII99;)#??00&&**++>>  99;)+++W r1   c                   V P                  4       '       d   V P                  VR7      # VR8X  g   Vf(   V P                  4       R8X  d   V P                  W#R7      # Ve   VR8X  d   V P	                  VR7      # \        RV 24      h)a
  
Return a public or private OpenSSH string.  See
L{_fromString_PUBLIC_OPENSSH} and L{_fromPrivateOpenSSH_PEM} for the
string formats.

@param subtype: A subtype to emit.  Only supported for private keys,
    for which the currently supported subtypes are C{'PEM'} and C{'v1'}.
    If not given, an appropriate default is used.
@type subtype: L{str} or L{None}

@param comment: Comment for a public key.
@type comment: L{bytes}

@param passphrase: Passphrase for a private key.
@type passphrase: L{bytes}

@rtype: L{bytes}
)r  v1rE  )r  rP   r  rO   zunknown subtype )rM  r  r[   r  r  r   )r.  r  r  rP   s   &&&&r2   _toString_OPENSSHKey._toString_OPENSSH	  s    & ==??(((99_TYY[I5M,,W,TT_5 0---DD/y9::r1   c                   V P                  4       pV P                  4       pV P                  4       '       EdZ   VR8X  df   \        P                  ! RRR\
        P                  ! VR,          4      R,          .R\
        P                  ! VR,          4      R,          ....4      pMVR	8X  d   \        P                  ! RR
R\
        P                  ! VR,          4      R,          .R\
        P                  ! VR,          4      R,          .R\
        P                  ! VR,          4      R,          .R\
        P                  ! VR,          4      R,          ....4      pM\        RV 24      hR\        V4      P                  RR4      ,           R,           # VR8X  Edq   VR,          VR,          re\        P                  ! WV4      p\        P                  ! RRR\
        P                  ! VR,          4      R,          .R\
        P                  ! VR,          4      R,          .R\
        P                  ! VR,          4      R,          .R\
        P                  ! V4      R,          .R\
        P                  ! V4      R,          .R\
        P                  ! VR,          V^,
          ,          4      R,          .R\
        P                  ! VR,          V^,
          ,          4      R,          .R\
        P                  ! V4      R,          ..	..4      # VR	8X  d   \        P                  ! RR
R\
        P                  ! VR,          4      R,          .R\
        P                  ! VR,          4      R,          .R\
        P                  ! VR,          4      R,          .R\
        P                  ! VR,          4      R,          .R\
        P                  ! VR ,          4      R,          ....4      # \        RV R!24      h)"z
Return a public or private LSH key.  See _fromString_PUBLIC_LSH and
_fromString_PRIVATE_LSH for the key formats.

@rtype: L{bytes}
rl  r   r   r   r   r   r   r   rm  r   r   rn   r   ro   r   rp   r   rr   r   r  r  r1      }r   r   r   r      a   b   cr   r   ')rg   r[   rM  r   r  r   rR  r(   r   r  r   r  )r.  kwargsrg   r[   keyDatarn   ro   r  s   &,      r2   _toString_LSHKey._toString_LSH&  s=    yy{yy{==??u}** * 1!%vyyc';B'? @!%vyyc';B'? @	 ** * &!%vyyc';B'? @!%vyyc';B'? @!%vyyc';B'? @!%vyyc';B'? @	 "$5dV"<==+g.66ucBBTIIu}Cy$s)1''-zz + ,!%vyyc';B'? @!%vyyc';B'? @!%vyyc';B'? @!%vyy|B'7 8!%vyy|B'7 8!%vyyca!e1D'Eb'I J!%vyyca!e1D'Eb'I J!%vyyr': ;
 $ zz + &!%vyyc';B'? @!%vyyc';B'? @!%vyyc';B'? @!%vyyc';B'? @!%vyyc';B'? @
   "$5dV1"=>>r1   c                   V P                  4       pV P                  4       '       g   V P                  4       R8X  d4   VR,          VR,          VR,          VR,          VR,          VR,          3pM?V P                  4       R8X  d+   VR,          VR,          VR	,          VR
,          VR,          3p\        P                  ! V P                  4       4      RP                  \        \        P                  X4      4      ,           # R# )zl
Return a private Secure Shell Agent v3 key.  See
_fromString_AGENTV3 for the key format.

@rtype: L{bytes}
rl  r   r   r   r   rn   ro   rm  rp   rr   r   r1   N)	rg   rM  r[   r   r   rt  r   maprR  )r.  r  rg   valuess   &,  r2   _toString_AGENTV3Key._toString_AGENTV3x  s     yy{}}yy{e#IIIIII %s)T#YS	49d3iP99T\\^,sxxFIIv8N/OOO r1   c               $    V ^8  d   QhRRRRRR/# )r2  rg   r  r  zbytes | Noner5  r)   )r7  s   "r2   r8  r9    s!     ?. ?. ?.| ?.u ?.r1   c                f   V P                  4       pVf   V P                  4       pV P                  V4      pVf   \        RV: RV R24      hVR8X  dI   V P                  P                  V\        P                  ! 4       V4      p\        P                  ! V4      pEMzVR8X  d\   V P                  P                  W4      p\        V4      w  rx\        P                  ! \        V^4      \        V^4      ,           4      pEMVR8X  d   V P                  P                  V\        P                  ! V4      4      p	\        V	4      w  rx\        V4      p
\        V4      pV
^ ,          pV^,          '       d
   RV
,           p
V^ ,          pV^,          '       d
   RV,           p\        P                  ! \        P                  ! V
4      \        P                  ! V4      ,           4      pM6VR8X  d0   \        P                  ! V P                  P                  V4      4      p\        P                  ! V4      X,           # )	a  
Sign some data with this key.

SECSH-TRANS RFC 4253 Section 6.6.

@param data: The data to sign.

@param signatureType: The SSH public key algorithm name to sign this
    data with, or L{None} to use a reasonable default for the key.

@return: A signature for the given data.
zpublic key signature algorithm z is not defined for z keysrl  rm  r@      rE  )r[   rt  r  r4   r-  signr   PKCS1v15r   r   r"   r   r   ECDSA)r.  rg   r  r   hashAlgorithmsigretrs	signaturerU   sbrcompscomps   &&&           r2   r  Key.sign  s    ))+ 
 !LLNM..}= ,1-1B C&iu. 
 e//&&tW-=-=-?OC))C.C//&&t;C)#.FQ
 ))LB/,q"2EEFC_,,T288M3JKI))4FQaBaBqEE t||r\qEEt||r\))FIIbMFIIbM9:C	!))DOO0067Cyy'#--r1   c                j   \        V4      ^(8X  d   R\        P                  ! V4      rM\        P                  ! V4      w  r1V P	                  V4      pVf   R# V P                  4       pVR8X  di   V P                  pV P                  4       '       g   VP                  4       p\        P                  ! V4      ^ ,          V\        P                  ! 4       V3pEMVR8X  d   \        P                  ! V4      ^ ,          p\        P                  VR,          R4      p	\        P                  VR,          R4      p
\        W4      pV P                  pV P                  4       '       g   VP                  4       pWV3pEMVR8X  d   \        P                  ! V4      ^ ,          p\        P                  ! V^4      w  rp\        P                  VR4      p	\        P                  VR4      p
\        W4      pV P                  pV P                  4       '       g   VP                  4       pW\        P                  ! V4      3pMXVR	8X  dR   V P                  pV P                  4       '       g   VP                  4       p\        P                  ! V4      ^ ,          V3p XP                   ! X!   R
#   \"         d     R# i ; i)z
Verify a signature using this key.

@type signature: L{bytes}
@param signature: The signature to verify.

@type data: L{bytes}
@param data: The signed data.

@rtype: L{bool}
@return: C{True} if the signature is valid.
rl   Frl  rm  :N   Nbig:r  NNr@  rE  T)r   r   r   rz   r  r[   r-  rM  r}   r   r  r   
from_bytesr#   r   r  verifyr   )r.  r  rg   r  r  r   r   argsconcatenatedSignaturer  r  rstrsstrr   s   &&&           r2   r  
Key.verify  s    y>R'1699Y3G9'-||I'>$M..}= ))+eA==??LLNY'*  "	D $*LL$;A$>!4S95AA4S95AA,Q2IA==??LLN]3D_$*LL$;A$>!%||,A1EDtU+AtU+A,Q2IA==??LLNRXXm%<=D	!A==??LLNLL+A.5D	HHdO    		s   J# #J21J2r,  )NN)NNNN)N)NNN)2r+   r,   r-   r.   r/   classmethodr]   rW   r   r   r   r   r   r   r   r   r   rb   r   r   r   r   r   r/  r<  rY  rM  ra  r;   r<   rh  r[   rt  ry  r  rP  rg   r   r  r!   r  r  r  r  r  r  r  r  r  r0   r)   r1   r2   rS   rS      s-    > >( %, %,N D; D;L H? H?T * *( V= V=p 6: 6:p A A8 D D> #D #DJ .= .=` 2 2h * *X    D  >  6  ,	"*$X
 5 "4!;!; &TPO.B
$,:(JJX:;xQ;f !i l#	
:O:OxJ4<)|8;:P?dP,?.BDr1   rS   c                d   V P                  4       P                  RR7       V P                  4       '       g   \        P                  ! RV\        4       R7      pVP                  \        P                  P                  \        P                  P                  \        P                  ! 4       R7      pV P                  V4       V P                  R4      ;_uu_ 4       p\        P                  ! VP!                  4       R\        4       R7      p\#        V4      uuRRR4       #   + '       g   i     R# ; i)	a  
This function returns a persistent L{Key}.

The key is loaded from a PEM file in C{location}. If it does not exist, a
key with the key size of C{keySize} is generated and saved.

@param location: Where the key is stored.
@type location: L{twisted.python.filepath.FilePath}

@param keySize: The size of the key, if it needs to be generated.
@type keySize: L{int}

@returns: A persistent key.
@rtype: L{Key}
T)ignoreExistingDirectoryi  )public_exponentr  r   )encodingr7  encryption_algorithmrU   N)passwordr   )parentmakedirsexistsr   generate_private_keyr   r  r   r  r  r  r  r  
setContentrV   r   rX   rS   )locationr   
privateKeypemkeyFiles   &&   r2   _getPersistentRSAKeyr
    s      OOt< ??--!G_=N

 &&"++// ..AA!.!;!;!= ' 
 	C  
t		"77LLNT?3D

 :	 
			s   :DD/	)i   )Nr/   
__future__r   rf  r   rC   r  base64r   r   r   hashlibr   r   typingr   r   
constantlyr	   r
   cryptographyr   cryptography.exceptionsr   cryptography.hazmat.backendsr   cryptography.hazmat.primitivesr   r   )cryptography.hazmat.primitives.asymmetricr   r   r   r   r   &cryptography.hazmat.primitives.ciphersr   r   r   ,cryptography.hazmat.primitives.serializationr   r   r   twisted.conch.sshr   r   twisted.conch.ssh.commonr   twisted.pythonr   twisted.python.compatr   r    twisted.python.deprecater!   /cryptography.hazmat.primitives.asymmetric.utilsr"   r#   ImportErrorr$   r%   	SECP256R1	SECP384R1	SECP521R1r   r   r&  r'  	Exceptionr(   r4   r7   r9   r;   r?   rQ   rS   r
  r)   r1   r2   <module>r"     s?  
 #     6 6    +  4 8 @ T T L L  + 1 $ 9 @	 BLLNBLLNBLLN +++
 ++ -- )  	 9 $ $"9 >| |~3(W7   s    E E%$E%