Skip to content

Commit 928626d

Browse files
authored
Abstract core KEM functionality out of DHKEM 2/2
This change was missed in the initial port of #1664. Without this change, customers cannot provide a non-DH KEM
1 parent 7cc8bf6 commit 928626d

File tree

1 file changed

+19
-0
lines changed
  • core/src/main/java/org/bouncycastle/crypto/hpke

1 file changed

+19
-0
lines changed

core/src/main/java/org/bouncycastle/crypto/hpke/HPKE.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,25 @@ public HPKE(byte mode, short kemId, short kdfId, short aeadId)
7070

7171
}
7272

73+
public HPKE(byte mode, short kemId, short kdfId, short aeadId, KEM kem, int encSize)
74+
{
75+
this.mode = mode;
76+
this.kemId = kemId;
77+
this.kdfId = kdfId;
78+
this.aeadId = aeadId;
79+
this.hkdf = new HKDF(kdfId);
80+
this.kem = kem;
81+
if (aeadId == aead_AES_GCM128)
82+
{
83+
Nk = 16;
84+
}
85+
else
86+
{
87+
Nk = 32;
88+
}
89+
this.encSize = encSize;
90+
}
91+
7392
public int getEncSize()
7493
{
7594
return kem.getEncryptionSize();

0 commit comments

Comments
 (0)