1726fad2Dina K Nimeh/*
2726fad2Dina K Nimeh * CDDL HEADER START
3726fad2Dina K Nimeh *
4726fad2Dina K Nimeh * The contents of this file are subject to the terms of the
5726fad2Dina K Nimeh * Common Development and Distribution License (the "License").
6726fad2Dina K Nimeh * You may not use this file except in compliance with the License.
7726fad2Dina K Nimeh *
8726fad2Dina K Nimeh * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9726fad2Dina K Nimeh * or http://www.opensolaris.org/os/licensing.
10726fad2Dina K Nimeh * See the License for the specific language governing permissions
11726fad2Dina K Nimeh * and limitations under the License.
12726fad2Dina K Nimeh *
13726fad2Dina K Nimeh * When distributing Covered Code, include this CDDL HEADER in each
14726fad2Dina K Nimeh * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15726fad2Dina K Nimeh * If applicable, add the following below this CDDL HEADER, with the
16726fad2Dina K Nimeh * fields enclosed by brackets "[]" replaced with your own identifying
17726fad2Dina K Nimeh * information: Portions Copyright [yyyy] [name of copyright owner]
18726fad2Dina K Nimeh *
19726fad2Dina K Nimeh * CDDL HEADER END
20726fad2Dina K Nimeh */
21726fad2Dina K Nimeh
22726fad2Dina K Nimeh/*
23726fad2Dina K Nimeh * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
24726fad2Dina K Nimeh */
25726fad2Dina K Nimeh
26726fad2Dina K Nimeh#ifndef _PADDING_H
27726fad2Dina K Nimeh#define	_PADDING_H
28726fad2Dina K Nimeh
29726fad2Dina K Nimeh#ifdef __cplusplus
30726fad2Dina K Nimehextern "C" {
31726fad2Dina K Nimeh#endif
32726fad2Dina K Nimeh
33726fad2Dina K Nimeh#include <sys/types.h>
34726fad2Dina K Nimeh
35726fad2Dina K Nimeh#define	MIN_PKCS1_PADLEN	11
36726fad2Dina K Nimeh
37726fad2Dina K Nimeh/*
38726fad2Dina K Nimeh * Values for PKCS#1 method of encoding/decoding.
39726fad2Dina K Nimeh */
40726fad2Dina K Nimeh#define	PKCS1_ENCRYPT		0x02
41726fad2Dina K Nimeh#define	PKCS1_DECRYPT		0x02
42726fad2Dina K Nimeh#define	PKCS1_SIGN		0x01
43726fad2Dina K Nimeh#define	PKCS1_VERIFY		0x01
44726fad2Dina K Nimeh
45726fad2Dina K Nimeh#ifdef _KERNEL
46726fad2Dina K Nimeh
47726fad2Dina K Nimeh#include <sys/sunddi.h>
48726fad2Dina K Nimeh#include <sys/crypto/common.h>
49726fad2Dina K Nimeh
50726fad2Dina K Nimeh#define	CK_BYTE			uchar_t
51726fad2Dina K Nimeh#define	CK_ULONG		ulong_t
52726fad2Dina K Nimeh
53726fad2Dina K Nimeh#define	CKR_DATA_LEN_RANGE	CRYPTO_DATA_LEN_RANGE
54726fad2Dina K Nimeh#define	CKR_DEVICE_ERROR	CRYPTO_DEVICE_ERROR
55726fad2Dina K Nimeh#define	CKR_ENCRYPTED_DATA_INVALID	CRYPTO_ENCRYPTED_DATA_INVALID
56726fad2Dina K Nimeh#define	CKR_SIGNATURE_INVALID	CRYPTO_SIGNATURE_INVALID
57726fad2Dina K Nimeh
58726fad2Dina K Nimehint knzero_random_generator(uint8_t *ran_out, size_t ran_len);
59726fad2Dina K Nimehvoid kmemset(uint8_t *buf, char pattern, size_t len);
60726fad2Dina K Nimeh
61726fad2Dina K Nimeh#else
62726fad2Dina K Nimeh
63726fad2Dina K Nimeh#include <security/cryptoki.h>
64726fad2Dina K Nimeh#include <security/pkcs11t.h>
65726fad2Dina K Nimeh
66726fad2Dina K Nimeh#endif	/* _KERNEL */
67726fad2Dina K Nimeh
68726fad2Dina K Nimehint pkcs1_encode(int method, uint8_t *databuf, size_t datalen, uint8_t *padbuf,
69726fad2Dina K Nimeh    size_t padbuflen);
70726fad2Dina K Nimehint pkcs1_decode(int method, uint8_t *padbuf, size_t *plen);
71726fad2Dina K Nimeh
72726fad2Dina K Nimehint pkcs7_encode(uint8_t *databuf, size_t datalen, uint8_t *padbuf,
73726fad2Dina K Nimeh    size_t padbuflen, uint8_t multiple);
74726fad2Dina K Nimehint pkcs7_decode(uint8_t *padbuf, size_t *plen);
75726fad2Dina K Nimeh
76726fad2Dina K Nimeh#ifdef	__cplusplus
77726fad2Dina K Nimeh}
78726fad2Dina K Nimeh#endif
79726fad2Dina K Nimeh
80726fad2Dina K Nimeh#endif /* _PADDING_H */
81