use of org.bouncycastle.pqc.jcajce.provider.mceliece.BCMcElieceCCA2PublicKey in project smoke by textbrowser.
the class Cryptography method fancyKeyInformationOutput.
public String fancyKeyInformationOutput(KeyPair keyPair) {
if (keyPair == null || keyPair.getPublic() == null)
return "";
PublicKey publicKey = keyPair.getPublic();
String algorithm = publicKey.getAlgorithm();
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Algorithm: ");
stringBuilder.append(algorithm);
stringBuilder.append("\n");
stringBuilder.append("Fingerprint: ");
stringBuilder.append(publicKeyFingerPrint(publicKey));
stringBuilder.append("\n");
stringBuilder.append("Format: ");
stringBuilder.append(publicKey.getFormat());
if (algorithm.equals("EC") || algorithm.equals("McEliece-CCA2") || algorithm.equals("RSA"))
try {
if (algorithm.equals("EC")) {
ECPublicKey ecPublicKey = (ECPublicKey) publicKey;
if (ecPublicKey != null)
stringBuilder.append("\n").append("Size: ").append(ecPublicKey.getW().getAffineX().bitLength());
} else if (algorithm.equals("McEliece-CCA2")) {
BCMcElieceCCA2PublicKey mcEliecePublicKey = (BCMcElieceCCA2PublicKey) publicKey;
if (mcEliecePublicKey != null)
stringBuilder.append("\n").append("m = ").append((int) (Math.log(mcEliecePublicKey.getN()) / Math.log(2))).append(", t = ").append(mcEliecePublicKey.getT());
} else if (algorithm.equals("RSA")) {
RSAPublicKey rsaPublicKey = (RSAPublicKey) publicKey;
if (rsaPublicKey != null)
stringBuilder.append("\n").append("Size: ").append(rsaPublicKey.getModulus().bitLength());
}
} catch (Exception exception) {
}
return stringBuilder.toString();
}
Aggregations