2002-04-02 13:26:42 +00:00
|
|
|
/*
|
|
|
|
* Card profile information (internal)
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Olaf Kirch <okir@lst.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _OPENSC_PROFILE_H
|
|
|
|
#define _OPENSC_PROFILE_H
|
|
|
|
|
2002-04-19 14:23:31 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2002-04-05 13:48:00 +00:00
|
|
|
#include <opensc/pkcs15.h>
|
2003-10-13 16:13:12 +00:00
|
|
|
#include "keycache.h"
|
2002-04-02 13:26:42 +00:00
|
|
|
|
|
|
|
#ifndef SC_PKCS15_PROFILE_DIRECTORY
|
|
|
|
#define SC_PKCS15_PROFILE_DIRECTORY "/usr/lib/opensc/profiles"
|
|
|
|
#endif
|
|
|
|
#ifndef SC_PKCS15_PROFILE_SUFFIX
|
|
|
|
#define SC_PKCS15_PROFILE_SUFFIX "profile"
|
|
|
|
#endif
|
|
|
|
|
2003-10-13 16:13:12 +00:00
|
|
|
/* Obsolete */
|
2002-04-02 13:26:42 +00:00
|
|
|
struct auth_info {
|
|
|
|
struct auth_info * next;
|
|
|
|
unsigned int type; /* CHV, AUT, PRO */
|
|
|
|
unsigned int ref;
|
|
|
|
size_t key_len;
|
|
|
|
u8 key[32];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct file_info {
|
|
|
|
char * ident;
|
|
|
|
struct file_info * next;
|
|
|
|
struct sc_file * file;
|
2002-04-08 15:50:11 +00:00
|
|
|
unsigned int dont_free;
|
2002-04-02 13:26:42 +00:00
|
|
|
struct file_info * parent;
|
2003-10-13 16:13:12 +00:00
|
|
|
|
|
|
|
/* Template support */
|
|
|
|
struct file_info * instance;
|
|
|
|
struct sc_profile * base_template;
|
|
|
|
unsigned int inst_index;
|
|
|
|
sc_path_t inst_path;
|
2002-04-02 13:26:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* For now, we assume the PUK always resides
|
|
|
|
* in the same file as the PIN
|
|
|
|
*/
|
|
|
|
struct pin_info {
|
|
|
|
unsigned int id;
|
|
|
|
struct pin_info * next;
|
2003-10-13 16:13:12 +00:00
|
|
|
char * file_name; /* obsolete */
|
|
|
|
unsigned int file_offset; /* obsolete */
|
|
|
|
struct file_info * file; /* obsolete */
|
2002-04-02 13:26:42 +00:00
|
|
|
|
2003-10-13 16:13:12 +00:00
|
|
|
sc_pkcs15_pin_info_t pin;
|
2002-04-02 13:26:42 +00:00
|
|
|
};
|
|
|
|
|
2003-10-13 16:13:12 +00:00
|
|
|
typedef struct sc_macro {
|
|
|
|
char * name;
|
|
|
|
struct sc_macro * next;
|
|
|
|
scconf_list * value;
|
|
|
|
} sc_macro_t;
|
|
|
|
|
|
|
|
/* Template support.
|
|
|
|
*
|
|
|
|
* Templates are EFs or entire hierarchies of DFs/EFs.
|
|
|
|
* When instantiating a template, the file IDs of the
|
|
|
|
* EFs and DFs are combined from the value given in the
|
|
|
|
* profile, and the last octet of the pkcs15 ID.
|
|
|
|
*/
|
|
|
|
typedef struct sc_template {
|
|
|
|
char * name;
|
|
|
|
struct sc_template * next;
|
|
|
|
struct sc_profile * data;
|
|
|
|
struct file_info * file;
|
|
|
|
} sc_template_t;
|
|
|
|
|
2003-11-19 20:37:02 +00:00
|
|
|
#define SC_PKCS15INIT_MAX_OPTIONS 16
|
2002-04-02 13:26:42 +00:00
|
|
|
struct sc_profile {
|
2003-11-19 20:37:02 +00:00
|
|
|
char * name;
|
|
|
|
char * options[SC_PKCS15INIT_MAX_OPTIONS];
|
|
|
|
|
2003-10-14 09:57:29 +00:00
|
|
|
sc_card_t * card;
|
2002-04-02 13:26:42 +00:00
|
|
|
char * driver;
|
|
|
|
struct sc_pkcs15init_operations *ops;
|
|
|
|
struct sc_pkcs15init_callbacks *cbs;
|
2004-10-25 10:43:50 +00:00
|
|
|
void * dll; /* handle for dynamic modules */
|
2002-04-02 13:26:42 +00:00
|
|
|
|
2002-04-03 11:52:30 +00:00
|
|
|
struct file_info * mf_info;
|
|
|
|
struct file_info * df_info;
|
2002-04-02 13:26:42 +00:00
|
|
|
struct file_info * ef_list;
|
|
|
|
struct sc_file * df[SC_PKCS15_DF_TYPE_COUNT];
|
|
|
|
|
|
|
|
struct pin_info * pin_list;
|
|
|
|
struct auth_info * auth_list;
|
2003-10-13 16:13:12 +00:00
|
|
|
sc_template_t * template_list;
|
|
|
|
sc_macro_t * macro_list;
|
2002-04-02 13:26:42 +00:00
|
|
|
|
2003-10-13 16:13:12 +00:00
|
|
|
unsigned int pin_domains;
|
2002-04-02 13:26:42 +00:00
|
|
|
unsigned int pin_maxlen;
|
|
|
|
unsigned int pin_minlen;
|
|
|
|
unsigned int pin_pad_char;
|
|
|
|
unsigned int pin_encoding;
|
|
|
|
unsigned int pin_attempts;
|
|
|
|
unsigned int puk_attempts;
|
|
|
|
unsigned int rsa_access_flags;
|
|
|
|
unsigned int dsa_access_flags;
|
2003-10-13 16:13:12 +00:00
|
|
|
unsigned int protect_certificates;
|
2004-01-06 14:30:24 +00:00
|
|
|
unsigned int keep_public_key;
|
2002-04-02 13:26:42 +00:00
|
|
|
|
2003-11-19 20:37:02 +00:00
|
|
|
struct {
|
|
|
|
unsigned int direct_certificates;
|
|
|
|
unsigned int encode_df_length;
|
|
|
|
} pkcs15;
|
|
|
|
|
2002-04-02 13:26:42 +00:00
|
|
|
/* PKCS15 information */
|
2003-10-21 11:05:35 +00:00
|
|
|
sc_pkcs15_card_t * p15_spec; /* as given by profile */
|
|
|
|
sc_pkcs15_card_t * p15_data; /* as found on card */
|
2002-04-02 13:26:42 +00:00
|
|
|
};
|
|
|
|
|
2002-04-05 10:05:50 +00:00
|
|
|
struct sc_profile *sc_profile_new();
|
2003-11-19 20:37:02 +00:00
|
|
|
int sc_profile_load(struct sc_profile *, const char *);
|
2002-04-02 13:26:42 +00:00
|
|
|
int sc_profile_finish(struct sc_profile *);
|
2002-04-05 10:05:50 +00:00
|
|
|
void sc_profile_free(struct sc_profile *);
|
2002-04-02 13:26:42 +00:00
|
|
|
int sc_profile_build_pkcs15(struct sc_profile *);
|
|
|
|
void sc_profile_get_pin_info(struct sc_profile *,
|
|
|
|
unsigned int, struct sc_pkcs15_pin_info *);
|
|
|
|
int sc_profile_get_pin_id(struct sc_profile *,
|
|
|
|
unsigned int, unsigned int *);
|
|
|
|
int sc_profile_get_file(struct sc_profile *, const char *,
|
|
|
|
struct sc_file **);
|
|
|
|
int sc_profile_get_file_by_path(struct sc_profile *,
|
|
|
|
const struct sc_path *, struct sc_file **);
|
|
|
|
int sc_profile_get_path(struct sc_profile *,
|
|
|
|
const char *, struct sc_path *);
|
2003-10-13 16:13:12 +00:00
|
|
|
int sc_profile_get_file_in(struct sc_profile *,
|
|
|
|
const sc_path_t *, const char *, sc_file_t **);
|
|
|
|
int sc_profile_instantiate_template(struct sc_profile *,
|
|
|
|
const char *, const sc_path_t *,
|
|
|
|
const char *, const sc_pkcs15_id_t *,
|
|
|
|
sc_file_t **);
|
|
|
|
int sc_profile_add_file(struct sc_profile *,
|
|
|
|
const char *, sc_file_t *);
|
2002-04-02 13:26:42 +00:00
|
|
|
|
2002-04-19 14:23:31 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2002-04-02 13:26:42 +00:00
|
|
|
|
|
|
|
#endif /* _OPENSC_PROFILE_H */
|