Skip to content

Commit

Permalink
[crypto] Fix compile error in BufferWriter init (#25015)
Browse files Browse the repository at this point in the history
BufferWriter class expects a (uint8_t*, size_t) as initialization.
The given parameter 'output' was a `P256SerializedKeypair` which throws a compiler error.

Output: used compiler - gcc-arm-none-eabi-9-2019-q4-major
In member function 'virtual CHIP_ERROR chip::Crypto::P256Keypair::Serialize(chip::Crypto::P256SerializedKeypair&) const':
.../src/crypto/CHIPCryptoPALPSA.cpp:685:51: error: no matching function for call to 'chip::Encoding::BufferWriter::BufferWriter(chip::Crypto::P256SerializedKeypair&, const size_t&)'
  685 |     Encoding::BufferWriter bbuf(output, outputSize);

Fix:
Use the `Bytes` method to expose a uint8_t* for use of the BufferWriter.
  • Loading branch information
tima-q authored and pull[bot] committed Aug 12, 2023
1 parent fdd9e79 commit b4f48aa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/crypto/CHIPCryptoPALPSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ CHIP_ERROR P256Keypair::Serialize(P256SerializedKeypair & output) const
psa_status_t status = PSA_SUCCESS;
const PSAP256KeypairContext & context = toConstPSAContext(mKeypair);
const size_t outputSize = output.Length() == 0 ? output.Capacity() : output.Length();
Encoding::BufferWriter bbuf(output, outputSize);
Encoding::BufferWriter bbuf(output.Bytes(), outputSize);
uint8_t privateKey[kP256_PrivateKey_Length];
size_t privateKeyLength = 0;

Expand Down

0 comments on commit b4f48aa

Please sign in to comment.