예제 #1
0
        byte[] getSignature_rsa(Session session, byte[] data)
        {
            try
            {
                //Type t=Type.GetType(jsch.getConfig("signature.rsa"));
                //SignatureRSA rsa=(SignatureRSA)Activator.CreateInstance(t);
                ISignatureRSA rsa = new Tamir.SharpSsh.jsch.jce.SignatureRSA();

                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
 public byte[] getSignature(Session session, byte[] data)
 {
     try
     {
         SignatureRSA rsa = new Tamir.SharpSsh.jsch.jce.SignatureRSA();
         rsa.init();
         rsa.setPrvKey(_e_array, _n_array, _d_array, _p_array, _q_array, _dmp1_array, _dmq1_array, _iqmp_array);
         rsa.update(data);
         byte[] sig = rsa.sign();
         Buffer buf = new Buffer(ALGORITHM_NAME.Length + 4 + sig.Length + 4);
         buf.putString(System.Text.Encoding.Default.GetBytes(ALGORITHM_NAME));
         buf.putString(sig);
         return(buf.buffer);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
     return(null);
 }
예제 #3
0
        public static void testSig()
        {
            byte[] hash = Util.getBytes("Tamir");
            Tamir.SharpSsh.jsch.jce.SignatureRSA  enc_rsa = new Tamir.SharpSsh.jsch.jce.SignatureRSA();
            Tamir.SharpSsh.jsch.jce.SignatureRSA  dec_rsa = new Tamir.SharpSsh.jsch.jce.SignatureRSA();
            Tamir.SharpSsh.jsch.jce.KeyPairGenRSA gen     = new Tamir.SharpSsh.jsch.jce.KeyPairGenRSA();
            gen.init(512);

            enc_rsa.init();
            enc_rsa.setPrvKey(gen.KeyInfo);
            enc_rsa.update(hash);
            byte[] sig = enc_rsa.sign();

            dump(gen.getE(), gen.getN(), sig, hash);

            dec_rsa.init();
            dec_rsa.setPubKey(gen.getE(), gen.getN());
            dec_rsa.update(hash);



            Console.WriteLine(dec_rsa.verify(sig));
        }
예제 #4
0
파일: Main.cs 프로젝트: stux2000/dokan
		public static void testSig()
		{
			byte[] hash = Util.getBytes( "Tamir" );
			Tamir.SharpSsh.jsch.jce.SignatureRSA enc_rsa = new Tamir.SharpSsh.jsch.jce.SignatureRSA();
			Tamir.SharpSsh.jsch.jce.SignatureRSA dec_rsa = new Tamir.SharpSsh.jsch.jce.SignatureRSA();
			Tamir.SharpSsh.jsch.jce.KeyPairGenRSA gen = new Tamir.SharpSsh.jsch.jce.KeyPairGenRSA();
			gen.init(512);
			
			enc_rsa.init();
			enc_rsa.setPrvKey(gen.KeyInfo);
			enc_rsa.update(hash);
			byte[] sig = enc_rsa.sign();

			dump(gen.getE(), gen.getN(), sig, hash);

			dec_rsa.init();
			dec_rsa.setPubKey(gen.getE(), gen.getN());
			dec_rsa.update(hash);
			
			

			Console.WriteLine( dec_rsa.verify(sig) );
		}