Skip to content

Commit

Permalink
Update (#34)
Browse files Browse the repository at this point in the history
- Fixed method name `BouncyCastle.RegisterNetalgrithms` -> `RegisterNetAlgorithms`
  • Loading branch information
nd1012 authored Apr 13, 2024
1 parent a54b000 commit 3a97b3f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/wan24-Crypto-BC/BouncyCastle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static void ReplaceNetAlgorithms()
/// <summary>
/// Register (HMAC)SHA3-* algorithms to <see cref="CryptoAppConfig"/> (replace the .NET defaults!)
/// </summary>
public static void RegisterNetAlgrithms()
public static void RegisterNetAlgorithms()
{
HashBcSha3_256Algorithm.SHA3_256.Register();
HashBcSha3_384Algorithm.SHA3_384.Register();
Expand Down
24 changes: 24 additions & 0 deletions src/wan24-Crypto-BC/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,30 @@ and use the default output length of the `wan24-Crypto` implementations
instead. The `NetShake128/256HashAlgorithmAdapter` can't be replaced for this
reason.

In order to override the .NET default SHA3 hash and HMAC algorithms, you can
call:

```cs
BouncyCastle.RegisterNetAlgorithms();
```

This will use Bouncy Castle SHA3 implementations for the .NET implemented SHA3
hash algorithms:

| Name | Type |
| ---- | ---- |
| SHA3-256 | `HashBcSha3_256.SHA3_256` |
| SHA3-384 | `HashBcSha3_384.SHA3_384` |
| SHA3-512 | `HashBcSha3_512.SHA3_512` |
| HMACSHA3-256 | `MacBcHmacSha3_256.HMACSHA3_256` |
| HMACSHA3-384 | `MacBcHmacSha3_384.HMACSHA3_384` |
| HMACSHA3-512 | `MacBcHmacSha3_512.HMACSHA3_512` |

This step is required, if you want to ensure that whenever a .NET crypto type
or any 3rd party crypto type requests a SHA3 hash or HMAC instance using the
static `HashAlgorithm.Create("NAME")` or `KeyedHashAlgorithm.Create("NAME")`
methods.

### Use as default algorithms

To set Bouncy Castle defaults as `wan24-Crypto` defaults:
Expand Down
2 changes: 1 addition & 1 deletion src/wan24-Crypto-BC/wan24-Crypto-BC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<PackageId>wan24-Crypto-BC</PackageId>
<Title>wan24-Crypto-BC</Title>
<Version>3.5.0</Version>
<Version>3.5.1</Version>
<Authors>nd1012</Authors>
<Company>Andreas Zimmermann, wan24.de</Company>
<Product>wan24-Crypto-BC</Product>
Expand Down

0 comments on commit 3a97b3f

Please sign in to comment.