tags:

views:

366

answers:

2

I am relatively new to socket programming so this may sound like a very lame question. I have to use authenticated TCP(MD5 as a TCP option to start with) as a transport for some application. I was wondering if this could be done using the sockets API or there is some other form of an existing TCP APIs that I could use to do the same. I would appreciate if I could get some help with this.

+2  A: 

I'm a bit confused by your question. You can certainly set socket options on a socket using the setsockopt function, but by the sound of the rest of your question, this isn't quite what you mean. I've never heard of any transport protocol called Authenticated TCP and google throws up nothing useful. Is it a standard; is there an RFC?

If you're just wanting a secure, authenticated TCP transport layer, then you should look in to Secure Sockets Layer, or SSL for short, or its replacement, Transport Layer Security, or TLS for short. There will almost certainly be an implementation for whatever language you're using (you haven't specified).

Also, what do you mean by MD5 for authentication? MD5 is a hashing algorithm, however it's not collision resistant enough for use in communication that requires secure signatures.

Edit aha! You're talking about TCP options, I understand now. I haven't seen any implementations of that particular TCP option built in to any of the socket APIs, so you may be out of luck here. It depends on the implementation you use, but it might be especially rare given that this is a fairly obscure TCP option designed for enhancing the border gateway protocol, not something you would usually have use for outside of routing software. In case it is supported, you would set it something like this:

BOOL optVal = TRUE;
int optLen = sizeof(BOOL);

if (setsockopt(
      socket,
      IPPROTO_TCP,
      TCP_WHATEVER,
      optVal,
      optLen) != SOCKET_ERROR) {
    printf("Success\n");
}
IRBMe
Thanks IRBMe! I am referring to RFC 2385. To make a long story short and based on the nature of the application, we have to use TCP with MD5 option as the transport (C implementation). I see sockets API as one possible option to setup this kind of a transport. I was wondering if there exist some other API set that could do the same thing but at the same time simplify the implementation a bit. thanks !
A: 

If you are looking for the TCP-MD5 option described by RFC 2385, a few systems support a TCP_MD5SIG option to enable this. It is enabled on a socket as follows:

int opt = 1;
setsockopt(sockfd, IPPROTO_TCP, TCP_MD5SIG, &opt, sizeof(opt));

See tcp(7) for further details.

mark4o