- Work in progress: Almost finished (hopefully) flexible sm implementation

(untested).  struct sm_ctx needs external cipher and authentication
  implementations.  Here only routines for encryption/decryption/authentication
  with PACE are given.


git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@54 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
frankmorgner
2010-04-09 20:36:32 +00:00
parent 9d573d0398
commit 62e48e2a7c
11 changed files with 651 additions and 579 deletions

View File

@@ -16,12 +16,13 @@
* You should have received a copy of the GNU General Public License along with
* ccid. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _PACE_H
#define _PACE_H
#ifndef _CCID_PACE_H
#define _CCID_PACE_H
#include "sm.h"
#include <linux/usb/ch9.h>
#include <opensc/opensc.h>
#include <openssl/pace.h>
#ifdef __cplusplus
extern "C" {
@@ -40,10 +41,34 @@ extern "C" {
#define MAX_EF_CARDACCESS 2048
struct pace_sm_ctx {
int protocol;
/* XXX SSC is up to 16 Bytes long, not only 16 Bits */
uint16_t ssc;
const BUF_MEM *key_mac;
const BUF_MEM *key_enc;
PACE_CTX *ctx;
};
struct pace_sm_ctx *
pace_sm_ctx_create(int protocol, const BUF_MEM *key_mac,
const BUF_MEM *key_enc, PACE_CTX *ctx);
void
pace_sm_ctx_free(struct pace_sm_ctx *ctx);
void
pace_sm_ctx_clear_free(struct pace_sm_ctx *ctx);
int pace_sm_encrypt(sc_card_t *card, const struct sm_ctx *ctx,
const u8 *data, size_t datalen, u8 **enc);
int pace_sm_decrypt(sc_card_t *card, const struct sm_ctx *ctx,
const u8 *enc, size_t enclen, u8 **data);
int pace_sm_authenticate(sc_card_t *card, const struct sm_ctx *ctx,
const u8 *data, size_t datalen, u8 **outdata);
int GetReadersPACECapabilities(sc_card_t *card, const __u8
*in, __u8 **out, size_t *outlen);
int EstablishPACEChannel(sc_card_t *card, const __u8 *in,
__u8 **out, size_t *outlen, struct sm_ctx *sm_ctx);
__u8 **out, size_t *outlen, struct sm_ctx *ctx);
int pace_test(sc_card_t *card);
#ifdef __cplusplus