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

Logical Channel Support / pom.xml fix #138

Open
wants to merge 52 commits into
base: master
Choose a base branch
from

Conversation

koh-osug
Copy link

@koh-osug koh-osug commented Jan 16, 2019

  1. I added support for (faked) logical channels.
  2. The build system does not work with a fresh checkout. There is a dependency to oracle.javacard.api:classic as dependency, later the maven-install-plugin is used to install this Java Card API from a environment path. This fails if not both is met. Now a systemPath and system scope is used for the Oracle depdendency.
    3 . I added support for BouncyCastel 1.64. The other version is too old, if used together with other libraries requiring a newer version this is causing ClassCastExceptions or NoSuchMethodExceptions because the BC classes are packaged with the shade plugin.

koh-osug and others added 13 commits December 14, 2021 02:49
- if the System property `com.licel.jcardsim.randomdata.seed` is set, the hex-decoded value of the property is added as a seed material to the RandomData on initialization
- else if the System property `com.licel.jcardsim.randomdata.secure` is set to `1`, the SecureRandom is used to generate 32 random bytes that are added as a seed material to the RandomData
- else the original behavior is preserved to be consistent with previous versions (some tests might rely on the fixed randomness)
This occasionally fails with java.lang.ArrayIndexOutOfBoundsException
when the ECDSA key starts with 0 and the length is trimmed in
setBigInteger() of ByteContainer for the first key pair and the second
one does not fit.

Backtraces collected from OpenSC testsuite were sometimes very
different, but all point to this place:

Error:  testGenerateSecretECDH(com.licel.jcardsim.crypto.KeyAgreementImplTest)  Time elapsed: 0.2 s  <<< ERROR!
java.lang.ArrayIndexOutOfBoundsException
	at java.lang.System.arraycopy(Native Method)
	at javacard.framework.Util.arrayCopy(Unknown Source)
	at com.licel.jcardsim.crypto.ByteContainer.setBytes(ByteContainer.java:122)
	at com.licel.jcardsim.crypto.ByteContainer.setBytes(ByteContainer.java:99)
	at com.licel.jcardsim.crypto.ByteContainer.setBigInteger(ByteContainer.java:87)
	at com.licel.jcardsim.crypto.ECPrivateKeyImpl.setParameters(ECPrivateKeyImpl.java:57)
	at com.licel.jcardsim.crypto.KeyPairImpl.genKeyPair(KeyPairImpl.java:93)
	at javacard.security.KeyPair.genKeyPair(Unknown Source)
	at com.licel.jcardsim.crypto.KeyAgreementImplTest.testGenerateSecret(KeyAgreementImplTest.java:119)
	at com.licel.jcardsim.crypto.KeyAgreementImplTest.testGenerateSecretECDH(KeyAgreementImplTest.java:56)

Error:  Errors:
Error:    com.licel.jcardsim.crypto.KeyAgreementImplTest#testGenerateSecretECDH ArrayIndexOutOfBoundsException

[ERROR] testGenerateSecretDH(com.licel.jcardsim.crypto.KeyAgreementImplTest)  Time elapsed: 0.023 s  <<< ERROR!
java.lang.ArrayIndexOutOfBoundsException
	at java.lang.System.arraycopy(Native Method)
	at javacard.framework.Util.arrayCopy(Unknown Source)
	at com.licel.jcardsim.crypto.ByteContainer.setBytes(ByteContainer.java:122)
	at com.licel.jcardsim.crypto.ByteContainer.setBytes(ByteContainer.java:99)
	at com.licel.jcardsim.crypto.ByteContainer.setBigInteger(ByteContainer.java:90)
	at com.licel.jcardsim.crypto.DHPrivateKeyImpl.setParameters(DHPrivateKeyImpl.java:45)
	at com.licel.jcardsim.crypto.KeyPairImpl.genKeyPair(KeyPairImpl.java:93)
	at javacard.security.KeyPair.genKeyPair(Unknown Source)
	at com.licel.jcardsim.crypto.KeyAgreementImplTest.generateSecretDH(KeyAgreementImplTest.java:86)
	at com.licel.jcardsim.crypto.KeyAgreementImplTest.testGenerateSecretDH(KeyAgreementImplTest.java:71)
