Amaury Pouly | cb09e36 | 2012-11-03 02:16:01 +0100 | [diff] [blame] | 1 | /*************************************************************************** |
| 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 Pouly | 37f95f6 | 2016-10-27 23:06:16 +0200 | [diff] [blame] | 26 | #include <stddef.h> |
Amaury Pouly | cf82f20 | 2016-08-30 17:19:30 +1000 | [diff] [blame] | 27 | #include "fwp.h" |
Amaury Pouly | cb09e36 | 2012-11-03 02:16:01 +0100 | [diff] [blame] | 28 | |
| 29 | enum keysig_search_method_t |
| 30 | { |
| 31 | KEYSIG_SEARCH_NONE = 0, |
| 32 | KEYSIG_SEARCH_FIRST, |
Amaury Pouly | 5cfd4a5 | 2017-01-04 16:35:38 +0100 | [diff] [blame] | 33 | KEYSIG_SEARCH_XDIGITS = KEYSIG_SEARCH_FIRST, |
| 34 | KEYSIG_SEARCH_XDIGITS_UP, |
| 35 | KEYSIG_SEARCH_ALNUM, |
Amaury Pouly | cb09e36 | 2012-11-03 02:16:01 +0100 | [diff] [blame] | 36 | KEYSIG_SEARCH_LAST |
| 37 | }; |
| 38 | |
| 39 | /* notify returns true if the key seems ok */ |
Amaury Pouly | cf82f20 | 2016-08-30 17:19:30 +1000 | [diff] [blame] | 40 | typedef bool (*keysig_notify_fn_t)(void *user, uint8_t key[NWZ_KEY_SIZE], |
| 41 | uint8_t sig[NWZ_SIG_SIZE]); |
Amaury Pouly | cb09e36 | 2012-11-03 02:16:01 +0100 | [diff] [blame] | 42 | |
| 43 | struct keysig_search_desc_t |
| 44 | { |
| 45 | const char *name; |
| 46 | const char *comment; |
Amaury Pouly | cb09e36 | 2012-11-03 02:16:01 +0100 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | struct keysig_search_desc_t keysig_search_desc[KEYSIG_SEARCH_LAST]; |
| 50 | |
Amaury Pouly | 37f95f6 | 2016-10-27 23:06:16 +0200 | [diff] [blame] | 51 | bool 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 Pouly | cb09e36 | 2012-11-03 02:16:01 +0100 | [diff] [blame] | 54 | #endif /* __keysig_search_h__ */ |