OfficeIMO.Security 3.1.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package OfficeIMO.Security --version 3.1.0
                    
NuGet\Install-Package OfficeIMO.Security -Version 3.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OfficeIMO.Security" Version="3.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OfficeIMO.Security" Version="3.1.0" />
                    
Directory.Packages.props
<PackageReference Include="OfficeIMO.Security" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OfficeIMO.Security --version 3.1.0
                    
#r "nuget: OfficeIMO.Security, 3.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OfficeIMO.Security@3.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OfficeIMO.Security&version=3.1.0
                    
Install as a Cake Addin
#tool nuget:?package=OfficeIMO.Security&version=3.1.0
                    
Install as a Cake Tool

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 the platform RSA handle and does not export the private key. 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. The current Bouncy Castle key-transport adapter requires an exportable RSA private key for envelope decryption; a non-exportable key produces the stable EnvelopePrivateKeyNotExportable finding.

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.

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.

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.Cryptography 2.x and System.Security.Cryptography.Xml.
  • OfficeIMO: the zero-dependency OfficeIMO.Core foundation 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.1.1 0 8/7/2026
3.1.0 22 8/6/2026
3.0.3 3,375 7/27/2026
3.0.2 2,135 7/26/2026
3.0.1 1,238 7/26/2026
3.0.0 1,549 7/20/2026