File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -141,6 +141,21 @@ secure_buffer key(std::move(secret_string)); // обнуляет перемещ
141141auto mac = hmac::get_hmac(key, payload, hmac::TypeHash::SHA256);
142142```
143143
144+ Для дополнительной защиты в памяти можно использовать `hmac_cpp::secret_string`, который
145+ обфусцирует данные и по возможности закрепляет их в RAM:
146+
147+ ```cpp
148+ #include <hmac_cpp/secret.hpp>
149+
150+ hmac_cpp::secret_string token("super-secret-token");
151+
152+ token.with_plaintext([](const uint8_t* p, size_t n){
153+ // p действует только внутри коллбэка
154+ });
155+
156+ token.clear();
157+ ```
158+
144159### HMAC (сырой буфер)
145160
146161``` cpp
Original file line number Diff line number Diff line change @@ -142,6 +142,21 @@ secure_buffer key(std::move(secret_string)); // zeroizes moved-from string
142142auto mac = hmac::get_hmac(key, payload, hmac::TypeHash::SHA256);
143143```
144144
145+ For additional protection in memory, `hmac_cpp::secret_string` obfuscates
146+ the data and tries to keep it locked in RAM:
147+
148+ ```cpp
149+ #include <hmac_cpp/secret.hpp>
150+
151+ hmac_cpp::secret_string token("super-secret-token");
152+
153+ token.with_plaintext([](const uint8_t* p, size_t n){
154+ // p is valid only inside the callback
155+ });
156+
157+ token.clear();
158+ ```
159+
145160### HMAC (raw buffer)
146161
147162``` cpp
You can’t perform that action at this time.
0 commit comments