zakharovsergey1000 opened a new pull request, #467:

   …yPair() method call.
   The keyPairGenerator object is a bouncycastle implementation of the class. The generateKeyPair method in class 
org.bouncycastle.jcajce.provider.asymmetric.edec.KeyPairGeneratorSpi is not 
thread safe, so calling the generateKeyPair method must be synchronized, 
otherwise calling this method by multiple threads will often cause a 
NullPointerException due to a race conditions.
   Consider the following scenario: two threads simultaneously reach the 
generateKeyPair() method in class 
org.bouncycastle.jcajce.provider.asymmetric.edec.KeyPairGeneratorSpi. Thread 
one performs the if (!initialised) check. The "initialised" variable is false. 
Therefore, the setupGenerator(algorithm) method is executed. In the 
setupGenerator method, the "initialised" variable is assigned true at the very 
beginning. And at this moment, execution of the thread one is suspended and 
execution of the thread two continues. Thread two evaluates the "initialised" 
variable. The variable is true therefore thread two executes the further 
command AsymmetricCipherKeyPair kp = generator.generateKeyPair(); the generator 
is not yet correctly initialized. Thread two continues its execution and 
eventually throws a NullPointerException, which is the result of the generator 
not being initialized correctly because the setupGenerator method was not 
executed to completion even though the initialised vari
 able was already set to true. The callstack looks like this:
   Caused by: java.lang.NullPointerException
   at at 
random, byte[] k) method executes the random.nextBytes(k) instruction. In this 
case, the "random" argument is null, since the setupGenerator(algorithm) method 
was not completed yet. The result is a NullPointerException.

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail:

For queries about this service, please contact Infrastructure at:

To unsubscribe, e-mail:
For additional commands, e-mail:

Reply via email to