private void DecryptFrame(MBusFrame data) { DriverContext.Logger.LogTrace($"Check frame {data?.CiField}"); if (data != null && data.CiField == 0x5B) { var controlHigh = data.RawData.Span[18]; DriverContext.Logger.LogTrace($"Check frame if frame is supported {controlHigh}"); switch (controlHigh & 0x0F) { case 5: { if (!(OmsHelper.AesDecrypt(_aesKey, data, _logger) is VariableDataFrame variableDataFrame)) { DriverContext.Logger.LogError("Could not encrypt data frame"); return; } foreach (var child in Children) { if (child is OmsDriverAttribute att) { att.SetData(variableDataFrame); } } break; } } } }
private void DecryptFrame(MBusFrame data) { if (data != null && data.CiField == 0x5B) { var controlHigh = data.RawData.Span[OffsetUserData + 11]; var controlLow = data.RawData.Span[OffsetUserData + 10]; switch (controlHigh & 0x0F) { case 5: { int countEncBlocks = controlLow >> 4; System.Console.WriteLine( $"AES with dyn.init vector {countEncBlocks} d 16 byte blocks plus % d unencrypted data {data.RawData.Length - 12 - 16 * countEncBlocks}"); var encrypted = OmsHelper.AesDecrypt(_aesKey, data, NullLogger.Instance); break; } } } }