@@ -241,9 +241,6 @@ CHIP_ERROR FabricInfo::SetOperationalKeypair(const P256Keypair * keyPair)
241
241
{
242
242
VerifyOrReturnError (keyPair != nullptr , CHIP_ERROR_INVALID_ARGUMENT);
243
243
244
- P256SerializedKeypair serialized;
245
- ReturnErrorOnFailure (keyPair->Serialize (serialized));
246
-
247
244
if (mHasExternallyOwnedOperationalKey )
248
245
{
249
246
// Drop it, so we will allocate an internally owned one.
@@ -256,7 +253,7 @@ CHIP_ERROR FabricInfo::SetOperationalKeypair(const P256Keypair * keyPair)
256
253
mOperationalKey = chip::Platform::New<P256Keypair>();
257
254
}
258
255
VerifyOrReturnError (mOperationalKey != nullptr , CHIP_ERROR_NO_MEMORY);
259
- return mOperationalKey ->Deserialize (serialized );
256
+ return mOperationalKey ->Copy (*keyPair );
260
257
}
261
258
262
259
CHIP_ERROR FabricInfo::SetExternallyOwnedOperationalKeypair (P256Keypair * keyPair)
@@ -690,16 +687,12 @@ CHIP_ERROR FabricTable::AddNewFabricForTest(const ByteSpan & rootCert, const Byt
690
687
CHIP_ERROR err = CHIP_ERROR_INTERNAL;
691
688
692
689
Crypto::P256Keypair injectedOpKey;
693
- Crypto::P256SerializedKeypair injectedOpKeysSerialized;
694
-
695
690
Crypto::P256Keypair * opKey = nullptr ;
691
+
696
692
if (!opKeySpan.empty ())
697
693
{
698
- VerifyOrReturnError (opKeySpan.size () == injectedOpKeysSerialized.Capacity (), CHIP_ERROR_INVALID_ARGUMENT);
699
-
700
- memcpy (injectedOpKeysSerialized.Bytes (), opKeySpan.data (), opKeySpan.size ());
701
- SuccessOrExit (err = injectedOpKeysSerialized.SetLength (opKeySpan.size ()));
702
- SuccessOrExit (err = injectedOpKey.Deserialize (injectedOpKeysSerialized));
694
+ VerifyOrReturnError (opKeySpan.size () == kP256_PublicKey_Length + kP256_PrivateKey_Length , CHIP_ERROR_INVALID_ARGUMENT);
695
+ SuccessOrExit (err = injectedOpKey.ImportRawKeypair (opKeySpan));
703
696
opKey = &injectedOpKey;
704
697
}
705
698
0 commit comments