Merge tag 'libcrypto-updates-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux
Pull crypto library updates from Eric Biggers:
"This is the main crypto library pull request for 6.17. The main focus
this cycle is on reorganizing the SHA-1 and SHA-2 code, providing
high-quality library APIs for SHA-1 and SHA-2 including HMAC support,
and establishing conventions for lib/crypto/ going forward:
- Migrate the SHA-1 and SHA-512 code (and also SHA-384 which shares
most of the SHA-512 code) into lib/crypto/. This includes both the
generic and architecture-optimized code. Greatly simplify how the
architecture-optimized code is integrated. Add an easy-to-use
library API for each SHA variant, including HMAC support. Finally,
reimplement the crypto_shash support on top of the library API.
- Apply the same reorganization to the SHA-256 code (and also SHA-224
which shares most of the SHA-256 code). This is a somewhat smaller
change, due to my earlier work on SHA-256. But this brings in all
the same additional improvements that I made for SHA-1 and SHA-512.
There are also some smaller changes:
- Move the architecture-optimized ChaCha, Poly1305, and BLAKE2s code
from arch/$(SRCARCH)/lib/crypto/ to lib/crypto/$(SRCARCH)/. For
these algorithms it's just a move, not a full reorganization yet.
- Fix the MIPS chacha-core.S to build with the clang assembler.
- Fix the Poly1305 functions to work in all contexts.
- Fix a performance regression in the x86_64 Poly1305 code.
- Clean up the x86_64 SHA-NI optimized SHA-1 assembly code.
Note that since the new organization of the SHA code is much simpler,
the diffstat of this pull request is negative, despite the addition of
new fully-documented library APIs for multiple SHA and HMAC-SHA
variants.
These APIs will allow further simplifications across the kernel as
users start using them instead of the old-school crypto API. (I've
already written a lot of such conversion patches, removing over 1000
more lines of code. But most of those will target 6.18 or later)"
* tag 'libcrypto-updates-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux: (67 commits)
lib/crypto: arm64/sha512-ce: Drop compatibility macros for older binutils
lib/crypto: x86/sha1-ni: Convert to use rounds macros
lib/crypto: x86/sha1-ni: Minor optimizations and cleanup
crypto: sha1 - Remove sha1_base.h
lib/crypto: x86/sha1: Migrate optimized code into library
lib/crypto: sparc/sha1: Migrate optimized code into library
lib/crypto: s390/sha1: Migrate optimized code into library
lib/crypto: powerpc/sha1: Migrate optimized code into library
lib/crypto: mips/sha1: Migrate optimized code into library
lib/crypto: arm64/sha1: Migrate optimized code into library
lib/crypto: arm/sha1: Migrate optimized code into library
crypto: sha1 - Use same state format as legacy drivers
crypto: sha1 - Wrap library and add HMAC support
lib/crypto: sha1: Add HMAC support
lib/crypto: sha1: Add SHA-1 library functions
lib/crypto: sha1: Rename sha1_init() to sha1_init_raw()
crypto: x86/sha1 - Rename conflicting symbol
lib/crypto: sha2: Add hmac_sha*_init_usingrawkey()
lib/crypto: arm/poly1305: Remove unneeded empty weak function
lib/crypto: x86/poly1305: Fix performance regression on short messages
...
This commit is contained in:
+1
-1
@@ -304,7 +304,7 @@ int bpf_prog_calc_tag(struct bpf_prog *fp)
|
||||
if (!raw)
|
||||
return -ENOMEM;
|
||||
|
||||
sha1_init(digest);
|
||||
sha1_init_raw(digest);
|
||||
memset(ws, 0, sizeof(ws));
|
||||
|
||||
/* We need to take out the map fd for the digest calculation
|
||||
|
||||
+5
-5
@@ -751,7 +751,7 @@ int kexec_add_buffer(struct kexec_buf *kbuf)
|
||||
/* Calculate and store the digest of segments */
|
||||
static int kexec_calculate_store_digests(struct kimage *image)
|
||||
{
|
||||
struct sha256_state state;
|
||||
struct sha256_ctx sctx;
|
||||
int ret = 0, i, j, zero_buf_sz, sha_region_sz;
|
||||
size_t nullsz;
|
||||
u8 digest[SHA256_DIGEST_SIZE];
|
||||
@@ -770,7 +770,7 @@ static int kexec_calculate_store_digests(struct kimage *image)
|
||||
if (!sha_regions)
|
||||
return -ENOMEM;
|
||||
|
||||
sha256_init(&state);
|
||||
sha256_init(&sctx);
|
||||
|
||||
for (j = i = 0; i < image->nr_segments; i++) {
|
||||
struct kexec_segment *ksegment;
|
||||
@@ -796,7 +796,7 @@ static int kexec_calculate_store_digests(struct kimage *image)
|
||||
if (check_ima_segment_index(image, i))
|
||||
continue;
|
||||
|
||||
sha256_update(&state, ksegment->kbuf, ksegment->bufsz);
|
||||
sha256_update(&sctx, ksegment->kbuf, ksegment->bufsz);
|
||||
|
||||
/*
|
||||
* Assume rest of the buffer is filled with zero and
|
||||
@@ -808,7 +808,7 @@ static int kexec_calculate_store_digests(struct kimage *image)
|
||||
|
||||
if (bytes > zero_buf_sz)
|
||||
bytes = zero_buf_sz;
|
||||
sha256_update(&state, zero_buf, bytes);
|
||||
sha256_update(&sctx, zero_buf, bytes);
|
||||
nullsz -= bytes;
|
||||
}
|
||||
|
||||
@@ -817,7 +817,7 @@ static int kexec_calculate_store_digests(struct kimage *image)
|
||||
j++;
|
||||
}
|
||||
|
||||
sha256_final(&state, digest);
|
||||
sha256_final(&sctx, digest);
|
||||
|
||||
ret = kexec_purgatory_get_set_symbol(image, "purgatory_sha_regions",
|
||||
sha_regions, sha_region_sz, 0);
|
||||
|
||||
Reference in New Issue
Block a user