Skip to content

docs(CommitmentPolicy): Detail Commitment Policy on Enum #913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/main/java/com/amazonaws/encryptionsdk/CommitmentPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,30 @@

package com.amazonaws.encryptionsdk;

/**
* Governs how a AwsCrypto behaves during configuration, encryption, and decryption, with respect to
* key commitment.
*/
public enum CommitmentPolicy {
/**
* On encrypty, algorithm suite must NOT support key commitment; On decrypt, if a key commitment
* is present on the ciphertext, then the key commitment must be valid. Key commitment will NOT be
* included in ciphertext on encrypt.
*/
ForbidEncryptAllowDecrypt,
/**
* On encrypt, algorithm suite must support key commitment; On decrypt, if a key commitment is
* present on the ciphertext, then the key commitment must be valid. Key commitment will be
* included in ciphertext on encrypt.
*/
RequireEncryptAllowDecrypt,
/**
* Algorithm suite must support key commitment. Key commitment will be included in ciphertext on
* encrypt. Valid key commitment must be present in ciphertext on decrypt.
*/
RequireEncryptRequireDecrypt;

/** Validates that an algorithm meets the Policy's On encrypt key commitment. */
public boolean algorithmAllowedForEncrypt(CryptoAlgorithm algorithm) {
switch (this) {
case ForbidEncryptAllowDecrypt:
Expand All @@ -21,6 +40,7 @@ public boolean algorithmAllowedForEncrypt(CryptoAlgorithm algorithm) {
}
}

/** Validates that an algorithm meets the Policy's On decrypt key commitment. */
public boolean algorithmAllowedForDecrypt(CryptoAlgorithm algorithm) {
switch (this) {
case ForbidEncryptAllowDecrypt:
Expand Down