Giter Club home page Giter Club logo

Comments (7)

misery avatar misery commented on August 25, 2024 1

By the way... SP13 will fix this problem internally.

http://support.reiner-sct.de/downloads/LINUX/V3.99.5_SP13/pcsc-cyberjack_3.99.5final.SP13.tar.gz

from pcsc.

misery avatar misery commented on August 25, 2024

This can be triggered by this (ugly) code snippet:

g++ main.cpp `pkg-config --libs --cflags libpcsclite`

Do not forget to change "reader_name".

#include <iostream>
#include <cstring>
#include <winscard.h>
#include <algorithm>
#include <stdexcept>

std::string hex_to_string(const std::string& input)
{
    static const char* const lut = "0123456789abcdef";
    size_t len = input.length();
    if (len & 1) throw std::invalid_argument("odd length");

    std::string output;
    output.reserve(len / 2);
    for (size_t i = 0; i < len; i += 2)
    {
        char a = input[i];
        const char* p = std::lower_bound(lut, lut + 16, a);
        if (*p != a) throw std::invalid_argument("not a hex digit");

        char b = input[i + 1];
        const char* q = std::lower_bound(lut, lut + 16, b);
        if (*q != b) throw std::invalid_argument("not a hex digit");

        output.push_back(((p - lut) << 4) | (q - lut));
    }
    return output;
}

int main()
{
        typedef SCARDHANDLE PCSC_CARDHANDLE;
        typedef DWORD PCSC_INT;

        std::string dataHex = "02cc0203157f4c12060904007f0007030102025305000513ff0000b202308202ae060a04007f00070301030101a1160c14476f7665726e696b757320546573742044564341a21a1318687474703a2f2f7777772e676f7665726e696b75732e6465a31a0c18476f7665726e696b757320476d6248202620436f2e204b47a420131e68747470733a2f2f746573742e676f7665726e696b75732d6569642e6465a58201510c82014d416e736368726966743a090d0a476f7665726e696b757320476d6248202620436f2e204b470d0a416d2046616c6c7475726d20390d0a3238333539204272656d656e090d0a0d0a452d4d61696c2d416472657373653a09686240626f732d6272656d656e2e6465090d0a0d0a5a7765636b20646573204175736c657365766f7267616e67733a090d0a44656d6f6e7374726174696f6e20646573206549442d53657276696365090d0a0d0a5a757374c3a46e6469676520446174656e73636875747a61756673696368743a090d0a446965204c616e64657362656175667472616774652066c3bc7220446174656e73636875747a20756e6420496e666f726d6174696f6e736672656968656974206465722046726569656e2048616e73657374616474204272656d656e0d0a41726e647473747261c39f6520310d0a3237353730204272656d6572686176656ea64b134968747470733a2f2f746573742e676f7665726e696b75732d6569642e64653a3434332f417574656e742d44656d6f4170706c69636174696f6e2f5265636569766572536572766c6574a7818b318188042048b1397235e55ed163f3280b170b6965ce39033d9b0a83148347fc3ff9daf0d304208ac4afbf236cbb8d30d2fbeb0ad990d101e4efaa7b4df4ce1705135e530e993f0420d2e54e1d26fc5dfc3408609831bbe4cfe3204365604849e7b094623566b54a760420e224d25b448dc054c023392ca11017751041d762f83d880895b3018d8ec2b290";

        std::string data = hex_to_string(dataHex);

        SCARDCONTEXT context;
        std::cout << "establish: " << SCardEstablishContext(SCARD_SCOPE_USER, nullptr, nullptr, &context) << std::endl;

        PCSC_INT protocol;
        PCSC_CARDHANDLE cardHandle;
        PCSC_INT shareMode = SCARD_SHARE_SHARED;
        PCSC_INT preferredProtocols = SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1;

        const char* reader_name = "REINER SCT cyberJack RFID komfort (9334382841) 00 00";
        std::cout << "connect: " << SCardConnect(context, reader_name, shareMode, preferredProtocols, &cardHandle, &protocol) << std::endl;
        std::cout << "transaction: " << SCardBeginTransaction(cardHandle) << std::endl;

        const SCARD_IO_REQUEST* sendPci = SCARD_PCI_T1;
        SCARD_IO_REQUEST recvPci;
        recvPci.dwProtocol = protocol;
        recvPci.cbPciLength = sizeof(SCARD_IO_REQUEST);

        char buffer[4096];

        PCSC_INT cntrCode = 1107299788;
        PCSC_INT len;
        std::cout << "control: " << SCardControl(cardHandle,
                        cntrCode,
                        data.data(),
                        data.size(),
                        buffer,
                        sizeof(buffer),
                        &len) << std::endl;

        return 0;
}

from pcsc.

LudovicRousseau avatar LudovicRousseau commented on August 25, 2024

Why do you think the problem is with pcsc-lite and not with the pcsc-cyberjack driver that cannot handle large buffers?

from pcsc.

misery avatar misery commented on August 25, 2024

I think the pcsc-cyberjack is the problem. ;-)
I already mailed with Frank Neuber. He asked me to open an issue here... hopefully he and ReinerSCT will fix the problem.

from pcsc.

LudovicRousseau avatar LudovicRousseau commented on August 25, 2024

Thanks. Closing the issue.

from pcsc.

qxlsz avatar qxlsz commented on August 25, 2024

I have the same issue now in pcscd daemon though. It powers and unpowers itself

from pcsc.

LudovicRousseau avatar LudovicRousseau commented on August 25, 2024

@qxlsz please open a new issue with complete details.
https://pcsclite.apdu.fr/#support

from pcsc.

Related Issues (20)

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.