mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
SRT: Upgrade libsrt from 1.4.1 to 1.5.1. v6.0.12 (#3362)
Co-authored-by: winlin <winlin@vip.126.com>
This commit is contained in:
parent
7a56208f2f
commit
fe086dfc31
143 changed files with 38185 additions and 15108 deletions
|
@ -13,18 +13,23 @@
|
|||
written by
|
||||
Haivision Systems Inc.
|
||||
|
||||
2022-05-19 (jdube)
|
||||
CRYSPR2 adaptation
|
||||
2019-06-26 (jdube)
|
||||
OpenSSL CRYSPR/4SRT (CRYypto Service PRovider for SRT).
|
||||
OpenSSL Direct AES CRYSPR/4SRT (CRYypto Service PRovider for SRT).
|
||||
*****************************************************************************/
|
||||
|
||||
#include "hcrypt.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
typedef struct tag_crysprOpenSSL_AES_cb {
|
||||
CRYSPR_cb ccb;
|
||||
/* Add cryptolib specific data here */
|
||||
CRYSPR_cb ccb;
|
||||
/* Add cryptolib specific data here */
|
||||
#ifdef CRYSPR2
|
||||
CRYSPR_AESCTX aes_kek_buf; /* Key Encrypting Key (KEK) */
|
||||
CRYSPR_AESCTX aes_sek_buf[2]; /* even/odd Stream Encrypting Key (SEK) */
|
||||
#endif
|
||||
} crysprOpenSSL_cb;
|
||||
|
||||
|
||||
|
@ -34,11 +39,14 @@ int crysprOpenSSL_Prng(unsigned char *rn, int len)
|
|||
}
|
||||
|
||||
int crysprOpenSSL_AES_SetKey(
|
||||
int cipher_type, /* One of HCRYPT_CTX_MODE_[CLRTXT|AESECB|AESCTR] */
|
||||
bool bEncrypt, /* true Enxcrypt key, false: decrypt */
|
||||
const unsigned char *kstr, /* key sttring*/
|
||||
size_t kstr_len, /* kstr len in bytes (16, 24, or 32 bytes (for AES128,AES192, or AES256) */
|
||||
CRYSPR_AESCTX *aes_key) /* CRYpto Service PRovider AES Key context */
|
||||
{
|
||||
(void)cipher_type;
|
||||
|
||||
if (bEncrypt) { /* Encrypt key */
|
||||
if (AES_set_encrypt_key(kstr, kstr_len * 8, aes_key)) {
|
||||
HCRYPT_LOG(LOG_ERR, "%s", "AES_set_encrypt_key(kek) failed\n");
|
||||
|
@ -123,7 +131,24 @@ int crysprOpenSSL_AES_CtrCipher(
|
|||
#endif
|
||||
return 0;
|
||||
}
|
||||
#ifdef CRYSPR2
|
||||
static CRYSPR_cb *crysprOpenSSL_Open(CRYSPR_methods *cryspr, size_t max_len)
|
||||
{
|
||||
crysprOpenSSL_cb *aes_data;
|
||||
|
||||
aes_data = (crysprOpenSSL_cb *)crysprHelper_Open(cryspr, sizeof(crysprOpenSSL_cb), max_len);
|
||||
if (NULL == aes_data) {
|
||||
HCRYPT_LOG(LOG_ERR, "crysprHelper_Open(%p, %zd, %zd) failed\n", cryspr, sizeof(crysprOpenSSL_cb), max_len);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
aes_data->ccb.aes_kek = &aes_data->aes_kek_buf; //key encrypting key
|
||||
aes_data->ccb.aes_sek[0] = &aes_data->aes_sek_buf[0]; //stream encrypting key
|
||||
aes_data->ccb.aes_sek[1] = &aes_data->aes_sek_buf[1]; //stream encrypting key
|
||||
|
||||
return(&aes_data->ccb);
|
||||
}
|
||||
#endif /* CRYSPR2 */
|
||||
/*
|
||||
* Password-based Key Derivation Function
|
||||
*/
|
||||
|
@ -148,8 +173,7 @@ int crysprOpenSSL_KmWrap(CRYSPR_cb *cryspr_cb,
|
|||
const unsigned char *sek,
|
||||
unsigned int seklen)
|
||||
{
|
||||
crysprOpenSSL_cb *aes_data = (crysprOpenSSL_cb *)cryspr_cb;
|
||||
AES_KEY *kek = &aes_data->ccb.aes_kek; //key encrypting key
|
||||
AES_KEY *kek = CRYSPR_GETKEK(cryspr_cb); //key encrypting key
|
||||
|
||||
return(((seklen + HAICRYPT_WRAPKEY_SIGN_SZ) == (unsigned int)AES_wrap_key(kek, NULL, wrap, sek, seklen)) ? 0 : -1);
|
||||
}
|
||||
|
@ -160,8 +184,7 @@ int crysprOpenSSL_KmUnwrap(
|
|||
const unsigned char *wrap,
|
||||
unsigned int wraplen)
|
||||
{
|
||||
crysprOpenSSL_cb *aes_data = (crysprOpenSSL_cb *)cryspr_cb;
|
||||
AES_KEY *kek = &aes_data->ccb.aes_kek; //key encrypting key
|
||||
AES_KEY *kek = CRYSPR_GETKEK(cryspr_cb); //key encrypting key
|
||||
|
||||
return(((wraplen - HAICRYPT_WRAPKEY_SIGN_SZ) == (unsigned int)AES_unwrap_key(kek, NULL, sek, wrap, wraplen)) ? 0 : -1);
|
||||
}
|
||||
|
@ -192,7 +215,11 @@ CRYSPR_methods *crysprOpenSSL(void)
|
|||
#endif
|
||||
|
||||
//--Crypto Session API-----------------------------------------
|
||||
#ifdef CRYSPR2
|
||||
crysprOpenSSL_methods.open = crysprOpenSSL_Open;
|
||||
#else
|
||||
// crysprOpenSSL_methods.open =
|
||||
#endif
|
||||
// crysprOpenSSL_methods.close =
|
||||
//--Keying material (km) encryption
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue