r3248 - in trunk: libmcrypto/include/libmcrypto libmcrypto/source libmikey/keyagreement libmikey/mikey libmsip/source libmsip/source/transactions

xuan at minisip.org xuan at minisip.org
Thu Mar 22 17:27:42 CET 2007


Author: xuan
Date: 2007-03-22 17:27:41 +0100 (Thu, 22 Mar 2007)
New Revision: 3248

Added:
   trunk/libmcrypto/include/libmcrypto/GDEnum.h
   trunk/libmcrypto/source/GDEnum.cxx
Modified:
   trunk/libmcrypto/include/libmcrypto/Makefile.am
   trunk/libmcrypto/source/Makefile.am
   trunk/libmcrypto/source/SipSimSmartCardGD.cxx
   trunk/libmikey/keyagreement/KeyAgreementDH.cxx
   trunk/libmikey/mikey/Mikey.cxx
   trunk/libmsip/source/SipLayerTransport.cxx
   trunk/libmsip/source/transactions/SipTransaction.cxx
   trunk/libmsip/source/transactions/SipTransactionInviteServer.cxx
Log:
did no change but made some code more readable



Added: trunk/libmcrypto/include/libmcrypto/GDEnum.h
===================================================================
--- trunk/libmcrypto/include/libmcrypto/GDEnum.h	2007-03-22 15:47:24 UTC (rev 3247)
+++ trunk/libmcrypto/include/libmcrypto/GDEnum.h	2007-03-22 16:27:41 UTC (rev 3248)
@@ -0,0 +1,136 @@
+/**
+Copyright (C) 2005, 2004 Erik Eliasson, Pan Xuan
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+* Authors: Erik Eliasson <eliasson at it.kth.se>
+*          Pan Xuan <xuan at kth.se>
+
+*/
+
+#ifndef GDENUM_H
+#define GDENUM_H
+
+class GDEnum{
+public:
+	GDEnum();
+	~GDEnum();
+	enum SW_1_2{
+		
+		SUCCESS = 0x9000,
+		
+		APPLET_SELECT_FAILURE = 0x6999,
+		
+		PIN_RETRY_TIMER_2 = 0x63C2,
+		
+		PIN_RETRY_TIMER_1 = 0x63C1,
+		
+		PIN_RETRY_TIMER_0 = 0x63C0,
+		
+		PIN_NOT_FOUND = 0x6A88,
+		
+		AUTH_LEVEL_INSUFFICIENT = 0x6982,
+		
+		GET_DH_PUBKEY_FAILURE = 0x6001,
+		
+		ENCRY_ENV_KEY_GEN_FAILURE = 0x6002,
+
+		SIGNING_FAILURE = 0x6004,
+
+		DH_TEK_GEN_FAILURE = 0x6006,
+		
+		PK_TEK_GEN_FAILURE = 0x6007,
+		
+		RANDOM_GEN_FAILURE = 0x6008,
+
+		DH_PRIKEY_GEN_FAILURE = 0x6009
+
+		
+	
+	};
+
+	enum CLA{
+		
+		GD_CLA = 0x00,
+		
+		MIKEY_CLA = 0xB0
+	};
+
+	enum INS{
+
+		VERIFY_INS = 0x10,
+
+		UPDATE_INS = 0xD0,
+
+		DH_PARA_INS = 0x20,
+
+		PKE_INS = 0x30,
+
+		KEMAC_INS = 0x32,
+
+		RAND_INS = 0x40,
+
+		SIGMAC_INS = 0x42,
+
+		DERIVE_KEY_INS = 0x44,
+
+		TGK_INS = 0x45,
+
+		GEN_KEYPAIR_INS = 0xD3,
+
+		PUT_PUBKEY_INS = 0xD4,
+
+		GET_PUBKEY_INS = 0xD5,
+
+		PUT_PRIKEY_INS = 0xD6,
+
+		GET_PRIKEY_INS = 0xD7,
+
+		SELECT_KEYRING_INS = 0xD8,
+
+		PUT_KEYRING_INS = 0xD9
+	
+	};
+
+	enum verifyMode{
+		
+		USER_PIN_VERIFY = 0,
+
+		ADMIN_PIN_VERIFY
+		
+	};
+
+	enum authLevel{
+		
+		UNVERIFIED = 0,
+		
+		USER_VERIFIED,
+		
+		ADMIN_VERIFIED
+	};
+
+	enum cardBlockLevel{
+
+		UNBLOCKED = 0,
+
+		USER_BLOCKED,
+
+		ADMIN_BLOCKED
+	};
+
+};
+
+
+#endif

