1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2012 Amaury Pouly
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
27 int fwp_read(void *in
, int size
, void *out
, uint8_t *key
)
29 return mg_decrypt_fw(in
, size
, out
, key
);
32 int fwp_write(void *in
, int size
, void *out
, uint8_t *key
)
34 return mg_encrypt_fw(in
, size
, out
, key
);
37 static uint8_t g_key
[NWZ_KEY_SIZE
];
39 void fwp_setkey(char key
[NWZ_KEY_SIZE
])
41 memcpy(g_key
, key
, NWZ_KEY_SIZE
);
44 int fwp_crypt(void *buf
, int size
, int mode
)
46 while(size
>= NWZ_KEY_SIZE
)
49 mg_decrypt_pass(buf
, NWZ_KEY_SIZE
, buf
, g_key
);
51 mg_encrypt_pass(buf
, NWZ_KEY_SIZE
, buf
, g_key
);
57 cprintf(GREY
, "Cannot fwp_crypt non-multiple of 8!\n");