Bitwarden.Server.Sdk.CryptoPrimitives
0.1.0
Prefix Reserved
See the version list below for details.
dotnet add package Bitwarden.Server.Sdk.CryptoPrimitives --version 0.1.0
NuGet\Install-Package Bitwarden.Server.Sdk.CryptoPrimitives -Version 0.1.0
<PackageReference Include="Bitwarden.Server.Sdk.CryptoPrimitives" Version="0.1.0" />
<PackageVersion Include="Bitwarden.Server.Sdk.CryptoPrimitives" Version="0.1.0" />
<PackageReference Include="Bitwarden.Server.Sdk.CryptoPrimitives" />
paket add Bitwarden.Server.Sdk.CryptoPrimitives --version 0.1.0
#r "nuget: Bitwarden.Server.Sdk.CryptoPrimitives, 0.1.0"
#:package Bitwarden.Server.Sdk.CryptoPrimitives@0.1.0
#addin nuget:?package=Bitwarden.Server.Sdk.CryptoPrimitives&version=0.1.0
#tool nuget:?package=Bitwarden.Server.Sdk.CryptoPrimitives&version=0.1.0
Bitwarden.Server.Sdk.CryptoPrimitives
About
Cryptographic primitives built only on System.Security.Cryptography.
Installing
dotnet add package Bitwarden.Server.Sdk.CryptoPrimitives
Usage
Derive a cache key
Derive a 32-byte cache key from a secret and a list of strings:
var secret = CacheSecret.FromString(configuration["Caching:Secret"]!); // base64, 32 bytes
var key = CacheKey.DeriveCacheKey(secret, "account-by-email", email);
var redisKey = key.ToString(); // base64
The key is HMAC-SHA-256(secret, LP(p0) || ... || LP(pn)), where
LP(x) = uint64_be(len(utf8(x))) || utf8(x). The length prefixes keep ("ab", "c") and ("a", "bc")
apart.
CacheSecret.Development is 32 zero bytes, the same as default. Use it only in development:
anyone can derive the same keys from it.
Gotchas and constraints
- A parameter that is not valid UTF-16, such as a lone surrogate, throws
EncoderFallbackExceptionrather than being replaced and colliding with another string. ToString()returns base64, andFromStringreads it back, for both types.ToString()of aCacheSecretwrites the secret itself: keep it out of logs.
Types
| Type | Purpose |
|---|---|
CacheSecret |
The 32-byte secret cache keys are derived from |
CacheKey |
A 32-byte cache key derived from a secret |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Bitwarden.Server.Sdk.CryptoPrimitives:
| Package | Downloads |
|---|---|
|
Bitwarden.Server.Sdk.Resources.Caching.Abstractions
How a Bitwarden service-owned cache entry is stored and keyed, shared by its owner and its readers. |
|
|
Bitwarden.Server.Sdk.Idempotency.Abstractions
Idempotency keys, and the operations whose writes repeat the same keys, shared by Bitwarden services and their callers. |
GitHub repositories
This package is not used by any popular GitHub repositories.