sig/ reformat

This commit is contained in:
Shikhar Bhushan
2010-03-01 23:45:55 +01:00
parent 5335c282dc
commit f63d09969c
3 changed files with 26 additions and 15 deletions

View File

@@ -44,7 +44,8 @@ import java.security.PublicKey;
import java.security.SignatureException;
/** An abstract class for {@link Signature} that implements common functionality. */
public abstract class AbstractSignature implements Signature {
public abstract class AbstractSignature
implements Signature {
protected java.security.Signature signature;
protected String algorithm;
@@ -82,14 +83,14 @@ public abstract class AbstractSignature implements Signature {
int i = 0;
int j;
j = sig[i++] << 24 & 0xff000000 //
| sig[i++] << 16 & 0x00ff0000 //
| sig[i++] << 8 & 0x0000ff00 //
| sig[i++] & 0x000000ff;
| sig[i++] << 16 & 0x00ff0000 //
| sig[i++] << 8 & 0x0000ff00 //
| sig[i++] & 0x000000ff;
i += j;
j = sig[i++] << 24 & 0xff000000 //
| sig[i++] << 16 & 0x00ff0000 //
| sig[i++] << 8 & 0x0000ff00 //
| sig[i++] & 0x000000ff;
| sig[i++] << 16 & 0x00ff0000 //
| sig[i++] << 8 & 0x0000ff00 //
| sig[i++] & 0x000000ff;
byte[] tmp = new byte[j];
System.arraycopy(sig, i, tmp, 0, j);
sig = tmp;

View File

@@ -41,10 +41,12 @@ import net.schmizz.sshj.common.SSHRuntimeException;
import java.security.SignatureException;
/** DSA {@link Signature} */
public class SignatureDSA extends AbstractSignature {
public class SignatureDSA
extends AbstractSignature {
/** A named factory for DSA signature */
public static class Factory implements net.schmizz.sshj.common.Factory.Named<Signature> {
public static class Factory
implements net.schmizz.sshj.common.Factory.Named<Signature> {
public Signature create() {
return new SignatureDSA();
@@ -84,10 +86,16 @@ public class SignatureDSA extends AbstractSignature {
// result must be 40 bytes, but length of r and s may not be 20 bytes
System.arraycopy(r, r.length > 20 ? 1 : 0, result, r.length > 20 ? 0 : 20 - r.length, r.length > 20 ? 20
: r.length);
System.arraycopy(s, s.length > 20 ? 1 : 0, result, s.length > 20 ? 20 : 40 - s.length, s.length > 20 ? 20
: s.length);
System.arraycopy(r,
r.length > 20 ? 1 : 0,
result,
r.length > 20 ? 0 : 20 - r.length,
r.length > 20 ? 20 : r.length);
System.arraycopy(s,
s.length > 20 ? 1 : 0,
result,
s.length > 20 ? 20 : 40 - s.length,
s.length > 20 ? 20 : s.length);
return result;
}

View File

@@ -41,10 +41,12 @@ import net.schmizz.sshj.common.SSHRuntimeException;
import java.security.SignatureException;
/** RSA {@link Signature} */
public class SignatureRSA extends AbstractSignature {
public class SignatureRSA
extends AbstractSignature {
/** A named factory for RSA {@link Signature} */
public static class Factory implements net.schmizz.sshj.common.Factory.Named<Signature> {
public static class Factory
implements net.schmizz.sshj.common.Factory.Named<Signature> {
public Signature create() {
return new SignatureRSA();