static KeyPair fromSSHAgent(JSch jsch, Buffer buf) throws JSchException { byte[][] tmp = buf.getBytes(8, "invalid key format"); byte[] n_array = tmp[1]; byte[] pub_array = tmp[2]; byte[] prv_array = tmp[3]; KeyPairRSA kpair = new KeyPairRSA(jsch, n_array, pub_array, prv_array); kpair.c_array = tmp[4]; // iqmp kpair.p_array = tmp[5]; kpair.q_array = tmp[6]; kpair.publicKeyComment = new String(tmp[7]); kpair.vendor=VENDOR_OPENSSH; return kpair; }
byte[] getPrivateKey(){ int content= 1+countLength(1) + 1 + // INTEGER 1+countLength(n_array.length) + n_array.length + // INTEGER N 1+countLength(pub_array.length) + pub_array.length + // INTEGER pub 1+countLength(prv_array.length) + prv_array.length+ // INTEGER prv 1+countLength(p_array.length) + p_array.length+ // INTEGER p 1+countLength(q_array.length) + q_array.length+ // INTEGER q 1+countLength(ep_array.length) + ep_array.length+ // INTEGER ep 1+countLength(eq_array.length) + eq_array.length+ // INTEGER eq 1+countLength(c_array.length) + c_array.length; // INTEGER c int total= 1+countLength(content)+content; // SEQUENCE byte[] plain=new byte[total]; int index=0; index=writeSEQUENCE(plain, index, content); index=writeINTEGER(plain, index, new byte[1]); // 0 index=writeINTEGER(plain, index, n_array); index=writeINTEGER(plain, index, pub_array); index=writeINTEGER(plain, index, prv_array); index=writeINTEGER(plain, index, p_array); index=writeINTEGER(plain, index, q_array); index=writeINTEGER(plain, index, ep_array); index=writeINTEGER(plain, index, eq_array); index=writeINTEGER(plain, index, c_array); return plain; }
getEPArray(); getEQArray(); getEPArray(); getEQArray(); getCArray();
kpair=KeyPairRSA.fromSSHAgent(jsch, buf); else if(type==RSA){ kpair=new KeyPairRSA(jsch); } else if(type==ECDSA){ kpair=new KeyPairECDSA(jsch, pubkey); } else if(vendor==VENDOR_PKCS8){ kpair = new KeyPairPKCS8(jsch); }
public byte[] forSSHAgent() throws JSchException { if (isEncrypted()) { throw new JSchException("key is encrypted."); } Buffer buf = new Buffer(); buf.putString(sshrsa); buf.putString(n_array); buf.putString(pub_array); buf.putString(prv_array); buf.putString(getCArray()); buf.putString(p_array); buf.putString(q_array); buf.putString(Util.str2byte(publicKeyComment)); byte[] result = new byte[buf.getLength()]; buf.getByte(result, 0, result.length); return result; }
public Signature getVerifier() { try { Class<?> c = Class.forName(JSch.getConfig("signature.rsa")); SignatureRSA rsa = (SignatureRSA) (c.newInstance()); rsa.init(); if (pub_array == null && n_array == null && getPublicKeyBlob() != null) { Buffer buf = new Buffer(getPublicKeyBlob()); buf.getString(); pub_array = buf.getString(); n_array = buf.getString(); } rsa.setPubKey(pub_array, n_array); return rsa; } catch (Exception e) { } return null; }
getEPArray(); getEQArray(); getEPArray(); getEQArray(); getCArray();
kpair=KeyPairRSA.fromSSHAgent(jsch, buf); else if(type==RSA){ kpair=new KeyPairRSA(jsch); } else if(type==ECDSA){ kpair=new KeyPairECDSA(jsch); } else if(vendor==VENDOR_PKCS8){ kpair = new KeyPairPKCS8(jsch); }
public byte[] forSSHAgent() throws JSchException { if(isEncrypted()){ throw new JSchException("key is encrypted."); } Buffer buf = new Buffer(); buf.putString(sshrsa); buf.putString(n_array); buf.putString(pub_array); buf.putString(prv_array); buf.putString(getCArray()); buf.putString(p_array); buf.putString(q_array); buf.putString(Util.str2byte(publicKeyComment)); byte[] result = new byte[buf.getLength()]; buf.getByte(result, 0, result.length); return result; }
public Signature getVerifier(){ try{ Class c=Class.forName((String)jsch.getConfig("signature.rsa")); SignatureRSA rsa=(SignatureRSA)(c.newInstance()); rsa.init(); if(pub_array == null && n_array == null && getPublicKeyBlob()!=null){ Buffer buf = new Buffer(getPublicKeyBlob()); buf.getString(); pub_array = buf.getString(); n_array = buf.getString(); } rsa.setPubKey(pub_array, n_array); return rsa; } catch(Exception e){ } return null; }
byte[] getPrivateKey(){ int content= 1+countLength(1) + 1 + // INTEGER 1+countLength(n_array.length) + n_array.length + // INTEGER N 1+countLength(pub_array.length) + pub_array.length + // INTEGER pub 1+countLength(prv_array.length) + prv_array.length+ // INTEGER prv 1+countLength(p_array.length) + p_array.length+ // INTEGER p 1+countLength(q_array.length) + q_array.length+ // INTEGER q 1+countLength(ep_array.length) + ep_array.length+ // INTEGER ep 1+countLength(eq_array.length) + eq_array.length+ // INTEGER eq 1+countLength(c_array.length) + c_array.length; // INTEGER c int total= 1+countLength(content)+content; // SEQUENCE byte[] plain=new byte[total]; int index=0; index=writeSEQUENCE(plain, index, content); index=writeINTEGER(plain, index, new byte[1]); // 0 index=writeINTEGER(plain, index, n_array); index=writeINTEGER(plain, index, pub_array); index=writeINTEGER(plain, index, prv_array); index=writeINTEGER(plain, index, p_array); index=writeINTEGER(plain, index, q_array); index=writeINTEGER(plain, index, ep_array); index=writeINTEGER(plain, index, eq_array); index=writeINTEGER(plain, index, c_array); return plain; }
static KeyPair fromSSHAgent(JSch jsch, Buffer buf) throws JSchException { byte[][] tmp = buf.getBytes(8, "invalid key format"); byte[] n_array = tmp[1]; byte[] pub_array = tmp[2]; byte[] prv_array = tmp[3]; KeyPairRSA kpair = new KeyPairRSA(jsch, n_array, pub_array, prv_array); kpair.c_array = tmp[4]; // iqmp kpair.p_array = tmp[5]; kpair.q_array = tmp[6]; kpair.publicKeyComment = new String(tmp[7]); kpair.vendor=VENDOR_OPENSSH; return kpair; }
getEPArray(); getEQArray(); getEPArray(); getEQArray(); getCArray();
kpair=KeyPairRSA.fromSSHAgent(jsch, buf); else if(type==RSA){ kpair=new KeyPairRSA(jsch); } else if(type==ECDSA){ kpair=new KeyPairECDSA(jsch); } else if(vendor==VENDOR_PKCS8){ kpair = new KeyPairPKCS8(jsch); }
public byte[] forSSHAgent() throws JSchException { if(isEncrypted()){ throw new JSchException("key is encrypted."); } Buffer buf = new Buffer(); buf.putString(sshrsa); buf.putString(n_array); buf.putString(pub_array); buf.putString(prv_array); buf.putString(getCArray()); buf.putString(p_array); buf.putString(q_array); buf.putString(Util.str2byte(publicKeyComment)); byte[] result = new byte[buf.getLength()]; buf.getByte(result, 0, result.length); return result; }
public Signature getVerifier(){ try{ Class c=Class.forName((String)jsch.getConfig("signature.rsa")); SignatureRSA rsa=(SignatureRSA)(c.newInstance()); rsa.init(); if(pub_array == null && n_array == null && getPublicKeyBlob()!=null){ Buffer buf = new Buffer(getPublicKeyBlob()); buf.getString(); pub_array = buf.getString(); n_array = buf.getString(); } rsa.setPubKey(pub_array, n_array); return rsa; } catch(Exception e){ } return null; }
byte[] getPrivateKey() { int content = 1 + countLength(1) + 1 + // INTEGER 1 + countLength(n_array.length) + n_array.length + // INTEGER N 1 + countLength(pub_array.length) + pub_array.length + // INTEGER pub 1 + countLength(prv_array.length) + prv_array.length + // INTEGER prv 1 + countLength(p_array.length) + p_array.length + // INTEGER p 1 + countLength(q_array.length) + q_array.length + // INTEGER q 1 + countLength(ep_array.length) + ep_array.length + // INTEGER ep 1 + countLength(eq_array.length) + eq_array.length + // INTEGER eq 1 + countLength(c_array.length) + c_array.length; // INTEGER c int total = 1 + countLength(content) + content; // SEQUENCE byte[] plain = new byte[total]; int index = 0; index = writeSEQUENCE(plain, index, content); index = writeINTEGER(plain, index, new byte[1]); // 0 index = writeINTEGER(plain, index, n_array); index = writeINTEGER(plain, index, pub_array); index = writeINTEGER(plain, index, prv_array); index = writeINTEGER(plain, index, p_array); index = writeINTEGER(plain, index, q_array); index = writeINTEGER(plain, index, ep_array); index = writeINTEGER(plain, index, eq_array); index = writeINTEGER(plain, index, c_array); return plain; }
static KeyPair fromSSHAgent(Buffer buf) throws JSchException { byte[][] tmp = buf.getBytes(8, "invalid key format"); byte[] n_array = tmp[1]; byte[] pub_array = tmp[2]; byte[] prv_array = tmp[3]; KeyPairRSA kpair = new KeyPairRSA(n_array, pub_array, prv_array); kpair.c_array = tmp[4]; // iqmp kpair.p_array = tmp[5]; kpair.q_array = tmp[6]; kpair.publicKeyComment = new String(tmp[7]); kpair.vendor = VENDOR_OPENSSH; return kpair; }
getEPArray(); getEQArray(); getEPArray(); getEQArray(); getCArray();
kpair = KeyPairRSA.fromSSHAgent(buf); } else if (_type.equals("ssh-dss")) { kpair = KeyPairDSA.fromSSHAgent(buf); kpair = new KeyPairDSA(); } else if (type == RSA) { kpair = new KeyPairRSA(); } else if (type == ECDSA) { kpair = new KeyPairECDSA();