summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/current.txt62
-rw-r--r--keystore/java/android/security/AndroidKeyPairGenerator.java14
-rw-r--r--keystore/java/android/security/AndroidKeyStore.java9
-rw-r--r--keystore/java/android/security/AndroidKeyStoreProvider.java4
-rw-r--r--keystore/java/android/security/KeyPairGeneratorSpec.java (renamed from keystore/java/android/security/AndroidKeyPairGeneratorSpec.java)34
-rw-r--r--keystore/java/android/security/KeyStoreParameter.java (renamed from keystore/java/android/security/AndroidKeyStoreParameter.java)41
-rw-r--r--keystore/tests/src/android/security/AndroidKeyPairGeneratorTest.java18
-rw-r--r--keystore/tests/src/android/security/AndroidKeyStoreTest.java14
-rw-r--r--keystore/tests/src/android/security/KeyPairGeneratorSpecTest.java (renamed from keystore/tests/src/android/security/AndroidKeyPairGeneratorSpecTest.java)22
9 files changed, 111 insertions, 107 deletions
diff --git a/api/current.txt b/api/current.txt
index 803bb02..62c90df 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -21120,37 +21120,6 @@ package android.sax {
package android.security {
- public final class AndroidKeyPairGeneratorSpec implements java.security.spec.AlgorithmParameterSpec {
- method public android.content.Context getContext();
- method public java.util.Date getEndDate();
- method public java.lang.String getKeystoreAlias();
- method public java.math.BigInteger getSerialNumber();
- method public java.util.Date getStartDate();
- method public javax.security.auth.x500.X500Principal getSubjectDN();
- method public boolean isEncryptionRequired();
- }
-
- public static final class AndroidKeyPairGeneratorSpec.Builder {
- ctor public AndroidKeyPairGeneratorSpec.Builder(android.content.Context);
- method public android.security.AndroidKeyPairGeneratorSpec build();
- method public android.security.AndroidKeyPairGeneratorSpec.Builder setAlias(java.lang.String);
- method public android.security.AndroidKeyPairGeneratorSpec.Builder setEncryptionRequired();
- method public android.security.AndroidKeyPairGeneratorSpec.Builder setEndDate(java.util.Date);
- method public android.security.AndroidKeyPairGeneratorSpec.Builder setSerialNumber(java.math.BigInteger);
- method public android.security.AndroidKeyPairGeneratorSpec.Builder setStartDate(java.util.Date);
- method public android.security.AndroidKeyPairGeneratorSpec.Builder setSubject(javax.security.auth.x500.X500Principal);
- }
-
- public final class AndroidKeyStoreParameter implements java.security.KeyStore.ProtectionParameter {
- method public boolean isEncryptionRequired();
- }
-
- public static final class AndroidKeyStoreParameter.Builder {
- ctor public AndroidKeyStoreParameter.Builder(android.content.Context);
- method public android.security.AndroidKeyStoreParameter build();
- method public android.security.AndroidKeyStoreParameter.Builder setEncryptionRequired();
- }
-
public final class KeyChain {
ctor public KeyChain();
method public static void choosePrivateKeyAlias(android.app.Activity, android.security.KeyChainAliasCallback, java.lang.String[], java.security.Principal[], java.lang.String, int, java.lang.String);
@@ -21176,6 +21145,37 @@ package android.security {
ctor public KeyChainException(java.lang.Throwable);
}
+ public final class KeyPairGeneratorSpec implements java.security.spec.AlgorithmParameterSpec {
+ method public android.content.Context getContext();
+ method public java.util.Date getEndDate();
+ method public java.lang.String getKeystoreAlias();
+ method public java.math.BigInteger getSerialNumber();
+ method public java.util.Date getStartDate();
+ method public javax.security.auth.x500.X500Principal getSubjectDN();
+ method public boolean isEncryptionRequired();
+ }
+
+ public static final class KeyPairGeneratorSpec.Builder {
+ ctor public KeyPairGeneratorSpec.Builder(android.content.Context);
+ method public android.security.KeyPairGeneratorSpec build();
+ method public android.security.KeyPairGeneratorSpec.Builder setAlias(java.lang.String);
+ method public android.security.KeyPairGeneratorSpec.Builder setEncryptionRequired();
+ method public android.security.KeyPairGeneratorSpec.Builder setEndDate(java.util.Date);
+ method public android.security.KeyPairGeneratorSpec.Builder setSerialNumber(java.math.BigInteger);
+ method public android.security.KeyPairGeneratorSpec.Builder setStartDate(java.util.Date);
+ method public android.security.KeyPairGeneratorSpec.Builder setSubject(javax.security.auth.x500.X500Principal);
+ }
+
+ public final class KeyStoreParameter implements java.security.KeyStore.ProtectionParameter {
+ method public boolean isEncryptionRequired();
+ }
+
+ public static final class KeyStoreParameter.Builder {
+ ctor public KeyStoreParameter.Builder(android.content.Context);
+ method public android.security.KeyStoreParameter build();
+ method public android.security.KeyStoreParameter.Builder setEncryptionRequired(boolean);
+ }
+
}
package android.service.dreams {
diff --git a/keystore/java/android/security/AndroidKeyPairGenerator.java b/keystore/java/android/security/AndroidKeyPairGenerator.java
index 6975583..43d1eb6 100644
--- a/keystore/java/android/security/AndroidKeyPairGenerator.java
+++ b/keystore/java/android/security/AndroidKeyPairGenerator.java
@@ -52,12 +52,12 @@ import java.security.spec.X509EncodedKeySpec;
public class AndroidKeyPairGenerator extends KeyPairGeneratorSpi {
private android.security.KeyStore mKeyStore;
- private AndroidKeyPairGeneratorSpec mSpec;
+ private KeyPairGeneratorSpec mSpec;
/**
* Generate a KeyPair which is backed by the Android keystore service. You
* must call {@link KeyPairGenerator#initialize(AlgorithmParameterSpec)}
- * with an {@link AndroidKeyPairGeneratorSpec} as the {@code params}
+ * with an {@link KeyPairGeneratorSpec} as the {@code params}
* argument before calling this otherwise an {@code IllegalStateException}
* will be thrown.
* <p>
@@ -73,7 +73,7 @@ public class AndroidKeyPairGenerator extends KeyPairGeneratorSpi {
public KeyPair generateKeyPair() {
if (mKeyStore == null || mSpec == null) {
throw new IllegalStateException(
- "Must call initialize with an AndroidKeyPairGeneratorSpec first");
+ "Must call initialize with an android.security.KeyPairGeneratorSpec first");
}
if (((mSpec.getFlags() & KeyStore.FLAG_ENCRYPTED) != 0)
@@ -156,13 +156,13 @@ public class AndroidKeyPairGenerator extends KeyPairGeneratorSpi {
throws InvalidAlgorithmParameterException {
if (params == null) {
throw new InvalidAlgorithmParameterException(
- "must supply params of type AndroidKeyPairGenericSpec");
- } else if (!(params instanceof AndroidKeyPairGeneratorSpec)) {
+ "must supply params of type android.security.KeyPairGeneratorSpec");
+ } else if (!(params instanceof KeyPairGeneratorSpec)) {
throw new InvalidAlgorithmParameterException(
- "params must be of type AndroidKeyPairGeneratorSpec");
+ "params must be of type android.security.KeyPairGeneratorSpec");
}
- AndroidKeyPairGeneratorSpec spec = (AndroidKeyPairGeneratorSpec) params;
+ KeyPairGeneratorSpec spec = (KeyPairGeneratorSpec) params;
mSpec = spec;
mKeyStore = android.security.KeyStore.getInstance();
diff --git a/keystore/java/android/security/AndroidKeyStore.java b/keystore/java/android/security/AndroidKeyStore.java
index dcc9516..04ee8c4 100644
--- a/keystore/java/android/security/AndroidKeyStore.java
+++ b/keystore/java/android/security/AndroidKeyStore.java
@@ -209,7 +209,7 @@ public class AndroidKeyStore extends KeyStoreSpi {
}
private void setPrivateKeyEntry(String alias, PrivateKey key, Certificate[] chain,
- AndroidKeyStoreParameter params) throws KeyStoreException {
+ KeyStoreParameter params) throws KeyStoreException {
byte[] keyBytes = null;
final String pkeyAlias;
@@ -544,15 +544,16 @@ public class AndroidKeyStore extends KeyStoreSpi {
return;
}
- if (param != null && !(param instanceof AndroidKeyStoreParameter)) {
- throw new KeyStoreException("protParam should be AndroidKeyStoreParameter; was: "
+ if (param != null && !(param instanceof KeyStoreParameter)) {
+ throw new KeyStoreException(
+ "protParam should be android.security.KeyStoreParameter; was: "
+ param.getClass().getName());
}
if (entry instanceof PrivateKeyEntry) {
PrivateKeyEntry prE = (PrivateKeyEntry) entry;
setPrivateKeyEntry(alias, prE.getPrivateKey(), prE.getCertificateChain(),
- (AndroidKeyStoreParameter) param);
+ (KeyStoreParameter) param);
return;
}
diff --git a/keystore/java/android/security/AndroidKeyStoreProvider.java b/keystore/java/android/security/AndroidKeyStoreProvider.java
index 8ca301e..b17e450 100644
--- a/keystore/java/android/security/AndroidKeyStoreProvider.java
+++ b/keystore/java/android/security/AndroidKeyStoreProvider.java
@@ -24,7 +24,7 @@ import java.security.Provider;
* @hide
*/
public class AndroidKeyStoreProvider extends Provider {
- public static final String PROVIDER_NAME = "AndroidKeyStoreProvider";
+ public static final String PROVIDER_NAME = "AndroidKeyStore";
public AndroidKeyStoreProvider() {
super(PROVIDER_NAME, 1.0, "Android KeyStore security provider");
@@ -33,6 +33,6 @@ public class AndroidKeyStoreProvider extends Provider {
put("KeyStore." + AndroidKeyStore.NAME, AndroidKeyStore.class.getName());
// java.security.KeyPairGenerator
- put("KeyPairGenerator." + AndroidKeyStore.NAME, AndroidKeyPairGenerator.class.getName());
+ put("KeyPairGenerator.RSA", AndroidKeyPairGenerator.class.getName());
}
}
diff --git a/keystore/java/android/security/AndroidKeyPairGeneratorSpec.java b/keystore/java/android/security/KeyPairGeneratorSpec.java
index b126f03..59f89bc 100644
--- a/keystore/java/android/security/AndroidKeyPairGeneratorSpec.java
+++ b/keystore/java/android/security/KeyPairGeneratorSpec.java
@@ -29,9 +29,9 @@ import javax.security.auth.x500.X500Principal;
/**
* This provides the required parameters needed for initializing the
- * {@code KeyPairGenerator} that works with <a href="{@docRoot}
- * guide/topics/security/keystore.html">Android KeyStore facility</a>. The
- * Android KeyStore facility is accessed through a
+ * {@code KeyPairGenerator} that works with
+ * <a href="{@docRoot}guide/topics/security/keystore.html">Android KeyStore
+ * facility</a>. The Android KeyStore facility is accessed through a
* {@link java.security.KeyPairGenerator} API using the {@code AndroidKeyStore}
* provider. The {@code context} passed in may be used to pop up some UI to ask
* the user to unlock or initialize the Android KeyStore facility.
@@ -49,7 +49,7 @@ import javax.security.auth.x500.X500Principal;
* The self-signed X.509 certificate may be replaced at a later time by a
* certificate signed by a real Certificate Authority.
*/
-public final class AndroidKeyPairGeneratorSpec implements AlgorithmParameterSpec {
+public final class KeyPairGeneratorSpec implements AlgorithmParameterSpec {
private final String mKeystoreAlias;
private final Context mContext;
@@ -91,9 +91,9 @@ public final class AndroidKeyPairGeneratorSpec implements AlgorithmParameterSpec
* period
* @throws IllegalArgumentException when any argument is {@code null} or
* {@code endDate} is before {@code startDate}.
- * @hide should be built with AndroidKeyPairGeneratorSpecBuilder
+ * @hide should be built with KeyPairGeneratorSpecBuilder
*/
- public AndroidKeyPairGeneratorSpec(Context context, String keyStoreAlias,
+ public KeyPairGeneratorSpec(Context context, String keyStoreAlias,
X500Principal subjectDN, BigInteger serialNumber, Date startDate, Date endDate,
int flags) {
if (context == null) {
@@ -184,7 +184,7 @@ public final class AndroidKeyPairGeneratorSpec implements AlgorithmParameterSpec
}
/**
- * Builder class for {@link AndroidKeyPairGeneratorSpec} objects.
+ * Builder class for {@link KeyPairGeneratorSpec} objects.
* <p>
* This will build a parameter spec for use with the <a href="{@docRoot}
* guide/topics/security/keystore.html">Android KeyStore facility</a>.
@@ -198,14 +198,10 @@ public final class AndroidKeyPairGeneratorSpec implements AlgorithmParameterSpec
* Calendar end = new Calendar();
* end.add(1, Calendar.YEAR);
*
- * AndroidKeyPairGeneratorSpec spec =
- * new AndroidKeyPairGeneratorSpec.Builder(mContext)
- * .setAlias(&quot;myKey&quot;)
- * .setSubject(new X500Principal(&quot;CN=myKey&quot;))
- * .setSerial(BigInteger.valueOf(1337))
- * .setStartDate(start.getTime())
- * .setEndDate(end.getTime())
- * .build();
+ * KeyPairGeneratorSpec spec =
+ * new KeyPairGeneratorSpec.Builder(mContext).setAlias(&quot;myKey&quot;)
+ * .setSubject(new X500Principal(&quot;CN=myKey&quot;)).setSerial(BigInteger.valueOf(1337))
+ * .setStartDate(start.getTime()).setEndDate(end.getTime()).build();
* </pre>
*/
public final static class Builder {
@@ -309,13 +305,13 @@ public final class AndroidKeyPairGeneratorSpec implements AlgorithmParameterSpec
}
/**
- * Builds the instance of the {@code AndroidKeyPairGeneratorSpec}.
+ * Builds the instance of the {@code KeyPairGeneratorSpec}.
*
* @throws IllegalArgumentException if a required field is missing
- * @return built instance of {@code AndroidKeyPairGeneratorSpec}
+ * @return built instance of {@code KeyPairGeneratorSpec}
*/
- public AndroidKeyPairGeneratorSpec build() {
- return new AndroidKeyPairGeneratorSpec(mContext, mKeystoreAlias, mSubjectDN,
+ public KeyPairGeneratorSpec build() {
+ return new KeyPairGeneratorSpec(mContext, mKeystoreAlias, mSubjectDN,
mSerialNumber, mStartDate, mEndDate, mFlags);
}
}
diff --git a/keystore/java/android/security/AndroidKeyStoreParameter.java b/keystore/java/android/security/KeyStoreParameter.java
index 44f57c4..621a605 100644
--- a/keystore/java/android/security/AndroidKeyStoreParameter.java
+++ b/keystore/java/android/security/KeyStoreParameter.java
@@ -17,7 +17,7 @@
package android.security;
import android.content.Context;
-import android.security.AndroidKeyPairGeneratorSpec.Builder;
+import android.security.KeyPairGeneratorSpec.Builder;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
@@ -26,9 +26,9 @@ import java.security.cert.Certificate;
/**
* This provides the optional parameters that can be specified for
- * {@code KeyStore} entries that work with <a href="{@docRoot}
- * guide/topics/security/keystore.html">Android KeyStore facility</a>. The
- * Android KeyStore facility is accessed through a
+ * {@code KeyStore} entries that work with
+ * <a href="{@docRoot}guide/topics/security/keystore.html">Android KeyStore
+ * facility</a>. The Android KeyStore facility is accessed through a
* {@link java.security.KeyStore} API using the {@code AndroidKeyStore}
* provider. The {@code context} passed in may be used to pop up some UI to ask
* the user to unlock or initialize the Android KeyStore facility.
@@ -39,15 +39,15 @@ import java.security.cert.Certificate;
* {@code KeyStore}.
* <p>
* Keys may be generated using the {@link KeyPairGenerator} facility with a
- * {@link AndroidKeyPairGeneratorSpec} to specify the entry's {@code alias}. A
+ * {@link KeyPairGeneratorSpec} to specify the entry's {@code alias}. A
* self-signed X.509 certificate will be attached to generated entries, but that
* may be replaced at a later time by a certificate signed by a real Certificate
* Authority.
*/
-public final class AndroidKeyStoreParameter implements ProtectionParameter {
+public final class KeyStoreParameter implements ProtectionParameter {
private int mFlags;
- private AndroidKeyStoreParameter(int flags) {
+ private KeyStoreParameter(int flags) {
mFlags = flags;
}
@@ -67,10 +67,10 @@ public final class AndroidKeyStoreParameter implements ProtectionParameter {
}
/**
- * Builder class for {@link AndroidKeyStoreParameter} objects.
+ * Builder class for {@link KeyStoreParameter} objects.
* <p>
- * This will build protection parameters for use with the <a
- * href="{@docRoot} guide/topics/security/keystore.html">Android KeyStore
+ * This will build protection parameters for use with the
+ * <a href="{@docRoot}guide/topics/security/keystore.html">Android KeyStore
* facility</a>.
* <p>
* This can be used to require that KeyStore entries be stored encrypted.
@@ -78,8 +78,9 @@ public final class AndroidKeyStoreParameter implements ProtectionParameter {
* Example:
*
* <pre class="prettyprint">
- * AndroidKeyStoreParameter params =
- * new AndroidKeyStoreParameter.Builder(mContext).setEncryptionRequired().build();
+ * KeyStoreParameter params = new KeyStoreParameter.Builder(mContext)
+ * .setEncryptionRequired()
+ * .build();
* </pre>
*/
public final static class Builder {
@@ -105,19 +106,23 @@ public final class AndroidKeyStoreParameter implements ProtectionParameter {
* screen (e.g., PIN, password) before creating or using the generated
* key is successful.
*/
- public Builder setEncryptionRequired() {
- mFlags |= KeyStore.FLAG_ENCRYPTED;
+ public Builder setEncryptionRequired(boolean required) {
+ if (required) {
+ mFlags |= KeyStore.FLAG_ENCRYPTED;
+ } else {
+ mFlags &= ~KeyStore.FLAG_ENCRYPTED;
+ }
return this;
}
/**
- * Builds the instance of the {@code AndroidKeyPairGeneratorSpec}.
+ * Builds the instance of the {@code KeyPairGeneratorSpec}.
*
* @throws IllegalArgumentException if a required field is missing
- * @return built instance of {@code AndroidKeyPairGeneratorSpec}
+ * @return built instance of {@code KeyPairGeneratorSpec}
*/
- public AndroidKeyStoreParameter build() {
- return new AndroidKeyStoreParameter(mFlags);
+ public KeyStoreParameter build() {
+ return new KeyStoreParameter(mFlags);
}
}
}
diff --git a/keystore/tests/src/android/security/AndroidKeyPairGeneratorTest.java b/keystore/tests/src/android/security/AndroidKeyPairGeneratorTest.java
index c5cf514..1582f74 100644
--- a/keystore/tests/src/android/security/AndroidKeyPairGeneratorTest.java
+++ b/keystore/tests/src/android/security/AndroidKeyPairGeneratorTest.java
@@ -65,7 +65,7 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {
assertFalse(mAndroidKeyStore.isUnlocked());
- mGenerator = java.security.KeyPairGenerator.getInstance("AndroidKeyStore");
+ mGenerator = java.security.KeyPairGenerator.getInstance("RSA", "AndroidKeyStore");
}
private void setupPassword() {
@@ -80,7 +80,7 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {
public void testKeyPairGenerator_Initialize_Params_Encrypted_Success() throws Exception {
setupPassword();
- mGenerator.initialize(new AndroidKeyPairGeneratorSpec.Builder(getContext())
+ mGenerator.initialize(new KeyPairGeneratorSpec.Builder(getContext())
.setAlias(TEST_ALIAS_1)
.setSubject(TEST_DN_1)
.setSerialNumber(TEST_SERIAL_1)
@@ -116,7 +116,7 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {
setupPassword();
mGenerator.initialize(
- new AndroidKeyPairGeneratorSpec.Builder(getContext())
+ new KeyPairGeneratorSpec.Builder(getContext())
.setAlias(TEST_ALIAS_1)
.setSubject(TEST_DN_1)
.setSerialNumber(TEST_SERIAL_1)
@@ -130,7 +130,7 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {
public void testKeyPairGenerator_GenerateKeyPair_Encrypted_Success() throws Exception {
setupPassword();
- mGenerator.initialize(new AndroidKeyPairGeneratorSpec.Builder(getContext())
+ mGenerator.initialize(new KeyPairGeneratorSpec.Builder(getContext())
.setAlias(TEST_ALIAS_1)
.setSubject(TEST_DN_1)
.setSerialNumber(TEST_SERIAL_1)
@@ -146,7 +146,7 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {
}
public void testKeyPairGenerator_GenerateKeyPair_Unencrypted_Success() throws Exception {
- mGenerator.initialize(new AndroidKeyPairGeneratorSpec.Builder(getContext())
+ mGenerator.initialize(new KeyPairGeneratorSpec.Builder(getContext())
.setAlias(TEST_ALIAS_1)
.setSubject(TEST_DN_1)
.setSerialNumber(TEST_SERIAL_1)
@@ -163,7 +163,7 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {
public void testKeyPairGenerator_GenerateKeyPair_Replaced_Success() throws Exception {
// Generate the first key
{
- mGenerator.initialize(new AndroidKeyPairGeneratorSpec.Builder(getContext())
+ mGenerator.initialize(new KeyPairGeneratorSpec.Builder(getContext())
.setAlias(TEST_ALIAS_1)
.setSubject(TEST_DN_1)
.setSerialNumber(TEST_SERIAL_1)
@@ -178,7 +178,7 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {
// Replace the original key
{
- mGenerator.initialize(new AndroidKeyPairGeneratorSpec.Builder(getContext())
+ mGenerator.initialize(new KeyPairGeneratorSpec.Builder(getContext())
.setAlias(TEST_ALIAS_2)
.setSubject(TEST_DN_2)
.setSerialNumber(TEST_SERIAL_2)
@@ -196,7 +196,7 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {
throws Exception {
// Generate the first key
{
- mGenerator.initialize(new AndroidKeyPairGeneratorSpec.Builder(getContext())
+ mGenerator.initialize(new KeyPairGeneratorSpec.Builder(getContext())
.setAlias(TEST_ALIAS_1)
.setSubject(TEST_DN_1)
.setSerialNumber(TEST_SERIAL_1)
@@ -211,7 +211,7 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {
// Attempt to replace previous key
{
- mGenerator.initialize(new AndroidKeyPairGeneratorSpec.Builder(getContext())
+ mGenerator.initialize(new KeyPairGeneratorSpec.Builder(getContext())
.setAlias(TEST_ALIAS_1)
.setSubject(TEST_DN_2)
.setSerialNumber(TEST_SERIAL_2)
diff --git a/keystore/tests/src/android/security/AndroidKeyStoreTest.java b/keystore/tests/src/android/security/AndroidKeyStoreTest.java
index 507d41c..8798fb5 100644
--- a/keystore/tests/src/android/security/AndroidKeyStoreTest.java
+++ b/keystore/tests/src/android/security/AndroidKeyStoreTest.java
@@ -1232,8 +1232,8 @@ public class AndroidKeyStoreTest extends AndroidTestCase {
try {
mKeyStore.setEntry(TEST_ALIAS_1, entry,
- new AndroidKeyStoreParameter.Builder(getContext())
- .setEncryptionRequired()
+ new KeyStoreParameter.Builder(getContext())
+ .setEncryptionRequired(true)
.build());
fail("Shouldn't be able to insert encrypted entry when KeyStore uninitialized");
} catch (KeyStoreException expected) {
@@ -1752,8 +1752,10 @@ public class AndroidKeyStoreTest extends AndroidTestCase {
Entry entry = mKeyStore.getEntry(TEST_ALIAS_1, null);
try {
- mKeyStore.setEntry(TEST_ALIAS_1, entry, new AndroidKeyStoreParameter.Builder(
- getContext()).setEncryptionRequired().build());
+ mKeyStore.setEntry(TEST_ALIAS_1, entry,
+ new KeyStoreParameter.Builder(getContext())
+ .setEncryptionRequired(true)
+ .build());
fail("Should not allow setting of Entry without unlocked keystore");
} catch (KeyStoreException success) {
}
@@ -1762,8 +1764,8 @@ public class AndroidKeyStoreTest extends AndroidTestCase {
assertTrue(mAndroidKeyStore.isUnlocked());
mKeyStore.setEntry(TEST_ALIAS_1, entry,
- new AndroidKeyStoreParameter.Builder(getContext())
- .setEncryptionRequired()
+ new KeyStoreParameter.Builder(getContext())
+ .setEncryptionRequired(true)
.build());
}
}
diff --git a/keystore/tests/src/android/security/AndroidKeyPairGeneratorSpecTest.java b/keystore/tests/src/android/security/KeyPairGeneratorSpecTest.java
index 5d4ab9c..113d730 100644
--- a/keystore/tests/src/android/security/AndroidKeyPairGeneratorSpecTest.java
+++ b/keystore/tests/src/android/security/KeyPairGeneratorSpecTest.java
@@ -23,7 +23,7 @@ import java.util.Date;
import javax.security.auth.x500.X500Principal;
-public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
+public class KeyPairGeneratorSpecTest extends AndroidTestCase {
private static final String TEST_ALIAS_1 = "test1";
private static final X500Principal TEST_DN_1 = new X500Principal("CN=test1");
@@ -39,8 +39,8 @@ public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
private static final Date NOW_PLUS_10_YEARS = new Date(NOW.getYear() + 10, 0, 1);
public void testConstructor_Success() throws Exception {
- AndroidKeyPairGeneratorSpec spec =
- new AndroidKeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, SERIAL_1,
+ KeyPairGeneratorSpec spec =
+ new KeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, SERIAL_1,
NOW, NOW_PLUS_10_YEARS, 0);
assertEquals("Context should be the one specified", getContext(), spec.getContext());
@@ -55,7 +55,7 @@ public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
}
public void testBuilder_Success() throws Exception {
- AndroidKeyPairGeneratorSpec spec = new AndroidKeyPairGeneratorSpec.Builder(getContext())
+ KeyPairGeneratorSpec spec = new KeyPairGeneratorSpec.Builder(getContext())
.setAlias(TEST_ALIAS_1)
.setSubject(TEST_DN_1)
.setSerialNumber(SERIAL_1)
@@ -79,7 +79,7 @@ public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
public void testConstructor_NullContext_Failure() throws Exception {
try {
- new AndroidKeyPairGeneratorSpec(null, TEST_ALIAS_1, TEST_DN_1, SERIAL_1, NOW,
+ new KeyPairGeneratorSpec(null, TEST_ALIAS_1, TEST_DN_1, SERIAL_1, NOW,
NOW_PLUS_10_YEARS, 0);
fail("Should throw IllegalArgumentException when context is null");
} catch (IllegalArgumentException success) {
@@ -88,7 +88,7 @@ public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
public void testConstructor_NullKeystoreAlias_Failure() throws Exception {
try {
- new AndroidKeyPairGeneratorSpec(getContext(), null, TEST_DN_1, SERIAL_1, NOW,
+ new KeyPairGeneratorSpec(getContext(), null, TEST_DN_1, SERIAL_1, NOW,
NOW_PLUS_10_YEARS, 0);
fail("Should throw IllegalArgumentException when keystoreAlias is null");
} catch (IllegalArgumentException success) {
@@ -97,7 +97,7 @@ public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
public void testConstructor_NullSubjectDN_Failure() throws Exception {
try {
- new AndroidKeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, null, SERIAL_1, NOW,
+ new KeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, null, SERIAL_1, NOW,
NOW_PLUS_10_YEARS, 0);
fail("Should throw IllegalArgumentException when subjectDN is null");
} catch (IllegalArgumentException success) {
@@ -106,7 +106,7 @@ public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
public void testConstructor_NullSerial_Failure() throws Exception {
try {
- new AndroidKeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, null, NOW,
+ new KeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, null, NOW,
NOW_PLUS_10_YEARS, 0);
fail("Should throw IllegalArgumentException when startDate is null");
} catch (IllegalArgumentException success) {
@@ -115,7 +115,7 @@ public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
public void testConstructor_NullStartDate_Failure() throws Exception {
try {
- new AndroidKeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, SERIAL_1, null,
+ new KeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, SERIAL_1, null,
NOW_PLUS_10_YEARS, 0);
fail("Should throw IllegalArgumentException when startDate is null");
} catch (IllegalArgumentException success) {
@@ -124,7 +124,7 @@ public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
public void testConstructor_NullEndDate_Failure() throws Exception {
try {
- new AndroidKeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, SERIAL_1, NOW,
+ new KeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, SERIAL_1, NOW,
null, 0);
fail("Should throw IllegalArgumentException when keystoreAlias is null");
} catch (IllegalArgumentException success) {
@@ -133,7 +133,7 @@ public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
public void testConstructor_EndBeforeStart_Failure() throws Exception {
try {
- new AndroidKeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, SERIAL_1,
+ new KeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, SERIAL_1,
NOW_PLUS_10_YEARS, NOW, 0);
fail("Should throw IllegalArgumentException when end is before start");
} catch (IllegalArgumentException success) {