xref: /freebsd/sys/contrib/openzfs/module/zfs/zfs_impl.c (revision 22649d4dba730d46244fd2dff4fd174903c8379f)
1 // SPDX-License-Identifier: CDDL-1.0
2 /*
3  * This file and its contents are supplied under the terms of the
4  * Common Development and Distribution License ("CDDL"), version 1.0.
5  * You may only use this file in accordance with the terms of version
6  * 1.0 of the CDDL.
7  *
8  * A full copy of the text of the CDDL should have accompanied this
9  * source.  A copy of the CDDL is also available via the Internet at
10  * https://opensource.org/license/CDDL-1.0.
11  */
12 
13 /*
14  * Copyright (c) 2022 Tino Reichardt <milky-zfs@mcmilk.de>
15  */
16 
17 #include <sys/zio_checksum.h>
18 #include <sys/zfs_context.h>
19 #include <sys/zfs_impl.h>
20 
21 #include <sys/blake3.h>
22 #include <sys/sha2.h>
23 
24 /*
25  * impl_ops - backend for implementations of algorithms
26  */
27 const zfs_impl_t *impl_ops[] = {
28 	&zfs_blake3_ops,
29 	&zfs_sha256_ops,
30 	&zfs_sha512_ops,
31 	NULL
32 };
33 
34 /*
35  * zfs_impl_get_ops - Get the API functions for an impl backend
36  */
37 const zfs_impl_t *
zfs_impl_get_ops(const char * algo)38 zfs_impl_get_ops(const char *algo)
39 {
40 	const zfs_impl_t **ops = impl_ops;
41 
42 	if (!algo || !*algo)
43 		return (*ops);
44 
45 	for (; *ops; ops++) {
46 		if (strcmp(algo, (*ops)->name) == 0)
47 			break;
48 	}
49 
50 	ASSERT3P(ops, !=, NULL);
51 	return (*ops);
52 }
53