Skip to content

Commit

Permalink
Allow changing of data size in ByteContainer.setBytes(byte[], short, …
Browse files Browse the repository at this point in the history
…short).

The motivation for this patch is github-af/SmartPGP#40.

However, this workaround avoids looking at the underlying problem:
ECKeyImpl(byte, short) should not initialize the DomainParameters (according to its own docs), but does.
This leads to problems with NIST P-521 because the default parameter for b has a leading zero bit that gets stripped, leading to a change in data size, when SmartPGP later sets b explicitly with the leading zero bit intact.
  • Loading branch information
hko-s authored and StarGate01 committed Jun 19, 2022
1 parent 35f039f commit ba5bf89
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/com/licel/jcardsim/crypto/ByteContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void setBytes(byte[] buff) {
* @param length length of data in byte array
*/
public void setBytes(byte[] buff, short offset, short length) {
if (data == null) {
if (data == null || this.length != length) {
switch (memoryType) {
case JCSystem.MEMORY_TYPE_TRANSIENT_DESELECT:
data = JCSystem.makeTransientByteArray(length, JCSystem.CLEAR_ON_DESELECT);
Expand Down

0 comments on commit ba5bf89

Please sign in to comment.