diff options
author | ambrosin <ambrosin@google.com> | 2023-03-17 08:07:55 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-03-17 08:09:25 -0700 |
commit | b0239e26d0355a8d8141c863fc18a93f242db3d6 (patch) | |
tree | d257968d4c266e477d95d605a786f10007bea33f /java_src/examples | |
parent | dd698d4698506b702ba9454508846a4a9602fdcb (diff) | |
download | tink-b0239e26d0355a8d8141c863fc18a93f242db3d6.tar.gz |
Uniform comments for walkthrough examples.
PiperOrigin-RevId: 517415247
Diffstat (limited to 'java_src/examples')
3 files changed, 18 insertions, 21 deletions
diff --git a/java_src/examples/walkthrough/src/main/java/walkthrough/CreateKeysetExample.java b/java_src/examples/walkthrough/src/main/java/walkthrough/CreateKeysetExample.java index 3af87701c..42db6f5e9 100644 --- a/java_src/examples/walkthrough/src/main/java/walkthrough/CreateKeysetExample.java +++ b/java_src/examples/walkthrough/src/main/java/walkthrough/CreateKeysetExample.java @@ -23,6 +23,7 @@ import java.security.GeneralSecurityException; final class CreateKeysetExample { private CreateKeysetExample() {} // [END_EXCLUDE] + /** * Creates a keyset with a single AES128-GCM key and return a handle to it. * @@ -40,7 +41,5 @@ final class CreateKeysetExample { // generate a new keyset with only *one* key and return a keyset handle to it. return KeysetHandle.generateNew(KeyTemplates.get("AES128_GCM")); } - // [START_EXCLUDE] + // [END tink_walkthrough_create_keyset] } -// [END_EXCLUDE] -// [END tink_walkthrough_create_keyset] diff --git a/java_src/examples/walkthrough/src/main/java/walkthrough/ObtainAndUseAeadPrimitiveExample.java b/java_src/examples/walkthrough/src/main/java/walkthrough/ObtainAndUseAeadPrimitiveExample.java index d4bdb1a7f..247c06392 100644 --- a/java_src/examples/walkthrough/src/main/java/walkthrough/ObtainAndUseAeadPrimitiveExample.java +++ b/java_src/examples/walkthrough/src/main/java/walkthrough/ObtainAndUseAeadPrimitiveExample.java @@ -23,8 +23,9 @@ import java.security.GeneralSecurityException; final class ObtainAndUseAeadPrimitiveExample { private ObtainAndUseAeadPrimitiveExample() {} // [END_EXCLUDE] + /** - * Example to showcase obtaining an AEAD primitive from {@code keysetHandle} and encrypt/decrypt. + * Showcases obtaining an AEAD primitive from {@code keysetHandle} and encrypt/decrypt. * * <p>Prerequisites for this example: * @@ -44,7 +45,5 @@ final class ObtainAndUseAeadPrimitiveExample { byte[] ciphertext = aead.encrypt(plaintext, associatedData); return aead.decrypt(ciphertext, associatedData); } - // [START_EXCLUDE] + // [END tink_walkthrough_obtain_and_use_aead_primitive] } -// [END_EXCLUDE] -// [END tink_walkthrough_obtain_and_use_aead_primitive] diff --git a/java_src/examples/walkthrough/src/main/java/walkthrough/WriteKeysetExample.java b/java_src/examples/walkthrough/src/main/java/walkthrough/WriteKeysetExample.java index 97eb76094..90a323d73 100644 --- a/java_src/examples/walkthrough/src/main/java/walkthrough/WriteKeysetExample.java +++ b/java_src/examples/walkthrough/src/main/java/walkthrough/WriteKeysetExample.java @@ -11,34 +11,33 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ -// [START tink_walkthrough_write_keyset] package walkthrough; +// [START tink_walkthrough_write_keyset] import com.google.crypto.tink.Aead; import com.google.crypto.tink.KeysetHandle; import com.google.crypto.tink.KmsClients; import com.google.crypto.tink.TinkJsonProtoKeysetFormat; import java.security.GeneralSecurityException; -/** - * Examples to write a keyset to an output stream encrypted with a KMS key. - * - * <p>Prerequisites for this example: - * - * <ul> - * <li>Register AEAD implementations of Tink. - * <li>Register a KMS client to {@link KmsClients} that can use {@code kmsKekUri}. - * <li>Create a keyset and wrap it with a {@link KeysetHandle}. - * </ul> - */ +// [START_EXCLUDE] +/** Examples to write a keyset to an output stream encrypted with a KMS key. */ final class WriteKeysetExample { - // [START_EXCLUDE] private WriteKeysetExample() {} // [END_EXCLUDE] + /** * Serializes a keyset with handle {@code keysetHandle} in JSON format; the keyset is encrypted * through a KMS service using the KMS key {@code kmsKekUri} and {@code associatedData}. * + * <p>Prerequisites for this example: + * + * <ul> + * <li>Register AEAD implementations of Tink. + * <li>Register a KMS client to {@link KmsClients} that can use {@code kmsKekUri}. + * <li>Create a keyset and wrap it with a {@link KeysetHandle}. + * </ul> + * * @param associatedData the associated data to use for encrypting the keyset. See * https://developers.google.com/tink/aead#associated_data. * @return the serialized keyset. @@ -51,5 +50,5 @@ final class WriteKeysetExample { return TinkJsonProtoKeysetFormat.serializeEncryptedKeyset( keysetHandle, kmsKekAead, associatedData); } + // [END tink_walkthrough_write_keyset] } -// [END tink_walkthrough_write_keyset] |