Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: MiniTLS-HTTPS-Example
tls_alert.c
00001 /* 00002 MiniTLS - A super trimmed down TLS/SSL Library for embedded devices 00003 Author: Donatien Garnier 00004 Copyright (C) 2013-2014 AppNearMe Ltd 00005 00006 This program is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU General Public License 00008 as published by the Free Software Foundation; either version 2 00009 of the License, or (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 *//** 00020 * \file tls_alert.c 00021 * \copyright Copyright (c) AppNearMe Ltd 2013 00022 * \author Donatien Garnier 00023 */ 00024 00025 #define __DEBUG__ 4 00026 #ifndef __MODULE__ 00027 #define __MODULE__ "tls_alert.c" 00028 #endif 00029 00030 #include "core/fwk.h" 00031 #include "inc/minitls_errors.h" 00032 #include "tls_alert.h" 00033 00034 minitls_err_t tls_alert_send( tls_record_t* record, tls_message_alert_level_t level, tls_message_alert_description_t description, buffer_t* buffer_tx ) 00035 { 00036 if( buffer_size(buffer_tx) < 2 ) 00037 { 00038 return MINITLS_ERR_BUFFER_TOO_SMALL; 00039 } 00040 00041 buffer_reset(buffer_tx); 00042 00043 buffer_nu8_write(buffer_tx, level); 00044 buffer_nu8_write(buffer_tx, description); 00045 00046 minitls_err_t ret = tls_record_send(record, TLS_ALERT, buffer_tx); 00047 if(ret) 00048 { 00049 return ret; 00050 } 00051 00052 return MINITLS_OK; 00053 } 00054 00055 minitls_err_t tls_alert_process( tls_record_t* record, buffer_t* buffer_rx ) 00056 { 00057 if( buffer_length(buffer_rx) < 2 ) 00058 { 00059 return MINITLS_ERR_BUFFER_TOO_SMALL; 00060 } 00061 00062 tls_message_alert_level_t level = buffer_nu8_read(buffer_rx); 00063 tls_message_alert_description_t description = buffer_nu8_read(buffer_rx); 00064 00065 WARN("Alert: type: %d, description: %d", level, description); 00066 if(description == CLOSE_NOTIFY) 00067 { 00068 return MINITLS_ERR_CONNECTION_CLOSED; 00069 } 00070 00071 //Always return error 00072 return MINITLS_ERR_PEER; 00073 }
Generated on Wed Jul 13 2022 00:22:54 by
1.7.2