@@ -34,7 +34,7 @@ public class Security2 : CommandClassBase
3434 private const byte TRANSFER_COMPLETE = 0x1 ;
3535 public event CommandClassEvent < ErrorReport > ? SecurityError ;
3636 TaskCompletionSource bootstrapComplete = new TaskCompletionSource ( ) ;
37- private static uint sequence = ( uint ) new Random ( ) . Next ( ) ;
37+ private static uint sequence = ( uint ) Random . Shared . Next ( ) ;
3838
3939 internal enum Security2Command
4040 {
@@ -128,7 +128,7 @@ internal async Task KexFail(KexFailType type, CancellationToken cancellationToke
128128 controller . SecurityManager ? . GetRequestedKeys ( node . ID , true ) ;
129129 if ( type == KexFailType . KEX_FAIL_AUTH || type == KexFailType . KEX_FAIL_DECRYPT || type == KexFailType . KEX_FAIL_KEY_VERIFY || type == KexFailType . KEX_FAIL_KEY_GET )
130130 {
131- CommandMessage reportKex = new CommandMessage ( controller , node . ID , EndPoint , CommandClass , ( byte ) Security2Command . KEXFail , false , ( byte ) type ) ;
131+ CommandMessage reportKex = new CommandMessage ( controller , [ node . ID ] , EndPoint , CommandClass , ( byte ) Security2Command . KEXFail , false , ( byte ) type ) ;
132132 await Transmit ( reportKex . Payload , SecurityManager . RecordType . ECDH_TEMP , cancellationToken ) . ConfigureAwait ( false ) ;
133133 }
134134 else
@@ -386,6 +386,8 @@ internal override async Task<SupervisionStatus> Handle(ReportMessage message)
386386 {
387387 if ( controller . SecurityManager == null )
388388 return SupervisionStatus . Fail ;
389+ if ( message . IsMulticastMethod )
390+ return SupervisionStatus . Fail ;
389391 KeyExchangeReport ? requestedKeys = controller . SecurityManager . GetRequestedKeys ( node . ID ) ;
390392 if ( requestedKeys != null )
391393 {
@@ -396,7 +398,7 @@ internal override async Task<SupervisionStatus> Handle(ReportMessage message)
396398 }
397399 requestedKeys . Echo = true ;
398400 Log . Verbose ( "Responding: " + requestedKeys . ToString ( ) ) ;
399- CommandMessage reportKex = new CommandMessage ( controller , node . ID , EndPoint , CommandClass , ( byte ) Security2Command . KEXReport , false , requestedKeys . ToBytes ( ) ) ;
401+ CommandMessage reportKex = new CommandMessage ( controller , [ node . ID ] , EndPoint , CommandClass , ( byte ) Security2Command . KEXReport , false , requestedKeys . ToBytes ( ) ) ;
400402 await Transmit ( reportKex . Payload , SecurityManager . RecordType . ECDH_TEMP ) . ConfigureAwait ( false ) ;
401403 }
402404 }
@@ -445,13 +447,15 @@ internal override async Task<SupervisionStatus> Handle(ReportMessage message)
445447 default :
446448 return SupervisionStatus . Fail ; //Invalid Key Type - Ignore this
447449 }
448- CommandMessage data = new CommandMessage ( controller , node . ID , EndPoint , CommandClass , ( byte ) Security2Command . NetworkKeyReport , false , resp ) ;
450+ CommandMessage data = new CommandMessage ( controller , [ node . ID ] , EndPoint , CommandClass , ( byte ) Security2Command . NetworkKeyReport , false , resp ) ;
449451 await Transmit ( data . Payload , SecurityManager . RecordType . ECDH_TEMP ) . ConfigureAwait ( false ) ;
450452 Log . Verbose ( $ "Provided Network Key { key } ") ;
451453 return SupervisionStatus . Success ;
452454 case Security2Command . NetworkKeyVerify :
453455 if ( controller . SecurityManager == null )
454456 return SupervisionStatus . Fail ;
457+ if ( message . IsMulticastMethod )
458+ return SupervisionStatus . Fail ;
455459 Log . Verbose ( "Network Key Verified!" ) ;
456460 if ( message . SecurityLevel == SecurityKey . None || ( message . Flags & ReportFlags . Security ) != ReportFlags . Security )
457461 {
@@ -460,7 +464,7 @@ internal override async Task<SupervisionStatus> Handle(ReportMessage message)
460464 }
461465 Log . Information ( $ "Revoking { message . SecurityLevel } ") ;
462466 controller . SecurityManager . RevokeKey ( node . ID , SecurityManager . KeyToType ( message . SecurityLevel ) ) ;
463- CommandMessage transferEnd = new CommandMessage ( controller , node . ID , EndPoint , CommandClass , ( byte ) Security2Command . TransferEnd , false , KEY_VERIFIED ) ;
467+ CommandMessage transferEnd = new CommandMessage ( controller , [ node . ID ] , EndPoint , CommandClass , ( byte ) Security2Command . TransferEnd , false , KEY_VERIFIED ) ;
464468 await Transmit ( transferEnd . Payload , SecurityManager . RecordType . ECDH_TEMP ) ;
465469 return SupervisionStatus . Success ;
466470 case Security2Command . NonceGet :
@@ -534,6 +538,8 @@ internal override async Task<SupervisionStatus> Handle(ReportMessage message)
534538 bootstrapComplete . TrySetResult ( ) ;
535539 return SupervisionStatus . Success ;
536540 case Security2Command . KEXFail :
541+ if ( message . IsMulticastMethod )
542+ return SupervisionStatus . Fail ;
537543 ErrorReport errorMessage = new ErrorReport ( message . Payload . Span [ 0 ] , ( ( KexFailType ) message . Payload . Span [ 0 ] ) . ToString ( ) ) ;
538544 Log . Error ( "Key Exchange Failure " + errorMessage ) ;
539545 await FireEvent ( SecurityError , errorMessage ) ;
0 commit comments