Java Code Examples for java.security.spec.InvalidKeySpecException#initCause()

The following examples show how to use java.security.spec.InvalidKeySpecException#initCause() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PBKDF2KeyImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a PBE key from a given PBE key specification.
 *
 * @param key the given PBE key specification
 */
PBKDF2KeyImpl(PBEKeySpec keySpec, String prfAlgo)
    throws InvalidKeySpecException {
    char[] passwd = keySpec.getPassword();
    if (passwd == null) {
        // Should allow an empty password.
        this.passwd = new char[0];
    } else {
        this.passwd = passwd.clone();
    }
    // Convert the password from char[] to byte[]
    byte[] passwdBytes = getPasswordBytes(this.passwd);

    this.salt = keySpec.getSalt();
    if (salt == null) {
        throw new InvalidKeySpecException("Salt not found");
    }
    this.iterCount = keySpec.getIterationCount();
    if (iterCount == 0) {
        throw new InvalidKeySpecException("Iteration count not found");
    } else if (iterCount < 0) {
        throw new InvalidKeySpecException("Iteration count is negative");
    }
    int keyLength = keySpec.getKeyLength();
    if (keyLength == 0) {
        throw new InvalidKeySpecException("Key length not found");
    } else if (keyLength < 0) {
        throw new InvalidKeySpecException("Key length is negative");
    }
    try {
        this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
    } catch (NoSuchAlgorithmException nsae) {
        // not gonna happen; re-throw just in case
        InvalidKeySpecException ike = new InvalidKeySpecException();
        ike.initCause(nsae);
        throw ike;
    }
    this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength);
}
 
Example 2
Source File: PBKDF2KeyImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a PBE key from a given PBE key specification.
 *
 * @param key the given PBE key specification
 */
PBKDF2KeyImpl(PBEKeySpec keySpec, String prfAlgo)
    throws InvalidKeySpecException {
    char[] passwd = keySpec.getPassword();
    if (passwd == null) {
        // Should allow an empty password.
        this.passwd = new char[0];
    } else {
        this.passwd = passwd.clone();
    }
    // Convert the password from char[] to byte[]
    byte[] passwdBytes = getPasswordBytes(this.passwd);

    this.salt = keySpec.getSalt();
    if (salt == null) {
        throw new InvalidKeySpecException("Salt not found");
    }
    this.iterCount = keySpec.getIterationCount();
    if (iterCount == 0) {
        throw new InvalidKeySpecException("Iteration count not found");
    } else if (iterCount < 0) {
        throw new InvalidKeySpecException("Iteration count is negative");
    }
    int keyLength = keySpec.getKeyLength();
    if (keyLength == 0) {
        throw new InvalidKeySpecException("Key length not found");
    } else if (keyLength < 0) {
        throw new InvalidKeySpecException("Key length is negative");
    }
    try {
        this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
    } catch (NoSuchAlgorithmException nsae) {
        // not gonna happen; re-throw just in case
        InvalidKeySpecException ike = new InvalidKeySpecException();
        ike.initCause(nsae);
        throw ike;
    }
    this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength);
}
 
Example 3
Source File: PBKDF2KeyImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a PBE key from a given PBE key specification.
 *
 * @param key the given PBE key specification
 */
PBKDF2KeyImpl(PBEKeySpec keySpec, String prfAlgo)
    throws InvalidKeySpecException {
    char[] passwd = keySpec.getPassword();
    if (passwd == null) {
        // Should allow an empty password.
        this.passwd = new char[0];
    } else {
        this.passwd = passwd.clone();
    }
    // Convert the password from char[] to byte[]
    byte[] passwdBytes = getPasswordBytes(this.passwd);

    this.salt = keySpec.getSalt();
    if (salt == null) {
        throw new InvalidKeySpecException("Salt not found");
    }
    this.iterCount = keySpec.getIterationCount();
    if (iterCount == 0) {
        throw new InvalidKeySpecException("Iteration count not found");
    } else if (iterCount < 0) {
        throw new InvalidKeySpecException("Iteration count is negative");
    }
    int keyLength = keySpec.getKeyLength();
    if (keyLength == 0) {
        throw new InvalidKeySpecException("Key length not found");
    } else if (keyLength < 0) {
        throw new InvalidKeySpecException("Key length is negative");
    }
    try {
        this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
    } catch (NoSuchAlgorithmException nsae) {
        // not gonna happen; re-throw just in case
        InvalidKeySpecException ike = new InvalidKeySpecException();
        ike.initCause(nsae);
        throw ike;
    }
    this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength);
}
 
