2016-05-12 14:51:24 +00:00
|
|
|
/*
|
|
|
|
* CDDL HEADER START
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the terms of the
|
|
|
|
* Common Development and Distribution License (the "License").
|
|
|
|
* You may not use this file except in compliance with the License.
|
|
|
|
*
|
|
|
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
|
|
* or http://www.opensolaris.org/os/licensing.
|
|
|
|
* See the License for the specific language governing permissions
|
|
|
|
* and limitations under the License.
|
|
|
|
*
|
|
|
|
* When distributing Covered Code, include this CDDL HEADER in each
|
|
|
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
|
|
* If applicable, add the following below this CDDL HEADER, with the
|
|
|
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
|
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
|
|
*
|
|
|
|
* CDDL HEADER END
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
|
|
|
* Use is subject to license terms.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SYS_CRYPTO_API_H
|
|
|
|
#define _SYS_CRYPTO_API_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/zfs_context.h>
|
|
|
|
#include <sys/crypto/common.h>
|
|
|
|
|
|
|
|
typedef void *crypto_context_t;
|
|
|
|
typedef void *crypto_ctx_template_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Returns the mechanism type corresponding to a mechanism name.
|
|
|
|
*/
|
|
|
|
#define CRYPTO_MECH_INVALID ((uint64_t)-1)
|
2022-01-14 23:37:55 +00:00
|
|
|
extern crypto_mech_type_t crypto_mech2id(const char *name);
|
2016-05-12 14:51:24 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Create and destroy context templates.
|
|
|
|
*/
|
|
|
|
extern int crypto_create_ctx_template(crypto_mechanism_t *mech,
|
2021-12-25 03:34:29 +00:00
|
|
|
crypto_key_t *key, crypto_ctx_template_t *tmpl);
|
2016-05-12 14:51:24 +00:00
|
|
|
extern void crypto_destroy_ctx_template(crypto_ctx_template_t tmpl);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Single and multi-part MAC operations.
|
|
|
|
*/
|
|
|
|
extern int crypto_mac(crypto_mechanism_t *mech, crypto_data_t *data,
|
2021-12-25 03:34:29 +00:00
|
|
|
crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *mac);
|
2016-05-12 14:51:24 +00:00
|
|
|
extern int crypto_mac_init(crypto_mechanism_t *mech, crypto_key_t *key,
|
2021-12-25 03:34:29 +00:00
|
|
|
crypto_ctx_template_t tmpl, crypto_context_t *ctxp);
|
2021-12-24 15:26:11 +00:00
|
|
|
extern int crypto_mac_update(crypto_context_t ctx, crypto_data_t *data);
|
|
|
|
extern int crypto_mac_final(crypto_context_t ctx, crypto_data_t *data);
|
2016-05-12 14:51:24 +00:00
|
|
|
|
|
|
|
/*
|
2021-12-25 03:00:34 +00:00
|
|
|
* Single-part encryption/decryption operations.
|
2016-05-12 14:51:24 +00:00
|
|
|
*/
|
|
|
|
extern int crypto_encrypt(crypto_mechanism_t *mech, crypto_data_t *plaintext,
|
2021-12-25 03:34:29 +00:00
|
|
|
crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *ciphertext);
|
2016-05-12 14:51:24 +00:00
|
|
|
extern int crypto_decrypt(crypto_mechanism_t *mech, crypto_data_t *ciphertext,
|
2021-12-25 03:34:29 +00:00
|
|
|
crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *plaintext);
|
2016-05-12 14:51:24 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _SYS_CRYPTO_API_H */
|