Merge "On-device signing binary."
diff --git a/keystore2/Android.bp b/keystore2/Android.bp
index dab6123..e63a469 100644
--- a/keystore2/Android.bp
+++ b/keystore2/Android.bp
@@ -19,7 +19,7 @@
 
     rustlibs: [
         "android.system.keystore2-rust",
-        "android.hardware.keymint-rust",
+        "android.hardware.security.keymint-rust",
         "libanyhow",
         "libbinder_rs",
         "libkeystore2_selinux",
@@ -41,7 +41,7 @@
     test_config: "AndroidTest.xml",
     rustlibs: [
         "android.system.keystore2-rust",
-        "android.hardware.keymint-rust",
+        "android.hardware.security.keymint-rust",
         "libandroid_logger",
         "libanyhow",
         "libbinder_rs",
@@ -65,22 +65,3 @@
     ],
     init_rc: ["keystore2.rc"],
 }
-
-aidl_interface {
-    name: "android.security.attestationmanager",
-    srcs: [
-        "aidl/android/security/ByteArray.aidl",
-        "aidl/android/security/IAttestationManager.aidl",
-    ],
-    local_include_dir: "aidl",
-    imports: [ "android.hardware.keymint" ],
-    unstable: true,
-    backend: {
-        java: {
-            sdk_version: "module_current",
-        },
-        rust: {
-            enabled: true,
-        },
-    },
-}
diff --git a/keystore2/aidl/Android.bp b/keystore2/aidl/Android.bp
new file mode 100644
index 0000000..3b2dff0
--- /dev/null
+++ b/keystore2/aidl/Android.bp
@@ -0,0 +1,30 @@
+// Copyright 2020, The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+aidl_interface {
+    name: "android.security.attestationmanager",
+    srcs: [
+        "android/security/attestationmanager/*.aidl",
+    ],
+    imports: [ "android.hardware.security.keymint" ],
+    unstable: true,
+    backend: {
+        java: {
+            sdk_version: "module_current",
+        },
+        rust: {
+            enabled: true,
+        },
+    },
+}
diff --git a/keystore2/aidl/android/security/ByteArray.aidl b/keystore2/aidl/android/security/attestationmanager/ByteArray.aidl
similarity index 94%
rename from keystore2/aidl/android/security/ByteArray.aidl
rename to keystore2/aidl/android/security/attestationmanager/ByteArray.aidl
index db2e18c..a1592ec 100644
--- a/keystore2/aidl/android/security/ByteArray.aidl
+++ b/keystore2/aidl/android/security/attestationmanager/ByteArray.aidl
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.security;
+package android.security.attestationmanager;
 
 /**
  * Simple data holder for a byte array, allowing for multidimensional arrays in AIDL.
diff --git a/keystore2/aidl/android/security/IAttestationManager.aidl b/keystore2/aidl/android/security/attestationmanager/IAttestationManager.aidl
similarity index 87%
rename from keystore2/aidl/android/security/IAttestationManager.aidl
rename to keystore2/aidl/android/security/attestationmanager/IAttestationManager.aidl
index 1953cca..85eee57 100644
--- a/keystore2/aidl/android/security/IAttestationManager.aidl
+++ b/keystore2/aidl/android/security/attestationmanager/IAttestationManager.aidl
@@ -14,10 +14,10 @@
  * limitations under the License.
  */
 
-package android.security;
+package android.security.attestationmanager;
 
