@@ -32,6 +32,20 @@ CI covers Linux/Windows/macOS. Tested with GCC, Clang, and MSVC; requires C++11.
3232
3333---
3434
35+ ## 📈 Versioning / SemVer policy
36+
37+ * Follows [ Semantic Versioning] ( https://semver.org ) .
38+ * MAJOR: breaking changes to headers or exported symbols.
39+ * MINOR: backward-compatible additions.
40+ * PATCH: bug fixes and internal changes.
41+
42+ Version macros live in ` <hmac_cpp/version.hpp> ` :
43+ ` HMAC_CPP_VERSION_MAJOR ` , ` HMAC_CPP_VERSION_MINOR ` ,
44+ ` HMAC_CPP_VERSION_PATCH ` , and ` HMAC_CPP_VERSION ` .
45+ See [ CHANGELOG.md] ( CHANGELOG.md ) for history.
46+
47+ ---
48+
3549## 🔧 Build & Installation
3650
3751Examples, tests, and benchmarks are OFF by default. Enable via:
@@ -40,6 +54,10 @@ Examples, tests, and benchmarks are OFF by default. Enable via:
4054* ` HMACCPP_BUILD_TESTS `
4155* ` HMACCPP_BUILD_BENCH `
4256
57+ The library builds ** static** by default. Use ` -DHMACCPP_BUILD_SHARED=ON `
58+ to produce a shared library. The ` HMAC_CPP_API ` macro is empty for static
59+ builds and controls symbol export/import for shared builds.
60+
4361### Build
4462
4563``` bash
@@ -51,23 +69,21 @@ cmake --build build
5169
5270``` bash
5371cmake --install build --prefix _install
72+ # MSVC
73+ cmake --install build --config Release --prefix _install
5474```
5575
5676Install layout:
5777
5878```
5979_install/
60- ├─ include/hmac_cpp/
61- │ ├─ hmac.hpp
62- │ ├─ hmac_utils.hpp
63- │ ├─ sha1.hpp
64- │ ├─ sha256.hpp
65- │ ├─ sha512.hpp
66- │ └─ secure_buffer.hpp # if included in your build
67- └─ lib/
68- └─ libhmac_cpp.a
80+ ├── include/hmac_cpp/...
81+ └── lib/
82+ └── libhmac_cpp.a
6983```
7084
85+ A ` hmac_cpp.pc ` file is installed for ` pkg-config ` .
86+
7187### Consume with CMake
7288
7389``` cmake
@@ -80,6 +96,10 @@ target_link_libraries(my_app PRIVATE hmac_cpp::hmac_cpp)
8096``` bash
8197# adjust paths to your prefix
8298g++ example.cpp -std=c++11 -I_install/include -L_install/lib -lhmac_cpp
99+ # MSVC
100+ cl /EHsc example.cpp /I _install\i nclude /link /LIBPATH:_install\l ib hmac_cpp.lib
101+ # pkg-config
102+ c++ example.cpp $( pkg-config --cflags --libs hmac_cpp)
83103```
84104
85105Predefined MinGW build scripts are available: ` build_*.bat ` .
@@ -154,6 +174,8 @@ auto key = hmac::pbkdf2_hmac_sha256(password, salt, iters, 32); // 32 = AES-256
154174* ** Iterations** : tune for \~ 100–250 ms on target hardware (e.g., desktop ≈ 600k, laptop ≈ 300k, mobile ≈ 150k; adjust).
155175* ** Derived key length** : 32 bytes; ** PRF** : HMAC-SHA256.
156176
177+ > PBKDF2 is CPU-bound; for user passwords prefer memory-hard KDFs such as Argon2 or scrypt if available.
178+
157179** Serialization example** (binary):
158180
159181```
@@ -262,12 +284,14 @@ ctest --test-dir build --output-on-failure
262284
263285Covered vectors:
264286
265- * HMAC — ** RFC 4231**
266- * PBKDF2 — ** RFC 6070**
267- * HOTP — ** RFC 4226** (Appendix D)
268- * TOTP — ** RFC 6238** (Appendix B)
287+ | Suite | RFC |
288+ | ------ | --- |
289+ | HMAC | RFC 4231 |
290+ | PBKDF2 | RFC 6070 |
291+ | HOTP | RFC 4226 (App D) |
292+ | TOTP | RFC 6238 (App B) |
269293
270- CI runs these on Linux/Windows/macOS .
294+ CI: [ GitHub Actions ] ( https://github.com/NewYaroslav/hmac-cpp/actions ) .
271295
272296---
273297
@@ -302,15 +326,18 @@ g++ example.cpp -std=c++11 -I_install/include -L_install/lib -lhmac_cpp
302326MSVC:
303327
304328``` bat
305- cl /EHsc example.cpp /I _install\include /link /LIBPATH:_install\lib hmach_cpp .lib
329+ cl /EHsc example.cpp /I _install\include /link /LIBPATH:_install\lib hmac_cpp .lib
306330```
307331
308332---
309333
310334## ⚠️ Exceptions & Contracts
311335
312- * Functions may throw ` std::invalid_argument ` (bad params) and ` std::runtime_error ` (internal errors).
313- * ` constant_time_equal ` assumes lengths are public; compare sizes first.
336+ * ` pbkdf2 ` , ` hkdf_* ` , HOTP/TOTP, and time-token helpers validate parameters and throw
337+ ` std::invalid_argument ` ; time-token helpers also throw ` std::runtime_error ` if the
338+ system clock fails.
339+ * ` base64_decode ` and ` base32_decode ` are ` noexcept ` and return ` false ` on invalid input.
340+ * ` constant_time_equal ` is ` noexcept ` ; compare sizes first.
314341* PBKDF2 limits: ` dkLen ≤ (2^32−1)·hLen ` ; iterations ≥ 1; salt length ≥ 16 recommended.
315342* HKDF limits: ` L ≤ 255·HashLen ` .
316343* Thread-safety: functions are stateless and thread-safe given separate buffers.
0 commit comments