SmartPGP/.github/workflows/jcardsim_patches/jcardsim_random_patch
Ryad Benadjila 0b43929a83 Add CI/CD tests using Github Actions.
The tests compile and run the applet in the jcardsim Javacard simulator.
ECDSA signature tests are performed using OpenPGPpy, other tests such as
AES are performed using the local bin/smartpgp-cli script.

TODO: add tests for RSA, asymmetric encryption, pin modifications, secure
messaging (if well supported by jcardsim), etc.
2022-01-10 16:40:35 +01:00

21 lines
1008 B
Plaintext

diff --git a/src/main/java/com/licel/jcardsim/crypto/SecureRandomNullProvider.java b/src/main/java/com/licel/jcardsim/crypto/SecureRandomNullProvider.java
index f4cca44..70d41a3 100644
--- a/src/main/java/com/licel/jcardsim/crypto/SecureRandomNullProvider.java
+++ b/src/main/java/com/licel/jcardsim/crypto/SecureRandomNullProvider.java
@@ -32,7 +32,14 @@ class SecureRandomNullProvider extends SecureRandom {
}
@Override
protected void engineNextBytes(byte[] arg) {
- engine.nextBytes(arg);
+ final String doSecureRandom = System.getProperty("com.licel.jcardsim.randomdata.secure", "0");
+ if ("1".equals(doSecureRandom)){
+ SecureRandom randomGenerator = new SecureRandom();
+ randomGenerator.nextBytes(arg);
+ }
+ else{
+ engine.nextBytes(arg);
+ }
}
@Override
protected byte[] engineGenerateSeed(int len) {