-
Notifications
You must be signed in to change notification settings - Fork 186
Open
Description
Migrate HMAC_* to EVP_MAC interface
Issue Summary
Migrate the HMAC implementation in gost_keyexpimp.c from deprecated HMAC_* APIs to the modern EVP_MAC interface to ensure compatibility with OpenSSL builds that disable deprecated functionality.
Problem Description
The current HMAC usage in key derivation functions relies on deprecated HMAC APIs (HMAC_CTX_new, HMAC_CTX_free, HMAC_Init_ex, HMAC_Update, HMAC_Final, HMAC_CTX_reset), which are marked for removal in future OpenSSL versions. This prevents the codebase from building or running with OPENSSL_NO_DEPRECATED_3_0 enabled. The migration to EVP_MAC provides a stable, provider-based alternative that aligns with OpenSSL's modern architecture.
Current Implementation
gost_kdftree2012_256()usesHMAC_CTX *ctxwithHMAC_CTX_new(),HMAC_Init_ex(),HMAC_Update(),HMAC_Final(),HMAC_CTX_reset(), andHMAC_CTX_free()- Context is created, initialized with key and digest, updated with data, finalized, and reset for multiple iterations
Required Changes
1. Replace HMAC_CTX with EVP_MAC context
- Modify
gost_kdftree2012_256()to useEVP_MAC *macandEVP_MAC_CTX *mac_ctx - Replace
HMAC_CTX_new()withEVP_MAC_fetch("HMAC")andEVP_MAC_CTX_new()
2. Update MAC initialization
- Replace
HMAC_Init_ex()withEVP_MAC_init()usingOSSL_MAC_PARAM_DIGESTparameter (set toNID_id_GostR3411_2012_256)
3. Update MAC update and final operations
- Replace
HMAC_Update()withEVP_MAC_update() - Replace
HMAC_Final()withEVP_MAC_final()
4. Update context reset and cleanup
- Replace
HMAC_CTX_reset()with re-runningEVP_MAC_init()with the same key and parameters - Replace
HMAC_CTX_free()withEVP_MAC_CTX_free()andEVP_MAC_free()
5. Handle EVP_MAC availability
- Add checks for
EVP_MACsupport; provide fallback or error if not available
Files to Modify
- gost_keyexpimp.c: Update
gost_kdftree2012_256()function to use EVP_MAC APIs
Dependencies
This task has no dependencies on other issues but should be completed before full provider decoupling (#116, #117).
Acceptance Criteria
- HMAC implementation uses only
EVP_MACAPIs, noHMAC_*calls remain - Key derivation function
gost_kdftree2012_256()works correctly with EVP_MAC
Testing
- Unit tests for key derivation (
gost_kdftree2012_256) pass with new implementation - Integration tests with TLS tree key derivation (
gost_tlstree) succeed
Metadata
Metadata
Assignees
Labels
No labels