initial commit

This commit is contained in:
Julian
2023-07-30 12:44:37 +02:00
commit d3081f97a1
32 changed files with 472 additions and 0 deletions

3
Signing/.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"dotnet.defaultSolution": "Signing.sln"
}

77
Signing/Program.cs Normal file
View File

@@ -0,0 +1,77 @@
using System.Security.Cryptography;
using System.Text;
// ---- Hashing example
var data = "My Passwort";
HashAlgorithm sha = SHA256.Create();
byte[] result = sha.ComputeHash(Encoding.ASCII.GetBytes(data));
foreach(var byt in result)
{
Console.Write($"{byt:X}");
}
// ----
// ---- Signing
/*
Verifying a digital signature is the opposite of signing data.
Verifying a signature will tell you if the signed data has changed
or not. When a digital signature is verified, the signature is decrypted
using the public key to produce the original hash value. The data that was
signed is hashed. If the two hash values match, then the signature has been
verified. To do this, write a program.
publicKey kann verschlüssen. Nur der privat key kann aber Entschlüssen.
*/
// https://learn.microsoft.com/en-us/dotnet/standard/security/cryptographic-signatures
using SHA256 alg = SHA256.Create();
byte[] data = Encoding.ASCII.GetBytes("Hello, from the .NET Docs!");
byte[] hash = alg.ComputeHash(data);
RSAParameters sharedParameters;
byte[] signedHash;
// Generate signature
using (RSA rsa = RSA.Create())
{
sharedParameters = rsa.ExportParameters(false); //Public key
RSAPKCS1SignatureFormatter rsaFormatter = new(rsa);
rsaFormatter.SetHashAlgorithm(nameof(SHA256));
signedHash = rsaFormatter.CreateSignature(hash);
}
// Verify signature
using (RSA rsa = RSA.Create())
{
rsa.ImportParameters(sharedParameters); //Public key
RSAPKCS1SignatureDeformatter rsaDeformatter = new(rsa);
rsaDeformatter.SetHashAlgorithm(nameof(SHA256));
if (rsaDeformatter.VerifySignature(hash, signedHash))
{
Console.WriteLine("The signature is valid.");
}
else
{
Console.WriteLine("The signature is not valid.");
}
}
// ----

10
Signing/Signing.csproj Normal file
View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

25
Signing/Signing.sln Normal file
View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Signing", "Signing.csproj", "{446297B3-C8E1-4312-92C4-6697B6A060BB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{446297B3-C8E1-4312-92C4-6697B6A060BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{446297B3-C8E1-4312-92C4-6697B6A060BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{446297B3-C8E1-4312-92C4-6697B6A060BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{446297B3-C8E1-4312-92C4-6697B6A060BB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7A747AF1-E00D-44CB-A976-FD91E4DD036E}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v7.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v7.0": {
"Signing/1.0.0": {
"runtime": {
"Signing.dll": {}
}
}
}
},
"libraries": {
"Signing/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "net7.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "7.0.0"
}
}
}

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")]

View File

