+#ifdef FIPS_MODULE
+/*
+ * Refer: FIPS 140-3 IG 10.3.A Additional Comment 1
+ * Perform a pairwise test for EDDSA by signing and verifying signature.
+ *
+ * The parameter `self_test` is used to indicate whether to create OSSL_SELF_TEST
+ * instance.
+ */
+static int ecd_fips140_pairwise_test(const ECX_KEY *ecx, int type, int self_test)
+{
+ int ret = 0;
+ OSSL_SELF_TEST *st = NULL;
+ OSSL_CALLBACK *cb = NULL;
+ void *cbarg = NULL;
+
+ unsigned char msg[16] = {0};
+ size_t msg_len = sizeof(msg);
+ unsigned char sig[ED448_SIGSIZE] = {0};
+
+ int is_ed25519 = (type == ECX_KEY_TYPE_ED25519) ? 1 : 0;
+ int operation_result = 0;
+
+ /*
+ * The functions `OSSL_SELF_TEST_*` will return directly if parameter `st`
+ * is NULL.
+ */
+ if (self_test) {
+ OSSL_SELF_TEST_get_callback(ecx->libctx, &cb, &cbarg);
+
+ st = OSSL_SELF_TEST_new(cb, cbarg);
+ if (st == NULL)
+ return 0;
+ }
+
+ OSSL_SELF_TEST_onbegin(st, OSSL_SELF_TEST_TYPE_PCT,
+ OSSL_SELF_TEST_DESC_PCT_EDDSA);
+
+ if (is_ed25519)
+ operation_result = ossl_ed25519_sign(sig, msg, msg_len, ecx->pubkey,
+ ecx->privkey, 0, 0, 0, NULL, 0,
+ ecx->libctx, ecx->propq);
+ else
+ operation_result = ossl_ed448_sign(ecx->libctx, sig, msg, msg_len,
+ ecx->pubkey, ecx->privkey, NULL, 0,
+ 0, ecx->propq);
+ if (operation_result != 1)
+ goto err;
+
+ OSSL_SELF_TEST_oncorrupt_byte(st, sig);
+
+ if (is_ed25519)
+ operation_result = ossl_ed25519_verify(msg, msg_len, sig, ecx->pubkey,
+ 0, 0, 0, NULL, 0, ecx->libctx,
+ ecx->propq);
+ else
+ operation_result = ossl_ed448_verify(ecx->libctx, msg, msg_len, sig,
+ ecx->pubkey, NULL, 0, 0, ecx->propq);
+ if (operation_result != 1)
+ goto err;
+
+ ret = 1;
+err:
+ OSSL_SELF_TEST_onend(st, ret);
+ OSSL_SELF_TEST_free(st);
+ return ret;
+}
+#endif
+