Examples of DEREncoder


Examples of codec.asn1.DEREncoder

     */
    private ContentInfo makeData(SafeContents safe) throws IOException,
      ASN1Exception {
  Data data = null;
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  DEREncoder encoder = new DEREncoder(baos);
  safe.encode(encoder);
  data = new Data(baos.toByteArray());
  baos.close();
  ContentInfo cInfo = new ContentInfo(data);
  return cInfo;
View Full Code Here

Examples of codec.asn1.DEREncoder

    private ContentInfo makeEncryptedData(SafeContents safe, char[] pwd,
      String algorithm) throws IOException, ASN1Exception,
      GeneralSecurityException {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  ByteArrayInputStream bais;
  DEREncoder encoder = new DEREncoder(baos);
  safe.encode(encoder);
  byte[] help = baos.toByteArray();

  // for ( int i = 0; i < help.length; i++)
  // System.out.print(help[i] + "\t");
View Full Code Here

Examples of codec.asn1.DEREncoder

      java.security.cert.X509Certificate[] cert) throws IOException,
      GeneralSecurityException, BadNameException, ASN1Exception {
  // BER encode the SafeBag
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  ByteArrayInputStream bais;
  DEREncoder encoder = new DEREncoder(baos);
  safe.encode(encoder);
  bais = new ByteArrayInputStream(baos.toByteArray());
  baos.close();

  // Make an envelopedData and put it in a ContentInfo
View Full Code Here

Examples of codec.asn1.DEREncoder

     *                 if an exception is thrown while encoding the given key.
     *                 No such exception should ever happen.
     */
    public PrivateKeyInfo(AlgorithmIdentifier aid, ASN1Type key) {
  ByteArrayOutputStream bos;
  DEREncoder enc;
  byte[] code;

  version_ = new ASN1Integer(VERSION);
  add(version_);

  algorithm_ = aid;
  add(algorithm_);

  try {
      bos = new ByteArrayOutputStream();
      enc = new DEREncoder(bos);
      key.encode(enc);
      code = bos.toByteArray();
      enc.close();
  } catch (IOException e) {
      throw new InconsistentStateException("Caught IOException!");
  } catch (ASN1Exception e) {
      throw new InconsistentStateException("Caught ASN1Exception!");
  }
View Full Code Here

Examples of codec.asn1.DEREncoder

     *                 defined by the installed providers.
     */
    public PrivateKey getPrivateKey() throws NoSuchAlgorithmException {
  ByteArrayOutputStream bos;
  PKCS8EncodedKeySpec spec;
  DEREncoder enc;
  KeyFactory kf;
  String alg;

  try {
      bos = new ByteArrayOutputStream();
      enc = new DEREncoder(bos);
      encode(enc);
      spec = new PKCS8EncodedKeySpec(bos.toByteArray());
      enc.close();

      alg = algorithm_.getAlgorithmOID().toString();
      kf = KeyFactory.getInstance(alg);

      return kf.generatePrivate(spec);
View Full Code Here

Examples of codec.asn1.DEREncoder

     *                 if an internal error occurs while the key is encoded.
     *                 This should never happen.
     */
    protected void setRawKey(ASN1Type key) {
  ByteArrayOutputStream bos;
  DEREncoder enc;

  try {
      bos = new ByteArrayOutputStream();
      enc = new DEREncoder(bos);
      key.encode(enc);
      encodedKey_ = new ASN1OctetString(bos.toByteArray());
      enc.close();
      set(2, encodedKey_);
  } catch (ASN1Exception e) {
      throw new InconsistentStateException("Internal, encoding error!");
  } catch (IOException e) {
      throw new InconsistentStateException(
View Full Code Here

Examples of codec.asn1.DEREncoder

  byte[] res;

  try {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();

      encode(new DEREncoder(baos));
      res = baos.toByteArray();
      baos.close();
  } catch (IOException e) {
      throw new ASN1Exception(e.getMessage());
  }
View Full Code Here

Examples of codec.asn1.DEREncoder

  byte[] res;

  try {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();

      certificationRequestInfo_.encode(new DEREncoder(baos));
      res = baos.toByteArray();
      baos.close();
  } catch (IOException e) {
      throw new CorruptedCodeException("internal error: "
        + e.getMessage());
View Full Code Here

Examples of codec.asn1.DEREncoder

  byte[] res = null;

  ByteArrayOutputStream baos = new ByteArrayOutputStream();

  try {
      encode(new DEREncoder(baos));
      res = baos.toByteArray();
      baos.close();
  } catch (IOException e) {
      System.out.println("internal error:");
      e.printStackTrace();
View Full Code Here

Examples of codec.asn1.DEREncoder

  byte[] res = null;

  ByteArrayOutputStream baos = new ByteArrayOutputStream();

  try {
      encode(new DEREncoder(baos));
      res = baos.toByteArray();
      baos.close();
      s.write(res);
  } catch (ASN1Exception e) {
      throw new RuntimeException(e.toString());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.