summaryrefslogtreecommitdiff
path: root/security/keymint/aidl/vts/functional/KeyMintTest.cpp
diff options
context:
space:
mode:
authorDavid Drysdale <drysdale@google.com>2022-05-09 16:44:13 +0100
committerDavid Drysdale <drysdale@google.com>2022-05-09 17:47:11 +0100
commit857158ba122d565f6dcdfe8df87e8db72e6c5dcd (patch)
treef2c7dd8ecfe228b7559dba93d3112cc3176e1c2b /security/keymint/aidl/vts/functional/KeyMintTest.cpp
parent955b77be576ebe34b97e37dbe940d967a07aa3b3 (diff)
KeyMint VTS: x25519 pubkey as SubjectPublicKeyInfo
The data for a key agreement operation should always send in the SubjectPublicKeyInfo structure, not a raw key for X25519. Test: VtsAidlKeyMintTargetTest Bug: 231959070 Change-Id: Ib5157da6a986d957162fab60dbe927017cfdd703 Merged-In: Ib5157da6a986d957162fab60dbe927017cfdd703
Diffstat (limited to 'security/keymint/aidl/vts/functional/KeyMintTest.cpp')
-rw-r--r--security/keymint/aidl/vts/functional/KeyMintTest.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/security/keymint/aidl/vts/functional/KeyMintTest.cpp b/security/keymint/aidl/vts/functional/KeyMintTest.cpp
index 7950850f91..3c2bece4af 100644
--- a/security/keymint/aidl/vts/functional/KeyMintTest.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintTest.cpp
@@ -7525,7 +7525,6 @@ class KeyAgreementTest : public KeyMintAidlTestBase {
uint8_t privKeyData[32];
uint8_t pubKeyData[32];
X25519_keypair(pubKeyData, privKeyData);
- *localPublicKey = vector<uint8_t>(pubKeyData, pubKeyData + 32);
*localPrivKey = EVP_PKEY_Ptr(EVP_PKEY_new_raw_private_key(
EVP_PKEY_X25519, nullptr, privKeyData, sizeof(privKeyData)));
} else {
@@ -7537,16 +7536,15 @@ class KeyAgreementTest : public KeyMintAidlTestBase {
ASSERT_EQ(EC_KEY_generate_key(ecKey.get()), 1);
*localPrivKey = EVP_PKEY_Ptr(EVP_PKEY_new());
ASSERT_EQ(EVP_PKEY_set1_EC_KEY(localPrivKey->get(), ecKey.get()), 1);
-
- // Get encoded form of the public part of the locally generated key...
- unsigned char* p = nullptr;
- int localPublicKeySize = i2d_PUBKEY(localPrivKey->get(), &p);
- ASSERT_GT(localPublicKeySize, 0);
- *localPublicKey =
- vector<uint8_t>(reinterpret_cast<const uint8_t*>(p),
- reinterpret_cast<const uint8_t*>(p + localPublicKeySize));
- OPENSSL_free(p);
}
+
+ // Get encoded form of the public part of the locally generated key...
+ unsigned char* p = nullptr;
+ int localPublicKeySize = i2d_PUBKEY(localPrivKey->get(), &p);
+ ASSERT_GT(localPublicKeySize, 0);
+ *localPublicKey = vector<uint8_t>(reinterpret_cast<const uint8_t*>(p),
+ reinterpret_cast<const uint8_t*>(p + localPublicKeySize));
+ OPENSSL_free(p);
}
void GenerateKeyMintEcKey(EcCurve curve, EVP_PKEY_Ptr* kmPubKey) {
@@ -7641,6 +7639,9 @@ TEST_P(KeyAgreementTest, Ecdh) {
//
for (auto curve : ValidCurves()) {
for (auto localCurve : ValidCurves()) {
+ SCOPED_TRACE(testing::Message()
+ << "local-curve-" << localCurve << "-keymint-curve-" << curve);
+
// Generate EC key locally (with access to private key material)
EVP_PKEY_Ptr localPrivKey;
vector<uint8_t> localPublicKey;