Skip to content

Commit

Permalink
fix issue #15
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpdg committed Jan 21, 2021
1 parent 7555259 commit 8f86784
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 6 additions & 2 deletions cie-pkcs11/CSP/IAS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,13 @@ uint8_t NXP_ATR[] = { 0x80, 0x31, 0x80, 0x65, 0x49, 0x54, 0x4E, 0x58, 0x50, 0x12
uint8_t Gemalto_ATR[] = { 0x80, 0x31, 0x80, 0x65, 0xB0, 0x85, 0x04, 0x00, 0x11, 0x12, 0x0F, 0xFF, 0x82, 0x90, 0x00 };
uint8_t Gemalto2_ATR[] = { 0x80, 0x31, 0x80, 0x65, 0xB0, 0x85, 0x03, 0x00, 0xEF, 0x12, 0x0F, 0xFF, 0x82, 0x90, 0x00 };
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() {
init_func
Expand All @@ -283,6 +285,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 Down Expand Up @@ -311,7 +315,7 @@ void IAS::SelectAID_IAS(bool SM) {
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)
Expand Down Expand Up @@ -996,7 +1000,7 @@ void IAS::InitDHParam() {
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 cie-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 cie-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 @@ -405,6 +407,8 @@ namespace p11 {
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

0 comments on commit 8f86784

Please sign in to comment.