Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SP: big-endian support #7410

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SparkiDev
Copy link
Contributor

Description

Handle reading and writing from big-endian byte array when compiling for big-endian.

Fixes zd#17810

Testing

Emulator not available on Ubuntu for big-endian ARM.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

Handle reading and writing from big-endian byte array when compiling for
big endian.
@SparkiDev SparkiDev self-assigned this Apr 10, 2024
@dgarske
Copy link
Contributor

dgarske commented May 15, 2024

@SparkiDev , what's the state of this PR? Is it ready for review?

Copy link
Contributor

@douzzer douzzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to get this to compile with BIG_ENDIAN_ORDER, these changes are needed:

diff --git a/wolfcrypt/src/sp_arm32.c b/wolfcrypt/src/sp_arm32.c
index d08bf9cd3..20d7f5577 100644
--- a/wolfcrypt/src/sp_arm32.c
+++ b/wolfcrypt/src/sp_arm32.c
@@ -91,7 +91,6 @@ static void sp_2048_from_bin(sp_digit* r, int size, const byte* a, int n)
 {
     int i;
     int j;
-    byte* d;
 
     for (i = n - 1,j = 0; i >= 3; i -= 4) {
         r[j]  = ((sp_digit)a[i - 0] <<  0) |
@@ -111,6 +110,8 @@ static void sp_2048_from_bin(sp_digit* r, int size, const byte* a, int n)
             r[j] |= ((sp_digit)a[i]) << s;
         }
 #else
+        byte* d;
+
         r[j] = 0;
 
         d = (byte*)r;
@@ -18274,7 +18275,6 @@ static void sp_3072_from_bin(sp_digit* r, int size, const byte* a, int n)
 {
     int i;
     int j;
-    byte* d;
 
     for (i = n - 1,j = 0; i >= 3; i -= 4) {
         r[j]  = ((sp_digit)a[i - 0] <<  0) |
@@ -18294,6 +18294,8 @@ static void sp_3072_from_bin(sp_digit* r, int size, const byte* a, int n)
             r[j] |= ((sp_digit)a[i]) << s;
         }
 #else
+        byte* d;
+
         r[j] = 0;
 
         d = (byte*)r;
@@ -76393,7 +76395,6 @@ static void sp_256_from_bin(sp_digit* r, int size, const byte* a, int n)
 {
     int i;
     int j;
-    byte* d;
 
     for (i = n - 1,j = 0; i >= 3; i -= 4) {
         r[j]  = ((sp_digit)a[i - 0] <<  0) |
@@ -76413,6 +76414,8 @@ static void sp_256_from_bin(sp_digit* r, int size, const byte* a, int n)
             r[j] |= ((sp_digit)a[i]) << s;
         }
 #else
+        byte* d;
+
         r[j] = 0;
 
         d = (byte*)r;
@@ -156655,7 +156658,6 @@ static void sp_1024_from_bin(sp_digit* r, int size, const byte* a, int n)
 {
     int i;
     int j;
-    byte* d;
 
     for (i = n - 1,j = 0; i >= 3; i -= 4) {
         r[j]  = ((sp_digit)a[i - 0] <<  0) |
@@ -156675,6 +156677,8 @@ static void sp_1024_from_bin(sp_digit* r, int size, const byte* a, int n)
             r[j] |= ((sp_digit)a[i]) << s;
         }
 #else
+        byte* d;
+
         r[j] = 0;
 
         d = (byte*)r;

once that's done, building on armeb-linux-gnueabihf gives

/tmp/tmp.4346_12509/cc4wYqsG.s:133: Error: selected processor does not support `umaal r11,r12,r0,r5' in ARM mode
/tmp/tmp.4346_12509/cc4wYqsG.s:135: Error: selected processor does not support `umaal r12,r8,r1,r5' in ARM mode
/tmp/tmp.4346_12509/cc4wYqsG.s:136: Error: selected processor does not support `umaal r12,r7,r0,r6' in ARM mode
[and a couple hundred more like this]

not sure if I'm using the wrong target or what.

it builds clean targeting armv7a-unknown-linux-gnueabihf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants