Exemple #1
0
  /**
   * Used to decode the integer value from the ASN.1 buffer. The passed encoder is used to decode
   * the ASN.1 information and the integer value is stored in the internal object.
   *
   * @param buf The encoded ASN.1 data
   * @param offset The offset of the first byte of data
   * @param encoder The ASN.1 decoder object.
   * @return The byte immediantly after the last decoded byte of information.
   */
  public int decodeASN(byte[] buf, int offset, AsnEncoder encoder) throws AsnDecodingException {
    Object[] rVals = encoder.parseInteger32(buf, offset);

    if (((Byte) rVals[1]).byteValue() != typeId())
      throw new AsnDecodingException("Invalid ASN.1 type");

    m_value = ((Integer) rVals[2]).intValue();

    return ((Integer) rVals[0]).intValue();
  }
  /**
   * Encodes the ASN.1 octet string using the passed encoder and stores the results in the passed
   * buffer. An exception is thrown if an error occurs with the encoding of the information.
   *
   * @param buf The buffer to write the encoded information.
   * @param offset The offset to start writing information
   * @param encoder The encoder object.
   * @return The offset of the byte immediantly after the last encoded byte.
   * @exception AsnEncodingException Thrown if the encoder finds an error in the buffer.
   */
  @Override
  public int encodeASN(byte[] buf, int offset, AsnEncoder encoder) throws AsnEncodingException {
    if (m_data == null) throw new AsnEncodingException("No data in octet string");

    return encoder.buildString(buf, offset, typeId(), m_data);
  }
Exemple #3
0
 /**
  * Used to encode the integer value into an ASN.1 buffer. The passed encoder defines the method
  * for encoding the data.
  *
  * @param buf The location to write the encoded data
  * @param offset The start of the encoded buffer.
  * @param encoder The ASN.1 encoder object
  * @return The byte immediantly after the last encoded byte.
  */
 public int encodeASN(byte[] buf, int offset, AsnEncoder encoder) throws AsnEncodingException {
   return encoder.buildInteger32(buf, offset, typeId(), m_value);
 }