Giter Club home page Giter Club logo

dukpt.net's Introduction

👋 Hello, world!

dukpt.net's People

Contributors

jm97 avatar rbonestell avatar sgbj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dukpt.net's Issues

WinRT port question

Hey @sgbj - This is a question, not an issue, if you have time for it. I'm working to port this library to WinRT so that I can use it in an app I'm creating. WinRT uses a new cryptography API that's different than the one that ships with .Net 4.5. One difference that I've found is that the 3DES implementation in WinRT apparently doesn't support a 16-byte key. Passing a 16-byte key to the function that creates the key throws an ArgumentException, "Value does not fall in expected range." If I expand it to a 24-byte key, padding the extra 8 bytes with zeros, it no longer throws an exception but the encrypted value is larger than the one produced by the 16-byte key and the rest of the algorithm doesn't produce the correct result. Do you have any thoughts/insights that could point me in the right direction? Thanks!

Does this not work if the message contains both track1 and track2 data?

Thanks for all the explanation. You made the libraries look pretty simple.

But while testing (No changes made to the code), could not get this program work for inputs which are having both track1 and track 2 information. It may not be related to having both track info, but it is not working for below inputs.

track = "670d1456491444377905ab458d2ad9d900d652d661ae7adbc9847f9f63c681c45a065fb47497a970abdc5ad267fd9c6f341ae8f4fe15514a639a6d3611450a537ceea909a60fbc8ecc7c4a0b50dc58fbb024caa90e3a5f97536524276a749767efc62d8e8bcc03bf2bca8e00c5c3719c3fff1a5819233038"

bdk = "0123456789ABCDEFFEDCBA9876543210"
ksn = "00000415130001e00007"

Encrypted and decrypted results are not matching.

//Expected results:
track1Decrypted = "%B4518341234567894^TEST/CARD ^2507201134160000000000819000000?"

track2Decrypted = ";4518341234567894=25072011341681900000?"

HexToBigInteger()

Thanks for the great library. On the previous version, we could use:

BigInt.FromHex(track).GetBytes();

on version 2, it looks like it's changed to:

track.HexToBigInteger().GetBytes();

Can you confirm this is the intended behavior? After upgrading to v2, HexToBigInteger() is not accessible. I think it may be related to StringExtensions is an internal class.

impossible to decrypt

I am using this key: 895250336175515C4120CF45F41ABF1C
and this ksn : 62994901190000000003

this is the encrypted data: 029801803F48236B03BF252A343236362A2A2A2A2A2A2A2A393939395E42555348204A522F47454F52474520572E4D525E2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A3F2A3B343236362A2A2A2A2A2A2A2A393939393D2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A3F2A6D7D5B204D3579694E148F3FB2565544D35825EA89BA30C966D34363151BF592F995EDA86B94A47EBFDF6434CB3A075DDD18F616E21F1E2038BC3AD5F96C1387177BD89409DA2E92A684543E007087F8694AEA8D3DB36BA10BC4D4B2771C622FEC8271A6E021AA5644ED559EC09CABF19F36B422CA2016B48A7241B2DA9584ED4415B4F30637734CF5031AF475DAF27C188A1A771264011BAA090E91893BC2A52EDD56F8E6E9554BC0C5207C04E3C21B6DA2A48F2257DC6946DBFBC87F3189E5C8B954BF7303D01E443155911E4137AEAD52441567AA1D50924A7597EC9D758A3418AC88F65E1DB7ED4D10973F99DFC8463FF6DF113B6226C4898A9D355057ECAF11A5598F02CA31688861C157C1CE2E0F72CE0F3BB598A614EAABB162994901190000000003769A0

I can't get it to work, please advise

how we get BDK key of magtek

we have magtek device and company provided document for generating key is key component- conveyance form which have key component details, and i want to know how we generate this BDK key with these information.

Add a license

@sgbj - thanks for your work on this project and for sharing it. It's been one of the most useful things I've found as I've researched DUKPT. Could you add a license to this project so I can use it in my work?

DEK_MASK

Hi,
Wondering if you could help me, I am trying to add the ability to decrypt the ID tech.
I am following their instructions but cant seem to get it to work.
Here is the excerpt from IDtech:
"The key management scheme is DUKPT. For DUKPT, the key used for encrypting data is called the Data Key. Data Key is generated by first taking the DUKPT Derived Key exclusive or’ed with 0000000000FF00000000000000FF0000 to get the resulting intermediate variant key. The left side of the intermediate variant key is then TDES encrypted with the entire 16-byte variant as the key. After the same steps are preformed for the right side of the key, combine the two key parts to create the Data Key."

The method i am modifying is CreatesessionKey

        public static BigInteger CreateSessionKey(BigInteger ipek, BigInteger ksn, bool IDTECH)
        {
            if (IDTECH)
            {
                var curKey = DeriveKey(ipek, ksn) ^ DEK_MASK;

                return BigInt.FromHex(Transform("TripleDES", true, curKey, ((curKey & Ms16Mask) >> 64)).ToString("x") +
                    Transform("TripleDES", true, curKey, (curKey & Ls16Mask)).ToString("x"));


            }
            else
            {
                return DeriveKey(ipek, ksn) ^ PekMask;
            }
        }

How to check Card Type that swaped

hi
Actually , in my side encryption and decryption of card details or track1 and track2 details is correct.
but after decryption process i am unable to find out which card is swiped . So please give me the resolution for that how i am verify card type from decrypted track1 or track2 details.

Length of the data to decrypt is invalid. - Fix

Found another issue:
If the enrypted track begins with 00 you get the following error.
Length of the data to decrypt is invalid.
It was getting 39 bytes instead of 40

To Fix the Issue i used the GetNearestWholeMultiple method from issue #5 .

i did the following

public static BigInteger Transform(string name, bool encrypt, BigInteger key, BigInteger message)
        {
            using (var cipher = SymmetricAlgorithm.Create(name))
            {
                var k = key.GetBytes();
                cipher.Key = new byte[Math.Max(0, GetNearestWholeMultiple(k.Length, 8) - k.Length)].Concat(key.GetBytes()).ToArray();
                cipher.IV = new byte[8];
                cipher.Mode = CipherMode.CBC;
                cipher.Padding = PaddingMode.Zeros;
                using (var crypto = encrypt ? cipher.CreateEncryptor() : cipher.CreateDecryptor())
                {
                    var data = message.GetBytes();
//Added the GetNearestWholeMultiple here.
                    data = new byte[Math.Max(0, GetNearestWholeMultiple(data.Length, 8) - data.Length)].Concat(message.GetBytes()).ToArray();
                    return BigInt.FromBytes(crypto.TransformFinalBlock(data, 0, data.Length));
                }
            }
        }

NuGet?

Will you add a NuGet package anytime soon? If you want, I can create the NuSpec & hook it up through MyGet.

EXCEPTION : Length of the data to decrypt is invalid.

var decBytes = Dukpt.Decrypt(bdk, ksn, BigInt.FromHex( TRACK ).GetBytes());

where TRACK data is 70 characters length. and i am getting exception in

public static BigInteger Transform() function.

exactly in this line - return BigInt.FromBytes(crypto.TransformFinalBlock(data, 0, data.Length));

Kindly help me to solve this issue.

BigInt.Parse Missed Implementation

I have been trying to use the library, but not even the example works, It says the BigInt.Parse has not been implemented. Could be that possible? Why? What should I do?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.