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 {
try {
final KeyType type = KeyType.fromString(readString());
switch(type) {
case RSA:
case DSA:
return type.readPubKeyFromBuffer(this);
default:
if (SecurityUtils.isBouncyCastleRegistered()) {
switch (type) {
case RSA:
case DSA:
return type.readPubKeyFromBuffer(this);
} else {
throw new BufferException("BouncyCastle is required to read a key of type " + type);
}
default:
if (SecurityUtils.isBouncyCastleRegistered()) {
return type.readPubKeyFromBuffer(this);
} else {
throw new BufferException("BouncyCastle is required to read a key of type " + type);
}
}
} catch (GeneralSecurityException e) {
throw new SSHRuntimeException(e);

View File

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