1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Header file for SHA hardware acceleration
5 * Copyright (c) 2012 Samsung Electronics
12 * Computes hash value of input pbuf using h/w acceleration
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
17 * 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
21 void hw_sha512(const uchar *in_addr, uint buflen, uchar *out_addr,
25 * Computes hash value of input pbuf using h/w acceleration
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
34 void hw_sha384(const uchar *in_addr, uint buflen, uchar *out_addr,
38 * Computes hash value of input pbuf using h/w acceleration
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
43 * 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
47 void hw_sha256(const uchar *in_addr, uint buflen, uchar *out_addr,
51 * Computes hash value of input pbuf using h/w acceleration
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
60 void hw_sha1(const uchar *in_addr, uint buflen, uchar *out_addr,
64 * Create the context for sha progressive hashing using h/w acceleration
66 * @algo: Pointer to the hash_algo struct
67 * @ctxp: Pointer to the pointer of the context for hashing
68 * Return: 0 if ok, -ve on error
70 int hw_sha_init(struct hash_algo *algo, void **ctxp);
73 * Update buffer for sha progressive hashing using h/w acceleration
75 * The context is freed by this function if an error occurs.
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
82 * Return: 0 if ok, -ve on error
84 int hw_sha_update(struct hash_algo *algo, void *ctx, const void *buf,
85 unsigned int size, int is_last);
88 * Copy sha hash result at destination location
90 * The context is freed after completion of hash operation or after an error.
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
96 * Return: 0 if ok, -ve on error
98 int hw_sha_finish(struct hash_algo *algo, void *ctx, void *dest_buf,