- Descripción general del servicio
-
Guía del usuario
- Key Management Service
- Cloud Secret Management Service
- Key Pair Service
- HSM dedicado
- Gestión de etiquetas
- Registros de auditoría
- Control de permisos
-
Prácticas recomendadas
-
Key Management Service
- Uso de KMS para cifrar datos sin conexión
- Uso de KMS para cifrar y descifrar datos para servicios en la nube
- Uso del SDK de encriptación para cifrar y descifrar datos locales
- Encriptación y descifrado de datos con recuperación ante desastres entre regiones
- Uso de KMS para proteger la integridad de archivos
- Cloud Secret Management Service
- Generales
-
Key Management Service
-
Referencia de la API
- Antes de empezar
- Llamadas a APIs
- Descripción general de la API
-
APIs
- API de gestión de claves
- API de gestión de pares clave
- API de gestión de secreto
- Las API históricas
- Ejemplos de aplicación
- Políticas de permisos y acciones admitidas
- Apéndice
- Historial de cambios
- Pasos iniciales
-
Preguntas frecuentes
-
KMS Relacionados
- ¿Qué es Key Management Service?
- ¿Qué es una clave maestra del cliente?
- ¿Qué es una clave predeterminada?
- ¿Cuáles son las diferencias entre una clave personalizada y una clave predeterminada?
- What Is a Data Encryption Key?
- ¿Por qué no puedo eliminar un CMK inmediatamente?
- ¿Qué servicios en la nube pueden usar KMS para el cifrado?
- ¿Cómo servicios de Huawei Cloud utilizan KMS para cifrar datos?
- ¿Cuáles son los beneficios del cifrado de sobres?
- ¿Hay un límite en el número de claves personalizadas que puedo crear en KMS?
- ¿Puedo exportar un CMK desde KMS?
- ¿Puedo descifrar mis datos si elimino permanentemente mi clave personalizada?
- ¿Cómo uso la herramienta en línea para cifrar o descifrar pequeños volúmenes de datos?
- ¿Puedo actualizar CMK creados por materiales clave generados por KMS?
- When Should I Use a CMK Created with Imported Key Materials?
- ¿Qué debo hacer cuando elimino accidentalmente materiales clave?
- ¿Cómo se generan las claves predeterminadas?
- ¿Qué debo hacer si no tengo permisos para realizar operaciones en KMS?
- ¿Por qué no puedo envolver claves asimétricas usando -id-aes256-wrap-pad en OpenSSL?
- Algoritmos de clave soportados por KMS
- ¿Qué debo hacer si no se ha solicitado KMS y se muestra el código de error 401?
- ¿Cuál es la relación entre el texto cifrado y el texto plano devuelto por la API de encrypt-data?
- ¿Cómo protege KMS mis claves?
- ¿Cómo uso una clave asimétrica para verificar el resultado de la firma de un par de claves públicas?
- ¿Una clave importada admite la rotación?
- Credencial Relacionado
-
KPS Relacionados
- ¿Cómo creo un par de claves?
- ¿Qué son un par de claves privadas y un par de claves de cuenta?
- ¿Cómo puedo manejar un error de importación de un par de claves creado con PuTTYgen?
- ¿Qué debo hacer cuando no puedo importar un par de claves usando Internet Explorer 9?
- ¿Cómo inicio sesión en un ECS de Linux con una clave privada?
- ¿Cómo uso una clave privada para obtener la contraseña para iniciar sesión en un ECS de Windows?
- ¿Cómo puedo manejar la falla en la vinculación de un par de claves?
- ¿Cómo manejo el fallo en la sustitución de un par de claves?
- ¿Cómo puedo manejar la falla en el restablecimiento de un par de claves?
- ¿Cómo puedo manejar el fallo en la desvinculación de un par de claves?
- ¿Necesito reiniciar los servidores después de reemplazar su par de claves?
- ¿Cómo activo el modo de inicio de sesión con contraseña para un ECS?
- ¿Cómo manejo el fallo al iniciar sesión en ECS después de desvincular el par de claves?
- ¿Qué debo hacer si se pierde mi clave privada?
- ¿Cómo convierto el formato de un archivo de clave privada?
- ¿Puedo cambiar el par de claves de un servidor?
- ¿Puede un par de claves ser compartido por varios usuarios?
- ¿Cómo obtengo el archivo de clave pública o privada de un par de claves?
- ¿Qué puedo hacer si se informa de un error cuando se crea o actualiza una clave de cuenta por primera vez?
- ¿Se ocupará la cuota del par de claves de cuenta después de que se actualice un par de claves privadas a un par de claves de cuenta?
-
Relacionado con HSM dedicado
- ¿Qué es el HSM dedicado?
- ¿Cómo garantiza el HSM dedicado la seguridad para la generación de claves?
- ¿El personal de la sala de equipos tiene la función de súper administrador para robar información mediante el uso de un UKey privilegiado?
- ¿Qué HSM se utilizan para HSM dedicado?
- ¿Qué API admite HSM dedicado?
- ¿Cómo habilito el acceso público a una instancia de HSM dedicado?
- Precios
-
General
- ¿Qué funciones proporciona DEW?
- ¿Qué algoritmos de criptografía utiliza DEW?
- ¿En qué regiones están disponibles los servicios DEW?
- What Is a Quota?
- ¿Qué es el mecanismo de asignación de recursos de DEW?
- ¿Qué son las Regiones y las AZ?
- Can DEW Be Shared Across Accounts?
- ¿Cómo accedo a las funciones de DEW?
-
KMS Relacionados
- Actualmente, el contenido no está disponible en el idioma seleccionado. Sugerimos consultar la versión en inglés.
- What's New
- Function Overview
- Billing
- SDK Reference
- Videos
-
More Documents
- User Guide (ME-Abu Dhabi Region)
- User Guide (Paris and Amsterdam Regions)
-
User Guide (Kuala Lumpur Region)
- Service Overview
-
User Guide
- Key Management Service
- Cloud Secret Management Service
- Auditing Logs
- Permission Control
-
FAQs
-
KMS Related
- What Is Key Management Service?
- What Is a Customer Master Key?
- What Is a Default Key?
- What Are the Differences Between a Custom Key and a Default Key?
- What Is a Data Encryption Key?
- Why Cannot I Delete a CMK Immediately?
- Which Cloud Services Can Use KMS for Encryption?
- How Do Cloud Services Use KMS to Encrypt Data?
- What Are the Benefits of Envelope Encryption?
- Is There a Limit on the Number of Custom Keys That I Can Create on KMS?
- Can I Export a CMK from KMS?
- Can I Decrypt My Data if I Permanently Delete My Custom Key?
- How Do I Use the Online Tool to Encrypt or Decrypt Small Volumes of Data?
- Can I Update CMKs Created by KMS-Generated Key Materials?
- When Should I Use a CMK Created with Imported Key Materials?
- What Types of Keys Can I Import?
- What Should I Do When I Accidentally Delete Key Materials?
- How Are Default Keys Generated?
- What Should I Do If I Do Not Have the Permissions to Perform Operations on KMS?
- Why Can't I Wrap Asymmetric Keys by Using -id-aes256-wrap-pad in OpenSSL?
- Key Algorithms Supported by KMS
- What Should I Do If KMS Failed to Be Requested and Error Code 401 Is Displayed?
- What Is the Relationship Between the Ciphertext and Plaintext Returned by the encrypt-data API?
- How Does KMS Protect My Keys?
- Credential Related
-
KMS Related
- Change History
-
API Reference (ME-Abu Dhabi Region)
- Before You Start
- Calling APIs
- API Overview
-
APIs
- Creating a CMK
- Enabling a CMK
- Disabling a CMK
- Scheduling the Deletion of a CMK
- Canceling the Scheduled Deletion of a CMK
- Querying the List of CMKs
- Querying the Information About a CMK
- Creating a Random Number
- Creating a DEK
- Creating a Plaintext-Free DEK
- Encrypting a DEK
- Decrypting a DEK
- Querying the Number of Instances
- Querying the Quota of a User
- Changing the Alias of a CMK
- Changing the Description of a CMK
- Encrypting Data
- Decrypting Data
- Obtaining CMK Import Parameters
- Importing CMK Material
- Deleting CMK Material
- Querying CMK Instances
- Querying CMK Tags
- Querying Project Tags
- Adding or Deleting CMK Tags in Batches
- Adding a CMK Tag
- Deleting a CMK Tag
- Permissions Policies and Supported Actions
- Appendix
- Change History
-
API Reference (Paris and Amsterdam Regions)
- Before You Start
- Calling APIs
- API Overview
-
APIs
- Creating a CMK
- Enabling a CMK
- Disabling a CMK
- Scheduling the Deletion of a CMK
- Canceling the Scheduled Deletion of a CMK
- Querying the List of CMKs
- Querying the Information About a CMK
- Creating a Random Number
- Creating a DEK
- Creating a Plaintext-Free DEK
- Encrypting a DEK
- Decrypting a DEK
- Querying the Number of Instances
- Querying the Quota of a User
- Changing the Alias of a CMK
- Changing the Description of a CMK
- Creating a Grant
- Revoking a Grant
- Retiring a Grant
- Querying Grants on a CMK
- Querying Grants That Can Be Retired
- Encrypting Data
- Decrypting Data
- Obtaining CMK Import Parameters
- Importing CMK Material
- Deleting CMK Material
- Enabling Rotation for a CMK
- Changing the Rotation Interval for a CMK
- Disabling Rotation for a CMK
- Querying the Rotation Status of a CMK
- Appendix
- Change History
-
API Reference (Kuala Lumpur Region)
- Before You Start
- Calling APIs
- API Overview
-
APIs
- Creating a CMK
- Enabling a CMK
- Disabling a CMK
- Scheduling the Deletion of a CMK
- Canceling the Scheduled Deletion of a CMK
- Querying the List of CMKs
- Querying the Information About a CMK
- Creating a Random Number
- Creating a DEK
- Creating a Plaintext-Free DEK
- Encrypting a DEK
- Decrypting a DEK
- Querying the Number of Instances
- Querying the Quota of a User
- Changing the Alias of a CMK
- Changing the Description of a CMK
- Creating a Grant
- Revoking a Grant
- Retiring a Grant
- Querying Grants on a CMK
- Querying Grants That Can Be Retired
- Encrypting Data
- Decrypting Data
- Obtaining CMK Import Parameters
- Importing CMK Material
- Deleting CMK Material
- Enabling Rotation for a CMK
- Changing the Rotation Interval for a CMK
- Disabling Rotation for a CMK
- Querying the Rotation Status of a CMK
- Appendix
- Change History
Mostrar todo
Copiado.
Uso del SDK de encriptación para cifrar y descifrar datos locales
Puede utilizar determinados algoritmos para encriptar sus archivos, protegiéndolos de posibles violaciones o manipulaciones.
El SDK de encriptación es una biblioteca de contraseñas de cliente que puede cifrar y descifrar datos y flujos de archivos. Puede cifrar y descifrar grandes cantidades de datos simplemente invocando a las API. Le permite concentrarse en el desarrollo de las funciones principales de sus aplicaciones sin distraerse con los procesos de encriptación y descifrado de datos.
Escenario
Si se envían archivos e imágenes de gran tamaño a KMS por HTTPS para su encriptación, se consumirá un gran número de recursos de red y la encriptación será lenta. En esta sección se describe cómo cifrar rápidamente una gran cantidad de datos.
Solución
El SDK de encriptación realiza la encriptación en sobres en flujos de archivos segmento por segmento.
Los datos se cifran dentro del SDK utilizando la DEK generada por KMS. La encriptación segmentada de archivos en la memoria garantiza la seguridad y la corrección de la encriptación de archivos, ya que no requiere la transferencia de archivos por la red.
El SDK carga un archivo en la memoria y lo procesa segmento por segmento. El siguiente segmento no se leerá antes de que finalice la encriptación o el descifrado del segmento actual.
Proceso
Procedimiento
- Obtenga las AK y SK.
- ACCESS_KEY: Clave de acceso de la cuenta de Huawei. Para obtener más detalles, consulte ¿Cómo obtengo una clave de acceso (AK/SK)?
- SECRET_ACCESS_KEY: Clave de acceso secreta de la cuenta de Huawei. Para obtener más detalles, consulte ¿Cómo obtengo una clave de acceso (AK/SK)?
- Habrá riesgos de seguridad si la AK/SK utilizada para la autenticación se escribe directamente en el código. Cifre la AK/SK en el archivo de configuración o en las variables de entorno para su almacenamiento.
- En este ejemplo, las AK/SK almacenadas en las variables de entorno se utilizan para la autenticación de identidad. Primero configure las variables de entorno HUAWEICLOUD_SDK_AK y HUAWEICLOUD_SDK_SK en el entorno local.
- Obtenga información de la región.
- Inicie sesión en la consola de gestión.
- Pase el ratón por encima del nombre de usuario en la esquina superior derecha y seleccione My Credentials en la lista desplegable.
- Obtenga los Project ID y Project Name.
Figura 1 Obtención del ID y el nombre del proyecto
- Haga clic en
. Elija Security & Compliance > Data Encryption Workshop.
- Obtenga el ID de la CMK (KEYID) que se utilizará en la región actual.
Figura 2 Obtención del ID de CMK
- Obtenga el punto de conexión (ENDPOINT) requerido por la región actual.
Un punto de conexión es la request address para llamar a una API. Los puntos de conexión varían según los servicios y las regiones. Para ver los puntos de conexión de todos los servicios, consulte Regiones y puntos de conexción.
Figura 3 Obtención de un punto de conexión
- Encriptar y descifrar un archivo.
public class KmsEncryptFileExample { private static final String ACCESS_KEY = System.getenv("HUAWEICLOUD_SDK_AK"); private static final String SECRET_ACCESS_KEY = System.getenv("HUAWEICLOUD_SDK_SK"); private static final String PROJECT_ID = "<projectId>"; private static final String REGION = "<region>"; private static final String KEYID = "<keyId>"; public static final String ENDPOINT = "<endpoint>"; public static void main(String[] args) throws IOException { // Source file path String encryptFileInPutPath = args[0]; // Path of the encrypted ciphertext file String encryptFileOutPutPath = args[1]; // Path of the decrypted file String decryptFileOutPutPath = args[2]; // Encryption context Map<String, String> encryptContextMap = new HashMap<>(); encryptContextMap.put("encryption", "context"); encryptContextMap.put("simple", "test"); encryptContextMap.put("caching", "encrypt"); // Construct the encryption configuration HuaweiConfig config = HuaweiConfig.builder().buildSk(SECRET_ACCESS_KEY) .buildAk(ACCESS_KEY) .buildKmsConfig(Collections.singletonList(new KMSConfig(REGION, KEYID, PROJECT_ID, ENDPOINT))) .buildCryptoAlgorithm(CryptoAlgorithm.AES_256_GCM_NOPADDING) .build(); HuaweiCrypto huaweiCrypto = new HuaweiCrypto(config); // Set the key ring. huaweiCrypto.withKeyring(new KmsKeyringFactory().getKeyring(KeyringTypeEnum.KMS_MULTI_REGION.getType())); // Encrypt the file. encryptFile(encryptContextMap, huaweiCrypto, encryptFileInPutPath, encryptFileOutPutPath); // Decrypt the file. decryptFile(huaweiCrypto, encryptFileOutPutPath, decryptFileOutPutPath); } private static void encryptFile(Map<String, String> encryptContextMap, HuaweiCrypto huaweiCrypto, String encryptFileInPutPath, String encryptFileOutPutPath) throws IOException { // fileInputStream: input stream corresponding to the encrypted file FileInputStream fileInputStream = new FileInputStream(encryptFileInPutPath); // fileOutputStream: output stream corresponding to the source file FileOutputStream fileOutputStream = new FileOutputStream(encryptFileOutPutPath); // Encryption huaweiCrypto.encrypt(fileInputStream, fileOutputStream, encryptContextMap); fileInputStream.close(); fileOutputStream.close(); } private static void decryptFile(HuaweiCrypto huaweiCrypto, String decryptFileInPutPath, String decryptFileOutPutPath) throws IOException { // in: input stream corresponding to the source file FileInputStream fileInputStream = new FileInputStream(decryptFileInPutPath); // out: output stream corresponding to the encrypted file FileOutputStream fileOutputStream = new FileOutputStream(decryptFileOutPutPath); // Decryption huaweiCrypto.decrypt(fileInputStream, fileOutputStream); fileInputStream.close(); fileOutputStream.close(); } }