/// <summary>
        /// Signs the given data
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public override String SignData(String data)
        {
            AgentClient.Connect();

            SSHAgentSignRequest signRequest = new SSHAgentSignRequest();

            signRequest.SetPublicKey(PublicKey);
            signRequest.SetSignData(data);

            if (SignDigestType == DigestType.SSH_RSA_SHA512)
            {
                signRequest.SetSignFlags((int)AgentSignFlags.SSH_AGENT_RSA_SHA2_512);
            }
            else
            {
                signRequest.SetSignFlags((int)AgentSignFlags.SSH_AGENT_RSA_SHA2_256);
            }

            SSHAgentSignResponse signResponse = AgentClient.Send <SSHAgentSignResponse>(signRequest);

            AgentClient.Disconnect();

            if (signResponse.Signature.Length > 0)
            {
                return(System.Convert.ToBase64String(signResponse.Signature));
            }

            throw new Exception("Invalid Signature");
        }
Example #2
0
        public override SSHAgentResponse Unpack(BinaryReader Reader)
        {
            var response = new SSHAgentSignResponse();

            response.Unpack(Reader);

            return(response);
        }