Okay, more spaces Codacy, you win!

This commit is contained in:
David Solin
2016-09-09 16:03:45 -05:00
parent 68b924863e
commit e420593fa9
2 changed files with 34 additions and 34 deletions

View File

@@ -427,16 +427,16 @@ public class Buffer<T extends Buffer<T>> {
throws BufferException { throws BufferException {
try { try {
final KeyType type = KeyType.fromString(readString()); final KeyType type = KeyType.fromString(readString());
switch(type) { switch (type) {
case RSA: case RSA:
case DSA: case DSA:
return type.readPubKeyFromBuffer(this);
default:
if (SecurityUtils.isBouncyCastleRegistered()) {
return type.readPubKeyFromBuffer(this); return type.readPubKeyFromBuffer(this);
} else { default:
throw new BufferException("BouncyCastle is required to read a key of type " + type); if (SecurityUtils.isBouncyCastleRegistered()) {
} return type.readPubKeyFromBuffer(this);
} else {
throw new BufferException("BouncyCastle is required to read a key of type " + type);
}
} }
} catch (GeneralSecurityException e) { } catch (GeneralSecurityException e) {
throw new SSHRuntimeException(e); throw new SSHRuntimeException(e);

View File

@@ -194,31 +194,31 @@ public class PKCS5KeyFile
throw new FormatException("PKCS5 header not found"); throw new FormatException("PKCS5 header not found");
} }
ASN1Data asn = new ASN1Data(data = decrypt(Base64.decode(sb.toString()), cipher, iv)); ASN1Data asn = new ASN1Data(data = decrypt(Base64.decode(sb.toString()), cipher, iv));
switch(type) { switch (type) {
case RSA: { case RSA: {
KeyFactory factory = KeyFactory.getInstance("RSA"); KeyFactory factory = KeyFactory.getInstance("RSA");
asn.readNext(); asn.readNext();
BigInteger modulus = asn.readNext(); BigInteger modulus = asn.readNext();
BigInteger pubExp = asn.readNext(); BigInteger pubExp = asn.readNext();
BigInteger prvExp = asn.readNext(); BigInteger prvExp = asn.readNext();
PublicKey pubKey = factory.generatePublic(new RSAPublicKeySpec(modulus, pubExp)); PublicKey pubKey = factory.generatePublic(new RSAPublicKeySpec(modulus, pubExp));
PrivateKey prvKey = factory.generatePrivate(new RSAPrivateKeySpec(modulus, prvExp)); PrivateKey prvKey = factory.generatePrivate(new RSAPrivateKeySpec(modulus, prvExp));
return new KeyPair(pubKey, prvKey); return new KeyPair(pubKey, prvKey);
} }
case DSA: { case DSA: {
KeyFactory factory = KeyFactory.getInstance("DSA"); KeyFactory factory = KeyFactory.getInstance("DSA");
asn.readNext(); asn.readNext();
BigInteger p = asn.readNext(); BigInteger p = asn.readNext();
BigInteger q = asn.readNext(); BigInteger q = asn.readNext();
BigInteger g = asn.readNext(); BigInteger g = asn.readNext();
BigInteger pub = asn.readNext(); BigInteger pub = asn.readNext();
BigInteger prv = asn.readNext(); BigInteger prv = asn.readNext();
PublicKey pubKey = factory.generatePublic(new DSAPublicKeySpec(pub, p, q, g)); PublicKey pubKey = factory.generatePublic(new DSAPublicKeySpec(pub, p, q, g));
PrivateKey prvKey = factory.generatePrivate(new DSAPrivateKeySpec(prv, p, q, g)); PrivateKey prvKey = factory.generatePrivate(new DSAPrivateKeySpec(prv, p, q, g));
return new KeyPair(pubKey, prvKey); return new KeyPair(pubKey, prvKey);
} }
default: default:
throw new IOException("Unrecognized PKCS5 key type: " + type); throw new IOException("Unrecognized PKCS5 key type: " + type);
} }
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
throw new IOException(e); throw new IOException(e);