Skip to content

Instantly share code, notes, and snippets.

@andrew-aladev
Created January 26, 2020 10:09
Show Gist options
  • Save andrew-aladev/fbccfb7b5a5e03063d6dde0f43f2f296 to your computer and use it in GitHub Desktop.
Save andrew-aladev/fbccfb7b5a5e03063d6dde0f43f2f296 to your computer and use it in GitHub Desktop.
aarch64_be.openssl-1.1.1d.patch
diff --git a/crypto/aes/asm/aesv8-armx.pl b/crypto/aes/asm/aesv8-armx.pl
index eec0ed230a..8eca5c2e28 100755
--- a/crypto/aes/asm/aesv8-armx.pl
+++ b/crypto/aes/asm/aesv8-armx.pl
@@ -183,7 +183,12 @@ $code.=<<___;
.Loop192:
vtbl.8 $key,{$in1},$mask
vext.8 $tmp,$zero,$in0,#12
- vst1.32 {$in1},[$out],#8
+#ifdef __ARMEB__
+ vst1.32 {$in1},[$out],#16
+ sub $out,$out,#8
+#else
+ vst1.32 {$in1},[$out],#8
+#endif
aese $key,$zero
subs $bits,$bits,#1
@@ -715,7 +720,12 @@ $code.=<<___;
ldr $rounds,[$key,#240]
ldr $ctr, [$ivp, #12]
- vld1.32 {$dat0},[$ivp]
+
+#ifdef __ARMEB__
+ vld1.8 {$dat0},[$ivp]
+#else
+ vld1.32 {$dat0},[$ivp]
+#endif
vld1.32 {q8-q9},[$key] // load key schedule...
sub $rounds,$rounds,#4
diff --git a/crypto/modes/modes_lcl.h b/crypto/modes/modes_lcl.h
index f2ae01d11a..766a39c5c0 100644
--- a/crypto/modes/modes_lcl.h
+++ b/crypto/modes/modes_lcl.h
@@ -55,12 +55,17 @@ typedef unsigned char u8;
asm ("bswapl %0" \
: "+r"(ret_)); ret_; })
# elif defined(__aarch64__)
-# define BSWAP8(x) ({ u64 ret_; \
- asm ("rev %0,%1" \
- : "=r"(ret_) : "r"(x)); ret_; })
+# if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
+ __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__
+# define BSWAP8(x) ({ u64 ret_; \
+ asm ("rev %0,%1" \
+ : "=r"(ret_) : "r"(x)); ret_; })
# define BSWAP4(x) ({ u32 ret_; \
- asm ("rev %w0,%w1" \
- : "=r"(ret_) : "r"(x)); ret_; })
+# define BSWAP4(x) ({ u32 ret_; \
+ asm ("rev %w0,%w1" \
+ : "=r"(ret_) : "r"(x)); ret_; })
+# endif
+
# elif (defined(__arm__) || defined(__arm)) && !defined(STRICT_ALIGNMENT)
# define BSWAP8(x) ({ u32 lo_=(u64)(x)>>32,hi_=(x); \
asm ("rev %0,%0; rev %1,%1" \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment