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

Fix compile errors on ppc64-be #6

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Fix compile errors on ppc64-be #6

wants to merge 11 commits into from

Conversation

noloader
Copy link

@noloader noloader commented Mar 8, 2018

This fixes three compile errors on ppc64-be.

The first fix is a trivial unbalanced closing brace. The second is undefined behavior due to a shift width issue. 'unsigned long long' is always 64-bits in practice, and it avoids '<stdint.h>' headers. The third is a missing 'swap_bytes' implementation, which is trivially fixed with a 'memcpy'.

There are some additional fixes, like avoiding the use of reserved identifiers, fixing a compile under IBM XL C/C++ and fixing duplicate symbols on AIX.

A ppc64-be machine is available on the GCC Compile Farm at gcc119.fsffrance.org. Accounts are free for open source developers. Access is provided using SSH. Sign up for an account at tetaneutral.net | Compile Farm. The compile farm account gets you access to the hardware listed at CFarm Machines.

noloader added 8 commits March 8, 2018 08:46
Compiling with IBM XL C/C++ needs additional CFLAGS. The makefile should honor a user's choice of flags. ALL_CFLAGS supplies the project's C compiler options, and combines them with the user's CFLAGS. Also see GNU Coding Standards, Section 7.2.3, Variables for Specifying Commands (https://www.gnu.org/prep/standards/standards.html#Command-Variables)
The C and C++ standard reserves leading underscores in identifiers for library code. User code should not use them
@noloader
Copy link
Author

noloader commented Mar 8, 2018

@gut, @brunoalr, @lbianc and @leitao

Here is the result of testing on GCC119, which is ppc64-be. I believe the changes tested good except for the missing sha256sum. The calculated hashes displayed below are correct for the string abc using SHA-256 and SHA-512. I did not check the other strings.

Maybe your test script can check for the availability of the command sha256sum with command -v sha256sum. command -v is Posix and it is the recommended way to test for a program. If the sha256sum program is available then use it. Otherwise skip the test that uses sha256sum.

$ make COMPILERS=gcc test
mkdir -p ./bin
make[1]: Entering directory '/home/test/sha2-le'
make[1]: Nothing to be done for 'all-compiler'.
make[1]: Leaving directory '/home/test/sha2-le'
make[1]: Entering directory '/home/test/sha2-le'
=======================================================================
Testing gcc
=======================================================================
CC=gcc ./blackbox-test.sh
Running tests for SHA-256:
./blackbox-test.sh: line 36: sha256sum: command not found
Test #1:        libcrypto is NOK
@@ -1 +0,0 @@
-ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
c is NOK
@@ -1 +0,0 @@
-ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad

./blackbox-test.sh: line 36: sha256sum: command not found
Test #2:        libcrypto is NOK
@@ -1 +0,0 @@
-287448c188eb60578adf83df7df2b9aeb4d09a15374079625fa5ad6a3bd19602
c is NOK
@@ -1 +0,0 @@
-287448c188eb60578adf83df7df2b9aeb4d09a15374079625fa5ad6a3bd19602

./blackbox-test.sh: line 36: sha256sum: command not found
Test #3:        libcrypto is NOK
@@ -1 +0,0 @@
-111cf84a6c98554db87366a2c1750c5eaee6589699941e5db5874dc3a4e16b43
c is NOK
@@ -1 +0,0 @@
-111cf84a6c98554db87366a2c1750c5eaee6589699941e5db5874dc3a4e16b43

./blackbox-test.sh: line 36: sha256sum: command not found
Test #4:        libcrypto is NOK
@@ -1 +0,0 @@
-89e4f019b607bed96fb265f8195dacab2c2cde908de26728d5432d6a6090591a
c is NOK
@@ -1 +0,0 @@
-89e4f019b607bed96fb265f8195dacab2c2cde908de26728d5432d6a6090591a


Running tests for SHA-512:
./blackbox-test.sh: line 36: sha512sum: command not found
Test #1:        libcrypto is NOK
@@ -1 +0,0 @@
-ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f
c is NOK
@@ -1 +0,0 @@
-ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f

./blackbox-test.sh: line 36: sha512sum: command not found
Test #2:        libcrypto is NOK
@@ -1 +0,0 @@
-84300a42363295dffc15b70152749fd47dd9c1fb3567b139c08e159c4884ee9a8cf47b0d41b48d12852becc9a84014adbe2490cbfdfb1f9955b58fb8b51d4595
c is NOK
@@ -1 +0,0 @@
-84300a42363295dffc15b70152749fd47dd9c1fb3567b139c08e159c4884ee9a8cf47b0d41b48d12852becc9a84014adbe2490cbfdfb1f9955b58fb8b51d4595

./blackbox-test.sh: line 36: sha512sum: command not found
Test #3:        libcrypto is NOK
@@ -1 +0,0 @@
-338e69ec94c24d74e15a11eb3c734ab8ee64be3fd34514b3a6c10a1281bfc4e2a8059a11fe33b2b81578420a0a429fe4538cccf18e15d339213059e4a55273f6
c is NOK
@@ -1 +0,0 @@
-338e69ec94c24d74e15a11eb3c734ab8ee64be3fd34514b3a6c10a1281bfc4e2a8059a11fe33b2b81578420a0a429fe4538cccf18e15d339213059e4a55273f6

./blackbox-test.sh: line 36: sha512sum: command not found
Test #4:        libcrypto is NOK
@@ -1 +0,0 @@
-256648efd9c76906804f683dc944552cdbcd80658f141a4cd03b5744dcc7d054c074b805c26829c7d01660edbfeb34bf539267fa42723e83ce0b145c7291bb50
c is NOK
@@ -1 +0,0 @@
-256648efd9c76906804f683dc944552cdbcd80658f141a4cd03b5744dcc7d054c074b805c26829c7d01660edbfeb34bf539267fa42723e83ce0b145c7291bb50


Makefile:114: recipe for target 'test-compiler' failed
make[1]: *** [test-compiler] Error 1
make[1]: Leaving directory '/home/test/sha2-le'
Makefile:124: recipe for target 'test' failed
make: *** [test] Error 2
-bash-4.4$

@gut
Copy link
Contributor

gut commented Mar 9, 2018

Hi @noloader . Thanks for your contribution!

Unfortunately I'm not supporting this project anymore. I guess @lbianc and @leitao can help you with that.

@noloader
Copy link
Author

noloader commented Mar 14, 2018

@gut, @lbianc and @leitao

Sorry to wander off-topic here.

We started a book on POWER8 in-core crypto programming at POWER8-crypto... I'd like you guys to contribute to it. You folks are a part of a small group who has actually programmed this stuff. Contribute by writing content or technical editing.

I cited sha2-le in the nominal references. I would enjoy adding you as an author or a contributor (see book.xml for the listing).

@noloader
Copy link
Author

noloader commented Mar 16, 2018

@gut, @lbianc and @leitao,

I added a section to the book on integrating with sha2-le. Also see Chapter 7, Section 2.

The signature of the function sha256_compress_ppc is kind of unusual because the keys are passed as a parameter. Every other API I have looked at only us state and message as parameters; and the keys are baked into the algorithm.

Do you guys want to rework the public API?

@gut
Copy link
Contributor

gut commented Mar 16, 2018

I don't think that this project is going to be updated. Sorry

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.

2 participants