Skip to content

v4.0.1

Choose a tag to compare

@paolostivanin paolostivanin released this 15 Apr 14:35
4a08793

Highlights

Patch release focused on security fixes, memory safety improvements, and binary hardening.

Security Fixes

  • Fixed timing side-channel in validate_totp_in_window: comparison now uses min(gen_len, user_len) bytes to prevent reading past buffer bounds when lengths differ
  • Normalized secret key is now zeroed with cotp_secure_memzero before freeing in compute_hmac
  • Fixed memory leak in OpenSSL backend: EVP_MAC not freed when calloc fails in whmac_gethandle
  • Fixed memory leak in OpenSSL backend: EVP_MAC_CTX not freed in whmac_freehandle and on buffer-too-small error path in whmac_finalize
  • Added negative algorithm index validation (algo < 0) in all three HMAC backends (gcrypt, OpenSSL, MbedTLS)

Hardening

  • All public symbols now use explicit __attribute__((visibility("default"))); library compiled with -fvisibility=hidden to minimize exported symbol surface
  • Added linker hardening flags: full RELRO (-Wl,-z,relro,-z,now) and non-executable stack (-Wl,-z,noexecstack)
  • REVERSE_BYTES macro wrapped in do { ... } while (0) for safe use in all statement contexts
  • CMake now detects explicit_bzero at configure time via check_function_exists

Improvements

  • Base32 validation (valid_b32_str) now enforces RFC 4648 padding rules: rejects data characters after padding, validates padding count (0, 1, 3, 4, or 6), and requires padded strings to have length divisible by 8
  • check_input max_len parameter changed from int32_t to size_t for type correctness

Tests

  • Significantly expanded test coverage: OTP edge cases, Base32 decode corner cases, and new TOTP window validation tests

Documentation

  • Updated README examples to use COTP_SHA1/COTP_SHA256/COTP_SHA512 constants (renamed in v4.0.0)

sha256: f8c843004d18880eb41417853fcfc3855f6197e7a32dcd87d23a6609cf0a116a