-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #495 from h2o/kazuho/mbedtls
support mbedtls as backend
- Loading branch information
Showing
10 changed files
with
1,067 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Try to find MbedTLS; recognized hints are: | ||
# * MBEDTLS_ROOT_DIR | ||
# * MBEDTLS_LIBDIR | ||
# Upon return, | ||
# * MBEDTLS_INCLUDE_DIRS | ||
# * MBEDTLS_LIBRARIES | ||
# will be set. | ||
# Users may supply MBEDTLS_INCLUDE_DIRS or MBEDTLS_LIBRARIES directly. | ||
|
||
INCLUDE(FindPackageHandleStandardArgs) | ||
|
||
# setup default vars for the hints | ||
IF (NOT DEFINED MBEDTLS_ROOT_DIR) | ||
SET(MBEDTLS_ROOT_DIR "/usr/local" "/usr") | ||
ENDIF () | ||
IF (NOT DEFINED MBEDTLS_LIBDIR) | ||
SET(MBEDTLS_LIBDIR) | ||
FOREACH (item IN LISTS MBEDTLS_ROOT_DIR) | ||
LIST(APPEND MBEDTLS_LIBDIR "${item}/lib") | ||
ENDFOREACH () | ||
ENDIF () | ||
|
||
# find include directory | ||
IF (NOT DEFINED MBEDTLS_INCLUDE_DIRS) | ||
SET(HINTS) | ||
FOREACH (item IN LISTS MBEDTLS_ROOT_DIR) | ||
LIST(APPEND HINTS "${item}/include") | ||
ENDFOREACH () | ||
FIND_PATH(MBEDTLS_INCLUDE_DIRS | ||
NAMES mbedtls/build_info.h psa/crypto.h | ||
HINTS $HINTS) | ||
ENDIF () | ||
|
||
# find libraries | ||
FIND_LIBRARY(MBEDTLS_LIBRARY mbedtls HINTS $MBEDTLS_LIBDIR) | ||
FIND_LIBRARY(MBEDTLS_CRYPTO mbedcrypto HINTS $MBEDTLS_LIBDIR) | ||
FIND_LIBRARY(MBEDTLS_X509 mbedx509 HINTS $MBEDTLS_LIBDIR) | ||
|
||
# setup | ||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MbedTLS REQUIRED_VARS | ||
MBEDTLS_LIBRARY | ||
MBEDTLS_CRYPTO | ||
MBEDTLS_X509 | ||
MBEDTLS_INCLUDE_DIRS) | ||
IF (MbedTLS_FOUND) | ||
SET(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY} ${MBEDTLS_CRYPTO} ${MBEDTLS_X509}) | ||
MARK_AS_ADVANCED(MBEDTLS_LIBRARIES MBEDTLS_INCLUDE_DIRS) | ||
ENDIF () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (c) 2023, Christian Huitema | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to | ||
* deal in the Software without restriction, including without limitation the | ||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
* sell copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
*/ | ||
#ifndef picotls_mbedtls_h | ||
#define picotls_mbedtls_h | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include <psa/crypto.h> | ||
#include "picotls.h" | ||
|
||
/* before using any of these objects, psa_crypto_init() must be called */ | ||
|
||
extern ptls_hash_algorithm_t ptls_mbedtls_sha256; | ||
extern ptls_hash_algorithm_t ptls_mbedtls_sha512; | ||
#if defined(MBEDTLS_SHA384_C) | ||
extern ptls_hash_algorithm_t ptls_mbedtls_sha384; | ||
#endif | ||
|
||
extern ptls_cipher_algorithm_t ptls_mbedtls_aes128ecb; | ||
extern ptls_cipher_algorithm_t ptls_mbedtls_aes256ecb; | ||
extern ptls_cipher_algorithm_t ptls_mbedtls_aes128ctr; | ||
extern ptls_cipher_algorithm_t ptls_mbedtls_aes256ctr; | ||
extern ptls_cipher_algorithm_t ptls_mbedtls_chacha20; | ||
|
||
extern ptls_aead_algorithm_t ptls_mbedtls_aes128gcm; | ||
extern ptls_aead_algorithm_t ptls_mbedtls_aes256gcm; | ||
extern ptls_aead_algorithm_t ptls_mbedtls_chacha20poly1305; | ||
|
||
extern ptls_cipher_suite_t ptls_mbedtls_aes128gcmsha256; | ||
#if defined(MBEDTLS_SHA384_C) | ||
extern ptls_cipher_suite_t ptls_mbedtls_aes256gcmsha384; | ||
#endif | ||
extern ptls_cipher_suite_t ptls_mbedtls_chacha20poly1305sha256; | ||
extern ptls_cipher_suite_t *ptls_mbedtls_cipher_suites[]; | ||
|
||
extern ptls_key_exchange_algorithm_t ptls_mbedtls_secp256r1; | ||
extern ptls_key_exchange_algorithm_t ptls_mbedtls_x25519; | ||
extern ptls_key_exchange_algorithm_t *ptls_mbedtls_key_exchanges[]; | ||
|
||
void ptls_mbedtls_random_bytes(void *buf, size_t len); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif /* picotls_mbedtls_h */ |
Oops, something went wrong.