Skip to content

Commit cc6137b

Browse files
committed
Scaffolding for new SSLSession exportKeyingMaterial methods
1 parent d8677b4 commit cc6137b

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed

tls/src/main/java/org/bouncycastle/jsse/BCExtendedSSLSession.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,23 @@
33
import java.util.Collections;
44
import java.util.List;
55

6+
import javax.crypto.SecretKey;
7+
import javax.net.ssl.SSLKeyException;
68
import javax.net.ssl.SSLSession;
79

810
public abstract class BCExtendedSSLSession implements SSLSession
911
{
12+
public byte[] exportKeyingMaterialData(String label, byte[] context, int length) throws SSLKeyException
13+
{
14+
throw new UnsupportedOperationException();
15+
}
16+
17+
public SecretKey exportKeyingMaterialKey(String keyAlg, String label, byte[] context, int length)
18+
throws SSLKeyException
19+
{
20+
throw new UnsupportedOperationException();
21+
}
22+
1023
public abstract String[] getLocalSupportedSignatureAlgorithms();
1124

1225
public String[] getLocalSupportedSignatureAlgorithmsBC()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.bouncycastle.jsse.provider;
2+
3+
import javax.crypto.SecretKey;
4+
import javax.net.ssl.SSLKeyException;
5+
6+
import org.bouncycastle.jsse.BCExtendedSSLSession;
7+
8+
class ExportSSLSession_25
9+
extends ExportSSLSession_9
10+
{
11+
ExportSSLSession_25(BCExtendedSSLSession sslSession)
12+
{
13+
super(sslSession);
14+
}
15+
16+
@Override
17+
public byte[] exportKeyingMaterialData(String label, byte[] context, int length) throws SSLKeyException
18+
{
19+
return sslSession.exportKeyingMaterialData(label, context, length);
20+
}
21+
22+
@Override
23+
public SecretKey exportKeyingMaterialKey(String keyAlg, String label, byte[] context, int length)
24+
throws SSLKeyException
25+
{
26+
return sslSession.exportKeyingMaterialKey(keyAlg, label, context, length);
27+
}
28+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.bouncycastle.jsse.provider;
2+
3+
import javax.crypto.SecretKey;
4+
import javax.net.ssl.ExtendedSSLSession;
5+
import javax.net.ssl.SSLKeyException;
6+
7+
class ImportSSLSession_25
8+
extends ImportSSLSession_9
9+
{
10+
ImportSSLSession_25(ExtendedSSLSession sslSession)
11+
{
12+
super(sslSession);
13+
}
14+
15+
@Override
16+
public byte[] exportKeyingMaterialData(String label, byte[] context, int length) throws SSLKeyException
17+
{
18+
return sslSession.exportKeyingMaterialData(label, context, length);
19+
}
20+
21+
@Override
22+
public SecretKey exportKeyingMaterialKey(String keyAlg, String label, byte[] context, int length)
23+
throws SSLKeyException
24+
{
25+
return sslSession.exportKeyingMaterialKey(keyAlg, label, context, length);
26+
}
27+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package org.bouncycastle.jsse.provider;
2+
3+
import javax.net.ssl.ExtendedSSLSession;
4+
import javax.net.ssl.SSLSession;
5+
6+
import org.bouncycastle.jsse.BCExtendedSSLSession;
7+
8+
abstract class SSLSessionUtil
9+
{
10+
static SSLSession exportSSLSession(BCExtendedSSLSession sslSession)
11+
{
12+
if (sslSession instanceof ImportSSLSession)
13+
{
14+
return ((ImportSSLSession)sslSession).unwrap();
15+
}
16+
17+
return new ExportSSLSession_25(sslSession);
18+
}
19+
20+
static BCExtendedSSLSession importSSLSession(SSLSession sslSession)
21+
{
22+
if (sslSession instanceof BCExtendedSSLSession)
23+
{
24+
return (BCExtendedSSLSession)sslSession;
25+
}
26+
27+
if (sslSession instanceof ExportSSLSession)
28+
{
29+
return ((ExportSSLSession)sslSession).unwrap();
30+
}
31+
32+
if (sslSession instanceof ExtendedSSLSession)
33+
{
34+
return new ImportSSLSession_25((ExtendedSSLSession)sslSession);
35+
}
36+
37+
return new ImportSSLSession_5(sslSession);
38+
}
39+
}

0 commit comments

Comments
 (0)