Skip to content

Commit

Permalink
Add Schannel protocol & settings configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Rans4ckeR committed Feb 25, 2024
1 parent 49ca16e commit ab77a64
Show file tree
Hide file tree
Showing 64 changed files with 1,453 additions and 1,607 deletions.
1,558 changes: 369 additions & 1,189 deletions .editorconfig

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<FileVersion>0.0.0.1</FileVersion>
<InformationalVersion>0.0.0.1</InformationalVersion>
<Platforms>AnyCPU</Platforms>
<EnableSourceControlManagerQueries Condition="$(Configuration) == 'Debug'">true</EnableSourceControlManagerQueries> <!--https://github.com/dotnet/sdk/issues/36666-->
</PropertyGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
Expand Down
2 changes: 1 addition & 1 deletion CipherPunk.CipherSuiteInfoApi/Entities/CipherSuite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public readonly record struct CipherSuite(
[property: JsonPropertyName("enc_algorithm")] string EncryptionAlgorithm,
[property: JsonPropertyName("hash_algorithm")] string HashAlgorithm,
[property: JsonPropertyName("security")] CipherSuiteSecurity Security,
[property: JsonPropertyName("tls_version")] CipherSuiteTlsVersion[] TlsVersions);
[property: JsonPropertyName("tls_version")] ICollection<CipherSuiteTlsVersion> TlsVersions);
13 changes: 13 additions & 0 deletions CipherPunk.UI/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@
<Setter Property="AlternatingRowBackground" Value="{StaticResource NavigationBackgroundSolidColorBrush}"/>
<Setter Property="RowBackground" Value="{StaticResource TitleBackgroundSolidColorBrush}"/>
</Style>
<Style TargetType="{x:Type ListBox}">
<Setter Property="Foreground" Value="{StaticResource TextSolidColorBrush}"/>
<Setter Property="Background" Value="{StaticResource TitleBackgroundSolidColorBrush}"/>
</Style>
<Style TargetType="{x:Type CheckBox}">
<Setter Property="Foreground" Value="{StaticResource TextSolidColorBrush}"/>
</Style>
<Style TargetType="{x:Type ui:NoScrollDataGrid}" BasedOn="{StaticResource {x:Type DataGrid}}">
<Setter Property="IsReadOnly" Value="True"/>
</Style>
Expand Down Expand Up @@ -97,6 +104,9 @@
<DataTemplate DataType="{x:Type ui:LoggingViewModel}">
<ui:LoggingView/>
</DataTemplate>
<DataTemplate DataType="{x:Type ui:DefaultProtocolsViewModel}">
<ui:DefaultProtocolsView/>
</DataTemplate>
<DataTemplate DataType="{x:Type ui:DefaultCipherSuitesViewModel}">
<ui:DefaultCipherSuitesView/>
</DataTemplate>
Expand All @@ -109,5 +119,8 @@
<DataTemplate DataType="{x:Type ui:SchannelSettingsViewModel}">
<ui:SchannelSettingsView/>
</DataTemplate>
<DataTemplate DataType="{x:Type ui:SchannelProtocolSettingsViewModel}">
<ui:SchannelProtocolSettingsView/>
</DataTemplate>
</Application.Resources>
</Application>
12 changes: 8 additions & 4 deletions CipherPunk.UI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,22 @@ public App()
.AddSingleton<EllipticCurvesGroupPolicySettingsViewModel>()
.AddSingleton<RemoteServerTestViewModel>()
.AddSingleton<LoggingViewModel>()
.AddSingleton<DefaultProtocolsViewModel>()
.AddSingleton<DefaultCipherSuitesViewModel>()
.AddSingleton<DefaultEllipticCurvesViewModel>()
.AddSingleton<ElevationViewModel>()
.AddSingleton<SchannelSettingsViewModel>()
.AddSingleton<SchannelProtocolSettingsViewModel>()
.AddCipherPunk()
.AddCipherSuiteInfoApi();
}).Build();
}

protected override async void OnStartup(StartupEventArgs e)
protected override void OnStartup(StartupEventArgs e)
{
await host.StartAsync();
Mouse.OverrideCursor = Cursors.AppStarting;

host.Start();

SetUiCulture();

Expand All @@ -61,13 +65,13 @@ protected override async void OnStartup(StartupEventArgs e)
Mouse.OverrideCursor = null;
}

