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.
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.
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]
23 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
33 #include <sys/types.h>
36 #define MIN_DH_KEYLENGTH_IN_BYTES 8
37 #define MAX_DH_KEYLENGTH_IN_BYTES 512
38 #define DH_MIN_KEY_LEN 64
39 #define DH_MAX_KEY_LEN 4096
43 #include <sys/sunddi.h>
44 #include <sys/crypto/common.h>
48 #define CKR_OK CRYPTO_SUCCESS
49 #define CKR_ARGUMENTS_BAD CRYPTO_ARGUMENTS_BAD
50 #define CKR_ATTRIBUTE_TYPE_INVALID CRYPTO_ATTRIBUTE_TYPE_INVALID
51 #define CKR_ATTRIBUTE_VALUE_INVALID CRYPTO_ATTRIBUTE_VALUE_INVALID
52 #define CKR_DEVICE_ERROR CRYPTO_DEVICE_ERROR
53 #define CKR_GENERAL_ERROR CRYPTO_GENERAL_ERROR
54 #define CKR_HOST_MEMORY CRYPTO_HOST_MEMORY
55 #define CKR_KEY_SIZE_RANGE CRYPTO_KEY_SIZE_RANGE
57 int random_get_bytes(uint8_t *ran_out
, size_t ran_len
);
58 int random_get_pseudo_bytes(uint8_t *ran_out
, size_t ran_len
);
62 #include <security/cryptoki.h>
63 #include <security/pkcs11t.h>
68 /* DH key using BIGNUM representations */
70 int size
; /* key size in bits */
71 BIGNUM p
; /* p (prime) */
72 BIGNUM g
; /* g (base) */
73 BIGNUM x
; /* private value (random) */
74 BIGNUM y
; /* public value (= g^x mod p) */
77 /* DH key using byte string representations, useful for parameter lists */
79 uint32_t prime_bits
; /* size */
80 uchar_t
*prime
; /* p */
82 uchar_t
*base
; /* g */
83 uint32_t value_bits
; /* for both x and y */
84 uchar_t
*private_x
; /* x */
85 uchar_t
*public_y
; /* y */
86 int (*rfunc
)(void *, size_t); /* random function */
90 CK_RV
dh_genkey_pair(DHbytekey
*bkey
);
92 CK_RV
dh_key_derive(DHbytekey
*bkey
, uint32_t key_type
,
93 uchar_t
*secretkey
, uint32_t *secretkey_len
, int flag
);
99 #endif /* _DH_IMPL_H */