RSA_generate_key () using prngd instead of / dev / random or / dev / urandom

I want to use RSA_generate_key()on HP-UX 11.11. But hp-ux 11.11 does not provide / dev / random or / dev / urandom, so I need to use openssl prngd.

Please let me know how to use it by default in C code. I have openssl installed and prngd is available.

$ ls /opt/openssl/prngd/prngd  
/opt/openssl/prngd/prngd

Let me know if you need more information.

+5
source share
2 answers

Noting that prngd uses the same interface as EGD, check out the instructions found here . Interesting quote:

On systems without / dev / * random devices providing entropy from the kernel

PRNGD, EGD-.

OpenSSL EGD, RAND_bytes(), RAND_status() , /var/run/egd -pool,/dev/egd-pool /etc/egd-pool.

, prngd, prngd /dev/egd-pool

+3

prngd "/dev/random" "/dev/urandom" . Unix ( "/var/run/egd-pool" ), ( ) IP TCP 708 4840 ( --- ).

, Unix :

#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>

int devrandom(void)
{
  union 
  {
    struct sockaddr    sa;
    struct sockaddr_un path;
  } location;
  int sock;               

  memset(&location,0,sizeof(location));
  location.path.sun_family = AF_UNIX;
  strcpy(location.path.sun_path,"/var/run/egd-pool");

  sock = socket(AF_UNIX,SOCK_STREAM,0);
  if (sock < 0)
    return -1; 

  if (connect(sock,&location.sa,sizeof(struct sockaddr_un)) < 0)
    return -1;

  return sock;
}

, read(), ( : ). TCP/IP , , .

+2

All Articles