Home GnuPG

ec: Add zSeries/s390x accelerated scalar multiplication.

Description

ec: Add zSeries/s390x accelerated scalar multiplication.

* cipher/asm-inline-s390x.h (PCC_FUNCTION_*): New.
(pcc_query, pcc_scalar_multiply): New.
* mpi/Makefile.am: Add 'ec-hw-s390x.c'.
* mpi/ec-hw-s390x.c: New.
* mpi/ec-internal.h (_gcry_s390x_ec_hw_mul_point)
(mpi_ec_hw_mul_point): New.
* mpi/ec.c (_gcry_mpi_ec_mul_point): Call 'mpi_ec_hw_mul_point'.
* src/g10lib.h (HWF_S390X_MSA_9): New.
* src/hwf-s390x.c (s390x_features): Add MSA9.
* src/hwfeatures.c (hwflist): Add 's390x-msa-9'.

Cherry-pick master commit of: 69fdcb5433236c4fc5d24c1dcc269424a088086c

Patch adds ECC scalar multiplication acceleration using
s390x's PCC instruction. Following curves are supported:

  • Ed25519
  • Ed448
  • X25519
  • X448
  • NIST curves P-256, P-384 and P-521

Benchmark on z15 (5.2Ghz):

Before:
Ed25519 | nanosecs/iter cycles/iter

  mult |         389791       2026916
keygen |         572017       2974487
  sign |         636603       3310336
verify |        1189097       6183305
       =

X25519 | nanosecs/iter cycles/iter

mult |         296805       1543385
     =

Ed448 | nanosecs/iter cycles/iter

  mult |        1693373       8805541
keygen |        2382473      12388858
  sign |        2609562      13569725
verify |        5177606      26923552
       =

X448 | nanosecs/iter cycles/iter

mult |        1136178       5908127
     =

NIST-P256 | nanosecs/iter cycles/iter

  mult |         792620       4121625
keygen |        4627835      24064740
  sign |        1528268       7946991
verify |        1678205       8726664
       =

NIST-P384 | nanosecs/iter cycles/iter

  mult |        1766418       9185373
keygen |       10158485      52824123
  sign |        3341172      17374095
verify |        3694750      19212700
       =

NIST-P521 | nanosecs/iter cycles/iter

  mult |        3172566      16497346
keygen |       18184747      94560683
  sign |        6039956      31407771
verify |        6480882      33700588

After:
Ed25519 | nanosecs/iter cycles/iter speed-up

  mult |          25913        134746        15x
keygen |          44447        231124        12x
  sign |         106928        556028         6x
verify |         164681        856341         7x
       =

X25519 | nanosecs/iter cycles/iter speed-up

mult |          17761         92358        16x
     =

Ed448 | nanosecs/iter cycles/iter speed-up

  mult |          50808        264199        33x
keygen |          68644        356951        34x
  sign |         317446       1650720         8x
verify |         457115       2376997        11x
       =

X448 | nanosecs/iter cycles/iter speed-up

mult |          35637        185313        31x
     =

NIST-P256 | nanosecs/iter cycles/iter speed-up

  mult |          30678        159528        25x
keygen |         323722       1683356        14x
  sign |         114176        593713        13x
verify |         169901        883487         9x
       =

NIST-P384 | nanosecs/iter cycles/iter speed-up

  mult |          59966        311822        29x
keygen |         607778       3160445        16x
  sign |         209832       1091128        16x
verify |         329506       1713431        11x
       =

NIST-P521 | nanosecs/iter cycles/iter speed-up

  mult |          98230        510797        32x
keygen |        1131686       5884765        16x
  sign |         397777       2068442        15x
verify |         623076       3239998        10x
  • Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>

Details

Provenance
jukiviliAuthored on Jun 16 2021, 7:27 PM
gniibeCommitted on Sep 28 2021, 3:58 AM
Parents
rCa23a8f04d8da: tests/t-mpi-point: Add one more NIST P-256 reduction test-vector.
Branches
Unknown
Tags
Unknown