summaryrefslogtreecommitdiff
path: root/utils/nwztools/upgtools/fwp.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2017-01-04 16:55:53 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2017-01-04 17:05:15 +0100
commitdbeb6db1b55a50dedf17e7d78ddb6fe9eebc2a63 (patch)
tree29118847ebd2328095bb9f31fe7208c0a4bb6052 /utils/nwztools/upgtools/fwp.c
parent92ecbd5fb8a7c8e939b1b4dde82cc6c9ba9d41af (diff)
downloadrockbox-dbeb6db1b55a50dedf17e7d78ddb6fe9eebc2a63.tar.gz
rockbox-dbeb6db1b55a50dedf17e7d78ddb6fe9eebc2a63.zip
nwztools: cleanup crypto, switch MD5 to Crypto++
We already use Crypto++ for DES anyway, and using OpenSSL is not great because of its incompatible licence. Change-Id: I78771b84c1708795a0c0c30afa5bdfe4885dea4e
Diffstat (limited to 'utils/nwztools/upgtools/fwp.c')
-rw-r--r--utils/nwztools/upgtools/fwp.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/utils/nwztools/upgtools/fwp.c b/utils/nwztools/upgtools/fwp.c
index 34c55f6e5a..7d8f8002a8 100644
--- a/utils/nwztools/upgtools/fwp.c
+++ b/utils/nwztools/upgtools/fwp.c
@@ -18,21 +18,20 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <stdio.h> 21#include <string.h>
22#include <stdlib.h> 22#include <stdlib.h>
23#include "fwp.h" 23#include "fwp.h"
24#include "misc.h" 24#include "misc.h"
25#include "mg.h" 25#include "mg.h"
26#include <string.h>
27 26
28int fwp_read(void *in, int size, void *out, uint8_t *key) 27void fwp_read(void *in, int size, void *out, uint8_t *key)
29{ 28{
30 return mg_decrypt_fw(in, size, out, key); 29 mg_decrypt_fw(in, size, out, key);
31} 30}
32 31
33int fwp_write(void *in, int size, void *out, uint8_t *key) 32void fwp_write(void *in, int size, void *out, uint8_t *key)
34{ 33{
35 return mg_encrypt_fw(in, size, out, key); 34 mg_encrypt_fw(in, size, out, key);
36} 35}
37 36
38static uint8_t g_key[NWZ_KEY_SIZE]; 37static uint8_t g_key[NWZ_KEY_SIZE];
@@ -42,7 +41,7 @@ void fwp_setkey(char key[NWZ_KEY_SIZE])
42 memcpy(g_key, key, NWZ_KEY_SIZE); 41 memcpy(g_key, key, NWZ_KEY_SIZE);
43} 42}
44 43
45int fwp_crypt(void *buf, int size, int mode) 44void fwp_crypt(void *buf, int size, int mode)
46{ 45{
47 while(size >= NWZ_KEY_SIZE) 46 while(size >= NWZ_KEY_SIZE)
48 { 47 {
@@ -54,6 +53,5 @@ int fwp_crypt(void *buf, int size, int mode)
54 size -= NWZ_KEY_SIZE; 53 size -= NWZ_KEY_SIZE;
55 } 54 }
56 if(size != 0) 55 if(size != 0)
57 abort(); 56 abort(); /* size is not a multiple of 8 */
58 return 0;
59} 57}