xmlsecurityengine/xmlsec/src/xmlsec_keys.c
branchRCL_3
changeset 16 d10d750052f0
parent 0 e35f40988205
child 24 74f0b3eb154c
equal deleted inserted replaced
14:361f875fa818 16:d10d750052f0
   167     xmlSecKeyUseWithPtr newKeyUseWith;
   167     xmlSecKeyUseWithPtr newKeyUseWith;
   168 
   168 
   169     xmlSecAssert2(keyUseWith != NULL, NULL);
   169     xmlSecAssert2(keyUseWith != NULL, NULL);
   170 
   170 
   171     newKeyUseWith = xmlSecKeyUseWithCreate(NULL, NULL);
   171     newKeyUseWith = xmlSecKeyUseWithCreate(NULL, NULL);
   172     if(newKeyUseWith == NULL) {
   172     if(newKeyUseWith == NULL) 
       
   173         {
       
   174         xmlSecError(XMLSEC_ERRORS_HERE,
       
   175 		    NULL,
       
   176 		    "xmlSecKeyUseWithCreate",
       
   177 		    XMLSEC_ERRORS_R_XMLSEC_FAILED,
       
   178 		    XMLSEC_ERRORS_NO_MESSAGE);
       
   179         return(NULL);        
       
   180         }
       
   181 
       
   182     ret = xmlSecKeyUseWithCopy(newKeyUseWith, keyUseWith);
       
   183     if(ret < 0) 
       
   184         {
   173     	xmlSecError(XMLSEC_ERRORS_HERE,
   185     	xmlSecError(XMLSEC_ERRORS_HERE,
   174 		    NULL,
   186 		    NULL,
   175 		    "xmlSecKeyUseWithCreate",
   187 		    "xmlSecKeyUseWithCopy",
   176 		    XMLSEC_ERRORS_R_XMLSEC_FAILED,
   188 		    XMLSEC_ERRORS_R_XMLSEC_FAILED,
   177 		    XMLSEC_ERRORS_NO_MESSAGE);
   189 		    XMLSEC_ERRORS_NO_MESSAGE);
       
   190 		xmlSecKeyUseWithDestroy(keyUseWith);
       
   191         xmlSecKeyUseWithDestroy( newKeyUseWith);
   178         return(NULL);        
   192         return(NULL);        
   179     }
   193         }
   180 
       
   181     ret = xmlSecKeyUseWithCopy(newKeyUseWith, keyUseWith);
       
   182     if(ret < 0) {
       
   183     	xmlSecError(XMLSEC_ERRORS_HERE,
       
   184 		    NULL,
       
   185 		    "xmlSecKeyUseWithCopy",
       
   186 		    XMLSEC_ERRORS_R_XMLSEC_FAILED,
       
   187 		    XMLSEC_ERRORS_NO_MESSAGE);
       
   188         xmlSecKeyUseWithDestroy(keyUseWith);
       
   189         return(NULL);        
       
   190     }
       
   191 
   194 
   192     return(newKeyUseWith);
   195     return(newKeyUseWith);
   193 }
   196 }
   194 
   197 
   195 /** 
   198 /** 
  1382 	return(NULL);
  1385 	return(NULL);
  1383     }
  1386     }
  1384 
  1387 
  1385     if(keyInfoNode != NULL) {
  1388     if(keyInfoNode != NULL) {
  1386 	ret = xmlSecKeyInfoNodeRead(keyInfoNode, key, keyInfoCtx);
  1389 	ret = xmlSecKeyInfoNodeRead(keyInfoNode, key, keyInfoCtx);
  1387 	if(ret < 0) {
  1390 	if(ret < 0) 
  1388 	    xmlSecError(XMLSEC_ERRORS_HERE,
  1391 	    {
       
  1392         xmlSecError(XMLSEC_ERRORS_HERE,
  1389 			NULL,
  1393 			NULL,
  1390 			"xmlSecKeyInfoNodeRead",
  1394 			"xmlSecKeyInfoNodeRead",
  1391 			XMLSEC_ERRORS_R_XMLSEC_FAILED,
  1395 			XMLSEC_ERRORS_R_XMLSEC_FAILED,
  1392 			"node=%s",
  1396 			"node=%s",
  1393 			xmlSecErrorsSafeString(xmlSecNodeGetName(keyInfoNode)));
  1397 			xmlSecErrorsSafeString(xmlSecNodeGetName(keyInfoNode)));
  1401         }
  1405         }
  1402     }	
  1406     }	
  1403         tempkey=xmlSecKeyDuplicate(key);
  1407         tempkey=xmlSecKeyDuplicate(key);
  1404         if(tempkey == NULL) 
  1408         if(tempkey == NULL) 
  1405             {
  1409             {
  1406 	    xmlSecError(XMLSEC_ERRORS_HERE,
  1410             xmlSecError(XMLSEC_ERRORS_HERE,
  1407 			NULL,
  1411                     NULL,
  1408 			"xmlSecKeysMngrFindKey",
  1412                     "xmlSecKeysMngrFindKey",
  1409 			XMLSEC_ERRORS_R_XMLSEC_FAILED,
  1413                     XMLSEC_ERRORS_R_XMLSEC_FAILED,
  1410 			XMLSEC_ERRORS_NO_MESSAGE);
  1414                     XMLSEC_ERRORS_NO_MESSAGE);
  1411 	    return(NULL);
  1415             xmlSecKeyDestroy(key);
       
  1416             return(NULL);
  1412             }
  1417             }
  1413         keyname=xmlSecKeyGetName(tempkey);	
  1418     keyname=xmlSecKeyGetName(tempkey);	
  1414     xmlSecKeyDestroy(key);
  1419     xmlSecKeyDestroy(key);
  1415     
  1420     
  1416     /* if we have keys manager, try it */
  1421     /* if we have keys manager, try it */
  1417     if(keyInfoCtx->keysMngr != NULL) {
  1422     if(keyInfoCtx->keysMngr != NULL) 
  1418 	key = xmlSecKeysMngrFindKey(keyInfoCtx->keysMngr, keyname /*NULL*/, keyInfoCtx);
  1423 		{
  1419          xmlSecKeyDestroy(tempkey);
  1424 		key = xmlSecKeysMngrFindKey(keyInfoCtx->keysMngr, keyname /*NULL*/, keyInfoCtx);
  1420         	if(key == NULL) {
  1425         	if(key == NULL) 
  1421 	    xmlSecError(XMLSEC_ERRORS_HERE,
  1426 				{
  1422 			NULL,
  1427 				xmlSecError(XMLSEC_ERRORS_HERE,
  1423 			"xmlSecKeysMngrFindKey",
  1428 					NULL,
  1424 			XMLSEC_ERRORS_R_XMLSEC_FAILED,
  1429 					"xmlSecKeysMngrFindKey",
  1425 			XMLSEC_ERRORS_NO_MESSAGE);
  1430 					XMLSEC_ERRORS_R_XMLSEC_FAILED,
  1426 	    return(NULL);
  1431 					XMLSEC_ERRORS_NO_MESSAGE);
  1427 	}
  1432 				 xmlSecKeyDestroy(tempkey);
  1428 	if(xmlSecKeyGetValue(key) != NULL) {
  1433 				return(NULL);
  1429 	    return(key);
  1434 				}
  1430 	}
  1435 		if(xmlSecKeyGetValue(key) != NULL) 
  1431 	xmlSecKeyDestroy(key);
  1436 			{
  1432     }
  1437 			xmlSecKeyDestroy(tempkey);
       
  1438 			return(key);
       
  1439 			}
       
  1440 		xmlSecKeyDestroy(key);
       
  1441 		}
  1433     
  1442     
  1434     xmlSecError(XMLSEC_ERRORS_HERE,
  1443     xmlSecError(XMLSEC_ERRORS_HERE,
  1435 		NULL,
  1444 		NULL,
  1436 		NULL,
  1445 		NULL,
  1437 		XMLSEC_ERRORS_R_KEY_NOT_FOUND,
  1446 		XMLSEC_ERRORS_R_KEY_NOT_FOUND,
  1438 		XMLSEC_ERRORS_NO_MESSAGE);    
  1447 		XMLSEC_ERRORS_NO_MESSAGE);  
       
  1448     xmlSecKeyDestroy(tempkey);
  1439     return(NULL);
  1449     return(NULL);
  1440 }
  1450 }
  1441 
  1451 
  1442 /***********************************************************************
  1452 /***********************************************************************
  1443  *
  1453  *