24
24
*/
25
25
#ifdef HAVE_CONFIG_H
26
26
# include <config.h>
27
- #endif /* HAVE_CONFIG_H */
27
+ #endif /* defined( HAVE_CONFIG_H) */
28
28
29
29
#include <assert.h>
30
30
#include <string.h>
@@ -52,15 +52,15 @@ typedef struct ngtcp2_crypto_boringssl_cipher {
52
52
} ngtcp2_crypto_boringssl_cipher ;
53
53
54
54
static ngtcp2_crypto_boringssl_cipher crypto_cipher_aes_128 = {
55
- NGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_128 ,
55
+ NGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_128 ,
56
56
};
57
57
58
58
static ngtcp2_crypto_boringssl_cipher crypto_cipher_aes_256 = {
59
- NGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_256 ,
59
+ NGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_256 ,
60
60
};
61
61
62
62
static ngtcp2_crypto_boringssl_cipher crypto_cipher_chacha20 = {
63
- NGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_CHACHA20 ,
63
+ NGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_CHACHA20 ,
64
64
};
65
65
66
66
ngtcp2_crypto_aead * ngtcp2_crypto_aead_aes_128_gcm (ngtcp2_crypto_aead * aead ) {
@@ -175,7 +175,7 @@ static ngtcp2_crypto_ctx *crypto_ctx_cipher_id(ngtcp2_crypto_ctx *ctx,
175
175
ctx -> hp .native_handle = (void * )crypto_cipher_id_get_hp (cipher_id );
176
176
ctx -> max_encryption = crypto_cipher_id_get_aead_max_encryption (cipher_id );
177
177
ctx -> max_decryption_failure =
178
- crypto_cipher_id_get_aead_max_decryption_failure (cipher_id );
178
+ crypto_cipher_id_get_aead_max_decryption_failure (cipher_id );
179
179
180
180
return ctx ;
181
181
}
@@ -413,12 +413,12 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
413
413
AES_ecb_encrypt (sample , dest , & ctx -> aes_key , 1 );
414
414
return 0 ;
415
415
case NGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_CHACHA20 :
416
- #if defined( WORDS_BIGENDIAN )
416
+ #ifdef WORDS_BIGENDIAN
417
417
counter = (uint32_t )sample [0 ] + (uint32_t )(sample [1 ] << 8 ) +
418
418
(uint32_t )(sample [2 ] << 16 ) + (uint32_t )(sample [3 ] << 24 );
419
- #else /* !WORDS_BIGENDIAN */
419
+ #else /* !defined( WORDS_BIGENDIAN) */
420
420
memcpy (& counter , sample , sizeof (counter ));
421
- #endif /* !WORDS_BIGENDIAN */
421
+ #endif /* !defined( WORDS_BIGENDIAN) */
422
422
CRYPTO_chacha_20 (dest , PLAINTEXT , sizeof (PLAINTEXT ) - 1 , ctx -> key ,
423
423
sample + sizeof (counter ), counter );
424
424
return 0 ;
@@ -429,17 +429,16 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
429
429
}
430
430
431
431
int ngtcp2_crypto_read_write_crypto_data (
432
- ngtcp2_conn * conn , ngtcp2_encryption_level encryption_level ,
433
- const uint8_t * data , size_t datalen ) {
432
+ ngtcp2_conn * conn , ngtcp2_encryption_level encryption_level ,
433
+ const uint8_t * data , size_t datalen ) {
434
434
SSL * ssl = ngtcp2_conn_get_tls_native_handle (conn );
435
435
int rv ;
436
436
int err ;
437
437
438
438
if (SSL_provide_quic_data (
439
- ssl ,
440
- ngtcp2_crypto_boringssl_from_ngtcp2_encryption_level (
441
- encryption_level ),
442
- data , datalen ) != 1 ) {
439
+ ssl ,
440
+ ngtcp2_crypto_boringssl_from_ngtcp2_encryption_level (encryption_level ),
441
+ data , datalen ) != 1 ) {
443
442
return -1 ;
444
443
}
445
444
@@ -522,7 +521,7 @@ int ngtcp2_crypto_set_local_transport_params(void *tls, const uint8_t *buf,
522
521
}
523
522
524
523
ngtcp2_encryption_level ngtcp2_crypto_boringssl_from_ssl_encryption_level (
525
- enum ssl_encryption_level_t ssl_level ) {
524
+ enum ssl_encryption_level_t ssl_level ) {
526
525
switch (ssl_level ) {
527
526
case ssl_encryption_initial :
528
527
return NGTCP2_ENCRYPTION_LEVEL_INITIAL ;
@@ -540,7 +539,7 @@ ngtcp2_encryption_level ngtcp2_crypto_boringssl_from_ssl_encryption_level(
540
539
541
540
enum ssl_encryption_level_t
542
541
ngtcp2_crypto_boringssl_from_ngtcp2_encryption_level (
543
- ngtcp2_encryption_level encryption_level ) {
542
+ ngtcp2_encryption_level encryption_level ) {
544
543
switch (encryption_level ) {
545
544
case NGTCP2_ENCRYPTION_LEVEL_INITIAL :
546
545
return ssl_encryption_initial ;
@@ -582,7 +581,7 @@ static int set_read_secret(SSL *ssl, enum ssl_encryption_level_t bssl_level,
582
581
ngtcp2_crypto_conn_ref * conn_ref = SSL_get_app_data (ssl );
583
582
ngtcp2_conn * conn = conn_ref -> get_conn (conn_ref );
584
583
ngtcp2_encryption_level level =
585
- ngtcp2_crypto_boringssl_from_ssl_encryption_level (bssl_level );
584
+ ngtcp2_crypto_boringssl_from_ssl_encryption_level (bssl_level );
586
585
(void )cipher ;
587
586
588
587
if (ngtcp2_crypto_derive_and_install_rx_key (conn , NULL , NULL , NULL , level ,
@@ -599,7 +598,7 @@ static int set_write_secret(SSL *ssl, enum ssl_encryption_level_t bssl_level,
599
598
ngtcp2_crypto_conn_ref * conn_ref = SSL_get_app_data (ssl );
600
599
ngtcp2_conn * conn = conn_ref -> get_conn (conn_ref );
601
600
ngtcp2_encryption_level level =
602
- ngtcp2_crypto_boringssl_from_ssl_encryption_level (bssl_level );
601
+ ngtcp2_crypto_boringssl_from_ssl_encryption_level (bssl_level );
603
602
(void )cipher ;
604
603
605
604
if (ngtcp2_crypto_derive_and_install_tx_key (conn , NULL , NULL , NULL , level ,
@@ -615,7 +614,7 @@ static int add_handshake_data(SSL *ssl, enum ssl_encryption_level_t bssl_level,
615
614
ngtcp2_crypto_conn_ref * conn_ref = SSL_get_app_data (ssl );
616
615
ngtcp2_conn * conn = conn_ref -> get_conn (conn_ref );
617
616
ngtcp2_encryption_level level =
618
- ngtcp2_crypto_boringssl_from_ssl_encryption_level (bssl_level );
617
+ ngtcp2_crypto_boringssl_from_ssl_encryption_level (bssl_level );
619
618
int rv ;
620
619
621
620
rv = ngtcp2_conn_submit_crypto_data (conn , level , data , datalen );
@@ -644,8 +643,8 @@ static int send_alert(SSL *ssl, enum ssl_encryption_level_t bssl_level,
644
643
}
645
644
646
645
static SSL_QUIC_METHOD quic_method = {
647
- set_read_secret , set_write_secret , add_handshake_data ,
648
- flush_flight , send_alert ,
646
+ set_read_secret , set_write_secret , add_handshake_data ,
647
+ flush_flight , send_alert ,
649
648
};
650
649
651
650
static void crypto_boringssl_configure_context (SSL_CTX * ssl_ctx ) {
0 commit comments