1*2a58b312SMartin Matuska /*
2*2a58b312SMartin Matuska  * CDDL HEADER START
3*2a58b312SMartin Matuska  *
4*2a58b312SMartin Matuska  * The contents of this file are subject to the terms of the
5*2a58b312SMartin Matuska  * Common Development and Distribution License (the "License").
6*2a58b312SMartin Matuska  * You may not use this file except in compliance with the License.
7*2a58b312SMartin Matuska  *
8*2a58b312SMartin Matuska  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*2a58b312SMartin Matuska  * or https://opensource.org/licenses/CDDL-1.0.
10*2a58b312SMartin Matuska  * See the License for the specific language governing permissions
11*2a58b312SMartin Matuska  * and limitations under the License.
12*2a58b312SMartin Matuska  *
13*2a58b312SMartin Matuska  * When distributing Covered Code, include this CDDL HEADER in each
14*2a58b312SMartin Matuska  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*2a58b312SMartin Matuska  * If applicable, add the following below this CDDL HEADER, with the
16*2a58b312SMartin Matuska  * fields enclosed by brackets "[]" replaced with your own identifying
17*2a58b312SMartin Matuska  * information: Portions Copyright [yyyy] [name of copyright owner]
18*2a58b312SMartin Matuska  *
19*2a58b312SMartin Matuska  * CDDL HEADER END
20*2a58b312SMartin Matuska  */
21*2a58b312SMartin Matuska 
22*2a58b312SMartin Matuska /*
23*2a58b312SMartin Matuska  * Copyright (c) 2022 Tino Reichardt <milky-zfs@mcmilk.de>
24*2a58b312SMartin Matuska  */
25*2a58b312SMartin Matuska 
26*2a58b312SMartin Matuska #include <sys/zio_checksum.h>
27*2a58b312SMartin Matuska #include <sys/zfs_context.h>
28*2a58b312SMartin Matuska #include <sys/zfs_impl.h>
29*2a58b312SMartin Matuska 
30*2a58b312SMartin Matuska #include <sys/blake3.h>
31*2a58b312SMartin Matuska #include <sys/sha2.h>
32*2a58b312SMartin Matuska 
33*2a58b312SMartin Matuska /*
34*2a58b312SMartin Matuska  * impl_ops - backend for implementations of algorithms
35*2a58b312SMartin Matuska  */
36*2a58b312SMartin Matuska const zfs_impl_t *impl_ops[] = {
37*2a58b312SMartin Matuska 	&zfs_blake3_ops,
38*2a58b312SMartin Matuska 	&zfs_sha256_ops,
39*2a58b312SMartin Matuska 	&zfs_sha512_ops,
40*2a58b312SMartin Matuska 	NULL
41*2a58b312SMartin Matuska };
42*2a58b312SMartin Matuska 
43*2a58b312SMartin Matuska /*
44*2a58b312SMartin Matuska  * zfs_impl_get_ops - Get the API functions for an impl backend
45*2a58b312SMartin Matuska  */
46*2a58b312SMartin Matuska const zfs_impl_t *
zfs_impl_get_ops(const char * algo)47*2a58b312SMartin Matuska zfs_impl_get_ops(const char *algo)
48*2a58b312SMartin Matuska {
49*2a58b312SMartin Matuska 	const zfs_impl_t **ops = impl_ops;
50*2a58b312SMartin Matuska 
51*2a58b312SMartin Matuska 	if (!algo || !*algo)
52*2a58b312SMartin Matuska 		return (*ops);
53*2a58b312SMartin Matuska 
54*2a58b312SMartin Matuska 	for (; *ops; ops++) {
55*2a58b312SMartin Matuska 		if (strcmp(algo, (*ops)->name) == 0)
56*2a58b312SMartin Matuska 			break;
57*2a58b312SMartin Matuska 	}
58*2a58b312SMartin Matuska 
59*2a58b312SMartin Matuska 	ASSERT3P(ops, !=, NULL);
60*2a58b312SMartin Matuska 	return (*ops);
61*2a58b312SMartin Matuska }
62