Modified: trunk/libmcrypto/include/libmcrypto/Makefile.am
===================================================================
--- trunk/libmcrypto/include/libmcrypto/Makefile.am	2007-03-22 15:47:24 UTC (rev 3247)
+++ trunk/libmcrypto/include/libmcrypto/Makefile.am	2007-03-22 16:27:41 UTC (rev 3248)
@@ -15,6 +15,7 @@
 	     SipSimDh.h \
 	     SmartCard.h \
 	     SipSimSmartCardGD.h \
+	     GDEnum.h \
 	     SmartCardException.h
 endif
 

Added: trunk/libmcrypto/source/GDEnum.cxx
===================================================================
--- trunk/libmcrypto/source/GDEnum.cxx	2007-03-22 15:47:24 UTC (rev 3247)
+++ trunk/libmcrypto/source/GDEnum.cxx	2007-03-22 16:27:41 UTC (rev 3248)
@@ -0,0 +1,35 @@
+/*
+  Copyright (C) 2007 Erik Eliasson, Pan Xuan
+ 
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+ 
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+ 
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ 
+*/
+
+/*
+  Authors: Erik Eliasson <eliasson at it.kth.se>
+           Pan Xuan <xuan at kth.se>
+*/
+
+#include <libmcrypto/GDEnum.h>
+
+GDEnum::GDEnum(){
+
+
+}
+
+GDEnum::~GDEnum(){
+
+
+}

Modified: trunk/libmcrypto/source/Makefile.am
===================================================================
--- trunk/libmcrypto/source/Makefile.am	2007-03-22 15:47:24 UTC (rev 3247)
+++ trunk/libmcrypto/source/Makefile.am	2007-03-22 16:27:41 UTC (rev 3248)
@@ -24,6 +24,7 @@
 	     SipSimDh.cxx \
 	     SmartCard.cxx \
 	     SipSimSmartCardGD.cxx \
+	     GDEnum.cxx \
 	     SmartCardException.cxx
 endif
 

Modified: trunk/libmcrypto/source/SipSimSmartCardGD.cxx
===================================================================
--- trunk/libmcrypto/source/SipSimSmartCardGD.cxx	2007-03-22 15:47:24 UTC (rev 3247)
+++ trunk/libmcrypto/source/SipSimSmartCardGD.cxx	2007-03-22 16:27:41 UTC (rev 3248)
@@ -21,6 +21,7 @@
  *          Pan Xuan <xuan at kth.se>
 */
 
+#include <libmcrypto/GDEnum.h>
 #include <libmcrypto/SipSimSmartCardGD.h>
 #include <libmcrypto/SmartCardException.h>
 #include <libmcrypto/sha1.h>
@@ -33,9 +34,9 @@
 	this->recvBufferLength = 0;
 	this->sendBuffer = NULL;
 	this->recvBuffer = NULL;
-	this->verifiedCard = 0;
+	this->verifiedCard = GDEnum::UNVERIFIED;
 	this->sw_1_2 = 0x0000;
-	this->blockedCard = 0;
+	this->blockedCard = GDEnum::UNBLOCKED;
 	this->userAttemptTimer = 3;
 	this->adminAttemptTimer = 3;
 
@@ -73,7 +74,7 @@
 	memset(sendBuffer, 0, sendBufferLength);
 	memset(recvBuffer, 0, recvBufferLength);
 	 
