File: //lib/google-cloud-sdk/lib/surface/kms/__pycache__/decapsulate.cpython-312.pyc
�
��� � �� � d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z
ddlm Z ddlmZ ddlm
Z
ddlmZ dd lmZ dd
lmZ ddlmZ ddlmZ e j, G d
� de j. � � Zy)z@Decapsulate an input file using a key-encapsulation key version.� )�absolute_import)�division)�unicode_literals)�
exceptions)�base)�crc32c)�
e2e_integrity)�flags)�log)�
console_io)�filesc �8 � e Zd ZdZed� � Zd� Zd� Zd� Zd� Z y)�DecapsulateaD Decapsulate an input file using a key-encapsulation key version.
Decapsulates the given ciphertext file using the provided key-encapsulation
key version and saves the decapsulated shared secret to the shared secret file.
By default, the command performs integrity verification on data sent to and
received from Cloud KMS. Use `--skip-integrity-verification` to disable
integrity verification.
## EXAMPLES
The following command will read the file '/tmp/my/secret.file.enc', decapsulate it
using the key encapsulation CryptoKey `my-key` Version 3 and write the shared secret
to '/tmp/my/secret.file.dec'.
$ {command} \
--location=us-central1 \
--keyring=my-keyring \
--key=my-key \
--version=3 \
--ciphertext-file=/tmp/my/secret.file.enc \
--shared-secret-file=/tmp/my/secret.file.dec
c �� � t j | d� t j | d� t j | d� t j | d� t j
| � y )Nzto use for decapsulation.zto use for decapsulationzto decapsulatez to output)r
�AddKeyResourceFlags�AddCryptoKeyVersionFlag�AddCiphertextFileFlag�AddSharedSecretFileFlag�AddSkipIntegrityVerification)�parsers �lib/surface/kms/decapsulate.py�ArgszDecapsulate.Args; sS � � ���f�&A�B� �!�!�&�*D�E� ����(8�9� �!�!�&�+�6� �&�&�v�.� c � � |j S )N)�skip_integrity_verification)�self�argss r �_PerformIntegrityVerificationz)Decapsulate._PerformIntegrityVerificationC s � ��/�/�/�/r c � � t j |j d�� }t j � }t j |� }|j |j � �� }| j |� r/t j |� }|j# ||�� |_ |S |j# |�� |_ |S # t j $ r4}t j dj |j |� � �d }~ww xY w)NT)�binaryz)Failed to read ciphertext file [{0}]: {1})�name)�
ciphertext�ciphertextCrc32c)r"