{
u_char *p, *pnp, *nonce, *sample, *packet;
ngx_str_t ad, out;
- const EVP_CIPHER *cipher;
+ const EVP_CIPHER *cipher, *hp;
ngx_quic_connection_t *qc;
u_char mask[16];
case NGX_AES_128_GCM_SHA256:
cipher = EVP_aes_128_gcm();
+ hp = EVP_aes_128_ecb();
break;
case NGX_AES_256_GCM_SHA384:
cipher = EVP_aes_256_gcm();
+ hp = EVP_aes_256_ecb();
break;
default:
} else {
cipher = EVP_aes_128_gcm();
+ hp = EVP_aes_128_ecb();
}
nonce = ngx_pstrdup(c->pool, &pkt->secret->iv);
}
sample = &out.data[3]; // pnl=0
- if (ngx_quic_tls_hp(c, EVP_aes_128_ecb(), pkt->secret, mask, sample) != NGX_OK) {
+ if (ngx_quic_tls_hp(c, hp, pkt->secret, mask, sample) != NGX_OK) {
return NGX_ERROR;
}
{
u_char *p, *pnp, *nonce, *sample, *packet;
ngx_str_t ad, out;
- const EVP_CIPHER *cipher;
+ const EVP_CIPHER *cipher, *hp;
ngx_quic_connection_t *qc;
u_char mask[16];
case NGX_AES_128_GCM_SHA256:
cipher = EVP_aes_128_gcm();
+ hp = EVP_aes_128_ecb();
break;
case NGX_AES_256_GCM_SHA384:
cipher = EVP_aes_256_gcm();
+ hp = EVP_aes_256_ecb();
break;
default:
ngx_quic_hexdump0(c->log, "out", out.data, out.len);
sample = &out.data[3]; // pnl=0
- if (ngx_quic_tls_hp(c, EVP_aes_128_ecb(), pkt->secret, mask, sample)
- != NGX_OK)
- {
+ if (ngx_quic_tls_hp(c, hp, pkt->secret, mask, sample) != NGX_OK) {
return NGX_ERROR;
}
ngx_int_t pnl, rc;
ngx_str_t in, ad;
- const EVP_CIPHER *cipher;
+ const EVP_CIPHER *cipher, *hp;
uint8_t mask[16];
+ if (c->ssl) {
+ switch (SSL_CIPHER_get_id(SSL_get_current_cipher(c->ssl->connection)) & 0xffff) {
+
+ case NGX_AES_128_GCM_SHA256:
+ cipher = EVP_aes_128_gcm();
+ hp = EVP_aes_128_ecb();
+ break;
+ case NGX_AES_256_GCM_SHA384:
+ cipher = EVP_aes_256_gcm();
+ hp = EVP_aes_256_ecb();
+ break;
+ default:
+ ngx_ssl_error(NGX_LOG_INFO, c->log, 0, "unexpected cipher");
+ return NGX_ERROR;
+ }
+
+ } else {
+ /* initial packets */
+ cipher = EVP_aes_128_gcm();
+ hp = EVP_aes_128_ecb();
+ }
+
p = pkt->pos;
/* draft-ietf-quic-tls-23#section-5.4.2:
/* header protection */
- if (ngx_quic_tls_hp(c, EVP_aes_128_ecb(), pkt->secret, mask, sample)
- != NGX_OK)
- {
+ if (ngx_quic_tls_hp(c, hp, pkt->secret, mask, sample) != NGX_OK) {
return NGX_ERROR;
}
ngx_quic_hexdump0(c->log, "nonce", nonce, 12);
ngx_quic_hexdump0(c->log, "ad", ad.data, ad.len);
- if (c->ssl) {
- switch (SSL_CIPHER_get_id(SSL_get_current_cipher(c->ssl->connection)) & 0xffff) {
-
- case NGX_AES_128_GCM_SHA256:
- cipher = EVP_aes_128_gcm();
- break;
- case NGX_AES_256_GCM_SHA384:
- cipher = EVP_aes_256_gcm();
- break;
- default:
- ngx_ssl_error(NGX_LOG_INFO, c->log, 0, "unexpected cipher");
- return NGX_ERROR;
- }
-
- } else {
- /* initial packets */
- cipher = EVP_aes_128_gcm();
- }
-
rc = ngx_quic_tls_open(c, cipher, pkt->secret, &pkt->payload,
nonce, &in, &ad);