Table of Contents

Class DecryptingAssetSource

Namespace
EncDotNet.S100.ExchangeSets.Protection
Assembly
EncDotNet.S100.ExchangeSets.dll

An IAssetSource decorator that transparently decrypts (and optionally decompresses) the protected files of an S-100 Part 15 exchange set as they are read, so downstream dataset readers and the ExchangeSetVerifier can consume plaintext through the ordinary IAssetSource contract.

public sealed class DecryptingAssetSource : IAssetSource, IDisposable, IAsyncDisposable
Inheritance
DecryptingAssetSource
Implements
Inherited Members

Remarks

S-100 Edition 5.2.1 Part 15 §15-5, §15-6. A file is decrypted only when the supplied IDatasetKeyProvider yields a cell key for it; files with no key (for example the exchange catalogue or unencrypted support files) are passed through unchanged. Because the digital signature is computed over the unencrypted resource (§15-8.9), wrapping the source in this decorator lets the existing signature verifier validate an encrypted set without modification.

When decompress is enabled, a decrypted file that begins with the ZIP local-file-header signature is treated as the single-file DEFLATE archive mandated by §15-5.2 and its sole entry is returned; other content is returned as-is.

Constructors

DecryptingAssetSource(IAssetSource, IDatasetKeyProvider, bool, bool)

Creates a decrypting asset source.

public DecryptingAssetSource(IAssetSource inner, IDatasetKeyProvider keyProvider, bool decompress = false, bool ownsInner = true)

Parameters

inner IAssetSource

The underlying asset source to read encrypted bytes from.

keyProvider IDatasetKeyProvider

The provider that resolves cell keys per dataset.

decompress bool

Whether to decompress decrypted files that are single-file ZIP archives (set when the exchange set declares compressionFlag, §15-5.3).

ownsInner bool

Whether disposing this instance should also dispose inner. Defaults to true.

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

OpenAsync(string, CancellationToken)

Opens a readable stream for the asset at the given relative path within the source.

public Task<Stream> OpenAsync(string relativePath, CancellationToken cancellationToken = default)

Parameters

relativePath string

A forward-slash separated relative path to the asset.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Stream>

Exceptions

DatasetPermitException

The requested protected dataset is not authorized by its permit.

DatasetDecryptionException

The permit authorized the dataset, but its cell key could not decrypt it, most likely because the hardware id is wrong.