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

crypto: sha512 - Export struct sha512_state

This patch renames struct sha512_ctx and exports it as struct
sha512_state so that other sha512 implementations can use it
as the reference structure for exporting their state.

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

+13 -13
+7 -13
crypto/sha512_generic.c
··· 21 21 #include <linux/percpu.h> 22 22 #include <asm/byteorder.h> 23 23 24 - struct sha512_ctx { 25 - u64 state[8]; 26 - u32 count[4]; 27 - u8 buf[128]; 28 - }; 29 - 30 24 static DEFINE_PER_CPU(u64[80], msg_schedule); 31 25 32 26 static inline u64 Ch(u64 x, u64 y, u64 z) ··· 135 141 static int 136 142 sha512_init(struct shash_desc *desc) 137 143 { 138 - struct sha512_ctx *sctx = shash_desc_ctx(desc); 144 + struct sha512_state *sctx = shash_desc_ctx(desc); 139 145 sctx->state[0] = SHA512_H0; 140 146 sctx->state[1] = SHA512_H1; 141 147 sctx->state[2] = SHA512_H2; ··· 152 158 static int 153 159 sha384_init(struct shash_desc *desc) 154 160 { 155 - struct sha512_ctx *sctx = shash_desc_ctx(desc); 161 + struct sha512_state *sctx = shash_desc_ctx(desc); 156 162 sctx->state[0] = SHA384_H0; 157 163 sctx->state[1] = SHA384_H1; 158 164 sctx->state[2] = SHA384_H2; ··· 169 175 static int 170 176 sha512_update(struct shash_desc *desc, const u8 *data, unsigned int len) 171 177 { 172 - struct sha512_ctx *sctx = shash_desc_ctx(desc); 178 + struct sha512_state *sctx = shash_desc_ctx(desc); 173 179 174 180 unsigned int i, index, part_len; 175 181 ··· 208 214 static int 209 215 sha512_final(struct shash_desc *desc, u8 *hash) 210 216 { 211 - struct sha512_ctx *sctx = shash_desc_ctx(desc); 217 + struct sha512_state *sctx = shash_desc_ctx(desc); 212 218 static u8 padding[128] = { 0x80, }; 213 219 __be64 *dst = (__be64 *)hash; 214 220 __be32 bits[4]; ··· 234 240 dst[i] = cpu_to_be64(sctx->state[i]); 235 241 236 242 /* Zeroize sensitive information. */ 237 - memset(sctx, 0, sizeof(struct sha512_ctx)); 243 + memset(sctx, 0, sizeof(struct sha512_state)); 238 244 239 245 return 0; 240 246 } ··· 256 262 .init = sha512_init, 257 263 .update = sha512_update, 258 264 .final = sha512_final, 259 - .descsize = sizeof(struct sha512_ctx), 265 + .descsize = sizeof(struct sha512_state), 260 266 .base = { 261 267 .cra_name = "sha512", 262 268 .cra_flags = CRYPTO_ALG_TYPE_SHASH, ··· 270 276 .init = sha384_init, 271 277 .update = sha512_update, 272 278 .final = sha384_final, 273 - .descsize = sizeof(struct sha512_ctx), 279 + .descsize = sizeof(struct sha512_state), 274 280 .base = { 275 281 .cra_name = "sha384", 276 282 .cra_flags = CRYPTO_ALG_TYPE_SHASH,
+6
include/crypto/sha.h
··· 76 76 u8 buf[SHA256_BLOCK_SIZE]; 77 77 }; 78 78 79 + struct sha512_state { 80 + u64 state[8]; 81 + u32 count[4]; 82 + u8 buf[128]; 83 + }; 84 + 79 85 #endif