Skip to content

Commit

Permalink
Call DRBG_get_bytes() For Subscription Id Generation. (#9995)
Browse files Browse the repository at this point in the history
  • Loading branch information
emargolis authored and pull[bot] committed Oct 7, 2021
1 parent f6380db commit 1708073
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
7 changes: 1 addition & 6 deletions src/app/ReadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <app/MessageDef/SubscribeResponse.h>
#include <app/ReadHandler.h>
#include <app/reporting/Engine.h>
#include <lib/support/RandUtils.h>

namespace chip {
namespace app {
Expand Down Expand Up @@ -545,11 +544,7 @@ CHIP_ERROR ReadHandler::ProcessSubscribeRequest(System::PacketBufferHandle && aP
ReturnLogErrorOnFailure(subscribeRequestParser.GetMinIntervalSeconds(&mMinIntervalFloorSeconds));
ReturnLogErrorOnFailure(subscribeRequestParser.GetMaxIntervalSeconds(&mMaxIntervalCeilingSeconds));

// TODO: Use GetSecureRandomData to generate subscription id
// it needs #include <support/crypto/CHIPRNG.h>, but somehow CHIPRNG.h is missing
// err = Platform::Security::GetSecureRandomData((uint8_t *) &mSubscriptionId, sizeof(mSubscriptionId));
// SuccessOrExit(err);
mSubscriptionId = GetRandU64();
ReturnLogErrorOnFailure(Crypto::DRBG_get_bytes(reinterpret_cast<uint8_t *>(&mSubscriptionId), sizeof(mSubscriptionId)));

MoveToState(HandlerState::GeneratingReports);

Expand Down
2 changes: 1 addition & 1 deletion src/lib/support/RandUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* @note These utility functions do not generate cryptographically strong
* random number. To get cryptographically strong random data use
* chip::Platform::Security::GetSecureRandomData().
* chip::Crypto::DRBG_get_bytes().
*
*/

Expand Down
2 changes: 1 addition & 1 deletion src/lib/support/RandUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* @note These utility functions do not generate cryptographically strong
* random number. To get cryptographically strong random data use
* chip::Platform::Security::GetSecureRandomData().
* chip::Crypto::DRBG_get_bytes().
*
*/

Expand Down

0 comments on commit 1708073

Please sign in to comment.