Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/harrison314/PkcsExtensions.Blazor
Add PKCS extensionsfor for Blazor WebAssembly and light WebCrypto interop.
https://github.com/harrison314/PkcsExtensions.Blazor
Last synced: 18 days ago
JSON representation
Add PKCS extensionsfor for Blazor WebAssembly and light WebCrypto interop.
- Host: GitHub
- URL: https://github.com/harrison314/PkcsExtensions.Blazor
- Owner: harrison314
- License: gpl-3.0
- Created: 2020-05-20T18:18:04.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-08-10T19:51:28.000Z (over 3 years ago)
- Last Synced: 2024-10-04T07:06:38.862Z (about 1 month ago)
- Language: C#
- Homepage:
- Size: 109 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PkcsExtensions.Blazor
[![NuGet Status](http://img.shields.io/nuget/v/PkcsExtensions.Blazor.svg?style=flat)](https://www.nuget.org/packages/PkcsExtensions.Blazor/)Add crypto and digital signature functionality for Blazor and light [WebCrypto](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) interop.
## Features
- Namespace **PkcsExtensions.Blazor**:
- `IWebCryptoProvider` - provide generate random numbers, generate RSA and ECDSA (as JsonWebKey) key pairs
- `IEcWebCryptoProvider` - provide methods `GetSharedDhmSecret` for derive bytes using _Diffie Hellman Merkle_ and `GetSharedEphemeralDhmSecret` for ECIES scheme.
- Namespace **PkcsExtensions.Blazor.Jwk** - implementation of __JsonWebKey__
- Namespace **PkcsExtensions.Blazor.Security** - extensions for [System.Security.Cryptography](https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography?view=netstandard-2.1)## Usage
Install package `dotnet add package PkcsExtensions.Blazor` to Blazor WebAssebmly project.Add to _index.html_:
```html```
or minifiy version:
```html```
And register services in _Main_ method:
```cs
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add("app");
builder.Services.AddSingleton(new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddWebCryptoProvider();WebAssemblyHost host = builder.Build();
await host.RunAsync();
}
}
```
## ExamplesSee [other examples](Examples/BlazorWebAssemblyExamples.md).
## Recommendations
- Avoid use WebCyrpto for hashing, HMAC-ing, encryption, because their implementations has differs between browsers and operating systems. Use _.Net_ implementation.
- Avoid use WebCrypto for digital signing because it does not support hash signing.
- Hint: Consider using high performance elliptic curves [Curve25519](https://en.wikipedia.org/wiki/Curve25519),
[Ed25519](https://en.wikipedia.org/wiki/EdDSA#Ed25519) or similar. Use full managed implementation e.g. [Chaos.NaCl library](https://github.com/CodesInChaos/Chaos.NaCl).## Read more
1. [PkcsExtensions](https://github.com/harrison314/PkcsExtensions)
1. [WebCrypto support in browsers](https://diafygi.github.io/webcrypto-examples/)