forked from L1L1/cardpeek
-
Notifications
You must be signed in to change notification settings - Fork 1
/
crypto.h
77 lines (62 loc) · 2.29 KB
/
crypto.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**********************************************************************
*
* This file is part of Cardpeek, the smart card reader utility.
*
* Copyright 2009-2013 by Alain Pannetrat <[email protected]>
*
* Cardpeek is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Cardpeek is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Cardpeek. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef CRYPTO_H
#define CRYPTO_H
#include "bytestring.h"
typedef enum {
CRYPTO_OK,
CRYPTO_ERROR_BAD_KEY_FORMAT,
CRYPTO_ERROR_UNKNOWN_KEY_TYPE,
CRYPTO_ERROR_BAD_CLEARTEXT_LENGTH,
CRYPTO_ERROR_BAD_IV_LENGTH,
CRYPTO_ERROR_UNKNOWN_PADDING_METHOD,
CRYPTO_ERROR_UNKNOWN_ALGORITHM,
CRYPTO_ERROR_UNKNOWN
} crypto_error_t;
typedef unsigned crypto_alg_t;
#define CRYPTO_ALG_DES_ECB (0x0000)
#define CRYPTO_ALG_DES_CBC (0x0001)
#define CRYPTO_ALG_DES2_EDE_ECB (0x0010)
#define CRYPTO_ALG_DES2_EDE_CBC (0x0011)
#define CRYPTO_ALG_ISO9797_M3 (0x0021)
#define CRYPTO_ALG_SHA1 (0x0030)
#define CRYPTO_PAD_ZERO (0x0000)
#define CRYPTO_PAD_OPT_80_ZERO (0x0100)
#define CRYPTO_PAD_ISO9797_P2 (0x0200)
crypto_error_t crypto_create_context(bytestring_t *ctx,
crypto_alg_t alg_type,
const bytestring_t* key_bin);
crypto_error_t crypto_encrypt(bytestring_t* dst,
const bytestring_t* ctx,
const bytestring_t* src,
const bytestring_t* iv);
crypto_error_t crypto_decrypt(bytestring_t* dst,
const bytestring_t* ctx,
const bytestring_t* src,
const bytestring_t* iv);
crypto_error_t crypto_mac(bytestring_t* dst,
const bytestring_t* ctx,
const bytestring_t* src);
crypto_error_t crypto_digest(bytestring_t* dst,
const bytestring_t* ctx,
const bytestring_t* src);
const char *crypto_stringify_error(crypto_error_t err);
#endif