// --- BEGIN COPYRIGHT BLOCK --- // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; version 2 of the License. // // This program 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 for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // (C) 2007 Red Hat, Inc. // All rights reserved. // --- END COPYRIGHT BLOCK --- package com.netscape.kra; import org.mozilla.jss.util.Password; import java.util.*; import java.io.*; import com.netscape.certsrv.security.*; import java.net.*; import java.security.*; import java.security.cert.*; import org.mozilla.jss.crypto.X509Certificate; import org.mozilla.jss.crypto.TokenCertificate; import netscape.security.x509.*; import netscape.security.util.*; import com.netscape.cmscore.util.*; //import com.netscape.cmscore.kra.*; import com.netscape.certsrv.dbs.keydb.*; import com.netscape.certsrv.apps.*; import com.netscape.certsrv.logging.*; import com.netscape.certsrv.base.*; import com.netscape.certsrv.security.*; import com.netscape.certsrv.kra.*; import org.mozilla.jss.crypto.PrivateKey; import org.mozilla.jss.*; import org.mozilla.jss.asn1.INTEGER; import org.mozilla.jss.util.*; import org.mozilla.jss.util.Password; import org.mozilla.jss.crypto.*; import com.netscape.cmscore.cert.*; /** * A class represents a storage key unit. Currently, this * is implemented with cryptix, the final implementation * should be built on JSS/HCL. * * @author thomask * @version $Revision$, $Date$ */ public class StorageKeyUnit extends EncryptionUnit implements ISubsystem, IStorageKeyUnit { private IConfigStore mConfig = null; // private RSAPublicKey mPublicKey = null; // private RSAPrivateKey mPrivateKey = null; private IConfigStore mStorageConfig = null; private IKeyRecoveryAuthority mKRA = null; private String mTokenFile = null; private X509Certificate mCert = null; private CryptoManager mManager = null; private CryptoToken mToken = null; private PrivateKey mPrivateKey = null; private byte mPrivateKeyData[] = null; private boolean mKeySplitting = false; private static final String PROP_N = "n"; private static final String PROP_M = "m"; private static final String PROP_UID = "uid"; private static final String PROP_SHARE = "share"; private static final String PROP_HARDWARE = "hardware"; private static final String PROP_LOGOUT = "logout"; public static final String PROP_NICKNAME = "nickName"; public static final String PROP_KEYDB = "keydb"; public static final String PROP_CERTDB = "certdb"; public static final String PROP_MN = "mn"; /** * Constructs this token. */ public StorageKeyUnit() { super(); } /** * Retrieves subsystem identifier. */ public String getId() { return "storageKeyUnit"; } /** * Sets subsystem identifier. Once the system is * loaded, system identifier cannot be changed * dynamically. */ public void setId(String id) throws EBaseException { throw new EBaseException(CMS.getUserMessage("CMS_INVALID_OPERATION")); } /** * return true if byte arrays are equal, false otherwise */ private boolean byteArraysMatch(byte a[], byte b[]) { if (a==null || b==null) { return false; } if (a.length != b.length) { return false; } for (int i=0; i