Skip to content
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

Not getting random results #8

Closed
kategray opened this issue Jan 20, 2019 · 2 comments
Closed

Not getting random results #8

kategray opened this issue Jan 20, 2019 · 2 comments

Comments

@kategray
Copy link

The application works fine, however, when running the unit tests, I get the same result each time:

Gradle suite > Gradle test > tests.AppletTest.hello STANDARD_OUT
    Connecting to card... Done.
    --> [00C00000080000000000000000] 13
    <-- 51373E8B6FDEC284DB569204CA13D2CAA23BD1D85DCAB02A0E3D50461E73F1BB 9000 (32)
    ResponseAPDU: 34 bytes, SW=9000

Looking through the source code, I see that random.generateData is generating into tmpBuffer, then copied into the APDU buffer. As this is part of the process() function (which should be executed separately every time the tests are run), shouldn't the output be random? The implementation in jCardSim seems to be based off bouncycastle, so I would expect it to actually be random.

@ph4r05
Copy link
Owner

ph4r05 commented May 19, 2020

The reason is the JCardSim uses a static seed for randomness generated by the RandomData API. I think the main reason is the test reproducibility. One can reseed the generator with another seed.

@ph4r05 ph4r05 closed this as completed May 19, 2020
@ph4r05
Copy link
Owner

ph4r05 commented May 19, 2020

I noticed that you @kategray already addressed this in the issue licel/jcardsim#139 and created a PR licel/jcardsim#141.

I decided to preserve backward compatibility and created another PR licel/jcardsim#155 which is already merged in my fork https://github.com/ph4r05/jcardsim which is published in the maven repo as 3.0.5.11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants