r3093 - in trunk/libmcrypto: include/libmcrypto source
xuan at minisip.org
xuan at minisip.org
Sun Jan 7 15:23:31 CET 2007
Author: xuan
Date: 2007-01-07 15:23:30 +0100 (Sun, 07 Jan 2007)
New Revision: 3093
Modified:
trunk/libmcrypto/include/libmcrypto/SmartCard.h
trunk/libmcrypto/source/SipSimSmartCardGD.cxx
trunk/libmcrypto/source/SmartCard.cxx
Log:
modified the sending and receiving buffer of SIGMAC APDU
the HASH value is 20 bytes and the signature is 1024 bits
Modified: trunk/libmcrypto/include/libmcrypto/SmartCard.h
===================================================================
--- trunk/libmcrypto/include/libmcrypto/SmartCard.h 2007-01-06 11:48:48 UTC (rev 3092)
+++ trunk/libmcrypto/include/libmcrypto/SmartCard.h 2007-01-07 14:23:30 UTC (rev 3093)
@@ -38,23 +38,23 @@
public:
/* constructor is called to connect to the smart card */
SmartCard();
-
- /* destructor is called to disconnect from smart card */
- ~SmartCard();
+
+ /* destructor is called to disconnect from smart card */
+ ~SmartCard();
- /* smart card transaction */
- void startTransaction();
- void endTransaction();
+ /* smart card transaction */
+ void startTransaction();
+ void endTransaction();
- /* one round trip of APDU exchange */
- bool transmitApdu(unsigned long sendLength, unsigned char * sendBufferPtr,
- unsigned long & recvLength, unsigned char * recvBufferPtr);
-
- /* Smart card Pin related functions */
- void setPin(const char * pinCode);
- void setAdminPin(const char * adminPinCode);
- virtual bool verifyPin(int verifyMode) = 0;
- virtual bool changePin( const char * newPinCode) = 0;
+ /* one round trip of APDU exchange */
+ bool transmitApdu(unsigned long sendLength, unsigned char * sendBufferPtr,
+ unsigned long & recvLength, unsigned char * recvBufferPtr);
+
+ /* Smart card Pin related functions */
+ void setPin(const char * pinCode);
+ void setAdminPin(const char * adminPinCode);
+ virtual bool verifyPin(int verifyMode) = 0;
+ virtual bool changePin( const char * newPinCode) = 0;
/* General smart card member function */
virtual unsigned char * getRandomValue(unsigned long randomLength) = 0;
Modified: trunk/libmcrypto/source/SipSimSmartCardGD.cxx
===================================================================
--- trunk/libmcrypto/source/SipSimSmartCardGD.cxx 2007-01-06 11:48:48 UTC (rev 3092)
+++ trunk/libmcrypto/source/SipSimSmartCardGD.cxx 2007-01-07 14:23:30 UTC (rev 3093)
@@ -312,8 +312,8 @@
bool doHash, int hash_alg)
{
if(establishedConnection == true && verifiedCard == 1 && blockedCard ==0){
- sendBufferLength = 13; // sha-1 has 20 bytes (160 bits) output as message digest
- recvBufferLength = 128; // this time we don't know the size of the receive buffer. Assume 128 is big enough and we
+ sendBufferLength = 26; // sha-1 has 20 bytes (160 bits) output as message digest
+ recvBufferLength = 130; // this time we don't know the size of the receive buffer. Assume 128 is big enough and we
// send the reference of recvBufferLength to this function and get that actual size from it
clearBuffer();
sendBuffer = new unsigned char[sendBufferLength];
@@ -325,16 +325,14 @@
sendBuffer[1] = 0x42;
sendBuffer[2] = 0x10;
sendBuffer[3] = 0x00;
- // sendBuffer[4] = 0x14; // sha-1 has 20 bytes (160 bits) output as message digest
- sendBuffer[4] = 0x08; // sha-1 has 20 bytes (160 bits) output as message digest
- memcpy(&sendBuffer[5], dataPtr, 8);
- // sendBuffer[25] = 0x80;
- sendBuffer[13] = 0x00;
+ sendBuffer[4] = 0x14; // sha-1 has 20 bytes (160 bits) output as message digest
+ memcpy(&sendBuffer[5], dataPtr, 20);
+ sendBuffer[25] = 0x80;
+ // sendBuffer[13] = 0x00;
//assert(dataLength==20); //TODO: FIXME: do not assert this - use doHash, and compute hash if necessary -EE
//memcpy(&sendBuffer[5], dataPtr, 20);
- //sendBuffer[25] = 0x80;
transmitApdu(sendBufferLength, sendBuffer, recvBufferLength, recvBuffer);
@@ -472,7 +470,7 @@
memset(recvBuffer, 0, 2);
sendBuffer[0] = 0xB0;
- sendBuffer[1] = 0xD0;
+ sendBuffer[1] = 0xD3;
sendBuffer[2] = 0x00;
sendBuffer[3] = 0x00;
Modified: trunk/libmcrypto/source/SmartCard.cxx
===================================================================
--- trunk/libmcrypto/source/SmartCard.cxx 2007-01-06 11:48:48 UTC (rev 3092)
+++ trunk/libmcrypto/source/SmartCard.cxx 2007-01-07 14:23:30 UTC (rev 3093)
@@ -153,6 +153,7 @@
return true;
}
else
+ cerr << "the return code is: " << rvTransmit << endl;
throw SmartCardException("APDU transmission failure");
}
More information about the Minisip-devel
mailing list