Artifactspublic-v0

curl

master
ply4 git calls26 ms289 KiB3 cachedprotocol v2
169 lines5.1 KiBRaw
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 * RFC2104 Keyed-Hashing for Message Authentication
24 *
25 ***************************************************************************/
26#include "curl_setup.h"
28#if !defined(CURL_DISABLE_AWS) || !defined(CURL_DISABLE_DIGEST_AUTH) || \
29 defined(USE_SSL)
31#include "curl_hmac.h"
33/*
34 * Generic HMAC algorithm.
35 *
36 * This module computes HMAC digests based on any hash function. Parameters
37 * and computing procedures are setup dynamically at HMAC computation context
38 * initialization.
39 */
41static const unsigned char hmac_ipad = 0x36;
42static const unsigned char hmac_opad = 0x5C;
44struct HMAC_context *Curl_HMAC_init(const struct HMAC_params *hashparams,
45 const unsigned char *key,
46 unsigned int keylen)
48 size_t i;
49 struct HMAC_context *ctxt;
50 unsigned char *hkey;
51 unsigned char b;
53 /* Create HMAC context. */
54 i = sizeof(*ctxt) + (2 * hashparams->ctxtsize) + hashparams->resultlen;
55 ctxt = curlx_malloc(i);
57 if(!ctxt)
58 return ctxt;
60 ctxt->hash = hashparams;
61 ctxt->hashctxt1 = (void *)(ctxt + 1);
62 ctxt->hashctxt2 = (void *)((char *)ctxt->hashctxt1 + hashparams->ctxtsize);
64 /* If the key is too long, replace it by its hash digest. */
65 if(keylen > hashparams->maxkeylen) {
66 if(hashparams->hinit(ctxt->hashctxt1))
67 goto fail;
68 hashparams->hupdate(ctxt->hashctxt1, key, keylen);
69 hkey = (unsigned char *)ctxt->hashctxt2 + hashparams->ctxtsize;
70 hashparams->hfinal(hkey, ctxt->hashctxt1);
71 key = hkey;
72 keylen = hashparams->resultlen;
73 }
75 /* Prime the two hash contexts with the modified key. */
76 if(hashparams->hinit(ctxt->hashctxt1) ||
77 hashparams->hinit(ctxt->hashctxt2))
78 goto fail;
80 for(i = 0; i < keylen; i++) {
81 b = (unsigned char)(*key ^ hmac_ipad);
82 hashparams->hupdate(ctxt->hashctxt1, &b, 1);
83 b = (unsigned char)(*key++ ^ hmac_opad);
84 hashparams->hupdate(ctxt->hashctxt2, &b, 1);
85 }
87 for(; i < hashparams->maxkeylen; i++) {
88 hashparams->hupdate(ctxt->hashctxt1, &hmac_ipad, 1);
89 hashparams->hupdate(ctxt->hashctxt2, &hmac_opad, 1);
90 }
92 /* Done, return pointer to HMAC context. */
93 return ctxt;
95fail:
96 curlx_free(ctxt);
97 return NULL;
100void Curl_HMAC_update(struct HMAC_context *ctxt,
101 const unsigned char *data,
102 unsigned int len)
104 /* Update first hash calculation. */
105 ctxt->hash->hupdate(ctxt->hashctxt1, data, len);
108int Curl_HMAC_final(struct HMAC_context *ctxt, unsigned char *output)
110 const struct HMAC_params *hashparams = ctxt->hash;
112 /* Do not get output if called with a null parameter: only release
113 storage. */
115 if(!output)
116 output = (unsigned char *)ctxt->hashctxt2 + ctxt->hash->ctxtsize;
118 hashparams->hfinal(output, ctxt->hashctxt1);
119 hashparams->hupdate(ctxt->hashctxt2, output, hashparams->resultlen);
120 hashparams->hfinal(output, ctxt->hashctxt2);
121 curlx_free(ctxt);
122 return 0;
125/*
126 * Curl_hmacit()
127 *
128 * This is used to generate a HMAC hash, for the specified input data, given
129 * the specified hash function and key.
130 *
131 * Parameters:
132 *
133 * hashparams [in] - The hash function (Curl_HMAC_MD5).
134 * key [in] - The key to use.
135 * keylen [in] - The length of the key.
136 * buf [in] - The data to encrypt.
137 * buflen [in] - The length of the data.
138 * output [in/out] - The output buffer.
139 *
140 * Returns CURLE_OK on success.
141 */
142CURLcode Curl_hmacit(const struct HMAC_params *hashparams,
143 const unsigned char *key, const size_t keylen,
144 const unsigned char *data, size_t datalen,
145 unsigned char *output)
147 struct HMAC_context *ctxt;
148 if(keylen > UINT_MAX) /* unlikely to ever happen */
149 return CURLE_BAD_FUNCTION_ARGUMENT;
150 ctxt = Curl_HMAC_init(hashparams, key, curlx_uztoui(keylen));
152 if(!ctxt)
153 return CURLE_OUT_OF_MEMORY;
155 /* Update the digest with the given challenge */
156 do {
157 unsigned int ilen = (unsigned int)CURLMIN(datalen, UINT_MAX);
158 Curl_HMAC_update(ctxt, data, ilen);
159 datalen -= ilen;
160 data += ilen;
161 } while(datalen);
163 /* Finalise the digest */
164 Curl_HMAC_final(ctxt, output);
166 return CURLE_OK;
169#endif /* AWS or Digest and TLS */
Diagnostics4 git calls · 26 ms
CallStatusSizeTime026 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
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 · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=2
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=2
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=86
Open pack map
fetch2001.9 KiB · hit21 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=20
git.response.bytes=1980
git.response.cache=HIT
git.response.duration_ms=21
git.fetch.wants=21575f1f43cb182ea47c049b4f33e3e831c740ad
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=1980
git.pkt.payload.max=1959
git.sideband.band1.bytes=1958
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
a5e15f59af51725b
Request
30a8b427…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format