当前位置: 首页>>代码示例>>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;未经允许,请勿转载。