r3083 - in trunk/libmikey: include/libmikey keyagreement mikey

mikma at minisip.org mikma at minisip.org
Thu Jan 4 00:22:13 CET 2007


Author: mikma
Date: 2007-01-04 00:22:12 +0100 (Thu, 04 Jan 2007)
New Revision: 3083

Modified:
   trunk/libmikey/include/libmikey/KeyAgreementPKE.h
   trunk/libmikey/include/libmikey/MikeyMessage.h
   trunk/libmikey/include/libmikey/MikeyPayloadPKE.h
   trunk/libmikey/keyagreement/KeyAgreementPKE.cxx
   trunk/libmikey/mikey/MikeyMessage.cxx
   trunk/libmikey/mikey/MikeyMessagePKE.cxx
   trunk/libmikey/mikey/MikeyMessagePKE.h
   trunk/libmikey/mikey/MikeyPayloadPKE.cxx
Log:
* Add extractCertificateChain and const payload iterators to MikeyPayloads
* Implement the following methods which are needed by more than one MIKEY method
  to MikeyPayloads: verifySignature, verifyV, addCertificatePayloads, extractPkeEnvKey
* Update MikeyMessagePKE using methods above.



Modified: trunk/libmikey/include/libmikey/KeyAgreementPKE.h
===================================================================
--- trunk/libmikey/include/libmikey/KeyAgreementPKE.h	2007-01-03 22:09:47 UTC (rev 3082)
+++ trunk/libmikey/include/libmikey/KeyAgreementPKE.h	2007-01-03 23:22:12 UTC (rev 3083)
@@ -3,6 +3,7 @@
 
 #include <libmikey/keyagreement.h>
 #include <libmikey/keyagreement_psk.h>
+#include <libmikey/keyagreement_dh.h>
 #include <libmcrypto/cert.h>
 
 /**
@@ -10,15 +11,23 @@
  * the keys used in the security protocol SRTP
  * It contains the necessary methods to derive the keys used
  */
