Package codec.asn1

Examples of codec.asn1.ASN1GeneralizedTime


     *
     * @return The raw key decoded according to DER.
     */
    public ASN1Type getDecodedRawKey() throws CorruptedCodeException {
  DERDecoder dec;
  ASN1Type raw;

  try {
      dec = new DERDecoder(new ByteArrayInputStream(encodedKey_
        .getByteArray()));

View Full Code Here


     *                The {@link Decoder Decoder} to use.
     */
    public void decode(Decoder decoder) throws ASN1Exception, IOException {
  super.decode(decoder);

  ASN1Type t;
  ASN1OpenType o;

  t = certValue_.getInnerType();
  if (t instanceof ASN1OpenType) {
      o = (ASN1OpenType) t;
View Full Code Here

        .println("This bag is either password or public-key protected.");
      return null;
  }
  bais = new ByteArrayInputStream(encodedData);
  SafeContents safe = new SafeContents();
  BERDecoder decoder = new BERDecoder(bais);
  safe.decode(decoder);
  bais.close();
  return safe;
    }
View Full Code Here

  SecretKey pbeKey = skf.generateSecret(pbeSpec);
  encData.init(pbeKey);
  data = encData.getData();
  bais = new ByteArrayInputStream(data);
  SafeContents safe = new SafeContents();
  BERDecoder decoder = new BERDecoder(bais);
  safe.decode(decoder);
  bais.close();
  return safe;
    }
View Full Code Here

  envData.init(cert, key);
  byte[] data = envData.getData();

  bais = new ByteArrayInputStream(data);
  SafeContents safe = new SafeContents();
  BERDecoder decoder = new BERDecoder(bais);
  safe.decode(decoder);
  bais.close();
  return safe;
    }
View Full Code Here

  AlgorithmIdentifier aid;
  PBEParameterSpec pspec;
  SecretKeyFactory skf;
  PrivateKeyInfo pki;
  KeyFactory kf;
  DERDecoder dec;
  SecretKey secret;
  KeySpec kspec;
  Cipher cipher;
  String name;
  byte[] buf;

  try {
      name = algorithm_.getAlgorithmOID().toString();
      params = algorithm_.getParameters();
      pspec = (PBEParameterSpec) params
        .getParameterSpec(PBEParameterSpec.class);

      skf = SecretKeyFactory.getInstance(name);
      kspec = new PBEKeySpec(password);
      secret = skf.generateSecret(kspec);

      cipher = Cipher.getInstance(name);
      cipher.init(Cipher.DECRYPT_MODE, secret, pspec);

      buf = cipher.doFinal(encryptedData_.getByteArray());
      kspec = new PKCS8EncodedKeySpec(buf);

      pki = new PrivateKeyInfo();
      dec = new DERDecoder(new ByteArrayInputStream(buf));
      pki.decode(dec);
      dec.close();

      aid = pki.getAlgorithmIdentifier();
      name = aid.getAlgorithmOID().toString();
      kf = KeyFactory.getInstance(name);
View Full Code Here

     */
    public void setPrivateKey(PrivateKey key) throws InvalidKeyException {
  if (key == null)
      throw new NullPointerException("Key is null!");

  DERDecoder dec;

  clear();

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

  algorithm_ = new AlgorithmIdentifier();
  add(algorithm_);

  encodedKey_ = new ASN1OctetString();
  add(encodedKey_);

  attributes_ = new ASN1SetOf(Attribute.class);
  add(new ASN1TaggedType(0, attributes_, false, true));

  try {
      dec = new DERDecoder(new ByteArrayInputStream(key.getEncoded()));

      decode(dec);
      dec.close();
  } catch (IOException e) {
      throw new InvalidKeyException("Caught IOException!");
  } catch (ASN1Exception e) {
      throw new InvalidKeyException("Bad encoding!");
  }
View Full Code Here

     * encodings.
     *
     * @return The raw key decoded according to DER.
     */
    public ASN1Type getDecodedRawKey() throws CorruptedCodeException {
  DERDecoder dec;
  ASN1Type raw;

  try {
      dec = new DERDecoder(new ByteArrayInputStream(encodedKey_
        .getByteArray()));

      raw = dec.readType();
      dec.close();

      return raw;
  } catch (ASN1Exception e) {
      throw new CorruptedCodeException("Cannot decode raw key!");
  } catch (IOException e) {
View Full Code Here

  this();

  try {
      ByteArrayInputStream bais = new ByteArrayInputStream(enc);

      decode(new DERDecoder(bais));
      bais.close();
  } catch (IOException e) {
      throw new ASN1Exception(e.getMessage());
  }
    }
View Full Code Here

     */
    public CertificationRequest(InputStream in) throws ASN1Exception,
      IOException {
  this();

  DERDecoder dec;

  dec = new DERDecoder(in);
  decode(dec);
  dec.close();
    }
View Full Code Here

TOP

Related Classes of codec.asn1.ASN1GeneralizedTime

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.