R&Y: Added DAY RTA Tapp Card and Additional BKK BEM Stored Value Card AIDs to `aid_de...
[RRG-proxmark3.git] / common / cryptorf / cryptolib.h
blob9760acdc831bcbea74c75901c8c10d1a4cb5e95d
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2010, Flavio D. Garcia, Peter van Rossum, Roel Verdult
3 // and Ronny Wichers Schreur. Radboud University Nijmegen
4 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // See LICENSE.txt for the text of the license.
17 //-----------------------------------------------------------------------------
18 // SecureMemory, CryptoMemory and CryptoRF library
19 //-----------------------------------------------------------------------------
21 #ifndef _CRYPTOLIB_H_
22 #define _CRYPTOLIB_H_
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
28 #include <stdint.h>
30 // A nibble is actually only 4 bits, but there is no such type ;)
31 typedef uint8_t nibble;
33 typedef struct {
34 uint64_t l;
35 uint64_t m;
36 uint64_t r;
37 nibble b0;
38 nibble b1;
39 nibble b1l;
40 nibble b1r;
41 nibble b1s;
42 } crypto_state_t;
43 typedef crypto_state_t *crypto_state;
45 void print_crypto_state(const char *text, crypto_state s);
46 void sm_auth(const uint8_t *Gc, const uint8_t *Ci, const uint8_t *Q, uint8_t *Ch, uint8_t *Ci_1, crypto_state s);
47 void cm_auth(const uint8_t *Gc, const uint8_t *Ci, const uint8_t *Q, uint8_t *Ch, uint8_t *Ci_1, uint8_t *Ci_2, crypto_state s);
48 void cm_encrypt(const uint8_t offset, const uint8_t len, const uint8_t *pt, uint8_t *ct, crypto_state s);
49 void cm_decrypt(const uint8_t offset, const uint8_t len, const uint8_t *ct, uint8_t *pt, crypto_state s);
50 void cm_grind_read_system_zone(const uint8_t offset, const uint8_t len, const uint8_t *pt, crypto_state s);
51 void cm_grind_set_user_zone(const uint8_t zone, crypto_state s);
52 void cm_mac(uint8_t *mac, crypto_state s);
53 void cm_password(const uint8_t *pt, uint8_t *ct, crypto_state s);
55 #ifdef __cplusplus
57 #endif
58 #endif // _CRYPTOLIB_H_