Skip to content

Commit a5133e4

Browse files
committed
Introduce a NoiseKeyEncapsulationMechanism interface
1 parent 4d29db6 commit a5133e4

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.eatthepath.noise.component;
2+
3+
public record EncapsulatedKey(byte[] sharedSecret, byte[] encapsulation) {
4+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.eatthepath.noise.component;
2+
3+
import java.security.KeyPair;
4+
import java.security.PrivateKey;
5+
import java.security.PublicKey;
6+
7+
public interface NoiseKeyEncapsulationMechanism {
8+
9+
static NoiseKeyEncapsulationMechanism getInstance(final String name) {
10+
throw new IllegalArgumentException("Unrecognized key encapsulation method name: " + name);
11+
}
12+
13+
String getName();
14+
15+
KeyPair generateKeyPair();
16+
17+
EncapsulatedKey encapsulate(PublicKey publicKey);
18+
19+
byte[] decapsulate(PrivateKey privateKey, byte[] encapsulation);
20+
21+
int getPublicKeyLength();
22+
23+
int getSharedSecretLength();
24+
25+
int getEncapsulationLength();
26+
}

0 commit comments

Comments
 (0)