[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-18。"],[],[],null,["# Key wrapping\n\n*Key wrapping* is the process of encrypting one key using another key, in order\nto securely store it or transmit it over an untrusted channel. Key wrapping may\nrely on either symmetric or asymmetric cryptography, depending on the context.\n\nIn Cloud Key Management Service, key wrapping is used to securely import user-provided\ncryptographic keys. Importing keys requires an *import job* , and each import job\nhas an *import method* that specifies the key wrapping protocol to use.\n\nCloud KMS expects specific formats for imported key material.\nBefore your key material is wrapped for import, you may need to convert it to\nthe format expected by Cloud KMS. [Formatting keys for import](/kms/docs/formatting-keys-for-import)\ncontains details of the required formats, and provides instructions on how you\ncan convert your keys to the required format if necessary.\n\nOnce your key material is formatted properly, the Google Cloud CLI can\nautomatically wrap your key material before securely transmitting it to\nCloud KMS. For details, see [Importing a key](/kms/docs/importing-a-key).\nAlternatively, you may manually wrap your keys using the appropriate\ncryptographic protocols. [Wrapping a key using OpenSSL on Linux](/kms/docs/wrapping-a-key) provides\none example of how you can do this.\n\nImport methods\n--------------\n\nCloud KMS provides the following import methods:\n\nKey wrapping algorithms\n-----------------------\n\nThe import methods provided by Cloud KMS correspond to the\nfollowing key wrapping algorithms:\n\n### RSAES-OAEP with SHA-1/SHA-256 + AES-KWP\n\nThis key wrapping algorithm is a hybrid encryption scheme that consists of both\nan asymmetric key wrapping operation and a symmetric key wrapping operation:\n\n1. The public key from the import job is used to encrypt a one-time-use AES-256 key. Encryption is performed using RSAES-OAEP and MGF-1, along with the digest algorithm specified by the import method. The one-time-use AES-256 key is generated at the time the wrapping is performed.\n2. The one-time-use AES-256 key from step 1 is used to encrypt the target key material using [AES Key Wrap with Padding](https://tools.ietf.org/html/rfc5649).\n\nThe wrapped key material for import is a single byte array consisting of the\nresults of step 1, followed by the results of step 2. In other words, the\nresults of steps 1 and 2 are concatenated together to form the wrapped key\nmaterial.\n\nThis algorithm is the same as the PKCS #11 key wrapping algorithm\n[CKM_RSA_AES_KEY_WRAP](http://docs.oasis-open.org/pkcs11/pkcs11-curr/v2.40/cos01/pkcs11-curr-v2.40-cos01.html#_Toc408226908). If you are importing a key from an HSM, and your HSM\nsupports this algorithm, you may use it directly. Alternatively, steps 1 and 2\nabove can be performed with the PKCS #11 mechanisms [CKM_RSA_PKCS_OAEP](http://docs.oasis-open.org/pkcs11/pkcs11-curr/v2.40/cos01/pkcs11-curr-v2.40-cos01.html#_Toc228894637) and\n[CKM_AES_KEY_WRAP_PAD](http://docs.oasis-open.org/pkcs11/pkcs11-curr/v2.40/cos01/pkcs11-curr-v2.40-cos01.html#_Toc228894722) respectively.\n\nIf your source HSM (or other key provider if not using HSM) does not support\nthe RSA AES key wrap mechanism, you need to manually wrap your key material\nusing your import job's public key. For one example of how to do this using\nOpenSSL, see [Wrapping a key using OpenSSL on Linux](/kms/docs/wrapping-a-key).\n\n### RSAES-OAEP with SHA-256\n\nThis is an asymmetric key wrapping operation that uses the public key from the\nimport job with RSAES-OAEP, using MGF-1 and the SHA-256 digest algorithm, to\ndirectly encrypt the target key material. It is based on the PKCS #11 RSA OAEP\nmechanism [CKM_RSA_PKCS_OAEP](http://docs.oasis-open.org/pkcs11/pkcs11-curr/v2.40/cos01/pkcs11-curr-v2.40-cos01.html#_Toc228894637). The size limitations associated with this\nimport method make it unsuitable for importing RSA private keys."]]