File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 21
21
*/
22
22
#pragma once
23
23
24
+ #include < crypto/RandUtils.h>
24
25
#include < lib/support/PersistedCounter.h>
25
26
26
27
namespace chip {
@@ -106,8 +107,14 @@ class GlobalEncryptedMessageCounter : public MessageCounter
106
107
class LocalSessionMessageCounter : public MessageCounter
107
108
{
108
109
public:
109
- static constexpr uint32_t kInitialValue = 1 ;
110
- LocalSessionMessageCounter () : value(kInitialValue ) {}
110
+ static constexpr uint32_t kInitialValue = 1 ; // /< Used for initializing peer counter
111
+ static constexpr uint32_t kMessageCounterRandomInitMask = 0x0FFFFFF ; // /< 28-bit mask
112
+
113
+ /* *
114
+ * Initialize a local message counter with random value between [0, 2^28-1]. This increases the difficulty of traffic analysis
115
+ * attacks by making it harder to determine how long a particular session has been open.
116
+ */
117
+ LocalSessionMessageCounter () { value = Crypto::GetRandU32 () & kMessageCounterRandomInitMask ; }
111
118
112
119
Type GetType () override { return Session; }
113
120
uint32_t Value () override { return value; }
You can’t perform that action at this time.
0 commit comments