Coder Social home page Coder Social logo

hidglobal / hid-omnikey-sample-codes Goto Github PK

View Code? Open in Web Editor NEW
51.0 15.0 25.0 2.61 MB

Sample codes for the OMNIKEY Smart Card Readers. Application contains simple examples of reader's functionalities based on the software developer guide.

C# 100.00%

hid-omnikey-sample-codes's Introduction

HID OMNIKEY Smart Card Readers' Sample Codes

Sample codes for the OMNIKEY Smart Card Readers. Application contains simple examples of reader's functionalities based on the software developer guide.

Getting Started

Sample codes are written in C# and developed for Windows.

Supported readers

  • OMNIKEY 5022
  • OMNIKEY 5023
  • OMNIKEY 5027
  • OMNIKEY 5122
  • OMNIKEY 5422

Functionality

  • reader discovery based on the PCSC reader's name
  • connects only to the supported readers
  • OMNIKEY 5022
    • Configuration
      • Read
      • Write
      • Display
    • User EEPROM
      • Read
      • Write
    • ISO/IEC 14443 Type A
      • MIFARE Classic 1K/4K Example
        • Read one block
        • Write one block
        • Increment value type block
        • Decrement value type block
        • Load key example
    • iClass 2ks/16k example with secure session (requires keys)
      • Load key example
      • Read Binary
      • Update Binary
    • Seos example
      • get UID
    • ISO 15693
      • Read one block
      • Update one block
  • OMNIKEY 5023
    • Configuration
      • Read
      • Write
      • Display
    • User EEPROM
      • Read
      • Write
    • ISO/IEC 14443 Type A
      • MIFARE Classic 1K/4K Example
        • Read one block
        • Write one block
        • Increment value type block
        • Decrement value type block
        • Load key example
    • iClass 2ks/16k example with secure session (requires keys)
      • Load key example
      • Read Binary
      • Update Binary
    • Secure Processor Examples
      • Read PACS data
      • Desfire example
  • OMNIKEY 5027
    • Configuration
      • Read
      • Write
      • Display
    • User EEPROM
      • Read
      • Write
  • OMNIKEY 5422 / 5122
    • Configuration
      • Read
      • Write
      • Display
    • User EEPROM
      • Read
      • Write *ISO/IEC 14443 Type A
      • MIFARE Classic 1K/4K Example
        • Read one block
        • Write one block
        • Increment value type block
        • Decrement value type block
        • Load key example
    • iClass 2ks/16k example with secure session
      • Load key example
      • Read Binary
      • Update Binary
    • Seos example
      • Get UID
    • Synchronous card example
      • 2WBP
      • 3WBP
      • I2C

Release Notes

  • v1.6.0
    • Added support for OMNIKEY 5027 reader
  • v1.5.0
    • Added support for OMNIKEY 5023 reader
    • Added support for OMNIKEY 5122 reader
    • Refactored secure session examples

Prerequisites

.Net Framework 4.5.2

Documentation

The code is well commented. You can use doxygen to obtain documentation, or if you downlaoded the zip bundle from hidglobal.com open the index.html file attached to the samples in the "documentation" folder.

License

