Skip to content

Commit 12c3b2e

Browse files
committed
Added BIKE KEM algorithm
Added getEncapsulationLength() method to EncapsulatedSecretExtractor.
1 parent d0cac2f commit 12c3b2e

File tree

106 files changed

+21561
-99
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+21561
-99
lines changed

core/src/main/java/org/bouncycastle/asn1/bc/BCObjectIdentifiers.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,4 +358,20 @@ public interface BCObjectIdentifiers
358358
ASN1ObjectIdentifier sntrup953 = pqc_kem_sntruprime.branch("4");
359359
ASN1ObjectIdentifier sntrup1013 = pqc_kem_sntruprime.branch("5");
360360
ASN1ObjectIdentifier sntrup1277 = pqc_kem_sntruprime.branch("6");
361+
362+
/**
363+
* BIKE
364+
**/
365+
ASN1ObjectIdentifier pqc_kem_bike = bc_kem.branch("8");
366+
ASN1ObjectIdentifier bike128 = pqc_kem_bike.branch("1");
367+
ASN1ObjectIdentifier bike192 = pqc_kem_bike.branch("2");
368+
ASN1ObjectIdentifier bike256 = pqc_kem_bike.branch("3");
369+
370+
/**
371+
* HQC
372+
**/
373+
ASN1ObjectIdentifier pqc_kem_hqc = bc_kem.branch("9");
374+
ASN1ObjectIdentifier hqc128 = pqc_kem_hqc.branch("1");
375+
ASN1ObjectIdentifier hqc192 = pqc_kem_hqc.branch("2");
376+
ASN1ObjectIdentifier hqc256 = pqc_kem_hqc.branch("3");
361377
}

core/src/main/java/org/bouncycastle/crypto/EncapsulatedSecretExtractor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,11 @@ public interface EncapsulatedSecretExtractor
88
* @param encapsulation the encapsulated secret.
99
*/
1010
byte[] extractSecret(byte[] encapsulation);
11+
12+
/**
13+
* Return the length in bytes of the encapsulation.
14+
*
15+
* @return length in bytes of an encapsulation for this parameter set.
16+
*/
17+
int getEncapsulationLength();
1118
}

core/src/main/java/org/bouncycastle/crypto/kems/ECIESKEMExtractor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,9 @@ public byte[] extractSecret(byte[] encapsulation)
116116

117117
return ECIESKEMGenerator.deriveKey(SingleHashMode, kdf, keyLen, encapsulation, PEH);
118118
}
119+
120+
public int getEncapsulationLength()
121+
{
122+
return (decKey.getParameters().getCurve().getFieldSize() / 8) * 2 + 1;
123+
}
119124
}

core/src/main/java/org/bouncycastle/crypto/kems/RSAKEMExtractor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,9 @@ public byte[] extractSecret(byte[] encapsulation)
5858

5959
return RSAKEMGenerator.generateKey(kdf, n, r, keyLen);
6060
}
61+
62+
public int getEncapsulationLength()
63+
{
64+
return (privKey.getModulus().bitLength() + 7) / 8;
65+
}
6166
}

0 commit comments

Comments
 (0)