Java 类org.bouncycastle.asn1.DERInteger 实例源码

项目:keepass2android    文件:DHParameter.java   
public DHParameter(
    BigInteger  p,
    BigInteger  g,
    int         l)
{
    this.p = new DERInteger(p);
    this.g = new DERInteger(g);

    if (l != 0)
    {
        this.l = new DERInteger(l);
    }
    else
    {
        this.l = null;
    }
}
项目:keepass2android    文件:DHParameter.java   
public DHParameter(
    ASN1Sequence  seq)
{
    Enumeration     e = seq.getObjects();

    p = (DERInteger)e.nextElement();
    g = (DERInteger)e.nextElement();

    if (e.hasMoreElements())
    {
        l = (DERInteger)e.nextElement();
    }
    else
    {
        l = null;
    }
}
项目:keepass2android    文件:RSAPrivateKeyStructure.java   
public RSAPrivateKeyStructure(
    ASN1Sequence  seq)
{
    Enumeration e = seq.getObjects();

    BigInteger  v = ((DERInteger)e.nextElement()).getValue();
    if (v.intValue() != 0 && v.intValue() != 1)
    {
        throw new IllegalArgumentException("wrong version for RSA private key");
    }

    version = v.intValue();
    modulus = ((DERInteger)e.nextElement()).getValue();
    publicExponent = ((DERInteger)e.nextElement()).getValue();
    privateExponent = ((DERInteger)e.nextElement()).getValue();
    prime1 = ((DERInteger)e.nextElement()).getValue();
    prime2 = ((DERInteger)e.nextElement()).getValue();
    exponent1 = ((DERInteger)e.nextElement()).getValue();
    exponent2 = ((DERInteger)e.nextElement()).getValue();
    coefficient = ((DERInteger)e.nextElement()).getValue();

    if (e.hasMoreElements())
    {
        otherPrimeInfos = (ASN1Sequence)e.nextElement();
    }
}
项目:keepass2android    文件:PBKDF2Params.java   
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;
    }
}
项目:ipack    文件:JCEDHPublicKey.java   
private boolean isPKCSParam(ASN1Sequence seq)
{
    if (seq.size() == 2)
    {
        return true;
    }

    if (seq.size() > 3)
    {
        return false;
    }

    DERInteger l = DERInteger.getInstance(seq.getObjectAt(2));
    DERInteger p = DERInteger.getInstance(seq.getObjectAt(0));

    if (l.getValue().compareTo(BigInteger.valueOf(p.getValue().bitLength())) > 0)
    {
        return false;
    }

    return true;
}
项目:ipack    文件:JDKDSAPublicKey.java   
public byte[] getEncoded()
{
    try
    {
        if (dsaSpec == null)
        {
            return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new DERInteger(y)).getEncoded(ASN1Encoding.DER);
        }

        return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new DERInteger(y)).getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        return null;
    }
}
项目:ipack    文件:JcaEACSignatureVerifierBuilder.java   
private static byte[] derEncode(byte[] rawSign) throws IOException
{
    int len = rawSign.length / 2;

    byte[] r = new byte[len];
    byte[] s = new byte[len];
    System.arraycopy(rawSign, 0, r, 0, len);
    System.arraycopy(rawSign, len, s, 0, len);

    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(new DERInteger(new BigInteger(1, r)));
    v.add(new DERInteger(new BigInteger(1, s)));

    DERSequence seq = new DERSequence(v);
    return seq.getEncoded();
}
项目:ipack    文件:AlgorithmParametersSpi.java   
/**
 * in the absence of a standard way of doing it this will do for
 * now...
 */
protected byte[] engineGetEncoded()
{
    try
    {
        ASN1EncodableVector v = new ASN1EncodableVector();

        v.add(new DEROctetString(currentSpec.getDerivationV()));
        v.add(new DEROctetString(currentSpec.getEncodingV()));
        v.add(new DERInteger(currentSpec.getMacKeySize()));

        return new DERSequence(v).getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        throw new RuntimeException("Error encoding IESParameters");
    }
}
项目:ipack    文件:TimeStampResponseGenerator.java   
private PKIStatusInfo getPKIStatusInfo()
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(new DERInteger(status));

    if (statusStrings.size() > 0)
    {
        v.add(PKIFreeText.getInstance(new DERSequence(statusStrings)));
    }

    if (failInfo != 0)
    {
        DERBitString failInfoBitString = new FailInfo(failInfo);
        v.add(failInfoBitString);
    }

    return PKIStatusInfo.getInstance(new DERSequence(v));
}
项目:KeePass2Android    文件:DHParameter.java   
public DHParameter(
    BigInteger  p,
    BigInteger  g,
    int         l)
{
    this.p = new DERInteger(p);
    this.g = new DERInteger(g);

    if (l != 0)
    {
        this.l = new DERInteger(l);
    }
    else
    {
        this.l = null;
    }
}
项目:KeePass2Android    文件:DHParameter.java   
public DHParameter(
    ASN1Sequence  seq)
{
    Enumeration     e = seq.getObjects();

    p = (DERInteger)e.nextElement();
    g = (DERInteger)e.nextElement();

    if (e.hasMoreElements())
    {
        l = (DERInteger)e.nextElement();
    }
    else
    {
        l = null;
    }
}
项目:KeePass2Android    文件:RSAPrivateKeyStructure.java   
public RSAPrivateKeyStructure(
    ASN1Sequence  seq)
{
    Enumeration e = seq.getObjects();

    BigInteger  v = ((DERInteger)e.nextElement()).getValue();
    if (v.intValue() != 0 && v.intValue() != 1)
    {
        throw new IllegalArgumentException("wrong version for RSA private key");
    }

    version = v.intValue();
    modulus = ((DERInteger)e.nextElement()).getValue();
    publicExponent = ((DERInteger)e.nextElement()).getValue();
    privateExponent = ((DERInteger)e.nextElement()).getValue();
    prime1 = ((DERInteger)e.nextElement()).getValue();
    prime2 = ((DERInteger)e.nextElement()).getValue();
    exponent1 = ((DERInteger)e.nextElement()).getValue();
    exponent2 = ((DERInteger)e.nextElement()).getValue();
    coefficient = ((DERInteger)e.nextElement()).getValue();

    if (e.hasMoreElements())
    {
        otherPrimeInfos = (ASN1Sequence)e.nextElement();
    }
}
项目:KeePass2Android    文件:PBKDF2Params.java   
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;
    }
}
项目:Direct-File-Downloader    文件:AttributeCertificateHolder.java   
public AttributeCertificateHolder(X509Certificate cert)
    throws CertificateParsingException
{
    X509Principal name;

    try
    {
        name = PrincipalUtil.getIssuerX509Principal(cert);
    }
    catch (Exception e)
    {
        throw new CertificateParsingException(e.getMessage());
    }

    holder = new Holder(new IssuerSerial(generateGeneralNames(name),
        new DERInteger(cert.getSerialNumber())));
}
项目:eid-applet    文件:XAdESXLSignatureFacet.java   
private BigInteger getCrlNumber(X509CRL crl) {
    byte[] crlNumberExtensionValue = crl.getExtensionValue(X509Extensions.CRLNumber.getId());
    if (null == crlNumberExtensionValue) {
        return null;
    }
    try {
        ASN1InputStream asn1InputStream = new ASN1InputStream(crlNumberExtensionValue);
        ASN1OctetString octetString = (ASN1OctetString) asn1InputStream.readObject();
        byte[] octets = octetString.getOctets();
        DERInteger integer = (DERInteger) new ASN1InputStream(octets).readObject();
        BigInteger crlNumber = integer.getPositiveValue();
        return crlNumber;
    } catch (IOException e) {
        throw new RuntimeException("I/O error: " + e.getMessage(), e);
    }
}
项目:signer-source    文件:DerEncoder.java   
public byte[] buildCmsBody(String signedHashId,
        X509Certificate certContent, byte[] content, String hashId,
        int version) throws CertificateEncodingException, IOException {
    final DEREncodableVector whole = new DEREncodableVector();
    whole.add(new DERObjectIdentifier(CMS_SIGNED_ID));

    final DEREncodableVector body = new DEREncodableVector();
    // ----- versao -------
    // final int version = 1;
    body.add(new DERInteger(version));
    buildDigestAlg(body, hashId);
    // buildContentInfo(body, content);
    buildCerts(body, certContent);

    buildSignerInfo(body, signedHashId, certContent, hashId);

    whole.add(new DERTaggedObject(0, new DERSequence(body)));

    return genOutput(new DERSequence(whole));

}
项目:signer-source    文件:DerEncoder.java   
public byte[] buildCmsBody(byte[] signedHashId,
        X509Certificate certContent, List<X509Certificate> chain,
        int hashId, int version, int attachSize) throws Exception {
    final DEREncodableVector whole = new DEREncodableVector(); // 0 SEQ
    whole.add(new DERObjectIdentifier(CMS_SIGNED_ID)); // 1 SEQ

    final DEREncodableVector body = new DEREncodableVector();
    // ----- versao -------
    // final int version = 1;
    body.add(new DERInteger(version)); // 3 INT
    buildDigestAlg(body, getHashAlg(hashId)); // 3 SET
    buildContentInfo(body, attachSize); // 3 SEQ
    buildCerts(body, chain); // 3 CS

    buildSignerInfo(body, signedHashId, certContent, hashId); // 3 SET

    whole.add(new DERTaggedObject(0, new DERSequence( // 2 SEQ
            body))); // 1 CS

    return genOutput(new DERSequence(whole));

}
项目:signer-source    文件:DerEncoder.java   
private void buildSignerInfo(DEREncodableVector body,
        byte[] signedHashContent, X509Certificate certContent, int hashId)
        throws Exception {
    // ----- Signers Info --------

    final DEREncodableVector vec = new DEREncodableVector();
    final DEREncodableVector signerinfoVector = new DEREncodableVector();
    signerinfoVector.add(new DERInteger(SI_VERSION));

    signerinfoVector.add(siAddCert(certContent));
    signerinfoVector.add(siAddDigestAlgorithm(getHashAlg(hashId)));
    signerinfoVector
            .add(siAddDigestEncryptionAlgorithm(getHashSignAlg(hashId)));
    // Add the digest
    signerinfoVector.add(new DEROctetString(signedHashContent));

    final DERSequence siSeq = new DERSequence(signerinfoVector);
    vec.add(siSeq);
    DERSet siSet = new DERSet(vec);
    body.add(siSet);

}
项目:signer-source    文件:DerEncoder.java   
private void buildSignerInfo(DEREncodableVector body,
        String signedHashContent, X509Certificate certContent, String hashId)
        throws CertificateEncodingException {
    // ----- Signers Info --------

    final DEREncodableVector vec = new DEREncodableVector();
    final DEREncodableVector signerinfoVector = new DEREncodableVector();
    signerinfoVector.add(new DERInteger(SI_VERSION)); // 5 INT

    signerinfoVector.add(siAddCert(certContent));
    signerinfoVector.add(siAddDigestAlgorithm(hashId));
    signerinfoVector.add(siAddDigestEncryptionAlgorithm(ID_SHA1_RSA)); // 6
                                                                        // OCT
                                                                        // STR
    // Add the digest
    signerinfoVector.add(new DEROctetString(
            getDerSignedDigest(signedHashContent)));

    final DERSequence siSeq = new DERSequence(signerinfoVector); // 4 SEQ
    vec.add(siSeq);
    DERSet siSet = new DERSet(vec); // 3 SET
    body.add(siSet);

}
项目:signer-source    文件:DerEncoder.java   
public byte[] buildCmsBody(String signedHashId,
        X509Certificate certContent, byte[] content, String hashId,
        int version) throws CertificateEncodingException, IOException {
    final ASN1EncodableVector whole = new ASN1EncodableVector();
    whole.add(new DERObjectIdentifier(CMS_SIGNED_ID));

    final ASN1EncodableVector body = new ASN1EncodableVector();
    // ----- versao -------
    // final int version = 1;
    body.add(new DERInteger(version));
    buildDigestAlg(body, hashId);
    // buildContentInfo(body, content);
    buildCerts(body, certContent);

    buildSignerInfo(body, signedHashId, certContent, hashId);

    whole.add(new DERTaggedObject(0, new DERSequence(body)));

    return genOutput(new DERSequence(whole));

}
项目:signer-source    文件:DerEncoder.java   
public byte[] buildCmsBody(byte[] signedHashId,
        X509Certificate certContent, List<X509Certificate> chain,
        int hashId, int version, int attachSize) throws Exception {
    final ASN1EncodableVector whole = new ASN1EncodableVector(); // 0 SEQ
    whole.add(new DERObjectIdentifier(CMS_SIGNED_ID)); // 1 SEQ

    final ASN1EncodableVector body = new ASN1EncodableVector();
    // ----- versao -------
    // final int version = 1;
    body.add(new DERInteger(version)); // 3 INT
    buildDigestAlg(body, getHashAlg(hashId)); // 3 SET
    buildContentInfo(body, attachSize); // 3 SEQ
    buildCerts(body, chain); // 3 CS

    buildSignerInfo(body, signedHashId, certContent, hashId); // 3 SET

    whole.add(new DERTaggedObject(0, new DERSequence( // 2 SEQ
            body))); // 1 CS

    return genOutput(new DERSequence(whole));

}
项目:signer-source    文件:DerEncoder.java   
private void buildSignerInfo(ASN1EncodableVector body,
        byte[] signedHashContent, X509Certificate certContent, int hashId)
        throws Exception {
    // ----- Signers Info --------

    final ASN1EncodableVector vec = new ASN1EncodableVector();
    final ASN1EncodableVector signerinfoVector = new ASN1EncodableVector();
    signerinfoVector.add(new DERInteger(SI_VERSION));

    signerinfoVector.add(siAddCert(certContent));
    signerinfoVector.add(siAddDigestAlgorithm(getHashAlg(hashId)));
    signerinfoVector
            .add(siAddDigestEncryptionAlgorithm(getHashSignAlg(hashId)));
    // Add the digest
    signerinfoVector.add(new DEROctetString(signedHashContent));

    final DERSequence siSeq = new DERSequence(signerinfoVector);
    vec.add(siSeq);
    DERSet siSet = new DERSet(vec);
    body.add(siSet);

}
项目:signer-source    文件:DerEncoder.java   
private void buildSignerInfo(ASN1EncodableVector body,
        String signedHashContent, X509Certificate certContent, String hashId)
        throws CertificateEncodingException {
    // ----- Signers Info --------

    final ASN1EncodableVector vec = new ASN1EncodableVector();
    final ASN1EncodableVector signerinfoVector = new ASN1EncodableVector();
    signerinfoVector.add(new DERInteger(SI_VERSION)); // 5 INT

    signerinfoVector.add(siAddCert(certContent));
    signerinfoVector.add(siAddDigestAlgorithm(hashId));
    signerinfoVector.add(siAddDigestEncryptionAlgorithm(ID_SHA1_RSA)); // 6
                                                                        // OCT
                                                                        // STR
    // Add the digest
    signerinfoVector.add(new DEROctetString(
            getDerSignedDigest(signedHashContent)));

    final DERSequence siSeq = new DERSequence(signerinfoVector); // 4 SEQ
    vec.add(siSeq);
    DERSet siSet = new DERSet(vec); // 3 SET
    body.add(siSet);

}
项目:signer-source    文件:DerEncoder.java   
public byte[] buildCmsBody(String signedHashId,
        X509Certificate certContent, byte[] content, String hashId,
        int version) throws CertificateEncodingException, IOException {
    final ASN1EncodableVector whole = new ASN1EncodableVector();
    whole.add(new DERObjectIdentifier(CMS_SIGNED_ID));

    final ASN1EncodableVector body = new ASN1EncodableVector();
    // ----- versao -------
    // final int version = 1;
    body.add(new DERInteger(version));
    buildDigestAlg(body, hashId);
    // buildContentInfo(body, content);
    buildCerts(body, certContent);

    buildSignerInfo(body, signedHashId, certContent, hashId);

    whole.add(new DERTaggedObject(0, new DERSequence(body)));

    return genOutput(new DERSequence(whole));

}
项目:signer-source    文件:DerEncoder.java   
public byte[] buildCmsBody(byte[] signedHashId,
        X509Certificate certContent, List<X509Certificate> chain,
        int hashId, int version, int attachSize) throws Exception {
    final ASN1EncodableVector whole = new ASN1EncodableVector(); // 0 SEQ
    whole.add(new DERObjectIdentifier(CMS_SIGNED_ID)); // 1 SEQ

    final ASN1EncodableVector body = new ASN1EncodableVector();
    // ----- versao -------
    // final int version = 1;
    body.add(new DERInteger(version)); // 3 INT
    buildDigestAlg(body, getHashAlg(hashId)); // 3 SET
    buildContentInfo(body, attachSize); // 3 SEQ
    buildCerts(body, chain); // 3 CS

    buildSignerInfo(body, signedHashId, certContent, hashId); // 3 SET

    whole.add(new DERTaggedObject(0, new DERSequence( // 2 SEQ
            body))); // 1 CS

    return genOutput(new DERSequence(whole));

}
项目:signer-source    文件:DerEncoder.java   
private void buildSignerInfo(ASN1EncodableVector body,
        byte[] signedHashContent, X509Certificate certContent, int hashId)
        throws Exception {
    // ----- Signers Info --------

    final ASN1EncodableVector vec = new ASN1EncodableVector();
    final ASN1EncodableVector signerinfoVector = new ASN1EncodableVector();
    signerinfoVector.add(new DERInteger(SI_VERSION));

    signerinfoVector.add(siAddCert(certContent));
    signerinfoVector.add(siAddDigestAlgorithm(getHashAlg(hashId)));
    signerinfoVector
            .add(siAddDigestEncryptionAlgorithm(getHashSignAlg(hashId)));
    // Add the digest
    signerinfoVector.add(new DEROctetString(signedHashContent));

    final DERSequence siSeq = new DERSequence(signerinfoVector);
    vec.add(siSeq);
    DERSet siSet = new DERSet(vec);
    body.add(siSet);

}
项目:signer-source    文件:DerEncoder.java   
private void buildSignerInfo(ASN1EncodableVector body,
        String signedHashContent, X509Certificate certContent, String hashId)
        throws CertificateEncodingException {
    // ----- Signers Info --------

    final ASN1EncodableVector vec = new ASN1EncodableVector();
    final ASN1EncodableVector signerinfoVector = new ASN1EncodableVector();
    signerinfoVector.add(new DERInteger(SI_VERSION)); // 5 INT

    signerinfoVector.add(siAddCert(certContent));
    signerinfoVector.add(siAddDigestAlgorithm(hashId));
    signerinfoVector.add(siAddDigestEncryptionAlgorithm(ID_SHA1_RSA)); // 6
                                                                        // OCT
                                                                        // STR
    // Add the digest
    signerinfoVector.add(new DEROctetString(
            getDerSignedDigest(signedHashContent)));

    final DERSequence siSeq = new DERSequence(signerinfoVector); // 4 SEQ
    vec.add(siSeq);
    DERSet siSet = new DERSet(vec); // 3 SET
    body.add(siSet);

}
项目:animamea    文件:ECDSA5Test.java   
protected BigInteger[] derDecode(
    byte[]  encoding)
    throws IOException
{
    ByteArrayInputStream    bIn = new ByteArrayInputStream(encoding);
    ASN1InputStream         aIn = new ASN1InputStream(bIn);
    ASN1Sequence            s = (ASN1Sequence)aIn.readObject();
    aIn.close();

    BigInteger[]            sig = new BigInteger[2];

    sig[0] = ((DERInteger)s.getObjectAt(0)).getValue();
    sig[1] = ((DERInteger)s.getObjectAt(1)).getValue();

    return sig;
}
项目:AcademicTorrents-Downloader    文件:AttributeCertificateHolder.java   
public AttributeCertificateHolder(X509Certificate cert)
    throws CertificateParsingException
{
    X509Principal name;

    try
    {
        name = PrincipalUtil.getIssuerX509Principal(cert);
    }
    catch (Exception e)
    {
        throw new CertificateParsingException(e.getMessage());
    }

    holder = new Holder(new IssuerSerial(generateGeneralNames(name),
        new DERInteger(cert.getSerialNumber())));
}
项目:AcademicTorrents-Downloader    文件:JDKDSASigner.java   
private byte[] derEncode(
    BigInteger  r,
    BigInteger  s)
    throws IOException
{
    ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
    DEROutputStream         dOut = new DEROutputStream(bOut);
    ASN1EncodableVector     v = new ASN1EncodableVector();

    v.add(new DERInteger(r));
    v.add(new DERInteger(s));

    dOut.writeObject(new DERSequence(v));

    return bOut.toByteArray();
}
项目:AcademicTorrents-Downloader    文件:ECPrivateKeyStructure.java   
public ECPrivateKeyStructure(
    BigInteger  key)
{
    byte[]  bytes = key.toByteArray();

    if (bytes[0] == 0)
    {
        byte[]  tmp = new byte[bytes.length - 1];

        System.arraycopy(bytes, 1, tmp, 0, tmp.length);
        bytes = tmp;
    }

    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(new DERInteger(1));
    v.add(new DEROctetString(bytes));

    seq = new DERSequence(v);
}
项目:AcademicTorrents-Downloader    文件:NoticeReference.java   
/**
 * Creates a new <code>NoticeReference</code> instance.
 *
 * @param orgName a <code>String</code> value
 * @param numbers a <code>Vector</code> value
 */
