diff options
author | Prashant Patil <patilprashant@google.com> | 2023-12-11 19:42:07 +0000 |
---|---|---|
committer | Prashant Patil <patilprashant@google.com> | 2023-12-11 19:42:07 +0000 |
commit | aab39d41736c29cd0e40c0b6dd19a611957df55b (patch) | |
tree | 922230029c38d959bf7c501abe297d3ac4daab71 | |
parent | e545a28a6b30c2c154400acb091c22c76b85453f (diff) | |
download | wycheproof-aab39d41736c29cd0e40c0b6dd19a611957df55b.tar.gz |
Handle FLAG_MGF1_DIGEST_SETTER enable and disable
The setMgf1Digests() API is flagged API, however initially this API is
used without checking whether Flag is enabled or disabled.
So these tests are updated to check whether FLAG_MGF1_DIGEST_SETTER flag
is enabled or disabled.
Bug: 308069562
Test: atest CtsKeystoreWycheproofTestCases:RsaOaepTest
Change-Id: If077503ca981dfa8628c4981627daae591a0f75e
-rw-r--r-- | keystore-cts/java/com/google/security/wycheproof/testcases/RsaOaepTest.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/keystore-cts/java/com/google/security/wycheproof/testcases/RsaOaepTest.java b/keystore-cts/java/com/google/security/wycheproof/testcases/RsaOaepTest.java index dbcc5ab..c0ee341 100644 --- a/keystore-cts/java/com/google/security/wycheproof/testcases/RsaOaepTest.java +++ b/keystore-cts/java/com/google/security/wycheproof/testcases/RsaOaepTest.java @@ -38,6 +38,7 @@ import javax.crypto.spec.PSource; import org.junit.After; import org.junit.Test; import org.junit.Ignore; +import android.security.Flags; import android.security.keystore.KeyProtection; import android.security.keystore.KeyProperties; import android.keystore.cts.util.KeyStoreUtil; @@ -66,9 +67,17 @@ public class RsaOaepTest { KeyProperties.PURPOSE_DECRYPT) .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_RSA_PKCS1, KeyProperties.ENCRYPTION_PADDING_RSA_OAEP) - .setDigests(digest) - .setMgf1Digests(mgfDigest) .setIsStrongBoxBacked(isStrongBox); + if (Flags.mgf1DigestSetter()) { + keyProtection.setDigests(digest); + keyProtection.setMgf1Digests(mgfDigest); + } else { + if (digest.equalsIgnoreCase(mgfDigest)) { + keyProtection.setDigests(digest); + } else { + keyProtection.setDigests(digest, mgfDigest); + } + } return (PrivateKey) KeyStoreUtil.saveKeysToKeystore(KEY_ALIAS_1, pubKey, privKey, keyProtection.build()).getKey(KEY_ALIAS_1, null); } |