root/trunk/src/libopensc/muscle.h

Revision 3080, 4.2 KB (checked in by aj, 2 years ago)

update to latest muscle code.

Line 
1/*
2 * muscle.h: Support for MuscleCard Applet from musclecard.com
3 *
4 * Copyright (C) 2006, Identity Alliance, Thomas Harning <support@identityalliance.com>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library 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 GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20#ifndef MUSCLE_H_
21#define MUSCLE_H_
22
23#include <stddef.h>
24
25#include <opensc/types.h>
26#include <opensc.h>
27#include <opensc/cardctl.h>
28
29#include "muscle-filesystem.h"
30
31#define MSC_MAX_APDU 256 /* Max APDU send/recv, used for stack allocation */
32#define MSC_MAX_PIN_LENGTH 8
33#define MSC_MAX_PIN_COMMAND_LENGTH ((1 + MSC_MAX_PIN_LENGTH) * 2)
34
35/* Currently max size handled by muscle driver is 255 ... */
36#define MSC_MAX_READ (MIN(card->reader->driver->max_recv_size,255))
37#define MSC_MAX_SEND (MIN(card->reader->driver->max_send_size,255))
38
39int msc_list_objects(sc_card_t* card, u8 next, mscfs_file_t* file);
40int msc_partial_read_object(sc_card_t *card, msc_id objectId, int offset, u8 *data, size_t dataLength);
41int msc_read_object(sc_card_t *card, msc_id objectId, int offset, u8 *data, size_t dataLength);
42int msc_create_object(sc_card_t *card, msc_id objectId, size_t objectSize, unsigned short read, unsigned short write, unsigned short deletion);
43int msc_partial_update_object(sc_card_t *card, msc_id objectId, int offset, const u8 *data, size_t dataLength);
44int msc_update_object(sc_card_t *card, msc_id objectId, int offset, const u8 *data, size_t dataLength);
45int msc_zero_object(sc_card_t *card, msc_id objectId, size_t dataLength);
46
47int msc_delete_object(sc_card_t *card, msc_id objectId, int zero);
48int msc_select_applet(sc_card_t *card, u8 *appletId, size_t appletIdLength);
49
50int msc_verify_pin(sc_card_t *card, int pinNumber, const u8 *pinValue, int pinLength, int *tries);
51void msc_verify_pin_apdu(sc_card_t *card, sc_apdu_t *apdu, u8* buffer, size_t bufferLength, int pinNumber, const u8 *pinValue, int pinLength);
52int msc_unblock_pin(sc_card_t *card, int pinNumber, const u8 *pukValue, int pukLength, int *tries);
53void msc_unblock_pin_apdu(sc_card_t *card, sc_apdu_t *apdu, u8* buffer, size_t bufferLength, int pinNumber, const u8 *pukValue, int pukLength);
54int msc_change_pin(sc_card_t *card, int pinNumber, const u8 *pinValue, int pinLength, const u8 *newPin, int newPinLength, int *tries);
55void msc_change_pin_apdu(sc_card_t *card, sc_apdu_t *apdu, u8* buffer, size_t bufferLength, int pinNumber, const u8 *pinValue, int pinLength, const u8 *newPin, int newPinLength);
56
57int msc_get_challenge(sc_card_t *card, short dataLength, short seedLength, u8 *seedData, u8* outputData);
58
59int msc_generate_keypair(sc_card_t *card, int privateKey, int publicKey, int algorithm, int keySize, int options);
60int msc_extract_rsa_public_key(sc_card_t *card,
61                        int keyLocation,
62                        int* modLength,
63                        u8** modulus,
64                        int* expLength,
65                        u8** exponent);
66int msc_extract_key(sc_card_t *card,
67                        int keyLocation);
68int msc_compute_crypt_init(sc_card_t *card,
69                        int keyLocation,
70                        int cipherMode,
71                        int cipherDirection,
72                        const u8* initData,
73                        u8* outputData,
74                        size_t dataLength,
75                        size_t* outputDataLength);
76int msc_compute_crypt_process(
77                        sc_card_t *card,
78                        int keyLocation,
79                        const u8* inputData,
80                        u8* outputData,
81                        size_t dataLength,
82                        size_t* outputDataLength);
83int msc_compute_crypt_final(
84                        sc_card_t *card,
85                        int keyLocation,
86                        const u8* inputData,
87                        u8* outputData,
88                        size_t dataLength,
89                        size_t* outputDataLength);
90int msc_compute_crypt(sc_card_t *card,
91                        int keyLocation,
92                        int cipherMode,
93                        int cipherDirection,
94                        const u8* data,
95                        u8* outputData,
96                        size_t dataLength,
97                        size_t outputDataLength);
98int msc_import_key(sc_card_t *card,
99        int keyLocation,
100        sc_cardctl_muscle_key_info_t *data);
101
102
103#endif /*MUSCLE_H_*/
Note: See TracBrowser for help on using the browser.