rename cb to cancel_cb
diff --git a/include/picotls.h b/include/picotls.h
index 7cbb4a8..a8c3cce 100644
--- a/include/picotls.h
+++ b/include/picotls.h
@@ -614,7 +614,7 @@
* When `ptls_t` is disposed of while the async operation is in flight, `*cancel_cb` will be invoked. The backend should abort the
* calculation and free any temporary data allocated for that calculation.
*/
-PTLS_CALLBACK_TYPE(int, sign_certificate, ptls_t *tls, void (**cb)(void *sign_ctx), void **sign_certificate_ctx,
+PTLS_CALLBACK_TYPE(int, sign_certificate, ptls_t *tls, void (**cancel_cb)(void *sign_ctx), void **sign_certificate_ctx,
uint16_t *selected_algorithm, ptls_buffer_t *output, ptls_iovec_t input, const uint16_t *algorithms, size_t num_algorithms);
/**
* after receiving Certificate, the core calls the callback to verify the certificate chain and to obtain a pointer to a
diff --git a/lib/openssl.c b/lib/openssl.c
index edfce81..2f263e6 100644
--- a/lib/openssl.c
+++ b/lib/openssl.c
@@ -767,7 +767,7 @@
}
static int do_sign(EVP_PKEY *key, const struct st_ptls_openssl_signature_scheme_t *scheme, ptls_buffer_t *outbuf,
- ptls_iovec_t input, void (**cb)(void *sign_ctx), void **sign_ctx, int is_async)
+ ptls_iovec_t input, void (**cancel_cb)(void *sign_ctx), void **sign_ctx, int is_async)
{
const EVP_MD *md = scheme->scheme_md != NULL ? scheme->scheme_md() : NULL;
int pkey_id = EVP_PKEY_id(key);
@@ -857,8 +857,8 @@
goto Exit;
case ASYNC_PAUSE: {
ret = PTLS_ERROR_ASYNC_OPERATION;
- if (cb != NULL)
- *cb = async_sign_cancel;
+ assert(cancel_cb == NULL);
+ *cancel_cb = async_sign_cancel;
return ret;
}
case ASYNC_NO_JOBS:
@@ -897,8 +897,8 @@
Exit:
if (sign_ctx != NULL)
*sign_ctx = NULL;
- if (cb != NULL)
- *cb = NULL;
+ if (cancel_cb != NULL)
+ *cancel_cb = NULL;
sign_ctx_destroy(args);
if (ctx != NULL)
EVP_MD_CTX_destroy(ctx);
@@ -1196,7 +1196,7 @@
}
return scheme;
}
-static int sign_certificate(ptls_sign_certificate_t *_self, ptls_t *tls, void (**cb)(void *sign_ctx), void **sign_ctx,
+static int sign_certificate(ptls_sign_certificate_t *_self, ptls_t *tls, void (**cancel_cb)(void *sign_ctx), void **sign_ctx,
uint16_t *selected_algorithm, ptls_buffer_t *outbuf, ptls_iovec_t input, const uint16_t *algorithms,
size_t num_algorithms)
{
@@ -1229,7 +1229,7 @@
Exit:
*selected_algorithm = scheme->scheme_id;
- return do_sign(self->key, scheme, outbuf, input, cb, sign_ctx, is_async);
+ return do_sign(self->key, scheme, outbuf, input, cancel_cb, sign_ctx, is_async);
}
static X509 *to_x509(ptls_iovec_t vec)
diff --git a/lib/picotls.c b/lib/picotls.c
index c3a7662..48ad348 100644
--- a/lib/picotls.c
+++ b/lib/picotls.c
@@ -253,7 +253,7 @@
uint32_t early_data_skipped_bytes; /* if not UINT32_MAX, the server is skipping early data */
unsigned can_send_session_ticket : 1;
struct {
- void (*cb)(void *sign_certificate_ctx);
+ void (*cancel_cb)(void *sign_certificate_ctx);
void *sign_certificate_ctx;
} sign_certificate;
} server;
@@ -389,7 +389,7 @@
ptls_iovec_t hash_value, const char *label_prefix);
static ptls_aead_context_t *new_aead(ptls_aead_algorithm_t *aead, ptls_hash_algorithm_t *hash, int is_enc, const void *secret,
ptls_iovec_t hash_value, const char *label_prefix);
-static int server_complete_handshake(ptls_t *tls, ptls_message_emitter_t *emitter, int send_cert_verify,
+static int server_finish_handshake(ptls_t *tls, ptls_message_emitter_t *emitter, int send_cert_verify,
struct st_ptls_signature_algorithms_t *signature_algorithms);
static int is_supported_version(uint16_t v)
@@ -2759,7 +2759,7 @@
uint8_t data[PTLS_MAX_CERTIFICATE_VERIFY_SIGNDATA_SIZE];
size_t datalen = build_certificate_verify_signdata(data, tls->key_schedule, context_string);
if ((ret = tls->ctx->sign_certificate->cb(tls->ctx->sign_certificate, tls,
- tls->is_server ? &tls->server.sign_certificate.cb : NULL,
+ tls->is_server ? &tls->server.sign_certificate.cancel_cb : NULL,
tls->is_server ? &tls->server.sign_certificate.sign_certificate_ctx : NULL,
&algo, sendbuf, ptls_iovec_init(data, datalen),
signature_algorithms != NULL ? signature_algorithms->list : NULL,
@@ -4488,8 +4488,8 @@
if (tls->certificate_verify.cb != NULL) {
tls->certificate_verify.cb(tls->certificate_verify.verify_ctx, 0, ptls_iovec_init(NULL, 0), ptls_iovec_init(NULL, 0));
}
- if (tls->server.sign_certificate.cb != NULL) {
- tls->server.sign_certificate.cb(tls->server.sign_certificate.sign_certificate_ctx);
+ if (tls->server.sign_certificate.cancel_cb != NULL) {
+ tls->server.sign_certificate.cancel_cb(tls->server.sign_certificate.sign_certificate_ctx);
}
if (tls->pending_handshake_secret != NULL) {
ptls_clear_memory(tls->pending_handshake_secret, PTLS_MAX_DIGEST_SIZE);
diff --git a/t/picotls.c b/t/picotls.c
index 6197c84..61d51f2 100644
--- a/t/picotls.c
+++ b/t/picotls.c
@@ -906,15 +906,15 @@
static ptls_sign_certificate_t *sc_orig;
-static int sign_certificate(ptls_sign_certificate_t *self, ptls_t *tls, void (**cb)(void *sign_ctx), void **sign_ctx,
+static int sign_certificate(ptls_sign_certificate_t *self, ptls_t *tls, void (**cancel_cb)(void *sign_ctx), void **sign_ctx,
uint16_t *selected_algorithm, ptls_buffer_t *output, ptls_iovec_t input, const uint16_t *algorithms,
size_t num_algorithms)
{
++*(ptls_is_server(tls) ? &server_sc_callcnt : &client_sc_callcnt);
- return sc_orig->cb(sc_orig, tls, cb, sign_ctx, selected_algorithm, output, input, algorithms, num_algorithms);
+ return sc_orig->cb(sc_orig, tls, cancel_cb, sign_ctx, selected_algorithm, output, input, algorithms, num_algorithms);
}
-static int async_sign_certificate(ptls_sign_certificate_t *self, ptls_t *tls, void (**cb)(void *sign_ctx), void **sign_ctx,
+static int async_sign_certificate(ptls_sign_certificate_t *self, ptls_t *tls, void (**cancel_cb)(void *sign_ctx), void **sign_ctx,
uint16_t *selected_algorithm, ptls_buffer_t *output, ptls_iovec_t input, const uint16_t *algorithms,
size_t num_algorithms)
{
@@ -926,7 +926,7 @@
/* first invocation, make a fake call to the backend and obtain the algorithm, return it, but not the signature */
ptls_buffer_t fakebuf;
ptls_buffer_init(&fakebuf, "", 0);
- int ret = sign_certificate(self, tls, cb, &inner_sign_ctx, selected_algorithm, &fakebuf, input, algorithms,
+ int ret = sign_certificate(self, tls, cancel_cb, &inner_sign_ctx, selected_algorithm, &fakebuf, input, algorithms,
num_algorithms);
assert(ret == 0);
ptls_buffer_dispose(&fakebuf);
@@ -943,18 +943,18 @@
num_algorithms = 1;
}
- return sign_certificate(self, tls, cb, &inner_sign_ctx, selected_algorithm, output, input, algorithms,
+ return sign_certificate(self, tls, cancel_cb, &inner_sign_ctx, selected_algorithm, output, input, algorithms,
num_algorithms);
}
static ptls_sign_certificate_t *second_sc_orig;
-static int second_sign_certificate(ptls_sign_certificate_t *self, ptls_t *tls, void (**cb)(void *sign_ctx), void **sign_ctx,
+static int second_sign_certificate(ptls_sign_certificate_t *self, ptls_t *tls, void (**cancel_cb)(void *sign_ctx), void **sign_ctx,
uint16_t *selected_algorithm, ptls_buffer_t *output, ptls_iovec_t input, const uint16_t *algorithms,
size_t num_algorithms)
{
++*(ptls_is_server(tls) ? &server_sc_callcnt : &client_sc_callcnt);
- return second_sc_orig->cb(second_sc_orig, tls, cb, sign_ctx, selected_algorithm, output, input, algorithms, num_algorithms);
+ return second_sc_orig->cb(second_sc_orig, tls, cancel_cb, sign_ctx, selected_algorithm, output, input, algorithms, num_algorithms);
}
static void test_full_handshake_impl(int require_client_authentication, int is_async)