2009-01-03 22:22:43 +01:00
|
|
|
/*
|
|
|
|
* SSLv3/TLSv1 server-side functions
|
|
|
|
*
|
2015-07-27 11:11:48 +02:00
|
|
|
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
2015-09-04 14:21:07 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2010-07-18 22:36:00 +02:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
* not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2009-01-04 17:27:10 +01:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2009-01-03 22:22:43 +01:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2009-01-03 22:22:43 +01:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* This file is part of mbed TLS (https://tls.mbed.org)
|
2009-01-03 22:22:43 +01:00
|
|
|
*/
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if !defined(MBEDTLS_CONFIG_FILE)
|
2015-03-09 18:05:11 +01:00
|
|
|
#include "mbedtls/config.h"
|
2014-04-29 12:39:06 +02:00
|
|
|
#else
|
2015-04-08 12:49:31 +02:00
|
|
|
#include MBEDTLS_CONFIG_FILE
|
2014-04-29 12:39:06 +02:00
|
|
|
#endif
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_SSL_SRV_C)
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2016-04-26 08:43:27 +02:00
|
|
|
#if defined(MBEDTLS_PLATFORM_C)
|
|
|
|
#include "mbedtls/platform.h"
|
|
|
|
#else
|
|
|
|
#include <stdlib.h>
|
|
|
|
#define mbedtls_calloc calloc
|
|
|
|
#define mbedtls_free free
|
|
|
|
#endif
|
|
|
|
|
2015-03-09 18:05:11 +01:00
|
|
|
#include "mbedtls/ssl.h"
|
2015-05-26 11:57:05 +02:00
|
|
|
#include "mbedtls/ssl_internal.h"
|
2019-12-18 16:07:04 +01:00
|
|
|
#include "mbedtls/debug.h"
|
|
|
|
#include "mbedtls/error.h"
|
2018-04-24 15:40:46 +02:00
|
|
|
#include "mbedtls/platform_util.h"
|
2015-02-06 14:43:58 +01:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_ECP_C)
|
2015-03-09 18:05:11 +01:00
|
|
|
#include "mbedtls/ecp.h"
|
2013-03-20 14:39:14 +01:00
|
|
|
#endif
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_HAVE_TIME)
|
2016-07-13 15:46:18 +02:00
|
|
|
#include "mbedtls/platform_time.h"
|
2013-07-03 15:31:03 +02:00
|
|
|
#endif
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY)
|
|
|
|
int mbedtls_ssl_set_client_transport_id( mbedtls_ssl_context *ssl,
|
2014-07-22 17:32:01 +02:00
|
|
|
const unsigned char *info,
|
|
|
|
size_t ilen )
|
|
|
|
{
|
2015-05-04 10:55:58 +02:00
|
|
|
if( ssl->conf->endpoint != MBEDTLS_SSL_IS_SERVER )
|
2015-04-08 12:49:31 +02:00
|
|
|
return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
|
2014-07-22 17:32:01 +02:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_free( ssl->cli_id );
|
2014-07-22 17:32:01 +02:00
|
|
|
|
2015-05-26 16:04:06 +02:00
|
|
|
if( ( ssl->cli_id = mbedtls_calloc( 1, ilen ) ) == NULL )
|
2015-05-28 09:33:39 +02:00
|
|
|
return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
|
2014-07-22 17:32:01 +02:00
|
|
|
|
|
|
|
memcpy( ssl->cli_id, info, ilen );
|
|
|
|
ssl->cli_id_len = ilen;
|
|
|
|
|
|
|
|
return( 0 );
|
|
|
|
}
|
2014-07-23 14:56:15 +02:00
|
|
|
|
2015-05-11 09:50:24 +02:00
|
|
|
void mbedtls_ssl_conf_dtls_cookies( mbedtls_ssl_config *conf,
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_ssl_cookie_write_t *f_cookie_write,
|
|
|
|
mbedtls_ssl_cookie_check_t *f_cookie_check,
|
2014-07-23 14:56:15 +02:00
|
|
|
void *p_cookie )
|
|
|
|
{
|
2015-05-05 10:45:39 +02:00
|
|
|
conf->f_cookie_write = f_cookie_write;
|
|
|
|
conf->f_cookie_check = f_cookie_check;
|
|
|
|
conf->p_cookie = p_cookie;
|
2014-07-23 14:56:15 +02:00
|
|
|
}
|
2015-04-08 12:49:31 +02:00
|
|
|
#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY */
|
2014-07-22 17:32:01 +02:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#endif /* MBEDTLS_SSL_SRV_C */
|