The IETF is working on the specification of key formats and algorithm identifiers for using PQ algorithms in X.509 certificates and IETF based protocols like TLS, CMS or S/MIME. Although drafts of key and algorithm identifier specifications already exist they are also subject to change.
Online Javadoc for IAIK-COMPOSITE PROVIDER
Since implemented as JCA Provider, the JCA Signature API can be used for calculating/verfiying composite signatures:
The following example demonsrates key pair generation, signature calculation and signature verification for the MLDSA65-ECDSA-P256-SHA512 signature algorithm:
// generate key pair
KeyPairGenerator kpq = KeyPairGenerator.getInstance("MLDSA65-ECDSA-P256-SHA512", IaikComposite.getInstance());
KeyPair kp = kpq.generateKeyPair();
PublicKey publicKey = kp.getPublic();
PrivateKey privateKey = kp.getPrivate();
// the data to be signed
byte[] data = ...;
// create a Signature engine and initialize it with the private key for signing
Signature signature = Signature.getInstance("MLDSA65-ECDSA-P256-SHA512", IaikComposite.getInstance());
signature.initSign(privateKey);
// update the Signature engine with the data
signature.update(data);
// calculate the signature value
byte[] sigVal = signature.sign();
// create a Signature engine and initialize it with the public key for verification
Signature sigVer = Signature.getInstance("MLDSA65-ECDSA-P256-SHA512", IaikComposite.getInstance());
// initialize the Signature engine for verification
sigVer.initVerify(publicKey);
// update the Signature engine with the data
signVer.update(data);
// verify the signature value
boolean valid = sigVer.verify(sigVal);
In some environments it might be appropriate to calcualte the message digest from the message outside the Signature engine and then let the Signature engine calculate the signature value from the calculated hash value. For that purpose you can use a “raw” (e.g. NONEwithMLDSA65-ECDSA-P256-SHA512) Signature engine:
// generate key pair
KeyPairGenerator kpq = KeyPairGenerator.getInstance("MLDSA65-ECDSA-P256-SHA512", IaikComposite.getInstance());
KeyPair kp = kpq.generateKeyPair();
PublicKey publicKey = kp.getPublic();
PrivateKey privateKey = kp.getPrivate();
// the data to be signed
byte[] data = ...;
// calculate the hash value outside the Signature engine
MessageDigest md = MessageDigest.getInstance("SHA-512");
md.update(data);
byte[] digest = md.digest();
// create a raw Signature engine and initialize it for signing
Signature signature = Signature.getInstance("NONEwithMLDSA65-ECDSA-P256-SHA512", IaikComposite.getInstance());
signature.initSign(privateKey);
// update the Signature engine with the externally calculated digest value
signature.update(digest);
// calculate the signature value
byte[] sigVal = signature.sign();
// create a raw Signature engine and initialize it with the public key for verification
Signature sigVer = Signature.getInstance("NONEwithMLDSA65-ECDSA-P256-SHA512", IaikComposite.getInstance());
// initialize the Signature engine for verification
sigVer.initVerify(publicKey);
// update the Signature engine with the externally calculated digest value
sigVer.update(digest);
// verify the signature value
boolean valid = sigVer.verify(sigVal);
| Class or Package | Bug / Change / New Feature | Description and Examples |
|---|---|---|
| iaik.security.composite.provider | NF | JCA Provider for composite (combination of traditional and quatum resistant) signature algorithms. |
| iaik.security.composite.sig | NF | Signature, KeyPairGenerator and KeyFactory engines for all algorithms specified by https://datatracker.ietf.org/doc/html/draft-ietf-lamps-pq-composite-sigs-19:
|
| Class or Package | Bug / Change / New Feature | Description and Examples |
|---|---|---|
| iaik.security.composite.provider | NF | JCA Provider for composite (combination of traditional and quatum resistant) signature algorithms. |
| iaik.security.composite.sig | NF | Signature, KeyPairGenerator and KeyFactory engines for all algorithms specified by https://datatracker.ietf.org/doc/html/draft-ietf-lamps-pq-composite-sigs-19:
|