From a60b281780f0d3e063c6ea4c8dcd65880a8e4968 Mon Sep 17 00:00:00 2001
From: Brad Hards <bradh@frogmouth.net>
Date: Fri, 17 Nov 2006 05:06:47 +0000
Subject: [PATCH] Remove the "withAlgorithm" method, which doesn't really make
 sense with our new approach to using MessageAuthenticationCode directly.

Also a few random whitepace changes, brought to you by
.xemacs.

svn path=/trunk/kdesupport/qca/; revision=605535
---
 examples/aes-cmac/aes-cmac.cpp | 32 ++++++++++++++++----------------
 include/QtCrypto/qca_basic.h   |  9 ---------
 src/qca_basic.cpp              |  7 +------
 3 files changed, 17 insertions(+), 31 deletions(-)

diff --git a/examples/aes-cmac/aes-cmac.cpp b/examples/aes-cmac/aes-cmac.cpp
index ff921190..cc36fbad 100644
--- a/examples/aes-cmac/aes-cmac.cpp
+++ b/examples/aes-cmac/aes-cmac.cpp
@@ -7,10 +7,10 @@
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:
- 
+
  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.
- 
+
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
@@ -79,7 +79,7 @@ public:
     {
 	// We might not have a real key, since this can get called
 	// from the constructor.
-	if (key.size() == 0) 
+	if (key.size() == 0)
 	    return;
 
 	m_key = key;
@@ -96,11 +96,11 @@ public:
 			   QCA::Cipher::ECB, QCA::Cipher::DefaultPadding,
 			   QCA::Encode, key);
 	QSecureArray L = aesObj.process(const_Zero);
-	
+
 	// Figure 2.2, step 2
 	if (0 == (L[0] & 0x80))
 	    m_k1 = leftShift(L);
-	else 
+	else
 	    m_k1 = xorArray(leftShift(L), const_Rb);
 
 	// Figure 2.2, step 3
@@ -189,7 +189,7 @@ protected:
     QSecureArray m_Y;
 
     // partial block that we can't do yet
-    QSecureArray m_residual; 
+    QSecureArray m_residual;
 };
 
 class ClientSideProvider : public QCA::Provider
@@ -231,9 +231,9 @@ public:
 class AES_CMAC: public QCA::MessageAuthenticationCode
 {
 public:
-    AES_CMAC(const QCA::SymmetricKey &key = QCA::SymmetricKey(), 
+    AES_CMAC(const QCA::SymmetricKey &key = QCA::SymmetricKey(),
 	     const QString &provider = QString()):
-	QCA::MessageAuthenticationCode(QCA::MessageAuthenticationCode::withAlgorithm("cmac", "aes"), key, provider)
+	QCA::MessageAuthenticationCode( "cmac(aes)", key, provider)
     {}
 };
 
@@ -241,7 +241,7 @@ public:
 int main(int argc, char **argv)
 {
     QCoreApplication app(argc, argv);
-    
+
     qDebug() << "This example shows AES CMAC";
 
     // the Initializer object sets things up, and
@@ -256,7 +256,7 @@ int main(int argc, char **argv)
 
     if ( QCA::insertProvider(new ClientSideProvider, 0) )
 	qDebug() << "Inserted our provider";
-    else 
+    else
 	qDebug() << "our provider could not be added";
 
     // We should check AES CMAC is supported before using it.
@@ -265,16 +265,16 @@ int main(int argc, char **argv)
     } else {
 	// create the required object
 	AES_CMAC cmacObject;
-	
+
 	// create the key
 	QCA::SymmetricKey key(QCA::hexToArray("2b7e151628aed2a6abf7158809cf4f3c"));
-	
-	// set the MAC to use the key 
+
+	// set the MAC to use the key
 	cmacObject.setup(key);
-	
+
 	QSecureArray message = QCA::hexToArray("6bc1bee22e409f96e93d7e117393172a"
-					       "ae2d8a571e03ac9c9eb76fac45af8e51" 
-					       "30c81c46a35ce411e5fbc1191a0a52ef" 
+					       "ae2d8a571e03ac9c9eb76fac45af8e51"
+					       "30c81c46a35ce411e5fbc1191a0a52ef"
 					       "f69f2445df4f9b17ad2b417be66c3710");
 	QSecureArray message1(message);
 	message1.resize(0);
diff --git a/include/QtCrypto/qca_basic.h b/include/QtCrypto/qca_basic.h
index b81a57ef..2790e6dd 100644
--- a/include/QtCrypto/qca_basic.h
+++ b/include/QtCrypto/qca_basic.h
@@ -737,15 +737,6 @@ namespace QCA
 		 */
 		void setup(const SymmetricKey &key);
 
-		/**
-		 * Construct the name of the algorithm
-		 *
-		 * You can use this to build a standard name string.
-		 * You probably only need this method if you are 
-		 * creating a new subclass.
-		 */
-		static QString withAlgorithm(const QString &macType, const QString &algType);
-
 	private:
 		class Private;
 		Private *d;
diff --git a/src/qca_basic.cpp b/src/qca_basic.cpp
index b938ec0c..439c871a 100644
--- a/src/qca_basic.cpp
+++ b/src/qca_basic.cpp
@@ -133,7 +133,7 @@ public:
 };
 
 Cipher::Cipher( const QString &type, Mode m, Padding pad,
-	Direction dir, const SymmetricKey &key, 
+	Direction dir, const SymmetricKey &key,
 	const InitializationVector &iv,
 	const QString &provider )
 :Algorithm(withAlgorithms( type, m, pad ), provider)
@@ -338,11 +338,6 @@ void MessageAuthenticationCode::setup(const SymmetricKey &key)
 	clear();
 }
 
-QString MessageAuthenticationCode::withAlgorithm(const QString &macType, const QString &algType)
-{
-	return (macType + '(' + algType + ')');
-}
-
 //----------------------------------------------------------------------------
 // Key Derivation Function
 //----------------------------------------------------------------------------