From 64d3ad761b53cf83224fd2f4ec623883055f109a Mon Sep 17 00:00:00 2001 From: Austin Hsieh <77706079+austinh0@users.noreply.github.com> Date: Tue, 8 Feb 2022 13:30:54 -0800 Subject: [PATCH] Use keypair capacity and bytes (#14908) --- .../ExampleOperationalCredentialsIssuer.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/controller/ExampleOperationalCredentialsIssuer.cpp b/src/controller/ExampleOperationalCredentialsIssuer.cpp index ff94a229009d1f..19db629fb5c803 100644 --- a/src/controller/ExampleOperationalCredentialsIssuer.cpp +++ b/src/controller/ExampleOperationalCredentialsIssuer.cpp @@ -52,10 +52,10 @@ CHIP_ERROR ExampleOperationalCredentialsIssuer::Initialize(PersistentStorageDele ReturnErrorOnFailure(ASN1ToChipEpochTime(effectiveTime, mNow)); Crypto::P256SerializedKeypair serializedKey; - uint16_t keySize = static_cast(sizeof(serializedKey)); + uint16_t keySize = static_cast(serializedKey.Capacity()); PERSISTENT_KEY_OP(mIndex, kOperationalCredentialsIssuerKeypairStorage, key, - err = storage.SyncGetKeyValue(key, &serializedKey, keySize)); + err = storage.SyncGetKeyValue(key, serializedKey.Bytes(), keySize)); serializedKey.SetLength(keySize); if (err != CHIP_NO_ERROR) @@ -65,10 +65,10 @@ CHIP_ERROR ExampleOperationalCredentialsIssuer::Initialize(PersistentStorageDele ReturnErrorOnFailure(mIssuer.Initialize()); ReturnErrorOnFailure(mIssuer.Serialize(serializedKey)); - keySize = static_cast(sizeof(serializedKey)); + keySize = static_cast(serializedKey.Capacity()); PERSISTENT_KEY_OP(mIndex, kOperationalCredentialsIssuerKeypairStorage, key, - ReturnErrorOnFailure(storage.SyncSetKeyValue(key, &serializedKey, keySize))); + ReturnErrorOnFailure(storage.SyncSetKeyValue(key, serializedKey.Bytes(), keySize))); } else { @@ -76,10 +76,10 @@ CHIP_ERROR ExampleOperationalCredentialsIssuer::Initialize(PersistentStorageDele ReturnErrorOnFailure(mIssuer.Deserialize(serializedKey)); } - keySize = static_cast(sizeof(serializedKey)); + keySize = static_cast(serializedKey.Capacity()); PERSISTENT_KEY_OP(mIndex, kOperationalCredentialsIntermediateIssuerKeypairStorage, key, - err = storage.SyncGetKeyValue(key, &serializedKey, keySize)); + err = storage.SyncGetKeyValue(key, serializedKey.Bytes(), keySize)); serializedKey.SetLength(keySize); if (err != CHIP_NO_ERROR) @@ -90,10 +90,10 @@ CHIP_ERROR ExampleOperationalCredentialsIssuer::Initialize(PersistentStorageDele ReturnErrorOnFailure(mIntermediateIssuer.Initialize()); ReturnErrorOnFailure(mIntermediateIssuer.Serialize(serializedKey)); - keySize = static_cast(sizeof(serializedKey)); + keySize = static_cast(serializedKey.Capacity()); PERSISTENT_KEY_OP(mIndex, kOperationalCredentialsIntermediateIssuerKeypairStorage, key, - ReturnErrorOnFailure(storage.SyncSetKeyValue(key, &serializedKey, keySize))); + ReturnErrorOnFailure(storage.SyncSetKeyValue(key, serializedKey.Bytes(), keySize))); } else {