-
Notifications
You must be signed in to change notification settings - Fork 171
Asynchronous signing #408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Asynchronous signing #408
Changes from 18 commits
ded17f2
aa4f09a
4d6f6cd
2b4aff9
f7ea678
621509b
4ab5ba7
a55938b
04aa8cf
b9a0040
7c6707a
2792654
c931aef
83607a8
a58b7e3
cc5a20e
10472b5
ec6e099
e1148cd
b4ab91a
d2ffef1
6f558cf
6b71b99
5c0a108
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -191,6 +191,7 @@ extern "C" { | |
| #define PTLS_ERROR_ESNI_RETRY (PTLS_ERROR_CLASS_INTERNAL + 8) | ||
| #define PTLS_ERROR_REJECT_EARLY_DATA (PTLS_ERROR_CLASS_INTERNAL + 9) | ||
| #define PTLS_ERROR_DELEGATE (PTLS_ERROR_CLASS_INTERNAL + 10) | ||
| #define PTLS_ERROR_ASYNC_OPERATION (PTLS_ERROR_CLASS_INTERNAL + 11) | ||
|
|
||
| #define PTLS_ERROR_INCORRECT_BASE64 (PTLS_ERROR_CLASS_INTERNAL + 50) | ||
| #define PTLS_ERROR_PEM_LABEL_NOT_FOUND (PTLS_ERROR_CLASS_INTERNAL + 51) | ||
|
|
@@ -604,10 +605,16 @@ PTLS_CALLBACK_TYPE(int, on_client_hello, ptls_t *tls, ptls_on_client_hello_param | |
| PTLS_CALLBACK_TYPE(int, emit_certificate, ptls_t *tls, ptls_message_emitter_t *emitter, ptls_key_schedule_t *key_sched, | ||
| ptls_iovec_t context, int push_status_request, const uint16_t *compress_algos, size_t num_compress_algos); | ||
| /** | ||
| * when gerenating CertificateVerify, the core calls the callback to sign the handshake context using the certificate. | ||
| * When gerenating CertificateVerify, the core calls the callback to sign the handshake context using the certificate. This callback | ||
| * may return PTLS_ERROR_ASYNC_OPERATION, and signal the application outside of picotls when the signature has been generated. At | ||
| * that point, the application should call `ptls_handshake`, which in turn would invoke this callback once again. The callback then | ||
| * fills `*selected_algorithm` and `output` with the signature being generated. Note that `algorithms` and `num_algorithms` are | ||
| * provided only when the callback is called for the first time. The callback can store arbitrary pointer specific to each signature | ||
| * generation in `*sign_ctx`. `*cb` can be set as an opportunity to cancel any asynchronous operation or free any temporary | ||
| * data allocated for the callback. | ||
| */ | ||
| PTLS_CALLBACK_TYPE(int, sign_certificate, ptls_t *tls, uint16_t *selected_algorithm, ptls_buffer_t *output, ptls_iovec_t input, | ||
| const uint16_t *algorithms, size_t num_algorithms); | ||
| PTLS_CALLBACK_TYPE(int, sign_certificate, ptls_t *tls, void (**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 | ||
| * callback that should be used for verifying CertificateVerify. If an error occurs between a successful return from this | ||
|
|
@@ -778,6 +785,10 @@ struct st_ptls_context_t { | |
| * boolean indicating if the cipher-suite should be chosen based on server's preference | ||
| */ | ||
| unsigned server_cipher_preference : 1; | ||
| /** | ||
| * boolean indicating if handshaking should be asynchronous | ||
| */ | ||
| unsigned async_handshake : 1; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about containing this state within the openssl backend? It can be a flag of IMO, all we need is a mechanism that allows the backend signal picotls if the operation has started asynchronously, the capability being provided by the error code being added.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes you're correct here, I don't think this flag should be needed in the end. I've added it as a way to temporarily disable async, for example in QUIC context, quicly uses a different code path, which I haven't gotten around to yet. |
||
| /** | ||
| * | ||
| */ | ||
|
|
@@ -1157,6 +1168,10 @@ ptls_context_t *ptls_get_context(ptls_t *tls); | |
| * updates the context of a connection. Can be called from `on_client_hello` callback. | ||
| */ | ||
| void ptls_set_context(ptls_t *tls, ptls_context_t *ctx); | ||
| /** | ||
| * get the signature context | ||
| */ | ||
| void *ptls_get_sign_context(ptls_t *tls); | ||
| /** | ||
| * returns the client-random | ||
| */ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.