summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
071e09e)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Backport of r43080
git-svn-id: svn://svn.openwrt.org/openwrt/branches/barrier_breaker@43083
3c298f89-4303-0410-b956-
a3cf2f4a3e73
-# Copyright (C) 2010 Jo-Philipp Wich <xm@subsignal.org>
+# Copyright (C) 2010-2014 Jo-Philipp Wich <xm@subsignal.org>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
include $(TOPDIR)/rules.mk
PKG_NAME:=px5g
include $(TOPDIR)/rules.mk
PKG_NAME:=px5g
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_CHECK_FORMAT_SECURITY:=0
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_CHECK_FORMAT_SECURITY:=0
+ * Create a random serial
+ */
+static int get_random_serial(void)
+{
+ int random = 0;
+ FILE *fd;
+
+ fd = fopen("/dev/urandom", "r");
+
+ if (fd) {
+ if (fread(&random, 1, sizeof(random), fd) != sizeof(random))
+ random = 0;
+
+ fclose(fd);
+ }
+
+ return random;
+}
+
+/*
* Create a self signed certificate
*/
int x509write_create_sign(x509_raw *chain, rsa_context *privkey)
* Create a self signed certificate
*/
int x509write_create_sign(x509_raw *chain, rsa_context *privkey)
/*
* CertificateSerialNumber ::= INTEGER
*/
/*
* CertificateSerialNumber ::= INTEGER
*/
- srand((unsigned int) time(NULL));
- serial = rand();
+ serial = get_random_serial();
+
+ if (serial == 0)
+ return 1;
+
if ((ret = asn1_add_int(serial, &chain->serial)) != 0)
return ret;
if ((ret = asn1_add_int(serial, &chain->serial)) != 0)
return ret;