Example 4
Source File: PBKDF2KeyImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a PBE key from a given PBE key specification.
 *
 * @param key the given PBE key specification
 */
PBKDF2KeyImpl(PBEKeySpec keySpec, String prfAlgo)
    throws InvalidKeySpecException {
    char[] passwd = keySpec.getPassword();
    if (passwd == null) {
        // Should allow an empty password.
        this.passwd = new char[0];
    } else {
        this.passwd = passwd.clone();
    }
    // Convert the password from char[] to byte[]
    byte[] passwdBytes = getPasswordBytes(this.passwd);

    this.salt = keySpec.getSalt();
    if (salt == null) {
        throw new InvalidKeySpecException("Salt not found");
    }
    this.iterCount = keySpec.getIterationCount();
    if (iterCount == 0) {
        throw new InvalidKeySpecException("Iteration count not found");
    } else if (iterCount < 0) {
        throw new InvalidKeySpecException("Iteration count is negative");
    }
    int keyLength = keySpec.getKeyLength();
    if (keyLength == 0) {
        throw new InvalidKeySpecException("Key length not found");
    } else if (keyLength < 0) {
        throw new InvalidKeySpecException("Key length is negative");
    }
    try {
        this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
    } catch (NoSuchAlgorithmException nsae) {
        // not gonna happen; re-throw just in case
        InvalidKeySpecException ike = new InvalidKeySpecException();
        ike.initCause(nsae);
        throw ike;
    }
    this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength);
}
 
Example 5
Source File: PBKDF2KeyImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a PBE key from a given PBE key specification.
 *
 * @param key the given PBE key specification
 */
PBKDF2KeyImpl(PBEKeySpec keySpec, String prfAlgo)
    throws InvalidKeySpecException {
    char[] passwd = keySpec.getPassword();
    if (passwd == null) {
        // Should allow an empty password.
        this.passwd = new char[0];
    } else {
        this.passwd = passwd.clone();
    }
    // Convert the password from char[] to byte[]
    byte[] passwdBytes = getPasswordBytes(this.passwd);

    this.salt = keySpec.getSalt();
    if (salt == null) {
        throw new InvalidKeySpecException("Salt not found");
    }
    this.iterCount = keySpec.getIterationCount();
    if (iterCount == 0) {
        throw new InvalidKeySpecException("Iteration count not found");
    } else if (iterCount < 0) {
        throw new InvalidKeySpecException("Iteration count is negative");
    }
    int keyLength = keySpec.getKeyLength();
    if (keyLength == 0) {
        throw new InvalidKeySpecException("Key length not found");
    } else if (keyLength < 0) {
        throw new InvalidKeySpecException("Key length is negative");
    }
    try {
        this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
    } catch (NoSuchAlgorithmException nsae) {
        // not gonna happen; re-throw just in case
        InvalidKeySpecException ike = new InvalidKeySpecException();
        ike.initCause(nsae);
        throw ike;
    }
    this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength);
}
 
Example 6
Source File: PBKDF2KeyImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a PBE key from a given PBE key specification.
 *
 * @param key the given PBE key specification
 */
PBKDF2KeyImpl(PBEKeySpec keySpec, String prfAlgo)
    throws InvalidKeySpecException {
    char[] passwd = keySpec.getPassword();
    if (passwd == null) {
        // Should allow an empty password.
        this.passwd = new char[0];
    } else {
        this.passwd = passwd.clone();
    }
    // Convert the password from char[] to byte[]
    byte[] passwdBytes = getPasswordBytes(this.passwd);

    this.salt = keySpec.getSalt();
    if (salt == null) {
        throw new InvalidKeySpecException("Salt not found");
    }
    this.iterCount = keySpec.getIterationCount();
    if (iterCount == 0) {
        throw new InvalidKeySpecException("Iteration count not found");
    } else if (iterCount < 0) {
        throw new InvalidKeySpecException("Iteration count is negative");
    }
    int keyLength = keySpec.getKeyLength();
    if (keyLength == 0) {
        throw new InvalidKeySpecException("Key length not found");
    } else if (keyLength < 0) {
        throw new InvalidKeySpecException("Key length is negative");
    }
    try {
        this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
    } catch (NoSuchAlgorithmException nsae) {
        // not gonna happen; re-throw just in case
        InvalidKeySpecException ike = new InvalidKeySpecException();
        ike.initCause(nsae);
        throw ike;
    }
    this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength);
}
 
