-/* $OpenBSD: getentropy_linux.c,v 1.23 2014/07/13 13:03:09 deraadt Exp $ */
+/* $OpenBSD: getentropy_linux.c,v 1.24 2014/07/13 13:37:38 deraadt Exp $ */
/*
* Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
+#include <link.h>
#include <termios.h>
#include <fcntl.h>
#include <signal.h>
static int getentropy_sysctl(void *buf, size_t len);
#endif
static int getentropy_fallback(void *buf, size_t len);
+static int getentropy_phdr(struct dl_phdr_info *info, size_t size, void *data);
int
getentropy(void *buf, size_t len)
#endif
};
+static int
+getentropy_phdr(struct dl_phdr_info *info, size_t size, void *data)
+{
+ SHA512_CTX *ctx = data;
+
+ SHA512_Update(ctx, &info->dlpi_addr, sizeof (info->dlpi_addr));
+ return 0;
+}
+
static int
getentropy_fallback(void *buf, size_t len)
{
cnt += (int)tv.tv_usec;
}
+ dl_iterate_phdr(getentropy_phdr, &ctx);
+
for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); ii++)
HX(clock_gettime(cl[ii], &ts) == -1, ts);
-/* $OpenBSD: getentropy_solaris.c,v 1.6 2014/07/13 13:03:09 deraadt Exp $ */
+/* $OpenBSD: getentropy_solaris.c,v 1.7 2014/07/13 13:37:38 deraadt Exp $ */
/*
* Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
+#include <link.h>
#include <termios.h>
#include <fcntl.h>
#include <signal.h>
static int getentropy_urandom(void *buf, size_t len, const char *path,
int devfscheck);
static int getentropy_fallback(void *buf, size_t len);
+static int getentropy_phdr(struct dl_phdr_info *info, size_t size, void *data);
int
getentropy(void *buf, size_t len)
#endif
};
+static int
+getentropy_phdr(struct dl_phdr_info *info, size_t size, void *data)
+{
+ SHA512_CTX *ctx = data;
+
+ SHA512_Update(ctx, &info->dlpi_addr, sizeof (info->dlpi_addr));
+ return 0;
+}
+
static int
getentropy_fallback(void *buf, size_t len)
{
cnt += (int)tv.tv_usec;
}
+ dl_iterate_phdr(getentropy_phdr, &ctx);
+
for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); ii++)
HX(clock_gettime(cl[ii], &ts) == -1, ts);
-/* $OpenBSD: getentropy_linux.c,v 1.23 2014/07/13 13:03:09 deraadt Exp $ */
+/* $OpenBSD: getentropy_linux.c,v 1.24 2014/07/13 13:37:38 deraadt Exp $ */
/*
* Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
+#include <link.h>
#include <termios.h>
#include <fcntl.h>
#include <signal.h>
static int getentropy_sysctl(void *buf, size_t len);
#endif
static int getentropy_fallback(void *buf, size_t len);
+static int getentropy_phdr(struct dl_phdr_info *info, size_t size, void *data);
int
getentropy(void *buf, size_t len)
#endif
};
+static int
+getentropy_phdr(struct dl_phdr_info *info, size_t size, void *data)
+{
+ SHA512_CTX *ctx = data;
+
+ SHA512_Update(ctx, &info->dlpi_addr, sizeof (info->dlpi_addr));
+ return 0;
+}
+
static int
getentropy_fallback(void *buf, size_t len)
{
cnt += (int)tv.tv_usec;
}
+ dl_iterate_phdr(getentropy_phdr, &ctx);
+
for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); ii++)
HX(clock_gettime(cl[ii], &ts) == -1, ts);
-/* $OpenBSD: getentropy_solaris.c,v 1.6 2014/07/13 13:03:09 deraadt Exp $ */
+/* $OpenBSD: getentropy_solaris.c,v 1.7 2014/07/13 13:37:38 deraadt Exp $ */
/*
* Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
+#include <link.h>
#include <termios.h>
#include <fcntl.h>
#include <signal.h>
static int getentropy_urandom(void *buf, size_t len, const char *path,
int devfscheck);
static int getentropy_fallback(void *buf, size_t len);
+static int getentropy_phdr(struct dl_phdr_info *info, size_t size, void *data);
int
getentropy(void *buf, size_t len)
#endif
};
+static int
+getentropy_phdr(struct dl_phdr_info *info, size_t size, void *data)
+{
+ SHA512_CTX *ctx = data;
+
+ SHA512_Update(ctx, &info->dlpi_addr, sizeof (info->dlpi_addr));
+ return 0;
+}
+
static int
getentropy_fallback(void *buf, size_t len)
{
cnt += (int)tv.tv_usec;
}
+ dl_iterate_phdr(getentropy_phdr, &ctx);
+
for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); ii++)
HX(clock_gettime(cl[ii], &ts) == -1, ts);