xmlsecurityengine/xmlseccrypto/src/xmlsecc_evp.cpp
changeset 17 ed3155dbd163
parent 15 9b1f1fe06753
child 24 74f0b3eb154c
equal deleted inserted replaced
15:9b1f1fe06753 17:ed3155dbd163
   133     xmlSecAssert2(!ctxDst->pKey, -1);
   133     xmlSecAssert2(!ctxDst->pKey, -1);
   134 
   134 
   135     ctxSrc = xmlSecSymbianCryptoEvpKeyDataGetCtx(src);
   135     ctxSrc = xmlSecSymbianCryptoEvpKeyDataGetCtx(src);
   136     xmlSecAssert2(ctxSrc, -1);
   136     xmlSecAssert2(ctxSrc, -1);
   137 
   137 
   138     if(ctxSrc->pKey) {
   138     if(ctxSrc->pKey) 
       
   139     {
   139 	ctxDst->pKey = xmlSecSymbianCryptoEvpKeyDup(ctxSrc->pKey);
   140 	ctxDst->pKey = xmlSecSymbianCryptoEvpKeyDup(ctxSrc->pKey);
   140             ctxDst->pKey->duplicate=0;
   141 	if(!ctxDst->pKey) 
   141             ctxSrc->pKey->duplicate=1;
   142 	    {
   142 	if(!ctxDst->pKey) {
   143 	        xmlSecError(XMLSEC_ERRORS_HERE,
   143 	    xmlSecError(XMLSEC_ERRORS_HERE,
   144 	            xmlSecErrorsSafeString(xmlSecKeyDataGetName(dst)),
   144 			xmlSecErrorsSafeString(xmlSecKeyDataGetName(dst)),
   145 	            "xmlSecSymbianCryptoEvpKeyDup",
   145 			"xmlSecSymbianCryptoEvpKeyDup",
   146 	            XMLSEC_ERRORS_R_XMLSEC_FAILED,
   146 			XMLSEC_ERRORS_R_XMLSEC_FAILED,
   147 	            XMLSEC_ERRORS_NO_MESSAGE);
   147 			XMLSEC_ERRORS_NO_MESSAGE);
   148 	        return(-1);
   148 	    return(-1);
   149 	    }   
   149 	}	
   150      ctxDst->pKey->duplicate=0;
   150     } 
   151      ctxSrc->pKey->duplicate=1;
       
   152      } 
   151 
   153 
   152     return(0);
   154     return(0);
   153 }
   155 }
   154 
   156 
   155 static void
   157 static void
  1399 		    XMLSEC_ERRORS_R_INVALID_KEY_DATA,
  1401 		    XMLSEC_ERRORS_R_INVALID_KEY_DATA,
  1400 		    "key already has a value");
  1402 		    "key already has a value");
  1401 	return(-1);	
  1403 	return(-1);	
  1402     }
  1404     }
  1403 
  1405 
       
  1406 	/*
  1404     if(!rsa) {
  1407     if(!rsa) {
  1405 	xmlSecError(XMLSEC_ERRORS_HERE,
  1408 	xmlSecError(XMLSEC_ERRORS_HERE,
  1406 		    xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
  1409 		    xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
  1407 		    "RSA_new",
  1410 		    "RSA_new",
  1408 		    XMLSEC_ERRORS_R_CRYPTO_FAILED,
  1411 		    XMLSEC_ERRORS_R_CRYPTO_FAILED,
  1409 		    XMLSEC_ERRORS_NO_MESSAGE);
  1412 		    XMLSEC_ERRORS_NO_MESSAGE);
  1410 	return(-1);
  1413 	return(-1);
  1411     }
  1414     }
  1412 
  1415 	*/
  1413     cur = xmlSecGetNextElementNode(node->children);
  1416     cur = xmlSecGetNextElementNode(node->children);
  1414     
  1417     
  1415     /* first is Modulus node. It is REQUIRED because we do not support Seed and PgenCounter*/
  1418     /* first is Modulus node. It is REQUIRED because we do not support Seed and PgenCounter*/
  1416     if((!cur) || (!xmlSecCheckNodeName(cur,  xmlSecNodeRSAModulus, xmlSecDSigNs))) {
  1419     if((!cur) || (!xmlSecCheckNodeName(cur,  xmlSecNodeRSAModulus, xmlSecDSigNs))) {
  1417 	xmlSecError(XMLSEC_ERRORS_HERE,
  1420 	xmlSecError(XMLSEC_ERRORS_HERE,
  1650 	xmlSecError(XMLSEC_ERRORS_HERE,
  1653 	xmlSecError(XMLSEC_ERRORS_HERE,
  1651 		    xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
  1654 		    xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
  1652 		    "sc_load_key",
  1655 		    "sc_load_key",
  1653 		    XMLSEC_ERRORS_R_CRYPTO_FAILED,
  1656 		    XMLSEC_ERRORS_R_CRYPTO_FAILED,
  1654 		    "sizeBits=%d", sizeBits);
  1657 		    "sizeBits=%d", sizeBits);
       
  1658 	sc_pkey_free(pKey);
  1655 	return(-1);  
  1659 	return(-1);  
  1656     }	
  1660     }	
  1657 		
  1661 		
  1658 	// Generate key if key is not found		
  1662 	// Generate key if key is not found		
  1659 	if (ret == -1)	// KErrNotFound
  1663 	if (ret == -1)	// KErrNotFound
  1665 		    xmlSecError(XMLSEC_ERRORS_HERE,
  1669 		    xmlSecError(XMLSEC_ERRORS_HERE,
  1666 		    xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
  1670 		    xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
  1667 		    "sc_generate_key",
  1671 		    "sc_generate_key",
  1668 		    XMLSEC_ERRORS_R_CRYPTO_FAILED,
  1672 		    XMLSEC_ERRORS_R_CRYPTO_FAILED,
  1669 		    "sizeBits=%d", sizeBits);
  1673 		    "sizeBits=%d", sizeBits);
  1670 	            return(-1);      
  1674 			sc_pkey_free(pKey);
       
  1675 	        return(-1);      
  1671 		}
  1676 		}
  1672 	}		
  1677 	}		
  1673 	if (!pKey->load) {
  1678 	if (!pKey->load) 
  1674 	xmlSecError(XMLSEC_ERRORS_HERE,
  1679 		{
       
  1680 	
       
  1681 		xmlSecError(XMLSEC_ERRORS_HERE,
  1675 		    xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
  1682 		    xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
  1676 		    "sc_generate_key",
  1683 		    "sc_generate_key",
  1677 		    XMLSEC_ERRORS_R_CRYPTO_FAILED,
  1684 		    XMLSEC_ERRORS_R_CRYPTO_FAILED,
  1678 		    "sizeBits=%d", sizeBits);
  1685 		    "sizeBits=%d", sizeBits);
  1679 	return(-1);  
  1686 		
  1680     }	
  1687 		sc_pkey_free(pKey);
       
  1688 		return(-1);  
       
  1689 		}	
  1681 
  1690 
  1682     ret = xmlSecSymbianCryptoKeyDataRsaAdoptEvp(data, pKey);
  1691     ret = xmlSecSymbianCryptoKeyDataRsaAdoptEvp(data, pKey);
  1683     if(ret < 0) {
  1692     if(ret < 0) {
  1684 	xmlSecError(XMLSEC_ERRORS_HERE,
  1693 	xmlSecError(XMLSEC_ERRORS_HERE,
  1685 		    xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
  1694 		    xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
  1703 		    XMLSEC_ERRORS_NO_MESSAGE);
  1712 		    XMLSEC_ERRORS_NO_MESSAGE);
  1704 	RSA_free(rsa);
  1713 	RSA_free(rsa);
  1705 	return(-1);
  1714 	return(-1);
  1706     }
  1715     }
  1707 */
  1716 */
       
  1717     sc_pkey_free(pKey);
  1708     return(0);
  1718     return(0);
  1709 }
  1719 }
  1710 
  1720 
  1711 static xmlSecKeyDataType
  1721 static xmlSecKeyDataType
  1712 xmlSecSymbianCryptoKeyDataRsaGetType(xmlSecKeyDataPtr data) {
  1722 xmlSecSymbianCryptoKeyDataRsaGetType(xmlSecKeyDataPtr data) {