本文整理汇总了Java中javax.crypto.spec.OAEPParameterSpec.getMGFParameters方法的典型用法代码示例。如果您正苦于以下问题:Java OAEPParameterSpec.getMGFParameters方法的具体用法?Java OAEPParameterSpec.getMGFParameters怎么用?Java OAEPParameterSpec.getMGFParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.crypto.spec.OAEPParameterSpec
的用法示例。
在下文中一共展示了OAEPParameterSpec.getMGFParameters方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compareMGF
import javax.crypto.spec.OAEPParameterSpec; //导入方法依赖的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 javax.crypto.spec.OAEPParameterSpec; //导入方法依赖的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 javax.crypto.spec.OAEPParameterSpec; //导入方法依赖的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: engineInit
import javax.crypto.spec.OAEPParameterSpec; //导入方法依赖的package包/类
protected void engineInit(AlgorithmParameterSpec paramSpec)
throws InvalidParameterSpecException {
if (!(paramSpec instanceof OAEPParameterSpec)) {
throw new InvalidParameterSpecException
("Inappropriate parameter specification");
}
OAEPParameterSpec spec = (OAEPParameterSpec) paramSpec;
mdName = spec.getDigestAlgorithm();
String mgfName = spec.getMGFAlgorithm();
if (!mgfName.equalsIgnoreCase("MGF1")) {
throw new InvalidParameterSpecException("Unsupported mgf " +
mgfName + "; MGF1 only");
}
AlgorithmParameterSpec mgfSpec = spec.getMGFParameters();
if (!(mgfSpec instanceof MGF1ParameterSpec)) {
throw new InvalidParameterSpecException("Inappropriate mgf " +
"parameters; non-null MGF1ParameterSpec only");
}
this.mgfSpec = (MGF1ParameterSpec) mgfSpec;
PSource pSrc = spec.getPSource();
if (pSrc.getAlgorithm().equals("PSpecified")) {
p = ((PSource.PSpecified) pSrc).getValue();
} else {
throw new InvalidParameterSpecException("Unsupported pSource " +
pSrc.getAlgorithm() + "; PSpecified only");
}
}
示例5: readOAEPParameters
import javax.crypto.spec.OAEPParameterSpec; //导入方法依赖的package包/类
private void readOAEPParameters(OAEPParameterSpec spec)
throws InvalidAlgorithmParameterException {
String mgfAlgUpper = spec.getMGFAlgorithm().toUpperCase(Locale.US);
AlgorithmParameterSpec mgfSpec = spec.getMGFParameters();
if ((!EvpMdRef.MGF1_ALGORITHM_NAME.equals(mgfAlgUpper)
&& !EvpMdRef.MGF1_OID.equals(mgfAlgUpper))
|| !(mgfSpec instanceof MGF1ParameterSpec)) {
throw new InvalidAlgorithmParameterException(
"Only MGF1 supported as mask generation function");
}
MGF1ParameterSpec mgf1spec = (MGF1ParameterSpec) mgfSpec;
String oaepAlgUpper = spec.getDigestAlgorithm().toUpperCase(Locale.US);
try {
oaepMd = EvpMdRef.getEVP_MDByJcaDigestAlgorithmStandardName(oaepAlgUpper);
oaepMdSizeBytes =
EvpMdRef.getDigestSizeBytesByJcaDigestAlgorithmStandardName(oaepAlgUpper);
mgf1Md = EvpMdRef.getEVP_MDByJcaDigestAlgorithmStandardName(
mgf1spec.getDigestAlgorithm());
} catch (NoSuchAlgorithmException e) {
throw new InvalidAlgorithmParameterException(e);
}
PSource pSource = spec.getPSource();
if (!"PSpecified".equals(pSource.getAlgorithm())
|| !(pSource instanceof PSource.PSpecified)) {
throw new InvalidAlgorithmParameterException(
"Only PSpecified accepted for PSource");
}
label = ((PSource.PSpecified) pSource).getValue();
}
示例6: initFromSpec
import javax.crypto.spec.OAEPParameterSpec; //导入方法依赖的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" );
}