santuario-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scan...@apache.org
Subject svn commit: r991666 - in /xml/security/trunk/c: ./ src/dsig/ src/framework/ src/xenc/impl/
Date Wed, 01 Sep 2010 19:36:57 GMT
Author: scantor
Date: Wed Sep  1 19:36:57 2010
New Revision: 991666

URL: http://svn.apache.org/viewvc?rev=991666&view=rev
Log:
Distinguish classes of algorithms using method on AlgHandler.

Modified:
    xml/security/trunk/c/CHANGELOG.txt
    xml/security/trunk/c/src/dsig/DSIGAlgorithmHandlerDefault.cpp
    xml/security/trunk/c/src/dsig/DSIGAlgorithmHandlerDefault.hpp
    xml/security/trunk/c/src/framework/XSECAlgorithmHandler.hpp
    xml/security/trunk/c/src/xenc/impl/XENCAlgorithmHandlerDefault.cpp
    xml/security/trunk/c/src/xenc/impl/XENCAlgorithmHandlerDefault.hpp

Modified: xml/security/trunk/c/CHANGELOG.txt
URL: http://svn.apache.org/viewvc/xml/security/trunk/c/CHANGELOG.txt?rev=991666&r1=991665&r2=991666&view=diff
==============================================================================
--- xml/security/trunk/c/CHANGELOG.txt (original)
+++ xml/security/trunk/c/CHANGELOG.txt Wed Sep  1 19:36:57 2010
@@ -16,6 +16,7 @@ Changes since 1.5.1
 * Add selected XML Signature 1.1 KeyInfo extensions (SC)
 * Add elliptic curve signatures via ECDSA (SC)
 * Support debugging of Reference/SignedInfo data (SC)
+* Support distinguishing types of algorithms using AlgorithmHandler (SC)
 
 Changes between 1.5 and 1.5.1
 =====================================

Modified: xml/security/trunk/c/src/dsig/DSIGAlgorithmHandlerDefault.cpp
URL: http://svn.apache.org/viewvc/xml/security/trunk/c/src/dsig/DSIGAlgorithmHandlerDefault.cpp?rev=991666&r1=991665&r2=991666&view=diff
==============================================================================
--- xml/security/trunk/c/src/dsig/DSIGAlgorithmHandlerDefault.cpp (original)
+++ xml/security/trunk/c/src/dsig/DSIGAlgorithmHandlerDefault.cpp Wed Sep  1 19:36:57 2010
@@ -185,6 +185,21 @@ void convertRawToBase64String(safeBuffer
 
 }
 
+XSECAlgorithmHandler::AlgorithmClassType DSIGAlgorithmHandlerDefault::getAlgorithmClass(const
XMLCh* alg) const {
+
+	signatureMethod sm;
+	hashMethod hm;
+
+	if (XSECmapURIToHashMethod(alg, hm))
+        return ALG_DIGEST;
+
+	if (XSECmapURIToSignatureMethods(alg, sm, hm)) {
+        return (sm == SIGNATURE_HMAC) ? ALG_HMAC : ALG_DSIG;
+    }
+
+    return ALG_NONE;
+}
+
 // --------------------------------------------------------------------------------
 //			Clone
 // --------------------------------------------------------------------------------

Modified: xml/security/trunk/c/src/dsig/DSIGAlgorithmHandlerDefault.hpp
URL: http://svn.apache.org/viewvc/xml/security/trunk/c/src/dsig/DSIGAlgorithmHandlerDefault.hpp?rev=991666&r1=991665&r2=991666&view=diff
==============================================================================
--- xml/security/trunk/c/src/dsig/DSIGAlgorithmHandlerDefault.hpp (original)
+++ xml/security/trunk/c/src/dsig/DSIGAlgorithmHandlerDefault.hpp Wed Sep  1 19:36:57 2010
@@ -45,6 +45,7 @@ public:
 	
 	virtual ~DSIGAlgorithmHandlerDefault() {};
 
+    virtual AlgorithmClassType getAlgorithmClass(const XMLCh* alg) const;
 
 	virtual XSECAlgorithmHandler * clone(void) const;
 

