mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 23:30:55 +03:00
- Some more indentation fixes
This commit is contained in:
@@ -82,7 +82,7 @@ public class ECDSAVariationsAdapter {
|
|||||||
byte[] encoded = SecgUtils.getEncoded(ecdsa.getW(), ecdsa.getParams().getCurve());
|
byte[] encoded = SecgUtils.getEncoded(ecdsa.getW(), ecdsa.getParams().getCurve());
|
||||||
|
|
||||||
buf.putString(Integer.toString(fieldSizeFromKey(ecdsa)))
|
buf.putString(Integer.toString(fieldSizeFromKey(ecdsa)))
|
||||||
.putBytes(encoded);
|
.putBytes(encoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int fieldSizeFromKey(ECPublicKey ecPublicKey) {
|
public static int fieldSizeFromKey(ECPublicKey ecPublicKey) {
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public enum KeyType {
|
|||||||
protected void writePubKeyContentsIntoBuffer(PublicKey pk, Buffer<?> buf) {
|
protected void writePubKeyContentsIntoBuffer(PublicKey pk, Buffer<?> buf) {
|
||||||
final RSAPublicKey rsaKey = (RSAPublicKey) pk;
|
final RSAPublicKey rsaKey = (RSAPublicKey) pk;
|
||||||
buf.putMPInt(rsaKey.getPublicExponent()) // e
|
buf.putMPInt(rsaKey.getPublicExponent()) // e
|
||||||
.putMPInt(rsaKey.getModulus()); // n
|
.putMPInt(rsaKey.getModulus()); // n
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -101,9 +101,9 @@ public enum KeyType {
|
|||||||
protected void writePubKeyContentsIntoBuffer(PublicKey pk, Buffer<?> buf) {
|
protected void writePubKeyContentsIntoBuffer(PublicKey pk, Buffer<?> buf) {
|
||||||
final DSAPublicKey dsaKey = (DSAPublicKey) pk;
|
final DSAPublicKey dsaKey = (DSAPublicKey) pk;
|
||||||
buf.putMPInt(dsaKey.getParams().getP()) // p
|
buf.putMPInt(dsaKey.getParams().getP()) // p
|
||||||
.putMPInt(dsaKey.getParams().getQ()) // q
|
.putMPInt(dsaKey.getParams().getQ()) // q
|
||||||
.putMPInt(dsaKey.getParams().getG()) // g
|
.putMPInt(dsaKey.getParams().getG()) // g
|
||||||
.putMPInt(dsaKey.getY()); // y
|
.putMPInt(dsaKey.getY()); // y
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -119,7 +119,7 @@ public enum KeyType {
|
|||||||
@Override
|
@Override
|
||||||
public PublicKey readPubKeyFromBuffer(Buffer<?> buf)
|
public PublicKey readPubKeyFromBuffer(Buffer<?> buf)
|
||||||
throws GeneralSecurityException {
|
throws GeneralSecurityException {
|
||||||
return ECDSAVariationsAdapter.readPubKeyFromBuffer(buf, "256");
|
return ECDSAVariationsAdapter.readPubKeyFromBuffer(buf, "256");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -136,11 +136,11 @@ public enum KeyType {
|
|||||||
|
|
||||||
/** SSH identifier for ECDSA-384 keys */
|
/** SSH identifier for ECDSA-384 keys */
|
||||||
ECDSA384("ecdsa-sha2-nistp384") {
|
ECDSA384("ecdsa-sha2-nistp384") {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PublicKey readPubKeyFromBuffer(Buffer<?> buf)
|
public PublicKey readPubKeyFromBuffer(Buffer<?> buf)
|
||||||
throws GeneralSecurityException {
|
throws GeneralSecurityException {
|
||||||
return ECDSAVariationsAdapter.readPubKeyFromBuffer(buf, "384");
|
return ECDSAVariationsAdapter.readPubKeyFromBuffer(buf, "384");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -157,11 +157,11 @@ public enum KeyType {
|
|||||||
|
|
||||||
/** SSH identifier for ECDSA-521 keys */
|
/** SSH identifier for ECDSA-521 keys */
|
||||||
ECDSA521("ecdsa-sha2-nistp521") {
|
ECDSA521("ecdsa-sha2-nistp521") {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PublicKey readPubKeyFromBuffer(Buffer<?> buf)
|
public PublicKey readPubKeyFromBuffer(Buffer<?> buf)
|
||||||
throws GeneralSecurityException {
|
throws GeneralSecurityException {
|
||||||
return ECDSAVariationsAdapter.readPubKeyFromBuffer(buf, "521");
|
return ECDSAVariationsAdapter.readPubKeyFromBuffer(buf, "521");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ public enum KeyType {
|
|||||||
return ("ECDSA".equals(key.getAlgorithm()) && ECDSAVariationsAdapter.fieldSizeFromKey((ECPublicKey) key) == 521);
|
return ("ECDSA".equals(key.getAlgorithm()) && ECDSAVariationsAdapter.fieldSizeFromKey((ECPublicKey) key) == 521);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
ED25519("ssh-ed25519") {
|
ED25519("ssh-ed25519") {
|
||||||
private final Logger log = LoggerFactory.getLogger(KeyType.class);
|
private final Logger log = LoggerFactory.getLogger(KeyType.class);
|
||||||
@Override
|
@Override
|
||||||
@@ -189,7 +189,7 @@ public enum KeyType {
|
|||||||
sType,
|
sType,
|
||||||
keyLen,
|
keyLen,
|
||||||
Arrays.toString(p))
|
Arrays.toString(p))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
EdDSANamedCurveSpec ed25519 = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.CURVE_ED25519_SHA512);
|
EdDSANamedCurveSpec ed25519 = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.CURVE_ED25519_SHA512);
|
||||||
@@ -343,16 +343,16 @@ public enum KeyType {
|
|||||||
buf.putBytes(certificate.getNonce());
|
buf.putBytes(certificate.getNonce());
|
||||||
innerKeyType.writePubKeyContentsIntoBuffer(certificate.getKey(), buf);
|
innerKeyType.writePubKeyContentsIntoBuffer(certificate.getKey(), buf);
|
||||||
buf.putUInt64(certificate.getSerial())
|
buf.putUInt64(certificate.getSerial())
|
||||||
.putUInt32(certificate.getType())
|
.putUInt32(certificate.getType())
|
||||||
.putString(certificate.getId())
|
.putString(certificate.getId())
|
||||||
.putBytes(packList(certificate.getValidPrincipals()))
|
.putBytes(packList(certificate.getValidPrincipals()))
|
||||||
.putUInt64(epochFromDate(certificate.getValidAfter()))
|
.putUInt64(epochFromDate(certificate.getValidAfter()))
|
||||||
.putUInt64(epochFromDate(certificate.getValidBefore()))
|
.putUInt64(epochFromDate(certificate.getValidBefore()))
|
||||||
.putBytes(packMap(certificate.getCritOptions()))
|
.putBytes(packMap(certificate.getCritOptions()))
|
||||||
.putBytes(packMap(certificate.getExtensions()))
|
.putBytes(packMap(certificate.getExtensions()))
|
||||||
.putString("") // reserved
|
.putString("") // reserved
|
||||||
.putBytes(certificate.getSignatureKey())
|
.putBytes(certificate.getSignatureKey())
|
||||||
.putBytes(certificate.getSignature());
|
.putBytes(certificate.getSignature());
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isCertificateOfType(Key key, KeyType innerKeyType) {
|
static boolean isCertificateOfType(Key key, KeyType innerKeyType) {
|
||||||
@@ -368,11 +368,11 @@ public enum KeyType {
|
|||||||
static Certificate<PublicKey> toCertificate(PublicKey key) {
|
static Certificate<PublicKey> toCertificate(PublicKey key) {
|
||||||
if (!(key instanceof Certificate)) {
|
if (!(key instanceof Certificate)) {
|
||||||
throw new UnsupportedOperationException("Can't convert non-certificate key " +
|
throw new UnsupportedOperationException("Can't convert non-certificate key " +
|
||||||
key.getAlgorithm() + " to certificate");
|
key.getAlgorithm() + " to certificate");
|
||||||
}
|
}
|
||||||
return ((Certificate<PublicKey>) key);
|
return ((Certificate<PublicKey>) key);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Date dateFromEpoch(long seconds) {
|
private static Date dateFromEpoch(long seconds) {
|
||||||
return new Date(seconds * 1000);
|
return new Date(seconds * 1000);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user