NebulaCrypto
Provides random bytes, SHA-256 hashes, hash-based message authentication codes (HMAC), and key derivation for encrypted transport connections.
Nebula · Packages/com.1by3.nebula/Runtime/Transport/NebulaCrypto.cspublic static class NebulaCryptoProvides random bytes, SHA-256 hashes, hash-based message authentication codes (HMAC), and key derivation for encrypted transport connections. Randomness, hashing, and HMAC use the platform's cryptography APIs.
The associated X25519 and managed ChaCha20Poly1305Managed implementations are not constant-time. The transport generates a new key pair for each connection.
Methods
Random
public static byte[] Random(int bytes);FixedTimeEquals
public static bool FixedTimeEquals(byte[] a, byte[] b);Compares equal-length arrays without stopping at a differing byte. Returns false for null arrays or unequal lengths.
Sha256
public static byte[] Sha256(byte[] data);HmacSha256
public static byte[] HmacSha256(byte[] key, byte[] data);Hkdf
public static byte[] Hkdf(byte[] salt, byte[] ikm, string info, int length);Derives length bytes using the HMAC-based extract-and-expand key derivation function (HKDF) with SHA-256, as specified in RFC 5869.