xref: /freebsd/usr.sbin/pkg/hash.c (revision 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
1b2654064SBaptiste Daroussin /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3b2654064SBaptiste Daroussin  *
4b2654064SBaptiste Daroussin  * Copyright (c) 2012-2014 Baptiste Daroussin <bapt@FreeBSD.org>
5b2654064SBaptiste Daroussin  * Copyright (c) 2013 Bryan Drewery <bdrewery@FreeBSD.org>
6b2654064SBaptiste Daroussin  * All rights reserved.
7b2654064SBaptiste Daroussin  *
8b2654064SBaptiste Daroussin  * Redistribution and use in source and binary forms, with or without
9b2654064SBaptiste Daroussin  * modification, are permitted provided that the following conditions
10b2654064SBaptiste Daroussin  * are met:
11b2654064SBaptiste Daroussin  * 1. Redistributions of source code must retain the above copyright
12b2654064SBaptiste Daroussin  *    notice, this list of conditions and the following disclaimer.
13b2654064SBaptiste Daroussin  * 2. Redistributions in binary form must reproduce the above copyright
14b2654064SBaptiste Daroussin  *    notice, this list of conditions and the following disclaimer in the
15b2654064SBaptiste Daroussin  *    documentation and/or other materials provided with the distribution.
16b2654064SBaptiste Daroussin  *
17b2654064SBaptiste Daroussin  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18b2654064SBaptiste Daroussin  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19b2654064SBaptiste Daroussin  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20b2654064SBaptiste Daroussin  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21b2654064SBaptiste Daroussin  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22b2654064SBaptiste Daroussin  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23b2654064SBaptiste Daroussin  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24b2654064SBaptiste Daroussin  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25b2654064SBaptiste Daroussin  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26b2654064SBaptiste Daroussin  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27b2654064SBaptiste Daroussin  * SUCH DAMAGE.
28b2654064SBaptiste Daroussin  */
29b2654064SBaptiste Daroussin 
30b2654064SBaptiste Daroussin #include <sha256.h>
31b2654064SBaptiste Daroussin #include <unistd.h>
32b2654064SBaptiste Daroussin 
33b2654064SBaptiste Daroussin #include "hash.h"
34b2654064SBaptiste Daroussin 
35e5dd5bfaSBaptiste Daroussin char *
sha256_buf(char * buf,size_t len)36e5dd5bfaSBaptiste Daroussin sha256_buf(char *buf, size_t len)
37b2654064SBaptiste Daroussin {
38b2654064SBaptiste Daroussin 
39e5dd5bfaSBaptiste Daroussin 	return (SHA256_Data(buf, len, NULL));
40b2654064SBaptiste Daroussin }
41b2654064SBaptiste Daroussin 
42e5dd5bfaSBaptiste Daroussin char *
sha256_fd(int fd)43e5dd5bfaSBaptiste Daroussin sha256_fd(int fd)
44b2654064SBaptiste Daroussin {
45b2654064SBaptiste Daroussin 
46e5dd5bfaSBaptiste Daroussin 	return (SHA256_Fd(fd, NULL));
47b2654064SBaptiste Daroussin }
48