1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

fix #155, #135, support osx(darwin) for mac pro. 2.0.137.

This commit is contained in:
winlin 2015-03-10 12:50:27 +08:00
parent 20fb5f3e8e
commit db7ddfd510
16 changed files with 1075 additions and 52 deletions

View file

@ -73,7 +73,7 @@ namespace _srs_internal
int __openssl_HMACsha256(HMAC_CTX* ctx, const void* data, int data_size, void* digest, unsigned int* digest_size)
{
int ret = ERROR_SUCCESS;
#ifndef SRS_OSX
if (HMAC_Update(ctx, (unsigned char *) data, data_size) < 0) {
ret = ERROR_OpenSslSha256Update;
return ret;
@ -83,6 +83,10 @@ namespace _srs_internal
ret = ERROR_OpenSslSha256Final;
return ret;
}
#else
HMAC_Update(ctx, (unsigned char *) data, data_size);
HMAC_Final(ctx, (unsigned char *) digest, digest_size);
#endif
return ret;
}
@ -117,10 +121,14 @@ namespace _srs_internal
// for instance, in python, hashlib.sha256(data).digest().
HMAC_CTX_init(&ctx);
#ifndef SRS_OSX
if (HMAC_Init_ex(&ctx, __key, key_size, EVP_sha256(), NULL) < 0) {
ret = ERROR_OpenSslSha256Init;
return ret;
}
#else
HMAC_Init_ex(&ctx, __key, key_size, EVP_sha256(), NULL);
#endif
ret = __openssl_HMACsha256(&ctx, data, data_size, __digest, &digest_size);
HMAC_CTX_cleanup(&ctx);