Files
Joseph Doherty fe2a6db786
rust / build / test / clippy / fmt (push) Has been cancelled
Initial project state: .NET reference, design, Rust port (M0+M1), evidence
Layout:
- src/                    .NET 10 x64 reference: MxNativeCodec, MxNativeClient,
                          MxAsbClient, probes, tests, harnesses. Executable spec.
- design/                 Architectural plan for the Rust port (M0–M6), error
                          model, protocol invariants, risks (R1–R16), adversarial
                          review log (review.md).
- rust/                   Rust workspace. M0 skeleton + M1 codec parity.
                          mxaccess-codec: 215 unit tests + 2 cross-implementation
                          parity tests (byte-identical against .NET reference).
                          Other crates are M0 stubs awaiting M2+.
- captures/               Frida + netsh + pcap evidence per CLAUDE.md
                          ("captures are evidence, not throwaway logs").
- analysis/               Decompiled C# (frida/proxy/decompiled-*),
                          Ghidra exports for native DLLs (`exports/` only —
                          working state at `projects/` and AVEVA's input
                          binaries at `input/` are gitignored).
- docs/                   Reverse-engineering reference docs.
- tools/                  Setup-LiveProbeEnv.ps1 (Infisical credential fetcher),
                          Compute-Crc.ps1 (.NET parity helper).
- .github/workflows/      Rust CI: fmt + build + test + clippy on Windows.
- LICENSE                 MIT (Joseph Doherty, 2026).

Verified:
- cargo test --workspace → 217 passed (215 unit + 2 .NET parity), 0 failed
- cargo clippy --workspace -- -D warnings → clean
- cargo fmt --all -- --check → clean
- cargo publish --dry-run -p mxaccess-codec → packages cleanly

Excluded from history (see .gitignore):
- **/bin, **/obj, **/target — build artifacts
- analysis/ghidra/projects/ — Ghidra working state (regenerable)
- analysis/ghidra/input/ — AVEVA proprietary DLLs (vendor IP)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-05 06:21:00 -04:00

101 lines
2.8 KiB
C#

using System;
using System.Security.Cryptography;
using System.Text;
namespace ArchestrAServices.Common;
public class ASBConfigurationInformation
{
private const string DefaultCryptoGenerator = "22";
private const int DefaultKeySize = 256;
private const string DefaultPrime768 = "1552518092300708935130918131258481755631334049434514313202351194902966239949102107258669453876591642442910007680288864229150803718918046342632727613031282983744380820890196288509170691316593175367469551763119843371637221007210577919";
private const string DefaultHashAlgorithm = "None";
private const int DefaultPasswordIterations = 1;
private const string DefaultSaltValue = "s@1tValue";
private const string DefaultInitializationVector = "ba172e9941be138b";
public string SolutionName { get; set; }
public string Generator { get; set; }
public string Prime { get; set; }
public string HashAlgorithm { get; set; }
public string InitializationVector { get; set; }
public string SaltValue { get; set; }
public int PasswordDerivationIterations { get; set; }
public int KeySize { get; set; }
public string EncryptedSharedSecret { get; set; }
public string EncryptedCertificate { get; set; }
public string IsDefault { get; set; }
public string SRNodeName { get; set; }
public string PrimaryGlobalDiscovery { get; set; }
public string SecondaryGlobalDiscovery { get; set; }
public string PrimaryUniversalDiscovery { get; set; }
public string SecondaryUniversalDiscovery { get; set; }
public ASBConfigurationInformation()
{
Generator = "22";
KeySize = 256;
Prime = "1552518092300708935130918131258481755631334049434514313202351194902966239949102107258669453876591642442910007680288864229150803718918046342632727613031282983744380820890196288509170691316593175367469551763119843371637221007210577919";
HashAlgorithm = "None";
PasswordDerivationIterations = 1;
SaltValue = "s@1tValue";
InitializationVector = "ba172e9941be138b";
}
public static string GetNewSharedSecret(int length)
{
if (length < 1)
{
throw new ArgumentOutOfRangeException("length");
}
StringBuilder stringBuilder = new StringBuilder(length);
RNGCryptoServiceProvider rNGCryptoServiceProvider = new RNGCryptoServiceProvider();
try
{
char[] array = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".ToCharArray();
byte[] array2 = new byte[1];
for (int i = 0; i < length; i++)
{
do
{
rNGCryptoServiceProvider.GetBytes(array2);
}
while (!IsFairRandomNumber(array2[0], array.Length));
stringBuilder.Append(array[array2[0] % array.Length]);
}
}
finally
{
rNGCryptoServiceProvider.Dispose();
}
return stringBuilder.ToString();
}
private static bool IsFairRandomNumber(byte randomNumber, int numChars)
{
int num = 255 / numChars;
return randomNumber < numChars * num;
}
}