Make keymaster more self contained

Keymaster uses UniquePtr, a reimplementation of std::unique_ptr offered
by the Android framework. As keymaster becomes part of the trebbelized
HAL, it must build with the vndk. As such it must not use framework
headers. An attempt to replace UniquePtr with std::unique_ptr, which
is available in the vndk, failed because keymaster, i.e., parts thereof,
must also build and run in the Trusty environment which does not have
a full C++ STL.

This patch makes keymaster more self contained. To that end the
following was done by this patch.

 * Install a copy of UniquePtr.h in include/keymaster.
 * Add a tiny subset of STL symbols to keymaster.
 * Reorganize linking units and
 * build parts of keymaster with stl: "none".

libkeymaster1 was split into libkeymaster_portable and libkeymaster.
The former comprises all compilation units that are included
in the keymaster TA (trusted app) and must run on Trusty.
This library is built with the option stl: "none" to raise
compilation errors as soon as someone tries to use STL features.
A tiny subset of STL symbols, which are also available in Trusty
is weakly defined in keymaster_stl.cpp.
The latter library comprises some other functionality that is
used by the softkeymasterdevice on Android and may use the STL.

Bug: 37467707
Test: keymaster vts tests and keystore cts test
Change-Id: I884336e1a2d2c6402a2c7deb27010fd88b907b6b
Merged-In: I884336e1a2d2c6402a2c7deb27010fd88b907b6b
43 files changed
tree: 6453c37bdeadaf346afe83d97adbec7e805b548b
  1. include/
  2. .clang-format
  3. .gitignore
  4. ae.h
  5. aes_key.cpp
  6. aes_key.h
  7. aes_operation.cpp
  8. aes_operation.h
  9. Android.bp
  10. Android.mk
  11. android_keymaster.cpp
  12. android_keymaster_messages.cpp
  13. android_keymaster_messages_test.cpp
  14. android_keymaster_test.cpp
  15. android_keymaster_test_utils.cpp
  16. android_keymaster_test_utils.h
  17. android_keymaster_utils.cpp
  18. asymmetric_key.cpp
  19. asymmetric_key.h
  20. asymmetric_key_factory.cpp
  21. attestation_record.cpp
  22. attestation_record.h
  23. attestation_record_test.cpp
  24. auth_encrypted_key_blob.cpp
  25. auth_encrypted_key_blob.h
  26. authorization_set.cpp
  27. authorization_set_test.cpp
  28. ec_key.cpp
  29. ec_key.h
  30. ec_key_factory.cpp
  31. ec_keymaster0_key.cpp
  32. ec_keymaster0_key.h
  33. ec_keymaster1_key.cpp
  34. ec_keymaster1_key.h
  35. ec_privkey_pk8.der
  36. ecdsa_keymaster1_operation.cpp
  37. ecdsa_keymaster1_operation.h
  38. ecdsa_operation.cpp
  39. ecdsa_operation.h
  40. ecies_kem.cpp
  41. ecies_kem.h
  42. ecies_kem_test.cpp
  43. gtest_main.cpp
  44. hkdf.cpp
  45. hkdf.h
  46. hkdf_test.cpp
  47. hmac.cpp
  48. hmac.h
  49. hmac_key.cpp
  50. hmac_key.h
  51. hmac_operation.cpp
  52. hmac_operation.h
  53. hmac_test.cpp
  54. integrity_assured_key_blob.cpp
  55. integrity_assured_key_blob.h
  56. iso18033kdf.cpp
  57. iso18033kdf.h
  58. kdf.cpp
  59. kdf.h
  60. kdf1.h
  61. kdf1_test.cpp
  62. kdf2.h
  63. kdf2_test.cpp
  64. kdf_test.cpp
  65. kem.h
  66. key.cpp
  67. key.h
  68. key_blob_test.cpp
  69. key_exchange.h
  70. keymaster0_engine.cpp
  71. keymaster0_engine.h
  72. keymaster1_engine.cpp
  73. keymaster1_engine.h
  74. keymaster_configuration.cpp
  75. keymaster_configuration_test.cpp
  76. keymaster_enforcement.cpp
  77. keymaster_enforcement_test.cpp
  78. keymaster_stl.cpp
  79. keymaster_tags.cpp
  80. km0_sw_rsa_512.blob
  81. km1_sw_ecdsa_256.blob
  82. km1_sw_rsa_512.blob
  83. km1_sw_rsa_512_unversioned.blob
  84. List.h
  85. logger.cpp
  86. Makefile
  87. MODULE_LICENSE_APACHE2
  88. nist_curve_key_exchange.cpp
  89. nist_curve_key_exchange.h
  90. nist_curve_key_exchange_test.cpp
  91. NOTICE
  92. ocb.c
  93. ocb_utils.cpp
  94. ocb_utils.h
  95. openssl_err.cpp
  96. openssl_err.h
  97. openssl_utils.cpp
  98. openssl_utils.h
  99. operation.cpp
  100. operation.h
  101. operation_table.cpp
  102. operation_table.h
  103. OWNERS
  104. rsa_key.cpp
  105. rsa_key.h
  106. rsa_key_factory.cpp
  107. rsa_keymaster0_key.cpp
  108. rsa_keymaster0_key.h
  109. rsa_keymaster1_key.cpp
  110. rsa_keymaster1_key.h
  111. rsa_keymaster1_operation.cpp
  112. rsa_keymaster1_operation.h
  113. rsa_operation.cpp
  114. rsa_operation.h
  115. rsa_privkey_pk8.der
  116. serializable.cpp
  117. soft_keymaster_context.cpp
  118. soft_keymaster_device.cpp
  119. soft_keymaster_logger.cpp
  120. sw_rsa_attest_root.key.pem
  121. symmetric_key.cpp
  122. symmetric_key.h
  123. valgrind.supp