Example 7
Source File: PBKDF2KeyImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a PBE key from a given PBE key specification.
 *
 * @param key the given PBE key specification
 */
PBKDF2KeyImpl(PBEKeySpec keySpec, String prfAlgo)
    throws InvalidKeySpecException {
    char[] passwd = keySpec.getPassword();
    if (passwd == null) {
        // Should allow an empty password.
        this.passwd = new char[0];
    } else {
        this.passwd = passwd.clone();
    }
    // Convert the password from char[] to byte[]
    byte[] passwdBytes = getPasswordBytes(this.passwd);

    this.salt = keySpec.getSalt();
    if (salt == null) {
        throw new InvalidKeySpecException("Salt not found");
    }
    this.iterCount = keySpec.getIterationCount();
    if (iterCount == 0) {
        throw new InvalidKeySpecException("Iteration count not found");
    } else if (iterCount < 0) {
        throw new InvalidKeySpecException("Iteration count is negative");
    }
    int keyLength = keySpec.getKeyLength();
    if (keyLength == 0) {
        throw new InvalidKeySpecException("Key length not found");
    } else if (keyLength < 0) {
        throw new InvalidKeySpecException("Key length is negative");
    }
    try {
        this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
    } catch (NoSuchAlgorithmException nsae) {
        // not gonna happen; re-throw just in case
        InvalidKeySpecException ike = new InvalidKeySpecException();
        ike.initCause(nsae);
        throw ike;
    }
    this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength);
}
 
Example 8
Source File: PBKDF2KeyImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a PBE key from a given PBE key specification.
 *
 * @param key the given PBE key specification
 */
PBKDF2KeyImpl(PBEKeySpec keySpec, String prfAlgo)
    throws InvalidKeySpecException {
    char[] passwd = keySpec.getPassword();
    if (passwd == null) {
        // Should allow an empty password.
        this.passwd = new char[0];
    } else {
        this.passwd = passwd.clone();
    }
    // Convert the password from char[] to byte[]
    byte[] passwdBytes = getPasswordBytes(this.passwd);

    this.salt = keySpec.getSalt();
    if (salt == null) {
        throw new InvalidKeySpecException("Salt not found");
    }
    this.iterCount = keySpec.getIterationCount();
    if (iterCount == 0) {
        throw new InvalidKeySpecException("Iteration count not found");
    } else if (iterCount < 0) {
        throw new InvalidKeySpecException("Iteration count is negative");
    }
    int keyLength = keySpec.getKeyLength();
    if (keyLength == 0) {
        throw new InvalidKeySpecException("Key length not found");
    } else if (keyLength < 0) {
        throw new InvalidKeySpecException("Key length is negative");
    }
    try {
        this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
    } catch (NoSuchAlgorithmException nsae) {
        // not gonna happen; re-throw just in case
        InvalidKeySpecException ike = new InvalidKeySpecException();
        ike.initCause(nsae);
        throw ike;
    }
    this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength);
}
 
Example 9
Source File: PBKDF2KeyImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a PBE key from a given PBE key specification.
 *
 * @param key the given PBE key specification
 */
PBKDF2KeyImpl(PBEKeySpec keySpec, String prfAlgo)
    throws InvalidKeySpecException {
    char[] passwd = keySpec.getPassword();
    if (passwd == null) {
        // Should allow an empty password.
        this.passwd = new char[0];
    } else {
        this.passwd = passwd.clone();
    }
    // Convert the password from char[] to byte[]
    byte[] passwdBytes = getPasswordBytes(this.passwd);
    // remove local copy
    if (passwd != null) Arrays.fill(passwd, '\0');

    this.salt = keySpec.getSalt();
    if (salt == null) {
        throw new InvalidKeySpecException("Salt not found");
    }
    this.iterCount = keySpec.getIterationCount();
    if (iterCount == 0) {
        throw new InvalidKeySpecException("Iteration count not found");
    } else if (iterCount < 0) {
        throw new InvalidKeySpecException("Iteration count is negative");
    }
    int keyLength = keySpec.getKeyLength();
    if (keyLength == 0) {
        throw new InvalidKeySpecException("Key length not found");
    } else if (keyLength < 0) {
        throw new InvalidKeySpecException("Key length is negative");
    }
    try {
        this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
        this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength);
    } catch (NoSuchAlgorithmException nsae) {
        // not gonna happen; re-throw just in case
        InvalidKeySpecException ike = new InvalidKeySpecException();
        ike.initCause(nsae);
        throw ike;
    } finally {
        Arrays.fill(passwdBytes, (byte)0x00);
    }
}
 
