forked from I2P_Developers/i2p.i2p
Crypto: Don't start YK thread in app context
This commit is contained in:
@ -40,6 +40,7 @@ import net.i2p.data.PublicKey;
|
|||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
import net.i2p.util.NativeBigInteger;
|
import net.i2p.util.NativeBigInteger;
|
||||||
import net.i2p.util.SimpleByteCache;
|
import net.i2p.util.SimpleByteCache;
|
||||||
|
import net.i2p.util.SystemVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for ElGamal encryption/signature schemes.
|
* Wrapper for ElGamal encryption/signature schemes.
|
||||||
@ -49,6 +50,8 @@ import net.i2p.util.SimpleByteCache;
|
|||||||
* making up the SHA256 of the data, then the data itself. The random byte and
|
* making up the SHA256 of the data, then the data itself. The random byte and
|
||||||
* the SHA256 hash is stripped on decrypt so the original data is returned.
|
* the SHA256 hash is stripped on decrypt so the original data is returned.
|
||||||
*
|
*
|
||||||
|
* Not recommended for new applications.
|
||||||
|
*
|
||||||
* @author thecrypto, jrandom
|
* @author thecrypto, jrandom
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -68,6 +71,7 @@ public final class ElGamalEngine {
|
|||||||
* application context. This constructor should only be used by the
|
* application context. This constructor should only be used by the
|
||||||
* appropriate application context itself.
|
* appropriate application context itself.
|
||||||
*
|
*
|
||||||
|
* Starts the YK precalc thread if context is RouterContext or Android.
|
||||||
*/
|
*/
|
||||||
public ElGamalEngine(I2PAppContext context) {
|
public ElGamalEngine(I2PAppContext context) {
|
||||||
context.statManager().createRateStat("crypto.elGamal.encrypt",
|
context.statManager().createRateStat("crypto.elGamal.encrypt",
|
||||||
@ -79,6 +83,11 @@ public final class ElGamalEngine {
|
|||||||
_context = context;
|
_context = context;
|
||||||
_log = context.logManager().getLog(ElGamalEngine.class);
|
_log = context.logManager().getLog(ElGamalEngine.class);
|
||||||
_ykgen = new YKGenerator(context);
|
_ykgen = new YKGenerator(context);
|
||||||
|
// Don't start the precalc thread for external applications,
|
||||||
|
// benchmarks, or unit tests.
|
||||||
|
// YKgen still works, it just won't precalc.
|
||||||
|
// Known external users are Bote and Syndie.
|
||||||
|
if (context.isRouterContext() || SystemVersion.isAndroid())
|
||||||
_ykgen.start();
|
_ykgen.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user