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

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

Pull crypto library fix from Eric Biggers:
"Fix a big endian specific issue in the PPC64-optimized AES code"

* tag 'libcrypto-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux:
lib/crypto: powerpc/aes: Fix rndkey_from_vsx() on big endian CPUs

+7 -5
+7 -5
lib/crypto/powerpc/aes.h
··· 95 95 } 96 96 97 97 /* 98 - * Convert a round key from VSX to generic format by reflecting the 16 bytes, 98 + * Convert a round key from VSX to generic format by reflecting all 16 bytes (if 99 + * little endian) or reflecting the bytes in each 4-byte word (if big endian), 99 100 * and (if apply_inv_mix=true) applying InvMixColumn to each column. 100 101 * 101 102 * It would be nice if the VSX and generic key formats would be compatible. But ··· 108 107 */ 109 108 static void rndkey_from_vsx(u32 out[4], const u32 in[4], bool apply_inv_mix) 110 109 { 110 + const bool be = IS_ENABLED(CONFIG_CPU_BIG_ENDIAN); 111 111 u32 k0 = swab32(in[0]); 112 112 u32 k1 = swab32(in[1]); 113 113 u32 k2 = swab32(in[2]); ··· 120 118 k2 = inv_mix_columns(k2); 121 119 k3 = inv_mix_columns(k3); 122 120 } 123 - out[0] = k3; 124 - out[1] = k2; 125 - out[2] = k1; 126 - out[3] = k0; 121 + out[0] = be ? k0 : k3; 122 + out[1] = be ? k1 : k2; 123 + out[2] = be ? k2 : k1; 124 + out[3] = be ? k3 : k0; 127 125 } 128 126 129 127 static void aes_preparekey_arch(union aes_enckey_arch *k,