Repository navigation
WIP: Add X448 and Ed448 support - #4829
mattcaswell wants to merge 43 commits into
Conversation
This imports selected files from the src directory of this repository: https://sourceforge.net/p/ed448goldilocks/code/ci/v0.9.4/tree/ This is from the version tagged as "v0.9.4" with commit id 7527e9. This code was originally writting by Mike Hamburg and the import is done by kind permission of Rambus and Mike Hamburg under CLA. As this is under CLA the files are being relicensed under the OpenSSL licence. Subsequent commits will correct any licence notices in the individual files. These files should provide complete self-contained support for X448 and Ed448. They are imported "as is" from the source repository and this commit does not attempt to integrate them into the OpenSSL build system, or modify them in any way to fit OpenSSL style guidelines. That will be done by subsequent commits.
Most of these were in point_448.h. While I was at it I spotted some unused declarations, so I deleted those too.
OpenSSL does not currently have this concept. It only provides compiler warnings so just remove it.
OpenSSL does not have this concept
Make sure we generate the symbolic link required for the library
…lity Some non-portable includes are left because they are already suitably guarded.
Convert the curve448 test to use the OpenSSL implementation of shake256.
We have fully converted curve448 to use the OpenSSL shake256 implementation so we can now remove the old one.
It is no longer used
Unlike X448 the key lengths for ED448 are 57 bytes (as opposed to 56)
ecx_meth.c is specific to the 25519 curve. This commit makes it more generic so it can handle the 448 curve too.
There's nothing special about being able to set the MAC key. It's just a private key so the same ctrl can be used for other things other than MAC algorithms. We also add the ability to set public keys directly.
This enables setting the private and public key directly for X25519, X448, Ed25519 and Ed448
Previously private and public keys had to be pem encoded to be read by evp_test. This enables us to embed the raw private/public key values in the test file. The algorithm has to support EVP_PKEY_new_priv_key() and EVP_PKEY_new_pub_key() for this to work.
This adds the Ed448 test vectors from RFC8032 and the X448 test vectors from RFC7748.
Some files talk about the MIT license. This code was contributed under CLA and was relicensed to the OpenSSL licence when imported.
| * in the file LICENSE in the source distribution or at | ||
| * https://www.openssl.org/source/license.html | ||
| * | ||
| * Originally written by Mike Hamburg |
There was a problem hiding this comment.
I think we should take all names out, not just email ones. The git log will show who authored a particular file.
There was a problem hiding this comment.
I have no problem with this at all, specially since he's not listed as author in git.
| @@ -0,0 +1,38 @@ | |||
| all: libcurve448.so.1 curve448_test | |||
There was a problem hiding this comment.
Is this file going to go away?
There was a problem hiding this comment.
Yes - I was using it temporarily before I had integrated the code into our build system.
| @@ -0,0 +1,48 @@ | |||
| /* Copyright (c) 2014-2016 Cryptography Research, Inc. | |||
| * Released under the MIT License. See LICENSE.txt for license information. | |||
There was a problem hiding this comment.
Oops missed one - I thought I had done all of these!
| return ((uint64_t)a) * b; | ||
| } | ||
|
|
||
| #endif /* __ARCH_ARM_32_ARCH_INTRINSICS_H__ */ |
|
|
||
| __asm__ __volatile__ ("smlal %[lo], %[hi], %[a], %[b]" | ||
| : [lo]"+&r"(lo), [hi]"+&r"(hi) | ||
| : [a]"r"(a), [b]"r"(b)); |
There was a problem hiding this comment.
I'm going to guess that all this assembler is going to need to get converted to perlasm so that it's works over all our platforms. I'm wondering if we should start with a plain C implementation and add all the assembler implementations at some later time.
There was a problem hiding this comment.
As I mentioned in the intro to this PR I've only integrated the 32-bit reference implementation which is C only. The platform specific optimisations are still there, but aren't integrated into the build at this point. This code belongs to one of those non-integrated files.
| static __inline__ __attribute((always_inline,unused)) | ||
| uint32_t word_is_zero(uint32_t a) { | ||
| /* let's hope the compiler isn't clever enough to optimize this. */ | ||
| return (((uint64_t)a)-1)>>32; |
There was a problem hiding this comment.
I think this function can be replaced by our constant_time_is_zero
There was a problem hiding this comment.
The types aren't quite the same, so this is probably a non-trivial exercise.
|
I'd say that it would be unnecessary hard to review this in single request and would like to suggest to break it into smaller steps. And even detach from original commit line. I mean do we actually need to have commits like Makefile updates? |
I could certainly split it into 1 PR to add the underlying primitives, and 1 PR to integrate it into EVP. WRT the Makefile it was only ever intended to be a temporary artefact that I was going to remove (including the commits). In general though I'd like to preserve most of the commit history as it does document how the code has been transformed from what was contributed to what is eventually used. |
|
Replaced by #5105. |
This PR adds libcrypto (EVP level) support for X448 and Ed448. It does not add SSL/TLS support - that will be done in a later PR.
This is based heavily on original work by Mike Hamburg (thanks @bitwiseshiftleft) and contributed under CLA.
This is still WIP because there is still a lot more work to do. Many of the files need their style updating to match OpenSSL coding standards. Also a big issue is that the original code uses a lot of compiler/language features that we do not allow in OpenSSL for portability reasons - at least we don't allow them without appropriate guarding in place. For that reason this is currently using the 32-bit reference implementation rather than some of the platform specific optimised versions. Those optimised versions are still there - I just need to figure out how best to use them. I've tried this on my linux box. It quite likely won't compile on other platforms at the moment.
The Ed448 primitives support PureEDDSA and the pre-hash variant. I have only exposed the PureEDDSA version at the EVP layer due to the lack of OIDs. The underlying primitives also support contexts but I have not exposed those either at this point.