當前位置: 首頁>>代碼示例>>Java>>正文


Java AlgorithmIdentifier.getAlgorithm方法代碼示例

本文整理匯總了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);
        }
    };
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:19,代碼來源:BcPKCS12MacCalculatorBuilderProvider.java

示例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());
    }
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:22,代碼來源:AlgorithmUtil.java

示例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;
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:23,代碼來源:AlgorithmUtil.java

示例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;
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:19,代碼來源:AlgorithmUtil.java

示例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;
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:19,代碼來源:AlgorithmUtil.java

示例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;
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:19,代碼來源:AlgorithmUtil.java

示例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);
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:20,代碼來源:AlgorithmUtil.java

示例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;
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:10,代碼來源:CMSSignedHelper.java

示例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);
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:8,代碼來源:AlgorithmUtil.java

示例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;
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:15,代碼來源:AlgorithmUtil.java

示例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;
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:13,代碼來源:AlgorithmUtil.java

示例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;
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:9,代碼來源:AlgorithmUtil.java

示例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));
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:30,代碼來源:SignerUtil.java

示例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();
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:37,代碼來源:P11MacContentSigner.java

示例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;
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:37,代碼來源:SoftTokenMacContentSignerBuilder.java


注:本文中的org.bouncycastle.asn1.x509.AlgorithmIdentifier.getAlgorithm方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。