blob: 877da2f89cec5060145c63d8a6e5b4eb1d8b833d [file] [log] [blame]
Amaury Poulycb09e362012-11-03 02:16:01 +01001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2012 Amaury Pouly
11 *
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.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef __keysig_search_h__
22#define __keysig_search_h__
23
24#include <stdbool.h>
25#include <stdint.h>
Amaury Pouly37f95f62016-10-27 23:06:16 +020026#include <stddef.h>
Amaury Poulycf82f202016-08-30 17:19:30 +100027#include "fwp.h"
Amaury Poulycb09e362012-11-03 02:16:01 +010028
29enum keysig_search_method_t
30{
31 KEYSIG_SEARCH_NONE = 0,
32 KEYSIG_SEARCH_FIRST,
Amaury Pouly5cfd4a52017-01-04 16:35:38 +010033 KEYSIG_SEARCH_XDIGITS = KEYSIG_SEARCH_FIRST,
34 KEYSIG_SEARCH_XDIGITS_UP,
35 KEYSIG_SEARCH_ALNUM,
Amaury Poulycb09e362012-11-03 02:16:01 +010036 KEYSIG_SEARCH_LAST
37};
38
39/* notify returns true if the key seems ok */
Amaury Poulycf82f202016-08-30 17:19:30 +100040typedef bool (*keysig_notify_fn_t)(void *user, uint8_t key[NWZ_KEY_SIZE],
41 uint8_t sig[NWZ_SIG_SIZE]);
Amaury Poulycb09e362012-11-03 02:16:01 +010042
43struct keysig_search_desc_t
44{
45 const char *name;
46 const char *comment;
Amaury Poulycb09e362012-11-03 02:16:01 +010047};
48
49struct keysig_search_desc_t keysig_search_desc[KEYSIG_SEARCH_LAST];
50
Amaury Pouly37f95f62016-10-27 23:06:16 +020051bool keysig_search(int method, uint8_t *enc_buf, size_t buf_sz,
52 keysig_notify_fn_t notify, void *user, int nr_threads);
53
Amaury Poulycb09e362012-11-03 02:16:01 +010054#endif /* __keysig_search_h__ */