Search in sources :

Example 61 with IBinder

use of android.os.IBinder in project platform_frameworks_base by android.

the class KeyStoreTest method testBadToken.

public void testBadToken() throws Exception {
    IBinder token = new Binder();
    OperationResult result = mKeyStore.update(token, null, new byte[] { 0x01 });
    assertEquals("Update with invalid token should fail", KeymasterDefs.KM_ERROR_INVALID_OPERATION_HANDLE, result.resultCode);
}
Also used : IBinder(android.os.IBinder) Binder(android.os.Binder) IBinder(android.os.IBinder) OperationResult(android.security.keymaster.OperationResult)

Example 62 with IBinder

use of android.os.IBinder in project platform_frameworks_base by android.

the class KeyStoreTest method testOperationPruning.

// This is a very implementation specific test and should be thrown out eventually, however it
// is nice for now to test that keystore is properly pruning operations.
public void testOperationPruning() throws Exception {
    String name = "test";
    KeymasterArguments args = new KeymasterArguments();
    args.addEnum(KeymasterDefs.KM_TAG_PURPOSE, KeymasterDefs.KM_PURPOSE_ENCRYPT);
    args.addEnum(KeymasterDefs.KM_TAG_PURPOSE, KeymasterDefs.KM_PURPOSE_DECRYPT);
    args.addEnum(KeymasterDefs.KM_TAG_ALGORITHM, KeymasterDefs.KM_ALGORITHM_AES);
    args.addEnum(KeymasterDefs.KM_TAG_PADDING, KeymasterDefs.KM_PAD_NONE);
    args.addUnsignedInt(KeymasterDefs.KM_TAG_KEY_SIZE, 256);
    args.addEnum(KeymasterDefs.KM_TAG_BLOCK_MODE, KeymasterDefs.KM_MODE_CTR);
    args.addBoolean(KeymasterDefs.KM_TAG_NO_AUTH_REQUIRED);
    KeyCharacteristics outCharacteristics = new KeyCharacteristics();
    int rc = mKeyStore.generateKey(name, args, null, 0, outCharacteristics);
    assertEquals("Generate should succeed", KeyStore.NO_ERROR, rc);
    args = new KeymasterArguments();
    args.addEnum(KeymasterDefs.KM_TAG_ALGORITHM, KeymasterDefs.KM_ALGORITHM_AES);
    args.addEnum(KeymasterDefs.KM_TAG_BLOCK_MODE, KeymasterDefs.KM_MODE_CTR);
    args.addEnum(KeymasterDefs.KM_TAG_PADDING, KeymasterDefs.KM_PAD_NONE);
    OperationResult result = mKeyStore.begin(name, KeymasterDefs.KM_PURPOSE_ENCRYPT, true, args, null);
    assertEquals("Begin should succeed", KeyStore.NO_ERROR, result.resultCode);
    IBinder first = result.token;
    // Implementation detail: softkeymaster supports 16 concurrent operations
    for (int i = 0; i < 16; i++) {
        result = mKeyStore.begin(name, KeymasterDefs.KM_PURPOSE_ENCRYPT, true, args, null);
        assertEquals("Begin should succeed", KeyStore.NO_ERROR, result.resultCode);
    }
    // At this point the first operation should be pruned.
    assertEquals("Operation should be pruned", KeymasterDefs.KM_ERROR_INVALID_OPERATION_HANDLE, mKeyStore.update(first, null, new byte[] { 0x01 }).resultCode);
}
Also used : IBinder(android.os.IBinder) KeymasterArguments(android.security.keymaster.KeymasterArguments) KeyCharacteristics(android.security.keymaster.KeyCharacteristics) OperationResult(android.security.keymaster.OperationResult)

Example 63 with IBinder

use of android.os.IBinder in project platform_frameworks_base by android.

the class KeyStoreTest method doOperation.

private byte[] doOperation(String name, int purpose, byte[] in, KeymasterArguments beginArgs) {
    OperationResult result = mKeyStore.begin(name, purpose, true, beginArgs, null);
    assertEquals("Begin should succeed", KeyStore.NO_ERROR, result.resultCode);
    IBinder token = result.token;
    result = mKeyStore.update(token, null, in);
    assertEquals("Update should succeed", KeyStore.NO_ERROR, result.resultCode);
    assertEquals("All data should be consumed", in.length, result.inputConsumed);
    assertEquals("Finish should succeed", KeyStore.NO_ERROR, mKeyStore.finish(token, null, null).resultCode);
    return result.output;
}
Also used : IBinder(android.os.IBinder) OperationResult(android.security.keymaster.OperationResult)

