master
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "unitcheck.h"
25#include "vtls/x509asn1.h"
26#include "vtls/vtls.h"
28static CURLcode test_unit1676(const char *arg)
29{
30 UNITTEST_BEGIN_SIMPLE
32#if defined(USE_GNUTLS) || defined(USE_MBEDTLS) || defined(USE_RUSTLS) || \
33 defined(USE_SCHANNEL)
35 /*
36 * Minimal DER-encoded X.509 certificate with a DH public key.
37 * Hand-crafted to exercise the do_pubkey() dhpublicnumber branch.
38 *
39 * The DH parameters contain two distinct INTEGER values:
40 * p = 0x11 (renders as "17" via int2str decimal format)
41 * g = 0x22 (renders as "34")
42 * The public key value is:
43 * pub_key = 0x33 (renders as "51")
44 *
45 * OID 1.2.840.10046.2.1 = dhpublicnumber
46 */
47 static const uint8_t cert[] = {
48 0x30, 0x81, 0x85, 0x30, 0x72, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x01,
49 0x01, 0x30, 0x0B, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01,
50 0x01, 0x0B, 0x30, 0x0F, 0x31, 0x0D, 0x30, 0x0B, 0x06, 0x03, 0x55, 0x04,
51 0x03, 0x0C, 0x04, 0x74, 0x65, 0x73, 0x74, 0x30, 0x1E, 0x17, 0x0D, 0x32,
52 0x35, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5A,
53 0x17, 0x0D, 0x32, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30,
54 0x30, 0x30, 0x5A, 0x30, 0x0F, 0x31, 0x0D, 0x30, 0x0B, 0x06, 0x03, 0x55,
55 0x04, 0x03, 0x0C, 0x04, 0x74, 0x65, 0x73, 0x74, 0x30, 0x19, 0x30, 0x11,
56 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3E, 0x02, 0x01, 0x30, 0x06, 0x02,
57 0x01, 0x11, 0x02, 0x01, 0x22, 0x03, 0x04, 0x00, 0x02, 0x01, 0x33, 0x30,
58 0x0B, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B,
59 0x03, 0x02, 0x00, 0xFF
60 };
62 CURLcode result;
63 const uint8_t *beg = &cert[0];
64 const uint8_t *end = &cert[sizeof(cert)];
65 struct Curl_easy *data;
66 struct curl_slist *slist;
67 const char *dhp_value = NULL;
68 const char *dhg_value = NULL;
69 const char *dhpk_value = NULL;
71 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
72 curl_mfprintf(stderr, "curl_global_init() failed\n");
73 return TEST_ERR_MAJOR_BAD;
74 }
76 data = curl_easy_init();
77 if(!data) {
78 curl_global_cleanup();
79 return TEST_ERR_MAJOR_BAD;
80 }
82 data->set.ssl.certinfo = 1;
83 result = Curl_ssl_init_certinfo(data, 1);
84 if(result) {
85 curl_easy_cleanup(data);
86 curl_global_cleanup();
87 return TEST_ERR_MAJOR_BAD;
88 }
90 result = Curl_extract_certinfo(data, 0, beg, end);
91 fail_unless(result == CURLE_OK, "Curl_extract_certinfo returned error");
92 if(result == CURLE_OK) {
93 /* Walk certinfo entries to find dh(p), dh(g), and dh(pub_key) */
94 for(slist = data->info.certs.certinfo[0]; slist; slist = slist->next) {
95 if(!strncmp(slist->data, "dh(p):", 6))
96 dhp_value = slist->data + 6;
97 else if(!strncmp(slist->data, "dh(g):", 6))
98 dhg_value = slist->data + 6;
99 else if(!strncmp(slist->data, "dh(pub_key):", 12))
100 dhpk_value = slist->data + 12;
101 }
103 abort_unless(dhp_value, "dh(p) not found in certinfo");
104 abort_unless(dhg_value, "dh(g) not found in certinfo");
105 abort_unless(dhpk_value, "dh(pub_key) not found in certinfo");
106 fail_if(!strcmp(dhp_value, dhg_value),
107 "dh(p) and dh(g) have the same value (bug: g re-reads p)");
108 fail_unless(!strcmp(dhp_value, "17"), "dh(p) expected 17 (0x11)");
109 fail_unless(!strcmp(dhg_value, "34"), "dh(g) expected 34 (0x22)");
110 fail_unless(!strcmp(dhpk_value, "51"), "dh(pub_key) expected 51 (0x33)");
111 }
113 curl_easy_cleanup(data);
114 curl_global_cleanup();
115#else
116 puts("not tested since Curl_extract_certinfo() is not built in");
117#endif
118 UNITTEST_END_SIMPLE
119}
Diagnostics4 git calls · 30 ms
CallStatusSizeTime030 ms
discover200152 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B · hit3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=3 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=24 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch2001.8 KiB · hit24 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=1844 git.response.cache=HIT git.response.duration_ms=24 git.fetch.wants=e1d2d92f65a3bcbec0ffc05d9f20d86f45fb8cee git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=1844 git.pkt.payload.max=1823 git.sideband.band1.bytes=1822 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e1fd7d986da9c0
- Request
- 982541e6…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format