blob: 991e496a3cb25ac9fa4ffb414a8638e6b48f50c9 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Akshay Saraswat1f9c9282013-03-20 21:00:58 +00002/*
3 * Header file for SHA hardware acceleration
4 *
5 * Copyright (c) 2012 Samsung Electronics
Akshay Saraswat1f9c9282013-03-20 21:00:58 +00006 */
7#ifndef __HW_SHA_H
8#define __HW_SHA_H
gaurav rana94e3c8c2015-02-20 12:51:46 +05309#include <hash.h>
Akshay Saraswat1f9c9282013-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
17 * 32 bytes are copied to pout[0]...pout[31]. Thus, a user
18 * should allocate at least 32 bytes at pOut in advance.
19 * @param chunk_size chunk size for sha256
20 */
21void hw_sha256(const uchar * in_addr, uint buflen,
22 uchar * out_addr, 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 * 32 bytes are copied to pout[0]...pout[31]. Thus, a user
31 * should allocate at least 32 bytes at pOut in advance.
32 * @param chunk_size chunk_size for sha1
33 */
34void hw_sha1(const uchar * in_addr, uint buflen,
35 uchar * out_addr, uint chunk_size);
gaurav rana94e3c8c2015-02-20 12:51:46 +053036
37/*
38 * Create the context for sha progressive hashing using h/w acceleration
39 *
40 * @algo: Pointer to the hash_algo struct
41 * @ctxp: Pointer to the pointer of the context for hashing
42 * @return 0 if ok, -ve on error
43 */
44int hw_sha_init(struct hash_algo *algo, void **ctxp);
45
46/*
47 * Update buffer for sha progressive hashing using h/w acceleration
48 *
49 * The context is freed by this function if an error occurs.
50 *
51 * @algo: Pointer to the hash_algo struct
52 * @ctx: Pointer to the context for hashing
53 * @buf: Pointer to the buffer being hashed
54 * @size: Size of the buffer being hashed
55 * @is_last: 1 if this is the last update; 0 otherwise
56 * @return 0 if ok, -ve on error
57 */
58int hw_sha_update(struct hash_algo *algo, void *ctx, const void *buf,
59 unsigned int size, int is_last);
60
61/*
62 * Copy sha hash result at destination location
63 *
64 * The context is freed after completion of hash operation or after an error.
65 *
66 * @algo: Pointer to the hash_algo struct
67 * @ctx: Pointer to the context for hashing
68 * @dest_buf: Pointer to the destination buffer where hash is to be copied
69 * @size: Size of the buffer being hashed
70 * @return 0 if ok, -ve on error
71 */
72int hw_sha_finish(struct hash_algo *algo, void *ctx, void *dest_buf,
73 int size);
74
Akshay Saraswat1f9c9282013-03-20 21:00:58 +000075#endif