-	sendBuffer[0] = 0x00;
+	sendBuffer[0] = GDEnum::GD_CLA;
 	sendBuffer[1] = 0xA4;
 	sendBuffer[2] = 0x04;
 	sendBuffer[3] = 0x00;
@@ -94,9 +95,9 @@
 	transmitApdu(sendBufferLength, sendBuffer, recvBufferLength, recvBuffer);
 	sw_1_2 = recvBuffer[0] << 8 | recvBuffer[1];
 	clearBuffer();
-	if(sw_1_2 == 0x9000)
+	if(sw_1_2 == GDEnum::SUCCESS)
 		return true;
-	else if(sw_1_2 == 0x6999){
+	else if(sw_1_2 == GDEnum::APPLET_SELECT_FAILURE){
 		throw SmartCardException("Mikey Applet selection failed");
 	}
 	else 
@@ -113,14 +114,14 @@
 	recvBuffer = new unsigned char[recvBufferLength];
 	memset(recvBuffer, 0, recvBufferLength);
 	
-	if(verifyMode == 0 && (userAttemptTimer > 0) && (userAttemptTimer <= 3)  && blockedCard == 0){
+	if(verifyMode == GDEnum::USER_PIN_VERIFY && (userAttemptTimer > 0) && (userAttemptTimer <= 3)  && blockedCard == GDEnum::UNBLOCKED){
 
 		sendBufferLength = 10; // 1+1+1+1+1+4 (CLA+INS+P1+P1+LEN+DATA)
 		sendBuffer = new unsigned char[sendBufferLength];
 		memset(sendBuffer, 0, sendBufferLength);
 
-		sendBuffer[0] = 0xB0;
-		sendBuffer[1] = 0x10;
+		sendBuffer[0] = GDEnum::MIKEY_CLA;
+		sendBuffer[1] = GDEnum::VERIFY_INS;
 		sendBuffer[2] =	0x00;
 		sendBuffer[3] = 0x00;
 		sendBuffer[4] = 0x04;
@@ -134,28 +135,28 @@
 		sw_1_2 = recvBuffer[0] << 8 | recvBuffer[1];
 		clearBuffer();
 			switch (sw_1_2){
-			case 0x9000:
+			case GDEnum::SUCCESS:
 				userAttemptTimer = 3;
 				blockedCard = 0;
-				verifiedCard = 1;
+				verifiedCard = GDEnum::USER_VERIFIED;
 				return true;
 			
-			case 0x63C2:
+			case GDEnum::PIN_RETRY_TIMER_2:
 				userAttemptTimer = 2;
 				blockedCard = 0;
 				break;
 			
-			case 0x63C1:
+			case GDEnum::PIN_RETRY_TIMER_1:
 				userAttemptTimer = 1;
 				blockedCard = 0;
 				break;
 			
-			case 0x63C0:
+			case GDEnum::PIN_RETRY_TIMER_0:
 				userAttemptTimer = 0;
 				blockedCard = 1;
 				break;
 
-			case  0x6A88:
+			case GDEnum::PIN_NOT_FOUND:
 				throw SmartCardException("Pin not found. Wrong P2 value");
 				
 			default:
@@ -165,12 +166,12 @@
 			return false;
 	}
 
-	else if(verifyMode == 1 && (adminAttemptTimer > 0 && adminAttemptTimer <= 3) && (blockedCard == 0 || blockedCard == 1)){
+	else if(verifyMode == GDEnum::ADMIN_PIN_VERIFY  && (adminAttemptTimer > 0 && adminAttemptTimer <= 3) && (blockedCard == GDEnum::UNBLOCKED || blockedCard == GDEnum::USER_BLOCKED)){
 			sendBufferLength = 14;
 			sendBuffer = new unsigned char[sendBufferLength];
 			memset(sendBuffer, 0, sendBufferLength);
-			sendBuffer[0] = 0xB0;
-			sendBuffer[1] = 0x10;
+			sendBuffer[0] = GDEnum::MIKEY_CLA;
+			sendBuffer[1] = GDEnum::VERIFY_INS;
 			sendBuffer[2] =	0x00;
 			sendBuffer[3] = 0x01;
 			sendBuffer[4] = 0x08;
@@ -187,29 +188,29 @@
 			clearBuffer();
 						
 			switch (sw_1_2){
-			case 0x9000:
+			case GDEnum::SUCCESS:
 				adminAttemptTimer = 3;
 				userAttemptTimer = 3;
 				blockedCard = 0;								// to validate the userPinCode by a right adminPinCode
-				verifiedCard = 2;
+				verifiedCard = GDEnum::ADMIN_VERIFIED;
 				return true;
 
-			case 0x63C2:
+			case GDEnum::PIN_RETRY_TIMER_2:
 				adminAttemptTimer = 2;
 				blockedCard = 1;
 				break;
 
-			case 0x63C1:
+			case GDEnum::PIN_RETRY_TIMER_1:
 				adminAttemptTimer = 1;
 				blockedCard = 1;
 				break;
 
-			case 0x63C0:
+			case GDEnum::PIN_RETRY_TIMER_0:
 				adminAttemptTimer = 0;
 				blockedCard = 2;
 				break;
 
-			case  0x6A88:
+			case GDEnum::PIN_NOT_FOUND:
 				throw SmartCardException("Pin not found. Wrong P2 value");
 				
 			default:
@@ -224,7 +225,7 @@
 
 bool SipSimSmartCardGD::changePin(const char * newPinCode){
 	
-	if(establishedConnection == true && verifiedCard == 2){
+	if(establishedConnection == true && verifiedCard == GDEnum::ADMIN_VERIFIED){
 		setPin(newPinCode);
 		sendBufferLength = 10;
 		recvBufferLength = 2;
@@ -234,8 +235,8 @@
 		memset(sendBuffer, 0, sendBufferLength);
 		memset(recvBuffer, 0, recvBufferLength);
 
-		sendBuffer[0] = 0xB0;
-		sendBuffer[1] = 0xD0;
+		sendBuffer[0] = GDEnum::MIKEY_CLA;
+		sendBuffer[1] = GDEnum::UPDATE_INS;
 		sendBuffer[2] = 0x00;
 		sendBuffer[3] = 0x00;
 		sendBuffer[4] = 0x04;
@@ -246,11 +247,11 @@
 		sw_1_2 = recvBuffer[0] << 8 | recvBuffer[1];
 		clearBuffer();
 		switch(sw_1_2){
-			case 0x9000:
+			case GDEnum::SUCCESS:
 				break;
-			case 0x6982:
+			case GDEnum::AUTH_LEVEL_INSUFFICIENT:
 				throw SmartCardException("authentication level is not sufficient");
-			case 0x6A88:
+			case GDEnum::PIN_NOT_FOUND:
 				throw SmartCardException("PIN not found");
 			default:
 				throw SmartCardException("Unknown status code was returned");
@@ -262,7 +263,7 @@
 }
 
 bool SipSimSmartCardGD::getRandomValue(unsigned char * randomPtr, unsigned long randomLength){
-	if(establishedConnection == true && verifiedCard == 1 && blockedCard == 0){
+	if(establishedConnection == true && verifiedCard ==  GDEnum::USER_VERIFIED && blockedCard == GDEnum::UNBLOCKED){
 
 		unsigned char * tempBuffer;
 		sendBufferLength = 5;
@@ -275,8 +276,8 @@
 		memset(recvBuffer, 0, recvBufferLength);
 		tempBuffer = (unsigned char *) &randomLength;
 
-		sendBuffer[0] = 0xB0;
-		sendBuffer[1] = 0x40;
+		sendBuffer[0] = GDEnum::MIKEY_CLA;
+		sendBuffer[1] = GDEnum::GDEnum::RAND_INS;
 		sendBuffer[2] = 0x00;
 		sendBuffer[3] = 0x00;
 		sendBuffer[4] = *tempBuffer;
@@ -285,9 +286,9 @@
 		
 		sw_1_2 = recvBuffer[randomLength] << 8 | recvBuffer[randomLength + 1];
 		switch(sw_1_2){
-			case 0x9000:
+			case GDEnum::SUCCESS:
 				break;
-			case 0x6008:
+			case GDEnum::RANDOM_GEN_FAILURE:
 				clearBuffer();
 				return false;
 				//throw SmartCardException("failed to generate random value from G&D smart card");
@@ -309,7 +310,7 @@
 bool SipSimSmartCardGD::getSignature(unsigned char *dataPtr, int dataLength, unsigned char *signaturePtr, int & signatureLength, 
 									 bool doHash, int hash_alg)
 {
-	if(establishedConnection == true && verifiedCard == 1 && blockedCard ==0){	
+	if(establishedConnection == true && verifiedCard == GDEnum::USER_VERIFIED && blockedCard == GDEnum::UNBLOCKED){	
 		unsigned char * messageDigestPtr;
 		unsigned long messageDigestLength;
 		if (doHash){ 
@@ -331,8 +332,8 @@
 		memset(sendBuffer, 0, sendBufferLength);
 		memset(recvBuffer, 0, recvBufferLength);
 		
-		sendBuffer[0] = 0xB0;
-		sendBuffer[1] = 0x42;
+		sendBuffer[0] = GDEnum::MIKEY_CLA;
+		sendBuffer[1] = GDEnum::SIGMAC_INS;
 		sendBuffer[2] = 0x10;
 		sendBuffer[3] = 0x00;
 		sendBuffer[4] = 0x14;				// sha-1 has 20 bytes (160 bits) output as message digest
@@ -343,9 +344,9 @@
 		
 		sw_1_2 = recvBuffer[recvBufferLength - 2] << 8 | recvBuffer[recvBufferLength - 1];
 			switch(sw_1_2){
-				case 0x9000:
+				case GDEnum::SUCCESS:
 					break;
-				case 0x6004:
+				case GDEnum::SIGNING_FAILURE:
 					clearBuffer();
 					return false;
 					//throw SmartCardException("failed to sign the message digest on the smart card");
@@ -369,7 +370,7 @@
 
 bool SipSimSmartCardGD::genTgk( unsigned char * dhpubPtr, unsigned long dhpubLength ) {
 
-	if(establishedConnection == true && verifiedCard == 1 && blockedCard == 0){
+	if(establishedConnection == true && verifiedCard == GDEnum::USER_VERIFIED && blockedCard == GDEnum::UNBLOCKED){
 		sendBufferLength = 4+dhpubLength+1; 
 		recvBufferLength = 257;
 		
@@ -379,8 +380,8 @@
 		memset(sendBuffer, 0, sendBufferLength);
 		memset(recvBuffer, 0, recvBufferLength);
 
-		sendBuffer[0] = 0xB0;
-		sendBuffer[1] = 0x45;
+		sendBuffer[0] = GDEnum::MIKEY_CLA;
+		sendBuffer[1] = GDEnum::TGK_INS;
 		sendBuffer[2] = 0x00;
 		sendBuffer[3] = 0x00;
 		sendBuffer[4] = dhpubLength;
@@ -389,9 +390,9 @@
 		transmitApdu(sendBufferLength, sendBuffer, recvBufferLength, recvBuffer);
 		sw_1_2 = recvBuffer[recvBufferLength - 2] << 8 | recvBuffer[recvBufferLength - 1];
 		switch(sw_1_2){
-			case 0x9000:
+			case GDEnum::SUCCESS:
 				break;
-			case 0x6007:
+			case GDEnum::DH_PRIKEY_GEN_FAILURE:
 				clearBuffer();
 				throw SmartCardException("failed to generate the Diffie-Hellman priavte key in the smart card");
 			default:
@@ -410,7 +411,7 @@
 			       unsigned char * randPtr, unsigned long randLength,
 			       unsigned char * key, unsigned long keyLength, int keyType){
 
-	if(establishedConnection == true && verifiedCard == 1 && blockedCard == 0){
+	if(establishedConnection == true && verifiedCard == GDEnum::USER_VERIFIED && blockedCard == GDEnum::UNBLOCKED){
 		sendBufferLength = 4+randLength+7; 
 		recvBufferLength = 257;
 		
@@ -420,8 +421,8 @@
 		memset(sendBuffer, 0, sendBufferLength);
 		memset(recvBuffer, 0, recvBufferLength);
 
-		sendBuffer[0] = 0xB0;
-		sendBuffer[1] = 0x44;
+		sendBuffer[0] = GDEnum::MIKEY_CLA;
+		sendBuffer[1] = GDEnum::DERIVE_KEY_INS;
 		sendBuffer[2] = 0x00;
 		sendBuffer[3] = keyType;
 		
@@ -440,11 +441,13 @@
 		transmitApdu(i, sendBuffer, recvBufferLength, recvBuffer);
 		sw_1_2 = recvBuffer[recvBufferLength - 2] << 8 | recvBuffer[recvBufferLength - 1];
 		switch(sw_1_2){
-			case 0x9000:
+			case GDEnum::SUCCESS:
 				break;
-			case 0x6007:
+			case GDEnum::DH_TEK_GEN_FAILURE: 
 				clearBuffer();
-				throw SmartCardException("failed to get the TEK from the smart card");
+				throw SmartCardException("failed to generate the TEK (DH key agreement) from the smart card");
+			case GDEnum::PK_TEK_GEN_FAILURE:
+              			throw SmartCardException("failed to generate the TEK (PK key agreement) from the smart card");
 			default:
 				clearBuffer();
 				throw SmartCardException("Unknown state value was returned when generating TEK from the smart card");
@@ -468,7 +471,7 @@
 
 bool SipSimSmartCardGD::getDHPublicValue(unsigned long & dhPublicValueLength, unsigned char * dhPublickValuePtr){
 
-	if(establishedConnection == true && verifiedCard == 1 && blockedCard == 0){	
+	if(establishedConnection == true && verifiedCard == GDEnum::USER_VERIFIED && blockedCard == GDEnum::UNBLOCKED){	
 		sendBufferLength = 5;
 		recvBufferLength = 255;
 
@@ -478,8 +481,8 @@
 		memset(sendBuffer, 0, sendBufferLength);
 		memset(recvBuffer, 0, recvBufferLength);
 		
-		sendBuffer[0] = 0xB0;
-		sendBuffer[1] = 0x20;
+		sendBuffer[0] = GDEnum::MIKEY_CLA;
+		sendBuffer[1] = GDEnum::DH_PARA_INS;
 		sendBuffer[2] = 0x00;
 		sendBuffer[3] = 0x00;
 		sendBuffer[4] = 0xFF;
@@ -487,9 +490,9 @@
 		transmitApdu(sendBufferLength, sendBuffer, recvBufferLength, recvBuffer);
 		sw_1_2 = recvBuffer[recvBufferLength - 2] << 8 | recvBuffer[recvBufferLength - 1];
 		switch(sw_1_2){
-			case 0x9000:
+			case GDEnum::SUCCESS:
 				break;
-			case 0x6001:
+			case GDEnum::GET_DH_PUBKEY_FAILURE:
 				clearBuffer();
 				throw SmartCardException("failed to get the Diffie-Hellman public key from the smart card");
 			default:
@@ -508,7 +511,7 @@
 
 bool SipSimSmartCardGD::generateKeyPair(){
 	
-	if(establishedConnection == true && verifiedCard == 2 && blockedCard == 0){	
+	if(establishedConnection == true && verifiedCard == GDEnum::ADMIN_VERIFIED && blockedCard == GDEnum::UNBLOCKED){	
 		
 		sendBufferLength = 4;
 		recvBufferLength = 2;
@@ -518,8 +521,8 @@
 		memset(sendBuffer, 0, 4);
 		memset(recvBuffer, 0, 2);
 		
-		sendBuffer[0] = 0xB0;
-		sendBuffer[1] = 0xD3;
+		sendBuffer[0] = GDEnum::MIKEY_CLA;
+		sendBuffer[1] = GDEnum::GEN_KEYPAIR_INS;
 		sendBuffer[2] = 0x00;
 		sendBuffer[3] = 0x00;
 		
@@ -529,9 +532,9 @@
 		clearBuffer();
 		
 		switch(sw_1_2){
-			case 0x9000:
+			case GDEnum::SUCCESS:
 				return true;
-			case 0x6982:
+			case GDEnum::AUTH_LEVEL_INSUFFICIENT:
 				throw SmartCardException("authorization level insufficient");
 			default:
 				throw SmartCardException("Unknown state value was returned when generating the key pair on the smart card");
@@ -543,7 +546,7 @@
 }
 
 bool SipSimSmartCardGD::getPublicKey(unsigned char * publicKeyPtr, int keyPairType){
-	if(establishedConnection == true && verifiedCard == 1 && blockedCard == 0){
+	if(establishedConnection == true && verifiedCard == GDEnum::USER_VERIFIED && blockedCard == GDEnum::UNBLOCKED){
 		sendBufferLength = 5;
 	        switch(keyPairType){
 	        	case 0:
@@ -560,8 +563,8 @@
 		recvBuffer = new unsigned char[recvBufferLength];
 		memset(sendBuffer, 0, sendBufferLength);
 		memset(recvBuffer, 0, recvBufferLength);
-		sendBuffer[0] = 0xB0;
-		sendBuffer[1] = 0xD5;
+		sendBuffer[0] = GDEnum::MIKEY_CLA;
+		sendBuffer[1] = GDEnum::GET_PUBKEY_INS;
 		sendBuffer[2] = 0x00;
 		switch(keyPairType){
 	        	case 0:
@@ -579,11 +582,11 @@
 		 }
  
                  switch(sw_1_2){
-		 	case 0x9000:
+		 	case GDEnum::SUCCESS:
 				memcpy(publicKeyPtr, &recvBuffer[1], recvBuffer[0]);
 				clearBuffer();
 		        	return true;
-		        case 0x6982:
+		        case GDEnum::AUTH_LEVEL_INSUFFICIENT:
 				clearBuffer();
 		                return false;
 		        default:

Modified: trunk/libmikey/keyagreement/KeyAgreementDH.cxx
===================================================================
--- trunk/libmikey/keyagreement/KeyAgreementDH.cxx	2007-03-22 15:47:24 UTC (rev 3247)
+++ trunk/libmikey/keyagreement/KeyAgreementDH.cxx	2007-03-22 16:27:41 UTC (rev 3248)
@@ -31,6 +31,7 @@
 #include<libmcrypto/OakleyDH.h>
 #include<libmcrypto/SipSim.h>
 
+
 #ifdef SCSIM_SUPPORT
 #include<libmcrypto/SipSimSmartCardGD.h>
 #endif
@@ -130,7 +131,6 @@
 #ifdef SCSIM_SUPPORT
 	if (sim && dynamic_cast<SipSimSmartCardGD*>(*sim)){
 		SipSimSmartCardGD* gd = dynamic_cast<SipSimSmartCardGD*>(*sim);
-		cerr<<"EEEE: the public key is generated+++++++++++"<<endl;
 		assert (groupValue==DH_GROUP_OAKLEY5);
 
 		publicKeyPtr = new unsigned char[192];
@@ -236,6 +236,7 @@
 }
 
 int PeerCertificates::controlPeerCertificate( const std::string &peerUri ){
+	cerr << "start0000000000000000 peerUri is: " << peerUri <<endl;
 	if( peerCertChainPtr.isNull() || certDbPtr.isNull() )
 		return 0;
 
@@ -250,7 +251,6 @@
 
 	MRef<certificate *> peerCert = peerCertChainPtr->get_first();
 	vector<string> altNames;
-
 	altNames = peerCert->get_alt_name( certificate::SAN_URI );
 	if( find( altNames.begin(), altNames.end(), peerUri ) != altNames.end() ){
 		return 1;

Modified: trunk/libmikey/mikey/Mikey.cxx
===================================================================
--- trunk/libmikey/mikey/Mikey.cxx	2007-03-22 15:47:24 UTC (rev 3247)
+++ trunk/libmikey/mikey/Mikey.cxx	2007-03-22 16:27:41 UTC (rev 3248)
@@ -93,10 +93,8 @@
 #ifdef ENABLE_TS
 				ts.save( AUTH_START );
 #endif
-
 				if( init_mes->authenticate( *ka ) ){
 					string msg = "Authentication of the MIKEY init message failed: " + ka->authError();
-
 					throw MikeyExceptionAuthentication(
 						msg.c_str() );
 				}
@@ -104,7 +102,6 @@
 #ifdef ENABLE_TS
 				ts.save( TMP );
 #endif
-
 				if( config->isCertCheckEnabled() ){
 					PeerCertificates *peers =
 						dynamic_cast<PeerCertificates*>(*ka);

Modified: trunk/libmsip/source/SipLayerTransport.cxx
===================================================================
--- trunk/libmsip/source/SipLayerTransport.cxx	2007-03-22 15:47:24 UTC (rev 3247)
+++ trunk/libmsip/source/SipLayerTransport.cxx	2007-03-22 16:27:41 UTC (rev 3248)
@@ -852,7 +852,6 @@
 	try{
 		socket = pack->getSocket();
 		MRef<IPAddress *>destAddr;
-
 		if( !socket ){
 			// Lookup IPv4 or IPv6 address
 			destAddr = IPAddress::create(ip_addr);
@@ -927,10 +926,10 @@
 #endif
 				if( dsocket->sendTo( **destAddr, port, 
 							(const void*)packetString.c_str(),
-							(int32_t)packetString.length() ) == -1 ){
+							(int32_t)packetString.length() ) == -1 )
+				{
 
 					throw SendFailed( errno );
-
 				}
 		}
 		else{

Modified: trunk/libmsip/source/transactions/SipTransaction.cxx
===================================================================
--- trunk/libmsip/source/transactions/SipTransaction.cxx	2007-03-22 15:47:24 UTC (rev 3247)
+++ trunk/libmsip/source/transactions/SipTransaction.cxx	2007-03-22 16:27:41 UTC (rev 3248)
@@ -197,7 +197,6 @@
 
 		if( pack->getType() == SipResponse::type )
 			pack->setSocket( getSocket() );
-
 		transportLayer->sendMessage(pack, br, addVia);
 
 		if( pack->getType() != SipResponse::type && pack->getSocket() )

Modified: trunk/libmsip/source/transactions/SipTransactionInviteServer.cxx
===================================================================
--- trunk/libmsip/source/transactions/SipTransactionInviteServer.cxx	2007-03-22 15:47:24 UTC (rev 3247)
+++ trunk/libmsip/source/transactions/SipTransactionInviteServer.cxx	2007-03-22 16:27:41 UTC (rev 3248)
@@ -304,7 +304,6 @@
 				SipSMCommand::transport_layer, 
 				SipSMCommand::transaction_layer)){
 		MRef<SipResponse*> resp = lastResponse;
-		
 		send(MRef<SipMessage*>(*resp), false);
 		return true;
 	}else{
@@ -429,7 +428,6 @@
 
 		timerRel1xxResend*=2;
 		requestTimeout(timerRel1xxResend, "timerRel1xxResend");
-		
 		send(*lastResponse, false); // second parameter is "bool addVia"
 		
 		return true;
@@ -468,7 +466,6 @@
 	new StateTransition<SipSMCommand,string>(this, "transition_start_proceeding_INVITE",
 			(bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteServer::a0_start_proceeding_INVITE, 
 			s_start, s_proceeding);
-
 	new StateTransition<SipSMCommand,string>(this, "transition_proceeding_proceeding_INVITE",
 			(bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteServer::a1_proceeding_proceeding_INVITE, 
 			s_proceeding, s_proceeding);



More information about the Minisip-devel mailing list