Skip to content

Commit 3be06e0

Browse files
committed
Fix no-engine
Make sure references to ENGINE functions are appropriately guarded. Reviewed-by: Richard Levitte <[email protected]> (Merged from openssl#9720)
1 parent bad41b6 commit 3be06e0

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

crypto/evp/p_lib.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,9 @@ EVP_PKEY *EVP_PKEY_new_CMAC_key(ENGINE *e, const unsigned char *priv,
321321
size_t len, const EVP_CIPHER *cipher)
322322
{
323323
#ifndef OPENSSL_NO_CMAC
324+
# ifndef OPENSSL_NO_ENGINE
324325
const char *engine_name = e != NULL ? ENGINE_get_name(e) : NULL;
326+
# endif
325327
const char *cipher_name = EVP_CIPHER_name(cipher);
326328
const OSSL_PROVIDER *prov = EVP_CIPHER_provider(cipher);
327329
OPENSSL_CTX *libctx =
@@ -339,11 +341,14 @@ EVP_PKEY *EVP_PKEY_new_CMAC_key(ENGINE *e, const unsigned char *priv,
339341
goto err;
340342
}
341343

344+
# ifndef OPENSSL_NO_ENGINE
342345
if (engine_name != NULL)
343346
params[paramsn++] =
344347
OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_ENGINE,
345348
(char *)engine_name,
346349
strlen(engine_name) + 1);
350+
# endif
351+
347352
params[paramsn++] =
348353
OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_CIPHER,
349354
(char *)cipher_name,

crypto/evp/pkey_mac.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,14 @@ static int pkey_mac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
274274
OSSL_PARAM params[3];
275275
size_t params_n = 0;
276276
char *ciphname = (char *)OBJ_nid2sn(EVP_CIPHER_nid(p2));
277+
#ifndef OPENSSL_NO_ENGINE
277278
char *engineid = (char *)ENGINE_get_id(ctx->engine);
278279

279280
params[params_n++] =
280281
OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_ENGINE,
281282
engineid,
282283
strlen(engineid) + 1);
284+
#endif
283285
params[params_n++] =
284286
OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_CIPHER,
285287
ciphname,
@@ -396,6 +398,7 @@ static int pkey_mac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
396398
size_t params_n = 0;
397399
char *mdname =
398400
(char *)OBJ_nid2sn(EVP_MD_nid(hctx->raw_data.md));
401+
#ifndef OPENSSL_NO_ENGINE
399402
char *engineid = ctx->engine == NULL
400403
? NULL : (char *)ENGINE_get_id(ctx->engine);
401404

@@ -406,6 +409,7 @@ static int pkey_mac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
406409
engineid,
407410
engineid_l);
408411
}
412+
#endif
409413
params[params_n++] =
410414
OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_DIGEST,
411415
mdname,

providers/common/macs/cmac_prov.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ static int cmac_set_ctx_params(void *vmacctx, const OSSL_PARAM params[])
184184
const char *algoname = p->data;
185185
const char *propquery = NULL;
186186

187-
#ifndef FIPS_MODE /* Inside the FIPS module, we don't support engines */
187+
/* Inside the FIPS module, we don't support engines */
188+
#if !defined(FIPS_MODE) && !defined(OPENSSL_NO_ENGINE)
188189
ENGINE_finish(macctx->tmpengine);
189190
macctx->tmpengine = NULL;
190191

providers/common/macs/gmac_prov.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ static int gmac_set_ctx_params(void *vmacctx, const OSSL_PARAM params[])
198198
const char *algoname = p->data;
199199
const char *propquery = NULL;
200200

201-
#ifndef FIPS_MODE /* Inside the FIPS module, we don't support engines */
201+
/* Inside the FIPS module, we don't support engines */
202+
#if !defined(FIPS_MODE) && !defined(OPENSSL_NO_ENGINE)
202203
ENGINE_finish(macctx->engine);
203204
macctx->engine = NULL;
204205

providers/common/macs/hmac_prov.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ static int hmac_set_ctx_params(void *vmacctx, const OSSL_PARAM params[])
198198
const char *algoname = p->data;
199199
const char *propquery = NULL;
200200

201-
#ifndef FIPS_MODE /* Inside the FIPS module, we don't support engines */
201+
/* Inside the FIPS module, we don't support engines */
202+
#if !defined(FIPS_MODE) && !defined(OPENSSL_NO_ENGINE)
202203
ENGINE_finish(macctx->tmpengine);
203204
macctx->tmpengine = NULL;
204205

0 commit comments

Comments
 (0)