]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
replace some deprecated OpenSSL calls
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Sat, 10 Jun 2023 15:06:25 +0000 (16:06 +0100)
committerMike Brady <4265913+mikebrady@users.noreply.github.com>
Sat, 10 Jun 2023 15:06:25 +0000 (16:06 +0100)
common.c
shairport.c

index 6bac822a4162837aeb741eb4a9dd1a05e8da462a..2c902e3bc8775b7b0bfa1b95710383191fb0137a 100644 (file)
--- a/common.c
+++ b/common.c
@@ -823,10 +823,9 @@ uint8_t *rsa_apply(uint8_t *input, int inlen, int *outlen, int mode) {
         if (EVP_PKEY_sign_init(ctx) > 0) {                                                // 1.0.2
           if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) > 0) {                 // 1.0.2
             if (EVP_PKEY_sign(ctx, NULL, &ol, (const unsigned char *)input, inlen) > 0) { // 1.0.2
-              debug(1, "output size = %lu.", ol);
               out = (unsigned char *)malloc(ol);
               if (EVP_PKEY_sign(ctx, out, &ol, (const unsigned char *)input, inlen) > 0) { // 1.0.2
-                debug(1, "success with output length of %lu.", ol);
+                debug(3, "success with output length of %lu.", ol);
               } else {
                 debug(1, "error 2 \"%s\" with EVP_PKEY_sign:",
                       ERR_error_string(ERR_get_error(), NULL));
@@ -852,7 +851,7 @@ uint8_t *rsa_apply(uint8_t *input, int inlen, int *outlen, int mode) {
               out = OPENSSL_malloc(ol);
               if (out != NULL) {
                 if (EVP_PKEY_decrypt(ctx, out, &ol, (const unsigned char *)input, inlen) > 0) {
-                  debug(1, "decrypt success");
+                  debug(3, "decrypt success");
                 } else {
                   debug(1, "error \"%s\" with EVP_PKEY_decrypt:",
                         ERR_error_string(ERR_get_error(), NULL));
index db54c8c6d02ebe031cab928b10a8bb7ca3bc81a0..8aafa2699f042822bc33baa4095f27007592ee8b 100644 (file)
@@ -62,6 +62,7 @@
 
 #ifdef CONFIG_OPENSSL
 #include <openssl/md5.h>
+#include <openssl/evp.h>
 #endif
 
 #if defined(CONFIG_DBUS_INTERFACE)
@@ -2525,11 +2526,12 @@ int main(int argc, char **argv) {
 
   // debug(1, "size of hw_addr is %u.", sizeof(config.hw_addr));
 #ifdef CONFIG_OPENSSL
-  MD5_CTX ctx;
-  MD5_Init(&ctx);
-  MD5_Update(&ctx, config.service_name, strlen(config.service_name));
-  MD5_Update(&ctx, config.hw_addr, sizeof(config.hw_addr));
-  MD5_Final(ap_md5, &ctx);
+  EVP_MD_CTX *mdctx = EVP_MD_CTX_new();
+  EVP_DigestInit_ex(mdctx, EVP_md5(), NULL);
+  EVP_DigestUpdate(mdctx, config.service_name, strlen(config.service_name));
+  EVP_DigestUpdate(mdctx, config.hw_addr, sizeof(config.hw_addr));
+  unsigned int md5_digest_len = EVP_MD_size(EVP_md5());
+  EVP_DigestFinal_ex(mdctx, ap_md5, &md5_digest_len); 
 #endif
 
 #ifdef CONFIG_MBEDTLS