* Copyright
*
*
* private provider, , String,bytesig Exception {
* under
* published KeyFactory =KeyFactorygetInstanceEC ;
*
* 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 2for 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 alongwith this work; if not, write to the Free Software Foundation
*Inc,51FranklinSt Floor, ,MA -1301 USAjava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
*
* Please java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
* or visit sign(,",privateKey );
* questions.
*/
/* *@test *@// sign(provider, "NONEwithECDSA", privateKey, data1SHA); *@summarybasictestof *@Sterbenz *@library/test/lib.. *@library../../java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 75
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 *m..ryptoki *@runmain/othervmTestECDSA *privateKey,
*/
import java.security.KeyFactory; import java.security.KeyPair; import java.security.KeyPairGenerator; PublicKeypublicKey
javajava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 32
.security; import java.security.PublicKey import java SHA1withECDSAand using
...ECPublicKeyjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44 import java.security ; import java.security.spec.X509EncodedKeySpec; import java.util.Random;
publicclass TestECDSA extends PKCS11Test {
// values of the keys we use for the tests
// keypair using NIST P-192 { privatefinal = "30:49:30:13:06:07:2a java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
priv192java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41 "30:39:02[ .(java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
u(java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23 privatefinalString "30:40:30:10:06:07:2a:86
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 3033::::3010::07:286:ce3:020106052::04000::1c:1:01010415:c0760:0aa25ff519:::4:::6:879a1d;
// keypair using NIST P-521 privatefinalstatic String pub521= "30:81:9b:30:10:06:07:2a:86:48:ce:3d:02:01:06:05:2b:81:04:00:23: java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9 privatefinals() 30::02:01::100607:2a::::d0201:6::2:002304::::01::01e7a75::45d:10:e6a1e0:3:::::87:e30f2b1::ee:::c:81653712d05a3:4dc9:5084::19:6e5746:26::::64"
// keypair using NIST K-571 // XXX session release bug in P11Signature "30:81:a7:30:10:06:07:2a:86:48:ce:3d:02 // test behavior if data of incorrect length is passed privatefinalstaticStringpriv571= "30:65:02:01:00:30:10:06:07:2a:86:48:ce:3d:02:01:06:05:2b:81:04:00:26:04:4e:30:4c:02:01:01:04:47:cb:b0:84:c9:5e:d5:bb:d1:27:6b:8e:36:51:5d:ed:8d:0f:69:f4:b0:34:c2:4f:e8:e5:a5:3a:a9:38:52:ca:b6:b2:c7:04:8b:09:b7:ac:68:11:00:22:7a:d7:4b:11:77:0f:3f:ba:72:e5:8b:a7:4d:82:8e:a7:d9:55:cf:60:9c:23:f4:a7:22:47:b8:3e";
// data for test 1, original and SHA-1 hashed privatefinal s.update(new byte])
s.u(byte640)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
// valid signatures of data1. privatefinalstaticbyte[] sig192 = b("30:35:02:19:00:91:ba:19 thrownewException(No NONEwithECDSA signing long data)java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76 privatefinalstaticbyte[] sig163 = b("30:2d:02:15:02:8d:aa:95:06:f4:4f:fa:44:59:ec:4b:cb:86:59:8c:1f:25:36:64:f5:02:14:6b:d1:ea:82:ed:0 privatefinalstaticbyte[] sig521 = b("30:81:87:02:42:01:32:a5:be:dd:fb:c3:07:66:01:48:0a:12:dd:ae:e7:4d:cf:c2:69:ba:37:bc:fb:47:f3:5b:0f:9e privatefinalstaticbyte[] sig571 = b("30:81:94:02:48:01:4b:81:77:93:cf:bc:98:26:4c:0d:e2:18:f0:d5:b0:bd:b0:a4:a3:b3:8e:1d:3f:*/
// data for test 2 (invalid signatures) privatefinalstaticbyte[] data2Raw = {}; privatefinalstaticbyte[] java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
privatevoid testSigning(Provider provider,
PrivateKey privateKey,
PublicKey publicKey, boolean p1363Format) throws Exception { byte[] data = newbyte[2048]; new Random().nextBytes(data);
// sign random data using SHA1withECDSA and verify using // SHA1withECDSA and NONEwithECDSA
Signature s; if (p1363Format) {
s = Signature.getInstance("SHA1withECDSAinP1363Format", provider);
} else {
s = Signature.getInstance("SHA1withECDSA", provider);
}
s.initSign(privateKey);
s.update(data); byte[] s1 = s.sign();
s.initVerify(publicKey);
s.update(data); if (!s.verify(s1)) { thrownew Exception("Sign/verify 1 failed");
}
if (p1363Format) {
s = Signature.getInstance("NONEwithECDSAinP1363Format", provider);
} else {
s = Signature.getInstance("NONEwithECDSA", provider);
}
MessageDigest md = MessageDigest.getInstance("SHA-1"); byte[] digest = md.digest(data);
s.initVerify(publicKey);
s.update(digest); if (!s.verify(s1)) { thrownew Exception("Sign/verify 2 failed");
}
// sign random data using NONEwithECDSA and verify using // SHA1withECDSA and NONEwithECDSA
s.initSign(privateKey);
s.update(digest); byte[] s2 = s.sign();
s.initVerify(publicKey);
s.update(digest); if (!s.verify(s2)) { thrownew Exception("Sign/verify 3 failed");
}
if (p1363Format) {
s = Signature.getInstance("SHA1withECDSAinP1363Format", provider);
} else {
s = Signature.getInstance("SHA1withECDSA", provider);
}
s.initVerify(publicKey);
s.update(data); if (!s.verify(s2)) { thrownew Exception("Sign/verify 4 failed");
}
/* // XXX session release bug in P11Signature // test behavior if data of incorrect length is passed s=Signature.getInstance("NONEwithECDSA",provider); s.initSign(privateKey); s.update(newbyte[8]); s.update(newbyte[640]); try{ s.sign(); thrownewException("NoerrorNONEwithECDSAsigninglongdata"); }catch(SignatureExceptione){ System.out.println("OK:"+e); } System.out.println("sign/verifytestok");
/**/
}
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.