Java Code Examples for java.security.spec.InvalidParameterSpecException

The following are top voted examples for showing how to use java.security.spec.InvalidParameterSpecException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: CrashCoin   File: Main.java   View source code 7 votes vote down vote up
public static void main(final String[] argv) throws IOException, InvalidKeySpecException, NoSuchPaddingException, 
        InvalidKeyException, InvalidParameterSpecException, IllegalBlockSizeException, BadPaddingException,
        InvalidAlgorithmParameterException, ClassNotFoundException, GeneralSecurityException {
    
    if(argv.length >= 2) {
        ip = argv[0];
        port = Integer.parseInt(argv[1]);
    } else {
        Logger.getLogger(Main.class.getName()).log(Level.INFO, "Default ip and port were applied.");
        ip = Parameters.RELAY_IP;
        port = Parameters.RELAY_PORT_WALLET_LISTENER;
    }
    
    // Init connection with relay
    try {
        RelayConnection.getInstance();
    } catch(IOException ex) {
        Logger.getLogger(Main.class.getName()).severe(ex.getMessage());
        return;
    }
    
    new ClientApplication();

}
 
Example 2
Project: wolfcrypt-jni   File: WolfCryptCipher.java   View source code 7 votes vote down vote up
@Override
protected void engineInit(int opmode, Key key,
        AlgorithmParameters params, SecureRandom random)
    throws InvalidKeyException, InvalidAlgorithmParameterException {

    AlgorithmParameterSpec spec;

    try {

        spec = params.getParameterSpec(IvParameterSpec.class);

        if (debug.DEBUG)
            log("initialized with key and AlgorithmParameters");

    } catch (InvalidParameterSpecException ipe) {
        throw new InvalidAlgorithmParameterException(ipe);
    }

    wolfCryptCipherInit(opmode, key, spec, random);
}
 
