changeset 9:765303f4f2da

Attempt to fix randombytes.c for unpatched NaCl
author Ivo Smits <Ivo@UCIS.nl>
date Thu, 14 Jul 2011 16:49:21 +0200
parents a1fc155ca80b
children 130a6a714966
files nacl.c randombytes.c
diffstat 2 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/nacl.c	Thu Jul 14 16:32:23 2011 +0200
+++ b/nacl.c	Thu Jul 14 16:49:21 2011 +0200
@@ -43,23 +43,23 @@
 ZEND_BEGIN_ARG_INFO_EX(arginfo_nacl_crypto_box_curve25519xsalsa20poly1305_keypair, 0, 0, 2)
 	ZEND_ARG_INFO(1, zsk)
 	ZEND_ARG_INFO(0, rb)
-ZEND_END_ARG_INFO() 
+ZEND_END_ARG_INFO()
 #else
 ZEND_BEGIN_ARG_INFO_EX(arginfo_nacl_crypto_box_curve25519xsalsa20poly1305_keypair, 0, 0, 1)
 	ZEND_ARG_INFO(1, zsk)
 	ZEND_ARG_INFO(0, rb)
-ZEND_END_ARG_INFO() 
+ZEND_END_ARG_INFO()
 #endif
 #if defined crypto_sign_edwards25519sha512batch_KEYPAIRRANDOMBYTES
 ZEND_BEGIN_ARG_INFO_EX(arginfo_nacl_crypto_sign_edwards25519sha512batch_keypair, 0, 0, 2)
 	ZEND_ARG_INFO(1, zsk)
 	ZEND_ARG_INFO(0, rb)
-ZEND_END_ARG_INFO() 
+ZEND_END_ARG_INFO()
 #else
 ZEND_BEGIN_ARG_INFO_EX(arginfo_nacl_crypto_sign_edwards25519sha512batch_keypair, 0, 0, 1)
 	ZEND_ARG_INFO(1, zsk)
 	ZEND_ARG_INFO(0, rb)
-ZEND_END_ARG_INFO() 
+ZEND_END_ARG_INFO()
 #endif
 
 static function_entry nacl_functions[] = {
--- a/randombytes.c	Thu Jul 14 16:32:23 2011 +0200
+++ b/randombytes.c	Thu Jul 14 16:49:21 2011 +0200
@@ -1,8 +1,8 @@
 #include <time.h>
 
 void randombytes(unsigned char *x,unsigned long long xlen) {
-	int fd = open("/dev/urandom",O_RDONLY);
-	if (fd != -1) {
+	FILE* fd = fopen("/dev/urandom", "rb");
+	if (fd != NULL) {
 		fread(x, 1, xlen, fd);
 		fclose(fd);
 	} else {