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