Run all C/C++ in this repo through clang-format.
Also create a .clang-format file.
Change-Id: I5ac5904ea1bfd10177c1a4b0b1fdead0b477fc95
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..f3eb5d2
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,5 @@
+#
+# This repo is exists both in Android and Chrome OS. The two share most patches
+# so it makes sense for them to use the same coding style.
+#
+BasedOnStyle: Chromium
diff --git a/attestation/attestation_testrunner.cc b/attestation/attestation_testrunner.cc
index 2aac479..f769727 100644
--- a/attestation/attestation_testrunner.cc
+++ b/attestation/attestation_testrunner.cc
@@ -20,7 +20,7 @@
#include <brillo/syslog_logging.h>
#include <gtest/gtest.h>
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
base::CommandLine::Init(argc, argv);
brillo::InitLog(brillo::kLogToStderr);
// Enable verbose logging while running unit tests.
diff --git a/attestation/client/dbus_proxy.cc b/attestation/client/dbus_proxy.cc
index bf37d0a..834a3ee 100644
--- a/attestation/client/dbus_proxy.cc
+++ b/attestation/client/dbus_proxy.cc
@@ -57,12 +57,8 @@
callback.Run(reply);
};
brillo::dbus_utils::CallMethodWithTimeout(
- kDBusTimeoutMS,
- object_proxy_,
- attestation::kAttestationInterface,
- attestation::kCreateGoogleAttestedKey,
- callback,
- base::Bind(on_error),
+ kDBusTimeoutMS, object_proxy_, attestation::kAttestationInterface,
+ attestation::kCreateGoogleAttestedKey, callback, base::Bind(on_error),
request);
}
@@ -74,13 +70,8 @@
callback.Run(reply);
};
brillo::dbus_utils::CallMethodWithTimeout(
- kDBusTimeoutMS,
- object_proxy_,
- attestation::kAttestationInterface,
- attestation::kGetKeyInfo,
- callback,
- base::Bind(on_error),
- request);
+ kDBusTimeoutMS, object_proxy_, attestation::kAttestationInterface,
+ attestation::kGetKeyInfo, callback, base::Bind(on_error), request);
}
void DBusProxy::GetEndorsementInfo(const GetEndorsementInfoRequest& request,
@@ -91,12 +82,8 @@
callback.Run(reply);
};
brillo::dbus_utils::CallMethodWithTimeout(
- kDBusTimeoutMS,
- object_proxy_,
- attestation::kAttestationInterface,
- attestation::kGetEndorsementInfo,
- callback,
- base::Bind(on_error),
+ kDBusTimeoutMS, object_proxy_, attestation::kAttestationInterface,
+ attestation::kGetEndorsementInfo, callback, base::Bind(on_error),
request);
}
@@ -109,12 +96,8 @@
callback.Run(reply);
};
brillo::dbus_utils::CallMethodWithTimeout(
- kDBusTimeoutMS,
- object_proxy_,
- attestation::kAttestationInterface,
- attestation::kGetAttestationKeyInfo,
- callback,
- base::Bind(on_error),
+ kDBusTimeoutMS, object_proxy_, attestation::kAttestationInterface,
+ attestation::kGetAttestationKeyInfo, callback, base::Bind(on_error),
request);
}
@@ -127,12 +110,8 @@
callback.Run(reply);
};
brillo::dbus_utils::CallMethodWithTimeout(
- kDBusTimeoutMS,
- object_proxy_,
- attestation::kAttestationInterface,
- attestation::kActivateAttestationKey,
- callback,
- base::Bind(on_error),
+ kDBusTimeoutMS, object_proxy_, attestation::kAttestationInterface,
+ attestation::kActivateAttestationKey, callback, base::Bind(on_error),
request);
}
@@ -145,12 +124,8 @@
callback.Run(reply);
};
brillo::dbus_utils::CallMethodWithTimeout(
- kDBusTimeoutMS,
- object_proxy_,
- attestation::kAttestationInterface,
- attestation::kCreateCertifiableKey,
- callback,
- base::Bind(on_error),
+ kDBusTimeoutMS, object_proxy_, attestation::kAttestationInterface,
+ attestation::kCreateCertifiableKey, callback, base::Bind(on_error),
request);
}
@@ -162,13 +137,8 @@
callback.Run(reply);
};
brillo::dbus_utils::CallMethodWithTimeout(
- kDBusTimeoutMS,
- object_proxy_,
- attestation::kAttestationInterface,
- attestation::kDecrypt,
- callback,
- base::Bind(on_error),
- request);
+ kDBusTimeoutMS, object_proxy_, attestation::kAttestationInterface,
+ attestation::kDecrypt, callback, base::Bind(on_error), request);
}
void DBusProxy::Sign(const SignRequest& request, const SignCallback& callback) {
@@ -178,13 +148,8 @@
callback.Run(reply);
};
brillo::dbus_utils::CallMethodWithTimeout(
- kDBusTimeoutMS,
- object_proxy_,
- attestation::kAttestationInterface,
- attestation::kSign,
- callback,
- base::Bind(on_error),
- request);
+ kDBusTimeoutMS, object_proxy_, attestation::kAttestationInterface,
+ attestation::kSign, callback, base::Bind(on_error), request);
}
void DBusProxy::RegisterKeyWithChapsToken(
@@ -196,12 +161,8 @@
callback.Run(reply);
};
brillo::dbus_utils::CallMethodWithTimeout(
- kDBusTimeoutMS,
- object_proxy_,
- attestation::kAttestationInterface,
- attestation::kRegisterKeyWithChapsToken,
- callback,
- base::Bind(on_error),
+ kDBusTimeoutMS, object_proxy_, attestation::kAttestationInterface,
+ attestation::kRegisterKeyWithChapsToken, callback, base::Bind(on_error),
request);
}
diff --git a/attestation/client/dbus_proxy_test.cc b/attestation/client/dbus_proxy_test.cc
index 7170a28..39daa3c 100644
--- a/attestation/client/dbus_proxy_test.cc
+++ b/attestation/client/dbus_proxy_test.cc
@@ -38,6 +38,7 @@
nullptr, "", dbus::ObjectPath(""));
proxy_.set_object_proxy(mock_object_proxy_.get());
}
+
protected:
scoped_refptr<StrictMock<dbus::MockObjectProxy>> mock_object_proxy_;
DBusProxy proxy_;
@@ -399,11 +400,11 @@
// Set expectations on the outputs.
int callback_count = 0;
- auto callback = [&callback_count](
- const RegisterKeyWithChapsTokenReply& reply) {
- callback_count++;
- EXPECT_EQ(STATUS_SUCCESS, reply.status());
- };
+ auto callback =
+ [&callback_count](const RegisterKeyWithChapsTokenReply& reply) {
+ callback_count++;
+ EXPECT_EQ(STATUS_SUCCESS, reply.status());
+ };
RegisterKeyWithChapsTokenRequest request;
request.set_key_label("label");
request.set_username("user");
diff --git a/attestation/client/main.cc b/attestation/client/main.cc
index 868b42c..328899a 100644
--- a/attestation/client/main.cc
+++ b/attestation/client/main.cc
@@ -147,11 +147,9 @@
task = base::Bind(&ClientLoop::CallCreateCertifiableKey,
weak_factory_.GetWeakPtr(),
command_line->GetSwitchValueASCII("label"),
- command_line->GetSwitchValueASCII("user"),
- usage);
+ command_line->GetSwitchValueASCII("user"), usage);
} else if (args.front() == kInfoCommand) {
- task = base::Bind(&ClientLoop::CallGetKeyInfo,
- weak_factory_.GetWeakPtr(),
+ task = base::Bind(&ClientLoop::CallGetKeyInfo, weak_factory_.GetWeakPtr(),
command_line->GetSwitchValueASCII("label"),
command_line->GetSwitchValueASCII("user"));
} else if (args.front() == kEndorsementCommand) {
@@ -171,8 +169,7 @@
return EX_NOINPUT;
}
task = base::Bind(&ClientLoop::CallActivateAttestationKey,
- weak_factory_.GetWeakPtr(),
- input);
+ weak_factory_.GetWeakPtr(), input);
} else if (args.front() == kEncryptForActivateCommand) {
if (!command_line->HasSwitch("input") ||
!command_line->HasSwitch("output")) {
@@ -185,8 +182,7 @@
return EX_NOINPUT;
}
task = base::Bind(&ClientLoop::EncryptForActivate,
- weak_factory_.GetWeakPtr(),
- input);
+ weak_factory_.GetWeakPtr(), input);
} else if (args.front() == kEncryptCommand) {
if (!command_line->HasSwitch("input") ||
!command_line->HasSwitch("output")) {
@@ -198,11 +194,9 @@
LOG(ERROR) << "Failed to read file: " << filename.value();
return EX_NOINPUT;
}
- task = base::Bind(&ClientLoop::Encrypt,
- weak_factory_.GetWeakPtr(),
+ task = base::Bind(&ClientLoop::Encrypt, weak_factory_.GetWeakPtr(),
command_line->GetSwitchValueASCII("label"),
- command_line->GetSwitchValueASCII("user"),
- input);
+ command_line->GetSwitchValueASCII("user"), input);
} else if (args.front() == kDecryptCommand) {
if (!command_line->HasSwitch("input")) {
return EX_USAGE;
@@ -213,11 +207,9 @@
LOG(ERROR) << "Failed to read file: " << filename.value();
return EX_NOINPUT;
}
- task = base::Bind(&ClientLoop::CallDecrypt,
- weak_factory_.GetWeakPtr(),
+ task = base::Bind(&ClientLoop::CallDecrypt, weak_factory_.GetWeakPtr(),
command_line->GetSwitchValueASCII("label"),
- command_line->GetSwitchValueASCII("user"),
- input);
+ command_line->GetSwitchValueASCII("user"), input);
} else if (args.front() == kSignCommand) {
if (!command_line->HasSwitch("input")) {
return EX_USAGE;
@@ -228,11 +220,9 @@
LOG(ERROR) << "Failed to read file: " << filename.value();
return EX_NOINPUT;
}
- task = base::Bind(&ClientLoop::CallSign,
- weak_factory_.GetWeakPtr(),
+ task = base::Bind(&ClientLoop::CallSign, weak_factory_.GetWeakPtr(),
command_line->GetSwitchValueASCII("label"),
- command_line->GetSwitchValueASCII("user"),
- input);
+ command_line->GetSwitchValueASCII("user"), input);
} else if (args.front() == kVerifyCommand) {
if (!command_line->HasSwitch("input") ||
!command_line->HasSwitch("signature")) {
@@ -250,15 +240,12 @@
LOG(ERROR) << "Failed to read file: " << filename2.value();
return EX_NOINPUT;
}
- task = base::Bind(&ClientLoop::VerifySignature,
- weak_factory_.GetWeakPtr(),
- command_line->GetSwitchValueASCII("label"),
- command_line->GetSwitchValueASCII("user"),
- input,
- signature);
+ task = base::Bind(
+ &ClientLoop::VerifySignature, weak_factory_.GetWeakPtr(),
+ command_line->GetSwitchValueASCII("label"),
+ command_line->GetSwitchValueASCII("user"), input, signature);
} else if (args.front() == kRegisterCommand) {
- task = base::Bind(&ClientLoop::CallRegister,
- weak_factory_.GetWeakPtr(),
+ task = base::Bind(&ClientLoop::CallRegister, weak_factory_.GetWeakPtr(),
command_line->GetSwitchValueASCII("label"),
command_line->GetSwitchValueASCII("user"));
} else {
@@ -275,8 +262,8 @@
}
void WriteOutput(const std::string& output) {
- base::FilePath filename(base::CommandLine::ForCurrentProcess()->
- GetSwitchValueASCII("output"));
+ base::FilePath filename(
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII("output"));
if (base::WriteFile(filename, output.data(), output.size()) !=
static_cast<int>(output.size())) {
LOG(ERROR) << "Failed to write file: " << filename.value();
@@ -303,9 +290,8 @@
request.set_key_label(label);
request.set_username(username);
attestation_->GetKeyInfo(
- request,
- base::Bind(&ClientLoop::PrintReplyAndQuit<GetKeyInfoReply>,
- weak_factory_.GetWeakPtr()));
+ request, base::Bind(&ClientLoop::PrintReplyAndQuit<GetKeyInfoReply>,
+ weak_factory_.GetWeakPtr()));
}
void CallGetEndorsementInfo() {
@@ -341,10 +327,8 @@
GetEndorsementInfoRequest request;
request.set_key_type(KEY_TYPE_RSA);
attestation_->GetEndorsementInfo(
- request,
- base::Bind(&ClientLoop::EncryptForActivate2,
- weak_factory_.GetWeakPtr(),
- input));
+ request, base::Bind(&ClientLoop::EncryptForActivate2,
+ weak_factory_.GetWeakPtr(), input));
}
void EncryptForActivate2(const std::string& input,
@@ -356,10 +340,8 @@
request.set_key_type(KEY_TYPE_RSA);
attestation_->GetAttestationKeyInfo(
request,
- base::Bind(&ClientLoop::EncryptForActivate3,
- weak_factory_.GetWeakPtr(),
- input,
- endorsement_info));
+ base::Bind(&ClientLoop::EncryptForActivate3, weak_factory_.GetWeakPtr(),
+ input, endorsement_info));
}
void EncryptForActivate3(
@@ -372,10 +354,8 @@
CryptoUtilityImpl crypto(nullptr);
EncryptedIdentityCredential encrypted;
if (!crypto.EncryptIdentityCredential(
- input,
- endorsement_info.ek_public_key(),
- attestation_key_info.public_key_tpm_format(),
- &encrypted)) {
+ input, endorsement_info.ek_public_key(),
+ attestation_key_info.public_key_tpm_format(), &encrypted)) {
QuitWithExitCode(EX_SOFTWARE);
}
std::string output;
@@ -404,13 +384,12 @@
GetKeyInfoRequest request;
request.set_key_label(label);
request.set_username(username);
- attestation_->GetKeyInfo(request, base::Bind(&ClientLoop::Encrypt2,
- weak_factory_.GetWeakPtr(),
- input));
+ attestation_->GetKeyInfo(
+ request,
+ base::Bind(&ClientLoop::Encrypt2, weak_factory_.GetWeakPtr(), input));
}
- void Encrypt2(const std::string& input,
- const GetKeyInfoReply& key_info) {
+ void Encrypt2(const std::string& input, const GetKeyInfoReply& key_info) {
CryptoUtilityImpl crypto(nullptr);
std::string output;
if (!crypto.EncryptForUnbind(key_info.public_key(), input, &output)) {
@@ -428,9 +407,8 @@
request.set_username(username);
request.set_encrypted_data(input);
attestation_->Decrypt(
- request,
- base::Bind(&ClientLoop::PrintReplyAndQuit<DecryptReply>,
- weak_factory_.GetWeakPtr()));
+ request, base::Bind(&ClientLoop::PrintReplyAndQuit<DecryptReply>,
+ weak_factory_.GetWeakPtr()));
}
void CallSign(const std::string& label,
@@ -459,9 +437,9 @@
GetKeyInfoRequest request;
request.set_key_label(label);
request.set_username(username);
- attestation_->GetKeyInfo(request, base::Bind(&ClientLoop::VerifySignature2,
- weak_factory_.GetWeakPtr(),
- input, signature));
+ attestation_->GetKeyInfo(
+ request, base::Bind(&ClientLoop::VerifySignature2,
+ weak_factory_.GetWeakPtr(), input, signature));
}
void VerifySignature2(const std::string& input,
@@ -480,9 +458,11 @@
RegisterKeyWithChapsTokenRequest request;
request.set_key_label(label);
request.set_username(username);
- attestation_->RegisterKeyWithChapsToken(request, base::Bind(
- &ClientLoop::PrintReplyAndQuit<RegisterKeyWithChapsTokenReply>,
- weak_factory_.GetWeakPtr()));
+ attestation_->RegisterKeyWithChapsToken(
+ request,
+ base::Bind(
+ &ClientLoop::PrintReplyAndQuit<RegisterKeyWithChapsTokenReply>,
+ weak_factory_.GetWeakPtr()));
}
std::unique_ptr<attestation::AttestationInterface> attestation_;
diff --git a/attestation/common/crypto_utility_impl.cc b/attestation/common/crypto_utility_impl.cc
index c506fcb..548bf35 100644
--- a/attestation/common/crypto_utility_impl.cc
+++ b/attestation/common/crypto_utility_impl.cc
@@ -142,9 +142,8 @@
LOG(ERROR) << __func__ << ": Failed to parse protobuf.";
return false;
}
- std::string mac = HmacSha512(
- encrypted_pb.iv() + encrypted_pb.encrypted_data(),
- aes_key);
+ std::string mac =
+ HmacSha512(encrypted_pb.iv() + encrypted_pb.encrypted_data(), aes_key);
if (mac.length() != encrypted_pb.mac().length()) {
LOG(ERROR) << __func__ << ": Corrupted data in encrypted pb.";
return false;
@@ -166,18 +165,18 @@
const std::string& public_key,
std::string* public_key_info) {
auto asn1_ptr = reinterpret_cast<const unsigned char*>(public_key.data());
- crypto::ScopedRSA rsa(d2i_RSAPublicKey(nullptr, &asn1_ptr,
- public_key.size()));
+ crypto::ScopedRSA rsa(
+ d2i_RSAPublicKey(nullptr, &asn1_ptr, public_key.size()));
if (!rsa.get()) {
- LOG(ERROR) << __func__ << ": Failed to decode public key: "
- << GetOpenSSLError();
+ LOG(ERROR) << __func__
+ << ": Failed to decode public key: " << GetOpenSSLError();
return false;
}
unsigned char* buffer = nullptr;
int length = i2d_RSA_PUBKEY(rsa.get(), &buffer);
if (length <= 0) {
- LOG(ERROR) << __func__ << ": Failed to encode public key: "
- << GetOpenSSLError();
+ LOG(ERROR) << __func__
+ << ": Failed to encode public key: " << GetOpenSSLError();
return false;
}
crypto::ScopedOpenSSLBytes scoped_buffer(buffer);
@@ -187,20 +186,20 @@
bool CryptoUtilityImpl::GetRSAPublicKey(const std::string& public_key_info,
std::string* public_key) {
- auto asn1_ptr = reinterpret_cast<const unsigned char*>(
- public_key_info.data());
- crypto::ScopedRSA rsa(d2i_RSA_PUBKEY(NULL, &asn1_ptr,
- public_key_info.size()));
+ auto asn1_ptr =
+ reinterpret_cast<const unsigned char*>(public_key_info.data());
+ crypto::ScopedRSA rsa(
+ d2i_RSA_PUBKEY(NULL, &asn1_ptr, public_key_info.size()));
if (!rsa.get()) {
- LOG(ERROR) << __func__ << ": Failed to decode public key: "
- << GetOpenSSLError();
+ LOG(ERROR) << __func__
+ << ": Failed to decode public key: " << GetOpenSSLError();
return false;
}
unsigned char* buffer = NULL;
int length = i2d_RSAPublicKey(rsa.get(), &buffer);
if (length <= 0) {
- LOG(ERROR) << __func__ << ": Failed to encode public key: "
- << GetOpenSSLError();
+ LOG(ERROR) << __func__
+ << ": Failed to encode public key: " << GetOpenSSLError();
return false;
}
crypto::ScopedOpenSSLBytes scoped_buffer(buffer);
@@ -213,10 +212,10 @@
const std::string& ek_public_key_info,
const std::string& aik_public_key,
EncryptedIdentityCredential* encrypted) {
- const char kAlgAES256 = 9; // This comes from TPM_ALG_AES256.
+ const char kAlgAES256 = 9; // This comes from TPM_ALG_AES256.
const char kEncModeCBC = 2; // This comes from TPM_SYM_MODE_CBC.
- const char kAsymContentHeader[] =
- {0, 0, 0, kAlgAES256, 0, kEncModeCBC, 0, kAesKeySize};
+ const char kAsymContentHeader[] = {0, 0, 0, kAlgAES256,
+ 0, kEncModeCBC, 0, kAesKeySize};
const char kSymContentHeader[12] = {};
// Generate an AES key and encrypt the credential.
@@ -234,17 +233,17 @@
// Construct a TPM_ASYM_CA_CONTENTS structure.
std::string asym_header(std::begin(kAsymContentHeader),
std::end(kAsymContentHeader));
- std::string asym_content = asym_header + aes_key +
- base::SHA1HashString(aik_public_key);
+ std::string asym_content =
+ asym_header + aes_key + base::SHA1HashString(aik_public_key);
// Encrypt the TPM_ASYM_CA_CONTENTS with the EK public key.
- auto asn1_ptr = reinterpret_cast<const unsigned char*>(
- ek_public_key_info.data());
- crypto::ScopedRSA rsa(d2i_RSA_PUBKEY(NULL, &asn1_ptr,
- ek_public_key_info.size()));
+ auto asn1_ptr =
+ reinterpret_cast<const unsigned char*>(ek_public_key_info.data());
+ crypto::ScopedRSA rsa(
+ d2i_RSA_PUBKEY(NULL, &asn1_ptr, ek_public_key_info.size()));
if (!rsa.get()) {
- LOG(ERROR) << __func__ << ": Failed to decode EK public key: "
- << GetOpenSSLError();
+ LOG(ERROR) << __func__
+ << ": Failed to decode EK public key: " << GetOpenSSLError();
return false;
}
std::string encrypted_asym_content;
@@ -279,8 +278,8 @@
auto asn1_ptr = reinterpret_cast<const unsigned char*>(public_key.data());
crypto::ScopedRSA rsa(d2i_RSA_PUBKEY(NULL, &asn1_ptr, public_key.size()));
if (!rsa.get()) {
- LOG(ERROR) << __func__ << ": Failed to decode public key: "
- << GetOpenSSLError();
+ LOG(ERROR) << __func__
+ << ": Failed to decode public key: " << GetOpenSSLError();
return false;
}
if (!TpmCompatibleOAEPEncrypt(bound_data, rsa.get(), encrypted_data)) {
@@ -296,16 +295,16 @@
auto asn1_ptr = reinterpret_cast<const unsigned char*>(public_key.data());
crypto::ScopedRSA rsa(d2i_RSA_PUBKEY(NULL, &asn1_ptr, public_key.size()));
if (!rsa.get()) {
- LOG(ERROR) << __func__ << ": Failed to decode public key: "
- << GetOpenSSLError();
+ LOG(ERROR) << __func__
+ << ": Failed to decode public key: " << GetOpenSSLError();
return false;
}
std::string digest = crypto::SHA256HashString(data);
auto digest_buffer = reinterpret_cast<const unsigned char*>(digest.data());
std::string mutable_signature(signature);
unsigned char* signature_buffer = StringAsOpenSSLBuffer(&mutable_signature);
- return (RSA_verify(NID_sha256, digest_buffer, digest.size(),
- signature_buffer, signature.size(), rsa.get()) == 1);
+ return (RSA_verify(NID_sha256, digest_buffer, digest.size(), signature_buffer,
+ signature.size(), rsa.get()) == 1);
}
bool CryptoUtilityImpl::AesEncrypt(const std::string& data,
@@ -327,8 +326,8 @@
unsigned char* iv_buffer = StringAsOpenSSLBuffer(&mutable_iv);
// Allocate enough space for the output (including padding).
encrypted_data->resize(data.size() + kAesBlockSize);
- auto output_buffer = reinterpret_cast<unsigned char*>(
- string_as_array(encrypted_data));
+ auto output_buffer =
+ reinterpret_cast<unsigned char*>(string_as_array(encrypted_data));
int output_size = 0;
const EVP_CIPHER* cipher = EVP_aes_256_cbc();
EVP_CIPHER_CTX encryption_context;
@@ -445,22 +444,22 @@
const unsigned char oaep_param[4] = {'T', 'C', 'P', 'A'};
std::string padded_input;
padded_input.resize(RSA_size(key));
- auto padded_buffer = reinterpret_cast<unsigned char*>(
- string_as_array(&padded_input));
+ auto padded_buffer =
+ reinterpret_cast<unsigned char*>(string_as_array(&padded_input));
auto input_buffer = reinterpret_cast<const unsigned char*>(input.data());
int result = RSA_padding_add_PKCS1_OAEP(padded_buffer, padded_input.size(),
input_buffer, input.size(),
oaep_param, arraysize(oaep_param));
if (!result) {
- LOG(ERROR) << __func__ << ": Failed to add OAEP padding: "
- << GetOpenSSLError();
+ LOG(ERROR) << __func__
+ << ": Failed to add OAEP padding: " << GetOpenSSLError();
return false;
}
output->resize(padded_input.size());
- auto output_buffer = reinterpret_cast<unsigned char*>(
- string_as_array(output));
- result = RSA_public_encrypt(padded_input.size(), padded_buffer,
- output_buffer, key, RSA_NO_PADDING);
+ auto output_buffer =
+ reinterpret_cast<unsigned char*>(string_as_array(output));
+ result = RSA_public_encrypt(padded_input.size(), padded_buffer, output_buffer,
+ key, RSA_NO_PADDING);
if (result == -1) {
LOG(ERROR) << __func__ << ": Failed to encrypt OAEP padded input: "
<< GetOpenSSLError();
diff --git a/attestation/common/crypto_utility_impl_test.cc b/attestation/common/crypto_utility_impl_test.cc
index 9d37583..92b25da 100644
--- a/attestation/common/crypto_utility_impl_test.cc
+++ b/attestation/common/crypto_utility_impl_test.cc
@@ -87,8 +87,8 @@
EXPECT_TRUE(crypto_utility_->CreateSealedKey(&key, &sealed_key));
std::string data("test");
std::string encrypted_data;
- EXPECT_TRUE(crypto_utility_->EncryptData(data, key, sealed_key,
- &encrypted_data));
+ EXPECT_TRUE(
+ crypto_utility_->EncryptData(data, key, sealed_key, &encrypted_data));
key.clear();
sealed_key.clear();
data.clear();
@@ -123,8 +123,7 @@
}
TEST_F(CryptoUtilityImplTest, UnsealError) {
- EXPECT_CALL(mock_tpm_utility_, Unseal(_, _))
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(mock_tpm_utility_, Unseal(_, _)).WillRepeatedly(Return(false));
std::string key(32, 0);
std::string data;
EXPECT_TRUE(crypto_utility_->EncryptData("data", key, key, &data));
@@ -162,8 +161,8 @@
TEST_F(CryptoUtilityImplTest, GetRSASubjectPublicKeyInfoBadInput) {
std::string public_key = "bad_public_key";
std::string output;
- EXPECT_FALSE(crypto_utility_->GetRSASubjectPublicKeyInfo(public_key,
- &output));
+ EXPECT_FALSE(
+ crypto_utility_->GetRSASubjectPublicKeyInfo(public_key, &output));
}
TEST_F(CryptoUtilityImplTest, GetRSASubjectPublicKeyInfoPairWise) {
@@ -181,20 +180,16 @@
EXPECT_TRUE(crypto_utility_->GetRSASubjectPublicKeyInfo(public_key,
&public_key_info));
EncryptedIdentityCredential output;
- EXPECT_TRUE(crypto_utility_->EncryptIdentityCredential("credential",
- public_key_info,
- "aik",
- &output));
+ EXPECT_TRUE(crypto_utility_->EncryptIdentityCredential(
+ "credential", public_key_info, "aik", &output));
EXPECT_TRUE(output.has_asym_ca_contents());
EXPECT_TRUE(output.has_sym_ca_attestation());
}
TEST_F(CryptoUtilityImplTest, EncryptIdentityCredentialBadEK) {
EncryptedIdentityCredential output;
- EXPECT_FALSE(crypto_utility_->EncryptIdentityCredential("credential",
- "bad_ek",
- "aik",
- &output));
+ EXPECT_FALSE(crypto_utility_->EncryptIdentityCredential(
+ "credential", "bad_ek", "aik", &output));
}
TEST_F(CryptoUtilityImplTest, EncryptForUnbind) {
@@ -203,8 +198,8 @@
EXPECT_TRUE(crypto_utility_->GetRSASubjectPublicKeyInfo(public_key,
&public_key_info));
std::string output;
- EXPECT_TRUE(crypto_utility_->EncryptForUnbind(public_key_info, "input",
- &output));
+ EXPECT_TRUE(
+ crypto_utility_->EncryptForUnbind(public_key_info, "input", &output));
EXPECT_FALSE(output.empty());
}
@@ -220,8 +215,8 @@
&public_key_info));
std::string input(1000, 'A');
std::string output;
- EXPECT_FALSE(crypto_utility_->EncryptForUnbind(public_key_info, input,
- &output));
+ EXPECT_FALSE(
+ crypto_utility_->EncryptForUnbind(public_key_info, input, &output));
}
TEST_F(CryptoUtilityImplTest, VerifySignatureBadSignature) {
@@ -230,8 +225,8 @@
EXPECT_TRUE(crypto_utility_->GetRSASubjectPublicKeyInfo(public_key,
&public_key_info));
std::string output;
- EXPECT_FALSE(crypto_utility_->VerifySignature(public_key_info, "input",
- "signature"));
+ EXPECT_FALSE(
+ crypto_utility_->VerifySignature(public_key_info, "input", "signature"));
}
TEST_F(CryptoUtilityImplTest, VerifySignatureBadKey) {
diff --git a/attestation/common/mock_attestation_interface.h b/attestation/common/mock_attestation_interface.h
index cff4809..fc86653 100644
--- a/attestation/common/mock_attestation_interface.h
+++ b/attestation/common/mock_attestation_interface.h
@@ -31,21 +31,23 @@
virtual ~MockAttestationInterface() = default;
MOCK_METHOD0(Initialize, bool());
- MOCK_METHOD2(CreateGoogleAttestedKey, void(
- const CreateGoogleAttestedKeyRequest&,
- const CreateGoogleAttestedKeyCallback&));
- MOCK_METHOD2(GetKeyInfo, void(const GetKeyInfoRequest&,
- const GetKeyInfoCallback&));
- MOCK_METHOD2(GetEndorsementInfo, void(const GetEndorsementInfoRequest&,
- const GetEndorsementInfoCallback&));
+ MOCK_METHOD2(CreateGoogleAttestedKey,
+ void(const CreateGoogleAttestedKeyRequest&,
+ const CreateGoogleAttestedKeyCallback&));
+ MOCK_METHOD2(GetKeyInfo,
+ void(const GetKeyInfoRequest&, const GetKeyInfoCallback&));
+ MOCK_METHOD2(GetEndorsementInfo,
+ void(const GetEndorsementInfoRequest&,
+ const GetEndorsementInfoCallback&));
MOCK_METHOD2(GetAttestationKeyInfo,
void(const GetAttestationKeyInfoRequest&,
const GetAttestationKeyInfoCallback&));
MOCK_METHOD2(ActivateAttestationKey,
void(const ActivateAttestationKeyRequest&,
const ActivateAttestationKeyCallback&));
- MOCK_METHOD2(CreateCertifiableKey, void(const CreateCertifiableKeyRequest&,
- const CreateCertifiableKeyCallback&));
+ MOCK_METHOD2(CreateCertifiableKey,
+ void(const CreateCertifiableKeyRequest&,
+ const CreateCertifiableKeyCallback&));
MOCK_METHOD2(Decrypt, void(const DecryptRequest&, const DecryptCallback&));
MOCK_METHOD2(Sign, void(const SignRequest&, const SignCallback&));
MOCK_METHOD2(RegisterKeyWithChapsToken,
@@ -56,4 +58,3 @@
} // namespace attestation
#endif // ATTESTATION_COMMON_MOCK_ATTESTATION_INTERFACE_H_
-
diff --git a/attestation/common/mock_crypto_utility.h b/attestation/common/mock_crypto_utility.h
index 4327d55..5e6a906 100644
--- a/attestation/common/mock_crypto_utility.h
+++ b/attestation/common/mock_crypto_utility.h
@@ -32,34 +32,38 @@
MOCK_CONST_METHOD2(GetRandom, bool(size_t, std::string*));
- MOCK_METHOD2(CreateSealedKey, bool(std::string* aes_key,
- std::string* sealed_key));
+ MOCK_METHOD2(CreateSealedKey,
+ bool(std::string* aes_key, std::string* sealed_key));
- MOCK_METHOD4(EncryptData, bool(const std::string& data,
- const std::string& aes_key,
- const std::string& sealed_key,
- std::string* encrypted_data));
+ MOCK_METHOD4(EncryptData,
+ bool(const std::string& data,
+ const std::string& aes_key,
+ const std::string& sealed_key,
+ std::string* encrypted_data));
- MOCK_METHOD3(UnsealKey, bool(const std::string& encrypted_data,
- std::string* aes_key,
- std::string* sealed_key));
+ MOCK_METHOD3(UnsealKey,
+ bool(const std::string& encrypted_data,
+ std::string* aes_key,
+ std::string* sealed_key));
- MOCK_METHOD3(DecryptData, bool(const std::string& encrypted_data,
- const std::string& aes_key,
- std::string* data));
- MOCK_METHOD2(GetRSASubjectPublicKeyInfo, bool(const std::string&,
- std::string*));
+ MOCK_METHOD3(DecryptData,
+ bool(const std::string& encrypted_data,
+ const std::string& aes_key,
+ std::string* data));
+ MOCK_METHOD2(GetRSASubjectPublicKeyInfo,
+ bool(const std::string&, std::string*));
MOCK_METHOD2(GetRSAPublicKey, bool(const std::string&, std::string*));
- MOCK_METHOD4(EncryptIdentityCredential, bool(const std::string&,
- const std::string&,
- const std::string&,
- EncryptedIdentityCredential*));
- MOCK_METHOD3(EncryptForUnbind, bool(const std::string&,
- const std::string&,
- std::string*));
- MOCK_METHOD3(VerifySignature, bool(const std::string&,
- const std::string&,
- const std::string&));
+ MOCK_METHOD4(EncryptIdentityCredential,
+ bool(const std::string&,
+ const std::string&,
+ const std::string&,
+ EncryptedIdentityCredential*));
+ MOCK_METHOD3(EncryptForUnbind,
+ bool(const std::string&, const std::string&, std::string*));
+ MOCK_METHOD3(VerifySignature,
+ bool(const std::string&,
+ const std::string&,
+ const std::string&));
};
} // namespace attestation
diff --git a/attestation/common/mock_tpm_utility.h b/attestation/common/mock_tpm_utility.h
index 46ccfb9..92285a4 100644
--- a/attestation/common/mock_tpm_utility.h
+++ b/attestation/common/mock_tpm_utility.h
@@ -37,28 +37,30 @@
const std::string& input);
MOCK_METHOD0(IsTpmReady, bool());
- MOCK_METHOD6(ActivateIdentity, bool(const std::string&,
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&,
- std::string*));
- MOCK_METHOD9(CreateCertifiedKey, bool(KeyType,
- KeyUsage,
- const std::string&,
- const std::string&,
- std::string*,
- std::string*,
- std::string*,
- std::string*,
- std::string*));
+ MOCK_METHOD6(ActivateIdentity,
+ bool(const std::string&,
+ const std::string&,
+ const std::string&,
+ const std::string&,
+ const std::string&,
+ std::string*));
+ MOCK_METHOD9(CreateCertifiedKey,
+ bool(KeyType,
+ KeyUsage,
+ const std::string&,
+ const std::string&,
+ std::string*,
+ std::string*,
+ std::string*,
+ std::string*,
+ std::string*));
MOCK_METHOD2(SealToPCR0, bool(const std::string&, std::string*));
MOCK_METHOD2(Unseal, bool(const std::string&, std::string*));
MOCK_METHOD1(GetEndorsementPublicKey, bool(std::string*));
- MOCK_METHOD3(Unbind, bool(const std::string&, const std::string&,
- std::string*));
- MOCK_METHOD3(Sign, bool(const std::string&, const std::string&,
- std::string*));
+ MOCK_METHOD3(Unbind,
+ bool(const std::string&, const std::string&, std::string*));
+ MOCK_METHOD3(Sign,
+ bool(const std::string&, const std::string&, std::string*));
};
} // namespace attestation
diff --git a/attestation/common/print_common_proto.cc b/attestation/common/print_common_proto.cc
index 077157e..2bd4f3f 100644
--- a/attestation/common/print_common_proto.cc
+++ b/attestation/common/print_common_proto.cc
@@ -98,24 +98,26 @@
}
if (value.has_quoted_data()) {
output += indent + " quoted_data: ";
- base::StringAppendF(&output, "%s",
- base::HexEncode(value.quoted_data().data(),
- value.quoted_data().size()).c_str());
+ base::StringAppendF(
+ &output, "%s",
+ base::HexEncode(value.quoted_data().data(), value.quoted_data().size())
+ .c_str());
output += "\n";
}
if (value.has_quoted_pcr_value()) {
output += indent + " quoted_pcr_value: ";
- base::StringAppendF(
- &output, "%s",
- base::HexEncode(value.quoted_pcr_value().data(),
- value.quoted_pcr_value().size()).c_str());
+ base::StringAppendF(&output, "%s",
+ base::HexEncode(value.quoted_pcr_value().data(),
+ value.quoted_pcr_value().size())
+ .c_str());
output += "\n";
}
if (value.has_pcr_source_hint()) {
output += indent + " pcr_source_hint: ";
- base::StringAppendF(
- &output, "%s", base::HexEncode(value.pcr_source_hint().data(),
- value.pcr_source_hint().size()).c_str());
+ base::StringAppendF(&output, "%s",
+ base::HexEncode(value.pcr_source_hint().data(),
+ value.pcr_source_hint().size())
+ .c_str());
output += "\n";
}
output += indent + "}\n";
@@ -134,9 +136,10 @@
if (value.has_wrapped_key()) {
output += indent + " wrapped_key: ";
- base::StringAppendF(&output, "%s",
- base::HexEncode(value.wrapped_key().data(),
- value.wrapped_key().size()).c_str());
+ base::StringAppendF(
+ &output, "%s",
+ base::HexEncode(value.wrapped_key().data(), value.wrapped_key().size())
+ .c_str());
output += "\n";
}
if (value.has_iv()) {
@@ -157,14 +160,16 @@
output += indent + " encrypted_data: ";
base::StringAppendF(&output, "%s",
base::HexEncode(value.encrypted_data().data(),
- value.encrypted_data().size()).c_str());
+ value.encrypted_data().size())
+ .c_str());
output += "\n";
}
if (value.has_wrapping_key_id()) {
output += indent + " wrapping_key_id: ";
- base::StringAppendF(
- &output, "%s", base::HexEncode(value.wrapping_key_id().data(),
- value.wrapping_key_id().size()).c_str());
+ base::StringAppendF(&output, "%s",
+ base::HexEncode(value.wrapping_key_id().data(),
+ value.wrapping_key_id().size())
+ .c_str());
output += "\n";
}
output += indent + "}\n";
@@ -190,9 +195,9 @@
}
if (value.has_signature()) {
output += indent + " signature: ";
- base::StringAppendF(&output, "%s",
- base::HexEncode(value.signature().data(),
- value.signature().size()).c_str());
+ base::StringAppendF(&output, "%s", base::HexEncode(value.signature().data(),
+ value.signature().size())
+ .c_str());
output += "\n";
}
output += indent + "}\n";
@@ -212,18 +217,18 @@
if (value.has_asym_ca_contents()) {
output += indent + " asym_ca_contents: ";
- base::StringAppendF(
- &output, "%s",
- base::HexEncode(value.asym_ca_contents().data(),
- value.asym_ca_contents().size()).c_str());
+ base::StringAppendF(&output, "%s",
+ base::HexEncode(value.asym_ca_contents().data(),
+ value.asym_ca_contents().size())
+ .c_str());
output += "\n";
}
if (value.has_sym_ca_attestation()) {
output += indent + " sym_ca_attestation: ";
- base::StringAppendF(
- &output, "%s",
- base::HexEncode(value.sym_ca_attestation().data(),
- value.sym_ca_attestation().size()).c_str());
+ base::StringAppendF(&output, "%s",
+ base::HexEncode(value.sym_ca_attestation().data(),
+ value.sym_ca_attestation().size())
+ .c_str());
output += "\n";
}
output += indent + "}\n";
diff --git a/attestation/common/print_interface_proto.cc b/attestation/common/print_interface_proto.cc
index 6776e96..44f373d 100644
--- a/attestation/common/print_interface_proto.cc
+++ b/attestation/common/print_interface_proto.cc
@@ -78,23 +78,24 @@
}
if (value.has_key_type()) {
output += indent + " key_type: ";
- base::StringAppendF(&output, "%s",
- GetProtoDebugStringWithIndent(value.key_type(),
- indent_size + 2).c_str());
+ base::StringAppendF(&output, "%s", GetProtoDebugStringWithIndent(
+ value.key_type(), indent_size + 2)
+ .c_str());
output += "\n";
}
if (value.has_key_usage()) {
output += indent + " key_usage: ";
- base::StringAppendF(&output, "%s",
- GetProtoDebugStringWithIndent(value.key_usage(),
- indent_size + 2).c_str());
+ base::StringAppendF(&output, "%s", GetProtoDebugStringWithIndent(
+ value.key_usage(), indent_size + 2)
+ .c_str());
output += "\n";
}
if (value.has_certificate_profile()) {
output += indent + " certificate_profile: ";
- base::StringAppendF(&output, "%s", GetProtoDebugStringWithIndent(
- value.certificate_profile(),
- indent_size + 2).c_str());
+ base::StringAppendF(&output, "%s",
+ GetProtoDebugStringWithIndent(
+ value.certificate_profile(), indent_size + 2)
+ .c_str());
output += "\n";
}
if (value.has_username()) {
@@ -186,45 +187,48 @@
}
if (value.has_key_type()) {
output += indent + " key_type: ";
- base::StringAppendF(&output, "%s",
- GetProtoDebugStringWithIndent(value.key_type(),
- indent_size + 2).c_str());
+ base::StringAppendF(&output, "%s", GetProtoDebugStringWithIndent(
+ value.key_type(), indent_size + 2)
+ .c_str());
output += "\n";
}
if (value.has_key_usage()) {
output += indent + " key_usage: ";
- base::StringAppendF(&output, "%s",
- GetProtoDebugStringWithIndent(value.key_usage(),
- indent_size + 2).c_str());
+ base::StringAppendF(&output, "%s", GetProtoDebugStringWithIndent(
+ value.key_usage(), indent_size + 2)
+ .c_str());
output += "\n";
}
if (value.has_public_key()) {
output += indent + " public_key: ";
- base::StringAppendF(&output, "%s",
- base::HexEncode(value.public_key().data(),
- value.public_key().size()).c_str());
+ base::StringAppendF(
+ &output, "%s",
+ base::HexEncode(value.public_key().data(), value.public_key().size())
+ .c_str());
output += "\n";
}
if (value.has_certify_info()) {
output += indent + " certify_info: ";
base::StringAppendF(&output, "%s",
base::HexEncode(value.certify_info().data(),
- value.certify_info().size()).c_str());
+ value.certify_info().size())
+ .c_str());
output += "\n";
}
if (value.has_certify_info_signature()) {
output += indent + " certify_info_signature: ";
- base::StringAppendF(
- &output, "%s",
- base::HexEncode(value.certify_info_signature().data(),
- value.certify_info_signature().size()).c_str());
+ base::StringAppendF(&output, "%s",
+ base::HexEncode(value.certify_info_signature().data(),
+ value.certify_info_signature().size())
+ .c_str());
output += "\n";
}
if (value.has_certificate()) {
output += indent + " certificate: ";
- base::StringAppendF(&output, "%s",
- base::HexEncode(value.certificate().data(),
- value.certificate().size()).c_str());
+ base::StringAppendF(
+ &output, "%s",
+ base::HexEncode(value.certificate().data(), value.certificate().size())
+ .c_str());
output += "\n";
}
output += indent + "}\n";
@@ -244,9 +248,9 @@
if (value.has_key_type()) {
output += indent + " key_type: ";
- base::StringAppendF(&output, "%s",
- GetProtoDebugStringWithIndent(value.key_type(),
- indent_size + 2).c_str());
+ base::StringAppendF(&output, "%s", GetProtoDebugStringWithIndent(
+ value.key_type(), indent_size + 2)
+ .c_str());
output += "\n";
}
output += indent + "}\n";
@@ -274,14 +278,16 @@
output += indent + " ek_public_key: ";
base::StringAppendF(&output, "%s",
base::HexEncode(value.ek_public_key().data(),
- value.ek_public_key().size()).c_str());
+ value.ek_public_key().size())
+ .c_str());
output += "\n";
}
if (value.has_ek_certificate()) {
output += indent + " ek_certificate: ";
base::StringAppendF(&output, "%s",
base::HexEncode(value.ek_certificate().data(),
- value.ek_certificate().size()).c_str());
+ value.ek_certificate().size())
+ .c_str());
output += "\n";
}
output += indent + "}\n";
@@ -301,9 +307,9 @@
if (value.has_key_type()) {
output += indent + " key_type: ";
- base::StringAppendF(&output, "%s",
- GetProtoDebugStringWithIndent(value.key_type(),
- indent_size + 2).c_str());
+ base::StringAppendF(&output, "%s", GetProtoDebugStringWithIndent(
+ value.key_type(), indent_size + 2)
+ .c_str());
output += "\n";
}
output += indent + "}\n";
@@ -330,38 +336,40 @@
}
if (value.has_public_key()) {
output += indent + " public_key: ";
- base::StringAppendF(&output, "%s",
- base::HexEncode(value.public_key().data(),
- value.public_key().size()).c_str());
+ base::StringAppendF(
+ &output, "%s",
+ base::HexEncode(value.public_key().data(), value.public_key().size())
+ .c_str());
output += "\n";
}
if (value.has_public_key_tpm_format()) {
output += indent + " public_key_tpm_format: ";
- base::StringAppendF(
- &output, "%s",
- base::HexEncode(value.public_key_tpm_format().data(),
- value.public_key_tpm_format().size()).c_str());
+ base::StringAppendF(&output, "%s",
+ base::HexEncode(value.public_key_tpm_format().data(),
+ value.public_key_tpm_format().size())
+ .c_str());
output += "\n";
}
if (value.has_certificate()) {
output += indent + " certificate: ";
- base::StringAppendF(&output, "%s",
- base::HexEncode(value.certificate().data(),
- value.certificate().size()).c_str());
+ base::StringAppendF(
+ &output, "%s",
+ base::HexEncode(value.certificate().data(), value.certificate().size())
+ .c_str());
output += "\n";
}
if (value.has_pcr0_quote()) {
output += indent + " pcr0_quote: ";
- base::StringAppendF(&output, "%s",
- GetProtoDebugStringWithIndent(value.pcr0_quote(),
- indent_size + 2).c_str());
+ base::StringAppendF(&output, "%s", GetProtoDebugStringWithIndent(
+ value.pcr0_quote(), indent_size + 2)
+ .c_str());
output += "\n";
}
if (value.has_pcr1_quote()) {
output += indent + " pcr1_quote: ";
- base::StringAppendF(&output, "%s",
- GetProtoDebugStringWithIndent(value.pcr1_quote(),
- indent_size + 2).c_str());
+ base::StringAppendF(&output, "%s", GetProtoDebugStringWithIndent(
+ value.pcr1_quote(), indent_size + 2)
+ .c_str());
output += "\n";
}
output += indent + "}\n";
@@ -381,16 +389,17 @@
if (value.has_key_type()) {
output += indent + " key_type: ";
- base::StringAppendF(&output, "%s",
- GetProtoDebugStringWithIndent(value.key_type(),
- indent_size + 2).c_str());
+ base::StringAppendF(&output, "%s", GetProtoDebugStringWithIndent(
+ value.key_type(), indent_size + 2)
+ .c_str());
output += "\n";
}
if (value.has_encrypted_certificate()) {
output += indent + " encrypted_certificate: ";
- base::StringAppendF(&output, "%s", GetProtoDebugStringWithIndent(
- value.encrypted_certificate(),
- indent_size + 2).c_str());
+ base::StringAppendF(&output, "%s",
+ GetProtoDebugStringWithIndent(
+ value.encrypted_certificate(), indent_size + 2)
+ .c_str());
output += "\n";
}
if (value.has_save_certificate()) {
@@ -423,9 +432,10 @@
}
if (value.has_certificate()) {
output += indent + " certificate: ";
- base::StringAppendF(&output, "%s",
- base::HexEncode(value.certificate().data(),
- value.certificate().size()).c_str());
+ base::StringAppendF(
+ &output, "%s",
+ base::HexEncode(value.certificate().data(), value.certificate().size())
+ .c_str());
output += "\n";
}
output += indent + "}\n";
@@ -455,16 +465,16 @@
}
if (value.has_key_type()) {
output += indent + " key_type: ";
- base::StringAppendF(&output, "%s",
- GetProtoDebugStringWithIndent(value.key_type(),
- indent_size + 2).c_str());
+ base::StringAppendF(&output, "%s", GetProtoDebugStringWithIndent(
+ value.key_type(), indent_size + 2)
+ .c_str());
output += "\n";
}
if (value.has_key_usage()) {
output += indent + " key_usage: ";
- base::StringAppendF(&output, "%s",
- GetProtoDebugStringWithIndent(value.key_usage(),
- indent_size + 2).c_str());
+ base::StringAppendF(&output, "%s", GetProtoDebugStringWithIndent(
+ value.key_usage(), indent_size + 2)
+ .c_str());
output += "\n";
}
output += indent + "}\n";
@@ -491,24 +501,26 @@
}
if (value.has_public_key()) {
output += indent + " public_key: ";
- base::StringAppendF(&output, "%s",
- base::HexEncode(value.public_key().data(),
- value.public_key().size()).c_str());
+ base::StringAppendF(
+ &output, "%s",
+ base::HexEncode(value.public_key().data(), value.public_key().size())
+ .c_str());
output += "\n";
}
if (value.has_certify_info()) {
output += indent + " certify_info: ";
base::StringAppendF(&output, "%s",
base::HexEncode(value.certify_info().data(),
- value.certify_info().size()).c_str());
+ value.certify_info().size())
+ .c_str());
output += "\n";
}
if (value.has_certify_info_signature()) {
output += indent + " certify_info_signature: ";
- base::StringAppendF(
- &output, "%s",
- base::HexEncode(value.certify_info_signature().data(),
- value.certify_info_signature().size()).c_str());
+ base::StringAppendF(&output, "%s",
+ base::HexEncode(value.certify_info_signature().data(),
+ value.certify_info_signature().size())
+ .c_str());
output += "\n";
}
output += indent + "}\n";
@@ -539,7 +551,8 @@
output += indent + " encrypted_data: ";
base::StringAppendF(&output, "%s",
base::HexEncode(value.encrypted_data().data(),
- value.encrypted_data().size()).c_str());
+ value.encrypted_data().size())
+ .c_str());
output += "\n";
}
output += indent + "}\n";
@@ -567,7 +580,8 @@
output += indent + " decrypted_data: ";
base::StringAppendF(&output, "%s",
base::HexEncode(value.decrypted_data().data(),
- value.decrypted_data().size()).c_str());
+ value.decrypted_data().size())
+ .c_str());
output += "\n";
}
output += indent + "}\n";
@@ -598,7 +612,8 @@
output += indent + " data_to_sign: ";
base::StringAppendF(&output, "%s",
base::HexEncode(value.data_to_sign().data(),
- value.data_to_sign().size()).c_str());
+ value.data_to_sign().size())
+ .c_str());
output += "\n";
}
output += indent + "}\n";
@@ -624,9 +639,9 @@
}
if (value.has_signature()) {
output += indent + " signature: ";
- base::StringAppendF(&output, "%s",
- base::HexEncode(value.signature().data(),
- value.signature().size()).c_str());
+ base::StringAppendF(&output, "%s", base::HexEncode(value.signature().data(),
+ value.signature().size())
+ .c_str());
output += "\n";
}
output += indent + "}\n";
diff --git a/attestation/common/tpm_utility_v1.cc b/attestation/common/tpm_utility_v1.cc
index b6bc64f..c12c3c5 100644
--- a/attestation/common/tpm_utility_v1.cc
+++ b/attestation/common/tpm_utility_v1.cc
@@ -29,9 +29,9 @@
#include <trousers/trousers.h>
#include <trousers/tss.h>
-#define TPM_LOG(severity, result) \
- LOG(severity) << "TPM error 0x" << std::hex << result \
- << " (" << Trspi_Error_String(result) << "): "
+#define TPM_LOG(severity, result) \
+ LOG(severity) << "TPM error 0x" << std::hex << result << " (" \
+ << Trspi_Error_String(result) << "): "
using trousers::ScopedTssContext;
using trousers::ScopedTssKey;
@@ -50,9 +50,8 @@
const char* kMscTpmOwnedFile = "/sys/class/misc/tpm0/device/owned";
const unsigned int kWellKnownExponent = 65537;
const unsigned char kSha256DigestInfo[] = {
- 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04,
- 0x02, 0x01, 0x05, 0x00, 0x04, 0x20
-};
+ 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01,
+ 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20};
std::string GetFirstByte(const char* file_name) {
std::string content;
@@ -117,8 +116,8 @@
// Connect to the TPM as the owner delegate.
ScopedTssContext context_handle;
TSS_HTPM tpm_handle;
- if (!ConnectContextAsDelegate(delegate_blob, delegate_secret,
- &context_handle, &tpm_handle)) {
+ if (!ConnectContextAsDelegate(delegate_blob, delegate_secret, &context_handle,
+ &tpm_handle)) {
LOG(ERROR) << __func__ << ": Could not connect to the TPM.";
return false;
}
@@ -131,15 +130,12 @@
}
// Load the AIK (which is wrapped by the SRK).
std::string mutable_identity_key_blob(identity_key_blob);
- BYTE* identity_key_blob_buffer = StringAsTSSBuffer(
- &mutable_identity_key_blob);
+ BYTE* identity_key_blob_buffer =
+ StringAsTSSBuffer(&mutable_identity_key_blob);
ScopedTssKey identity_key(context_handle);
result = Tspi_Context_LoadKeyByBlob(
- context_handle,
- srk_handle,
- identity_key_blob.size(),
- identity_key_blob_buffer,
- identity_key.ptr());
+ context_handle, srk_handle, identity_key_blob.size(),
+ identity_key_blob_buffer, identity_key.ptr());
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << __func__ << ": Failed to load AIK.";
return false;
@@ -147,23 +143,20 @@
std::string mutable_asym_ca_contents(asym_ca_contents);
BYTE* asym_ca_contents_buffer = StringAsTSSBuffer(&mutable_asym_ca_contents);
std::string mutable_sym_ca_attestation(sym_ca_attestation);
- BYTE* sym_ca_attestation_buffer = StringAsTSSBuffer(
- &mutable_sym_ca_attestation);
+ BYTE* sym_ca_attestation_buffer =
+ StringAsTSSBuffer(&mutable_sym_ca_attestation);
UINT32 credential_length = 0;
ScopedTssMemory credential_buffer(context_handle);
- result = Tspi_TPM_ActivateIdentity(tpm_handle, identity_key,
- asym_ca_contents.size(),
- asym_ca_contents_buffer,
- sym_ca_attestation.size(),
- sym_ca_attestation_buffer,
- &credential_length,
- credential_buffer.ptr());
+ result = Tspi_TPM_ActivateIdentity(
+ tpm_handle, identity_key, asym_ca_contents.size(),
+ asym_ca_contents_buffer, sym_ca_attestation.size(),
+ sym_ca_attestation_buffer, &credential_length, credential_buffer.ptr());
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << __func__ << ": Failed to activate identity.";
return false;
}
- credential->assign(TSSBufferAsString(credential_buffer.value(),
- credential_length));
+ credential->assign(
+ TSSBufferAsString(credential_buffer.value(), credential_length));
return true;
}
@@ -196,28 +189,22 @@
// Create a non-migratable RSA key.
ScopedTssKey key(context_handle_);
- UINT32 tss_key_type = (key_usage == KEY_USAGE_SIGN) ? TSS_KEY_TYPE_SIGNING :
- TSS_KEY_TYPE_BIND;
- UINT32 init_flags = tss_key_type |
- TSS_KEY_NOT_MIGRATABLE |
- TSS_KEY_VOLATILE |
- TSS_KEY_NO_AUTHORIZATION |
- TSS_KEY_SIZE_2048;
- TSS_RESULT result = Tspi_Context_CreateObject(context_handle_,
- TSS_OBJECT_TYPE_RSAKEY,
- init_flags, key.ptr());
+ UINT32 tss_key_type =
+ (key_usage == KEY_USAGE_SIGN) ? TSS_KEY_TYPE_SIGNING : TSS_KEY_TYPE_BIND;
+ UINT32 init_flags = tss_key_type | TSS_KEY_NOT_MIGRATABLE | TSS_KEY_VOLATILE |
+ TSS_KEY_NO_AUTHORIZATION | TSS_KEY_SIZE_2048;
+ TSS_RESULT result = Tspi_Context_CreateObject(
+ context_handle_, TSS_OBJECT_TYPE_RSAKEY, init_flags, key.ptr());
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << __func__ << ": Failed to create object.";
return false;
}
if (key_usage == KEY_USAGE_SIGN) {
- result = Tspi_SetAttribUint32(key,
- TSS_TSPATTRIB_KEY_INFO,
+ result = Tspi_SetAttribUint32(key, TSS_TSPATTRIB_KEY_INFO,
TSS_TSPATTRIB_KEYINFO_SIGSCHEME,
TSS_SS_RSASSAPKCS1V15_DER);
} else {
- result = Tspi_SetAttribUint32(key,
- TSS_TSPATTRIB_KEY_INFO,
+ result = Tspi_SetAttribUint32(key, TSS_TSPATTRIB_KEY_INFO,
TSS_TSPATTRIB_KEYINFO_ENCSCHEME,
TSS_ES_RSAESOAEP_SHA1_MGF1);
}
@@ -251,9 +238,7 @@
ScopedTssMemory scoped_proof(0, validation.rgbValidationData);
// Get the certified public key.
- if (!GetDataAttribute(context_handle_,
- key,
- TSS_TSPATTRIB_KEY_BLOB,
+ if (!GetDataAttribute(context_handle_, key, TSS_TSPATTRIB_KEY_BLOB,
TSS_TSPATTRIB_KEYBLOB_PUBLIC_KEY,
public_key_tpm_format)) {
LOG(ERROR) << __func__ << ": Failed to read public key.";
@@ -264,18 +249,15 @@
}
// Get the certified key blob so we can load it later.
- if (!GetDataAttribute(context_handle_,
- key,
- TSS_TSPATTRIB_KEY_BLOB,
- TSS_TSPATTRIB_KEYBLOB_BLOB,
- key_blob)) {
+ if (!GetDataAttribute(context_handle_, key, TSS_TSPATTRIB_KEY_BLOB,
+ TSS_TSPATTRIB_KEYBLOB_BLOB, key_blob)) {
LOG(ERROR) << __func__ << ": Failed to read key blob.";
return false;
}
// Get the data that was certified.
- key_info->assign(TSSBufferAsString(validation.rgbData,
- validation.ulDataLength));
+ key_info->assign(
+ TSSBufferAsString(validation.rgbData, validation.ulDataLength));
// Get the certification proof.
proof->assign(TSSBufferAsString(validation.rgbValidationData,
@@ -294,12 +276,11 @@
// Create a PCRS object which holds the value of PCR0.
ScopedTssPcrs pcrs_handle(context_handle_);
TSS_RESULT result;
- if (TPM_ERROR(result = Tspi_Context_CreateObject(context_handle_,
- TSS_OBJECT_TYPE_PCRS,
- TSS_PCRS_STRUCT_INFO,
- pcrs_handle.ptr()))) {
- TPM_LOG(ERROR, result)
- << __func__ << ": Error calling Tspi_Context_CreateObject";
+ if (TPM_ERROR(result = Tspi_Context_CreateObject(
+ context_handle_, TSS_OBJECT_TYPE_PCRS, TSS_PCRS_STRUCT_INFO,
+ pcrs_handle.ptr()))) {
+ TPM_LOG(ERROR, result) << __func__
+ << ": Error calling Tspi_Context_CreateObject";
return false;
}
UINT32 pcr_length = 0;
@@ -310,24 +291,19 @@
// Create a ENCDATA object to receive the sealed data.
ScopedTssKey encrypted_data_handle(context_handle_);
if (TPM_ERROR(result = Tspi_Context_CreateObject(
- context_handle_,
- TSS_OBJECT_TYPE_ENCDATA,
- TSS_ENCDATA_SEAL,
- encrypted_data_handle.ptr()))) {
- TPM_LOG(ERROR, result)
- << __func__ << ": Error calling Tspi_Context_CreateObject";
+ context_handle_, TSS_OBJECT_TYPE_ENCDATA, TSS_ENCDATA_SEAL,
+ encrypted_data_handle.ptr()))) {
+ TPM_LOG(ERROR, result) << __func__
+ << ": Error calling Tspi_Context_CreateObject";
return false;
}
// Seal the given value with the SRK.
std::string mutable_data(data);
BYTE* data_buffer = StringAsTSSBuffer(&mutable_data);
- if (TPM_ERROR(result = Tspi_Data_Seal(
- encrypted_data_handle,
- srk_handle_,
- data.size(),
- data_buffer,
- pcrs_handle))) {
+ if (TPM_ERROR(result =
+ Tspi_Data_Seal(encrypted_data_handle, srk_handle_,
+ data.size(), data_buffer, pcrs_handle))) {
TPM_LOG(ERROR, result) << __func__ << ": Error calling Tspi_Data_Seal";
return false;
}
@@ -335,16 +311,15 @@
// Extract the sealed value.
ScopedTssMemory encrypted_data(context_handle_);
UINT32 encrypted_data_length = 0;
- if (TPM_ERROR(result = Tspi_GetAttribData(encrypted_data_handle,
- TSS_TSPATTRIB_ENCDATA_BLOB,
- TSS_TSPATTRIB_ENCDATABLOB_BLOB,
- &encrypted_data_length,
- encrypted_data.ptr()))) {
+ if (TPM_ERROR(result = Tspi_GetAttribData(
+ encrypted_data_handle, TSS_TSPATTRIB_ENCDATA_BLOB,
+ TSS_TSPATTRIB_ENCDATABLOB_BLOB, &encrypted_data_length,
+ encrypted_data.ptr()))) {
TPM_LOG(ERROR, result) << __func__ << ": Error calling Tspi_GetAttribData";
return false;
}
- sealed_data->assign(TSSBufferAsString(encrypted_data.value(),
- encrypted_data_length));
+ sealed_data->assign(
+ TSSBufferAsString(encrypted_data.value(), encrypted_data_length));
return true;
}
@@ -359,22 +334,19 @@
ScopedTssKey encrypted_data_handle(context_handle_);
TSS_RESULT result;
if (TPM_ERROR(result = Tspi_Context_CreateObject(
- context_handle_,
- TSS_OBJECT_TYPE_ENCDATA,
- TSS_ENCDATA_SEAL,
- encrypted_data_handle.ptr()))) {
- TPM_LOG(ERROR, result)
- << __func__ << ": Error calling Tspi_Context_CreateObject";
+ context_handle_, TSS_OBJECT_TYPE_ENCDATA, TSS_ENCDATA_SEAL,
+ encrypted_data_handle.ptr()))) {
+ TPM_LOG(ERROR, result) << __func__
+ << ": Error calling Tspi_Context_CreateObject";
return false;
}
std::string mutable_sealed_data(sealed_data);
BYTE* sealed_data_buffer = StringAsTSSBuffer(&mutable_sealed_data);
- if (TPM_ERROR(result = Tspi_SetAttribData(encrypted_data_handle,
- TSS_TSPATTRIB_ENCDATA_BLOB,
- TSS_TSPATTRIB_ENCDATABLOB_BLOB,
- sealed_data.size(),
- sealed_data_buffer))) {
+ if (TPM_ERROR(result = Tspi_SetAttribData(
+ encrypted_data_handle, TSS_TSPATTRIB_ENCDATA_BLOB,
+ TSS_TSPATTRIB_ENCDATABLOB_BLOB, sealed_data.size(),
+ sealed_data_buffer))) {
TPM_LOG(ERROR, result) << __func__ << ": Error calling Tspi_SetAttribData";
return false;
}
@@ -382,15 +354,14 @@
// Unseal using the SRK.
ScopedTssMemory decrypted_data(context_handle_);
UINT32 decrypted_data_length = 0;
- if (TPM_ERROR(result = Tspi_Data_Unseal(encrypted_data_handle,
- srk_handle_,
+ if (TPM_ERROR(result = Tspi_Data_Unseal(encrypted_data_handle, srk_handle_,
&decrypted_data_length,
decrypted_data.ptr()))) {
TPM_LOG(ERROR, result) << __func__ << ": Error calling Tspi_Data_Unseal";
return false;
}
- data->assign(TSSBufferAsString(decrypted_data.value(),
- decrypted_data_length));
+ data->assign(
+ TSSBufferAsString(decrypted_data.value(), decrypted_data_length));
return true;
}
@@ -405,11 +376,9 @@
}
// Get the public key in TPM_PUBKEY form.
std::string ek_public_key_blob;
- if (!GetDataAttribute(context_handle_,
- ek_public_key_object,
- TSS_TSPATTRIB_KEY_BLOB,
- TSS_TSPATTRIB_KEYBLOB_PUBLIC_KEY,
- &ek_public_key_blob)) {
+ if (!GetDataAttribute(
+ context_handle_, ek_public_key_object, TSS_TSPATTRIB_KEY_BLOB,
+ TSS_TSPATTRIB_KEYBLOB_PUBLIC_KEY, &ek_public_key_blob)) {
LOG(ERROR) << __func__ << ": Failed to read public key.";
return false;
}
@@ -434,28 +403,25 @@
}
TSS_RESULT result;
ScopedTssEncryptedData data_handle(context_handle_);
- if (TPM_ERROR(result = Tspi_Context_CreateObject(context_handle_,
- TSS_OBJECT_TYPE_ENCDATA,
- TSS_ENCDATA_BIND,
- data_handle.ptr()))) {
+ if (TPM_ERROR(result = Tspi_Context_CreateObject(
+ context_handle_, TSS_OBJECT_TYPE_ENCDATA, TSS_ENCDATA_BIND,
+ data_handle.ptr()))) {
TPM_LOG(ERROR, result) << __func__ << ": Tspi_Context_CreateObject failed.";
return false;
}
std::string mutable_bound_data(bound_data);
if (TPM_ERROR(result = Tspi_SetAttribData(
- data_handle,
- TSS_TSPATTRIB_ENCDATA_BLOB,
- TSS_TSPATTRIB_ENCDATABLOB_BLOB,
- bound_data.size(),
- StringAsTSSBuffer(&mutable_bound_data)))) {
+ data_handle, TSS_TSPATTRIB_ENCDATA_BLOB,
+ TSS_TSPATTRIB_ENCDATABLOB_BLOB, bound_data.size(),
+ StringAsTSSBuffer(&mutable_bound_data)))) {
TPM_LOG(ERROR, result) << __func__ << ": Tspi_SetAttribData failed.";
return false;
}
ScopedTssMemory decrypted_data(context_handle_);
UINT32 length = 0;
- if (TPM_ERROR(result = Tspi_Data_Unbind(data_handle, key_handle,
- &length, decrypted_data.ptr()))) {
+ if (TPM_ERROR(result = Tspi_Data_Unbind(data_handle, key_handle, &length,
+ decrypted_data.ptr()))) {
TPM_LOG(ERROR, result) << __func__ << ": Tspi_Data_Unbind failed.";
return false;
}
@@ -481,16 +447,13 @@
digest_to_sign += crypto::SHA256HashString(data_to_sign);
// Create a hash object to hold the digest.
ScopedTssHash hash_handle(context_handle_);
- TSS_RESULT result = Tspi_Context_CreateObject(context_handle_,
- TSS_OBJECT_TYPE_HASH,
- TSS_HASH_OTHER,
- hash_handle.ptr());
+ TSS_RESULT result = Tspi_Context_CreateObject(
+ context_handle_, TSS_OBJECT_TYPE_HASH, TSS_HASH_OTHER, hash_handle.ptr());
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << __func__ << ": Failed to create hash object.";
return false;
}
- result = Tspi_Hash_SetHashValue(hash_handle,
- digest_to_sign.size(),
+ result = Tspi_Hash_SetHashValue(hash_handle, digest_to_sign.size(),
StringAsTSSBuffer(&digest_to_sign));
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << __func__ << ": Failed to set hash data.";
@@ -537,8 +500,7 @@
}
TSS_RESULT result;
TSS_HPOLICY tpm_usage_policy;
- if (TPM_ERROR(result = Tspi_GetPolicyObject(*tpm,
- TSS_POLICY_USAGE,
+ if (TPM_ERROR(result = Tspi_GetPolicyObject(*tpm, TSS_POLICY_USAGE,
&tpm_usage_policy))) {
TPM_LOG(ERROR, result) << __func__
<< ": Error calling Tspi_GetPolicyObject";
@@ -546,10 +508,9 @@
}
std::string mutable_delegate_secret(delegate_secret);
BYTE* secret_buffer = StringAsTSSBuffer(&mutable_delegate_secret);
- if (TPM_ERROR(result = Tspi_Policy_SetSecret(tpm_usage_policy,
- TSS_SECRET_MODE_PLAIN,
- delegate_secret.size(),
- secret_buffer))) {
+ if (TPM_ERROR(result = Tspi_Policy_SetSecret(
+ tpm_usage_policy, TSS_SECRET_MODE_PLAIN,
+ delegate_secret.size(), secret_buffer))) {
TPM_LOG(ERROR, result) << __func__
<< ": Error calling Tspi_Policy_SetSecret";
return false;
@@ -557,11 +518,9 @@
std::string mutable_delegate_blob(delegate_blob);
BYTE* blob_buffer = StringAsTSSBuffer(&mutable_delegate_blob);
if (TPM_ERROR(result = Tspi_SetAttribData(
- tpm_usage_policy,
- TSS_TSPATTRIB_POLICY_DELEGATION_INFO,
- TSS_TSPATTRIB_POLDEL_OWNERBLOB,
- delegate_blob.size(),
- blob_buffer))) {
+ tpm_usage_policy, TSS_TSPATTRIB_POLICY_DELEGATION_INFO,
+ TSS_TSPATTRIB_POLDEL_OWNERBLOB, delegate_blob.size(),
+ blob_buffer))) {
TPM_LOG(ERROR, result) << __func__ << ": Error calling Tspi_SetAttribData";
return false;
}
@@ -599,8 +558,7 @@
TSS_RESULT result;
TSS_UUID uuid = TSS_UUID_SRK;
if (TPM_ERROR(result = Tspi_Context_LoadKeyByUUID(context_handle,
- TSS_PS_TYPE_SYSTEM,
- uuid,
+ TSS_PS_TYPE_SYSTEM, uuid,
srk_handle->ptr()))) {
TPM_LOG(ERROR, result) << __func__
<< ": Error calling Tspi_Context_LoadKeyByUUID";
@@ -608,10 +566,9 @@
}
// Check if the SRK wants a password.
UINT32 auth_usage;
- if (TPM_ERROR(result = Tspi_GetAttribUint32(*srk_handle,
- TSS_TSPATTRIB_KEY_INFO,
- TSS_TSPATTRIB_KEYINFO_AUTHUSAGE,
- &auth_usage))) {
+ if (TPM_ERROR(result = Tspi_GetAttribUint32(
+ *srk_handle, TSS_TSPATTRIB_KEY_INFO,
+ TSS_TSPATTRIB_KEYINFO_AUTHUSAGE, &auth_usage))) {
TPM_LOG(ERROR, result) << __func__
<< ": Error calling Tspi_GetAttribUint32";
return false;
@@ -619,18 +576,17 @@
if (auth_usage) {
// Give it an empty password if needed.
TSS_HPOLICY usage_policy;
- if (TPM_ERROR(result = Tspi_GetPolicyObject(*srk_handle,
- TSS_POLICY_USAGE,
+ if (TPM_ERROR(result = Tspi_GetPolicyObject(*srk_handle, TSS_POLICY_USAGE,
&usage_policy))) {
- TPM_LOG(ERROR, result) << __func__
- << ": Error calling Tspi_GetPolicyObject";
+ TPM_LOG(ERROR, result) << __func__
+ << ": Error calling Tspi_GetPolicyObject";
return false;
}
BYTE empty_password[] = {};
- if (TPM_ERROR(result = Tspi_Policy_SetSecret(usage_policy,
- TSS_SECRET_MODE_PLAIN,
- 0, empty_password))) {
+ if (TPM_ERROR(result =
+ Tspi_Policy_SetSecret(usage_policy, TSS_SECRET_MODE_PLAIN,
+ 0, empty_password))) {
TPM_LOG(ERROR, result) << __func__
<< ": Error calling Tspi_Policy_SetSecret";
return false;
@@ -646,10 +602,7 @@
std::string mutable_key_blob(key_blob);
BYTE* key_blob_buffer = StringAsTSSBuffer(&mutable_key_blob);
TSS_RESULT result = Tspi_Context_LoadKeyByBlob(
- context_handle,
- parent_key_handle,
- key_blob.size(),
- key_blob_buffer,
+ context_handle, parent_key_handle, key_blob.size(), key_blob_buffer,
key_handle->ptr());
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << __func__ << ": Failed to load key by blob.";
@@ -665,8 +618,8 @@
std::string* data) {
UINT32 length = 0;
ScopedTssMemory buffer(context);
- TSS_RESULT result = Tspi_GetAttribData(object, flag, sub_flag, &length,
- buffer.ptr());
+ TSS_RESULT result =
+ Tspi_GetAttribData(object, flag, sub_flag, &length, buffer.ptr());
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << __func__ << "Failed to read object attribute.";
return false;
@@ -713,8 +666,8 @@
return false;
}
public_key_der->resize(der_length);
- unsigned char* der_buffer = reinterpret_cast<unsigned char*>(
- string_as_array(public_key_der));
+ unsigned char* der_buffer =
+ reinterpret_cast<unsigned char*>(string_as_array(public_key_der));
der_length = i2d_RSAPublicKey(rsa.get(), &der_buffer);
if (der_length < 0) {
LOG(ERROR) << "Failed to DER-encode public key.";
diff --git a/attestation/server/attestation_service.cc b/attestation/server/attestation_service.cc
index d7f7974..5d85afc 100644
--- a/attestation/server/attestation_service.cc
+++ b/attestation/server/attestation_service.cc
@@ -44,8 +44,7 @@
namespace attestation {
AttestationService::AttestationService()
- : attestation_ca_origin_(kACAWebOrigin),
- weak_factory_(this) {}
+ : attestation_ca_origin_(kACAWebOrigin), weak_factory_(this) {}
bool AttestationService::Initialize() {
LOG(INFO) << "Attestation service started.";
@@ -65,9 +64,9 @@
}
if (!database_) {
default_database_.reset(new DatabaseImpl(crypto_utility_));
- worker_thread_->task_runner()->PostTask(FROM_HERE, base::Bind(
- &DatabaseImpl::Initialize,
- base::Unretained(default_database_.get())));
+ worker_thread_->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&DatabaseImpl::Initialize,
+ base::Unretained(default_database_.get())));
database_ = default_database_.get();
}
if (!key_store_) {
@@ -82,16 +81,12 @@
const CreateGoogleAttestedKeyRequest& request,
const CreateGoogleAttestedKeyCallback& callback) {
auto result = std::make_shared<CreateGoogleAttestedKeyReply>();
- base::Closure task = base::Bind(
- &AttestationService::CreateGoogleAttestedKeyTask,
- base::Unretained(this),
- request,
- result);
+ base::Closure task =
+ base::Bind(&AttestationService::CreateGoogleAttestedKeyTask,
+ base::Unretained(this), request, result);
base::Closure reply = base::Bind(
&AttestationService::TaskRelayCallback<CreateGoogleAttestedKeyReply>,
- GetWeakPtr(),
- callback,
- result);
+ GetWeakPtr(), callback, result);
worker_thread_->task_runner()->PostTaskAndReply(FROM_HERE, task, reply);
}
@@ -111,9 +106,7 @@
return;
}
std::string enroll_reply;
- if (!SendACARequestAndBlock(kEnroll,
- enroll_request,
- &enroll_reply)) {
+ if (!SendACARequestAndBlock(kEnroll, enroll_request, &enroll_reply)) {
result->set_status(STATUS_CA_NOT_AVAILABLE);
return;
}
@@ -136,31 +129,23 @@
}
std::string certificate_request;
std::string message_id;
- if (!CreateCertificateRequest(request.username(),
- key,
- request.certificate_profile(),
- request.origin(),
- &certificate_request,
- &message_id)) {
+ if (!CreateCertificateRequest(request.username(), key,
+ request.certificate_profile(), request.origin(),
+ &certificate_request, &message_id)) {
result->set_status(STATUS_UNEXPECTED_DEVICE_ERROR);
return;
}
std::string certificate_reply;
- if (!SendACARequestAndBlock(kGetCertificate,
- certificate_request,
+ if (!SendACARequestAndBlock(kGetCertificate, certificate_request,
&certificate_reply)) {
result->set_status(STATUS_CA_NOT_AVAILABLE);
return;
}
std::string certificate_chain;
std::string server_error;
- if (!FinishCertificateRequest(certificate_reply,
- request.username(),
- request.key_label(),
- message_id,
- &key,
- &certificate_chain,
- &server_error)) {
+ if (!FinishCertificateRequest(certificate_reply, request.username(),
+ request.key_label(), message_id, &key,
+ &certificate_chain, &server_error)) {
if (server_error.empty()) {
result->set_status(STATUS_UNEXPECTED_DEVICE_ERROR);
return;
@@ -175,16 +160,11 @@
void AttestationService::GetKeyInfo(const GetKeyInfoRequest& request,
const GetKeyInfoCallback& callback) {
auto result = std::make_shared<GetKeyInfoReply>();
- base::Closure task = base::Bind(
- &AttestationService::GetKeyInfoTask,
- base::Unretained(this),
- request,
- result);
- base::Closure reply = base::Bind(
- &AttestationService::TaskRelayCallback<GetKeyInfoReply>,
- GetWeakPtr(),
- callback,
- result);
+ base::Closure task = base::Bind(&AttestationService::GetKeyInfoTask,
+ base::Unretained(this), request, result);
+ base::Closure reply =
+ base::Bind(&AttestationService::TaskRelayCallback<GetKeyInfoReply>,
+ GetWeakPtr(), callback, result);
worker_thread_->task_runner()->PostTaskAndReply(FROM_HERE, task, reply);
}
@@ -219,16 +199,11 @@
const GetEndorsementInfoRequest& request,
const GetEndorsementInfoCallback& callback) {
auto result = std::make_shared<GetEndorsementInfoReply>();
- base::Closure task = base::Bind(
- &AttestationService::GetEndorsementInfoTask,
- base::Unretained(this),
- request,
- result);
+ base::Closure task = base::Bind(&AttestationService::GetEndorsementInfoTask,
+ base::Unretained(this), request, result);
base::Closure reply = base::Bind(
&AttestationService::TaskRelayCallback<GetEndorsementInfoReply>,
- GetWeakPtr(),
- callback,
- result);
+ GetWeakPtr(), callback, result);
worker_thread_->task_runner()->PostTaskAndReply(FROM_HERE, task, reply);
}
@@ -252,9 +227,9 @@
}
std::string public_key_info;
if (!GetSubjectPublicKeyInfo(
- request.key_type(),
- database_pb.credentials().endorsement_public_key(),
- &public_key_info)) {
+ request.key_type(),
+ database_pb.credentials().endorsement_public_key(),
+ &public_key_info)) {
LOG(ERROR) << __func__ << ": Bad public key.";
result->set_status(STATUS_UNEXPECTED_DEVICE_ERROR);
return;
@@ -270,16 +245,12 @@
const GetAttestationKeyInfoRequest& request,
const GetAttestationKeyInfoCallback& callback) {
auto result = std::make_shared<GetAttestationKeyInfoReply>();
- base::Closure task = base::Bind(
- &AttestationService::GetAttestationKeyInfoTask,
- base::Unretained(this),
- request,
- result);
+ base::Closure task =
+ base::Bind(&AttestationService::GetAttestationKeyInfoTask,
+ base::Unretained(this), request, result);
base::Closure reply = base::Bind(
&AttestationService::TaskRelayCallback<GetAttestationKeyInfoReply>,
- GetWeakPtr(),
- callback,
- result);
+ GetWeakPtr(), callback, result);
worker_thread_->task_runner()->PostTaskAndReply(FROM_HERE, task, reply);
}
@@ -298,9 +269,9 @@
if (database_pb.identity_key().has_identity_public_key()) {
std::string public_key_info;
if (!GetSubjectPublicKeyInfo(
- request.key_type(),
- database_pb.identity_key().identity_public_key(),
- &public_key_info)) {
+ request.key_type(),
+ database_pb.identity_key().identity_public_key(),
+ &public_key_info)) {
LOG(ERROR) << __func__ << ": Bad public key.";
result->set_status(STATUS_UNEXPECTED_DEVICE_ERROR);
return;
@@ -327,16 +298,12 @@
const ActivateAttestationKeyRequest& request,
const ActivateAttestationKeyCallback& callback) {
auto result = std::make_shared<ActivateAttestationKeyReply>();
- base::Closure task = base::Bind(
- &AttestationService::ActivateAttestationKeyTask,
- base::Unretained(this),
- request,
- result);
+ base::Closure task =
+ base::Bind(&AttestationService::ActivateAttestationKeyTask,
+ base::Unretained(this), request, result);
base::Closure reply = base::Bind(
&AttestationService::TaskRelayCallback<ActivateAttestationKeyReply>,
- GetWeakPtr(),
- callback,
- result);
+ GetWeakPtr(), callback, result);
worker_thread_->task_runner()->PostTaskAndReply(FROM_HERE, task, reply);
}
@@ -350,19 +317,18 @@
std::string certificate;
auto database_pb = database_->GetProtobuf();
if (!tpm_utility_->ActivateIdentity(
- database_pb.delegate().blob(),
- database_pb.delegate().secret(),
- database_pb.identity_key().identity_key_blob(),
- request.encrypted_certificate().asym_ca_contents(),
- request.encrypted_certificate().sym_ca_attestation(),
- &certificate)) {
+ database_pb.delegate().blob(), database_pb.delegate().secret(),
+ database_pb.identity_key().identity_key_blob(),
+ request.encrypted_certificate().asym_ca_contents(),
+ request.encrypted_certificate().sym_ca_attestation(), &certificate)) {
LOG(ERROR) << __func__ << ": Failed to activate identity.";
result->set_status(STATUS_UNEXPECTED_DEVICE_ERROR);
return;
}
if (request.save_certificate()) {
- database_->GetMutableProtobuf()->mutable_identity_key()->
- set_identity_credential(certificate);
+ database_->GetMutableProtobuf()
+ ->mutable_identity_key()
+ ->set_identity_credential(certificate);
if (!database_->SaveChanges()) {
LOG(ERROR) << __func__ << ": Failed to persist database changes.";
result->set_status(STATUS_UNEXPECTED_DEVICE_ERROR);
@@ -375,16 +341,11 @@
const CreateCertifiableKeyRequest& request,
const CreateCertifiableKeyCallback& callback) {
auto result = std::make_shared<CreateCertifiableKeyReply>();
- base::Closure task = base::Bind(
- &AttestationService::CreateCertifiableKeyTask,
- base::Unretained(this),
- request,
- result);
+ base::Closure task = base::Bind(&AttestationService::CreateCertifiableKeyTask,
+ base::Unretained(this), request, result);
base::Closure reply = base::Bind(
&AttestationService::TaskRelayCallback<CreateCertifiableKeyReply>,
- GetWeakPtr(),
- callback,
- result);
+ GetWeakPtr(), callback, result);
worker_thread_->task_runner()->PostTaskAndReply(FROM_HERE, task, reply);
}
@@ -412,16 +373,11 @@
void AttestationService::Decrypt(const DecryptRequest& request,
const DecryptCallback& callback) {
auto result = std::make_shared<DecryptReply>();
- base::Closure task = base::Bind(
- &AttestationService::DecryptTask,
- base::Unretained(this),
- request,
- result);
- base::Closure reply = base::Bind(
- &AttestationService::TaskRelayCallback<DecryptReply>,
- GetWeakPtr(),
- callback,
- result);
+ base::Closure task = base::Bind(&AttestationService::DecryptTask,
+ base::Unretained(this), request, result);
+ base::Closure reply =
+ base::Bind(&AttestationService::TaskRelayCallback<DecryptReply>,
+ GetWeakPtr(), callback, result);
worker_thread_->task_runner()->PostTaskAndReply(FROM_HERE, task, reply);
}
@@ -444,16 +400,11 @@
void AttestationService::Sign(const SignRequest& request,
const SignCallback& callback) {
auto result = std::make_shared<SignReply>();
- base::Closure task = base::Bind(
- &AttestationService::SignTask,
- base::Unretained(this),
- request,
- result);
- base::Closure reply = base::Bind(
- &AttestationService::TaskRelayCallback<SignReply>,
- GetWeakPtr(),
- callback,
- result);
+ base::Closure task = base::Bind(&AttestationService::SignTask,
+ base::Unretained(this), request, result);
+ base::Closure reply =
+ base::Bind(&AttestationService::TaskRelayCallback<SignReply>,
+ GetWeakPtr(), callback, result);
worker_thread_->task_runner()->PostTaskAndReply(FROM_HERE, task, reply);
}
@@ -476,16 +427,12 @@
const RegisterKeyWithChapsTokenRequest& request,
const RegisterKeyWithChapsTokenCallback& callback) {
auto result = std::make_shared<RegisterKeyWithChapsTokenReply>();
- base::Closure task = base::Bind(
- &AttestationService::RegisterKeyWithChapsTokenTask,
- base::Unretained(this),
- request,
- result);
+ base::Closure task =
+ base::Bind(&AttestationService::RegisterKeyWithChapsTokenTask,
+ base::Unretained(this), request, result);
base::Closure reply = base::Bind(
&AttestationService::TaskRelayCallback<RegisterKeyWithChapsTokenReply>,
- GetWeakPtr(),
- callback,
- result);
+ GetWeakPtr(), callback, result);
worker_thread_->task_runner()->PostTaskAndReply(FROM_HERE, task, reply);
}
@@ -511,8 +458,7 @@
}
for (int i = 0; i < key.additional_intermediate_ca_cert_size(); ++i) {
if (!key_store_->RegisterCertificate(
- request.username(),
- key.additional_intermediate_ca_cert(i))) {
+ request.username(), key.additional_intermediate_ca_cert(i))) {
result->set_status(STATUS_UNEXPECTED_DEVICE_ERROR);
return;
}
@@ -528,9 +474,9 @@
if (!database_pb.has_credentials()) {
return false;
}
- return (database_pb.credentials().has_endorsement_credential() ||
- database_pb.credentials()
- .has_default_encrypted_endorsement_credential());
+ return (
+ database_pb.credentials().has_endorsement_credential() ||
+ database_pb.credentials().has_default_encrypted_endorsement_credential());
}
bool AttestationService::IsEnrolled() {
@@ -572,24 +518,24 @@
}
if (response_pb.status() != OK) {
*server_error = response_pb.detail();
- LOG(ERROR) << __func__ << ": Error received from CA: "
- << response_pb.detail();
+ LOG(ERROR) << __func__
+ << ": Error received from CA: " << response_pb.detail();
return false;
}
std::string credential;
auto database_pb = database_->GetProtobuf();
if (!tpm_utility_->ActivateIdentity(
- database_pb.delegate().blob(),
- database_pb.delegate().secret(),
- database_pb.identity_key().identity_key_blob(),
- response_pb.encrypted_identity_credential().asym_ca_contents(),
- response_pb.encrypted_identity_credential().sym_ca_attestation(),
- &credential)) {
+ database_pb.delegate().blob(), database_pb.delegate().secret(),
+ database_pb.identity_key().identity_key_blob(),
+ response_pb.encrypted_identity_credential().asym_ca_contents(),
+ response_pb.encrypted_identity_credential().sym_ca_attestation(),
+ &credential)) {
LOG(ERROR) << __func__ << ": Failed to activate identity.";
return false;
}
- database_->GetMutableProtobuf()->mutable_identity_key()->
- set_identity_credential(credential);
+ database_->GetMutableProtobuf()
+ ->mutable_identity_key()
+ ->set_identity_credential(credential);
if (!database_->SaveChanges()) {
LOG(ERROR) << __func__ << ": Failed to persist database changes.";
return false;
@@ -655,8 +601,8 @@
}
if (response_pb.status() != OK) {
*server_error = response_pb.detail();
- LOG(ERROR) << __func__ << ": Error received from Privacy CA: "
- << response_pb.detail();
+ LOG(ERROR) << __func__
+ << ": Error received from Privacy CA: " << response_pb.detail();
return false;
}
if (message_id != response_pb.message_id()) {
@@ -685,11 +631,8 @@
transport = brillo::http::Transport::CreateDefault();
}
std::unique_ptr<brillo::http::Response> response = PostBinaryAndBlock(
- GetACAURL(request_type),
- request.data(),
- request.size(),
- brillo::mime::application::kOctet_stream,
- {}, // headers
+ GetACAURL(request_type), request.data(), request.size(),
+ brillo::mime::application::kOctet_stream, {}, // headers
transport,
nullptr); // error
if (!response || !response->IsSuccessful()) {
@@ -743,15 +686,9 @@
std::string proof;
auto database_pb = database_->GetProtobuf();
if (!tpm_utility_->CreateCertifiedKey(
- key_type,
- key_usage,
- database_pb.identity_key().identity_key_blob(),
- nonce,
- &key_blob,
- &public_key,
- &public_key_tpm_format,
- &key_info,
- &proof)) {
+ key_type, key_usage, database_pb.identity_key().identity_key_blob(),
+ nonce, &key_blob, &public_key, &public_key_tpm_format, &key_info,
+ &proof)) {
return false;
}
key->set_key_blob(key_blob);
@@ -861,7 +798,6 @@
return pem;
}
-
int AttestationService::ChooseTemporalIndex(const std::string& user,
const std::string& origin) {
std::string user_hash = crypto::SHA256HashString(user);
diff --git a/attestation/server/attestation_service.h b/attestation/server/attestation_service.h
index 8426272..8e6fd94 100644
--- a/attestation/server/attestation_service.h
+++ b/attestation/server/attestation_service.h
@@ -96,27 +96,19 @@
crypto_utility_ = crypto_utility;
}
- void set_database(Database* database) {
- database_ = database;
- }
+ void set_database(Database* database) { database_ = database; }
void set_http_transport(
const std::shared_ptr<brillo::http::Transport>& transport) {
http_transport_ = transport;
}
- void set_key_store(KeyStore* key_store) {
- key_store_ = key_store;
- }
+ void set_key_store(KeyStore* key_store) { key_store_ = key_store; }
- void set_tpm_utility(TpmUtility* tpm_utility) {
- tpm_utility_ = tpm_utility;
- }
+ void set_tpm_utility(TpmUtility* tpm_utility) { tpm_utility_ = tpm_utility; }
// So tests don't need to duplicate URL decisions.
- const std::string& attestation_ca_origin() {
- return attestation_ca_origin_;
- }
+ const std::string& attestation_ca_origin() { return attestation_ca_origin_; }
private:
enum ACARequestType {
@@ -126,7 +118,7 @@
// A relay callback which allows the use of weak pointer semantics for a reply
// to TaskRunner::PostTaskAndReply.
- template<typename ReplyProtobufType>
+ template <typename ReplyProtobufType>
void TaskRelayCallback(
const base::Callback<void(const ReplyProtobufType&)> callback,
const std::shared_ptr<ReplyProtobufType>& reply) {
@@ -140,9 +132,8 @@
const std::shared_ptr<CreateGoogleAttestedKeyReply>& result);
// A blocking implementation of GetKeyInfo.
- void GetKeyInfoTask(
- const GetKeyInfoRequest& request,
- const std::shared_ptr<GetKeyInfoReply>& result);
+ void GetKeyInfoTask(const GetKeyInfoRequest& request,
+ const std::shared_ptr<GetKeyInfoReply>& result);
// A blocking implementation of GetEndorsementInfo.
void GetEndorsementInfoTask(
@@ -245,8 +236,7 @@
const CertifiedKey& key);
// Deletes the key associated with |username| and |key_label|.
- void DeleteKey(const std::string& username,
- const std::string& key_label);
+ void DeleteKey(const std::string& username, const std::string& key_label);
// Adds named device-wide key to the attestation database.
bool AddDeviceKey(const std::string& key_label, const CertifiedKey& key);
@@ -277,7 +267,6 @@
base::WeakPtr<AttestationService> GetWeakPtr();
-
const std::string attestation_ca_origin_;
// Other than initialization and destruction, these are used only by the
diff --git a/attestation/server/attestation_service_test.cc b/attestation/server/attestation_service_test.cc
index 494904b..34566d1 100644
--- a/attestation/server/attestation_service_test.cc
+++ b/attestation/server/attestation_service_test.cc
@@ -64,9 +64,10 @@
service_->set_key_store(&mock_key_store_);
service_->set_tpm_utility(&mock_tpm_utility_);
// Setup a fake wrapped EK certificate by default.
- mock_database_.GetMutableProtobuf()->mutable_credentials()->
- mutable_default_encrypted_endorsement_credential()->
- set_wrapping_key_id("default");
+ mock_database_.GetMutableProtobuf()
+ ->mutable_credentials()
+ ->mutable_default_encrypted_endorsement_credential()
+ ->set_wrapping_key_id("default");
// Setup a fake Attestation CA for success by default.
SetupFakeCAEnroll(kSuccess);
SetupFakeCASign(kSuccess);
@@ -79,16 +80,14 @@
service_->attestation_ca_origin() + "/enroll",
brillo::http::request_type::kPost,
base::Bind(&AttestationServiceTest::FakeCAEnroll,
- base::Unretained(this),
- state));
+ base::Unretained(this), state));
}
void SetupFakeCASign(FakeCAState state) {
fake_http_transport_->AddHandler(
service_->attestation_ca_origin() + "/sign",
brillo::http::request_type::kPost,
- base::Bind(&AttestationServiceTest::FakeCASign,
- base::Unretained(this),
+ base::Bind(&AttestationServiceTest::FakeCASign, base::Unretained(this),
state));
}
@@ -116,17 +115,11 @@
return request;
}
- void Run() {
- run_loop_.Run();
- }
+ void Run() { run_loop_.Run(); }
- void RunUntilIdle() {
- run_loop_.RunUntilIdle();
- }
+ void RunUntilIdle() { run_loop_.RunUntilIdle(); }
- void Quit() {
- run_loop_.Quit();
- }
+ void Quit() { run_loop_.Quit(); }
std::shared_ptr<brillo::http::fake::Transport> fake_http_transport_;
NiceMock<MockCryptoUtility> mock_crypto_utility_;
@@ -153,10 +146,10 @@
} else if (state == kSuccess) {
response_pb.set_status(OK);
response_pb.set_detail("");
- response_pb.mutable_encrypted_identity_credential()->
- set_asym_ca_contents("1234");
- response_pb.mutable_encrypted_identity_credential()->
- set_sym_ca_attestation("5678");
+ response_pb.mutable_encrypted_identity_credential()->set_asym_ca_contents(
+ "1234");
+ response_pb.mutable_encrypted_identity_credential()
+ ->set_sym_ca_attestation("5678");
} else {
NOTREACHED();
}
@@ -363,8 +356,7 @@
}
TEST_F(AttestationServiceTest, CreateGoogleAttestedKeyWithKeyWriteFailure) {
- EXPECT_CALL(mock_key_store_, Write(_, _, _))
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(mock_key_store_, Write(_, _, _)).WillRepeatedly(Return(false));
// Set expectations on the outputs.
auto callback = [this](const CreateGoogleAttestedKeyReply& reply) {
EXPECT_NE(STATUS_SUCCESS, reply.status());
@@ -377,8 +369,7 @@
}
TEST_F(AttestationServiceTest, CreateGoogleAttestedKeyWithTpmNotReady) {
- EXPECT_CALL(mock_tpm_utility_, IsTpmReady())
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(mock_tpm_utility_, IsTpmReady()).WillRepeatedly(Return(false));
// Set expectations on the outputs.
auto callback = [this](const CreateGoogleAttestedKeyReply& reply) {
EXPECT_NE(STATUS_SUCCESS, reply.status());
@@ -652,8 +643,8 @@
TEST_F(AttestationServiceTest, ActivateAttestationKeySuccess) {
EXPECT_CALL(mock_database_, SaveChanges()).Times(1);
- EXPECT_CALL(mock_tpm_utility_, ActivateIdentity(_, _, _, "encrypted1",
- "encrypted2", _))
+ EXPECT_CALL(mock_tpm_utility_,
+ ActivateIdentity(_, _, _, "encrypted1", "encrypted2", _))
.WillOnce(DoAll(SetArgumentPointee<5>(std::string("certificate")),
Return(true)));
// Set expectations on the outputs.
@@ -674,8 +665,8 @@
TEST_F(AttestationServiceTest, ActivateAttestationKeySuccessNoSave) {
EXPECT_CALL(mock_database_, GetMutableProtobuf()).Times(0);
EXPECT_CALL(mock_database_, SaveChanges()).Times(0);
- EXPECT_CALL(mock_tpm_utility_, ActivateIdentity(_, _, _, "encrypted1",
- "encrypted2", _))
+ EXPECT_CALL(mock_tpm_utility_,
+ ActivateIdentity(_, _, _, "encrypted1", "encrypted2", _))
.WillOnce(DoAll(SetArgumentPointee<5>(std::string("certificate")),
Return(true)));
// Set expectations on the outputs.
@@ -710,8 +701,8 @@
}
TEST_F(AttestationServiceTest, ActivateAttestationKeyActivateFailure) {
- EXPECT_CALL(mock_tpm_utility_, ActivateIdentity(_, _, _, "encrypted1",
- "encrypted2", _))
+ EXPECT_CALL(mock_tpm_utility_,
+ ActivateIdentity(_, _, _, "encrypted1", "encrypted2", _))
.WillRepeatedly(Return(false));
// Set expectations on the outputs.
auto callback = [this](const ActivateAttestationKeyReply& reply) {
@@ -729,14 +720,14 @@
TEST_F(AttestationServiceTest, CreateCertifiableKeySuccess) {
// Configure a fake TPM response.
- EXPECT_CALL(mock_tpm_utility_, CreateCertifiedKey(KEY_TYPE_ECC,
- KEY_USAGE_SIGN,
- _, _, _, _, _, _, _))
- .WillOnce(DoAll(SetArgumentPointee<5>(std::string("public_key")),
- SetArgumentPointee<7>(std::string("certify_info")),
- SetArgumentPointee<8>(
- std::string("certify_info_signature")),
- Return(true)));
+ EXPECT_CALL(
+ mock_tpm_utility_,
+ CreateCertifiedKey(KEY_TYPE_ECC, KEY_USAGE_SIGN, _, _, _, _, _, _, _))
+ .WillOnce(
+ DoAll(SetArgumentPointee<5>(std::string("public_key")),
+ SetArgumentPointee<7>(std::string("certify_info")),
+ SetArgumentPointee<8>(std::string("certify_info_signature")),
+ Return(true)));
// Expect the key to be written exactly once.
EXPECT_CALL(mock_key_store_, Write("user", "label", _)).Times(1);
// Set expectations on the outputs.
@@ -758,14 +749,14 @@
TEST_F(AttestationServiceTest, CreateCertifiableKeySuccessNoUser) {
// Configure a fake TPM response.
- EXPECT_CALL(mock_tpm_utility_, CreateCertifiedKey(KEY_TYPE_ECC,
- KEY_USAGE_SIGN,
- _, _, _, _, _, _, _))
- .WillOnce(DoAll(SetArgumentPointee<5>(std::string("public_key")),
- SetArgumentPointee<7>(std::string("certify_info")),
- SetArgumentPointee<8>(
- std::string("certify_info_signature")),
- Return(true)));
+ EXPECT_CALL(
+ mock_tpm_utility_,
+ CreateCertifiedKey(KEY_TYPE_ECC, KEY_USAGE_SIGN, _, _, _, _, _, _, _))
+ .WillOnce(
+ DoAll(SetArgumentPointee<5>(std::string("public_key")),
+ SetArgumentPointee<7>(std::string("certify_info")),
+ SetArgumentPointee<8>(std::string("certify_info_signature")),
+ Return(true)));
// Expect the key to be written exactly once.
EXPECT_CALL(mock_database_, SaveChanges()).Times(1);
// Set expectations on the outputs.
@@ -1032,13 +1023,10 @@
.WillOnce(DoAll(SetArgumentPointee<2>(key_bytes), Return(true)));
// Cardinality is verified here to verify various steps are performed and to
// catch performance regressions.
- EXPECT_CALL(mock_key_store_, Register("user",
- "label",
- KEY_TYPE_RSA,
- KEY_USAGE_SIGN,
- "key_blob",
- "public_key",
- "fake_cert")).Times(1);
+ EXPECT_CALL(mock_key_store_,
+ Register("user", "label", KEY_TYPE_RSA, KEY_USAGE_SIGN,
+ "key_blob", "public_key", "fake_cert"))
+ .Times(1);
EXPECT_CALL(mock_key_store_, RegisterCertificate("user", "fake_ca_cert"))
.Times(1);
EXPECT_CALL(mock_key_store_, RegisterCertificate("user", "fake_ca_cert2"))
@@ -1069,13 +1057,10 @@
key.set_key_usage(KEY_USAGE_SIGN);
// Cardinality is verified here to verify various steps are performed and to
// catch performance regressions.
- EXPECT_CALL(mock_key_store_, Register("",
- "label",
- KEY_TYPE_RSA,
- KEY_USAGE_SIGN,
- "key_blob",
- "public_key",
- "fake_cert")).Times(1);
+ EXPECT_CALL(mock_key_store_,
+ Register("", "label", KEY_TYPE_RSA, KEY_USAGE_SIGN, "key_blob",
+ "public_key", "fake_cert"))
+ .Times(1);
EXPECT_CALL(mock_key_store_, RegisterCertificate("", "fake_ca_cert"))
.Times(1);
EXPECT_CALL(mock_key_store_, RegisterCertificate("", "fake_ca_cert2"))
diff --git a/attestation/server/database_impl.cc b/attestation/server/database_impl.cc
index 2f2c150..1c59da0 100644
--- a/attestation/server/database_impl.cc
+++ b/attestation/server/database_impl.cc
@@ -47,8 +47,8 @@
namespace attestation {
-DatabaseImpl::DatabaseImpl(CryptoUtility* crypto) : io_(this), crypto_(crypto) {
-}
+DatabaseImpl::DatabaseImpl(CryptoUtility* crypto)
+ : io_(this), crypto_(crypto) {}
DatabaseImpl::~DatabaseImpl() {
brillo::SecureMemset(string_as_array(&database_key_), 0,
@@ -127,7 +127,7 @@
}
// Sync the parent directory.
std::string dir_name = file_path.DirName().value();
- int dir_fd = HANDLE_EINTR(open(dir_name.c_str(), O_RDONLY|O_DIRECTORY));
+ int dir_fd = HANDLE_EINTR(open(dir_name.c_str(), O_RDONLY | O_DIRECTORY));
if (dir_fd < 0) {
PLOG(WARNING) << "Could not open " << dir_name << " for syncing";
return false;
diff --git a/attestation/server/database_impl.h b/attestation/server/database_impl.h
index 9007d92..b37b5f7 100644
--- a/attestation/server/database_impl.h
+++ b/attestation/server/database_impl.h
@@ -42,8 +42,7 @@
// An implementation of Database backed by an ordinary file. Not thread safe.
// All methods must be called on the same thread as the Initialize() call.
-class DatabaseImpl : public Database,
- public DatabaseIO {
+class DatabaseImpl : public Database, public DatabaseIO {
public:
// Does not take ownership of pointers.
explicit DatabaseImpl(CryptoUtility* crypto);
@@ -65,9 +64,7 @@
void Watch(const base::Closure& callback) override;
// Useful for testing.
- void set_io(DatabaseIO* io) {
- io_ = io;
- }
+ void set_io(DatabaseIO* io) { io_ = io; }
private:
// Encrypts |protobuf_| into |encrypted_output|. Returns true on success.
diff --git a/attestation/server/database_impl_test.cc b/attestation/server/database_impl_test.cc
index 9b3d750..fe4ae89 100644
--- a/attestation/server/database_impl_test.cc
+++ b/attestation/server/database_impl_test.cc
@@ -37,8 +37,7 @@
namespace attestation {
-class DatabaseImplTest : public testing::Test,
- public DatabaseIO {
+class DatabaseImplTest : public testing::Test, public DatabaseIO {
public:
~DatabaseImplTest() override = default;
void SetUp() override {
@@ -108,8 +107,9 @@
}
TEST_F(DatabaseImplTest, WriteSuccess) {
- database_->GetMutableProtobuf()->mutable_credentials()->
- set_platform_credential("test");
+ database_->GetMutableProtobuf()
+ ->mutable_credentials()
+ ->set_platform_credential("test");
std::string expected_data;
database_->GetProtobuf().SerializeToString(&expected_data);
EXPECT_TRUE(database_->SaveChanges());
@@ -118,16 +118,18 @@
TEST_F(DatabaseImplTest, WriteFailure) {
fake_persistent_data_writable_ = false;
- database_->GetMutableProtobuf()->mutable_credentials()->
- set_platform_credential("test");
+ database_->GetMutableProtobuf()
+ ->mutable_credentials()
+ ->set_platform_credential("test");
EXPECT_FALSE(database_->SaveChanges());
}
TEST_F(DatabaseImplTest, EncryptFailure) {
EXPECT_CALL(mock_crypto_utility_, EncryptData(_, _, _, _))
.WillRepeatedly(Return(false));
- database_->GetMutableProtobuf()->mutable_credentials()->
- set_platform_credential("test");
+ database_->GetMutableProtobuf()
+ ->mutable_credentials()
+ ->set_platform_credential("test");
EXPECT_FALSE(database_->SaveChanges());
}
diff --git a/attestation/server/dbus_service.cc b/attestation/server/dbus_service.cc
index 9c25dab..1e08ce7 100644
--- a/attestation/server/dbus_service.cc
+++ b/attestation/server/dbus_service.cc
@@ -32,8 +32,7 @@
DBusService::DBusService(const scoped_refptr<dbus::Bus>& bus,
AttestationInterface* service)
: dbus_object_(nullptr, bus, dbus::ObjectPath(kAttestationServicePath)),
- service_(service) {
-}
+ service_(service) {}
void DBusService::Register(const CompletionAction& callback) {
brillo::dbus_utils::DBusInterface* dbus_interface =
@@ -42,11 +41,9 @@
dbus_interface->AddMethodHandler(kCreateGoogleAttestedKey,
base::Unretained(this),
&DBusService::HandleCreateGoogleAttestedKey);
- dbus_interface->AddMethodHandler(kGetKeyInfo,
- base::Unretained(this),
+ dbus_interface->AddMethodHandler(kGetKeyInfo, base::Unretained(this),
&DBusService::HandleGetKeyInfo);
- dbus_interface->AddMethodHandler(kGetEndorsementInfo,
- base::Unretained(this),
+ dbus_interface->AddMethodHandler(kGetEndorsementInfo, base::Unretained(this),
&DBusService::HandleGetEndorsementInfo);
dbus_interface->AddMethodHandler(kGetAttestationKeyInfo,
base::Unretained(this),
@@ -57,15 +54,12 @@
dbus_interface->AddMethodHandler(kCreateCertifiableKey,
base::Unretained(this),
&DBusService::HandleCreateCertifiableKey);
- dbus_interface->AddMethodHandler(kDecrypt,
- base::Unretained(this),
+ dbus_interface->AddMethodHandler(kDecrypt, base::Unretained(this),
&DBusService::HandleDecrypt);
- dbus_interface->AddMethodHandler(kSign,
- base::Unretained(this),
+ dbus_interface->AddMethodHandler(kSign, base::Unretained(this),
&DBusService::HandleSign);
dbus_interface->AddMethodHandler(
- kRegisterKeyWithChapsToken,
- base::Unretained(this),
+ kRegisterKeyWithChapsToken, base::Unretained(this),
&DBusService::HandleRegisterKeyWithChapsToken);
dbus_object_.RegisterAsync(callback);
@@ -78,8 +72,8 @@
VLOG(1) << __func__;
// Convert |response| to a shared_ptr so |service_| can safely copy the
// callback.
- using SharedResponsePointer = std::shared_ptr<
- DBusMethodResponse<const CreateGoogleAttestedKeyReply&>>;
+ using SharedResponsePointer =
+ std::shared_ptr<DBusMethodResponse<const CreateGoogleAttestedKeyReply&>>;
// A callback that fills the reply protobuf and sends it.
auto callback = [](const SharedResponsePointer& response,
const CreateGoogleAttestedKeyReply& reply) {
@@ -96,13 +90,11 @@
VLOG(1) << __func__;
// Convert |response| to a shared_ptr so |service_| can safely copy the
// callback.
- using SharedResponsePointer = std::shared_ptr<
- DBusMethodResponse<const GetKeyInfoReply&>>;
+ using SharedResponsePointer =
+ std::shared_ptr<DBusMethodResponse<const GetKeyInfoReply&>>;
// A callback that fills the reply protobuf and sends it.
auto callback = [](const SharedResponsePointer& response,
- const GetKeyInfoReply& reply) {
- response->Return(reply);
- };
+ const GetKeyInfoReply& reply) { response->Return(reply); };
service_->GetKeyInfo(
request,
base::Bind(callback, SharedResponsePointer(std::move(response))));
@@ -115,8 +107,8 @@
VLOG(1) << __func__;
// Convert |response| to a shared_ptr so |service_| can safely copy the
// callback.
- using SharedResponsePointer = std::shared_ptr<
- DBusMethodResponse<const GetEndorsementInfoReply&>>;
+ using SharedResponsePointer =
+ std::shared_ptr<DBusMethodResponse<const GetEndorsementInfoReply&>>;
// A callback that fills the reply protobuf and sends it.
auto callback = [](const SharedResponsePointer& response,
const GetEndorsementInfoReply& reply) {
@@ -134,8 +126,8 @@
VLOG(1) << __func__;
// Convert |response| to a shared_ptr so |service_| can safely copy the
// callback.
- using SharedResponsePointer = std::shared_ptr<
- DBusMethodResponse<const GetAttestationKeyInfoReply&>>;
+ using SharedResponsePointer =
+ std::shared_ptr<DBusMethodResponse<const GetAttestationKeyInfoReply&>>;
// A callback that fills the reply protobuf and sends it.
auto callback = [](const SharedResponsePointer& response,
const GetAttestationKeyInfoReply& reply) {
@@ -153,8 +145,8 @@
VLOG(1) << __func__;
// Convert |response| to a shared_ptr so |service_| can safely copy the
// callback.
- using SharedResponsePointer = std::shared_ptr<
- DBusMethodResponse<const ActivateAttestationKeyReply&>>;
+ using SharedResponsePointer =
+ std::shared_ptr<DBusMethodResponse<const ActivateAttestationKeyReply&>>;
// A callback that fills the reply protobuf and sends it.
auto callback = [](const SharedResponsePointer& response,
const ActivateAttestationKeyReply& reply) {
@@ -172,8 +164,8 @@
VLOG(1) << __func__;
// Convert |response| to a shared_ptr so |service_| can safely copy the
// callback.
- using SharedResponsePointer = std::shared_ptr<
- DBusMethodResponse<const CreateCertifiableKeyReply&>>;
+ using SharedResponsePointer =
+ std::shared_ptr<DBusMethodResponse<const CreateCertifiableKeyReply&>>;
// A callback that fills the reply protobuf and sends it.
auto callback = [](const SharedResponsePointer& response,
const CreateCertifiableKeyReply& reply) {
@@ -190,13 +182,11 @@
VLOG(1) << __func__;
// Convert |response| to a shared_ptr so |service_| can safely copy the
// callback.
- using SharedResponsePointer = std::shared_ptr<
- DBusMethodResponse<const DecryptReply&>>;
+ using SharedResponsePointer =
+ std::shared_ptr<DBusMethodResponse<const DecryptReply&>>;
// A callback that fills the reply protobuf and sends it.
auto callback = [](const SharedResponsePointer& response,
- const DecryptReply& reply) {
- response->Return(reply);
- };
+ const DecryptReply& reply) { response->Return(reply); };
service_->Decrypt(
request,
base::Bind(callback, SharedResponsePointer(std::move(response))));
@@ -208,13 +198,11 @@
VLOG(1) << __func__;
// Convert |response| to a shared_ptr so |service_| can safely copy the
// callback.
- using SharedResponsePointer = std::shared_ptr<
- DBusMethodResponse<const SignReply&>>;
+ using SharedResponsePointer =
+ std::shared_ptr<DBusMethodResponse<const SignReply&>>;
// A callback that fills the reply protobuf and sends it.
auto callback = [](const SharedResponsePointer& response,
- const SignReply& reply) {
- response->Return(reply);
- };
+ const SignReply& reply) { response->Return(reply); };
service_->Sign(
request,
base::Bind(callback, SharedResponsePointer(std::move(response))));
diff --git a/attestation/server/dbus_service.h b/attestation/server/dbus_service.h
index dd4281c..68c99b7 100644
--- a/attestation/server/dbus_service.h
+++ b/attestation/server/dbus_service.h
@@ -43,9 +43,7 @@
void Register(const CompletionAction& callback);
// Useful for testing.
- void set_service(AttestationInterface* service) {
- service_ = service;
- }
+ void set_service(AttestationInterface* service) { service_ = service; }
private:
friend class DBusServiceTest;
@@ -57,10 +55,9 @@
const CreateGoogleAttestedKeyRequest& request);
// Handles a GetKeyInfo D-Bus call.
- void HandleGetKeyInfo(
- std::unique_ptr<brillo::dbus_utils::DBusMethodResponse<
- const GetKeyInfoReply&>> response,
- const GetKeyInfoRequest& request);
+ void HandleGetKeyInfo(std::unique_ptr<brillo::dbus_utils::DBusMethodResponse<
+ const GetKeyInfoReply&>> response,
+ const GetKeyInfoRequest& request);
// Handles a GetEndorsementInfo D-Bus call.
void HandleGetEndorsementInfo(
@@ -88,14 +85,14 @@
// Handles a Decrypt D-Bus call.
void HandleDecrypt(
- std::unique_ptr<brillo::dbus_utils::DBusMethodResponse<
- const DecryptReply&>> response,
+ std::unique_ptr<
+ brillo::dbus_utils::DBusMethodResponse<const DecryptReply&>> response,
const DecryptRequest& request);
// Handles a Sign D-Bus call.
void HandleSign(
- std::unique_ptr<brillo::dbus_utils::DBusMethodResponse<
- const SignReply&>> response,
+ std::unique_ptr<brillo::dbus_utils::DBusMethodResponse<const SignReply&>>
+ response,
const SignRequest& request);
// Handles a RegisterKeyWithChapsToken D-Bus call.
diff --git a/attestation/server/dbus_service_test.cc b/attestation/server/dbus_service_test.cc
index ebe6acc..3d89dfa 100644
--- a/attestation/server/dbus_service_test.cc
+++ b/attestation/server/dbus_service_test.cc
@@ -43,24 +43,24 @@
dbus::Bus::Options options;
mock_bus_ = new NiceMock<dbus::MockBus>(options);
dbus::ObjectPath path(kAttestationServicePath);
- mock_exported_object_ = new NiceMock<dbus::MockExportedObject>(
- mock_bus_.get(), path);
+ mock_exported_object_ =
+ new NiceMock<dbus::MockExportedObject>(mock_bus_.get(), path);
ON_CALL(*mock_bus_, GetExportedObject(path))
.WillByDefault(Return(mock_exported_object_.get()));
dbus_service_.reset(new DBusService(mock_bus_, &mock_service_));
- dbus_service_->Register(brillo::dbus_utils::AsyncEventSequencer::
- GetDefaultCompletionAction());
+ dbus_service_->Register(
+ brillo::dbus_utils::AsyncEventSequencer::GetDefaultCompletionAction());
}
std::unique_ptr<dbus::Response> CallMethod(dbus::MethodCall* method_call) {
- return brillo::dbus_utils::testing::CallMethod(
- dbus_service_->dbus_object_, method_call);
+ return brillo::dbus_utils::testing::CallMethod(dbus_service_->dbus_object_,
+ method_call);
}
std::unique_ptr<dbus::MethodCall> CreateMethodCall(
const std::string& method_name) {
- std::unique_ptr<dbus::MethodCall> call(new dbus::MethodCall(
- kAttestationInterface, method_name));
+ std::unique_ptr<dbus::MethodCall> call(
+ new dbus::MethodCall(kAttestationInterface, method_name));
call->SetSerial(1);
return call;
}
@@ -81,25 +81,25 @@
request.set_username("username");
request.set_origin("origin");
EXPECT_CALL(mock_service_, CreateGoogleAttestedKey(_, _))
- .WillOnce(Invoke([](
- const CreateGoogleAttestedKeyRequest& request,
- const AttestationInterface::
- CreateGoogleAttestedKeyCallback& callback) {
- EXPECT_EQ("label", request.key_label());
- EXPECT_EQ(KEY_TYPE_ECC, request.key_type());
- EXPECT_EQ(KEY_USAGE_SIGN, request.key_usage());
- EXPECT_EQ(ENTERPRISE_MACHINE_CERTIFICATE,
- request.certificate_profile());
- EXPECT_EQ("username", request.username());
- EXPECT_EQ("origin", request.origin());
- CreateGoogleAttestedKeyReply reply;
- reply.set_status(STATUS_SUCCESS);
- reply.set_certificate_chain("certificate");
- reply.set_server_error("server_error");
- callback.Run(reply);
- }));
- std::unique_ptr<dbus::MethodCall> call = CreateMethodCall(
- kCreateGoogleAttestedKey);
+ .WillOnce(
+ Invoke([](const CreateGoogleAttestedKeyRequest& request,
+ const AttestationInterface::CreateGoogleAttestedKeyCallback&
+ callback) {
+ EXPECT_EQ("label", request.key_label());
+ EXPECT_EQ(KEY_TYPE_ECC, request.key_type());
+ EXPECT_EQ(KEY_USAGE_SIGN, request.key_usage());
+ EXPECT_EQ(ENTERPRISE_MACHINE_CERTIFICATE,
+ request.certificate_profile());
+ EXPECT_EQ("username", request.username());
+ EXPECT_EQ("origin", request.origin());
+ CreateGoogleAttestedKeyReply reply;
+ reply.set_status(STATUS_SUCCESS);
+ reply.set_certificate_chain("certificate");
+ reply.set_server_error("server_error");
+ callback.Run(reply);
+ }));
+ std::unique_ptr<dbus::MethodCall> call =
+ CreateMethodCall(kCreateGoogleAttestedKey);
dbus::MessageWriter writer(call.get());
writer.AppendProtoAsArrayOfBytes(request);
auto response = CallMethod(call.get());
@@ -113,15 +113,16 @@
TEST_F(DBusServiceTest, CopyableCallback) {
EXPECT_CALL(mock_service_, CreateGoogleAttestedKey(_, _))
- .WillOnce(WithArgs<1>(Invoke([](const AttestationInterface::
- CreateGoogleAttestedKeyCallback& callback) {
- // Copy the callback, then call the original.
- CreateGoogleAttestedKeyReply reply;
- base::Closure copy = base::Bind(callback, reply);
- callback.Run(reply);
- })));
- std::unique_ptr<dbus::MethodCall> call = CreateMethodCall(
- kCreateGoogleAttestedKey);
+ .WillOnce(WithArgs<1>(
+ Invoke([](const AttestationInterface::CreateGoogleAttestedKeyCallback&
+ callback) {
+ // Copy the callback, then call the original.
+ CreateGoogleAttestedKeyReply reply;
+ base::Closure copy = base::Bind(callback, reply);
+ callback.Run(reply);
+ })));
+ std::unique_ptr<dbus::MethodCall> call =
+ CreateMethodCall(kCreateGoogleAttestedKey);
CreateGoogleAttestedKeyRequest request;
dbus::MessageWriter writer(call.get());
writer.AppendProtoAsArrayOfBytes(request);
@@ -136,21 +137,21 @@
request.set_key_label("label");
request.set_username("username");
EXPECT_CALL(mock_service_, GetKeyInfo(_, _))
- .WillOnce(Invoke([](
- const GetKeyInfoRequest& request,
- const AttestationInterface::GetKeyInfoCallback& callback) {
- EXPECT_EQ("label", request.key_label());
- EXPECT_EQ("username", request.username());
- GetKeyInfoReply reply;
- reply.set_status(STATUS_SUCCESS);
- reply.set_key_type(KEY_TYPE_ECC);
- reply.set_key_usage(KEY_USAGE_SIGN);
- reply.set_public_key("public_key");
- reply.set_certify_info("certify");
- reply.set_certify_info_signature("signature");
- reply.set_certificate("certificate");
- callback.Run(reply);
- }));
+ .WillOnce(
+ Invoke([](const GetKeyInfoRequest& request,
+ const AttestationInterface::GetKeyInfoCallback& callback) {
+ EXPECT_EQ("label", request.key_label());
+ EXPECT_EQ("username", request.username());
+ GetKeyInfoReply reply;
+ reply.set_status(STATUS_SUCCESS);
+ reply.set_key_type(KEY_TYPE_ECC);
+ reply.set_key_usage(KEY_USAGE_SIGN);
+ reply.set_public_key("public_key");
+ reply.set_certify_info("certify");
+ reply.set_certify_info_signature("signature");
+ reply.set_certificate("certificate");
+ callback.Run(reply);
+ }));
std::unique_ptr<dbus::MethodCall> call = CreateMethodCall(kGetKeyInfo);
dbus::MessageWriter writer(call.get());
writer.AppendProtoAsArrayOfBytes(request);
@@ -171,16 +172,16 @@
GetEndorsementInfoRequest request;
request.set_key_type(KEY_TYPE_ECC);
EXPECT_CALL(mock_service_, GetEndorsementInfo(_, _))
- .WillOnce(Invoke([](
- const GetEndorsementInfoRequest& request,
- const AttestationInterface::GetEndorsementInfoCallback& callback) {
- EXPECT_EQ(KEY_TYPE_ECC, request.key_type());
- GetEndorsementInfoReply reply;
- reply.set_status(STATUS_SUCCESS);
- reply.set_ek_public_key("public_key");
- reply.set_ek_certificate("certificate");
- callback.Run(reply);
- }));
+ .WillOnce(Invoke(
+ [](const GetEndorsementInfoRequest& request,
+ const AttestationInterface::GetEndorsementInfoCallback& callback) {
+ EXPECT_EQ(KEY_TYPE_ECC, request.key_type());
+ GetEndorsementInfoReply reply;
+ reply.set_status(STATUS_SUCCESS);
+ reply.set_ek_public_key("public_key");
+ reply.set_ek_certificate("certificate");
+ callback.Run(reply);
+ }));
std::unique_ptr<dbus::MethodCall> call =
CreateMethodCall(kGetEndorsementInfo);
dbus::MessageWriter writer(call.get());
@@ -234,21 +235,21 @@
request.mutable_encrypted_certificate()->set_sym_ca_attestation("encrypted2");
request.set_save_certificate(true);
EXPECT_CALL(mock_service_, ActivateAttestationKey(_, _))
- .WillOnce(Invoke([](
- const ActivateAttestationKeyRequest& request,
- const AttestationInterface::ActivateAttestationKeyCallback&
- callback) {
- EXPECT_EQ(KEY_TYPE_ECC, request.key_type());
- EXPECT_EQ("encrypted1",
- request.encrypted_certificate().asym_ca_contents());
- EXPECT_EQ("encrypted2",
- request.encrypted_certificate().sym_ca_attestation());
- EXPECT_TRUE(request.save_certificate());
- ActivateAttestationKeyReply reply;
- reply.set_status(STATUS_SUCCESS);
- reply.set_certificate("certificate");
- callback.Run(reply);
- }));
+ .WillOnce(
+ Invoke([](const ActivateAttestationKeyRequest& request,
+ const AttestationInterface::ActivateAttestationKeyCallback&
+ callback) {
+ EXPECT_EQ(KEY_TYPE_ECC, request.key_type());
+ EXPECT_EQ("encrypted1",
+ request.encrypted_certificate().asym_ca_contents());
+ EXPECT_EQ("encrypted2",
+ request.encrypted_certificate().sym_ca_attestation());
+ EXPECT_TRUE(request.save_certificate());
+ ActivateAttestationKeyReply reply;
+ reply.set_status(STATUS_SUCCESS);
+ reply.set_certificate("certificate");
+ callback.Run(reply);
+ }));
std::unique_ptr<dbus::MethodCall> call =
CreateMethodCall(kActivateAttestationKey);
dbus::MessageWriter writer(call.get());
@@ -302,17 +303,17 @@
request.set_username("user");
request.set_encrypted_data("data");
EXPECT_CALL(mock_service_, Decrypt(_, _))
- .WillOnce(Invoke([](
- const DecryptRequest& request,
- const AttestationInterface::DecryptCallback& callback) {
- EXPECT_EQ("label", request.key_label());
- EXPECT_EQ("user", request.username());
- EXPECT_EQ("data", request.encrypted_data());
- DecryptReply reply;
- reply.set_status(STATUS_SUCCESS);
- reply.set_decrypted_data("data");
- callback.Run(reply);
- }));
+ .WillOnce(
+ Invoke([](const DecryptRequest& request,
+ const AttestationInterface::DecryptCallback& callback) {
+ EXPECT_EQ("label", request.key_label());
+ EXPECT_EQ("user", request.username());
+ EXPECT_EQ("data", request.encrypted_data());
+ DecryptReply reply;
+ reply.set_status(STATUS_SUCCESS);
+ reply.set_decrypted_data("data");
+ callback.Run(reply);
+ }));
std::unique_ptr<dbus::MethodCall> call = CreateMethodCall(kDecrypt);
dbus::MessageWriter writer(call.get());
writer.AppendProtoAsArrayOfBytes(request);
@@ -330,9 +331,8 @@
request.set_username("user");
request.set_data_to_sign("data");
EXPECT_CALL(mock_service_, Sign(_, _))
- .WillOnce(Invoke([](
- const SignRequest& request,
- const AttestationInterface::SignCallback& callback) {
+ .WillOnce(Invoke([](const SignRequest& request,
+ const AttestationInterface::SignCallback& callback) {
EXPECT_EQ("label", request.key_label());
EXPECT_EQ("user", request.username());
EXPECT_EQ("data", request.data_to_sign());
@@ -357,16 +357,16 @@
request.set_key_label("label");
request.set_username("user");
EXPECT_CALL(mock_service_, RegisterKeyWithChapsToken(_, _))
- .WillOnce(Invoke([](
- const RegisterKeyWithChapsTokenRequest& request,
- const AttestationInterface::RegisterKeyWithChapsTokenCallback&
- callback) {
- EXPECT_EQ("label", request.key_label());
- EXPECT_EQ("user", request.username());
- RegisterKeyWithChapsTokenReply reply;
- reply.set_status(STATUS_SUCCESS);
- callback.Run(reply);
- }));
+ .WillOnce(Invoke(
+ [](const RegisterKeyWithChapsTokenRequest& request,
+ const AttestationInterface::RegisterKeyWithChapsTokenCallback&
+ callback) {
+ EXPECT_EQ("label", request.key_label());
+ EXPECT_EQ("user", request.username());
+ RegisterKeyWithChapsTokenReply reply;
+ reply.set_status(STATUS_SUCCESS);
+ callback.Run(reply);
+ }));
std::unique_ptr<dbus::MethodCall> call =
CreateMethodCall(kRegisterKeyWithChapsToken);
dbus::MessageWriter writer(call.get());
@@ -378,5 +378,4 @@
EXPECT_EQ(STATUS_SUCCESS, reply.status());
}
-
} // namespace attestation
diff --git a/attestation/server/main.cc b/attestation/server/main.cc
index 1ba4405..37982eb 100644
--- a/attestation/server/main.cc
+++ b/attestation/server/main.cc
@@ -43,9 +43,8 @@
void InitMinijailSandbox() {
uid_t attestation_uid;
gid_t attestation_gid;
- CHECK(brillo::userdb::GetUserInfo(kAttestationUser,
- &attestation_uid,
- &attestation_gid))
+ CHECK(brillo::userdb::GetUserInfo(kAttestationUser, &attestation_uid,
+ &attestation_gid))
<< "Error getting attestation uid and gid.";
CHECK_EQ(getuid(), kRootUID) << "AttestationDaemon not initialized as root.";
brillo::Minijail* minijail = brillo::Minijail::GetInstance();
@@ -86,9 +85,8 @@
}
void RegisterDBusObjectsAsync(AsyncEventSequencer* sequencer) override {
- dbus_service_.reset(new attestation::DBusService(
- bus_,
- attestation_service_.get()));
+ dbus_service_.reset(
+ new attestation::DBusService(bus_, attestation_service_.get()));
dbus_service_->Register(sequencer->GetHandler("Register() failed.", true));
}
@@ -101,7 +99,7 @@
int main(int argc, char* argv[]) {
base::CommandLine::Init(argc, argv);
- base::CommandLine *cl = base::CommandLine::ForCurrentProcess();
+ base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
int flags = brillo::kLogToSyslog;
if (cl->HasSwitch("log_to_stderr")) {
flags |= brillo::kLogToStderr;
diff --git a/attestation/server/mock_key_store.h b/attestation/server/mock_key_store.h
index f6566ca..608f831 100644
--- a/attestation/server/mock_key_store.h
+++ b/attestation/server/mock_key_store.h
@@ -31,25 +31,30 @@
MockKeyStore();
virtual ~MockKeyStore();
- MOCK_METHOD3(Read, bool(const std::string& username,
- const std::string& name,
- std::string* key_data));
- MOCK_METHOD3(Write, bool(const std::string& username,
- const std::string& name,
- const std::string& key_data));
- MOCK_METHOD2(Delete, bool(const std::string& username,
- const std::string& name));
- MOCK_METHOD2(DeleteByPrefix, bool(const std::string& username,
- const std::string& key_prefix));
- MOCK_METHOD7(Register, bool(const std::string& username,
- const std::string& label,
- KeyType key_type,
- KeyUsage key_usage,
- const std::string& private_key_blob,
- const std::string& public_key_der,
- const std::string& certificate));
- MOCK_METHOD2(RegisterCertificate, bool(const std::string& username,
- const std::string& certificate));
+ MOCK_METHOD3(Read,
+ bool(const std::string& username,
+ const std::string& name,
+ std::string* key_data));
+ MOCK_METHOD3(Write,
+ bool(const std::string& username,
+ const std::string& name,
+ const std::string& key_data));
+ MOCK_METHOD2(Delete,
+ bool(const std::string& username, const std::string& name));
+ MOCK_METHOD2(DeleteByPrefix,
+ bool(const std::string& username,
+ const std::string& key_prefix));
+ MOCK_METHOD7(Register,
+ bool(const std::string& username,
+ const std::string& label,
+ KeyType key_type,
+ KeyUsage key_usage,
+ const std::string& private_key_blob,
+ const std::string& public_key_der,
+ const std::string& certificate));
+ MOCK_METHOD2(RegisterCertificate,
+ bool(const std::string& username,
+ const std::string& certificate));
private:
DISALLOW_COPY_AND_ASSIGN(MockKeyStore);
diff --git a/attestation/server/pkcs11_key_store.cc b/attestation/server/pkcs11_key_store.cc
index 6ffb872..8554436 100644
--- a/attestation/server/pkcs11_key_store.cc
+++ b/attestation/server/pkcs11_key_store.cc
@@ -76,13 +76,9 @@
}
}
- CK_SESSION_HANDLE handle() const {
- return handle_;
- }
+ CK_SESSION_HANDLE handle() const { return handle_; }
- bool IsValid() const {
- return (handle_ != CK_INVALID_HANDLE);
- }
+ bool IsValid() const { return (handle_ != CK_INVALID_HANDLE); }
private:
CK_SESSION_HANDLE handle_;
@@ -115,17 +111,15 @@
}
// First get the attribute with a NULL buffer which will give us the length.
CK_ATTRIBUTE attribute = {CKA_VALUE, nullptr, 0};
- if (C_GetAttributeValue(session.handle(),
- key_handle,
- &attribute, 1) != CKR_OK) {
+ if (C_GetAttributeValue(session.handle(), key_handle, &attribute, 1) !=
+ CKR_OK) {
LOG(ERROR) << "Pkcs11KeyStore: Failed to read key data: " << key_name;
return false;
}
key_data->resize(attribute.ulValueLen);
attribute.pValue = string_as_array(key_data);
- if (C_GetAttributeValue(session.handle(),
- key_handle,
- &attribute, 1) != CKR_OK) {
+ if (C_GetAttributeValue(session.handle(), key_handle, &attribute, 1) !=
+ CKR_OK) {
LOG(ERROR) << "Pkcs11KeyStore: Failed to read key data: " << key_name;
return false;
}
@@ -158,30 +152,16 @@
CK_BBOOL true_value = CK_TRUE;
CK_BBOOL false_value = CK_FALSE;
CK_ATTRIBUTE attributes[] = {
- {CKA_CLASS, &object_class, sizeof(object_class)},
- {
- CKA_LABEL,
- string_as_array(&mutable_key_name),
- mutable_key_name.size()
- },
- {
- CKA_VALUE,
- string_as_array(&mutable_key_data),
- mutable_key_data.size()
- },
- {
- CKA_APPLICATION,
- string_as_array(&mutable_application_id),
- mutable_application_id.size()
- },
- {CKA_TOKEN, &true_value, sizeof(true_value)},
- {CKA_PRIVATE, &true_value, sizeof(true_value)},
- {CKA_MODIFIABLE, &false_value, sizeof(false_value)}
- };
+ {CKA_CLASS, &object_class, sizeof(object_class)},
+ {CKA_LABEL, string_as_array(&mutable_key_name), mutable_key_name.size()},
+ {CKA_VALUE, string_as_array(&mutable_key_data), mutable_key_data.size()},
+ {CKA_APPLICATION, string_as_array(&mutable_application_id),
+ mutable_application_id.size()},
+ {CKA_TOKEN, &true_value, sizeof(true_value)},
+ {CKA_PRIVATE, &true_value, sizeof(true_value)},
+ {CKA_MODIFIABLE, &false_value, sizeof(false_value)}};
CK_OBJECT_HANDLE key_handle = CK_INVALID_HANDLE;
- if (C_CreateObject(session.handle(),
- attributes,
- arraysize(attributes),
+ if (C_CreateObject(session.handle(), attributes, arraysize(attributes),
&key_handle) != CKR_OK) {
LOG(ERROR) << "Pkcs11KeyStore: Failed to write key data: " << key_name;
return false;
@@ -223,11 +203,9 @@
LOG(ERROR) << "Pkcs11KeyStore: Failed to open token session.";
return false;
}
- EnumObjectsCallback callback = base::Bind(
- &Pkcs11KeyStore::DeleteIfMatchesPrefix,
- base::Unretained(this),
- session.handle(),
- key_prefix);
+ EnumObjectsCallback callback =
+ base::Bind(&Pkcs11KeyStore::DeleteIfMatchesPrefix, base::Unretained(this),
+ session.handle(), key_prefix);
if (!EnumObjects(session.handle(), callback)) {
LOG(ERROR) << "Pkcs11KeyStore: Failed to delete key data.";
return false;
@@ -260,18 +238,18 @@
}
// Extract the modulus from the public key.
- const unsigned char* asn1_ptr = reinterpret_cast<const unsigned char*>(
- public_key_der.data());
- crypto::ScopedRSA public_key(d2i_RSAPublicKey(nullptr,
- &asn1_ptr,
- public_key_der.size()));
+ const unsigned char* asn1_ptr =
+ reinterpret_cast<const unsigned char*>(public_key_der.data());
+ crypto::ScopedRSA public_key(
+ d2i_RSAPublicKey(nullptr, &asn1_ptr, public_key_der.size()));
if (!public_key.get()) {
LOG(ERROR) << "Pkcs11KeyStore: Failed to decode public key.";
return false;
}
std::string modulus(BN_num_bytes(public_key.get()->n), 0);
- int length = BN_bn2bin(public_key.get()->n, reinterpret_cast<unsigned char*>(
- string_as_array(&modulus)));
+ int length =
+ BN_bn2bin(public_key.get()->n,
+ reinterpret_cast<unsigned char*>(string_as_array(&modulus)));
if (length <= 0) {
LOG(ERROR) << "Pkcs11KeyStore: Failed to extract public key modulus.";
return false;
@@ -290,24 +268,22 @@
CK_BBOOL decrypt_usage = (key_usage == KEY_USAGE_DECRYPT);
unsigned char public_exponent[] = {1, 0, 1};
CK_ATTRIBUTE public_key_attributes[] = {
- {CKA_CLASS, &public_key_class, sizeof(public_key_class)},
- {CKA_TOKEN, &true_value, sizeof(true_value)},
- {CKA_DERIVE, &false_value, sizeof(false_value)},
- {CKA_WRAP, &false_value, sizeof(false_value)},
- {CKA_VERIFY, &sign_usage, sizeof(sign_usage)},
- {CKA_VERIFY_RECOVER, &false_value, sizeof(false_value)},
- {CKA_ENCRYPT, &decrypt_usage, sizeof(decrypt_usage)},
- {CKA_KEY_TYPE, &p11_key_type, sizeof(p11_key_type)},
- {CKA_ID, string_as_array(&id), id.size()},
- {CKA_LABEL, string_as_array(&mutable_label), mutable_label.size()},
- {CKA_MODULUS_BITS, &modulus_bits, sizeof(modulus_bits)},
- {CKA_PUBLIC_EXPONENT, public_exponent, arraysize(public_exponent)},
- {CKA_MODULUS, string_as_array(&modulus), modulus.size()}
- };
+ {CKA_CLASS, &public_key_class, sizeof(public_key_class)},
+ {CKA_TOKEN, &true_value, sizeof(true_value)},
+ {CKA_DERIVE, &false_value, sizeof(false_value)},
+ {CKA_WRAP, &false_value, sizeof(false_value)},
+ {CKA_VERIFY, &sign_usage, sizeof(sign_usage)},
+ {CKA_VERIFY_RECOVER, &false_value, sizeof(false_value)},
+ {CKA_ENCRYPT, &decrypt_usage, sizeof(decrypt_usage)},
+ {CKA_KEY_TYPE, &p11_key_type, sizeof(p11_key_type)},
+ {CKA_ID, string_as_array(&id), id.size()},
+ {CKA_LABEL, string_as_array(&mutable_label), mutable_label.size()},
+ {CKA_MODULUS_BITS, &modulus_bits, sizeof(modulus_bits)},
+ {CKA_PUBLIC_EXPONENT, public_exponent, arraysize(public_exponent)},
+ {CKA_MODULUS, string_as_array(&modulus), modulus.size()}};
CK_OBJECT_HANDLE object_handle = CK_INVALID_HANDLE;
- if (C_CreateObject(session.handle(),
- public_key_attributes,
+ if (C_CreateObject(session.handle(), public_key_attributes,
arraysize(public_key_attributes),
&object_handle) != CKR_OK) {
LOG(ERROR) << "Pkcs11KeyStore: Failed to create public key object.";
@@ -318,30 +294,25 @@
std::string mutable_private_key_blob(private_key_blob);
CK_OBJECT_CLASS private_key_class = CKO_PRIVATE_KEY;
CK_ATTRIBUTE private_key_attributes[] = {
- {CKA_CLASS, &private_key_class, sizeof(private_key_class)},
- {CKA_TOKEN, &true_value, sizeof(true_value)},
- {CKA_PRIVATE, &true_value, sizeof(true_value)},
- {CKA_SENSITIVE, &true_value, sizeof(true_value)},
- {CKA_EXTRACTABLE, &false_value, sizeof(false_value)},
- {CKA_DERIVE, &false_value, sizeof(false_value)},
- {CKA_UNWRAP, &false_value, sizeof(false_value)},
- {CKA_SIGN, &sign_usage, sizeof(sign_usage)},
- {CKA_SIGN_RECOVER, &false_value, sizeof(false_value)},
- {CKA_DECRYPT, &decrypt_usage, sizeof(decrypt_usage)},
- {CKA_KEY_TYPE, &p11_key_type, sizeof(p11_key_type)},
- {CKA_ID, string_as_array(&id), id.size()},
- {CKA_LABEL, string_as_array(&mutable_label), mutable_label.size()},
- {CKA_PUBLIC_EXPONENT, public_exponent, arraysize(public_exponent)},
- {CKA_MODULUS, string_as_array(&modulus), modulus.size()},
- {
- kKeyBlobAttribute,
- string_as_array(&mutable_private_key_blob),
- mutable_private_key_blob.size()
- }
- };
+ {CKA_CLASS, &private_key_class, sizeof(private_key_class)},
+ {CKA_TOKEN, &true_value, sizeof(true_value)},
+ {CKA_PRIVATE, &true_value, sizeof(true_value)},
+ {CKA_SENSITIVE, &true_value, sizeof(true_value)},
+ {CKA_EXTRACTABLE, &false_value, sizeof(false_value)},
+ {CKA_DERIVE, &false_value, sizeof(false_value)},
+ {CKA_UNWRAP, &false_value, sizeof(false_value)},
+ {CKA_SIGN, &sign_usage, sizeof(sign_usage)},
+ {CKA_SIGN_RECOVER, &false_value, sizeof(false_value)},
+ {CKA_DECRYPT, &decrypt_usage, sizeof(decrypt_usage)},
+ {CKA_KEY_TYPE, &p11_key_type, sizeof(p11_key_type)},
+ {CKA_ID, string_as_array(&id), id.size()},
+ {CKA_LABEL, string_as_array(&mutable_label), mutable_label.size()},
+ {CKA_PUBLIC_EXPONENT, public_exponent, arraysize(public_exponent)},
+ {CKA_MODULUS, string_as_array(&modulus), modulus.size()},
+ {kKeyBlobAttribute, string_as_array(&mutable_private_key_blob),
+ mutable_private_key_blob.size()}};
- if (C_CreateObject(session.handle(),
- private_key_attributes,
+ if (C_CreateObject(session.handle(), private_key_attributes,
arraysize(private_key_attributes),
&object_handle) != CKR_OK) {
LOG(ERROR) << "Pkcs11KeyStore: Failed to create private key object.";
@@ -360,28 +331,20 @@
CK_OBJECT_CLASS certificate_class = CKO_CERTIFICATE;
CK_CERTIFICATE_TYPE certificate_type = CKC_X_509;
CK_ATTRIBUTE certificate_attributes[] = {
- {CKA_CLASS, &certificate_class, sizeof(certificate_class)},
- {CKA_TOKEN, &true_value, sizeof(true_value)},
- {CKA_PRIVATE, &false_value, sizeof(false_value)},
- {CKA_ID, string_as_array(&id), id.size()},
- {CKA_LABEL, string_as_array(&mutable_label), mutable_label.size()},
- {CKA_CERTIFICATE_TYPE, &certificate_type, sizeof(certificate_type)},
- {CKA_SUBJECT, string_as_array(&subject), subject.size()},
- {CKA_ISSUER, string_as_array(&issuer), issuer.size()},
- {
- CKA_SERIAL_NUMBER,
- string_as_array(&serial_number),
- serial_number.size()
- },
- {
- CKA_VALUE,
- string_as_array(&mutable_certificate),
- mutable_certificate.size()
- }
- };
+ {CKA_CLASS, &certificate_class, sizeof(certificate_class)},
+ {CKA_TOKEN, &true_value, sizeof(true_value)},
+ {CKA_PRIVATE, &false_value, sizeof(false_value)},
+ {CKA_ID, string_as_array(&id), id.size()},
+ {CKA_LABEL, string_as_array(&mutable_label), mutable_label.size()},
+ {CKA_CERTIFICATE_TYPE, &certificate_type, sizeof(certificate_type)},
+ {CKA_SUBJECT, string_as_array(&subject), subject.size()},
+ {CKA_ISSUER, string_as_array(&issuer), issuer.size()},
+ {CKA_SERIAL_NUMBER, string_as_array(&serial_number),
+ serial_number.size()},
+ {CKA_VALUE, string_as_array(&mutable_certificate),
+ mutable_certificate.size()}};
- if (C_CreateObject(session.handle(),
- certificate_attributes,
+ if (C_CreateObject(session.handle(), certificate_attributes,
arraysize(certificate_attributes),
&object_handle) != CKR_OK) {
LOG(ERROR) << "Pkcs11KeyStore: Failed to create certificate object.";
@@ -426,22 +389,18 @@
CK_BBOOL true_value = CK_TRUE;
CK_BBOOL false_value = CK_FALSE;
CK_ATTRIBUTE certificate_attributes[] = {
- {CKA_CLASS, &certificate_class, sizeof(certificate_class)},
- {CKA_TOKEN, &true_value, sizeof(true_value)},
- {CKA_PRIVATE, &false_value, sizeof(false_value)},
- {CKA_CERTIFICATE_TYPE, &certificate_type, sizeof(certificate_type)},
- {CKA_SUBJECT, string_as_array(&subject), subject.size()},
- {CKA_ISSUER, string_as_array(&issuer), issuer.size()},
- {CKA_SERIAL_NUMBER, string_as_array(&serial_number), serial_number.size()},
- {
- CKA_VALUE,
- string_as_array(&mutable_certificate),
- mutable_certificate.size()
- }
- };
+ {CKA_CLASS, &certificate_class, sizeof(certificate_class)},
+ {CKA_TOKEN, &true_value, sizeof(true_value)},
+ {CKA_PRIVATE, &false_value, sizeof(false_value)},
+ {CKA_CERTIFICATE_TYPE, &certificate_type, sizeof(certificate_type)},
+ {CKA_SUBJECT, string_as_array(&subject), subject.size()},
+ {CKA_ISSUER, string_as_array(&issuer), issuer.size()},
+ {CKA_SERIAL_NUMBER, string_as_array(&serial_number),
+ serial_number.size()},
+ {CKA_VALUE, string_as_array(&mutable_certificate),
+ mutable_certificate.size()}};
CK_OBJECT_HANDLE object_handle = CK_INVALID_HANDLE;
- if (C_CreateObject(session.handle(),
- certificate_attributes,
+ if (C_CreateObject(session.handle(), certificate_attributes,
arraysize(certificate_attributes),
&object_handle) != CKR_OK) {
LOG(ERROR) << "Pkcs11KeyStore: Failed to create certificate object.";
@@ -459,26 +418,17 @@
CK_BBOOL true_value = CK_TRUE;
CK_BBOOL false_value = CK_FALSE;
CK_ATTRIBUTE attributes[] = {
- {CKA_CLASS, &object_class, sizeof(object_class)},
- {
- CKA_LABEL,
- string_as_array(&mutable_key_name),
- mutable_key_name.size()
- },
- {
- CKA_APPLICATION,
- string_as_array(&mutable_application_id),
- mutable_application_id.size()
- },
- {CKA_TOKEN, &true_value, sizeof(true_value)},
- {CKA_PRIVATE, &true_value, sizeof(true_value)},
- {CKA_MODIFIABLE, &false_value, sizeof(false_value)}
- };
+ {CKA_CLASS, &object_class, sizeof(object_class)},
+ {CKA_LABEL, string_as_array(&mutable_key_name), mutable_key_name.size()},
+ {CKA_APPLICATION, string_as_array(&mutable_application_id),
+ mutable_application_id.size()},
+ {CKA_TOKEN, &true_value, sizeof(true_value)},
+ {CKA_PRIVATE, &true_value, sizeof(true_value)},
+ {CKA_MODIFIABLE, &false_value, sizeof(false_value)}};
CK_OBJECT_HANDLE key_handle = CK_INVALID_HANDLE;
CK_ULONG count = 0;
- if ((C_FindObjectsInit(session_handle,
- attributes,
- arraysize(attributes)) != CKR_OK) ||
+ if ((C_FindObjectsInit(session_handle, attributes, arraysize(attributes)) !=
+ CKR_OK) ||
(C_FindObjects(session_handle, &key_handle, 1, &count) != CKR_OK) ||
(C_FindObjectsFinal(session_handle) != CKR_OK)) {
LOG(ERROR) << "Key search failed: " << key_name;
@@ -493,9 +443,10 @@
CK_SLOT_ID_PTR slot) {
const char kChapsDaemonName[] = "chaps";
const char kChapsSystemToken[] = "/var/lib/chaps";
- base::FilePath token_path = username.empty() ?
- base::FilePath(kChapsSystemToken) :
- brillo::cryptohome::home::GetDaemonPath(username, kChapsDaemonName);
+ base::FilePath token_path =
+ username.empty()
+ ? base::FilePath(kChapsSystemToken)
+ : brillo::cryptohome::home::GetDaemonPath(username, kChapsDaemonName);
CK_RV rv;
rv = C_Initialize(nullptr);
if (rv != CKR_OK && rv != CKR_CRYPTOKI_ALREADY_INITIALIZED) {
@@ -518,9 +469,9 @@
for (CK_ULONG i = 0; i < num_slots; ++i) {
base::FilePath slot_path;
if (token_manager_->GetTokenPath(
- chaps::IsolateCredentialManager::GetDefaultIsolateCredential(),
- slot_list[i],
- &slot_path) && (token_path == slot_path)) {
+ chaps::IsolateCredentialManager::GetDefaultIsolateCredential(),
+ slot_list[i], &slot_path) &&
+ (token_path == slot_path)) {
*slot = slot_list[i];
return true;
}
@@ -538,22 +489,17 @@
CK_BBOOL true_value = CK_TRUE;
CK_BBOOL false_value = CK_FALSE;
CK_ATTRIBUTE attributes[] = {
- {CKA_CLASS, &object_class, sizeof(object_class)},
- {
- CKA_APPLICATION,
- string_as_array(&mutable_application_id),
- mutable_application_id.size()
- },
- {CKA_TOKEN, &true_value, sizeof(true_value)},
- {CKA_PRIVATE, &true_value, sizeof(true_value)},
- {CKA_MODIFIABLE, &false_value, sizeof(false_value)}
- };
+ {CKA_CLASS, &object_class, sizeof(object_class)},
+ {CKA_APPLICATION, string_as_array(&mutable_application_id),
+ mutable_application_id.size()},
+ {CKA_TOKEN, &true_value, sizeof(true_value)},
+ {CKA_PRIVATE, &true_value, sizeof(true_value)},
+ {CKA_MODIFIABLE, &false_value, sizeof(false_value)}};
const CK_ULONG kMaxHandles = 100; // Arbitrary.
CK_OBJECT_HANDLE handles[kMaxHandles];
CK_ULONG count = 0;
- if ((C_FindObjectsInit(session_handle,
- attributes,
- arraysize(attributes)) != CKR_OK) ||
+ if ((C_FindObjectsInit(session_handle, attributes, arraysize(attributes)) !=
+ CKR_OK) ||
(C_FindObjects(session_handle, handles, kMaxHandles, &count) != CKR_OK)) {
LOG(ERROR) << "Key search failed.";
return false;
@@ -615,8 +561,8 @@
std::string* subject,
std::string* issuer,
std::string* serial_number) {
- const unsigned char* asn1_ptr = reinterpret_cast<const unsigned char*>(
- certificate.data());
+ const unsigned char* asn1_ptr =
+ reinterpret_cast<const unsigned char*>(certificate.data());
ScopedX509 x509(d2i_X509(nullptr, &asn1_ptr, certificate.size()));
if (!x509.get() || !x509->cert_info || !x509->cert_info->subject) {
LOG(WARNING) << "Pkcs11KeyStore: Failed to decode certificate.";
@@ -641,8 +587,8 @@
issuer->assign(reinterpret_cast<char*>(issuer_buffer), length);
unsigned char* serial_number_buffer = nullptr;
- length = i2d_ASN1_INTEGER(x509->cert_info->serialNumber,
- &serial_number_buffer);
+ length =
+ i2d_ASN1_INTEGER(x509->cert_info->serialNumber, &serial_number_buffer);
crypto::ScopedOpenSSLBytes scoped_serial_number_buffer(serial_number_buffer);
if (length <= 0) {
LOG(WARNING) << "Pkcs11KeyStore: Failed to encode certificate serial "
@@ -653,28 +599,22 @@
return true;
}
-bool Pkcs11KeyStore::DoesCertificateExist(
- CK_SESSION_HANDLE session_handle,
- const std::string& certificate) {
+bool Pkcs11KeyStore::DoesCertificateExist(CK_SESSION_HANDLE session_handle,
+ const std::string& certificate) {
CK_OBJECT_CLASS object_class = CKO_CERTIFICATE;
CK_BBOOL true_value = CK_TRUE;
CK_BBOOL false_value = CK_FALSE;
std::string mutable_certificate = certificate;
CK_ATTRIBUTE attributes[] = {
- {CKA_CLASS, &object_class, sizeof(object_class)},
- {CKA_TOKEN, &true_value, sizeof(true_value)},
- {CKA_PRIVATE, &false_value, sizeof(false_value)},
- {
- CKA_VALUE,
- string_as_array(&mutable_certificate),
- mutable_certificate.size()
- }
- };
+ {CKA_CLASS, &object_class, sizeof(object_class)},
+ {CKA_TOKEN, &true_value, sizeof(true_value)},
+ {CKA_PRIVATE, &false_value, sizeof(false_value)},
+ {CKA_VALUE, string_as_array(&mutable_certificate),
+ mutable_certificate.size()}};
CK_OBJECT_HANDLE object_handle = CK_INVALID_HANDLE;
CK_ULONG count = 0;
- if ((C_FindObjectsInit(session_handle,
- attributes,
- arraysize(attributes)) != CKR_OK) ||
+ if ((C_FindObjectsInit(session_handle, attributes, arraysize(attributes)) !=
+ CKR_OK) ||
(C_FindObjects(session_handle, &object_handle, 1, &count) != CKR_OK) ||
(C_FindObjectsFinal(session_handle) != CKR_OK)) {
return false;
diff --git a/attestation/server/pkcs11_key_store.h b/attestation/server/pkcs11_key_store.h
index a1ccd7e..608a5b0 100644
--- a/attestation/server/pkcs11_key_store.h
+++ b/attestation/server/pkcs11_key_store.h
@@ -80,8 +80,7 @@
// Gets a slot for the given |username| if |is_user_specific| or the system
// slot otherwise. Returns false if no appropriate slot is found.
- bool GetUserSlot(const std::string& username,
- CK_SLOT_ID_PTR slot);
+ bool GetUserSlot(const std::string& username, CK_SLOT_ID_PTR slot);
// Enumerates all PKCS #11 objects associated with keys. The |callback| is
// called once for each object.
diff --git a/attestation/server/pkcs11_key_store_test.cc b/attestation/server/pkcs11_key_store_test.cc
index 4e967b2..4bafce7 100644
--- a/attestation/server/pkcs11_key_store_test.cc
+++ b/attestation/server/pkcs11_key_store_test.cc
@@ -101,9 +101,7 @@
ScopedFakeSalt() : salt_(128, 0) {
brillo::cryptohome::home::SetSystemSalt(&salt_);
}
- ~ScopedFakeSalt() {
- brillo::cryptohome::home::SetSystemSalt(nullptr);
- }
+ ~ScopedFakeSalt() { brillo::cryptohome::home::SetSystemSalt(nullptr); }
private:
std::string salt_;
@@ -149,8 +147,7 @@
.WillByDefault(DoAll(SetArgumentPointee<2>(slot_list), Return(0)));
ON_CALL(pkcs11_, OpenSession(_, _, _, _))
.WillByDefault(DoAll(SetArgumentPointee<3>(kSession), Return(0)));
- ON_CALL(pkcs11_, CloseSession(_, _))
- .WillByDefault(Return(0));
+ ON_CALL(pkcs11_, CloseSession(_, _)).WillByDefault(Return(0));
ON_CALL(pkcs11_, CreateObject(_, _, _, _))
.WillByDefault(Invoke(this, &KeyStoreTest::CreateObject));
ON_CALL(pkcs11_, DestroyObject(_, _, _))
@@ -163,13 +160,12 @@
.WillByDefault(Invoke(this, &KeyStoreTest::FindObjectsInit));
ON_CALL(pkcs11_, FindObjects(_, _, _, _))
.WillByDefault(Invoke(this, &KeyStoreTest::FindObjects));
- ON_CALL(pkcs11_, FindObjectsFinal(_, _))
- .WillByDefault(Return(0));
+ ON_CALL(pkcs11_, FindObjectsFinal(_, _)).WillByDefault(Return(0));
base::FilePath system_path("/var/lib/chaps");
ON_CALL(token_manager_, GetTokenPath(_, 0, _))
.WillByDefault(DoAll(SetArgumentPointee<2>(system_path), Return(true)));
- base::FilePath user_path(brillo::cryptohome::home::GetDaemonPath(
- kDefaultUser, "chaps"));
+ base::FilePath user_path(
+ brillo::cryptohome::home::GetDaemonPath(kDefaultUser, "chaps"));
ON_CALL(token_manager_, GetTokenPath(_, 1, _))
.WillByDefault(DoAll(SetArgumentPointee<2>(user_path), Return(true)));
}
@@ -225,11 +221,10 @@
}
// Supports writing CKA_VALUE.
- virtual uint32_t SetAttributeValue(
- const brillo::SecureBlob& isolate,
- uint64_t session_id,
- uint64_t object_handle,
- const std::vector<uint8_t>& attributes) {
+ virtual uint32_t SetAttributeValue(const brillo::SecureBlob& isolate,
+ uint64_t session_id,
+ uint64_t object_handle,
+ const std::vector<uint8_t>& attributes) {
values_[handles_[object_handle]] = GetValue(attributes, CKA_VALUE);
return CKR_OK;
}
@@ -434,15 +429,13 @@
EXPECT_TRUE(key_store.Write(kDefaultUser, "test", "test_data"));
EXPECT_FALSE(key_store.Read(kDefaultUser, "test", &blob));
- EXPECT_CALL(pkcs11_, FindObjectsInit(_, _, _))
- .WillRepeatedly(Return(CKR_OK));
+ EXPECT_CALL(pkcs11_, FindObjectsInit(_, _, _)).WillRepeatedly(Return(CKR_OK));
EXPECT_CALL(pkcs11_, FindObjects(_, _, _, _))
.WillRepeatedly(Return(CKR_GENERAL_ERROR));
EXPECT_TRUE(key_store.Write(kDefaultUser, "test", "test_data"));
EXPECT_FALSE(key_store.Read(kDefaultUser, "test", &blob));
- EXPECT_CALL(pkcs11_, FindObjects(_, _, _, _))
- .WillRepeatedly(Return(CKR_OK));
+ EXPECT_CALL(pkcs11_, FindObjects(_, _, _, _)).WillRepeatedly(Return(CKR_OK));
EXPECT_CALL(pkcs11_, FindObjectsFinal(_, _))
.WillRepeatedly(Return(CKR_GENERAL_ERROR));
EXPECT_TRUE(key_store.Write(kDefaultUser, "test", "test_data"));
@@ -515,8 +508,7 @@
}
TEST_F(KeyStoreTest, RegisterDecryptionKey) {
- EXPECT_CALL(pkcs11_, CreateObject(_, _, _, _))
- .WillRepeatedly(Return(CKR_OK));
+ EXPECT_CALL(pkcs11_, CreateObject(_, _, _, _)).WillRepeatedly(Return(CKR_OK));
Pkcs11KeyStore key_store(&token_manager_);
std::string public_key_der = HexDecode(kValidPublicKeyHex);
EXPECT_TRUE(key_store.Register(kDefaultUser, "test_label", KEY_TYPE_RSA,
@@ -550,8 +542,7 @@
Pkcs11KeyStore key_store(&token_manager_);
std::string certificate_der = HexDecode(kValidCertificateHex);
// Try with the system token.
- EXPECT_CALL(pkcs11_, CreateObject(_, _, _, _))
- .WillOnce(Return(CKR_OK));
+ EXPECT_CALL(pkcs11_, CreateObject(_, _, _, _)).WillOnce(Return(CKR_OK));
EXPECT_TRUE(key_store.RegisterCertificate(kDefaultUser, certificate_der));
}
diff --git a/tpm_manager/client/main.cc b/tpm_manager/client/main.cc
index 79ae520..f96d959 100644
--- a/tpm_manager/client/main.cc
+++ b/tpm_manager/client/main.cc
@@ -137,8 +137,7 @@
weak_factory_.GetWeakPtr());
} else if (command_line->HasSwitch(kRemoveOwnerDependencyCommand)) {
task = base::Bind(
- &ClientLoop::HandleRemoveOwnerDependency,
- weak_factory_.GetWeakPtr(),
+ &ClientLoop::HandleRemoveOwnerDependency, weak_factory_.GetWeakPtr(),
command_line->GetSwitchValueASCII(kRemoveOwnerDependencyCommand));
} else if (command_line->HasSwitch(kDefineNvramCommand)) {
if (!command_line->HasSwitch(kNvramIndexArg) ||
@@ -147,8 +146,7 @@
return EX_USAGE;
}
task = base::Bind(
- &ClientLoop::HandleDefineNvram,
- weak_factory_.GetWeakPtr(),
+ &ClientLoop::HandleDefineNvram, weak_factory_.GetWeakPtr(),
atoi(command_line->GetSwitchValueASCII(kNvramIndexArg).c_str()),
atoi(command_line->GetSwitchValueASCII(kNvramLengthArg).c_str()));
} else if (command_line->HasSwitch(kDestroyNvramCommand)) {
@@ -157,8 +155,7 @@
return EX_USAGE;
}
task = base::Bind(
- &ClientLoop::HandleDestroyNvram,
- weak_factory_.GetWeakPtr(),
+ &ClientLoop::HandleDestroyNvram, weak_factory_.GetWeakPtr(),
atoi(command_line->GetSwitchValueASCII(kNvramIndexArg).c_str()));
} else if (command_line->HasSwitch(kWriteNvramCommand)) {
if (!command_line->HasSwitch(kNvramIndexArg) ||
@@ -167,8 +164,7 @@
return EX_USAGE;
}
task = base::Bind(
- &ClientLoop::HandleWriteNvram,
- weak_factory_.GetWeakPtr(),
+ &ClientLoop::HandleWriteNvram, weak_factory_.GetWeakPtr(),
atoi(command_line->GetSwitchValueASCII(kNvramIndexArg).c_str()),
command_line->GetSwitchValueASCII(kNvramDataArg));
} else if (command_line->HasSwitch(kReadNvramCommand)) {
@@ -177,8 +173,7 @@
return EX_USAGE;
}
task = base::Bind(
- &ClientLoop::HandleReadNvram,
- weak_factory_.GetWeakPtr(),
+ &ClientLoop::HandleReadNvram, weak_factory_.GetWeakPtr(),
atoi(command_line->GetSwitchValueASCII(kNvramIndexArg).c_str()));
} else if (command_line->HasSwitch(kIsNvramDefinedCommand)) {
if (!command_line->HasSwitch(kNvramIndexArg)) {
@@ -186,8 +181,7 @@
return EX_USAGE;
}
task = base::Bind(
- &ClientLoop::HandleIsNvramDefined,
- weak_factory_.GetWeakPtr(),
+ &ClientLoop::HandleIsNvramDefined, weak_factory_.GetWeakPtr(),
atoi(command_line->GetSwitchValueASCII(kNvramIndexArg).c_str()));
} else if (command_line->HasSwitch(kIsNvramLockedCommand)) {
if (!command_line->HasSwitch(kNvramIndexArg)) {
@@ -195,8 +189,7 @@
return EX_USAGE;
}
task = base::Bind(
- &ClientLoop::HandleIsNvramLocked,
- weak_factory_.GetWeakPtr(),
+ &ClientLoop::HandleIsNvramLocked, weak_factory_.GetWeakPtr(),
atoi(command_line->GetSwitchValueASCII(kNvramIndexArg).c_str()));
} else if (command_line->HasSwitch(kGetNvramSizeCommand)) {
if (!command_line->HasSwitch(kNvramIndexArg)) {
@@ -204,8 +197,7 @@
return EX_USAGE;
}
task = base::Bind(
- &ClientLoop::HandleGetNvramSize,
- weak_factory_.GetWeakPtr(),
+ &ClientLoop::HandleGetNvramSize, weak_factory_.GetWeakPtr(),
atoi(command_line->GetSwitchValueASCII(kNvramIndexArg).c_str()));
} else {
// Command line arguments did not match any valid commands.
@@ -226,17 +218,15 @@
void HandleGetTpmStatus() {
GetTpmStatusRequest request;
tpm_ownership_->GetTpmStatus(
- request,
- base::Bind(&ClientLoop::PrintReplyAndQuit<GetTpmStatusReply>,
- weak_factory_.GetWeakPtr()));
+ request, base::Bind(&ClientLoop::PrintReplyAndQuit<GetTpmStatusReply>,
+ weak_factory_.GetWeakPtr()));
}
void HandleTakeOwnership() {
TakeOwnershipRequest request;
tpm_ownership_->TakeOwnership(
- request,
- base::Bind(&ClientLoop::PrintReplyAndQuit<TakeOwnershipReply>,
- weak_factory_.GetWeakPtr()));
+ request, base::Bind(&ClientLoop::PrintReplyAndQuit<TakeOwnershipReply>,
+ weak_factory_.GetWeakPtr()));
}
void HandleRemoveOwnerDependency(const std::string& owner_dependency) {
@@ -253,18 +243,16 @@
request.set_index(index);
request.set_length(length);
tpm_nvram_->DefineNvram(
- request,
- base::Bind(&ClientLoop::PrintReplyAndQuit<DefineNvramReply>,
- weak_factory_.GetWeakPtr()));
+ request, base::Bind(&ClientLoop::PrintReplyAndQuit<DefineNvramReply>,
+ weak_factory_.GetWeakPtr()));
}
void HandleDestroyNvram(uint32_t index) {
DestroyNvramRequest request;
request.set_index(index);
tpm_nvram_->DestroyNvram(
- request,
- base::Bind(&ClientLoop::PrintReplyAndQuit<DestroyNvramReply>,
- weak_factory_.GetWeakPtr()));
+ request, base::Bind(&ClientLoop::PrintReplyAndQuit<DestroyNvramReply>,
+ weak_factory_.GetWeakPtr()));
}
void HandleWriteNvram(uint32_t index, const std::string& data) {
@@ -272,45 +260,40 @@
request.set_index(index);
request.set_data(data);
tpm_nvram_->WriteNvram(
- request,
- base::Bind(&ClientLoop::PrintReplyAndQuit<WriteNvramReply>,
- weak_factory_.GetWeakPtr()));
+ request, base::Bind(&ClientLoop::PrintReplyAndQuit<WriteNvramReply>,
+ weak_factory_.GetWeakPtr()));
}
void HandleReadNvram(uint32_t index) {
ReadNvramRequest request;
request.set_index(index);
tpm_nvram_->ReadNvram(
- request,
- base::Bind(&ClientLoop::PrintReplyAndQuit<ReadNvramReply>,
- weak_factory_.GetWeakPtr()));
+ request, base::Bind(&ClientLoop::PrintReplyAndQuit<ReadNvramReply>,
+ weak_factory_.GetWeakPtr()));
}
void HandleIsNvramDefined(uint32_t index) {
IsNvramDefinedRequest request;
request.set_index(index);
tpm_nvram_->IsNvramDefined(
- request,
- base::Bind(&ClientLoop::PrintReplyAndQuit<IsNvramDefinedReply>,
- weak_factory_.GetWeakPtr()));
+ request, base::Bind(&ClientLoop::PrintReplyAndQuit<IsNvramDefinedReply>,
+ weak_factory_.GetWeakPtr()));
}
void HandleIsNvramLocked(uint32_t index) {
IsNvramLockedRequest request;
request.set_index(index);
tpm_nvram_->IsNvramLocked(
- request,
- base::Bind(&ClientLoop::PrintReplyAndQuit<IsNvramLockedReply>,
- weak_factory_.GetWeakPtr()));
+ request, base::Bind(&ClientLoop::PrintReplyAndQuit<IsNvramLockedReply>,
+ weak_factory_.GetWeakPtr()));
}
void HandleGetNvramSize(uint32_t index) {
GetNvramSizeRequest request;
request.set_index(index);
tpm_nvram_->GetNvramSize(
- request,
- base::Bind(&ClientLoop::PrintReplyAndQuit<GetNvramSizeReply>,
- weak_factory_.GetWeakPtr()));
+ request, base::Bind(&ClientLoop::PrintReplyAndQuit<GetNvramSizeReply>,
+ weak_factory_.GetWeakPtr()));
}
// Pointer to a DBus proxy to tpm_managerd.
diff --git a/tpm_manager/client/tpm_nvram_dbus_proxy.cc b/tpm_manager/client/tpm_nvram_dbus_proxy.cc
index fc0706e..aed66dc 100644
--- a/tpm_manager/client/tpm_nvram_dbus_proxy.cc
+++ b/tpm_manager/client/tpm_nvram_dbus_proxy.cc
@@ -69,14 +69,14 @@
void TpmNvramDBusProxy::IsNvramDefined(const IsNvramDefinedRequest& request,
const IsNvramDefinedCallback& callback) {
- CallMethod<IsNvramDefinedReply>(
- tpm_manager::kIsNvramDefined, request, callback);
+ CallMethod<IsNvramDefinedReply>(tpm_manager::kIsNvramDefined, request,
+ callback);
}
void TpmNvramDBusProxy::IsNvramLocked(const IsNvramLockedRequest& request,
const IsNvramLockedCallback& callback) {
- CallMethod<IsNvramLockedReply>(
- tpm_manager::kIsNvramLocked, request, callback);
+ CallMethod<IsNvramLockedReply>(tpm_manager::kIsNvramLocked, request,
+ callback);
}
void TpmNvramDBusProxy::GetNvramSize(const GetNvramSizeRequest& request,
@@ -84,9 +84,9 @@
CallMethod<GetNvramSizeReply>(tpm_manager::kGetNvramSize, request, callback);
}
-template<typename ReplyProtobufType,
- typename RequestProtobufType,
- typename CallbackType>
+template <typename ReplyProtobufType,
+ typename RequestProtobufType,
+ typename CallbackType>
void TpmNvramDBusProxy::CallMethod(const std::string& method_name,
const RequestProtobufType& request,
const CallbackType& callback) {
@@ -96,13 +96,8 @@
callback.Run(reply);
};
brillo::dbus_utils::CallMethodWithTimeout(
- kDBusTimeoutMS,
- object_proxy_,
- tpm_manager::kTpmNvramInterface,
- method_name,
- callback,
- base::Bind(on_error),
- request);
+ kDBusTimeoutMS, object_proxy_, tpm_manager::kTpmNvramInterface,
+ method_name, callback, base::Bind(on_error), request);
}
} // namespace tpm_manager
diff --git a/tpm_manager/client/tpm_nvram_dbus_proxy.h b/tpm_manager/client/tpm_nvram_dbus_proxy.h
index 4522311..c757f2c 100644
--- a/tpm_manager/client/tpm_nvram_dbus_proxy.h
+++ b/tpm_manager/client/tpm_nvram_dbus_proxy.h
@@ -66,9 +66,9 @@
private:
// Template method to call a given |method_name| remotely via dbus.
- template<typename ReplyProtobufType,
- typename RequestProtobufType,
- typename CallbackType>
+ template <typename ReplyProtobufType,
+ typename RequestProtobufType,
+ typename CallbackType>
void CallMethod(const std::string& method_name,
const RequestProtobufType& request,
const CallbackType& callback);
diff --git a/tpm_manager/client/tpm_nvram_dbus_proxy_test.cc b/tpm_manager/client/tpm_nvram_dbus_proxy_test.cc
index b03237e..9f31918 100644
--- a/tpm_manager/client/tpm_nvram_dbus_proxy_test.cc
+++ b/tpm_manager/client/tpm_nvram_dbus_proxy_test.cc
@@ -212,8 +212,8 @@
.WillOnce(WithArgs<0, 2>(Invoke(fake_dbus_call)));
// Set expectations on the outputs.
int callback_count = 0;
- auto callback = [&callback_count, nvram_defined](
- const IsNvramDefinedReply& reply) {
+ auto callback = [&callback_count,
+ nvram_defined](const IsNvramDefinedReply& reply) {
callback_count++;
EXPECT_EQ(STATUS_SUCCESS, reply.status());
EXPECT_TRUE(reply.has_is_defined());
@@ -250,8 +250,8 @@
.WillOnce(WithArgs<0, 2>(Invoke(fake_dbus_call)));
// Set expectations on the outputs.
int callback_count = 0;
- auto callback = [&callback_count, nvram_locked](
- const IsNvramLockedReply& reply) {
+ auto callback = [&callback_count,
+ nvram_locked](const IsNvramLockedReply& reply) {
callback_count++;
EXPECT_EQ(STATUS_SUCCESS, reply.status());
EXPECT_TRUE(reply.has_is_locked());
@@ -288,8 +288,8 @@
.WillOnce(WithArgs<0, 2>(Invoke(fake_dbus_call)));
// Set expectations on the outputs.
int callback_count = 0;
- auto callback = [&callback_count, nvram_size](
- const GetNvramSizeReply& reply) {
+ auto callback = [&callback_count,
+ nvram_size](const GetNvramSizeReply& reply) {
callback_count++;
EXPECT_EQ(STATUS_SUCCESS, reply.status());
EXPECT_TRUE(reply.has_size());
diff --git a/tpm_manager/client/tpm_ownership_dbus_proxy.cc b/tpm_manager/client/tpm_ownership_dbus_proxy.cc
index ae5c6a5..de1f68f 100644
--- a/tpm_manager/client/tpm_ownership_dbus_proxy.cc
+++ b/tpm_manager/client/tpm_ownership_dbus_proxy.cc
@@ -47,29 +47,28 @@
return (object_proxy_ != nullptr);
}
-void TpmOwnershipDBusProxy::GetTpmStatus(
- const GetTpmStatusRequest& request,
- const GetTpmStatusCallback& callback) {
+void TpmOwnershipDBusProxy::GetTpmStatus(const GetTpmStatusRequest& request,
+ const GetTpmStatusCallback& callback) {
CallMethod<GetTpmStatusReply>(tpm_manager::kGetTpmStatus, request, callback);
}
void TpmOwnershipDBusProxy::TakeOwnership(
const TakeOwnershipRequest& request,
const TakeOwnershipCallback& callback) {
- CallMethod<TakeOwnershipReply>(
- tpm_manager::kTakeOwnership, request, callback);
+ CallMethod<TakeOwnershipReply>(tpm_manager::kTakeOwnership, request,
+ callback);
}
void TpmOwnershipDBusProxy::RemoveOwnerDependency(
const RemoveOwnerDependencyRequest& request,
const RemoveOwnerDependencyCallback& callback) {
- CallMethod<RemoveOwnerDependencyReply>(
- tpm_manager::kRemoveOwnerDependency, request, callback);
+ CallMethod<RemoveOwnerDependencyReply>(tpm_manager::kRemoveOwnerDependency,
+ request, callback);
}
-template<typename ReplyProtobufType,
- typename RequestProtobufType,
- typename CallbackType>
+template <typename ReplyProtobufType,
+ typename RequestProtobufType,
+ typename CallbackType>
void TpmOwnershipDBusProxy::CallMethod(const std::string& method_name,
const RequestProtobufType& request,
const CallbackType& callback) {
@@ -79,13 +78,8 @@
callback.Run(reply);
};
brillo::dbus_utils::CallMethodWithTimeout(
- kDBusTimeoutMS,
- object_proxy_,
- tpm_manager::kTpmOwnershipInterface,
- method_name,
- callback,
- base::Bind(on_error),
- request);
+ kDBusTimeoutMS, object_proxy_, tpm_manager::kTpmOwnershipInterface,
+ method_name, callback, base::Bind(on_error), request);
}
} // namespace tpm_manager
diff --git a/tpm_manager/client/tpm_ownership_dbus_proxy.h b/tpm_manager/client/tpm_ownership_dbus_proxy.h
index 1731f15..f2e6ad1 100644
--- a/tpm_manager/client/tpm_ownership_dbus_proxy.h
+++ b/tpm_manager/client/tpm_ownership_dbus_proxy.h
@@ -59,9 +59,9 @@
private:
// Template method to call a given |method_name| remotely via dbus.
- template<typename ReplyProtobufType,
- typename RequestProtobufType,
- typename CallbackType>
+ template <typename ReplyProtobufType,
+ typename RequestProtobufType,
+ typename CallbackType>
void CallMethod(const std::string& method_name,
const RequestProtobufType& request,
const CallbackType& callback);
diff --git a/tpm_manager/common/mock_tpm_nvram_interface.h b/tpm_manager/common/mock_tpm_nvram_interface.h
index c7360e7..2f8364d 100644
--- a/tpm_manager/common/mock_tpm_nvram_interface.h
+++ b/tpm_manager/common/mock_tpm_nvram_interface.h
@@ -28,20 +28,27 @@
MockTpmNvramInterface();
~MockTpmNvramInterface() override;
- MOCK_METHOD2(DefineNvram, void(const DefineNvramRequest& request,
- const DefineNvramCallback& callback));
- MOCK_METHOD2(DestroyNvram, void(const DestroyNvramRequest& request,
- const DestroyNvramCallback& callback));
- MOCK_METHOD2(WriteNvram, void(const WriteNvramRequest& request,
- const WriteNvramCallback& callback));
- MOCK_METHOD2(ReadNvram, void(const ReadNvramRequest& request,
- const ReadNvramCallback& callback));
- MOCK_METHOD2(IsNvramDefined, void(const IsNvramDefinedRequest& request,
- const IsNvramDefinedCallback& callback));
- MOCK_METHOD2(IsNvramLocked, void(const IsNvramLockedRequest& request,
- const IsNvramLockedCallback& callback));
- MOCK_METHOD2(GetNvramSize, void(const GetNvramSizeRequest& request,
- const GetNvramSizeCallback& callback));
+ MOCK_METHOD2(DefineNvram,
+ void(const DefineNvramRequest& request,
+ const DefineNvramCallback& callback));
+ MOCK_METHOD2(DestroyNvram,
+ void(const DestroyNvramRequest& request,
+ const DestroyNvramCallback& callback));
+ MOCK_METHOD2(WriteNvram,
+ void(const WriteNvramRequest& request,
+ const WriteNvramCallback& callback));
+ MOCK_METHOD2(ReadNvram,
+ void(const ReadNvramRequest& request,
+ const ReadNvramCallback& callback));
+ MOCK_METHOD2(IsNvramDefined,
+ void(const IsNvramDefinedRequest& request,
+ const IsNvramDefinedCallback& callback));
+ MOCK_METHOD2(IsNvramLocked,
+ void(const IsNvramLockedRequest& request,
+ const IsNvramLockedCallback& callback));
+ MOCK_METHOD2(GetNvramSize,
+ void(const GetNvramSizeRequest& request,
+ const GetNvramSizeCallback& callback));
};
} // namespace tpm_manager
diff --git a/tpm_manager/common/mock_tpm_ownership_interface.h b/tpm_manager/common/mock_tpm_ownership_interface.h
index b26f650..87058d3 100644
--- a/tpm_manager/common/mock_tpm_ownership_interface.h
+++ b/tpm_manager/common/mock_tpm_ownership_interface.h
@@ -28,10 +28,12 @@
MockTpmOwnershipInterface();
~MockTpmOwnershipInterface() override;
- MOCK_METHOD2(GetTpmStatus, void(const GetTpmStatusRequest& request,
- const GetTpmStatusCallback& callback));
- MOCK_METHOD2(TakeOwnership, void(const TakeOwnershipRequest& request,
- const TakeOwnershipCallback& callback));
+ MOCK_METHOD2(GetTpmStatus,
+ void(const GetTpmStatusRequest& request,
+ const GetTpmStatusCallback& callback));
+ MOCK_METHOD2(TakeOwnership,
+ void(const TakeOwnershipRequest& request,
+ const TakeOwnershipCallback& callback));
MOCK_METHOD2(RemoveOwnerDependency,
void(const RemoveOwnerDependencyRequest& request,
const RemoveOwnerDependencyCallback& callback));
diff --git a/tpm_manager/common/tpm_manager_constants.h b/tpm_manager/common/tpm_manager_constants.h
index 8d994cd..725300e 100644
--- a/tpm_manager/common/tpm_manager_constants.h
+++ b/tpm_manager/common/tpm_manager_constants.h
@@ -34,7 +34,7 @@
// Array to easily access the list of ownership dependencies.
// Note: When dependencies are added/removed from the above list, they should
// be modified here as well.
-constexpr const char* kInitialTpmOwnerDependencies[] = { kTestDependency };
+constexpr const char* kInitialTpmOwnerDependencies[] = {kTestDependency};
} // namespace tpm_manager
diff --git a/tpm_manager/server/dbus_service.cc b/tpm_manager/server/dbus_service.cc
index 6e1945c..5c914fe 100644
--- a/tpm_manager/server/dbus_service.cc
+++ b/tpm_manager/server/dbus_service.cc
@@ -41,103 +41,80 @@
dbus_object_.AddOrGetInterface(kTpmOwnershipInterface);
ownership_dbus_interface->AddMethodHandler(
- kGetTpmStatus,
- base::Unretained(this),
+ kGetTpmStatus, base::Unretained(this),
&DBusService::HandleOwnershipDBusMethod<
- GetTpmStatusRequest,
- GetTpmStatusReply,
+ GetTpmStatusRequest, GetTpmStatusReply,
&TpmOwnershipInterface::GetTpmStatus>);
ownership_dbus_interface->AddMethodHandler(
- kTakeOwnership,
- base::Unretained(this),
+ kTakeOwnership, base::Unretained(this),
&DBusService::HandleOwnershipDBusMethod<
- TakeOwnershipRequest,
- TakeOwnershipReply,
+ TakeOwnershipRequest, TakeOwnershipReply,
&TpmOwnershipInterface::TakeOwnership>);
ownership_dbus_interface->AddMethodHandler(
- kRemoveOwnerDependency,
- base::Unretained(this),
+ kRemoveOwnerDependency, base::Unretained(this),
&DBusService::HandleOwnershipDBusMethod<
- RemoveOwnerDependencyRequest,
- RemoveOwnerDependencyReply,
+ RemoveOwnerDependencyRequest, RemoveOwnerDependencyReply,
&TpmOwnershipInterface::RemoveOwnerDependency>);
brillo::dbus_utils::DBusInterface* nvram_dbus_interface =
dbus_object_.AddOrGetInterface(kTpmNvramInterface);
nvram_dbus_interface->AddMethodHandler(
- kDefineNvram,
- base::Unretained(this),
- &DBusService::HandleNvramDBusMethod<
- DefineNvramRequest,
- DefineNvramReply,
- &TpmNvramInterface::DefineNvram>);
+ kDefineNvram, base::Unretained(this),
+ &DBusService::HandleNvramDBusMethod<DefineNvramRequest, DefineNvramReply,
+ &TpmNvramInterface::DefineNvram>);
nvram_dbus_interface->AddMethodHandler(
- kDestroyNvram,
- base::Unretained(this),
- &DBusService::HandleNvramDBusMethod<
- DestroyNvramRequest,
- DestroyNvramReply,
- &TpmNvramInterface::DestroyNvram>);
+ kDestroyNvram, base::Unretained(this),
+ &DBusService::HandleNvramDBusMethod<DestroyNvramRequest,
+ DestroyNvramReply,
+ &TpmNvramInterface::DestroyNvram>);
nvram_dbus_interface->AddMethodHandler(
- kWriteNvram,
- base::Unretained(this),
- &DBusService::HandleNvramDBusMethod<
- WriteNvramRequest,
- WriteNvramReply,
- &TpmNvramInterface::WriteNvram>);
+ kWriteNvram, base::Unretained(this),
+ &DBusService::HandleNvramDBusMethod<WriteNvramRequest, WriteNvramReply,
+ &TpmNvramInterface::WriteNvram>);
nvram_dbus_interface->AddMethodHandler(
- kReadNvram,
- base::Unretained(this),
- &DBusService::HandleNvramDBusMethod<
- ReadNvramRequest,
- ReadNvramReply,
- &TpmNvramInterface::ReadNvram>);
+ kReadNvram, base::Unretained(this),
+ &DBusService::HandleNvramDBusMethod<ReadNvramRequest, ReadNvramReply,
+ &TpmNvramInterface::ReadNvram>);
nvram_dbus_interface->AddMethodHandler(
- kIsNvramDefined,
- base::Unretained(this),
- &DBusService::HandleNvramDBusMethod<
- IsNvramDefinedRequest,
- IsNvramDefinedReply,
- &TpmNvramInterface::IsNvramDefined>);
+ kIsNvramDefined, base::Unretained(this),
+ &DBusService::HandleNvramDBusMethod<IsNvramDefinedRequest,
+ IsNvramDefinedReply,
+ &TpmNvramInterface::IsNvramDefined>);
nvram_dbus_interface->AddMethodHandler(
- kIsNvramLocked,
- base::Unretained(this),
- &DBusService::HandleNvramDBusMethod<
- IsNvramLockedRequest,
- IsNvramLockedReply,
- &TpmNvramInterface::IsNvramLocked>);
+ kIsNvramLocked, base::Unretained(this),
+ &DBusService::HandleNvramDBusMethod<IsNvramLockedRequest,
+ IsNvramLockedReply,
+ &TpmNvramInterface::IsNvramLocked>);
nvram_dbus_interface->AddMethodHandler(
- kGetNvramSize,
- base::Unretained(this),
- &DBusService::HandleNvramDBusMethod<
- GetNvramSizeRequest,
- GetNvramSizeReply,
- &TpmNvramInterface::GetNvramSize>);
+ kGetNvramSize, base::Unretained(this),
+ &DBusService::HandleNvramDBusMethod<GetNvramSizeRequest,
+ GetNvramSizeReply,
+ &TpmNvramInterface::GetNvramSize>);
dbus_object_.RegisterAsync(callback);
}
-template<typename RequestProtobufType,
- typename ReplyProtobufType,
- DBusService::HandlerFunction<RequestProtobufType,
- ReplyProtobufType,
- TpmNvramInterface> func>
+template <typename RequestProtobufType,
+ typename ReplyProtobufType,
+ DBusService::HandlerFunction<RequestProtobufType,
+ ReplyProtobufType,
+ TpmNvramInterface> func>
void DBusService::HandleNvramDBusMethod(
std::unique_ptr<DBusMethodResponse<const ReplyProtobufType&>> response,
const RequestProtobufType& request) {
// Convert |response| to a shared_ptr so |nvram_service_| can safely copy the
// callback.
- using SharedResponsePointer = std::shared_ptr<
- DBusMethodResponse<const ReplyProtobufType&>>;
+ using SharedResponsePointer =
+ std::shared_ptr<DBusMethodResponse<const ReplyProtobufType&>>;
// A callback that sends off the reply protobuf.
auto callback = [](const SharedResponsePointer& response,
const ReplyProtobufType& reply) {
@@ -148,18 +125,18 @@
base::Bind(callback, SharedResponsePointer(std::move(response))));
}
-template<typename RequestProtobufType,
- typename ReplyProtobufType,
- DBusService::HandlerFunction<RequestProtobufType,
- ReplyProtobufType,
- TpmOwnershipInterface> func>
+template <typename RequestProtobufType,
+ typename ReplyProtobufType,
+ DBusService::HandlerFunction<RequestProtobufType,
+ ReplyProtobufType,
+ TpmOwnershipInterface> func>
void DBusService::HandleOwnershipDBusMethod(
std::unique_ptr<DBusMethodResponse<const ReplyProtobufType&>> response,
const RequestProtobufType& request) {
// Convert |response| to a shared_ptr so |ownership_service_| can safely
// copy the callback.
- using SharedResponsePointer = std::shared_ptr<
- DBusMethodResponse<const ReplyProtobufType&>>;
+ using SharedResponsePointer =
+ std::shared_ptr<DBusMethodResponse<const ReplyProtobufType&>>;
// A callback that sends off the reply protobuf.
auto callback = [](const SharedResponsePointer& response,
const ReplyProtobufType& reply) {
diff --git a/tpm_manager/server/dbus_service.h b/tpm_manager/server/dbus_service.h
index 4746310..b49cc83 100644
--- a/tpm_manager/server/dbus_service.h
+++ b/tpm_manager/server/dbus_service.h
@@ -49,28 +49,28 @@
private:
friend class DBusServiceTest;
- template<typename RequestProtobufType,
- typename ReplyProtobufType,
- typename TpmInterface>
- using HandlerFunction = void(TpmInterface::*)(
+ template <typename RequestProtobufType,
+ typename ReplyProtobufType,
+ typename TpmInterface>
+ using HandlerFunction = void (TpmInterface::*)(
const RequestProtobufType&,
const base::Callback<void(const ReplyProtobufType&)>&);
// Templates to handle D-Bus calls.
- template<typename RequestProtobufType,
- typename ReplyProtobufType,
- DBusService::HandlerFunction<RequestProtobufType,
- ReplyProtobufType,
- TpmNvramInterface> func>
+ template <typename RequestProtobufType,
+ typename ReplyProtobufType,
+ DBusService::HandlerFunction<RequestProtobufType,
+ ReplyProtobufType,
+ TpmNvramInterface> func>
void HandleNvramDBusMethod(
std::unique_ptr<DBusMethodResponse<const ReplyProtobufType&>> response,
const RequestProtobufType& request);
- template<typename RequestProtobufType,
- typename ReplyProtobufType,
- DBusService::HandlerFunction<RequestProtobufType,
- ReplyProtobufType,
- TpmOwnershipInterface> func>
+ template <typename RequestProtobufType,
+ typename ReplyProtobufType,
+ DBusService::HandlerFunction<RequestProtobufType,
+ ReplyProtobufType,
+ TpmOwnershipInterface> func>
void HandleOwnershipDBusMethod(
std::unique_ptr<DBusMethodResponse<const ReplyProtobufType&>> response,
const RequestProtobufType& request);
diff --git a/tpm_manager/server/dbus_service_test.cc b/tpm_manager/server/dbus_service_test.cc
index f4bb55f..8ba84d9 100644
--- a/tpm_manager/server/dbus_service_test.cc
+++ b/tpm_manager/server/dbus_service_test.cc
@@ -46,24 +46,23 @@
dbus::Bus::Options options;
mock_bus_ = new NiceMock<dbus::MockBus>(options);
dbus::ObjectPath path(kTpmManagerServicePath);
- mock_exported_object_ = new NiceMock<dbus::MockExportedObject>(
- mock_bus_.get(), path);
+ mock_exported_object_ =
+ new NiceMock<dbus::MockExportedObject>(mock_bus_.get(), path);
ON_CALL(*mock_bus_, GetExportedObject(path))
.WillByDefault(Return(mock_exported_object_.get()));
- dbus_service_.reset(new DBusService(mock_bus_,
- &mock_nvram_service_,
+ dbus_service_.reset(new DBusService(mock_bus_, &mock_nvram_service_,
&mock_ownership_service_));
- dbus_service_->Register(brillo::dbus_utils::AsyncEventSequencer::
- GetDefaultCompletionAction());
+ dbus_service_->Register(
+ brillo::dbus_utils::AsyncEventSequencer::GetDefaultCompletionAction());
}
- template<typename RequestProtobufType, typename ReplyProtobufType>
+ template <typename RequestProtobufType, typename ReplyProtobufType>
void ExecuteMethod(const std::string& method_name,
const RequestProtobufType& request,
ReplyProtobufType* reply,
const std::string& interface) {
- std::unique_ptr<dbus::MethodCall> call = CreateMethodCall(method_name,
- interface);
+ std::unique_ptr<dbus::MethodCall> call =
+ CreateMethodCall(method_name, interface);
dbus::MessageWriter writer(call.get());
writer.AppendProtoAsArrayOfBytes(request);
auto response = brillo::dbus_utils::testing::CallMethod(
@@ -74,9 +73,10 @@
protected:
std::unique_ptr<dbus::MethodCall> CreateMethodCall(
- const std::string& method_name, const std::string& interface) {
- std::unique_ptr<dbus::MethodCall> call(new dbus::MethodCall(
- interface, method_name));
+ const std::string& method_name,
+ const std::string& interface) {
+ std::unique_ptr<dbus::MethodCall> call(
+ new dbus::MethodCall(interface, method_name));
call->SetSerial(1);
return call;
}
@@ -90,8 +90,8 @@
TEST_F(DBusServiceTest, CopyableCallback) {
EXPECT_CALL(mock_ownership_service_, GetTpmStatus(_, _))
- .WillOnce(WithArgs<1>(Invoke([](
- const TpmOwnershipInterface::GetTpmStatusCallback& callback) {
+ .WillOnce(WithArgs<1>(Invoke(
+ [](const TpmOwnershipInterface::GetTpmStatusCallback& callback) {
// Copy the callback, then call the original.
GetTpmStatusReply reply;
base::Closure copy = base::Bind(callback, reply);
@@ -105,19 +105,19 @@
TEST_F(DBusServiceTest, GetTpmStatus) {
GetTpmStatusRequest request;
EXPECT_CALL(mock_ownership_service_, GetTpmStatus(_, _))
- .WillOnce(Invoke([](
- const GetTpmStatusRequest& request,
- const TpmOwnershipInterface::GetTpmStatusCallback& callback) {
- GetTpmStatusReply reply;
- reply.set_status(STATUS_SUCCESS);
- reply.set_enabled(true);
- reply.set_owned(true);
- reply.set_dictionary_attack_counter(3);
- reply.set_dictionary_attack_threshold(4);
- reply.set_dictionary_attack_lockout_in_effect(true);
- reply.set_dictionary_attack_lockout_seconds_remaining(5);
- callback.Run(reply);
- }));
+ .WillOnce(Invoke(
+ [](const GetTpmStatusRequest& request,
+ const TpmOwnershipInterface::GetTpmStatusCallback& callback) {
+ GetTpmStatusReply reply;
+ reply.set_status(STATUS_SUCCESS);
+ reply.set_enabled(true);
+ reply.set_owned(true);
+ reply.set_dictionary_attack_counter(3);
+ reply.set_dictionary_attack_threshold(4);
+ reply.set_dictionary_attack_lockout_in_effect(true);
+ reply.set_dictionary_attack_lockout_seconds_remaining(5);
+ callback.Run(reply);
+ }));
GetTpmStatusReply reply;
ExecuteMethod(kGetTpmStatus, request, &reply, kTpmOwnershipInterface);
EXPECT_EQ(STATUS_SUCCESS, reply.status());
@@ -131,13 +131,13 @@
TEST_F(DBusServiceTest, TakeOwnership) {
EXPECT_CALL(mock_ownership_service_, TakeOwnership(_, _))
- .WillOnce(Invoke([](
- const TakeOwnershipRequest& request,
- const TpmOwnershipInterface::TakeOwnershipCallback& callback) {
- TakeOwnershipReply reply;
- reply.set_status(STATUS_SUCCESS);
- callback.Run(reply);
- }));
+ .WillOnce(Invoke(
+ [](const TakeOwnershipRequest& request,
+ const TpmOwnershipInterface::TakeOwnershipCallback& callback) {
+ TakeOwnershipReply reply;
+ reply.set_status(STATUS_SUCCESS);
+ callback.Run(reply);
+ }));
TakeOwnershipRequest request;
TakeOwnershipReply reply;
ExecuteMethod(kTakeOwnership, request, &reply, kTpmOwnershipInterface);
@@ -151,8 +151,8 @@
EXPECT_CALL(mock_ownership_service_, RemoveOwnerDependency(_, _))
.WillOnce(Invoke([&owner_dependency](
const RemoveOwnerDependencyRequest& request,
- const TpmOwnershipInterface::RemoveOwnerDependencyCallback& callback)
- {
+ const TpmOwnershipInterface::RemoveOwnerDependencyCallback&
+ callback) {
EXPECT_TRUE(request.has_owner_dependency());
EXPECT_EQ(owner_dependency, request.owner_dependency());
RemoveOwnerDependencyReply reply;
@@ -160,9 +160,7 @@
callback.Run(reply);
}));
RemoveOwnerDependencyReply reply;
- ExecuteMethod(kRemoveOwnerDependency,
- request,
- &reply,
+ ExecuteMethod(kRemoveOwnerDependency, request, &reply,
kTpmOwnershipInterface);
EXPECT_EQ(STATUS_SUCCESS, reply.status());
}
diff --git a/tpm_manager/server/local_data_store_impl.cc b/tpm_manager/server/local_data_store_impl.cc
index 6cf8848..9851c08 100644
--- a/tpm_manager/server/local_data_store_impl.cc
+++ b/tpm_manager/server/local_data_store_impl.cc
@@ -76,7 +76,7 @@
}
// Sync the parent directory.
std::string dir_name = path.DirName().value();
- int dir_fd = HANDLE_EINTR(open(dir_name.c_str(), O_RDONLY|O_DIRECTORY));
+ int dir_fd = HANDLE_EINTR(open(dir_name.c_str(), O_RDONLY | O_DIRECTORY));
if (dir_fd < 0) {
PLOG(WARNING) << "Could not open " << dir_name << " for syncing";
return false;
diff --git a/tpm_manager/server/local_data_store_impl.h b/tpm_manager/server/local_data_store_impl.h
index b258ec3..af7cdac 100644
--- a/tpm_manager/server/local_data_store_impl.h
+++ b/tpm_manager/server/local_data_store_impl.h
@@ -38,8 +38,6 @@
DISALLOW_COPY_AND_ASSIGN(LocalDataStoreImpl);
};
-
} // namespace tpm_manager
-
#endif // TPM_MANAGER_SERVER_LOCAL_DATA_STORE_IMPL_H_
diff --git a/tpm_manager/server/main.cc b/tpm_manager/server/main.cc
index dfbe024..77632d3 100644
--- a/tpm_manager/server/main.cc
+++ b/tpm_manager/server/main.cc
@@ -54,21 +54,17 @@
#if USE_TPM2
tpm_status_.reset(new tpm_manager::Tpm2StatusImpl);
tpm_initializer_.reset(new tpm_manager::Tpm2InitializerImpl(
- local_data_store_.get(),
- tpm_status_.get()));
+ local_data_store_.get(), tpm_status_.get()));
tpm_nvram_.reset(new tpm_manager::Tpm2NvramImpl(local_data_store_.get()));
#else
tpm_status_.reset(new tpm_manager::TpmStatusImpl);
tpm_initializer_.reset(new tpm_manager::TpmInitializerImpl(
- local_data_store_.get(),
- tpm_status_.get()));
+ local_data_store_.get(), tpm_status_.get()));
tpm_nvram_.reset(new tpm_manager::TpmNvramImpl(local_data_store_.get()));
#endif
tpm_manager_service_.reset(new tpm_manager::TpmManagerService(
command_line->HasSwitch(kWaitForOwnershipTriggerSwitch),
- local_data_store_.get(),
- tpm_status_.get(),
- tpm_initializer_.get(),
+ local_data_store_.get(), tpm_status_.get(), tpm_initializer_.get(),
tpm_nvram_.get()));
}
@@ -104,7 +100,7 @@
int main(int argc, char* argv[]) {
base::CommandLine::Init(argc, argv);
- base::CommandLine *cl = base::CommandLine::ForCurrentProcess();
+ base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
int flags = brillo::kLogToSyslog;
if (cl->HasSwitch("log_to_stderr")) {
flags |= brillo::kLogToStderr;
diff --git a/tpm_manager/server/mock_openssl_crypto_util.cc b/tpm_manager/server/mock_openssl_crypto_util.cc
index e9a9d94..225d110 100644
--- a/tpm_manager/server/mock_openssl_crypto_util.cc
+++ b/tpm_manager/server/mock_openssl_crypto_util.cc
@@ -35,4 +35,3 @@
}
} // namespace tpm_manager
-
diff --git a/tpm_manager/server/tpm2_initializer_impl.cc b/tpm_manager/server/tpm2_initializer_impl.cc
index 8d30643..e2e24aa 100644
--- a/tpm_manager/server/tpm2_initializer_impl.cc
+++ b/tpm_manager/server/tpm2_initializer_impl.cc
@@ -90,7 +90,7 @@
// We write the passwords to disk, in case there is an error while taking
// ownership.
local_data.clear_owner_dependency();
- for (auto dependency: kInitialTpmOwnerDependencies) {
+ for (auto dependency : kInitialTpmOwnerDependencies) {
local_data.add_owner_dependency(dependency);
}
local_data.set_owner_password(owner_password);
@@ -115,7 +115,7 @@
return false;
}
trunks::TPM_RC result = trunks_factory_->GetTpmUtility()->StirRandom(
- random_bytes, nullptr /* No Authorization */);
+ random_bytes, nullptr /* No Authorization */);
if (result != trunks::TPM_RC_SUCCESS) {
return false;
}
@@ -125,7 +125,7 @@
bool Tpm2InitializerImpl::GetTpmRandomData(size_t num_bytes,
std::string* random_data) {
trunks::TPM_RC result = trunks_factory_->GetTpmUtility()->GenerateRandom(
- num_bytes, nullptr /* No Authorization */, random_data);
+ num_bytes, nullptr /* No Authorization */, random_data);
if (result != trunks::TPM_RC_SUCCESS) {
return false;
}
diff --git a/tpm_manager/server/tpm2_initializer_impl.h b/tpm_manager/server/tpm2_initializer_impl.h
index 964e3fb..aa217c4 100644
--- a/tpm_manager/server/tpm2_initializer_impl.h
+++ b/tpm_manager/server/tpm2_initializer_impl.h
@@ -43,8 +43,7 @@
class Tpm2InitializerImpl : public TpmInitializer {
public:
// Does not take ownership of |local_data_store| or |tpm_status|.
- Tpm2InitializerImpl(LocalDataStore* local_data_store,
- TpmStatus* tpm_status);
+ Tpm2InitializerImpl(LocalDataStore* local_data_store, TpmStatus* tpm_status);
// Does not take ownership of |openssl_util|, |local_data_store| or
// |tpm_status|. Takes ownership of |factory|.
Tpm2InitializerImpl(trunks::TrunksFactory* factory,
diff --git a/tpm_manager/server/tpm2_initializer_test.cc b/tpm_manager/server/tpm2_initializer_test.cc
index a46f27d..536ed7a 100644
--- a/tpm_manager/server/tpm2_initializer_test.cc
+++ b/tpm_manager/server/tpm2_initializer_test.cc
@@ -45,10 +45,8 @@
void SetUp() {
trunks::TrunksFactoryForTest* factory = new trunks::TrunksFactoryForTest();
factory->set_tpm_utility(&mock_tpm_utility_);
- tpm_initializer_.reset(new Tpm2InitializerImpl(factory,
- &mock_openssl_util_,
- &mock_data_store_,
- &mock_tpm_status_));
+ tpm_initializer_.reset(new Tpm2InitializerImpl(
+ factory, &mock_openssl_util_, &mock_data_store_, &mock_tpm_status_));
}
protected:
@@ -66,51 +64,40 @@
}
TEST_F(Tpm2InitializerTest, InitializeTpmAlreadyOwned) {
- EXPECT_CALL(mock_tpm_status_, IsTpmOwned())
- .WillRepeatedly(Return(true));
- EXPECT_CALL(mock_tpm_utility_, TakeOwnership(_, _, _))
- .Times(0);
+ EXPECT_CALL(mock_tpm_status_, IsTpmOwned()).WillRepeatedly(Return(true));
+ EXPECT_CALL(mock_tpm_utility_, TakeOwnership(_, _, _)).Times(0);
EXPECT_TRUE(tpm_initializer_->InitializeTpm());
}
TEST_F(Tpm2InitializerTest, InitializeTpmLocalDataReadError) {
- EXPECT_CALL(mock_tpm_status_, IsTpmOwned())
- .WillRepeatedly(Return(false));
- EXPECT_CALL(mock_data_store_, Read(_))
- .WillRepeatedly(Return(false));
- EXPECT_CALL(mock_tpm_utility_, TakeOwnership(_, _, _))
- .Times(0);
+ EXPECT_CALL(mock_tpm_status_, IsTpmOwned()).WillRepeatedly(Return(false));
+ EXPECT_CALL(mock_data_store_, Read(_)).WillRepeatedly(Return(false));
+ EXPECT_CALL(mock_tpm_utility_, TakeOwnership(_, _, _)).Times(0);
EXPECT_FALSE(tpm_initializer_->InitializeTpm());
}
TEST_F(Tpm2InitializerTest, InitializeTpmLocalDataWriteError) {
- EXPECT_CALL(mock_tpm_status_, IsTpmOwned())
- .WillRepeatedly(Return(false));
- EXPECT_CALL(mock_data_store_, Write(_))
- .WillRepeatedly(Return(false));
- EXPECT_CALL(mock_tpm_utility_, TakeOwnership(_, _, _))
- .Times(0);
+ EXPECT_CALL(mock_tpm_status_, IsTpmOwned()).WillRepeatedly(Return(false));
+ EXPECT_CALL(mock_data_store_, Write(_)).WillRepeatedly(Return(false));
+ EXPECT_CALL(mock_tpm_utility_, TakeOwnership(_, _, _)).Times(0);
EXPECT_FALSE(tpm_initializer_->InitializeTpm());
}
TEST_F(Tpm2InitializerTest, InitializeTpmOwnershipError) {
- EXPECT_CALL(mock_tpm_status_, IsTpmOwned())
- .WillOnce(Return(false));
+ EXPECT_CALL(mock_tpm_status_, IsTpmOwned()).WillOnce(Return(false));
EXPECT_CALL(mock_tpm_utility_, TakeOwnership(_, _, _))
.WillRepeatedly(Return(trunks::TPM_RC_FAILURE));
EXPECT_FALSE(tpm_initializer_->InitializeTpm());
}
TEST_F(Tpm2InitializerTest, InitializeTpmSuccess) {
- EXPECT_CALL(mock_tpm_status_, IsTpmOwned())
- .WillOnce(Return(false));
+ EXPECT_CALL(mock_tpm_status_, IsTpmOwned()).WillOnce(Return(false));
std::string owner_password;
std::string endorsement_password;
std::string lockout_password;
LocalData local_data;
EXPECT_CALL(mock_data_store_, Read(_))
- .WillOnce(DoAll(SetArgPointee<0>(local_data),
- Return(true)));
+ .WillOnce(DoAll(SetArgPointee<0>(local_data), Return(true)));
EXPECT_CALL(mock_tpm_utility_, GenerateRandom(_, _, _))
.Times(3) // Once for owner, endorsement and lockout passwords
.WillRepeatedly(Return(trunks::TPM_RC_SUCCESS));
@@ -120,8 +107,7 @@
}
TEST_F(Tpm2InitializerTest, InitializeTpmSuccessAfterError) {
- EXPECT_CALL(mock_tpm_status_, IsTpmOwned())
- .WillOnce(Return(false));
+ EXPECT_CALL(mock_tpm_status_, IsTpmOwned()).WillOnce(Return(false));
std::string owner_password("owner");
std::string endorsement_password("endorsement");
std::string lockout_password("lockout");
@@ -131,19 +117,17 @@
local_data.set_endorsement_password(endorsement_password);
local_data.set_lockout_password(lockout_password);
EXPECT_CALL(mock_data_store_, Read(_))
- .WillOnce(DoAll(SetArgPointee<0>(local_data),
- Return(true)));
+ .WillOnce(DoAll(SetArgPointee<0>(local_data), Return(true)));
EXPECT_CALL(mock_data_store_, Write(_))
- .WillOnce(DoAll(SaveArg<0>(&local_data),
- Return(true)));
+ .WillOnce(DoAll(SaveArg<0>(&local_data), Return(true)));
EXPECT_EQ(1, local_data.owner_dependency_size());
EXPECT_EQ(kTestDependency, local_data.owner_dependency(0));
EXPECT_EQ(owner_password, local_data.owner_password());
EXPECT_EQ(endorsement_password, local_data.endorsement_password());
EXPECT_EQ(lockout_password, local_data.lockout_password());
- EXPECT_CALL(mock_tpm_utility_, TakeOwnership(owner_password,
- endorsement_password,
- lockout_password))
+ EXPECT_CALL(
+ mock_tpm_utility_,
+ TakeOwnership(owner_password, endorsement_password, lockout_password))
.WillOnce(Return(trunks::TPM_RC_SUCCESS));
EXPECT_TRUE(tpm_initializer_->InitializeTpm());
}
diff --git a/tpm_manager/server/tpm2_nvram_impl.cc b/tpm_manager/server/tpm2_nvram_impl.cc
index d06bc87..bee3b54 100644
--- a/tpm_manager/server/tpm2_nvram_impl.cc
+++ b/tpm_manager/server/tpm2_nvram_impl.cc
@@ -97,8 +97,8 @@
if (!InitializeWithOwnerPassword()) {
return false;
}
- TPM_RC result = trunks_utility_->DestroyNVSpace(
- index, trunks_session_->GetDelegate());
+ TPM_RC result =
+ trunks_utility_->DestroyNVSpace(index, trunks_session_->GetDelegate());
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error destroying nvram space:" << GetErrorString(result);
return false;
@@ -110,10 +110,10 @@
if (!InitializeWithOwnerPassword()) {
return false;
}
- TPM_RC result = trunks_utility_->WriteNVSpace(index,
- 0, // offset
- data,
- trunks_session_->GetDelegate());
+ TPM_RC result =
+ trunks_utility_->WriteNVSpace(index,
+ 0, // offset
+ data, trunks_session_->GetDelegate());
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error writing to nvram space: " << GetErrorString(result);
return false;
@@ -138,8 +138,7 @@
trunks_session_->SetEntityAuthorizationValue("");
TPM_RC result = trunks_utility_->ReadNVSpace(index,
0, // offset
- nvram_size,
- data,
+ nvram_size, data,
trunks_session_->GetDelegate());
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error reading nvram space: " << GetErrorString(result);
diff --git a/tpm_manager/server/tpm2_nvram_test.cc b/tpm_manager/server/tpm2_nvram_test.cc
index 347b17a..8dc284b 100644
--- a/tpm_manager/server/tpm2_nvram_test.cc
+++ b/tpm_manager/server/tpm2_nvram_test.cc
@@ -50,16 +50,14 @@
factory->set_hmac_session(&mock_hmac_session_);
factory->set_tpm_utility(&mock_tpm_utility_);
tpm_nvram_.reset(new Tpm2NvramImpl(
- std::unique_ptr<trunks::TrunksFactory>(factory),
- &mock_data_store_));
+ std::unique_ptr<trunks::TrunksFactory>(factory), &mock_data_store_));
}
void InitializeNvram(const std::string& owner_password) {
LocalData local_data;
local_data.set_owner_password(owner_password);
ON_CALL(mock_data_store_, Read(_))
- .WillByDefault(DoAll(SetArgPointee<0>(local_data),
- Return(true)));
+ .WillByDefault(DoAll(SetArgPointee<0>(local_data), Return(true)));
tpm_nvram_->Initialize();
Mock::VerifyAndClearExpectations(&mock_data_store_);
Mock::VerifyAndClearExpectations(&mock_hmac_session_);
@@ -157,13 +155,11 @@
trunks::TPMS_NV_PUBLIC nvram_public;
nvram_public.data_size = size;
EXPECT_CALL(mock_tpm_utility_, GetNVSpacePublicArea(_, _))
- .WillOnce(DoAll(SetArgPointee<1>(nvram_public),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SetArgPointee<1>(nvram_public), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_hmac_session_, SetEntityAuthorizationValue(""));
EXPECT_CALL(mock_tpm_utility_, ReadNVSpace(index, 0, size, _, _))
- .WillOnce(DoAll(SetArgPointee<3>(tpm_data),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SetArgPointee<3>(tpm_data), Return(TPM_RC_SUCCESS)));
std::string read_data;
EXPECT_TRUE(tpm_nvram_->ReadNvram(index, &read_data));
EXPECT_EQ(read_data, tpm_data);
@@ -181,8 +177,7 @@
uint32_t index = 42;
trunks::TPMS_NV_PUBLIC nvram_public;
EXPECT_CALL(mock_tpm_utility_, GetNVSpacePublicArea(index, _))
- .WillOnce(DoAll(SetArgPointee<1>(nvram_public),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SetArgPointee<1>(nvram_public), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_utility_, ReadNVSpace(index, _, _, _, _))
.WillOnce(Return(TPM_RC_FAILURE));
std::string read_data;
@@ -220,8 +215,7 @@
trunks::TPMS_NV_PUBLIC nvram_public;
nvram_public.attributes = trunks::TPMA_NV_WRITELOCKED;
EXPECT_CALL(mock_tpm_utility_, GetNVSpacePublicArea(index, _))
- .WillOnce(DoAll(SetArgPointee<1>(nvram_public),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SetArgPointee<1>(nvram_public), Return(TPM_RC_SUCCESS)));
bool locked;
EXPECT_TRUE(tpm_nvram_->IsNvramLocked(index, &locked));
EXPECT_TRUE(locked);
@@ -232,8 +226,7 @@
trunks::TPMS_NV_PUBLIC nvram_public;
nvram_public.attributes = 0;
EXPECT_CALL(mock_tpm_utility_, GetNVSpacePublicArea(index, _))
- .WillOnce(DoAll(SetArgPointee<1>(nvram_public),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SetArgPointee<1>(nvram_public), Return(TPM_RC_SUCCESS)));
bool locked;
EXPECT_TRUE(tpm_nvram_->IsNvramLocked(index, &locked));
EXPECT_FALSE(locked);
@@ -253,8 +246,7 @@
trunks::TPMS_NV_PUBLIC nvram_public;
nvram_public.data_size = nvram_size;
EXPECT_CALL(mock_tpm_utility_, GetNVSpacePublicArea(index, _))
- .WillOnce(DoAll(SetArgPointee<1>(nvram_public),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SetArgPointee<1>(nvram_public), Return(TPM_RC_SUCCESS)));
size_t size;
EXPECT_TRUE(tpm_nvram_->GetNvramSize(index, &size));
EXPECT_EQ(size, nvram_size);
diff --git a/tpm_manager/server/tpm2_status_impl.cc b/tpm_manager/server/tpm2_status_impl.cc
index e315aed..70c8e1f 100644
--- a/tpm_manager/server/tpm2_status_impl.cc
+++ b/tpm_manager/server/tpm2_status_impl.cc
@@ -27,13 +27,13 @@
namespace tpm_manager {
Tpm2StatusImpl::Tpm2StatusImpl()
- : default_trunks_factory_(new trunks::TrunksFactoryImpl()),
- trunks_factory_(default_trunks_factory_.get()),
- trunks_tpm_state_(trunks_factory_->GetTpmState()) {}
+ : default_trunks_factory_(new trunks::TrunksFactoryImpl()),
+ trunks_factory_(default_trunks_factory_.get()),
+ trunks_tpm_state_(trunks_factory_->GetTpmState()) {}
Tpm2StatusImpl::Tpm2StatusImpl(trunks::TrunksFactory* factory)
- : trunks_factory_(factory),
- trunks_tpm_state_(trunks_factory_->GetTpmState()) {}
+ : trunks_factory_(factory),
+ trunks_tpm_state_(trunks_factory_->GetTpmState()) {}
bool Tpm2StatusImpl::IsTpmEnabled() {
if (!initialized_) {
diff --git a/tpm_manager/server/tpm2_status_test.cc b/tpm_manager/server/tpm2_status_test.cc
index a55a9c5..d758649 100644
--- a/tpm_manager/server/tpm2_status_test.cc
+++ b/tpm_manager/server/tpm2_status_test.cc
@@ -46,24 +46,20 @@
std::unique_ptr<TpmStatus> tpm_status_;
};
-
TEST_F(Tpm2StatusTest, IsEnabledSuccess) {
EXPECT_CALL(mock_tpm_state_, Initialize())
.WillRepeatedly(Return(TPM_RC_SUCCESS));
- EXPECT_CALL(mock_tpm_state_, IsEnabled())
- .WillRepeatedly(Return(true));
+ EXPECT_CALL(mock_tpm_state_, IsEnabled()).WillRepeatedly(Return(true));
EXPECT_TRUE(tpm_status_->IsTpmEnabled());
}
TEST_F(Tpm2StatusTest, IsEnabledFailure) {
- EXPECT_CALL(mock_tpm_state_, IsEnabled())
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(mock_tpm_state_, IsEnabled()).WillRepeatedly(Return(false));
EXPECT_FALSE(tpm_status_->IsTpmEnabled());
}
TEST_F(Tpm2StatusTest, IsEnabledNoRepeatedInitialization) {
- EXPECT_CALL(mock_tpm_state_, Initialize())
- .WillOnce(Return(TPM_RC_SUCCESS));
+ EXPECT_CALL(mock_tpm_state_, Initialize()).WillOnce(Return(TPM_RC_SUCCESS));
EXPECT_TRUE(tpm_status_->IsTpmEnabled());
EXPECT_TRUE(tpm_status_->IsTpmEnabled());
}
@@ -71,14 +67,12 @@
TEST_F(Tpm2StatusTest, IsOwnedSuccess) {
EXPECT_CALL(mock_tpm_state_, Initialize())
.WillRepeatedly(Return(TPM_RC_SUCCESS));
- EXPECT_CALL(mock_tpm_state_, IsOwned())
- .WillRepeatedly(Return(true));
+ EXPECT_CALL(mock_tpm_state_, IsOwned()).WillRepeatedly(Return(true));
EXPECT_TRUE(tpm_status_->IsTpmOwned());
}
TEST_F(Tpm2StatusTest, IsOwnedFailure) {
- EXPECT_CALL(mock_tpm_state_, IsOwned())
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(mock_tpm_state_, IsOwned()).WillRepeatedly(Return(false));
EXPECT_FALSE(tpm_status_->IsTpmOwned());
}
@@ -86,19 +80,15 @@
EXPECT_CALL(mock_tpm_state_, Initialize())
.Times(2)
.WillRepeatedly(Return(TPM_RC_SUCCESS));
- EXPECT_CALL(mock_tpm_state_, IsOwned())
- .WillOnce(Return(false));
+ EXPECT_CALL(mock_tpm_state_, IsOwned()).WillOnce(Return(false));
EXPECT_FALSE(tpm_status_->IsTpmOwned());
- EXPECT_CALL(mock_tpm_state_, IsOwned())
- .WillRepeatedly(Return(true));
+ EXPECT_CALL(mock_tpm_state_, IsOwned()).WillRepeatedly(Return(true));
EXPECT_TRUE(tpm_status_->IsTpmOwned());
}
TEST_F(Tpm2StatusTest, IsOwnedNoRepeatedInitializationOnTrue) {
- EXPECT_CALL(mock_tpm_state_, Initialize())
- .WillOnce(Return(TPM_RC_SUCCESS));
- EXPECT_CALL(mock_tpm_state_, IsOwned())
- .WillRepeatedly(Return(true));
+ EXPECT_CALL(mock_tpm_state_, Initialize()).WillOnce(Return(TPM_RC_SUCCESS));
+ EXPECT_CALL(mock_tpm_state_, IsOwned()).WillRepeatedly(Return(true));
EXPECT_TRUE(tpm_status_->IsTpmOwned());
EXPECT_TRUE(tpm_status_->IsTpmOwned());
}
@@ -110,10 +100,8 @@
int threshold;
bool lockout;
int seconds_remaining;
- EXPECT_FALSE(tpm_status_->GetDictionaryAttackInfo(&count,
- &threshold,
- &lockout,
- &seconds_remaining));
+ EXPECT_FALSE(tpm_status_->GetDictionaryAttackInfo(
+ &count, &threshold, &lockout, &seconds_remaining));
}
TEST_F(Tpm2StatusTest, GetDictionaryAttackInfoForwarding) {
@@ -125,17 +113,14 @@
.WillRepeatedly(Return(lockout_count));
EXPECT_CALL(mock_tpm_state_, GetLockoutThreshold())
.WillRepeatedly(Return(lockout_threshold));
- EXPECT_CALL(mock_tpm_state_, IsInLockout())
- .WillRepeatedly(Return(is_locked));
+ EXPECT_CALL(mock_tpm_state_, IsInLockout()).WillRepeatedly(Return(is_locked));
EXPECT_CALL(mock_tpm_state_, GetLockoutInterval())
.WillRepeatedly(Return(lockout_interval));
int count;
int threshold;
bool lockout;
int seconds_remaining;
- EXPECT_TRUE(tpm_status_->GetDictionaryAttackInfo(&count,
- &threshold,
- &lockout,
+ EXPECT_TRUE(tpm_status_->GetDictionaryAttackInfo(&count, &threshold, &lockout,
&seconds_remaining));
EXPECT_EQ(count, lockout_count);
EXPECT_EQ(threshold, lockout_threshold);
@@ -150,9 +135,7 @@
int threshold;
bool lockout;
int seconds_remaining;
- EXPECT_TRUE(tpm_status_->GetDictionaryAttackInfo(&count,
- &threshold,
- &lockout,
+ EXPECT_TRUE(tpm_status_->GetDictionaryAttackInfo(&count, &threshold, &lockout,
&seconds_remaining));
}
diff --git a/tpm_manager/server/tpm_connection.cc b/tpm_manager/server/tpm_connection.cc
index 2b03699..9ed8d86 100644
--- a/tpm_manager/server/tpm_connection.cc
+++ b/tpm_manager/server/tpm_connection.cc
@@ -47,8 +47,8 @@
}
TSS_RESULT result;
TSS_HTPM tpm_handle;
- if (TPM_ERROR(result = Tspi_Context_GetTpmObject(context_.value(),
- &tpm_handle))) {
+ if (TPM_ERROR(result =
+ Tspi_Context_GetTpmObject(context_.value(), &tpm_handle))) {
TPM_LOG(ERROR, result) << "Error getting a handle to the TPM.";
return 0;
}
@@ -62,17 +62,16 @@
}
TSS_RESULT result;
TSS_HPOLICY tpm_usage_policy;
- if (TPM_ERROR(result = Tspi_GetPolicyObject(tpm_handle,
- TSS_POLICY_USAGE,
+ if (TPM_ERROR(result = Tspi_GetPolicyObject(tpm_handle, TSS_POLICY_USAGE,
&tpm_usage_policy))) {
TPM_LOG(ERROR, result) << "Error calling Tspi_GetPolicyObject";
return false;
}
if (TPM_ERROR(result = Tspi_Policy_SetSecret(
- tpm_usage_policy,
- TSS_SECRET_MODE_PLAIN,
- owner_password.size(),
- reinterpret_cast<BYTE *>(const_cast<char*>(owner_password.data()))))) {
+ tpm_usage_policy, TSS_SECRET_MODE_PLAIN,
+ owner_password.size(),
+ reinterpret_cast<BYTE*>(
+ const_cast<char*>(owner_password.data()))))) {
TPM_LOG(ERROR, result) << "Error calling Tspi_Policy_SetSecret";
return false;
}
diff --git a/tpm_manager/server/tpm_initializer_impl.cc b/tpm_manager/server/tpm_initializer_impl.cc
index 4e72eb0..4fed91e 100644
--- a/tpm_manager/server/tpm_initializer_impl.cc
+++ b/tpm_manager/server/tpm_initializer_impl.cc
@@ -41,8 +41,7 @@
TpmInitializerImpl::TpmInitializerImpl(LocalDataStore* local_data_store,
TpmStatus* tpm_status)
- : local_data_store_(local_data_store),
- tpm_status_(tpm_status) {}
+ : local_data_store_(local_data_store), tpm_status_(tpm_status) {}
bool TpmInitializerImpl::InitializeTpm() {
if (tpm_status_->IsTpmOwned() && !TestTpmAuth(kDefaultOwnerPassword)) {
@@ -54,8 +53,7 @@
if (tpm_handle == 0) {
return false;
}
- if (!InitializeEndorsementKey(tpm_handle) ||
- !TakeOwnership(tpm_handle) ||
+ if (!InitializeEndorsementKey(tpm_handle) || !TakeOwnership(tpm_handle) ||
!InitializeSrk(tpm_handle)) {
return false;
}
@@ -65,7 +63,7 @@
}
LocalData local_data;
local_data.clear_owner_dependency();
- for (auto value: kInitialTpmOwnerDependencies) {
+ for (auto value : kInitialTpmOwnerDependencies) {
local_data.add_owner_dependency(value);
}
local_data.set_owner_password(owner_password);
@@ -81,9 +79,7 @@
bool TpmInitializerImpl::InitializeEndorsementKey(TSS_HTPM tpm_handle) {
trousers::ScopedTssKey local_key_handle(tpm_connection_.GetContext());
- TSS_RESULT result = Tspi_TPM_GetPubEndorsementKey(tpm_handle,
- false,
- nullptr,
+ TSS_RESULT result = Tspi_TPM_GetPubEndorsementKey(tpm_handle, false, nullptr,
local_key_handle.ptr());
if (TPM_ERROR(result) == TPM_SUCCESS) {
// In this case the EK already exists, so we can return true here.
@@ -91,16 +87,14 @@
}
// At this point the EK does not exist, so we create it.
TSS_FLAG init_flags = TSS_KEY_TYPE_LEGACY | TSS_KEY_SIZE_2048;
- if (TPM_ERROR(result = Tspi_Context_CreateObject(tpm_connection_.GetContext(),
- TSS_OBJECT_TYPE_RSAKEY,
- init_flags,
- local_key_handle.ptr()))) {
+ if (TPM_ERROR(result = Tspi_Context_CreateObject(
+ tpm_connection_.GetContext(), TSS_OBJECT_TYPE_RSAKEY,
+ init_flags, local_key_handle.ptr()))) {
TPM_LOG(ERROR, result) << "Error calling Tspi_Context_CreateObject";
return false;
}
- if (TPM_ERROR(result = Tspi_TPM_CreateEndorsementKey(tpm_handle,
- local_key_handle,
- NULL))) {
+ if (TPM_ERROR(result = Tspi_TPM_CreateEndorsementKey(
+ tpm_handle, local_key_handle, NULL))) {
TPM_LOG(ERROR, result) << "Error calling Tspi_TPM_CreateEndorsementKey";
return false;
}
@@ -115,26 +109,23 @@
TSS_RESULT result;
trousers::ScopedTssKey srk_handle(tpm_connection_.GetContext());
TSS_FLAG init_flags = TSS_KEY_TSP_SRK | TSS_KEY_AUTHORIZATION;
- if (TPM_ERROR(result = Tspi_Context_CreateObject(tpm_connection_.GetContext(),
- TSS_OBJECT_TYPE_RSAKEY,
- init_flags,
- srk_handle.ptr()))) {
+ if (TPM_ERROR(result = Tspi_Context_CreateObject(
+ tpm_connection_.GetContext(), TSS_OBJECT_TYPE_RSAKEY,
+ init_flags, srk_handle.ptr()))) {
TPM_LOG(ERROR, result) << "Error calling Tspi_Context_CreateObject";
return false;
}
TSS_HPOLICY srk_usage_policy;
- if (TPM_ERROR(result = Tspi_GetPolicyObject(srk_handle,
- TSS_POLICY_USAGE,
+ if (TPM_ERROR(result = Tspi_GetPolicyObject(srk_handle, TSS_POLICY_USAGE,
&srk_usage_policy))) {
TPM_LOG(ERROR, result) << "Error calling Tspi_GetPolicyObject";
return false;
}
if (TPM_ERROR(result = Tspi_Policy_SetSecret(
- srk_usage_policy,
- TSS_SECRET_MODE_PLAIN,
- strlen(kWellKnownSrkSecret),
- const_cast<BYTE *>(reinterpret_cast<const BYTE *>(
- kWellKnownSrkSecret))))) {
+ srk_usage_policy, TSS_SECRET_MODE_PLAIN,
+ strlen(kWellKnownSrkSecret),
+ const_cast<BYTE*>(
+ reinterpret_cast<const BYTE*>(kWellKnownSrkSecret))))) {
TPM_LOG(ERROR, result) << "Error calling Tspi_Policy_SetSecret";
return false;
}
@@ -152,8 +143,8 @@
(result == (TSS_LAYER_TDDL | TDDL_E_IOERROR))) &&
(retry_count < kMaxOwnershipTimeoutRetries));
if (result) {
- TPM_LOG(ERROR, result)
- << "Error calling Tspi_TPM_TakeOwnership, attempts: " << retry_count;
+ TPM_LOG(ERROR, result) << "Error calling Tspi_TPM_TakeOwnership, attempts: "
+ << retry_count;
return false;
}
return true;
@@ -164,34 +155,28 @@
trousers::ScopedTssKey srk_handle(tpm_connection_.GetContext());
TSS_UUID SRK_UUID = TSS_UUID_SRK;
if (TPM_ERROR(result = Tspi_Context_LoadKeyByUUID(
- tpm_connection_.GetContext(),
- TSS_PS_TYPE_SYSTEM,
- SRK_UUID,
- srk_handle.ptr()))) {
+ tpm_connection_.GetContext(), TSS_PS_TYPE_SYSTEM, SRK_UUID,
+ srk_handle.ptr()))) {
TPM_LOG(ERROR, result) << "Error calling Tspi_Context_LoadKeyByUUID";
return false;
}
trousers::ScopedTssPolicy policy_handle(tpm_connection_.GetContext());
- if (TPM_ERROR(result = Tspi_Context_CreateObject(tpm_connection_.GetContext(),
- TSS_OBJECT_TYPE_POLICY,
- TSS_POLICY_USAGE,
- policy_handle.ptr()))) {
+ if (TPM_ERROR(result = Tspi_Context_CreateObject(
+ tpm_connection_.GetContext(), TSS_OBJECT_TYPE_POLICY,
+ TSS_POLICY_USAGE, policy_handle.ptr()))) {
TPM_LOG(ERROR, result) << "Error calling Tspi_Context_CreateObject";
return false;
}
BYTE new_password[0];
- if (TPM_ERROR(result = Tspi_Policy_SetSecret(policy_handle,
- TSS_SECRET_MODE_PLAIN,
- 0,
- new_password))) {
+ if (TPM_ERROR(result = Tspi_Policy_SetSecret(
+ policy_handle, TSS_SECRET_MODE_PLAIN, 0, new_password))) {
TPM_LOG(ERROR, result) << "Error calling Tspi_Policy_SetSecret";
return false;
}
- if (TPM_ERROR(result = Tspi_ChangeAuth(srk_handle,
- tpm_handle,
- policy_handle))) {
+ if (TPM_ERROR(result =
+ Tspi_ChangeAuth(srk_handle, tpm_handle, policy_handle))) {
TPM_LOG(ERROR, result) << "Error calling Tspi_ChangeAuth";
return false;
}
@@ -204,9 +189,8 @@
}
// If the SRK is restricted, we unrestrict it.
if (is_srk_restricted) {
- if (TPM_ERROR(result = Tspi_TPM_SetStatus(tpm_handle,
- TSS_TPMSTATUS_DISABLEPUBSRKREAD,
- false))) {
+ if (TPM_ERROR(result = Tspi_TPM_SetStatus(
+ tpm_handle, TSS_TPMSTATUS_DISABLEPUBSRKREAD, false))) {
TPM_LOG(ERROR, result) << "Error calling Tspi_TPM_SetStatus";
return false;
}
@@ -215,21 +199,21 @@
}
bool TpmInitializerImpl::ChangeOwnerPassword(
- TSS_HTPM tpm_handle, const std::string& owner_password) {
+ TSS_HTPM tpm_handle,
+ const std::string& owner_password) {
TSS_RESULT result;
trousers::ScopedTssPolicy policy_handle(tpm_connection_.GetContext());
- if (TPM_ERROR(result = Tspi_Context_CreateObject(tpm_connection_.GetContext(),
- TSS_OBJECT_TYPE_POLICY,
- TSS_POLICY_USAGE,
- policy_handle.ptr()))) {
+ if (TPM_ERROR(result = Tspi_Context_CreateObject(
+ tpm_connection_.GetContext(), TSS_OBJECT_TYPE_POLICY,
+ TSS_POLICY_USAGE, policy_handle.ptr()))) {
TPM_LOG(ERROR, result) << "Error calling Tspi_Context_CreateObject";
return false;
}
std::string mutable_owner_password(owner_password);
- if (TPM_ERROR(result = Tspi_Policy_SetSecret(policy_handle,
- TSS_SECRET_MODE_PLAIN,
- owner_password.size(),
- reinterpret_cast<BYTE *>(string_as_array(&mutable_owner_password))))) {
+ if (TPM_ERROR(result = Tspi_Policy_SetSecret(
+ policy_handle, TSS_SECRET_MODE_PLAIN, owner_password.size(),
+ reinterpret_cast<BYTE*>(
+ string_as_array(&mutable_owner_password))))) {
TPM_LOG(ERROR, result) << "Error calling Tspi_Policy_SetSecret";
return false;
}
@@ -250,8 +234,7 @@
// Call Tspi_TPM_GetStatus to test the |owner_password| provided.
TSS_RESULT result;
TSS_BOOL current_status = false;
- if (TPM_ERROR(result = Tspi_TPM_GetStatus(tpm_handle,
- TSS_TPMSTATUS_DISABLED,
+ if (TPM_ERROR(result = Tspi_TPM_GetStatus(tpm_handle, TSS_TPMSTATUS_DISABLED,
¤t_status))) {
return false;
}
diff --git a/tpm_manager/server/tpm_initializer_impl.h b/tpm_manager/server/tpm_initializer_impl.h
index b7b995c..3e8df17 100644
--- a/tpm_manager/server/tpm_initializer_impl.h
+++ b/tpm_manager/server/tpm_initializer_impl.h
@@ -44,8 +44,7 @@
class TpmInitializerImpl : public TpmInitializer {
public:
// Does not take ownership of |local_data_store| or |tpm_status|.
- TpmInitializerImpl(LocalDataStore* local_data_store,
- TpmStatus* tpm_status);
+ TpmInitializerImpl(LocalDataStore* local_data_store, TpmStatus* tpm_status);
~TpmInitializerImpl() override = default;
// TpmInitializer methods.
diff --git a/tpm_manager/server/tpm_manager_service.cc b/tpm_manager/server/tpm_manager_service.cc
index 522792b..2c410e7 100644
--- a/tpm_manager/server/tpm_manager_service.cc
+++ b/tpm_manager/server/tpm_manager_service.cc
@@ -39,8 +39,8 @@
worker_thread_.reset(new base::Thread("TpmManager Service Worker"));
worker_thread_->StartWithOptions(
base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
- base::Closure task = base::Bind(&TpmManagerService::InitializeTask,
- base::Unretained(this));
+ base::Closure task =
+ base::Bind(&TpmManagerService::InitializeTask, base::Unretained(this));
worker_thread_->task_runner()->PostNonNestableTask(FROM_HERE, task);
return true;
}
@@ -136,7 +136,8 @@
}
void TpmManagerService::RemoveOwnerDependency(
- const std::string& owner_dependency, LocalData* local_data) {
+ const std::string& owner_dependency,
+ LocalData* local_data) {
google::protobuf::RepeatedPtrField<std::string>* dependencies =
local_data->mutable_owner_dependency();
for (int i = 0; i < dependencies->size(); i++) {
@@ -155,8 +156,8 @@
void TpmManagerService::DefineNvram(const DefineNvramRequest& request,
const DefineNvramCallback& callback) {
- PostTaskToWorkerThread<DefineNvramReply>(
- request, callback, &TpmManagerService::DefineNvramTask);
+ PostTaskToWorkerThread<DefineNvramReply>(request, callback,
+ &TpmManagerService::DefineNvramTask);
}
void TpmManagerService::DefineNvramTask(
@@ -189,8 +190,8 @@
void TpmManagerService::WriteNvram(const WriteNvramRequest& request,
const WriteNvramCallback& callback) {
- PostTaskToWorkerThread<WriteNvramReply>(
- request, callback, &TpmManagerService::WriteNvramTask);
+ PostTaskToWorkerThread<WriteNvramReply>(request, callback,
+ &TpmManagerService::WriteNvramTask);
}
void TpmManagerService::WriteNvramTask(
@@ -206,8 +207,8 @@
void TpmManagerService::ReadNvram(const ReadNvramRequest& request,
const ReadNvramCallback& callback) {
- PostTaskToWorkerThread<ReadNvramReply>(
- request, callback, &TpmManagerService::ReadNvramTask);
+ PostTaskToWorkerThread<ReadNvramReply>(request, callback,
+ &TpmManagerService::ReadNvramTask);
}
void TpmManagerService::ReadNvramTask(
@@ -278,32 +279,27 @@
result->set_status(STATUS_SUCCESS);
}
-template<typename ReplyProtobufType>
+template <typename ReplyProtobufType>
void TpmManagerService::TaskRelayCallback(
const base::Callback<void(const ReplyProtobufType&)> callback,
const std::shared_ptr<ReplyProtobufType>& reply) {
callback.Run(*reply);
}
-template<typename ReplyProtobufType,
- typename RequestProtobufType,
- typename ReplyCallbackType,
- typename TaskType>
+template <typename ReplyProtobufType,
+ typename RequestProtobufType,
+ typename ReplyCallbackType,
+ typename TaskType>
void TpmManagerService::PostTaskToWorkerThread(RequestProtobufType& request,
ReplyCallbackType& callback,
TaskType task) {
auto result = std::make_shared<ReplyProtobufType>();
- base::Closure background_task = base::Bind(task,
- base::Unretained(this),
- request,
- result);
- base::Closure reply = base::Bind(
- &TpmManagerService::TaskRelayCallback<ReplyProtobufType>,
- weak_factory_.GetWeakPtr(),
- callback,
- result);
- worker_thread_->task_runner()->PostTaskAndReply(FROM_HERE,
- background_task,
+ base::Closure background_task =
+ base::Bind(task, base::Unretained(this), request, result);
+ base::Closure reply =
+ base::Bind(&TpmManagerService::TaskRelayCallback<ReplyProtobufType>,
+ weak_factory_.GetWeakPtr(), callback, result);
+ worker_thread_->task_runner()->PostTaskAndReply(FROM_HERE, background_task,
reply);
}
diff --git a/tpm_manager/server/tpm_manager_service.h b/tpm_manager/server/tpm_manager_service.h
index b644a14..12672cb 100644
--- a/tpm_manager/server/tpm_manager_service.h
+++ b/tpm_manager/server/tpm_manager_service.h
@@ -97,7 +97,7 @@
private:
// A relay callback which allows the use of weak pointer semantics for a reply
// to TaskRunner::PostTaskAndReply.
- template<typename ReplyProtobufType>
+ template <typename ReplyProtobufType>
void TaskRelayCallback(
const base::Callback<void(const ReplyProtobufType&)> callback,
const std::shared_ptr<ReplyProtobufType>& reply);
@@ -105,10 +105,10 @@
// This templated method posts the provided |TaskType| to the background
// thread with the provided |RequestProtobufType|. When |TaskType| finishes
// executing, the |ReplyCallbackType| is called with the |ReplyProtobufType|.
- template<typename ReplyProtobufType,
- typename RequestProtobufType,
- typename ReplyCallbackType,
- typename TaskType>
+ template <typename ReplyProtobufType,
+ typename RequestProtobufType,
+ typename ReplyCallbackType,
+ typename TaskType>
void PostTaskToWorkerThread(RequestProtobufType& request,
ReplyCallbackType& callback,
TaskType task);
diff --git a/tpm_manager/server/tpm_manager_service_test.cc b/tpm_manager/server/tpm_manager_service_test.cc
index 63e4c70..9d720df 100644
--- a/tpm_manager/server/tpm_manager_service_test.cc
+++ b/tpm_manager/server/tpm_manager_service_test.cc
@@ -37,7 +37,6 @@
const char kOwnerPassword[] = "owner";
const char kOwnerDependency[] = "owner_dependency";
const char kOtherDependency[] = "other_dependency";
-
}
namespace tpm_manager {
@@ -48,37 +47,27 @@
public:
~TpmManagerServiceTest() override = default;
void SetUp() override {
- service_.reset(new TpmManagerService(true /*wait_for_ownership*/,
- &mock_local_data_store_,
- &mock_tpm_status_,
- &mock_tpm_initializer_,
- &mock_tpm_nvram_));
+ service_.reset(new TpmManagerService(
+ true /*wait_for_ownership*/, &mock_local_data_store_, &mock_tpm_status_,
+ &mock_tpm_initializer_, &mock_tpm_nvram_));
SetupService();
}
protected:
- void Run() {
- run_loop_.Run();
- }
+ void Run() { run_loop_.Run(); }
void RunServiceWorkerAndQuit() {
// Run out the service worker loop by posting a new command and waiting for
// the response.
- auto callback = [this](const GetTpmStatusReply& reply) {
- Quit();
- };
+ auto callback = [this](const GetTpmStatusReply& reply) { Quit(); };
GetTpmStatusRequest request;
service_->GetTpmStatus(request, base::Bind(callback));
Run();
}
- void Quit() {
- run_loop_.Quit();
- }
+ void Quit() { run_loop_.Quit(); }
- void SetupService() {
- CHECK(service_->Initialize());
- }
+ void SetupService() { CHECK(service_->Initialize()); }
NiceMock<MockLocalDataStore> mock_local_data_store_;
NiceMock<MockTpmInitializer> mock_tpm_initializer_;
@@ -96,11 +85,9 @@
public:
~TpmManagerServiceTest_NoWaitForOwnership() override = default;
void SetUp() override {
- service_.reset(new TpmManagerService(false /*wait_for_ownership*/,
- &mock_local_data_store_,
- &mock_tpm_status_,
- &mock_tpm_initializer_,
- &mock_tpm_nvram_));
+ service_.reset(new TpmManagerService(
+ false /*wait_for_ownership*/, &mock_local_data_store_,
+ &mock_tpm_status_, &mock_tpm_initializer_, &mock_tpm_nvram_));
}
};
@@ -175,8 +162,7 @@
}
TEST_F(TpmManagerServiceTest, GetTpmStatusLocalDataFailure) {
- EXPECT_CALL(mock_local_data_store_, Read(_))
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(mock_local_data_store_, Read(_)).WillRepeatedly(Return(false));
auto callback = [this](const GetTpmStatusReply& reply) {
EXPECT_EQ(STATUS_SUCCESS, reply.status());
EXPECT_TRUE(reply.enabled());
@@ -249,8 +235,7 @@
}
TEST_F(TpmManagerServiceTest, RemoveOwnerDependencyReadFailure) {
- EXPECT_CALL(mock_local_data_store_, Read(_))
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(mock_local_data_store_, Read(_)).WillRepeatedly(Return(false));
auto callback = [this](const RemoveOwnerDependencyReply& reply) {
EXPECT_EQ(STATUS_UNEXPECTED_DEVICE_ERROR, reply.status());
Quit();
@@ -262,8 +247,7 @@
}
TEST_F(TpmManagerServiceTest, RemoveOwnerDependencyWriteFailure) {
- EXPECT_CALL(mock_local_data_store_, Write(_))
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(mock_local_data_store_, Write(_)).WillRepeatedly(Return(false));
auto callback = [this](const RemoveOwnerDependencyReply& reply) {
EXPECT_EQ(STATUS_UNEXPECTED_DEVICE_ERROR, reply.status());
Quit();
@@ -280,11 +264,9 @@
local_data.add_owner_dependency(kOwnerDependency);
local_data.add_owner_dependency(kOtherDependency);
EXPECT_CALL(mock_local_data_store_, Read(_))
- .WillOnce(DoAll(SetArgPointee<0>(local_data),
- Return(true)));
+ .WillOnce(DoAll(SetArgPointee<0>(local_data), Return(true)));
EXPECT_CALL(mock_local_data_store_, Write(_))
- .WillOnce(DoAll(SaveArg<0>(&local_data),
- Return(true)));
+ .WillOnce(DoAll(SaveArg<0>(&local_data), Return(true)));
auto callback = [this, &local_data](const RemoveOwnerDependencyReply& reply) {
EXPECT_EQ(STATUS_SUCCESS, reply.status());
EXPECT_EQ(1, local_data.owner_dependency_size());
@@ -304,11 +286,9 @@
local_data.set_owner_password(kOwnerPassword);
local_data.add_owner_dependency(kOwnerDependency);
EXPECT_CALL(mock_local_data_store_, Read(_))
- .WillOnce(DoAll(SetArgPointee<0>(local_data),
- Return(true)));
+ .WillOnce(DoAll(SetArgPointee<0>(local_data), Return(true)));
EXPECT_CALL(mock_local_data_store_, Write(_))
- .WillOnce(DoAll(SaveArg<0>(&local_data),
- Return(true)));
+ .WillOnce(DoAll(SaveArg<0>(&local_data), Return(true)));
auto callback = [this, &local_data](const RemoveOwnerDependencyReply& reply) {
EXPECT_EQ(STATUS_SUCCESS, reply.status());
EXPECT_EQ(0, local_data.owner_dependency_size());
@@ -326,11 +306,9 @@
local_data.set_owner_password(kOwnerPassword);
local_data.add_owner_dependency(kOwnerDependency);
EXPECT_CALL(mock_local_data_store_, Read(_))
- .WillOnce(DoAll(SetArgPointee<0>(local_data),
- Return(true)));
+ .WillOnce(DoAll(SetArgPointee<0>(local_data), Return(true)));
EXPECT_CALL(mock_local_data_store_, Write(_))
- .WillOnce(DoAll(SaveArg<0>(&local_data),
- Return(true)));
+ .WillOnce(DoAll(SaveArg<0>(&local_data), Return(true)));
auto callback = [this, &local_data](const RemoveOwnerDependencyReply& reply) {
EXPECT_EQ(STATUS_SUCCESS, reply.status());
EXPECT_EQ(1, local_data.owner_dependency_size());
diff --git a/tpm_manager/server/tpm_nvram_impl.cc b/tpm_manager/server/tpm_nvram_impl.cc
index 598959a..d9a61a9 100644
--- a/tpm_manager/server/tpm_nvram_impl.cc
+++ b/tpm_manager/server/tpm_nvram_impl.cc
@@ -54,22 +54,22 @@
return false;
}
TSS_RESULT result;
- result = Tspi_SetAttribUint32(nv_handle, TSS_TSPATTRIB_NV_DATASIZE,
- 0, length);
+ result =
+ Tspi_SetAttribUint32(nv_handle, TSS_TSPATTRIB_NV_DATASIZE, 0, length);
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << "Could not set size on NVRAM object: " << length;
return false;
}
// Restrict to only one write.
- result = Tspi_SetAttribUint32(nv_handle, TSS_TSPATTRIB_NV_PERMISSIONS,
- 0, TPM_NV_PER_WRITEDEFINE);
+ result = Tspi_SetAttribUint32(nv_handle, TSS_TSPATTRIB_NV_PERMISSIONS, 0,
+ TPM_NV_PER_WRITEDEFINE);
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << "Could not set PER_WRITEDEFINE on NVRAM object";
return false;
}
// Restrict to writing only with owner authorization.
- result = Tspi_SetAttribUint32(nv_handle, TSS_TSPATTRIB_NV_PERMISSIONS,
- 0, TPM_NV_PER_OWNERWRITE);
+ result = Tspi_SetAttribUint32(nv_handle, TSS_TSPATTRIB_NV_PERMISSIONS, 0,
+ TPM_NV_PER_OWNERWRITE);
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << "Could not set PER_OWNERWRITE on NVRAM object";
return false;
@@ -118,7 +118,7 @@
}
TSS_RESULT result = Tspi_NV_WriteValue(
nv_handle, 0 /* offset */, data.size(),
- reinterpret_cast<BYTE *>(const_cast<char*>(data.data())));
+ reinterpret_cast<BYTE*>(const_cast<char*>(data.data())));
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << "Could not write to NVRAM space: " << index;
return false;
@@ -155,10 +155,8 @@
return false;
}
CHECK_LE((offset + chunk_size), data->size());
- data->replace(offset,
- chunk_size,
- reinterpret_cast<char*>(space_data.value()),
- chunk_size);
+ data->replace(offset, chunk_size,
+ reinterpret_cast<char*>(space_data.value()), chunk_size);
offset += chunk_size;
}
return true;
@@ -168,12 +166,9 @@
CHECK(defined);
uint32_t nv_list_data_length = 0;
ScopedTssMemory nv_list_data(tpm_connection_.GetContext());
- TSS_RESULT result = Tspi_TPM_GetCapability(tpm_connection_.GetTpm(),
- TSS_TPMCAP_NV_LIST,
- 0,
- NULL,
- &nv_list_data_length,
- nv_list_data.ptr());
+ TSS_RESULT result =
+ Tspi_TPM_GetCapability(tpm_connection_.GetTpm(), TSS_TPMCAP_NV_LIST, 0,
+ NULL, &nv_list_data_length, nv_list_data.ptr());
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << "Error calling Tspi_TPM_GetCapability";
return false;
@@ -196,12 +191,10 @@
CHECK(locked);
uint32_t nv_index_data_length = 0;
ScopedTssMemory nv_index_data(tpm_connection_.GetContext());
- TSS_RESULT result = Tspi_TPM_GetCapability(tpm_connection_.GetTpm(),
- TSS_TPMCAP_NV_INDEX,
- sizeof(index),
- reinterpret_cast<BYTE*>(&index),
- &nv_index_data_length,
- nv_index_data.ptr());
+ TSS_RESULT result =
+ Tspi_TPM_GetCapability(tpm_connection_.GetTpm(), TSS_TPMCAP_NV_INDEX,
+ sizeof(index), reinterpret_cast<BYTE*>(&index),
+ &nv_index_data_length, nv_index_data.ptr());
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << "Error calling Tspi_TPM_GetCapability";
return false;
@@ -211,9 +204,9 @@
}
// TPM_NV_DATA_PUBLIC->bWriteDefine is the second to last element in the
// struct.
- uint32_t* nv_data_public = reinterpret_cast<uint32_t*>(
- nv_index_data.value() + nv_index_data_length -
- (sizeof(uint32_t) + sizeof(TPM_BOOL)));
+ uint32_t* nv_data_public =
+ reinterpret_cast<uint32_t*>(nv_index_data.value() + nv_index_data_length -
+ (sizeof(uint32_t) + sizeof(TPM_BOOL)));
*locked = (*nv_data_public != 0);
return true;
}
@@ -222,12 +215,10 @@
CHECK(size);
UINT32 nv_index_data_length = 0;
ScopedTssMemory nv_index_data(tpm_connection_.GetContext());
- TSS_RESULT result = Tspi_TPM_GetCapability(tpm_connection_.GetTpm(),
- TSS_TPMCAP_NV_INDEX,
- sizeof(index),
- reinterpret_cast<BYTE*>(&index),
- &nv_index_data_length,
- nv_index_data.ptr());
+ TSS_RESULT result =
+ Tspi_TPM_GetCapability(tpm_connection_.GetTpm(), TSS_TPMCAP_NV_INDEX,
+ sizeof(index), reinterpret_cast<BYTE*>(&index),
+ &nv_index_data_length, nv_index_data.ptr());
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << "Error calling Tspi_TPM_GetCapability";
return false;
@@ -237,25 +228,21 @@
}
// TPM_NV_DATA_PUBLIC->dataSize is the last element in the struct.
uint32_t* nv_data_public = reinterpret_cast<uint32_t*>(
- nv_index_data.value() + nv_index_data_length -
- sizeof(uint32_t));
+ nv_index_data.value() + nv_index_data_length - sizeof(uint32_t));
*size = htonl(*nv_data_public);
return true;
}
bool TpmNvramImpl::InitializeNvramHandle(ScopedTssNvStore* nv_handle,
uint32_t index) {
-
- TSS_RESULT result = Tspi_Context_CreateObject(tpm_connection_.GetContext(),
- TSS_OBJECT_TYPE_NV,
- 0,
- nv_handle->ptr());
+ TSS_RESULT result = Tspi_Context_CreateObject(
+ tpm_connection_.GetContext(), TSS_OBJECT_TYPE_NV, 0, nv_handle->ptr());
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << "Could not acquire an NVRAM object handle";
return false;
}
- result = Tspi_SetAttribUint32(
- nv_handle->value(), TSS_TSPATTRIB_NV_INDEX, 0, index);
+ result = Tspi_SetAttribUint32(nv_handle->value(), TSS_TSPATTRIB_NV_INDEX, 0,
+ index);
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << "Could not set index on NVRAM object: " << index;
return false;
@@ -267,8 +254,7 @@
trousers::ScopedTssPolicy policy_handle(tpm_connection_.GetContext());
TSS_RESULT result;
result = Tspi_Context_CreateObject(tpm_connection_.GetContext(),
- TSS_OBJECT_TYPE_POLICY,
- TSS_POLICY_USAGE,
+ TSS_OBJECT_TYPE_POLICY, TSS_POLICY_USAGE,
policy_handle.ptr());
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << "Error calling Tspi_Context_CreateObject";
@@ -279,16 +265,14 @@
return false;
}
result = Tspi_Policy_SetSecret(
- policy_handle,
- TSS_SECRET_MODE_PLAIN,
- owner_password.size(),
- reinterpret_cast<BYTE *>(const_cast<char*>(owner_password.data())));
+ policy_handle, TSS_SECRET_MODE_PLAIN, owner_password.size(),
+ reinterpret_cast<BYTE*>(const_cast<char*>(owner_password.data())));
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << "Error calling Tspi_Policy_SetSecret";
return false;
}
- result = Tspi_Policy_AssignToObject(policy_handle.value(),
- nv_handle->value());
+ result =
+ Tspi_Policy_AssignToObject(policy_handle.value(), nv_handle->value());
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << "Could not set NVRAM object policy.";
return false;
@@ -297,10 +281,9 @@
}
bool TpmNvramImpl::SetCompositePcr0(ScopedTssPcrs* pcr_handle) {
- TSS_RESULT result = Tspi_Context_CreateObject(tpm_connection_.GetContext(),
- TSS_OBJECT_TYPE_PCRS,
- TSS_PCRS_STRUCT_INFO_SHORT,
- pcr_handle->ptr());
+ TSS_RESULT result = Tspi_Context_CreateObject(
+ tpm_connection_.GetContext(), TSS_OBJECT_TYPE_PCRS,
+ TSS_PCRS_STRUCT_INFO_SHORT, pcr_handle->ptr());
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << "Could not acquire PCR object handle";
return false;
@@ -312,23 +295,19 @@
}
ScopedTssMemory pcr_value(tpm_connection_.GetContext());
result = Tspi_TPM_PcrRead(tpm_connection_.GetTpmWithAuth(owner_password),
- kTpmBootPCR,
- &pcr_len,
- pcr_value.ptr());
+ kTpmBootPCR, &pcr_len, pcr_value.ptr());
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << "Could not read PCR0 value";
return false;
}
- result = Tspi_PcrComposite_SetPcrValue(pcr_handle->value(),
- kTpmBootPCR,
- pcr_len,
- pcr_value.value());
+ result = Tspi_PcrComposite_SetPcrValue(pcr_handle->value(), kTpmBootPCR,
+ pcr_len, pcr_value.value());
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << "Could not set value for PCR0 in PCR handle";
return false;
}
- result = Tspi_PcrComposite_SetPcrLocality(pcr_handle->value(),
- kTpmPCRLocality);
+ result =
+ Tspi_PcrComposite_SetPcrLocality(pcr_handle->value(), kTpmPCRLocality);
if (TPM_ERROR(result)) {
TPM_LOG(ERROR, result) << "Could not set locality for PCR0 in PCR handle";
return false;
diff --git a/tpm_manager/server/tpm_status_impl.cc b/tpm_manager/server/tpm_status_impl.cc
index 588f68c..5a9da2d 100644
--- a/tpm_manager/server/tpm_status_impl.cc
+++ b/tpm_manager/server/tpm_status_impl.cc
@@ -46,8 +46,8 @@
bool* lockout,
int* seconds_remaining) {
std::string capability_data;
- if (!GetCapability(TSS_TPMCAP_DA_LOGIC, TPM_ET_KEYHANDLE,
- &capability_data, nullptr) ||
+ if (!GetCapability(TSS_TPMCAP_DA_LOGIC, TPM_ET_KEYHANDLE, &capability_data,
+ nullptr) ||
capability_data.size() < kMinimumDaInfoSize) {
LOG(ERROR) << "Error getting tpm capability data.";
return false;
@@ -57,10 +57,18 @@
uint64_t offset = 0;
std::vector<BYTE> bytes(capability_data.begin(), capability_data.end());
Trspi_UnloadBlob_DA_INFO(&offset, bytes.data(), &da_info);
- if (counter) { *counter = da_info.currentCount; }
- if (threshold) { *threshold = da_info.thresholdCount; }
- if (lockout) { *lockout = (da_info.state == TPM_DA_STATE_ACTIVE); }
- if (seconds_remaining) { *seconds_remaining = da_info.actionDependValue; }
+ if (counter) {
+ *counter = da_info.currentCount;
+ }
+ if (threshold) {
+ *threshold = da_info.thresholdCount;
+ }
+ if (lockout) {
+ *lockout = (da_info.state == TPM_DA_STATE_ACTIVE);
+ }
+ if (seconds_remaining) {
+ *seconds_remaining = da_info.actionDependValue;
+ }
}
return true;
}
@@ -100,8 +108,7 @@
trousers::ScopedTssMemory buf(tpm_connection_.GetContext());
TSS_RESULT result = Tspi_TPM_GetCapability(
tpm_handle, capability, sizeof(uint32_t),
- reinterpret_cast<BYTE*>(&sub_capability),
- &length, buf.ptr());
+ reinterpret_cast<BYTE*>(&sub_capability), &length, buf.ptr());
if (tpm_result) {
*tpm_result = result;
}
diff --git a/tpm_manager/server/tpm_util.h b/tpm_manager/server/tpm_util.h
index 64721c2..8823d92 100644
--- a/tpm_manager/server/tpm_util.h
+++ b/tpm_manager/server/tpm_util.h
@@ -19,9 +19,9 @@
namespace tpm_manager {
-#define TPM_LOG(severity, result) \
- LOG(severity) << "TPM error 0x" << std::hex << result \
- << " (" << Trspi_Error_String(result) << "): "
+#define TPM_LOG(severity, result) \
+ LOG(severity) << "TPM error 0x" << std::hex << result << " (" \
+ << Trspi_Error_String(result) << "): "
} // namespace tpm_manager
diff --git a/tpm_manager/tpm_manager_testrunner.cc b/tpm_manager/tpm_manager_testrunner.cc
index 2aac479..f769727 100644
--- a/tpm_manager/tpm_manager_testrunner.cc
+++ b/tpm_manager/tpm_manager_testrunner.cc
@@ -20,7 +20,7 @@
#include <brillo/syslog_logging.h>
#include <gtest/gtest.h>
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
base::CommandLine::Init(argc, argv);
brillo::InitLog(brillo::kLogToStderr);
// Enable verbose logging while running unit tests.
diff --git a/trunks/background_command_transceiver.cc b/trunks/background_command_transceiver.cc
index aa18000..7748649 100644
--- a/trunks/background_command_transceiver.cc
+++ b/trunks/background_command_transceiver.cc
@@ -60,17 +60,14 @@
const std::string& command,
const ResponseCallback& callback) {
if (task_runner_.get()) {
- ResponseCallback background_callback = base::Bind(
- PostCallbackToTaskRunner,
- callback,
- base::ThreadTaskRunnerHandle::Get());
+ ResponseCallback background_callback =
+ base::Bind(PostCallbackToTaskRunner, callback,
+ base::ThreadTaskRunnerHandle::Get());
// Use SendCommandTask instead of binding to next_transceiver_ directly to
// leverage weak pointer semantics.
- base::Closure task = base::Bind(
- &BackgroundCommandTransceiver::SendCommandTask,
- GetWeakPtr(),
- command,
- background_callback);
+ base::Closure task =
+ base::Bind(&BackgroundCommandTransceiver::SendCommandTask, GetWeakPtr(),
+ command, background_callback);
task_runner_->PostNonNestableTask(FROM_HERE, task);
} else {
next_transceiver_->SendCommand(command, callback);
@@ -87,11 +84,9 @@
base::Bind(&AssignAndSignal, &response, &response_ready);
// Use SendCommandTask instead of binding to next_transceiver_ directly to
// leverage weak pointer semantics.
- base::Closure task = base::Bind(
- &BackgroundCommandTransceiver::SendCommandTask,
- GetWeakPtr(),
- command,
- callback);
+ base::Closure task =
+ base::Bind(&BackgroundCommandTransceiver::SendCommandTask, GetWeakPtr(),
+ command, callback);
task_runner_->PostNonNestableTask(FROM_HERE, task);
response_ready.Wait();
return response;
diff --git a/trunks/background_command_transceiver.h b/trunks/background_command_transceiver.h
index 99fb76e..fca4ed3 100644
--- a/trunks/background_command_transceiver.h
+++ b/trunks/background_command_transceiver.h
@@ -39,7 +39,7 @@
// background_thread.message_loop_proxy());
// ...
// background_transceiver.SendCommand(my_command, MyCallback);
-class TRUNKS_EXPORT BackgroundCommandTransceiver: public CommandTransceiver {
+class TRUNKS_EXPORT BackgroundCommandTransceiver : public CommandTransceiver {
public:
// All commands will be forwarded to |next_transceiver| on |task_runner|,
// regardless of whether the synchronous or asynchronous method is used. This
diff --git a/trunks/background_command_transceiver_test.cc b/trunks/background_command_transceiver_test.cc
index 125eed3..8b7174a 100644
--- a/trunks/background_command_transceiver_test.cc
+++ b/trunks/background_command_transceiver_test.cc
@@ -79,8 +79,7 @@
TEST_F(BackgroundTransceiverTest, Asynchronous) {
trunks::BackgroundCommandTransceiver background_transceiver(
- &next_transceiver_,
- test_thread_.task_runner());
+ &next_transceiver_, test_thread_.task_runner());
std::string output = "not_assigned";
background_transceiver.SendCommand("test", base::Bind(Assign, &output));
do {
@@ -93,14 +92,12 @@
TEST_F(BackgroundTransceiverTest, Synchronous) {
trunks::BackgroundCommandTransceiver background_transceiver(
- &next_transceiver_,
- test_thread_.task_runner());
+ &next_transceiver_, test_thread_.task_runner());
std::string output = "not_assigned";
// Post a synchronous call to be run when we start pumping the loop.
message_loop_.PostTask(FROM_HERE,
base::Bind(SendCommandAndWaitAndAssign,
- &background_transceiver,
- &output));
+ &background_transceiver, &output));
base::RunLoop run_loop;
run_loop.RunUntilIdle();
// The call to our mock should have happened on the background thread.
diff --git a/trunks/blob_parser.cc b/trunks/blob_parser.cc
index 71f2014..186b27c 100644
--- a/trunks/blob_parser.cc
+++ b/trunks/blob_parser.cc
@@ -85,7 +85,7 @@
return false;
}
result = Serialize_TPMT_TK_CREATION(creation_ticket, creation_blob);
- if (result != TPM_RC_SUCCESS) {
+ if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error serializing creation_ticket: "
<< GetErrorString(result);
return false;
@@ -104,8 +104,8 @@
return false;
}
std::string mutable_creation_blob = creation_blob;
- TPM_RC result = Parse_TPM2B_CREATION_DATA(&mutable_creation_blob,
- creation_data, nullptr);
+ TPM_RC result =
+ Parse_TPM2B_CREATION_DATA(&mutable_creation_blob, creation_data, nullptr);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error parsing creation_data: " << GetErrorString(result);
return false;
@@ -115,8 +115,8 @@
LOG(ERROR) << "Error parsing creation_hash: " << GetErrorString(result);
return false;
}
- result = Parse_TPMT_TK_CREATION(&mutable_creation_blob,
- creation_ticket, nullptr);
+ result =
+ Parse_TPMT_TK_CREATION(&mutable_creation_blob, creation_ticket, nullptr);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error parsing creation_ticket: " << GetErrorString(result);
return false;
diff --git a/trunks/command_transceiver.h b/trunks/command_transceiver.h
index 00e4bef..1683b23 100644
--- a/trunks/command_transceiver.h
+++ b/trunks/command_transceiver.h
@@ -35,9 +35,8 @@
// |callback| will be called with the |response| data from the TPM. If a
// transmission error occurs |callback| will be called with a well-formed
// error |response|.
- virtual void SendCommand(
- const std::string& command,
- const ResponseCallback& callback) = 0;
+ virtual void SendCommand(const std::string& command,
+ const ResponseCallback& callback) = 0;
// Sends a TPM |command| synchronously (i.e. waits for a response) and returns
// the response. If a transmission error occurs the response will be populated
diff --git a/trunks/error_codes.cc b/trunks/error_codes.cc
index 0f04576..9458c41 100644
--- a/trunks/error_codes.cc
+++ b/trunks/error_codes.cc
@@ -32,149 +32,270 @@
// Returns a known error code or the empty string if unknown.
std::string GetErrorStringInternal(trunks::TPM_RC error) {
switch (error) {
- case trunks::TPM_RC_SUCCESS: return "TPM_RC_SUCCESS";
- case trunks::TPM_RC_BAD_TAG: return "TPM_RC_BAD_TAG";
- case trunks::TPM_RC_INITIALIZE: return "TPM_RC_INITIALIZE";
- case trunks::TPM_RC_FAILURE: return "TPM_RC_FAILURE";
- case trunks::TPM_RC_SEQUENCE: return "TPM_RC_SEQUENCE";
- case trunks::TPM_RC_PRIVATE: return "TPM_RC_PRIVATE";
- case trunks::TPM_RC_HMAC: return "TPM_RC_HMAC";
- case trunks::TPM_RC_DISABLED: return "TPM_RC_DISABLED";
- case trunks::TPM_RC_EXCLUSIVE: return "TPM_RC_EXCLUSIVE";
- case trunks::TPM_RC_AUTH_TYPE: return "TPM_RC_AUTH_TYPE";
- case trunks::TPM_RC_AUTH_MISSING: return "TPM_RC_AUTH_MISSING";
- case trunks::TPM_RC_POLICY: return "TPM_RC_POLICY";
- case trunks::TPM_RC_PCR: return "TPM_RC_PCR";
- case trunks::TPM_RC_PCR_CHANGED: return "TPM_RC_PCR_CHANGED";
- case trunks::TPM_RC_UPGRADE: return "TPM_RC_UPGRADE";
- case trunks::TPM_RC_TOO_MANY_CONTEXTS: return "TPM_RC_TOO_MANY_CONTEXTS";
- case trunks::TPM_RC_AUTH_UNAVAILABLE: return "TPM_RC_AUTH_UNAVAILABLE";
- case trunks::TPM_RC_REBOOT: return "TPM_RC_REBOOT";
- case trunks::TPM_RC_UNBALANCED: return "TPM_RC_UNBALANCED";
- case trunks::TPM_RC_COMMAND_SIZE: return "TPM_RC_COMMAND_SIZE";
- case trunks::TPM_RC_COMMAND_CODE: return "TPM_RC_COMMAND_CODE";
- case trunks::TPM_RC_AUTHSIZE: return "TPM_RC_AUTHSIZE";
- case trunks::TPM_RC_AUTH_CONTEXT: return "TPM_RC_AUTH_CONTEXT";
- case trunks::TPM_RC_NV_RANGE: return "TPM_RC_NV_RANGE";
- case trunks::TPM_RC_NV_SIZE: return "TPM_RC_NV_SIZE";
- case trunks::TPM_RC_NV_LOCKED: return "TPM_RC_NV_LOCKED";
- case trunks::TPM_RC_NV_AUTHORIZATION: return "TPM_RC_NV_AUTHORIZATION";
- case trunks::TPM_RC_NV_UNINITIALIZED: return "TPM_RC_NV_UNINITIALIZED";
- case trunks::TPM_RC_NV_SPACE: return "TPM_RC_NV_SPACE";
- case trunks::TPM_RC_NV_DEFINED: return "TPM_RC_NV_DEFINED";
- case trunks::TPM_RC_BAD_CONTEXT: return "TPM_RC_BAD_CONTEXT";
- case trunks::TPM_RC_CPHASH: return "TPM_RC_CPHASH";
- case trunks::TPM_RC_PARENT: return "TPM_RC_PARENT";
- case trunks::TPM_RC_NEEDS_TEST: return "TPM_RC_NEEDS_TEST";
- case trunks::TPM_RC_NO_RESULT: return "TPM_RC_NO_RESULT";
- case trunks::TPM_RC_SENSITIVE: return "TPM_RC_SENSITIVE";
- case trunks::TPM_RC_ASYMMETRIC: return "TPM_RC_ASYMMETRIC";
- case trunks::TPM_RC_ATTRIBUTES: return "TPM_RC_ATTRIBUTES";
- case trunks::TPM_RC_HASH: return "TPM_RC_HASH";
- case trunks::TPM_RC_VALUE: return "TPM_RC_VALUE";
- case trunks::TPM_RC_HIERARCHY: return "TPM_RC_HIERARCHY";
- case trunks::TPM_RC_KEY_SIZE: return "TPM_RC_KEY_SIZE";
- case trunks::TPM_RC_MGF: return "TPM_RC_MGF";
- case trunks::TPM_RC_MODE: return "TPM_RC_MODE";
- case trunks::TPM_RC_TYPE: return "TPM_RC_TYPE";
- case trunks::TPM_RC_HANDLE: return "TPM_RC_HANDLE";
- case trunks::TPM_RC_KDF: return "TPM_RC_KDF";
- case trunks::TPM_RC_RANGE: return "TPM_RC_RANGE";
- case trunks::TPM_RC_AUTH_FAIL: return "TPM_RC_AUTH_FAIL";
- case trunks::TPM_RC_NONCE: return "TPM_RC_NONCE";
- case trunks::TPM_RC_PP: return "TPM_RC_PP";
- case trunks::TPM_RC_SCHEME: return "TPM_RC_SCHEME";
- case trunks::TPM_RC_SIZE: return "TPM_RC_SIZE";
- case trunks::TPM_RC_SYMMETRIC: return "TPM_RC_SYMMETRIC";
- case trunks::TPM_RC_TAG: return "TPM_RC_TAG";
- case trunks::TPM_RC_SELECTOR: return "TPM_RC_SELECTOR";
- case trunks::TPM_RC_INSUFFICIENT: return "TPM_RC_INSUFFICIENT";
- case trunks::TPM_RC_SIGNATURE: return "TPM_RC_SIGNATURE";
- case trunks::TPM_RC_KEY: return "TPM_RC_KEY";
- case trunks::TPM_RC_POLICY_FAIL: return "TPM_RC_POLICY_FAIL";
- case trunks::TPM_RC_INTEGRITY: return "TPM_RC_INTEGRITY";
- case trunks::TPM_RC_TICKET: return "TPM_RC_TICKET";
- case trunks::TPM_RC_RESERVED_BITS: return "TPM_RC_RESERVED_BITS";
- case trunks::TPM_RC_BAD_AUTH: return "TPM_RC_BAD_AUTH";
- case trunks::TPM_RC_EXPIRED: return "TPM_RC_EXPIRED";
- case trunks::TPM_RC_POLICY_CC: return "TPM_RC_POLICY_CC";
- case trunks::TPM_RC_BINDING: return "TPM_RC_BINDING";
- case trunks::TPM_RC_CURVE: return "TPM_RC_CURVE";
- case trunks::TPM_RC_ECC_POINT: return "TPM_RC_ECC_POINT";
- case trunks::TPM_RC_CONTEXT_GAP: return "TPM_RC_CONTEXT_GAP";
- case trunks::TPM_RC_OBJECT_MEMORY: return "TPM_RC_OBJECT_MEMORY";
- case trunks::TPM_RC_SESSION_MEMORY: return "TPM_RC_SESSION_MEMORY";
- case trunks::TPM_RC_MEMORY: return "TPM_RC_MEMORY";
- case trunks::TPM_RC_SESSION_HANDLES: return "TPM_RC_SESSION_HANDLES";
- case trunks::TPM_RC_OBJECT_HANDLES: return "TPM_RC_OBJECT_HANDLES";
- case trunks::TPM_RC_LOCALITY: return "TPM_RC_LOCALITY";
- case trunks::TPM_RC_YIELDED: return "TPM_RC_YIELDED";
- case trunks::TPM_RC_CANCELED: return "TPM_RC_CANCELED";
- case trunks::TPM_RC_TESTING: return "TPM_RC_TESTING";
- case trunks::TPM_RC_REFERENCE_H0: return "TPM_RC_REFERENCE_H0";
- case trunks::TPM_RC_REFERENCE_H1: return "TPM_RC_REFERENCE_H1";
- case trunks::TPM_RC_REFERENCE_H2: return "TPM_RC_REFERENCE_H2";
- case trunks::TPM_RC_REFERENCE_H3: return "TPM_RC_REFERENCE_H3";
- case trunks::TPM_RC_REFERENCE_H4: return "TPM_RC_REFERENCE_H4";
- case trunks::TPM_RC_REFERENCE_H5: return "TPM_RC_REFERENCE_H5";
- case trunks::TPM_RC_REFERENCE_H6: return "TPM_RC_REFERENCE_H6";
- case trunks::TPM_RC_REFERENCE_S0: return "TPM_RC_REFERENCE_S0";
- case trunks::TPM_RC_REFERENCE_S1: return "TPM_RC_REFERENCE_S1";
- case trunks::TPM_RC_REFERENCE_S2: return "TPM_RC_REFERENCE_S2";
- case trunks::TPM_RC_REFERENCE_S3: return "TPM_RC_REFERENCE_S3";
- case trunks::TPM_RC_REFERENCE_S4: return "TPM_RC_REFERENCE_S4";
- case trunks::TPM_RC_REFERENCE_S5: return "TPM_RC_REFERENCE_S5";
- case trunks::TPM_RC_REFERENCE_S6: return "TPM_RC_REFERENCE_S6";
- case trunks::TPM_RC_NV_RATE: return "TPM_RC_NV_RATE";
- case trunks::TPM_RC_LOCKOUT: return "TPM_RC_LOCKOUT";
- case trunks::TPM_RC_RETRY: return "TPM_RC_RETRY";
- case trunks::TPM_RC_NV_UNAVAILABLE: return "TPM_RC_NV_UNAVAILABLE";
- case trunks::TPM_RC_NOT_USED: return "TPM_RC_NOT_USED";
+ case trunks::TPM_RC_SUCCESS:
+ return "TPM_RC_SUCCESS";
+ case trunks::TPM_RC_BAD_TAG:
+ return "TPM_RC_BAD_TAG";
+ case trunks::TPM_RC_INITIALIZE:
+ return "TPM_RC_INITIALIZE";
+ case trunks::TPM_RC_FAILURE:
+ return "TPM_RC_FAILURE";
+ case trunks::TPM_RC_SEQUENCE:
+ return "TPM_RC_SEQUENCE";
+ case trunks::TPM_RC_PRIVATE:
+ return "TPM_RC_PRIVATE";
+ case trunks::TPM_RC_HMAC:
+ return "TPM_RC_HMAC";
+ case trunks::TPM_RC_DISABLED:
+ return "TPM_RC_DISABLED";
+ case trunks::TPM_RC_EXCLUSIVE:
+ return "TPM_RC_EXCLUSIVE";
+ case trunks::TPM_RC_AUTH_TYPE:
+ return "TPM_RC_AUTH_TYPE";
+ case trunks::TPM_RC_AUTH_MISSING:
+ return "TPM_RC_AUTH_MISSING";
+ case trunks::TPM_RC_POLICY:
+ return "TPM_RC_POLICY";
+ case trunks::TPM_RC_PCR:
+ return "TPM_RC_PCR";
+ case trunks::TPM_RC_PCR_CHANGED:
+ return "TPM_RC_PCR_CHANGED";
+ case trunks::TPM_RC_UPGRADE:
+ return "TPM_RC_UPGRADE";
+ case trunks::TPM_RC_TOO_MANY_CONTEXTS:
+ return "TPM_RC_TOO_MANY_CONTEXTS";
+ case trunks::TPM_RC_AUTH_UNAVAILABLE:
+ return "TPM_RC_AUTH_UNAVAILABLE";
+ case trunks::TPM_RC_REBOOT:
+ return "TPM_RC_REBOOT";
+ case trunks::TPM_RC_UNBALANCED:
+ return "TPM_RC_UNBALANCED";
+ case trunks::TPM_RC_COMMAND_SIZE:
+ return "TPM_RC_COMMAND_SIZE";
+ case trunks::TPM_RC_COMMAND_CODE:
+ return "TPM_RC_COMMAND_CODE";
+ case trunks::TPM_RC_AUTHSIZE:
+ return "TPM_RC_AUTHSIZE";
+ case trunks::TPM_RC_AUTH_CONTEXT:
+ return "TPM_RC_AUTH_CONTEXT";
+ case trunks::TPM_RC_NV_RANGE:
+ return "TPM_RC_NV_RANGE";
+ case trunks::TPM_RC_NV_SIZE:
+ return "TPM_RC_NV_SIZE";
+ case trunks::TPM_RC_NV_LOCKED:
+ return "TPM_RC_NV_LOCKED";
+ case trunks::TPM_RC_NV_AUTHORIZATION:
+ return "TPM_RC_NV_AUTHORIZATION";
+ case trunks::TPM_RC_NV_UNINITIALIZED:
+ return "TPM_RC_NV_UNINITIALIZED";
+ case trunks::TPM_RC_NV_SPACE:
+ return "TPM_RC_NV_SPACE";
+ case trunks::TPM_RC_NV_DEFINED:
+ return "TPM_RC_NV_DEFINED";
+ case trunks::TPM_RC_BAD_CONTEXT:
+ return "TPM_RC_BAD_CONTEXT";
+ case trunks::TPM_RC_CPHASH:
+ return "TPM_RC_CPHASH";
+ case trunks::TPM_RC_PARENT:
+ return "TPM_RC_PARENT";
+ case trunks::TPM_RC_NEEDS_TEST:
+ return "TPM_RC_NEEDS_TEST";
+ case trunks::TPM_RC_NO_RESULT:
+ return "TPM_RC_NO_RESULT";
+ case trunks::TPM_RC_SENSITIVE:
+ return "TPM_RC_SENSITIVE";
+ case trunks::TPM_RC_ASYMMETRIC:
+ return "TPM_RC_ASYMMETRIC";
+ case trunks::TPM_RC_ATTRIBUTES:
+ return "TPM_RC_ATTRIBUTES";
+ case trunks::TPM_RC_HASH:
+ return "TPM_RC_HASH";
+ case trunks::TPM_RC_VALUE:
+ return "TPM_RC_VALUE";
+ case trunks::TPM_RC_HIERARCHY:
+ return "TPM_RC_HIERARCHY";
+ case trunks::TPM_RC_KEY_SIZE:
+ return "TPM_RC_KEY_SIZE";
+ case trunks::TPM_RC_MGF:
+ return "TPM_RC_MGF";
+ case trunks::TPM_RC_MODE:
+ return "TPM_RC_MODE";
+ case trunks::TPM_RC_TYPE:
+ return "TPM_RC_TYPE";
+ case trunks::TPM_RC_HANDLE:
+ return "TPM_RC_HANDLE";
+ case trunks::TPM_RC_KDF:
+ return "TPM_RC_KDF";
+ case trunks::TPM_RC_RANGE:
+ return "TPM_RC_RANGE";
+ case trunks::TPM_RC_AUTH_FAIL:
+ return "TPM_RC_AUTH_FAIL";
+ case trunks::TPM_RC_NONCE:
+ return "TPM_RC_NONCE";
+ case trunks::TPM_RC_PP:
+ return "TPM_RC_PP";
+ case trunks::TPM_RC_SCHEME:
+ return "TPM_RC_SCHEME";
+ case trunks::TPM_RC_SIZE:
+ return "TPM_RC_SIZE";
+ case trunks::TPM_RC_SYMMETRIC:
+ return "TPM_RC_SYMMETRIC";
+ case trunks::TPM_RC_TAG:
+ return "TPM_RC_TAG";
+ case trunks::TPM_RC_SELECTOR:
+ return "TPM_RC_SELECTOR";
+ case trunks::TPM_RC_INSUFFICIENT:
+ return "TPM_RC_INSUFFICIENT";
+ case trunks::TPM_RC_SIGNATURE:
+ return "TPM_RC_SIGNATURE";
+ case trunks::TPM_RC_KEY:
+ return "TPM_RC_KEY";
+ case trunks::TPM_RC_POLICY_FAIL:
+ return "TPM_RC_POLICY_FAIL";
+ case trunks::TPM_RC_INTEGRITY:
+ return "TPM_RC_INTEGRITY";
+ case trunks::TPM_RC_TICKET:
+ return "TPM_RC_TICKET";
+ case trunks::TPM_RC_RESERVED_BITS:
+ return "TPM_RC_RESERVED_BITS";
+ case trunks::TPM_RC_BAD_AUTH:
+ return "TPM_RC_BAD_AUTH";
+ case trunks::TPM_RC_EXPIRED:
+ return "TPM_RC_EXPIRED";
+ case trunks::TPM_RC_POLICY_CC:
+ return "TPM_RC_POLICY_CC";
+ case trunks::TPM_RC_BINDING:
+ return "TPM_RC_BINDING";
+ case trunks::TPM_RC_CURVE:
+ return "TPM_RC_CURVE";
+ case trunks::TPM_RC_ECC_POINT:
+ return "TPM_RC_ECC_POINT";
+ case trunks::TPM_RC_CONTEXT_GAP:
+ return "TPM_RC_CONTEXT_GAP";
+ case trunks::TPM_RC_OBJECT_MEMORY:
+ return "TPM_RC_OBJECT_MEMORY";
+ case trunks::TPM_RC_SESSION_MEMORY:
+ return "TPM_RC_SESSION_MEMORY";
+ case trunks::TPM_RC_MEMORY:
+ return "TPM_RC_MEMORY";
+ case trunks::TPM_RC_SESSION_HANDLES:
+ return "TPM_RC_SESSION_HANDLES";
+ case trunks::TPM_RC_OBJECT_HANDLES:
+ return "TPM_RC_OBJECT_HANDLES";
+ case trunks::TPM_RC_LOCALITY:
+ return "TPM_RC_LOCALITY";
+ case trunks::TPM_RC_YIELDED:
+ return "TPM_RC_YIELDED";
+ case trunks::TPM_RC_CANCELED:
+ return "TPM_RC_CANCELED";
+ case trunks::TPM_RC_TESTING:
+ return "TPM_RC_TESTING";
+ case trunks::TPM_RC_REFERENCE_H0:
+ return "TPM_RC_REFERENCE_H0";
+ case trunks::TPM_RC_REFERENCE_H1:
+ return "TPM_RC_REFERENCE_H1";
+ case trunks::TPM_RC_REFERENCE_H2:
+ return "TPM_RC_REFERENCE_H2";
+ case trunks::TPM_RC_REFERENCE_H3:
+ return "TPM_RC_REFERENCE_H3";
+ case trunks::TPM_RC_REFERENCE_H4:
+ return "TPM_RC_REFERENCE_H4";
+ case trunks::TPM_RC_REFERENCE_H5:
+ return "TPM_RC_REFERENCE_H5";
+ case trunks::TPM_RC_REFERENCE_H6:
+ return "TPM_RC_REFERENCE_H6";
+ case trunks::TPM_RC_REFERENCE_S0:
+ return "TPM_RC_REFERENCE_S0";
+ case trunks::TPM_RC_REFERENCE_S1:
+ return "TPM_RC_REFERENCE_S1";
+ case trunks::TPM_RC_REFERENCE_S2:
+ return "TPM_RC_REFERENCE_S2";
+ case trunks::TPM_RC_REFERENCE_S3:
+ return "TPM_RC_REFERENCE_S3";
+ case trunks::TPM_RC_REFERENCE_S4:
+ return "TPM_RC_REFERENCE_S4";
+ case trunks::TPM_RC_REFERENCE_S5:
+ return "TPM_RC_REFERENCE_S5";
+ case trunks::TPM_RC_REFERENCE_S6:
+ return "TPM_RC_REFERENCE_S6";
+ case trunks::TPM_RC_NV_RATE:
+ return "TPM_RC_NV_RATE";
+ case trunks::TPM_RC_LOCKOUT:
+ return "TPM_RC_LOCKOUT";
+ case trunks::TPM_RC_RETRY:
+ return "TPM_RC_RETRY";
+ case trunks::TPM_RC_NV_UNAVAILABLE:
+ return "TPM_RC_NV_UNAVAILABLE";
+ case trunks::TPM_RC_NOT_USED:
+ return "TPM_RC_NOT_USED";
case trunks::TRUNKS_RC_AUTHORIZATION_FAILED:
return "TRUNKS_RC_AUTHORIZATION_FAILED";
case trunks::TRUNKS_RC_ENCRYPTION_FAILED:
return "TRUNKS_RC_ENCRYPTION_FAILED";
- case trunks::TRUNKS_RC_READ_ERROR: return "TRUNKS_RC_READ_ERROR";
- case trunks::TRUNKS_RC_WRITE_ERROR: return "TRUNKS_RC_WRITE_ERROR";
- case trunks::TRUNKS_RC_IPC_ERROR: return "TRUNKS_RC_IPC_ERROR";
+ case trunks::TRUNKS_RC_READ_ERROR:
+ return "TRUNKS_RC_READ_ERROR";
+ case trunks::TRUNKS_RC_WRITE_ERROR:
+ return "TRUNKS_RC_WRITE_ERROR";
+ case trunks::TRUNKS_RC_IPC_ERROR:
+ return "TRUNKS_RC_IPC_ERROR";
case trunks::TRUNKS_RC_SESSION_SETUP_ERROR:
return "TRUNKS_RC_SESSION_SETUP_ERROR";
- case trunks::TCTI_RC_TRY_AGAIN: return "TCTI_RC_TRY_AGAIN";
- case trunks::TCTI_RC_GENERAL_FAILURE: return "TCTI_RC_GENERAL_FAILURE";
- case trunks::TCTI_RC_BAD_CONTEXT: return "TCTI_RC_BAD_CONTEXT";
- case trunks::TCTI_RC_WRONG_ABI_VERSION: return "TCTI_RC_WRONG_ABI_VERSION";
- case trunks::TCTI_RC_NOT_IMPLEMENTED: return "TCTI_RC_NOT_IMPLEMENTED";
- case trunks::TCTI_RC_BAD_PARAMETER: return "TCTI_RC_BAD_PARAMETER";
+ case trunks::TCTI_RC_TRY_AGAIN:
+ return "TCTI_RC_TRY_AGAIN";
+ case trunks::TCTI_RC_GENERAL_FAILURE:
+ return "TCTI_RC_GENERAL_FAILURE";
+ case trunks::TCTI_RC_BAD_CONTEXT:
+ return "TCTI_RC_BAD_CONTEXT";
+ case trunks::TCTI_RC_WRONG_ABI_VERSION:
+ return "TCTI_RC_WRONG_ABI_VERSION";
+ case trunks::TCTI_RC_NOT_IMPLEMENTED:
+ return "TCTI_RC_NOT_IMPLEMENTED";
+ case trunks::TCTI_RC_BAD_PARAMETER:
+ return "TCTI_RC_BAD_PARAMETER";
case trunks::TCTI_RC_INSUFFICIENT_BUFFER:
return "TCTI_RC_INSUFFICIENT_BUFFER";
- case trunks::TCTI_RC_NO_CONNECTION: return "TCTI_RC_NO_CONNECTION";
- case trunks::TCTI_RC_DRIVER_NOT_FOUND: return "TCTI_RC_DRIVER_NOT_FOUND";
+ case trunks::TCTI_RC_NO_CONNECTION:
+ return "TCTI_RC_NO_CONNECTION";
+ case trunks::TCTI_RC_DRIVER_NOT_FOUND:
+ return "TCTI_RC_DRIVER_NOT_FOUND";
case trunks::TCTI_RC_DRIVERINFO_NOT_FOUND:
return "TCTI_RC_DRIVERINFO_NOT_FOUND";
- case trunks::TCTI_RC_NO_RESPONSE: return "TCTI_RC_NO_RESPONSE";
- case trunks::TCTI_RC_BAD_VALUE: return "TCTI_RC_BAD_VALUE";
- case trunks::SAPI_RC_INVALID_SESSIONS: return "SAPI_RC_INVALID_SESSIONS";
- case trunks::SAPI_RC_ABI_MISMATCH: return "SAPI_RC_ABI_MISMATCH";
+ case trunks::TCTI_RC_NO_RESPONSE:
+ return "TCTI_RC_NO_RESPONSE";
+ case trunks::TCTI_RC_BAD_VALUE:
+ return "TCTI_RC_BAD_VALUE";
+ case trunks::SAPI_RC_INVALID_SESSIONS:
+ return "SAPI_RC_INVALID_SESSIONS";
+ case trunks::SAPI_RC_ABI_MISMATCH:
+ return "SAPI_RC_ABI_MISMATCH";
case trunks::SAPI_RC_INSUFFICIENT_BUFFER:
return "SAPI_RC_INSUFFICIENT_BUFFER";
- case trunks::SAPI_RC_BAD_PARAMETER: return "SAPI_RC_BAD_PARAMETER";
- case trunks::SAPI_RC_BAD_SEQUENCE: return "SAPI_RC_BAD_SEQUENCE";
- case trunks::SAPI_RC_NO_DECRYPT_PARAM: return "SAPI_RC_NO_DECRYPT_PARAM";
- case trunks::SAPI_RC_NO_ENCRYPT_PARAM: return "SAPI_RC_NO_ENCRYPT_PARAM";
+ case trunks::SAPI_RC_BAD_PARAMETER:
+ return "SAPI_RC_BAD_PARAMETER";
+ case trunks::SAPI_RC_BAD_SEQUENCE:
+ return "SAPI_RC_BAD_SEQUENCE";
+ case trunks::SAPI_RC_NO_DECRYPT_PARAM:
+ return "SAPI_RC_NO_DECRYPT_PARAM";
+ case trunks::SAPI_RC_NO_ENCRYPT_PARAM:
+ return "SAPI_RC_NO_ENCRYPT_PARAM";
case trunks::SAPI_RC_NO_RESPONSE_RECEIVED:
return "SAPI_RC_NO_RESPONSE_RECEIVED";
- case trunks::SAPI_RC_BAD_SIZE: return "SAPI_RC_BAD_SIZE";
- case trunks::SAPI_RC_CORRUPTED_DATA: return "SAPI_RC_CORRUPTED_DATA";
+ case trunks::SAPI_RC_BAD_SIZE:
+ return "SAPI_RC_BAD_SIZE";
+ case trunks::SAPI_RC_CORRUPTED_DATA:
+ return "SAPI_RC_CORRUPTED_DATA";
case trunks::SAPI_RC_INSUFFICIENT_CONTEXT:
return "SAPI_RC_INSUFFICIENT_CONTEXT";
case trunks::SAPI_RC_INSUFFICIENT_RESPONSE:
return "SAPI_RC_INSUFFICIENT_RESPONSE";
- case trunks::SAPI_RC_INCOMPATIBLE_TCTI: return "SAPI_RC_INCOMPATIBLE_TCTI";
+ case trunks::SAPI_RC_INCOMPATIBLE_TCTI:
+ return "SAPI_RC_INCOMPATIBLE_TCTI";
case trunks::SAPI_RC_MALFORMED_RESPONSE:
return "SAPI_RC_MALFORMED_RESPONSE";
case trunks::SAPI_RC_BAD_TCTI_STRUCTURE:
return "SAPI_RC_BAD_TCTI_STRUCTURE";
- default: return std::string();
+ default:
+ return std::string();
}
NOTREACHED();
return std::string();
diff --git a/trunks/ftdi/mpsse.c b/trunks/ftdi/mpsse.c
index b109bb0..26fd632 100644
--- a/trunks/ftdi/mpsse.c
+++ b/trunks/ftdi/mpsse.c
@@ -60,8 +60,8 @@
struct mpsse_context* mpsse = NULL;
for (i = 0; supported_devices[i].vid != 0; i++) {
- mpsse = Open(supported_devices[i].vid, supported_devices[i].pid, mode,
- freq, endianess, IFACE_A, NULL, NULL);
+ mpsse = Open(supported_devices[i].vid, supported_devices[i].pid, mode, freq,
+ endianess, IFACE_A, NULL, NULL);
if (mpsse) {
mpsse->description = supported_devices[i].description;
return mpsse;
@@ -885,9 +885,8 @@
rxsize = SPI_TRANSFER_SIZE;
}
- txdata =
- build_block_buffer(mpsse, mpsse->txrx, data + n,
- rxsize, &data_size);
+ txdata = build_block_buffer(mpsse, mpsse->txrx, data + n, rxsize,
+ &data_size);
if (txdata) {
retval = raw_write(mpsse, txdata, data_size);
free(txdata);
diff --git a/trunks/ftdi/mpsse.h b/trunks/ftdi/mpsse.h
index f73eede..07b8cae 100644
--- a/trunks/ftdi/mpsse.h
+++ b/trunks/ftdi/mpsse.h
@@ -233,8 +233,7 @@
swig_string_data Transfer(struct mpsse_context* mpsse, char* data, int size);
#else
uint8_t* Read(struct mpsse_context* mpsse, int size);
-uint8_t* Transfer(struct mpsse_context* mpsse,
- uint8_t* data, int size);
+uint8_t* Transfer(struct mpsse_context* mpsse, uint8_t* data, int size);
int FastWrite(struct mpsse_context* mpsse, char* data, int size);
int FastRead(struct mpsse_context* mpsse, char* data, int size);
@@ -246,4 +245,4 @@
#ifdef __cplusplus
}
#endif
-#endif /* TRUNKS_FTDI_MPSSE_H_ */
+#endif /* TRUNKS_FTDI_MPSSE_H_ */
diff --git a/trunks/ftdi/support.c b/trunks/ftdi/support.c
index 9b7c05d..2947380 100644
--- a/trunks/ftdi/support.c
+++ b/trunks/ftdi/support.c
@@ -23,255 +23,256 @@
* Craig Heffner
* 27 December 2011
*/
-
#include <string.h>
#include "trunks/ftdi/support.h"
/* Write data to the FTDI chip */
int raw_write(struct mpsse_context* mpsse, uint8_t* buf, int size) {
- int retval = MPSSE_FAIL;
+ int retval = MPSSE_FAIL;
- if (mpsse->mode) {
- if (ftdi_write_data(&mpsse->ftdi, buf, size) == size) {
- retval = MPSSE_OK;
- }
- }
+ if (mpsse->mode) {
+ if (ftdi_write_data(&mpsse->ftdi, buf, size) == size) {
+ retval = MPSSE_OK;
+ }
+ }
- return retval;
-}
+ return retval;
+ }
-/* Read data from the FTDI chip */
-int raw_read(struct mpsse_context* mpsse, uint8_t* buf, int size) {
- int n = 0, r = 0;
+ /* Read data from the FTDI chip */
+ int raw_read(struct mpsse_context* mpsse, uint8_t* buf, int size) {
+ int n = 0, r = 0;
- if (mpsse->mode) {
- while (n < size) {
- r = ftdi_read_data(&mpsse->ftdi, buf, size);
- if (r < 0)
- break;
- n += r;
- }
+ if (mpsse->mode) {
+ while (n < size) {
+ r = ftdi_read_data(&mpsse->ftdi, buf, size);
+ if (r < 0)
+ break;
+ n += r;
+ }
- if (mpsse->flush_after_read) {
- /*
- * Make sure the buffers are cleared after a read or subsequent reads may
- *fail.
- *
- * Is this needed anymore? It slows down repetitive read operations by
- *~8%.
- */
- ftdi_usb_purge_rx_buffer(&mpsse->ftdi);
- }
- }
+ if (mpsse->flush_after_read) {
+ /*
+ * Make sure the buffers are cleared after a read or subsequent reads may
+ *fail.
+ *
+ * Is this needed anymore? It slows down repetitive read operations by
+ *~8%.
+ */
+ ftdi_usb_purge_rx_buffer(&mpsse->ftdi);
+ }
+ }
- return n;
-}
+ return n;
+ }
-/* Sets the read and write timeout periods for bulk usb data transfers. */
-void set_timeouts(struct mpsse_context* mpsse, int timeout) {
- if (mpsse->mode) {
- mpsse->ftdi.usb_read_timeout = timeout;
- mpsse->ftdi.usb_write_timeout = timeout;
- }
+ /* Sets the read and write timeout periods for bulk usb data transfers. */
+ void set_timeouts(struct mpsse_context* mpsse, int timeout) {
+ if (mpsse->mode) {
+ mpsse->ftdi.usb_read_timeout = timeout;
+ mpsse->ftdi.usb_write_timeout = timeout;
+ }
- return;
-}
+ return;
+ }
-/* Convert a frequency to a clock divisor */
-uint16_t freq2div(uint32_t system_clock, uint32_t freq) {
- return (((system_clock / freq) / 2) - 1);
-}
+ /* Convert a frequency to a clock divisor */
+ uint16_t freq2div(uint32_t system_clock, uint32_t freq) {
+ return (((system_clock / freq) / 2) - 1);
+ }
-/* Convert a clock divisor to a frequency */
-uint32_t div2freq(uint32_t system_clock, uint16_t div) {
- return (system_clock / ((1 + div) * 2));
-}
+ /* Convert a clock divisor to a frequency */
+ uint32_t div2freq(uint32_t system_clock, uint16_t div) {
+ return (system_clock / ((1 + div) * 2));
+ }
-/* Builds a buffer of commands + data blocks */
-uint8_t* build_block_buffer(struct mpsse_context* mpsse,
- uint8_t cmd,
- const uint8_t* data,
- int size,
- int* buf_size) {
- uint8_t* buf = NULL;
- int i = 0, j = 0, k = 0, dsize = 0, num_blocks = 0, total_size = 0,
- xfer_size = 0;
- uint16_t rsize = 0;
+ /* Builds a buffer of commands + data blocks */
+ uint8_t* build_block_buffer(struct mpsse_context* mpsse,
+ uint8_t cmd,
+ const uint8_t* data,
+ int size,
+ int* buf_size) {
+ uint8_t* buf = NULL;
+ int i = 0, j = 0, k = 0, dsize = 0, num_blocks = 0, total_size = 0,
+ xfer_size = 0;
+ uint16_t rsize = 0;
- *buf_size = 0;
+ *buf_size = 0;
- /* Data block size is 1 in I2C, or when in bitmode */
- if (mpsse->mode == I2C || (cmd & MPSSE_BITMODE)) {
- xfer_size = 1;
- } else {
- xfer_size = mpsse->xsize;
- }
+ /* Data block size is 1 in I2C, or when in bitmode */
+ if (mpsse->mode == I2C || (cmd & MPSSE_BITMODE)) {
+ xfer_size = 1;
+ } else {
+ xfer_size = mpsse->xsize;
+ }
- num_blocks = (size / xfer_size);
- if (size % xfer_size) {
- num_blocks++;
- }
+ num_blocks = (size / xfer_size);
+ if (size % xfer_size) {
+ num_blocks++;
+ }
- /* The total size of the data will be the data size + the write command */
- total_size = size + (CMD_SIZE * num_blocks);
+ /* The total size of the data will be the data size + the write command */
+ total_size = size + (CMD_SIZE * num_blocks);
- /* In I2C we have to add 3 additional commands per data block */
- if (mpsse->mode == I2C) {
- total_size += (CMD_SIZE * 3 * num_blocks);
- }
+ /* In I2C we have to add 3 additional commands per data block */
+ if (mpsse->mode == I2C) {
+ total_size += (CMD_SIZE * 3 * num_blocks);
+ }
- buf = malloc(total_size);
- if (buf) {
- memset(buf, 0, total_size);
+ buf = malloc(total_size);
+ if (buf) {
+ memset(buf, 0, total_size);
- for (j = 0; j < num_blocks; j++) {
- dsize = size - k;
- if (dsize > xfer_size) {
- dsize = xfer_size;
- }
+ for (j = 0; j < num_blocks; j++) {
+ dsize = size - k;
+ if (dsize > xfer_size) {
+ dsize = xfer_size;
+ }
- /* The reported size of this block is block size - 1 */
- rsize = dsize - 1;
+ /* The reported size of this block is block size - 1 */
+ rsize = dsize - 1;
- /* For I2C we need to ensure that the clock pin is set low prior to
- * clocking out data */
- if (mpsse->mode == I2C) {
- buf[i++] = SET_BITS_LOW;
- buf[i++] = mpsse->pstart & ~SK;
+ /* For I2C we need to ensure that the clock pin is set low prior to
+ * clocking out data */
+ if (mpsse->mode == I2C) {
+ buf[i++] = SET_BITS_LOW;
+ buf[i++] = mpsse->pstart & ~SK;
- /* On receive, we need to ensure that the data out line is set as an
- * input to avoid contention on the bus */
- if (cmd == mpsse->rx) {
- buf[i++] = mpsse->tris & ~DO;
- } else {
- buf[i++] = mpsse->tris;
- }
- }
+ /* On receive, we need to ensure that the data out line is set as an
+ * input to avoid contention on the bus */
+ if (cmd == mpsse->rx) {
+ buf[i++] = mpsse->tris & ~DO;
+ } else {
+ buf[i++] = mpsse->tris;
+ }
+ }
- /* Copy in the command for this block */
- buf[i++] = cmd;
- buf[i++] = (rsize & 0xFF);
- if (!(cmd & MPSSE_BITMODE)) {
- buf[i++] = ((rsize >> 8) & 0xFF);
- }
+ /* Copy in the command for this block */
+ buf[i++] = cmd;
+ buf[i++] = (rsize & 0xFF);
+ if (!(cmd & MPSSE_BITMODE)) {
+ buf[i++] = ((rsize >> 8) & 0xFF);
+ }
- /* On a write, copy the data to transmit after the command */
- if (cmd == mpsse->tx || cmd == mpsse->txrx) {
- memcpy(buf + i, data + k, dsize);
+ /* On a write, copy the data to transmit after the command */
+ if (cmd == mpsse->tx || cmd == mpsse->txrx) {
+ memcpy(buf + i, data + k, dsize);
- /* i == offset into buf */
- i += dsize;
- /* k == offset into data */
- k += dsize;
- }
+ /* i == offset into buf */
+ i += dsize;
+ /* k == offset into data */
+ k += dsize;
+ }
- /* In I2C mode we need to clock one ACK bit after each byte */
- if (mpsse->mode == I2C) {
- /* If we are receiving data, then we need to clock out an ACK for each
- * byte */
- if (cmd == mpsse->rx) {
- buf[i++] = SET_BITS_LOW;
- buf[i++] = mpsse->pstart & ~SK;
- buf[i++] = mpsse->tris;
+ /* In I2C mode we need to clock one ACK bit after each byte */
+ if (mpsse->mode == I2C) {
+ /* If we are receiving data, then we need to clock out an ACK for each
+ * byte */
+ if (cmd == mpsse->rx) {
+ buf[i++] = SET_BITS_LOW;
+ buf[i++] = mpsse->pstart & ~SK;
+ buf[i++] = mpsse->tris;
- buf[i++] = mpsse->tx | MPSSE_BITMODE;
- buf[i++] = 0;
- buf[i++] = mpsse->tack;
- }
- /* If we are sending data, then we need to clock in an ACK for each byte
- */
- else if (cmd == mpsse->tx) {
- /* Need to make data out an input to avoid contention on the bus when
- * the slave sends an ACK */
- buf[i++] = SET_BITS_LOW;
- buf[i++] = mpsse->pstart & ~SK;
- buf[i++] = mpsse->tris & ~DO;
+ buf[i++] = mpsse->tx | MPSSE_BITMODE;
+ buf[i++] = 0;
+ buf[i++] = mpsse->tack;
+ }
+ /* If we are sending data, then we need to clock in an ACK for each
+ * byte
+ */
+ else if (cmd == mpsse->tx) {
+ /* Need to make data out an input to avoid contention on the bus when
+ * the slave sends an ACK */
+ buf[i++] = SET_BITS_LOW;
+ buf[i++] = mpsse->pstart & ~SK;
+ buf[i++] = mpsse->tris & ~DO;
- buf[i++] = mpsse->rx | MPSSE_BITMODE;
- buf[i++] = 0;
- buf[i++] = SEND_IMMEDIATE;
- }
- }
- }
+ buf[i++] = mpsse->rx | MPSSE_BITMODE;
+ buf[i++] = 0;
+ buf[i++] = SEND_IMMEDIATE;
+ }
+ }
+ }
- *buf_size = i;
- }
+ *buf_size = i;
+ }
- return buf;
-}
+ return buf;
+ }
-/* Set the low bit pins high/low */
-int set_bits_low(struct mpsse_context* mpsse, int port) {
- char buf[CMD_SIZE] = {0};
+ /* Set the low bit pins high/low */
+ int set_bits_low(struct mpsse_context* mpsse, int port) {
+ char buf[CMD_SIZE] = {0};
- buf[0] = SET_BITS_LOW;
- buf[1] = port;
- buf[2] = mpsse->tris;
+ buf[0] = SET_BITS_LOW;
+ buf[1] = port;
+ buf[2] = mpsse->tris;
- return raw_write(mpsse, (uint8_t*)&buf, sizeof(buf));
-}
+ return raw_write(mpsse, (uint8_t*)&buf, sizeof(buf));
+ }
-/* Set the high bit pins high/low */
-int set_bits_high(struct mpsse_context* mpsse, int port) {
- char buf[CMD_SIZE] = {0};
+ /* Set the high bit pins high/low */
+ int set_bits_high(struct mpsse_context* mpsse, int port) {
+ char buf[CMD_SIZE] = {0};
- buf[0] = SET_BITS_HIGH;
- buf[1] = port;
- buf[2] = mpsse->trish;
+ buf[0] = SET_BITS_HIGH;
+ buf[1] = port;
+ buf[2] = mpsse->trish;
- return raw_write(mpsse, (uint8_t*)&buf, sizeof(buf));
-}
+ return raw_write(mpsse, (uint8_t*)&buf, sizeof(buf));
+ }
-/* Set the GPIO pins high/low */
-int gpio_write(struct mpsse_context* mpsse, int pin, int direction) {
- int retval = MPSSE_FAIL;
+ /* Set the GPIO pins high/low */
+ int gpio_write(struct mpsse_context* mpsse, int pin, int direction) {
+ int retval = MPSSE_FAIL;
- if (mpsse->mode == BITBANG) {
- if (direction == HIGH) {
- mpsse->bitbang |= (1 << pin);
- } else {
- mpsse->bitbang &= ~(1 << pin);
- }
+ if (mpsse->mode == BITBANG) {
+ if (direction == HIGH) {
+ mpsse->bitbang |= (1 << pin);
+ } else {
+ mpsse->bitbang &= ~(1 << pin);
+ }
- if (set_bits_high(mpsse, mpsse->bitbang) == MPSSE_OK) {
- retval = raw_write(mpsse, (uint8_t*)&mpsse->bitbang, 1);
- }
- } else {
- /* The first four pins can't be changed unless we are in a stopped status */
- if (pin < NUM_GPIOL_PINS && mpsse->status == STOPPED) {
- /* Convert pin number (0-3) to the corresponding pin bit */
- pin = (GPIO0 << pin);
+ if (set_bits_high(mpsse, mpsse->bitbang) == MPSSE_OK) {
+ retval = raw_write(mpsse, (uint8_t*)&mpsse->bitbang, 1);
+ }
+ } else {
+ /* The first four pins can't be changed unless we are in a stopped status
+ */
+ if (pin < NUM_GPIOL_PINS && mpsse->status == STOPPED) {
+ /* Convert pin number (0-3) to the corresponding pin bit */
+ pin = (GPIO0 << pin);
- if (direction == HIGH) {
- mpsse->pstart |= pin;
- mpsse->pidle |= pin;
- mpsse->pstop |= pin;
- } else {
- mpsse->pstart &= ~pin;
- mpsse->pidle &= ~pin;
- mpsse->pstop &= ~pin;
- }
+ if (direction == HIGH) {
+ mpsse->pstart |= pin;
+ mpsse->pidle |= pin;
+ mpsse->pstop |= pin;
+ } else {
+ mpsse->pstart &= ~pin;
+ mpsse->pidle &= ~pin;
+ mpsse->pstop &= ~pin;
+ }
- retval = set_bits_low(mpsse, mpsse->pstop);
- } else if (pin >= NUM_GPIOL_PINS && pin < NUM_GPIO_PINS) {
- /* Convert pin number (4 - 11) to the corresponding pin bit */
- pin -= NUM_GPIOL_PINS;
+ retval = set_bits_low(mpsse, mpsse->pstop);
+ } else if (pin >= NUM_GPIOL_PINS && pin < NUM_GPIO_PINS) {
+ /* Convert pin number (4 - 11) to the corresponding pin bit */
+ pin -= NUM_GPIOL_PINS;
- if (direction == HIGH) {
- mpsse->gpioh |= (1 << pin);
- } else {
- mpsse->gpioh &= ~(1 << pin);
- }
+ if (direction == HIGH) {
+ mpsse->gpioh |= (1 << pin);
+ } else {
+ mpsse->gpioh &= ~(1 << pin);
+ }
- retval = set_bits_high(mpsse, mpsse->gpioh);
- }
- }
+ retval = set_bits_high(mpsse, mpsse->gpioh);
+ }
+ }
- return retval;
-}
+ return retval;
+ }
-/* Checks if a given MPSSE context is valid. */
-int is_valid_context(struct mpsse_context* mpsse) {
- return mpsse != NULL;
-}
+ /* Checks if a given MPSSE context is valid. */
+ int is_valid_context(struct mpsse_context* mpsse) {
+ return mpsse != NULL;
+ }
diff --git a/trunks/ftdi/support.h b/trunks/ftdi/support.h
index b9455a9..42753f0 100644
--- a/trunks/ftdi/support.h
+++ b/trunks/ftdi/support.h
@@ -25,18 +25,18 @@
#include "trunks/ftdi/mpsse.h"
int raw_write(struct mpsse_context* mpsse, uint8_t* buf, int size);
-int raw_read(struct mpsse_context* mpsse, uint8_t* buf, int size);
-void set_timeouts(struct mpsse_context* mpsse, int timeout);
-uint16_t freq2div(uint32_t system_clock, uint32_t freq);
-uint32_t div2freq(uint32_t system_clock, uint16_t div);
-uint8_t* build_block_buffer(struct mpsse_context* mpsse,
- uint8_t cmd,
- const uint8_t* data,
- int size,
- int* buf_size);
-int set_bits_high(struct mpsse_context* mpsse, int port);
-int set_bits_low(struct mpsse_context* mpsse, int port);
-int gpio_write(struct mpsse_context* mpsse, int pin, int direction);
-int is_valid_context(struct mpsse_context* mpsse);
+ int raw_read(struct mpsse_context* mpsse, uint8_t* buf, int size);
+ void set_timeouts(struct mpsse_context* mpsse, int timeout);
+ uint16_t freq2div(uint32_t system_clock, uint32_t freq);
+ uint32_t div2freq(uint32_t system_clock, uint16_t div);
+ uint8_t* build_block_buffer(struct mpsse_context* mpsse,
+ uint8_t cmd,
+ const uint8_t* data,
+ int size,
+ int* buf_size);
+ int set_bits_high(struct mpsse_context* mpsse, int port);
+ int set_bits_low(struct mpsse_context* mpsse, int port);
+ int gpio_write(struct mpsse_context* mpsse, int pin, int direction);
+ int is_valid_context(struct mpsse_context* mpsse);
-#endif /* TRUNKS_FTDI_SUPPORT_H_ */
+#endif /* TRUNKS_FTDI_SUPPORT_H_ */
diff --git a/trunks/generator/generator.py b/trunks/generator/generator.py
index 1aa4a4f..d818f8f 100755
--- a/trunks/generator/generator.py
+++ b/trunks/generator/generator.py
@@ -73,6 +73,7 @@
import argparse
import re
+import subprocess
import union_selectors
@@ -2066,6 +2067,10 @@
out_file.close()
+def FormatFile(filename):
+ subprocess.call(['clang-format', '-i', '-style=file', filename])
+
+
def main():
"""A main function.
@@ -2086,6 +2091,8 @@
commands = command_parser.Parse()
GenerateHeader(types, constants, structs, defines, typemap, commands)
GenerateImplementation(types, structs, typemap, commands)
+ FormatFile(_OUTPUT_FILE_H)
+ FormatFile(_OUTPUT_FILE_CC)
print('Processed %d commands.' % len(commands))
diff --git a/trunks/hmac_authorization_delegate.cc b/trunks/hmac_authorization_delegate.cc
index 5aa842b..d88ff91 100644
--- a/trunks/hmac_authorization_delegate.cc
+++ b/trunks/hmac_authorization_delegate.cc
@@ -31,8 +31,8 @@
const uint32_t kDigestBits = 256;
const uint16_t kNonceMinSize = 16;
const uint16_t kNonceMaxSize = 32;
-const uint8_t kDecryptSession = 1<<5;
-const uint8_t kEncryptSession = 1<<6;
+const uint8_t kDecryptSession = 1 << 5;
+const uint8_t kEncryptSession = 1 << 6;
const uint8_t kLabelSize = 4;
const size_t kAesIVSize = 16;
const uint32_t kTpmBufferSize = 4096;
@@ -80,7 +80,8 @@
nonce_generated_ = false;
std::string attributes_bytes;
CHECK_EQ(Serialize_TPMA_SESSION(auth.session_attributes, &attributes_bytes),
- TPM_RC_SUCCESS) << "Error serializing session attributes.";
+ TPM_RC_SUCCESS)
+ << "Error serializing session attributes.";
std::string hmac_data;
std::string hmac_key;
@@ -115,9 +116,8 @@
TPMS_AUTH_RESPONSE auth_response;
std::string mutable_auth_string(authorization);
TPM_RC parse_error;
- parse_error = Parse_TPMS_AUTH_RESPONSE(&mutable_auth_string,
- &auth_response,
- nullptr);
+ parse_error =
+ Parse_TPMS_AUTH_RESPONSE(&mutable_auth_string, &auth_response, nullptr);
if (parse_error != TPM_RC_SUCCESS) {
LOG(ERROR) << "Could not parse authorization response.";
return false;
@@ -135,7 +135,8 @@
std::string attributes_bytes;
CHECK_EQ(Serialize_TPMA_SESSION(auth_response.session_attributes,
&attributes_bytes),
- TPM_RC_SUCCESS) << "Error serializing session attributes.";
+ TPM_RC_SUCCESS)
+ << "Error serializing session attributes.";
std::string hmac_data;
std::string hmac_key;
@@ -207,13 +208,12 @@
return true;
}
-bool HmacAuthorizationDelegate::InitSession(
- TPM_HANDLE session_handle,
- const TPM2B_NONCE& tpm_nonce,
- const TPM2B_NONCE& caller_nonce,
- const std::string& salt,
- const std::string& bind_auth_value,
- bool enable_parameter_encryption) {
+bool HmacAuthorizationDelegate::InitSession(TPM_HANDLE session_handle,
+ const TPM2B_NONCE& tpm_nonce,
+ const TPM2B_NONCE& caller_nonce,
+ const std::string& salt,
+ const std::string& bind_auth_value,
+ bool enable_parameter_encryption) {
session_handle_ = session_handle;
if (caller_nonce.size < kNonceMinSize || caller_nonce.size > kNonceMaxSize ||
tpm_nonce.size < kNonceMinSize || tpm_nonce.size > kNonceMaxSize) {
@@ -229,10 +229,8 @@
// unbound sessions.
session_key_ = std::string();
} else {
- session_key_ = CreateKey(bind_auth_value + salt,
- session_key_label,
- tpm_nonce_,
- caller_nonce_);
+ session_key_ = CreateKey(bind_auth_value + salt, session_key_label,
+ tpm_nonce_, caller_nonce_);
}
return true;
}
@@ -275,12 +273,8 @@
const std::string& data) {
unsigned char digest[EVP_MAX_MD_SIZE];
unsigned int digest_length;
- HMAC(EVP_sha256(),
- key.data(),
- key.size(),
- reinterpret_cast<const unsigned char*>(data.data()),
- data.size(),
- digest,
+ HMAC(EVP_sha256(), key.data(), key.size(),
+ reinterpret_cast<const unsigned char*>(data.data()), data.size(), digest,
&digest_length);
CHECK_EQ(digest_length, kHashDigestSize);
return std::string(reinterpret_cast<char*>(digest), digest_length);
@@ -291,11 +285,9 @@
const TPM2B_NONCE& nonce_older,
int operation_type) {
std::string label("CFB", kLabelSize);
- std::string compound_key = CreateKey(
- session_key_ + entity_authorization_value_,
- label,
- nonce_newer,
- nonce_older);
+ std::string compound_key =
+ CreateKey(session_key_ + entity_authorization_value_, label, nonce_newer,
+ nonce_older);
CHECK_EQ(compound_key.size(), kAesKeySize + kAesIVSize);
unsigned char aes_key[kAesKeySize];
unsigned char aes_iv[kAesIVSize];
@@ -303,13 +295,10 @@
memcpy(aes_iv, &compound_key[kAesKeySize], kAesIVSize);
AES_KEY key;
int iv_offset = 0;
- AES_set_encrypt_key(aes_key, kAesKeySize*8, &key);
+ AES_set_encrypt_key(aes_key, kAesKeySize * 8, &key);
unsigned char decrypted[kTpmBufferSize];
AES_cfb128_encrypt(reinterpret_cast<const unsigned char*>(parameter->data()),
- decrypted,
- parameter->size(),
- &key, aes_iv,
- &iv_offset,
+ decrypted, parameter->size(), &key, aes_iv, &iv_offset,
operation_type);
memcpy(string_as_array(parameter), decrypted, parameter->size());
}
@@ -318,8 +307,8 @@
CHECK(session_handle_);
// RAND_bytes takes a signed number, but since nonce_size is guaranteed to be
// less than 32 bytes and greater than 16 we dont have to worry about it.
- CHECK_EQ(RAND_bytes(caller_nonce_.buffer, caller_nonce_.size), 1) <<
- "Error regnerating a cryptographically random nonce.";
+ CHECK_EQ(RAND_bytes(caller_nonce_.buffer, caller_nonce_.size), 1)
+ << "Error regnerating a cryptographically random nonce.";
}
} // namespace trunks
diff --git a/trunks/hmac_authorization_delegate.h b/trunks/hmac_authorization_delegate.h
index 2a02827..bb46bfe 100644
--- a/trunks/hmac_authorization_delegate.h
+++ b/trunks/hmac_authorization_delegate.h
@@ -58,7 +58,7 @@
// tpm.Create(..., &hmac);
// hmac.set_entity_authorization_value(...);
// tpm.Load(..., &hmac);
-class TRUNKS_EXPORT HmacAuthorizationDelegate: public AuthorizationDelegate {
+class TRUNKS_EXPORT HmacAuthorizationDelegate : public AuthorizationDelegate {
public:
HmacAuthorizationDelegate();
~HmacAuthorizationDelegate() override;
@@ -106,9 +106,7 @@
return entity_authorization_value_;
}
- TPM_HANDLE session_handle() const {
- return session_handle_;
- }
+ TPM_HANDLE session_handle() const { return session_handle_; }
void set_use_entity_authorization_for_encryption_only(bool value) {
use_entity_authorization_for_encryption_only_ = value;
@@ -127,8 +125,7 @@
const TPM2B_NONCE& nonce_newer,
const TPM2B_NONCE& nonce_older);
// This method performs a FIPS198 HMAC operation on |data| using |key|
- std::string HmacSha256(const std::string& key,
- const std::string& data);
+ std::string HmacSha256(const std::string& key, const std::string& data);
// This method performs an AES operation using a 128 bit key.
// |operation_type| can be either AES_ENCRYPT or AES_DECRYPT and it
// determines if the operation is an encryption or decryption.
diff --git a/trunks/hmac_authorization_delegate_test.cc b/trunks/hmac_authorization_delegate_test.cc
index 6a4e2e3..c68599b 100644
--- a/trunks/hmac_authorization_delegate_test.cc
+++ b/trunks/hmac_authorization_delegate_test.cc
@@ -49,11 +49,12 @@
dummy_auth, false));
EXPECT_EQ(kHashDigestSize, delegate.session_key_.size());
// TODO(usanghi): Use TCG TPM2.0 test vectors when available.
- std::string expected_key("\xfb\x2f\x3c\x33\x65\x3e\xdc\x47"
- "\xda\xbe\x4e\xb7\xf4\x6c\x19\x4d"
- "\xea\x50\xb2\x11\x54\x45\x32\x73"
- "\x47\x38\xef\xb3\x4a\x82\x29\x94",
- kHashDigestSize);
+ std::string expected_key(
+ "\xfb\x2f\x3c\x33\x65\x3e\xdc\x47"
+ "\xda\xbe\x4e\xb7\xf4\x6c\x19\x4d"
+ "\xea\x50\xb2\x11\x54\x45\x32\x73"
+ "\x47\x38\xef\xb3\x4a\x82\x29\x94",
+ kHashDigestSize);
EXPECT_EQ(0, expected_key.compare(delegate.session_key_));
}
@@ -121,8 +122,7 @@
true)); // Enable encryption.
TPM2B_NONCE original_nonce = session_nonce_;
EXPECT_EQ(delegate_.caller_nonce_.size, original_nonce.size);
- EXPECT_EQ(0, memcmp(delegate_.caller_nonce_.buffer,
- original_nonce.buffer,
+ EXPECT_EQ(0, memcmp(delegate_.caller_nonce_.buffer, original_nonce.buffer,
original_nonce.size));
// First we check that performing GetCommandAuthorization resets the nonce.
std::string command_hash;
@@ -130,16 +130,13 @@
TPMS_AUTH_COMMAND auth_command;
EXPECT_TRUE(delegate_.GetCommandAuthorization(command_hash, false, false,
&authorization));
- EXPECT_EQ(TPM_RC_SUCCESS, Parse_TPMS_AUTH_COMMAND(&authorization,
- &auth_command,
- nullptr));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ Parse_TPMS_AUTH_COMMAND(&authorization, &auth_command, nullptr));
EXPECT_EQ(delegate_.caller_nonce_.size, original_nonce.size);
EXPECT_EQ(auth_command.nonce.size, original_nonce.size);
- EXPECT_NE(0, memcmp(delegate_.caller_nonce_.buffer,
- original_nonce.buffer,
+ EXPECT_NE(0, memcmp(delegate_.caller_nonce_.buffer, original_nonce.buffer,
original_nonce.size));
- EXPECT_EQ(0, memcmp(delegate_.caller_nonce_.buffer,
- auth_command.nonce.buffer,
+ EXPECT_EQ(0, memcmp(delegate_.caller_nonce_.buffer, auth_command.nonce.buffer,
auth_command.nonce.size));
// Now we check that GetCommandAuthorization does not reset nonce
// when EncryptCommandParameter is called first.
@@ -147,23 +144,19 @@
std::string parameter;
EXPECT_TRUE(delegate_.EncryptCommandParameter(¶meter));
EXPECT_EQ(delegate_.caller_nonce_.size, original_nonce.size);
- EXPECT_NE(0, memcmp(delegate_.caller_nonce_.buffer,
- original_nonce.buffer,
+ EXPECT_NE(0, memcmp(delegate_.caller_nonce_.buffer, original_nonce.buffer,
original_nonce.size));
EXPECT_TRUE(delegate_.nonce_generated_);
original_nonce = delegate_.caller_nonce_;
EXPECT_TRUE(delegate_.GetCommandAuthorization(command_hash, false, false,
&authorization));
- EXPECT_EQ(TPM_RC_SUCCESS, Parse_TPMS_AUTH_COMMAND(&authorization,
- &auth_command,
- nullptr));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ Parse_TPMS_AUTH_COMMAND(&authorization, &auth_command, nullptr));
EXPECT_EQ(delegate_.caller_nonce_.size, original_nonce.size);
EXPECT_EQ(auth_command.nonce.size, original_nonce.size);
- EXPECT_EQ(0, memcmp(delegate_.caller_nonce_.buffer,
- original_nonce.buffer,
+ EXPECT_EQ(0, memcmp(delegate_.caller_nonce_.buffer, original_nonce.buffer,
original_nonce.size));
- EXPECT_EQ(0, memcmp(delegate_.caller_nonce_.buffer,
- auth_command.nonce.buffer,
+ EXPECT_EQ(0, memcmp(delegate_.caller_nonce_.buffer, auth_command.nonce.buffer,
auth_command.nonce.size));
}
@@ -174,9 +167,8 @@
&authorization));
TPMS_AUTH_COMMAND auth_command;
std::string auth_bytes;
- EXPECT_EQ(TPM_RC_SUCCESS, Parse_TPMS_AUTH_COMMAND(&authorization,
- &auth_command,
- &auth_bytes));
+ EXPECT_EQ(TPM_RC_SUCCESS, Parse_TPMS_AUTH_COMMAND(
+ &authorization, &auth_command, &auth_bytes));
EXPECT_EQ(auth_command.session_handle, session_handle_);
EXPECT_EQ(auth_command.nonce.size, session_nonce_.size);
EXPECT_EQ(kContinueSession, auth_command.session_attributes);
@@ -190,23 +182,22 @@
memset(auth_response.nonce.buffer, 0, kAesKeySize);
auth_response.hmac.size = kHashDigestSize;
// TODO(usanghi): Use TCG TPM2.0 test vectors when available.
- uint8_t hmac_buffer[kHashDigestSize] =
- {0x37, 0x69, 0xaf, 0x12, 0xff, 0x4d, 0xbf, 0x44,
- 0xe5, 0x16, 0xa2, 0x2d, 0x1d, 0x05, 0x12, 0xe8,
- 0xbc, 0x42, 0x51, 0x6d, 0x59, 0xe8, 0xbf, 0x40,
- 0x1e, 0xa3, 0x46, 0xa4, 0xd6, 0x0d, 0xcc, 0xf7};
+ uint8_t hmac_buffer[kHashDigestSize] = {
+ 0x37, 0x69, 0xaf, 0x12, 0xff, 0x4d, 0xbf, 0x44, 0xe5, 0x16, 0xa2,
+ 0x2d, 0x1d, 0x05, 0x12, 0xe8, 0xbc, 0x42, 0x51, 0x6d, 0x59, 0xe8,
+ 0xbf, 0x40, 0x1e, 0xa3, 0x46, 0xa4, 0xd6, 0x0d, 0xcc, 0xf7};
memcpy(auth_response.hmac.buffer, hmac_buffer, kHashDigestSize);
std::string response_hash;
std::string authorization;
- EXPECT_EQ(TPM_RC_SUCCESS, Serialize_TPMS_AUTH_RESPONSE(auth_response,
- &authorization));
- EXPECT_TRUE(delegate_.CheckResponseAuthorization(response_hash,
- authorization));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ Serialize_TPMS_AUTH_RESPONSE(auth_response, &authorization));
+ EXPECT_TRUE(
+ delegate_.CheckResponseAuthorization(response_hash, authorization));
}
TEST_F(HmacAuthorizationDelegateFixture, SessionAttributes) {
- const uint8_t kDecryptSession = 1<<5;
- const uint8_t kEncryptSession = 1<<6;
+ const uint8_t kDecryptSession = 1 << 5;
+ const uint8_t kEncryptSession = 1 << 6;
// Encryption disabled and not possible for command.
std::string authorization;
@@ -214,17 +205,15 @@
&authorization));
TPMS_AUTH_COMMAND auth_command;
std::string auth_bytes;
- EXPECT_EQ(TPM_RC_SUCCESS, Parse_TPMS_AUTH_COMMAND(&authorization,
- &auth_command,
- &auth_bytes));
+ EXPECT_EQ(TPM_RC_SUCCESS, Parse_TPMS_AUTH_COMMAND(
+ &authorization, &auth_command, &auth_bytes));
EXPECT_EQ(kContinueSession, auth_command.session_attributes);
// Encryption disabled and possible for command.
EXPECT_TRUE(delegate_.GetCommandAuthorization(std::string(), true, true,
&authorization));
- EXPECT_EQ(TPM_RC_SUCCESS, Parse_TPMS_AUTH_COMMAND(&authorization,
- &auth_command,
- &auth_bytes));
+ EXPECT_EQ(TPM_RC_SUCCESS, Parse_TPMS_AUTH_COMMAND(
+ &authorization, &auth_command, &auth_bytes));
EXPECT_EQ(kContinueSession, auth_command.session_attributes);
// Encryption enabled and not possible for command.
@@ -236,35 +225,31 @@
true)); // Enable encryption.
EXPECT_TRUE(delegate_.GetCommandAuthorization(std::string(), false, false,
&authorization));
- EXPECT_EQ(TPM_RC_SUCCESS, Parse_TPMS_AUTH_COMMAND(&authorization,
- &auth_command,
- &auth_bytes));
+ EXPECT_EQ(TPM_RC_SUCCESS, Parse_TPMS_AUTH_COMMAND(
+ &authorization, &auth_command, &auth_bytes));
EXPECT_EQ(kContinueSession, auth_command.session_attributes);
// Encryption enabled and possible only for command input.
EXPECT_TRUE(delegate_.GetCommandAuthorization(std::string(), true, false,
&authorization));
- EXPECT_EQ(TPM_RC_SUCCESS, Parse_TPMS_AUTH_COMMAND(&authorization,
- &auth_command,
- &auth_bytes));
+ EXPECT_EQ(TPM_RC_SUCCESS, Parse_TPMS_AUTH_COMMAND(
+ &authorization, &auth_command, &auth_bytes));
EXPECT_EQ(kContinueSession | kDecryptSession,
auth_command.session_attributes);
// Encryption enabled and possible only for command output.
EXPECT_TRUE(delegate_.GetCommandAuthorization(std::string(), false, true,
&authorization));
- EXPECT_EQ(TPM_RC_SUCCESS, Parse_TPMS_AUTH_COMMAND(&authorization,
- &auth_command,
- &auth_bytes));
+ EXPECT_EQ(TPM_RC_SUCCESS, Parse_TPMS_AUTH_COMMAND(
+ &authorization, &auth_command, &auth_bytes));
EXPECT_EQ(kContinueSession | kEncryptSession,
auth_command.session_attributes);
// Encryption enabled and possible for command input and output.
EXPECT_TRUE(delegate_.GetCommandAuthorization(std::string(), true, true,
&authorization));
- EXPECT_EQ(TPM_RC_SUCCESS, Parse_TPMS_AUTH_COMMAND(&authorization,
- &auth_command,
- &auth_bytes));
+ EXPECT_EQ(TPM_RC_SUCCESS, Parse_TPMS_AUTH_COMMAND(
+ &authorization, &auth_command, &auth_bytes));
EXPECT_EQ(kContinueSession | kEncryptSession | kDecryptSession,
auth_command.session_attributes);
}
diff --git a/trunks/hmac_session.h b/trunks/hmac_session.h
index 0b94765..22760d5 100644
--- a/trunks/hmac_session.h
+++ b/trunks/hmac_session.h
@@ -42,10 +42,9 @@
// |bind_authorization_value|. Encryption is enabled if |enable_encryption| is
// true. The session remains active until this object is destroyed or another
// session is started with a call to Start*Session.
- virtual TPM_RC StartBoundSession(
- TPMI_DH_ENTITY bind_entity,
- const std::string& bind_authorization_value,
- bool enable_encryption) = 0;
+ virtual TPM_RC StartBoundSession(TPMI_DH_ENTITY bind_entity,
+ const std::string& bind_authorization_value,
+ bool enable_encryption) = 0;
// Starts a salted, unbound session. Encryption is enabled if
// |enable_encryption| is true. The session remains active until this object
diff --git a/trunks/hmac_session_impl.cc b/trunks/hmac_session_impl.cc
index 48e0b2a..2cbe722 100644
--- a/trunks/hmac_session_impl.cc
+++ b/trunks/hmac_session_impl.cc
@@ -58,13 +58,11 @@
return StartBoundSession(TPM_RH_NULL, "", enable_encryption);
}
-void HmacSessionImpl::SetEntityAuthorizationValue(
- const std::string& value) {
+void HmacSessionImpl::SetEntityAuthorizationValue(const std::string& value) {
hmac_delegate_.set_entity_authorization_value(value);
}
-void HmacSessionImpl::SetFutureAuthorizationValue(
- const std::string& value) {
+void HmacSessionImpl::SetFutureAuthorizationValue(const std::string& value) {
hmac_delegate_.set_future_authorization_value(value);
}
diff --git a/trunks/hmac_session_impl.h b/trunks/hmac_session_impl.h
index a2d9eb9..97726a7 100644
--- a/trunks/hmac_session_impl.h
+++ b/trunks/hmac_session_impl.h
@@ -30,7 +30,6 @@
namespace trunks {
-
// This class implements the HmacSession interface. It is used for
// keeping track of the HmacAuthorizationDelegate used for commands, and to
// provide authorization for commands that need it. It is instantiated by
@@ -44,7 +43,7 @@
// NOTE: StartBoundSession/StartUnboundSession should not be called before
// TPM Ownership is taken. This is because starting a session uses the
// SaltingKey, which is only created after ownership is taken.
-class TRUNKS_EXPORT HmacSessionImpl: public HmacSession {
+class TRUNKS_EXPORT HmacSessionImpl : public HmacSession {
public:
// The constructor for HmacAuthroizationSession needs a factory. In
// producation code, this factory is used to access the TPM class to forward
diff --git a/trunks/hmac_session_test.cc b/trunks/hmac_session_test.cc
index 8df82c1..0a27ba3 100644
--- a/trunks/hmac_session_test.cc
+++ b/trunks/hmac_session_test.cc
@@ -69,8 +69,8 @@
TEST_F(HmacSessionTest, StartBoundSessionSuccess) {
HmacSessionImpl session(factory_);
TPM_HANDLE bind_entity = TPM_RH_FIRST;
- EXPECT_CALL(mock_session_manager_, StartSession(TPM_SE_HMAC, bind_entity,
- _, true, _))
+ EXPECT_CALL(mock_session_manager_,
+ StartSession(TPM_SE_HMAC, bind_entity, _, true, _))
.WillOnce(Return(TPM_RC_SUCCESS));
EXPECT_EQ(TPM_RC_SUCCESS, session.StartBoundSession(bind_entity, "", true));
}
@@ -78,8 +78,8 @@
TEST_F(HmacSessionTest, StartBoundSessionFailure) {
HmacSessionImpl session(factory_);
TPM_HANDLE bind_entity = TPM_RH_FIRST;
- EXPECT_CALL(mock_session_manager_, StartSession(TPM_SE_HMAC, bind_entity,
- _, true, _))
+ EXPECT_CALL(mock_session_manager_,
+ StartSession(TPM_SE_HMAC, bind_entity, _, true, _))
.WillOnce(Return(TPM_RC_FAILURE));
EXPECT_EQ(TPM_RC_FAILURE, session.StartBoundSession(bind_entity, "", true));
}
diff --git a/trunks/mock_authorization_delegate.h b/trunks/mock_authorization_delegate.h
index 2069a4e..80ee61b 100644
--- a/trunks/mock_authorization_delegate.h
+++ b/trunks/mock_authorization_delegate.h
@@ -31,12 +31,10 @@
MockAuthorizationDelegate();
~MockAuthorizationDelegate() override;
- MOCK_METHOD4(GetCommandAuthorization, bool(const std::string&,
- bool,
- bool,
- std::string*));
- MOCK_METHOD2(CheckResponseAuthorization, bool(const std::string&,
- const std::string&));
+ MOCK_METHOD4(GetCommandAuthorization,
+ bool(const std::string&, bool, bool, std::string*));
+ MOCK_METHOD2(CheckResponseAuthorization,
+ bool(const std::string&, const std::string&));
MOCK_METHOD1(EncryptCommandParameter, bool(std::string*));
MOCK_METHOD1(DecryptResponseParameter, bool(std::string*));
diff --git a/trunks/mock_blob_parser.h b/trunks/mock_blob_parser.h
index f6f3d6e..1ec22c6 100644
--- a/trunks/mock_blob_parser.h
+++ b/trunks/mock_blob_parser.h
@@ -30,20 +30,20 @@
MockBlobParser();
~MockBlobParser() override;
- MOCK_METHOD3(SerializeKeyBlob, bool(const TPM2B_PUBLIC&,
- const TPM2B_PRIVATE&,
- std::string*));
- MOCK_METHOD3(ParseKeyBlob, bool(const std::string&,
- TPM2B_PUBLIC*,
- TPM2B_PRIVATE*));
- MOCK_METHOD4(SerializeCreationBlob, bool(const TPM2B_CREATION_DATA&,
- const TPM2B_DIGEST&,
- const TPMT_TK_CREATION&,
- std::string*));
- MOCK_METHOD4(ParseCreationBlob, bool(const std::string&,
- TPM2B_CREATION_DATA*,
- TPM2B_DIGEST*,
- TPMT_TK_CREATION*));
+ MOCK_METHOD3(SerializeKeyBlob,
+ bool(const TPM2B_PUBLIC&, const TPM2B_PRIVATE&, std::string*));
+ MOCK_METHOD3(ParseKeyBlob,
+ bool(const std::string&, TPM2B_PUBLIC*, TPM2B_PRIVATE*));
+ MOCK_METHOD4(SerializeCreationBlob,
+ bool(const TPM2B_CREATION_DATA&,
+ const TPM2B_DIGEST&,
+ const TPMT_TK_CREATION&,
+ std::string*));
+ MOCK_METHOD4(ParseCreationBlob,
+ bool(const std::string&,
+ TPM2B_CREATION_DATA*,
+ TPM2B_DIGEST*,
+ TPMT_TK_CREATION*));
};
} // namespace trunks
diff --git a/trunks/mock_hmac_session.h b/trunks/mock_hmac_session.h
index 3bd1fad..b334d84 100644
--- a/trunks/mock_hmac_session.h
+++ b/trunks/mock_hmac_session.h
@@ -31,10 +31,10 @@
~MockHmacSession() override;
MOCK_METHOD0(GetDelegate, AuthorizationDelegate*());
- MOCK_METHOD3(StartBoundSession, TPM_RC(
- TPMI_DH_ENTITY bind_entity,
- const std::string& bind_authorization_value,
- bool enable_encryption));
+ MOCK_METHOD3(StartBoundSession,
+ TPM_RC(TPMI_DH_ENTITY bind_entity,
+ const std::string& bind_authorization_value,
+ bool enable_encryption));
MOCK_METHOD1(StartUnboundSession, TPM_RC(bool enable_encryption));
MOCK_METHOD1(SetEntityAuthorizationValue, void(const std::string& value));
MOCK_METHOD1(SetFutureAuthorizationValue, void(const std::string& value));
diff --git a/trunks/mock_policy_session.h b/trunks/mock_policy_session.h
index 2ce4214..9edbfeb 100644
--- a/trunks/mock_policy_session.h
+++ b/trunks/mock_policy_session.h
@@ -32,10 +32,10 @@
~MockPolicySession() override;
MOCK_METHOD0(GetDelegate, AuthorizationDelegate*());
- MOCK_METHOD3(StartBoundSession, TPM_RC(
- TPMI_DH_ENTITY bind_entity,
- const std::string& bind_authorization_value,
- bool enable_encryption));
+ MOCK_METHOD3(StartBoundSession,
+ TPM_RC(TPMI_DH_ENTITY bind_entity,
+ const std::string& bind_authorization_value,
+ bool enable_encryption));
MOCK_METHOD1(StartUnboundSession, TPM_RC(bool enable_encryption));
MOCK_METHOD1(GetDigest, TPM_RC(std::string*));
MOCK_METHOD1(PolicyOR, TPM_RC(const std::vector<std::string>&));
diff --git a/trunks/mock_session_manager.h b/trunks/mock_session_manager.h
index e674f0b..93df5de 100644
--- a/trunks/mock_session_manager.h
+++ b/trunks/mock_session_manager.h
@@ -32,11 +32,12 @@
MOCK_CONST_METHOD0(GetSessionHandle, TPM_HANDLE());
MOCK_METHOD0(CloseSession, void());
- MOCK_METHOD5(StartSession, TPM_RC(TPM_SE,
- TPMI_DH_ENTITY,
- const std::string&,
- bool,
- HmacAuthorizationDelegate*));
+ MOCK_METHOD5(StartSession,
+ TPM_RC(TPM_SE,
+ TPMI_DH_ENTITY,
+ const std::string&,
+ bool,
+ HmacAuthorizationDelegate*));
private:
DISALLOW_COPY_AND_ASSIGN(MockSessionManager);
diff --git a/trunks/mock_tpm.cc b/trunks/mock_tpm.cc
index 41ebd2a..c4ab280 100644
--- a/trunks/mock_tpm.cc
+++ b/trunks/mock_tpm.cc
@@ -27,24 +27,22 @@
MockTpm::MockTpm() : Tpm(nullptr) {
ON_CALL(*this, PCR_AllocateSync(_, _, _, _, _, _, _, _))
- .WillByDefault(DoAll(SetArgPointee<3>(YES),
- Return(TPM_RC_SUCCESS)));
+ .WillByDefault(DoAll(SetArgPointee<3>(YES), Return(TPM_RC_SUCCESS)));
}
MockTpm::~MockTpm() {}
-void MockTpm::StartAuthSession(
- const TPMI_DH_OBJECT& tpm_key,
- const std::string& tpm_key_name,
- const TPMI_DH_ENTITY& bind,
- const std::string& bind_name,
- const TPM2B_NONCE& nonce_caller,
- const TPM2B_ENCRYPTED_SECRET& encrypted_salt,
- const TPM_SE& session_type,
- const TPMT_SYM_DEF& symmetric,
- const TPMI_ALG_HASH& auth_hash,
- AuthorizationDelegate* authorization_delegate,
- const StartAuthSessionResponse& callback) {
+void MockTpm::StartAuthSession(const TPMI_DH_OBJECT& tpm_key,
+ const std::string& tpm_key_name,
+ const TPMI_DH_ENTITY& bind,
+ const std::string& bind_name,
+ const TPM2B_NONCE& nonce_caller,
+ const TPM2B_ENCRYPTED_SECRET& encrypted_salt,
+ const TPM_SE& session_type,
+ const TPMT_SYM_DEF& symmetric,
+ const TPMI_ALG_HASH& auth_hash,
+ AuthorizationDelegate* authorization_delegate,
+ const StartAuthSessionResponse& callback) {
StartAuthSessionShort(tpm_key, bind, nonce_caller, encrypted_salt,
session_type, symmetric, auth_hash,
authorization_delegate, callback);
@@ -63,28 +61,25 @@
TPMI_SH_AUTH_SESSION* session_handle,
TPM2B_NONCE* nonce_tpm,
AuthorizationDelegate* authorization_delegate) {
- return StartAuthSessionSyncShort(tpm_key, bind, nonce_caller,
- encrypted_salt, session_type, symmetric,
- auth_hash, session_handle, nonce_tpm,
- authorization_delegate);
+ return StartAuthSessionSyncShort(
+ tpm_key, bind, nonce_caller, encrypted_salt, session_type, symmetric,
+ auth_hash, session_handle, nonce_tpm, authorization_delegate);
}
-TPM_RC MockTpm::CreateSync(
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_SENSITIVE_CREATE& in_sensitive,
- const TPM2B_PUBLIC& in_public,
- const TPM2B_DATA& outside_info,
- const TPML_PCR_SELECTION& creation_pcr,
- TPM2B_PRIVATE* out_private,
- TPM2B_PUBLIC* out_public,
- TPM2B_CREATION_DATA* creation_data,
- TPM2B_DIGEST* creation_hash,
- TPMT_TK_CREATION* creation_ticket,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC MockTpm::CreateSync(const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_SENSITIVE_CREATE& in_sensitive,
+ const TPM2B_PUBLIC& in_public,
+ const TPM2B_DATA& outside_info,
+ const TPML_PCR_SELECTION& creation_pcr,
+ TPM2B_PRIVATE* out_private,
+ TPM2B_PUBLIC* out_public,
+ TPM2B_CREATION_DATA* creation_data,
+ TPM2B_DIGEST* creation_hash,
+ TPMT_TK_CREATION* creation_ticket,
+ AuthorizationDelegate* authorization_delegate) {
return CreateSyncShort(parent_handle, in_sensitive, in_public, creation_pcr,
- out_private, out_public, creation_data,
- creation_hash, creation_ticket,
- authorization_delegate);
+ out_private, out_public, creation_data, creation_hash,
+ creation_ticket, authorization_delegate);
}
TPM_RC MockTpm::CertifyCreationSync(
const TPMI_DH_OBJECT& sign_handle,
@@ -98,10 +93,9 @@
TPM2B_ATTEST* certify_info,
TPMT_SIGNATURE* signature,
AuthorizationDelegate* authorization_delegate) {
- return CertifyCreationSyncShort(sign_handle, object_handle,
- qualifying_data, creation_hash, in_scheme,
- creation_ticket, certify_info, signature,
- authorization_delegate);
+ return CertifyCreationSyncShort(
+ sign_handle, object_handle, qualifying_data, creation_hash, in_scheme,
+ creation_ticket, certify_info, signature, authorization_delegate);
}
TPM_RC MockTpm::GetSessionAuditDigestSync(
const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
@@ -115,39 +109,36 @@
TPM2B_ATTEST* audit_info,
TPMT_SIGNATURE* signature,
AuthorizationDelegate* authorization_delegate) {
- return GetSessionAuditDigestSyncShort(privacy_admin_handle, sign_handle,
- session_handle, qualifying_data,
- in_scheme, audit_info, signature,
- authorization_delegate);
+ return GetSessionAuditDigestSyncShort(
+ privacy_admin_handle, sign_handle, session_handle, qualifying_data,
+ in_scheme, audit_info, signature, authorization_delegate);
}
-TPM_RC MockTpm::CommitSync(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const UINT32& param_size,
- const TPM2B_ECC_POINT& p1,
- const TPM2B_SENSITIVE_DATA& s2,
- const TPM2B_ECC_PARAMETER& y2,
- UINT32* param_size_out,
- TPM2B_ECC_POINT* k,
- TPM2B_ECC_POINT* l,
- TPM2B_ECC_POINT* e,
- UINT16* counter,
- AuthorizationDelegate* authorization_delegate) {
- return CommitSyncShort(sign_handle, param_size, p1, y2, param_size_out, k,
- l, e, counter, authorization_delegate);
+TPM_RC MockTpm::CommitSync(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const UINT32& param_size,
+ const TPM2B_ECC_POINT& p1,
+ const TPM2B_SENSITIVE_DATA& s2,
+ const TPM2B_ECC_PARAMETER& y2,
+ UINT32* param_size_out,
+ TPM2B_ECC_POINT* k,
+ TPM2B_ECC_POINT* l,
+ TPM2B_ECC_POINT* e,
+ UINT16* counter,
+ AuthorizationDelegate* authorization_delegate) {
+ return CommitSyncShort(sign_handle, param_size, p1, y2, param_size_out, k, l,
+ e, counter, authorization_delegate);
}
-void MockTpm::PolicySigned(
- const TPMI_DH_OBJECT& auth_object,
- const std::string& auth_object_name,
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_NONCE& nonce_tpm,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const INT32& expiration,
- const TPMT_SIGNATURE& auth,
- AuthorizationDelegate* authorization_delegate,
- const PolicySignedResponse& callback) {
+void MockTpm::PolicySigned(const TPMI_DH_OBJECT& auth_object,
+ const std::string& auth_object_name,
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_NONCE& nonce_tpm,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const INT32& expiration,
+ const TPMT_SIGNATURE& auth,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicySignedResponse& callback) {
PolicySignedShort(auth_object, policy_session, nonce_tpm, cp_hash_a,
policy_ref, expiration, auth, authorization_delegate,
callback);
@@ -233,20 +224,19 @@
NV_CertifyShort(sign_handle, auth_handle, nv_index, qualifying_data,
in_scheme, size, offset, authorization_delegate, callback);
}
-TPM_RC MockTpm::NV_CertifySync(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- const UINT16& size,
- const UINT16& offset,
- TPM2B_ATTEST* certify_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC MockTpm::NV_CertifySync(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const UINT16& size,
+ const UINT16& offset,
+ TPM2B_ATTEST* certify_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate) {
return NV_CertifySyncShort(sign_handle, auth_handle, nv_index,
qualifying_data, in_scheme, size, offset,
certify_info, signature, authorization_delegate);
diff --git a/trunks/mock_tpm.h b/trunks/mock_tpm.h
index 7dae456..7d4836b 100644
--- a/trunks/mock_tpm.h
+++ b/trunks/mock_tpm.h
@@ -32,41 +32,41 @@
~MockTpm() override;
MOCK_METHOD3(Startup,
- void(const TPM_SU& startup_type,
- AuthorizationDelegate* authorization_delegate,
- const StartupResponse& callback));
+ void(const TPM_SU& startup_type,
+ AuthorizationDelegate* authorization_delegate,
+ const StartupResponse& callback));
MOCK_METHOD2(StartupSync,
- TPM_RC(const TPM_SU& startup_type,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPM_SU& startup_type,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD3(Shutdown,
- void(const TPM_SU& shutdown_type,
- AuthorizationDelegate* authorization_delegate,
- const ShutdownResponse& callback));
+ void(const TPM_SU& shutdown_type,
+ AuthorizationDelegate* authorization_delegate,
+ const ShutdownResponse& callback));
MOCK_METHOD2(ShutdownSync,
- TPM_RC(const TPM_SU& shutdown_type,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPM_SU& shutdown_type,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD3(SelfTest,
- void(const TPMI_YES_NO& full_test,
- AuthorizationDelegate* authorization_delegate,
- const SelfTestResponse& callback));
+ void(const TPMI_YES_NO& full_test,
+ AuthorizationDelegate* authorization_delegate,
+ const SelfTestResponse& callback));
MOCK_METHOD2(SelfTestSync,
- TPM_RC(const TPMI_YES_NO& full_test,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_YES_NO& full_test,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD3(IncrementalSelfTest,
- void(const TPML_ALG& to_test,
- AuthorizationDelegate* authorization_delegate,
- const IncrementalSelfTestResponse& callback));
+ void(const TPML_ALG& to_test,
+ AuthorizationDelegate* authorization_delegate,
+ const IncrementalSelfTestResponse& callback));
MOCK_METHOD3(IncrementalSelfTestSync,
- TPM_RC(const TPML_ALG& to_test,
- TPML_ALG* to_do_list,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPML_ALG& to_test,
+ TPML_ALG* to_do_list,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD2(GetTestResult,
- void(AuthorizationDelegate* authorization_delegate,
- const GetTestResultResponse& callback));
+ void(AuthorizationDelegate* authorization_delegate,
+ const GetTestResultResponse& callback));
MOCK_METHOD3(GetTestResultSync,
- TPM_RC(TPM2B_MAX_BUFFER* out_data,
- TPM_RC* test_result,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(TPM2B_MAX_BUFFER* out_data,
+ TPM_RC* test_result,
+ AuthorizationDelegate* authorization_delegate));
// Too many args to mock, forward to *Short version.
void StartAuthSession(const TPMI_DH_OBJECT& tpm_key,
const std::string& tpm_key_name,
@@ -80,15 +80,15 @@
AuthorizationDelegate* authorization_delegate,
const StartAuthSessionResponse& callback) override;
MOCK_METHOD9(StartAuthSessionShort,
- void(const TPMI_DH_OBJECT& tpm_key,
- const TPMI_DH_ENTITY& bind,
- const TPM2B_NONCE& nonce_caller,
- const TPM2B_ENCRYPTED_SECRET& encrypted_salt,
- const TPM_SE& session_type,
- const TPMT_SYM_DEF& symmetric,
- const TPMI_ALG_HASH& auth_hash,
- AuthorizationDelegate* authorization_delegate,
- const StartAuthSessionResponse& callback));
+ void(const TPMI_DH_OBJECT& tpm_key,
+ const TPMI_DH_ENTITY& bind,
+ const TPM2B_NONCE& nonce_caller,
+ const TPM2B_ENCRYPTED_SECRET& encrypted_salt,
+ const TPM_SE& session_type,
+ const TPMT_SYM_DEF& symmetric,
+ const TPMI_ALG_HASH& auth_hash,
+ AuthorizationDelegate* authorization_delegate,
+ const StartAuthSessionResponse& callback));
// Too many args to mock, forward to *Short version.
TPM_RC StartAuthSessionSync(
const TPMI_DH_OBJECT& tpm_key,
@@ -104,34 +104,34 @@
TPM2B_NONCE* nonce_tpm,
AuthorizationDelegate* authorization_delegate) override;
MOCK_METHOD10(StartAuthSessionSyncShort,
- TPM_RC(const TPMI_DH_OBJECT& tpm_key,
- const TPMI_DH_ENTITY& bind,
- const TPM2B_NONCE& nonce_caller,
- const TPM2B_ENCRYPTED_SECRET& encrypted_salt,
- const TPM_SE& session_type,
- const TPMT_SYM_DEF& symmetric,
- const TPMI_ALG_HASH& auth_hash,
- TPMI_SH_AUTH_SESSION* session_handle,
- TPM2B_NONCE* nonce_tpm,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& tpm_key,
+ const TPMI_DH_ENTITY& bind,
+ const TPM2B_NONCE& nonce_caller,
+ const TPM2B_ENCRYPTED_SECRET& encrypted_salt,
+ const TPM_SE& session_type,
+ const TPMT_SYM_DEF& symmetric,
+ const TPMI_ALG_HASH& auth_hash,
+ TPMI_SH_AUTH_SESSION* session_handle,
+ TPM2B_NONCE* nonce_tpm,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD4(PolicyRestart,
- void(const TPMI_SH_POLICY& session_handle,
- const std::string& session_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const PolicyRestartResponse& callback));
+ void(const TPMI_SH_POLICY& session_handle,
+ const std::string& session_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyRestartResponse& callback));
MOCK_METHOD3(PolicyRestartSync,
- TPM_RC(const TPMI_SH_POLICY& session_handle,
- const std::string& session_handle_name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_SH_POLICY& session_handle,
+ const std::string& session_handle_name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD8(Create,
- void(const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_SENSITIVE_CREATE& in_sensitive,
- const TPM2B_PUBLIC& in_public,
- const TPM2B_DATA& outside_info,
- const TPML_PCR_SELECTION& creation_pcr,
- AuthorizationDelegate* authorization_delegate,
- const CreateResponse& callback));
+ void(const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_SENSITIVE_CREATE& in_sensitive,
+ const TPM2B_PUBLIC& in_public,
+ const TPM2B_DATA& outside_info,
+ const TPML_PCR_SELECTION& creation_pcr,
+ AuthorizationDelegate* authorization_delegate,
+ const CreateResponse& callback));
// Too many args to mock, forward to *Short version.
TPM_RC CreateSync(const TPMI_DH_OBJECT& parent_handle,
const std::string& parent_handle_name,
@@ -146,415 +146,415 @@
TPMT_TK_CREATION* creation_ticket,
AuthorizationDelegate* authorization_delegate) override;
MOCK_METHOD10(CreateSyncShort,
- TPM_RC(const TPMI_DH_OBJECT& parent_handle,
- const TPM2B_SENSITIVE_CREATE& in_sensitive,
- const TPM2B_PUBLIC& in_public,
- const TPML_PCR_SELECTION& creation_pcr,
- TPM2B_PRIVATE* out_private,
- TPM2B_PUBLIC* out_public,
- TPM2B_CREATION_DATA* creation_data,
- TPM2B_DIGEST* creation_hash,
- TPMT_TK_CREATION* creation_ticket,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& parent_handle,
+ const TPM2B_SENSITIVE_CREATE& in_sensitive,
+ const TPM2B_PUBLIC& in_public,
+ const TPML_PCR_SELECTION& creation_pcr,
+ TPM2B_PRIVATE* out_private,
+ TPM2B_PUBLIC* out_public,
+ TPM2B_CREATION_DATA* creation_data,
+ TPM2B_DIGEST* creation_hash,
+ TPMT_TK_CREATION* creation_ticket,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD6(Load,
- void(const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_PRIVATE& in_private,
- const TPM2B_PUBLIC& in_public,
- AuthorizationDelegate* authorization_delegate,
- const LoadResponse& callback));
+ void(const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_PRIVATE& in_private,
+ const TPM2B_PUBLIC& in_public,
+ AuthorizationDelegate* authorization_delegate,
+ const LoadResponse& callback));
MOCK_METHOD7(LoadSync,
- TPM_RC(const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_PRIVATE& in_private,
- const TPM2B_PUBLIC& in_public,
- TPM_HANDLE* object_handle,
- TPM2B_NAME* name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_PRIVATE& in_private,
+ const TPM2B_PUBLIC& in_public,
+ TPM_HANDLE* object_handle,
+ TPM2B_NAME* name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(LoadExternal,
- void(const TPM2B_SENSITIVE& in_private,
- const TPM2B_PUBLIC& in_public,
- const TPMI_RH_HIERARCHY& hierarchy,
- AuthorizationDelegate* authorization_delegate,
- const LoadExternalResponse& callback));
+ void(const TPM2B_SENSITIVE& in_private,
+ const TPM2B_PUBLIC& in_public,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ AuthorizationDelegate* authorization_delegate,
+ const LoadExternalResponse& callback));
MOCK_METHOD6(LoadExternalSync,
- TPM_RC(const TPM2B_SENSITIVE& in_private,
- const TPM2B_PUBLIC& in_public,
- const TPMI_RH_HIERARCHY& hierarchy,
- TPM_HANDLE* object_handle,
- TPM2B_NAME* name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPM2B_SENSITIVE& in_private,
+ const TPM2B_PUBLIC& in_public,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ TPM_HANDLE* object_handle,
+ TPM2B_NAME* name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD4(ReadPublic,
- void(const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const ReadPublicResponse& callback));
+ void(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const ReadPublicResponse& callback));
MOCK_METHOD6(ReadPublicSync,
- TPM_RC(const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- TPM2B_PUBLIC* out_public,
- TPM2B_NAME* name,
- TPM2B_NAME* qualified_name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ TPM2B_PUBLIC* out_public,
+ TPM2B_NAME* name,
+ TPM2B_NAME* qualified_name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD8(ActivateCredential,
- void(const TPMI_DH_OBJECT& activate_handle,
- const std::string& activate_handle_name,
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_ID_OBJECT& credential_blob,
- const TPM2B_ENCRYPTED_SECRET& secret,
- AuthorizationDelegate* authorization_delegate,
- const ActivateCredentialResponse& callback));
+ void(const TPMI_DH_OBJECT& activate_handle,
+ const std::string& activate_handle_name,
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_ID_OBJECT& credential_blob,
+ const TPM2B_ENCRYPTED_SECRET& secret,
+ AuthorizationDelegate* authorization_delegate,
+ const ActivateCredentialResponse& callback));
MOCK_METHOD8(ActivateCredentialSync,
- TPM_RC(const TPMI_DH_OBJECT& activate_handle,
- const std::string& activate_handle_name,
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_ID_OBJECT& credential_blob,
- const TPM2B_ENCRYPTED_SECRET& secret,
- TPM2B_DIGEST* cert_info,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& activate_handle,
+ const std::string& activate_handle_name,
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_ID_OBJECT& credential_blob,
+ const TPM2B_ENCRYPTED_SECRET& secret,
+ TPM2B_DIGEST* cert_info,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD6(MakeCredential,
- void(const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_DIGEST& credential,
- const TPM2B_NAME& object_name,
- AuthorizationDelegate* authorization_delegate,
- const MakeCredentialResponse& callback));
+ void(const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_DIGEST& credential,
+ const TPM2B_NAME& object_name,
+ AuthorizationDelegate* authorization_delegate,
+ const MakeCredentialResponse& callback));
MOCK_METHOD7(MakeCredentialSync,
- TPM_RC(const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_DIGEST& credential,
- const TPM2B_NAME& object_name,
- TPM2B_ID_OBJECT* credential_blob,
- TPM2B_ENCRYPTED_SECRET* secret,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_DIGEST& credential,
+ const TPM2B_NAME& object_name,
+ TPM2B_ID_OBJECT* credential_blob,
+ TPM2B_ENCRYPTED_SECRET* secret,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD4(Unseal,
- void(const TPMI_DH_OBJECT& item_handle,
- const std::string& item_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const UnsealResponse& callback));
+ void(const TPMI_DH_OBJECT& item_handle,
+ const std::string& item_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const UnsealResponse& callback));
MOCK_METHOD4(UnsealSync,
- TPM_RC(const TPMI_DH_OBJECT& item_handle,
- const std::string& item_handle_name,
- TPM2B_SENSITIVE_DATA* out_data,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& item_handle,
+ const std::string& item_handle_name,
+ TPM2B_SENSITIVE_DATA* out_data,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD7(ObjectChangeAuth,
- void(const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_AUTH& new_auth,
- AuthorizationDelegate* authorization_delegate,
- const ObjectChangeAuthResponse& callback));
+ void(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_AUTH& new_auth,
+ AuthorizationDelegate* authorization_delegate,
+ const ObjectChangeAuthResponse& callback));
MOCK_METHOD7(ObjectChangeAuthSync,
- TPM_RC(const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_AUTH& new_auth,
- TPM2B_PRIVATE* out_private,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_AUTH& new_auth,
+ TPM2B_PRIVATE* out_private,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD8(Duplicate,
- void(const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& new_parent_handle,
- const std::string& new_parent_handle_name,
- const TPM2B_DATA& encryption_key_in,
- const TPMT_SYM_DEF_OBJECT& symmetric_alg,
- AuthorizationDelegate* authorization_delegate,
- const DuplicateResponse& callback));
+ void(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& new_parent_handle,
+ const std::string& new_parent_handle_name,
+ const TPM2B_DATA& encryption_key_in,
+ const TPMT_SYM_DEF_OBJECT& symmetric_alg,
+ AuthorizationDelegate* authorization_delegate,
+ const DuplicateResponse& callback));
MOCK_METHOD10(DuplicateSync,
- TPM_RC(const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& new_parent_handle,
- const std::string& new_parent_handle_name,
- const TPM2B_DATA& encryption_key_in,
- const TPMT_SYM_DEF_OBJECT& symmetric_alg,
- TPM2B_DATA* encryption_key_out,
- TPM2B_PRIVATE* duplicate,
- TPM2B_ENCRYPTED_SECRET* out_sym_seed,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& new_parent_handle,
+ const std::string& new_parent_handle_name,
+ const TPM2B_DATA& encryption_key_in,
+ const TPMT_SYM_DEF_OBJECT& symmetric_alg,
+ TPM2B_DATA* encryption_key_out,
+ TPM2B_PRIVATE* duplicate,
+ TPM2B_ENCRYPTED_SECRET* out_sym_seed,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD9(Rewrap,
- void(const TPMI_DH_OBJECT& old_parent,
- const std::string& old_parent_name,
- const TPMI_DH_OBJECT& new_parent,
- const std::string& new_parent_name,
- const TPM2B_PRIVATE& in_duplicate,
- const TPM2B_NAME& name,
- const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
- AuthorizationDelegate* authorization_delegate,
- const RewrapResponse& callback));
+ void(const TPMI_DH_OBJECT& old_parent,
+ const std::string& old_parent_name,
+ const TPMI_DH_OBJECT& new_parent,
+ const std::string& new_parent_name,
+ const TPM2B_PRIVATE& in_duplicate,
+ const TPM2B_NAME& name,
+ const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
+ AuthorizationDelegate* authorization_delegate,
+ const RewrapResponse& callback));
MOCK_METHOD10(RewrapSync,
- TPM_RC(const TPMI_DH_OBJECT& old_parent,
- const std::string& old_parent_name,
- const TPMI_DH_OBJECT& new_parent,
- const std::string& new_parent_name,
- const TPM2B_PRIVATE& in_duplicate,
- const TPM2B_NAME& name,
- const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
- TPM2B_PRIVATE* out_duplicate,
- TPM2B_ENCRYPTED_SECRET* out_sym_seed,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& old_parent,
+ const std::string& old_parent_name,
+ const TPMI_DH_OBJECT& new_parent,
+ const std::string& new_parent_name,
+ const TPM2B_PRIVATE& in_duplicate,
+ const TPM2B_NAME& name,
+ const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
+ TPM2B_PRIVATE* out_duplicate,
+ TPM2B_ENCRYPTED_SECRET* out_sym_seed,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD9(Import,
- void(const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_DATA& encryption_key,
- const TPM2B_PUBLIC& object_public,
- const TPM2B_PRIVATE& duplicate,
- const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
- const TPMT_SYM_DEF_OBJECT& symmetric_alg,
- AuthorizationDelegate* authorization_delegate,
- const ImportResponse& callback));
+ void(const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_DATA& encryption_key,
+ const TPM2B_PUBLIC& object_public,
+ const TPM2B_PRIVATE& duplicate,
+ const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
+ const TPMT_SYM_DEF_OBJECT& symmetric_alg,
+ AuthorizationDelegate* authorization_delegate,
+ const ImportResponse& callback));
MOCK_METHOD9(ImportSync,
- TPM_RC(const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_DATA& encryption_key,
- const TPM2B_PUBLIC& object_public,
- const TPM2B_PRIVATE& duplicate,
- const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
- const TPMT_SYM_DEF_OBJECT& symmetric_alg,
- TPM2B_PRIVATE* out_private,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_DATA& encryption_key,
+ const TPM2B_PUBLIC& object_public,
+ const TPM2B_PRIVATE& duplicate,
+ const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
+ const TPMT_SYM_DEF_OBJECT& symmetric_alg,
+ TPM2B_PRIVATE* out_private,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD7(RSA_Encrypt,
- void(const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_PUBLIC_KEY_RSA& message,
- const TPMT_RSA_DECRYPT& in_scheme,
- const TPM2B_DATA& label,
- AuthorizationDelegate* authorization_delegate,
- const RSA_EncryptResponse& callback));
+ void(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_PUBLIC_KEY_RSA& message,
+ const TPMT_RSA_DECRYPT& in_scheme,
+ const TPM2B_DATA& label,
+ AuthorizationDelegate* authorization_delegate,
+ const RSA_EncryptResponse& callback));
MOCK_METHOD7(RSA_EncryptSync,
- TPM_RC(const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_PUBLIC_KEY_RSA& message,
- const TPMT_RSA_DECRYPT& in_scheme,
- const TPM2B_DATA& label,
- TPM2B_PUBLIC_KEY_RSA* out_data,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_PUBLIC_KEY_RSA& message,
+ const TPMT_RSA_DECRYPT& in_scheme,
+ const TPM2B_DATA& label,
+ TPM2B_PUBLIC_KEY_RSA* out_data,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD7(RSA_Decrypt,
- void(const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_PUBLIC_KEY_RSA& cipher_text,
- const TPMT_RSA_DECRYPT& in_scheme,
- const TPM2B_DATA& label,
- AuthorizationDelegate* authorization_delegate,
- const RSA_DecryptResponse& callback));
+ void(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_PUBLIC_KEY_RSA& cipher_text,
+ const TPMT_RSA_DECRYPT& in_scheme,
+ const TPM2B_DATA& label,
+ AuthorizationDelegate* authorization_delegate,
+ const RSA_DecryptResponse& callback));
MOCK_METHOD7(RSA_DecryptSync,
- TPM_RC(const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_PUBLIC_KEY_RSA& cipher_text,
- const TPMT_RSA_DECRYPT& in_scheme,
- const TPM2B_DATA& label,
- TPM2B_PUBLIC_KEY_RSA* message,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_PUBLIC_KEY_RSA& cipher_text,
+ const TPMT_RSA_DECRYPT& in_scheme,
+ const TPM2B_DATA& label,
+ TPM2B_PUBLIC_KEY_RSA* message,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD4(ECDH_KeyGen,
- void(const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const ECDH_KeyGenResponse& callback));
+ void(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const ECDH_KeyGenResponse& callback));
MOCK_METHOD5(ECDH_KeyGenSync,
- TPM_RC(const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- TPM2B_ECC_POINT* z_point,
- TPM2B_ECC_POINT* pub_point,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ TPM2B_ECC_POINT* z_point,
+ TPM2B_ECC_POINT* pub_point,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(ECDH_ZGen,
- void(const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_ECC_POINT& in_point,
- AuthorizationDelegate* authorization_delegate,
- const ECDH_ZGenResponse& callback));
+ void(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_ECC_POINT& in_point,
+ AuthorizationDelegate* authorization_delegate,
+ const ECDH_ZGenResponse& callback));
MOCK_METHOD5(ECDH_ZGenSync,
- TPM_RC(const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_ECC_POINT& in_point,
- TPM2B_ECC_POINT* out_point,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_ECC_POINT& in_point,
+ TPM2B_ECC_POINT* out_point,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD3(ECC_Parameters,
- void(const TPMI_ECC_CURVE& curve_id,
- AuthorizationDelegate* authorization_delegate,
- const ECC_ParametersResponse& callback));
+ void(const TPMI_ECC_CURVE& curve_id,
+ AuthorizationDelegate* authorization_delegate,
+ const ECC_ParametersResponse& callback));
MOCK_METHOD3(ECC_ParametersSync,
- TPM_RC(const TPMI_ECC_CURVE& curve_id,
- TPMS_ALGORITHM_DETAIL_ECC* parameters,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_ECC_CURVE& curve_id,
+ TPMS_ALGORITHM_DETAIL_ECC* parameters,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD8(ZGen_2Phase,
- void(const TPMI_DH_OBJECT& key_a,
- const std::string& key_a_name,
- const TPM2B_ECC_POINT& in_qs_b,
- const TPM2B_ECC_POINT& in_qe_b,
- const TPMI_ECC_KEY_EXCHANGE& in_scheme,
- const UINT16& counter,
- AuthorizationDelegate* authorization_delegate,
- const ZGen_2PhaseResponse& callback));
+ void(const TPMI_DH_OBJECT& key_a,
+ const std::string& key_a_name,
+ const TPM2B_ECC_POINT& in_qs_b,
+ const TPM2B_ECC_POINT& in_qe_b,
+ const TPMI_ECC_KEY_EXCHANGE& in_scheme,
+ const UINT16& counter,
+ AuthorizationDelegate* authorization_delegate,
+ const ZGen_2PhaseResponse& callback));
MOCK_METHOD9(ZGen_2PhaseSync,
- TPM_RC(const TPMI_DH_OBJECT& key_a,
- const std::string& key_a_name,
- const TPM2B_ECC_POINT& in_qs_b,
- const TPM2B_ECC_POINT& in_qe_b,
- const TPMI_ECC_KEY_EXCHANGE& in_scheme,
- const UINT16& counter,
- TPM2B_ECC_POINT* out_z1,
- TPM2B_ECC_POINT* out_z2,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& key_a,
+ const std::string& key_a_name,
+ const TPM2B_ECC_POINT& in_qs_b,
+ const TPM2B_ECC_POINT& in_qe_b,
+ const TPMI_ECC_KEY_EXCHANGE& in_scheme,
+ const UINT16& counter,
+ TPM2B_ECC_POINT* out_z1,
+ TPM2B_ECC_POINT* out_z2,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD8(EncryptDecrypt,
- void(const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPMI_YES_NO& decrypt,
- const TPMI_ALG_SYM_MODE& mode,
- const TPM2B_IV& iv_in,
- const TPM2B_MAX_BUFFER& in_data,
- AuthorizationDelegate* authorization_delegate,
- const EncryptDecryptResponse& callback));
+ void(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPMI_YES_NO& decrypt,
+ const TPMI_ALG_SYM_MODE& mode,
+ const TPM2B_IV& iv_in,
+ const TPM2B_MAX_BUFFER& in_data,
+ AuthorizationDelegate* authorization_delegate,
+ const EncryptDecryptResponse& callback));
MOCK_METHOD9(EncryptDecryptSync,
- TPM_RC(const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPMI_YES_NO& decrypt,
- const TPMI_ALG_SYM_MODE& mode,
- const TPM2B_IV& iv_in,
- const TPM2B_MAX_BUFFER& in_data,
- TPM2B_MAX_BUFFER* out_data,
- TPM2B_IV* iv_out,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPMI_YES_NO& decrypt,
+ const TPMI_ALG_SYM_MODE& mode,
+ const TPM2B_IV& iv_in,
+ const TPM2B_MAX_BUFFER& in_data,
+ TPM2B_MAX_BUFFER* out_data,
+ TPM2B_IV* iv_out,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(Hash,
- void(const TPM2B_MAX_BUFFER& data,
- const TPMI_ALG_HASH& hash_alg,
- const TPMI_RH_HIERARCHY& hierarchy,
- AuthorizationDelegate* authorization_delegate,
- const HashResponse& callback));
+ void(const TPM2B_MAX_BUFFER& data,
+ const TPMI_ALG_HASH& hash_alg,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ AuthorizationDelegate* authorization_delegate,
+ const HashResponse& callback));
MOCK_METHOD6(HashSync,
- TPM_RC(const TPM2B_MAX_BUFFER& data,
- const TPMI_ALG_HASH& hash_alg,
- const TPMI_RH_HIERARCHY& hierarchy,
- TPM2B_DIGEST* out_hash,
- TPMT_TK_HASHCHECK* validation,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPM2B_MAX_BUFFER& data,
+ const TPMI_ALG_HASH& hash_alg,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ TPM2B_DIGEST* out_hash,
+ TPMT_TK_HASHCHECK* validation,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD6(HMAC,
- void(const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- const TPMI_ALG_HASH& hash_alg,
- AuthorizationDelegate* authorization_delegate,
- const HMACResponse& callback));
+ void(const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ const TPMI_ALG_HASH& hash_alg,
+ AuthorizationDelegate* authorization_delegate,
+ const HMACResponse& callback));
MOCK_METHOD6(HMACSync,
- TPM_RC(const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- const TPMI_ALG_HASH& hash_alg,
- TPM2B_DIGEST* out_hmac,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ const TPMI_ALG_HASH& hash_alg,
+ TPM2B_DIGEST* out_hmac,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD3(GetRandom,
- void(const UINT16& bytes_requested,
- AuthorizationDelegate* authorization_delegate,
- const GetRandomResponse& callback));
+ void(const UINT16& bytes_requested,
+ AuthorizationDelegate* authorization_delegate,
+ const GetRandomResponse& callback));
MOCK_METHOD3(GetRandomSync,
- TPM_RC(const UINT16& bytes_requested,
- TPM2B_DIGEST* random_bytes,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const UINT16& bytes_requested,
+ TPM2B_DIGEST* random_bytes,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD3(StirRandom,
- void(const TPM2B_SENSITIVE_DATA& in_data,
- AuthorizationDelegate* authorization_delegate,
- const StirRandomResponse& callback));
+ void(const TPM2B_SENSITIVE_DATA& in_data,
+ AuthorizationDelegate* authorization_delegate,
+ const StirRandomResponse& callback));
MOCK_METHOD2(StirRandomSync,
- TPM_RC(const TPM2B_SENSITIVE_DATA& in_data,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPM2B_SENSITIVE_DATA& in_data,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD6(HMAC_Start,
- void(const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_AUTH& auth,
- const TPMI_ALG_HASH& hash_alg,
- AuthorizationDelegate* authorization_delegate,
- const HMAC_StartResponse& callback));
+ void(const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_AUTH& auth,
+ const TPMI_ALG_HASH& hash_alg,
+ AuthorizationDelegate* authorization_delegate,
+ const HMAC_StartResponse& callback));
MOCK_METHOD6(HMAC_StartSync,
- TPM_RC(const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_AUTH& auth,
- const TPMI_ALG_HASH& hash_alg,
- TPMI_DH_OBJECT* sequence_handle,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_AUTH& auth,
+ const TPMI_ALG_HASH& hash_alg,
+ TPMI_DH_OBJECT* sequence_handle,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD4(HashSequenceStart,
- void(const TPM2B_AUTH& auth,
- const TPMI_ALG_HASH& hash_alg,
- AuthorizationDelegate* authorization_delegate,
- const HashSequenceStartResponse& callback));
+ void(const TPM2B_AUTH& auth,
+ const TPMI_ALG_HASH& hash_alg,
+ AuthorizationDelegate* authorization_delegate,
+ const HashSequenceStartResponse& callback));
MOCK_METHOD4(HashSequenceStartSync,
- TPM_RC(const TPM2B_AUTH& auth,
- const TPMI_ALG_HASH& hash_alg,
- TPMI_DH_OBJECT* sequence_handle,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPM2B_AUTH& auth,
+ const TPMI_ALG_HASH& hash_alg,
+ TPMI_DH_OBJECT* sequence_handle,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(SequenceUpdate,
- void(const TPMI_DH_OBJECT& sequence_handle,
- const std::string& sequence_handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- AuthorizationDelegate* authorization_delegate,
- const SequenceUpdateResponse& callback));
+ void(const TPMI_DH_OBJECT& sequence_handle,
+ const std::string& sequence_handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ AuthorizationDelegate* authorization_delegate,
+ const SequenceUpdateResponse& callback));
MOCK_METHOD4(SequenceUpdateSync,
- TPM_RC(const TPMI_DH_OBJECT& sequence_handle,
- const std::string& sequence_handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& sequence_handle,
+ const std::string& sequence_handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD6(SequenceComplete,
- void(const TPMI_DH_OBJECT& sequence_handle,
- const std::string& sequence_handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- const TPMI_RH_HIERARCHY& hierarchy,
- AuthorizationDelegate* authorization_delegate,
- const SequenceCompleteResponse& callback));
+ void(const TPMI_DH_OBJECT& sequence_handle,
+ const std::string& sequence_handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ AuthorizationDelegate* authorization_delegate,
+ const SequenceCompleteResponse& callback));
MOCK_METHOD7(SequenceCompleteSync,
- TPM_RC(const TPMI_DH_OBJECT& sequence_handle,
- const std::string& sequence_handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- const TPMI_RH_HIERARCHY& hierarchy,
- TPM2B_DIGEST* result,
- TPMT_TK_HASHCHECK* validation,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& sequence_handle,
+ const std::string& sequence_handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ TPM2B_DIGEST* result,
+ TPMT_TK_HASHCHECK* validation,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD7(EventSequenceComplete,
- void(const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPMI_DH_OBJECT& sequence_handle,
- const std::string& sequence_handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- AuthorizationDelegate* authorization_delegate,
- const EventSequenceCompleteResponse& callback));
+ void(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPMI_DH_OBJECT& sequence_handle,
+ const std::string& sequence_handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ AuthorizationDelegate* authorization_delegate,
+ const EventSequenceCompleteResponse& callback));
MOCK_METHOD7(EventSequenceCompleteSync,
- TPM_RC(const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPMI_DH_OBJECT& sequence_handle,
- const std::string& sequence_handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- TPML_DIGEST_VALUES* results,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPMI_DH_OBJECT& sequence_handle,
+ const std::string& sequence_handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ TPML_DIGEST_VALUES* results,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD8(Certify,
- void(const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- AuthorizationDelegate* authorization_delegate,
- const CertifyResponse& callback));
+ void(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ AuthorizationDelegate* authorization_delegate,
+ const CertifyResponse& callback));
MOCK_METHOD9(CertifySync,
- TPM_RC(const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- TPM2B_ATTEST* certify_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ TPM2B_ATTEST* certify_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD10(CertifyCreation,
- void(const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPM2B_DIGEST& creation_hash,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPMT_TK_CREATION& creation_ticket,
- AuthorizationDelegate* authorization_delegate,
- const CertifyCreationResponse& callback));
+ void(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPM2B_DIGEST& creation_hash,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPMT_TK_CREATION& creation_ticket,
+ AuthorizationDelegate* authorization_delegate,
+ const CertifyCreationResponse& callback));
// Too many args to mock, forward to *Short version.
TPM_RC CertifyCreationSync(
const TPMI_DH_OBJECT& sign_handle,
@@ -569,43 +569,43 @@
TPMT_SIGNATURE* signature,
AuthorizationDelegate* authorization_delegate) override;
MOCK_METHOD9(CertifyCreationSyncShort,
- TPM_RC(const TPMI_DH_OBJECT& sign_handle,
- const TPMI_DH_OBJECT& object_handle,
- const TPM2B_DATA& qualifying_data,
- const TPM2B_DIGEST& creation_hash,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPMT_TK_CREATION& creation_ticket,
- TPM2B_ATTEST* certify_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& sign_handle,
+ const TPMI_DH_OBJECT& object_handle,
+ const TPM2B_DATA& qualifying_data,
+ const TPM2B_DIGEST& creation_hash,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPMT_TK_CREATION& creation_ticket,
+ TPM2B_ATTEST* certify_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD7(Quote,
- void(const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPML_PCR_SELECTION& pcrselect,
- AuthorizationDelegate* authorization_delegate,
- const QuoteResponse& callback));
+ void(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPML_PCR_SELECTION& pcrselect,
+ AuthorizationDelegate* authorization_delegate,
+ const QuoteResponse& callback));
MOCK_METHOD8(QuoteSync,
- TPM_RC(const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPML_PCR_SELECTION& pcrselect,
- TPM2B_ATTEST* quoted,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPML_PCR_SELECTION& pcrselect,
+ TPM2B_ATTEST* quoted,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD10(GetSessionAuditDigest,
- void(const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
- const std::string& privacy_admin_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPMI_SH_HMAC& session_handle,
- const std::string& session_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- AuthorizationDelegate* authorization_delegate,
- const GetSessionAuditDigestResponse& callback));
+ void(const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
+ const std::string& privacy_admin_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPMI_SH_HMAC& session_handle,
+ const std::string& session_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ AuthorizationDelegate* authorization_delegate,
+ const GetSessionAuditDigestResponse& callback));
// Too many args to mock, forward to *Short version.
TPM_RC GetSessionAuditDigestSync(
const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
@@ -620,61 +620,61 @@
TPMT_SIGNATURE* signature,
AuthorizationDelegate* authorization_delegate) override;
MOCK_METHOD8(GetSessionAuditDigestSyncShort,
- TPM_RC(const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
- const TPMI_DH_OBJECT& sign_handle,
- const TPMI_SH_HMAC& session_handle,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- TPM2B_ATTEST* audit_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
+ const TPMI_DH_OBJECT& sign_handle,
+ const TPMI_SH_HMAC& session_handle,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ TPM2B_ATTEST* audit_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD8(GetCommandAuditDigest,
- void(const TPMI_RH_ENDORSEMENT& privacy_handle,
- const std::string& privacy_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- AuthorizationDelegate* authorization_delegate,
- const GetCommandAuditDigestResponse& callback));
+ void(const TPMI_RH_ENDORSEMENT& privacy_handle,
+ const std::string& privacy_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ AuthorizationDelegate* authorization_delegate,
+ const GetCommandAuditDigestResponse& callback));
MOCK_METHOD9(GetCommandAuditDigestSync,
- TPM_RC(const TPMI_RH_ENDORSEMENT& privacy_handle,
- const std::string& privacy_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- TPM2B_ATTEST* audit_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_ENDORSEMENT& privacy_handle,
+ const std::string& privacy_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ TPM2B_ATTEST* audit_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD8(GetTime,
- void(const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
- const std::string& privacy_admin_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- AuthorizationDelegate* authorization_delegate,
- const GetTimeResponse& callback));
+ void(const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
+ const std::string& privacy_admin_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ AuthorizationDelegate* authorization_delegate,
+ const GetTimeResponse& callback));
MOCK_METHOD9(GetTimeSync,
- TPM_RC(const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
- const std::string& privacy_admin_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- TPM2B_ATTEST* time_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
+ const std::string& privacy_admin_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ TPM2B_ATTEST* time_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD8(Commit,
- void(const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const UINT32& param_size,
- const TPM2B_ECC_POINT& p1,
- const TPM2B_SENSITIVE_DATA& s2,
- const TPM2B_ECC_PARAMETER& y2,
- AuthorizationDelegate* authorization_delegate,
- const CommitResponse& callback));
+ void(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const UINT32& param_size,
+ const TPM2B_ECC_POINT& p1,
+ const TPM2B_SENSITIVE_DATA& s2,
+ const TPM2B_ECC_PARAMETER& y2,
+ AuthorizationDelegate* authorization_delegate,
+ const CommitResponse& callback));
// Too many args to mock, forward to *Short version.
TPM_RC CommitSync(const TPMI_DH_OBJECT& sign_handle,
const std::string& sign_handle_name,
@@ -689,181 +689,180 @@
UINT16* counter,
AuthorizationDelegate* authorization_delegate) override;
MOCK_METHOD10(CommitSyncShort,
- TPM_RC(const TPMI_DH_OBJECT& sign_handle,
- const UINT32& param_size,
- const TPM2B_ECC_POINT& p1,
- const TPM2B_ECC_PARAMETER& y2,
- UINT32* param_size_out,
- TPM2B_ECC_POINT* k,
- TPM2B_ECC_POINT* l,
- TPM2B_ECC_POINT* e,
- UINT16* counter,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& sign_handle,
+ const UINT32& param_size,
+ const TPM2B_ECC_POINT& p1,
+ const TPM2B_ECC_PARAMETER& y2,
+ UINT32* param_size_out,
+ TPM2B_ECC_POINT* k,
+ TPM2B_ECC_POINT* l,
+ TPM2B_ECC_POINT* e,
+ UINT16* counter,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD4(EC_Ephemeral,
- void(const UINT32& param_size,
- const TPMI_ECC_CURVE& curve_id,
- AuthorizationDelegate* authorization_delegate,
- const EC_EphemeralResponse& callback));
+ void(const UINT32& param_size,
+ const TPMI_ECC_CURVE& curve_id,
+ AuthorizationDelegate* authorization_delegate,
+ const EC_EphemeralResponse& callback));
MOCK_METHOD6(EC_EphemeralSync,
- TPM_RC(const UINT32& param_size,
- const TPMI_ECC_CURVE& curve_id,
- UINT32* param_size_out,
- TPM2B_ECC_POINT* q,
- UINT16* counter,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const UINT32& param_size,
+ const TPMI_ECC_CURVE& curve_id,
+ UINT32* param_size_out,
+ TPM2B_ECC_POINT* q,
+ UINT16* counter,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD6(VerifySignature,
- void(const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& digest,
- const TPMT_SIGNATURE& signature,
- AuthorizationDelegate* authorization_delegate,
- const VerifySignatureResponse& callback));
+ void(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& digest,
+ const TPMT_SIGNATURE& signature,
+ AuthorizationDelegate* authorization_delegate,
+ const VerifySignatureResponse& callback));
MOCK_METHOD6(VerifySignatureSync,
- TPM_RC(const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& digest,
- const TPMT_SIGNATURE& signature,
- TPMT_TK_VERIFIED* validation,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& digest,
+ const TPMT_SIGNATURE& signature,
+ TPMT_TK_VERIFIED* validation,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD7(Sign,
- void(const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& digest,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPMT_TK_HASHCHECK& validation,
- AuthorizationDelegate* authorization_delegate,
- const SignResponse& callback));
+ void(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& digest,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPMT_TK_HASHCHECK& validation,
+ AuthorizationDelegate* authorization_delegate,
+ const SignResponse& callback));
MOCK_METHOD7(SignSync,
- TPM_RC(const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& digest,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPMT_TK_HASHCHECK& validation,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& digest,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPMT_TK_HASHCHECK& validation,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD7(SetCommandCodeAuditStatus,
- void(const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const TPMI_ALG_HASH& audit_alg,
- const TPML_CC& set_list,
- const TPML_CC& clear_list,
- AuthorizationDelegate* authorization_delegate,
- const SetCommandCodeAuditStatusResponse& callback));
+ void(const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const TPMI_ALG_HASH& audit_alg,
+ const TPML_CC& set_list,
+ const TPML_CC& clear_list,
+ AuthorizationDelegate* authorization_delegate,
+ const SetCommandCodeAuditStatusResponse& callback));
MOCK_METHOD6(SetCommandCodeAuditStatusSync,
- TPM_RC(const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const TPMI_ALG_HASH& audit_alg,
- const TPML_CC& set_list,
- const TPML_CC& clear_list,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const TPMI_ALG_HASH& audit_alg,
+ const TPML_CC& set_list,
+ const TPML_CC& clear_list,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(PCR_Extend,
- void(const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPML_DIGEST_VALUES& digests,
- AuthorizationDelegate* authorization_delegate,
- const PCR_ExtendResponse& callback));
+ void(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPML_DIGEST_VALUES& digests,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_ExtendResponse& callback));
MOCK_METHOD4(PCR_ExtendSync,
- TPM_RC(const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPML_DIGEST_VALUES& digests,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPML_DIGEST_VALUES& digests,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(PCR_Event,
- void(const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPM2B_EVENT& event_data,
- AuthorizationDelegate* authorization_delegate,
- const PCR_EventResponse& callback));
+ void(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPM2B_EVENT& event_data,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_EventResponse& callback));
MOCK_METHOD5(PCR_EventSync,
- TPM_RC(const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPM2B_EVENT& event_data,
- TPML_DIGEST_VALUES* digests,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPM2B_EVENT& event_data,
+ TPML_DIGEST_VALUES* digests,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD3(PCR_Read,
- void(const TPML_PCR_SELECTION& pcr_selection_in,
- AuthorizationDelegate* authorization_delegate,
- const PCR_ReadResponse& callback));
+ void(const TPML_PCR_SELECTION& pcr_selection_in,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_ReadResponse& callback));
MOCK_METHOD5(PCR_ReadSync,
- TPM_RC(const TPML_PCR_SELECTION& pcr_selection_in,
- UINT32* pcr_update_counter,
- TPML_PCR_SELECTION* pcr_selection_out,
- TPML_DIGEST* pcr_values,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPML_PCR_SELECTION& pcr_selection_in,
+ UINT32* pcr_update_counter,
+ TPML_PCR_SELECTION* pcr_selection_out,
+ TPML_DIGEST* pcr_values,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(PCR_Allocate,
- void(const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- const TPML_PCR_SELECTION& pcr_allocation,
- AuthorizationDelegate* authorization_delegate,
- const PCR_AllocateResponse& callback));
+ void(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ const TPML_PCR_SELECTION& pcr_allocation,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_AllocateResponse& callback));
MOCK_METHOD8(PCR_AllocateSync,
- TPM_RC(const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- const TPML_PCR_SELECTION& pcr_allocation,
- TPMI_YES_NO* allocation_success,
- UINT32* max_pcr,
- UINT32* size_needed,
- UINT32* size_available,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ const TPML_PCR_SELECTION& pcr_allocation,
+ TPMI_YES_NO* allocation_success,
+ UINT32* max_pcr,
+ UINT32* size_needed,
+ UINT32* size_available,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD8(PCR_SetAuthPolicy,
- void(const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_DH_PCR& pcr_num,
- const std::string& pcr_num_name,
- const TPM2B_DIGEST& auth_policy,
- const TPMI_ALG_HASH& policy_digest,
- AuthorizationDelegate* authorization_delegate,
- const PCR_SetAuthPolicyResponse& callback));
+ void(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_DH_PCR& pcr_num,
+ const std::string& pcr_num_name,
+ const TPM2B_DIGEST& auth_policy,
+ const TPMI_ALG_HASH& policy_digest,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_SetAuthPolicyResponse& callback));
MOCK_METHOD7(PCR_SetAuthPolicySync,
- TPM_RC(const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_DH_PCR& pcr_num,
- const std::string& pcr_num_name,
- const TPM2B_DIGEST& auth_policy,
- const TPMI_ALG_HASH& policy_digest,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_DH_PCR& pcr_num,
+ const std::string& pcr_num_name,
+ const TPM2B_DIGEST& auth_policy,
+ const TPMI_ALG_HASH& policy_digest,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(PCR_SetAuthValue,
- void(const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPM2B_DIGEST& auth,
- AuthorizationDelegate* authorization_delegate,
- const PCR_SetAuthValueResponse& callback));
+ void(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPM2B_DIGEST& auth,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_SetAuthValueResponse& callback));
MOCK_METHOD4(PCR_SetAuthValueSync,
- TPM_RC(const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPM2B_DIGEST& auth,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPM2B_DIGEST& auth,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD4(PCR_Reset,
- void(const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const PCR_ResetResponse& callback));
+ void(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_ResetResponse& callback));
MOCK_METHOD3(PCR_ResetSync,
- TPM_RC(const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ AuthorizationDelegate* authorization_delegate));
// Too many args to mock, forward to *Short version.
- void PolicySigned(
- const TPMI_DH_OBJECT& auth_object,
- const std::string& auth_object_name,
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_NONCE& nonce_tpm,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const INT32& expiration,
- const TPMT_SIGNATURE& auth,
- AuthorizationDelegate* authorization_delegate,
- const PolicySignedResponse& callback) override;
+ void PolicySigned(const TPMI_DH_OBJECT& auth_object,
+ const std::string& auth_object_name,
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_NONCE& nonce_tpm,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const INT32& expiration,
+ const TPMT_SIGNATURE& auth,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicySignedResponse& callback) override;
MOCK_METHOD9(PolicySignedShort,
- void(const TPMI_DH_OBJECT& auth_object,
- const TPMI_SH_POLICY& policy_session,
- const TPM2B_NONCE& nonce_tpm,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const INT32& expiration,
- const TPMT_SIGNATURE& auth,
- AuthorizationDelegate* authorization_delegate,
- const PolicySignedResponse& callback));
+ void(const TPMI_DH_OBJECT& auth_object,
+ const TPMI_SH_POLICY& policy_session,
+ const TPM2B_NONCE& nonce_tpm,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const INT32& expiration,
+ const TPMT_SIGNATURE& auth,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicySignedResponse& callback));
// Too many args to mock, forward to *Short version.
TPM_RC PolicySignedSync(
const TPMI_DH_OBJECT& auth_object,
@@ -879,27 +878,27 @@
TPMT_TK_AUTH* policy_ticket,
AuthorizationDelegate* authorization_delegate) override;
MOCK_METHOD10(PolicySignedSyncShort,
- TPM_RC(const TPMI_DH_OBJECT& auth_object,
- const TPMI_SH_POLICY& policy_session,
- const TPM2B_NONCE& nonce_tpm,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const INT32& expiration,
- const TPMT_SIGNATURE& auth,
- TPM2B_TIMEOUT* timeout,
- TPMT_TK_AUTH* policy_ticket,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& auth_object,
+ const TPMI_SH_POLICY& policy_session,
+ const TPM2B_NONCE& nonce_tpm,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const INT32& expiration,
+ const TPMT_SIGNATURE& auth,
+ TPM2B_TIMEOUT* timeout,
+ TPMT_TK_AUTH* policy_ticket,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD10(PolicySecret,
- void(const TPMI_DH_ENTITY& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_NONCE& nonce_tpm,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const INT32& expiration,
- AuthorizationDelegate* authorization_delegate,
- const PolicySecretResponse& callback));
+ void(const TPMI_DH_ENTITY& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_NONCE& nonce_tpm,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const INT32& expiration,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicySecretResponse& callback));
// Too many args to mock, forward to *Short version.
TPM_RC PolicySecretSync(
const TPMI_DH_ENTITY& auth_handle,
@@ -914,69 +913,69 @@
TPMT_TK_AUTH* policy_ticket,
AuthorizationDelegate* authorization_delegate) override;
MOCK_METHOD9(PolicySecretSyncShort,
- TPM_RC(const TPMI_DH_ENTITY& auth_handle,
- const TPMI_SH_POLICY& policy_session,
- const TPM2B_NONCE& nonce_tpm,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const INT32& expiration,
- TPM2B_TIMEOUT* timeout,
- TPMT_TK_AUTH* policy_ticket,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_ENTITY& auth_handle,
+ const TPMI_SH_POLICY& policy_session,
+ const TPM2B_NONCE& nonce_tpm,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const INT32& expiration,
+ TPM2B_TIMEOUT* timeout,
+ TPMT_TK_AUTH* policy_ticket,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD9(PolicyTicket,
- void(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_TIMEOUT& timeout,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const TPM2B_NAME& auth_name,
- const TPMT_TK_AUTH& ticket,
- AuthorizationDelegate* authorization_delegate,
- const PolicyTicketResponse& callback));
+ void(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_TIMEOUT& timeout,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const TPM2B_NAME& auth_name,
+ const TPMT_TK_AUTH& ticket,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyTicketResponse& callback));
MOCK_METHOD8(PolicyTicketSync,
- TPM_RC(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_TIMEOUT& timeout,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const TPM2B_NAME& auth_name,
- const TPMT_TK_AUTH& ticket,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_TIMEOUT& timeout,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const TPM2B_NAME& auth_name,
+ const TPMT_TK_AUTH& ticket,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(PolicyOR,
- void(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPML_DIGEST& p_hash_list,
- AuthorizationDelegate* authorization_delegate,
- const PolicyORResponse& callback));
+ void(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPML_DIGEST& p_hash_list,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyORResponse& callback));
MOCK_METHOD4(PolicyORSync,
- TPM_RC(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPML_DIGEST& p_hash_list,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPML_DIGEST& p_hash_list,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD6(PolicyPCR,
- void(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& pcr_digest,
- const TPML_PCR_SELECTION& pcrs,
- AuthorizationDelegate* authorization_delegate,
- const PolicyPCRResponse& callback));
+ void(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& pcr_digest,
+ const TPML_PCR_SELECTION& pcrs,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyPCRResponse& callback));
MOCK_METHOD5(PolicyPCRSync,
- TPM_RC(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& pcr_digest,
- const TPML_PCR_SELECTION& pcrs,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& pcr_digest,
+ const TPML_PCR_SELECTION& pcrs,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(PolicyLocality,
- void(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPMA_LOCALITY& locality,
- AuthorizationDelegate* authorization_delegate,
- const PolicyLocalityResponse& callback));
+ void(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPMA_LOCALITY& locality,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyLocalityResponse& callback));
MOCK_METHOD4(PolicyLocalitySync,
- TPM_RC(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPMA_LOCALITY& locality,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPMA_LOCALITY& locality,
+ AuthorizationDelegate* authorization_delegate));
// Too many args to mock, forward to *Short version.
void PolicyNV(const TPMI_RH_NV_AUTH& auth_handle,
const std::string& auth_handle_name,
@@ -990,162 +989,162 @@
AuthorizationDelegate* authorization_delegate,
const PolicyNVResponse& callback) override;
MOCK_METHOD8(PolicyNVShort,
- void(const TPMI_RH_NV_AUTH& auth_handle,
- const TPMI_RH_NV_INDEX& nv_index,
- const TPMI_SH_POLICY& policy_session,
- const TPM2B_OPERAND& operand_b,
- const UINT16& offset,
- const TPM_EO& operation,
- AuthorizationDelegate* authorization_delegate,
- const PolicyNVResponse& callback));
+ void(const TPMI_RH_NV_AUTH& auth_handle,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const TPMI_SH_POLICY& policy_session,
+ const TPM2B_OPERAND& operand_b,
+ const UINT16& offset,
+ const TPM_EO& operation,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyNVResponse& callback));
MOCK_METHOD10(PolicyNVSync,
- TPM_RC(const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_OPERAND& operand_b,
- const UINT16& offset,
- const TPM_EO& operation,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_OPERAND& operand_b,
+ const UINT16& offset,
+ const TPM_EO& operation,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD7(PolicyCounterTimer,
- void(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_OPERAND& operand_b,
- const UINT16& offset,
- const TPM_EO& operation,
- AuthorizationDelegate* authorization_delegate,
- const PolicyCounterTimerResponse& callback));
+ void(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_OPERAND& operand_b,
+ const UINT16& offset,
+ const TPM_EO& operation,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyCounterTimerResponse& callback));
MOCK_METHOD6(PolicyCounterTimerSync,
- TPM_RC(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_OPERAND& operand_b,
- const UINT16& offset,
- const TPM_EO& operation,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_OPERAND& operand_b,
+ const UINT16& offset,
+ const TPM_EO& operation,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(PolicyCommandCode,
- void(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM_CC& code,
- AuthorizationDelegate* authorization_delegate,
- const PolicyCommandCodeResponse& callback));
+ void(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM_CC& code,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyCommandCodeResponse& callback));
MOCK_METHOD4(PolicyCommandCodeSync,
- TPM_RC(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM_CC& code,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM_CC& code,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD4(PolicyPhysicalPresence,
- void(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- AuthorizationDelegate* authorization_delegate,
- const PolicyPhysicalPresenceResponse& callback));
+ void(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyPhysicalPresenceResponse& callback));
MOCK_METHOD3(PolicyPhysicalPresenceSync,
- TPM_RC(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(PolicyCpHash,
- void(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& cp_hash_a,
- AuthorizationDelegate* authorization_delegate,
- const PolicyCpHashResponse& callback));
+ void(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& cp_hash_a,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyCpHashResponse& callback));
MOCK_METHOD4(PolicyCpHashSync,
- TPM_RC(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& cp_hash_a,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& cp_hash_a,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(PolicyNameHash,
- void(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& name_hash,
- AuthorizationDelegate* authorization_delegate,
- const PolicyNameHashResponse& callback));
+ void(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& name_hash,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyNameHashResponse& callback));
MOCK_METHOD4(PolicyNameHashSync,
- TPM_RC(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& name_hash,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& name_hash,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD7(PolicyDuplicationSelect,
- void(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_NAME& object_name,
- const TPM2B_NAME& new_parent_name,
- const TPMI_YES_NO& include_object,
- AuthorizationDelegate* authorization_delegate,
- const PolicyDuplicationSelectResponse& callback));
+ void(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_NAME& object_name,
+ const TPM2B_NAME& new_parent_name,
+ const TPMI_YES_NO& include_object,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyDuplicationSelectResponse& callback));
MOCK_METHOD6(PolicyDuplicationSelectSync,
- TPM_RC(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_NAME& object_name,
- const TPM2B_NAME& new_parent_name,
- const TPMI_YES_NO& include_object,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_NAME& object_name,
+ const TPM2B_NAME& new_parent_name,
+ const TPMI_YES_NO& include_object,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD8(PolicyAuthorize,
- void(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& approved_policy,
- const TPM2B_NONCE& policy_ref,
- const TPM2B_NAME& key_sign,
- const TPMT_TK_VERIFIED& check_ticket,
- AuthorizationDelegate* authorization_delegate,
- const PolicyAuthorizeResponse& callback));
+ void(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& approved_policy,
+ const TPM2B_NONCE& policy_ref,
+ const TPM2B_NAME& key_sign,
+ const TPMT_TK_VERIFIED& check_ticket,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyAuthorizeResponse& callback));
MOCK_METHOD7(PolicyAuthorizeSync,
- TPM_RC(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& approved_policy,
- const TPM2B_NONCE& policy_ref,
- const TPM2B_NAME& key_sign,
- const TPMT_TK_VERIFIED& check_ticket,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& approved_policy,
+ const TPM2B_NONCE& policy_ref,
+ const TPM2B_NAME& key_sign,
+ const TPMT_TK_VERIFIED& check_ticket,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD4(PolicyAuthValue,
- void(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- AuthorizationDelegate* authorization_delegate,
- const PolicyAuthValueResponse& callback));
+ void(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyAuthValueResponse& callback));
MOCK_METHOD3(PolicyAuthValueSync,
- TPM_RC(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD4(PolicyPassword,
- void(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- AuthorizationDelegate* authorization_delegate,
- const PolicyPasswordResponse& callback));
+ void(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyPasswordResponse& callback));
MOCK_METHOD3(PolicyPasswordSync,
- TPM_RC(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD4(PolicyGetDigest,
- void(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- AuthorizationDelegate* authorization_delegate,
- const PolicyGetDigestResponse& callback));
+ void(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyGetDigestResponse& callback));
MOCK_METHOD4(PolicyGetDigestSync,
- TPM_RC(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- TPM2B_DIGEST* policy_digest,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ TPM2B_DIGEST* policy_digest,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(PolicyNvWritten,
- void(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPMI_YES_NO& written_set,
- AuthorizationDelegate* authorization_delegate,
- const PolicyNvWrittenResponse& callback));
+ void(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPMI_YES_NO& written_set,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyNvWrittenResponse& callback));
MOCK_METHOD4(PolicyNvWrittenSync,
- TPM_RC(const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPMI_YES_NO& written_set,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPMI_YES_NO& written_set,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD8(CreatePrimary,
- void(const TPMI_RH_HIERARCHY& primary_handle,
- const std::string& primary_handle_name,
- const TPM2B_SENSITIVE_CREATE& in_sensitive,
- const TPM2B_PUBLIC& in_public,
- const TPM2B_DATA& outside_info,
- const TPML_PCR_SELECTION& creation_pcr,
- AuthorizationDelegate* authorization_delegate,
- const CreatePrimaryResponse& callback));
+ void(const TPMI_RH_HIERARCHY& primary_handle,
+ const std::string& primary_handle_name,
+ const TPM2B_SENSITIVE_CREATE& in_sensitive,
+ const TPM2B_PUBLIC& in_public,
+ const TPM2B_DATA& outside_info,
+ const TPML_PCR_SELECTION& creation_pcr,
+ AuthorizationDelegate* authorization_delegate,
+ const CreatePrimaryResponse& callback));
// Too many args to mock, forward to *Short version.
TPM_RC CreatePrimarySync(
const TPMI_RH_HIERARCHY& primary_handle,
@@ -1162,435 +1161,435 @@
TPM2B_NAME* name,
AuthorizationDelegate* authorization_delegate) override;
MOCK_METHOD10(CreatePrimarySyncShort,
- TPM_RC(const TPMI_RH_HIERARCHY& primary_handle,
- const TPM2B_PUBLIC& in_public,
- const TPML_PCR_SELECTION& creation_pcr,
- TPM_HANDLE* object_handle,
- TPM2B_PUBLIC* out_public,
- TPM2B_CREATION_DATA* creation_data,
- TPM2B_DIGEST* creation_hash,
- TPMT_TK_CREATION* creation_ticket,
- TPM2B_NAME* name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_HIERARCHY& primary_handle,
+ const TPM2B_PUBLIC& in_public,
+ const TPML_PCR_SELECTION& creation_pcr,
+ TPM_HANDLE* object_handle,
+ TPM2B_PUBLIC* out_public,
+ TPM2B_CREATION_DATA* creation_data,
+ TPM2B_DIGEST* creation_hash,
+ TPMT_TK_CREATION* creation_ticket,
+ TPM2B_NAME* name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD6(HierarchyControl,
- void(const TPMI_RH_HIERARCHY& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_ENABLES& enable,
- const TPMI_YES_NO& state,
- AuthorizationDelegate* authorization_delegate,
- const HierarchyControlResponse& callback));
+ void(const TPMI_RH_HIERARCHY& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_ENABLES& enable,
+ const TPMI_YES_NO& state,
+ AuthorizationDelegate* authorization_delegate,
+ const HierarchyControlResponse& callback));
MOCK_METHOD5(HierarchyControlSync,
- TPM_RC(const TPMI_RH_HIERARCHY& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_ENABLES& enable,
- const TPMI_YES_NO& state,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_HIERARCHY& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_ENABLES& enable,
+ const TPMI_YES_NO& state,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD6(SetPrimaryPolicy,
- void(const TPMI_RH_HIERARCHY& auth_handle,
- const std::string& auth_handle_name,
- const TPM2B_DIGEST& auth_policy,
- const TPMI_ALG_HASH& hash_alg,
- AuthorizationDelegate* authorization_delegate,
- const SetPrimaryPolicyResponse& callback));
+ void(const TPMI_RH_HIERARCHY& auth_handle,
+ const std::string& auth_handle_name,
+ const TPM2B_DIGEST& auth_policy,
+ const TPMI_ALG_HASH& hash_alg,
+ AuthorizationDelegate* authorization_delegate,
+ const SetPrimaryPolicyResponse& callback));
MOCK_METHOD5(SetPrimaryPolicySync,
- TPM_RC(const TPMI_RH_HIERARCHY& auth_handle,
- const std::string& auth_handle_name,
- const TPM2B_DIGEST& auth_policy,
- const TPMI_ALG_HASH& hash_alg,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_HIERARCHY& auth_handle,
+ const std::string& auth_handle_name,
+ const TPM2B_DIGEST& auth_policy,
+ const TPMI_ALG_HASH& hash_alg,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD4(ChangePPS,
- void(const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const ChangePPSResponse& callback));
+ void(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const ChangePPSResponse& callback));
MOCK_METHOD3(ChangePPSSync,
- TPM_RC(const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD4(ChangeEPS,
- void(const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const ChangeEPSResponse& callback));
+ void(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const ChangeEPSResponse& callback));
MOCK_METHOD3(ChangeEPSSync,
- TPM_RC(const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD4(Clear,
- void(const TPMI_RH_CLEAR& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const ClearResponse& callback));
+ void(const TPMI_RH_CLEAR& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const ClearResponse& callback));
MOCK_METHOD3(ClearSync,
- TPM_RC(const TPMI_RH_CLEAR& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_CLEAR& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(ClearControl,
- void(const TPMI_RH_CLEAR& auth,
- const std::string& auth_name,
- const TPMI_YES_NO& disable,
- AuthorizationDelegate* authorization_delegate,
- const ClearControlResponse& callback));
+ void(const TPMI_RH_CLEAR& auth,
+ const std::string& auth_name,
+ const TPMI_YES_NO& disable,
+ AuthorizationDelegate* authorization_delegate,
+ const ClearControlResponse& callback));
MOCK_METHOD4(ClearControlSync,
- TPM_RC(const TPMI_RH_CLEAR& auth,
- const std::string& auth_name,
- const TPMI_YES_NO& disable,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_CLEAR& auth,
+ const std::string& auth_name,
+ const TPMI_YES_NO& disable,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(HierarchyChangeAuth,
- void(const TPMI_RH_HIERARCHY_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPM2B_AUTH& new_auth,
- AuthorizationDelegate* authorization_delegate,
- const HierarchyChangeAuthResponse& callback));
+ void(const TPMI_RH_HIERARCHY_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPM2B_AUTH& new_auth,
+ AuthorizationDelegate* authorization_delegate,
+ const HierarchyChangeAuthResponse& callback));
MOCK_METHOD4(HierarchyChangeAuthSync,
- TPM_RC(const TPMI_RH_HIERARCHY_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPM2B_AUTH& new_auth,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_HIERARCHY_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPM2B_AUTH& new_auth,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD4(DictionaryAttackLockReset,
- void(const TPMI_RH_LOCKOUT& lock_handle,
- const std::string& lock_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const DictionaryAttackLockResetResponse& callback));
+ void(const TPMI_RH_LOCKOUT& lock_handle,
+ const std::string& lock_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const DictionaryAttackLockResetResponse& callback));
MOCK_METHOD3(DictionaryAttackLockResetSync,
- TPM_RC(const TPMI_RH_LOCKOUT& lock_handle,
- const std::string& lock_handle_name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_LOCKOUT& lock_handle,
+ const std::string& lock_handle_name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD7(DictionaryAttackParameters,
- void(const TPMI_RH_LOCKOUT& lock_handle,
- const std::string& lock_handle_name,
- const UINT32& new_max_tries,
- const UINT32& new_recovery_time,
- const UINT32& lockout_recovery,
- AuthorizationDelegate* authorization_delegate,
- const DictionaryAttackParametersResponse& callback));
+ void(const TPMI_RH_LOCKOUT& lock_handle,
+ const std::string& lock_handle_name,
+ const UINT32& new_max_tries,
+ const UINT32& new_recovery_time,
+ const UINT32& lockout_recovery,
+ AuthorizationDelegate* authorization_delegate,
+ const DictionaryAttackParametersResponse& callback));
MOCK_METHOD6(DictionaryAttackParametersSync,
- TPM_RC(const TPMI_RH_LOCKOUT& lock_handle,
- const std::string& lock_handle_name,
- const UINT32& new_max_tries,
- const UINT32& new_recovery_time,
- const UINT32& lockout_recovery,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_LOCKOUT& lock_handle,
+ const std::string& lock_handle_name,
+ const UINT32& new_max_tries,
+ const UINT32& new_recovery_time,
+ const UINT32& lockout_recovery,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD6(PP_Commands,
- void(const TPMI_RH_PLATFORM& auth,
- const std::string& auth_name,
- const TPML_CC& set_list,
- const TPML_CC& clear_list,
- AuthorizationDelegate* authorization_delegate,
- const PP_CommandsResponse& callback));
+ void(const TPMI_RH_PLATFORM& auth,
+ const std::string& auth_name,
+ const TPML_CC& set_list,
+ const TPML_CC& clear_list,
+ AuthorizationDelegate* authorization_delegate,
+ const PP_CommandsResponse& callback));
MOCK_METHOD5(PP_CommandsSync,
- TPM_RC(const TPMI_RH_PLATFORM& auth,
- const std::string& auth_name,
- const TPML_CC& set_list,
- const TPML_CC& clear_list,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_PLATFORM& auth,
+ const std::string& auth_name,
+ const TPML_CC& set_list,
+ const TPML_CC& clear_list,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(SetAlgorithmSet,
- void(const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- const UINT32& algorithm_set,
- AuthorizationDelegate* authorization_delegate,
- const SetAlgorithmSetResponse& callback));
+ void(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ const UINT32& algorithm_set,
+ AuthorizationDelegate* authorization_delegate,
+ const SetAlgorithmSetResponse& callback));
MOCK_METHOD4(SetAlgorithmSetSync,
- TPM_RC(const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- const UINT32& algorithm_set,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ const UINT32& algorithm_set,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD8(FieldUpgradeStart,
- void(const TPMI_RH_PLATFORM& authorization,
- const std::string& authorization_name,
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& fu_digest,
- const TPMT_SIGNATURE& manifest_signature,
- AuthorizationDelegate* authorization_delegate,
- const FieldUpgradeStartResponse& callback));
+ void(const TPMI_RH_PLATFORM& authorization,
+ const std::string& authorization_name,
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& fu_digest,
+ const TPMT_SIGNATURE& manifest_signature,
+ AuthorizationDelegate* authorization_delegate,
+ const FieldUpgradeStartResponse& callback));
MOCK_METHOD7(FieldUpgradeStartSync,
- TPM_RC(const TPMI_RH_PLATFORM& authorization,
- const std::string& authorization_name,
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& fu_digest,
- const TPMT_SIGNATURE& manifest_signature,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_PLATFORM& authorization,
+ const std::string& authorization_name,
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& fu_digest,
+ const TPMT_SIGNATURE& manifest_signature,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD3(FieldUpgradeData,
- void(const TPM2B_MAX_BUFFER& fu_data,
- AuthorizationDelegate* authorization_delegate,
- const FieldUpgradeDataResponse& callback));
+ void(const TPM2B_MAX_BUFFER& fu_data,
+ AuthorizationDelegate* authorization_delegate,
+ const FieldUpgradeDataResponse& callback));
MOCK_METHOD4(FieldUpgradeDataSync,
- TPM_RC(const TPM2B_MAX_BUFFER& fu_data,
- TPMT_HA* next_digest,
- TPMT_HA* first_digest,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPM2B_MAX_BUFFER& fu_data,
+ TPMT_HA* next_digest,
+ TPMT_HA* first_digest,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD3(FirmwareRead,
- void(const UINT32& sequence_number,
- AuthorizationDelegate* authorization_delegate,
- const FirmwareReadResponse& callback));
+ void(const UINT32& sequence_number,
+ AuthorizationDelegate* authorization_delegate,
+ const FirmwareReadResponse& callback));
MOCK_METHOD3(FirmwareReadSync,
- TPM_RC(const UINT32& sequence_number,
- TPM2B_MAX_BUFFER* fu_data,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const UINT32& sequence_number,
+ TPM2B_MAX_BUFFER* fu_data,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD4(ContextSave,
- void(const TPMI_DH_CONTEXT& save_handle,
- const std::string& save_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const ContextSaveResponse& callback));
+ void(const TPMI_DH_CONTEXT& save_handle,
+ const std::string& save_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const ContextSaveResponse& callback));
MOCK_METHOD4(ContextSaveSync,
- TPM_RC(const TPMI_DH_CONTEXT& save_handle,
- const std::string& save_handle_name,
- TPMS_CONTEXT* context,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_CONTEXT& save_handle,
+ const std::string& save_handle_name,
+ TPMS_CONTEXT* context,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD3(ContextLoad,
- void(const TPMS_CONTEXT& context,
- AuthorizationDelegate* authorization_delegate,
- const ContextLoadResponse& callback));
+ void(const TPMS_CONTEXT& context,
+ AuthorizationDelegate* authorization_delegate,
+ const ContextLoadResponse& callback));
MOCK_METHOD3(ContextLoadSync,
- TPM_RC(const TPMS_CONTEXT& context,
- TPMI_DH_CONTEXT* loaded_handle,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMS_CONTEXT& context,
+ TPMI_DH_CONTEXT* loaded_handle,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD3(FlushContext,
- void(const TPMI_DH_CONTEXT& flush_handle,
- AuthorizationDelegate* authorization_delegate,
- const FlushContextResponse& callback));
+ void(const TPMI_DH_CONTEXT& flush_handle,
+ AuthorizationDelegate* authorization_delegate,
+ const FlushContextResponse& callback));
MOCK_METHOD2(FlushContextSync,
- TPM_RC(const TPMI_DH_CONTEXT& flush_handle,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_CONTEXT& flush_handle,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD7(EvictControl,
- void(const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_PERSISTENT& persistent_handle,
- AuthorizationDelegate* authorization_delegate,
- const EvictControlResponse& callback));
+ void(const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_PERSISTENT& persistent_handle,
+ AuthorizationDelegate* authorization_delegate,
+ const EvictControlResponse& callback));
MOCK_METHOD6(EvictControlSync,
- TPM_RC(const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_PERSISTENT& persistent_handle,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_PERSISTENT& persistent_handle,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD2(ReadClock,
- void(AuthorizationDelegate* authorization_delegate,
- const ReadClockResponse& callback));
+ void(AuthorizationDelegate* authorization_delegate,
+ const ReadClockResponse& callback));
MOCK_METHOD2(ReadClockSync,
- TPM_RC(TPMS_TIME_INFO* current_time,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(TPMS_TIME_INFO* current_time,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(ClockSet,
- void(const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const UINT64& new_time,
- AuthorizationDelegate* authorization_delegate,
- const ClockSetResponse& callback));
+ void(const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const UINT64& new_time,
+ AuthorizationDelegate* authorization_delegate,
+ const ClockSetResponse& callback));
MOCK_METHOD4(ClockSetSync,
- TPM_RC(const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const UINT64& new_time,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const UINT64& new_time,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(ClockRateAdjust,
- void(const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const TPM_CLOCK_ADJUST& rate_adjust,
- AuthorizationDelegate* authorization_delegate,
- const ClockRateAdjustResponse& callback));
+ void(const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const TPM_CLOCK_ADJUST& rate_adjust,
+ AuthorizationDelegate* authorization_delegate,
+ const ClockRateAdjustResponse& callback));
MOCK_METHOD4(ClockRateAdjustSync,
- TPM_RC(const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const TPM_CLOCK_ADJUST& rate_adjust,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const TPM_CLOCK_ADJUST& rate_adjust,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(GetCapability,
- void(const TPM_CAP& capability,
- const UINT32& property,
- const UINT32& property_count,
- AuthorizationDelegate* authorization_delegate,
- const GetCapabilityResponse& callback));
+ void(const TPM_CAP& capability,
+ const UINT32& property,
+ const UINT32& property_count,
+ AuthorizationDelegate* authorization_delegate,
+ const GetCapabilityResponse& callback));
MOCK_METHOD6(GetCapabilitySync,
- TPM_RC(const TPM_CAP& capability,
- const UINT32& property,
- const UINT32& property_count,
- TPMI_YES_NO* more_data,
- TPMS_CAPABILITY_DATA* capability_data,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPM_CAP& capability,
+ const UINT32& property,
+ const UINT32& property_count,
+ TPMI_YES_NO* more_data,
+ TPMS_CAPABILITY_DATA* capability_data,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD3(TestParms,
- void(const TPMT_PUBLIC_PARMS& parameters,
- AuthorizationDelegate* authorization_delegate,
- const TestParmsResponse& callback));
+ void(const TPMT_PUBLIC_PARMS& parameters,
+ AuthorizationDelegate* authorization_delegate,
+ const TestParmsResponse& callback));
MOCK_METHOD2(TestParmsSync,
- TPM_RC(const TPMT_PUBLIC_PARMS& parameters,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMT_PUBLIC_PARMS& parameters,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD6(NV_DefineSpace,
- void(const TPMI_RH_PROVISION& auth_handle,
- const std::string& auth_handle_name,
- const TPM2B_AUTH& auth,
- const TPM2B_NV_PUBLIC& public_info,
- AuthorizationDelegate* authorization_delegate,
- const NV_DefineSpaceResponse& callback));
+ void(const TPMI_RH_PROVISION& auth_handle,
+ const std::string& auth_handle_name,
+ const TPM2B_AUTH& auth,
+ const TPM2B_NV_PUBLIC& public_info,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_DefineSpaceResponse& callback));
MOCK_METHOD5(NV_DefineSpaceSync,
- TPM_RC(const TPMI_RH_PROVISION& auth_handle,
- const std::string& auth_handle_name,
- const TPM2B_AUTH& auth,
- const TPM2B_NV_PUBLIC& public_info,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_PROVISION& auth_handle,
+ const std::string& auth_handle_name,
+ const TPM2B_AUTH& auth,
+ const TPM2B_NV_PUBLIC& public_info,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD6(NV_UndefineSpace,
- void(const TPMI_RH_PROVISION& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_UndefineSpaceResponse& callback));
+ void(const TPMI_RH_PROVISION& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_UndefineSpaceResponse& callback));
MOCK_METHOD5(NV_UndefineSpaceSync,
- TPM_RC(const TPMI_RH_PROVISION& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_PROVISION& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD6(NV_UndefineSpaceSpecial,
- void(const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPMI_RH_PLATFORM& platform,
- const std::string& platform_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_UndefineSpaceSpecialResponse& callback));
+ void(const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPMI_RH_PLATFORM& platform,
+ const std::string& platform_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_UndefineSpaceSpecialResponse& callback));
MOCK_METHOD5(NV_UndefineSpaceSpecialSync,
- TPM_RC(const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPMI_RH_PLATFORM& platform,
- const std::string& platform_name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPMI_RH_PLATFORM& platform,
+ const std::string& platform_name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD4(NV_ReadPublic,
- void(const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_ReadPublicResponse& callback));
+ void(const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_ReadPublicResponse& callback));
MOCK_METHOD5(NV_ReadPublicSync,
- TPM_RC(const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- TPM2B_NV_PUBLIC* nv_public,
- TPM2B_NAME* nv_name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ TPM2B_NV_PUBLIC* nv_public,
+ TPM2B_NAME* nv_name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD8(NV_Write,
- void(const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_MAX_NV_BUFFER& data,
- const UINT16& offset,
- AuthorizationDelegate* authorization_delegate,
- const NV_WriteResponse& callback));
+ void(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_MAX_NV_BUFFER& data,
+ const UINT16& offset,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_WriteResponse& callback));
MOCK_METHOD7(NV_WriteSync,
- TPM_RC(const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_MAX_NV_BUFFER& data,
- const UINT16& offset,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_MAX_NV_BUFFER& data,
+ const UINT16& offset,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD6(NV_Increment,
- void(const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_IncrementResponse& callback));
+ void(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_IncrementResponse& callback));
MOCK_METHOD5(NV_IncrementSync,
- TPM_RC(const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD7(NV_Extend,
- void(const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_MAX_NV_BUFFER& data,
- AuthorizationDelegate* authorization_delegate,
- const NV_ExtendResponse& callback));
+ void(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_MAX_NV_BUFFER& data,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_ExtendResponse& callback));
MOCK_METHOD6(NV_ExtendSync,
- TPM_RC(const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_MAX_NV_BUFFER& data,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_MAX_NV_BUFFER& data,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD7(NV_SetBits,
- void(const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const UINT64& bits,
- AuthorizationDelegate* authorization_delegate,
- const NV_SetBitsResponse& callback));
+ void(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const UINT64& bits,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_SetBitsResponse& callback));
MOCK_METHOD6(NV_SetBitsSync,
- TPM_RC(const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const UINT64& bits,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const UINT64& bits,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD6(NV_WriteLock,
- void(const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_WriteLockResponse& callback));
+ void(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_WriteLockResponse& callback));
MOCK_METHOD5(NV_WriteLockSync,
- TPM_RC(const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD4(NV_GlobalWriteLock,
- void(const TPMI_RH_PROVISION& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_GlobalWriteLockResponse& callback));
+ void(const TPMI_RH_PROVISION& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_GlobalWriteLockResponse& callback));
MOCK_METHOD3(NV_GlobalWriteLockSync,
- TPM_RC(const TPMI_RH_PROVISION& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_PROVISION& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD8(NV_Read,
- void(const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const UINT16& size,
- const UINT16& offset,
- AuthorizationDelegate* authorization_delegate,
- const NV_ReadResponse& callback));
+ void(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const UINT16& size,
+ const UINT16& offset,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_ReadResponse& callback));
MOCK_METHOD8(NV_ReadSync,
- TPM_RC(const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const UINT16& size,
- const UINT16& offset,
- TPM2B_MAX_NV_BUFFER* data,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const UINT16& size,
+ const UINT16& offset,
+ TPM2B_MAX_NV_BUFFER* data,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD6(NV_ReadLock,
- void(const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_ReadLockResponse& callback));
+ void(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_ReadLockResponse& callback));
MOCK_METHOD5(NV_ReadLockSync,
- TPM_RC(const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate));
MOCK_METHOD5(NV_ChangeAuth,
- void(const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_AUTH& new_auth,
- AuthorizationDelegate* authorization_delegate,
- const NV_ChangeAuthResponse& callback));
+ void(const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_AUTH& new_auth,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_ChangeAuthResponse& callback));
MOCK_METHOD4(NV_ChangeAuthSync,
- TPM_RC(const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_AUTH& new_auth,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_AUTH& new_auth,
+ AuthorizationDelegate* authorization_delegate));
// Too many args to mock, forward to *Short version.
void NV_Certify(const TPMI_DH_OBJECT& sign_handle,
const std::string& sign_handle_name,
@@ -1605,41 +1604,40 @@
AuthorizationDelegate* authorization_delegate,
const NV_CertifyResponse& callback) override;
MOCK_METHOD9(NV_CertifyShort,
- void(const TPMI_DH_OBJECT& sign_handle,
- const TPMI_RH_NV_AUTH& auth_handle,
- const TPMI_RH_NV_INDEX& nv_index,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- const UINT16& size,
- const UINT16& offset,
- AuthorizationDelegate* authorization_delegate,
- const NV_CertifyResponse& callback));
+ void(const TPMI_DH_OBJECT& sign_handle,
+ const TPMI_RH_NV_AUTH& auth_handle,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const UINT16& size,
+ const UINT16& offset,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_CertifyResponse& callback));
// Too many args to mock, forward to *Short version.
- TPM_RC NV_CertifySync(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- const UINT16& size,
- const UINT16& offset,
- TPM2B_ATTEST* certify_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate) override;
+ TPM_RC NV_CertifySync(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const UINT16& size,
+ const UINT16& offset,
+ TPM2B_ATTEST* certify_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate) override;
MOCK_METHOD10(NV_CertifySyncShort,
- TPM_RC(const TPMI_DH_OBJECT& sign_handle,
- const TPMI_RH_NV_AUTH& auth_handle,
- const TPMI_RH_NV_INDEX& nv_index,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- const UINT16& size,
- const UINT16& offset,
- TPM2B_ATTEST* certify_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate));
+ TPM_RC(const TPMI_DH_OBJECT& sign_handle,
+ const TPMI_RH_NV_AUTH& auth_handle,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const UINT16& size,
+ const UINT16& offset,
+ TPM2B_ATTEST* certify_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate));
};
} // namespace trunks
diff --git a/trunks/mock_tpm_utility.h b/trunks/mock_tpm_utility.h
index 1fa7fce..833e6b5 100644
--- a/trunks/mock_tpm_utility.h
+++ b/trunks/mock_tpm_utility.h
@@ -35,95 +35,94 @@
MOCK_METHOD0(Shutdown, void());
MOCK_METHOD0(InitializeTpm, TPM_RC());
MOCK_METHOD1(AllocatePCR, TPM_RC(const std::string&));
- MOCK_METHOD3(TakeOwnership, TPM_RC(const std::string&,
- const std::string&,
- const std::string&));
+ MOCK_METHOD3(TakeOwnership,
+ TPM_RC(const std::string&,
+ const std::string&,
+ const std::string&));
MOCK_METHOD2(StirRandom, TPM_RC(const std::string&, AuthorizationDelegate*));
- MOCK_METHOD3(GenerateRandom, TPM_RC(size_t,
- AuthorizationDelegate*,
- std::string*));
+ MOCK_METHOD3(GenerateRandom,
+ TPM_RC(size_t, AuthorizationDelegate*, std::string*));
MOCK_METHOD3(ExtendPCR,
TPM_RC(int, const std::string&, AuthorizationDelegate*));
MOCK_METHOD2(ReadPCR, TPM_RC(int, std::string*));
- MOCK_METHOD6(AsymmetricEncrypt, TPM_RC(TPM_HANDLE,
- TPM_ALG_ID,
- TPM_ALG_ID,
- const std::string&,
- AuthorizationDelegate*,
- std::string*));
- MOCK_METHOD6(AsymmetricDecrypt, TPM_RC(TPM_HANDLE,
- TPM_ALG_ID,
- TPM_ALG_ID,
- const std::string&,
- AuthorizationDelegate*,
- std::string*));
- MOCK_METHOD6(Sign, TPM_RC(TPM_HANDLE,
- TPM_ALG_ID,
- TPM_ALG_ID,
- const std::string&,
- AuthorizationDelegate*,
- std::string*));
- MOCK_METHOD6(Verify, TPM_RC(TPM_HANDLE,
- TPM_ALG_ID,
- TPM_ALG_ID,
- const std::string&,
- const std::string&,
- AuthorizationDelegate*));
- MOCK_METHOD2(CertifyCreation, TPM_RC(TPM_HANDLE,
- const std::string&));
- MOCK_METHOD4(ChangeKeyAuthorizationData, TPM_RC(TPM_HANDLE,
- const std::string&,
- AuthorizationDelegate*,
- std::string*));
- MOCK_METHOD7(ImportRSAKey, TPM_RC(AsymmetricKeyUsage,
- const std::string&,
- uint32_t,
- const std::string&,
- const std::string&,
- AuthorizationDelegate*,
- std::string*));
- MOCK_METHOD10(CreateRSAKeyPair, TPM_RC(AsymmetricKeyUsage,
- int,
- uint32_t,
- const std::string&,
- const std::string&,
- bool,
- int,
- AuthorizationDelegate*,
- std::string*,
- std::string*));
- MOCK_METHOD3(LoadKey, TPM_RC(const std::string&,
- AuthorizationDelegate*,
- TPM_HANDLE*));
+ MOCK_METHOD6(AsymmetricEncrypt,
+ TPM_RC(TPM_HANDLE,
+ TPM_ALG_ID,
+ TPM_ALG_ID,
+ const std::string&,
+ AuthorizationDelegate*,
+ std::string*));
+ MOCK_METHOD6(AsymmetricDecrypt,
+ TPM_RC(TPM_HANDLE,
+ TPM_ALG_ID,
+ TPM_ALG_ID,
+ const std::string&,
+ AuthorizationDelegate*,
+ std::string*));
+ MOCK_METHOD6(Sign,
+ TPM_RC(TPM_HANDLE,
+ TPM_ALG_ID,
+ TPM_ALG_ID,
+ const std::string&,
+ AuthorizationDelegate*,
+ std::string*));
+ MOCK_METHOD6(Verify,
+ TPM_RC(TPM_HANDLE,
+ TPM_ALG_ID,
+ TPM_ALG_ID,
+ const std::string&,
+ const std::string&,
+ AuthorizationDelegate*));
+ MOCK_METHOD2(CertifyCreation, TPM_RC(TPM_HANDLE, const std::string&));
+ MOCK_METHOD4(ChangeKeyAuthorizationData,
+ TPM_RC(TPM_HANDLE,
+ const std::string&,
+ AuthorizationDelegate*,
+ std::string*));
+ MOCK_METHOD7(ImportRSAKey,
+ TPM_RC(AsymmetricKeyUsage,
+ const std::string&,
+ uint32_t,
+ const std::string&,
+ const std::string&,
+ AuthorizationDelegate*,
+ std::string*));
+ MOCK_METHOD10(CreateRSAKeyPair,
+ TPM_RC(AsymmetricKeyUsage,
+ int,
+ uint32_t,
+ const std::string&,
+ const std::string&,
+ bool,
+ int,
+ AuthorizationDelegate*,
+ std::string*,
+ std::string*));
+ MOCK_METHOD3(LoadKey,
+ TPM_RC(const std::string&, AuthorizationDelegate*, TPM_HANDLE*));
MOCK_METHOD2(GetKeyName, TPM_RC(TPM_HANDLE, std::string*));
MOCK_METHOD2(GetKeyPublicArea, TPM_RC(TPM_HANDLE, TPMT_PUBLIC*));
- MOCK_METHOD4(SealData, TPM_RC(const std::string&,
- const std::string&,
- AuthorizationDelegate*,
- std::string*));
- MOCK_METHOD3(UnsealData, TPM_RC(const std::string&,
- AuthorizationDelegate*,
- std::string*));
+ MOCK_METHOD4(SealData,
+ TPM_RC(const std::string&,
+ const std::string&,
+ AuthorizationDelegate*,
+ std::string*));
+ MOCK_METHOD3(UnsealData,
+ TPM_RC(const std::string&,
+ AuthorizationDelegate*,
+ std::string*));
MOCK_METHOD1(StartSession, TPM_RC(HmacSession*));
- MOCK_METHOD3(GetPolicyDigestForPcrValue, TPM_RC(int,
- const std::string&,
- std::string*));
- MOCK_METHOD3(DefineNVSpace, TPM_RC(uint32_t,
- size_t,
- AuthorizationDelegate*));
- MOCK_METHOD2(DestroyNVSpace, TPM_RC(uint32_t,
- AuthorizationDelegate*));
- MOCK_METHOD2(LockNVSpace, TPM_RC(uint32_t,
- AuthorizationDelegate*));
- MOCK_METHOD4(WriteNVSpace, TPM_RC(uint32_t,
- uint32_t,
- const std::string&,
- AuthorizationDelegate*));
- MOCK_METHOD5(ReadNVSpace, TPM_RC(uint32_t,
- uint32_t,
- size_t,
- std::string*,
- AuthorizationDelegate*));
+ MOCK_METHOD3(GetPolicyDigestForPcrValue,
+ TPM_RC(int, const std::string&, std::string*));
+ MOCK_METHOD3(DefineNVSpace, TPM_RC(uint32_t, size_t, AuthorizationDelegate*));
+ MOCK_METHOD2(DestroyNVSpace, TPM_RC(uint32_t, AuthorizationDelegate*));
+ MOCK_METHOD2(LockNVSpace, TPM_RC(uint32_t, AuthorizationDelegate*));
+ MOCK_METHOD4(
+ WriteNVSpace,
+ TPM_RC(uint32_t, uint32_t, const std::string&, AuthorizationDelegate*));
+ MOCK_METHOD5(
+ ReadNVSpace,
+ TPM_RC(uint32_t, uint32_t, size_t, std::string*, AuthorizationDelegate*));
MOCK_METHOD2(GetNVSpaceName, TPM_RC(uint32_t, std::string*));
MOCK_METHOD2(GetNVSpacePublicArea, TPM_RC(uint32_t, TPMS_NV_PUBLIC*));
};
diff --git a/trunks/password_authorization_delegate_test.cc b/trunks/password_authorization_delegate_test.cc
index 2bdcbb0..0b3a445 100644
--- a/trunks/password_authorization_delegate_test.cc
+++ b/trunks/password_authorization_delegate_test.cc
@@ -33,18 +33,18 @@
// delegate. It compared the serialized structure generated by the delegate
// to the expected authorization string.
TEST(PasswordAuthorizationDelegateTest, SerializationTest) {
- std::string expected_auth("\x40\x00\x00\x09" // session_handle = TPM_RS_PW
- "\x00\x00" // nonce = zero length buffer
- "\x01" // session_attributes = continueSession
- "\x00\x06" // password length
- "secret", // password
- 15);
+ std::string expected_auth(
+ "\x40\x00\x00\x09" // session_handle = TPM_RS_PW
+ "\x00\x00" // nonce = zero length buffer
+ "\x01" // session_attributes = continueSession
+ "\x00\x06" // password length
+ "secret", // password
+ 15);
PasswordAuthorizationDelegate delegate("secret");
std::string authorization;
std::string command_hash;
- bool authorization_result = delegate.GetCommandAuthorization(command_hash,
- false, false,
- &authorization);
+ bool authorization_result = delegate.GetCommandAuthorization(
+ command_hash, false, false, &authorization);
EXPECT_EQ(authorization_result, true);
EXPECT_EQ(authorization.length(), expected_auth.length());
EXPECT_EQ(expected_auth.compare(authorization), 0);
@@ -53,31 +53,31 @@
// This test looks at the delegate's ability to parse and check authorization
// responses when the response is well formed.
TEST(PasswordAuthorizationDelegateTest, ParseGoodParams) {
- std::string auth_response("\x00\x00" // nonceTpm = zero length buffer
- "\x01" // session_attributes = continueSession
- "\x00\x00", // hmac = zero length buffer
- 5);
+ std::string auth_response(
+ "\x00\x00" // nonceTpm = zero length buffer
+ "\x01" // session_attributes = continueSession
+ "\x00\x00", // hmac = zero length buffer
+ 5);
PasswordAuthorizationDelegate delegate("secret");
std::string response_hash;
- bool authorization_result = delegate.CheckResponseAuthorization(
- response_hash,
- auth_response);
+ bool authorization_result =
+ delegate.CheckResponseAuthorization(response_hash, auth_response);
EXPECT_EQ(authorization_result, true);
}
// This test checks the delegate's ability to correctly identify an incorrect
// authorization response.
TEST(PasswordAuthorizationDelegateTest, ParseBadParams) {
- std::string auth_response("\x00\x00" // nonceTpm = zero length buffer
- "\x01" // session_attributes = continueSession
- "\x00\x06" // password length
- "secret", // password
- 11);
+ std::string auth_response(
+ "\x00\x00" // nonceTpm = zero length buffer
+ "\x01" // session_attributes = continueSession
+ "\x00\x06" // password length
+ "secret", // password
+ 11);
PasswordAuthorizationDelegate delegate("secret");
std::string response_hash;
- bool authorization_result = delegate.CheckResponseAuthorization(
- response_hash,
- auth_response);
+ bool authorization_result =
+ delegate.CheckResponseAuthorization(response_hash, auth_response);
EXPECT_EQ(authorization_result, false);
}
diff --git a/trunks/policy_session.h b/trunks/policy_session.h
index a8d7d4b..14d8a81 100644
--- a/trunks/policy_session.h
+++ b/trunks/policy_session.h
@@ -43,10 +43,9 @@
// |bind_authorization_value|. Encryption is enabled if |enable_encryption| is
// true. The session remains active until this object is destroyed or another
// session is started with a call to Start*Session.
- virtual TPM_RC StartBoundSession(
- TPMI_DH_ENTITY bind_entity,
- const std::string& bind_authorization_value,
- bool enable_encryption) = 0;
+ virtual TPM_RC StartBoundSession(TPMI_DH_ENTITY bind_entity,
+ const std::string& bind_authorization_value,
+ bool enable_encryption) = 0;
// Starts a salted, unbound session. Encryption is enabled if
// |enable_encryption| is true. The session remains active until this object
diff --git a/trunks/policy_session_impl.cc b/trunks/policy_session_impl.cc
index cb2c4e0..8070c34 100644
--- a/trunks/policy_session_impl.cc
+++ b/trunks/policy_session_impl.cc
@@ -31,15 +31,13 @@
namespace trunks {
PolicySessionImpl::PolicySessionImpl(const TrunksFactory& factory)
- : factory_(factory),
- session_type_(TPM_SE_POLICY) {
+ : factory_(factory), session_type_(TPM_SE_POLICY) {
session_manager_ = factory_.GetSessionManager();
}
PolicySessionImpl::PolicySessionImpl(const TrunksFactory& factory,
TPM_SE session_type)
- : factory_(factory),
- session_type_(session_type) {
+ : factory_(factory), session_type_(session_type) {
session_manager_ = factory_.GetSessionManager();
}
@@ -80,8 +78,7 @@
TPM_RC result = factory_.GetTpm()->PolicyGetDigestSync(
session_manager_->GetSessionHandle(),
"", // No name is needed for this command, as it does no authorization.
- &policy_digest,
- nullptr);
+ &policy_digest, nullptr);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error getting policy digest: " << GetErrorString(result);
return result;
@@ -103,8 +100,7 @@
TPM_RC result = factory_.GetTpm()->PolicyORSync(
session_manager_->GetSessionHandle(),
"", // No policy name is needed as we do no authorization checks.
- tpm_digests,
- nullptr);
+ tpm_digests, nullptr);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error performing PolicyOR: " << GetErrorString(result);
return result;
@@ -139,9 +135,7 @@
TPM_RC result = factory_.GetTpm()->PolicyPCRSync(
session_manager_->GetSessionHandle(),
"", // No policy name is needed as we do no authorization checks.
- pcr_digest,
- pcr_select,
- nullptr);
+ pcr_digest, pcr_select, nullptr);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error performing PolicyPCR: " << GetErrorString(result);
return result;
@@ -153,8 +147,7 @@
TPM_RC result = factory_.GetTpm()->PolicyCommandCodeSync(
session_manager_->GetSessionHandle(),
"", // No policy name is needed as we do no authorization checks.
- command_code,
- nullptr);
+ command_code, nullptr);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error performing PolicyCommandCode: "
<< GetErrorString(result);
diff --git a/trunks/policy_session_impl.h b/trunks/policy_session_impl.h
index fc17f7b..e04f16c 100644
--- a/trunks/policy_session_impl.h
+++ b/trunks/policy_session_impl.h
@@ -40,7 +40,7 @@
// NOTE: StartBoundSession/StartUnboundSession should not be called before
// TPM Ownership is taken. This is because starting a session uses the
// SaltingKey, which is only created after ownership is taken.
-class TRUNKS_EXPORT PolicySessionImpl: public PolicySession {
+class TRUNKS_EXPORT PolicySessionImpl : public PolicySession {
public:
explicit PolicySessionImpl(const TrunksFactory& factory);
// |session_type| specifies what type of session this is. It can only
diff --git a/trunks/policy_session_test.cc b/trunks/policy_session_test.cc
index 5d9e8c5..859912b 100644
--- a/trunks/policy_session_test.cc
+++ b/trunks/policy_session_test.cc
@@ -75,8 +75,8 @@
TEST_F(PolicySessionTest, StartBoundSessionFailure) {
PolicySessionImpl session(factory_);
TPM_HANDLE handle = TPM_RH_FIRST;
- EXPECT_CALL(mock_session_manager_, StartSession(TPM_SE_POLICY, handle,
- _, true, _))
+ EXPECT_CALL(mock_session_manager_,
+ StartSession(TPM_SE_POLICY, handle, _, true, _))
.WillRepeatedly(Return(TPM_RC_FAILURE));
EXPECT_EQ(TPM_RC_FAILURE, session.StartBoundSession(handle, "auth", true));
}
@@ -94,8 +94,8 @@
TEST_F(PolicySessionTest, StartUnboundSessionFailure) {
PolicySessionImpl session(factory_);
- EXPECT_CALL(mock_session_manager_, StartSession(TPM_SE_POLICY, TPM_RH_NULL,
- _, true, _))
+ EXPECT_CALL(mock_session_manager_,
+ StartSession(TPM_SE_POLICY, TPM_RH_NULL, _, true, _))
.WillRepeatedly(Return(TPM_RC_FAILURE));
EXPECT_EQ(TPM_RC_FAILURE, session.StartUnboundSession(true));
}
@@ -106,8 +106,7 @@
TPM2B_DIGEST policy_digest;
policy_digest.size = SHA256_DIGEST_SIZE;
EXPECT_CALL(mock_tpm_, PolicyGetDigestSync(_, _, _, _))
- .WillOnce(DoAll(SetArgPointee<2>(policy_digest),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SetArgPointee<2>(policy_digest), Return(TPM_RC_SUCCESS)));
EXPECT_EQ(TPM_RC_SUCCESS, session.GetDigest(&digest));
EXPECT_EQ(static_cast<size_t>(SHA256_DIGEST_SIZE), digest.size());
}
@@ -128,8 +127,7 @@
digests.push_back("digest3");
TPML_DIGEST tpm_digests;
EXPECT_CALL(mock_tpm_, PolicyORSync(_, _, _, _))
- .WillOnce(DoAll(SaveArg<2>(&tpm_digests),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SaveArg<2>(&tpm_digests), Return(TPM_RC_SUCCESS)));
EXPECT_EQ(TPM_RC_SUCCESS, session.PolicyOR(digests));
EXPECT_EQ(tpm_digests.count, digests.size());
EXPECT_EQ(StringFrom_TPM2B_DIGEST(tpm_digests.digests[0]), digests[0]);
@@ -161,8 +159,7 @@
TPML_PCR_SELECTION pcr_select;
TPM2B_DIGEST pcr_value;
EXPECT_CALL(mock_tpm_, PolicyPCRSync(_, _, _, _, _))
- .WillOnce(DoAll(SaveArg<2>(&pcr_value),
- SaveArg<3>(&pcr_select),
+ .WillOnce(DoAll(SaveArg<2>(&pcr_value), SaveArg<3>(&pcr_select),
Return(TPM_RC_SUCCESS)));
EXPECT_EQ(TPM_RC_SUCCESS, session.PolicyPCR(pcr_index, pcr_digest));
uint8_t pcr_select_index = pcr_index / 8;
diff --git a/trunks/resource_manager.cc b/trunks/resource_manager.cc
index 82dd18d..04cd7c5 100644
--- a/trunks/resource_manager.cc
+++ b/trunks/resource_manager.cc
@@ -46,6 +46,7 @@
target_ = target;
*target_ = true;
}
+
private:
bool* target_;
};
@@ -56,8 +57,7 @@
ResourceManager::ResourceManager(const TrunksFactory& factory,
CommandTransceiver* next_transceiver)
- : factory_(factory),
- next_transceiver_(next_transceiver) {}
+ : factory_(factory), next_transceiver_(next_transceiver) {}
ResourceManager::~ResourceManager() {}
@@ -71,19 +71,15 @@
<< GetErrorString(result);
// Full control of the TPM is assumed and required. Existing transient object
// and session handles are mercilessly flushed.
- for (UINT32 handle_type : {HR_TRANSIENT,
- HR_HMAC_SESSION,
- HR_POLICY_SESSION}) {
+ for (UINT32 handle_type :
+ {HR_TRANSIENT, HR_HMAC_SESSION, HR_POLICY_SESSION}) {
TPMI_YES_NO more_data = YES;
TPMS_CAPABILITY_DATA data;
UINT32 handle_range = handle_type;
while (more_data) {
- result = factory_.GetTpm()->GetCapabilitySync(TPM_CAP_HANDLES,
- handle_range,
- MAX_CAP_HANDLES,
- &more_data,
- &data,
- nullptr);
+ result = factory_.GetTpm()->GetCapabilitySync(
+ TPM_CAP_HANDLES, handle_range, MAX_CAP_HANDLES, &more_data, &data,
+ nullptr);
if (result != TPM_RC_SUCCESS) {
LOG(WARNING) << "Failed to query existing handles: "
<< GetErrorString(result);
@@ -96,15 +92,14 @@
if (more_data) {
// Adjust the range to be greater than the most recent handle so on the
// next query we'll start where we left off.
- handle_range = handle_list.handle[handle_list.count-1];
+ handle_range = handle_list.handle[handle_list.count - 1];
}
}
}
}
-void ResourceManager::SendCommand(
- const std::string& command,
- const ResponseCallback& callback) {
+void ResourceManager::SendCommand(const std::string& command,
+ const ResponseCallback& callback) {
callback.Run(SendCommandAndWait(command));
}
@@ -141,8 +136,8 @@
}
// On a ContextLoad we may need to map virtualized context data.
if (command_info.code == TPM_CC_ContextLoad) {
- std::string actual_load_data = GetActualContextFromExternalContext(
- command_info.parameter_data);
+ std::string actual_load_data =
+ GetActualContextFromExternalContext(command_info.parameter_data);
// Check equality to see if replacement is necessary, and check size to see
// if the command looks like we expect (the idea is to avoid 'fixing'
// malformed commands). Note: updated_command.size() is guaranteed to be >=
@@ -208,8 +203,7 @@
for (auto& item : session_handles_) {
HandleInfo& info = item.second;
if (info.is_loaded &&
- std::find(sessions_to_retain.begin(),
- sessions_to_retain.end(),
+ std::find(sessions_to_retain.begin(), sessions_to_retain.end(),
info.tpm_handle) == sessions_to_retain.end()) {
candidates.push_back(item.first);
}
@@ -220,8 +214,7 @@
}
// Choose the candidate with the earliest |time_of_last_use|.
auto oldest_iter = std::min_element(
- candidates.begin(), candidates.end(),
- [this](TPM_HANDLE a, TPM_HANDLE b) {
+ candidates.begin(), candidates.end(), [this](TPM_HANDLE a, TPM_HANDLE b) {
return (session_handles_[a].time_of_last_use <
session_handles_[b].time_of_last_use);
});
@@ -297,8 +290,7 @@
for (auto& item : virtual_object_handles_) {
HandleInfo& info = item.second;
if (!info.is_loaded ||
- std::find(command_info.handles.begin(),
- command_info.handles.end(),
+ std::find(command_info.handles.begin(), command_info.handles.end(),
item.first) != command_info.handles.end()) {
continue;
}
@@ -435,8 +427,8 @@
if (!ChooseSessionToEvict(command_info.session_handles, &session_to_flush)) {
return;
}
- TPM_RC result = factory_.GetTpm()->FlushContextSync(session_to_flush,
- nullptr);
+ TPM_RC result =
+ factory_.GetTpm()->FlushContextSync(session_to_flush, nullptr);
if (result != TPM_RC_SUCCESS) {
LOG(WARNING) << "Failed to flush session: " << GetErrorString(result);
return;
@@ -468,16 +460,15 @@
TPM_RC result = TPM_RC_SUCCESS;
int attempts = 0;
while (attempts++ < kMaxCommandAttempts) {
- result = factory_.GetTpm()->ContextLoadSync(handle_info->context,
- &handle_info->tpm_handle,
- nullptr);
+ result = factory_.GetTpm()->ContextLoadSync(
+ handle_info->context, &handle_info->tpm_handle, nullptr);
if (!FixWarnings(command_info, result)) {
break;
}
}
if (result != TPM_RC_SUCCESS) {
- LOG(ERROR) << __func__ << ": Failed to load context: "
- << GetErrorString(result);
+ LOG(ERROR) << __func__
+ << ": Failed to load context: " << GetErrorString(result);
return result;
}
handle_info->is_loaded = true;
@@ -667,9 +658,8 @@
std::string mutable_parameter = response_info.parameter_data;
TPMS_CONTEXT context;
std::string context_blob;
- TPM_RC result = Parse_TPMS_CONTEXT(&mutable_parameter,
- &context,
- &context_blob);
+ TPM_RC result =
+ Parse_TPMS_CONTEXT(&mutable_parameter, &context, &context_blob);
if (result != TPM_RC_SUCCESS) {
LOG(WARNING) << "Invalid context save response: " << GetErrorString(result);
return;
@@ -720,8 +710,8 @@
// parameter.
std::string handle_blob;
Serialize_TPM_HANDLE(actual_handle, &handle_blob);
- std::string updated_command = command.substr(0, kMessageHeaderSize) +
- handle_blob;
+ std::string updated_command =
+ command.substr(0, kMessageHeaderSize) + handle_blob;
// No need to loop and fix warnings, there are no actionable warnings on when
// flushing context.
std::string response = next_transceiver_->SendCommandAndWait(updated_command);
@@ -820,25 +810,21 @@
Serialize_TPM_HANDLE(handle_info->tpm_handle, &tpm_handle_name);
result = factory_.GetTpm()->ContextSaveSync(handle_info->tpm_handle,
tpm_handle_name,
- &handle_info->context,
- nullptr);
+ &handle_info->context, nullptr);
if (!FixWarnings(command_info, result)) {
break;
}
}
if (result != TPM_RC_SUCCESS) {
- LOG(ERROR) << __func__ << ": Failed to load context: "
- << GetErrorString(result);
+ LOG(ERROR) << __func__
+ << ": Failed to load context: " << GetErrorString(result);
return result;
}
handle_info->is_loaded = false;
return result;
}
-
-ResourceManager::HandleInfo::HandleInfo()
- : is_loaded(false),
- tpm_handle(0) {
+ResourceManager::HandleInfo::HandleInfo() : is_loaded(false), tpm_handle(0) {
memset(&context, 0, sizeof(TPMS_CONTEXT));
}
diff --git a/trunks/resource_manager_test.cc b/trunks/resource_manager_test.cc
index 4aafbaf..872375f 100644
--- a/trunks/resource_manager_test.cc
+++ b/trunks/resource_manager_test.cc
@@ -52,9 +52,7 @@
ScopedDisableLogging() : original_severity_(logging::GetMinLogLevel()) {
logging::SetMinLogLevel(logging::LOG_FATAL);
}
- ~ScopedDisableLogging() {
- logging::SetMinLogLevel(original_severity_);
- }
+ ~ScopedDisableLogging() { logging::SetMinLogLevel(original_severity_); }
private:
logging::LogSeverity original_severity_;
@@ -73,9 +71,7 @@
ResourceManagerTest() : resource_manager_(factory_, &transceiver_) {}
~ResourceManagerTest() override {}
- void SetUp() override {
- factory_.set_tpm(&tpm_);
- }
+ void SetUp() override { factory_.set_tpm(&tpm_); }
// Builds a well-formed command.
std::string CreateCommand(TPM_CC code,
@@ -151,36 +147,28 @@
// the newly associated virtual handle.
TPM_HANDLE LoadHandle(TPM_HANDLE handle) {
std::vector<TPM_HANDLE> input_handles = {PERSISTENT_FIRST};
- std::string command = CreateCommand(TPM_CC_Load,
- input_handles,
- kNoAuthorization,
- kNoParameters);
+ std::string command = CreateCommand(TPM_CC_Load, input_handles,
+ kNoAuthorization, kNoParameters);
std::vector<TPM_HANDLE> output_handles = {handle};
- std::string response = CreateResponse(TPM_RC_SUCCESS,
- output_handles,
- kNoAuthorization,
- kNoParameters);
+ std::string response = CreateResponse(TPM_RC_SUCCESS, output_handles,
+ kNoAuthorization, kNoParameters);
EXPECT_CALL(transceiver_, SendCommandAndWait(command))
.WillOnce(Return(response));
std::string actual_response = resource_manager_.SendCommandAndWait(command);
std::string handle_blob = StripHeader(actual_response);
TPM_HANDLE virtual_handle;
- CHECK_EQ(TPM_RC_SUCCESS, Parse_TPM_HANDLE(&handle_blob, &virtual_handle,
- NULL));
+ CHECK_EQ(TPM_RC_SUCCESS,
+ Parse_TPM_HANDLE(&handle_blob, &virtual_handle, NULL));
return virtual_handle;
}
// Causes the resource manager to evict existing object handles.
void EvictObjects() {
- std::string command = CreateCommand(TPM_CC_Startup,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
+ std::string command = CreateCommand(TPM_CC_Startup, kNoHandles,
+ kNoAuthorization, kNoParameters);
std::string response = CreateErrorResponse(TPM_RC_OBJECT_MEMORY);
- std::string success_response = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
+ std::string success_response = CreateResponse(
+ TPM_RC_SUCCESS, kNoHandles, kNoAuthorization, kNoParameters);
EXPECT_CALL(transceiver_, SendCommandAndWait(_))
.WillOnce(Return(response))
.WillRepeatedly(Return(success_response));
@@ -194,15 +182,11 @@
// Makes the resource manager aware of a session handle.
void StartSession(TPM_HANDLE handle) {
std::vector<TPM_HANDLE> input_handles = {1, 2};
- std::string command = CreateCommand(TPM_CC_StartAuthSession,
- input_handles,
- kNoAuthorization,
- kNoParameters);
+ std::string command = CreateCommand(TPM_CC_StartAuthSession, input_handles,
+ kNoAuthorization, kNoParameters);
std::vector<TPM_HANDLE> output_handles = {handle};
- std::string response = CreateResponse(TPM_RC_SUCCESS,
- output_handles,
- kNoAuthorization,
- kNoParameters);
+ std::string response = CreateResponse(TPM_RC_SUCCESS, output_handles,
+ kNoAuthorization, kNoParameters);
EXPECT_CALL(transceiver_, SendCommandAndWait(command))
.WillOnce(Return(response));
std::string actual_response = resource_manager_.SendCommandAndWait(command);
@@ -211,15 +195,11 @@
// Causes the resource manager to evict an existing session handle.
void EvictSession() {
- std::string command = CreateCommand(TPM_CC_Startup,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
+ std::string command = CreateCommand(TPM_CC_Startup, kNoHandles,
+ kNoAuthorization, kNoParameters);
std::string response = CreateErrorResponse(TPM_RC_SESSION_MEMORY);
- std::string success_response = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
+ std::string success_response = CreateResponse(
+ TPM_RC_SUCCESS, kNoHandles, kNoAuthorization, kNoParameters);
EXPECT_CALL(transceiver_, SendCommandAndWait(_))
.WillOnce(Return(response))
.WillRepeatedly(Return(success_response));
@@ -251,14 +231,10 @@
};
TEST_F(ResourceManagerTest, BasicPassThrough) {
- std::string command = CreateCommand(TPM_CC_Startup,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
- std::string response = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
+ std::string command = CreateCommand(TPM_CC_Startup, kNoHandles,
+ kNoAuthorization, kNoParameters);
+ std::string response = CreateResponse(TPM_RC_SUCCESS, kNoHandles,
+ kNoAuthorization, kNoParameters);
EXPECT_CALL(transceiver_, SendCommandAndWait(command))
.WillOnce(Return(response));
std::string actual_response = resource_manager_.SendCommandAndWait(command);
@@ -266,14 +242,10 @@
}
TEST_F(ResourceManagerTest, BasicPassThroughAsync) {
- std::string command = CreateCommand(TPM_CC_Startup,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
- std::string response = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
+ std::string command = CreateCommand(TPM_CC_Startup, kNoHandles,
+ kNoAuthorization, kNoParameters);
+ std::string response = CreateResponse(TPM_RC_SUCCESS, kNoHandles,
+ kNoAuthorization, kNoParameters);
EXPECT_CALL(transceiver_, SendCommandAndWait(command))
.WillOnce(Return(response));
std::string actual_response;
@@ -285,15 +257,11 @@
TEST_F(ResourceManagerTest, VirtualHandleOutput) {
std::vector<TPM_HANDLE> input_handles = {PERSISTENT_FIRST};
- std::string command = CreateCommand(TPM_CC_Load,
- input_handles,
- kNoAuthorization,
- kNoParameters);
+ std::string command = CreateCommand(TPM_CC_Load, input_handles,
+ kNoAuthorization, kNoParameters);
std::vector<TPM_HANDLE> output_handles = {kArbitraryObjectHandle};
- std::string response = CreateResponse(TPM_RC_SUCCESS,
- output_handles,
- kNoAuthorization,
- kNoParameters);
+ std::string response = CreateResponse(TPM_RC_SUCCESS, output_handles,
+ kNoAuthorization, kNoParameters);
EXPECT_CALL(transceiver_, SendCommandAndWait(command))
.WillOnce(Return(response));
std::string actual_response = resource_manager_.SendCommandAndWait(command);
@@ -311,21 +279,15 @@
TPM_HANDLE tpm_handle = kArbitraryObjectHandle;
TPM_HANDLE virtual_handle = LoadHandle(tpm_handle);
std::vector<TPM_HANDLE> input_handles = {virtual_handle};
- std::string command = CreateCommand(TPM_CC_Sign,
- input_handles,
- kNoAuthorization,
- kNoParameters);
+ std::string command = CreateCommand(TPM_CC_Sign, input_handles,
+ kNoAuthorization, kNoParameters);
// We expect the resource manager to replace |virtual_handle| with
// |tpm_handle|.
std::vector<TPM_HANDLE> expected_input_handles = {tpm_handle};
- std::string expected_command = CreateCommand(TPM_CC_Sign,
- expected_input_handles,
- kNoAuthorization,
- kNoParameters);
- std::string response = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
+ std::string expected_command = CreateCommand(
+ TPM_CC_Sign, expected_input_handles, kNoAuthorization, kNoParameters);
+ std::string response = CreateResponse(TPM_RC_SUCCESS, kNoHandles,
+ kNoAuthorization, kNoParameters);
EXPECT_CALL(transceiver_, SendCommandAndWait(expected_command))
.WillOnce(Return(response));
std::string actual_response = resource_manager_.SendCommandAndWait(command);
@@ -337,29 +299,21 @@
TPM_HANDLE virtual_handle = LoadHandle(tpm_handle);
std::string parameters;
Serialize_TPM_HANDLE(virtual_handle, ¶meters);
- std::string command = CreateCommand(TPM_CC_FlushContext,
- kNoHandles,
- kNoAuthorization,
- parameters);
+ std::string command = CreateCommand(TPM_CC_FlushContext, kNoHandles,
+ kNoAuthorization, parameters);
std::string expected_parameters;
Serialize_TPM_HANDLE(tpm_handle, &expected_parameters);
- std::string expected_command = CreateCommand(TPM_CC_FlushContext,
- kNoHandles,
- kNoAuthorization,
- expected_parameters);
- std::string response = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
+ std::string expected_command = CreateCommand(
+ TPM_CC_FlushContext, kNoHandles, kNoAuthorization, expected_parameters);
+ std::string response = CreateResponse(TPM_RC_SUCCESS, kNoHandles,
+ kNoAuthorization, kNoParameters);
EXPECT_CALL(transceiver_, SendCommandAndWait(expected_command))
.WillOnce(Return(response));
std::string actual_response = resource_manager_.SendCommandAndWait(command);
EXPECT_EQ(response, actual_response);
// Now we expect there to be no record of |virtual_handle|.
std::vector<TPM_HANDLE> input_handles = {virtual_handle};
- command = CreateCommand(TPM_CC_Sign,
- input_handles,
- kNoAuthorization,
+ command = CreateCommand(TPM_CC_Sign, input_handles, kNoAuthorization,
kNoParameters);
response = CreateErrorResponse(TPM_RC_HANDLE | kResourceManagerTpmErrorBase);
actual_response = resource_manager_.SendCommandAndWait(command);
@@ -369,9 +323,7 @@
virtual_handle = LoadHandle(tpm_handle);
parameters.clear();
Serialize_TPM_HANDLE(tpm_handle, ¶meters);
- command = CreateCommand(TPM_CC_FlushContext,
- kNoHandles,
- kNoAuthorization,
+ command = CreateCommand(TPM_CC_FlushContext, kNoHandles, kNoAuthorization,
parameters);
actual_response = resource_manager_.SendCommandAndWait(command);
// TPM_RC_HANDLE also expected here.
@@ -383,21 +335,14 @@
TPM_HANDLE virtual_handle = LoadHandle(tpm_handle);
EvictObjects();
std::vector<TPM_HANDLE> input_handles = {virtual_handle};
- std::string command = CreateCommand(TPM_CC_Sign,
- input_handles,
- kNoAuthorization,
- kNoParameters);
+ std::string command = CreateCommand(TPM_CC_Sign, input_handles,
+ kNoAuthorization, kNoParameters);
std::vector<TPM_HANDLE> expected_input_handles = {tpm_handle};
- std::string expected_command = CreateCommand(TPM_CC_Sign,
- expected_input_handles,
- kNoAuthorization,
- kNoParameters);
- std::string response = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
- EXPECT_CALL(tpm_, ContextLoadSync(_, _, _))
- .WillOnce(Return(TPM_RC_SUCCESS));
+ std::string expected_command = CreateCommand(
+ TPM_CC_Sign, expected_input_handles, kNoAuthorization, kNoParameters);
+ std::string response = CreateResponse(TPM_RC_SUCCESS, kNoHandles,
+ kNoAuthorization, kNoParameters);
+ EXPECT_CALL(tpm_, ContextLoadSync(_, _, _)).WillOnce(Return(TPM_RC_SUCCESS));
EXPECT_CALL(transceiver_, SendCommandAndWait(expected_command))
.WillOnce(Return(response));
std::string actual_response = resource_manager_.SendCommandAndWait(command);
@@ -406,12 +351,10 @@
TEST_F(ResourceManagerTest, InvalidVirtualHandle) {
std::vector<TPM_HANDLE> input_handles = {kArbitraryObjectHandle};
- std::string command = CreateCommand(TPM_CC_Sign,
- input_handles,
- kNoAuthorization,
- kNoParameters);
- std::string response = CreateErrorResponse(TPM_RC_HANDLE |
- kResourceManagerTpmErrorBase);
+ std::string command = CreateCommand(TPM_CC_Sign, input_handles,
+ kNoAuthorization, kNoParameters);
+ std::string response =
+ CreateErrorResponse(TPM_RC_HANDLE | kResourceManagerTpmErrorBase);
std::string actual_response = resource_manager_.SendCommandAndWait(command);
EXPECT_EQ(response, actual_response);
}
@@ -419,12 +362,11 @@
TEST_F(ResourceManagerTest, SimpleFuzzInputParser) {
std::vector<TPM_HANDLE> handles = {1, 2};
std::string parameters = "12345";
- std::string command = CreateCommand(TPM_CC_StartAuthSession,
- handles,
- CreateCommandAuthorization(
- kArbitrarySessionHandle,
- true), // continue_session
- parameters);
+ std::string command =
+ CreateCommand(TPM_CC_StartAuthSession, handles,
+ CreateCommandAuthorization(kArbitrarySessionHandle,
+ true), // continue_session
+ parameters);
// We don't care about what happens, only that it doesn't crash.
EXPECT_CALL(transceiver_, SendCommandAndWait(_))
.WillRepeatedly(Return(CreateErrorResponse(TPM_RC_FAILURE)));
@@ -433,7 +375,7 @@
resource_manager_.SendCommandAndWait(command.substr(0, i));
resource_manager_.SendCommandAndWait(command.substr(i));
std::string fuzzed_command(command);
- for (uint8_t value = 0; ; value++) {
+ for (uint8_t value = 0;; value++) {
fuzzed_command[i] = static_cast<char>(value);
resource_manager_.SendCommandAndWait(fuzzed_command);
if (value == 255) {
@@ -446,18 +388,16 @@
TEST_F(ResourceManagerTest, SimpleFuzzOutputParser) {
std::vector<TPM_HANDLE> handles = {1, 2};
std::string parameters = "12345";
- std::string command = CreateCommand(TPM_CC_StartAuthSession,
- handles,
- CreateCommandAuthorization(
- kArbitrarySessionHandle,
- true), // continue_session
- parameters);
+ std::string command =
+ CreateCommand(TPM_CC_StartAuthSession, handles,
+ CreateCommandAuthorization(kArbitrarySessionHandle,
+ true), // continue_session
+ parameters);
std::vector<TPM_HANDLE> out_handles = {3};
- std::string response = CreateResponse(TPM_RC_SUCCESS,
- out_handles,
- CreateResponseAuthorization(
- true), // continue_session
- parameters);
+ std::string response =
+ CreateResponse(TPM_RC_SUCCESS, out_handles,
+ CreateResponseAuthorization(true), // continue_session
+ parameters);
std::string fuzzed_response;
EXPECT_CALL(transceiver_, SendCommandAndWait(_))
.WillRepeatedly(ReturnPointee(&fuzzed_response));
@@ -468,7 +408,7 @@
fuzzed_response = response.substr(i);
resource_manager_.SendCommandAndWait(command);
fuzzed_response = response;
- for (uint8_t value = 0; ; value++) {
+ for (uint8_t value = 0;; value++) {
fuzzed_response[i] = static_cast<char>(value);
resource_manager_.SendCommandAndWait(command);
if (value == 255) {
@@ -481,17 +421,15 @@
TEST_F(ResourceManagerTest, NewSession) {
StartSession(kArbitrarySessionHandle);
- std::string command = CreateCommand(TPM_CC_Startup,
- kNoHandles,
- CreateCommandAuthorization(
- kArbitrarySessionHandle,
- true), // continue_session
- kNoParameters);
- std::string response = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- CreateResponseAuthorization(
- true), // continue_session
- kNoParameters);
+ std::string command =
+ CreateCommand(TPM_CC_Startup, kNoHandles,
+ CreateCommandAuthorization(kArbitrarySessionHandle,
+ true), // continue_session
+ kNoParameters);
+ std::string response =
+ CreateResponse(TPM_RC_SUCCESS, kNoHandles,
+ CreateResponseAuthorization(true), // continue_session
+ kNoParameters);
EXPECT_CALL(transceiver_, SendCommandAndWait(command))
.WillOnce(Return(response));
std::string actual_response = resource_manager_.SendCommandAndWait(command);
@@ -501,17 +439,15 @@
TEST_F(ResourceManagerTest, DiscontinuedSession) {
StartSession(kArbitrarySessionHandle);
// Use the session but do not continue.
- std::string command = CreateCommand(TPM_CC_Startup,
- kNoHandles,
- CreateCommandAuthorization(
- kArbitrarySessionHandle,
- false), // continue_session
- kNoParameters);
- std::string response = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- CreateResponseAuthorization(
- false), // continue_session
- kNoParameters);
+ std::string command =
+ CreateCommand(TPM_CC_Startup, kNoHandles,
+ CreateCommandAuthorization(kArbitrarySessionHandle,
+ false), // continue_session
+ kNoParameters);
+ std::string response =
+ CreateResponse(TPM_RC_SUCCESS, kNoHandles,
+ CreateResponseAuthorization(false), // continue_session
+ kNoParameters);
EXPECT_CALL(transceiver_, SendCommandAndWait(command))
.WillOnce(Return(response));
std::string actual_response = resource_manager_.SendCommandAndWait(command);
@@ -525,21 +461,18 @@
TEST_F(ResourceManagerTest, LoadSessionBeforeUse) {
StartSession(kArbitrarySessionHandle);
EvictSession();
- std::string command = CreateCommand(TPM_CC_Startup,
- kNoHandles,
- CreateCommandAuthorization(
- kArbitrarySessionHandle,
- true), // continue_session
- kNoParameters);
- std::string response = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- CreateResponseAuthorization(
- true), // continue_session
- kNoParameters);
+ std::string command =
+ CreateCommand(TPM_CC_Startup, kNoHandles,
+ CreateCommandAuthorization(kArbitrarySessionHandle,
+ true), // continue_session
+ kNoParameters);
+ std::string response =
+ CreateResponse(TPM_RC_SUCCESS, kNoHandles,
+ CreateResponseAuthorization(true), // continue_session
+ kNoParameters);
EXPECT_CALL(transceiver_, SendCommandAndWait(command))
.WillOnce(Return(response));
- EXPECT_CALL(tpm_, ContextLoadSync(_, _, _))
- .WillOnce(Return(TPM_RC_SUCCESS));
+ EXPECT_CALL(tpm_, ContextLoadSync(_, _, _)).WillOnce(Return(TPM_RC_SUCCESS));
std::string actual_response = resource_manager_.SendCommandAndWait(command);
EXPECT_EQ(response, actual_response);
}
@@ -548,24 +481,18 @@
StartSession(kArbitrarySessionHandle);
std::string parameters;
Serialize_TPM_HANDLE(kArbitrarySessionHandle, ¶meters);
- std::string command = CreateCommand(TPM_CC_FlushContext,
- kNoHandles,
- kNoAuthorization,
- parameters);
- std::string response = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
+ std::string command = CreateCommand(TPM_CC_FlushContext, kNoHandles,
+ kNoAuthorization, parameters);
+ std::string response = CreateResponse(TPM_RC_SUCCESS, kNoHandles,
+ kNoAuthorization, kNoParameters);
EXPECT_CALL(transceiver_, SendCommandAndWait(command))
.WillOnce(Return(response));
std::string actual_response = resource_manager_.SendCommandAndWait(command);
EXPECT_EQ(response, actual_response);
// Now we expect there to be no record of |kArbitrarySessionHandle|.
- command = CreateCommand(TPM_CC_Startup,
- kNoHandles,
- CreateCommandAuthorization(
- kArbitrarySessionHandle,
- true), // continue_session
+ command = CreateCommand(TPM_CC_Startup, kNoHandles,
+ CreateCommandAuthorization(kArbitrarySessionHandle,
+ true), // continue_session
kNoParameters);
response = CreateErrorResponse(TPM_RC_HANDLE | kResourceManagerTpmErrorBase);
actual_response = resource_manager_.SendCommandAndWait(command);
@@ -578,16 +505,12 @@
TPM_HANDLE tpm_handle2 = kArbitraryObjectHandle + 1;
LoadHandle(tpm_handle2);
std::vector<TPM_HANDLE> input_handles = {virtual_handle};
- std::string command = CreateCommand(TPM_CC_Sign,
- input_handles,
- kNoAuthorization,
- kNoParameters);
+ std::string command = CreateCommand(TPM_CC_Sign, input_handles,
+ kNoAuthorization, kNoParameters);
// Trigger evict logic and verify |input_handles| are not evicted.
std::string response = CreateErrorResponse(TPM_RC_OBJECT_MEMORY);
- std::string success_response = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
+ std::string success_response = CreateResponse(
+ TPM_RC_SUCCESS, kNoHandles, kNoAuthorization, kNoParameters);
EXPECT_CALL(tpm_, ContextSaveSync(tpm_handle2, _, _, _))
.WillOnce(Return(TPM_RC_SUCCESS));
EXPECT_CALL(tpm_, FlushContextSync(tpm_handle2, _))
@@ -602,17 +525,15 @@
TEST_F(ResourceManagerTest, EvictWhenSessionInUse) {
StartSession(kArbitrarySessionHandle);
StartSession(kArbitrarySessionHandle + 1);
- std::string command = CreateCommand(TPM_CC_Startup,
- kNoHandles,
- CreateCommandAuthorization(
- kArbitrarySessionHandle,
- true), // continue_session
- kNoParameters);
- std::string response = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- CreateResponseAuthorization(
- true), // continue_session
- kNoParameters);
+ std::string command =
+ CreateCommand(TPM_CC_Startup, kNoHandles,
+ CreateCommandAuthorization(kArbitrarySessionHandle,
+ true), // continue_session
+ kNoParameters);
+ std::string response =
+ CreateResponse(TPM_RC_SUCCESS, kNoHandles,
+ CreateResponseAuthorization(true), // continue_session
+ kNoParameters);
std::string error_response = CreateErrorResponse(TPM_RC_SESSION_MEMORY);
EXPECT_CALL(transceiver_, SendCommandAndWait(_))
.WillOnce(Return(error_response))
@@ -631,10 +552,8 @@
handles[LoadHandle(handle)] = handle;
}
EvictObjects();
- std::string response = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
+ std::string response = CreateResponse(TPM_RC_SUCCESS, kNoHandles,
+ kNoAuthorization, kNoParameters);
EXPECT_CALL(tpm_, ContextLoadSync(_, _, _))
.Times(kNumObjects)
.WillRepeatedly(Return(TPM_RC_SUCCESS));
@@ -642,10 +561,8 @@
.WillRepeatedly(Return(response));
for (auto item : handles) {
std::vector<TPM_HANDLE> input_handles = {item.first};
- std::string command = CreateCommand(TPM_CC_Sign,
- input_handles,
- kNoAuthorization,
- kNoParameters);
+ std::string command = CreateCommand(TPM_CC_Sign, input_handles,
+ kNoAuthorization, kNoParameters);
std::string actual_response = resource_manager_.SendCommandAndWait(command);
EXPECT_EQ(response, actual_response);
}
@@ -655,21 +572,19 @@
StartSession(kArbitrarySessionHandle);
StartSession(kArbitrarySessionHandle + 1);
StartSession(kArbitrarySessionHandle + 2);
- std::string response = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- CreateResponseAuthorization(
- true), // continue_session
- kNoParameters);
+ std::string response =
+ CreateResponse(TPM_RC_SUCCESS, kNoHandles,
+ CreateResponseAuthorization(true), // continue_session
+ kNoParameters);
EXPECT_CALL(transceiver_, SendCommandAndWait(_))
.WillRepeatedly(Return(response));
// Use the first two sessions, leaving the third as the most stale.
for (int i = 0; i < 2; ++i) {
- std::string command = CreateCommand(TPM_CC_Startup,
- kNoHandles,
- CreateCommandAuthorization(
- kArbitrarySessionHandle + i,
- true), // continue_session
- kNoParameters);
+ std::string command =
+ CreateCommand(TPM_CC_Startup, kNoHandles,
+ CreateCommandAuthorization(kArbitrarySessionHandle + i,
+ true), // continue_session
+ kNoParameters);
std::string actual_response = resource_manager_.SendCommandAndWait(command);
EXPECT_EQ(response, actual_response);
}
@@ -679,24 +594,21 @@
.WillRepeatedly(Return(response));
// Use the first two sessions again, expecting no calls to ContextLoad.
for (int i = 0; i < 2; ++i) {
- std::string command = CreateCommand(TPM_CC_Startup,
- kNoHandles,
- CreateCommandAuthorization(
- kArbitrarySessionHandle + i,
- true), // continue_session
- kNoParameters);
+ std::string command =
+ CreateCommand(TPM_CC_Startup, kNoHandles,
+ CreateCommandAuthorization(kArbitrarySessionHandle + i,
+ true), // continue_session
+ kNoParameters);
std::string actual_response = resource_manager_.SendCommandAndWait(command);
EXPECT_EQ(response, actual_response);
}
// Expect a call to ContextLoad if we use the third session.
- std::string command = CreateCommand(TPM_CC_Startup,
- kNoHandles,
- CreateCommandAuthorization(
- kArbitrarySessionHandle + 2,
- true), // continue_session
- kNoParameters);
- EXPECT_CALL(tpm_, ContextLoadSync(_, _, _))
- .WillOnce(Return(TPM_RC_SUCCESS));
+ std::string command =
+ CreateCommand(TPM_CC_Startup, kNoHandles,
+ CreateCommandAuthorization(kArbitrarySessionHandle + 2,
+ true), // continue_session
+ kNoParameters);
+ EXPECT_CALL(tpm_, ContextLoadSync(_, _, _)).WillOnce(Return(TPM_RC_SUCCESS));
std::string actual_response = resource_manager_.SendCommandAndWait(command);
EXPECT_EQ(response, actual_response);
}
@@ -713,15 +625,11 @@
}
}
// Invoke a context gap.
- std::string command = CreateCommand(TPM_CC_Startup,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
+ std::string command = CreateCommand(TPM_CC_Startup, kNoHandles,
+ kNoAuthorization, kNoParameters);
std::string response = CreateErrorResponse(TPM_RC_CONTEXT_GAP);
- std::string success_response = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
+ std::string success_response = CreateResponse(
+ TPM_RC_SUCCESS, kNoHandles, kNoAuthorization, kNoParameters);
{
InSequence ungap_order;
for (auto handle : expected_ungap_order) {
@@ -742,37 +650,29 @@
StartSession(kArbitrarySessionHandle);
// Do an external context save.
std::vector<TPM_HANDLE> handles = {kArbitrarySessionHandle};
- std::string context_save = CreateCommand(TPM_CC_ContextSave,
- handles,
- kNoAuthorization,
- kNoParameters);
+ std::string context_save = CreateCommand(TPM_CC_ContextSave, handles,
+ kNoAuthorization, kNoParameters);
std::string context_parameter1 = CreateContextParameter(1);
- std::string context_save_response1 = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- kNoAuthorization,
- context_parameter1);
+ std::string context_save_response1 = CreateResponse(
+ TPM_RC_SUCCESS, kNoHandles, kNoAuthorization, context_parameter1);
EXPECT_CALL(transceiver_, SendCommandAndWait(context_save))
.WillOnce(Return(context_save_response1));
- std::string actual_response = resource_manager_.SendCommandAndWait(
- context_save);
+ std::string actual_response =
+ resource_manager_.SendCommandAndWait(context_save);
EXPECT_EQ(context_save_response1, actual_response);
// Invoke a context gap (which will cause context1 to be mapped to context2).
- EXPECT_CALL(tpm_, ContextLoadSync(Field(&TPMS_CONTEXT::sequence, Eq(1u)),
- _, _))
+ EXPECT_CALL(tpm_,
+ ContextLoadSync(Field(&TPMS_CONTEXT::sequence, Eq(1u)), _, _))
.WillOnce(Return(TPM_RC_SUCCESS));
EXPECT_CALL(tpm_, ContextSaveSync(kArbitrarySessionHandle, _, _, _))
.WillOnce(DoAll(SetArgumentPointee<2>(CreateContext(2)),
Return(TPM_RC_SUCCESS)));
- std::string command = CreateCommand(TPM_CC_Startup,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
+ std::string command = CreateCommand(TPM_CC_Startup, kNoHandles,
+ kNoAuthorization, kNoParameters);
std::string response = CreateErrorResponse(TPM_RC_CONTEXT_GAP);
- std::string success_response = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
+ std::string success_response = CreateResponse(
+ TPM_RC_SUCCESS, kNoHandles, kNoAuthorization, kNoParameters);
EXPECT_CALL(transceiver_, SendCommandAndWait(command))
.WillOnce(Return(response))
.WillOnce(Return(success_response));
@@ -780,18 +680,13 @@
EXPECT_EQ(success_response, actual_response);
// Now load external context1 and expect an actual load of context2.
- std::string context_load1 = CreateCommand(TPM_CC_ContextLoad,
- kNoHandles,
- kNoAuthorization,
- context_parameter1);
- std::string context_load2 = CreateCommand(TPM_CC_ContextLoad,
- kNoHandles,
- kNoAuthorization,
- CreateContextParameter(2));
- std::string context_load_response = CreateResponse(TPM_RC_SUCCESS,
- handles,
- kNoAuthorization,
- kNoParameters);
+ std::string context_load1 = CreateCommand(
+ TPM_CC_ContextLoad, kNoHandles, kNoAuthorization, context_parameter1);
+ std::string context_load2 =
+ CreateCommand(TPM_CC_ContextLoad, kNoHandles, kNoAuthorization,
+ CreateContextParameter(2));
+ std::string context_load_response =
+ CreateResponse(TPM_RC_SUCCESS, handles, kNoAuthorization, kNoParameters);
EXPECT_CALL(transceiver_, SendCommandAndWait(context_load2))
.WillOnce(Return(context_load_response));
actual_response = resource_manager_.SendCommandAndWait(context_load1);
@@ -831,10 +726,8 @@
.WillRepeatedly(Return(TPM_RC_SESSION_MEMORY));
// The resource manager should not handle the same warning twice so we expect
// the error of the original call to bubble up.
- std::string command = CreateCommand(TPM_CC_Startup,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
+ std::string command = CreateCommand(TPM_CC_Startup, kNoHandles,
+ kNoAuthorization, kNoParameters);
std::string response = resource_manager_.SendCommandAndWait(command);
EXPECT_EQ(error_response, response);
}
@@ -843,10 +736,8 @@
std::string error_response = CreateErrorResponse(TPM_RC_MEMORY);
EXPECT_CALL(transceiver_, SendCommandAndWait(_))
.WillRepeatedly(Return(error_response));
- std::string command = CreateCommand(TPM_CC_Startup,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
+ std::string command = CreateCommand(TPM_CC_Startup, kNoHandles,
+ kNoAuthorization, kNoParameters);
std::string response = resource_manager_.SendCommandAndWait(command);
EXPECT_EQ(error_response, response);
}
@@ -867,26 +758,22 @@
EXPECT_CALL(tpm_, ContextLoadSync(_, _, _))
.WillOnce(Return(TPM_RC_CONTEXT_GAP))
.WillRepeatedly(Return(TPM_RC_SUCCESS));
- std::string command = CreateCommand(TPM_CC_Startup,
- kNoHandles,
- kNoAuthorization,
- kNoParameters);
+ std::string command = CreateCommand(TPM_CC_Startup, kNoHandles,
+ kNoAuthorization, kNoParameters);
std::string response = resource_manager_.SendCommandAndWait(command);
EXPECT_EQ(error_response, response);
}
TEST_F(ResourceManagerTest, PasswordAuthorization) {
- std::string command = CreateCommand(TPM_CC_Startup,
- kNoHandles,
- CreateCommandAuthorization(
- TPM_RS_PW,
- false), // continue_session
- kNoParameters);
- std::string response = CreateResponse(TPM_RC_SUCCESS,
- kNoHandles,
- CreateResponseAuthorization(
- false), // continue_session
- kNoParameters);
+ std::string command =
+ CreateCommand(TPM_CC_Startup, kNoHandles,
+ CreateCommandAuthorization(TPM_RS_PW,
+ false), // continue_session
+ kNoParameters);
+ std::string response =
+ CreateResponse(TPM_RC_SUCCESS, kNoHandles,
+ CreateResponseAuthorization(false), // continue_session
+ kNoParameters);
EXPECT_CALL(transceiver_, SendCommandAndWait(command))
.WillOnce(Return(response));
std::string actual_response = resource_manager_.SendCommandAndWait(command);
diff --git a/trunks/scoped_key_handle.cc b/trunks/scoped_key_handle.cc
index e8b4800..ae61b58 100644
--- a/trunks/scoped_key_handle.cc
+++ b/trunks/scoped_key_handle.cc
@@ -29,13 +29,11 @@
namespace trunks {
ScopedKeyHandle::ScopedKeyHandle(const TrunksFactory& factory)
- : factory_(factory),
- handle_(kInvalidHandle) {}
+ : factory_(factory), handle_(kInvalidHandle) {}
ScopedKeyHandle::ScopedKeyHandle(const TrunksFactory& factory,
TPM_HANDLE handle)
- : factory_(factory),
- handle_(handle) {}
+ : factory_(factory), handle_(handle) {}
ScopedKeyHandle::~ScopedKeyHandle() {
if (handle_ != kInvalidHandle) {
diff --git a/trunks/scoped_key_handle_test.cc b/trunks/scoped_key_handle_test.cc
index 3f40be6..1dc50aa 100644
--- a/trunks/scoped_key_handle_test.cc
+++ b/trunks/scoped_key_handle_test.cc
@@ -39,9 +39,7 @@
ScopedKeyHandleTest() {}
~ScopedKeyHandleTest() override {}
- void SetUp() override {
- factory_.set_tpm(&mock_tpm_);
- }
+ void SetUp() override { factory_.set_tpm(&mock_tpm_); }
protected:
TrunksFactoryForTest factory_;
diff --git a/trunks/session_manager_impl.cc b/trunks/session_manager_impl.cc
index 22e32de..998fd38 100644
--- a/trunks/session_manager_impl.cc
+++ b/trunks/session_manager_impl.cc
@@ -51,8 +51,7 @@
namespace trunks {
SessionManagerImpl::SessionManagerImpl(const TrunksFactory& factory)
- : factory_(factory),
- session_handle_(kUninitializedHandle) {
+ : factory_(factory), session_handle_(kUninitializedHandle) {
crypto::EnsureOpenSSLInit();
}
@@ -119,30 +118,22 @@
// The TPM2 command below needs no authorization. This is why we can use
// the empty string "", when referring to the handle names for the salting
// key and the bind entity.
- TPM_RC tpm_result = tpm->StartAuthSessionSync(kSaltingKey,
- "", // salt_handle_name.
- bind_entity,
- "", // bind_entity_name.
- nonce_caller,
- encrypted_secret,
- session_type,
- symmetric_algorithm,
- hash_algorithm,
- &session_handle_,
- &nonce_tpm,
- nullptr); // No Authorization.
+ TPM_RC tpm_result = tpm->StartAuthSessionSync(
+ kSaltingKey,
+ "", // salt_handle_name.
+ bind_entity,
+ "", // bind_entity_name.
+ nonce_caller, encrypted_secret, session_type, symmetric_algorithm,
+ hash_algorithm, &session_handle_, &nonce_tpm,
+ nullptr); // No Authorization.
if (tpm_result) {
LOG(ERROR) << "Error creating an authorization session: "
<< GetErrorString(tpm_result);
return tpm_result;
}
- bool hmac_result = delegate->InitSession(
- session_handle_,
- nonce_tpm,
- nonce_caller,
- salt,
- bind_authorization_value,
- enable_encryption);
+ bool hmac_result =
+ delegate->InitSession(session_handle_, nonce_tpm, nonce_caller, salt,
+ bind_authorization_value, enable_encryption);
if (!hmac_result) {
LOG(ERROR) << "Failed to initialize an authorization session delegate.";
return TPM_RC_FAILURE;
diff --git a/trunks/session_manager_impl.h b/trunks/session_manager_impl.h
index 967bde6..4f3e040 100644
--- a/trunks/session_manager_impl.h
+++ b/trunks/session_manager_impl.h
@@ -68,5 +68,4 @@
} // namespace trunks
-
#endif // TRUNKS_SESSION_MANAGER_IMPL_H_
diff --git a/trunks/session_manager_test.cc b/trunks/session_manager_test.cc
index 565708c..6725b4d 100644
--- a/trunks/session_manager_test.cc
+++ b/trunks/session_manager_test.cc
@@ -44,9 +44,7 @@
}
~SessionManagerTest() override {}
- void SetUp() override {
- factory_.set_tpm(&mock_tpm_);
- }
+ void SetUp() override { factory_.set_tpm(&mock_tpm_); }
void SetHandle(TPM_HANDLE handle) {
session_manager_.session_handle_ = handle;
@@ -89,8 +87,7 @@
TEST_F(SessionManagerTest, CloseSessionNoHandle) {
TPM_HANDLE handle = kUninitializedHandle;
SetHandle(handle);
- EXPECT_CALL(mock_tpm_, FlushContextSync(handle, nullptr))
- .Times(0);
+ EXPECT_CALL(mock_tpm_, FlushContextSync(handle, nullptr)).Times(0);
session_manager_.CloseSession();
}
@@ -101,26 +98,21 @@
EXPECT_EQ(handle, session_manager_.GetSessionHandle());
}
-
TEST_F(SessionManagerTest, StartSessionSuccess) {
TPM_SE session_type = TPM_SE_TRIAL;
TPM2B_PUBLIC public_data;
public_data.public_area.type = TPM_ALG_RSA;
public_data.public_area.unique.rsa = GetValidRSAPublicKey();
EXPECT_CALL(mock_tpm_, ReadPublicSync(kSaltingKey, _, _, _, _, nullptr))
- .WillOnce(DoAll(SetArgPointee<2>(public_data),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SetArgPointee<2>(public_data), Return(TPM_RC_SUCCESS)));
TPM_HANDLE handle = TPM_RH_FIRST;
TPM2B_NONCE nonce;
nonce.size = 20;
- EXPECT_CALL(mock_tpm_, StartAuthSessionSyncShort(_, handle,
- _, _, session_type, _, _,
- _, _, _))
- .WillOnce(DoAll(SetArgPointee<8>(nonce),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(TPM_RC_SUCCESS, session_manager_.StartSession(session_type,
- handle, "", false,
- delegate_));
+ EXPECT_CALL(mock_tpm_, StartAuthSessionSyncShort(_, handle, _, _,
+ session_type, _, _, _, _, _))
+ .WillOnce(DoAll(SetArgPointee<8>(nonce), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(TPM_RC_SUCCESS, session_manager_.StartSession(
+ session_type, handle, "", false, delegate_));
}
TEST_F(SessionManagerTest, StartSessionBadSaltingKey) {
@@ -128,16 +120,14 @@
public_data.public_area.type = TPM_ALG_RSA;
public_data.public_area.unique.rsa.size = 32;
EXPECT_CALL(mock_tpm_, ReadPublicSync(kSaltingKey, _, _, _, _, nullptr))
- .WillOnce(DoAll(SetArgPointee<2>(public_data),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SetArgPointee<2>(public_data), Return(TPM_RC_SUCCESS)));
EXPECT_EQ(TRUNKS_RC_SESSION_SETUP_ERROR,
session_manager_.StartSession(TPM_SE_TRIAL, TPM_RH_NULL, "", false,
delegate_));
public_data.public_area.type = TPM_ALG_ECC;
public_data.public_area.unique.rsa.size = 256;
EXPECT_CALL(mock_tpm_, ReadPublicSync(kSaltingKey, _, _, _, _, nullptr))
- .WillOnce(DoAll(SetArgPointee<2>(public_data),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SetArgPointee<2>(public_data), Return(TPM_RC_SUCCESS)));
EXPECT_EQ(TRUNKS_RC_SESSION_SETUP_ERROR,
session_manager_.StartSession(TPM_SE_TRIAL, TPM_RH_NULL, "", false,
delegate_));
@@ -148,15 +138,13 @@
public_data.public_area.type = TPM_ALG_RSA;
public_data.public_area.unique.rsa = GetValidRSAPublicKey();
EXPECT_CALL(mock_tpm_, ReadPublicSync(kSaltingKey, _, _, _, _, nullptr))
- .WillOnce(DoAll(SetArgPointee<2>(public_data),
- Return(TPM_RC_SUCCESS)));
- EXPECT_CALL(mock_tpm_, StartAuthSessionSyncShort(_,
- TPM_RH_NULL,
- _, _, _, _, _, _, _, _))
+ .WillOnce(DoAll(SetArgPointee<2>(public_data), Return(TPM_RC_SUCCESS)));
+ EXPECT_CALL(mock_tpm_,
+ StartAuthSessionSyncShort(_, TPM_RH_NULL, _, _, _, _, _, _, _, _))
.WillOnce(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE, session_manager_.StartSession(TPM_SE_TRIAL,
- TPM_RH_NULL, "",
- false, delegate_));
+ EXPECT_EQ(TPM_RC_FAILURE,
+ session_manager_.StartSession(TPM_SE_TRIAL, TPM_RH_NULL, "", false,
+ delegate_));
}
TEST_F(SessionManagerTest, StartSessionBadNonce) {
@@ -165,19 +153,15 @@
public_data.public_area.type = TPM_ALG_RSA;
public_data.public_area.unique.rsa = GetValidRSAPublicKey();
EXPECT_CALL(mock_tpm_, ReadPublicSync(kSaltingKey, _, _, _, _, nullptr))
- .WillOnce(DoAll(SetArgPointee<2>(public_data),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SetArgPointee<2>(public_data), Return(TPM_RC_SUCCESS)));
TPM_HANDLE handle = TPM_RH_FIRST;
TPM2B_NONCE nonce;
nonce.size = 0;
- EXPECT_CALL(mock_tpm_, StartAuthSessionSyncShort(_, handle,
- _, _, session_type, _, _,
- _, _, _))
- .WillOnce(DoAll(SetArgPointee<8>(nonce),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(TPM_RC_FAILURE, session_manager_.StartSession(session_type,
- handle, "", false,
- delegate_));
+ EXPECT_CALL(mock_tpm_, StartAuthSessionSyncShort(_, handle, _, _,
+ session_type, _, _, _, _, _))
+ .WillOnce(DoAll(SetArgPointee<8>(nonce), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(TPM_RC_FAILURE, session_manager_.StartSession(
+ session_type, handle, "", false, delegate_));
}
} // namespace trunks
diff --git a/trunks/tpm_generated.cc b/trunks/tpm_generated.cc
index 70979aa..44cf3df 100644
--- a/trunks/tpm_generated.cc
+++ b/trunks/tpm_generated.cc
@@ -33,235 +33,452 @@
#include "trunks/command_transceiver.h"
#include "trunks/error_codes.h"
-
namespace trunks {
size_t GetNumberOfRequestHandles(TPM_CC command_code) {
switch (command_code) {
- case TPM_CC_Startup: return 0;
- case TPM_CC_Shutdown: return 0;
- case TPM_CC_SelfTest: return 0;
- case TPM_CC_IncrementalSelfTest: return 0;
- case TPM_CC_GetTestResult: return 0;
- case TPM_CC_StartAuthSession: return 2;
- case TPM_CC_PolicyRestart: return 1;
- case TPM_CC_Create: return 1;
- case TPM_CC_Load: return 1;
- case TPM_CC_LoadExternal: return 0;
- case TPM_CC_ReadPublic: return 1;
- case TPM_CC_ActivateCredential: return 2;
- case TPM_CC_MakeCredential: return 1;
- case TPM_CC_Unseal: return 1;
- case TPM_CC_ObjectChangeAuth: return 2;
- case TPM_CC_Duplicate: return 2;
- case TPM_CC_Rewrap: return 2;
- case TPM_CC_Import: return 1;
- case TPM_CC_RSA_Encrypt: return 1;
- case TPM_CC_RSA_Decrypt: return 1;
- case TPM_CC_ECDH_KeyGen: return 1;
- case TPM_CC_ECDH_ZGen: return 1;
- case TPM_CC_ECC_Parameters: return 0;
- case TPM_CC_ZGen_2Phase: return 1;
- case TPM_CC_EncryptDecrypt: return 1;
- case TPM_CC_Hash: return 0;
- case TPM_CC_HMAC: return 1;
- case TPM_CC_GetRandom: return 0;
- case TPM_CC_StirRandom: return 0;
- case TPM_CC_HMAC_Start: return 1;
- case TPM_CC_HashSequenceStart: return 0;
- case TPM_CC_SequenceUpdate: return 1;
- case TPM_CC_SequenceComplete: return 1;
- case TPM_CC_EventSequenceComplete: return 2;
- case TPM_CC_Certify: return 2;
- case TPM_CC_CertifyCreation: return 2;
- case TPM_CC_Quote: return 1;
- case TPM_CC_GetSessionAuditDigest: return 3;
- case TPM_CC_GetCommandAuditDigest: return 2;
- case TPM_CC_GetTime: return 2;
- case TPM_CC_Commit: return 1;
- case TPM_CC_EC_Ephemeral: return 0;
- case TPM_CC_VerifySignature: return 1;
- case TPM_CC_Sign: return 1;
- case TPM_CC_SetCommandCodeAuditStatus: return 1;
- case TPM_CC_PCR_Extend: return 1;
- case TPM_CC_PCR_Event: return 1;
- case TPM_CC_PCR_Read: return 0;
- case TPM_CC_PCR_Allocate: return 1;
- case TPM_CC_PCR_SetAuthPolicy: return 2;
- case TPM_CC_PCR_SetAuthValue: return 1;
- case TPM_CC_PCR_Reset: return 1;
- case TPM_CC_PolicySigned: return 2;
- case TPM_CC_PolicySecret: return 2;
- case TPM_CC_PolicyTicket: return 1;
- case TPM_CC_PolicyOR: return 1;
- case TPM_CC_PolicyPCR: return 1;
- case TPM_CC_PolicyLocality: return 1;
- case TPM_CC_PolicyNV: return 3;
- case TPM_CC_PolicyCounterTimer: return 1;
- case TPM_CC_PolicyCommandCode: return 1;
- case TPM_CC_PolicyPhysicalPresence: return 1;
- case TPM_CC_PolicyCpHash: return 1;
- case TPM_CC_PolicyNameHash: return 1;
- case TPM_CC_PolicyDuplicationSelect: return 1;
- case TPM_CC_PolicyAuthorize: return 1;
- case TPM_CC_PolicyAuthValue: return 1;
- case TPM_CC_PolicyPassword: return 1;
- case TPM_CC_PolicyGetDigest: return 1;
- case TPM_CC_PolicyNvWritten: return 1;
- case TPM_CC_CreatePrimary: return 1;
- case TPM_CC_HierarchyControl: return 1;
- case TPM_CC_SetPrimaryPolicy: return 1;
- case TPM_CC_ChangePPS: return 1;
- case TPM_CC_ChangeEPS: return 1;
- case TPM_CC_Clear: return 1;
- case TPM_CC_ClearControl: return 1;
- case TPM_CC_HierarchyChangeAuth: return 1;
- case TPM_CC_DictionaryAttackLockReset: return 1;
- case TPM_CC_DictionaryAttackParameters: return 1;
- case TPM_CC_PP_Commands: return 1;
- case TPM_CC_SetAlgorithmSet: return 1;
- case TPM_CC_FieldUpgradeStart: return 2;
- case TPM_CC_FieldUpgradeData: return 0;
- case TPM_CC_FirmwareRead: return 0;
- case TPM_CC_ContextSave: return 1;
- case TPM_CC_ContextLoad: return 0;
- case TPM_CC_FlushContext: return 0;
- case TPM_CC_EvictControl: return 2;
- case TPM_CC_ReadClock: return 0;
- case TPM_CC_ClockSet: return 1;
- case TPM_CC_ClockRateAdjust: return 1;
- case TPM_CC_GetCapability: return 0;
- case TPM_CC_TestParms: return 0;
- case TPM_CC_NV_DefineSpace: return 1;
- case TPM_CC_NV_UndefineSpace: return 2;
- case TPM_CC_NV_UndefineSpaceSpecial: return 2;
- case TPM_CC_NV_ReadPublic: return 1;
- case TPM_CC_NV_Write: return 2;
- case TPM_CC_NV_Increment: return 2;
- case TPM_CC_NV_Extend: return 2;
- case TPM_CC_NV_SetBits: return 2;
- case TPM_CC_NV_WriteLock: return 2;
- case TPM_CC_NV_GlobalWriteLock: return 1;
- case TPM_CC_NV_Read: return 2;
- case TPM_CC_NV_ReadLock: return 2;
- case TPM_CC_NV_ChangeAuth: return 1;
- case TPM_CC_NV_Certify: return 3;
- default: LOG(WARNING) << "Unknown command code: " << command_code;
+ case TPM_CC_Startup:
+ return 0;
+ case TPM_CC_Shutdown:
+ return 0;
+ case TPM_CC_SelfTest:
+ return 0;
+ case TPM_CC_IncrementalSelfTest:
+ return 0;
+ case TPM_CC_GetTestResult:
+ return 0;
+ case TPM_CC_StartAuthSession:
+ return 2;
+ case TPM_CC_PolicyRestart:
+ return 1;
+ case TPM_CC_Create:
+ return 1;
+ case TPM_CC_Load:
+ return 1;
+ case TPM_CC_LoadExternal:
+ return 0;
+ case TPM_CC_ReadPublic:
+ return 1;
+ case TPM_CC_ActivateCredential:
+ return 2;
+ case TPM_CC_MakeCredential:
+ return 1;
+ case TPM_CC_Unseal:
+ return 1;
+ case TPM_CC_ObjectChangeAuth:
+ return 2;
+ case TPM_CC_Duplicate:
+ return 2;
+ case TPM_CC_Rewrap:
+ return 2;
+ case TPM_CC_Import:
+ return 1;
+ case TPM_CC_RSA_Encrypt:
+ return 1;
+ case TPM_CC_RSA_Decrypt:
+ return 1;
+ case TPM_CC_ECDH_KeyGen:
+ return 1;
+ case TPM_CC_ECDH_ZGen:
+ return 1;
+ case TPM_CC_ECC_Parameters:
+ return 0;
+ case TPM_CC_ZGen_2Phase:
+ return 1;
+ case TPM_CC_EncryptDecrypt:
+ return 1;
+ case TPM_CC_Hash:
+ return 0;
+ case TPM_CC_HMAC:
+ return 1;
+ case TPM_CC_GetRandom:
+ return 0;
+ case TPM_CC_StirRandom:
+ return 0;
+ case TPM_CC_HMAC_Start:
+ return 1;
+ case TPM_CC_HashSequenceStart:
+ return 0;
+ case TPM_CC_SequenceUpdate:
+ return 1;
+ case TPM_CC_SequenceComplete:
+ return 1;
+ case TPM_CC_EventSequenceComplete:
+ return 2;
+ case TPM_CC_Certify:
+ return 2;
+ case TPM_CC_CertifyCreation:
+ return 2;
+ case TPM_CC_Quote:
+ return 1;
+ case TPM_CC_GetSessionAuditDigest:
+ return 3;
+ case TPM_CC_GetCommandAuditDigest:
+ return 2;
+ case TPM_CC_GetTime:
+ return 2;
+ case TPM_CC_Commit:
+ return 1;
+ case TPM_CC_EC_Ephemeral:
+ return 0;
+ case TPM_CC_VerifySignature:
+ return 1;
+ case TPM_CC_Sign:
+ return 1;
+ case TPM_CC_SetCommandCodeAuditStatus:
+ return 1;
+ case TPM_CC_PCR_Extend:
+ return 1;
+ case TPM_CC_PCR_Event:
+ return 1;
+ case TPM_CC_PCR_Read:
+ return 0;
+ case TPM_CC_PCR_Allocate:
+ return 1;
+ case TPM_CC_PCR_SetAuthPolicy:
+ return 2;
+ case TPM_CC_PCR_SetAuthValue:
+ return 1;
+ case TPM_CC_PCR_Reset:
+ return 1;
+ case TPM_CC_PolicySigned:
+ return 2;
+ case TPM_CC_PolicySecret:
+ return 2;
+ case TPM_CC_PolicyTicket:
+ return 1;
+ case TPM_CC_PolicyOR:
+ return 1;
+ case TPM_CC_PolicyPCR:
+ return 1;
+ case TPM_CC_PolicyLocality:
+ return 1;
+ case TPM_CC_PolicyNV:
+ return 3;
+ case TPM_CC_PolicyCounterTimer:
+ return 1;
+ case TPM_CC_PolicyCommandCode:
+ return 1;
+ case TPM_CC_PolicyPhysicalPresence:
+ return 1;
+ case TPM_CC_PolicyCpHash:
+ return 1;
+ case TPM_CC_PolicyNameHash:
+ return 1;
+ case TPM_CC_PolicyDuplicationSelect:
+ return 1;
+ case TPM_CC_PolicyAuthorize:
+ return 1;
+ case TPM_CC_PolicyAuthValue:
+ return 1;
+ case TPM_CC_PolicyPassword:
+ return 1;
+ case TPM_CC_PolicyGetDigest:
+ return 1;
+ case TPM_CC_PolicyNvWritten:
+ return 1;
+ case TPM_CC_CreatePrimary:
+ return 1;
+ case TPM_CC_HierarchyControl:
+ return 1;
+ case TPM_CC_SetPrimaryPolicy:
+ return 1;
+ case TPM_CC_ChangePPS:
+ return 1;
+ case TPM_CC_ChangeEPS:
+ return 1;
+ case TPM_CC_Clear:
+ return 1;
+ case TPM_CC_ClearControl:
+ return 1;
+ case TPM_CC_HierarchyChangeAuth:
+ return 1;
+ case TPM_CC_DictionaryAttackLockReset:
+ return 1;
+ case TPM_CC_DictionaryAttackParameters:
+ return 1;
+ case TPM_CC_PP_Commands:
+ return 1;
+ case TPM_CC_SetAlgorithmSet:
+ return 1;
+ case TPM_CC_FieldUpgradeStart:
+ return 2;
+ case TPM_CC_FieldUpgradeData:
+ return 0;
+ case TPM_CC_FirmwareRead:
+ return 0;
+ case TPM_CC_ContextSave:
+ return 1;
+ case TPM_CC_ContextLoad:
+ return 0;
+ case TPM_CC_FlushContext:
+ return 0;
+ case TPM_CC_EvictControl:
+ return 2;
+ case TPM_CC_ReadClock:
+ return 0;
+ case TPM_CC_ClockSet:
+ return 1;
+ case TPM_CC_ClockRateAdjust:
+ return 1;
+ case TPM_CC_GetCapability:
+ return 0;
+ case TPM_CC_TestParms:
+ return 0;
+ case TPM_CC_NV_DefineSpace:
+ return 1;
+ case TPM_CC_NV_UndefineSpace:
+ return 2;
+ case TPM_CC_NV_UndefineSpaceSpecial:
+ return 2;
+ case TPM_CC_NV_ReadPublic:
+ return 1;
+ case TPM_CC_NV_Write:
+ return 2;
+ case TPM_CC_NV_Increment:
+ return 2;
+ case TPM_CC_NV_Extend:
+ return 2;
+ case TPM_CC_NV_SetBits:
+ return 2;
+ case TPM_CC_NV_WriteLock:
+ return 2;
+ case TPM_CC_NV_GlobalWriteLock:
+ return 1;
+ case TPM_CC_NV_Read:
+ return 2;
+ case TPM_CC_NV_ReadLock:
+ return 2;
+ case TPM_CC_NV_ChangeAuth:
+ return 1;
+ case TPM_CC_NV_Certify:
+ return 3;
+ default:
+ LOG(WARNING) << "Unknown command code: " << command_code;
}
return 0;
}
size_t GetNumberOfResponseHandles(TPM_CC command_code) {
switch (command_code) {
- case TPM_CC_Startup: return 0;
- case TPM_CC_Shutdown: return 0;
- case TPM_CC_SelfTest: return 0;
- case TPM_CC_IncrementalSelfTest: return 0;
- case TPM_CC_GetTestResult: return 0;
- case TPM_CC_StartAuthSession: return 1;
- case TPM_CC_PolicyRestart: return 0;
- case TPM_CC_Create: return 0;
- case TPM_CC_Load: return 1;
- case TPM_CC_LoadExternal: return 1;
- case TPM_CC_ReadPublic: return 0;
- case TPM_CC_ActivateCredential: return 0;
- case TPM_CC_MakeCredential: return 0;
- case TPM_CC_Unseal: return 0;
- case TPM_CC_ObjectChangeAuth: return 0;
- case TPM_CC_Duplicate: return 0;
- case TPM_CC_Rewrap: return 0;
- case TPM_CC_Import: return 0;
- case TPM_CC_RSA_Encrypt: return 0;
- case TPM_CC_RSA_Decrypt: return 0;
- case TPM_CC_ECDH_KeyGen: return 0;
- case TPM_CC_ECDH_ZGen: return 0;
- case TPM_CC_ECC_Parameters: return 0;
- case TPM_CC_ZGen_2Phase: return 0;
- case TPM_CC_EncryptDecrypt: return 0;
- case TPM_CC_Hash: return 0;
- case TPM_CC_HMAC: return 0;
- case TPM_CC_GetRandom: return 0;
- case TPM_CC_StirRandom: return 0;
- case TPM_CC_HMAC_Start: return 1;
- case TPM_CC_HashSequenceStart: return 1;
- case TPM_CC_SequenceUpdate: return 0;
- case TPM_CC_SequenceComplete: return 0;
- case TPM_CC_EventSequenceComplete: return 0;
- case TPM_CC_Certify: return 0;
- case TPM_CC_CertifyCreation: return 0;
- case TPM_CC_Quote: return 0;
- case TPM_CC_GetSessionAuditDigest: return 0;
- case TPM_CC_GetCommandAuditDigest: return 0;
- case TPM_CC_GetTime: return 0;
- case TPM_CC_Commit: return 0;
- case TPM_CC_EC_Ephemeral: return 0;
- case TPM_CC_VerifySignature: return 0;
- case TPM_CC_Sign: return 0;
- case TPM_CC_SetCommandCodeAuditStatus: return 0;
- case TPM_CC_PCR_Extend: return 0;
- case TPM_CC_PCR_Event: return 0;
- case TPM_CC_PCR_Read: return 0;
- case TPM_CC_PCR_Allocate: return 0;
- case TPM_CC_PCR_SetAuthPolicy: return 0;
- case TPM_CC_PCR_SetAuthValue: return 0;
- case TPM_CC_PCR_Reset: return 0;
- case TPM_CC_PolicySigned: return 0;
- case TPM_CC_PolicySecret: return 0;
- case TPM_CC_PolicyTicket: return 0;
- case TPM_CC_PolicyOR: return 0;
- case TPM_CC_PolicyPCR: return 0;
- case TPM_CC_PolicyLocality: return 0;
- case TPM_CC_PolicyNV: return 0;
- case TPM_CC_PolicyCounterTimer: return 0;
- case TPM_CC_PolicyCommandCode: return 0;
- case TPM_CC_PolicyPhysicalPresence: return 0;
- case TPM_CC_PolicyCpHash: return 0;
- case TPM_CC_PolicyNameHash: return 0;
- case TPM_CC_PolicyDuplicationSelect: return 0;
- case TPM_CC_PolicyAuthorize: return 0;
- case TPM_CC_PolicyAuthValue: return 0;
- case TPM_CC_PolicyPassword: return 0;
- case TPM_CC_PolicyGetDigest: return 0;
- case TPM_CC_PolicyNvWritten: return 0;
- case TPM_CC_CreatePrimary: return 1;
- case TPM_CC_HierarchyControl: return 0;
- case TPM_CC_SetPrimaryPolicy: return 0;
- case TPM_CC_ChangePPS: return 0;
- case TPM_CC_ChangeEPS: return 0;
- case TPM_CC_Clear: return 0;
- case TPM_CC_ClearControl: return 0;
- case TPM_CC_HierarchyChangeAuth: return 0;
- case TPM_CC_DictionaryAttackLockReset: return 0;
- case TPM_CC_DictionaryAttackParameters: return 0;
- case TPM_CC_PP_Commands: return 0;
- case TPM_CC_SetAlgorithmSet: return 0;
- case TPM_CC_FieldUpgradeStart: return 0;
- case TPM_CC_FieldUpgradeData: return 0;
- case TPM_CC_FirmwareRead: return 0;
- case TPM_CC_ContextSave: return 0;
- case TPM_CC_ContextLoad: return 1;
- case TPM_CC_FlushContext: return 0;
- case TPM_CC_EvictControl: return 0;
- case TPM_CC_ReadClock: return 0;
- case TPM_CC_ClockSet: return 0;
- case TPM_CC_ClockRateAdjust: return 0;
- case TPM_CC_GetCapability: return 0;
- case TPM_CC_TestParms: return 0;
- case TPM_CC_NV_DefineSpace: return 0;
- case TPM_CC_NV_UndefineSpace: return 0;
- case TPM_CC_NV_UndefineSpaceSpecial: return 0;
- case TPM_CC_NV_ReadPublic: return 0;
- case TPM_CC_NV_Write: return 0;
- case TPM_CC_NV_Increment: return 0;
- case TPM_CC_NV_Extend: return 0;
- case TPM_CC_NV_SetBits: return 0;
- case TPM_CC_NV_WriteLock: return 0;
- case TPM_CC_NV_GlobalWriteLock: return 0;
- case TPM_CC_NV_Read: return 0;
- case TPM_CC_NV_ReadLock: return 0;
- case TPM_CC_NV_ChangeAuth: return 0;
- case TPM_CC_NV_Certify: return 0;
- default: LOG(WARNING) << "Unknown command code: " << command_code;
+ case TPM_CC_Startup:
+ return 0;
+ case TPM_CC_Shutdown:
+ return 0;
+ case TPM_CC_SelfTest:
+ return 0;
+ case TPM_CC_IncrementalSelfTest:
+ return 0;
+ case TPM_CC_GetTestResult:
+ return 0;
+ case TPM_CC_StartAuthSession:
+ return 1;
+ case TPM_CC_PolicyRestart:
+ return 0;
+ case TPM_CC_Create:
+ return 0;
+ case TPM_CC_Load:
+ return 1;
+ case TPM_CC_LoadExternal:
+ return 1;
+ case TPM_CC_ReadPublic:
+ return 0;
+ case TPM_CC_ActivateCredential:
+ return 0;
+ case TPM_CC_MakeCredential:
+ return 0;
+ case TPM_CC_Unseal:
+ return 0;
+ case TPM_CC_ObjectChangeAuth:
+ return 0;
+ case TPM_CC_Duplicate:
+ return 0;
+ case TPM_CC_Rewrap:
+ return 0;
+ case TPM_CC_Import:
+ return 0;
+ case TPM_CC_RSA_Encrypt:
+ return 0;
+ case TPM_CC_RSA_Decrypt:
+ return 0;
+ case TPM_CC_ECDH_KeyGen:
+ return 0;
+ case TPM_CC_ECDH_ZGen:
+ return 0;
+ case TPM_CC_ECC_Parameters:
+ return 0;
+ case TPM_CC_ZGen_2Phase:
+ return 0;
+ case TPM_CC_EncryptDecrypt:
+ return 0;
+ case TPM_CC_Hash:
+ return 0;
+ case TPM_CC_HMAC:
+ return 0;
+ case TPM_CC_GetRandom:
+ return 0;
+ case TPM_CC_StirRandom:
+ return 0;
+ case TPM_CC_HMAC_Start:
+ return 1;
+ case TPM_CC_HashSequenceStart:
+ return 1;
+ case TPM_CC_SequenceUpdate:
+ return 0;
+ case TPM_CC_SequenceComplete:
+ return 0;
+ case TPM_CC_EventSequenceComplete:
+ return 0;
+ case TPM_CC_Certify:
+ return 0;
+ case TPM_CC_CertifyCreation:
+ return 0;
+ case TPM_CC_Quote:
+ return 0;
+ case TPM_CC_GetSessionAuditDigest:
+ return 0;
+ case TPM_CC_GetCommandAuditDigest:
+ return 0;
+ case TPM_CC_GetTime:
+ return 0;
+ case TPM_CC_Commit:
+ return 0;
+ case TPM_CC_EC_Ephemeral:
+ return 0;
+ case TPM_CC_VerifySignature:
+ return 0;
+ case TPM_CC_Sign:
+ return 0;
+ case TPM_CC_SetCommandCodeAuditStatus:
+ return 0;
+ case TPM_CC_PCR_Extend:
+ return 0;
+ case TPM_CC_PCR_Event:
+ return 0;
+ case TPM_CC_PCR_Read:
+ return 0;
+ case TPM_CC_PCR_Allocate:
+ return 0;
+ case TPM_CC_PCR_SetAuthPolicy:
+ return 0;
+ case TPM_CC_PCR_SetAuthValue:
+ return 0;
+ case TPM_CC_PCR_Reset:
+ return 0;
+ case TPM_CC_PolicySigned:
+ return 0;
+ case TPM_CC_PolicySecret:
+ return 0;
+ case TPM_CC_PolicyTicket:
+ return 0;
+ case TPM_CC_PolicyOR:
+ return 0;
+ case TPM_CC_PolicyPCR:
+ return 0;
+ case TPM_CC_PolicyLocality:
+ return 0;
+ case TPM_CC_PolicyNV:
+ return 0;
+ case TPM_CC_PolicyCounterTimer:
+ return 0;
+ case TPM_CC_PolicyCommandCode:
+ return 0;
+ case TPM_CC_PolicyPhysicalPresence:
+ return 0;
+ case TPM_CC_PolicyCpHash:
+ return 0;
+ case TPM_CC_PolicyNameHash:
+ return 0;
+ case TPM_CC_PolicyDuplicationSelect:
+ return 0;
+ case TPM_CC_PolicyAuthorize:
+ return 0;
+ case TPM_CC_PolicyAuthValue:
+ return 0;
+ case TPM_CC_PolicyPassword:
+ return 0;
+ case TPM_CC_PolicyGetDigest:
+ return 0;
+ case TPM_CC_PolicyNvWritten:
+ return 0;
+ case TPM_CC_CreatePrimary:
+ return 1;
+ case TPM_CC_HierarchyControl:
+ return 0;
+ case TPM_CC_SetPrimaryPolicy:
+ return 0;
+ case TPM_CC_ChangePPS:
+ return 0;
+ case TPM_CC_ChangeEPS:
+ return 0;
+ case TPM_CC_Clear:
+ return 0;
+ case TPM_CC_ClearControl:
+ return 0;
+ case TPM_CC_HierarchyChangeAuth:
+ return 0;
+ case TPM_CC_DictionaryAttackLockReset:
+ return 0;
+ case TPM_CC_DictionaryAttackParameters:
+ return 0;
+ case TPM_CC_PP_Commands:
+ return 0;
+ case TPM_CC_SetAlgorithmSet:
+ return 0;
+ case TPM_CC_FieldUpgradeStart:
+ return 0;
+ case TPM_CC_FieldUpgradeData:
+ return 0;
+ case TPM_CC_FirmwareRead:
+ return 0;
+ case TPM_CC_ContextSave:
+ return 0;
+ case TPM_CC_ContextLoad:
+ return 1;
+ case TPM_CC_FlushContext:
+ return 0;
+ case TPM_CC_EvictControl:
+ return 0;
+ case TPM_CC_ReadClock:
+ return 0;
+ case TPM_CC_ClockSet:
+ return 0;
+ case TPM_CC_ClockRateAdjust:
+ return 0;
+ case TPM_CC_GetCapability:
+ return 0;
+ case TPM_CC_TestParms:
+ return 0;
+ case TPM_CC_NV_DefineSpace:
+ return 0;
+ case TPM_CC_NV_UndefineSpace:
+ return 0;
+ case TPM_CC_NV_UndefineSpaceSpecial:
+ return 0;
+ case TPM_CC_NV_ReadPublic:
+ return 0;
+ case TPM_CC_NV_Write:
+ return 0;
+ case TPM_CC_NV_Increment:
+ return 0;
+ case TPM_CC_NV_Extend:
+ return 0;
+ case TPM_CC_NV_SetBits:
+ return 0;
+ case TPM_CC_NV_WriteLock:
+ return 0;
+ case TPM_CC_NV_GlobalWriteLock:
+ return 0;
+ case TPM_CC_NV_Read:
+ return 0;
+ case TPM_CC_NV_ReadLock:
+ return 0;
+ case TPM_CC_NV_ChangeAuth:
+ return 0;
+ case TPM_CC_NV_Certify:
+ return 0;
+ default:
+ LOG(WARNING) << "Unknown command code: " << command_code;
}
return 0;
}
@@ -287,10 +504,9 @@
return TPM_RC_SUCCESS;
}
-TPM_RC Parse_uint8_t(
- std::string* buffer,
- uint8_t* value,
- std::string* value_bytes) {
+TPM_RC Parse_uint8_t(std::string* buffer,
+ uint8_t* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
if (buffer->size() < sizeof(uint8_t))
return TPM_RC_INSUFFICIENT;
@@ -337,10 +553,9 @@
return TPM_RC_SUCCESS;
}
-TPM_RC Parse_int8_t(
- std::string* buffer,
- int8_t* value,
- std::string* value_bytes) {
+TPM_RC Parse_int8_t(std::string* buffer,
+ int8_t* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
if (buffer->size() < sizeof(int8_t))
return TPM_RC_INSUFFICIENT;
@@ -387,10 +602,7 @@
return TPM_RC_SUCCESS;
}
-TPM_RC Parse_int(
- std::string* buffer,
- int* value,
- std::string* value_bytes) {
+TPM_RC Parse_int(std::string* buffer, int* value, std::string* value_bytes) {
VLOG(3) << __func__;
if (buffer->size() < sizeof(int))
return TPM_RC_INSUFFICIENT;
@@ -437,10 +649,9 @@
return TPM_RC_SUCCESS;
}
-TPM_RC Parse_uint16_t(
- std::string* buffer,
- uint16_t* value,
- std::string* value_bytes) {
+TPM_RC Parse_uint16_t(std::string* buffer,
+ uint16_t* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
if (buffer->size() < sizeof(uint16_t))
return TPM_RC_INSUFFICIENT;
@@ -487,10 +698,9 @@
return TPM_RC_SUCCESS;
}
-TPM_RC Parse_int16_t(
- std::string* buffer,
- int16_t* value,
- std::string* value_bytes) {
+TPM_RC Parse_int16_t(std::string* buffer,
+ int16_t* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
if (buffer->size() < sizeof(int16_t))
return TPM_RC_INSUFFICIENT;
@@ -537,10 +747,9 @@
return TPM_RC_SUCCESS;
}
-TPM_RC Parse_uint32_t(
- std::string* buffer,
- uint32_t* value,
- std::string* value_bytes) {
+TPM_RC Parse_uint32_t(std::string* buffer,
+ uint32_t* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
if (buffer->size() < sizeof(uint32_t))
return TPM_RC_INSUFFICIENT;
@@ -587,10 +796,9 @@
return TPM_RC_SUCCESS;
}
-TPM_RC Parse_int32_t(
- std::string* buffer,
- int32_t* value,
- std::string* value_bytes) {
+TPM_RC Parse_int32_t(std::string* buffer,
+ int32_t* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
if (buffer->size() < sizeof(int32_t))
return TPM_RC_INSUFFICIENT;
@@ -637,10 +845,9 @@
return TPM_RC_SUCCESS;
}
-TPM_RC Parse_uint64_t(
- std::string* buffer,
- uint64_t* value,
- std::string* value_bytes) {
+TPM_RC Parse_uint64_t(std::string* buffer,
+ uint64_t* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
if (buffer->size() < sizeof(uint64_t))
return TPM_RC_INSUFFICIENT;
@@ -687,10 +894,9 @@
return TPM_RC_SUCCESS;
}
-TPM_RC Parse_int64_t(
- std::string* buffer,
- int64_t* value,
- std::string* value_bytes) {
+TPM_RC Parse_int64_t(std::string* buffer,
+ int64_t* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
if (buffer->size() < sizeof(int64_t))
return TPM_RC_INSUFFICIENT;
@@ -716,264 +922,209 @@
return TPM_RC_SUCCESS;
}
-TPM_RC Serialize_UINT8(
- const UINT8& value,
- std::string* buffer) {
+TPM_RC Serialize_UINT8(const UINT8& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_uint8_t(value, buffer);
}
-TPM_RC Parse_UINT8(
- std::string* buffer,
- UINT8* value,
- std::string* value_bytes) {
+TPM_RC Parse_UINT8(std::string* buffer,
+ UINT8* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_uint8_t(buffer, value, value_bytes);
}
-TPM_RC Serialize_BYTE(
- const BYTE& value,
- std::string* buffer) {
+TPM_RC Serialize_BYTE(const BYTE& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_uint8_t(value, buffer);
}
-TPM_RC Parse_BYTE(
- std::string* buffer,
- BYTE* value,
- std::string* value_bytes) {
+TPM_RC Parse_BYTE(std::string* buffer, BYTE* value, std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_uint8_t(buffer, value, value_bytes);
}
-TPM_RC Serialize_INT8(
- const INT8& value,
- std::string* buffer) {
+TPM_RC Serialize_INT8(const INT8& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_int8_t(value, buffer);
}
-TPM_RC Parse_INT8(
- std::string* buffer,
- INT8* value,
- std::string* value_bytes) {
+TPM_RC Parse_INT8(std::string* buffer, INT8* value, std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_int8_t(buffer, value, value_bytes);
}
-TPM_RC Serialize_BOOL(
- const BOOL& value,
- std::string* buffer) {
+TPM_RC Serialize_BOOL(const BOOL& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_int(value, buffer);
}
-TPM_RC Parse_BOOL(
- std::string* buffer,
- BOOL* value,
- std::string* value_bytes) {
+TPM_RC Parse_BOOL(std::string* buffer, BOOL* value, std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_int(buffer, value, value_bytes);
}
-TPM_RC Serialize_UINT16(
- const UINT16& value,
- std::string* buffer) {
+TPM_RC Serialize_UINT16(const UINT16& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_uint16_t(value, buffer);
}
-TPM_RC Parse_UINT16(
- std::string* buffer,
- UINT16* value,
- std::string* value_bytes) {
+TPM_RC Parse_UINT16(std::string* buffer,
+ UINT16* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_uint16_t(buffer, value, value_bytes);
}
-TPM_RC Serialize_INT16(
- const INT16& value,
- std::string* buffer) {
+TPM_RC Serialize_INT16(const INT16& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_int16_t(value, buffer);
}
-TPM_RC Parse_INT16(
- std::string* buffer,
- INT16* value,
- std::string* value_bytes) {
+TPM_RC Parse_INT16(std::string* buffer,
+ INT16* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_int16_t(buffer, value, value_bytes);
}
-TPM_RC Serialize_UINT32(
- const UINT32& value,
- std::string* buffer) {
+TPM_RC Serialize_UINT32(const UINT32& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_uint32_t(value, buffer);
}
-TPM_RC Parse_UINT32(
- std::string* buffer,
- UINT32* value,
- std::string* value_bytes) {
+TPM_RC Parse_UINT32(std::string* buffer,
+ UINT32* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_uint32_t(buffer, value, value_bytes);
}
-TPM_RC Serialize_INT32(
- const INT32& value,
- std::string* buffer) {
+TPM_RC Serialize_INT32(const INT32& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_int32_t(value, buffer);
}
-TPM_RC Parse_INT32(
- std::string* buffer,
- INT32* value,
- std::string* value_bytes) {
+TPM_RC Parse_INT32(std::string* buffer,
+ INT32* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_int32_t(buffer, value, value_bytes);
}
-TPM_RC Serialize_UINT64(
- const UINT64& value,
- std::string* buffer) {
+TPM_RC Serialize_UINT64(const UINT64& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_uint64_t(value, buffer);
}
-TPM_RC Parse_UINT64(
- std::string* buffer,
- UINT64* value,
- std::string* value_bytes) {
+TPM_RC Parse_UINT64(std::string* buffer,
+ UINT64* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_uint64_t(buffer, value, value_bytes);
}
-TPM_RC Serialize_INT64(
- const INT64& value,
- std::string* buffer) {
+TPM_RC Serialize_INT64(const INT64& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_int64_t(value, buffer);
}
-TPM_RC Parse_INT64(
- std::string* buffer,
- INT64* value,
- std::string* value_bytes) {
+TPM_RC Parse_INT64(std::string* buffer,
+ INT64* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_int64_t(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_ALGORITHM_ID(
- const TPM_ALGORITHM_ID& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_ALGORITHM_ID(const TPM_ALGORITHM_ID& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPM_ALGORITHM_ID(
- std::string* buffer,
- TPM_ALGORITHM_ID* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_ALGORITHM_ID(std::string* buffer,
+ TPM_ALGORITHM_ID* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_MODIFIER_INDICATOR(
- const TPM_MODIFIER_INDICATOR& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_MODIFIER_INDICATOR(const TPM_MODIFIER_INDICATOR& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPM_MODIFIER_INDICATOR(
- std::string* buffer,
- TPM_MODIFIER_INDICATOR* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_MODIFIER_INDICATOR(std::string* buffer,
+ TPM_MODIFIER_INDICATOR* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_AUTHORIZATION_SIZE(
- const TPM_AUTHORIZATION_SIZE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_AUTHORIZATION_SIZE(const TPM_AUTHORIZATION_SIZE& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPM_AUTHORIZATION_SIZE(
- std::string* buffer,
- TPM_AUTHORIZATION_SIZE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_AUTHORIZATION_SIZE(std::string* buffer,
+ TPM_AUTHORIZATION_SIZE* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_PARAMETER_SIZE(
- const TPM_PARAMETER_SIZE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_PARAMETER_SIZE(const TPM_PARAMETER_SIZE& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPM_PARAMETER_SIZE(
- std::string* buffer,
- TPM_PARAMETER_SIZE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_PARAMETER_SIZE(std::string* buffer,
+ TPM_PARAMETER_SIZE* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_KEY_SIZE(
- const TPM_KEY_SIZE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_KEY_SIZE(const TPM_KEY_SIZE& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT16(value, buffer);
}
-TPM_RC Parse_TPM_KEY_SIZE(
- std::string* buffer,
- TPM_KEY_SIZE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_KEY_SIZE(std::string* buffer,
+ TPM_KEY_SIZE* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT16(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_KEY_BITS(
- const TPM_KEY_BITS& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_KEY_BITS(const TPM_KEY_BITS& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT16(value, buffer);
}
-TPM_RC Parse_TPM_KEY_BITS(
- std::string* buffer,
- TPM_KEY_BITS* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_KEY_BITS(std::string* buffer,
+ TPM_KEY_BITS* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT16(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_HANDLE(
- const TPM_HANDLE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_HANDLE(const TPM_HANDLE& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPM_HANDLE(
- std::string* buffer,
- TPM_HANDLE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_HANDLE(std::string* buffer,
+ TPM_HANDLE* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM2B_DIGEST(
- const TPM2B_DIGEST& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_DIGEST(const TPM2B_DIGEST& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -994,17 +1145,13 @@
return result;
}
-TPM_RC Parse_TPM2B_DIGEST(
- std::string* buffer,
- TPM2B_DIGEST* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_DIGEST(std::string* buffer,
+ TPM2B_DIGEST* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -1013,10 +1160,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->buffer[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->buffer[i], value_bytes);
if (result) {
return result;
}
@@ -1024,8 +1168,7 @@
return result;
}
-TPM2B_DIGEST Make_TPM2B_DIGEST(
- const std::string& bytes) {
+TPM2B_DIGEST Make_TPM2B_DIGEST(const std::string& bytes) {
TPM2B_DIGEST tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.buffer));
memset(&tpm2b, 0, sizeof(TPM2B_DIGEST));
@@ -1034,91 +1177,75 @@
return tpm2b;
}
-std::string StringFrom_TPM2B_DIGEST(
- const TPM2B_DIGEST& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.buffer);
+std::string StringFrom_TPM2B_DIGEST(const TPM2B_DIGEST& tpm2b) {
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.buffer);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPM2B_NONCE(
- const TPM2B_NONCE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_NONCE(const TPM2B_NONCE& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM2B_DIGEST(value, buffer);
}
-TPM_RC Parse_TPM2B_NONCE(
- std::string* buffer,
- TPM2B_NONCE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_NONCE(std::string* buffer,
+ TPM2B_NONCE* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM2B_DIGEST(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM2B_AUTH(
- const TPM2B_AUTH& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_AUTH(const TPM2B_AUTH& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM2B_DIGEST(value, buffer);
}
-TPM_RC Parse_TPM2B_AUTH(
- std::string* buffer,
- TPM2B_AUTH* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_AUTH(std::string* buffer,
+ TPM2B_AUTH* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM2B_DIGEST(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM2B_OPERAND(
- const TPM2B_OPERAND& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_OPERAND(const TPM2B_OPERAND& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM2B_DIGEST(value, buffer);
}
-TPM_RC Parse_TPM2B_OPERAND(
- std::string* buffer,
- TPM2B_OPERAND* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_OPERAND(std::string* buffer,
+ TPM2B_OPERAND* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM2B_DIGEST(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_ALG_ID(
- const TPM_ALG_ID& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_ALG_ID(const TPM_ALG_ID& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT16(value, buffer);
}
-TPM_RC Parse_TPM_ALG_ID(
- std::string* buffer,
- TPM_ALG_ID* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_ALG_ID(std::string* buffer,
+ TPM_ALG_ID* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT16(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_ALG_HASH(
- const TPMI_ALG_HASH& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_ALG_HASH(const TPMI_ALG_HASH& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_ALG_ID(value, buffer);
}
-TPM_RC Parse_TPMI_ALG_HASH(
- std::string* buffer,
- TPMI_ALG_HASH* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_ALG_HASH(std::string* buffer,
+ TPMI_ALG_HASH* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_ALG_ID(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMS_SCHEME_SIGHASH(
- const TPMS_SCHEME_SIGHASH& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SCHEME_SIGHASH(const TPMS_SCHEME_SIGHASH& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -1129,589 +1256,503 @@
return result;
}
-TPM_RC Parse_TPMS_SCHEME_SIGHASH(
- std::string* buffer,
- TPMS_SCHEME_SIGHASH* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SCHEME_SIGHASH(std::string* buffer,
+ TPMS_SCHEME_SIGHASH* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_HASH(
- buffer,
- &value->hash_alg,
- value_bytes);
+ result = Parse_TPMI_ALG_HASH(buffer, &value->hash_alg, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_SCHEME_HMAC(
- const TPMS_SCHEME_HMAC& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SCHEME_HMAC(const TPMS_SCHEME_HMAC& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPMS_SCHEME_SIGHASH(value, buffer);
}
-TPM_RC Parse_TPMS_SCHEME_HMAC(
- std::string* buffer,
- TPMS_SCHEME_HMAC* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SCHEME_HMAC(std::string* buffer,
+ TPMS_SCHEME_HMAC* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPMS_SCHEME_SIGHASH(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMS_SCHEME_RSASSA(
- const TPMS_SCHEME_RSASSA& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SCHEME_RSASSA(const TPMS_SCHEME_RSASSA& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPMS_SCHEME_SIGHASH(value, buffer);
}
-TPM_RC Parse_TPMS_SCHEME_RSASSA(
- std::string* buffer,
- TPMS_SCHEME_RSASSA* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SCHEME_RSASSA(std::string* buffer,
+ TPMS_SCHEME_RSASSA* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPMS_SCHEME_SIGHASH(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMS_SCHEME_RSAPSS(
- const TPMS_SCHEME_RSAPSS& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SCHEME_RSAPSS(const TPMS_SCHEME_RSAPSS& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPMS_SCHEME_SIGHASH(value, buffer);
}
-TPM_RC Parse_TPMS_SCHEME_RSAPSS(
- std::string* buffer,
- TPMS_SCHEME_RSAPSS* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SCHEME_RSAPSS(std::string* buffer,
+ TPMS_SCHEME_RSAPSS* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPMS_SCHEME_SIGHASH(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMS_SCHEME_ECDSA(
- const TPMS_SCHEME_ECDSA& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SCHEME_ECDSA(const TPMS_SCHEME_ECDSA& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPMS_SCHEME_SIGHASH(value, buffer);
}
-TPM_RC Parse_TPMS_SCHEME_ECDSA(
- std::string* buffer,
- TPMS_SCHEME_ECDSA* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SCHEME_ECDSA(std::string* buffer,
+ TPMS_SCHEME_ECDSA* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPMS_SCHEME_SIGHASH(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMS_SCHEME_SM2(
- const TPMS_SCHEME_SM2& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SCHEME_SM2(const TPMS_SCHEME_SM2& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPMS_SCHEME_SIGHASH(value, buffer);
}
-TPM_RC Parse_TPMS_SCHEME_SM2(
- std::string* buffer,
- TPMS_SCHEME_SM2* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SCHEME_SM2(std::string* buffer,
+ TPMS_SCHEME_SM2* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPMS_SCHEME_SIGHASH(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMS_SCHEME_ECSCHNORR(
- const TPMS_SCHEME_ECSCHNORR& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SCHEME_ECSCHNORR(const TPMS_SCHEME_ECSCHNORR& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPMS_SCHEME_SIGHASH(value, buffer);
}
-TPM_RC Parse_TPMS_SCHEME_ECSCHNORR(
- std::string* buffer,
- TPMS_SCHEME_ECSCHNORR* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SCHEME_ECSCHNORR(std::string* buffer,
+ TPMS_SCHEME_ECSCHNORR* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPMS_SCHEME_SIGHASH(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_YES_NO(
- const TPMI_YES_NO& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_YES_NO(const TPMI_YES_NO& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_BYTE(value, buffer);
}
-TPM_RC Parse_TPMI_YES_NO(
- std::string* buffer,
- TPMI_YES_NO* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_YES_NO(std::string* buffer,
+ TPMI_YES_NO* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_BYTE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_DH_OBJECT(
- const TPMI_DH_OBJECT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_DH_OBJECT(const TPMI_DH_OBJECT& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_DH_OBJECT(
- std::string* buffer,
- TPMI_DH_OBJECT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_DH_OBJECT(std::string* buffer,
+ TPMI_DH_OBJECT* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_DH_PERSISTENT(
- const TPMI_DH_PERSISTENT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_DH_PERSISTENT(const TPMI_DH_PERSISTENT& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_DH_PERSISTENT(
- std::string* buffer,
- TPMI_DH_PERSISTENT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_DH_PERSISTENT(std::string* buffer,
+ TPMI_DH_PERSISTENT* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_DH_ENTITY(
- const TPMI_DH_ENTITY& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_DH_ENTITY(const TPMI_DH_ENTITY& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_DH_ENTITY(
- std::string* buffer,
- TPMI_DH_ENTITY* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_DH_ENTITY(std::string* buffer,
+ TPMI_DH_ENTITY* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_DH_PCR(
- const TPMI_DH_PCR& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_DH_PCR(const TPMI_DH_PCR& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_DH_PCR(
- std::string* buffer,
- TPMI_DH_PCR* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_DH_PCR(std::string* buffer,
+ TPMI_DH_PCR* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_SH_AUTH_SESSION(
- const TPMI_SH_AUTH_SESSION& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_SH_AUTH_SESSION(const TPMI_SH_AUTH_SESSION& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_SH_AUTH_SESSION(
- std::string* buffer,
- TPMI_SH_AUTH_SESSION* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_SH_AUTH_SESSION(std::string* buffer,
+ TPMI_SH_AUTH_SESSION* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_SH_HMAC(
- const TPMI_SH_HMAC& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_SH_HMAC(const TPMI_SH_HMAC& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_SH_HMAC(
- std::string* buffer,
- TPMI_SH_HMAC* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_SH_HMAC(std::string* buffer,
+ TPMI_SH_HMAC* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_SH_POLICY(
- const TPMI_SH_POLICY& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_SH_POLICY(const TPMI_SH_POLICY& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_SH_POLICY(
- std::string* buffer,
- TPMI_SH_POLICY* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_SH_POLICY(std::string* buffer,
+ TPMI_SH_POLICY* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_DH_CONTEXT(
- const TPMI_DH_CONTEXT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_DH_CONTEXT(const TPMI_DH_CONTEXT& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_DH_CONTEXT(
- std::string* buffer,
- TPMI_DH_CONTEXT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_DH_CONTEXT(std::string* buffer,
+ TPMI_DH_CONTEXT* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_RH_HIERARCHY(
- const TPMI_RH_HIERARCHY& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_RH_HIERARCHY(const TPMI_RH_HIERARCHY& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_RH_HIERARCHY(
- std::string* buffer,
- TPMI_RH_HIERARCHY* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_RH_HIERARCHY(std::string* buffer,
+ TPMI_RH_HIERARCHY* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_RH_ENABLES(
- const TPMI_RH_ENABLES& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_RH_ENABLES(const TPMI_RH_ENABLES& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_RH_ENABLES(
- std::string* buffer,
- TPMI_RH_ENABLES* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_RH_ENABLES(std::string* buffer,
+ TPMI_RH_ENABLES* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_RH_HIERARCHY_AUTH(
- const TPMI_RH_HIERARCHY_AUTH& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_RH_HIERARCHY_AUTH(const TPMI_RH_HIERARCHY_AUTH& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_RH_HIERARCHY_AUTH(
- std::string* buffer,
- TPMI_RH_HIERARCHY_AUTH* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_RH_HIERARCHY_AUTH(std::string* buffer,
+ TPMI_RH_HIERARCHY_AUTH* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_RH_PLATFORM(
- const TPMI_RH_PLATFORM& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_RH_PLATFORM(const TPMI_RH_PLATFORM& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_RH_PLATFORM(
- std::string* buffer,
- TPMI_RH_PLATFORM* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_RH_PLATFORM(std::string* buffer,
+ TPMI_RH_PLATFORM* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_RH_OWNER(
- const TPMI_RH_OWNER& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_RH_OWNER(const TPMI_RH_OWNER& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_RH_OWNER(
- std::string* buffer,
- TPMI_RH_OWNER* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_RH_OWNER(std::string* buffer,
+ TPMI_RH_OWNER* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_RH_ENDORSEMENT(
- const TPMI_RH_ENDORSEMENT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_RH_ENDORSEMENT(const TPMI_RH_ENDORSEMENT& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_RH_ENDORSEMENT(
- std::string* buffer,
- TPMI_RH_ENDORSEMENT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_RH_ENDORSEMENT(std::string* buffer,
+ TPMI_RH_ENDORSEMENT* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_RH_PROVISION(
- const TPMI_RH_PROVISION& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_RH_PROVISION(const TPMI_RH_PROVISION& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_RH_PROVISION(
- std::string* buffer,
- TPMI_RH_PROVISION* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_RH_PROVISION(std::string* buffer,
+ TPMI_RH_PROVISION* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_RH_CLEAR(
- const TPMI_RH_CLEAR& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_RH_CLEAR(const TPMI_RH_CLEAR& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_RH_CLEAR(
- std::string* buffer,
- TPMI_RH_CLEAR* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_RH_CLEAR(std::string* buffer,
+ TPMI_RH_CLEAR* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_RH_NV_AUTH(
- const TPMI_RH_NV_AUTH& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_RH_NV_AUTH(const TPMI_RH_NV_AUTH& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_RH_NV_AUTH(
- std::string* buffer,
- TPMI_RH_NV_AUTH* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_RH_NV_AUTH(std::string* buffer,
+ TPMI_RH_NV_AUTH* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_RH_LOCKOUT(
- const TPMI_RH_LOCKOUT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_RH_LOCKOUT(const TPMI_RH_LOCKOUT& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_RH_LOCKOUT(
- std::string* buffer,
- TPMI_RH_LOCKOUT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_RH_LOCKOUT(std::string* buffer,
+ TPMI_RH_LOCKOUT* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_RH_NV_INDEX(
- const TPMI_RH_NV_INDEX& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_RH_NV_INDEX(const TPMI_RH_NV_INDEX& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPMI_RH_NV_INDEX(
- std::string* buffer,
- TPMI_RH_NV_INDEX* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_RH_NV_INDEX(std::string* buffer,
+ TPMI_RH_NV_INDEX* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_ALG_ASYM(
- const TPMI_ALG_ASYM& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_ALG_ASYM(const TPMI_ALG_ASYM& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_ALG_ID(value, buffer);
}
-TPM_RC Parse_TPMI_ALG_ASYM(
- std::string* buffer,
- TPMI_ALG_ASYM* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_ALG_ASYM(std::string* buffer,
+ TPMI_ALG_ASYM* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_ALG_ID(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_ALG_SYM(
- const TPMI_ALG_SYM& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_ALG_SYM(const TPMI_ALG_SYM& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_ALG_ID(value, buffer);
}
-TPM_RC Parse_TPMI_ALG_SYM(
- std::string* buffer,
- TPMI_ALG_SYM* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_ALG_SYM(std::string* buffer,
+ TPMI_ALG_SYM* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_ALG_ID(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_ALG_SYM_OBJECT(
- const TPMI_ALG_SYM_OBJECT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_ALG_SYM_OBJECT(const TPMI_ALG_SYM_OBJECT& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_ALG_ID(value, buffer);
}
-TPM_RC Parse_TPMI_ALG_SYM_OBJECT(
- std::string* buffer,
- TPMI_ALG_SYM_OBJECT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_ALG_SYM_OBJECT(std::string* buffer,
+ TPMI_ALG_SYM_OBJECT* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_ALG_ID(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_ALG_SYM_MODE(
- const TPMI_ALG_SYM_MODE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_ALG_SYM_MODE(const TPMI_ALG_SYM_MODE& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_ALG_ID(value, buffer);
}
-TPM_RC Parse_TPMI_ALG_SYM_MODE(
- std::string* buffer,
- TPMI_ALG_SYM_MODE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_ALG_SYM_MODE(std::string* buffer,
+ TPMI_ALG_SYM_MODE* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_ALG_ID(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_ALG_KDF(
- const TPMI_ALG_KDF& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_ALG_KDF(const TPMI_ALG_KDF& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_ALG_ID(value, buffer);
}
-TPM_RC Parse_TPMI_ALG_KDF(
- std::string* buffer,
- TPMI_ALG_KDF* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_ALG_KDF(std::string* buffer,
+ TPMI_ALG_KDF* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_ALG_ID(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_ALG_SIG_SCHEME(
- const TPMI_ALG_SIG_SCHEME& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_ALG_SIG_SCHEME(const TPMI_ALG_SIG_SCHEME& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_ALG_ID(value, buffer);
}
-TPM_RC Parse_TPMI_ALG_SIG_SCHEME(
- std::string* buffer,
- TPMI_ALG_SIG_SCHEME* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_ALG_SIG_SCHEME(std::string* buffer,
+ TPMI_ALG_SIG_SCHEME* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_ALG_ID(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_ECC_KEY_EXCHANGE(
- const TPMI_ECC_KEY_EXCHANGE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_ECC_KEY_EXCHANGE(const TPMI_ECC_KEY_EXCHANGE& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_ALG_ID(value, buffer);
}
-TPM_RC Parse_TPMI_ECC_KEY_EXCHANGE(
- std::string* buffer,
- TPMI_ECC_KEY_EXCHANGE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_ECC_KEY_EXCHANGE(std::string* buffer,
+ TPMI_ECC_KEY_EXCHANGE* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_ALG_ID(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_ST(
- const TPM_ST& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_ST(const TPM_ST& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT16(value, buffer);
}
-TPM_RC Parse_TPM_ST(
- std::string* buffer,
- TPM_ST* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_ST(std::string* buffer,
+ TPM_ST* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT16(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_ST_COMMAND_TAG(
- const TPMI_ST_COMMAND_TAG& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_ST_COMMAND_TAG(const TPMI_ST_COMMAND_TAG& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_ST(value, buffer);
}
-TPM_RC Parse_TPMI_ST_COMMAND_TAG(
- std::string* buffer,
- TPMI_ST_COMMAND_TAG* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_ST_COMMAND_TAG(std::string* buffer,
+ TPMI_ST_COMMAND_TAG* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_ST(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_ST_ATTEST(
- const TPMI_ST_ATTEST& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_ST_ATTEST(const TPMI_ST_ATTEST& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_ST(value, buffer);
}
-TPM_RC Parse_TPMI_ST_ATTEST(
- std::string* buffer,
- TPMI_ST_ATTEST* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_ST_ATTEST(std::string* buffer,
+ TPMI_ST_ATTEST* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_ST(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_AES_KEY_BITS(
- const TPMI_AES_KEY_BITS& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_AES_KEY_BITS(const TPMI_AES_KEY_BITS& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_KEY_BITS(value, buffer);
}
-TPM_RC Parse_TPMI_AES_KEY_BITS(
- std::string* buffer,
- TPMI_AES_KEY_BITS* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_AES_KEY_BITS(std::string* buffer,
+ TPMI_AES_KEY_BITS* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_KEY_BITS(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_SM4_KEY_BITS(
- const TPMI_SM4_KEY_BITS& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_SM4_KEY_BITS(const TPMI_SM4_KEY_BITS& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_KEY_BITS(value, buffer);
}
-TPM_RC Parse_TPMI_SM4_KEY_BITS(
- std::string* buffer,
- TPMI_SM4_KEY_BITS* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_SM4_KEY_BITS(std::string* buffer,
+ TPMI_SM4_KEY_BITS* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_KEY_BITS(buffer, value, value_bytes);
}
@@ -1723,505 +1764,419 @@
return Serialize_TPM_ALG_ID(value, buffer);
}
-TPM_RC Parse_TPMI_ALG_KEYEDHASH_SCHEME(
- std::string* buffer,
- TPMI_ALG_KEYEDHASH_SCHEME* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_ALG_KEYEDHASH_SCHEME(std::string* buffer,
+ TPMI_ALG_KEYEDHASH_SCHEME* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_ALG_ID(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_ALG_ASYM_SCHEME(
- const TPMI_ALG_ASYM_SCHEME& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_ALG_ASYM_SCHEME(const TPMI_ALG_ASYM_SCHEME& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_ALG_ID(value, buffer);
}
-TPM_RC Parse_TPMI_ALG_ASYM_SCHEME(
- std::string* buffer,
- TPMI_ALG_ASYM_SCHEME* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_ALG_ASYM_SCHEME(std::string* buffer,
+ TPMI_ALG_ASYM_SCHEME* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_ALG_ID(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_ALG_RSA_SCHEME(
- const TPMI_ALG_RSA_SCHEME& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_ALG_RSA_SCHEME(const TPMI_ALG_RSA_SCHEME& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_ALG_ID(value, buffer);
}
-TPM_RC Parse_TPMI_ALG_RSA_SCHEME(
- std::string* buffer,
- TPMI_ALG_RSA_SCHEME* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_ALG_RSA_SCHEME(std::string* buffer,
+ TPMI_ALG_RSA_SCHEME* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_ALG_ID(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_ALG_RSA_DECRYPT(
- const TPMI_ALG_RSA_DECRYPT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_ALG_RSA_DECRYPT(const TPMI_ALG_RSA_DECRYPT& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_ALG_ID(value, buffer);
}
-TPM_RC Parse_TPMI_ALG_RSA_DECRYPT(
- std::string* buffer,
- TPMI_ALG_RSA_DECRYPT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_ALG_RSA_DECRYPT(std::string* buffer,
+ TPMI_ALG_RSA_DECRYPT* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_ALG_ID(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_RSA_KEY_BITS(
- const TPMI_RSA_KEY_BITS& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_RSA_KEY_BITS(const TPMI_RSA_KEY_BITS& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_KEY_BITS(value, buffer);
}
-TPM_RC Parse_TPMI_RSA_KEY_BITS(
- std::string* buffer,
- TPMI_RSA_KEY_BITS* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_RSA_KEY_BITS(std::string* buffer,
+ TPMI_RSA_KEY_BITS* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_KEY_BITS(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_ALG_ECC_SCHEME(
- const TPMI_ALG_ECC_SCHEME& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_ALG_ECC_SCHEME(const TPMI_ALG_ECC_SCHEME& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_ALG_ID(value, buffer);
}
-TPM_RC Parse_TPMI_ALG_ECC_SCHEME(
- std::string* buffer,
- TPMI_ALG_ECC_SCHEME* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_ALG_ECC_SCHEME(std::string* buffer,
+ TPMI_ALG_ECC_SCHEME* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_ALG_ID(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_ECC_CURVE(
- const TPM_ECC_CURVE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_ECC_CURVE(const TPM_ECC_CURVE& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT16(value, buffer);
}
-TPM_RC Parse_TPM_ECC_CURVE(
- std::string* buffer,
- TPM_ECC_CURVE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_ECC_CURVE(std::string* buffer,
+ TPM_ECC_CURVE* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT16(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_ECC_CURVE(
- const TPMI_ECC_CURVE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_ECC_CURVE(const TPMI_ECC_CURVE& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_ECC_CURVE(value, buffer);
}
-TPM_RC Parse_TPMI_ECC_CURVE(
- std::string* buffer,
- TPMI_ECC_CURVE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_ECC_CURVE(std::string* buffer,
+ TPMI_ECC_CURVE* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_ECC_CURVE(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMI_ALG_PUBLIC(
- const TPMI_ALG_PUBLIC& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMI_ALG_PUBLIC(const TPMI_ALG_PUBLIC& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_ALG_ID(value, buffer);
}
-TPM_RC Parse_TPMI_ALG_PUBLIC(
- std::string* buffer,
- TPMI_ALG_PUBLIC* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMI_ALG_PUBLIC(std::string* buffer,
+ TPMI_ALG_PUBLIC* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_ALG_ID(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMA_ALGORITHM(
- const TPMA_ALGORITHM& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMA_ALGORITHM(const TPMA_ALGORITHM& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPMA_ALGORITHM(
- std::string* buffer,
- TPMA_ALGORITHM* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMA_ALGORITHM(std::string* buffer,
+ TPMA_ALGORITHM* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMA_OBJECT(
- const TPMA_OBJECT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMA_OBJECT(const TPMA_OBJECT& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPMA_OBJECT(
- std::string* buffer,
- TPMA_OBJECT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMA_OBJECT(std::string* buffer,
+ TPMA_OBJECT* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMA_SESSION(
- const TPMA_SESSION& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMA_SESSION(const TPMA_SESSION& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT8(value, buffer);
}
-TPM_RC Parse_TPMA_SESSION(
- std::string* buffer,
- TPMA_SESSION* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMA_SESSION(std::string* buffer,
+ TPMA_SESSION* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT8(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMA_LOCALITY(
- const TPMA_LOCALITY& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMA_LOCALITY(const TPMA_LOCALITY& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT8(value, buffer);
}
-TPM_RC Parse_TPMA_LOCALITY(
- std::string* buffer,
- TPMA_LOCALITY* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMA_LOCALITY(std::string* buffer,
+ TPMA_LOCALITY* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT8(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMA_PERMANENT(
- const TPMA_PERMANENT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMA_PERMANENT(const TPMA_PERMANENT& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPMA_PERMANENT(
- std::string* buffer,
- TPMA_PERMANENT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMA_PERMANENT(std::string* buffer,
+ TPMA_PERMANENT* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMA_STARTUP_CLEAR(
- const TPMA_STARTUP_CLEAR& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMA_STARTUP_CLEAR(const TPMA_STARTUP_CLEAR& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPMA_STARTUP_CLEAR(
- std::string* buffer,
- TPMA_STARTUP_CLEAR* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMA_STARTUP_CLEAR(std::string* buffer,
+ TPMA_STARTUP_CLEAR* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMA_MEMORY(
- const TPMA_MEMORY& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMA_MEMORY(const TPMA_MEMORY& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPMA_MEMORY(
- std::string* buffer,
- TPMA_MEMORY* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMA_MEMORY(std::string* buffer,
+ TPMA_MEMORY* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_CC(
- const TPM_CC& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_CC(const TPM_CC& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPM_CC(
- std::string* buffer,
- TPM_CC* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_CC(std::string* buffer,
+ TPM_CC* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMA_CC(
- const TPMA_CC& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMA_CC(const TPMA_CC& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_CC(value, buffer);
}
-TPM_RC Parse_TPMA_CC(
- std::string* buffer,
- TPMA_CC* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMA_CC(std::string* buffer,
+ TPMA_CC* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_CC(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_NV_INDEX(
- const TPM_NV_INDEX& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_NV_INDEX(const TPM_NV_INDEX& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPM_NV_INDEX(
- std::string* buffer,
- TPM_NV_INDEX* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_NV_INDEX(std::string* buffer,
+ TPM_NV_INDEX* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPMA_NV(
- const TPMA_NV& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMA_NV(const TPMA_NV& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPMA_NV(
- std::string* buffer,
- TPMA_NV* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMA_NV(std::string* buffer,
+ TPMA_NV* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_SPEC(
- const TPM_SPEC& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_SPEC(const TPM_SPEC& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPM_SPEC(
- std::string* buffer,
- TPM_SPEC* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_SPEC(std::string* buffer,
+ TPM_SPEC* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_GENERATED(
- const TPM_GENERATED& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_GENERATED(const TPM_GENERATED& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPM_GENERATED(
- std::string* buffer,
- TPM_GENERATED* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_GENERATED(std::string* buffer,
+ TPM_GENERATED* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_RC(
- const TPM_RC& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_RC(const TPM_RC& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPM_RC(
- std::string* buffer,
- TPM_RC* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_RC(std::string* buffer,
+ TPM_RC* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_CLOCK_ADJUST(
- const TPM_CLOCK_ADJUST& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_CLOCK_ADJUST(const TPM_CLOCK_ADJUST& value,
+ std::string* buffer) {
VLOG(3) << __func__;
return Serialize_INT8(value, buffer);
}
-TPM_RC Parse_TPM_CLOCK_ADJUST(
- std::string* buffer,
- TPM_CLOCK_ADJUST* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_CLOCK_ADJUST(std::string* buffer,
+ TPM_CLOCK_ADJUST* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_INT8(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_EO(
- const TPM_EO& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_EO(const TPM_EO& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT16(value, buffer);
}
-TPM_RC Parse_TPM_EO(
- std::string* buffer,
- TPM_EO* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_EO(std::string* buffer,
+ TPM_EO* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT16(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_SU(
- const TPM_SU& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_SU(const TPM_SU& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT16(value, buffer);
}
-TPM_RC Parse_TPM_SU(
- std::string* buffer,
- TPM_SU* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_SU(std::string* buffer,
+ TPM_SU* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT16(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_SE(
- const TPM_SE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_SE(const TPM_SE& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT8(value, buffer);
}
-TPM_RC Parse_TPM_SE(
- std::string* buffer,
- TPM_SE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_SE(std::string* buffer,
+ TPM_SE* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT8(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_CAP(
- const TPM_CAP& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_CAP(const TPM_CAP& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPM_CAP(
- std::string* buffer,
- TPM_CAP* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_CAP(std::string* buffer,
+ TPM_CAP* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_PT(
- const TPM_PT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_PT(const TPM_PT& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPM_PT(
- std::string* buffer,
- TPM_PT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_PT(std::string* buffer,
+ TPM_PT* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_PT_PCR(
- const TPM_PT_PCR& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_PT_PCR(const TPM_PT_PCR& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPM_PT_PCR(
- std::string* buffer,
- TPM_PT_PCR* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_PT_PCR(std::string* buffer,
+ TPM_PT_PCR* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_PS(
- const TPM_PS& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_PS(const TPM_PS& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPM_PS(
- std::string* buffer,
- TPM_PS* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_PS(std::string* buffer,
+ TPM_PS* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_HT(
- const TPM_HT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_HT(const TPM_HT& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT8(value, buffer);
}
-TPM_RC Parse_TPM_HT(
- std::string* buffer,
- TPM_HT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_HT(std::string* buffer,
+ TPM_HT* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT8(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_RH(
- const TPM_RH& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_RH(const TPM_RH& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_UINT32(value, buffer);
}
-TPM_RC Parse_TPM_RH(
- std::string* buffer,
- TPM_RH* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_RH(std::string* buffer,
+ TPM_RH* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_UINT32(buffer, value, value_bytes);
}
-TPM_RC Serialize_TPM_HC(
- const TPM_HC& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM_HC(const TPM_HC& value, std::string* buffer) {
VLOG(3) << __func__;
return Serialize_TPM_HANDLE(value, buffer);
}
-TPM_RC Parse_TPM_HC(
- std::string* buffer,
- TPM_HC* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM_HC(std::string* buffer,
+ TPM_HC* value,
+ std::string* value_bytes) {
VLOG(3) << __func__;
return Parse_TPM_HANDLE(buffer, value, value_bytes);
}
@@ -2244,35 +2199,27 @@
return result;
}
-TPM_RC Parse_TPMS_ALGORITHM_DESCRIPTION(
- std::string* buffer,
- TPMS_ALGORITHM_DESCRIPTION* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_ALGORITHM_DESCRIPTION(std::string* buffer,
+ TPMS_ALGORITHM_DESCRIPTION* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM_ALG_ID(
- buffer,
- &value->alg,
- value_bytes);
+ result = Parse_TPM_ALG_ID(buffer, &value->alg, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMA_ALGORITHM(
- buffer,
- &value->attributes,
- value_bytes);
+ result = Parse_TPMA_ALGORITHM(buffer, &value->attributes, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMU_HA(
- const TPMU_HA& value,
- TPMI_ALG_HASH selector,
- std::string* buffer) {
+TPM_RC Serialize_TPMU_HA(const TPMU_HA& value,
+ TPMI_ALG_HASH selector,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -2342,11 +2289,10 @@
return result;
}
-TPM_RC Parse_TPMU_HA(
- std::string* buffer,
- TPMI_ALG_HASH selector,
- TPMU_HA* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMU_HA(std::string* buffer,
+ TPMI_ALG_HASH selector,
+ TPMU_HA* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -2355,10 +2301,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < SHA384_DIGEST_SIZE; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->sha384[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->sha384[i], value_bytes);
if (result) {
return result;
}
@@ -2370,10 +2313,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < SHA1_DIGEST_SIZE; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->sha1[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->sha1[i], value_bytes);
if (result) {
return result;
}
@@ -2385,10 +2325,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < SM3_256_DIGEST_SIZE; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->sm3_256[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->sm3_256[i], value_bytes);
if (result) {
return result;
}
@@ -2404,10 +2341,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < SHA256_DIGEST_SIZE; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->sha256[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->sha256[i], value_bytes);
if (result) {
return result;
}
@@ -2419,10 +2353,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < SHA512_DIGEST_SIZE; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->sha512[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->sha512[i], value_bytes);
if (result) {
return result;
}
@@ -2431,9 +2362,7 @@
return result;
}
-TPM_RC Serialize_TPMT_HA(
- const TPMT_HA& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMT_HA(const TPMT_HA& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -2442,45 +2371,32 @@
return result;
}
- result = Serialize_TPMU_HA(
- value.digest,
- value.hash_alg,
- buffer);
+ result = Serialize_TPMU_HA(value.digest, value.hash_alg, buffer);
if (result) {
return result;
}
return result;
}
-TPM_RC Parse_TPMT_HA(
- std::string* buffer,
- TPMT_HA* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMT_HA(std::string* buffer,
+ TPMT_HA* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_HASH(
- buffer,
- &value->hash_alg,
- value_bytes);
+ result = Parse_TPMI_ALG_HASH(buffer, &value->hash_alg, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_HA(
- buffer,
- value->hash_alg,
- &value->digest,
- value_bytes);
+ result = Parse_TPMU_HA(buffer, value->hash_alg, &value->digest, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPM2B_DATA(
- const TPM2B_DATA& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_DATA(const TPM2B_DATA& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -2501,17 +2417,13 @@
return result;
}
-TPM_RC Parse_TPM2B_DATA(
- std::string* buffer,
- TPM2B_DATA* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_DATA(std::string* buffer,
+ TPM2B_DATA* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -2520,10 +2432,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->buffer[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->buffer[i], value_bytes);
if (result) {
return result;
}
@@ -2531,8 +2440,7 @@
return result;
}
-TPM2B_DATA Make_TPM2B_DATA(
- const std::string& bytes) {
+TPM2B_DATA Make_TPM2B_DATA(const std::string& bytes) {
TPM2B_DATA tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.buffer));
memset(&tpm2b, 0, sizeof(TPM2B_DATA));
@@ -2541,16 +2449,12 @@
return tpm2b;
}
-std::string StringFrom_TPM2B_DATA(
- const TPM2B_DATA& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.buffer);
+std::string StringFrom_TPM2B_DATA(const TPM2B_DATA& tpm2b) {
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.buffer);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPM2B_EVENT(
- const TPM2B_EVENT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_EVENT(const TPM2B_EVENT& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -2571,17 +2475,13 @@
return result;
}
-TPM_RC Parse_TPM2B_EVENT(
- std::string* buffer,
- TPM2B_EVENT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_EVENT(std::string* buffer,
+ TPM2B_EVENT* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -2590,10 +2490,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->buffer[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->buffer[i], value_bytes);
if (result) {
return result;
}
@@ -2601,8 +2498,7 @@
return result;
}
-TPM2B_EVENT Make_TPM2B_EVENT(
- const std::string& bytes) {
+TPM2B_EVENT Make_TPM2B_EVENT(const std::string& bytes) {
TPM2B_EVENT tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.buffer));
memset(&tpm2b, 0, sizeof(TPM2B_EVENT));
@@ -2611,16 +2507,13 @@
return tpm2b;
}
-std::string StringFrom_TPM2B_EVENT(
- const TPM2B_EVENT& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.buffer);
+std::string StringFrom_TPM2B_EVENT(const TPM2B_EVENT& tpm2b) {
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.buffer);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPM2B_MAX_BUFFER(
- const TPM2B_MAX_BUFFER& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_MAX_BUFFER(const TPM2B_MAX_BUFFER& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -2641,17 +2534,13 @@
return result;
}
-TPM_RC Parse_TPM2B_MAX_BUFFER(
- std::string* buffer,
- TPM2B_MAX_BUFFER* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_MAX_BUFFER(std::string* buffer,
+ TPM2B_MAX_BUFFER* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -2660,10 +2549,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->buffer[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->buffer[i], value_bytes);
if (result) {
return result;
}
@@ -2671,8 +2557,7 @@
return result;
}
-TPM2B_MAX_BUFFER Make_TPM2B_MAX_BUFFER(
- const std::string& bytes) {
+TPM2B_MAX_BUFFER Make_TPM2B_MAX_BUFFER(const std::string& bytes) {
TPM2B_MAX_BUFFER tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.buffer));
memset(&tpm2b, 0, sizeof(TPM2B_MAX_BUFFER));
@@ -2681,16 +2566,13 @@
return tpm2b;
}
-std::string StringFrom_TPM2B_MAX_BUFFER(
- const TPM2B_MAX_BUFFER& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.buffer);
+std::string StringFrom_TPM2B_MAX_BUFFER(const TPM2B_MAX_BUFFER& tpm2b) {
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.buffer);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPM2B_MAX_NV_BUFFER(
- const TPM2B_MAX_NV_BUFFER& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_MAX_NV_BUFFER(const TPM2B_MAX_NV_BUFFER& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -2711,17 +2593,13 @@
return result;
}
-TPM_RC Parse_TPM2B_MAX_NV_BUFFER(
- std::string* buffer,
- TPM2B_MAX_NV_BUFFER* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_MAX_NV_BUFFER(std::string* buffer,
+ TPM2B_MAX_NV_BUFFER* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -2730,10 +2608,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->buffer[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->buffer[i], value_bytes);
if (result) {
return result;
}
@@ -2741,8 +2616,7 @@
return result;
}
-TPM2B_MAX_NV_BUFFER Make_TPM2B_MAX_NV_BUFFER(
- const std::string& bytes) {
+TPM2B_MAX_NV_BUFFER Make_TPM2B_MAX_NV_BUFFER(const std::string& bytes) {
TPM2B_MAX_NV_BUFFER tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.buffer));
memset(&tpm2b, 0, sizeof(TPM2B_MAX_NV_BUFFER));
@@ -2751,16 +2625,13 @@
return tpm2b;
}
-std::string StringFrom_TPM2B_MAX_NV_BUFFER(
- const TPM2B_MAX_NV_BUFFER& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.buffer);
+std::string StringFrom_TPM2B_MAX_NV_BUFFER(const TPM2B_MAX_NV_BUFFER& tpm2b) {
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.buffer);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPM2B_TIMEOUT(
- const TPM2B_TIMEOUT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_TIMEOUT(const TPM2B_TIMEOUT& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -2781,17 +2652,13 @@
return result;
}
-TPM_RC Parse_TPM2B_TIMEOUT(
- std::string* buffer,
- TPM2B_TIMEOUT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_TIMEOUT(std::string* buffer,
+ TPM2B_TIMEOUT* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -2800,10 +2667,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->buffer[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->buffer[i], value_bytes);
if (result) {
return result;
}
@@ -2811,8 +2675,7 @@
return result;
}
-TPM2B_TIMEOUT Make_TPM2B_TIMEOUT(
- const std::string& bytes) {
+TPM2B_TIMEOUT Make_TPM2B_TIMEOUT(const std::string& bytes) {
TPM2B_TIMEOUT tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.buffer));
memset(&tpm2b, 0, sizeof(TPM2B_TIMEOUT));
@@ -2821,16 +2684,12 @@
return tpm2b;
}
-std::string StringFrom_TPM2B_TIMEOUT(
- const TPM2B_TIMEOUT& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.buffer);
+std::string StringFrom_TPM2B_TIMEOUT(const TPM2B_TIMEOUT& tpm2b) {
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.buffer);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPM2B_IV(
- const TPM2B_IV& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_IV(const TPM2B_IV& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -2851,17 +2710,13 @@
return result;
}
-TPM_RC Parse_TPM2B_IV(
- std::string* buffer,
- TPM2B_IV* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_IV(std::string* buffer,
+ TPM2B_IV* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -2870,10 +2725,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->buffer[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->buffer[i], value_bytes);
if (result) {
return result;
}
@@ -2881,8 +2733,7 @@
return result;
}
-TPM2B_IV Make_TPM2B_IV(
- const std::string& bytes) {
+TPM2B_IV Make_TPM2B_IV(const std::string& bytes) {
TPM2B_IV tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.buffer));
memset(&tpm2b, 0, sizeof(TPM2B_IV));
@@ -2891,16 +2742,12 @@
return tpm2b;
}
-std::string StringFrom_TPM2B_IV(
- const TPM2B_IV& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.buffer);
+std::string StringFrom_TPM2B_IV(const TPM2B_IV& tpm2b) {
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.buffer);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPM2B_NAME(
- const TPM2B_NAME& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_NAME(const TPM2B_NAME& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -2921,17 +2768,13 @@
return result;
}
-TPM_RC Parse_TPM2B_NAME(
- std::string* buffer,
- TPM2B_NAME* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_NAME(std::string* buffer,
+ TPM2B_NAME* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -2940,10 +2783,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->name[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->name[i], value_bytes);
if (result) {
return result;
}
@@ -2951,8 +2791,7 @@
return result;
}
-TPM2B_NAME Make_TPM2B_NAME(
- const std::string& bytes) {
+TPM2B_NAME Make_TPM2B_NAME(const std::string& bytes) {
TPM2B_NAME tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.name));
memset(&tpm2b, 0, sizeof(TPM2B_NAME));
@@ -2961,16 +2800,13 @@
return tpm2b;
}
-std::string StringFrom_TPM2B_NAME(
- const TPM2B_NAME& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.name);
+std::string StringFrom_TPM2B_NAME(const TPM2B_NAME& tpm2b) {
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.name);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPMS_PCR_SELECT(
- const TPMS_PCR_SELECT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_PCR_SELECT(const TPMS_PCR_SELECT& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -2991,17 +2827,13 @@
return result;
}
-TPM_RC Parse_TPMS_PCR_SELECT(
- std::string* buffer,
- TPMS_PCR_SELECT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_PCR_SELECT(std::string* buffer,
+ TPMS_PCR_SELECT* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT8(
- buffer,
- &value->sizeof_select,
- value_bytes);
+ result = Parse_UINT8(buffer, &value->sizeof_select, value_bytes);
if (result) {
return result;
}
@@ -3010,10 +2842,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->sizeof_select; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->pcr_select[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->pcr_select[i], value_bytes);
if (result) {
return result;
}
@@ -3021,9 +2850,8 @@
return result;
}
-TPM_RC Serialize_TPMS_PCR_SELECTION(
- const TPMS_PCR_SELECTION& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_PCR_SELECTION(const TPMS_PCR_SELECTION& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -3049,25 +2877,18 @@
return result;
}
-TPM_RC Parse_TPMS_PCR_SELECTION(
- std::string* buffer,
- TPMS_PCR_SELECTION* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_PCR_SELECTION(std::string* buffer,
+ TPMS_PCR_SELECTION* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_HASH(
- buffer,
- &value->hash,
- value_bytes);
+ result = Parse_TPMI_ALG_HASH(buffer, &value->hash, value_bytes);
if (result) {
return result;
}
- result = Parse_UINT8(
- buffer,
- &value->sizeof_select,
- value_bytes);
+ result = Parse_UINT8(buffer, &value->sizeof_select, value_bytes);
if (result) {
return result;
}
@@ -3076,10 +2897,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->sizeof_select; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->pcr_select[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->pcr_select[i], value_bytes);
if (result) {
return result;
}
@@ -3087,9 +2905,8 @@
return result;
}
-TPM_RC Serialize_TPMT_TK_CREATION(
- const TPMT_TK_CREATION& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMT_TK_CREATION(const TPMT_TK_CREATION& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -3110,42 +2927,31 @@
return result;
}
-TPM_RC Parse_TPMT_TK_CREATION(
- std::string* buffer,
- TPMT_TK_CREATION* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMT_TK_CREATION(std::string* buffer,
+ TPMT_TK_CREATION* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM_ST(
- buffer,
- &value->tag,
- value_bytes);
+ result = Parse_TPM_ST(buffer, &value->tag, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMI_RH_HIERARCHY(
- buffer,
- &value->hierarchy,
- value_bytes);
+ result = Parse_TPMI_RH_HIERARCHY(buffer, &value->hierarchy, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->digest,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->digest, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMT_TK_VERIFIED(
- const TPMT_TK_VERIFIED& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMT_TK_VERIFIED(const TPMT_TK_VERIFIED& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -3166,42 +2972,30 @@
return result;
}
-TPM_RC Parse_TPMT_TK_VERIFIED(
- std::string* buffer,
- TPMT_TK_VERIFIED* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMT_TK_VERIFIED(std::string* buffer,
+ TPMT_TK_VERIFIED* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM_ST(
- buffer,
- &value->tag,
- value_bytes);
+ result = Parse_TPM_ST(buffer, &value->tag, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMI_RH_HIERARCHY(
- buffer,
- &value->hierarchy,
- value_bytes);
+ result = Parse_TPMI_RH_HIERARCHY(buffer, &value->hierarchy, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->digest,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->digest, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMT_TK_AUTH(
- const TPMT_TK_AUTH& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMT_TK_AUTH(const TPMT_TK_AUTH& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -3217,34 +3011,26 @@
return result;
}
-TPM_RC Parse_TPMT_TK_AUTH(
- std::string* buffer,
- TPMT_TK_AUTH* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMT_TK_AUTH(std::string* buffer,
+ TPMT_TK_AUTH* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_RH_HIERARCHY(
- buffer,
- &value->hierarchy,
- value_bytes);
+ result = Parse_TPMI_RH_HIERARCHY(buffer, &value->hierarchy, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->digest,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->digest, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMT_TK_HASHCHECK(
- const TPMT_TK_HASHCHECK& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMT_TK_HASHCHECK(const TPMT_TK_HASHCHECK& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -3265,42 +3051,31 @@
return result;
}
-TPM_RC Parse_TPMT_TK_HASHCHECK(
- std::string* buffer,
- TPMT_TK_HASHCHECK* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMT_TK_HASHCHECK(std::string* buffer,
+ TPMT_TK_HASHCHECK* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM_ST(
- buffer,
- &value->tag,
- value_bytes);
+ result = Parse_TPM_ST(buffer, &value->tag, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMI_RH_HIERARCHY(
- buffer,
- &value->hierarchy,
- value_bytes);
+ result = Parse_TPMI_RH_HIERARCHY(buffer, &value->hierarchy, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->digest,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->digest, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_ALG_PROPERTY(
- const TPMS_ALG_PROPERTY& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_ALG_PROPERTY(const TPMS_ALG_PROPERTY& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -3316,34 +3091,26 @@
return result;
}
-TPM_RC Parse_TPMS_ALG_PROPERTY(
- std::string* buffer,
- TPMS_ALG_PROPERTY* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_ALG_PROPERTY(std::string* buffer,
+ TPMS_ALG_PROPERTY* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM_ALG_ID(
- buffer,
- &value->alg,
- value_bytes);
+ result = Parse_TPM_ALG_ID(buffer, &value->alg, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMA_ALGORITHM(
- buffer,
- &value->alg_properties,
- value_bytes);
+ result = Parse_TPMA_ALGORITHM(buffer, &value->alg_properties, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_TAGGED_PROPERTY(
- const TPMS_TAGGED_PROPERTY& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_TAGGED_PROPERTY(const TPMS_TAGGED_PROPERTY& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -3359,34 +3126,26 @@
return result;
}
-TPM_RC Parse_TPMS_TAGGED_PROPERTY(
- std::string* buffer,
- TPMS_TAGGED_PROPERTY* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_TAGGED_PROPERTY(std::string* buffer,
+ TPMS_TAGGED_PROPERTY* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM_PT(
- buffer,
- &value->property,
- value_bytes);
+ result = Parse_TPM_PT(buffer, &value->property, value_bytes);
if (result) {
return result;
}
- result = Parse_UINT32(
- buffer,
- &value->value,
- value_bytes);
+ result = Parse_UINT32(buffer, &value->value, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_TAGGED_PCR_SELECT(
- const TPMS_TAGGED_PCR_SELECT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_TAGGED_PCR_SELECT(const TPMS_TAGGED_PCR_SELECT& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -3412,25 +3171,18 @@
return result;
}
-TPM_RC Parse_TPMS_TAGGED_PCR_SELECT(
- std::string* buffer,
- TPMS_TAGGED_PCR_SELECT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_TAGGED_PCR_SELECT(std::string* buffer,
+ TPMS_TAGGED_PCR_SELECT* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM_PT(
- buffer,
- &value->tag,
- value_bytes);
+ result = Parse_TPM_PT(buffer, &value->tag, value_bytes);
if (result) {
return result;
}
- result = Parse_UINT8(
- buffer,
- &value->sizeof_select,
- value_bytes);
+ result = Parse_UINT8(buffer, &value->sizeof_select, value_bytes);
if (result) {
return result;
}
@@ -3439,10 +3191,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->sizeof_select; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->pcr_select[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->pcr_select[i], value_bytes);
if (result) {
return result;
}
@@ -3450,9 +3199,7 @@
return result;
}
-TPM_RC Serialize_TPML_CC(
- const TPML_CC& value,
- std::string* buffer) {
+TPM_RC Serialize_TPML_CC(const TPML_CC& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -3473,17 +3220,13 @@
return result;
}
-TPM_RC Parse_TPML_CC(
- std::string* buffer,
- TPML_CC* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPML_CC(std::string* buffer,
+ TPML_CC* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT32(
- buffer,
- &value->count,
- value_bytes);
+ result = Parse_UINT32(buffer, &value->count, value_bytes);
if (result) {
return result;
}
@@ -3492,10 +3235,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->count; ++i) {
- result = Parse_TPM_CC(
- buffer,
- &value->command_codes[i],
- value_bytes);
+ result = Parse_TPM_CC(buffer, &value->command_codes[i], value_bytes);
if (result) {
return result;
}
@@ -3503,9 +3243,7 @@
return result;
}
-TPM_RC Serialize_TPML_CCA(
- const TPML_CCA& value,
- std::string* buffer) {
+TPM_RC Serialize_TPML_CCA(const TPML_CCA& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -3526,17 +3264,13 @@
return result;
}
-TPM_RC Parse_TPML_CCA(
- std::string* buffer,
- TPML_CCA* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPML_CCA(std::string* buffer,
+ TPML_CCA* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT32(
- buffer,
- &value->count,
- value_bytes);
+ result = Parse_UINT32(buffer, &value->count, value_bytes);
if (result) {
return result;
}
@@ -3545,10 +3279,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->count; ++i) {
- result = Parse_TPMA_CC(
- buffer,
- &value->command_attributes[i],
- value_bytes);
+ result = Parse_TPMA_CC(buffer, &value->command_attributes[i], value_bytes);
if (result) {
return result;
}
@@ -3556,9 +3287,7 @@
return result;
}
-TPM_RC Serialize_TPML_ALG(
- const TPML_ALG& value,
- std::string* buffer) {
+TPM_RC Serialize_TPML_ALG(const TPML_ALG& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -3579,17 +3308,13 @@
return result;
}
-TPM_RC Parse_TPML_ALG(
- std::string* buffer,
- TPML_ALG* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPML_ALG(std::string* buffer,
+ TPML_ALG* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT32(
- buffer,
- &value->count,
- value_bytes);
+ result = Parse_UINT32(buffer, &value->count, value_bytes);
if (result) {
return result;
}
@@ -3598,10 +3323,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->count; ++i) {
- result = Parse_TPM_ALG_ID(
- buffer,
- &value->algorithms[i],
- value_bytes);
+ result = Parse_TPM_ALG_ID(buffer, &value->algorithms[i], value_bytes);
if (result) {
return result;
}
@@ -3609,9 +3331,7 @@
return result;
}
-TPM_RC Serialize_TPML_HANDLE(
- const TPML_HANDLE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPML_HANDLE(const TPML_HANDLE& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -3632,17 +3352,13 @@
return result;
}
-TPM_RC Parse_TPML_HANDLE(
- std::string* buffer,
- TPML_HANDLE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPML_HANDLE(std::string* buffer,
+ TPML_HANDLE* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT32(
- buffer,
- &value->count,
- value_bytes);
+ result = Parse_UINT32(buffer, &value->count, value_bytes);
if (result) {
return result;
}
@@ -3651,10 +3367,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->count; ++i) {
- result = Parse_TPM_HANDLE(
- buffer,
- &value->handle[i],
- value_bytes);
+ result = Parse_TPM_HANDLE(buffer, &value->handle[i], value_bytes);
if (result) {
return result;
}
@@ -3662,9 +3375,7 @@
return result;
}
-TPM_RC Serialize_TPML_DIGEST(
- const TPML_DIGEST& value,
- std::string* buffer) {
+TPM_RC Serialize_TPML_DIGEST(const TPML_DIGEST& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -3685,17 +3396,13 @@
return result;
}
-TPM_RC Parse_TPML_DIGEST(
- std::string* buffer,
- TPML_DIGEST* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPML_DIGEST(std::string* buffer,
+ TPML_DIGEST* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT32(
- buffer,
- &value->count,
- value_bytes);
+ result = Parse_UINT32(buffer, &value->count, value_bytes);
if (result) {
return result;
}
@@ -3704,10 +3411,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->count; ++i) {
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->digests[i],
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->digests[i], value_bytes);
if (result) {
return result;
}
@@ -3715,9 +3419,8 @@
return result;
}
-TPM_RC Serialize_TPML_DIGEST_VALUES(
- const TPML_DIGEST_VALUES& value,
- std::string* buffer) {
+TPM_RC Serialize_TPML_DIGEST_VALUES(const TPML_DIGEST_VALUES& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -3738,17 +3441,13 @@
return result;
}
-TPM_RC Parse_TPML_DIGEST_VALUES(
- std::string* buffer,
- TPML_DIGEST_VALUES* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPML_DIGEST_VALUES(std::string* buffer,
+ TPML_DIGEST_VALUES* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT32(
- buffer,
- &value->count,
- value_bytes);
+ result = Parse_UINT32(buffer, &value->count, value_bytes);
if (result) {
return result;
}
@@ -3757,10 +3456,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->count; ++i) {
- result = Parse_TPMT_HA(
- buffer,
- &value->digests[i],
- value_bytes);
+ result = Parse_TPMT_HA(buffer, &value->digests[i], value_bytes);
if (result) {
return result;
}
@@ -3768,9 +3464,8 @@
return result;
}
-TPM_RC Serialize_TPM2B_DIGEST_VALUES(
- const TPM2B_DIGEST_VALUES& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_DIGEST_VALUES(const TPM2B_DIGEST_VALUES& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -3791,17 +3486,13 @@
return result;
}
-TPM_RC Parse_TPM2B_DIGEST_VALUES(
- std::string* buffer,
- TPM2B_DIGEST_VALUES* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_DIGEST_VALUES(std::string* buffer,
+ TPM2B_DIGEST_VALUES* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -3810,10 +3501,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->buffer[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->buffer[i], value_bytes);
if (result) {
return result;
}
@@ -3821,8 +3509,7 @@
return result;
}
-TPM2B_DIGEST_VALUES Make_TPM2B_DIGEST_VALUES(
- const std::string& bytes) {
+TPM2B_DIGEST_VALUES Make_TPM2B_DIGEST_VALUES(const std::string& bytes) {
TPM2B_DIGEST_VALUES tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.buffer));
memset(&tpm2b, 0, sizeof(TPM2B_DIGEST_VALUES));
@@ -3831,16 +3518,13 @@
return tpm2b;
}
-std::string StringFrom_TPM2B_DIGEST_VALUES(
- const TPM2B_DIGEST_VALUES& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.buffer);
+std::string StringFrom_TPM2B_DIGEST_VALUES(const TPM2B_DIGEST_VALUES& tpm2b) {
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.buffer);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPML_PCR_SELECTION(
- const TPML_PCR_SELECTION& value,
- std::string* buffer) {
+TPM_RC Serialize_TPML_PCR_SELECTION(const TPML_PCR_SELECTION& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -3861,17 +3545,13 @@
return result;
}
-TPM_RC Parse_TPML_PCR_SELECTION(
- std::string* buffer,
- TPML_PCR_SELECTION* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPML_PCR_SELECTION(std::string* buffer,
+ TPML_PCR_SELECTION* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT32(
- buffer,
- &value->count,
- value_bytes);
+ result = Parse_UINT32(buffer, &value->count, value_bytes);
if (result) {
return result;
}
@@ -3880,10 +3560,8 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->count; ++i) {
- result = Parse_TPMS_PCR_SELECTION(
- buffer,
- &value->pcr_selections[i],
- value_bytes);
+ result = Parse_TPMS_PCR_SELECTION(buffer, &value->pcr_selections[i],
+ value_bytes);
if (result) {
return result;
}
@@ -3891,9 +3569,8 @@
return result;
}
-TPM_RC Serialize_TPML_ALG_PROPERTY(
- const TPML_ALG_PROPERTY& value,
- std::string* buffer) {
+TPM_RC Serialize_TPML_ALG_PROPERTY(const TPML_ALG_PROPERTY& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -3914,17 +3591,13 @@
return result;
}
-TPM_RC Parse_TPML_ALG_PROPERTY(
- std::string* buffer,
- TPML_ALG_PROPERTY* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPML_ALG_PROPERTY(std::string* buffer,
+ TPML_ALG_PROPERTY* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT32(
- buffer,
- &value->count,
- value_bytes);
+ result = Parse_UINT32(buffer, &value->count, value_bytes);
if (result) {
return result;
}
@@ -3933,10 +3606,8 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->count; ++i) {
- result = Parse_TPMS_ALG_PROPERTY(
- buffer,
- &value->alg_properties[i],
- value_bytes);
+ result =
+ Parse_TPMS_ALG_PROPERTY(buffer, &value->alg_properties[i], value_bytes);
if (result) {
return result;
}
@@ -3944,9 +3615,8 @@
return result;
}
-TPM_RC Serialize_TPML_TAGGED_TPM_PROPERTY(
- const TPML_TAGGED_TPM_PROPERTY& value,
- std::string* buffer) {
+TPM_RC Serialize_TPML_TAGGED_TPM_PROPERTY(const TPML_TAGGED_TPM_PROPERTY& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -3967,17 +3637,13 @@
return result;
}
-TPM_RC Parse_TPML_TAGGED_TPM_PROPERTY(
- std::string* buffer,
- TPML_TAGGED_TPM_PROPERTY* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPML_TAGGED_TPM_PROPERTY(std::string* buffer,
+ TPML_TAGGED_TPM_PROPERTY* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT32(
- buffer,
- &value->count,
- value_bytes);
+ result = Parse_UINT32(buffer, &value->count, value_bytes);
if (result) {
return result;
}
@@ -3986,10 +3652,8 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->count; ++i) {
- result = Parse_TPMS_TAGGED_PROPERTY(
- buffer,
- &value->tpm_property[i],
- value_bytes);
+ result = Parse_TPMS_TAGGED_PROPERTY(buffer, &value->tpm_property[i],
+ value_bytes);
if (result) {
return result;
}
@@ -3997,9 +3661,8 @@
return result;
}
-TPM_RC Serialize_TPML_TAGGED_PCR_PROPERTY(
- const TPML_TAGGED_PCR_PROPERTY& value,
- std::string* buffer) {
+TPM_RC Serialize_TPML_TAGGED_PCR_PROPERTY(const TPML_TAGGED_PCR_PROPERTY& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -4020,17 +3683,13 @@
return result;
}
-TPM_RC Parse_TPML_TAGGED_PCR_PROPERTY(
- std::string* buffer,
- TPML_TAGGED_PCR_PROPERTY* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPML_TAGGED_PCR_PROPERTY(std::string* buffer,
+ TPML_TAGGED_PCR_PROPERTY* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT32(
- buffer,
- &value->count,
- value_bytes);
+ result = Parse_UINT32(buffer, &value->count, value_bytes);
if (result) {
return result;
}
@@ -4039,10 +3698,8 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->count; ++i) {
- result = Parse_TPMS_TAGGED_PCR_SELECT(
- buffer,
- &value->pcr_property[i],
- value_bytes);
+ result = Parse_TPMS_TAGGED_PCR_SELECT(buffer, &value->pcr_property[i],
+ value_bytes);
if (result) {
return result;
}
@@ -4050,9 +3707,8 @@
return result;
}
-TPM_RC Serialize_TPML_ECC_CURVE(
- const TPML_ECC_CURVE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPML_ECC_CURVE(const TPML_ECC_CURVE& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -4073,17 +3729,13 @@
return result;
}
-TPM_RC Parse_TPML_ECC_CURVE(
- std::string* buffer,
- TPML_ECC_CURVE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPML_ECC_CURVE(std::string* buffer,
+ TPML_ECC_CURVE* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT32(
- buffer,
- &value->count,
- value_bytes);
+ result = Parse_UINT32(buffer, &value->count, value_bytes);
if (result) {
return result;
}
@@ -4092,10 +3744,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->count; ++i) {
- result = Parse_TPM_ECC_CURVE(
- buffer,
- &value->ecc_curves[i],
- value_bytes);
+ result = Parse_TPM_ECC_CURVE(buffer, &value->ecc_curves[i], value_bytes);
if (result) {
return result;
}
@@ -4103,10 +3752,9 @@
return result;
}
-TPM_RC Serialize_TPMU_CAPABILITIES(
- const TPMU_CAPABILITIES& value,
- TPM_CAP selector,
- std::string* buffer) {
+TPM_RC Serialize_TPMU_CAPABILITIES(const TPMU_CAPABILITIES& value,
+ TPM_CAP selector,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -4175,99 +3823,74 @@
return result;
}
-TPM_RC Parse_TPMU_CAPABILITIES(
- std::string* buffer,
- TPM_CAP selector,
- TPMU_CAPABILITIES* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMU_CAPABILITIES(std::string* buffer,
+ TPM_CAP selector,
+ TPMU_CAPABILITIES* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
if (selector == TPM_CAP_PCRS) {
- result = Parse_TPML_PCR_SELECTION(
- buffer,
- &value->assigned_pcr,
- value_bytes);
+ result =
+ Parse_TPML_PCR_SELECTION(buffer, &value->assigned_pcr, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_CAP_TPM_PROPERTIES) {
- result = Parse_TPML_TAGGED_TPM_PROPERTY(
- buffer,
- &value->tpm_properties,
- value_bytes);
+ result = Parse_TPML_TAGGED_TPM_PROPERTY(buffer, &value->tpm_properties,
+ value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_CAP_PP_COMMANDS) {
- result = Parse_TPML_CC(
- buffer,
- &value->pp_commands,
- value_bytes);
+ result = Parse_TPML_CC(buffer, &value->pp_commands, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_CAP_AUDIT_COMMANDS) {
- result = Parse_TPML_CC(
- buffer,
- &value->audit_commands,
- value_bytes);
+ result = Parse_TPML_CC(buffer, &value->audit_commands, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_CAP_COMMANDS) {
- result = Parse_TPML_CCA(
- buffer,
- &value->command,
- value_bytes);
+ result = Parse_TPML_CCA(buffer, &value->command, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_CAP_ECC_CURVES) {
- result = Parse_TPML_ECC_CURVE(
- buffer,
- &value->ecc_curves,
- value_bytes);
+ result = Parse_TPML_ECC_CURVE(buffer, &value->ecc_curves, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_CAP_PCR_PROPERTIES) {
- result = Parse_TPML_TAGGED_PCR_PROPERTY(
- buffer,
- &value->pcr_properties,
- value_bytes);
+ result = Parse_TPML_TAGGED_PCR_PROPERTY(buffer, &value->pcr_properties,
+ value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_CAP_HANDLES) {
- result = Parse_TPML_HANDLE(
- buffer,
- &value->handles,
- value_bytes);
+ result = Parse_TPML_HANDLE(buffer, &value->handles, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_CAP_ALGS) {
- result = Parse_TPML_ALG_PROPERTY(
- buffer,
- &value->algorithms,
- value_bytes);
+ result = Parse_TPML_ALG_PROPERTY(buffer, &value->algorithms, value_bytes);
if (result) {
return result;
}
@@ -4275,9 +3898,8 @@
return result;
}
-TPM_RC Serialize_TPMS_CAPABILITY_DATA(
- const TPMS_CAPABILITY_DATA& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_CAPABILITY_DATA(const TPMS_CAPABILITY_DATA& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -4286,45 +3908,34 @@
return result;
}
- result = Serialize_TPMU_CAPABILITIES(
- value.data,
- value.capability,
- buffer);
+ result = Serialize_TPMU_CAPABILITIES(value.data, value.capability, buffer);
if (result) {
return result;
}
return result;
}
-TPM_RC Parse_TPMS_CAPABILITY_DATA(
- std::string* buffer,
- TPMS_CAPABILITY_DATA* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_CAPABILITY_DATA(std::string* buffer,
+ TPMS_CAPABILITY_DATA* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM_CAP(
- buffer,
- &value->capability,
- value_bytes);
+ result = Parse_TPM_CAP(buffer, &value->capability, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_CAPABILITIES(
- buffer,
- value->capability,
- &value->data,
- value_bytes);
+ result = Parse_TPMU_CAPABILITIES(buffer, value->capability, &value->data,
+ value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_CLOCK_INFO(
- const TPMS_CLOCK_INFO& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_CLOCK_INFO(const TPMS_CLOCK_INFO& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -4350,50 +3961,36 @@
return result;
}
-TPM_RC Parse_TPMS_CLOCK_INFO(
- std::string* buffer,
- TPMS_CLOCK_INFO* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_CLOCK_INFO(std::string* buffer,
+ TPMS_CLOCK_INFO* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT64(
- buffer,
- &value->clock,
- value_bytes);
+ result = Parse_UINT64(buffer, &value->clock, value_bytes);
if (result) {
return result;
}
- result = Parse_UINT32(
- buffer,
- &value->reset_count,
- value_bytes);
+ result = Parse_UINT32(buffer, &value->reset_count, value_bytes);
if (result) {
return result;
}
- result = Parse_UINT32(
- buffer,
- &value->restart_count,
- value_bytes);
+ result = Parse_UINT32(buffer, &value->restart_count, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMI_YES_NO(
- buffer,
- &value->safe,
- value_bytes);
+ result = Parse_TPMI_YES_NO(buffer, &value->safe, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_TIME_INFO(
- const TPMS_TIME_INFO& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_TIME_INFO(const TPMS_TIME_INFO& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -4409,34 +4006,26 @@
return result;
}
-TPM_RC Parse_TPMS_TIME_INFO(
- std::string* buffer,
- TPMS_TIME_INFO* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_TIME_INFO(std::string* buffer,
+ TPMS_TIME_INFO* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT64(
- buffer,
- &value->time,
- value_bytes);
+ result = Parse_UINT64(buffer, &value->time, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMS_CLOCK_INFO(
- buffer,
- &value->clock_info,
- value_bytes);
+ result = Parse_TPMS_CLOCK_INFO(buffer, &value->clock_info, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_TIME_ATTEST_INFO(
- const TPMS_TIME_ATTEST_INFO& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_TIME_ATTEST_INFO(const TPMS_TIME_ATTEST_INFO& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -4452,34 +4041,26 @@
return result;
}
-TPM_RC Parse_TPMS_TIME_ATTEST_INFO(
- std::string* buffer,
- TPMS_TIME_ATTEST_INFO* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_TIME_ATTEST_INFO(std::string* buffer,
+ TPMS_TIME_ATTEST_INFO* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMS_TIME_INFO(
- buffer,
- &value->time,
- value_bytes);
+ result = Parse_TPMS_TIME_INFO(buffer, &value->time, value_bytes);
if (result) {
return result;
}
- result = Parse_UINT64(
- buffer,
- &value->firmware_version,
- value_bytes);
+ result = Parse_UINT64(buffer, &value->firmware_version, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_CERTIFY_INFO(
- const TPMS_CERTIFY_INFO& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_CERTIFY_INFO(const TPMS_CERTIFY_INFO& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -4495,34 +4076,26 @@
return result;
}
-TPM_RC Parse_TPMS_CERTIFY_INFO(
- std::string* buffer,
- TPMS_CERTIFY_INFO* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_CERTIFY_INFO(std::string* buffer,
+ TPMS_CERTIFY_INFO* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM2B_NAME(
- buffer,
- &value->name,
- value_bytes);
+ result = Parse_TPM2B_NAME(buffer, &value->name, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_NAME(
- buffer,
- &value->qualified_name,
- value_bytes);
+ result = Parse_TPM2B_NAME(buffer, &value->qualified_name, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_QUOTE_INFO(
- const TPMS_QUOTE_INFO& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_QUOTE_INFO(const TPMS_QUOTE_INFO& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -4538,34 +4111,26 @@
return result;
}
-TPM_RC Parse_TPMS_QUOTE_INFO(
- std::string* buffer,
- TPMS_QUOTE_INFO* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_QUOTE_INFO(std::string* buffer,
+ TPMS_QUOTE_INFO* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPML_PCR_SELECTION(
- buffer,
- &value->pcr_select,
- value_bytes);
+ result = Parse_TPML_PCR_SELECTION(buffer, &value->pcr_select, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->pcr_digest,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->pcr_digest, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_COMMAND_AUDIT_INFO(
- const TPMS_COMMAND_AUDIT_INFO& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_COMMAND_AUDIT_INFO(const TPMS_COMMAND_AUDIT_INFO& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -4591,50 +4156,36 @@
return result;
}
-TPM_RC Parse_TPMS_COMMAND_AUDIT_INFO(
- std::string* buffer,
- TPMS_COMMAND_AUDIT_INFO* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_COMMAND_AUDIT_INFO(std::string* buffer,
+ TPMS_COMMAND_AUDIT_INFO* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT64(
- buffer,
- &value->audit_counter,
- value_bytes);
+ result = Parse_UINT64(buffer, &value->audit_counter, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM_ALG_ID(
- buffer,
- &value->digest_alg,
- value_bytes);
+ result = Parse_TPM_ALG_ID(buffer, &value->digest_alg, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->audit_digest,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->audit_digest, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->command_digest,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->command_digest, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_SESSION_AUDIT_INFO(
- const TPMS_SESSION_AUDIT_INFO& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SESSION_AUDIT_INFO(const TPMS_SESSION_AUDIT_INFO& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -4650,34 +4201,26 @@
return result;
}
-TPM_RC Parse_TPMS_SESSION_AUDIT_INFO(
- std::string* buffer,
- TPMS_SESSION_AUDIT_INFO* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SESSION_AUDIT_INFO(std::string* buffer,
+ TPMS_SESSION_AUDIT_INFO* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_YES_NO(
- buffer,
- &value->exclusive_session,
- value_bytes);
+ result = Parse_TPMI_YES_NO(buffer, &value->exclusive_session, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->session_digest,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->session_digest, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_CREATION_INFO(
- const TPMS_CREATION_INFO& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_CREATION_INFO(const TPMS_CREATION_INFO& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -4693,34 +4236,26 @@
return result;
}
-TPM_RC Parse_TPMS_CREATION_INFO(
- std::string* buffer,
- TPMS_CREATION_INFO* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_CREATION_INFO(std::string* buffer,
+ TPMS_CREATION_INFO* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM2B_NAME(
- buffer,
- &value->object_name,
- value_bytes);
+ result = Parse_TPM2B_NAME(buffer, &value->object_name, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->creation_hash,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->creation_hash, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_NV_CERTIFY_INFO(
- const TPMS_NV_CERTIFY_INFO& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_NV_CERTIFY_INFO(const TPMS_NV_CERTIFY_INFO& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -4741,43 +4276,32 @@
return result;
}
-TPM_RC Parse_TPMS_NV_CERTIFY_INFO(
- std::string* buffer,
- TPMS_NV_CERTIFY_INFO* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_NV_CERTIFY_INFO(std::string* buffer,
+ TPMS_NV_CERTIFY_INFO* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM2B_NAME(
- buffer,
- &value->index_name,
- value_bytes);
+ result = Parse_TPM2B_NAME(buffer, &value->index_name, value_bytes);
if (result) {
return result;
}
- result = Parse_UINT16(
- buffer,
- &value->offset,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->offset, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_MAX_NV_BUFFER(
- buffer,
- &value->nv_contents,
- value_bytes);
+ result = Parse_TPM2B_MAX_NV_BUFFER(buffer, &value->nv_contents, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMU_ATTEST(
- const TPMU_ATTEST& value,
- TPMI_ST_ATTEST selector,
- std::string* buffer) {
+TPM_RC Serialize_TPMU_ATTEST(const TPMU_ATTEST& value,
+ TPMI_ST_ATTEST selector,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -4832,79 +4356,59 @@
return result;
}
-TPM_RC Parse_TPMU_ATTEST(
- std::string* buffer,
- TPMI_ST_ATTEST selector,
- TPMU_ATTEST* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMU_ATTEST(std::string* buffer,
+ TPMI_ST_ATTEST selector,
+ TPMU_ATTEST* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
if (selector == TPM_ST_ATTEST_SESSION_AUDIT) {
- result = Parse_TPMS_SESSION_AUDIT_INFO(
- buffer,
- &value->session_audit,
- value_bytes);
+ result = Parse_TPMS_SESSION_AUDIT_INFO(buffer, &value->session_audit,
+ value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ST_ATTEST_QUOTE) {
- result = Parse_TPMS_QUOTE_INFO(
- buffer,
- &value->quote,
- value_bytes);
+ result = Parse_TPMS_QUOTE_INFO(buffer, &value->quote, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ST_ATTEST_COMMAND_AUDIT) {
- result = Parse_TPMS_COMMAND_AUDIT_INFO(
- buffer,
- &value->command_audit,
- value_bytes);
+ result = Parse_TPMS_COMMAND_AUDIT_INFO(buffer, &value->command_audit,
+ value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ST_ATTEST_CERTIFY) {
- result = Parse_TPMS_CERTIFY_INFO(
- buffer,
- &value->certify,
- value_bytes);
+ result = Parse_TPMS_CERTIFY_INFO(buffer, &value->certify, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ST_ATTEST_NV) {
- result = Parse_TPMS_NV_CERTIFY_INFO(
- buffer,
- &value->nv,
- value_bytes);
+ result = Parse_TPMS_NV_CERTIFY_INFO(buffer, &value->nv, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ST_ATTEST_TIME) {
- result = Parse_TPMS_TIME_ATTEST_INFO(
- buffer,
- &value->time,
- value_bytes);
+ result = Parse_TPMS_TIME_ATTEST_INFO(buffer, &value->time, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ST_ATTEST_CREATION) {
- result = Parse_TPMS_CREATION_INFO(
- buffer,
- &value->creation,
- value_bytes);
+ result = Parse_TPMS_CREATION_INFO(buffer, &value->creation, value_bytes);
if (result) {
return result;
}
@@ -4912,9 +4416,7 @@
return result;
}
-TPM_RC Serialize_TPMS_ATTEST(
- const TPMS_ATTEST& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_ATTEST(const TPMS_ATTEST& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -4948,85 +4450,58 @@
return result;
}
- result = Serialize_TPMU_ATTEST(
- value.attested,
- value.type,
- buffer);
+ result = Serialize_TPMU_ATTEST(value.attested, value.type, buffer);
if (result) {
return result;
}
return result;
}
-TPM_RC Parse_TPMS_ATTEST(
- std::string* buffer,
- TPMS_ATTEST* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_ATTEST(std::string* buffer,
+ TPMS_ATTEST* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM_GENERATED(
- buffer,
- &value->magic,
- value_bytes);
+ result = Parse_TPM_GENERATED(buffer, &value->magic, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMI_ST_ATTEST(
- buffer,
- &value->type,
- value_bytes);
+ result = Parse_TPMI_ST_ATTEST(buffer, &value->type, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_NAME(
- buffer,
- &value->qualified_signer,
- value_bytes);
+ result = Parse_TPM2B_NAME(buffer, &value->qualified_signer, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_DATA(
- buffer,
- &value->extra_data,
- value_bytes);
+ result = Parse_TPM2B_DATA(buffer, &value->extra_data, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMS_CLOCK_INFO(
- buffer,
- &value->clock_info,
- value_bytes);
+ result = Parse_TPMS_CLOCK_INFO(buffer, &value->clock_info, value_bytes);
if (result) {
return result;
}
- result = Parse_UINT64(
- buffer,
- &value->firmware_version,
- value_bytes);
+ result = Parse_UINT64(buffer, &value->firmware_version, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_ATTEST(
- buffer,
- value->type,
- &value->attested,
- value_bytes);
+ result =
+ Parse_TPMU_ATTEST(buffer, value->type, &value->attested, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPM2B_ATTEST(
- const TPM2B_ATTEST& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_ATTEST(const TPM2B_ATTEST& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5047,17 +4522,13 @@
return result;
}
-TPM_RC Parse_TPM2B_ATTEST(
- std::string* buffer,
- TPM2B_ATTEST* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_ATTEST(std::string* buffer,
+ TPM2B_ATTEST* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -5066,10 +4537,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->attestation_data[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->attestation_data[i], value_bytes);
if (result) {
return result;
}
@@ -5077,8 +4545,7 @@
return result;
}
-TPM2B_ATTEST Make_TPM2B_ATTEST(
- const std::string& bytes) {
+TPM2B_ATTEST Make_TPM2B_ATTEST(const std::string& bytes) {
TPM2B_ATTEST tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.attestation_data));
memset(&tpm2b, 0, sizeof(TPM2B_ATTEST));
@@ -5087,16 +4554,14 @@
return tpm2b;
}
-std::string StringFrom_TPM2B_ATTEST(
- const TPM2B_ATTEST& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.attestation_data);
+std::string StringFrom_TPM2B_ATTEST(const TPM2B_ATTEST& tpm2b) {
+ const char* char_buffer =
+ reinterpret_cast<const char*>(tpm2b.attestation_data);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPMS_AUTH_COMMAND(
- const TPMS_AUTH_COMMAND& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_AUTH_COMMAND(const TPMS_AUTH_COMMAND& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5122,50 +4587,37 @@
return result;
}
-TPM_RC Parse_TPMS_AUTH_COMMAND(
- std::string* buffer,
- TPMS_AUTH_COMMAND* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_AUTH_COMMAND(std::string* buffer,
+ TPMS_AUTH_COMMAND* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_SH_AUTH_SESSION(
- buffer,
- &value->session_handle,
- value_bytes);
+ result =
+ Parse_TPMI_SH_AUTH_SESSION(buffer, &value->session_handle, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_NONCE(
- buffer,
- &value->nonce,
- value_bytes);
+ result = Parse_TPM2B_NONCE(buffer, &value->nonce, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMA_SESSION(
- buffer,
- &value->session_attributes,
- value_bytes);
+ result = Parse_TPMA_SESSION(buffer, &value->session_attributes, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_AUTH(
- buffer,
- &value->hmac,
- value_bytes);
+ result = Parse_TPM2B_AUTH(buffer, &value->hmac, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_AUTH_RESPONSE(
- const TPMS_AUTH_RESPONSE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_AUTH_RESPONSE(const TPMS_AUTH_RESPONSE& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5186,43 +4638,32 @@
return result;
}
-TPM_RC Parse_TPMS_AUTH_RESPONSE(
- std::string* buffer,
- TPMS_AUTH_RESPONSE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_AUTH_RESPONSE(std::string* buffer,
+ TPMS_AUTH_RESPONSE* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM2B_NONCE(
- buffer,
- &value->nonce,
- value_bytes);
+ result = Parse_TPM2B_NONCE(buffer, &value->nonce, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMA_SESSION(
- buffer,
- &value->session_attributes,
- value_bytes);
+ result = Parse_TPMA_SESSION(buffer, &value->session_attributes, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_AUTH(
- buffer,
- &value->hmac,
- value_bytes);
+ result = Parse_TPM2B_AUTH(buffer, &value->hmac, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMU_SYM_KEY_BITS(
- const TPMU_SYM_KEY_BITS& value,
- TPMI_ALG_SYM selector,
- std::string* buffer) {
+TPM_RC Serialize_TPMU_SYM_KEY_BITS(const TPMU_SYM_KEY_BITS& value,
+ TPMI_ALG_SYM selector,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5253,11 +4694,10 @@
return result;
}
-TPM_RC Parse_TPMU_SYM_KEY_BITS(
- std::string* buffer,
- TPMI_ALG_SYM selector,
- TPMU_SYM_KEY_BITS* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMU_SYM_KEY_BITS(std::string* buffer,
+ TPMI_ALG_SYM selector,
+ TPMU_SYM_KEY_BITS* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5266,30 +4706,21 @@
}
if (selector == TPM_ALG_SM4) {
- result = Parse_TPMI_SM4_KEY_BITS(
- buffer,
- &value->sm4,
- value_bytes);
+ result = Parse_TPMI_SM4_KEY_BITS(buffer, &value->sm4, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_AES) {
- result = Parse_TPMI_AES_KEY_BITS(
- buffer,
- &value->aes,
- value_bytes);
+ result = Parse_TPMI_AES_KEY_BITS(buffer, &value->aes, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_XOR) {
- result = Parse_TPMI_ALG_HASH(
- buffer,
- &value->xor_,
- value_bytes);
+ result = Parse_TPMI_ALG_HASH(buffer, &value->xor_, value_bytes);
if (result) {
return result;
}
@@ -5297,10 +4728,9 @@
return result;
}
-TPM_RC Serialize_TPMU_SYM_MODE(
- const TPMU_SYM_MODE& value,
- TPMI_ALG_SYM selector,
- std::string* buffer) {
+TPM_RC Serialize_TPMU_SYM_MODE(const TPMU_SYM_MODE& value,
+ TPMI_ALG_SYM selector,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5328,11 +4758,10 @@
return result;
}
-TPM_RC Parse_TPMU_SYM_MODE(
- std::string* buffer,
- TPMI_ALG_SYM selector,
- TPMU_SYM_MODE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMU_SYM_MODE(std::string* buffer,
+ TPMI_ALG_SYM selector,
+ TPMU_SYM_MODE* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5341,20 +4770,14 @@
}
if (selector == TPM_ALG_SM4) {
- result = Parse_TPMI_ALG_SYM_MODE(
- buffer,
- &value->sm4,
- value_bytes);
+ result = Parse_TPMI_ALG_SYM_MODE(buffer, &value->sm4, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_AES) {
- result = Parse_TPMI_ALG_SYM_MODE(
- buffer,
- &value->aes,
- value_bytes);
+ result = Parse_TPMI_ALG_SYM_MODE(buffer, &value->aes, value_bytes);
if (result) {
return result;
}
@@ -5366,28 +4789,24 @@
return result;
}
-TPM_RC Serialize_TPMU_SYM_DETAILS(
- const TPMU_SYM_DETAILS& value,
- TPMI_ALG_SYM selector,
- std::string* buffer) {
+TPM_RC Serialize_TPMU_SYM_DETAILS(const TPMU_SYM_DETAILS& value,
+ TPMI_ALG_SYM selector,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
return result;
}
-TPM_RC Parse_TPMU_SYM_DETAILS(
- std::string* buffer,
- TPMI_ALG_SYM selector,
- TPMU_SYM_DETAILS* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMU_SYM_DETAILS(std::string* buffer,
+ TPMI_ALG_SYM selector,
+ TPMU_SYM_DETAILS* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
return result;
}
-TPM_RC Serialize_TPMT_SYM_DEF(
- const TPMT_SYM_DEF& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMT_SYM_DEF(const TPMT_SYM_DEF& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5396,79 +4815,56 @@
return result;
}
- result = Serialize_TPMU_SYM_KEY_BITS(
- value.key_bits,
- value.algorithm,
- buffer);
+ result = Serialize_TPMU_SYM_KEY_BITS(value.key_bits, value.algorithm, buffer);
if (result) {
return result;
}
- result = Serialize_TPMU_SYM_MODE(
- value.mode,
- value.algorithm,
- buffer);
+ result = Serialize_TPMU_SYM_MODE(value.mode, value.algorithm, buffer);
if (result) {
return result;
}
- result = Serialize_TPMU_SYM_DETAILS(
- value.details,
- value.algorithm,
- buffer);
+ result = Serialize_TPMU_SYM_DETAILS(value.details, value.algorithm, buffer);
if (result) {
return result;
}
return result;
}
-TPM_RC Parse_TPMT_SYM_DEF(
- std::string* buffer,
- TPMT_SYM_DEF* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMT_SYM_DEF(std::string* buffer,
+ TPMT_SYM_DEF* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_SYM(
- buffer,
- &value->algorithm,
- value_bytes);
+ result = Parse_TPMI_ALG_SYM(buffer, &value->algorithm, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_SYM_KEY_BITS(
- buffer,
- value->algorithm,
- &value->key_bits,
- value_bytes);
+ result = Parse_TPMU_SYM_KEY_BITS(buffer, value->algorithm, &value->key_bits,
+ value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_SYM_MODE(
- buffer,
- value->algorithm,
- &value->mode,
- value_bytes);
+ result =
+ Parse_TPMU_SYM_MODE(buffer, value->algorithm, &value->mode, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_SYM_DETAILS(
- buffer,
- value->algorithm,
- &value->details,
- value_bytes);
+ result = Parse_TPMU_SYM_DETAILS(buffer, value->algorithm, &value->details,
+ value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMT_SYM_DEF_OBJECT(
- const TPMT_SYM_DEF_OBJECT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMT_SYM_DEF_OBJECT(const TPMT_SYM_DEF_OBJECT& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5477,79 +4873,56 @@
return result;
}
- result = Serialize_TPMU_SYM_KEY_BITS(
- value.key_bits,
- value.algorithm,
- buffer);
+ result = Serialize_TPMU_SYM_KEY_BITS(value.key_bits, value.algorithm, buffer);
if (result) {
return result;
}
- result = Serialize_TPMU_SYM_MODE(
- value.mode,
- value.algorithm,
- buffer);
+ result = Serialize_TPMU_SYM_MODE(value.mode, value.algorithm, buffer);
if (result) {
return result;
}
- result = Serialize_TPMU_SYM_DETAILS(
- value.details,
- value.algorithm,
- buffer);
+ result = Serialize_TPMU_SYM_DETAILS(value.details, value.algorithm, buffer);
if (result) {
return result;
}
return result;
}
-TPM_RC Parse_TPMT_SYM_DEF_OBJECT(
- std::string* buffer,
- TPMT_SYM_DEF_OBJECT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMT_SYM_DEF_OBJECT(std::string* buffer,
+ TPMT_SYM_DEF_OBJECT* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_SYM_OBJECT(
- buffer,
- &value->algorithm,
- value_bytes);
+ result = Parse_TPMI_ALG_SYM_OBJECT(buffer, &value->algorithm, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_SYM_KEY_BITS(
- buffer,
- value->algorithm,
- &value->key_bits,
- value_bytes);
+ result = Parse_TPMU_SYM_KEY_BITS(buffer, value->algorithm, &value->key_bits,
+ value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_SYM_MODE(
- buffer,
- value->algorithm,
- &value->mode,
- value_bytes);
+ result =
+ Parse_TPMU_SYM_MODE(buffer, value->algorithm, &value->mode, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_SYM_DETAILS(
- buffer,
- value->algorithm,
- &value->details,
- value_bytes);
+ result = Parse_TPMU_SYM_DETAILS(buffer, value->algorithm, &value->details,
+ value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPM2B_SYM_KEY(
- const TPM2B_SYM_KEY& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_SYM_KEY(const TPM2B_SYM_KEY& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5570,17 +4943,13 @@
return result;
}
-TPM_RC Parse_TPM2B_SYM_KEY(
- std::string* buffer,
- TPM2B_SYM_KEY* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_SYM_KEY(std::string* buffer,
+ TPM2B_SYM_KEY* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -5589,10 +4958,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->buffer[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->buffer[i], value_bytes);
if (result) {
return result;
}
@@ -5600,8 +4966,7 @@
return result;
}
-TPM2B_SYM_KEY Make_TPM2B_SYM_KEY(
- const std::string& bytes) {
+TPM2B_SYM_KEY Make_TPM2B_SYM_KEY(const std::string& bytes) {
TPM2B_SYM_KEY tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.buffer));
memset(&tpm2b, 0, sizeof(TPM2B_SYM_KEY));
@@ -5610,16 +4975,13 @@
return tpm2b;
}
-std::string StringFrom_TPM2B_SYM_KEY(
- const TPM2B_SYM_KEY& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.buffer);
+std::string StringFrom_TPM2B_SYM_KEY(const TPM2B_SYM_KEY& tpm2b) {
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.buffer);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPMS_SYMCIPHER_PARMS(
- const TPMS_SYMCIPHER_PARMS& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SYMCIPHER_PARMS(const TPMS_SYMCIPHER_PARMS& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5630,26 +4992,21 @@
return result;
}
-TPM_RC Parse_TPMS_SYMCIPHER_PARMS(
- std::string* buffer,
- TPMS_SYMCIPHER_PARMS* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SYMCIPHER_PARMS(std::string* buffer,
+ TPMS_SYMCIPHER_PARMS* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMT_SYM_DEF_OBJECT(
- buffer,
- &value->sym,
- value_bytes);
+ result = Parse_TPMT_SYM_DEF_OBJECT(buffer, &value->sym, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPM2B_SENSITIVE_DATA(
- const TPM2B_SENSITIVE_DATA& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_SENSITIVE_DATA(const TPM2B_SENSITIVE_DATA& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5670,17 +5027,13 @@
return result;
}
-TPM_RC Parse_TPM2B_SENSITIVE_DATA(
- std::string* buffer,
- TPM2B_SENSITIVE_DATA* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_SENSITIVE_DATA(std::string* buffer,
+ TPM2B_SENSITIVE_DATA* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -5689,10 +5042,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->buffer[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->buffer[i], value_bytes);
if (result) {
return result;
}
@@ -5700,8 +5050,7 @@
return result;
}
-TPM2B_SENSITIVE_DATA Make_TPM2B_SENSITIVE_DATA(
- const std::string& bytes) {
+TPM2B_SENSITIVE_DATA Make_TPM2B_SENSITIVE_DATA(const std::string& bytes) {
TPM2B_SENSITIVE_DATA tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.buffer));
memset(&tpm2b, 0, sizeof(TPM2B_SENSITIVE_DATA));
@@ -5710,16 +5059,13 @@
return tpm2b;
}
-std::string StringFrom_TPM2B_SENSITIVE_DATA(
- const TPM2B_SENSITIVE_DATA& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.buffer);
+std::string StringFrom_TPM2B_SENSITIVE_DATA(const TPM2B_SENSITIVE_DATA& tpm2b) {
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.buffer);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPMS_SENSITIVE_CREATE(
- const TPMS_SENSITIVE_CREATE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SENSITIVE_CREATE(const TPMS_SENSITIVE_CREATE& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5735,34 +5081,26 @@
return result;
}
-TPM_RC Parse_TPMS_SENSITIVE_CREATE(
- std::string* buffer,
- TPMS_SENSITIVE_CREATE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SENSITIVE_CREATE(std::string* buffer,
+ TPMS_SENSITIVE_CREATE* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM2B_AUTH(
- buffer,
- &value->user_auth,
- value_bytes);
+ result = Parse_TPM2B_AUTH(buffer, &value->user_auth, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_SENSITIVE_DATA(
- buffer,
- &value->data,
- value_bytes);
+ result = Parse_TPM2B_SENSITIVE_DATA(buffer, &value->data, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPM2B_SENSITIVE_CREATE(
- const TPM2B_SENSITIVE_CREATE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_SENSITIVE_CREATE(const TPM2B_SENSITIVE_CREATE& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5780,25 +5118,18 @@
return result;
}
-TPM_RC Parse_TPM2B_SENSITIVE_CREATE(
- std::string* buffer,
- TPM2B_SENSITIVE_CREATE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_SENSITIVE_CREATE(std::string* buffer,
+ TPM2B_SENSITIVE_CREATE* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMS_SENSITIVE_CREATE(
- buffer,
- &value->sensitive,
- value_bytes);
+ result = Parse_TPMS_SENSITIVE_CREATE(buffer, &value->sensitive, value_bytes);
if (result) {
return result;
}
@@ -5813,9 +5144,8 @@
return tpm2b;
}
-TPM_RC Serialize_TPMS_SCHEME_XOR(
- const TPMS_SCHEME_XOR& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SCHEME_XOR(const TPMS_SCHEME_XOR& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5831,35 +5161,27 @@
return result;
}
-TPM_RC Parse_TPMS_SCHEME_XOR(
- std::string* buffer,
- TPMS_SCHEME_XOR* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SCHEME_XOR(std::string* buffer,
+ TPMS_SCHEME_XOR* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_HASH(
- buffer,
- &value->hash_alg,
- value_bytes);
+ result = Parse_TPMI_ALG_HASH(buffer, &value->hash_alg, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMI_ALG_KDF(
- buffer,
- &value->kdf,
- value_bytes);
+ result = Parse_TPMI_ALG_KDF(buffer, &value->kdf, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMU_SCHEME_KEYEDHASH(
- const TPMU_SCHEME_KEYEDHASH& value,
- TPMI_ALG_KEYEDHASH_SCHEME selector,
- std::string* buffer) {
+TPM_RC Serialize_TPMU_SCHEME_KEYEDHASH(const TPMU_SCHEME_KEYEDHASH& value,
+ TPMI_ALG_KEYEDHASH_SCHEME selector,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5883,11 +5205,10 @@
return result;
}
-TPM_RC Parse_TPMU_SCHEME_KEYEDHASH(
- std::string* buffer,
- TPMI_ALG_KEYEDHASH_SCHEME selector,
- TPMU_SCHEME_KEYEDHASH* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMU_SCHEME_KEYEDHASH(std::string* buffer,
+ TPMI_ALG_KEYEDHASH_SCHEME selector,
+ TPMU_SCHEME_KEYEDHASH* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5896,20 +5217,14 @@
}
if (selector == TPM_ALG_HMAC) {
- result = Parse_TPMS_SCHEME_HMAC(
- buffer,
- &value->hmac,
- value_bytes);
+ result = Parse_TPMS_SCHEME_HMAC(buffer, &value->hmac, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_XOR) {
- result = Parse_TPMS_SCHEME_XOR(
- buffer,
- &value->xor_,
- value_bytes);
+ result = Parse_TPMS_SCHEME_XOR(buffer, &value->xor_, value_bytes);
if (result) {
return result;
}
@@ -5917,9 +5232,8 @@
return result;
}
-TPM_RC Serialize_TPMT_KEYEDHASH_SCHEME(
- const TPMT_KEYEDHASH_SCHEME& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMT_KEYEDHASH_SCHEME(const TPMT_KEYEDHASH_SCHEME& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5928,45 +5242,34 @@
return result;
}
- result = Serialize_TPMU_SCHEME_KEYEDHASH(
- value.details,
- value.scheme,
- buffer);
+ result = Serialize_TPMU_SCHEME_KEYEDHASH(value.details, value.scheme, buffer);
if (result) {
return result;
}
return result;
}
-TPM_RC Parse_TPMT_KEYEDHASH_SCHEME(
- std::string* buffer,
- TPMT_KEYEDHASH_SCHEME* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMT_KEYEDHASH_SCHEME(std::string* buffer,
+ TPMT_KEYEDHASH_SCHEME* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_KEYEDHASH_SCHEME(
- buffer,
- &value->scheme,
- value_bytes);
+ result = Parse_TPMI_ALG_KEYEDHASH_SCHEME(buffer, &value->scheme, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_SCHEME_KEYEDHASH(
- buffer,
- value->scheme,
- &value->details,
- value_bytes);
+ result = Parse_TPMU_SCHEME_KEYEDHASH(buffer, value->scheme, &value->details,
+ value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_SCHEME_ECDAA(
- const TPMS_SCHEME_ECDAA& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SCHEME_ECDAA(const TPMS_SCHEME_ECDAA& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -5982,35 +5285,27 @@
return result;
}
-TPM_RC Parse_TPMS_SCHEME_ECDAA(
- std::string* buffer,
- TPMS_SCHEME_ECDAA* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SCHEME_ECDAA(std::string* buffer,
+ TPMS_SCHEME_ECDAA* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_HASH(
- buffer,
- &value->hash_alg,
- value_bytes);
+ result = Parse_TPMI_ALG_HASH(buffer, &value->hash_alg, value_bytes);
if (result) {
return result;
}
- result = Parse_UINT16(
- buffer,
- &value->count,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->count, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMU_SIG_SCHEME(
- const TPMU_SIG_SCHEME& value,
- TPMI_ALG_SIG_SCHEME selector,
- std::string* buffer) {
+TPM_RC Serialize_TPMU_SIG_SCHEME(const TPMU_SIG_SCHEME& value,
+ TPMI_ALG_SIG_SCHEME selector,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -6069,79 +5364,58 @@
return result;
}
-TPM_RC Parse_TPMU_SIG_SCHEME(
- std::string* buffer,
- TPMI_ALG_SIG_SCHEME selector,
- TPMU_SIG_SCHEME* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMU_SIG_SCHEME(std::string* buffer,
+ TPMI_ALG_SIG_SCHEME selector,
+ TPMU_SIG_SCHEME* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
if (selector == TPM_ALG_HMAC) {
- result = Parse_TPMS_SCHEME_HMAC(
- buffer,
- &value->hmac,
- value_bytes);
+ result = Parse_TPMS_SCHEME_HMAC(buffer, &value->hmac, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_ECSCHNORR) {
- result = Parse_TPMS_SCHEME_ECSCHNORR(
- buffer,
- &value->ec_schnorr,
- value_bytes);
+ result =
+ Parse_TPMS_SCHEME_ECSCHNORR(buffer, &value->ec_schnorr, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_RSAPSS) {
- result = Parse_TPMS_SCHEME_RSAPSS(
- buffer,
- &value->rsapss,
- value_bytes);
+ result = Parse_TPMS_SCHEME_RSAPSS(buffer, &value->rsapss, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_ECDAA) {
- result = Parse_TPMS_SCHEME_ECDAA(
- buffer,
- &value->ecdaa,
- value_bytes);
+ result = Parse_TPMS_SCHEME_ECDAA(buffer, &value->ecdaa, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_RSASSA) {
- result = Parse_TPMS_SCHEME_RSASSA(
- buffer,
- &value->rsassa,
- value_bytes);
+ result = Parse_TPMS_SCHEME_RSASSA(buffer, &value->rsassa, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_SM2) {
- result = Parse_TPMS_SCHEME_SM2(
- buffer,
- &value->sm2,
- value_bytes);
+ result = Parse_TPMS_SCHEME_SM2(buffer, &value->sm2, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_ECDSA) {
- result = Parse_TPMS_SCHEME_ECDSA(
- buffer,
- &value->ecdsa,
- value_bytes);
+ result = Parse_TPMS_SCHEME_ECDSA(buffer, &value->ecdsa, value_bytes);
if (result) {
return result;
}
@@ -6153,9 +5427,8 @@
return result;
}
-TPM_RC Serialize_TPMT_SIG_SCHEME(
- const TPMT_SIG_SCHEME& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMT_SIG_SCHEME(const TPMT_SIG_SCHEME& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -6164,45 +5437,34 @@
return result;
}
- result = Serialize_TPMU_SIG_SCHEME(
- value.details,
- value.scheme,
- buffer);
+ result = Serialize_TPMU_SIG_SCHEME(value.details, value.scheme, buffer);
if (result) {
return result;
}
return result;
}
-TPM_RC Parse_TPMT_SIG_SCHEME(
- std::string* buffer,
- TPMT_SIG_SCHEME* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMT_SIG_SCHEME(std::string* buffer,
+ TPMT_SIG_SCHEME* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_SIG_SCHEME(
- buffer,
- &value->scheme,
- value_bytes);
+ result = Parse_TPMI_ALG_SIG_SCHEME(buffer, &value->scheme, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_SIG_SCHEME(
- buffer,
- value->scheme,
- &value->details,
- value_bytes);
+ result = Parse_TPMU_SIG_SCHEME(buffer, value->scheme, &value->details,
+ value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_SCHEME_OAEP(
- const TPMS_SCHEME_OAEP& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SCHEME_OAEP(const TPMS_SCHEME_OAEP& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -6213,26 +5475,21 @@
return result;
}
-TPM_RC Parse_TPMS_SCHEME_OAEP(
- std::string* buffer,
- TPMS_SCHEME_OAEP* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SCHEME_OAEP(std::string* buffer,
+ TPMS_SCHEME_OAEP* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_HASH(
- buffer,
- &value->hash_alg,
- value_bytes);
+ result = Parse_TPMI_ALG_HASH(buffer, &value->hash_alg, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_SCHEME_ECDH(
- const TPMS_SCHEME_ECDH& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SCHEME_ECDH(const TPMS_SCHEME_ECDH& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -6243,26 +5500,21 @@
return result;
}
-TPM_RC Parse_TPMS_SCHEME_ECDH(
- std::string* buffer,
- TPMS_SCHEME_ECDH* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SCHEME_ECDH(std::string* buffer,
+ TPMS_SCHEME_ECDH* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_HASH(
- buffer,
- &value->hash_alg,
- value_bytes);
+ result = Parse_TPMI_ALG_HASH(buffer, &value->hash_alg, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_SCHEME_MGF1(
- const TPMS_SCHEME_MGF1& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SCHEME_MGF1(const TPMS_SCHEME_MGF1& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -6273,17 +5525,13 @@
return result;
}
-TPM_RC Parse_TPMS_SCHEME_MGF1(
- std::string* buffer,
- TPMS_SCHEME_MGF1* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SCHEME_MGF1(std::string* buffer,
+ TPMS_SCHEME_MGF1* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_HASH(
- buffer,
- &value->hash_alg,
- value_bytes);
+ result = Parse_TPMI_ALG_HASH(buffer, &value->hash_alg, value_bytes);
if (result) {
return result;
}
@@ -6303,26 +5551,21 @@
return result;
}
-TPM_RC Parse_TPMS_SCHEME_KDF1_SP800_56a(
- std::string* buffer,
- TPMS_SCHEME_KDF1_SP800_56a* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SCHEME_KDF1_SP800_56a(std::string* buffer,
+ TPMS_SCHEME_KDF1_SP800_56a* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_HASH(
- buffer,
- &value->hash_alg,
- value_bytes);
+ result = Parse_TPMI_ALG_HASH(buffer, &value->hash_alg, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_SCHEME_KDF2(
- const TPMS_SCHEME_KDF2& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SCHEME_KDF2(const TPMS_SCHEME_KDF2& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -6333,17 +5576,13 @@
return result;
}
-TPM_RC Parse_TPMS_SCHEME_KDF2(
- std::string* buffer,
- TPMS_SCHEME_KDF2* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SCHEME_KDF2(std::string* buffer,
+ TPMS_SCHEME_KDF2* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_HASH(
- buffer,
- &value->hash_alg,
- value_bytes);
+ result = Parse_TPMI_ALG_HASH(buffer, &value->hash_alg, value_bytes);
if (result) {
return result;
}
@@ -6363,27 +5602,22 @@
return result;
}
-TPM_RC Parse_TPMS_SCHEME_KDF1_SP800_108(
- std::string* buffer,
- TPMS_SCHEME_KDF1_SP800_108* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SCHEME_KDF1_SP800_108(std::string* buffer,
+ TPMS_SCHEME_KDF1_SP800_108* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_HASH(
- buffer,
- &value->hash_alg,
- value_bytes);
+ result = Parse_TPMI_ALG_HASH(buffer, &value->hash_alg, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMU_KDF_SCHEME(
- const TPMU_KDF_SCHEME& value,
- TPMI_ALG_KDF selector,
- std::string* buffer) {
+TPM_RC Serialize_TPMU_KDF_SCHEME(const TPMU_KDF_SCHEME& value,
+ TPMI_ALG_KDF selector,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -6421,49 +5655,38 @@
return result;
}
-TPM_RC Parse_TPMU_KDF_SCHEME(
- std::string* buffer,
- TPMI_ALG_KDF selector,
- TPMU_KDF_SCHEME* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMU_KDF_SCHEME(std::string* buffer,
+ TPMI_ALG_KDF selector,
+ TPMU_KDF_SCHEME* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
if (selector == TPM_ALG_KDF1_SP800_56a) {
- result = Parse_TPMS_SCHEME_KDF1_SP800_56a(
- buffer,
- &value->kdf1_sp800_56a,
- value_bytes);
+ result = Parse_TPMS_SCHEME_KDF1_SP800_56a(buffer, &value->kdf1_sp800_56a,
+ value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_MGF1) {
- result = Parse_TPMS_SCHEME_MGF1(
- buffer,
- &value->mgf1,
- value_bytes);
+ result = Parse_TPMS_SCHEME_MGF1(buffer, &value->mgf1, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_KDF1_SP800_108) {
- result = Parse_TPMS_SCHEME_KDF1_SP800_108(
- buffer,
- &value->kdf1_sp800_108,
- value_bytes);
+ result = Parse_TPMS_SCHEME_KDF1_SP800_108(buffer, &value->kdf1_sp800_108,
+ value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_KDF2) {
- result = Parse_TPMS_SCHEME_KDF2(
- buffer,
- &value->kdf2,
- value_bytes);
+ result = Parse_TPMS_SCHEME_KDF2(buffer, &value->kdf2, value_bytes);
if (result) {
return result;
}
@@ -6475,9 +5698,8 @@
return result;
}
-TPM_RC Serialize_TPMT_KDF_SCHEME(
- const TPMT_KDF_SCHEME& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMT_KDF_SCHEME(const TPMT_KDF_SCHEME& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -6486,46 +5708,35 @@
return result;
}
- result = Serialize_TPMU_KDF_SCHEME(
- value.details,
- value.scheme,
- buffer);
+ result = Serialize_TPMU_KDF_SCHEME(value.details, value.scheme, buffer);
if (result) {
return result;
}
return result;
}
-TPM_RC Parse_TPMT_KDF_SCHEME(
- std::string* buffer,
- TPMT_KDF_SCHEME* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMT_KDF_SCHEME(std::string* buffer,
+ TPMT_KDF_SCHEME* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_KDF(
- buffer,
- &value->scheme,
- value_bytes);
+ result = Parse_TPMI_ALG_KDF(buffer, &value->scheme, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_KDF_SCHEME(
- buffer,
- value->scheme,
- &value->details,
- value_bytes);
+ result = Parse_TPMU_KDF_SCHEME(buffer, value->scheme, &value->details,
+ value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMU_ASYM_SCHEME(
- const TPMU_ASYM_SCHEME& value,
- TPMI_ALG_ASYM_SCHEME selector,
- std::string* buffer) {
+TPM_RC Serialize_TPMU_ASYM_SCHEME(const TPMU_ASYM_SCHEME& value,
+ TPMI_ALG_ASYM_SCHEME selector,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -6595,11 +5806,10 @@
return result;
}
-TPM_RC Parse_TPMU_ASYM_SCHEME(
- std::string* buffer,
- TPMI_ALG_ASYM_SCHEME selector,
- TPMU_ASYM_SCHEME* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMU_ASYM_SCHEME(std::string* buffer,
+ TPMI_ALG_ASYM_SCHEME selector,
+ TPMU_ASYM_SCHEME* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -6608,10 +5818,8 @@
}
if (selector == TPM_ALG_ECSCHNORR) {
- result = Parse_TPMS_SCHEME_ECSCHNORR(
- buffer,
- &value->ec_schnorr,
- value_bytes);
+ result =
+ Parse_TPMS_SCHEME_ECSCHNORR(buffer, &value->ec_schnorr, value_bytes);
if (result) {
return result;
}
@@ -6622,70 +5830,49 @@
}
if (selector == TPM_ALG_ECDH) {
- result = Parse_TPMS_SCHEME_ECDH(
- buffer,
- &value->ecdh,
- value_bytes);
+ result = Parse_TPMS_SCHEME_ECDH(buffer, &value->ecdh, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_OAEP) {
- result = Parse_TPMS_SCHEME_OAEP(
- buffer,
- &value->oaep,
- value_bytes);
+ result = Parse_TPMS_SCHEME_OAEP(buffer, &value->oaep, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_RSAPSS) {
- result = Parse_TPMS_SCHEME_RSAPSS(
- buffer,
- &value->rsapss,
- value_bytes);
+ result = Parse_TPMS_SCHEME_RSAPSS(buffer, &value->rsapss, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_ECDAA) {
- result = Parse_TPMS_SCHEME_ECDAA(
- buffer,
- &value->ecdaa,
- value_bytes);
+ result = Parse_TPMS_SCHEME_ECDAA(buffer, &value->ecdaa, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_RSASSA) {
- result = Parse_TPMS_SCHEME_RSASSA(
- buffer,
- &value->rsassa,
- value_bytes);
+ result = Parse_TPMS_SCHEME_RSASSA(buffer, &value->rsassa, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_SM2) {
- result = Parse_TPMS_SCHEME_SM2(
- buffer,
- &value->sm2,
- value_bytes);
+ result = Parse_TPMS_SCHEME_SM2(buffer, &value->sm2, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_ECDSA) {
- result = Parse_TPMS_SCHEME_ECDSA(
- buffer,
- &value->ecdsa,
- value_bytes);
+ result = Parse_TPMS_SCHEME_ECDSA(buffer, &value->ecdsa, value_bytes);
if (result) {
return result;
}
@@ -6693,9 +5880,8 @@
return result;
}
-TPM_RC Serialize_TPMT_ASYM_SCHEME(
- const TPMT_ASYM_SCHEME& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMT_ASYM_SCHEME(const TPMT_ASYM_SCHEME& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -6704,45 +5890,34 @@
return result;
}
- result = Serialize_TPMU_ASYM_SCHEME(
- value.details,
- value.scheme,
- buffer);
+ result = Serialize_TPMU_ASYM_SCHEME(value.details, value.scheme, buffer);
if (result) {
return result;
}
return result;
}
-TPM_RC Parse_TPMT_ASYM_SCHEME(
- std::string* buffer,
- TPMT_ASYM_SCHEME* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMT_ASYM_SCHEME(std::string* buffer,
+ TPMT_ASYM_SCHEME* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_ASYM_SCHEME(
- buffer,
- &value->scheme,
- value_bytes);
+ result = Parse_TPMI_ALG_ASYM_SCHEME(buffer, &value->scheme, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_ASYM_SCHEME(
- buffer,
- value->scheme,
- &value->details,
- value_bytes);
+ result = Parse_TPMU_ASYM_SCHEME(buffer, value->scheme, &value->details,
+ value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMT_RSA_SCHEME(
- const TPMT_RSA_SCHEME& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMT_RSA_SCHEME(const TPMT_RSA_SCHEME& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -6751,45 +5926,34 @@
return result;
}
- result = Serialize_TPMU_ASYM_SCHEME(
- value.details,
- value.scheme,
- buffer);
+ result = Serialize_TPMU_ASYM_SCHEME(value.details, value.scheme, buffer);
if (result) {
return result;
}
return result;
}
-TPM_RC Parse_TPMT_RSA_SCHEME(
- std::string* buffer,
- TPMT_RSA_SCHEME* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMT_RSA_SCHEME(std::string* buffer,
+ TPMT_RSA_SCHEME* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_RSA_SCHEME(
- buffer,
- &value->scheme,
- value_bytes);
+ result = Parse_TPMI_ALG_RSA_SCHEME(buffer, &value->scheme, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_ASYM_SCHEME(
- buffer,
- value->scheme,
- &value->details,
- value_bytes);
+ result = Parse_TPMU_ASYM_SCHEME(buffer, value->scheme, &value->details,
+ value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMT_RSA_DECRYPT(
- const TPMT_RSA_DECRYPT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMT_RSA_DECRYPT(const TPMT_RSA_DECRYPT& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -6798,45 +5962,34 @@
return result;
}
- result = Serialize_TPMU_ASYM_SCHEME(
- value.details,
- value.scheme,
- buffer);
+ result = Serialize_TPMU_ASYM_SCHEME(value.details, value.scheme, buffer);
if (result) {
return result;
}
return result;
}
-TPM_RC Parse_TPMT_RSA_DECRYPT(
- std::string* buffer,
- TPMT_RSA_DECRYPT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMT_RSA_DECRYPT(std::string* buffer,
+ TPMT_RSA_DECRYPT* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_RSA_DECRYPT(
- buffer,
- &value->scheme,
- value_bytes);
+ result = Parse_TPMI_ALG_RSA_DECRYPT(buffer, &value->scheme, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_ASYM_SCHEME(
- buffer,
- value->scheme,
- &value->details,
- value_bytes);
+ result = Parse_TPMU_ASYM_SCHEME(buffer, value->scheme, &value->details,
+ value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPM2B_PUBLIC_KEY_RSA(
- const TPM2B_PUBLIC_KEY_RSA& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_PUBLIC_KEY_RSA(const TPM2B_PUBLIC_KEY_RSA& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -6857,17 +6010,13 @@
return result;
}
-TPM_RC Parse_TPM2B_PUBLIC_KEY_RSA(
- std::string* buffer,
- TPM2B_PUBLIC_KEY_RSA* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_PUBLIC_KEY_RSA(std::string* buffer,
+ TPM2B_PUBLIC_KEY_RSA* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -6876,10 +6025,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->buffer[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->buffer[i], value_bytes);
if (result) {
return result;
}
@@ -6887,8 +6033,7 @@
return result;
}
-TPM2B_PUBLIC_KEY_RSA Make_TPM2B_PUBLIC_KEY_RSA(
- const std::string& bytes) {
+TPM2B_PUBLIC_KEY_RSA Make_TPM2B_PUBLIC_KEY_RSA(const std::string& bytes) {
TPM2B_PUBLIC_KEY_RSA tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.buffer));
memset(&tpm2b, 0, sizeof(TPM2B_PUBLIC_KEY_RSA));
@@ -6897,16 +6042,13 @@
return tpm2b;
}
-std::string StringFrom_TPM2B_PUBLIC_KEY_RSA(
- const TPM2B_PUBLIC_KEY_RSA& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.buffer);
+std::string StringFrom_TPM2B_PUBLIC_KEY_RSA(const TPM2B_PUBLIC_KEY_RSA& tpm2b) {
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.buffer);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPM2B_PRIVATE_KEY_RSA(
- const TPM2B_PRIVATE_KEY_RSA& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_PRIVATE_KEY_RSA(const TPM2B_PRIVATE_KEY_RSA& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -6927,17 +6069,13 @@
return result;
}
-TPM_RC Parse_TPM2B_PRIVATE_KEY_RSA(
- std::string* buffer,
- TPM2B_PRIVATE_KEY_RSA* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_PRIVATE_KEY_RSA(std::string* buffer,
+ TPM2B_PRIVATE_KEY_RSA* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -6946,10 +6084,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->buffer[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->buffer[i], value_bytes);
if (result) {
return result;
}
@@ -6957,8 +6092,7 @@
return result;
}
-TPM2B_PRIVATE_KEY_RSA Make_TPM2B_PRIVATE_KEY_RSA(
- const std::string& bytes) {
+TPM2B_PRIVATE_KEY_RSA Make_TPM2B_PRIVATE_KEY_RSA(const std::string& bytes) {
TPM2B_PRIVATE_KEY_RSA tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.buffer));
memset(&tpm2b, 0, sizeof(TPM2B_PRIVATE_KEY_RSA));
@@ -6969,14 +6103,12 @@
std::string StringFrom_TPM2B_PRIVATE_KEY_RSA(
const TPM2B_PRIVATE_KEY_RSA& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.buffer);
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.buffer);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPM2B_ECC_PARAMETER(
- const TPM2B_ECC_PARAMETER& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_ECC_PARAMETER(const TPM2B_ECC_PARAMETER& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -6997,17 +6129,13 @@
return result;
}
-TPM_RC Parse_TPM2B_ECC_PARAMETER(
- std::string* buffer,
- TPM2B_ECC_PARAMETER* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_ECC_PARAMETER(std::string* buffer,
+ TPM2B_ECC_PARAMETER* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -7016,10 +6144,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->buffer[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->buffer[i], value_bytes);
if (result) {
return result;
}
@@ -7027,8 +6152,7 @@
return result;
}
-TPM2B_ECC_PARAMETER Make_TPM2B_ECC_PARAMETER(
- const std::string& bytes) {
+TPM2B_ECC_PARAMETER Make_TPM2B_ECC_PARAMETER(const std::string& bytes) {
TPM2B_ECC_PARAMETER tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.buffer));
memset(&tpm2b, 0, sizeof(TPM2B_ECC_PARAMETER));
@@ -7037,16 +6161,13 @@
return tpm2b;
}
-std::string StringFrom_TPM2B_ECC_PARAMETER(
- const TPM2B_ECC_PARAMETER& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.buffer);
+std::string StringFrom_TPM2B_ECC_PARAMETER(const TPM2B_ECC_PARAMETER& tpm2b) {
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.buffer);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPMS_ECC_POINT(
- const TPMS_ECC_POINT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_ECC_POINT(const TPMS_ECC_POINT& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -7062,34 +6183,26 @@
return result;
}
-TPM_RC Parse_TPMS_ECC_POINT(
- std::string* buffer,
- TPMS_ECC_POINT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_ECC_POINT(std::string* buffer,
+ TPMS_ECC_POINT* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM2B_ECC_PARAMETER(
- buffer,
- &value->x,
- value_bytes);
+ result = Parse_TPM2B_ECC_PARAMETER(buffer, &value->x, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_ECC_PARAMETER(
- buffer,
- &value->y,
- value_bytes);
+ result = Parse_TPM2B_ECC_PARAMETER(buffer, &value->y, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPM2B_ECC_POINT(
- const TPM2B_ECC_POINT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_ECC_POINT(const TPM2B_ECC_POINT& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -7107,42 +6220,33 @@
return result;
}
-TPM_RC Parse_TPM2B_ECC_POINT(
- std::string* buffer,
- TPM2B_ECC_POINT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_ECC_POINT(std::string* buffer,
+ TPM2B_ECC_POINT* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMS_ECC_POINT(
- buffer,
- &value->point,
- value_bytes);
+ result = Parse_TPMS_ECC_POINT(buffer, &value->point, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM2B_ECC_POINT Make_TPM2B_ECC_POINT(
- const TPMS_ECC_POINT& inner) {
+TPM2B_ECC_POINT Make_TPM2B_ECC_POINT(const TPMS_ECC_POINT& inner) {
TPM2B_ECC_POINT tpm2b;
tpm2b.size = sizeof(TPMS_ECC_POINT);
tpm2b.point = inner;
return tpm2b;
}
-TPM_RC Serialize_TPMT_ECC_SCHEME(
- const TPMT_ECC_SCHEME& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMT_ECC_SCHEME(const TPMT_ECC_SCHEME& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -7151,36 +6255,26 @@
return result;
}
- result = Serialize_TPMU_SIG_SCHEME(
- value.details,
- value.scheme,
- buffer);
+ result = Serialize_TPMU_SIG_SCHEME(value.details, value.scheme, buffer);
if (result) {
return result;
}
return result;
}
-TPM_RC Parse_TPMT_ECC_SCHEME(
- std::string* buffer,
- TPMT_ECC_SCHEME* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMT_ECC_SCHEME(std::string* buffer,
+ TPMT_ECC_SCHEME* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_ECC_SCHEME(
- buffer,
- &value->scheme,
- value_bytes);
+ result = Parse_TPMI_ALG_ECC_SCHEME(buffer, &value->scheme, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_SIG_SCHEME(
- buffer,
- value->scheme,
- &value->details,
- value_bytes);
+ result = Parse_TPMU_SIG_SCHEME(buffer, value->scheme, &value->details,
+ value_bytes);
if (result) {
return result;
}
@@ -7250,106 +6344,71 @@
return result;
}
-TPM_RC Parse_TPMS_ALGORITHM_DETAIL_ECC(
- std::string* buffer,
- TPMS_ALGORITHM_DETAIL_ECC* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_ALGORITHM_DETAIL_ECC(std::string* buffer,
+ TPMS_ALGORITHM_DETAIL_ECC* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM_ECC_CURVE(
- buffer,
- &value->curve_id,
- value_bytes);
+ result = Parse_TPM_ECC_CURVE(buffer, &value->curve_id, value_bytes);
if (result) {
return result;
}
- result = Parse_UINT16(
- buffer,
- &value->key_size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->key_size, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMT_KDF_SCHEME(
- buffer,
- &value->kdf,
- value_bytes);
+ result = Parse_TPMT_KDF_SCHEME(buffer, &value->kdf, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMT_ECC_SCHEME(
- buffer,
- &value->sign,
- value_bytes);
+ result = Parse_TPMT_ECC_SCHEME(buffer, &value->sign, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_ECC_PARAMETER(
- buffer,
- &value->p,
- value_bytes);
+ result = Parse_TPM2B_ECC_PARAMETER(buffer, &value->p, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_ECC_PARAMETER(
- buffer,
- &value->a,
- value_bytes);
+ result = Parse_TPM2B_ECC_PARAMETER(buffer, &value->a, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_ECC_PARAMETER(
- buffer,
- &value->b,
- value_bytes);
+ result = Parse_TPM2B_ECC_PARAMETER(buffer, &value->b, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_ECC_PARAMETER(
- buffer,
- &value->g_x,
- value_bytes);
+ result = Parse_TPM2B_ECC_PARAMETER(buffer, &value->g_x, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_ECC_PARAMETER(
- buffer,
- &value->g_y,
- value_bytes);
+ result = Parse_TPM2B_ECC_PARAMETER(buffer, &value->g_y, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_ECC_PARAMETER(
- buffer,
- &value->n,
- value_bytes);
+ result = Parse_TPM2B_ECC_PARAMETER(buffer, &value->n, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_ECC_PARAMETER(
- buffer,
- &value->h,
- value_bytes);
+ result = Parse_TPM2B_ECC_PARAMETER(buffer, &value->h, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_SIGNATURE_RSASSA(
- const TPMS_SIGNATURE_RSASSA& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SIGNATURE_RSASSA(const TPMS_SIGNATURE_RSASSA& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -7365,34 +6424,26 @@
return result;
}
-TPM_RC Parse_TPMS_SIGNATURE_RSASSA(
- std::string* buffer,
- TPMS_SIGNATURE_RSASSA* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SIGNATURE_RSASSA(std::string* buffer,
+ TPMS_SIGNATURE_RSASSA* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_HASH(
- buffer,
- &value->hash,
- value_bytes);
+ result = Parse_TPMI_ALG_HASH(buffer, &value->hash, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_PUBLIC_KEY_RSA(
- buffer,
- &value->sig,
- value_bytes);
+ result = Parse_TPM2B_PUBLIC_KEY_RSA(buffer, &value->sig, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_SIGNATURE_RSAPSS(
- const TPMS_SIGNATURE_RSAPSS& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SIGNATURE_RSAPSS(const TPMS_SIGNATURE_RSAPSS& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -7408,34 +6459,26 @@
return result;
}
-TPM_RC Parse_TPMS_SIGNATURE_RSAPSS(
- std::string* buffer,
- TPMS_SIGNATURE_RSAPSS* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SIGNATURE_RSAPSS(std::string* buffer,
+ TPMS_SIGNATURE_RSAPSS* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_HASH(
- buffer,
- &value->hash,
- value_bytes);
+ result = Parse_TPMI_ALG_HASH(buffer, &value->hash, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_PUBLIC_KEY_RSA(
- buffer,
- &value->sig,
- value_bytes);
+ result = Parse_TPM2B_PUBLIC_KEY_RSA(buffer, &value->sig, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_SIGNATURE_ECDSA(
- const TPMS_SIGNATURE_ECDSA& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_SIGNATURE_ECDSA(const TPMS_SIGNATURE_ECDSA& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -7456,43 +6499,32 @@
return result;
}
-TPM_RC Parse_TPMS_SIGNATURE_ECDSA(
- std::string* buffer,
- TPMS_SIGNATURE_ECDSA* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_SIGNATURE_ECDSA(std::string* buffer,
+ TPMS_SIGNATURE_ECDSA* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_HASH(
- buffer,
- &value->hash,
- value_bytes);
+ result = Parse_TPMI_ALG_HASH(buffer, &value->hash, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_ECC_PARAMETER(
- buffer,
- &value->signature_r,
- value_bytes);
+ result = Parse_TPM2B_ECC_PARAMETER(buffer, &value->signature_r, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_ECC_PARAMETER(
- buffer,
- &value->signature_s,
- value_bytes);
+ result = Parse_TPM2B_ECC_PARAMETER(buffer, &value->signature_s, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMU_SIGNATURE(
- const TPMU_SIGNATURE& value,
- TPMI_ALG_SIG_SCHEME selector,
- std::string* buffer) {
+TPM_RC Serialize_TPMU_SIGNATURE(const TPMU_SIGNATURE& value,
+ TPMI_ALG_SIG_SCHEME selector,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -7551,79 +6583,57 @@
return result;
}
-TPM_RC Parse_TPMU_SIGNATURE(
- std::string* buffer,
- TPMI_ALG_SIG_SCHEME selector,
- TPMU_SIGNATURE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMU_SIGNATURE(std::string* buffer,
+ TPMI_ALG_SIG_SCHEME selector,
+ TPMU_SIGNATURE* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
if (selector == TPM_ALG_HMAC) {
- result = Parse_TPMT_HA(
- buffer,
- &value->hmac,
- value_bytes);
+ result = Parse_TPMT_HA(buffer, &value->hmac, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_ECSCHNORR) {
- result = Parse_TPMS_SIGNATURE_ECDSA(
- buffer,
- &value->ecschnorr,
- value_bytes);
+ result = Parse_TPMS_SIGNATURE_ECDSA(buffer, &value->ecschnorr, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_RSAPSS) {
- result = Parse_TPMS_SIGNATURE_RSAPSS(
- buffer,
- &value->rsapss,
- value_bytes);
+ result = Parse_TPMS_SIGNATURE_RSAPSS(buffer, &value->rsapss, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_ECDAA) {
- result = Parse_TPMS_SIGNATURE_ECDSA(
- buffer,
- &value->ecdaa,
- value_bytes);
+ result = Parse_TPMS_SIGNATURE_ECDSA(buffer, &value->ecdaa, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_RSASSA) {
- result = Parse_TPMS_SIGNATURE_RSASSA(
- buffer,
- &value->rsassa,
- value_bytes);
+ result = Parse_TPMS_SIGNATURE_RSASSA(buffer, &value->rsassa, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_SM2) {
- result = Parse_TPMS_SIGNATURE_ECDSA(
- buffer,
- &value->sm2,
- value_bytes);
+ result = Parse_TPMS_SIGNATURE_ECDSA(buffer, &value->sm2, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_ECDSA) {
- result = Parse_TPMS_SIGNATURE_ECDSA(
- buffer,
- &value->ecdsa,
- value_bytes);
+ result = Parse_TPMS_SIGNATURE_ECDSA(buffer, &value->ecdsa, value_bytes);
if (result) {
return result;
}
@@ -7635,9 +6645,8 @@
return result;
}
-TPM_RC Serialize_TPMT_SIGNATURE(
- const TPMT_SIGNATURE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMT_SIGNATURE(const TPMT_SIGNATURE& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -7646,45 +6655,34 @@
return result;
}
- result = Serialize_TPMU_SIGNATURE(
- value.signature,
- value.sig_alg,
- buffer);
+ result = Serialize_TPMU_SIGNATURE(value.signature, value.sig_alg, buffer);
if (result) {
return result;
}
return result;
}
-TPM_RC Parse_TPMT_SIGNATURE(
- std::string* buffer,
- TPMT_SIGNATURE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMT_SIGNATURE(std::string* buffer,
+ TPMT_SIGNATURE* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_SIG_SCHEME(
- buffer,
- &value->sig_alg,
- value_bytes);
+ result = Parse_TPMI_ALG_SIG_SCHEME(buffer, &value->sig_alg, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_SIGNATURE(
- buffer,
- value->sig_alg,
- &value->signature,
- value_bytes);
+ result = Parse_TPMU_SIGNATURE(buffer, value->sig_alg, &value->signature,
+ value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPM2B_ENCRYPTED_SECRET(
- const TPM2B_ENCRYPTED_SECRET& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_ENCRYPTED_SECRET(const TPM2B_ENCRYPTED_SECRET& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -7705,17 +6703,13 @@
return result;
}
-TPM_RC Parse_TPM2B_ENCRYPTED_SECRET(
- std::string* buffer,
- TPM2B_ENCRYPTED_SECRET* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_ENCRYPTED_SECRET(std::string* buffer,
+ TPM2B_ENCRYPTED_SECRET* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -7724,10 +6718,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->secret[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->secret[i], value_bytes);
if (result) {
return result;
}
@@ -7735,8 +6726,7 @@
return result;
}
-TPM2B_ENCRYPTED_SECRET Make_TPM2B_ENCRYPTED_SECRET(
- const std::string& bytes) {
+TPM2B_ENCRYPTED_SECRET Make_TPM2B_ENCRYPTED_SECRET(const std::string& bytes) {
TPM2B_ENCRYPTED_SECRET tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.secret));
memset(&tpm2b, 0, sizeof(TPM2B_ENCRYPTED_SECRET));
@@ -7747,14 +6737,12 @@
std::string StringFrom_TPM2B_ENCRYPTED_SECRET(
const TPM2B_ENCRYPTED_SECRET& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.secret);
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.secret);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPMS_KEYEDHASH_PARMS(
- const TPMS_KEYEDHASH_PARMS& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_KEYEDHASH_PARMS(const TPMS_KEYEDHASH_PARMS& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -7765,26 +6753,21 @@
return result;
}
-TPM_RC Parse_TPMS_KEYEDHASH_PARMS(
- std::string* buffer,
- TPMS_KEYEDHASH_PARMS* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_KEYEDHASH_PARMS(std::string* buffer,
+ TPMS_KEYEDHASH_PARMS* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMT_KEYEDHASH_SCHEME(
- buffer,
- &value->scheme,
- value_bytes);
+ result = Parse_TPMT_KEYEDHASH_SCHEME(buffer, &value->scheme, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_ASYM_PARMS(
- const TPMS_ASYM_PARMS& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_ASYM_PARMS(const TPMS_ASYM_PARMS& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -7800,34 +6783,26 @@
return result;
}
-TPM_RC Parse_TPMS_ASYM_PARMS(
- std::string* buffer,
- TPMS_ASYM_PARMS* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_ASYM_PARMS(std::string* buffer,
+ TPMS_ASYM_PARMS* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMT_SYM_DEF_OBJECT(
- buffer,
- &value->symmetric,
- value_bytes);
+ result = Parse_TPMT_SYM_DEF_OBJECT(buffer, &value->symmetric, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMT_ASYM_SCHEME(
- buffer,
- &value->scheme,
- value_bytes);
+ result = Parse_TPMT_ASYM_SCHEME(buffer, &value->scheme, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_RSA_PARMS(
- const TPMS_RSA_PARMS& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_RSA_PARMS(const TPMS_RSA_PARMS& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -7853,50 +6828,36 @@
return result;
}
-TPM_RC Parse_TPMS_RSA_PARMS(
- std::string* buffer,
- TPMS_RSA_PARMS* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_RSA_PARMS(std::string* buffer,
+ TPMS_RSA_PARMS* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMT_SYM_DEF_OBJECT(
- buffer,
- &value->symmetric,
- value_bytes);
+ result = Parse_TPMT_SYM_DEF_OBJECT(buffer, &value->symmetric, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMT_RSA_SCHEME(
- buffer,
- &value->scheme,
- value_bytes);
+ result = Parse_TPMT_RSA_SCHEME(buffer, &value->scheme, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMI_RSA_KEY_BITS(
- buffer,
- &value->key_bits,
- value_bytes);
+ result = Parse_TPMI_RSA_KEY_BITS(buffer, &value->key_bits, value_bytes);
if (result) {
return result;
}
- result = Parse_UINT32(
- buffer,
- &value->exponent,
- value_bytes);
+ result = Parse_UINT32(buffer, &value->exponent, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_ECC_PARMS(
- const TPMS_ECC_PARMS& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_ECC_PARMS(const TPMS_ECC_PARMS& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -7922,51 +6883,37 @@
return result;
}
-TPM_RC Parse_TPMS_ECC_PARMS(
- std::string* buffer,
- TPMS_ECC_PARMS* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_ECC_PARMS(std::string* buffer,
+ TPMS_ECC_PARMS* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMT_SYM_DEF_OBJECT(
- buffer,
- &value->symmetric,
- value_bytes);
+ result = Parse_TPMT_SYM_DEF_OBJECT(buffer, &value->symmetric, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMT_ECC_SCHEME(
- buffer,
- &value->scheme,
- value_bytes);
+ result = Parse_TPMT_ECC_SCHEME(buffer, &value->scheme, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMI_ECC_CURVE(
- buffer,
- &value->curve_id,
- value_bytes);
+ result = Parse_TPMI_ECC_CURVE(buffer, &value->curve_id, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMT_KDF_SCHEME(
- buffer,
- &value->kdf,
- value_bytes);
+ result = Parse_TPMT_KDF_SCHEME(buffer, &value->kdf, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMU_PUBLIC_PARMS(
- const TPMU_PUBLIC_PARMS& value,
- TPMI_ALG_PUBLIC selector,
- std::string* buffer) {
+TPM_RC Serialize_TPMU_PUBLIC_PARMS(const TPMU_PUBLIC_PARMS& value,
+ TPMI_ALG_PUBLIC selector,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -8000,49 +6947,38 @@
return result;
}
-TPM_RC Parse_TPMU_PUBLIC_PARMS(
- std::string* buffer,
- TPMI_ALG_PUBLIC selector,
- TPMU_PUBLIC_PARMS* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMU_PUBLIC_PARMS(std::string* buffer,
+ TPMI_ALG_PUBLIC selector,
+ TPMU_PUBLIC_PARMS* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
if (selector == TPM_ALG_KEYEDHASH) {
- result = Parse_TPMS_KEYEDHASH_PARMS(
- buffer,
- &value->keyed_hash_detail,
- value_bytes);
+ result = Parse_TPMS_KEYEDHASH_PARMS(buffer, &value->keyed_hash_detail,
+ value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_RSA) {
- result = Parse_TPMS_RSA_PARMS(
- buffer,
- &value->rsa_detail,
- value_bytes);
+ result = Parse_TPMS_RSA_PARMS(buffer, &value->rsa_detail, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_SYMCIPHER) {
- result = Parse_TPMS_SYMCIPHER_PARMS(
- buffer,
- &value->sym_detail,
- value_bytes);
+ result =
+ Parse_TPMS_SYMCIPHER_PARMS(buffer, &value->sym_detail, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_ECC) {
- result = Parse_TPMS_ECC_PARMS(
- buffer,
- &value->ecc_detail,
- value_bytes);
+ result = Parse_TPMS_ECC_PARMS(buffer, &value->ecc_detail, value_bytes);
if (result) {
return result;
}
@@ -8050,9 +6986,8 @@
return result;
}
-TPM_RC Serialize_TPMT_PUBLIC_PARMS(
- const TPMT_PUBLIC_PARMS& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMT_PUBLIC_PARMS(const TPMT_PUBLIC_PARMS& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -8061,46 +6996,35 @@
return result;
}
- result = Serialize_TPMU_PUBLIC_PARMS(
- value.parameters,
- value.type,
- buffer);
+ result = Serialize_TPMU_PUBLIC_PARMS(value.parameters, value.type, buffer);
if (result) {
return result;
}
return result;
}
-TPM_RC Parse_TPMT_PUBLIC_PARMS(
- std::string* buffer,
- TPMT_PUBLIC_PARMS* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMT_PUBLIC_PARMS(std::string* buffer,
+ TPMT_PUBLIC_PARMS* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_PUBLIC(
- buffer,
- &value->type,
- value_bytes);
+ result = Parse_TPMI_ALG_PUBLIC(buffer, &value->type, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_PUBLIC_PARMS(
- buffer,
- value->type,
- &value->parameters,
- value_bytes);
+ result = Parse_TPMU_PUBLIC_PARMS(buffer, value->type, &value->parameters,
+ value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMU_PUBLIC_ID(
- const TPMU_PUBLIC_ID& value,
- TPMI_ALG_PUBLIC selector,
- std::string* buffer) {
+TPM_RC Serialize_TPMU_PUBLIC_ID(const TPMU_PUBLIC_ID& value,
+ TPMI_ALG_PUBLIC selector,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -8134,49 +7058,36 @@
return result;
}
-TPM_RC Parse_TPMU_PUBLIC_ID(
- std::string* buffer,
- TPMI_ALG_PUBLIC selector,
- TPMU_PUBLIC_ID* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMU_PUBLIC_ID(std::string* buffer,
+ TPMI_ALG_PUBLIC selector,
+ TPMU_PUBLIC_ID* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
if (selector == TPM_ALG_KEYEDHASH) {
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->keyed_hash,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->keyed_hash, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_RSA) {
- result = Parse_TPM2B_PUBLIC_KEY_RSA(
- buffer,
- &value->rsa,
- value_bytes);
+ result = Parse_TPM2B_PUBLIC_KEY_RSA(buffer, &value->rsa, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_SYMCIPHER) {
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->sym,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->sym, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_ECC) {
- result = Parse_TPMS_ECC_POINT(
- buffer,
- &value->ecc,
- value_bytes);
+ result = Parse_TPMS_ECC_POINT(buffer, &value->ecc, value_bytes);
if (result) {
return result;
}
@@ -8184,9 +7095,7 @@
return result;
}
-TPM_RC Serialize_TPMT_PUBLIC(
- const TPMT_PUBLIC& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMT_PUBLIC(const TPMT_PUBLIC& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -8210,86 +7119,59 @@
return result;
}
- result = Serialize_TPMU_PUBLIC_PARMS(
- value.parameters,
- value.type,
- buffer);
+ result = Serialize_TPMU_PUBLIC_PARMS(value.parameters, value.type, buffer);
if (result) {
return result;
}
- result = Serialize_TPMU_PUBLIC_ID(
- value.unique,
- value.type,
- buffer);
+ result = Serialize_TPMU_PUBLIC_ID(value.unique, value.type, buffer);
if (result) {
return result;
}
return result;
}
-TPM_RC Parse_TPMT_PUBLIC(
- std::string* buffer,
- TPMT_PUBLIC* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMT_PUBLIC(std::string* buffer,
+ TPMT_PUBLIC* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_PUBLIC(
- buffer,
- &value->type,
- value_bytes);
+ result = Parse_TPMI_ALG_PUBLIC(buffer, &value->type, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMI_ALG_HASH(
- buffer,
- &value->name_alg,
- value_bytes);
+ result = Parse_TPMI_ALG_HASH(buffer, &value->name_alg, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMA_OBJECT(
- buffer,
- &value->object_attributes,
- value_bytes);
+ result = Parse_TPMA_OBJECT(buffer, &value->object_attributes, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->auth_policy,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->auth_policy, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_PUBLIC_PARMS(
- buffer,
- value->type,
- &value->parameters,
- value_bytes);
+ result = Parse_TPMU_PUBLIC_PARMS(buffer, value->type, &value->parameters,
+ value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_PUBLIC_ID(
- buffer,
- value->type,
- &value->unique,
- value_bytes);
+ result =
+ Parse_TPMU_PUBLIC_ID(buffer, value->type, &value->unique, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPM2B_PUBLIC(
- const TPM2B_PUBLIC& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_PUBLIC(const TPM2B_PUBLIC& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -8307,33 +7189,25 @@
return result;
}
-TPM_RC Parse_TPM2B_PUBLIC(
- std::string* buffer,
- TPM2B_PUBLIC* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_PUBLIC(std::string* buffer,
+ TPM2B_PUBLIC* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMT_PUBLIC(
- buffer,
- &value->public_area,
- value_bytes);
+ result = Parse_TPMT_PUBLIC(buffer, &value->public_area, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM2B_PUBLIC Make_TPM2B_PUBLIC(
- const TPMT_PUBLIC& inner) {
+TPM2B_PUBLIC Make_TPM2B_PUBLIC(const TPMT_PUBLIC& inner) {
TPM2B_PUBLIC tpm2b;
tpm2b.size = sizeof(TPMT_PUBLIC);
tpm2b.public_area = inner;
@@ -8363,17 +7237,13 @@
return result;
}
-TPM_RC Parse_TPM2B_PRIVATE_VENDOR_SPECIFIC(
- std::string* buffer,
- TPM2B_PRIVATE_VENDOR_SPECIFIC* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_PRIVATE_VENDOR_SPECIFIC(std::string* buffer,
+ TPM2B_PRIVATE_VENDOR_SPECIFIC* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -8382,10 +7252,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->buffer[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->buffer[i], value_bytes);
if (result) {
return result;
}
@@ -8405,15 +7272,13 @@
std::string StringFrom_TPM2B_PRIVATE_VENDOR_SPECIFIC(
const TPM2B_PRIVATE_VENDOR_SPECIFIC& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.buffer);
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.buffer);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPMU_SENSITIVE_COMPOSITE(
- const TPMU_SENSITIVE_COMPOSITE& value,
- TPMI_ALG_PUBLIC selector,
- std::string* buffer) {
+TPM_RC Serialize_TPMU_SENSITIVE_COMPOSITE(const TPMU_SENSITIVE_COMPOSITE& value,
+ TPMI_ALG_PUBLIC selector,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -8447,49 +7312,36 @@
return result;
}
-TPM_RC Parse_TPMU_SENSITIVE_COMPOSITE(
- std::string* buffer,
- TPMI_ALG_PUBLIC selector,
- TPMU_SENSITIVE_COMPOSITE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMU_SENSITIVE_COMPOSITE(std::string* buffer,
+ TPMI_ALG_PUBLIC selector,
+ TPMU_SENSITIVE_COMPOSITE* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
if (selector == TPM_ALG_KEYEDHASH) {
- result = Parse_TPM2B_SENSITIVE_DATA(
- buffer,
- &value->bits,
- value_bytes);
+ result = Parse_TPM2B_SENSITIVE_DATA(buffer, &value->bits, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_RSA) {
- result = Parse_TPM2B_PRIVATE_KEY_RSA(
- buffer,
- &value->rsa,
- value_bytes);
+ result = Parse_TPM2B_PRIVATE_KEY_RSA(buffer, &value->rsa, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_SYMCIPHER) {
- result = Parse_TPM2B_SYM_KEY(
- buffer,
- &value->sym,
- value_bytes);
+ result = Parse_TPM2B_SYM_KEY(buffer, &value->sym, value_bytes);
if (result) {
return result;
}
}
if (selector == TPM_ALG_ECC) {
- result = Parse_TPM2B_ECC_PARAMETER(
- buffer,
- &value->ecc,
- value_bytes);
+ result = Parse_TPM2B_ECC_PARAMETER(buffer, &value->ecc, value_bytes);
if (result) {
return result;
}
@@ -8497,9 +7349,8 @@
return result;
}
-TPM_RC Serialize_TPMT_SENSITIVE(
- const TPMT_SENSITIVE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMT_SENSITIVE(const TPMT_SENSITIVE& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -8518,61 +7369,45 @@
return result;
}
- result = Serialize_TPMU_SENSITIVE_COMPOSITE(
- value.sensitive,
- value.sensitive_type,
- buffer);
+ result = Serialize_TPMU_SENSITIVE_COMPOSITE(value.sensitive,
+ value.sensitive_type, buffer);
if (result) {
return result;
}
return result;
}
-TPM_RC Parse_TPMT_SENSITIVE(
- std::string* buffer,
- TPMT_SENSITIVE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMT_SENSITIVE(std::string* buffer,
+ TPMT_SENSITIVE* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_ALG_PUBLIC(
- buffer,
- &value->sensitive_type,
- value_bytes);
+ result = Parse_TPMI_ALG_PUBLIC(buffer, &value->sensitive_type, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_AUTH(
- buffer,
- &value->auth_value,
- value_bytes);
+ result = Parse_TPM2B_AUTH(buffer, &value->auth_value, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->seed_value,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->seed_value, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMU_SENSITIVE_COMPOSITE(
- buffer,
- value->sensitive_type,
- &value->sensitive,
- value_bytes);
+ result = Parse_TPMU_SENSITIVE_COMPOSITE(buffer, value->sensitive_type,
+ &value->sensitive, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPM2B_SENSITIVE(
- const TPM2B_SENSITIVE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_SENSITIVE(const TPM2B_SENSITIVE& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -8590,42 +7425,32 @@
return result;
}
-TPM_RC Parse_TPM2B_SENSITIVE(
- std::string* buffer,
- TPM2B_SENSITIVE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_SENSITIVE(std::string* buffer,
+ TPM2B_SENSITIVE* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMT_SENSITIVE(
- buffer,
- &value->sensitive_area,
- value_bytes);
+ result = Parse_TPMT_SENSITIVE(buffer, &value->sensitive_area, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM2B_SENSITIVE Make_TPM2B_SENSITIVE(
- const TPMT_SENSITIVE& inner) {
+TPM2B_SENSITIVE Make_TPM2B_SENSITIVE(const TPMT_SENSITIVE& inner) {
TPM2B_SENSITIVE tpm2b;
tpm2b.size = sizeof(TPMT_SENSITIVE);
tpm2b.sensitive_area = inner;
return tpm2b;
}
-TPM_RC Serialize__PRIVATE(
- const _PRIVATE& value,
- std::string* buffer) {
+TPM_RC Serialize__PRIVATE(const _PRIVATE& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -8646,42 +7471,31 @@
return result;
}
-TPM_RC Parse__PRIVATE(
- std::string* buffer,
- _PRIVATE* value,
- std::string* value_bytes) {
+TPM_RC Parse__PRIVATE(std::string* buffer,
+ _PRIVATE* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->integrity_outer,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->integrity_outer, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->integrity_inner,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->integrity_inner, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMT_SENSITIVE(
- buffer,
- &value->sensitive,
- value_bytes);
+ result = Parse_TPMT_SENSITIVE(buffer, &value->sensitive, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPM2B_PRIVATE(
- const TPM2B_PRIVATE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_PRIVATE(const TPM2B_PRIVATE& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -8702,17 +7516,13 @@
return result;
}
-TPM_RC Parse_TPM2B_PRIVATE(
- std::string* buffer,
- TPM2B_PRIVATE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_PRIVATE(std::string* buffer,
+ TPM2B_PRIVATE* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -8721,10 +7531,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->buffer[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->buffer[i], value_bytes);
if (result) {
return result;
}
@@ -8732,8 +7539,7 @@
return result;
}
-TPM2B_PRIVATE Make_TPM2B_PRIVATE(
- const std::string& bytes) {
+TPM2B_PRIVATE Make_TPM2B_PRIVATE(const std::string& bytes) {
TPM2B_PRIVATE tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.buffer));
memset(&tpm2b, 0, sizeof(TPM2B_PRIVATE));
@@ -8742,16 +7548,12 @@
return tpm2b;
}
-std::string StringFrom_TPM2B_PRIVATE(
- const TPM2B_PRIVATE& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.buffer);
+std::string StringFrom_TPM2B_PRIVATE(const TPM2B_PRIVATE& tpm2b) {
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.buffer);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize__ID_OBJECT(
- const _ID_OBJECT& value,
- std::string* buffer) {
+TPM_RC Serialize__ID_OBJECT(const _ID_OBJECT& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -8767,34 +7569,26 @@
return result;
}
-TPM_RC Parse__ID_OBJECT(
- std::string* buffer,
- _ID_OBJECT* value,
- std::string* value_bytes) {
+TPM_RC Parse__ID_OBJECT(std::string* buffer,
+ _ID_OBJECT* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->integrity_hmac,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->integrity_hmac, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->enc_identity,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->enc_identity, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPM2B_ID_OBJECT(
- const TPM2B_ID_OBJECT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_ID_OBJECT(const TPM2B_ID_OBJECT& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -8815,17 +7609,13 @@
return result;
}
-TPM_RC Parse_TPM2B_ID_OBJECT(
- std::string* buffer,
- TPM2B_ID_OBJECT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_ID_OBJECT(std::string* buffer,
+ TPM2B_ID_OBJECT* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -8834,10 +7624,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->credential[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->credential[i], value_bytes);
if (result) {
return result;
}
@@ -8845,8 +7632,7 @@
return result;
}
-TPM2B_ID_OBJECT Make_TPM2B_ID_OBJECT(
- const std::string& bytes) {
+TPM2B_ID_OBJECT Make_TPM2B_ID_OBJECT(const std::string& bytes) {
TPM2B_ID_OBJECT tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.credential));
memset(&tpm2b, 0, sizeof(TPM2B_ID_OBJECT));
@@ -8855,16 +7641,13 @@
return tpm2b;
}
-std::string StringFrom_TPM2B_ID_OBJECT(
- const TPM2B_ID_OBJECT& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.credential);
+std::string StringFrom_TPM2B_ID_OBJECT(const TPM2B_ID_OBJECT& tpm2b) {
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.credential);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPMS_NV_PUBLIC(
- const TPMS_NV_PUBLIC& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_NV_PUBLIC(const TPMS_NV_PUBLIC& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -8895,58 +7678,41 @@
return result;
}
-TPM_RC Parse_TPMS_NV_PUBLIC(
- std::string* buffer,
- TPMS_NV_PUBLIC* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_NV_PUBLIC(std::string* buffer,
+ TPMS_NV_PUBLIC* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPMI_RH_NV_INDEX(
- buffer,
- &value->nv_index,
- value_bytes);
+ result = Parse_TPMI_RH_NV_INDEX(buffer, &value->nv_index, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMI_ALG_HASH(
- buffer,
- &value->name_alg,
- value_bytes);
+ result = Parse_TPMI_ALG_HASH(buffer, &value->name_alg, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMA_NV(
- buffer,
- &value->attributes,
- value_bytes);
+ result = Parse_TPMA_NV(buffer, &value->attributes, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->auth_policy,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->auth_policy, value_bytes);
if (result) {
return result;
}
- result = Parse_UINT16(
- buffer,
- &value->data_size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->data_size, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPM2B_NV_PUBLIC(
- const TPM2B_NV_PUBLIC& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_NV_PUBLIC(const TPM2B_NV_PUBLIC& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -8964,42 +7730,33 @@
return result;
}
-TPM_RC Parse_TPM2B_NV_PUBLIC(
- std::string* buffer,
- TPM2B_NV_PUBLIC* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_NV_PUBLIC(std::string* buffer,
+ TPM2B_NV_PUBLIC* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMS_NV_PUBLIC(
- buffer,
- &value->nv_public,
- value_bytes);
+ result = Parse_TPMS_NV_PUBLIC(buffer, &value->nv_public, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM2B_NV_PUBLIC Make_TPM2B_NV_PUBLIC(
- const TPMS_NV_PUBLIC& inner) {
+TPM2B_NV_PUBLIC Make_TPM2B_NV_PUBLIC(const TPMS_NV_PUBLIC& inner) {
TPM2B_NV_PUBLIC tpm2b;
tpm2b.size = sizeof(TPMS_NV_PUBLIC);
tpm2b.nv_public = inner;
return tpm2b;
}
-TPM_RC Serialize_TPM2B_CONTEXT_SENSITIVE(
- const TPM2B_CONTEXT_SENSITIVE& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_CONTEXT_SENSITIVE(const TPM2B_CONTEXT_SENSITIVE& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -9020,17 +7777,13 @@
return result;
}
-TPM_RC Parse_TPM2B_CONTEXT_SENSITIVE(
- std::string* buffer,
- TPM2B_CONTEXT_SENSITIVE* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_CONTEXT_SENSITIVE(std::string* buffer,
+ TPM2B_CONTEXT_SENSITIVE* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -9039,10 +7792,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->buffer[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->buffer[i], value_bytes);
if (result) {
return result;
}
@@ -9050,8 +7800,7 @@
return result;
}
-TPM2B_CONTEXT_SENSITIVE Make_TPM2B_CONTEXT_SENSITIVE(
- const std::string& bytes) {
+TPM2B_CONTEXT_SENSITIVE Make_TPM2B_CONTEXT_SENSITIVE(const std::string& bytes) {
TPM2B_CONTEXT_SENSITIVE tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.buffer));
memset(&tpm2b, 0, sizeof(TPM2B_CONTEXT_SENSITIVE));
@@ -9062,14 +7811,12 @@
std::string StringFrom_TPM2B_CONTEXT_SENSITIVE(
const TPM2B_CONTEXT_SENSITIVE& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.buffer);
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.buffer);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPMS_CONTEXT_DATA(
- const TPMS_CONTEXT_DATA& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_CONTEXT_DATA(const TPMS_CONTEXT_DATA& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -9085,34 +7832,27 @@
return result;
}
-TPM_RC Parse_TPMS_CONTEXT_DATA(
- std::string* buffer,
- TPMS_CONTEXT_DATA* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_CONTEXT_DATA(std::string* buffer,
+ TPMS_CONTEXT_DATA* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->integrity,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->integrity, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_CONTEXT_SENSITIVE(
- buffer,
- &value->encrypted,
- value_bytes);
+ result =
+ Parse_TPM2B_CONTEXT_SENSITIVE(buffer, &value->encrypted, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPM2B_CONTEXT_DATA(
- const TPM2B_CONTEXT_DATA& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_CONTEXT_DATA(const TPM2B_CONTEXT_DATA& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -9133,17 +7873,13 @@
return result;
}
-TPM_RC Parse_TPM2B_CONTEXT_DATA(
- std::string* buffer,
- TPM2B_CONTEXT_DATA* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_CONTEXT_DATA(std::string* buffer,
+ TPM2B_CONTEXT_DATA* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
@@ -9152,10 +7888,7 @@
return TPM_RC_INSUFFICIENT;
}
for (uint32_t i = 0; i < value->size; ++i) {
- result = Parse_BYTE(
- buffer,
- &value->buffer[i],
- value_bytes);
+ result = Parse_BYTE(buffer, &value->buffer[i], value_bytes);
if (result) {
return result;
}
@@ -9163,8 +7896,7 @@
return result;
}
-TPM2B_CONTEXT_DATA Make_TPM2B_CONTEXT_DATA(
- const std::string& bytes) {
+TPM2B_CONTEXT_DATA Make_TPM2B_CONTEXT_DATA(const std::string& bytes) {
TPM2B_CONTEXT_DATA tpm2b;
CHECK(bytes.size() <= sizeof(tpm2b.buffer));
memset(&tpm2b, 0, sizeof(TPM2B_CONTEXT_DATA));
@@ -9173,16 +7905,12 @@
return tpm2b;
}
-std::string StringFrom_TPM2B_CONTEXT_DATA(
- const TPM2B_CONTEXT_DATA& tpm2b) {
- const char* char_buffer = reinterpret_cast<const char*>(
- tpm2b.buffer);
+std::string StringFrom_TPM2B_CONTEXT_DATA(const TPM2B_CONTEXT_DATA& tpm2b) {
+ const char* char_buffer = reinterpret_cast<const char*>(tpm2b.buffer);
return std::string(char_buffer, tpm2b.size);
}
-TPM_RC Serialize_TPMS_CONTEXT(
- const TPMS_CONTEXT& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_CONTEXT(const TPMS_CONTEXT& value, std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -9208,50 +7936,36 @@
return result;
}
-TPM_RC Parse_TPMS_CONTEXT(
- std::string* buffer,
- TPMS_CONTEXT* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_CONTEXT(std::string* buffer,
+ TPMS_CONTEXT* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT64(
- buffer,
- &value->sequence,
- value_bytes);
+ result = Parse_UINT64(buffer, &value->sequence, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMI_DH_CONTEXT(
- buffer,
- &value->saved_handle,
- value_bytes);
+ result = Parse_TPMI_DH_CONTEXT(buffer, &value->saved_handle, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMI_RH_HIERARCHY(
- buffer,
- &value->hierarchy,
- value_bytes);
+ result = Parse_TPMI_RH_HIERARCHY(buffer, &value->hierarchy, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_CONTEXT_DATA(
- buffer,
- &value->context_blob,
- value_bytes);
+ result = Parse_TPM2B_CONTEXT_DATA(buffer, &value->context_blob, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPMS_CREATION_DATA(
- const TPMS_CREATION_DATA& value,
- std::string* buffer) {
+TPM_RC Serialize_TPMS_CREATION_DATA(const TPMS_CREATION_DATA& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -9292,74 +8006,51 @@
return result;
}
-TPM_RC Parse_TPMS_CREATION_DATA(
- std::string* buffer,
- TPMS_CREATION_DATA* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPMS_CREATION_DATA(std::string* buffer,
+ TPMS_CREATION_DATA* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_TPML_PCR_SELECTION(
- buffer,
- &value->pcr_select,
- value_bytes);
+ result = Parse_TPML_PCR_SELECTION(buffer, &value->pcr_select, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_DIGEST(
- buffer,
- &value->pcr_digest,
- value_bytes);
+ result = Parse_TPM2B_DIGEST(buffer, &value->pcr_digest, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMA_LOCALITY(
- buffer,
- &value->locality,
- value_bytes);
+ result = Parse_TPMA_LOCALITY(buffer, &value->locality, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM_ALG_ID(
- buffer,
- &value->parent_name_alg,
- value_bytes);
+ result = Parse_TPM_ALG_ID(buffer, &value->parent_name_alg, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_NAME(
- buffer,
- &value->parent_name,
- value_bytes);
+ result = Parse_TPM2B_NAME(buffer, &value->parent_name, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_NAME(
- buffer,
- &value->parent_qualified_name,
- value_bytes);
+ result = Parse_TPM2B_NAME(buffer, &value->parent_qualified_name, value_bytes);
if (result) {
return result;
}
- result = Parse_TPM2B_DATA(
- buffer,
- &value->outside_info,
- value_bytes);
+ result = Parse_TPM2B_DATA(buffer, &value->outside_info, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM_RC Serialize_TPM2B_CREATION_DATA(
- const TPM2B_CREATION_DATA& value,
- std::string* buffer) {
+TPM_RC Serialize_TPM2B_CREATION_DATA(const TPM2B_CREATION_DATA& value,
+ std::string* buffer) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
@@ -9377,33 +8068,25 @@
return result;
}
-TPM_RC Parse_TPM2B_CREATION_DATA(
- std::string* buffer,
- TPM2B_CREATION_DATA* value,
- std::string* value_bytes) {
+TPM_RC Parse_TPM2B_CREATION_DATA(std::string* buffer,
+ TPM2B_CREATION_DATA* value,
+ std::string* value_bytes) {
TPM_RC result = TPM_RC_SUCCESS;
VLOG(3) << __func__;
- result = Parse_UINT16(
- buffer,
- &value->size,
- value_bytes);
+ result = Parse_UINT16(buffer, &value->size, value_bytes);
if (result) {
return result;
}
- result = Parse_TPMS_CREATION_DATA(
- buffer,
- &value->creation_data,
- value_bytes);
+ result = Parse_TPMS_CREATION_DATA(buffer, &value->creation_data, value_bytes);
if (result) {
return result;
}
return result;
}
-TPM2B_CREATION_DATA Make_TPM2B_CREATION_DATA(
- const TPMS_CREATION_DATA& inner) {
+TPM2B_CREATION_DATA Make_TPM2B_CREATION_DATA(const TPMS_CREATION_DATA& inner) {
TPM2B_CREATION_DATA tpm2b;
tpm2b.size = sizeof(TPMS_CREATION_DATA);
tpm2b.creation_data = inner;
@@ -9411,9 +8094,9 @@
}
TPM_RC Tpm::SerializeCommand_Startup(
- const TPM_SU& startup_type,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPM_SU& startup_type,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -9424,25 +8107,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string startup_type_bytes;
- rc = Serialize_TPM_SU(
- startup_type,
- &startup_type_bytes);
+ rc = Serialize_TPM_SU(startup_type, &startup_type_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(startup_type_bytes.data(),
- startup_type_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(startup_type_bytes.data(), startup_type_bytes.size());
parameter_section_bytes += startup_type_bytes;
command_size += startup_type_bytes.size();
std::string command_hash(32, 0);
@@ -9451,10 +8128,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -9465,31 +8141,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -9497,36 +8165,27 @@
}
TPM_RC Tpm::ParseResponse_Startup(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -9538,9 +8197,7 @@
}
TPM_CC command_code = TPM_CC_Startup;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -9558,68 +8215,54 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void StartupErrorCallback(
- const Tpm::StartupResponse& callback,
- TPM_RC response_code) {
+void StartupErrorCallback(const Tpm::StartupResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void StartupResponseParser(
- const Tpm::StartupResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void StartupResponseParser(const Tpm::StartupResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(StartupErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_Startup(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_Startup(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::Startup(
- const TPM_SU& startup_type,
- AuthorizationDelegate* authorization_delegate,
- const StartupResponse& callback) {
+void Tpm::Startup(const TPM_SU& startup_type,
+ AuthorizationDelegate* authorization_delegate,
+ const StartupResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(StartupErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(StartupResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(StartupResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_Startup(
- startup_type,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_Startup(startup_type, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -9627,29 +8270,24 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::StartupSync(
- const TPM_SU& startup_type,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::StartupSync(const TPM_SU& startup_type,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_Startup(
- startup_type,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_Startup(startup_type, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_Startup(
- response,
- authorization_delegate);
+ rc = ParseResponse_Startup(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_Shutdown(
- const TPM_SU& shutdown_type,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPM_SU& shutdown_type,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -9660,25 +8298,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string shutdown_type_bytes;
- rc = Serialize_TPM_SU(
- shutdown_type,
- &shutdown_type_bytes);
+ rc = Serialize_TPM_SU(shutdown_type, &shutdown_type_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(shutdown_type_bytes.data(),
- shutdown_type_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(shutdown_type_bytes.data(), shutdown_type_bytes.size());
parameter_section_bytes += shutdown_type_bytes;
command_size += shutdown_type_bytes.size();
std::string command_hash(32, 0);
@@ -9687,10 +8319,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -9701,31 +8332,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -9733,36 +8356,27 @@
}
TPM_RC Tpm::ParseResponse_Shutdown(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -9774,9 +8388,7 @@
}
TPM_CC command_code = TPM_CC_Shutdown;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -9794,68 +8406,54 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void ShutdownErrorCallback(
- const Tpm::ShutdownResponse& callback,
- TPM_RC response_code) {
+void ShutdownErrorCallback(const Tpm::ShutdownResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void ShutdownResponseParser(
- const Tpm::ShutdownResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void ShutdownResponseParser(const Tpm::ShutdownResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ShutdownErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_Shutdown(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_Shutdown(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::Shutdown(
- const TPM_SU& shutdown_type,
- AuthorizationDelegate* authorization_delegate,
- const ShutdownResponse& callback) {
+void Tpm::Shutdown(const TPM_SU& shutdown_type,
+ AuthorizationDelegate* authorization_delegate,
+ const ShutdownResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ShutdownErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(ShutdownResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(ShutdownResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_Shutdown(
- shutdown_type,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_Shutdown(shutdown_type, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -9863,29 +8461,24 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::ShutdownSync(
- const TPM_SU& shutdown_type,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ShutdownSync(const TPM_SU& shutdown_type,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_Shutdown(
- shutdown_type,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_Shutdown(shutdown_type, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_Shutdown(
- response,
- authorization_delegate);
+ rc = ParseResponse_Shutdown(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_SelfTest(
- const TPMI_YES_NO& full_test,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_YES_NO& full_test,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -9896,25 +8489,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string full_test_bytes;
- rc = Serialize_TPMI_YES_NO(
- full_test,
- &full_test_bytes);
+ rc = Serialize_TPMI_YES_NO(full_test, &full_test_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(full_test_bytes.data(),
- full_test_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(full_test_bytes.data(), full_test_bytes.size());
parameter_section_bytes += full_test_bytes;
command_size += full_test_bytes.size();
std::string command_hash(32, 0);
@@ -9923,10 +8510,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -9937,31 +8523,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -9969,36 +8547,27 @@
}
TPM_RC Tpm::ParseResponse_SelfTest(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -10010,9 +8579,7 @@
}
TPM_CC command_code = TPM_CC_SelfTest;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -10030,68 +8597,54 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void SelfTestErrorCallback(
- const Tpm::SelfTestResponse& callback,
- TPM_RC response_code) {
+void SelfTestErrorCallback(const Tpm::SelfTestResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void SelfTestResponseParser(
- const Tpm::SelfTestResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void SelfTestResponseParser(const Tpm::SelfTestResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(SelfTestErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_SelfTest(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_SelfTest(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::SelfTest(
- const TPMI_YES_NO& full_test,
- AuthorizationDelegate* authorization_delegate,
- const SelfTestResponse& callback) {
+void Tpm::SelfTest(const TPMI_YES_NO& full_test,
+ AuthorizationDelegate* authorization_delegate,
+ const SelfTestResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(SelfTestErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(SelfTestResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(SelfTestResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_SelfTest(
- full_test,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_SelfTest(full_test, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -10099,29 +8652,24 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::SelfTestSync(
- const TPMI_YES_NO& full_test,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::SelfTestSync(const TPMI_YES_NO& full_test,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_SelfTest(
- full_test,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_SelfTest(full_test, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_SelfTest(
- response,
- authorization_delegate);
+ rc = ParseResponse_SelfTest(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_IncrementalSelfTest(
- const TPML_ALG& to_test,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPML_ALG& to_test,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -10132,25 +8680,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string to_test_bytes;
- rc = Serialize_TPML_ALG(
- to_test,
- &to_test_bytes);
+ rc = Serialize_TPML_ALG(to_test, &to_test_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(to_test_bytes.data(),
- to_test_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(to_test_bytes.data(), to_test_bytes.size());
parameter_section_bytes += to_test_bytes;
command_size += to_test_bytes.size();
std::string command_hash(32, 0);
@@ -10159,10 +8701,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -10173,31 +8714,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -10205,37 +8738,28 @@
}
TPM_RC Tpm::ParseResponse_IncrementalSelfTest(
- const std::string& response,
- TPML_ALG* to_do_list,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPML_ALG* to_do_list,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -10247,9 +8771,7 @@
}
TPM_CC command_code = TPM_CC_IncrementalSelfTest;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -10267,29 +8789,22 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string to_do_list_bytes;
- rc = Parse_TPML_ALG(
- &buffer,
- to_do_list,
- &to_do_list_bytes);
+ rc = Parse_TPML_ALG(&buffer, to_do_list, &to_do_list_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -10300,8 +8815,7 @@
const Tpm::IncrementalSelfTestResponse& callback,
TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPML_ALG());
+ callback.Run(response_code, TPML_ALG());
}
void IncrementalSelfTestResponseParser(
@@ -10312,35 +8826,26 @@
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(IncrementalSelfTestErrorCallback, callback);
TPML_ALG to_do_list;
- TPM_RC rc = Tpm::ParseResponse_IncrementalSelfTest(
- response,
- &to_do_list,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_IncrementalSelfTest(response, &to_do_list,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- to_do_list);
+ callback.Run(rc, to_do_list);
}
-void Tpm::IncrementalSelfTest(
- const TPML_ALG& to_test,
- AuthorizationDelegate* authorization_delegate,
- const IncrementalSelfTestResponse& callback) {
+void Tpm::IncrementalSelfTest(const TPML_ALG& to_test,
+ AuthorizationDelegate* authorization_delegate,
+ const IncrementalSelfTestResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(IncrementalSelfTestErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(IncrementalSelfTestResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ IncrementalSelfTestResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_IncrementalSelfTest(
- to_test,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_IncrementalSelfTest(to_test, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -10349,29 +8854,25 @@
}
TPM_RC Tpm::IncrementalSelfTestSync(
- const TPML_ALG& to_test,
- TPML_ALG* to_do_list,
- AuthorizationDelegate* authorization_delegate) {
+ const TPML_ALG& to_test,
+ TPML_ALG* to_do_list,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_IncrementalSelfTest(
- to_test,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_IncrementalSelfTest(to_test, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_IncrementalSelfTest(
- response,
- to_do_list,
- authorization_delegate);
+ rc = ParseResponse_IncrementalSelfTest(response, to_do_list,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_GetTestResult(
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -10382,26 +8883,22 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
std::string command_hash(32, 0);
hash->Finish(string_as_array(&command_hash), command_hash.size());
std::string authorization_section_bytes;
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -10412,31 +8909,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -10444,38 +8933,29 @@
}
TPM_RC Tpm::ParseResponse_GetTestResult(
- const std::string& response,
- TPM2B_MAX_BUFFER* out_data,
- TPM_RC* test_result,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_MAX_BUFFER* out_data,
+ TPM_RC* test_result,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -10487,9 +8967,7 @@
}
TPM_CC command_code = TPM_CC_GetTestResult;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -10507,37 +8985,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string out_data_bytes;
- rc = Parse_TPM2B_MAX_BUFFER(
- &buffer,
- out_data,
- &out_data_bytes);
+ rc = Parse_TPM2B_MAX_BUFFER(&buffer, out_data, &out_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string test_result_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- test_result,
- &test_result_bytes);
+ rc = Parse_TPM_RC(&buffer, test_result, &test_result_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -10549,10 +9017,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
out_data_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_MAX_BUFFER(
- &out_data_bytes,
- out_data,
- nullptr);
+ rc = Parse_TPM2B_MAX_BUFFER(&out_data_bytes, out_data, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -10560,53 +9025,38 @@
return TPM_RC_SUCCESS;
}
-void GetTestResultErrorCallback(
- const Tpm::GetTestResultResponse& callback,
- TPM_RC response_code) {
+void GetTestResultErrorCallback(const Tpm::GetTestResultResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_MAX_BUFFER(),
- TPM_RC());
+ callback.Run(response_code, TPM2B_MAX_BUFFER(), TPM_RC());
}
-void GetTestResultResponseParser(
- const Tpm::GetTestResultResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void GetTestResultResponseParser(const Tpm::GetTestResultResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(GetTestResultErrorCallback, callback);
TPM2B_MAX_BUFFER out_data;
TPM_RC test_result;
TPM_RC rc = Tpm::ParseResponse_GetTestResult(
- response,
- &out_data,
- &test_result,
- authorization_delegate);
+ response, &out_data, &test_result, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- out_data,
- test_result);
+ callback.Run(rc, out_data, test_result);
}
-void Tpm::GetTestResult(
- AuthorizationDelegate* authorization_delegate,
- const GetTestResultResponse& callback) {
+void Tpm::GetTestResult(AuthorizationDelegate* authorization_delegate,
+ const GetTestResultResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(GetTestResultErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(GetTestResultResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(GetTestResultResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_GetTestResult(
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_GetTestResult(&command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -10614,39 +9064,33 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::GetTestResultSync(
- TPM2B_MAX_BUFFER* out_data,
- TPM_RC* test_result,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::GetTestResultSync(TPM2B_MAX_BUFFER* out_data,
+ TPM_RC* test_result,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_GetTestResult(
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_GetTestResult(&command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_GetTestResult(
- response,
- out_data,
- test_result,
- authorization_delegate);
+ rc = ParseResponse_GetTestResult(response, out_data, test_result,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_StartAuthSession(
- const TPMI_DH_OBJECT& tpm_key,
- const std::string& tpm_key_name,
- const TPMI_DH_ENTITY& bind,
- const std::string& bind_name,
- const TPM2B_NONCE& nonce_caller,
- const TPM2B_ENCRYPTED_SECRET& encrypted_salt,
- const TPM_SE& session_type,
- const TPMT_SYM_DEF& symmetric,
- const TPMI_ALG_HASH& auth_hash,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& tpm_key,
+ const std::string& tpm_key_name,
+ const TPMI_DH_ENTITY& bind,
+ const std::string& bind_name,
+ const TPM2B_NONCE& nonce_caller,
+ const TPM2B_ENCRYPTED_SECRET& encrypted_salt,
+ const TPM_SE& session_type,
+ const TPMT_SYM_DEF& symmetric,
+ const TPMI_ALG_HASH& auth_hash,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -10657,58 +9101,42 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string tpm_key_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- tpm_key,
- &tpm_key_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(tpm_key, &tpm_key_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string bind_bytes;
- rc = Serialize_TPMI_DH_ENTITY(
- bind,
- &bind_bytes);
+ rc = Serialize_TPMI_DH_ENTITY(bind, &bind_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string nonce_caller_bytes;
- rc = Serialize_TPM2B_NONCE(
- nonce_caller,
- &nonce_caller_bytes);
+ rc = Serialize_TPM2B_NONCE(nonce_caller, &nonce_caller_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string encrypted_salt_bytes;
- rc = Serialize_TPM2B_ENCRYPTED_SECRET(
- encrypted_salt,
- &encrypted_salt_bytes);
+ rc = Serialize_TPM2B_ENCRYPTED_SECRET(encrypted_salt, &encrypted_salt_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string session_type_bytes;
- rc = Serialize_TPM_SE(
- session_type,
- &session_type_bytes);
+ rc = Serialize_TPM_SE(session_type, &session_type_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string symmetric_bytes;
- rc = Serialize_TPMT_SYM_DEF(
- symmetric,
- &symmetric_bytes);
+ rc = Serialize_TPMT_SYM_DEF(symmetric, &symmetric_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_hash_bytes;
- rc = Serialize_TPMI_ALG_HASH(
- auth_hash,
- &auth_hash_bytes);
+ rc = Serialize_TPMI_ALG_HASH(auth_hash, &auth_hash_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -10720,36 +9148,28 @@
}
nonce_caller_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(tpm_key_name.data(),
- tpm_key_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(tpm_key_name.data(), tpm_key_name.size());
handle_section_bytes += tpm_key_bytes;
command_size += tpm_key_bytes.size();
- hash->Update(bind_name.data(),
- bind_name.size());
+ hash->Update(bind_name.data(), bind_name.size());
handle_section_bytes += bind_bytes;
command_size += bind_bytes.size();
- hash->Update(nonce_caller_bytes.data(),
- nonce_caller_bytes.size());
+ hash->Update(nonce_caller_bytes.data(), nonce_caller_bytes.size());
parameter_section_bytes += nonce_caller_bytes;
command_size += nonce_caller_bytes.size();
- hash->Update(encrypted_salt_bytes.data(),
- encrypted_salt_bytes.size());
+ hash->Update(encrypted_salt_bytes.data(), encrypted_salt_bytes.size());
parameter_section_bytes += encrypted_salt_bytes;
command_size += encrypted_salt_bytes.size();
- hash->Update(session_type_bytes.data(),
- session_type_bytes.size());
+ hash->Update(session_type_bytes.data(), session_type_bytes.size());
parameter_section_bytes += session_type_bytes;
command_size += session_type_bytes.size();
- hash->Update(symmetric_bytes.data(),
- symmetric_bytes.size());
+ hash->Update(symmetric_bytes.data(), symmetric_bytes.size());
parameter_section_bytes += symmetric_bytes;
command_size += symmetric_bytes.size();
- hash->Update(auth_hash_bytes.data(),
- auth_hash_bytes.size());
+ hash->Update(auth_hash_bytes.data(), auth_hash_bytes.size());
parameter_section_bytes += auth_hash_bytes;
command_size += auth_hash_bytes.size();
std::string command_hash(32, 0);
@@ -10758,10 +9178,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -10772,31 +9191,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -10804,38 +9215,29 @@
}
TPM_RC Tpm::ParseResponse_StartAuthSession(
- const std::string& response,
- TPMI_SH_AUTH_SESSION* session_handle,
- TPM2B_NONCE* nonce_tpm,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPMI_SH_AUTH_SESSION* session_handle,
+ TPM2B_NONCE* nonce_tpm,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -10846,18 +9248,14 @@
return response_code;
}
std::string session_handle_bytes;
- rc = Parse_TPMI_SH_AUTH_SESSION(
- &buffer,
- session_handle,
- &session_handle_bytes);
+ rc = Parse_TPMI_SH_AUTH_SESSION(&buffer, session_handle,
+ &session_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_CC command_code = TPM_CC_StartAuthSession;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -10875,29 +9273,22 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string nonce_tpm_bytes;
- rc = Parse_TPM2B_NONCE(
- &buffer,
- nonce_tpm,
- &nonce_tpm_bytes);
+ rc = Parse_TPM2B_NONCE(&buffer, nonce_tpm, &nonce_tpm_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -10909,10 +9300,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
nonce_tpm_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_NONCE(
- &nonce_tpm_bytes,
- nonce_tpm,
- nullptr);
+ rc = Parse_TPM2B_NONCE(&nonce_tpm_bytes, nonce_tpm, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -10924,9 +9312,7 @@
const Tpm::StartAuthSessionResponse& callback,
TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPMI_SH_AUTH_SESSION(),
- TPM2B_NONCE());
+ callback.Run(response_code, TPMI_SH_AUTH_SESSION(), TPM2B_NONCE());
}
void StartAuthSessionResponseParser(
@@ -10939,52 +9325,34 @@
TPMI_SH_AUTH_SESSION session_handle;
TPM2B_NONCE nonce_tpm;
TPM_RC rc = Tpm::ParseResponse_StartAuthSession(
- response,
- &session_handle,
- &nonce_tpm,
- authorization_delegate);
+ response, &session_handle, &nonce_tpm, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- session_handle,
- nonce_tpm);
+ callback.Run(rc, session_handle, nonce_tpm);
}
-void Tpm::StartAuthSession(
- const TPMI_DH_OBJECT& tpm_key,
- const std::string& tpm_key_name,
- const TPMI_DH_ENTITY& bind,
- const std::string& bind_name,
- const TPM2B_NONCE& nonce_caller,
- const TPM2B_ENCRYPTED_SECRET& encrypted_salt,
- const TPM_SE& session_type,
- const TPMT_SYM_DEF& symmetric,
- const TPMI_ALG_HASH& auth_hash,
- AuthorizationDelegate* authorization_delegate,
- const StartAuthSessionResponse& callback) {
+void Tpm::StartAuthSession(const TPMI_DH_OBJECT& tpm_key,
+ const std::string& tpm_key_name,
+ const TPMI_DH_ENTITY& bind,
+ const std::string& bind_name,
+ const TPM2B_NONCE& nonce_caller,
+ const TPM2B_ENCRYPTED_SECRET& encrypted_salt,
+ const TPM_SE& session_type,
+ const TPMT_SYM_DEF& symmetric,
+ const TPMI_ALG_HASH& auth_hash,
+ AuthorizationDelegate* authorization_delegate,
+ const StartAuthSessionResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(StartAuthSessionErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(StartAuthSessionResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ StartAuthSessionResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_StartAuthSession(
- tpm_key,
- tpm_key_name,
- bind,
- bind_name,
- nonce_caller,
- encrypted_salt,
- session_type,
- symmetric,
- auth_hash,
- &command,
- authorization_delegate);
+ tpm_key, tpm_key_name, bind, bind_name, nonce_caller, encrypted_salt,
+ session_type, symmetric, auth_hash, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -10993,49 +9361,37 @@
}
TPM_RC Tpm::StartAuthSessionSync(
- const TPMI_DH_OBJECT& tpm_key,
- const std::string& tpm_key_name,
- const TPMI_DH_ENTITY& bind,
- const std::string& bind_name,
- const TPM2B_NONCE& nonce_caller,
- const TPM2B_ENCRYPTED_SECRET& encrypted_salt,
- const TPM_SE& session_type,
- const TPMT_SYM_DEF& symmetric,
- const TPMI_ALG_HASH& auth_hash,
- TPMI_SH_AUTH_SESSION* session_handle,
- TPM2B_NONCE* nonce_tpm,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& tpm_key,
+ const std::string& tpm_key_name,
+ const TPMI_DH_ENTITY& bind,
+ const std::string& bind_name,
+ const TPM2B_NONCE& nonce_caller,
+ const TPM2B_ENCRYPTED_SECRET& encrypted_salt,
+ const TPM_SE& session_type,
+ const TPMT_SYM_DEF& symmetric,
+ const TPMI_ALG_HASH& auth_hash,
+ TPMI_SH_AUTH_SESSION* session_handle,
+ TPM2B_NONCE* nonce_tpm,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_StartAuthSession(
- tpm_key,
- tpm_key_name,
- bind,
- bind_name,
- nonce_caller,
- encrypted_salt,
- session_type,
- symmetric,
- auth_hash,
- &command,
- authorization_delegate);
+ tpm_key, tpm_key_name, bind, bind_name, nonce_caller, encrypted_salt,
+ session_type, symmetric, auth_hash, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_StartAuthSession(
- response,
- session_handle,
- nonce_tpm,
- authorization_delegate);
+ rc = ParseResponse_StartAuthSession(response, session_handle, nonce_tpm,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicyRestart(
- const TPMI_SH_POLICY& session_handle,
- const std::string& session_handle_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& session_handle,
+ const std::string& session_handle_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -11046,25 +9402,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string session_handle_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- session_handle,
- &session_handle_bytes);
+ rc = Serialize_TPMI_SH_POLICY(session_handle, &session_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(session_handle_name.data(),
- session_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(session_handle_name.data(), session_handle_name.size());
handle_section_bytes += session_handle_bytes;
command_size += session_handle_bytes.size();
std::string command_hash(32, 0);
@@ -11073,10 +9423,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -11087,31 +9436,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -11119,36 +9460,27 @@
}
TPM_RC Tpm::ParseResponse_PolicyRestart(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -11160,9 +9492,7 @@
}
TPM_CC command_code = TPM_CC_PolicyRestart;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -11180,70 +9510,56 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void PolicyRestartErrorCallback(
- const Tpm::PolicyRestartResponse& callback,
- TPM_RC response_code) {
+void PolicyRestartErrorCallback(const Tpm::PolicyRestartResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void PolicyRestartResponseParser(
- const Tpm::PolicyRestartResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void PolicyRestartResponseParser(const Tpm::PolicyRestartResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyRestartErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PolicyRestart(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_PolicyRestart(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PolicyRestart(
- const TPMI_SH_POLICY& session_handle,
- const std::string& session_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const PolicyRestartResponse& callback) {
+void Tpm::PolicyRestart(const TPMI_SH_POLICY& session_handle,
+ const std::string& session_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyRestartResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyRestartErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(PolicyRestartResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(PolicyRestartResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_PolicyRestart(
- session_handle,
- session_handle_name,
- &command,
- authorization_delegate);
+ session_handle, session_handle_name, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -11251,36 +9567,30 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PolicyRestartSync(
- const TPMI_SH_POLICY& session_handle,
- const std::string& session_handle_name,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PolicyRestartSync(const TPMI_SH_POLICY& session_handle,
+ const std::string& session_handle_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_PolicyRestart(
- session_handle,
- session_handle_name,
- &command,
- authorization_delegate);
+ session_handle, session_handle_name, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicyRestart(
- response,
- authorization_delegate);
+ rc = ParseResponse_PolicyRestart(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_Create(
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_SENSITIVE_CREATE& in_sensitive,
- const TPM2B_PUBLIC& in_public,
- const TPM2B_DATA& outside_info,
- const TPML_PCR_SELECTION& creation_pcr,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_SENSITIVE_CREATE& in_sensitive,
+ const TPM2B_PUBLIC& in_public,
+ const TPM2B_DATA& outside_info,
+ const TPML_PCR_SELECTION& creation_pcr,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -11291,44 +9601,32 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string parent_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- parent_handle,
- &parent_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(parent_handle, &parent_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_sensitive_bytes;
- rc = Serialize_TPM2B_SENSITIVE_CREATE(
- in_sensitive,
- &in_sensitive_bytes);
+ rc = Serialize_TPM2B_SENSITIVE_CREATE(in_sensitive, &in_sensitive_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_public_bytes;
- rc = Serialize_TPM2B_PUBLIC(
- in_public,
- &in_public_bytes);
+ rc = Serialize_TPM2B_PUBLIC(in_public, &in_public_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string outside_info_bytes;
- rc = Serialize_TPM2B_DATA(
- outside_info,
- &outside_info_bytes);
+ rc = Serialize_TPM2B_DATA(outside_info, &outside_info_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string creation_pcr_bytes;
- rc = Serialize_TPML_PCR_SELECTION(
- creation_pcr,
- &creation_pcr_bytes);
+ rc = Serialize_TPML_PCR_SELECTION(creation_pcr, &creation_pcr_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -11340,28 +9638,22 @@
}
in_sensitive_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(parent_handle_name.data(),
- parent_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(parent_handle_name.data(), parent_handle_name.size());
handle_section_bytes += parent_handle_bytes;
command_size += parent_handle_bytes.size();
- hash->Update(in_sensitive_bytes.data(),
- in_sensitive_bytes.size());
+ hash->Update(in_sensitive_bytes.data(), in_sensitive_bytes.size());
parameter_section_bytes += in_sensitive_bytes;
command_size += in_sensitive_bytes.size();
- hash->Update(in_public_bytes.data(),
- in_public_bytes.size());
+ hash->Update(in_public_bytes.data(), in_public_bytes.size());
parameter_section_bytes += in_public_bytes;
command_size += in_public_bytes.size();
- hash->Update(outside_info_bytes.data(),
- outside_info_bytes.size());
+ hash->Update(outside_info_bytes.data(), outside_info_bytes.size());
parameter_section_bytes += outside_info_bytes;
command_size += outside_info_bytes.size();
- hash->Update(creation_pcr_bytes.data(),
- creation_pcr_bytes.size());
+ hash->Update(creation_pcr_bytes.data(), creation_pcr_bytes.size());
parameter_section_bytes += creation_pcr_bytes;
command_size += creation_pcr_bytes.size();
std::string command_hash(32, 0);
@@ -11370,10 +9662,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -11384,31 +9675,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -11416,41 +9699,32 @@
}
TPM_RC Tpm::ParseResponse_Create(
- const std::string& response,
- TPM2B_PRIVATE* out_private,
- TPM2B_PUBLIC* out_public,
- TPM2B_CREATION_DATA* creation_data,
- TPM2B_DIGEST* creation_hash,
- TPMT_TK_CREATION* creation_ticket,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_PRIVATE* out_private,
+ TPM2B_PUBLIC* out_public,
+ TPM2B_CREATION_DATA* creation_data,
+ TPM2B_DIGEST* creation_hash,
+ TPMT_TK_CREATION* creation_ticket,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -11462,9 +9736,7 @@
}
TPM_CC command_code = TPM_CC_Create;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -11482,61 +9754,42 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string out_private_bytes;
- rc = Parse_TPM2B_PRIVATE(
- &buffer,
- out_private,
- &out_private_bytes);
+ rc = Parse_TPM2B_PRIVATE(&buffer, out_private, &out_private_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string out_public_bytes;
- rc = Parse_TPM2B_PUBLIC(
- &buffer,
- out_public,
- &out_public_bytes);
+ rc = Parse_TPM2B_PUBLIC(&buffer, out_public, &out_public_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string creation_data_bytes;
- rc = Parse_TPM2B_CREATION_DATA(
- &buffer,
- creation_data,
- &creation_data_bytes);
+ rc = Parse_TPM2B_CREATION_DATA(&buffer, creation_data, &creation_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string creation_hash_bytes;
- rc = Parse_TPM2B_DIGEST(
- &buffer,
- creation_hash,
- &creation_hash_bytes);
+ rc = Parse_TPM2B_DIGEST(&buffer, creation_hash, &creation_hash_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string creation_ticket_bytes;
- rc = Parse_TPMT_TK_CREATION(
- &buffer,
- creation_ticket,
- &creation_ticket_bytes);
+ rc = Parse_TPMT_TK_CREATION(&buffer, creation_ticket, &creation_ticket_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -11548,10 +9801,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
out_private_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_PRIVATE(
- &out_private_bytes,
- out_private,
- nullptr);
+ rc = Parse_TPM2B_PRIVATE(&out_private_bytes, out_private, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -11559,22 +9809,16 @@
return TPM_RC_SUCCESS;
}
-void CreateErrorCallback(
- const Tpm::CreateResponse& callback,
- TPM_RC response_code) {
+void CreateErrorCallback(const Tpm::CreateResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_PRIVATE(),
- TPM2B_PUBLIC(),
- TPM2B_CREATION_DATA(),
- TPM2B_DIGEST(),
- TPMT_TK_CREATION());
+ callback.Run(response_code, TPM2B_PRIVATE(), TPM2B_PUBLIC(),
+ TPM2B_CREATION_DATA(), TPM2B_DIGEST(), TPMT_TK_CREATION());
}
-void CreateResponseParser(
- const Tpm::CreateResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void CreateResponseParser(const Tpm::CreateResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(CreateErrorCallback, callback);
@@ -11584,52 +9828,33 @@
TPM2B_DIGEST creation_hash;
TPMT_TK_CREATION creation_ticket;
TPM_RC rc = Tpm::ParseResponse_Create(
- response,
- &out_private,
- &out_public,
- &creation_data,
- &creation_hash,
- &creation_ticket,
- authorization_delegate);
+ response, &out_private, &out_public, &creation_data, &creation_hash,
+ &creation_ticket, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- out_private,
- out_public,
- creation_data,
- creation_hash,
- creation_ticket);
+ callback.Run(rc, out_private, out_public, creation_data, creation_hash,
+ creation_ticket);
}
-void Tpm::Create(
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_SENSITIVE_CREATE& in_sensitive,
- const TPM2B_PUBLIC& in_public,
- const TPM2B_DATA& outside_info,
- const TPML_PCR_SELECTION& creation_pcr,
- AuthorizationDelegate* authorization_delegate,
- const CreateResponse& callback) {
+void Tpm::Create(const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_SENSITIVE_CREATE& in_sensitive,
+ const TPM2B_PUBLIC& in_public,
+ const TPM2B_DATA& outside_info,
+ const TPML_PCR_SELECTION& creation_pcr,
+ AuthorizationDelegate* authorization_delegate,
+ const CreateResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(CreateErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(CreateResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(CreateResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_Create(
- parent_handle,
- parent_handle_name,
- in_sensitive,
- in_public,
- outside_info,
- creation_pcr,
- &command,
- authorization_delegate);
+ parent_handle, parent_handle_name, in_sensitive, in_public, outside_info,
+ creation_pcr, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -11637,52 +9862,40 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::CreateSync(
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_SENSITIVE_CREATE& in_sensitive,
- const TPM2B_PUBLIC& in_public,
- const TPM2B_DATA& outside_info,
- const TPML_PCR_SELECTION& creation_pcr,
- TPM2B_PRIVATE* out_private,
- TPM2B_PUBLIC* out_public,
- TPM2B_CREATION_DATA* creation_data,
- TPM2B_DIGEST* creation_hash,
- TPMT_TK_CREATION* creation_ticket,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::CreateSync(const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_SENSITIVE_CREATE& in_sensitive,
+ const TPM2B_PUBLIC& in_public,
+ const TPM2B_DATA& outside_info,
+ const TPML_PCR_SELECTION& creation_pcr,
+ TPM2B_PRIVATE* out_private,
+ TPM2B_PUBLIC* out_public,
+ TPM2B_CREATION_DATA* creation_data,
+ TPM2B_DIGEST* creation_hash,
+ TPMT_TK_CREATION* creation_ticket,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_Create(
- parent_handle,
- parent_handle_name,
- in_sensitive,
- in_public,
- outside_info,
- creation_pcr,
- &command,
- authorization_delegate);
+ parent_handle, parent_handle_name, in_sensitive, in_public, outside_info,
+ creation_pcr, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_Create(
- response,
- out_private,
- out_public,
- creation_data,
- creation_hash,
- creation_ticket,
- authorization_delegate);
+ rc = ParseResponse_Create(response, out_private, out_public, creation_data,
+ creation_hash, creation_ticket,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_Load(
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_PRIVATE& in_private,
- const TPM2B_PUBLIC& in_public,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_PRIVATE& in_private,
+ const TPM2B_PUBLIC& in_public,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -11693,30 +9906,22 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string parent_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- parent_handle,
- &parent_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(parent_handle, &parent_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_private_bytes;
- rc = Serialize_TPM2B_PRIVATE(
- in_private,
- &in_private_bytes);
+ rc = Serialize_TPM2B_PRIVATE(in_private, &in_private_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_public_bytes;
- rc = Serialize_TPM2B_PUBLIC(
- in_public,
- &in_public_bytes);
+ rc = Serialize_TPM2B_PUBLIC(in_public, &in_public_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -11728,20 +9933,16 @@
}
in_private_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(parent_handle_name.data(),
- parent_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(parent_handle_name.data(), parent_handle_name.size());
handle_section_bytes += parent_handle_bytes;
command_size += parent_handle_bytes.size();
- hash->Update(in_private_bytes.data(),
- in_private_bytes.size());
+ hash->Update(in_private_bytes.data(), in_private_bytes.size());
parameter_section_bytes += in_private_bytes;
command_size += in_private_bytes.size();
- hash->Update(in_public_bytes.data(),
- in_public_bytes.size());
+ hash->Update(in_public_bytes.data(), in_public_bytes.size());
parameter_section_bytes += in_public_bytes;
command_size += in_public_bytes.size();
std::string command_hash(32, 0);
@@ -11750,10 +9951,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -11764,70 +9964,52 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
return TPM_RC_SUCCESS;
}
-TPM_RC Tpm::ParseResponse_Load(
- const std::string& response,
- TPM_HANDLE* object_handle,
- TPM2B_NAME* name,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ParseResponse_Load(const std::string& response,
+ TPM_HANDLE* object_handle,
+ TPM2B_NAME* name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -11838,18 +10020,13 @@
return response_code;
}
std::string object_handle_bytes;
- rc = Parse_TPM_HANDLE(
- &buffer,
- object_handle,
- &object_handle_bytes);
+ rc = Parse_TPM_HANDLE(&buffer, object_handle, &object_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_CC command_code = TPM_CC_Load;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -11867,29 +10044,22 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string name_bytes;
- rc = Parse_TPM2B_NAME(
- &buffer,
- name,
- &name_bytes);
+ rc = Parse_TPM2B_NAME(&buffer, name, &name_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -11901,10 +10071,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
name_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_NAME(
- &name_bytes,
- name,
- nullptr);
+ rc = Parse_TPM2B_NAME(&name_bytes, name, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -11912,61 +10079,44 @@
return TPM_RC_SUCCESS;
}
-void LoadErrorCallback(
- const Tpm::LoadResponse& callback,
- TPM_RC response_code) {
+void LoadErrorCallback(const Tpm::LoadResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM_HANDLE(),
- TPM2B_NAME());
+ callback.Run(response_code, TPM_HANDLE(), TPM2B_NAME());
}
-void LoadResponseParser(
- const Tpm::LoadResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void LoadResponseParser(const Tpm::LoadResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(LoadErrorCallback, callback);
TPM_HANDLE object_handle;
TPM2B_NAME name;
- TPM_RC rc = Tpm::ParseResponse_Load(
- response,
- &object_handle,
- &name,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_Load(response, &object_handle, &name,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- object_handle,
- name);
+ callback.Run(rc, object_handle, name);
}
-void Tpm::Load(
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_PRIVATE& in_private,
- const TPM2B_PUBLIC& in_public,
- AuthorizationDelegate* authorization_delegate,
- const LoadResponse& callback) {
+void Tpm::Load(const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_PRIVATE& in_private,
+ const TPM2B_PUBLIC& in_public,
+ AuthorizationDelegate* authorization_delegate,
+ const LoadResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(LoadErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(LoadResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(LoadResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_Load(
- parent_handle,
- parent_handle_name,
- in_private,
- in_public,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_Load(parent_handle, parent_handle_name, in_private,
+ in_public, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -11974,41 +10124,33 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::LoadSync(
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_PRIVATE& in_private,
- const TPM2B_PUBLIC& in_public,
- TPM_HANDLE* object_handle,
- TPM2B_NAME* name,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::LoadSync(const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_PRIVATE& in_private,
+ const TPM2B_PUBLIC& in_public,
+ TPM_HANDLE* object_handle,
+ TPM2B_NAME* name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_Load(
- parent_handle,
- parent_handle_name,
- in_private,
- in_public,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_Load(parent_handle, parent_handle_name, in_private,
+ in_public, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_Load(
- response,
- object_handle,
- name,
- authorization_delegate);
+ rc =
+ ParseResponse_Load(response, object_handle, name, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_LoadExternal(
- const TPM2B_SENSITIVE& in_private,
- const TPM2B_PUBLIC& in_public,
- const TPMI_RH_HIERARCHY& hierarchy,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPM2B_SENSITIVE& in_private,
+ const TPM2B_PUBLIC& in_public,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -12019,30 +10161,22 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_private_bytes;
- rc = Serialize_TPM2B_SENSITIVE(
- in_private,
- &in_private_bytes);
+ rc = Serialize_TPM2B_SENSITIVE(in_private, &in_private_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_public_bytes;
- rc = Serialize_TPM2B_PUBLIC(
- in_public,
- &in_public_bytes);
+ rc = Serialize_TPM2B_PUBLIC(in_public, &in_public_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string hierarchy_bytes;
- rc = Serialize_TPMI_RH_HIERARCHY(
- hierarchy,
- &hierarchy_bytes);
+ rc = Serialize_TPMI_RH_HIERARCHY(hierarchy, &hierarchy_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -12054,20 +10188,16 @@
}
in_private_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(in_private_bytes.data(),
- in_private_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(in_private_bytes.data(), in_private_bytes.size());
parameter_section_bytes += in_private_bytes;
command_size += in_private_bytes.size();
- hash->Update(in_public_bytes.data(),
- in_public_bytes.size());
+ hash->Update(in_public_bytes.data(), in_public_bytes.size());
parameter_section_bytes += in_public_bytes;
command_size += in_public_bytes.size();
- hash->Update(hierarchy_bytes.data(),
- hierarchy_bytes.size());
+ hash->Update(hierarchy_bytes.data(), hierarchy_bytes.size());
parameter_section_bytes += hierarchy_bytes;
command_size += hierarchy_bytes.size();
std::string command_hash(32, 0);
@@ -12076,10 +10206,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -12090,31 +10219,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -12122,38 +10243,29 @@
}
TPM_RC Tpm::ParseResponse_LoadExternal(
- const std::string& response,
- TPM_HANDLE* object_handle,
- TPM2B_NAME* name,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM_HANDLE* object_handle,
+ TPM2B_NAME* name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -12164,18 +10276,13 @@
return response_code;
}
std::string object_handle_bytes;
- rc = Parse_TPM_HANDLE(
- &buffer,
- object_handle,
- &object_handle_bytes);
+ rc = Parse_TPM_HANDLE(&buffer, object_handle, &object_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_CC command_code = TPM_CC_LoadExternal;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -12193,29 +10300,22 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string name_bytes;
- rc = Parse_TPM2B_NAME(
- &buffer,
- name,
- &name_bytes);
+ rc = Parse_TPM2B_NAME(&buffer, name, &name_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -12227,10 +10327,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
name_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_NAME(
- &name_bytes,
- name,
- nullptr);
+ rc = Parse_TPM2B_NAME(&name_bytes, name, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -12238,59 +10335,42 @@
return TPM_RC_SUCCESS;
}
-void LoadExternalErrorCallback(
- const Tpm::LoadExternalResponse& callback,
- TPM_RC response_code) {
+void LoadExternalErrorCallback(const Tpm::LoadExternalResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM_HANDLE(),
- TPM2B_NAME());
+ callback.Run(response_code, TPM_HANDLE(), TPM2B_NAME());
}
-void LoadExternalResponseParser(
- const Tpm::LoadExternalResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void LoadExternalResponseParser(const Tpm::LoadExternalResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(LoadExternalErrorCallback, callback);
TPM_HANDLE object_handle;
TPM2B_NAME name;
- TPM_RC rc = Tpm::ParseResponse_LoadExternal(
- response,
- &object_handle,
- &name,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_LoadExternal(response, &object_handle, &name,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- object_handle,
- name);
+ callback.Run(rc, object_handle, name);
}
-void Tpm::LoadExternal(
- const TPM2B_SENSITIVE& in_private,
- const TPM2B_PUBLIC& in_public,
- const TPMI_RH_HIERARCHY& hierarchy,
- AuthorizationDelegate* authorization_delegate,
- const LoadExternalResponse& callback) {
+void Tpm::LoadExternal(const TPM2B_SENSITIVE& in_private,
+ const TPM2B_PUBLIC& in_public,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ AuthorizationDelegate* authorization_delegate,
+ const LoadExternalResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(LoadExternalErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(LoadExternalResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(LoadExternalResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_LoadExternal(
- in_private,
- in_public,
- hierarchy,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_LoadExternal(in_private, in_public, hierarchy,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -12298,38 +10378,30 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::LoadExternalSync(
- const TPM2B_SENSITIVE& in_private,
- const TPM2B_PUBLIC& in_public,
- const TPMI_RH_HIERARCHY& hierarchy,
- TPM_HANDLE* object_handle,
- TPM2B_NAME* name,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::LoadExternalSync(const TPM2B_SENSITIVE& in_private,
+ const TPM2B_PUBLIC& in_public,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ TPM_HANDLE* object_handle,
+ TPM2B_NAME* name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_LoadExternal(
- in_private,
- in_public,
- hierarchy,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_LoadExternal(in_private, in_public, hierarchy,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_LoadExternal(
- response,
- object_handle,
- name,
- authorization_delegate);
+ rc = ParseResponse_LoadExternal(response, object_handle, name,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_ReadPublic(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -12340,25 +10412,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string object_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- object_handle,
- &object_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(object_handle, &object_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(object_handle_name.data(),
- object_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(object_handle_name.data(), object_handle_name.size());
handle_section_bytes += object_handle_bytes;
command_size += object_handle_bytes.size();
std::string command_hash(32, 0);
@@ -12367,10 +10433,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -12381,31 +10446,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -12413,39 +10470,30 @@
}
TPM_RC Tpm::ParseResponse_ReadPublic(
- const std::string& response,
- TPM2B_PUBLIC* out_public,
- TPM2B_NAME* name,
- TPM2B_NAME* qualified_name,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_PUBLIC* out_public,
+ TPM2B_NAME* name,
+ TPM2B_NAME* qualified_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -12457,9 +10505,7 @@
}
TPM_CC command_code = TPM_CC_ReadPublic;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -12477,45 +10523,32 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string out_public_bytes;
- rc = Parse_TPM2B_PUBLIC(
- &buffer,
- out_public,
- &out_public_bytes);
+ rc = Parse_TPM2B_PUBLIC(&buffer, out_public, &out_public_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string name_bytes;
- rc = Parse_TPM2B_NAME(
- &buffer,
- name,
- &name_bytes);
+ rc = Parse_TPM2B_NAME(&buffer, name, &name_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string qualified_name_bytes;
- rc = Parse_TPM2B_NAME(
- &buffer,
- qualified_name,
- &qualified_name_bytes);
+ rc = Parse_TPM2B_NAME(&buffer, qualified_name, &qualified_name_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -12527,10 +10560,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
out_public_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_PUBLIC(
- &out_public_bytes,
- out_public,
- nullptr);
+ rc = Parse_TPM2B_PUBLIC(&out_public_bytes, out_public, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -12538,20 +10568,15 @@
return TPM_RC_SUCCESS;
}
-void ReadPublicErrorCallback(
- const Tpm::ReadPublicResponse& callback,
- TPM_RC response_code) {
+void ReadPublicErrorCallback(const Tpm::ReadPublicResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_PUBLIC(),
- TPM2B_NAME(),
- TPM2B_NAME());
+ callback.Run(response_code, TPM2B_PUBLIC(), TPM2B_NAME(), TPM2B_NAME());
}
-void ReadPublicResponseParser(
- const Tpm::ReadPublicResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void ReadPublicResponseParser(const Tpm::ReadPublicResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ReadPublicErrorCallback, callback);
@@ -12559,40 +10584,26 @@
TPM2B_NAME name;
TPM2B_NAME qualified_name;
TPM_RC rc = Tpm::ParseResponse_ReadPublic(
- response,
- &out_public,
- &name,
- &qualified_name,
- authorization_delegate);
+ response, &out_public, &name, &qualified_name, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- out_public,
- name,
- qualified_name);
+ callback.Run(rc, out_public, name, qualified_name);
}
-void Tpm::ReadPublic(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const ReadPublicResponse& callback) {
+void Tpm::ReadPublic(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const ReadPublicResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ReadPublicErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(ReadPublicResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(ReadPublicResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_ReadPublic(
- object_handle,
- object_handle_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ReadPublic(object_handle, object_handle_name,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -12600,42 +10611,34 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::ReadPublicSync(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- TPM2B_PUBLIC* out_public,
- TPM2B_NAME* name,
- TPM2B_NAME* qualified_name,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ReadPublicSync(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ TPM2B_PUBLIC* out_public,
+ TPM2B_NAME* name,
+ TPM2B_NAME* qualified_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_ReadPublic(
- object_handle,
- object_handle_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ReadPublic(object_handle, object_handle_name,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_ReadPublic(
- response,
- out_public,
- name,
- qualified_name,
- authorization_delegate);
+ rc = ParseResponse_ReadPublic(response, out_public, name, qualified_name,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_ActivateCredential(
- const TPMI_DH_OBJECT& activate_handle,
- const std::string& activate_handle_name,
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_ID_OBJECT& credential_blob,
- const TPM2B_ENCRYPTED_SECRET& secret,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& activate_handle,
+ const std::string& activate_handle_name,
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_ID_OBJECT& credential_blob,
+ const TPM2B_ENCRYPTED_SECRET& secret,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -12646,37 +10649,27 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string activate_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- activate_handle,
- &activate_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(activate_handle, &activate_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string key_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- key_handle,
- &key_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(key_handle, &key_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string credential_blob_bytes;
- rc = Serialize_TPM2B_ID_OBJECT(
- credential_blob,
- &credential_blob_bytes);
+ rc = Serialize_TPM2B_ID_OBJECT(credential_blob, &credential_blob_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string secret_bytes;
- rc = Serialize_TPM2B_ENCRYPTED_SECRET(
- secret,
- &secret_bytes);
+ rc = Serialize_TPM2B_ENCRYPTED_SECRET(secret, &secret_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -12688,24 +10681,19 @@
}
credential_blob_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(activate_handle_name.data(),
- activate_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(activate_handle_name.data(), activate_handle_name.size());
handle_section_bytes += activate_handle_bytes;
command_size += activate_handle_bytes.size();
- hash->Update(key_handle_name.data(),
- key_handle_name.size());
+ hash->Update(key_handle_name.data(), key_handle_name.size());
handle_section_bytes += key_handle_bytes;
command_size += key_handle_bytes.size();
- hash->Update(credential_blob_bytes.data(),
- credential_blob_bytes.size());
+ hash->Update(credential_blob_bytes.data(), credential_blob_bytes.size());
parameter_section_bytes += credential_blob_bytes;
command_size += credential_blob_bytes.size();
- hash->Update(secret_bytes.data(),
- secret_bytes.size());
+ hash->Update(secret_bytes.data(), secret_bytes.size());
parameter_section_bytes += secret_bytes;
command_size += secret_bytes.size();
std::string command_hash(32, 0);
@@ -12714,10 +10702,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -12728,31 +10715,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -12760,37 +10739,28 @@
}
TPM_RC Tpm::ParseResponse_ActivateCredential(
- const std::string& response,
- TPM2B_DIGEST* cert_info,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_DIGEST* cert_info,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -12802,9 +10772,7 @@
}
TPM_CC command_code = TPM_CC_ActivateCredential;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -12822,29 +10790,22 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string cert_info_bytes;
- rc = Parse_TPM2B_DIGEST(
- &buffer,
- cert_info,
- &cert_info_bytes);
+ rc = Parse_TPM2B_DIGEST(&buffer, cert_info, &cert_info_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -12856,10 +10817,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
cert_info_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_DIGEST(
- &cert_info_bytes,
- cert_info,
- nullptr);
+ rc = Parse_TPM2B_DIGEST(&cert_info_bytes, cert_info, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -12871,8 +10829,7 @@
const Tpm::ActivateCredentialResponse& callback,
TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_DIGEST());
+ callback.Run(response_code, TPM2B_DIGEST());
}
void ActivateCredentialResponseParser(
@@ -12883,45 +10840,32 @@
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ActivateCredentialErrorCallback, callback);
TPM2B_DIGEST cert_info;
- TPM_RC rc = Tpm::ParseResponse_ActivateCredential(
- response,
- &cert_info,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_ActivateCredential(response, &cert_info,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- cert_info);
+ callback.Run(rc, cert_info);
}
-void Tpm::ActivateCredential(
- const TPMI_DH_OBJECT& activate_handle,
- const std::string& activate_handle_name,
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_ID_OBJECT& credential_blob,
- const TPM2B_ENCRYPTED_SECRET& secret,
- AuthorizationDelegate* authorization_delegate,
- const ActivateCredentialResponse& callback) {
+void Tpm::ActivateCredential(const TPMI_DH_OBJECT& activate_handle,
+ const std::string& activate_handle_name,
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_ID_OBJECT& credential_blob,
+ const TPM2B_ENCRYPTED_SECRET& secret,
+ AuthorizationDelegate* authorization_delegate,
+ const ActivateCredentialResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ActivateCredentialErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(ActivateCredentialResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ ActivateCredentialResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_ActivateCredential(
- activate_handle,
- activate_handle_name,
- key_handle,
- key_handle_name,
- credential_blob,
- secret,
- &command,
- authorization_delegate);
+ activate_handle, activate_handle_name, key_handle, key_handle_name,
+ credential_blob, secret, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -12930,43 +10874,35 @@
}
TPM_RC Tpm::ActivateCredentialSync(
- const TPMI_DH_OBJECT& activate_handle,
- const std::string& activate_handle_name,
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_ID_OBJECT& credential_blob,
- const TPM2B_ENCRYPTED_SECRET& secret,
- TPM2B_DIGEST* cert_info,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& activate_handle,
+ const std::string& activate_handle_name,
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_ID_OBJECT& credential_blob,
+ const TPM2B_ENCRYPTED_SECRET& secret,
+ TPM2B_DIGEST* cert_info,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_ActivateCredential(
- activate_handle,
- activate_handle_name,
- key_handle,
- key_handle_name,
- credential_blob,
- secret,
- &command,
- authorization_delegate);
+ activate_handle, activate_handle_name, key_handle, key_handle_name,
+ credential_blob, secret, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_ActivateCredential(
- response,
- cert_info,
- authorization_delegate);
+ rc = ParseResponse_ActivateCredential(response, cert_info,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_MakeCredential(
- const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_DIGEST& credential,
- const TPM2B_NAME& object_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_DIGEST& credential,
+ const TPM2B_NAME& object_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -12977,30 +10913,22 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- handle,
- &handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(handle, &handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string credential_bytes;
- rc = Serialize_TPM2B_DIGEST(
- credential,
- &credential_bytes);
+ rc = Serialize_TPM2B_DIGEST(credential, &credential_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string object_name_bytes;
- rc = Serialize_TPM2B_NAME(
- object_name,
- &object_name_bytes);
+ rc = Serialize_TPM2B_NAME(object_name, &object_name_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -13012,20 +10940,16 @@
}
credential_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(handle_name.data(),
- handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(handle_name.data(), handle_name.size());
handle_section_bytes += handle_bytes;
command_size += handle_bytes.size();
- hash->Update(credential_bytes.data(),
- credential_bytes.size());
+ hash->Update(credential_bytes.data(), credential_bytes.size());
parameter_section_bytes += credential_bytes;
command_size += credential_bytes.size();
- hash->Update(object_name_bytes.data(),
- object_name_bytes.size());
+ hash->Update(object_name_bytes.data(), object_name_bytes.size());
parameter_section_bytes += object_name_bytes;
command_size += object_name_bytes.size();
std::string command_hash(32, 0);
@@ -13034,10 +10958,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -13048,31 +10971,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -13080,38 +10995,29 @@
}
TPM_RC Tpm::ParseResponse_MakeCredential(
- const std::string& response,
- TPM2B_ID_OBJECT* credential_blob,
- TPM2B_ENCRYPTED_SECRET* secret,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_ID_OBJECT* credential_blob,
+ TPM2B_ENCRYPTED_SECRET* secret,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -13123,9 +11029,7 @@
}
TPM_CC command_code = TPM_CC_MakeCredential;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -13143,37 +11047,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string credential_blob_bytes;
- rc = Parse_TPM2B_ID_OBJECT(
- &buffer,
- credential_blob,
- &credential_blob_bytes);
+ rc = Parse_TPM2B_ID_OBJECT(&buffer, credential_blob, &credential_blob_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string secret_bytes;
- rc = Parse_TPM2B_ENCRYPTED_SECRET(
- &buffer,
- secret,
- &secret_bytes);
+ rc = Parse_TPM2B_ENCRYPTED_SECRET(&buffer, secret, &secret_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -13185,10 +11079,8 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
credential_blob_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_ID_OBJECT(
- &credential_blob_bytes,
- credential_blob,
- nullptr);
+ rc =
+ Parse_TPM2B_ID_OBJECT(&credential_blob_bytes, credential_blob, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -13196,61 +11088,44 @@
return TPM_RC_SUCCESS;
}
-void MakeCredentialErrorCallback(
- const Tpm::MakeCredentialResponse& callback,
- TPM_RC response_code) {
+void MakeCredentialErrorCallback(const Tpm::MakeCredentialResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_ID_OBJECT(),
- TPM2B_ENCRYPTED_SECRET());
+ callback.Run(response_code, TPM2B_ID_OBJECT(), TPM2B_ENCRYPTED_SECRET());
}
-void MakeCredentialResponseParser(
- const Tpm::MakeCredentialResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void MakeCredentialResponseParser(const Tpm::MakeCredentialResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(MakeCredentialErrorCallback, callback);
TPM2B_ID_OBJECT credential_blob;
TPM2B_ENCRYPTED_SECRET secret;
TPM_RC rc = Tpm::ParseResponse_MakeCredential(
- response,
- &credential_blob,
- &secret,
- authorization_delegate);
+ response, &credential_blob, &secret, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- credential_blob,
- secret);
+ callback.Run(rc, credential_blob, secret);
}
-void Tpm::MakeCredential(
- const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_DIGEST& credential,
- const TPM2B_NAME& object_name,
- AuthorizationDelegate* authorization_delegate,
- const MakeCredentialResponse& callback) {
+void Tpm::MakeCredential(const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_DIGEST& credential,
+ const TPM2B_NAME& object_name,
+ AuthorizationDelegate* authorization_delegate,
+ const MakeCredentialResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(MakeCredentialErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(MakeCredentialResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ MakeCredentialResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_MakeCredential(
- handle,
- handle_name,
- credential,
- object_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_MakeCredential(handle, handle_name, credential,
+ object_name, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -13258,40 +11133,32 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::MakeCredentialSync(
- const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_DIGEST& credential,
- const TPM2B_NAME& object_name,
- TPM2B_ID_OBJECT* credential_blob,
- TPM2B_ENCRYPTED_SECRET* secret,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::MakeCredentialSync(const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_DIGEST& credential,
+ const TPM2B_NAME& object_name,
+ TPM2B_ID_OBJECT* credential_blob,
+ TPM2B_ENCRYPTED_SECRET* secret,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_MakeCredential(
- handle,
- handle_name,
- credential,
- object_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_MakeCredential(handle, handle_name, credential,
+ object_name, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_MakeCredential(
- response,
- credential_blob,
- secret,
- authorization_delegate);
+ rc = ParseResponse_MakeCredential(response, credential_blob, secret,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_Unseal(
- const TPMI_DH_OBJECT& item_handle,
- const std::string& item_handle_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& item_handle,
+ const std::string& item_handle_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -13302,25 +11169,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string item_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- item_handle,
- &item_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(item_handle, &item_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(item_handle_name.data(),
- item_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(item_handle_name.data(), item_handle_name.size());
handle_section_bytes += item_handle_bytes;
command_size += item_handle_bytes.size();
std::string command_hash(32, 0);
@@ -13329,10 +11190,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -13343,31 +11203,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -13375,37 +11227,28 @@
}
TPM_RC Tpm::ParseResponse_Unseal(
- const std::string& response,
- TPM2B_SENSITIVE_DATA* out_data,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_SENSITIVE_DATA* out_data,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -13417,9 +11260,7 @@
}
TPM_CC command_code = TPM_CC_Unseal;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -13437,29 +11278,22 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string out_data_bytes;
- rc = Parse_TPM2B_SENSITIVE_DATA(
- &buffer,
- out_data,
- &out_data_bytes);
+ rc = Parse_TPM2B_SENSITIVE_DATA(&buffer, out_data, &out_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -13471,10 +11305,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
out_data_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_SENSITIVE_DATA(
- &out_data_bytes,
- out_data,
- nullptr);
+ rc = Parse_TPM2B_SENSITIVE_DATA(&out_data_bytes, out_data, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -13482,53 +11313,40 @@
return TPM_RC_SUCCESS;
}
-void UnsealErrorCallback(
- const Tpm::UnsealResponse& callback,
- TPM_RC response_code) {
+void UnsealErrorCallback(const Tpm::UnsealResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_SENSITIVE_DATA());
+ callback.Run(response_code, TPM2B_SENSITIVE_DATA());
}
-void UnsealResponseParser(
- const Tpm::UnsealResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void UnsealResponseParser(const Tpm::UnsealResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(UnsealErrorCallback, callback);
TPM2B_SENSITIVE_DATA out_data;
- TPM_RC rc = Tpm::ParseResponse_Unseal(
- response,
- &out_data,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_Unseal(response, &out_data, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- out_data);
+ callback.Run(rc, out_data);
}
-void Tpm::Unseal(
- const TPMI_DH_OBJECT& item_handle,
- const std::string& item_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const UnsealResponse& callback) {
+void Tpm::Unseal(const TPMI_DH_OBJECT& item_handle,
+ const std::string& item_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const UnsealResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(UnsealErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(UnsealResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(UnsealResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_Unseal(
- item_handle,
- item_handle_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_Unseal(item_handle, item_handle_name, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -13536,37 +11354,30 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::UnsealSync(
- const TPMI_DH_OBJECT& item_handle,
- const std::string& item_handle_name,
- TPM2B_SENSITIVE_DATA* out_data,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::UnsealSync(const TPMI_DH_OBJECT& item_handle,
+ const std::string& item_handle_name,
+ TPM2B_SENSITIVE_DATA* out_data,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_Unseal(
- item_handle,
- item_handle_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_Unseal(item_handle, item_handle_name, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_Unseal(
- response,
- out_data,
- authorization_delegate);
+ rc = ParseResponse_Unseal(response, out_data, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_ObjectChangeAuth(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_AUTH& new_auth,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_AUTH& new_auth,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -13577,30 +11388,22 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string object_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- object_handle,
- &object_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(object_handle, &object_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string parent_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- parent_handle,
- &parent_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(parent_handle, &parent_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string new_auth_bytes;
- rc = Serialize_TPM2B_AUTH(
- new_auth,
- &new_auth_bytes);
+ rc = Serialize_TPM2B_AUTH(new_auth, &new_auth_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -13612,20 +11415,16 @@
}
new_auth_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(object_handle_name.data(),
- object_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(object_handle_name.data(), object_handle_name.size());
handle_section_bytes += object_handle_bytes;
command_size += object_handle_bytes.size();
- hash->Update(parent_handle_name.data(),
- parent_handle_name.size());
+ hash->Update(parent_handle_name.data(), parent_handle_name.size());
handle_section_bytes += parent_handle_bytes;
command_size += parent_handle_bytes.size();
- hash->Update(new_auth_bytes.data(),
- new_auth_bytes.size());
+ hash->Update(new_auth_bytes.data(), new_auth_bytes.size());
parameter_section_bytes += new_auth_bytes;
command_size += new_auth_bytes.size();
std::string command_hash(32, 0);
@@ -13634,10 +11433,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -13648,31 +11446,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -13680,37 +11470,28 @@
}
TPM_RC Tpm::ParseResponse_ObjectChangeAuth(
- const std::string& response,
- TPM2B_PRIVATE* out_private,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_PRIVATE* out_private,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -13722,9 +11503,7 @@
}
TPM_CC command_code = TPM_CC_ObjectChangeAuth;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -13742,29 +11521,22 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string out_private_bytes;
- rc = Parse_TPM2B_PRIVATE(
- &buffer,
- out_private,
- &out_private_bytes);
+ rc = Parse_TPM2B_PRIVATE(&buffer, out_private, &out_private_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -13776,10 +11548,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
out_private_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_PRIVATE(
- &out_private_bytes,
- out_private,
- nullptr);
+ rc = Parse_TPM2B_PRIVATE(&out_private_bytes, out_private, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -13791,8 +11560,7 @@
const Tpm::ObjectChangeAuthResponse& callback,
TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_PRIVATE());
+ callback.Run(response_code, TPM2B_PRIVATE());
}
void ObjectChangeAuthResponseParser(
@@ -13803,43 +11571,31 @@
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ObjectChangeAuthErrorCallback, callback);
TPM2B_PRIVATE out_private;
- TPM_RC rc = Tpm::ParseResponse_ObjectChangeAuth(
- response,
- &out_private,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_ObjectChangeAuth(response, &out_private,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- out_private);
+ callback.Run(rc, out_private);
}
-void Tpm::ObjectChangeAuth(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_AUTH& new_auth,
- AuthorizationDelegate* authorization_delegate,
- const ObjectChangeAuthResponse& callback) {
+void Tpm::ObjectChangeAuth(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_AUTH& new_auth,
+ AuthorizationDelegate* authorization_delegate,
+ const ObjectChangeAuthResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ObjectChangeAuthErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(ObjectChangeAuthResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ ObjectChangeAuthResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_ObjectChangeAuth(
- object_handle,
- object_handle_name,
- parent_handle,
- parent_handle_name,
- new_auth,
- &command,
- authorization_delegate);
+ object_handle, object_handle_name, parent_handle, parent_handle_name,
+ new_auth, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -13848,43 +11604,36 @@
}
TPM_RC Tpm::ObjectChangeAuthSync(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_AUTH& new_auth,
- TPM2B_PRIVATE* out_private,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_AUTH& new_auth,
+ TPM2B_PRIVATE* out_private,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_ObjectChangeAuth(
- object_handle,
- object_handle_name,
- parent_handle,
- parent_handle_name,
- new_auth,
- &command,
- authorization_delegate);
+ object_handle, object_handle_name, parent_handle, parent_handle_name,
+ new_auth, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_ObjectChangeAuth(
- response,
- out_private,
- authorization_delegate);
+ rc = ParseResponse_ObjectChangeAuth(response, out_private,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_Duplicate(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& new_parent_handle,
- const std::string& new_parent_handle_name,
- const TPM2B_DATA& encryption_key_in,
- const TPMT_SYM_DEF_OBJECT& symmetric_alg,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& new_parent_handle,
+ const std::string& new_parent_handle_name,
+ const TPM2B_DATA& encryption_key_in,
+ const TPMT_SYM_DEF_OBJECT& symmetric_alg,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -13895,37 +11644,27 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string object_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- object_handle,
- &object_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(object_handle, &object_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string new_parent_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- new_parent_handle,
- &new_parent_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(new_parent_handle, &new_parent_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string encryption_key_in_bytes;
- rc = Serialize_TPM2B_DATA(
- encryption_key_in,
- &encryption_key_in_bytes);
+ rc = Serialize_TPM2B_DATA(encryption_key_in, &encryption_key_in_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string symmetric_alg_bytes;
- rc = Serialize_TPMT_SYM_DEF_OBJECT(
- symmetric_alg,
- &symmetric_alg_bytes);
+ rc = Serialize_TPMT_SYM_DEF_OBJECT(symmetric_alg, &symmetric_alg_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -13937,24 +11676,19 @@
}
encryption_key_in_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(object_handle_name.data(),
- object_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(object_handle_name.data(), object_handle_name.size());
handle_section_bytes += object_handle_bytes;
command_size += object_handle_bytes.size();
- hash->Update(new_parent_handle_name.data(),
- new_parent_handle_name.size());
+ hash->Update(new_parent_handle_name.data(), new_parent_handle_name.size());
handle_section_bytes += new_parent_handle_bytes;
command_size += new_parent_handle_bytes.size();
- hash->Update(encryption_key_in_bytes.data(),
- encryption_key_in_bytes.size());
+ hash->Update(encryption_key_in_bytes.data(), encryption_key_in_bytes.size());
parameter_section_bytes += encryption_key_in_bytes;
command_size += encryption_key_in_bytes.size();
- hash->Update(symmetric_alg_bytes.data(),
- symmetric_alg_bytes.size());
+ hash->Update(symmetric_alg_bytes.data(), symmetric_alg_bytes.size());
parameter_section_bytes += symmetric_alg_bytes;
command_size += symmetric_alg_bytes.size();
std::string command_hash(32, 0);
@@ -13963,10 +11697,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -13977,31 +11710,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -14009,39 +11734,30 @@
}
TPM_RC Tpm::ParseResponse_Duplicate(
- const std::string& response,
- TPM2B_DATA* encryption_key_out,
- TPM2B_PRIVATE* duplicate,
- TPM2B_ENCRYPTED_SECRET* out_sym_seed,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_DATA* encryption_key_out,
+ TPM2B_PRIVATE* duplicate,
+ TPM2B_ENCRYPTED_SECRET* out_sym_seed,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -14053,9 +11769,7 @@
}
TPM_CC command_code = TPM_CC_Duplicate;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -14073,45 +11787,32 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string encryption_key_out_bytes;
- rc = Parse_TPM2B_DATA(
- &buffer,
- encryption_key_out,
- &encryption_key_out_bytes);
+ rc = Parse_TPM2B_DATA(&buffer, encryption_key_out, &encryption_key_out_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string duplicate_bytes;
- rc = Parse_TPM2B_PRIVATE(
- &buffer,
- duplicate,
- &duplicate_bytes);
+ rc = Parse_TPM2B_PRIVATE(&buffer, duplicate, &duplicate_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string out_sym_seed_bytes;
- rc = Parse_TPM2B_ENCRYPTED_SECRET(
- &buffer,
- out_sym_seed,
- &out_sym_seed_bytes);
+ rc = Parse_TPM2B_ENCRYPTED_SECRET(&buffer, out_sym_seed, &out_sym_seed_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -14123,10 +11824,8 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
encryption_key_out_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_DATA(
- &encryption_key_out_bytes,
- encryption_key_out,
- nullptr);
+ rc = Parse_TPM2B_DATA(&encryption_key_out_bytes, encryption_key_out,
+ nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -14134,68 +11833,49 @@
return TPM_RC_SUCCESS;
}
-void DuplicateErrorCallback(
- const Tpm::DuplicateResponse& callback,
- TPM_RC response_code) {
+void DuplicateErrorCallback(const Tpm::DuplicateResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_DATA(),
- TPM2B_PRIVATE(),
+ callback.Run(response_code, TPM2B_DATA(), TPM2B_PRIVATE(),
TPM2B_ENCRYPTED_SECRET());
}
-void DuplicateResponseParser(
- const Tpm::DuplicateResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void DuplicateResponseParser(const Tpm::DuplicateResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(DuplicateErrorCallback, callback);
TPM2B_DATA encryption_key_out;
TPM2B_PRIVATE duplicate;
TPM2B_ENCRYPTED_SECRET out_sym_seed;
- TPM_RC rc = Tpm::ParseResponse_Duplicate(
- response,
- &encryption_key_out,
- &duplicate,
- &out_sym_seed,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_Duplicate(response, &encryption_key_out, &duplicate,
+ &out_sym_seed, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- encryption_key_out,
- duplicate,
- out_sym_seed);
+ callback.Run(rc, encryption_key_out, duplicate, out_sym_seed);
}
-void Tpm::Duplicate(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& new_parent_handle,
- const std::string& new_parent_handle_name,
- const TPM2B_DATA& encryption_key_in,
- const TPMT_SYM_DEF_OBJECT& symmetric_alg,
- AuthorizationDelegate* authorization_delegate,
- const DuplicateResponse& callback) {
+void Tpm::Duplicate(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& new_parent_handle,
+ const std::string& new_parent_handle_name,
+ const TPM2B_DATA& encryption_key_in,
+ const TPMT_SYM_DEF_OBJECT& symmetric_alg,
+ AuthorizationDelegate* authorization_delegate,
+ const DuplicateResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(DuplicateErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(DuplicateResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(DuplicateResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_Duplicate(
- object_handle,
- object_handle_name,
- new_parent_handle,
- new_parent_handle_name,
- encryption_key_in,
- symmetric_alg,
- &command,
+ object_handle, object_handle_name, new_parent_handle,
+ new_parent_handle_name, encryption_key_in, symmetric_alg, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
@@ -14204,51 +11884,41 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::DuplicateSync(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& new_parent_handle,
- const std::string& new_parent_handle_name,
- const TPM2B_DATA& encryption_key_in,
- const TPMT_SYM_DEF_OBJECT& symmetric_alg,
- TPM2B_DATA* encryption_key_out,
- TPM2B_PRIVATE* duplicate,
- TPM2B_ENCRYPTED_SECRET* out_sym_seed,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::DuplicateSync(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& new_parent_handle,
+ const std::string& new_parent_handle_name,
+ const TPM2B_DATA& encryption_key_in,
+ const TPMT_SYM_DEF_OBJECT& symmetric_alg,
+ TPM2B_DATA* encryption_key_out,
+ TPM2B_PRIVATE* duplicate,
+ TPM2B_ENCRYPTED_SECRET* out_sym_seed,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_Duplicate(
- object_handle,
- object_handle_name,
- new_parent_handle,
- new_parent_handle_name,
- encryption_key_in,
- symmetric_alg,
- &command,
+ object_handle, object_handle_name, new_parent_handle,
+ new_parent_handle_name, encryption_key_in, symmetric_alg, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_Duplicate(
- response,
- encryption_key_out,
- duplicate,
- out_sym_seed,
- authorization_delegate);
+ rc = ParseResponse_Duplicate(response, encryption_key_out, duplicate,
+ out_sym_seed, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_Rewrap(
- const TPMI_DH_OBJECT& old_parent,
- const std::string& old_parent_name,
- const TPMI_DH_OBJECT& new_parent,
- const std::string& new_parent_name,
- const TPM2B_PRIVATE& in_duplicate,
- const TPM2B_NAME& name,
- const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& old_parent,
+ const std::string& old_parent_name,
+ const TPMI_DH_OBJECT& new_parent,
+ const std::string& new_parent_name,
+ const TPM2B_PRIVATE& in_duplicate,
+ const TPM2B_NAME& name,
+ const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -14259,44 +11929,32 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string old_parent_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- old_parent,
- &old_parent_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(old_parent, &old_parent_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string new_parent_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- new_parent,
- &new_parent_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(new_parent, &new_parent_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_duplicate_bytes;
- rc = Serialize_TPM2B_PRIVATE(
- in_duplicate,
- &in_duplicate_bytes);
+ rc = Serialize_TPM2B_PRIVATE(in_duplicate, &in_duplicate_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string name_bytes;
- rc = Serialize_TPM2B_NAME(
- name,
- &name_bytes);
+ rc = Serialize_TPM2B_NAME(name, &name_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_sym_seed_bytes;
- rc = Serialize_TPM2B_ENCRYPTED_SECRET(
- in_sym_seed,
- &in_sym_seed_bytes);
+ rc = Serialize_TPM2B_ENCRYPTED_SECRET(in_sym_seed, &in_sym_seed_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -14308,28 +11966,22 @@
}
in_duplicate_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(old_parent_name.data(),
- old_parent_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(old_parent_name.data(), old_parent_name.size());
handle_section_bytes += old_parent_bytes;
command_size += old_parent_bytes.size();
- hash->Update(new_parent_name.data(),
- new_parent_name.size());
+ hash->Update(new_parent_name.data(), new_parent_name.size());
handle_section_bytes += new_parent_bytes;
command_size += new_parent_bytes.size();
- hash->Update(in_duplicate_bytes.data(),
- in_duplicate_bytes.size());
+ hash->Update(in_duplicate_bytes.data(), in_duplicate_bytes.size());
parameter_section_bytes += in_duplicate_bytes;
command_size += in_duplicate_bytes.size();
- hash->Update(name_bytes.data(),
- name_bytes.size());
+ hash->Update(name_bytes.data(), name_bytes.size());
parameter_section_bytes += name_bytes;
command_size += name_bytes.size();
- hash->Update(in_sym_seed_bytes.data(),
- in_sym_seed_bytes.size());
+ hash->Update(in_sym_seed_bytes.data(), in_sym_seed_bytes.size());
parameter_section_bytes += in_sym_seed_bytes;
command_size += in_sym_seed_bytes.size();
std::string command_hash(32, 0);
@@ -14338,10 +11990,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -14352,31 +12003,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -14384,38 +12027,29 @@
}
TPM_RC Tpm::ParseResponse_Rewrap(
- const std::string& response,
- TPM2B_PRIVATE* out_duplicate,
- TPM2B_ENCRYPTED_SECRET* out_sym_seed,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_PRIVATE* out_duplicate,
+ TPM2B_ENCRYPTED_SECRET* out_sym_seed,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -14427,9 +12061,7 @@
}
TPM_CC command_code = TPM_CC_Rewrap;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -14447,37 +12079,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string out_duplicate_bytes;
- rc = Parse_TPM2B_PRIVATE(
- &buffer,
- out_duplicate,
- &out_duplicate_bytes);
+ rc = Parse_TPM2B_PRIVATE(&buffer, out_duplicate, &out_duplicate_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string out_sym_seed_bytes;
- rc = Parse_TPM2B_ENCRYPTED_SECRET(
- &buffer,
- out_sym_seed,
- &out_sym_seed_bytes);
+ rc = Parse_TPM2B_ENCRYPTED_SECRET(&buffer, out_sym_seed, &out_sym_seed_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -14489,10 +12111,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
out_duplicate_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_PRIVATE(
- &out_duplicate_bytes,
- out_duplicate,
- nullptr);
+ rc = Parse_TPM2B_PRIVATE(&out_duplicate_bytes, out_duplicate, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -14500,67 +12119,47 @@
return TPM_RC_SUCCESS;
}
-void RewrapErrorCallback(
- const Tpm::RewrapResponse& callback,
- TPM_RC response_code) {
+void RewrapErrorCallback(const Tpm::RewrapResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_PRIVATE(),
- TPM2B_ENCRYPTED_SECRET());
+ callback.Run(response_code, TPM2B_PRIVATE(), TPM2B_ENCRYPTED_SECRET());
}
-void RewrapResponseParser(
- const Tpm::RewrapResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void RewrapResponseParser(const Tpm::RewrapResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(RewrapErrorCallback, callback);
TPM2B_PRIVATE out_duplicate;
TPM2B_ENCRYPTED_SECRET out_sym_seed;
- TPM_RC rc = Tpm::ParseResponse_Rewrap(
- response,
- &out_duplicate,
- &out_sym_seed,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_Rewrap(response, &out_duplicate, &out_sym_seed,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- out_duplicate,
- out_sym_seed);
+ callback.Run(rc, out_duplicate, out_sym_seed);
}
-void Tpm::Rewrap(
- const TPMI_DH_OBJECT& old_parent,
- const std::string& old_parent_name,
- const TPMI_DH_OBJECT& new_parent,
- const std::string& new_parent_name,
- const TPM2B_PRIVATE& in_duplicate,
- const TPM2B_NAME& name,
- const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
- AuthorizationDelegate* authorization_delegate,
- const RewrapResponse& callback) {
+void Tpm::Rewrap(const TPMI_DH_OBJECT& old_parent,
+ const std::string& old_parent_name,
+ const TPMI_DH_OBJECT& new_parent,
+ const std::string& new_parent_name,
+ const TPM2B_PRIVATE& in_duplicate,
+ const TPM2B_NAME& name,
+ const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
+ AuthorizationDelegate* authorization_delegate,
+ const RewrapResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(RewrapErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(RewrapResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(RewrapResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_Rewrap(
- old_parent,
- old_parent_name,
- new_parent,
- new_parent_name,
- in_duplicate,
- name,
- in_sym_seed,
- &command,
- authorization_delegate);
+ old_parent, old_parent_name, new_parent, new_parent_name, in_duplicate,
+ name, in_sym_seed, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -14568,51 +12167,40 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::RewrapSync(
- const TPMI_DH_OBJECT& old_parent,
- const std::string& old_parent_name,
- const TPMI_DH_OBJECT& new_parent,
- const std::string& new_parent_name,
- const TPM2B_PRIVATE& in_duplicate,
- const TPM2B_NAME& name,
- const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
- TPM2B_PRIVATE* out_duplicate,
- TPM2B_ENCRYPTED_SECRET* out_sym_seed,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::RewrapSync(const TPMI_DH_OBJECT& old_parent,
+ const std::string& old_parent_name,
+ const TPMI_DH_OBJECT& new_parent,
+ const std::string& new_parent_name,
+ const TPM2B_PRIVATE& in_duplicate,
+ const TPM2B_NAME& name,
+ const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
+ TPM2B_PRIVATE* out_duplicate,
+ TPM2B_ENCRYPTED_SECRET* out_sym_seed,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_Rewrap(
- old_parent,
- old_parent_name,
- new_parent,
- new_parent_name,
- in_duplicate,
- name,
- in_sym_seed,
- &command,
- authorization_delegate);
+ old_parent, old_parent_name, new_parent, new_parent_name, in_duplicate,
+ name, in_sym_seed, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_Rewrap(
- response,
- out_duplicate,
- out_sym_seed,
- authorization_delegate);
+ rc = ParseResponse_Rewrap(response, out_duplicate, out_sym_seed,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_Import(
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_DATA& encryption_key,
- const TPM2B_PUBLIC& object_public,
- const TPM2B_PRIVATE& duplicate,
- const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
- const TPMT_SYM_DEF_OBJECT& symmetric_alg,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_DATA& encryption_key,
+ const TPM2B_PUBLIC& object_public,
+ const TPM2B_PRIVATE& duplicate,
+ const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
+ const TPMT_SYM_DEF_OBJECT& symmetric_alg,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -14623,51 +12211,37 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string parent_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- parent_handle,
- &parent_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(parent_handle, &parent_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string encryption_key_bytes;
- rc = Serialize_TPM2B_DATA(
- encryption_key,
- &encryption_key_bytes);
+ rc = Serialize_TPM2B_DATA(encryption_key, &encryption_key_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string object_public_bytes;
- rc = Serialize_TPM2B_PUBLIC(
- object_public,
- &object_public_bytes);
+ rc = Serialize_TPM2B_PUBLIC(object_public, &object_public_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string duplicate_bytes;
- rc = Serialize_TPM2B_PRIVATE(
- duplicate,
- &duplicate_bytes);
+ rc = Serialize_TPM2B_PRIVATE(duplicate, &duplicate_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_sym_seed_bytes;
- rc = Serialize_TPM2B_ENCRYPTED_SECRET(
- in_sym_seed,
- &in_sym_seed_bytes);
+ rc = Serialize_TPM2B_ENCRYPTED_SECRET(in_sym_seed, &in_sym_seed_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string symmetric_alg_bytes;
- rc = Serialize_TPMT_SYM_DEF_OBJECT(
- symmetric_alg,
- &symmetric_alg_bytes);
+ rc = Serialize_TPMT_SYM_DEF_OBJECT(symmetric_alg, &symmetric_alg_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -14679,32 +12253,25 @@
}
encryption_key_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(parent_handle_name.data(),
- parent_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(parent_handle_name.data(), parent_handle_name.size());
handle_section_bytes += parent_handle_bytes;
command_size += parent_handle_bytes.size();
- hash->Update(encryption_key_bytes.data(),
- encryption_key_bytes.size());
+ hash->Update(encryption_key_bytes.data(), encryption_key_bytes.size());
parameter_section_bytes += encryption_key_bytes;
command_size += encryption_key_bytes.size();
- hash->Update(object_public_bytes.data(),
- object_public_bytes.size());
+ hash->Update(object_public_bytes.data(), object_public_bytes.size());
parameter_section_bytes += object_public_bytes;
command_size += object_public_bytes.size();
- hash->Update(duplicate_bytes.data(),
- duplicate_bytes.size());
+ hash->Update(duplicate_bytes.data(), duplicate_bytes.size());
parameter_section_bytes += duplicate_bytes;
command_size += duplicate_bytes.size();
- hash->Update(in_sym_seed_bytes.data(),
- in_sym_seed_bytes.size());
+ hash->Update(in_sym_seed_bytes.data(), in_sym_seed_bytes.size());
parameter_section_bytes += in_sym_seed_bytes;
command_size += in_sym_seed_bytes.size();
- hash->Update(symmetric_alg_bytes.data(),
- symmetric_alg_bytes.size());
+ hash->Update(symmetric_alg_bytes.data(), symmetric_alg_bytes.size());
parameter_section_bytes += symmetric_alg_bytes;
command_size += symmetric_alg_bytes.size();
std::string command_hash(32, 0);
@@ -14713,10 +12280,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -14727,31 +12293,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -14759,37 +12317,28 @@
}
TPM_RC Tpm::ParseResponse_Import(
- const std::string& response,
- TPM2B_PRIVATE* out_private,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_PRIVATE* out_private,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -14801,9 +12350,7 @@
}
TPM_CC command_code = TPM_CC_Import;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -14821,29 +12368,22 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string out_private_bytes;
- rc = Parse_TPM2B_PRIVATE(
- &buffer,
- out_private,
- &out_private_bytes);
+ rc = Parse_TPM2B_PRIVATE(&buffer, out_private, &out_private_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -14855,10 +12395,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
out_private_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_PRIVATE(
- &out_private_bytes,
- out_private,
- nullptr);
+ rc = Parse_TPM2B_PRIVATE(&out_private_bytes, out_private, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -14866,63 +12403,46 @@
return TPM_RC_SUCCESS;
}
-void ImportErrorCallback(
- const Tpm::ImportResponse& callback,
- TPM_RC response_code) {
+void ImportErrorCallback(const Tpm::ImportResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_PRIVATE());
+ callback.Run(response_code, TPM2B_PRIVATE());
}
-void ImportResponseParser(
- const Tpm::ImportResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void ImportResponseParser(const Tpm::ImportResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ImportErrorCallback, callback);
TPM2B_PRIVATE out_private;
- TPM_RC rc = Tpm::ParseResponse_Import(
- response,
- &out_private,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_Import(response, &out_private, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- out_private);
+ callback.Run(rc, out_private);
}
-void Tpm::Import(
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_DATA& encryption_key,
- const TPM2B_PUBLIC& object_public,
- const TPM2B_PRIVATE& duplicate,
- const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
- const TPMT_SYM_DEF_OBJECT& symmetric_alg,
- AuthorizationDelegate* authorization_delegate,
- const ImportResponse& callback) {
+void Tpm::Import(const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_DATA& encryption_key,
+ const TPM2B_PUBLIC& object_public,
+ const TPM2B_PRIVATE& duplicate,
+ const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
+ const TPMT_SYM_DEF_OBJECT& symmetric_alg,
+ AuthorizationDelegate* authorization_delegate,
+ const ImportResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ImportErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(ImportResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(ImportResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_Import(
- parent_handle,
- parent_handle_name,
- encryption_key,
- object_public,
- duplicate,
- in_sym_seed,
- symmetric_alg,
- &command,
- authorization_delegate);
+ parent_handle, parent_handle_name, encryption_key, object_public,
+ duplicate, in_sym_seed, symmetric_alg, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -14930,47 +12450,36 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::ImportSync(
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_DATA& encryption_key,
- const TPM2B_PUBLIC& object_public,
- const TPM2B_PRIVATE& duplicate,
- const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
- const TPMT_SYM_DEF_OBJECT& symmetric_alg,
- TPM2B_PRIVATE* out_private,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ImportSync(const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_DATA& encryption_key,
+ const TPM2B_PUBLIC& object_public,
+ const TPM2B_PRIVATE& duplicate,
+ const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
+ const TPMT_SYM_DEF_OBJECT& symmetric_alg,
+ TPM2B_PRIVATE* out_private,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_Import(
- parent_handle,
- parent_handle_name,
- encryption_key,
- object_public,
- duplicate,
- in_sym_seed,
- symmetric_alg,
- &command,
- authorization_delegate);
+ parent_handle, parent_handle_name, encryption_key, object_public,
+ duplicate, in_sym_seed, symmetric_alg, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_Import(
- response,
- out_private,
- authorization_delegate);
+ rc = ParseResponse_Import(response, out_private, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_RSA_Encrypt(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_PUBLIC_KEY_RSA& message,
- const TPMT_RSA_DECRYPT& in_scheme,
- const TPM2B_DATA& label,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_PUBLIC_KEY_RSA& message,
+ const TPMT_RSA_DECRYPT& in_scheme,
+ const TPM2B_DATA& label,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -14981,37 +12490,27 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string key_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- key_handle,
- &key_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(key_handle, &key_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string message_bytes;
- rc = Serialize_TPM2B_PUBLIC_KEY_RSA(
- message,
- &message_bytes);
+ rc = Serialize_TPM2B_PUBLIC_KEY_RSA(message, &message_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_scheme_bytes;
- rc = Serialize_TPMT_RSA_DECRYPT(
- in_scheme,
- &in_scheme_bytes);
+ rc = Serialize_TPMT_RSA_DECRYPT(in_scheme, &in_scheme_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string label_bytes;
- rc = Serialize_TPM2B_DATA(
- label,
- &label_bytes);
+ rc = Serialize_TPM2B_DATA(label, &label_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -15023,24 +12522,19 @@
}
message_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(key_handle_name.data(),
- key_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(key_handle_name.data(), key_handle_name.size());
handle_section_bytes += key_handle_bytes;
command_size += key_handle_bytes.size();
- hash->Update(message_bytes.data(),
- message_bytes.size());
+ hash->Update(message_bytes.data(), message_bytes.size());
parameter_section_bytes += message_bytes;
command_size += message_bytes.size();
- hash->Update(in_scheme_bytes.data(),
- in_scheme_bytes.size());
+ hash->Update(in_scheme_bytes.data(), in_scheme_bytes.size());
parameter_section_bytes += in_scheme_bytes;
command_size += in_scheme_bytes.size();
- hash->Update(label_bytes.data(),
- label_bytes.size());
+ hash->Update(label_bytes.data(), label_bytes.size());
parameter_section_bytes += label_bytes;
command_size += label_bytes.size();
std::string command_hash(32, 0);
@@ -15049,10 +12543,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -15063,31 +12556,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -15095,37 +12580,28 @@
}
TPM_RC Tpm::ParseResponse_RSA_Encrypt(
- const std::string& response,
- TPM2B_PUBLIC_KEY_RSA* out_data,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_PUBLIC_KEY_RSA* out_data,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -15137,9 +12613,7 @@
}
TPM_CC command_code = TPM_CC_RSA_Encrypt;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -15157,29 +12631,22 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string out_data_bytes;
- rc = Parse_TPM2B_PUBLIC_KEY_RSA(
- &buffer,
- out_data,
- &out_data_bytes);
+ rc = Parse_TPM2B_PUBLIC_KEY_RSA(&buffer, out_data, &out_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -15191,10 +12658,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
out_data_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_PUBLIC_KEY_RSA(
- &out_data_bytes,
- out_data,
- nullptr);
+ rc = Parse_TPM2B_PUBLIC_KEY_RSA(&out_data_bytes, out_data, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -15202,59 +12666,44 @@
return TPM_RC_SUCCESS;
}
-void RSA_EncryptErrorCallback(
- const Tpm::RSA_EncryptResponse& callback,
- TPM_RC response_code) {
+void RSA_EncryptErrorCallback(const Tpm::RSA_EncryptResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_PUBLIC_KEY_RSA());
+ callback.Run(response_code, TPM2B_PUBLIC_KEY_RSA());
}
-void RSA_EncryptResponseParser(
- const Tpm::RSA_EncryptResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void RSA_EncryptResponseParser(const Tpm::RSA_EncryptResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(RSA_EncryptErrorCallback, callback);
TPM2B_PUBLIC_KEY_RSA out_data;
- TPM_RC rc = Tpm::ParseResponse_RSA_Encrypt(
- response,
- &out_data,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_RSA_Encrypt(response, &out_data,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- out_data);
+ callback.Run(rc, out_data);
}
-void Tpm::RSA_Encrypt(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_PUBLIC_KEY_RSA& message,
- const TPMT_RSA_DECRYPT& in_scheme,
- const TPM2B_DATA& label,
- AuthorizationDelegate* authorization_delegate,
- const RSA_EncryptResponse& callback) {
+void Tpm::RSA_Encrypt(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_PUBLIC_KEY_RSA& message,
+ const TPMT_RSA_DECRYPT& in_scheme,
+ const TPM2B_DATA& label,
+ AuthorizationDelegate* authorization_delegate,
+ const RSA_EncryptResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(RSA_EncryptErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(RSA_EncryptResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(RSA_EncryptResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_RSA_Encrypt(
- key_handle,
- key_handle_name,
- message,
- in_scheme,
- label,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_RSA_Encrypt(key_handle, key_handle_name, message,
+ in_scheme, label, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -15262,43 +12711,34 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::RSA_EncryptSync(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_PUBLIC_KEY_RSA& message,
- const TPMT_RSA_DECRYPT& in_scheme,
- const TPM2B_DATA& label,
- TPM2B_PUBLIC_KEY_RSA* out_data,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::RSA_EncryptSync(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_PUBLIC_KEY_RSA& message,
+ const TPMT_RSA_DECRYPT& in_scheme,
+ const TPM2B_DATA& label,
+ TPM2B_PUBLIC_KEY_RSA* out_data,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_RSA_Encrypt(
- key_handle,
- key_handle_name,
- message,
- in_scheme,
- label,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_RSA_Encrypt(key_handle, key_handle_name, message,
+ in_scheme, label, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_RSA_Encrypt(
- response,
- out_data,
- authorization_delegate);
+ rc = ParseResponse_RSA_Encrypt(response, out_data, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_RSA_Decrypt(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_PUBLIC_KEY_RSA& cipher_text,
- const TPMT_RSA_DECRYPT& in_scheme,
- const TPM2B_DATA& label,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_PUBLIC_KEY_RSA& cipher_text,
+ const TPMT_RSA_DECRYPT& in_scheme,
+ const TPM2B_DATA& label,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -15309,37 +12749,27 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string key_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- key_handle,
- &key_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(key_handle, &key_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string cipher_text_bytes;
- rc = Serialize_TPM2B_PUBLIC_KEY_RSA(
- cipher_text,
- &cipher_text_bytes);
+ rc = Serialize_TPM2B_PUBLIC_KEY_RSA(cipher_text, &cipher_text_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_scheme_bytes;
- rc = Serialize_TPMT_RSA_DECRYPT(
- in_scheme,
- &in_scheme_bytes);
+ rc = Serialize_TPMT_RSA_DECRYPT(in_scheme, &in_scheme_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string label_bytes;
- rc = Serialize_TPM2B_DATA(
- label,
- &label_bytes);
+ rc = Serialize_TPM2B_DATA(label, &label_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -15351,24 +12781,19 @@
}
cipher_text_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(key_handle_name.data(),
- key_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(key_handle_name.data(), key_handle_name.size());
handle_section_bytes += key_handle_bytes;
command_size += key_handle_bytes.size();
- hash->Update(cipher_text_bytes.data(),
- cipher_text_bytes.size());
+ hash->Update(cipher_text_bytes.data(), cipher_text_bytes.size());
parameter_section_bytes += cipher_text_bytes;
command_size += cipher_text_bytes.size();
- hash->Update(in_scheme_bytes.data(),
- in_scheme_bytes.size());
+ hash->Update(in_scheme_bytes.data(), in_scheme_bytes.size());
parameter_section_bytes += in_scheme_bytes;
command_size += in_scheme_bytes.size();
- hash->Update(label_bytes.data(),
- label_bytes.size());
+ hash->Update(label_bytes.data(), label_bytes.size());
parameter_section_bytes += label_bytes;
command_size += label_bytes.size();
std::string command_hash(32, 0);
@@ -15377,10 +12802,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -15391,31 +12815,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -15423,37 +12839,28 @@
}
TPM_RC Tpm::ParseResponse_RSA_Decrypt(
- const std::string& response,
- TPM2B_PUBLIC_KEY_RSA* message,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_PUBLIC_KEY_RSA* message,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -15465,9 +12872,7 @@
}
TPM_CC command_code = TPM_CC_RSA_Decrypt;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -15485,29 +12890,22 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string message_bytes;
- rc = Parse_TPM2B_PUBLIC_KEY_RSA(
- &buffer,
- message,
- &message_bytes);
+ rc = Parse_TPM2B_PUBLIC_KEY_RSA(&buffer, message, &message_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -15519,10 +12917,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
message_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_PUBLIC_KEY_RSA(
- &message_bytes,
- message,
- nullptr);
+ rc = Parse_TPM2B_PUBLIC_KEY_RSA(&message_bytes, message, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -15530,59 +12925,44 @@
return TPM_RC_SUCCESS;
}
-void RSA_DecryptErrorCallback(
- const Tpm::RSA_DecryptResponse& callback,
- TPM_RC response_code) {
+void RSA_DecryptErrorCallback(const Tpm::RSA_DecryptResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_PUBLIC_KEY_RSA());
+ callback.Run(response_code, TPM2B_PUBLIC_KEY_RSA());
}
-void RSA_DecryptResponseParser(
- const Tpm::RSA_DecryptResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void RSA_DecryptResponseParser(const Tpm::RSA_DecryptResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(RSA_DecryptErrorCallback, callback);
TPM2B_PUBLIC_KEY_RSA message;
- TPM_RC rc = Tpm::ParseResponse_RSA_Decrypt(
- response,
- &message,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_RSA_Decrypt(response, &message,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- message);
+ callback.Run(rc, message);
}
-void Tpm::RSA_Decrypt(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_PUBLIC_KEY_RSA& cipher_text,
- const TPMT_RSA_DECRYPT& in_scheme,
- const TPM2B_DATA& label,
- AuthorizationDelegate* authorization_delegate,
- const RSA_DecryptResponse& callback) {
+void Tpm::RSA_Decrypt(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_PUBLIC_KEY_RSA& cipher_text,
+ const TPMT_RSA_DECRYPT& in_scheme,
+ const TPM2B_DATA& label,
+ AuthorizationDelegate* authorization_delegate,
+ const RSA_DecryptResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(RSA_DecryptErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(RSA_DecryptResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(RSA_DecryptResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_RSA_Decrypt(
- key_handle,
- key_handle_name,
- cipher_text,
- in_scheme,
- label,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_RSA_Decrypt(key_handle, key_handle_name,
+ cipher_text, in_scheme, label,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -15590,40 +12970,31 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::RSA_DecryptSync(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_PUBLIC_KEY_RSA& cipher_text,
- const TPMT_RSA_DECRYPT& in_scheme,
- const TPM2B_DATA& label,
- TPM2B_PUBLIC_KEY_RSA* message,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::RSA_DecryptSync(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_PUBLIC_KEY_RSA& cipher_text,
+ const TPMT_RSA_DECRYPT& in_scheme,
+ const TPM2B_DATA& label,
+ TPM2B_PUBLIC_KEY_RSA* message,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_RSA_Decrypt(
- key_handle,
- key_handle_name,
- cipher_text,
- in_scheme,
- label,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_RSA_Decrypt(key_handle, key_handle_name,
+ cipher_text, in_scheme, label,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_RSA_Decrypt(
- response,
- message,
- authorization_delegate);
+ rc = ParseResponse_RSA_Decrypt(response, message, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_ECDH_KeyGen(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -15634,25 +13005,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string key_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- key_handle,
- &key_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(key_handle, &key_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(key_handle_name.data(),
- key_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(key_handle_name.data(), key_handle_name.size());
handle_section_bytes += key_handle_bytes;
command_size += key_handle_bytes.size();
std::string command_hash(32, 0);
@@ -15661,10 +13026,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -15675,31 +13039,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -15707,38 +13063,29 @@
}
TPM_RC Tpm::ParseResponse_ECDH_KeyGen(
- const std::string& response,
- TPM2B_ECC_POINT* z_point,
- TPM2B_ECC_POINT* pub_point,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_ECC_POINT* z_point,
+ TPM2B_ECC_POINT* pub_point,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -15750,9 +13097,7 @@
}
TPM_CC command_code = TPM_CC_ECDH_KeyGen;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -15770,37 +13115,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string z_point_bytes;
- rc = Parse_TPM2B_ECC_POINT(
- &buffer,
- z_point,
- &z_point_bytes);
+ rc = Parse_TPM2B_ECC_POINT(&buffer, z_point, &z_point_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string pub_point_bytes;
- rc = Parse_TPM2B_ECC_POINT(
- &buffer,
- pub_point,
- &pub_point_bytes);
+ rc = Parse_TPM2B_ECC_POINT(&buffer, pub_point, &pub_point_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -15812,10 +13147,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
z_point_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_ECC_POINT(
- &z_point_bytes,
- z_point,
- nullptr);
+ rc = Parse_TPM2B_ECC_POINT(&z_point_bytes, z_point, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -15823,57 +13155,41 @@
return TPM_RC_SUCCESS;
}
-void ECDH_KeyGenErrorCallback(
- const Tpm::ECDH_KeyGenResponse& callback,
- TPM_RC response_code) {
+void ECDH_KeyGenErrorCallback(const Tpm::ECDH_KeyGenResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_ECC_POINT(),
- TPM2B_ECC_POINT());
+ callback.Run(response_code, TPM2B_ECC_POINT(), TPM2B_ECC_POINT());
}
-void ECDH_KeyGenResponseParser(
- const Tpm::ECDH_KeyGenResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void ECDH_KeyGenResponseParser(const Tpm::ECDH_KeyGenResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ECDH_KeyGenErrorCallback, callback);
TPM2B_ECC_POINT z_point;
TPM2B_ECC_POINT pub_point;
- TPM_RC rc = Tpm::ParseResponse_ECDH_KeyGen(
- response,
- &z_point,
- &pub_point,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_ECDH_KeyGen(response, &z_point, &pub_point,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- z_point,
- pub_point);
+ callback.Run(rc, z_point, pub_point);
}
-void Tpm::ECDH_KeyGen(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const ECDH_KeyGenResponse& callback) {
+void Tpm::ECDH_KeyGen(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const ECDH_KeyGenResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ECDH_KeyGenErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(ECDH_KeyGenResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(ECDH_KeyGenResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_ECDH_KeyGen(
- key_handle,
- key_handle_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ECDH_KeyGen(key_handle, key_handle_name,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -15881,37 +13197,30 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::ECDH_KeyGenSync(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- TPM2B_ECC_POINT* z_point,
- TPM2B_ECC_POINT* pub_point,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ECDH_KeyGenSync(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ TPM2B_ECC_POINT* z_point,
+ TPM2B_ECC_POINT* pub_point,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_ECDH_KeyGen(
- key_handle,
- key_handle_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ECDH_KeyGen(key_handle, key_handle_name,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_ECDH_KeyGen(
- response,
- z_point,
- pub_point,
- authorization_delegate);
+ rc = ParseResponse_ECDH_KeyGen(response, z_point, pub_point,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_ECDH_ZGen(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_ECC_POINT& in_point,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_ECC_POINT& in_point,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -15922,23 +13231,17 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string key_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- key_handle,
- &key_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(key_handle, &key_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_point_bytes;
- rc = Serialize_TPM2B_ECC_POINT(
- in_point,
- &in_point_bytes);
+ rc = Serialize_TPM2B_ECC_POINT(in_point, &in_point_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -15950,16 +13253,13 @@
}
in_point_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(key_handle_name.data(),
- key_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(key_handle_name.data(), key_handle_name.size());
handle_section_bytes += key_handle_bytes;
command_size += key_handle_bytes.size();
- hash->Update(in_point_bytes.data(),
- in_point_bytes.size());
+ hash->Update(in_point_bytes.data(), in_point_bytes.size());
parameter_section_bytes += in_point_bytes;
command_size += in_point_bytes.size();
std::string command_hash(32, 0);
@@ -15968,10 +13268,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -15982,31 +13281,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -16014,37 +13305,28 @@
}
TPM_RC Tpm::ParseResponse_ECDH_ZGen(
- const std::string& response,
- TPM2B_ECC_POINT* out_point,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_ECC_POINT* out_point,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -16056,9 +13338,7 @@
}
TPM_CC command_code = TPM_CC_ECDH_ZGen;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -16076,29 +13356,22 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string out_point_bytes;
- rc = Parse_TPM2B_ECC_POINT(
- &buffer,
- out_point,
- &out_point_bytes);
+ rc = Parse_TPM2B_ECC_POINT(&buffer, out_point, &out_point_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -16110,10 +13383,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
out_point_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_ECC_POINT(
- &out_point_bytes,
- out_point,
- nullptr);
+ rc = Parse_TPM2B_ECC_POINT(&out_point_bytes, out_point, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -16121,55 +13391,41 @@
return TPM_RC_SUCCESS;
}
-void ECDH_ZGenErrorCallback(
- const Tpm::ECDH_ZGenResponse& callback,
- TPM_RC response_code) {
+void ECDH_ZGenErrorCallback(const Tpm::ECDH_ZGenResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_ECC_POINT());
+ callback.Run(response_code, TPM2B_ECC_POINT());
}
-void ECDH_ZGenResponseParser(
- const Tpm::ECDH_ZGenResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void ECDH_ZGenResponseParser(const Tpm::ECDH_ZGenResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ECDH_ZGenErrorCallback, callback);
TPM2B_ECC_POINT out_point;
- TPM_RC rc = Tpm::ParseResponse_ECDH_ZGen(
- response,
- &out_point,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_ECDH_ZGen(response, &out_point,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- out_point);
+ callback.Run(rc, out_point);
}
-void Tpm::ECDH_ZGen(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_ECC_POINT& in_point,
- AuthorizationDelegate* authorization_delegate,
- const ECDH_ZGenResponse& callback) {
+void Tpm::ECDH_ZGen(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_ECC_POINT& in_point,
+ AuthorizationDelegate* authorization_delegate,
+ const ECDH_ZGenResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ECDH_ZGenErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(ECDH_ZGenResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(ECDH_ZGenResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_ECDH_ZGen(
- key_handle,
- key_handle_name,
- in_point,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ECDH_ZGen(key_handle, key_handle_name, in_point,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -16177,35 +13433,27 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::ECDH_ZGenSync(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_ECC_POINT& in_point,
- TPM2B_ECC_POINT* out_point,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ECDH_ZGenSync(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_ECC_POINT& in_point,
+ TPM2B_ECC_POINT* out_point,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_ECDH_ZGen(
- key_handle,
- key_handle_name,
- in_point,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ECDH_ZGen(key_handle, key_handle_name, in_point,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_ECDH_ZGen(
- response,
- out_point,
- authorization_delegate);
+ rc = ParseResponse_ECDH_ZGen(response, out_point, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_ECC_Parameters(
- const TPMI_ECC_CURVE& curve_id,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_ECC_CURVE& curve_id,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -16216,25 +13464,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string curve_id_bytes;
- rc = Serialize_TPMI_ECC_CURVE(
- curve_id,
- &curve_id_bytes);
+ rc = Serialize_TPMI_ECC_CURVE(curve_id, &curve_id_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(curve_id_bytes.data(),
- curve_id_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(curve_id_bytes.data(), curve_id_bytes.size());
parameter_section_bytes += curve_id_bytes;
command_size += curve_id_bytes.size();
std::string command_hash(32, 0);
@@ -16243,10 +13485,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -16257,31 +13498,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -16289,37 +13522,28 @@
}
TPM_RC Tpm::ParseResponse_ECC_Parameters(
- const std::string& response,
- TPMS_ALGORITHM_DETAIL_ECC* parameters,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPMS_ALGORITHM_DETAIL_ECC* parameters,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -16331,9 +13555,7 @@
}
TPM_CC command_code = TPM_CC_ECC_Parameters;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -16351,80 +13573,61 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string parameters_bytes;
- rc = Parse_TPMS_ALGORITHM_DETAIL_ECC(
- &buffer,
- parameters,
- ¶meters_bytes);
+ rc = Parse_TPMS_ALGORITHM_DETAIL_ECC(&buffer, parameters, ¶meters_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
return TPM_RC_SUCCESS;
}
-void ECC_ParametersErrorCallback(
- const Tpm::ECC_ParametersResponse& callback,
- TPM_RC response_code) {
+void ECC_ParametersErrorCallback(const Tpm::ECC_ParametersResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPMS_ALGORITHM_DETAIL_ECC());
+ callback.Run(response_code, TPMS_ALGORITHM_DETAIL_ECC());
}
-void ECC_ParametersResponseParser(
- const Tpm::ECC_ParametersResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void ECC_ParametersResponseParser(const Tpm::ECC_ParametersResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ECC_ParametersErrorCallback, callback);
TPMS_ALGORITHM_DETAIL_ECC parameters;
- TPM_RC rc = Tpm::ParseResponse_ECC_Parameters(
- response,
- ¶meters,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_ECC_Parameters(response, ¶meters,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- parameters);
+ callback.Run(rc, parameters);
}
-void Tpm::ECC_Parameters(
- const TPMI_ECC_CURVE& curve_id,
- AuthorizationDelegate* authorization_delegate,
- const ECC_ParametersResponse& callback) {
+void Tpm::ECC_Parameters(const TPMI_ECC_CURVE& curve_id,
+ AuthorizationDelegate* authorization_delegate,
+ const ECC_ParametersResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ECC_ParametersErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(ECC_ParametersResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ ECC_ParametersResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_ECC_Parameters(
- curve_id,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ECC_Parameters(curve_id, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -16432,36 +13635,31 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::ECC_ParametersSync(
- const TPMI_ECC_CURVE& curve_id,
- TPMS_ALGORITHM_DETAIL_ECC* parameters,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ECC_ParametersSync(const TPMI_ECC_CURVE& curve_id,
+ TPMS_ALGORITHM_DETAIL_ECC* parameters,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_ECC_Parameters(
- curve_id,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ECC_Parameters(curve_id, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_ECC_Parameters(
- response,
- parameters,
- authorization_delegate);
+ rc = ParseResponse_ECC_Parameters(response, parameters,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_ZGen_2Phase(
- const TPMI_DH_OBJECT& key_a,
- const std::string& key_a_name,
- const TPM2B_ECC_POINT& in_qs_b,
- const TPM2B_ECC_POINT& in_qe_b,
- const TPMI_ECC_KEY_EXCHANGE& in_scheme,
- const UINT16& counter,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& key_a,
+ const std::string& key_a_name,
+ const TPM2B_ECC_POINT& in_qs_b,
+ const TPM2B_ECC_POINT& in_qe_b,
+ const TPMI_ECC_KEY_EXCHANGE& in_scheme,
+ const UINT16& counter,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -16472,44 +13670,32 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string key_a_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- key_a,
- &key_a_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(key_a, &key_a_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_qs_b_bytes;
- rc = Serialize_TPM2B_ECC_POINT(
- in_qs_b,
- &in_qs_b_bytes);
+ rc = Serialize_TPM2B_ECC_POINT(in_qs_b, &in_qs_b_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_qe_b_bytes;
- rc = Serialize_TPM2B_ECC_POINT(
- in_qe_b,
- &in_qe_b_bytes);
+ rc = Serialize_TPM2B_ECC_POINT(in_qe_b, &in_qe_b_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_scheme_bytes;
- rc = Serialize_TPMI_ECC_KEY_EXCHANGE(
- in_scheme,
- &in_scheme_bytes);
+ rc = Serialize_TPMI_ECC_KEY_EXCHANGE(in_scheme, &in_scheme_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string counter_bytes;
- rc = Serialize_UINT16(
- counter,
- &counter_bytes);
+ rc = Serialize_UINT16(counter, &counter_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -16521,28 +13707,22 @@
}
in_qs_b_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(key_a_name.data(),
- key_a_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(key_a_name.data(), key_a_name.size());
handle_section_bytes += key_a_bytes;
command_size += key_a_bytes.size();
- hash->Update(in_qs_b_bytes.data(),
- in_qs_b_bytes.size());
+ hash->Update(in_qs_b_bytes.data(), in_qs_b_bytes.size());
parameter_section_bytes += in_qs_b_bytes;
command_size += in_qs_b_bytes.size();
- hash->Update(in_qe_b_bytes.data(),
- in_qe_b_bytes.size());
+ hash->Update(in_qe_b_bytes.data(), in_qe_b_bytes.size());
parameter_section_bytes += in_qe_b_bytes;
command_size += in_qe_b_bytes.size();
- hash->Update(in_scheme_bytes.data(),
- in_scheme_bytes.size());
+ hash->Update(in_scheme_bytes.data(), in_scheme_bytes.size());
parameter_section_bytes += in_scheme_bytes;
command_size += in_scheme_bytes.size();
- hash->Update(counter_bytes.data(),
- counter_bytes.size());
+ hash->Update(counter_bytes.data(), counter_bytes.size());
parameter_section_bytes += counter_bytes;
command_size += counter_bytes.size();
std::string command_hash(32, 0);
@@ -16551,10 +13731,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -16565,31 +13744,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -16597,38 +13768,29 @@
}
TPM_RC Tpm::ParseResponse_ZGen_2Phase(
- const std::string& response,
- TPM2B_ECC_POINT* out_z1,
- TPM2B_ECC_POINT* out_z2,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_ECC_POINT* out_z1,
+ TPM2B_ECC_POINT* out_z2,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -16640,9 +13802,7 @@
}
TPM_CC command_code = TPM_CC_ZGen_2Phase;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -16660,37 +13820,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string out_z1_bytes;
- rc = Parse_TPM2B_ECC_POINT(
- &buffer,
- out_z1,
- &out_z1_bytes);
+ rc = Parse_TPM2B_ECC_POINT(&buffer, out_z1, &out_z1_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string out_z2_bytes;
- rc = Parse_TPM2B_ECC_POINT(
- &buffer,
- out_z2,
- &out_z2_bytes);
+ rc = Parse_TPM2B_ECC_POINT(&buffer, out_z2, &out_z2_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -16702,10 +13852,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
out_z1_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_ECC_POINT(
- &out_z1_bytes,
- out_z1,
- nullptr);
+ rc = Parse_TPM2B_ECC_POINT(&out_z1_bytes, out_z1, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -16713,65 +13860,46 @@
return TPM_RC_SUCCESS;
}
-void ZGen_2PhaseErrorCallback(
- const Tpm::ZGen_2PhaseResponse& callback,
- TPM_RC response_code) {
+void ZGen_2PhaseErrorCallback(const Tpm::ZGen_2PhaseResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_ECC_POINT(),
- TPM2B_ECC_POINT());
+ callback.Run(response_code, TPM2B_ECC_POINT(), TPM2B_ECC_POINT());
}
-void ZGen_2PhaseResponseParser(
- const Tpm::ZGen_2PhaseResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void ZGen_2PhaseResponseParser(const Tpm::ZGen_2PhaseResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ZGen_2PhaseErrorCallback, callback);
TPM2B_ECC_POINT out_z1;
TPM2B_ECC_POINT out_z2;
- TPM_RC rc = Tpm::ParseResponse_ZGen_2Phase(
- response,
- &out_z1,
- &out_z2,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_ZGen_2Phase(response, &out_z1, &out_z2,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- out_z1,
- out_z2);
+ callback.Run(rc, out_z1, out_z2);
}
-void Tpm::ZGen_2Phase(
- const TPMI_DH_OBJECT& key_a,
- const std::string& key_a_name,
- const TPM2B_ECC_POINT& in_qs_b,
- const TPM2B_ECC_POINT& in_qe_b,
- const TPMI_ECC_KEY_EXCHANGE& in_scheme,
- const UINT16& counter,
- AuthorizationDelegate* authorization_delegate,
- const ZGen_2PhaseResponse& callback) {
+void Tpm::ZGen_2Phase(const TPMI_DH_OBJECT& key_a,
+ const std::string& key_a_name,
+ const TPM2B_ECC_POINT& in_qs_b,
+ const TPM2B_ECC_POINT& in_qe_b,
+ const TPMI_ECC_KEY_EXCHANGE& in_scheme,
+ const UINT16& counter,
+ AuthorizationDelegate* authorization_delegate,
+ const ZGen_2PhaseResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ZGen_2PhaseErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(ZGen_2PhaseResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(ZGen_2PhaseResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_ZGen_2Phase(
- key_a,
- key_a_name,
- in_qs_b,
- in_qe_b,
- in_scheme,
- counter,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ZGen_2Phase(key_a, key_a_name, in_qs_b, in_qe_b,
+ in_scheme, counter, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -16779,48 +13907,38 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::ZGen_2PhaseSync(
- const TPMI_DH_OBJECT& key_a,
- const std::string& key_a_name,
- const TPM2B_ECC_POINT& in_qs_b,
- const TPM2B_ECC_POINT& in_qe_b,
- const TPMI_ECC_KEY_EXCHANGE& in_scheme,
- const UINT16& counter,
- TPM2B_ECC_POINT* out_z1,
- TPM2B_ECC_POINT* out_z2,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ZGen_2PhaseSync(const TPMI_DH_OBJECT& key_a,
+ const std::string& key_a_name,
+ const TPM2B_ECC_POINT& in_qs_b,
+ const TPM2B_ECC_POINT& in_qe_b,
+ const TPMI_ECC_KEY_EXCHANGE& in_scheme,
+ const UINT16& counter,
+ TPM2B_ECC_POINT* out_z1,
+ TPM2B_ECC_POINT* out_z2,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_ZGen_2Phase(
- key_a,
- key_a_name,
- in_qs_b,
- in_qe_b,
- in_scheme,
- counter,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ZGen_2Phase(key_a, key_a_name, in_qs_b, in_qe_b,
+ in_scheme, counter, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_ZGen_2Phase(
- response,
- out_z1,
- out_z2,
- authorization_delegate);
+ rc = ParseResponse_ZGen_2Phase(response, out_z1, out_z2,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_EncryptDecrypt(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPMI_YES_NO& decrypt,
- const TPMI_ALG_SYM_MODE& mode,
- const TPM2B_IV& iv_in,
- const TPM2B_MAX_BUFFER& in_data,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPMI_YES_NO& decrypt,
+ const TPMI_ALG_SYM_MODE& mode,
+ const TPM2B_IV& iv_in,
+ const TPM2B_MAX_BUFFER& in_data,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -16831,69 +13949,51 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string key_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- key_handle,
- &key_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(key_handle, &key_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string decrypt_bytes;
- rc = Serialize_TPMI_YES_NO(
- decrypt,
- &decrypt_bytes);
+ rc = Serialize_TPMI_YES_NO(decrypt, &decrypt_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string mode_bytes;
- rc = Serialize_TPMI_ALG_SYM_MODE(
- mode,
- &mode_bytes);
+ rc = Serialize_TPMI_ALG_SYM_MODE(mode, &mode_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string iv_in_bytes;
- rc = Serialize_TPM2B_IV(
- iv_in,
- &iv_in_bytes);
+ rc = Serialize_TPM2B_IV(iv_in, &iv_in_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_data_bytes;
- rc = Serialize_TPM2B_MAX_BUFFER(
- in_data,
- &in_data_bytes);
+ rc = Serialize_TPM2B_MAX_BUFFER(in_data, &in_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(key_handle_name.data(),
- key_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(key_handle_name.data(), key_handle_name.size());
handle_section_bytes += key_handle_bytes;
command_size += key_handle_bytes.size();
- hash->Update(decrypt_bytes.data(),
- decrypt_bytes.size());
+ hash->Update(decrypt_bytes.data(), decrypt_bytes.size());
parameter_section_bytes += decrypt_bytes;
command_size += decrypt_bytes.size();
- hash->Update(mode_bytes.data(),
- mode_bytes.size());
+ hash->Update(mode_bytes.data(), mode_bytes.size());
parameter_section_bytes += mode_bytes;
command_size += mode_bytes.size();
- hash->Update(iv_in_bytes.data(),
- iv_in_bytes.size());
+ hash->Update(iv_in_bytes.data(), iv_in_bytes.size());
parameter_section_bytes += iv_in_bytes;
command_size += iv_in_bytes.size();
- hash->Update(in_data_bytes.data(),
- in_data_bytes.size());
+ hash->Update(in_data_bytes.data(), in_data_bytes.size());
parameter_section_bytes += in_data_bytes;
command_size += in_data_bytes.size();
std::string command_hash(32, 0);
@@ -16902,10 +14002,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -16916,31 +14015,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -16948,38 +14039,29 @@
}
TPM_RC Tpm::ParseResponse_EncryptDecrypt(
- const std::string& response,
- TPM2B_MAX_BUFFER* out_data,
- TPM2B_IV* iv_out,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_MAX_BUFFER* out_data,
+ TPM2B_IV* iv_out,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -16991,9 +14073,7 @@
}
TPM_CC command_code = TPM_CC_EncryptDecrypt;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -17011,37 +14091,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string out_data_bytes;
- rc = Parse_TPM2B_MAX_BUFFER(
- &buffer,
- out_data,
- &out_data_bytes);
+ rc = Parse_TPM2B_MAX_BUFFER(&buffer, out_data, &out_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string iv_out_bytes;
- rc = Parse_TPM2B_IV(
- &buffer,
- iv_out,
- &iv_out_bytes);
+ rc = Parse_TPM2B_IV(&buffer, iv_out, &iv_out_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -17053,10 +14123,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
out_data_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_MAX_BUFFER(
- &out_data_bytes,
- out_data,
- nullptr);
+ rc = Parse_TPM2B_MAX_BUFFER(&out_data_bytes, out_data, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -17064,65 +14131,46 @@
return TPM_RC_SUCCESS;
}
-void EncryptDecryptErrorCallback(
- const Tpm::EncryptDecryptResponse& callback,
- TPM_RC response_code) {
+void EncryptDecryptErrorCallback(const Tpm::EncryptDecryptResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_MAX_BUFFER(),
- TPM2B_IV());
+ callback.Run(response_code, TPM2B_MAX_BUFFER(), TPM2B_IV());
}
-void EncryptDecryptResponseParser(
- const Tpm::EncryptDecryptResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void EncryptDecryptResponseParser(const Tpm::EncryptDecryptResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(EncryptDecryptErrorCallback, callback);
TPM2B_MAX_BUFFER out_data;
TPM2B_IV iv_out;
- TPM_RC rc = Tpm::ParseResponse_EncryptDecrypt(
- response,
- &out_data,
- &iv_out,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_EncryptDecrypt(response, &out_data, &iv_out,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- out_data,
- iv_out);
+ callback.Run(rc, out_data, iv_out);
}
-void Tpm::EncryptDecrypt(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPMI_YES_NO& decrypt,
- const TPMI_ALG_SYM_MODE& mode,
- const TPM2B_IV& iv_in,
- const TPM2B_MAX_BUFFER& in_data,
- AuthorizationDelegate* authorization_delegate,
- const EncryptDecryptResponse& callback) {
+void Tpm::EncryptDecrypt(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPMI_YES_NO& decrypt,
+ const TPMI_ALG_SYM_MODE& mode,
+ const TPM2B_IV& iv_in,
+ const TPM2B_MAX_BUFFER& in_data,
+ AuthorizationDelegate* authorization_delegate,
+ const EncryptDecryptResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(EncryptDecryptErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(EncryptDecryptResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ EncryptDecryptResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_EncryptDecrypt(
- key_handle,
- key_handle_name,
- decrypt,
- mode,
- iv_in,
- in_data,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_EncryptDecrypt(key_handle, key_handle_name,
+ decrypt, mode, iv_in, in_data,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -17130,45 +14178,35 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::EncryptDecryptSync(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPMI_YES_NO& decrypt,
- const TPMI_ALG_SYM_MODE& mode,
- const TPM2B_IV& iv_in,
- const TPM2B_MAX_BUFFER& in_data,
- TPM2B_MAX_BUFFER* out_data,
- TPM2B_IV* iv_out,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::EncryptDecryptSync(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPMI_YES_NO& decrypt,
+ const TPMI_ALG_SYM_MODE& mode,
+ const TPM2B_IV& iv_in,
+ const TPM2B_MAX_BUFFER& in_data,
+ TPM2B_MAX_BUFFER* out_data,
+ TPM2B_IV* iv_out,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_EncryptDecrypt(
- key_handle,
- key_handle_name,
- decrypt,
- mode,
- iv_in,
- in_data,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_EncryptDecrypt(key_handle, key_handle_name,
+ decrypt, mode, iv_in, in_data,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_EncryptDecrypt(
- response,
- out_data,
- iv_out,
- authorization_delegate);
+ rc = ParseResponse_EncryptDecrypt(response, out_data, iv_out,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_Hash(
- const TPM2B_MAX_BUFFER& data,
- const TPMI_ALG_HASH& hash_alg,
- const TPMI_RH_HIERARCHY& hierarchy,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPM2B_MAX_BUFFER& data,
+ const TPMI_ALG_HASH& hash_alg,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -17179,30 +14217,22 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string data_bytes;
- rc = Serialize_TPM2B_MAX_BUFFER(
- data,
- &data_bytes);
+ rc = Serialize_TPM2B_MAX_BUFFER(data, &data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string hash_alg_bytes;
- rc = Serialize_TPMI_ALG_HASH(
- hash_alg,
- &hash_alg_bytes);
+ rc = Serialize_TPMI_ALG_HASH(hash_alg, &hash_alg_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string hierarchy_bytes;
- rc = Serialize_TPMI_RH_HIERARCHY(
- hierarchy,
- &hierarchy_bytes);
+ rc = Serialize_TPMI_RH_HIERARCHY(hierarchy, &hierarchy_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -17214,20 +14244,16 @@
}
data_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(data_bytes.data(),
- data_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(data_bytes.data(), data_bytes.size());
parameter_section_bytes += data_bytes;
command_size += data_bytes.size();
- hash->Update(hash_alg_bytes.data(),
- hash_alg_bytes.size());
+ hash->Update(hash_alg_bytes.data(), hash_alg_bytes.size());
parameter_section_bytes += hash_alg_bytes;
command_size += hash_alg_bytes.size();
- hash->Update(hierarchy_bytes.data(),
- hierarchy_bytes.size());
+ hash->Update(hierarchy_bytes.data(), hierarchy_bytes.size());
parameter_section_bytes += hierarchy_bytes;
command_size += hierarchy_bytes.size();
std::string command_hash(32, 0);
@@ -17236,10 +14262,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -17250,70 +14275,52 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
return TPM_RC_SUCCESS;
}
-TPM_RC Tpm::ParseResponse_Hash(
- const std::string& response,
- TPM2B_DIGEST* out_hash,
- TPMT_TK_HASHCHECK* validation,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ParseResponse_Hash(const std::string& response,
+ TPM2B_DIGEST* out_hash,
+ TPMT_TK_HASHCHECK* validation,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -17325,9 +14332,7 @@
}
TPM_CC command_code = TPM_CC_Hash;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -17345,37 +14350,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string out_hash_bytes;
- rc = Parse_TPM2B_DIGEST(
- &buffer,
- out_hash,
- &out_hash_bytes);
+ rc = Parse_TPM2B_DIGEST(&buffer, out_hash, &out_hash_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string validation_bytes;
- rc = Parse_TPMT_TK_HASHCHECK(
- &buffer,
- validation,
- &validation_bytes);
+ rc = Parse_TPMT_TK_HASHCHECK(&buffer, validation, &validation_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -17387,10 +14382,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
out_hash_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_DIGEST(
- &out_hash_bytes,
- out_hash,
- nullptr);
+ rc = Parse_TPM2B_DIGEST(&out_hash_bytes, out_hash, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -17398,59 +14390,42 @@
return TPM_RC_SUCCESS;
}
-void HashErrorCallback(
- const Tpm::HashResponse& callback,
- TPM_RC response_code) {
+void HashErrorCallback(const Tpm::HashResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_DIGEST(),
- TPMT_TK_HASHCHECK());
+ callback.Run(response_code, TPM2B_DIGEST(), TPMT_TK_HASHCHECK());
}
-void HashResponseParser(
- const Tpm::HashResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void HashResponseParser(const Tpm::HashResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(HashErrorCallback, callback);
TPM2B_DIGEST out_hash;
TPMT_TK_HASHCHECK validation;
- TPM_RC rc = Tpm::ParseResponse_Hash(
- response,
- &out_hash,
- &validation,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_Hash(response, &out_hash, &validation,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- out_hash,
- validation);
+ callback.Run(rc, out_hash, validation);
}
-void Tpm::Hash(
- const TPM2B_MAX_BUFFER& data,
- const TPMI_ALG_HASH& hash_alg,
- const TPMI_RH_HIERARCHY& hierarchy,
- AuthorizationDelegate* authorization_delegate,
- const HashResponse& callback) {
+void Tpm::Hash(const TPM2B_MAX_BUFFER& data,
+ const TPMI_ALG_HASH& hash_alg,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ AuthorizationDelegate* authorization_delegate,
+ const HashResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(HashErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(HashResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(HashResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_Hash(
- data,
- hash_alg,
- hierarchy,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_Hash(data, hash_alg, hierarchy, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -17458,40 +14433,32 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::HashSync(
- const TPM2B_MAX_BUFFER& data,
- const TPMI_ALG_HASH& hash_alg,
- const TPMI_RH_HIERARCHY& hierarchy,
- TPM2B_DIGEST* out_hash,
- TPMT_TK_HASHCHECK* validation,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::HashSync(const TPM2B_MAX_BUFFER& data,
+ const TPMI_ALG_HASH& hash_alg,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ TPM2B_DIGEST* out_hash,
+ TPMT_TK_HASHCHECK* validation,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_Hash(
- data,
- hash_alg,
- hierarchy,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_Hash(data, hash_alg, hierarchy, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_Hash(
- response,
- out_hash,
- validation,
- authorization_delegate);
+ rc = ParseResponse_Hash(response, out_hash, validation,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_HMAC(
- const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- const TPMI_ALG_HASH& hash_alg,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ const TPMI_ALG_HASH& hash_alg,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -17502,30 +14469,22 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- handle,
- &handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(handle, &handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string buffer_bytes;
- rc = Serialize_TPM2B_MAX_BUFFER(
- buffer,
- &buffer_bytes);
+ rc = Serialize_TPM2B_MAX_BUFFER(buffer, &buffer_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string hash_alg_bytes;
- rc = Serialize_TPMI_ALG_HASH(
- hash_alg,
- &hash_alg_bytes);
+ rc = Serialize_TPMI_ALG_HASH(hash_alg, &hash_alg_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -17537,20 +14496,16 @@
}
buffer_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(handle_name.data(),
- handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(handle_name.data(), handle_name.size());
handle_section_bytes += handle_bytes;
command_size += handle_bytes.size();
- hash->Update(buffer_bytes.data(),
- buffer_bytes.size());
+ hash->Update(buffer_bytes.data(), buffer_bytes.size());
parameter_section_bytes += buffer_bytes;
command_size += buffer_bytes.size();
- hash->Update(hash_alg_bytes.data(),
- hash_alg_bytes.size());
+ hash->Update(hash_alg_bytes.data(), hash_alg_bytes.size());
parameter_section_bytes += hash_alg_bytes;
command_size += hash_alg_bytes.size();
std::string command_hash(32, 0);
@@ -17559,10 +14514,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -17573,69 +14527,51 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
return TPM_RC_SUCCESS;
}
-TPM_RC Tpm::ParseResponse_HMAC(
- const std::string& response,
- TPM2B_DIGEST* out_hmac,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ParseResponse_HMAC(const std::string& response,
+ TPM2B_DIGEST* out_hmac,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -17647,9 +14583,7 @@
}
TPM_CC command_code = TPM_CC_HMAC;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -17667,29 +14601,22 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string out_hmac_bytes;
- rc = Parse_TPM2B_DIGEST(
- &buffer,
- out_hmac,
- &out_hmac_bytes);
+ rc = Parse_TPM2B_DIGEST(&buffer, out_hmac, &out_hmac_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -17701,10 +14628,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
out_hmac_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_DIGEST(
- &out_hmac_bytes,
- out_hmac,
- nullptr);
+ rc = Parse_TPM2B_DIGEST(&out_hmac_bytes, out_hmac, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -17712,57 +14636,42 @@
return TPM_RC_SUCCESS;
}
-void HMACErrorCallback(
- const Tpm::HMACResponse& callback,
- TPM_RC response_code) {
+void HMACErrorCallback(const Tpm::HMACResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_DIGEST());
+ callback.Run(response_code, TPM2B_DIGEST());
}
-void HMACResponseParser(
- const Tpm::HMACResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void HMACResponseParser(const Tpm::HMACResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(HMACErrorCallback, callback);
TPM2B_DIGEST out_hmac;
- TPM_RC rc = Tpm::ParseResponse_HMAC(
- response,
- &out_hmac,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_HMAC(response, &out_hmac, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- out_hmac);
+ callback.Run(rc, out_hmac);
}
-void Tpm::HMAC(
- const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- const TPMI_ALG_HASH& hash_alg,
- AuthorizationDelegate* authorization_delegate,
- const HMACResponse& callback) {
+void Tpm::HMAC(const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ const TPMI_ALG_HASH& hash_alg,
+ AuthorizationDelegate* authorization_delegate,
+ const HMACResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(HMACErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(HMACResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(HMACResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_HMAC(
- handle,
- handle_name,
- buffer,
- hash_alg,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_HMAC(handle, handle_name, buffer, hash_alg,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -17770,37 +14679,28 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::HMACSync(
- const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- const TPMI_ALG_HASH& hash_alg,
- TPM2B_DIGEST* out_hmac,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::HMACSync(const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ const TPMI_ALG_HASH& hash_alg,
+ TPM2B_DIGEST* out_hmac,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_HMAC(
- handle,
- handle_name,
- buffer,
- hash_alg,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_HMAC(handle, handle_name, buffer, hash_alg,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_HMAC(
- response,
- out_hmac,
- authorization_delegate);
+ rc = ParseResponse_HMAC(response, out_hmac, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_GetRandom(
- const UINT16& bytes_requested,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const UINT16& bytes_requested,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -17811,25 +14711,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string bytes_requested_bytes;
- rc = Serialize_UINT16(
- bytes_requested,
- &bytes_requested_bytes);
+ rc = Serialize_UINT16(bytes_requested, &bytes_requested_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(bytes_requested_bytes.data(),
- bytes_requested_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(bytes_requested_bytes.data(), bytes_requested_bytes.size());
parameter_section_bytes += bytes_requested_bytes;
command_size += bytes_requested_bytes.size();
std::string command_hash(32, 0);
@@ -17838,10 +14732,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -17852,31 +14745,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -17884,37 +14769,28 @@
}
TPM_RC Tpm::ParseResponse_GetRandom(
- const std::string& response,
- TPM2B_DIGEST* random_bytes,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_DIGEST* random_bytes,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -17926,9 +14802,7 @@
}
TPM_CC command_code = TPM_CC_GetRandom;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -17946,29 +14820,22 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string random_bytes_bytes;
- rc = Parse_TPM2B_DIGEST(
- &buffer,
- random_bytes,
- &random_bytes_bytes);
+ rc = Parse_TPM2B_DIGEST(&buffer, random_bytes, &random_bytes_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -17980,10 +14847,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
random_bytes_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_DIGEST(
- &random_bytes_bytes,
- random_bytes,
- nullptr);
+ rc = Parse_TPM2B_DIGEST(&random_bytes_bytes, random_bytes, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -17991,51 +14855,39 @@
return TPM_RC_SUCCESS;
}
-void GetRandomErrorCallback(
- const Tpm::GetRandomResponse& callback,
- TPM_RC response_code) {
+void GetRandomErrorCallback(const Tpm::GetRandomResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_DIGEST());
+ callback.Run(response_code, TPM2B_DIGEST());
}
-void GetRandomResponseParser(
- const Tpm::GetRandomResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void GetRandomResponseParser(const Tpm::GetRandomResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(GetRandomErrorCallback, callback);
TPM2B_DIGEST random_bytes;
- TPM_RC rc = Tpm::ParseResponse_GetRandom(
- response,
- &random_bytes,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_GetRandom(response, &random_bytes,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- random_bytes);
+ callback.Run(rc, random_bytes);
}
-void Tpm::GetRandom(
- const UINT16& bytes_requested,
- AuthorizationDelegate* authorization_delegate,
- const GetRandomResponse& callback) {
+void Tpm::GetRandom(const UINT16& bytes_requested,
+ AuthorizationDelegate* authorization_delegate,
+ const GetRandomResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(GetRandomErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(GetRandomResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(GetRandomResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_GetRandom(
- bytes_requested,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_GetRandom(bytes_requested, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -18043,31 +14895,25 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::GetRandomSync(
- const UINT16& bytes_requested,
- TPM2B_DIGEST* random_bytes,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::GetRandomSync(const UINT16& bytes_requested,
+ TPM2B_DIGEST* random_bytes,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_GetRandom(
- bytes_requested,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_GetRandom(bytes_requested, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_GetRandom(
- response,
- random_bytes,
- authorization_delegate);
+ rc = ParseResponse_GetRandom(response, random_bytes, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_StirRandom(
- const TPM2B_SENSITIVE_DATA& in_data,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPM2B_SENSITIVE_DATA& in_data,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -18078,16 +14924,12 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_data_bytes;
- rc = Serialize_TPM2B_SENSITIVE_DATA(
- in_data,
- &in_data_bytes);
+ rc = Serialize_TPM2B_SENSITIVE_DATA(in_data, &in_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -18099,12 +14941,10 @@
}
in_data_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(in_data_bytes.data(),
- in_data_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(in_data_bytes.data(), in_data_bytes.size());
parameter_section_bytes += in_data_bytes;
command_size += in_data_bytes.size();
std::string command_hash(32, 0);
@@ -18113,10 +14953,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -18127,31 +14966,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -18159,36 +14990,27 @@
}
TPM_RC Tpm::ParseResponse_StirRandom(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -18200,9 +15022,7 @@
}
TPM_CC command_code = TPM_CC_StirRandom;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -18220,68 +15040,54 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void StirRandomErrorCallback(
- const Tpm::StirRandomResponse& callback,
- TPM_RC response_code) {
+void StirRandomErrorCallback(const Tpm::StirRandomResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void StirRandomResponseParser(
- const Tpm::StirRandomResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void StirRandomResponseParser(const Tpm::StirRandomResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(StirRandomErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_StirRandom(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_StirRandom(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::StirRandom(
- const TPM2B_SENSITIVE_DATA& in_data,
- AuthorizationDelegate* authorization_delegate,
- const StirRandomResponse& callback) {
+void Tpm::StirRandom(const TPM2B_SENSITIVE_DATA& in_data,
+ AuthorizationDelegate* authorization_delegate,
+ const StirRandomResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(StirRandomErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(StirRandomResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(StirRandomResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_StirRandom(
- in_data,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_StirRandom(in_data, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -18289,32 +15095,27 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::StirRandomSync(
- const TPM2B_SENSITIVE_DATA& in_data,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::StirRandomSync(const TPM2B_SENSITIVE_DATA& in_data,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_StirRandom(
- in_data,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_StirRandom(in_data, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_StirRandom(
- response,
- authorization_delegate);
+ rc = ParseResponse_StirRandom(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_HMAC_Start(
- const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_AUTH& auth,
- const TPMI_ALG_HASH& hash_alg,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_AUTH& auth,
+ const TPMI_ALG_HASH& hash_alg,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -18325,30 +15126,22 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- handle,
- &handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(handle, &handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_bytes;
- rc = Serialize_TPM2B_AUTH(
- auth,
- &auth_bytes);
+ rc = Serialize_TPM2B_AUTH(auth, &auth_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string hash_alg_bytes;
- rc = Serialize_TPMI_ALG_HASH(
- hash_alg,
- &hash_alg_bytes);
+ rc = Serialize_TPMI_ALG_HASH(hash_alg, &hash_alg_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -18360,20 +15153,16 @@
}
auth_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(handle_name.data(),
- handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(handle_name.data(), handle_name.size());
handle_section_bytes += handle_bytes;
command_size += handle_bytes.size();
- hash->Update(auth_bytes.data(),
- auth_bytes.size());
+ hash->Update(auth_bytes.data(), auth_bytes.size());
parameter_section_bytes += auth_bytes;
command_size += auth_bytes.size();
- hash->Update(hash_alg_bytes.data(),
- hash_alg_bytes.size());
+ hash->Update(hash_alg_bytes.data(), hash_alg_bytes.size());
parameter_section_bytes += hash_alg_bytes;
command_size += hash_alg_bytes.size();
std::string command_hash(32, 0);
@@ -18382,10 +15171,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -18396,31 +15184,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -18428,37 +15208,28 @@
}
TPM_RC Tpm::ParseResponse_HMAC_Start(
- const std::string& response,
- TPMI_DH_OBJECT* sequence_handle,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPMI_DH_OBJECT* sequence_handle,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -18469,18 +15240,13 @@
return response_code;
}
std::string sequence_handle_bytes;
- rc = Parse_TPMI_DH_OBJECT(
- &buffer,
- sequence_handle,
- &sequence_handle_bytes);
+ rc = Parse_TPMI_DH_OBJECT(&buffer, sequence_handle, &sequence_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_CC command_code = TPM_CC_HMAC_Start;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -18498,78 +15264,59 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void HMAC_StartErrorCallback(
- const Tpm::HMAC_StartResponse& callback,
- TPM_RC response_code) {
+void HMAC_StartErrorCallback(const Tpm::HMAC_StartResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPMI_DH_OBJECT());
+ callback.Run(response_code, TPMI_DH_OBJECT());
}
-void HMAC_StartResponseParser(
- const Tpm::HMAC_StartResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void HMAC_StartResponseParser(const Tpm::HMAC_StartResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(HMAC_StartErrorCallback, callback);
TPMI_DH_OBJECT sequence_handle;
- TPM_RC rc = Tpm::ParseResponse_HMAC_Start(
- response,
- &sequence_handle,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_HMAC_Start(response, &sequence_handle,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- sequence_handle);
+ callback.Run(rc, sequence_handle);
}
-void Tpm::HMAC_Start(
- const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_AUTH& auth,
- const TPMI_ALG_HASH& hash_alg,
- AuthorizationDelegate* authorization_delegate,
- const HMAC_StartResponse& callback) {
+void Tpm::HMAC_Start(const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_AUTH& auth,
+ const TPMI_ALG_HASH& hash_alg,
+ AuthorizationDelegate* authorization_delegate,
+ const HMAC_StartResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(HMAC_StartErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(HMAC_StartResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(HMAC_StartResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_HMAC_Start(
- handle,
- handle_name,
- auth,
- hash_alg,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_HMAC_Start(handle, handle_name, auth, hash_alg,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -18577,38 +15324,30 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::HMAC_StartSync(
- const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_AUTH& auth,
- const TPMI_ALG_HASH& hash_alg,
- TPMI_DH_OBJECT* sequence_handle,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::HMAC_StartSync(const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_AUTH& auth,
+ const TPMI_ALG_HASH& hash_alg,
+ TPMI_DH_OBJECT* sequence_handle,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_HMAC_Start(
- handle,
- handle_name,
- auth,
- hash_alg,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_HMAC_Start(handle, handle_name, auth, hash_alg,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_HMAC_Start(
- response,
- sequence_handle,
- authorization_delegate);
+ rc = ParseResponse_HMAC_Start(response, sequence_handle,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_HashSequenceStart(
- const TPM2B_AUTH& auth,
- const TPMI_ALG_HASH& hash_alg,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPM2B_AUTH& auth,
+ const TPMI_ALG_HASH& hash_alg,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -18619,23 +15358,17 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_bytes;
- rc = Serialize_TPM2B_AUTH(
- auth,
- &auth_bytes);
+ rc = Serialize_TPM2B_AUTH(auth, &auth_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string hash_alg_bytes;
- rc = Serialize_TPMI_ALG_HASH(
- hash_alg,
- &hash_alg_bytes);
+ rc = Serialize_TPMI_ALG_HASH(hash_alg, &hash_alg_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -18647,16 +15380,13 @@
}
auth_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_bytes.data(),
- auth_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_bytes.data(), auth_bytes.size());
parameter_section_bytes += auth_bytes;
command_size += auth_bytes.size();
- hash->Update(hash_alg_bytes.data(),
- hash_alg_bytes.size());
+ hash->Update(hash_alg_bytes.data(), hash_alg_bytes.size());
parameter_section_bytes += hash_alg_bytes;
command_size += hash_alg_bytes.size();
std::string command_hash(32, 0);
@@ -18665,10 +15395,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -18679,31 +15408,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -18711,37 +15432,28 @@
}
TPM_RC Tpm::ParseResponse_HashSequenceStart(
- const std::string& response,
- TPMI_DH_OBJECT* sequence_handle,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPMI_DH_OBJECT* sequence_handle,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -18752,18 +15464,13 @@
return response_code;
}
std::string sequence_handle_bytes;
- rc = Parse_TPMI_DH_OBJECT(
- &buffer,
- sequence_handle,
- &sequence_handle_bytes);
+ rc = Parse_TPMI_DH_OBJECT(&buffer, sequence_handle, &sequence_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_CC command_code = TPM_CC_HashSequenceStart;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -18781,21 +15488,17 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
@@ -18806,8 +15509,7 @@
const Tpm::HashSequenceStartResponse& callback,
TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPMI_DH_OBJECT());
+ callback.Run(response_code, TPMI_DH_OBJECT());
}
void HashSequenceStartResponseParser(
@@ -18818,37 +15520,27 @@
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(HashSequenceStartErrorCallback, callback);
TPMI_DH_OBJECT sequence_handle;
- TPM_RC rc = Tpm::ParseResponse_HashSequenceStart(
- response,
- &sequence_handle,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_HashSequenceStart(response, &sequence_handle,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- sequence_handle);
+ callback.Run(rc, sequence_handle);
}
-void Tpm::HashSequenceStart(
- const TPM2B_AUTH& auth,
- const TPMI_ALG_HASH& hash_alg,
- AuthorizationDelegate* authorization_delegate,
- const HashSequenceStartResponse& callback) {
+void Tpm::HashSequenceStart(const TPM2B_AUTH& auth,
+ const TPMI_ALG_HASH& hash_alg,
+ AuthorizationDelegate* authorization_delegate,
+ const HashSequenceStartResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(HashSequenceStartErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(HashSequenceStartResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ HashSequenceStartResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_HashSequenceStart(
- auth,
- hash_alg,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_HashSequenceStart(auth, hash_alg, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -18857,34 +15549,29 @@
}
TPM_RC Tpm::HashSequenceStartSync(
- const TPM2B_AUTH& auth,
- const TPMI_ALG_HASH& hash_alg,
- TPMI_DH_OBJECT* sequence_handle,
- AuthorizationDelegate* authorization_delegate) {
+ const TPM2B_AUTH& auth,
+ const TPMI_ALG_HASH& hash_alg,
+ TPMI_DH_OBJECT* sequence_handle,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_HashSequenceStart(
- auth,
- hash_alg,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_HashSequenceStart(auth, hash_alg, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_HashSequenceStart(
- response,
- sequence_handle,
- authorization_delegate);
+ rc = ParseResponse_HashSequenceStart(response, sequence_handle,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_SequenceUpdate(
- const TPMI_DH_OBJECT& sequence_handle,
- const std::string& sequence_handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& sequence_handle,
+ const std::string& sequence_handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -18895,23 +15582,17 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string sequence_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- sequence_handle,
- &sequence_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(sequence_handle, &sequence_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string buffer_bytes;
- rc = Serialize_TPM2B_MAX_BUFFER(
- buffer,
- &buffer_bytes);
+ rc = Serialize_TPM2B_MAX_BUFFER(buffer, &buffer_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -18923,16 +15604,13 @@
}
buffer_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(sequence_handle_name.data(),
- sequence_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(sequence_handle_name.data(), sequence_handle_name.size());
handle_section_bytes += sequence_handle_bytes;
command_size += sequence_handle_bytes.size();
- hash->Update(buffer_bytes.data(),
- buffer_bytes.size());
+ hash->Update(buffer_bytes.data(), buffer_bytes.size());
parameter_section_bytes += buffer_bytes;
command_size += buffer_bytes.size();
std::string command_hash(32, 0);
@@ -18941,10 +15619,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -18955,31 +15632,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -18987,36 +15656,27 @@
}
TPM_RC Tpm::ParseResponse_SequenceUpdate(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -19028,9 +15688,7 @@
}
TPM_CC command_code = TPM_CC_SequenceUpdate;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -19048,72 +15706,58 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void SequenceUpdateErrorCallback(
- const Tpm::SequenceUpdateResponse& callback,
- TPM_RC response_code) {
+void SequenceUpdateErrorCallback(const Tpm::SequenceUpdateResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void SequenceUpdateResponseParser(
- const Tpm::SequenceUpdateResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void SequenceUpdateResponseParser(const Tpm::SequenceUpdateResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(SequenceUpdateErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_SequenceUpdate(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_SequenceUpdate(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::SequenceUpdate(
- const TPMI_DH_OBJECT& sequence_handle,
- const std::string& sequence_handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- AuthorizationDelegate* authorization_delegate,
- const SequenceUpdateResponse& callback) {
+void Tpm::SequenceUpdate(const TPMI_DH_OBJECT& sequence_handle,
+ const std::string& sequence_handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ AuthorizationDelegate* authorization_delegate,
+ const SequenceUpdateResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(SequenceUpdateErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(SequenceUpdateResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ SequenceUpdateResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_SequenceUpdate(
- sequence_handle,
- sequence_handle_name,
- buffer,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_SequenceUpdate(sequence_handle, sequence_handle_name,
+ buffer, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -19121,36 +15765,30 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::SequenceUpdateSync(
- const TPMI_DH_OBJECT& sequence_handle,
- const std::string& sequence_handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::SequenceUpdateSync(const TPMI_DH_OBJECT& sequence_handle,
+ const std::string& sequence_handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_SequenceUpdate(
- sequence_handle,
- sequence_handle_name,
- buffer,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_SequenceUpdate(sequence_handle, sequence_handle_name,
+ buffer, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_SequenceUpdate(
- response,
- authorization_delegate);
+ rc = ParseResponse_SequenceUpdate(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_SequenceComplete(
- const TPMI_DH_OBJECT& sequence_handle,
- const std::string& sequence_handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- const TPMI_RH_HIERARCHY& hierarchy,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& sequence_handle,
+ const std::string& sequence_handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -19161,30 +15799,22 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string sequence_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- sequence_handle,
- &sequence_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(sequence_handle, &sequence_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string buffer_bytes;
- rc = Serialize_TPM2B_MAX_BUFFER(
- buffer,
- &buffer_bytes);
+ rc = Serialize_TPM2B_MAX_BUFFER(buffer, &buffer_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string hierarchy_bytes;
- rc = Serialize_TPMI_RH_HIERARCHY(
- hierarchy,
- &hierarchy_bytes);
+ rc = Serialize_TPMI_RH_HIERARCHY(hierarchy, &hierarchy_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -19196,20 +15826,16 @@
}
buffer_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(sequence_handle_name.data(),
- sequence_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(sequence_handle_name.data(), sequence_handle_name.size());
handle_section_bytes += sequence_handle_bytes;
command_size += sequence_handle_bytes.size();
- hash->Update(buffer_bytes.data(),
- buffer_bytes.size());
+ hash->Update(buffer_bytes.data(), buffer_bytes.size());
parameter_section_bytes += buffer_bytes;
command_size += buffer_bytes.size();
- hash->Update(hierarchy_bytes.data(),
- hierarchy_bytes.size());
+ hash->Update(hierarchy_bytes.data(), hierarchy_bytes.size());
parameter_section_bytes += hierarchy_bytes;
command_size += hierarchy_bytes.size();
std::string command_hash(32, 0);
@@ -19218,10 +15844,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -19232,31 +15857,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -19264,38 +15881,29 @@
}
TPM_RC Tpm::ParseResponse_SequenceComplete(
- const std::string& response,
- TPM2B_DIGEST* result,
- TPMT_TK_HASHCHECK* validation,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_DIGEST* result,
+ TPMT_TK_HASHCHECK* validation,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -19307,9 +15915,7 @@
}
TPM_CC command_code = TPM_CC_SequenceComplete;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -19327,37 +15933,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string result_bytes;
- rc = Parse_TPM2B_DIGEST(
- &buffer,
- result,
- &result_bytes);
+ rc = Parse_TPM2B_DIGEST(&buffer, result, &result_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string validation_bytes;
- rc = Parse_TPMT_TK_HASHCHECK(
- &buffer,
- validation,
- &validation_bytes);
+ rc = Parse_TPMT_TK_HASHCHECK(&buffer, validation, &validation_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -19369,10 +15965,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
result_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_DIGEST(
- &result_bytes,
- result,
- nullptr);
+ rc = Parse_TPM2B_DIGEST(&result_bytes, result, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -19384,9 +15977,7 @@
const Tpm::SequenceCompleteResponse& callback,
TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_DIGEST(),
- TPMT_TK_HASHCHECK());
+ callback.Run(response_code, TPM2B_DIGEST(), TPMT_TK_HASHCHECK());
}
void SequenceCompleteResponseParser(
@@ -19399,41 +15990,28 @@
TPM2B_DIGEST result;
TPMT_TK_HASHCHECK validation;
TPM_RC rc = Tpm::ParseResponse_SequenceComplete(
- response,
- &result,
- &validation,
- authorization_delegate);
+ response, &result, &validation, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- result,
- validation);
+ callback.Run(rc, result, validation);
}
-void Tpm::SequenceComplete(
- const TPMI_DH_OBJECT& sequence_handle,
- const std::string& sequence_handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- const TPMI_RH_HIERARCHY& hierarchy,
- AuthorizationDelegate* authorization_delegate,
- const SequenceCompleteResponse& callback) {
+void Tpm::SequenceComplete(const TPMI_DH_OBJECT& sequence_handle,
+ const std::string& sequence_handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ AuthorizationDelegate* authorization_delegate,
+ const SequenceCompleteResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(SequenceCompleteErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(SequenceCompleteResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ SequenceCompleteResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_SequenceComplete(
- sequence_handle,
- sequence_handle_name,
- buffer,
- hierarchy,
- &command,
+ sequence_handle, sequence_handle_name, buffer, hierarchy, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
@@ -19443,42 +16021,35 @@
}
TPM_RC Tpm::SequenceCompleteSync(
- const TPMI_DH_OBJECT& sequence_handle,
- const std::string& sequence_handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- const TPMI_RH_HIERARCHY& hierarchy,
- TPM2B_DIGEST* result,
- TPMT_TK_HASHCHECK* validation,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& sequence_handle,
+ const std::string& sequence_handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ TPM2B_DIGEST* result,
+ TPMT_TK_HASHCHECK* validation,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_SequenceComplete(
- sequence_handle,
- sequence_handle_name,
- buffer,
- hierarchy,
- &command,
+ sequence_handle, sequence_handle_name, buffer, hierarchy, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_SequenceComplete(
- response,
- result,
- validation,
- authorization_delegate);
+ rc = ParseResponse_SequenceComplete(response, result, validation,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_EventSequenceComplete(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPMI_DH_OBJECT& sequence_handle,
- const std::string& sequence_handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPMI_DH_OBJECT& sequence_handle,
+ const std::string& sequence_handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -19489,30 +16060,22 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string pcr_handle_bytes;
- rc = Serialize_TPMI_DH_PCR(
- pcr_handle,
- &pcr_handle_bytes);
+ rc = Serialize_TPMI_DH_PCR(pcr_handle, &pcr_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string sequence_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- sequence_handle,
- &sequence_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(sequence_handle, &sequence_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string buffer_bytes;
- rc = Serialize_TPM2B_MAX_BUFFER(
- buffer,
- &buffer_bytes);
+ rc = Serialize_TPM2B_MAX_BUFFER(buffer, &buffer_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -19524,20 +16087,16 @@
}
buffer_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(pcr_handle_name.data(),
- pcr_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(pcr_handle_name.data(), pcr_handle_name.size());
handle_section_bytes += pcr_handle_bytes;
command_size += pcr_handle_bytes.size();
- hash->Update(sequence_handle_name.data(),
- sequence_handle_name.size());
+ hash->Update(sequence_handle_name.data(), sequence_handle_name.size());
handle_section_bytes += sequence_handle_bytes;
command_size += sequence_handle_bytes.size();
- hash->Update(buffer_bytes.data(),
- buffer_bytes.size());
+ hash->Update(buffer_bytes.data(), buffer_bytes.size());
parameter_section_bytes += buffer_bytes;
command_size += buffer_bytes.size();
std::string command_hash(32, 0);
@@ -19546,10 +16105,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -19560,31 +16118,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -19592,37 +16142,28 @@
}
TPM_RC Tpm::ParseResponse_EventSequenceComplete(
- const std::string& response,
- TPML_DIGEST_VALUES* results,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPML_DIGEST_VALUES* results,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -19634,9 +16175,7 @@
}
TPM_CC command_code = TPM_CC_EventSequenceComplete;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -19654,29 +16193,22 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string results_bytes;
- rc = Parse_TPML_DIGEST_VALUES(
- &buffer,
- results,
- &results_bytes);
+ rc = Parse_TPML_DIGEST_VALUES(&buffer, results, &results_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -19687,8 +16219,7 @@
const Tpm::EventSequenceCompleteResponse& callback,
TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPML_DIGEST_VALUES());
+ callback.Run(response_code, TPML_DIGEST_VALUES());
}
void EventSequenceCompleteResponseParser(
@@ -19699,43 +16230,31 @@
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(EventSequenceCompleteErrorCallback, callback);
TPML_DIGEST_VALUES results;
- TPM_RC rc = Tpm::ParseResponse_EventSequenceComplete(
- response,
- &results,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_EventSequenceComplete(response, &results,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- results);
+ callback.Run(rc, results);
}
-void Tpm::EventSequenceComplete(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPMI_DH_OBJECT& sequence_handle,
- const std::string& sequence_handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- AuthorizationDelegate* authorization_delegate,
- const EventSequenceCompleteResponse& callback) {
+void Tpm::EventSequenceComplete(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPMI_DH_OBJECT& sequence_handle,
+ const std::string& sequence_handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ AuthorizationDelegate* authorization_delegate,
+ const EventSequenceCompleteResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(EventSequenceCompleteErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(EventSequenceCompleteResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ EventSequenceCompleteResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_EventSequenceComplete(
- pcr_handle,
- pcr_handle_name,
- sequence_handle,
- sequence_handle_name,
- buffer,
- &command,
- authorization_delegate);
+ pcr_handle, pcr_handle_name, sequence_handle, sequence_handle_name,
+ buffer, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -19744,43 +16263,36 @@
}
TPM_RC Tpm::EventSequenceCompleteSync(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPMI_DH_OBJECT& sequence_handle,
- const std::string& sequence_handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- TPML_DIGEST_VALUES* results,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPMI_DH_OBJECT& sequence_handle,
+ const std::string& sequence_handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ TPML_DIGEST_VALUES* results,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_EventSequenceComplete(
- pcr_handle,
- pcr_handle_name,
- sequence_handle,
- sequence_handle_name,
- buffer,
- &command,
- authorization_delegate);
+ pcr_handle, pcr_handle_name, sequence_handle, sequence_handle_name,
+ buffer, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_EventSequenceComplete(
- response,
- results,
- authorization_delegate);
+ rc = ParseResponse_EventSequenceComplete(response, results,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_Certify(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -19791,37 +16303,27 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string object_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- object_handle,
- &object_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(object_handle, &object_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string sign_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- sign_handle,
- &sign_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(sign_handle, &sign_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string qualifying_data_bytes;
- rc = Serialize_TPM2B_DATA(
- qualifying_data,
- &qualifying_data_bytes);
+ rc = Serialize_TPM2B_DATA(qualifying_data, &qualifying_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_scheme_bytes;
- rc = Serialize_TPMT_SIG_SCHEME(
- in_scheme,
- &in_scheme_bytes);
+ rc = Serialize_TPMT_SIG_SCHEME(in_scheme, &in_scheme_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -19833,24 +16335,19 @@
}
qualifying_data_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(object_handle_name.data(),
- object_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(object_handle_name.data(), object_handle_name.size());
handle_section_bytes += object_handle_bytes;
command_size += object_handle_bytes.size();
- hash->Update(sign_handle_name.data(),
- sign_handle_name.size());
+ hash->Update(sign_handle_name.data(), sign_handle_name.size());
handle_section_bytes += sign_handle_bytes;
command_size += sign_handle_bytes.size();
- hash->Update(qualifying_data_bytes.data(),
- qualifying_data_bytes.size());
+ hash->Update(qualifying_data_bytes.data(), qualifying_data_bytes.size());
parameter_section_bytes += qualifying_data_bytes;
command_size += qualifying_data_bytes.size();
- hash->Update(in_scheme_bytes.data(),
- in_scheme_bytes.size());
+ hash->Update(in_scheme_bytes.data(), in_scheme_bytes.size());
parameter_section_bytes += in_scheme_bytes;
command_size += in_scheme_bytes.size();
std::string command_hash(32, 0);
@@ -19859,10 +16356,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -19873,31 +16369,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -19905,38 +16393,29 @@
}
TPM_RC Tpm::ParseResponse_Certify(
- const std::string& response,
- TPM2B_ATTEST* certify_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_ATTEST* certify_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -19948,9 +16427,7 @@
}
TPM_CC command_code = TPM_CC_Certify;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -19968,37 +16445,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string certify_info_bytes;
- rc = Parse_TPM2B_ATTEST(
- &buffer,
- certify_info,
- &certify_info_bytes);
+ rc = Parse_TPM2B_ATTEST(&buffer, certify_info, &certify_info_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string signature_bytes;
- rc = Parse_TPMT_SIGNATURE(
- &buffer,
- signature,
- &signature_bytes);
+ rc = Parse_TPMT_SIGNATURE(&buffer, signature, &signature_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -20010,10 +16477,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
certify_info_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_ATTEST(
- &certify_info_bytes,
- certify_info,
- nullptr);
+ rc = Parse_TPM2B_ATTEST(&certify_info_bytes, certify_info, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -20021,65 +16485,46 @@
return TPM_RC_SUCCESS;
}
-void CertifyErrorCallback(
- const Tpm::CertifyResponse& callback,
- TPM_RC response_code) {
+void CertifyErrorCallback(const Tpm::CertifyResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_ATTEST(),
- TPMT_SIGNATURE());
+ callback.Run(response_code, TPM2B_ATTEST(), TPMT_SIGNATURE());
}
-void CertifyResponseParser(
- const Tpm::CertifyResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void CertifyResponseParser(const Tpm::CertifyResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(CertifyErrorCallback, callback);
TPM2B_ATTEST certify_info;
TPMT_SIGNATURE signature;
- TPM_RC rc = Tpm::ParseResponse_Certify(
- response,
- &certify_info,
- &signature,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_Certify(response, &certify_info, &signature,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- certify_info,
- signature);
+ callback.Run(rc, certify_info, signature);
}
-void Tpm::Certify(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- AuthorizationDelegate* authorization_delegate,
- const CertifyResponse& callback) {
+void Tpm::Certify(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ AuthorizationDelegate* authorization_delegate,
+ const CertifyResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(CertifyErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(CertifyResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(CertifyResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_Certify(
- object_handle,
- object_handle_name,
- sign_handle,
- sign_handle_name,
- qualifying_data,
- in_scheme,
- &command,
- authorization_delegate);
+ object_handle, object_handle_name, sign_handle, sign_handle_name,
+ qualifying_data, in_scheme, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -20087,50 +16532,40 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::CertifySync(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- TPM2B_ATTEST* certify_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::CertifySync(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ TPM2B_ATTEST* certify_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_Certify(
- object_handle,
- object_handle_name,
- sign_handle,
- sign_handle_name,
- qualifying_data,
- in_scheme,
- &command,
- authorization_delegate);
+ object_handle, object_handle_name, sign_handle, sign_handle_name,
+ qualifying_data, in_scheme, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_Certify(
- response,
- certify_info,
- signature,
- authorization_delegate);
+ rc = ParseResponse_Certify(response, certify_info, signature,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_CertifyCreation(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPM2B_DIGEST& creation_hash,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPMT_TK_CREATION& creation_ticket,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPM2B_DIGEST& creation_hash,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPMT_TK_CREATION& creation_ticket,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -20141,51 +16576,37 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string sign_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- sign_handle,
- &sign_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(sign_handle, &sign_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string object_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- object_handle,
- &object_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(object_handle, &object_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string qualifying_data_bytes;
- rc = Serialize_TPM2B_DATA(
- qualifying_data,
- &qualifying_data_bytes);
+ rc = Serialize_TPM2B_DATA(qualifying_data, &qualifying_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string creation_hash_bytes;
- rc = Serialize_TPM2B_DIGEST(
- creation_hash,
- &creation_hash_bytes);
+ rc = Serialize_TPM2B_DIGEST(creation_hash, &creation_hash_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_scheme_bytes;
- rc = Serialize_TPMT_SIG_SCHEME(
- in_scheme,
- &in_scheme_bytes);
+ rc = Serialize_TPMT_SIG_SCHEME(in_scheme, &in_scheme_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string creation_ticket_bytes;
- rc = Serialize_TPMT_TK_CREATION(
- creation_ticket,
- &creation_ticket_bytes);
+ rc = Serialize_TPMT_TK_CREATION(creation_ticket, &creation_ticket_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -20197,32 +16618,25 @@
}
qualifying_data_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(sign_handle_name.data(),
- sign_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(sign_handle_name.data(), sign_handle_name.size());
handle_section_bytes += sign_handle_bytes;
command_size += sign_handle_bytes.size();
- hash->Update(object_handle_name.data(),
- object_handle_name.size());
+ hash->Update(object_handle_name.data(), object_handle_name.size());
handle_section_bytes += object_handle_bytes;
command_size += object_handle_bytes.size();
- hash->Update(qualifying_data_bytes.data(),
- qualifying_data_bytes.size());
+ hash->Update(qualifying_data_bytes.data(), qualifying_data_bytes.size());
parameter_section_bytes += qualifying_data_bytes;
command_size += qualifying_data_bytes.size();
- hash->Update(creation_hash_bytes.data(),
- creation_hash_bytes.size());
+ hash->Update(creation_hash_bytes.data(), creation_hash_bytes.size());
parameter_section_bytes += creation_hash_bytes;
command_size += creation_hash_bytes.size();
- hash->Update(in_scheme_bytes.data(),
- in_scheme_bytes.size());
+ hash->Update(in_scheme_bytes.data(), in_scheme_bytes.size());
parameter_section_bytes += in_scheme_bytes;
command_size += in_scheme_bytes.size();
- hash->Update(creation_ticket_bytes.data(),
- creation_ticket_bytes.size());
+ hash->Update(creation_ticket_bytes.data(), creation_ticket_bytes.size());
parameter_section_bytes += creation_ticket_bytes;
command_size += creation_ticket_bytes.size();
std::string command_hash(32, 0);
@@ -20231,10 +16645,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -20245,31 +16658,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -20277,38 +16682,29 @@
}
TPM_RC Tpm::ParseResponse_CertifyCreation(
- const std::string& response,
- TPM2B_ATTEST* certify_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_ATTEST* certify_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -20320,9 +16716,7 @@
}
TPM_CC command_code = TPM_CC_CertifyCreation;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -20340,37 +16734,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string certify_info_bytes;
- rc = Parse_TPM2B_ATTEST(
- &buffer,
- certify_info,
- &certify_info_bytes);
+ rc = Parse_TPM2B_ATTEST(&buffer, certify_info, &certify_info_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string signature_bytes;
- rc = Parse_TPMT_SIGNATURE(
- &buffer,
- signature,
- &signature_bytes);
+ rc = Parse_TPMT_SIGNATURE(&buffer, signature, &signature_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -20382,10 +16766,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
certify_info_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_ATTEST(
- &certify_info_bytes,
- certify_info,
- nullptr);
+ rc = Parse_TPM2B_ATTEST(&certify_info_bytes, certify_info, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -20393,13 +16774,10 @@
return TPM_RC_SUCCESS;
}
-void CertifyCreationErrorCallback(
- const Tpm::CertifyCreationResponse& callback,
- TPM_RC response_code) {
+void CertifyCreationErrorCallback(const Tpm::CertifyCreationResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_ATTEST(),
- TPMT_SIGNATURE());
+ callback.Run(response_code, TPM2B_ATTEST(), TPMT_SIGNATURE());
}
void CertifyCreationResponseParser(
@@ -20412,49 +16790,33 @@
TPM2B_ATTEST certify_info;
TPMT_SIGNATURE signature;
TPM_RC rc = Tpm::ParseResponse_CertifyCreation(
- response,
- &certify_info,
- &signature,
- authorization_delegate);
+ response, &certify_info, &signature, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- certify_info,
- signature);
+ callback.Run(rc, certify_info, signature);
}
-void Tpm::CertifyCreation(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPM2B_DIGEST& creation_hash,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPMT_TK_CREATION& creation_ticket,
- AuthorizationDelegate* authorization_delegate,
- const CertifyCreationResponse& callback) {
+void Tpm::CertifyCreation(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPM2B_DIGEST& creation_hash,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPMT_TK_CREATION& creation_ticket,
+ AuthorizationDelegate* authorization_delegate,
+ const CertifyCreationResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(CertifyCreationErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(CertifyCreationResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ CertifyCreationResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_CertifyCreation(
- sign_handle,
- sign_handle_name,
- object_handle,
- object_handle_name,
- qualifying_data,
- creation_hash,
- in_scheme,
- creation_ticket,
- &command,
+ sign_handle, sign_handle_name, object_handle, object_handle_name,
+ qualifying_data, creation_hash, in_scheme, creation_ticket, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
@@ -20463,51 +16825,40 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::CertifyCreationSync(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPM2B_DIGEST& creation_hash,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPMT_TK_CREATION& creation_ticket,
- TPM2B_ATTEST* certify_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::CertifyCreationSync(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPM2B_DIGEST& creation_hash,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPMT_TK_CREATION& creation_ticket,
+ TPM2B_ATTEST* certify_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_CertifyCreation(
- sign_handle,
- sign_handle_name,
- object_handle,
- object_handle_name,
- qualifying_data,
- creation_hash,
- in_scheme,
- creation_ticket,
- &command,
+ sign_handle, sign_handle_name, object_handle, object_handle_name,
+ qualifying_data, creation_hash, in_scheme, creation_ticket, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_CertifyCreation(
- response,
- certify_info,
- signature,
- authorization_delegate);
+ rc = ParseResponse_CertifyCreation(response, certify_info, signature,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_Quote(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPML_PCR_SELECTION& pcrselect,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPML_PCR_SELECTION& pcrselect,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -20518,37 +16869,27 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string sign_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- sign_handle,
- &sign_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(sign_handle, &sign_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string qualifying_data_bytes;
- rc = Serialize_TPM2B_DATA(
- qualifying_data,
- &qualifying_data_bytes);
+ rc = Serialize_TPM2B_DATA(qualifying_data, &qualifying_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_scheme_bytes;
- rc = Serialize_TPMT_SIG_SCHEME(
- in_scheme,
- &in_scheme_bytes);
+ rc = Serialize_TPMT_SIG_SCHEME(in_scheme, &in_scheme_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string pcrselect_bytes;
- rc = Serialize_TPML_PCR_SELECTION(
- pcrselect,
- &pcrselect_bytes);
+ rc = Serialize_TPML_PCR_SELECTION(pcrselect, &pcrselect_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -20560,24 +16901,19 @@
}
qualifying_data_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(sign_handle_name.data(),
- sign_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(sign_handle_name.data(), sign_handle_name.size());
handle_section_bytes += sign_handle_bytes;
command_size += sign_handle_bytes.size();
- hash->Update(qualifying_data_bytes.data(),
- qualifying_data_bytes.size());
+ hash->Update(qualifying_data_bytes.data(), qualifying_data_bytes.size());
parameter_section_bytes += qualifying_data_bytes;
command_size += qualifying_data_bytes.size();
- hash->Update(in_scheme_bytes.data(),
- in_scheme_bytes.size());
+ hash->Update(in_scheme_bytes.data(), in_scheme_bytes.size());
parameter_section_bytes += in_scheme_bytes;
command_size += in_scheme_bytes.size();
- hash->Update(pcrselect_bytes.data(),
- pcrselect_bytes.size());
+ hash->Update(pcrselect_bytes.data(), pcrselect_bytes.size());
parameter_section_bytes += pcrselect_bytes;
command_size += pcrselect_bytes.size();
std::string command_hash(32, 0);
@@ -20586,10 +16922,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -20600,70 +16935,52 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
return TPM_RC_SUCCESS;
}
-TPM_RC Tpm::ParseResponse_Quote(
- const std::string& response,
- TPM2B_ATTEST* quoted,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ParseResponse_Quote(const std::string& response,
+ TPM2B_ATTEST* quoted,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -20675,9 +16992,7 @@
}
TPM_CC command_code = TPM_CC_Quote;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -20695,37 +17010,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string quoted_bytes;
- rc = Parse_TPM2B_ATTEST(
- &buffer,
- quoted,
- "ed_bytes);
+ rc = Parse_TPM2B_ATTEST(&buffer, quoted, "ed_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string signature_bytes;
- rc = Parse_TPMT_SIGNATURE(
- &buffer,
- signature,
- &signature_bytes);
+ rc = Parse_TPMT_SIGNATURE(&buffer, signature, &signature_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -20737,10 +17042,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
quoted_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_ATTEST(
- "ed_bytes,
- quoted,
- nullptr);
+ rc = Parse_TPM2B_ATTEST("ed_bytes, quoted, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -20748,63 +17050,45 @@
return TPM_RC_SUCCESS;
}
-void QuoteErrorCallback(
- const Tpm::QuoteResponse& callback,
- TPM_RC response_code) {
+void QuoteErrorCallback(const Tpm::QuoteResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_ATTEST(),
- TPMT_SIGNATURE());
+ callback.Run(response_code, TPM2B_ATTEST(), TPMT_SIGNATURE());
}
-void QuoteResponseParser(
- const Tpm::QuoteResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void QuoteResponseParser(const Tpm::QuoteResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(QuoteErrorCallback, callback);
TPM2B_ATTEST quoted;
TPMT_SIGNATURE signature;
- TPM_RC rc = Tpm::ParseResponse_Quote(
- response,
- "ed,
- &signature,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_Quote(response, "ed, &signature,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- quoted,
- signature);
+ callback.Run(rc, quoted, signature);
}
-void Tpm::Quote(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPML_PCR_SELECTION& pcrselect,
- AuthorizationDelegate* authorization_delegate,
- const QuoteResponse& callback) {
+void Tpm::Quote(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPML_PCR_SELECTION& pcrselect,
+ AuthorizationDelegate* authorization_delegate,
+ const QuoteResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(QuoteErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(QuoteResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(QuoteResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_Quote(
- sign_handle,
- sign_handle_name,
- qualifying_data,
- in_scheme,
- pcrselect,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_Quote(sign_handle, sign_handle_name,
+ qualifying_data, in_scheme, pcrselect,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -20812,48 +17096,38 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::QuoteSync(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPML_PCR_SELECTION& pcrselect,
- TPM2B_ATTEST* quoted,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::QuoteSync(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPML_PCR_SELECTION& pcrselect,
+ TPM2B_ATTEST* quoted,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_Quote(
- sign_handle,
- sign_handle_name,
- qualifying_data,
- in_scheme,
- pcrselect,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_Quote(sign_handle, sign_handle_name,
+ qualifying_data, in_scheme, pcrselect,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_Quote(
- response,
- quoted,
- signature,
- authorization_delegate);
+ rc = ParseResponse_Quote(response, quoted, signature, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_GetSessionAuditDigest(
- const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
- const std::string& privacy_admin_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPMI_SH_HMAC& session_handle,
- const std::string& session_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
+ const std::string& privacy_admin_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPMI_SH_HMAC& session_handle,
+ const std::string& session_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -20864,44 +17138,33 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string privacy_admin_handle_bytes;
- rc = Serialize_TPMI_RH_ENDORSEMENT(
- privacy_admin_handle,
- &privacy_admin_handle_bytes);
+ rc = Serialize_TPMI_RH_ENDORSEMENT(privacy_admin_handle,
+ &privacy_admin_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string sign_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- sign_handle,
- &sign_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(sign_handle, &sign_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string session_handle_bytes;
- rc = Serialize_TPMI_SH_HMAC(
- session_handle,
- &session_handle_bytes);
+ rc = Serialize_TPMI_SH_HMAC(session_handle, &session_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string qualifying_data_bytes;
- rc = Serialize_TPM2B_DATA(
- qualifying_data,
- &qualifying_data_bytes);
+ rc = Serialize_TPM2B_DATA(qualifying_data, &qualifying_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_scheme_bytes;
- rc = Serialize_TPMT_SIG_SCHEME(
- in_scheme,
- &in_scheme_bytes);
+ rc = Serialize_TPMT_SIG_SCHEME(in_scheme, &in_scheme_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -20913,28 +17176,23 @@
}
qualifying_data_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
hash->Update(privacy_admin_handle_name.data(),
privacy_admin_handle_name.size());
handle_section_bytes += privacy_admin_handle_bytes;
command_size += privacy_admin_handle_bytes.size();
- hash->Update(sign_handle_name.data(),
- sign_handle_name.size());
+ hash->Update(sign_handle_name.data(), sign_handle_name.size());
handle_section_bytes += sign_handle_bytes;
command_size += sign_handle_bytes.size();
- hash->Update(session_handle_name.data(),
- session_handle_name.size());
+ hash->Update(session_handle_name.data(), session_handle_name.size());
handle_section_bytes += session_handle_bytes;
command_size += session_handle_bytes.size();
- hash->Update(qualifying_data_bytes.data(),
- qualifying_data_bytes.size());
+ hash->Update(qualifying_data_bytes.data(), qualifying_data_bytes.size());
parameter_section_bytes += qualifying_data_bytes;
command_size += qualifying_data_bytes.size();
- hash->Update(in_scheme_bytes.data(),
- in_scheme_bytes.size());
+ hash->Update(in_scheme_bytes.data(), in_scheme_bytes.size());
parameter_section_bytes += in_scheme_bytes;
command_size += in_scheme_bytes.size();
std::string command_hash(32, 0);
@@ -20943,10 +17201,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -20957,31 +17214,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -20989,38 +17238,29 @@
}
TPM_RC Tpm::ParseResponse_GetSessionAuditDigest(
- const std::string& response,
- TPM2B_ATTEST* audit_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_ATTEST* audit_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -21032,9 +17272,7 @@
}
TPM_CC command_code = TPM_CC_GetSessionAuditDigest;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -21052,37 +17290,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string audit_info_bytes;
- rc = Parse_TPM2B_ATTEST(
- &buffer,
- audit_info,
- &audit_info_bytes);
+ rc = Parse_TPM2B_ATTEST(&buffer, audit_info, &audit_info_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string signature_bytes;
- rc = Parse_TPMT_SIGNATURE(
- &buffer,
- signature,
- &signature_bytes);
+ rc = Parse_TPMT_SIGNATURE(&buffer, signature, &signature_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -21094,10 +17322,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
audit_info_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_ATTEST(
- &audit_info_bytes,
- audit_info,
- nullptr);
+ rc = Parse_TPM2B_ATTEST(&audit_info_bytes, audit_info, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -21109,9 +17334,7 @@
const Tpm::GetSessionAuditDigestResponse& callback,
TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_ATTEST(),
- TPMT_SIGNATURE());
+ callback.Run(response_code, TPM2B_ATTEST(), TPMT_SIGNATURE());
}
void GetSessionAuditDigestResponseParser(
@@ -21124,50 +17347,34 @@
TPM2B_ATTEST audit_info;
TPMT_SIGNATURE signature;
TPM_RC rc = Tpm::ParseResponse_GetSessionAuditDigest(
- response,
- &audit_info,
- &signature,
- authorization_delegate);
+ response, &audit_info, &signature, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- audit_info,
- signature);
+ callback.Run(rc, audit_info, signature);
}
-void Tpm::GetSessionAuditDigest(
- const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
- const std::string& privacy_admin_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPMI_SH_HMAC& session_handle,
- const std::string& session_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- AuthorizationDelegate* authorization_delegate,
- const GetSessionAuditDigestResponse& callback) {
+void Tpm::GetSessionAuditDigest(const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
+ const std::string& privacy_admin_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPMI_SH_HMAC& session_handle,
+ const std::string& session_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ AuthorizationDelegate* authorization_delegate,
+ const GetSessionAuditDigestResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(GetSessionAuditDigestErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(GetSessionAuditDigestResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ GetSessionAuditDigestResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_GetSessionAuditDigest(
- privacy_admin_handle,
- privacy_admin_handle_name,
- sign_handle,
- sign_handle_name,
- session_handle,
- session_handle_name,
- qualifying_data,
- in_scheme,
- &command,
- authorization_delegate);
+ privacy_admin_handle, privacy_admin_handle_name, sign_handle,
+ sign_handle_name, session_handle, session_handle_name, qualifying_data,
+ in_scheme, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -21176,51 +17383,41 @@
}
TPM_RC Tpm::GetSessionAuditDigestSync(
- const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
- const std::string& privacy_admin_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPMI_SH_HMAC& session_handle,
- const std::string& session_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- TPM2B_ATTEST* audit_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
+ const std::string& privacy_admin_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPMI_SH_HMAC& session_handle,
+ const std::string& session_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ TPM2B_ATTEST* audit_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_GetSessionAuditDigest(
- privacy_admin_handle,
- privacy_admin_handle_name,
- sign_handle,
- sign_handle_name,
- session_handle,
- session_handle_name,
- qualifying_data,
- in_scheme,
- &command,
- authorization_delegate);
+ privacy_admin_handle, privacy_admin_handle_name, sign_handle,
+ sign_handle_name, session_handle, session_handle_name, qualifying_data,
+ in_scheme, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_GetSessionAuditDigest(
- response,
- audit_info,
- signature,
- authorization_delegate);
+ rc = ParseResponse_GetSessionAuditDigest(response, audit_info, signature,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_GetCommandAuditDigest(
- const TPMI_RH_ENDORSEMENT& privacy_handle,
- const std::string& privacy_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_ENDORSEMENT& privacy_handle,
+ const std::string& privacy_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -21231,37 +17428,27 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string privacy_handle_bytes;
- rc = Serialize_TPMI_RH_ENDORSEMENT(
- privacy_handle,
- &privacy_handle_bytes);
+ rc = Serialize_TPMI_RH_ENDORSEMENT(privacy_handle, &privacy_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string sign_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- sign_handle,
- &sign_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(sign_handle, &sign_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string qualifying_data_bytes;
- rc = Serialize_TPM2B_DATA(
- qualifying_data,
- &qualifying_data_bytes);
+ rc = Serialize_TPM2B_DATA(qualifying_data, &qualifying_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_scheme_bytes;
- rc = Serialize_TPMT_SIG_SCHEME(
- in_scheme,
- &in_scheme_bytes);
+ rc = Serialize_TPMT_SIG_SCHEME(in_scheme, &in_scheme_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -21273,24 +17460,19 @@
}
qualifying_data_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(privacy_handle_name.data(),
- privacy_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(privacy_handle_name.data(), privacy_handle_name.size());
handle_section_bytes += privacy_handle_bytes;
command_size += privacy_handle_bytes.size();
- hash->Update(sign_handle_name.data(),
- sign_handle_name.size());
+ hash->Update(sign_handle_name.data(), sign_handle_name.size());
handle_section_bytes += sign_handle_bytes;
command_size += sign_handle_bytes.size();
- hash->Update(qualifying_data_bytes.data(),
- qualifying_data_bytes.size());
+ hash->Update(qualifying_data_bytes.data(), qualifying_data_bytes.size());
parameter_section_bytes += qualifying_data_bytes;
command_size += qualifying_data_bytes.size();
- hash->Update(in_scheme_bytes.data(),
- in_scheme_bytes.size());
+ hash->Update(in_scheme_bytes.data(), in_scheme_bytes.size());
parameter_section_bytes += in_scheme_bytes;
command_size += in_scheme_bytes.size();
std::string command_hash(32, 0);
@@ -21299,10 +17481,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -21313,31 +17494,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -21345,38 +17518,29 @@
}
TPM_RC Tpm::ParseResponse_GetCommandAuditDigest(
- const std::string& response,
- TPM2B_ATTEST* audit_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_ATTEST* audit_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -21388,9 +17552,7 @@
}
TPM_CC command_code = TPM_CC_GetCommandAuditDigest;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -21408,37 +17570,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string audit_info_bytes;
- rc = Parse_TPM2B_ATTEST(
- &buffer,
- audit_info,
- &audit_info_bytes);
+ rc = Parse_TPM2B_ATTEST(&buffer, audit_info, &audit_info_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string signature_bytes;
- rc = Parse_TPMT_SIGNATURE(
- &buffer,
- signature,
- &signature_bytes);
+ rc = Parse_TPMT_SIGNATURE(&buffer, signature, &signature_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -21450,10 +17602,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
audit_info_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_ATTEST(
- &audit_info_bytes,
- audit_info,
- nullptr);
+ rc = Parse_TPM2B_ATTEST(&audit_info_bytes, audit_info, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -21465,9 +17614,7 @@
const Tpm::GetCommandAuditDigestResponse& callback,
TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_ATTEST(),
- TPMT_SIGNATURE());
+ callback.Run(response_code, TPM2B_ATTEST(), TPMT_SIGNATURE());
}
void GetCommandAuditDigestResponseParser(
@@ -21480,46 +17627,31 @@
TPM2B_ATTEST audit_info;
TPMT_SIGNATURE signature;
TPM_RC rc = Tpm::ParseResponse_GetCommandAuditDigest(
- response,
- &audit_info,
- &signature,
- authorization_delegate);
+ response, &audit_info, &signature, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- audit_info,
- signature);
+ callback.Run(rc, audit_info, signature);
}
-void Tpm::GetCommandAuditDigest(
- const TPMI_RH_ENDORSEMENT& privacy_handle,
- const std::string& privacy_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- AuthorizationDelegate* authorization_delegate,
- const GetCommandAuditDigestResponse& callback) {
+void Tpm::GetCommandAuditDigest(const TPMI_RH_ENDORSEMENT& privacy_handle,
+ const std::string& privacy_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ AuthorizationDelegate* authorization_delegate,
+ const GetCommandAuditDigestResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(GetCommandAuditDigestErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(GetCommandAuditDigestResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ GetCommandAuditDigestResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_GetCommandAuditDigest(
- privacy_handle,
- privacy_handle_name,
- sign_handle,
- sign_handle_name,
- qualifying_data,
- in_scheme,
- &command,
- authorization_delegate);
+ privacy_handle, privacy_handle_name, sign_handle, sign_handle_name,
+ qualifying_data, in_scheme, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -21528,47 +17660,38 @@
}
TPM_RC Tpm::GetCommandAuditDigestSync(
- const TPMI_RH_ENDORSEMENT& privacy_handle,
- const std::string& privacy_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- TPM2B_ATTEST* audit_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_ENDORSEMENT& privacy_handle,
+ const std::string& privacy_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ TPM2B_ATTEST* audit_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_GetCommandAuditDigest(
- privacy_handle,
- privacy_handle_name,
- sign_handle,
- sign_handle_name,
- qualifying_data,
- in_scheme,
- &command,
- authorization_delegate);
+ privacy_handle, privacy_handle_name, sign_handle, sign_handle_name,
+ qualifying_data, in_scheme, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_GetCommandAuditDigest(
- response,
- audit_info,
- signature,
- authorization_delegate);
+ rc = ParseResponse_GetCommandAuditDigest(response, audit_info, signature,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_GetTime(
- const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
- const std::string& privacy_admin_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
+ const std::string& privacy_admin_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -21579,37 +17702,28 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string privacy_admin_handle_bytes;
- rc = Serialize_TPMI_RH_ENDORSEMENT(
- privacy_admin_handle,
- &privacy_admin_handle_bytes);
+ rc = Serialize_TPMI_RH_ENDORSEMENT(privacy_admin_handle,
+ &privacy_admin_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string sign_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- sign_handle,
- &sign_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(sign_handle, &sign_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string qualifying_data_bytes;
- rc = Serialize_TPM2B_DATA(
- qualifying_data,
- &qualifying_data_bytes);
+ rc = Serialize_TPM2B_DATA(qualifying_data, &qualifying_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_scheme_bytes;
- rc = Serialize_TPMT_SIG_SCHEME(
- in_scheme,
- &in_scheme_bytes);
+ rc = Serialize_TPMT_SIG_SCHEME(in_scheme, &in_scheme_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -21621,24 +17735,20 @@
}
qualifying_data_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
hash->Update(privacy_admin_handle_name.data(),
privacy_admin_handle_name.size());
handle_section_bytes += privacy_admin_handle_bytes;
command_size += privacy_admin_handle_bytes.size();
- hash->Update(sign_handle_name.data(),
- sign_handle_name.size());
+ hash->Update(sign_handle_name.data(), sign_handle_name.size());
handle_section_bytes += sign_handle_bytes;
command_size += sign_handle_bytes.size();
- hash->Update(qualifying_data_bytes.data(),
- qualifying_data_bytes.size());
+ hash->Update(qualifying_data_bytes.data(), qualifying_data_bytes.size());
parameter_section_bytes += qualifying_data_bytes;
command_size += qualifying_data_bytes.size();
- hash->Update(in_scheme_bytes.data(),
- in_scheme_bytes.size());
+ hash->Update(in_scheme_bytes.data(), in_scheme_bytes.size());
parameter_section_bytes += in_scheme_bytes;
command_size += in_scheme_bytes.size();
std::string command_hash(32, 0);
@@ -21647,10 +17757,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -21661,31 +17770,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -21693,38 +17794,29 @@
}
TPM_RC Tpm::ParseResponse_GetTime(
- const std::string& response,
- TPM2B_ATTEST* time_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_ATTEST* time_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -21736,9 +17828,7 @@
}
TPM_CC command_code = TPM_CC_GetTime;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -21756,37 +17846,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string time_info_bytes;
- rc = Parse_TPM2B_ATTEST(
- &buffer,
- time_info,
- &time_info_bytes);
+ rc = Parse_TPM2B_ATTEST(&buffer, time_info, &time_info_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string signature_bytes;
- rc = Parse_TPMT_SIGNATURE(
- &buffer,
- signature,
- &signature_bytes);
+ rc = Parse_TPMT_SIGNATURE(&buffer, signature, &signature_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -21798,10 +17878,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
time_info_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_ATTEST(
- &time_info_bytes,
- time_info,
- nullptr);
+ rc = Parse_TPM2B_ATTEST(&time_info_bytes, time_info, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -21809,65 +17886,47 @@
return TPM_RC_SUCCESS;
}
-void GetTimeErrorCallback(
- const Tpm::GetTimeResponse& callback,
- TPM_RC response_code) {
+void GetTimeErrorCallback(const Tpm::GetTimeResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_ATTEST(),
- TPMT_SIGNATURE());
+ callback.Run(response_code, TPM2B_ATTEST(), TPMT_SIGNATURE());
}
-void GetTimeResponseParser(
- const Tpm::GetTimeResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void GetTimeResponseParser(const Tpm::GetTimeResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(GetTimeErrorCallback, callback);
TPM2B_ATTEST time_info;
TPMT_SIGNATURE signature;
- TPM_RC rc = Tpm::ParseResponse_GetTime(
- response,
- &time_info,
- &signature,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_GetTime(response, &time_info, &signature,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- time_info,
- signature);
+ callback.Run(rc, time_info, signature);
}
-void Tpm::GetTime(
- const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
- const std::string& privacy_admin_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- AuthorizationDelegate* authorization_delegate,
- const GetTimeResponse& callback) {
+void Tpm::GetTime(const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
+ const std::string& privacy_admin_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ AuthorizationDelegate* authorization_delegate,
+ const GetTimeResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(GetTimeErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(GetTimeResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(GetTimeResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_GetTime(
- privacy_admin_handle,
- privacy_admin_handle_name,
- sign_handle,
- sign_handle_name,
- qualifying_data,
- in_scheme,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_GetTime(privacy_admin_handle, privacy_admin_handle_name,
+ sign_handle, sign_handle_name, qualifying_data,
+ in_scheme, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -21875,48 +17934,39 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::GetTimeSync(
- const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
- const std::string& privacy_admin_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- TPM2B_ATTEST* time_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::GetTimeSync(const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
+ const std::string& privacy_admin_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ TPM2B_ATTEST* time_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_GetTime(
- privacy_admin_handle,
- privacy_admin_handle_name,
- sign_handle,
- sign_handle_name,
- qualifying_data,
- in_scheme,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_GetTime(privacy_admin_handle, privacy_admin_handle_name,
+ sign_handle, sign_handle_name, qualifying_data,
+ in_scheme, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_GetTime(
- response,
- time_info,
- signature,
- authorization_delegate);
+ rc = ParseResponse_GetTime(response, time_info, signature,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_Commit(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const UINT32& param_size,
- const TPM2B_ECC_POINT& p1,
- const TPM2B_SENSITIVE_DATA& s2,
- const TPM2B_ECC_PARAMETER& y2,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const UINT32& param_size,
+ const TPM2B_ECC_POINT& p1,
+ const TPM2B_SENSITIVE_DATA& s2,
+ const TPM2B_ECC_PARAMETER& y2,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -21927,69 +17977,51 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string param_size_bytes;
- rc = Serialize_UINT32(
- param_size,
- ¶m_size_bytes);
+ rc = Serialize_UINT32(param_size, ¶m_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string sign_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- sign_handle,
- &sign_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(sign_handle, &sign_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string p1_bytes;
- rc = Serialize_TPM2B_ECC_POINT(
- p1,
- &p1_bytes);
+ rc = Serialize_TPM2B_ECC_POINT(p1, &p1_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string s2_bytes;
- rc = Serialize_TPM2B_SENSITIVE_DATA(
- s2,
- &s2_bytes);
+ rc = Serialize_TPM2B_SENSITIVE_DATA(s2, &s2_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string y2_bytes;
- rc = Serialize_TPM2B_ECC_PARAMETER(
- y2,
- &y2_bytes);
+ rc = Serialize_TPM2B_ECC_PARAMETER(y2, &y2_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(sign_handle_name.data(),
- sign_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(sign_handle_name.data(), sign_handle_name.size());
handle_section_bytes += sign_handle_bytes;
command_size += sign_handle_bytes.size();
- hash->Update(param_size_bytes.data(),
- param_size_bytes.size());
+ hash->Update(param_size_bytes.data(), param_size_bytes.size());
parameter_section_bytes += param_size_bytes;
command_size += param_size_bytes.size();
- hash->Update(p1_bytes.data(),
- p1_bytes.size());
+ hash->Update(p1_bytes.data(), p1_bytes.size());
parameter_section_bytes += p1_bytes;
command_size += p1_bytes.size();
- hash->Update(s2_bytes.data(),
- s2_bytes.size());
+ hash->Update(s2_bytes.data(), s2_bytes.size());
parameter_section_bytes += s2_bytes;
command_size += s2_bytes.size();
- hash->Update(y2_bytes.data(),
- y2_bytes.size());
+ hash->Update(y2_bytes.data(), y2_bytes.size());
parameter_section_bytes += y2_bytes;
command_size += y2_bytes.size();
std::string command_hash(32, 0);
@@ -21998,10 +18030,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -22012,31 +18043,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -22044,41 +18067,32 @@
}
TPM_RC Tpm::ParseResponse_Commit(
- const std::string& response,
- UINT32* param_size_out,
- TPM2B_ECC_POINT* k,
- TPM2B_ECC_POINT* l,
- TPM2B_ECC_POINT* e,
- UINT16* counter,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ UINT32* param_size_out,
+ TPM2B_ECC_POINT* k,
+ TPM2B_ECC_POINT* l,
+ TPM2B_ECC_POINT* e,
+ UINT16* counter,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -22090,9 +18104,7 @@
}
TPM_CC command_code = TPM_CC_Commit;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -22110,83 +18122,58 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string param_size_out_bytes;
- rc = Parse_UINT32(
- &buffer,
- param_size_out,
- ¶m_size_out_bytes);
+ rc = Parse_UINT32(&buffer, param_size_out, ¶m_size_out_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string k_bytes;
- rc = Parse_TPM2B_ECC_POINT(
- &buffer,
- k,
- &k_bytes);
+ rc = Parse_TPM2B_ECC_POINT(&buffer, k, &k_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string l_bytes;
- rc = Parse_TPM2B_ECC_POINT(
- &buffer,
- l,
- &l_bytes);
+ rc = Parse_TPM2B_ECC_POINT(&buffer, l, &l_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string e_bytes;
- rc = Parse_TPM2B_ECC_POINT(
- &buffer,
- e,
- &e_bytes);
+ rc = Parse_TPM2B_ECC_POINT(&buffer, e, &e_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string counter_bytes;
- rc = Parse_UINT16(
- &buffer,
- counter,
- &counter_bytes);
+ rc = Parse_UINT16(&buffer, counter, &counter_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
return TPM_RC_SUCCESS;
}
-void CommitErrorCallback(
- const Tpm::CommitResponse& callback,
- TPM_RC response_code) {
+void CommitErrorCallback(const Tpm::CommitResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- UINT32(),
- TPM2B_ECC_POINT(),
- TPM2B_ECC_POINT(),
- TPM2B_ECC_POINT(),
- UINT16());
+ callback.Run(response_code, UINT32(), TPM2B_ECC_POINT(), TPM2B_ECC_POINT(),
+ TPM2B_ECC_POINT(), UINT16());
}
-void CommitResponseParser(
- const Tpm::CommitResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void CommitResponseParser(const Tpm::CommitResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(CommitErrorCallback, callback);
@@ -22195,53 +18182,32 @@
TPM2B_ECC_POINT l;
TPM2B_ECC_POINT e;
UINT16 counter;
- TPM_RC rc = Tpm::ParseResponse_Commit(
- response,
- ¶m_size_out,
- &k,
- &l,
- &e,
- &counter,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_Commit(response, ¶m_size_out, &k, &l, &e,
+ &counter, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- param_size_out,
- k,
- l,
- e,
- counter);
+ callback.Run(rc, param_size_out, k, l, e, counter);
}
-void Tpm::Commit(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const UINT32& param_size,
- const TPM2B_ECC_POINT& p1,
- const TPM2B_SENSITIVE_DATA& s2,
- const TPM2B_ECC_PARAMETER& y2,
- AuthorizationDelegate* authorization_delegate,
- const CommitResponse& callback) {
+void Tpm::Commit(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const UINT32& param_size,
+ const TPM2B_ECC_POINT& p1,
+ const TPM2B_SENSITIVE_DATA& s2,
+ const TPM2B_ECC_PARAMETER& y2,
+ AuthorizationDelegate* authorization_delegate,
+ const CommitResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(CommitErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(CommitResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(CommitResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_Commit(
- sign_handle,
- sign_handle_name,
- param_size,
- p1,
- s2,
- y2,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_Commit(sign_handle, sign_handle_name, param_size, p1, s2,
+ y2, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -22249,50 +18215,37 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::CommitSync(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const UINT32& param_size,
- const TPM2B_ECC_POINT& p1,
- const TPM2B_SENSITIVE_DATA& s2,
- const TPM2B_ECC_PARAMETER& y2,
- UINT32* param_size_out,
- TPM2B_ECC_POINT* k,
- TPM2B_ECC_POINT* l,
- TPM2B_ECC_POINT* e,
- UINT16* counter,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::CommitSync(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const UINT32& param_size,
+ const TPM2B_ECC_POINT& p1,
+ const TPM2B_SENSITIVE_DATA& s2,
+ const TPM2B_ECC_PARAMETER& y2,
+ UINT32* param_size_out,
+ TPM2B_ECC_POINT* k,
+ TPM2B_ECC_POINT* l,
+ TPM2B_ECC_POINT* e,
+ UINT16* counter,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_Commit(
- sign_handle,
- sign_handle_name,
- param_size,
- p1,
- s2,
- y2,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_Commit(sign_handle, sign_handle_name, param_size, p1, s2,
+ y2, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_Commit(
- response,
- param_size_out,
- k,
- l,
- e,
- counter,
- authorization_delegate);
+ rc = ParseResponse_Commit(response, param_size_out, k, l, e, counter,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_EC_Ephemeral(
- const UINT32& param_size,
- const TPMI_ECC_CURVE& curve_id,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const UINT32& param_size,
+ const TPMI_ECC_CURVE& curve_id,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -22303,36 +18256,27 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string param_size_bytes;
- rc = Serialize_UINT32(
- param_size,
- ¶m_size_bytes);
+ rc = Serialize_UINT32(param_size, ¶m_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string curve_id_bytes;
- rc = Serialize_TPMI_ECC_CURVE(
- curve_id,
- &curve_id_bytes);
+ rc = Serialize_TPMI_ECC_CURVE(curve_id, &curve_id_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(param_size_bytes.data(),
- param_size_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(param_size_bytes.data(), param_size_bytes.size());
parameter_section_bytes += param_size_bytes;
command_size += param_size_bytes.size();
- hash->Update(curve_id_bytes.data(),
- curve_id_bytes.size());
+ hash->Update(curve_id_bytes.data(), curve_id_bytes.size());
parameter_section_bytes += curve_id_bytes;
command_size += curve_id_bytes.size();
std::string command_hash(32, 0);
@@ -22341,10 +18285,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -22355,31 +18298,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -22387,39 +18322,30 @@
}
TPM_RC Tpm::ParseResponse_EC_Ephemeral(
- const std::string& response,
- UINT32* param_size_out,
- TPM2B_ECC_POINT* q,
- UINT16* counter,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ UINT32* param_size_out,
+ TPM2B_ECC_POINT* q,
+ UINT16* counter,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -22431,9 +18357,7 @@
}
TPM_CC command_code = TPM_CC_EC_Ephemeral;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -22451,106 +18375,74 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string param_size_out_bytes;
- rc = Parse_UINT32(
- &buffer,
- param_size_out,
- ¶m_size_out_bytes);
+ rc = Parse_UINT32(&buffer, param_size_out, ¶m_size_out_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string q_bytes;
- rc = Parse_TPM2B_ECC_POINT(
- &buffer,
- q,
- &q_bytes);
+ rc = Parse_TPM2B_ECC_POINT(&buffer, q, &q_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string counter_bytes;
- rc = Parse_UINT16(
- &buffer,
- counter,
- &counter_bytes);
+ rc = Parse_UINT16(&buffer, counter, &counter_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
return TPM_RC_SUCCESS;
}
-void EC_EphemeralErrorCallback(
- const Tpm::EC_EphemeralResponse& callback,
- TPM_RC response_code) {
+void EC_EphemeralErrorCallback(const Tpm::EC_EphemeralResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- UINT32(),
- TPM2B_ECC_POINT(),
- UINT16());
+ callback.Run(response_code, UINT32(), TPM2B_ECC_POINT(), UINT16());
}
-void EC_EphemeralResponseParser(
- const Tpm::EC_EphemeralResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void EC_EphemeralResponseParser(const Tpm::EC_EphemeralResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(EC_EphemeralErrorCallback, callback);
UINT32 param_size_out;
TPM2B_ECC_POINT q;
UINT16 counter;
- TPM_RC rc = Tpm::ParseResponse_EC_Ephemeral(
- response,
- ¶m_size_out,
- &q,
- &counter,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_EC_Ephemeral(response, ¶m_size_out, &q,
+ &counter, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- param_size_out,
- q,
- counter);
+ callback.Run(rc, param_size_out, q, counter);
}
-void Tpm::EC_Ephemeral(
- const UINT32& param_size,
- const TPMI_ECC_CURVE& curve_id,
- AuthorizationDelegate* authorization_delegate,
- const EC_EphemeralResponse& callback) {
+void Tpm::EC_Ephemeral(const UINT32& param_size,
+ const TPMI_ECC_CURVE& curve_id,
+ AuthorizationDelegate* authorization_delegate,
+ const EC_EphemeralResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(EC_EphemeralErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(EC_EphemeralResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(EC_EphemeralResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_EC_Ephemeral(
- param_size,
- curve_id,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_EC_Ephemeral(param_size, curve_id, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -22558,40 +18450,32 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::EC_EphemeralSync(
- const UINT32& param_size,
- const TPMI_ECC_CURVE& curve_id,
- UINT32* param_size_out,
- TPM2B_ECC_POINT* q,
- UINT16* counter,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::EC_EphemeralSync(const UINT32& param_size,
+ const TPMI_ECC_CURVE& curve_id,
+ UINT32* param_size_out,
+ TPM2B_ECC_POINT* q,
+ UINT16* counter,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_EC_Ephemeral(
- param_size,
- curve_id,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_EC_Ephemeral(param_size, curve_id, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_EC_Ephemeral(
- response,
- param_size_out,
- q,
- counter,
- authorization_delegate);
+ rc = ParseResponse_EC_Ephemeral(response, param_size_out, q, counter,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_VerifySignature(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& digest,
- const TPMT_SIGNATURE& signature,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& digest,
+ const TPMT_SIGNATURE& signature,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -22602,30 +18486,22 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string key_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- key_handle,
- &key_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(key_handle, &key_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string digest_bytes;
- rc = Serialize_TPM2B_DIGEST(
- digest,
- &digest_bytes);
+ rc = Serialize_TPM2B_DIGEST(digest, &digest_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string signature_bytes;
- rc = Serialize_TPMT_SIGNATURE(
- signature,
- &signature_bytes);
+ rc = Serialize_TPMT_SIGNATURE(signature, &signature_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -22637,20 +18513,16 @@
}
digest_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(key_handle_name.data(),
- key_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(key_handle_name.data(), key_handle_name.size());
handle_section_bytes += key_handle_bytes;
command_size += key_handle_bytes.size();
- hash->Update(digest_bytes.data(),
- digest_bytes.size());
+ hash->Update(digest_bytes.data(), digest_bytes.size());
parameter_section_bytes += digest_bytes;
command_size += digest_bytes.size();
- hash->Update(signature_bytes.data(),
- signature_bytes.size());
+ hash->Update(signature_bytes.data(), signature_bytes.size());
parameter_section_bytes += signature_bytes;
command_size += signature_bytes.size();
std::string command_hash(32, 0);
@@ -22659,10 +18531,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -22673,31 +18544,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -22705,37 +18568,28 @@
}
TPM_RC Tpm::ParseResponse_VerifySignature(
- const std::string& response,
- TPMT_TK_VERIFIED* validation,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPMT_TK_VERIFIED* validation,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -22747,9 +18601,7 @@
}
TPM_CC command_code = TPM_CC_VerifySignature;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -22767,41 +18619,32 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string validation_bytes;
- rc = Parse_TPMT_TK_VERIFIED(
- &buffer,
- validation,
- &validation_bytes);
+ rc = Parse_TPMT_TK_VERIFIED(&buffer, validation, &validation_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
return TPM_RC_SUCCESS;
}
-void VerifySignatureErrorCallback(
- const Tpm::VerifySignatureResponse& callback,
- TPM_RC response_code) {
+void VerifySignatureErrorCallback(const Tpm::VerifySignatureResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPMT_TK_VERIFIED());
+ callback.Run(response_code, TPMT_TK_VERIFIED());
}
void VerifySignatureResponseParser(
@@ -22812,41 +18655,30 @@
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(VerifySignatureErrorCallback, callback);
TPMT_TK_VERIFIED validation;
- TPM_RC rc = Tpm::ParseResponse_VerifySignature(
- response,
- &validation,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_VerifySignature(response, &validation,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- validation);
+ callback.Run(rc, validation);
}
-void Tpm::VerifySignature(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& digest,
- const TPMT_SIGNATURE& signature,
- AuthorizationDelegate* authorization_delegate,
- const VerifySignatureResponse& callback) {
+void Tpm::VerifySignature(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& digest,
+ const TPMT_SIGNATURE& signature,
+ AuthorizationDelegate* authorization_delegate,
+ const VerifySignatureResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(VerifySignatureErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(VerifySignatureResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ VerifySignatureResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_VerifySignature(
- key_handle,
- key_handle_name,
- digest,
- signature,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_VerifySignature(key_handle, key_handle_name,
+ digest, signature, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -22854,41 +18686,34 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::VerifySignatureSync(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& digest,
- const TPMT_SIGNATURE& signature,
- TPMT_TK_VERIFIED* validation,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::VerifySignatureSync(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& digest,
+ const TPMT_SIGNATURE& signature,
+ TPMT_TK_VERIFIED* validation,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_VerifySignature(
- key_handle,
- key_handle_name,
- digest,
- signature,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_VerifySignature(key_handle, key_handle_name,
+ digest, signature, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_VerifySignature(
- response,
- validation,
- authorization_delegate);
+ rc = ParseResponse_VerifySignature(response, validation,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_Sign(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& digest,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPMT_TK_HASHCHECK& validation,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& digest,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPMT_TK_HASHCHECK& validation,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -22899,37 +18724,27 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string key_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- key_handle,
- &key_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(key_handle, &key_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string digest_bytes;
- rc = Serialize_TPM2B_DIGEST(
- digest,
- &digest_bytes);
+ rc = Serialize_TPM2B_DIGEST(digest, &digest_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_scheme_bytes;
- rc = Serialize_TPMT_SIG_SCHEME(
- in_scheme,
- &in_scheme_bytes);
+ rc = Serialize_TPMT_SIG_SCHEME(in_scheme, &in_scheme_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string validation_bytes;
- rc = Serialize_TPMT_TK_HASHCHECK(
- validation,
- &validation_bytes);
+ rc = Serialize_TPMT_TK_HASHCHECK(validation, &validation_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -22941,24 +18756,19 @@
}
digest_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(key_handle_name.data(),
- key_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(key_handle_name.data(), key_handle_name.size());
handle_section_bytes += key_handle_bytes;
command_size += key_handle_bytes.size();
- hash->Update(digest_bytes.data(),
- digest_bytes.size());
+ hash->Update(digest_bytes.data(), digest_bytes.size());
parameter_section_bytes += digest_bytes;
command_size += digest_bytes.size();
- hash->Update(in_scheme_bytes.data(),
- in_scheme_bytes.size());
+ hash->Update(in_scheme_bytes.data(), in_scheme_bytes.size());
parameter_section_bytes += in_scheme_bytes;
command_size += in_scheme_bytes.size();
- hash->Update(validation_bytes.data(),
- validation_bytes.size());
+ hash->Update(validation_bytes.data(), validation_bytes.size());
parameter_section_bytes += validation_bytes;
command_size += validation_bytes.size();
std::string command_hash(32, 0);
@@ -22967,10 +18777,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -22981,69 +18790,51 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
return TPM_RC_SUCCESS;
}
-TPM_RC Tpm::ParseResponse_Sign(
- const std::string& response,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ParseResponse_Sign(const std::string& response,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -23055,9 +18846,7 @@
}
TPM_CC command_code = TPM_CC_Sign;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -23075,88 +18864,66 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string signature_bytes;
- rc = Parse_TPMT_SIGNATURE(
- &buffer,
- signature,
- &signature_bytes);
+ rc = Parse_TPMT_SIGNATURE(&buffer, signature, &signature_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
return TPM_RC_SUCCESS;
}
-void SignErrorCallback(
- const Tpm::SignResponse& callback,
- TPM_RC response_code) {
+void SignErrorCallback(const Tpm::SignResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPMT_SIGNATURE());
+ callback.Run(response_code, TPMT_SIGNATURE());
}
-void SignResponseParser(
- const Tpm::SignResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void SignResponseParser(const Tpm::SignResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(SignErrorCallback, callback);
TPMT_SIGNATURE signature;
- TPM_RC rc = Tpm::ParseResponse_Sign(
- response,
- &signature,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_Sign(response, &signature, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- signature);
+ callback.Run(rc, signature);
}
-void Tpm::Sign(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& digest,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPMT_TK_HASHCHECK& validation,
- AuthorizationDelegate* authorization_delegate,
- const SignResponse& callback) {
+void Tpm::Sign(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& digest,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPMT_TK_HASHCHECK& validation,
+ AuthorizationDelegate* authorization_delegate,
+ const SignResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(SignErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(SignResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(SignResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_Sign(
- key_handle,
- key_handle_name,
- digest,
- in_scheme,
- validation,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_Sign(key_handle, key_handle_name, digest, in_scheme,
+ validation, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -23164,43 +18931,34 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::SignSync(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& digest,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPMT_TK_HASHCHECK& validation,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::SignSync(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& digest,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPMT_TK_HASHCHECK& validation,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_Sign(
- key_handle,
- key_handle_name,
- digest,
- in_scheme,
- validation,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_Sign(key_handle, key_handle_name, digest, in_scheme,
+ validation, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_Sign(
- response,
- signature,
- authorization_delegate);
+ rc = ParseResponse_Sign(response, signature, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_SetCommandCodeAuditStatus(
- const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const TPMI_ALG_HASH& audit_alg,
- const TPML_CC& set_list,
- const TPML_CC& clear_list,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const TPMI_ALG_HASH& audit_alg,
+ const TPML_CC& set_list,
+ const TPML_CC& clear_list,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -23211,58 +18969,43 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_bytes;
- rc = Serialize_TPMI_RH_PROVISION(
- auth,
- &auth_bytes);
+ rc = Serialize_TPMI_RH_PROVISION(auth, &auth_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string audit_alg_bytes;
- rc = Serialize_TPMI_ALG_HASH(
- audit_alg,
- &audit_alg_bytes);
+ rc = Serialize_TPMI_ALG_HASH(audit_alg, &audit_alg_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string set_list_bytes;
- rc = Serialize_TPML_CC(
- set_list,
- &set_list_bytes);
+ rc = Serialize_TPML_CC(set_list, &set_list_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string clear_list_bytes;
- rc = Serialize_TPML_CC(
- clear_list,
- &clear_list_bytes);
+ rc = Serialize_TPML_CC(clear_list, &clear_list_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_name.data(),
- auth_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_name.data(), auth_name.size());
handle_section_bytes += auth_bytes;
command_size += auth_bytes.size();
- hash->Update(audit_alg_bytes.data(),
- audit_alg_bytes.size());
+ hash->Update(audit_alg_bytes.data(), audit_alg_bytes.size());
parameter_section_bytes += audit_alg_bytes;
command_size += audit_alg_bytes.size();
- hash->Update(set_list_bytes.data(),
- set_list_bytes.size());
+ hash->Update(set_list_bytes.data(), set_list_bytes.size());
parameter_section_bytes += set_list_bytes;
command_size += set_list_bytes.size();
- hash->Update(clear_list_bytes.data(),
- clear_list_bytes.size());
+ hash->Update(clear_list_bytes.data(), clear_list_bytes.size());
parameter_section_bytes += clear_list_bytes;
command_size += clear_list_bytes.size();
std::string command_hash(32, 0);
@@ -23271,10 +19014,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -23285,31 +19027,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -23317,36 +19051,27 @@
}
TPM_RC Tpm::ParseResponse_SetCommandCodeAuditStatus(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -23358,9 +19083,7 @@
}
TPM_CC command_code = TPM_CC_SetCommandCodeAuditStatus;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -23378,21 +19101,17 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
@@ -23414,39 +19133,31 @@
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(SetCommandCodeAuditStatusErrorCallback, callback);
TPM_RC rc = Tpm::ParseResponse_SetCommandCodeAuditStatus(
- response,
- authorization_delegate);
+ response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
void Tpm::SetCommandCodeAuditStatus(
- const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const TPMI_ALG_HASH& audit_alg,
- const TPML_CC& set_list,
- const TPML_CC& clear_list,
- AuthorizationDelegate* authorization_delegate,
- const SetCommandCodeAuditStatusResponse& callback) {
+ const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const TPMI_ALG_HASH& audit_alg,
+ const TPML_CC& set_list,
+ const TPML_CC& clear_list,
+ AuthorizationDelegate* authorization_delegate,
+ const SetCommandCodeAuditStatusResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(SetCommandCodeAuditStatusErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(SetCommandCodeAuditStatusResponseParser,
- callback,
+ base::Bind(SetCommandCodeAuditStatusResponseParser, callback,
authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_SetCommandCodeAuditStatus(
- auth,
- auth_name,
- audit_alg,
- set_list,
- clear_list,
- &command,
+ auth, auth_name, audit_alg, set_list, clear_list, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
@@ -23456,38 +19167,32 @@
}
TPM_RC Tpm::SetCommandCodeAuditStatusSync(
- const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const TPMI_ALG_HASH& audit_alg,
- const TPML_CC& set_list,
- const TPML_CC& clear_list,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const TPMI_ALG_HASH& audit_alg,
+ const TPML_CC& set_list,
+ const TPML_CC& clear_list,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_SetCommandCodeAuditStatus(
- auth,
- auth_name,
- audit_alg,
- set_list,
- clear_list,
- &command,
+ auth, auth_name, audit_alg, set_list, clear_list, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_SetCommandCodeAuditStatus(
- response,
- authorization_delegate);
+ rc =
+ ParseResponse_SetCommandCodeAuditStatus(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PCR_Extend(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPML_DIGEST_VALUES& digests,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPML_DIGEST_VALUES& digests,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -23498,36 +19203,27 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string pcr_handle_bytes;
- rc = Serialize_TPMI_DH_PCR(
- pcr_handle,
- &pcr_handle_bytes);
+ rc = Serialize_TPMI_DH_PCR(pcr_handle, &pcr_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string digests_bytes;
- rc = Serialize_TPML_DIGEST_VALUES(
- digests,
- &digests_bytes);
+ rc = Serialize_TPML_DIGEST_VALUES(digests, &digests_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(pcr_handle_name.data(),
- pcr_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(pcr_handle_name.data(), pcr_handle_name.size());
handle_section_bytes += pcr_handle_bytes;
command_size += pcr_handle_bytes.size();
- hash->Update(digests_bytes.data(),
- digests_bytes.size());
+ hash->Update(digests_bytes.data(), digests_bytes.size());
parameter_section_bytes += digests_bytes;
command_size += digests_bytes.size();
std::string command_hash(32, 0);
@@ -23536,10 +19232,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -23550,31 +19245,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -23582,36 +19269,27 @@
}
TPM_RC Tpm::ParseResponse_PCR_Extend(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -23623,9 +19301,7 @@
}
TPM_CC command_code = TPM_CC_PCR_Extend;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -23643,72 +19319,56 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void PCR_ExtendErrorCallback(
- const Tpm::PCR_ExtendResponse& callback,
- TPM_RC response_code) {
+void PCR_ExtendErrorCallback(const Tpm::PCR_ExtendResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void PCR_ExtendResponseParser(
- const Tpm::PCR_ExtendResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void PCR_ExtendResponseParser(const Tpm::PCR_ExtendResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PCR_ExtendErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PCR_Extend(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_PCR_Extend(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PCR_Extend(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPML_DIGEST_VALUES& digests,
- AuthorizationDelegate* authorization_delegate,
- const PCR_ExtendResponse& callback) {
+void Tpm::PCR_Extend(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPML_DIGEST_VALUES& digests,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_ExtendResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PCR_ExtendErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(PCR_ExtendResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(PCR_ExtendResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_PCR_Extend(
- pcr_handle,
- pcr_handle_name,
- digests,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_PCR_Extend(pcr_handle, pcr_handle_name, digests,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -23716,35 +19376,28 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PCR_ExtendSync(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPML_DIGEST_VALUES& digests,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PCR_ExtendSync(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPML_DIGEST_VALUES& digests,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_PCR_Extend(
- pcr_handle,
- pcr_handle_name,
- digests,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_PCR_Extend(pcr_handle, pcr_handle_name, digests,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PCR_Extend(
- response,
- authorization_delegate);
+ rc = ParseResponse_PCR_Extend(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PCR_Event(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPM2B_EVENT& event_data,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPM2B_EVENT& event_data,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -23755,23 +19408,17 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string pcr_handle_bytes;
- rc = Serialize_TPMI_DH_PCR(
- pcr_handle,
- &pcr_handle_bytes);
+ rc = Serialize_TPMI_DH_PCR(pcr_handle, &pcr_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string event_data_bytes;
- rc = Serialize_TPM2B_EVENT(
- event_data,
- &event_data_bytes);
+ rc = Serialize_TPM2B_EVENT(event_data, &event_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -23783,16 +19430,13 @@
}
event_data_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(pcr_handle_name.data(),
- pcr_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(pcr_handle_name.data(), pcr_handle_name.size());
handle_section_bytes += pcr_handle_bytes;
command_size += pcr_handle_bytes.size();
- hash->Update(event_data_bytes.data(),
- event_data_bytes.size());
+ hash->Update(event_data_bytes.data(), event_data_bytes.size());
parameter_section_bytes += event_data_bytes;
command_size += event_data_bytes.size();
std::string command_hash(32, 0);
@@ -23801,10 +19445,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -23815,31 +19458,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -23847,37 +19482,28 @@
}
TPM_RC Tpm::ParseResponse_PCR_Event(
- const std::string& response,
- TPML_DIGEST_VALUES* digests,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPML_DIGEST_VALUES* digests,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -23889,9 +19515,7 @@
}
TPM_CC command_code = TPM_CC_PCR_Event;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -23909,84 +19533,64 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string digests_bytes;
- rc = Parse_TPML_DIGEST_VALUES(
- &buffer,
- digests,
- &digests_bytes);
+ rc = Parse_TPML_DIGEST_VALUES(&buffer, digests, &digests_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
return TPM_RC_SUCCESS;
}
-void PCR_EventErrorCallback(
- const Tpm::PCR_EventResponse& callback,
- TPM_RC response_code) {
+void PCR_EventErrorCallback(const Tpm::PCR_EventResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPML_DIGEST_VALUES());
+ callback.Run(response_code, TPML_DIGEST_VALUES());
}
-void PCR_EventResponseParser(
- const Tpm::PCR_EventResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void PCR_EventResponseParser(const Tpm::PCR_EventResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PCR_EventErrorCallback, callback);
TPML_DIGEST_VALUES digests;
- TPM_RC rc = Tpm::ParseResponse_PCR_Event(
- response,
- &digests,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_PCR_Event(response, &digests, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- digests);
+ callback.Run(rc, digests);
}
-void Tpm::PCR_Event(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPM2B_EVENT& event_data,
- AuthorizationDelegate* authorization_delegate,
- const PCR_EventResponse& callback) {
+void Tpm::PCR_Event(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPM2B_EVENT& event_data,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_EventResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PCR_EventErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(PCR_EventResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(PCR_EventResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_PCR_Event(
- pcr_handle,
- pcr_handle_name,
- event_data,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_PCR_Event(pcr_handle, pcr_handle_name, event_data,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -23994,35 +19598,28 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PCR_EventSync(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPM2B_EVENT& event_data,
- TPML_DIGEST_VALUES* digests,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PCR_EventSync(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPM2B_EVENT& event_data,
+ TPML_DIGEST_VALUES* digests,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_PCR_Event(
- pcr_handle,
- pcr_handle_name,
- event_data,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_PCR_Event(pcr_handle, pcr_handle_name, event_data,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PCR_Event(
- response,
- digests,
- authorization_delegate);
+ rc = ParseResponse_PCR_Event(response, digests, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PCR_Read(
- const TPML_PCR_SELECTION& pcr_selection_in,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPML_PCR_SELECTION& pcr_selection_in,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -24033,25 +19630,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string pcr_selection_in_bytes;
- rc = Serialize_TPML_PCR_SELECTION(
- pcr_selection_in,
- &pcr_selection_in_bytes);
+ rc = Serialize_TPML_PCR_SELECTION(pcr_selection_in, &pcr_selection_in_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(pcr_selection_in_bytes.data(),
- pcr_selection_in_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(pcr_selection_in_bytes.data(), pcr_selection_in_bytes.size());
parameter_section_bytes += pcr_selection_in_bytes;
command_size += pcr_selection_in_bytes.size();
std::string command_hash(32, 0);
@@ -24060,10 +19651,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -24074,31 +19664,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -24106,39 +19688,30 @@
}
TPM_RC Tpm::ParseResponse_PCR_Read(
- const std::string& response,
- UINT32* pcr_update_counter,
- TPML_PCR_SELECTION* pcr_selection_out,
- TPML_DIGEST* pcr_values,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ UINT32* pcr_update_counter,
+ TPML_PCR_SELECTION* pcr_selection_out,
+ TPML_DIGEST* pcr_values,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -24150,9 +19723,7 @@
}
TPM_CC command_code = TPM_CC_PCR_Read;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -24170,104 +19741,75 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string pcr_update_counter_bytes;
- rc = Parse_UINT32(
- &buffer,
- pcr_update_counter,
- &pcr_update_counter_bytes);
+ rc = Parse_UINT32(&buffer, pcr_update_counter, &pcr_update_counter_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string pcr_selection_out_bytes;
- rc = Parse_TPML_PCR_SELECTION(
- &buffer,
- pcr_selection_out,
- &pcr_selection_out_bytes);
+ rc = Parse_TPML_PCR_SELECTION(&buffer, pcr_selection_out,
+ &pcr_selection_out_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string pcr_values_bytes;
- rc = Parse_TPML_DIGEST(
- &buffer,
- pcr_values,
- &pcr_values_bytes);
+ rc = Parse_TPML_DIGEST(&buffer, pcr_values, &pcr_values_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
return TPM_RC_SUCCESS;
}
-void PCR_ReadErrorCallback(
- const Tpm::PCR_ReadResponse& callback,
- TPM_RC response_code) {
+void PCR_ReadErrorCallback(const Tpm::PCR_ReadResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- UINT32(),
- TPML_PCR_SELECTION(),
- TPML_DIGEST());
+ callback.Run(response_code, UINT32(), TPML_PCR_SELECTION(), TPML_DIGEST());
}
-void PCR_ReadResponseParser(
- const Tpm::PCR_ReadResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void PCR_ReadResponseParser(const Tpm::PCR_ReadResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PCR_ReadErrorCallback, callback);
UINT32 pcr_update_counter;
TPML_PCR_SELECTION pcr_selection_out;
TPML_DIGEST pcr_values;
- TPM_RC rc = Tpm::ParseResponse_PCR_Read(
- response,
- &pcr_update_counter,
- &pcr_selection_out,
- &pcr_values,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_PCR_Read(response, &pcr_update_counter,
+ &pcr_selection_out, &pcr_values,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- pcr_update_counter,
- pcr_selection_out,
- pcr_values);
+ callback.Run(rc, pcr_update_counter, pcr_selection_out, pcr_values);
}
-void Tpm::PCR_Read(
- const TPML_PCR_SELECTION& pcr_selection_in,
- AuthorizationDelegate* authorization_delegate,
- const PCR_ReadResponse& callback) {
+void Tpm::PCR_Read(const TPML_PCR_SELECTION& pcr_selection_in,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_ReadResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PCR_ReadErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(PCR_ReadResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(PCR_ReadResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_PCR_Read(
- pcr_selection_in,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_PCR_Read(pcr_selection_in, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -24275,37 +19817,30 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PCR_ReadSync(
- const TPML_PCR_SELECTION& pcr_selection_in,
- UINT32* pcr_update_counter,
- TPML_PCR_SELECTION* pcr_selection_out,
- TPML_DIGEST* pcr_values,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PCR_ReadSync(const TPML_PCR_SELECTION& pcr_selection_in,
+ UINT32* pcr_update_counter,
+ TPML_PCR_SELECTION* pcr_selection_out,
+ TPML_DIGEST* pcr_values,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_PCR_Read(
- pcr_selection_in,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_PCR_Read(pcr_selection_in, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PCR_Read(
- response,
- pcr_update_counter,
- pcr_selection_out,
- pcr_values,
- authorization_delegate);
+ rc = ParseResponse_PCR_Read(response, pcr_update_counter, pcr_selection_out,
+ pcr_values, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PCR_Allocate(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- const TPML_PCR_SELECTION& pcr_allocation,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ const TPML_PCR_SELECTION& pcr_allocation,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -24316,36 +19851,27 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_PLATFORM(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_PLATFORM(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string pcr_allocation_bytes;
- rc = Serialize_TPML_PCR_SELECTION(
- pcr_allocation,
- &pcr_allocation_bytes);
+ rc = Serialize_TPML_PCR_SELECTION(pcr_allocation, &pcr_allocation_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
- hash->Update(pcr_allocation_bytes.data(),
- pcr_allocation_bytes.size());
+ hash->Update(pcr_allocation_bytes.data(), pcr_allocation_bytes.size());
parameter_section_bytes += pcr_allocation_bytes;
command_size += pcr_allocation_bytes.size();
std::string command_hash(32, 0);
@@ -24354,10 +19880,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -24368,31 +19893,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -24400,40 +19917,31 @@
}
TPM_RC Tpm::ParseResponse_PCR_Allocate(
- const std::string& response,
- TPMI_YES_NO* allocation_success,
- UINT32* max_pcr,
- UINT32* size_needed,
- UINT32* size_available,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPMI_YES_NO* allocation_success,
+ UINT32* max_pcr,
+ UINT32* size_needed,
+ UINT32* size_available,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -24445,9 +19953,7 @@
}
TPM_CC command_code = TPM_CC_PCR_Allocate;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -24465,74 +19971,53 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string allocation_success_bytes;
- rc = Parse_TPMI_YES_NO(
- &buffer,
- allocation_success,
- &allocation_success_bytes);
+ rc =
+ Parse_TPMI_YES_NO(&buffer, allocation_success, &allocation_success_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string max_pcr_bytes;
- rc = Parse_UINT32(
- &buffer,
- max_pcr,
- &max_pcr_bytes);
+ rc = Parse_UINT32(&buffer, max_pcr, &max_pcr_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string size_needed_bytes;
- rc = Parse_UINT32(
- &buffer,
- size_needed,
- &size_needed_bytes);
+ rc = Parse_UINT32(&buffer, size_needed, &size_needed_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string size_available_bytes;
- rc = Parse_UINT32(
- &buffer,
- size_available,
- &size_available_bytes);
+ rc = Parse_UINT32(&buffer, size_available, &size_available_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
return TPM_RC_SUCCESS;
}
-void PCR_AllocateErrorCallback(
- const Tpm::PCR_AllocateResponse& callback,
- TPM_RC response_code) {
+void PCR_AllocateErrorCallback(const Tpm::PCR_AllocateResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPMI_YES_NO(),
- UINT32(),
- UINT32(),
- UINT32());
+ callback.Run(response_code, TPMI_YES_NO(), UINT32(), UINT32(), UINT32());
}
-void PCR_AllocateResponseParser(
- const Tpm::PCR_AllocateResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void PCR_AllocateResponseParser(const Tpm::PCR_AllocateResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PCR_AllocateErrorCallback, callback);
@@ -24541,44 +20026,29 @@
UINT32 size_needed;
UINT32 size_available;
TPM_RC rc = Tpm::ParseResponse_PCR_Allocate(
- response,
- &allocation_success,
- &max_pcr,
- &size_needed,
- &size_available,
+ response, &allocation_success, &max_pcr, &size_needed, &size_available,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- allocation_success,
- max_pcr,
- size_needed,
- size_available);
+ callback.Run(rc, allocation_success, max_pcr, size_needed, size_available);
}
-void Tpm::PCR_Allocate(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- const TPML_PCR_SELECTION& pcr_allocation,
- AuthorizationDelegate* authorization_delegate,
- const PCR_AllocateResponse& callback) {
+void Tpm::PCR_Allocate(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ const TPML_PCR_SELECTION& pcr_allocation,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_AllocateResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PCR_AllocateErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(PCR_AllocateResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(PCR_AllocateResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_PCR_Allocate(
- auth_handle,
- auth_handle_name,
- pcr_allocation,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_PCR_Allocate(auth_handle, auth_handle_name,
+ pcr_allocation, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -24586,46 +20056,38 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PCR_AllocateSync(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- const TPML_PCR_SELECTION& pcr_allocation,
- TPMI_YES_NO* allocation_success,
- UINT32* max_pcr,
- UINT32* size_needed,
- UINT32* size_available,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PCR_AllocateSync(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ const TPML_PCR_SELECTION& pcr_allocation,
+ TPMI_YES_NO* allocation_success,
+ UINT32* max_pcr,
+ UINT32* size_needed,
+ UINT32* size_available,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_PCR_Allocate(
- auth_handle,
- auth_handle_name,
- pcr_allocation,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_PCR_Allocate(auth_handle, auth_handle_name,
+ pcr_allocation, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PCR_Allocate(
- response,
- allocation_success,
- max_pcr,
- size_needed,
- size_available,
- authorization_delegate);
+ rc = ParseResponse_PCR_Allocate(response, allocation_success, max_pcr,
+ size_needed, size_available,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PCR_SetAuthPolicy(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_DH_PCR& pcr_num,
- const std::string& pcr_num_name,
- const TPM2B_DIGEST& auth_policy,
- const TPMI_ALG_HASH& policy_digest,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_DH_PCR& pcr_num,
+ const std::string& pcr_num_name,
+ const TPM2B_DIGEST& auth_policy,
+ const TPMI_ALG_HASH& policy_digest,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -24636,37 +20098,27 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_PLATFORM(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_PLATFORM(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_policy_bytes;
- rc = Serialize_TPM2B_DIGEST(
- auth_policy,
- &auth_policy_bytes);
+ rc = Serialize_TPM2B_DIGEST(auth_policy, &auth_policy_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_digest_bytes;
- rc = Serialize_TPMI_ALG_HASH(
- policy_digest,
- &policy_digest_bytes);
+ rc = Serialize_TPMI_ALG_HASH(policy_digest, &policy_digest_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string pcr_num_bytes;
- rc = Serialize_TPMI_DH_PCR(
- pcr_num,
- &pcr_num_bytes);
+ rc = Serialize_TPMI_DH_PCR(pcr_num, &pcr_num_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -24678,24 +20130,19 @@
}
auth_policy_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
- hash->Update(pcr_num_name.data(),
- pcr_num_name.size());
+ hash->Update(pcr_num_name.data(), pcr_num_name.size());
handle_section_bytes += pcr_num_bytes;
command_size += pcr_num_bytes.size();
- hash->Update(auth_policy_bytes.data(),
- auth_policy_bytes.size());
+ hash->Update(auth_policy_bytes.data(), auth_policy_bytes.size());
parameter_section_bytes += auth_policy_bytes;
command_size += auth_policy_bytes.size();
- hash->Update(policy_digest_bytes.data(),
- policy_digest_bytes.size());
+ hash->Update(policy_digest_bytes.data(), policy_digest_bytes.size());
parameter_section_bytes += policy_digest_bytes;
command_size += policy_digest_bytes.size();
std::string command_hash(32, 0);
@@ -24704,10 +20151,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -24718,31 +20164,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -24750,36 +20188,27 @@
}
TPM_RC Tpm::ParseResponse_PCR_SetAuthPolicy(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -24791,9 +20220,7 @@
}
TPM_CC command_code = TPM_CC_PCR_SetAuthPolicy;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -24811,21 +20238,17 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
@@ -24846,43 +20269,32 @@
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PCR_SetAuthPolicyErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PCR_SetAuthPolicy(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_PCR_SetAuthPolicy(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PCR_SetAuthPolicy(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_DH_PCR& pcr_num,
- const std::string& pcr_num_name,
- const TPM2B_DIGEST& auth_policy,
- const TPMI_ALG_HASH& policy_digest,
- AuthorizationDelegate* authorization_delegate,
- const PCR_SetAuthPolicyResponse& callback) {
+void Tpm::PCR_SetAuthPolicy(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_DH_PCR& pcr_num,
+ const std::string& pcr_num_name,
+ const TPM2B_DIGEST& auth_policy,
+ const TPMI_ALG_HASH& policy_digest,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_SetAuthPolicyResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PCR_SetAuthPolicyErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(PCR_SetAuthPolicyResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ PCR_SetAuthPolicyResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_PCR_SetAuthPolicy(
- auth_handle,
- auth_handle_name,
- pcr_num,
- pcr_num_name,
- auth_policy,
- policy_digest,
- &command,
- authorization_delegate);
+ auth_handle, auth_handle_name, pcr_num, pcr_num_name, auth_policy,
+ policy_digest, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -24891,40 +20303,32 @@
}
TPM_RC Tpm::PCR_SetAuthPolicySync(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_DH_PCR& pcr_num,
- const std::string& pcr_num_name,
- const TPM2B_DIGEST& auth_policy,
- const TPMI_ALG_HASH& policy_digest,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_DH_PCR& pcr_num,
+ const std::string& pcr_num_name,
+ const TPM2B_DIGEST& auth_policy,
+ const TPMI_ALG_HASH& policy_digest,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_PCR_SetAuthPolicy(
- auth_handle,
- auth_handle_name,
- pcr_num,
- pcr_num_name,
- auth_policy,
- policy_digest,
- &command,
- authorization_delegate);
+ auth_handle, auth_handle_name, pcr_num, pcr_num_name, auth_policy,
+ policy_digest, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PCR_SetAuthPolicy(
- response,
- authorization_delegate);
+ rc = ParseResponse_PCR_SetAuthPolicy(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PCR_SetAuthValue(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPM2B_DIGEST& auth,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPM2B_DIGEST& auth,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -24935,23 +20339,17 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string pcr_handle_bytes;
- rc = Serialize_TPMI_DH_PCR(
- pcr_handle,
- &pcr_handle_bytes);
+ rc = Serialize_TPMI_DH_PCR(pcr_handle, &pcr_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_bytes;
- rc = Serialize_TPM2B_DIGEST(
- auth,
- &auth_bytes);
+ rc = Serialize_TPM2B_DIGEST(auth, &auth_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -24963,16 +20361,13 @@
}
auth_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(pcr_handle_name.data(),
- pcr_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(pcr_handle_name.data(), pcr_handle_name.size());
handle_section_bytes += pcr_handle_bytes;
command_size += pcr_handle_bytes.size();
- hash->Update(auth_bytes.data(),
- auth_bytes.size());
+ hash->Update(auth_bytes.data(), auth_bytes.size());
parameter_section_bytes += auth_bytes;
command_size += auth_bytes.size();
std::string command_hash(32, 0);
@@ -24981,10 +20376,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -24995,31 +20389,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -25027,36 +20413,27 @@
}
TPM_RC Tpm::ParseResponse_PCR_SetAuthValue(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -25068,9 +20445,7 @@
}
TPM_CC command_code = TPM_CC_PCR_SetAuthValue;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -25088,21 +20463,17 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
@@ -25123,37 +20494,28 @@
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PCR_SetAuthValueErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PCR_SetAuthValue(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_PCR_SetAuthValue(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PCR_SetAuthValue(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPM2B_DIGEST& auth,
- AuthorizationDelegate* authorization_delegate,
- const PCR_SetAuthValueResponse& callback) {
+void Tpm::PCR_SetAuthValue(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPM2B_DIGEST& auth,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_SetAuthValueResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PCR_SetAuthValueErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(PCR_SetAuthValueResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ PCR_SetAuthValueResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_PCR_SetAuthValue(
- pcr_handle,
- pcr_handle_name,
- auth,
- &command,
- authorization_delegate);
+ pcr_handle, pcr_handle_name, auth, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -25162,33 +20524,27 @@
}
TPM_RC Tpm::PCR_SetAuthValueSync(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPM2B_DIGEST& auth,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPM2B_DIGEST& auth,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_PCR_SetAuthValue(
- pcr_handle,
- pcr_handle_name,
- auth,
- &command,
- authorization_delegate);
+ pcr_handle, pcr_handle_name, auth, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PCR_SetAuthValue(
- response,
- authorization_delegate);
+ rc = ParseResponse_PCR_SetAuthValue(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PCR_Reset(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -25199,25 +20555,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string pcr_handle_bytes;
- rc = Serialize_TPMI_DH_PCR(
- pcr_handle,
- &pcr_handle_bytes);
+ rc = Serialize_TPMI_DH_PCR(pcr_handle, &pcr_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(pcr_handle_name.data(),
- pcr_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(pcr_handle_name.data(), pcr_handle_name.size());
handle_section_bytes += pcr_handle_bytes;
command_size += pcr_handle_bytes.size();
std::string command_hash(32, 0);
@@ -25226,10 +20576,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -25240,31 +20589,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -25272,36 +20613,27 @@
}
TPM_RC Tpm::ParseResponse_PCR_Reset(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -25313,9 +20645,7 @@
}
TPM_CC command_code = TPM_CC_PCR_Reset;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -25333,70 +20663,55 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void PCR_ResetErrorCallback(
- const Tpm::PCR_ResetResponse& callback,
- TPM_RC response_code) {
+void PCR_ResetErrorCallback(const Tpm::PCR_ResetResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void PCR_ResetResponseParser(
- const Tpm::PCR_ResetResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void PCR_ResetResponseParser(const Tpm::PCR_ResetResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PCR_ResetErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PCR_Reset(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_PCR_Reset(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PCR_Reset(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const PCR_ResetResponse& callback) {
+void Tpm::PCR_Reset(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_ResetResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PCR_ResetErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(PCR_ResetResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(PCR_ResetResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_PCR_Reset(
- pcr_handle,
- pcr_handle_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_PCR_Reset(pcr_handle, pcr_handle_name, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -25404,39 +20719,33 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PCR_ResetSync(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PCR_ResetSync(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_PCR_Reset(
- pcr_handle,
- pcr_handle_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_PCR_Reset(pcr_handle, pcr_handle_name, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PCR_Reset(
- response,
- authorization_delegate);
+ rc = ParseResponse_PCR_Reset(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicySigned(
- const TPMI_DH_OBJECT& auth_object,
- const std::string& auth_object_name,
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_NONCE& nonce_tpm,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const INT32& expiration,
- const TPMT_SIGNATURE& auth,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& auth_object,
+ const std::string& auth_object_name,
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_NONCE& nonce_tpm,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const INT32& expiration,
+ const TPMT_SIGNATURE& auth,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -25447,58 +20756,42 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_object_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- auth_object,
- &auth_object_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(auth_object, &auth_object_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_session_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- policy_session,
- &policy_session_bytes);
+ rc = Serialize_TPMI_SH_POLICY(policy_session, &policy_session_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string nonce_tpm_bytes;
- rc = Serialize_TPM2B_NONCE(
- nonce_tpm,
- &nonce_tpm_bytes);
+ rc = Serialize_TPM2B_NONCE(nonce_tpm, &nonce_tpm_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string cp_hash_a_bytes;
- rc = Serialize_TPM2B_DIGEST(
- cp_hash_a,
- &cp_hash_a_bytes);
+ rc = Serialize_TPM2B_DIGEST(cp_hash_a, &cp_hash_a_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_ref_bytes;
- rc = Serialize_TPM2B_NONCE(
- policy_ref,
- &policy_ref_bytes);
+ rc = Serialize_TPM2B_NONCE(policy_ref, &policy_ref_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string expiration_bytes;
- rc = Serialize_INT32(
- expiration,
- &expiration_bytes);
+ rc = Serialize_INT32(expiration, &expiration_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_bytes;
- rc = Serialize_TPMT_SIGNATURE(
- auth,
- &auth_bytes);
+ rc = Serialize_TPMT_SIGNATURE(auth, &auth_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -25510,36 +20803,28 @@
}
nonce_tpm_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_object_name.data(),
- auth_object_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_object_name.data(), auth_object_name.size());
handle_section_bytes += auth_object_bytes;
command_size += auth_object_bytes.size();
- hash->Update(policy_session_name.data(),
- policy_session_name.size());
+ hash->Update(policy_session_name.data(), policy_session_name.size());
handle_section_bytes += policy_session_bytes;
command_size += policy_session_bytes.size();
- hash->Update(nonce_tpm_bytes.data(),
- nonce_tpm_bytes.size());
+ hash->Update(nonce_tpm_bytes.data(), nonce_tpm_bytes.size());
parameter_section_bytes += nonce_tpm_bytes;
command_size += nonce_tpm_bytes.size();
- hash->Update(cp_hash_a_bytes.data(),
- cp_hash_a_bytes.size());
+ hash->Update(cp_hash_a_bytes.data(), cp_hash_a_bytes.size());
parameter_section_bytes += cp_hash_a_bytes;
command_size += cp_hash_a_bytes.size();
- hash->Update(policy_ref_bytes.data(),
- policy_ref_bytes.size());
+ hash->Update(policy_ref_bytes.data(), policy_ref_bytes.size());
parameter_section_bytes += policy_ref_bytes;
command_size += policy_ref_bytes.size();
- hash->Update(expiration_bytes.data(),
- expiration_bytes.size());
+ hash->Update(expiration_bytes.data(), expiration_bytes.size());
parameter_section_bytes += expiration_bytes;
command_size += expiration_bytes.size();
- hash->Update(auth_bytes.data(),
- auth_bytes.size());
+ hash->Update(auth_bytes.data(), auth_bytes.size());
parameter_section_bytes += auth_bytes;
command_size += auth_bytes.size();
std::string command_hash(32, 0);
@@ -25548,10 +20833,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -25562,31 +20846,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -25594,38 +20870,29 @@
}
TPM_RC Tpm::ParseResponse_PolicySigned(
- const std::string& response,
- TPM2B_TIMEOUT* timeout,
- TPMT_TK_AUTH* policy_ticket,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_TIMEOUT* timeout,
+ TPMT_TK_AUTH* policy_ticket,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -25637,9 +20904,7 @@
}
TPM_CC command_code = TPM_CC_PolicySigned;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -25657,37 +20922,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string timeout_bytes;
- rc = Parse_TPM2B_TIMEOUT(
- &buffer,
- timeout,
- &timeout_bytes);
+ rc = Parse_TPM2B_TIMEOUT(&buffer, timeout, &timeout_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_ticket_bytes;
- rc = Parse_TPMT_TK_AUTH(
- &buffer,
- policy_ticket,
- &policy_ticket_bytes);
+ rc = Parse_TPMT_TK_AUTH(&buffer, policy_ticket, &policy_ticket_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -25699,10 +20954,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
timeout_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_TIMEOUT(
- &timeout_bytes,
- timeout,
- nullptr);
+ rc = Parse_TPM2B_TIMEOUT(&timeout_bytes, timeout, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -25710,70 +20962,49 @@
return TPM_RC_SUCCESS;
}
-void PolicySignedErrorCallback(
- const Tpm::PolicySignedResponse& callback,
- TPM_RC response_code) {
+void PolicySignedErrorCallback(const Tpm::PolicySignedResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_TIMEOUT(),
- TPMT_TK_AUTH());
+ callback.Run(response_code, TPM2B_TIMEOUT(), TPMT_TK_AUTH());
}
-void PolicySignedResponseParser(
- const Tpm::PolicySignedResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void PolicySignedResponseParser(const Tpm::PolicySignedResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicySignedErrorCallback, callback);
TPM2B_TIMEOUT timeout;
TPMT_TK_AUTH policy_ticket;
TPM_RC rc = Tpm::ParseResponse_PolicySigned(
- response,
- &timeout,
- &policy_ticket,
- authorization_delegate);
+ response, &timeout, &policy_ticket, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- timeout,
- policy_ticket);
+ callback.Run(rc, timeout, policy_ticket);
}
-void Tpm::PolicySigned(
- const TPMI_DH_OBJECT& auth_object,
- const std::string& auth_object_name,
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_NONCE& nonce_tpm,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const INT32& expiration,
- const TPMT_SIGNATURE& auth,
- AuthorizationDelegate* authorization_delegate,
- const PolicySignedResponse& callback) {
+void Tpm::PolicySigned(const TPMI_DH_OBJECT& auth_object,
+ const std::string& auth_object_name,
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_NONCE& nonce_tpm,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const INT32& expiration,
+ const TPMT_SIGNATURE& auth,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicySignedResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicySignedErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(PolicySignedResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(PolicySignedResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_PolicySigned(
- auth_object,
- auth_object_name,
- policy_session,
- policy_session_name,
- nonce_tpm,
- cp_hash_a,
- policy_ref,
- expiration,
- auth,
- &command,
+ auth_object, auth_object_name, policy_session, policy_session_name,
+ nonce_tpm, cp_hash_a, policy_ref, expiration, auth, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
@@ -25782,56 +21013,44 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PolicySignedSync(
- const TPMI_DH_OBJECT& auth_object,
- const std::string& auth_object_name,
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_NONCE& nonce_tpm,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const INT32& expiration,
- const TPMT_SIGNATURE& auth,
- TPM2B_TIMEOUT* timeout,
- TPMT_TK_AUTH* policy_ticket,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PolicySignedSync(const TPMI_DH_OBJECT& auth_object,
+ const std::string& auth_object_name,
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_NONCE& nonce_tpm,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const INT32& expiration,
+ const TPMT_SIGNATURE& auth,
+ TPM2B_TIMEOUT* timeout,
+ TPMT_TK_AUTH* policy_ticket,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_PolicySigned(
- auth_object,
- auth_object_name,
- policy_session,
- policy_session_name,
- nonce_tpm,
- cp_hash_a,
- policy_ref,
- expiration,
- auth,
- &command,
+ auth_object, auth_object_name, policy_session, policy_session_name,
+ nonce_tpm, cp_hash_a, policy_ref, expiration, auth, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicySigned(
- response,
- timeout,
- policy_ticket,
- authorization_delegate);
+ rc = ParseResponse_PolicySigned(response, timeout, policy_ticket,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicySecret(
- const TPMI_DH_ENTITY& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_NONCE& nonce_tpm,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const INT32& expiration,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_ENTITY& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_NONCE& nonce_tpm,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const INT32& expiration,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -25842,51 +21061,37 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_DH_ENTITY(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_DH_ENTITY(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_session_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- policy_session,
- &policy_session_bytes);
+ rc = Serialize_TPMI_SH_POLICY(policy_session, &policy_session_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string nonce_tpm_bytes;
- rc = Serialize_TPM2B_NONCE(
- nonce_tpm,
- &nonce_tpm_bytes);
+ rc = Serialize_TPM2B_NONCE(nonce_tpm, &nonce_tpm_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string cp_hash_a_bytes;
- rc = Serialize_TPM2B_DIGEST(
- cp_hash_a,
- &cp_hash_a_bytes);
+ rc = Serialize_TPM2B_DIGEST(cp_hash_a, &cp_hash_a_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_ref_bytes;
- rc = Serialize_TPM2B_NONCE(
- policy_ref,
- &policy_ref_bytes);
+ rc = Serialize_TPM2B_NONCE(policy_ref, &policy_ref_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string expiration_bytes;
- rc = Serialize_INT32(
- expiration,
- &expiration_bytes);
+ rc = Serialize_INT32(expiration, &expiration_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -25898,32 +21103,25 @@
}
nonce_tpm_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
- hash->Update(policy_session_name.data(),
- policy_session_name.size());
+ hash->Update(policy_session_name.data(), policy_session_name.size());
handle_section_bytes += policy_session_bytes;
command_size += policy_session_bytes.size();
- hash->Update(nonce_tpm_bytes.data(),
- nonce_tpm_bytes.size());
+ hash->Update(nonce_tpm_bytes.data(), nonce_tpm_bytes.size());
parameter_section_bytes += nonce_tpm_bytes;
command_size += nonce_tpm_bytes.size();
- hash->Update(cp_hash_a_bytes.data(),
- cp_hash_a_bytes.size());
+ hash->Update(cp_hash_a_bytes.data(), cp_hash_a_bytes.size());
parameter_section_bytes += cp_hash_a_bytes;
command_size += cp_hash_a_bytes.size();
- hash->Update(policy_ref_bytes.data(),
- policy_ref_bytes.size());
+ hash->Update(policy_ref_bytes.data(), policy_ref_bytes.size());
parameter_section_bytes += policy_ref_bytes;
command_size += policy_ref_bytes.size();
- hash->Update(expiration_bytes.data(),
- expiration_bytes.size());
+ hash->Update(expiration_bytes.data(), expiration_bytes.size());
parameter_section_bytes += expiration_bytes;
command_size += expiration_bytes.size();
std::string command_hash(32, 0);
@@ -25932,10 +21130,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -25946,31 +21143,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -25978,38 +21167,29 @@
}
TPM_RC Tpm::ParseResponse_PolicySecret(
- const std::string& response,
- TPM2B_TIMEOUT* timeout,
- TPMT_TK_AUTH* policy_ticket,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_TIMEOUT* timeout,
+ TPMT_TK_AUTH* policy_ticket,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -26021,9 +21201,7 @@
}
TPM_CC command_code = TPM_CC_PolicySecret;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -26041,37 +21219,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string timeout_bytes;
- rc = Parse_TPM2B_TIMEOUT(
- &buffer,
- timeout,
- &timeout_bytes);
+ rc = Parse_TPM2B_TIMEOUT(&buffer, timeout, &timeout_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_ticket_bytes;
- rc = Parse_TPMT_TK_AUTH(
- &buffer,
- policy_ticket,
- &policy_ticket_bytes);
+ rc = Parse_TPMT_TK_AUTH(&buffer, policy_ticket, &policy_ticket_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -26083,10 +21251,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
timeout_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_TIMEOUT(
- &timeout_bytes,
- timeout,
- nullptr);
+ rc = Parse_TPM2B_TIMEOUT(&timeout_bytes, timeout, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -26094,68 +21259,48 @@
return TPM_RC_SUCCESS;
}
-void PolicySecretErrorCallback(
- const Tpm::PolicySecretResponse& callback,
- TPM_RC response_code) {
+void PolicySecretErrorCallback(const Tpm::PolicySecretResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_TIMEOUT(),
- TPMT_TK_AUTH());
+ callback.Run(response_code, TPM2B_TIMEOUT(), TPMT_TK_AUTH());
}
-void PolicySecretResponseParser(
- const Tpm::PolicySecretResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void PolicySecretResponseParser(const Tpm::PolicySecretResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicySecretErrorCallback, callback);
TPM2B_TIMEOUT timeout;
TPMT_TK_AUTH policy_ticket;
TPM_RC rc = Tpm::ParseResponse_PolicySecret(
- response,
- &timeout,
- &policy_ticket,
- authorization_delegate);
+ response, &timeout, &policy_ticket, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- timeout,
- policy_ticket);
+ callback.Run(rc, timeout, policy_ticket);
}
-void Tpm::PolicySecret(
- const TPMI_DH_ENTITY& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_NONCE& nonce_tpm,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const INT32& expiration,
- AuthorizationDelegate* authorization_delegate,
- const PolicySecretResponse& callback) {
+void Tpm::PolicySecret(const TPMI_DH_ENTITY& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_NONCE& nonce_tpm,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const INT32& expiration,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicySecretResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicySecretErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(PolicySecretResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(PolicySecretResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_PolicySecret(
- auth_handle,
- auth_handle_name,
- policy_session,
- policy_session_name,
- nonce_tpm,
- cp_hash_a,
- policy_ref,
- expiration,
- &command,
+ auth_handle, auth_handle_name, policy_session, policy_session_name,
+ nonce_tpm, cp_hash_a, policy_ref, expiration, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
@@ -26164,53 +21309,42 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PolicySecretSync(
- const TPMI_DH_ENTITY& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_NONCE& nonce_tpm,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const INT32& expiration,
- TPM2B_TIMEOUT* timeout,
- TPMT_TK_AUTH* policy_ticket,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PolicySecretSync(const TPMI_DH_ENTITY& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_NONCE& nonce_tpm,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const INT32& expiration,
+ TPM2B_TIMEOUT* timeout,
+ TPMT_TK_AUTH* policy_ticket,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_PolicySecret(
- auth_handle,
- auth_handle_name,
- policy_session,
- policy_session_name,
- nonce_tpm,
- cp_hash_a,
- policy_ref,
- expiration,
- &command,
+ auth_handle, auth_handle_name, policy_session, policy_session_name,
+ nonce_tpm, cp_hash_a, policy_ref, expiration, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicySecret(
- response,
- timeout,
- policy_ticket,
- authorization_delegate);
+ rc = ParseResponse_PolicySecret(response, timeout, policy_ticket,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicyTicket(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_TIMEOUT& timeout,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const TPM2B_NAME& auth_name,
- const TPMT_TK_AUTH& ticket,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_TIMEOUT& timeout,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const TPM2B_NAME& auth_name,
+ const TPMT_TK_AUTH& ticket,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -26221,51 +21355,37 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_session_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- policy_session,
- &policy_session_bytes);
+ rc = Serialize_TPMI_SH_POLICY(policy_session, &policy_session_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string timeout_bytes;
- rc = Serialize_TPM2B_TIMEOUT(
- timeout,
- &timeout_bytes);
+ rc = Serialize_TPM2B_TIMEOUT(timeout, &timeout_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string cp_hash_a_bytes;
- rc = Serialize_TPM2B_DIGEST(
- cp_hash_a,
- &cp_hash_a_bytes);
+ rc = Serialize_TPM2B_DIGEST(cp_hash_a, &cp_hash_a_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_ref_bytes;
- rc = Serialize_TPM2B_NONCE(
- policy_ref,
- &policy_ref_bytes);
+ rc = Serialize_TPM2B_NONCE(policy_ref, &policy_ref_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_name_bytes;
- rc = Serialize_TPM2B_NAME(
- auth_name,
- &auth_name_bytes);
+ rc = Serialize_TPM2B_NAME(auth_name, &auth_name_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string ticket_bytes;
- rc = Serialize_TPMT_TK_AUTH(
- ticket,
- &ticket_bytes);
+ rc = Serialize_TPMT_TK_AUTH(ticket, &ticket_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -26277,32 +21397,25 @@
}
timeout_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(policy_session_name.data(),
- policy_session_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(policy_session_name.data(), policy_session_name.size());
handle_section_bytes += policy_session_bytes;
command_size += policy_session_bytes.size();
- hash->Update(timeout_bytes.data(),
- timeout_bytes.size());
+ hash->Update(timeout_bytes.data(), timeout_bytes.size());
parameter_section_bytes += timeout_bytes;
command_size += timeout_bytes.size();
- hash->Update(cp_hash_a_bytes.data(),
- cp_hash_a_bytes.size());
+ hash->Update(cp_hash_a_bytes.data(), cp_hash_a_bytes.size());
parameter_section_bytes += cp_hash_a_bytes;
command_size += cp_hash_a_bytes.size();
- hash->Update(policy_ref_bytes.data(),
- policy_ref_bytes.size());
+ hash->Update(policy_ref_bytes.data(), policy_ref_bytes.size());
parameter_section_bytes += policy_ref_bytes;
command_size += policy_ref_bytes.size();
- hash->Update(auth_name_bytes.data(),
- auth_name_bytes.size());
+ hash->Update(auth_name_bytes.data(), auth_name_bytes.size());
parameter_section_bytes += auth_name_bytes;
command_size += auth_name_bytes.size();
- hash->Update(ticket_bytes.data(),
- ticket_bytes.size());
+ hash->Update(ticket_bytes.data(), ticket_bytes.size());
parameter_section_bytes += ticket_bytes;
command_size += ticket_bytes.size();
std::string command_hash(32, 0);
@@ -26311,10 +21424,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -26325,31 +21437,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -26357,36 +21461,27 @@
}
TPM_RC Tpm::ParseResponse_PolicyTicket(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -26398,9 +21493,7 @@
}
TPM_CC command_code = TPM_CC_PolicyTicket;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -26418,80 +21511,61 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void PolicyTicketErrorCallback(
- const Tpm::PolicyTicketResponse& callback,
- TPM_RC response_code) {
+void PolicyTicketErrorCallback(const Tpm::PolicyTicketResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void PolicyTicketResponseParser(
- const Tpm::PolicyTicketResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void PolicyTicketResponseParser(const Tpm::PolicyTicketResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyTicketErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PolicyTicket(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_PolicyTicket(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PolicyTicket(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_TIMEOUT& timeout,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const TPM2B_NAME& auth_name,
- const TPMT_TK_AUTH& ticket,
- AuthorizationDelegate* authorization_delegate,
- const PolicyTicketResponse& callback) {
+void Tpm::PolicyTicket(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_TIMEOUT& timeout,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const TPM2B_NAME& auth_name,
+ const TPMT_TK_AUTH& ticket,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyTicketResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyTicketErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(PolicyTicketResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(PolicyTicketResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_PolicyTicket(
- policy_session,
- policy_session_name,
- timeout,
- cp_hash_a,
- policy_ref,
- auth_name,
- ticket,
- &command,
- authorization_delegate);
+ policy_session, policy_session_name, timeout, cp_hash_a, policy_ref,
+ auth_name, ticket, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -26499,43 +21573,33 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PolicyTicketSync(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_TIMEOUT& timeout,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const TPM2B_NAME& auth_name,
- const TPMT_TK_AUTH& ticket,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PolicyTicketSync(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_TIMEOUT& timeout,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const TPM2B_NAME& auth_name,
+ const TPMT_TK_AUTH& ticket,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_PolicyTicket(
- policy_session,
- policy_session_name,
- timeout,
- cp_hash_a,
- policy_ref,
- auth_name,
- ticket,
- &command,
- authorization_delegate);
+ policy_session, policy_session_name, timeout, cp_hash_a, policy_ref,
+ auth_name, ticket, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicyTicket(
- response,
- authorization_delegate);
+ rc = ParseResponse_PolicyTicket(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicyOR(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPML_DIGEST& p_hash_list,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPML_DIGEST& p_hash_list,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -26546,36 +21610,27 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_session_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- policy_session,
- &policy_session_bytes);
+ rc = Serialize_TPMI_SH_POLICY(policy_session, &policy_session_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string p_hash_list_bytes;
- rc = Serialize_TPML_DIGEST(
- p_hash_list,
- &p_hash_list_bytes);
+ rc = Serialize_TPML_DIGEST(p_hash_list, &p_hash_list_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(policy_session_name.data(),
- policy_session_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(policy_session_name.data(), policy_session_name.size());
handle_section_bytes += policy_session_bytes;
command_size += policy_session_bytes.size();
- hash->Update(p_hash_list_bytes.data(),
- p_hash_list_bytes.size());
+ hash->Update(p_hash_list_bytes.data(), p_hash_list_bytes.size());
parameter_section_bytes += p_hash_list_bytes;
command_size += p_hash_list_bytes.size();
std::string command_hash(32, 0);
@@ -26584,10 +21639,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -26598,31 +21652,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -26630,36 +21676,27 @@
}
TPM_RC Tpm::ParseResponse_PolicyOR(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -26671,9 +21708,7 @@
}
TPM_CC command_code = TPM_CC_PolicyOR;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -26691,72 +21726,57 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void PolicyORErrorCallback(
- const Tpm::PolicyORResponse& callback,
- TPM_RC response_code) {
+void PolicyORErrorCallback(const Tpm::PolicyORResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void PolicyORResponseParser(
- const Tpm::PolicyORResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void PolicyORResponseParser(const Tpm::PolicyORResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyORErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PolicyOR(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_PolicyOR(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PolicyOR(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPML_DIGEST& p_hash_list,
- AuthorizationDelegate* authorization_delegate,
- const PolicyORResponse& callback) {
+void Tpm::PolicyOR(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPML_DIGEST& p_hash_list,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyORResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyORErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(PolicyORResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(PolicyORResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_PolicyOR(
- policy_session,
- policy_session_name,
- p_hash_list,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_PolicyOR(policy_session, policy_session_name,
+ p_hash_list, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -26764,36 +21784,30 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PolicyORSync(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPML_DIGEST& p_hash_list,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PolicyORSync(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPML_DIGEST& p_hash_list,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_PolicyOR(
- policy_session,
- policy_session_name,
- p_hash_list,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_PolicyOR(policy_session, policy_session_name,
+ p_hash_list, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicyOR(
- response,
- authorization_delegate);
+ rc = ParseResponse_PolicyOR(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicyPCR(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& pcr_digest,
- const TPML_PCR_SELECTION& pcrs,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& pcr_digest,
+ const TPML_PCR_SELECTION& pcrs,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -26804,30 +21818,22 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_session_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- policy_session,
- &policy_session_bytes);
+ rc = Serialize_TPMI_SH_POLICY(policy_session, &policy_session_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string pcr_digest_bytes;
- rc = Serialize_TPM2B_DIGEST(
- pcr_digest,
- &pcr_digest_bytes);
+ rc = Serialize_TPM2B_DIGEST(pcr_digest, &pcr_digest_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string pcrs_bytes;
- rc = Serialize_TPML_PCR_SELECTION(
- pcrs,
- &pcrs_bytes);
+ rc = Serialize_TPML_PCR_SELECTION(pcrs, &pcrs_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -26839,20 +21845,16 @@
}
pcr_digest_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(policy_session_name.data(),
- policy_session_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(policy_session_name.data(), policy_session_name.size());
handle_section_bytes += policy_session_bytes;
command_size += policy_session_bytes.size();
- hash->Update(pcr_digest_bytes.data(),
- pcr_digest_bytes.size());
+ hash->Update(pcr_digest_bytes.data(), pcr_digest_bytes.size());
parameter_section_bytes += pcr_digest_bytes;
command_size += pcr_digest_bytes.size();
- hash->Update(pcrs_bytes.data(),
- pcrs_bytes.size());
+ hash->Update(pcrs_bytes.data(), pcrs_bytes.size());
parameter_section_bytes += pcrs_bytes;
command_size += pcrs_bytes.size();
std::string command_hash(32, 0);
@@ -26861,10 +21863,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -26875,31 +21876,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -26907,36 +21900,27 @@
}
TPM_RC Tpm::ParseResponse_PolicyPCR(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -26948,9 +21932,7 @@
}
TPM_CC command_code = TPM_CC_PolicyPCR;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -26968,74 +21950,58 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void PolicyPCRErrorCallback(
- const Tpm::PolicyPCRResponse& callback,
- TPM_RC response_code) {
+void PolicyPCRErrorCallback(const Tpm::PolicyPCRResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void PolicyPCRResponseParser(
- const Tpm::PolicyPCRResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void PolicyPCRResponseParser(const Tpm::PolicyPCRResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyPCRErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PolicyPCR(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_PolicyPCR(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PolicyPCR(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& pcr_digest,
- const TPML_PCR_SELECTION& pcrs,
- AuthorizationDelegate* authorization_delegate,
- const PolicyPCRResponse& callback) {
+void Tpm::PolicyPCR(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& pcr_digest,
+ const TPML_PCR_SELECTION& pcrs,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyPCRResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyPCRErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(PolicyPCRResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(PolicyPCRResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_PolicyPCR(
- policy_session,
- policy_session_name,
- pcr_digest,
- pcrs,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_PolicyPCR(policy_session, policy_session_name,
+ pcr_digest, pcrs, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -27043,37 +22009,30 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PolicyPCRSync(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& pcr_digest,
- const TPML_PCR_SELECTION& pcrs,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PolicyPCRSync(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& pcr_digest,
+ const TPML_PCR_SELECTION& pcrs,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_PolicyPCR(
- policy_session,
- policy_session_name,
- pcr_digest,
- pcrs,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_PolicyPCR(policy_session, policy_session_name,
+ pcr_digest, pcrs, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicyPCR(
- response,
- authorization_delegate);
+ rc = ParseResponse_PolicyPCR(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicyLocality(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPMA_LOCALITY& locality,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPMA_LOCALITY& locality,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -27084,36 +22043,27 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_session_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- policy_session,
- &policy_session_bytes);
+ rc = Serialize_TPMI_SH_POLICY(policy_session, &policy_session_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string locality_bytes;
- rc = Serialize_TPMA_LOCALITY(
- locality,
- &locality_bytes);
+ rc = Serialize_TPMA_LOCALITY(locality, &locality_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(policy_session_name.data(),
- policy_session_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(policy_session_name.data(), policy_session_name.size());
handle_section_bytes += policy_session_bytes;
command_size += policy_session_bytes.size();
- hash->Update(locality_bytes.data(),
- locality_bytes.size());
+ hash->Update(locality_bytes.data(), locality_bytes.size());
parameter_section_bytes += locality_bytes;
command_size += locality_bytes.size();
std::string command_hash(32, 0);
@@ -27122,10 +22072,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -27136,31 +22085,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -27168,36 +22109,27 @@
}
TPM_RC Tpm::ParseResponse_PolicyLocality(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -27209,9 +22141,7 @@
}
TPM_CC command_code = TPM_CC_PolicyLocality;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -27229,72 +22159,58 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void PolicyLocalityErrorCallback(
- const Tpm::PolicyLocalityResponse& callback,
- TPM_RC response_code) {
+void PolicyLocalityErrorCallback(const Tpm::PolicyLocalityResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void PolicyLocalityResponseParser(
- const Tpm::PolicyLocalityResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void PolicyLocalityResponseParser(const Tpm::PolicyLocalityResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyLocalityErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PolicyLocality(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_PolicyLocality(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PolicyLocality(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPMA_LOCALITY& locality,
- AuthorizationDelegate* authorization_delegate,
- const PolicyLocalityResponse& callback) {
+void Tpm::PolicyLocality(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPMA_LOCALITY& locality,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyLocalityResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyLocalityErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(PolicyLocalityResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ PolicyLocalityResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_PolicyLocality(
- policy_session,
- policy_session_name,
- locality,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_PolicyLocality(policy_session,
+ policy_session_name, locality,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -27302,41 +22218,35 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PolicyLocalitySync(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPMA_LOCALITY& locality,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PolicyLocalitySync(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPMA_LOCALITY& locality,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_PolicyLocality(
- policy_session,
- policy_session_name,
- locality,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_PolicyLocality(policy_session,
+ policy_session_name, locality,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicyLocality(
- response,
- authorization_delegate);
+ rc = ParseResponse_PolicyLocality(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicyNV(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_OPERAND& operand_b,
- const UINT16& offset,
- const TPM_EO& operation,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_OPERAND& operand_b,
+ const UINT16& offset,
+ const TPM_EO& operation,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -27347,51 +22257,37 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_NV_AUTH(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_NV_AUTH(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string nv_index_bytes;
- rc = Serialize_TPMI_RH_NV_INDEX(
- nv_index,
- &nv_index_bytes);
+ rc = Serialize_TPMI_RH_NV_INDEX(nv_index, &nv_index_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_session_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- policy_session,
- &policy_session_bytes);
+ rc = Serialize_TPMI_SH_POLICY(policy_session, &policy_session_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string operand_b_bytes;
- rc = Serialize_TPM2B_OPERAND(
- operand_b,
- &operand_b_bytes);
+ rc = Serialize_TPM2B_OPERAND(operand_b, &operand_b_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string offset_bytes;
- rc = Serialize_UINT16(
- offset,
- &offset_bytes);
+ rc = Serialize_UINT16(offset, &offset_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string operation_bytes;
- rc = Serialize_TPM_EO(
- operation,
- &operation_bytes);
+ rc = Serialize_TPM_EO(operation, &operation_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -27403,32 +22299,25 @@
}
operand_b_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
- hash->Update(nv_index_name.data(),
- nv_index_name.size());
+ hash->Update(nv_index_name.data(), nv_index_name.size());
handle_section_bytes += nv_index_bytes;
command_size += nv_index_bytes.size();
- hash->Update(policy_session_name.data(),
- policy_session_name.size());
+ hash->Update(policy_session_name.data(), policy_session_name.size());
handle_section_bytes += policy_session_bytes;
command_size += policy_session_bytes.size();
- hash->Update(operand_b_bytes.data(),
- operand_b_bytes.size());
+ hash->Update(operand_b_bytes.data(), operand_b_bytes.size());
parameter_section_bytes += operand_b_bytes;
command_size += operand_b_bytes.size();
- hash->Update(offset_bytes.data(),
- offset_bytes.size());
+ hash->Update(offset_bytes.data(), offset_bytes.size());
parameter_section_bytes += offset_bytes;
command_size += offset_bytes.size();
- hash->Update(operation_bytes.data(),
- operation_bytes.size());
+ hash->Update(operation_bytes.data(), operation_bytes.size());
parameter_section_bytes += operation_bytes;
command_size += operation_bytes.size();
std::string command_hash(32, 0);
@@ -27437,10 +22326,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -27451,31 +22339,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -27483,36 +22363,27 @@
}
TPM_RC Tpm::ParseResponse_PolicyNV(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -27524,9 +22395,7 @@
}
TPM_CC command_code = TPM_CC_PolicyNV;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -27544,83 +22413,63 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void PolicyNVErrorCallback(
- const Tpm::PolicyNVResponse& callback,
- TPM_RC response_code) {
+void PolicyNVErrorCallback(const Tpm::PolicyNVResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void PolicyNVResponseParser(
- const Tpm::PolicyNVResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void PolicyNVResponseParser(const Tpm::PolicyNVResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyNVErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PolicyNV(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_PolicyNV(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PolicyNV(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_OPERAND& operand_b,
- const UINT16& offset,
- const TPM_EO& operation,
- AuthorizationDelegate* authorization_delegate,
- const PolicyNVResponse& callback) {
+void Tpm::PolicyNV(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_OPERAND& operand_b,
+ const UINT16& offset,
+ const TPM_EO& operation,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyNVResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyNVErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(PolicyNVResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(PolicyNVResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_PolicyNV(
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- policy_session,
- policy_session_name,
- operand_b,
- offset,
- operation,
- &command,
+ auth_handle, auth_handle_name, nv_index, nv_index_name, policy_session,
+ policy_session_name, operand_b, offset, operation, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
@@ -27629,49 +22478,38 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PolicyNVSync(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_OPERAND& operand_b,
- const UINT16& offset,
- const TPM_EO& operation,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PolicyNVSync(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_OPERAND& operand_b,
+ const UINT16& offset,
+ const TPM_EO& operation,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_PolicyNV(
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- policy_session,
- policy_session_name,
- operand_b,
- offset,
- operation,
- &command,
+ auth_handle, auth_handle_name, nv_index, nv_index_name, policy_session,
+ policy_session_name, operand_b, offset, operation, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicyNV(
- response,
- authorization_delegate);
+ rc = ParseResponse_PolicyNV(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicyCounterTimer(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_OPERAND& operand_b,
- const UINT16& offset,
- const TPM_EO& operation,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_OPERAND& operand_b,
+ const UINT16& offset,
+ const TPM_EO& operation,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -27682,37 +22520,27 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_session_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- policy_session,
- &policy_session_bytes);
+ rc = Serialize_TPMI_SH_POLICY(policy_session, &policy_session_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string operand_b_bytes;
- rc = Serialize_TPM2B_OPERAND(
- operand_b,
- &operand_b_bytes);
+ rc = Serialize_TPM2B_OPERAND(operand_b, &operand_b_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string offset_bytes;
- rc = Serialize_UINT16(
- offset,
- &offset_bytes);
+ rc = Serialize_UINT16(offset, &offset_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string operation_bytes;
- rc = Serialize_TPM_EO(
- operation,
- &operation_bytes);
+ rc = Serialize_TPM_EO(operation, &operation_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -27724,24 +22552,19 @@
}
operand_b_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(policy_session_name.data(),
- policy_session_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(policy_session_name.data(), policy_session_name.size());
handle_section_bytes += policy_session_bytes;
command_size += policy_session_bytes.size();
- hash->Update(operand_b_bytes.data(),
- operand_b_bytes.size());
+ hash->Update(operand_b_bytes.data(), operand_b_bytes.size());
parameter_section_bytes += operand_b_bytes;
command_size += operand_b_bytes.size();
- hash->Update(offset_bytes.data(),
- offset_bytes.size());
+ hash->Update(offset_bytes.data(), offset_bytes.size());
parameter_section_bytes += offset_bytes;
command_size += offset_bytes.size();
- hash->Update(operation_bytes.data(),
- operation_bytes.size());
+ hash->Update(operation_bytes.data(), operation_bytes.size());
parameter_section_bytes += operation_bytes;
command_size += operation_bytes.size();
std::string command_hash(32, 0);
@@ -27750,10 +22573,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -27764,31 +22586,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -27796,36 +22610,27 @@
}
TPM_RC Tpm::ParseResponse_PolicyCounterTimer(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -27837,9 +22642,7 @@
}
TPM_CC command_code = TPM_CC_PolicyCounterTimer;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -27857,21 +22660,17 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
@@ -27892,41 +22691,31 @@
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyCounterTimerErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PolicyCounterTimer(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_PolicyCounterTimer(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PolicyCounterTimer(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_OPERAND& operand_b,
- const UINT16& offset,
- const TPM_EO& operation,
- AuthorizationDelegate* authorization_delegate,
- const PolicyCounterTimerResponse& callback) {
+void Tpm::PolicyCounterTimer(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_OPERAND& operand_b,
+ const UINT16& offset,
+ const TPM_EO& operation,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyCounterTimerResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyCounterTimerErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(PolicyCounterTimerResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ PolicyCounterTimerResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_PolicyCounterTimer(
- policy_session,
- policy_session_name,
- operand_b,
- offset,
- operation,
- &command,
- authorization_delegate);
+ policy_session, policy_session_name, operand_b, offset, operation,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -27935,38 +22724,31 @@
}
TPM_RC Tpm::PolicyCounterTimerSync(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_OPERAND& operand_b,
- const UINT16& offset,
- const TPM_EO& operation,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_OPERAND& operand_b,
+ const UINT16& offset,
+ const TPM_EO& operation,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_PolicyCounterTimer(
- policy_session,
- policy_session_name,
- operand_b,
- offset,
- operation,
- &command,
- authorization_delegate);
+ policy_session, policy_session_name, operand_b, offset, operation,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicyCounterTimer(
- response,
- authorization_delegate);
+ rc = ParseResponse_PolicyCounterTimer(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicyCommandCode(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM_CC& code,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM_CC& code,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -27977,36 +22759,27 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_session_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- policy_session,
- &policy_session_bytes);
+ rc = Serialize_TPMI_SH_POLICY(policy_session, &policy_session_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string code_bytes;
- rc = Serialize_TPM_CC(
- code,
- &code_bytes);
+ rc = Serialize_TPM_CC(code, &code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(policy_session_name.data(),
- policy_session_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(policy_session_name.data(), policy_session_name.size());
handle_section_bytes += policy_session_bytes;
command_size += policy_session_bytes.size();
- hash->Update(code_bytes.data(),
- code_bytes.size());
+ hash->Update(code_bytes.data(), code_bytes.size());
parameter_section_bytes += code_bytes;
command_size += code_bytes.size();
std::string command_hash(32, 0);
@@ -28015,10 +22788,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -28029,31 +22801,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -28061,36 +22825,27 @@
}
TPM_RC Tpm::ParseResponse_PolicyCommandCode(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -28102,9 +22857,7 @@
}
TPM_CC command_code = TPM_CC_PolicyCommandCode;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -28122,21 +22875,17 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
@@ -28157,36 +22906,28 @@
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyCommandCodeErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PolicyCommandCode(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_PolicyCommandCode(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PolicyCommandCode(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM_CC& code,
- AuthorizationDelegate* authorization_delegate,
- const PolicyCommandCodeResponse& callback) {
+void Tpm::PolicyCommandCode(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM_CC& code,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyCommandCodeResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyCommandCodeErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(PolicyCommandCodeResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ PolicyCommandCodeResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_PolicyCommandCode(
- policy_session,
- policy_session_name,
- code,
- &command,
+ policy_session, policy_session_name, code, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
@@ -28196,33 +22937,28 @@
}
TPM_RC Tpm::PolicyCommandCodeSync(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM_CC& code,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM_CC& code,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_PolicyCommandCode(
- policy_session,
- policy_session_name,
- code,
- &command,
+ policy_session, policy_session_name, code, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicyCommandCode(
- response,
- authorization_delegate);
+ rc = ParseResponse_PolicyCommandCode(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicyPhysicalPresence(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -28233,25 +22969,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_session_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- policy_session,
- &policy_session_bytes);
+ rc = Serialize_TPMI_SH_POLICY(policy_session, &policy_session_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(policy_session_name.data(),
- policy_session_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(policy_session_name.data(), policy_session_name.size());
handle_section_bytes += policy_session_bytes;
command_size += policy_session_bytes.size();
std::string command_hash(32, 0);
@@ -28260,10 +22990,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -28274,31 +23003,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -28306,36 +23027,27 @@
}
TPM_RC Tpm::ParseResponse_PolicyPhysicalPresence(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -28347,9 +23059,7 @@
}
TPM_CC command_code = TPM_CC_PolicyPhysicalPresence;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -28367,21 +23077,17 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
@@ -28402,35 +23108,28 @@
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyPhysicalPresenceErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PolicyPhysicalPresence(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_PolicyPhysicalPresence(response,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
void Tpm::PolicyPhysicalPresence(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- AuthorizationDelegate* authorization_delegate,
- const PolicyPhysicalPresenceResponse& callback) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyPhysicalPresenceResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyPhysicalPresenceErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(PolicyPhysicalPresenceResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ PolicyPhysicalPresenceResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_PolicyPhysicalPresence(
- policy_session,
- policy_session_name,
- &command,
- authorization_delegate);
+ policy_session, policy_session_name, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -28439,32 +23138,27 @@
}
TPM_RC Tpm::PolicyPhysicalPresenceSync(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_PolicyPhysicalPresence(
- policy_session,
- policy_session_name,
- &command,
- authorization_delegate);
+ policy_session, policy_session_name, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicyPhysicalPresence(
- response,
- authorization_delegate);
+ rc = ParseResponse_PolicyPhysicalPresence(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicyCpHash(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& cp_hash_a,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& cp_hash_a,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -28475,23 +23169,17 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_session_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- policy_session,
- &policy_session_bytes);
+ rc = Serialize_TPMI_SH_POLICY(policy_session, &policy_session_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string cp_hash_a_bytes;
- rc = Serialize_TPM2B_DIGEST(
- cp_hash_a,
- &cp_hash_a_bytes);
+ rc = Serialize_TPM2B_DIGEST(cp_hash_a, &cp_hash_a_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -28503,16 +23191,13 @@
}
cp_hash_a_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(policy_session_name.data(),
- policy_session_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(policy_session_name.data(), policy_session_name.size());
handle_section_bytes += policy_session_bytes;
command_size += policy_session_bytes.size();
- hash->Update(cp_hash_a_bytes.data(),
- cp_hash_a_bytes.size());
+ hash->Update(cp_hash_a_bytes.data(), cp_hash_a_bytes.size());
parameter_section_bytes += cp_hash_a_bytes;
command_size += cp_hash_a_bytes.size();
std::string command_hash(32, 0);
@@ -28521,10 +23206,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -28535,31 +23219,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -28567,36 +23243,27 @@
}
TPM_RC Tpm::ParseResponse_PolicyCpHash(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -28608,9 +23275,7 @@
}
TPM_CC command_code = TPM_CC_PolicyCpHash;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -28628,72 +23293,57 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void PolicyCpHashErrorCallback(
- const Tpm::PolicyCpHashResponse& callback,
- TPM_RC response_code) {
+void PolicyCpHashErrorCallback(const Tpm::PolicyCpHashResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void PolicyCpHashResponseParser(
- const Tpm::PolicyCpHashResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void PolicyCpHashResponseParser(const Tpm::PolicyCpHashResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyCpHashErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PolicyCpHash(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_PolicyCpHash(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PolicyCpHash(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& cp_hash_a,
- AuthorizationDelegate* authorization_delegate,
- const PolicyCpHashResponse& callback) {
+void Tpm::PolicyCpHash(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& cp_hash_a,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyCpHashResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyCpHashErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(PolicyCpHashResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(PolicyCpHashResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_PolicyCpHash(
- policy_session,
- policy_session_name,
- cp_hash_a,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_PolicyCpHash(policy_session, policy_session_name,
+ cp_hash_a, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -28701,35 +23351,29 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PolicyCpHashSync(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& cp_hash_a,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PolicyCpHashSync(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& cp_hash_a,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_PolicyCpHash(
- policy_session,
- policy_session_name,
- cp_hash_a,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_PolicyCpHash(policy_session, policy_session_name,
+ cp_hash_a, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicyCpHash(
- response,
- authorization_delegate);
+ rc = ParseResponse_PolicyCpHash(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicyNameHash(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& name_hash,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& name_hash,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -28740,23 +23384,17 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_session_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- policy_session,
- &policy_session_bytes);
+ rc = Serialize_TPMI_SH_POLICY(policy_session, &policy_session_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string name_hash_bytes;
- rc = Serialize_TPM2B_DIGEST(
- name_hash,
- &name_hash_bytes);
+ rc = Serialize_TPM2B_DIGEST(name_hash, &name_hash_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -28768,16 +23406,13 @@
}
name_hash_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(policy_session_name.data(),
- policy_session_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(policy_session_name.data(), policy_session_name.size());
handle_section_bytes += policy_session_bytes;
command_size += policy_session_bytes.size();
- hash->Update(name_hash_bytes.data(),
- name_hash_bytes.size());
+ hash->Update(name_hash_bytes.data(), name_hash_bytes.size());
parameter_section_bytes += name_hash_bytes;
command_size += name_hash_bytes.size();
std::string command_hash(32, 0);
@@ -28786,10 +23421,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -28800,31 +23434,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -28832,36 +23458,27 @@
}
TPM_RC Tpm::ParseResponse_PolicyNameHash(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -28873,9 +23490,7 @@
}
TPM_CC command_code = TPM_CC_PolicyNameHash;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -28893,72 +23508,58 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void PolicyNameHashErrorCallback(
- const Tpm::PolicyNameHashResponse& callback,
- TPM_RC response_code) {
+void PolicyNameHashErrorCallback(const Tpm::PolicyNameHashResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void PolicyNameHashResponseParser(
- const Tpm::PolicyNameHashResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void PolicyNameHashResponseParser(const Tpm::PolicyNameHashResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyNameHashErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PolicyNameHash(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_PolicyNameHash(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PolicyNameHash(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& name_hash,
- AuthorizationDelegate* authorization_delegate,
- const PolicyNameHashResponse& callback) {
+void Tpm::PolicyNameHash(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& name_hash,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyNameHashResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyNameHashErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(PolicyNameHashResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ PolicyNameHashResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_PolicyNameHash(
- policy_session,
- policy_session_name,
- name_hash,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_PolicyNameHash(policy_session,
+ policy_session_name, name_hash,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -28966,37 +23567,31 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PolicyNameHashSync(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& name_hash,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PolicyNameHashSync(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& name_hash,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_PolicyNameHash(
- policy_session,
- policy_session_name,
- name_hash,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_PolicyNameHash(policy_session,
+ policy_session_name, name_hash,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicyNameHash(
- response,
- authorization_delegate);
+ rc = ParseResponse_PolicyNameHash(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicyDuplicationSelect(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_NAME& object_name,
- const TPM2B_NAME& new_parent_name,
- const TPMI_YES_NO& include_object,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_NAME& object_name,
+ const TPM2B_NAME& new_parent_name,
+ const TPMI_YES_NO& include_object,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -29007,37 +23602,27 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_session_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- policy_session,
- &policy_session_bytes);
+ rc = Serialize_TPMI_SH_POLICY(policy_session, &policy_session_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string object_name_bytes;
- rc = Serialize_TPM2B_NAME(
- object_name,
- &object_name_bytes);
+ rc = Serialize_TPM2B_NAME(object_name, &object_name_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string new_parent_name_bytes;
- rc = Serialize_TPM2B_NAME(
- new_parent_name,
- &new_parent_name_bytes);
+ rc = Serialize_TPM2B_NAME(new_parent_name, &new_parent_name_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string include_object_bytes;
- rc = Serialize_TPMI_YES_NO(
- include_object,
- &include_object_bytes);
+ rc = Serialize_TPMI_YES_NO(include_object, &include_object_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -29049,24 +23634,19 @@
}
object_name_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(policy_session_name.data(),
- policy_session_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(policy_session_name.data(), policy_session_name.size());
handle_section_bytes += policy_session_bytes;
command_size += policy_session_bytes.size();
- hash->Update(object_name_bytes.data(),
- object_name_bytes.size());
+ hash->Update(object_name_bytes.data(), object_name_bytes.size());
parameter_section_bytes += object_name_bytes;
command_size += object_name_bytes.size();
- hash->Update(new_parent_name_bytes.data(),
- new_parent_name_bytes.size());
+ hash->Update(new_parent_name_bytes.data(), new_parent_name_bytes.size());
parameter_section_bytes += new_parent_name_bytes;
command_size += new_parent_name_bytes.size();
- hash->Update(include_object_bytes.data(),
- include_object_bytes.size());
+ hash->Update(include_object_bytes.data(), include_object_bytes.size());
parameter_section_bytes += include_object_bytes;
command_size += include_object_bytes.size();
std::string command_hash(32, 0);
@@ -29075,10 +23655,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -29089,31 +23668,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -29121,36 +23692,27 @@
}
TPM_RC Tpm::ParseResponse_PolicyDuplicationSelect(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -29162,9 +23724,7 @@
}
TPM_CC command_code = TPM_CC_PolicyDuplicationSelect;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -29182,21 +23742,17 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
@@ -29218,40 +23774,31 @@
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyDuplicationSelectErrorCallback, callback);
TPM_RC rc = Tpm::ParseResponse_PolicyDuplicationSelect(
- response,
- authorization_delegate);
+ response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
void Tpm::PolicyDuplicationSelect(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_NAME& object_name,
- const TPM2B_NAME& new_parent_name,
- const TPMI_YES_NO& include_object,
- AuthorizationDelegate* authorization_delegate,
- const PolicyDuplicationSelectResponse& callback) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_NAME& object_name,
+ const TPM2B_NAME& new_parent_name,
+ const TPMI_YES_NO& include_object,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyDuplicationSelectResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyDuplicationSelectErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(PolicyDuplicationSelectResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ PolicyDuplicationSelectResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_PolicyDuplicationSelect(
- policy_session,
- policy_session_name,
- object_name,
- new_parent_name,
- include_object,
- &command,
- authorization_delegate);
+ policy_session, policy_session_name, object_name, new_parent_name,
+ include_object, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -29260,41 +23807,34 @@
}
TPM_RC Tpm::PolicyDuplicationSelectSync(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_NAME& object_name,
- const TPM2B_NAME& new_parent_name,
- const TPMI_YES_NO& include_object,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_NAME& object_name,
+ const TPM2B_NAME& new_parent_name,
+ const TPMI_YES_NO& include_object,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_PolicyDuplicationSelect(
- policy_session,
- policy_session_name,
- object_name,
- new_parent_name,
- include_object,
- &command,
- authorization_delegate);
+ policy_session, policy_session_name, object_name, new_parent_name,
+ include_object, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicyDuplicationSelect(
- response,
- authorization_delegate);
+ rc = ParseResponse_PolicyDuplicationSelect(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicyAuthorize(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& approved_policy,
- const TPM2B_NONCE& policy_ref,
- const TPM2B_NAME& key_sign,
- const TPMT_TK_VERIFIED& check_ticket,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& approved_policy,
+ const TPM2B_NONCE& policy_ref,
+ const TPM2B_NAME& key_sign,
+ const TPMT_TK_VERIFIED& check_ticket,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -29305,44 +23845,32 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_session_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- policy_session,
- &policy_session_bytes);
+ rc = Serialize_TPMI_SH_POLICY(policy_session, &policy_session_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string approved_policy_bytes;
- rc = Serialize_TPM2B_DIGEST(
- approved_policy,
- &approved_policy_bytes);
+ rc = Serialize_TPM2B_DIGEST(approved_policy, &approved_policy_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_ref_bytes;
- rc = Serialize_TPM2B_NONCE(
- policy_ref,
- &policy_ref_bytes);
+ rc = Serialize_TPM2B_NONCE(policy_ref, &policy_ref_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string key_sign_bytes;
- rc = Serialize_TPM2B_NAME(
- key_sign,
- &key_sign_bytes);
+ rc = Serialize_TPM2B_NAME(key_sign, &key_sign_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string check_ticket_bytes;
- rc = Serialize_TPMT_TK_VERIFIED(
- check_ticket,
- &check_ticket_bytes);
+ rc = Serialize_TPMT_TK_VERIFIED(check_ticket, &check_ticket_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -29354,28 +23882,22 @@
}
approved_policy_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(policy_session_name.data(),
- policy_session_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(policy_session_name.data(), policy_session_name.size());
handle_section_bytes += policy_session_bytes;
command_size += policy_session_bytes.size();
- hash->Update(approved_policy_bytes.data(),
- approved_policy_bytes.size());
+ hash->Update(approved_policy_bytes.data(), approved_policy_bytes.size());
parameter_section_bytes += approved_policy_bytes;
command_size += approved_policy_bytes.size();
- hash->Update(policy_ref_bytes.data(),
- policy_ref_bytes.size());
+ hash->Update(policy_ref_bytes.data(), policy_ref_bytes.size());
parameter_section_bytes += policy_ref_bytes;
command_size += policy_ref_bytes.size();
- hash->Update(key_sign_bytes.data(),
- key_sign_bytes.size());
+ hash->Update(key_sign_bytes.data(), key_sign_bytes.size());
parameter_section_bytes += key_sign_bytes;
command_size += key_sign_bytes.size();
- hash->Update(check_ticket_bytes.data(),
- check_ticket_bytes.size());
+ hash->Update(check_ticket_bytes.data(), check_ticket_bytes.size());
parameter_section_bytes += check_ticket_bytes;
command_size += check_ticket_bytes.size();
std::string command_hash(32, 0);
@@ -29384,10 +23906,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -29398,31 +23919,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -29430,36 +23943,27 @@
}
TPM_RC Tpm::ParseResponse_PolicyAuthorize(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -29471,9 +23975,7 @@
}
TPM_CC command_code = TPM_CC_PolicyAuthorize;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -29491,30 +23993,25 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void PolicyAuthorizeErrorCallback(
- const Tpm::PolicyAuthorizeResponse& callback,
- TPM_RC response_code) {
+void PolicyAuthorizeErrorCallback(const Tpm::PolicyAuthorizeResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
@@ -29526,43 +24023,32 @@
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyAuthorizeErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PolicyAuthorize(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_PolicyAuthorize(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PolicyAuthorize(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& approved_policy,
- const TPM2B_NONCE& policy_ref,
- const TPM2B_NAME& key_sign,
- const TPMT_TK_VERIFIED& check_ticket,
- AuthorizationDelegate* authorization_delegate,
- const PolicyAuthorizeResponse& callback) {
+void Tpm::PolicyAuthorize(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& approved_policy,
+ const TPM2B_NONCE& policy_ref,
+ const TPM2B_NAME& key_sign,
+ const TPMT_TK_VERIFIED& check_ticket,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyAuthorizeResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyAuthorizeErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(PolicyAuthorizeResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ PolicyAuthorizeResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_PolicyAuthorize(
- policy_session,
- policy_session_name,
- approved_policy,
- policy_ref,
- key_sign,
- check_ticket,
- &command,
- authorization_delegate);
+ policy_session, policy_session_name, approved_policy, policy_ref,
+ key_sign, check_ticket, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -29570,40 +24056,31 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PolicyAuthorizeSync(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& approved_policy,
- const TPM2B_NONCE& policy_ref,
- const TPM2B_NAME& key_sign,
- const TPMT_TK_VERIFIED& check_ticket,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PolicyAuthorizeSync(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& approved_policy,
+ const TPM2B_NONCE& policy_ref,
+ const TPM2B_NAME& key_sign,
+ const TPMT_TK_VERIFIED& check_ticket,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_PolicyAuthorize(
- policy_session,
- policy_session_name,
- approved_policy,
- policy_ref,
- key_sign,
- check_ticket,
- &command,
- authorization_delegate);
+ policy_session, policy_session_name, approved_policy, policy_ref,
+ key_sign, check_ticket, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicyAuthorize(
- response,
- authorization_delegate);
+ rc = ParseResponse_PolicyAuthorize(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicyAuthValue(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -29614,25 +24091,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_session_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- policy_session,
- &policy_session_bytes);
+ rc = Serialize_TPMI_SH_POLICY(policy_session, &policy_session_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(policy_session_name.data(),
- policy_session_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(policy_session_name.data(), policy_session_name.size());
handle_section_bytes += policy_session_bytes;
command_size += policy_session_bytes.size();
std::string command_hash(32, 0);
@@ -29641,10 +24112,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -29655,31 +24125,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -29687,36 +24149,27 @@
}
TPM_RC Tpm::ParseResponse_PolicyAuthValue(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -29728,9 +24181,7 @@
}
TPM_CC command_code = TPM_CC_PolicyAuthValue;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -29748,30 +24199,25 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void PolicyAuthValueErrorCallback(
- const Tpm::PolicyAuthValueResponse& callback,
- TPM_RC response_code) {
+void PolicyAuthValueErrorCallback(const Tpm::PolicyAuthValueResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
@@ -29783,35 +24229,27 @@
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyAuthValueErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PolicyAuthValue(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_PolicyAuthValue(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PolicyAuthValue(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- AuthorizationDelegate* authorization_delegate,
- const PolicyAuthValueResponse& callback) {
+void Tpm::PolicyAuthValue(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyAuthValueResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyAuthValueErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(PolicyAuthValueResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ PolicyAuthValueResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_PolicyAuthValue(
- policy_session,
- policy_session_name,
- &command,
- authorization_delegate);
+ policy_session, policy_session_name, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -29819,32 +24257,26 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PolicyAuthValueSync(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PolicyAuthValueSync(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_PolicyAuthValue(
- policy_session,
- policy_session_name,
- &command,
- authorization_delegate);
+ policy_session, policy_session_name, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicyAuthValue(
- response,
- authorization_delegate);
+ rc = ParseResponse_PolicyAuthValue(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicyPassword(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -29855,25 +24287,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_session_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- policy_session,
- &policy_session_bytes);
+ rc = Serialize_TPMI_SH_POLICY(policy_session, &policy_session_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(policy_session_name.data(),
- policy_session_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(policy_session_name.data(), policy_session_name.size());
handle_section_bytes += policy_session_bytes;
command_size += policy_session_bytes.size();
std::string command_hash(32, 0);
@@ -29882,10 +24308,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -29896,31 +24321,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -29928,36 +24345,27 @@
}
TPM_RC Tpm::ParseResponse_PolicyPassword(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -29969,9 +24377,7 @@
}
TPM_CC command_code = TPM_CC_PolicyPassword;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -29989,70 +24395,56 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void PolicyPasswordErrorCallback(
- const Tpm::PolicyPasswordResponse& callback,
- TPM_RC response_code) {
+void PolicyPasswordErrorCallback(const Tpm::PolicyPasswordResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void PolicyPasswordResponseParser(
- const Tpm::PolicyPasswordResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void PolicyPasswordResponseParser(const Tpm::PolicyPasswordResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyPasswordErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PolicyPassword(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_PolicyPassword(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PolicyPassword(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- AuthorizationDelegate* authorization_delegate,
- const PolicyPasswordResponse& callback) {
+void Tpm::PolicyPassword(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyPasswordResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyPasswordErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(PolicyPasswordResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ PolicyPasswordResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_PolicyPassword(
- policy_session,
- policy_session_name,
- &command,
- authorization_delegate);
+ policy_session, policy_session_name, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -30060,32 +24452,26 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PolicyPasswordSync(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PolicyPasswordSync(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_PolicyPassword(
- policy_session,
- policy_session_name,
- &command,
- authorization_delegate);
+ policy_session, policy_session_name, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicyPassword(
- response,
- authorization_delegate);
+ rc = ParseResponse_PolicyPassword(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicyGetDigest(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -30096,25 +24482,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_session_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- policy_session,
- &policy_session_bytes);
+ rc = Serialize_TPMI_SH_POLICY(policy_session, &policy_session_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(policy_session_name.data(),
- policy_session_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(policy_session_name.data(), policy_session_name.size());
handle_section_bytes += policy_session_bytes;
command_size += policy_session_bytes.size();
std::string command_hash(32, 0);
@@ -30123,10 +24503,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -30137,31 +24516,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -30169,37 +24540,28 @@
}
TPM_RC Tpm::ParseResponse_PolicyGetDigest(
- const std::string& response,
- TPM2B_DIGEST* policy_digest,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_DIGEST* policy_digest,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -30211,9 +24573,7 @@
}
TPM_CC command_code = TPM_CC_PolicyGetDigest;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -30231,29 +24591,22 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string policy_digest_bytes;
- rc = Parse_TPM2B_DIGEST(
- &buffer,
- policy_digest,
- &policy_digest_bytes);
+ rc = Parse_TPM2B_DIGEST(&buffer, policy_digest, &policy_digest_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -30265,10 +24618,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
policy_digest_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_DIGEST(
- &policy_digest_bytes,
- policy_digest,
- nullptr);
+ rc = Parse_TPM2B_DIGEST(&policy_digest_bytes, policy_digest, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -30276,12 +24626,10 @@
return TPM_RC_SUCCESS;
}
-void PolicyGetDigestErrorCallback(
- const Tpm::PolicyGetDigestResponse& callback,
- TPM_RC response_code) {
+void PolicyGetDigestErrorCallback(const Tpm::PolicyGetDigestResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_DIGEST());
+ callback.Run(response_code, TPM2B_DIGEST());
}
void PolicyGetDigestResponseParser(
@@ -30292,37 +24640,27 @@
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyGetDigestErrorCallback, callback);
TPM2B_DIGEST policy_digest;
- TPM_RC rc = Tpm::ParseResponse_PolicyGetDigest(
- response,
- &policy_digest,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_PolicyGetDigest(response, &policy_digest,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- policy_digest);
+ callback.Run(rc, policy_digest);
}
-void Tpm::PolicyGetDigest(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- AuthorizationDelegate* authorization_delegate,
- const PolicyGetDigestResponse& callback) {
+void Tpm::PolicyGetDigest(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyGetDigestResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyGetDigestErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(PolicyGetDigestResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ PolicyGetDigestResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_PolicyGetDigest(
- policy_session,
- policy_session_name,
- &command,
- authorization_delegate);
+ policy_session, policy_session_name, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -30330,35 +24668,29 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PolicyGetDigestSync(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- TPM2B_DIGEST* policy_digest,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PolicyGetDigestSync(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ TPM2B_DIGEST* policy_digest,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_PolicyGetDigest(
- policy_session,
- policy_session_name,
- &command,
- authorization_delegate);
+ policy_session, policy_session_name, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicyGetDigest(
- response,
- policy_digest,
- authorization_delegate);
+ rc = ParseResponse_PolicyGetDigest(response, policy_digest,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PolicyNvWritten(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPMI_YES_NO& written_set,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPMI_YES_NO& written_set,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -30369,36 +24701,27 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string policy_session_bytes;
- rc = Serialize_TPMI_SH_POLICY(
- policy_session,
- &policy_session_bytes);
+ rc = Serialize_TPMI_SH_POLICY(policy_session, &policy_session_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string written_set_bytes;
- rc = Serialize_TPMI_YES_NO(
- written_set,
- &written_set_bytes);
+ rc = Serialize_TPMI_YES_NO(written_set, &written_set_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(policy_session_name.data(),
- policy_session_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(policy_session_name.data(), policy_session_name.size());
handle_section_bytes += policy_session_bytes;
command_size += policy_session_bytes.size();
- hash->Update(written_set_bytes.data(),
- written_set_bytes.size());
+ hash->Update(written_set_bytes.data(), written_set_bytes.size());
parameter_section_bytes += written_set_bytes;
command_size += written_set_bytes.size();
std::string command_hash(32, 0);
@@ -30407,10 +24730,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -30421,31 +24743,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -30453,36 +24767,27 @@
}
TPM_RC Tpm::ParseResponse_PolicyNvWritten(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -30494,9 +24799,7 @@
}
TPM_CC command_code = TPM_CC_PolicyNvWritten;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -30514,30 +24817,25 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void PolicyNvWrittenErrorCallback(
- const Tpm::PolicyNvWrittenResponse& callback,
- TPM_RC response_code) {
+void PolicyNvWrittenErrorCallback(const Tpm::PolicyNvWrittenResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
@@ -30549,36 +24847,28 @@
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyNvWrittenErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PolicyNvWritten(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_PolicyNvWritten(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PolicyNvWritten(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPMI_YES_NO& written_set,
- AuthorizationDelegate* authorization_delegate,
- const PolicyNvWrittenResponse& callback) {
+void Tpm::PolicyNvWritten(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPMI_YES_NO& written_set,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyNvWrittenResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PolicyNvWrittenErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(PolicyNvWrittenResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ PolicyNvWrittenResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_PolicyNvWritten(
- policy_session,
- policy_session_name,
- written_set,
- &command,
+ policy_session, policy_session_name, written_set, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
@@ -30587,38 +24877,32 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PolicyNvWrittenSync(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPMI_YES_NO& written_set,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PolicyNvWrittenSync(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPMI_YES_NO& written_set,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_PolicyNvWritten(
- policy_session,
- policy_session_name,
- written_set,
- &command,
+ policy_session, policy_session_name, written_set, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PolicyNvWritten(
- response,
- authorization_delegate);
+ rc = ParseResponse_PolicyNvWritten(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_CreatePrimary(
- const TPMI_RH_HIERARCHY& primary_handle,
- const std::string& primary_handle_name,
- const TPM2B_SENSITIVE_CREATE& in_sensitive,
- const TPM2B_PUBLIC& in_public,
- const TPM2B_DATA& outside_info,
- const TPML_PCR_SELECTION& creation_pcr,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_HIERARCHY& primary_handle,
+ const std::string& primary_handle_name,
+ const TPM2B_SENSITIVE_CREATE& in_sensitive,
+ const TPM2B_PUBLIC& in_public,
+ const TPM2B_DATA& outside_info,
+ const TPML_PCR_SELECTION& creation_pcr,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -30629,44 +24913,32 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string primary_handle_bytes;
- rc = Serialize_TPMI_RH_HIERARCHY(
- primary_handle,
- &primary_handle_bytes);
+ rc = Serialize_TPMI_RH_HIERARCHY(primary_handle, &primary_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_sensitive_bytes;
- rc = Serialize_TPM2B_SENSITIVE_CREATE(
- in_sensitive,
- &in_sensitive_bytes);
+ rc = Serialize_TPM2B_SENSITIVE_CREATE(in_sensitive, &in_sensitive_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_public_bytes;
- rc = Serialize_TPM2B_PUBLIC(
- in_public,
- &in_public_bytes);
+ rc = Serialize_TPM2B_PUBLIC(in_public, &in_public_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string outside_info_bytes;
- rc = Serialize_TPM2B_DATA(
- outside_info,
- &outside_info_bytes);
+ rc = Serialize_TPM2B_DATA(outside_info, &outside_info_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string creation_pcr_bytes;
- rc = Serialize_TPML_PCR_SELECTION(
- creation_pcr,
- &creation_pcr_bytes);
+ rc = Serialize_TPML_PCR_SELECTION(creation_pcr, &creation_pcr_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -30678,28 +24950,22 @@
}
in_sensitive_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(primary_handle_name.data(),
- primary_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(primary_handle_name.data(), primary_handle_name.size());
handle_section_bytes += primary_handle_bytes;
command_size += primary_handle_bytes.size();
- hash->Update(in_sensitive_bytes.data(),
- in_sensitive_bytes.size());
+ hash->Update(in_sensitive_bytes.data(), in_sensitive_bytes.size());
parameter_section_bytes += in_sensitive_bytes;
command_size += in_sensitive_bytes.size();
- hash->Update(in_public_bytes.data(),
- in_public_bytes.size());
+ hash->Update(in_public_bytes.data(), in_public_bytes.size());
parameter_section_bytes += in_public_bytes;
command_size += in_public_bytes.size();
- hash->Update(outside_info_bytes.data(),
- outside_info_bytes.size());
+ hash->Update(outside_info_bytes.data(), outside_info_bytes.size());
parameter_section_bytes += outside_info_bytes;
command_size += outside_info_bytes.size();
- hash->Update(creation_pcr_bytes.data(),
- creation_pcr_bytes.size());
+ hash->Update(creation_pcr_bytes.data(), creation_pcr_bytes.size());
parameter_section_bytes += creation_pcr_bytes;
command_size += creation_pcr_bytes.size();
std::string command_hash(32, 0);
@@ -30708,10 +24974,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -30722,31 +24987,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -30754,42 +25011,33 @@
}
TPM_RC Tpm::ParseResponse_CreatePrimary(
- const std::string& response,
- TPM_HANDLE* object_handle,
- TPM2B_PUBLIC* out_public,
- TPM2B_CREATION_DATA* creation_data,
- TPM2B_DIGEST* creation_hash,
- TPMT_TK_CREATION* creation_ticket,
- TPM2B_NAME* name,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM_HANDLE* object_handle,
+ TPM2B_PUBLIC* out_public,
+ TPM2B_CREATION_DATA* creation_data,
+ TPM2B_DIGEST* creation_hash,
+ TPMT_TK_CREATION* creation_ticket,
+ TPM2B_NAME* name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -30800,18 +25048,13 @@
return response_code;
}
std::string object_handle_bytes;
- rc = Parse_TPM_HANDLE(
- &buffer,
- object_handle,
- &object_handle_bytes);
+ rc = Parse_TPM_HANDLE(&buffer, object_handle, &object_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_CC command_code = TPM_CC_CreatePrimary;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -30829,61 +25072,42 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string out_public_bytes;
- rc = Parse_TPM2B_PUBLIC(
- &buffer,
- out_public,
- &out_public_bytes);
+ rc = Parse_TPM2B_PUBLIC(&buffer, out_public, &out_public_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string creation_data_bytes;
- rc = Parse_TPM2B_CREATION_DATA(
- &buffer,
- creation_data,
- &creation_data_bytes);
+ rc = Parse_TPM2B_CREATION_DATA(&buffer, creation_data, &creation_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string creation_hash_bytes;
- rc = Parse_TPM2B_DIGEST(
- &buffer,
- creation_hash,
- &creation_hash_bytes);
+ rc = Parse_TPM2B_DIGEST(&buffer, creation_hash, &creation_hash_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string creation_ticket_bytes;
- rc = Parse_TPMT_TK_CREATION(
- &buffer,
- creation_ticket,
- &creation_ticket_bytes);
+ rc = Parse_TPMT_TK_CREATION(&buffer, creation_ticket, &creation_ticket_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string name_bytes;
- rc = Parse_TPM2B_NAME(
- &buffer,
- name,
- &name_bytes);
+ rc = Parse_TPM2B_NAME(&buffer, name, &name_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -30895,10 +25119,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
out_public_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_PUBLIC(
- &out_public_bytes,
- out_public,
- nullptr);
+ rc = Parse_TPM2B_PUBLIC(&out_public_bytes, out_public, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -30906,23 +25127,17 @@
return TPM_RC_SUCCESS;
}
-void CreatePrimaryErrorCallback(
- const Tpm::CreatePrimaryResponse& callback,
- TPM_RC response_code) {
+void CreatePrimaryErrorCallback(const Tpm::CreatePrimaryResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM_HANDLE(),
- TPM2B_PUBLIC(),
- TPM2B_CREATION_DATA(),
- TPM2B_DIGEST(),
- TPMT_TK_CREATION(),
+ callback.Run(response_code, TPM_HANDLE(), TPM2B_PUBLIC(),
+ TPM2B_CREATION_DATA(), TPM2B_DIGEST(), TPMT_TK_CREATION(),
TPM2B_NAME());
}
-void CreatePrimaryResponseParser(
- const Tpm::CreatePrimaryResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void CreatePrimaryResponseParser(const Tpm::CreatePrimaryResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(CreatePrimaryErrorCallback, callback);
@@ -30933,54 +25148,33 @@
TPMT_TK_CREATION creation_ticket;
TPM2B_NAME name;
TPM_RC rc = Tpm::ParseResponse_CreatePrimary(
- response,
- &object_handle,
- &out_public,
- &creation_data,
- &creation_hash,
- &creation_ticket,
- &name,
- authorization_delegate);
+ response, &object_handle, &out_public, &creation_data, &creation_hash,
+ &creation_ticket, &name, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- object_handle,
- out_public,
- creation_data,
- creation_hash,
- creation_ticket,
- name);
+ callback.Run(rc, object_handle, out_public, creation_data, creation_hash,
+ creation_ticket, name);
}
-void Tpm::CreatePrimary(
- const TPMI_RH_HIERARCHY& primary_handle,
- const std::string& primary_handle_name,
- const TPM2B_SENSITIVE_CREATE& in_sensitive,
- const TPM2B_PUBLIC& in_public,
- const TPM2B_DATA& outside_info,
- const TPML_PCR_SELECTION& creation_pcr,
- AuthorizationDelegate* authorization_delegate,
- const CreatePrimaryResponse& callback) {
+void Tpm::CreatePrimary(const TPMI_RH_HIERARCHY& primary_handle,
+ const std::string& primary_handle_name,
+ const TPM2B_SENSITIVE_CREATE& in_sensitive,
+ const TPM2B_PUBLIC& in_public,
+ const TPM2B_DATA& outside_info,
+ const TPML_PCR_SELECTION& creation_pcr,
+ AuthorizationDelegate* authorization_delegate,
+ const CreatePrimaryResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(CreatePrimaryErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(CreatePrimaryResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(CreatePrimaryResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_CreatePrimary(
- primary_handle,
- primary_handle_name,
- in_sensitive,
- in_public,
- outside_info,
- creation_pcr,
- &command,
- authorization_delegate);
+ primary_handle, primary_handle_name, in_sensitive, in_public,
+ outside_info, creation_pcr, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -30988,54 +25182,41 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::CreatePrimarySync(
- const TPMI_RH_HIERARCHY& primary_handle,
- const std::string& primary_handle_name,
- const TPM2B_SENSITIVE_CREATE& in_sensitive,
- const TPM2B_PUBLIC& in_public,
- const TPM2B_DATA& outside_info,
- const TPML_PCR_SELECTION& creation_pcr,
- TPM_HANDLE* object_handle,
- TPM2B_PUBLIC* out_public,
- TPM2B_CREATION_DATA* creation_data,
- TPM2B_DIGEST* creation_hash,
- TPMT_TK_CREATION* creation_ticket,
- TPM2B_NAME* name,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::CreatePrimarySync(const TPMI_RH_HIERARCHY& primary_handle,
+ const std::string& primary_handle_name,
+ const TPM2B_SENSITIVE_CREATE& in_sensitive,
+ const TPM2B_PUBLIC& in_public,
+ const TPM2B_DATA& outside_info,
+ const TPML_PCR_SELECTION& creation_pcr,
+ TPM_HANDLE* object_handle,
+ TPM2B_PUBLIC* out_public,
+ TPM2B_CREATION_DATA* creation_data,
+ TPM2B_DIGEST* creation_hash,
+ TPMT_TK_CREATION* creation_ticket,
+ TPM2B_NAME* name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_CreatePrimary(
- primary_handle,
- primary_handle_name,
- in_sensitive,
- in_public,
- outside_info,
- creation_pcr,
- &command,
- authorization_delegate);
+ primary_handle, primary_handle_name, in_sensitive, in_public,
+ outside_info, creation_pcr, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
rc = ParseResponse_CreatePrimary(
- response,
- object_handle,
- out_public,
- creation_data,
- creation_hash,
- creation_ticket,
- name,
- authorization_delegate);
+ response, object_handle, out_public, creation_data, creation_hash,
+ creation_ticket, name, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_HierarchyControl(
- const TPMI_RH_HIERARCHY& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_ENABLES& enable,
- const TPMI_YES_NO& state,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_HIERARCHY& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_ENABLES& enable,
+ const TPMI_YES_NO& state,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -31046,47 +25227,35 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_HIERARCHY(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_HIERARCHY(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string enable_bytes;
- rc = Serialize_TPMI_RH_ENABLES(
- enable,
- &enable_bytes);
+ rc = Serialize_TPMI_RH_ENABLES(enable, &enable_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string state_bytes;
- rc = Serialize_TPMI_YES_NO(
- state,
- &state_bytes);
+ rc = Serialize_TPMI_YES_NO(state, &state_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
- hash->Update(enable_bytes.data(),
- enable_bytes.size());
+ hash->Update(enable_bytes.data(), enable_bytes.size());
parameter_section_bytes += enable_bytes;
command_size += enable_bytes.size();
- hash->Update(state_bytes.data(),
- state_bytes.size());
+ hash->Update(state_bytes.data(), state_bytes.size());
parameter_section_bytes += state_bytes;
command_size += state_bytes.size();
std::string command_hash(32, 0);
@@ -31095,10 +25264,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -31109,31 +25277,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -31141,36 +25301,27 @@
}
TPM_RC Tpm::ParseResponse_HierarchyControl(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -31182,9 +25333,7 @@
}
TPM_CC command_code = TPM_CC_HierarchyControl;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -31202,21 +25351,17 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
@@ -31237,39 +25382,30 @@
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(HierarchyControlErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_HierarchyControl(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_HierarchyControl(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::HierarchyControl(
- const TPMI_RH_HIERARCHY& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_ENABLES& enable,
- const TPMI_YES_NO& state,
- AuthorizationDelegate* authorization_delegate,
- const HierarchyControlResponse& callback) {
+void Tpm::HierarchyControl(const TPMI_RH_HIERARCHY& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_ENABLES& enable,
+ const TPMI_YES_NO& state,
+ AuthorizationDelegate* authorization_delegate,
+ const HierarchyControlResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(HierarchyControlErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(HierarchyControlResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ HierarchyControlResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_HierarchyControl(
- auth_handle,
- auth_handle_name,
- enable,
- state,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_HierarchyControl(auth_handle, auth_handle_name,
+ enable, state, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -31278,37 +25414,31 @@
}
TPM_RC Tpm::HierarchyControlSync(
- const TPMI_RH_HIERARCHY& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_ENABLES& enable,
- const TPMI_YES_NO& state,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_HIERARCHY& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_ENABLES& enable,
+ const TPMI_YES_NO& state,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_HierarchyControl(
- auth_handle,
- auth_handle_name,
- enable,
- state,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_HierarchyControl(auth_handle, auth_handle_name,
+ enable, state, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_HierarchyControl(
- response,
- authorization_delegate);
+ rc = ParseResponse_HierarchyControl(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_SetPrimaryPolicy(
- const TPMI_RH_HIERARCHY& auth_handle,
- const std::string& auth_handle_name,
- const TPM2B_DIGEST& auth_policy,
- const TPMI_ALG_HASH& hash_alg,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_HIERARCHY& auth_handle,
+ const std::string& auth_handle_name,
+ const TPM2B_DIGEST& auth_policy,
+ const TPMI_ALG_HASH& hash_alg,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -31319,30 +25449,22 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_HIERARCHY(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_HIERARCHY(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_policy_bytes;
- rc = Serialize_TPM2B_DIGEST(
- auth_policy,
- &auth_policy_bytes);
+ rc = Serialize_TPM2B_DIGEST(auth_policy, &auth_policy_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string hash_alg_bytes;
- rc = Serialize_TPMI_ALG_HASH(
- hash_alg,
- &hash_alg_bytes);
+ rc = Serialize_TPMI_ALG_HASH(hash_alg, &hash_alg_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -31354,20 +25476,16 @@
}
auth_policy_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
- hash->Update(auth_policy_bytes.data(),
- auth_policy_bytes.size());
+ hash->Update(auth_policy_bytes.data(), auth_policy_bytes.size());
parameter_section_bytes += auth_policy_bytes;
command_size += auth_policy_bytes.size();
- hash->Update(hash_alg_bytes.data(),
- hash_alg_bytes.size());
+ hash->Update(hash_alg_bytes.data(), hash_alg_bytes.size());
parameter_section_bytes += hash_alg_bytes;
command_size += hash_alg_bytes.size();
std::string command_hash(32, 0);
@@ -31376,10 +25494,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -31390,31 +25507,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -31422,36 +25531,27 @@
}
TPM_RC Tpm::ParseResponse_SetPrimaryPolicy(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -31463,9 +25563,7 @@
}
TPM_CC command_code = TPM_CC_SetPrimaryPolicy;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -31483,21 +25581,17 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
@@ -31518,39 +25612,30 @@
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(SetPrimaryPolicyErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_SetPrimaryPolicy(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_SetPrimaryPolicy(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::SetPrimaryPolicy(
- const TPMI_RH_HIERARCHY& auth_handle,
- const std::string& auth_handle_name,
- const TPM2B_DIGEST& auth_policy,
- const TPMI_ALG_HASH& hash_alg,
- AuthorizationDelegate* authorization_delegate,
- const SetPrimaryPolicyResponse& callback) {
+void Tpm::SetPrimaryPolicy(const TPMI_RH_HIERARCHY& auth_handle,
+ const std::string& auth_handle_name,
+ const TPM2B_DIGEST& auth_policy,
+ const TPMI_ALG_HASH& hash_alg,
+ AuthorizationDelegate* authorization_delegate,
+ const SetPrimaryPolicyResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(SetPrimaryPolicyErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(SetPrimaryPolicyResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ SetPrimaryPolicyResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_SetPrimaryPolicy(
- auth_handle,
- auth_handle_name,
- auth_policy,
- hash_alg,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_SetPrimaryPolicy(auth_handle, auth_handle_name,
+ auth_policy, hash_alg, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -31559,35 +25644,29 @@
}
TPM_RC Tpm::SetPrimaryPolicySync(
- const TPMI_RH_HIERARCHY& auth_handle,
- const std::string& auth_handle_name,
- const TPM2B_DIGEST& auth_policy,
- const TPMI_ALG_HASH& hash_alg,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_HIERARCHY& auth_handle,
+ const std::string& auth_handle_name,
+ const TPM2B_DIGEST& auth_policy,
+ const TPMI_ALG_HASH& hash_alg,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_SetPrimaryPolicy(
- auth_handle,
- auth_handle_name,
- auth_policy,
- hash_alg,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_SetPrimaryPolicy(auth_handle, auth_handle_name,
+ auth_policy, hash_alg, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_SetPrimaryPolicy(
- response,
- authorization_delegate);
+ rc = ParseResponse_SetPrimaryPolicy(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_ChangePPS(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -31598,25 +25677,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_PLATFORM(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_PLATFORM(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
std::string command_hash(32, 0);
@@ -31625,10 +25698,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -31639,31 +25711,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -31671,36 +25735,27 @@
}
TPM_RC Tpm::ParseResponse_ChangePPS(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -31712,9 +25767,7 @@
}
TPM_CC command_code = TPM_CC_ChangePPS;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -31732,70 +25785,55 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void ChangePPSErrorCallback(
- const Tpm::ChangePPSResponse& callback,
- TPM_RC response_code) {
+void ChangePPSErrorCallback(const Tpm::ChangePPSResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void ChangePPSResponseParser(
- const Tpm::ChangePPSResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void ChangePPSResponseParser(const Tpm::ChangePPSResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ChangePPSErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_ChangePPS(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_ChangePPS(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::ChangePPS(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const ChangePPSResponse& callback) {
+void Tpm::ChangePPS(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const ChangePPSResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ChangePPSErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(ChangePPSResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(ChangePPSResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_ChangePPS(
- auth_handle,
- auth_handle_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ChangePPS(auth_handle, auth_handle_name,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -31803,32 +25841,26 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::ChangePPSSync(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ChangePPSSync(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_ChangePPS(
- auth_handle,
- auth_handle_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ChangePPS(auth_handle, auth_handle_name,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_ChangePPS(
- response,
- authorization_delegate);
+ rc = ParseResponse_ChangePPS(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_ChangeEPS(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -31839,25 +25871,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_PLATFORM(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_PLATFORM(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
std::string command_hash(32, 0);
@@ -31866,10 +25892,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -31880,31 +25905,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -31912,36 +25929,27 @@
}
TPM_RC Tpm::ParseResponse_ChangeEPS(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -31953,9 +25961,7 @@
}
TPM_CC command_code = TPM_CC_ChangeEPS;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -31973,70 +25979,55 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void ChangeEPSErrorCallback(
- const Tpm::ChangeEPSResponse& callback,
- TPM_RC response_code) {
+void ChangeEPSErrorCallback(const Tpm::ChangeEPSResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void ChangeEPSResponseParser(
- const Tpm::ChangeEPSResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void ChangeEPSResponseParser(const Tpm::ChangeEPSResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ChangeEPSErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_ChangeEPS(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_ChangeEPS(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::ChangeEPS(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const ChangeEPSResponse& callback) {
+void Tpm::ChangeEPS(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const ChangeEPSResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ChangeEPSErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(ChangeEPSResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(ChangeEPSResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_ChangeEPS(
- auth_handle,
- auth_handle_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ChangeEPS(auth_handle, auth_handle_name,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -32044,32 +26035,26 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::ChangeEPSSync(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ChangeEPSSync(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_ChangeEPS(
- auth_handle,
- auth_handle_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ChangeEPS(auth_handle, auth_handle_name,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_ChangeEPS(
- response,
- authorization_delegate);
+ rc = ParseResponse_ChangeEPS(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_Clear(
- const TPMI_RH_CLEAR& auth_handle,
- const std::string& auth_handle_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_CLEAR& auth_handle,
+ const std::string& auth_handle_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -32080,25 +26065,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_CLEAR(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_CLEAR(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
std::string command_hash(32, 0);
@@ -32107,10 +26086,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -32121,68 +26099,50 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
return TPM_RC_SUCCESS;
}
-TPM_RC Tpm::ParseResponse_Clear(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ParseResponse_Clear(const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -32194,9 +26154,7 @@
}
TPM_CC command_code = TPM_CC_Clear;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -32214,70 +26172,55 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void ClearErrorCallback(
- const Tpm::ClearResponse& callback,
- TPM_RC response_code) {
+void ClearErrorCallback(const Tpm::ClearResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void ClearResponseParser(
- const Tpm::ClearResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void ClearResponseParser(const Tpm::ClearResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ClearErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_Clear(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_Clear(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::Clear(
- const TPMI_RH_CLEAR& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const ClearResponse& callback) {
+void Tpm::Clear(const TPMI_RH_CLEAR& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const ClearResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ClearErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(ClearResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(ClearResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_Clear(
- auth_handle,
- auth_handle_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_Clear(auth_handle, auth_handle_name, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -32285,33 +26228,27 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::ClearSync(
- const TPMI_RH_CLEAR& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ClearSync(const TPMI_RH_CLEAR& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_Clear(
- auth_handle,
- auth_handle_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_Clear(auth_handle, auth_handle_name, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_Clear(
- response,
- authorization_delegate);
+ rc = ParseResponse_Clear(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_ClearControl(
- const TPMI_RH_CLEAR& auth,
- const std::string& auth_name,
- const TPMI_YES_NO& disable,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_CLEAR& auth,
+ const std::string& auth_name,
+ const TPMI_YES_NO& disable,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -32322,36 +26259,27 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_bytes;
- rc = Serialize_TPMI_RH_CLEAR(
- auth,
- &auth_bytes);
+ rc = Serialize_TPMI_RH_CLEAR(auth, &auth_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string disable_bytes;
- rc = Serialize_TPMI_YES_NO(
- disable,
- &disable_bytes);
+ rc = Serialize_TPMI_YES_NO(disable, &disable_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_name.data(),
- auth_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_name.data(), auth_name.size());
handle_section_bytes += auth_bytes;
command_size += auth_bytes.size();
- hash->Update(disable_bytes.data(),
- disable_bytes.size());
+ hash->Update(disable_bytes.data(), disable_bytes.size());
parameter_section_bytes += disable_bytes;
command_size += disable_bytes.size();
std::string command_hash(32, 0);
@@ -32360,10 +26288,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -32374,31 +26301,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -32406,36 +26325,27 @@
}
TPM_RC Tpm::ParseResponse_ClearControl(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -32447,9 +26357,7 @@
}
TPM_CC command_code = TPM_CC_ClearControl;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -32467,72 +26375,56 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void ClearControlErrorCallback(
- const Tpm::ClearControlResponse& callback,
- TPM_RC response_code) {
+void ClearControlErrorCallback(const Tpm::ClearControlResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void ClearControlResponseParser(
- const Tpm::ClearControlResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void ClearControlResponseParser(const Tpm::ClearControlResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ClearControlErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_ClearControl(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_ClearControl(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::ClearControl(
- const TPMI_RH_CLEAR& auth,
- const std::string& auth_name,
- const TPMI_YES_NO& disable,
- AuthorizationDelegate* authorization_delegate,
- const ClearControlResponse& callback) {
+void Tpm::ClearControl(const TPMI_RH_CLEAR& auth,
+ const std::string& auth_name,
+ const TPMI_YES_NO& disable,
+ AuthorizationDelegate* authorization_delegate,
+ const ClearControlResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ClearControlErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(ClearControlResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(ClearControlResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_ClearControl(
- auth,
- auth_name,
- disable,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ClearControl(auth, auth_name, disable, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -32540,35 +26432,28 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::ClearControlSync(
- const TPMI_RH_CLEAR& auth,
- const std::string& auth_name,
- const TPMI_YES_NO& disable,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ClearControlSync(const TPMI_RH_CLEAR& auth,
+ const std::string& auth_name,
+ const TPMI_YES_NO& disable,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_ClearControl(
- auth,
- auth_name,
- disable,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ClearControl(auth, auth_name, disable, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_ClearControl(
- response,
- authorization_delegate);
+ rc = ParseResponse_ClearControl(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_HierarchyChangeAuth(
- const TPMI_RH_HIERARCHY_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPM2B_AUTH& new_auth,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_HIERARCHY_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPM2B_AUTH& new_auth,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -32579,23 +26464,17 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_HIERARCHY_AUTH(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_HIERARCHY_AUTH(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string new_auth_bytes;
- rc = Serialize_TPM2B_AUTH(
- new_auth,
- &new_auth_bytes);
+ rc = Serialize_TPM2B_AUTH(new_auth, &new_auth_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -32607,16 +26486,13 @@
}
new_auth_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
- hash->Update(new_auth_bytes.data(),
- new_auth_bytes.size());
+ hash->Update(new_auth_bytes.data(), new_auth_bytes.size());
parameter_section_bytes += new_auth_bytes;
command_size += new_auth_bytes.size();
std::string command_hash(32, 0);
@@ -32625,10 +26501,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -32639,31 +26514,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -32671,36 +26538,27 @@
}
TPM_RC Tpm::ParseResponse_HierarchyChangeAuth(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -32712,9 +26570,7 @@
}
TPM_CC command_code = TPM_CC_HierarchyChangeAuth;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -32732,21 +26588,17 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
@@ -32767,36 +26619,28 @@
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(HierarchyChangeAuthErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_HierarchyChangeAuth(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_HierarchyChangeAuth(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::HierarchyChangeAuth(
- const TPMI_RH_HIERARCHY_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPM2B_AUTH& new_auth,
- AuthorizationDelegate* authorization_delegate,
- const HierarchyChangeAuthResponse& callback) {
+void Tpm::HierarchyChangeAuth(const TPMI_RH_HIERARCHY_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPM2B_AUTH& new_auth,
+ AuthorizationDelegate* authorization_delegate,
+ const HierarchyChangeAuthResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(HierarchyChangeAuthErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(HierarchyChangeAuthResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ HierarchyChangeAuthResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_HierarchyChangeAuth(
- auth_handle,
- auth_handle_name,
- new_auth,
- &command,
+ auth_handle, auth_handle_name, new_auth, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
@@ -32806,33 +26650,28 @@
}
TPM_RC Tpm::HierarchyChangeAuthSync(
- const TPMI_RH_HIERARCHY_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPM2B_AUTH& new_auth,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_HIERARCHY_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPM2B_AUTH& new_auth,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_HierarchyChangeAuth(
- auth_handle,
- auth_handle_name,
- new_auth,
- &command,
+ auth_handle, auth_handle_name, new_auth, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_HierarchyChangeAuth(
- response,
- authorization_delegate);
+ rc = ParseResponse_HierarchyChangeAuth(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_DictionaryAttackLockReset(
- const TPMI_RH_LOCKOUT& lock_handle,
- const std::string& lock_handle_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_LOCKOUT& lock_handle,
+ const std::string& lock_handle_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -32843,25 +26682,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string lock_handle_bytes;
- rc = Serialize_TPMI_RH_LOCKOUT(
- lock_handle,
- &lock_handle_bytes);
+ rc = Serialize_TPMI_RH_LOCKOUT(lock_handle, &lock_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(lock_handle_name.data(),
- lock_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(lock_handle_name.data(), lock_handle_name.size());
handle_section_bytes += lock_handle_bytes;
command_size += lock_handle_bytes.size();
std::string command_hash(32, 0);
@@ -32870,10 +26703,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -32884,31 +26716,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -32916,36 +26740,27 @@
}
TPM_RC Tpm::ParseResponse_DictionaryAttackLockReset(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -32957,9 +26772,7 @@
}
TPM_CC command_code = TPM_CC_DictionaryAttackLockReset;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -32977,21 +26790,17 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
@@ -33013,34 +26822,28 @@
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(DictionaryAttackLockResetErrorCallback, callback);
TPM_RC rc = Tpm::ParseResponse_DictionaryAttackLockReset(
- response,
- authorization_delegate);
+ response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
void Tpm::DictionaryAttackLockReset(
- const TPMI_RH_LOCKOUT& lock_handle,
- const std::string& lock_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const DictionaryAttackLockResetResponse& callback) {
+ const TPMI_RH_LOCKOUT& lock_handle,
+ const std::string& lock_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const DictionaryAttackLockResetResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(DictionaryAttackLockResetErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(DictionaryAttackLockResetResponseParser,
- callback,
+ base::Bind(DictionaryAttackLockResetResponseParser, callback,
authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_DictionaryAttackLockReset(
- lock_handle,
- lock_handle_name,
- &command,
- authorization_delegate);
+ lock_handle, lock_handle_name, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -33049,34 +26852,30 @@
}
TPM_RC Tpm::DictionaryAttackLockResetSync(
- const TPMI_RH_LOCKOUT& lock_handle,
- const std::string& lock_handle_name,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_LOCKOUT& lock_handle,
+ const std::string& lock_handle_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_DictionaryAttackLockReset(
- lock_handle,
- lock_handle_name,
- &command,
- authorization_delegate);
+ lock_handle, lock_handle_name, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_DictionaryAttackLockReset(
- response,
- authorization_delegate);
+ rc =
+ ParseResponse_DictionaryAttackLockReset(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_DictionaryAttackParameters(
- const TPMI_RH_LOCKOUT& lock_handle,
- const std::string& lock_handle_name,
- const UINT32& new_max_tries,
- const UINT32& new_recovery_time,
- const UINT32& lockout_recovery,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_LOCKOUT& lock_handle,
+ const std::string& lock_handle_name,
+ const UINT32& new_max_tries,
+ const UINT32& new_recovery_time,
+ const UINT32& lockout_recovery,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -33087,58 +26886,43 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string lock_handle_bytes;
- rc = Serialize_TPMI_RH_LOCKOUT(
- lock_handle,
- &lock_handle_bytes);
+ rc = Serialize_TPMI_RH_LOCKOUT(lock_handle, &lock_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string new_max_tries_bytes;
- rc = Serialize_UINT32(
- new_max_tries,
- &new_max_tries_bytes);
+ rc = Serialize_UINT32(new_max_tries, &new_max_tries_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string new_recovery_time_bytes;
- rc = Serialize_UINT32(
- new_recovery_time,
- &new_recovery_time_bytes);
+ rc = Serialize_UINT32(new_recovery_time, &new_recovery_time_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string lockout_recovery_bytes;
- rc = Serialize_UINT32(
- lockout_recovery,
- &lockout_recovery_bytes);
+ rc = Serialize_UINT32(lockout_recovery, &lockout_recovery_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(lock_handle_name.data(),
- lock_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(lock_handle_name.data(), lock_handle_name.size());
handle_section_bytes += lock_handle_bytes;
command_size += lock_handle_bytes.size();
- hash->Update(new_max_tries_bytes.data(),
- new_max_tries_bytes.size());
+ hash->Update(new_max_tries_bytes.data(), new_max_tries_bytes.size());
parameter_section_bytes += new_max_tries_bytes;
command_size += new_max_tries_bytes.size();
- hash->Update(new_recovery_time_bytes.data(),
- new_recovery_time_bytes.size());
+ hash->Update(new_recovery_time_bytes.data(), new_recovery_time_bytes.size());
parameter_section_bytes += new_recovery_time_bytes;
command_size += new_recovery_time_bytes.size();
- hash->Update(lockout_recovery_bytes.data(),
- lockout_recovery_bytes.size());
+ hash->Update(lockout_recovery_bytes.data(), lockout_recovery_bytes.size());
parameter_section_bytes += lockout_recovery_bytes;
command_size += lockout_recovery_bytes.size();
std::string command_hash(32, 0);
@@ -33147,10 +26931,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -33161,31 +26944,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -33193,36 +26968,27 @@
}
TPM_RC Tpm::ParseResponse_DictionaryAttackParameters(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -33234,9 +27000,7 @@
}
TPM_CC command_code = TPM_CC_DictionaryAttackParameters;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -33254,21 +27018,17 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
@@ -33290,40 +27050,32 @@
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(DictionaryAttackParametersErrorCallback, callback);
TPM_RC rc = Tpm::ParseResponse_DictionaryAttackParameters(
- response,
- authorization_delegate);
+ response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
void Tpm::DictionaryAttackParameters(
- const TPMI_RH_LOCKOUT& lock_handle,
- const std::string& lock_handle_name,
- const UINT32& new_max_tries,
- const UINT32& new_recovery_time,
- const UINT32& lockout_recovery,
- AuthorizationDelegate* authorization_delegate,
- const DictionaryAttackParametersResponse& callback) {
+ const TPMI_RH_LOCKOUT& lock_handle,
+ const std::string& lock_handle_name,
+ const UINT32& new_max_tries,
+ const UINT32& new_recovery_time,
+ const UINT32& lockout_recovery,
+ AuthorizationDelegate* authorization_delegate,
+ const DictionaryAttackParametersResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(DictionaryAttackParametersErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(DictionaryAttackParametersResponseParser,
- callback,
+ base::Bind(DictionaryAttackParametersResponseParser, callback,
authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_DictionaryAttackParameters(
- lock_handle,
- lock_handle_name,
- new_max_tries,
- new_recovery_time,
- lockout_recovery,
- &command,
- authorization_delegate);
+ lock_handle, lock_handle_name, new_max_tries, new_recovery_time,
+ lockout_recovery, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -33332,39 +27084,33 @@
}
TPM_RC Tpm::DictionaryAttackParametersSync(
- const TPMI_RH_LOCKOUT& lock_handle,
- const std::string& lock_handle_name,
- const UINT32& new_max_tries,
- const UINT32& new_recovery_time,
- const UINT32& lockout_recovery,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_LOCKOUT& lock_handle,
+ const std::string& lock_handle_name,
+ const UINT32& new_max_tries,
+ const UINT32& new_recovery_time,
+ const UINT32& lockout_recovery,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_DictionaryAttackParameters(
- lock_handle,
- lock_handle_name,
- new_max_tries,
- new_recovery_time,
- lockout_recovery,
- &command,
- authorization_delegate);
+ lock_handle, lock_handle_name, new_max_tries, new_recovery_time,
+ lockout_recovery, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_DictionaryAttackParameters(
- response,
- authorization_delegate);
+ rc = ParseResponse_DictionaryAttackParameters(response,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_PP_Commands(
- const TPMI_RH_PLATFORM& auth,
- const std::string& auth_name,
- const TPML_CC& set_list,
- const TPML_CC& clear_list,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PLATFORM& auth,
+ const std::string& auth_name,
+ const TPML_CC& set_list,
+ const TPML_CC& clear_list,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -33375,47 +27121,35 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_bytes;
- rc = Serialize_TPMI_RH_PLATFORM(
- auth,
- &auth_bytes);
+ rc = Serialize_TPMI_RH_PLATFORM(auth, &auth_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string set_list_bytes;
- rc = Serialize_TPML_CC(
- set_list,
- &set_list_bytes);
+ rc = Serialize_TPML_CC(set_list, &set_list_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string clear_list_bytes;
- rc = Serialize_TPML_CC(
- clear_list,
- &clear_list_bytes);
+ rc = Serialize_TPML_CC(clear_list, &clear_list_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_name.data(),
- auth_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_name.data(), auth_name.size());
handle_section_bytes += auth_bytes;
command_size += auth_bytes.size();
- hash->Update(set_list_bytes.data(),
- set_list_bytes.size());
+ hash->Update(set_list_bytes.data(), set_list_bytes.size());
parameter_section_bytes += set_list_bytes;
command_size += set_list_bytes.size();
- hash->Update(clear_list_bytes.data(),
- clear_list_bytes.size());
+ hash->Update(clear_list_bytes.data(), clear_list_bytes.size());
parameter_section_bytes += clear_list_bytes;
command_size += clear_list_bytes.size();
std::string command_hash(32, 0);
@@ -33424,10 +27158,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -33438,31 +27171,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -33470,36 +27195,27 @@
}
TPM_RC Tpm::ParseResponse_PP_Commands(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -33511,9 +27227,7 @@
}
TPM_CC command_code = TPM_CC_PP_Commands;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -33531,74 +27245,57 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void PP_CommandsErrorCallback(
- const Tpm::PP_CommandsResponse& callback,
- TPM_RC response_code) {
+void PP_CommandsErrorCallback(const Tpm::PP_CommandsResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void PP_CommandsResponseParser(
- const Tpm::PP_CommandsResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void PP_CommandsResponseParser(const Tpm::PP_CommandsResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PP_CommandsErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_PP_Commands(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_PP_Commands(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::PP_Commands(
- const TPMI_RH_PLATFORM& auth,
- const std::string& auth_name,
- const TPML_CC& set_list,
- const TPML_CC& clear_list,
- AuthorizationDelegate* authorization_delegate,
- const PP_CommandsResponse& callback) {
+void Tpm::PP_Commands(const TPMI_RH_PLATFORM& auth,
+ const std::string& auth_name,
+ const TPML_CC& set_list,
+ const TPML_CC& clear_list,
+ AuthorizationDelegate* authorization_delegate,
+ const PP_CommandsResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(PP_CommandsErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(PP_CommandsResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(PP_CommandsResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_PP_Commands(
- auth,
- auth_name,
- set_list,
- clear_list,
- &command,
- authorization_delegate);
+ auth, auth_name, set_list, clear_list, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -33606,37 +27303,29 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::PP_CommandsSync(
- const TPMI_RH_PLATFORM& auth,
- const std::string& auth_name,
- const TPML_CC& set_list,
- const TPML_CC& clear_list,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::PP_CommandsSync(const TPMI_RH_PLATFORM& auth,
+ const std::string& auth_name,
+ const TPML_CC& set_list,
+ const TPML_CC& clear_list,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_PP_Commands(
- auth,
- auth_name,
- set_list,
- clear_list,
- &command,
- authorization_delegate);
+ auth, auth_name, set_list, clear_list, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_PP_Commands(
- response,
- authorization_delegate);
+ rc = ParseResponse_PP_Commands(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_SetAlgorithmSet(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- const UINT32& algorithm_set,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ const UINT32& algorithm_set,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -33647,36 +27336,27 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_PLATFORM(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_PLATFORM(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string algorithm_set_bytes;
- rc = Serialize_UINT32(
- algorithm_set,
- &algorithm_set_bytes);
+ rc = Serialize_UINT32(algorithm_set, &algorithm_set_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
- hash->Update(algorithm_set_bytes.data(),
- algorithm_set_bytes.size());
+ hash->Update(algorithm_set_bytes.data(), algorithm_set_bytes.size());
parameter_section_bytes += algorithm_set_bytes;
command_size += algorithm_set_bytes.size();
std::string command_hash(32, 0);
@@ -33685,10 +27365,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -33699,31 +27378,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -33731,36 +27402,27 @@
}
TPM_RC Tpm::ParseResponse_SetAlgorithmSet(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -33772,9 +27434,7 @@
}
TPM_CC command_code = TPM_CC_SetAlgorithmSet;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -33792,30 +27452,25 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void SetAlgorithmSetErrorCallback(
- const Tpm::SetAlgorithmSetResponse& callback,
- TPM_RC response_code) {
+void SetAlgorithmSetErrorCallback(const Tpm::SetAlgorithmSetResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
@@ -33827,37 +27482,29 @@
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(SetAlgorithmSetErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_SetAlgorithmSet(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_SetAlgorithmSet(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::SetAlgorithmSet(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- const UINT32& algorithm_set,
- AuthorizationDelegate* authorization_delegate,
- const SetAlgorithmSetResponse& callback) {
+void Tpm::SetAlgorithmSet(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ const UINT32& algorithm_set,
+ AuthorizationDelegate* authorization_delegate,
+ const SetAlgorithmSetResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(SetAlgorithmSetErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(SetAlgorithmSetResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ SetAlgorithmSetResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_SetAlgorithmSet(
- auth_handle,
- auth_handle_name,
- algorithm_set,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_SetAlgorithmSet(auth_handle, auth_handle_name,
+ algorithm_set, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -33865,38 +27512,32 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::SetAlgorithmSetSync(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- const UINT32& algorithm_set,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::SetAlgorithmSetSync(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ const UINT32& algorithm_set,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_SetAlgorithmSet(
- auth_handle,
- auth_handle_name,
- algorithm_set,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_SetAlgorithmSet(auth_handle, auth_handle_name,
+ algorithm_set, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_SetAlgorithmSet(
- response,
- authorization_delegate);
+ rc = ParseResponse_SetAlgorithmSet(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_FieldUpgradeStart(
- const TPMI_RH_PLATFORM& authorization,
- const std::string& authorization_name,
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& fu_digest,
- const TPMT_SIGNATURE& manifest_signature,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PLATFORM& authorization,
+ const std::string& authorization_name,
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& fu_digest,
+ const TPMT_SIGNATURE& manifest_signature,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -33907,37 +27548,27 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string authorization_bytes;
- rc = Serialize_TPMI_RH_PLATFORM(
- authorization,
- &authorization_bytes);
+ rc = Serialize_TPMI_RH_PLATFORM(authorization, &authorization_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string key_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- key_handle,
- &key_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(key_handle, &key_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string fu_digest_bytes;
- rc = Serialize_TPM2B_DIGEST(
- fu_digest,
- &fu_digest_bytes);
+ rc = Serialize_TPM2B_DIGEST(fu_digest, &fu_digest_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string manifest_signature_bytes;
- rc = Serialize_TPMT_SIGNATURE(
- manifest_signature,
- &manifest_signature_bytes);
+ rc = Serialize_TPMT_SIGNATURE(manifest_signature, &manifest_signature_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -33949,20 +27580,16 @@
}
fu_digest_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(authorization_name.data(),
- authorization_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(authorization_name.data(), authorization_name.size());
handle_section_bytes += authorization_bytes;
command_size += authorization_bytes.size();
- hash->Update(key_handle_name.data(),
- key_handle_name.size());
+ hash->Update(key_handle_name.data(), key_handle_name.size());
handle_section_bytes += key_handle_bytes;
command_size += key_handle_bytes.size();
- hash->Update(fu_digest_bytes.data(),
- fu_digest_bytes.size());
+ hash->Update(fu_digest_bytes.data(), fu_digest_bytes.size());
parameter_section_bytes += fu_digest_bytes;
command_size += fu_digest_bytes.size();
hash->Update(manifest_signature_bytes.data(),
@@ -33975,10 +27602,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -33989,31 +27615,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -34021,36 +27639,27 @@
}
TPM_RC Tpm::ParseResponse_FieldUpgradeStart(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -34062,9 +27671,7 @@
}
TPM_CC command_code = TPM_CC_FieldUpgradeStart;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -34082,21 +27689,17 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
@@ -34117,43 +27720,32 @@
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(FieldUpgradeStartErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_FieldUpgradeStart(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_FieldUpgradeStart(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::FieldUpgradeStart(
- const TPMI_RH_PLATFORM& authorization,
- const std::string& authorization_name,
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& fu_digest,
- const TPMT_SIGNATURE& manifest_signature,
- AuthorizationDelegate* authorization_delegate,
- const FieldUpgradeStartResponse& callback) {
+void Tpm::FieldUpgradeStart(const TPMI_RH_PLATFORM& authorization,
+ const std::string& authorization_name,
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& fu_digest,
+ const TPMT_SIGNATURE& manifest_signature,
+ AuthorizationDelegate* authorization_delegate,
+ const FieldUpgradeStartResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(FieldUpgradeStartErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(FieldUpgradeStartResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ FieldUpgradeStartResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_FieldUpgradeStart(
- authorization,
- authorization_name,
- key_handle,
- key_handle_name,
- fu_digest,
- manifest_signature,
- &command,
- authorization_delegate);
+ authorization, authorization_name, key_handle, key_handle_name, fu_digest,
+ manifest_signature, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -34162,38 +27754,30 @@
}
TPM_RC Tpm::FieldUpgradeStartSync(
- const TPMI_RH_PLATFORM& authorization,
- const std::string& authorization_name,
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& fu_digest,
- const TPMT_SIGNATURE& manifest_signature,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PLATFORM& authorization,
+ const std::string& authorization_name,
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& fu_digest,
+ const TPMT_SIGNATURE& manifest_signature,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_FieldUpgradeStart(
- authorization,
- authorization_name,
- key_handle,
- key_handle_name,
- fu_digest,
- manifest_signature,
- &command,
- authorization_delegate);
+ authorization, authorization_name, key_handle, key_handle_name, fu_digest,
+ manifest_signature, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_FieldUpgradeStart(
- response,
- authorization_delegate);
+ rc = ParseResponse_FieldUpgradeStart(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_FieldUpgradeData(
- const TPM2B_MAX_BUFFER& fu_data,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPM2B_MAX_BUFFER& fu_data,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -34204,16 +27788,12 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string fu_data_bytes;
- rc = Serialize_TPM2B_MAX_BUFFER(
- fu_data,
- &fu_data_bytes);
+ rc = Serialize_TPM2B_MAX_BUFFER(fu_data, &fu_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -34225,12 +27805,10 @@
}
fu_data_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(fu_data_bytes.data(),
- fu_data_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(fu_data_bytes.data(), fu_data_bytes.size());
parameter_section_bytes += fu_data_bytes;
command_size += fu_data_bytes.size();
std::string command_hash(32, 0);
@@ -34239,10 +27817,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -34253,31 +27830,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -34285,38 +27854,29 @@
}
TPM_RC Tpm::ParseResponse_FieldUpgradeData(
- const std::string& response,
- TPMT_HA* next_digest,
- TPMT_HA* first_digest,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPMT_HA* next_digest,
+ TPMT_HA* first_digest,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -34328,9 +27888,7 @@
}
TPM_CC command_code = TPM_CC_FieldUpgradeData;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -34348,37 +27906,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string next_digest_bytes;
- rc = Parse_TPMT_HA(
- &buffer,
- next_digest,
- &next_digest_bytes);
+ rc = Parse_TPMT_HA(&buffer, next_digest, &next_digest_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string first_digest_bytes;
- rc = Parse_TPMT_HA(
- &buffer,
- first_digest,
- &first_digest_bytes);
+ rc = Parse_TPMT_HA(&buffer, first_digest, &first_digest_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -34389,9 +27937,7 @@
const Tpm::FieldUpgradeDataResponse& callback,
TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPMT_HA(),
- TPMT_HA());
+ callback.Run(response_code, TPMT_HA(), TPMT_HA());
}
void FieldUpgradeDataResponseParser(
@@ -34404,36 +27950,25 @@
TPMT_HA next_digest;
TPMT_HA first_digest;
TPM_RC rc = Tpm::ParseResponse_FieldUpgradeData(
- response,
- &next_digest,
- &first_digest,
- authorization_delegate);
+ response, &next_digest, &first_digest, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- next_digest,
- first_digest);
+ callback.Run(rc, next_digest, first_digest);
}
-void Tpm::FieldUpgradeData(
- const TPM2B_MAX_BUFFER& fu_data,
- AuthorizationDelegate* authorization_delegate,
- const FieldUpgradeDataResponse& callback) {
+void Tpm::FieldUpgradeData(const TPM2B_MAX_BUFFER& fu_data,
+ AuthorizationDelegate* authorization_delegate,
+ const FieldUpgradeDataResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(FieldUpgradeDataErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(FieldUpgradeDataResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ FieldUpgradeDataResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_FieldUpgradeData(
- fu_data,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_FieldUpgradeData(fu_data, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -34442,32 +27977,27 @@
}
TPM_RC Tpm::FieldUpgradeDataSync(
- const TPM2B_MAX_BUFFER& fu_data,
- TPMT_HA* next_digest,
- TPMT_HA* first_digest,
- AuthorizationDelegate* authorization_delegate) {
+ const TPM2B_MAX_BUFFER& fu_data,
+ TPMT_HA* next_digest,
+ TPMT_HA* first_digest,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_FieldUpgradeData(
- fu_data,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_FieldUpgradeData(fu_data, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_FieldUpgradeData(
- response,
- next_digest,
- first_digest,
- authorization_delegate);
+ rc = ParseResponse_FieldUpgradeData(response, next_digest, first_digest,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_FirmwareRead(
- const UINT32& sequence_number,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const UINT32& sequence_number,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -34478,25 +28008,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string sequence_number_bytes;
- rc = Serialize_UINT32(
- sequence_number,
- &sequence_number_bytes);
+ rc = Serialize_UINT32(sequence_number, &sequence_number_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(sequence_number_bytes.data(),
- sequence_number_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(sequence_number_bytes.data(), sequence_number_bytes.size());
parameter_section_bytes += sequence_number_bytes;
command_size += sequence_number_bytes.size();
std::string command_hash(32, 0);
@@ -34505,10 +28029,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -34519,31 +28042,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -34551,37 +28066,28 @@
}
TPM_RC Tpm::ParseResponse_FirmwareRead(
- const std::string& response,
- TPM2B_MAX_BUFFER* fu_data,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_MAX_BUFFER* fu_data,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -34593,9 +28099,7 @@
}
TPM_CC command_code = TPM_CC_FirmwareRead;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -34613,29 +28117,22 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string fu_data_bytes;
- rc = Parse_TPM2B_MAX_BUFFER(
- &buffer,
- fu_data,
- &fu_data_bytes);
+ rc = Parse_TPM2B_MAX_BUFFER(&buffer, fu_data, &fu_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -34647,10 +28144,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
fu_data_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_MAX_BUFFER(
- &fu_data_bytes,
- fu_data,
- nullptr);
+ rc = Parse_TPM2B_MAX_BUFFER(&fu_data_bytes, fu_data, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -34658,51 +28152,39 @@
return TPM_RC_SUCCESS;
}
-void FirmwareReadErrorCallback(
- const Tpm::FirmwareReadResponse& callback,
- TPM_RC response_code) {
+void FirmwareReadErrorCallback(const Tpm::FirmwareReadResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_MAX_BUFFER());
+ callback.Run(response_code, TPM2B_MAX_BUFFER());
}
-void FirmwareReadResponseParser(
- const Tpm::FirmwareReadResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void FirmwareReadResponseParser(const Tpm::FirmwareReadResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(FirmwareReadErrorCallback, callback);
TPM2B_MAX_BUFFER fu_data;
- TPM_RC rc = Tpm::ParseResponse_FirmwareRead(
- response,
- &fu_data,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_FirmwareRead(response, &fu_data,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- fu_data);
+ callback.Run(rc, fu_data);
}
-void Tpm::FirmwareRead(
- const UINT32& sequence_number,
- AuthorizationDelegate* authorization_delegate,
- const FirmwareReadResponse& callback) {
+void Tpm::FirmwareRead(const UINT32& sequence_number,
+ AuthorizationDelegate* authorization_delegate,
+ const FirmwareReadResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(FirmwareReadErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(FirmwareReadResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(FirmwareReadResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_FirmwareRead(
- sequence_number,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_FirmwareRead(sequence_number, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -34710,32 +28192,26 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::FirmwareReadSync(
- const UINT32& sequence_number,
- TPM2B_MAX_BUFFER* fu_data,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::FirmwareReadSync(const UINT32& sequence_number,
+ TPM2B_MAX_BUFFER* fu_data,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_FirmwareRead(
- sequence_number,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_FirmwareRead(sequence_number, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_FirmwareRead(
- response,
- fu_data,
- authorization_delegate);
+ rc = ParseResponse_FirmwareRead(response, fu_data, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_ContextSave(
- const TPMI_DH_CONTEXT& save_handle,
- const std::string& save_handle_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_CONTEXT& save_handle,
+ const std::string& save_handle_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -34746,25 +28222,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string save_handle_bytes;
- rc = Serialize_TPMI_DH_CONTEXT(
- save_handle,
- &save_handle_bytes);
+ rc = Serialize_TPMI_DH_CONTEXT(save_handle, &save_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(save_handle_name.data(),
- save_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(save_handle_name.data(), save_handle_name.size());
handle_section_bytes += save_handle_bytes;
command_size += save_handle_bytes.size();
std::string command_hash(32, 0);
@@ -34773,10 +28243,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -34787,31 +28256,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -34819,37 +28280,28 @@
}
TPM_RC Tpm::ParseResponse_ContextSave(
- const std::string& response,
- TPMS_CONTEXT* context,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPMS_CONTEXT* context,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -34861,9 +28313,7 @@
}
TPM_CC command_code = TPM_CC_ContextSave;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -34881,82 +28331,62 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string context_bytes;
- rc = Parse_TPMS_CONTEXT(
- &buffer,
- context,
- &context_bytes);
+ rc = Parse_TPMS_CONTEXT(&buffer, context, &context_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
return TPM_RC_SUCCESS;
}
-void ContextSaveErrorCallback(
- const Tpm::ContextSaveResponse& callback,
- TPM_RC response_code) {
+void ContextSaveErrorCallback(const Tpm::ContextSaveResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPMS_CONTEXT());
+ callback.Run(response_code, TPMS_CONTEXT());
}
-void ContextSaveResponseParser(
- const Tpm::ContextSaveResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void ContextSaveResponseParser(const Tpm::ContextSaveResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ContextSaveErrorCallback, callback);
TPMS_CONTEXT context;
- TPM_RC rc = Tpm::ParseResponse_ContextSave(
- response,
- &context,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_ContextSave(response, &context,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- context);
+ callback.Run(rc, context);
}
-void Tpm::ContextSave(
- const TPMI_DH_CONTEXT& save_handle,
- const std::string& save_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const ContextSaveResponse& callback) {
+void Tpm::ContextSave(const TPMI_DH_CONTEXT& save_handle,
+ const std::string& save_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const ContextSaveResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ContextSaveErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(ContextSaveResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(ContextSaveResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_ContextSave(
- save_handle,
- save_handle_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ContextSave(save_handle, save_handle_name,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -34964,33 +28394,26 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::ContextSaveSync(
- const TPMI_DH_CONTEXT& save_handle,
- const std::string& save_handle_name,
- TPMS_CONTEXT* context,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ContextSaveSync(const TPMI_DH_CONTEXT& save_handle,
+ const std::string& save_handle_name,
+ TPMS_CONTEXT* context,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_ContextSave(
- save_handle,
- save_handle_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ContextSave(save_handle, save_handle_name,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_ContextSave(
- response,
- context,
- authorization_delegate);
+ rc = ParseResponse_ContextSave(response, context, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_ContextLoad(
- const TPMS_CONTEXT& context,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMS_CONTEXT& context,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -35001,25 +28424,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string context_bytes;
- rc = Serialize_TPMS_CONTEXT(
- context,
- &context_bytes);
+ rc = Serialize_TPMS_CONTEXT(context, &context_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(context_bytes.data(),
- context_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(context_bytes.data(), context_bytes.size());
parameter_section_bytes += context_bytes;
command_size += context_bytes.size();
std::string command_hash(32, 0);
@@ -35028,10 +28445,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -35042,31 +28458,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -35074,37 +28482,28 @@
}
TPM_RC Tpm::ParseResponse_ContextLoad(
- const std::string& response,
- TPMI_DH_CONTEXT* loaded_handle,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPMI_DH_CONTEXT* loaded_handle,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -35115,18 +28514,13 @@
return response_code;
}
std::string loaded_handle_bytes;
- rc = Parse_TPMI_DH_CONTEXT(
- &buffer,
- loaded_handle,
- &loaded_handle_bytes);
+ rc = Parse_TPMI_DH_CONTEXT(&buffer, loaded_handle, &loaded_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_CC command_code = TPM_CC_ContextLoad;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -35144,72 +28538,56 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void ContextLoadErrorCallback(
- const Tpm::ContextLoadResponse& callback,
- TPM_RC response_code) {
+void ContextLoadErrorCallback(const Tpm::ContextLoadResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPMI_DH_CONTEXT());
+ callback.Run(response_code, TPMI_DH_CONTEXT());
}
-void ContextLoadResponseParser(
- const Tpm::ContextLoadResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void ContextLoadResponseParser(const Tpm::ContextLoadResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ContextLoadErrorCallback, callback);
TPMI_DH_CONTEXT loaded_handle;
- TPM_RC rc = Tpm::ParseResponse_ContextLoad(
- response,
- &loaded_handle,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_ContextLoad(response, &loaded_handle,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- loaded_handle);
+ callback.Run(rc, loaded_handle);
}
-void Tpm::ContextLoad(
- const TPMS_CONTEXT& context,
- AuthorizationDelegate* authorization_delegate,
- const ContextLoadResponse& callback) {
+void Tpm::ContextLoad(const TPMS_CONTEXT& context,
+ AuthorizationDelegate* authorization_delegate,
+ const ContextLoadResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ContextLoadErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(ContextLoadResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(ContextLoadResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_ContextLoad(
- context,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_ContextLoad(context, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -35217,31 +28595,26 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::ContextLoadSync(
- const TPMS_CONTEXT& context,
- TPMI_DH_CONTEXT* loaded_handle,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ContextLoadSync(const TPMS_CONTEXT& context,
+ TPMI_DH_CONTEXT* loaded_handle,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_ContextLoad(
- context,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_ContextLoad(context, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_ContextLoad(
- response,
- loaded_handle,
- authorization_delegate);
+ rc = ParseResponse_ContextLoad(response, loaded_handle,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_FlushContext(
- const TPMI_DH_CONTEXT& flush_handle,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_CONTEXT& flush_handle,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -35252,25 +28625,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string flush_handle_bytes;
- rc = Serialize_TPMI_DH_CONTEXT(
- flush_handle,
- &flush_handle_bytes);
+ rc = Serialize_TPMI_DH_CONTEXT(flush_handle, &flush_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(flush_handle_bytes.data(),
- flush_handle_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(flush_handle_bytes.data(), flush_handle_bytes.size());
parameter_section_bytes += flush_handle_bytes;
command_size += flush_handle_bytes.size();
std::string command_hash(32, 0);
@@ -35279,10 +28646,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -35293,31 +28659,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -35325,36 +28683,27 @@
}
TPM_RC Tpm::ParseResponse_FlushContext(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -35366,9 +28715,7 @@
}
TPM_CC command_code = TPM_CC_FlushContext;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -35386,68 +28733,54 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void FlushContextErrorCallback(
- const Tpm::FlushContextResponse& callback,
- TPM_RC response_code) {
+void FlushContextErrorCallback(const Tpm::FlushContextResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void FlushContextResponseParser(
- const Tpm::FlushContextResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void FlushContextResponseParser(const Tpm::FlushContextResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(FlushContextErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_FlushContext(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_FlushContext(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::FlushContext(
- const TPMI_DH_CONTEXT& flush_handle,
- AuthorizationDelegate* authorization_delegate,
- const FlushContextResponse& callback) {
+void Tpm::FlushContext(const TPMI_DH_CONTEXT& flush_handle,
+ AuthorizationDelegate* authorization_delegate,
+ const FlushContextResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(FlushContextErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(FlushContextResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(FlushContextResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_FlushContext(
- flush_handle,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_FlushContext(flush_handle, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -35455,33 +28788,28 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::FlushContextSync(
- const TPMI_DH_CONTEXT& flush_handle,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::FlushContextSync(const TPMI_DH_CONTEXT& flush_handle,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_FlushContext(
- flush_handle,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_FlushContext(flush_handle, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_FlushContext(
- response,
- authorization_delegate);
+ rc = ParseResponse_FlushContext(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_EvictControl(
- const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_PERSISTENT& persistent_handle,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_PERSISTENT& persistent_handle,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -35492,47 +28820,36 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_bytes;
- rc = Serialize_TPMI_RH_PROVISION(
- auth,
- &auth_bytes);
+ rc = Serialize_TPMI_RH_PROVISION(auth, &auth_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string object_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- object_handle,
- &object_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(object_handle, &object_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string persistent_handle_bytes;
- rc = Serialize_TPMI_DH_PERSISTENT(
- persistent_handle,
- &persistent_handle_bytes);
+ rc =
+ Serialize_TPMI_DH_PERSISTENT(persistent_handle, &persistent_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_name.data(),
- auth_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_name.data(), auth_name.size());
handle_section_bytes += auth_bytes;
command_size += auth_bytes.size();
- hash->Update(object_handle_name.data(),
- object_handle_name.size());
+ hash->Update(object_handle_name.data(), object_handle_name.size());
handle_section_bytes += object_handle_bytes;
command_size += object_handle_bytes.size();
- hash->Update(persistent_handle_bytes.data(),
- persistent_handle_bytes.size());
+ hash->Update(persistent_handle_bytes.data(), persistent_handle_bytes.size());
parameter_section_bytes += persistent_handle_bytes;
command_size += persistent_handle_bytes.size();
std::string command_hash(32, 0);
@@ -35541,10 +28858,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -35555,31 +28871,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -35587,36 +28895,27 @@
}
TPM_RC Tpm::ParseResponse_EvictControl(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -35628,9 +28927,7 @@
}
TPM_CC command_code = TPM_CC_EvictControl;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -35648,76 +28945,59 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void EvictControlErrorCallback(
- const Tpm::EvictControlResponse& callback,
- TPM_RC response_code) {
+void EvictControlErrorCallback(const Tpm::EvictControlResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void EvictControlResponseParser(
- const Tpm::EvictControlResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void EvictControlResponseParser(const Tpm::EvictControlResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(EvictControlErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_EvictControl(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_EvictControl(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::EvictControl(
- const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_PERSISTENT& persistent_handle,
- AuthorizationDelegate* authorization_delegate,
- const EvictControlResponse& callback) {
+void Tpm::EvictControl(const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_PERSISTENT& persistent_handle,
+ AuthorizationDelegate* authorization_delegate,
+ const EvictControlResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(EvictControlErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(EvictControlResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(EvictControlResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_EvictControl(
- auth,
- auth_name,
- object_handle,
- object_handle_name,
- persistent_handle,
- &command,
- authorization_delegate);
+ auth, auth_name, object_handle, object_handle_name, persistent_handle,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -35725,36 +29005,28 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::EvictControlSync(
- const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_PERSISTENT& persistent_handle,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::EvictControlSync(const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_PERSISTENT& persistent_handle,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_EvictControl(
- auth,
- auth_name,
- object_handle,
- object_handle_name,
- persistent_handle,
- &command,
- authorization_delegate);
+ auth, auth_name, object_handle, object_handle_name, persistent_handle,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_EvictControl(
- response,
- authorization_delegate);
+ rc = ParseResponse_EvictControl(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_ReadClock(
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -35765,26 +29037,22 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
std::string command_hash(32, 0);
hash->Finish(string_as_array(&command_hash), command_hash.size());
std::string authorization_section_bytes;
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -35795,31 +29063,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -35827,37 +29087,28 @@
}
TPM_RC Tpm::ParseResponse_ReadClock(
- const std::string& response,
- TPMS_TIME_INFO* current_time,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPMS_TIME_INFO* current_time,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -35869,9 +29120,7 @@
}
TPM_CC command_code = TPM_CC_ReadClock;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -35889,78 +29138,59 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string current_time_bytes;
- rc = Parse_TPMS_TIME_INFO(
- &buffer,
- current_time,
- ¤t_time_bytes);
+ rc = Parse_TPMS_TIME_INFO(&buffer, current_time, ¤t_time_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
return TPM_RC_SUCCESS;
}
-void ReadClockErrorCallback(
- const Tpm::ReadClockResponse& callback,
- TPM_RC response_code) {
+void ReadClockErrorCallback(const Tpm::ReadClockResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPMS_TIME_INFO());
+ callback.Run(response_code, TPMS_TIME_INFO());
}
-void ReadClockResponseParser(
- const Tpm::ReadClockResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void ReadClockResponseParser(const Tpm::ReadClockResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ReadClockErrorCallback, callback);
TPMS_TIME_INFO current_time;
- TPM_RC rc = Tpm::ParseResponse_ReadClock(
- response,
- ¤t_time,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_ReadClock(response, ¤t_time,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- current_time);
+ callback.Run(rc, current_time);
}
-void Tpm::ReadClock(
- AuthorizationDelegate* authorization_delegate,
- const ReadClockResponse& callback) {
+void Tpm::ReadClock(AuthorizationDelegate* authorization_delegate,
+ const ReadClockResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ReadClockErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(ReadClockResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(ReadClockResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_ReadClock(
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ReadClock(&command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -35968,31 +29198,25 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::ReadClockSync(
- TPMS_TIME_INFO* current_time,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ReadClockSync(TPMS_TIME_INFO* current_time,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_ReadClock(
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ReadClock(&command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_ReadClock(
- response,
- current_time,
- authorization_delegate);
+ rc = ParseResponse_ReadClock(response, current_time, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_ClockSet(
- const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const UINT64& new_time,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const UINT64& new_time,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -36003,36 +29227,27 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_bytes;
- rc = Serialize_TPMI_RH_PROVISION(
- auth,
- &auth_bytes);
+ rc = Serialize_TPMI_RH_PROVISION(auth, &auth_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string new_time_bytes;
- rc = Serialize_UINT64(
- new_time,
- &new_time_bytes);
+ rc = Serialize_UINT64(new_time, &new_time_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_name.data(),
- auth_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_name.data(), auth_name.size());
handle_section_bytes += auth_bytes;
command_size += auth_bytes.size();
- hash->Update(new_time_bytes.data(),
- new_time_bytes.size());
+ hash->Update(new_time_bytes.data(), new_time_bytes.size());
parameter_section_bytes += new_time_bytes;
command_size += new_time_bytes.size();
std::string command_hash(32, 0);
@@ -36041,10 +29256,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -36055,31 +29269,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -36087,36 +29293,27 @@
}
TPM_RC Tpm::ParseResponse_ClockSet(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -36128,9 +29325,7 @@
}
TPM_CC command_code = TPM_CC_ClockSet;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -36148,72 +29343,56 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void ClockSetErrorCallback(
- const Tpm::ClockSetResponse& callback,
- TPM_RC response_code) {
+void ClockSetErrorCallback(const Tpm::ClockSetResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void ClockSetResponseParser(
- const Tpm::ClockSetResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void ClockSetResponseParser(const Tpm::ClockSetResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ClockSetErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_ClockSet(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_ClockSet(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::ClockSet(
- const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const UINT64& new_time,
- AuthorizationDelegate* authorization_delegate,
- const ClockSetResponse& callback) {
+void Tpm::ClockSet(const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const UINT64& new_time,
+ AuthorizationDelegate* authorization_delegate,
+ const ClockSetResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ClockSetErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(ClockSetResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(ClockSetResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_ClockSet(
- auth,
- auth_name,
- new_time,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ClockSet(auth, auth_name, new_time, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -36221,35 +29400,28 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::ClockSetSync(
- const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const UINT64& new_time,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ClockSetSync(const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const UINT64& new_time,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_ClockSet(
- auth,
- auth_name,
- new_time,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_ClockSet(auth, auth_name, new_time, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_ClockSet(
- response,
- authorization_delegate);
+ rc = ParseResponse_ClockSet(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_ClockRateAdjust(
- const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const TPM_CLOCK_ADJUST& rate_adjust,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const TPM_CLOCK_ADJUST& rate_adjust,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -36260,36 +29432,27 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_bytes;
- rc = Serialize_TPMI_RH_PROVISION(
- auth,
- &auth_bytes);
+ rc = Serialize_TPMI_RH_PROVISION(auth, &auth_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string rate_adjust_bytes;
- rc = Serialize_TPM_CLOCK_ADJUST(
- rate_adjust,
- &rate_adjust_bytes);
+ rc = Serialize_TPM_CLOCK_ADJUST(rate_adjust, &rate_adjust_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_name.data(),
- auth_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_name.data(), auth_name.size());
handle_section_bytes += auth_bytes;
command_size += auth_bytes.size();
- hash->Update(rate_adjust_bytes.data(),
- rate_adjust_bytes.size());
+ hash->Update(rate_adjust_bytes.data(), rate_adjust_bytes.size());
parameter_section_bytes += rate_adjust_bytes;
command_size += rate_adjust_bytes.size();
std::string command_hash(32, 0);
@@ -36298,10 +29461,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -36312,31 +29474,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -36344,36 +29498,27 @@
}
TPM_RC Tpm::ParseResponse_ClockRateAdjust(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -36385,9 +29530,7 @@
}
TPM_CC command_code = TPM_CC_ClockRateAdjust;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -36405,30 +29548,25 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void ClockRateAdjustErrorCallback(
- const Tpm::ClockRateAdjustResponse& callback,
- TPM_RC response_code) {
+void ClockRateAdjustErrorCallback(const Tpm::ClockRateAdjustResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
@@ -36440,37 +29578,28 @@
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ClockRateAdjustErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_ClockRateAdjust(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_ClockRateAdjust(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::ClockRateAdjust(
- const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const TPM_CLOCK_ADJUST& rate_adjust,
- AuthorizationDelegate* authorization_delegate,
- const ClockRateAdjustResponse& callback) {
+void Tpm::ClockRateAdjust(const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const TPM_CLOCK_ADJUST& rate_adjust,
+ AuthorizationDelegate* authorization_delegate,
+ const ClockRateAdjustResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(ClockRateAdjustErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(ClockRateAdjustResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ ClockRateAdjustResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_ClockRateAdjust(
- auth,
- auth_name,
- rate_adjust,
- &command,
- authorization_delegate);
+ auth, auth_name, rate_adjust, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -36478,35 +29607,28 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::ClockRateAdjustSync(
- const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const TPM_CLOCK_ADJUST& rate_adjust,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::ClockRateAdjustSync(const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const TPM_CLOCK_ADJUST& rate_adjust,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_ClockRateAdjust(
- auth,
- auth_name,
- rate_adjust,
- &command,
- authorization_delegate);
+ auth, auth_name, rate_adjust, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_ClockRateAdjust(
- response,
- authorization_delegate);
+ rc = ParseResponse_ClockRateAdjust(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_GetCapability(
- const TPM_CAP& capability,
- const UINT32& property,
- const UINT32& property_count,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPM_CAP& capability,
+ const UINT32& property,
+ const UINT32& property_count,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -36517,47 +29639,35 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string capability_bytes;
- rc = Serialize_TPM_CAP(
- capability,
- &capability_bytes);
+ rc = Serialize_TPM_CAP(capability, &capability_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string property_bytes;
- rc = Serialize_UINT32(
- property,
- &property_bytes);
+ rc = Serialize_UINT32(property, &property_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string property_count_bytes;
- rc = Serialize_UINT32(
- property_count,
- &property_count_bytes);
+ rc = Serialize_UINT32(property_count, &property_count_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(capability_bytes.data(),
- capability_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(capability_bytes.data(), capability_bytes.size());
parameter_section_bytes += capability_bytes;
command_size += capability_bytes.size();
- hash->Update(property_bytes.data(),
- property_bytes.size());
+ hash->Update(property_bytes.data(), property_bytes.size());
parameter_section_bytes += property_bytes;
command_size += property_bytes.size();
- hash->Update(property_count_bytes.data(),
- property_count_bytes.size());
+ hash->Update(property_count_bytes.data(), property_count_bytes.size());
parameter_section_bytes += property_count_bytes;
command_size += property_count_bytes.size();
std::string command_hash(32, 0);
@@ -36566,10 +29676,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -36580,31 +29689,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -36612,38 +29713,29 @@
}
TPM_RC Tpm::ParseResponse_GetCapability(
- const std::string& response,
- TPMI_YES_NO* more_data,
- TPMS_CAPABILITY_DATA* capability_data,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPMI_YES_NO* more_data,
+ TPMS_CAPABILITY_DATA* capability_data,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -36655,9 +29747,7 @@
}
TPM_CC command_code = TPM_CC_GetCapability;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -36675,96 +29765,70 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string more_data_bytes;
- rc = Parse_TPMI_YES_NO(
- &buffer,
- more_data,
- &more_data_bytes);
+ rc = Parse_TPMI_YES_NO(&buffer, more_data, &more_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string capability_data_bytes;
- rc = Parse_TPMS_CAPABILITY_DATA(
- &buffer,
- capability_data,
- &capability_data_bytes);
+ rc = Parse_TPMS_CAPABILITY_DATA(&buffer, capability_data,
+ &capability_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
return TPM_RC_SUCCESS;
}
-void GetCapabilityErrorCallback(
- const Tpm::GetCapabilityResponse& callback,
- TPM_RC response_code) {
+void GetCapabilityErrorCallback(const Tpm::GetCapabilityResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPMI_YES_NO(),
- TPMS_CAPABILITY_DATA());
+ callback.Run(response_code, TPMI_YES_NO(), TPMS_CAPABILITY_DATA());
}
-void GetCapabilityResponseParser(
- const Tpm::GetCapabilityResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void GetCapabilityResponseParser(const Tpm::GetCapabilityResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(GetCapabilityErrorCallback, callback);
TPMI_YES_NO more_data;
TPMS_CAPABILITY_DATA capability_data;
TPM_RC rc = Tpm::ParseResponse_GetCapability(
- response,
- &more_data,
- &capability_data,
- authorization_delegate);
+ response, &more_data, &capability_data, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- more_data,
- capability_data);
+ callback.Run(rc, more_data, capability_data);
}
-void Tpm::GetCapability(
- const TPM_CAP& capability,
- const UINT32& property,
- const UINT32& property_count,
- AuthorizationDelegate* authorization_delegate,
- const GetCapabilityResponse& callback) {
+void Tpm::GetCapability(const TPM_CAP& capability,
+ const UINT32& property,
+ const UINT32& property_count,
+ AuthorizationDelegate* authorization_delegate,
+ const GetCapabilityResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(GetCapabilityErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(GetCapabilityResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(GetCapabilityResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_GetCapability(
- capability,
- property,
- property_count,
- &command,
- authorization_delegate);
+ capability, property, property_count, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -36772,37 +29836,29 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::GetCapabilitySync(
- const TPM_CAP& capability,
- const UINT32& property,
- const UINT32& property_count,
- TPMI_YES_NO* more_data,
- TPMS_CAPABILITY_DATA* capability_data,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::GetCapabilitySync(const TPM_CAP& capability,
+ const UINT32& property,
+ const UINT32& property_count,
+ TPMI_YES_NO* more_data,
+ TPMS_CAPABILITY_DATA* capability_data,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_GetCapability(
- capability,
- property,
- property_count,
- &command,
- authorization_delegate);
+ capability, property, property_count, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_GetCapability(
- response,
- more_data,
- capability_data,
- authorization_delegate);
+ rc = ParseResponse_GetCapability(response, more_data, capability_data,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_TestParms(
- const TPMT_PUBLIC_PARMS& parameters,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMT_PUBLIC_PARMS& parameters,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -36813,25 +29869,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string parameters_bytes;
- rc = Serialize_TPMT_PUBLIC_PARMS(
- parameters,
- ¶meters_bytes);
+ rc = Serialize_TPMT_PUBLIC_PARMS(parameters, ¶meters_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(parameters_bytes.data(),
- parameters_bytes.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(parameters_bytes.data(), parameters_bytes.size());
parameter_section_bytes += parameters_bytes;
command_size += parameters_bytes.size();
std::string command_hash(32, 0);
@@ -36840,10 +29890,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -36854,31 +29903,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -36886,36 +29927,27 @@
}
TPM_RC Tpm::ParseResponse_TestParms(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -36927,9 +29959,7 @@
}
TPM_CC command_code = TPM_CC_TestParms;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -36947,68 +29977,54 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void TestParmsErrorCallback(
- const Tpm::TestParmsResponse& callback,
- TPM_RC response_code) {
+void TestParmsErrorCallback(const Tpm::TestParmsResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void TestParmsResponseParser(
- const Tpm::TestParmsResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void TestParmsResponseParser(const Tpm::TestParmsResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(TestParmsErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_TestParms(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_TestParms(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::TestParms(
- const TPMT_PUBLIC_PARMS& parameters,
- AuthorizationDelegate* authorization_delegate,
- const TestParmsResponse& callback) {
+void Tpm::TestParms(const TPMT_PUBLIC_PARMS& parameters,
+ AuthorizationDelegate* authorization_delegate,
+ const TestParmsResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(TestParmsErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(TestParmsResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(TestParmsResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_TestParms(
- parameters,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_TestParms(parameters, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -37016,32 +30032,27 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::TestParmsSync(
- const TPMT_PUBLIC_PARMS& parameters,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::TestParmsSync(const TPMT_PUBLIC_PARMS& parameters,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_TestParms(
- parameters,
- &command,
- authorization_delegate);
+ TPM_RC rc =
+ SerializeCommand_TestParms(parameters, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_TestParms(
- response,
- authorization_delegate);
+ rc = ParseResponse_TestParms(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_NV_DefineSpace(
- const TPMI_RH_PROVISION& auth_handle,
- const std::string& auth_handle_name,
- const TPM2B_AUTH& auth,
- const TPM2B_NV_PUBLIC& public_info,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PROVISION& auth_handle,
+ const std::string& auth_handle_name,
+ const TPM2B_AUTH& auth,
+ const TPM2B_NV_PUBLIC& public_info,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -37052,30 +30063,22 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_PROVISION(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_PROVISION(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_bytes;
- rc = Serialize_TPM2B_AUTH(
- auth,
- &auth_bytes);
+ rc = Serialize_TPM2B_AUTH(auth, &auth_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string public_info_bytes;
- rc = Serialize_TPM2B_NV_PUBLIC(
- public_info,
- &public_info_bytes);
+ rc = Serialize_TPM2B_NV_PUBLIC(public_info, &public_info_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -37087,20 +30090,16 @@
}
auth_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
- hash->Update(auth_bytes.data(),
- auth_bytes.size());
+ hash->Update(auth_bytes.data(), auth_bytes.size());
parameter_section_bytes += auth_bytes;
command_size += auth_bytes.size();
- hash->Update(public_info_bytes.data(),
- public_info_bytes.size());
+ hash->Update(public_info_bytes.data(), public_info_bytes.size());
parameter_section_bytes += public_info_bytes;
command_size += public_info_bytes.size();
std::string command_hash(32, 0);
@@ -37109,10 +30108,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -37123,31 +30121,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -37155,36 +30145,27 @@
}
TPM_RC Tpm::ParseResponse_NV_DefineSpace(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -37196,9 +30177,7 @@
}
TPM_CC command_code = TPM_CC_NV_DefineSpace;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -37216,74 +30195,59 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void NV_DefineSpaceErrorCallback(
- const Tpm::NV_DefineSpaceResponse& callback,
- TPM_RC response_code) {
+void NV_DefineSpaceErrorCallback(const Tpm::NV_DefineSpaceResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void NV_DefineSpaceResponseParser(
- const Tpm::NV_DefineSpaceResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void NV_DefineSpaceResponseParser(const Tpm::NV_DefineSpaceResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_DefineSpaceErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_NV_DefineSpace(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_NV_DefineSpace(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::NV_DefineSpace(
- const TPMI_RH_PROVISION& auth_handle,
- const std::string& auth_handle_name,
- const TPM2B_AUTH& auth,
- const TPM2B_NV_PUBLIC& public_info,
- AuthorizationDelegate* authorization_delegate,
- const NV_DefineSpaceResponse& callback) {
+void Tpm::NV_DefineSpace(const TPMI_RH_PROVISION& auth_handle,
+ const std::string& auth_handle_name,
+ const TPM2B_AUTH& auth,
+ const TPM2B_NV_PUBLIC& public_info,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_DefineSpaceResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_DefineSpaceErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(NV_DefineSpaceResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ NV_DefineSpaceResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_NV_DefineSpace(
- auth_handle,
- auth_handle_name,
- auth,
- public_info,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_DefineSpace(auth_handle, auth_handle_name,
+ auth, public_info, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -37291,38 +30255,31 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::NV_DefineSpaceSync(
- const TPMI_RH_PROVISION& auth_handle,
- const std::string& auth_handle_name,
- const TPM2B_AUTH& auth,
- const TPM2B_NV_PUBLIC& public_info,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::NV_DefineSpaceSync(const TPMI_RH_PROVISION& auth_handle,
+ const std::string& auth_handle_name,
+ const TPM2B_AUTH& auth,
+ const TPM2B_NV_PUBLIC& public_info,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_NV_DefineSpace(
- auth_handle,
- auth_handle_name,
- auth,
- public_info,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_DefineSpace(auth_handle, auth_handle_name,
+ auth, public_info, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_NV_DefineSpace(
- response,
- authorization_delegate);
+ rc = ParseResponse_NV_DefineSpace(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_NV_UndefineSpace(
- const TPMI_RH_PROVISION& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PROVISION& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -37333,36 +30290,27 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_PROVISION(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_PROVISION(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string nv_index_bytes;
- rc = Serialize_TPMI_RH_NV_INDEX(
- nv_index,
- &nv_index_bytes);
+ rc = Serialize_TPMI_RH_NV_INDEX(nv_index, &nv_index_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
- hash->Update(nv_index_name.data(),
- nv_index_name.size());
+ hash->Update(nv_index_name.data(), nv_index_name.size());
handle_section_bytes += nv_index_bytes;
command_size += nv_index_bytes.size();
std::string command_hash(32, 0);
@@ -37371,10 +30319,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -37385,31 +30332,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -37417,36 +30356,27 @@
}
TPM_RC Tpm::ParseResponse_NV_UndefineSpace(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -37458,9 +30388,7 @@
}
TPM_CC command_code = TPM_CC_NV_UndefineSpace;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -37478,21 +30406,17 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
@@ -37513,38 +30437,29 @@
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_UndefineSpaceErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_NV_UndefineSpace(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_NV_UndefineSpace(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::NV_UndefineSpace(
- const TPMI_RH_PROVISION& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_UndefineSpaceResponse& callback) {
+void Tpm::NV_UndefineSpace(const TPMI_RH_PROVISION& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_UndefineSpaceResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_UndefineSpaceErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(NV_UndefineSpaceResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ NV_UndefineSpaceResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_NV_UndefineSpace(
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- &command,
+ auth_handle, auth_handle_name, nv_index, nv_index_name, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
@@ -37554,37 +30469,31 @@
}
TPM_RC Tpm::NV_UndefineSpaceSync(
- const TPMI_RH_PROVISION& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PROVISION& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_NV_UndefineSpace(
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- &command,
+ auth_handle, auth_handle_name, nv_index, nv_index_name, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_NV_UndefineSpace(
- response,
- authorization_delegate);
+ rc = ParseResponse_NV_UndefineSpace(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_NV_UndefineSpaceSpecial(
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPMI_RH_PLATFORM& platform,
- const std::string& platform_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPMI_RH_PLATFORM& platform,
+ const std::string& platform_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -37595,36 +30504,27 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string nv_index_bytes;
- rc = Serialize_TPMI_RH_NV_INDEX(
- nv_index,
- &nv_index_bytes);
+ rc = Serialize_TPMI_RH_NV_INDEX(nv_index, &nv_index_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string platform_bytes;
- rc = Serialize_TPMI_RH_PLATFORM(
- platform,
- &platform_bytes);
+ rc = Serialize_TPMI_RH_PLATFORM(platform, &platform_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(nv_index_name.data(),
- nv_index_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(nv_index_name.data(), nv_index_name.size());
handle_section_bytes += nv_index_bytes;
command_size += nv_index_bytes.size();
- hash->Update(platform_name.data(),
- platform_name.size());
+ hash->Update(platform_name.data(), platform_name.size());
handle_section_bytes += platform_bytes;
command_size += platform_bytes.size();
std::string command_hash(32, 0);
@@ -37633,10 +30533,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -37647,31 +30546,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -37679,36 +30570,27 @@
}
TPM_RC Tpm::ParseResponse_NV_UndefineSpaceSpecial(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -37720,9 +30602,7 @@
}
TPM_CC command_code = TPM_CC_NV_UndefineSpaceSpecial;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -37740,21 +30620,17 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
@@ -37776,37 +30652,29 @@
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_UndefineSpaceSpecialErrorCallback, callback);
TPM_RC rc = Tpm::ParseResponse_NV_UndefineSpaceSpecial(
- response,
- authorization_delegate);
+ response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
void Tpm::NV_UndefineSpaceSpecial(
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPMI_RH_PLATFORM& platform,
- const std::string& platform_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_UndefineSpaceSpecialResponse& callback) {
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPMI_RH_PLATFORM& platform,
+ const std::string& platform_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_UndefineSpaceSpecialResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_UndefineSpaceSpecialErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(NV_UndefineSpaceSpecialResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ NV_UndefineSpaceSpecialResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_NV_UndefineSpaceSpecial(
- nv_index,
- nv_index_name,
- platform,
- platform_name,
- &command,
+ nv_index, nv_index_name, platform, platform_name, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
@@ -37816,35 +30684,29 @@
}
TPM_RC Tpm::NV_UndefineSpaceSpecialSync(
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPMI_RH_PLATFORM& platform,
- const std::string& platform_name,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPMI_RH_PLATFORM& platform,
+ const std::string& platform_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_NV_UndefineSpaceSpecial(
- nv_index,
- nv_index_name,
- platform,
- platform_name,
- &command,
+ nv_index, nv_index_name, platform, platform_name, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_NV_UndefineSpaceSpecial(
- response,
- authorization_delegate);
+ rc = ParseResponse_NV_UndefineSpaceSpecial(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_NV_ReadPublic(
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -37855,25 +30717,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string nv_index_bytes;
- rc = Serialize_TPMI_RH_NV_INDEX(
- nv_index,
- &nv_index_bytes);
+ rc = Serialize_TPMI_RH_NV_INDEX(nv_index, &nv_index_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(nv_index_name.data(),
- nv_index_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(nv_index_name.data(), nv_index_name.size());
handle_section_bytes += nv_index_bytes;
command_size += nv_index_bytes.size();
std::string command_hash(32, 0);
@@ -37882,10 +30738,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -37896,31 +30751,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -37928,38 +30775,29 @@
}
TPM_RC Tpm::ParseResponse_NV_ReadPublic(
- const std::string& response,
- TPM2B_NV_PUBLIC* nv_public,
- TPM2B_NAME* nv_name,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_NV_PUBLIC* nv_public,
+ TPM2B_NAME* nv_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -37971,9 +30809,7 @@
}
TPM_CC command_code = TPM_CC_NV_ReadPublic;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -37991,37 +30827,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string nv_public_bytes;
- rc = Parse_TPM2B_NV_PUBLIC(
- &buffer,
- nv_public,
- &nv_public_bytes);
+ rc = Parse_TPM2B_NV_PUBLIC(&buffer, nv_public, &nv_public_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string nv_name_bytes;
- rc = Parse_TPM2B_NAME(
- &buffer,
- nv_name,
- &nv_name_bytes);
+ rc = Parse_TPM2B_NAME(&buffer, nv_name, &nv_name_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -38033,10 +30859,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
nv_public_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_NV_PUBLIC(
- &nv_public_bytes,
- nv_public,
- nullptr);
+ rc = Parse_TPM2B_NV_PUBLIC(&nv_public_bytes, nv_public, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -38044,57 +30867,41 @@
return TPM_RC_SUCCESS;
}
-void NV_ReadPublicErrorCallback(
- const Tpm::NV_ReadPublicResponse& callback,
- TPM_RC response_code) {
+void NV_ReadPublicErrorCallback(const Tpm::NV_ReadPublicResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_NV_PUBLIC(),
- TPM2B_NAME());
+ callback.Run(response_code, TPM2B_NV_PUBLIC(), TPM2B_NAME());
}
-void NV_ReadPublicResponseParser(
- const Tpm::NV_ReadPublicResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void NV_ReadPublicResponseParser(const Tpm::NV_ReadPublicResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_ReadPublicErrorCallback, callback);
TPM2B_NV_PUBLIC nv_public;
TPM2B_NAME nv_name;
- TPM_RC rc = Tpm::ParseResponse_NV_ReadPublic(
- response,
- &nv_public,
- &nv_name,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_NV_ReadPublic(response, &nv_public, &nv_name,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- nv_public,
- nv_name);
+ callback.Run(rc, nv_public, nv_name);
}
-void Tpm::NV_ReadPublic(
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_ReadPublicResponse& callback) {
+void Tpm::NV_ReadPublic(const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_ReadPublicResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_ReadPublicErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(NV_ReadPublicResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(NV_ReadPublicResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_NV_ReadPublic(
- nv_index,
- nv_index_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_ReadPublic(nv_index, nv_index_name, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -38102,40 +30909,33 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::NV_ReadPublicSync(
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- TPM2B_NV_PUBLIC* nv_public,
- TPM2B_NAME* nv_name,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::NV_ReadPublicSync(const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ TPM2B_NV_PUBLIC* nv_public,
+ TPM2B_NAME* nv_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_NV_ReadPublic(
- nv_index,
- nv_index_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_ReadPublic(nv_index, nv_index_name, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_NV_ReadPublic(
- response,
- nv_public,
- nv_name,
- authorization_delegate);
+ rc = ParseResponse_NV_ReadPublic(response, nv_public, nv_name,
+ authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_NV_Write(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_MAX_NV_BUFFER& data,
- const UINT16& offset,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_MAX_NV_BUFFER& data,
+ const UINT16& offset,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -38146,37 +30946,27 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_NV_AUTH(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_NV_AUTH(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string nv_index_bytes;
- rc = Serialize_TPMI_RH_NV_INDEX(
- nv_index,
- &nv_index_bytes);
+ rc = Serialize_TPMI_RH_NV_INDEX(nv_index, &nv_index_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string data_bytes;
- rc = Serialize_TPM2B_MAX_NV_BUFFER(
- data,
- &data_bytes);
+ rc = Serialize_TPM2B_MAX_NV_BUFFER(data, &data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string offset_bytes;
- rc = Serialize_UINT16(
- offset,
- &offset_bytes);
+ rc = Serialize_UINT16(offset, &offset_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -38188,24 +30978,19 @@
}
data_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
- hash->Update(nv_index_name.data(),
- nv_index_name.size());
+ hash->Update(nv_index_name.data(), nv_index_name.size());
handle_section_bytes += nv_index_bytes;
command_size += nv_index_bytes.size();
- hash->Update(data_bytes.data(),
- data_bytes.size());
+ hash->Update(data_bytes.data(), data_bytes.size());
parameter_section_bytes += data_bytes;
command_size += data_bytes.size();
- hash->Update(offset_bytes.data(),
- offset_bytes.size());
+ hash->Update(offset_bytes.data(), offset_bytes.size());
parameter_section_bytes += offset_bytes;
command_size += offset_bytes.size();
std::string command_hash(32, 0);
@@ -38214,10 +30999,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -38228,31 +31012,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -38260,36 +31036,27 @@
}
TPM_RC Tpm::ParseResponse_NV_Write(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -38301,9 +31068,7 @@
}
TPM_CC command_code = TPM_CC_NV_Write;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -38321,78 +31086,60 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void NV_WriteErrorCallback(
- const Tpm::NV_WriteResponse& callback,
- TPM_RC response_code) {
+void NV_WriteErrorCallback(const Tpm::NV_WriteResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void NV_WriteResponseParser(
- const Tpm::NV_WriteResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void NV_WriteResponseParser(const Tpm::NV_WriteResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_WriteErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_NV_Write(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_NV_Write(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::NV_Write(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_MAX_NV_BUFFER& data,
- const UINT16& offset,
- AuthorizationDelegate* authorization_delegate,
- const NV_WriteResponse& callback) {
+void Tpm::NV_Write(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_MAX_NV_BUFFER& data,
+ const UINT16& offset,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_WriteResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_WriteErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(NV_WriteResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(NV_WriteResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_NV_Write(
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- data,
- offset,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_Write(auth_handle, auth_handle_name, nv_index,
+ nv_index_name, data, offset, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -38400,42 +31147,33 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::NV_WriteSync(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_MAX_NV_BUFFER& data,
- const UINT16& offset,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::NV_WriteSync(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_MAX_NV_BUFFER& data,
+ const UINT16& offset,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_NV_Write(
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- data,
- offset,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_Write(auth_handle, auth_handle_name, nv_index,
+ nv_index_name, data, offset, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_NV_Write(
- response,
- authorization_delegate);
+ rc = ParseResponse_NV_Write(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_NV_Increment(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -38446,36 +31184,27 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_NV_AUTH(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_NV_AUTH(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string nv_index_bytes;
- rc = Serialize_TPMI_RH_NV_INDEX(
- nv_index,
- &nv_index_bytes);
+ rc = Serialize_TPMI_RH_NV_INDEX(nv_index, &nv_index_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
- hash->Update(nv_index_name.data(),
- nv_index_name.size());
+ hash->Update(nv_index_name.data(), nv_index_name.size());
handle_section_bytes += nv_index_bytes;
command_size += nv_index_bytes.size();
std::string command_hash(32, 0);
@@ -38484,10 +31213,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -38498,31 +31226,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -38530,36 +31250,27 @@
}
TPM_RC Tpm::ParseResponse_NV_Increment(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -38571,9 +31282,7 @@
}
TPM_CC command_code = TPM_CC_NV_Increment;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -38591,74 +31300,58 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void NV_IncrementErrorCallback(
- const Tpm::NV_IncrementResponse& callback,
- TPM_RC response_code) {
+void NV_IncrementErrorCallback(const Tpm::NV_IncrementResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void NV_IncrementResponseParser(
- const Tpm::NV_IncrementResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void NV_IncrementResponseParser(const Tpm::NV_IncrementResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_IncrementErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_NV_Increment(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_NV_Increment(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::NV_Increment(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_IncrementResponse& callback) {
+void Tpm::NV_Increment(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_IncrementResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_IncrementErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(NV_IncrementResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(NV_IncrementResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_NV_Increment(
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_Increment(auth_handle, auth_handle_name,
+ nv_index, nv_index_name, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -38666,39 +31359,32 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::NV_IncrementSync(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::NV_IncrementSync(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_NV_Increment(
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_Increment(auth_handle, auth_handle_name,
+ nv_index, nv_index_name, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_NV_Increment(
- response,
- authorization_delegate);
+ rc = ParseResponse_NV_Increment(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_NV_Extend(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_MAX_NV_BUFFER& data,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_MAX_NV_BUFFER& data,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -38709,30 +31395,22 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_NV_AUTH(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_NV_AUTH(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string nv_index_bytes;
- rc = Serialize_TPMI_RH_NV_INDEX(
- nv_index,
- &nv_index_bytes);
+ rc = Serialize_TPMI_RH_NV_INDEX(nv_index, &nv_index_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string data_bytes;
- rc = Serialize_TPM2B_MAX_NV_BUFFER(
- data,
- &data_bytes);
+ rc = Serialize_TPM2B_MAX_NV_BUFFER(data, &data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -38744,20 +31422,16 @@
}
data_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
- hash->Update(nv_index_name.data(),
- nv_index_name.size());
+ hash->Update(nv_index_name.data(), nv_index_name.size());
handle_section_bytes += nv_index_bytes;
command_size += nv_index_bytes.size();
- hash->Update(data_bytes.data(),
- data_bytes.size());
+ hash->Update(data_bytes.data(), data_bytes.size());
parameter_section_bytes += data_bytes;
command_size += data_bytes.size();
std::string command_hash(32, 0);
@@ -38766,10 +31440,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -38780,31 +31453,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -38812,36 +31477,27 @@
}
TPM_RC Tpm::ParseResponse_NV_Extend(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -38853,9 +31509,7 @@
}
TPM_CC command_code = TPM_CC_NV_Extend;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -38873,76 +31527,59 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void NV_ExtendErrorCallback(
- const Tpm::NV_ExtendResponse& callback,
- TPM_RC response_code) {
+void NV_ExtendErrorCallback(const Tpm::NV_ExtendResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void NV_ExtendResponseParser(
- const Tpm::NV_ExtendResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void NV_ExtendResponseParser(const Tpm::NV_ExtendResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_ExtendErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_NV_Extend(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_NV_Extend(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::NV_Extend(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_MAX_NV_BUFFER& data,
- AuthorizationDelegate* authorization_delegate,
- const NV_ExtendResponse& callback) {
+void Tpm::NV_Extend(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_MAX_NV_BUFFER& data,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_ExtendResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_ExtendErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(NV_ExtendResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(NV_ExtendResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_NV_Extend(
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- data,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_Extend(auth_handle, auth_handle_name,
+ nv_index, nv_index_name, data,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -38950,41 +31587,33 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::NV_ExtendSync(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_MAX_NV_BUFFER& data,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::NV_ExtendSync(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_MAX_NV_BUFFER& data,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_NV_Extend(
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- data,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_Extend(auth_handle, auth_handle_name,
+ nv_index, nv_index_name, data,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_NV_Extend(
- response,
- authorization_delegate);
+ rc = ParseResponse_NV_Extend(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_NV_SetBits(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const UINT64& bits,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const UINT64& bits,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -38995,47 +31624,35 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_NV_AUTH(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_NV_AUTH(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string nv_index_bytes;
- rc = Serialize_TPMI_RH_NV_INDEX(
- nv_index,
- &nv_index_bytes);
+ rc = Serialize_TPMI_RH_NV_INDEX(nv_index, &nv_index_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string bits_bytes;
- rc = Serialize_UINT64(
- bits,
- &bits_bytes);
+ rc = Serialize_UINT64(bits, &bits_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
- hash->Update(nv_index_name.data(),
- nv_index_name.size());
+ hash->Update(nv_index_name.data(), nv_index_name.size());
handle_section_bytes += nv_index_bytes;
command_size += nv_index_bytes.size();
- hash->Update(bits_bytes.data(),
- bits_bytes.size());
+ hash->Update(bits_bytes.data(), bits_bytes.size());
parameter_section_bytes += bits_bytes;
command_size += bits_bytes.size();
std::string command_hash(32, 0);
@@ -39044,10 +31661,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -39058,31 +31674,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -39090,36 +31698,27 @@
}
TPM_RC Tpm::ParseResponse_NV_SetBits(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -39131,9 +31730,7 @@
}
TPM_CC command_code = TPM_CC_NV_SetBits;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -39151,76 +31748,59 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void NV_SetBitsErrorCallback(
- const Tpm::NV_SetBitsResponse& callback,
- TPM_RC response_code) {
+void NV_SetBitsErrorCallback(const Tpm::NV_SetBitsResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void NV_SetBitsResponseParser(
- const Tpm::NV_SetBitsResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void NV_SetBitsResponseParser(const Tpm::NV_SetBitsResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_SetBitsErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_NV_SetBits(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_NV_SetBits(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::NV_SetBits(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const UINT64& bits,
- AuthorizationDelegate* authorization_delegate,
- const NV_SetBitsResponse& callback) {
+void Tpm::NV_SetBits(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const UINT64& bits,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_SetBitsResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_SetBitsErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(NV_SetBitsResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(NV_SetBitsResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_NV_SetBits(
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- bits,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_SetBits(auth_handle, auth_handle_name,
+ nv_index, nv_index_name, bits,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -39228,40 +31808,32 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::NV_SetBitsSync(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const UINT64& bits,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::NV_SetBitsSync(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const UINT64& bits,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_NV_SetBits(
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- bits,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_SetBits(auth_handle, auth_handle_name,
+ nv_index, nv_index_name, bits,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_NV_SetBits(
- response,
- authorization_delegate);
+ rc = ParseResponse_NV_SetBits(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_NV_WriteLock(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -39272,36 +31844,27 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_NV_AUTH(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_NV_AUTH(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string nv_index_bytes;
- rc = Serialize_TPMI_RH_NV_INDEX(
- nv_index,
- &nv_index_bytes);
+ rc = Serialize_TPMI_RH_NV_INDEX(nv_index, &nv_index_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
- hash->Update(nv_index_name.data(),
- nv_index_name.size());
+ hash->Update(nv_index_name.data(), nv_index_name.size());
handle_section_bytes += nv_index_bytes;
command_size += nv_index_bytes.size();
std::string command_hash(32, 0);
@@ -39310,10 +31873,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -39324,31 +31886,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -39356,36 +31910,27 @@
}
TPM_RC Tpm::ParseResponse_NV_WriteLock(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -39397,9 +31942,7 @@
}
TPM_CC command_code = TPM_CC_NV_WriteLock;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -39417,74 +31960,58 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void NV_WriteLockErrorCallback(
- const Tpm::NV_WriteLockResponse& callback,
- TPM_RC response_code) {
+void NV_WriteLockErrorCallback(const Tpm::NV_WriteLockResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void NV_WriteLockResponseParser(
- const Tpm::NV_WriteLockResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void NV_WriteLockResponseParser(const Tpm::NV_WriteLockResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_WriteLockErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_NV_WriteLock(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_NV_WriteLock(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::NV_WriteLock(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_WriteLockResponse& callback) {
+void Tpm::NV_WriteLock(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_WriteLockResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_WriteLockErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(NV_WriteLockResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(NV_WriteLockResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_NV_WriteLock(
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_WriteLock(auth_handle, auth_handle_name,
+ nv_index, nv_index_name, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -39492,36 +32019,29 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::NV_WriteLockSync(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::NV_WriteLockSync(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_NV_WriteLock(
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_WriteLock(auth_handle, auth_handle_name,
+ nv_index, nv_index_name, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_NV_WriteLock(
- response,
- authorization_delegate);
+ rc = ParseResponse_NV_WriteLock(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_NV_GlobalWriteLock(
- const TPMI_RH_PROVISION& auth_handle,
- const std::string& auth_handle_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PROVISION& auth_handle,
+ const std::string& auth_handle_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -39532,25 +32052,19 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_PROVISION(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_PROVISION(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
std::string command_hash(32, 0);
@@ -39559,10 +32073,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -39573,31 +32086,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -39605,36 +32110,27 @@
}
TPM_RC Tpm::ParseResponse_NV_GlobalWriteLock(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -39646,9 +32142,7 @@
}
TPM_CC command_code = TPM_CC_NV_GlobalWriteLock;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -39666,21 +32160,17 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
@@ -39701,35 +32191,27 @@
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_GlobalWriteLockErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_NV_GlobalWriteLock(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_NV_GlobalWriteLock(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::NV_GlobalWriteLock(
- const TPMI_RH_PROVISION& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_GlobalWriteLockResponse& callback) {
+void Tpm::NV_GlobalWriteLock(const TPMI_RH_PROVISION& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_GlobalWriteLockResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_GlobalWriteLockErrorCallback, callback);
- base::Callback<void(const std::string&)> parser =
- base::Bind(NV_GlobalWriteLockResponseParser,
- callback,
- authorization_delegate);
+ base::Callback<void(const std::string&)> parser = base::Bind(
+ NV_GlobalWriteLockResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_NV_GlobalWriteLock(
- auth_handle,
- auth_handle_name,
- &command,
- authorization_delegate);
+ auth_handle, auth_handle_name, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -39738,35 +32220,30 @@
}
TPM_RC Tpm::NV_GlobalWriteLockSync(
- const TPMI_RH_PROVISION& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_PROVISION& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_NV_GlobalWriteLock(
- auth_handle,
- auth_handle_name,
- &command,
- authorization_delegate);
+ auth_handle, auth_handle_name, &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_NV_GlobalWriteLock(
- response,
- authorization_delegate);
+ rc = ParseResponse_NV_GlobalWriteLock(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_NV_Read(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const UINT16& size,
- const UINT16& offset,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const UINT16& size,
+ const UINT16& offset,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -39777,58 +32254,43 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_NV_AUTH(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_NV_AUTH(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string nv_index_bytes;
- rc = Serialize_TPMI_RH_NV_INDEX(
- nv_index,
- &nv_index_bytes);
+ rc = Serialize_TPMI_RH_NV_INDEX(nv_index, &nv_index_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string size_bytes;
- rc = Serialize_UINT16(
- size,
- &size_bytes);
+ rc = Serialize_UINT16(size, &size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string offset_bytes;
- rc = Serialize_UINT16(
- offset,
- &offset_bytes);
+ rc = Serialize_UINT16(offset, &offset_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
- hash->Update(nv_index_name.data(),
- nv_index_name.size());
+ hash->Update(nv_index_name.data(), nv_index_name.size());
handle_section_bytes += nv_index_bytes;
command_size += nv_index_bytes.size();
- hash->Update(size_bytes.data(),
- size_bytes.size());
+ hash->Update(size_bytes.data(), size_bytes.size());
parameter_section_bytes += size_bytes;
command_size += size_bytes.size();
- hash->Update(offset_bytes.data(),
- offset_bytes.size());
+ hash->Update(offset_bytes.data(), offset_bytes.size());
parameter_section_bytes += offset_bytes;
command_size += offset_bytes.size();
std::string command_hash(32, 0);
@@ -39837,10 +32299,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -39851,31 +32312,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -39883,37 +32336,28 @@
}
TPM_RC Tpm::ParseResponse_NV_Read(
- const std::string& response,
- TPM2B_MAX_NV_BUFFER* data,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_MAX_NV_BUFFER* data,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -39925,9 +32369,7 @@
}
TPM_CC command_code = TPM_CC_NV_Read;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -39945,29 +32387,22 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string data_bytes;
- rc = Parse_TPM2B_MAX_NV_BUFFER(
- &buffer,
- data,
- &data_bytes);
+ rc = Parse_TPM2B_MAX_NV_BUFFER(&buffer, data, &data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -39979,10 +32414,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
data_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_MAX_NV_BUFFER(
- &data_bytes,
- data,
- nullptr);
+ rc = Parse_TPM2B_MAX_NV_BUFFER(&data_bytes, data, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -39990,61 +32422,45 @@
return TPM_RC_SUCCESS;
}
-void NV_ReadErrorCallback(
- const Tpm::NV_ReadResponse& callback,
- TPM_RC response_code) {
+void NV_ReadErrorCallback(const Tpm::NV_ReadResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_MAX_NV_BUFFER());
+ callback.Run(response_code, TPM2B_MAX_NV_BUFFER());
}
-void NV_ReadResponseParser(
- const Tpm::NV_ReadResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void NV_ReadResponseParser(const Tpm::NV_ReadResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_ReadErrorCallback, callback);
TPM2B_MAX_NV_BUFFER data;
- TPM_RC rc = Tpm::ParseResponse_NV_Read(
- response,
- &data,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_NV_Read(response, &data, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- data);
+ callback.Run(rc, data);
}
-void Tpm::NV_Read(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const UINT16& size,
- const UINT16& offset,
- AuthorizationDelegate* authorization_delegate,
- const NV_ReadResponse& callback) {
+void Tpm::NV_Read(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const UINT16& size,
+ const UINT16& offset,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_ReadResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_ReadErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(NV_ReadResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(NV_ReadResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_NV_Read(
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- size,
- offset,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_Read(auth_handle, auth_handle_name, nv_index,
+ nv_index_name, size, offset, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -40052,44 +32468,34 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::NV_ReadSync(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const UINT16& size,
- const UINT16& offset,
- TPM2B_MAX_NV_BUFFER* data,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::NV_ReadSync(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const UINT16& size,
+ const UINT16& offset,
+ TPM2B_MAX_NV_BUFFER* data,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_NV_Read(
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- size,
- offset,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_Read(auth_handle, auth_handle_name, nv_index,
+ nv_index_name, size, offset, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_NV_Read(
- response,
- data,
- authorization_delegate);
+ rc = ParseResponse_NV_Read(response, data, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_NV_ReadLock(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -40100,36 +32506,27 @@
bool is_command_parameter_encryption_possible = false;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_NV_AUTH(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_NV_AUTH(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string nv_index_bytes;
- rc = Serialize_TPMI_RH_NV_INDEX(
- nv_index,
- &nv_index_bytes);
+ rc = Serialize_TPMI_RH_NV_INDEX(nv_index, &nv_index_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
- hash->Update(nv_index_name.data(),
- nv_index_name.size());
+ hash->Update(nv_index_name.data(), nv_index_name.size());
handle_section_bytes += nv_index_bytes;
command_size += nv_index_bytes.size();
std::string command_hash(32, 0);
@@ -40138,10 +32535,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -40152,31 +32548,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -40184,36 +32572,27 @@
}
TPM_RC Tpm::ParseResponse_NV_ReadLock(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -40225,9 +32604,7 @@
}
TPM_CC command_code = TPM_CC_NV_ReadLock;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -40245,74 +32622,58 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void NV_ReadLockErrorCallback(
- const Tpm::NV_ReadLockResponse& callback,
- TPM_RC response_code) {
+void NV_ReadLockErrorCallback(const Tpm::NV_ReadLockResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void NV_ReadLockResponseParser(
- const Tpm::NV_ReadLockResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void NV_ReadLockResponseParser(const Tpm::NV_ReadLockResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_ReadLockErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_NV_ReadLock(
- response,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_NV_ReadLock(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::NV_ReadLock(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_ReadLockResponse& callback) {
+void Tpm::NV_ReadLock(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_ReadLockResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_ReadLockErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(NV_ReadLockResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(NV_ReadLockResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_NV_ReadLock(
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_ReadLock(auth_handle, auth_handle_name,
+ nv_index, nv_index_name, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -40320,37 +32681,30 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::NV_ReadLockSync(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::NV_ReadLockSync(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_NV_ReadLock(
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_ReadLock(auth_handle, auth_handle_name,
+ nv_index, nv_index_name, &command,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_NV_ReadLock(
- response,
- authorization_delegate);
+ rc = ParseResponse_NV_ReadLock(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_NV_ChangeAuth(
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_AUTH& new_auth,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_AUTH& new_auth,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -40361,23 +32715,17 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = false;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string nv_index_bytes;
- rc = Serialize_TPMI_RH_NV_INDEX(
- nv_index,
- &nv_index_bytes);
+ rc = Serialize_TPMI_RH_NV_INDEX(nv_index, &nv_index_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string new_auth_bytes;
- rc = Serialize_TPM2B_AUTH(
- new_auth,
- &new_auth_bytes);
+ rc = Serialize_TPM2B_AUTH(new_auth, &new_auth_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -40389,16 +32737,13 @@
}
new_auth_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(nv_index_name.data(),
- nv_index_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(nv_index_name.data(), nv_index_name.size());
handle_section_bytes += nv_index_bytes;
command_size += nv_index_bytes.size();
- hash->Update(new_auth_bytes.data(),
- new_auth_bytes.size());
+ hash->Update(new_auth_bytes.data(), new_auth_bytes.size());
parameter_section_bytes += new_auth_bytes;
command_size += new_auth_bytes.size();
std::string command_hash(32, 0);
@@ -40407,10 +32752,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -40421,31 +32765,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -40453,36 +32789,27 @@
}
TPM_RC Tpm::ParseResponse_NV_ChangeAuth(
- const std::string& response,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -40494,9 +32821,7 @@
}
TPM_CC command_code = TPM_CC_NV_ChangeAuth;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -40514,72 +32839,57 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
return TPM_RC_SUCCESS;
}
-void NV_ChangeAuthErrorCallback(
- const Tpm::NV_ChangeAuthResponse& callback,
- TPM_RC response_code) {
+void NV_ChangeAuthErrorCallback(const Tpm::NV_ChangeAuthResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
callback.Run(response_code);
}
-void NV_ChangeAuthResponseParser(
- const Tpm::NV_ChangeAuthResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void NV_ChangeAuthResponseParser(const Tpm::NV_ChangeAuthResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_ChangeAuthErrorCallback, callback);
- TPM_RC rc = Tpm::ParseResponse_NV_ChangeAuth(
- response,
- authorization_delegate);
+ TPM_RC rc =
+ Tpm::ParseResponse_NV_ChangeAuth(response, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc);
+ callback.Run(rc);
}
-void Tpm::NV_ChangeAuth(
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_AUTH& new_auth,
- AuthorizationDelegate* authorization_delegate,
- const NV_ChangeAuthResponse& callback) {
+void Tpm::NV_ChangeAuth(const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_AUTH& new_auth,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_ChangeAuthResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_ChangeAuthErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(NV_ChangeAuthResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(NV_ChangeAuthResponseParser, callback, authorization_delegate);
std::string command;
- TPM_RC rc = SerializeCommand_NV_ChangeAuth(
- nv_index,
- nv_index_name,
- new_auth,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_ChangeAuth(nv_index, nv_index_name, new_auth,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
@@ -40587,42 +32897,35 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::NV_ChangeAuthSync(
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_AUTH& new_auth,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::NV_ChangeAuthSync(const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_AUTH& new_auth,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
- TPM_RC rc = SerializeCommand_NV_ChangeAuth(
- nv_index,
- nv_index_name,
- new_auth,
- &command,
- authorization_delegate);
+ TPM_RC rc = SerializeCommand_NV_ChangeAuth(nv_index, nv_index_name, new_auth,
+ &command, authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_NV_ChangeAuth(
- response,
- authorization_delegate);
+ rc = ParseResponse_NV_ChangeAuth(response, authorization_delegate);
return rc;
}
TPM_RC Tpm::SerializeCommand_NV_Certify(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- const UINT16& size,
- const UINT16& offset,
- std::string* serialized_command,
- AuthorizationDelegate* authorization_delegate) {
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const UINT16& size,
+ const UINT16& offset,
+ std::string* serialized_command,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;
@@ -40633,58 +32936,42 @@
bool is_command_parameter_encryption_possible = true;
bool is_response_parameter_encryption_possible = true;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string sign_handle_bytes;
- rc = Serialize_TPMI_DH_OBJECT(
- sign_handle,
- &sign_handle_bytes);
+ rc = Serialize_TPMI_DH_OBJECT(sign_handle, &sign_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string auth_handle_bytes;
- rc = Serialize_TPMI_RH_NV_AUTH(
- auth_handle,
- &auth_handle_bytes);
+ rc = Serialize_TPMI_RH_NV_AUTH(auth_handle, &auth_handle_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string nv_index_bytes;
- rc = Serialize_TPMI_RH_NV_INDEX(
- nv_index,
- &nv_index_bytes);
+ rc = Serialize_TPMI_RH_NV_INDEX(nv_index, &nv_index_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string qualifying_data_bytes;
- rc = Serialize_TPM2B_DATA(
- qualifying_data,
- &qualifying_data_bytes);
+ rc = Serialize_TPM2B_DATA(qualifying_data, &qualifying_data_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string in_scheme_bytes;
- rc = Serialize_TPMT_SIG_SCHEME(
- in_scheme,
- &in_scheme_bytes);
+ rc = Serialize_TPMT_SIG_SCHEME(in_scheme, &in_scheme_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string size_bytes;
- rc = Serialize_UINT16(
- size,
- &size_bytes);
+ rc = Serialize_UINT16(size, &size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string offset_bytes;
- rc = Serialize_UINT16(
- offset,
- &offset_bytes);
+ rc = Serialize_UINT16(offset, &offset_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -40696,36 +32983,28 @@
}
qualifying_data_bytes.replace(2, std::string::npos, tmp);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(sign_handle_name.data(),
- sign_handle_name.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(sign_handle_name.data(), sign_handle_name.size());
handle_section_bytes += sign_handle_bytes;
command_size += sign_handle_bytes.size();
- hash->Update(auth_handle_name.data(),
- auth_handle_name.size());
+ hash->Update(auth_handle_name.data(), auth_handle_name.size());
handle_section_bytes += auth_handle_bytes;
command_size += auth_handle_bytes.size();
- hash->Update(nv_index_name.data(),
- nv_index_name.size());
+ hash->Update(nv_index_name.data(), nv_index_name.size());
handle_section_bytes += nv_index_bytes;
command_size += nv_index_bytes.size();
- hash->Update(qualifying_data_bytes.data(),
- qualifying_data_bytes.size());
+ hash->Update(qualifying_data_bytes.data(), qualifying_data_bytes.size());
parameter_section_bytes += qualifying_data_bytes;
command_size += qualifying_data_bytes.size();
- hash->Update(in_scheme_bytes.data(),
- in_scheme_bytes.size());
+ hash->Update(in_scheme_bytes.data(), in_scheme_bytes.size());
parameter_section_bytes += in_scheme_bytes;
command_size += in_scheme_bytes.size();
- hash->Update(size_bytes.data(),
- size_bytes.size());
+ hash->Update(size_bytes.data(), size_bytes.size());
parameter_section_bytes += size_bytes;
command_size += size_bytes.size();
- hash->Update(offset_bytes.data(),
- offset_bytes.size());
+ hash->Update(offset_bytes.data(), offset_bytes.size());
parameter_section_bytes += offset_bytes;
command_size += offset_bytes.size();
std::string command_hash(32, 0);
@@ -40734,10 +33013,9 @@
std::string authorization_size_bytes;
if (authorization_delegate) {
if (!authorization_delegate->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- &authorization_section_bytes)) {
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible,
+ &authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
if (!authorization_section_bytes.empty()) {
@@ -40748,31 +33026,23 @@
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- command_size += authorization_size_bytes.size() +
- authorization_section_bytes.size();
+ command_size +=
+ authorization_size_bytes.size() + authorization_section_bytes.size();
}
}
std::string tag_bytes;
- rc = Serialize_TPMI_ST_COMMAND_TAG(
- tag,
- &tag_bytes);
+ rc = Serialize_TPMI_ST_COMMAND_TAG(tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string command_size_bytes;
- rc = Serialize_UINT32(
- command_size,
- &command_size_bytes);
+ rc = Serialize_UINT32(command_size, &command_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
- *serialized_command = tag_bytes +
- command_size_bytes +
- command_code_bytes +
- handle_section_bytes +
- authorization_size_bytes +
- authorization_section_bytes +
- parameter_section_bytes;
+ *serialized_command = tag_bytes + command_size_bytes + command_code_bytes +
+ handle_section_bytes + authorization_size_bytes +
+ authorization_section_bytes + parameter_section_bytes;
CHECK(serialized_command->size() == command_size) << "Command size mismatch!";
VLOG(2) << "Command: " << base::HexEncode(serialized_command->data(),
serialized_command->size());
@@ -40780,38 +33050,29 @@
}
TPM_RC Tpm::ParseResponse_NV_Certify(
- const std::string& response,
- TPM2B_ATTEST* certify_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate) {
+ const std::string& response,
+ TPM2B_ATTEST* certify_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(3) << __func__;
VLOG(2) << "Response: " << base::HexEncode(response.data(), response.size());
TPM_RC rc = TPM_RC_SUCCESS;
std::string buffer(response);
TPM_ST tag;
std::string tag_bytes;
- rc = Parse_TPM_ST(
- &buffer,
- &tag,
- &tag_bytes);
+ rc = Parse_TPM_ST(&buffer, &tag, &tag_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
UINT32 response_size;
std::string response_size_bytes;
- rc = Parse_UINT32(
- &buffer,
- &response_size,
- &response_size_bytes);
+ rc = Parse_UINT32(&buffer, &response_size, &response_size_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
TPM_RC response_code;
std::string response_code_bytes;
- rc = Parse_TPM_RC(
- &buffer,
- &response_code,
- &response_code_bytes);
+ rc = Parse_TPM_RC(&buffer, &response_code, &response_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -40823,9 +33084,7 @@
}
TPM_CC command_code = TPM_CC_NV_Certify;
std::string command_code_bytes;
- rc = Serialize_TPM_CC(
- command_code,
- &command_code_bytes);
+ rc = Serialize_TPM_CC(command_code, &command_code_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -40843,37 +33102,27 @@
// Keep the parameter section in |buffer|.
buffer.erase(parameter_section_size);
}
- scoped_ptr<crypto::SecureHash> hash(crypto::SecureHash::Create(
- crypto::SecureHash::SHA256));
- hash->Update(response_code_bytes.data(),
- response_code_bytes.size());
- hash->Update(command_code_bytes.data(),
- command_code_bytes.size());
- hash->Update(buffer.data(),
- buffer.size());
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(response_code_bytes.data(), response_code_bytes.size());
+ hash->Update(command_code_bytes.data(), command_code_bytes.size());
+ hash->Update(buffer.data(), buffer.size());
std::string response_hash(32, 0);
hash->Finish(string_as_array(&response_hash), response_hash.size());
if (tag == TPM_ST_SESSIONS) {
CHECK(authorization_delegate) << "Authorization delegate missing!";
if (!authorization_delegate->CheckResponseAuthorization(
- response_hash,
- authorization_section_bytes)) {
+ response_hash, authorization_section_bytes)) {
return TRUNKS_RC_AUTHORIZATION_FAILED;
}
}
std::string certify_info_bytes;
- rc = Parse_TPM2B_ATTEST(
- &buffer,
- certify_info,
- &certify_info_bytes);
+ rc = Parse_TPM2B_ATTEST(&buffer, certify_info, &certify_info_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string signature_bytes;
- rc = Parse_TPMT_SIGNATURE(
- &buffer,
- signature,
- &signature_bytes);
+ rc = Parse_TPMT_SIGNATURE(&buffer, signature, &signature_bytes);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -40885,10 +33134,7 @@
return TRUNKS_RC_ENCRYPTION_FAILED;
}
certify_info_bytes.replace(2, std::string::npos, tmp);
- rc = Parse_TPM2B_ATTEST(
- &certify_info_bytes,
- certify_info,
- nullptr);
+ rc = Parse_TPM2B_ATTEST(&certify_info_bytes, certify_info, nullptr);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
@@ -40896,72 +33142,50 @@
return TPM_RC_SUCCESS;
}
-void NV_CertifyErrorCallback(
- const Tpm::NV_CertifyResponse& callback,
- TPM_RC response_code) {
+void NV_CertifyErrorCallback(const Tpm::NV_CertifyResponse& callback,
+ TPM_RC response_code) {
VLOG(1) << __func__;
- callback.Run(response_code,
- TPM2B_ATTEST(),
- TPMT_SIGNATURE());
+ callback.Run(response_code, TPM2B_ATTEST(), TPMT_SIGNATURE());
}
-void NV_CertifyResponseParser(
- const Tpm::NV_CertifyResponse& callback,
- AuthorizationDelegate* authorization_delegate,
- const std::string& response) {
+void NV_CertifyResponseParser(const Tpm::NV_CertifyResponse& callback,
+ AuthorizationDelegate* authorization_delegate,
+ const std::string& response) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_CertifyErrorCallback, callback);
TPM2B_ATTEST certify_info;
TPMT_SIGNATURE signature;
- TPM_RC rc = Tpm::ParseResponse_NV_Certify(
- response,
- &certify_info,
- &signature,
- authorization_delegate);
+ TPM_RC rc = Tpm::ParseResponse_NV_Certify(response, &certify_info, &signature,
+ authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
return;
}
- callback.Run(
- rc,
- certify_info,
- signature);
+ callback.Run(rc, certify_info, signature);
}
-void Tpm::NV_Certify(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- const UINT16& size,
- const UINT16& offset,
- AuthorizationDelegate* authorization_delegate,
- const NV_CertifyResponse& callback) {
+void Tpm::NV_Certify(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const UINT16& size,
+ const UINT16& offset,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_CertifyResponse& callback) {
VLOG(1) << __func__;
base::Callback<void(TPM_RC)> error_reporter =
base::Bind(NV_CertifyErrorCallback, callback);
base::Callback<void(const std::string&)> parser =
- base::Bind(NV_CertifyResponseParser,
- callback,
- authorization_delegate);
+ base::Bind(NV_CertifyResponseParser, callback, authorization_delegate);
std::string command;
TPM_RC rc = SerializeCommand_NV_Certify(
- sign_handle,
- sign_handle_name,
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- qualifying_data,
- in_scheme,
- size,
- offset,
- &command,
+ sign_handle, sign_handle_name, auth_handle, auth_handle_name, nv_index,
+ nv_index_name, qualifying_data, in_scheme, size, offset, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
error_reporter.Run(rc);
@@ -40970,44 +33194,31 @@
transceiver_->SendCommand(command, parser);
}
-TPM_RC Tpm::NV_CertifySync(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- const UINT16& size,
- const UINT16& offset,
- TPM2B_ATTEST* certify_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate) {
+TPM_RC Tpm::NV_CertifySync(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const UINT16& size,
+ const UINT16& offset,
+ TPM2B_ATTEST* certify_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate) {
VLOG(1) << __func__;
std::string command;
TPM_RC rc = SerializeCommand_NV_Certify(
- sign_handle,
- sign_handle_name,
- auth_handle,
- auth_handle_name,
- nv_index,
- nv_index_name,
- qualifying_data,
- in_scheme,
- size,
- offset,
- &command,
+ sign_handle, sign_handle_name, auth_handle, auth_handle_name, nv_index,
+ nv_index_name, qualifying_data, in_scheme, size, offset, &command,
authorization_delegate);
if (rc != TPM_RC_SUCCESS) {
return rc;
}
std::string response = transceiver_->SendCommandAndWait(command);
- rc = ParseResponse_NV_Certify(
- response,
- certify_info,
- signature,
- authorization_delegate);
+ rc = ParseResponse_NV_Certify(response, certify_info, signature,
+ authorization_delegate);
return rc;
}
diff --git a/trunks/tpm_generated.h b/trunks/tpm_generated.h
index df46844..1044692 100644
--- a/trunks/tpm_generated.h
+++ b/trunks/tpm_generated.h
@@ -41,7 +41,11 @@
#define SHA1_DER_SIZE 15
#endif
#if !defined(SHA1_DER)
-#define SHA1_DER {0x30,0x21,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x04,0x14}
+#define SHA1_DER \
+ { \
+ 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, \
+ 0x00, 0x04, 0x14 \
+ }
#endif
#if !defined(SHA256_DIGEST_SIZE)
#define SHA256_DIGEST_SIZE 32
@@ -53,7 +57,11 @@
#define SHA256_DER_SIZE 19
#endif
#if !defined(SHA256_DER)
-#define SHA256_DER {0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0x04,0x20}
+#define SHA256_DER \
+ { \
+ 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, \
+ 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20 \
+ }
#endif
#if !defined(SHA384_DIGEST_SIZE)
#define SHA384_DIGEST_SIZE 48
@@ -65,7 +73,11 @@
#define SHA384_DER_SIZE 19
#endif
#if !defined(SHA384_DER)
-#define SHA384_DER {0x30,0x41,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x02,0x05,0x00,0x04,0x30}
+#define SHA384_DER \
+ { \
+ 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, \
+ 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30 \
+ }
#endif
#if !defined(SHA512_DIGEST_SIZE)
#define SHA512_DIGEST_SIZE 64
@@ -77,7 +89,11 @@
#define SHA512_DER_SIZE 19
#endif
#if !defined(SHA512_DER)
-#define SHA512_DER {0x30,0x51,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x03,0x05,0x00,0x04,0x40}
+#define SHA512_DER \
+ { \
+ 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, \
+ 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40 \
+ }
#endif
#if !defined(SM3_256_DIGEST_SIZE)
#define SM3_256_DIGEST_SIZE 32
@@ -89,7 +105,11 @@
#define SM3_256_DER_SIZE 18
#endif
#if !defined(SM3_256_DER)
-#define SM3_256_DER {0x30,0x30,0x30,0x0c,0x06,0x08,0x2a,0x81,0x1c,0x81,0x45,0x01,0x83,0x11,0x05,0x00,0x04,0x20}
+#define SM3_256_DER \
+ { \
+ 0x30, 0x30, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x81, 0x1c, 0x81, 0x45, 0x01, \
+ 0x83, 0x11, 0x05, 0x00, 0x04, 0x20 \
+ }
#endif
#if !defined(MAX_SESSION_NUMBER)
#define MAX_SESSION_NUMBER 3
@@ -122,7 +142,8 @@
#define NO_AUTO_ALIGN NO
#endif
#if !defined(RSA_KEY_SIZES_BITS)
-#define RSA_KEY_SIZES_BITS {1024, 2048}
+#define RSA_KEY_SIZES_BITS \
+ { 1024, 2048 }
#endif
#if !defined(MAX_RSA_KEY_BITS)
#define MAX_RSA_KEY_BITS 2048
@@ -131,10 +152,12 @@
#define MAX_RSA_KEY_BYTES ((MAX_RSA_KEY_BITS + 7) / 8)
#endif
#if !defined(ECC_CURVES)
-#define ECC_CURVES {TPM_ECC_NIST_P256, TPM_ECC_BN_P256, TPM_ECC_SM2_P256}
+#define ECC_CURVES \
+ { TPM_ECC_NIST_P256, TPM_ECC_BN_P256, TPM_ECC_SM2_P256 }
#endif
#if !defined(ECC_KEY_SIZES_BITS)
-#define ECC_KEY_SIZES_BITS {256}
+#define ECC_KEY_SIZES_BITS \
+ { 256 }
#endif
#if !defined(MAX_ECC_KEY_BITS)
#define MAX_ECC_KEY_BITS 256
@@ -143,7 +166,8 @@
#define MAX_ECC_KEY_BYTES ((MAX_ECC_KEY_BITS + 7) / 8)
#endif
#if !defined(AES_KEY_SIZES_BITS)
-#define AES_KEY_SIZES_BITS {128}
+#define AES_KEY_SIZES_BITS \
+ { 128 }
#endif
#if !defined(MAX_AES_KEY_BITS)
#define MAX_AES_KEY_BITS 128
@@ -155,7 +179,8 @@
#define MAX_AES_KEY_BYTES ((MAX_AES_KEY_BITS + 7) / 8)
#endif
#if !defined(SM4_KEY_SIZES_BITS)
-#define SM4_KEY_SIZES_BITS {128}
+#define SM4_KEY_SIZES_BITS \
+ { 128 }
#endif
#if !defined(MAX_SM4_KEY_BITS)
#define MAX_SM4_KEY_BITS 128
@@ -224,10 +249,10 @@
#define MIN_EVICT_OBJECTS 2
#endif
#if !defined(PCR_SELECT_MIN)
-#define PCR_SELECT_MIN ((PLATFORM_PCR+7)/8)
+#define PCR_SELECT_MIN ((PLATFORM_PCR + 7) / 8)
#endif
#if !defined(PCR_SELECT_MAX)
-#define PCR_SELECT_MAX ((IMPLEMENTATION_PCR+7)/8)
+#define PCR_SELECT_MAX ((IMPLEMENTATION_PCR + 7) / 8)
#endif
#if !defined(NUM_POLICY_PCR_GROUP)
#define NUM_POLICY_PCR_GROUP 1
@@ -272,7 +297,7 @@
#define CONTEXT_ENCRYPT_KEY_BITS MAX_SYM_KEY_BITS
#endif
#if !defined(CONTEXT_ENCRYPT_KEY_BYTES)
-#define CONTEXT_ENCRYPT_KEY_BYTES ((CONTEXT_ENCRYPT_KEY_BITS+7)/8)
+#define CONTEXT_ENCRYPT_KEY_BYTES ((CONTEXT_ENCRYPT_KEY_BITS + 7) / 8)
#endif
#if !defined(CONTEXT_INTEGRITY_HASH_ALG)
#define CONTEXT_INTEGRITY_HASH_ALG TPM_ALG_SHA256
@@ -326,28 +351,29 @@
#define CRT_FORMAT_RSA YES
#endif
#if !defined(PRIVATE_VENDOR_SPECIFIC_BYTES)
-#define PRIVATE_VENDOR_SPECIFIC_BYTES ((MAX_RSA_KEY_BYTES/2) * (3 + CRT_FORMAT_RSA * 2))
+#define PRIVATE_VENDOR_SPECIFIC_BYTES \
+ ((MAX_RSA_KEY_BYTES / 2) * (3 + CRT_FORMAT_RSA * 2))
#endif
#if !defined(MAX_CAP_DATA)
-#define MAX_CAP_DATA (MAX_CAP_BUFFER-sizeof(TPM_CAP)-sizeof(UINT32))
+#define MAX_CAP_DATA (MAX_CAP_BUFFER - sizeof(TPM_CAP) - sizeof(UINT32))
#endif
#if !defined(MAX_CAP_ALGS)
#define MAX_CAP_ALGS (TPM_ALG_LAST - TPM_ALG_FIRST + 1)
#endif
#if !defined(MAX_CAP_HANDLES)
-#define MAX_CAP_HANDLES (MAX_CAP_DATA/sizeof(TPM_HANDLE))
+#define MAX_CAP_HANDLES (MAX_CAP_DATA / sizeof(TPM_HANDLE))
#endif
#if !defined(MAX_CAP_CC)
#define MAX_CAP_CC ((TPM_CC_LAST - TPM_CC_FIRST) + 1)
#endif
#if !defined(MAX_TPM_PROPERTIES)
-#define MAX_TPM_PROPERTIES (MAX_CAP_DATA/sizeof(TPMS_TAGGED_PROPERTY))
+#define MAX_TPM_PROPERTIES (MAX_CAP_DATA / sizeof(TPMS_TAGGED_PROPERTY))
#endif
#if !defined(MAX_PCR_PROPERTIES)
-#define MAX_PCR_PROPERTIES (MAX_CAP_DATA/sizeof(TPMS_TAGGED_PCR_SELECT))
+#define MAX_PCR_PROPERTIES (MAX_CAP_DATA / sizeof(TPMS_TAGGED_PCR_SELECT))
#endif
#if !defined(MAX_ECC_CURVES)
-#define MAX_ECC_CURVES (MAX_CAP_DATA/sizeof(TPM_ECC_CURVE))
+#define MAX_ECC_CURVES (MAX_CAP_DATA / sizeof(TPM_ECC_CURVE))
#endif
#if !defined(HASH_COUNT)
#define HASH_COUNT 3
@@ -926,16 +952,17 @@
const TPM_HC HR_NV_INDEX = (TPM_HT_NV_INDEX << HR_SHIFT);
const TPM_HC HR_PERMANENT = (TPM_HT_PERMANENT << HR_SHIFT);
const TPM_HC PCR_FIRST = (HR_PCR + 0);
-const TPM_HC PCR_LAST = (PCR_FIRST + IMPLEMENTATION_PCR-1);
+const TPM_HC PCR_LAST = (PCR_FIRST + IMPLEMENTATION_PCR - 1);
const TPM_HC HMAC_SESSION_FIRST = (HR_HMAC_SESSION + 0);
-const TPM_HC HMAC_SESSION_LAST = (HMAC_SESSION_FIRST+MAX_ACTIVE_SESSIONS-1);
+const TPM_HC HMAC_SESSION_LAST = (HMAC_SESSION_FIRST + MAX_ACTIVE_SESSIONS - 1);
const TPM_HC LOADED_SESSION_LAST = HMAC_SESSION_LAST;
const TPM_HC POLICY_SESSION_FIRST = (HR_POLICY_SESSION + 0);
-const TPM_HC POLICY_SESSION_LAST = (POLICY_SESSION_FIRST + MAX_ACTIVE_SESSIONS-1);
+const TPM_HC POLICY_SESSION_LAST =
+ (POLICY_SESSION_FIRST + MAX_ACTIVE_SESSIONS - 1);
const TPM_HC TRANSIENT_FIRST = (HR_TRANSIENT + 0);
const TPM_HC ACTIVE_SESSION_FIRST = POLICY_SESSION_FIRST;
const TPM_HC ACTIVE_SESSION_LAST = POLICY_SESSION_LAST;
-const TPM_HC TRANSIENT_LAST = (TRANSIENT_FIRST+MAX_LOADED_OBJECTS-1);
+const TPM_HC TRANSIENT_LAST = (TRANSIENT_FIRST + MAX_LOADED_OBJECTS - 1);
const TPM_HC PERSISTENT_FIRST = (HR_PERSISTENT + 0);
const TPM_HC PERSISTENT_LAST = (PERSISTENT_FIRST + 0x00FFFFFF);
const TPM_HC PLATFORM_PERSISTENT = (PERSISTENT_FIRST + 0x00800000);
@@ -1235,8 +1262,7 @@
TPMI_ALG_SYM_MODE sym;
};
-union TPMU_SYM_DETAILS {
-};
+union TPMU_SYM_DETAILS {};
struct TPMT_SYM_DEF {
TPMI_ALG_SYM algorithm;
@@ -1386,7 +1412,7 @@
struct TPM2B_PRIVATE_KEY_RSA {
UINT16 size;
- BYTE buffer[MAX_RSA_KEY_BYTES/2];
+ BYTE buffer[MAX_RSA_KEY_BYTES / 2];
};
struct TPM2B_ECC_PARAMETER {
@@ -1620,2112 +1646,1699 @@
TPMS_CREATION_DATA creation_data;
};
-
TRUNKS_EXPORT size_t GetNumberOfRequestHandles(TPM_CC command_code);
TRUNKS_EXPORT size_t GetNumberOfResponseHandles(TPM_CC command_code);
-TRUNKS_EXPORT TPM_RC Serialize_uint8_t(
- const uint8_t& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_uint8_t(const uint8_t& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_uint8_t(
- std::string* buffer,
- uint8_t* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_uint8_t(std::string* buffer,
+ uint8_t* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_int8_t(
- const int8_t& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_int8_t(const int8_t& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_int8_t(
- std::string* buffer,
- int8_t* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_int8_t(std::string* buffer,
+ int8_t* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_int(
- const int& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_int(const int& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_int(
- std::string* buffer,
- int* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_int(std::string* buffer,
+ int* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_uint16_t(
- const uint16_t& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_uint16_t(const uint16_t& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_uint16_t(
- std::string* buffer,
- uint16_t* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_uint16_t(std::string* buffer,
+ uint16_t* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_int16_t(
- const int16_t& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_int16_t(const int16_t& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_int16_t(
- std::string* buffer,
- int16_t* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_int16_t(std::string* buffer,
+ int16_t* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_uint32_t(
- const uint32_t& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_uint32_t(const uint32_t& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_uint32_t(
- std::string* buffer,
- uint32_t* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_uint32_t(std::string* buffer,
+ uint32_t* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_int32_t(
- const int32_t& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_int32_t(const int32_t& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_int32_t(
- std::string* buffer,
- int32_t* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_int32_t(std::string* buffer,
+ int32_t* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_uint64_t(
- const uint64_t& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_uint64_t(const uint64_t& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_uint64_t(
- std::string* buffer,
- uint64_t* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_uint64_t(std::string* buffer,
+ uint64_t* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_int64_t(
- const int64_t& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_int64_t(const int64_t& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_int64_t(
- std::string* buffer,
- int64_t* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_int64_t(std::string* buffer,
+ int64_t* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_UINT8(
- const UINT8& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_UINT8(const UINT8& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_UINT8(
- std::string* buffer,
- UINT8* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_UINT8(std::string* buffer,
+ UINT8* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_BYTE(
- const BYTE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_BYTE(const BYTE& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_BYTE(
- std::string* buffer,
- BYTE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_BYTE(std::string* buffer,
+ BYTE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_INT8(
- const INT8& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_INT8(const INT8& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_INT8(
- std::string* buffer,
- INT8* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_INT8(std::string* buffer,
+ INT8* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_BOOL(
- const BOOL& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_BOOL(const BOOL& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_BOOL(
- std::string* buffer,
- BOOL* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_BOOL(std::string* buffer,
+ BOOL* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_UINT16(
- const UINT16& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_UINT16(const UINT16& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_UINT16(
- std::string* buffer,
- UINT16* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_UINT16(std::string* buffer,
+ UINT16* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_INT16(
- const INT16& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_INT16(const INT16& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_INT16(
- std::string* buffer,
- INT16* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_INT16(std::string* buffer,
+ INT16* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_UINT32(
- const UINT32& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_UINT32(const UINT32& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_UINT32(
- std::string* buffer,
- UINT32* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_UINT32(std::string* buffer,
+ UINT32* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_INT32(
- const INT32& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_INT32(const INT32& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_INT32(
- std::string* buffer,
- INT32* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_INT32(std::string* buffer,
+ INT32* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_UINT64(
- const UINT64& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_UINT64(const UINT64& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_UINT64(
- std::string* buffer,
- UINT64* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_UINT64(std::string* buffer,
+ UINT64* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_INT64(
- const INT64& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_INT64(const INT64& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_INT64(
- std::string* buffer,
- INT64* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_INT64(std::string* buffer,
+ INT64* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_ALGORITHM_ID(
- const TPM_ALGORITHM_ID& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_ALGORITHM_ID(const TPM_ALGORITHM_ID& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_ALGORITHM_ID(
- std::string* buffer,
- TPM_ALGORITHM_ID* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_ALGORITHM_ID(std::string* buffer,
+ TPM_ALGORITHM_ID* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_MODIFIER_INDICATOR(
- const TPM_MODIFIER_INDICATOR& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPM_MODIFIER_INDICATOR(const TPM_MODIFIER_INDICATOR& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_MODIFIER_INDICATOR(
- std::string* buffer,
- TPM_MODIFIER_INDICATOR* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_MODIFIER_INDICATOR(std::string* buffer,
+ TPM_MODIFIER_INDICATOR* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_AUTHORIZATION_SIZE(
- const TPM_AUTHORIZATION_SIZE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPM_AUTHORIZATION_SIZE(const TPM_AUTHORIZATION_SIZE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_AUTHORIZATION_SIZE(
- std::string* buffer,
- TPM_AUTHORIZATION_SIZE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_AUTHORIZATION_SIZE(std::string* buffer,
+ TPM_AUTHORIZATION_SIZE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_PARAMETER_SIZE(
- const TPM_PARAMETER_SIZE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPM_PARAMETER_SIZE(const TPM_PARAMETER_SIZE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_PARAMETER_SIZE(
- std::string* buffer,
- TPM_PARAMETER_SIZE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_PARAMETER_SIZE(std::string* buffer,
+ TPM_PARAMETER_SIZE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_KEY_SIZE(
- const TPM_KEY_SIZE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_KEY_SIZE(const TPM_KEY_SIZE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_KEY_SIZE(
- std::string* buffer,
- TPM_KEY_SIZE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_KEY_SIZE(std::string* buffer,
+ TPM_KEY_SIZE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_KEY_BITS(
- const TPM_KEY_BITS& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_KEY_BITS(const TPM_KEY_BITS& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_KEY_BITS(
- std::string* buffer,
- TPM_KEY_BITS* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_KEY_BITS(std::string* buffer,
+ TPM_KEY_BITS* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_HANDLE(
- const TPM_HANDLE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_HANDLE(const TPM_HANDLE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_HANDLE(
- std::string* buffer,
- TPM_HANDLE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_HANDLE(std::string* buffer,
+ TPM_HANDLE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_NONCE(
- const TPM2B_NONCE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM2B_NONCE(const TPM2B_NONCE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_NONCE(
- std::string* buffer,
- TPM2B_NONCE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_NONCE(std::string* buffer,
+ TPM2B_NONCE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_AUTH(
- const TPM2B_AUTH& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM2B_AUTH(const TPM2B_AUTH& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_AUTH(
- std::string* buffer,
- TPM2B_AUTH* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_AUTH(std::string* buffer,
+ TPM2B_AUTH* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_OPERAND(
- const TPM2B_OPERAND& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM2B_OPERAND(const TPM2B_OPERAND& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_OPERAND(
- std::string* buffer,
- TPM2B_OPERAND* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_OPERAND(std::string* buffer,
+ TPM2B_OPERAND* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_HMAC(
- const TPMS_SCHEME_HMAC& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_HMAC(const TPMS_SCHEME_HMAC& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_HMAC(
- std::string* buffer,
- TPMS_SCHEME_HMAC* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_HMAC(std::string* buffer,
+ TPMS_SCHEME_HMAC* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_RSASSA(
- const TPMS_SCHEME_RSASSA& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_SCHEME_RSASSA(const TPMS_SCHEME_RSASSA& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_RSASSA(
- std::string* buffer,
- TPMS_SCHEME_RSASSA* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_RSASSA(std::string* buffer,
+ TPMS_SCHEME_RSASSA* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_RSAPSS(
- const TPMS_SCHEME_RSAPSS& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_SCHEME_RSAPSS(const TPMS_SCHEME_RSAPSS& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_RSAPSS(
- std::string* buffer,
- TPMS_SCHEME_RSAPSS* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_RSAPSS(std::string* buffer,
+ TPMS_SCHEME_RSAPSS* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_ECDSA(
- const TPMS_SCHEME_ECDSA& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_ECDSA(const TPMS_SCHEME_ECDSA& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_ECDSA(
- std::string* buffer,
- TPMS_SCHEME_ECDSA* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_ECDSA(std::string* buffer,
+ TPMS_SCHEME_ECDSA* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_SM2(
- const TPMS_SCHEME_SM2& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_SM2(const TPMS_SCHEME_SM2& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_SM2(
- std::string* buffer,
- TPMS_SCHEME_SM2* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_SM2(std::string* buffer,
+ TPMS_SCHEME_SM2* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_ECSCHNORR(
- const TPMS_SCHEME_ECSCHNORR& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_SCHEME_ECSCHNORR(const TPMS_SCHEME_ECSCHNORR& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_ECSCHNORR(
- std::string* buffer,
- TPMS_SCHEME_ECSCHNORR* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_ECSCHNORR(std::string* buffer,
+ TPMS_SCHEME_ECSCHNORR* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_YES_NO(
- const TPMI_YES_NO& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_YES_NO(const TPMI_YES_NO& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_YES_NO(
- std::string* buffer,
- TPMI_YES_NO* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_YES_NO(std::string* buffer,
+ TPMI_YES_NO* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_DH_OBJECT(
- const TPMI_DH_OBJECT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_DH_OBJECT(const TPMI_DH_OBJECT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_DH_OBJECT(
- std::string* buffer,
- TPMI_DH_OBJECT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_DH_OBJECT(std::string* buffer,
+ TPMI_DH_OBJECT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_DH_PERSISTENT(
- const TPMI_DH_PERSISTENT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMI_DH_PERSISTENT(const TPMI_DH_PERSISTENT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_DH_PERSISTENT(
- std::string* buffer,
- TPMI_DH_PERSISTENT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_DH_PERSISTENT(std::string* buffer,
+ TPMI_DH_PERSISTENT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_DH_ENTITY(
- const TPMI_DH_ENTITY& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_DH_ENTITY(const TPMI_DH_ENTITY& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_DH_ENTITY(
- std::string* buffer,
- TPMI_DH_ENTITY* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_DH_ENTITY(std::string* buffer,
+ TPMI_DH_ENTITY* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_DH_PCR(
- const TPMI_DH_PCR& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_DH_PCR(const TPMI_DH_PCR& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_DH_PCR(
- std::string* buffer,
- TPMI_DH_PCR* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_DH_PCR(std::string* buffer,
+ TPMI_DH_PCR* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_SH_AUTH_SESSION(
- const TPMI_SH_AUTH_SESSION& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMI_SH_AUTH_SESSION(const TPMI_SH_AUTH_SESSION& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_SH_AUTH_SESSION(
- std::string* buffer,
- TPMI_SH_AUTH_SESSION* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_SH_AUTH_SESSION(std::string* buffer,
+ TPMI_SH_AUTH_SESSION* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_SH_HMAC(
- const TPMI_SH_HMAC& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_SH_HMAC(const TPMI_SH_HMAC& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_SH_HMAC(
- std::string* buffer,
- TPMI_SH_HMAC* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_SH_HMAC(std::string* buffer,
+ TPMI_SH_HMAC* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_SH_POLICY(
- const TPMI_SH_POLICY& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_SH_POLICY(const TPMI_SH_POLICY& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_SH_POLICY(
- std::string* buffer,
- TPMI_SH_POLICY* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_SH_POLICY(std::string* buffer,
+ TPMI_SH_POLICY* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_DH_CONTEXT(
- const TPMI_DH_CONTEXT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_DH_CONTEXT(const TPMI_DH_CONTEXT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_DH_CONTEXT(
- std::string* buffer,
- TPMI_DH_CONTEXT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_DH_CONTEXT(std::string* buffer,
+ TPMI_DH_CONTEXT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_HIERARCHY(
- const TPMI_RH_HIERARCHY& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_HIERARCHY(const TPMI_RH_HIERARCHY& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_HIERARCHY(
- std::string* buffer,
- TPMI_RH_HIERARCHY* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_HIERARCHY(std::string* buffer,
+ TPMI_RH_HIERARCHY* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_ENABLES(
- const TPMI_RH_ENABLES& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_ENABLES(const TPMI_RH_ENABLES& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_ENABLES(
- std::string* buffer,
- TPMI_RH_ENABLES* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_ENABLES(std::string* buffer,
+ TPMI_RH_ENABLES* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_HIERARCHY_AUTH(
- const TPMI_RH_HIERARCHY_AUTH& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMI_RH_HIERARCHY_AUTH(const TPMI_RH_HIERARCHY_AUTH& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_HIERARCHY_AUTH(
- std::string* buffer,
- TPMI_RH_HIERARCHY_AUTH* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_HIERARCHY_AUTH(std::string* buffer,
+ TPMI_RH_HIERARCHY_AUTH* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_PLATFORM(
- const TPMI_RH_PLATFORM& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_PLATFORM(const TPMI_RH_PLATFORM& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_PLATFORM(
- std::string* buffer,
- TPMI_RH_PLATFORM* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_PLATFORM(std::string* buffer,
+ TPMI_RH_PLATFORM* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_OWNER(
- const TPMI_RH_OWNER& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_OWNER(const TPMI_RH_OWNER& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_OWNER(
- std::string* buffer,
- TPMI_RH_OWNER* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_OWNER(std::string* buffer,
+ TPMI_RH_OWNER* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_ENDORSEMENT(
- const TPMI_RH_ENDORSEMENT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMI_RH_ENDORSEMENT(const TPMI_RH_ENDORSEMENT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_ENDORSEMENT(
- std::string* buffer,
- TPMI_RH_ENDORSEMENT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_ENDORSEMENT(std::string* buffer,
+ TPMI_RH_ENDORSEMENT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_PROVISION(
- const TPMI_RH_PROVISION& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_PROVISION(const TPMI_RH_PROVISION& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_PROVISION(
- std::string* buffer,
- TPMI_RH_PROVISION* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_PROVISION(std::string* buffer,
+ TPMI_RH_PROVISION* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_CLEAR(
- const TPMI_RH_CLEAR& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_CLEAR(const TPMI_RH_CLEAR& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_CLEAR(
- std::string* buffer,
- TPMI_RH_CLEAR* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_CLEAR(std::string* buffer,
+ TPMI_RH_CLEAR* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_NV_AUTH(
- const TPMI_RH_NV_AUTH& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_NV_AUTH(const TPMI_RH_NV_AUTH& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_NV_AUTH(
- std::string* buffer,
- TPMI_RH_NV_AUTH* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_NV_AUTH(std::string* buffer,
+ TPMI_RH_NV_AUTH* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_LOCKOUT(
- const TPMI_RH_LOCKOUT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_LOCKOUT(const TPMI_RH_LOCKOUT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_LOCKOUT(
- std::string* buffer,
- TPMI_RH_LOCKOUT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_LOCKOUT(std::string* buffer,
+ TPMI_RH_LOCKOUT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_NV_INDEX(
- const TPMI_RH_NV_INDEX& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_RH_NV_INDEX(const TPMI_RH_NV_INDEX& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_NV_INDEX(
- std::string* buffer,
- TPMI_RH_NV_INDEX* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_RH_NV_INDEX(std::string* buffer,
+ TPMI_RH_NV_INDEX* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_HASH(
- const TPMI_ALG_HASH& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_HASH(const TPMI_ALG_HASH& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_HASH(
- std::string* buffer,
- TPMI_ALG_HASH* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_HASH(std::string* buffer,
+ TPMI_ALG_HASH* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_ASYM(
- const TPMI_ALG_ASYM& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_ASYM(const TPMI_ALG_ASYM& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_ASYM(
- std::string* buffer,
- TPMI_ALG_ASYM* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_ASYM(std::string* buffer,
+ TPMI_ALG_ASYM* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_SYM(
- const TPMI_ALG_SYM& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_SYM(const TPMI_ALG_SYM& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_SYM(
- std::string* buffer,
- TPMI_ALG_SYM* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_SYM(std::string* buffer,
+ TPMI_ALG_SYM* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_SYM_OBJECT(
- const TPMI_ALG_SYM_OBJECT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMI_ALG_SYM_OBJECT(const TPMI_ALG_SYM_OBJECT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_SYM_OBJECT(
- std::string* buffer,
- TPMI_ALG_SYM_OBJECT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_SYM_OBJECT(std::string* buffer,
+ TPMI_ALG_SYM_OBJECT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_SYM_MODE(
- const TPMI_ALG_SYM_MODE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_SYM_MODE(const TPMI_ALG_SYM_MODE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_SYM_MODE(
- std::string* buffer,
- TPMI_ALG_SYM_MODE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_SYM_MODE(std::string* buffer,
+ TPMI_ALG_SYM_MODE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_KDF(
- const TPMI_ALG_KDF& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_KDF(const TPMI_ALG_KDF& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_KDF(
- std::string* buffer,
- TPMI_ALG_KDF* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_KDF(std::string* buffer,
+ TPMI_ALG_KDF* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_SIG_SCHEME(
- const TPMI_ALG_SIG_SCHEME& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMI_ALG_SIG_SCHEME(const TPMI_ALG_SIG_SCHEME& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_SIG_SCHEME(
- std::string* buffer,
- TPMI_ALG_SIG_SCHEME* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_SIG_SCHEME(std::string* buffer,
+ TPMI_ALG_SIG_SCHEME* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_ECC_KEY_EXCHANGE(
- const TPMI_ECC_KEY_EXCHANGE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMI_ECC_KEY_EXCHANGE(const TPMI_ECC_KEY_EXCHANGE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_ECC_KEY_EXCHANGE(
- std::string* buffer,
- TPMI_ECC_KEY_EXCHANGE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_ECC_KEY_EXCHANGE(std::string* buffer,
+ TPMI_ECC_KEY_EXCHANGE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_ST_COMMAND_TAG(
- const TPMI_ST_COMMAND_TAG& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMI_ST_COMMAND_TAG(const TPMI_ST_COMMAND_TAG& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_ST_COMMAND_TAG(
- std::string* buffer,
- TPMI_ST_COMMAND_TAG* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_ST_COMMAND_TAG(std::string* buffer,
+ TPMI_ST_COMMAND_TAG* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_ST_ATTEST(
- const TPMI_ST_ATTEST& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_ST_ATTEST(const TPMI_ST_ATTEST& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_ST_ATTEST(
- std::string* buffer,
- TPMI_ST_ATTEST* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_ST_ATTEST(std::string* buffer,
+ TPMI_ST_ATTEST* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_AES_KEY_BITS(
- const TPMI_AES_KEY_BITS& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_AES_KEY_BITS(const TPMI_AES_KEY_BITS& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_AES_KEY_BITS(
- std::string* buffer,
- TPMI_AES_KEY_BITS* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_AES_KEY_BITS(std::string* buffer,
+ TPMI_AES_KEY_BITS* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_SM4_KEY_BITS(
- const TPMI_SM4_KEY_BITS& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_SM4_KEY_BITS(const TPMI_SM4_KEY_BITS& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_SM4_KEY_BITS(
- std::string* buffer,
- TPMI_SM4_KEY_BITS* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_SM4_KEY_BITS(std::string* buffer,
+ TPMI_SM4_KEY_BITS* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_KEYEDHASH_SCHEME(
- const TPMI_ALG_KEYEDHASH_SCHEME& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMI_ALG_KEYEDHASH_SCHEME(const TPMI_ALG_KEYEDHASH_SCHEME& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_KEYEDHASH_SCHEME(
- std::string* buffer,
- TPMI_ALG_KEYEDHASH_SCHEME* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC
+Parse_TPMI_ALG_KEYEDHASH_SCHEME(std::string* buffer,
+ TPMI_ALG_KEYEDHASH_SCHEME* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_ASYM_SCHEME(
- const TPMI_ALG_ASYM_SCHEME& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMI_ALG_ASYM_SCHEME(const TPMI_ALG_ASYM_SCHEME& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_ASYM_SCHEME(
- std::string* buffer,
- TPMI_ALG_ASYM_SCHEME* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_ASYM_SCHEME(std::string* buffer,
+ TPMI_ALG_ASYM_SCHEME* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_RSA_SCHEME(
- const TPMI_ALG_RSA_SCHEME& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMI_ALG_RSA_SCHEME(const TPMI_ALG_RSA_SCHEME& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_RSA_SCHEME(
- std::string* buffer,
- TPMI_ALG_RSA_SCHEME* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_RSA_SCHEME(std::string* buffer,
+ TPMI_ALG_RSA_SCHEME* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_RSA_DECRYPT(
- const TPMI_ALG_RSA_DECRYPT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMI_ALG_RSA_DECRYPT(const TPMI_ALG_RSA_DECRYPT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_RSA_DECRYPT(
- std::string* buffer,
- TPMI_ALG_RSA_DECRYPT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_RSA_DECRYPT(std::string* buffer,
+ TPMI_ALG_RSA_DECRYPT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_RSA_KEY_BITS(
- const TPMI_RSA_KEY_BITS& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_RSA_KEY_BITS(const TPMI_RSA_KEY_BITS& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_RSA_KEY_BITS(
- std::string* buffer,
- TPMI_RSA_KEY_BITS* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_RSA_KEY_BITS(std::string* buffer,
+ TPMI_RSA_KEY_BITS* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_ECC_SCHEME(
- const TPMI_ALG_ECC_SCHEME& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMI_ALG_ECC_SCHEME(const TPMI_ALG_ECC_SCHEME& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_ECC_SCHEME(
- std::string* buffer,
- TPMI_ALG_ECC_SCHEME* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_ECC_SCHEME(std::string* buffer,
+ TPMI_ALG_ECC_SCHEME* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_ECC_CURVE(
- const TPMI_ECC_CURVE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_ECC_CURVE(const TPMI_ECC_CURVE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_ECC_CURVE(
- std::string* buffer,
- TPMI_ECC_CURVE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_ECC_CURVE(std::string* buffer,
+ TPMI_ECC_CURVE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_PUBLIC(
- const TPMI_ALG_PUBLIC& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMI_ALG_PUBLIC(const TPMI_ALG_PUBLIC& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_PUBLIC(
- std::string* buffer,
- TPMI_ALG_PUBLIC* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMI_ALG_PUBLIC(std::string* buffer,
+ TPMI_ALG_PUBLIC* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMA_ALGORITHM(
- const TPMA_ALGORITHM& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMA_ALGORITHM(const TPMA_ALGORITHM& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMA_ALGORITHM(
- std::string* buffer,
- TPMA_ALGORITHM* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMA_ALGORITHM(std::string* buffer,
+ TPMA_ALGORITHM* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMA_OBJECT(
- const TPMA_OBJECT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMA_OBJECT(const TPMA_OBJECT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMA_OBJECT(
- std::string* buffer,
- TPMA_OBJECT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMA_OBJECT(std::string* buffer,
+ TPMA_OBJECT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMA_SESSION(
- const TPMA_SESSION& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMA_SESSION(const TPMA_SESSION& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMA_SESSION(
- std::string* buffer,
- TPMA_SESSION* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMA_SESSION(std::string* buffer,
+ TPMA_SESSION* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMA_LOCALITY(
- const TPMA_LOCALITY& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMA_LOCALITY(const TPMA_LOCALITY& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMA_LOCALITY(
- std::string* buffer,
- TPMA_LOCALITY* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMA_LOCALITY(std::string* buffer,
+ TPMA_LOCALITY* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMA_PERMANENT(
- const TPMA_PERMANENT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMA_PERMANENT(const TPMA_PERMANENT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMA_PERMANENT(
- std::string* buffer,
- TPMA_PERMANENT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMA_PERMANENT(std::string* buffer,
+ TPMA_PERMANENT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMA_STARTUP_CLEAR(
- const TPMA_STARTUP_CLEAR& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMA_STARTUP_CLEAR(const TPMA_STARTUP_CLEAR& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMA_STARTUP_CLEAR(
- std::string* buffer,
- TPMA_STARTUP_CLEAR* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMA_STARTUP_CLEAR(std::string* buffer,
+ TPMA_STARTUP_CLEAR* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMA_MEMORY(
- const TPMA_MEMORY& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMA_MEMORY(const TPMA_MEMORY& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMA_MEMORY(
- std::string* buffer,
- TPMA_MEMORY* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMA_MEMORY(std::string* buffer,
+ TPMA_MEMORY* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMA_CC(
- const TPMA_CC& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMA_CC(const TPMA_CC& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMA_CC(
- std::string* buffer,
- TPMA_CC* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMA_CC(std::string* buffer,
+ TPMA_CC* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_NV_INDEX(
- const TPM_NV_INDEX& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_NV_INDEX(const TPM_NV_INDEX& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_NV_INDEX(
- std::string* buffer,
- TPM_NV_INDEX* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_NV_INDEX(std::string* buffer,
+ TPM_NV_INDEX* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMA_NV(
- const TPMA_NV& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMA_NV(const TPMA_NV& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMA_NV(
- std::string* buffer,
- TPMA_NV* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMA_NV(std::string* buffer,
+ TPMA_NV* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_SPEC(
- const TPM_SPEC& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_SPEC(const TPM_SPEC& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_SPEC(
- std::string* buffer,
- TPM_SPEC* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_SPEC(std::string* buffer,
+ TPM_SPEC* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_GENERATED(
- const TPM_GENERATED& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_GENERATED(const TPM_GENERATED& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_GENERATED(
- std::string* buffer,
- TPM_GENERATED* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_GENERATED(std::string* buffer,
+ TPM_GENERATED* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_ALG_ID(
- const TPM_ALG_ID& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_ALG_ID(const TPM_ALG_ID& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_ALG_ID(
- std::string* buffer,
- TPM_ALG_ID* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_ALG_ID(std::string* buffer,
+ TPM_ALG_ID* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_ECC_CURVE(
- const TPM_ECC_CURVE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_ECC_CURVE(const TPM_ECC_CURVE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_ECC_CURVE(
- std::string* buffer,
- TPM_ECC_CURVE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_ECC_CURVE(std::string* buffer,
+ TPM_ECC_CURVE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_CC(
- const TPM_CC& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_CC(const TPM_CC& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_CC(
- std::string* buffer,
- TPM_CC* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_CC(std::string* buffer,
+ TPM_CC* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_RC(
- const TPM_RC& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_RC(const TPM_RC& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_RC(
- std::string* buffer,
- TPM_RC* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_RC(std::string* buffer,
+ TPM_RC* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_CLOCK_ADJUST(
- const TPM_CLOCK_ADJUST& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_CLOCK_ADJUST(const TPM_CLOCK_ADJUST& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_CLOCK_ADJUST(
- std::string* buffer,
- TPM_CLOCK_ADJUST* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_CLOCK_ADJUST(std::string* buffer,
+ TPM_CLOCK_ADJUST* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_EO(
- const TPM_EO& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_EO(const TPM_EO& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_EO(
- std::string* buffer,
- TPM_EO* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_EO(std::string* buffer,
+ TPM_EO* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_ST(
- const TPM_ST& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_ST(const TPM_ST& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_ST(
- std::string* buffer,
- TPM_ST* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_ST(std::string* buffer,
+ TPM_ST* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_SU(
- const TPM_SU& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_SU(const TPM_SU& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_SU(
- std::string* buffer,
- TPM_SU* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_SU(std::string* buffer,
+ TPM_SU* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_SE(
- const TPM_SE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_SE(const TPM_SE& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_SE(
- std::string* buffer,
- TPM_SE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_SE(std::string* buffer,
+ TPM_SE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_CAP(
- const TPM_CAP& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_CAP(const TPM_CAP& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_CAP(
- std::string* buffer,
- TPM_CAP* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_CAP(std::string* buffer,
+ TPM_CAP* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_PT(
- const TPM_PT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_PT(const TPM_PT& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_PT(
- std::string* buffer,
- TPM_PT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_PT(std::string* buffer,
+ TPM_PT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_PT_PCR(
- const TPM_PT_PCR& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_PT_PCR(const TPM_PT_PCR& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_PT_PCR(
- std::string* buffer,
- TPM_PT_PCR* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_PT_PCR(std::string* buffer,
+ TPM_PT_PCR* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_PS(
- const TPM_PS& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_PS(const TPM_PS& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_PS(
- std::string* buffer,
- TPM_PS* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_PS(std::string* buffer,
+ TPM_PS* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_HT(
- const TPM_HT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_HT(const TPM_HT& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_HT(
- std::string* buffer,
- TPM_HT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_HT(std::string* buffer,
+ TPM_HT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_RH(
- const TPM_RH& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_RH(const TPM_RH& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_RH(
- std::string* buffer,
- TPM_RH* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_RH(std::string* buffer,
+ TPM_RH* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM_HC(
- const TPM_HC& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM_HC(const TPM_HC& value, std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM_HC(
- std::string* buffer,
- TPM_HC* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM_HC(std::string* buffer,
+ TPM_HC* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_ALGORITHM_DESCRIPTION(
- const TPMS_ALGORITHM_DESCRIPTION& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_ALGORITHM_DESCRIPTION(const TPMS_ALGORITHM_DESCRIPTION& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_ALGORITHM_DESCRIPTION(
- std::string* buffer,
- TPMS_ALGORITHM_DESCRIPTION* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC
+Parse_TPMS_ALGORITHM_DESCRIPTION(std::string* buffer,
+ TPMS_ALGORITHM_DESCRIPTION* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMT_HA(
- const TPMT_HA& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMT_HA(const TPMT_HA& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMT_HA(
- std::string* buffer,
- TPMT_HA* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMT_HA(std::string* buffer,
+ TPMT_HA* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_DIGEST(
- const TPM2B_DIGEST& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM2B_DIGEST(const TPM2B_DIGEST& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_DIGEST(
- std::string* buffer,
- TPM2B_DIGEST* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_DIGEST(std::string* buffer,
+ TPM2B_DIGEST* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_DIGEST Make_TPM2B_DIGEST(
- const std::string& bytes);
-TRUNKS_EXPORT std::string StringFrom_TPM2B_DIGEST(
- const TPM2B_DIGEST& tpm2b);
+TRUNKS_EXPORT TPM2B_DIGEST Make_TPM2B_DIGEST(const std::string& bytes);
+TRUNKS_EXPORT std::string StringFrom_TPM2B_DIGEST(const TPM2B_DIGEST& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_DATA(
- const TPM2B_DATA& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM2B_DATA(const TPM2B_DATA& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_DATA(
- std::string* buffer,
- TPM2B_DATA* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_DATA(std::string* buffer,
+ TPM2B_DATA* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_DATA Make_TPM2B_DATA(
- const std::string& bytes);
-TRUNKS_EXPORT std::string StringFrom_TPM2B_DATA(
- const TPM2B_DATA& tpm2b);
+TRUNKS_EXPORT TPM2B_DATA Make_TPM2B_DATA(const std::string& bytes);
+TRUNKS_EXPORT std::string StringFrom_TPM2B_DATA(const TPM2B_DATA& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_EVENT(
- const TPM2B_EVENT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM2B_EVENT(const TPM2B_EVENT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_EVENT(
- std::string* buffer,
- TPM2B_EVENT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_EVENT(std::string* buffer,
+ TPM2B_EVENT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_EVENT Make_TPM2B_EVENT(
- const std::string& bytes);
-TRUNKS_EXPORT std::string StringFrom_TPM2B_EVENT(
- const TPM2B_EVENT& tpm2b);
+TRUNKS_EXPORT TPM2B_EVENT Make_TPM2B_EVENT(const std::string& bytes);
+TRUNKS_EXPORT std::string StringFrom_TPM2B_EVENT(const TPM2B_EVENT& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_MAX_BUFFER(
- const TPM2B_MAX_BUFFER& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM2B_MAX_BUFFER(const TPM2B_MAX_BUFFER& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_MAX_BUFFER(
- std::string* buffer,
- TPM2B_MAX_BUFFER* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_MAX_BUFFER(std::string* buffer,
+ TPM2B_MAX_BUFFER* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_MAX_BUFFER Make_TPM2B_MAX_BUFFER(
- const std::string& bytes);
+TRUNKS_EXPORT TPM2B_MAX_BUFFER Make_TPM2B_MAX_BUFFER(const std::string& bytes);
TRUNKS_EXPORT std::string StringFrom_TPM2B_MAX_BUFFER(
const TPM2B_MAX_BUFFER& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_MAX_NV_BUFFER(
- const TPM2B_MAX_NV_BUFFER& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPM2B_MAX_NV_BUFFER(const TPM2B_MAX_NV_BUFFER& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_MAX_NV_BUFFER(
- std::string* buffer,
- TPM2B_MAX_NV_BUFFER* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_MAX_NV_BUFFER(std::string* buffer,
+ TPM2B_MAX_NV_BUFFER* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_MAX_NV_BUFFER Make_TPM2B_MAX_NV_BUFFER(
- const std::string& bytes);
+TRUNKS_EXPORT TPM2B_MAX_NV_BUFFER
+Make_TPM2B_MAX_NV_BUFFER(const std::string& bytes);
TRUNKS_EXPORT std::string StringFrom_TPM2B_MAX_NV_BUFFER(
const TPM2B_MAX_NV_BUFFER& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_TIMEOUT(
- const TPM2B_TIMEOUT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM2B_TIMEOUT(const TPM2B_TIMEOUT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_TIMEOUT(
- std::string* buffer,
- TPM2B_TIMEOUT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_TIMEOUT(std::string* buffer,
+ TPM2B_TIMEOUT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_TIMEOUT Make_TPM2B_TIMEOUT(
- const std::string& bytes);
-TRUNKS_EXPORT std::string StringFrom_TPM2B_TIMEOUT(
- const TPM2B_TIMEOUT& tpm2b);
+TRUNKS_EXPORT TPM2B_TIMEOUT Make_TPM2B_TIMEOUT(const std::string& bytes);
+TRUNKS_EXPORT std::string StringFrom_TPM2B_TIMEOUT(const TPM2B_TIMEOUT& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_IV(
- const TPM2B_IV& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM2B_IV(const TPM2B_IV& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_IV(
- std::string* buffer,
- TPM2B_IV* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_IV(std::string* buffer,
+ TPM2B_IV* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_IV Make_TPM2B_IV(
- const std::string& bytes);
-TRUNKS_EXPORT std::string StringFrom_TPM2B_IV(
- const TPM2B_IV& tpm2b);
+TRUNKS_EXPORT TPM2B_IV Make_TPM2B_IV(const std::string& bytes);
+TRUNKS_EXPORT std::string StringFrom_TPM2B_IV(const TPM2B_IV& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_NAME(
- const TPM2B_NAME& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM2B_NAME(const TPM2B_NAME& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_NAME(
- std::string* buffer,
- TPM2B_NAME* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_NAME(std::string* buffer,
+ TPM2B_NAME* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_NAME Make_TPM2B_NAME(
- const std::string& bytes);
-TRUNKS_EXPORT std::string StringFrom_TPM2B_NAME(
- const TPM2B_NAME& tpm2b);
+TRUNKS_EXPORT TPM2B_NAME Make_TPM2B_NAME(const std::string& bytes);
+TRUNKS_EXPORT std::string StringFrom_TPM2B_NAME(const TPM2B_NAME& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_PCR_SELECT(
- const TPMS_PCR_SELECT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_PCR_SELECT(const TPMS_PCR_SELECT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_PCR_SELECT(
- std::string* buffer,
- TPMS_PCR_SELECT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_PCR_SELECT(std::string* buffer,
+ TPMS_PCR_SELECT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_PCR_SELECTION(
- const TPMS_PCR_SELECTION& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_PCR_SELECTION(const TPMS_PCR_SELECTION& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_PCR_SELECTION(
- std::string* buffer,
- TPMS_PCR_SELECTION* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_PCR_SELECTION(std::string* buffer,
+ TPMS_PCR_SELECTION* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMT_TK_CREATION(
- const TPMT_TK_CREATION& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMT_TK_CREATION(const TPMT_TK_CREATION& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMT_TK_CREATION(
- std::string* buffer,
- TPMT_TK_CREATION* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMT_TK_CREATION(std::string* buffer,
+ TPMT_TK_CREATION* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMT_TK_VERIFIED(
- const TPMT_TK_VERIFIED& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMT_TK_VERIFIED(const TPMT_TK_VERIFIED& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMT_TK_VERIFIED(
- std::string* buffer,
- TPMT_TK_VERIFIED* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMT_TK_VERIFIED(std::string* buffer,
+ TPMT_TK_VERIFIED* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMT_TK_AUTH(
- const TPMT_TK_AUTH& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMT_TK_AUTH(const TPMT_TK_AUTH& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMT_TK_AUTH(
- std::string* buffer,
- TPMT_TK_AUTH* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMT_TK_AUTH(std::string* buffer,
+ TPMT_TK_AUTH* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMT_TK_HASHCHECK(
- const TPMT_TK_HASHCHECK& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMT_TK_HASHCHECK(const TPMT_TK_HASHCHECK& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMT_TK_HASHCHECK(
- std::string* buffer,
- TPMT_TK_HASHCHECK* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMT_TK_HASHCHECK(std::string* buffer,
+ TPMT_TK_HASHCHECK* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_ALG_PROPERTY(
- const TPMS_ALG_PROPERTY& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_ALG_PROPERTY(const TPMS_ALG_PROPERTY& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_ALG_PROPERTY(
- std::string* buffer,
- TPMS_ALG_PROPERTY* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_ALG_PROPERTY(std::string* buffer,
+ TPMS_ALG_PROPERTY* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_TAGGED_PROPERTY(
- const TPMS_TAGGED_PROPERTY& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_TAGGED_PROPERTY(const TPMS_TAGGED_PROPERTY& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_TAGGED_PROPERTY(
- std::string* buffer,
- TPMS_TAGGED_PROPERTY* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_TAGGED_PROPERTY(std::string* buffer,
+ TPMS_TAGGED_PROPERTY* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_TAGGED_PCR_SELECT(
- const TPMS_TAGGED_PCR_SELECT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_TAGGED_PCR_SELECT(const TPMS_TAGGED_PCR_SELECT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_TAGGED_PCR_SELECT(
- std::string* buffer,
- TPMS_TAGGED_PCR_SELECT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_TAGGED_PCR_SELECT(std::string* buffer,
+ TPMS_TAGGED_PCR_SELECT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPML_CC(
- const TPML_CC& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPML_CC(const TPML_CC& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPML_CC(
- std::string* buffer,
- TPML_CC* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPML_CC(std::string* buffer,
+ TPML_CC* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPML_CCA(
- const TPML_CCA& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPML_CCA(const TPML_CCA& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPML_CCA(
- std::string* buffer,
- TPML_CCA* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPML_CCA(std::string* buffer,
+ TPML_CCA* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPML_ALG(
- const TPML_ALG& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPML_ALG(const TPML_ALG& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPML_ALG(
- std::string* buffer,
- TPML_ALG* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPML_ALG(std::string* buffer,
+ TPML_ALG* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPML_HANDLE(
- const TPML_HANDLE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPML_HANDLE(const TPML_HANDLE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPML_HANDLE(
- std::string* buffer,
- TPML_HANDLE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPML_HANDLE(std::string* buffer,
+ TPML_HANDLE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPML_DIGEST(
- const TPML_DIGEST& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPML_DIGEST(const TPML_DIGEST& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPML_DIGEST(
- std::string* buffer,
- TPML_DIGEST* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPML_DIGEST(std::string* buffer,
+ TPML_DIGEST* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPML_DIGEST_VALUES(
- const TPML_DIGEST_VALUES& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPML_DIGEST_VALUES(const TPML_DIGEST_VALUES& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPML_DIGEST_VALUES(
- std::string* buffer,
- TPML_DIGEST_VALUES* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPML_DIGEST_VALUES(std::string* buffer,
+ TPML_DIGEST_VALUES* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_DIGEST_VALUES(
- const TPM2B_DIGEST_VALUES& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPM2B_DIGEST_VALUES(const TPM2B_DIGEST_VALUES& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_DIGEST_VALUES(
- std::string* buffer,
- TPM2B_DIGEST_VALUES* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_DIGEST_VALUES(std::string* buffer,
+ TPM2B_DIGEST_VALUES* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_DIGEST_VALUES Make_TPM2B_DIGEST_VALUES(
- const std::string& bytes);
+TRUNKS_EXPORT TPM2B_DIGEST_VALUES
+Make_TPM2B_DIGEST_VALUES(const std::string& bytes);
TRUNKS_EXPORT std::string StringFrom_TPM2B_DIGEST_VALUES(
const TPM2B_DIGEST_VALUES& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPML_PCR_SELECTION(
- const TPML_PCR_SELECTION& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPML_PCR_SELECTION(const TPML_PCR_SELECTION& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPML_PCR_SELECTION(
- std::string* buffer,
- TPML_PCR_SELECTION* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPML_PCR_SELECTION(std::string* buffer,
+ TPML_PCR_SELECTION* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPML_ALG_PROPERTY(
- const TPML_ALG_PROPERTY& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPML_ALG_PROPERTY(const TPML_ALG_PROPERTY& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPML_ALG_PROPERTY(
- std::string* buffer,
- TPML_ALG_PROPERTY* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPML_ALG_PROPERTY(std::string* buffer,
+ TPML_ALG_PROPERTY* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPML_TAGGED_TPM_PROPERTY(
- const TPML_TAGGED_TPM_PROPERTY& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPML_TAGGED_TPM_PROPERTY(const TPML_TAGGED_TPM_PROPERTY& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPML_TAGGED_TPM_PROPERTY(
- std::string* buffer,
- TPML_TAGGED_TPM_PROPERTY* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC
+Parse_TPML_TAGGED_TPM_PROPERTY(std::string* buffer,
+ TPML_TAGGED_TPM_PROPERTY* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPML_TAGGED_PCR_PROPERTY(
- const TPML_TAGGED_PCR_PROPERTY& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPML_TAGGED_PCR_PROPERTY(const TPML_TAGGED_PCR_PROPERTY& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPML_TAGGED_PCR_PROPERTY(
- std::string* buffer,
- TPML_TAGGED_PCR_PROPERTY* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC
+Parse_TPML_TAGGED_PCR_PROPERTY(std::string* buffer,
+ TPML_TAGGED_PCR_PROPERTY* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPML_ECC_CURVE(
- const TPML_ECC_CURVE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPML_ECC_CURVE(const TPML_ECC_CURVE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPML_ECC_CURVE(
- std::string* buffer,
- TPML_ECC_CURVE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPML_ECC_CURVE(std::string* buffer,
+ TPML_ECC_CURVE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_CAPABILITY_DATA(
- const TPMS_CAPABILITY_DATA& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_CAPABILITY_DATA(const TPMS_CAPABILITY_DATA& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_CAPABILITY_DATA(
- std::string* buffer,
- TPMS_CAPABILITY_DATA* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_CAPABILITY_DATA(std::string* buffer,
+ TPMS_CAPABILITY_DATA* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_CLOCK_INFO(
- const TPMS_CLOCK_INFO& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_CLOCK_INFO(const TPMS_CLOCK_INFO& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_CLOCK_INFO(
- std::string* buffer,
- TPMS_CLOCK_INFO* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_CLOCK_INFO(std::string* buffer,
+ TPMS_CLOCK_INFO* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_TIME_INFO(
- const TPMS_TIME_INFO& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_TIME_INFO(const TPMS_TIME_INFO& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_TIME_INFO(
- std::string* buffer,
- TPMS_TIME_INFO* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_TIME_INFO(std::string* buffer,
+ TPMS_TIME_INFO* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_TIME_ATTEST_INFO(
- const TPMS_TIME_ATTEST_INFO& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_TIME_ATTEST_INFO(const TPMS_TIME_ATTEST_INFO& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_TIME_ATTEST_INFO(
- std::string* buffer,
- TPMS_TIME_ATTEST_INFO* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_TIME_ATTEST_INFO(std::string* buffer,
+ TPMS_TIME_ATTEST_INFO* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_CERTIFY_INFO(
- const TPMS_CERTIFY_INFO& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_CERTIFY_INFO(const TPMS_CERTIFY_INFO& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_CERTIFY_INFO(
- std::string* buffer,
- TPMS_CERTIFY_INFO* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_CERTIFY_INFO(std::string* buffer,
+ TPMS_CERTIFY_INFO* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_QUOTE_INFO(
- const TPMS_QUOTE_INFO& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_QUOTE_INFO(const TPMS_QUOTE_INFO& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_QUOTE_INFO(
- std::string* buffer,
- TPMS_QUOTE_INFO* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_QUOTE_INFO(std::string* buffer,
+ TPMS_QUOTE_INFO* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_COMMAND_AUDIT_INFO(
- const TPMS_COMMAND_AUDIT_INFO& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_COMMAND_AUDIT_INFO(const TPMS_COMMAND_AUDIT_INFO& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_COMMAND_AUDIT_INFO(
- std::string* buffer,
- TPMS_COMMAND_AUDIT_INFO* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC
+Parse_TPMS_COMMAND_AUDIT_INFO(std::string* buffer,
+ TPMS_COMMAND_AUDIT_INFO* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SESSION_AUDIT_INFO(
- const TPMS_SESSION_AUDIT_INFO& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_SESSION_AUDIT_INFO(const TPMS_SESSION_AUDIT_INFO& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SESSION_AUDIT_INFO(
- std::string* buffer,
- TPMS_SESSION_AUDIT_INFO* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC
+Parse_TPMS_SESSION_AUDIT_INFO(std::string* buffer,
+ TPMS_SESSION_AUDIT_INFO* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_CREATION_INFO(
- const TPMS_CREATION_INFO& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_CREATION_INFO(const TPMS_CREATION_INFO& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_CREATION_INFO(
- std::string* buffer,
- TPMS_CREATION_INFO* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_CREATION_INFO(std::string* buffer,
+ TPMS_CREATION_INFO* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_NV_CERTIFY_INFO(
- const TPMS_NV_CERTIFY_INFO& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_NV_CERTIFY_INFO(const TPMS_NV_CERTIFY_INFO& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_NV_CERTIFY_INFO(
- std::string* buffer,
- TPMS_NV_CERTIFY_INFO* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_NV_CERTIFY_INFO(std::string* buffer,
+ TPMS_NV_CERTIFY_INFO* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_ATTEST(
- const TPMS_ATTEST& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_ATTEST(const TPMS_ATTEST& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_ATTEST(
- std::string* buffer,
- TPMS_ATTEST* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_ATTEST(std::string* buffer,
+ TPMS_ATTEST* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_ATTEST(
- const TPM2B_ATTEST& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM2B_ATTEST(const TPM2B_ATTEST& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_ATTEST(
- std::string* buffer,
- TPM2B_ATTEST* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_ATTEST(std::string* buffer,
+ TPM2B_ATTEST* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_ATTEST Make_TPM2B_ATTEST(
- const std::string& bytes);
-TRUNKS_EXPORT std::string StringFrom_TPM2B_ATTEST(
- const TPM2B_ATTEST& tpm2b);
+TRUNKS_EXPORT TPM2B_ATTEST Make_TPM2B_ATTEST(const std::string& bytes);
+TRUNKS_EXPORT std::string StringFrom_TPM2B_ATTEST(const TPM2B_ATTEST& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_AUTH_COMMAND(
- const TPMS_AUTH_COMMAND& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_AUTH_COMMAND(const TPMS_AUTH_COMMAND& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_AUTH_COMMAND(
- std::string* buffer,
- TPMS_AUTH_COMMAND* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_AUTH_COMMAND(std::string* buffer,
+ TPMS_AUTH_COMMAND* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_AUTH_RESPONSE(
- const TPMS_AUTH_RESPONSE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_AUTH_RESPONSE(const TPMS_AUTH_RESPONSE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_AUTH_RESPONSE(
- std::string* buffer,
- TPMS_AUTH_RESPONSE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_AUTH_RESPONSE(std::string* buffer,
+ TPMS_AUTH_RESPONSE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMT_SYM_DEF(
- const TPMT_SYM_DEF& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMT_SYM_DEF(const TPMT_SYM_DEF& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMT_SYM_DEF(
- std::string* buffer,
- TPMT_SYM_DEF* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMT_SYM_DEF(std::string* buffer,
+ TPMT_SYM_DEF* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMT_SYM_DEF_OBJECT(
- const TPMT_SYM_DEF_OBJECT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMT_SYM_DEF_OBJECT(const TPMT_SYM_DEF_OBJECT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMT_SYM_DEF_OBJECT(
- std::string* buffer,
- TPMT_SYM_DEF_OBJECT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMT_SYM_DEF_OBJECT(std::string* buffer,
+ TPMT_SYM_DEF_OBJECT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_SYM_KEY(
- const TPM2B_SYM_KEY& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM2B_SYM_KEY(const TPM2B_SYM_KEY& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_SYM_KEY(
- std::string* buffer,
- TPM2B_SYM_KEY* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_SYM_KEY(std::string* buffer,
+ TPM2B_SYM_KEY* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_SYM_KEY Make_TPM2B_SYM_KEY(
- const std::string& bytes);
-TRUNKS_EXPORT std::string StringFrom_TPM2B_SYM_KEY(
- const TPM2B_SYM_KEY& tpm2b);
+TRUNKS_EXPORT TPM2B_SYM_KEY Make_TPM2B_SYM_KEY(const std::string& bytes);
+TRUNKS_EXPORT std::string StringFrom_TPM2B_SYM_KEY(const TPM2B_SYM_KEY& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SYMCIPHER_PARMS(
- const TPMS_SYMCIPHER_PARMS& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_SYMCIPHER_PARMS(const TPMS_SYMCIPHER_PARMS& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SYMCIPHER_PARMS(
- std::string* buffer,
- TPMS_SYMCIPHER_PARMS* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_SYMCIPHER_PARMS(std::string* buffer,
+ TPMS_SYMCIPHER_PARMS* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_SENSITIVE_DATA(
- const TPM2B_SENSITIVE_DATA& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPM2B_SENSITIVE_DATA(const TPM2B_SENSITIVE_DATA& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_SENSITIVE_DATA(
- std::string* buffer,
- TPM2B_SENSITIVE_DATA* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_SENSITIVE_DATA(std::string* buffer,
+ TPM2B_SENSITIVE_DATA* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_SENSITIVE_DATA Make_TPM2B_SENSITIVE_DATA(
- const std::string& bytes);
+TRUNKS_EXPORT TPM2B_SENSITIVE_DATA
+Make_TPM2B_SENSITIVE_DATA(const std::string& bytes);
TRUNKS_EXPORT std::string StringFrom_TPM2B_SENSITIVE_DATA(
const TPM2B_SENSITIVE_DATA& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SENSITIVE_CREATE(
- const TPMS_SENSITIVE_CREATE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_SENSITIVE_CREATE(const TPMS_SENSITIVE_CREATE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SENSITIVE_CREATE(
- std::string* buffer,
- TPMS_SENSITIVE_CREATE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_SENSITIVE_CREATE(std::string* buffer,
+ TPMS_SENSITIVE_CREATE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_SENSITIVE_CREATE(
- const TPM2B_SENSITIVE_CREATE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPM2B_SENSITIVE_CREATE(const TPM2B_SENSITIVE_CREATE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_SENSITIVE_CREATE(
- std::string* buffer,
- TPM2B_SENSITIVE_CREATE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_SENSITIVE_CREATE(std::string* buffer,
+ TPM2B_SENSITIVE_CREATE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_SENSITIVE_CREATE Make_TPM2B_SENSITIVE_CREATE(
- const TPMS_SENSITIVE_CREATE& inner);
+TRUNKS_EXPORT TPM2B_SENSITIVE_CREATE
+Make_TPM2B_SENSITIVE_CREATE(const TPMS_SENSITIVE_CREATE& inner);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_SIGHASH(
- const TPMS_SCHEME_SIGHASH& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_SCHEME_SIGHASH(const TPMS_SCHEME_SIGHASH& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_SIGHASH(
- std::string* buffer,
- TPMS_SCHEME_SIGHASH* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_SIGHASH(std::string* buffer,
+ TPMS_SCHEME_SIGHASH* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_XOR(
- const TPMS_SCHEME_XOR& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_XOR(const TPMS_SCHEME_XOR& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_XOR(
- std::string* buffer,
- TPMS_SCHEME_XOR* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_XOR(std::string* buffer,
+ TPMS_SCHEME_XOR* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMT_KEYEDHASH_SCHEME(
- const TPMT_KEYEDHASH_SCHEME& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMT_KEYEDHASH_SCHEME(const TPMT_KEYEDHASH_SCHEME& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMT_KEYEDHASH_SCHEME(
- std::string* buffer,
- TPMT_KEYEDHASH_SCHEME* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMT_KEYEDHASH_SCHEME(std::string* buffer,
+ TPMT_KEYEDHASH_SCHEME* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_ECDAA(
- const TPMS_SCHEME_ECDAA& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_ECDAA(const TPMS_SCHEME_ECDAA& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_ECDAA(
- std::string* buffer,
- TPMS_SCHEME_ECDAA* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_ECDAA(std::string* buffer,
+ TPMS_SCHEME_ECDAA* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMT_SIG_SCHEME(
- const TPMT_SIG_SCHEME& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMT_SIG_SCHEME(const TPMT_SIG_SCHEME& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMT_SIG_SCHEME(
- std::string* buffer,
- TPMT_SIG_SCHEME* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMT_SIG_SCHEME(std::string* buffer,
+ TPMT_SIG_SCHEME* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_OAEP(
- const TPMS_SCHEME_OAEP& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_OAEP(const TPMS_SCHEME_OAEP& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_OAEP(
- std::string* buffer,
- TPMS_SCHEME_OAEP* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_OAEP(std::string* buffer,
+ TPMS_SCHEME_OAEP* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_ECDH(
- const TPMS_SCHEME_ECDH& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_ECDH(const TPMS_SCHEME_ECDH& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_ECDH(
- std::string* buffer,
- TPMS_SCHEME_ECDH* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_ECDH(std::string* buffer,
+ TPMS_SCHEME_ECDH* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_MGF1(
- const TPMS_SCHEME_MGF1& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_MGF1(const TPMS_SCHEME_MGF1& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_MGF1(
- std::string* buffer,
- TPMS_SCHEME_MGF1* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_MGF1(std::string* buffer,
+ TPMS_SCHEME_MGF1* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_KDF1_SP800_56a(
- const TPMS_SCHEME_KDF1_SP800_56a& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_SCHEME_KDF1_SP800_56a(const TPMS_SCHEME_KDF1_SP800_56a& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_KDF1_SP800_56a(
- std::string* buffer,
- TPMS_SCHEME_KDF1_SP800_56a* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC
+Parse_TPMS_SCHEME_KDF1_SP800_56a(std::string* buffer,
+ TPMS_SCHEME_KDF1_SP800_56a* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_KDF2(
- const TPMS_SCHEME_KDF2& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_KDF2(const TPMS_SCHEME_KDF2& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_KDF2(
- std::string* buffer,
- TPMS_SCHEME_KDF2* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_KDF2(std::string* buffer,
+ TPMS_SCHEME_KDF2* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SCHEME_KDF1_SP800_108(
- const TPMS_SCHEME_KDF1_SP800_108& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_SCHEME_KDF1_SP800_108(const TPMS_SCHEME_KDF1_SP800_108& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SCHEME_KDF1_SP800_108(
- std::string* buffer,
- TPMS_SCHEME_KDF1_SP800_108* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC
+Parse_TPMS_SCHEME_KDF1_SP800_108(std::string* buffer,
+ TPMS_SCHEME_KDF1_SP800_108* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMT_KDF_SCHEME(
- const TPMT_KDF_SCHEME& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMT_KDF_SCHEME(const TPMT_KDF_SCHEME& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMT_KDF_SCHEME(
- std::string* buffer,
- TPMT_KDF_SCHEME* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMT_KDF_SCHEME(std::string* buffer,
+ TPMT_KDF_SCHEME* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMT_ASYM_SCHEME(
- const TPMT_ASYM_SCHEME& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMT_ASYM_SCHEME(const TPMT_ASYM_SCHEME& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMT_ASYM_SCHEME(
- std::string* buffer,
- TPMT_ASYM_SCHEME* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMT_ASYM_SCHEME(std::string* buffer,
+ TPMT_ASYM_SCHEME* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMT_RSA_SCHEME(
- const TPMT_RSA_SCHEME& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMT_RSA_SCHEME(const TPMT_RSA_SCHEME& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMT_RSA_SCHEME(
- std::string* buffer,
- TPMT_RSA_SCHEME* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMT_RSA_SCHEME(std::string* buffer,
+ TPMT_RSA_SCHEME* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMT_RSA_DECRYPT(
- const TPMT_RSA_DECRYPT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMT_RSA_DECRYPT(const TPMT_RSA_DECRYPT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMT_RSA_DECRYPT(
- std::string* buffer,
- TPMT_RSA_DECRYPT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMT_RSA_DECRYPT(std::string* buffer,
+ TPMT_RSA_DECRYPT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_PUBLIC_KEY_RSA(
- const TPM2B_PUBLIC_KEY_RSA& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPM2B_PUBLIC_KEY_RSA(const TPM2B_PUBLIC_KEY_RSA& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_PUBLIC_KEY_RSA(
- std::string* buffer,
- TPM2B_PUBLIC_KEY_RSA* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_PUBLIC_KEY_RSA(std::string* buffer,
+ TPM2B_PUBLIC_KEY_RSA* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_PUBLIC_KEY_RSA Make_TPM2B_PUBLIC_KEY_RSA(
- const std::string& bytes);
+TRUNKS_EXPORT TPM2B_PUBLIC_KEY_RSA
+Make_TPM2B_PUBLIC_KEY_RSA(const std::string& bytes);
TRUNKS_EXPORT std::string StringFrom_TPM2B_PUBLIC_KEY_RSA(
const TPM2B_PUBLIC_KEY_RSA& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_PRIVATE_KEY_RSA(
- const TPM2B_PRIVATE_KEY_RSA& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPM2B_PRIVATE_KEY_RSA(const TPM2B_PRIVATE_KEY_RSA& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_PRIVATE_KEY_RSA(
- std::string* buffer,
- TPM2B_PRIVATE_KEY_RSA* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_PRIVATE_KEY_RSA(std::string* buffer,
+ TPM2B_PRIVATE_KEY_RSA* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_PRIVATE_KEY_RSA Make_TPM2B_PRIVATE_KEY_RSA(
- const std::string& bytes);
+TRUNKS_EXPORT TPM2B_PRIVATE_KEY_RSA
+Make_TPM2B_PRIVATE_KEY_RSA(const std::string& bytes);
TRUNKS_EXPORT std::string StringFrom_TPM2B_PRIVATE_KEY_RSA(
const TPM2B_PRIVATE_KEY_RSA& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_ECC_PARAMETER(
- const TPM2B_ECC_PARAMETER& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPM2B_ECC_PARAMETER(const TPM2B_ECC_PARAMETER& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_ECC_PARAMETER(
- std::string* buffer,
- TPM2B_ECC_PARAMETER* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_ECC_PARAMETER(std::string* buffer,
+ TPM2B_ECC_PARAMETER* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_ECC_PARAMETER Make_TPM2B_ECC_PARAMETER(
- const std::string& bytes);
+TRUNKS_EXPORT TPM2B_ECC_PARAMETER
+Make_TPM2B_ECC_PARAMETER(const std::string& bytes);
TRUNKS_EXPORT std::string StringFrom_TPM2B_ECC_PARAMETER(
const TPM2B_ECC_PARAMETER& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_ECC_POINT(
- const TPMS_ECC_POINT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_ECC_POINT(const TPMS_ECC_POINT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_ECC_POINT(
- std::string* buffer,
- TPMS_ECC_POINT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_ECC_POINT(std::string* buffer,
+ TPMS_ECC_POINT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_ECC_POINT(
- const TPM2B_ECC_POINT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM2B_ECC_POINT(const TPM2B_ECC_POINT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_ECC_POINT(
- std::string* buffer,
- TPM2B_ECC_POINT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_ECC_POINT(std::string* buffer,
+ TPM2B_ECC_POINT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_ECC_POINT Make_TPM2B_ECC_POINT(
- const TPMS_ECC_POINT& inner);
+TRUNKS_EXPORT TPM2B_ECC_POINT Make_TPM2B_ECC_POINT(const TPMS_ECC_POINT& inner);
-TRUNKS_EXPORT TPM_RC Serialize_TPMT_ECC_SCHEME(
- const TPMT_ECC_SCHEME& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMT_ECC_SCHEME(const TPMT_ECC_SCHEME& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMT_ECC_SCHEME(
- std::string* buffer,
- TPMT_ECC_SCHEME* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMT_ECC_SCHEME(std::string* buffer,
+ TPMT_ECC_SCHEME* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_ALGORITHM_DETAIL_ECC(
- const TPMS_ALGORITHM_DETAIL_ECC& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_ALGORITHM_DETAIL_ECC(const TPMS_ALGORITHM_DETAIL_ECC& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_ALGORITHM_DETAIL_ECC(
- std::string* buffer,
- TPMS_ALGORITHM_DETAIL_ECC* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC
+Parse_TPMS_ALGORITHM_DETAIL_ECC(std::string* buffer,
+ TPMS_ALGORITHM_DETAIL_ECC* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SIGNATURE_RSASSA(
- const TPMS_SIGNATURE_RSASSA& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_SIGNATURE_RSASSA(const TPMS_SIGNATURE_RSASSA& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SIGNATURE_RSASSA(
- std::string* buffer,
- TPMS_SIGNATURE_RSASSA* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_SIGNATURE_RSASSA(std::string* buffer,
+ TPMS_SIGNATURE_RSASSA* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SIGNATURE_RSAPSS(
- const TPMS_SIGNATURE_RSAPSS& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_SIGNATURE_RSAPSS(const TPMS_SIGNATURE_RSAPSS& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SIGNATURE_RSAPSS(
- std::string* buffer,
- TPMS_SIGNATURE_RSAPSS* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_SIGNATURE_RSAPSS(std::string* buffer,
+ TPMS_SIGNATURE_RSAPSS* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_SIGNATURE_ECDSA(
- const TPMS_SIGNATURE_ECDSA& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_SIGNATURE_ECDSA(const TPMS_SIGNATURE_ECDSA& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_SIGNATURE_ECDSA(
- std::string* buffer,
- TPMS_SIGNATURE_ECDSA* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_SIGNATURE_ECDSA(std::string* buffer,
+ TPMS_SIGNATURE_ECDSA* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMT_SIGNATURE(
- const TPMT_SIGNATURE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMT_SIGNATURE(const TPMT_SIGNATURE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMT_SIGNATURE(
- std::string* buffer,
- TPMT_SIGNATURE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMT_SIGNATURE(std::string* buffer,
+ TPMT_SIGNATURE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_ENCRYPTED_SECRET(
- const TPM2B_ENCRYPTED_SECRET& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPM2B_ENCRYPTED_SECRET(const TPM2B_ENCRYPTED_SECRET& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_ENCRYPTED_SECRET(
- std::string* buffer,
- TPM2B_ENCRYPTED_SECRET* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_ENCRYPTED_SECRET(std::string* buffer,
+ TPM2B_ENCRYPTED_SECRET* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_ENCRYPTED_SECRET Make_TPM2B_ENCRYPTED_SECRET(
- const std::string& bytes);
+TRUNKS_EXPORT TPM2B_ENCRYPTED_SECRET
+Make_TPM2B_ENCRYPTED_SECRET(const std::string& bytes);
TRUNKS_EXPORT std::string StringFrom_TPM2B_ENCRYPTED_SECRET(
const TPM2B_ENCRYPTED_SECRET& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_KEYEDHASH_PARMS(
- const TPMS_KEYEDHASH_PARMS& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_KEYEDHASH_PARMS(const TPMS_KEYEDHASH_PARMS& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_KEYEDHASH_PARMS(
- std::string* buffer,
- TPMS_KEYEDHASH_PARMS* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_KEYEDHASH_PARMS(std::string* buffer,
+ TPMS_KEYEDHASH_PARMS* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_ASYM_PARMS(
- const TPMS_ASYM_PARMS& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_ASYM_PARMS(const TPMS_ASYM_PARMS& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_ASYM_PARMS(
- std::string* buffer,
- TPMS_ASYM_PARMS* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_ASYM_PARMS(std::string* buffer,
+ TPMS_ASYM_PARMS* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_RSA_PARMS(
- const TPMS_RSA_PARMS& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_RSA_PARMS(const TPMS_RSA_PARMS& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_RSA_PARMS(
- std::string* buffer,
- TPMS_RSA_PARMS* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_RSA_PARMS(std::string* buffer,
+ TPMS_RSA_PARMS* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_ECC_PARMS(
- const TPMS_ECC_PARMS& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_ECC_PARMS(const TPMS_ECC_PARMS& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_ECC_PARMS(
- std::string* buffer,
- TPMS_ECC_PARMS* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_ECC_PARMS(std::string* buffer,
+ TPMS_ECC_PARMS* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMT_PUBLIC_PARMS(
- const TPMT_PUBLIC_PARMS& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMT_PUBLIC_PARMS(const TPMT_PUBLIC_PARMS& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMT_PUBLIC_PARMS(
- std::string* buffer,
- TPMT_PUBLIC_PARMS* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMT_PUBLIC_PARMS(std::string* buffer,
+ TPMT_PUBLIC_PARMS* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMT_PUBLIC(
- const TPMT_PUBLIC& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMT_PUBLIC(const TPMT_PUBLIC& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMT_PUBLIC(
- std::string* buffer,
- TPMT_PUBLIC* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMT_PUBLIC(std::string* buffer,
+ TPMT_PUBLIC* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_PUBLIC(
- const TPM2B_PUBLIC& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM2B_PUBLIC(const TPM2B_PUBLIC& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_PUBLIC(
- std::string* buffer,
- TPM2B_PUBLIC* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_PUBLIC(std::string* buffer,
+ TPM2B_PUBLIC* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_PUBLIC Make_TPM2B_PUBLIC(
- const TPMT_PUBLIC& inner);
+TRUNKS_EXPORT TPM2B_PUBLIC Make_TPM2B_PUBLIC(const TPMT_PUBLIC& inner);
TRUNKS_EXPORT TPM_RC Serialize_TPM2B_PRIVATE_VENDOR_SPECIFIC(
const TPM2B_PRIVATE_VENDOR_SPECIFIC& value,
std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_PRIVATE_VENDOR_SPECIFIC(
- std::string* buffer,
- TPM2B_PRIVATE_VENDOR_SPECIFIC* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC
+Parse_TPM2B_PRIVATE_VENDOR_SPECIFIC(std::string* buffer,
+ TPM2B_PRIVATE_VENDOR_SPECIFIC* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_PRIVATE_VENDOR_SPECIFIC Make_TPM2B_PRIVATE_VENDOR_SPECIFIC(
- const std::string& bytes);
+TRUNKS_EXPORT TPM2B_PRIVATE_VENDOR_SPECIFIC
+Make_TPM2B_PRIVATE_VENDOR_SPECIFIC(const std::string& bytes);
TRUNKS_EXPORT std::string StringFrom_TPM2B_PRIVATE_VENDOR_SPECIFIC(
const TPM2B_PRIVATE_VENDOR_SPECIFIC& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPMT_SENSITIVE(
- const TPMT_SENSITIVE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMT_SENSITIVE(const TPMT_SENSITIVE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMT_SENSITIVE(
- std::string* buffer,
- TPMT_SENSITIVE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMT_SENSITIVE(std::string* buffer,
+ TPMT_SENSITIVE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_SENSITIVE(
- const TPM2B_SENSITIVE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM2B_SENSITIVE(const TPM2B_SENSITIVE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_SENSITIVE(
- std::string* buffer,
- TPM2B_SENSITIVE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_SENSITIVE(std::string* buffer,
+ TPM2B_SENSITIVE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_SENSITIVE Make_TPM2B_SENSITIVE(
- const TPMT_SENSITIVE& inner);
+TRUNKS_EXPORT TPM2B_SENSITIVE Make_TPM2B_SENSITIVE(const TPMT_SENSITIVE& inner);
-TRUNKS_EXPORT TPM_RC Serialize__PRIVATE(
- const _PRIVATE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize__PRIVATE(const _PRIVATE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse__PRIVATE(
- std::string* buffer,
- _PRIVATE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse__PRIVATE(std::string* buffer,
+ _PRIVATE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_PRIVATE(
- const TPM2B_PRIVATE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM2B_PRIVATE(const TPM2B_PRIVATE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_PRIVATE(
- std::string* buffer,
- TPM2B_PRIVATE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_PRIVATE(std::string* buffer,
+ TPM2B_PRIVATE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_PRIVATE Make_TPM2B_PRIVATE(
- const std::string& bytes);
-TRUNKS_EXPORT std::string StringFrom_TPM2B_PRIVATE(
- const TPM2B_PRIVATE& tpm2b);
+TRUNKS_EXPORT TPM2B_PRIVATE Make_TPM2B_PRIVATE(const std::string& bytes);
+TRUNKS_EXPORT std::string StringFrom_TPM2B_PRIVATE(const TPM2B_PRIVATE& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize__ID_OBJECT(
- const _ID_OBJECT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize__ID_OBJECT(const _ID_OBJECT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse__ID_OBJECT(
- std::string* buffer,
- _ID_OBJECT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse__ID_OBJECT(std::string* buffer,
+ _ID_OBJECT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_ID_OBJECT(
- const TPM2B_ID_OBJECT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM2B_ID_OBJECT(const TPM2B_ID_OBJECT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_ID_OBJECT(
- std::string* buffer,
- TPM2B_ID_OBJECT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_ID_OBJECT(std::string* buffer,
+ TPM2B_ID_OBJECT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_ID_OBJECT Make_TPM2B_ID_OBJECT(
- const std::string& bytes);
+TRUNKS_EXPORT TPM2B_ID_OBJECT Make_TPM2B_ID_OBJECT(const std::string& bytes);
TRUNKS_EXPORT std::string StringFrom_TPM2B_ID_OBJECT(
const TPM2B_ID_OBJECT& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_NV_PUBLIC(
- const TPMS_NV_PUBLIC& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_NV_PUBLIC(const TPMS_NV_PUBLIC& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_NV_PUBLIC(
- std::string* buffer,
- TPMS_NV_PUBLIC* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_NV_PUBLIC(std::string* buffer,
+ TPMS_NV_PUBLIC* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_NV_PUBLIC(
- const TPM2B_NV_PUBLIC& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPM2B_NV_PUBLIC(const TPM2B_NV_PUBLIC& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_NV_PUBLIC(
- std::string* buffer,
- TPM2B_NV_PUBLIC* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_NV_PUBLIC(std::string* buffer,
+ TPM2B_NV_PUBLIC* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_NV_PUBLIC Make_TPM2B_NV_PUBLIC(
- const TPMS_NV_PUBLIC& inner);
+TRUNKS_EXPORT TPM2B_NV_PUBLIC Make_TPM2B_NV_PUBLIC(const TPMS_NV_PUBLIC& inner);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_CONTEXT_SENSITIVE(
- const TPM2B_CONTEXT_SENSITIVE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPM2B_CONTEXT_SENSITIVE(const TPM2B_CONTEXT_SENSITIVE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_CONTEXT_SENSITIVE(
- std::string* buffer,
- TPM2B_CONTEXT_SENSITIVE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC
+Parse_TPM2B_CONTEXT_SENSITIVE(std::string* buffer,
+ TPM2B_CONTEXT_SENSITIVE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_CONTEXT_SENSITIVE Make_TPM2B_CONTEXT_SENSITIVE(
- const std::string& bytes);
+TRUNKS_EXPORT TPM2B_CONTEXT_SENSITIVE
+Make_TPM2B_CONTEXT_SENSITIVE(const std::string& bytes);
TRUNKS_EXPORT std::string StringFrom_TPM2B_CONTEXT_SENSITIVE(
const TPM2B_CONTEXT_SENSITIVE& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_CONTEXT_DATA(
- const TPMS_CONTEXT_DATA& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_CONTEXT_DATA(const TPMS_CONTEXT_DATA& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_CONTEXT_DATA(
- std::string* buffer,
- TPMS_CONTEXT_DATA* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_CONTEXT_DATA(std::string* buffer,
+ TPMS_CONTEXT_DATA* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_CONTEXT_DATA(
- const TPM2B_CONTEXT_DATA& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPM2B_CONTEXT_DATA(const TPM2B_CONTEXT_DATA& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_CONTEXT_DATA(
- std::string* buffer,
- TPM2B_CONTEXT_DATA* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_CONTEXT_DATA(std::string* buffer,
+ TPM2B_CONTEXT_DATA* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_CONTEXT_DATA Make_TPM2B_CONTEXT_DATA(
- const std::string& bytes);
+TRUNKS_EXPORT TPM2B_CONTEXT_DATA
+Make_TPM2B_CONTEXT_DATA(const std::string& bytes);
TRUNKS_EXPORT std::string StringFrom_TPM2B_CONTEXT_DATA(
const TPM2B_CONTEXT_DATA& tpm2b);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_CONTEXT(
- const TPMS_CONTEXT& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMS_CONTEXT(const TPMS_CONTEXT& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_CONTEXT(
- std::string* buffer,
- TPMS_CONTEXT* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_CONTEXT(std::string* buffer,
+ TPMS_CONTEXT* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMS_CREATION_DATA(
- const TPMS_CREATION_DATA& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMS_CREATION_DATA(const TPMS_CREATION_DATA& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMS_CREATION_DATA(
- std::string* buffer,
- TPMS_CREATION_DATA* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMS_CREATION_DATA(std::string* buffer,
+ TPMS_CREATION_DATA* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPM2B_CREATION_DATA(
- const TPM2B_CREATION_DATA& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPM2B_CREATION_DATA(const TPM2B_CREATION_DATA& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPM2B_CREATION_DATA(
- std::string* buffer,
- TPM2B_CREATION_DATA* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPM2B_CREATION_DATA(std::string* buffer,
+ TPM2B_CREATION_DATA* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM2B_CREATION_DATA Make_TPM2B_CREATION_DATA(
- const TPMS_CREATION_DATA& inner);
+TRUNKS_EXPORT TPM2B_CREATION_DATA
+Make_TPM2B_CREATION_DATA(const TPMS_CREATION_DATA& inner);
-TRUNKS_EXPORT TPM_RC Serialize_TPMU_HA(
- const TPMU_HA& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMU_HA(const TPMU_HA& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMU_HA(
- std::string* buffer,
- TPMU_HA* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMU_HA(std::string* buffer,
+ TPMU_HA* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMU_NAME(
- const TPMU_NAME& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMU_NAME(const TPMU_NAME& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMU_NAME(
- std::string* buffer,
- TPMU_NAME* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMU_NAME(std::string* buffer,
+ TPMU_NAME* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMU_CAPABILITIES(
- const TPMU_CAPABILITIES& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMU_CAPABILITIES(const TPMU_CAPABILITIES& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMU_CAPABILITIES(
- std::string* buffer,
- TPMU_CAPABILITIES* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMU_CAPABILITIES(std::string* buffer,
+ TPMU_CAPABILITIES* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMU_ATTEST(
- const TPMU_ATTEST& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMU_ATTEST(const TPMU_ATTEST& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMU_ATTEST(
- std::string* buffer,
- TPMU_ATTEST* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMU_ATTEST(std::string* buffer,
+ TPMU_ATTEST* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMU_SYM_KEY_BITS(
- const TPMU_SYM_KEY_BITS& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMU_SYM_KEY_BITS(const TPMU_SYM_KEY_BITS& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMU_SYM_KEY_BITS(
- std::string* buffer,
- TPMU_SYM_KEY_BITS* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMU_SYM_KEY_BITS(std::string* buffer,
+ TPMU_SYM_KEY_BITS* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMU_SYM_MODE(
- const TPMU_SYM_MODE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMU_SYM_MODE(const TPMU_SYM_MODE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMU_SYM_MODE(
- std::string* buffer,
- TPMU_SYM_MODE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMU_SYM_MODE(std::string* buffer,
+ TPMU_SYM_MODE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMU_SCHEME_KEYEDHASH(
- const TPMU_SCHEME_KEYEDHASH& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMU_SCHEME_KEYEDHASH(const TPMU_SCHEME_KEYEDHASH& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMU_SCHEME_KEYEDHASH(
- std::string* buffer,
- TPMU_SCHEME_KEYEDHASH* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMU_SCHEME_KEYEDHASH(std::string* buffer,
+ TPMU_SCHEME_KEYEDHASH* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMU_SIG_SCHEME(
- const TPMU_SIG_SCHEME& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMU_SIG_SCHEME(const TPMU_SIG_SCHEME& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMU_SIG_SCHEME(
- std::string* buffer,
- TPMU_SIG_SCHEME* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMU_SIG_SCHEME(std::string* buffer,
+ TPMU_SIG_SCHEME* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMU_KDF_SCHEME(
- const TPMU_KDF_SCHEME& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMU_KDF_SCHEME(const TPMU_KDF_SCHEME& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMU_KDF_SCHEME(
- std::string* buffer,
- TPMU_KDF_SCHEME* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMU_KDF_SCHEME(std::string* buffer,
+ TPMU_KDF_SCHEME* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMU_ASYM_SCHEME(
- const TPMU_ASYM_SCHEME& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMU_ASYM_SCHEME(const TPMU_ASYM_SCHEME& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMU_ASYM_SCHEME(
- std::string* buffer,
- TPMU_ASYM_SCHEME* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMU_ASYM_SCHEME(std::string* buffer,
+ TPMU_ASYM_SCHEME* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMU_SIGNATURE(
- const TPMU_SIGNATURE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMU_SIGNATURE(const TPMU_SIGNATURE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMU_SIGNATURE(
- std::string* buffer,
- TPMU_SIGNATURE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMU_SIGNATURE(std::string* buffer,
+ TPMU_SIGNATURE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMU_ENCRYPTED_SECRET(
- const TPMU_ENCRYPTED_SECRET& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMU_ENCRYPTED_SECRET(const TPMU_ENCRYPTED_SECRET& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMU_ENCRYPTED_SECRET(
- std::string* buffer,
- TPMU_ENCRYPTED_SECRET* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMU_ENCRYPTED_SECRET(std::string* buffer,
+ TPMU_ENCRYPTED_SECRET* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMU_PUBLIC_ID(
- const TPMU_PUBLIC_ID& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMU_PUBLIC_ID(const TPMU_PUBLIC_ID& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMU_PUBLIC_ID(
- std::string* buffer,
- TPMU_PUBLIC_ID* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMU_PUBLIC_ID(std::string* buffer,
+ TPMU_PUBLIC_ID* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMU_PUBLIC_PARMS(
- const TPMU_PUBLIC_PARMS& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMU_PUBLIC_PARMS(const TPMU_PUBLIC_PARMS& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMU_PUBLIC_PARMS(
- std::string* buffer,
- TPMU_PUBLIC_PARMS* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMU_PUBLIC_PARMS(std::string* buffer,
+ TPMU_PUBLIC_PARMS* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMU_SENSITIVE_COMPOSITE(
- const TPMU_SENSITIVE_COMPOSITE& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC
+Serialize_TPMU_SENSITIVE_COMPOSITE(const TPMU_SENSITIVE_COMPOSITE& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMU_SENSITIVE_COMPOSITE(
- std::string* buffer,
- TPMU_SENSITIVE_COMPOSITE* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC
+Parse_TPMU_SENSITIVE_COMPOSITE(std::string* buffer,
+ TPMU_SENSITIVE_COMPOSITE* value,
+ std::string* value_bytes);
-TRUNKS_EXPORT TPM_RC Serialize_TPMU_SYM_DETAILS(
- const TPMU_SYM_DETAILS& value,
- std::string* buffer);
+TRUNKS_EXPORT TPM_RC Serialize_TPMU_SYM_DETAILS(const TPMU_SYM_DETAILS& value,
+ std::string* buffer);
-TRUNKS_EXPORT TPM_RC Parse_TPMU_SYM_DETAILS(
- std::string* buffer,
- TPMU_SYM_DETAILS* value,
- std::string* value_bytes);
+TRUNKS_EXPORT TPM_RC Parse_TPMU_SYM_DETAILS(std::string* buffer,
+ TPMU_SYM_DETAILS* value,
+ std::string* value_bytes);
class TRUNKS_EXPORT Tpm {
public:
@@ -3733,8 +3346,7 @@
explicit Tpm(CommandTransceiver* transceiver) : transceiver_(transceiver) {}
virtual ~Tpm() {}
- typedef base::Callback<void(
- TPM_RC response_code)> StartupResponse;
+ typedef base::Callback<void(TPM_RC response_code)> StartupResponse;
static TPM_RC SerializeCommand_Startup(
const TPM_SU& startup_type,
std::string* serialized_command,
@@ -3742,15 +3354,12 @@
static TPM_RC ParseResponse_Startup(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void Startup(
- const TPM_SU& startup_type,
- AuthorizationDelegate* authorization_delegate,
- const StartupResponse& callback);
- virtual TPM_RC StartupSync(
- const TPM_SU& startup_type,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> ShutdownResponse;
+ virtual void Startup(const TPM_SU& startup_type,
+ AuthorizationDelegate* authorization_delegate,
+ const StartupResponse& callback);
+ virtual TPM_RC StartupSync(const TPM_SU& startup_type,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> ShutdownResponse;
static TPM_RC SerializeCommand_Shutdown(
const TPM_SU& shutdown_type,
std::string* serialized_command,
@@ -3758,15 +3367,12 @@
static TPM_RC ParseResponse_Shutdown(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void Shutdown(
- const TPM_SU& shutdown_type,
- AuthorizationDelegate* authorization_delegate,
- const ShutdownResponse& callback);
- virtual TPM_RC ShutdownSync(
- const TPM_SU& shutdown_type,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> SelfTestResponse;
+ virtual void Shutdown(const TPM_SU& shutdown_type,
+ AuthorizationDelegate* authorization_delegate,
+ const ShutdownResponse& callback);
+ virtual TPM_RC ShutdownSync(const TPM_SU& shutdown_type,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> SelfTestResponse;
static TPM_RC SerializeCommand_SelfTest(
const TPMI_YES_NO& full_test,
std::string* serialized_command,
@@ -3774,16 +3380,13 @@
static TPM_RC ParseResponse_SelfTest(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void SelfTest(
- const TPMI_YES_NO& full_test,
- AuthorizationDelegate* authorization_delegate,
- const SelfTestResponse& callback);
- virtual TPM_RC SelfTestSync(
- const TPMI_YES_NO& full_test,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPML_ALG& to_do_list)> IncrementalSelfTestResponse;
+ virtual void SelfTest(const TPMI_YES_NO& full_test,
+ AuthorizationDelegate* authorization_delegate,
+ const SelfTestResponse& callback);
+ virtual TPM_RC SelfTestSync(const TPMI_YES_NO& full_test,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code, const TPML_ALG& to_do_list)>
+ IncrementalSelfTestResponse;
static TPM_RC SerializeCommand_IncrementalSelfTest(
const TPML_ALG& to_test,
std::string* serialized_command,
@@ -3800,10 +3403,10 @@
const TPML_ALG& to_test,
TPML_ALG* to_do_list,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_MAX_BUFFER& out_data,
- const TPM_RC& test_result)> GetTestResultResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_MAX_BUFFER& out_data,
+ const TPM_RC& test_result)>
+ GetTestResultResponse;
static TPM_RC SerializeCommand_GetTestResult(
std::string* serialized_command,
AuthorizationDelegate* authorization_delegate);
@@ -3812,17 +3415,16 @@
TPM2B_MAX_BUFFER* out_data,
TPM_RC* test_result,
AuthorizationDelegate* authorization_delegate);
- virtual void GetTestResult(
- AuthorizationDelegate* authorization_delegate,
- const GetTestResultResponse& callback);
+ virtual void GetTestResult(AuthorizationDelegate* authorization_delegate,
+ const GetTestResultResponse& callback);
virtual TPM_RC GetTestResultSync(
TPM2B_MAX_BUFFER* out_data,
TPM_RC* test_result,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPMI_SH_AUTH_SESSION& session_handle,
- const TPM2B_NONCE& nonce_tpm)> StartAuthSessionResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPMI_SH_AUTH_SESSION& session_handle,
+ const TPM2B_NONCE& nonce_tpm)>
+ StartAuthSessionResponse;
static TPM_RC SerializeCommand_StartAuthSession(
const TPMI_DH_OBJECT& tpm_key,
const std::string& tpm_key_name,
@@ -3840,18 +3442,17 @@
TPMI_SH_AUTH_SESSION* session_handle,
TPM2B_NONCE* nonce_tpm,
AuthorizationDelegate* authorization_delegate);
- virtual void StartAuthSession(
- const TPMI_DH_OBJECT& tpm_key,
- const std::string& tpm_key_name,
- const TPMI_DH_ENTITY& bind,
- const std::string& bind_name,
- const TPM2B_NONCE& nonce_caller,
- const TPM2B_ENCRYPTED_SECRET& encrypted_salt,
- const TPM_SE& session_type,
- const TPMT_SYM_DEF& symmetric,
- const TPMI_ALG_HASH& auth_hash,
- AuthorizationDelegate* authorization_delegate,
- const StartAuthSessionResponse& callback);
+ virtual void StartAuthSession(const TPMI_DH_OBJECT& tpm_key,
+ const std::string& tpm_key_name,
+ const TPMI_DH_ENTITY& bind,
+ const std::string& bind_name,
+ const TPM2B_NONCE& nonce_caller,
+ const TPM2B_ENCRYPTED_SECRET& encrypted_salt,
+ const TPM_SE& session_type,
+ const TPMT_SYM_DEF& symmetric,
+ const TPMI_ALG_HASH& auth_hash,
+ AuthorizationDelegate* authorization_delegate,
+ const StartAuthSessionResponse& callback);
virtual TPM_RC StartAuthSessionSync(
const TPMI_DH_OBJECT& tpm_key,
const std::string& tpm_key_name,
@@ -3865,8 +3466,7 @@
TPMI_SH_AUTH_SESSION* session_handle,
TPM2B_NONCE* nonce_tpm,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PolicyRestartResponse;
+ typedef base::Callback<void(TPM_RC response_code)> PolicyRestartResponse;
static TPM_RC SerializeCommand_PolicyRestart(
const TPMI_SH_POLICY& session_handle,
const std::string& session_handle_name,
@@ -3875,22 +3475,21 @@
static TPM_RC ParseResponse_PolicyRestart(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PolicyRestart(
- const TPMI_SH_POLICY& session_handle,
- const std::string& session_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const PolicyRestartResponse& callback);
+ virtual void PolicyRestart(const TPMI_SH_POLICY& session_handle,
+ const std::string& session_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyRestartResponse& callback);
virtual TPM_RC PolicyRestartSync(
const TPMI_SH_POLICY& session_handle,
const std::string& session_handle_name,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_PRIVATE& out_private,
- const TPM2B_PUBLIC& out_public,
- const TPM2B_CREATION_DATA& creation_data,
- const TPM2B_DIGEST& creation_hash,
- const TPMT_TK_CREATION& creation_ticket)> CreateResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_PRIVATE& out_private,
+ const TPM2B_PUBLIC& out_public,
+ const TPM2B_CREATION_DATA& creation_data,
+ const TPM2B_DIGEST& creation_hash,
+ const TPMT_TK_CREATION& creation_ticket)>
+ CreateResponse;
static TPM_RC SerializeCommand_Create(
const TPMI_DH_OBJECT& parent_handle,
const std::string& parent_handle_name,
@@ -3908,32 +3507,30 @@
TPM2B_DIGEST* creation_hash,
TPMT_TK_CREATION* creation_ticket,
AuthorizationDelegate* authorization_delegate);
- virtual void Create(
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_SENSITIVE_CREATE& in_sensitive,
- const TPM2B_PUBLIC& in_public,
- const TPM2B_DATA& outside_info,
- const TPML_PCR_SELECTION& creation_pcr,
- AuthorizationDelegate* authorization_delegate,
- const CreateResponse& callback);
- virtual TPM_RC CreateSync(
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_SENSITIVE_CREATE& in_sensitive,
- const TPM2B_PUBLIC& in_public,
- const TPM2B_DATA& outside_info,
- const TPML_PCR_SELECTION& creation_pcr,
- TPM2B_PRIVATE* out_private,
- TPM2B_PUBLIC* out_public,
- TPM2B_CREATION_DATA* creation_data,
- TPM2B_DIGEST* creation_hash,
- TPMT_TK_CREATION* creation_ticket,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM_HANDLE& object_handle,
- const TPM2B_NAME& name)> LoadResponse;
+ virtual void Create(const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_SENSITIVE_CREATE& in_sensitive,
+ const TPM2B_PUBLIC& in_public,
+ const TPM2B_DATA& outside_info,
+ const TPML_PCR_SELECTION& creation_pcr,
+ AuthorizationDelegate* authorization_delegate,
+ const CreateResponse& callback);
+ virtual TPM_RC CreateSync(const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_SENSITIVE_CREATE& in_sensitive,
+ const TPM2B_PUBLIC& in_public,
+ const TPM2B_DATA& outside_info,
+ const TPML_PCR_SELECTION& creation_pcr,
+ TPM2B_PRIVATE* out_private,
+ TPM2B_PUBLIC* out_public,
+ TPM2B_CREATION_DATA* creation_data,
+ TPM2B_DIGEST* creation_hash,
+ TPMT_TK_CREATION* creation_ticket,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM_HANDLE& object_handle,
+ const TPM2B_NAME& name)>
+ LoadResponse;
static TPM_RC SerializeCommand_Load(
const TPMI_DH_OBJECT& parent_handle,
const std::string& parent_handle_name,
@@ -3946,25 +3543,23 @@
TPM_HANDLE* object_handle,
TPM2B_NAME* name,
AuthorizationDelegate* authorization_delegate);
- virtual void Load(
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_PRIVATE& in_private,
- const TPM2B_PUBLIC& in_public,
- AuthorizationDelegate* authorization_delegate,
- const LoadResponse& callback);
- virtual TPM_RC LoadSync(
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_PRIVATE& in_private,
- const TPM2B_PUBLIC& in_public,
- TPM_HANDLE* object_handle,
- TPM2B_NAME* name,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM_HANDLE& object_handle,
- const TPM2B_NAME& name)> LoadExternalResponse;
+ virtual void Load(const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_PRIVATE& in_private,
+ const TPM2B_PUBLIC& in_public,
+ AuthorizationDelegate* authorization_delegate,
+ const LoadResponse& callback);
+ virtual TPM_RC LoadSync(const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_PRIVATE& in_private,
+ const TPM2B_PUBLIC& in_public,
+ TPM_HANDLE* object_handle,
+ TPM2B_NAME* name,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM_HANDLE& object_handle,
+ const TPM2B_NAME& name)>
+ LoadExternalResponse;
static TPM_RC SerializeCommand_LoadExternal(
const TPM2B_SENSITIVE& in_private,
const TPM2B_PUBLIC& in_public,
@@ -3976,12 +3571,11 @@
TPM_HANDLE* object_handle,
TPM2B_NAME* name,
AuthorizationDelegate* authorization_delegate);
- virtual void LoadExternal(
- const TPM2B_SENSITIVE& in_private,
- const TPM2B_PUBLIC& in_public,
- const TPMI_RH_HIERARCHY& hierarchy,
- AuthorizationDelegate* authorization_delegate,
- const LoadExternalResponse& callback);
+ virtual void LoadExternal(const TPM2B_SENSITIVE& in_private,
+ const TPM2B_PUBLIC& in_public,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ AuthorizationDelegate* authorization_delegate,
+ const LoadExternalResponse& callback);
virtual TPM_RC LoadExternalSync(
const TPM2B_SENSITIVE& in_private,
const TPM2B_PUBLIC& in_public,
@@ -3989,11 +3583,11 @@
TPM_HANDLE* object_handle,
TPM2B_NAME* name,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_PUBLIC& out_public,
- const TPM2B_NAME& name,
- const TPM2B_NAME& qualified_name)> ReadPublicResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_PUBLIC& out_public,
+ const TPM2B_NAME& name,
+ const TPM2B_NAME& qualified_name)>
+ ReadPublicResponse;
static TPM_RC SerializeCommand_ReadPublic(
const TPMI_DH_OBJECT& object_handle,
const std::string& object_handle_name,
@@ -4005,21 +3599,19 @@
TPM2B_NAME* name,
TPM2B_NAME* qualified_name,
AuthorizationDelegate* authorization_delegate);
- virtual void ReadPublic(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const ReadPublicResponse& callback);
- virtual TPM_RC ReadPublicSync(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- TPM2B_PUBLIC* out_public,
- TPM2B_NAME* name,
- TPM2B_NAME* qualified_name,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_DIGEST& cert_info)> ActivateCredentialResponse;
+ virtual void ReadPublic(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const ReadPublicResponse& callback);
+ virtual TPM_RC ReadPublicSync(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ TPM2B_PUBLIC* out_public,
+ TPM2B_NAME* name,
+ TPM2B_NAME* qualified_name,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_DIGEST& cert_info)>
+ ActivateCredentialResponse;
static TPM_RC SerializeCommand_ActivateCredential(
const TPMI_DH_OBJECT& activate_handle,
const std::string& activate_handle_name,
@@ -4033,15 +3625,14 @@
const std::string& response,
TPM2B_DIGEST* cert_info,
AuthorizationDelegate* authorization_delegate);
- virtual void ActivateCredential(
- const TPMI_DH_OBJECT& activate_handle,
- const std::string& activate_handle_name,
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_ID_OBJECT& credential_blob,
- const TPM2B_ENCRYPTED_SECRET& secret,
- AuthorizationDelegate* authorization_delegate,
- const ActivateCredentialResponse& callback);
+ virtual void ActivateCredential(const TPMI_DH_OBJECT& activate_handle,
+ const std::string& activate_handle_name,
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_ID_OBJECT& credential_blob,
+ const TPM2B_ENCRYPTED_SECRET& secret,
+ AuthorizationDelegate* authorization_delegate,
+ const ActivateCredentialResponse& callback);
virtual TPM_RC ActivateCredentialSync(
const TPMI_DH_OBJECT& activate_handle,
const std::string& activate_handle_name,
@@ -4051,10 +3642,10 @@
const TPM2B_ENCRYPTED_SECRET& secret,
TPM2B_DIGEST* cert_info,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_ID_OBJECT& credential_blob,
- const TPM2B_ENCRYPTED_SECRET& secret)> MakeCredentialResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_ID_OBJECT& credential_blob,
+ const TPM2B_ENCRYPTED_SECRET& secret)>
+ MakeCredentialResponse;
static TPM_RC SerializeCommand_MakeCredential(
const TPMI_DH_OBJECT& handle,
const std::string& handle_name,
@@ -4067,13 +3658,12 @@
TPM2B_ID_OBJECT* credential_blob,
TPM2B_ENCRYPTED_SECRET* secret,
AuthorizationDelegate* authorization_delegate);
- virtual void MakeCredential(
- const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_DIGEST& credential,
- const TPM2B_NAME& object_name,
- AuthorizationDelegate* authorization_delegate,
- const MakeCredentialResponse& callback);
+ virtual void MakeCredential(const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_DIGEST& credential,
+ const TPM2B_NAME& object_name,
+ AuthorizationDelegate* authorization_delegate,
+ const MakeCredentialResponse& callback);
virtual TPM_RC MakeCredentialSync(
const TPMI_DH_OBJECT& handle,
const std::string& handle_name,
@@ -4082,9 +3672,9 @@
TPM2B_ID_OBJECT* credential_blob,
TPM2B_ENCRYPTED_SECRET* secret,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_SENSITIVE_DATA& out_data)> UnsealResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_SENSITIVE_DATA& out_data)>
+ UnsealResponse;
static TPM_RC SerializeCommand_Unseal(
const TPMI_DH_OBJECT& item_handle,
const std::string& item_handle_name,
@@ -4094,19 +3684,17 @@
const std::string& response,
TPM2B_SENSITIVE_DATA* out_data,
AuthorizationDelegate* authorization_delegate);
- virtual void Unseal(
- const TPMI_DH_OBJECT& item_handle,
- const std::string& item_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const UnsealResponse& callback);
- virtual TPM_RC UnsealSync(
- const TPMI_DH_OBJECT& item_handle,
- const std::string& item_handle_name,
- TPM2B_SENSITIVE_DATA* out_data,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_PRIVATE& out_private)> ObjectChangeAuthResponse;
+ virtual void Unseal(const TPMI_DH_OBJECT& item_handle,
+ const std::string& item_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const UnsealResponse& callback);
+ virtual TPM_RC UnsealSync(const TPMI_DH_OBJECT& item_handle,
+ const std::string& item_handle_name,
+ TPM2B_SENSITIVE_DATA* out_data,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_PRIVATE& out_private)>
+ ObjectChangeAuthResponse;
static TPM_RC SerializeCommand_ObjectChangeAuth(
const TPMI_DH_OBJECT& object_handle,
const std::string& object_handle_name,
@@ -4119,14 +3707,13 @@
const std::string& response,
TPM2B_PRIVATE* out_private,
AuthorizationDelegate* authorization_delegate);
- virtual void ObjectChangeAuth(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_AUTH& new_auth,
- AuthorizationDelegate* authorization_delegate,
- const ObjectChangeAuthResponse& callback);
+ virtual void ObjectChangeAuth(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_AUTH& new_auth,
+ AuthorizationDelegate* authorization_delegate,
+ const ObjectChangeAuthResponse& callback);
virtual TPM_RC ObjectChangeAuthSync(
const TPMI_DH_OBJECT& object_handle,
const std::string& object_handle_name,
@@ -4135,11 +3722,11 @@
const TPM2B_AUTH& new_auth,
TPM2B_PRIVATE* out_private,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_DATA& encryption_key_out,
- const TPM2B_PRIVATE& duplicate,
- const TPM2B_ENCRYPTED_SECRET& out_sym_seed)> DuplicateResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_DATA& encryption_key_out,
+ const TPM2B_PRIVATE& duplicate,
+ const TPM2B_ENCRYPTED_SECRET& out_sym_seed)>
+ DuplicateResponse;
static TPM_RC SerializeCommand_Duplicate(
const TPMI_DH_OBJECT& object_handle,
const std::string& object_handle_name,
@@ -4155,30 +3742,28 @@
TPM2B_PRIVATE* duplicate,
TPM2B_ENCRYPTED_SECRET* out_sym_seed,
AuthorizationDelegate* authorization_delegate);
- virtual void Duplicate(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& new_parent_handle,
- const std::string& new_parent_handle_name,
- const TPM2B_DATA& encryption_key_in,
- const TPMT_SYM_DEF_OBJECT& symmetric_alg,
- AuthorizationDelegate* authorization_delegate,
- const DuplicateResponse& callback);
- virtual TPM_RC DuplicateSync(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& new_parent_handle,
- const std::string& new_parent_handle_name,
- const TPM2B_DATA& encryption_key_in,
- const TPMT_SYM_DEF_OBJECT& symmetric_alg,
- TPM2B_DATA* encryption_key_out,
- TPM2B_PRIVATE* duplicate,
- TPM2B_ENCRYPTED_SECRET* out_sym_seed,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_PRIVATE& out_duplicate,
- const TPM2B_ENCRYPTED_SECRET& out_sym_seed)> RewrapResponse;
+ virtual void Duplicate(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& new_parent_handle,
+ const std::string& new_parent_handle_name,
+ const TPM2B_DATA& encryption_key_in,
+ const TPMT_SYM_DEF_OBJECT& symmetric_alg,
+ AuthorizationDelegate* authorization_delegate,
+ const DuplicateResponse& callback);
+ virtual TPM_RC DuplicateSync(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& new_parent_handle,
+ const std::string& new_parent_handle_name,
+ const TPM2B_DATA& encryption_key_in,
+ const TPMT_SYM_DEF_OBJECT& symmetric_alg,
+ TPM2B_DATA* encryption_key_out,
+ TPM2B_PRIVATE* duplicate,
+ TPM2B_ENCRYPTED_SECRET* out_sym_seed,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_PRIVATE& out_duplicate,
+ const TPM2B_ENCRYPTED_SECRET& out_sym_seed)>
+ RewrapResponse;
static TPM_RC SerializeCommand_Rewrap(
const TPMI_DH_OBJECT& old_parent,
const std::string& old_parent_name,
@@ -4194,30 +3779,28 @@
TPM2B_PRIVATE* out_duplicate,
TPM2B_ENCRYPTED_SECRET* out_sym_seed,
AuthorizationDelegate* authorization_delegate);
- virtual void Rewrap(
- const TPMI_DH_OBJECT& old_parent,
- const std::string& old_parent_name,
- const TPMI_DH_OBJECT& new_parent,
- const std::string& new_parent_name,
- const TPM2B_PRIVATE& in_duplicate,
- const TPM2B_NAME& name,
- const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
- AuthorizationDelegate* authorization_delegate,
- const RewrapResponse& callback);
- virtual TPM_RC RewrapSync(
- const TPMI_DH_OBJECT& old_parent,
- const std::string& old_parent_name,
- const TPMI_DH_OBJECT& new_parent,
- const std::string& new_parent_name,
- const TPM2B_PRIVATE& in_duplicate,
- const TPM2B_NAME& name,
- const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
- TPM2B_PRIVATE* out_duplicate,
- TPM2B_ENCRYPTED_SECRET* out_sym_seed,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_PRIVATE& out_private)> ImportResponse;
+ virtual void Rewrap(const TPMI_DH_OBJECT& old_parent,
+ const std::string& old_parent_name,
+ const TPMI_DH_OBJECT& new_parent,
+ const std::string& new_parent_name,
+ const TPM2B_PRIVATE& in_duplicate,
+ const TPM2B_NAME& name,
+ const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
+ AuthorizationDelegate* authorization_delegate,
+ const RewrapResponse& callback);
+ virtual TPM_RC RewrapSync(const TPMI_DH_OBJECT& old_parent,
+ const std::string& old_parent_name,
+ const TPMI_DH_OBJECT& new_parent,
+ const std::string& new_parent_name,
+ const TPM2B_PRIVATE& in_duplicate,
+ const TPM2B_NAME& name,
+ const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
+ TPM2B_PRIVATE* out_duplicate,
+ TPM2B_ENCRYPTED_SECRET* out_sym_seed,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_PRIVATE& out_private)>
+ ImportResponse;
static TPM_RC SerializeCommand_Import(
const TPMI_DH_OBJECT& parent_handle,
const std::string& parent_handle_name,
@@ -4232,29 +3815,27 @@
const std::string& response,
TPM2B_PRIVATE* out_private,
AuthorizationDelegate* authorization_delegate);
- virtual void Import(
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_DATA& encryption_key,
- const TPM2B_PUBLIC& object_public,
- const TPM2B_PRIVATE& duplicate,
- const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
- const TPMT_SYM_DEF_OBJECT& symmetric_alg,
- AuthorizationDelegate* authorization_delegate,
- const ImportResponse& callback);
- virtual TPM_RC ImportSync(
- const TPMI_DH_OBJECT& parent_handle,
- const std::string& parent_handle_name,
- const TPM2B_DATA& encryption_key,
- const TPM2B_PUBLIC& object_public,
- const TPM2B_PRIVATE& duplicate,
- const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
- const TPMT_SYM_DEF_OBJECT& symmetric_alg,
- TPM2B_PRIVATE* out_private,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_PUBLIC_KEY_RSA& out_data)> RSA_EncryptResponse;
+ virtual void Import(const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_DATA& encryption_key,
+ const TPM2B_PUBLIC& object_public,
+ const TPM2B_PRIVATE& duplicate,
+ const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
+ const TPMT_SYM_DEF_OBJECT& symmetric_alg,
+ AuthorizationDelegate* authorization_delegate,
+ const ImportResponse& callback);
+ virtual TPM_RC ImportSync(const TPMI_DH_OBJECT& parent_handle,
+ const std::string& parent_handle_name,
+ const TPM2B_DATA& encryption_key,
+ const TPM2B_PUBLIC& object_public,
+ const TPM2B_PRIVATE& duplicate,
+ const TPM2B_ENCRYPTED_SECRET& in_sym_seed,
+ const TPMT_SYM_DEF_OBJECT& symmetric_alg,
+ TPM2B_PRIVATE* out_private,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_PUBLIC_KEY_RSA& out_data)>
+ RSA_EncryptResponse;
static TPM_RC SerializeCommand_RSA_Encrypt(
const TPMI_DH_OBJECT& key_handle,
const std::string& key_handle_name,
@@ -4267,25 +3848,23 @@
const std::string& response,
TPM2B_PUBLIC_KEY_RSA* out_data,
AuthorizationDelegate* authorization_delegate);
- virtual void RSA_Encrypt(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_PUBLIC_KEY_RSA& message,
- const TPMT_RSA_DECRYPT& in_scheme,
- const TPM2B_DATA& label,
- AuthorizationDelegate* authorization_delegate,
- const RSA_EncryptResponse& callback);
- virtual TPM_RC RSA_EncryptSync(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_PUBLIC_KEY_RSA& message,
- const TPMT_RSA_DECRYPT& in_scheme,
- const TPM2B_DATA& label,
- TPM2B_PUBLIC_KEY_RSA* out_data,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_PUBLIC_KEY_RSA& message)> RSA_DecryptResponse;
+ virtual void RSA_Encrypt(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_PUBLIC_KEY_RSA& message,
+ const TPMT_RSA_DECRYPT& in_scheme,
+ const TPM2B_DATA& label,
+ AuthorizationDelegate* authorization_delegate,
+ const RSA_EncryptResponse& callback);
+ virtual TPM_RC RSA_EncryptSync(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_PUBLIC_KEY_RSA& message,
+ const TPMT_RSA_DECRYPT& in_scheme,
+ const TPM2B_DATA& label,
+ TPM2B_PUBLIC_KEY_RSA* out_data,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_PUBLIC_KEY_RSA& message)>
+ RSA_DecryptResponse;
static TPM_RC SerializeCommand_RSA_Decrypt(
const TPMI_DH_OBJECT& key_handle,
const std::string& key_handle_name,
@@ -4298,26 +3877,24 @@
const std::string& response,
TPM2B_PUBLIC_KEY_RSA* message,
AuthorizationDelegate* authorization_delegate);
- virtual void RSA_Decrypt(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_PUBLIC_KEY_RSA& cipher_text,
- const TPMT_RSA_DECRYPT& in_scheme,
- const TPM2B_DATA& label,
- AuthorizationDelegate* authorization_delegate,
- const RSA_DecryptResponse& callback);
- virtual TPM_RC RSA_DecryptSync(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_PUBLIC_KEY_RSA& cipher_text,
- const TPMT_RSA_DECRYPT& in_scheme,
- const TPM2B_DATA& label,
- TPM2B_PUBLIC_KEY_RSA* message,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_ECC_POINT& z_point,
- const TPM2B_ECC_POINT& pub_point)> ECDH_KeyGenResponse;
+ virtual void RSA_Decrypt(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_PUBLIC_KEY_RSA& cipher_text,
+ const TPMT_RSA_DECRYPT& in_scheme,
+ const TPM2B_DATA& label,
+ AuthorizationDelegate* authorization_delegate,
+ const RSA_DecryptResponse& callback);
+ virtual TPM_RC RSA_DecryptSync(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_PUBLIC_KEY_RSA& cipher_text,
+ const TPMT_RSA_DECRYPT& in_scheme,
+ const TPM2B_DATA& label,
+ TPM2B_PUBLIC_KEY_RSA* message,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_ECC_POINT& z_point,
+ const TPM2B_ECC_POINT& pub_point)>
+ ECDH_KeyGenResponse;
static TPM_RC SerializeCommand_ECDH_KeyGen(
const TPMI_DH_OBJECT& key_handle,
const std::string& key_handle_name,
@@ -4328,20 +3905,18 @@
TPM2B_ECC_POINT* z_point,
TPM2B_ECC_POINT* pub_point,
AuthorizationDelegate* authorization_delegate);
- virtual void ECDH_KeyGen(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const ECDH_KeyGenResponse& callback);
- virtual TPM_RC ECDH_KeyGenSync(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- TPM2B_ECC_POINT* z_point,
- TPM2B_ECC_POINT* pub_point,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_ECC_POINT& out_point)> ECDH_ZGenResponse;
+ virtual void ECDH_KeyGen(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const ECDH_KeyGenResponse& callback);
+ virtual TPM_RC ECDH_KeyGenSync(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ TPM2B_ECC_POINT* z_point,
+ TPM2B_ECC_POINT* pub_point,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_ECC_POINT& out_point)>
+ ECDH_ZGenResponse;
static TPM_RC SerializeCommand_ECDH_ZGen(
const TPMI_DH_OBJECT& key_handle,
const std::string& key_handle_name,
@@ -4352,21 +3927,19 @@
const std::string& response,
TPM2B_ECC_POINT* out_point,
AuthorizationDelegate* authorization_delegate);
- virtual void ECDH_ZGen(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_ECC_POINT& in_point,
- AuthorizationDelegate* authorization_delegate,
- const ECDH_ZGenResponse& callback);
- virtual TPM_RC ECDH_ZGenSync(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_ECC_POINT& in_point,
- TPM2B_ECC_POINT* out_point,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPMS_ALGORITHM_DETAIL_ECC& parameters)> ECC_ParametersResponse;
+ virtual void ECDH_ZGen(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_ECC_POINT& in_point,
+ AuthorizationDelegate* authorization_delegate,
+ const ECDH_ZGenResponse& callback);
+ virtual TPM_RC ECDH_ZGenSync(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_ECC_POINT& in_point,
+ TPM2B_ECC_POINT* out_point,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPMS_ALGORITHM_DETAIL_ECC& parameters)>
+ ECC_ParametersResponse;
static TPM_RC SerializeCommand_ECC_Parameters(
const TPMI_ECC_CURVE& curve_id,
std::string* serialized_command,
@@ -4375,18 +3948,17 @@
const std::string& response,
TPMS_ALGORITHM_DETAIL_ECC* parameters,
AuthorizationDelegate* authorization_delegate);
- virtual void ECC_Parameters(
- const TPMI_ECC_CURVE& curve_id,
- AuthorizationDelegate* authorization_delegate,
- const ECC_ParametersResponse& callback);
+ virtual void ECC_Parameters(const TPMI_ECC_CURVE& curve_id,
+ AuthorizationDelegate* authorization_delegate,
+ const ECC_ParametersResponse& callback);
virtual TPM_RC ECC_ParametersSync(
const TPMI_ECC_CURVE& curve_id,
TPMS_ALGORITHM_DETAIL_ECC* parameters,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_ECC_POINT& out_z1,
- const TPM2B_ECC_POINT& out_z2)> ZGen_2PhaseResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_ECC_POINT& out_z1,
+ const TPM2B_ECC_POINT& out_z2)>
+ ZGen_2PhaseResponse;
static TPM_RC SerializeCommand_ZGen_2Phase(
const TPMI_DH_OBJECT& key_a,
const std::string& key_a_name,
@@ -4401,29 +3973,27 @@
TPM2B_ECC_POINT* out_z1,
TPM2B_ECC_POINT* out_z2,
AuthorizationDelegate* authorization_delegate);
- virtual void ZGen_2Phase(
- const TPMI_DH_OBJECT& key_a,
- const std::string& key_a_name,
- const TPM2B_ECC_POINT& in_qs_b,
- const TPM2B_ECC_POINT& in_qe_b,
- const TPMI_ECC_KEY_EXCHANGE& in_scheme,
- const UINT16& counter,
- AuthorizationDelegate* authorization_delegate,
- const ZGen_2PhaseResponse& callback);
- virtual TPM_RC ZGen_2PhaseSync(
- const TPMI_DH_OBJECT& key_a,
- const std::string& key_a_name,
- const TPM2B_ECC_POINT& in_qs_b,
- const TPM2B_ECC_POINT& in_qe_b,
- const TPMI_ECC_KEY_EXCHANGE& in_scheme,
- const UINT16& counter,
- TPM2B_ECC_POINT* out_z1,
- TPM2B_ECC_POINT* out_z2,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_MAX_BUFFER& out_data,
- const TPM2B_IV& iv_out)> EncryptDecryptResponse;
+ virtual void ZGen_2Phase(const TPMI_DH_OBJECT& key_a,
+ const std::string& key_a_name,
+ const TPM2B_ECC_POINT& in_qs_b,
+ const TPM2B_ECC_POINT& in_qe_b,
+ const TPMI_ECC_KEY_EXCHANGE& in_scheme,
+ const UINT16& counter,
+ AuthorizationDelegate* authorization_delegate,
+ const ZGen_2PhaseResponse& callback);
+ virtual TPM_RC ZGen_2PhaseSync(const TPMI_DH_OBJECT& key_a,
+ const std::string& key_a_name,
+ const TPM2B_ECC_POINT& in_qs_b,
+ const TPM2B_ECC_POINT& in_qe_b,
+ const TPMI_ECC_KEY_EXCHANGE& in_scheme,
+ const UINT16& counter,
+ TPM2B_ECC_POINT* out_z1,
+ TPM2B_ECC_POINT* out_z2,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_MAX_BUFFER& out_data,
+ const TPM2B_IV& iv_out)>
+ EncryptDecryptResponse;
static TPM_RC SerializeCommand_EncryptDecrypt(
const TPMI_DH_OBJECT& key_handle,
const std::string& key_handle_name,
@@ -4438,15 +4008,14 @@
TPM2B_MAX_BUFFER* out_data,
TPM2B_IV* iv_out,
AuthorizationDelegate* authorization_delegate);
- virtual void EncryptDecrypt(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPMI_YES_NO& decrypt,
- const TPMI_ALG_SYM_MODE& mode,
- const TPM2B_IV& iv_in,
- const TPM2B_MAX_BUFFER& in_data,
- AuthorizationDelegate* authorization_delegate,
- const EncryptDecryptResponse& callback);
+ virtual void EncryptDecrypt(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPMI_YES_NO& decrypt,
+ const TPMI_ALG_SYM_MODE& mode,
+ const TPM2B_IV& iv_in,
+ const TPM2B_MAX_BUFFER& in_data,
+ AuthorizationDelegate* authorization_delegate,
+ const EncryptDecryptResponse& callback);
virtual TPM_RC EncryptDecryptSync(
const TPMI_DH_OBJECT& key_handle,
const std::string& key_handle_name,
@@ -4457,10 +4026,10 @@
TPM2B_MAX_BUFFER* out_data,
TPM2B_IV* iv_out,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_DIGEST& out_hash,
- const TPMT_TK_HASHCHECK& validation)> HashResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_DIGEST& out_hash,
+ const TPMT_TK_HASHCHECK& validation)>
+ HashResponse;
static TPM_RC SerializeCommand_Hash(
const TPM2B_MAX_BUFFER& data,
const TPMI_ALG_HASH& hash_alg,
@@ -4472,22 +4041,20 @@
TPM2B_DIGEST* out_hash,
TPMT_TK_HASHCHECK* validation,
AuthorizationDelegate* authorization_delegate);
- virtual void Hash(
- const TPM2B_MAX_BUFFER& data,
- const TPMI_ALG_HASH& hash_alg,
- const TPMI_RH_HIERARCHY& hierarchy,
- AuthorizationDelegate* authorization_delegate,
- const HashResponse& callback);
- virtual TPM_RC HashSync(
- const TPM2B_MAX_BUFFER& data,
- const TPMI_ALG_HASH& hash_alg,
- const TPMI_RH_HIERARCHY& hierarchy,
- TPM2B_DIGEST* out_hash,
- TPMT_TK_HASHCHECK* validation,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_DIGEST& out_hmac)> HMACResponse;
+ virtual void Hash(const TPM2B_MAX_BUFFER& data,
+ const TPMI_ALG_HASH& hash_alg,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ AuthorizationDelegate* authorization_delegate,
+ const HashResponse& callback);
+ virtual TPM_RC HashSync(const TPM2B_MAX_BUFFER& data,
+ const TPMI_ALG_HASH& hash_alg,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ TPM2B_DIGEST* out_hash,
+ TPMT_TK_HASHCHECK* validation,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_DIGEST& out_hmac)>
+ HMACResponse;
static TPM_RC SerializeCommand_HMAC(
const TPMI_DH_OBJECT& handle,
const std::string& handle_name,
@@ -4499,23 +4066,21 @@
const std::string& response,
TPM2B_DIGEST* out_hmac,
AuthorizationDelegate* authorization_delegate);
- virtual void HMAC(
- const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- const TPMI_ALG_HASH& hash_alg,
- AuthorizationDelegate* authorization_delegate,
- const HMACResponse& callback);
- virtual TPM_RC HMACSync(
- const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- const TPMI_ALG_HASH& hash_alg,
- TPM2B_DIGEST* out_hmac,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_DIGEST& random_bytes)> GetRandomResponse;
+ virtual void HMAC(const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ const TPMI_ALG_HASH& hash_alg,
+ AuthorizationDelegate* authorization_delegate,
+ const HMACResponse& callback);
+ virtual TPM_RC HMACSync(const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ const TPMI_ALG_HASH& hash_alg,
+ TPM2B_DIGEST* out_hmac,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_DIGEST& random_bytes)>
+ GetRandomResponse;
static TPM_RC SerializeCommand_GetRandom(
const UINT16& bytes_requested,
std::string* serialized_command,
@@ -4524,16 +4089,13 @@
const std::string& response,
TPM2B_DIGEST* random_bytes,
AuthorizationDelegate* authorization_delegate);
- virtual void GetRandom(
- const UINT16& bytes_requested,
- AuthorizationDelegate* authorization_delegate,
- const GetRandomResponse& callback);
- virtual TPM_RC GetRandomSync(
- const UINT16& bytes_requested,
- TPM2B_DIGEST* random_bytes,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> StirRandomResponse;
+ virtual void GetRandom(const UINT16& bytes_requested,
+ AuthorizationDelegate* authorization_delegate,
+ const GetRandomResponse& callback);
+ virtual TPM_RC GetRandomSync(const UINT16& bytes_requested,
+ TPM2B_DIGEST* random_bytes,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> StirRandomResponse;
static TPM_RC SerializeCommand_StirRandom(
const TPM2B_SENSITIVE_DATA& in_data,
std::string* serialized_command,
@@ -4541,16 +4103,14 @@
static TPM_RC ParseResponse_StirRandom(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void StirRandom(
- const TPM2B_SENSITIVE_DATA& in_data,
- AuthorizationDelegate* authorization_delegate,
- const StirRandomResponse& callback);
- virtual TPM_RC StirRandomSync(
- const TPM2B_SENSITIVE_DATA& in_data,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPMI_DH_OBJECT& sequence_handle)> HMAC_StartResponse;
+ virtual void StirRandom(const TPM2B_SENSITIVE_DATA& in_data,
+ AuthorizationDelegate* authorization_delegate,
+ const StirRandomResponse& callback);
+ virtual TPM_RC StirRandomSync(const TPM2B_SENSITIVE_DATA& in_data,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPMI_DH_OBJECT& sequence_handle)>
+ HMAC_StartResponse;
static TPM_RC SerializeCommand_HMAC_Start(
const TPMI_DH_OBJECT& handle,
const std::string& handle_name,
@@ -4562,23 +4122,21 @@
const std::string& response,
TPMI_DH_OBJECT* sequence_handle,
AuthorizationDelegate* authorization_delegate);
- virtual void HMAC_Start(
- const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_AUTH& auth,
- const TPMI_ALG_HASH& hash_alg,
- AuthorizationDelegate* authorization_delegate,
- const HMAC_StartResponse& callback);
- virtual TPM_RC HMAC_StartSync(
- const TPMI_DH_OBJECT& handle,
- const std::string& handle_name,
- const TPM2B_AUTH& auth,
- const TPMI_ALG_HASH& hash_alg,
- TPMI_DH_OBJECT* sequence_handle,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPMI_DH_OBJECT& sequence_handle)> HashSequenceStartResponse;
+ virtual void HMAC_Start(const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_AUTH& auth,
+ const TPMI_ALG_HASH& hash_alg,
+ AuthorizationDelegate* authorization_delegate,
+ const HMAC_StartResponse& callback);
+ virtual TPM_RC HMAC_StartSync(const TPMI_DH_OBJECT& handle,
+ const std::string& handle_name,
+ const TPM2B_AUTH& auth,
+ const TPMI_ALG_HASH& hash_alg,
+ TPMI_DH_OBJECT* sequence_handle,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPMI_DH_OBJECT& sequence_handle)>
+ HashSequenceStartResponse;
static TPM_RC SerializeCommand_HashSequenceStart(
const TPM2B_AUTH& auth,
const TPMI_ALG_HASH& hash_alg,
@@ -4588,18 +4146,16 @@
const std::string& response,
TPMI_DH_OBJECT* sequence_handle,
AuthorizationDelegate* authorization_delegate);
- virtual void HashSequenceStart(
- const TPM2B_AUTH& auth,
- const TPMI_ALG_HASH& hash_alg,
- AuthorizationDelegate* authorization_delegate,
- const HashSequenceStartResponse& callback);
+ virtual void HashSequenceStart(const TPM2B_AUTH& auth,
+ const TPMI_ALG_HASH& hash_alg,
+ AuthorizationDelegate* authorization_delegate,
+ const HashSequenceStartResponse& callback);
virtual TPM_RC HashSequenceStartSync(
const TPM2B_AUTH& auth,
const TPMI_ALG_HASH& hash_alg,
TPMI_DH_OBJECT* sequence_handle,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> SequenceUpdateResponse;
+ typedef base::Callback<void(TPM_RC response_code)> SequenceUpdateResponse;
static TPM_RC SerializeCommand_SequenceUpdate(
const TPMI_DH_OBJECT& sequence_handle,
const std::string& sequence_handle_name,
@@ -4609,21 +4165,20 @@
static TPM_RC ParseResponse_SequenceUpdate(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void SequenceUpdate(
- const TPMI_DH_OBJECT& sequence_handle,
- const std::string& sequence_handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- AuthorizationDelegate* authorization_delegate,
- const SequenceUpdateResponse& callback);
+ virtual void SequenceUpdate(const TPMI_DH_OBJECT& sequence_handle,
+ const std::string& sequence_handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ AuthorizationDelegate* authorization_delegate,
+ const SequenceUpdateResponse& callback);
virtual TPM_RC SequenceUpdateSync(
const TPMI_DH_OBJECT& sequence_handle,
const std::string& sequence_handle_name,
const TPM2B_MAX_BUFFER& buffer,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_DIGEST& result,
- const TPMT_TK_HASHCHECK& validation)> SequenceCompleteResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_DIGEST& result,
+ const TPMT_TK_HASHCHECK& validation)>
+ SequenceCompleteResponse;
static TPM_RC SerializeCommand_SequenceComplete(
const TPMI_DH_OBJECT& sequence_handle,
const std::string& sequence_handle_name,
@@ -4636,13 +4191,12 @@
TPM2B_DIGEST* result,
TPMT_TK_HASHCHECK* validation,
AuthorizationDelegate* authorization_delegate);
- virtual void SequenceComplete(
- const TPMI_DH_OBJECT& sequence_handle,
- const std::string& sequence_handle_name,
- const TPM2B_MAX_BUFFER& buffer,
- const TPMI_RH_HIERARCHY& hierarchy,
- AuthorizationDelegate* authorization_delegate,
- const SequenceCompleteResponse& callback);
+ virtual void SequenceComplete(const TPMI_DH_OBJECT& sequence_handle,
+ const std::string& sequence_handle_name,
+ const TPM2B_MAX_BUFFER& buffer,
+ const TPMI_RH_HIERARCHY& hierarchy,
+ AuthorizationDelegate* authorization_delegate,
+ const SequenceCompleteResponse& callback);
virtual TPM_RC SequenceCompleteSync(
const TPMI_DH_OBJECT& sequence_handle,
const std::string& sequence_handle_name,
@@ -4651,9 +4205,9 @@
TPM2B_DIGEST* result,
TPMT_TK_HASHCHECK* validation,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPML_DIGEST_VALUES& results)> EventSequenceCompleteResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPML_DIGEST_VALUES& results)>
+ EventSequenceCompleteResponse;
static TPM_RC SerializeCommand_EventSequenceComplete(
const TPMI_DH_PCR& pcr_handle,
const std::string& pcr_handle_name,
@@ -4682,10 +4236,10 @@
const TPM2B_MAX_BUFFER& buffer,
TPML_DIGEST_VALUES* results,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_ATTEST& certify_info,
- const TPMT_SIGNATURE& signature)> CertifyResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_ATTEST& certify_info,
+ const TPMT_SIGNATURE& signature)>
+ CertifyResponse;
static TPM_RC SerializeCommand_Certify(
const TPMI_DH_OBJECT& object_handle,
const std::string& object_handle_name,
@@ -4700,29 +4254,27 @@
TPM2B_ATTEST* certify_info,
TPMT_SIGNATURE* signature,
AuthorizationDelegate* authorization_delegate);
- virtual void Certify(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- AuthorizationDelegate* authorization_delegate,
- const CertifyResponse& callback);
- virtual TPM_RC CertifySync(
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- TPM2B_ATTEST* certify_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_ATTEST& certify_info,
- const TPMT_SIGNATURE& signature)> CertifyCreationResponse;
+ virtual void Certify(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ AuthorizationDelegate* authorization_delegate,
+ const CertifyResponse& callback);
+ virtual TPM_RC CertifySync(const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ TPM2B_ATTEST* certify_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_ATTEST& certify_info,
+ const TPMT_SIGNATURE& signature)>
+ CertifyCreationResponse;
static TPM_RC SerializeCommand_CertifyCreation(
const TPMI_DH_OBJECT& sign_handle,
const std::string& sign_handle_name,
@@ -4739,17 +4291,16 @@
TPM2B_ATTEST* certify_info,
TPMT_SIGNATURE* signature,
AuthorizationDelegate* authorization_delegate);
- virtual void CertifyCreation(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPM2B_DIGEST& creation_hash,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPMT_TK_CREATION& creation_ticket,
- AuthorizationDelegate* authorization_delegate,
- const CertifyCreationResponse& callback);
+ virtual void CertifyCreation(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPM2B_DIGEST& creation_hash,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPMT_TK_CREATION& creation_ticket,
+ AuthorizationDelegate* authorization_delegate,
+ const CertifyCreationResponse& callback);
virtual TPM_RC CertifyCreationSync(
const TPMI_DH_OBJECT& sign_handle,
const std::string& sign_handle_name,
@@ -4762,10 +4313,10 @@
TPM2B_ATTEST* certify_info,
TPMT_SIGNATURE* signature,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_ATTEST& quoted,
- const TPMT_SIGNATURE& signature)> QuoteResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_ATTEST& quoted,
+ const TPMT_SIGNATURE& signature)>
+ QuoteResponse;
static TPM_RC SerializeCommand_Quote(
const TPMI_DH_OBJECT& sign_handle,
const std::string& sign_handle_name,
@@ -4779,27 +4330,25 @@
TPM2B_ATTEST* quoted,
TPMT_SIGNATURE* signature,
AuthorizationDelegate* authorization_delegate);
- virtual void Quote(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPML_PCR_SELECTION& pcrselect,
- AuthorizationDelegate* authorization_delegate,
- const QuoteResponse& callback);
- virtual TPM_RC QuoteSync(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPML_PCR_SELECTION& pcrselect,
- TPM2B_ATTEST* quoted,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_ATTEST& audit_info,
- const TPMT_SIGNATURE& signature)> GetSessionAuditDigestResponse;
+ virtual void Quote(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPML_PCR_SELECTION& pcrselect,
+ AuthorizationDelegate* authorization_delegate,
+ const QuoteResponse& callback);
+ virtual TPM_RC QuoteSync(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPML_PCR_SELECTION& pcrselect,
+ TPM2B_ATTEST* quoted,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_ATTEST& audit_info,
+ const TPMT_SIGNATURE& signature)>
+ GetSessionAuditDigestResponse;
static TPM_RC SerializeCommand_GetSessionAuditDigest(
const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
const std::string& privacy_admin_handle_name,
@@ -4839,10 +4388,10 @@
TPM2B_ATTEST* audit_info,
TPMT_SIGNATURE* signature,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_ATTEST& audit_info,
- const TPMT_SIGNATURE& signature)> GetCommandAuditDigestResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_ATTEST& audit_info,
+ const TPMT_SIGNATURE& signature)>
+ GetCommandAuditDigestResponse;
static TPM_RC SerializeCommand_GetCommandAuditDigest(
const TPMI_RH_ENDORSEMENT& privacy_handle,
const std::string& privacy_handle_name,
@@ -4876,10 +4425,10 @@
TPM2B_ATTEST* audit_info,
TPMT_SIGNATURE* signature,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_ATTEST& time_info,
- const TPMT_SIGNATURE& signature)> GetTimeResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_ATTEST& time_info,
+ const TPMT_SIGNATURE& signature)>
+ GetTimeResponse;
static TPM_RC SerializeCommand_GetTime(
const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
const std::string& privacy_admin_handle_name,
@@ -4894,32 +4443,30 @@
TPM2B_ATTEST* time_info,
TPMT_SIGNATURE* signature,
AuthorizationDelegate* authorization_delegate);
- virtual void GetTime(
- const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
- const std::string& privacy_admin_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- AuthorizationDelegate* authorization_delegate,
- const GetTimeResponse& callback);
- virtual TPM_RC GetTimeSync(
- const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
- const std::string& privacy_admin_handle_name,
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- TPM2B_ATTEST* time_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const UINT32& param_size_out,
- const TPM2B_ECC_POINT& k,
- const TPM2B_ECC_POINT& l,
- const TPM2B_ECC_POINT& e,
- const UINT16& counter)> CommitResponse;
+ virtual void GetTime(const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
+ const std::string& privacy_admin_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ AuthorizationDelegate* authorization_delegate,
+ const GetTimeResponse& callback);
+ virtual TPM_RC GetTimeSync(const TPMI_RH_ENDORSEMENT& privacy_admin_handle,
+ const std::string& privacy_admin_handle_name,
+ const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ TPM2B_ATTEST* time_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const UINT32& param_size_out,
+ const TPM2B_ECC_POINT& k,
+ const TPM2B_ECC_POINT& l,
+ const TPM2B_ECC_POINT& e,
+ const UINT16& counter)>
+ CommitResponse;
static TPM_RC SerializeCommand_Commit(
const TPMI_DH_OBJECT& sign_handle,
const std::string& sign_handle_name,
@@ -4937,33 +4484,31 @@
TPM2B_ECC_POINT* e,
UINT16* counter,
AuthorizationDelegate* authorization_delegate);
- virtual void Commit(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const UINT32& param_size,
- const TPM2B_ECC_POINT& p1,
- const TPM2B_SENSITIVE_DATA& s2,
- const TPM2B_ECC_PARAMETER& y2,
- AuthorizationDelegate* authorization_delegate,
- const CommitResponse& callback);
- virtual TPM_RC CommitSync(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const UINT32& param_size,
- const TPM2B_ECC_POINT& p1,
- const TPM2B_SENSITIVE_DATA& s2,
- const TPM2B_ECC_PARAMETER& y2,
- UINT32* param_size_out,
- TPM2B_ECC_POINT* k,
- TPM2B_ECC_POINT* l,
- TPM2B_ECC_POINT* e,
- UINT16* counter,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const UINT32& param_size_out,
- const TPM2B_ECC_POINT& q,
- const UINT16& counter)> EC_EphemeralResponse;
+ virtual void Commit(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const UINT32& param_size,
+ const TPM2B_ECC_POINT& p1,
+ const TPM2B_SENSITIVE_DATA& s2,
+ const TPM2B_ECC_PARAMETER& y2,
+ AuthorizationDelegate* authorization_delegate,
+ const CommitResponse& callback);
+ virtual TPM_RC CommitSync(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const UINT32& param_size,
+ const TPM2B_ECC_POINT& p1,
+ const TPM2B_SENSITIVE_DATA& s2,
+ const TPM2B_ECC_PARAMETER& y2,
+ UINT32* param_size_out,
+ TPM2B_ECC_POINT* k,
+ TPM2B_ECC_POINT* l,
+ TPM2B_ECC_POINT* e,
+ UINT16* counter,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const UINT32& param_size_out,
+ const TPM2B_ECC_POINT& q,
+ const UINT16& counter)>
+ EC_EphemeralResponse;
static TPM_RC SerializeCommand_EC_Ephemeral(
const UINT32& param_size,
const TPMI_ECC_CURVE& curve_id,
@@ -4975,11 +4520,10 @@
TPM2B_ECC_POINT* q,
UINT16* counter,
AuthorizationDelegate* authorization_delegate);
- virtual void EC_Ephemeral(
- const UINT32& param_size,
- const TPMI_ECC_CURVE& curve_id,
- AuthorizationDelegate* authorization_delegate,
- const EC_EphemeralResponse& callback);
+ virtual void EC_Ephemeral(const UINT32& param_size,
+ const TPMI_ECC_CURVE& curve_id,
+ AuthorizationDelegate* authorization_delegate,
+ const EC_EphemeralResponse& callback);
virtual TPM_RC EC_EphemeralSync(
const UINT32& param_size,
const TPMI_ECC_CURVE& curve_id,
@@ -4987,9 +4531,9 @@
TPM2B_ECC_POINT* q,
UINT16* counter,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPMT_TK_VERIFIED& validation)> VerifySignatureResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPMT_TK_VERIFIED& validation)>
+ VerifySignatureResponse;
static TPM_RC SerializeCommand_VerifySignature(
const TPMI_DH_OBJECT& key_handle,
const std::string& key_handle_name,
@@ -5001,13 +4545,12 @@
const std::string& response,
TPMT_TK_VERIFIED* validation,
AuthorizationDelegate* authorization_delegate);
- virtual void VerifySignature(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& digest,
- const TPMT_SIGNATURE& signature,
- AuthorizationDelegate* authorization_delegate,
- const VerifySignatureResponse& callback);
+ virtual void VerifySignature(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& digest,
+ const TPMT_SIGNATURE& signature,
+ AuthorizationDelegate* authorization_delegate,
+ const VerifySignatureResponse& callback);
virtual TPM_RC VerifySignatureSync(
const TPMI_DH_OBJECT& key_handle,
const std::string& key_handle_name,
@@ -5015,9 +4558,9 @@
const TPMT_SIGNATURE& signature,
TPMT_TK_VERIFIED* validation,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPMT_SIGNATURE& signature)> SignResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPMT_SIGNATURE& signature)>
+ SignResponse;
static TPM_RC SerializeCommand_Sign(
const TPMI_DH_OBJECT& key_handle,
const std::string& key_handle_name,
@@ -5030,24 +4573,22 @@
const std::string& response,
TPMT_SIGNATURE* signature,
AuthorizationDelegate* authorization_delegate);
- virtual void Sign(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& digest,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPMT_TK_HASHCHECK& validation,
- AuthorizationDelegate* authorization_delegate,
- const SignResponse& callback);
- virtual TPM_RC SignSync(
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& digest,
- const TPMT_SIG_SCHEME& in_scheme,
- const TPMT_TK_HASHCHECK& validation,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> SetCommandCodeAuditStatusResponse;
+ virtual void Sign(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& digest,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPMT_TK_HASHCHECK& validation,
+ AuthorizationDelegate* authorization_delegate,
+ const SignResponse& callback);
+ virtual TPM_RC SignSync(const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& digest,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const TPMT_TK_HASHCHECK& validation,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)>
+ SetCommandCodeAuditStatusResponse;
static TPM_RC SerializeCommand_SetCommandCodeAuditStatus(
const TPMI_RH_PROVISION& auth,
const std::string& auth_name,
@@ -5074,8 +4615,7 @@
const TPML_CC& set_list,
const TPML_CC& clear_list,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PCR_ExtendResponse;
+ typedef base::Callback<void(TPM_RC response_code)> PCR_ExtendResponse;
static TPM_RC SerializeCommand_PCR_Extend(
const TPMI_DH_PCR& pcr_handle,
const std::string& pcr_handle_name,
@@ -5085,20 +4625,18 @@
static TPM_RC ParseResponse_PCR_Extend(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PCR_Extend(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPML_DIGEST_VALUES& digests,
- AuthorizationDelegate* authorization_delegate,
- const PCR_ExtendResponse& callback);
- virtual TPM_RC PCR_ExtendSync(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPML_DIGEST_VALUES& digests,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPML_DIGEST_VALUES& digests)> PCR_EventResponse;
+ virtual void PCR_Extend(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPML_DIGEST_VALUES& digests,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_ExtendResponse& callback);
+ virtual TPM_RC PCR_ExtendSync(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPML_DIGEST_VALUES& digests,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPML_DIGEST_VALUES& digests)>
+ PCR_EventResponse;
static TPM_RC SerializeCommand_PCR_Event(
const TPMI_DH_PCR& pcr_handle,
const std::string& pcr_handle_name,
@@ -5109,23 +4647,21 @@
const std::string& response,
TPML_DIGEST_VALUES* digests,
AuthorizationDelegate* authorization_delegate);
- virtual void PCR_Event(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPM2B_EVENT& event_data,
- AuthorizationDelegate* authorization_delegate,
- const PCR_EventResponse& callback);
- virtual TPM_RC PCR_EventSync(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPM2B_EVENT& event_data,
- TPML_DIGEST_VALUES* digests,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const UINT32& pcr_update_counter,
- const TPML_PCR_SELECTION& pcr_selection_out,
- const TPML_DIGEST& pcr_values)> PCR_ReadResponse;
+ virtual void PCR_Event(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPM2B_EVENT& event_data,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_EventResponse& callback);
+ virtual TPM_RC PCR_EventSync(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPM2B_EVENT& event_data,
+ TPML_DIGEST_VALUES* digests,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const UINT32& pcr_update_counter,
+ const TPML_PCR_SELECTION& pcr_selection_out,
+ const TPML_DIGEST& pcr_values)>
+ PCR_ReadResponse;
static TPM_RC SerializeCommand_PCR_Read(
const TPML_PCR_SELECTION& pcr_selection_in,
std::string* serialized_command,
@@ -5136,22 +4672,20 @@
TPML_PCR_SELECTION* pcr_selection_out,
TPML_DIGEST* pcr_values,
AuthorizationDelegate* authorization_delegate);
- virtual void PCR_Read(
- const TPML_PCR_SELECTION& pcr_selection_in,
- AuthorizationDelegate* authorization_delegate,
- const PCR_ReadResponse& callback);
- virtual TPM_RC PCR_ReadSync(
- const TPML_PCR_SELECTION& pcr_selection_in,
- UINT32* pcr_update_counter,
- TPML_PCR_SELECTION* pcr_selection_out,
- TPML_DIGEST* pcr_values,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPMI_YES_NO& allocation_success,
- const UINT32& max_pcr,
- const UINT32& size_needed,
- const UINT32& size_available)> PCR_AllocateResponse;
+ virtual void PCR_Read(const TPML_PCR_SELECTION& pcr_selection_in,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_ReadResponse& callback);
+ virtual TPM_RC PCR_ReadSync(const TPML_PCR_SELECTION& pcr_selection_in,
+ UINT32* pcr_update_counter,
+ TPML_PCR_SELECTION* pcr_selection_out,
+ TPML_DIGEST* pcr_values,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPMI_YES_NO& allocation_success,
+ const UINT32& max_pcr,
+ const UINT32& size_needed,
+ const UINT32& size_available)>
+ PCR_AllocateResponse;
static TPM_RC SerializeCommand_PCR_Allocate(
const TPMI_RH_PLATFORM& auth_handle,
const std::string& auth_handle_name,
@@ -5165,12 +4699,11 @@
UINT32* size_needed,
UINT32* size_available,
AuthorizationDelegate* authorization_delegate);
- virtual void PCR_Allocate(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- const TPML_PCR_SELECTION& pcr_allocation,
- AuthorizationDelegate* authorization_delegate,
- const PCR_AllocateResponse& callback);
+ virtual void PCR_Allocate(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ const TPML_PCR_SELECTION& pcr_allocation,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_AllocateResponse& callback);
virtual TPM_RC PCR_AllocateSync(
const TPMI_RH_PLATFORM& auth_handle,
const std::string& auth_handle_name,
@@ -5180,8 +4713,7 @@
UINT32* size_needed,
UINT32* size_available,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PCR_SetAuthPolicyResponse;
+ typedef base::Callback<void(TPM_RC response_code)> PCR_SetAuthPolicyResponse;
static TPM_RC SerializeCommand_PCR_SetAuthPolicy(
const TPMI_RH_PLATFORM& auth_handle,
const std::string& auth_handle_name,
@@ -5194,15 +4726,14 @@
static TPM_RC ParseResponse_PCR_SetAuthPolicy(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PCR_SetAuthPolicy(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_DH_PCR& pcr_num,
- const std::string& pcr_num_name,
- const TPM2B_DIGEST& auth_policy,
- const TPMI_ALG_HASH& policy_digest,
- AuthorizationDelegate* authorization_delegate,
- const PCR_SetAuthPolicyResponse& callback);
+ virtual void PCR_SetAuthPolicy(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_DH_PCR& pcr_num,
+ const std::string& pcr_num_name,
+ const TPM2B_DIGEST& auth_policy,
+ const TPMI_ALG_HASH& policy_digest,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_SetAuthPolicyResponse& callback);
virtual TPM_RC PCR_SetAuthPolicySync(
const TPMI_RH_PLATFORM& auth_handle,
const std::string& auth_handle_name,
@@ -5211,8 +4742,7 @@
const TPM2B_DIGEST& auth_policy,
const TPMI_ALG_HASH& policy_digest,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PCR_SetAuthValueResponse;
+ typedef base::Callback<void(TPM_RC response_code)> PCR_SetAuthValueResponse;
static TPM_RC SerializeCommand_PCR_SetAuthValue(
const TPMI_DH_PCR& pcr_handle,
const std::string& pcr_handle_name,
@@ -5222,19 +4752,17 @@
static TPM_RC ParseResponse_PCR_SetAuthValue(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PCR_SetAuthValue(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- const TPM2B_DIGEST& auth,
- AuthorizationDelegate* authorization_delegate,
- const PCR_SetAuthValueResponse& callback);
+ virtual void PCR_SetAuthValue(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ const TPM2B_DIGEST& auth,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_SetAuthValueResponse& callback);
virtual TPM_RC PCR_SetAuthValueSync(
const TPMI_DH_PCR& pcr_handle,
const std::string& pcr_handle_name,
const TPM2B_DIGEST& auth,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PCR_ResetResponse;
+ typedef base::Callback<void(TPM_RC response_code)> PCR_ResetResponse;
static TPM_RC SerializeCommand_PCR_Reset(
const TPMI_DH_PCR& pcr_handle,
const std::string& pcr_handle_name,
@@ -5243,19 +4771,17 @@
static TPM_RC ParseResponse_PCR_Reset(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PCR_Reset(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const PCR_ResetResponse& callback);
- virtual TPM_RC PCR_ResetSync(
- const TPMI_DH_PCR& pcr_handle,
- const std::string& pcr_handle_name,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_TIMEOUT& timeout,
- const TPMT_TK_AUTH& policy_ticket)> PolicySignedResponse;
+ virtual void PCR_Reset(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const PCR_ResetResponse& callback);
+ virtual TPM_RC PCR_ResetSync(const TPMI_DH_PCR& pcr_handle,
+ const std::string& pcr_handle_name,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_TIMEOUT& timeout,
+ const TPMT_TK_AUTH& policy_ticket)>
+ PolicySignedResponse;
static TPM_RC SerializeCommand_PolicySigned(
const TPMI_DH_OBJECT& auth_object,
const std::string& auth_object_name,
@@ -5273,18 +4799,17 @@
TPM2B_TIMEOUT* timeout,
TPMT_TK_AUTH* policy_ticket,
AuthorizationDelegate* authorization_delegate);
- virtual void PolicySigned(
- const TPMI_DH_OBJECT& auth_object,
- const std::string& auth_object_name,
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_NONCE& nonce_tpm,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const INT32& expiration,
- const TPMT_SIGNATURE& auth,
- AuthorizationDelegate* authorization_delegate,
- const PolicySignedResponse& callback);
+ virtual void PolicySigned(const TPMI_DH_OBJECT& auth_object,
+ const std::string& auth_object_name,
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_NONCE& nonce_tpm,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const INT32& expiration,
+ const TPMT_SIGNATURE& auth,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicySignedResponse& callback);
virtual TPM_RC PolicySignedSync(
const TPMI_DH_OBJECT& auth_object,
const std::string& auth_object_name,
@@ -5298,10 +4823,10 @@
TPM2B_TIMEOUT* timeout,
TPMT_TK_AUTH* policy_ticket,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_TIMEOUT& timeout,
- const TPMT_TK_AUTH& policy_ticket)> PolicySecretResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_TIMEOUT& timeout,
+ const TPMT_TK_AUTH& policy_ticket)>
+ PolicySecretResponse;
static TPM_RC SerializeCommand_PolicySecret(
const TPMI_DH_ENTITY& auth_handle,
const std::string& auth_handle_name,
@@ -5318,17 +4843,16 @@
TPM2B_TIMEOUT* timeout,
TPMT_TK_AUTH* policy_ticket,
AuthorizationDelegate* authorization_delegate);
- virtual void PolicySecret(
- const TPMI_DH_ENTITY& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_NONCE& nonce_tpm,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const INT32& expiration,
- AuthorizationDelegate* authorization_delegate,
- const PolicySecretResponse& callback);
+ virtual void PolicySecret(const TPMI_DH_ENTITY& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_NONCE& nonce_tpm,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const INT32& expiration,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicySecretResponse& callback);
virtual TPM_RC PolicySecretSync(
const TPMI_DH_ENTITY& auth_handle,
const std::string& auth_handle_name,
@@ -5341,8 +4865,7 @@
TPM2B_TIMEOUT* timeout,
TPMT_TK_AUTH* policy_ticket,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PolicyTicketResponse;
+ typedef base::Callback<void(TPM_RC response_code)> PolicyTicketResponse;
static TPM_RC SerializeCommand_PolicyTicket(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
@@ -5356,16 +4879,15 @@
static TPM_RC ParseResponse_PolicyTicket(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PolicyTicket(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_TIMEOUT& timeout,
- const TPM2B_DIGEST& cp_hash_a,
- const TPM2B_NONCE& policy_ref,
- const TPM2B_NAME& auth_name,
- const TPMT_TK_AUTH& ticket,
- AuthorizationDelegate* authorization_delegate,
- const PolicyTicketResponse& callback);
+ virtual void PolicyTicket(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_TIMEOUT& timeout,
+ const TPM2B_DIGEST& cp_hash_a,
+ const TPM2B_NONCE& policy_ref,
+ const TPM2B_NAME& auth_name,
+ const TPMT_TK_AUTH& ticket,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyTicketResponse& callback);
virtual TPM_RC PolicyTicketSync(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
@@ -5375,8 +4897,7 @@
const TPM2B_NAME& auth_name,
const TPMT_TK_AUTH& ticket,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PolicyORResponse;
+ typedef base::Callback<void(TPM_RC response_code)> PolicyORResponse;
static TPM_RC SerializeCommand_PolicyOR(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
@@ -5386,19 +4907,16 @@
static TPM_RC ParseResponse_PolicyOR(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PolicyOR(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPML_DIGEST& p_hash_list,
- AuthorizationDelegate* authorization_delegate,
- const PolicyORResponse& callback);
- virtual TPM_RC PolicyORSync(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPML_DIGEST& p_hash_list,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PolicyPCRResponse;
+ virtual void PolicyOR(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPML_DIGEST& p_hash_list,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyORResponse& callback);
+ virtual TPM_RC PolicyORSync(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPML_DIGEST& p_hash_list,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> PolicyPCRResponse;
static TPM_RC SerializeCommand_PolicyPCR(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
@@ -5409,21 +4927,18 @@
static TPM_RC ParseResponse_PolicyPCR(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PolicyPCR(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& pcr_digest,
- const TPML_PCR_SELECTION& pcrs,
- AuthorizationDelegate* authorization_delegate,
- const PolicyPCRResponse& callback);
- virtual TPM_RC PolicyPCRSync(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& pcr_digest,
- const TPML_PCR_SELECTION& pcrs,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PolicyLocalityResponse;
+ virtual void PolicyPCR(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& pcr_digest,
+ const TPML_PCR_SELECTION& pcrs,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyPCRResponse& callback);
+ virtual TPM_RC PolicyPCRSync(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& pcr_digest,
+ const TPML_PCR_SELECTION& pcrs,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> PolicyLocalityResponse;
static TPM_RC SerializeCommand_PolicyLocality(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
@@ -5433,19 +4948,17 @@
static TPM_RC ParseResponse_PolicyLocality(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PolicyLocality(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPMA_LOCALITY& locality,
- AuthorizationDelegate* authorization_delegate,
- const PolicyLocalityResponse& callback);
+ virtual void PolicyLocality(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPMA_LOCALITY& locality,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyLocalityResponse& callback);
virtual TPM_RC PolicyLocalitySync(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
const TPMA_LOCALITY& locality,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PolicyNVResponse;
+ typedef base::Callback<void(TPM_RC response_code)> PolicyNVResponse;
static TPM_RC SerializeCommand_PolicyNV(
const TPMI_RH_NV_AUTH& auth_handle,
const std::string& auth_handle_name,
@@ -5461,31 +4974,28 @@
static TPM_RC ParseResponse_PolicyNV(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PolicyNV(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_OPERAND& operand_b,
- const UINT16& offset,
- const TPM_EO& operation,
- AuthorizationDelegate* authorization_delegate,
- const PolicyNVResponse& callback);
- virtual TPM_RC PolicyNVSync(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_OPERAND& operand_b,
- const UINT16& offset,
- const TPM_EO& operation,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PolicyCounterTimerResponse;
+ virtual void PolicyNV(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_OPERAND& operand_b,
+ const UINT16& offset,
+ const TPM_EO& operation,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyNVResponse& callback);
+ virtual TPM_RC PolicyNVSync(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_OPERAND& operand_b,
+ const UINT16& offset,
+ const TPM_EO& operation,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> PolicyCounterTimerResponse;
static TPM_RC SerializeCommand_PolicyCounterTimer(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
@@ -5497,14 +5007,13 @@
static TPM_RC ParseResponse_PolicyCounterTimer(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PolicyCounterTimer(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_OPERAND& operand_b,
- const UINT16& offset,
- const TPM_EO& operation,
- AuthorizationDelegate* authorization_delegate,
- const PolicyCounterTimerResponse& callback);
+ virtual void PolicyCounterTimer(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_OPERAND& operand_b,
+ const UINT16& offset,
+ const TPM_EO& operation,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyCounterTimerResponse& callback);
virtual TPM_RC PolicyCounterTimerSync(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
@@ -5512,8 +5021,7 @@
const UINT16& offset,
const TPM_EO& operation,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PolicyCommandCodeResponse;
+ typedef base::Callback<void(TPM_RC response_code)> PolicyCommandCodeResponse;
static TPM_RC SerializeCommand_PolicyCommandCode(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
@@ -5523,19 +5031,18 @@
static TPM_RC ParseResponse_PolicyCommandCode(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PolicyCommandCode(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM_CC& code,
- AuthorizationDelegate* authorization_delegate,
- const PolicyCommandCodeResponse& callback);
+ virtual void PolicyCommandCode(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM_CC& code,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyCommandCodeResponse& callback);
virtual TPM_RC PolicyCommandCodeSync(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
const TPM_CC& code,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PolicyPhysicalPresenceResponse;
+ typedef base::Callback<void(TPM_RC response_code)>
+ PolicyPhysicalPresenceResponse;
static TPM_RC SerializeCommand_PolicyPhysicalPresence(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
@@ -5553,8 +5060,7 @@
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PolicyCpHashResponse;
+ typedef base::Callback<void(TPM_RC response_code)> PolicyCpHashResponse;
static TPM_RC SerializeCommand_PolicyCpHash(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
@@ -5564,19 +5070,17 @@
static TPM_RC ParseResponse_PolicyCpHash(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PolicyCpHash(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& cp_hash_a,
- AuthorizationDelegate* authorization_delegate,
- const PolicyCpHashResponse& callback);
+ virtual void PolicyCpHash(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& cp_hash_a,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyCpHashResponse& callback);
virtual TPM_RC PolicyCpHashSync(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
const TPM2B_DIGEST& cp_hash_a,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PolicyNameHashResponse;
+ typedef base::Callback<void(TPM_RC response_code)> PolicyNameHashResponse;
static TPM_RC SerializeCommand_PolicyNameHash(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
@@ -5586,19 +5090,18 @@
static TPM_RC ParseResponse_PolicyNameHash(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PolicyNameHash(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& name_hash,
- AuthorizationDelegate* authorization_delegate,
- const PolicyNameHashResponse& callback);
+ virtual void PolicyNameHash(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& name_hash,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyNameHashResponse& callback);
virtual TPM_RC PolicyNameHashSync(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
const TPM2B_DIGEST& name_hash,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PolicyDuplicationSelectResponse;
+ typedef base::Callback<void(TPM_RC response_code)>
+ PolicyDuplicationSelectResponse;
static TPM_RC SerializeCommand_PolicyDuplicationSelect(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
@@ -5625,8 +5128,7 @@
const TPM2B_NAME& new_parent_name,
const TPMI_YES_NO& include_object,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PolicyAuthorizeResponse;
+ typedef base::Callback<void(TPM_RC response_code)> PolicyAuthorizeResponse;
static TPM_RC SerializeCommand_PolicyAuthorize(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
@@ -5639,15 +5141,14 @@
static TPM_RC ParseResponse_PolicyAuthorize(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PolicyAuthorize(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPM2B_DIGEST& approved_policy,
- const TPM2B_NONCE& policy_ref,
- const TPM2B_NAME& key_sign,
- const TPMT_TK_VERIFIED& check_ticket,
- AuthorizationDelegate* authorization_delegate,
- const PolicyAuthorizeResponse& callback);
+ virtual void PolicyAuthorize(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPM2B_DIGEST& approved_policy,
+ const TPM2B_NONCE& policy_ref,
+ const TPM2B_NAME& key_sign,
+ const TPMT_TK_VERIFIED& check_ticket,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyAuthorizeResponse& callback);
virtual TPM_RC PolicyAuthorizeSync(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
@@ -5656,8 +5157,7 @@
const TPM2B_NAME& key_sign,
const TPMT_TK_VERIFIED& check_ticket,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PolicyAuthValueResponse;
+ typedef base::Callback<void(TPM_RC response_code)> PolicyAuthValueResponse;
static TPM_RC SerializeCommand_PolicyAuthValue(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
@@ -5666,17 +5166,15 @@
static TPM_RC ParseResponse_PolicyAuthValue(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PolicyAuthValue(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- AuthorizationDelegate* authorization_delegate,
- const PolicyAuthValueResponse& callback);
+ virtual void PolicyAuthValue(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyAuthValueResponse& callback);
virtual TPM_RC PolicyAuthValueSync(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PolicyPasswordResponse;
+ typedef base::Callback<void(TPM_RC response_code)> PolicyPasswordResponse;
static TPM_RC SerializeCommand_PolicyPassword(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
@@ -5685,18 +5183,17 @@
static TPM_RC ParseResponse_PolicyPassword(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PolicyPassword(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- AuthorizationDelegate* authorization_delegate,
- const PolicyPasswordResponse& callback);
+ virtual void PolicyPassword(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyPasswordResponse& callback);
virtual TPM_RC PolicyPasswordSync(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_DIGEST& policy_digest)> PolicyGetDigestResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_DIGEST& policy_digest)>
+ PolicyGetDigestResponse;
static TPM_RC SerializeCommand_PolicyGetDigest(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
@@ -5706,18 +5203,16 @@
const std::string& response,
TPM2B_DIGEST* policy_digest,
AuthorizationDelegate* authorization_delegate);
- virtual void PolicyGetDigest(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- AuthorizationDelegate* authorization_delegate,
- const PolicyGetDigestResponse& callback);
+ virtual void PolicyGetDigest(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyGetDigestResponse& callback);
virtual TPM_RC PolicyGetDigestSync(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
TPM2B_DIGEST* policy_digest,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PolicyNvWrittenResponse;
+ typedef base::Callback<void(TPM_RC response_code)> PolicyNvWrittenResponse;
static TPM_RC SerializeCommand_PolicyNvWritten(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
@@ -5727,25 +5222,24 @@
static TPM_RC ParseResponse_PolicyNvWritten(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PolicyNvWritten(
- const TPMI_SH_POLICY& policy_session,
- const std::string& policy_session_name,
- const TPMI_YES_NO& written_set,
- AuthorizationDelegate* authorization_delegate,
- const PolicyNvWrittenResponse& callback);
+ virtual void PolicyNvWritten(const TPMI_SH_POLICY& policy_session,
+ const std::string& policy_session_name,
+ const TPMI_YES_NO& written_set,
+ AuthorizationDelegate* authorization_delegate,
+ const PolicyNvWrittenResponse& callback);
virtual TPM_RC PolicyNvWrittenSync(
const TPMI_SH_POLICY& policy_session,
const std::string& policy_session_name,
const TPMI_YES_NO& written_set,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM_HANDLE& object_handle,
- const TPM2B_PUBLIC& out_public,
- const TPM2B_CREATION_DATA& creation_data,
- const TPM2B_DIGEST& creation_hash,
- const TPMT_TK_CREATION& creation_ticket,
- const TPM2B_NAME& name)> CreatePrimaryResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM_HANDLE& object_handle,
+ const TPM2B_PUBLIC& out_public,
+ const TPM2B_CREATION_DATA& creation_data,
+ const TPM2B_DIGEST& creation_hash,
+ const TPMT_TK_CREATION& creation_ticket,
+ const TPM2B_NAME& name)>
+ CreatePrimaryResponse;
static TPM_RC SerializeCommand_CreatePrimary(
const TPMI_RH_HIERARCHY& primary_handle,
const std::string& primary_handle_name,
@@ -5764,15 +5258,14 @@
TPMT_TK_CREATION* creation_ticket,
TPM2B_NAME* name,
AuthorizationDelegate* authorization_delegate);
- virtual void CreatePrimary(
- const TPMI_RH_HIERARCHY& primary_handle,
- const std::string& primary_handle_name,
- const TPM2B_SENSITIVE_CREATE& in_sensitive,
- const TPM2B_PUBLIC& in_public,
- const TPM2B_DATA& outside_info,
- const TPML_PCR_SELECTION& creation_pcr,
- AuthorizationDelegate* authorization_delegate,
- const CreatePrimaryResponse& callback);
+ virtual void CreatePrimary(const TPMI_RH_HIERARCHY& primary_handle,
+ const std::string& primary_handle_name,
+ const TPM2B_SENSITIVE_CREATE& in_sensitive,
+ const TPM2B_PUBLIC& in_public,
+ const TPM2B_DATA& outside_info,
+ const TPML_PCR_SELECTION& creation_pcr,
+ AuthorizationDelegate* authorization_delegate,
+ const CreatePrimaryResponse& callback);
virtual TPM_RC CreatePrimarySync(
const TPMI_RH_HIERARCHY& primary_handle,
const std::string& primary_handle_name,
@@ -5787,8 +5280,7 @@
TPMT_TK_CREATION* creation_ticket,
TPM2B_NAME* name,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> HierarchyControlResponse;
+ typedef base::Callback<void(TPM_RC response_code)> HierarchyControlResponse;
static TPM_RC SerializeCommand_HierarchyControl(
const TPMI_RH_HIERARCHY& auth_handle,
const std::string& auth_handle_name,
@@ -5799,21 +5291,19 @@
static TPM_RC ParseResponse_HierarchyControl(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void HierarchyControl(
- const TPMI_RH_HIERARCHY& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_ENABLES& enable,
- const TPMI_YES_NO& state,
- AuthorizationDelegate* authorization_delegate,
- const HierarchyControlResponse& callback);
+ virtual void HierarchyControl(const TPMI_RH_HIERARCHY& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_ENABLES& enable,
+ const TPMI_YES_NO& state,
+ AuthorizationDelegate* authorization_delegate,
+ const HierarchyControlResponse& callback);
virtual TPM_RC HierarchyControlSync(
const TPMI_RH_HIERARCHY& auth_handle,
const std::string& auth_handle_name,
const TPMI_RH_ENABLES& enable,
const TPMI_YES_NO& state,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> SetPrimaryPolicyResponse;
+ typedef base::Callback<void(TPM_RC response_code)> SetPrimaryPolicyResponse;
static TPM_RC SerializeCommand_SetPrimaryPolicy(
const TPMI_RH_HIERARCHY& auth_handle,
const std::string& auth_handle_name,
@@ -5824,21 +5314,19 @@
static TPM_RC ParseResponse_SetPrimaryPolicy(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void SetPrimaryPolicy(
- const TPMI_RH_HIERARCHY& auth_handle,
- const std::string& auth_handle_name,
- const TPM2B_DIGEST& auth_policy,
- const TPMI_ALG_HASH& hash_alg,
- AuthorizationDelegate* authorization_delegate,
- const SetPrimaryPolicyResponse& callback);
+ virtual void SetPrimaryPolicy(const TPMI_RH_HIERARCHY& auth_handle,
+ const std::string& auth_handle_name,
+ const TPM2B_DIGEST& auth_policy,
+ const TPMI_ALG_HASH& hash_alg,
+ AuthorizationDelegate* authorization_delegate,
+ const SetPrimaryPolicyResponse& callback);
virtual TPM_RC SetPrimaryPolicySync(
const TPMI_RH_HIERARCHY& auth_handle,
const std::string& auth_handle_name,
const TPM2B_DIGEST& auth_policy,
const TPMI_ALG_HASH& hash_alg,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> ChangePPSResponse;
+ typedef base::Callback<void(TPM_RC response_code)> ChangePPSResponse;
static TPM_RC SerializeCommand_ChangePPS(
const TPMI_RH_PLATFORM& auth_handle,
const std::string& auth_handle_name,
@@ -5847,17 +5335,14 @@
static TPM_RC ParseResponse_ChangePPS(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void ChangePPS(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const ChangePPSResponse& callback);
- virtual TPM_RC ChangePPSSync(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> ChangeEPSResponse;
+ virtual void ChangePPS(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const ChangePPSResponse& callback);
+ virtual TPM_RC ChangePPSSync(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> ChangeEPSResponse;
static TPM_RC SerializeCommand_ChangeEPS(
const TPMI_RH_PLATFORM& auth_handle,
const std::string& auth_handle_name,
@@ -5866,17 +5351,14 @@
static TPM_RC ParseResponse_ChangeEPS(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void ChangeEPS(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const ChangeEPSResponse& callback);
- virtual TPM_RC ChangeEPSSync(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> ClearResponse;
+ virtual void ChangeEPS(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const ChangeEPSResponse& callback);
+ virtual TPM_RC ChangeEPSSync(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> ClearResponse;
static TPM_RC SerializeCommand_Clear(
const TPMI_RH_CLEAR& auth_handle,
const std::string& auth_handle_name,
@@ -5885,17 +5367,14 @@
static TPM_RC ParseResponse_Clear(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void Clear(
- const TPMI_RH_CLEAR& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const ClearResponse& callback);
- virtual TPM_RC ClearSync(
- const TPMI_RH_CLEAR& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> ClearControlResponse;
+ virtual void Clear(const TPMI_RH_CLEAR& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const ClearResponse& callback);
+ virtual TPM_RC ClearSync(const TPMI_RH_CLEAR& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> ClearControlResponse;
static TPM_RC SerializeCommand_ClearControl(
const TPMI_RH_CLEAR& auth,
const std::string& auth_name,
@@ -5905,19 +5384,18 @@
static TPM_RC ParseResponse_ClearControl(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void ClearControl(
- const TPMI_RH_CLEAR& auth,
- const std::string& auth_name,
- const TPMI_YES_NO& disable,
- AuthorizationDelegate* authorization_delegate,
- const ClearControlResponse& callback);
+ virtual void ClearControl(const TPMI_RH_CLEAR& auth,
+ const std::string& auth_name,
+ const TPMI_YES_NO& disable,
+ AuthorizationDelegate* authorization_delegate,
+ const ClearControlResponse& callback);
virtual TPM_RC ClearControlSync(
const TPMI_RH_CLEAR& auth,
const std::string& auth_name,
const TPMI_YES_NO& disable,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> HierarchyChangeAuthResponse;
+ typedef base::Callback<void(TPM_RC response_code)>
+ HierarchyChangeAuthResponse;
static TPM_RC SerializeCommand_HierarchyChangeAuth(
const TPMI_RH_HIERARCHY_AUTH& auth_handle,
const std::string& auth_handle_name,
@@ -5938,8 +5416,8 @@
const std::string& auth_handle_name,
const TPM2B_AUTH& new_auth,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> DictionaryAttackLockResetResponse;
+ typedef base::Callback<void(TPM_RC response_code)>
+ DictionaryAttackLockResetResponse;
static TPM_RC SerializeCommand_DictionaryAttackLockReset(
const TPMI_RH_LOCKOUT& lock_handle,
const std::string& lock_handle_name,
@@ -5957,8 +5435,8 @@
const TPMI_RH_LOCKOUT& lock_handle,
const std::string& lock_handle_name,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> DictionaryAttackParametersResponse;
+ typedef base::Callback<void(TPM_RC response_code)>
+ DictionaryAttackParametersResponse;
static TPM_RC SerializeCommand_DictionaryAttackParameters(
const TPMI_RH_LOCKOUT& lock_handle,
const std::string& lock_handle_name,
@@ -5985,8 +5463,7 @@
const UINT32& new_recovery_time,
const UINT32& lockout_recovery,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> PP_CommandsResponse;
+ typedef base::Callback<void(TPM_RC response_code)> PP_CommandsResponse;
static TPM_RC SerializeCommand_PP_Commands(
const TPMI_RH_PLATFORM& auth,
const std::string& auth_name,
@@ -5997,21 +5474,18 @@
static TPM_RC ParseResponse_PP_Commands(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void PP_Commands(
- const TPMI_RH_PLATFORM& auth,
- const std::string& auth_name,
- const TPML_CC& set_list,
- const TPML_CC& clear_list,
- AuthorizationDelegate* authorization_delegate,
- const PP_CommandsResponse& callback);
- virtual TPM_RC PP_CommandsSync(
- const TPMI_RH_PLATFORM& auth,
- const std::string& auth_name,
- const TPML_CC& set_list,
- const TPML_CC& clear_list,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> SetAlgorithmSetResponse;
+ virtual void PP_Commands(const TPMI_RH_PLATFORM& auth,
+ const std::string& auth_name,
+ const TPML_CC& set_list,
+ const TPML_CC& clear_list,
+ AuthorizationDelegate* authorization_delegate,
+ const PP_CommandsResponse& callback);
+ virtual TPM_RC PP_CommandsSync(const TPMI_RH_PLATFORM& auth,
+ const std::string& auth_name,
+ const TPML_CC& set_list,
+ const TPML_CC& clear_list,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> SetAlgorithmSetResponse;
static TPM_RC SerializeCommand_SetAlgorithmSet(
const TPMI_RH_PLATFORM& auth_handle,
const std::string& auth_handle_name,
@@ -6021,19 +5495,17 @@
static TPM_RC ParseResponse_SetAlgorithmSet(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void SetAlgorithmSet(
- const TPMI_RH_PLATFORM& auth_handle,
- const std::string& auth_handle_name,
- const UINT32& algorithm_set,
- AuthorizationDelegate* authorization_delegate,
- const SetAlgorithmSetResponse& callback);
+ virtual void SetAlgorithmSet(const TPMI_RH_PLATFORM& auth_handle,
+ const std::string& auth_handle_name,
+ const UINT32& algorithm_set,
+ AuthorizationDelegate* authorization_delegate,
+ const SetAlgorithmSetResponse& callback);
virtual TPM_RC SetAlgorithmSetSync(
const TPMI_RH_PLATFORM& auth_handle,
const std::string& auth_handle_name,
const UINT32& algorithm_set,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> FieldUpgradeStartResponse;
+ typedef base::Callback<void(TPM_RC response_code)> FieldUpgradeStartResponse;
static TPM_RC SerializeCommand_FieldUpgradeStart(
const TPMI_RH_PLATFORM& authorization,
const std::string& authorization_name,
@@ -6046,15 +5518,14 @@
static TPM_RC ParseResponse_FieldUpgradeStart(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void FieldUpgradeStart(
- const TPMI_RH_PLATFORM& authorization,
- const std::string& authorization_name,
- const TPMI_DH_OBJECT& key_handle,
- const std::string& key_handle_name,
- const TPM2B_DIGEST& fu_digest,
- const TPMT_SIGNATURE& manifest_signature,
- AuthorizationDelegate* authorization_delegate,
- const FieldUpgradeStartResponse& callback);
+ virtual void FieldUpgradeStart(const TPMI_RH_PLATFORM& authorization,
+ const std::string& authorization_name,
+ const TPMI_DH_OBJECT& key_handle,
+ const std::string& key_handle_name,
+ const TPM2B_DIGEST& fu_digest,
+ const TPMT_SIGNATURE& manifest_signature,
+ AuthorizationDelegate* authorization_delegate,
+ const FieldUpgradeStartResponse& callback);
virtual TPM_RC FieldUpgradeStartSync(
const TPMI_RH_PLATFORM& authorization,
const std::string& authorization_name,
@@ -6063,10 +5534,10 @@
const TPM2B_DIGEST& fu_digest,
const TPMT_SIGNATURE& manifest_signature,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPMT_HA& next_digest,
- const TPMT_HA& first_digest)> FieldUpgradeDataResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPMT_HA& next_digest,
+ const TPMT_HA& first_digest)>
+ FieldUpgradeDataResponse;
static TPM_RC SerializeCommand_FieldUpgradeData(
const TPM2B_MAX_BUFFER& fu_data,
std::string* serialized_command,
@@ -6076,18 +5547,17 @@
TPMT_HA* next_digest,
TPMT_HA* first_digest,
AuthorizationDelegate* authorization_delegate);
- virtual void FieldUpgradeData(
- const TPM2B_MAX_BUFFER& fu_data,
- AuthorizationDelegate* authorization_delegate,
- const FieldUpgradeDataResponse& callback);
+ virtual void FieldUpgradeData(const TPM2B_MAX_BUFFER& fu_data,
+ AuthorizationDelegate* authorization_delegate,
+ const FieldUpgradeDataResponse& callback);
virtual TPM_RC FieldUpgradeDataSync(
const TPM2B_MAX_BUFFER& fu_data,
TPMT_HA* next_digest,
TPMT_HA* first_digest,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_MAX_BUFFER& fu_data)> FirmwareReadResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_MAX_BUFFER& fu_data)>
+ FirmwareReadResponse;
static TPM_RC SerializeCommand_FirmwareRead(
const UINT32& sequence_number,
std::string* serialized_command,
@@ -6096,17 +5566,16 @@
const std::string& response,
TPM2B_MAX_BUFFER* fu_data,
AuthorizationDelegate* authorization_delegate);
- virtual void FirmwareRead(
- const UINT32& sequence_number,
- AuthorizationDelegate* authorization_delegate,
- const FirmwareReadResponse& callback);
+ virtual void FirmwareRead(const UINT32& sequence_number,
+ AuthorizationDelegate* authorization_delegate,
+ const FirmwareReadResponse& callback);
virtual TPM_RC FirmwareReadSync(
const UINT32& sequence_number,
TPM2B_MAX_BUFFER* fu_data,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPMS_CONTEXT& context)> ContextSaveResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPMS_CONTEXT& context)>
+ ContextSaveResponse;
static TPM_RC SerializeCommand_ContextSave(
const TPMI_DH_CONTEXT& save_handle,
const std::string& save_handle_name,
@@ -6116,19 +5585,17 @@
const std::string& response,
TPMS_CONTEXT* context,
AuthorizationDelegate* authorization_delegate);
- virtual void ContextSave(
- const TPMI_DH_CONTEXT& save_handle,
- const std::string& save_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const ContextSaveResponse& callback);
- virtual TPM_RC ContextSaveSync(
- const TPMI_DH_CONTEXT& save_handle,
- const std::string& save_handle_name,
- TPMS_CONTEXT* context,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPMI_DH_CONTEXT& loaded_handle)> ContextLoadResponse;
+ virtual void ContextSave(const TPMI_DH_CONTEXT& save_handle,
+ const std::string& save_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const ContextSaveResponse& callback);
+ virtual TPM_RC ContextSaveSync(const TPMI_DH_CONTEXT& save_handle,
+ const std::string& save_handle_name,
+ TPMS_CONTEXT* context,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPMI_DH_CONTEXT& loaded_handle)>
+ ContextLoadResponse;
static TPM_RC SerializeCommand_ContextLoad(
const TPMS_CONTEXT& context,
std::string* serialized_command,
@@ -6137,16 +5604,13 @@
const std::string& response,
TPMI_DH_CONTEXT* loaded_handle,
AuthorizationDelegate* authorization_delegate);
- virtual void ContextLoad(
- const TPMS_CONTEXT& context,
- AuthorizationDelegate* authorization_delegate,
- const ContextLoadResponse& callback);
- virtual TPM_RC ContextLoadSync(
- const TPMS_CONTEXT& context,
- TPMI_DH_CONTEXT* loaded_handle,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> FlushContextResponse;
+ virtual void ContextLoad(const TPMS_CONTEXT& context,
+ AuthorizationDelegate* authorization_delegate,
+ const ContextLoadResponse& callback);
+ virtual TPM_RC ContextLoadSync(const TPMS_CONTEXT& context,
+ TPMI_DH_CONTEXT* loaded_handle,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> FlushContextResponse;
static TPM_RC SerializeCommand_FlushContext(
const TPMI_DH_CONTEXT& flush_handle,
std::string* serialized_command,
@@ -6154,15 +5618,13 @@
static TPM_RC ParseResponse_FlushContext(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void FlushContext(
- const TPMI_DH_CONTEXT& flush_handle,
- AuthorizationDelegate* authorization_delegate,
- const FlushContextResponse& callback);
+ virtual void FlushContext(const TPMI_DH_CONTEXT& flush_handle,
+ AuthorizationDelegate* authorization_delegate,
+ const FlushContextResponse& callback);
virtual TPM_RC FlushContextSync(
const TPMI_DH_CONTEXT& flush_handle,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> EvictControlResponse;
+ typedef base::Callback<void(TPM_RC response_code)> EvictControlResponse;
static TPM_RC SerializeCommand_EvictControl(
const TPMI_RH_PROVISION& auth,
const std::string& auth_name,
@@ -6174,14 +5636,13 @@
static TPM_RC ParseResponse_EvictControl(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void EvictControl(
- const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const TPMI_DH_OBJECT& object_handle,
- const std::string& object_handle_name,
- const TPMI_DH_PERSISTENT& persistent_handle,
- AuthorizationDelegate* authorization_delegate,
- const EvictControlResponse& callback);
+ virtual void EvictControl(const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const TPMI_DH_OBJECT& object_handle,
+ const std::string& object_handle_name,
+ const TPMI_DH_PERSISTENT& persistent_handle,
+ AuthorizationDelegate* authorization_delegate,
+ const EvictControlResponse& callback);
virtual TPM_RC EvictControlSync(
const TPMI_RH_PROVISION& auth,
const std::string& auth_name,
@@ -6189,9 +5650,9 @@
const std::string& object_handle_name,
const TPMI_DH_PERSISTENT& persistent_handle,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPMS_TIME_INFO& current_time)> ReadClockResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPMS_TIME_INFO& current_time)>
+ ReadClockResponse;
static TPM_RC SerializeCommand_ReadClock(
std::string* serialized_command,
AuthorizationDelegate* authorization_delegate);
@@ -6199,14 +5660,11 @@
const std::string& response,
TPMS_TIME_INFO* current_time,
AuthorizationDelegate* authorization_delegate);
- virtual void ReadClock(
- AuthorizationDelegate* authorization_delegate,
- const ReadClockResponse& callback);
- virtual TPM_RC ReadClockSync(
- TPMS_TIME_INFO* current_time,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> ClockSetResponse;
+ virtual void ReadClock(AuthorizationDelegate* authorization_delegate,
+ const ReadClockResponse& callback);
+ virtual TPM_RC ReadClockSync(TPMS_TIME_INFO* current_time,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> ClockSetResponse;
static TPM_RC SerializeCommand_ClockSet(
const TPMI_RH_PROVISION& auth,
const std::string& auth_name,
@@ -6216,19 +5674,16 @@
static TPM_RC ParseResponse_ClockSet(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void ClockSet(
- const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const UINT64& new_time,
- AuthorizationDelegate* authorization_delegate,
- const ClockSetResponse& callback);
- virtual TPM_RC ClockSetSync(
- const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const UINT64& new_time,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> ClockRateAdjustResponse;
+ virtual void ClockSet(const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const UINT64& new_time,
+ AuthorizationDelegate* authorization_delegate,
+ const ClockSetResponse& callback);
+ virtual TPM_RC ClockSetSync(const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const UINT64& new_time,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> ClockRateAdjustResponse;
static TPM_RC SerializeCommand_ClockRateAdjust(
const TPMI_RH_PROVISION& auth,
const std::string& auth_name,
@@ -6238,21 +5693,20 @@
static TPM_RC ParseResponse_ClockRateAdjust(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void ClockRateAdjust(
- const TPMI_RH_PROVISION& auth,
- const std::string& auth_name,
- const TPM_CLOCK_ADJUST& rate_adjust,
- AuthorizationDelegate* authorization_delegate,
- const ClockRateAdjustResponse& callback);
+ virtual void ClockRateAdjust(const TPMI_RH_PROVISION& auth,
+ const std::string& auth_name,
+ const TPM_CLOCK_ADJUST& rate_adjust,
+ AuthorizationDelegate* authorization_delegate,
+ const ClockRateAdjustResponse& callback);
virtual TPM_RC ClockRateAdjustSync(
const TPMI_RH_PROVISION& auth,
const std::string& auth_name,
const TPM_CLOCK_ADJUST& rate_adjust,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPMI_YES_NO& more_data,
- const TPMS_CAPABILITY_DATA& capability_data)> GetCapabilityResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPMI_YES_NO& more_data,
+ const TPMS_CAPABILITY_DATA& capability_data)>
+ GetCapabilityResponse;
static TPM_RC SerializeCommand_GetCapability(
const TPM_CAP& capability,
const UINT32& property,
@@ -6264,12 +5718,11 @@
TPMI_YES_NO* more_data,
TPMS_CAPABILITY_DATA* capability_data,
AuthorizationDelegate* authorization_delegate);
- virtual void GetCapability(
- const TPM_CAP& capability,
- const UINT32& property,
- const UINT32& property_count,
- AuthorizationDelegate* authorization_delegate,
- const GetCapabilityResponse& callback);
+ virtual void GetCapability(const TPM_CAP& capability,
+ const UINT32& property,
+ const UINT32& property_count,
+ AuthorizationDelegate* authorization_delegate,
+ const GetCapabilityResponse& callback);
virtual TPM_RC GetCapabilitySync(
const TPM_CAP& capability,
const UINT32& property,
@@ -6277,8 +5730,7 @@
TPMI_YES_NO* more_data,
TPMS_CAPABILITY_DATA* capability_data,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> TestParmsResponse;
+ typedef base::Callback<void(TPM_RC response_code)> TestParmsResponse;
static TPM_RC SerializeCommand_TestParms(
const TPMT_PUBLIC_PARMS& parameters,
std::string* serialized_command,
@@ -6286,15 +5738,12 @@
static TPM_RC ParseResponse_TestParms(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void TestParms(
- const TPMT_PUBLIC_PARMS& parameters,
- AuthorizationDelegate* authorization_delegate,
- const TestParmsResponse& callback);
- virtual TPM_RC TestParmsSync(
- const TPMT_PUBLIC_PARMS& parameters,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> NV_DefineSpaceResponse;
+ virtual void TestParms(const TPMT_PUBLIC_PARMS& parameters,
+ AuthorizationDelegate* authorization_delegate,
+ const TestParmsResponse& callback);
+ virtual TPM_RC TestParmsSync(const TPMT_PUBLIC_PARMS& parameters,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> NV_DefineSpaceResponse;
static TPM_RC SerializeCommand_NV_DefineSpace(
const TPMI_RH_PROVISION& auth_handle,
const std::string& auth_handle_name,
@@ -6305,21 +5754,19 @@
static TPM_RC ParseResponse_NV_DefineSpace(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void NV_DefineSpace(
- const TPMI_RH_PROVISION& auth_handle,
- const std::string& auth_handle_name,
- const TPM2B_AUTH& auth,
- const TPM2B_NV_PUBLIC& public_info,
- AuthorizationDelegate* authorization_delegate,
- const NV_DefineSpaceResponse& callback);
+ virtual void NV_DefineSpace(const TPMI_RH_PROVISION& auth_handle,
+ const std::string& auth_handle_name,
+ const TPM2B_AUTH& auth,
+ const TPM2B_NV_PUBLIC& public_info,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_DefineSpaceResponse& callback);
virtual TPM_RC NV_DefineSpaceSync(
const TPMI_RH_PROVISION& auth_handle,
const std::string& auth_handle_name,
const TPM2B_AUTH& auth,
const TPM2B_NV_PUBLIC& public_info,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> NV_UndefineSpaceResponse;
+ typedef base::Callback<void(TPM_RC response_code)> NV_UndefineSpaceResponse;
static TPM_RC SerializeCommand_NV_UndefineSpace(
const TPMI_RH_PROVISION& auth_handle,
const std::string& auth_handle_name,
@@ -6330,21 +5777,20 @@
static TPM_RC ParseResponse_NV_UndefineSpace(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void NV_UndefineSpace(
- const TPMI_RH_PROVISION& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_UndefineSpaceResponse& callback);
+ virtual void NV_UndefineSpace(const TPMI_RH_PROVISION& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_UndefineSpaceResponse& callback);
virtual TPM_RC NV_UndefineSpaceSync(
const TPMI_RH_PROVISION& auth_handle,
const std::string& auth_handle_name,
const TPMI_RH_NV_INDEX& nv_index,
const std::string& nv_index_name,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> NV_UndefineSpaceSpecialResponse;
+ typedef base::Callback<void(TPM_RC response_code)>
+ NV_UndefineSpaceSpecialResponse;
static TPM_RC SerializeCommand_NV_UndefineSpaceSpecial(
const TPMI_RH_NV_INDEX& nv_index,
const std::string& nv_index_name,
@@ -6368,10 +5814,10 @@
const TPMI_RH_PLATFORM& platform,
const std::string& platform_name,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_NV_PUBLIC& nv_public,
- const TPM2B_NAME& nv_name)> NV_ReadPublicResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_NV_PUBLIC& nv_public,
+ const TPM2B_NAME& nv_name)>
+ NV_ReadPublicResponse;
static TPM_RC SerializeCommand_NV_ReadPublic(
const TPMI_RH_NV_INDEX& nv_index,
const std::string& nv_index_name,
@@ -6382,19 +5828,17 @@
TPM2B_NV_PUBLIC* nv_public,
TPM2B_NAME* nv_name,
AuthorizationDelegate* authorization_delegate);
- virtual void NV_ReadPublic(
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_ReadPublicResponse& callback);
+ virtual void NV_ReadPublic(const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_ReadPublicResponse& callback);
virtual TPM_RC NV_ReadPublicSync(
const TPMI_RH_NV_INDEX& nv_index,
const std::string& nv_index_name,
TPM2B_NV_PUBLIC* nv_public,
TPM2B_NAME* nv_name,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> NV_WriteResponse;
+ typedef base::Callback<void(TPM_RC response_code)> NV_WriteResponse;
static TPM_RC SerializeCommand_NV_Write(
const TPMI_RH_NV_AUTH& auth_handle,
const std::string& auth_handle_name,
@@ -6407,25 +5851,22 @@
static TPM_RC ParseResponse_NV_Write(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void NV_Write(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_MAX_NV_BUFFER& data,
- const UINT16& offset,
- AuthorizationDelegate* authorization_delegate,
- const NV_WriteResponse& callback);
- virtual TPM_RC NV_WriteSync(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_MAX_NV_BUFFER& data,
- const UINT16& offset,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> NV_IncrementResponse;
+ virtual void NV_Write(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_MAX_NV_BUFFER& data,
+ const UINT16& offset,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_WriteResponse& callback);
+ virtual TPM_RC NV_WriteSync(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_MAX_NV_BUFFER& data,
+ const UINT16& offset,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> NV_IncrementResponse;
static TPM_RC SerializeCommand_NV_Increment(
const TPMI_RH_NV_AUTH& auth_handle,
const std::string& auth_handle_name,
@@ -6436,21 +5877,19 @@
static TPM_RC ParseResponse_NV_Increment(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void NV_Increment(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_IncrementResponse& callback);
+ virtual void NV_Increment(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_IncrementResponse& callback);
virtual TPM_RC NV_IncrementSync(
const TPMI_RH_NV_AUTH& auth_handle,
const std::string& auth_handle_name,
const TPMI_RH_NV_INDEX& nv_index,
const std::string& nv_index_name,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> NV_ExtendResponse;
+ typedef base::Callback<void(TPM_RC response_code)> NV_ExtendResponse;
static TPM_RC SerializeCommand_NV_Extend(
const TPMI_RH_NV_AUTH& auth_handle,
const std::string& auth_handle_name,
@@ -6462,23 +5901,20 @@
static TPM_RC ParseResponse_NV_Extend(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void NV_Extend(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_MAX_NV_BUFFER& data,
- AuthorizationDelegate* authorization_delegate,
- const NV_ExtendResponse& callback);
- virtual TPM_RC NV_ExtendSync(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_MAX_NV_BUFFER& data,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> NV_SetBitsResponse;
+ virtual void NV_Extend(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_MAX_NV_BUFFER& data,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_ExtendResponse& callback);
+ virtual TPM_RC NV_ExtendSync(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_MAX_NV_BUFFER& data,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> NV_SetBitsResponse;
static TPM_RC SerializeCommand_NV_SetBits(
const TPMI_RH_NV_AUTH& auth_handle,
const std::string& auth_handle_name,
@@ -6490,23 +5926,20 @@
static TPM_RC ParseResponse_NV_SetBits(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void NV_SetBits(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const UINT64& bits,
- AuthorizationDelegate* authorization_delegate,
- const NV_SetBitsResponse& callback);
- virtual TPM_RC NV_SetBitsSync(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const UINT64& bits,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> NV_WriteLockResponse;
+ virtual void NV_SetBits(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const UINT64& bits,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_SetBitsResponse& callback);
+ virtual TPM_RC NV_SetBitsSync(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const UINT64& bits,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> NV_WriteLockResponse;
static TPM_RC SerializeCommand_NV_WriteLock(
const TPMI_RH_NV_AUTH& auth_handle,
const std::string& auth_handle_name,
@@ -6517,21 +5950,19 @@
static TPM_RC ParseResponse_NV_WriteLock(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void NV_WriteLock(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_WriteLockResponse& callback);
+ virtual void NV_WriteLock(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_WriteLockResponse& callback);
virtual TPM_RC NV_WriteLockSync(
const TPMI_RH_NV_AUTH& auth_handle,
const std::string& auth_handle_name,
const TPMI_RH_NV_INDEX& nv_index,
const std::string& nv_index_name,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> NV_GlobalWriteLockResponse;
+ typedef base::Callback<void(TPM_RC response_code)> NV_GlobalWriteLockResponse;
static TPM_RC SerializeCommand_NV_GlobalWriteLock(
const TPMI_RH_PROVISION& auth_handle,
const std::string& auth_handle_name,
@@ -6540,18 +5971,17 @@
static TPM_RC ParseResponse_NV_GlobalWriteLock(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void NV_GlobalWriteLock(
- const TPMI_RH_PROVISION& auth_handle,
- const std::string& auth_handle_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_GlobalWriteLockResponse& callback);
+ virtual void NV_GlobalWriteLock(const TPMI_RH_PROVISION& auth_handle,
+ const std::string& auth_handle_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_GlobalWriteLockResponse& callback);
virtual TPM_RC NV_GlobalWriteLockSync(
const TPMI_RH_PROVISION& auth_handle,
const std::string& auth_handle_name,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_MAX_NV_BUFFER& data)> NV_ReadResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_MAX_NV_BUFFER& data)>
+ NV_ReadResponse;
static TPM_RC SerializeCommand_NV_Read(
const TPMI_RH_NV_AUTH& auth_handle,
const std::string& auth_handle_name,
@@ -6565,26 +5995,23 @@
const std::string& response,
TPM2B_MAX_NV_BUFFER* data,
AuthorizationDelegate* authorization_delegate);
- virtual void NV_Read(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const UINT16& size,
- const UINT16& offset,
- AuthorizationDelegate* authorization_delegate,
- const NV_ReadResponse& callback);
- virtual TPM_RC NV_ReadSync(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const UINT16& size,
- const UINT16& offset,
- TPM2B_MAX_NV_BUFFER* data,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> NV_ReadLockResponse;
+ virtual void NV_Read(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const UINT16& size,
+ const UINT16& offset,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_ReadResponse& callback);
+ virtual TPM_RC NV_ReadSync(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const UINT16& size,
+ const UINT16& offset,
+ TPM2B_MAX_NV_BUFFER* data,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> NV_ReadLockResponse;
static TPM_RC SerializeCommand_NV_ReadLock(
const TPMI_RH_NV_AUTH& auth_handle,
const std::string& auth_handle_name,
@@ -6595,21 +6022,18 @@
static TPM_RC ParseResponse_NV_ReadLock(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void NV_ReadLock(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate,
- const NV_ReadLockResponse& callback);
- virtual TPM_RC NV_ReadLockSync(
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code)> NV_ChangeAuthResponse;
+ virtual void NV_ReadLock(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_ReadLockResponse& callback);
+ virtual TPM_RC NV_ReadLockSync(const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ AuthorizationDelegate* authorization_delegate);
+ typedef base::Callback<void(TPM_RC response_code)> NV_ChangeAuthResponse;
static TPM_RC SerializeCommand_NV_ChangeAuth(
const TPMI_RH_NV_INDEX& nv_index,
const std::string& nv_index_name,
@@ -6619,21 +6043,20 @@
static TPM_RC ParseResponse_NV_ChangeAuth(
const std::string& response,
AuthorizationDelegate* authorization_delegate);
- virtual void NV_ChangeAuth(
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_AUTH& new_auth,
- AuthorizationDelegate* authorization_delegate,
- const NV_ChangeAuthResponse& callback);
+ virtual void NV_ChangeAuth(const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_AUTH& new_auth,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_ChangeAuthResponse& callback);
virtual TPM_RC NV_ChangeAuthSync(
const TPMI_RH_NV_INDEX& nv_index,
const std::string& nv_index_name,
const TPM2B_AUTH& new_auth,
AuthorizationDelegate* authorization_delegate);
- typedef base::Callback<void(
- TPM_RC response_code,
- const TPM2B_ATTEST& certify_info,
- const TPMT_SIGNATURE& signature)> NV_CertifyResponse;
+ typedef base::Callback<void(TPM_RC response_code,
+ const TPM2B_ATTEST& certify_info,
+ const TPMT_SIGNATURE& signature)>
+ NV_CertifyResponse;
static TPM_RC SerializeCommand_NV_Certify(
const TPMI_DH_OBJECT& sign_handle,
const std::string& sign_handle_name,
@@ -6652,33 +6075,31 @@
TPM2B_ATTEST* certify_info,
TPMT_SIGNATURE* signature,
AuthorizationDelegate* authorization_delegate);
- virtual void NV_Certify(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- const UINT16& size,
- const UINT16& offset,
- AuthorizationDelegate* authorization_delegate,
- const NV_CertifyResponse& callback);
- virtual TPM_RC NV_CertifySync(
- const TPMI_DH_OBJECT& sign_handle,
- const std::string& sign_handle_name,
- const TPMI_RH_NV_AUTH& auth_handle,
- const std::string& auth_handle_name,
- const TPMI_RH_NV_INDEX& nv_index,
- const std::string& nv_index_name,
- const TPM2B_DATA& qualifying_data,
- const TPMT_SIG_SCHEME& in_scheme,
- const UINT16& size,
- const UINT16& offset,
- TPM2B_ATTEST* certify_info,
- TPMT_SIGNATURE* signature,
- AuthorizationDelegate* authorization_delegate);
+ virtual void NV_Certify(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const UINT16& size,
+ const UINT16& offset,
+ AuthorizationDelegate* authorization_delegate,
+ const NV_CertifyResponse& callback);
+ virtual TPM_RC NV_CertifySync(const TPMI_DH_OBJECT& sign_handle,
+ const std::string& sign_handle_name,
+ const TPMI_RH_NV_AUTH& auth_handle,
+ const std::string& auth_handle_name,
+ const TPMI_RH_NV_INDEX& nv_index,
+ const std::string& nv_index_name,
+ const TPM2B_DATA& qualifying_data,
+ const TPMT_SIG_SCHEME& in_scheme,
+ const UINT16& size,
+ const UINT16& offset,
+ TPM2B_ATTEST* certify_info,
+ TPMT_SIGNATURE* signature,
+ AuthorizationDelegate* authorization_delegate);
private:
CommandTransceiver* transceiver_;
diff --git a/trunks/tpm_generated_test.cc b/trunks/tpm_generated_test.cc
index 6048153..21e3791 100644
--- a/trunks/tpm_generated_test.cc
+++ b/trunks/tpm_generated_test.cc
@@ -64,8 +64,7 @@
EXPECT_EQ(0u, buffer.size());
EXPECT_EQ(buffer_before, buffer_parsed);
EXPECT_EQ(buffer_before.size() - 2, data2.size);
- EXPECT_EQ(0, memcmp(&data.creation_data,
- &data2.creation_data,
+ EXPECT_EQ(0, memcmp(&data.creation_data, &data2.creation_data,
sizeof(TPMS_CREATION_DATA)));
}
@@ -92,15 +91,17 @@
TEST(GeneratorTest, SynchronousCommand) {
// A hand-rolled TPM2_Startup command.
- std::string expected_command("\x80\x01" // tag=TPM_ST_NO_SESSIONS
- "\x00\x00\x00\x0C" // size=12
- "\x00\x00\x01\x44" // code=TPM_CC_Startup
- "\x00\x00", // param=TPM_SU_CLEAR
- 12);
- std::string command_response("\x80\x01" // tag=TPM_ST_NO_SESSIONS
- "\x00\x00\x00\x0A" // size=10
- "\x00\x00\x00\x00", // code=TPM_RC_SUCCESS
- 10);
+ std::string expected_command(
+ "\x80\x01" // tag=TPM_ST_NO_SESSIONS
+ "\x00\x00\x00\x0C" // size=12
+ "\x00\x00\x01\x44" // code=TPM_CC_Startup
+ "\x00\x00", // param=TPM_SU_CLEAR
+ 12);
+ std::string command_response(
+ "\x80\x01" // tag=TPM_ST_NO_SESSIONS
+ "\x00\x00\x00\x0A" // size=10
+ "\x00\x00\x00\x00", // code=TPM_RC_SUCCESS
+ 10);
StrictMock<MockCommandTransceiver> transceiver;
EXPECT_CALL(transceiver, SendCommandAndWait(expected_command))
.WillOnce(Return(command_response));
@@ -113,15 +114,17 @@
TEST(GeneratorTest, SynchronousCommandWithError) {
// A hand-rolled TPM2_Startup command.
- std::string expected_command("\x80\x01" // tag=TPM_ST_NO_SESSIONS
- "\x00\x00\x00\x0C" // size=12
- "\x00\x00\x01\x44" // code=TPM_CC_Startup
- "\x00\x00", // param=TPM_SU_CLEAR
- 12);
- std::string command_response("\x80\x01" // tag=TPM_ST_NO_SESSIONS
- "\x00\x00\x00\x0A" // size=10
- "\x00\x00\x01\x01", // code=TPM_RC_FAILURE
- 10);
+ std::string expected_command(
+ "\x80\x01" // tag=TPM_ST_NO_SESSIONS
+ "\x00\x00\x00\x0C" // size=12
+ "\x00\x00\x01\x44" // code=TPM_CC_Startup
+ "\x00\x00", // param=TPM_SU_CLEAR
+ 12);
+ std::string command_response(
+ "\x80\x01" // tag=TPM_ST_NO_SESSIONS
+ "\x00\x00\x00\x0A" // size=10
+ "\x00\x00\x01\x01", // code=TPM_RC_FAILURE
+ 10);
StrictMock<MockCommandTransceiver> transceiver;
EXPECT_CALL(transceiver, SendCommandAndWait(expected_command))
.WillOnce(Return(command_response));
@@ -138,49 +141,61 @@
std::string auth_size("\x00\x00\x00\x0A", 4);
std::string handle_in("\x40\x00\x00\x07", 4); // primary_handle = TPM_RH_NULL
std::string handle_out("\x80\x00\x00\x01", 4); // out_handle
- std::string sensitive("\x00\x05" // sensitive.size = 5
- "\x00\x01" // sensitive.auth.size = 1
- "\x61" // sensitive.auth.buffer[0] = 0x65
- "\x00\x00", // sensitive.data.size = 0
- 7);
- std::string public_data("\x00\x12" // public.size = 18
- "\x00\x25" // public.type = TPM_ALG_SYMCIPHER
- "\x00\x0B" // public.name_alg = SHA256
- "\x00\x00\x00\x00"
- "\x00\x00" // public.auth_policy.size = 0
- "\x00\x06" // public.sym.alg = TPM_ALG_AES
- "\x00\x80" // public.sym.key_bits = 128
- "\x00\x43" // public.sym.mode = TPM_ALG_CFB
- "\x00\x00", // public.unique.size = 0
- 20);
- std::string outside("\x00\x00", 2); // outside_info.size = 0
+ std::string sensitive(
+ "\x00\x05" // sensitive.size = 5
+ "\x00\x01" // sensitive.auth.size = 1
+ "\x61" // sensitive.auth.buffer[0] = 0x65
+ "\x00\x00", // sensitive.data.size = 0
+ 7);
+ std::string public_data(
+ "\x00\x12" // public.size = 18
+ "\x00\x25" // public.type = TPM_ALG_SYMCIPHER
+ "\x00\x0B" // public.name_alg = SHA256
+ "\x00\x00\x00\x00"
+ "\x00\x00" // public.auth_policy.size = 0
+ "\x00\x06" // public.sym.alg = TPM_ALG_AES
+ "\x00\x80" // public.sym.key_bits = 128
+ "\x00\x43" // public.sym.mode = TPM_ALG_CFB
+ "\x00\x00", // public.unique.size = 0
+ 20);
+ std::string outside("\x00\x00", 2); // outside_info.size = 0
std::string pcr_select("\x00\x00\x00\x00", 4); // pcr_select.size = 0
- std::string data("\x00\x0F" // creation_data.size = 15
- "\x00\x00\x00\x00" // creation.pcr = 0
- "\x00\x00" // creation.digest.size = 0
- "\x00" // creation.locality = 0
- "\x00\x00" // creation.parent_alg = 0
- "\x00\x00" // creation.parent_name.size = 0
- "\x00\x00"
- "\x00\x00", // creation.outside.size = 0
- 17);
- std::string hash("\x00\x01"
- "\x62", 3);
- std::string ticket("\x80\x02" // tag = TPM_ST_SESSIONS
- "\x40\x00\x00\x07" // parent = TPM_RH_NULL
- "\x00\x00", 8);
- std::string name("\x00\x03" "KEY", 5);
+ std::string data(
+ "\x00\x0F" // creation_data.size = 15
+ "\x00\x00\x00\x00" // creation.pcr = 0
+ "\x00\x00" // creation.digest.size = 0
+ "\x00" // creation.locality = 0
+ "\x00\x00" // creation.parent_alg = 0
+ "\x00\x00" // creation.parent_name.size = 0
+ "\x00\x00"
+ "\x00\x00", // creation.outside.size = 0
+ 17);
+ std::string hash(
+ "\x00\x01"
+ "\x62",
+ 3);
+ std::string ticket(
+ "\x80\x02" // tag = TPM_ST_SESSIONS
+ "\x40\x00\x00\x07" // parent = TPM_RH_NULL
+ "\x00\x00",
+ 8);
+ std::string name(
+ "\x00\x03"
+ "KEY",
+ 5);
std::string parameter_size("\x00\x00\x00\x35", 4); // param_size = 38
- std::string command_tag("\x80\x02" // tag = TPM_ST_SESSIONS
- "\x00\x00\x00\x3D" // size = 61
- "\x00\x00\x01\x31", // code = TPM_CC_CreatePrimary
- 10);
- std::string response_tag("\x80\x02" // tag = TPM_ST_SESSIONS
- "\x00\x00\x00\x51" // size = 79
- "\x00\x00\x00\x00", // rc = TPM_RC_SUCCESS
- 10);
+ std::string command_tag(
+ "\x80\x02" // tag = TPM_ST_SESSIONS
+ "\x00\x00\x00\x3D" // size = 61
+ "\x00\x00\x01\x31", // code = TPM_CC_CreatePrimary
+ 10);
+ std::string response_tag(
+ "\x80\x02" // tag = TPM_ST_SESSIONS
+ "\x00\x00\x00\x51" // size = 79
+ "\x00\x00\x00\x00", // rc = TPM_RC_SUCCESS
+ 10);
std::string expected_command = command_tag + handle_in + auth_size + auth_in +
sensitive + public_data + outside + pcr_select;
@@ -196,8 +211,7 @@
.WillOnce(DoAll(SetArgPointee<3>(auth_in), Return(true)));
EXPECT_CALL(authorization, CheckResponseAuthorization(_, auth_out))
.WillOnce(Return(true));
- EXPECT_CALL(authorization, EncryptCommandParameter(_))
- .WillOnce(Return(true));
+ EXPECT_CALL(authorization, EncryptCommandParameter(_)).WillOnce(Return(true));
EXPECT_CALL(authorization, DecryptResponseParameter(_))
.WillOnce(Return(true));
@@ -229,19 +243,10 @@
TPM2B_NAME key_name;
Tpm tpm(&transceiver);
- TPM_RC rc = tpm.CreatePrimarySync(trunks::TPM_RH_NULL,
- "",
- in_sensitive,
- in_public,
- outside_info,
- create_pcr,
- &key_handle,
- &out_public,
- &creation_data,
- &creation_hash,
- &creation_ticket,
- &key_name,
- &authorization);
+ TPM_RC rc = tpm.CreatePrimarySync(
+ trunks::TPM_RH_NULL, "", in_sensitive, in_public, outside_info,
+ create_pcr, &key_handle, &out_public, &creation_data, &creation_hash,
+ &creation_ticket, &key_name, &authorization);
ASSERT_EQ(rc, TPM_RC_SUCCESS);
EXPECT_EQ(key_handle, 0x80000001);
EXPECT_EQ(out_public.size, 18);
@@ -263,17 +268,15 @@
CommandFlowTest() : response_code_(TPM_RC_SUCCESS) {}
~CommandFlowTest() override {}
- void StartupCallback(TPM_RC response_code) {
- response_code_ = response_code;
- }
+ void StartupCallback(TPM_RC response_code) { response_code_ = response_code; }
void CertifyCallback(TPM_RC response_code,
const TPM2B_ATTEST& certify_info,
const TPMT_SIGNATURE& signature) {
response_code_ = response_code;
signed_data_ = StringFrom_TPM2B_ATTEST(certify_info);
- signature_ = StringFrom_TPM2B_PUBLIC_KEY_RSA(
- signature.signature.rsassa.sig);
+ signature_ =
+ StringFrom_TPM2B_PUBLIC_KEY_RSA(signature.signature.rsassa.sig);
}
protected:
@@ -295,7 +298,7 @@
class PostResponse {
public:
explicit PostResponse(const std::string& response) : response_(response) {}
- void operator() (const base::Callback<void(const std::string&)>& callback) {
+ void operator()(const base::Callback<void(const std::string&)>& callback) {
base::MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(callback, response_));
}
@@ -308,9 +311,8 @@
class Encryptor {
public:
Encryptor(const std::string& expected_input, const std::string& output)
- : expected_input_(expected_input),
- output_(output) {}
- bool operator() (std::string* value) {
+ : expected_input_(expected_input), output_(output) {}
+ bool operator()(std::string* value) {
EXPECT_EQ(expected_input_, *value);
value->assign(output_);
return true;
@@ -323,15 +325,17 @@
TEST_F(CommandFlowTest, SimpleCommandFlow) {
// A hand-rolled TPM2_Startup command.
- std::string expected_command("\x80\x01" // tag=TPM_ST_NO_SESSIONS
- "\x00\x00\x00\x0C" // size=12
- "\x00\x00\x01\x44" // code=TPM_CC_Startup
- "\x00\x00", // param=TPM_SU_CLEAR
- 12);
- std::string command_response("\x80\x01" // tag=TPM_ST_NO_SESSIONS
- "\x00\x00\x00\x0A" // size=10
- "\x00\x00\x00\x00", // code=TPM_RC_SUCCESS
- 10);
+ std::string expected_command(
+ "\x80\x01" // tag=TPM_ST_NO_SESSIONS
+ "\x00\x00\x00\x0C" // size=12
+ "\x00\x00\x01\x44" // code=TPM_CC_Startup
+ "\x00\x00", // param=TPM_SU_CLEAR
+ 12);
+ std::string command_response(
+ "\x80\x01" // tag=TPM_ST_NO_SESSIONS
+ "\x00\x00\x00\x0A" // size=10
+ "\x00\x00\x00\x00", // code=TPM_RC_SUCCESS
+ 10);
StrictMock<MockCommandTransceiver> transceiver;
EXPECT_CALL(transceiver, SendCommand(expected_command, _))
.WillOnce(WithArg<1>(Invoke(PostResponse(command_response))));
@@ -340,25 +344,26 @@
.WillOnce(Return(true));
Tpm tpm(&transceiver);
response_code_ = TPM_RC_FAILURE;
- tpm.Startup(TPM_SU_CLEAR,
- &authorization,
- base::Bind(&CommandFlowTest::StartupCallback,
- base::Unretained(this)));
+ tpm.Startup(
+ TPM_SU_CLEAR, &authorization,
+ base::Bind(&CommandFlowTest::StartupCallback, base::Unretained(this)));
Run();
EXPECT_EQ(TPM_RC_SUCCESS, response_code_);
}
TEST_F(CommandFlowTest, SimpleCommandFlowWithError) {
// A hand-rolled TPM2_Startup command.
- std::string expected_command("\x80\x01" // tag=TPM_ST_NO_SESSIONS
- "\x00\x00\x00\x0C" // size=12
- "\x00\x00\x01\x44" // code=TPM_CC_Startup
- "\x00\x00", // param=TPM_SU_CLEAR
- 12);
- std::string command_response("\x80\x01" // tag=TPM_ST_NO_SESSIONS
- "\x00\x00\x00\x0A" // size=10
- "\x00\x00\x01\x01", // code=TPM_RC_FAILURE
- 10);
+ std::string expected_command(
+ "\x80\x01" // tag=TPM_ST_NO_SESSIONS
+ "\x00\x00\x00\x0C" // size=12
+ "\x00\x00\x01\x44" // code=TPM_CC_Startup
+ "\x00\x00", // param=TPM_SU_CLEAR
+ 12);
+ std::string command_response(
+ "\x80\x01" // tag=TPM_ST_NO_SESSIONS
+ "\x00\x00\x00\x0A" // size=10
+ "\x00\x00\x01\x01", // code=TPM_RC_FAILURE
+ 10);
StrictMock<MockCommandTransceiver> transceiver;
EXPECT_CALL(transceiver, SendCommand(expected_command, _))
.WillOnce(WithArg<1>(Invoke(PostResponse(command_response))));
@@ -366,10 +371,9 @@
EXPECT_CALL(authorization, GetCommandAuthorization(_, _, _, _))
.WillOnce(Return(true));
Tpm tpm(&transceiver);
- tpm.Startup(TPM_SU_CLEAR,
- &authorization,
- base::Bind(&CommandFlowTest::StartupCallback,
- base::Unretained(this)));
+ tpm.Startup(
+ TPM_SU_CLEAR, &authorization,
+ base::Bind(&CommandFlowTest::StartupCallback, base::Unretained(this)));
Run();
EXPECT_EQ(TPM_RC_FAILURE, response_code_);
}
@@ -384,27 +388,36 @@
// A hand-rolled TPM2_Certify command.
std::string auth_in(10, 'A');
std::string auth_out(20, 'B');
- std::string user_data("\x00\x0C" "ct_user_data", 14);
+ std::string user_data(
+ "\x00\x0C"
+ "ct_user_data",
+ 14);
std::string scheme("\x00\x10", 2); // scheme=TPM_ALG_NULL
- std::string signed_data("\x00\x0E" "ct_signed_data", 16);
- std::string signature("\x00\x14" // sig_scheme=RSASSA
- "\x00\x0B" // hash_scheme=SHA256
- "\x00\x09" // signature size
- "signature", // signature bytes
- 15);
- std::string expected_command("\x80\x02" // tag=TPM_ST_SESSIONS
- "\x00\x00\x00\x30" // size=48
- "\x00\x00\x01\x48" // code=TPM_CC_Certify
- "\x11\x22\x33\x44" // @objectHandle
- "\x55\x66\x77\x88" // @signHandle
- "\x00\x00\x00\x0A", // auth_size=10
- 22);
+ std::string signed_data(
+ "\x00\x0E"
+ "ct_signed_data",
+ 16);
+ std::string signature(
+ "\x00\x14" // sig_scheme=RSASSA
+ "\x00\x0B" // hash_scheme=SHA256
+ "\x00\x09" // signature size
+ "signature", // signature bytes
+ 15);
+ std::string expected_command(
+ "\x80\x02" // tag=TPM_ST_SESSIONS
+ "\x00\x00\x00\x30" // size=48
+ "\x00\x00\x01\x48" // code=TPM_CC_Certify
+ "\x11\x22\x33\x44" // @objectHandle
+ "\x55\x66\x77\x88" // @signHandle
+ "\x00\x00\x00\x0A", // auth_size=10
+ 22);
expected_command += auth_in + user_data + scheme;
- std::string command_response("\x80\x02" // tag=TPM_ST_SESSIONS
- "\x00\x00\x00\x41" // size=65
- "\x00\x00\x00\x00" // code=TPM_RC_SUCCESS
- "\x00\x00\x00\x1F", // param_size=31
- 14);
+ std::string command_response(
+ "\x80\x02" // tag=TPM_ST_SESSIONS
+ "\x00\x00\x00\x41" // size=65
+ "\x00\x00\x00\x00" // code=TPM_RC_SUCCESS
+ "\x00\x00\x00\x1F", // param_size=31
+ 14);
command_response += signed_data + signature + auth_out;
StrictMock<MockCommandTransceiver> transceiver;
@@ -424,13 +437,10 @@
null_scheme.scheme = TPM_ALG_NULL;
null_scheme.details.rsassa.hash_alg = TPM_ALG_SHA256;
Tpm tpm(&transceiver);
- tpm.Certify(0x11223344u, "object_handle",
- 0x55667788u, "sign_handle",
- Make_TPM2B_DATA("pt_user_data"),
- null_scheme,
- &authorization,
- base::Bind(&CommandFlowTest::CertifyCallback,
- base::Unretained(this)));
+ tpm.Certify(
+ 0x11223344u, "object_handle", 0x55667788u, "sign_handle",
+ Make_TPM2B_DATA("pt_user_data"), null_scheme, &authorization,
+ base::Bind(&CommandFlowTest::CertifyCallback, base::Unretained(this)));
Run();
ASSERT_EQ(TPM_RC_SUCCESS, response_code_);
EXPECT_EQ("pt_signed_data", signed_data_);
diff --git a/trunks/tpm_handle.h b/trunks/tpm_handle.h
index 3aa626f..cde9868 100644
--- a/trunks/tpm_handle.h
+++ b/trunks/tpm_handle.h
@@ -34,7 +34,7 @@
// TpmHandle handle;
// if (!handle.Init()) {...}
// std::string response = handle.SendCommandAndWait(command);
-class TpmHandle : public CommandTransceiver {
+class TpmHandle : public CommandTransceiver {
public:
TpmHandle();
~TpmHandle() override;
diff --git a/trunks/tpm_simulator_handle.cc b/trunks/tpm_simulator_handle.cc
index 0ef8210..4f4354d 100644
--- a/trunks/tpm_simulator_handle.cc
+++ b/trunks/tpm_simulator_handle.cc
@@ -56,7 +56,7 @@
}
void TpmSimulatorHandle::SendCommand(const std::string& command,
- const ResponseCallback& callback) {
+ const ResponseCallback& callback) {
callback.Run(SendCommandAndWait(command));
}
diff --git a/trunks/tpm_simulator_handle.h b/trunks/tpm_simulator_handle.h
index 24c65ca..8118cdc 100644
--- a/trunks/tpm_simulator_handle.h
+++ b/trunks/tpm_simulator_handle.h
@@ -35,7 +35,7 @@
// TpmSimulatorHandle handle;
// if (!handle.Init()) {...}
// std::string response = handle.SendCommandAndWait(command);
-class TpmSimulatorHandle : public CommandTransceiver {
+class TpmSimulatorHandle : public CommandTransceiver {
public:
TpmSimulatorHandle();
~TpmSimulatorHandle() override;
diff --git a/trunks/tpm_state_impl.cc b/trunks/tpm_state_impl.cc
index ca9f7b0..93874c4 100644
--- a/trunks/tpm_state_impl.cc
+++ b/trunks/tpm_state_impl.cc
@@ -49,8 +49,7 @@
permanent_flags_(0),
startup_clear_flags_(0),
rsa_flags_(0),
- ecc_flags_(0) {
-}
+ ecc_flags_(0) {}
TpmStateImpl::~TpmStateImpl() {}
@@ -88,11 +87,9 @@
TPMI_YES_NO more_data;
TPMS_CAPABILITY_DATA capability_data;
- result = factory_.GetTpm()->GetCapabilitySync(TPM_CAP_ALGS,
- TPM_ALG_RSA,
+ result = factory_.GetTpm()->GetCapabilitySync(TPM_CAP_ALGS, TPM_ALG_RSA,
1, // There is only one value.
- &more_data,
- &capability_data,
+ &more_data, &capability_data,
nullptr);
if (result) {
LOG(ERROR) << __func__ << ": " << GetErrorString(result);
@@ -107,11 +104,9 @@
rsa_flags_ =
capability_data.data.algorithms.alg_properties[0].alg_properties;
}
- result = factory_.GetTpm()->GetCapabilitySync(TPM_CAP_ALGS,
- TPM_ALG_ECC,
+ result = factory_.GetTpm()->GetCapabilitySync(TPM_CAP_ALGS, TPM_ALG_ECC,
1, // There is only one value.
- &more_data,
- &capability_data,
+ &more_data, &capability_data,
nullptr);
if (result) {
LOG(ERROR) << __func__ << ": " << GetErrorString(result);
@@ -147,8 +142,7 @@
}
bool TpmStateImpl::IsOwned() {
- return (IsOwnerPasswordSet() &&
- IsEndorsementPasswordSet() &&
+ return (IsOwnerPasswordSet() && IsEndorsementPasswordSet() &&
IsLockoutPasswordSet());
}
@@ -160,31 +154,30 @@
bool TpmStateImpl::IsPlatformHierarchyEnabled() {
CHECK(initialized_);
return ((startup_clear_flags_ & kPlatformHierarchyMask) ==
- kPlatformHierarchyMask);
+ kPlatformHierarchyMask);
}
bool TpmStateImpl::IsStorageHierarchyEnabled() {
CHECK(initialized_);
return ((startup_clear_flags_ & kStorageHierarchyMask) ==
- kStorageHierarchyMask);
+ kStorageHierarchyMask);
}
bool TpmStateImpl::IsEndorsementHierarchyEnabled() {
CHECK(initialized_);
return ((startup_clear_flags_ & kEndorsementHierarchyMask) ==
- kEndorsementHierarchyMask);
+ kEndorsementHierarchyMask);
}
bool TpmStateImpl::IsEnabled() {
- return (!IsPlatformHierarchyEnabled() &&
- IsStorageHierarchyEnabled() &&
+ return (!IsPlatformHierarchyEnabled() && IsStorageHierarchyEnabled() &&
IsEndorsementHierarchyEnabled());
}
bool TpmStateImpl::WasShutdownOrderly() {
CHECK(initialized_);
return ((startup_clear_flags_ & kOrderlyShutdownMask) ==
- kOrderlyShutdownMask);
+ kOrderlyShutdownMask);
}
bool TpmStateImpl::IsRSASupported() {
@@ -217,17 +210,14 @@
return lockout_recovery_;
}
-TPM_RC TpmStateImpl::GetTpmProperty(uint32_t property,
- uint32_t* value) {
+TPM_RC TpmStateImpl::GetTpmProperty(uint32_t property, uint32_t* value) {
CHECK(value);
TPMI_YES_NO more_data;
TPMS_CAPABILITY_DATA capability_data;
- TPM_RC result = factory_.GetTpm()->GetCapabilitySync(TPM_CAP_TPM_PROPERTIES,
- property,
- 1, // Only one property.
- &more_data,
- &capability_data,
- nullptr);
+ TPM_RC result = factory_.GetTpm()->GetCapabilitySync(
+ TPM_CAP_TPM_PROPERTIES, property,
+ 1, // Only one property.
+ &more_data, &capability_data, nullptr);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << __func__ << ": " << GetErrorString(result);
return result;
@@ -235,7 +225,7 @@
if (capability_data.capability != TPM_CAP_TPM_PROPERTIES ||
capability_data.data.tpm_properties.count != 1 ||
capability_data.data.tpm_properties.tpm_property[0].property !=
- property) {
+ property) {
LOG(ERROR) << __func__ << ": Unexpected capability data.";
return SAPI_RC_MALFORMED_RESPONSE;
}
diff --git a/trunks/tpm_state_test.cc b/trunks/tpm_state_test.cc
index 8bf4f39..7356d8e 100644
--- a/trunks/tpm_state_test.cc
+++ b/trunks/tpm_state_test.cc
@@ -53,40 +53,37 @@
lockout_recovery_ = GetValidCapabilityData(TPM_PT_LOCKOUT_RECOVERY, 0);
EXPECT_CALL(mock_tpm_, GetCapabilitySync(TPM_CAP_TPM_PROPERTIES,
TPM_PT_PERMANENT, 1, _, _, _))
- .WillRepeatedly(WithArgs<4>(
- Invoke(this, &TpmStateTest::GetLivePermanent)));
+ .WillRepeatedly(
+ WithArgs<4>(Invoke(this, &TpmStateTest::GetLivePermanent)));
EXPECT_CALL(mock_tpm_, GetCapabilitySync(TPM_CAP_TPM_PROPERTIES,
TPM_PT_STARTUP_CLEAR, 1, _, _, _))
- .WillRepeatedly(WithArgs<4>(
- Invoke(this, &TpmStateTest::GetLiveStartupClear)));
- EXPECT_CALL(mock_tpm_, GetCapabilitySync(TPM_CAP_ALGS,
- TPM_ALG_RSA, 1, _, _, _))
- .WillRepeatedly(WithArgs<4>(
- Invoke(this, &TpmStateTest::GetLiveRSA)));
- EXPECT_CALL(mock_tpm_, GetCapabilitySync(TPM_CAP_ALGS,
- TPM_ALG_ECC, 1, _, _, _))
- .WillRepeatedly(WithArgs<4>(
- Invoke(this, &TpmStateTest::GetLiveECC)));
+ .WillRepeatedly(
+ WithArgs<4>(Invoke(this, &TpmStateTest::GetLiveStartupClear)));
+ EXPECT_CALL(mock_tpm_,
+ GetCapabilitySync(TPM_CAP_ALGS, TPM_ALG_RSA, 1, _, _, _))
+ .WillRepeatedly(WithArgs<4>(Invoke(this, &TpmStateTest::GetLiveRSA)));
+ EXPECT_CALL(mock_tpm_,
+ GetCapabilitySync(TPM_CAP_ALGS, TPM_ALG_ECC, 1, _, _, _))
+ .WillRepeatedly(WithArgs<4>(Invoke(this, &TpmStateTest::GetLiveECC)));
+ EXPECT_CALL(mock_tpm_,
+ GetCapabilitySync(TPM_CAP_TPM_PROPERTIES,
+ TPM_PT_LOCKOUT_COUNTER, 1, _, _, _))
+ .WillRepeatedly(
+ WithArgs<4>(Invoke(this, &TpmStateTest::GetLiveLockoutCounter)));
EXPECT_CALL(mock_tpm_, GetCapabilitySync(TPM_CAP_TPM_PROPERTIES,
- TPM_PT_LOCKOUT_COUNTER,
- 1, _, _, _))
- .WillRepeatedly(WithArgs<4>(
- Invoke(this, &TpmStateTest::GetLiveLockoutCounter)));
- EXPECT_CALL(mock_tpm_, GetCapabilitySync(TPM_CAP_TPM_PROPERTIES,
- TPM_PT_MAX_AUTH_FAIL,
- 1, _, _, _))
- .WillRepeatedly(WithArgs<4>(
- Invoke(this, &TpmStateTest::GetLiveLockoutThreshold)));
- EXPECT_CALL(mock_tpm_, GetCapabilitySync(TPM_CAP_TPM_PROPERTIES,
- TPM_PT_LOCKOUT_INTERVAL,
- 1, _, _, _))
- .WillRepeatedly(WithArgs<4>(
- Invoke(this, &TpmStateTest::GetLiveLockoutInterval)));
- EXPECT_CALL(mock_tpm_, GetCapabilitySync(TPM_CAP_TPM_PROPERTIES,
- TPM_PT_LOCKOUT_RECOVERY,
- 1, _, _, _))
- .WillRepeatedly(WithArgs<4>(
- Invoke(this, &TpmStateTest::GetLiveLockoutRecovery)));
+ TPM_PT_MAX_AUTH_FAIL, 1, _, _, _))
+ .WillRepeatedly(
+ WithArgs<4>(Invoke(this, &TpmStateTest::GetLiveLockoutThreshold)));
+ EXPECT_CALL(mock_tpm_,
+ GetCapabilitySync(TPM_CAP_TPM_PROPERTIES,
+ TPM_PT_LOCKOUT_INTERVAL, 1, _, _, _))
+ .WillRepeatedly(
+ WithArgs<4>(Invoke(this, &TpmStateTest::GetLiveLockoutInterval)));
+ EXPECT_CALL(mock_tpm_,
+ GetCapabilitySync(TPM_CAP_TPM_PROPERTIES,
+ TPM_PT_LOCKOUT_RECOVERY, 1, _, _, _))
+ .WillRepeatedly(
+ WithArgs<4>(Invoke(this, &TpmStateTest::GetLiveLockoutRecovery)));
}
TPM_RC GetLivePermanent(TPMS_CAPABILITY_DATA* capability_data) {
diff --git a/trunks/tpm_utility.h b/trunks/tpm_utility.h
index c2db557..bb61cfe 100644
--- a/trunks/tpm_utility.h
+++ b/trunks/tpm_utility.h
@@ -39,11 +39,7 @@
// An interface which provides convenient methods for common TPM operations.
class TRUNKS_EXPORT TpmUtility {
public:
- enum AsymmetricKeyUsage {
- kDecryptKey,
- kSignKey,
- kDecryptAndSignKey
- };
+ enum AsymmetricKeyUsage { kDecryptKey, kSignKey, kDecryptAndSignKey };
TpmUtility() {}
virtual ~TpmUtility() {}
diff --git a/trunks/tpm_utility_impl.cc b/trunks/tpm_utility_impl.cc
index b3e0756..39559d3 100644
--- a/trunks/tpm_utility_impl.cc
+++ b/trunks/tpm_utility_impl.cc
@@ -43,7 +43,7 @@
const char kWellKnownPassword[] = "cros-password";
const size_t kMaxPasswordLength = 32;
// The below maximum is defined in TPM 2.0 Library Spec Part 2 Section 13.1
-const uint32_t kMaxNVSpaceIndex = (1<<24) - 1;
+const uint32_t kMaxNVSpaceIndex = (1 << 24) - 1;
// Returns a serialized representation of the unmodified handle. This is useful
// for predefined handle values, like TPM_RH_OWNER. For details on what types of
@@ -76,8 +76,7 @@
crypto::EnsureOpenSSLInit();
}
-TpmUtilityImpl::~TpmUtilityImpl() {
-}
+TpmUtilityImpl::~TpmUtilityImpl() {}
TPM_RC TpmUtilityImpl::Startup() {
TPM_RC result = TPM_RC_SUCCESS;
@@ -108,9 +107,8 @@
if (result == TPM_RC_AUTH_MISSING) {
scoped_ptr<AuthorizationDelegate> authorization(
factory_.GetPasswordAuthorization(kPlatformPassword));
- result = factory_.GetTpm()->ClearSync(TPM_RH_PLATFORM,
- NameFromHandle(TPM_RH_PLATFORM),
- authorization.get());
+ result = factory_.GetTpm()->ClearSync(
+ TPM_RH_PLATFORM, NameFromHandle(TPM_RH_PLATFORM), authorization.get());
}
if (GetFormatOneError(result) == TPM_RC_BAD_AUTH) {
LOG(INFO) << "Clear failed because of BAD_AUTH. This probably means "
@@ -152,8 +150,7 @@
if (tpm_state->IsPlatformHierarchyEnabled()) {
scoped_ptr<AuthorizationDelegate> empty_password(
factory_.GetPasswordAuthorization(""));
- result = SetHierarchyAuthorization(TPM_RH_PLATFORM,
- kPlatformPassword,
+ result = SetHierarchyAuthorization(TPM_RH_PLATFORM, kPlatformPassword,
empty_password.get());
if (GetFormatOneError(result) == TPM_RC_BAD_AUTH) {
// Most likely the platform password has already been set.
@@ -226,14 +223,10 @@
uint32_t max_pcr;
uint32_t size_needed;
uint32_t size_available;
- result = factory_.GetTpm()->PCR_AllocateSync(TPM_RH_PLATFORM,
- NameFromHandle(TPM_RH_PLATFORM),
- pcr_allocation,
- &allocation_success,
- &max_pcr,
- &size_needed,
- &size_available,
- platform_delegate.get());
+ result = factory_.GetTpm()->PCR_AllocateSync(
+ TPM_RH_PLATFORM, NameFromHandle(TPM_RH_PLATFORM), pcr_allocation,
+ &allocation_success, &max_pcr, &size_needed, &size_available,
+ platform_delegate.get());
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error allocating PCRs: " << GetErrorString(result);
return result;
@@ -264,8 +257,7 @@
}
result = CreateSaltingKey(kWellKnownPassword);
if (result) {
- LOG(ERROR) << "Error creating salting key: "
- << GetErrorString(result);
+ LOG(ERROR) << "Error creating salting key: " << GetErrorString(result);
return result;
}
@@ -281,8 +273,7 @@
session->SetEntityAuthorizationValue("");
session->SetFutureAuthorizationValue(endorsement_password);
if (!tpm_state->IsEndorsementPasswordSet()) {
- result = SetHierarchyAuthorization(TPM_RH_ENDORSEMENT,
- endorsement_password,
+ result = SetHierarchyAuthorization(TPM_RH_ENDORSEMENT, endorsement_password,
session->GetDelegate());
if (result) {
LOG(ERROR) << __func__ << ": " << GetErrorString(result);
@@ -291,8 +282,7 @@
}
session->SetFutureAuthorizationValue(lockout_password);
if (!tpm_state->IsLockoutPasswordSet()) {
- result = SetHierarchyAuthorization(TPM_RH_LOCKOUT,
- lockout_password,
+ result = SetHierarchyAuthorization(TPM_RH_LOCKOUT, lockout_password,
session->GetDelegate());
if (result) {
LOG(ERROR) << __func__ << ": " << GetErrorString(result);
@@ -302,8 +292,7 @@
// We take ownership of owner hierarchy last.
session->SetEntityAuthorizationValue(kWellKnownPassword);
session->SetFutureAuthorizationValue(owner_password);
- result = SetHierarchyAuthorization(TPM_RH_OWNER,
- owner_password,
+ result = SetHierarchyAuthorization(TPM_RH_OWNER, owner_password,
session->GetDelegate());
if ((GetFormatOneError(result) == TPM_RC_BAD_AUTH) &&
tpm_state->IsOwnerPasswordSet()) {
@@ -334,9 +323,7 @@
TPM_RC rc;
TPM2B_DIGEST digest;
while (bytes_left > 0) {
- rc = factory_.GetTpm()->GetRandomSync(bytes_left,
- &digest,
- delegate);
+ rc = factory_.GetTpm()->GetRandomSync(bytes_left, &digest, delegate);
if (rc) {
LOG(ERROR) << "Error getting random data from tpm.";
return rc;
@@ -360,12 +347,9 @@
TPML_DIGEST_VALUES digests;
digests.count = 1;
digests.digests[0].hash_alg = TPM_ALG_SHA256;
- crypto::SHA256HashString(extend_data,
- digests.digests[0].digest.sha256,
+ crypto::SHA256HashString(extend_data, digests.digests[0].digest.sha256,
crypto::kSHA256Length);
- return factory_.GetTpm()->PCR_ExtendSync(pcr_handle,
- pcr_name,
- digests,
+ return factory_.GetTpm()->PCR_ExtendSync(pcr_handle, pcr_name, digests,
delegate);
}
@@ -384,20 +368,17 @@
pcr_select_in.pcr_selections[0].pcr_select[pcr_select_index] =
pcr_select_byte;
- TPM_RC rc = factory_.GetTpm()->PCR_ReadSync(pcr_select_in,
- &pcr_update_counter,
- &pcr_select_out,
- &pcr_values,
- nullptr);
+ TPM_RC rc =
+ factory_.GetTpm()->PCR_ReadSync(pcr_select_in, &pcr_update_counter,
+ &pcr_select_out, &pcr_values, nullptr);
if (rc) {
LOG(INFO) << "Error trying to read a pcr: " << GetErrorString(rc);
return rc;
}
if (pcr_select_out.count != 1 ||
- pcr_select_out.pcr_selections[0].sizeof_select <
- (pcr_select_index + 1) ||
+ pcr_select_out.pcr_selections[0].sizeof_select < (pcr_select_index + 1) ||
pcr_select_out.pcr_selections[0].pcr_select[pcr_select_index] !=
- pcr_select_byte) {
+ pcr_select_byte) {
LOG(ERROR) << "TPM did not return the requested PCR";
return TPM_RC_FAILURE;
}
@@ -453,16 +434,11 @@
label.size = 0;
TPM2B_PUBLIC_KEY_RSA in_message = Make_TPM2B_PUBLIC_KEY_RSA(plaintext);
TPM2B_PUBLIC_KEY_RSA out_message;
- result = factory_.GetTpm()->RSA_EncryptSync(key_handle,
- key_name,
- in_message,
- in_scheme,
- label,
- &out_message,
+ result = factory_.GetTpm()->RSA_EncryptSync(key_handle, key_name, in_message,
+ in_scheme, label, &out_message,
delegate);
if (result != TPM_RC_SUCCESS) {
- LOG(ERROR) << "Error performing RSA encrypt: "
- << GetErrorString(result);
+ LOG(ERROR) << "Error performing RSA encrypt: " << GetErrorString(result);
return result;
}
ciphertext->assign(StringFrom_TPM2B_PUBLIC_KEY_RSA(out_message));
@@ -522,16 +498,11 @@
label.size = 0;
TPM2B_PUBLIC_KEY_RSA in_message = Make_TPM2B_PUBLIC_KEY_RSA(ciphertext);
TPM2B_PUBLIC_KEY_RSA out_message;
- result = factory_.GetTpm()->RSA_DecryptSync(key_handle,
- key_name,
- in_message,
- in_scheme,
- label,
- &out_message,
+ result = factory_.GetTpm()->RSA_DecryptSync(key_handle, key_name, in_message,
+ in_scheme, label, &out_message,
delegate);
if (result) {
- LOG(ERROR) << "Error performing RSA decrypt: "
- << GetErrorString(result);
+ LOG(ERROR) << "Error performing RSA decrypt: " << GetErrorString(result);
return result;
}
plaintext->assign(StringFrom_TPM2B_PUBLIC_KEY_RSA(out_message));
@@ -594,25 +565,21 @@
validation.tag = TPM_ST_HASHCHECK;
validation.hierarchy = TPM_RH_NULL;
validation.digest.size = 0;
- result = factory_.GetTpm()->SignSync(key_handle,
- key_name,
- tpm_digest,
- in_scheme,
- validation,
- &signature_out,
- delegate);
+ result =
+ factory_.GetTpm()->SignSync(key_handle, key_name, tpm_digest, in_scheme,
+ validation, &signature_out, delegate);
if (result) {
LOG(ERROR) << "Error signing digest: " << GetErrorString(result);
return result;
}
if (scheme == TPM_ALG_RSAPSS) {
signature->resize(signature_out.signature.rsapss.sig.size);
- signature->assign(StringFrom_TPM2B_PUBLIC_KEY_RSA(
- signature_out.signature.rsapss.sig));
+ signature->assign(
+ StringFrom_TPM2B_PUBLIC_KEY_RSA(signature_out.signature.rsapss.sig));
} else {
signature->resize(signature_out.signature.rsassa.sig.size);
- signature->assign(StringFrom_TPM2B_PUBLIC_KEY_RSA(
- signature_out.signature.rsassa.sig));
+ signature->assign(
+ StringFrom_TPM2B_PUBLIC_KEY_RSA(signature_out.signature.rsassa.sig));
}
return TPM_RC_SUCCESS;
}
@@ -659,12 +626,8 @@
TPMT_TK_VERIFIED verified;
std::string digest = HashString(plaintext, hash_alg);
TPM2B_DIGEST tpm_digest = Make_TPM2B_DIGEST(digest);
- return_code = factory_.GetTpm()->VerifySignatureSync(key_handle,
- key_name,
- tpm_digest,
- signature_in,
- &verified,
- delegate);
+ return_code = factory_.GetTpm()->VerifySignatureSync(
+ key_handle, key_name, tpm_digest, signature_in, &verified, delegate);
if (return_code == TPM_RC_SIGNATURE) {
LOG(WARNING) << "Incorrect signature for given digest.";
return TPM_RC_SIGNATURE;
@@ -680,10 +643,8 @@
TPM2B_CREATION_DATA creation_data;
TPM2B_DIGEST creation_hash;
TPMT_TK_CREATION creation_ticket;
- if (!factory_.GetBlobParser()->ParseCreationBlob(creation_blob,
- &creation_data,
- &creation_hash,
- &creation_ticket)) {
+ if (!factory_.GetBlobParser()->ParseCreationBlob(
+ creation_blob, &creation_data, &creation_hash, &creation_ticket)) {
LOG(ERROR) << "Error parsing CreationBlob.";
return SAPI_RC_BAD_PARAMETER;
}
@@ -695,17 +656,9 @@
TPMT_SIGNATURE signature;
scoped_ptr<AuthorizationDelegate> delegate =
factory_.GetPasswordAuthorization("");
- TPM_RC result = factory_.GetTpm()->CertifyCreationSync(TPM_RH_NULL,
- "",
- key_handle,
- "",
- qualifying_data,
- creation_hash,
- in_scheme,
- creation_ticket,
- &certify_info,
- &signature,
- delegate.get());
+ TPM_RC result = factory_.GetTpm()->CertifyCreationSync(
+ TPM_RH_NULL, "", key_handle, "", qualifying_data, creation_hash,
+ in_scheme, creation_ticket, &certify_info, &signature, delegate.get());
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error certifying key creation: " << GetErrorString(result);
return result;
@@ -742,13 +695,9 @@
TPM2B_AUTH new_auth = Make_TPM2B_DIGEST(new_password);
TPM2B_PRIVATE new_private_data;
new_private_data.size = 0;
- result = factory_.GetTpm()->ObjectChangeAuthSync(key_handle,
- key_name,
- kRSAStorageRootKey,
- parent_name,
- new_auth,
- &new_private_data,
- delegate);
+ result = factory_.GetTpm()->ObjectChangeAuthSync(
+ key_handle, key_name, kRSAStorageRootKey, parent_name, new_auth,
+ &new_private_data, delegate);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error changing object authorization data: "
<< GetErrorString(result);
@@ -761,7 +710,7 @@
return result;
}
if (!factory_.GetBlobParser()->SerializeKeyBlob(
- Make_TPM2B_PUBLIC(public_data), new_private_data, key_blob)) {
+ Make_TPM2B_PUBLIC(public_data), new_private_data, key_blob)) {
return SAPI_RC_BAD_TCTI_STRUCTURE;
}
}
@@ -807,8 +756,8 @@
public_area.unique.rsa = Make_TPM2B_PUBLIC_KEY_RSA(modulus);
TPM2B_DATA encryption_key;
encryption_key.size = kAesKeySize;
- CHECK_EQ(RAND_bytes(encryption_key.buffer, encryption_key.size), 1) <<
- "Error generating a cryptographically random Aes Key.";
+ CHECK_EQ(RAND_bytes(encryption_key.buffer, encryption_key.size), 1)
+ << "Error generating a cryptographically random Aes Key.";
TPM2B_PUBLIC public_data = Make_TPM2B_PUBLIC(public_area);
TPM2B_ENCRYPTED_SECRET in_sym_seed = Make_TPM2B_ENCRYPTED_SECRET("");
TPMT_SYM_DEF_OBJECT symmetric_alg;
@@ -821,8 +770,8 @@
in_sensitive.seed_value = Make_TPM2B_DIGEST("");
in_sensitive.sensitive.rsa = Make_TPM2B_PRIVATE_KEY_RSA(prime_factor);
TPM2B_PRIVATE private_data;
- result = EncryptPrivateData(in_sensitive, public_area,
- &private_data, &encryption_key);
+ result = EncryptPrivateData(in_sensitive, public_area, &private_data,
+ &encryption_key);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error creating encrypted private struct: "
<< GetErrorString(result);
@@ -830,22 +779,16 @@
}
TPM2B_PRIVATE tpm_private_data;
tpm_private_data.size = 0;
- result = factory_.GetTpm()->ImportSync(kRSAStorageRootKey,
- parent_name,
- encryption_key,
- public_data,
- private_data,
- in_sym_seed,
- symmetric_alg,
- &tpm_private_data,
- delegate);
+ result = factory_.GetTpm()->ImportSync(
+ kRSAStorageRootKey, parent_name, encryption_key, public_data,
+ private_data, in_sym_seed, symmetric_alg, &tpm_private_data, delegate);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error importing key: " << GetErrorString(result);
return result;
}
if (key_blob) {
if (!factory_.GetBlobParser()->SerializeKeyBlob(
- public_data, tpm_private_data, key_blob)) {
+ public_data, tpm_private_data, key_blob)) {
return SAPI_RC_BAD_TCTI_STRUCTURE;
}
}
@@ -915,8 +858,8 @@
TPMS_SENSITIVE_CREATE sensitive;
sensitive.user_auth = Make_TPM2B_DIGEST(password);
sensitive.data = Make_TPM2B_SENSITIVE_DATA("");
- TPM2B_SENSITIVE_CREATE sensitive_create = Make_TPM2B_SENSITIVE_CREATE(
- sensitive);
+ TPM2B_SENSITIVE_CREATE sensitive_create =
+ Make_TPM2B_SENSITIVE_CREATE(sensitive);
TPM2B_DATA outside_info = Make_TPM2B_DATA("");
TPM2B_PUBLIC out_public;
out_public.size = 0;
@@ -925,29 +868,21 @@
TPM2B_CREATION_DATA creation_data;
TPM2B_DIGEST creation_hash;
TPMT_TK_CREATION creation_ticket;
- result = factory_.GetTpm()->CreateSync(kRSAStorageRootKey,
- parent_name,
- sensitive_create,
- Make_TPM2B_PUBLIC(public_area),
- outside_info,
- creation_pcrs,
- &out_private,
- &out_public,
- &creation_data,
- &creation_hash,
- &creation_ticket,
- delegate);
+ result = factory_.GetTpm()->CreateSync(
+ kRSAStorageRootKey, parent_name, sensitive_create,
+ Make_TPM2B_PUBLIC(public_area), outside_info, creation_pcrs, &out_private,
+ &out_public, &creation_data, &creation_hash, &creation_ticket, delegate);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error creating RSA key: " << GetErrorString(result);
return result;
}
- if (!factory_.GetBlobParser()->SerializeKeyBlob(
- out_public, out_private, key_blob)) {
+ if (!factory_.GetBlobParser()->SerializeKeyBlob(out_public, out_private,
+ key_blob)) {
return SAPI_RC_BAD_TCTI_STRUCTURE;
}
if (creation_blob) {
if (!factory_.GetBlobParser()->SerializeCreationBlob(
- creation_data, creation_hash, creation_ticket, creation_blob)) {
+ creation_data, creation_hash, creation_ticket, creation_blob)) {
return SAPI_RC_BAD_TCTI_STRUCTURE;
}
}
@@ -973,19 +908,15 @@
}
TPM2B_PUBLIC in_public;
TPM2B_PRIVATE in_private;
- if (!factory_.GetBlobParser()->ParseKeyBlob(
- key_blob, &in_public, &in_private)) {
+ if (!factory_.GetBlobParser()->ParseKeyBlob(key_blob, &in_public,
+ &in_private)) {
return SAPI_RC_BAD_TCTI_STRUCTURE;
}
TPM2B_NAME key_name;
key_name.size = 0;
- result = factory_.GetTpm()->LoadSync(kRSAStorageRootKey,
- parent_name,
- in_private,
- in_public,
- key_handle,
- &key_name,
- delegate);
+ result =
+ factory_.GetTpm()->LoadSync(kRSAStorageRootKey, parent_name, in_private,
+ in_public, key_handle, &key_name, delegate);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error loading key: " << GetErrorString(result);
return result;
@@ -1017,12 +948,8 @@
TPM2B_PUBLIC public_area;
TPM2B_NAME qualified_name;
std::string handle_name; // Unused
- TPM_RC return_code = factory_.GetTpm()->ReadPublicSync(handle,
- handle_name,
- &public_area,
- &out_name,
- &qualified_name,
- nullptr);
+ TPM_RC return_code = factory_.GetTpm()->ReadPublicSync(
+ handle, handle_name, &public_area, &out_name, &qualified_name, nullptr);
if (return_code) {
LOG(ERROR) << "Error getting public area for object: " << handle;
return return_code;
@@ -1060,8 +987,8 @@
TPMS_SENSITIVE_CREATE sensitive;
sensitive.user_auth = Make_TPM2B_DIGEST("");
sensitive.data = Make_TPM2B_SENSITIVE_DATA(data_to_seal);
- TPM2B_SENSITIVE_CREATE sensitive_create = Make_TPM2B_SENSITIVE_CREATE(
- sensitive);
+ TPM2B_SENSITIVE_CREATE sensitive_create =
+ Make_TPM2B_SENSITIVE_CREATE(sensitive);
TPM2B_DATA outside_info = Make_TPM2B_DATA("");
TPM2B_PUBLIC out_public;
out_public.size = 0;
@@ -1070,24 +997,16 @@
TPM2B_CREATION_DATA creation_data;
TPM2B_DIGEST creation_hash;
TPMT_TK_CREATION creation_ticket;
- result = factory_.GetTpm()->CreateSync(kRSAStorageRootKey,
- parent_name,
- sensitive_create,
- Make_TPM2B_PUBLIC(public_area),
- outside_info,
- creation_pcrs,
- &out_private,
- &out_public,
- &creation_data,
- &creation_hash,
- &creation_ticket,
- delegate);
+ result = factory_.GetTpm()->CreateSync(
+ kRSAStorageRootKey, parent_name, sensitive_create,
+ Make_TPM2B_PUBLIC(public_area), outside_info, creation_pcrs, &out_private,
+ &out_public, &creation_data, &creation_hash, &creation_ticket, delegate);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error creating sealed object: " << GetErrorString(result);
return result;
}
- if (!factory_.GetBlobParser()->SerializeKeyBlob(
- out_public, out_private, sealed_data)) {
+ if (!factory_.GetBlobParser()->SerializeKeyBlob(out_public, out_private,
+ sealed_data)) {
return SAPI_RC_BAD_TCTI_STRUCTURE;
}
return TPM_RC_SUCCESS;
@@ -1131,7 +1050,7 @@
}
TPM_RC TpmUtilityImpl::StartSession(HmacSession* session) {
- TPM_RC result = session->StartUnboundSession(true /* enable_encryption */);
+ TPM_RC result = session->StartUnboundSession(true /* enable_encryption */);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error starting unbound session: " << GetErrorString(result);
return result;
@@ -1208,19 +1127,14 @@
// reboot.
// TPMA_NV_AUTHREAD: The index authValue (default: "") can be used to
// authorize read actions.
- public_data.attributes = TPMA_NV_NO_DA |
- TPMA_NV_OWNERWRITE |
- TPMA_NV_WRITEDEFINE |
- TPMA_NV_AUTHREAD;
+ public_data.attributes = TPMA_NV_NO_DA | TPMA_NV_OWNERWRITE |
+ TPMA_NV_WRITEDEFINE | TPMA_NV_AUTHREAD;
public_data.auth_policy = Make_TPM2B_DIGEST("");
public_data.data_size = num_bytes;
TPM2B_AUTH authorization = Make_TPM2B_DIGEST("");
TPM2B_NV_PUBLIC public_area = Make_TPM2B_NV_PUBLIC(public_data);
result = factory_.GetTpm()->NV_DefineSpaceSync(
- TPM_RH_OWNER,
- NameFromHandle(TPM_RH_OWNER),
- authorization,
- public_area,
+ TPM_RH_OWNER, NameFromHandle(TPM_RH_OWNER), authorization, public_area,
delegate);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error defining non-volatile space: "
@@ -1253,11 +1167,7 @@
}
uint32_t nv_index = NV_INDEX_FIRST + index;
result = factory_.GetTpm()->NV_UndefineSpaceSync(
- TPM_RH_OWNER,
- NameFromHandle(TPM_RH_OWNER),
- nv_index,
- nv_name,
- delegate);
+ TPM_RH_OWNER, NameFromHandle(TPM_RH_OWNER), nv_index, nv_name, delegate);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error undefining non-volatile space: "
<< GetErrorString(result);
@@ -1288,11 +1198,8 @@
return result;
}
uint32_t nv_index = NV_INDEX_FIRST + index;
- result = factory_.GetTpm()->NV_WriteLockSync(TPM_RH_OWNER,
- NameFromHandle(TPM_RH_OWNER),
- nv_index,
- nv_name,
- delegate);
+ result = factory_.GetTpm()->NV_WriteLockSync(
+ TPM_RH_OWNER, NameFromHandle(TPM_RH_OWNER), nv_index, nv_name, delegate);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error locking non-volatile spaces: "
<< GetErrorString(result);
@@ -1334,13 +1241,9 @@
return result;
}
uint32_t nv_index = NV_INDEX_FIRST + index;
- result = factory_.GetTpm()->NV_WriteSync(TPM_RH_OWNER,
- NameFromHandle(TPM_RH_OWNER),
- nv_index,
- nv_name,
- Make_TPM2B_MAX_NV_BUFFER(nvram_data),
- offset,
- delegate);
+ result = factory_.GetTpm()->NV_WriteSync(
+ TPM_RH_OWNER, NameFromHandle(TPM_RH_OWNER), nv_index, nv_name,
+ Make_TPM2B_MAX_NV_BUFFER(nvram_data), offset, delegate);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error writing to non-volatile space: "
<< GetErrorString(result);
@@ -1385,14 +1288,9 @@
uint32_t nv_index = NV_INDEX_FIRST + index;
TPM2B_MAX_NV_BUFFER data_buffer;
data_buffer.size = 0;
- result = factory_.GetTpm()->NV_ReadSync(nv_index,
- nv_name,
- nv_index,
- nv_name,
- num_bytes,
- offset,
- &data_buffer,
- delegate);
+ result =
+ factory_.GetTpm()->NV_ReadSync(nv_index, nv_name, nv_index, nv_name,
+ num_bytes, offset, &data_buffer, delegate);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error reading from non-volatile space: "
<< GetErrorString(result);
@@ -1440,11 +1338,8 @@
TPM2B_NV_PUBLIC public_area;
public_area.nv_public.nv_index = 0;
uint32_t nv_index = NV_INDEX_FIRST + index;
- result = factory_.GetTpm()->NV_ReadPublicSync(nv_index,
- "",
- &public_area,
- &nvram_name,
- nullptr);
+ result = factory_.GetTpm()->NV_ReadPublicSync(nv_index, "", &public_area,
+ &nvram_name, nullptr);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error reading non-volatile space public information: "
<< GetErrorString(result);
@@ -1470,8 +1365,7 @@
<< "This is normal if ownership is already taken.";
return TPM_RC_SUCCESS;
}
- result = SetHierarchyAuthorization(TPM_RH_OWNER,
- known_owner_password,
+ result = SetHierarchyAuthorization(TPM_RH_OWNER, known_owner_password,
delegate.get());
if (result) {
LOG(ERROR) << "Error setting storage hierarchy authorization "
@@ -1484,7 +1378,7 @@
TPM_RC TpmUtilityImpl::CreateStorageRootKeys(
const std::string& owner_password) {
TPM_RC result = TPM_RC_SUCCESS;
- scoped_ptr<TpmState> tpm_state(factory_.GetTpmState());
+ scoped_ptr<TpmState> tpm_state(factory_.GetTpmState());
result = tpm_state->Initialize();
if (result) {
LOG(ERROR) << __func__ << ": " << GetErrorString(result);
@@ -1512,38 +1406,28 @@
}
if (!exists) {
TPMT_PUBLIC public_area = CreateDefaultPublicArea(TPM_ALG_RSA);
- public_area.object_attributes |=
- (kSensitiveDataOrigin | kUserWithAuth | kNoDA |
- kRestricted | kDecrypt);
+ public_area.object_attributes |= (kSensitiveDataOrigin | kUserWithAuth |
+ kNoDA | kRestricted | kDecrypt);
public_area.parameters.rsa_detail.symmetric.algorithm = TPM_ALG_AES;
public_area.parameters.rsa_detail.symmetric.key_bits.aes = 128;
public_area.parameters.rsa_detail.symmetric.mode.aes = TPM_ALG_CFB;
TPM2B_PUBLIC rsa_public_area = Make_TPM2B_PUBLIC(public_area);
- result = tpm->CreatePrimarySync(TPM_RH_OWNER,
- NameFromHandle(TPM_RH_OWNER),
- Make_TPM2B_SENSITIVE_CREATE(sensitive),
- rsa_public_area,
- Make_TPM2B_DATA(""),
- creation_pcrs,
- &object_handle,
- &rsa_public_area,
- &creation_data,
- &creation_digest,
- &creation_ticket,
- &object_name,
- delegate.get());
+ result = tpm->CreatePrimarySync(
+ TPM_RH_OWNER, NameFromHandle(TPM_RH_OWNER),
+ Make_TPM2B_SENSITIVE_CREATE(sensitive), rsa_public_area,
+ Make_TPM2B_DATA(""), creation_pcrs, &object_handle, &rsa_public_area,
+ &creation_data, &creation_digest, &creation_ticket, &object_name,
+ delegate.get());
if (result) {
LOG(ERROR) << __func__ << ": " << GetErrorString(result);
return result;
}
ScopedKeyHandle rsa_key(factory_, object_handle);
// This will make the key persistent.
- result = tpm->EvictControlSync(TPM_RH_OWNER,
- NameFromHandle(TPM_RH_OWNER),
+ result = tpm->EvictControlSync(TPM_RH_OWNER, NameFromHandle(TPM_RH_OWNER),
object_handle,
StringFrom_TPM2B_NAME(object_name),
- kRSAStorageRootKey,
- delegate.get());
+ kRSAStorageRootKey, delegate.get());
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << __func__ << ": " << GetErrorString(result);
return result;
@@ -1565,38 +1449,28 @@
}
if (!exists) {
TPMT_PUBLIC public_area = CreateDefaultPublicArea(TPM_ALG_ECC);
- public_area.object_attributes |=
- (kSensitiveDataOrigin | kUserWithAuth | kNoDA |
- kRestricted | kDecrypt);
+ public_area.object_attributes |= (kSensitiveDataOrigin | kUserWithAuth |
+ kNoDA | kRestricted | kDecrypt);
public_area.parameters.ecc_detail.symmetric.algorithm = TPM_ALG_AES;
public_area.parameters.ecc_detail.symmetric.key_bits.aes = 128;
public_area.parameters.ecc_detail.symmetric.mode.aes = TPM_ALG_CFB;
TPM2B_PUBLIC ecc_public_area = Make_TPM2B_PUBLIC(public_area);
- result = tpm->CreatePrimarySync(TPM_RH_OWNER,
- NameFromHandle(TPM_RH_OWNER),
- Make_TPM2B_SENSITIVE_CREATE(sensitive),
- ecc_public_area,
- Make_TPM2B_DATA(""),
- creation_pcrs,
- &object_handle,
- &ecc_public_area,
- &creation_data,
- &creation_digest,
- &creation_ticket,
- &object_name,
- delegate.get());
+ result = tpm->CreatePrimarySync(
+ TPM_RH_OWNER, NameFromHandle(TPM_RH_OWNER),
+ Make_TPM2B_SENSITIVE_CREATE(sensitive), ecc_public_area,
+ Make_TPM2B_DATA(""), creation_pcrs, &object_handle, &ecc_public_area,
+ &creation_data, &creation_digest, &creation_ticket, &object_name,
+ delegate.get());
if (result) {
LOG(ERROR) << __func__ << ": " << GetErrorString(result);
return result;
}
ScopedKeyHandle ecc_key(factory_, object_handle);
// This will make the key persistent.
- result = tpm->EvictControlSync(TPM_RH_OWNER,
- NameFromHandle(TPM_RH_OWNER),
+ result = tpm->EvictControlSync(TPM_RH_OWNER, NameFromHandle(TPM_RH_OWNER),
object_handle,
StringFrom_TPM2B_NAME(object_name),
- kECCStorageRootKey,
- delegate.get());
+ kECCStorageRootKey, delegate.get());
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << __func__ << ": " << GetErrorString(result);
return result;
@@ -1637,8 +1511,8 @@
TPMS_SENSITIVE_CREATE sensitive;
sensitive.user_auth = Make_TPM2B_DIGEST("");
sensitive.data = Make_TPM2B_SENSITIVE_DATA("");
- TPM2B_SENSITIVE_CREATE sensitive_create = Make_TPM2B_SENSITIVE_CREATE(
- sensitive);
+ TPM2B_SENSITIVE_CREATE sensitive_create =
+ Make_TPM2B_SENSITIVE_CREATE(sensitive);
TPM2B_DATA outside_info = Make_TPM2B_DATA("");
TPM2B_PRIVATE out_private;
@@ -1653,18 +1527,11 @@
// crbug.com/442331
scoped_ptr<AuthorizationDelegate> delegate =
factory_.GetPasswordAuthorization("");
- result = factory_.GetTpm()->CreateSync(kRSAStorageRootKey,
- parent_name,
- sensitive_create,
- Make_TPM2B_PUBLIC(public_area),
- outside_info,
- creation_pcrs,
- &out_private,
- &out_public,
- &creation_data,
- &creation_hash,
- &creation_ticket,
- delegate.get());
+ result = factory_.GetTpm()->CreateSync(
+ kRSAStorageRootKey, parent_name, sensitive_create,
+ Make_TPM2B_PUBLIC(public_area), outside_info, creation_pcrs, &out_private,
+ &out_public, &creation_data, &creation_hash, &creation_ticket,
+ delegate.get());
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error creating salting key: " << GetErrorString(result);
return result;
@@ -1672,13 +1539,9 @@
TPM2B_NAME key_name;
key_name.size = 0;
TPM_HANDLE key_handle;
- result = factory_.GetTpm()->LoadSync(kRSAStorageRootKey,
- parent_name,
- out_private,
- out_public,
- &key_handle,
- &key_name,
- delegate.get());
+ result = factory_.GetTpm()->LoadSync(kRSAStorageRootKey, parent_name,
+ out_private, out_public, &key_handle,
+ &key_name, delegate.get());
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error loading salting key: " << GetErrorString(result);
return result;
@@ -1686,12 +1549,9 @@
ScopedKeyHandle key(factory_, key_handle);
scoped_ptr<AuthorizationDelegate> owner_delegate =
factory_.GetPasswordAuthorization(owner_password);
- result = factory_.GetTpm()->EvictControlSync(TPM_RH_OWNER,
- NameFromHandle(TPM_RH_OWNER),
- key_handle,
- StringFrom_TPM2B_NAME(key_name),
- kSaltingKey,
- owner_delegate.get());
+ result = factory_.GetTpm()->EvictControlSync(
+ TPM_RH_OWNER, NameFromHandle(TPM_RH_OWNER), key_handle,
+ StringFrom_TPM2B_NAME(key_name), kSaltingKey, owner_delegate.get());
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << __func__ << ": " << GetErrorString(result);
return result;
@@ -1736,9 +1596,7 @@
return SAPI_RC_BAD_SIZE;
}
return factory_.GetTpm()->HierarchyChangeAuthSync(
- hierarchy,
- NameFromHandle(hierarchy),
- Make_TPM2B_DIGEST(password),
+ hierarchy, NameFromHandle(hierarchy), Make_TPM2B_DIGEST(password),
authorization);
}
@@ -1748,7 +1606,7 @@
TPM_RH_PLATFORM, // The authorizing entity.
NameFromHandle(TPM_RH_PLATFORM),
TPM_RH_PLATFORM, // The target hierarchy.
- 0, // Disable.
+ 0, // Disable.
authorization);
}
@@ -1786,8 +1644,8 @@
return TPM_RC_SUCCESS;
}
std::string serialized_public_area;
- TPM_RC result = Serialize_TPMS_NV_PUBLIC(nv_public_area,
- &serialized_public_area);
+ TPM_RC result =
+ Serialize_TPMS_NV_PUBLIC(nv_public_area, &serialized_public_area);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error serializing public area: " << GetErrorString(result);
return result;
@@ -1809,8 +1667,8 @@
TPM2B_DATA* encryption_key) {
TPM2B_SENSITIVE sensitive_data = Make_TPM2B_SENSITIVE(sensitive_area);
std::string serialized_sensitive_data;
- TPM_RC result = Serialize_TPM2B_SENSITIVE(sensitive_data,
- &serialized_sensitive_data);
+ TPM_RC result =
+ Serialize_TPM2B_SENSITIVE(sensitive_data, &serialized_sensitive_data);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error serializing sensitive data: "
<< GetErrorString(result);
@@ -1822,8 +1680,8 @@
LOG(ERROR) << "Error computing object name: " << GetErrorString(result);
return result;
}
- TPM2B_DIGEST inner_integrity = Make_TPM2B_DIGEST(crypto::SHA256HashString(
- serialized_sensitive_data + object_name));
+ TPM2B_DIGEST inner_integrity = Make_TPM2B_DIGEST(
+ crypto::SHA256HashString(serialized_sensitive_data + object_name));
std::string serialized_inner_integrity;
result = Serialize_TPM2B_DIGEST(inner_integrity, &serialized_inner_integrity);
if (result != TPM_RC_SUCCESS) {
@@ -1831,21 +1689,20 @@
<< GetErrorString(result);
return result;
}
- std::string unencrypted_private_data = serialized_inner_integrity +
- serialized_sensitive_data;
+ std::string unencrypted_private_data =
+ serialized_inner_integrity + serialized_sensitive_data;
AES_KEY key;
AES_set_encrypt_key(encryption_key->buffer, kAesKeySize * 8, &key);
std::string private_data_string(unencrypted_private_data.size(), 0);
int iv_in = 0;
unsigned char iv[MAX_AES_BLOCK_SIZE_BYTES] = {0};
AES_cfb128_encrypt(
- reinterpret_cast<const unsigned char*>(unencrypted_private_data.data()),
- reinterpret_cast<unsigned char*>(string_as_array(&private_data_string)),
- unencrypted_private_data.size(), &key, iv, &iv_in, AES_ENCRYPT);
+ reinterpret_cast<const unsigned char*>(unencrypted_private_data.data()),
+ reinterpret_cast<unsigned char*>(string_as_array(&private_data_string)),
+ unencrypted_private_data.size(), &key, iv, &iv_in, AES_ENCRYPT);
*encrypted_private_data = Make_TPM2B_PRIVATE(private_data_string);
if (result != TPM_RC_SUCCESS) {
- LOG(ERROR) << "Error making private area: "
- << GetErrorString(result);
+ LOG(ERROR) << "Error making private area: " << GetErrorString(result);
return result;
}
return TPM_RC_SUCCESS;
diff --git a/trunks/tpm_utility_impl.h b/trunks/tpm_utility_impl.h
index 86b34ab..0d6ff80 100644
--- a/trunks/tpm_utility_impl.h
+++ b/trunks/tpm_utility_impl.h
@@ -108,8 +108,7 @@
AuthorizationDelegate* delegate,
TPM_HANDLE* key_handle) override;
TPM_RC GetKeyName(TPM_HANDLE handle, std::string* name) override;
- TPM_RC GetKeyPublicArea(TPM_HANDLE handle,
- TPMT_PUBLIC* public_data) override;
+ TPM_RC GetKeyPublicArea(TPM_HANDLE handle, TPMT_PUBLIC* public_data) override;
TPM_RC SealData(const std::string& data_to_seal,
const std::string& policy_digest,
AuthorizationDelegate* delegate,
diff --git a/trunks/tpm_utility_test.cc b/trunks/tpm_utility_test.cc
index a245cdd..335e923 100644
--- a/trunks/tpm_utility_test.cc
+++ b/trunks/tpm_utility_test.cc
@@ -59,13 +59,11 @@
return utility_.ComputeKeyName(public_area, object_name);
}
- void SetNVRAMMap(uint32_t index,
- const TPMS_NV_PUBLIC& public_area) {
+ void SetNVRAMMap(uint32_t index, const TPMS_NV_PUBLIC& public_area) {
utility_.nvram_public_area_map_[index] = public_area;
}
- TPM_RC GetNVRAMMap(uint32_t index,
- TPMS_NV_PUBLIC* public_area) {
+ TPM_RC GetNVRAMMap(uint32_t index, TPMS_NV_PUBLIC* public_area) {
auto it = utility_.nvram_public_area_map_.find(index);
if (it == utility_.nvram_public_area_map_.end()) {
return TPM_RC_FAILURE;
@@ -130,8 +128,7 @@
TPMS_CAPABILITY_DATA capability_data = {};
TPML_PCR_SELECTION& pcrs = capability_data.data.assigned_pcr;
PopulatePCRSelection(has_sha1_pcrs, false, has_sha256_pcrs, &pcrs);
- EXPECT_CALL(mock_tpm_,
- GetCapabilitySync(TPM_CAP_PCRS, _, _, _, _, _))
+ EXPECT_CALL(mock_tpm_, GetCapabilitySync(TPM_CAP_PCRS, _, _, _, _, _))
.WillRepeatedly(
DoAll(SetArgPointee<4>(capability_data), Return(TPM_RC_SUCCESS)));
}
@@ -181,8 +178,7 @@
}
TEST_F(TpmUtilityTest, ClearFail) {
- EXPECT_CALL(mock_tpm_, ClearSync(_, _, _))
- .WillOnce(Return(TPM_RC_FAILURE));
+ EXPECT_CALL(mock_tpm_, ClearSync(_, _, _)).WillOnce(Return(TPM_RC_FAILURE));
EXPECT_EQ(TPM_RC_FAILURE, utility_.Clear());
}
@@ -222,8 +218,7 @@
SetExistingPCRSExpectation(false, false);
TPML_PCR_SELECTION new_pcr_allocation;
EXPECT_CALL(mock_tpm_, PCR_AllocateSync(TPM_RH_PLATFORM, _, _, _, _, _, _, _))
- .WillOnce(DoAll(SaveArg<2>(&new_pcr_allocation),
- SetArgPointee<3>(YES),
+ .WillOnce(DoAll(SaveArg<2>(&new_pcr_allocation), SetArgPointee<3>(YES),
Return(TPM_RC_SUCCESS)));
ASSERT_EQ(TPM_RC_SUCCESS, utility_.AllocatePCR(""));
ASSERT_EQ(1u, new_pcr_allocation.count);
@@ -237,8 +232,7 @@
SetExistingPCRSExpectation(true, false);
TPML_PCR_SELECTION new_pcr_allocation;
EXPECT_CALL(mock_tpm_, PCR_AllocateSync(TPM_RH_PLATFORM, _, _, _, _, _, _, _))
- .WillOnce(DoAll(SaveArg<2>(&new_pcr_allocation),
- SetArgPointee<3>(YES),
+ .WillOnce(DoAll(SaveArg<2>(&new_pcr_allocation), SetArgPointee<3>(YES),
Return(TPM_RC_SUCCESS)));
ASSERT_EQ(TPM_RC_SUCCESS, utility_.AllocatePCR(""));
ASSERT_EQ(2u, new_pcr_allocation.count);
@@ -252,8 +246,7 @@
SetExistingPCRSExpectation(true, true);
TPML_PCR_SELECTION new_pcr_allocation;
EXPECT_CALL(mock_tpm_, PCR_AllocateSync(TPM_RH_PLATFORM, _, _, _, _, _, _, _))
- .WillOnce(DoAll(SaveArg<2>(&new_pcr_allocation),
- SetArgPointee<3>(YES),
+ .WillOnce(DoAll(SaveArg<2>(&new_pcr_allocation), SetArgPointee<3>(YES),
Return(TPM_RC_SUCCESS)));
ASSERT_EQ(TPM_RC_SUCCESS, utility_.AllocatePCR(""));
ASSERT_EQ(1u, new_pcr_allocation.count);
@@ -280,8 +273,7 @@
TEST_F(TpmUtilityTest, AllocatePCRTpmFailure) {
SetExistingPCRSExpectation(false, false);
EXPECT_CALL(mock_tpm_, PCR_AllocateSync(_, _, _, _, _, _, _, _))
- .WillOnce(DoAll(SetArgPointee<3>(NO),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SetArgPointee<3>(NO), Return(TPM_RC_SUCCESS)));
EXPECT_EQ(TPM_RC_FAILURE, utility_.AllocatePCR(""));
}
@@ -292,31 +284,27 @@
.WillRepeatedly(Return(false));
EXPECT_CALL(mock_tpm_state_, IsLockoutPasswordSet())
.WillRepeatedly(Return(false));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.TakeOwnership("owner",
- "endorsement",
- "lockout"));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.TakeOwnership("owner", "endorsement", "lockout"));
}
TEST_F(TpmUtilityTest, TakeOwnershipOwnershipDone) {
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.TakeOwnership("owner",
- "endorsement",
- "lockout"));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.TakeOwnership("owner", "endorsement", "lockout"));
}
TEST_F(TpmUtilityTest, TakeOwnershipBadSession) {
EXPECT_CALL(mock_hmac_session_, StartUnboundSession(true))
.WillRepeatedly(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE, utility_.TakeOwnership("owner",
- "endorsement",
- "lockout"));
+ EXPECT_EQ(TPM_RC_FAILURE,
+ utility_.TakeOwnership("owner", "endorsement", "lockout"));
}
TEST_F(TpmUtilityTest, TakeOwnershipFailure) {
EXPECT_CALL(mock_tpm_, HierarchyChangeAuthSync(TPM_RH_OWNER, _, _, _))
.WillRepeatedly(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE, utility_.TakeOwnership("owner",
- "endorsement",
- "lockout"));
+ EXPECT_EQ(TPM_RC_FAILURE,
+ utility_.TakeOwnership("owner", "endorsement", "lockout"));
}
TEST_F(TpmUtilityTest, ChangeOwnerPasswordEndorsementDone) {
@@ -324,9 +312,8 @@
.WillRepeatedly(Return(false));
EXPECT_CALL(mock_tpm_state_, IsLockoutPasswordSet())
.WillRepeatedly(Return(false));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.TakeOwnership("owner",
- "endorsement",
- "lockout"));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.TakeOwnership("owner", "endorsement", "lockout"));
}
TEST_F(TpmUtilityTest, ChangeOwnerPasswordLockoutDone) {
@@ -334,17 +321,15 @@
.WillRepeatedly(Return(false));
EXPECT_CALL(mock_tpm_state_, IsEndorsementPasswordSet())
.WillRepeatedly(Return(false));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.TakeOwnership("owner",
- "endorsement",
- "lockout"));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.TakeOwnership("owner", "endorsement", "lockout"));
}
TEST_F(TpmUtilityTest, ChangeOwnerPasswordEndorsementLockoutDone) {
EXPECT_CALL(mock_tpm_state_, IsOwnerPasswordSet())
.WillRepeatedly(Return(false));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.TakeOwnership("owner",
- "endorsement",
- "lockout"));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.TakeOwnership("owner", "endorsement", "lockout"));
}
TEST_F(TpmUtilityTest, ChangeOwnerPasswordEndorsementFail) {
@@ -356,9 +341,8 @@
.WillRepeatedly(Return(TPM_RC_SUCCESS));
EXPECT_CALL(mock_tpm_, HierarchyChangeAuthSync(TPM_RH_ENDORSEMENT, _, _, _))
.WillRepeatedly(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE, utility_.TakeOwnership("owner",
- "endorsement",
- "lockout"));
+ EXPECT_EQ(TPM_RC_FAILURE,
+ utility_.TakeOwnership("owner", "endorsement", "lockout"));
}
TEST_F(TpmUtilityTest, ChangeOwnerPasswordLockoutFailure) {
@@ -372,9 +356,8 @@
.WillRepeatedly(Return(TPM_RC_SUCCESS));
EXPECT_CALL(mock_tpm_, HierarchyChangeAuthSync(TPM_RH_LOCKOUT, _, _, _))
.WillRepeatedly(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE, utility_.TakeOwnership("owner",
- "endorsement",
- "lockout"));
+ EXPECT_EQ(TPM_RC_FAILURE,
+ utility_.TakeOwnership("owner", "endorsement", "lockout"));
}
TEST_F(TpmUtilityTest, StirRandomSuccess) {
@@ -402,13 +385,13 @@
small_random.size = 8;
EXPECT_CALL(mock_tpm_, GetRandomSync(_, _, &mock_authorization_delegate_))
.Times(2)
- .WillRepeatedly(DoAll(SetArgPointee<1>(large_random),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<1>(large_random), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, GetRandomSync(8, _, &mock_authorization_delegate_))
- .WillOnce(DoAll(SetArgPointee<1>(small_random),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.GenerateRandom(
- num_bytes, &mock_authorization_delegate_, &random_data));
+ .WillOnce(DoAll(SetArgPointee<1>(small_random), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.GenerateRandom(num_bytes, &mock_authorization_delegate_,
+ &random_data));
EXPECT_EQ(num_bytes, random_data.size());
}
@@ -426,15 +409,13 @@
TPML_DIGEST_VALUES digests;
EXPECT_CALL(mock_tpm_,
PCR_ExtendSync(pcr_handle, _, _, &mock_authorization_delegate_))
- .WillOnce(DoAll(SaveArg<2>(&digests),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SaveArg<2>(&digests), Return(TPM_RC_SUCCESS)));
EXPECT_EQ(TPM_RC_SUCCESS, utility_.ExtendPCR(1, "test digest",
&mock_authorization_delegate_));
EXPECT_EQ(1u, digests.count);
EXPECT_EQ(TPM_ALG_SHA256, digests.digests[0].hash_alg);
std::string hash_string = crypto::SHA256HashString("test digest");
- EXPECT_EQ(0, memcmp(hash_string.data(),
- digests.digests[0].digest.sha256,
+ EXPECT_EQ(0, memcmp(hash_string.data(), digests.digests[0].digest.sha256,
crypto::kSHA256Length));
}
@@ -466,8 +447,7 @@
pcr_values.digests[0].size = 5;
EXPECT_CALL(mock_tpm_, PCR_ReadSync(_, _, _, _, _))
.WillOnce(DoAll(SetArgPointee<2>(pcr_select),
- SetArgPointee<3>(pcr_values),
- Return(TPM_RC_SUCCESS)));
+ SetArgPointee<3>(pcr_values), Return(TPM_RC_SUCCESS)));
EXPECT_EQ(TPM_RC_SUCCESS, utility_.ReadPCR(pcr_index, &pcr_value));
}
@@ -488,27 +468,23 @@
std::string plaintext;
std::string output_ciphertext("ciphertext");
std::string ciphertext;
- TPM2B_PUBLIC_KEY_RSA out_message = Make_TPM2B_PUBLIC_KEY_RSA(
- output_ciphertext);
+ TPM2B_PUBLIC_KEY_RSA out_message =
+ Make_TPM2B_PUBLIC_KEY_RSA(output_ciphertext);
TPM2B_PUBLIC public_area;
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kDecrypt;
public_area.public_area.auth_policy.size = 0;
public_area.public_area.unique.rsa.size = 0;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, RSA_EncryptSync(key_handle, _, _, _, _, _,
&mock_authorization_delegate_))
- .WillOnce(DoAll(SetArgPointee<5>(out_message),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.AsymmetricEncrypt(
- key_handle,
- TPM_ALG_NULL,
- TPM_ALG_NULL,
- plaintext,
- &mock_authorization_delegate_,
- &ciphertext));
+ .WillOnce(DoAll(SetArgPointee<5>(out_message), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.AsymmetricEncrypt(key_handle, TPM_ALG_NULL, TPM_ALG_NULL,
+ plaintext, &mock_authorization_delegate_,
+ &ciphertext));
EXPECT_EQ(0, ciphertext.compare(output_ciphertext));
}
@@ -522,16 +498,13 @@
public_area.public_area.auth_policy.size = 0;
public_area.public_area.unique.rsa.size = 0;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, RSA_EncryptSync(key_handle, _, _, _, _, _, nullptr))
.WillOnce(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE, utility_.AsymmetricEncrypt(key_handle,
- TPM_ALG_NULL,
- TPM_ALG_NULL,
- plaintext,
- nullptr,
- &ciphertext));
+ EXPECT_EQ(TPM_RC_FAILURE,
+ utility_.AsymmetricEncrypt(key_handle, TPM_ALG_NULL, TPM_ALG_NULL,
+ plaintext, nullptr, &ciphertext));
}
TEST_F(TpmUtilityTest, AsymmetricEncryptBadParams) {
@@ -542,14 +515,11 @@
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kDecrypt | kRestricted;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, nullptr))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(SAPI_RC_BAD_PARAMETER, utility_.AsymmetricEncrypt(key_handle,
- TPM_ALG_RSAES,
- TPM_ALG_NULL,
- plaintext,
- nullptr,
- &ciphertext));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(SAPI_RC_BAD_PARAMETER,
+ utility_.AsymmetricEncrypt(key_handle, TPM_ALG_RSAES, TPM_ALG_NULL,
+ plaintext, nullptr, &ciphertext));
}
TEST_F(TpmUtilityTest, AsymmetricEncryptNullSchemeForward) {
@@ -557,8 +527,8 @@
std::string plaintext;
std::string output_ciphertext("ciphertext");
std::string ciphertext;
- TPM2B_PUBLIC_KEY_RSA out_message = Make_TPM2B_PUBLIC_KEY_RSA(
- output_ciphertext);
+ TPM2B_PUBLIC_KEY_RSA out_message =
+ Make_TPM2B_PUBLIC_KEY_RSA(output_ciphertext);
TPM2B_PUBLIC public_area;
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kDecrypt;
@@ -566,18 +536,14 @@
public_area.public_area.unique.rsa.size = 0;
TPMT_RSA_DECRYPT scheme;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, RSA_EncryptSync(key_handle, _, _, _, _, _, nullptr))
- .WillOnce(DoAll(SetArgPointee<5>(out_message),
- SaveArg<3>(&scheme),
+ .WillOnce(DoAll(SetArgPointee<5>(out_message), SaveArg<3>(&scheme),
Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.AsymmetricEncrypt(key_handle,
- TPM_ALG_NULL,
- TPM_ALG_NULL,
- plaintext,
- nullptr,
- &ciphertext));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.AsymmetricEncrypt(key_handle, TPM_ALG_NULL, TPM_ALG_NULL,
+ plaintext, nullptr, &ciphertext));
EXPECT_EQ(scheme.scheme, TPM_ALG_OAEP);
EXPECT_EQ(scheme.details.oaep.hash_alg, TPM_ALG_SHA256);
}
@@ -587,8 +553,8 @@
std::string plaintext;
std::string output_ciphertext("ciphertext");
std::string ciphertext;
- TPM2B_PUBLIC_KEY_RSA out_message = Make_TPM2B_PUBLIC_KEY_RSA(
- output_ciphertext);
+ TPM2B_PUBLIC_KEY_RSA out_message =
+ Make_TPM2B_PUBLIC_KEY_RSA(output_ciphertext);
TPM2B_PUBLIC public_area;
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kDecrypt;
@@ -596,18 +562,14 @@
public_area.public_area.unique.rsa.size = 0;
TPMT_RSA_DECRYPT scheme;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, RSA_EncryptSync(key_handle, _, _, _, _, _, nullptr))
- .WillOnce(DoAll(SetArgPointee<5>(out_message),
- SaveArg<3>(&scheme),
+ .WillOnce(DoAll(SetArgPointee<5>(out_message), SaveArg<3>(&scheme),
Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.AsymmetricEncrypt(key_handle,
- TPM_ALG_RSAES,
- TPM_ALG_NULL,
- plaintext,
- nullptr,
- &ciphertext));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.AsymmetricEncrypt(key_handle, TPM_ALG_RSAES, TPM_ALG_NULL,
+ plaintext, nullptr, &ciphertext));
EXPECT_EQ(scheme.scheme, TPM_ALG_RSAES);
}
@@ -617,27 +579,23 @@
std::string output_plaintext("plaintext");
std::string ciphertext;
std::string password("password");
- TPM2B_PUBLIC_KEY_RSA out_message = Make_TPM2B_PUBLIC_KEY_RSA(
- output_plaintext);
+ TPM2B_PUBLIC_KEY_RSA out_message =
+ Make_TPM2B_PUBLIC_KEY_RSA(output_plaintext);
TPM2B_PUBLIC public_area;
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kDecrypt;
public_area.public_area.auth_policy.size = 0;
public_area.public_area.unique.rsa.size = 0;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, RSA_DecryptSync(key_handle, _, _, _, _, _,
&mock_authorization_delegate_))
- .WillOnce(DoAll(SetArgPointee<5>(out_message),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.AsymmetricDecrypt(
- key_handle,
- TPM_ALG_NULL,
- TPM_ALG_NULL,
- ciphertext,
- &mock_authorization_delegate_,
- &plaintext));
+ .WillOnce(DoAll(SetArgPointee<5>(out_message), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.AsymmetricDecrypt(
+ key_handle, TPM_ALG_NULL, TPM_ALG_NULL, ciphertext,
+ &mock_authorization_delegate_, &plaintext));
EXPECT_EQ(0, plaintext.compare(output_plaintext));
}
@@ -653,17 +611,14 @@
public_area.public_area.auth_policy.size = 0;
public_area.public_area.unique.rsa.size = 0;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, RSA_DecryptSync(key_handle, _, _, _, _, _, _))
.WillOnce(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE, utility_.AsymmetricDecrypt(
- key_handle,
- TPM_ALG_NULL,
- TPM_ALG_NULL,
- ciphertext,
- &mock_authorization_delegate_,
- &plaintext));
+ EXPECT_EQ(TPM_RC_FAILURE,
+ utility_.AsymmetricDecrypt(
+ key_handle, TPM_ALG_NULL, TPM_ALG_NULL, ciphertext,
+ &mock_authorization_delegate_, &plaintext));
}
TEST_F(TpmUtilityTest, AsymmetricDecryptBadParams) {
@@ -674,15 +629,12 @@
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kDecrypt | kRestricted;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(SAPI_RC_BAD_PARAMETER, utility_.AsymmetricDecrypt(
- key_handle,
- TPM_ALG_RSAES,
- TPM_ALG_NULL,
- ciphertext,
- &mock_authorization_delegate_,
- &plaintext));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(SAPI_RC_BAD_PARAMETER,
+ utility_.AsymmetricDecrypt(
+ key_handle, TPM_ALG_RSAES, TPM_ALG_NULL, ciphertext,
+ &mock_authorization_delegate_, &plaintext));
}
TEST_F(TpmUtilityTest, AsymmetricDecryptBadSession) {
@@ -691,9 +643,9 @@
std::string plaintext;
std::string ciphertext;
std::string password;
- EXPECT_EQ(SAPI_RC_INVALID_SESSIONS, utility_.AsymmetricDecrypt(
- key_handle, TPM_ALG_RSAES, TPM_ALG_NULL,
- ciphertext, nullptr, &plaintext));
+ EXPECT_EQ(SAPI_RC_INVALID_SESSIONS,
+ utility_.AsymmetricDecrypt(key_handle, TPM_ALG_RSAES, TPM_ALG_NULL,
+ ciphertext, nullptr, &plaintext));
}
TEST_F(TpmUtilityTest, AsymmetricDecryptNullSchemeForward) {
@@ -702,8 +654,8 @@
std::string output_plaintext("plaintext");
std::string ciphertext;
std::string password;
- TPM2B_PUBLIC_KEY_RSA out_message = Make_TPM2B_PUBLIC_KEY_RSA(
- output_plaintext);
+ TPM2B_PUBLIC_KEY_RSA out_message =
+ Make_TPM2B_PUBLIC_KEY_RSA(output_plaintext);
TPM2B_PUBLIC public_area;
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kDecrypt;
@@ -711,19 +663,15 @@
public_area.public_area.unique.rsa.size = 0;
TPMT_RSA_DECRYPT scheme;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, RSA_DecryptSync(key_handle, _, _, _, _, _, _))
- .WillOnce(DoAll(SetArgPointee<5>(out_message),
- SaveArg<3>(&scheme),
+ .WillOnce(DoAll(SetArgPointee<5>(out_message), SaveArg<3>(&scheme),
Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.AsymmetricDecrypt(
- key_handle,
- TPM_ALG_NULL,
- TPM_ALG_NULL,
- ciphertext,
- &mock_authorization_delegate_,
- &plaintext));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.AsymmetricDecrypt(
+ key_handle, TPM_ALG_NULL, TPM_ALG_NULL, ciphertext,
+ &mock_authorization_delegate_, &plaintext));
EXPECT_EQ(scheme.scheme, TPM_ALG_OAEP);
EXPECT_EQ(scheme.details.oaep.hash_alg, TPM_ALG_SHA256);
}
@@ -734,8 +682,8 @@
std::string output_plaintext("plaintext");
std::string ciphertext;
std::string password;
- TPM2B_PUBLIC_KEY_RSA out_message = Make_TPM2B_PUBLIC_KEY_RSA(
- output_plaintext);
+ TPM2B_PUBLIC_KEY_RSA out_message =
+ Make_TPM2B_PUBLIC_KEY_RSA(output_plaintext);
TPM2B_PUBLIC public_area;
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kDecrypt;
@@ -743,19 +691,15 @@
public_area.public_area.unique.rsa.size = 0;
TPMT_RSA_DECRYPT scheme;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, RSA_DecryptSync(key_handle, _, _, _, _, _, _))
- .WillOnce(DoAll(SetArgPointee<5>(out_message),
- SaveArg<3>(&scheme),
+ .WillOnce(DoAll(SetArgPointee<5>(out_message), SaveArg<3>(&scheme),
Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.AsymmetricDecrypt(
- key_handle,
- TPM_ALG_RSAES,
- TPM_ALG_NULL,
- ciphertext,
- &mock_authorization_delegate_,
- &plaintext));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.AsymmetricDecrypt(
+ key_handle, TPM_ALG_RSAES, TPM_ALG_NULL, ciphertext,
+ &mock_authorization_delegate_, &plaintext));
EXPECT_EQ(scheme.scheme, TPM_ALG_RSAES);
}
@@ -774,18 +718,14 @@
public_area.public_area.auth_policy.size = 0;
public_area.public_area.unique.rsa.size = 0;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, SignSync(key_handle, _, _, _, _, _,
&mock_authorization_delegate_))
- .WillOnce(DoAll(SetArgPointee<5>(signature_out),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.Sign(key_handle,
- TPM_ALG_NULL,
- TPM_ALG_NULL,
- digest,
- &mock_authorization_delegate_,
- &signature));
+ .WillOnce(DoAll(SetArgPointee<5>(signature_out), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.Sign(key_handle, TPM_ALG_NULL, TPM_ALG_NULL, digest,
+ &mock_authorization_delegate_, &signature));
EXPECT_EQ(0, signature.compare("hi"));
}
@@ -800,16 +740,13 @@
public_area.public_area.auth_policy.size = 0;
public_area.public_area.unique.rsa.size = 0;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, SignSync(key_handle, _, _, _, _, _, _))
.WillOnce(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE, utility_.Sign(key_handle,
- TPM_ALG_NULL,
- TPM_ALG_NULL,
- digest,
- &mock_authorization_delegate_,
- &signature));
+ EXPECT_EQ(TPM_RC_FAILURE,
+ utility_.Sign(key_handle, TPM_ALG_NULL, TPM_ALG_NULL, digest,
+ &mock_authorization_delegate_, &signature));
}
TEST_F(TpmUtilityTest, SignBadParams1) {
@@ -821,14 +758,11 @@
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kSign | kRestricted;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(SAPI_RC_BAD_PARAMETER, utility_.Sign(key_handle,
- TPM_ALG_RSAPSS,
- TPM_ALG_NULL,
- digest,
- &mock_authorization_delegate_,
- &signature));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(SAPI_RC_BAD_PARAMETER,
+ utility_.Sign(key_handle, TPM_ALG_RSAPSS, TPM_ALG_NULL, digest,
+ &mock_authorization_delegate_, &signature));
}
TEST_F(TpmUtilityTest, SignBadAuthorizationSession) {
@@ -836,12 +770,9 @@
std::string password;
std::string digest(32, 'a');
std::string signature;
- EXPECT_EQ(SAPI_RC_INVALID_SESSIONS, utility_.Sign(key_handle,
- TPM_ALG_RSAPSS,
- TPM_ALG_NULL,
- digest,
- nullptr,
- &signature));
+ EXPECT_EQ(SAPI_RC_INVALID_SESSIONS,
+ utility_.Sign(key_handle, TPM_ALG_RSAPSS, TPM_ALG_NULL, digest,
+ nullptr, &signature));
}
TEST_F(TpmUtilityTest, SignBadParams2) {
@@ -853,14 +784,11 @@
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kDecrypt;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(SAPI_RC_BAD_PARAMETER, utility_.Sign(key_handle,
- TPM_ALG_RSAPSS,
- TPM_ALG_NULL,
- digest,
- &mock_authorization_delegate_,
- &signature));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(SAPI_RC_BAD_PARAMETER,
+ utility_.Sign(key_handle, TPM_ALG_RSAPSS, TPM_ALG_NULL, digest,
+ &mock_authorization_delegate_, &signature));
}
TEST_F(TpmUtilityTest, SignBadParams3) {
@@ -872,14 +800,11 @@
public_area.public_area.type = TPM_ALG_ECC;
public_area.public_area.object_attributes = kSign;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(SAPI_RC_BAD_PARAMETER, utility_.Sign(key_handle,
- TPM_ALG_RSAPSS,
- TPM_ALG_NULL,
- digest,
- &mock_authorization_delegate_,
- &signature));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(SAPI_RC_BAD_PARAMETER,
+ utility_.Sign(key_handle, TPM_ALG_RSAPSS, TPM_ALG_NULL, digest,
+ &mock_authorization_delegate_, &signature));
}
TEST_F(TpmUtilityTest, SignBadParams4) {
@@ -891,14 +816,11 @@
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kSign;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_FAILURE)));
- EXPECT_EQ(TPM_RC_FAILURE, utility_.Sign(key_handle,
- TPM_ALG_RSAPSS,
- TPM_ALG_NULL,
- digest,
- &mock_authorization_delegate_,
- &signature));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_FAILURE)));
+ EXPECT_EQ(TPM_RC_FAILURE,
+ utility_.Sign(key_handle, TPM_ALG_RSAPSS, TPM_ALG_NULL, digest,
+ &mock_authorization_delegate_, &signature));
}
TEST_F(TpmUtilityTest, SignBadParams5) {
@@ -906,15 +828,11 @@
std::string password;
std::string digest(32, 'a');
std::string signature;
- EXPECT_EQ(SAPI_RC_BAD_PARAMETER, utility_.Sign(key_handle,
- TPM_ALG_AES,
- TPM_ALG_NULL,
- digest,
- &mock_authorization_delegate_,
- &signature));
+ EXPECT_EQ(SAPI_RC_BAD_PARAMETER,
+ utility_.Sign(key_handle, TPM_ALG_AES, TPM_ALG_NULL, digest,
+ &mock_authorization_delegate_, &signature));
}
-
TEST_F(TpmUtilityTest, SignNullSchemeForward) {
TPM_HANDLE key_handle;
std::string password;
@@ -929,18 +847,14 @@
public_area.public_area.auth_policy.size = 0;
public_area.public_area.unique.rsa.size = 0;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, SignSync(key_handle, _, _, _, _, _, _))
- .WillOnce(DoAll(SetArgPointee<5>(signature_out),
- SaveArg<3>(&scheme),
+ .WillOnce(DoAll(SetArgPointee<5>(signature_out), SaveArg<3>(&scheme),
Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.Sign(key_handle,
- TPM_ALG_NULL,
- TPM_ALG_NULL,
- digest,
- &mock_authorization_delegate_,
- &signature));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.Sign(key_handle, TPM_ALG_NULL, TPM_ALG_NULL, digest,
+ &mock_authorization_delegate_, &signature));
EXPECT_EQ(scheme.scheme, TPM_ALG_RSASSA);
EXPECT_EQ(scheme.details.rsassa.hash_alg, TPM_ALG_SHA256);
}
@@ -959,18 +873,14 @@
public_area.public_area.auth_policy.size = 0;
public_area.public_area.unique.rsa.size = 0;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, SignSync(key_handle, _, _, _, _, _, _))
- .WillOnce(DoAll(SetArgPointee<5>(signature_out),
- SaveArg<3>(&scheme),
+ .WillOnce(DoAll(SetArgPointee<5>(signature_out), SaveArg<3>(&scheme),
Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.Sign(key_handle,
- TPM_ALG_RSAPSS,
- TPM_ALG_SHA1,
- digest,
- &mock_authorization_delegate_,
- &signature));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.Sign(key_handle, TPM_ALG_RSAPSS, TPM_ALG_SHA1, digest,
+ &mock_authorization_delegate_, &signature));
EXPECT_EQ(scheme.scheme, TPM_ALG_RSAPSS);
EXPECT_EQ(scheme.details.rsapss.hash_alg, TPM_ALG_SHA1);
}
@@ -983,16 +893,13 @@
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kSign;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, VerifySignatureSync(key_handle, _, _, _, _, _))
.WillOnce(Return(TPM_RC_SUCCESS));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.Verify(key_handle,
- TPM_ALG_NULL,
- TPM_ALG_NULL,
- digest,
- signature,
- nullptr));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.Verify(key_handle, TPM_ALG_NULL, TPM_ALG_NULL, digest,
+ signature, nullptr));
}
TEST_F(TpmUtilityTest, VerifyFail) {
@@ -1003,16 +910,13 @@
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kSign;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, VerifySignatureSync(key_handle, _, _, _, _, _))
.WillOnce(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE, utility_.Verify(key_handle,
- TPM_ALG_NULL,
- TPM_ALG_NULL,
- digest,
- signature,
- nullptr));
+ EXPECT_EQ(TPM_RC_FAILURE,
+ utility_.Verify(key_handle, TPM_ALG_NULL, TPM_ALG_NULL, digest,
+ signature, nullptr));
}
TEST_F(TpmUtilityTest, VerifyBadParams1) {
@@ -1023,14 +927,11 @@
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kSign | kRestricted;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(SAPI_RC_BAD_PARAMETER, utility_.Verify(key_handle,
- TPM_ALG_NULL,
- TPM_ALG_NULL,
- digest,
- signature,
- nullptr));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(SAPI_RC_BAD_PARAMETER,
+ utility_.Verify(key_handle, TPM_ALG_NULL, TPM_ALG_NULL, digest,
+ signature, nullptr));
}
TEST_F(TpmUtilityTest, VerifyBadParams2) {
@@ -1041,14 +942,11 @@
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kDecrypt;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(SAPI_RC_BAD_PARAMETER, utility_.Verify(key_handle,
- TPM_ALG_NULL,
- TPM_ALG_NULL,
- digest,
- signature,
- nullptr));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(SAPI_RC_BAD_PARAMETER,
+ utility_.Verify(key_handle, TPM_ALG_NULL, TPM_ALG_NULL, digest,
+ signature, nullptr));
}
TEST_F(TpmUtilityTest, VerifyBadParams3) {
@@ -1059,14 +957,11 @@
public_area.public_area.type = TPM_ALG_ECC;
public_area.public_area.object_attributes = kSign;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(SAPI_RC_BAD_PARAMETER, utility_.Verify(key_handle,
- TPM_ALG_NULL,
- TPM_ALG_NULL,
- digest,
- signature,
- nullptr));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(SAPI_RC_BAD_PARAMETER,
+ utility_.Verify(key_handle, TPM_ALG_NULL, TPM_ALG_NULL, digest,
+ signature, nullptr));
}
TEST_F(TpmUtilityTest, VerifyBadParams4) {
@@ -1077,14 +972,11 @@
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kSign;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_FAILURE)));
- EXPECT_EQ(TPM_RC_FAILURE, utility_.Verify(key_handle,
- TPM_ALG_NULL,
- TPM_ALG_NULL,
- digest,
- signature,
- nullptr));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_FAILURE)));
+ EXPECT_EQ(TPM_RC_FAILURE,
+ utility_.Verify(key_handle, TPM_ALG_NULL, TPM_ALG_NULL, digest,
+ signature, nullptr));
}
TEST_F(TpmUtilityTest, VerifyBadParams5) {
@@ -1095,14 +987,11 @@
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kSign;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(SAPI_RC_BAD_PARAMETER, utility_.Verify(key_handle,
- TPM_ALG_AES,
- TPM_ALG_NULL,
- digest,
- signature,
- nullptr));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(SAPI_RC_BAD_PARAMETER,
+ utility_.Verify(key_handle, TPM_ALG_AES, TPM_ALG_NULL, digest,
+ signature, nullptr));
}
TEST_F(TpmUtilityTest, VerifyNullSchemeForward) {
@@ -1114,17 +1003,13 @@
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kSign;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, VerifySignatureSync(key_handle, _, _, _, _, _))
- .WillOnce(DoAll(SaveArg<3>(&signature_in),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.Verify(key_handle,
- TPM_ALG_NULL,
- TPM_ALG_NULL,
- digest,
- signature,
- nullptr));
+ .WillOnce(DoAll(SaveArg<3>(&signature_in), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.Verify(key_handle, TPM_ALG_NULL, TPM_ALG_NULL, digest,
+ signature, nullptr));
EXPECT_EQ(signature_in.sig_alg, TPM_ALG_RSASSA);
EXPECT_EQ(signature_in.signature.rsassa.hash, TPM_ALG_SHA256);
}
@@ -1138,17 +1023,13 @@
public_area.public_area.type = TPM_ALG_RSA;
public_area.public_area.object_attributes = kSign;
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, VerifySignatureSync(key_handle, _, _, _, _, _))
- .WillOnce(DoAll(SaveArg<3>(&signature_in),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.Verify(key_handle,
- TPM_ALG_RSAPSS,
- TPM_ALG_SHA1,
- digest,
- signature,
- nullptr));
+ .WillOnce(DoAll(SaveArg<3>(&signature_in), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.Verify(key_handle, TPM_ALG_RSAPSS, TPM_ALG_SHA1, digest,
+ signature, nullptr));
EXPECT_EQ(signature_in.sig_alg, TPM_ALG_RSAPSS);
EXPECT_EQ(signature_in.signature.rsassa.hash, TPM_ALG_SHA1);
}
@@ -1156,8 +1037,8 @@
TEST_F(TpmUtilityTest, CertifyCreationSuccess) {
TPM_HANDLE key_handle = 42;
std::string creation_blob;
- EXPECT_CALL(mock_tpm_, CertifyCreationSyncShort(TPM_RH_NULL, key_handle,
- _, _, _, _, _, _, _))
+ EXPECT_CALL(mock_tpm_, CertifyCreationSyncShort(TPM_RH_NULL, key_handle, _, _,
+ _, _, _, _, _))
.WillOnce(Return(TPM_RC_SUCCESS));
EXPECT_EQ(TPM_RC_SUCCESS,
utility_.CertifyCreation(key_handle, creation_blob));
@@ -1175,8 +1056,8 @@
TEST_F(TpmUtilityTest, CertifyCreationFailure) {
TPM_HANDLE key_handle = 42;
std::string creation_blob;
- EXPECT_CALL(mock_tpm_, CertifyCreationSyncShort(TPM_RH_NULL, key_handle,
- _, _, _, _, _, _, _))
+ EXPECT_CALL(mock_tpm_, CertifyCreationSyncShort(TPM_RH_NULL, key_handle, _, _,
+ _, _, _, _, _))
.WillOnce(Return(TPM_RC_FAILURE));
EXPECT_EQ(TPM_RC_FAILURE,
utility_.CertifyCreation(key_handle, creation_blob));
@@ -1191,10 +1072,11 @@
public_area.public_area.auth_policy.size = 0;
public_area.public_area.unique.rsa.size = 0;
EXPECT_CALL(mock_tpm_, ReadPublicSync(_, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
EXPECT_EQ(TPM_RC_SUCCESS, utility_.ChangeKeyAuthorizationData(
- key_handle, new_password, &mock_authorization_delegate_, &key_blob));
+ key_handle, new_password,
+ &mock_authorization_delegate_, &key_blob));
}
TEST_F(TpmUtilityTest, ChangeAuthDataKeyNameFail) {
@@ -1204,7 +1086,8 @@
EXPECT_CALL(mock_tpm_, ReadPublicSync(key_handle, _, _, _, _, _))
.WillOnce(Return(TPM_RC_FAILURE));
EXPECT_EQ(TPM_RC_FAILURE, utility_.ChangeKeyAuthorizationData(
- key_handle, new_password, &mock_authorization_delegate_, nullptr));
+ key_handle, new_password,
+ &mock_authorization_delegate_, nullptr));
}
TEST_F(TpmUtilityTest, ChangeAuthDataFailure) {
@@ -1213,7 +1096,8 @@
EXPECT_CALL(mock_tpm_, ObjectChangeAuthSync(key_handle, _, _, _, _, _, _))
.WillOnce(Return(TPM_RC_FAILURE));
EXPECT_EQ(TPM_RC_FAILURE, utility_.ChangeKeyAuthorizationData(
- key_handle, new_password, &mock_authorization_delegate_, nullptr));
+ key_handle, new_password,
+ &mock_authorization_delegate_, nullptr));
}
TEST_F(TpmUtilityTest, ChangeAuthDataParserFail) {
@@ -1225,12 +1109,14 @@
public_area.public_area.auth_policy.size = 0;
public_area.public_area.unique.rsa.size = 0;
EXPECT_CALL(mock_tpm_, ReadPublicSync(_, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_area), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_blob_parser_, SerializeKeyBlob(_, _, &key_blob))
.WillOnce(Return(false));
- EXPECT_EQ(SAPI_RC_BAD_TCTI_STRUCTURE, utility_.ChangeKeyAuthorizationData(
- key_handle, new_password, &mock_authorization_delegate_, &key_blob));
+ EXPECT_EQ(
+ SAPI_RC_BAD_TCTI_STRUCTURE,
+ utility_.ChangeKeyAuthorizationData(
+ key_handle, new_password, &mock_authorization_delegate_, &key_blob));
}
TEST_F(TpmUtilityTest, ImportRSAKeySuccess) {
@@ -1243,26 +1129,21 @@
TPM2B_PUBLIC public_data;
TPM2B_PRIVATE private_data;
EXPECT_CALL(mock_tpm_, ImportSync(_, _, _, _, _, _, _, _, _))
- .WillOnce(DoAll(SaveArg<2>(&encryption_key),
- SaveArg<3>(&public_data),
- SaveArg<4>(&private_data),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.ImportRSAKey(
- TpmUtility::AsymmetricKeyUsage::kDecryptKey,
- modulus,
- public_exponent,
- prime_factor,
- password,
- &mock_authorization_delegate_,
- &key_blob));
+ .WillOnce(DoAll(SaveArg<2>(&encryption_key), SaveArg<3>(&public_data),
+ SaveArg<4>(&private_data), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(
+ TPM_RC_SUCCESS,
+ utility_.ImportRSAKey(TpmUtility::AsymmetricKeyUsage::kDecryptKey,
+ modulus, public_exponent, prime_factor, password,
+ &mock_authorization_delegate_, &key_blob));
// Validate that the public area was properly constructed.
EXPECT_EQ(public_data.public_area.parameters.rsa_detail.key_bits,
modulus.size() * 8);
EXPECT_EQ(public_data.public_area.parameters.rsa_detail.exponent,
public_exponent);
EXPECT_EQ(public_data.public_area.unique.rsa.size, modulus.size());
- EXPECT_EQ(0, memcmp(public_data.public_area.unique.rsa.buffer,
- modulus.data(), modulus.size()));
+ EXPECT_EQ(0, memcmp(public_data.public_area.unique.rsa.buffer, modulus.data(),
+ modulus.size()));
// Validate the private struct construction.
EXPECT_EQ(kAesKeySize, encryption_key.size);
AES_KEY key;
@@ -1271,20 +1152,19 @@
int iv_in = 0;
std::string unencrypted_private(private_data.size, 0);
AES_cfb128_encrypt(
- reinterpret_cast<const unsigned char*>(private_data.buffer),
- reinterpret_cast<unsigned char*>(string_as_array(&unencrypted_private)),
- private_data.size, &key, iv, &iv_in, AES_DECRYPT);
+ reinterpret_cast<const unsigned char*>(private_data.buffer),
+ reinterpret_cast<unsigned char*>(string_as_array(&unencrypted_private)),
+ private_data.size, &key, iv, &iv_in, AES_DECRYPT);
TPM2B_DIGEST inner_integrity;
EXPECT_EQ(TPM_RC_SUCCESS, Parse_TPM2B_DIGEST(&unencrypted_private,
&inner_integrity, nullptr));
std::string object_name;
EXPECT_EQ(TPM_RC_SUCCESS,
ComputeKeyName(public_data.public_area, &object_name));
- std::string integrity_value = crypto::SHA256HashString(unencrypted_private +
- object_name);
+ std::string integrity_value =
+ crypto::SHA256HashString(unencrypted_private + object_name);
EXPECT_EQ(integrity_value.size(), inner_integrity.size);
- EXPECT_EQ(0, memcmp(inner_integrity.buffer,
- integrity_value.data(),
+ EXPECT_EQ(0, memcmp(inner_integrity.buffer, integrity_value.data(),
inner_integrity.size));
TPM2B_SENSITIVE sensitive_data;
EXPECT_EQ(TPM_RC_SUCCESS, Parse_TPM2B_SENSITIVE(&unencrypted_private,
@@ -1303,14 +1183,11 @@
std::string modulus(256, 'a');
std::string prime_factor(128, 'b');
std::string password;
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.ImportRSAKey(
- TpmUtility::AsymmetricKeyUsage::kDecryptKey,
- modulus,
- public_exponent,
- prime_factor,
- password,
- &mock_authorization_delegate_,
- nullptr));
+ EXPECT_EQ(
+ TPM_RC_SUCCESS,
+ utility_.ImportRSAKey(TpmUtility::AsymmetricKeyUsage::kDecryptKey,
+ modulus, public_exponent, prime_factor, password,
+ &mock_authorization_delegate_, nullptr));
}
TEST_F(TpmUtilityTest, ImportRSAKeyParentNameFail) {
@@ -1320,14 +1197,11 @@
std::string password;
EXPECT_CALL(mock_tpm_, ReadPublicSync(_, _, _, _, _, _))
.WillOnce(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE, utility_.ImportRSAKey(
- TpmUtility::AsymmetricKeyUsage::kDecryptKey,
- modulus,
- public_exponent,
- prime_factor,
- password,
- &mock_authorization_delegate_,
- nullptr));
+ EXPECT_EQ(
+ TPM_RC_FAILURE,
+ utility_.ImportRSAKey(TpmUtility::AsymmetricKeyUsage::kDecryptKey,
+ modulus, public_exponent, prime_factor, password,
+ &mock_authorization_delegate_, nullptr));
}
TEST_F(TpmUtilityTest, ImportRSAKeyFail) {
@@ -1336,14 +1210,10 @@
std::string password;
EXPECT_CALL(mock_tpm_, ImportSync(_, _, _, _, _, _, _, _, _))
.WillOnce(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE, utility_.ImportRSAKey(
- TpmUtility::AsymmetricKeyUsage::kDecryptKey,
- modulus,
- 0x10001,
- prime_factor,
- password,
- &mock_authorization_delegate_,
- nullptr));
+ EXPECT_EQ(TPM_RC_FAILURE,
+ utility_.ImportRSAKey(TpmUtility::AsymmetricKeyUsage::kDecryptKey,
+ modulus, 0x10001, prime_factor, password,
+ &mock_authorization_delegate_, nullptr));
}
TEST_F(TpmUtilityTest, ImportRSAKeyParserFail) {
@@ -1353,32 +1223,27 @@
std::string key_blob;
EXPECT_CALL(mock_blob_parser_, SerializeKeyBlob(_, _, &key_blob))
.WillOnce(Return(false));
- EXPECT_EQ(SAPI_RC_BAD_TCTI_STRUCTURE, utility_.ImportRSAKey(
- TpmUtility::AsymmetricKeyUsage::kDecryptKey,
- modulus,
- 0x10001,
- prime_factor,
- password,
- &mock_authorization_delegate_,
- &key_blob));
+ EXPECT_EQ(SAPI_RC_BAD_TCTI_STRUCTURE,
+ utility_.ImportRSAKey(TpmUtility::AsymmetricKeyUsage::kDecryptKey,
+ modulus, 0x10001, prime_factor, password,
+ &mock_authorization_delegate_, &key_blob));
}
TEST_F(TpmUtilityTest, CreateRSAKeyPairSuccess) {
TPM2B_PUBLIC public_area;
TPML_PCR_SELECTION creation_pcrs;
- EXPECT_CALL(mock_tpm_, CreateSyncShort(kRSAStorageRootKey,
- _, _, _, _, _, _, _, _,
- &mock_authorization_delegate_))
- .WillOnce(DoAll(SaveArg<2>(&public_area),
- SaveArg<3>(&creation_pcrs),
+ EXPECT_CALL(mock_tpm_, CreateSyncShort(kRSAStorageRootKey, _, _, _, _, _, _,
+ _, _, &mock_authorization_delegate_))
+ .WillOnce(DoAll(SaveArg<2>(&public_area), SaveArg<3>(&creation_pcrs),
Return(TPM_RC_SUCCESS)));
std::string key_blob;
std::string creation_blob;
int creation_pcr = 12;
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.CreateRSAKeyPair(
- TpmUtility::AsymmetricKeyUsage::kDecryptAndSignKey, 2048, 0x10001,
- "password", "", false, creation_pcr, &mock_authorization_delegate_,
- &key_blob, &creation_blob));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.CreateRSAKeyPair(
+ TpmUtility::AsymmetricKeyUsage::kDecryptAndSignKey, 2048,
+ 0x10001, "password", "", false, creation_pcr,
+ &mock_authorization_delegate_, &key_blob, &creation_blob));
EXPECT_EQ(public_area.public_area.object_attributes & kDecrypt, kDecrypt);
EXPECT_EQ(public_area.public_area.object_attributes & kSign, kSign);
EXPECT_EQ(public_area.public_area.object_attributes & kUserWithAuth,
@@ -1395,16 +1260,15 @@
TEST_F(TpmUtilityTest, CreateRSAKeyPairDecryptKeySuccess) {
TPM2B_PUBLIC public_area;
- EXPECT_CALL(mock_tpm_, CreateSyncShort(kRSAStorageRootKey,
- _, _, _, _, _, _, _, _,
- &mock_authorization_delegate_))
- .WillOnce(DoAll(SaveArg<2>(&public_area),
- Return(TPM_RC_SUCCESS)));
+ EXPECT_CALL(mock_tpm_, CreateSyncShort(kRSAStorageRootKey, _, _, _, _, _, _,
+ _, _, &mock_authorization_delegate_))
+ .WillOnce(DoAll(SaveArg<2>(&public_area), Return(TPM_RC_SUCCESS)));
std::string key_blob;
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.CreateRSAKeyPair(
- TpmUtility::AsymmetricKeyUsage::kDecryptKey, 2048, 0x10001, "password",
- "", false, kNoCreationPCR, &mock_authorization_delegate_, &key_blob,
- nullptr));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.CreateRSAKeyPair(
+ TpmUtility::AsymmetricKeyUsage::kDecryptKey, 2048, 0x10001,
+ "password", "", false, kNoCreationPCR,
+ &mock_authorization_delegate_, &key_blob, nullptr));
EXPECT_EQ(public_area.public_area.object_attributes & kDecrypt, kDecrypt);
EXPECT_EQ(public_area.public_area.object_attributes & kSign, 0u);
EXPECT_EQ(public_area.public_area.parameters.rsa_detail.scheme.scheme,
@@ -1414,19 +1278,19 @@
TEST_F(TpmUtilityTest, CreateRSAKeyPairSignKeySuccess) {
TPM2B_PUBLIC public_area;
TPM2B_SENSITIVE_CREATE sensitive_create;
- EXPECT_CALL(mock_tpm_, CreateSyncShort(kRSAStorageRootKey,
- _, _, _, _, _, _, _, _,
- &mock_authorization_delegate_))
- .WillOnce(DoAll(SaveArg<1>(&sensitive_create),
- SaveArg<2>(&public_area),
+ EXPECT_CALL(mock_tpm_, CreateSyncShort(kRSAStorageRootKey, _, _, _, _, _, _,
+ _, _, &mock_authorization_delegate_))
+ .WillOnce(DoAll(SaveArg<1>(&sensitive_create), SaveArg<2>(&public_area),
Return(TPM_RC_SUCCESS)));
std::string key_blob;
std::string policy_digest(32, 'a');
std::string key_auth("password");
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.CreateRSAKeyPair(
- TpmUtility::AsymmetricKeyUsage::kSignKey, 2048, 0x10001, key_auth,
- policy_digest, true /* use_only_policy_authorization */, kNoCreationPCR,
- &mock_authorization_delegate_, &key_blob, nullptr));
+ EXPECT_EQ(
+ TPM_RC_SUCCESS,
+ utility_.CreateRSAKeyPair(
+ TpmUtility::AsymmetricKeyUsage::kSignKey, 2048, 0x10001, key_auth,
+ policy_digest, true /* use_only_policy_authorization */,
+ kNoCreationPCR, &mock_authorization_delegate_, &key_blob, nullptr));
EXPECT_EQ(public_area.public_area.object_attributes & kDecrypt, 0u);
EXPECT_EQ(public_area.public_area.object_attributes & kSign, kSign);
EXPECT_EQ(public_area.public_area.object_attributes & kUserWithAuth, 0u);
@@ -1446,31 +1310,34 @@
TEST_F(TpmUtilityTest, CreateRSAKeyPairBadDelegate) {
std::string key_blob;
- EXPECT_EQ(SAPI_RC_INVALID_SESSIONS, utility_.CreateRSAKeyPair(
- TpmUtility::AsymmetricKeyUsage::kDecryptKey, 2048, 0x10001, "password",
- "", false, kNoCreationPCR, nullptr, &key_blob, nullptr));
+ EXPECT_EQ(
+ SAPI_RC_INVALID_SESSIONS,
+ utility_.CreateRSAKeyPair(TpmUtility::AsymmetricKeyUsage::kDecryptKey,
+ 2048, 0x10001, "password", "", false,
+ kNoCreationPCR, nullptr, &key_blob, nullptr));
}
TEST_F(TpmUtilityTest, CreateRSAKeyPairFailure) {
- EXPECT_CALL(mock_tpm_, CreateSyncShort(kRSAStorageRootKey,
- _, _, _, _, _, _, _, _,
- &mock_authorization_delegate_))
+ EXPECT_CALL(mock_tpm_, CreateSyncShort(kRSAStorageRootKey, _, _, _, _, _, _,
+ _, _, &mock_authorization_delegate_))
.WillOnce(Return(TPM_RC_FAILURE));
std::string key_blob;
- EXPECT_EQ(TPM_RC_FAILURE, utility_.CreateRSAKeyPair(
- TpmUtility::AsymmetricKeyUsage::kSignKey, 2048, 0x10001, "password",
- "", false, kNoCreationPCR, &mock_authorization_delegate_, &key_blob,
- nullptr));
+ EXPECT_EQ(TPM_RC_FAILURE,
+ utility_.CreateRSAKeyPair(
+ TpmUtility::AsymmetricKeyUsage::kSignKey, 2048, 0x10001,
+ "password", "", false, kNoCreationPCR,
+ &mock_authorization_delegate_, &key_blob, nullptr));
}
TEST_F(TpmUtilityTest, CreateRSAKeyPairKeyParserFail) {
std::string key_blob;
EXPECT_CALL(mock_blob_parser_, SerializeKeyBlob(_, _, &key_blob))
.WillOnce(Return(false));
- EXPECT_EQ(SAPI_RC_BAD_TCTI_STRUCTURE, utility_.CreateRSAKeyPair(
- TpmUtility::AsymmetricKeyUsage::kSignKey, 2048, 0x10001, "password",
- "", false, kNoCreationPCR, &mock_authorization_delegate_, &key_blob,
- nullptr));
+ EXPECT_EQ(SAPI_RC_BAD_TCTI_STRUCTURE,
+ utility_.CreateRSAKeyPair(
+ TpmUtility::AsymmetricKeyUsage::kSignKey, 2048, 0x10001,
+ "password", "", false, kNoCreationPCR,
+ &mock_authorization_delegate_, &key_blob, nullptr));
}
TEST_F(TpmUtilityTest, CreateRSAKeyPairCreationParserFail) {
@@ -1478,10 +1345,11 @@
std::string key_blob;
EXPECT_CALL(mock_blob_parser_, SerializeCreationBlob(_, _, _, &creation_blob))
.WillOnce(Return(false));
- EXPECT_EQ(SAPI_RC_BAD_TCTI_STRUCTURE, utility_.CreateRSAKeyPair(
- TpmUtility::AsymmetricKeyUsage::kSignKey, 2048, 0x10001, "password",
- "", false, kNoCreationPCR, &mock_authorization_delegate_, &key_blob,
- &creation_blob));
+ EXPECT_EQ(SAPI_RC_BAD_TCTI_STRUCTURE,
+ utility_.CreateRSAKeyPair(
+ TpmUtility::AsymmetricKeyUsage::kSignKey, 2048, 0x10001,
+ "password", "", false, kNoCreationPCR,
+ &mock_authorization_delegate_, &key_blob, &creation_blob));
}
TEST_F(TpmUtilityTest, LoadKeySuccess) {
@@ -1489,11 +1357,11 @@
TPM_HANDLE loaded_handle;
EXPECT_CALL(mock_tpm_, LoadSync(kRSAStorageRootKey, _, _, _, _, _,
&mock_authorization_delegate_))
- .WillOnce(DoAll(SetArgPointee<4>(key_handle),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SetArgPointee<4>(key_handle), Return(TPM_RC_SUCCESS)));
std::string key_blob;
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.LoadKey(
- key_blob, &mock_authorization_delegate_, &loaded_handle));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.LoadKey(key_blob, &mock_authorization_delegate_,
+ &loaded_handle));
EXPECT_EQ(loaded_handle, key_handle);
}
@@ -1502,15 +1370,16 @@
EXPECT_CALL(mock_tpm_, LoadSync(_, _, _, _, _, _, _))
.WillOnce(Return(TPM_RC_FAILURE));
std::string key_blob;
- EXPECT_EQ(TPM_RC_FAILURE, utility_.LoadKey(
- key_blob, &mock_authorization_delegate_, &key_handle));
+ EXPECT_EQ(
+ TPM_RC_FAILURE,
+ utility_.LoadKey(key_blob, &mock_authorization_delegate_, &key_handle));
}
TEST_F(TpmUtilityTest, LoadKeyBadDelegate) {
TPM_HANDLE key_handle;
std::string key_blob;
- EXPECT_EQ(SAPI_RC_INVALID_SESSIONS, utility_.LoadKey(
- key_blob, nullptr, &key_handle));
+ EXPECT_EQ(SAPI_RC_INVALID_SESSIONS,
+ utility_.LoadKey(key_blob, nullptr, &key_handle));
}
TEST_F(TpmUtilityTest, LoadKeyParserFail) {
@@ -1518,8 +1387,9 @@
std::string key_blob;
EXPECT_CALL(mock_blob_parser_, ParseKeyBlob(key_blob, _, _))
.WillOnce(Return(false));
- EXPECT_EQ(SAPI_RC_BAD_TCTI_STRUCTURE, utility_.LoadKey(
- key_blob, &mock_authorization_delegate_, &key_handle));
+ EXPECT_EQ(
+ SAPI_RC_BAD_TCTI_STRUCTURE,
+ utility_.LoadKey(key_blob, &mock_authorization_delegate_, &key_handle));
}
TEST_F(TpmUtilityTest, SealedDataSuccess) {
@@ -1527,13 +1397,13 @@
std::string sealed_data;
TPM2B_SENSITIVE_CREATE sensitive_create;
TPM2B_PUBLIC in_public;
- EXPECT_CALL(mock_tpm_, CreateSyncShort(kRSAStorageRootKey, _, _,
- _, _, _, _, _, _, _))
- .WillOnce(DoAll(SaveArg<1>(&sensitive_create),
- SaveArg<2>(&in_public),
+ EXPECT_CALL(mock_tpm_,
+ CreateSyncShort(kRSAStorageRootKey, _, _, _, _, _, _, _, _, _))
+ .WillOnce(DoAll(SaveArg<1>(&sensitive_create), SaveArg<2>(&in_public),
Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.SealData(
- data_to_seal, "", &mock_authorization_delegate_, &sealed_data));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.SealData(data_to_seal, "", &mock_authorization_delegate_,
+ &sealed_data));
EXPECT_EQ(sensitive_create.sensitive.data.size, data_to_seal.size());
EXPECT_EQ(0, memcmp(sensitive_create.sensitive.data.buffer,
data_to_seal.data(), data_to_seal.size()));
@@ -1544,18 +1414,19 @@
TEST_F(TpmUtilityTest, SealDataBadDelegate) {
std::string data_to_seal("seal_data");
std::string sealed_data;
- EXPECT_EQ(SAPI_RC_INVALID_SESSIONS, utility_.SealData(
- data_to_seal, "", nullptr, &sealed_data));
+ EXPECT_EQ(SAPI_RC_INVALID_SESSIONS,
+ utility_.SealData(data_to_seal, "", nullptr, &sealed_data));
}
TEST_F(TpmUtilityTest, SealDataFailure) {
std::string data_to_seal("seal_data");
std::string sealed_data;
- EXPECT_CALL(mock_tpm_, CreateSyncShort(kRSAStorageRootKey, _, _,
- _, _, _, _, _, _, _))
+ EXPECT_CALL(mock_tpm_,
+ CreateSyncShort(kRSAStorageRootKey, _, _, _, _, _, _, _, _, _))
.WillOnce(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE, utility_.SealData(
- data_to_seal, "", &mock_authorization_delegate_, &sealed_data));
+ EXPECT_EQ(TPM_RC_FAILURE,
+ utility_.SealData(data_to_seal, "", &mock_authorization_delegate_,
+ &sealed_data));
}
TEST_F(TpmUtilityTest, SealDataParserFail) {
@@ -1563,8 +1434,9 @@
std::string sealed_data;
EXPECT_CALL(mock_blob_parser_, SerializeKeyBlob(_, _, &sealed_data))
.WillOnce(Return(false));
- EXPECT_EQ(SAPI_RC_BAD_TCTI_STRUCTURE, utility_.SealData(
- data_to_seal, "", &mock_authorization_delegate_, &sealed_data));
+ EXPECT_EQ(SAPI_RC_BAD_TCTI_STRUCTURE,
+ utility_.SealData(data_to_seal, "", &mock_authorization_delegate_,
+ &sealed_data));
}
TEST_F(TpmUtilityTest, UnsealDataSuccess) {
@@ -1575,28 +1447,27 @@
TPM2B_PUBLIC public_data;
public_data.public_area.auth_policy.size = 0;
EXPECT_CALL(mock_tpm_, ReadPublicSync(_, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_data),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_data), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, ReadPublicSync(object_handle, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(public_data),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<2>(public_data), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, LoadSync(_, _, _, _, _, _, _))
- .WillOnce(DoAll(SetArgPointee<4>(object_handle),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SetArgPointee<4>(object_handle), Return(TPM_RC_SUCCESS)));
TPM2B_SENSITIVE_DATA out_data = Make_TPM2B_SENSITIVE_DATA(tpm_unsealed_data);
EXPECT_CALL(mock_tpm_, UnsealSync(object_handle, _, _, _))
- .WillOnce(DoAll(SetArgPointee<2>(out_data),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.UnsealData(
- sealed_data, &mock_authorization_delegate_, &unsealed_data));
+ .WillOnce(DoAll(SetArgPointee<2>(out_data), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.UnsealData(sealed_data, &mock_authorization_delegate_,
+ &unsealed_data));
EXPECT_EQ(unsealed_data, tpm_unsealed_data);
}
TEST_F(TpmUtilityTest, UnsealDataBadDelegate) {
std::string sealed_data;
std::string unsealed_data;
- EXPECT_EQ(SAPI_RC_INVALID_SESSIONS, utility_.UnsealData(
- sealed_data, nullptr, &unsealed_data));
+ EXPECT_EQ(SAPI_RC_INVALID_SESSIONS,
+ utility_.UnsealData(sealed_data, nullptr, &unsealed_data));
}
TEST_F(TpmUtilityTest, UnsealDataLoadFail) {
@@ -1604,8 +1475,9 @@
std::string unsealed_data;
EXPECT_CALL(mock_tpm_, LoadSync(_, _, _, _, _, _, _))
.WillOnce(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE, utility_.UnsealData(
- sealed_data, &mock_authorization_delegate_, &unsealed_data));
+ EXPECT_EQ(TPM_RC_FAILURE,
+ utility_.UnsealData(sealed_data, &mock_authorization_delegate_,
+ &unsealed_data));
}
TEST_F(TpmUtilityTest, UnsealDataBadKeyName) {
@@ -1613,8 +1485,9 @@
std::string unsealed_data;
EXPECT_CALL(mock_tpm_, ReadPublicSync(_, _, _, _, _, _))
.WillOnce(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE, utility_.UnsealData(
- sealed_data, &mock_authorization_delegate_, &unsealed_data));
+ EXPECT_EQ(TPM_RC_FAILURE,
+ utility_.UnsealData(sealed_data, &mock_authorization_delegate_,
+ &unsealed_data));
}
TEST_F(TpmUtilityTest, UnsealObjectFailure) {
@@ -1622,22 +1495,21 @@
std::string unsealed_data;
EXPECT_CALL(mock_tpm_, UnsealSync(_, _, _, _))
.WillOnce(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE, utility_.UnsealData(
- sealed_data, &mock_authorization_delegate_, &unsealed_data));
+ EXPECT_EQ(TPM_RC_FAILURE,
+ utility_.UnsealData(sealed_data, &mock_authorization_delegate_,
+ &unsealed_data));
}
TEST_F(TpmUtilityTest, StartSessionSuccess) {
EXPECT_CALL(mock_hmac_session_, StartUnboundSession(true))
.WillOnce(Return(TPM_RC_SUCCESS));
- EXPECT_EQ(TPM_RC_SUCCESS,
- utility_.StartSession(&mock_hmac_session_));
+ EXPECT_EQ(TPM_RC_SUCCESS, utility_.StartSession(&mock_hmac_session_));
}
TEST_F(TpmUtilityTest, StartSessionFailure) {
EXPECT_CALL(mock_hmac_session_, StartUnboundSession(true))
.WillOnce(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE,
- utility_.StartSession(&mock_hmac_session_));
+ EXPECT_EQ(TPM_RC_FAILURE, utility_.StartSession(&mock_hmac_session_));
}
TEST_F(TpmUtilityTest, GetPolicyDigestForPcrValueSuccess) {
@@ -1654,18 +1526,16 @@
pcr_values.digests[0] = Make_TPM2B_DIGEST(pcr_value);
EXPECT_CALL(mock_tpm_, PCR_ReadSync(_, _, _, _, _))
.WillOnce(DoAll(SetArgPointee<2>(pcr_select),
- SetArgPointee<3>(pcr_values),
- Return(TPM_RC_SUCCESS)));
+ SetArgPointee<3>(pcr_values), Return(TPM_RC_SUCCESS)));
std::string tpm_pcr_value;
EXPECT_CALL(mock_policy_session_, PolicyPCR(index, _))
- .WillOnce(DoAll(SaveArg<1>(&tpm_pcr_value),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SaveArg<1>(&tpm_pcr_value), Return(TPM_RC_SUCCESS)));
std::string tpm_policy_digest("digest");
EXPECT_CALL(mock_policy_session_, GetDigest(_))
- .WillOnce(DoAll(SetArgPointee<0>(tpm_policy_digest),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(
+ DoAll(SetArgPointee<0>(tpm_policy_digest), Return(TPM_RC_SUCCESS)));
EXPECT_EQ(TPM_RC_SUCCESS,
- utility_.GetPolicyDigestForPcrValue(index, "", &policy_digest));
+ utility_.GetPolicyDigestForPcrValue(index, "", &policy_digest));
EXPECT_EQ(policy_digest, tpm_policy_digest);
EXPECT_EQ(pcr_value, tpm_pcr_value);
}
@@ -1676,14 +1546,13 @@
std::string policy_digest;
std::string tpm_pcr_value;
EXPECT_CALL(mock_policy_session_, PolicyPCR(index, _))
- .WillOnce(DoAll(SaveArg<1>(&tpm_pcr_value),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SaveArg<1>(&tpm_pcr_value), Return(TPM_RC_SUCCESS)));
std::string tpm_policy_digest("digest");
EXPECT_CALL(mock_policy_session_, GetDigest(_))
- .WillOnce(DoAll(SetArgPointee<0>(tpm_policy_digest),
- Return(TPM_RC_SUCCESS)));
- EXPECT_EQ(TPM_RC_SUCCESS,
- utility_.GetPolicyDigestForPcrValue(index, pcr_value, &policy_digest));
+ .WillOnce(
+ DoAll(SetArgPointee<0>(tpm_policy_digest), Return(TPM_RC_SUCCESS)));
+ EXPECT_EQ(TPM_RC_SUCCESS, utility_.GetPolicyDigestForPcrValue(
+ index, pcr_value, &policy_digest));
EXPECT_EQ(policy_digest, tpm_policy_digest);
EXPECT_EQ(pcr_value, tpm_pcr_value);
}
@@ -1694,8 +1563,8 @@
std::string policy_digest;
EXPECT_CALL(mock_policy_session_, StartUnboundSession(false))
.WillOnce(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE,
- utility_.GetPolicyDigestForPcrValue(index, pcr_value, &policy_digest));
+ EXPECT_EQ(TPM_RC_FAILURE, utility_.GetPolicyDigestForPcrValue(
+ index, pcr_value, &policy_digest));
}
TEST_F(TpmUtilityTest, GetPolicyDigestForPcrValuePcrReadFail) {
@@ -1704,7 +1573,7 @@
EXPECT_CALL(mock_tpm_, PCR_ReadSync(_, _, _, _, _))
.WillOnce(Return(TPM_RC_FAILURE));
EXPECT_EQ(TPM_RC_FAILURE,
- utility_.GetPolicyDigestForPcrValue(index, "", &policy_digest));
+ utility_.GetPolicyDigestForPcrValue(index, "", &policy_digest));
}
TEST_F(TpmUtilityTest, GetPolicyDigestForPcrValueBadPcr) {
@@ -1713,8 +1582,8 @@
std::string policy_digest;
EXPECT_CALL(mock_policy_session_, PolicyPCR(index, _))
.WillOnce(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE,
- utility_.GetPolicyDigestForPcrValue(index, pcr_value, &policy_digest));
+ EXPECT_EQ(TPM_RC_FAILURE, utility_.GetPolicyDigestForPcrValue(
+ index, pcr_value, &policy_digest));
}
TEST_F(TpmUtilityTest, GetPolicyDigestForPcrValueBadDigest) {
@@ -1723,20 +1592,19 @@
std::string policy_digest;
EXPECT_CALL(mock_policy_session_, GetDigest(&policy_digest))
.WillOnce(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE,
- utility_.GetPolicyDigestForPcrValue(index, pcr_value, &policy_digest));
+ EXPECT_EQ(TPM_RC_FAILURE, utility_.GetPolicyDigestForPcrValue(
+ index, pcr_value, &policy_digest));
}
TEST_F(TpmUtilityTest, DefineNVSpaceSuccess) {
uint32_t index = 59;
uint32_t nvram_index = NV_INDEX_FIRST + index;
- size_t length = 256;
+ size_t length = 256;
TPM2B_NV_PUBLIC public_data;
EXPECT_CALL(mock_tpm_, NV_DefineSpaceSync(TPM_RH_OWNER, _, _, _, _))
- .WillOnce(DoAll(SaveArg<3>(&public_data),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SaveArg<3>(&public_data), Return(TPM_RC_SUCCESS)));
EXPECT_EQ(TPM_RC_SUCCESS, utility_.DefineNVSpace(
- index, length, &mock_authorization_delegate_));
+ index, length, &mock_authorization_delegate_));
EXPECT_EQ(public_data.nv_public.nv_index, nvram_index);
EXPECT_EQ(public_data.nv_public.name_alg, TPM_ALG_SHA256);
EXPECT_EQ(public_data.nv_public.attributes,
@@ -1747,13 +1615,15 @@
TEST_F(TpmUtilityTest, DefineNVSpaceBadLength) {
size_t bad_length = 3000;
- EXPECT_EQ(SAPI_RC_BAD_SIZE,
+ EXPECT_EQ(
+ SAPI_RC_BAD_SIZE,
utility_.DefineNVSpace(0, bad_length, &mock_authorization_delegate_));
}
TEST_F(TpmUtilityTest, DefineNVSpaceBadIndex) {
- uint32_t bad_index = 1<<29;
- EXPECT_EQ(SAPI_RC_BAD_PARAMETER,
+ uint32_t bad_index = 1 << 29;
+ EXPECT_EQ(
+ SAPI_RC_BAD_PARAMETER,
utility_.DefineNVSpace(bad_index, 2, &mock_authorization_delegate_));
}
@@ -1763,11 +1633,11 @@
TEST_F(TpmUtilityTest, DefineNVSpaceFail) {
uint32_t index = 59;
- size_t length = 256;
+ size_t length = 256;
EXPECT_CALL(mock_tpm_, NV_DefineSpaceSync(TPM_RH_OWNER, _, _, _, _))
.WillOnce(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE,
- utility_.DefineNVSpace(index, length, &mock_authorization_delegate_));
+ EXPECT_EQ(TPM_RC_FAILURE, utility_.DefineNVSpace(
+ index, length, &mock_authorization_delegate_));
}
TEST_F(TpmUtilityTest, DestroyNVSpaceSuccess) {
@@ -1780,7 +1650,7 @@
}
TEST_F(TpmUtilityTest, DestroyNVSpaceBadIndex) {
- uint32_t bad_index = 1<<29;
+ uint32_t bad_index = 1 << 29;
EXPECT_EQ(SAPI_RC_BAD_PARAMETER,
utility_.DestroyNVSpace(bad_index, &mock_authorization_delegate_));
}
@@ -1812,7 +1682,7 @@
}
TEST_F(TpmUtilityTest, LockNVSpaceBadIndex) {
- uint32_t bad_index = 1<<24;
+ uint32_t bad_index = 1 << 24;
EXPECT_EQ(SAPI_RC_BAD_PARAMETER,
utility_.LockNVSpace(bad_index, &mock_authorization_delegate_));
}
@@ -1837,8 +1707,9 @@
EXPECT_CALL(mock_tpm_,
NV_WriteSync(TPM_RH_OWNER, _, nvram_index, _, _, offset, _))
.WillOnce(Return(TPM_RC_SUCCESS));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.WriteNVSpace(
- index, offset, "", &mock_authorization_delegate_));
+ EXPECT_EQ(
+ TPM_RC_SUCCESS,
+ utility_.WriteNVSpace(index, offset, "", &mock_authorization_delegate_));
TPMS_NV_PUBLIC public_area;
EXPECT_EQ(TPM_RC_SUCCESS, GetNVRAMMap(index, &public_area));
EXPECT_EQ(public_area.attributes & TPMA_NV_WRITTEN, TPMA_NV_WRITTEN);
@@ -1847,14 +1718,16 @@
TEST_F(TpmUtilityTest, WriteNVSpaceBadSize) {
uint32_t index = 53;
std::string nvram_data(1025, 0);
- EXPECT_EQ(SAPI_RC_BAD_SIZE, utility_.WriteNVSpace(
- index, 0, nvram_data, &mock_authorization_delegate_));
+ EXPECT_EQ(SAPI_RC_BAD_SIZE,
+ utility_.WriteNVSpace(index, 0, nvram_data,
+ &mock_authorization_delegate_));
}
TEST_F(TpmUtilityTest, WriteNVSpaceBadIndex) {
- uint32_t bad_index = 1<<24;
- EXPECT_EQ(SAPI_RC_BAD_PARAMETER, utility_.WriteNVSpace(
- bad_index, 0, "", &mock_authorization_delegate_));
+ uint32_t bad_index = 1 << 24;
+ EXPECT_EQ(
+ SAPI_RC_BAD_PARAMETER,
+ utility_.WriteNVSpace(bad_index, 0, "", &mock_authorization_delegate_));
}
TEST_F(TpmUtilityTest, WriteNVSpaceBadSessions) {
@@ -1869,8 +1742,9 @@
EXPECT_CALL(mock_tpm_,
NV_WriteSync(TPM_RH_OWNER, _, nvram_index, _, _, offset, _))
.WillOnce(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE, utility_.WriteNVSpace(
- index, offset, "", &mock_authorization_delegate_));
+ EXPECT_EQ(
+ TPM_RC_FAILURE,
+ utility_.WriteNVSpace(index, offset, "", &mock_authorization_delegate_));
}
TEST_F(TpmUtilityTest, ReadNVSpaceSuccess) {
@@ -1882,22 +1756,25 @@
EXPECT_CALL(mock_tpm_,
NV_ReadSync(nv_index, _, nv_index, _, length, offset, _, _))
.WillOnce(Return(TPM_RC_SUCCESS));
- EXPECT_EQ(TPM_RC_SUCCESS, utility_.ReadNVSpace(
- index, offset, length, &nvram_data, &mock_authorization_delegate_));
+ EXPECT_EQ(TPM_RC_SUCCESS,
+ utility_.ReadNVSpace(index, offset, length, &nvram_data,
+ &mock_authorization_delegate_));
}
TEST_F(TpmUtilityTest, ReadNVSpaceBadReadLength) {
size_t length = 1025;
std::string nvram_data;
- EXPECT_EQ(SAPI_RC_BAD_SIZE, utility_.ReadNVSpace(
- 52, 0, length, &nvram_data, &mock_authorization_delegate_));
+ EXPECT_EQ(SAPI_RC_BAD_SIZE,
+ utility_.ReadNVSpace(52, 0, length, &nvram_data,
+ &mock_authorization_delegate_));
}
TEST_F(TpmUtilityTest, ReadNVSpaceBadIndex) {
- uint32_t bad_index = 1<<24;
+ uint32_t bad_index = 1 << 24;
std::string nvram_data;
- EXPECT_EQ(SAPI_RC_BAD_PARAMETER, utility_.ReadNVSpace(
- bad_index, 0, 5, &nvram_data, &mock_authorization_delegate_));
+ EXPECT_EQ(SAPI_RC_BAD_PARAMETER,
+ utility_.ReadNVSpace(bad_index, 0, 5, &nvram_data,
+ &mock_authorization_delegate_));
}
TEST_F(TpmUtilityTest, ReadNVSpaceBadSession) {
@@ -1915,8 +1792,9 @@
EXPECT_CALL(mock_tpm_,
NV_ReadSync(nv_index, _, nv_index, _, length, offset, _, _))
.WillOnce(Return(TPM_RC_FAILURE));
- EXPECT_EQ(TPM_RC_FAILURE, utility_.ReadNVSpace(
- index, offset, length, &nvram_data, &mock_authorization_delegate_));
+ EXPECT_EQ(TPM_RC_FAILURE,
+ utility_.ReadNVSpace(index, offset, length, &nvram_data,
+ &mock_authorization_delegate_));
}
TEST_F(TpmUtilityTest, GetNVSpaceNameSuccess) {
@@ -1940,8 +1818,7 @@
uint32_t index = 53;
TPMS_NV_PUBLIC public_area;
SetNVRAMMap(index, public_area);
- EXPECT_CALL(mock_tpm_, NV_ReadPublicSync(_, _, _, _, _))
- .Times(0);
+ EXPECT_CALL(mock_tpm_, NV_ReadPublicSync(_, _, _, _, _)).Times(0);
EXPECT_EQ(TPM_RC_SUCCESS, utility_.GetNVSpacePublicArea(index, &public_area));
}
@@ -1963,8 +1840,7 @@
}
TEST_F(TpmUtilityTest, SetKnownPasswordSuccess) {
- EXPECT_CALL(mock_tpm_state_, IsOwnerPasswordSet())
- .WillOnce(Return(false));
+ EXPECT_CALL(mock_tpm_state_, IsOwnerPasswordSet()).WillOnce(Return(false));
EXPECT_CALL(mock_tpm_, HierarchyChangeAuthSync(TPM_RH_OWNER, _, _, _))
.WillOnce(Return(TPM_RC_SUCCESS));
EXPECT_EQ(TPM_RC_SUCCESS, SetKnownOwnerPassword("password"));
@@ -1975,8 +1851,7 @@
}
TEST_F(TpmUtilityTest, SetKnownPasswordFailure) {
- EXPECT_CALL(mock_tpm_state_, IsOwnerPasswordSet())
- .WillOnce(Return(false));
+ EXPECT_CALL(mock_tpm_state_, IsOwnerPasswordSet()).WillOnce(Return(false));
EXPECT_CALL(mock_tpm_, HierarchyChangeAuthSync(TPM_RH_OWNER, _, _, _))
.WillRepeatedly(Return(TPM_RC_FAILURE));
EXPECT_EQ(TPM_RC_FAILURE, SetKnownOwnerPassword("password"));
@@ -1989,8 +1864,8 @@
TEST_F(TpmUtilityTest, RootKeysHandleConsistency) {
TPM_HANDLE test_handle = 42;
EXPECT_CALL(mock_tpm_, CreatePrimarySyncShort(_, _, _, _, _, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<3>(test_handle),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<3>(test_handle), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, EvictControlSync(_, _, test_handle, _, _, _))
.WillRepeatedly(Return(TPM_RC_SUCCESS));
EXPECT_EQ(TPM_RC_SUCCESS, CreateStorageRootKeys("password"));
@@ -2017,8 +1892,7 @@
TEST_F(TpmUtilityTest, SaltingKeySuccess) {
TPM2B_PUBLIC public_area;
EXPECT_CALL(mock_tpm_, CreateSyncShort(_, _, _, _, _, _, _, _, _, _))
- .WillOnce(DoAll(SaveArg<2>(&public_area),
- Return(TPM_RC_SUCCESS)));
+ .WillOnce(DoAll(SaveArg<2>(&public_area), Return(TPM_RC_SUCCESS)));
EXPECT_EQ(TPM_RC_SUCCESS, CreateSaltingKey("password"));
EXPECT_EQ(TPM_ALG_SHA256, public_area.public_area.name_alg);
}
@@ -2026,8 +1900,8 @@
TEST_F(TpmUtilityTest, SaltingKeyConsistency) {
TPM_HANDLE test_handle = 42;
EXPECT_CALL(mock_tpm_, LoadSync(_, _, _, _, _, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<4>(test_handle),
- Return(TPM_RC_SUCCESS)));
+ .WillRepeatedly(
+ DoAll(SetArgPointee<4>(test_handle), Return(TPM_RC_SUCCESS)));
EXPECT_CALL(mock_tpm_, EvictControlSync(_, _, test_handle, _, _, _))
.WillRepeatedly(Return(TPM_RC_SUCCESS));
EXPECT_EQ(TPM_RC_SUCCESS, CreateSaltingKey("password"));
diff --git a/trunks/trunks_binder_proxy.cc b/trunks/trunks_binder_proxy.cc
index 2dd2d35..5c7590c 100644
--- a/trunks/trunks_binder_proxy.cc
+++ b/trunks/trunks_binder_proxy.cc
@@ -33,7 +33,8 @@
// Implements ITrunksClient and forwards response data to a ResponseCallback.
class ResponseObserver : public android::trunks::BnTrunksClient {
public:
- explicit ResponseObserver(const trunks::CommandTransceiver::ResponseCallback& callback)
+ explicit ResponseObserver(
+ const trunks::CommandTransceiver::ResponseCallback& callback)
: callback_(callback) {}
// ITrunksClient interface.
diff --git a/trunks/trunks_binder_service.h b/trunks/trunks_binder_service.h
index 0352b74..d9c8dec 100644
--- a/trunks/trunks_binder_service.h
+++ b/trunks/trunks_binder_service.h
@@ -86,5 +86,4 @@
} // namespace trunks
-
#endif // TRUNKS_TRUNKS_BINDER_SERVICE_H_
diff --git a/trunks/trunks_client.cc b/trunks/trunks_client.cc
index ac29bf1..76e2305 100644
--- a/trunks/trunks_client.cc
+++ b/trunks/trunks_client.cc
@@ -81,8 +81,7 @@
int TakeOwnership(const std::string& owner_password, TrunksFactory* factory) {
trunks::TPM_RC rc;
- rc = factory->GetTpmUtility()->TakeOwnership(owner_password,
- owner_password,
+ rc = factory->GetTpmUtility()->TakeOwnership(owner_password, owner_password,
owner_password);
if (rc) {
LOG(ERROR) << "Error taking ownership: " << trunks::GetErrorString(rc);
@@ -105,24 +104,19 @@
state->IsEndorsementPasswordSet() ? "true" : "false");
printf("Lockout password set: %s\n",
state->IsLockoutPasswordSet() ? "true" : "false");
- printf("Ownership status: %s\n",
- state->IsOwned() ? "true" : "false");
- printf("In lockout: %s\n",
- state->IsInLockout() ? "true" : "false");
+ printf("Ownership status: %s\n", state->IsOwned() ? "true" : "false");
+ printf("In lockout: %s\n", state->IsInLockout() ? "true" : "false");
printf("Platform hierarchy enabled: %s\n",
state->IsPlatformHierarchyEnabled() ? "true" : "false");
printf("Storage hierarchy enabled: %s\n",
state->IsStorageHierarchyEnabled() ? "true" : "false");
printf("Endorsement hierarchy enabled: %s\n",
state->IsEndorsementHierarchyEnabled() ? "true" : "false");
- printf("Is Tpm enabled: %s\n",
- state->IsEnabled() ? "true" : "false");
+ printf("Is Tpm enabled: %s\n", state->IsEnabled() ? "true" : "false");
printf("Was shutdown orderly: %s\n",
state->WasShutdownOrderly() ? "true" : "false");
- printf("Is RSA supported: %s\n",
- state->IsRSASupported() ? "true" : "false");
- printf("Is ECC supported: %s\n",
- state->IsECCSupported() ? "true" : "false");
+ printf("Is RSA supported: %s\n", state->IsRSASupported() ? "true" : "false");
+ printf("Is ECC supported: %s\n", state->IsECCSupported() ? "true" : "false");
printf("Lockout Counter: %u\n", state->GetLockoutCounter());
printf("Lockout Threshold: %u\n", state->GetLockoutThreshold());
printf("Lockout Interval: %u\n", state->GetLockoutInterval());
@@ -132,10 +126,10 @@
} // namespace
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
base::CommandLine::Init(argc, argv);
brillo::InitLog(brillo::kLogToStderr);
- base::CommandLine *cl = base::CommandLine::ForCurrentProcess();
+ base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
if (cl->HasSwitch("help")) {
puts("Trunks Client: A command line tool to access the TPM.");
PrintUsage();
diff --git a/trunks/trunks_client_test.cc b/trunks/trunks_client_test.cc
index fc78b19..2c8611e 100644
--- a/trunks/trunks_client_test.cc
+++ b/trunks/trunks_client_test.cc
@@ -82,8 +82,8 @@
LOG(ERROR) << "Error stirring TPM RNG: " << GetErrorString(result);
return false;
}
- result = utility->GenerateRandom(num_bytes, session->GetDelegate(),
- &random_data);
+ result =
+ utility->GenerateRandom(num_bytes, session->GetDelegate(), &random_data);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error getting random bytes from TPM: "
<< GetErrorString(result);
@@ -121,9 +121,9 @@
ScopedKeyHandle scoped_key(*factory_.get(), signing_key);
session->SetEntityAuthorizationValue(key_authorization);
std::string signature;
- result = utility->Sign(signing_key, TPM_ALG_NULL, TPM_ALG_NULL,
- std::string(32, 'a'), session->GetDelegate(),
- &signature);
+ result =
+ utility->Sign(signing_key, TPM_ALG_NULL, TPM_ALG_NULL,
+ std::string(32, 'a'), session->GetDelegate(), &signature);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error using key to sign: " << GetErrorString(result);
return false;
@@ -160,8 +160,7 @@
LOG(ERROR) << "Error loading decrypt key: " << GetErrorString(result);
}
ScopedKeyHandle scoped_key(*factory_.get(), decrypt_key);
- return PerformRSAEncrpytAndDecrpyt(scoped_key.get(),
- key_authorization,
+ return PerformRSAEncrpytAndDecrpyt(scoped_key.get(), key_authorization,
session.get());
}
@@ -205,8 +204,8 @@
std::string key_authorization("new_pass");
std::string key_blob;
TPM_RC result = utility->CreateRSAKeyPair(
- TpmUtility::AsymmetricKeyUsage::kDecryptKey, 2048, 0x10001,
- "old_pass", "", false, // use_only_policy_authorization
+ TpmUtility::AsymmetricKeyUsage::kDecryptKey, 2048, 0x10001, "old_pass",
+ "", false, // use_only_policy_authorization
kNoCreationPCR, session->GetDelegate(), &key_blob, nullptr);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error creating change auth key: " << GetErrorString(result);
@@ -219,9 +218,8 @@
}
ScopedKeyHandle scoped_key(*factory_.get(), key_handle);
session->SetEntityAuthorizationValue("old_pass");
- result = utility->ChangeKeyAuthorizationData(key_handle, key_authorization,
- session->GetDelegate(),
- &key_blob);
+ result = utility->ChangeKeyAuthorizationData(
+ key_handle, key_authorization, session->GetDelegate(), &key_blob);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error changing auth data: " << GetErrorString(result);
return false;
@@ -248,8 +246,8 @@
std::string creation_blob;
session->SetEntityAuthorizationValue("");
TPM_RC result = utility->CreateRSAKeyPair(
- TpmUtility::AsymmetricKeyUsage::kDecryptKey, 2048, 0x10001,
- "", "", false, // use_only_policy_authorization
+ TpmUtility::AsymmetricKeyUsage::kDecryptKey, 2048, 0x10001, "", "",
+ false, // use_only_policy_authorization
kNoCreationPCR, session->GetDelegate(), &key_blob, &creation_blob);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error creating certify key: " << GetErrorString(result);
@@ -257,10 +255,9 @@
}
std::string alternate_key_blob;
result = utility->CreateRSAKeyPair(
- TpmUtility::AsymmetricKeyUsage::kDecryptKey, 2048, 0x10001,
- "", "", false, // use_only_policy_authorization
- kNoCreationPCR, session->GetDelegate(), &alternate_key_blob,
- nullptr);
+ TpmUtility::AsymmetricKeyUsage::kDecryptKey, 2048, 0x10001, "", "",
+ false, // use_only_policy_authorization
+ kNoCreationPCR, session->GetDelegate(), &alternate_key_blob, nullptr);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error creating alternate key: " << GetErrorString(result);
return false;
@@ -272,8 +269,7 @@
return false;
}
TPM_HANDLE alternate_key_handle;
- result = utility->LoadKey(alternate_key_blob,
- session->GetDelegate(),
+ result = utility->LoadKey(alternate_key_blob, session->GetDelegate(),
&alternate_key_handle);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error loading alternate key: " << GetErrorString(result);
@@ -303,8 +299,8 @@
}
int pcr_index = 5;
std::string policy_digest;
- TPM_RC result = utility->GetPolicyDigestForPcrValue(pcr_index, "",
- &policy_digest);
+ TPM_RC result =
+ utility->GetPolicyDigestForPcrValue(pcr_index, "", &policy_digest);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error getting policy_digest: " << GetErrorString(result);
return false;
@@ -477,10 +473,9 @@
return false;
}
std::string ciphertext;
- result = utility->AsymmetricEncrypt(scoped_key.get(), TPM_ALG_NULL,
- TPM_ALG_NULL, "plaintext",
- nullptr,
- &ciphertext);
+ result =
+ utility->AsymmetricEncrypt(scoped_key.get(), TPM_ALG_NULL, TPM_ALG_NULL,
+ "plaintext", nullptr, &ciphertext);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error encrypting using RSA key: " << GetErrorString(result);
return false;
@@ -493,10 +488,9 @@
}
std::string plaintext;
policy_session->SetEntityAuthorizationValue("password");
- result = utility->AsymmetricDecrypt(scoped_key.get(), TPM_ALG_NULL,
- TPM_ALG_NULL, ciphertext,
- policy_session->GetDelegate(),
- &plaintext);
+ result = utility->AsymmetricDecrypt(
+ scoped_key.get(), TPM_ALG_NULL, TPM_ALG_NULL, ciphertext,
+ policy_session->GetDelegate(), &plaintext);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error encrypting using RSA key: " << GetErrorString(result);
return false;
@@ -829,8 +823,8 @@
uint32_t index = 1;
session->SetEntityAuthorizationValue(owner_password);
std::string nv_data("nv_data");
- result = utility->DefineNVSpace(index, nv_data.size(),
- session->GetDelegate());
+ result =
+ utility->DefineNVSpace(index, nv_data.size(), session->GetDelegate());
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error defining nvram: " << GetErrorString(result);
return false;
@@ -843,8 +837,8 @@
}
std::string new_nvdata;
session->SetEntityAuthorizationValue("");
- result = utility->ReadNVSpace(index, 0, nv_data.size(),
- &new_nvdata, session->GetDelegate());
+ result = utility->ReadNVSpace(index, 0, nv_data.size(), &new_nvdata,
+ session->GetDelegate());
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error reading nvram: " << GetErrorString(result);
return false;
@@ -860,8 +854,8 @@
return false;
}
session->SetEntityAuthorizationValue("");
- result = utility->ReadNVSpace(index, 0, nv_data.size(),
- &new_nvdata, session->GetDelegate());
+ result = utility->ReadNVSpace(index, 0, nv_data.size(), &new_nvdata,
+ session->GetDelegate());
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error reading nvram: " << GetErrorString(result);
return false;
@@ -961,19 +955,18 @@
scoped_ptr<TpmUtility> utility = factory_->GetTpmUtility();
std::string ciphertext;
session->SetEntityAuthorizationValue("");
- TPM_RC result = utility->AsymmetricEncrypt(key_handle, TPM_ALG_NULL,
- TPM_ALG_NULL, "plaintext",
- session->GetDelegate(),
- &ciphertext);
+ TPM_RC result = utility->AsymmetricEncrypt(
+ key_handle, TPM_ALG_NULL, TPM_ALG_NULL, "plaintext",
+ session->GetDelegate(), &ciphertext);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error using key to encrypt: " << GetErrorString(result);
return false;
}
std::string plaintext;
session->SetEntityAuthorizationValue(key_authorization);
- result = utility->AsymmetricDecrypt(key_handle, TPM_ALG_NULL,
- TPM_ALG_NULL, ciphertext,
- session->GetDelegate(), &plaintext);
+ result = utility->AsymmetricDecrypt(key_handle, TPM_ALG_NULL, TPM_ALG_NULL,
+ ciphertext, session->GetDelegate(),
+ &plaintext);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Error using key to decrypt: " << GetErrorString(result);
return false;
@@ -1017,16 +1010,16 @@
const std::string& data,
const std::string& signature) {
auto asn1_ptr = reinterpret_cast<const unsigned char*>(public_key.data());
- crypto::ScopedRSA rsa(d2i_RSAPublicKey(nullptr, &asn1_ptr,
- public_key.size()));
+ crypto::ScopedRSA rsa(
+ d2i_RSAPublicKey(nullptr, &asn1_ptr, public_key.size()));
CHECK(rsa.get());
std::string digest = crypto::SHA256HashString(data);
auto digest_buffer = reinterpret_cast<const unsigned char*>(digest.data());
std::string mutable_signature(signature);
unsigned char* signature_buffer =
reinterpret_cast<unsigned char*>(string_as_array(&mutable_signature));
- return (RSA_verify(NID_sha256, digest_buffer, digest.size(),
- signature_buffer, signature.size(), rsa.get()) == 1);
+ return (RSA_verify(NID_sha256, digest_buffer, digest.size(), signature_buffer,
+ signature.size(), rsa.get()) == 1);
}
bool TrunksClientTest::LoadSigningKey(ScopedKeyHandle* key_handle,
@@ -1037,19 +1030,16 @@
std::string key_blob;
scoped_ptr<TpmUtility> utility = factory_->GetTpmUtility();
TPM_RC result = utility->ImportRSAKey(
- TpmUtility::AsymmetricKeyUsage::kSignKey,
- modulus, 0x10001, prime_factor,
+ TpmUtility::AsymmetricKeyUsage::kSignKey, modulus, 0x10001, prime_factor,
"", // password
- factory_->GetPasswordAuthorization("").get(),
- &key_blob);
+ factory_->GetPasswordAuthorization("").get(), &key_blob);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "ImportRSAKey: " << GetErrorString(result);
return false;
}
TPM_HANDLE raw_key_handle;
- result = utility->LoadKey(key_blob,
- factory_->GetPasswordAuthorization("").get(),
- &raw_key_handle);
+ result = utility->LoadKey(
+ key_blob, factory_->GetPasswordAuthorization("").get(), &raw_key_handle);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "LoadKey: " << GetErrorString(result);
return false;
@@ -1064,12 +1054,9 @@
std::string signature;
std::string data_to_sign("sign_this");
scoped_ptr<TpmUtility> utility = factory_->GetTpmUtility();
- TPM_RC result = utility->Sign(key_handle.get(),
- TPM_ALG_RSASSA,
- TPM_ALG_SHA256,
- data_to_sign,
- delegate,
- &signature);
+ TPM_RC result =
+ utility->Sign(key_handle.get(), TPM_ALG_RSASSA, TPM_ALG_SHA256,
+ data_to_sign, delegate, &signature);
if (result != TPM_RC_SUCCESS) {
LOG(ERROR) << "Sign: " << GetErrorString(result);
return false;
diff --git a/trunks/trunks_dbus_proxy.cc b/trunks/trunks_dbus_proxy.cc
index 9c2dfae..e6ce49f 100644
--- a/trunks/trunks_dbus_proxy.cc
+++ b/trunks/trunks_dbus_proxy.cc
@@ -49,14 +49,13 @@
options.bus_type = dbus::Bus::SYSTEM;
bus_ = new dbus::Bus(options);
object_proxy_ = bus_->GetObjectProxy(
- trunks::kTrunksServiceName,
- dbus::ObjectPath(trunks::kTrunksServicePath));
+ trunks::kTrunksServiceName, dbus::ObjectPath(trunks::kTrunksServicePath));
origin_thread_id_ = base::PlatformThread::CurrentId();
return (object_proxy_ != nullptr);
}
void TrunksDBusProxy::SendCommand(const std::string& command,
- const ResponseCallback& callback) {
+ const ResponseCallback& callback) {
if (origin_thread_id_ != base::PlatformThread::CurrentId()) {
LOG(ERROR) << "Error TrunksDBusProxy cannot be shared by multiple threads.";
callback.Run(CreateErrorResponse(TRUNKS_RC_IPC_ERROR));
@@ -72,12 +71,8 @@
callback.Run(response.response());
};
brillo::dbus_utils::CallMethodWithTimeout(
- kDBusMaxTimeout,
- object_proxy_,
- trunks::kTrunksInterface,
- trunks::kSendCommand,
- base::Bind(on_success),
- base::Bind(on_error),
+ kDBusMaxTimeout, object_proxy_, trunks::kTrunksInterface,
+ trunks::kSendCommand, base::Bind(on_success), base::Bind(on_error),
tpm_command_proto);
}
@@ -91,15 +86,12 @@
brillo::ErrorPtr error;
std::unique_ptr<dbus::Response> dbus_response =
brillo::dbus_utils::CallMethodAndBlockWithTimeout(
- kDBusMaxTimeout,
- object_proxy_,
- trunks::kTrunksInterface,
- trunks::kSendCommand,
- &error,
- tpm_command_proto);
+ kDBusMaxTimeout, object_proxy_, trunks::kTrunksInterface,
+ trunks::kSendCommand, &error, tpm_command_proto);
SendCommandResponse tpm_response_proto;
- if (dbus_response.get() && brillo::dbus_utils::ExtractMethodCallResults(
- dbus_response.get(), &error, &tpm_response_proto)) {
+ if (dbus_response.get() &&
+ brillo::dbus_utils::ExtractMethodCallResults(dbus_response.get(), &error,
+ &tpm_response_proto)) {
return tpm_response_proto.response();
} else {
LOG(ERROR) << "TrunksProxy could not parse response: "
@@ -108,5 +100,4 @@
}
}
-
} // namespace trunks
diff --git a/trunks/trunks_dbus_proxy.h b/trunks/trunks_dbus_proxy.h
index aa60e63..42385f2 100644
--- a/trunks/trunks_dbus_proxy.h
+++ b/trunks/trunks_dbus_proxy.h
@@ -33,7 +33,7 @@
// commands to the trunksd D-Bus daemon. See TrunksDBusService for details on
// how the commands are handled once they reach trunksd. A TrunksDBusProxy
// instance must be used in only one thread.
-class TRUNKS_EXPORT TrunksDBusProxy: public CommandTransceiver {
+class TRUNKS_EXPORT TrunksDBusProxy : public CommandTransceiver {
public:
TrunksDBusProxy();
~TrunksDBusProxy() override;
diff --git a/trunks/trunks_dbus_service.h b/trunks/trunks_dbus_service.h
index 5a7a697..3312cc8 100644
--- a/trunks/trunks_dbus_service.h
+++ b/trunks/trunks_dbus_service.h
@@ -56,10 +56,9 @@
private:
// Handles calls to the 'SendCommand' method.
- void HandleSendCommand(
- std::unique_ptr<brillo::dbus_utils::DBusMethodResponse<
- const SendCommandResponse&>> response_sender,
- const SendCommandRequest& request);
+ void HandleSendCommand(std::unique_ptr<brillo::dbus_utils::DBusMethodResponse<
+ const SendCommandResponse&>> response_sender,
+ const SendCommandRequest& request);
base::WeakPtr<TrunksDBusService> GetWeakPtr() {
return weak_factory_.GetWeakPtr();
@@ -75,5 +74,4 @@
} // namespace trunks
-
#endif // TRUNKS_TRUNKS_DBUS_SERVICE_H_
diff --git a/trunks/trunks_factory_for_test.cc b/trunks/trunks_factory_for_test.cc
index 6b73e64..2efcb98 100644
--- a/trunks/trunks_factory_for_test.cc
+++ b/trunks/trunks_factory_for_test.cc
@@ -44,13 +44,9 @@
explicit TpmStateForwarder(TpmState* target) : target_(target) {}
~TpmStateForwarder() override = default;
- TPM_RC Initialize() override {
- return target_->Initialize();
- }
+ TPM_RC Initialize() override { return target_->Initialize(); }
- bool IsOwnerPasswordSet() override {
- return target_->IsOwnerPasswordSet();
- }
+ bool IsOwnerPasswordSet() override { return target_->IsOwnerPasswordSet(); }
bool IsEndorsementPasswordSet() override {
return target_->IsEndorsementPasswordSet();
@@ -60,13 +56,9 @@
return target_->IsLockoutPasswordSet();
}
- bool IsOwned() override {
- return target_->IsOwned();
- }
+ bool IsOwned() override { return target_->IsOwned(); }
- bool IsInLockout() override {
- return target_->IsInLockout();
- }
+ bool IsInLockout() override { return target_->IsInLockout(); }
bool IsPlatformHierarchyEnabled() override {
return target_->IsPlatformHierarchyEnabled();
@@ -80,25 +72,15 @@
return target_->IsEndorsementHierarchyEnabled();
}
- bool IsEnabled() override {
- return target_->IsEnabled();
- }
+ bool IsEnabled() override { return target_->IsEnabled(); }
- bool WasShutdownOrderly() override {
- return target_->WasShutdownOrderly();
- }
+ bool WasShutdownOrderly() override { return target_->WasShutdownOrderly(); }
- bool IsRSASupported() override {
- return target_->IsRSASupported();
- }
+ bool IsRSASupported() override { return target_->IsRSASupported(); }
- bool IsECCSupported() override {
- return target_->IsECCSupported();
- }
+ bool IsECCSupported() override { return target_->IsECCSupported(); }
- uint32_t GetLockoutCounter() override {
- return target_->GetLockoutCounter();
- }
+ uint32_t GetLockoutCounter() override { return target_->GetLockoutCounter(); }
uint32_t GetLockoutThreshold() override {
return target_->GetLockoutThreshold();
@@ -122,21 +104,13 @@
explicit TpmUtilityForwarder(TpmUtility* target) : target_(target) {}
~TpmUtilityForwarder() override = default;
- TPM_RC Startup() override {
- return target_->Startup();
- }
+ TPM_RC Startup() override { return target_->Startup(); }
- TPM_RC Clear() override {
- return target_->Clear();
- }
+ TPM_RC Clear() override { return target_->Clear(); }
- void Shutdown() override {
- return target_->Shutdown();
- }
+ void Shutdown() override { return target_->Shutdown(); }
- TPM_RC InitializeTpm() override {
- return target_->InitializeTpm();
- }
+ TPM_RC InitializeTpm() override { return target_->InitializeTpm(); }
TPM_RC AllocatePCR(const std::string& platform_password) override {
return target_->AllocatePCR(platform_password);
@@ -145,8 +119,7 @@
TPM_RC TakeOwnership(const std::string& owner_password,
const std::string& endorsement_password,
const std::string& lockout_password) override {
- return target_->TakeOwnership(owner_password,
- endorsement_password,
+ return target_->TakeOwnership(owner_password, endorsement_password,
lockout_password);
}
@@ -177,12 +150,8 @@
const std::string& plaintext,
AuthorizationDelegate* delegate,
std::string* ciphertext) override {
- return target_->AsymmetricEncrypt(key_handle,
- scheme,
- hash_alg,
- plaintext,
- delegate,
- ciphertext);
+ return target_->AsymmetricEncrypt(key_handle, scheme, hash_alg, plaintext,
+ delegate, ciphertext);
}
TPM_RC AsymmetricDecrypt(TPM_HANDLE key_handle,
@@ -191,12 +160,8 @@
const std::string& ciphertext,
AuthorizationDelegate* delegate,
std::string* plaintext) override {
- return target_->AsymmetricDecrypt(key_handle,
- scheme,
- hash_alg,
- ciphertext,
- delegate,
- plaintext);
+ return target_->AsymmetricDecrypt(key_handle, scheme, hash_alg, ciphertext,
+ delegate, plaintext);
}
TPM_RC Sign(TPM_HANDLE key_handle,
@@ -205,11 +170,7 @@
const std::string& plaintext,
AuthorizationDelegate* delegate,
std::string* signature) override {
- return target_->Sign(key_handle,
- scheme,
- hash_alg,
- plaintext,
- delegate,
+ return target_->Sign(key_handle, scheme, hash_alg, plaintext, delegate,
signature);
}
@@ -219,8 +180,8 @@
const std::string& plaintext,
const std::string& signature,
AuthorizationDelegate* delegate) override {
- return target_->Verify(key_handle, scheme, hash_alg,
- plaintext, signature, delegate);
+ return target_->Verify(key_handle, scheme, hash_alg, plaintext, signature,
+ delegate);
}
TPM_RC CertifyCreation(TPM_HANDLE key_handle,
@@ -232,10 +193,8 @@
const std::string& new_password,
AuthorizationDelegate* delegate,
std::string* key_blob) override {
- return target_->ChangeKeyAuthorizationData(key_handle,
- new_password,
- delegate,
- key_blob);
+ return target_->ChangeKeyAuthorizationData(key_handle, new_password,
+ delegate, key_blob);
}
TPM_RC ImportRSAKey(AsymmetricKeyUsage key_type,
@@ -259,11 +218,10 @@
AuthorizationDelegate* delegate,
std::string* key_blob,
std::string* creation_blob) override {
- return target_->CreateRSAKeyPair(key_type, modulus_bits, public_exponent,
- password, policy_digest,
- use_only_policy_authorization,
- creation_pcr_index,
- delegate, key_blob, creation_blob);
+ return target_->CreateRSAKeyPair(
+ key_type, modulus_bits, public_exponent, password, policy_digest,
+ use_only_policy_authorization, creation_pcr_index, delegate, key_blob,
+ creation_blob);
}
TPM_RC LoadKey(const std::string& key_blob,
@@ -285,8 +243,8 @@
const std::string& policy_digest,
AuthorizationDelegate* delegate,
std::string* sealed_data) override {
- return target_->SealData(data_to_seal, policy_digest,
- delegate, sealed_data);
+ return target_->SealData(data_to_seal, policy_digest, delegate,
+ sealed_data);
}
TPM_RC UnsealData(const std::string& sealed_data,
@@ -317,8 +275,7 @@
return target_->DestroyNVSpace(index, delegate);
}
- TPM_RC LockNVSpace(uint32_t index,
- AuthorizationDelegate* delegate) override {
+ TPM_RC LockNVSpace(uint32_t index, AuthorizationDelegate* delegate) override {
return target_->LockNVSpace(index, delegate);
}
@@ -362,10 +319,8 @@
bool is_response_parameter_encryption_possible,
std::string* authorization) override {
return target_->GetCommandAuthorization(
- command_hash,
- is_command_parameter_encryption_possible,
- is_response_parameter_encryption_possible,
- authorization);
+ command_hash, is_command_parameter_encryption_possible,
+ is_response_parameter_encryption_possible, authorization);
}
bool CheckResponseAuthorization(const std::string& response_hash,
@@ -395,17 +350,16 @@
return target_->GetSessionHandle();
}
- void CloseSession() override {
- return target_->CloseSession();
- }
+ void CloseSession() override { return target_->CloseSession(); }
- TPM_RC StartSession(TPM_SE session_type, TPMI_DH_ENTITY bind_entity,
+ TPM_RC StartSession(TPM_SE session_type,
+ TPMI_DH_ENTITY bind_entity,
const std::string& bind_authorization_value,
bool enable_encryption,
HmacAuthorizationDelegate* delegate) override {
return target_->StartSession(session_type, bind_entity,
- bind_authorization_value,
- enable_encryption, delegate);
+ bind_authorization_value, enable_encryption,
+ delegate);
}
private:
@@ -415,7 +369,7 @@
// Forwards all calls to a target instance.
class HmacSessionForwarder : public HmacSession {
public:
- explicit HmacSessionForwarder(HmacSession* target): target_(target) {}
+ explicit HmacSessionForwarder(HmacSession* target) : target_(target) {}
~HmacSessionForwarder() override = default;
AuthorizationDelegate* GetDelegate() override {
@@ -425,8 +379,7 @@
TPM_RC StartBoundSession(TPMI_DH_ENTITY bind_entity,
const std::string& bind_authorization_value,
bool enable_encryption) override {
- return target_->StartBoundSession(bind_entity,
- bind_authorization_value,
+ return target_->StartBoundSession(bind_entity, bind_authorization_value,
enable_encryption);
}
@@ -446,11 +399,10 @@
HmacSession* target_;
};
-
// Forwards all calls to a target instance.
class PolicySessionForwarder : public PolicySession {
public:
- explicit PolicySessionForwarder(PolicySession* target): target_(target) {}
+ explicit PolicySessionForwarder(PolicySession* target) : target_(target) {}
~PolicySessionForwarder() override = default;
AuthorizationDelegate* GetDelegate() override {
@@ -460,8 +412,7 @@
TPM_RC StartBoundSession(TPMI_DH_ENTITY bind_entity,
const std::string& bind_authorization_value,
bool enable_encryption) override {
- return target_->StartBoundSession(bind_entity,
- bind_authorization_value,
+ return target_->StartBoundSession(bind_entity, bind_authorization_value,
enable_encryption);
}
@@ -485,9 +436,7 @@
return target_->PolicyCommandCode(command_code);
}
- TPM_RC PolicyAuthValue() override {
- return target_->PolicyAuthValue();
- }
+ TPM_RC PolicyAuthValue() override { return target_->PolicyAuthValue(); }
void SetEntityAuthorizationValue(const std::string& value) override {
return target_->SetEntityAuthorizationValue(value);
@@ -500,7 +449,7 @@
// Forwards all calls to a target instance.
class BlobParserForwarder : public BlobParser {
public:
- explicit BlobParserForwarder(BlobParser* target): target_(target) {}
+ explicit BlobParserForwarder(BlobParser* target) : target_(target) {}
~BlobParserForwarder() override = default;
bool SerializeKeyBlob(const TPM2B_PUBLIC& public_info,
@@ -551,8 +500,7 @@
default_policy_session_(new NiceMock<MockPolicySession>()),
policy_session_(default_policy_session_.get()),
default_blob_parser_(new NiceMock<MockBlobParser>()),
- blob_parser_(default_blob_parser_.get()) {
-}
+ blob_parser_(default_blob_parser_.get()) {}
TrunksFactoryForTest::~TrunksFactoryForTest() {}
@@ -569,8 +517,8 @@
}
scoped_ptr<AuthorizationDelegate>
- TrunksFactoryForTest::GetPasswordAuthorization(
- const std::string& password) const {
+TrunksFactoryForTest::GetPasswordAuthorization(
+ const std::string& password) const {
return scoped_ptr<AuthorizationDelegate>(
new AuthorizationDelegateForwarder(password_authorization_delegate_));
}
diff --git a/trunks/trunks_factory_for_test.h b/trunks/trunks_factory_for_test.h
index 190326e..447e212 100644
--- a/trunks/trunks_factory_for_test.h
+++ b/trunks/trunks_factory_for_test.h
@@ -73,17 +73,11 @@
scoped_ptr<BlobParser> GetBlobParser() const override;
// Mutators to inject custom mocks.
- void set_tpm(Tpm* tpm) {
- tpm_ = tpm;
- }
+ void set_tpm(Tpm* tpm) { tpm_ = tpm; }
- void set_tpm_state(TpmState* tpm_state) {
- tpm_state_ = tpm_state;
- }
+ void set_tpm_state(TpmState* tpm_state) { tpm_state_ = tpm_state; }
- void set_tpm_utility(TpmUtility* tpm_utility) {
- tpm_utility_ = tpm_utility;
- }
+ void set_tpm_utility(TpmUtility* tpm_utility) { tpm_utility_ = tpm_utility; }
void set_password_authorization_delegate(AuthorizationDelegate* delegate) {
password_authorization_delegate_ = delegate;
@@ -101,9 +95,7 @@
policy_session_ = policy_session;
}
- void set_blob_parser(BlobParser* blob_parser) {
- blob_parser_ = blob_parser;
- }
+ void set_blob_parser(BlobParser* blob_parser) { blob_parser_ = blob_parser; }
private:
scoped_ptr<MockTpm> default_tpm_;
diff --git a/trunks/trunks_ftdi_spi.cc b/trunks/trunks_ftdi_spi.cc
index 8a6de59..4272c4e 100644
--- a/trunks/trunks_ftdi_spi.cc
+++ b/trunks/trunks_ftdi_spi.cc
@@ -25,11 +25,11 @@
#include "trunks/trunks_ftdi_spi.h"
// Assorted TPM2 registers for interface type FIFO.
-#define TPM_ACCESS_REG 0
-#define TPM_STS_REG 0x18
+#define TPM_ACCESS_REG 0
+#define TPM_STS_REG 0x18
#define TPM_DATA_FIFO_REG 0x24
-#define TPM_DID_VID_REG 0xf00
-#define TPM_RID_REG 0xf04
+#define TPM_DID_VID_REG 0xf00
+#define TPM_RID_REG 0xf04
namespace trunks {
@@ -48,7 +48,7 @@
resetEstablishmentBit = (1 << 25),
commandCancel = (1 << 24),
burstCountShift = 8,
- burstCountMask = ((1 << 16) -1), // 16 bits wide
+ burstCountMask = ((1 << 16) - 1), // 16 bits wide
stsValid = (1 << 7),
commandReady = (1 << 6),
tpmGo = (1 << 5),
@@ -58,9 +58,9 @@
responseRetry = (1 << 1),
};
- // SPI frame header for TPM transactions is 4 bytes in size, it is described
- // in section "6.4.6 Spi Bit Protocol" of the TCG issued "TPM Profile (PTP)
- // Specification Revision 00.43.
+// SPI frame header for TPM transactions is 4 bytes in size, it is described
+// in section "6.4.6 Spi Bit Protocol" of the TCG issued "TPM Profile (PTP)
+// Specification Revision 00.43.
struct SpiFrameHeader {
unsigned char body[4];
};
@@ -72,7 +72,7 @@
mpsse_ = NULL;
}
-bool TrunksFtdiSpi::ReadTpmSts(uint32_t *status) {
+bool TrunksFtdiSpi::ReadTpmSts(uint32_t* status) {
return FtdiReadReg(TPM_STS_REG, sizeof(*status), status);
}
@@ -81,8 +81,9 @@
}
void TrunksFtdiSpi::StartTransaction(bool read_write,
- size_t bytes, unsigned addr) {
- unsigned char *response;
+ size_t bytes,
+ unsigned addr) {
+ unsigned char* response;
SpiFrameHeader header;
usleep(10000); // give it 10 ms. TODO(vbendeb): remove this once
@@ -111,7 +112,7 @@
// until the last bit in the received byte (transferred during the last
// clock of the byte) is set to 1.
while (!(response[3] & 1)) {
- unsigned char *poll_state;
+ unsigned char* poll_state;
poll_state = Read(mpsse_, 1);
response[3] = *poll_state;
@@ -120,8 +121,9 @@
free(response);
}
-bool TrunksFtdiSpi::FtdiWriteReg(unsigned reg_number, size_t bytes,
- const void *buffer) {
+bool TrunksFtdiSpi::FtdiWriteReg(unsigned reg_number,
+ size_t bytes,
+ const void* buffer) {
if (!mpsse_)
return false;
@@ -131,9 +133,10 @@
return true;
}
-bool TrunksFtdiSpi::FtdiReadReg(unsigned reg_number, size_t bytes,
- void *buffer) {
- unsigned char *value;
+bool TrunksFtdiSpi::FtdiReadReg(unsigned reg_number,
+ size_t bytes,
+ void* buffer) {
+ unsigned char* value;
if (!mpsse_)
return false;
@@ -188,7 +191,7 @@
cmd = requestUse;
FtdiWriteReg(TPM_ACCESS_REG, sizeof(cmd), &cmd);
FtdiReadReg(TPM_ACCESS_REG, sizeof(cmd), &cmd);
- if ((cmd & ~tpmEstablishment) != (tpmRegValidSts | activeLocality)) {
+ if ((cmd & ~tpmEstablishment) != (tpmRegValidSts | activeLocality)) {
LOG(ERROR) << "failed to claim locality, status: 0x" << std::hex
<< (unsigned)cmd;
return false;
@@ -213,7 +216,8 @@
}
bool TrunksFtdiSpi::WaitForStatus(uint32_t statusMask,
- uint32_t statusExpected, int timeout_ms) {
+ uint32_t statusExpected,
+ int timeout_ms) {
uint32_t status;
time_t target_time;
@@ -249,9 +253,8 @@
// the minimum of the two values - burst_count and 64 (which is the protocol
// limitation)
do {
- transaction_size = std::min(std::min(command.size() - handled_so_far,
- GetBurstCount()),
- (size_t)64);
+ transaction_size = std::min(
+ std::min(command.size() - handled_so_far, GetBurstCount()), (size_t)64);
if (transaction_size) {
LOG(INFO) << "will transfer " << transaction_size << " bytes";
@@ -266,7 +269,7 @@
expected_status_bits = stsValid | dataAvail;
if (!WaitForStatus(expected_status_bits, expected_status_bits))
- return rv;
+ return rv;
// The response is ready, let's read it.
// First we read the FIFO payload header, to see how much data to expect.
@@ -292,18 +295,16 @@
LOG(INFO) << "Total payload size " << payload_size;
-
// Let's read all but the last byte in the FIFO to make sure the status
// register is showing correct flow control bits: 'more data' until the last
// byte and then 'no more data' once the last byte is read.
handled_so_far = 0;
payload_size = payload_size - sizeof(data_header) - 1;
// Allow room for the last byte too.
- uint8_t *payload = new uint8_t[payload_size + 1];
+ uint8_t* payload = new uint8_t[payload_size + 1];
do {
- transaction_size = std::min(std::min(payload_size - handled_so_far,
- GetBurstCount()),
- (size_t)64);
+ transaction_size = std::min(
+ std::min(payload_size - handled_so_far, GetBurstCount()), (size_t)64);
if (transaction_size) {
FtdiReadReg(TPM_DATA_FIFO_REG, transaction_size,
@@ -332,7 +333,7 @@
}
rv = std::string(data_header, sizeof(data_header)) +
- std::string(reinterpret_cast<char *>(payload), payload_size + 1);
+ std::string(reinterpret_cast<char*>(payload), payload_size + 1);
/* Move the TPM back to idle state. */
WriteTpmSts(commandReady);
diff --git a/trunks/trunks_ftdi_spi.h b/trunks/trunks_ftdi_spi.h
index de78f93..73de0df 100644
--- a/trunks/trunks_ftdi_spi.h
+++ b/trunks/trunks_ftdi_spi.h
@@ -32,7 +32,7 @@
// TrunksFtdiSpi is a CommandTransceiver implementation that forwards all
// commands to the SPI over FTDI interface directly to a TPM chip.
-class TRUNKS_EXPORT TrunksFtdiSpi: public CommandTransceiver {
+class TRUNKS_EXPORT TrunksFtdiSpi : public CommandTransceiver {
public:
TrunksFtdiSpi() : mpsse_(NULL), locality_(0) {}
~TrunksFtdiSpi() override;
@@ -45,16 +45,14 @@
private:
struct mpsse_context* mpsse_;
- unsigned locality_; // Set at initialization.
+ unsigned locality_; // Set at initialization.
// Read a TPM register into the passed in buffer, where 'bytes' the width of
// the register. Return true on success, false on failure.
- bool FtdiReadReg(unsigned reg_number, size_t bytes,
- void *buffer);
+ bool FtdiReadReg(unsigned reg_number, size_t bytes, void* buffer);
// Write a TPM register from the passed in buffer, where 'bytes' the width of
// the register. Return true on success, false on failure.
- bool FtdiWriteReg(unsigned reg_number, size_t bytes,
- const void *buffer);
+ bool FtdiWriteReg(unsigned reg_number, size_t bytes, const void* buffer);
// Generate a proper SPI frame for read/write transaction, read_write set to
// true for read transactions, the size of the transaction is passed as
// 'bytes', addr is the internal TPM address space address (accounting for
@@ -65,12 +63,13 @@
void StartTransaction(bool read_write, size_t bytes, unsigned addr);
// TPM Status Register is going to be accessed a lot, let's have dedicated
// accessors for it,
- bool ReadTpmSts(uint32_t *status);
+ bool ReadTpmSts(uint32_t* status);
bool WriteTpmSts(uint32_t status);
// Poll status register until the required value is read or the timeout
// expires.
bool WaitForStatus(uint32_t statusMask,
- uint32_t statusExpected, int timeout_ms = 10000);
+ uint32_t statusExpected,
+ int timeout_ms = 10000);
// Retrieve current value of the burst count field.
size_t GetBurstCount(void);
@@ -85,7 +84,7 @@
// A plug to support compilations on platforms where FTDI SPI interface is not
// available.
-class TRUNKS_EXPORT TrunksFtdiSpi: public CommandTransceiver {
+class TRUNKS_EXPORT TrunksFtdiSpi : public CommandTransceiver {
public:
TrunksFtdiSpi() {}
~TrunksFtdiSpi() {}
@@ -94,7 +93,8 @@
void SendCommand(const std::string& command,
const ResponseCallback& callback) {}
std::string SendCommandAndWait(const std::string& command) {
- return std::string(""); }
+ return std::string("");
+ }
};
} // namespace trunks
diff --git a/trunks/trunks_testrunner.cc b/trunks/trunks_testrunner.cc
index 9cbc9f9..b20f957 100644
--- a/trunks/trunks_testrunner.cc
+++ b/trunks/trunks_testrunner.cc
@@ -20,7 +20,7 @@
#include <brillo/syslog_logging.h>
#include <gtest/gtest.h>
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
base::CommandLine::Init(argc, argv);
brillo::InitLog(brillo::kLogToStderr);
// Enable verbose logging while running unit tests.
diff --git a/trunks/trunksd.cc b/trunks/trunksd.cc
index 7c7f5cf..12cef73 100644
--- a/trunks/trunksd.cc
+++ b/trunks/trunksd.cc
@@ -69,17 +69,17 @@
} // namespace
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
base::CommandLine::Init(argc, argv);
- base::CommandLine *cl = base::CommandLine::ForCurrentProcess();
+ base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
int flags = brillo::kLogToSyslog;
if (cl->HasSwitch("log_to_stderr")) {
flags |= brillo::kLogToStderr;
}
brillo::InitLog(flags);
- // Create a service instance before anything else so objects like
- // AtExitManager exist.
+// Create a service instance before anything else so objects like
+// AtExitManager exist.
#if defined(USE_BINDER_IPC)
trunks::TrunksBinderService service;
#else
@@ -91,7 +91,7 @@
// --> ResourceManager
// --> TpmHandle
// --> [TPM]
- trunks::CommandTransceiver *low_level_transceiver;
+ trunks::CommandTransceiver* low_level_transceiver;
if (cl->HasSwitch("ftdi")) {
LOG(INFO) << "Sending commands to FTDI SPI.";
low_level_transceiver = new trunks::TrunksFtdiSpi();