(c) 2017-2018 HID Global Corporation/ASSA ABLOY AB. All rights reserved.

  Redistribution and use in source and binary forms, with or without modification,
  are permitted provided that the following conditions are met:
     - Redistributions of source code must retain the above copyright notice,
       this list of conditions and the following disclaimer.
     - Redistributions in binary form must reproduce the above copyright notice,
       this list of conditions and the following disclaimer in the documentation
       and/or other materials provided with the distribution.
       THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
       AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
       THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
       ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
       FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
       (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
       LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
       ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
       THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

hid-omnikey-sample-codes's People

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

Watchers

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

hid-omnikey-sample-codes's Issues

Secure session with Mifare Plus 2K fails

Reader: HID OMNIKEY 5022
Card: MIFARE Plus 2k "S" (Other)

Issue Description:

I'm using the ExampleWithiClass.cs class to connect to a MIFARE Plus 2k "S" card.
Here's my card diagnostic.
image

After running the console program, I follow these steps for a default card.

Smart Card Readers>PCSC Reader Name: ... > Contactless Card Examples > iClass Examples > Load iClass and Secure Session keys Example

I receive a "Security Error" after choosing Load iClass and Secure Session keys Example. I've tried default keys for EncKey and MacKey (all "FF" or all "00"), but they don't work.
Here' s the SS I've received.
image

I read the OMNIKEY® 5022 SOFTWARE DEVELOPER GUIDE but I've not been able to fix this issue.

Questions:

What are the correct keys/steps for establishing the secure session?

I added my comments in the code snippet as well.

        public class LoadKeyToPcScContainerExample
        {
            private const byte KeyRelatedAccessRight = (byte)SessionAccessKeyType.UserAdminCipherKey;
           // What are the default values for these keys
            private const string EncKey = "";
            private const string MacKey = ""; 
            private void LoadKeyCommand(ISecureChannel session, string description, byte keySlot, LoadKeyCommand.KeyType keyType, LoadKeyCommand.Persistence persistence, LoadKeyCommand.Transmission transmission, LoadKeyCommand.KeyLength keyLength, string key)
           ...
            public void Run(string readerName)
            {
                var reader = new SmartCardReader(readerName);
                var secureChannel = new Readers.SecureSession.SecureChannel(reader);
                try
                {
                    ConsoleWriter.Instance.PrintSplitter();
                    ConsoleWriter.Instance.PrintTask("Establishing SAM Secure Session");

                    if (!IsValidSessionKeyFormat(EncKey) || !IsValidSessionKeyFormat(MacKey))
                        throw new ArgumentException("Secure session key format is incorrect, correct format of session key string is 32 character long hexadecimal string without hex specifier. Example: \"00000000000000000000000000000000\"");
                   // I expect functions here to load cipher key and mac key to reader before establishing session.
                   // This part also confuses me.
                    secureChannel.Establish(EncKey + MacKey, KeyRelatedAccessRight);
                    ...

cannot read write data with device HID Global OMNIKEY 5422

Select Menu 1 -> 2 Reader Name: HID Global OMNIKEY 5422 -> 2 User EEPROM
-> Read Example

Connecting to HID Global OMNIKEY 5422 Smardcard Reader 0...
Connected
Connection ModeL Direct
An error has occured: Incorrect function
Reader connection closed

Please help me.

Read Data OMNIKEY 5422

Hello,

I have a new problem,
I'm write data to card no.1 and read data is ok,
after that, i'm read data from card no.2, why data from card no.1 is writed to card no.2 ???

Help me check from your application test
Thank you.

  1. Smart Card Readers -> 3. PCSC Reader Name: HID Gloebal ONIKEY 5422CL Smartcard Reader 0 -> 2. User EEPROM -> 2. Write Example

I need more clarification

I want to read the PCAC ships which belongs to Saudi ID cards using OMNIKEY 5422 reader.
I found in your examples that there is 'user EEPROM' example and there is also 'Synchronus Contact Card Examples' example which I don't know which one I should use.
Just I want more clarification to able to get a result from the reader.
As you can see the result below for the two ways which I used it. I can't get any useful data.
User EEPROM

  1. Back
  2. Read Example
  3. Write Example

1


Connecting to HID Global OMNIKEY 5422 Smartcard Reader 0 ...
Connected
Connection Mode: Shared

Sending command: Read 1 byte with offset address 0x0000
<-- FF70076B0DA20BA009A7078102000082010100
--> 9D01FF9000

Sending command: Read 16 bytes with offset address 0x00F0
<-- FF70076B0DA20BA009A707810200F082011000
--> 9D10FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF9000

Sending command: Read 128 bytes with offset address 0x0100
<-- FF70076B0DA20BA009A7078102010082018000
--> 9D820080FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF9000

Reader connection closed

I2C Example

  1. Back
  2. Read Example with AT24C16
  3. Write Example with AT24C16
  4. Read Example with AT24C128
  5. Write Example with AT24C128

1


<-- FF70076B09A607A2050201A1000000
--> 9E0200019000
I2C Read 1 byte from address 0x000000:

<-- FF70076B09A607A205020AA1100000
--> 9E0200019000
I2C Read 10 bytes starting from address 0x000010:

<-- FF70076B09A607A2050220A9000000
--> 9E0200019000
I2C Read 32 bytes starting from address 0x000400:
Press any key to continue..

5427G2 Support

Hi all,

Thank you for all the examples.
Any chance that you can include support for the 5427G2 omnikey reader in this example?

Regards,
Jacques

Trying to auth to Mifare SAM AV3 using HID Global OMNIKEY 5422 Smartcard Reader

Hi,

I'm trying to use the class SamSecureSession, but when it comes to the function InitializeAuthentication i'm a little bit lost.

The command we first transmit :
initAuthCommand = "FF70076B14" + $"A112A0108001{versionSecCh:X2}" + $"8101{keyNumber:X2}" + $"8208{clientNonce}00";
As i understood versionSecCh is the version of the key we want to use and keyNumber is the index of the key we want to use, but i'm not able to get this working even after checked multiples times my index and version were good.

I was not able to find any explanations about the rest of the request, can someone explain it to me or tell me which documents i can read about it ? Would be really helpfull !

Deployed Custom App to web server, get Access denied

I made a custom application that references the HidGlobal.Ok.Readers class library to use the omnikey 5022 card reader. Everything has been working well until I deployed the application to production, which I get:

"blazor.server.js:1 [2023-10-17T20:13:04.594Z] Error: System.ComponentModel.Win32Exception (5): Access is denied.
at HidGlobal.OK.Readers.WinSCard.WinSCardWrapper.EstablishContext(Scope scope)"

What do I need to do to get the custom application working in production? It was working as expected in the local environment. Thank you in advance!

how to implement for 5427ck

hi team, i notice that this code doesn't support the omnikey 5427ck. would you have any suggestions on how to get this running for the 5427CK? Or any other resources that may help.

HID Omnikey 5427 "The drivers for this device are not installed. (Code 28)"

We are integrating the Omnikey 5427 and connected to a win 10 notebook it says:

The drivers for this device are not installed. (Code 28)
There are no compatible drivers for this device.
To find a driver for this device, click Update Driver.

It is working despite the error, but is that normal behaviour?

image

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.