Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
fix the Attestation related CTS failed issue
Browse files Browse the repository at this point in the history
the below cases previous failed is due to we didn't implemented
the related API(GenerateAttestation), now we uncomment it due to
the depends on the AOSP part has been updated.

test:
testEcAttestation
testRsaAttestation

Change-Id: If0b7776cdc330233520b9111f3c6e7f557ad7985
Signed-off-by: Yan, Shaopu <[email protected]>
  • Loading branch information
syan10 authored and rogerxfeng8 committed Nov 13, 2018
1 parent 08996a1 commit 7ba3d68
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 330 deletions.
198 changes: 0 additions & 198 deletions override/hmac_operation.cpp

This file was deleted.

76 changes: 0 additions & 76 deletions override/hmac_operation.h

This file was deleted.

3 changes: 2 additions & 1 deletion rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ MODULE_SRCS += \
$(KEYMASTER_ROOT)/km_openssl/ec_key_factory.cpp \
$(KEYMASTER_ROOT)/km_openssl/ecdsa_operation.cpp \
$(KEYMASTER_ROOT)/km_openssl/hmac_key.cpp \
$(LOCAL_DIR)/override/hmac_operation.cpp \
$(KEYMASTER_ROOT)/km_openssl/attestation_utils.cpp \
$(KEYMASTER_ROOT)/km_openssl/hmac_operation.cpp \
$(KEYMASTER_ROOT)/android_keymaster/keymaster_enforcement.cpp \
$(KEYMASTER_ROOT)/android_keymaster/logger.cpp \
$(KEYMASTER_ROOT)/key_blob_utils/ocb.c \
Expand Down
64 changes: 17 additions & 47 deletions trusty_keymaster_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,60 +522,29 @@ TrustyKeymasterContext::GetVerifiedBootParams(keymaster_blob_t* verified_boot_ke
return KM_ERROR_OK;
}

const keymaster_key_blob_t* TrustyKeymasterContext::getAttestationKey(keymaster_algorithm_t algorithm,
keymaster_error_t* error) const{
KeymasterKeyBlob getAttestationKey(keymaster_algorithm_t algorithm,
keymaster_error_t* error) {

uint8_t* key = nullptr;
uint32_t key_size = 0;
UniquePtr<uint8_t[]> key_deleter;

#if 0
int evp_key_type;
switch (algorithm) {
case KM_ALGORITHM_RSA:
evp_key_type = EVP_PKEY_RSA;
break;

case KM_ALGORITHM_EC:
evp_key_type = EVP_PKEY_EC;
break;

default:
*error = KM_ERROR_UNSUPPORTED_ALGORITHM;
return nullptr;
}
#endif

*error = ReadKeyFromStorage(algorithm, &key, &key_size);
if (*error == KM_ERROR_OK) {
key_deleter.reset(key);
} else {
if (*error != KM_ERROR_OK) {
LOG_E("Failed to read attestation key from RPMB, falling back to test key", 0);
*error = GetSoftwareAttestationKey(algorithm, &key, &key_size);
if (*error != KM_ERROR_OK)
return {};
}

if (*error != KM_ERROR_OK)
return nullptr;
#if 0
const uint8_t* const_key = key;

EVP_PKEY* pkey = d2i_PrivateKey(evp_key_type, nullptr, &const_key, key_size);
if (!pkey)
*error = TranslateLastOpenSslError();

return pkey;
#endif
static const keymaster_key_blob_t AttestKeyBlob = {
(const uint8_t*)key, key_size
};

return &AttestKeyBlob;
auto result = KeymasterKeyBlob(key, key_size);
if (!result.key_material)
*error = KM_ERROR_MEMORY_ALLOCATION_FAILED;
return result;
}

keymaster_cert_chain_t* TrustyKeymasterContext::getAttestationChain(keymaster_algorithm_t algorithm,
keymaster_error_t* error) const{
CertChainPtr getAttestationChain(keymaster_algorithm_t algorithm,
keymaster_error_t* error) {

UniquePtr<keymaster_cert_chain_t, CertificateChainDelete> chain(new keymaster_cert_chain_t);
CertChainPtr chain(new keymaster_cert_chain_t);
if (!chain.get()) {
*error = KM_ERROR_MEMORY_ALLOCATION_FAILED;
return nullptr;
Expand All @@ -594,9 +563,9 @@ keymaster_cert_chain_t* TrustyKeymasterContext::getAttestationChain(keymaster_al

if (*error != KM_ERROR_OK)
return nullptr;
return chain.release();
return chain;
}
#if 0

keymaster_error_t TrustyKeymasterContext::GenerateAttestation(const Key& key,
const AuthorizationSet& attest_params, CertChainPtr* cert_chain) const {

Expand All @@ -620,9 +589,10 @@ keymaster_error_t TrustyKeymasterContext::GenerateAttestation(const Key& key,
if (error != KM_ERROR_OK) return error;

return generate_attestation(asymmetric_key, attest_params,
*attestation_chain, *attestation_key, *this, cert_chain);
*attestation_chain, attestation_key, *this,
cert_chain);
}
#endif

keymaster_error_t TrustyKeymasterContext::SetBootParams(
uint32_t os_version, uint32_t os_patchlevel, const Buffer& verified_boot_key,
keymaster_verified_boot_t verified_boot_state, bool device_locked) {
Expand Down
Loading

0 comments on commit 7ba3d68

Please sign in to comment.