3

How can i use minidriver for gemalto smart card(axaltocm.dll) in .net for using method

void ChangeReferenceData(byte mode, byte role, byte[] oldPin,byte[] newPin, int maxTries);

I have installed gelamto minidriver from windows update.

Basically I want to change Admin key using ChangeReferenceData method.

Please help.

codedip
  • 191
  • 3
  • 11
  • Have you created a project? Added the .dll as a reference in your project? we need to know where you're currently at. – Kestami Jun 03 '13 at 11:30
  • @Shane.C yes i created the project but when ever i am trying to add it....it is showing some error.-[a reference to "axaltocm.dll" could not be added] – codedip Jun 04 '13 at 07:15
  • @codedip did you manage to know how to do it? because i have the same problem. – Dark_Knight Jan 29 '15 at 12:51

3 Answers3

2

You can install the Gemalto SDK http://www.gemalto.com/products/dotnet_card/resources/development.html

Add CardModule_stub.dll as reference

Use the MSCM service:

CardModuleService service = (CardModuleService)Activator.GetObject(typeof(CardModuleService),@"apdu://selfdiscover/MSCM")

service.ChangeReferenceData(.......)

Fredrik
  • 76
  • 4
  • Thank you for your reply. It helped me. But ,as i am very new in it, it will be very helpful if you help me with a full code example. i tried the code - service.ChangeReferenceData(0, 0x02, old, new, -1); but it shows unauthorized action error[Attempted to perform an unauthorized operation.]. Kindly help. – codedip Jun 17 '13 at 09:21
  • I have not tried the specific function you are using but you probably need to verify your existing pincode first //byte role = the role you want verify , string pincode = exsiting pincode service.VerifyPin(role, Encoding.ASCII.GetBytes(pincode)); if(service.IsAuthenticated(role)){ service.ChangeReferenceData(.......) } Try this on the normal user first. If you lock admin user do you need to discard the card. Documentation: http://www.gemalto.com/dwnld/6263_IDPrime_.NET_Integ_Guide.pdf – Fredrik Jun 17 '13 at 15:16
  • Thank you once again, for your reply. I tried the same , but when i verify as User it worked, in case of admin it is saying "Value does not fall within the expected range." I think verifypin is only for user, for admin authentication , i used AuthenticateEx for the same. But still getting same error msg for Admin key change. It is also working ok for User.Any idea??? Help please – codedip Jun 18 '13 at 09:34
  • From documentation for ChangeReferenceData: oldPin: – If role = Admin Key or Access Manager Admin Key, it must be a valid response (8 bytes) of a challenge obtained with GetChallenge(). – If role = User, it must be the current value of User PIN. Are you using challenge 8-byte for the old pin for admin account ? – Fredrik Jun 18 '13 at 10:54
1

My solution for change Admin Key (on Gemalto IDPrime.Net smart card) is:

            byte[] ch = service.GetChallenge();
            String sData = BitConverter.ToString(ch).Replace("-", "");
            byte[] bResp = Encrypt("000000000000000000000000000000000000000000000000", "0000000000000000", sData);//key, and iv
            service.ExternalAuthenticate(bResp);
            if (service.IsAuthenticated(2))//2-Admin,1-User
            {
                byte[] ch1 = service.GetChallenge();
                String sData1 = BitConverter.ToString(ch1).Replace("-", "");
                byte[] bResp1 = Encrypt("000000000000000000000000000000000000000000000000", "0000000000000000", sData1);
                service.ChangeReferenceData(0, 2, bResp1, b_newpin , -1);//for Admin PIN
                //service.ChangeReferenceData(0, 1, Encoding.ASCII.GetBytes(userpin), Encoding.ASCII.GetBytes("0001"), -1);//for User PIN
            } 
Peter
  • 11
  • 1
0

Can't you import the dll refence into your project? If the dll is unmanaged code (ex. c++) you have to use dllimport. http://msdn.microsoft.com/en-us/library/aa288468(v=vs.71).aspx. Else you have just to add the refence.

kostas ch.
  • 1,960
  • 1
  • 17
  • 30
  • i did that also but still no luck....it is not related to .net but minidriver ..... any body has any idea – codedip Jun 07 '13 at 07:56