2017-12-24 17:26:47 +08:00
|
|
|
/*
|
|
|
|
* libopenemv - a library to work with EMV family of smart cards
|
|
|
|
* Copyright (C) 2015 Dmitry Eremin-Solenikov
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CRYPTO_BACKEND_H
|
|
|
|
#define CRYPTO_BACKEND_H
|
|
|
|
|
|
|
|
#include "crypto.h"
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
struct crypto_hash {
|
2019-03-10 06:35:06 +08:00
|
|
|
enum crypto_algo_hash algo;
|
|
|
|
void (*write)(struct crypto_hash *ch, const unsigned char *buf, size_t len);
|
|
|
|
unsigned char *(*read)(struct crypto_hash *ch);
|
|
|
|
void (*close)(struct crypto_hash *ch);
|
|
|
|
size_t (*get_size)(const struct crypto_hash *ch);
|
2017-12-24 17:26:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct crypto_pk {
|
2019-03-10 06:35:06 +08:00
|
|
|
enum crypto_algo_pk algo;
|
|
|
|
unsigned char *(*encrypt)(const struct crypto_pk *cp, const unsigned char *buf, size_t len, size_t *clen);
|
|
|
|
unsigned char *(*decrypt)(const struct crypto_pk *cp, const unsigned char *buf, size_t len, size_t *clen);
|
|
|
|
unsigned char *(*get_parameter)(const struct crypto_pk *cp, unsigned param, size_t *plen);
|
|
|
|
size_t (*get_nbits)(const struct crypto_pk *cp);
|
|
|
|
void (*close)(struct crypto_pk *cp);
|
2017-12-24 17:26:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct crypto_backend {
|
2019-03-10 06:35:06 +08:00
|
|
|
struct crypto_hash *(*hash_open)(enum crypto_algo_hash hash);
|
|
|
|
struct crypto_pk *(*pk_open)(enum crypto_algo_pk pk, va_list vl);
|
|
|
|
struct crypto_pk *(*pk_open_priv)(enum crypto_algo_pk pk, va_list vl);
|
|
|
|
struct crypto_pk *(*pk_genkey)(enum crypto_algo_pk pk, va_list vl);
|
2017-12-24 17:26:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct crypto_backend *crypto_polarssl_init(void);
|
|
|
|
|
|
|
|
#endif
|