Bumps [bcprov-jdk14](https://github.com/bcgit/bc-java) from 1.46 to 1.67.
- [Release notes](https://github.com/bcgit/bc-java/releases)
- [Changelog](https://github.com/bcgit/bc-java/blob/master/docs/releasenotes.html)
- [Commits](https://github.com/bcgit/bc-java/commits)

---
updated-dependencies:
- dependency-name: org.bouncycastle:bcprov-jdk14
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
…ch a known curve

The curve parameters can in any case be set later via the ECKeyImpl.setX().
== APDU
0000:  00 46 00 00  FF 81 28 D3
0008:  5E 47 20 36  BC 4F B7 E1
0010:  3C 78 5E D2  01 E0 65 F9
0018:  8F CF A6 F6  F4 0D EF 4F
0020:  92 B9 EC 78  93 EC 28 FC
0028:  D4 12 B1 F1  B3 2E 27 82
0030:  28 3E E3 0B  56 8F BA B0
0038:  F8 83 CC EB  D4 6D 3F 3B
0040:  B8 A2 A7 35  13 F5 EB 79
0048:  DA 66 19 0E  B0 85 FF A9
0050:  F4 92 F3 75  A9 7D 86 0E
0058:  B4 83 28 52  08 83 94 9D
0060:  FD BC 42 D3  AD 19 86 40
0068:  68 8A 6F E1  3F 41 34 95
0070:  54 B4 9A CC  31 DC CD 88
0078:  45 39 81 6F  5E B4 AC 8F
0080:  B1 F1 A6 84  51 04 43 BD
0088:  7E 9A FB 53  D8 B8 52 89
0090:  BC C4 8E E5  BF E6 F2 01
0098:  37 D1 0A 08  7E B6 E7 87
00A0:  1E 2A 10 A5  99 C7 10 AF
00A8:  8D 0D 39 E2  06 11 14 FD
00B0:  D0 55 45 EC  1C C8 AB 40
00B8:  93 24 7F 77  27 5E 07 43
00C0:  FF ED 11 71  82 EA A9 C7
00C8:  78 77 AA AC  6A C7 D3 52
00D0:  45 D1 69 2E  8E E1 85 28
00D8:  D3 5E 47 20  36 BC 4F B7
00E0:  E1 3C 78 5E  D2 01 E0 65
00E8:  F9 8F CF A5  B6 8F 12 A3
00F0:  2D 48 2E C7  EE 86 58 E9
00F8:  86 91 55 5B  44 C5 93 11
0100:  87 02 00 01  00

java.lang.RuntimeException: Internal reflection error
    at com.licel.jcardsim.base.SimulatorRuntime.resetAPDU(SimulatorRuntime.java:426)
    at com.licel.jcardsim.base.SimulatorRuntime.transmitCommand(SimulatorRuntime.java:301)
    at com.licel.jcardsim.base.Simulator.transmitCommand(Simulator.java:260)
    at com.licel.jcardsim.base.CardManager.dispatchApduImpl(CardManager.java:66)
    at com.licel.jcardsim.base.CardManager.dispatchApdu(CardManager.java:36)
    at com.licel.jcardsim.remote.VSmartCard$IOThread.run(VSmartCard.java:158)
Caused by: java.lang.reflect.InvocationTargetException
    at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at com.licel.jcardsim.base.SimulatorRuntime.resetAPDU(SimulatorRuntime.java:424)
    ... 5 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: arraycopy: last destination index 261 out of bounds for byte[2
    at java.base/java.lang.System.arraycopy(Native Method)
    at javacard.framework.APDU.internalReset(Unknown Source)
    ... 9 more
@koh-osug koh-osug force-pushed the master branch 7 times, most recently from a8f85d0 to dc8a3f5 Compare December 16, 2021 00:30
koh-osug and others added 30 commits December 16, 2021 03:03
…to fix inconsistent module metadata that breaks gradle artifact resolution

>> Could not resolve de.ohmesoftware:jcardsim:3.0.5-2.
>> inconsistent module metadata found. Descriptor: com.licel:jcardsim:3.0.5-2 Errors: bad group: expected='de.ohmesoftware' found='com.licel'
* Update <group.id> in pom.xml from "com.licel" to "de.ohmesoftware"
… and injected more proxy exception classes for javacardx in JavaCardApiProcessor
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

Successfully merging this pull request may close these issues.

7 participants