xref: /titanic_41/usr/src/lib/pkcs11/pkcs11_softtoken/common/softRSA.h (revision da14cebe459d3275048785f25bd869cb09b5307f)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SOFTRSA_H
27 #define	_SOFTRSA_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #include <sys/types.h>
36 #include <security/pkcs11t.h>
37 #include <bignum.h>
38 #include "softObject.h"
39 #include "softSession.h"
40 #include "rsa_impl.h"
41 
42 
43 typedef struct soft_rsa_ctx {
44 	soft_object_t *key;
45 } soft_rsa_ctx_t;
46 
47 /*
48  * Function Prototypes.
49  */
50 
51 /* RSA */
52 
53 CK_RV soft_rsa_encrypt(soft_object_t *, CK_BYTE_PTR, uint32_t, CK_BYTE_PTR,
54 	int);
55 
56 CK_RV soft_rsa_decrypt(soft_object_t *, CK_BYTE_PTR, uint32_t, CK_BYTE_PTR);
57 
58 CK_RV soft_rsa_crypt_init_common(soft_session_t *, CK_MECHANISM_PTR,
59 	soft_object_t *, boolean_t);
60 
61 CK_RV soft_rsa_encrypt_common(soft_session_t *, CK_BYTE_PTR, CK_ULONG,
62 	CK_BYTE_PTR, CK_ULONG_PTR, CK_MECHANISM_TYPE);
63 
64 CK_RV soft_rsa_decrypt_common(soft_session_t *, CK_BYTE_PTR, CK_ULONG,
65 	CK_BYTE_PTR, CK_ULONG_PTR, CK_MECHANISM_TYPE);
66 
67 CK_RV soft_rsa_sign_verify_init_common(soft_session_t *, CK_MECHANISM_PTR,
68 	soft_object_t *, boolean_t);
69 
70 CK_RV soft_rsa_verify_common(soft_session_t *, CK_BYTE_PTR, CK_ULONG,
71 	CK_BYTE_PTR, CK_ULONG, CK_MECHANISM_TYPE);
72 
73 CK_RV soft_rsa_sign_common(soft_session_t *, CK_BYTE_PTR, CK_ULONG,
74 	CK_BYTE_PTR, CK_ULONG_PTR, CK_MECHANISM_TYPE);
75 
76 CK_RV soft_rsa_digest_sign_common(soft_session_t *, CK_BYTE_PTR,
77     CK_ULONG, CK_BYTE_PTR, CK_ULONG_PTR, CK_MECHANISM_TYPE, boolean_t);
78 
79 CK_RV soft_rsa_digest_verify_common(soft_session_t *, CK_BYTE_PTR,
80     CK_ULONG, CK_BYTE_PTR, CK_ULONG, CK_MECHANISM_TYPE, boolean_t);
81 
82 CK_RV soft_rsa_genkey_pair(soft_object_t *, soft_object_t *);
83 
84 CK_RV soft_rsa_verify_recover(soft_session_t *, CK_BYTE_PTR, CK_ULONG,
85 	CK_BYTE_PTR, CK_ULONG_PTR);
86 
87 
88 #ifdef	__cplusplus
89 }
90 #endif
91 
92 #endif /* _SOFTRSA_H */
93