From c2dda95767e03af277f4d7dab1334aa10e3ee10f Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Sun, 25 Jul 2010 21:38:28 +0200 Subject: ncr_int.h -> ncr-int.h --- cryptodev_main.c | 2 +- libtomcrypt/hashes/hash_get_oid.c | 2 +- libtomcrypt/hashes/hash_memory.c | 2 +- libtomcrypt/hashes/hash_memory_multi.c | 2 +- libtomcrypt/pk/pkcs1/pkcs_1_mgf1.c | 2 +- libtomcrypt/pk/pkcs1/pkcs_1_oaep_decode.c | 2 +- libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c | 2 +- libtomcrypt/pk/pkcs1/pkcs_1_pss_decode.c | 2 +- libtomcrypt/pk/pkcs1/pkcs_1_pss_encode.c | 2 +- libtomcrypt/pk/rsa/rsa_decrypt_key.c | 2 +- libtomcrypt/pk/rsa/rsa_encrypt_key.c | 2 +- libtomcrypt/pk/rsa/rsa_export.c | 2 +- libtomcrypt/pk/rsa/rsa_sign_hash.c | 2 +- libtomcrypt/pk/rsa/rsa_verify_hash.c | 2 +- ncr-data.c | 2 +- ncr-int.h | 221 ++++++++++++++++++++++++++++++ ncr-key-storage.c | 2 +- ncr-key-wrap.c | 2 +- ncr-key.c | 2 +- ncr-limits.c | 2 +- ncr-pk.c | 2 +- ncr-sessions-direct.c | 2 +- ncr-sessions.c | 2 +- ncr.c | 2 +- ncr_int.h | 221 ------------------------------ 25 files changed, 244 insertions(+), 244 deletions(-) create mode 100644 ncr-int.h delete mode 100644 ncr_int.h diff --git a/cryptodev_main.c b/cryptodev_main.c index 89b9a02..3cb96fb 100644 --- a/cryptodev_main.c +++ b/cryptodev_main.c @@ -41,7 +41,7 @@ #include #include #include "cryptodev_int.h" -#include "ncr_int.h" +#include "ncr-int.h" #include #include "version.h" diff --git a/libtomcrypt/hashes/hash_get_oid.c b/libtomcrypt/hashes/hash_get_oid.c index c6469ba..39f4372 100644 --- a/libtomcrypt/hashes/hash_get_oid.c +++ b/libtomcrypt/hashes/hash_get_oid.c @@ -8,7 +8,7 @@ * */ #include "tomcrypt.h" -#include +#include /* Returns the OID of the hash. diff --git a/libtomcrypt/hashes/hash_memory.c b/libtomcrypt/hashes/hash_memory.c index 5ba3bc6..a416de9 100644 --- a/libtomcrypt/hashes/hash_memory.c +++ b/libtomcrypt/hashes/hash_memory.c @@ -9,7 +9,7 @@ * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" -#include +#include #include /** diff --git a/libtomcrypt/hashes/hash_memory_multi.c b/libtomcrypt/hashes/hash_memory_multi.c index d772492..a914916 100644 --- a/libtomcrypt/hashes/hash_memory_multi.c +++ b/libtomcrypt/hashes/hash_memory_multi.c @@ -10,7 +10,7 @@ */ #include "tomcrypt.h" #include -#include +#include #include /** diff --git a/libtomcrypt/pk/pkcs1/pkcs_1_mgf1.c b/libtomcrypt/pk/pkcs1/pkcs_1_mgf1.c index b09dd11..58052eb 100644 --- a/libtomcrypt/pk/pkcs1/pkcs_1_mgf1.c +++ b/libtomcrypt/pk/pkcs1/pkcs_1_mgf1.c @@ -9,7 +9,7 @@ * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" -#include +#include /** @file pkcs_1_mgf1.c diff --git a/libtomcrypt/pk/pkcs1/pkcs_1_oaep_decode.c b/libtomcrypt/pk/pkcs1/pkcs_1_oaep_decode.c index 60f76a0..5214a29 100644 --- a/libtomcrypt/pk/pkcs1/pkcs_1_oaep_decode.c +++ b/libtomcrypt/pk/pkcs1/pkcs_1_oaep_decode.c @@ -9,7 +9,7 @@ * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" -#include +#include /** @file pkcs_1_oaep_decode.c diff --git a/libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c b/libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c index c56e3b1..ef644f9 100644 --- a/libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c +++ b/libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c @@ -9,7 +9,7 @@ * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" -#include +#include /** @file pkcs_1_oaep_encode.c diff --git a/libtomcrypt/pk/pkcs1/pkcs_1_pss_decode.c b/libtomcrypt/pk/pkcs1/pkcs_1_pss_decode.c index 293d84f..4249743 100644 --- a/libtomcrypt/pk/pkcs1/pkcs_1_pss_decode.c +++ b/libtomcrypt/pk/pkcs1/pkcs_1_pss_decode.c @@ -9,7 +9,7 @@ * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" -#include +#include /** @file pkcs_1_pss_decode.c diff --git a/libtomcrypt/pk/pkcs1/pkcs_1_pss_encode.c b/libtomcrypt/pk/pkcs1/pkcs_1_pss_encode.c index d747b49..956c79e 100644 --- a/libtomcrypt/pk/pkcs1/pkcs_1_pss_encode.c +++ b/libtomcrypt/pk/pkcs1/pkcs_1_pss_encode.c @@ -9,7 +9,7 @@ * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" -#include +#include /** @file pkcs_1_pss_encode.c diff --git a/libtomcrypt/pk/rsa/rsa_decrypt_key.c b/libtomcrypt/pk/rsa/rsa_decrypt_key.c index 989c935..a8f3ac4 100644 --- a/libtomcrypt/pk/rsa/rsa_decrypt_key.c +++ b/libtomcrypt/pk/rsa/rsa_decrypt_key.c @@ -9,7 +9,7 @@ * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" -#include "ncr_int.h" +#include "ncr-int.h" /** @file rsa_decrypt_key.c diff --git a/libtomcrypt/pk/rsa/rsa_encrypt_key.c b/libtomcrypt/pk/rsa/rsa_encrypt_key.c index 4ce51a4..8d3f2db 100644 --- a/libtomcrypt/pk/rsa/rsa_encrypt_key.c +++ b/libtomcrypt/pk/rsa/rsa_encrypt_key.c @@ -9,7 +9,7 @@ * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" -#include "ncr_int.h" +#include "ncr-int.h" /** @file rsa_encrypt_key.c diff --git a/libtomcrypt/pk/rsa/rsa_export.c b/libtomcrypt/pk/rsa/rsa_export.c index 33c222d..905bb6f 100644 --- a/libtomcrypt/pk/rsa/rsa_export.c +++ b/libtomcrypt/pk/rsa/rsa_export.c @@ -9,7 +9,7 @@ * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" -#include +#include /** @file rsa_export.c Export RSA LTC_PKCS keys, Tom St Denis diff --git a/libtomcrypt/pk/rsa/rsa_sign_hash.c b/libtomcrypt/pk/rsa/rsa_sign_hash.c index 5a32d33..f27789d 100644 --- a/libtomcrypt/pk/rsa/rsa_sign_hash.c +++ b/libtomcrypt/pk/rsa/rsa_sign_hash.c @@ -9,7 +9,7 @@ * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" -#include "ncr_int.h" +#include "ncr-int.h" /** @file rsa_sign_hash.c diff --git a/libtomcrypt/pk/rsa/rsa_verify_hash.c b/libtomcrypt/pk/rsa/rsa_verify_hash.c index 20f852e..c8a113d 100644 --- a/libtomcrypt/pk/rsa/rsa_verify_hash.c +++ b/libtomcrypt/pk/rsa/rsa_verify_hash.c @@ -9,7 +9,7 @@ * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" -#include "ncr_int.h" +#include "ncr-int.h" /** @file rsa_verify_hash.c diff --git a/ncr-data.c b/ncr-data.c index 73c62c6..639637f 100644 --- a/ncr-data.c +++ b/ncr-data.c @@ -27,7 +27,7 @@ #include #include #include "ncr.h" -#include "ncr_int.h" +#include "ncr-int.h" /* must be called with data semaphore down */ static void _ncr_data_unlink_item(struct data_item_st *item) diff --git a/ncr-int.h b/ncr-int.h new file mode 100644 index 0000000..6ccbcd2 --- /dev/null +++ b/ncr-int.h @@ -0,0 +1,221 @@ +#ifndef NCR_INT_H +# define NCR_INT_H + +#include "ncr.h" +#include +#include "cryptodev_int.h" +#include + +#define KEY_DATA_MAX_SIZE 3*1024 + +#define err() printk(KERN_DEBUG"ncr: %s: %s: %d\n", __FILE__, __func__, __LINE__) + +struct algo_properties_st { + ncr_algorithm_t algo; + const char *kstr; + unsigned needs_iv:1; + unsigned is_hmac:1; + unsigned can_sign:1; + unsigned can_digest:1; + unsigned can_encrypt:1; + unsigned is_symmetric:1; + unsigned is_pk:1; + int digest_size; + /* NCR_KEY_TYPE_SECRET if for a secret key algorithm or MAC, + * NCR_KEY_TYPE_PUBLIC for a public key algorithm. + */ + ncr_key_type_t key_type; +}; + +struct session_item_st { + struct list_head list; + + const struct algo_properties_st *algorithm; + ncr_crypto_op_t op; + + /* contexts for various options. + * simpler to have them like that than + * in a union. + */ + struct cipher_data cipher; + struct ncr_pk_ctx pk; + struct hash_data hash; + + struct scatterlist *sg; + struct page **pages; + unsigned array_size; + unsigned available_pages; + struct semaphore mem_mutex; /* down when the + * values above are changed. + */ + + struct key_item_st* key; + + atomic_t refcnt; + ncr_session_t desc; +}; + +struct data_item_st { + struct list_head list; + /* This object is not protected from concurrent access. + * I see no reason to allow concurrent writes (reads are + * not an issue). + */ + struct scatterlist sg; /* points to data */ + + uint8_t* data; + size_t data_size; + size_t max_data_size; + unsigned int flags; + atomic_t refcnt; + + /* owner. The one charged with this */ + uid_t uid; + pid_t pid; + + ncr_data_t desc; +}; + +struct key_item_st { + struct list_head list; + /* This object is also not protected from concurrent access. + */ + ncr_key_type_t type; + unsigned int flags; + const struct algo_properties_st *algorithm; /* non-NULL for public/private keys */ + uint8_t key_id[MAX_KEY_ID_SIZE]; + size_t key_id_size; + + union { + struct { + uint8_t data[NCR_CIPHER_MAX_KEY_LEN]; + size_t size; + } secret; + union { + rsa_key rsa; + dsa_key dsa; + } pk; + } key; + + atomic_t refcnt; + atomic_t writer; + + /* owner. The one charged with this */ + uid_t uid; + pid_t pid; + + ncr_key_t desc; +}; + +struct list_sem_st { + struct list_head list; + struct semaphore sem; +}; + +/* all the data associated with the open descriptor + * are here. + */ +struct ncr_lists { + struct list_sem_st data; + struct list_sem_st key; + + /* sessions */ + struct list_sem_st sessions; +}; + +void* ncr_init_lists(void); +void ncr_deinit_lists(struct ncr_lists *lst); + +int ncr_ioctl(struct ncr_lists*, struct file *filp, + unsigned int cmd, unsigned long arg); + +int ncr_data_set(struct list_sem_st*, void __user* arg); +int ncr_data_get(struct list_sem_st*, void __user* arg); +int ncr_data_deinit(struct list_sem_st*, void __user* arg); +int ncr_data_init(struct list_sem_st*, void __user* arg); +void ncr_data_list_deinit(struct list_sem_st*); +struct data_item_st* ncr_data_item_get( struct list_sem_st* lst, ncr_data_t desc); +void _ncr_data_item_put( struct data_item_st* item); + +int ncr_key_init(struct list_sem_st*, void __user* arg); +int ncr_key_deinit(struct list_sem_st*, void __user* arg); +int ncr_key_export(struct list_sem_st* data_lst, + struct list_sem_st* key_lst,void __user* arg); +int ncr_key_import(struct list_sem_st* data_lst, + struct list_sem_st* key_lst,void __user* arg); +void ncr_key_list_deinit(struct list_sem_st* lst); +int ncr_key_generate(struct list_sem_st* data_lst, void __user* arg); +int ncr_key_info(struct list_sem_st*, void __user* arg); + +int ncr_key_generate_pair(struct list_sem_st* lst, void __user* arg); +int ncr_key_derive(struct list_sem_st*, void __user* arg); +int ncr_key_get_public(struct list_sem_st* lst, void __user* arg); + +int ncr_key_item_get_read(struct key_item_st**st, struct list_sem_st* lst, + ncr_key_t desc); +/* get key item for writing */ +int ncr_key_item_get_write( struct key_item_st** st, + struct list_sem_st* lst, ncr_key_t desc); +void _ncr_key_item_put( struct key_item_st* item); + +typedef enum { + LIMIT_TYPE_KEY, + LIMIT_TYPE_DATA +} limits_type_t; + +void ncr_limits_remove(uid_t uid, pid_t pid, limits_type_t type); +int ncr_limits_add_and_check(uid_t uid, pid_t pid, limits_type_t type); +void ncr_limits_init(void); +void ncr_limits_deinit(void); + +int ncr_key_wrap(struct list_sem_st* keys, void __user* arg); +int ncr_key_unwrap(struct list_sem_st*, void __user* arg); +int ncr_key_storage_wrap(struct list_sem_st* key_lst, void __user* arg); +int ncr_key_storage_unwrap(struct list_sem_st*, void __user* arg); + +/* sessions */ +struct session_item_st* ncr_session_new(struct list_sem_st* lst); +void _ncr_sessions_item_put( struct session_item_st* item); +struct session_item_st* ncr_sessions_item_get( struct list_sem_st* lst, ncr_session_t desc); +void ncr_sessions_list_deinit(struct list_sem_st* lst); + +int ncr_session_init(struct ncr_lists* lists, void __user* arg); +int ncr_session_update(struct ncr_lists* lists, void __user* arg); +int ncr_session_final(struct ncr_lists* lists, void __user* arg); +int ncr_session_once(struct ncr_lists* lists, void __user* arg); + +/* master key */ +extern struct key_item_st master_key; + +void ncr_master_key_reset(void); + +/* storage */ +int key_from_storage_data(struct key_item_st* key, const void* data, size_t data_size); +int key_to_storage_data( uint8_t** data, size_t * data_size, const struct key_item_st *key); + + +/* misc helper macros */ +inline static unsigned int key_flags_to_data(unsigned int key_flags) +{ + unsigned int flags = 0; + + if (key_flags & NCR_KEY_FLAG_EXPORTABLE) + flags |= NCR_DATA_FLAG_EXPORTABLE; + + return flags; +} + +inline static unsigned int data_flags_to_key(unsigned int data_flags) +{ + unsigned int flags = 0; + + if (data_flags & NCR_DATA_FLAG_EXPORTABLE) + flags |= NCR_KEY_FLAG_EXPORTABLE; + + return flags; +} + +const struct algo_properties_st *_ncr_algo_to_properties(ncr_algorithm_t algo); +const struct algo_properties_st *ncr_key_params_get_sign_hash(const struct algo_properties_st *algo, struct ncr_key_params_st * params); + +#endif diff --git a/ncr-key-storage.c b/ncr-key-storage.c index 90d3f74..a1788dc 100644 --- a/ncr-key-storage.c +++ b/ncr-key-storage.c @@ -25,7 +25,7 @@ #include #include #include "ncr.h" -#include "ncr_int.h" +#include "ncr-int.h" #include "cryptodev_int.h" struct packed_key { diff --git a/ncr-key-wrap.c b/ncr-key-wrap.c index 149a8ff..2edcefb 100644 --- a/ncr-key-wrap.c +++ b/ncr-key-wrap.c @@ -27,7 +27,7 @@ #include #include #include "ncr.h" -#include "ncr_int.h" +#include "ncr-int.h" #include "cryptodev_int.h" typedef uint8_t val64_t[8]; diff --git a/ncr-key.c b/ncr-key.c index db5d458..126d1bf 100644 --- a/ncr-key.c +++ b/ncr-key.c @@ -26,7 +26,7 @@ #include #include #include "ncr.h" -#include "ncr_int.h" +#include "ncr-int.h" static void ncr_key_clear(struct key_item_st* item); diff --git a/ncr-limits.c b/ncr-limits.c index 746434c..5340954 100644 --- a/ncr-limits.c +++ b/ncr-limits.c @@ -29,7 +29,7 @@ #include #include #include "ncr.h" -#include "ncr_int.h" +#include "ncr-int.h" /* arbitrary now */ static unsigned int max_per_user[] = { diff --git a/ncr-pk.c b/ncr-pk.c index 8d85a92..cb217d7 100644 --- a/ncr-pk.c +++ b/ncr-pk.c @@ -26,7 +26,7 @@ #include #include #include "ncr.h" -#include "ncr_int.h" +#include "ncr-int.h" #include static struct workqueue_struct * pk_wq = NULL; diff --git a/ncr-sessions-direct.c b/ncr-sessions-direct.c index aa4c756..97d5ad7 100644 --- a/ncr-sessions-direct.c +++ b/ncr-sessions-direct.c @@ -22,7 +22,7 @@ #include #include "cryptodev.h" #include "ncr.h" -#include "ncr_int.h" +#include "ncr-int.h" #include #include #include diff --git a/ncr-sessions.c b/ncr-sessions.c index 8137276..3202e69 100644 --- a/ncr-sessions.c +++ b/ncr-sessions.c @@ -22,7 +22,7 @@ #include #include "cryptodev.h" #include "ncr.h" -#include "ncr_int.h" +#include "ncr-int.h" #include #include #include diff --git a/ncr.c b/ncr.c index 928bf3e..4813eef 100644 --- a/ncr.c +++ b/ncr.c @@ -30,7 +30,7 @@ #include #include #include "ncr.h" -#include "ncr_int.h" +#include "ncr-int.h" #include /* This is the master wrapping key for storage of keys diff --git a/ncr_int.h b/ncr_int.h deleted file mode 100644 index 6ccbcd2..0000000 --- a/ncr_int.h +++ /dev/null @@ -1,221 +0,0 @@ -#ifndef NCR_INT_H -# define NCR_INT_H - -#include "ncr.h" -#include -#include "cryptodev_int.h" -#include - -#define KEY_DATA_MAX_SIZE 3*1024 - -#define err() printk(KERN_DEBUG"ncr: %s: %s: %d\n", __FILE__, __func__, __LINE__) - -struct algo_properties_st { - ncr_algorithm_t algo; - const char *kstr; - unsigned needs_iv:1; - unsigned is_hmac:1; - unsigned can_sign:1; - unsigned can_digest:1; - unsigned can_encrypt:1; - unsigned is_symmetric:1; - unsigned is_pk:1; - int digest_size; - /* NCR_KEY_TYPE_SECRET if for a secret key algorithm or MAC, - * NCR_KEY_TYPE_PUBLIC for a public key algorithm. - */ - ncr_key_type_t key_type; -}; - -struct session_item_st { - struct list_head list; - - const struct algo_properties_st *algorithm; - ncr_crypto_op_t op; - - /* contexts for various options. - * simpler to have them like that than - * in a union. - */ - struct cipher_data cipher; - struct ncr_pk_ctx pk; - struct hash_data hash; - - struct scatterlist *sg; - struct page **pages; - unsigned array_size; - unsigned available_pages; - struct semaphore mem_mutex; /* down when the - * values above are changed. - */ - - struct key_item_st* key; - - atomic_t refcnt; - ncr_session_t desc; -}; - -struct data_item_st { - struct list_head list; - /* This object is not protected from concurrent access. - * I see no reason to allow concurrent writes (reads are - * not an issue). - */ - struct scatterlist sg; /* points to data */ - - uint8_t* data; - size_t data_size; - size_t max_data_size; - unsigned int flags; - atomic_t refcnt; - - /* owner. The one charged with this */ - uid_t uid; - pid_t pid; - - ncr_data_t desc; -}; - -struct key_item_st { - struct list_head list; - /* This object is also not protected from concurrent access. - */ - ncr_key_type_t type; - unsigned int flags; - const struct algo_properties_st *algorithm; /* non-NULL for public/private keys */ - uint8_t key_id[MAX_KEY_ID_SIZE]; - size_t key_id_size; - - union { - struct { - uint8_t data[NCR_CIPHER_MAX_KEY_LEN]; - size_t size; - } secret; - union { - rsa_key rsa; - dsa_key dsa; - } pk; - } key; - - atomic_t refcnt; - atomic_t writer; - - /* owner. The one charged with this */ - uid_t uid; - pid_t pid; - - ncr_key_t desc; -}; - -struct list_sem_st { - struct list_head list; - struct semaphore sem; -}; - -/* all the data associated with the open descriptor - * are here. - */ -struct ncr_lists { - struct list_sem_st data; - struct list_sem_st key; - - /* sessions */ - struct list_sem_st sessions; -}; - -void* ncr_init_lists(void); -void ncr_deinit_lists(struct ncr_lists *lst); - -int ncr_ioctl(struct ncr_lists*, struct file *filp, - unsigned int cmd, unsigned long arg); - -int ncr_data_set(struct list_sem_st*, void __user* arg); -int ncr_data_get(struct list_sem_st*, void __user* arg); -int ncr_data_deinit(struct list_sem_st*, void __user* arg); -int ncr_data_init(struct list_sem_st*, void __user* arg); -void ncr_data_list_deinit(struct list_sem_st*); -struct data_item_st* ncr_data_item_get( struct list_sem_st* lst, ncr_data_t desc); -void _ncr_data_item_put( struct data_item_st* item); - -int ncr_key_init(struct list_sem_st*, void __user* arg); -int ncr_key_deinit(struct list_sem_st*, void __user* arg); -int ncr_key_export(struct list_sem_st* data_lst, - struct list_sem_st* key_lst,void __user* arg); -int ncr_key_import(struct list_sem_st* data_lst, - struct list_sem_st* key_lst,void __user* arg); -void ncr_key_list_deinit(struct list_sem_st* lst); -int ncr_key_generate(struct list_sem_st* data_lst, void __user* arg); -int ncr_key_info(struct list_sem_st*, void __user* arg); - -int ncr_key_generate_pair(struct list_sem_st* lst, void __user* arg); -int ncr_key_derive(struct list_sem_st*, void __user* arg); -int ncr_key_get_public(struct list_sem_st* lst, void __user* arg); - -int ncr_key_item_get_read(struct key_item_st**st, struct list_sem_st* lst, - ncr_key_t desc); -/* get key item for writing */ -int ncr_key_item_get_write( struct key_item_st** st, - struct list_sem_st* lst, ncr_key_t desc); -void _ncr_key_item_put( struct key_item_st* item); - -typedef enum { - LIMIT_TYPE_KEY, - LIMIT_TYPE_DATA -} limits_type_t; - -void ncr_limits_remove(uid_t uid, pid_t pid, limits_type_t type); -int ncr_limits_add_and_check(uid_t uid, pid_t pid, limits_type_t type); -void ncr_limits_init(void); -void ncr_limits_deinit(void); - -int ncr_key_wrap(struct list_sem_st* keys, void __user* arg); -int ncr_key_unwrap(struct list_sem_st*, void __user* arg); -int ncr_key_storage_wrap(struct list_sem_st* key_lst, void __user* arg); -int ncr_key_storage_unwrap(struct list_sem_st*, void __user* arg); - -/* sessions */ -struct session_item_st* ncr_session_new(struct list_sem_st* lst); -void _ncr_sessions_item_put( struct session_item_st* item); -struct session_item_st* ncr_sessions_item_get( struct list_sem_st* lst, ncr_session_t desc); -void ncr_sessions_list_deinit(struct list_sem_st* lst); - -int ncr_session_init(struct ncr_lists* lists, void __user* arg); -int ncr_session_update(struct ncr_lists* lists, void __user* arg); -int ncr_session_final(struct ncr_lists* lists, void __user* arg); -int ncr_session_once(struct ncr_lists* lists, void __user* arg); - -/* master key */ -extern struct key_item_st master_key; - -void ncr_master_key_reset(void); - -/* storage */ -int key_from_storage_data(struct key_item_st* key, const void* data, size_t data_size); -int key_to_storage_data( uint8_t** data, size_t * data_size, const struct key_item_st *key); - - -/* misc helper macros */ -inline static unsigned int key_flags_to_data(unsigned int key_flags) -{ - unsigned int flags = 0; - - if (key_flags & NCR_KEY_FLAG_EXPORTABLE) - flags |= NCR_DATA_FLAG_EXPORTABLE; - - return flags; -} - -inline static unsigned int data_flags_to_key(unsigned int data_flags) -{ - unsigned int flags = 0; - - if (data_flags & NCR_DATA_FLAG_EXPORTABLE) - flags |= NCR_KEY_FLAG_EXPORTABLE; - - return flags; -} - -const struct algo_properties_st *_ncr_algo_to_properties(ncr_algorithm_t algo); -const struct algo_properties_st *ncr_key_params_get_sign_hash(const struct algo_properties_st *algo, struct ncr_key_params_st * params); - -#endif -- cgit