Example #1
0
        /// <summary>
        /// SSH1 RSA challenge
        /// </summary>
        /// <param name="e">public exponent</param>
        /// <param name="n">public modulus</param>
        /// <param name="encryptedChallenge">encrypted challenge</param>
        /// <param name="sessionId">session id</param>
        /// <param name="responseType">response type</param>
        private void SSH1IRSAChallenge(BigInteger e, BigInteger n, BigInteger encryptedChallenge, byte[] sessionId, uint responseType)
        {
            if (responseType != 1)
            {
                SendFailure();
                return;
            }

            SSH1UserAuthKey key = SSH1FindKey(e, n);

            if (key == null)
            {
                SendFailure();
                return;
            }

            BigInteger challenge = key.decryptChallenge(encryptedChallenge);

            byte[] rawchallenge = RSAUtil.StripPKCS1Pad(challenge, 2).GetBytes();
            byte[] hash;
            using (var md5 = new MD5CryptoServiceProvider()) {
                md5.TransformBlock(rawchallenge, 0, rawchallenge.Length, rawchallenge, 0);
                md5.TransformFinalBlock(sessionId, 0, sessionId.Length);
                hash = md5.Hash;
            }

            Send(
                new OpenSSHAgentForwardingMessage(OpenSSHAgentForwardingMessageType.SSH_AGENT_RSA_RESPONSE)
                .Write(hash)
                );
        }
Example #2
0
 public SSH1UserAuthKey[] GetAvailableSSH1UserAuthKeys()
 {
     if (_ssh1Keys == null)
     {
         try {
             SSH1UserAuthKey k = new SSH1UserAuthKey(@"C:\P4\Tools\keys\aaa", "aaa");
             _ssh1Keys = new SSH1UserAuthKey[] { k };
         }
         catch (Exception e) {
             Debug.WriteLine(e.Message);
             _ssh1Keys = new SSH1UserAuthKey[0];
         }
     }
     return(_ssh1Keys);
 }