padding.h revision 726fad2a65f16c200a03969c29cb5c86c2d427db
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh/*
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh * CDDL HEADER START
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh *
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh * The contents of this file are subject to the terms of the
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh * Common Development and Distribution License (the "License").
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh * You may not use this file except in compliance with the License.
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh *
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh * or http://www.opensolaris.org/os/licensing.
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh * See the License for the specific language governing permissions
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh * and limitations under the License.
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh *
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh * When distributing Covered Code, include this CDDL HEADER in each
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh * If applicable, add the following below this CDDL HEADER, with the
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh * fields enclosed by brackets "[]" replaced with your own identifying
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh * information: Portions Copyright [yyyy] [name of copyright owner]
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh *
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh * CDDL HEADER END
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh */
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh/*
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh */
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#ifndef _PADDING_H
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#define _PADDING_H
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#ifdef __cplusplus
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimehextern "C" {
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#endif
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#include <sys/types.h>
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#define MIN_PKCS1_PADLEN 11
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh/*
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh * Values for PKCS#1 method of encoding/decoding.
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh */
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#define PKCS1_ENCRYPT 0x02
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#define PKCS1_DECRYPT 0x02
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#define PKCS1_SIGN 0x01
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#define PKCS1_VERIFY 0x01
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#ifdef _KERNEL
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#include <sys/sunddi.h>
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#include <sys/crypto/common.h>
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#define CK_BYTE uchar_t
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#define CK_ULONG ulong_t
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#define CKR_DATA_LEN_RANGE CRYPTO_DATA_LEN_RANGE
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#define CKR_DEVICE_ERROR CRYPTO_DEVICE_ERROR
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#define CKR_ENCRYPTED_DATA_INVALID CRYPTO_ENCRYPTED_DATA_INVALID
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#define CKR_SIGNATURE_INVALID CRYPTO_SIGNATURE_INVALID
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimehint knzero_random_generator(uint8_t *ran_out, size_t ran_len);
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimehvoid kmemset(uint8_t *buf, char pattern, size_t len);
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#else
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#include <security/cryptoki.h>
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#include <security/pkcs11t.h>
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#endif /* _KERNEL */
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimehint pkcs1_encode(int method, uint8_t *databuf, size_t datalen, uint8_t *padbuf,
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh size_t padbuflen);
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimehint pkcs1_decode(int method, uint8_t *padbuf, size_t *plen);
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimehint pkcs7_encode(uint8_t *databuf, size_t datalen, uint8_t *padbuf,
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh size_t padbuflen, uint8_t multiple);
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimehint pkcs7_decode(uint8_t *padbuf, size_t *plen);
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#ifdef __cplusplus
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh}
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#endif
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh
726fad2a65f16c200a03969c29cb5c86c2d427dbDina K Nimeh#endif /* _PADDING_H */