lime.c: temporary remove clang-not-compiling checks

This commit is contained in:
Gautier Pelloux-Prayer 2015-03-17 11:28:20 +01:00
parent 8f03913001
commit 2bc09231d5

View file

@ -93,20 +93,20 @@ int lime_getSelfZid(xmlDocPtr cacheBuffer, uint8_t selfZid[25]) {
xmlNodePtr cur;
xmlChar *selfZidHex;
if (cacheBuffer == NULL ) {
return LIME_INVALID_CACHE;
if (cacheBuffer == NULL ) {
return LIME_INVALID_CACHE;
}
cur = xmlDocGetRootElement(cacheBuffer);
/* if we found a root element, parse its children node */
if (cur!=NULL)
if (cur!=NULL)
{
cur = cur->xmlChildrenNode;
}
selfZidHex = NULL;
while (cur!=NULL) {
if ((!xmlStrcmp(cur->name, (const xmlChar *)"selfZID"))){ /* self ZID found, extract it */
selfZidHex = xmlNodeListGetString(cacheBuffer, cur->xmlChildrenNode, 1);
selfZidHex = xmlNodeListGetString(cacheBuffer, cur->xmlChildrenNode, 1);
/* copy it to the output buffer and add the null termination */
memcpy(selfZid, selfZidHex, 24);
selfZid[24]='\0';
@ -126,7 +126,7 @@ int lime_getSelfZid(xmlDocPtr cacheBuffer, uint8_t selfZid[25]) {
int lime_getCachedSndKeysByURI(xmlDocPtr cacheBuffer, limeURIKeys_t *associatedKeys) {
xmlNodePtr cur;
/* parse the file to get all peer matching the sipURI given in associatedKeys*/
if (cacheBuffer == NULL ) { /* there is no cache return error */
return LIME_INVALID_CACHE;
@ -138,7 +138,7 @@ int lime_getCachedSndKeysByURI(xmlDocPtr cacheBuffer, limeURIKeys_t *associatedK
cur = xmlDocGetRootElement(cacheBuffer);
/* if we found a root element, parse its children node */
if (cur!=NULL)
if (cur!=NULL)
{
cur = cur->xmlChildrenNode;
}
@ -165,7 +165,7 @@ int lime_getCachedSndKeysByURI(xmlDocPtr cacheBuffer, limeURIKeys_t *associatedK
limeKey_t *currentPeerKeys = (limeKey_t *)malloc(sizeof(limeKey_t));
uint8_t itemFound = 0; /* count the item found, we must get all of the requested infos: 5 nodes*/
uint8_t pvs = 0;
peerNodeChildren = cur->xmlChildrenNode; /* reset peerNodeChildren to the first child of node */
while (peerNodeChildren!=NULL && itemFound<5) {
xmlChar *nodeContent = NULL;
@ -239,7 +239,7 @@ int lime_getCachedRcvKeyByZid(xmlDocPtr cacheBuffer, limeKey_t *associatedKey) {
cur = xmlDocGetRootElement(cacheBuffer);
/* if we found a root element, parse its children node */
if (cur!=NULL)
if (cur!=NULL)
{
cur = cur->xmlChildrenNode;
@ -313,7 +313,7 @@ int lime_setCachedKey(xmlDocPtr cacheBuffer, limeKey_t *associatedKey, uint8_t r
cur = xmlDocGetRootElement(cacheBuffer);
/* if we found a root element, parse its children node */
if (cur!=NULL)
if (cur!=NULL)
{
cur = cur->xmlChildrenNode;
@ -375,7 +375,7 @@ int lime_setCachedKey(xmlDocPtr cacheBuffer, limeKey_t *associatedKey, uint8_t r
cur = cur->next;
}
return 0;
}
@ -387,9 +387,12 @@ int lime_deriveKey(limeKey_t *key) {
return LIME_UNABLE_TO_DERIVE_KEY;
}
#if 0
/*not doing anything yet since key and sessionId are array, not pointers*/
if ((key->key == NULL) || (key->sessionId == NULL)) {
return LIME_UNABLE_TO_DERIVE_KEY;
}
#endif
/* Derivation is made derived Key = HMAC_SHA256(Key, 0x0000001||"MessageKey"||0x00||SessionId||SessionIndex||0x00000100)*/
/* total data to be hashed is 55 bytes : 4 + 10 + 1 + 32 + 4 + 4 */
@ -397,18 +400,18 @@ int lime_deriveKey(limeKey_t *key) {
inputData[1] = 0x00;
inputData[2] = 0x00;
inputData[3] = 0x01;
memcpy(inputData+4, "MessageKey", 10);
inputData[14] = 0x00;
memcpy(inputData+15, key->sessionId, 32);
inputData[47] = (uint8_t)((key->sessionIndex>>24)&0x000000FF);
inputData[48] = (uint8_t)((key->sessionIndex>>16)&0x000000FF);
inputData[49] = (uint8_t)((key->sessionIndex>>8)&0x000000FF);
inputData[50] = (uint8_t)(key->sessionIndex&0x000000FF);
inputData[51] = 0x00;
inputData[52] = 0x00;
inputData[53] = 0x01;
@ -501,7 +504,7 @@ int lime_decryptFile(void **cryptoContext, unsigned char *key, size_t length, ch
} else { /* this is not the first call, get the context */
gcmContext = (gcm_context *)*cryptoContext;
}
if (length != 0) {
gcm_update(gcmContext, length, (const unsigned char *)cipher, (unsigned char *)plain);
} else { /* lenght is 0, finish the stream */
@ -626,10 +629,10 @@ int lime_createMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_t
xmlNewTextChild(msgNode, NULL, (const xmlChar *)"text", (const xmlChar *)encryptedMessageb64);
free(encryptedMessage);
free(encryptedMessageb64);
/* add the message Node into the doc */
xmlAddChild(rootNode, msgNode);
/* update the key used */
lime_deriveKey(currentKey);
lime_setCachedKey(cacheBuffer, currentKey, LIME_SENDER);
@ -680,7 +683,7 @@ int lime_decryptMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_
if (cur != NULL) {
cur = cur->xmlChildrenNode;
if ((!xmlStrcmp(cur->name, (const xmlChar *)"ZID"))){ /* sender ZID found, extract it */
peerZidHex = xmlNodeListGetString(xmlEncryptedMessage, cur->xmlChildrenNode, 1);
peerZidHex = xmlNodeListGetString(xmlEncryptedMessage, cur->xmlChildrenNode, 1);
/* convert it from hexa string to bytes string and set the result in the associatedKey structure */
lime_strToUint8(associatedKey.peerZID, peerZidHex, strlen((char *)peerZidHex));
cur = cur->next;