Zamane 0.1.2
dotnet add package Zamane --version 0.1.2
NuGet\Install-Package Zamane -Version 0.1.2
<PackageReference Include="Zamane" Version="0.1.2" />
<PackageVersion Include="Zamane" Version="0.1.2" />
<PackageReference Include="Zamane" />
paket add Zamane --version 0.1.2
#r "nuget: Zamane, 0.1.2"
#:package Zamane@0.1.2
#addin nuget:?package=Zamane&version=0.1.2
#tool nuget:?package=Zamane&version=0.1.2
Zamane
A small, dependency-free client library for KamuSM's Zamane
timestamp service. ASN.1 work is done with the built-in
System.Formats.Asn1 API, so there are no external NuGet dependencies.
Install
dotnet add package Zamane
API
| Type | Responsibility |
|---|---|
IdentityGenerator |
customerNo + password + hash → DER-encoded hex identity |
TimeStampRequestParser |
TimeStampReq → messageImprint.hashedMessage |
TimeStampClient |
HTTP POST + identity header → Zamane TimeStampResp |
Quick start
using Zamane;
using var http = new HttpClient();
var client = new TimeStampClient(
TimeStampClient.TestBaseUrl, // or .ProductionBaseUrl
http);
byte[] tsr = await client.RequestTimestampAsync(
customerNo: "12345",
password: "secret",
timeStampReq: tsReqBytes);
await File.WriteAllBytesAsync("token.tsr", tsr);
tsReqBytes must be a DER-encoded RFC 3161 TimeStampReq. Build one
with BouncyCastle (or any other ASN.1 toolkit) before calling the
client.
Client options
Pass a TimeStampClientOptions to override defaults. Set
RegenerateNonce = true to have the client rewrite the nonce field of
the supplied TimeStampReq with a fresh cryptographically random value
on every request (useful when the same DER-encoded request is reused):
var client = new TimeStampClient(
TimeStampClient.TestBaseUrl,
http,
new TimeStampClientOptions { RegenerateNonce = true });
RegenerateNonce defaults to false, in which case the request is sent
verbatim.
Building an identity directly
using System.Numerics;
using Zamane;
string identity = IdentityGenerator.CreateIdentity(
customerNo: BigInteger.Parse("12345"),
password: "secret",
hashValue: hashBytes);
// Override iteration count, salt, IV:
string identity2 = IdentityGenerator.CreateIdentity(
customerNo: 42,
password: "secret",
hashValue: hashBytes,
iterations: 10_000,
salt: saltBytes, // 8 bytes
iv: ivBytes); // 16 bytes
The hex string decodes to:
SEQUENCE {
INTEGER customerNo,
OCTET STRING salt (8 bytes),
INTEGER iterations,
OCTET STRING iv (16 bytes),
OCTET STRING ciphertext
}
Reading hashedMessage from a TimeStampReq
using Zamane;
byte[] hashedMessage = TimeStampRequestParser.GetHashedMessage(tsReqBytes);
// or from a hex string:
byte[] hashedMessage2 = TimeStampRequestParser.GetHashedMessage(tsReqHex);
Using IHttpClientFactory
services.AddHttpClient<TimeStampClient>(c =>
{
c.BaseAddress = new Uri(TimeStampClient.ProductionBaseUrl);
c.Timeout = TimeSpan.FromSeconds(30);
});
TimeStampClient accepts a base URL and an optional HttpClient. In
DI scenarios, prefer passing a shared HttpClient instance.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- System.Formats.Asn1 (>= 10.0.7)
-
net9.0
- System.Formats.Asn1 (>= 10.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.