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

Small fixups #112

Merged
merged 3 commits into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
### Maintenance
* Upgrade tests to JUnit5. [PR #111](https://github.com/corretto/amazon-corretto-crypto-provider/pull/111)
* Upgrade BouncyCastle test dependency 1.65. [PR #110](https://github.com/corretto/amazon-corretto-crypto-provider/pull/110)
* Add version gating to P1363 Format tests. [PR #112](https://github.com/corretto/amazon-corretto-crypto-provider/pull/112)
* Re-add support for very old x86_64 build-chains. [PR #112](https://github.com/corretto/amazon-corretto-crypto-provider/pull/112)

## 1.4.0
### Improvements
Expand Down
25 changes: 23 additions & 2 deletions csrc/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,33 @@ class pthread_lock_auto {
};

#if __BYTE_ORDER == __LITTLE_ENDIAN
#if defined(__x86_64__)
// We need to continue supporting some old x86_64 build-chains, so we use a hand-rolled version of bswap64
static inline uint64_t swapEndian(uint64_t val) {
uint64_t result = val;
__asm__(
"bswap %0"
: "+r"(result)
);
return result;
}
#define hostToBigEndian64(x) swapEndian(x)
#define bigEndianToHost64(x) swapEndian(x)

#else
// For all other platforms (currently just aarch64), we know we are on a modern build-chain
// and can use the build-in function. (Also, the x86_64 assembly above won't work.)
#define hostToBigEndian64(x) __builtin_bswap64(x)
#define bigEndianToHost64(x) __builtin_bswap64(x)
#else

#endif // Platform logic in __BYTE_ORDER == __LITTLE_ENDIAN

#else // __BYTE_ORDER == __BIG_ENDIAN
// No conversions are needed, so these methods become NOPs
#define hostToBigEndian64(x) (x)
#define bigEndianToHost64(x) (x)
#endif
#endif // BYTE_ORDER logic


static inline void* fast_xor(void* dest, const void* src, int len) {
int idx = 0;
Expand Down
16 changes: 10 additions & 6 deletions tst/com/amazon/corretto/crypto/provider/test/EvpSignatureTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.amazon.corretto.crypto.provider.test;

import static com.amazon.corretto.crypto.provider.test.TestUtil.assertThrows;
import static com.amazon.corretto.crypto.provider.test.TestUtil.versionCompare;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand Down Expand Up @@ -200,12 +201,15 @@ public static void setupParams() throws GeneralSecurityException {
MASTER_PARAMS_LIST.add(new TestParams(base, algorithm, length, true, false, currentPair));
MASTER_PARAMS_LIST.add(new TestParams(base, algorithm, length, false, true, currentPair));
MASTER_PARAMS_LIST.add(new TestParams(base, algorithm, length, true, true, currentPair));
if (base.equals("ECDSA") && !hash.equals("NONE")) {
algorithm = algorithm + "inP1363Format";
MASTER_PARAMS_LIST.add(new TestParams(base, algorithm, length, false, false, currentPair));
MASTER_PARAMS_LIST.add(new TestParams(base, algorithm, length, true, false, currentPair));
MASTER_PARAMS_LIST.add(new TestParams(base, algorithm, length, false, true, currentPair));
MASTER_PARAMS_LIST.add(new TestParams(base, algorithm, length, true, true, currentPair));
// These new algorithms were only added in 1.3.0
if (versionCompare("1.3.0", NATIVE_PROVIDER) <= 0) {
if (base.equals("ECDSA") && !hash.equals("NONE")) {
algorithm = algorithm + "inP1363Format";
MASTER_PARAMS_LIST.add(new TestParams(base, algorithm, length, false, false, currentPair));
MASTER_PARAMS_LIST.add(new TestParams(base, algorithm, length, true, false, currentPair));
MASTER_PARAMS_LIST.add(new TestParams(base, algorithm, length, false, true, currentPair));
MASTER_PARAMS_LIST.add(new TestParams(base, algorithm, length, true, true, currentPair));
}
}
}
}
Expand Down