From bf21420cd0b0cd6b7e601e0bb7726bf4d1322691 Mon Sep 17 00:00:00 2001 From: Shu Chen Date: Thu, 16 Feb 2017 11:57:33 +0800 Subject: [PATCH] Add PSKc generation feature support (#1165) * implement PBKDF2 using AES-CMAC-PRF-128 * generate PSKc using PBKDF2, AES-CMAC-PRF-128 * expand "dataset pskc" cli to input PSKc source (passphrase, network name, extended panid) --- etc/visual-studio/libopenthread.vcxproj | 2 + .../libopenthread.vcxproj.filters | 6 ++ etc/visual-studio/libopenthread_k.vcxproj | 2 + .../libopenthread_k.vcxproj.filters | 6 ++ etc/visual-studio/mbedtls.vcxproj | 3 +- etc/visual-studio/mbedtls.vcxproj.filters | 5 +- etc/visual-studio/mbedtls_k.vcxproj | 3 +- etc/visual-studio/mbedtls_k.vcxproj.filters | 5 +- include/openthread-types.h | 6 +- include/openthread.h | 18 ++++ src/cli/README.md | 19 ++++ src/cli/cli_dataset.cpp | 20 ++-- src/core/Makefile.am | 2 + src/core/crypto/pbkdf2_cmac.cpp | 100 ++++++++++++++++++ src/core/crypto/pbkdf2_cmac.h | 69 ++++++++++++ src/core/meshcop/dataset_manager_ftd.cpp | 9 +- src/core/openthread.cpp | 6 ++ src/core/thread/network_data_leader_ftd.cpp | 29 +++++ src/core/thread/network_data_leader_ftd.hpp | 16 +++ src/core/thread/network_data_leader_mtd.hpp | 2 + third_party/mbedtls/Makefile.am | 7 +- third_party/mbedtls/mbedtls-config.h | 3 +- 22 files changed, 321 insertions(+), 17 deletions(-) create mode 100644 src/core/crypto/pbkdf2_cmac.cpp create mode 100644 src/core/crypto/pbkdf2_cmac.h diff --git a/etc/visual-studio/libopenthread.vcxproj b/etc/visual-studio/libopenthread.vcxproj index 8fccebc21..e6745b3d1 100644 --- a/etc/visual-studio/libopenthread.vcxproj +++ b/etc/visual-studio/libopenthread.vcxproj @@ -72,6 +72,7 @@ + @@ -145,6 +146,7 @@ + diff --git a/etc/visual-studio/libopenthread.vcxproj.filters b/etc/visual-studio/libopenthread.vcxproj.filters index fe3856169..f7f5723c5 100644 --- a/etc/visual-studio/libopenthread.vcxproj.filters +++ b/etc/visual-studio/libopenthread.vcxproj.filters @@ -234,6 +234,9 @@ Source Files\crypto + + Source Files\crypto + Source Files\crypto @@ -482,6 +485,9 @@ Header Files\crypto + + Header Files\crypto + Header Files\crypto diff --git a/etc/visual-studio/libopenthread_k.vcxproj b/etc/visual-studio/libopenthread_k.vcxproj index 73e2e7a23..d20fca6c0 100644 --- a/etc/visual-studio/libopenthread_k.vcxproj +++ b/etc/visual-studio/libopenthread_k.vcxproj @@ -80,6 +80,7 @@ + @@ -153,6 +154,7 @@ + diff --git a/etc/visual-studio/libopenthread_k.vcxproj.filters b/etc/visual-studio/libopenthread_k.vcxproj.filters index 7611e7f17..89e658f76 100644 --- a/etc/visual-studio/libopenthread_k.vcxproj.filters +++ b/etc/visual-studio/libopenthread_k.vcxproj.filters @@ -231,6 +231,9 @@ Source Files\crypto + + Source Files\crypto + Source Files\crypto @@ -470,6 +473,9 @@ Header Files\crypto + + Header Files\crypto + Header Files\crypto diff --git a/etc/visual-studio/mbedtls.vcxproj b/etc/visual-studio/mbedtls.vcxproj index ef36a6c33..5f6f62e7e 100644 --- a/etc/visual-studio/mbedtls.vcxproj +++ b/etc/visual-studio/mbedtls.vcxproj @@ -59,6 +59,7 @@ + @@ -81,4 +82,4 @@ - \ No newline at end of file + diff --git a/etc/visual-studio/mbedtls.vcxproj.filters b/etc/visual-studio/mbedtls.vcxproj.filters index 6c78ed5ad..7939941fd 100644 --- a/etc/visual-studio/mbedtls.vcxproj.filters +++ b/etc/visual-studio/mbedtls.vcxproj.filters @@ -31,6 +31,9 @@ Source Files\repo\library + + Source Files\repo\library + Source Files\repo\library @@ -86,4 +89,4 @@ Source Files\repo\library - \ No newline at end of file + diff --git a/etc/visual-studio/mbedtls_k.vcxproj b/etc/visual-studio/mbedtls_k.vcxproj index 734631686..42ced4b07 100644 --- a/etc/visual-studio/mbedtls_k.vcxproj +++ b/etc/visual-studio/mbedtls_k.vcxproj @@ -62,6 +62,7 @@ + @@ -83,4 +84,4 @@ - \ No newline at end of file + diff --git a/etc/visual-studio/mbedtls_k.vcxproj.filters b/etc/visual-studio/mbedtls_k.vcxproj.filters index 1b8c0d7a1..691803f13 100644 --- a/etc/visual-studio/mbedtls_k.vcxproj.filters +++ b/etc/visual-studio/mbedtls_k.vcxproj.filters @@ -31,6 +31,9 @@ Source Files\repo\library + + Source Files\repo\library + Source Files\repo\library @@ -86,4 +89,4 @@ Source Files\repo\library - \ No newline at end of file + diff --git a/include/openthread-types.h b/include/openthread-types.h index ab354b506..d4db4f2a1 100644 --- a/include/openthread-types.h +++ b/include/openthread-types.h @@ -245,7 +245,11 @@ typedef struct otMeshLocalPrefix uint8_t m8[OT_MESH_LOCAL_PREFIX_SIZE]; } otMeshLocalPrefix; -#define OT_PSKC_MAX_SIZE 16 ///< Maximum size of the PSKc (bytes) +#define OT_PSKC_MAX_SIZE 16 ///< Maximum size of the PSKc (bytes) + +#define OT_COMMISSIONING_PASSPHRASE_MIN_SIZE 6 ///< Minimum size of the Commissioning Passphrase +#define OT_COMMISSIONING_PASSPHRASE_MAX_SIZE 255 ///< Maximum size of the Commissioning Passphrase +#define OT_COMMISSIONING_PASSPHRASE_DEFAULT "OpenThreadPassphrase" ///< The default commissioning passphrase /** * This structure represents PSKc. diff --git a/include/openthread.h b/include/openthread.h index ea5ec44a0..c53f08f95 100644 --- a/include/openthread.h +++ b/include/openthread.h @@ -639,6 +639,24 @@ OTAPI const uint8_t *OTCALL otGetMasterKey(otInstance *aInstance, uint8_t *aKeyL */ OTAPI ThreadError OTCALL otSetMasterKey(otInstance *aInstance, const uint8_t *aKey, uint8_t aKeyLength); +/** + * This method generates PSKc. + * + * PSKc is used to establish the Commissioner Session. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * @param[in] aPassPhrase The commissioning passphrase. + * @param[in] aNetworkName The network name for PSKc computation. + * @param[in] aExtPanId The extended pan id for PSKc computation. + * @param[out] aPSKc A pointer to where the generated PSKc will be placed. + * + * @retval kThreadErrorNone Successfully generate PSKc. + * @retval kThreadError_InvalidArgs If any of the input arguments is invalid. + * + */ +OTAPI ThreadError OTCALL otGeneratePSKc(otInstance *aInstance, const char *aPassPhrase, const char *aNetworkName, + const uint8_t *aExtPanId, uint8_t *aPSKc); + /** * This function returns the maximum transmit power setting in dBm. * diff --git a/src/cli/README.md b/src/cli/README.md index df61d5db0..7c01ce344 100644 --- a/src/cli/README.md +++ b/src/cli/README.md @@ -406,6 +406,7 @@ networkname panid pending pendingtimestamp +pskc userdata Done ``` @@ -645,6 +646,24 @@ Set pending timestamp. Done ``` +### dataset pskc \[pskc\] + +Set pskc with hex format. + +```bash +> dataset pskc 67c0c203aa0b042bfb5381c47aef4d9e +Done +``` + +### dataset pskc \[passphrase\] \[networkname\] \[extpanid\] + +Generate pskc from passphrase, network name and extended panid. + +```bash +> dataset pskc OpenThreadPassphrase OpenThread dead00beef00cafe +Done +``` + ### dataset userdata \[size\] \[data\] Set user specific data for the command. diff --git a/src/cli/cli_dataset.cpp b/src/cli/cli_dataset.cpp index cc1f86df8..b3100cfe8 100644 --- a/src/cli/cli_dataset.cpp +++ b/src/cli/cli_dataset.cpp @@ -666,17 +666,25 @@ exit: ThreadError Dataset::ProcessPSKc(otInstance *aInstance, int argc, char *argv[]) { ThreadError error = kThreadError_None; + uint8_t extPanId[OT_EXT_PAN_ID_SIZE]; uint16_t length; - VerifyOrExit(argc > 0, error = kThreadError_Parse); + VerifyOrExit((argc == 1) || (argc == 3), error = kThreadError_Parse); - length = static_cast((strlen(argv[0]) + 1) / 2); - VerifyOrExit(length <= OT_PSKC_MAX_SIZE, error = kThreadError_NoBufs); - VerifyOrExit(Interpreter::Hex2Bin(argv[0], sDataset.mPSKc.m8 + OT_PSKC_MAX_SIZE - length, length) - == length, error = kThreadError_Parse); + if (argc == 1) + { + length = static_cast((strlen(argv[0]) + 1) / 2); + VerifyOrExit(length <= OT_PSKC_MAX_SIZE, error = kThreadError_NoBufs); + VerifyOrExit(Interpreter::Hex2Bin(argv[0], sDataset.mPSKc.m8 + OT_PSKC_MAX_SIZE - length, length) == length, + error = kThreadError_Parse); + } + else + { + VerifyOrExit(Interpreter::Hex2Bin(argv[2], extPanId, sizeof(extPanId)) >= 0, error = kThreadError_Parse); + SuccessOrExit(error = otGeneratePSKc(aInstance, argv[0], argv[1], extPanId, sDataset.mPSKc.m8)); + } sDataset.mIsPSKcSet = true; - (void)aInstance; exit: return error; diff --git a/src/core/Makefile.am b/src/core/Makefile.am index b66dc9459..493313423 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -147,6 +147,7 @@ libopenthread_ftd_a_CPPFLAGS = \ libopenthread_ftd_a_SOURCES = \ $(SOURCES_COMMON) \ + crypto/pbkdf2_cmac.cpp \ meshcop/dataset_manager_ftd.cpp \ meshcop/joiner_router.cpp \ meshcop/leader.cpp \ @@ -192,6 +193,7 @@ noinst_HEADERS = \ crypto/aes_ecb.hpp \ crypto/hmac_sha256.hpp \ crypto/mbedtls.hpp \ + crypto/pbkdf2_cmac.h \ crypto/sha256.hpp \ mac/mac.hpp \ mac/mac_blacklist.hpp \ diff --git a/src/core/crypto/pbkdf2_cmac.cpp b/src/core/crypto/pbkdf2_cmac.cpp new file mode 100644 index 000000000..518569276 --- /dev/null +++ b/src/core/crypto/pbkdf2_cmac.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2016, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * This file implements PBKDF2 using AES-CMAC-PRF-128 + */ + +#include +#include +#include + +namespace Thread { +namespace Crypto { + +#ifdef __cplusplus +extern "C" { +#endif + +void otPbkdf2Cmac( + const uint8_t *aPassword, uint16_t aPasswordLen, + const uint8_t *aSalt, uint16_t aSaltLen, + uint32_t aIterationCounter , uint16_t aKeyLen, + uint8_t *aKey) +{ + uint32_t blockCounter = 0; + uint16_t useLen = 0; + uint16_t prfBlockLen = MBEDTLS_CIPHER_BLKSIZE_MAX; + uint8_t prfInput[OT_PBKDF2_SALT_MAX_LEN + 4]; // Salt || INT(), for U1 calculation + uint8_t prfOutput[MBEDTLS_CIPHER_BLKSIZE_MAX]; + uint8_t keyBlock[MBEDTLS_CIPHER_BLKSIZE_MAX]; + uint8_t *key = aKey; + uint16_t keyLen = aKeyLen; + + while (keyLen) + { + memcpy(prfInput, aSalt, aSaltLen); + + blockCounter++; + prfInput[aSaltLen + 0] = (uint8_t)(blockCounter >> 24); + prfInput[aSaltLen + 1] = (uint8_t)(blockCounter >> 16); + prfInput[aSaltLen + 2] = (uint8_t)(blockCounter >> 8); + prfInput[aSaltLen + 3] = (uint8_t)(blockCounter); + + // Calculate U_1 + mbedtls_aes_cmac_prf_128(aPassword, aPasswordLen, prfInput, aSaltLen + 4, prfOutput); + memcpy(keyBlock, prfOutput, prfBlockLen); + + for (uint32_t i = 1; i < aIterationCounter; i++) + { + memcpy(prfInput, prfOutput, prfBlockLen); + + // Calculate U_i + mbedtls_aes_cmac_prf_128(aPassword, aPasswordLen, prfInput, prfBlockLen, prfOutput); + + // xor + for (uint32_t j = 0; j < prfBlockLen; j++) + { + keyBlock[j] ^= prfOutput[j]; + } + } + + useLen = (keyLen < prfBlockLen) ? keyLen : prfBlockLen; + memcpy(key, keyBlock, useLen); + key += useLen; + keyLen -= useLen; + } +} + +#ifdef __cplusplus +} // extern "C" +#endif + +} // namespace Crypto +} // namespace Thread diff --git a/src/core/crypto/pbkdf2_cmac.h b/src/core/crypto/pbkdf2_cmac.h new file mode 100644 index 000000000..a69d07a1b --- /dev/null +++ b/src/core/crypto/pbkdf2_cmac.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2016, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief + * This file defines the PBKDF2 using CMAC C APIs. + */ + +#ifndef PBKDF2_CMAC_H_ +#define PBKDF2_CMAC_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define OT_PBKDF2_SALT_MAX_LEN 30 // salt prefix (6) + extended panid (8) + network name (16) + +/** + * This method perform PKCS#5 PBKDF2 using CMAC (AES-CMAC-PRF-128). + * + * @param[in] aPassword Password to use when generating key. + * @param[in] aPasswordLen Length of password. + * @param[in] aSalt Salt to use when generating key. + * @param[in] aSaltLen Length of salt. + * @param[in] aIterationCounter Iteration count. + * @param[in] aKeyLen Length of generated key in bytes. + * @param[out] aKey A pointer to the generated key. + * + */ +void otPbkdf2Cmac( + const uint8_t *aPassword, uint16_t aPasswordLen, + const uint8_t *aSalt, uint16_t aSaltLen, + uint32_t aIterationCounter , uint16_t aKeyLen, + uint8_t *aKey); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // PBKDF2_CMAC_H_ diff --git a/src/core/meshcop/dataset_manager_ftd.cpp b/src/core/meshcop/dataset_manager_ftd.cpp index 60515c2fb..80d8c2378 100644 --- a/src/core/meshcop/dataset_manager_ftd.cpp +++ b/src/core/meshcop/dataset_manager_ftd.cpp @@ -156,10 +156,15 @@ ThreadError ActiveDataset::GenerateLocal(void) // PSKc if (!IsTlvInitialized(Tlv::kPSKc)) { - const uint8_t PSKc[16] = {0}; PSKcTlv tlv; + uint8_t pskc[OT_PSKC_MAX_SIZE] = {0}; + const char password[OT_COMMISSIONING_PASSPHRASE_MAX_SIZE] = OT_COMMISSIONING_PASSPHRASE_DEFAULT; + const char *networkName = mNetif.GetMac().GetNetworkName(); + const uint8_t *extPanId = mNetif.GetMac().GetExtendedPanId(); + + mNetif.GetNetworkDataLeader().GeneratePSKc(password, networkName, extPanId, pskc); tlv.Init(); - tlv.SetPSKc(PSKc); + tlv.SetPSKc(pskc); mLocal.Set(tlv); } diff --git a/src/core/openthread.cpp b/src/core/openthread.cpp index e5dd730d4..0a7b5fcc1 100644 --- a/src/core/openthread.cpp +++ b/src/core/openthread.cpp @@ -270,6 +270,12 @@ ThreadError otSetMasterKey(otInstance *aInstance, const uint8_t *aKey, uint8_t a return aInstance->mThreadNetif.GetKeyManager().SetMasterKey(aKey, aKeyLength); } +ThreadError otGeneratePSKc(otInstance *aInstance, const char *aPassPhrase, const char *aNetworkName, + const uint8_t *aExtPanId, uint8_t *aPSKc) +{ + return aInstance->mThreadNetif.GetNetworkDataLeader().GeneratePSKc(aPassPhrase, aNetworkName, aExtPanId, aPSKc); +} + int8_t otGetMaxTransmitPower(otInstance *aInstance) { return aInstance->mThreadNetif.GetMac().GetMaxTransmitPower(); diff --git a/src/core/thread/network_data_leader_ftd.cpp b/src/core/thread/network_data_leader_ftd.cpp index 479f6fbb7..d31dd7580 100644 --- a/src/core/thread/network_data_leader_ftd.cpp +++ b/src/core/thread/network_data_leader_ftd.cpp @@ -48,6 +48,7 @@ #include #include #include +#include using Thread::Encoding::BigEndian::HostSwap16; @@ -1074,5 +1075,33 @@ void Leader::HandleTimer(void) } } +ThreadError Leader::GeneratePSKc(const char *aPassPhrase, const char *aNetworkName, const uint8_t *aExtPanId, + uint8_t *aPSKc) +{ + ThreadError error = kThreadError_None; + const char *saltPrefix = "Thread"; + uint8_t salt[OT_PBKDF2_SALT_MAX_LEN]; + uint16_t saltLen = 0; + + VerifyOrExit((strlen(aPassPhrase) >= OT_COMMISSIONING_PASSPHRASE_MIN_SIZE) && + (strlen(aPassPhrase) <= OT_COMMISSIONING_PASSPHRASE_MAX_SIZE), error = kThreadError_InvalidArgs); + + memset(salt, 0, sizeof(salt)); + memcpy(salt, saltPrefix, strlen(saltPrefix)); + saltLen += static_cast(strlen(saltPrefix)); + + memcpy(salt + saltLen, aExtPanId, OT_EXT_PAN_ID_SIZE); + saltLen += OT_EXT_PAN_ID_SIZE; + + memcpy(salt + saltLen, aNetworkName, strlen(aNetworkName)); + saltLen += static_cast(strlen(aNetworkName)); + + otPbkdf2Cmac(reinterpret_cast(aPassPhrase), static_cast(strlen(aPassPhrase)), + reinterpret_cast(salt), saltLen, 16384, OT_PSKC_MAX_SIZE, aPSKc); + +exit: + return error; +} + } // namespace NetworkData } // namespace Thread diff --git a/src/core/thread/network_data_leader_ftd.hpp b/src/core/thread/network_data_leader_ftd.hpp index 5946439af..d53c1e6a9 100644 --- a/src/core/thread/network_data_leader_ftd.hpp +++ b/src/core/thread/network_data_leader_ftd.hpp @@ -140,6 +140,22 @@ public: */ ThreadError SendServerDataNotification(uint16_t aRloc16); + /** + * This method generates PSKc. + * + * PSKc is used to establish the Commissioner Session. + * + * @param[in] aPassPhrase The commissioning passphrase. + * @param[in] aNetworkName The network name for PSKc computation. + * @param[in] aExtPanId The extended pan id for PSKc computation. + * @param[out] aPSKc A pointer to where the generated PSKc will be placed. + * + * @retval kThreadErrorNone Successfully generate PSKc. + * @retval kThreadError_InvalidArgs If the length of passphrase is out of range. + * + */ + ThreadError GeneratePSKc(const char *aPassPhrase, const char *aNetworkName, const uint8_t *aExtPanId, uint8_t *aPSKc); + private: static void HandleServerData(void *aContext, otCoapHeader *aHeader, otMessage aMessage, const otMessageInfo *aMessageInfo); diff --git a/src/core/thread/network_data_leader_mtd.hpp b/src/core/thread/network_data_leader_mtd.hpp index 6eec4594f..235eefec3 100644 --- a/src/core/thread/network_data_leader_mtd.hpp +++ b/src/core/thread/network_data_leader_mtd.hpp @@ -59,6 +59,8 @@ public: void RemoveBorderRouter(uint16_t) { } ThreadError SendServerDataNotification(uint16_t) { return kThreadError_NotImplemented; } + + ThreadError GeneratePSKc(const char *, const char *, const uint8_t *, uint8_t *) { return kThreadError_NotImplemented; } }; } // namespace NetworkData diff --git a/third_party/mbedtls/Makefile.am b/third_party/mbedtls/Makefile.am index 1d1a72a43..61332df5c 100644 --- a/third_party/mbedtls/Makefile.am +++ b/third_party/mbedtls/Makefile.am @@ -43,6 +43,10 @@ libmbedcrypto_a_CPPFLAGS = \ libmbedcrypto_a_SOURCES = \ hardware_entropy.c \ repo/library/aes.c \ + repo/library/ccm.c \ + repo/library/cipher.c \ + repo/library/cipher_wrap.c \ + repo/library/cmac.c \ repo/library/md.c \ repo/library/md_wrap.c \ repo/library/memory_buffer_alloc.c \ @@ -53,9 +57,6 @@ libmbedcrypto_a_SOURCES = \ if OPENTHREAD_ENABLE_DTLS libmbedcrypto_a_SOURCES += \ repo/library/bignum.c \ - repo/library/ccm.c \ - repo/library/cipher.c \ - repo/library/cipher_wrap.c \ repo/library/ctr_drbg.c \ repo/library/debug.c \ repo/library/ecjpake.c \ diff --git a/third_party/mbedtls/mbedtls-config.h b/third_party/mbedtls/mbedtls-config.h index 9e7fbf9fb..116299053 100644 --- a/third_party/mbedtls/mbedtls-config.h +++ b/third_party/mbedtls/mbedtls-config.h @@ -39,6 +39,7 @@ // Temporary, until the warnings can get fixed in the mbed library #pragma warning(disable:4242) // conversion from '*' to '*', possible loss of data #pragma warning(disable:4244) // conversion from '*' to '*', possible loss of data +#pragma warning(disable:4267) // conversion from '*' to '*', possible loss of data #endif #if defined(_KERNEL_MODE) @@ -1696,7 +1697,7 @@ __inline int windows_kernel_snprintf(char * s, size_t n, const char * format, .. * Requires: MBEDTLS_AES_C or MBEDTLS_DES_C * */ -//#define MBEDTLS_CMAC_C +#define MBEDTLS_CMAC_C /** * \def MBEDTLS_CTR_DRBG_C