Is there already an XMSS/XMSS^MT Provider for Java JCA (Java Cryptography Architecture)?
I was wondering if there are already Providers in the Java Cryptography Architecture (JCA) for post-quantum signature schemes, especially XMSS^MT?
java cryptography post-quantum-cryptography
|
show 2 more comments
I was wondering if there are already Providers in the Java Cryptography Architecture (JCA) for post-quantum signature schemes, especially XMSS^MT?
java cryptography post-quantum-cryptography
See this, this, this and so on. You might next look for third-party providers.
– James K Polk
Nov 22 '18 at 16:37
this, this, this <- no xmss^mt,. no xmss^mt, no xmss^mt..
– Nicolas Brauer
Nov 22 '18 at 16:51
Sorry, maybe a third-party provider. Check Bouncycastle, and there is a German university that I recall has a post-quantum provider ... I'll see what I can find.
– James K Polk
Nov 22 '18 at 16:53
The german one is was thinking of is flexiprovider, but I don't see any evidencee of XMSS support. On the other hand, Bouncycastle has XMSS support so you should give it a try.
– James K Polk
Nov 22 '18 at 16:59
Thank you very much! I found BouncyCastlePQCProvider though I seem to be unable to implement it correctly in the JCA, are you experienced with this ?
– Nicolas Brauer
Nov 22 '18 at 17:08
|
show 2 more comments
I was wondering if there are already Providers in the Java Cryptography Architecture (JCA) for post-quantum signature schemes, especially XMSS^MT?
java cryptography post-quantum-cryptography
I was wondering if there are already Providers in the Java Cryptography Architecture (JCA) for post-quantum signature schemes, especially XMSS^MT?
java cryptography post-quantum-cryptography
java cryptography post-quantum-cryptography
asked Nov 22 '18 at 14:48
Nicolas BrauerNicolas Brauer
387
387
See this, this, this and so on. You might next look for third-party providers.
– James K Polk
Nov 22 '18 at 16:37
this, this, this <- no xmss^mt,. no xmss^mt, no xmss^mt..
– Nicolas Brauer
Nov 22 '18 at 16:51
Sorry, maybe a third-party provider. Check Bouncycastle, and there is a German university that I recall has a post-quantum provider ... I'll see what I can find.
– James K Polk
Nov 22 '18 at 16:53
The german one is was thinking of is flexiprovider, but I don't see any evidencee of XMSS support. On the other hand, Bouncycastle has XMSS support so you should give it a try.
– James K Polk
Nov 22 '18 at 16:59
Thank you very much! I found BouncyCastlePQCProvider though I seem to be unable to implement it correctly in the JCA, are you experienced with this ?
– Nicolas Brauer
Nov 22 '18 at 17:08
|
show 2 more comments
See this, this, this and so on. You might next look for third-party providers.
– James K Polk
Nov 22 '18 at 16:37
this, this, this <- no xmss^mt,. no xmss^mt, no xmss^mt..
– Nicolas Brauer
Nov 22 '18 at 16:51
Sorry, maybe a third-party provider. Check Bouncycastle, and there is a German university that I recall has a post-quantum provider ... I'll see what I can find.
– James K Polk
Nov 22 '18 at 16:53
The german one is was thinking of is flexiprovider, but I don't see any evidencee of XMSS support. On the other hand, Bouncycastle has XMSS support so you should give it a try.
– James K Polk
Nov 22 '18 at 16:59
Thank you very much! I found BouncyCastlePQCProvider though I seem to be unable to implement it correctly in the JCA, are you experienced with this ?
– Nicolas Brauer
Nov 22 '18 at 17:08
See this, this, this and so on. You might next look for third-party providers.
– James K Polk
Nov 22 '18 at 16:37
See this, this, this and so on. You might next look for third-party providers.
– James K Polk
Nov 22 '18 at 16:37
this, this, this <- no xmss^mt,. no xmss^mt, no xmss^mt..
– Nicolas Brauer
Nov 22 '18 at 16:51
this, this, this <- no xmss^mt,. no xmss^mt, no xmss^mt..
– Nicolas Brauer
Nov 22 '18 at 16:51
Sorry, maybe a third-party provider. Check Bouncycastle, and there is a German university that I recall has a post-quantum provider ... I'll see what I can find.
– James K Polk
Nov 22 '18 at 16:53
Sorry, maybe a third-party provider. Check Bouncycastle, and there is a German university that I recall has a post-quantum provider ... I'll see what I can find.
– James K Polk
Nov 22 '18 at 16:53
The german one is was thinking of is flexiprovider, but I don't see any evidencee of XMSS support. On the other hand, Bouncycastle has XMSS support so you should give it a try.
– James K Polk
Nov 22 '18 at 16:59
The german one is was thinking of is flexiprovider, but I don't see any evidencee of XMSS support. On the other hand, Bouncycastle has XMSS support so you should give it a try.
– James K Polk
Nov 22 '18 at 16:59
Thank you very much! I found BouncyCastlePQCProvider though I seem to be unable to implement it correctly in the JCA, are you experienced with this ?
– Nicolas Brauer
Nov 22 '18 at 17:08
Thank you very much! I found BouncyCastlePQCProvider though I seem to be unable to implement it correctly in the JCA, are you experienced with this ?
– Nicolas Brauer
Nov 22 '18 at 17:08
|
show 2 more comments
1 Answer
1
active
oldest
votes
Here is an example taken almost verbatim from the Bouncycastle source code in org.bouncycastle.pqc.jcajce.provider.test.XMSSMTTest
. This code was run on Java 8.
import org.bouncycastle.pqc.jcajce.interfaces.StateAwareSignature;
import org.bouncycastle.pqc.jcajce.provider.BouncyCastlePQCProvider;
import org.bouncycastle.pqc.jcajce.spec.XMSSMTParameterSpec;
import org.bouncycastle.util.Strings;
import java.security.*;
public class Main {
private static void fail(boolean condition, String msg) {
if (condition) {
throw new RuntimeException(msg);
}
}
public static void main(String args) throws Exception {
Security.addProvider(new BouncyCastlePQCProvider());
byte msg = Strings.toByteArray("Cthulhu Fthagn --What a wonderful phrase!Cthulhu Fthagn --Say it and you're crazed!");
KeyPairGenerator kpg = KeyPairGenerator.getInstance("XMSSMT", "BCPQC");
kpg.initialize(new XMSSMTParameterSpec(20, 10, XMSSMTParameterSpec.SHA256), new SecureRandom());
KeyPair kp = kpg.generateKeyPair();
Signature sig = Signature.getInstance("SHA256withXMSSMT", "BCPQC");
fail(!(sig instanceof StateAwareSignature), "wrong signature instance");
StateAwareSignature xmssSig = (StateAwareSignature) sig;
xmssSig.initSign(kp.getPrivate());
fail(!xmssSig.isSigningCapable(), "signature object is not signing-capable");
xmssSig.update(msg, 0, msg.length);
byte s = sig.sign();
PrivateKey nKey = xmssSig.getUpdatedPrivateKey();
fail(kp.getPrivate().equals(nKey), "");
fail(xmssSig.isSigningCapable(), "signature object is signing-capable");
xmssSig.update(msg, 0, msg.length);
try {
sig.sign();
fail(true, "no exception after key extraction");
} catch (SignatureException e) {
fail(!"signing key no longer usable".equals(e.getMessage()), "wrong exception");
}
try {
xmssSig.getUpdatedPrivateKey();
fail(true, "no exception after key extraction");
} catch (IllegalStateException e) {
fail(!"signature object not in a signing state".equals(e.getMessage()), "wrong exception");
}
xmssSig.initSign(nKey);
xmssSig.update(msg, 0, msg.length);
s = sig.sign();
xmssSig.initVerify(kp.getPublic());
xmssSig.update(msg, 0, msg.length);
fail(!xmssSig.verify(s), "verification failure");
}
}
There are other examples in that file as well. Source code is available here.
Thank you very much James, when I try to implement the BouncyCastlePQCProvider to the JCA like described here under Step 8, it does not get recognized.keytool -genkeypair -alias <alias> -keyalg xmss
prompts:no such algorithm exeption
which means the BCProvider does not get recognized (as it clearly does provide the xmss alg for keygen). As you did already help me a lot, might you have an idea for this as well ? ^^
– Nicolas Brauer
Nov 22 '18 at 20:41
@NicolasBrauer: is the provider configured in your JRE/lib/security/java.security or j9+ JRE/conf/security/java.security and is the jar findable (through j8 JRE/lib/ext is good)? (If the first part is true your code wouldn't need the Security.addProvider call. Remember BouncyCastlePQCProvider and BouncyCastleProvider are different.)
– dave_thompson_085
Nov 22 '18 at 22:29
Those instructions are for building and signing your own provider. Leave those java.security files alone. Bouncycastle has already gotten their provider jar properly signed, just place thebcprov-jdk15on-160.jar
file on your classpath and add the provider as in the example.
– James K Polk
Nov 22 '18 at 22:58
@dave_thompson_085 thank you but as of java9(or even 8 i dont know)extensions mechanism are no longer supported; Use -classpath instead.
@JamesKPolk thank you very much this helps a lot, though i will not be able to add the provider as in the example as I don't intend using it to write java code but only to use jarsigner with it through command line interface. So how would I add it statically? (as the example is used to add it dynamically)
– Nicolas Brauer
Nov 23 '18 at 8:53
1
On checking, keytool and jarsigner don't use the normal classpath, so you also need-providerpath jarfile
to find the provider. However, it appears keytool only uses the init(int) overload and XMSSKeyPairGeneratorSpi rejects that; it wants AlgorithmParameterSpec specifically XMSSParameterSpec, or no init at all -- and if I try the latter, it does generates a keypair, but the resulting keys can't be encoded and thus can't be stored. Bleah. I think you'll have to code the generation. I haven't looked at the signature side yet.
– dave_thompson_085
Nov 24 '18 at 23:48
|
show 3 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53433436%2fis-there-already-an-xmss-xmssmt-provider-for-java-jca-java-cryptography-archit%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here is an example taken almost verbatim from the Bouncycastle source code in org.bouncycastle.pqc.jcajce.provider.test.XMSSMTTest
. This code was run on Java 8.
import org.bouncycastle.pqc.jcajce.interfaces.StateAwareSignature;
import org.bouncycastle.pqc.jcajce.provider.BouncyCastlePQCProvider;
import org.bouncycastle.pqc.jcajce.spec.XMSSMTParameterSpec;
import org.bouncycastle.util.Strings;
import java.security.*;
public class Main {
private static void fail(boolean condition, String msg) {
if (condition) {
throw new RuntimeException(msg);
}
}
public static void main(String args) throws Exception {
Security.addProvider(new BouncyCastlePQCProvider());
byte msg = Strings.toByteArray("Cthulhu Fthagn --What a wonderful phrase!Cthulhu Fthagn --Say it and you're crazed!");
KeyPairGenerator kpg = KeyPairGenerator.getInstance("XMSSMT", "BCPQC");
kpg.initialize(new XMSSMTParameterSpec(20, 10, XMSSMTParameterSpec.SHA256), new SecureRandom());
KeyPair kp = kpg.generateKeyPair();
Signature sig = Signature.getInstance("SHA256withXMSSMT", "BCPQC");
fail(!(sig instanceof StateAwareSignature), "wrong signature instance");
StateAwareSignature xmssSig = (StateAwareSignature) sig;
xmssSig.initSign(kp.getPrivate());
fail(!xmssSig.isSigningCapable(), "signature object is not signing-capable");
xmssSig.update(msg, 0, msg.length);
byte s = sig.sign();
PrivateKey nKey = xmssSig.getUpdatedPrivateKey();
fail(kp.getPrivate().equals(nKey), "");
fail(xmssSig.isSigningCapable(), "signature object is signing-capable");
xmssSig.update(msg, 0, msg.length);
try {
sig.sign();
fail(true, "no exception after key extraction");
} catch (SignatureException e) {
fail(!"signing key no longer usable".equals(e.getMessage()), "wrong exception");
}
try {
xmssSig.getUpdatedPrivateKey();
fail(true, "no exception after key extraction");
} catch (IllegalStateException e) {
fail(!"signature object not in a signing state".equals(e.getMessage()), "wrong exception");
}
xmssSig.initSign(nKey);
xmssSig.update(msg, 0, msg.length);
s = sig.sign();
xmssSig.initVerify(kp.getPublic());
xmssSig.update(msg, 0, msg.length);
fail(!xmssSig.verify(s), "verification failure");
}
}
There are other examples in that file as well. Source code is available here.
Thank you very much James, when I try to implement the BouncyCastlePQCProvider to the JCA like described here under Step 8, it does not get recognized.keytool -genkeypair -alias <alias> -keyalg xmss
prompts:no such algorithm exeption
which means the BCProvider does not get recognized (as it clearly does provide the xmss alg for keygen). As you did already help me a lot, might you have an idea for this as well ? ^^
– Nicolas Brauer
Nov 22 '18 at 20:41
@NicolasBrauer: is the provider configured in your JRE/lib/security/java.security or j9+ JRE/conf/security/java.security and is the jar findable (through j8 JRE/lib/ext is good)? (If the first part is true your code wouldn't need the Security.addProvider call. Remember BouncyCastlePQCProvider and BouncyCastleProvider are different.)
– dave_thompson_085
Nov 22 '18 at 22:29
Those instructions are for building and signing your own provider. Leave those java.security files alone. Bouncycastle has already gotten their provider jar properly signed, just place thebcprov-jdk15on-160.jar
file on your classpath and add the provider as in the example.
– James K Polk
Nov 22 '18 at 22:58
@dave_thompson_085 thank you but as of java9(or even 8 i dont know)extensions mechanism are no longer supported; Use -classpath instead.
@JamesKPolk thank you very much this helps a lot, though i will not be able to add the provider as in the example as I don't intend using it to write java code but only to use jarsigner with it through command line interface. So how would I add it statically? (as the example is used to add it dynamically)
– Nicolas Brauer
Nov 23 '18 at 8:53
1
On checking, keytool and jarsigner don't use the normal classpath, so you also need-providerpath jarfile
to find the provider. However, it appears keytool only uses the init(int) overload and XMSSKeyPairGeneratorSpi rejects that; it wants AlgorithmParameterSpec specifically XMSSParameterSpec, or no init at all -- and if I try the latter, it does generates a keypair, but the resulting keys can't be encoded and thus can't be stored. Bleah. I think you'll have to code the generation. I haven't looked at the signature side yet.
– dave_thompson_085
Nov 24 '18 at 23:48
|
show 3 more comments
Here is an example taken almost verbatim from the Bouncycastle source code in org.bouncycastle.pqc.jcajce.provider.test.XMSSMTTest
. This code was run on Java 8.
import org.bouncycastle.pqc.jcajce.interfaces.StateAwareSignature;
import org.bouncycastle.pqc.jcajce.provider.BouncyCastlePQCProvider;
import org.bouncycastle.pqc.jcajce.spec.XMSSMTParameterSpec;
import org.bouncycastle.util.Strings;
import java.security.*;
public class Main {
private static void fail(boolean condition, String msg) {
if (condition) {
throw new RuntimeException(msg);
}
}
public static void main(String args) throws Exception {
Security.addProvider(new BouncyCastlePQCProvider());
byte msg = Strings.toByteArray("Cthulhu Fthagn --What a wonderful phrase!Cthulhu Fthagn --Say it and you're crazed!");
KeyPairGenerator kpg = KeyPairGenerator.getInstance("XMSSMT", "BCPQC");
kpg.initialize(new XMSSMTParameterSpec(20, 10, XMSSMTParameterSpec.SHA256), new SecureRandom());
KeyPair kp = kpg.generateKeyPair();
Signature sig = Signature.getInstance("SHA256withXMSSMT", "BCPQC");
fail(!(sig instanceof StateAwareSignature), "wrong signature instance");
StateAwareSignature xmssSig = (StateAwareSignature) sig;
xmssSig.initSign(kp.getPrivate());
fail(!xmssSig.isSigningCapable(), "signature object is not signing-capable");
xmssSig.update(msg, 0, msg.length);
byte s = sig.sign();
PrivateKey nKey = xmssSig.getUpdatedPrivateKey();
fail(kp.getPrivate().equals(nKey), "");
fail(xmssSig.isSigningCapable(), "signature object is signing-capable");
xmssSig.update(msg, 0, msg.length);
try {
sig.sign();
fail(true, "no exception after key extraction");
} catch (SignatureException e) {
fail(!"signing key no longer usable".equals(e.getMessage()), "wrong exception");
}
try {
xmssSig.getUpdatedPrivateKey();
fail(true, "no exception after key extraction");
} catch (IllegalStateException e) {
fail(!"signature object not in a signing state".equals(e.getMessage()), "wrong exception");
}
xmssSig.initSign(nKey);
xmssSig.update(msg, 0, msg.length);
s = sig.sign();
xmssSig.initVerify(kp.getPublic());
xmssSig.update(msg, 0, msg.length);
fail(!xmssSig.verify(s), "verification failure");
}
}
There are other examples in that file as well. Source code is available here.
Thank you very much James, when I try to implement the BouncyCastlePQCProvider to the JCA like described here under Step 8, it does not get recognized.keytool -genkeypair -alias <alias> -keyalg xmss
prompts:no such algorithm exeption
which means the BCProvider does not get recognized (as it clearly does provide the xmss alg for keygen). As you did already help me a lot, might you have an idea for this as well ? ^^
– Nicolas Brauer
Nov 22 '18 at 20:41
@NicolasBrauer: is the provider configured in your JRE/lib/security/java.security or j9+ JRE/conf/security/java.security and is the jar findable (through j8 JRE/lib/ext is good)? (If the first part is true your code wouldn't need the Security.addProvider call. Remember BouncyCastlePQCProvider and BouncyCastleProvider are different.)
– dave_thompson_085
Nov 22 '18 at 22:29
Those instructions are for building and signing your own provider. Leave those java.security files alone. Bouncycastle has already gotten their provider jar properly signed, just place thebcprov-jdk15on-160.jar
file on your classpath and add the provider as in the example.
– James K Polk
Nov 22 '18 at 22:58
@dave_thompson_085 thank you but as of java9(or even 8 i dont know)extensions mechanism are no longer supported; Use -classpath instead.
@JamesKPolk thank you very much this helps a lot, though i will not be able to add the provider as in the example as I don't intend using it to write java code but only to use jarsigner with it through command line interface. So how would I add it statically? (as the example is used to add it dynamically)
– Nicolas Brauer
Nov 23 '18 at 8:53
1
On checking, keytool and jarsigner don't use the normal classpath, so you also need-providerpath jarfile
to find the provider. However, it appears keytool only uses the init(int) overload and XMSSKeyPairGeneratorSpi rejects that; it wants AlgorithmParameterSpec specifically XMSSParameterSpec, or no init at all -- and if I try the latter, it does generates a keypair, but the resulting keys can't be encoded and thus can't be stored. Bleah. I think you'll have to code the generation. I haven't looked at the signature side yet.
– dave_thompson_085
Nov 24 '18 at 23:48
|
show 3 more comments
Here is an example taken almost verbatim from the Bouncycastle source code in org.bouncycastle.pqc.jcajce.provider.test.XMSSMTTest
. This code was run on Java 8.
import org.bouncycastle.pqc.jcajce.interfaces.StateAwareSignature;
import org.bouncycastle.pqc.jcajce.provider.BouncyCastlePQCProvider;
import org.bouncycastle.pqc.jcajce.spec.XMSSMTParameterSpec;
import org.bouncycastle.util.Strings;
import java.security.*;
public class Main {
private static void fail(boolean condition, String msg) {
if (condition) {
throw new RuntimeException(msg);
}
}
public static void main(String args) throws Exception {
Security.addProvider(new BouncyCastlePQCProvider());
byte msg = Strings.toByteArray("Cthulhu Fthagn --What a wonderful phrase!Cthulhu Fthagn --Say it and you're crazed!");
KeyPairGenerator kpg = KeyPairGenerator.getInstance("XMSSMT", "BCPQC");
kpg.initialize(new XMSSMTParameterSpec(20, 10, XMSSMTParameterSpec.SHA256), new SecureRandom());
KeyPair kp = kpg.generateKeyPair();
Signature sig = Signature.getInstance("SHA256withXMSSMT", "BCPQC");
fail(!(sig instanceof StateAwareSignature), "wrong signature instance");
StateAwareSignature xmssSig = (StateAwareSignature) sig;
xmssSig.initSign(kp.getPrivate());
fail(!xmssSig.isSigningCapable(), "signature object is not signing-capable");
xmssSig.update(msg, 0, msg.length);
byte s = sig.sign();
PrivateKey nKey = xmssSig.getUpdatedPrivateKey();
fail(kp.getPrivate().equals(nKey), "");
fail(xmssSig.isSigningCapable(), "signature object is signing-capable");
xmssSig.update(msg, 0, msg.length);
try {
sig.sign();
fail(true, "no exception after key extraction");
} catch (SignatureException e) {
fail(!"signing key no longer usable".equals(e.getMessage()), "wrong exception");
}
try {
xmssSig.getUpdatedPrivateKey();
fail(true, "no exception after key extraction");
} catch (IllegalStateException e) {
fail(!"signature object not in a signing state".equals(e.getMessage()), "wrong exception");
}
xmssSig.initSign(nKey);
xmssSig.update(msg, 0, msg.length);
s = sig.sign();
xmssSig.initVerify(kp.getPublic());
xmssSig.update(msg, 0, msg.length);
fail(!xmssSig.verify(s), "verification failure");
}
}
There are other examples in that file as well. Source code is available here.
Here is an example taken almost verbatim from the Bouncycastle source code in org.bouncycastle.pqc.jcajce.provider.test.XMSSMTTest
. This code was run on Java 8.
import org.bouncycastle.pqc.jcajce.interfaces.StateAwareSignature;
import org.bouncycastle.pqc.jcajce.provider.BouncyCastlePQCProvider;
import org.bouncycastle.pqc.jcajce.spec.XMSSMTParameterSpec;
import org.bouncycastle.util.Strings;
import java.security.*;
public class Main {
private static void fail(boolean condition, String msg) {
if (condition) {
throw new RuntimeException(msg);
}
}
public static void main(String args) throws Exception {
Security.addProvider(new BouncyCastlePQCProvider());
byte msg = Strings.toByteArray("Cthulhu Fthagn --What a wonderful phrase!Cthulhu Fthagn --Say it and you're crazed!");
KeyPairGenerator kpg = KeyPairGenerator.getInstance("XMSSMT", "BCPQC");
kpg.initialize(new XMSSMTParameterSpec(20, 10, XMSSMTParameterSpec.SHA256), new SecureRandom());
KeyPair kp = kpg.generateKeyPair();
Signature sig = Signature.getInstance("SHA256withXMSSMT", "BCPQC");
fail(!(sig instanceof StateAwareSignature), "wrong signature instance");
StateAwareSignature xmssSig = (StateAwareSignature) sig;
xmssSig.initSign(kp.getPrivate());
fail(!xmssSig.isSigningCapable(), "signature object is not signing-capable");
xmssSig.update(msg, 0, msg.length);
byte s = sig.sign();
PrivateKey nKey = xmssSig.getUpdatedPrivateKey();
fail(kp.getPrivate().equals(nKey), "");
fail(xmssSig.isSigningCapable(), "signature object is signing-capable");
xmssSig.update(msg, 0, msg.length);
try {
sig.sign();
fail(true, "no exception after key extraction");
} catch (SignatureException e) {
fail(!"signing key no longer usable".equals(e.getMessage()), "wrong exception");
}
try {
xmssSig.getUpdatedPrivateKey();
fail(true, "no exception after key extraction");
} catch (IllegalStateException e) {
fail(!"signature object not in a signing state".equals(e.getMessage()), "wrong exception");
}
xmssSig.initSign(nKey);
xmssSig.update(msg, 0, msg.length);
s = sig.sign();
xmssSig.initVerify(kp.getPublic());
xmssSig.update(msg, 0, msg.length);
fail(!xmssSig.verify(s), "verification failure");
}
}
There are other examples in that file as well. Source code is available here.
edited Nov 22 '18 at 22:53
answered Nov 22 '18 at 20:15
James K PolkJames K Polk
30k116896
30k116896
Thank you very much James, when I try to implement the BouncyCastlePQCProvider to the JCA like described here under Step 8, it does not get recognized.keytool -genkeypair -alias <alias> -keyalg xmss
prompts:no such algorithm exeption
which means the BCProvider does not get recognized (as it clearly does provide the xmss alg for keygen). As you did already help me a lot, might you have an idea for this as well ? ^^
– Nicolas Brauer
Nov 22 '18 at 20:41
@NicolasBrauer: is the provider configured in your JRE/lib/security/java.security or j9+ JRE/conf/security/java.security and is the jar findable (through j8 JRE/lib/ext is good)? (If the first part is true your code wouldn't need the Security.addProvider call. Remember BouncyCastlePQCProvider and BouncyCastleProvider are different.)
– dave_thompson_085
Nov 22 '18 at 22:29
Those instructions are for building and signing your own provider. Leave those java.security files alone. Bouncycastle has already gotten their provider jar properly signed, just place thebcprov-jdk15on-160.jar
file on your classpath and add the provider as in the example.
– James K Polk
Nov 22 '18 at 22:58
@dave_thompson_085 thank you but as of java9(or even 8 i dont know)extensions mechanism are no longer supported; Use -classpath instead.
@JamesKPolk thank you very much this helps a lot, though i will not be able to add the provider as in the example as I don't intend using it to write java code but only to use jarsigner with it through command line interface. So how would I add it statically? (as the example is used to add it dynamically)
– Nicolas Brauer
Nov 23 '18 at 8:53
1
On checking, keytool and jarsigner don't use the normal classpath, so you also need-providerpath jarfile
to find the provider. However, it appears keytool only uses the init(int) overload and XMSSKeyPairGeneratorSpi rejects that; it wants AlgorithmParameterSpec specifically XMSSParameterSpec, or no init at all -- and if I try the latter, it does generates a keypair, but the resulting keys can't be encoded and thus can't be stored. Bleah. I think you'll have to code the generation. I haven't looked at the signature side yet.
– dave_thompson_085
Nov 24 '18 at 23:48
|
show 3 more comments
Thank you very much James, when I try to implement the BouncyCastlePQCProvider to the JCA like described here under Step 8, it does not get recognized.keytool -genkeypair -alias <alias> -keyalg xmss
prompts:no such algorithm exeption
which means the BCProvider does not get recognized (as it clearly does provide the xmss alg for keygen). As you did already help me a lot, might you have an idea for this as well ? ^^
– Nicolas Brauer
Nov 22 '18 at 20:41
@NicolasBrauer: is the provider configured in your JRE/lib/security/java.security or j9+ JRE/conf/security/java.security and is the jar findable (through j8 JRE/lib/ext is good)? (If the first part is true your code wouldn't need the Security.addProvider call. Remember BouncyCastlePQCProvider and BouncyCastleProvider are different.)
– dave_thompson_085
Nov 22 '18 at 22:29
Those instructions are for building and signing your own provider. Leave those java.security files alone. Bouncycastle has already gotten their provider jar properly signed, just place thebcprov-jdk15on-160.jar
file on your classpath and add the provider as in the example.
– James K Polk
Nov 22 '18 at 22:58
@dave_thompson_085 thank you but as of java9(or even 8 i dont know)extensions mechanism are no longer supported; Use -classpath instead.
@JamesKPolk thank you very much this helps a lot, though i will not be able to add the provider as in the example as I don't intend using it to write java code but only to use jarsigner with it through command line interface. So how would I add it statically? (as the example is used to add it dynamically)
– Nicolas Brauer
Nov 23 '18 at 8:53
1
On checking, keytool and jarsigner don't use the normal classpath, so you also need-providerpath jarfile
to find the provider. However, it appears keytool only uses the init(int) overload and XMSSKeyPairGeneratorSpi rejects that; it wants AlgorithmParameterSpec specifically XMSSParameterSpec, or no init at all -- and if I try the latter, it does generates a keypair, but the resulting keys can't be encoded and thus can't be stored. Bleah. I think you'll have to code the generation. I haven't looked at the signature side yet.
– dave_thompson_085
Nov 24 '18 at 23:48
Thank you very much James, when I try to implement the BouncyCastlePQCProvider to the JCA like described here under Step 8, it does not get recognized.
keytool -genkeypair -alias <alias> -keyalg xmss
prompts: no such algorithm exeption
which means the BCProvider does not get recognized (as it clearly does provide the xmss alg for keygen). As you did already help me a lot, might you have an idea for this as well ? ^^– Nicolas Brauer
Nov 22 '18 at 20:41
Thank you very much James, when I try to implement the BouncyCastlePQCProvider to the JCA like described here under Step 8, it does not get recognized.
keytool -genkeypair -alias <alias> -keyalg xmss
prompts: no such algorithm exeption
which means the BCProvider does not get recognized (as it clearly does provide the xmss alg for keygen). As you did already help me a lot, might you have an idea for this as well ? ^^– Nicolas Brauer
Nov 22 '18 at 20:41
@NicolasBrauer: is the provider configured in your JRE/lib/security/java.security or j9+ JRE/conf/security/java.security and is the jar findable (through j8 JRE/lib/ext is good)? (If the first part is true your code wouldn't need the Security.addProvider call. Remember BouncyCastlePQCProvider and BouncyCastleProvider are different.)
– dave_thompson_085
Nov 22 '18 at 22:29
@NicolasBrauer: is the provider configured in your JRE/lib/security/java.security or j9+ JRE/conf/security/java.security and is the jar findable (through j8 JRE/lib/ext is good)? (If the first part is true your code wouldn't need the Security.addProvider call. Remember BouncyCastlePQCProvider and BouncyCastleProvider are different.)
– dave_thompson_085
Nov 22 '18 at 22:29
Those instructions are for building and signing your own provider. Leave those java.security files alone. Bouncycastle has already gotten their provider jar properly signed, just place the
bcprov-jdk15on-160.jar
file on your classpath and add the provider as in the example.– James K Polk
Nov 22 '18 at 22:58
Those instructions are for building and signing your own provider. Leave those java.security files alone. Bouncycastle has already gotten their provider jar properly signed, just place the
bcprov-jdk15on-160.jar
file on your classpath and add the provider as in the example.– James K Polk
Nov 22 '18 at 22:58
@dave_thompson_085 thank you but as of java9(or even 8 i dont know)
extensions mechanism are no longer supported; Use -classpath instead.
@JamesKPolk thank you very much this helps a lot, though i will not be able to add the provider as in the example as I don't intend using it to write java code but only to use jarsigner with it through command line interface. So how would I add it statically? (as the example is used to add it dynamically)– Nicolas Brauer
Nov 23 '18 at 8:53
@dave_thompson_085 thank you but as of java9(or even 8 i dont know)
extensions mechanism are no longer supported; Use -classpath instead.
@JamesKPolk thank you very much this helps a lot, though i will not be able to add the provider as in the example as I don't intend using it to write java code but only to use jarsigner with it through command line interface. So how would I add it statically? (as the example is used to add it dynamically)– Nicolas Brauer
Nov 23 '18 at 8:53
1
1
On checking, keytool and jarsigner don't use the normal classpath, so you also need
-providerpath jarfile
to find the provider. However, it appears keytool only uses the init(int) overload and XMSSKeyPairGeneratorSpi rejects that; it wants AlgorithmParameterSpec specifically XMSSParameterSpec, or no init at all -- and if I try the latter, it does generates a keypair, but the resulting keys can't be encoded and thus can't be stored. Bleah. I think you'll have to code the generation. I haven't looked at the signature side yet.– dave_thompson_085
Nov 24 '18 at 23:48
On checking, keytool and jarsigner don't use the normal classpath, so you also need
-providerpath jarfile
to find the provider. However, it appears keytool only uses the init(int) overload and XMSSKeyPairGeneratorSpi rejects that; it wants AlgorithmParameterSpec specifically XMSSParameterSpec, or no init at all -- and if I try the latter, it does generates a keypair, but the resulting keys can't be encoded and thus can't be stored. Bleah. I think you'll have to code the generation. I haven't looked at the signature side yet.– dave_thompson_085
Nov 24 '18 at 23:48
|
show 3 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53433436%2fis-there-already-an-xmss-xmssmt-provider-for-java-jca-java-cryptography-archit%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
See this, this, this and so on. You might next look for third-party providers.
– James K Polk
Nov 22 '18 at 16:37
this, this, this <- no xmss^mt,. no xmss^mt, no xmss^mt..
– Nicolas Brauer
Nov 22 '18 at 16:51
Sorry, maybe a third-party provider. Check Bouncycastle, and there is a German university that I recall has a post-quantum provider ... I'll see what I can find.
– James K Polk
Nov 22 '18 at 16:53
The german one is was thinking of is flexiprovider, but I don't see any evidencee of XMSS support. On the other hand, Bouncycastle has XMSS support so you should give it a try.
– James K Polk
Nov 22 '18 at 16:59
Thank you very much! I found BouncyCastlePQCProvider though I seem to be unable to implement it correctly in the JCA, are you experienced with this ?
– Nicolas Brauer
Nov 22 '18 at 17:08