private bool ConfigureSecurityState() { Random r = new Random(); EmberInitialSecurityBitmask bitmask = (EmberInitialSecurityBitmask.EMBER_STANDARD_SECURITY_MODE | EmberInitialSecurityBitmask.EMBER_HAVE_PRECONFIGURED_KEY | EmberInitialSecurityBitmask.EMBER_GLOBAL_LINK_KEY | EmberInitialSecurityBitmask.EMBER_REQUIRE_ENCRYPTED_KEY | EmberInitialSecurityBitmask.EMBER_HAVE_NETWORK_KEY); EmberKeyData preconfigKey = new Centralite.Ember.DataTypes.EmberKeyData(new byte[] { 0x5A, 0x69, 0x67, 0x42, 0x65, 0x65, 0x41, 0x6C, 0x6C, 0x69, 0x61, 0x6E, 0x63, 0x65, 0x30, 0x39 }); byte[] key = new byte[16]; r.NextBytes(key); EmberKeyData networkKey = new EmberKeyData(key); var res = Ezsp.SetInitialSecurityState(new EmberInitialSecurityState(bitmask, preconfigKey, networkKey, 0)) ?? new EmberStatusResponse(EmberStatus.EMBER_ERR_FATAL); if (res?.Status != EmberStatus.EMBER_SUCCESS) { errorProducerService.AddMessage(new ErrorMessage("Unable to configure security state of USB stick", ErrorType.Exception)); } return(res?.Status == EmberStatus.EMBER_SUCCESS); }
/// <summary> /// The bitmask to remove to the set as <see cref="EmberInitialSecurityBitmask"/> </summary> public void RemoveBitmask(EmberInitialSecurityBitmask bitmask) { _bitmask.Remove(bitmask); }
/// <summary> /// The bitmask to add to the set as <see cref="EmberInitialSecurityBitmask"/> </summary> public void AddBitmask(EmberInitialSecurityBitmask bitmask) { _bitmask.Add(bitmask); }