]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
allow for updated or old mbedtls library
authorMike Brady <mikebrady@eircom.net>
Sat, 2 Feb 2019 15:03:27 +0000 (15:03 +0000)
committerMike Brady <mikebrady@eircom.net>
Sat, 2 Feb 2019 15:03:27 +0000 (15:03 +0000)
metadata_hub.c
rtsp.c
shairport.c

index 015327f0bb3c90ace33ec50d9da67f67781ee62e..3ec7a4146435c3dbd1f13c95b017f12789bdc9f4 100644 (file)
@@ -227,10 +227,17 @@ char *metadata_write_image_file(const char *buf, int len) {
 #endif
 
 #ifdef CONFIG_MBEDTLS
-  mbedtls_md5_context tctx;
-  mbedtls_md5_starts_ret(&tctx);
-  mbedtls_md5_update_ret(&tctx, (const unsigned char *)buf, len);
-  mbedtls_md5_finish_ret(&tctx, img_md5);
+  #if MBEDTLS_VERSION_MINOR >= 7
+    mbedtls_md5_context tctx;
+    mbedtls_md5_starts_ret(&tctx);
+    mbedtls_md5_update_ret(&tctx, (const unsigned char *)buf, len);
+    mbedtls_md5_finish_ret(&tctx, img_md5);
+  #else
+    mbedtls_md5_context tctx;
+    mbedtls_md5_starts(&tctx);
+    mbedtls_md5_update(&tctx, (const unsigned char *)buf, len);
+    mbedtls_md5_finish(&tctx, img_md5);
+  #endif
 #endif
 
 #ifdef CONFIG_POLARSSL
diff --git a/rtsp.c b/rtsp.c
index 3143dba556f87000a32b00a962adaedbf0e8200b..fb66d4c347367b36f77803d05a4fef984057c0b4 100644 (file)
--- a/rtsp.c
+++ b/rtsp.c
@@ -2038,6 +2038,7 @@ static int rtsp_auth(char **nonce, rtsp_message *req, rtsp_message *resp) {
 #endif
 
 #ifdef CONFIG_MBEDTLS
+  #if MBEDTLS_VERSION_MINOR >= 7
   mbedtls_md5_context tctx;
   mbedtls_md5_starts_ret(&tctx);
   mbedtls_md5_update_ret(&tctx, (const unsigned char *)username, strlen(username));
@@ -2051,6 +2052,21 @@ static int rtsp_auth(char **nonce, rtsp_message *req, rtsp_message *resp) {
   mbedtls_md5_update_ret(&tctx, (unsigned char *)":", 1);
   mbedtls_md5_update_ret(&tctx, (const unsigned char *)uri, strlen(uri));
   mbedtls_md5_finish_ret(&tctx, digest_mu);
+  #else
+  mbedtls_md5_context tctx;
+  mbedtls_md5_starts(&tctx);
+  mbedtls_md5_update(&tctx, (const unsigned char *)username, strlen(username));
+  mbedtls_md5_update(&tctx, (unsigned char *)":", 1);
+  mbedtls_md5_update(&tctx, (const unsigned char *)realm, strlen(realm));
+  mbedtls_md5_update(&tctx, (unsigned char *)":", 1);
+  mbedtls_md5_update(&tctx, (const unsigned char *)config.password, strlen(config.password));
+  mbedtls_md5_finish(&tctx, digest_urp);
+  mbedtls_md5_starts(&tctx);
+  mbedtls_md5_update(&tctx, (const unsigned char *)req->method, strlen(req->method));
+  mbedtls_md5_update(&tctx, (unsigned char *)":", 1);
+  mbedtls_md5_update(&tctx, (const unsigned char *)uri, strlen(uri));
+  mbedtls_md5_finish(&tctx, digest_mu);
+  #endif
 #endif
 
 #ifdef CONFIG_POLARSSL
@@ -2089,6 +2105,7 @@ static int rtsp_auth(char **nonce, rtsp_message *req, rtsp_message *resp) {
 #endif
 
 #ifdef CONFIG_MBEDTLS
+  #if MBEDTLS_VERSION_MINOR >= 7
   mbedtls_md5_starts_ret(&tctx);
   mbedtls_md5_update_ret(&tctx, buf, 32);
   mbedtls_md5_update_ret(&tctx, (unsigned char *)":", 1);
@@ -2098,6 +2115,17 @@ static int rtsp_auth(char **nonce, rtsp_message *req, rtsp_message *resp) {
     snprintf((char *)buf + 2 * i, 3, "%02x", digest_mu[i]);
   mbedtls_md5_update_ret(&tctx, buf, 32);
   mbedtls_md5_finish_ret(&tctx, digest_total);
+  #else
+  mbedtls_md5_starts(&tctx);
+  mbedtls_md5_update(&tctx, buf, 32);
+  mbedtls_md5_update(&tctx, (unsigned char *)":", 1);
+  mbedtls_md5_update(&tctx, (const unsigned char *)*nonce, strlen(*nonce));
+  mbedtls_md5_update(&tctx, (unsigned char *)":", 1);
+  for (i = 0; i < 16; i++)
+    snprintf((char *)buf + 2 * i, 3, "%02x", digest_mu[i]);
+  mbedtls_md5_update(&tctx, buf, 32);
+  mbedtls_md5_finish(&tctx, digest_total);
+  #endif
 #endif
 
 #ifdef CONFIG_POLARSSL
index 9a26a368924b2e6f7a73baf6884efc8c20795fb6..617e90097de2d08ce1024a62220ccbebf5ae760c 100644 (file)
@@ -1609,10 +1609,17 @@ int main(int argc, char **argv) {
 #endif
 
 #ifdef CONFIG_MBEDTLS
-  mbedtls_md5_context tctx;
-  mbedtls_md5_starts_ret(&tctx);
-  mbedtls_md5_update_ret(&tctx, (unsigned char *)config.service_name, strlen(config.service_name));
-  mbedtls_md5_finish_ret(&tctx, ap_md5);
+  #if MBEDTLS_VERSION_MINOR >= 7
+    mbedtls_md5_context tctx;
+    mbedtls_md5_starts_ret(&tctx);
+    mbedtls_md5_update_ret(&tctx, (unsigned char *)config.service_name, strlen(config.service_name));
+    mbedtls_md5_finish_ret(&tctx, ap_md5);
+  #else
+    mbedtls_md5_context tctx;
+    mbedtls_md5_starts(&tctx);
+    mbedtls_md5_update(&tctx, (unsigned char *)config.service_name, strlen(config.service_name));
+    mbedtls_md5_finish(&tctx, ap_md5);
+  #endif
 #endif
 
 #ifdef CONFIG_POLARSSL