Example 64 with IBinder

use of android.os.IBinder in project platform_frameworks_base by android.

the class KeyStoreTest method testAesGcmEncryptSuccess.

public void testAesGcmEncryptSuccess() throws Exception {
    String name = "test";
    KeymasterArguments args = new KeymasterArguments();
    args.addEnum(KeymasterDefs.KM_TAG_PURPOSE, KeymasterDefs.KM_PURPOSE_ENCRYPT);
    args.addEnum(KeymasterDefs.KM_TAG_PURPOSE, KeymasterDefs.KM_PURPOSE_DECRYPT);
    args.addEnum(KeymasterDefs.KM_TAG_ALGORITHM, KeymasterDefs.KM_ALGORITHM_AES);
    args.addEnum(KeymasterDefs.KM_TAG_PADDING, KeymasterDefs.KM_PAD_NONE);
    args.addUnsignedInt(KeymasterDefs.KM_TAG_KEY_SIZE, 256);
    args.addEnum(KeymasterDefs.KM_TAG_BLOCK_MODE, KeymasterDefs.KM_MODE_GCM);
    args.addBoolean(KeymasterDefs.KM_TAG_NO_AUTH_REQUIRED);
    KeyCharacteristics outCharacteristics = new KeyCharacteristics();
    int rc = mKeyStore.generateKey(name, args, null, 0, outCharacteristics);
    assertEquals("Generate should succeed", KeyStore.NO_ERROR, rc);
    args = new KeymasterArguments();
    args.addEnum(KeymasterDefs.KM_TAG_ALGORITHM, KeymasterDefs.KM_ALGORITHM_AES);
    args.addEnum(KeymasterDefs.KM_TAG_BLOCK_MODE, KeymasterDefs.KM_MODE_GCM);
    args.addEnum(KeymasterDefs.KM_TAG_PADDING, KeymasterDefs.KM_PAD_NONE);
    args.addUnsignedInt(KeymasterDefs.KM_TAG_MAC_LENGTH, 128);
    OperationResult result = mKeyStore.begin(name, KeymasterDefs.KM_PURPOSE_ENCRYPT, true, args, null);
    IBinder token = result.token;
    assertEquals("Begin should succeed", KeyStore.NO_ERROR, result.resultCode);
    result = mKeyStore.update(token, null, new byte[] { 0x01, 0x02, 0x03, 0x04 });
    assertEquals("Update should succeed", KeyStore.NO_ERROR, result.resultCode);
    assertEquals("Finish should succeed", KeyStore.NO_ERROR, mKeyStore.finish(token, null, null).resultCode);
// TODO: Assert that an AEAD tag was returned by finish
}
Also used : IBinder(android.os.IBinder) KeymasterArguments(android.security.keymaster.KeymasterArguments) KeyCharacteristics(android.security.keymaster.KeyCharacteristics) OperationResult(android.security.keymaster.OperationResult)

Example 65 with IBinder

use of android.os.IBinder in project platform_frameworks_base by android.

the class Geocoder method isPresent.

/**
     * Returns true if the Geocoder methods getFromLocation and
     * getFromLocationName are implemented.  Lack of network
     * connectivity may still cause these methods to return null or
     * empty lists.
     */
public static boolean isPresent() {
    IBinder b = ServiceManager.getService(Context.LOCATION_SERVICE);
    ILocationManager lm = ILocationManager.Stub.asInterface(b);
    try {
        return lm.geocoderIsPresent();
    } catch (RemoteException e) {
        Log.e(TAG, "isPresent: got RemoteException", e);
        return false;
    }
}
Also used : IBinder(android.os.IBinder) RemoteException(android.os.RemoteException)

Aggregations

IBinder (android.os.IBinder)991 RemoteException (android.os.RemoteException)494 Intent (android.content.Intent)141 ComponentName (android.content.ComponentName)128 ServiceConnection (android.content.ServiceConnection)94 Parcel (android.os.Parcel)91 Point (android.graphics.Point)67 PendingIntent (android.app.PendingIntent)60 IOException (java.io.IOException)53 UserHandle (android.os.UserHandle)50 Bundle (android.os.Bundle)40 Binder (android.os.Binder)37 Message (android.os.Message)37 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)34 AndroidRuntimeException (android.util.AndroidRuntimeException)33 Handler (android.os.Handler)31 ArrayList (java.util.ArrayList)27 IContentProvider (android.content.IContentProvider)25 TransactionTooLargeException (android.os.TransactionTooLargeException)25 OperationResult (android.security.keymaster.OperationResult)25