Code example for PSSParameterSpec

Methods: getDigestAlgorithm, getMGFAlgorithm, getMGFParameters, getSaltLength, getTrailerField

0
paramSpec = (PSSParameterSpec)params;
             
            if (originalSpec != null)
            { 
                if (!JCEDigestUtil.isSameDigest(originalSpec.getDigestAlgorithm(), paramSpec.getDigestAlgorithm()))
                { 
                    throw new InvalidParameterException("parameter must be using " + originalSpec.getDigestAlgorithm());
                } 
            } 
            if (!paramSpec.getMGFAlgorithm().equalsIgnoreCase("MGF1") && !paramSpec.getMGFAlgorithm().equals(PKCSObjectIdentifiers.id_mgf1.getId()))
            { 
                throw new InvalidParameterException("unknown mask generation function specified");
            } 
             
            if (!(paramSpec.getMGFParameters() instanceof MGF1ParameterSpec))
            { 
                throw new InvalidParameterException("unkown MGF parameters");
            } 
             
            MGF1ParameterSpec   mgfParams = (MGF1ParameterSpec)paramSpec.getMGFParameters();
             
            if (!JCEDigestUtil.isSameDigest(mgfParams.getDigestAlgorithm(), paramSpec.getDigestAlgorithm()))
            { 
                throw new InvalidParameterException("digest algorithm for MGF should be the same as for PSS parameters.");
            } 
             
            digest = JCEDigestUtil.getDigest(mgfParams.getDigestAlgorithm());
             
            if (digest == null)
            { 
                throw new InvalidParameterException("no match on MGF digest algorithm: "+ mgfParams.getDigestAlgorithm());
            } 
             
            this.saltLength = paramSpec.getSaltLength();
            this.trailer = getTrailer(paramSpec.getTrailerField());
        } 
        else 
        { 
            throw new InvalidParameterException("Only PSSParameterSpec supported");
        }