11 #include <netinet/in.h>
26 #define PUBFILE "cert.pem"
27 #define PRIVFILE "privkey.pem"
35 static const char *
usage =
"Usage: example1 [-d]\n";
37 int main(
int argc,
char *argv[])
46 else if ((argc == 2) && !strcmp(argv[1],
"-d"))
64 unsigned char *ekey[1];
66 int ekeylen, net_ekeylen;
71 memset(iv,
'\0',
sizeof(iv));
77 fprintf(stderr,
"Error: can't load public key");
97 net_ekeylen = htonl(ekeylen);
98 write(
STDOUT, (
char*)&net_ekeylen,
sizeof(net_ekeylen));
99 write(
STDOUT, ekey[0], ekeylen);
100 write(
STDOUT, iv,
sizeof(iv));
116 write(
STDOUT, ebuf, ebuflen);
121 write(
STDOUT, ebuf, ebuflen);
134 unsigned char *encryptKey;
135 unsigned int ekeylen;
138 memset(iv,
'\0',
sizeof(iv));
143 fprintf(stderr,
"Error: can't load private key");
148 ekeylen = ntohl(ekeylen);
153 fprintf(stderr,
"keylength mismatch");
157 encryptKey = malloc(
sizeof(
char) * ekeylen);
176 int readlen =
read(
STDIN, ebuf,
sizeof(ebuf));
187 write(
STDOUT, buf, buflen);
192 write(
STDOUT, buf, buflen);