Documentation
¶
Overview ¶
Package ssm provides cryptographic utilities for banking SSM operations.
Index ¶
- Constants
- Variables
- func AesDecrypt(kaeyB64, ivB64, textB64 string) (string, error)
- func AesEncrypt(kaeyB64, ivB64, text string) (string, error)
- func Decimalize(notDecimaliz string, length int, immediate bool) string
- func DecryptDes(cipherB64, keyB64 string) (string, error)
- func DecryptDesBothHex(cipherHex, keyHex string) (string, error)
- func DecryptDesHex(cipherHex, keyB64 string) (string, error)
- func DecryptRsa(ks1 keystore.KeyStore, keyID, pass, data string) (string, error)
- func EncryptCvv(tspB64, cvkB64 string) (string, error)
- func EncryptDes(textB64, keyB64 string) (string, error)
- func EncryptDesHex(textHex, keyB64 string) (string, error)
- func EncryptRsa(ks1 keystore.KeyStore, keyID, data string) (string, error)
- func ExtractPanFromCard(card string) (string, error)
- func GenCvv(pan, exp, service, cvkB64 string) (string, error)
- func GenerateOffset(card, pvkB64, pin string, pinlen int) (string, error)
- func GeneratePinBlock(pan, tpkB64, pin string) (string, error)
- func GeneratePvv(card, pvkB64, pvki, pin string) (string, error)
- func GenerateRandomPin(length int) string
- func Initialize()
- func IsPinEasy(pin int) bool
- func PKCS7Padding(ciphertext []byte) []byte
- func PKCS7UnPadding(plantText []byte) []byte
- func PinBlock(pan, pin, tpk string) (string, error)
- func RandomData(length int) string
- func ReadKeyStore(filename string, password []byte) keystore.KeyStore
- func SubTen(pin, decimalized string, length int) (string, error)
- func WriteKeyStore(ks keystore.KeyStore, filename string, password []byte)
- func Zeroing(buf []byte)
- type DesMode
- type Ssm
- func (s *Ssm) Crypt(data, mode string) (string, error)
- func (s *Ssm) Cvv(pan, exp, cvvType string) (string, error)
- func (s *Ssm) Cvv2Padding(cvv2 string) (string, error)
- func (s *Ssm) GetKey(id string) string
- func (s *Ssm) Mac(_ string) (string, error)
- func (s *Ssm) Offset(pan, pinBlock string) (string, error)
- func (s *Ssm) PinBlock(pan, pin string) (string, error)
- func (s *Ssm) PinBlockDecode(pan, pinBlock string) (string, error)
- func (s *Ssm) Pvv(pan, pinBlock string) (string, error)
- func (s *Ssm) SetKey(id, value string)
- func (s *Ssm) Translate(pan, pinBlock, tpk2nd string) (string, error)
Constants ¶
const DecimalizationTable string = "0123456789012345"
DecimalizationTable maps hex digits to decimal digits for PVV/CVV generation.
Variables ¶
var BadPins []int
BadPins is the list of PIN values considered weak or easily guessable.
var ZeroIv = []byte{0, 0, 0, 0, 0, 0, 0, 0}
ZeroIv is an 8-byte zero initialization vector used for DES operations.
Functions ¶
func AesDecrypt ¶
AesDecrypt decrypts a base64-encoded AES-CBC ciphertext using the given base64-encoded key and IV.
func AesEncrypt ¶
AesEncrypt encrypts a plaintext string using AES-CBC with the given base64-encoded key and IV.
func Decimalize ¶
Decimalize converts hex digits to decimal digits using the decimalization table.
func DecryptDes ¶
DecryptDes decrypts a base64-encoded DES/Triple-DES ciphertext using a base64-encoded key.
func DecryptDesBothHex ¶
DecryptDesBothHex decrypts a hex-encoded DES/Triple-DES ciphertext using a hex-encoded key.
func DecryptDesHex ¶
DecryptDesHex decrypts a hex-encoded DES/Triple-DES ciphertext using a base64-encoded key.
func DecryptRsa ¶
DecryptRsa decrypts base64-encoded RSA ciphertext using the private key from the given keystore entry.
func EncryptCvv ¶
EncryptCvv encrypts a CVV toolstring using a two-part DES scheme with the given CVK.
func EncryptDes ¶
EncryptDes encrypts base64-encoded plaintext with DES/Triple-DES using a base64-encoded key.
func EncryptDesHex ¶
EncryptDesHex encrypts hex-encoded plaintext with DES/Triple-DES using a base64-encoded key.
func EncryptRsa ¶
EncryptRsa encrypts base64-encoded data using the RSA public key from the given keystore entry.
func ExtractPanFromCard ¶
ExtractPanFromCard extracts the 12-digit PAN from a 16-digit card number.
func GenerateOffset ¶
GenerateOffset generates a PIN offset from the card, PVK, PIN, and PIN length.
func GeneratePinBlock ¶
GeneratePinBlock creates an encrypted PIN block for the given PAN, TPK, and PIN.
func GeneratePvv ¶
GeneratePvv generates a PVV (PIN Verification Value) from the card, PVK, PVKI, and PIN.
func GenerateRandomPin ¶
GenerateRandomPin generates a random PIN of the given length, avoiding weak PINs.
func Initialize ¶
func Initialize()
Initialize seeds the random number generator for PIN generation.
func PKCS7Padding ¶
PKCS7Padding appends PKCS#7 padding bytes to the given ciphertext.
func PKCS7UnPadding ¶
PKCS7UnPadding removes PKCS#7 padding bytes from the given plaintext.
func RandomData ¶
RandomData generates a random base64-encoded string of the given length.
func ReadKeyStore ¶
ReadKeyStore loads a Java keystore from the given file using the provided password.
func SubTen ¶
SubTen performs a digit-wise subtraction of the decimalized value from the PIN, modulo 10.
func WriteKeyStore ¶
WriteKeyStore saves a Java keystore to the given file using the provided password.
Types ¶
type Ssm ¶
Ssm holds the cryptographic keys used for SSM operations including CVK, PVK, TPK, and CSD.
func (*Ssm) Cvv ¶
Cvv generates a CVV (Card Verification Value) for the given PAN, expiry, and CVV type.
func (*Ssm) Cvv2Padding ¶ added in v0.16.3
Cvv2Padding encrypts a CVV2 value with zero-padding using the Ssm's CSD key.
func (*Ssm) GetKey ¶
GetKey returns the value of a cryptographic key by its identifier (Cvk, Pvk, Tpk, or Csd).
func (*Ssm) Mac ¶
Mac returns a MAC (Message Authentication Code) for the given data (currently returns zeros).
func (*Ssm) PinBlock ¶
PinBlock encrypts a PIN block for the given PAN and PIN using the Ssm's TPK key.
func (*Ssm) PinBlockDecode ¶
PinBlockDecode decrypts a PIN block and extracts the plaintext PIN for the given PAN.
func (*Ssm) Pvv ¶
Pvv generates a PVV (PIN Verification Value) from the PAN and encrypted PIN block.