コード例 #1
0
 protected override List <TKey> LoadKeys(TWorkflowOptions workflowOptions)
 {
     return(new List <TKey>()
     {
         _keyLoader.Load(new NullKeyLoaderDetails())
     });
 }
コード例 #2
0
        protected override List <TKey> LoadKeys(TWorkflowOptions workflowOptions)
        {
            var keys = new List <TKey>(workflowOptions.KeyFilePaths.Count);

            for (uint keyPathI = 0; keyPathI < workflowOptions.KeyFilePaths.Count; keyPathI++)
            {
                var loadedKey = _keyLoader.Load(
                    new KeyFromFileDetails()
                {
                    FilePath = workflowOptions.KeyFilePaths[(int)keyPathI]
                });
                keys.Add(loadedKey);
            }

            return(keys);
        }
コード例 #3
0
        public IList <byte[]> GetEncryptedSegments(TKeyLoadDetails usingKeyDetails, string toEncrypt, out TKey withKey)
        {
            Contract.Requires <ArgumentException>(!string.IsNullOrWhiteSpace(toEncrypt), "toEncrypt");
            Contract.Ensures(Contract.ValueAtReturn(out withKey) != null);
            //
            var key = _keyLoader.Load(usingKeyDetails);

            if (!_keySuitabilityChecker.IsEncryptingKey(key))
            {
                throw new EnvCryptException("impossible to encrypt using this {0} key. Name: {1}", key.Algorithm, key.Name);
            }

            var binaryToEncrypt = _userStringConverter.Encode(toEncrypt);

            withKey = key;
            return(_segmentEncrypter.Encrypt(binaryToEncrypt, key));
        }