Modified: xml/security/trunk/c/src/framework/XSECAlgorithmHandler.hpp
URL: http://svn.apache.org/viewvc/xml/security/trunk/c/src/framework/XSECAlgorithmHandler.hpp?rev=991666&r1=991665&r2=991666&view=diff
==============================================================================
--- xml/security/trunk/c/src/framework/XSECAlgorithmHandler.hpp (original)
+++ xml/security/trunk/c/src/framework/XSECAlgorithmHandler.hpp Wed Sep  1 19:36:57 2010
@@ -78,6 +78,34 @@ public:
 
 	//@}
 
+	/**
+	 * \brief Algorithm types understood by the library
+	 *
+	 * This type defines the list of algorithm classes that the library
+	 * understands.
+	 */
+
+	enum AlgorithmClassType {
+
+		ALG_NONE,
+        ALG_DIGEST,
+        ALG_DSIG,
+        ALG_HMAC,
+        ALG_ENC,
+        ALG_KEYWRAP,
+        ALG_KEYTRAN,
+        ALG_KEYAGREE,
+        ALG_KEYDERIV
+	};
+
+	/**
+	 * \brief Returns the general class of an algorithm.
+     *
+     * @param alg   algorithm URI
+	 */
+
+	virtual AlgorithmClassType getAlgorithmClass(const XMLCh* alg) const {return ALG_NONE;}
+
 	/** @name Encryption Methods */
 	//@{
 

Modified: xml/security/trunk/c/src/xenc/impl/XENCAlgorithmHandlerDefault.cpp
URL: http://svn.apache.org/viewvc/xml/security/trunk/c/src/xenc/impl/XENCAlgorithmHandlerDefault.cpp?rev=991666&r1=991665&r2=991666&view=diff
==============================================================================
--- xml/security/trunk/c/src/xenc/impl/XENCAlgorithmHandlerDefault.cpp (original)
+++ xml/security/trunk/c/src/xenc/impl/XENCAlgorithmHandlerDefault.cpp Wed Sep  1 19:36:57
2010
@@ -71,6 +71,27 @@ unsigned char s_AES_IV [] = {
 
 };
 
+XSECAlgorithmHandler::AlgorithmClassType XENCAlgorithmHandlerDefault::getAlgorithmClass(const
XMLCh* alg) const {
+
+    if (strEquals(alg, DSIGConstants::s_unicodeStrURIRSA_1_5) ||
+        strEquals(alg, DSIGConstants::s_unicodeStrURIRSA_OAEP_MGFP1))
+        return ALG_KEYTRAN;
+
+	if (strEquals(alg, DSIGConstants::s_unicodeStrURI3DES_CBC) ||
+        strEquals(alg, DSIGConstants::s_unicodeStrURIAES128_CBC) ||
+        strEquals(alg, DSIGConstants::s_unicodeStrURIAES192_CBC) ||
+        strEquals(alg, DSIGConstants::s_unicodeStrURIAES256_CBC))
+        return ALG_ENC;
+
+	if (strEquals(alg, DSIGConstants::s_unicodeStrURIKW_3DES) ||
+        strEquals(alg, DSIGConstants::s_unicodeStrURIKW_AES128) ||
+        strEquals(alg, DSIGConstants::s_unicodeStrURIKW_AES192) ||
+        strEquals(alg, DSIGConstants::s_unicodeStrURIKW_AES256))
+        return ALG_KEYWRAP;
+
+    return ALG_NONE;
+}
+
 // --------------------------------------------------------------------------------
 //			Compare URI to key type
 // --------------------------------------------------------------------------------

Modified: xml/security/trunk/c/src/xenc/impl/XENCAlgorithmHandlerDefault.hpp
URL: http://svn.apache.org/viewvc/xml/security/trunk/c/src/xenc/impl/XENCAlgorithmHandlerDefault.hpp?rev=991666&r1=991665&r2=991666&view=diff
==============================================================================
--- xml/security/trunk/c/src/xenc/impl/XENCAlgorithmHandlerDefault.hpp (original)
+++ xml/security/trunk/c/src/xenc/impl/XENCAlgorithmHandlerDefault.hpp Wed Sep  1 19:36:57
2010
@@ -45,6 +45,7 @@ public:
 	
 	virtual ~XENCAlgorithmHandlerDefault() {};
 
+    virtual AlgorithmClassType getAlgorithmClass(const XMLCh* alg) const;
 
 	virtual unsigned int decryptToSafeBuffer(
 		TXFMChain * cipherText,



Mime
View raw message