@@ -238,7 +238,7 @@ CHIP_ERROR P256Keypair::ECDH_derive_secret(const P256PublicKey & remote_public_k
238
238
return ECDH_derive_secret_H (&mKeypair , remote_public_key, out_secret);
239
239
}
240
240
241
- ChipLogDetail (Crypto, " ECDH_derive_secret: TrustM " );
241
+ ChipLogDetail (Crypto, " TrustM: ECDH_derive_secret " );
242
242
trustm_Open ();
243
243
244
244
const uint8_t * const rem_pubKey = Uint8::to_const_uchar (remote_public_key);
@@ -281,7 +281,7 @@ CHIP_ERROR P256PublicKey::ECDSA_validate_hash_signature(const uint8_t * hash, si
281
281
282
282
VerifyOrReturnError (hash != nullptr , CHIP_ERROR_INVALID_ARGUMENT);
283
283
VerifyOrReturnError (hash_length > 0 , CHIP_ERROR_INVALID_ARGUMENT);
284
- ChipLogDetail (Crypto, " ECDSA_validate_hash_signature" );
284
+ ChipLogDetail (Crypto, " TrustM: ECDSA_validate_hash_signature" );
285
285
286
286
// Trust M init
287
287
trustm_Open ();
@@ -338,20 +338,19 @@ CHIP_ERROR P256Keypair::Deserialize(P256SerializedKeypair & input)
338
338
339
339
VerifyOrReturnError (input.Length () == public_key.Length () + kP256_PrivateKey_Length , CHIP_ERROR_INVALID_ARGUMENT);
340
340
341
- privkey = input.ConstBytes () /* Uint8::to_const_uchar(input) */ + public_key.Length ();
341
+ privkey = input.ConstBytes () + public_key.Length ();
342
342
343
343
if (0 == memcmp (privkey, trustm_magic_no, sizeof (trustm_magic_no)))
344
344
{
345
345
/* trustm_magic_no + KeyID is passed */
346
- ChipLogDetail (Crypto, " Deserialize: ref key found" );
346
+ ChipLogDetail (Crypto, " Deserialize: key found" );
347
347
bbuf.Put (input.Bytes (), public_key.Length ());
348
348
VerifyOrReturnError (bbuf.Fit (), CHIP_ERROR_NO_MEMORY);
349
349
350
350
memcpy (&mKeypair .mBytes [0 ], trustm_magic_no, sizeof (trustm_magic_no));
351
351
352
352
mKeypair .mBytes [4 ] = *(privkey + 4 );
353
353
mKeypair .mBytes [5 ] = *(privkey + 5 );
354
- // ChipLogDetail(Crypto, "Parsed keyId = 0x%02X%02X", mKeypair.mBytes[4], mKeypair.mBytes[5]);
355
354
356
355
mInitialized = true ;
357
356
@@ -390,7 +389,7 @@ CHIP_ERROR P256PublicKey::ECDSA_validate_msg_signature(const uint8_t * msg, size
390
389
VerifyOrReturnError (msg != nullptr , CHIP_ERROR_INVALID_ARGUMENT);
391
390
VerifyOrReturnError (msg_length > 0 , CHIP_ERROR_INVALID_ARGUMENT);
392
391
393
- ChipLogDetail (Crypto, " ECDSA_validate_msg_signature" );
392
+ ChipLogDetail (Crypto, " TrustM: ECDSA_validate_msg_signature" );
394
393
395
394
// Trust M init
396
395
trustm_Open ();
@@ -399,8 +398,6 @@ CHIP_ERROR P256PublicKey::ECDSA_validate_msg_signature(const uint8_t * msg, size
399
398
out_der_sig_span);
400
399
SuccessOrExit (error);
401
400
402
- /* Set the public key */
403
- // P256PublicKeyHSM & public_key = const_cast<P256PublicKeyHSM &>(Pubkey());
404
401
signature_trustm_len = out_der_sig_span.size ();
405
402
// Hash to get the digest
406
403
memset (&digest[0 ], 0 , sizeof (digest));
@@ -422,7 +419,7 @@ CHIP_ERROR P256PublicKey::ECDSA_validate_msg_signature(const uint8_t * msg, size
422
419
423
420
static void add_tlv (uint8_t * buf, size_t buf_index, uint8_t tag, size_t len, uint8_t * val)
424
421
{
425
- buf[buf_index++] = ( uint8_t ) tag;
422
+ buf[buf_index++] = tag;
426
423
buf[buf_index++] = (uint8_t ) len;
427
424
if (len > 0 && val != NULL )
428
425
{
@@ -501,8 +498,6 @@ CHIP_ERROR P256Keypair::NewCertificateSigningRequest(uint8_t * csr, size_t & csr
501
498
502
499
// Add length
503
500
buffer_index -= kTlvHeader ;
504
- // Subject TLV ==> 1 + 1 + len(subject)
505
- // Org OID TLV ==> 1 + 1 + len(organisation_oid)
506
501
VerifyOrExit (buffer_index > 0 , error = CHIP_ERROR_INTERNAL);
507
502
add_tlv (data_to_hash, buffer_index, (ASN1_CONSTRUCTED | ASN1_SEQUENCE),
508
503
((2 * kTlvHeader ) + (sizeof (SUBJECT_STR) - 1 ) + sizeof (organisation_oid)), NULL );
0 commit comments