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


Java AlgorithmIdentifier類代碼示例

本文整理匯總了Java中org.bouncycastle.asn1.x509.AlgorithmIdentifier的典型用法代碼示例。如果您正苦於以下問題:Java AlgorithmIdentifier類的具體用法?Java AlgorithmIdentifier怎麽用?Java AlgorithmIdentifier使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AlgorithmIdentifier類屬於org.bouncycastle.asn1.x509包,在下文中一共展示了AlgorithmIdentifier類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: determineKeyEncAlg

import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //導入依賴的package包/類
static AlgorithmIdentifier determineKeyEncAlg(KeyParameter key)
{
    int length = key.getKey().length * 8;
    ASN1ObjectIdentifier wrapOid;

    if (length == 128)
    {
        wrapOid = NISTObjectIdentifiers.id_aes128_wrap;
    }
    else if (length == 192)
    {
        wrapOid = NISTObjectIdentifiers.id_aes192_wrap;
    }
    else if (length == 256)
    {
        wrapOid = NISTObjectIdentifiers.id_aes256_wrap;
    }
    else
    {
        throw new IllegalArgumentException("illegal keysize in AES");
    }

    return new AlgorithmIdentifier(wrapOid); // parameters absent
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:25,代碼來源:AESUtil.java

示例2: getAlgorithmIdentifier

import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //導入依賴的package包/類
protected static AlgorithmIdentifier getAlgorithmIdentifier(
    PublicKey key)
    throws CertPathValidatorException
{
    try
    {
        ASN1InputStream aIn = new ASN1InputStream(key.getEncoded());

        SubjectPublicKeyInfo info = SubjectPublicKeyInfo.getInstance(aIn.readObject());

        return info.getAlgorithmId();
    }
    catch (Exception e)
    {
        throw new ExtCertPathValidatorException("Subject public key cannot be decoded.", e);
    }
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:18,代碼來源:CertPathValidatorUtilities.java

示例3: getPublicKey

import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //導入依賴的package包/類
public PublicKey getPublicKey(String provider)
    throws NoSuchAlgorithmException, NoSuchProviderException, 
           InvalidKeyException
{
    SubjectPublicKeyInfo subjectPKInfo = pkac.getSubjectPublicKeyInfo();
    try
    {
        DERBitString bStr = new DERBitString(subjectPKInfo);
        X509EncodedKeySpec xspec = new X509EncodedKeySpec(bStr.getBytes());
        

        AlgorithmIdentifier keyAlg = subjectPKInfo.getAlgorithm();

        KeyFactory factory =
            KeyFactory.getInstance(keyAlg.getAlgorithm().getId(),provider);

        return factory.generatePublic(xspec);
                       
    }
    catch (Exception e)
    {
        throw new InvalidKeyException("error encoding public key");
    }
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:25,代碼來源:SignedPublicKeyAndChallenge.java

示例4: getSignatureName

import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //導入依賴的package包/類
static String getSignatureName(
    AlgorithmIdentifier sigAlgId)
{
    ASN1Encodable params = sigAlgId.getParameters();

    if (params != null && !DERNull.INSTANCE.equals(params))
    {
        if (sigAlgId.getObjectId().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
        {
            RSASSAPSSparams rsaParams = RSASSAPSSparams.getInstance(params);
            return getDigestAlgName(rsaParams.getHashAlgorithm().getObjectId()) + "withRSAandMGF1";
        }
    }

    return sigAlgId.getObjectId().getId();
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:17,代碼來源:PKCS10CertificationRequest.java

示例5: getEncoded

import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //導入依賴的package包/類
/**
 * Return the keyData to encode in the SubjectPublicKeyInfo structure.
 * <p/>
 * The ASN.1 definition of the key structure is
 * <p/>
 * <pre>
 *       McEliecePublicKey ::= SEQUENCE {
 *         n           Integer      -- length of the code
 *         t           Integer      -- error correcting capability
 *         matrixG     OctetString  -- generator matrix as octet string
 *       }
 * </pre>
 *
 * @return the keyData to encode in the SubjectPublicKeyInfo structure
 */
public byte[] getEncoded()
{
    McEliecePublicKey key = new McEliecePublicKey(new ASN1ObjectIdentifier(oid), n, t, g);
    AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(this.getOID(), DERNull.INSTANCE);

    try
    {
        SubjectPublicKeyInfo subjectPublicKeyInfo = new SubjectPublicKeyInfo(algorithmIdentifier, key);

        return subjectPublicKeyInfo.getEncoded();
    }
    catch (IOException e)
    {
        return null;
    }
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:32,代碼來源:BCMcEliecePublicKey.java

示例6: 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

示例7: getValueDecryptor

import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //導入依賴的package包/類
public InputDecryptor getValueDecryptor(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentEncryptionAlgorithm, byte[] encryptedContentEncryptionKey)
    throws CRMFException
{
    Key secretKey = extractSecretKey(keyEncryptionAlgorithm, contentEncryptionAlgorithm, encryptedContentEncryptionKey);

    final Cipher dataCipher = helper.createContentCipher(secretKey, contentEncryptionAlgorithm);

    return new InputDecryptor()
    {
        public AlgorithmIdentifier getAlgorithmIdentifier()
        {
            return contentEncryptionAlgorithm;
        }

        public InputStream getInputStream(InputStream dataIn)
        {
            return new CipherInputStream(dataIn, dataCipher);
        }
    };
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:21,代碼來源:JceAsymmetricValueDecryptorGenerator.java

示例8: P11DSAContentSigner

import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //導入依賴的package包/類
P11DSAContentSigner(P11CryptService cryptService, P11EntityIdentifier identityId,
        AlgorithmIdentifier signatureAlgId, boolean plain)
        throws XiSecurityException, P11TokenException {
    this.identityId = ParamUtil.requireNonNull("identityId", identityId);
    this.cryptService = ParamUtil.requireNonNull("cryptService", cryptService);
    this.algorithmIdentifier = ParamUtil.requireNonNull("signatureAlgId", signatureAlgId);
    try {
        this.encodedAlgorithmIdentifier = algorithmIdentifier.getEncoded();
    } catch (IOException ex) {
        throw new XiSecurityException("could not encode AlgorithmIdentifier", ex);
    }
    this.plain = plain;

    String algOid = signatureAlgId.getAlgorithm().getId();
    HashAlgoType hashAlgo = sigAlgHashMap.get(algOid);
    if (hashAlgo == null) {
        throw new XiSecurityException("unsupported signature algorithm " + algOid);
    }

    P11SlotIdentifier slotId = identityId.slotId();
    P11Slot slot = cryptService.getSlot(slotId);
    if (slot.supportsMechanism(PKCS11Constants.CKM_DSA)) {
        this.mechanism = PKCS11Constants.CKM_DSA;
        Digest digest = hashAlgo.createDigest();
        this.outputStream = new DigestOutputStream(digest);
    } else {
        this.mechanism = hashMechMap.get(hashAlgo).longValue();
        if (!slot.supportsMechanism(this.mechanism)) {
            throw new XiSecurityException("unsupported signature algorithm " + algOid);
        }

        this.outputStream = new ByteArrayOutputStream();
    }
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:35,代碼來源:P11DSAContentSigner.java

示例9: getAlgorithmIdentifier

import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //導入依賴的package包/類
AlgorithmIdentifier getAlgorithmIdentifier(ASN1ObjectIdentifier encryptionOID, AlgorithmParameters params)
    throws CMSException
{
    ASN1Encodable asn1Params;
    if (params != null)
    {
        try
        {
            asn1Params = ASN1Primitive.fromByteArray(params.getEncoded("ASN.1"));
        }
        catch (IOException e)
        {
            throw new CMSException("cannot encode parameters: " + e.getMessage(), e);
        }
    }
    else
    {
        asn1Params = DERNull.INSTANCE;
    }

    return new AlgorithmIdentifier(
        encryptionOID,
        asn1Params);
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:25,代碼來源:EnvelopedDataHelper.java

示例10: getAlgorithmIdentifier

import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //導入依賴的package包/類
protected AlgorithmIdentifier getAlgorithmIdentifier(String encryptionOID, AlgorithmParameters params) throws IOException
{
    ASN1Encodable asn1Params;
    if (params != null)
    {
        asn1Params = ASN1Primitive.fromByteArray(params.getEncoded("ASN.1"));
    }
    else
    {
        asn1Params = DERNull.INSTANCE;
    }

    return new AlgorithmIdentifier(
        new ASN1ObjectIdentifier(encryptionOID),
        asn1Params);
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:17,代碼來源:CMSEnvelopedGenerator.java

示例11: HmacContentSigner

import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //導入依賴的package包/類
public HmacContentSigner(HashAlgoType hashAlgo, AlgorithmIdentifier algorithmIdentifier,
        SecretKey signingKey) throws XiSecurityException {
    this.algorithmIdentifier = ParamUtil.requireNonNull("algorithmIdentifier",
            algorithmIdentifier);
    try {
        this.encodedAlgorithmIdentifier = algorithmIdentifier.getEncoded();
    } catch (IOException ex) {
        throw new XiSecurityException("could not encode AlgorithmIdentifier", ex);
    }
    ParamUtil.requireNonNull("signingKey", signingKey);
    if (hashAlgo == null) {
        hashAlgo = AlgorithmUtil.extractHashAlgoFromMacAlg(algorithmIdentifier);
    }

    this.hmac = new HMac(hashAlgo.createDigest());
    byte[] keyBytes = signingKey.getEncoded();
    this.hmac.init(new KeyParameter(keyBytes, 0, keyBytes.length));
    this.outLen = hmac.getMacSize();
    this.outputStream = new HmacOutputStream();
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:21,代碼來源:HmacContentSigner.java

示例12: KeyAgreeRecipientInfo

import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //導入依賴的package包/類
public KeyAgreeRecipientInfo(
    ASN1Sequence seq)
{
    int index = 0;
    
    version = (ASN1Integer)seq.getObjectAt(index++);
    originator = OriginatorIdentifierOrKey.getInstance(
                        (ASN1TaggedObject)seq.getObjectAt(index++), true);

    if (seq.getObjectAt(index) instanceof ASN1TaggedObject)
    {
        ukm = ASN1OctetString.getInstance(
                        (ASN1TaggedObject)seq.getObjectAt(index++), true);
    }

    keyEncryptionAlgorithm = AlgorithmIdentifier.getInstance(
                                            seq.getObjectAt(index++));

    recipientEncryptedKeys = (ASN1Sequence)seq.getObjectAt(index++);
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:21,代碼來源:KeyAgreeRecipientInfo.java

示例13: 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

示例14: SignerInfo

import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //導入依賴的package包/類
public SignerInfo(
    SignerIdentifier        sid,
    AlgorithmIdentifier     digAlgorithm,
    Attributes              authenticatedAttributes,
    AlgorithmIdentifier     digEncryptionAlgorithm,
    ASN1OctetString         encryptedDigest,
    Attributes              unauthenticatedAttributes)
{
    if (sid.isTagged())
    {
        this.version = new ASN1Integer(3);
    }
    else
    {
        this.version = new ASN1Integer(1);
    }

    this.sid = sid;
    this.digAlgorithm = digAlgorithm;
    this.authenticatedAttributes = ASN1Set.getInstance(authenticatedAttributes);
    this.digEncryptionAlgorithm = digEncryptionAlgorithm;
    this.encryptedDigest = encryptedDigest;
    this.unauthenticatedAttributes = ASN1Set.getInstance(unauthenticatedAttributes);
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:25,代碼來源:SignerInfo.java

示例15: SignerInfo

import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //導入依賴的package包/類
public SignerInfo(
    ASN1Integer              version,
    IssuerAndSerialNumber   issuerAndSerialNumber,
    AlgorithmIdentifier     digAlgorithm,
    ASN1Set                 authenticatedAttributes,
    AlgorithmIdentifier     digEncryptionAlgorithm,
    ASN1OctetString         encryptedDigest,
    ASN1Set                 unauthenticatedAttributes)
{
    this.version = version;
    this.issuerAndSerialNumber = issuerAndSerialNumber;
    this.digAlgorithm = digAlgorithm;
    this.authenticatedAttributes = authenticatedAttributes;
    this.digEncryptionAlgorithm = digEncryptionAlgorithm;
    this.encryptedDigest = encryptedDigest;
    this.unauthenticatedAttributes = unauthenticatedAttributes;
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:18,代碼來源:SignerInfo.java


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