dlech.SshAgentLib.Agent.Unlock C# (CSharp) Method

Unlock() public method

public Unlock ( byte aPassphrase ) : void
aPassphrase byte
return void
        public void Unlock(byte[] aPassphrase)
        {
            if (!IsLocked) {
            // can't unlock if not locked
            throw new AgentLockedException();
              }
              if (aPassphrase == null) {
            aPassphrase = new byte[0];
              }
              if (mLockedPassphrase.Length != aPassphrase.Length) {
            // passwords definitely do not match
            throw new PassphraseException();
              }
              IntPtr lockedPassPtr =
              Marshal.SecureStringToGlobalAllocUnicode(mLockedPassphrase);
              for (int i = 0; i < mLockedPassphrase.Length; i++) {
            Int16 lockedPassChar = Marshal.ReadInt16(lockedPassPtr, i * 2);
            if (lockedPassChar != aPassphrase[i]) {
              Marshal.ZeroFreeGlobalAllocUnicode(lockedPassPtr);
              throw new PassphraseException();
            }
              }
              Marshal.ZeroFreeGlobalAllocUnicode(lockedPassPtr);
              mLockedPassphrase.Clear();
              IsLocked = false;
              FireLocked();
        }