xref: /titanic_50/usr/src/common/crypto/padding/padding.h (revision 726fad2a65f16c200a03969c29cb5c86c2d427db)
1*726fad2aSDina K Nimeh /*
2*726fad2aSDina K Nimeh  * CDDL HEADER START
3*726fad2aSDina K Nimeh  *
4*726fad2aSDina K Nimeh  * The contents of this file are subject to the terms of the
5*726fad2aSDina K Nimeh  * Common Development and Distribution License (the "License").
6*726fad2aSDina K Nimeh  * You may not use this file except in compliance with the License.
7*726fad2aSDina K Nimeh  *
8*726fad2aSDina K Nimeh  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*726fad2aSDina K Nimeh  * or http://www.opensolaris.org/os/licensing.
10*726fad2aSDina K Nimeh  * See the License for the specific language governing permissions
11*726fad2aSDina K Nimeh  * and limitations under the License.
12*726fad2aSDina K Nimeh  *
13*726fad2aSDina K Nimeh  * When distributing Covered Code, include this CDDL HEADER in each
14*726fad2aSDina K Nimeh  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*726fad2aSDina K Nimeh  * If applicable, add the following below this CDDL HEADER, with the
16*726fad2aSDina K Nimeh  * fields enclosed by brackets "[]" replaced with your own identifying
17*726fad2aSDina K Nimeh  * information: Portions Copyright [yyyy] [name of copyright owner]
18*726fad2aSDina K Nimeh  *
19*726fad2aSDina K Nimeh  * CDDL HEADER END
20*726fad2aSDina K Nimeh  */
21*726fad2aSDina K Nimeh 
22*726fad2aSDina K Nimeh /*
23*726fad2aSDina K Nimeh  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
24*726fad2aSDina K Nimeh  */
25*726fad2aSDina K Nimeh 
26*726fad2aSDina K Nimeh #ifndef _PADDING_H
27*726fad2aSDina K Nimeh #define	_PADDING_H
28*726fad2aSDina K Nimeh 
29*726fad2aSDina K Nimeh #ifdef __cplusplus
30*726fad2aSDina K Nimeh extern "C" {
31*726fad2aSDina K Nimeh #endif
32*726fad2aSDina K Nimeh 
33*726fad2aSDina K Nimeh #include <sys/types.h>
34*726fad2aSDina K Nimeh 
35*726fad2aSDina K Nimeh #define	MIN_PKCS1_PADLEN	11
36*726fad2aSDina K Nimeh 
37*726fad2aSDina K Nimeh /*
38*726fad2aSDina K Nimeh  * Values for PKCS#1 method of encoding/decoding.
39*726fad2aSDina K Nimeh  */
40*726fad2aSDina K Nimeh #define	PKCS1_ENCRYPT		0x02
41*726fad2aSDina K Nimeh #define	PKCS1_DECRYPT		0x02
42*726fad2aSDina K Nimeh #define	PKCS1_SIGN		0x01
43*726fad2aSDina K Nimeh #define	PKCS1_VERIFY		0x01
44*726fad2aSDina K Nimeh 
45*726fad2aSDina K Nimeh #ifdef _KERNEL
46*726fad2aSDina K Nimeh 
47*726fad2aSDina K Nimeh #include <sys/sunddi.h>
48*726fad2aSDina K Nimeh #include <sys/crypto/common.h>
49*726fad2aSDina K Nimeh 
50*726fad2aSDina K Nimeh #define	CK_BYTE			uchar_t
51*726fad2aSDina K Nimeh #define	CK_ULONG		ulong_t
52*726fad2aSDina K Nimeh 
53*726fad2aSDina K Nimeh #define	CKR_DATA_LEN_RANGE	CRYPTO_DATA_LEN_RANGE
54*726fad2aSDina K Nimeh #define	CKR_DEVICE_ERROR	CRYPTO_DEVICE_ERROR
55*726fad2aSDina K Nimeh #define	CKR_ENCRYPTED_DATA_INVALID	CRYPTO_ENCRYPTED_DATA_INVALID
56*726fad2aSDina K Nimeh #define	CKR_SIGNATURE_INVALID	CRYPTO_SIGNATURE_INVALID
57*726fad2aSDina K Nimeh 
58*726fad2aSDina K Nimeh int knzero_random_generator(uint8_t *ran_out, size_t ran_len);
59*726fad2aSDina K Nimeh void kmemset(uint8_t *buf, char pattern, size_t len);
60*726fad2aSDina K Nimeh 
61*726fad2aSDina K Nimeh #else
62*726fad2aSDina K Nimeh 
63*726fad2aSDina K Nimeh #include <security/cryptoki.h>
64*726fad2aSDina K Nimeh #include <security/pkcs11t.h>
65*726fad2aSDina K Nimeh 
66*726fad2aSDina K Nimeh #endif	/* _KERNEL */
67*726fad2aSDina K Nimeh 
68*726fad2aSDina K Nimeh int pkcs1_encode(int method, uint8_t *databuf, size_t datalen, uint8_t *padbuf,
69*726fad2aSDina K Nimeh     size_t padbuflen);
70*726fad2aSDina K Nimeh int pkcs1_decode(int method, uint8_t *padbuf, size_t *plen);
71*726fad2aSDina K Nimeh 
72*726fad2aSDina K Nimeh int pkcs7_encode(uint8_t *databuf, size_t datalen, uint8_t *padbuf,
73*726fad2aSDina K Nimeh     size_t padbuflen, uint8_t multiple);
74*726fad2aSDina K Nimeh int pkcs7_decode(uint8_t *padbuf, size_t *plen);
75*726fad2aSDina K Nimeh 
76*726fad2aSDina K Nimeh #ifdef	__cplusplus
77*726fad2aSDina K Nimeh }
78*726fad2aSDina K Nimeh #endif
79*726fad2aSDina K Nimeh 
80*726fad2aSDina K Nimeh #endif /* _PADDING_H */
81