2 * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
17 #include <crypto/scatterwalk.h>
18 #include <crypto/sha.h>
23 #define QCE_SHA_MAX_BLOCKSIZE SHA256_BLOCK_SIZE
24 #define QCE_SHA_MAX_DIGESTSIZE SHA256_DIGEST_SIZE
27 u8 authkey
[QCE_SHA_MAX_BLOCKSIZE
];
31 * struct qce_sha_reqctx - holds private ahash objects per request
32 * @buf: used during update, import and export
33 * @tmpbuf: buffer for internal use
34 * @digest: calculated digest buffer
35 * @buflen: length of the buffer
36 * @flags: operation flags
37 * @src_orig: original request sg list
38 * @nbytes_orig: original request number of bytes
39 * @src_chained: is source scatterlist chained
40 * @src_nents: source number of entries
41 * @byte_count: byte count
42 * @count: save count in states during update, import and export
43 * @first_blk: is it the first block
44 * @last_blk: is it the last block
45 * @sg: used to chain sg lists
46 * @authkey: pointer to auth key in sha ctx
47 * @authklen: auth key length
48 * @result_sg: scatterlist used for result buffer
50 struct qce_sha_reqctx
{
51 u8 buf
[QCE_SHA_MAX_BLOCKSIZE
];
52 u8 tmpbuf
[QCE_SHA_MAX_BLOCKSIZE
];
53 u8 digest
[QCE_SHA_MAX_DIGESTSIZE
];
56 struct scatterlist
*src_orig
;
57 unsigned int nbytes_orig
;
64 struct scatterlist sg
[2];
66 unsigned int authklen
;
67 struct scatterlist result_sg
;
70 static inline struct qce_alg_template
*to_ahash_tmpl(struct crypto_tfm
*tfm
)
72 struct crypto_ahash
*ahash
= __crypto_ahash_cast(tfm
);
73 struct ahash_alg
*alg
= container_of(crypto_hash_alg_common(ahash
),
74 struct ahash_alg
, halg
);
76 return container_of(alg
, struct qce_alg_template
, alg
.ahash
);
79 extern const struct qce_algo_ops ahash_ops
;