Package codec.asn1

Examples of codec.asn1.ASN1IA5String


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

  attributes_ = new ASN1Set();
  add(new ASN1TaggedType(0, attributes_, false, true));
    }
View Full Code Here


  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);
View Full Code Here

     */
    public SecretBag() {
  super(2);
  ASN1ObjectIdentifier secretTypeId = new ASN1ObjectIdentifier();
  ASN1OpenType ot = new ASN1OpenType(reg_, secretTypeId);
  secretValue_ = new ASN1TaggedType(0, ot, true);
    }
View Full Code Here

  if (!(values_ instanceof ASN1SetOf)) {
      return;
  }
  ArrayList list;
  ASN1Type o;
  Iterator i;

  try {
      list = new ArrayList(values_.size());
View Full Code Here

     *
     * @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

        .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

TOP

Related Classes of codec.asn1.ASN1IA5String

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.