Skip to content

Commit

Permalink
Changed a names a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
ArekBalysNordic committed Jan 3, 2024
1 parent 42f0d42 commit 5ff3dc7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/platform/nrfconnect/FactoryDataProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ CHIP_ERROR FactoryDataProvider<FlashFactoryData>::MoveDACPrivateKeyToSecureStora
size_t requiredFlashSpaceSize = ROUND_UP(kDACPrivateKeyLength + bytesToLeftBefore, flashParameters->write_block_size);
size_t bytesToLeftAfter = requiredFlashSpaceSize - bytesToLeftBefore - kDACPrivateKeyLength;

// Allocate the memory buffer for migration.
chip::Platform::ScopedMemoryBuffer<uint8_t> newDADBuffer;
VerifyOrReturnError(newDADBuffer.Calloc(requiredFlashSpaceSize), CHIP_ERROR_NO_MEMORY);
// Allocate the memory buffer for removing DAC private key.
chip::Platform::ScopedMemoryBuffer<uint8_t> removedPrivKeyBuffer;
VerifyOrReturnError(removedPrivKeyBuffer.Calloc(requiredFlashSpaceSize), CHIP_ERROR_NO_MEMORY);
// Copy the existing parts of the aligned memory space to before and after the DAC private key space.
memcpy(newDADBuffer.Get(), factoryDataPartition, bytesToLeftBefore);
memcpy(newDADBuffer.Get() + bytesToLeftBefore + kDACPrivateKeyLength, factoryDataPartition, bytesToLeftAfter);
memcpy(removedPrivKeyBuffer.Get(), factoryDataPartition, bytesToLeftBefore);
memcpy(removedPrivKeyBuffer.Get() + bytesToLeftBefore + kDACPrivateKeyLength, factoryDataPartition, bytesToLeftAfter);
// Write aligned buffer directly to the Flash without erasing.
VerifyOrReturnError(0 ==
flash_write(kFlashDev, kFactoryDataPartitionAddress + alignedDacPrivKeyOffset, newDADBuffer.Get(),
flash_write(kFlashDev, kFactoryDataPartitionAddress + alignedDacPrivKeyOffset, removedPrivKeyBuffer.Get(),
requiredFlashSpaceSize),
CHIP_ERROR_INTERNAL);
// Parse the factory Data again and verify if the procedure finished successfully
Expand Down

0 comments on commit 5ff3dc7

Please sign in to comment.