@@ -125,7 +125,7 @@ static int supported_cipher_suite(ptls_cipher_suite_t *cs) {
125
125
#ifdef PTLS_OPENSSL_HAVE_CHACHA20_POLY1305
126
126
|| cs -> aead == & ptls_openssl_chacha20poly1305
127
127
#endif /* defined(PTLS_OPENSSL_HAVE_CHACHA20_POLY1305) */
128
- ;
128
+ ;
129
129
}
130
130
131
131
ngtcp2_crypto_ctx * ngtcp2_crypto_ctx_tls (ngtcp2_crypto_ctx * ctx ,
@@ -146,7 +146,7 @@ ngtcp2_crypto_ctx *ngtcp2_crypto_ctx_tls(ngtcp2_crypto_ctx *ctx,
146
146
ctx -> hp .native_handle = (void * )crypto_cipher_suite_get_hp (cs );
147
147
ctx -> max_encryption = crypto_cipher_suite_get_aead_max_encryption (cs );
148
148
ctx -> max_decryption_failure =
149
- crypto_cipher_suite_get_aead_max_decryption_failure (cs );
149
+ crypto_cipher_suite_get_aead_max_decryption_failure (cs );
150
150
return ctx ;
151
151
}
152
152
@@ -329,19 +329,22 @@ int ngtcp2_crypto_decrypt(uint8_t *dest, const ngtcp2_crypto_aead *aead,
329
329
const uint8_t * nonce , size_t noncelen ,
330
330
const uint8_t * aad , size_t aadlen ) {
331
331
ptls_aead_context_t * actx = aead_ctx -> native_handle ;
332
+ size_t nwrite ;
332
333
333
334
(void )aead ;
334
335
335
336
ptls_aead_xor_iv (actx , nonce , noncelen );
336
337
337
- if (ptls_aead_decrypt (actx , dest , ciphertext , ciphertextlen , 0 , aad ,
338
- aadlen ) == SIZE_MAX ) {
339
- return -1 ;
340
- }
338
+ nwrite =
339
+ ptls_aead_decrypt (actx , dest , ciphertext , ciphertextlen , 0 , aad , aadlen );
341
340
342
341
/* zero-out static iv once again */
343
342
ptls_aead_xor_iv (actx , nonce , noncelen );
344
343
344
+ if (nwrite == SIZE_MAX ) {
345
+ return -1 ;
346
+ }
347
+
345
348
return 0 ;
346
349
}
347
350
@@ -360,13 +363,13 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
360
363
}
361
364
362
365
int ngtcp2_crypto_read_write_crypto_data (
363
- ngtcp2_conn * conn , ngtcp2_encryption_level encryption_level ,
364
- const uint8_t * data , size_t datalen ) {
366
+ ngtcp2_conn * conn , ngtcp2_encryption_level encryption_level ,
367
+ const uint8_t * data , size_t datalen ) {
365
368
ngtcp2_crypto_picotls_ctx * cptls = ngtcp2_conn_get_tls_native_handle (conn );
366
369
ptls_buffer_t sendbuf ;
367
370
size_t epoch_offsets [5 ] = {0 };
368
371
size_t epoch =
369
- ngtcp2_crypto_picotls_from_ngtcp2_encryption_level (encryption_level );
372
+ ngtcp2_crypto_picotls_from_ngtcp2_encryption_level (encryption_level );
370
373
size_t epoch_datalen ;
371
374
size_t i ;
372
375
int rv ;
@@ -388,7 +391,7 @@ int ngtcp2_crypto_read_write_crypto_data(
388
391
389
392
if (!ngtcp2_conn_is_server (conn ) &&
390
393
cptls -> handshake_properties .client .early_data_acceptance ==
391
- PTLS_EARLY_DATA_REJECTED ) {
394
+ PTLS_EARLY_DATA_REJECTED ) {
392
395
rv = ngtcp2_conn_tls_early_data_rejected (conn );
393
396
if (rv != 0 ) {
394
397
rv = -1 ;
@@ -405,8 +408,8 @@ int ngtcp2_crypto_read_write_crypto_data(
405
408
assert (i != 1 );
406
409
407
410
if (ngtcp2_conn_submit_crypto_data (
408
- conn , ngtcp2_crypto_picotls_from_epoch (i ),
409
- sendbuf .base + epoch_offsets [i ], epoch_datalen ) != 0 ) {
411
+ conn , ngtcp2_crypto_picotls_from_epoch (i ),
412
+ sendbuf .base + epoch_offsets [i ], epoch_datalen ) != 0 ) {
410
413
rv = -1 ;
411
414
goto fin ;
412
415
}
@@ -463,7 +466,7 @@ ngtcp2_encryption_level ngtcp2_crypto_picotls_from_epoch(size_t epoch) {
463
466
}
464
467
465
468
size_t ngtcp2_crypto_picotls_from_ngtcp2_encryption_level (
466
- ngtcp2_encryption_level encryption_level ) {
469
+ ngtcp2_encryption_level encryption_level ) {
467
470
switch (encryption_level ) {
468
471
case NGTCP2_ENCRYPTION_LEVEL_INITIAL :
469
472
return 0 ;
@@ -532,17 +535,17 @@ static int set_additional_extensions(ptls_handshake_properties_t *hsprops,
532
535
}
533
536
534
537
int ngtcp2_crypto_picotls_collect_extension (
535
- ptls_t * ptls , struct st_ptls_handshake_properties_t * properties ,
536
- uint16_t type ) {
538
+ ptls_t * ptls , struct st_ptls_handshake_properties_t * properties ,
539
+ uint16_t type ) {
537
540
(void )ptls ;
538
541
(void )properties ;
539
542
540
543
return type == NGTCP2_TLSEXT_QUIC_TRANSPORT_PARAMETERS_V1 ;
541
544
}
542
545
543
546
int ngtcp2_crypto_picotls_collected_extensions (
544
- ptls_t * ptls , struct st_ptls_handshake_properties_t * properties ,
545
- ptls_raw_extension_t * extensions ) {
547
+ ptls_t * ptls , struct st_ptls_handshake_properties_t * properties ,
548
+ ptls_raw_extension_t * extensions ) {
546
549
ngtcp2_crypto_conn_ref * conn_ref ;
547
550
ngtcp2_conn * conn ;
548
551
int rv ;
@@ -558,7 +561,7 @@ int ngtcp2_crypto_picotls_collected_extensions(
558
561
conn = conn_ref -> get_conn (conn_ref );
559
562
560
563
rv = ngtcp2_conn_decode_and_set_remote_transport_params (
561
- conn , extensions -> data .base , extensions -> data .len );
564
+ conn , extensions -> data .base , extensions -> data .len );
562
565
if (rv != 0 ) {
563
566
ngtcp2_conn_set_tls_error (conn , rv );
564
567
return -1 ;
@@ -613,7 +616,7 @@ static int update_traffic_key_server_cb(ptls_update_traffic_key_t *self,
613
616
}
614
617
615
618
static ptls_update_traffic_key_t update_traffic_key_server = {
616
- update_traffic_key_server_cb ,
619
+ update_traffic_key_server_cb ,
617
620
};
618
621
619
622
static int update_traffic_key_cb (ptls_update_traffic_key_t * self , ptls_t * ptls ,
@@ -661,7 +664,7 @@ int ngtcp2_crypto_picotls_configure_client_context(ptls_context_t *ctx) {
661
664
}
662
665
663
666
int ngtcp2_crypto_picotls_configure_server_session (
664
- ngtcp2_crypto_picotls_ctx * cptls ) {
667
+ ngtcp2_crypto_picotls_ctx * cptls ) {
665
668
ptls_handshake_properties_t * hsprops = & cptls -> handshake_properties ;
666
669
667
670
hsprops -> collect_extension = ngtcp2_crypto_picotls_collect_extension ;
@@ -671,7 +674,7 @@ int ngtcp2_crypto_picotls_configure_server_session(
671
674
}
672
675
673
676
int ngtcp2_crypto_picotls_configure_client_session (
674
- ngtcp2_crypto_picotls_ctx * cptls , ngtcp2_conn * conn ) {
677
+ ngtcp2_crypto_picotls_ctx * cptls , ngtcp2_conn * conn ) {
675
678
ptls_handshake_properties_t * hsprops = & cptls -> handshake_properties ;
676
679
677
680
hsprops -> client .max_early_data_size = calloc (1 , sizeof (size_t ));
@@ -692,7 +695,7 @@ int ngtcp2_crypto_picotls_configure_client_session(
692
695
}
693
696
694
697
void ngtcp2_crypto_picotls_deconfigure_session (
695
- ngtcp2_crypto_picotls_ctx * cptls ) {
698
+ ngtcp2_crypto_picotls_ctx * cptls ) {
696
699
ptls_handshake_properties_t * hsprops ;
697
700
ptls_raw_extension_t * exts ;
698
701
0 commit comments