本文整理汇总了Java中org.bouncycastle.asn1.x509.AlgorithmIdentifier.getAlgorithm方法的典型用法代码示例。如果您正苦于以下问题:Java AlgorithmIdentifier.getAlgorithm方法的具体用法?Java AlgorithmIdentifier.getAlgorithm怎么用?Java AlgorithmIdentifier.getAlgorithm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.asn1.x509.AlgorithmIdentifier
的用法示例。
在下文中一共展示了AlgorithmIdentifier.getAlgorithm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入方法依赖的package包/类
public PKCS12MacCalculatorBuilder get(final AlgorithmIdentifier algorithmIdentifier)
{
return new PKCS12MacCalculatorBuilder()
{
public MacCalculator build(final char[] password)
throws OperatorCreationException
{
PKCS12PBEParams pbeParams = PKCS12PBEParams.getInstance(algorithmIdentifier.getParameters());
return PKCS12PBEUtils.createMacCalculator(algorithmIdentifier.getAlgorithm(), digestProvider.get(algorithmIdentifier), pbeParams, password);
}
public AlgorithmIdentifier getDigestAlgorithmIdentifier()
{
return new AlgorithmIdentifier(algorithmIdentifier.getAlgorithm(), DERNull.INSTANCE);
}
};
}
示例2: getSigOrMacAlgoCode
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入方法依赖的package包/类
public static AlgorithmCode getSigOrMacAlgoCode(AlgorithmIdentifier algId)
throws NoSuchAlgorithmException {
ASN1ObjectIdentifier oid = algId.getAlgorithm();
AlgorithmCode code = algOidToCodeMap.get(oid);
if (code != null) {
return code;
}
if (PKCSObjectIdentifiers.id_RSASSA_PSS.equals(oid)) {
RSASSAPSSparams param = RSASSAPSSparams.getInstance(algId.getParameters());
ASN1ObjectIdentifier digestAlgOid = param.getHashAlgorithm().getAlgorithm();
code = digestToMgf1AlgCodeMap.get(digestAlgOid);
if (code == null) {
throw new NoSuchAlgorithmException("unsupported digest algorithm " + digestAlgOid);
}
return code;
} else {
throw new NoSuchAlgorithmException("unsupported signature algorithm "
+ oid.getId());
}
}
示例3: getSignatureAlgoName
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入方法依赖的package包/类
public static String getSignatureAlgoName(AlgorithmIdentifier sigAlgId)
throws NoSuchAlgorithmException {
ParamUtil.requireNonNull("sigAlgId", sigAlgId);
ASN1ObjectIdentifier algOid = sigAlgId.getAlgorithm();
String name = null;
if (PKCSObjectIdentifiers.id_RSASSA_PSS.equals(algOid)) {
RSASSAPSSparams param = RSASSAPSSparams.getInstance(sigAlgId.getParameters());
ASN1ObjectIdentifier digestAlgOid = param.getHashAlgorithm().getAlgorithm();
name = digestOidToMgf1SigNameMap.get(digestAlgOid);
if (name == null) {
throw new NoSuchAlgorithmException("unsupported digest algorithm " + digestAlgOid);
}
} else {
name = sigAlgOidToNameMap.get(algOid);
}
if (name == null) {
throw new NoSuchAlgorithmException("unsupported signature algorithm " + algOid.getId());
}
return name;
}
示例4: isRSASigAlgId
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入方法依赖的package包/类
public static boolean isRSASigAlgId(AlgorithmIdentifier algId) {
ParamUtil.requireNonNull("algId", algId);
ASN1ObjectIdentifier oid = algId.getAlgorithm();
if (PKCSObjectIdentifiers.sha1WithRSAEncryption.equals(oid)
|| PKCSObjectIdentifiers.sha224WithRSAEncryption.equals(oid)
|| PKCSObjectIdentifiers.sha256WithRSAEncryption.equals(oid)
|| PKCSObjectIdentifiers.sha384WithRSAEncryption.equals(oid)
|| PKCSObjectIdentifiers.sha512WithRSAEncryption.equals(oid)
|| NISTObjectIdentifiers.id_rsassa_pkcs1_v1_5_with_sha3_224.equals(oid)
|| NISTObjectIdentifiers.id_rsassa_pkcs1_v1_5_with_sha3_256.equals(oid)
|| NISTObjectIdentifiers.id_rsassa_pkcs1_v1_5_with_sha3_384.equals(oid)
|| NISTObjectIdentifiers.id_rsassa_pkcs1_v1_5_with_sha3_512.equals(oid)
|| PKCSObjectIdentifiers.id_RSASSA_PSS.equals(oid)) {
return true;
}
return false;
}
示例5: isECDSASigAlg
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入方法依赖的package包/类
private static boolean isECDSASigAlg(AlgorithmIdentifier algId) {
ParamUtil.requireNonNull("algId", algId);
ASN1ObjectIdentifier oid = algId.getAlgorithm();
if (X9ObjectIdentifiers.ecdsa_with_SHA1.equals(oid)
|| X9ObjectIdentifiers.ecdsa_with_SHA224.equals(oid)
|| X9ObjectIdentifiers.ecdsa_with_SHA256.equals(oid)
|| X9ObjectIdentifiers.ecdsa_with_SHA384.equals(oid)
|| X9ObjectIdentifiers.ecdsa_with_SHA512.equals(oid)
|| NISTObjectIdentifiers.id_ecdsa_with_sha3_224.equals(oid)
|| NISTObjectIdentifiers.id_ecdsa_with_sha3_256.equals(oid)
|| NISTObjectIdentifiers.id_ecdsa_with_sha3_384.equals(oid)
|| NISTObjectIdentifiers.id_ecdsa_with_sha3_512.equals(oid)) {
return true;
}
return false;
}
示例6: isDSASigAlg
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入方法依赖的package包/类
public static boolean isDSASigAlg(AlgorithmIdentifier algId) {
ParamUtil.requireNonNull("algId", algId);
ASN1ObjectIdentifier oid = algId.getAlgorithm();
if (X9ObjectIdentifiers.id_dsa_with_sha1.equals(oid)
|| NISTObjectIdentifiers.dsa_with_sha224.equals(oid)
|| NISTObjectIdentifiers.dsa_with_sha256.equals(oid)
|| NISTObjectIdentifiers.dsa_with_sha384.equals(oid)
|| NISTObjectIdentifiers.dsa_with_sha512.equals(oid)
|| NISTObjectIdentifiers.id_dsa_with_sha3_224.equals(oid)
|| NISTObjectIdentifiers.id_dsa_with_sha3_256.equals(oid)
|| NISTObjectIdentifiers.id_dsa_with_sha3_384.equals(oid)
|| NISTObjectIdentifiers.id_dsa_with_sha3_512.equals(oid)) {
return true;
}
return false;
}
示例7: extractDigesetAlgFromSigAlg
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入方法依赖的package包/类
public static AlgorithmIdentifier extractDigesetAlgFromSigAlg( AlgorithmIdentifier sigAlgId)
throws NoSuchAlgorithmException {
ASN1ObjectIdentifier algOid = sigAlgId.getAlgorithm();
ASN1ObjectIdentifier digestAlgOid;
if (PKCSObjectIdentifiers.id_RSASSA_PSS.equals(algOid)) {
ASN1Encodable asn1Encodable = sigAlgId.getParameters();
RSASSAPSSparams param = RSASSAPSSparams.getInstance(asn1Encodable);
digestAlgOid = param.getHashAlgorithm().getAlgorithm();
} else {
HashAlgoType digestAlg = sigAlgOidToDigestMap.get(algOid);
if (digestAlg == null) {
throw new NoSuchAlgorithmException("unknown signature algorithm " + algOid.getId());
}
digestAlgOid = digestAlg.oid();
}
return new AlgorithmIdentifier(digestAlgOid, DERNull.INSTANCE);
}
示例8: fixAlgID
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入方法依赖的package包/类
AlgorithmIdentifier fixAlgID(AlgorithmIdentifier algId)
{
if (algId.getParameters() == null)
{
return new AlgorithmIdentifier(algId.getAlgorithm(), DERNull.INSTANCE);
}
return algId;
}
示例9: getSigOrMacAlgoName
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入方法依赖的package包/类
public static String getSigOrMacAlgoName(AlgorithmIdentifier sigAlgId)
throws NoSuchAlgorithmException {
ParamUtil.requireNonNull("sigAlgId", sigAlgId);
ASN1ObjectIdentifier algOid = sigAlgId.getAlgorithm();
String name = macAlgOidToNameMap.get(algOid);
return (name != null) ? name : getSignatureAlgoName(sigAlgId);
}
示例10: isPlainECDSASigAlg
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入方法依赖的package包/类
public static boolean isPlainECDSASigAlg(AlgorithmIdentifier algId) {
ParamUtil.requireNonNull("algId", algId);
ASN1ObjectIdentifier oid = algId.getAlgorithm();
if (BSIObjectIdentifiers.ecdsa_plain_SHA1.equals(oid)
|| BSIObjectIdentifiers.ecdsa_plain_SHA224.equals(oid)
|| BSIObjectIdentifiers.ecdsa_plain_SHA256.equals(oid)
|| BSIObjectIdentifiers.ecdsa_plain_SHA384.equals(oid)
|| BSIObjectIdentifiers.ecdsa_plain_SHA512.equals(oid)) {
return true;
}
return false;
}
示例11: isSm2SigAlg
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入方法依赖的package包/类
public static boolean isSm2SigAlg(AlgorithmIdentifier algId) {
ParamUtil.requireNonNull("algId", algId);
ASN1ObjectIdentifier oid = algId.getAlgorithm();
if (GMObjectIdentifiers.sm2sign_with_sm3.equals(oid)) {
return true;
}
// other algorithms not supported yet.
return false;
}
示例12: extractHashAlgoFromMacAlg
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入方法依赖的package包/类
public static HashAlgoType extractHashAlgoFromMacAlg(AlgorithmIdentifier macAlg) {
ASN1ObjectIdentifier oid = macAlg.getAlgorithm();
HashAlgoType hashAlgo = macAlgOidToDigestMap.get(oid);
if (hashAlgo == null) {
throw new IllegalArgumentException("unknown algorithm identifier " + oid.getId());
}
return hashAlgo;
}
示例13: createPSSRSASigner
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入方法依赖的package包/类
public static PSSSigner createPSSRSASigner(AlgorithmIdentifier sigAlgId,
AsymmetricBlockCipher cipher) throws XiSecurityException {
ParamUtil.requireNonNull("sigAlgId", sigAlgId);
if (!PKCSObjectIdentifiers.id_RSASSA_PSS.equals(sigAlgId.getAlgorithm())) {
throw new XiSecurityException("signature algorithm " + sigAlgId.getAlgorithm()
+ " is not allowed");
}
AlgorithmIdentifier digAlgId;
try {
digAlgId = AlgorithmUtil.extractDigesetAlgFromSigAlg(sigAlgId);
} catch (NoSuchAlgorithmException ex) {
throw new XiSecurityException(ex.getMessage(), ex);
}
RSASSAPSSparams param = RSASSAPSSparams.getInstance(sigAlgId.getParameters());
AlgorithmIdentifier mfgDigAlgId = AlgorithmIdentifier.getInstance(
param.getMaskGenAlgorithm().getParameters());
Digest dig = getDigest(digAlgId);
Digest mfgDig = getDigest(mfgDigAlgId);
int saltSize = param.getSaltLength().intValue();
int trailerField = param.getTrailerField().intValue();
AsymmetricBlockCipher tmpCipher = (cipher == null) ? new RSABlindedEngine() : cipher;
return new PSSSigner(tmpCipher, dig, mfgDig, saltSize, getTrailer(trailerField));
}
示例14: P11MacContentSigner
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入方法依赖的package包/类
P11MacContentSigner(P11CryptService cryptService, P11EntityIdentifier identityId,
AlgorithmIdentifier macAlgId) throws XiSecurityException, P11TokenException {
this.identityId = ParamUtil.requireNonNull("identityId", identityId);
this.cryptService = ParamUtil.requireNonNull("cryptService", cryptService);
this.algorithmIdentifier = ParamUtil.requireNonNull("macAlgId", macAlgId);
try {
this.encodedAlgorithmIdentifier = algorithmIdentifier.getEncoded();
} catch (IOException ex) {
throw new XiSecurityException("could not encode AlgorithmIdentifier", ex);
}
ASN1ObjectIdentifier oid = macAlgId.getAlgorithm();
if (PKCSObjectIdentifiers.id_hmacWithSHA1.equals(oid)) {
mechanism = PKCS11Constants.CKM_SHA_1_HMAC;
} else if (PKCSObjectIdentifiers.id_hmacWithSHA224.equals(oid)) {
mechanism = PKCS11Constants.CKM_SHA224_HMAC;
} else if (PKCSObjectIdentifiers.id_hmacWithSHA256.equals(oid)) {
mechanism = PKCS11Constants.CKM_SHA256_HMAC;
} else if (PKCSObjectIdentifiers.id_hmacWithSHA384.equals(oid)) {
mechanism = PKCS11Constants.CKM_SHA384_HMAC;
} else if (PKCSObjectIdentifiers.id_hmacWithSHA512.equals(oid)) {
mechanism = PKCS11Constants.CKM_SHA512_HMAC;
} else if (NISTObjectIdentifiers.id_hmacWithSHA3_224.equals(oid)) {
mechanism = PKCS11Constants.CKM_SHA3_224_HMAC;
} else if (NISTObjectIdentifiers.id_hmacWithSHA3_256.equals(oid)) {
mechanism = PKCS11Constants.CKM_SHA3_256_HMAC;
} else if (NISTObjectIdentifiers.id_hmacWithSHA3_384.equals(oid)) {
mechanism = PKCS11Constants.CKM_SHA3_384_HMAC;
} else if (NISTObjectIdentifiers.id_hmacWithSHA3_512.equals(oid)) {
mechanism = PKCS11Constants.CKM_SHA3_512_HMAC;
} else {
throw new IllegalArgumentException("unknown algorithm identifier " + oid.getId());
}
this.outputStream = new ByteArrayOutputStream();
}
示例15: createSigner
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入方法依赖的package包/类
public ConcurrentContentSigner createSigner(AlgorithmIdentifier signatureAlgId,
int parallelism, SecureRandom random) throws XiSecurityException {
ParamUtil.requireNonNull("signatureAlgId", signatureAlgId);
ParamUtil.requireMin("parallelism", parallelism, 1);
List<XiContentSigner> signers = new ArrayList<>(parallelism);
boolean gmac = false;
ASN1ObjectIdentifier oid = signatureAlgId.getAlgorithm();
if (oid.equals(NISTObjectIdentifiers.id_aes128_GCM)
|| oid.equals(NISTObjectIdentifiers.id_aes192_GCM)
|| oid.equals(NISTObjectIdentifiers.id_aes256_GCM)) {
gmac = true;
}
for (int i = 0; i < parallelism; i++) {
XiContentSigner signer;
if (gmac) {
signer = new AESGmacContentSigner(oid, key);
} else {
signer = new HmacContentSigner(signatureAlgId, key);
}
signers.add(signer);
}
final boolean mac = true;
DfltConcurrentContentSigner concurrentSigner;
try {
concurrentSigner = new DfltConcurrentContentSigner(mac, signers, key);
} catch (NoSuchAlgorithmException ex) {
throw new XiSecurityException(ex.getMessage(), ex);
}
concurrentSigner.setSha1DigestOfMacKey(HashAlgoType.SHA1.hash(key.getEncoded()));
return concurrentSigner;
}