Code example for OAEPParameterSpec

Methods: getDigestAlgorithm, getMGFAlgorithm, getMGFParameters, getPSource

0
            } 
            else 
            { 
                throw new InvalidKeyException("unknown key type passed to RSA");
            } 
             
            if (params != null)
            { 
                OAEPParameterSpec   spec = (OAEPParameterSpec)params;
                 
                paramSpec = params;
                 
                if (!spec.getMGFAlgorithm().equalsIgnoreCase("MGF1") && !spec.getMGFAlgorithm().equals(PKCSObjectIdentifiers.id_mgf1.getId()))
                { 
                    throw new InvalidAlgorithmParameterException("unknown mask generation function specified");
                } 
                 
                if (!(spec.getMGFParameters() instanceof MGF1ParameterSpec))
                { 
                    throw new InvalidAlgorithmParameterException("unkown MGF parameters");
                } 
     
                Digest digest = JCEDigestUtil.getDigest(spec.getDigestAlgorithm());
 
                if (digest == null)
                { 
                    throw new InvalidAlgorithmParameterException("no match on digest algorithm: "+ spec.getDigestAlgorithm());
                } 
 
                MGF1ParameterSpec mgfParams = (MGF1ParameterSpec)spec.getMGFParameters();
                Digest mgfDigest = JCEDigestUtil.getDigest(mgfParams.getDigestAlgorithm());
                 
                if (mgfDigest == null)
                { 
                    throw new InvalidAlgorithmParameterException("no match on MGF digest algorithm: "+ mgfParams.getDigestAlgorithm());
                }