protected override async void OnExit(ExitEventArgs e)
protected override void OnExit(ExitEventArgs e)
{
Mouse.OverrideCursor = Cursors.Wait;

using (host)
{
await host.StopAsync();
host.StopAsync().GetAwaiter().GetResult();
}

base.OnExit(e);
Expand Down
3 changes: 1 addition & 2 deletions CipherPunk.UI/CipherPunk.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<Platforms>x86;x64;ARM64</Platforms>
<ApplicationManifest>app.manifest</ApplicationManifest>
<EnableSourceControlManagerQueries Condition="$(Configuration) == 'Debug'">true</EnableSourceControlManagerQueries> <!--https://github.com/dotnet/sdk/issues/36666-->
<ApplicationIcon>..\CipherPunk.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
Expand All @@ -40,7 +39,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.SDK.Win32Metadata" Version="58.0.18-preview">
<PackageReference Include="Microsoft.Windows.SDK.Win32Metadata" Version="59.0.13-preview">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
18 changes: 18 additions & 0 deletions CipherPunk.UI/Entities/UiMemberStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace CipherPunk.UI;

using CommunityToolkit.Mvvm.ComponentModel;

internal sealed class UiMemberStatus<T>(T member, bool enabled) : ObservableObject
{
public T Member
{
get => member;
set => SetProperty(ref member, value);
}

public bool Enabled
{
get => enabled;
set => SetProperty(ref enabled, value);
}
}
35 changes: 35 additions & 0 deletions CipherPunk.UI/Entities/UiSchannelProtocolSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace CipherPunk.UI;

using CommunityToolkit.Mvvm.ComponentModel;

internal sealed class UiSchannelProtocolSettings : ObservableObject
{
private SchannelProtocol protocol;
private SchannelProtocolStatus clientStatus;
private SchannelProtocolStatus serverStatus;

public UiSchannelProtocolSettings(SchannelProtocolSettings schannelProtocolSettings)
{
Protocol = schannelProtocolSettings.Protocol;
ClientStatus = schannelProtocolSettings.ClientStatus;
ServerStatus = schannelProtocolSettings.ServerStatus;
}

public SchannelProtocol Protocol
{
get => protocol;
set => SetProperty(ref protocol, value);
}

public SchannelProtocolStatus ClientStatus
{
get => clientStatus;
set => SetProperty(ref clientStatus, value);
}

public SchannelProtocolStatus ServerStatus
{
get => serverStatus;
set => SetProperty(ref serverStatus, value);
}
}
107 changes: 107 additions & 0 deletions CipherPunk.UI/Entities/UiSchannelSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
namespace CipherPunk.UI;

using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;

internal sealed class UiSchannelSettings : ObservableObject
{
private ObservableCollection<UiMemberStatus<SchannelEventLogging>>? eventLogging;
private ObservableCollection<UiMemberStatus<SchannelCertificateMappingMethod>>? certificateMappingMethod;
private int? clientCacheTime;
private bool? enableOcspStaplingForSni;
private int? issuerCacheSize;
private int? issuerCacheTime;
private bool? sendTrustedIssuerList;
private int? serverCacheTime;
private int? messageLimitClient;
private int? messageLimitServer;
private int? messageLimitServerClientAuth;

public UiSchannelSettings(SchannelSettings schannelSettings)
{
EventLogging = new(Enum.GetValues<SchannelEventLogging>().Select(q => new UiMemberStatus<SchannelEventLogging>(q, schannelSettings.EventLogging!.Value.HasFlag(q))));
CertificateMappingMethods = new(Enum.GetValues<SchannelCertificateMappingMethod>().Select(q => new UiMemberStatus<SchannelCertificateMappingMethod>(q, schannelSettings.CertificateMappingMethods!.Value.HasFlag(q))));
ClientCacheTime = schannelSettings.ClientCacheTime;
EnableOcspStaplingForSni = schannelSettings.EnableOcspStaplingForSni;
IssuerCacheSize = schannelSettings.IssuerCacheSize;
IssuerCacheTime = schannelSettings.IssuerCacheTime;
MaximumCacheSize = schannelSettings.MaximumCacheSize;
SendTrustedIssuerList = schannelSettings.SendTrustedIssuerList;
ServerCacheTime = schannelSettings.ServerCacheTime;
MessageLimitClient = schannelSettings.MessageLimitClient;
MessageLimitServer = schannelSettings.MessageLimitServer;
MessageLimitServerClientAuth = schannelSettings.MessageLimitServerClientAuth;
}

public ObservableCollection<UiMemberStatus<SchannelEventLogging>>? EventLogging
{
get => eventLogging;
set => SetProperty(ref eventLogging, value);
}

public ObservableCollection<UiMemberStatus<SchannelCertificateMappingMethod>>? CertificateMappingMethods
{
get => certificateMappingMethod;
set => SetProperty(ref certificateMappingMethod, value);
}

public int? ClientCacheTime
{
get => clientCacheTime;
set => SetProperty(ref clientCacheTime, value);
}

public bool? EnableOcspStaplingForSni
{
get => enableOcspStaplingForSni;
set => SetProperty(ref enableOcspStaplingForSni, value);
}

public int? IssuerCacheSize
{
get => issuerCacheSize;
set => SetProperty(ref issuerCacheSize, value);
}

public int? IssuerCacheTime
{
get => issuerCacheTime;
set => SetProperty(ref issuerCacheTime, value);
}

public int? MaximumCacheSize
{
get => clientCacheTime;
set => SetProperty(ref clientCacheTime, value);
}

public bool? SendTrustedIssuerList
{
get => sendTrustedIssuerList;
set => SetProperty(ref sendTrustedIssuerList, value);
}

public int? ServerCacheTime
{
get => serverCacheTime;
set => SetProperty(ref serverCacheTime, value);
}

public int? MessageLimitClient
{
get => messageLimitClient;
set => SetProperty(ref messageLimitClient, value);
}

public int? MessageLimitServer
{
get => messageLimitServer;
set => SetProperty(ref messageLimitServer, value);
}

public int? MessageLimitServerClientAuth
{
get => messageLimitServerClientAuth;
set => SetProperty(ref messageLimitServerClientAuth, value);
}
}
2 changes: 1 addition & 1 deletion CipherPunk.UI/Infrastructure/ExceptionMessageBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

using System.Text;

public static class ExceptionMessageBuilder
internal static class ExceptionMessageBuilder
{
public static string GetDetailedExceptionInfo(this Exception ex) => new StringBuilder().GetExceptionInfo(ex).ToString();

Expand Down
2 changes: 1 addition & 1 deletion CipherPunk.UI/Infrastructure/LoggerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace CipherPunk.UI;

public static class LoggerExtensions
internal static class LoggerExtensions
{
private static readonly Action<ILogger, string, Exception?> ExceptionDetails = LoggerMessage.Define<string>(LogLevel.Error, new(1, nameof(ExceptionThrown)), "{Exception}");

Expand Down
27 changes: 15 additions & 12 deletions CipherPunk.UI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,48 +37,51 @@
</Ribbon.ContextMenu>
<RibbonTab Header="Overview">
<RibbonGroup>
<RibbonButton Label="Overview" LargeImageSource="{Binding CipherSuitesButtonImage}" Command="{Binding OverviewViewModel.DefaultCommand}"/>
<RibbonButton Label="Overview" Command="{Binding OverviewViewModel.DefaultCommand}"/>
</RibbonGroup>
</RibbonTab>
<RibbonTab Header="Cipher Suites">
<RibbonGroup>
<RibbonButton Label="Active Cipher Suites" LargeImageSource="{Binding CipherSuitesButtonImage}" Command="{Binding CipherSuitesViewModel.DefaultCommand}"/>
<RibbonButton Label="Active Cipher Suites" Command="{Binding CipherSuitesViewModel.DefaultCommand}"/>
</RibbonGroup>
<RibbonGroup>
<RibbonButton Label="OS Settings" LargeImageSource="{Binding CipherSuitesButtonImage}" Command="{Binding CipherSuitesOsSettingsViewModel.DefaultCommand}"/>
<RibbonButton Label="OS Settings" Command="{Binding CipherSuitesOsSettingsViewModel.DefaultCommand}"/>
</RibbonGroup>
<RibbonGroup>
<RibbonButton Label="Group Policy Settings" LargeImageSource="{Binding CipherSuitesButtonImage}" Command="{Binding CipherSuitesGroupPolicySettingsViewModel.DefaultCommand}"/>
<RibbonButton Label="Group Policy Settings" Command="{Binding CipherSuitesGroupPolicySettingsViewModel.DefaultCommand}"/>
</RibbonGroup>
</RibbonTab>
<RibbonTab Header="Elliptic Curves">
<RibbonGroup>
<RibbonButton Label="Active Elliptic Curves" LargeImageSource="{Binding EllipticCurvesButtonImage}" Command="{Binding EllipticCurvesViewModel.DefaultCommand}"/>
<RibbonButton Label="Active Elliptic Curves" Command="{Binding EllipticCurvesViewModel.DefaultCommand}"/>
</RibbonGroup>
<RibbonGroup>
<RibbonButton Label="OS Settings" LargeImageSource="{Binding EllipticCurvesButtonImage}" Command="{Binding EllipticCurvesOsSettingsViewModel.DefaultCommand}"/>
<RibbonButton Label="OS Settings" Command="{Binding EllipticCurvesOsSettingsViewModel.DefaultCommand}"/>
</RibbonGroup>
<RibbonGroup>
<RibbonButton Label="Group Policy Settings" LargeImageSource="{Binding EllipticCurvesButtonImage}" Command="{Binding EllipticCurvesGroupPolicySettingsViewModel.DefaultCommand}"/>
<RibbonButton Label="Group Policy Settings" Command="{Binding EllipticCurvesGroupPolicySettingsViewModel.DefaultCommand}"/>
</RibbonGroup>
</RibbonTab>
<RibbonTab Header="Remote Server Probe">
<RibbonGroup>
<RibbonButton Label="Remote Server Probe" LargeImageSource="{Binding CipherSuitesButtonImage}" Command="{Binding RemoteServerTestViewModel.DefaultCommand}"/>
<RibbonButton Label="Remote Server Probe" Command="{Binding RemoteServerTestViewModel.DefaultCommand}"/>
</RibbonGroup>
</RibbonTab>
<RibbonTab Header="Information">
<RibbonGroup>
<RibbonButton Label="Schannel logging" LargeImageSource="{Binding CipherSuitesButtonImage}" Command="{Binding LoggingViewModel.DefaultCommand}"/>
<RibbonButton Label="Schannel logging" Command="{Binding LoggingViewModel.DefaultCommand}"/>
</RibbonGroup>
<RibbonGroup>
<RibbonButton Label="Windows Default Cipher Suites" LargeImageSource="{Binding CipherSuitesButtonImage}" Command="{Binding DefaultCipherSuitesViewModel.DefaultCommand}"/>
<RibbonButton Label="Windows Default Protocols" Command="{Binding DefaultProtocolsViewModel.DefaultCommand}"/>
</RibbonGroup>
<RibbonGroup>
<RibbonButton Label="Windows Default Elliptic Curves" LargeImageSource="{Binding EllipticCurvesButtonImage}" Command="{Binding DefaultEllipticCurvesViewModel.DefaultCommand}"/>
<RibbonButton Label="Windows Default Cipher Suites" Command="{Binding DefaultCipherSuitesViewModel.DefaultCommand}"/>
</RibbonGroup>
<RibbonGroup>
<RibbonButton Label="UAC Elevation" LargeImageSource="{Binding CipherSuitesButtonImage}" Command="{Binding ElevationViewModel.DefaultCommand}"/>
<RibbonButton Label="Windows Default Elliptic Curves" Command="{Binding DefaultEllipticCurvesViewModel.DefaultCommand}"/>
</RibbonGroup>
<RibbonGroup>
<RibbonButton Label="UAC Elevation" Command="{Binding ElevationViewModel.DefaultCommand}"/>
</RibbonGroup>
</RibbonTab>
</Ribbon>
Expand Down
4 changes: 4 additions & 0 deletions CipherPunk.UI/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public MainWindowViewModel(
EllipticCurvesGroupPolicySettingsViewModel ellipticCurvesGroupPolicySettingsViewModel,
RemoteServerTestViewModel remoteServerTestViewModel,
LoggingViewModel loggingViewModel,
DefaultProtocolsViewModel defaultProtocolsViewModel,
DefaultCipherSuitesViewModel defaultCipherSuitesViewModel,
DefaultEllipticCurvesViewModel defaultEllipticCurvesViewModel,
ElevationViewModel elevationViewModel)
Expand All @@ -47,6 +48,7 @@ public MainWindowViewModel(
EllipticCurvesGroupPolicySettingsViewModel = ellipticCurvesGroupPolicySettingsViewModel;
RemoteServerTestViewModel = remoteServerTestViewModel;
LoggingViewModel = loggingViewModel;
DefaultProtocolsViewModel = defaultProtocolsViewModel;
DefaultCipherSuitesViewModel = defaultCipherSuitesViewModel;
DefaultEllipticCurvesViewModel = defaultEllipticCurvesViewModel;
ElevationViewModel = elevationViewModel;
Expand Down Expand Up @@ -82,6 +84,8 @@ public MainWindowViewModel(

public LoggingViewModel LoggingViewModel { get; }

public DefaultProtocolsViewModel DefaultProtocolsViewModel { get; }

public DefaultCipherSuitesViewModel DefaultCipherSuitesViewModel { get; }

public DefaultEllipticCurvesViewModel DefaultEllipticCurvesViewModel { get; }
Expand Down
Loading

0 comments on commit ab77a64

Please sign in to comment.