本文整理汇总了Java中java.security.spec.MGF1ParameterSpec.getDigestAlgorithm方法的典型用法代码示例。如果您正苦于以下问题:Java MGF1ParameterSpec.getDigestAlgorithm方法的具体用法?Java MGF1ParameterSpec.getDigestAlgorithm怎么用?Java MGF1ParameterSpec.getDigestAlgorithm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.security.spec.MGF1ParameterSpec
的用法示例。
在下文中一共展示了MGF1ParameterSpec.getDigestAlgorithm方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compareMGF
import java.security.spec.MGF1ParameterSpec; //导入方法依赖的package包/类
private static boolean compareMGF(OAEPParameterSpec s1,
OAEPParameterSpec s2) {
String alg1 = s1.getMGFAlgorithm();
String alg2 = s2.getMGFAlgorithm();
if (alg1.equals(alg2)) {
MGF1ParameterSpec mp1 = (MGF1ParameterSpec)s1.getMGFParameters();
MGF1ParameterSpec mp2 = (MGF1ParameterSpec)s2.getMGFParameters();
alg1 = mp1.getDigestAlgorithm();
alg2 = mp2.getDigestAlgorithm();
if (alg1.equals(alg2)) {
return true;
} else {
System.out.println("MGF's MD algos: " + alg1 + " vs " + alg2);
return false;
}
} else {
System.out.println("MGF algos: " + alg1 + " vs " + alg2);
return false;
}
}
示例2: initFromSpec
import java.security.spec.MGF1ParameterSpec; //导入方法依赖的package包/类
private void initFromSpec(
OAEPParameterSpec pSpec)
throws NoSuchPaddingException
{
MGF1ParameterSpec mgfParams = (MGF1ParameterSpec)pSpec.getMGFParameters();
Digest digest = DigestFactory.getDigest(mgfParams.getDigestAlgorithm());
if (digest == null)
{
throw new NoSuchPaddingException("no match on OAEP constructor for digest algorithm: "+ mgfParams.getDigestAlgorithm());
}
cipher = new OAEPEncoding(new RSABlindedEngine(), digest, ((PSource.PSpecified)pSpec.getPSource()).getValue());
paramSpec = pSpec;
}
示例3: initFromSpec
import java.security.spec.MGF1ParameterSpec; //导入方法依赖的package包/类
private void initFromSpec(
OAEPParameterSpec pSpec)
throws NoSuchPaddingException
{
MGF1ParameterSpec mgfParams = (MGF1ParameterSpec)pSpec.getMGFParameters();
Digest digest = DigestFactory.getDigest(mgfParams.getDigestAlgorithm());
if (digest == null)
{
throw new NoSuchPaddingException("no match on OAEP constructor for digest algorithm: "+ mgfParams.getDigestAlgorithm());
}
cipher = new BufferedAsymmetricBlockCipher(new OAEPEncoding(new ElGamalEngine(), digest, ((PSource.PSpecified)pSpec.getPSource()).getValue()));
paramSpec = pSpec;
}
示例4: RsaPssSha256
import java.security.spec.MGF1ParameterSpec; //导入方法依赖的package包/类
public RsaPssSha256()
{
super(AlgorithmIdentifiers.RSA_PSS_USING_SHA256, "SHA256withRSAandMGF1");
MGF1ParameterSpec mgf1pec = MGF1ParameterSpec.SHA256;
PSSParameterSpec pssSpec = new PSSParameterSpec(mgf1pec.getDigestAlgorithm(), MGF1, mgf1pec, 32, TRAILER);
setAlgorithmParameterSpec(pssSpec);
}
示例5: RsaPssSha384
import java.security.spec.MGF1ParameterSpec; //导入方法依赖的package包/类
public RsaPssSha384()
{
super(AlgorithmIdentifiers.RSA_PSS_USING_SHA384, "SHA384withRSAandMGF1");
MGF1ParameterSpec mgf1pec = MGF1ParameterSpec.SHA384;
PSSParameterSpec pssSpec = new PSSParameterSpec(mgf1pec.getDigestAlgorithm(), MGF1, mgf1pec, 48, TRAILER);
setAlgorithmParameterSpec(pssSpec);
}
示例6: RsaPssSha512
import java.security.spec.MGF1ParameterSpec; //导入方法依赖的package包/类
public RsaPssSha512()
{
super(AlgorithmIdentifiers.RSA_PSS_USING_SHA512, "SHA512withRSAandMGF1");
MGF1ParameterSpec mgf1pec = MGF1ParameterSpec.SHA512;
PSSParameterSpec pssSpec = new PSSParameterSpec(mgf1pec.getDigestAlgorithm(), MGF1, mgf1pec, 64, TRAILER);
setAlgorithmParameterSpec(pssSpec);
}
示例7: initFromSpec
import java.security.spec.MGF1ParameterSpec; //导入方法依赖的package包/类
private void initFromSpec(OAEPParameterSpec pSpec)
throws NoSuchPaddingException, NoSuchFieldException, IllegalAccessException
{
MGF1ParameterSpec mgfParams = (MGF1ParameterSpec)pSpec.getMGFParameters();
Digest digest = DigestFactory.getDigest(mgfParams.getDigestAlgorithm());
if (digest == null)
{
throw new NoSuchPaddingException("no match on OAEP constructor for digest algorithm: "+ mgfParams.getDigestAlgorithm());
}
cipher(new OAEPEncoding(new NativeRSAEngine(), digest, ((PSource.PSpecified)pSpec.getPSource()).getValue()));
set( pSpec, "paramSpec" );
}
示例8: engineSetParameter
import java.security.spec.MGF1ParameterSpec; //导入方法依赖的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");
}
}
示例9: engineSetParameter
import java.security.spec.MGF1ParameterSpec; //导入方法依赖的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");
}
}
示例10: engineSetParameter
import java.security.spec.MGF1ParameterSpec; //导入方法依赖的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);
}
}
示例11: engineSetParameter
import java.security.spec.MGF1ParameterSpec; //导入方法依赖的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");
}
}