dynamodb_encryption_sdk.internal.crypto.jce_bridge.encryption

Cipher resource for JCE bridge.

Warning

No guarantee is provided on the modules and APIs within this namespace staying consistent. Directly reference at your own risk.

Classes

JavaCipher(cipher, mode, padding)

Defines the encryption cipher, mode, and padding type to use for encryption.

class dynamodb_encryption_sdk.internal.crypto.jce_bridge.encryption.JavaCipher(cipher: dynamodb_encryption_sdk.internal.crypto.jce_bridge.primitives.JavaEncryptionAlgorithm, mode: dynamodb_encryption_sdk.internal.crypto.jce_bridge.primitives.JavaMode, padding: dynamodb_encryption_sdk.internal.crypto.jce_bridge.primitives.JavaPadding)[source]

Bases: object

Defines the encryption cipher, mode, and padding type to use for encryption.

https://docs.oracle.com/javase/8/docs/api/javax/crypto/Cipher.html

Parameters
encrypt(key, data)[source]

Encrypt data using loaded key.

Parameters
  • key – Key loaded by cipher

  • data (bytes) – Data to encrypt

Returns

Encrypted data

Return type

bytes

decrypt(key, data)[source]

Decrypt data using loaded key.

Parameters
  • key – Key loaded by cipher

  • data (bytes) – Data to decrypt

Returns

Decrypted data

Return type

bytes

wrap(wrapping_key, key_to_wrap)[source]

Wrap key using loaded key.

Parameters
  • wrapping_key – Key loaded by cipher

  • key_to_wrap (bytes) – Key to wrap

Returns

Wrapped key

Return type

bytes

unwrap(wrapping_key, wrapped_key)[source]

Wrap key using loaded key.

Parameters
  • wrapping_key – Key loaded by cipher

  • wrapped_key (bytes) – Wrapped key

Returns

Unwrapped key

Return type

bytes

property transformation

Returns the Java transformation describing this JavaCipher. https://docs.oracle.com/javase/8/docs/api/javax/crypto/Cipher.html https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#Cipher

Returns

Formatted transformation

Return type

str

classmethod from_transformation(cipher_transformation)[source]

Generates an JavaCipher object from the Java transformation. https://docs.oracle.com/javase/8/docs/api/javax/crypto/Cipher.html https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#Cipher

Parameters

cipher_transformation (str) – Formatted transformation

Returns

JavaCipher instance

Return type

JavaCipher