Package org.bouncycastle.asn1

Examples of org.bouncycastle.asn1.ASN1Primitive


   */
  public static String getTSAURL(X509Certificate certificate) {
      byte der[] = certificate.getExtensionValue(SecurityIDs.ID_TSA);
      if(der == null)
          return null;
      ASN1Primitive asn1obj;
    try {
      asn1obj = ASN1Primitive.fromByteArray(der);
          DEROctetString octets = (DEROctetString)asn1obj;
          asn1obj = ASN1Primitive.fromByteArray(octets.getOctets());
          ASN1Sequence asn1seq = ASN1Sequence.getInstance(asn1obj);
View Full Code Here


      cipher = Cipher.getInstance(TRANSFORMATION);
      cipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
      AlgorithmParameters params = AlgorithmParameters.getInstance(CIPHER);
      params.init(paramSpec);
     
      ASN1Primitive sParams = ASN1Primitive.fromByteArray(params.getEncoded("ASN.1"));
      algId = new AlgorithmIdentifier(DES_OID, sParams);
    } catch (GeneralSecurityException e) {
      throw new RuntimeException(e);
    } catch (IOException e) {
      throw new RuntimeException(e);
View Full Code Here

        pkcs7input[20] = four;
        pkcs7input[21] = three;
        pkcs7input[22] = two;
        pkcs7input[23] = one;

        ASN1Primitive obj = createDERForRecipient(pkcs7input, (X509Certificate)certificate);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        DEROutputStream k = new DEROutputStream(baos);
View Full Code Here

        AlgorithmParameterGenerator algorithmparametergenerator = AlgorithmParameterGenerator.getInstance(s);
        AlgorithmParameters algorithmparameters = algorithmparametergenerator.generateParameters();
        ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(algorithmparameters.getEncoded("ASN.1"));
        ASN1InputStream asn1inputstream = new ASN1InputStream(bytearrayinputstream);
        ASN1Primitive derobject = asn1inputstream.readObject();
        KeyGenerator keygenerator = KeyGenerator.getInstance(s);
        keygenerator.init(128);
        SecretKey secretkey = keygenerator.generateKey();
        Cipher cipher = Cipher.getInstance(s);
        cipher.init(1, secretkey, algorithmparameters);
View Full Code Here

  public static String toString(final byte[] bytes) {
    return new String(bytes, ConstantesICPBrasil.DEFAULT_CHARSET);
  }

  public static String getStringFromTag(final DERTaggedObject tag) {
    ASN1Primitive obj = tag.getObject();
    return ICPBrasilHelper.getStringFromObject(obj);
  }
View Full Code Here

        SignerInformationStore signerInformationStore = signedData.getSignerInfos();
        List list = new ArrayList();
        for (Object o : signerInformationStore.getSigners()) {
          SignerInformation signerInformation = (SignerInformation) o;
          TimeStamp timeStamp = timeStampClient.getTimeStamp(signerInformation.getSignature());
          ASN1Primitive asn1Primitive = BouncyCastleProviderHelper.toASN1Primitive(timeStamp.getEncoded());
          DERSet derSet = new DERSet(asn1Primitive);

          Hashtable hashtable = new Hashtable();
          Attribute attribute = new Attribute(PKCSObjectIdentifiers.id_aa_signatureTimeStampToken, derSet);
          hashtable.put(PKCSObjectIdentifiers.id_aa_signatureTimeStampToken, attribute);
View Full Code Here

          // unsignedAttributeTable, PKCSObjectIdentifiers.pkcs_9_at_messageDigest);

          DERSequence timeStampDerSequence = this.getAttribute(signedAttributeTable, unsignedAttributeTable, PKCSObjectIdentifiers.id_aa_signatureTimeStampToken);
          if (timeStampDerSequence != null) {
            if (timeStampDerSequence.size() == 2) {
              ASN1Primitive derObjectIdentifier = ((ASN1Primitive) timeStampDerSequence.getObjectAt(0)).toASN1Primitive();
              ASN1Primitive derObjectValue = ((ASN1Primitive) timeStampDerSequence.getObjectAt(1)).toASN1Primitive();
              if ((derObjectIdentifier instanceof ASN1ObjectIdentifier) && (derObjectValue instanceof DERSet)) {
                // ASN1ObjectIdentifier asn1ObjectIdentifier = (ASN1ObjectIdentifier)
                // derObjectIdentifier;
                DERSet set = (DERSet) derObjectValue;
                ASN1Encodable encodable = set.getObjectAt(0);
                TimeStampToken timeStampToken = new TimeStampToken(new CMSSignedData(encodable.toASN1Primitive().getEncoded()));
                TimeStamp timeStamp = BouncyCastleTimeStampHelper.toTimeStamp(timeStampToken);
                signature.setTimeStamp(timeStamp);
              }
            }
          }

          DERSequence signTimeDerSequence = this.getAttribute(signedAttributeTable, unsignedAttributeTable, PKCSObjectIdentifiers.pkcs_9_at_signingTime);
          if (signTimeDerSequence != null) {
            ASN1Primitive derObjectIdentifier = ((ASN1Primitive) signTimeDerSequence.getObjectAt(0)).toASN1Primitive();
            ASN1Primitive derObjectValue = ((ASN1Primitive) signTimeDerSequence.getObjectAt(1)).toASN1Primitive();
            if ((derObjectIdentifier instanceof ASN1ObjectIdentifier) && (derObjectValue instanceof DERSet)) {
              DERSet set = (DERSet) derObjectValue;
              ASN1UTCTime time = (ASN1UTCTime) set.getObjectAt(0);
              signature.setDate(time.getAdjustedDate());
            }
View Full Code Here

    if (crldistribuitionPointsBytes == null) {
      return new URL[0];
    }

    ASN1Primitive crldistribuitionPointsObject = BouncyCastleProviderHelper.toASN1Primitive(crldistribuitionPointsBytes);
    DEROctetString crldistribuitionPointsString = (DEROctetString) crldistribuitionPointsObject;

    crldistribuitionPointsObject = BouncyCastleProviderHelper.toASN1Primitive(crldistribuitionPointsString.getOctets());
    CRLDistPoint distPoint = CRLDistPoint.getInstance(crldistribuitionPointsObject);
View Full Code Here

    return s;
  }

  public static ASN1Primitive toASN1Primitive(final byte[] bytes) throws IOException {
    ASN1InputStream inputStream = new ASN1InputStream(bytes);
    ASN1Primitive obj = inputStream.readObject();
    inputStream.close();
    return obj;
  }
View Full Code Here

    {
        String value = Strings.toLowerCase(s.trim());

        if (value.length() > 0 && value.charAt(0) == '#')
        {
            ASN1Primitive obj = decodeObject(value);

            if (obj instanceof ASN1String)
            {
                value = Strings.toLowerCase(((ASN1String)obj).getString().trim());
            }
View Full Code Here

TOP

Related Classes of org.bouncycastle.asn1.ASN1Primitive

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.