private short parseTLVLength(byte[] data, short dataOffset, short[] result) {
        if (data[dataOffset] == (byte) 0x81) {
            result[0] = data[(short) (dataOffset + 1)];
            return (short) (dataOffset + 2);
        }
        else {
            if (data[dataOffset] == (byte) 0x82) {
                result[0] = Util.makeShort(data[(short) (dataOffset + 1)], data[(short)(dataOffset + 2)]);
                return (short) (dataOffset + 3);
            }
            else { ISOException.throwIt((short) (ISO7816.SW_WRONG_DATA + 2)); }
        }     
        return dataOffset;
    }