Skip to contentSkip to conversation

sign-file: Use OpenSSL provided define to compile out missing (deprecated) APIs

PATCH New Lee Jones 1 participant 1 message Oct 6, 2021

Subsystems (2)
lore
Share & tools
lore

Lee Jones

author
#0 lore raw

PATCH v2 1/1 sign-file: Use OpenSSL provided define to compile out missing (deprecated) APIs

OpenSSL's ENGINE API is deprecated in OpenSSL v3.0.

Use OPENSSL_NO_ENGINE to ensure the ENGINE API is only used if it is present. This will safeguard against compile errors when using SSL implementations which lack support for this deprecated API.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by sign-file.c

              /tmp/sign-file-370a2f.o:(main)

error: undefined symbol: ENGINE_init

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by sign-file.c

              /tmp/sign-file-370a2f.o:(main)

ld.lld: error: undefined symbol: ENGINE_ctrl_cmd_string

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by sign-file.c

              /tmp/sign-file-370a2f.o:(main)

ld.lld: error: undefined symbol: ENGINE_load_private_key

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by sign-file.c

              /tmp/sign-file-370a2f.o:(main)

HDRINST usr/include/linux/virtio_i2c.h
make[1]: *** [/src/kernel/scripts/Makefile.host:95: scripts/sign-file] Error 1

Cc David Howells <[email protected]>
Cc David Woodhouse <[email protected]>
Cc Eric Biggers <[email protected]>

---

v1 => v2:
- Update commit message, as suggested-by Eric Biggers

 scripts/sign-file.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
scripts/sign-file.c +10 -9
index fbd34b8e8f578..fa3fa59db6669 100644
@@ -135,7 +135,9 @@ static int pem_pw_cb(char *buf, int len, int w, void *v)
 static EVP_PKEY *read_private_key(const char *private_key_name)
 {
 	EVP_PKEY *private_key;
+	BIO *b;
 
+#ifndef OPENSSL_NO_ENGINE
 	if (!strncmp(private_key_name, "pkcs11:", 7)) {
 		ENGINE *e;
 
@@ -153,17 +155,16 @@ static EVP_PKEY *read_private_key(const char *private_key_name)
 		private_key = ENGINE_load_private_key(e, private_key_name,
 						      NULL, NULL);
 		ERR(!private_key, "%s", private_key_name);
-	} else {
-		BIO *b;
-
-		b = BIO_new_file(private_key_name, "rb");
-		ERR(!b, "%s", private_key_name);
-		private_key = PEM_read_bio_PrivateKey(b, NULL, pem_pw_cb,
-						      NULL);
-		ERR(!private_key, "%s", private_key_name);
-		BIO_free(b);
+		return private_key;
 	}
+#endif
 
+	b = BIO_new_file(private_key_name, "rb");
+	ERR(!b, "%s", private_key_name);
+	private_key = PEM_read_bio_PrivateKey(b, NULL, pem_pw_cb,
+					      NULL);
+	ERR(!private_key, "%s", private_key_name);
+	BIO_free(b);
 	return private_key;
 }
 
Signature · 1 line
2.33.0.800.g4c38ced690-goog