Spec rev30: Fixes for the new fallback patterns

This commit is contained in:
Rhys Weatherley 2016-07-08 18:08:16 +10:00
parent 36223590c4
commit 3cc08ef765
2 changed files with 20 additions and 5 deletions

View File

@ -593,10 +593,17 @@ public class HandshakeState implements Destroyable {
throw new IllegalStateException("Responder cannot fall back from this state");
}
// Format a new protocol name for the "XXfallback" variant
// Format a new protocol name for the fallback variant
// and recreate the SymmetricState object.
String name = symmetric.getProtocolName().replace("_IK_", "_XXfallback_");
String[] components = name.split("_");
String[] components = symmetric.getProtocolName().split("_");
components[1] = patternName;
StringBuilder builder = new StringBuilder();
builder.append(components[0]);
for (int index = 1; index < components.length; ++index) {
builder.append('_');
builder.append(components[index]);
}
String name = builder.toString();
SymmetricState newSymmetric = new SymmetricState(name, components[3], components[4]);
symmetric.destroy();
symmetric = newSymmetric;

View File

@ -75,6 +75,7 @@ public class VectorTests {
public String dh;
public String cipher;
public String hash;
public String fallback_pattern;
public byte[] init_prologue;
public byte[] init_ephemeral;
public byte[] init_static;
@ -196,9 +197,14 @@ public class VectorTests {
// Success!
}
// Look up the pattern to fall back to.
String pattern = vec.fallback_pattern;
if (pattern == null)
pattern = "XXfallback";
// Initiate fallback on both sides.
initiator.fallback();
responder.fallback();
initiator.fallback(pattern);
responder.fallback(pattern);
// Restart the protocols.
initiator.start();
@ -297,6 +303,8 @@ public class VectorTests {
vec.cipher = reader.nextString();
else if (name.equals("hash"))
vec.hash = reader.nextString();
else if (name.equals("fallback_pattern"))
vec.fallback_pattern = reader.nextString();
else if (name.equals("init_prologue"))
vec.init_prologue = DatatypeConverter.parseHexBinary(reader.nextString());
else if (name.equals("init_ephemeral"))