From b50ff7c4ed64b000d97db419ee0296bf2b50db33 Mon Sep 17 00:00:00 2001 From: Austin Hsieh Date: Tue, 8 Feb 2022 12:02:04 -0800 Subject: [PATCH] Use keypair capacity and bytes --- .../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 {