summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Berger <stefanb@linux.ibm.com>2021-07-09 11:39:00 -0400
committerAlexey Kardashevskiy <aik@ozlabs.ru>2021-07-11 23:46:49 +1000
commite1362035a27e4fe3d3a82b70e92f4f2c48a61711 (patch)
tree674cd3ba78f411fade68b592c941b422220c65a3
parentcc4c4cb3c193dabdefe45db343c949452c081435 (diff)
downloadqemu-SLOF-e1362035a27e4fe3d3a82b70e92f4f2c48a61711.tar.gz
tcgbios: Use assembly for 32 bit rotr in sha256
Use assembly for the 32 bit rotr in the sha256 implementation similar to the assembly used in the sha1 and sha512 implementations. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
-rw-r--r--lib/libtpm/sha256.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/libtpm/sha256.c b/lib/libtpm/sha256.c
index c6b8767..1a0aa9a 100644
--- a/lib/libtpm/sha256.c
+++ b/lib/libtpm/sha256.c
@@ -22,10 +22,16 @@ typedef struct _sha256_ctx {
uint32_t h[8];
} sha256_ctx;
-static inline uint32_t rotr(uint32_t x, uint8_t n)
-{
- return (x >> n) | (x << (32 - n));
-}
+#define rotr(VAL, N) \
+({ \
+ uint32_t res; \
+ __asm__ ( \
+ "rotrwi %0, %1, %2\n\t" \
+ : "=r" (res) \
+ : "r" (VAL), "i" (N) \
+ ); \
+ res; \
+})
static inline uint32_t Ch(uint32_t x, uint32_t y, uint32_t z)
{