private NetFXCryptoService GetNetFXCryptoService(Purpose purpose, CryptoServiceOptions options) { // Extract the encryption and validation keys from the provided Purpose object CryptographicKey encryptionKey = purpose.GetDerivedEncryptionKey(_masterKeyProvider, _keyDerivationFunction); CryptographicKey validationKey = purpose.GetDerivedValidationKey(_masterKeyProvider, _keyDerivationFunction); // and return the ICryptoService // (predictable IV turned on if the caller requested cacheable output) return new NetFXCryptoService(_cryptoAlgorithmFactory, encryptionKey, validationKey, predictableIV: (options == CryptoServiceOptions.CacheableOutput)); }
private NetFXCryptoService GetNetFXCryptoService(Purpose purpose, CryptoServiceOptions options) { // Extract the encryption and validation keys from the provided Purpose object CryptographicKey encryptionKey = purpose.GetDerivedEncryptionKey(_masterKeyProvider, _keyDerivationFunction); CryptographicKey validationKey = purpose.GetDerivedValidationKey(_masterKeyProvider, _keyDerivationFunction); // and return the ICryptoService // (predictable IV turned on if the caller requested cacheable output) return(new NetFXCryptoService(_cryptoAlgorithmFactory, encryptionKey, validationKey, predictableIV: (options == CryptoServiceOptions.CacheableOutput))); }
public ICryptoService GetCryptoService(Purpose purpose, CryptoServiceOptions options = CryptoServiceOptions.None) { ICryptoService cryptoService; if (_isDataProtectorEnabled && options == CryptoServiceOptions.None) { // We can only use DataProtector if it's configured and the caller didn't ask for any special behavior like cacheability cryptoService = GetDataProtectorCryptoService(purpose); } else { // Otherwise we fall back to using the <machineKey> algorithms for cryptography cryptoService = GetNetFXCryptoService(purpose, options); } // always homogenize errors returned from the crypto service return new HomogenizingCryptoServiceWrapper(cryptoService); }
public ICryptoService GetCryptoService(Purpose purpose, CryptoServiceOptions options = CryptoServiceOptions.None) { ICryptoService cryptoService; if (_isDataProtectorEnabled && options == CryptoServiceOptions.None) { // We can only use DataProtector if it's configured and the caller didn't ask for any special behavior like cacheability cryptoService = GetDataProtectorCryptoService(purpose); } else { // Otherwise we fall back to using the <machineKey> algorithms for cryptography cryptoService = GetNetFXCryptoService(purpose, options); } // always homogenize errors returned from the crypto service return(new HomogenizingCryptoServiceWrapper(cryptoService)); }