Generate a system hash¶
This operation produces the identifier that callers present when requesting a secure configuration setting. It resolves the most plausible calling assembly name, hashes the resulting {systemName}-{systemType} payload with SHA-256, and — unless the caller explicitly asks for the raw value — wraps the digest with a time-based salt so its age can later be validated.
| Field | Value |
|---|---|
| Operation ID | OP-ENV-011 |
| Trigger | Caller needs a system hash |
| Inputs | SystemType, optional explicit systemName |
| Outputs | Salted hash string from ComputeHash or Get, or unsalted hash string from ComputeHashNow |
| Primary components | SystemHashUtil.Get, SystemHashUtil.GetAssembly, SystemHashUtil.ComputeHash, SystemHashUtil.ComputeHashNow, SystemHashUtil.GetHashValue |
| Entry point | SAIF.Framework.Security.EnvironmentApi\Services.Common\SystemHashUtil.cs |
Steps¶
- Resolve the source system name when the caller did not supply one explicitly.
Get(SystemType)callsGetAssembly()and uses whichever assembly name that method returns.GetAssembly()triesAssembly.GetEntryAssembly()first, thenGetWebEntryAssembly(), thenGetLegacyWebEntryAssembly(), and falls back toAssembly.GetExecutingAssembly()only if every prior candidate is unavailable.- Build the deterministic hash payload as
{systemName}-{(int)type}, so the same system and type combination always produces the same input to the hash function. - Encode that payload as Unicode bytes, hash it with SHA-256, and convert the digest to Base64.
- If the caller used
ComputeHashorGet, pass the Base64 payload tonew SaltShaker(DateTime.Now).SaltHash(value)and return the salted token. - If the caller used
ComputeHashNow, skip salting entirely and return the direct Base64 hash for scenarios that need an immediate, unsalted value.
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([Caller requests system hash]) --> Name[Resolve system name or assembly]
Name --> Payload[Build systemName-type payload]
Payload --> Digest[SHA-256 hash and Base64 encode]
Digest --> Salt{Salt result?}
Salt -->|Yes| SaltHash[SaltHash with current timestamp]
Salt -->|No| Raw([Return unsalted hash])
SaltHash --> End([Return salted hash])
Failure and edge-case behavior¶
GetLegacyWebEntryAssembly()falls back to stack-frame heuristics only when the standard entry-assembly discovery methods return nothing, so its result is best-effort in atypical hosting scenarios.ComputeHashNowintentionally skips the time-based salt wrapper, so its output cannot later be validated for age through Validate system hash lifetime.- The salting behavior itself is implemented entirely by the external
SAIF.HashUtilpackage; this operation only supplies the payload being salted.
Related documentation¶
Sources¶
- SAIF.Framework.Security.EnvironmentApi\Services.Common\SystemHashUtil.cs