2
votes

I want to design an EAP-TLS client. As the protocol works on the ethernet layer, I am using raw sockets in C and designing the handshake step by step. I wanted to get the TLS data into the packet i designed using OpenSSL. The examples I found online used SSL_Connect() with a socket descriptor and sent the data. I however want to copy the data into the buffer i will send using the raw sockets. Is there any way to do this ? Thank you!

1
It sounds like SSL_Connect() does everything you want it to do. Why can't you just copy the implementation? If you want to do it as a learning exercise Why cant you just create a packed struct full of the information you want and just write(fileDesc, struct ptr, sizeof(struct)) ?Scotty Bauer

1 Answers

3
votes

If you want to have everything in your own buffer and not send directly to the socket you have to use not a file descriptor, but a memory BIO as the lower layer for SSL and then you can use the usual SSL_ functions on top of it. You might have a look at Directly Read/Write Handshake data with Memory BIO. A working implementation you'll find in AnyEvent::Handle. Although this is Perl the usage of the BIO_ functions is the same.