Example 10
Source File: PBKDF2KeyImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a PBE key from a given PBE key specification.
 *
 * @param key the given PBE key specification
 */
PBKDF2KeyImpl(PBEKeySpec keySpec, String prfAlgo)
    throws InvalidKeySpecException {
    char[] passwd = keySpec.getPassword();
    if (passwd == null) {
        // Should allow an empty password.
        this.passwd = new char[0];
    } else {
        this.passwd = passwd.clone();
    }
    // Convert the password from char[] to byte[]
    byte[] passwdBytes = getPasswordBytes(this.passwd);
    // remove local copy
    if (passwd != null) Arrays.fill(passwd, '\0');

    this.salt = keySpec.getSalt();
    if (salt == null) {
        throw new InvalidKeySpecException("Salt not found");
    }
    this.iterCount = keySpec.getIterationCount();
    if (iterCount == 0) {
        throw new InvalidKeySpecException("Iteration count not found");
    } else if (iterCount < 0) {
        throw new InvalidKeySpecException("Iteration count is negative");
    }
    int keyLength = keySpec.getKeyLength();
    if (keyLength == 0) {
        throw new InvalidKeySpecException("Key length not found");
    } else if (keyLength < 0) {
        throw new InvalidKeySpecException("Key length is negative");
    }
    try {
        this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
        this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength);
    } catch (NoSuchAlgorithmException nsae) {
        // not gonna happen; re-throw just in case
        InvalidKeySpecException ike = new InvalidKeySpecException();
        ike.initCause(nsae);
        throw ike;
    } finally {
        Arrays.fill(passwdBytes, (byte)0x00);
    }
}
 
Example 11
Source File: PBKDF2KeyImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a PBE key from a given PBE key specification.
 *
 * @param key the given PBE key specification
 */
PBKDF2KeyImpl(PBEKeySpec keySpec, String prfAlgo)
    throws InvalidKeySpecException {
    char[] passwd = keySpec.getPassword();
    if (passwd == null) {
        // Should allow an empty password.
        this.passwd = new char[0];
    } else {
        this.passwd = passwd.clone();
    }
    // Convert the password from char[] to byte[]
    byte[] passwdBytes = getPasswordBytes(this.passwd);
    // remove local copy
    if (passwd != null) Arrays.fill(passwd, '\0');

    this.salt = keySpec.getSalt();
    if (salt == null) {
        throw new InvalidKeySpecException("Salt not found");
    }
    this.iterCount = keySpec.getIterationCount();
    if (iterCount == 0) {
        throw new InvalidKeySpecException("Iteration count not found");
    } else if (iterCount < 0) {
        throw new InvalidKeySpecException("Iteration count is negative");
    }
    int keyLength = keySpec.getKeyLength();
    if (keyLength == 0) {
        throw new InvalidKeySpecException("Key length not found");
    } else if (keyLength < 0) {
        throw new InvalidKeySpecException("Key length is negative");
    }
    try {
        this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
        this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength);
    } catch (NoSuchAlgorithmException nsae) {
        // not gonna happen; re-throw just in case
        InvalidKeySpecException ike = new InvalidKeySpecException();
        ike.initCause(nsae);
        throw ike;
    } finally {
        Arrays.fill(passwdBytes, (byte)0x00);
    }
}
 
Example 12
Source File: PBKDF2KeyImpl.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a PBE key from a given PBE key specification.
 *
 * @param keySpec the given PBE key specification
 * @param prfAlgo the given PBE key algorithm
 */
