Code example for InvalidParameterException

0
            engine.init(new KeyGenerationParameters(random, keySize));
            uninitialised = false;
        } 
        catch (IllegalArgumentException e)
        { 
            throw new InvalidParameterException(e.getMessage());
        } 
    } 
 
    protected SecretKey engineGenerateKey()
    { 
        if (uninitialised)
        { 
            engine.init(new KeyGenerationParameters(new SecureRandom(), defaultKeySize));
            uninitialised = false;
        } 
 
        return new SecretKeySpec(engine.generateKey(), algName);
    } 
 
    /**