@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Signing")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Signing")]
[assembly: System.Reflection.AssemblyTitleAttribute("Signing")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Von der MSBuild WriteCodeFragment-Klasse generiert.

View File

@@ -0,0 +1 @@
f0fb5878b2be5a9ef8f505c5564faa37e8efe06f

View File

@@ -0,0 +1,11 @@
is_global = true
build_property.TargetFramework = net7.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Signing
build_property.ProjectDir = C:\Users\gulum\Desktop\Projekte\UnderstandCrypt\Signing\

View File

@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;

Binary file not shown.

View File

@@ -0,0 +1 @@
4811e0b889ffc1f96fb9ae2e9e51b979c88a2219

View File

@@ -0,0 +1,15 @@
C:\Users\gulum\Desktop\Projekte\UnderstandCrypt\Signing\obj\Debug\net7.0\Signing.csproj.AssemblyReference.cache
C:\Users\gulum\Desktop\Projekte\UnderstandCrypt\Signing\obj\Debug\net7.0\Signing.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\gulum\Desktop\Projekte\UnderstandCrypt\Signing\obj\Debug\net7.0\Signing.AssemblyInfoInputs.cache
C:\Users\gulum\Desktop\Projekte\UnderstandCrypt\Signing\obj\Debug\net7.0\Signing.AssemblyInfo.cs
C:\Users\gulum\Desktop\Projekte\UnderstandCrypt\Signing\obj\Debug\net7.0\Signing.csproj.CoreCompileInputs.cache
C:\Users\gulum\Desktop\Projekte\UnderstandCrypt\Signing\bin\Debug\net7.0\Signing.exe
C:\Users\gulum\Desktop\Projekte\UnderstandCrypt\Signing\bin\Debug\net7.0\Signing.deps.json
C:\Users\gulum\Desktop\Projekte\UnderstandCrypt\Signing\bin\Debug\net7.0\Signing.runtimeconfig.json
C:\Users\gulum\Desktop\Projekte\UnderstandCrypt\Signing\bin\Debug\net7.0\Signing.dll
C:\Users\gulum\Desktop\Projekte\UnderstandCrypt\Signing\bin\Debug\net7.0\Signing.pdb
C:\Users\gulum\Desktop\Projekte\UnderstandCrypt\Signing\obj\Debug\net7.0\Signing.dll
C:\Users\gulum\Desktop\Projekte\UnderstandCrypt\Signing\obj\Debug\net7.0\refint\Signing.dll
C:\Users\gulum\Desktop\Projekte\UnderstandCrypt\Signing\obj\Debug\net7.0\Signing.pdb
C:\Users\gulum\Desktop\Projekte\UnderstandCrypt\Signing\obj\Debug\net7.0\Signing.genruntimeconfig.cache
C:\Users\gulum\Desktop\Projekte\UnderstandCrypt\Signing\obj\Debug\net7.0\ref\Signing.dll

Binary file not shown.

View File

@@ -0,0 +1 @@
fa3a6ed23a63461b2e50fecadac4703bd1b86022

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,63 @@
{
"format": 1,
"restore": {
"C:\\Users\\gulum\\Desktop\\Projekte\\UnderstandCrypt\\Signing\\Signing.csproj": {}
},
"projects": {
"C:\\Users\\gulum\\Desktop\\Projekte\\UnderstandCrypt\\Signing\\Signing.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\gulum\\Desktop\\Projekte\\UnderstandCrypt\\Signing\\Signing.csproj",
"projectName": "Signing",
"projectPath": "C:\\Users\\gulum\\Desktop\\Projekte\\UnderstandCrypt\\Signing\\Signing.csproj",
"packagesPath": "C:\\Users\\gulum\\.nuget\\packages\\",
"outputPath": "C:\\Users\\gulum\\Desktop\\Projekte\\UnderstandCrypt\\Signing\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\gulum\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net7.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.306\\RuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\gulum\.nuget\packages\</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.6.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\gulum\.nuget\packages\" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

View File

@@ -0,0 +1,68 @@
{
"version": 3,
"targets": {
"net7.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net7.0": []
},
"packageFolders": {
"C:\\Users\\gulum\\.nuget\\packages\\": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "c:\\Users\\gulum\\Desktop\\Projekte\\UnderstandCrypt\\Signing\\Signing.csproj",
"projectName": "Signing",
"projectPath": "c:\\Users\\gulum\\Desktop\\Projekte\\UnderstandCrypt\\Signing\\Signing.csproj",
"packagesPath": "C:\\Users\\gulum\\.nuget\\packages\\",
"outputPath": "c:\\Users\\gulum\\Desktop\\Projekte\\UnderstandCrypt\\Signing\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\gulum\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net7.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.306\\RuntimeIdentifierGraph.json"
}
}
}
}

View File

@@ -0,0 +1,8 @@
{
"version": 2,
"dgSpecHash": "0HnsmpJWjQm/KkFj3EB4I8oxrhtnBEtXjENYDe1zF4lzd1MUzno+Bh8knuXt2svJr3lF4kZ2TE13dHVe1487yw==",
"success": true,
"projectFilePath": "C:\\Users\\gulum\\Desktop\\Projekte\\UnderstandCrypt\\Signing\\Signing.csproj",
"expectedPackageFiles": [],
"logs": []
}