mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-03 19:59:36 +00:00
Lime gives more explicit warning messages
This commit is contained in:
parent
f6eb21ad82
commit
cb4b534a4d
3 changed files with 34 additions and 2 deletions
|
|
@ -129,7 +129,7 @@ void sal_process_incoming_message(SalOp *op,const belle_sip_request_event_t *eve
|
|||
free(cacheString);
|
||||
int retval = lime_decryptMultipartMessage(cacheXml, (uint8_t *)belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)), &decryptedMessage);
|
||||
if (retval != 0) {
|
||||
ms_warning("Unable to decrypt message, reason %x", retval);
|
||||
ms_warning("Unable to decrypt message, reason : %s - op [%p]", lime_error_code_to_string(retval), op);
|
||||
free(decryptedMessage);
|
||||
xmlFreeDoc(cacheXml);
|
||||
resp = belle_sip_response_create_from_request(req,488);
|
||||
|
|
@ -266,7 +266,7 @@ int sal_message_send(SalOp *op, const char *from, const char *to, const char* co
|
|||
free(cacheString);
|
||||
int retval = lime_createMultipartMessage(cacheXml, (uint8_t *)msg, (uint8_t *)peer_uri, &multipartEncryptedMessage);
|
||||
if (retval != 0) {
|
||||
ms_warning("Unable to encrypt message for %s error %x", peer_uri, retval);
|
||||
ms_warning("Unable to encrypt message for %s : %s - op [%p]", peer_uri, lime_error_code_to_string(retval), op);
|
||||
xmlFreeDoc(cacheXml);
|
||||
free(multipartEncryptedMessage);
|
||||
sal_error_info_set(&op->error_info, SalReasonNotAcceptable, 488, "Unable to encrypt IM", NULL);
|
||||
|
|
|
|||
|
|
@ -755,3 +755,16 @@ int lime_decryptMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *lime_error_code_to_string(int errorCode) {
|
||||
switch (errorCode) {
|
||||
case LIME_INVALID_CACHE: return "Invalid ZRTP cache";
|
||||
case LIME_UNABLE_TO_DERIVE_KEY: return "Unable to derive Key";
|
||||
case LIME_UNABLE_TO_ENCRYPT_MESSAGE: return "Unable to encrypt message";
|
||||
case LIME_UNABLE_TO_DECRYPT_MESSAGE: return "Unable to decrypt message";
|
||||
case LIME_NO_VALID_KEY_FOUND_FOR_PEER: return "No valid key found";
|
||||
case LIME_INVALID_ENCRYPTED_MESSAGE: return "Invalid encrypted message";
|
||||
}
|
||||
return "Unknow error";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,5 +169,24 @@ __attribute__ ((visibility ("default"))) int lime_decryptMessage(limeKey_t *key,
|
|||
* @return 0 on success, error code otherwise
|
||||
*/
|
||||
__attribute__ ((visibility ("default"))) int lime_createMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_t *peerURI, uint8_t **output);
|
||||
|
||||
/**
|
||||
* @brief decrypt a multipart xml message
|
||||
* Retrieve in cache the needed key which is then updated. Output buffer is allocated and must be freed by caller
|
||||
*
|
||||
* @param[in/out] cacheBuffer The xmlDoc containing current cache, get the key and selfZID from it, updated by this function with derivated keys
|
||||
* @param[in] message The multipart message, contain one or several part identified by destination ZID, one shall match the self ZID retrieved from cache
|
||||
* @param[out] output The output buffer, allocated and set with the decrypted message(null terminated string). Must be freed by caller
|
||||
*
|
||||
* @return 0 on success, error code otherwise
|
||||
*/
|
||||
|
||||
__attribute__ ((visibility ("default"))) int lime_decryptMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_t **output);
|
||||
|
||||
/**
|
||||
* @brief given a readable version of error code generated by Lime functions
|
||||
* @param[in] errorCode The error code
|
||||
* @return a string containing the error description
|
||||
*/
|
||||
char *lime_error_code_to_string(int errorCode);
|
||||
#endif /* LIME_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue