blob: b9bb5838102536fc08d97e4b4f55294636ea4798 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Akshay Saraswatcbd8f2c2013-03-20 21:00:58 +00002/*
3 * Header file for SHA hardware acceleration
4 *
5 * Copyright (c) 2012 Samsung Electronics
Akshay Saraswatcbd8f2c2013-03-20 21:00:58 +00006 */
7#ifndef __HW_SHA_H
8#define __HW_SHA_H
gaurav ranaef201592015-02-20 12:51:46 +05309#include <hash.h>
Akshay Saraswatcbd8f2c2013-03-20 21:00:58 +000010
11/**
12 * Computes hash value of input pbuf using h/w acceleration
13 *
14 * @param in_addr A pointer to the input buffer
15 * @param bufleni Byte length of input buffer
16 * @param out_addr A pointer to the output buffer. When complete
Joel Stanley92efc1f2021-02-17 13:50:42 +103017 * 64 bytes are copied to pout[0]...pout[63]. Thus, a user
18 * should allocate at least 64 bytes at pOut in advance.
19 * @param chunk_size chunk size for sha512
20 */
21void hw_sha512(const uchar *in_addr, uint buflen, uchar *out_addr,
22 uint chunk_size);
23
24/**
25 * Computes hash value of input pbuf using h/w acceleration
26 *
27 * @param in_addr A pointer to the input buffer
28 * @param bufleni Byte length of input buffer
29 * @param out_addr A pointer to the output buffer. When complete
30 * 48 bytes are copied to pout[0]...pout[47]. Thus, a user
31 * should allocate at least 48 bytes at pOut in advance.
32 * @param chunk_size chunk size for sha384
33 */
34void hw_sha384(const uchar *in_addr, uint buflen, uchar *out_addr,
35 uint chunk_size);
36
37/**
38 * Computes hash value of input pbuf using h/w acceleration
39 *
40 * @param in_addr A pointer to the input buffer
41 * @param bufleni Byte length of input buffer
42 * @param out_addr A pointer to the output buffer. When complete
Akshay Saraswatcbd8f2c2013-03-20 21:00:58 +000043 * 32 bytes are copied to pout[0]...pout[31]. Thus, a user
44 * should allocate at least 32 bytes at pOut in advance.
45 * @param chunk_size chunk size for sha256
46 */
Joel Stanleya9ec8f02021-02-17 13:50:40 +103047void hw_sha256(const uchar *in_addr, uint buflen, uchar *out_addr,
48 uint chunk_size);
Akshay Saraswatcbd8f2c2013-03-20 21:00:58 +000049
50/**
51 * Computes hash value of input pbuf using h/w acceleration
52 *
53 * @param in_addr A pointer to the input buffer
54 * @param bufleni Byte length of input buffer
55 * @param out_addr A pointer to the output buffer. When complete
56 * 32 bytes are copied to pout[0]...pout[31]. Thus, a user
57 * should allocate at least 32 bytes at pOut in advance.
58 * @param chunk_size chunk_size for sha1
59 */
Joel Stanleya9ec8f02021-02-17 13:50:40 +103060void hw_sha1(const uchar *in_addr, uint buflen, uchar *out_addr,
61 uint chunk_size);
gaurav ranaef201592015-02-20 12:51:46 +053062
63/*
64 * Create the context for sha progressive hashing using h/w acceleration
65 *
66 * @algo: Pointer to the hash_algo struct
67 * @ctxp: Pointer to the pointer of the context for hashing
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010068 * Return: 0 if ok, -ve on error
gaurav ranaef201592015-02-20 12:51:46 +053069 */
70int hw_sha_init(struct hash_algo *algo, void **ctxp);
71
72/*
73 * Update buffer for sha progressive hashing using h/w acceleration
74 *
75 * The context is freed by this function if an error occurs.
76 *
77 * @algo: Pointer to the hash_algo struct
78 * @ctx: Pointer to the context for hashing
79 * @buf: Pointer to the buffer being hashed
80 * @size: Size of the buffer being hashed
81 * @is_last: 1 if this is the last update; 0 otherwise
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010082 * Return: 0 if ok, -ve on error
gaurav ranaef201592015-02-20 12:51:46 +053083 */
84int hw_sha_update(struct hash_algo *algo, void *ctx, const void *buf,
Joel Stanleya9ec8f02021-02-17 13:50:40 +103085 unsigned int size, int is_last);
gaurav ranaef201592015-02-20 12:51:46 +053086
87/*
88 * Copy sha hash result at destination location
89 *
90 * The context is freed after completion of hash operation or after an error.
91 *
92 * @algo: Pointer to the hash_algo struct
93 * @ctx: Pointer to the context for hashing
94 * @dest_buf: Pointer to the destination buffer where hash is to be copied
95 * @size: Size of the buffer being hashed
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010096 * Return: 0 if ok, -ve on error
gaurav ranaef201592015-02-20 12:51:46 +053097 */
98int hw_sha_finish(struct hash_algo *algo, void *ctx, void *dest_buf,
Joel Stanleya9ec8f02021-02-17 13:50:40 +103099 int size);
gaurav ranaef201592015-02-20 12:51:46 +0530100
Akshay Saraswatcbd8f2c2013-03-20 21:00:58 +0000101#endif