Skip to content
This repository has been archived by the owner on Jun 30, 2020. It is now read-only.

Migrate from callbacks to sockopts #34

Open
npmccallum opened this issue Apr 4, 2019 · 3 comments
Open

Migrate from callbacks to sockopts #34

npmccallum opened this issue Apr 4, 2019 · 3 comments

Comments

@npmccallum
Copy link
Contributor

Currently, the HANDSHAKE sockopt calls callbacks. Let's move to socket options instead of callbacks.

@npmccallum
Copy link
Contributor Author

The new code should define two new socket options: TLS_PSK_USER and TLS_PSK_KEY. These can be used with either getsockopt() or setsockopt().

Inside the handshake function, we need to determine if the peer wants to use authentication (PSK or otherwise). If so, we need to return ENOKEY. This tells the caller that authentication credentials need to be supplied and then handshake needs to be called again. We use ENOKEY rather than EAGAIN because the former indicates to call handshake without polling for data and EAGAIN indicates to poll for data.

After the caller receives ENOKEY, they must call setsockopt() to provide the authentication credentials. Clients must provide both TLS_PSK_USER and TLS_PSK_KEY. Servers should call getsockopt(TLS_PSK_USER) and then call setsockopt(TLS_PSK_KEY) to set the proper key for the user.

@frozencemetery @puiterwijk Thoughts?

@frozencemetery
Copy link
Contributor

I agree with the idea of moving away from callbacks - that's closer to the design I went with in GSSAPI as well.

My one concern would be making sure that the same interface works with the different TLS backends we have, but barring that, it sounds good to me.

@puiterwijk
Copy link
Contributor

So, I think that this might work reasonably, but we should make sure there's a way for the application to figure out what kind of keys they are requested to set (PSK user/pass, cert/key, ...).
I'm wondering whether we might offer the possibility to set the socket options with PSK user/pass or cert/key ahead of calling the handshake (if you are entirely sure what credentials you're going to be using, and there's no distinction for which ones (e.g. SNI and different certificates)).

I do think this makes it less clear that all of these options can be clearer again after handshake: the memory management could become somewhat more complicated: Does tlssock copy option values or do we expect pointers to options to remain valid for the duration of the handshake? How about post-handshake for a renegotiation or re-authentication?

DK-DARKmatter pushed a commit to DK-DARKmatter/tlssock that referenced this issue May 13, 2019
Changes in main.c, remove the callback functions. Change the structure
in on_conn() function. Use setsockopt() and getsockopt() to set or get
handshake parameters.

This is a series of commits that are related to issue:enarx-archive#33, enarx-archive#34
DK-DARKmatter pushed a commit to DK-DARKmatter/tlssock that referenced this issue May 15, 2019
Changes in main.c, remove the callback functions. Change the structure
in on_conn() function. Use setsockopt() and getsockopt() to set or get
handshake parameters.

This is a series of commits that are related to issue:enarx-archive#33, enarx-archive#34
@mbestavros mbestavros added this to Triage in Planning Jul 14, 2020
@mbestavros mbestavros added this to Assigned in Sprint Jul 15, 2020
@npmccallum npmccallum removed this from Assigned in Sprint Jul 15, 2020
@npmccallum npmccallum removed this from Triage in Planning Jul 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants