am c71f2648: Merge "frameworks/base: switch to using NativeConstants."
* commit 'c71f264847eb75d53c0f99e6e1c42a8a1527d3b4': frameworks/base: switch to using NativeConstants.
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
package android.security;
|
package android.security;
|
||||||
|
|
||||||
import com.android.org.bouncycastle.x509.X509V3CertificateGenerator;
|
import com.android.org.bouncycastle.x509.X509V3CertificateGenerator;
|
||||||
import com.android.org.conscrypt.NativeCrypto;
|
import com.android.org.conscrypt.NativeConstants;
|
||||||
import com.android.org.conscrypt.OpenSSLEngine;
|
import com.android.org.conscrypt.OpenSSLEngine;
|
||||||
|
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
@@ -206,9 +206,9 @@ public abstract class AndroidKeyPairGenerator extends KeyPairGeneratorSpi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static int getDefaultKeySize(int keyType) {
|
private static int getDefaultKeySize(int keyType) {
|
||||||
if (keyType == NativeCrypto.EVP_PKEY_EC) {
|
if (keyType == NativeConstants.EVP_PKEY_EC) {
|
||||||
return EC_DEFAULT_KEY_SIZE;
|
return EC_DEFAULT_KEY_SIZE;
|
||||||
} else if (keyType == NativeCrypto.EVP_PKEY_RSA) {
|
} else if (keyType == NativeConstants.EVP_PKEY_RSA) {
|
||||||
return RSA_DEFAULT_KEY_SIZE;
|
return RSA_DEFAULT_KEY_SIZE;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@@ -216,12 +216,12 @@ public abstract class AndroidKeyPairGenerator extends KeyPairGeneratorSpi {
|
|||||||
|
|
||||||
private static void checkValidKeySize(String keyAlgorithm, int keyType, int keySize)
|
private static void checkValidKeySize(String keyAlgorithm, int keyType, int keySize)
|
||||||
throws InvalidAlgorithmParameterException {
|
throws InvalidAlgorithmParameterException {
|
||||||
if (keyType == NativeCrypto.EVP_PKEY_EC) {
|
if (keyType == NativeConstants.EVP_PKEY_EC) {
|
||||||
if (keySize < EC_MIN_KEY_SIZE || keySize > EC_MAX_KEY_SIZE) {
|
if (keySize < EC_MIN_KEY_SIZE || keySize > EC_MAX_KEY_SIZE) {
|
||||||
throw new InvalidAlgorithmParameterException("EC keys must be >= "
|
throw new InvalidAlgorithmParameterException("EC keys must be >= "
|
||||||
+ EC_MIN_KEY_SIZE + " and <= " + EC_MAX_KEY_SIZE);
|
+ EC_MIN_KEY_SIZE + " and <= " + EC_MAX_KEY_SIZE);
|
||||||
}
|
}
|
||||||
} else if (keyType == NativeCrypto.EVP_PKEY_RSA) {
|
} else if (keyType == NativeConstants.EVP_PKEY_RSA) {
|
||||||
if (keySize < RSA_MIN_KEY_SIZE || keySize > RSA_MAX_KEY_SIZE) {
|
if (keySize < RSA_MIN_KEY_SIZE || keySize > RSA_MAX_KEY_SIZE) {
|
||||||
throw new InvalidAlgorithmParameterException("RSA keys must be >= "
|
throw new InvalidAlgorithmParameterException("RSA keys must be >= "
|
||||||
+ RSA_MIN_KEY_SIZE + " and <= " + RSA_MAX_KEY_SIZE);
|
+ RSA_MIN_KEY_SIZE + " and <= " + RSA_MAX_KEY_SIZE);
|
||||||
@@ -234,7 +234,7 @@ public abstract class AndroidKeyPairGenerator extends KeyPairGeneratorSpi {
|
|||||||
|
|
||||||
private static void checkCorrectParametersSpec(int keyType, int keySize,
|
private static void checkCorrectParametersSpec(int keyType, int keySize,
|
||||||
AlgorithmParameterSpec spec) throws InvalidAlgorithmParameterException {
|
AlgorithmParameterSpec spec) throws InvalidAlgorithmParameterException {
|
||||||
if (keyType == NativeCrypto.EVP_PKEY_RSA && spec != null) {
|
if (keyType == NativeConstants.EVP_PKEY_RSA && spec != null) {
|
||||||
if (spec instanceof RSAKeyGenParameterSpec) {
|
if (spec instanceof RSAKeyGenParameterSpec) {
|
||||||
RSAKeyGenParameterSpec rsaSpec = (RSAKeyGenParameterSpec) spec;
|
RSAKeyGenParameterSpec rsaSpec = (RSAKeyGenParameterSpec) spec;
|
||||||
if (keySize != -1 && keySize != rsaSpec.getKeysize()) {
|
if (keySize != -1 && keySize != rsaSpec.getKeysize()) {
|
||||||
@@ -260,7 +260,7 @@ public abstract class AndroidKeyPairGenerator extends KeyPairGeneratorSpi {
|
|||||||
|
|
||||||
private static byte[][] getArgsForKeyType(int keyType, AlgorithmParameterSpec spec) {
|
private static byte[][] getArgsForKeyType(int keyType, AlgorithmParameterSpec spec) {
|
||||||
switch (keyType) {
|
switch (keyType) {
|
||||||
case NativeCrypto.EVP_PKEY_RSA:
|
case NativeConstants.EVP_PKEY_RSA:
|
||||||
if (spec instanceof RSAKeyGenParameterSpec) {
|
if (spec instanceof RSAKeyGenParameterSpec) {
|
||||||
RSAKeyGenParameterSpec rsaSpec = (RSAKeyGenParameterSpec) spec;
|
RSAKeyGenParameterSpec rsaSpec = (RSAKeyGenParameterSpec) spec;
|
||||||
return new byte[][] { rsaSpec.getPublicExponent().toByteArray() };
|
return new byte[][] { rsaSpec.getPublicExponent().toByteArray() };
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package android.security;
|
package android.security;
|
||||||
|
|
||||||
import com.android.org.conscrypt.NativeCrypto;
|
import com.android.org.conscrypt.NativeConstants;
|
||||||
|
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
@@ -88,9 +88,9 @@ public class KeyStore {
|
|||||||
|
|
||||||
static int getKeyTypeForAlgorithm(String keyType) {
|
static int getKeyTypeForAlgorithm(String keyType) {
|
||||||
if ("RSA".equalsIgnoreCase(keyType)) {
|
if ("RSA".equalsIgnoreCase(keyType)) {
|
||||||
return NativeCrypto.EVP_PKEY_RSA;
|
return NativeConstants.EVP_PKEY_RSA;
|
||||||
} else if ("EC".equalsIgnoreCase(keyType)) {
|
} else if ("EC".equalsIgnoreCase(keyType)) {
|
||||||
return NativeCrypto.EVP_PKEY_EC;
|
return NativeConstants.EVP_PKEY_EC;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package android.security;
|
|||||||
|
|
||||||
import com.android.org.bouncycastle.x509.X509V3CertificateGenerator;
|
import com.android.org.bouncycastle.x509.X509V3CertificateGenerator;
|
||||||
|
|
||||||
import com.android.org.conscrypt.NativeCrypto;
|
import com.android.org.conscrypt.NativeConstants;
|
||||||
import com.android.org.conscrypt.OpenSSLEngine;
|
import com.android.org.conscrypt.OpenSSLEngine;
|
||||||
|
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
@@ -768,7 +768,7 @@ public class AndroidKeyStoreTest extends AndroidTestCase {
|
|||||||
assertAliases(new String[] {});
|
assertAliases(new String[] {});
|
||||||
|
|
||||||
assertTrue(mAndroidKeyStore.generate(Credentials.USER_PRIVATE_KEY + TEST_ALIAS_1,
|
assertTrue(mAndroidKeyStore.generate(Credentials.USER_PRIVATE_KEY + TEST_ALIAS_1,
|
||||||
KeyStore.UID_SELF, NativeCrypto.EVP_PKEY_RSA, 1024, KeyStore.FLAG_ENCRYPTED,
|
KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA, 1024, KeyStore.FLAG_ENCRYPTED,
|
||||||
null));
|
null));
|
||||||
|
|
||||||
assertAliases(new String[] { TEST_ALIAS_1 });
|
assertAliases(new String[] { TEST_ALIAS_1 });
|
||||||
@@ -797,7 +797,7 @@ public class AndroidKeyStoreTest extends AndroidTestCase {
|
|||||||
assertAliases(new String[] {});
|
assertAliases(new String[] {});
|
||||||
|
|
||||||
assertTrue(mAndroidKeyStore.generate(Credentials.USER_PRIVATE_KEY + TEST_ALIAS_1,
|
assertTrue(mAndroidKeyStore.generate(Credentials.USER_PRIVATE_KEY + TEST_ALIAS_1,
|
||||||
KeyStore.UID_SELF, NativeCrypto.EVP_PKEY_RSA, 1024, KeyStore.FLAG_ENCRYPTED,
|
KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA, 1024, KeyStore.FLAG_ENCRYPTED,
|
||||||
null));
|
null));
|
||||||
|
|
||||||
assertTrue("Should contain generated private key", mKeyStore.containsAlias(TEST_ALIAS_1));
|
assertTrue("Should contain generated private key", mKeyStore.containsAlias(TEST_ALIAS_1));
|
||||||
@@ -1963,7 +1963,7 @@ public class AndroidKeyStoreTest extends AndroidTestCase {
|
|||||||
{
|
{
|
||||||
final String privateKeyAlias = Credentials.USER_PRIVATE_KEY + TEST_ALIAS_1;
|
final String privateKeyAlias = Credentials.USER_PRIVATE_KEY + TEST_ALIAS_1;
|
||||||
assertTrue(mAndroidKeyStore.generate(privateKeyAlias, KeyStore.UID_SELF,
|
assertTrue(mAndroidKeyStore.generate(privateKeyAlias, KeyStore.UID_SELF,
|
||||||
NativeCrypto.EVP_PKEY_RSA, 1024, KeyStore.FLAG_ENCRYPTED, null));
|
NativeConstants.EVP_PKEY_RSA, 1024, KeyStore.FLAG_ENCRYPTED, null));
|
||||||
|
|
||||||
Key key = mKeyStore.getKey(TEST_ALIAS_1, null);
|
Key key = mKeyStore.getKey(TEST_ALIAS_1, null);
|
||||||
|
|
||||||
@@ -2019,7 +2019,7 @@ public class AndroidKeyStoreTest extends AndroidTestCase {
|
|||||||
{
|
{
|
||||||
final String privateKeyAlias = Credentials.USER_PRIVATE_KEY + TEST_ALIAS_1;
|
final String privateKeyAlias = Credentials.USER_PRIVATE_KEY + TEST_ALIAS_1;
|
||||||
assertTrue(mAndroidKeyStore.generate(privateKeyAlias, KeyStore.UID_SELF,
|
assertTrue(mAndroidKeyStore.generate(privateKeyAlias, KeyStore.UID_SELF,
|
||||||
NativeCrypto.EVP_PKEY_RSA, 1024, KeyStore.FLAG_ENCRYPTED, null));
|
NativeConstants.EVP_PKEY_RSA, 1024, KeyStore.FLAG_ENCRYPTED, null));
|
||||||
|
|
||||||
X509Certificate cert = generateCertificate(mAndroidKeyStore, TEST_ALIAS_1,
|
X509Certificate cert = generateCertificate(mAndroidKeyStore, TEST_ALIAS_1,
|
||||||
TEST_SERIAL_1, TEST_DN_1, NOW, NOW_PLUS_10_YEARS);
|
TEST_SERIAL_1, TEST_DN_1, NOW, NOW_PLUS_10_YEARS);
|
||||||
@@ -2032,7 +2032,7 @@ public class AndroidKeyStoreTest extends AndroidTestCase {
|
|||||||
{
|
{
|
||||||
final String privateKeyAlias = Credentials.USER_PRIVATE_KEY + TEST_ALIAS_2;
|
final String privateKeyAlias = Credentials.USER_PRIVATE_KEY + TEST_ALIAS_2;
|
||||||
assertTrue(mAndroidKeyStore.generate(privateKeyAlias, KeyStore.UID_SELF,
|
assertTrue(mAndroidKeyStore.generate(privateKeyAlias, KeyStore.UID_SELF,
|
||||||
NativeCrypto.EVP_PKEY_RSA, 1024, KeyStore.FLAG_ENCRYPTED, null));
|
NativeConstants.EVP_PKEY_RSA, 1024, KeyStore.FLAG_ENCRYPTED, null));
|
||||||
|
|
||||||
X509Certificate cert = generateCertificate(mAndroidKeyStore, TEST_ALIAS_2,
|
X509Certificate cert = generateCertificate(mAndroidKeyStore, TEST_ALIAS_2,
|
||||||
TEST_SERIAL_2, TEST_DN_2, NOW, NOW_PLUS_10_YEARS);
|
TEST_SERIAL_2, TEST_DN_2, NOW, NOW_PLUS_10_YEARS);
|
||||||
@@ -2064,7 +2064,7 @@ public class AndroidKeyStoreTest extends AndroidTestCase {
|
|||||||
{
|
{
|
||||||
final String privateKeyAlias = Credentials.USER_PRIVATE_KEY + TEST_ALIAS_1;
|
final String privateKeyAlias = Credentials.USER_PRIVATE_KEY + TEST_ALIAS_1;
|
||||||
assertTrue(mAndroidKeyStore.generate(privateKeyAlias,
|
assertTrue(mAndroidKeyStore.generate(privateKeyAlias,
|
||||||
android.security.KeyStore.UID_SELF, NativeCrypto.EVP_PKEY_RSA, 1024,
|
android.security.KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA, 1024,
|
||||||
android.security.KeyStore.FLAG_NONE, null));
|
android.security.KeyStore.FLAG_NONE, null));
|
||||||
|
|
||||||
X509Certificate cert =
|
X509Certificate cert =
|
||||||
@@ -2116,7 +2116,7 @@ public class AndroidKeyStoreTest extends AndroidTestCase {
|
|||||||
assertAliases(new String[] { TEST_ALIAS_1, TEST_ALIAS_2 });
|
assertAliases(new String[] { TEST_ALIAS_1, TEST_ALIAS_2 });
|
||||||
|
|
||||||
assertTrue(mAndroidKeyStore.generate(Credentials.USER_PRIVATE_KEY + TEST_ALIAS_3,
|
assertTrue(mAndroidKeyStore.generate(Credentials.USER_PRIVATE_KEY + TEST_ALIAS_3,
|
||||||
KeyStore.UID_SELF, NativeCrypto.EVP_PKEY_RSA, 1024, KeyStore.FLAG_ENCRYPTED,
|
KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA, 1024, KeyStore.FLAG_ENCRYPTED,
|
||||||
null));
|
null));
|
||||||
|
|
||||||
assertEquals("The keystore size should match expected", 3, mKeyStore.size());
|
assertEquals("The keystore size should match expected", 3, mKeyStore.size());
|
||||||
@@ -2184,7 +2184,7 @@ public class AndroidKeyStoreTest extends AndroidTestCase {
|
|||||||
private void setupKey() throws Exception {
|
private void setupKey() throws Exception {
|
||||||
final String privateKeyAlias = Credentials.USER_PRIVATE_KEY + TEST_ALIAS_1;
|
final String privateKeyAlias = Credentials.USER_PRIVATE_KEY + TEST_ALIAS_1;
|
||||||
assertTrue(mAndroidKeyStore
|
assertTrue(mAndroidKeyStore
|
||||||
.generate(privateKeyAlias, KeyStore.UID_SELF, NativeCrypto.EVP_PKEY_RSA, 1024,
|
.generate(privateKeyAlias, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA, 1024,
|
||||||
KeyStore.FLAG_ENCRYPTED, null));
|
KeyStore.FLAG_ENCRYPTED, null));
|
||||||
|
|
||||||
X509Certificate cert = generateCertificate(mAndroidKeyStore, TEST_ALIAS_1, TEST_SERIAL_1,
|
X509Certificate cert = generateCertificate(mAndroidKeyStore, TEST_ALIAS_1, TEST_SERIAL_1,
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import android.test.ActivityUnitTestCase;
|
|||||||
import android.test.AssertionFailedError;
|
import android.test.AssertionFailedError;
|
||||||
import android.test.MoreAsserts;
|
import android.test.MoreAsserts;
|
||||||
import android.test.suitebuilder.annotation.MediumTest;
|
import android.test.suitebuilder.annotation.MediumTest;
|
||||||
import com.android.org.conscrypt.NativeCrypto;
|
import com.android.org.conscrypt.NativeConstants;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -365,7 +365,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> {
|
|||||||
|
|
||||||
public void testGenerate_NotInitialized_Fail() throws Exception {
|
public void testGenerate_NotInitialized_Fail() throws Exception {
|
||||||
assertFalse("Should fail when keystore is not initialized",
|
assertFalse("Should fail when keystore is not initialized",
|
||||||
mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeCrypto.EVP_PKEY_RSA,
|
mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA,
|
||||||
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,7 +373,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> {
|
|||||||
mKeyStore.password(TEST_PASSWD);
|
mKeyStore.password(TEST_PASSWD);
|
||||||
mKeyStore.lock();
|
mKeyStore.lock();
|
||||||
assertFalse("Should fail when keystore is locked",
|
assertFalse("Should fail when keystore is locked",
|
||||||
mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeCrypto.EVP_PKEY_RSA,
|
mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA,
|
||||||
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,7 +381,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> {
|
|||||||
assertTrue(mKeyStore.password(TEST_PASSWD));
|
assertTrue(mKeyStore.password(TEST_PASSWD));
|
||||||
|
|
||||||
assertTrue("Should be able to generate key when unlocked",
|
assertTrue("Should be able to generate key when unlocked",
|
||||||
mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeCrypto.EVP_PKEY_RSA,
|
mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA,
|
||||||
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
||||||
assertTrue(mKeyStore.contains(TEST_KEYNAME));
|
assertTrue(mKeyStore.contains(TEST_KEYNAME));
|
||||||
assertFalse(mKeyStore.contains(TEST_KEYNAME, Process.WIFI_UID));
|
assertFalse(mKeyStore.contains(TEST_KEYNAME, Process.WIFI_UID));
|
||||||
@@ -391,7 +391,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> {
|
|||||||
assertTrue(mKeyStore.password(TEST_PASSWD));
|
assertTrue(mKeyStore.password(TEST_PASSWD));
|
||||||
|
|
||||||
assertTrue("Should be able to generate key when unlocked",
|
assertTrue("Should be able to generate key when unlocked",
|
||||||
mKeyStore.generate(TEST_KEYNAME, Process.WIFI_UID, NativeCrypto.EVP_PKEY_RSA,
|
mKeyStore.generate(TEST_KEYNAME, Process.WIFI_UID, NativeConstants.EVP_PKEY_RSA,
|
||||||
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
||||||
assertTrue(mKeyStore.contains(TEST_KEYNAME, Process.WIFI_UID));
|
assertTrue(mKeyStore.contains(TEST_KEYNAME, Process.WIFI_UID));
|
||||||
assertFalse(mKeyStore.contains(TEST_KEYNAME));
|
assertFalse(mKeyStore.contains(TEST_KEYNAME));
|
||||||
@@ -401,7 +401,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> {
|
|||||||
assertTrue(mKeyStore.password(TEST_PASSWD));
|
assertTrue(mKeyStore.password(TEST_PASSWD));
|
||||||
|
|
||||||
assertFalse(mKeyStore.generate(TEST_KEYNAME, Process.BLUETOOTH_UID,
|
assertFalse(mKeyStore.generate(TEST_KEYNAME, Process.BLUETOOTH_UID,
|
||||||
NativeCrypto.EVP_PKEY_RSA, RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
NativeConstants.EVP_PKEY_RSA, RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
||||||
assertFalse(mKeyStore.contains(TEST_KEYNAME, Process.BLUETOOTH_UID));
|
assertFalse(mKeyStore.contains(TEST_KEYNAME, Process.BLUETOOTH_UID));
|
||||||
assertFalse(mKeyStore.contains(TEST_KEYNAME, Process.WIFI_UID));
|
assertFalse(mKeyStore.contains(TEST_KEYNAME, Process.WIFI_UID));
|
||||||
assertFalse(mKeyStore.contains(TEST_KEYNAME));
|
assertFalse(mKeyStore.contains(TEST_KEYNAME));
|
||||||
@@ -447,7 +447,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> {
|
|||||||
public void testSign_Success() throws Exception {
|
public void testSign_Success() throws Exception {
|
||||||
mKeyStore.password(TEST_PASSWD);
|
mKeyStore.password(TEST_PASSWD);
|
||||||
|
|
||||||
assertTrue(mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeCrypto.EVP_PKEY_RSA,
|
assertTrue(mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA,
|
||||||
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
||||||
assertTrue(mKeyStore.contains(TEST_KEYNAME));
|
assertTrue(mKeyStore.contains(TEST_KEYNAME));
|
||||||
final byte[] signature = mKeyStore.sign(TEST_KEYNAME, TEST_DATA);
|
final byte[] signature = mKeyStore.sign(TEST_KEYNAME, TEST_DATA);
|
||||||
@@ -458,7 +458,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> {
|
|||||||
public void testVerify_Success() throws Exception {
|
public void testVerify_Success() throws Exception {
|
||||||
mKeyStore.password(TEST_PASSWD);
|
mKeyStore.password(TEST_PASSWD);
|
||||||
|
|
||||||
assertTrue(mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeCrypto.EVP_PKEY_RSA,
|
assertTrue(mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA,
|
||||||
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
||||||
assertTrue(mKeyStore.contains(TEST_KEYNAME));
|
assertTrue(mKeyStore.contains(TEST_KEYNAME));
|
||||||
final byte[] signature = mKeyStore.sign(TEST_KEYNAME, TEST_DATA);
|
final byte[] signature = mKeyStore.sign(TEST_KEYNAME, TEST_DATA);
|
||||||
@@ -486,7 +486,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> {
|
|||||||
mKeyStore.password(TEST_PASSWD));
|
mKeyStore.password(TEST_PASSWD));
|
||||||
|
|
||||||
assertTrue("Should be able to generate key for testcase",
|
assertTrue("Should be able to generate key for testcase",
|
||||||
mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeCrypto.EVP_PKEY_RSA,
|
mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA,
|
||||||
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
||||||
|
|
||||||
assertTrue("Should be able to grant key to other user",
|
assertTrue("Should be able to grant key to other user",
|
||||||
@@ -520,7 +520,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> {
|
|||||||
mKeyStore.password(TEST_PASSWD));
|
mKeyStore.password(TEST_PASSWD));
|
||||||
|
|
||||||
assertTrue("Should be able to generate key for testcase",
|
assertTrue("Should be able to generate key for testcase",
|
||||||
mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeCrypto.EVP_PKEY_RSA,
|
mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA,
|
||||||
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
||||||
|
|
||||||
assertTrue("Should be able to grant key to other user",
|
assertTrue("Should be able to grant key to other user",
|
||||||
@@ -554,7 +554,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> {
|
|||||||
mKeyStore.password(TEST_PASSWD));
|
mKeyStore.password(TEST_PASSWD));
|
||||||
|
|
||||||
assertTrue("Should be able to generate key for testcase",
|
assertTrue("Should be able to generate key for testcase",
|
||||||
mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeCrypto.EVP_PKEY_RSA,
|
mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA,
|
||||||
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
||||||
|
|
||||||
assertFalse("Should not be able to revoke not existent grant",
|
assertFalse("Should not be able to revoke not existent grant",
|
||||||
@@ -566,7 +566,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> {
|
|||||||
mKeyStore.password(TEST_PASSWD));
|
mKeyStore.password(TEST_PASSWD));
|
||||||
|
|
||||||
assertTrue("Should be able to generate key for testcase",
|
assertTrue("Should be able to generate key for testcase",
|
||||||
mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeCrypto.EVP_PKEY_RSA,
|
mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA,
|
||||||
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
||||||
|
|
||||||
assertTrue("Should be able to grant key to other user",
|
assertTrue("Should be able to grant key to other user",
|
||||||
@@ -584,7 +584,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> {
|
|||||||
mKeyStore.password(TEST_PASSWD));
|
mKeyStore.password(TEST_PASSWD));
|
||||||
|
|
||||||
assertTrue("Should be able to generate key for testcase",
|
assertTrue("Should be able to generate key for testcase",
|
||||||
mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeCrypto.EVP_PKEY_RSA,
|
mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA,
|
||||||
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
||||||
|
|
||||||
assertTrue("Should be able to grant key to other user",
|
assertTrue("Should be able to grant key to other user",
|
||||||
@@ -605,7 +605,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> {
|
|||||||
|
|
||||||
assertFalse(mKeyStore.contains(TEST_KEYNAME));
|
assertFalse(mKeyStore.contains(TEST_KEYNAME));
|
||||||
|
|
||||||
assertTrue(mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeCrypto.EVP_PKEY_RSA,
|
assertTrue(mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA,
|
||||||
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
||||||
|
|
||||||
assertTrue(mKeyStore.contains(TEST_KEYNAME));
|
assertTrue(mKeyStore.contains(TEST_KEYNAME));
|
||||||
@@ -644,7 +644,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> {
|
|||||||
|
|
||||||
assertFalse(mKeyStore.contains(TEST_KEYNAME));
|
assertFalse(mKeyStore.contains(TEST_KEYNAME));
|
||||||
|
|
||||||
assertTrue(mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeCrypto.EVP_PKEY_RSA,
|
assertTrue(mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA,
|
||||||
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null));
|
||||||
|
|
||||||
assertTrue(mKeyStore.contains(TEST_KEYNAME));
|
assertTrue(mKeyStore.contains(TEST_KEYNAME));
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user