本文整理汇总了Java中com.trilead.ssh2.packets.TypesWriter.getBytes方法的典型用法代码示例。如果您正苦于以下问题:Java TypesWriter.getBytes方法的具体用法?Java TypesWriter.getBytes怎么用?Java TypesWriter.getBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.trilead.ssh2.packets.TypesWriter
的用法示例。
在下文中一共展示了TypesWriter.getBytes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeSSHRSASignature
import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
public static byte[] encodeSSHRSASignature(byte[] s) throws IOException
{
TypesWriter tw = new TypesWriter();
tw.writeString("ssh-rsa");
/* S is NOT an MPINT. "The value for 'rsa_signature_blob' is encoded as a string
* containing s (which is an integer, without lengths or padding, unsigned and in
* network byte order)."
*/
/* Remove first zero sign byte, if present */
if ((s.length > 1) && (s[0] == 0x00))
tw.writeString(s, 1, s.length - 1);
else
tw.writeString(s, 0, s.length);
return tw.getBytes();
}
示例2: encodeSSHRSASignature
import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
public static byte[] encodeSSHRSASignature(RSASignature sig) throws IOException
{
TypesWriter tw = new TypesWriter();
tw.writeString("ssh-rsa");
/* S is NOT an MPINT. "The value for 'rsa_signature_blob' is encoded as a string
* containing s (which is an integer, without lengths or padding, unsigned and in
* network byte order)."
*/
byte[] s = sig.getS().toByteArray();
/* Remove first zero sign byte, if present */
if ((s.length > 1) && (s[0] == 0x00))
tw.writeString(s, 1, s.length - 1);
else
tw.writeString(s, 0, s.length);
return tw.getBytes();
}
示例3: encodeSSHRSASignature
import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
public static byte[] encodeSSHRSASignature(RSASignature sig)
throws IOException {
TypesWriter tw = new TypesWriter();
tw.writeString("ssh-rsa");
/*
* S is NOT an MPINT. "The value for 'rsa_signature_blob' is encoded as
* a string containing s (which is an integer, without lengths or
* padding, unsigned and in network byte order)."
*/
byte[] s = sig.getS().toByteArray();
/* Remove first zero sign byte, if present */
if ((s.length > 1) && (s[0] == 0x00))
tw.writeString(s, 1, s.length - 1);
else
tw.writeString(s, 0, s.length);
return tw.getBytes();
}
示例4: encodeSSHDSAPublicKey
import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
public static byte[] encodeSSHDSAPublicKey(DSAPublicKey pk) throws IOException
{
TypesWriter tw = new TypesWriter();
tw.writeString("ssh-dss");
DSAParams params = pk.getParams();
tw.writeMPInt(params.getP());
tw.writeMPInt(params.getQ());
tw.writeMPInt(params.getG());
tw.writeMPInt(pk.getY());
return tw.getBytes();
}
示例5: encodeSSHDSASignature
import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
/**
* Convert from Java's signature ASN.1 encoding to the SSH spec.
* <p>
* Java ASN.1 encoding:
* <pre>
* SEQUENCE ::= {
* r INTEGER,
* s INTEGER
* }
* </pre>
*/
public static byte[] encodeSSHDSASignature(byte[] ds)
{
TypesWriter tw = new TypesWriter();
tw.writeString("ssh-dss");
int len, index;
index = 3;
len = ds[index++] & 0xff;
byte[] r = new byte[len];
System.arraycopy(ds, index, r, 0, r.length);
index = index + len + 1;
len = ds[index++] & 0xff;
byte[] s = new byte[len];
System.arraycopy(ds, index, s, 0, s.length);
byte[] a40 = new byte[40];
/* Patch (unsigned) r and s into the target array. */
int r_copylen = (r.length < 20) ? r.length : 20;
int s_copylen = (s.length < 20) ? s.length : 20;
System.arraycopy(r, r.length - r_copylen, a40, 20 - r_copylen, r_copylen);
System.arraycopy(s, s.length - s_copylen, a40, 40 - s_copylen, s_copylen);
tw.writeString(a40, 0, 40);
return tw.getBytes();
}
示例6: encodeSSHRSAPublicKey
import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
public static byte[] encodeSSHRSAPublicKey(RSAPublicKey pk) throws IOException
{
TypesWriter tw = new TypesWriter();
tw.writeString("ssh-rsa");
tw.writeMPInt(pk.getPublicExponent());
tw.writeMPInt(pk.getModulus());
return tw.getBytes();
}
示例7: encodeSSHECDSASignature
import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
public static byte[] encodeSSHECDSASignature(byte[] sig, ECParameterSpec params) throws IOException
{
TypesWriter tw = new TypesWriter();
String curveName = getCurveName(params);
tw.writeString(ECDSA_SHA2_PREFIX + curveName);
if ((sig[0] != 0x30) || (sig[1] != sig.length - 2) || (sig[2] != 0x02)) {
throw new IOException("Invalid signature format");
}
int rLength = sig[3];
if ((rLength + 6 > sig.length) || (sig[4 + rLength] != 0x02)) {
throw new IOException("Invalid signature format");
}
int sLength = sig[5 + rLength];
if (6 + rLength + sLength > sig.length) {
throw new IOException("Invalid signature format");
}
byte[] rArray = new byte[rLength];
byte[] sArray = new byte[sLength];
System.arraycopy(sig, 4, rArray, 0, rLength);
System.arraycopy(sig, 6 + rLength, sArray, 0, sLength);
BigInteger r = new BigInteger(rArray);
BigInteger s = new BigInteger(sArray);
// Write the <r,s> to its own types writer.
TypesWriter rsWriter = new TypesWriter();
rsWriter.writeMPInt(r);
rsWriter.writeMPInt(s);
byte[] encoded = rsWriter.getBytes();
tw.writeString(encoded, 0, encoded.length);
return tw.getBytes();
}
示例8: encodeSSHDSAPublicKey
import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
public static byte[] encodeSSHDSAPublicKey(DSAPublicKey pk) throws IOException
{
TypesWriter tw = new TypesWriter();
tw.writeString("ssh-dss");
tw.writeMPInt(pk.getP());
tw.writeMPInt(pk.getQ());
tw.writeMPInt(pk.getG());
tw.writeMPInt(pk.getY());
return tw.getBytes();
}
示例9: encodeSSHRSAPublicKey
import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
public static byte[] encodeSSHRSAPublicKey(RSAPublicKey pk) throws IOException
{
TypesWriter tw = new TypesWriter();
tw.writeString("ssh-rsa");
tw.writeMPInt(pk.getE());
tw.writeMPInt(pk.getN());
return tw.getBytes();
}
示例10: encodeSSHDSAPublicKey
import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
public static byte[] encodeSSHDSAPublicKey(DSAPublicKey pk)
throws IOException {
TypesWriter tw = new TypesWriter();
tw.writeString("ssh-dss");
tw.writeMPInt(pk.getP());
tw.writeMPInt(pk.getQ());
tw.writeMPInt(pk.getG());
tw.writeMPInt(pk.getY());
return tw.getBytes();
}
示例11: encodeSSHRSAPublicKey
import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
public static byte[] encodeSSHRSAPublicKey(RSAPublicKey pk)
throws IOException {
TypesWriter tw = new TypesWriter();
tw.writeString("ssh-rsa");
tw.writeMPInt(pk.getE());
tw.writeMPInt(pk.getN());
return tw.getBytes();
}
示例12: encodeSSHECDSAPublicKey
import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
public static byte[] encodeSSHECDSAPublicKey(ECPublicKey key) throws IOException {
TypesWriter tw = new TypesWriter();
String curveName = getCurveName(key.getParams());
String keyFormat = ECDSA_SHA2_PREFIX + curveName;
tw.writeString(keyFormat);
tw.writeString(curveName);
byte[] encoded = encodeECPoint(key.getW(), key.getParams().getCurve());
tw.writeString(encoded, 0, encoded.length);
return tw.getBytes();
}
示例13: createAttrs
import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
private byte[] createAttrs(SFTPv3FileAttributes attr)
{
TypesWriter tw = new TypesWriter();
int attrFlags = 0;
if (attr == null)
{
tw.writeUINT32(0);
}
else
{
if (attr.size != null)
attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_SIZE;
if ((attr.uid != null) && (attr.gid != null))
attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_V3_UIDGID;
if (attr.permissions != null)
attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_PERMISSIONS;
if ((attr.atime != null) && (attr.mtime != null))
attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_V3_ACMODTIME;
tw.writeUINT32(attrFlags);
if (attr.size != null)
tw.writeUINT64(attr.size.longValue());
if ((attr.uid != null) && (attr.gid != null))
{
tw.writeUINT32(attr.uid.intValue());
tw.writeUINT32(attr.gid.intValue());
}
if (attr.permissions != null)
tw.writeUINT32(attr.permissions.intValue());
if ((attr.atime != null) && (attr.mtime != null))
{
tw.writeUINT32(attr.atime.intValue());
tw.writeUINT32(attr.mtime.intValue());
}
}
return tw.getBytes();
}
示例14: encodeSSHDSASignature
import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
public static byte[] encodeSSHDSASignature(DSASignature ds)
{
TypesWriter tw = new TypesWriter();
tw.writeString("ssh-dss");
byte[] r = ds.getR().toByteArray();
byte[] s = ds.getS().toByteArray();
byte[] a40 = new byte[40];
/* Patch (unsigned) r and s into the target array. */
int r_copylen = (r.length < 20) ? r.length : 20;
int s_copylen = (s.length < 20) ? s.length : 20;
System.arraycopy(r, r.length - r_copylen, a40, 20 - r_copylen, r_copylen);
System.arraycopy(s, s.length - s_copylen, a40, 40 - s_copylen, s_copylen);
tw.writeString(a40, 0, 40);
return tw.getBytes();
}
示例15: encodeSSHDSASignature
import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
public static byte[] encodeSSHDSASignature(DSASignature ds) {
TypesWriter tw = new TypesWriter();
tw.writeString("ssh-dss");
byte[] r = ds.getR().toByteArray();
byte[] s = ds.getS().toByteArray();
byte[] a40 = new byte[40];
/* Patch (unsigned) r and s into the target array. */
int r_copylen = (r.length < 20) ? r.length : 20;
int s_copylen = (s.length < 20) ? s.length : 20;
System.arraycopy(r, r.length - r_copylen, a40, 20 - r_copylen,
r_copylen);
System.arraycopy(s, s.length - s_copylen, a40, 40 - s_copylen,
s_copylen);
tw.writeString(a40, 0, 40);
return tw.getBytes();
}