-class KeyAgreementPKE : public KeyAgreementPSK{
+class KeyAgreementPKE : public KeyAgreementPSK,
+			public PeerCertificates
+{
 	public:
 	
 		/**
-		 * Constructor with the keys needed for the encryption
+		 * Initiator
 		 */
-		KeyAgreementPKE( MRef<certificate*> pubKeyResponder,
-				 int envKeyLength = 192);
-	    
+		KeyAgreementPKE( MRef<certificate_chain*> cert,
+				 MRef<certificate_chain*> peerCert );
+
+		/**
+		 * Responder
+		 */
+		KeyAgreementPKE( MRef<certificate_chain *> cert, 
+				 MRef<ca_db *> ca_db );
+
 	    /**
 	     * Destructor deletes some objects to prevent memory leaks
 	     */
@@ -26,11 +35,6 @@
 	
 		int32_t type();
 
-	    /**
-	     * Returns the Public-Key of the responder
-	     */
-	    MRef<certificate*> getPublicKey(void);
-	    
 		/**
 		 * Returns the envelope key
 		 */
@@ -49,10 +53,5 @@
 		MikeyMessage* createMessage();
 
 	private:
-	    
-	    /**
-	     * Public-Key of the responder
-	     */
-		MRef<certificate*> pubKeyResponder;
 };
 #endif //KEYAGREEMENTPKE_H

Modified: trunk/libmikey/include/libmikey/MikeyMessage.h
===================================================================
--- trunk/libmikey/include/libmikey/MikeyMessage.h	2007-01-03 22:09:47 UTC (rev 3082)
+++ trunk/libmikey/include/libmikey/MikeyMessage.h	2007-01-03 23:22:12 UTC (rev 3083)
@@ -38,8 +38,6 @@
 #include<libmikey/keyagreement.h>
 #include<libmikey/keyagreement_dh.h>
 #include<libmikey/keyagreement_psk.h>
-#include<libmikey/KeyAgreementPKE.h>
-#include<libmikey/KeyAgreementDHHMAC.h>
 #include<libmcrypto/cert.h>
 
 #include<list>
@@ -70,6 +68,8 @@
 class SipSim;
 class certificate;
 class certificate_db;
+class KeyAgreementDHHMAC;
+class KeyAgreementPKE;
 
 class LIBMIKEY_API MikeyPayloads{
 	public:
@@ -81,17 +81,25 @@
 		void operator+=( MikeyPayload * payload );
 		void addSignaturePayload( MRef<SipSim*> sim );
 		void addSignaturePayload( MRef<certificate *> cert );
+		bool verifySignature( MRef<certificate*> cert );
+
 		void addVPayload( int macAlg, uint64_t receivedT,
 			byte_t * authKey, uint32_t authKeyLength);
-		virtual void addKemacPayload(
+		bool verifyV( KeyAgreementPSK* ka );
+
+		void addKemacPayload(
 				byte_t * tgk, int tgkLength,
 				byte_t * encrKey, byte_t * iv,
 				byte_t * authKey,
 				int encrAlg, int macAlg,
 				bool kemacOnly = false );
-				
+		bool verifyKemac( KeyAgreementPSK* ka ) const;
+
+		void addCertificatePayloads( MRef<certificate_chain *> certChain );
 		MRef<certificate_chain*> extractCertificateChain() const;
 
+		bool extractPkeEnvKey( KeyAgreementPKE* ka ) const;
+
 		std::string debugDump();
 		byte_t * rawMessageData();
 		int rawMessageLength();
@@ -151,8 +159,7 @@
 		//added by choehn
 		static MikeyMessage* create(KeyAgreementPKE* ka,
 				  int encrAlg = MIKEY_ENCR_AES_CM_128,
-				  int macAlg = MIKEY_MAC_HMAC_SHA1_160,
-				  MRef<certificate*> certInitiator = NULL);
+					    int macAlg = MIKEY_MAC_HMAC_SHA1_160 );
 
 		/**
 		 * Parse MIKEY message from binary representation

Modified: trunk/libmikey/include/libmikey/MikeyPayloadPKE.h
===================================================================
--- trunk/libmikey/include/libmikey/MikeyPayloadPKE.h	2007-01-03 22:09:47 UTC (rev 3082)
+++ trunk/libmikey/include/libmikey/MikeyPayloadPKE.h	2007-01-03 23:22:12 UTC (rev 3083)
@@ -46,8 +46,8 @@
 		virtual void writeData( byte_t * start, int expectedLength );
 		virtual std::string debugDump();
 		int c();
-		int dataLength();
-		byte_t * data();
+		int dataLength() const;
+		const byte_t * data() const;
 
 	private:
 		int cValue;

Modified: trunk/libmikey/keyagreement/KeyAgreementPKE.cxx
===================================================================
--- trunk/libmikey/keyagreement/KeyAgreementPKE.cxx	2007-01-03 22:09:47 UTC (rev 3082)
+++ trunk/libmikey/keyagreement/KeyAgreementPKE.cxx	2007-01-03 23:22:12 UTC (rev 3083)
@@ -5,22 +5,37 @@
 #include <libmikey/MikeyException.h>
 #include <libmcrypto/rand.h>
 
+using namespace std;
 
-KeyAgreementPKE::KeyAgreementPKE( MRef<certificate*> pubKeyResponderT, int envKeyLength )
-		:KeyAgreementPSK(){
-										
+KeyAgreementPKE::KeyAgreementPKE( MRef<certificate_chain*> cert,
+				  MRef<certificate_chain*> peerCert )
+		:KeyAgreementPSK(),
+		 PeerCertificates(cert, peerCert){
+	// TODO autodetect length from RSA size
+	int envKeyLength = 112;
+
 	//envelope key to encrypt KEMAC payload
 	byte_t envKey[ envKeyLength ];
 	Rand::randomize( envKey, envKeyLength );
 	setPSK( envKey, envKeyLength );
 
-	//public key to encrypt PKE payload
-	pubKeyResponder = pubKeyResponderT;
-	
 	//verification set
 	setV(1);
 }
 
+KeyAgreementPKE::KeyAgreementPKE( MRef<certificate_chain *> cert, 
+				  MRef<ca_db *> ca_db )
+		:KeyAgreementPSK(),
+		 PeerCertificates(cert, ca_db){
+
+	int envKeyLength = 112;
+
+	//envelope key to encrypt KEMAC payload
+	byte_t envKey[ envKeyLength ];
+	Rand::randomize( envKey, envKeyLength );
+	setPSK( envKey, envKeyLength );
+}
+
 KeyAgreementPKE::~KeyAgreementPKE(){
 }
 
@@ -28,10 +43,6 @@
 	return KEY_AGREEMENT_TYPE_PK;
 }
 
-MRef<certificate*> KeyAgreementPKE::getPublicKey(void){
-	return pubKeyResponder;
-}
-
 byte_t* KeyAgreementPKE::getEnvelopeKey(void){
 	return getPSK();
 }
@@ -45,7 +56,6 @@
 	setPSK( aEnvKey, aEnvKeyLength );
 }
 	
-
 MikeyMessage* KeyAgreementPKE::createMessage(){
 	return MikeyMessage::create( this );
 }

Modified: trunk/libmikey/mikey/MikeyMessage.cxx
===================================================================
--- trunk/libmikey/mikey/MikeyMessage.cxx	2007-01-03 22:09:47 UTC (rev 3082)
+++ trunk/libmikey/mikey/MikeyMessage.cxx	2007-01-03 23:22:12 UTC (rev 3083)
@@ -88,9 +88,8 @@
 }
 
 MikeyMessage* MikeyMessage::create( KeyAgreementPKE* ka,
-				    int encrAlg, int macAlg,
-				    MRef<certificate*> certInitiator ){
-	return new MikeyMessagePKE( ka, encrAlg, macAlg, certInitiator );
+				    int encrAlg, int macAlg ){
+	return new MikeyMessagePKE( ka, encrAlg, macAlg );
 }
 
 /*
@@ -329,7 +328,7 @@
 
 void MikeyPayloads::addSignaturePayload( MRef<certificate *> cert ){
 	byte_t signature[4096];
-	int signatureLength;
+	int signatureLength = sizeof(signature);
 	MikeyPayloadSIGN * sign;
 	MikeyPayload * last;
 	
@@ -765,6 +764,27 @@
 	return !error;
 }
 
+void MikeyPayloads::addCertificatePayloads( MRef<certificate_chain *> certChain ){
+	if( certChain.isNull() ){
+		cerr << "No certificates" << endl;
+		return;
+	}
+
+	certChain->lock();
+	certChain->init_index();
+	MRef<certificate*> cert = certChain->get_next();
+	while( ! cert.isNull() ){
+		MikeyPayload* payload =
+			new MikeyPayloadCERT( MIKEYPAYLOAD_CERT_TYPE_X509V3SIGN,
+					      cert);
+		addPayload( payload );
+		cert = certChain->get_next();
+	}
+
+	certChain->unlock();
+}
+
+
 MRef<certificate_chain*> MikeyPayloads::extractCertificateChain() const{
 	MRef<certificate_chain *> peerChain;
 
@@ -795,3 +815,142 @@
 
 	return peerChain;
 }
+
+bool MikeyPayloads::verifySignature( MRef<certificate*> cert ){
+	MikeyPayloadSIGN* sig = (MikeyPayloadSIGN*)extractPayload(MIKEYPAYLOAD_SIGN_PAYLOAD_TYPE);
+
+	if( !sig ){
+		return false;
+	}
+		
+	int res = cert->verif_sign( rawMessageData(),
+				    rawMessageLength() - sig->sigLength(),
+				    sig->sigData(),
+				    sig->sigLength() );
+	return res > 0;
+}
+
+bool MikeyPayloads::verifyKemac( KeyAgreementPSK* ka ) const{
+	int macAlg;
+	byte_t * receivedMac;
+	byte_t * macInput;
+	unsigned int macInputLength;
+	MikeyPayloadKEMAC * kemac;
+
+	kemac = (MikeyPayloadKEMAC *) extractPayload(MIKEYPAYLOAD_KEMAC_PAYLOAD_TYPE);
+	macAlg = kemac->macAlg();
+	receivedMac = kemac->macData();
+		
+	macInputLength = kemac->length();
+	macInput = new byte_t[macInputLength];
+
+	kemac->writeData( macInput, macInputLength );
+	macInput[0] = MIKEYPAYLOAD_LAST_PAYLOAD;
+	macInputLength -= 20; // Subtract mac data
+
+	byte_t authKey[20];
+	byte_t computedMac[20];
+	unsigned int computedMacLength;
+	
+	switch( macAlg ){
+		case MIKEY_MAC_HMAC_SHA1_160:
+			ka->genTranspAuthKey( authKey, 20 );
+
+			hmac_sha1( authKey, 20,
+				   macInput,
+				   macInputLength,
+				   computedMac, &computedMacLength );
+
+			for( int i = 0; i < 20; i++ ){
+				if( computedMac[i] != receivedMac[i] ){
+					ka->setAuthError(
+						"MAC mismatch."
+					);
+					return false;
+				}
+			}
+			return true;
+		case MIKEY_MAC_NULL:
+			return true;
+		default:
+			throw MikeyException( "Unknown MAC algorithm" );
+	}
+}
+
+bool MikeyPayloads::verifyV( KeyAgreementPSK* ka ){
+	int macAlg;
+	byte_t * receivedMac;
+	byte_t * macInput;
+	unsigned int macInputLength;
+	MikeyPayloadV * v;
+	uint64_t t_sent = ka->tSent();
+
+	v = (MikeyPayloadV *)extractPayload(MIKEYPAYLOAD_V_PAYLOAD_TYPE );
+	macAlg = v->macAlg();
+	receivedMac = v->verData();
+	// macInput = raw_messsage without mac / sent_t
+	macInputLength = rawMessageLength() - 20 + 8;
+	macInput = new byte_t[macInputLength];
+	memcpy( macInput, rawMessageData(), rawMessageLength() - 20 );
+	
+	for( int i = 0; i < 8; i++ ){
+		macInput[ macInputLength - i - 1 ] = 
+			(byte_t)((t_sent >> (i*8))&0xFF);
+	}
+
+	// TODO Refactor code duplication
+
+	byte_t authKey[20];
+	byte_t computedMac[20];
+	unsigned int computedMacLength;
+	
+	switch( macAlg ){
+		case MIKEY_MAC_HMAC_SHA1_160:
+			ka->genTranspAuthKey( authKey, 20 );
+
+			hmac_sha1( authKey, 20,
+				   macInput,
+				   macInputLength,
+				   computedMac, &computedMacLength );
+
+			for( int i = 0; i < 20; i++ ){
+				if( computedMac[i] != receivedMac[i] ){
+					ka->setAuthError(
+						"MAC mismatch."
+					);
+					return false;
+				}
+			}
+			return true;
+		case MIKEY_MAC_NULL:
+			return true;
+		default:
+			throw MikeyException( "Unknown MAC algorithm" );
+	}
+}
+
+bool MikeyPayloads::extractPkeEnvKey( KeyAgreementPKE* ka ) const{
+	const MikeyPayload *payloadPke =
+		extractPayload( MIKEYPAYLOAD_PKE_PAYLOAD_TYPE );
+	const MikeyPayloadPKE *pke =
+		dynamic_cast<const MikeyPayloadPKE*>( payloadPke );
+
+	if( !pke ){
+		throw MikeyException( "PKE init did not contain PKE payload" );
+	}
+
+	MRef<certificate*> cert = ka->certificateChain()->get_first();
+	int envKeyLength = pke->dataLength();
+	byte_t *envKey = new byte_t[ envKeyLength ];
+		
+	if( !cert->private_decrypt( pke->data(), pke->dataLength(),
+				    envKey, &envKeyLength ) ){
+		throw MikeyException( "Decryption of envelope key failed" );
+	}
+
+	ka->setEnvelopeKey( envKey, envKeyLength );
+
+	delete[] envKey;
+	envKey = NULL;
+	return true;
+}

Modified: trunk/libmikey/mikey/MikeyMessagePKE.cxx
===================================================================
--- trunk/libmikey/mikey/MikeyMessagePKE.cxx	2007-01-03 22:09:47 UTC (rev 3082)
+++ trunk/libmikey/mikey/MikeyMessagePKE.cxx	2007-01-03 23:22:12 UTC (rev 3083)
@@ -1,5 +1,6 @@
 /*
   Copyright (C) 2005, 2004 Erik Eliasson, Johan Bilien, Joachim Orrblad
+  Copyright (C) 2006 Mikael Magnusson
   
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -20,6 +21,7 @@
  * Authors: Erik Eliasson <eliasson at it.kth.se>
  *          Johan Bilien <jobi at via.ecp.fr>
  *	    Joachim Orrblad <joachim at orrblad.com>
+ *          Mikael Magnusson <mikma at users.sourceforge.net>
 */
 
 #include <config.h>
@@ -29,6 +31,7 @@
 #include <libmikey/MikeyPayloadT.h>
 #include <libmikey/MikeyPayloadRAND.h>
 #include <libmikey/MikeyException.h>
+#include <libmikey/MikeyPayloadCERT.h>
 #include <libmikey/MikeyPayloadKeyData.h>
 #include <libmikey/MikeyPayloadERR.h>
 #include <libmikey/MikeyPayloadID.h>
@@ -43,7 +46,7 @@
 MikeyMessagePKE::MikeyMessagePKE(){
 }
 
-MikeyMessagePKE::MikeyMessagePKE(KeyAgreementPKE* ka, int encrAlg, int macAlg, MRef<certificate*> certInitiator){
+MikeyMessagePKE::MikeyMessagePKE( KeyAgreementPKE* ka, int encrAlg, int macAlg ){
 
 	unsigned int csbId = rand();
 	ka->setCsbId(csbId);
@@ -71,6 +74,9 @@
 	//keep a copy of the random value
 	ka->setRand(randPayload->randData(), randPayload->randLength());
 
+	// Add certificate chain
+	addCertificatePayloads( ka->certificateChain() );
+
 	// Derive the transport keys from the env_key:
 	byte_t* encrKey = NULL;
 	byte_t* iv = NULL;
@@ -106,7 +112,8 @@
 	subPayloads = NULL;
 
 	//adding PKE payload
-	MRef<certificate*> certResponder = ka->getPublicKey();
+	MRef<certificate*> certResponder =
+		ka->peerCertificateChain()->get_first();
 
 	byte_t* env_key = ka->getEnvelopeKey();
 	int encEnvKeyLength = 8192; // TODO autodetect?
@@ -119,7 +126,7 @@
 
 	addPayload(new MikeyPayloadPKE(2, encEnvKey, encEnvKeyLength));
 	
-	addSignaturePayload( certInitiator );
+	addSignaturePayload( ka->certificateChain()->get_first() );
 
 	//remove garbage
 	if( encrKey != NULL )
@@ -209,6 +216,7 @@
 			new MikeyPayloadERR( MIKEY_ERR_TYPE_UNSPEC ) );
 	}	
 
+	// FIXME i can be NULL
 	ka->setRand( ((MikeyPayloadRAND *)i)->randData(),
 			((MikeyPayloadRAND *)i)->randLength() );
 
@@ -228,6 +236,7 @@
 			new MikeyPayloadERR( MIKEY_ERR_TYPE_UNSPEC ) );
 	}	
 
