本文整理匯總了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;
}