private static void EnsureCrtInitialized() { if (expensiveCrtInitialization) { return; } lock (expensiveCrtInitializationLock) { if (expensiveCrtInitialization) { return; } nativeKeyDerivationFunction = EscapeExecutionContext(() => { Assembly assembly; if (IntPtr.Size == 4) { assembly = Assembly.Load("Replicon.Cryptography.SCrypt.MMA, Version=1.1.6.13, Culture=neutral, PublicKeyToken=4e0c787cc79e77b2, processorArchitecture=x86"); } else { assembly = Assembly.Load("Replicon.Cryptography.SCrypt.MMA, Version=1.1.6.13, Culture=neutral, PublicKeyToken=4e0c787cc79e77b2, processorArchitecture=amd64"); } var type = assembly.GetType("Replicon.Cryptography.SCrypt.MMA.SCrypt"); return((IKeyDerivationFunction)Activator.CreateInstance(type)); }); expensiveCrtInitialization = true; } }
public AesEncryptor(IKeyDerivationFunction keyDeriver, IFastRandom fastRandom) : base(fastRandom) { if (keyDeriver == null) { throw new ArgumentNullException(nameof(keyDeriver)); } _keyDeriver = keyDeriver; }
public CryptoStorage(IKeyDerivationFunction kdf, IEncryptor encryptor) : this() { kdf.ThrowIfNull(nameof(kdf)); encryptor.ThrowIfNull(nameof(encryptor)); this.kdf = kdf; this.encryptor = encryptor; }
/// <summary> /// Create an IKeyDerivationFunction implemented by a mixed-mode assembly. This is a high-performance /// implementation using SSE2, but requires support for C++/CLI mixed-mode assemblies (ie. doesn't work on /// Mono), and requires that the current environment be supported (.NET 3.5 or 4.0, x86 or x64). /// </summary> /// <remarks>If the mixed-mode assembly cannot be loaded, this method will... FIXME: what?</remarks> public static IKeyDerivationFunction CreateNativeKeyDerivationFunction() { if (nativeKdf != null) return nativeKdf; lock (kdfCreationLock) { if (nativeKdf != null) return nativeKdf; return nativeKdf = new MixedModeAssemblyKeyDerivationFunction(); } }
public DiffieHellmanRatchet(ILogger <DiffieHellmanRatchet> _logger, IDiffieHellmanHandler _DHH, IKeyDerivationFunction _kdf, ISignatureHandler _signer) { logger = _logger; dHH = _DHH; kdf = _kdf; signer = _signer; logger = _logger; // create identity key (x509IdentityKey, x509IdentityPrivateKey) = dHH.GenerateKeys(); // create starting keys (publicKey, privateKey) = dHH.GenerateKeys(); // sign the identity key SignPublicKey(); }
/// <summary> /// Create an IKeyDerivationFunction. /// </summary> public static IKeyDerivationFunction CreateSCryptKeyDerivationFunction() { if (Kdf != null) { return(Kdf); } lock (kdfCreationLock) { if (Kdf != null) { return(Kdf); } return(Kdf = new KeyDerivationFunction()); } }
/// <summary> /// Create an IKeyDerivationFunction implemented by a mixed-mode assembly. This is a high-performance /// implementation using SSE2, but requires support for C++/CLI mixed-mode assemblies (ie. doesn't work on /// Mono), and requires that the current environment be supported (.NET 3.5 or 4.0, x86 or x64). /// </summary> /// <remarks>If the mixed-mode assembly cannot be loaded, this method will... FIXME: what?</remarks> public static IKeyDerivationFunction CreateNativeKeyDerivationFunction() { if (nativeKdf != null) { return(nativeKdf); } lock (kdfCreationLock) { if (nativeKdf != null) { return(nativeKdf); } return(nativeKdf = new MixedModeAssemblyKeyDerivationFunction()); } }
public AesEncryptor(IKeyDerivationFunction keyDeriver) : this( keyDeriver, SafeOrbitCore.Current.Factory.Get <IFastRandom>()) { }
/// <summary> /// Create an IPasswordHash implementation, using the provided key-derivation function implementation. /// </summary> public static IPasswordHash CreatePasswordHash(IKeyDerivationFunction kdf) { return(new DefaultPasswordHash(kdf)); }
public void TestFixtureSetUp() { kdf = Create(); }
public void OneTimeSetUpAttribute() { kdf = Create(); }
public CryptoStorage(IKeyDerivationFunction kdf, IEncryptor encryptor, Stream dataSource) : this(kdf, encryptor) { DataSource = dataSource; }
public DefaultPasswordHash(IKeyDerivationFunction kdf) { this.kdf = kdf; }
internal static void Serialize(Stream destination, IKeyDerivationFunction obj) { destination.ThrowIfNull(nameof(destination)); obj.ThrowIfNull(nameof(obj)); GenericSerializer.Serialize(destination, obj, TypeToEnumMappings, FormatExceptionMessage); }
/// <summary> /// Create an IPasswordHash implementation, using the provided key-derivation function implementation. /// </summary> public static IPasswordHash CreatePasswordHash(IKeyDerivationFunction kdf) { return new DefaultPasswordHash(kdf); }
protected ISafeEncryptor GetSut(IKeyDerivationFunction kdf = null, IFastRandom random = null) { return(new AesEncryptor(kdf ?? Stubs.Get <IKeyDerivationFunction>(), random ?? Stubs.Get <IFastRandom>())); }