From e0f6c088bcf4e4facfd8c1fb1428722e30e65f21 Mon Sep 17 00:00:00 2001 From: Eran Messeri Date: Wed, 15 Nov 2023 19:03:49 +0000 Subject: Make MGF1 Digest setter NotNull The MGF1 Digest setter should not accept a null vararg. It should not take in null at all. Bug: 302280420 Test: m Change-Id: I9db395d09e2fd0e609cd9019f3d3aedbb3244ef3 --- keystore/java/android/security/keystore/KeyGenParameterSpec.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'keystore/java') diff --git a/keystore/java/android/security/keystore/KeyGenParameterSpec.java b/keystore/java/android/security/keystore/KeyGenParameterSpec.java index b7140355e489..231fa4837441 100644 --- a/keystore/java/android/security/keystore/KeyGenParameterSpec.java +++ b/keystore/java/android/security/keystore/KeyGenParameterSpec.java @@ -1282,15 +1282,18 @@ public final class KeyGenParameterSpec implements AlgorithmParameterSpec, UserAu * function (MGF1) with a digest. * The default digest for MGF1 is {@code SHA-1}, which will be specified during key creation * time if no digests have been explicitly provided. - * When using the key, the caller may not specify any digests that were not provided during - * key creation time. The caller may specify the default digest, {@code SHA-1}, if no + * {@code null} may not be specified as a parameter to this method: It is not possible to + * disable MGF1 digest, a default must be present for when the caller tries to use it. + * + *

When using the key, the caller may not specify any digests that were not provided + * during key creation time. The caller may specify the default digest, {@code SHA-1}, if no * digests were explicitly provided during key creation (but it is not necessary to do so). * *

See {@link KeyProperties}.{@code DIGEST} constants. */ @NonNull @FlaggedApi("MGF1_DIGEST_SETTER") - public Builder setMgf1Digests(@Nullable @KeyProperties.DigestEnum String... mgf1Digests) { + public Builder setMgf1Digests(@NonNull @KeyProperties.DigestEnum String... mgf1Digests) { mMgf1Digests = Set.of(mgf1Digests); return this; } -- cgit v1.2.3-59-g8ed1b