Skip to content

Commit

Permalink
Alignments to the Matter Core.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArekBalysNordic committed Apr 10, 2024
1 parent 5933e57 commit f0b7593
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
7 changes: 5 additions & 2 deletions config/nrfconnect/chip-module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,11 @@ else()
endif()

if (CONFIG_CHIP_CRYPTO_PSA)
matter_add_gn_arg_string("chip_crypto" "psa")
matter_add_gn_arg_bool ("chip_crypto_psa_spake2p" TRUE)
matter_add_gn_arg_string("chip_crypto" "psa")
# PSA Spake2+ implementation is not ready for the POSIX target yet
if((NOT BOARD STREQUAL "native_posix") AND (NOT BOARD STREQUAL "native_posix_64"))
matter_add_gn_arg_bool ("chip_crypto_psa_spake2p" TRUE)
endif()
endif()

if (BOARD STREQUAL "native_posix")
Expand Down
1 change: 0 additions & 1 deletion src/crypto/CHIPCryptoPALPSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ CHIP_ERROR PsaKdf::InitOperation(psa_key_id_t hkdfKey, const ByteSpan & salt, co
CHIP_ERROR PsaKdf::DeriveBytes(const MutableByteSpan & output)
{
psa_status_t status = psa_key_derivation_output_bytes(&mOperation, output.data(), output.size());

VerifyOrReturnError(status == PSA_SUCCESS, CHIP_ERROR_INTERNAL);

return CHIP_NO_ERROR;
Expand Down
6 changes: 3 additions & 3 deletions src/crypto/PSASpake2p.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Project CHIP Authors
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -181,7 +181,7 @@ CHIP_ERROR PSASpake2p_P256_SHA256_HKDF_HMAC::KeyConfirm(const uint8_t * in, size
return CHIP_NO_ERROR;
}

CHIP_ERROR PSASpake2p_P256_SHA256_HKDF_HMAC::GetKeys(uint8_t * out, size_t * out_len)
CHIP_ERROR PSASpake2p_P256_SHA256_HKDF_HMAC::GetKeys(SessionKeystore & keystore, HkdfKeyHandle & key) const
{
auto & keyId = key.AsMutable<psa_key_id_t>();

Expand All @@ -191,7 +191,7 @@ CHIP_ERROR PSASpake2p_P256_SHA256_HKDF_HMAC::GetKeys(uint8_t * out, size_t * out
psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_DERIVE);
psa_set_key_algorithm(&attributes, PSA_ALG_HKDF(PSA_ALG_SHA_256));

psa_status_t status = psa_pake_get_shared_key(&mOperation, &attributes, &keyId);
psa_status_t status = psa_pake_get_shared_key(const_cast<psa_pake_operation_t *>(&(mOperation)), &attributes, &keyId);
VerifyOrReturnError(status == PSA_SUCCESS, CHIP_ERROR_INTERNAL);

return CHIP_NO_ERROR;
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/PSASpake2p.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Project CHIP Authors
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -151,7 +151,7 @@ class PSASpake2p_P256_SHA256_HKDF_HMAC
*
* @return Returns a CHIP_ERROR on error, CHIP_NO_ERROR otherwise
**/
CHIP_ERROR GetKeys(uint8_t * out, size_t * out_len);
CHIP_ERROR GetKeys(SessionKeystore & keystore, HkdfKeyHandle & key) const;

private:
psa_pake_operation_t mOperation = PSA_PAKE_OPERATION_INIT;
Expand Down
2 changes: 1 addition & 1 deletion src/protocols/secure_channel/PASESession.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class DLL_EXPORT PASESession : public Messaging::UnsolicitedMessageHandler,
Optional<Protocols::SecureChannel::MsgType> mNextExpectedMsg;

#if CHIP_CRYPTO_PSA_SPAKE2P
Spake2p_P256_SHA256_HKDF_HMAC mSpake2p;
Crypto::PSASpake2p_P256_SHA256_HKDF_HMAC mSpake2p;
#else
Crypto::Spake2p_P256_SHA256_HKDF_HMAC mSpake2p;
#endif
Expand Down

0 comments on commit f0b7593

Please sign in to comment.