privatestaticfinal Test[] tests = { new Test(SigAlg.SHA1withDSA, KeyAlg.DSA, Provider.Default, 1024), new Test(SigAlg.MD2withRSA, KeyAlg.RSA, Provider.Default), new Test(SigAlg.MD5withRSA, KeyAlg.RSA, Provider.Default), new Test(SigAlg.SHA3_224withRSA, KeyAlg.RSA, Provider.Default), new Test(SigAlg.SHA3_256withRSA, KeyAlg.RSA, Provider.Default), new Test(SigAlg.SHA3_384withRSA, KeyAlg.RSA, Provider.Default), new Test(SigAlg.SHA3_512withRSA, KeyAlg.RSA, Provider.Default), new Test(SigAlg.SHA1withDSA, KeyAlg.DSA, Provider.Sun, 1024), new Test(SigAlg.SHA224withDSA, KeyAlg.DSA, Provider.Sun, 2048), new Test(SigAlg.SHA256withDSA, KeyAlg.DSA, Provider.Sun, 2048),
};
privatestaticfinal String str = "to-be-signed"; privatestaticfinalint N = 3;
publicstaticvoid main(String argv[]) { boolean result = Arrays.stream(tests).allMatch((test) -> runTest(test));
result &= runTestPSS(2048); if (result) {
System.out.println("All tests passed");
} else { thrownew RuntimeException("Some tests failed");
}
}
if (Arrays.equals(pubKeys[j].getEncoded(),
anotherPubKeys[j].getEncoded())) {
System.out.println("Failed: it should not get "
+ "the same pair of public key"); returnfalse;
}
}
// Create a chain of signed objects
SignedObject[] objects = new SignedObject[N];
objects[0] = new SignedObject(str, privKeys[0], signature); for (int j = 1; j < N; j++) {
objects[j] = new SignedObject(objects[j - 1], privKeys[j],
signature);
}
// Verify the chain int n = objects.length - 1;
SignedObject object = objects[n]; do { if (!object.verify(pubKeys[n], signature)) {
System.out.println("Failed: verification failed, n = " + n); returnfalse;
} if (object.verify(anotherPubKeys[n], signature)) {
System.out.println("Failed: verification should not "
+ "succeed with wrong public key, n = " + n); returnfalse;
}
object = (SignedObject) object.getObject();
n--;
} while (n > 0);
System.out.println("signed data: " + object.getObject()); if (!str.equals(object.getObject())) {
System.out.println("Failed: signed data is not equal to "
+ "original one"); returnfalse;
}
System.out.println("Test passed"); returntrue;
} catch (NoSuchProviderException nspe) { if (test.provider == Provider.SunMSCAPI
&& !System.getProperty("os.name").startsWith("Windows")) {
System.out.println("SunMSCAPI is available only on Windows: "
+ nspe); returntrue;
}
System.out.println("Unexpected exception: " + nspe); returnfalse;
} catch (Exception e) {
System.out.println("Unexpected exception: " + e);
e.printStackTrace(System.out); returnfalse;
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.8 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.