Skip to content

Commit

Permalink
New ST chip compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
M0Rf30 committed Jan 26, 2021
1 parent 12716c4 commit e86ac7c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions libcie-pkcs11/CSP/IAS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,13 @@ uint8_t NXP_ATR[] = { 0x80, 0x31, 0x80, 0x65, 0x49, 0x54, 0x4E, 0x58, 0x50 };
uint8_t Gemalto_ATR[] = { 0x80, 0x31, 0x80, 0x65, 0xB0, 0x85, 0x04, 0x00, 0x11 };
uint8_t Gemalto2_ATR[] = { 0x80, 0x31, 0x80, 0x65, 0xB0, 0x85, 0x03, 0x00, 0xEF };
uint8_t STM_ATR[] = {0x80, 0x66, 0x47, 0x50, 0x00, 0xB8, 0x00, 0x7F};
uint8_t STM2_ATR[] = { 0x80, 0x80, 0x01, 0x01 };

ByteArray baNXP_ATR(NXP_ATR, sizeof(NXP_ATR));
ByteArray baGemalto_ATR(Gemalto_ATR, sizeof(Gemalto_ATR));
ByteArray baGemalto2_ATR(Gemalto2_ATR, sizeof(Gemalto2_ATR));
ByteArray baSTM_ATR(STM_ATR, sizeof(STM_ATR));
ByteArray baSTM2_ATR(STM2_ATR, sizeof(STM2_ATR));

void IAS::ReadCIEType()
{
Expand All @@ -295,6 +297,8 @@ void IAS::ReadCIEType()
type = CIE_Type::CIE_Gemalto;
else if (ATR.indexOf(baSTM_ATR, position))
type = CIE_Type::CIE_STM;
else if (ATR.indexOf(baSTM2_ATR, position))
type = CIE_Type::CIE_STM2;
else
throw logged_error("CIE non riconosciuta");
}
Expand All @@ -319,7 +323,7 @@ void IAS::SelectAID_IAS(bool SM)
if ((sw = SendAPDU(VarToByteArray(selectMF), ByteArray(), resp)) != 0x9000)
throw scard_error(sw);
}
} else if (type == CIE_Type::CIE_Gemalto || type == CIE_Type::CIE_STM) {
} else if (type == CIE_Type::CIE_Gemalto || type == CIE_Type::CIE_STM || type == CIE_Type::CIE_STM2) {
uint8_t selectIAS[] = { 0x00, 0xa4, 0x04, 0x0c };
if (SM) {
if ((sw = SendAPDU_SM(VarToByteArray(selectIAS), IAS_AID, resp)) != 0x9000)
Expand Down Expand Up @@ -994,7 +998,7 @@ void IAS::InitDHParam()
dh_g = parser.tags[0]->tags[0]->tags[0]->tags[0]->content;
dh_p = parser.tags[0]->tags[0]->tags[0]->tags[1]->content;
dh_q = parser.tags[0]->tags[0]->tags[0]->tags[2]->content;
} else if (type == CIE_Type::CIE_NXP || type == CIE_Type::CIE_STM) {
} else if (type == CIE_Type::CIE_NXP || type == CIE_Type::CIE_STM || type == CIE_Type::CIE_STM2) {
uint8_t getDHDoup[] = { 00, 0xcb, 0x3f, 0xff };
uint8_t getDHDuopData_g[] = { 0x4D, 0x0A, 0x70, 0x08, 0xBF, 0xA1, 0x01, 0x04, 0xA3, 0x02, 0x97, 0x00 };

Expand Down
3 changes: 2 additions & 1 deletion libcie-pkcs11/CSP/IAS.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ enum CIE_Type {
CIE_Unknown,
CIE_Gemalto,
CIE_NXP,
CIE_STM
CIE_STM,
CIE_STM2
};

enum CIE_DF {
Expand Down
4 changes: 4 additions & 0 deletions libcie-pkcs11/PKCS11/Slot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ extern uint8_t NXP_ATR[];
extern uint8_t Gemalto_ATR[];
extern uint8_t Gemalto2_ATR[];
extern uint8_t STM_ATR[];
extern uint8_t STM2_ATR[];

extern ByteArray baNXP_ATR;
extern ByteArray baGemalto_ATR;
extern ByteArray baGemalto2_ATR;
extern ByteArray baSTM_ATR;
extern ByteArray baSTM2_ATR;

namespace p11
{
Expand Down Expand Up @@ -408,6 +410,8 @@ void CSlot::GetTokenInfo(CK_TOKEN_INFO_PTR pInfo)
manifacturer = "Gemalto";
else if ((baATR.indexOf(baSTM_ATR, position)))
manifacturer = "STM";
else if ((baATR.indexOf(baSTM2_ATR, position)))
manifacturer = "STM2";
else
throw p11_error(CKR_TOKEN_NOT_RECOGNIZED);

Expand Down
2 changes: 1 addition & 1 deletion pacur/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ targets=(
"ubuntu"
)
pkgname="cie-middleware"
pkgver="1.3.1"
pkgver="1.3.2"
pkgrel="1"
pkgdesc="Middleware della CIE (Carta di Identità Elettronica) per Linux"
pkgdesclong=("Middleware della CIE (Carta di Identità Elettronica) per Linux")
Expand Down

0 comments on commit e86ac7c

Please sign in to comment.