-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the missing parts to link message layer to CHIP.
* Implement a basic set of protocols to enable basic feature of message layer * Add message layer to GN build system Restyled by whitespace Restyled by clang-format Restyled by gn
- Loading branch information
1 parent
7aa6f53
commit 5754565
Showing
23 changed files
with
2,451 additions
and
32 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
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,112 @@ | ||
/* | ||
* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* Copyright (c) 2013-2017 Nest Labs, Inc. | ||
* All rights reserved. | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @file | ||
* This file implements AES block cipher functions for the Weave layer. | ||
* The implementation is based on the OpenSSL library functions. | ||
* This implementation is used when #CHIP_CONFIG_AES_IMPLEMENTATION_OPENSSL | ||
* is enabled (1). | ||
* | ||
*/ | ||
|
||
#include <string.h> | ||
|
||
#include "AESBlockCipher.h" | ||
#include "CHIPCrypto.h" | ||
|
||
namespace chip { | ||
namespace Platform { | ||
namespace Security { | ||
|
||
using namespace chip::Crypto; | ||
|
||
AES128BlockCipher::AES128BlockCipher() | ||
{ | ||
memset(&mKey, 0, sizeof(mKey)); | ||
} | ||
|
||
AES128BlockCipher::~AES128BlockCipher() | ||
{ | ||
Reset(); | ||
} | ||
|
||
void AES128BlockCipher::Reset() | ||
{ | ||
ClearSecretData((uint8_t *) &mKey, sizeof(mKey)); | ||
} | ||
|
||
void AES128BlockCipherEnc::SetKey(const uint8_t * key) | ||
{ | ||
// AES_set_encrypt_key(key, kKeyLengthBits, &mKey); | ||
} | ||
|
||
void AES128BlockCipherEnc::EncryptBlock(const uint8_t * inBlock, uint8_t * outBlock) | ||
{ | ||
// AES_encrypt(inBlock, outBlock, &mKey); | ||
} | ||
|
||
void AES128BlockCipherDec::SetKey(const uint8_t * key) | ||
{ | ||
// AES_set_decrypt_key(key, kKeyLengthBits, &mKey); | ||
} | ||
|
||
void AES128BlockCipherDec::DecryptBlock(const uint8_t * inBlock, uint8_t * outBlock) | ||
{ | ||
// AES_decrypt(inBlock, outBlock, &mKey); | ||
} | ||
|
||
AES256BlockCipher::AES256BlockCipher() | ||
{ | ||
memset(&mKey, 0, sizeof(mKey)); | ||
} | ||
|
||
AES256BlockCipher::~AES256BlockCipher() | ||
{ | ||
Reset(); | ||
} | ||
|
||
void AES256BlockCipher::Reset() | ||
{ | ||
ClearSecretData((uint8_t *) &mKey, sizeof(mKey)); | ||
} | ||
|
||
void AES256BlockCipherEnc::SetKey(const uint8_t * key) | ||
{ | ||
// AES_set_encrypt_key(key, kKeyLengthBits, &mKey); | ||
} | ||
|
||
void AES256BlockCipherEnc::EncryptBlock(const uint8_t * inBlock, uint8_t * outBlock) | ||
{ | ||
// AES_encrypt(inBlock, outBlock, &mKey); | ||
} | ||
|
||
void AES256BlockCipherDec::SetKey(const uint8_t * key) | ||
{ | ||
// AES_set_decrypt_key(key, kKeyLengthBits, &mKey); | ||
} | ||
|
||
void AES256BlockCipherDec::DecryptBlock(const uint8_t * inBlock, uint8_t * outBlock) | ||
{ | ||
// AES_decrypt(inBlock, outBlock, &mKey); | ||
} | ||
|
||
} // namespace Security | ||
} // namespace Platform | ||
} // namespace chip |
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,57 @@ | ||
/* | ||
* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* Copyright (c) 2013-2017 Nest Labs, Inc. | ||
* All rights reserved. | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @file | ||
* This file implements general purpose cryptographic functions for the Message layer. | ||
* | ||
*/ | ||
|
||
#include <string.h> | ||
|
||
#include "CHIPCrypto.h" | ||
|
||
namespace chip { | ||
namespace Crypto { | ||
|
||
/** | ||
* Compares the first `len` bytes of memory area `buf1` and memory area `buf2`. | ||
* | ||
* The time taken by this function is independent of the data in memory areas `buf1` and `buf2`. | ||
* | ||
* @param[in] buf1 Pointer to a memory block. | ||
* | ||
* @param[in] buf2 Pointer to a memory block. | ||
* | ||
* @param[in] len Size of memory area to compare in bytes. | ||
* | ||
* @retval true if first \c len bytes of memory area \c buf1 and \c buf2 are equal. | ||
* @retval false otherwise. | ||
* | ||
*/ | ||
bool ConstantTimeCompare(const uint8_t * buf1, const uint8_t * buf2, uint16_t len) | ||
{ | ||
uint8_t c = 0; | ||
for (uint16_t i = 0; i < len; i++) | ||
c |= buf1[i] ^ buf2[i]; | ||
return c == 0; | ||
} | ||
|
||
} // namespace Crypto | ||
} // namespace chip |
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 @@ | ||
/* | ||
* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* Copyright (c) 2013-2017 Nest Labs, Inc. | ||
* All rights reserved. | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @file | ||
* This file implements secure random data initialization and generation functions | ||
* for the Weave layer. The implementation is based on the OpenSSL Library functions. | ||
* This implementation is used when #WEAVE_CONFIG_RNG_IMPLEMENTATION_OPENSSL | ||
* is enabled (1). | ||
* | ||
*/ | ||
|
||
#include "CHIPRNG.h" | ||
|
||
namespace chip { | ||
namespace Platform { | ||
namespace Security { | ||
|
||
CHIP_ERROR InitSecureRandomDataSource(chip::Crypto::EntropyFunct entropyFunct, uint16_t entropyLen, | ||
const uint8_t * personalizationData, uint16_t perDataLen) | ||
{ | ||
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; | ||
} | ||
|
||
CHIP_ERROR GetSecureRandomData(uint8_t * buf, uint16_t len) | ||
{ | ||
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; | ||
} | ||
|
||
} // namespace Security | ||
} // namespace Platform | ||
} // namespace chip |
Oops, something went wrong.