Delete fnptr-struct.md with huggingface_hub
Browse files- fnptr-struct.md +0 -1536
fnptr-struct.md
DELETED
|
@@ -1,1536 +0,0 @@
|
|
| 1 |
-
# Example 1
|
| 2 |
-
|
| 3 |
-
## Callsite
|
| 4 |
-
|
| 5 |
-
*/home/yuanting/work/icall-benchmarks/llm/redis-stable/src/t_zset.c:3102:9*
|
| 6 |
-
|
| 7 |
-
fnptr: *handler->finalizeResultEmission*
|
| 8 |
-
|
| 9 |
-
targets: zrangeResultFinalizeClient, zrangeResultFinalizeStore
|
| 10 |
-
|
| 11 |
-
## Related Code Snippets
|
| 12 |
-
|
| 13 |
-
```c
|
| 14 |
-
void genericZrangebyrankCommand(zrange_result_handler *handler,
|
| 15 |
-
robj *zobj, long start, long end, int withscores, int reverse) {
|
| 16 |
-
if (start > end || start >= llen) {
|
| 17 |
-
handler->beginResultEmission(handler, 0);
|
| 18 |
-
handler->finalizeResultEmission(handler, 0);
|
| 19 |
-
return;
|
| 20 |
-
}
|
| 21 |
-
}
|
| 22 |
-
|
| 23 |
-
static void zrangeResultHandlerInit(zrange_result_handler *handler,
|
| 24 |
-
client *client, zrange_consumer_type type)
|
| 25 |
-
{
|
| 26 |
-
memset(handler, 0, sizeof(*handler));
|
| 27 |
-
|
| 28 |
-
handler->client = client;
|
| 29 |
-
|
| 30 |
-
switch (type) {
|
| 31 |
-
case ZRANGE_CONSUMER_TYPE_CLIENT:
|
| 32 |
-
handler->beginResultEmission = zrangeResultBeginClient;
|
| 33 |
-
handler->finalizeResultEmission = zrangeResultFinalizeClient;
|
| 34 |
-
handler->emitResultFromCBuffer = zrangeResultEmitCBufferToClient;
|
| 35 |
-
handler->emitResultFromLongLong = zrangeResultEmitLongLongToClient;
|
| 36 |
-
break;
|
| 37 |
-
|
| 38 |
-
case ZRANGE_CONSUMER_TYPE_INTERNAL:
|
| 39 |
-
handler->beginResultEmission = zrangeResultBeginStore;
|
| 40 |
-
handler->finalizeResultEmission = zrangeResultFinalizeStore;
|
| 41 |
-
handler->emitResultFromCBuffer = zrangeResultEmitCBufferForStore;
|
| 42 |
-
handler->emitResultFromLongLong = zrangeResultEmitLongLongForStore;
|
| 43 |
-
break;
|
| 44 |
-
}
|
| 45 |
-
}
|
| 46 |
-
```
|
| 47 |
-
|
| 48 |
-
```c
|
| 49 |
-
void zrangestoreCommand (client *c) {
|
| 50 |
-
robj *dstkey = c->argv[1];
|
| 51 |
-
zrange_result_handler handler;
|
| 52 |
-
zrangeResultHandlerInit(&handler, c, ZRANGE_CONSUMER_TYPE_INTERNAL);
|
| 53 |
-
zrangeResultHandlerDestinationKeySet(&handler, dstkey);
|
| 54 |
-
zrangeGenericCommand(&handler, 2, 1, ZRANGE_AUTO, ZRANGE_DIRECTION_AUTO);
|
| 55 |
-
}
|
| 56 |
-
```
|
| 57 |
-
|
| 58 |
-
```c
|
| 59 |
-
void zrangeGenericCommand(zrange_result_handler *handler, int argc_start, int store,
|
| 60 |
-
zrange_type rangetype, zrange_direction direction)
|
| 61 |
-
{
|
| 62 |
-
switch (rangetype) {
|
| 63 |
-
case ZRANGE_AUTO:
|
| 64 |
-
case ZRANGE_RANK:
|
| 65 |
-
genericZrangebyrankCommand(handler, zobj, opt_start, opt_end,
|
| 66 |
-
opt_withscores || store, direction == ZRANGE_DIRECTION_REVERSE);
|
| 67 |
-
break;
|
| 68 |
-
|
| 69 |
-
case ZRANGE_SCORE:
|
| 70 |
-
genericZrangebyscoreCommand(handler, &range, zobj, opt_offset,
|
| 71 |
-
opt_limit, direction == ZRANGE_DIRECTION_REVERSE);
|
| 72 |
-
break;
|
| 73 |
-
|
| 74 |
-
case ZRANGE_LEX:
|
| 75 |
-
genericZrangebylexCommand(handler, &lexrange, zobj, opt_withscores || store,
|
| 76 |
-
opt_offset, opt_limit, direction == ZRANGE_DIRECTION_REVERSE);
|
| 77 |
-
break;
|
| 78 |
-
}
|
| 79 |
-
}
|
| 80 |
-
```
|
| 81 |
-
|
| 82 |
-
```c
|
| 83 |
-
static void zrangeResultBeginClient(zrange_result_handler *handler, long length) {
|
| 84 |
-
if (length > 0) {
|
| 85 |
-
/* In case of WITHSCORES, respond with a single array in RESP2, and
|
| 86 |
-
* nested arrays in RESP3. We can't use a map response type since the
|
| 87 |
-
* client library needs to know to respect the order. */
|
| 88 |
-
if (handler->withscores && (handler->client->resp == 2)) {
|
| 89 |
-
length *= 2;
|
| 90 |
-
}
|
| 91 |
-
addReplyArrayLen(handler->client, length);
|
| 92 |
-
handler->userdata = NULL;
|
| 93 |
-
return;
|
| 94 |
-
}
|
| 95 |
-
handler->userdata = addReplyDeferredLen(handler->client);
|
| 96 |
-
}
|
| 97 |
-
```
|
| 98 |
-
|
| 99 |
-
```c
|
| 100 |
-
static void zrangeResultFinalizeClient(zrange_result_handler *handler,
|
| 101 |
-
size_t result_count)
|
| 102 |
-
{
|
| 103 |
-
/* If the reply size was know at start there's nothing left to do */
|
| 104 |
-
if (!handler->userdata)
|
| 105 |
-
return;
|
| 106 |
-
/* In case of WITHSCORES, respond with a single array in RESP2, and
|
| 107 |
-
* nested arrays in RESP3. We can't use a map response type since the
|
| 108 |
-
* client library needs to know to respect the order. */
|
| 109 |
-
if (handler->withscores && (handler->client->resp == 2)) {
|
| 110 |
-
result_count *= 2;
|
| 111 |
-
}
|
| 112 |
-
|
| 113 |
-
setDeferredArrayLen(handler->client, handler->userdata, result_count);
|
| 114 |
-
}
|
| 115 |
-
```
|
| 116 |
-
|
| 117 |
-
```c
|
| 118 |
-
static void zrangeResultEmitCBufferToClient(zrange_result_handler *handler,
|
| 119 |
-
const void *value, size_t value_length_in_bytes, double score)
|
| 120 |
-
{
|
| 121 |
-
if (handler->should_emit_array_length) {
|
| 122 |
-
addReplyArrayLen(handler->client, 2);
|
| 123 |
-
}
|
| 124 |
-
|
| 125 |
-
addReplyBulkCBuffer(handler->client, value, value_length_in_bytes);
|
| 126 |
-
|
| 127 |
-
if (handler->withscores) {
|
| 128 |
-
addReplyDouble(handler->client, score);
|
| 129 |
-
}
|
| 130 |
-
}
|
| 131 |
-
```
|
| 132 |
-
|
| 133 |
-
```c
|
| 134 |
-
static void zrangeResultEmitLongLongToClient(zrange_result_handler *handler,
|
| 135 |
-
long long value, double score)
|
| 136 |
-
{
|
| 137 |
-
if (handler->should_emit_array_length) {
|
| 138 |
-
addReplyArrayLen(handler->client, 2);
|
| 139 |
-
}
|
| 140 |
-
|
| 141 |
-
addReplyBulkLongLong(handler->client, value);
|
| 142 |
-
|
| 143 |
-
if (handler->withscores) {
|
| 144 |
-
addReplyDouble(handler->client, score);
|
| 145 |
-
}
|
| 146 |
-
}
|
| 147 |
-
```
|
| 148 |
-
|
| 149 |
-
```c
|
| 150 |
-
static void zrangeResultBeginStore(zrange_result_handler *handler, long length)
|
| 151 |
-
{
|
| 152 |
-
handler->dstobj = zsetTypeCreate(length, 0);
|
| 153 |
-
}
|
| 154 |
-
```
|
| 155 |
-
|
| 156 |
-
```c
|
| 157 |
-
static void zrangeResultFinalizeStore(zrange_result_handler *handler, size_t result_count)
|
| 158 |
-
{
|
| 159 |
-
if (result_count) {
|
| 160 |
-
setKey(handler->client, handler->client->db, handler->dstkey, handler->dstobj, 0);
|
| 161 |
-
addReplyLongLong(handler->client, result_count);
|
| 162 |
-
notifyKeyspaceEvent(NOTIFY_ZSET, "zrangestore", handler->dstkey, handler->client->db->id);
|
| 163 |
-
server.dirty++;
|
| 164 |
-
} else {
|
| 165 |
-
addReply(handler->client, shared.czero);
|
| 166 |
-
if (dbDelete(handler->client->db, handler->dstkey)) {
|
| 167 |
-
signalModifiedKey(handler->client, handler->client->db, handler->dstkey);
|
| 168 |
-
notifyKeyspaceEvent(NOTIFY_GENERIC, "del", handler->dstkey, handler->client->db->id);
|
| 169 |
-
server.dirty++;
|
| 170 |
-
}
|
| 171 |
-
}
|
| 172 |
-
decrRefCount(handler->dstobj);
|
| 173 |
-
}
|
| 174 |
-
```
|
| 175 |
-
|
| 176 |
-
```c
|
| 177 |
-
static void zrangeResultEmitCBufferForStore(zrange_result_handler *handler,
|
| 178 |
-
const void *value, size_t value_length_in_bytes, double score)
|
| 179 |
-
{
|
| 180 |
-
double newscore;
|
| 181 |
-
int retflags = 0;
|
| 182 |
-
sds ele = sdsnewlen(value, value_length_in_bytes);
|
| 183 |
-
int retval = zsetAdd(handler->dstobj, score, ele, ZADD_IN_NONE, &retflags, &newscore);
|
| 184 |
-
sdsfree(ele);
|
| 185 |
-
serverAssert(retval);
|
| 186 |
-
}
|
| 187 |
-
```
|
| 188 |
-
|
| 189 |
-
```c
|
| 190 |
-
static void zrangeResultEmitLongLongForStore(zrange_result_handler *handler,
|
| 191 |
-
long long value, double score)
|
| 192 |
-
{
|
| 193 |
-
double newscore;
|
| 194 |
-
int retflags = 0;
|
| 195 |
-
sds ele = sdsfromlonglong(value);
|
| 196 |
-
int retval = zsetAdd(handler->dstobj, score, ele, ZADD_IN_NONE, &retflags, &newscore);
|
| 197 |
-
sdsfree(ele);
|
| 198 |
-
serverAssert(retval);
|
| 199 |
-
}
|
| 200 |
-
```
|
| 201 |
-
|
| 202 |
-
# Example 2
|
| 203 |
-
|
| 204 |
-
## Callsite
|
| 205 |
-
|
| 206 |
-
*/home/yuanting/work/icall-benchmarks/llm/gcc-clang-build/build-x86_64-pc-linux-gnu/libcpp/../../../gcc-13.2.0/libcpp/directives.cc:2611:5*
|
| 207 |
-
|
| 208 |
-
fnptr: *pfile->cb.before_define*
|
| 209 |
-
|
| 210 |
-
targets: dump_queued_macros
|
| 211 |
-
|
| 212 |
-
## Related Code Snippets
|
| 213 |
-
|
| 214 |
-
```c
|
| 215 |
-
static void
|
| 216 |
-
cpp_pop_definition (cpp_reader *pfile, struct def_pragma_macro *c)
|
| 217 |
-
{
|
| 218 |
-
cpp_hashnode *node = _cpp_lex_identifier (pfile, c->name);
|
| 219 |
-
if (node == NULL)
|
| 220 |
-
return;
|
| 221 |
-
|
| 222 |
-
if (pfile->cb.before_define)
|
| 223 |
-
pfile->cb.before_define (pfile);
|
| 224 |
-
...
|
| 225 |
-
}
|
| 226 |
-
```
|
| 227 |
-
|
| 228 |
-
```c
|
| 229 |
-
if (flag_dump_macros == 'U')
|
| 230 |
-
{
|
| 231 |
-
cb->before_define = dump_queued_macros;
|
| 232 |
-
cb->used_define = cb_used_define;
|
| 233 |
-
cb->used_undef = cb_used_undef;
|
| 234 |
-
}
|
| 235 |
-
```
|
| 236 |
-
|
| 237 |
-
```c
|
| 238 |
-
if (gfc_cpp_option.dump_macros == 'U')
|
| 239 |
-
{
|
| 240 |
-
cb->before_define = dump_queued_macros;
|
| 241 |
-
...
|
| 242 |
-
|
| 243 |
-
}
|
| 244 |
-
```
|
| 245 |
-
|
| 246 |
-
# Example 3
|
| 247 |
-
|
| 248 |
-
## Callsite
|
| 249 |
-
|
| 250 |
-
*/home/yuanting/work/icall-benchmarks/llm/ffmpeg-6.1.1/libavcodec/aaccoder.c:671:5*
|
| 251 |
-
|
| 252 |
-
fnptr: *s->abs_pow34*
|
| 253 |
-
|
| 254 |
-
targets: ff_abs_pow34_sse, abs_pow34_v
|
| 255 |
-
|
| 256 |
-
## Related Code Snippets
|
| 257 |
-
|
| 258 |
-
```c
|
| 259 |
-
av_cold void ff_aac_dsp_init_x86(AACEncContext *s)
|
| 260 |
-
{
|
| 261 |
-
int cpu_flags = av_get_cpu_flags();
|
| 262 |
-
|
| 263 |
-
if (EXTERNAL_SSE(cpu_flags))
|
| 264 |
-
s->abs_pow34 = ff_abs_pow34_sse;
|
| 265 |
-
|
| 266 |
-
if (EXTERNAL_SSE2(cpu_flags))
|
| 267 |
-
s->quant_bands = ff_aac_quantize_bands_sse2;
|
| 268 |
-
}
|
| 269 |
-
```
|
| 270 |
-
|
| 271 |
-
```c
|
| 272 |
-
static av_cold int aac_encode_init(AVCodecContext *avctx)
|
| 273 |
-
{
|
| 274 |
-
AACEncContext *s = avctx->priv_data;
|
| 275 |
-
...
|
| 276 |
-
s->random_state = 0x1f2e3d4c;
|
| 277 |
-
|
| 278 |
-
s->abs_pow34 = abs_pow34_v;
|
| 279 |
-
s->quant_bands = quantize_bands;
|
| 280 |
-
...
|
| 281 |
-
}
|
| 282 |
-
```
|
| 283 |
-
|
| 284 |
-
```c
|
| 285 |
-
static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s,
|
| 286 |
-
SingleChannelElement *sce,
|
| 287 |
-
const float lambda)
|
| 288 |
-
{
|
| 289 |
-
int start = 0, i, w, w2, g;
|
| 290 |
-
...
|
| 291 |
-
if (!allz)
|
| 292 |
-
return;
|
| 293 |
-
s->abs_pow34(s->scoefs, sce->coeffs, 1024);
|
| 294 |
-
ff_quantize_band_cost_cache_init(s);
|
| 295 |
-
...
|
| 296 |
-
}
|
| 297 |
-
```
|
| 298 |
-
|
| 299 |
-
# Example 4
|
| 300 |
-
|
| 301 |
-
## Callsite
|
| 302 |
-
|
| 303 |
-
*/home/yuanting/work/icall-benchmarks/llm/wrk-4.2.0/src/ae.c:322:22*
|
| 304 |
-
|
| 305 |
-
fnptr: *te->timeProc*
|
| 306 |
-
|
| 307 |
-
targets: record_rate
|
| 308 |
-
|
| 309 |
-
## Related Code Snippets
|
| 310 |
-
|
| 311 |
-
```c
|
| 312 |
-
/* Process time events */
|
| 313 |
-
static int processTimeEvents(aeEventLoop *eventLoop) {
|
| 314 |
-
int processed = 0;
|
| 315 |
-
...
|
| 316 |
-
while(te) {
|
| 317 |
-
...
|
| 318 |
-
aeGetTime(&now_sec, &now_ms);
|
| 319 |
-
if (now_sec > te->when_sec ||
|
| 320 |
-
(now_sec == te->when_sec && now_ms >= te->when_ms))
|
| 321 |
-
{
|
| 322 |
-
...
|
| 323 |
-
retval = te->timeProc(eventLoop, id, te->clientData);
|
| 324 |
-
...
|
| 325 |
-
}
|
| 326 |
-
return processed;
|
| 327 |
-
}
|
| 328 |
-
}
|
| 329 |
-
```
|
| 330 |
-
|
| 331 |
-
```c
|
| 332 |
-
void *thread_main(void *arg) {
|
| 333 |
-
thread *thread = arg;
|
| 334 |
-
...
|
| 335 |
-
aeEventLoop *loop = thread->loop;
|
| 336 |
-
aeCreateTimeEvent(loop, RECORD_INTERVAL_MS, record_rate, thread, NULL);
|
| 337 |
-
|
| 338 |
-
...
|
| 339 |
-
aeMain(loop);
|
| 340 |
-
...
|
| 341 |
-
return NULL;
|
| 342 |
-
}
|
| 343 |
-
```
|
| 344 |
-
|
| 345 |
-
```c
|
| 346 |
-
long long aeCreateTimeEvent(aeEventLoop *eventLoop, long long milliseconds,
|
| 347 |
-
aeTimeProc *proc, void *clientData,
|
| 348 |
-
aeEventFinalizerProc *finalizerProc)
|
| 349 |
-
{
|
| 350 |
-
...
|
| 351 |
-
te->timeProc = proc;
|
| 352 |
-
...
|
| 353 |
-
return id;
|
| 354 |
-
}
|
| 355 |
-
```
|
| 356 |
-
|
| 357 |
-
```c
|
| 358 |
-
void aeMain(aeEventLoop *eventLoop) {
|
| 359 |
-
eventLoop->stop = 0;
|
| 360 |
-
while (!eventLoop->stop) {
|
| 361 |
-
if (eventLoop->beforesleep != NULL)
|
| 362 |
-
eventLoop->beforesleep(eventLoop);
|
| 363 |
-
aeProcessEvents(eventLoop, AE_ALL_EVENTS);
|
| 364 |
-
}
|
| 365 |
-
}
|
| 366 |
-
```
|
| 367 |
-
|
| 368 |
-
```c
|
| 369 |
-
int aeProcessEvents(aeEventLoop *eventLoop, int flags)
|
| 370 |
-
{
|
| 371 |
-
...
|
| 372 |
-
/* Check time events */
|
| 373 |
-
if (flags & AE_TIME_EVENTS)
|
| 374 |
-
processed += processTimeEvents(eventLoop);
|
| 375 |
-
|
| 376 |
-
return processed; /* return the number of processed file/time events */
|
| 377 |
-
}
|
| 378 |
-
```
|
| 379 |
-
|
| 380 |
-
# Example 5
|
| 381 |
-
|
| 382 |
-
## Callsite
|
| 383 |
-
|
| 384 |
-
*/home/yuanting/work/icall-benchmarks/llm/zfs-build/../zfs-2.2.2/cmd/zdb/zdb.c:442:10*
|
| 385 |
-
|
| 386 |
-
fnptr: *uic->uic_cb*
|
| 387 |
-
|
| 388 |
-
targets: spacemap_check_sm_log_cb, load_unflushed_cb, load_unflushed_svr_segs_cb, count_unflushed_space_cb, log_spacemap_obsolete_stats_cb
|
| 389 |
-
|
| 390 |
-
## Related Code Snippets
|
| 391 |
-
|
| 392 |
-
```c
|
| 393 |
-
static int iterate_through_spacemap_logs_cb(space_map_entry_t *sme, void *arg)
|
| 394 |
-
{
|
| 395 |
-
unflushed_iter_cb_arg_t *uic = arg;
|
| 396 |
-
return (uic->uic_cb(uic->uic_spa, sme, uic->uic_txg, uic->uic_arg));
|
| 397 |
-
}
|
| 398 |
-
```
|
| 399 |
-
|
| 400 |
-
```c
|
| 401 |
-
static void iterate_through_spacemap_logs(spa_t *spa, zdb_log_sm_cb_t cb, void *arg)
|
| 402 |
-
{
|
| 403 |
-
if (!spa_feature_is_active(spa, SPA_FEATURE_LOG_SPACEMAP))
|
| 404 |
-
return;
|
| 405 |
-
|
| 406 |
-
spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER);
|
| 407 |
-
for (spa_log_sm_t *sls = avl_first(&spa->spa_sm_logs_by_txg);
|
| 408 |
-
sls; sls = AVL_NEXT(&spa->spa_sm_logs_by_txg, sls)) {
|
| 409 |
-
...
|
| 410 |
-
|
| 411 |
-
unflushed_iter_cb_arg_t uic = {
|
| 412 |
-
.uic_spa = spa,
|
| 413 |
-
.uic_txg = sls->sls_txg,
|
| 414 |
-
.uic_arg = arg,
|
| 415 |
-
.uic_cb = cb
|
| 416 |
-
};
|
| 417 |
-
VERIFY0(space_map_iterate(sm, space_map_length(sm),
|
| 418 |
-
iterate_through_spacemap_logs_cb, &uic));
|
| 419 |
-
space_map_close(sm);
|
| 420 |
-
}
|
| 421 |
-
spa_config_exit(spa, SCL_CONFIG, FTAG);
|
| 422 |
-
}
|
| 423 |
-
```
|
| 424 |
-
|
| 425 |
-
```c
|
| 426 |
-
int space_map_iterate(space_map_t *sm, uint64_t end, sm_cb_t callback, void *arg)
|
| 427 |
-
{
|
| 428 |
-
uint64_t blksz = sm->sm_blksz;
|
| 429 |
-
|
| 430 |
-
...
|
| 431 |
-
for (uint64_t block_base = 0; block_base < end && error == 0;
|
| 432 |
-
block_base += blksz) {
|
| 433 |
-
...
|
| 434 |
-
|
| 435 |
-
for (uint64_t *block_cursor = block_start;
|
| 436 |
-
block_cursor < block_end && error == 0; block_cursor++) {
|
| 437 |
-
uint64_t e = *block_cursor;
|
| 438 |
-
|
| 439 |
-
...
|
| 440 |
-
error = callback(&sme, arg);
|
| 441 |
-
}
|
| 442 |
-
dmu_buf_rele(db, FTAG);
|
| 443 |
-
}
|
| 444 |
-
return (error);
|
| 445 |
-
}
|
| 446 |
-
```
|
| 447 |
-
|
| 448 |
-
```c
|
| 449 |
-
static void spacemap_check_sm_log(spa_t *spa, metaslab_verify_t *mv)
|
| 450 |
-
{
|
| 451 |
-
iterate_through_spacemap_logs(spa, spacemap_check_sm_log_cb, mv);
|
| 452 |
-
}
|
| 453 |
-
```
|
| 454 |
-
|
| 455 |
-
```c
|
| 456 |
-
static void load_unflushed_to_ms_allocatables(spa_t *spa, maptype_t maptype)
|
| 457 |
-
{
|
| 458 |
-
iterate_through_spacemap_logs(spa, load_unflushed_cb, &maptype);
|
| 459 |
-
}
|
| 460 |
-
```
|
| 461 |
-
|
| 462 |
-
```c
|
| 463 |
-
static void zdb_claim_removing(spa_t *spa, zdb_cb_t *zcb)
|
| 464 |
-
{
|
| 465 |
-
...
|
| 466 |
-
iterate_through_spacemap_logs(spa, load_unflushed_svr_segs_cb, svr);
|
| 467 |
-
...
|
| 468 |
-
}
|
| 469 |
-
```
|
| 470 |
-
|
| 471 |
-
```c
|
| 472 |
-
static int64_t get_unflushed_alloc_space(spa_t *spa)
|
| 473 |
-
{
|
| 474 |
-
if (dump_opt['L'])
|
| 475 |
-
return (0);
|
| 476 |
-
|
| 477 |
-
int64_t ualloc_space = 0;
|
| 478 |
-
iterate_through_spacemap_logs(spa, count_unflushed_space_cb,
|
| 479 |
-
&ualloc_space);
|
| 480 |
-
return (ualloc_space);
|
| 481 |
-
}
|
| 482 |
-
```
|
| 483 |
-
|
| 484 |
-
```c
|
| 485 |
-
static void dump_log_spacemap_obsolete_stats(spa_t *spa)
|
| 486 |
-
{
|
| 487 |
-
...
|
| 488 |
-
iterate_through_spacemap_logs(spa,
|
| 489 |
-
log_spacemap_obsolete_stats_cb, &lsos);
|
| 490 |
-
...
|
| 491 |
-
}
|
| 492 |
-
```
|
| 493 |
-
|
| 494 |
-
# Example 6
|
| 495 |
-
|
| 496 |
-
## Callsite
|
| 497 |
-
|
| 498 |
-
*/home/yuanting/work/icall-benchmarks/llm/redis-stable/src/dict.c:1143:29*
|
| 499 |
-
|
| 500 |
-
fnptr: *defragalloc*
|
| 501 |
-
|
| 502 |
-
targets: activeDefragAlloc
|
| 503 |
-
|
| 504 |
-
## Related Code Snippets
|
| 505 |
-
|
| 506 |
-
```c
|
| 507 |
-
static void dictDefragBucket(dict *d, dictEntry **bucketref, dictDefragFunctions *defragfns) {
|
| 508 |
-
dictDefragAllocFunction *defragalloc = defragfns->defragAlloc;
|
| 509 |
-
dictDefragAllocFunction *defragkey = defragfns->defragKey;
|
| 510 |
-
dictDefragAllocFunction *defragval = defragfns->defragVal;
|
| 511 |
-
while (bucketref && *bucketref) {
|
| 512 |
-
dictEntry *de = *bucketref, *newde = NULL;
|
| 513 |
-
void *newkey = defragkey ? defragkey(dictGetKey(de)) : NULL;
|
| 514 |
-
void *newval = defragval ? defragval(dictGetVal(de)) : NULL;
|
| 515 |
-
if (entryIsKey(de)) {
|
| 516 |
-
if (newkey) *bucketref = newkey;
|
| 517 |
-
assert(entryIsKey(*bucketref));
|
| 518 |
-
} else if (entryIsNoValue(de)) {
|
| 519 |
-
dictEntryNoValue *entry = decodeEntryNoValue(de), *newentry;
|
| 520 |
-
if ((newentry = defragalloc(entry))) {
|
| 521 |
-
newde = encodeMaskedPtr(newentry, ENTRY_PTR_NO_VALUE);
|
| 522 |
-
entry = newentry;
|
| 523 |
-
}
|
| 524 |
-
}
|
| 525 |
-
}
|
| 526 |
-
}
|
| 527 |
-
```
|
| 528 |
-
|
| 529 |
-
```c
|
| 530 |
-
unsigned long dictScanDefrag(dict *d,
|
| 531 |
-
unsigned long v,
|
| 532 |
-
dictScanFunction *fn,
|
| 533 |
-
dictDefragFunctions *defragfns,
|
| 534 |
-
void *privdata)
|
| 535 |
-
{
|
| 536 |
-
...
|
| 537 |
-
if (!dictIsRehashing(d)) {
|
| 538 |
-
...
|
| 539 |
-
|
| 540 |
-
/* Emit entries at cursor */
|
| 541 |
-
if (defragfns) {
|
| 542 |
-
dictDefragBucket(d, &d->ht_table[htidx0][v & m0], defragfns);
|
| 543 |
-
}
|
| 544 |
-
...
|
| 545 |
-
} else {
|
| 546 |
-
...
|
| 547 |
-
if (defragfns) {
|
| 548 |
-
dictDefragBucket(d, &d->ht_table[htidx0][v & m0], defragfns);
|
| 549 |
-
}
|
| 550 |
-
...
|
| 551 |
-
do {
|
| 552 |
-
if (defragfns) {
|
| 553 |
-
dictDefragBucket(d, &d->ht_table[htidx1][v & m1], defragfns);
|
| 554 |
-
}
|
| 555 |
-
...
|
| 556 |
-
} while (v & (m0 ^ m1));
|
| 557 |
-
}
|
| 558 |
-
return v;
|
| 559 |
-
}
|
| 560 |
-
```
|
| 561 |
-
|
| 562 |
-
```c
|
| 563 |
-
void activeDefragCycle(void) {
|
| 564 |
-
...
|
| 565 |
-
|
| 566 |
-
dictDefragFunctions defragfns = {.defragAlloc = activeDefragAlloc};
|
| 567 |
-
do {
|
| 568 |
-
do {
|
| 569 |
-
...
|
| 570 |
-
|
| 571 |
-
/* Scan the keyspace dict unless we're scanning the expire dict. */
|
| 572 |
-
if (!expires_cursor)
|
| 573 |
-
cursor = dictScanDefrag(db->dict, cursor, defragScanCallback,
|
| 574 |
-
&defragfns, db);
|
| 575 |
-
|
| 576 |
-
/* When done scanning the keyspace dict, we scan the expire dict. */
|
| 577 |
-
if (!cursor)
|
| 578 |
-
expires_cursor = dictScanDefrag(db->expires, expires_cursor,
|
| 579 |
-
scanCallbackCountScanned,
|
| 580 |
-
&defragfns, NULL);
|
| 581 |
-
...
|
| 582 |
-
}
|
| 583 |
-
}
|
| 584 |
-
}
|
| 585 |
-
```
|
| 586 |
-
|
| 587 |
-
```c
|
| 588 |
-
void scanLaterZset(robj *ob, unsigned long *cursor) {
|
| 589 |
-
if (ob->type != OBJ_ZSET || ob->encoding != OBJ_ENCODING_SKIPLIST)
|
| 590 |
-
return;
|
| 591 |
-
zset *zs = (zset*)ob->ptr;
|
| 592 |
-
dict *d = zs->dict;
|
| 593 |
-
scanLaterZsetData data = {zs};
|
| 594 |
-
dictDefragFunctions defragfns = {.defragAlloc = activeDefragAlloc};
|
| 595 |
-
*cursor = dictScanDefrag(d, *cursor, scanLaterZsetCallback, &defragfns, &data);
|
| 596 |
-
}
|
| 597 |
-
```
|
| 598 |
-
|
| 599 |
-
```c
|
| 600 |
-
void scanLaterSet(robj *ob, unsigned long *cursor) {
|
| 601 |
-
if (ob->type != OBJ_SET || ob->encoding != OBJ_ENCODING_HT)
|
| 602 |
-
return;
|
| 603 |
-
dict *d = ob->ptr;
|
| 604 |
-
dictDefragFunctions defragfns = {
|
| 605 |
-
.defragAlloc = activeDefragAlloc,
|
| 606 |
-
.defragKey = (dictDefragAllocFunction *)activeDefragSds
|
| 607 |
-
};
|
| 608 |
-
*cursor = dictScanDefrag(d, *cursor, scanCallbackCountScanned, &defragfns, NULL);
|
| 609 |
-
}
|
| 610 |
-
```
|
| 611 |
-
|
| 612 |
-
```c
|
| 613 |
-
void scanLaterHash(robj *ob, unsigned long *cursor) {
|
| 614 |
-
if (ob->type != OBJ_HASH || ob->encoding != OBJ_ENCODING_HT)
|
| 615 |
-
return;
|
| 616 |
-
dict *d = ob->ptr;
|
| 617 |
-
dictDefragFunctions defragfns = {
|
| 618 |
-
.defragAlloc = activeDefragAlloc,
|
| 619 |
-
.defragKey = (dictDefragAllocFunction *)activeDefragSds,
|
| 620 |
-
.defragVal = (dictDefragAllocFunction *)activeDefragSds
|
| 621 |
-
};
|
| 622 |
-
*cursor = dictScanDefrag(d, *cursor, scanCallbackCountScanned, &defragfns, NULL);
|
| 623 |
-
}
|
| 624 |
-
```
|
| 625 |
-
|
| 626 |
-
```c
|
| 627 |
-
unsigned long dictScan(dict *d,
|
| 628 |
-
unsigned long v,
|
| 629 |
-
dictScanFunction *fn,
|
| 630 |
-
void *privdata)
|
| 631 |
-
{
|
| 632 |
-
return dictScanDefrag(d, v, fn, NULL, privdata);
|
| 633 |
-
}
|
| 634 |
-
```
|
| 635 |
-
|
| 636 |
-
# Example 7
|
| 637 |
-
|
| 638 |
-
## Callsite
|
| 639 |
-
|
| 640 |
-
*/home/yuanting/work/icall-benchmarks/llm/redis-stable/src/functions.c:428:13*
|
| 641 |
-
|
| 642 |
-
fnptr: *engine->get_engine_memory_overhead*
|
| 643 |
-
|
| 644 |
-
targets: luaEngineMemoryOverhead
|
| 645 |
-
|
| 646 |
-
## Related Code Snippets
|
| 647 |
-
|
| 648 |
-
```c
|
| 649 |
-
int functionsRegisterEngine(const char *engine_name, engine *engine) {
|
| 650 |
-
sds engine_name_sds = sdsnew(engine_name);
|
| 651 |
-
if (dictFetchValue(engines, engine_name_sds)) {
|
| 652 |
-
serverLog(LL_WARNING, "Same engine was registered twice");
|
| 653 |
-
sdsfree(engine_name_sds);
|
| 654 |
-
return C_ERR;
|
| 655 |
-
}
|
| 656 |
-
|
| 657 |
-
client *c = createClient(NULL);
|
| 658 |
-
c->flags |= (CLIENT_DENY_BLOCKING | CLIENT_SCRIPT);
|
| 659 |
-
engineInfo *ei = zmalloc(sizeof(*ei));
|
| 660 |
-
*ei = (engineInfo ) { .name = engine_name_sds, .engine = engine, .c = c,};
|
| 661 |
-
|
| 662 |
-
dictAdd(engines, engine_name_sds, ei);
|
| 663 |
-
|
| 664 |
-
engine_cache_memory += zmalloc_size(ei) + sdsZmallocSize(ei->name) +
|
| 665 |
-
zmalloc_size(engine) +
|
| 666 |
-
engine->get_engine_memory_overhead(engine->engine_ctx);
|
| 667 |
-
|
| 668 |
-
return C_OK;
|
| 669 |
-
}
|
| 670 |
-
```
|
| 671 |
-
|
| 672 |
-
```c
|
| 673 |
-
int luaEngineInitEngine(void) {
|
| 674 |
-
luaEngineCtx *lua_engine_ctx = zmalloc(sizeof(*lua_engine_ctx));
|
| 675 |
-
lua_engine_ctx->lua = lua_open();
|
| 676 |
-
|
| 677 |
-
...
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
engine *lua_engine = zmalloc(sizeof(*lua_engine));
|
| 681 |
-
*lua_engine = (engine) {
|
| 682 |
-
.engine_ctx = lua_engine_ctx,
|
| 683 |
-
.create = luaEngineCreate,
|
| 684 |
-
.call = luaEngineCall,
|
| 685 |
-
.get_used_memory = luaEngineGetUsedMemoy,
|
| 686 |
-
.get_function_memory_overhead = luaEngineFunctionMemoryOverhead,
|
| 687 |
-
.get_engine_memory_overhead = luaEngineMemoryOverhead,
|
| 688 |
-
.free_function = luaEngineFreeFunction,
|
| 689 |
-
};
|
| 690 |
-
return functionsRegisterEngine(LUA_ENGINE_NAME, lua_engine);
|
| 691 |
-
}
|
| 692 |
-
```
|
| 693 |
-
|
| 694 |
-
# Example 8
|
| 695 |
-
|
| 696 |
-
## Callsite
|
| 697 |
-
|
| 698 |
-
*/home/yuanting/work/icall-benchmarks/llm/wrk-4.2.0/obj/openssl-1.1.1i/crypto/evp/p_lib.c:42:12*
|
| 699 |
-
|
| 700 |
-
fnptr: *pkey->ameth->pkey_security_bits*
|
| 701 |
-
|
| 702 |
-
targets: NULL
|
| 703 |
-
|
| 704 |
-
## Related Code Snippets
|
| 705 |
-
|
| 706 |
-
```c
|
| 707 |
-
int EVP_PKEY_security_bits(const EVP_PKEY *pkey)
|
| 708 |
-
{
|
| 709 |
-
if (pkey == NULL)
|
| 710 |
-
return 0;
|
| 711 |
-
if (!pkey->ameth || !pkey->ameth->pkey_security_bits)
|
| 712 |
-
return -2;
|
| 713 |
-
return pkey->ameth->pkey_security_bits(pkey);
|
| 714 |
-
}
|
| 715 |
-
```
|
| 716 |
-
|
| 717 |
-
```c
|
| 718 |
-
void EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth,
|
| 719 |
-
int (*pkey_security_bits) (const EVP_PKEY
|
| 720 |
-
*pk))
|
| 721 |
-
{
|
| 722 |
-
ameth->pkey_security_bits = pkey_security_bits;
|
| 723 |
-
}
|
| 724 |
-
```
|
| 725 |
-
|
| 726 |
-
# Example 9
|
| 727 |
-
|
| 728 |
-
## Callsite
|
| 729 |
-
|
| 730 |
-
*/home/yuanting/work/icall-benchmarks/llm/wrk-4.2.0/obj/openssl-1.1.1i/apps/s_cb.c:1356:10*
|
| 731 |
-
|
| 732 |
-
fnptr: *sdb->old_cb*
|
| 733 |
-
|
| 734 |
-
targets: ssl_security_default_callback
|
| 735 |
-
|
| 736 |
-
## Related Code Snippets
|
| 737 |
-
|
| 738 |
-
```c
|
| 739 |
-
static int security_callback_debug(const SSL *s, const SSL_CTX *ctx,
|
| 740 |
-
int op, int bits, int nid,
|
| 741 |
-
void *other, void *ex)
|
| 742 |
-
{
|
| 743 |
-
security_debug_ex *sdb = ex;
|
| 744 |
-
int rv, show_bits = 1, cert_md = 0;
|
| 745 |
-
const char *nm;
|
| 746 |
-
int show_nm;
|
| 747 |
-
rv = sdb->old_cb(s, ctx, op, bits, nid, other, ex);
|
| 748 |
-
}
|
| 749 |
-
```
|
| 750 |
-
|
| 751 |
-
```c
|
| 752 |
-
void ssl_ctx_security_debug(SSL_CTX *ctx, int verbose)
|
| 753 |
-
{
|
| 754 |
-
static security_debug_ex sdb;
|
| 755 |
-
|
| 756 |
-
sdb.out = bio_err;
|
| 757 |
-
sdb.verbose = verbose;
|
| 758 |
-
sdb.old_cb = SSL_CTX_get_security_callback(ctx);
|
| 759 |
-
SSL_CTX_set_security_callback(ctx, security_callback_debug);
|
| 760 |
-
SSL_CTX_set0_security_ex_data(ctx, &sdb);
|
| 761 |
-
}
|
| 762 |
-
```
|
| 763 |
-
|
| 764 |
-
```c
|
| 765 |
-
void SSL_CTX_set_security_callback(SSL_CTX *ctx,
|
| 766 |
-
int (*cb) (const SSL *s, const SSL_CTX *ctx,
|
| 767 |
-
int op, int bits, int nid,
|
| 768 |
-
void *other, void *ex))
|
| 769 |
-
{
|
| 770 |
-
ctx->cert->sec_cb = cb;
|
| 771 |
-
}
|
| 772 |
-
|
| 773 |
-
int (*SSL_CTX_get_security_callback(const SSL_CTX *ctx)) (const SSL *s,
|
| 774 |
-
const SSL_CTX *ctx,
|
| 775 |
-
int op, int bits,
|
| 776 |
-
int nid,
|
| 777 |
-
void *other,
|
| 778 |
-
void *ex) {
|
| 779 |
-
return ctx->cert->sec_cb;
|
| 780 |
-
}
|
| 781 |
-
```
|
| 782 |
-
|
| 783 |
-
```c
|
| 784 |
-
int ssl_security(const SSL *s, int op, int bits, int nid, void *other)
|
| 785 |
-
{
|
| 786 |
-
return s->cert->sec_cb(s, NULL, op, bits, nid, other, s->cert->sec_ex);
|
| 787 |
-
}
|
| 788 |
-
|
| 789 |
-
int ssl_ctx_security(const SSL_CTX *ctx, int op, int bits, int nid, void *other)
|
| 790 |
-
{
|
| 791 |
-
return ctx->cert->sec_cb(NULL, ctx, op, bits, nid, other,
|
| 792 |
-
ctx->cert->sec_ex);
|
| 793 |
-
}
|
| 794 |
-
```
|
| 795 |
-
|
| 796 |
-
```c
|
| 797 |
-
int s_client_main(int argc, char **argv)
|
| 798 |
-
{
|
| 799 |
-
ctx = SSL_CTX_new(meth);
|
| 800 |
-
if (ctx == NULL) {
|
| 801 |
-
ERR_print_errors(bio_err);
|
| 802 |
-
goto end;
|
| 803 |
-
}
|
| 804 |
-
if (srp_arg.srplogin) {
|
| 805 |
-
if (!srp_lateuser && !SSL_CTX_set_srp_username(ctx, srp_arg.srplogin)) {
|
| 806 |
-
BIO_printf(bio_err, "Unable to set SRP username\n");
|
| 807 |
-
goto end;
|
| 808 |
-
}
|
| 809 |
-
srp_arg.msg = c_msg;
|
| 810 |
-
srp_arg.debug = c_debug;
|
| 811 |
-
SSL_CTX_set_srp_cb_arg(ctx, &srp_arg);
|
| 812 |
-
SSL_CTX_set_srp_client_pwd_callback(ctx, ssl_give_srp_client_pwd_cb);
|
| 813 |
-
SSL_CTX_set_srp_strength(ctx, srp_arg.strength);
|
| 814 |
-
if (c_msg || c_debug || srp_arg.amp == 0)
|
| 815 |
-
SSL_CTX_set_srp_verify_param_callback(ctx,
|
| 816 |
-
ssl_srp_verify_param_cb);
|
| 817 |
-
}
|
| 818 |
-
}
|
| 819 |
-
```
|
| 820 |
-
|
| 821 |
-
```c
|
| 822 |
-
# define tls1_ctx_ctrl ssl3_ctx_ctrl
|
| 823 |
-
|
| 824 |
-
int SSL_CTX_set_srp_username(SSL_CTX *ctx, char *name)
|
| 825 |
-
{
|
| 826 |
-
return tls1_ctx_ctrl(ctx, SSL_CTRL_SET_TLS_EXT_SRP_USERNAME, 0, name);
|
| 827 |
-
}
|
| 828 |
-
```
|
| 829 |
-
|
| 830 |
-
```c
|
| 831 |
-
long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
|
| 832 |
-
{
|
| 833 |
-
DH *dh = (DH *)parg;
|
| 834 |
-
EVP_PKEY *pkdh = NULL;
|
| 835 |
-
if (dh == NULL) {
|
| 836 |
-
SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_PASSED_NULL_PARAMETER);
|
| 837 |
-
return 0;
|
| 838 |
-
}
|
| 839 |
-
pkdh = ssl_dh_to_pkey(dh);
|
| 840 |
-
if (pkdh == NULL) {
|
| 841 |
-
SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_MALLOC_FAILURE);
|
| 842 |
-
return 0;
|
| 843 |
-
}
|
| 844 |
-
if (!ssl_ctx_security(ctx, SSL_SECOP_TMP_DH,
|
| 845 |
-
EVP_PKEY_security_bits(pkdh), 0, pkdh)) {
|
| 846 |
-
SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_DH_KEY_TOO_SMALL);
|
| 847 |
-
EVP_PKEY_free(pkdh);
|
| 848 |
-
return 0;
|
| 849 |
-
}
|
| 850 |
-
EVP_PKEY_free(ctx->cert->dh_tmp);
|
| 851 |
-
ctx->cert->dh_tmp = pkdh;
|
| 852 |
-
return 1;
|
| 853 |
-
}
|
| 854 |
-
```
|
| 855 |
-
|
| 856 |
-
```c
|
| 857 |
-
SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth)
|
| 858 |
-
{
|
| 859 |
-
if ((ret->cert = ssl_cert_new()) == NULL)
|
| 860 |
-
goto err;
|
| 861 |
-
}
|
| 862 |
-
```
|
| 863 |
-
|
| 864 |
-
```c
|
| 865 |
-
CERT *ssl_cert_new(void)
|
| 866 |
-
{
|
| 867 |
-
CERT *ret = OPENSSL_zalloc(sizeof(*ret));
|
| 868 |
-
|
| 869 |
-
if (ret == NULL) {
|
| 870 |
-
SSLerr(SSL_F_SSL_CERT_NEW, ERR_R_MALLOC_FAILURE);
|
| 871 |
-
return NULL;
|
| 872 |
-
}
|
| 873 |
-
|
| 874 |
-
ret->key = &(ret->pkeys[SSL_PKEY_RSA]);
|
| 875 |
-
ret->references = 1;
|
| 876 |
-
ret->sec_cb = ssl_security_default_callback;
|
| 877 |
-
ret->sec_level = OPENSSL_TLS_SECURITY_LEVEL;
|
| 878 |
-
ret->sec_ex = NULL;
|
| 879 |
-
ret->lock = CRYPTO_THREAD_lock_new();
|
| 880 |
-
if (ret->lock == NULL) {
|
| 881 |
-
SSLerr(SSL_F_SSL_CERT_NEW, ERR_R_MALLOC_FAILURE);
|
| 882 |
-
OPENSSL_free(ret);
|
| 883 |
-
return NULL;
|
| 884 |
-
}
|
| 885 |
-
|
| 886 |
-
return ret;
|
| 887 |
-
}
|
| 888 |
-
```
|
| 889 |
-
|
| 890 |
-
```c
|
| 891 |
-
static int ssl_security_default_callback(const SSL *s, const SSL_CTX *ctx,
|
| 892 |
-
int op, int bits, int nid, void *other,
|
| 893 |
-
void *ex)
|
| 894 |
-
{
|
| 895 |
-
int level, minbits;
|
| 896 |
-
static const int minbits_table[5] = { 80, 112, 128, 192, 256 };
|
| 897 |
-
if (ctx)
|
| 898 |
-
level = SSL_CTX_get_security_level(ctx);
|
| 899 |
-
else
|
| 900 |
-
level = SSL_get_security_level(s);
|
| 901 |
-
|
| 902 |
-
if (level <= 0) {
|
| 903 |
-
/*
|
| 904 |
-
* No EDH keys weaker than 1024-bits even at level 0, otherwise,
|
| 905 |
-
* anything goes.
|
| 906 |
-
*/
|
| 907 |
-
if (op == SSL_SECOP_TMP_DH && bits < 80)
|
| 908 |
-
return 0;
|
| 909 |
-
return 1;
|
| 910 |
-
}
|
| 911 |
-
if (level > 5)
|
| 912 |
-
level = 5;
|
| 913 |
-
minbits = minbits_table[level - 1];
|
| 914 |
-
switch (op) {
|
| 915 |
-
case SSL_SECOP_CIPHER_SUPPORTED:
|
| 916 |
-
case SSL_SECOP_CIPHER_SHARED:
|
| 917 |
-
case SSL_SECOP_CIPHER_CHECK:
|
| 918 |
-
{
|
| 919 |
-
const SSL_CIPHER *c = other;
|
| 920 |
-
/* No ciphers below security level */
|
| 921 |
-
if (bits < minbits)
|
| 922 |
-
return 0;
|
| 923 |
-
/* No unauthenticated ciphersuites */
|
| 924 |
-
if (c->algorithm_auth & SSL_aNULL)
|
| 925 |
-
return 0;
|
| 926 |
-
/* No MD5 mac ciphersuites */
|
| 927 |
-
if (c->algorithm_mac & SSL_MD5)
|
| 928 |
-
return 0;
|
| 929 |
-
/* SHA1 HMAC is 160 bits of security */
|
| 930 |
-
if (minbits > 160 && c->algorithm_mac & SSL_SHA1)
|
| 931 |
-
return 0;
|
| 932 |
-
/* Level 2: no RC4 */
|
| 933 |
-
if (level >= 2 && c->algorithm_enc == SSL_RC4)
|
| 934 |
-
return 0;
|
| 935 |
-
/* Level 3: forward secure ciphersuites only */
|
| 936 |
-
if (level >= 3 && c->min_tls != TLS1_3_VERSION &&
|
| 937 |
-
!(c->algorithm_mkey & (SSL_kEDH | SSL_kEECDH)))
|
| 938 |
-
return 0;
|
| 939 |
-
break;
|
| 940 |
-
}
|
| 941 |
-
case SSL_SECOP_VERSION:
|
| 942 |
-
if (!SSL_IS_DTLS(s)) {
|
| 943 |
-
/* SSLv3 not allowed at level 2 */
|
| 944 |
-
if (nid <= SSL3_VERSION && level >= 2)
|
| 945 |
-
return 0;
|
| 946 |
-
/* TLS v1.1 and above only for level 3 */
|
| 947 |
-
if (nid <= TLS1_VERSION && level >= 3)
|
| 948 |
-
return 0;
|
| 949 |
-
/* TLS v1.2 only for level 4 and above */
|
| 950 |
-
if (nid <= TLS1_1_VERSION && level >= 4)
|
| 951 |
-
return 0;
|
| 952 |
-
} else {
|
| 953 |
-
/* DTLS v1.2 only for level 4 and above */
|
| 954 |
-
if (DTLS_VERSION_LT(nid, DTLS1_2_VERSION) && level >= 4)
|
| 955 |
-
return 0;
|
| 956 |
-
}
|
| 957 |
-
break;
|
| 958 |
-
|
| 959 |
-
case SSL_SECOP_COMPRESSION:
|
| 960 |
-
if (level >= 2)
|
| 961 |
-
return 0;
|
| 962 |
-
break;
|
| 963 |
-
case SSL_SECOP_TICKET:
|
| 964 |
-
if (level >= 3)
|
| 965 |
-
return 0;
|
| 966 |
-
break;
|
| 967 |
-
default:
|
| 968 |
-
if (bits < minbits)
|
| 969 |
-
return 0;
|
| 970 |
-
}
|
| 971 |
-
return 1;
|
| 972 |
-
}
|
| 973 |
-
```
|
| 974 |
-
|
| 975 |
-
# Example 10
|
| 976 |
-
|
| 977 |
-
## Callsite
|
| 978 |
-
|
| 979 |
-
*/home/yuanting/work/icall-benchmarks/llm/wrk-4.2.0/obj/openssl-1.1.1i/crypto/dsa/dsa_ossl.c:270:18*
|
| 980 |
-
|
| 981 |
-
fnptr: *dsa->meth->bn_mod_exp*
|
| 982 |
-
|
| 983 |
-
targets: NULL
|
| 984 |
-
|
| 985 |
-
## Related Code Snippets
|
| 986 |
-
|
| 987 |
-
```c
|
| 988 |
-
static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
|
| 989 |
-
BIGNUM **kinvp, BIGNUM **rp,
|
| 990 |
-
const unsigned char *dgst, int dlen)
|
| 991 |
-
{
|
| 992 |
-
if ((dsa)->meth->bn_mod_exp != NULL) {
|
| 993 |
-
if (!dsa->meth->bn_mod_exp(dsa, r, dsa->g, k, dsa->p, ctx,
|
| 994 |
-
dsa->method_mont_p))
|
| 995 |
-
goto err;
|
| 996 |
-
} else {
|
| 997 |
-
if (!BN_mod_exp_mont(r, dsa->g, k, dsa->p, ctx, dsa->method_mont_p))
|
| 998 |
-
goto err;
|
| 999 |
-
}
|
| 1000 |
-
}
|
| 1001 |
-
```
|
| 1002 |
-
|
| 1003 |
-
```c
|
| 1004 |
-
int DSA_meth_set_bn_mod_exp(DSA_METHOD *dsam,
|
| 1005 |
-
int (*bn_mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,
|
| 1006 |
-
const BIGNUM *, BN_CTX *, BN_MONT_CTX *))
|
| 1007 |
-
{
|
| 1008 |
-
dsam->bn_mod_exp = bn_mod_exp;
|
| 1009 |
-
return 1;
|
| 1010 |
-
}
|
| 1011 |
-
```
|
| 1012 |
-
|
| 1013 |
-
```c
|
| 1014 |
-
static int capi_init(ENGINE *e)
|
| 1015 |
-
{
|
| 1016 |
-
/* Setup DSA Method */
|
| 1017 |
-
dsa_capi_idx = DSA_get_ex_new_index(0, NULL, NULL, NULL, 0);
|
| 1018 |
-
ossl_dsa_meth = DSA_OpenSSL();
|
| 1019 |
-
if ( !DSA_meth_set_sign(capi_dsa_method, capi_dsa_do_sign)
|
| 1020 |
-
|| !DSA_meth_set_verify(capi_dsa_method,
|
| 1021 |
-
DSA_meth_get_verify(ossl_dsa_meth))
|
| 1022 |
-
|| !DSA_meth_set_finish(capi_dsa_method, capi_dsa_free)
|
| 1023 |
-
|| !DSA_meth_set_mod_exp(capi_dsa_method,
|
| 1024 |
-
DSA_meth_get_mod_exp(ossl_dsa_meth))
|
| 1025 |
-
|| !DSA_meth_set_bn_mod_exp(capi_dsa_method,
|
| 1026 |
-
DSA_meth_get_bn_mod_exp(ossl_dsa_meth))) {
|
| 1027 |
-
goto memerr;
|
| 1028 |
-
}
|
| 1029 |
-
}
|
| 1030 |
-
```
|
| 1031 |
-
|
| 1032 |
-
```c
|
| 1033 |
-
int (*DSA_meth_get_bn_mod_exp(const DSA_METHOD *dsam))
|
| 1034 |
-
(DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *,
|
| 1035 |
-
BN_MONT_CTX *)
|
| 1036 |
-
{
|
| 1037 |
-
return dsam->bn_mod_exp;
|
| 1038 |
-
}
|
| 1039 |
-
```
|
| 1040 |
-
|
| 1041 |
-
```c
|
| 1042 |
-
const DSA_METHOD *DSA_OpenSSL(void)
|
| 1043 |
-
{
|
| 1044 |
-
return &openssl_dsa_meth;
|
| 1045 |
-
}
|
| 1046 |
-
```
|
| 1047 |
-
|
| 1048 |
-
```c
|
| 1049 |
-
static DSA_METHOD openssl_dsa_meth = {
|
| 1050 |
-
"OpenSSL DSA method",
|
| 1051 |
-
dsa_do_sign,
|
| 1052 |
-
dsa_sign_setup_no_digest,
|
| 1053 |
-
dsa_do_verify,
|
| 1054 |
-
NULL, /* dsa_mod_exp, */
|
| 1055 |
-
NULL, /* dsa_bn_mod_exp, */
|
| 1056 |
-
dsa_init,
|
| 1057 |
-
dsa_finish,
|
| 1058 |
-
DSA_FLAG_FIPS_METHOD,
|
| 1059 |
-
NULL,
|
| 1060 |
-
NULL,
|
| 1061 |
-
NULL
|
| 1062 |
-
};
|
| 1063 |
-
```
|
| 1064 |
-
|
| 1065 |
-
```c
|
| 1066 |
-
int (*DSA_meth_get_mod_exp(const DSA_METHOD *dsam))
|
| 1067 |
-
(DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,
|
| 1068 |
-
const BIGNUM *, const BIGNUM *, BN_CTX *, BN_MONT_CTX *)
|
| 1069 |
-
{
|
| 1070 |
-
return dsam->dsa_mod_exp;
|
| 1071 |
-
}
|
| 1072 |
-
|
| 1073 |
-
int DSA_meth_set_mod_exp(DSA_METHOD *dsam,
|
| 1074 |
-
int (*mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,
|
| 1075 |
-
const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *,
|
| 1076 |
-
BN_MONT_CTX *))
|
| 1077 |
-
{
|
| 1078 |
-
dsam->dsa_mod_exp = mod_exp;
|
| 1079 |
-
return 1;
|
| 1080 |
-
}
|
| 1081 |
-
```
|
| 1082 |
-
|
| 1083 |
-
# Example 11
|
| 1084 |
-
|
| 1085 |
-
## Callsite
|
| 1086 |
-
|
| 1087 |
-
*/home/yuanting/work/icall-benchmarks/llm/wrk-4.2.0/obj/openssl-1.1.1i/ssl/statem/statem_clnt.c:3773:14*
|
| 1088 |
-
|
| 1089 |
-
fnptr: *s->method->put_cipher_by_char*
|
| 1090 |
-
|
| 1091 |
-
targets: ssl3_put_cipher_by_char
|
| 1092 |
-
|
| 1093 |
-
## Related Code Snippets
|
| 1094 |
-
|
| 1095 |
-
```c
|
| 1096 |
-
int ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *sk, WPACKET *pkt)
|
| 1097 |
-
{
|
| 1098 |
-
if (!s->method->put_cipher_by_char(c, pkt, &len)) {
|
| 1099 |
-
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_CIPHER_LIST_TO_BYTES,
|
| 1100 |
-
ERR_R_INTERNAL_ERROR);
|
| 1101 |
-
return 0;
|
| 1102 |
-
}
|
| 1103 |
-
}
|
| 1104 |
-
```
|
| 1105 |
-
|
| 1106 |
-
```c
|
| 1107 |
-
# define IMPLEMENT_tls_meth_func(version, flags, mask, func_name, s_accept, \
|
| 1108 |
-
s_connect, enc_data) \
|
| 1109 |
-
const SSL_METHOD *func_name(void) \
|
| 1110 |
-
{ \
|
| 1111 |
-
static const SSL_METHOD func_name##_data= { \
|
| 1112 |
-
version, \
|
| 1113 |
-
flags, \
|
| 1114 |
-
mask, \
|
| 1115 |
-
tls1_new, \
|
| 1116 |
-
tls1_clear, \
|
| 1117 |
-
tls1_free, \
|
| 1118 |
-
s_accept, \
|
| 1119 |
-
s_connect, \
|
| 1120 |
-
ssl3_read, \
|
| 1121 |
-
ssl3_peek, \
|
| 1122 |
-
ssl3_write, \
|
| 1123 |
-
ssl3_shutdown, \
|
| 1124 |
-
ssl3_renegotiate, \
|
| 1125 |
-
ssl3_renegotiate_check, \
|
| 1126 |
-
ssl3_read_bytes, \
|
| 1127 |
-
ssl3_write_bytes, \
|
| 1128 |
-
ssl3_dispatch_alert, \
|
| 1129 |
-
ssl3_ctrl, \
|
| 1130 |
-
ssl3_ctx_ctrl, \
|
| 1131 |
-
ssl3_get_cipher_by_char, \
|
| 1132 |
-
ssl3_put_cipher_by_char, \
|
| 1133 |
-
ssl3_pending, \
|
| 1134 |
-
ssl3_num_ciphers, \
|
| 1135 |
-
ssl3_get_cipher, \
|
| 1136 |
-
tls1_default_timeout, \
|
| 1137 |
-
&enc_data, \
|
| 1138 |
-
ssl_undefined_void_function, \
|
| 1139 |
-
ssl3_callback_ctrl, \
|
| 1140 |
-
ssl3_ctx_callback_ctrl, \
|
| 1141 |
-
}; \
|
| 1142 |
-
return &func_name##_data; \
|
| 1143 |
-
}
|
| 1144 |
-
```
|
| 1145 |
-
|
| 1146 |
-
```c
|
| 1147 |
-
struct ssl_method_st {
|
| 1148 |
-
int version;
|
| 1149 |
-
unsigned flags;
|
| 1150 |
-
unsigned long mask;
|
| 1151 |
-
int (*ssl_new) (SSL *s);
|
| 1152 |
-
int (*ssl_clear) (SSL *s);
|
| 1153 |
-
void (*ssl_free) (SSL *s);
|
| 1154 |
-
int (*ssl_accept) (SSL *s);
|
| 1155 |
-
int (*ssl_connect) (SSL *s);
|
| 1156 |
-
int (*ssl_read) (SSL *s, void *buf, size_t len, size_t *readbytes);
|
| 1157 |
-
int (*ssl_peek) (SSL *s, void *buf, size_t len, size_t *readbytes);
|
| 1158 |
-
int (*ssl_write) (SSL *s, const void *buf, size_t len, size_t *written);
|
| 1159 |
-
int (*ssl_shutdown) (SSL *s);
|
| 1160 |
-
int (*ssl_renegotiate) (SSL *s);
|
| 1161 |
-
int (*ssl_renegotiate_check) (SSL *s, int);
|
| 1162 |
-
int (*ssl_read_bytes) (SSL *s, int type, int *recvd_type,
|
| 1163 |
-
unsigned char *buf, size_t len, int peek,
|
| 1164 |
-
size_t *readbytes);
|
| 1165 |
-
int (*ssl_write_bytes) (SSL *s, int type, const void *buf_, size_t len,
|
| 1166 |
-
size_t *written);
|
| 1167 |
-
int (*ssl_dispatch_alert) (SSL *s);
|
| 1168 |
-
long (*ssl_ctrl) (SSL *s, int cmd, long larg, void *parg);
|
| 1169 |
-
long (*ssl_ctx_ctrl) (SSL_CTX *ctx, int cmd, long larg, void *parg);
|
| 1170 |
-
const SSL_CIPHER *(*get_cipher_by_char) (const unsigned char *ptr);
|
| 1171 |
-
int (*put_cipher_by_char) (const SSL_CIPHER *cipher, WPACKET *pkt,
|
| 1172 |
-
size_t *len);
|
| 1173 |
-
size_t (*ssl_pending) (const SSL *s);
|
| 1174 |
-
int (*num_ciphers) (void);
|
| 1175 |
-
const SSL_CIPHER *(*get_cipher) (unsigned ncipher);
|
| 1176 |
-
long (*get_timeout) (void);
|
| 1177 |
-
const struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */
|
| 1178 |
-
int (*ssl_version) (void);
|
| 1179 |
-
long (*ssl_callback_ctrl) (SSL *s, int cb_id, void (*fp) (void));
|
| 1180 |
-
long (*ssl_ctx_callback_ctrl) (SSL_CTX *s, int cb_id, void (*fp) (void));
|
| 1181 |
-
};
|
| 1182 |
-
```
|
| 1183 |
-
|
| 1184 |
-
```c
|
| 1185 |
-
int ssl3_put_cipher_by_char(const SSL_CIPHER *c, WPACKET *pkt, size_t *len)
|
| 1186 |
-
{
|
| 1187 |
-
if ((c->id & 0xff000000) != SSL3_CK_CIPHERSUITE_FLAG) {
|
| 1188 |
-
*len = 0;
|
| 1189 |
-
return 1;
|
| 1190 |
-
}
|
| 1191 |
-
|
| 1192 |
-
if (!WPACKET_put_bytes_u16(pkt, c->id & 0xffff))
|
| 1193 |
-
return 0;
|
| 1194 |
-
|
| 1195 |
-
*len = 2;
|
| 1196 |
-
return 1;
|
| 1197 |
-
}
|
| 1198 |
-
```
|
| 1199 |
-
|
| 1200 |
-
# Example 12
|
| 1201 |
-
|
| 1202 |
-
## Callsite
|
| 1203 |
-
|
| 1204 |
-
*/home/yuanting/work/icall-benchmarks/llm/wrk-4.2.0/obj/openssl-1.1.1i/ssl/statem/statem_srvr.c:2172:17*
|
| 1205 |
-
|
| 1206 |
-
fnptr: *s->ctx->ext.alpn_select_cb*
|
| 1207 |
-
|
| 1208 |
-
targets: alpn_cb
|
| 1209 |
-
|
| 1210 |
-
## Related Code Snippets
|
| 1211 |
-
|
| 1212 |
-
```c
|
| 1213 |
-
int tls_handle_alpn(SSL *s)
|
| 1214 |
-
{
|
| 1215 |
-
if (s->ctx->ext.alpn_select_cb != NULL && s->s3->alpn_proposed != NULL) {
|
| 1216 |
-
int r = s->ctx->ext.alpn_select_cb(s, &selected, &selected_len,
|
| 1217 |
-
s->s3->alpn_proposed,
|
| 1218 |
-
(unsigned int)s->s3->alpn_proposed_len,
|
| 1219 |
-
s->ctx->ext.alpn_select_cb_arg);
|
| 1220 |
-
}
|
| 1221 |
-
return 1;
|
| 1222 |
-
}
|
| 1223 |
-
```
|
| 1224 |
-
|
| 1225 |
-
```c
|
| 1226 |
-
void SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx,
|
| 1227 |
-
SSL_CTX_alpn_select_cb_func cb,
|
| 1228 |
-
void *arg)
|
| 1229 |
-
{
|
| 1230 |
-
ctx->ext.alpn_select_cb = cb;
|
| 1231 |
-
ctx->ext.alpn_select_cb_arg = arg;
|
| 1232 |
-
}
|
| 1233 |
-
```
|
| 1234 |
-
|
| 1235 |
-
```c
|
| 1236 |
-
int s_server_main(int argc, char *argv[])
|
| 1237 |
-
{
|
| 1238 |
-
if (alpn_ctx.data)
|
| 1239 |
-
SSL_CTX_set_alpn_select_cb(ctx, alpn_cb, &alpn_ctx);
|
| 1240 |
-
}
|
| 1241 |
-
```
|
| 1242 |
-
|
| 1243 |
-
```c
|
| 1244 |
-
static int alpn_cb(SSL *s, const unsigned char **out, unsigned char *outlen,
|
| 1245 |
-
const unsigned char *in, unsigned int inlen, void *arg)
|
| 1246 |
-
{
|
| 1247 |
-
tlsextalpnctx *alpn_ctx = arg;
|
| 1248 |
-
|
| 1249 |
-
if (!s_quiet) {
|
| 1250 |
-
/* We can assume that |in| is syntactically valid. */
|
| 1251 |
-
unsigned int i;
|
| 1252 |
-
BIO_printf(bio_s_out, "ALPN protocols advertised by the client: ");
|
| 1253 |
-
for (i = 0; i < inlen;) {
|
| 1254 |
-
if (i)
|
| 1255 |
-
BIO_write(bio_s_out, ", ", 2);
|
| 1256 |
-
BIO_write(bio_s_out, &in[i + 1], in[i]);
|
| 1257 |
-
i += in[i] + 1;
|
| 1258 |
-
}
|
| 1259 |
-
BIO_write(bio_s_out, "\n", 1);
|
| 1260 |
-
}
|
| 1261 |
-
|
| 1262 |
-
if (SSL_select_next_proto
|
| 1263 |
-
((unsigned char **)out, outlen, alpn_ctx->data, alpn_ctx->len, in,
|
| 1264 |
-
inlen) != OPENSSL_NPN_NEGOTIATED) {
|
| 1265 |
-
return SSL_TLSEXT_ERR_NOACK;
|
| 1266 |
-
}
|
| 1267 |
-
|
| 1268 |
-
if (!s_quiet) {
|
| 1269 |
-
BIO_printf(bio_s_out, "ALPN protocols selected: ");
|
| 1270 |
-
BIO_write(bio_s_out, *out, *outlen);
|
| 1271 |
-
BIO_write(bio_s_out, "\n", 1);
|
| 1272 |
-
}
|
| 1273 |
-
|
| 1274 |
-
return SSL_TLSEXT_ERR_OK;
|
| 1275 |
-
}
|
| 1276 |
-
```
|
| 1277 |
-
|
| 1278 |
-
# Example 13
|
| 1279 |
-
|
| 1280 |
-
## Callsite
|
| 1281 |
-
|
| 1282 |
-
*/home/yuanting/work/icall-benchmarks/llm/wrk-4.2.0/obj/openssl-1.1.1i/crypto/modes/gcm128.c:1092:21*
|
| 1283 |
-
|
| 1284 |
-
fnptr: *block*
|
| 1285 |
-
|
| 1286 |
-
targets: aesni_encrypt
|
| 1287 |
-
|
| 1288 |
-
## Related Code Snippets
|
| 1289 |
-
|
| 1290 |
-
```c
|
| 1291 |
-
int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
|
| 1292 |
-
const unsigned char *in, unsigned char *out,
|
| 1293 |
-
size_t len)
|
| 1294 |
-
{
|
| 1295 |
-
block128_f block = ctx->block;
|
| 1296 |
-
(*block) (ctx->Yi.c, ctx->EKi.c, key);
|
| 1297 |
-
}
|
| 1298 |
-
```
|
| 1299 |
-
|
| 1300 |
-
```c
|
| 1301 |
-
static int aes_gcm_tls_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
| 1302 |
-
const unsigned char *in, size_t len)
|
| 1303 |
-
{
|
| 1304 |
-
EVP_AES_GCM_CTX *gctx = EVP_C_DATA(EVP_AES_GCM_CTX,ctx);
|
| 1305 |
-
int rv = -1;
|
| 1306 |
-
/* Encrypt/decrypt must be performed in place */
|
| 1307 |
-
if (out != in
|
| 1308 |
-
|| len < (EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN))
|
| 1309 |
-
return -1;
|
| 1310 |
-
/*
|
| 1311 |
-
* Set IV from start of buffer or generate IV and write to start of
|
| 1312 |
-
* buffer.
|
| 1313 |
-
*/
|
| 1314 |
-
if (EVP_CIPHER_CTX_ctrl(ctx, ctx->encrypt ? EVP_CTRL_GCM_IV_GEN
|
| 1315 |
-
: EVP_CTRL_GCM_SET_IV_INV,
|
| 1316 |
-
EVP_GCM_TLS_EXPLICIT_IV_LEN, out) <= 0)
|
| 1317 |
-
goto err;
|
| 1318 |
-
/* Use saved AAD */
|
| 1319 |
-
if (CRYPTO_gcm128_aad(&gctx->gcm, ctx->buf, gctx->tls_aad_len))
|
| 1320 |
-
goto err;
|
| 1321 |
-
/* Fix buffer and length to point to payload */
|
| 1322 |
-
in += EVP_GCM_TLS_EXPLICIT_IV_LEN;
|
| 1323 |
-
out += EVP_GCM_TLS_EXPLICIT_IV_LEN;
|
| 1324 |
-
len -= EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN;
|
| 1325 |
-
if (ctx->encrypt) {
|
| 1326 |
-
/* Encrypt payload */
|
| 1327 |
-
if (gctx->ctr) {
|
| 1328 |
-
size_t bulk = 0;
|
| 1329 |
-
#if defined(AES_GCM_ASM)
|
| 1330 |
-
if (len >= 32 && AES_GCM_ASM(gctx)) {
|
| 1331 |
-
if (CRYPTO_gcm128_encrypt(&gctx->gcm, NULL, NULL, 0))
|
| 1332 |
-
return -1;
|
| 1333 |
-
|
| 1334 |
-
bulk = AES_gcm_encrypt(in, out, len,
|
| 1335 |
-
gctx->gcm.key,
|
| 1336 |
-
gctx->gcm.Yi.c, gctx->gcm.Xi.u);
|
| 1337 |
-
gctx->gcm.len.u[1] += bulk;
|
| 1338 |
-
}
|
| 1339 |
-
#endif
|
| 1340 |
-
}
|
| 1341 |
-
}
|
| 1342 |
-
}
|
| 1343 |
-
```
|
| 1344 |
-
|
| 1345 |
-
```c
|
| 1346 |
-
void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx, void *key, block128_f block)
|
| 1347 |
-
{
|
| 1348 |
-
const union {
|
| 1349 |
-
long one;
|
| 1350 |
-
char little;
|
| 1351 |
-
} is_endian = { 1 };
|
| 1352 |
-
|
| 1353 |
-
memset(ctx, 0, sizeof(*ctx));
|
| 1354 |
-
ctx->block = block;
|
| 1355 |
-
ctx->key = key;
|
| 1356 |
-
}
|
| 1357 |
-
```
|
| 1358 |
-
|
| 1359 |
-
```c
|
| 1360 |
-
static int aesni_gcm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
| 1361 |
-
const unsigned char *iv, int enc)
|
| 1362 |
-
{
|
| 1363 |
-
EVP_AES_GCM_CTX *gctx = EVP_C_DATA(EVP_AES_GCM_CTX,ctx);
|
| 1364 |
-
if (!iv && !key)
|
| 1365 |
-
return 1;
|
| 1366 |
-
if (key) {
|
| 1367 |
-
aesni_set_encrypt_key(key, EVP_CIPHER_CTX_key_length(ctx) * 8,
|
| 1368 |
-
&gctx->ks.ks);
|
| 1369 |
-
CRYPTO_gcm128_init(&gctx->gcm, &gctx->ks, (block128_f) aesni_encrypt);
|
| 1370 |
-
gctx->ctr = (ctr128_f) aesni_ctr32_encrypt_blocks;
|
| 1371 |
-
/*
|
| 1372 |
-
* If we have an iv can set it directly, otherwise use saved IV.
|
| 1373 |
-
*/
|
| 1374 |
-
if (iv == NULL && gctx->iv_set)
|
| 1375 |
-
iv = gctx->iv;
|
| 1376 |
-
if (iv) {
|
| 1377 |
-
CRYPTO_gcm128_setiv(&gctx->gcm, iv, gctx->ivlen);
|
| 1378 |
-
gctx->iv_set = 1;
|
| 1379 |
-
}
|
| 1380 |
-
gctx->key_set = 1;
|
| 1381 |
-
}
|
| 1382 |
-
}
|
| 1383 |
-
```
|
| 1384 |
-
|
| 1385 |
-
```c
|
| 1386 |
-
void aesni_encrypt(const unsigned char *in, unsigned char *out,
|
| 1387 |
-
const AES_KEY *key);
|
| 1388 |
-
```
|
| 1389 |
-
|
| 1390 |
-
# Example 14
|
| 1391 |
-
|
| 1392 |
-
## Callsite
|
| 1393 |
-
|
| 1394 |
-
*/home/yuanting/work/icall-benchmarks/llm/wrk-4.2.0/obj/openssl-1.1.1i/ssl/record/rec_layer_s3.c:390:13*
|
| 1395 |
-
|
| 1396 |
-
fnptr: *s->handshake_func*
|
| 1397 |
-
|
| 1398 |
-
targets: ossl_statem_accept, ossl_statem_connect
|
| 1399 |
-
|
| 1400 |
-
## Related Code Snippets
|
| 1401 |
-
|
| 1402 |
-
```c
|
| 1403 |
-
int ssl3_write_bytes(SSL *s, int type, const void *buf_, size_t len,
|
| 1404 |
-
size_t *written)
|
| 1405 |
-
{
|
| 1406 |
-
if (SSL_in_init(s) && !ossl_statem_get_in_handshake(s)
|
| 1407 |
-
&& s->early_data_state != SSL_EARLY_DATA_UNAUTH_WRITING) {
|
| 1408 |
-
i = s->handshake_func(s);
|
| 1409 |
-
/* SSLfatal() already called */
|
| 1410 |
-
if (i < 0)
|
| 1411 |
-
return i;
|
| 1412 |
-
if (i == 0) {
|
| 1413 |
-
return -1;
|
| 1414 |
-
}
|
| 1415 |
-
}
|
| 1416 |
-
}
|
| 1417 |
-
```
|
| 1418 |
-
|
| 1419 |
-
```c
|
| 1420 |
-
WORK_STATE tls_finish_handshake(SSL *s, WORK_STATE wst, int clearbufs, int stop)
|
| 1421 |
-
{
|
| 1422 |
-
void (*cb) (const SSL *ssl, int type, int val) = NULL;
|
| 1423 |
-
int cleanuphand = s->statem.cleanuphand;
|
| 1424 |
-
|
| 1425 |
-
if (clearbufs) {
|
| 1426 |
-
if (!SSL_IS_DTLS(s)
|
| 1427 |
-
#ifndef OPENSSL_NO_SCTP
|
| 1428 |
-
/*
|
| 1429 |
-
* RFC6083: SCTP provides a reliable and in-sequence transport service for DTLS
|
| 1430 |
-
* messages that require it. Therefore, DTLS procedures for retransmissions
|
| 1431 |
-
* MUST NOT be used.
|
| 1432 |
-
* Hence the init_buf can be cleared when DTLS over SCTP as transport is used.
|
| 1433 |
-
*/
|
| 1434 |
-
|| BIO_dgram_is_sctp(SSL_get_wbio(s))
|
| 1435 |
-
#endif
|
| 1436 |
-
) {
|
| 1437 |
-
/*
|
| 1438 |
-
* We don't do this in DTLS over UDP because we may still need the init_buf
|
| 1439 |
-
* in case there are any unexpected retransmits
|
| 1440 |
-
*/
|
| 1441 |
-
BUF_MEM_free(s->init_buf);
|
| 1442 |
-
s->init_buf = NULL;
|
| 1443 |
-
}
|
| 1444 |
-
|
| 1445 |
-
if (!ssl_free_wbio_buffer(s)) {
|
| 1446 |
-
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_FINISH_HANDSHAKE,
|
| 1447 |
-
ERR_R_INTERNAL_ERROR);
|
| 1448 |
-
return WORK_ERROR;
|
| 1449 |
-
}
|
| 1450 |
-
s->init_num = 0;
|
| 1451 |
-
}
|
| 1452 |
-
|
| 1453 |
-
if (SSL_IS_TLS13(s) && !s->server
|
| 1454 |
-
&& s->post_handshake_auth == SSL_PHA_REQUESTED)
|
| 1455 |
-
s->post_handshake_auth = SSL_PHA_EXT_SENT;
|
| 1456 |
-
|
| 1457 |
-
/*
|
| 1458 |
-
* Only set if there was a Finished message and this isn't after a TLSv1.3
|
| 1459 |
-
* post handshake exchange
|
| 1460 |
-
*/
|
| 1461 |
-
if (cleanuphand) {
|
| 1462 |
-
/* skipped if we just sent a HelloRequest */
|
| 1463 |
-
s->renegotiate = 0;
|
| 1464 |
-
s->new_session = 0;
|
| 1465 |
-
s->statem.cleanuphand = 0;
|
| 1466 |
-
s->ext.ticket_expected = 0;
|
| 1467 |
-
|
| 1468 |
-
ssl3_cleanup_key_block(s);
|
| 1469 |
-
|
| 1470 |
-
if (s->server) {
|
| 1471 |
-
/*
|
| 1472 |
-
* In TLSv1.3 we update the cache as part of constructing the
|
| 1473 |
-
* NewSessionTicket
|
| 1474 |
-
*/
|
| 1475 |
-
if (!SSL_IS_TLS13(s))
|
| 1476 |
-
ssl_update_cache(s, SSL_SESS_CACHE_SERVER);
|
| 1477 |
-
|
| 1478 |
-
/* N.B. s->ctx may not equal s->session_ctx */
|
| 1479 |
-
tsan_counter(&s->ctx->stats.sess_accept_good);
|
| 1480 |
-
s->handshake_func = ossl_statem_accept;
|
| 1481 |
-
} else {
|
| 1482 |
-
if (SSL_IS_TLS13(s)) {
|
| 1483 |
-
/*
|
| 1484 |
-
* We encourage applications to only use TLSv1.3 tickets once,
|
| 1485 |
-
* so we remove this one from the cache.
|
| 1486 |
-
*/
|
| 1487 |
-
if ((s->session_ctx->session_cache_mode
|
| 1488 |
-
& SSL_SESS_CACHE_CLIENT) != 0)
|
| 1489 |
-
SSL_CTX_remove_session(s->session_ctx, s->session);
|
| 1490 |
-
} else {
|
| 1491 |
-
/*
|
| 1492 |
-
* In TLSv1.3 we update the cache as part of processing the
|
| 1493 |
-
* NewSessionTicket
|
| 1494 |
-
*/
|
| 1495 |
-
ssl_update_cache(s, SSL_SESS_CACHE_CLIENT);
|
| 1496 |
-
}
|
| 1497 |
-
if (s->hit)
|
| 1498 |
-
tsan_counter(&s->session_ctx->stats.sess_hit);
|
| 1499 |
-
|
| 1500 |
-
s->handshake_func = ossl_statem_connect;
|
| 1501 |
-
tsan_counter(&s->session_ctx->stats.sess_connect_good);
|
| 1502 |
-
}
|
| 1503 |
-
|
| 1504 |
-
if (SSL_IS_DTLS(s)) {
|
| 1505 |
-
/* done with handshaking */
|
| 1506 |
-
s->d1->handshake_read_seq = 0;
|
| 1507 |
-
s->d1->handshake_write_seq = 0;
|
| 1508 |
-
s->d1->next_handshake_write_seq = 0;
|
| 1509 |
-
dtls1_clear_received_buffer(s);
|
| 1510 |
-
}
|
| 1511 |
-
}
|
| 1512 |
-
|
| 1513 |
-
if (s->info_callback != NULL)
|
| 1514 |
-
cb = s->info_callback;
|
| 1515 |
-
else if (s->ctx->info_callback != NULL)
|
| 1516 |
-
cb = s->ctx->info_callback;
|
| 1517 |
-
|
| 1518 |
-
/* The callback may expect us to not be in init at handshake done */
|
| 1519 |
-
ossl_statem_set_in_init(s, 0);
|
| 1520 |
-
|
| 1521 |
-
if (cb != NULL) {
|
| 1522 |
-
if (cleanuphand
|
| 1523 |
-
|| !SSL_IS_TLS13(s)
|
| 1524 |
-
|| SSL_IS_FIRST_HANDSHAKE(s))
|
| 1525 |
-
cb(s, SSL_CB_HANDSHAKE_DONE, 1);
|
| 1526 |
-
}
|
| 1527 |
-
|
| 1528 |
-
if (!stop) {
|
| 1529 |
-
/* If we've got more work to do we go back into init */
|
| 1530 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