mirror of
https://github.com/zotanmew/nginx-rtmp-module.git
synced 2024-05-06 13:11:07 +02:00
OpenSSL-1.1 support
This commit is contained in:
parent
c3237ae747
commit
f23323a51a
|
@ -104,30 +104,37 @@ static ngx_int_t
|
||||||
ngx_rtmp_make_digest(ngx_str_t *key, ngx_buf_t *src,
|
ngx_rtmp_make_digest(ngx_str_t *key, ngx_buf_t *src,
|
||||||
u_char *skip, u_char *dst, ngx_log_t *log)
|
u_char *skip, u_char *dst, ngx_log_t *log)
|
||||||
{
|
{
|
||||||
static HMAC_CTX hmac;
|
static HMAC_CTX *hmac;
|
||||||
static unsigned hmac_initialized;
|
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
|
|
||||||
if (!hmac_initialized) {
|
if (hmac == NULL) {
|
||||||
HMAC_CTX_init(&hmac);
|
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||||
hmac_initialized = 1;
|
static HMAC_CTX shmac;
|
||||||
|
hmac = &shmac;
|
||||||
|
HMAC_CTX_init(hmac);
|
||||||
|
#else
|
||||||
|
hmac = HMAC_CTX_new();
|
||||||
|
if (hmac == NULL) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
HMAC_Init_ex(&hmac, key->data, key->len, EVP_sha256(), NULL);
|
HMAC_Init_ex(hmac, key->data, key->len, EVP_sha256(), NULL);
|
||||||
|
|
||||||
if (skip && src->pos <= skip && skip <= src->last) {
|
if (skip && src->pos <= skip && skip <= src->last) {
|
||||||
if (skip != src->pos) {
|
if (skip != src->pos) {
|
||||||
HMAC_Update(&hmac, src->pos, skip - src->pos);
|
HMAC_Update(hmac, src->pos, skip - src->pos);
|
||||||
}
|
}
|
||||||
if (src->last != skip + NGX_RTMP_HANDSHAKE_KEYLEN) {
|
if (src->last != skip + NGX_RTMP_HANDSHAKE_KEYLEN) {
|
||||||
HMAC_Update(&hmac, skip + NGX_RTMP_HANDSHAKE_KEYLEN,
|
HMAC_Update(hmac, skip + NGX_RTMP_HANDSHAKE_KEYLEN,
|
||||||
src->last - skip - NGX_RTMP_HANDSHAKE_KEYLEN);
|
src->last - skip - NGX_RTMP_HANDSHAKE_KEYLEN);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
HMAC_Update(&hmac, src->pos, src->last - src->pos);
|
HMAC_Update(hmac, src->pos, src->last - src->pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
HMAC_Final(&hmac, dst, &len);
|
HMAC_Final(hmac, dst, &len);
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue