зеркало из https://github.com/mozilla/pjs.git
update all classes to be in org.mozilla.jss.tests.package.
Improve TestKeyGen test.
This commit is contained in:
Родитель
5243b5b9f0
Коммит
4fb23434af
|
@ -31,7 +31,7 @@
|
|||
* GPL.
|
||||
*/
|
||||
|
||||
package org.mozilla.jss;
|
||||
package org.mozilla.jss.tests;
|
||||
|
||||
import org.mozilla.jss.crypto.*;
|
||||
import java.util.Enumeration;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
* may use your version of this file under either the MPL or the
|
||||
* GPL.
|
||||
*/
|
||||
package org.mozilla.jss.crypto;
|
||||
package org.mozilla.jss.tests;
|
||||
|
||||
import java.io.*;
|
||||
import org.mozilla.jss.CryptoManager;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
* GPL.
|
||||
*/
|
||||
|
||||
package org.mozilla.jss.crypto;
|
||||
package org.mozilla.jss.tests;
|
||||
|
||||
import java.security.*;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
* GPL.
|
||||
*/
|
||||
|
||||
package org.mozilla.jss;
|
||||
package org.mozilla.jss.tests;
|
||||
|
||||
import org.mozilla.jss.crypto.*;
|
||||
import org.mozilla.jss.CryptoManager;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
* may use your version of this file under either the MPL or the
|
||||
* GPL.
|
||||
*/
|
||||
package org.mozilla.jss.crypto;
|
||||
package org.mozilla.jss.tests;
|
||||
|
||||
import org.mozilla.jss.CryptoManager;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
* GPL.
|
||||
*/
|
||||
|
||||
package org.mozilla.jss;
|
||||
package org.mozilla.jss.tests;
|
||||
|
||||
import org.mozilla.jss.crypto.*;
|
||||
import org.mozilla.jss.CryptoManager;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
* GPL.
|
||||
*/
|
||||
|
||||
package org.mozilla.jss.pkcs11;
|
||||
package org.mozilla.jss.tests;
|
||||
|
||||
import org.mozilla.jss.util.*;
|
||||
import org.mozilla.jss.crypto.*;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
* GPL.
|
||||
*/
|
||||
|
||||
package org.mozilla.jss;
|
||||
package org.mozilla.jss.tests;
|
||||
|
||||
import org.mozilla.jss.crypto.*;
|
||||
import org.mozilla.jss.CryptoManager;
|
||||
|
|
|
@ -66,9 +66,7 @@ public class TestKeyGen {
|
|||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
CryptoToken token;
|
||||
CryptoManager manager;
|
||||
KeyPairGenerator keyPairGenerator;
|
||||
java.security.KeyPair keyPair;
|
||||
Base64OutputStream base64;
|
||||
|
||||
|
@ -105,12 +103,12 @@ public class TestKeyGen {
|
|||
DSAParams dsaParams;
|
||||
RSAParameterSpec rsaParams;
|
||||
|
||||
token = manager.getInternalKeyStorageToken();
|
||||
keyPairGenerator = token.getKeyPairGenerator(KeyPairAlgorithm.RSA);
|
||||
java.security.KeyPairGenerator kpg =
|
||||
java.security.KeyPairGenerator.getInstance("RSA", "Mozilla-JSS");
|
||||
|
||||
// 512-bit RSA with default exponent
|
||||
keyPairGenerator.initialize(512);
|
||||
keyPair = keyPairGenerator.genKeyPair();
|
||||
kpg.initialize(512);
|
||||
keyPair = kpg.genKeyPair();
|
||||
Assert.assert( keyPair.getPublic() instanceof RSAPublicKey);
|
||||
rsaPubKey = (RSAPublicKey) keyPair.getPublic();
|
||||
System.out.println("Generated 512-bit RSA KeyPair!");
|
||||
|
@ -118,8 +116,8 @@ public class TestKeyGen {
|
|||
System.out.println("Exponent: "+rsaPubKey.getPublicExponent());
|
||||
|
||||
// 1024-bit RSA with default exponent
|
||||
keyPairGenerator.initialize(1024);
|
||||
keyPair = keyPairGenerator.genKeyPair();
|
||||
kpg.initialize(1024);
|
||||
keyPair = kpg.genKeyPair();
|
||||
Assert.assert( keyPair.getPublic() instanceof RSAPublicKey);
|
||||
rsaPubKey = (RSAPublicKey) keyPair.getPublic();
|
||||
System.out.println("Generated 1024-bit RSA KeyPair!");
|
||||
|
@ -128,8 +126,8 @@ public class TestKeyGen {
|
|||
|
||||
// 512-bit RSA with exponent = 3
|
||||
rsaParams = new RSAParameterSpec(512, BigInteger.valueOf(3));
|
||||
keyPairGenerator.initialize(rsaParams);
|
||||
keyPair = keyPairGenerator.genKeyPair();
|
||||
kpg.initialize(rsaParams);
|
||||
keyPair = kpg.genKeyPair();
|
||||
Assert.assert( keyPair.getPublic() instanceof RSAPublicKey);
|
||||
rsaPubKey = (RSAPublicKey) keyPair.getPublic();
|
||||
System.out.println("Generated 512-bit RSA KeyPair with public exponent=3!");
|
||||
|
@ -137,9 +135,9 @@ public class TestKeyGen {
|
|||
System.out.println("Exponent: "+rsaPubKey.getPublicExponent());
|
||||
|
||||
// 512-bit DSA
|
||||
keyPairGenerator = token.getKeyPairGenerator(KeyPairAlgorithm.DSA);
|
||||
keyPairGenerator.initialize(512);
|
||||
keyPair = keyPairGenerator.genKeyPair();
|
||||
kpg = java.security.KeyPairGenerator.getInstance("DSA", "Mozilla-JSS");
|
||||
kpg.initialize(512);
|
||||
keyPair = kpg.genKeyPair();
|
||||
Assert.assert( keyPair.getPublic() instanceof DSAPublicKey);
|
||||
dsaPubKey = (DSAPublicKey) keyPair.getPublic();
|
||||
System.out.println("Generated 512-bit DSA KeyPair!");
|
||||
|
@ -150,8 +148,8 @@ public class TestKeyGen {
|
|||
System.out.println("Y: "+dsaPubKey.getY());
|
||||
|
||||
// 1024-bit DSA
|
||||
keyPairGenerator.initialize(1024);
|
||||
keyPair = keyPairGenerator.genKeyPair();
|
||||
kpg.initialize(1024);
|
||||
keyPair = kpg.genKeyPair();
|
||||
Assert.assert( keyPair.getPublic() instanceof DSAPublicKey);
|
||||
dsaPubKey = (DSAPublicKey) keyPair.getPublic();
|
||||
System.out.println("Generated 1024-bit DSA KeyPair!");
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Netscape Security Services for Java.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998-2000 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the
|
||||
# terms of the GNU General Public License Version 2 or later (the
|
||||
# "GPL"), in which case the provisions of the GPL are applicable
|
||||
# instead of those above. If you wish to allow use of your
|
||||
# version of this file only under the terms of the GPL and not to
|
||||
# allow others to use your version of this file under the MPL,
|
||||
# indicate your decision by deleting the provisions above and
|
||||
# replace them with the notice and other provisions required by
|
||||
# the GPL. If you do not delete the provisions above, a recipient
|
||||
# may use your version of this file under either the MPL or the
|
||||
# GPL.
|
||||
#
|
||||
|
||||
CORE_DEPTH = ../../../../..
|
||||
|
||||
MODULE = jss
|
||||
|
||||
NS_USE_JDK = 1
|
||||
|
||||
REQUIRES = nspr20 security
|
||||
|
||||
PRIVATE_CLASSES = \
|
||||
DigestTest \
|
||||
SelfTest \
|
||||
SymKeyGen \
|
||||
PK10Gen \
|
||||
JCASigTest \
|
||||
CloseDBs \
|
||||
KeyWrapping \
|
||||
ListCerts \
|
||||
socketTest \
|
||||
org.mozilla.jss.tests.SetupDBs \
|
||||
org.mozilla.jss.tests.TestKeyGen \
|
||||
org.mozilla.jss.tests.SigTest \
|
||||
$(NULL)
|
||||
|
||||
JSRCS = \
|
||||
DigestTest.java \
|
||||
SelfTest.java \
|
||||
SymKeyGen.java \
|
||||
PK10Gen.java \
|
||||
JCASigTest.java \
|
||||
CloseDBs.java \
|
||||
KeyWrapping.java \
|
||||
ListCerts.java \
|
||||
socketTest.java \
|
||||
SetupDBs.java \
|
||||
TestKeyGen.java \
|
||||
SigTest.java \
|
||||
$(NULL)
|
Загрузка…
Ссылка в новой задаче