mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2024-12-29 09:21:19 +00:00
ssl_cache: Return standard mbedtls error code
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
This commit is contained in:
parent
cdf06f69dd
commit
5038a38695
@ -110,7 +110,8 @@
|
||||
/* Error space gap */
|
||||
/* Error space gap */
|
||||
/* Error space gap */
|
||||
/* Error space gap */
|
||||
/** Cache entry not found */
|
||||
#define MBEDTLS_ERR_SSL_CACHE_NOT_FOUND -0x7E80
|
||||
/** Memory allocation failed */
|
||||
#define MBEDTLS_ERR_SSL_ALLOC_FAILED -0x7F00
|
||||
/** Hardware acceleration function returned with error */
|
||||
|
@ -51,7 +51,7 @@ static int ssl_cache_find_entry(mbedtls_ssl_cache_context *cache,
|
||||
size_t session_id_len,
|
||||
mbedtls_ssl_cache_entry **dst)
|
||||
{
|
||||
int ret = 1;
|
||||
int ret = MBEDTLS_ERR_SSL_CACHE_NOT_FOUND;
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
mbedtls_time_t t = mbedtls_time(NULL);
|
||||
#endif
|
||||
@ -88,7 +88,7 @@ int mbedtls_ssl_cache_get(void *data,
|
||||
size_t session_id_len,
|
||||
mbedtls_ssl_session *session)
|
||||
{
|
||||
int ret = 1;
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
mbedtls_ssl_cache_context *cache = (mbedtls_ssl_cache_context *) data;
|
||||
mbedtls_ssl_cache_entry *entry;
|
||||
|
||||
@ -198,7 +198,7 @@ static int ssl_cache_pick_writing_slot(mbedtls_ssl_cache_context *cache,
|
||||
/* Create new entry */
|
||||
cur = mbedtls_calloc(1, sizeof(mbedtls_ssl_cache_entry));
|
||||
if (cur == NULL) {
|
||||
return 1;
|
||||
return MBEDTLS_ERR_SSL_ALLOC_FAILED;
|
||||
}
|
||||
|
||||
/* Append to the end of the linked list. */
|
||||
@ -219,12 +219,13 @@ static int ssl_cache_pick_writing_slot(mbedtls_ssl_cache_context *cache,
|
||||
if (old == NULL) {
|
||||
/* This should only happen on an ill-configured cache
|
||||
* with max_entries == 0. */
|
||||
return 1;
|
||||
return MBEDTLS_ERR_SSL_INTERNAL_ERROR;
|
||||
}
|
||||
#else /* MBEDTLS_HAVE_TIME */
|
||||
/* Reuse first entry in chain, but move to last place. */
|
||||
if (cache->chain == NULL) {
|
||||
return 1;
|
||||
/* This should never happen */
|
||||
return MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
}
|
||||
|
||||
old = cache->chain;
|
||||
@ -260,7 +261,7 @@ int mbedtls_ssl_cache_set(void *data,
|
||||
size_t session_id_len,
|
||||
const mbedtls_ssl_session *session)
|
||||
{
|
||||
int ret = 1;
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
mbedtls_ssl_cache_context *cache = (mbedtls_ssl_cache_context *) data;
|
||||
mbedtls_ssl_cache_entry *cur;
|
||||
|
||||
@ -284,7 +285,6 @@ int mbedtls_ssl_cache_set(void *data,
|
||||
* and allocate a sufficiently large buffer. */
|
||||
ret = mbedtls_ssl_session_save(session, NULL, 0, &session_serialized_len);
|
||||
if (ret != MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL) {
|
||||
ret = 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ int mbedtls_ssl_cache_set(void *data,
|
||||
}
|
||||
|
||||
if (session_id_len > sizeof(cur->session_id)) {
|
||||
ret = 1;
|
||||
ret = MBEDTLS_ERR_SSL_BAD_INPUT_DATA;
|
||||
goto exit;
|
||||
}
|
||||
cur->session_id_len = session_id_len;
|
||||
@ -336,7 +336,7 @@ int mbedtls_ssl_cache_remove(void *data,
|
||||
unsigned char const *session_id,
|
||||
size_t session_id_len)
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_GENERIC_ERROR;
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
mbedtls_ssl_cache_context *cache = (mbedtls_ssl_cache_context *) data;
|
||||
mbedtls_ssl_cache_entry *entry;
|
||||
mbedtls_ssl_cache_entry *prev;
|
||||
|
Loading…
Reference in New Issue
Block a user