+	// FIXME i can be NULL
 #define kemac ((MikeyPayloadKEMAC *)i)
 	int encrAlg = kemac->encrAlg();
 	int macAlg  = kemac->macAlg();
@@ -373,6 +382,7 @@
 			new MikeyPayloadERR( MIKEY_ERR_TYPE_UNSPEC ) );
 	}	
 
+	// FIXME i can be NULL
 	if( ((MikeyPayloadT*)i)->checkOffset( MAX_TIME_OFFSET ) ){
 		error = true;
 		errorMessage->addPayload( 
@@ -405,11 +415,6 @@
 	}
 	
 	MikeyPayload * payload = *(lastPayload());
-	int i;
-	int macAlg;
-	byte_t * receivedMac;
-	byte_t * macInput;
-	unsigned int macInputLength;
 	list<MikeyPayload *>::iterator payload_i;
  
 	if( ka->rand() == NULL ){
@@ -433,118 +438,65 @@
 
 	if( type() == HDR_DATA_TYPE_PK_INIT )
 	{
-		MikeyPayloadKEMAC * kemac;
 		if( payload->payloadType() != MIKEYPAYLOAD_SIGN_PAYLOAD_TYPE){
 			throw MikeyException( 
 			   "PKE init did not end with a SIGN payload" );
 		}
-		
-		MikeyPayloadSIGN* sig = (MikeyPayloadSIGN*)extractPayload(MIKEYPAYLOAD_SIGN_PAYLOAD_TYPE);
-		
-		int res;
-		res = ka->getPublicKey()->verif_sign( rawMessageData(),
-						      rawMessageLength() - sig->sigLength(),
-						      sig->sigData(),
-						      sig->sigLength() );
-		if( res <= 0 ){
-			cout << "Verification of the PKE init message SIGN payload failed! Code: "  << res << endl;
+
+		// Fetch peer certificate chain
+		MRef<certificate_chain *> peerChain = ka->peerCertificateChain();
+		if( peerChain.isNull() || peerChain->get_first().isNull() ){
+			peerChain = extractCertificateChain();
+
+			if( peerChain.isNull() ){
+				ka->setAuthError( "No certificate was found" );
+				return true;
+			}
+
+			ka->setPeerCertificateChain( peerChain );
+		}
+
+ 		if( !verifySignature( peerChain->get_first() ) ){
+			cout << "Verification of the PKE init message SIGN payload failed!"  << endl;
 			cout << "Keypair of the initiator probably mismatch!" << endl;
 			return true;
 		}
 
-		kemac = (MikeyPayloadKEMAC *) extractPayload(MIKEYPAYLOAD_KEMAC_PAYLOAD_TYPE);
-		macAlg = kemac->macAlg();
-		receivedMac = kemac->macData();
-		
-		macInputLength = kemac->length();
-		macInput = new byte_t[macInputLength];
-
-		kemac->writeData( macInput, macInputLength );
-		macInput[0] = MIKEYPAYLOAD_LAST_PAYLOAD;
-		macInputLength -= 20; // Subtract mac data
-
 		ka->setCsbId( csbId() );
 
-		MikeyPayload *payloadPke =
-			extractPayload( MIKEYPAYLOAD_PKE_PAYLOAD_TYPE );
-		MikeyPayloadPKE *pke =
-			dynamic_cast<MikeyPayloadPKE*>( payloadPke );
-
-		if( !pke ){
-			throw MikeyException( "PKE init did not contain PKE payload" );
+		if( !extractPkeEnvKey( ka ) ){
+			throw MikeyException( "Decryption of envelope key failed" );
 		}
 
-		MRef<certificate*> cert = ka->getPublicKey();
-		int envKeyLength = pke->dataLength();
-		byte_t *envKey = new byte_t[ envKeyLength ];
-		
-		if( !cert->private_decrypt( pke->data(), pke->dataLength(),
-					    envKey, &envKeyLength ) ){
-			throw MikeyException( "Decryption of envelope key failed" );
+		if( !verifyKemac( ka ) ){
+			return true;
 		}
 
-		ka->setEnvelopeKey( envKey, envKeyLength );
-
-		delete[] envKey;
-		envKey = NULL;
+		return false;
 	}
 	else if( type() == HDR_DATA_TYPE_PK_RESP )
 	{
+		if( payload->payloadType() != MIKEYPAYLOAD_V_PAYLOAD_TYPE ){
+			throw MikeyException( 
+				"PKE response did not end with a V payload" );
+		}
+
 		if( ka->csbId() != csbId() ){
 			ka->setAuthError( "CSBID mismatch\n" );
 			return true;
 		}
-		MikeyPayloadV * v;
-		uint64_t t_sent = ka->tSent();
-		if( payload->payloadType() != MIKEYPAYLOAD_V_PAYLOAD_TYPE ){
-			throw MikeyException( 
-			   "PKE response did not end with a V payload" );
-		}
 
-		v = (MikeyPayloadV *)payload;
-		macAlg = v->macAlg();
-		receivedMac = v->verData();
-		// macInput = raw_messsage without mac / sent_t
-		macInputLength = rawMessageLength() - 20 + 8;
-		macInput = new byte_t[macInputLength];
-		memcpy( macInput, rawMessageData(), rawMessageLength() - 20 );
-		
-		for( i = 0; i < 8; i++ ){
-			macInput[ macInputLength - i - 1 ] = 
-				(byte_t)((t_sent >> (i*8))&0xFF);
+		if( !verifyV( ka ) ){
+			return true;
 		}
+
+		return false;
+
 	}
 	else{
 		throw MikeyException( "Invalide type for a PKE message" );
 	}
 
-	byte_t authKey[20];
-	byte_t computedMac[20];
-	unsigned int computedMacLength;
-	
-	switch( macAlg ){
-		case MIKEY_MAC_HMAC_SHA1_160:
-			ka->genTranspAuthKey( authKey, 20 );
-
-			hmac_sha1( authKey, 20,
-				   macInput,
-				   macInputLength,
-				   computedMac, &computedMacLength );
-
-			for( i = 0; i < 20; i++ ){
-				if( computedMac[i] != receivedMac[i] ){
-					ka->setAuthError(
-						"MAC mismatch."
-					);
-					return true;
-				}
-			}
-			return false;
-		case MIKEY_MAC_NULL:
-			return false;
-		default:
-			throw MikeyException( "Unknown MAC algorithm" );
-	}
 }
 
 bool MikeyMessagePKE::isInitiatorMessage() const{

Modified: trunk/libmikey/mikey/MikeyMessagePKE.h
===================================================================
--- trunk/libmikey/mikey/MikeyMessagePKE.h	2007-01-03 22:09:47 UTC (rev 3082)
+++ trunk/libmikey/mikey/MikeyMessagePKE.h	2007-01-03 23:22:12 UTC (rev 3083)
@@ -37,8 +37,7 @@
 		MikeyMessagePKE();
  		MikeyMessagePKE(KeyAgreementPKE* ka,
 				int encrAlg = MIKEY_ENCR_AES_CM_128,
-				int macAlg = MIKEY_MAC_HMAC_SHA1_160,
-				MRef<certificate*> certInitiator = NULL);
+				int macAlg = MIKEY_MAC_HMAC_SHA1_160 );
 
 		MikeyMessage * parseResponse( KeyAgreement  * ka );
 		void setOffer( KeyAgreement * ka );

Modified: trunk/libmikey/mikey/MikeyPayloadPKE.cxx
===================================================================
--- trunk/libmikey/mikey/MikeyPayloadPKE.cxx	2007-01-03 22:09:47 UTC (rev 3082)
+++ trunk/libmikey/mikey/MikeyPayloadPKE.cxx	2007-01-03 23:22:12 UTC (rev 3083)
@@ -90,11 +90,11 @@
 	return cValue;
 }
 
-int MikeyPayloadPKE::dataLength(){
+int MikeyPayloadPKE::dataLength() const{
 	return dataLengthValue;
 }
 
-byte_t * MikeyPayloadPKE::data(){
+const byte_t * MikeyPayloadPKE::data() const{
 	return dataPtr;
 }
 



More information about the Minisip-devel mailing list