Ejemplo n.º 1
0
        public byte[] getModulusBytes(int padding)
        {
            try
            {
                int discarded;

                return(HexByteUtils.GetBytes(ModStringData.PadLeft(
                                                 padding, '0'), out discarded));
            }
            catch (System.IO.InvalidDataException e)
            {
                string p = e.Message;
                return(new byte[0]);
            }
        }
        /*
         *      H8/H9 Command
         *
         * Input Data:
         *
         * 001-H801<FDC694A6>
         * <30550250AB378F98E373BBC6FA5E698F4F095A6D693A851E53C35CC9633947399C09D70932776DBEA5F2F0F0C4DAB4693CACB4D07B19242FF0435C55E3D4E28EFD563457F7EBA31BE1123DEA78CEC1573716130B020103>
         * ;99
         * 0192
         * <99658789F42672E7C51CB6ECAF3F061BBABCD954D4113E1CD9BD7BD4DF1BD94E6CBC10F497E9AE68265E87F77BFF293AA2D9FDE9C1A8F12A04D9B4D8DB9F5EAEE4690883838DEF670174E70C79E674F97E2457DD85EEEB346A17DD1F39CB3E8B2D69949436051994F8687F0FEE6558F28180D5A63946CD60604B1C82F6AE14454F5824CBFDCEE07478D2F0239299B64CD900DFF7559423E98F0C7AB8229933E4DD5A5E0BD736F8172668676949493577E323FC8EC592437F6DF20EDB5FBB6E92>
         * ;0080
         * <7C9DDD3AEFF1D50BAFD11DBAF240BE827BAA156F9E8BB555CC019E183B3708F26EBE6C94702A9AD7CC1D2159CF587437532969D113C70BD622EB81AFC06E9408F1B69F3ED838A9EADFB41FB0E6E4202E>
         * ;1234567890123456;000
         *
         *
         * Input data converted to binary
         *
         * <3030312D48383031FDC694A630550250AB378F98E373BBC6FA5E698F4F095A6D693A851E53C35CC9633947399C09D70932776DBEA5F2F0F0C4DAB4693CACB4D07B19242FF0435C55E3D4E28EFD563457F7EBA31BE1123DEA78CEC1573716130B0201033B39393031393299658789F42672E7C51CB6ECAF3F061BBABCD954D4113E1CD9BD7BD4DF1BD94E6CBC10F497E9AE68265E87F77BFF293AA2D9FDE9C1A8F12A04D9B4D8DB9F5EAEE4690883838DEF670174E70C79E674F97E2457DD85EEEB346A17DD1F39CB3E8B2D69949436051994F8687F0FEE6558F28180D5A63946CD60604B1C82F6AE14454F5824CBFDCEE07478D2F0239299B64CD900DFF7559423E98F0C7AB8229933E4DD5A5E0BD736F8172668676949493577E323FC8EC592437F6DF20EDB5FBB6E923B303038307C9DDD3AEFF1D50BAFD11DBAF240BE827BAA156F9E8BB555CC019E183B3708F26EBE6C94702A9AD7CC1D2159CF587437532969D113C70BD622EB81AFC06E9408F1B69F3ED838A9EADFB41FB0E6E4202E3B313233343536373839303132333435363B303030>
         *
         *
         * Response:
         *
         * 001-H900
         * H604A678C8C78E1B9CFD415220D418E76
         * U9912C5D8B113B5E9D6787D57EE9E43BA
         * 1122334455
         * 9876543210987654
         */

        public byte[] BuildCrossAcquirerKeyEncryptionKeyunderInitialTransportKey(string publicKeyEncoding, byte[] macPublicKey, byte[] pinPadPublicKey, byte[] secretKey, byte[] dataBlock, string randomNumber)
        {
            String message = "H8";        //ascii

            message += publicKeyEncoding; //ascii

            byte[] bytes1 = Encoding.ASCII.GetBytes(message);
            message += macPublicKey;    //binary
            message += pinPadPublicKey; //binary

            byte[] byte2 = macPublicKey.Concat(pinPadPublicKey).ToArray();

            string message2 = ";99";                     //ascii

            message2 += secretKey.Length.ToString("D4"); //ascii
            byte[] byte3 = Encoding.ASCII.GetBytes(message2);

            byte[] byte4 = secretKey;                    //binary

            string message4 = ";";                       //ascii

            message4 += dataBlock.Length.ToString("D4"); //ascii
            byte[] byte5 = Encoding.ASCII.GetBytes(message4);

            byte[] byte6 = dataBlock;                    //binary

            byte[] byte7 = Encoding.ASCII.GetBytes(";"); //ascii

            int discarded;

            byte[] byte8 = HexByteUtils.GetBytes(randomNumber, out discarded); //binary

            message += ";000";                                                 //ascii
            byte[] byte9 = Encoding.ASCII.GetBytes(";000");

            byte[] dataBytes =
                bytes1.Concat(byte2)
                .Concat(byte3)
                .Concat(byte4)
                .Concat(byte5)
                .Concat(byte6)
                .Concat(byte7)
                .Concat(byte8)
                .Concat(byte9)
                .ToArray();
            return(SendBytes(dataBytes));
        }
Ejemplo n.º 3
0
 public void setModulus(int modulus)
 {
     ModStringData = modulus.ToString("X2");
     ModBytesData  = HexByteUtils.GetBytes(ModStringData, out discarded);
     ModInteger    = int.Parse(ModStringData, NumberStyles.HexNumber);
 }
Ejemplo n.º 4
0
 public Modulus(string mod)
 {
     ModStringData = mod;
     ModBytesData  = HexByteUtils.GetBytes(mod, out discarded);
 }