tilln / jmeter-iso8583

ISO8583 Plugin for JMeter
MIT License
62 stars 32 forks source link

How to generate length 4 KCV #14

Closed Nzsquall closed 4 years ago

Nzsquall commented 4 years ago

Hi Till,

Thinking to generate dynamic key exchange request with your crypto functions instead of using a fixed keys.

Our spec requires use to generate 32 character PIN key (double length), and 04 character KCV of the PIN key and same for MAC key.

I can use this to generate a 32 PIN key: ${__generateDESKey(128, ZPK)}

But and use below one to calculate KCV: ${__calculateDESKeyCheckValue(${ZPK}, KCV)}

But the KCV calculated is 6 character in hex, something like this a8b7b5.

How do you know can I generate 4 characters of KCV with your functions?

Thanks Eric

tilln commented 4 years ago

Here is what I use, via "User Defined Variables"

Nmae Value Description
PINKEY ${__generateDESKey(128,PINKEY)}
PINKEY_KCV ${__calculateDESKeyCheckValue(${PINKEY},PINKEY_KCV)}
PINKEY_ENC ${__encryptDESKey(${PINKEY},${KEK_Paymark},PINKEY_ENC)}
MACKEY ${__generateDESKey(128,MACKEY)}
MACKEY_KCV ${__calculateDESKeyCheckValue(${MACKEY},MACKEY_KCV)}
MACKEY_ENC ${__encryptDESKey( ${MACKEY},${KEK_Paymark},MACKEY_ENC)}
SESSIONKEYS ${__jexl3(("${PINKEY_ENC}"+"${PINKEY_KCV}".substring(0\,4)+"${MACKEY_ENC}"+"${MACKEY_KCV}".substring(0\,4)).toUpperCase())}
Nzsquall commented 4 years ago

Thanks.

Yesterday I did try to use the first four characters in the hex string of the generated KCV to try, but the problem I have is I didn't convert the whole key/kcv hex string to upper case before putting them into the key exchange request...

Looks good now, thanks heaps.