Skip to content

Commit

Permalink
Added support for JCOP4 smartcards from Bit4id and Actalis. Aligned D…
Browse files Browse the repository at this point in the history
…S Verification function to Windows. Release 1.4.3.4.
  • Loading branch information
AntonioCiccarelli committed Jun 5, 2023
1 parent 2f8af29 commit 422bdce
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 71 deletions.
54 changes: 27 additions & 27 deletions CIEID/src/it/ipzs/cieid/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -1466,41 +1466,41 @@ public void run() {
}

System.out.printf("Verifica con CIE - Url: %s, Port: %s, credentials: %s", proxyAddress, proxyPort, proxyCredentials);
final long ret = Middleware.INSTANCE.verificaConCIE(filePath, proxyAddress, proxyPort, proxyCredentials);
final int ret = Middleware.INSTANCE.verificaConCIE(filePath, proxyAddress, proxyPort, proxyCredentials);

if (ret == 0) {
int nSign = Middleware.INSTANCE.getNumberOfSign();
if (ret > 0 && ret != (long)INVALID_FILE_TYPE) {

if (nSign == 0) {
logger.Info("Verifica completata");
JOptionPane.showMessageDialog(MainFrame.this.getContentPane(), "Il file selezionato non contiene firme", "Verifica completata", JOptionPane.INFORMATION_MESSAGE);
tabbedPane.setSelectedIndex(10);
} else {
VerifyTable vTable = new VerifyTable(verificaScrollPane);
verifyInfo vInfo = new verifyInfo();
verifyInfo[] vInfos = (verifyInfo[])vInfo.toArray(nSign);

for (int i = 0; i < nSign; i++) {
Middleware.INSTANCE.getVerifyInfo(i, vInfos[i]);
vInfos[i].printVerifyInfo();
vTable.addDataToModel(verificaScrollPane, vInfos[i]);
}
VerifyTable vTable = new VerifyTable(verificaScrollPane);
verifyInfo vInfo = new verifyInfo();
verifyInfo[] vInfos = (verifyInfo[])vInfo.toArray(ret);

verificaScrollPane.repaint();
for (int i = 0; i < ret; i++) {
Middleware.INSTANCE.getVerifyInfo(i, vInfos[i]);
vInfos[i].printVerifyInfo();
vTable.addDataToModel(verificaScrollPane, vInfos[i]);
}

if (FilenameUtils.getExtension(filePath).equals("p7m")) {
btnEstrai.setEnabled(true);
} else {
btnEstrai.setEnabled(false);
}
verificaScrollPane.repaint();

tabbedPane.setSelectedIndex(16);
if (FilenameUtils.getExtension(filePath).equals("p7m")) {
btnEstrai.setEnabled(true);
} else {
btnEstrai.setEnabled(false);
}
} else if (ret == (long)INVALID_FILE_TYPE) {

tabbedPane.setSelectedIndex(16);
}
else if (ret == (long)INVALID_FILE_TYPE) {
logger.Error("Il file selezionato non è un file valido");
JOptionPane.showMessageDialog(MainFrame.this.getContentPane(), "Il file selezionato non è un file valido. E' possibile verificare solo file con estensione .p7m o .pdf", "Errore nella verifica", JOptionPane.ERROR_MESSAGE);
tabbedPane.setSelectedIndex(10);
} else {
}
else if (ret == 0) {
logger.Info("Verifica completata");
JOptionPane.showMessageDialog(MainFrame.this.getContentPane(), "Il file selezionato non contiene firme.", "Verifica completata", JOptionPane.INFORMATION_MESSAGE);
tabbedPane.setSelectedIndex(10);
}
else {
logger.Error("Errore generico durante la verifica");
JOptionPane.showMessageDialog(MainFrame.this.getContentPane(), "Si è verificato un errore durante la verifica", "Errore nella verifica", JOptionPane.ERROR_MESSAGE);
tabbedPane.setSelectedIndex(10);
Expand Down Expand Up @@ -3069,7 +3069,7 @@ public void run() {

case CKR_OK:
logger.Info("CIE abilitata con successo");
JOptionPane.showMessageDialog(MainFrame.this.getContentPane(), "L'abilitazione della CIE è avvennuta con successo", "CIE abilitata", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(MainFrame.this.getContentPane(), "L'abilitazione della CIE è avvenuta con successo", "CIE abilitata", JOptionPane.INFORMATION_MESSAGE);
Gson gson = new Gson();
String serialDictionary = gson.toJson(cieDictionary);
Utils.setProperty("cieDictionary", serialDictionary);
Expand Down
6 changes: 1 addition & 5 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
<<<<<<< HEAD
1.4.3-2
=======
1.4.3-3
>>>>>>> 1.4.3.3-devel
1.4.3-4
20 changes: 11 additions & 9 deletions cie-pkcs11/CSP/ATR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
using namespace CieIDLogger;

cie_atr atr_list[] = {
{CIE_Type::CIE_NXP, "NXP", { 0x80, 0x31, 0x80, 0x65, 0x49, 0x54, 0x4E, 0x58, 0x50 }},
{CIE_Type::CIE_Gemalto, "Gemalto", { 0x80, 0x31, 0x80, 0x65, 0xB0, 0x85, 0x04, 0x00, 0x11 }},
{CIE_Type::CIE_Gemalto, "Gemalto2", { 0x80, 0x31, 0x80, 0x65, 0xB0, 0x85, 0x03, 0x00, 0xEF }},
{CIE_Type::CIE_STM, "STM", { 0x80, 0x66, 0x47, 0x50, 0x00, 0xB8, 0x00, 0x7F }},
{CIE_Type::CIE_STM2, "STM2", { 0x80, 0x80, 0x01, 0x01 }},
{CIE_Type::CIE_STM3, "STM3", { 0x80, 0x01, 0x80, 0x66, 0x47, 0x50, 0x00, 0xB8, 0x00, 0x94, 0x82, 0x90, 0x00, 0xC5 }},
{CIE_Type::CIE_ACTALIS, "Actalis", { 0x80, 0x01, 0x80, 0x31, 0x80, 0x65, 0x49, 0x54, 0x4a, 0x34, 0x41, 0x12, 0x0f, 0xff, 0x82, 0x90, 0x00, 0x88 }},
{CIE_Type::CIE_BIT4ID, "Bit4Id", { 0x80, 0x01, 0x80, 0x31, 0x80, 0x65, 0x49, 0x54, 0x4a, 0x34, 0x42, 0x12, 0x0f, 0xff, 0x82, 0x90, 0x00, 0x8b }}
{CIE_Type::CIE_NXP, "NXP", { 0x80, 0x31, 0x80, 0x65, 0x49, 0x54, 0x4E, 0x58, 0x50 }},
{CIE_Type::CIE_Gemalto, "Gemalto", { 0x80, 0x31, 0x80, 0x65, 0xB0, 0x85, 0x04, 0x00, 0x11 }},
{CIE_Type::CIE_Gemalto, "Gemalto2", { 0x80, 0x31, 0x80, 0x65, 0xB0, 0x85, 0x03, 0x00, 0xEF }},
{CIE_Type::CIE_STM, "STM", { 0x80, 0x66, 0x47, 0x50, 0x00, 0xB8, 0x00, 0x7F }},
{CIE_Type::CIE_STM2, "STM2", { 0x80, 0x80, 0x01, 0x01 }},
{CIE_Type::CIE_STM3, "STM3", { 0x80, 0x01, 0x80, 0x66, 0x47, 0x50, 0x00, 0xB8, 0x00, 0x94, 0x82, 0x90, 0x00, 0xC5 }},
{CIE_Type::CIE_ACTALIS, "Actalis", { 0x80, 0x01, 0x80, 0x31, 0x80, 0x65, 0x49, 0x54, 0x4A, 0x34, 0x41, 0x12, 0x0F, 0xFF, 0x82, 0x90, 0x00, 0x88 }},
{CIE_Type::CIE_ACTALIS, "Actalis_2023", { 0x80, 0x01, 0x80, 0x31, 0x80, 0x65, 0x49, 0x54, 0x4A, 0x34, 0x43, 0x12, 0x0F, 0xFF, 0x82, 0x90, 0x00, 0x8A }},
{CIE_Type::CIE_BIT4ID, "Bit4id", { 0x80, 0x01, 0x80, 0x31, 0x80, 0x65, 0x49, 0x54, 0x4A, 0x34, 0x42, 0x12, 0x0F, 0xFF, 0x82, 0x90, 0x00, 0x8B }},
{CIE_Type::CIE_BIT4ID, "Bit4id_2023", { 0x80, 0x01, 0x80, 0x31, 0x80, 0x65, 0x49, 0x54, 0x4A, 0x34, 0x44, 0x12, 0x0F, 0xFF, 0x82, 0x90, 0x00, 0x8D }}
};

template <typename T>
Expand Down Expand Up @@ -49,4 +51,4 @@ CIE_Type get_type(vector<uint8_t> atr) {
}
LOG_INFO("ReadCIEType - cie_type() Unkown CIE detected");
return CIE_Type::CIE_Unknown;
}
}
4 changes: 1 addition & 3 deletions cie-pkcs11/CSP/AbilitaCIE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,14 +418,12 @@ CK_RV CK_ENTRY AbilitaCIE(const char* szPAN, const char* szPIN, int* attempts,
free(readers);

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

return SCARD_S_SUCCESS;
}



DWORD CardAuthenticateEx(IAS* ias,
DWORD PinId,
DWORD dwFlags,
Expand Down
6 changes: 3 additions & 3 deletions cie-pkcs11/CSP/FirmaConCIE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ CK_RV CK_ENTRY firmaConCIE(const char* inFilePath, const char* type, const char*

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

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

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

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

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


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

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

Expand Down
28 changes: 14 additions & 14 deletions cie-pkcs11/CSP/VerificaConCIE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ extern "C" {
CK_RV CK_ENTRY estraiP7m(const char* inFilePath, const char* outFilePath);
}


CK_RV CK_ENTRY verificaConCIE( const char* inFilePath, const char* proxyAddress, int proxyPort, const char* usrPass)
CK_RV CK_ENTRY verificaConCIE(const char* inFilePath, const char* proxyAddress, int proxyPort, const char* usrPass)
{
CIEVerify* verifier = new CIEVerify();

verifier->verify(inFilePath, (VERIFY_RESULT*)&verifyResult, proxyAddress, proxyPort, usrPass);
CIEVerify* verifier = new CIEVerify();

if (verifyResult.nErrorCode == 0)
{
return 0;
}
else
{
LOG_ERROR("verificaConCIE - Errore nella verifica: %lu\n", verifyResult.nErrorCode);
return verifyResult.nErrorCode;
}
verifier->verify(inFilePath, (VERIFY_RESULT*)&verifyResult, proxyAddress, proxyPort, usrPass);

if (verifyResult.nErrorCode == 0)
{
printf("verificaConCIE OK");
return (CK_RV)verifyResult.verifyInfo.pSignerInfos->nCount;
}
else
{
printf("Errore nella verifica: %lu\n", verifyResult.nErrorCode);
return verifyResult.nErrorCode;
}
}

CK_RV CK_ENTRY getNumberOfSign(void)
Expand Down
2 changes: 1 addition & 1 deletion cie-pkcs11/LOGGER/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Logger* Logger::getInstance() throw ()
}

int log_level = m_Instance->getLogConfig();
printf("Lib log level: %d\n", log_level);
//printf("Lib log level: %d\n", log_level);

if (log_level == LOG_STATUS_DISABLED) {
m_Instance->disableLog();
Expand Down
21 changes: 12 additions & 9 deletions cie_sign_sdk/src/CSP/ATR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
#include <algorithm>

cie_atr atr_list[] = {
{CIE_Type::CIE_NXP, "NXP", { 0x80, 0x31, 0x80, 0x65, 0x49, 0x54, 0x4E, 0x58, 0x50 }},
{CIE_Type::CIE_Gemalto, "Gemalto", { 0x80, 0x31, 0x80, 0x65, 0xB0, 0x85, 0x04, 0x00, 0x11 }},
{CIE_Type::CIE_Gemalto, "Gemalto2", { 0x80, 0x31, 0x80, 0x65, 0xB0, 0x85, 0x03, 0x00, 0xEF }},
{CIE_Type::CIE_STM, "STM", { 0x80, 0x66, 0x47, 0x50, 0x00, 0xB8, 0x00, 0x7F }},
{CIE_Type::CIE_STM2, "STM2", { 0x80, 0x80, 0x01, 0x01 }},
{CIE_Type::CIE_STM3, "STM3", { 0x80, 0x01, 0x80, 0x66, 0x47, 0x50, 0x00, 0xB8, 0x00, 0x94, 0x82, 0x90, 0x00, 0xC5 }},
{CIE_Type::CIE_ACTALIS, "Actalis", { 0x80, 0x01, 0x80, 0x31, 0x80, 0x65, 0x49, 0x54, 0x4a, 0x34, 0x41, 0x12, 0x0f, 0xff, 0x82, 0x90, 0x00, 0x88 }},
{CIE_Type::CIE_BIT4ID, "Bit4Id", { 0x80, 0x01, 0x80, 0x31, 0x80, 0x65, 0x49, 0x54, 0x4a, 0x34, 0x42, 0x12, 0x0f, 0xff, 0x82, 0x90, 0x00, 0x8b }}
{CIE_Type::CIE_NXP, "NXP", { 0x80, 0x31, 0x80, 0x65, 0x49, 0x54, 0x4E, 0x58, 0x50 }},
{CIE_Type::CIE_Gemalto, "Gemalto", { 0x80, 0x31, 0x80, 0x65, 0xB0, 0x85, 0x04, 0x00, 0x11 }},
{CIE_Type::CIE_Gemalto, "Gemalto2", { 0x80, 0x31, 0x80, 0x65, 0xB0, 0x85, 0x03, 0x00, 0xEF }},
{CIE_Type::CIE_STM, "STM", { 0x80, 0x66, 0x47, 0x50, 0x00, 0xB8, 0x00, 0x7F }},
{CIE_Type::CIE_STM2, "STM2", { 0x80, 0x80, 0x01, 0x01 }},
{CIE_Type::CIE_STM3, "STM3", { 0x80, 0x01, 0x80, 0x66, 0x47, 0x50, 0x00, 0xB8, 0x00, 0x94, 0x82, 0x90, 0x00, 0xC5 }},
{CIE_Type::CIE_ACTALIS, "Actalis", { 0x80, 0x01, 0x80, 0x31, 0x80, 0x65, 0x49, 0x54, 0x4A, 0x34, 0x41, 0x12, 0x0F, 0xFF, 0x82, 0x90, 0x00, 0x88 }},
{CIE_Type::CIE_ACTALIS, "Actalis_2023", { 0x80, 0x01, 0x80, 0x31, 0x80, 0x65, 0x49, 0x54, 0x4A, 0x34, 0x43, 0x12, 0x0F, 0xFF, 0x82, 0x90, 0x00, 0x8A }},
{CIE_Type::CIE_BIT4ID, "Bit4id", { 0x80, 0x01, 0x80, 0x31, 0x80, 0x65, 0x49, 0x54, 0x4A, 0x34, 0x42, 0x12, 0x0F, 0xFF, 0x82, 0x90, 0x00, 0x8B }},
{CIE_Type::CIE_BIT4ID, "Bit4id_2023", { 0x80, 0x01, 0x80, 0x31, 0x80, 0x65, 0x49, 0x54, 0x4A, 0x34, 0x44, 0x12, 0x0F, 0xFF, 0x82, 0x90, 0x00, 0x8D }}
};

template <typename T>
Expand All @@ -36,11 +38,12 @@ string get_manufacturer(vector<uint8_t> atr) {

CIE_Type get_type(vector<uint8_t> atr) {


for (cie_atr el : atr_list) {
if (IsSubset(atr, el.atr)) {
return el.cie_type;
}
}

return CIE_Type::CIE_Unknown;
}
}

0 comments on commit 422bdce

Please sign in to comment.