Skip to content

Commit

Permalink
Use keypair capacity and bytes (project-chip#14908)
Browse files Browse the repository at this point in the history
  • Loading branch information
austinh0 authored Feb 8, 2022
1 parent 02f7dab commit 64d3ad7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/controller/ExampleOperationalCredentialsIssuer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ CHIP_ERROR ExampleOperationalCredentialsIssuer::Initialize(PersistentStorageDele
ReturnErrorOnFailure(ASN1ToChipEpochTime(effectiveTime, mNow));

Crypto::P256SerializedKeypair serializedKey;
uint16_t keySize = static_cast<uint16_t>(sizeof(serializedKey));
uint16_t keySize = static_cast<uint16_t>(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)
Expand All @@ -65,21 +65,21 @@ CHIP_ERROR ExampleOperationalCredentialsIssuer::Initialize(PersistentStorageDele
ReturnErrorOnFailure(mIssuer.Initialize());
ReturnErrorOnFailure(mIssuer.Serialize(serializedKey));

keySize = static_cast<uint16_t>(sizeof(serializedKey));
keySize = static_cast<uint16_t>(serializedKey.Capacity());

PERSISTENT_KEY_OP(mIndex, kOperationalCredentialsIssuerKeypairStorage, key,
ReturnErrorOnFailure(storage.SyncSetKeyValue(key, &serializedKey, keySize)));
ReturnErrorOnFailure(storage.SyncSetKeyValue(key, serializedKey.Bytes(), keySize)));
}
else
{
// Use the keypair from the storage
ReturnErrorOnFailure(mIssuer.Deserialize(serializedKey));
}

keySize = static_cast<uint16_t>(sizeof(serializedKey));
keySize = static_cast<uint16_t>(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)
Expand All @@ -90,10 +90,10 @@ CHIP_ERROR ExampleOperationalCredentialsIssuer::Initialize(PersistentStorageDele
ReturnErrorOnFailure(mIntermediateIssuer.Initialize());
ReturnErrorOnFailure(mIntermediateIssuer.Serialize(serializedKey));

keySize = static_cast<uint16_t>(sizeof(serializedKey));
keySize = static_cast<uint16_t>(serializedKey.Capacity());

PERSISTENT_KEY_OP(mIndex, kOperationalCredentialsIntermediateIssuerKeypairStorage, key,
ReturnErrorOnFailure(storage.SyncSetKeyValue(key, &serializedKey, keySize)));
ReturnErrorOnFailure(storage.SyncSetKeyValue(key, serializedKey.Bytes(), keySize)));
}
else
{
Expand Down

0 comments on commit 64d3ad7

Please sign in to comment.