X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=providers%2Fimplementations%2Fexchange%2Fecx_exch.c;h=ea12628937392fd4d420d2eb130bebbfcfc2f953;hp=b7d1d9e3951247e7a94e48ac1326d429d9a373cc;hb=97b50f67f212589661c9f1edd5285822c6cc642b;hpb=6f7d213533d9c7c2d810499cfedaa6d2424482c9 diff --git a/providers/implementations/exchange/ecx_exch.c b/providers/implementations/exchange/ecx_exch.c index b7d1d9e395..ea12628937 100644 --- a/providers/implementations/exchange/ecx_exch.c +++ b/providers/implementations/exchange/ecx_exch.c @@ -16,6 +16,9 @@ #include "crypto/ecx.h" #include "prov/implementations.h" #include "prov/providercommonerr.h" +#ifdef S390X_EC_ASM +# include "s390x_arch.h" +#endif static OSSL_OP_keyexch_newctx_fn x25519_newctx; static OSSL_OP_keyexch_newctx_fn x448_newctx; @@ -126,11 +129,31 @@ static int ecx_derive(void *vecxctx, unsigned char *secret, size_t *secretlen, } if (ecxctx->keylen == X25519_KEYLEN) { +#ifdef S390X_EC_ASM + if (OPENSSL_s390xcap_P.pcc[1] + & S390X_CAPBIT(S390X_SCALAR_MULTIPLY_X25519)) { + if (s390x_x25519_mul(secret, ecxctx->peerkey->pubkey, + ecxctx->key->privkey) == 0) { + ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_DURING_DERIVATION); + return 0; + } + } else +#endif if (X25519(secret, ecxctx->key->privkey, ecxctx->peerkey->pubkey) == 0) { ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_DURING_DERIVATION); return 0; } } else { +#ifdef S390X_EC_ASM + if (OPENSSL_s390xcap_P.pcc[1] + & S390X_CAPBIT(S390X_SCALAR_MULTIPLY_X448)) { + if (s390x_x448_mul(secret, ecxctx->peerkey->pubkey, + ecxctx->key->privkey) == 0) { + ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_DURING_DERIVATION); + return 0; + } + } else +#endif if (X448(secret, ecxctx->key->privkey, ecxctx->peerkey->pubkey) == 0) { ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_DURING_DERIVATION); return 0;