Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
java=26-amzn
gradle=9.5.0

gradle=9.5.1
11 changes: 9 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ subprojects {
'https://oss.sonatype.org/content/repositories/snapshots/' :
'https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/'
configurations.implementation.transitive = true
javadoc.failOnError = false
javadoc.failOnError = true

java {
sourceCompatibility = JavaVersion.VERSION_25
Expand Down Expand Up @@ -183,7 +183,14 @@ task aggregatedJavadoc (type: Javadoc, description: "Aggregated Javadocs") {
destinationDir = new File(buildDir, 'docs/javadoc')
classpath = files(subprojects.collect {project ->
project.sourceSets.main.compileClasspath})
failOnError = false
failOnError = true
configure(options) {
tags(
'apiNote:a:API Note:',
'implSpec:a:Implementation Requirements:',
'implNote:a:Implementation Note:'
)
}
}


Expand Down
3 changes: 1 addition & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jdom = "2.0.6.1"
sleepycatje = "18.3.12"
commonscli = "1.11.0"
commonslang3 = "3.20.0"
jline = "4.0.14"
jline = "4.1.0"
jna = '5.18.1'
jansi = '2.4.3'
beanshell = "2.0b6"
Expand Down Expand Up @@ -49,4 +49,3 @@ jacksonDataBind = { module = 'com.fasterxml.jackson.core:jackson-databind', vers
jacksonDataTypeJSR310 = { module = 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310', version.ref = 'jackson' }
jacksonDataFormatXML = { module = 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml', version.ref = 'jackson' }
mapdb = { module = "org.mapdb:mapdb", version.ref = "mapdb" }

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
Expand Down
18 changes: 18 additions & 0 deletions jpos/src/main/java/org/jpos/security/EMVCAPublicKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,40 @@ public record EMVCAPublicKey(byte[] rid, byte index, byte[] modulus,
byte[] exponent, byte hashAlgorithmIndicator,
byte publicKeyAlgorithmIndicator) {

/**
* Creates an EMV CA public key and defensively copies array components.
*/
public EMVCAPublicKey {
rid = copy(rid);
modulus = copy(modulus);
exponent = copy(exponent);
}

/**
* Returns a defensive copy of the RID.
*
* @return the Registered Application Provider Identifier
*/
@Override
public byte[] rid() {
return copy(rid);
}

/**
* Returns a defensive copy of the RSA modulus.
*
* @return the RSA modulus
*/
@Override
public byte[] modulus() {
return copy(modulus);
}

/**
* Returns a defensive copy of the RSA public exponent.
*
* @return the RSA public exponent
*/
@Override
public byte[] exponent() {
return copy(exponent);
Expand Down
8 changes: 8 additions & 0 deletions jpos/src/main/java/org/jpos/security/EMVCDAResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,18 @@
*/
public record EMVCDAResult(byte[] iccDynamicNumber, byte cid) {

/**
* Creates a CDA result and defensively copies array components.
*/
public EMVCDAResult {
iccDynamicNumber = copy(iccDynamicNumber);
}

/**
* Returns a defensive copy of the ICC dynamic number.
*
* @return the ICC dynamic number
*/
@Override
public byte[] iccDynamicNumber() {
return copy(iccDynamicNumber);
Expand Down
8 changes: 8 additions & 0 deletions jpos/src/main/java/org/jpos/security/EMVDerivedKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,18 @@
*/
public record EMVDerivedKey<T>(T key, byte[] kcv) {

/**
* Creates a derived-key result and defensively copies array components.
*/
public EMVDerivedKey {
kcv = copy(kcv);
}

/**
* Returns a defensive copy of the Key Check Value.
*
* @return the Key Check Value
*/
@Override
public byte[] kcv() {
return copy(kcv);
Expand Down
28 changes: 28 additions & 0 deletions jpos/src/main/java/org/jpos/security/EMVICCPublicKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public record EMVICCPublicKey(byte[] applicationPan, byte[] expirationDate,
byte[] exponent, byte hashAlgorithmIndicator,
byte publicKeyAlgorithmIndicator) {

/**
* Creates an EMV ICC public key and defensively copies array components.
*/
public EMVICCPublicKey {
applicationPan = copy(applicationPan);
expirationDate = copy(expirationDate);
Expand All @@ -65,26 +68,51 @@ public record EMVICCPublicKey(byte[] applicationPan, byte[] expirationDate,
exponent = copy(exponent);
}

/**
* Returns a defensive copy of the application PAN.
*
* @return the application PAN
*/
@Override
public byte[] applicationPan() {
return copy(applicationPan);
}

/**
* Returns a defensive copy of the certificate expiration date.
*
* @return the expiration date
*/
@Override
public byte[] expirationDate() {
return copy(expirationDate);
}

/**
* Returns a defensive copy of the certificate serial number.
*
* @return the serial number
*/
@Override
public byte[] serialNumber() {
return copy(serialNumber);
}

/**
* Returns a defensive copy of the RSA modulus.
*
* @return the RSA modulus
*/
@Override
public byte[] modulus() {
return copy(modulus);
}

/**
* Returns a defensive copy of the RSA public exponent.
*
* @return the RSA public exponent
*/
@Override
public byte[] exponent() {
return copy(exponent);
Expand Down
28 changes: 28 additions & 0 deletions jpos/src/main/java/org/jpos/security/EMVIssuerPublicKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public record EMVIssuerPublicKey(byte[] issuerIdentifier, byte[] expirationDate,
byte[] exponent, byte hashAlgorithmIndicator,
byte publicKeyAlgorithmIndicator) {

/**
* Creates an EMV issuer public key and defensively copies array components.
*/
public EMVIssuerPublicKey {
issuerIdentifier = copy(issuerIdentifier);
expirationDate = copy(expirationDate);
Expand All @@ -64,26 +67,51 @@ public record EMVIssuerPublicKey(byte[] issuerIdentifier, byte[] expirationDate,
exponent = copy(exponent);
}

/**
* Returns a defensive copy of the issuer identifier.
*
* @return the issuer identifier
*/
@Override
public byte[] issuerIdentifier() {
return copy(issuerIdentifier);
}

/**
* Returns a defensive copy of the certificate expiration date.
*
* @return the expiration date
*/
@Override
public byte[] expirationDate() {
return copy(expirationDate);
}

/**
* Returns a defensive copy of the certificate serial number.
*
* @return the serial number
*/
@Override
public byte[] serialNumber() {
return copy(serialNumber);
}

/**
* Returns a defensive copy of the RSA modulus.
*
* @return the RSA modulus
*/
@Override
public byte[] modulus() {
return copy(modulus);
}

/**
* Returns a defensive copy of the RSA public exponent.
*
* @return the RSA public exponent
*/
@Override
public byte[] exponent() {
return copy(exponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ protected byte[] paddingISO9797Method2(byte[] d) {
* @param key DES double length key
* @param d data to calculate MAC on it
* @return 8 byte of mac value
* @throws JCEHandlerException
* @throws JCEHandlerException if the MAC key cannot be formed or used
*/
protected byte[] calculateMACISO9797Alg3(Key key, byte[] d) throws JCEHandlerException {
Key kl = jceHandler.formDESKey(SMAdapter.LENGTH_DES
Expand Down Expand Up @@ -959,7 +959,7 @@ private EncryptedPIN translatePINExt (EncryptedPIN oldPinUnderKd1, EncryptedPIN
* @param mkac unique ICC Master Key for Application Cryptogams or Secure Messaging
* @param atc ICC generated Application Transaction Counter as diversification value
* @return derived 16-bytes Session Key with adjusted DES parity
* @throws JCEHandlerException
* @throws JCEHandlerException if the session key cannot be derived
*/
protected Key deriveSK_VISA(Key mkac, byte[] atc) throws JCEHandlerException {

Expand Down Expand Up @@ -988,7 +988,7 @@ protected Key deriveSK_VISA(Key mkac, byte[] atc) throws JCEHandlerException {
* @param mksm unique ICC Master Key for Secure Messaging
* @param rand Application Cryptogram as diversification value
* @return derived 16-bytes Session Key with adjusted DES parity
* @throws JCEHandlerException
* @throws JCEHandlerException if the session key cannot be derived
*/
protected Key deriveCommonSK_SM(Key mksm, byte[] rand) throws JCEHandlerException {
byte[] rl = Arrays.copyOf(rand,8);
Expand All @@ -1011,7 +1011,7 @@ protected Key deriveCommonSK_SM(Key mksm, byte[] rand) throws JCEHandlerExceptio
* @param mkac unique ICC Master Key for Application Cryptogams.
* @param atc ICC generated Application Transaction Counter as diversification value.
* @return derived 16-bytes Session Key with adjusted DES parity.
* @throws JCEHandlerException
* @throws JCEHandlerException if the session key cannot be derived
*/
protected Key deriveCommonSK_AC(Key mkac, byte[] atc) throws JCEHandlerException {

Expand All @@ -1024,14 +1024,14 @@ protected Key deriveCommonSK_AC(Key mkac, byte[] atc) throws JCEHandlerException
/**
* MasterCard Proprietary Session Key Derivation (SKD) method.
* <p>
* Described in M/Chip 4 version 1.1 Security & Key Management manual
* Described in M/Chip 4 version 1.1 Security &amp; Key Management manual
* paragraph 7 ICC Session Key Derivation.
*
* @param mkac unique ICC Master Key for Application Cryptogams
* @param atc ICC generated Application Transaction Counter as diversification value
* @param upn terminal generated random as diversification value
* @return derived 16-bytes Session Key with adjusted DES parity
* @throws JCEHandlerException
* @throws JCEHandlerException if the session key cannot be derived
*/
protected Key deriveSK_MK(Key mkac, byte[] atc, byte[] upn) throws JCEHandlerException {

Expand Down