mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-07 15:50:57 +03:00
sig/ reformat
This commit is contained in:
@@ -44,7 +44,8 @@ import java.security.PublicKey;
|
|||||||
import java.security.SignatureException;
|
import java.security.SignatureException;
|
||||||
|
|
||||||
/** An abstract class for {@link Signature} that implements common functionality. */
|
/** 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 java.security.Signature signature;
|
||||||
protected String algorithm;
|
protected String algorithm;
|
||||||
@@ -82,14 +83,14 @@ public abstract class AbstractSignature implements Signature {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
int j;
|
int j;
|
||||||
j = sig[i++] << 24 & 0xff000000 //
|
j = sig[i++] << 24 & 0xff000000 //
|
||||||
| sig[i++] << 16 & 0x00ff0000 //
|
| sig[i++] << 16 & 0x00ff0000 //
|
||||||
| sig[i++] << 8 & 0x0000ff00 //
|
| sig[i++] << 8 & 0x0000ff00 //
|
||||||
| sig[i++] & 0x000000ff;
|
| sig[i++] & 0x000000ff;
|
||||||
i += j;
|
i += j;
|
||||||
j = sig[i++] << 24 & 0xff000000 //
|
j = sig[i++] << 24 & 0xff000000 //
|
||||||
| sig[i++] << 16 & 0x00ff0000 //
|
| sig[i++] << 16 & 0x00ff0000 //
|
||||||
| sig[i++] << 8 & 0x0000ff00 //
|
| sig[i++] << 8 & 0x0000ff00 //
|
||||||
| sig[i++] & 0x000000ff;
|
| sig[i++] & 0x000000ff;
|
||||||
byte[] tmp = new byte[j];
|
byte[] tmp = new byte[j];
|
||||||
System.arraycopy(sig, i, tmp, 0, j);
|
System.arraycopy(sig, i, tmp, 0, j);
|
||||||
sig = tmp;
|
sig = tmp;
|
||||||
|
|||||||
@@ -41,10 +41,12 @@ import net.schmizz.sshj.common.SSHRuntimeException;
|
|||||||
import java.security.SignatureException;
|
import java.security.SignatureException;
|
||||||
|
|
||||||
/** DSA {@link Signature} */
|
/** DSA {@link Signature} */
|
||||||
public class SignatureDSA extends AbstractSignature {
|
public class SignatureDSA
|
||||||
|
extends AbstractSignature {
|
||||||
|
|
||||||
/** A named factory for DSA signature */
|
/** 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() {
|
public Signature create() {
|
||||||
return new SignatureDSA();
|
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
|
// 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
|
System.arraycopy(r,
|
||||||
: r.length);
|
r.length > 20 ? 1 : 0,
|
||||||
System.arraycopy(s, s.length > 20 ? 1 : 0, result, s.length > 20 ? 20 : 40 - s.length, s.length > 20 ? 20
|
result,
|
||||||
: s.length);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,10 +41,12 @@ import net.schmizz.sshj.common.SSHRuntimeException;
|
|||||||
import java.security.SignatureException;
|
import java.security.SignatureException;
|
||||||
|
|
||||||
/** RSA {@link Signature} */
|
/** RSA {@link Signature} */
|
||||||
public class SignatureRSA extends AbstractSignature {
|
public class SignatureRSA
|
||||||
|
extends AbstractSignature {
|
||||||
|
|
||||||
/** A named factory for RSA {@link Signature} */
|
/** 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() {
|
public Signature create() {
|
||||||
return new SignatureRSA();
|
return new SignatureRSA();
|
||||||
|
|||||||
Reference in New Issue
Block a user