From b4de0cfaf9893e7a7eee969d519bc50f0b6bab59 Mon Sep 17 00:00:00 2001 From: zzz Date: Sun, 3 May 2020 09:56:21 +0000 Subject: [PATCH] Crypto: Interrupt YK thread when empty --- core/java/src/net/i2p/crypto/YKGenerator.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/java/src/net/i2p/crypto/YKGenerator.java b/core/java/src/net/i2p/crypto/YKGenerator.java index 7a69eee36..d8aaa122d 100644 --- a/core/java/src/net/i2p/crypto/YKGenerator.java +++ b/core/java/src/net/i2p/crypto/YKGenerator.java @@ -126,10 +126,13 @@ final class YKGenerator { if (rv != null) return rv; ctx.statManager().addRateData("crypto.YKEmpty", 1); - return generateYK(); + rv = generateYK(); + if (_precalcThread != null) + _precalcThread.interrupt(); + return rv; } - private final static BigInteger _two = new NativeBigInteger(1, new byte[] { 0x02}); + private final static BigInteger TWO = new NativeBigInteger(1, new byte[] { 0x02}); /** @return rv[0] = Y; rv[1] = K */ private final BigInteger[] generateYK() { @@ -145,7 +148,7 @@ final class YKGenerator { k = null; continue; } - BigInteger kPlus2 = k.add(_two); + BigInteger kPlus2 = k.add(TWO); if (kPlus2.compareTo(CryptoConstants.elgp) > 0) k = null; } //long t2 = Clock.getInstance().now();