2016-09-21 22:28:08 -04:00
|
|
|
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
2016-09-20 04:58:46 -04:00
|
|
|
#include "ssl_methods.h"
|
|
|
|
#include "ssl_pm.h"
|
|
|
|
|
2016-09-23 02:50:27 -04:00
|
|
|
/**
|
2016-09-21 22:28:08 -04:00
|
|
|
* TLS method function collection
|
|
|
|
*/
|
2016-09-20 04:58:46 -04:00
|
|
|
IMPLEMENT_TLS_METHOD_FUNC(TLS_method_func,
|
|
|
|
ssl_pm_new, ssl_pm_free,
|
|
|
|
ssl_pm_handshake, ssl_pm_shutdown, ssl_pm_clear,
|
|
|
|
ssl_pm_read, ssl_pm_send, ssl_pm_pending,
|
2017-10-02 04:30:13 -04:00
|
|
|
ssl_pm_set_fd, ssl_pm_set_hostname, ssl_pm_get_fd,
|
2016-09-20 04:58:46 -04:00
|
|
|
ssl_pm_set_bufflen,
|
2016-09-22 03:15:16 -04:00
|
|
|
ssl_pm_get_verify_result,
|
2016-09-20 04:58:46 -04:00
|
|
|
ssl_pm_get_state);
|
|
|
|
|
2016-09-23 02:50:27 -04:00
|
|
|
/**
|
2016-09-21 22:28:08 -04:00
|
|
|
* TLS or SSL client method collection
|
|
|
|
*/
|
2016-09-20 04:58:46 -04:00
|
|
|
IMPLEMENT_TLS_METHOD(TLS_ANY_VERSION, 0, TLS_method_func, TLS_client_method);
|
|
|
|
|
|
|
|
IMPLEMENT_TLS_METHOD(TLS1_2_VERSION, 0, TLS_method_func, TLSv1_2_client_method);
|
|
|
|
|
|
|
|
IMPLEMENT_TLS_METHOD(TLS1_1_VERSION, 0, TLS_method_func, TLSv1_1_client_method);
|
|
|
|
|
|
|
|
IMPLEMENT_TLS_METHOD(TLS1_VERSION, 0, TLS_method_func, TLSv1_client_method);
|
|
|
|
|
|
|
|
IMPLEMENT_SSL_METHOD(SSL3_VERSION, 0, TLS_method_func, SSLv3_client_method);
|
|
|
|
|
2016-09-23 02:50:27 -04:00
|
|
|
/**
|
2016-09-21 22:28:08 -04:00
|
|
|
* TLS or SSL server method collection
|
|
|
|
*/
|
2016-09-20 04:58:46 -04:00
|
|
|
IMPLEMENT_TLS_METHOD(TLS_ANY_VERSION, 1, TLS_method_func, TLS_server_method);
|
|
|
|
|
|
|
|
IMPLEMENT_TLS_METHOD(TLS1_1_VERSION, 1, TLS_method_func, TLSv1_1_server_method);
|
|
|
|
|
|
|
|
IMPLEMENT_TLS_METHOD(TLS1_2_VERSION, 1, TLS_method_func, TLSv1_2_server_method);
|
|
|
|
|
2020-06-05 08:20:04 -04:00
|
|
|
IMPLEMENT_TLS_METHOD(TLS1_VERSION, 1, TLS_method_func, TLSv1_server_method);
|
2016-09-20 04:58:46 -04:00
|
|
|
|
|
|
|
IMPLEMENT_SSL_METHOD(SSL3_VERSION, 1, TLS_method_func, SSLv3_server_method);
|
|
|
|
|
2016-09-23 02:50:27 -04:00
|
|
|
/**
|
2016-09-21 22:28:08 -04:00
|
|
|
* TLS or SSL method collection
|
|
|
|
*/
|
2016-09-20 04:58:46 -04:00
|
|
|
IMPLEMENT_TLS_METHOD(TLS_ANY_VERSION, -1, TLS_method_func, TLS_method);
|
|
|
|
|
2020-06-05 08:20:04 -04:00
|
|
|
IMPLEMENT_TLS_METHOD(TLS1_2_VERSION, -1, TLS_method_func, TLSv1_2_method);
|
2016-09-20 04:58:46 -04:00
|
|
|
|
2020-06-05 08:20:04 -04:00
|
|
|
IMPLEMENT_TLS_METHOD(TLS1_1_VERSION, -1, TLS_method_func, TLSv1_1_method);
|
2016-09-20 04:58:46 -04:00
|
|
|
|
2020-06-05 08:20:04 -04:00
|
|
|
IMPLEMENT_TLS_METHOD(TLS1_VERSION, -1, TLS_method_func, TLSv1_method);
|
2016-09-20 04:58:46 -04:00
|
|
|
|
|
|
|
IMPLEMENT_SSL_METHOD(SSL3_VERSION, -1, TLS_method_func, SSLv3_method);
|
2016-09-21 22:28:08 -04:00
|
|
|
|
2016-09-23 02:50:27 -04:00
|
|
|
/**
|
|
|
|
* @brief get X509 object method
|
2016-09-21 22:28:08 -04:00
|
|
|
*/
|
|
|
|
IMPLEMENT_X509_METHOD(X509_method,
|
|
|
|
x509_pm_new, x509_pm_free,
|
2016-10-09 04:42:49 -04:00
|
|
|
x509_pm_load, x509_pm_show_info);
|
2016-09-21 22:28:08 -04:00
|
|
|
|
2016-09-23 02:50:27 -04:00
|
|
|
/**
|
|
|
|
* @brief get private key object method
|
2016-09-21 22:28:08 -04:00
|
|
|
*/
|
|
|
|
IMPLEMENT_PKEY_METHOD(EVP_PKEY_method,
|
|
|
|
pkey_pm_new, pkey_pm_free,
|
2016-09-25 23:14:19 -04:00
|
|
|
pkey_pm_load);
|
2020-06-05 08:20:04 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Generic SSL/TLS methods
|
|
|
|
*/
|
|
|
|
const SSL_METHOD *SSLv23_method(void)
|
|
|
|
{
|
|
|
|
return TLS_method();
|
|
|
|
}
|
|
|
|
|
|
|
|
const SSL_METHOD *SSLv23_server_method(void)
|
|
|
|
{
|
|
|
|
return TLS_server_method();
|
|
|
|
}
|
|
|
|
|
|
|
|
const SSL_METHOD *SSLv23_client_method(void)
|
|
|
|
{
|
|
|
|
return TLS_client_method();
|
|
|
|
}
|
|
|
|
|
|
|
|
int SSL_CTX_set_min_proto_version(SSL_CTX *ctx, int version)
|
|
|
|
{
|
|
|
|
ctx->min_version = version;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SSL_CTX_set_max_proto_version(SSL_CTX *ctx, int version)
|
|
|
|
{
|
|
|
|
ctx->max_version = version;
|
|
|
|
return 1;
|
|
|
|
}
|