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 https://opensource.org/licenses/CDDL-1.0.
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]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_CRYPTO_API_H
27 #define _SYS_CRYPTO_API_H
33 #include <sys/zfs_context.h>
34 #include <sys/crypto/common.h>
36 typedef void *crypto_context_t
;
37 typedef void *crypto_ctx_template_t
;
40 * Returns the mechanism type corresponding to a mechanism name.
42 #define CRYPTO_MECH_INVALID ((uint64_t)-1)
43 extern crypto_mech_type_t
crypto_mech2id(const char *name
);
46 * Create and destroy context templates.
48 extern int crypto_create_ctx_template(crypto_mechanism_t
*mech
,
49 crypto_key_t
*key
, crypto_ctx_template_t
*tmpl
);
50 extern void crypto_destroy_ctx_template(crypto_ctx_template_t tmpl
);
53 * Single and multi-part MAC operations.
55 extern int crypto_mac(crypto_mechanism_t
*mech
, crypto_data_t
*data
,
56 crypto_key_t
*key
, crypto_ctx_template_t tmpl
, crypto_data_t
*mac
);
57 extern int crypto_mac_init(crypto_mechanism_t
*mech
, crypto_key_t
*key
,
58 crypto_ctx_template_t tmpl
, crypto_context_t
*ctxp
);
59 extern int crypto_mac_update(crypto_context_t ctx
, crypto_data_t
*data
);
60 extern int crypto_mac_final(crypto_context_t ctx
, crypto_data_t
*data
);
63 * Single-part encryption/decryption operations.
65 extern int crypto_encrypt(crypto_mechanism_t
*mech
, crypto_data_t
*plaintext
,
66 crypto_key_t
*key
, crypto_ctx_template_t tmpl
, crypto_data_t
*ciphertext
);
67 extern int crypto_decrypt(crypto_mechanism_t
*mech
, crypto_data_t
*ciphertext
,
68 crypto_key_t
*key
, crypto_ctx_template_t tmpl
, crypto_data_t
*plaintext
);
74 #endif /* _SYS_CRYPTO_API_H */