Skip to content

Commit dd008fd

Browse files
author
Achim Kraus
committed
Add preSharedKeyIdentity to the ServerHandshaker.
Support creating statistics. Signed-off-by: Achim Kraus <[email protected]>
1 parent 24bb1d0 commit dd008fd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

scandium-core/src/main/java/org/eclipse/californium/scandium/dtls/ServerHandshaker.java

+9
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
* Achim Kraus (Bosch Software Innovations GmbH) - add handshake parameter available to
4949
* process reordered handshake messages
5050
* Achim Kraus (Bosch Software Innovations GmbH) - add dtls flight number
51+
* Achim Kraus (Bosch Software Innovations GmbH) - add preSharedKeyIdentity to
52+
* support creating statistics.
5153
******************************************************************************/
5254
package org.eclipse.californium.scandium.dtls;
5355

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

151+
private String preSharedKeyIdentity;
152+
149153
// Constructors ///////////////////////////////////////////////////
150154

151155
/**
@@ -244,6 +248,9 @@ public ServerHandshaker(int initialMessageSequenceNo, DTLSSession session, Recor
244248

245249
// Methods ////////////////////////////////////////////////////////
246250

251+
public String getPreSharedKeyIdentity() {
252+
return preSharedKeyIdentity;
253+
}
247254

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

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

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

0 commit comments

Comments
 (0)