generator: drop unused files
am: ddd74566ac

* commit 'ddd74566acf751be7109b34ef1e5e52100c3e23a':
  generator: drop unused files
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..46e84c9
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,305 @@
+# Copyright (C) 2015 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.
+
+LOCAL_PATH := $(call my-dir)
+
+# libtpm2
+# ========================================================
+include $(CLEAR_VARS)
+LOCAL_MODULE := libtpm2
+LOCAL_CFLAGS := -Wall -Wextra -Werror \
+  -Wno-typedef-redefinition \
+  -Wno-unused-parameter \
+  -Wno-missing-field-initializers \
+  -Wno-tautological-compare \
+  -Wno-sign-compare
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/tpm2
+LOCAL_CLANG := true
+LOCAL_SHARED_LIBRARIES := libcrypto
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
+LOCAL_SRC_FILES := \
+  ActivateCredential.c \
+  AlgorithmCap.c \
+  Attest_spt.c \
+  Bits.c \
+  Cancel.c \
+  Certify.c \
+  CertifyCreation.c \
+  ChangeEPS.c \
+  ChangePPS.c \
+  Clear.c \
+  ClearControl.c \
+  Clock.c \
+  ClockRateAdjust.c \
+  ClockSet.c \
+  CommandAudit.c \
+  CommandCodeAttributes.c \
+  CommandDispatcher.c \
+  Commit.c \
+  ContextLoad.c \
+  ContextSave.c \
+  Context_spt.c \
+  CpriCryptPri.c \
+  CpriECC.c \
+  CpriHash.c \
+  CpriMisc.c \
+  CpriRNG.c \
+  CpriRSA.c \
+  CpriSym.c \
+  Create.c \
+  CreatePrimary.c \
+  CryptSelfTest.c \
+  CryptUtil.c \
+  DA.c \
+  DRTM.c \
+  DictionaryAttackLockReset.c \
+  DictionaryAttackParameters.c \
+  Duplicate.c \
+  ECC_Parameters.c \
+  ECDH_KeyGen.c \
+  ECDH_ZGen.c \
+  EC_Ephemeral.c \
+  EncryptDecrypt.c \
+  Entity.c \
+  Entropy.c \
+  EventSequenceComplete.c \
+  EvictControl.c \
+  ExecCommand.c \
+  FieldUpgradeData.c \
+  FieldUpgradeStart.c \
+  FirmwareRead.c \
+  FlushContext.c \
+  GetCapability.c \
+  GetCommandAuditDigest.c \
+  GetCommandCodeString.c \
+  GetRandom.c \
+  GetSessionAuditDigest.c \
+  GetTestResult.c \
+  GetTime.c \
+  Global.c \
+  HMAC.c \
+  HMAC_Start.c \
+  Handle.c \
+  HandleProcess.c \
+  Hash.c \
+  HashSequenceStart.c \
+  Hierarchy.c \
+  HierarchyChangeAuth.c \
+  HierarchyControl.c \
+  Import.c \
+  IncrementalSelfTest.c \
+  Load.c \
+  LoadExternal.c \
+  Locality.c \
+  LocalityPlat.c \
+  MakeCredential.c \
+  Marshal_ActivateCredential.c \
+  Marshal_Certify.c \
+  Marshal_CertifyCreation.c \
+  Marshal_ChangeEPS.c \
+  Marshal_ChangePPS.c \
+  Marshal_Clear.c \
+  Marshal_ClearControl.c \
+  Marshal_ClockRateAdjust.c \
+  Marshal_ClockSet.c \
+  Marshal_Commit.c \
+  Marshal_ContextLoad.c \
+  Marshal_ContextSave.c \
+  Marshal_Create.c \
+  Marshal_CreatePrimary.c \
+  Marshal_DictionaryAttackLockReset.c \
+  Marshal_DictionaryAttackParameters.c \
+  Marshal_Duplicate.c \
+  Marshal_ECC_Parameters.c \
+  Marshal_ECDH_KeyGen.c \
+  Marshal_ECDH_ZGen.c \
+  Marshal_EC_Ephemeral.c \
+  Marshal_EncryptDecrypt.c \
+  Marshal_EventSequenceComplete.c \
+  Marshal_EvictControl.c \
+  Marshal_FirmwareRead.c \
+  Marshal_FlushContext.c \
+  Marshal_GetCapability.c \
+  Marshal_GetCommandAuditDigest.c \
+  Marshal_GetRandom.c \
+  Marshal_GetSessionAuditDigest.c \
+  Marshal_GetTestResult.c \
+  Marshal_GetTime.c \
+  Marshal_HMAC.c \
+  Marshal_HMAC_Start.c \
+  Marshal_Hash.c \
+  Marshal_HashSequenceStart.c \
+  Marshal_HierarchyChangeAuth.c \
+  Marshal_HierarchyControl.c \
+  Marshal_Import.c \
+  Marshal_IncrementalSelfTest.c \
+  Marshal_Load.c \
+  Marshal_LoadExternal.c \
+  Marshal_MakeCredential.c \
+  Marshal_NV_Certify.c \
+  Marshal_NV_ChangeAuth.c \
+  Marshal_NV_DefineSpace.c \
+  Marshal_NV_Extend.c \
+  Marshal_NV_GlobalWriteLock.c \
+  Marshal_NV_Increment.c \
+  Marshal_NV_Read.c \
+  Marshal_NV_ReadLock.c \
+  Marshal_NV_ReadPublic.c \
+  Marshal_NV_SetBits.c \
+  Marshal_NV_UndefineSpace.c \
+  Marshal_NV_UndefineSpaceSpecial.c \
+  Marshal_NV_Write.c \
+  Marshal_NV_WriteLock.c \
+  Marshal_ObjectChangeAuth.c \
+  Marshal_PCR_Allocate.c \
+  Marshal_PCR_Event.c \
+  Marshal_PCR_Extend.c \
+  Marshal_PCR_Read.c \
+  Marshal_PCR_Reset.c \
+  Marshal_PCR_SetAuthPolicy.c \
+  Marshal_PCR_SetAuthValue.c \
+  Marshal_PP_Commands.c \
+  Marshal_PolicyAuthValue.c \
+  Marshal_PolicyAuthorize.c \
+  Marshal_PolicyCommandCode.c \
+  Marshal_PolicyCounterTimer.c \
+  Marshal_PolicyCpHash.c \
+  Marshal_PolicyDuplicationSelect.c \
+  Marshal_PolicyGetDigest.c \
+  Marshal_PolicyLocality.c \
+  Marshal_PolicyNV.c \
+  Marshal_PolicyNameHash.c \
+  Marshal_PolicyNvWritten.c \
+  Marshal_PolicyOR.c \
+  Marshal_PolicyPCR.c \
+  Marshal_PolicyPassword.c \
+  Marshal_PolicyPhysicalPresence.c \
+  Marshal_PolicyRestart.c \
+  Marshal_PolicySecret.c \
+  Marshal_PolicySigned.c \
+  Marshal_PolicyTicket.c \
+  Marshal_Quote.c \
+  Marshal_RSA_Decrypt.c \
+  Marshal_RSA_Encrypt.c \
+  Marshal_ReadClock.c \
+  Marshal_ReadPublic.c \
+  Marshal_Rewrap.c \
+  Marshal_SelfTest.c \
+  Marshal_SequenceComplete.c \
+  Marshal_SequenceUpdate.c \
+  Marshal_SetAlgorithmSet.c \
+  Marshal_SetCommandCodeAuditStatus.c \
+  Marshal_SetPrimaryPolicy.c \
+  Marshal_Shutdown.c \
+  Marshal_Sign.c \
+  Marshal_StartAuthSession.c \
+  Marshal_Startup.c \
+  Marshal_StirRandom.c \
+  Marshal_TestParms.c \
+  Marshal_Unseal.c \
+  Marshal_VerifySignature.c \
+  Marshal_ZGen_2Phase.c \
+  Manufacture.c \
+  MathFunctions.c \
+  MemoryLib.c \
+  NV.c \
+  NVMem.c \
+  NV_Certify.c \
+  NV_ChangeAuth.c \
+  NV_DefineSpace.c \
+  NV_Extend.c \
+  NV_GlobalWriteLock.c \
+  NV_Increment.c \
+  NV_Read.c \
+  NV_ReadLock.c \
+  NV_ReadPublic.c \
+  NV_SetBits.c \
+  NV_UndefineSpace.c \
+  NV_UndefineSpaceSpecial.c \
+  NV_Write.c \
+  NV_WriteLock.c \
+  NV_spt.c \
+  Object.c \
+  ObjectChangeAuth.c \
+  Object_spt.c \
+  PCR.c \
+  PCR_Allocate.c \
+  PCR_Event.c \
+  PCR_Extend.c \
+  PCR_Read.c \
+  PCR_Reset.c \
+  PCR_SetAuthPolicy.c \
+  PCR_SetAuthValue.c \
+  PP.c \
+  PPPlat.c \
+  PP_Commands.c \
+  PlatformData.c \
+  PolicyAuthValue.c \
+  PolicyAuthorize.c \
+  PolicyCommandCode.c \
+  PolicyCounterTimer.c \
+  PolicyCpHash.c \
+  PolicyDuplicationSelect.c \
+  PolicyGetDigest.c \
+  PolicyLocality.c \
+  PolicyNV.c \
+  PolicyNameHash.c \
+  PolicyNvWritten.c \
+  PolicyOR.c \
+  PolicyPCR.c \
+  PolicyPassword.c \
+  PolicyPhysicalPresence.c \
+  PolicyRestart.c \
+  PolicySecret.c \
+  PolicySigned.c \
+  PolicyTicket.c \
+  Policy_spt.c \
+  Power.c \
+  PowerPlat.c \
+  PropertyCap.c \
+  Quote.c \
+  RSAData.c \
+  RSAKeySieve.c \
+  RSA_Decrypt.c \
+  RSA_Encrypt.c \
+  ReadClock.c \
+  ReadPublic.c \
+  Rewrap.c \
+  SelfTest.c \
+  SequenceComplete.c \
+  SequenceUpdate.c \
+  Session.c \
+  SessionProcess.c \
+  SetAlgorithmSet.c \
+  SetCommandCodeAuditStatus.c \
+  SetPrimaryPolicy.c \
+  Shutdown.c \
+  Sign.c \
+  StartAuthSession.c \
+  Startup.c \
+  StirRandom.c \
+  TestParms.c \
+  Ticket.c \
+  Time.c \
+  TpmFail.c \
+  Unique.c \
+  Unseal.c \
+  VerifySignature.c \
+  ZGen_2Phase.c \
+  _TPM_Hash_Data.c \
+  _TPM_Hash_End.c \
+  _TPM_Hash_Start.c \
+  _TPM_Init.c \
+  tpm_generated.c
+include $(BUILD_SHARED_LIBRARY)
diff --git a/CpriCryptPri.c b/CpriCryptPri.c
index 2c1210c..6926808 100644
--- a/CpriCryptPri.c
+++ b/CpriCryptPri.c
@@ -5,6 +5,8 @@
 // Level 00 Revision 01.16
 // October 30, 2014
 
