diff options
Diffstat (limited to 'utils/sbtools/crypto.h')
-rw-r--r-- | utils/sbtools/crypto.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/utils/sbtools/crypto.h b/utils/sbtools/crypto.h new file mode 100644 index 0000000000..e36900df47 --- /dev/null +++ b/utils/sbtools/crypto.h | |||
@@ -0,0 +1,57 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 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 | #include <stdio.h> | ||
22 | #include <stdint.h> | ||
23 | #include <string.h> | ||
24 | |||
25 | typedef uint8_t byte; | ||
26 | |||
27 | /* aes128.c */ | ||
28 | void xor_(byte *a, byte *b, int n); | ||
29 | void EncryptAES(byte *msg, byte *key, byte *c); | ||
30 | void DecryptAES(byte *c, byte *key, byte *m); | ||
31 | void Pretty(byte* b,int len,const char* label); | ||
32 | void cbc_mac( | ||
33 | byte *in_data, /* Input data */ | ||
34 | byte *out_data, /* Output data (or NULL) */ | ||
35 | int nr_blocks, /* Number of blocks to encrypt/decrypt (one block=16 bytes) */ | ||
36 | byte key[16], /* Key */ | ||
37 | byte iv[16], /* Initialisation Vector */ | ||
38 | byte (*out_cbc_mac)[16], /* CBC-MAC of the result (or NULL) */ | ||
39 | int encrypt /* 1 to encrypt, 0 to decrypt */ | ||
40 | ); | ||
41 | |||
42 | /* crc.c */ | ||
43 | uint32_t crc(byte *data, int size); | ||
44 | |||
45 | /* sha1.c */ | ||
46 | struct sha_1_params_t | ||
47 | { | ||
48 | uint32_t hash[5]; | ||
49 | uint64_t buffer_nr_bits; | ||
50 | uint32_t w[80]; | ||
51 | }; | ||
52 | |||
53 | void sha_1_init(struct sha_1_params_t *params); | ||
54 | void sha_1_block(struct sha_1_params_t *params, uint32_t cur_hash[5], byte *data); | ||
55 | void sha_1_update(struct sha_1_params_t *params, byte *buffer, int size); | ||
56 | void sha_1_finish(struct sha_1_params_t *params); | ||
57 | void sha_1_output(struct sha_1_params_t *params, byte *out); | ||