示例#1
0
        public CryptographicKey GetDerivedValidationKey(IMasterKeyProvider masterKeyProvider, KeyDerivationFunction keyDerivationFunction)
        {
            CryptographicKey cryptographicKey = this.DerivedValidationKey;

            if (cryptographicKey == null)
            {
                CryptographicKey validationKey = masterKeyProvider.GetValidationKey();
                cryptographicKey = keyDerivationFunction(validationKey, this);
                if (this.SaveDerivedKeys)
                {
                    this.DerivedValidationKey = cryptographicKey;
                }
            }
            return(cryptographicKey);
        }
        private NetFXCryptoService GetNetFXCryptoService()
        {
            if (_encryptionKey == null)
            {
                _encryptionKey = DeriveKey(_masterKeyProvider.GetEncryptionKey());
            }
            if (_validationKey == null)
            {
                _validationKey = DeriveKey(_masterKeyProvider.GetValidationKey());
            }

            // and return the ICryptoService
            // (predictable IV turned on if the caller requested cacheable output)
            return(new NetFXCryptoService(_cryptoAlgorithmFactory, _encryptionKey, _validationKey));
        }
示例#3
0
        public CryptographicKey GetDerivedValidationKey(IMasterKeyProvider masterKeyProvider, KeyDerivationFunction keyDerivationFunction)
        {
            // has a key already been stored?
            CryptographicKey actualDerivedKey = DerivedValidationKey;

            if (actualDerivedKey == null)
            {
                CryptographicKey masterKey = masterKeyProvider.GetValidationKey();
                actualDerivedKey = keyDerivationFunction(masterKey, this);

                // only save the key back to storage if this Purpose is configured to do so
                if (SaveDerivedKeys)
                {
                    DerivedValidationKey = actualDerivedKey;
                }
            }

            return(actualDerivedKey);
        }
示例#4
0
        public CryptographicKey GetDerivedValidationKey(IMasterKeyProvider masterKeyProvider, KeyDerivationFunction keyDerivationFunction) {
            // has a key already been stored?
            CryptographicKey actualDerivedKey = DerivedValidationKey;
            if (actualDerivedKey == null) {
                CryptographicKey masterKey = masterKeyProvider.GetValidationKey();
                actualDerivedKey = keyDerivationFunction(masterKey, this);

                // only save the key back to storage if this Purpose is configured to do so
                if (SaveDerivedKeys) {
                    DerivedValidationKey = actualDerivedKey;
                }
            }

            return actualDerivedKey;
        }