Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

jPOS-45 added extract option to encryptPIN

  • Loading branch information...
commit 41f33ad451768a2831408441c73c570db48b0fe1 1 parent b221767
@ar ar authored
View
9 jpos/src/main/java/org/jpos/security/BaseSMAdapter.java
@@ -180,8 +180,8 @@ public SecureDESKey importKey (short keyLength, String keyType, byte[] encrypted
return result;
}
- public EncryptedPIN encryptPIN (String pin, String accountNumber) throws SMException {
- accountNumber = EncryptedPIN.extractAccountNumberPart(accountNumber);
+ public EncryptedPIN encryptPIN (String pin, String accountNumber, boolean extract) throws SMException {
+ accountNumber = extract ? EncryptedPIN.extractAccountNumberPart(accountNumber) : accountNumber;
SimpleMsg[] cmdParameters = {
new SimpleMsg("parameter", "clear pin", pin), new SimpleMsg("parameter", "account number",
accountNumber)
@@ -200,6 +200,9 @@ public EncryptedPIN encryptPIN (String pin, String accountNumber) throws SMExcep
}
return result;
}
+ public EncryptedPIN encryptPIN (String pin, String accountNumber) throws SMException {
+ return encryptPIN(pin, accountNumber, true);
+ }
public String decryptPIN (EncryptedPIN pinUnderLmk) throws SMException {
SimpleMsg[] cmdParameters = {
@@ -416,7 +419,7 @@ protected SecureDESKey generateKeyImpl (short keyLength, String keyType) throws
/**
* Your SMAdapter should override this method if it has this functionality
- * @param key
+ * @param kd
* @return generated Key Check Value
* @throws SMException
*/
View
17 jpos/src/main/java/org/jpos/security/SMAdapter.java
@@ -178,7 +178,7 @@
/**
* Generates key check value.<br>
- * @param key SecureDESKey with untrusted or fake Key Check Value
+ * @param kd SecureDESKey with untrusted or fake Key Check Value
* @return key check value bytes
* @throws SMException
*/
@@ -217,7 +217,8 @@ public SecureDESKey importKey (short keyLength, String keyType, byte[] encrypted
*
* CAUTION: The use of clear pin presents a significant security risk
* @param pin clear pin as entered by card holder
- * @param accountNumber The 12 right-most digits of the account number excluding the check digit. Should also function correctly if the complete account number, including the check digit is passed.
+ * @param accountNumber The 12 right-most digits of the account number excluding the check digit.
+ * Should also function correctly if the complete account number, including the check digit is passed.
* NOTE: Except when passed accountNumber is 12 digit length. Then isn't reliable way to distinguish
* if it's just extracted or it's BIN, acount number and check digit
* @return PIN under LMK
@@ -226,6 +227,18 @@ public SecureDESKey importKey (short keyLength, String keyType, byte[] encrypted
public EncryptedPIN encryptPIN (String pin, String accountNumber) throws SMException;
/**
+ * Encrypts a clear pin under LMK.
+ *
+ * CAUTION: The use of clear pin presents a significant security risk
+ * @param pin clear pin as entered by card holder
+ * @param accountNumber 12 right-most digits of the account number, excluding the check digit.
+ * @param extract true to extract 12 right-most digits off the account number
+ * @return PIN under LMK
+ * @throws SMException
+ */
+ public EncryptedPIN encryptPIN (String pin, String accountNumber, boolean extract) throws SMException;
+
+ /**
* Decrypts an Encrypted PIN (under LMK).
* CAUTION: The use of clear pin presents a significant security risk
* @param pinUnderLmk
Please sign in to comment.
Something went wrong with that request. Please try again.