
    P                     t    S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKJr  SSK	J
r
  SSKJr  S	rSS
 jrS rg)zKey generation utilities.    )absolute_import)division)unicode_literalsN)
exceptions)log)filesa  A private key was exported to {}.

Possession of this key file could allow anybody to act as this certificate's
subject. Please make sure that you store this key file in a secure location at
all times, and ensure that only authorized users have access to it.
c                    Sn SSK Jn  SSKJn   SSK
Jn  SSK
Jn  SSK
Jn  SS	K
Jn  WR!                  S
U WS9nUR#                  WR$                  WR&                  W" 5       5      n	UR)                  5       R+                  UR$                  WR,                  5      n
X4$ ! [         a8    [
        R                  R                  U5        [        R                  " S5         Nf = f! [         ac     SSKJn  SSKJn  SSKJn  SS	KJn   N! [         a:    [
        R                  R                  U5        [        R                  " S5          GN!f = ff = f)zGenerates an RSA public-private key pair.

Args:
  key_size: The size of the RSA key, in number of bytes. Defaults to 2048.

Returns:
  A tuple with: (private_key, public_key) both serialized in PKCS1 as bytes.
a  Cannot load the Pyca cryptography library. Either the library is not installed, or site packages are not enabled for the Google Cloud SDK. Please consult Cloud KMS documentation on adding Pyca to Google Cloud SDK for further instructions.
https://cloud.google.com/kms/docs/cryptor   )rsa)backend   )Encoding)PrivateFormat)PublicFormat)NoEncryptioni  )public_exponentkey_sizer   ))cryptography.hazmat.primitives.asymmetricr
   ,cryptography.hazmat.backends.openssl.backendr   ImportErrorr   errPrintsysexit1cryptography.hazmat.primitives.serialization.baser   r   r   r   ,cryptography.hazmat.primitives.serializationgenerate_private_keyprivate_bytesPEMTraditionalOpenSSL
public_keypublic_bytesSubjectPublicKeyInfo)r   import_error_msgr
   r   r   r   r   r   private_keyprivate_key_bytespublic_key_bytess              :lib/googlecloudsdk/command_lib/privateca/key_generation.py	RSAKeyGenr(   $   s"   A
 >DJONN ((h ) A+ "//ll&&n
 !++-::llL557 
	,,G 
 GGMM"#HHQK 
 	GLKK 	ggmm$%	hhqkk	s:   B C" ?CC"
E-D?EE
EEc                 n    [         R                  " U 5        [         R                  " X5        [        R                  " U S5        [
        R                  " [        R                  U 5      5        g! [         R                  [        [        4 a&    [        R                  " SR                  U 5      5      ef = f)zExport a private key to a filename, printing a warning to the user.

Args:
  private_key_output_file: The path of the file to export to.
  private_key_bytes: The content in byte format to export.
   z3Error writing to private key output file named '{}'N)r   PrivatizeFileWriteFileContentsoschmodr   warningKEY_OUTPUT_WARNINGformatErrorOSErrorIOErrorr   FileOutputError)private_key_output_filer%   s     r'   ExportPrivateKeyr7   a   s    
&	/0	3GHH$e,KK"))*ABC
++w	( &

$
$=DD#	%& &&s   A,A/ /AB4)i   )__doc__
__future__r   r   r   r-   r   $googlecloudsdk.command_lib.privatecar   googlecloudsdk.corer   googlecloudsdk.core.utilr   r0   r(   r7        r'   <module>r?      s5      &  ' 	 
 ; # * :-z&r>   