Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ded17f2
add PTLS_ERROR_ASYNC_OPERATION application error
sharksforarms Jul 19, 2022
aa4f09a
add async capabilities to openssl implementation
sharksforarms Jul 19, 2022
4d6f6cd
fix minicrypto and uecc impls
sharksforarms Jul 19, 2022
2b4aff9
test async api
sharksforarms Jul 19, 2022
f7ea678
internally buffer the write buffer
sharksforarms Jul 19, 2022
621509b
Revert "internally buffer the write buffer"
sharksforarms Jul 19, 2022
4ab5ba7
internally buffer the asynchronous data
sharksforarms Jul 19, 2022
a55938b
fix: openssl copies the data from ptr, send a pointer instead
sharksforarms Jul 19, 2022
04aa8cf
fix: don't clobber job ptr
sharksforarms Jul 21, 2022
b9a0040
fix header decl for `ptls_openssl_get_async_fd`
sharksforarms Jul 22, 2022
7c6707a
allocate sign_ctx when we know siglen
sharksforarms Jul 22, 2022
2792654
rename `ptls_get_sign_ctx` to `ptls_get_sign_context`
sharksforarms Jul 22, 2022
c931aef
move `ASYNC_WAIT_CTX_new` to `sign_ctx_alloc`
sharksforarms Jul 25, 2022
83607a8
add a callback to signing api to free resources
sharksforarms Jul 26, 2022
a58b7e3
define `PTLS_OPENSSL_HAVE_ASYNC`
sharksforarms Aug 15, 2022
cc5a20e
support synchronous client signing
sharksforarms Aug 16, 2022
10472b5
coverity
sharksforarms Aug 24, 2022
ec6e099
add `async_handshake` flag to ptls context
sharksforarms Aug 24, 2022
e1148cd
improve docs
sharksforarms Sep 15, 2022
b4ab91a
rename cb to cancel_cb
sharksforarms Sep 15, 2022
d2ffef1
rename server_complete_handshake to server_finish_handshake
sharksforarms Sep 15, 2022
6f558cf
move async toggle to st_ptls_openssl_sign_certificate_t
sharksforarms Sep 15, 2022
6b71b99
check the value
sharksforarms Sep 15, 2022
5c0a108
async by default
sharksforarms Sep 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions include/picotls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -604,10 +605,17 @@ 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`.
* 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, 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 (**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
* callback that should be used for verifying CertificateVerify. If an error occurs between a successful return from this
Expand Down Expand Up @@ -1157,6 +1165,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
*/
Expand Down
13 changes: 13 additions & 0 deletions include/picotls/openssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ extern "C" {
#endif
#endif

#if OPENSSL_VERSION_NUMBER >= 0x10100010L && !defined(LIBRESSL_VERSION_NUMBER)
#if !defined(OPENSSL_NO_ASYNC)
#define PTLS_OPENSSL_HAVE_ASYNC 1
#endif
#endif

extern ptls_key_exchange_algorithm_t ptls_openssl_secp256r1;
#ifdef NID_secp384r1
#define PTLS_OPENSSL_HAVE_SECP384R1 1
Expand Down Expand Up @@ -91,6 +97,9 @@ void ptls_openssl_random_bytes(void *buf, size_t len);
* constructs a key exchange context. pkey's reference count is incremented.
*/
int ptls_openssl_create_key_exchange(ptls_key_exchange_context_t **ctx, EVP_PKEY *pkey);
#ifdef PTLS_OPENSSL_HAVE_ASYNC
int ptls_openssl_get_async_fd(ptls_t *ptls);
#endif

struct st_ptls_openssl_signature_scheme_t {
uint16_t scheme_id;
Expand All @@ -101,6 +110,10 @@ typedef struct st_ptls_openssl_sign_certificate_t {
ptls_sign_certificate_t super;
EVP_PKEY *key;
const struct st_ptls_openssl_signature_scheme_t *schemes; /* terminated by .scheme_id == UINT16_MAX */
/**
* boolean indicating if signing should be asynchronous
*/
unsigned async : 1;
} ptls_openssl_sign_certificate_t;

int ptls_openssl_init_sign_certificate(ptls_openssl_sign_certificate_t *self, EVP_PKEY *key);
Expand Down
Loading