Unify and improve RAID and crypto xor.
* grub-core/disk/raid.c (grub_raid_block_xor): Removed. All users changed to grub_crypto_xor * grub-core/lib/crypto.c (grub_crypto_xor): Moved from here ... * include/grub/crypto.h (grub_crypto_xor): ... here. Inlined. Use bigger types when possible.
This commit is contained in:
parent
ef6e433586
commit
496bd07446
6 changed files with 54 additions and 41 deletions
|
@ -198,8 +198,40 @@ grub_crypto_cipher_close (grub_crypto_cipher_handle_t cipher)
|
|||
grub_free (cipher);
|
||||
}
|
||||
|
||||
void
|
||||
grub_crypto_xor (void *out, const void *in1, const void *in2, grub_size_t size);
|
||||
static inline void
|
||||
grub_crypto_xor (void *out, const void *in1, const void *in2, grub_size_t size)
|
||||
{
|
||||
const grub_uint8_t *in1ptr = in1, *in2ptr = in2;
|
||||
grub_uint8_t *outptr = out;
|
||||
while (size && (((grub_addr_t) in1ptr & (sizeof (grub_uint64_t) - 1))
|
||||
|| ((grub_addr_t) in2ptr & (sizeof (grub_uint64_t) - 1))
|
||||
|| ((grub_addr_t) outptr & (sizeof (grub_uint64_t) - 1))))
|
||||
{
|
||||
*outptr = *in1ptr ^ *in2ptr;
|
||||
in1ptr++;
|
||||
in2ptr++;
|
||||
outptr++;
|
||||
size--;
|
||||
}
|
||||
while (size >= sizeof (grub_uint64_t))
|
||||
{
|
||||
*(grub_uint64_t *) (void *) outptr
|
||||
= (*(grub_uint64_t *) (void *) in1ptr
|
||||
^ *(grub_uint64_t *) (void *) in2ptr);
|
||||
in1ptr += sizeof (grub_uint64_t);
|
||||
in2ptr += sizeof (grub_uint64_t);
|
||||
outptr += sizeof (grub_uint64_t);
|
||||
size -= sizeof (grub_uint64_t);
|
||||
}
|
||||
while (size)
|
||||
{
|
||||
*outptr = *in1ptr ^ *in2ptr;
|
||||
in1ptr++;
|
||||
in2ptr++;
|
||||
outptr++;
|
||||
size--;
|
||||
}
|
||||
}
|
||||
|
||||
gcry_err_code_t
|
||||
grub_crypto_ecb_decrypt (grub_crypto_cipher_handle_t cipher,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue