u, u_red, sizeof(u_red));
}
-static int s390x_x25519_mul(unsigned char u_dst[32],
- const unsigned char u_src[32],
- const unsigned char d_src[32])
+int s390x_x25519_mul(unsigned char u_dst[32],
+ const unsigned char u_src[32],
+ const unsigned char d_src[32])
{
union {
struct {
return rc;
}
-static int s390x_x448_mul(unsigned char u_dst[56],
- const unsigned char u_src[56],
- const unsigned char d_src[56])
+int s390x_x448_mul(unsigned char u_dst[56],
+ const unsigned char u_src[56],
+ const unsigned char d_src[56])
{
union {
struct {
void X448_public_from_private(uint8_t out_public_value[56],
const uint8_t private_key[56]);
+int s390x_x25519_mul(unsigned char u_dst[32],
+ const unsigned char u_src[32],
+ const unsigned char d_src[32]);
+int s390x_x448_mul(unsigned char u_dst[56],
+ const unsigned char u_src[56],
+ const unsigned char d_src[56]);
+
# endif /* OPENSSL_NO_EC */
#endif
SOURCE[$DH_GOAL]=dh_exch.c
ENDIF
+IF[{- !$disabled{asm} -}]
+ $ECDEF_s390x=S390X_EC_ASM
+
+ # Now that we have defined all the arch specific variables, use the
+ # appropriate one, and define the appropriate macros
+ IF[$ECASM_{- $target{asm_arch} -}]
+ $ECDEF=$ECDEF_{- $target{asm_arch} -}
+ ENDIF
+ENDIF
+
+
SOURCE[$ECX_GOAL]=ecx_exch.c
+DEFINE[$ECX_GOAL]=$ECDEF
#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;
}
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;