Skip to content

Commit 3f38041

Browse files
authored
Merge pull request #109 from bigbrett/curve25519-blinding-fix
set RNG on curve25519 keys to support blinding
2 parents 756b5f5 + 4cd1a1d commit 3f38041

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/wh_server_crypto.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,15 +1174,21 @@ static int _HandleCurve25519SharedSecret(whServerContext* ctx, uint16_t magic,
11741174
/* init public key */
11751175
ret = wc_curve25519_init_ex(pub, NULL, ctx->crypto->devId);
11761176
if (ret == 0) {
1177-
ret = wh_Server_CacheExportCurve25519Key(
1178-
ctx, prv_key_id, priv);
1177+
#ifdef WOLFSSL_CURVE25519_BLINDING
1178+
ret = wc_curve25519_set_rng(priv, ctx->crypto->rng);
11791179
if (ret == 0) {
1180-
ret = wh_Server_CacheExportCurve25519Key(
1181-
ctx, pub_key_id, pub);
1180+
ret = wc_curve25519_set_rng(pub, ctx->crypto->rng);
1181+
}
1182+
#endif
1183+
if (ret == 0) {
1184+
ret = wh_Server_CacheExportCurve25519Key(ctx, prv_key_id, priv);
1185+
}
1186+
if (ret == 0) {
1187+
ret = wh_Server_CacheExportCurve25519Key(ctx, pub_key_id, pub);
11821188
}
11831189
if (ret == 0) {
1184-
ret = wc_curve25519_shared_secret_ex(
1185-
priv, pub, res_out, &res_len, endian);
1190+
ret = wc_curve25519_shared_secret_ex(priv, pub, res_out,
1191+
&res_len, endian);
11861192
}
11871193
wc_curve25519_free(pub);
11881194
}

0 commit comments

Comments
 (0)