check in some experimental X.509 parsing code
This commit is contained in:
19
init_tls_context.c
Normal file
19
init_tls_context.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "tinytls.h"
|
||||
#include "open.h"
|
||||
#include <unistd.h>
|
||||
|
||||
void init_tls_context_norandom(struct ssl_context* sc, const char* servername) {
|
||||
memset(sc,0,sizeof *sc);
|
||||
sc->servername=servername;
|
||||
}
|
||||
|
||||
int init_tls_context(struct ssl_context* sc, const char* servername) {
|
||||
int fd=open_read("/dev/urandom");
|
||||
int r;
|
||||
if (fd==-1) return -1;
|
||||
init_tls_context_norandom(sc,servername);
|
||||
r=read(fd,sc->myrandom,sizeof(sc->myrandom));
|
||||
close(fd);
|
||||
if (r!=sizeof(sc->myrandom)) return -1;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user