Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: sha256 - remove sha256_base.h

sha256_base.h is no longer used, so remove it.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Eric Biggers and committed by
Herbert Xu
5aab0177 11d7956d

-151
-151
include/crypto/sha256_base.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - /* 3 - * sha256_base.h - core logic for SHA-256 implementations 4 - * 5 - * Copyright (C) 2015 Linaro Ltd <ard.biesheuvel@linaro.org> 6 - */ 7 - 8 - #ifndef _CRYPTO_SHA256_BASE_H 9 - #define _CRYPTO_SHA256_BASE_H 10 - 11 - #include <crypto/internal/blockhash.h> 12 - #include <crypto/internal/hash.h> 13 - #include <crypto/internal/sha2.h> 14 - #include <linux/math.h> 15 - #include <linux/string.h> 16 - #include <linux/types.h> 17 - #include <linux/unaligned.h> 18 - 19 - typedef void (sha256_block_fn)(struct crypto_sha256_state *sst, u8 const *src, 20 - int blocks); 21 - 22 - static inline int sha224_base_init(struct shash_desc *desc) 23 - { 24 - struct sha256_state *sctx = shash_desc_ctx(desc); 25 - 26 - sha224_init(sctx); 27 - return 0; 28 - } 29 - 30 - static inline int sha256_base_init(struct shash_desc *desc) 31 - { 32 - struct sha256_state *sctx = shash_desc_ctx(desc); 33 - 34 - sha256_init(sctx); 35 - return 0; 36 - } 37 - 38 - static inline int lib_sha256_base_do_update(struct sha256_state *sctx, 39 - const u8 *data, 40 - unsigned int len, 41 - sha256_block_fn *block_fn) 42 - { 43 - unsigned int partial = sctx->count % SHA256_BLOCK_SIZE; 44 - 45 - sctx->count += len; 46 - BLOCK_HASH_UPDATE_BLOCKS(block_fn, &sctx->ctx, data, len, 47 - SHA256_BLOCK_SIZE, sctx->buf, partial); 48 - return 0; 49 - } 50 - 51 - static inline int lib_sha256_base_do_update_blocks( 52 - struct crypto_sha256_state *sctx, const u8 *data, unsigned int len, 53 - sha256_block_fn *block_fn) 54 - { 55 - unsigned int remain = len - round_down(len, SHA256_BLOCK_SIZE); 56 - 57 - sctx->count += len - remain; 58 - block_fn(sctx, data, len / SHA256_BLOCK_SIZE); 59 - return remain; 60 - } 61 - 62 - static inline int sha256_base_do_update_blocks( 63 - struct shash_desc *desc, const u8 *data, unsigned int len, 64 - sha256_block_fn *block_fn) 65 - { 66 - return lib_sha256_base_do_update_blocks(shash_desc_ctx(desc), data, 67 - len, block_fn); 68 - } 69 - 70 - static inline int lib_sha256_base_do_finup(struct crypto_sha256_state *sctx, 71 - const u8 *src, unsigned int len, 72 - sha256_block_fn *block_fn) 73 - { 74 - unsigned int bit_offset = SHA256_BLOCK_SIZE / 8 - 1; 75 - union { 76 - __be64 b64[SHA256_BLOCK_SIZE / 4]; 77 - u8 u8[SHA256_BLOCK_SIZE * 2]; 78 - } block = {}; 79 - 80 - if (len >= bit_offset * 8) 81 - bit_offset += SHA256_BLOCK_SIZE / 8; 82 - memcpy(&block, src, len); 83 - block.u8[len] = 0x80; 84 - sctx->count += len; 85 - block.b64[bit_offset] = cpu_to_be64(sctx->count << 3); 86 - block_fn(sctx, block.u8, (bit_offset + 1) * 8 / SHA256_BLOCK_SIZE); 87 - memzero_explicit(&block, sizeof(block)); 88 - 89 - return 0; 90 - } 91 - 92 - static inline int sha256_base_do_finup(struct shash_desc *desc, 93 - const u8 *src, unsigned int len, 94 - sha256_block_fn *block_fn) 95 - { 96 - struct crypto_sha256_state *sctx = shash_desc_ctx(desc); 97 - 98 - if (len >= SHA256_BLOCK_SIZE) { 99 - int remain; 100 - 101 - remain = lib_sha256_base_do_update_blocks(sctx, src, len, 102 - block_fn); 103 - src += len - remain; 104 - len = remain; 105 - } 106 - return lib_sha256_base_do_finup(sctx, src, len, block_fn); 107 - } 108 - 109 - static inline int lib_sha256_base_do_finalize(struct sha256_state *sctx, 110 - sha256_block_fn *block_fn) 111 - { 112 - unsigned int partial = sctx->count % SHA256_BLOCK_SIZE; 113 - struct crypto_sha256_state *state = (void *)sctx; 114 - 115 - sctx->count -= partial; 116 - return lib_sha256_base_do_finup(state, sctx->buf, partial, block_fn); 117 - } 118 - 119 - static inline int __sha256_base_finish(u32 state[SHA256_DIGEST_SIZE / 4], 120 - u8 *out, unsigned int digest_size) 121 - { 122 - __be32 *digest = (__be32 *)out; 123 - int i; 124 - 125 - for (i = 0; digest_size > 0; i++, digest_size -= sizeof(__be32)) 126 - put_unaligned_be32(state[i], digest++); 127 - return 0; 128 - } 129 - 130 - static inline void lib_sha256_base_finish(struct sha256_state *sctx, u8 *out, 131 - unsigned int digest_size) 132 - { 133 - __sha256_base_finish(sctx->state, out, digest_size); 134 - memzero_explicit(sctx, sizeof(*sctx)); 135 - } 136 - 137 - static inline int sha256_base_finish(struct shash_desc *desc, u8 *out) 138 - { 139 - unsigned int digest_size = crypto_shash_digestsize(desc->tfm); 140 - struct crypto_sha256_state *sctx = shash_desc_ctx(desc); 141 - 142 - return __sha256_base_finish(sctx->state, out, digest_size); 143 - } 144 - 145 - static inline void sha256_transform_blocks(struct crypto_sha256_state *sst, 146 - const u8 *input, int blocks) 147 - { 148 - sha256_blocks_generic(sst->state, input, blocks); 149 - } 150 - 151 - #endif /* _CRYPTO_SHA256_BASE_H */