Factor keystore_attestation_id into library and also use this in credstore.

This was needed because credstore needs to generate and pass the
generated AttestationApplicationId to the Identity Credential HAL.

Bug: 111446262
Test: atest android.security.identity.cts
Test: VtsHalIdentityCredentialTargetTest
Test: android.hardware.identity-support-lib-test
Change-Id: Id22b85ca083e23c7e1fbd3459910fba37a5db137
diff --git a/keystore/Android.bp b/keystore/Android.bp
index f3a7531..c0aeeda 100644
--- a/keystore/Android.bp
+++ b/keystore/Android.bp
@@ -29,7 +29,6 @@
     defaults: ["keystore_defaults"],
 
     srcs: [
-        ":IKeyAttestationApplicationIdProvider.aidl",
         "KeyStore.cpp",
         "auth_token_table.cpp",
         "blob.cpp",
@@ -41,7 +40,6 @@
         "keyblob_utils.cpp",
         "keymaster_enforcement.cpp",
         "keymaster_worker.cpp",
-        "keystore_attestation_id.cpp",
         "keystore_main.cpp",
         "keystore_utils.cpp",
         "legacy_keymaster_device_wrapper.cpp",
@@ -64,6 +62,7 @@
         "libkeymaster4support",
         "libkeymaster_messages",
         "libkeymaster_portable",
+        "libkeystore-attestation-application-id",
         "libkeystore_aidl",
         "libkeystore_binder",
         "libkeystore_parcelables",
@@ -144,13 +143,10 @@
     defaults: ["keystore_defaults"],
     export_include_dirs: ["include"],
     srcs: [
-        "KeyAttestationApplicationId.cpp",
-        "KeyAttestationPackageInfo.cpp",
         "KeymasterArguments.cpp",
         "keystore_aidl_hidl_marshalling_utils.cpp",
         "KeystoreResponse.cpp",
         "OperationResult.cpp",
-        "Signature.cpp",
     ],
     shared_libs: [
         "android.hardware.keymaster@4.0",
@@ -161,6 +157,7 @@
         "liblog",
         "libprotobuf-cpp-lite",
         "libutils",
+        "libkeystore-attestation-application-id",
     ],
     export_shared_lib_headers: [
         "android.hardware.keymaster@4.0",
@@ -210,6 +207,31 @@
     ],
 }
 
+// Library used by both keystore and credstore for generating the ASN.1 stored
+// in Tag::ATTESTATION_APPLICATION_ID
+cc_library_shared {
+    name: "libkeystore-attestation-application-id",
+    defaults: ["keystore_defaults"],
+
+    srcs: [
+        ":IKeyAttestationApplicationIdProvider.aidl",
+        "keystore_attestation_id.cpp",
+        "KeyAttestationApplicationId.cpp",
+        "KeyAttestationPackageInfo.cpp",
+        "Signature.cpp",
+    ],
+    shared_libs: [
+        "libbase",
+        "libbinder",
+        "libhidlbase",
+        "liblog",
+        "libutils",
+        "libcrypto",
+    ],
+
+    export_include_dirs: ["include"],
+}
+
 // Library for keystore clients using the WiFi HIDL interface
 cc_library_shared {
     name: "libkeystore-wifi-hidl",
@@ -235,13 +257,8 @@
     defaults: ["keystore_defaults"],
 
     srcs: [
-        ":IKeyAttestationApplicationIdProvider.aidl",
         "auth_token_table.cpp",
         "blob.cpp",
-        "keystore_attestation_id.cpp",
-        "KeyAttestationApplicationId.cpp",
-        "KeyAttestationPackageInfo.cpp",
-        "Signature.cpp",
     ],
     cflags: [ "-O0", ],
     static_libs: ["libgtest_main"],
@@ -251,6 +268,7 @@
         "libcrypto",
         "libhidlbase",
         "libkeymaster4support",
+        "libkeystore-attestation-application-id",
         "libutils",
         "libkeystore_aidl",
         "libkeystore_parcelables",