Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add preSharedKeyIdentity to the ServerHandshaker. #749

Merged
merged 1 commit into from
Sep 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
* Achim Kraus (Bosch Software Innovations GmbH) - add handshake parameter available to
* process reordered handshake messages
* Achim Kraus (Bosch Software Innovations GmbH) - add dtls flight number
* Achim Kraus (Bosch Software Innovations GmbH) - add preSharedKeyIdentity to
* support creating statistics.
******************************************************************************/
package org.eclipse.californium.scandium.dtls;

Expand Down Expand Up @@ -146,6 +148,8 @@ public class ServerHandshaker extends Handshaker {
/** Used to retrieve pre-shared-key from a given client identity */
protected final PskStore pskStore;

private String preSharedKeyIdentity;

// Constructors ///////////////////////////////////////////////////

/**
Expand Down Expand Up @@ -244,6 +248,9 @@ public ServerHandshaker(int initialMessageSequenceNo, DTLSSession session, Recor

// Methods ////////////////////////////////////////////////////////

public String getPreSharedKeyIdentity() {
return preSharedKeyIdentity;
}

@Override
protected synchronized void doProcessMessage(DTLSMessage message) throws HandshakeException, GeneralSecurityException {
Expand Down Expand Up @@ -712,6 +719,7 @@ private byte[] receivedClientKeyExchange(final PSKClientKeyExchange message) thr

// use the client's PSK identity to look up the pre-shared key
String identity = message.getIdentity();
preSharedKeyIdentity = identity;
byte[] psk = pskStore.getKey(indicatedServerNames, identity);
return configurePskCredentials(identity, psk, null);
}
Expand All @@ -722,6 +730,7 @@ private byte[] receivedClientKeyExchange(final EcdhPskClientKeyExchange message)

// use the client's PSK identity to look up the pre-shared key
String identity = message.getIdentity();
preSharedKeyIdentity = identity;
byte[] psk = pskStore.getKey(indicatedServerNames, identity);
byte[] otherSecret = ecdhe.getSecret(message.getEncodedPoint()).getEncoded();
return configurePskCredentials(identity, psk, otherSecret);
Expand Down