#include "tinytls.h" #include #include #include #include char pkt[]= "\x16\x03\x01\x01\x4e\x01\x00\x01\x4a\x03\x03\x4f\x93\x81\xfb\x57" "\x72\x4b\x79\x31\x35\x0f\x4e\xb6\xd5\x47\xb7\x0d\xb5\x54\x0e\xd1" "\x71\xc1\xb6\x9b\x9f\xdb\xa5\xf0\xe4\x43\xac\x00\x00\xa0\xc0\x30" "\xc0\x2c\xc0\x28\xc0\x24\xc0\x14\xc0\x0a\xc0\x22\xc0\x21\x00\xa3" "\x00\x9f\x00\x6b\x00\x6a\x00\x39\x00\x38\x00\x88\x00\x87\xc0\x32" "\xc0\x2e\xc0\x2a\xc0\x26\xc0\x0f\xc0\x05\x00\x9d\x00\x3d\x00\x35" "\x00\x84\xc0\x12\xc0\x08\xc0\x1c\xc0\x1b\x00\x16\x00\x13\xc0\x0d" "\xc0\x03\x00\x0a\xc0\x2f\xc0\x2b\xc0\x27\xc0\x23\xc0\x13\xc0\x09" "\xc0\x1f\xc0\x1e\x00\xa2\x00\x9e\x00\x67\x00\x40\x00\x33\x00\x32" "\x00\x9a\x00\x99\x00\x45\x00\x44\xc0\x31\xc0\x2d\xc0\x29\xc0\x25" "\xc0\x0e\xc0\x04\x00\x9c\x00\x3c\x00\x2f\x00\x96\x00\x41\x00\x07" "\xc0\x11\xc0\x07\xc0\x0c\xc0\x02\x00\x05\x00\x04\x00\x15\x00\x12" "\x00\x09\x00\x14\x00\x11\x00\x08\x00\x06\x00\x03\x00\xff\x02\x01" "\x00\x00\x80\x00\x00\x00\x11\x00\x0f\x00\x00\x0c\x62\x6c\x6f\x67" "\x2e\x66\x65\x66\x65\x2e\x64\x65\x00\x0b\x00\x04\x03\x00\x01\x02" "\x00\x0a\x00\x34\x00\x32\x00\x0e\x00\x0d\x00\x19\x00\x0b\x00\x0c" "\x00\x18\x00\x09\x00\x0a\x00\x16\x00\x17\x00\x08\x00\x06\x00\x07" "\x00\x14\x00\x15\x00\x04\x00\x05\x00\x12\x00\x13\x00\x01\x00\x02" "\x00\x03\x00\x0f\x00\x10\x00\x11\x00\x0d\x00\x22\x00\x20\x06\x01" "\x06\x02\x06\x03\x05\x01\x05\x02\x05\x03\x04\x01\x04\x02\x04\x03" "\x03\x01\x03\x02\x03\x03\x02\x01\x02\x02\x02\x03\x01\x01\x00\x0f" "\x00\x01\x01\x15\x03\x03\x00\x02\x02\x30"; int main() { struct ssl_context sc; int fd; fd=socket_tcp4b(); if (fd==-1) diesys(1,"socket"); if (socket_connect4(fd,ip4loopback,443)==-1) if (socket_connect4(fd,ip4loopback,4433)==-1) diesys(1,"connect"); #if 0 size_t l; char buf[200]; init_tls_context_norandom(&sc,NULL); printf("%zu\n",fmt_tls_serverhello(NULL,pkt,sizeof(pkt),&sc)); init_tls_context_norandom(&sc,"blog.fefe.de"); l=fmt_tls_clienthello(buf,&sc); printf("%zu\n",fmt_tls_serverhello(NULL,buf,l,&sc)); #endif init_tls_context(&sc,"localhost"); tls_connect(fd,&sc); return 0; }