diff options
Diffstat (limited to 'src/main/java/org/bouncycastle/crypto/tls/AbstractTlsContext.java')
-rw-r--r-- | src/main/java/org/bouncycastle/crypto/tls/AbstractTlsContext.java | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/src/main/java/org/bouncycastle/crypto/tls/AbstractTlsContext.java b/src/main/java/org/bouncycastle/crypto/tls/AbstractTlsContext.java index 0b5b8feb..83310330 100644 --- a/src/main/java/org/bouncycastle/crypto/tls/AbstractTlsContext.java +++ b/src/main/java/org/bouncycastle/crypto/tls/AbstractTlsContext.java @@ -2,7 +2,9 @@ package org.bouncycastle.crypto.tls; import java.security.SecureRandom;
-abstract class AbstractTlsContext implements TlsContext {
+abstract class AbstractTlsContext
+ implements TlsContext
+{
private SecureRandom secureRandom;
private SecurityParameters securityParameters;
@@ -11,50 +13,61 @@ abstract class AbstractTlsContext implements TlsContext { private ProtocolVersion serverVersion = null;
private Object userObject = null;
- AbstractTlsContext(SecureRandom secureRandom, SecurityParameters securityParameters) {
+ AbstractTlsContext(SecureRandom secureRandom, SecurityParameters securityParameters)
+ {
this.secureRandom = secureRandom;
this.securityParameters = securityParameters;
}
- public SecureRandom getSecureRandom() {
+ public SecureRandom getSecureRandom()
+ {
return secureRandom;
}
- public SecurityParameters getSecurityParameters() {
+ public SecurityParameters getSecurityParameters()
+ {
return securityParameters;
}
- public ProtocolVersion getClientVersion() {
+ public ProtocolVersion getClientVersion()
+ {
return clientVersion;
}
- public void setClientVersion(ProtocolVersion clientVersion) {
+ public void setClientVersion(ProtocolVersion clientVersion)
+ {
this.clientVersion = clientVersion;
}
- public ProtocolVersion getServerVersion() {
+ public ProtocolVersion getServerVersion()
+ {
return serverVersion;
}
- public void setServerVersion(ProtocolVersion serverVersion) {
+ public void setServerVersion(ProtocolVersion serverVersion)
+ {
this.serverVersion = serverVersion;
}
- public Object getUserObject() {
+ public Object getUserObject()
+ {
return userObject;
}
- public void setUserObject(Object userObject) {
+ public void setUserObject(Object userObject)
+ {
this.userObject = userObject;
}
- public byte[] exportKeyingMaterial(String asciiLabel, byte[] context_value, int length) {
+ public byte[] exportKeyingMaterial(String asciiLabel, byte[] context_value, int length)
+ {
SecurityParameters sp = getSecurityParameters();
byte[] cr = sp.getClientRandom(), sr = sp.getServerRandom();
int seedLength = cr.length + sr.length;
- if (context_value != null) {
+ if (context_value != null)
+ {
seedLength += (2 + context_value.length);
}
@@ -65,14 +78,16 @@ abstract class AbstractTlsContext implements TlsContext { seedPos += cr.length;
System.arraycopy(sr, 0, seed, seedPos, sr.length);
seedPos += sr.length;
- if (context_value != null) {
+ if (context_value != null)
+ {
TlsUtils.writeUint16(context_value.length, seed, seedPos);
seedPos += 2;
System.arraycopy(context_value, 0, seed, seedPos, context_value.length);
seedPos += context_value.length;
}
- if (seedPos != seedLength) {
+ if (seedPos != seedLength)
+ {
throw new IllegalStateException("error in calculation of seed for export");
}
|