r3108 - in trunk/libmcrypto: include/libmcrypto source

erik at minisip.org erik at minisip.org
Wed Jan 10 23:47:06 CET 2007


Author: erik
Date: 2007-01-10 23:47:05 +0100 (Wed, 10 Jan 2007)
New Revision: 3108

Modified:
   trunk/libmcrypto/include/libmcrypto/SipSim.h
   trunk/libmcrypto/include/libmcrypto/SipSimSmartCardGD.h
   trunk/libmcrypto/source/SipSimSmartCardGD.cxx
Log:

 * Moved setCAs and setCertificateChain from SipSimSmartCardGD to SipSim
  since it is common to all SIMs

 * Support not doing hashing in the G&D smart card api.




Modified: trunk/libmcrypto/include/libmcrypto/SipSim.h
===================================================================
--- trunk/libmcrypto/include/libmcrypto/SipSim.h	2007-01-10 20:28:32 UTC (rev 3107)
+++ trunk/libmcrypto/include/libmcrypto/SipSim.h	2007-01-10 22:47:05 UTC (rev 3108)
@@ -50,7 +50,10 @@
 				bool doHash, 
 				int hash_alg=HASH_SHA1) = 0;
 
+	virtual void setCertificateChain(MRef<certificate_chain *> c){certChain = c;}
 	virtual MRef<certificate_chain *> getCertificateChain(){return certChain;}
+
+	virtual void setCAs(MRef<ca_db*> c){ca_set=c;}
 	virtual MRef<ca_db *> getCAs(){return ca_set;}
 	
 

Modified: trunk/libmcrypto/include/libmcrypto/SipSimSmartCardGD.h
===================================================================
--- trunk/libmcrypto/include/libmcrypto/SipSimSmartCardGD.h	2007-01-10 20:28:32 UTC (rev 3107)
+++ trunk/libmcrypto/include/libmcrypto/SipSimSmartCardGD.h	2007-01-10 22:47:05 UTC (rev 3108)
@@ -39,9 +39,6 @@
 	
 	~SipSimSmartCardGD();
 
-	void setCertificateChain(MRef<certificate_chain*> c);
-	void setCA(MRef<ca_db *> ca);
-
 /* select MIKEY applet APDU */
 	bool selectMikeyApp();
 

Modified: trunk/libmcrypto/source/SipSimSmartCardGD.cxx
===================================================================
--- trunk/libmcrypto/source/SipSimSmartCardGD.cxx	2007-01-10 20:28:32 UTC (rev 3107)
+++ trunk/libmcrypto/source/SipSimSmartCardGD.cxx	2007-01-10 22:47:05 UTC (rev 3108)
@@ -63,14 +63,7 @@
 	}
 }
 
-void SipSimSmartCardGD::setCertificateChain(MRef<certificate_chain *> c){
-	certChain = c;
-}
 
-void SipSimSmartCardGD::setCA(MRef<ca_db *> ca){
-	ca_set = ca;
-}
-
 bool SipSimSmartCardGD::selectMikeyApp(){
 	sendBufferLength = 17;
 	recvBufferLength = 2;
@@ -320,14 +313,19 @@
 									 bool doHash, int hash_alg)
 {
 	if(establishedConnection == true && verifiedCard == 1 && blockedCard ==0){	
-		unsigned char * messageDigestPtr = NULL;
-		unsigned long messageDigestLengh = 20;
-		if (doHash){
+		unsigned char * messageDigestPtr;
+		unsigned long messageDigestLength;
+		if (doHash){ 
+			assert( hash_alg == HASH_SHA1 );
 			messageDigestPtr = new unsigned char[20];
 			sha1(dataPtr, dataLength, messageDigestPtr);
+			messageDigestLength=20;
+		}else{
+			messageDigestPtr = dataPtr;
+			messageDigestLength=dataLength;
 		}
 		
-		sendBufferLength = 26;
+		sendBufferLength = 6+messageDigestLength;
 		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();
@@ -341,11 +339,9 @@
 		sendBuffer[2] = 0x10;
 		sendBuffer[3] = 0x00;
 		sendBuffer[4] = 0x14;				// sha-1 has 20 bytes (160 bits) output as message digest
-		memcpy(&sendBuffer[5], messageDigestPtr, 20);
-		sendBuffer[25] = 0x80;
+		memcpy(&sendBuffer[5], messageDigestPtr, messageDigestLength);
+		sendBuffer[5+messageDigestLength] = 0x80;
 
-		//assert(dataLength==20); //TODO: FIXME: do not assert this - use doHash, and compute hash if necessary -EE
-		
 		transmitApdu(sendBufferLength, sendBuffer, recvBufferLength, recvBuffer);
 		
 		sw_1_2 = recvBuffer[recvBufferLength - 2] << 8 | recvBuffer[recvBufferLength - 1];



More information about the Minisip-devel mailing list