mbed TLS upgraded to 2.6.0
Fork of mbedtls by
scripts/data_files/error.fmt@2:bbdeda018a3c, 2017-09-29 (annotated)
- Committer:
- Jasper Wallace
- Date:
- Fri Sep 29 19:50:30 2017 +0100
- Revision:
- 2:bbdeda018a3c
- Parent:
- 1:9ebc941037d5
Update to mbedtls 2.6.0, many changes.
Changes to mbedtls sources made:
in include/mbedtls/config.h comment out:
#define MBEDTLS_FS_IO
#define MBEDTLS_NET_C
#define MBEDTLS_TIMING_C
uncomment:
#define MBEDTLS_NO_PLATFORM_ENTROPY
remove the following directorys:
programs
yotta
visualc
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jasper Wallace |
1:9ebc941037d5 | 1 | /* |
Jasper Wallace |
1:9ebc941037d5 | 2 | * Error message information |
Jasper Wallace |
1:9ebc941037d5 | 3 | * |
Jasper Wallace |
1:9ebc941037d5 | 4 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved |
Jasper Wallace |
1:9ebc941037d5 | 5 | * SPDX-License-Identifier: Apache-2.0 |
Jasper Wallace |
1:9ebc941037d5 | 6 | * |
Jasper Wallace |
1:9ebc941037d5 | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
Jasper Wallace |
1:9ebc941037d5 | 8 | * not use this file except in compliance with the License. |
Jasper Wallace |
1:9ebc941037d5 | 9 | * You may obtain a copy of the License at |
Jasper Wallace |
1:9ebc941037d5 | 10 | * |
Jasper Wallace |
1:9ebc941037d5 | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
Jasper Wallace |
1:9ebc941037d5 | 12 | * |
Jasper Wallace |
1:9ebc941037d5 | 13 | * Unless required by applicable law or agreed to in writing, software |
Jasper Wallace |
1:9ebc941037d5 | 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
Jasper Wallace |
1:9ebc941037d5 | 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Jasper Wallace |
1:9ebc941037d5 | 16 | * See the License for the specific language governing permissions and |
Jasper Wallace |
1:9ebc941037d5 | 17 | * limitations under the License. |
Jasper Wallace |
1:9ebc941037d5 | 18 | * |
Jasper Wallace |
1:9ebc941037d5 | 19 | * This file is part of mbed TLS (https://tls.mbed.org) |
Jasper Wallace |
1:9ebc941037d5 | 20 | */ |
Jasper Wallace |
1:9ebc941037d5 | 21 | |
Jasper Wallace |
1:9ebc941037d5 | 22 | #if !defined(MBEDTLS_CONFIG_FILE) |
Jasper Wallace |
1:9ebc941037d5 | 23 | #include "mbedtls/config.h" |
Jasper Wallace |
1:9ebc941037d5 | 24 | #else |
Jasper Wallace |
1:9ebc941037d5 | 25 | #include MBEDTLS_CONFIG_FILE |
Jasper Wallace |
1:9ebc941037d5 | 26 | #endif |
Jasper Wallace |
1:9ebc941037d5 | 27 | |
Jasper Wallace |
1:9ebc941037d5 | 28 | #if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY) |
Jasper Wallace |
1:9ebc941037d5 | 29 | #include "mbedtls/error.h" |
Jasper Wallace |
1:9ebc941037d5 | 30 | #include <string.h> |
Jasper Wallace |
1:9ebc941037d5 | 31 | #endif |
Jasper Wallace |
1:9ebc941037d5 | 32 | |
Jasper Wallace |
1:9ebc941037d5 | 33 | #if defined(MBEDTLS_PLATFORM_C) |
Jasper Wallace |
1:9ebc941037d5 | 34 | #include "mbedtls/platform.h" |
Jasper Wallace |
1:9ebc941037d5 | 35 | #else |
Jasper Wallace |
1:9ebc941037d5 | 36 | #define mbedtls_snprintf snprintf |
Jasper Wallace |
1:9ebc941037d5 | 37 | #define mbedtls_time_t time_t |
Jasper Wallace |
1:9ebc941037d5 | 38 | #endif |
Jasper Wallace |
1:9ebc941037d5 | 39 | |
Jasper Wallace |
1:9ebc941037d5 | 40 | #if defined(MBEDTLS_ERROR_C) |
Jasper Wallace |
1:9ebc941037d5 | 41 | |
Jasper Wallace |
1:9ebc941037d5 | 42 | #include <stdio.h> |
Jasper Wallace |
1:9ebc941037d5 | 43 | |
Jasper Wallace |
1:9ebc941037d5 | 44 | HEADER_INCLUDED |
Jasper Wallace |
1:9ebc941037d5 | 45 | |
Jasper Wallace |
1:9ebc941037d5 | 46 | void mbedtls_strerror( int ret, char *buf, size_t buflen ) |
Jasper Wallace |
1:9ebc941037d5 | 47 | { |
Jasper Wallace |
1:9ebc941037d5 | 48 | size_t len; |
Jasper Wallace |
1:9ebc941037d5 | 49 | int use_ret; |
Jasper Wallace |
1:9ebc941037d5 | 50 | |
Jasper Wallace |
1:9ebc941037d5 | 51 | if( buflen == 0 ) |
Jasper Wallace |
1:9ebc941037d5 | 52 | return; |
Jasper Wallace |
1:9ebc941037d5 | 53 | |
Jasper Wallace |
1:9ebc941037d5 | 54 | memset( buf, 0x00, buflen ); |
Jasper Wallace |
1:9ebc941037d5 | 55 | |
Jasper Wallace |
1:9ebc941037d5 | 56 | if( ret < 0 ) |
Jasper Wallace |
1:9ebc941037d5 | 57 | ret = -ret; |
Jasper Wallace |
1:9ebc941037d5 | 58 | |
Jasper Wallace |
1:9ebc941037d5 | 59 | if( ret & 0xFF80 ) |
Jasper Wallace |
1:9ebc941037d5 | 60 | { |
Jasper Wallace |
1:9ebc941037d5 | 61 | use_ret = ret & 0xFF80; |
Jasper Wallace |
1:9ebc941037d5 | 62 | |
Jasper Wallace |
1:9ebc941037d5 | 63 | // High level error codes |
Jasper Wallace |
1:9ebc941037d5 | 64 | // |
Jasper Wallace |
1:9ebc941037d5 | 65 | // BEGIN generated code |
Jasper Wallace |
1:9ebc941037d5 | 66 | HIGH_LEVEL_CODE_CHECKS |
Jasper Wallace |
1:9ebc941037d5 | 67 | // END generated code |
Jasper Wallace |
1:9ebc941037d5 | 68 | |
Jasper Wallace |
1:9ebc941037d5 | 69 | if( strlen( buf ) == 0 ) |
Jasper Wallace |
1:9ebc941037d5 | 70 | mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); |
Jasper Wallace |
1:9ebc941037d5 | 71 | } |
Jasper Wallace |
1:9ebc941037d5 | 72 | |
Jasper Wallace |
1:9ebc941037d5 | 73 | use_ret = ret & ~0xFF80; |
Jasper Wallace |
1:9ebc941037d5 | 74 | |
Jasper Wallace |
1:9ebc941037d5 | 75 | if( use_ret == 0 ) |
Jasper Wallace |
1:9ebc941037d5 | 76 | return; |
Jasper Wallace |
1:9ebc941037d5 | 77 | |
Jasper Wallace |
1:9ebc941037d5 | 78 | // If high level code is present, make a concatenation between both |
Jasper Wallace |
1:9ebc941037d5 | 79 | // error strings. |
Jasper Wallace |
1:9ebc941037d5 | 80 | // |
Jasper Wallace |
1:9ebc941037d5 | 81 | len = strlen( buf ); |
Jasper Wallace |
1:9ebc941037d5 | 82 | |
Jasper Wallace |
1:9ebc941037d5 | 83 | if( len > 0 ) |
Jasper Wallace |
1:9ebc941037d5 | 84 | { |
Jasper Wallace |
1:9ebc941037d5 | 85 | if( buflen - len < 5 ) |
Jasper Wallace |
1:9ebc941037d5 | 86 | return; |
Jasper Wallace |
1:9ebc941037d5 | 87 | |
Jasper Wallace |
1:9ebc941037d5 | 88 | mbedtls_snprintf( buf + len, buflen - len, " : " ); |
Jasper Wallace |
1:9ebc941037d5 | 89 | |
Jasper Wallace |
1:9ebc941037d5 | 90 | buf += len + 3; |
Jasper Wallace |
1:9ebc941037d5 | 91 | buflen -= len + 3; |
Jasper Wallace |
1:9ebc941037d5 | 92 | } |
Jasper Wallace |
1:9ebc941037d5 | 93 | |
Jasper Wallace |
1:9ebc941037d5 | 94 | // Low level error codes |
Jasper Wallace |
1:9ebc941037d5 | 95 | // |
Jasper Wallace |
1:9ebc941037d5 | 96 | // BEGIN generated code |
Jasper Wallace |
1:9ebc941037d5 | 97 | LOW_LEVEL_CODE_CHECKS |
Jasper Wallace |
1:9ebc941037d5 | 98 | // END generated code |
Jasper Wallace |
1:9ebc941037d5 | 99 | |
Jasper Wallace |
1:9ebc941037d5 | 100 | if( strlen( buf ) != 0 ) |
Jasper Wallace |
1:9ebc941037d5 | 101 | return; |
Jasper Wallace |
1:9ebc941037d5 | 102 | |
Jasper Wallace |
1:9ebc941037d5 | 103 | mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); |
Jasper Wallace |
1:9ebc941037d5 | 104 | } |
Jasper Wallace |
1:9ebc941037d5 | 105 | |
Jasper Wallace |
1:9ebc941037d5 | 106 | #else /* MBEDTLS_ERROR_C */ |
Jasper Wallace |
1:9ebc941037d5 | 107 | |
Jasper Wallace |
1:9ebc941037d5 | 108 | #if defined(MBEDTLS_ERROR_STRERROR_DUMMY) |
Jasper Wallace |
1:9ebc941037d5 | 109 | |
Jasper Wallace |
1:9ebc941037d5 | 110 | /* |
Jasper Wallace |
1:9ebc941037d5 | 111 | * Provide an non-function in case MBEDTLS_ERROR_C is not defined |
Jasper Wallace |
1:9ebc941037d5 | 112 | */ |
Jasper Wallace |
1:9ebc941037d5 | 113 | void mbedtls_strerror( int ret, char *buf, size_t buflen ) |
Jasper Wallace |
1:9ebc941037d5 | 114 | { |
Jasper Wallace |
1:9ebc941037d5 | 115 | ((void) ret); |
Jasper Wallace |
1:9ebc941037d5 | 116 | |
Jasper Wallace |
1:9ebc941037d5 | 117 | if( buflen > 0 ) |
Jasper Wallace |
1:9ebc941037d5 | 118 | buf[0] = '\0'; |
Jasper Wallace |
1:9ebc941037d5 | 119 | } |
Jasper Wallace |
1:9ebc941037d5 | 120 | |
Jasper Wallace |
1:9ebc941037d5 | 121 | #endif /* MBEDTLS_ERROR_STRERROR_DUMMY */ |
Jasper Wallace |
1:9ebc941037d5 | 122 | |
Jasper Wallace |
1:9ebc941037d5 | 123 | #endif /* MBEDTLS_ERROR_C */ |