示例#1
0
        byte[] getSignature_rsa(Session session, byte[] data)
        {
            try
            {
                Type         t   = Type.GetType(jsch.getConfig("signature.rsa"));
                SignatureRSA rsa = (SignatureRSA)Activator.CreateInstance(t);

                rsa.init();
                rsa.setPrvKey(e_array, n_array, d_array, p_array, q_array, dmp1_array, dmq1_array, iqmp_array);

                /*
                 * byte[] goo=new byte[4];
                 * goo[0]=(byte)(session.getSessionId().Length>>>24);
                 * goo[1]=(byte)(session.getSessionId().Length>>>16);
                 * goo[2]=(byte)(session.getSessionId().Length>>>8);
                 * goo[3]=(byte)(session.getSessionId().Length);
                 * rsa.update(goo);
                 * rsa.update(session.getSessionId());
                 */
                rsa.update(data);
                byte[] sig = rsa.sign();
                Buffer buf = new Buffer("ssh-rsa".Length + 4 +
                                        sig.Length + 4);
                buf.putString(System.Text.Encoding.Default.GetBytes("ssh-rsa"));
                buf.putString(sig);
                return(buf.buffer);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(null);
        }
示例#2
0
        byte[] getSignature_rsa(byte[] data)
        {
            try
            {
                Type         c   = Type.GetType((string)JSch.getConfig("signature.rsa"));
                SignatureRSA rsa = (SignatureRSA)(c.newInstance());

                rsa.init();
                rsa.setPrvKey(d_array, n_array);

                rsa.update(data);
                byte[] sig = rsa.sign();
                Buffer buf = new Buffer("ssh-rsa".Length + 4 +
                                        sig.Length + 4);
                buf.putString("ssh-rsa".getBytes());
                buf.putString(sig);
                return(buf.buffer);
            }
            catch //(Exception e)
            {
            }
            return(null);
        }