-import android.security.ByteArray;
-import android.hardware.keymint.KeyParameter;
+import android.security.attestationmanager.ByteArray;
+import android.hardware.security.keymint.KeyParameter;
 
 /**
  * Internal interface for performing device attestation.
diff --git a/keystore2/src/database.rs b/keystore2/src/database.rs
index 0db4162..45d561a 100644
--- a/keystore2/src/database.rs
+++ b/keystore2/src/database.rs
@@ -46,7 +46,7 @@
 use crate::permission::KeyPermSet;
 use anyhow::{anyhow, Context, Result};
 
-use android_hardware_keymint::aidl::android::hardware::keymint::SecurityLevel::SecurityLevel;
+use android_hardware_security_keymint::aidl::android::hardware::security::keymint::SecurityLevel::SecurityLevel;
 use android_system_keystore2::aidl::android::system::keystore2::{
     Domain::Domain, KeyDescriptor::KeyDescriptor,
 };
diff --git a/keystore2/src/error.rs b/keystore2/src/error.rs
index 49d72bb..b4cf913 100644
--- a/keystore2/src/error.rs
+++ b/keystore2/src/error.rs
@@ -32,7 +32,7 @@
 
 use std::cmp::PartialEq;
 
-pub use android_hardware_keymint::aidl::android::hardware::keymint::ErrorCode::ErrorCode;
+pub use android_hardware_security_keymint::aidl::android::hardware::security::keymint::ErrorCode::ErrorCode;
 pub use android_system_keystore2::aidl::android::system::keystore2::ResponseCode::ResponseCode;
 
 use keystore2_selinux as selinux;
diff --git a/keystore2/src/key_parameter.rs b/keystore2/src/key_parameter.rs
index 5698c96..7f2dc56 100644
--- a/keystore2/src/key_parameter.rs
+++ b/keystore2/src/key_parameter.rs
@@ -19,7 +19,7 @@
 use crate::error::Error as KeystoreError;
 use crate::error::ResponseCode;
 
-pub use android_hardware_keymint::aidl::android::hardware::keymint::{
+pub use android_hardware_security_keymint::aidl::android::hardware::security::keymint::{
     Algorithm::Algorithm, BlockMode::BlockMode, Digest::Digest, EcCurve::EcCurve,
     HardwareAuthenticatorType::HardwareAuthenticatorType, KeyOrigin::KeyOrigin,
     KeyParameter::KeyParameter as KmKeyParameter, KeyPurpose::KeyPurpose, PaddingMode::PaddingMode,
diff --git a/keystore2/src/operation.rs b/keystore2/src/operation.rs
index 14edc6c..13a9b0c 100644
--- a/keystore2/src/operation.rs
+++ b/keystore2/src/operation.rs
@@ -134,7 +134,7 @@
 
 use crate::error::{map_km_error, map_or_log_err, Error, ErrorCode, ResponseCode};
 use crate::utils::Asp;
-use android_hardware_keymint::aidl::android::hardware::keymint::{
+use android_hardware_security_keymint::aidl::android::hardware::security::keymint::{
     ByteArray::ByteArray, IKeyMintOperation::IKeyMintOperation,
     KeyParameter::KeyParameter as KmParam, KeyParameterArray::KeyParameterArray, Tag::Tag,
 };
diff --git a/keystore2/src/security_level.rs b/keystore2/src/security_level.rs
index 24a2e99..e7d07e3 100644
--- a/keystore2/src/security_level.rs
+++ b/keystore2/src/security_level.rs
@@ -16,7 +16,7 @@
 
 //! This crate implements the IKeystoreSecurityLevel interface.
 
-use android_hardware_keymint::aidl::android::hardware::keymint::{
+use android_hardware_security_keymint::aidl::android::hardware::security::keymint::{
     Algorithm::Algorithm, ByteArray::ByteArray, Certificate::Certificate as KmCertificate,
     HardwareAuthenticatorType::HardwareAuthenticatorType, IKeyMintDevice::IKeyMintDevice,
     KeyCharacteristics::KeyCharacteristics, KeyFormat::KeyFormat, KeyParameter::KeyParameter,
diff --git a/keystore2/src/service.rs b/keystore2/src/service.rs
index 71aecbd..eb0d01b 100644
--- a/keystore2/src/service.rs
+++ b/keystore2/src/service.rs
@@ -27,7 +27,7 @@
 use crate::utils::{
     check_grant_permission, check_key_permission, key_parameters_to_authorizations, Asp,
 };
-use android_hardware_keymint::aidl::android::hardware::keymint::SecurityLevel::SecurityLevel;
+use android_hardware_security_keymint::aidl::android::hardware::security::keymint::SecurityLevel::SecurityLevel;
 use android_system_keystore2::aidl::android::system::keystore2::{
     Domain::Domain, IKeystoreSecurityLevel::IKeystoreSecurityLevel,
     IKeystoreService::BnKeystoreService, IKeystoreService::IKeystoreService,
diff --git a/keystore2/src/utils.rs b/keystore2/src/utils.rs
index 1c678c3..66f3db6 100644
--- a/keystore2/src/utils.rs
+++ b/keystore2/src/utils.rs
@@ -18,7 +18,7 @@
 use crate::permission;
 use crate::permission::{KeyPerm, KeyPermSet, KeystorePerm};
 use crate::{error::Error, key_parameter::KeyParameterValue};
-use android_hardware_keymint::aidl::android::hardware::keymint::{
+use android_hardware_security_keymint::aidl::android::hardware::security::keymint::{
     KeyCharacteristics::KeyCharacteristics, SecurityLevel::SecurityLevel,
 };
 use android_system_keystore2::aidl::android::system::keystore2::{