]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ngtcp2: specify the missing required callback functions
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
Sun, 31 Oct 2021 13:38:44 +0000 (22:38 +0900)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 1 Nov 2021 14:54:24 +0000 (15:54 +0100)
Closes #7929

lib/vquic/ngtcp2.c

index 6f15ceda0c23d81fbafe91697d1e7ffa76cddf3b..2b0f7dbed8db025d23f9afe12eb26da11365b3e0 100644 (file)
@@ -647,6 +647,20 @@ static int cb_extend_max_stream_data(ngtcp2_conn *tconn, int64_t stream_id,
   return 0;
 }
 
+static void cb_rand(uint8_t *dest, size_t destlen,
+                    const ngtcp2_rand_ctx *rand_ctx)
+{
+  CURLcode result;
+  (void)rand_ctx;
+
+  result = Curl_rand(NULL, dest, destlen);
+  if(result) {
+    /* cb_rand is only used for non-cryptographic context.  If Curl_rand
+       failed, just fill 0 and call it *random*. */
+    memset(dest, 0, destlen);
+  }
+}
+
 static int cb_get_new_connection_id(ngtcp2_conn *tconn, ngtcp2_cid *cid,
                                     uint8_t *token, size_t cidlen,
                                     void *user_data)
@@ -684,7 +698,7 @@ static ngtcp2_callbacks ng_callbacks = {
   ngtcp2_crypto_recv_retry_cb,
   cb_extend_max_local_streams_bidi,
   NULL, /* extend_max_local_streams_uni */
-  NULL, /* rand  */
+  cb_rand,
   cb_get_new_connection_id,
   NULL, /* remove_connection_id */
   ngtcp2_crypto_update_key_cb, /* update_key */
@@ -702,7 +716,7 @@ static ngtcp2_callbacks ng_callbacks = {
   NULL, /* recv_datagram */
   NULL, /* ack_datagram */
   NULL, /* lost_datagram */
-  NULL, /* get_path_challenge_data */
+  ngtcp2_crypto_get_path_challenge_data_cb,
   cb_stream_stop_sending
 };