OfficeIMO.Security
3.6.2
Prefix Reserved
dotnet add package OfficeIMO.Security --version 3.6.2
NuGet\Install-Package OfficeIMO.Security -Version 3.6.2
<PackageReference Include="OfficeIMO.Security" Version="3.6.2" />
<PackageVersion Include="OfficeIMO.Security" Version="3.6.2" />
<PackageReference Include="OfficeIMO.Security" />
paket add OfficeIMO.Security --version 3.6.2
#r "nuget: OfficeIMO.Security, 3.6.2"
#:package OfficeIMO.Security@3.6.2
#addin nuget:?package=OfficeIMO.Security&version=3.6.2
#tool nuget:?package=OfficeIMO.Security&version=3.6.2
OfficeIMO.Security
OfficeIMO.Security is the optional cryptographic provider for OfficeIMO. It owns bounded CMS/PKCS#7, S/MIME,
RFC 3161, X.509, XML Digital Signature, and enveloped-data operations. Word, PDF, Email, and the other format
packages do not depend on this package: applications that use cryptographic features install it explicitly and pass
its strongly typed provider to the format API.
dotnet add package OfficeIMO.Security
The dependency-free IOfficeSecurityProvider contract and result models ship in the common OfficeIMO.Core
foundation under the OfficeIMO.Security namespace. The concrete OfficeSecurityProvider implementation lives in
this package. This keeps normal document creation, reading, conversion, signature inspection, and safe mutation
policies free of Bouncy Castle and XML DSig dependencies while avoiding reflection, dynamic plug-in discovery, or a
new package for every format.
using OfficeIMO.Security;
IOfficeSecurityProvider security = OfficeSecurityProvider.Default;
Applications remain responsible for key custody, certificate and recipient selection, and trust policy. The provider does not silently discover keys or enable network revocation.
Use with format packages
Pass the same provider to the format API that owns the document structure:
using OfficeIMO.Security;
using OfficeIMO.Word;
IOfficeSecurityProvider security = OfficeSecurityProvider.Default;
WordDocument.SignPackage("report.docx", security, signingCertificate);
using WordDocument signed = WordDocument.Load("report.docx");
WordSignatureValidationReport validation = signed.ValidateSignatures(security);
OfficeIMO.Pdf accepts it through PdfCmsExternalSigner and
PdfCmsSignatureCryptographyProvider. OfficeIMO.Email accepts it through EmailSmime.Verify and
EmailSmime.Decrypt. Structural signature inspection and fail-safe mutation policies do not require this package.
CMS signing and verification
The provider is also usable directly when no format adapter is involved:
byte[] signature = security.SignCmsDetached(content, signingCertificate);
CmsVerificationResult result = security.VerifyCmsDetached(signature, content);
foreach (CmsSignerVerificationResult signer in result.Signers) {
Console.WriteLine($"{signer.Subject}: {signer.SignatureStatus}, {signer.CertificateValidation.ChainStatus}");
}
Signing uses platform RSA or ECDsa handles and does not export private keys. CmsSigningOptions.UsePadesBaseline creates detached baseline CMS with a SHA-256 signing-certificate-v2 binding and omits CMS signing-time. Verification supports RSA and ECDSA
signers and keeps mathematical signature, message digest, certificate trust, revocation, and timestamp outcomes
separate. CreateCmsVerificationSession(...) shares operation-wide timestamp limits across related CMS containers.
Certificate trust validation
Use the provider when an application needs the same certificate-chain, revocation, and usage-policy result without first parsing CMS. Additional certificates are chain-building candidates, not trusted merely because a caller supplied them.
using System.Security.Cryptography.X509Certificates;
using OfficeIMO.Security;
var options = new CertificateValidationOptions {
RevocationMode = X509RevocationMode.NoCheck,
DisableCertificateDownloads = true
};
CertificateTrustValidationResult trust = security.ValidateCertificate(
signingCertificate,
additionalCertificates: new[] { intermediateCertificate },
options: options,
purpose: CertificateValidationPurpose.DocumentSigning);
Console.WriteLine($"Chain: {trust.Validation.ChainStatus}");
Console.WriteLine($"Revocation: {trust.Validation.RevocationStatus}");
The secure default disables certificate downloads and uses X509RevocationMode.NoCheck. Set an explicit verification
time, revocation mode, download policy, or chain evaluator when the application owns a different trust policy. Usage
and enhanced-key-usage checks remain active even when platform chain building is disabled.
EnvelopedData and timestamps
byte[] envelope = security.EncryptCms(content, new[] { recipientCertificate });
CmsDecryptionResult decrypted = security.DecryptCms(envelope, recipientWithPrivateKey);
Recipient selection is exact and caller-owned. On .NET 8 and later, RSA PKCS#1/OAEP recipients
with AES-128/192/256-CBC content use the supplied platform RSA handle without exporting private
parameters or searching certificate stores. Platform OAEP profiles require SHA-1, SHA-256,
SHA-384, or SHA-512 with the same MGF1 digest and an empty label. This supports keys that permit decryption while
prohibiting export. Keychain identity selection, authorization prompts, and retained access belong
to the application. Other envelope profiles and older target frameworks use the Bouncy Castle
adapter and require an exportable RSA key; unavailable export produces
EnvelopePrivateKeyNotExportable. Plaintext size is bounded before platform decryption where the
ciphertext length establishes it, then checked exactly before returning content.
VerifyTimestamp(...) validates RFC 3161 signatures, TSA certificate profiles, message imprints, caller trust policy,
and revocation as a separate operation. TSA chain validation defaults to the token generation time unless the caller
supplies another verification time.
Rfc3161TimestampClient requests timestamps through a supplied transport callback:
var tsa = new Rfc3161TimestampClient(timestampTransport, tsaTrustPolicy);
var signingOptions = new CmsSigningOptions {
UsePadesBaseline = true,
SignatureTimestampProvider = tsa.GetTimestamp
};
timestampTransport receives DER request bytes and a cancellation token and
returns the DER response bytes. POST with application/timestamp-query and
accept application/timestamp-reply. Configure the HTTP client's timeout and
enforce a response-size limit before buffering data. The timestamp client rechecks its response limit and validates
the nonce, message imprint, TSA signature, certificate profile and trust policy.
Revocation data retrieval
CertificateRevocationFetcher implements ICertificateRevocationFetcher. It reads a certificate's OCSP responder and
CRL distribution point locations, asks the OCSP responder first and falls back to the CRL:
using var fetcher = new CertificateRevocationFetcher(new CertificateRevocationFetcherOptions {
Timeout = TimeSpan.FromSeconds(10),
MaxResponseBytes = 16 * 1024 * 1024
});
CertificateRevocationEvidence evidence = await fetcher.FetchAsync(certificate, issuer, cancellationToken);
Only http and https locations are used. Responses are cached by the instance until their nextUpdate (five
minutes when they have none; failures for one minute). Loopback, private, link-local and other non-public addresses
are refused unless AllowPrivateNetworkAddresses is set for an internal PKI; while they are refused, connections go
directly to the server without a proxy. On .NET 8 and later every resolved address is checked when the connection is
made. Older frameworks check the resolved addresses before each request, send http requests to the checked address
and rely on certificate validation to bind https connections to the host name. The returned responses are untrusted input: validators check
their signatures, issuers and freshness. OfficeIMO.Pdf uses the fetcher for PAdES B-LT enrichment and for its
online revocation policies.
XML Digital Signatures
CreateXmlSignature(...), VerifyXmlSignature(...), and CanonicalizeXml(...) expose a closed, bounded XML DSig
algorithm set for format-owned signing workflows. RSA/SHA signature methods, SHA digests, canonicalization, and
enveloped-signature transforms are intersected with immutable provider support; caller allowlists can narrow that set
but cannot register or enable another implementation. External references and unsupported transforms are rejected.
Document packages remain responsible for package relationships, content types, signed-part selection, and mutation
safety.
Raw public-key signatures
OfficeSecurityProvider also implements IOfficePublicKeySignatureVerifier: RSASSA-PKCS1-v1_5 with SHA-256 or SHA-1
over DER SubjectPublicKeyInfo or PKCS #1 RSA keys, and Ed25519 (RFC 8032) over raw 32-byte keys. OfficeIMO.Email
uses it for DKIM and ARC. Malformed keys and signatures are reported as typed statuses rather than exceptions, and RSA
keys above 16384 bits are refused.
OpenPGP
OfficeSecurityProvider implements IOfficeOpenPgpProvider over BouncyCastle: detached and cleartext signature
verification and message decryption with integrity checks, using only the keys in the caller's
OfficeOpenPgpKeySet. It covers version 4 (RFC 4880) keys and signatures; RFC 9580 version 6 packets and AEAD
encrypted data are reported as unsupported. OfficeIMO.Email uses it for PGP/MIME.
NativeAOT and trimming
Ordinary OfficeIMO applications do not carry this package unless they opt in. The repository publishes a separate
OfficeIMO.Security.AotSmoke executable that signs and verifies both CMS and XML DSig from NativeAOT. The provider
roots only its accepted XML DSig algorithms to satisfy SignedXml's name-based algorithm resolution; consumers do
not need linker descriptors or reflection-based registration.
Dependency footprint
- External:
BouncyCastle.Cryptography2.x andSystem.Security.Cryptography.Xml. - OfficeIMO: the zero-dependency
OfficeIMO.Corefoundation for provider contracts and result models. - Not included transitively by:
OfficeIMO.Word,OfficeIMO.Pdf,OfficeIMO.Email, or other format packages.
IOfficeSecurityProvider and its result constructors are public in the dependency-free contract assembly, so an
application can supply a policy-specific provider or test double without referencing this concrete implementation.
| 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 is compatible. 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 was computed. 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 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7.2
- BouncyCastle.Cryptography (>= 2.7.0 && < 3.0.0)
- OfficeIMO.Core (>= 3.6.2)
- System.Security.Cryptography.Xml (>= 10.0.13)
-
.NETStandard 2.0
- BouncyCastle.Cryptography (>= 2.7.0 && < 3.0.0)
- OfficeIMO.Core (>= 3.6.2)
- System.Security.Cryptography.Xml (>= 10.0.13)
-
net10.0
- BouncyCastle.Cryptography (>= 2.7.0 && < 3.0.0)
- OfficeIMO.Core (>= 3.6.2)
- System.Security.Cryptography.Pkcs (>= 10.0.13)
- System.Security.Cryptography.Xml (>= 10.0.13)
-
net8.0
- BouncyCastle.Cryptography (>= 2.7.0 && < 3.0.0)
- OfficeIMO.Core (>= 3.6.2)
- System.Security.Cryptography.Pkcs (>= 10.0.13)
- System.Security.Cryptography.Xml (>= 10.0.13)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on OfficeIMO.Security:
| Package | Downloads |
|---|---|
|
Ank.DocToolkit
Convert HTML to PDF and DOCX in C# without a browser - pure managed, no Chromium, no wkhtmltopdf, no native binaries, no LibreOffice, no Office interop. Also converts Markdown to DOCX and PDF; renders DOCX, XLSX and PPTX to PDF; exports DOCX to HTML/Markdown and XLSX to CSV/HTML; reads legacy Word 97-2003 .doc files; reads text out of a PDF; creates/edits DOCX, XLSX and PPTX; password-protects PDF, DOCX, XLSX and PPTX; and inspects and validates digital signatures in DOCX, XLSX and PPTX. Runs on Linux, Windows, macOS and arm64, and makes no network calls at runtime. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.6.2 | 90 | 11/18/2026 |
| 3.6.1 | 234 | 11/10/2026 |
| 3.6.0 | 246 | 11/6/2026 |
| 3.5.3 | 523 | 10/31/2026 |
| 3.5.2 | 188 | 10/24/2026 |
| 3.5.1 | 235 | 10/16/2026 |
| 3.4.5 | 213 | 10/10/2026 |
| 3.4.4 | 211 | 9/27/2026 |
| 3.4.3 | 372 | 9/12/2026 |
| 3.4.2 | 209 | 9/9/2026 |
| 3.4.1 | 153 | 9/7/2026 |
| 3.4.0 | 172 | 9/6/2026 |
| 3.3.0 | 152 | 9/2/2026 |
| 3.2.7 | 176 | 8/29/2026 |
| 3.2.6 | 2,575 | 8/22/2026 |
| 3.2.5 | 145 | 8/21/2026 |
| 3.2.4 | 152 | 8/19/2026 |
| 3.2.3 | 142 | 8/17/2026 |
| 3.2.2 | 438 | 8/13/2026 |
| 3.2.1 | 139 | 8/11/2026 |