boringssl/tool
Kris Kwiatkowski eb43eca5a8 Add support for SIKE/p503 post-quantum KEM
Based on Microsoft's implementation available on github:
Source: https://github.com/Microsoft/PQCrypto-SIDH
Commit: 77044b76181eb61c744ac8eb7ddc7a8fe72f6919

Following changes has been applied

* In intel assembly, use MOV instead of MOVQ:
  Intel instruction reference in the Intel Software Developer's Manual
  volume 2A, the MOVQ has 4 forms. None of them mentions moving
  literal to GPR, hence "movq $rax, 0x0" is wrong. Instead, on 64bit
  system, MOV can be used.

* Some variables were wrongly zero-initialized (as per C99 spec)

* Move constant values to .RODATA segment, as keeping them in .TEXT
  segment is not compatible with XOM.

* Fixes issue in arm64 code related to the fact that compiler doesn't
  reserve enough space for the linker to relocate address of a global
  variable when used by 'ldr' instructions. Solution is to use 'adrp'
  followed by 'add' instruction. Relocations for 'adrp' and 'add'
  instructions is generated by prefixing the label with :pg_hi21:
  and :lo12: respectively.

* Enable MULX and ADX. Code from MS doesn't support PIC. MULX can't
  reference global variable directly. Instead RIP-relative addressing
  can be used. This improves performance around 10%-13% on SkyLake

* Check if CPU supports BMI2 and ADOX instruction at runtime. On AMD64
  optimized implementation of montgomery multiplication and reduction
  have 2 implementations - faster one takes advantage of BMI2
  instruction set introduced in Haswell and ADOX introduced in
  Broadwell. Thanks to OPENSSL_ia32cap_P it can be decided at runtime
  which implementation to choose. As CPU configuration is static by
  nature, branch predictor will be correct most of the time and hence
  this check very often has no cost.

* Reuse some utilities from boringssl instead of reimplementing them.
  This includes things like:
  * definition of a limb size (use crypto_word_t instead of digit_t)
  * use functions for checking in constant time if value is 0 and/or
    less then
  * #define's used for conditional compilation

* Use SSE2 for conditional swap on vector registers. Improves
  performance a little bit.

* Fix f2elm_t definition. Code imported from MSR defines f2elm_t type as
  a array of arrays. This decays to a pointer to an array (when passing
  as an argument). In C, one can't assign const pointer to an array with
  non-const pointer to an array. Seems it violates 6.7.3/8 from C99
  (same for C11). This problem occures in GCC 6, only when -pedantic
  flag is specified and it occures always in GCC 4.9 (debian jessie).

* Fix definition of eval_3_isog. Second argument in eval_3_isog mustn't be
  const. Similar reason as above.

* Use HMAC-SHA256 instead of cSHAKE-256 to avoid upstreaming cSHAKE
  and SHA3 code.

* Add speed and unit tests for SIKE.

Change-Id: I22f0bb1f9edff314a35cd74b48e8c4962568e330
2019-04-12 11:26:23 -07:00
..
args.cc
ciphers.cc Use getters in tools/ciphers.cc and add -openssl-name flag. 2017-08-18 00:10:31 +00:00
client.cc Delete the variants/draft code. 2019-01-08 17:38:41 +00:00
CMakeLists.txt Support symbol prefixes 2018-09-06 20:07:52 +00:00
const.cc Unwind multiprime RSA support. 2017-04-12 23:14:57 +00:00
digest.cc Correctness fixes for NaCl and other platforms. 2016-11-09 19:06:10 +00:00
file.cc Add a basic signing tool. 2017-04-05 23:32:13 +00:00
generate_ed25519.cc Add early data input from file. 2017-11-30 17:29:45 +00:00
genrsa.cc Unwind RSA_generate_multi_prime_key. 2017-04-11 18:15:20 +00:00
internal.h Add early data input from file. 2017-11-30 17:29:45 +00:00
pkcs12.cc Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
rand.cc Fix miscellaneous clang-tidy warnings. 2017-08-01 20:39:46 +00:00
server.cc Delete the variants/draft code. 2019-01-08 17:38:41 +00:00
sign.cc Align EVP_PKEY Ed25519 API with upstream. 2017-06-12 12:04:11 +00:00
speed.cc Add support for SIKE/p503 post-quantum KEM 2019-04-12 11:26:23 -07:00
tool.cc First part of the FIPS module. 2017-04-07 00:05:34 +00:00
transport_common.cc Remove SSL 3.0 implementation. 2018-06-28 16:54:58 +00:00
transport_common.h Reland "Fix bssl client/server's error-handling." 2018-05-07 17:19:59 +00:00