Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>PostQuantum.Hybrid SnippetsNew to Visual Studio Code? Get it now.
PostQuantum.Hybrid Snippets

PostQuantum.Hybrid Snippets

systemslibrarian

|
1 install
| (0) | Free
Analyzer-clean C# snippets for PostQuantum.Hybrid (Envelopes, AspNetCore) and the PostQuantum.FileEncryption family (fail-closed file encryption, key files, signing, DI).
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

PostQuantum.Hybrid — VS Code Snippets

Visual Studio Marketplace Installs

C# snippets for the PostQuantum.Hybrid library — hybrid post-quantum cryptography (X25519 + ML-KEM-768 for KEM, Ed25519 + ML-DSA-65 for signatures) on .NET 8 and .NET 10 — and for the PostQuantum.FileEncryption family (fail-closed file/stream encryption, passphrase-protected key files, detached signing, DI, KMS envelopes).

Every snippet follows the secure patterns the libraries' Roslyn analyzers enforce — PQH001 – PQH005 (PostQuantum.Hybrid.Analyzers) and PQFE101 – PQFE104 (PostQuantum.FileEncryption.Analyzers) — so the generated code is analyzer-clean and secure by default.

This version focuses on the repo's safest default surfaces first: Envelopes for application code, AspNetCore DI/rotation for services, and readiness-friendly patterns for production hardening.

Features

Provides IntelliSense snippets for C# files to accelerate working with the PostQuantum.Hybrid cryptography library.

Recommended starting points:

  • pqh-envelope for anonymous seal/open flows.
  • pqh-envelope-signed for authenticated confidentiality.
  • pqh-aspnet-config for production-style ASP.NET Core registration.
  • pqh-aspnet-rotate when you need zero-downtime KEM key rotation.
Prefix What it expands to
pqh-envelope Recommended start for most applications: HybridEnvelope.Seal / Open.
pqh-envelope-signed Recommended authenticated confidentiality pattern: SignedHybridEnvelope.Seal / Open.
pqh-kem Hybrid KEM round-trip: generate → encapsulate → decapsulate, with using on every disposable.
pqh-sig Hybrid signature round-trip: generate → sign → verify, with the result branched on (PQH004).
pqh-kem-encrypt KEM → HKDF.Expand → AES-GCM. Uses encapsulation.Secret (the typed HybridSharedSecret wrapper), binds the KEM ciphertext into associatedData (PQH005), and zeroes the derived AES key.
pqh-kem-decrypt Counterpart that uses TryDecapsulate at the trust boundary.
pqh-signed-encrypted Sign-then-encrypt receiver pattern with verify-before-decrypt ordering (PQH003).
pqh-key-load TryImportPem for both public and private keys, with caller-owned disposal.
pqh-key-save Generate a fresh hybrid pair and persist as PEM, with Unix file-permission tightening.
pqh-hkdf HKDF.Expand from a HybridSharedSecret — the typed wrapper flows in via implicit ReadOnlySpan<byte> conversion.
pqh-aspnet-di AddPostQuantumHybrid registration with the bootstrap-pair-disposed-correctly pattern for demos/tests.
pqh-aspnet-config AddPostQuantumHybrid using a configuration section.
pqh-aspnet-rotate AddRotatingHybridKemKeys registration for zero-downtime KEM key rotation.
pqh-readiness-check Startup smoke test that exercises a real signed-envelope seal/open flow.

PostQuantum.FileEncryption (pqfe-*)

Snippets for the file-encryption family, aligned with its cookbook and anti-patterns docs:

Prefix What it expands to
pqfe-encrypt Passphrase file round-trip done right: runtime passphrase (PQFE101), Argon2id, atomic output, fail-closed catch (PQFE104).
pqfe-decrypt-untrusted Decryptor with PqDecryptionLimits.Untrusted — the mandatory shape for uploads and shared storage.
pqfe-hybrid-keygen X25519 + ML-KEM-768 key pair with the private half stored as a passphrase-protected PQKF key file (PQFE102).
pqfe-hybrid-roundtrip Encrypt to a recipient public key; decrypt after ImportEncrypted of the protected key file.
pqfe-sign-verify Detached Ed25519 + ML-DSA-65 signing with verify-before-use and no swallowed PqSignatureException.
pqfe-di One-line DI registration, including the limits overload for services decrypting untrusted containers.
pqfe-upload ASP.NET Core streaming upload encryption — the web server holds only the public key and can read nothing it stores.
pqfe-kms AWS KMS / Azure Key Vault envelope encryption — the master key never enters your process.

Why These Snippets First?

  • Envelope snippets are the safest default. They collapse KEM + HKDF + AEAD into one misuse-resistant API.
  • ASP.NET snippets reflect real deployment patterns. Configuration-based registration and rotating KEM keys are more useful to service authors than only demo-style inline PEM wiring.
  • Readiness matters in production. A snippet that exercises real crypto at startup is far more useful than a static support probe.

Requirements

The snippets emit code that depends on the NuGet packages — install them in your project or they will not compile:

# For the pqh-* snippets:
dotnet add package PostQuantum.Hybrid
dotnet add package PostQuantum.Hybrid.Analyzers      # strongly recommended
dotnet add package PostQuantum.Hybrid.Envelopes      # for Seal/Open helpers
dotnet add package PostQuantum.Hybrid.AspNetCore     # for the ASP.NET Core wiring

# For the pqfe-* snippets:
dotnet add package PostQuantum.FileEncryption
dotnet add package PostQuantum.FileEncryption.Analyzers   # strongly recommended
dotnet add package PostQuantum.FileEncryption.Hybrid      # recipient encryption
dotnet add package PostQuantum.FileEncryption.Signing     # detached signatures
dotnet add package PostQuantum.FileEncryption.Extensions.DependencyInjection

Known Issues

See the main repository's KNOWN-GAPS.md for current library limitations.

Release Notes

See CHANGELOG.md for detailed release notes.

1.2.0

  • Added the pqfe-* snippet family for the PostQuantum.FileEncryption NuGet family: fail-closed file encryption, untrusted-input limits, PQKF key files, detached signing, DI registration, streaming upload encryption, and KMS envelopes.
  • Every pqfe-* snippet is analyzer-clean against PostQuantum.FileEncryption.Analyzers (PQFE101 – PQFE104) and mirrors that repo's cookbook recipes.

1.1.0

  • Added Envelopes, ASP.NET Core configuration/rotation, and readiness-check snippets.
  • Repositioned the snippet set around the safest high-level APIs first.
  • Tightened packaging/docs consistency for Marketplace publishing.

1.0.1

  • Marketplace polish release with icon, listing metadata, and packaging updates.

1.0.0

  • Initial release of C# snippets for PostQuantum.Hybrid.

To God be the glory — 1 Corinthians 10:31.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft