code: public static DerId decode(ByteBuffer buf) {
          if (buf == null || buf.remaining() == 0) {
              throw new IllegalArgumentException("Null or empty buffer");
          }
  
          DerId id = new DerId();
  
          byte first = buf.get(); // first octet
  
          // Bits 8 and 7 represent the tag class
          id.tagClass = TagClass.values()[(first & 0xc0) >> 6];
  
          // Bit 6 represents the encoding type
          id.encodingType = EncodingType.values()[(first & 0x20) >> 5];
  
          // Bits 5 through 1 represent the tag number if tag number is less than 30.
          // Bits 5 through 1 are set to 1 if the tag number is greater than 30.
          int tagNum = first & 0x1f;
          if (tagNum == 0x1F) {
              // Tag number greater than 30
              if (buf.remaining() == 0) {
                  throw new IllegalArgumentException("Insufficient data to decode tag number greater than 30");
              }
              tagNum = 0;
              while (buf.hasRemaining()) {
                  byte octet = buf.get();
                  tagNum = (tagNum << 7) + (octet & 0x7f);
                  if ((octet >> 7) == 0) {
                      break;
                  }
              }
          }
          id.tagNumber = tagNum;
  
          return id;
      }
docs: Decodes identifier octets from a DER-encoded message.
  
  @param buf
  the buffer containing the DER-encoded message
  @return the DER identifier