add DH callback to example server and client

This commit is contained in:
Jacob Barthelmeh
2018-01-05 11:56:59 -07:00
parent 915f628bc7
commit b22ae9de4c
2 changed files with 19 additions and 1 deletions

View File

@@ -15087,7 +15087,7 @@ static int my_DhCallback(WOLFSSL* ssl, struct DhKey* key,
};
static void test_dh_ctx_setup(WOLFSSL_CTX* ctx) {
wolfSSL_CTX_SetDhAgreeCb(ctx, &my_DhCallback);
wolfSSL_CTX_SetDhAgreeCb(ctx, my_DhCallback);
AssertIntEQ(wolfSSL_CTX_set_cipher_list(ctx, "DHE-RSA-AES128-SHA256"),
WOLFSSL_SUCCESS);
}

View File

@@ -2013,6 +2013,21 @@ static INLINE int myX25519SharedSecret(WOLFSSL* ssl, curve25519_key* otherKey,
#endif /* HAVE_ECC */
#ifndef NO_DH
static INLINE int myDhCallback(WOLFSSL* ssl, struct DhKey* key,
const unsigned char* priv, unsigned int privSz,
const unsigned char* pubKeyDer, unsigned int pubKeySz,
unsigned char* out, unsigned int* outlen,
void* ctx)
{
(void)ctx;
(void)ssl;
/* return 0 on success */
return wc_DhAgree(key, out, outlen, priv, privSz, pubKeyDer, pubKeySz);
};
#endif /* !NO_DH */
#ifndef NO_RSA
static INLINE int myRsaSign(WOLFSSL* ssl, const byte* in, word32 inSz,
@@ -2244,6 +2259,9 @@ static INLINE void SetupPkCallbacks(WOLFSSL_CTX* ctx, WOLFSSL* ssl)
wolfSSL_CTX_SetEccVerifyCb(ctx, myEccVerify);
wolfSSL_CTX_SetEccSharedSecretCb(ctx, myEccSharedSecret);
#endif /* HAVE_ECC */
#ifndef NO_DH
wolfSSL_CTX_SetDhAgreeCb(ctx, myDhCallback);
#endif
#ifdef HAVE_ED25519
wolfSSL_CTX_SetEd25519SignCb(ctx, myEd25519Sign);
wolfSSL_CTX_SetEd25519VerifyCb(ctx, myEd25519Verify);