+#include <stdlib.h>
+
 #include "CryptoEngine.h"
 #include "OsslCryptoEngine.h"
 static void Trap(const char *function, int line, int code);
diff --git a/Implementation.h b/Implementation.h
index 361c36e..b149d51 100644
--- a/Implementation.h
+++ b/Implementation.h
@@ -473,8 +473,7 @@
 #define   SHA256_BLOCK_SIZE        64
 #define   SHA256_DER_SIZE          19
 #define   SHA256_DER               \
-//      0x30,0x31,0x30,0x0D,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0
-//      x04,0x20
+   0x30,0x31,0x30,0x0D,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0x04,0x20
 //
 //      From TCG Algorithm Registry: Table 14 - Defines for SHA384 Hash Values
 //
@@ -482,8 +481,7 @@
 #define   SHA384_BLOCK_SIZE        128
 #define   SHA384_DER_SIZE          19
 #define   SHA384_DER               \
-//      0x30,0x41,0x30,0x0D,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x02,0x05,0x00,0
-//      x04,0x30
+   0x30,0x41,0x30,0x0D,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x02,0x05,0x00,0x04,0x30
 //
 //      From TCG Algorithm Registry: Table 15 - Defines for SHA512 Hash Values
 //
@@ -491,8 +489,7 @@
 #define   SHA512_BLOCK_SIZE        128
 #define   SHA512_DER_SIZE          19
 #define   SHA512_DER               \
