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


Java ASN1OctetString類代碼示例

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


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

示例1: AuthorityKeyIdentifier

import org.bouncycastle.asn1.ASN1OctetString; //導入依賴的package包/類
protected AuthorityKeyIdentifier(
    ASN1Sequence   seq)
{
    Enumeration     e = seq.getObjects();

    while (e.hasMoreElements())
    {
        ASN1TaggedObject o = DERTaggedObject.getInstance(e.nextElement());

        switch (o.getTagNo())
        {
        case 0:
            this.keyidentifier = ASN1OctetString.getInstance(o, false);
            break;
        case 1:
            this.certissuer = GeneralNames.getInstance(o, false);
            break;
        case 2:
            this.certserno = ASN1Integer.getInstance(o, false);
            break;
        default:
            throw new IllegalArgumentException("illegal tag");
        }
    }
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:26,代碼來源:AuthorityKeyIdentifier.java

示例2: getUPNStringFromSequence

import org.bouncycastle.asn1.ASN1OctetString; //導入依賴的package包/類
/**
 * Get UPN String.
 *
 * @param seq ASN1Sequence abstraction representing subject alternative name.
 * First element is the object identifier, second is the object itself.
 *
 * @return UPN string or null
 */
private String getUPNStringFromSequence(final ASN1Sequence seq) {
    if (seq != null) {
        // First in sequence is the object identifier, that we must check
        final ASN1ObjectIdentifier id = ASN1ObjectIdentifier.getInstance(seq.getObjectAt(0));
        if (id != null && UPN_OBJECTID.equals(id.getId())) {
            final ASN1TaggedObject obj = (ASN1TaggedObject) seq.getObjectAt(1);
            ASN1Primitive prim = obj.getObject();
            
            // Due to bug in java cert.getSubjectAltName, it can be tagged an extra time
            if (prim instanceof ASN1TaggedObject) {
                prim = ASN1TaggedObject.getInstance(((ASN1TaggedObject) prim)).getObject();
            }

            if (prim instanceof ASN1OctetString) {
                return new String(((ASN1OctetString) prim).getOctets());
            } else if (prim instanceof ASN1String) {
                return ((ASN1String) prim).getString();
            } else{
                return null;
            }
        }
    }
    return null;
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:33,代碼來源:X509SubjectAlternativeNameUPNPrincipalResolver.java

示例3: PBKDF2Params

import org.bouncycastle.asn1.ASN1OctetString; //導入依賴的package包/類
public PBKDF2Params(
    ASN1Sequence  seq)
{
    Enumeration e = seq.getObjects();

    octStr = (ASN1OctetString)e.nextElement();
    iterationCount = (DERInteger)e.nextElement();

    if (e.hasMoreElements())
    {
        keyLength = (DERInteger)e.nextElement();
    }
    else
    {
        keyLength = null;
    }
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:18,代碼來源:PBKDF2Params.java

示例4: getSignerId

import org.bouncycastle.asn1.ASN1OctetString; //導入依賴的package包/類
public SignerId getSignerId(X509CertSelector certSelector)
{
    try
    {
        if (certSelector.getSubjectKeyIdentifier() != null)
        {
            return new SignerId(X500Name.getInstance(certSelector.getIssuerAsBytes()), certSelector.getSerialNumber(), ASN1OctetString.getInstance(certSelector.getSubjectKeyIdentifier()).getOctets());
        }
        else
        {
            return new SignerId(X500Name.getInstance(certSelector.getIssuerAsBytes()), certSelector.getSerialNumber());
        }
    }
    catch (IOException e)
    {
        throw new IllegalArgumentException("unable to convert issuer: " + e.getMessage());
    }
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:19,代碼來源:JcaSelectorConverter.java

示例5: McElieceCCA2PrivateKey

import org.bouncycastle.asn1.ASN1OctetString; //導入依賴的package包/類
private McElieceCCA2PrivateKey(ASN1Sequence seq)
{
    oid = ((ASN1ObjectIdentifier)seq.getObjectAt(0));

    BigInteger bigN = ((ASN1Integer)seq.getObjectAt(1)).getValue();
    n = bigN.intValue();

    BigInteger bigK = ((ASN1Integer)seq.getObjectAt(2)).getValue();
    k = bigK.intValue();

    encField = ((ASN1OctetString)seq.getObjectAt(3)).getOctets();

    encGp = ((ASN1OctetString)seq.getObjectAt(4)).getOctets();

    encP = ((ASN1OctetString)seq.getObjectAt(5)).getOctets();

    encH = ((ASN1OctetString)seq.getObjectAt(6)).getOctets();

    ASN1Sequence asnQInv = (ASN1Sequence)seq.getObjectAt(7);
    encqInv = new byte[asnQInv.size()][];
    for (int i = 0; i < asnQInv.size(); i++)
    {
        encqInv[i] = ((ASN1OctetString)asnQInv.getObjectAt(i)).getOctets();
    }
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:26,代碼來源:McElieceCCA2PrivateKey.java

示例6: extractSecretKey

import org.bouncycastle.asn1.ASN1OctetString; //導入依賴的package包/類
protected Key extractSecretKey(AlgorithmIdentifier keyEncryptionAlgorithm, AlgorithmIdentifier contentEncryptionAlgorithm, byte[] derivedKey, byte[] encryptedContentEncryptionKey)
    throws CMSException
{
    Cipher keyEncryptionCipher = helper.createRFC3211Wrapper(keyEncryptionAlgorithm.getAlgorithm());

    try
    {
        IvParameterSpec ivSpec = new IvParameterSpec(ASN1OctetString.getInstance(keyEncryptionAlgorithm.getParameters()).getOctets());

        keyEncryptionCipher.init(Cipher.UNWRAP_MODE, new SecretKeySpec(derivedKey, keyEncryptionCipher.getAlgorithm()), ivSpec);

        return keyEncryptionCipher.unwrap(encryptedContentEncryptionKey, contentEncryptionAlgorithm.getAlgorithm().getId(), Cipher.SECRET_KEY);
    }
    catch (GeneralSecurityException e)
    {
        throw new CMSException("cannot process content encryption key: " + e.getMessage(), e);
    }
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:19,代碼來源:JcePasswordRecipient.java

示例7: McElieceCCA2PublicKey

import org.bouncycastle.asn1.ASN1OctetString; //導入依賴的package包/類
private McElieceCCA2PublicKey(ASN1Sequence seq)
{
    oid = ((ASN1ObjectIdentifier)seq.getObjectAt(0));
    BigInteger bigN = ((ASN1Integer)seq.getObjectAt(1)).getValue();
    n = bigN.intValue();

    BigInteger bigT = ((ASN1Integer)seq.getObjectAt(2)).getValue();
    t = bigT.intValue();

    matrixG = ((ASN1OctetString)seq.getObjectAt(3)).getOctets();
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:12,代碼來源:McElieceCCA2PublicKey.java

示例8: TimeStampedData

import org.bouncycastle.asn1.ASN1OctetString; //導入依賴的package包/類
private TimeStampedData(ASN1Sequence seq)
{
    this.version = ASN1Integer.getInstance(seq.getObjectAt(0));

    int index = 1;
    if (seq.getObjectAt(index) instanceof DERIA5String)
    {
        this.dataUri = DERIA5String.getInstance(seq.getObjectAt(index++));
    }
    if (seq.getObjectAt(index) instanceof MetaData || seq.getObjectAt(index) instanceof ASN1Sequence)
    {
        this.metaData = MetaData.getInstance(seq.getObjectAt(index++));
    }
    if (seq.getObjectAt(index) instanceof ASN1OctetString)
    {
        this.content = ASN1OctetString.getInstance(seq.getObjectAt(index++));
    }
    this.temporalEvidence = Evidence.getInstance(seq.getObjectAt(index));
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:20,代碼來源:TimeStampedData.java

示例9: getRecipientOperator

import org.bouncycastle.asn1.ASN1OctetString; //導入依賴的package包/類
public RecipientOperator getRecipientOperator(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentEncryptionAlgorithm, SubjectPublicKeyInfo senderPublicKey, ASN1OctetString userKeyingMaterial, byte[] encryptedContentKey)
    throws CMSException
{
    Key secretKey = extractSecretKey(keyEncryptionAlgorithm, contentEncryptionAlgorithm, senderPublicKey, userKeyingMaterial, encryptedContentKey);

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

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

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

示例10: isMacValid

import org.bouncycastle.asn1.ASN1OctetString; //導入依賴的package包/類
/**
 * Verify the MacData attached to the PFX is consistent with what is expected.
 *
 * @param macCalcProviderBuilder provider builder for the calculator for the MAC
 * @param password password to use
 * @return true if mac data is valid, false otherwise.
 * @throws PKCSException if there is a problem evaluating the MAC.
 * @throws IllegalStateException if no MAC is actually present
 */
public boolean isMacValid(PKCS12MacCalculatorBuilderProvider macCalcProviderBuilder, char[] password)
    throws PKCSException
{
    if (hasMac())
    {
        MacData pfxmData = pfx.getMacData();
        MacDataGenerator mdGen = new MacDataGenerator(macCalcProviderBuilder.get(new AlgorithmIdentifier(pfxmData.getMac().getAlgorithmId().getAlgorithm(), new PKCS12PBEParams(pfxmData.getSalt(), pfxmData.getIterationCount().intValue()))));

        try
        {
            MacData mData = mdGen.build(
                password,
                ASN1OctetString.getInstance(pfx.getAuthSafe().getContent()).getOctets());

            return Arrays.constantTimeAreEqual(mData.getEncoded(), pfx.getMacData().getEncoded());
        }
        catch (IOException e)
        {
            throw new PKCSException("unable to process AuthSafe: " + e.getMessage());
        }
    }

    throw new IllegalStateException("no MAC present on PFX");
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:34,代碼來源:PKCS12PfxPdu.java

示例11: X509Extensions

import org.bouncycastle.asn1.ASN1OctetString; //導入依賴的package包/類
/**
 * Constructor from ASN1Sequence.
 *
 * the extensions are a list of constructed sequences, either with (OID, OctetString) or (OID, Boolean, OctetString)
 */
public X509Extensions(
    ASN1Sequence  seq)
{
    Enumeration e = seq.getObjects();

    while (e.hasMoreElements())
    {
        ASN1Sequence            s = ASN1Sequence.getInstance(e.nextElement());

        if (s.size() == 3)
        {
            extensions.put(s.getObjectAt(0), new X509Extension(DERBoolean.getInstance(s.getObjectAt(1)), ASN1OctetString.getInstance(s.getObjectAt(2))));
        }
        else if (s.size() == 2)
        {
            extensions.put(s.getObjectAt(0), new X509Extension(false, ASN1OctetString.getInstance(s.getObjectAt(1))));
        }
        else
        {
            throw new IllegalArgumentException("Bad sequence size: " + s.size());
        }

        ordering.addElement(s.getObjectAt(0));
    }
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:31,代碼來源:X509Extensions.java

示例12: KeyTransRecipientInformation

import org.bouncycastle.asn1.ASN1OctetString; //導入依賴的package包/類
KeyTransRecipientInformation(
    KeyTransRecipientInfo   info,
    AlgorithmIdentifier     messageAlgorithm,
    CMSSecureReadable       secureReadable,
    AuthAttributesProvider  additionalData)
{
    super(info.getKeyEncryptionAlgorithm(), messageAlgorithm, secureReadable, additionalData);

    this.info = info;

    RecipientIdentifier r = info.getRecipientIdentifier();

    if (r.isTagged())
    {
        ASN1OctetString octs = ASN1OctetString.getInstance(r.getId());

        rid = new KeyTransRecipientId(octs.getOctets());
    }
    else
    {
        IssuerAndSerialNumber   iAnds = IssuerAndSerialNumber.getInstance(r.getId());

        rid = new KeyTransRecipientId(iAnds.getName(), iAnds.getSerialNumber().getValue());
    }
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:26,代碼來源:KeyTransRecipientInformation.java

示例13: getContent

import org.bouncycastle.asn1.ASN1OctetString; //導入依賴的package包/類
/**
 * Return the uncompressed content, throwing an exception if the data size
 * is greater than the passed in limit. If the content is exceeded getCause()
 * on the CMSException will contain a StreamOverflowException
 *
 * @param limit maximum number of bytes to read
 * @return the content read
 * @throws CMSException if there is an exception uncompressing the data.
 * @deprecated use getContent(InputExpanderProvider)
 */
public byte[] getContent(int limit)
    throws CMSException
{
    ContentInfo     content = comData.getEncapContentInfo();

    ASN1OctetString bytes = (ASN1OctetString)content.getContent();

    InflaterInputStream     zIn = new InflaterInputStream(bytes.getOctetStream());

    try
    {
        return CMSUtils.streamToByteArray(zIn, limit);
    }
    catch (IOException e)
    {
        throw new CMSException("exception reading compressed stream.", e);
    }
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:29,代碼來源:CMSCompressedData.java

示例14: getKeyTransRecipientId

import org.bouncycastle.asn1.ASN1OctetString; //導入依賴的package包/類
public KeyTransRecipientId getKeyTransRecipientId(X509CertSelector certSelector)
{
    try
    {
        if (certSelector.getSubjectKeyIdentifier() != null)
        {
            return new KeyTransRecipientId(X500Name.getInstance(certSelector.getIssuerAsBytes()), certSelector.getSerialNumber(), ASN1OctetString.getInstance(certSelector.getSubjectKeyIdentifier()).getOctets());
        }
        else
        {
            return new KeyTransRecipientId(X500Name.getInstance(certSelector.getIssuerAsBytes()), certSelector.getSerialNumber());
        }
    }
    catch (IOException e)
    {
        throw new IllegalArgumentException("unable to convert issuer: " + e.getMessage());
    }
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:19,代碼來源:JcaSelectorConverter.java

示例15: PKIArchiveOptions

import org.bouncycastle.asn1.ASN1OctetString; //導入依賴的package包/類
private PKIArchiveOptions(ASN1TaggedObject tagged)
{
    switch (tagged.getTagNo())
    {
    case encryptedPrivKey:
        value = EncryptedKey.getInstance(tagged.getObject());
        break;
    case keyGenParameters:
        value = ASN1OctetString.getInstance(tagged, false);
        break;
    case archiveRemGenPrivKey:
        value = ASN1Boolean.getInstance(tagged, false);
        break;
    default:
        throw new IllegalArgumentException("unknown tag number: " + tagged.getTagNo());
    }
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:18,代碼來源:PKIArchiveOptions.java


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