1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
/*
* Copyright (c) 2010 Katholieke Universiteit Leuven
* Copyright 2010 Red Hat, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Author: Nikos Mavrogiannopoulos <nmav@gnutls.org>
* Red Hat author: Jan Chadima <jchadima@redhat.com>
*/
#ifndef __NCRYPT_H__
#define __NCRYPT_H__
#include <linux/ncr.h>
#define NCR_DATA_GET_LAST 1
//#define NCR_DATA_SET_APPEND 1
#define NCR_SESSION_FINAL 1
//struct ncr_key_generate_params_st;
typedef struct ncr_key_generate_params_st *ncr_key_generate_params_t;
//struct ncr_key_params_st;
typedef struct ncr_key_params_st *ncr_key_params_t;
int ncr_global_init(unsigned int flags);
void ncr_global_deinit(void);
int ncr_key_generate_params_init(ncr_key_generate_params_t *params);
int ncr_key_generate_params_deinit(ncr_key_generate_params_t params);
int ncr_key_generate_params_set_algorithm(ncr_key_generate_params_t params, ncr_algorithm_t algorithm);
int ncr_key_generate_params_set_keyflags(ncr_key_generate_params_t params, unsigned int keyflags);
int ncr_key_generate_params_set_secret_bits(ncr_key_generate_params_t params, unsigned int bits);
int ncr_key_generate_params_set_rsa_bits(ncr_key_generate_params_t params, unsigned int bits);
int ncr_key_generate_params_set_rsa_e(ncr_key_generate_params_t params, void *e, size_t e_size);
int ncr_key_generate_params_set_dsa_p_bits(ncr_key_generate_params_t params, unsigned int p_bits);
int ncr_key_generate_params_set_dsa_q_bits(ncr_key_generate_params_t params, unsigned int q_bits);
int ncr_key_generate_params_set_dh(ncr_key_generate_params_t params, void *p, size_t p_size, void *g, size_t g_size);
int ncr_key_init(ncr_key_t *key);
int ncr_key_generate(ncr_key_t key, ncr_key_generate_params_t params);
int ncr_key_generate_pair(ncr_key_t key1, ncr_key_t key2, ncr_key_generate_params_t params);
int ncr_key_derive(ncr_key_t newkey, unsigned int keyflags, ncr_key_t key, ncr_derive_t derive, ncr_key_params_t key_params);
ncr_algorithm_t ncr_key_get_algorithm(ncr_key_t key);
int ncr_key_get_flags(ncr_key_t key);
ncr_key_type_t ncr_key_get_type(ncr_key_t key);
int ncr_key_get_id(ncr_key_t key, void *id, size_t *id_size);
int ncr_key_export(ncr_key_t key, void *idata, size_t idata_size);
int ncr_key_import(ncr_key_t key, void *idata, size_t idata_size, void *id, size_t id_size, ncr_algorithm_t algorithm, unsigned int type, unsigned int flags);
int ncr_key_wrap(ncr_key_t key, ncr_wrap_algorithm_t algorithm, ncr_key_params_t params, ncr_key_t keytowrap, void *idata, size_t idata_size);
int ncr_key_unwrap(ncr_key_t key, ncr_wrap_algorithm_t algorithm, ncr_key_params_t params, ncr_key_t keytowrap, void *idata, size_t idata_size);
int ncr_key_storage_wrap(ncr_key_t keytowrap, void *idata, size_t idata_size);
int ncr_key_storage_unwrap(ncr_key_t keytowrap, void *idata, size_t idata_size);
int ncr_key_deinit(ncr_key_t key);
int ncr_masterkey_set(void *key, size_t key_size);
int ncr_key_params_init(ncr_key_params_t *key_params);
void ncr_key_params_deinit(ncr_key_params_t key_params);
int ncr_key_params_set_cipher_iv(ncr_key_params_t key_params, void* iv, unsigned int iv_size);
int ncr_key_params_set_dh_pub(ncr_key_params_t params, void *pub, size_t pub_size);
int ncr_key_params_set_rsa_type(ncr_key_params_t params, ncr_rsa_type_t type);
int ncr_key_params_set_rsa_oaep_hash(ncr_key_params_t params, ncr_algorithm_t oaep_hash);
int ncr_key_params_set_rsa_sign_hash(ncr_key_params_t params, ncr_algorithm_t sign_hash);
int ncr_key_params_set_rsa_pss_salt(ncr_key_params_t params, unsigned int pss_salt);
int ncr_key_params_set_dsa_sign_hash(ncr_key_params_t params, ncr_algorithm_t sign_hash);
int ncr_session_once_key_data(ncr_key_t key, ncr_key_params_t params, ncr_crypto_op_t op, ncr_algorithm_t algorithm, ncr_key_t input, void *output, size_t output_size);
int ncr_session_once_direct_data(ncr_key_t key, ncr_key_params_t params, ncr_crypto_op_t op, ncr_algorithm_t algorithm, void *input, size_t input_size, void *output, size_t output_size);
int ncr_session_init(ncr_session_t *session, ncr_key_t key, ncr_key_params_t key_params, ncr_crypto_op_t op, ncr_algorithm_t algorithm);
int ncr_session_update_key_data(ncr_session_t session, ncr_key_t input, void *output, size_t output_size);
int ncr_session_update_direct_data(ncr_session_t session, void *input, size_t input_size, void *output, size_t output_size);
int ncr_session_final(ncr_session_t session, void *output, size_t output_size);
#endif
|