public NoticeReference(
    String orgName,
    Vector numbers) 
{
   organization = new DisplayText(orgName);

   Object o = numbers.elementAt(0);

   ASN1EncodableVector av = new ASN1EncodableVector();
   if (o instanceof Integer)
   {
      Enumeration it = numbers.elements();

      while (it.hasMoreElements())
      {
         Integer nm = (Integer) it.nextElement();
            DERInteger di = new DERInteger(nm.intValue());
         av.add (di);
      }
   }

   noticeNumbers = new DERSequence(av);
}
项目:AcademicTorrents-Downloader    文件:AuthorityKeyIdentifier.java   
public 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 = DERInteger.getInstance(o, false);
            break;
        default:
            throw new IllegalArgumentException("illegal tag");
        }
    }
}
项目:AcademicTorrents-Downloader    文件:AuthorityKeyIdentifier.java   
/**
 * create an AuthorityKeyIdentifier with the GeneralNames tag and
 * the serial number provided as well.
 */
public AuthorityKeyIdentifier(
    SubjectPublicKeyInfo    spki,
    GeneralNames            name,
    BigInteger              serialNumber)
{
    Digest  digest = new SHA1Digest();
    byte[]  resBuf = new byte[digest.getDigestSize()];

    byte[] bytes = spki.getPublicKeyData().getBytes();
    digest.update(bytes, 0, bytes.length);
    digest.doFinal(resBuf, 0);

    this.keyidentifier = new DEROctetString(resBuf);
    this.certissuer = GeneralNames.getInstance(name.toASN1Object());
    this.certserno = new DERInteger(serialNumber);
}
项目:AcademicTorrents-Downloader    文件:TBSCertList.java   
public CRLEntry(
    ASN1Sequence  seq)
{
    if (seq.size() < 2 || seq.size() > 3)
    {
        throw new IllegalArgumentException("Bad sequence size: " + seq.size());
    }

    this.seq = seq;

    userCertificate = DERInteger.getInstance(seq.getObjectAt(0));
    revocationDate = Time.getInstance(seq.getObjectAt(1));
    if (seq.size() == 3)
    {
        crlEntryExtensions = X509Extensions.getInstance(seq.getObjectAt(2));
    }
}
项目:AcademicTorrents-Downloader    文件:GeneralSubtree.java   
/**
 * Constructor from a given details.
 * 
 * According RFC 3280, the minimum and maximum fields are not used with any
 * name forms, thus minimum MUST be zero, and maximum MUST be absent.
 * <p>
 * If minimum is <code>null</code>, zero is assumed, if
 * maximum is <code>null</code>, maximum is absent.
 * 
 * @param base
 *            A restriction.
 * @param minimum
 *            Minimum
 * 
 * @param maximum
 *            Maximum
 */
public GeneralSubtree(
    GeneralName base,
    BigInteger minimum,
    BigInteger maximum)
{
    this.base = base;
    if (maximum != null)
    {
        this.maximum = new DERInteger(maximum);
    }
    if (minimum == null)
    {
        this.minimum = null;
    }
    else
    {
        this.minimum = new DERInteger(minimum);
    }
}
项目:AcademicTorrents-Downloader    文件:BasicConstraints.java   
/**
 * @deprecated use one of the other two unambigous constructors.
 * @param cA
 * @param pathLenConstraint
 */
public BasicConstraints(
    boolean cA,
    int     pathLenConstraint)
{
    if (cA)
    {
        this.cA = new DERBoolean(cA);
        this.pathLenConstraint = new DERInteger(pathLenConstraint);
    }
    else
    {
        this.cA = null;
        this.pathLenConstraint = null;
    }
}
项目:AcademicTorrents-Downloader    文件:IssuerSerial.java   
public IssuerSerial(
    ASN1Sequence    seq)
{
    if (seq.size() != 2 && seq.size() != 3)
    {
        throw new IllegalArgumentException("Bad sequence size: " + seq.size());
    }

    issuer = GeneralNames.getInstance(seq.getObjectAt(0));
    serial = DERInteger.getInstance(seq.getObjectAt(1));

    if (seq.size() == 3)
    {
        issuerUID = DERBitString.getInstance(seq.getObjectAt(2));
    }
}
项目:AcademicTorrents-Downloader    文件:X9Curve.java   
public X9Curve(
    X9FieldID     fieldID,
    ASN1Sequence  seq)
{
    if (fieldID.getIdentifier().equals(prime_field))
    {
        BigInteger      q = ((DERInteger)fieldID.getParameters()).getValue();
        X9FieldElement  x9A = new X9FieldElement(true, q, (ASN1OctetString)seq.getObjectAt(0));
        X9FieldElement  x9B = new X9FieldElement(true, q, (ASN1OctetString)seq.getObjectAt(1));
        curve = new ECCurve.Fp(q, x9A.getValue().toBigInteger(), x9B.getValue().toBigInteger());
    }
    else
    {
        throw new RuntimeException("not implemented");
    }

    if (seq.size() == 3)
    {
        seed = ((DERBitString)seq.getObjectAt(2)).getBytes();
    }
}
项目:AcademicTorrents-Downloader    文件:X9ECParameters.java   
/**
 * Produce an object suitable for an ASN1OutputStream.
 * <pre>
 *  ECParameters ::= SEQUENCE {
 *      version         INTEGER { ecpVer1(1) } (ecpVer1),
 *      fieldID         FieldID {{FieldTypes}},
 *      curve           X9Curve,
 *      base            X9ECPoint,
 *      order           INTEGER,
 *      cofactor        INTEGER OPTIONAL
 *  }
 * </pre>
 */
public DERObject getDERObject()
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(new DERInteger(1));
    v.add(fieldID);
    v.add(new X9Curve(curve, seed));
    v.add(new X9ECPoint(g));
    v.add(new DERInteger(n));

    if (!h.equals(BigInteger.valueOf(1)))
    {
        v.add(new DERInteger(h));
    }

    return new DERSequence(v);
}