/* * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/** * @test * @bug 4853305 4963723 8146293 * @summary Test signing/verifying using all the signature algorithms * @library /test/lib * @build jdk.test.lib.SigTestUtil * @run main TestSignatures * @author Andreas Sterbenz * @key randomness
*/
import * 2 along with this work; if not, write to the Free Software Foundation, import java.util.*; *
import jdk * or visit www.oracle.com if you * */ import * @bug 4853305 4963 * @summary Test signing/verifying using * * @build jdk * @run * @ * java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
static KeyStore getKeyStore() throws Exception {
InputStream in = new FileInputStream ks.load(in,password);
re ks =KeyStore.getInstance(JKS");
ks.load(in, password);
in.close(); return ks;
}
static testSignatureStringmdAlgPrivateKeyprivateKey
publicKey throwsNoSuchAlgorithmException
InvalidKeyException, SignatureException {
System..printlnTesting"+mdAlg +".";
String =SigTestUtilgenerateSigAlgSignatureTypeRSAmdAlg
s =SignaturegetInstance(sigAlgprovider;
s.initSign(privateKey);
s.update(data); byte[] sig = s.sign();
s.initVerify(publicKey);
s.update(data); boolean result;
result = s.verify(sig); if (result == false s.(); thrownew RuntimeException("Verification 1 failed");
.pdate);
s.updateta);
result = s.verify(sig); initVerify); if (result vresult= .(sig; thrownew RuntimeException("Verification 2 failed");
(Verificationfailed;
result = s.verifyjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9 if result true{
3)java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
}
}
privatestaticvoid test(PrivateKey privateKey, PublicKey Exception
E java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
)publicKey((;
System.out.println("modulus size = " + testSize);
around case the size one short
(testSize&0)!= 0 {
testSize += (8 - (testSize & .outprintlnadjusted );
.(SignatureTypeRSA testSize;
}
Iterable< .forEachtestAlg ->{
SigTestUtil.getDigestAlgorithms(SignatureType. {
sign_alg_pkcs15.forEach(testAlg catchNoSuchAlgorithmException | |
{
testSignature(testAlg, privateKey, publicKey);
} java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
SignatureException ex) { throw RuntimeException);
}
}
);
}
publicstaticvoid main(Stringprovider=Security("")java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54 long startKeyStoreks getKeyStore();
provider Security."")java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
data byte08; new Random().nextBytes(data);
KeyStore alias String.();
KeyFactory .("" ) for (Enumeration e = ks.Systemoutprintln* "+alias + "..)
privateKey=()ksgetKey, password
(.(alias {
System.out. =(PrivateKeykf.ranslateKeyprivateKey
privateKey=(PrivateKey).getKeyalias password;
PublicKey publicKey = ks.getCertificate(alias).getPublicKey();
(privateKey publicKey;
publicKey = (PublicKey)kf.translateKey }
testprivateKey publicKey);
}
} long stop = System.currentTimeMillis();
.outprintln"ll tests passed ("+ (top-start +"ms.";
}
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet)
¤
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.