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_base - Remove partial block helpers

Now that all sha256_base users have been converted to use the API
partial block handling, remove the partial block helpers.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+17 -48
+2 -2
arch/x86/crypto/sha256_ssse3_glue.c
··· 51 51 52 52 static int _sha256_update(struct shash_desc *desc, const u8 *data, 53 53 unsigned int len, 54 - crypto_sha256_block_fn *sha256_xform) 54 + sha256_block_fn *sha256_xform) 55 55 { 56 56 int remain; 57 57 ··· 69 69 } 70 70 71 71 static int sha256_finup(struct shash_desc *desc, const u8 *data, 72 - unsigned int len, u8 *out, crypto_sha256_block_fn *sha256_xform) 72 + unsigned int len, u8 *out, sha256_block_fn *sha256_xform) 73 73 { 74 74 kernel_fpu_begin(); 75 75 sha256_base_do_finup(desc, data, len, sha256_xform);
+13 -37
include/crypto/sha256_base.h
··· 15 15 #include <linux/types.h> 16 16 #include <linux/unaligned.h> 17 17 18 - typedef void (sha256_block_fn)(struct sha256_state *sst, u8 const *src, 18 + typedef void (sha256_block_fn)(struct crypto_sha256_state *sst, u8 const *src, 19 19 int blocks); 20 - typedef void (crypto_sha256_block_fn)(struct crypto_sha256_state *sst, 21 - u8 const *src, int blocks); 22 20 23 21 static inline int sha224_base_init(struct shash_desc *desc) 24 22 { ··· 40 42 sha256_block_fn *block_fn) 41 43 { 42 44 unsigned int partial = sctx->count % SHA256_BLOCK_SIZE; 45 + struct crypto_sha256_state *state = (void *)sctx; 43 46 44 47 sctx->count += len; 45 48 ··· 54 55 data += p; 55 56 len -= p; 56 57 57 - block_fn(sctx, sctx->buf, 1); 58 + block_fn(state, sctx->buf, 1); 58 59 } 59 60 60 61 blocks = len / SHA256_BLOCK_SIZE; 61 62 len %= SHA256_BLOCK_SIZE; 62 63 63 64 if (blocks) { 64 - block_fn(sctx, data, blocks); 65 + block_fn(state, data, blocks); 65 66 data += blocks * SHA256_BLOCK_SIZE; 66 67 } 67 68 partial = 0; ··· 72 73 return 0; 73 74 } 74 75 75 - static inline int sha256_base_do_update(struct shash_desc *desc, 76 - const u8 *data, 77 - unsigned int len, 78 - sha256_block_fn *block_fn) 79 - { 80 - struct sha256_state *sctx = shash_desc_ctx(desc); 81 - 82 - return lib_sha256_base_do_update(sctx, data, len, block_fn); 83 - } 84 - 85 76 static inline int lib_sha256_base_do_update_blocks( 86 77 struct crypto_sha256_state *sctx, const u8 *data, unsigned int len, 87 - crypto_sha256_block_fn *block_fn) 78 + sha256_block_fn *block_fn) 88 79 { 89 80 unsigned int remain = len - round_down(len, SHA256_BLOCK_SIZE); 90 81 ··· 85 96 86 97 static inline int sha256_base_do_update_blocks( 87 98 struct shash_desc *desc, const u8 *data, unsigned int len, 88 - crypto_sha256_block_fn *block_fn) 99 + sha256_block_fn *block_fn) 89 100 { 90 101 return lib_sha256_base_do_update_blocks(shash_desc_ctx(desc), data, 91 102 len, block_fn); ··· 93 104 94 105 static inline int lib_sha256_base_do_finup(struct crypto_sha256_state *sctx, 95 106 const u8 *src, unsigned int len, 96 - crypto_sha256_block_fn *block_fn) 107 + sha256_block_fn *block_fn) 97 108 { 98 109 unsigned int bit_offset = SHA256_BLOCK_SIZE / 8 - 1; 99 110 union { ··· 115 126 116 127 static inline int sha256_base_do_finup(struct shash_desc *desc, 117 128 const u8 *src, unsigned int len, 118 - crypto_sha256_block_fn *block_fn) 129 + sha256_block_fn *block_fn) 119 130 { 120 131 struct crypto_sha256_state *sctx = shash_desc_ctx(desc); 121 132 ··· 133 144 static inline int lib_sha256_base_do_finalize(struct sha256_state *sctx, 134 145 sha256_block_fn *block_fn) 135 146 { 136 - const int bit_offset = SHA256_BLOCK_SIZE - sizeof(__be64); 137 - __be64 *bits = (__be64 *)(sctx->buf + bit_offset); 138 147 unsigned int partial = sctx->count % SHA256_BLOCK_SIZE; 148 + struct crypto_sha256_state *state = (void *)sctx; 139 149 140 - sctx->buf[partial++] = 0x80; 141 - if (partial > bit_offset) { 142 - memset(sctx->buf + partial, 0x0, SHA256_BLOCK_SIZE - partial); 143 - partial = 0; 144 - 145 - block_fn(sctx, sctx->buf, 1); 146 - } 147 - 148 - memset(sctx->buf + partial, 0x0, bit_offset - partial); 149 - *bits = cpu_to_be64(sctx->count << 3); 150 - block_fn(sctx, sctx->buf, 1); 151 - 152 - return 0; 150 + sctx->count -= partial; 151 + return lib_sha256_base_do_finup(state, sctx->buf, partial, block_fn); 153 152 } 154 153 155 154 static inline int sha256_base_do_finalize(struct shash_desc *desc, ··· 159 182 return 0; 160 183 } 161 184 162 - static inline int lib_sha256_base_finish(struct sha256_state *sctx, u8 *out, 163 - unsigned int digest_size) 185 + static inline void lib_sha256_base_finish(struct sha256_state *sctx, u8 *out, 186 + unsigned int digest_size) 164 187 { 165 188 __sha256_base_finish(sctx->state, out, digest_size); 166 189 memzero_explicit(sctx, sizeof(*sctx)); 167 - return 0; 168 190 } 169 191 170 192 static inline int sha256_base_finish(struct shash_desc *desc, u8 *out)
+2 -9
lib/crypto/sha256.c
··· 132 132 } 133 133 EXPORT_SYMBOL_GPL(sha256_transform_blocks); 134 134 135 - static void lib_sha256_transform_blocks(struct sha256_state *sctx, 136 - const u8 *input, int blocks) 137 - { 138 - sha256_transform_blocks((struct crypto_sha256_state *)sctx, input, 139 - blocks); 140 - } 141 - 142 135 void sha256_update(struct sha256_state *sctx, const u8 *data, unsigned int len) 143 136 { 144 - lib_sha256_base_do_update(sctx, data, len, lib_sha256_transform_blocks); 137 + lib_sha256_base_do_update(sctx, data, len, sha256_transform_blocks); 145 138 } 146 139 EXPORT_SYMBOL(sha256_update); 147 140 148 141 static void __sha256_final(struct sha256_state *sctx, u8 *out, int digest_size) 149 142 { 150 - lib_sha256_base_do_finalize(sctx, lib_sha256_transform_blocks); 143 + lib_sha256_base_do_finalize(sctx, sha256_transform_blocks); 151 144 lib_sha256_base_finish(sctx, out, digest_size); 152 145 } 153 146