1 //-----------------------------------------------------------------------------
2 // Borrowed initially from https://github.com/lumag/emv-tools/
3 // Copyright (C) 2012, 2015 Dmitry Eremin-Solenikov
4 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
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 // libopenemv - a library to work with EMV family of smart cards
19 //-----------------------------------------------------------------------------
21 #ifndef CRYPTO_BACKEND_H
22 #define CRYPTO_BACKEND_H
26 #include <stdarg.h> // va_list
29 enum crypto_algo_hash algo
;
30 void (*write
)(struct crypto_hash
*ch
, const unsigned char *buf
, size_t len
);
31 unsigned char *(*read
)(struct crypto_hash
*ch
);
32 void (*close
)(struct crypto_hash
*ch
);
33 size_t (*get_size
)(const struct crypto_hash
*ch
);
37 enum crypto_algo_pk algo
;
38 unsigned char *(*encrypt
)(const struct crypto_pk
*cp
, const unsigned char *buf
, size_t len
, size_t *clen
);
39 unsigned char *(*decrypt
)(const struct crypto_pk
*cp
, const unsigned char *buf
, size_t len
, size_t *clen
);
40 unsigned char *(*get_parameter
)(const struct crypto_pk
*cp
, unsigned param
, size_t *plen
);
41 size_t (*get_nbits
)(const struct crypto_pk
*cp
);
42 void (*close
)(struct crypto_pk
*cp
);
45 struct crypto_backend
{
46 struct crypto_hash
*(*hash_open
)(enum crypto_algo_hash hash
);
47 struct crypto_pk
*(*pk_open
)(enum crypto_algo_pk pk
, va_list vl
);
48 struct crypto_pk
*(*pk_open_priv
)(enum crypto_algo_pk pk
, va_list vl
);
49 struct crypto_pk
*(*pk_genkey
)(enum crypto_algo_pk pk
, va_list vl
);
52 struct crypto_backend
*crypto_polarssl_init(void);