-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An infinite loop occurs when ED25519 signature verification #1599
Comments
By attaching to process,get function param. |
ScalarUtil.getBitLength(last, p) It seems to keep flipping between the two values p[last]=-1 or 0. ts=2024-03-11 21:59:43; [cost=7.03E-4ms] result=[[10,[-584333345,153520642,-831589256,2107610247,-966692209,14916415,-1902580523,463978880,1487883832,0,0,-1,-1,0,0,-1]],null,null] |
ScalarUtil.addShifted_NP(last, s, Nu, Nv, p); param always like this: |
ScalarUtil.subShifted_NP alway like this: |
@jr981008 Do you have the message, public key, and signature that produce this loop? Thank you! Also, what is "TPS in "When the TPS reaches 10000"? |
tps: indicates that the method is invoked 10000 times per second.The 10000 requests use different public and private key pairs, which are generated using the bc method. |
Key generation function:
|
I will try to get the data from the test environment after reproducing it, seem not hard to reproduce. I guess maybe key pairs trigger some boundary values in some scenarios. I don't see concurrency problem. |
Hi @jr981008, I created the following attempted reproducer: Contents of
|
Thank you for your prompt reply, I'm trying to reproduce and get the content of the messages that are having problems with the public-private key pairs, It's going to take a while.I will try get it as soon as possible. |
Same code verify true without endless loop when using bcpkix-jdk15on. any one help? @dghgit |
It's going to be bcprov that's carrying the Ed25519 implementation. Is this also for 1.74? |
The problem is with version 1.74 @dghgit ,Is there any way to fix it? |
Ah... so bcprov-jdk15on is referring to a much older release isn't it? We're looking into the issue with 1.77 at the moment. |
I've tried all versions from 1.74-1.77 and all of them have the infinite loop problem. Trying version 1.70 just to show that the problem is not always there, it should be in the latest version. |
Resolves: #1599 Signed-off-by: Alexander Scheel <alexander.scheel@keyfactor.com>
There's also an updated release for Java 8 and later on https://www.bouncycastle.org/betas now. |
Thanks @dghgit @cipherboy support.This method is commonly used for identification and authentication, may be a serious security issue. |
Glad to hear it's working, we will get a new release out soon. One last request, in future for anything like this please contact us at feedback-crypto@bouncycastle.org first. With anything likely to be a security issue we're more a fix first, release, then publish kind of organization. |
@jr981008 I'm in the process of filing a CVE report for this one while we're working on the release - would you email us at feedback-crypto@bouncycastle.org and let us know if you wish to be acknowledged for the report and how you would like us to list you. Thanks. |
Hello, we are also seeing this in 1.75. Does this bug affect the LTS version 2.73? We're thinking of moving back to this LTS release. |
Affect 1.71~1.77. |
Arh, ok, thanks. @dghgit Thanks for quickly resolving the above. Looks like we're a couple of weeks behind. Just wondering when your able to get a new 2.73 / 1.78 release out with this fix in? |
@adelel1 April 5th is our planned release date currently. You can use the beta available here: https://downloads.bouncycastle.org/betas/ (note that the build date is incorrect, but the patch is present). The LTS is also affected. |
@cipherboy Thanks for the date. Are they published to a repo we can access? Has the LTS been updated in the beta list? Its still at 2.73.5. Thanks |
I've put up a beta for the LTS release. It may be missing the hardware support, if so I'll deal with it a bit later, it fixes the Ed25519 issue though. It's uploaded to the betas area listed above. |
2.73.6-SNAPSHOT beta has now been updated to include hardware support. |
1.78/1.78.1 is now live (either fixes CVE-2024-30172, but if you're using OSGI on a container running Java 8 or later, use 1.78.1). |
jdk version:1.8.0_382
bc version: bcpkix-jdk18on-1.74
A 20-thread Vertx server processes ED25519 signature verification. When the TPS reaches 10000, an infinite loop occurs. Here is the stack of the problem thread and the code I used.
stack snap:
"vert.x-eventloop-thread-15" Id=176 RUNNABLE
at org.bouncycastle.math.ec.rfc8032.Scalar25519.reduceBasisVar(null:-1)
at org.bouncycastle.math.ec.rfc8032.Ed25519.implVerify(null:-1)
at org.bouncycastle.math.ec.rfc8032.Ed25519.verify(null:-1)
at org.bouncycastle.crypto.params.Ed25519PublicKeyParameters.verify(null:-1)
at org.bouncycastle.crypto.signers.Ed25519Signer$Buffer.verifySignature(null:-1)
at org.bouncycastle.crypto.signers.Ed25519Signer.verifySignature(null:-1)
at org.bouncycastle.jcajce.provider.asymmetric.edec.SignatureSpi.engineVerify(null:-1)
at java.security.Signature$Delegate.engineVerify(Signature.java:1392)
at java.security.Signature.verify(Signature.java:769)
code:
This is an urgent question. We are not familiar with cryptographic algorithms. Thanks for any help.
The text was updated successfully, but these errors were encountered: