From 6011573b7678d035e0ababebaccdc84a93bee90b Mon Sep 17 00:00:00 2001 From: joonhaengHeo <85541460+joonhaengHeo@users.noreply.github.com> Date: Sat, 2 Jul 2022 04:01:32 +0900 Subject: [PATCH] [Android] Fix Android commissioning complete fail (#20098) * Change to move KeyPair variable * Add comment --- src/controller/java/AndroidDeviceControllerWrapper.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/controller/java/AndroidDeviceControllerWrapper.cpp b/src/controller/java/AndroidDeviceControllerWrapper.cpp index cbbbbfe172aee0..9384f29d79b706 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.cpp +++ b/src/controller/java/AndroidDeviceControllerWrapper.cpp @@ -193,6 +193,9 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew( } MutableByteSpan rcacSpan(rcac.Get(), kMaxCHIPDERCertLength); + // The lifetime of the ephemeralKey variable must be kept until SetupParams is saved. + Crypto::P256Keypair ephemeralKey; + if (rootCertificate != nullptr && intermediateCertificate != nullptr && nodeOperationalCertificate != nullptr && keypairDelegate != nullptr) { @@ -217,7 +220,6 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew( } else { - Crypto::P256Keypair ephemeralKey; *errInfoOnFailure = ephemeralKey.Initialize(); if (*errInfoOnFailure != CHIP_NO_ERROR) {