Example 3
Project: openjdk-jdk10   File: RC2Parameters.java   View source code 6 votes vote down vote up
protected void engineInit(AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException {

    if (!(paramSpec instanceof RC2ParameterSpec)) {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
    RC2ParameterSpec rps = (RC2ParameterSpec) paramSpec;

    // check effective key size (a value of 0 means it is unspecified)
    effectiveKeySize = rps.getEffectiveKeyBits();
    if (effectiveKeySize != 0) {
        if (effectiveKeySize < 1 || effectiveKeySize > 1024) {
            throw new InvalidParameterSpecException("RC2 effective key " +
                "size must be between 1 and 1024 bits");
        }
        if (effectiveKeySize < 256) {
            version = EKB_TABLE[effectiveKeySize];
        } else {
            version = effectiveKeySize;
        }
    }
    this.iv = rps.getIV();
}
 
Example 4
Project: ipack   File: RC2.java   View source code 6 votes vote down vote up
protected AlgorithmParameterSpec localEngineGetParameterSpec(
    Class paramSpec)
    throws InvalidParameterSpecException
{
    if (paramSpec == RC2ParameterSpec.class)
    {
        if (parameterVersion != -1)
        {
            if (parameterVersion < 256)
            {
                return new RC2ParameterSpec(ekb[parameterVersion], iv);
            }
            else
            {
                return new RC2ParameterSpec(parameterVersion, iv);
            }
        }
    }

    if (paramSpec == IvParameterSpec.class)
    {
        return new IvParameterSpec(iv);
    }

    throw new InvalidParameterSpecException("unknown parameter spec passed to RC2 parameters object.");
}
 
Example 5
Project: jdk8u-jdk   File: DSAPrivateKey.java   View source code 6 votes vote down vote up
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
Example 6
Project: openjdk-jdk10   File: DSAParameters.java   View source code 6 votes vote down vote up
protected <T extends AlgorithmParameterSpec>
    T engineGetParameterSpec(Class<T> paramSpec)
    throws InvalidParameterSpecException
{
        try {
            Class<?> dsaParamSpec = Class.forName
                ("java.security.spec.DSAParameterSpec");
            if (dsaParamSpec.isAssignableFrom(paramSpec)) {
                return paramSpec.cast(
                        new DSAParameterSpec(this.p, this.q, this.g));
            } else {
                throw new InvalidParameterSpecException
                    ("Inappropriate parameter Specification");
            }
        } catch (ClassNotFoundException e) {
            throw new InvalidParameterSpecException
                ("Unsupported parameter specification: " + e.getMessage());
        }
}
 
Example 7
Project: ipack   File: AlgorithmParametersSpi.java   View source code 6 votes vote down vote up
protected void engineInit(
    AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException
{
    if (!(paramSpec instanceof ElGamalParameterSpec) && !(paramSpec instanceof DHParameterSpec))
    {
        throw new InvalidParameterSpecException("DHParameterSpec required to initialise a ElGamal algorithm parameters object");
    }

    if (paramSpec instanceof ElGamalParameterSpec)
    {
        this.currentSpec = (ElGamalParameterSpec)paramSpec;
    }
    else
    {
        DHParameterSpec s = (DHParameterSpec)paramSpec;

        this.currentSpec = new ElGamalParameterSpec(s.getP(), s.getG());
    }
}
 
Example 8
Project: jdk8u-jdk   File: RSACipher.java   View source code 6 votes vote down vote up
protected AlgorithmParameters engineGetParameters() {
    if (spec != null && spec instanceof OAEPParameterSpec) {
        try {
            AlgorithmParameters params =
                AlgorithmParameters.getInstance("OAEP",
                    SunJCE.getInstance());
            params.init(spec);
            return params;
        } catch (NoSuchAlgorithmException nsae) {
            // should never happen
            throw new RuntimeException("Cannot find OAEP " +
                " AlgorithmParameters implementation in SunJCE provider");
        } catch (InvalidParameterSpecException ipse) {
            // should never happen
            throw new RuntimeException("OAEPParameterSpec not supported");
        }
    } else {
        return null;
    }
}
 
Example 9
Project: jdk8u-jdk   File: DSAParameters.java   View source code 6 votes vote down vote up
protected <T extends AlgorithmParameterSpec>
    T engineGetParameterSpec(Class<T> paramSpec)
    throws InvalidParameterSpecException
{
        try {
            Class<?> dsaParamSpec = Class.forName
                ("java.security.spec.DSAParameterSpec");
            if (dsaParamSpec.isAssignableFrom(paramSpec)) {
                return paramSpec.cast(
                        new DSAParameterSpec(this.p, this.q, this.g));
            } else {
                throw new InvalidParameterSpecException
                    ("Inappropriate parameter Specification");
            }
        } catch (ClassNotFoundException e) {
            throw new InvalidParameterSpecException
                ("Unsupported parameter specification: " + e.getMessage());
        }
}
 
Example 10
Project: OpenJSharp   File: DSAPublicKey.java   View source code 6 votes vote down vote up
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
Example 11
Project: OpenJSharp   File: DSAPrivateKey.java   View source code 6 votes vote down vote up
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
Example 12
Project: OpenJSharp   File: RC2Parameters.java   View source code 6 votes vote down vote up
protected void engineInit(AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException {

    if (!(paramSpec instanceof RC2ParameterSpec)) {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
    RC2ParameterSpec rps = (RC2ParameterSpec) paramSpec;

    // check effective key size (a value of 0 means it is unspecified)
    effectiveKeySize = rps.getEffectiveKeyBits();
    if (effectiveKeySize != 0) {
        if (effectiveKeySize < 1 || effectiveKeySize > 1024) {
            throw new InvalidParameterSpecException("RC2 effective key " +
                "size must be between 1 and 1024 bits");
        }
        if (effectiveKeySize < 256) {
            version = EKB_TABLE[effectiveKeySize];
        } else {
            version = effectiveKeySize;
        }
    }
    this.iv = rps.getIV();
}
 
Example 13
Project: openjdk-jdk10   File: DSAPublicKey.java   View source code 6 votes vote down vote up
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
Example 14
Project: OpenJSharp   File: RSACipher.java   View source code 6 votes vote down vote up
protected AlgorithmParameters engineGetParameters() {
    if (spec != null && spec instanceof OAEPParameterSpec) {
        try {
            AlgorithmParameters params =
                AlgorithmParameters.getInstance("OAEP",
                    SunJCE.getInstance());
            params.init(spec);
            return params;
        } catch (NoSuchAlgorithmException nsae) {
            // should never happen
            throw new RuntimeException("Cannot find OAEP " +
                " AlgorithmParameters implementation in SunJCE provider");
        } catch (InvalidParameterSpecException ipse) {
            // should never happen
            throw new RuntimeException("OAEPParameterSpec not supported");
        }
    } else {
        return null;
    }
}
 
Example 15
Project: OpenJSharp   File: RSACipher.java   View source code 6 votes vote down vote up
protected void engineInit(int opmode, Key key,
        AlgorithmParameters params, SecureRandom random)
        throws InvalidKeyException, InvalidAlgorithmParameterException {
    if (params == null) {
        init(opmode, key, random, null);
    } else {
        try {
            OAEPParameterSpec spec =
                    params.getParameterSpec(OAEPParameterSpec.class);
            init(opmode, key, random, spec);
        } catch (InvalidParameterSpecException ipse) {
            InvalidAlgorithmParameterException iape =
                new InvalidAlgorithmParameterException("Wrong parameter");
            iape.initCause(ipse);
            throw iape;
        }
    }
}
 
Example 16
Project: OpenJSharp   File: Cipher.java   View source code 6 votes vote down vote up
private void checkCryptoPerm(CipherSpi checkSpi, Key key,
        AlgorithmParameters params)
        throws InvalidKeyException, InvalidAlgorithmParameterException {
    if (cryptoPerm == CryptoAllPermission.INSTANCE) {
        return;
    }
    // Convert the specified parameters into specs and then delegate.
    AlgorithmParameterSpec pSpec;
    try {
        pSpec = getAlgorithmParameterSpec(params);
    } catch (InvalidParameterSpecException ipse) {
        throw new InvalidAlgorithmParameterException
            ("Failed to retrieve algorithm parameter specification");
    }
    checkCryptoPerm(checkSpi, key, pSpec);
}
 
Example 17
Project: CrashCoin   File: WalletClient.java   View source code 6 votes vote down vote up
/**
 * Methods used to write the current ClientWallent into a generated file.
 * @param userPassword
 * @param accountName
 * @param keyPair
 * @throws InvalidKeyException
 * @throws InvalidParameterSpecException
 * @throws IllegalBlockSizeException
 * @throws BadPaddingException
 * @throws FileNotFoundException
 * @throws IOException 
 */
public static void writeWalletFile(final char[] userPassword, final String accountName, final KeyPair keyPair) 
        throws InvalidKeyException,
        InvalidParameterSpecException, IllegalBlockSizeException, BadPaddingException, FileNotFoundException,
        IOException {
    
    // Write wallet information in the wallet file
    final WalletInformation walletInformation = Cryptography.walletInformationFromKeyPair(userPassword, keyPair);

    // Creates wallet folder if not exists
    final File walletFolder = new File(Parameters.WALLETS_PATH);
    if (!walletFolder.exists()) {
        walletFolder.mkdir();
    }

    // Creates new wallet file
    final File f = new File(Parameters.WALLETS_PATH + accountName + ".wallet");
    final ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(f));
    oos.writeObject(walletInformation);
    oos.flush();
    oos.close();

    System.out.println("The creation of your wallet completed successfully");
    System.out.println("Please sign in and start crashing coins");
}
 
Example 18
Project: CrashCoin   File: ClientApplication.java   View source code 6 votes vote down vote up
private void actionMenuNotRegistered(final int choice) throws ClassNotFoundException, IOException, FileNotFoundException,
        InvalidKeyException, InvalidAlgorithmParameterException,
        InvalidKeySpecException, IllegalBlockSizeException, BadPaddingException, InvalidParameterSpecException {
    switch (choice) {
        case 1:
            signIn();
            break;

        case 2:
            signUp();
            break;
            
        case 3: // close with condition in while
            break;

        default:
            System.out.println("Unknow choice " + choice + "\n");
            break;

    }
}
 
Example 19
Project: jdk8u-jdk   File: DSAPublicKey.java   View source code 6 votes vote down vote up
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
Example 20
Project: keepass2android   File: NativeAESCipherSpi.java   View source code 5 votes vote down vote up
@Override
protected void engineInit(int opmode, Key key, AlgorithmParameters params,
		SecureRandom random) throws InvalidKeyException,
		InvalidAlgorithmParameterException {
	
	try {
		engineInit(opmode, key, params.getParameterSpec(AlgorithmParameterSpec.class), random);
	} catch (InvalidParameterSpecException e) {
		throw new InvalidAlgorithmParameterException(e);
	}

}
 
Example 21
Project: jdk8u-jdk   File: GCMParameters.java   View source code 5 votes vote down vote up
protected <T extends AlgorithmParameterSpec>
        T engineGetParameterSpec(Class<T> paramSpec)
    throws InvalidParameterSpecException {

    if (GCMParameterSpec.class.isAssignableFrom(paramSpec)) {
        return paramSpec.cast(new GCMParameterSpec(tLen * 8, iv));
    } else {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
}
 
Example 22
Project: ipack   File: PBEPKCS12.java   View source code 5 votes vote down vote up
protected void engineInit(
    AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException
{
    if (!(paramSpec instanceof PBEParameterSpec))
    {
        throw new InvalidParameterSpecException("PBEParameterSpec required to initialise a PKCS12 PBE parameters algorithm parameters object");
    }

    PBEParameterSpec pbeSpec = (PBEParameterSpec)paramSpec;

    this.params = new PKCS12PBEParams(pbeSpec.getSalt(),
        pbeSpec.getIterationCount());
}
 
Example 23
Project: openjdk-jdk10   File: BlockCipherParamsCore.java   View source code 5 votes vote down vote up
void init(AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException {
    if (!(paramSpec instanceof IvParameterSpec)) {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
    byte[] tmpIv = ((IvParameterSpec)paramSpec).getIV();
    if (tmpIv.length != block_size) {
        throw new InvalidParameterSpecException("IV not " +
                    block_size + " bytes long");
    }
    iv = tmpIv.clone();
}
 
Example 24
Project: ipack   File: PBEPBKDF2.java   View source code 5 votes vote down vote up
protected void engineInit(
    AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException
{
    if (!(paramSpec instanceof PBEParameterSpec))
    {
        throw new InvalidParameterSpecException("PBEParameterSpec required to initialise a PBKDF2 PBE parameters algorithm parameters object");
    }

    PBEParameterSpec    pbeSpec = (PBEParameterSpec)paramSpec;

    this.params = new PBKDF2Params(pbeSpec.getSalt(),
                        pbeSpec.getIterationCount());
}
 
Example 25
Project: ipack   File: CAST5.java   View source code 5 votes vote down vote up
protected AlgorithmParameterSpec localEngineGetParameterSpec(
    Class paramSpec)
    throws InvalidParameterSpecException
{
    if (paramSpec == IvParameterSpec.class)
    {
        return new IvParameterSpec(iv);
    }

    throw new InvalidParameterSpecException("unknown parameter spec passed to CAST5 parameters object.");
}
 
Example 26
Project: ipack   File: IvAlgorithmParameters.java   View source code 5 votes vote down vote up
protected AlgorithmParameterSpec localEngineGetParameterSpec(
    Class paramSpec)
    throws InvalidParameterSpecException
{
    if (paramSpec == IvParameterSpec.class)
    {
        return new IvParameterSpec(iv);
    }

    throw new InvalidParameterSpecException("unknown parameter spec passed to IV parameters object.");
}
 
Example 27
Project: ipack   File: IvAlgorithmParameters.java   View source code 5 votes vote down vote up
protected void engineInit(
    AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException
{
    if (!(paramSpec instanceof IvParameterSpec))
    {
        throw new InvalidParameterSpecException("IvParameterSpec required to initialise a IV parameters algorithm parameters object");
    }

    this.iv = ((IvParameterSpec)paramSpec).getIV();
}
 
Example 28
Project: ipack   File: BaseAlgorithmParameters.java   View source code 5 votes vote down vote up
protected AlgorithmParameterSpec engineGetParameterSpec(
    Class paramSpec)
    throws InvalidParameterSpecException
{
    if (paramSpec == null)
    {
        throw new NullPointerException("argument to getParameterSpec must not be null");
    }

    return localEngineGetParameterSpec(paramSpec);
}
 
Example 29
Project: jdk8u-jdk   File: BlockCipherParamsCore.java   View source code 5 votes vote down vote up
void init(AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException {
    if (!(paramSpec instanceof IvParameterSpec)) {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
    byte[] tmpIv = ((IvParameterSpec)paramSpec).getIV();
    if (tmpIv.length != block_size) {
        throw new InvalidParameterSpecException("IV not " +
                    block_size + " bytes long");
    }
    iv = tmpIv.clone();
}
 
Example 30
Project: ipack   File: IDEA.java   View source code 5 votes vote down vote up
protected void engineInit(
    AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException
{
    if (!(paramSpec instanceof IvParameterSpec))
    {
        throw new InvalidParameterSpecException("IvParameterSpec required to initialise a IV parameters algorithm parameters object");
    }

    this.iv = ((IvParameterSpec)paramSpec).getIV();
}
 
Example 31
Project: jdk8u-jdk   File: PBES2Parameters.java   View source code 5 votes vote down vote up
protected void engineInit(AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException
{
   if (!(paramSpec instanceof PBEParameterSpec)) {
       throw new InvalidParameterSpecException
           ("Inappropriate parameter specification");
   }
   this.salt = ((PBEParameterSpec)paramSpec).getSalt().clone();
   this.iCount = ((PBEParameterSpec)paramSpec).getIterationCount();
   this.cipherParam = ((PBEParameterSpec)paramSpec).getParameterSpec();
}
 
Example 32
Project: openjdk-jdk10   File: GCMParameters.java   View source code 5 votes vote down vote up
protected void engineInit(AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException {

    if (!(paramSpec instanceof GCMParameterSpec)) {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
    GCMParameterSpec gps = (GCMParameterSpec) paramSpec;
    // need to convert from bits to bytes for ASN.1 encoding
    this.tLen = gps.getTLen()/8;
    this.iv = gps.getIV();
}
 
Example 33
Project: openjdk-jdk10   File: SupportedGroupsExtension.java   View source code 5 votes vote down vote up
static ECGenParameterSpec getECGenParamSpec(NamedGroup namedGroup) {
    if (namedGroup.type != NamedGroupType.NAMED_GROUP_ECDHE) {
        throw new RuntimeException("Not a named EC group: " + namedGroup);
    }

    AlgorithmParameters params = namedGroupParams.get(namedGroup);
    try {
        return params.getParameterSpec(ECGenParameterSpec.class);
    } catch (InvalidParameterSpecException ipse) {
        // should be unlikely
        return new ECGenParameterSpec(namedGroup.oid);
    }
}
 
Example 34
Project: openjdk-jdk10   File: PBECipherWrapper.java   View source code 5 votes vote down vote up
@Override
protected void initCipher(int mode) throws InvalidKeyException,
        InvalidAlgorithmParameterException, InvalidParameterSpecException {
    if (Cipher.ENCRYPT_MODE == mode) {
        ci.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key.getEncoded(),
                KEY_ALGORITHM));
        iv = ci.getParameters().getParameterSpec(IvParameterSpec.class)
                .getIV();
    } else {
        ci.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key.getEncoded(),
                KEY_ALGORITHM), new IvParameterSpec(iv));
    }
}
 
Example 35
Project: ipack   File: AlgorithmParametersSpi.java   View source code 5 votes vote down vote up
protected AlgorithmParameterSpec localEngineGetParameterSpec(
    Class paramSpec) 
    throws InvalidParameterSpecException
{
    if (paramSpec == DHParameterSpec.class)
    {
        return currentSpec;
    }

    throw new InvalidParameterSpecException("unknown parameter spec passed to DH parameters object.");
}
 
Example 36
Project: ipack   File: AlgorithmParametersSpi.java   View source code 5 votes vote down vote up
protected void engineInit(
    AlgorithmParameterSpec paramSpec) 
    throws InvalidParameterSpecException
{
    if (!(paramSpec instanceof DHParameterSpec))
    {
        throw new InvalidParameterSpecException("DHParameterSpec required to initialise a Diffie-Hellman algorithm parameters object");
    }

    this.currentSpec = (DHParameterSpec)paramSpec;
}
 
Example 37
Project: ipack   File: AlgorithmParametersSpi.java   View source code 5 votes vote down vote up
protected AlgorithmParameterSpec engineGetParameterSpec(
    Class paramSpec)
    throws InvalidParameterSpecException
{
    if (paramSpec == null)
    {
        throw new NullPointerException("argument to getParameterSpec must not be null");
    }

    return localEngineGetParameterSpec(paramSpec);
}
 
Example 38
Project: jdk8u-jdk   File: PBEParameters.java   View source code 5 votes vote down vote up
protected void engineInit(AlgorithmParameterSpec paramSpec)
     throws InvalidParameterSpecException
{
    if (!(paramSpec instanceof PBEParameterSpec)) {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
    this.salt = ((PBEParameterSpec)paramSpec).getSalt().clone();
    this.iCount = ((PBEParameterSpec)paramSpec).getIterationCount();
    this.cipherParam = ((PBEParameterSpec)paramSpec).getParameterSpec();
 }
 
Example 39
Project: ipack   File: AlgorithmParametersSpi.java   View source code 5 votes vote down vote up
protected AlgorithmParameterSpec localEngineGetParameterSpec(
    Class paramSpec)
    throws InvalidParameterSpecException
{
    if (paramSpec == OAEPParameterSpec.class && currentSpec != null)
    {
        return currentSpec;
    }
    
    throw new InvalidParameterSpecException("unknown parameter spec passed to OAEP parameters object.");
}
 
Example 40
Project: ipack   File: AlgorithmParametersSpi.java   View source code 5 votes vote down vote up
protected AlgorithmParameterSpec localEngineGetParameterSpec(
    Class paramSpec)
    throws InvalidParameterSpecException
{
    if (paramSpec == PSSParameterSpec.class && currentSpec != null)
    {
        return currentSpec;
    }
    
    throw new InvalidParameterSpecException("unknown parameter spec passed to PSS parameters object.");
}