예제 #1
0
        /// <summary>
        /// Reads a title key for a sector on the disc.
        /// </summary>
        /// <param name="buffer">Buffer where the bus key will be stored</param>
        /// <param name="senseBuffer">Sense buffer.</param>
        /// <param name="keyClass">Key class.</param>
        /// <param name="address">The sector address to get the key for.</param>
        /// <param name="timeout">Timeout in seconds.</param>
        /// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
        /// <returns><c>true</c> if the command failed and <paramref name="senseBuffer" /> contains the sense buffer.</returns>
        public bool ReadTitleKey(out byte[] buffer, out byte[] senseBuffer, DvdCssKeyClass keyClass, ulong address,
                                 uint timeout, out double duration)
        {
            // We need to be in a bus key state to read title keys. Only CSS has title keys.
            ReadBusKey(out buffer, out senseBuffer, CopyrightType.CSS, timeout, out duration);

            BusKey = buffer;

            senseBuffer = new byte[32];
            byte[] cdb = new byte[12];
            buffer = new byte[12];

            cdb[0]  = (byte)ScsiCommands.ReportKey;
            cdb[2]  = (byte)((address & 0xFF000000) >> 24);
            cdb[3]  = (byte)((address & 0xFF0000) >> 16);
            cdb[4]  = (byte)((address & 0xFF00) >> 8);
            cdb[5]  = (byte)(address & 0xFF);
            cdb[7]  = (byte)keyClass;
            cdb[8]  = (byte)((buffer.Length & 0xFF00) >> 8);
            cdb[9]  = (byte)(buffer.Length & 0xFF);
            cdb[10] = (byte)((byte)CssReportKeyFormat.TitleKey ^ ((Agid & 0x03) << 6));

            _dev.SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
                                 out bool sense);

            AaruConsole.DebugWriteLine("SCSI Device", "GET TITLE KEY (AGID: {1}, LBA: {2}, Sense: {3}) took {0} ms.",
                                       duration, Agid, address, sense);

            return(sense);
        }
예제 #2
0
        /// <summary>
        /// Send KEY2 to the logical unit.
        /// </summary>
        /// <param name="buffer">Buffer where the Regional Playback Control State will be stored.</param>
        /// <param name="senseBuffer">Sense buffer.</param>
        /// <param name="keyClass">Key class.</param>
        /// <param name="key2">The KEY2 message.</param>
        /// <param name="timeout">Timeout in seconds.</param>
        /// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
        /// <returns><c>true</c> if the command failed and <paramref name="senseBuffer" /> contains the sense buffer.</returns>
        public bool SendKey2(out byte[] buffer, out byte[] senseBuffer, DvdCssKeyClass keyClass, byte[] key2,
                             uint timeout, out double duration)
        {
            senseBuffer = new byte[32];
            byte[] cdb = new byte[12];
            buffer = new byte[12];

            cdb[0]    = (byte)ScsiCommands.SendKey;
            cdb[7]    = (byte)keyClass;
            cdb[8]    = (byte)((buffer.Length & 0xFF00) >> 8);
            cdb[9]    = (byte)(buffer.Length & 0xFF);
            cdb[10]   = (byte)((byte)CssSendKeyFormat.Key2 ^ ((Agid & 0x03) << 6));
            buffer[0] = (byte)(((buffer.Length - 2) & 0xFF00) >> 8);
            buffer[1] = (byte)((buffer.Length - 2) & 0xFF);
            buffer[4] = key2[4];
            buffer[5] = key2[3];
            buffer[6] = key2[2];
            buffer[7] = key2[1];
            buffer[8] = key2[0];

            _dev.SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
                                 out bool sense);

            AaruConsole.DebugWriteLine("SCSI Device",
                                       "SEND CHALLENGE (AGID: {1}, KEY2 {2}, Sense: {3}, Last Error: {4}) took {0} ms.",
                                       duration, Agid, key2, sense, _dev.LastError);

            return(sense);
        }
예제 #3
0
        /// <summary>
        /// Returns the Authentication Success Flag of the logical unit.
        /// </summary>
        /// <returns><c>true</c> if the command failed and <paramref name="senseBuffer" /> contains the sense buffer.</returns>
        /// <param name="buffer">Buffer where the Authentication Success Flag will be stored.</param>
        /// <param name="senseBuffer">Sense buffer.</param>
        /// <param name="keyClass">Key class.</param>
        /// <param name="timeout">Timeout in seconds.</param>
        /// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
        public bool ReadAsf(out byte[] buffer, out byte[] senseBuffer, DvdCssKeyClass keyClass, uint timeout,
                            out double duration)
        {
            senseBuffer = new byte[32];
            byte[] cdb = new byte[12];
            buffer = new byte[8];

            cdb[0]  = (byte)ScsiCommands.ReportKey;
            cdb[7]  = (byte)keyClass;
            cdb[8]  = (byte)((buffer.Length & 0xFF00) >> 8);
            cdb[9]  = (byte)(buffer.Length & 0xFF);
            cdb[10] = (byte)((byte)CssReportKeyFormat.Asf ^ ((Agid & 0x03) << 6));

            _dev.SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
                                 out bool sense);

            AaruConsole.DebugWriteLine("SCSI Device",
                                       "REPORT ASF (AGID: {1}, Sense: {2}, Last Error: {3}) took {0} ms.", duration,
                                       Agid, sense, _dev.LastError);

            return(sense);
        }