[linux-minidisc] [PATCH] NetMD SP Transfer results in audible 'pop' on packet boundary


Hi,

your emails reminded me that I hit GH#39 this year and wanted to sent
you the re-based patch. IIRC the quoated webnetmd code did not apply
due to some code changes over the years:

Fix audible noise every ~47s, GH#39: NetMD SP Transfer results in
audible 'pop' on packet boundary. Tested on Sony MZ-RH1.

--- linux-minidisc/libnetmd/secure.c.vanilla	2025-02-22 18:33:21.819516328 +0100
+++ linux-minidisc/libnetmd/secure.c	2025-02-22 20:09:42.859406102 +0100
@@ -5,6 +5,7 @@
  *
  * Copyright (C) 2004 Bertrik Sikken
  * Copyright (C) 2011 Alexander Sulfrian
+ * Copyright (C) 2025 René Rebe
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -485,7 +486,7 @@
         gcry_cipher_setkey(data_handle, rand, sizeof(rand));
         gcry_cipher_encrypt(data_handle, next->data, chunksize, data + position, packet_data_length);
         /* set last encrypted block as iv for the next packet */
-        memcpy(iv, data + position + packet_data_length - 8, 8);
+        memcpy(iv, next->data + chunksize - 8, 8);
 
         /* next packet */
         position = position + chunksize;


-- 
  René Rebe, ExactCODE GmbH, Berlin, Germany
  https://exactcode.com | https://t2linux.com | https://rene.rebe.de