#include "htsmsg_json.h"
#include "compat.h"
+#include "openssl/opensslv.h"
+
#if ENABLE_ANDROID
#include <sys/socket.h>
#endif
mono ^= 0xa1687211885fcd30LL;
xor ^= 0xf6e398624aa55013LL;
snprintf(stamp, sizeof(stamp), "A!*Fz32%"PRId64"%"PRId64, mono, xor);
- m = sha512sum256_base64(stamp);
+ m = sha256sum_base64(stamp);
if (m == NULL) return -1;
strlcpy(n->nonce, m, sizeof(n->nonce));
tvh_mutex_lock(&global_lock);
char *a = alloca(strlen(realm) + strlen(hc->hc_nonce) + 1);
strcpy(a, realm);
strcat(a, hc->hc_nonce);
- return sha512sum256_base64(a);
+ return sha256sum_base64(a);
}
/**
char *opaque;
if (hc->hc_nonce == NULL && http_get_nonce(hc)) goto __noauth;
opaque = http_get_opaque(hc, realm);
+ if (opaque == NULL) goto __noauth;
if (config.http_auth_algo != HTTP_AUTH_ALGO_MD5)
http_auth_header(&hdrs, realm,
config.http_auth_algo == HTTP_AUTH_ALGO_SHA256 ?
- "SHA-256" : "SHA-512-256", hc->hc_nonce, opaque);
+ "SHA-256" :
+#if OPENSSL_VERSION_NUMBER >= 0x1010101fL
+ "SHA-512-256",
+#else
+ "SHA-256",
+#endif
+ hc->hc_nonce, opaque);
http_auth_header(&hdrs, realm, NULL, hc->hc_nonce, opaque);
free(opaque);
} else {
char *md5sum ( const char *str, int lowercase );
char *sha256sum ( const char *str, int lowercase );
char *sha512sum256 ( const char *str, int lowercase );
-char *sha512sum256_base64 ( const char *str );
+char *sha256sum_base64 ( const char *str );
int makedirs ( int subsys, const char *path, int mode, int mstrict, gid_t gid, uid_t uid );
#include <string.h>
#include <assert.h>
#include <openssl/evp.h>
+#include <openssl/opensslv.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
char *
sha512sum256 ( const char *str, int lowercase )
{
+#if OPENSSL_VERSION_NUMBER >= 0x1010101fL
return openssl_hash_hexstr(str, lowercase, EVP_sha512_256(), 32);
+#else
+ return NULL;
+#endif
}
char *
-sha512sum256_base64 ( const char *str )
+sha256sum_base64 ( const char *str )
{
uint8_t hash[32];
char *out = malloc(64);
if (out == NULL) return NULL;
- if (openssl_hash(hash, (const uint8_t *)str, strlen(str), EVP_sha512_256()) == NULL) {
+ if (openssl_hash(hash, (const uint8_t *)str, strlen(str), EVP_sha256()) == NULL) {
free(out);
return NULL;
}