xmlsecurityengine/xmlseccrypto/src/xmlsecc_evp.cpp
branchRCL_3
changeset 16 d10d750052f0
parent 8 e65204f75c47
child 24 74f0b3eb154c
--- a/xmlsecurityengine/xmlseccrypto/src/xmlsecc_evp.cpp	Thu Apr 01 00:31:02 2010 +0300
+++ b/xmlsecurityengine/xmlseccrypto/src/xmlsecc_evp.cpp	Tue Apr 27 18:31:15 2010 +0300
@@ -135,19 +135,21 @@
     ctxSrc = xmlSecSymbianCryptoEvpKeyDataGetCtx(src);
     xmlSecAssert2(ctxSrc, -1);
 
-    if(ctxSrc->pKey) {
+    if(ctxSrc->pKey) 
+    {
 	ctxDst->pKey = xmlSecSymbianCryptoEvpKeyDup(ctxSrc->pKey);
-            ctxDst->pKey->duplicate=0;
-            ctxSrc->pKey->duplicate=1;
-	if(!ctxDst->pKey) {
-	    xmlSecError(XMLSEC_ERRORS_HERE,
-			xmlSecErrorsSafeString(xmlSecKeyDataGetName(dst)),
-			"xmlSecSymbianCryptoEvpKeyDup",
-			XMLSEC_ERRORS_R_XMLSEC_FAILED,
-			XMLSEC_ERRORS_NO_MESSAGE);
-	    return(-1);
-	}	
-    } 
+	if(!ctxDst->pKey) 
+	    {
+	        xmlSecError(XMLSEC_ERRORS_HERE,
+	            xmlSecErrorsSafeString(xmlSecKeyDataGetName(dst)),
+	            "xmlSecSymbianCryptoEvpKeyDup",
+	            XMLSEC_ERRORS_R_XMLSEC_FAILED,
+	            XMLSEC_ERRORS_NO_MESSAGE);
+	        return(-1);
+	    }   
+     ctxDst->pKey->duplicate=0;
+     ctxSrc->pKey->duplicate=1;
+     } 
 
     return(0);
 }
@@ -1401,6 +1403,7 @@
 	return(-1);	
     }
 
+	/*
     if(!rsa) {
 	xmlSecError(XMLSEC_ERRORS_HERE,
 		    xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
@@ -1409,7 +1412,7 @@
 		    XMLSEC_ERRORS_NO_MESSAGE);
 	return(-1);
     }
-
+	*/
     cur = xmlSecGetNextElementNode(node->children);
     
     /* first is Modulus node. It is REQUIRED because we do not support Seed and PgenCounter*/
@@ -1652,6 +1655,7 @@
 		    "sc_load_key",
 		    XMLSEC_ERRORS_R_CRYPTO_FAILED,
 		    "sizeBits=%d", sizeBits);
+	sc_pkey_free(pKey);
 	return(-1);  
     }	
 		
@@ -1667,17 +1671,22 @@
 		    "sc_generate_key",
 		    XMLSEC_ERRORS_R_CRYPTO_FAILED,
 		    "sizeBits=%d", sizeBits);
-	            return(-1);      
+			sc_pkey_free(pKey);
+	        return(-1);      
 		}
 	}		
-	if (!pKey->load) {
-	xmlSecError(XMLSEC_ERRORS_HERE,
+	if (!pKey->load) 
+		{
+	
+		xmlSecError(XMLSEC_ERRORS_HERE,
 		    xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
 		    "sc_generate_key",
 		    XMLSEC_ERRORS_R_CRYPTO_FAILED,
 		    "sizeBits=%d", sizeBits);
-	return(-1);  
-    }	
+		
+		sc_pkey_free(pKey);
+		return(-1);  
+		}	
 
     ret = xmlSecSymbianCryptoKeyDataRsaAdoptEvp(data, pKey);
     if(ret < 0) {
@@ -1705,6 +1714,7 @@
 	return(-1);
     }
 */
+    sc_pkey_free(pKey);
     return(0);
 }