| // SPDX-License-Identifier: CDDL-1.0 | |
| /* | |
| * This file and its contents are supplied under the terms of the | |
| * Common Development and Distribution License ("CDDL"), version 1.0. | |
| * You may only use this file in accordance with the terms of version | |
| * 1.0 of the CDDL. | |
| * | |
| * A full copy of the text of the CDDL should have accompanied this | |
| * source. A copy of the CDDL is also available via the Internet at | |
| * https://opensource.org/license/CDDL-1.0. | |
| */ | |
| /* | |
| * 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) | |
| extern crypto_mech_type_t crypto_mech2id(const char *name); | |
| /* | |
| * Create and destroy context templates. | |
| */ | |
| extern int crypto_create_ctx_template(crypto_mechanism_t *mech, | |
| crypto_key_t *key, crypto_ctx_template_t *tmpl); | |
| 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, | |
| crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *mac); | |
| extern int crypto_mac_init(crypto_mechanism_t *mech, crypto_key_t *key, | |
| crypto_ctx_template_t tmpl, crypto_context_t *ctxp); | |
| 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); | |
| /* | |
| * Single-part encryption/decryption operations. | |
| */ | |
| extern int crypto_encrypt(crypto_mechanism_t *mech, crypto_data_t *plaintext, | |
| crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *ciphertext); | |
| extern int crypto_decrypt(crypto_mechanism_t *mech, crypto_data_t *ciphertext, | |
| crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *plaintext); | |
| #ifdef __cplusplus | |
| } | |
| #endif | |
| #endif /* _SYS_CRYPTO_API_H */ |