-
Notifications
You must be signed in to change notification settings - Fork 186
Open
Description
Decouple cipher provider logic from EVP_CIPHER* APIs
Issue Summary
Refactor gost_prov_cipher.c to operate exclusively on internal cipher contexts and descriptors, removing all dependencies on EVP_CIPHER, EVP_CIPHER_CTX, and legacy EVP wrappers. Implement provider-native cipher operations.
Problem Description
The provider cipher implementation wraps ENGINE-based ciphers using EVP_CIPHER_CTX as an intermediate layer, creating unnecessary indirection and dependency on deprecated APIs. This prevents the provider from being truly independent and compatible with OpenSSL builds disabling legacy interfaces.
Current Implementation
struct gost_prov_crypt_ctx_stcontainsEVP_CIPHER *cipherandEVP_CIPHER_CTX *cctx- Provider functions like
cipher_update,cipher_encrypt_initcallEVP_CipherUpdate,EVP_CipherInit_ex - Initialization uses
GOST_init_cipher()to create EVP wrappers
Required Changes
1. Redefine provider context structure
- Update
struct gost_prov_crypt_ctx_stin gost_prov_cipher.c:- Remove
EVP_CIPHER *cipherandEVP_CIPHER_CTX *cctx - Add
void *cipher_datafor direct context - Add
const GOST_cipher *descriptorfor method dispatch
- Remove
2. Implement direct cipher operations
- Refactor provider functions to call direct cipher methods:
cipher_encrypt_init: Calldescriptor->init_direct(cipher_data, ...)cipher_update: Calldescriptor->do_cipher_direct(cipher_data, ...)cipher_final: Calldescriptor->cleanup_directcipher_get_ctx_params: Extract params directly fromcipher_datacipher_set_ctx_params: Set params directly incipher_data
3. Update context management
cipher_newctx: Allocatecipher_datausingdescriptor->ctx_size; calldescriptor->init_directcipher_freectx: Calldescriptor->cleanup_direct(cipher_data); freecipher_datacipher_dupctx: Duplicatecipher_datadirectly
4. Remove EVP dependencies
- Eliminate calls to
EVP_CIPHER_CTX_new,EVP_CIPHER_CTX_free,EVP_CipherInit_ex, etc. - Remove
GOST_init_cipher()usage in provider code - Handle ASN.1 parameters directly via
descriptor->set_asn1_parameters_direct
5. Update cipher dispatch
- Modify
MAKE_FUNCTIONSmacro in gost_prov_cipher.c to use direct methods - Ensure all
OSSL_DISPATCHentries call provider-native functions
Files to Modify
- gost_prov_cipher.c: Redefine context structure; refactor all functions to use direct cipher methods; remove EVP calls
- gost_lcl.h: Ensure
GOST_cipherstructure supports direct dispatch
Acceptance Criteria
- Provider cipher operations use only internal contexts and descriptors
- No
EVP_CIPHER*orEVP_CIPHER_CTX*calls in gost_prov_cipher.c - Provider is independent of ENGINE and EVP wrappers
Testing
- Provider cipher tests pass without EVP dependencies
- Encryption/decryption operations work correctly
- Compatibility with OpenSSL provider API maintained
Metadata
Metadata
Assignees
Labels
No labels