Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ path = "../native/build/libs/crypto-native-2.9.0-SNAPSHOT.jar"
[[platform.java21.dependency]]
groupId = "org.bouncycastle"
artifactId = "bcpkix-jdk18on"
version = "1.78"
path = "./lib/bcpkix-jdk18on-1.78.jar"
version = "1.80"
path = "./lib/bcpkix-jdk18on-1.80.jar"

[[platform.java21.dependency]]
groupId = "org.bouncycastle"
artifactId = "bcprov-jdk18on"
version = "1.78"
path = "./lib/bcprov-jdk18on-1.78.jar"
version = "1.80"
path = "./lib/bcprov-jdk18on-1.80.jar"

[[platform.java21.dependency]]
groupId = "org.bouncycastle"
artifactId = "bcutil-jdk18on"
version = "1.78"
path = "./lib/bcutil-jdk18on-1.78.jar"
version = "1.80"
path = "./lib/bcutil-jdk18on-1.80.jar"

[[platform.java21.dependency]]
groupId = "org.bouncycastle"
artifactId = "bcpg-jdk18on"
version = "1.78"
path = "./lib/bcpg-jdk18on-1.78.jar"
version = "1.80"
path = "./lib/bcpg-jdk18on-1.80.jar"
4 changes: 2 additions & 2 deletions ballerina/private_public_key.bal
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public type KeyAlgorithm RSA|MLKEM768|MLDSA65;
public const RSA = "RSA";

# The `ML-KEM-768` algorithm.
public const MLKEM768 = "KYBER768";
public const MLKEM768 = "ML-KEM-768";

# The `ML-DSA-65` algorithm.
public const MLDSA65 = "DILITHIUM3";
public const MLDSA65 = "ML-DSA-65";

# Represents the KeyStore-related configurations.
#
Expand Down
4 changes: 2 additions & 2 deletions ballerina/tests/kem_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ isolated function testEncapsulateMlKem768WithInvalidPublicKey() returns Error? {
PublicKey publicKey = check decodeRsaPublicKeyFromTrustStore(rsaKeyStore, "ballerina");
EncapsulationResult|Error encapsulationResult = encapsulateMlKem768(publicKey);
if encapsulationResult is Error {
test:assertEquals(encapsulationResult.message(), "Error occurred while generating encapsulated key: key generator locked to KYBER768");
test:assertEquals(encapsulationResult.message(), "Error occurred while generating encapsulated key: key generator locked to ML-KEM-768");
} else {
test:assertFail("Expected error not found.");
}
Expand All @@ -63,7 +63,7 @@ isolated function testDecapsulateMlKem768WithInvalidPrivateKey() returns Error?
byte[]|Error sharedSecret = decapsulateMlKem768(encapsulationResult.encapsulatedSecret, privateKey);

if sharedSecret is Error {
test:assertEquals(sharedSecret.message(), "Error occurred while extracting secret: key generator locked to KYBER768");
test:assertEquals(sharedSecret.message(), "Error occurred while extracting secret: key generator locked to ML-KEM-768");
} else {
test:assertFail("Expected error not found.");
}
Expand Down
22 changes: 8 additions & 14 deletions ballerina/tests/private_public_key_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ isolated function testParseEncryptedMlKem768PrivateKeyFromP12() returns Error? {
password: "ballerina"
};
PrivateKey result = check decodeMlKem768PrivateKeyFromKeyStore(keyStore, "mlkem-keypair", "ballerina");
test:assertEquals(result.algorithm, "KYBER768");
test:assertEquals(result.algorithm, "ML-KEM-768");
}

@test:Config {}
Expand All @@ -44,7 +44,7 @@ isolated function testParseEncryptedMlDsa65PrivateKeyFromP12() returns Error? {
password: "ballerina"
};
PrivateKey result = check decodeMlDsa65PrivateKeyFromKeyStore(keyStore, "mldsa-keypair", "ballerina");
test:assertEquals(result.algorithm, "DILITHIUM3");
test:assertEquals(result.algorithm, "ML-DSA-65");
}

@test:Config {}
Expand Down Expand Up @@ -249,7 +249,7 @@ isolated function testParseErrorEcPrivateKeyFromKeyFile() returns Error? {
@test:Config {}
isolated function testParseEncryptedMlDsa65PrivateKeyFromKeyFile() returns Error? {
PrivateKey result = check decodeMlDsa65PrivateKeyFromKeyFile(MLDSA_PRIVATE_KEY_PATH, "ballerina");
test:assertEquals(result.algorithm, "DILITHIUM3");
test:assertEquals(result.algorithm, "ML-DSA-65");
}

@test:Config {}
Expand All @@ -262,12 +262,6 @@ isolated function testParseErrorMlDsa65PrivateKeyFromKeyFile() returns Error? {
}
}

@test:Config {}
isolated function testParseEncryptedMlKem768PrivateKeyFromKeyFile() returns Error? {
PrivateKey result = check decodeMlKem768PrivateKeyFromKeyFile(MLKEM_PRIVATE_KEY_PATH, "ballerina");
test:assertEquals(result.algorithm, "KYBER768");
}

@test:Config {}
isolated function testParseErrorMlKem768PrivateKeyFromKeyFile() returns Error? {
PrivateKey|Error result = decodeMlKem768PrivateKeyFromKeyFile(PRIVATE_KEY_PATH);
Expand Down Expand Up @@ -502,32 +496,32 @@ isolated function testParseEcPublicKeyFromX509CertFile() returns Error? {
@test:Config {}
isolated function testParseMlDsa65PublicKeyFromX509CertFile() returns Error? {
PublicKey publicKey = check decodeMlDsa65PublicKeyFromCertFile(MLDSA_CERT_PATH);
test:assertEquals(publicKey.algorithm, "DILITHIUM3");
test:assertEquals(publicKey.algorithm, "ML-DSA-65");
Certificate certificate = <Certificate>publicKey.certificate;

int serial = certificate.serial;
string issuer = certificate.issuer;
string subject = certificate.subject;
string signingAlgorithm = certificate.signingAlgorithm;

test:assertEquals(serial, 1023822328749742100);
test:assertEquals(serial, 4818446483955774646);
test:assertEquals(issuer, "CN=localhost,OU=WSO2,O=WSO2,L=Mountain View,ST=CA,C=US");
test:assertEquals(subject, "CN=localhost,OU=WSO2,O=WSO2,L=Mountain View,ST=CA,C=US");
test:assertEquals(signingAlgorithm, "DILITHIUM3");
test:assertEquals(signingAlgorithm, "ML-DSA-65");
}

@test:Config {}
isolated function testParseMlKem768PublicKeyFromX509CertFile() returns Error? {
PublicKey publicKey = check decodeMlKem768PublicKeyFromCertFile(MLKEM_CERT_PATH);
test:assertEquals(publicKey.algorithm, "KYBER768");
test:assertEquals(publicKey.algorithm, "ML-KEM-768");
Certificate certificate = <Certificate>publicKey.certificate;

int serial = certificate.serial;
string issuer = certificate.issuer;
string subject = certificate.subject;
string signingAlgorithm = certificate.signingAlgorithm;

test:assertEquals(serial, 749281432);
test:assertEquals(serial, 787519857);
test:assertEquals(issuer, "C=US,ST=CA,L=Mountain View,O=WSO2,OU=WSO2,CN=localhost");
test:assertEquals(subject, "C=US,ST=CA,L=Mountain View,O=WSO2,OU=WSO2,CN=localhost");
test:assertEquals(signingAlgorithm, "SHA256withRSA");
Expand Down
Loading
Loading