Commit 9ac5f70d authored by Maxence MOHR's avatar Maxence MOHR 😄
Browse files

Deleted old files, updated gitignore accordingly

parent 087ac446
.vs
PKCS11Test/bin
PKCS11Test/obj
PKCS11Explorer/bin
PKCS11Explorer/obj

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29209.62
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PKCS11Test", "PKCS11Test\PKCS11Test.csproj", "{F986591E-1874-4D6D-909F-39912117096E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F986591E-1874-4D6D-909F-39912117096E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F986591E-1874-4D6D-909F-39912117096E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F986591E-1874-4D6D-909F-39912117096E}.Debug|x64.ActiveCfg = Debug|x64
{F986591E-1874-4D6D-909F-39912117096E}.Debug|x64.Build.0 = Debug|x64
{F986591E-1874-4D6D-909F-39912117096E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F986591E-1874-4D6D-909F-39912117096E}.Release|Any CPU.Build.0 = Release|Any CPU
{F986591E-1874-4D6D-909F-39912117096E}.Release|x64.ActiveCfg = Release|x64
{F986591E-1874-4D6D-909F-39912117096E}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5962405E-4289-4C72-A00C-43DA5A433CA8}
EndGlobalSection
EndGlobal
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="PKCS11Test.App">
<Application.Styles>
<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml"/>
</Application.Styles>
</Application>
using Avalonia;
using Avalonia.Markup.Xaml;
namespace PKCS11Test
{
public class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
}
}
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="200" d:DesignHeight="150"
x:Class="PKCS11Test.MainWindow"
Title="PKCS11Test">
<StackPanel
Orientation="Vertical"
VerticalAlignment="Center"
HorizontalAlignment="Center">
<Button
Click="ButtonHandler_LoadFile">
Load a file
</Button>
<TextBlock
Name="Label"
HorizontalAlignment="Center">
Hello
</TextBlock>
</StackPanel>
</Window>
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using System;
using System.Collections.Generic;
using Net.Pkcs11Interop.Common;
using Net.Pkcs11Interop.HighLevelAPI;
using System.Threading.Tasks;
namespace PKCS11Test
{
public class MainWindow : Window
{
TextBlock Label;
public MainWindow()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
Label = this.FindControl<TextBlock>("Label");
}
private async void ButtonHandler_LoadFile(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.AllowMultiple = false;
List<String> allowedExtensions = new List<String>();
allowedExtensions.Add("so");
allowedExtensions.Add("dll");
allowedExtensions.Add("dylib");
FileDialogFilter filter = new FileDialogFilter();
filter.Extensions = allowedExtensions;
filter.Name = "PKCS11 Middleware";
List<FileDialogFilter> filters = new List<FileDialogFilter>();
filters.Add(filter);
openFileDialog.Filters = new List<FileDialogFilter>(filters);
string[] fileSelected = await openFileDialog.ShowAsync(this);
if (fileSelected.Length == 0)
Console.WriteLine("Canceled file selection");
else
{
Console.WriteLine("Selected file: " + fileSelected[0]);
TestPKCS11(fileSelected[0]);
}
}
private async void TestPKCS11(string libraryFilePath)
{
// Specify the path to unmanaged PKCS#11 library provided by the cryptographic device vendor
string pkcs11LibraryPath = libraryFilePath;
// Create factories used by Pkcs11Interop library
Pkcs11InteropFactories factories = new Pkcs11InteropFactories();
try
{
// Load unmanaged PKCS#11 library
using (IPkcs11Library pkcs11Library = factories.Pkcs11LibraryFactory.LoadPkcs11Library(factories, pkcs11LibraryPath, AppType.SingleThreaded))
{
// Show general information about loaded library
ILibraryInfo libraryInfo = pkcs11Library.GetInfo();
Console.WriteLine("Library");
Console.WriteLine(" Manufacturer: " + libraryInfo.ManufacturerId);
Console.WriteLine(" Description: " + libraryInfo.LibraryDescription);
Console.WriteLine(" Version: " + libraryInfo.LibraryVersion);
// Get list of all available slots
foreach (ISlot slot in pkcs11Library.GetSlotList(SlotsType.WithOrWithoutTokenPresent))
{
// Show basic information about slot
ISlotInfo slotInfo = slot.GetSlotInfo();
Console.WriteLine();
Console.WriteLine("Slot");
Console.WriteLine(" Manufacturer: " + slotInfo.ManufacturerId);
Console.WriteLine(" Description: " + slotInfo.SlotDescription);
Console.WriteLine(" Token present: " + slotInfo.SlotFlags.TokenPresent);
if (slotInfo.SlotFlags.TokenPresent)
{
// Show basic information about token present in the slot
ITokenInfo tokenInfo = slot.GetTokenInfo();
Console.WriteLine("Token");
Console.WriteLine(" Manufacturer: " + tokenInfo.ManufacturerId);
Console.WriteLine(" Model: " + tokenInfo.Model);
Console.WriteLine(" Serial number: " + tokenInfo.SerialNumber);
Console.WriteLine(" Label: " + tokenInfo.Label);
// Show list of mechanisms (algorithms) supported by the token
Console.WriteLine("Supported mechanisms: ");
foreach (CKM mechanism in slot.GetMechanismList())
Console.WriteLine(" " + mechanism);
}
}
}
}
catch(Net.Pkcs11Interop.Common.UnmanagedException exception)
{
Label.Text = exception.Message;
Console.WriteLine("Not a PKCS11 middleware: " + exception.Message);
}
catch(Net.Pkcs11Interop.Common.Pkcs11Exception exception)
{
Label.Text = exception.Message;
Console.WriteLine("Not a PKCS11 middleware: " + exception.Message);
}
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>
<Compile Update="**\*.xaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
<AvaloniaResource Include="**\*.xaml">
<SubType>Designer</SubType>
</AvaloniaResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.8.0" />
<PackageReference Include="Avalonia.Desktop" Version="0.8.0" />
<PackageReference Include="Pkcs11Interop" Version="5.0.0" />
<PackageReference Include="Pkcs11Interop.X509Store" Version="0.2.0" />
</ItemGroup>
</Project>
using System;
using Avalonia;
using Avalonia.Logging.Serilog;
namespace PKCS11Test
{
class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
public static void Main(string[] args) => BuildAvaloniaApp().Start(AppMain, args);
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToDebug();
// Your application's entry point. Here you can initialize your MVVM framework, DI
// container, etc.
private static void AppMain(Application app, string[] args)
{
app.Run(new MainWindow());
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<!--
To use the Avalonia CI feed to get unstable packages, move this file to the root of your solution.
-->
<configuration>
<packageSources>
<add key="AvaloniaCI" value="https://www.myget.org/F/avalonia-ci/api/v2" />
</packageSources>
</configuration>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment