diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-03-26 03:08:22 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-03-26 03:08:22 +0000 |
commit | e552504dd9dce4a9a8392e44dc300d33be0362c7 (patch) | |
tree | 8e6a5b79ccdd0ab5e1dbd78b4eeba2429f70dbf1 /security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp | |
parent | b2189c910d98d00088aa3eb207140d906b4b44fd (diff) | |
parent | 89345a4d7da9c6a7b7ae43b4a2aedd3c0354ffff (diff) |
Snap for 8362632 from 89345a4d7da9c6a7b7ae43b4a2aedd3c0354ffff to tm-release
Change-Id: I7b97265d96a8dc51053441f092f226bdbf4f99bf
Diffstat (limited to 'security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp')
-rw-r--r-- | security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp index 4ab989bcbc..f9510d3071 100644 --- a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp +++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp @@ -312,6 +312,30 @@ ErrorCode KeyMintAidlTestBase::GenerateKey(const AuthorizationSet& key_desc, return GenerateKey(key_desc, attest_key, &key_blob_, &key_characteristics_, &cert_chain_); } +ErrorCode KeyMintAidlTestBase::GenerateKeyWithSelfSignedAttestKey( + const AuthorizationSet& attest_key_desc, const AuthorizationSet& key_desc, + vector<uint8_t>* key_blob, vector<KeyCharacteristics>* key_characteristics, + vector<Certificate>* cert_chain) { + AttestationKey attest_key; + vector<Certificate> attest_cert_chain; + vector<KeyCharacteristics> attest_key_characteristics; + // Generate a key with self signed attestation. + auto error = GenerateKey(attest_key_desc, std::nullopt, &attest_key.keyBlob, + &attest_key_characteristics, &attest_cert_chain); + if (error != ErrorCode::OK) { + return error; + } + + attest_key.issuerSubjectName = make_name_from_str("Android Keystore Key"); + // Generate a key, by passing the above self signed attestation key as attest key. + error = GenerateKey(key_desc, attest_key, key_blob, key_characteristics, cert_chain); + if (error == ErrorCode::OK) { + // Append the attest_cert_chain to the attested cert_chain to yield a valid cert chain. + cert_chain->push_back(attest_cert_chain[0]); + } + return error; +} + ErrorCode KeyMintAidlTestBase::ImportKey(const AuthorizationSet& key_desc, KeyFormat format, const string& key_material, vector<uint8_t>* key_blob, vector<KeyCharacteristics>* key_characteristics) { |