-//      0x30,0x51,0x30,0x0D,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x03,0x05,0x00,0
-//      x04,0x40
+   0x30,0x51,0x30,0x0D,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x03,0x05,0x00,0x04,0x40
 //
 //      From TCG Algorithm Registry: Table 16 - Defines for SM3_256 Hash Values
 //
diff --git a/OsslCryptoEngine.h b/OsslCryptoEngine.h
index 7217e8a..3c5f3cb 100644
--- a/OsslCryptoEngine.h
+++ b/OsslCryptoEngine.h
@@ -28,6 +28,38 @@
 #   endif
 #   include    "CpriRSA_fp.h"
 #endif
+
+#ifdef OPENSSL_IS_BORINGSSL
+// libtpm2 reads internal EVP_MD state (e.g. ctx_size). The boringssl headers
+// don't expose this type so define it here.
+struct env_md_st {
+  /* type contains a NID identifing the digest function. (For example,
+   * NID_md5.) */
+  int type;
+
+  /* md_size contains the size, in bytes, of the resulting digest. */
+  unsigned md_size;
+
+  /* flags contains the OR of |EVP_MD_FLAG_*| values. */
+  uint32_t flags;
+
+  /* init initialises the state in |ctx->md_data|. */
+  void (*init)(EVP_MD_CTX *ctx);
+
+  /* update hashes |len| bytes of |data| into the state in |ctx->md_data|. */
+  void (*update)(EVP_MD_CTX *ctx, const void *data, size_t count);
+
+  /* final completes the hash and writes |md_size| bytes of digest to |out|. */
+  void (*final)(EVP_MD_CTX *ctx, uint8_t *out);
+
+  /* block_size contains the hash's native block size. */
+  unsigned block_size;
+
+  /* ctx_size contains the size, in bytes, of the state of the hash function. */
+  unsigned ctx_size;
+};
+#endif
+
 //
 //     This is a structure to hold the parameters for the version of KDFa() used by the CryptoEngine(). This
 //     structure allows the state to be passed between multiple functions that use the same pseudo-random
