>>3845 ニッタン 自分用のメモ。ソースが SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method()); SSL ssl = SSL_new(ctx); SSL_connect(ssl); となっていたとして、 SSL_CTX *SSL_CTX_new(SSL_METHOD *meth){ ret->method=meth; SSL_METHOD *SSLv23_client_method(void){ SSLv23_client_data.ssl_connect=ssl23_connect; int ssl23_connect(SSL *s) ret=ssl23_client_hello(s); static int ssl23_client_hello(SSL *s) RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE); int RAND_pseudo_bytes(unsigned char *buf, int num) const RAND_METHOD *meth = RAND_get_rand_method(); return meth->pseudorand(buf,num); /* (*1) */ const RAND_METHOD *RAND_get_rand_method(void) default_RAND_meth = RAND_SSLeay(); /* (*2) */ return default_RAND_meth; static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num){ ret = RAND_bytes(buf, num); static int ssleay_rand_bytes(unsigned char *buf, int num) if (ok){ ... } else { RANDerr(RAND_F_SSLEAY_RAND_BYTES,RAND_R_PRNG_NOT_SEEDED); ときて「PRNG not seeded」エラーになる、てな感じですかね。 (*1) RAND_METHOD rand_ssleay_meth={ ssleay_rand_seed, ssleay_rand_bytes, ssleay_rand_cleanup, ssleay_rand_add, ssleay_rand_pseudo_bytes, ssleay_rand_status }; typedef struct rand_meth_st { void (*seed)(const void *buf, int num); int (*bytes)(unsigned char *buf, int num); void (*cleanup)(void); void (*add)(const void *buf, int num, double entropy); int (*pseudorand)(unsigned char *buf, int num); int (*status)(void); } RAND_METHOD; (*2) RAND_METHOD *RAND_SSLeay(void) return(&rand_ssleay_meth); |