Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Key Management Service
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Keys
    • Key version
    • Data encryption
  • Concepts
    • Overview
    • Keys
    • Key version
    • Encryption
    • Envelope encryption
    • Key consistency
    • Quotas and limits
  • Use cases
    • All use cases
    • Data encryption
      • Which encryption method should I choose?
      • Encrypting data using the Yandex.Cloud CLI and API
      • Encrypting data using the Yandex.Cloud SDK
      • Encrypting data using the AWS Encryption SDK
      • Encrypting data using Google Tink
    • Encrypting secrets in Managed Service for Kubernetes
    • KMS key management with Hashicorp Terraform
    • Encrypting secrets in Hashicorp Terraform
  • Access management
  • Pricing policy
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • SymmetricCryptoService
      • SymmetricKeyService
      • OperationService
    • REST
      • Overview
      • SymmetricCrypto
        • Overview
        • decrypt
        • encrypt
        • generateDataKey
        • reEncrypt
      • SymmetricKey
        • Overview
        • cancelVersionDestruction
        • create
        • delete
        • get
        • list
        • listAccessBindings
        • listOperations
        • listVersions
        • rotate
        • scheduleVersionDestruction
        • setAccessBindings
        • setPrimaryVersion
        • update
        • updateAccessBindings
  • Questions and answers
  1. Use cases
  2. Data encryption
  3. Encrypting data using the AWS Encryption SDK

Encrypting data using the AWS Encryption SDK

  • Adding dependencies
  • Encryption and decryption

The AWS Encryption SDK is a library that simplifies the process of encrypting and decrypting data. Use it if you want to securely encrypt data without going into the details of encryption algorithms.

The Yandex.Cloud provider for the AWS Encryption SDK lets you use the AWS Encryption SDK to encrypt and decrypt data with Yandex.Cloud KMS keys. Data is encrypted using envelope encryption (the size of plaintext is not limited). The provider is only supported for Java.

Adding dependencies

Before you start, you need to add dependencies.

Java

Add dependencies using Apache Maven:

<dependency>
    <groupId>com.yandex.cloud</groupId>
    <artifactId>kms-provider-awscrypto</artifactId>
    <version>1.0</version>
</dependency>

Encryption and decryption

Create a Yandex.Cloud provider for the AWS Encryption SDK and use the methods of the AwsCrypto class to encrypt and decrypt data.

Java
YcKmsMasterKeyProvider provider = YcKmsMasterKeyProvider.builder()
    .setCredentialsSupplier(() -> credentials)
    .setKeyId(keyId)
    .build();
AwsCrypto awsCrypto = new AwsCrypto();

...

byte[] ciphertext = awsCrypto.encryptData(provider, plaintext, aad).getResult();

...

byte[] plaintext = awsCrypto.decryptData(provider, ciphertext).getResult();

Where:

  • credentials: Determines the authentication method (for more information, see Authentication in the Yandex.Cloud SDK).
  • keyId: ID of the key in KMS.
  • plaintext: Unencrypted text.
  • ciphertext: Encrypted text.
  • aad: AAD context.

See also

  • AWS Encryption SDK.
  • Yandex.Cloud provider for the AWS Encryption SDK.
  • Examples of using Yandex.Cloud KMS Providers for the AWS Encryption SDK.
In this article:
  • Adding dependencies
  • Encryption and decryption
Language
Careers
Privacy policy
Terms of use
© 2021 Yandex.Cloud LLC