diff --git a/ExecCommand_fp.h b/include/tpm2/ExecCommand_fp.h
similarity index 100%
rename from ExecCommand_fp.h
rename to include/tpm2/ExecCommand_fp.h
diff --git a/Manufacture_fp.h b/include/tpm2/Manufacture_fp.h
similarity index 90%
rename from Manufacture_fp.h
rename to include/tpm2/Manufacture_fp.h
index 5768df6..941f247 100644
--- a/Manufacture_fp.h
+++ b/include/tpm2/Manufacture_fp.h
@@ -7,6 +7,9 @@
 #ifndef __TPM2_MANUFACTURE_FP_H
 #define __TPM2_MANUFACTURE_FP_H
 
+#include "bool.h"
+#include "TpmBuildSwitches.h"
+
 LIB_EXPORT int TPM_Manufacture(
     BOOL firstTime  // IN: indicates if this is the first call from main()
     );
diff --git a/Platform.h b/include/tpm2/Platform.h
similarity index 100%
rename from Platform.h
rename to include/tpm2/Platform.h
diff --git a/TpmBuildSwitches.h b/include/tpm2/TpmBuildSwitches.h
similarity index 100%
rename from TpmBuildSwitches.h
rename to include/tpm2/TpmBuildSwitches.h
diff --git a/TpmError.h b/include/tpm2/TpmError.h
similarity index 100%
rename from TpmError.h
rename to include/tpm2/TpmError.h
diff --git a/_TPM_Init_fp.h b/include/tpm2/_TPM_Init_fp.h
similarity index 100%
rename from _TPM_Init_fp.h
rename to include/tpm2/_TPM_Init_fp.h
diff --git a/bool.h b/include/tpm2/bool.h
similarity index 100%
rename from bool.h
rename to include/tpm2/bool.h