本文整理汇总了Java中java.security.spec.PSSParameterSpec.getMGFParameters方法的典型用法代码示例。如果您正苦于以下问题:Java PSSParameterSpec.getMGFParameters方法的具体用法?Java PSSParameterSpec.getMGFParameters怎么用?Java PSSParameterSpec.getMGFParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.security.spec.PSSParameterSpec
的用法示例。
在下文中一共展示了PSSParameterSpec.getMGFParameters方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: engineGetEncoded
import java.security.spec.PSSParameterSpec; //导入方法依赖的package包/类
/**
* Return the PKCS#1 ASN.1 structure RSASSA-PSS-params.
*/
protected byte[] engineGetEncoded()
throws IOException
{
PSSParameterSpec pssSpec = currentSpec;
AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
DigestFactory.getOID(pssSpec.getDigestAlgorithm()),
DERNull.INSTANCE);
MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters();
AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
PKCSObjectIdentifiers.id_mgf1,
new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new ASN1Integer(pssSpec.getSaltLength()), new ASN1Integer(pssSpec.getTrailerField()));
return pssP.getEncoded("DER");
}
示例2: engineSetParameter
import java.security.spec.PSSParameterSpec; //导入方法依赖的package包/类
protected void engineSetParameter(
AlgorithmParameterSpec params)
throws InvalidParameterException
{
if (params instanceof PSSParameterSpec)
{
PSSParameterSpec newParamSpec = (PSSParameterSpec)params;
if (originalSpec != null)
{
if (!DigestFactory.isSameDigest(originalSpec.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm()))
{
throw new InvalidParameterException("parameter must be using " + originalSpec.getDigestAlgorithm());
}
}
if (!newParamSpec.getMGFAlgorithm().equalsIgnoreCase("MGF1") && !newParamSpec.getMGFAlgorithm().equals(PKCSObjectIdentifiers.id_mgf1.getId()))
{
throw new InvalidParameterException("unknown mask generation function specified");
}
if (!(newParamSpec.getMGFParameters() instanceof MGF1ParameterSpec))
{
throw new InvalidParameterException("unkown MGF parameters");
}
MGF1ParameterSpec mgfParams = (MGF1ParameterSpec)newParamSpec.getMGFParameters();
if (!DigestFactory.isSameDigest(mgfParams.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm()))
{
throw new InvalidParameterException("digest algorithm for MGF should be the same as for PSS parameters.");
}
Digest newDigest = DigestFactory.getDigest(mgfParams.getDigestAlgorithm());
if (newDigest == null)
{
throw new InvalidParameterException("no match on MGF digest algorithm: "+ mgfParams.getDigestAlgorithm());
}
this.engineParams = null;
this.paramSpec = newParamSpec;
this.mgfDigest = newDigest;
this.saltLength = paramSpec.getSaltLength();
this.trailer = getTrailer(paramSpec.getTrailerField());
setupContentDigest();
}
else
{
throw new InvalidParameterException("Only PSSParameterSpec supported");
}
}
示例3: engineSetParameter
import java.security.spec.PSSParameterSpec; //导入方法依赖的package包/类
@Override
protected void engineSetParameter(AlgorithmParameterSpec params)
throws InvalidParameterException {
if (params instanceof PSSParameterSpec) {
PSSParameterSpec newParamSpec = (PSSParameterSpec) params;
if (originalSpec != null) {
if (!DigestFactory.isSameDigest(originalSpec.getDigestAlgorithm(),
newParamSpec.getDigestAlgorithm())) {
throw new InvalidParameterException("parameter must be using "
+ originalSpec.getDigestAlgorithm());
}
}
if (!newParamSpec.getMGFAlgorithm().equalsIgnoreCase("MGF1")
&& !newParamSpec.getMGFAlgorithm().equals(
PKCSObjectIdentifiers.id_mgf1.getId())) {
throw new InvalidParameterException("unknown mask generation function specified");
}
if (!(newParamSpec.getMGFParameters() instanceof MGF1ParameterSpec)) {
throw new InvalidParameterException("unkown MGF parameters");
}
MGF1ParameterSpec mgfParams = (MGF1ParameterSpec) newParamSpec.getMGFParameters();
if (!DigestFactory.isSameDigest(mgfParams.getDigestAlgorithm(),
newParamSpec.getDigestAlgorithm())) {
throw new InvalidParameterException(
"digest algorithm for MGF should be the same as for PSS parameters.");
}
Digest newDigest = DigestFactory.getDigest(mgfParams.getDigestAlgorithm());
if (newDigest == null) {
throw new InvalidParameterException(
"no match on MGF digest algorithm: " + mgfParams.getDigestAlgorithm());
}
this.engineParams = null;
this.paramSpec = newParamSpec;
this.mgfDigest = newDigest;
this.saltLength = paramSpec.getSaltLength();
this.trailer = getTrailer(paramSpec.getTrailerField());
setupContentDigest();
} else {
throw new InvalidParameterException("only PSSParameterSpec supported");
}
}
示例4: engineSetParameter
import java.security.spec.PSSParameterSpec; //导入方法依赖的package包/类
@Override
protected final void engineSetParameter(AlgorithmParameterSpec params)
throws InvalidAlgorithmParameterException {
if (!(params instanceof PSSParameterSpec)) {
throw new InvalidAlgorithmParameterException(
"Unsupported parameter: " + params + ". Only "
+ PSSParameterSpec.class.getName() + " supported");
}
PSSParameterSpec spec = (PSSParameterSpec) params;
String specContentDigest = EvpMdRef
.getJcaDigestAlgorithmStandardName(spec.getDigestAlgorithm());
if (specContentDigest == null) {
throw new InvalidAlgorithmParameterException(
"Unsupported content digest algorithm: " + spec.getDigestAlgorithm());
} else if (!contentDigestAlgorithm.equalsIgnoreCase(specContentDigest)) {
throw new InvalidAlgorithmParameterException(
"Changing content digest algorithm not supported");
}
String specMgfAlgorithm = spec.getMGFAlgorithm();
if ((!EvpMdRef.MGF1_ALGORITHM_NAME.equalsIgnoreCase(specMgfAlgorithm))
&& (!EvpMdRef.MGF1_OID.equals(specMgfAlgorithm))) {
throw new InvalidAlgorithmParameterException(
"Unsupported MGF algorithm: " + specMgfAlgorithm + ". Only "
+ EvpMdRef.MGF1_ALGORITHM_NAME + " supported");
}
AlgorithmParameterSpec mgfSpec = spec.getMGFParameters();
if (!(mgfSpec instanceof MGF1ParameterSpec)) {
throw new InvalidAlgorithmParameterException(
"Unsupported MGF parameters: " + mgfSpec + ". Only "
+ MGF1ParameterSpec.class.getName() + " supported");
}
MGF1ParameterSpec specMgf1Spec = (MGF1ParameterSpec) spec.getMGFParameters();
String specMgf1Digest = EvpMdRef
.getJcaDigestAlgorithmStandardName(specMgf1Spec.getDigestAlgorithm());
if (specMgf1Digest == null) {
throw new InvalidAlgorithmParameterException(
"Unsupported MGF1 digest algorithm: " + specMgf1Spec.getDigestAlgorithm());
}
long specMgf1EvpMdRef;
try {
specMgf1EvpMdRef = EvpMdRef
.getEVP_MDByJcaDigestAlgorithmStandardName(specMgf1Digest);
} catch (NoSuchAlgorithmException e) {
throw new ProviderException("Failed to obtain EVP_MD for " + specMgf1Digest, e);
}
int specSaltSizeBytes = spec.getSaltLength();
if (specSaltSizeBytes < 0) {
throw new InvalidAlgorithmParameterException(
"Salt length must be non-negative: " + specSaltSizeBytes);
}
int specTrailer = spec.getTrailerField();
if (specTrailer != TRAILER_FIELD_BC_ID) {
throw new InvalidAlgorithmParameterException(
"Unsupported trailer field: " + specTrailer + ". Only "
+ TRAILER_FIELD_BC_ID + " supported");
}
this.mgf1DigestAlgorithm = specMgf1Digest;
this.mgf1EvpMdRef = specMgf1EvpMdRef;
this.saltSizeBytes = specSaltSizeBytes;
long ctx = getEVP_PKEY_CTX();
if (ctx != 0) {
configureEVP_PKEY_CTX(ctx);
}
}
示例5: engineSetParameter
import java.security.spec.PSSParameterSpec; //导入方法依赖的package包/类
protected void engineSetParameter(
AlgorithmParameterSpec params)
throws InvalidAlgorithmParameterException
{
if (params instanceof PSSParameterSpec)
{
PSSParameterSpec newParamSpec = (PSSParameterSpec)params;
if (originalSpec != null)
{
if (!DigestFactory.isSameDigest(originalSpec.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm()))
{
throw new InvalidAlgorithmParameterException("parameter must be using " + originalSpec.getDigestAlgorithm());
}
}
if (!newParamSpec.getMGFAlgorithm().equalsIgnoreCase("MGF1") && !newParamSpec.getMGFAlgorithm().equals(PKCSObjectIdentifiers.id_mgf1.getId()))
{
throw new InvalidAlgorithmParameterException("unknown mask generation function specified");
}
if (!(newParamSpec.getMGFParameters() instanceof MGF1ParameterSpec))
{
throw new InvalidAlgorithmParameterException("unknown MGF parameters");
}
MGF1ParameterSpec mgfParams = (MGF1ParameterSpec)newParamSpec.getMGFParameters();
if (!DigestFactory.isSameDigest(mgfParams.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm()))
{
throw new InvalidAlgorithmParameterException("digest algorithm for MGF should be the same as for PSS parameters.");
}
Digest newDigest = DigestFactory.getDigest(mgfParams.getDigestAlgorithm());
if (newDigest == null)
{
throw new InvalidAlgorithmParameterException("no match on MGF digest algorithm: "+ mgfParams.getDigestAlgorithm());
}
this.engineParams = null;
this.paramSpec = newParamSpec;
this.mgfDigest = newDigest;
this.saltLength = paramSpec.getSaltLength();
this.trailer = getTrailer(paramSpec.getTrailerField());
setupContentDigest();
}
else
{
throw new InvalidAlgorithmParameterException("Only PSSParameterSpec supported");
}
}