-
Notifications
You must be signed in to change notification settings - Fork 191
Open
Description
Migrate CMAC_* to EVP_MAC interface
Issue Summary
Migrate the CMAC implementation in gost_omac.c from deprecated CMAC_* APIs to the modern EVP_MAC interface to ensure compatibility with OpenSSL builds that disable deprecated functionality.
Problem Description
The current OMAC (CMAC) implementation relies on deprecated CMAC APIs (CMAC_CTX_new, CMAC_CTX_free, CMAC_Init, CMAC_Update, CMAC_Final, CMAC_CTX_copy), 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
OMAC_CTXstructure containsCMAC_CTX *cmac_ctx- Functions like
omac_key(),omac_imit_update(),omac_imit_final(),omac_imit_copy(), andomac_imit_cleanup()directly useCMAC_*APIs - Context initialization and cleanup rely on
CMAC_CTX_new()andCMAC_CTX_free() - MAC computation uses
CMAC_Init(),CMAC_Update(), andCMAC_Final()
Required Changes
1. Replace CMAC_CTX with EVP_MAC context
- Modify
OMAC_CTXto storeEVP_MAC *macandEVP_MAC_CTX *mac_ctxinstead ofCMAC_CTX *cmac_ctx - Update structure initialization to use
EVP_MAC_fetch("CMAC")andEVP_MAC_CTX_new()
2. Update MAC initialization and key setting
- In
omac_key(), replaceCMAC_Init()withEVP_MAC_init()usingOSSL_MAC_PARAM_CIPHERparameter - Ensure cipher is specified by name (e.g.,
c->cipher_name)
3. Update MAC update and final operations
- Replace
CMAC_Update()withEVP_MAC_update() - Replace
CMAC_Final()withEVP_MAC_final(), writing output to a buffer and thenmemcpytodgst_size
4. Update context copy and cleanup
- Replace
CMAC_CTX_copy()withEVP_MAC_CTX_dup()(if available) or manual duplication - Replace
CMAC_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_omac.c: Update
OMAC_CTXstructure,omac_key(),omac_imit_update(),omac_imit_final(),omac_imit_copy(),omac_imit_cleanup() - Potentially gost_lcl.h: If
OMAC_CTXis defined there, update accordingly
Acceptance Criteria
- CMAC implementation uses only
EVP_MACAPIs, noCMAC_*calls remain - OMAC operations (init, update, final, copy, cleanup) work correctly with EVP_MAC
Testing
- Unit tests for OMAC (magma_mac, grasshopper_mac) pass with new implementation
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels