/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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.
*/
private static char[] tokenPwd;
private static final char[] ibuttonPwd =
new char[0];
private static final char[] activcardPwd =
new char[] { '1', '1', '2', '2', '3', '3' };
private static final char[] nssPwd =
new char[] { 't', 'e', 's', 't', '1', '2' };
private static final char[] solarisPwd =
new char[] { 'p', 'i', 'n' };
private static final char[] sca1000Pwd =
new char[] { 'p', 'a', 's', 's', 'w', 'o', 'r', 'd' };
int length;
}
}
}
this.provider = p;
// get private keys
// get cert chains for private keys
// create secret keys
// read randomCert
doTest();
}
throw new Exception("token arg required");
}
throw new Exception("test arg required");
}
}
int testnum = 1;
// pkey and setAttribute
// sign
// setAttribute, pkey, sign
// setAttribute, pkey, sign, skey, copy
}
// this only works if NSS_TEST is set to true in P11KeyStore.java
int testnum = 1;
} else {
}
}
}
}
}
}
if (enu.hasMoreElements()) {
}
}
} else {
throw new SecurityException
}
" bytes in length");
return testnum;
}
}
throw new SecurityException("received chain not correct length");
}
throw new SecurityException("received chain not equal");
}
}
return testnum;
}
int testnum = 1;
// check instance
} else {
throw new SecurityException("did not get AuthProvider KeyStore");
}
// load
// aliases
int count = 0;
while (enu.hasMoreElements()) {
count++;
count +
" = " +
}
}
// perform Security.addProvider of P11 provider
KeyStoreLoginModule m = new KeyStoreLoginModule();
m.login();
m.commit();
m.logout();
}
/**
* SCA1000 does not handle extended secret key tests
* . Blowfish (CKR_TEMPLATE_INCOMPLETE)
* . AES (CKR_TEMPLATE_INCOMPLETE)
* . RC4 (CKR_ATTRIBUTE_TYPE_INVALID)
* so do this instead
*/
}
// delete all old aliases
int count = 0;
while (enu.hasMoreElements()) {
}
// set good ske 1
// set good ske 2
// getEntry good ske 1
} else {
throw new SecurityException
}
// getEntry good ske 2
} else {
throw new SecurityException
}
// getKey good ske 1
} else {
throw new SecurityException
}
// getKey good ske 2
} else {
throw new SecurityException
}
// aliases
count = 0;
while (enu.hasMoreElements()) {
count++;
count +
" = " +
}
if (count == 2) {
} else {
throw new SecurityException("expected 2 aliases");
}
// size
} else {
throw new SecurityException("expected size 2");
}
// isCertificateEntry sk1
} else {
throw new SecurityException("expected ske");
}
// isKeyEntry sk1
} else {
throw new SecurityException("expected ske");
}
// entryInstanceOf sk2
} else {
throw new SecurityException("expected ske");
}
return testnum;
}
}
// set good pke 1
}
// delete all old aliases except pk1
int count = 0;
while (enu.hasMoreElements()) {
}
}
throw new SecurityException("received chain not correct length");
}
throw new SecurityException("received chain not equal");
}
}
/**
* test change alias only
*/
// test C_SetAttribute
null);
// aliases
count = 0;
while (enu.hasMoreElements()) {
count++;
count +
" = " +
newAlias);
}
} else {
throw new SecurityException("expected 1 alias");
}
// size
} else {
throw new SecurityException("expected size 1");
}
throw new SecurityException("expected not to find pk1");
}
throw new SecurityException("received chain not correct length");
}
throw new SecurityException("received chain not equal");
}
}
/**
* test change cert chain
*/
null);
// aliases
count = 0;
while (enu.hasMoreElements()) {
count++;
count +
" = " +
newAlias);
}
} else {
throw new SecurityException("expected 1 alias");
}
// size
} else {
throw new SecurityException("expected size 1");
}
throw new SecurityException("expected not to find pk1SA");
}
throw new SecurityException("received chain not correct length");
}
throw new SecurityException("received chain not equal");
}
}
return testnum;
}
}
// check instance
} else {
throw new SecurityException("did not get AuthProvider KeyStore");
}
// delete all old aliases
int count = 0;
while (enu.hasMoreElements()) {
}
// set good pke 1
// set good pke 2
null);
// getEntry good pke 1
throw new SecurityException("received chain not correct length");
}
throw new SecurityException("received chain not equal");
}
}
// getKey good pke 1
} else {
throw new SecurityException
}
// getCertificate chain chain 1
throw new SecurityException("received chain not correct length");
}
throw new SecurityException("received chain not equal");
}
}
// getEntry good pke 2
} else {
throw new SecurityException
}
throw new SecurityException("received chain not correct length");
}
throw new SecurityException("received chain not equal");
}
}
// getKey good pke 2
} else {
throw new SecurityException
}
// getCertificate chain chain 2
throw new SecurityException("received chain not correct length");
}
throw new SecurityException("received chain not equal");
}
}
// aliases
count = 0;
while (enu.hasMoreElements()) {
count++;
count +
" = " +
}
if (count == 2) {
} else {
throw new SecurityException("expected 2 aliases");
}
// size
} else {
throw new SecurityException("expected size 2");
}
// getCertificate
} else {
throw new SecurityException("expected certificate pk1 end entity");
}
// containsAlias
} else {
throw new SecurityException("unexpected aliases encountered");
}
// isKeyEntry
} else {
throw new SecurityException("isKeyEntry failed");
}
// isCertificateEntry
} else {
throw new SecurityException("isCertificateEntry failed");
}
// getCertificateAlias
} else {
throw new SecurityException("getCertificateAlias failed");
}
} else {
throw new SecurityException("entryInstanceOf failed");
}
} else {
throw new SecurityException("deleteEntry failed");
}
// getEntry good pke 1
throw new SecurityException("received chain not correct length");
}
throw new SecurityException("received chain not equal");
}
}
// aliases
count = 0;
while (enu.hasMoreElements()) {
count++;
count +
" = " +
}
if (count == 1) {
} else {
throw new SecurityException("expected 1 alias");
}
// size
} else {
throw new SecurityException("expected size 1");
}
return testnum;
}
// setEntry unknown entry type
try {
throw new SecurityException("setEntry should have failed");
} catch (KeyStoreException kse) {
}
// getEntry random foo
throw new SecurityException("expected null entry");
} else {
}
// set good ske 1
// set good ske 2
// set good ske 3
null);
// set good ske 4
null);
// getEntry good ske 1
} else {
throw new SecurityException
}
// getEntry good ske 2
} else {
throw new SecurityException
}
// getEntry good ske 3
} else {
throw new SecurityException
}
// getEntry good ske 4
} else {
throw new SecurityException
}
// getKey good ske 1
} else {
throw new SecurityException
}
// getKey good ske 2
} else {
throw new SecurityException
}
// getKey good ske 3
} else {
throw new SecurityException
}
// getKey good ske 4
} else {
throw new SecurityException
}
// aliases
int count = 0;
while (enu.hasMoreElements()) {
count++;
count +
" = " +
}
if (count == 5) {
} else {
throw new SecurityException("expected 5 aliases");
}
// size
} else {
throw new SecurityException("expected size 5");
}
// set good pke 2
null);
// set good pke 3
null);
// getEntry good pke 1
throw new SecurityException("received chain not correct length");
}
throw new SecurityException("received chain not equal");
}
}
// getEntry good pke 2
throw new SecurityException("received chain not correct length");
}
throw new SecurityException("received chain not equal");
}
}
// getEntry good pke 3
throw new SecurityException("received chain not correct length");
}
throw new SecurityException("received chain not equal");
}
}
// getKey good pke 1
} else {
throw new SecurityException
}
// getCertificate chain chain 1
throw new SecurityException("received chain not correct length");
}
throw new SecurityException("received chain not equal");
}
}
// getKey good pke 2
} else {
throw new SecurityException
}
// getCertificate chain chain 2
throw new SecurityException("received chain not correct length");
}
throw new SecurityException("received chain not equal");
}
}
// getKey good pke 3
} else {
throw new SecurityException
}
// getCertificate chain chain 3
throw new SecurityException("received chain not correct length");
}
throw new SecurityException("received chain not equal");
}
}
// aliases
count = 0;
while (enu.hasMoreElements()) {
count++;
count +
" = " +
}
if (count == 7) {
} else {
throw new SecurityException("expected 7 aliases");
}
// size
} else {
throw new SecurityException("expected size 7");
}
// getCertificate good chain 1
} else {
throw new SecurityException("retrieved cert not equal");
}
// getCertificate good chain 3
} else {
throw new SecurityException("retrieved cert not equal");
}
// getKey good ske 1
} else {
throw new SecurityException
}
// getKey good ske 4
} else {
throw new SecurityException
}
// getKey good pke 1
} else {
throw new SecurityException
}
// getKey good pke 3
} else {
throw new SecurityException
}
// contains alias
throw new SecurityException("did not contain all aliases");
}
// getCertificateAlias pk1
} else {
throw new SecurityException("expected cert pk1");
}
// getCertificateAlias pk3
} else {
throw new SecurityException("expected cert pk3");
}
// isCertificateEntry pk1
} else {
throw new SecurityException("expected pke");
}
// isCertificateEntry pk3
} else {
throw new SecurityException("expected pke");
}
// isCertificateEntry sk1
} else {
throw new SecurityException("expected ske");
}
// isCertificateEntry sk4
} else {
throw new SecurityException("expected ske");
}
// isKeyEntry pk1
} else {
throw new SecurityException("expected pke");
}
// isKeyEntry pk3
} else {
throw new SecurityException("expected pke");
}
// isKeyEntry sk1
} else {
throw new SecurityException("expected ske");
}
// isKeyEntry sk4
} else {
throw new SecurityException("expected ske");
}
// isCertificateEntry random foo
} else {
throw new SecurityException("expected foo");
}
// isKeyEntry random foo
} else {
throw new SecurityException("expected foo");
}
// entryInstanceOf pk1
if (!ks.entryInstanceOf
} else {
throw new SecurityException("expected tce");
}
// entryInstanceOf pk3
if (!ks.entryInstanceOf
} else {
throw new SecurityException("expected tce");
}
// entryInstanceOf sk1
if (!ks.entryInstanceOf
} else {
throw new SecurityException("expected tce");
}
// entryInstanceOf sk4
if (!ks.entryInstanceOf
} else {
throw new SecurityException("expected tce");
}
// entryInstanceOf pk1
} else {
throw new SecurityException("expected pke");
}
// entryInstanceOf pk3
} else {
throw new SecurityException("expected pke");
}
// entryInstanceOf sk1
} else {
throw new SecurityException("expected pke");
}
// entryInstanceOf sk4
} else {
throw new SecurityException("expected pke");
}
// entryInstanceOf sk1
} else {
throw new SecurityException("expected ske");
}
// entryInstanceOf sk4
} else {
throw new SecurityException("expected ske");
}
// entryInstanceOf pk1
} else {
throw new SecurityException("expected ske");
}
// entryInstanceOf pk3
} else {
throw new SecurityException("expected ske");
}
// getEntry random foobar
throw new SecurityException("expected null entry");
} else {
}
// deleteEntry
// aliases
count = 0;
while (enu.hasMoreElements()) {
count++;
count +
" = " +
}
if (count == 3) {
} else {
throw new SecurityException("expected 3 aliases");
}
// size
} else {
throw new SecurityException("expected size 6");
}
// entryInstanceOf sk1
} else {
throw new SecurityException("expected pke");
}
// entryInstanceOf sk4
} else {
throw new SecurityException("expected pke");
}
// entryInstanceOf pk2
} else {
throw new SecurityException("expected pke");
}
return testnum;
}
}