xref: /titanic_50/usr/src/common/crypto/padding/padding.h (revision 0b5ce10aee80822ecc7df77df92a5e24078ba196)
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 /*
23  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 #ifndef _PADDING_H
27 #define	_PADDING_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/types.h>
34 
35 #define	MIN_PKCS1_PADLEN	11
36 
37 /*
38  * Values for PKCS#1 method of encoding/decoding.
39  */
40 #define	PKCS1_ENCRYPT		0x02
41 #define	PKCS1_DECRYPT		0x02
42 #define	PKCS1_SIGN		0x01
43 #define	PKCS1_VERIFY		0x01
44 
45 #ifdef _KERNEL
46 
47 #include <sys/sunddi.h>
48 #include <sys/crypto/common.h>
49 
50 #define	CK_BYTE			uchar_t
51 #define	CK_ULONG		ulong_t
52 
53 #define	CKR_DATA_LEN_RANGE	CRYPTO_DATA_LEN_RANGE
54 #define	CKR_DEVICE_ERROR	CRYPTO_DEVICE_ERROR
55 #define	CKR_ENCRYPTED_DATA_INVALID	CRYPTO_ENCRYPTED_DATA_INVALID
56 #define	CKR_SIGNATURE_INVALID	CRYPTO_SIGNATURE_INVALID
57 
58 int knzero_random_generator(uint8_t *ran_out, size_t ran_len);
59 void kmemset(uint8_t *buf, char pattern, size_t len);
60 
61 #else
62 
63 #include <security/cryptoki.h>
64 #include <security/pkcs11t.h>
65 
66 #endif	/* _KERNEL */
67 
68 int pkcs1_encode(int method, uint8_t *databuf, size_t datalen, uint8_t *padbuf,
69     size_t padbuflen);
70 int pkcs1_decode(int method, uint8_t *padbuf, size_t *plen);
71 
72 int pkcs7_encode(uint8_t *databuf, size_t datalen, uint8_t *padbuf,
73     size_t padbuflen, uint8_t multiple);
74 int pkcs7_decode(uint8_t *padbuf, size_t *plen);
75 
76 #ifdef	__cplusplus
77 }
78 #endif
79 
80 #endif /* _PADDING_H */
81