Esempio n. 1
0
 internal void FreeEncryptor(MbedEncryptor e)
 {
     if (e != null)
     {
         if (e.IsCipher)
         {
             encryptorPool.Add(e);
         }
         else
         {
             decryptorPool.Add(e);
         }
     }
 }
Esempio n. 2
0
        internal MbedEncryptor GetDecryptor(Server s)
        {
            MbedEncryptor decryptor;

            if (!decryptorPool.TryTake(out decryptor))
            {
                //Not  found
                decryptor = new MbedEncryptor(s.Method, false);
            }
            else if (decryptor.Method != s.Method)
            {
                //found but method not match
                decryptor.SetMethod(s.Method);
            }
            //found and method match, set key only
            decryptor.SetKey(s.Password);
            return(decryptor);
        }
Esempio n. 3
0
        internal MbedEncryptor GetEncryptor(Server s)
        {
            MbedEncryptor encryptor;

            if (!encryptorPool.TryTake(out encryptor))
            {
                //Not  found
                encryptor = new MbedEncryptor(s.Method, true);
            }
            else if (encryptor.Method != s.Method)
            {
                //found but method not match
                encryptor.SetMethod(s.Method);
            }
            //found and method match, set key and iv
            encryptor.SetKV(s.Password);
            return(encryptor);
        }