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.

Merge tag 'libcrypto-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux

Pull crypto library fixes from Eric Biggers:
"Fix a regression caused by my commits that reimplemented the sha1,
sha256, and sha512 crypto_shash algorithms on top of the library API.
Specifically, the export_core and import_core methods stopped being
supported, which broke some hardware offload drivers (such as qat)
that recently started depending on these for fallback functionality.

Later I'd like to make these drivers just use the library API for
their fallback. Then these methods won't be needed anymore. But for
now, this fixes the regression for 6.17"

* tag 'libcrypto-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux:
crypto: sha512 - Implement export_core() and import_core()
crypto: sha256 - Implement export_core() and import_core()
crypto: sha1 - Implement export_core() and import_core()

+181
+39
crypto/sha1.c
··· 49 49 return 0; 50 50 } 51 51 52 + static int __crypto_sha1_export_core(const struct sha1_ctx *ctx, void *out) 53 + { 54 + memcpy(out, ctx, offsetof(struct sha1_ctx, buf)); 55 + return 0; 56 + } 57 + 58 + static int __crypto_sha1_import_core(struct sha1_ctx *ctx, const void *in) 59 + { 60 + memcpy(ctx, in, offsetof(struct sha1_ctx, buf)); 61 + return 0; 62 + } 63 + 52 64 const u8 sha1_zero_message_hash[SHA1_DIGEST_SIZE] = { 53 65 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 54 66 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, ··· 104 92 static int crypto_sha1_import(struct shash_desc *desc, const void *in) 105 93 { 106 94 return __crypto_sha1_import(SHA1_CTX(desc), in); 95 + } 96 + 97 + static int crypto_sha1_export_core(struct shash_desc *desc, void *out) 98 + { 99 + return __crypto_sha1_export_core(SHA1_CTX(desc), out); 100 + } 101 + 102 + static int crypto_sha1_import_core(struct shash_desc *desc, const void *in) 103 + { 104 + return __crypto_sha1_import_core(SHA1_CTX(desc), in); 107 105 } 108 106 109 107 #define HMAC_SHA1_KEY(tfm) ((struct hmac_sha1_key *)crypto_shash_ctx(tfm)) ··· 165 143 return __crypto_sha1_import(&ctx->sha_ctx, in); 166 144 } 167 145 146 + static int crypto_hmac_sha1_export_core(struct shash_desc *desc, void *out) 147 + { 148 + return __crypto_sha1_export_core(&HMAC_SHA1_CTX(desc)->sha_ctx, out); 149 + } 150 + 151 + static int crypto_hmac_sha1_import_core(struct shash_desc *desc, const void *in) 152 + { 153 + struct hmac_sha1_ctx *ctx = HMAC_SHA1_CTX(desc); 154 + 155 + ctx->ostate = HMAC_SHA1_KEY(desc->tfm)->ostate; 156 + return __crypto_sha1_import_core(&ctx->sha_ctx, in); 157 + } 158 + 168 159 static struct shash_alg algs[] = { 169 160 { 170 161 .base.cra_name = "sha1", ··· 192 157 .digest = crypto_sha1_digest, 193 158 .export = crypto_sha1_export, 194 159 .import = crypto_sha1_import, 160 + .export_core = crypto_sha1_export_core, 161 + .import_core = crypto_sha1_import_core, 195 162 .descsize = sizeof(struct sha1_ctx), 196 163 .statesize = SHA1_SHASH_STATE_SIZE, 197 164 }, ··· 212 175 .digest = crypto_hmac_sha1_digest, 213 176 .export = crypto_hmac_sha1_export, 214 177 .import = crypto_hmac_sha1_import, 178 + .export_core = crypto_hmac_sha1_export_core, 179 + .import_core = crypto_hmac_sha1_import_core, 215 180 .descsize = sizeof(struct hmac_sha1_ctx), 216 181 .statesize = SHA1_SHASH_STATE_SIZE, 217 182 },
+71
crypto/sha256.c
··· 50 50 return 0; 51 51 } 52 52 53 + static int __crypto_sha256_export_core(const struct __sha256_ctx *ctx, 54 + void *out) 55 + { 56 + memcpy(out, ctx, offsetof(struct __sha256_ctx, buf)); 57 + return 0; 58 + } 59 + 60 + static int __crypto_sha256_import_core(struct __sha256_ctx *ctx, const void *in) 61 + { 62 + memcpy(ctx, in, offsetof(struct __sha256_ctx, buf)); 63 + return 0; 64 + } 65 + 53 66 /* SHA-224 */ 54 67 55 68 const u8 sha224_zero_message_hash[SHA224_DIGEST_SIZE] = { ··· 111 98 return __crypto_sha256_import(&SHA224_CTX(desc)->ctx, in); 112 99 } 113 100 101 + static int crypto_sha224_export_core(struct shash_desc *desc, void *out) 102 + { 103 + return __crypto_sha256_export_core(&SHA224_CTX(desc)->ctx, out); 104 + } 105 + 106 + static int crypto_sha224_import_core(struct shash_desc *desc, const void *in) 107 + { 108 + return __crypto_sha256_import_core(&SHA224_CTX(desc)->ctx, in); 109 + } 110 + 114 111 /* SHA-256 */ 115 112 116 113 const u8 sha256_zero_message_hash[SHA256_DIGEST_SIZE] = { ··· 167 144 static int crypto_sha256_import(struct shash_desc *desc, const void *in) 168 145 { 169 146 return __crypto_sha256_import(&SHA256_CTX(desc)->ctx, in); 147 + } 148 + 149 + static int crypto_sha256_export_core(struct shash_desc *desc, void *out) 150 + { 151 + return __crypto_sha256_export_core(&SHA256_CTX(desc)->ctx, out); 152 + } 153 + 154 + static int crypto_sha256_import_core(struct shash_desc *desc, const void *in) 155 + { 156 + return __crypto_sha256_import_core(&SHA256_CTX(desc)->ctx, in); 170 157 } 171 158 172 159 /* HMAC-SHA224 */ ··· 231 198 return __crypto_sha256_import(&ctx->ctx.sha_ctx, in); 232 199 } 233 200 201 + static int crypto_hmac_sha224_export_core(struct shash_desc *desc, void *out) 202 + { 203 + return __crypto_sha256_export_core(&HMAC_SHA224_CTX(desc)->ctx.sha_ctx, 204 + out); 205 + } 206 + 207 + static int crypto_hmac_sha224_import_core(struct shash_desc *desc, 208 + const void *in) 209 + { 210 + struct hmac_sha224_ctx *ctx = HMAC_SHA224_CTX(desc); 211 + 212 + ctx->ctx.ostate = HMAC_SHA224_KEY(desc->tfm)->key.ostate; 213 + return __crypto_sha256_import_core(&ctx->ctx.sha_ctx, in); 214 + } 215 + 234 216 /* HMAC-SHA256 */ 235 217 236 218 #define HMAC_SHA256_KEY(tfm) ((struct hmac_sha256_key *)crypto_shash_ctx(tfm)) ··· 298 250 return __crypto_sha256_import(&ctx->ctx.sha_ctx, in); 299 251 } 300 252 253 + static int crypto_hmac_sha256_export_core(struct shash_desc *desc, void *out) 254 + { 255 + return __crypto_sha256_export_core(&HMAC_SHA256_CTX(desc)->ctx.sha_ctx, 256 + out); 257 + } 258 + 259 + static int crypto_hmac_sha256_import_core(struct shash_desc *desc, 260 + const void *in) 261 + { 262 + struct hmac_sha256_ctx *ctx = HMAC_SHA256_CTX(desc); 263 + 264 + ctx->ctx.ostate = HMAC_SHA256_KEY(desc->tfm)->key.ostate; 265 + return __crypto_sha256_import_core(&ctx->ctx.sha_ctx, in); 266 + } 267 + 301 268 /* Algorithm definitions */ 302 269 303 270 static struct shash_alg algs[] = { ··· 329 266 .digest = crypto_sha224_digest, 330 267 .export = crypto_sha224_export, 331 268 .import = crypto_sha224_import, 269 + .export_core = crypto_sha224_export_core, 270 + .import_core = crypto_sha224_import_core, 332 271 .descsize = sizeof(struct sha224_ctx), 333 272 .statesize = SHA256_SHASH_STATE_SIZE, 334 273 }, ··· 347 282 .digest = crypto_sha256_digest, 348 283 .export = crypto_sha256_export, 349 284 .import = crypto_sha256_import, 285 + .export_core = crypto_sha256_export_core, 286 + .import_core = crypto_sha256_import_core, 350 287 .descsize = sizeof(struct sha256_ctx), 351 288 .statesize = SHA256_SHASH_STATE_SIZE, 352 289 }, ··· 367 300 .digest = crypto_hmac_sha224_digest, 368 301 .export = crypto_hmac_sha224_export, 369 302 .import = crypto_hmac_sha224_import, 303 + .export_core = crypto_hmac_sha224_export_core, 304 + .import_core = crypto_hmac_sha224_import_core, 370 305 .descsize = sizeof(struct hmac_sha224_ctx), 371 306 .statesize = SHA256_SHASH_STATE_SIZE, 372 307 }, ··· 387 318 .digest = crypto_hmac_sha256_digest, 388 319 .export = crypto_hmac_sha256_export, 389 320 .import = crypto_hmac_sha256_import, 321 + .export_core = crypto_hmac_sha256_export_core, 322 + .import_core = crypto_hmac_sha256_import_core, 390 323 .descsize = sizeof(struct hmac_sha256_ctx), 391 324 .statesize = SHA256_SHASH_STATE_SIZE, 392 325 },
+71
crypto/sha512.c
··· 50 50 return 0; 51 51 } 52 52 53 + static int __crypto_sha512_export_core(const struct __sha512_ctx *ctx, 54 + void *out) 55 + { 56 + memcpy(out, ctx, offsetof(struct __sha512_ctx, buf)); 57 + return 0; 58 + } 59 + 60 + static int __crypto_sha512_import_core(struct __sha512_ctx *ctx, const void *in) 61 + { 62 + memcpy(ctx, in, offsetof(struct __sha512_ctx, buf)); 63 + return 0; 64 + } 65 + 53 66 /* SHA-384 */ 54 67 55 68 const u8 sha384_zero_message_hash[SHA384_DIGEST_SIZE] = { ··· 111 98 static int crypto_sha384_import(struct shash_desc *desc, const void *in) 112 99 { 113 100 return __crypto_sha512_import(&SHA384_CTX(desc)->ctx, in); 101 + } 102 + 103 + static int crypto_sha384_export_core(struct shash_desc *desc, void *out) 104 + { 105 + return __crypto_sha512_export_core(&SHA384_CTX(desc)->ctx, out); 106 + } 107 + 108 + static int crypto_sha384_import_core(struct shash_desc *desc, const void *in) 109 + { 110 + return __crypto_sha512_import_core(&SHA384_CTX(desc)->ctx, in); 114 111 } 115 112 116 113 /* SHA-512 */ ··· 175 152 return __crypto_sha512_import(&SHA512_CTX(desc)->ctx, in); 176 153 } 177 154 155 + static int crypto_sha512_export_core(struct shash_desc *desc, void *out) 156 + { 157 + return __crypto_sha512_export_core(&SHA512_CTX(desc)->ctx, out); 158 + } 159 + 160 + static int crypto_sha512_import_core(struct shash_desc *desc, const void *in) 161 + { 162 + return __crypto_sha512_import_core(&SHA512_CTX(desc)->ctx, in); 163 + } 164 + 178 165 /* HMAC-SHA384 */ 179 166 180 167 #define HMAC_SHA384_KEY(tfm) ((struct hmac_sha384_key *)crypto_shash_ctx(tfm)) ··· 235 202 236 203 ctx->ctx.ostate = HMAC_SHA384_KEY(desc->tfm)->key.ostate; 237 204 return __crypto_sha512_import(&ctx->ctx.sha_ctx, in); 205 + } 206 + 207 + static int crypto_hmac_sha384_export_core(struct shash_desc *desc, void *out) 208 + { 209 + return __crypto_sha512_export_core(&HMAC_SHA384_CTX(desc)->ctx.sha_ctx, 210 + out); 211 + } 212 + 213 + static int crypto_hmac_sha384_import_core(struct shash_desc *desc, 214 + const void *in) 215 + { 216 + struct hmac_sha384_ctx *ctx = HMAC_SHA384_CTX(desc); 217 + 218 + ctx->ctx.ostate = HMAC_SHA384_KEY(desc->tfm)->key.ostate; 219 + return __crypto_sha512_import_core(&ctx->ctx.sha_ctx, in); 238 220 } 239 221 240 222 /* HMAC-SHA512 */ ··· 304 256 return __crypto_sha512_import(&ctx->ctx.sha_ctx, in); 305 257 } 306 258 259 + static int crypto_hmac_sha512_export_core(struct shash_desc *desc, void *out) 260 + { 261 + return __crypto_sha512_export_core(&HMAC_SHA512_CTX(desc)->ctx.sha_ctx, 262 + out); 263 + } 264 + 265 + static int crypto_hmac_sha512_import_core(struct shash_desc *desc, 266 + const void *in) 267 + { 268 + struct hmac_sha512_ctx *ctx = HMAC_SHA512_CTX(desc); 269 + 270 + ctx->ctx.ostate = HMAC_SHA512_KEY(desc->tfm)->key.ostate; 271 + return __crypto_sha512_import_core(&ctx->ctx.sha_ctx, in); 272 + } 273 + 307 274 /* Algorithm definitions */ 308 275 309 276 static struct shash_alg algs[] = { ··· 335 272 .digest = crypto_sha384_digest, 336 273 .export = crypto_sha384_export, 337 274 .import = crypto_sha384_import, 275 + .export_core = crypto_sha384_export_core, 276 + .import_core = crypto_sha384_import_core, 338 277 .descsize = sizeof(struct sha384_ctx), 339 278 .statesize = SHA512_SHASH_STATE_SIZE, 340 279 }, ··· 353 288 .digest = crypto_sha512_digest, 354 289 .export = crypto_sha512_export, 355 290 .import = crypto_sha512_import, 291 + .export_core = crypto_sha512_export_core, 292 + .import_core = crypto_sha512_import_core, 356 293 .descsize = sizeof(struct sha512_ctx), 357 294 .statesize = SHA512_SHASH_STATE_SIZE, 358 295 }, ··· 373 306 .digest = crypto_hmac_sha384_digest, 374 307 .export = crypto_hmac_sha384_export, 375 308 .import = crypto_hmac_sha384_import, 309 + .export_core = crypto_hmac_sha384_export_core, 310 + .import_core = crypto_hmac_sha384_import_core, 376 311 .descsize = sizeof(struct hmac_sha384_ctx), 377 312 .statesize = SHA512_SHASH_STATE_SIZE, 378 313 }, ··· 393 324 .digest = crypto_hmac_sha512_digest, 394 325 .export = crypto_hmac_sha512_export, 395 326 .import = crypto_hmac_sha512_import, 327 + .export_core = crypto_hmac_sha512_export_core, 328 + .import_core = crypto_hmac_sha512_import_core, 396 329 .descsize = sizeof(struct hmac_sha512_ctx), 397 330 .statesize = SHA512_SHASH_STATE_SIZE, 398 331 },