#include <arpa/inet.h>
#include <sys/socket.h>
-#include <openssl/sha.h>
-#include <openssl/rand.h>
-
#include "tvheadend.h"
#include "access.h"
#include "settings.h"
at = calloc(1, sizeof(access_ticket_t));
- RAND_bytes(buf, 20);
+ uuid_random(buf, 20);
//convert to hexstring
for(i=0; i<sizeof(buf); i++){
const uint8_t *challenge,
const char *username2, const char *passwd2)
{
- SHA_CTX shactx;
uint8_t d[20];
if (username == NULL || username[0] == '\0' ||
if (strcmp(username, username2))
return -1;
- SHA1_Init(&shactx);
- SHA1_Update(&shactx, (const uint8_t *)passwd2, strlen(passwd2));
- SHA1_Update(&shactx, challenge, 32);
- SHA1_Final(d, &shactx);
+ sha1_calc(d, (uint8_t *)passwd2, strlen(passwd2), challenge, 32);
return memcmp(d, digest, 20) ? -1 : 0;
}
access_entry_t *ae;
const char *s;
- static struct {
- pid_t pid;
- struct timeval tv;
- } randseed;
-
access_noacl = noacl;
if (noacl)
tvhlog(LOG_WARNING, "access", "Access control checking disabled");
- randseed.pid = getpid();
- gettimeofday(&randseed.tv, NULL);
- RAND_seed(&randseed, sizeof(randseed));
-
TAILQ_INIT(&access_entries);
TAILQ_INIT(&access_tickets);
TAILQ_INIT(&passwd_entries);
{
uint8_t uuidbin[20];
- satip_device_calc_bin_uuid(uuidbin, satip_uuid);
+ sha1_calc(uuidbin, (const uint8_t *)satip_uuid, strlen(satip_uuid), NULL, 0);
bin2hex(uuid->hex, sizeof(uuid->hex), uuidbin, sizeof(uuidbin));
}
uid_t uid = -1;
char buf[512];
FILE *pidfile = NULL;
+ static struct {
+ pid_t pid;
+ struct timeval tv;
+ uint8_t ru[32];
+ } randseed;
extern int dvb_bouquets_parse;
main_tid = pthread_self();
OPENSSL_config(NULL);
SSL_load_error_strings();
SSL_library_init();
+ /* Rand seed */
+ randseed.pid = main_tid;
+ gettimeofday(&randseed.tv, NULL);
+ uuid_random(randseed.ru, sizeof(randseed.ru));
+ RAND_seed(&randseed, sizeof(randseed));
/* Initialise configuration */
notify_init();
int deferred_unlink(const char *filename, const char *rootdir);
+void sha1_calc(uint8_t *dst, const uint8_t *d1, size_t d1_len, const uint8_t *d2, size_t d2_len);
+
static inline int32_t deltaI32(int32_t a, int32_t b) { return (a > b) ? (a - b) : (b - a); }
static inline uint32_t deltaU32(uint32_t a, uint32_t b) { return (a > b) ? (a - b) : (b - a); }
#include <dirent.h>
#include <unistd.h>
#include <ctype.h>
+
+#include <openssl/sha.h>
+
#include "tvheadend.h"
#include "tvh_endian.h"
}
return 0;
}
+
+void
+sha1_calc(uint8_t *dst,
+ const uint8_t *d1, size_t d1_len,
+ const uint8_t *d2, size_t d2_len)
+{
+ SHA_CTX shactx;
+
+ SHA1_Init(&shactx);
+ if (d1)
+ SHA1_Update(&shactx, d1, d1_len);
+ if (d2)
+ SHA1_Update(&shactx, d2, d2_len);
+ SHA1_Final(dst, &shactx);
+}