From 32438938926626a0e47579043e50bfe698fe0e82 Mon Sep 17 00:00:00 2001 From: Austin Hsieh <77706079+austinh0@users.noreply.github.com> Date: Tue, 8 Feb 2022 08:11:01 -0800 Subject: [PATCH] Set key length in example issuer to value length (#14869) --- src/controller/ExampleOperationalCredentialsIssuer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/controller/ExampleOperationalCredentialsIssuer.cpp b/src/controller/ExampleOperationalCredentialsIssuer.cpp index 3d2530ddc3f61e..ff94a229009d1f 100644 --- a/src/controller/ExampleOperationalCredentialsIssuer.cpp +++ b/src/controller/ExampleOperationalCredentialsIssuer.cpp @@ -56,9 +56,11 @@ CHIP_ERROR ExampleOperationalCredentialsIssuer::Initialize(PersistentStorageDele PERSISTENT_KEY_OP(mIndex, kOperationalCredentialsIssuerKeypairStorage, key, err = storage.SyncGetKeyValue(key, &serializedKey, keySize)); + serializedKey.SetLength(keySize); if (err != CHIP_NO_ERROR) { + ChipLogProgress(Controller, "Couldn't get %s from storage: %s", kOperationalCredentialsIssuerKeypairStorage, ErrorStr(err)); // Storage doesn't have an existing keypair. Let's create one and add it to the storage. ReturnErrorOnFailure(mIssuer.Initialize()); ReturnErrorOnFailure(mIssuer.Serialize(serializedKey)); @@ -78,9 +80,12 @@ CHIP_ERROR ExampleOperationalCredentialsIssuer::Initialize(PersistentStorageDele PERSISTENT_KEY_OP(mIndex, kOperationalCredentialsIntermediateIssuerKeypairStorage, key, err = storage.SyncGetKeyValue(key, &serializedKey, keySize)); + serializedKey.SetLength(keySize); if (err != CHIP_NO_ERROR) { + ChipLogProgress(Controller, "Couldn't get %s from storage: %s", kOperationalCredentialsIntermediateIssuerKeypairStorage, + ErrorStr(err)); // Storage doesn't have an existing keypair. Let's create one and add it to the storage. ReturnErrorOnFailure(mIntermediateIssuer.Initialize()); ReturnErrorOnFailure(mIntermediateIssuer.Serialize(serializedKey));