Skip to content

Commit

Permalink
feat: add Bit4Id and Actalis 2023 chipsets
Browse files Browse the repository at this point in the history
Also Sync cpp part with most prominent upstream changes
  • Loading branch information
M0Rf30 committed Jun 20, 2023
1 parent fdf1d48 commit ee36e9c
Show file tree
Hide file tree
Showing 7 changed files with 627 additions and 542 deletions.
2 changes: 2 additions & 0 deletions libs/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ cie_pkcs11_sources = [
'shared/src/Crypto/Base64.cpp',
'shared/src/Crypto/ASNParser.cpp',
'shared/src/Crypto/AES.cpp',
'shared/src/CSP/ATR.cpp',
'shared/src/CSP/ExtAuthKey.cpp',
'pkcs11/src/Util/util.cpp',
'pkcs11/src/Util/UtilException.cpp',
Expand Down Expand Up @@ -178,6 +179,7 @@ cie_sign_sdk_sources = [
'shared/src/Crypto/Base64.cpp',
'shared/src/Crypto/ASNParser.cpp',
'shared/src/Crypto/AES.cpp',
'shared/src/CSP/ATR.cpp',
'shared/src/CSP/ExtAuthKey.cpp',
]

Expand Down
11 changes: 7 additions & 4 deletions libs/pkcs11/src/CSP/AbilitaCIE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <arpa/inet.h>
#include <cryptopp/asn.h>
#include <cryptopp/config_int.h>
#include <cryptopp/cryptlib.h>
#include <cryptopp/misc.h>
#include <math.h>
Expand Down Expand Up @@ -185,6 +186,7 @@ CK_RV CK_ENTRY AbilitaCIE(const char* szPAN, const char* szPIN, int* attempts,

progressCallBack(10, "Verifica carta esistente");

LOG_DEBUG("AbbinaCIE - Checking if card has been activated yet...");
IAS ias((CToken::TokenTransmitCallback)TokenTransmitCallback, atrBa);
ias.SetCardContext(&conn);

Expand Down Expand Up @@ -238,7 +240,7 @@ CK_RV CK_ENTRY AbilitaCIE(const char* szPAN, const char* szPIN, int* attempts,
free(ATR);
ATR = NULL;

DWORD rs = CardAuthenticateEx(&ias, ROLE_USER, FULL_PIN, (BYTE*)(szPIN),
DWORD rs = CardAuthenticateEx(&ias, ROLE_USER, FULL_PIN, (BYTE*)szPIN,
(DWORD)strnlen(szPIN, sizeof(szPIN)),
nullptr, 0, progressCallBack, attempts);
if (rs == SCARD_W_WRONG_CHV) {
Expand Down Expand Up @@ -330,12 +332,12 @@ CK_RV CK_ENTRY AbilitaCIE(const char* szPAN, const char* szPIN, int* attempts,
{
OID oid(attributes);
if (oid == OID_GIVENNAME) {
byte tag = 0;
CryptoPP::byte tag = 0;
attributes.Peek(tag);

CryptoPP::BERDecodeTextString(attributes, name, tag);
} else if (oid == OID_SURNAME) {
byte tag = 0;
CryptoPP::byte tag = 0;
attributes.Peek(tag);

CryptoPP::BERDecodeTextString(attributes, surname, tag);
Expand Down Expand Up @@ -371,7 +373,7 @@ CK_RV CK_ENTRY AbilitaCIE(const char* szPAN, const char* szPIN, int* attempts,
if (readers) free(readers);

LOG_INFO("AbbinaCIE - CIE paired successfully");
progressCallBack(100, "");
progressCallBack(100, "OK!");
LOG_INFO("***** AbbinaCIE Ended *****");

return SCARD_S_SUCCESS;
Expand Down Expand Up @@ -445,6 +447,7 @@ DWORD CardAuthenticateEx(IAS* ias, DWORD PinId, DWORD dwFlags, BYTE* pbPinData,
}
if (sw >= 0x63C0 && sw <= 0x63CF) {
if (pcAttemptsRemaining != nullptr) *pcAttemptsRemaining = sw - 0x63C0;
LOG_ERROR("CardAuthenticateEx - Wrong Pin");
return SCARD_W_WRONG_CHV;
}
if (sw == 0x6700) {
Expand Down
6 changes: 3 additions & 3 deletions libs/pkcs11/src/CSP/FirmaConCIE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ CK_RV CK_ENTRY firmaConCIE(const char* inFilePath, const char* type,

ByteArray atrBa((BYTE*)ATR, atrLen);

progressCallBack(20, "");
progressCallBack(20, "Getting certificate from CIE...");

IAS* ias =
new IAS((CToken::TokenTransmitCallback)TokenTransmitCallback, atrBa);
Expand Down Expand Up @@ -130,7 +130,7 @@ CK_RV CK_ENTRY firmaConCIE(const char* inFilePath, const char* type,
FullPIN.append(LastPIN);
ias->token.Reset();

progressCallBack(40, "");
progressCallBack(40, "Starting signature...");

char fullPinCStr[9];
memcpy(fullPinCStr, FullPIN.data(), 8);
Expand All @@ -146,7 +146,7 @@ CK_RV CK_ENTRY firmaConCIE(const char* inFilePath, const char* type,
return CKR_PIN_LOCKED;
}

progressCallBack(100, "");
progressCallBack(100, "OK!");

LOG_INFO("firmaConCIE - completed, res: %d", ret);

Expand Down
Loading

0 comments on commit ee36e9c

Please sign in to comment.