Beispiel #1
0
        /// <summary>
        /// Default hexadecimal numeric string formatter with padding in the right side.
        /// </summary>
        /// <param name="obj">Value to convert.</param>
        /// <param name="length">Length for the value as string.</param>
        /// <returns>Value of the property as string.</returns>
        public static string HexadecimalRightPaddingStringFormatter(HexadecimalData obj, int length)
        {
            // Validation:
            if (obj == null)
            {
                throw new InvalidOperationException("Can not parse a null value");
            }

            return(StringFormatter.HexadecimalStringFormatter(obj).PadRight(length, '0'));
        }
Beispiel #2
0
        /// <summary>
        /// Default hexadecimal numeric string formatter.
        /// </summary>
        /// <param name="obj">Value to convert.</param>
        /// <returns>Value of the property as string.</returns>
        public static string HexadecimalStringFormatter(HexadecimalData obj)
        {
            // Validation:
            if (obj == null)
            {
                throw new InvalidOperationException("Can not parse a null value");
            }

            return(obj.DataString);
        }
        /// <summary>
        /// Gets the PinBlock and KeySerialNumber of a card using DUKPT mode
        /// </summary>
        /// <param name="cryptographyMode">Cryptography Mode</param>
        /// <param name="keyIndex">Pinpad Key Index</param>
        /// <param name="pan">Card Pan</param>
        /// <param name="pinMinLength">Card Pin Minimum length</param>
        /// <param name="pinMaxLength">Card Pin Maximum length</param>
        /// <param name="message">Pin Entry Message</param>
        /// <param name="pinBlock">Retrieved pin block or null on failure</param>
        /// <param name="ksn">Retrieved key serial number of null on failure</param>
        /// <returns>true on success, false on failure</returns>
        public bool GetDukptPin(CryptographyMode cryptographyMode, int keyIndex, string pan, int pinMinLength,
                                int pinMaxLength, SimpleMessageProperty message, out HexadecimalData pinBlock,
                                out HexadecimalData ksn)
        {
            // Creater GPN request:
            GpnRequest request = new GpnRequest();

            request.GPN_METHOD.Value = new CryptographyMethod(KeyManagementMode.DerivedUniqueKeyPerTransaction,
                                                              cryptographyMode);
            request.GPN_KEYIDX.Value = keyIndex;
            request.GPN_WKENC.Value  = new HexadecimalData(new byte[0]);
            request.GPN_PAN.Value    = pan;

            // Settings to capture PIN:
            GpnPinEntryRequest entry = new GpnPinEntryRequest();

            entry.GPN_MIN.Value = pinMinLength;
            entry.GPN_MAX.Value = pinMaxLength;
            entry.GPN_MSG.Value = message;

            request.GPN_ENTRIES.Value.Add(entry);

            // Sends the request and gets it's response:
            GpnResponse response = this.Communication.SendRequestAndReceiveResponse <GpnResponse>(request);

            // If none response war received:
            if (response == null)
            {
                pinBlock = null;
                ksn      = null;
                return(false);
            }

            // If a response was received:
            else
            {
                pinBlock = response.GPN_PINBLK.Value;
                ksn      = response.GPN_KSN.Value;
                return(true);
            }
        }
 /// <summary>
 /// Debrypt a package.
 /// </summary>
 /// <param name="value">Package to be decrypted.</param>
 /// <returns>Decrypted value.</returns>
 private byte[] DecryptTDES(HexadecimalData value)
 {
     // Null generates a ECB encryption out of CBC.
     return(CrossPlatformController.EncryptionController.DecryptTDES(value.Data, StoneTDESKey, null));
 }