[PATCH 16/25] raop: Honor encryption capability given by a remote device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some AirPlay device (likely a third-party one) may not support
RSA encryption. In such a case we fall back to no encryption mode.
---
 src/modules/raop/module-raop-sink.c |  5 ++++-
 src/modules/raop/raop_client.c      | 10 ++++++++--
 src/modules/raop/raop_client.h      |  2 ++
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/modules/raop/module-raop-sink.c b/src/modules/raop/module-raop-sink.c
index 9a3bd59..d49877d 100644
--- a/src/modules/raop/module-raop-sink.c
+++ b/src/modules/raop/module-raop-sink.c
@@ -794,7 +794,7 @@ int pa__init(pa_module *m) {
     struct userdata *u = NULL;
     pa_sample_spec ss;
     pa_modargs *ma = NULL;
-    const char *server, *protocol;
+    const char *server, *protocol, *encryption;
     pa_sink_new_data data;
     char *t = NULL;
 
@@ -916,6 +916,9 @@ int pa__init(pa_module *m) {
         goto fail;
     }
 
+    encryption = pa_modargs_get_value(ma, "encryption", NULL);
+    pa_raop_client_set_encryption(u->raop, !pa_streq(encryption, "none"));
+
     pa_raop_client_tcp_set_callback(u->raop, tcp_on_connection, u);
     pa_raop_client_tcp_set_closed_callback(u->raop, tcp_on_close, u);
 
diff --git a/src/modules/raop/raop_client.c b/src/modules/raop/raop_client.c
index fdb1a86..ba79759 100644
--- a/src/modules/raop/raop_client.c
+++ b/src/modules/raop/raop_client.c
@@ -98,6 +98,7 @@ struct pa_raop_client {
     uint8_t jack_status;
 
     /* Encryption Related bits */
+    int encryption; /* Enable encryption? */
     AES_KEY aes;
     uint8_t aes_iv[AES_CHUNKSIZE]; /* Initialization vector for aes-cbc */
     uint8_t aes_nv[AES_CHUNKSIZE]; /* Next vector for aes-cbc */
@@ -1317,8 +1318,10 @@ int pa_raop_client_encode_sample(pa_raop_client *c, pa_memchunk *raw, pa_memchun
         *(b + 3) = len & 0xff;
     }
 
-    /* Encrypt our data. */
-    aes_encrypt(c, (b + header_size), size);
+    if (c->encryption) {
+        /* Encrypt our data. */
+        aes_encrypt(c, (b + header_size), size);
+    }
 
     /* We're done with the chunk. */
     pa_memblock_release(encoded->memblock);
@@ -1340,6 +1343,9 @@ void pa_raop_client_tcp_set_closed_callback(pa_raop_client *c, pa_raop_client_cl
     c->tcp_closed_userdata = userdata;
 }
 
+void pa_raop_client_set_encryption(pa_raop_client *c, int encryption) {
+    c->encryption = encryption;
+}
 
 void pa_raop_client_udp_set_setup_callback(pa_raop_client *c, pa_raop_client_setup_cb_t callback, void *userdata) {
     pa_assert(c);
diff --git a/src/modules/raop/raop_client.h b/src/modules/raop/raop_client.h
index 5cf1ff7..1b8048d 100644
--- a/src/modules/raop/raop_client.h
+++ b/src/modules/raop/raop_client.h
@@ -42,6 +42,8 @@ int pa_raop_client_flush(pa_raop_client *c);
 int pa_raop_client_teardown(pa_raop_client *c);
 
 int pa_raop_client_udp_can_stream(pa_raop_client *c);
+
+void pa_raop_client_set_encryption(pa_raop_client *c, int encryption);
 int pa_raop_client_set_volume(pa_raop_client *c, pa_volume_t volume);
 int pa_raop_client_encode_sample(pa_raop_client *c, pa_memchunk *raw, pa_memchunk *encoded);
 
-- 
1.8.1.2



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux