Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
L'AO effectue des opérations de chiffrement et de déchiffrement via la CLI isolée Google Distributed Cloud (GDC) vers le KMS via un client gRPC.
Avant de commencer
Avant d'effectuer des opérations de chiffrement, téléchargez, installez et configurez la gdcloud CLI pour accéder au serveur de l'API Management. Pour ce faire, suivez la présentation de la CLI gdcloud.
Pour obtenir les autorisations nécessaires pour effectuer des opérations de chiffrement, demandez à votre administrateur IAM de l'organisation de vous accorder le rôle Développeur KMS (kms-developer).
Chiffrer des données
Pour chiffrer des données, utilisez la commande gdcloud kms keys encrypt. Cette commande chiffre un fichier en texte brut donné à l'aide de la clé AEAD et l'écrit dans un fichier chiffré nommé.
Pour chiffrer des données, transmettez le nom de la clé et les éléments suivants :
NAMESPACE : espace de noms du projet, par exemple : kms-test1.
KEY_NAME : nom de la clé utilisée pour chiffrer le texte brut, par exemple key-1.
PLAINTEXT_PATH : chemin d'accès au fichier contenant le texte brut à chiffrer.
ADDITIONAL_AUTHENTICATED_DATA_FILE : fichier facultatif contenant des données authentifiées supplémentaires (AAD). Le contrôle AAD permet de vérifier l'intégrité et de protéger les données contre une attaque de type "confused deputy". L'AAD et le texte brut sont chacun limités à 64 Ko.
CIPHERTEXT_PATH : chemin d'accès au fichier contenant le texte brut chiffré.
Après avoir exécuté la commande, vous verrez un fichier que vous avez spécifié dans l'indicateur --ciphertext-file et qui contient le contenu chiffré du fichier en texte brut.
Déchiffrer des données
Pour déchiffrer des données, utilisez la commande gdcloud kms keys decrypt. Cette commande déchiffre un fichier de texte chiffré donné à l'aide de la clé AEAD et l'écrit dans un fichier de texte brut nommé.
Pour déchiffrer le texte chiffré, transmettez le nom de la clé et les éléments suivants :
KEY_NAME : nom de la clé utilisée pour chiffrer le texte brut.
CIPHERTEXT_PATH : chemin d'accès au fichier que vous souhaitez déchiffrer.
ADDITIONAL_AUTHENTICATED_DATA_FILE : fichier facultatif contenant des données authentifiées supplémentaires (AAD). Le contrôle AAD permet de vérifier l'intégrité et de protéger les données contre une attaque de type "confused deputy". L'AAD et le texte brut sont chacun limités à 64 Ko.
PLAINTEXT_PATH : chemin d'accès au fichier contenant le texte brut déchiffré.
Après avoir exécuté la commande, vous verrez un fichier que vous avez spécifié dans l'indicateur --plaintext-file et qui contient les données déchiffrées.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[[["\u003cp\u003eThe AO (air-gapped operations) utilizes the Google Distributed Cloud (GDC) air-gapped CLI and a gRPC client to perform encryption and decryption operations via the KMS.\u003c/p\u003e\n"],["\u003cp\u003eBefore starting cryptographic operations, users must download, install, and configure the \u003ccode\u003egdcloud\u003c/code\u003e CLI to access the Management API server as detailed in the \u003ccode\u003egdcloud\u003c/code\u003e CLI overview.\u003c/p\u003e\n"],["\u003cp\u003eEncrypting data requires the \u003ccode\u003egdcloud kms keys encrypt\u003c/code\u003e command, where you must specify the key name, plaintext file path, an optional additional authenticated data file path, and a ciphertext file path.\u003c/p\u003e\n"],["\u003cp\u003eDecrypting data requires the \u003ccode\u003egdcloud kms keys decrypt\u003c/code\u003e command, specifying the key name, ciphertext file path, and the path for the decrypted plaintext file, in addition to the optional additional authenticated data file path.\u003c/p\u003e\n"],["\u003cp\u003eTo complete cryptographic operations, users must be granted the KMS Developer (\u003ccode\u003ekms-developer\u003c/code\u003e) role by their Organization IAM Admin.\u003c/p\u003e\n"]]],[],null,["# Encrypt and decrypt data\n\nThe AO performs encrypt and decrypt operations through the\nGoogle Distributed Cloud (GDC) air-gapped CLI to the KMS through a gRPC client.\n\nBefore you begin\n----------------\n\nBefore performing crypto operations, download, install, and configure the\ngdcloud CLI to access the Management API server. To do this, follow the\n[gdcloud CLI overview](/distributed-cloud/hosted/docs/latest/gdch/resources/gdcloud-overview).\n\nTo get the permissions you need to perform cryptographic operations, ask\nyour Organization IAM Admin to grant you the KMS Developer (`kms-developer`)\nrole.\n\nEncrypt data\n------------\n\nTo encrypt data, use the `gdcloud kms keys encrypt` command. This command encrypts a\ngiven plaintext file using the `AEAD` key, and writes it to a named ciphertext\nfile.\n\n- To encrypt data, pass in the key name and the following:\n\n gdcloud kms keys encrypt namespaces/\u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e/aeadKeys/\u003cvar translate=\"no\"\u003eKEY_NAME\u003c/var\u003e \\\n --plaintext-file=\u003cvar translate=\"no\"\u003ePLAINTEXT_PATH\u003c/var\u003e \\\n --additional-authenticated-data-file=\u003cvar translate=\"no\"\u003eADDITIONAL_AUTHENTICATED_DATA_FILE\u003c/var\u003e \\\n --ciphertext-file=\u003cvar translate=\"no\"\u003eCIPHERTEXT_PATH\u003c/var\u003e\n\n Replace the following variables:\n - \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e: the project namespace---for example: `kms-test1`.\n - \u003cvar translate=\"no\"\u003eKEY_NAME\u003c/var\u003e: the name of the key used to encrypt the plaintext---for example: `key-1`.\n - \u003cvar translate=\"no\"\u003ePLAINTEXT_PATH\u003c/var\u003e: the path to the file that contains the plaintext to encrypt.\n - \u003cvar translate=\"no\"\u003eADDITIONAL_AUTHENTICATED_DATA_FILE\u003c/var\u003e: an optional file that contains additional authenticated data (AAD). AAD is used for integrity checks and protects your data from a confused deputy attack. AAD and the plaintext each have a size limit of 64KB.\n - \u003cvar translate=\"no\"\u003eCIPHERTEXT_PATH\u003c/var\u003e: the path to the file that contains the encrypted plaintext.\n\n After running the command, you see a file you specified in the\n `--ciphertext-file` flag that contains the encrypted contents of the plaintext\n file.\n\nDecrypt data\n------------\n\nTo decrypt data, use the `gdcloud kms keys decrypt` command. This command decrypts a\ngiven ciphertext file using the `AEAD` key, and writes it to a named plaintext\nfile.\n\n- To decrypt ciphertext, pass in the key name and the following:\n\n gdcloud kms keys decrypt namespaces/\u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e/aeadKeys/\u003cvar translate=\"no\"\u003eKEY_NAME\u003c/var\u003e \\\n --ciphertext-file=\u003cvar translate=\"no\"\u003eCIPHERTEXT_PATH\u003c/var\u003e \\\n --additional-authenticated-data-file=\u003cvar translate=\"no\"\u003eADDITIONAL_AUTHENTICATED_DATA_FILE\u003c/var\u003e \\\n --plaintext-file=\u003cvar translate=\"no\"\u003ePLAINTEXT_PATH\u003c/var\u003e\n\n Replace the following variables:\n - \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e: the project namespace.\n - \u003cvar translate=\"no\"\u003eKEY_NAME\u003c/var\u003e: the name of the key used to encrypt the plaintext.\n - \u003cvar translate=\"no\"\u003eCIPHERTEXT_PATH\u003c/var\u003e: the path of the file you want to decrypt.\n - \u003cvar translate=\"no\"\u003eADDITIONAL_AUTHENTICATED_DATA_FILE\u003c/var\u003e: an optional file that contains additional authenticated data (AAD). AAD is used for integrity checks and protects your data from a confused deputy attack. AAD and the plaintext each have a size limit of 64KB. **Note**: You must use the same AAD you passed during the encrypt operation for the decrypt operation.\n - \u003cvar translate=\"no\"\u003ePLAINTEXT_PATH\u003c/var\u003e: the path to the file that contains the decrypted plaintext.\n\n After running the command, you see a file you specified in the\n `--plaintext-file` flag that contains the decrypted data."]]