PBKDF2KeyImpl(PBEKeySpec keySpec, String prfAlgo)
    throws InvalidKeySpecException {
    char[] passwd = keySpec.getPassword();
    if (passwd == null) {
        // Should allow an empty password.
        this.passwd = new char[0];
    } else {
        this.passwd = passwd.clone();
    }
    // Convert the password from char[] to byte[]
    byte[] passwdBytes = getPasswordBytes(this.passwd);
    // remove local copy
    if (passwd != null) Arrays.fill(passwd, '\0');

    try {
        this.salt = keySpec.getSalt();
        if (salt == null) {
            throw new InvalidKeySpecException("Salt not found");
        }
        this.iterCount = keySpec.getIterationCount();
        if (iterCount == 0) {
            throw new InvalidKeySpecException("Iteration count not found");
        } else if (iterCount < 0) {
            throw new InvalidKeySpecException("Iteration count is negative");
        }
        int keyLength = keySpec.getKeyLength();
        if (keyLength == 0) {
            throw new InvalidKeySpecException("Key length not found");
        } else if (keyLength < 0) {
            throw new InvalidKeySpecException("Key length is negative");
        }
        this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
        this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength);
    } catch (NoSuchAlgorithmException nsae) {
        // not gonna happen; re-throw just in case
        InvalidKeySpecException ike = new InvalidKeySpecException();
        ike.initCause(nsae);
        throw ike;
    } finally {
        Arrays.fill(passwdBytes, (byte) 0x00);

        // Use the cleaner to zero the key when no longer referenced
        final byte[] k = this.key;
        final char[] p = this.passwd;
        CleanerFactory.cleaner().register(this,
                () -> {
                    Arrays.fill(k, (byte) 0x00);
                    Arrays.fill(p, '\0');
                });
    }
}
 
Example 13
Source File: PBKDF2KeyImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a PBE key from a given PBE key specification.
 *
 * @param key the given PBE key specification
 */
PBKDF2KeyImpl(PBEKeySpec keySpec, String prfAlgo)
    throws InvalidKeySpecException {
    char[] passwd = keySpec.getPassword();
    if (passwd == null) {
        // Should allow an empty password.
        this.passwd = new char[0];
    } else {
        this.passwd = passwd.clone();
    }
    // Convert the password from char[] to byte[]
    byte[] passwdBytes = getPasswordBytes(this.passwd);

    this.salt = keySpec.getSalt();
    if (salt == null) {
        throw new InvalidKeySpecException("Salt not found");
    }
    this.iterCount = keySpec.getIterationCount();
    if (iterCount == 0) {
        throw new InvalidKeySpecException("Iteration count not found");
    } else if (iterCount < 0) {
        throw new InvalidKeySpecException("Iteration count is negative");
    }
    int keyLength = keySpec.getKeyLength();
    if (keyLength == 0) {
        throw new InvalidKeySpecException("Key length not found");
    } else if (keyLength < 0) {
        throw new InvalidKeySpecException("Key length is negative");
    }
    try {
        this.prf = Mac.getInstance(prfAlgo);
        // SunPKCS11 requires a non-empty PBE password
        if (passwdBytes.length == 0 &&
            this.prf.getProvider().getName().startsWith("SunPKCS11")) {
            this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
        }
    } catch (NoSuchAlgorithmException nsae) {
        // not gonna happen; re-throw just in case
        InvalidKeySpecException ike = new InvalidKeySpecException();
        ike.initCause(nsae);
        throw ike;
    }
    this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength);
}
 
Example 14
Source File: PBKDF2KeyImpl.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a PBE key from a given PBE key specification.
 *
 * @param key the given PBE key specification
 */
PBKDF2KeyImpl(PBEKeySpec keySpec, String prfAlgo)
    throws InvalidKeySpecException {
    char[] passwd = keySpec.getPassword();
    if (passwd == null) {
        // Should allow an empty password.
        this.passwd = new char[0];
    } else {
        this.passwd = passwd.clone();
    }
    // Convert the password from char[] to byte[]
    byte[] passwdBytes = getPasswordBytes(this.passwd);
    // remove local copy
    if (passwd != null) Arrays.fill(passwd, '\0');

    this.salt = keySpec.getSalt();
    if (salt == null) {
        throw new InvalidKeySpecException("Salt not found");
    }
    this.iterCount = keySpec.getIterationCount();
    if (iterCount == 0) {
        throw new InvalidKeySpecException("Iteration count not found");
    } else if (iterCount < 0) {
        throw new InvalidKeySpecException("Iteration count is negative");
    }
    int keyLength = keySpec.getKeyLength();
    if (keyLength == 0) {
        throw new InvalidKeySpecException("Key length not found");
    } else if (keyLength < 0) {
        throw new InvalidKeySpecException("Key length is negative");
    }
    try {
        this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
        this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength);
    } catch (NoSuchAlgorithmException nsae) {
        // not gonna happen; re-throw just in case
        InvalidKeySpecException ike = new InvalidKeySpecException();
        ike.initCause(nsae);
        throw ike;
    } finally {
        Arrays.fill(passwdBytes, (byte)0x00);
    }
}