mirror of
https://github.com/martijnvanbrummelen/nwipe.git
synced 2026-02-22 15:02:12 +00:00
Compare commits
53 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf3ae6a0f6 | ||
|
|
a88eeb9383 | ||
|
|
a84894f317 | ||
|
|
5c3eed8813 | ||
|
|
4b1c7007ff | ||
|
|
970d74f0d5 | ||
|
|
c815235f7b | ||
|
|
dcfa13a8db | ||
|
|
a1560de8b5 | ||
|
|
18386f225e | ||
|
|
1f3b36f141 | ||
|
|
962e1053dd | ||
|
|
93ea5f85d0 | ||
|
|
76a7be696c | ||
|
|
630d107558 | ||
|
|
5adc34b9e3 | ||
|
|
5bc61f2bdd | ||
|
|
b55b020a83 | ||
|
|
b34c99b81b | ||
|
|
63d20dc4be | ||
|
|
2111206fa3 | ||
|
|
5263a23cd6 | ||
|
|
a6b60bfd15 | ||
|
|
d8d627dce3 | ||
|
|
95d0b3f382 | ||
|
|
055d2e8b0c | ||
|
|
9f0674b3b9 | ||
|
|
5f332a407d | ||
|
|
543a880064 | ||
|
|
62c604bc0e | ||
|
|
2bc62a7217 | ||
|
|
7f5bc5aa34 | ||
|
|
7fa5c98023 | ||
|
|
4e159a902c | ||
|
|
3090b0682f | ||
|
|
d2dff52407 | ||
|
|
58a5184c88 | ||
|
|
6dcaaa6920 | ||
|
|
8e9e2ae90f | ||
|
|
02e356e0ec | ||
|
|
12063ad954 | ||
|
|
66d239c980 | ||
|
|
462777d92b | ||
|
|
69c9d7d6c5 | ||
|
|
fffee8bb34 | ||
|
|
b8a536a02f | ||
|
|
0c542660ff | ||
|
|
412917ab17 | ||
|
|
f5501ccc45 | ||
|
|
d819330583 | ||
|
|
2061346ace | ||
|
|
69fed30dde | ||
|
|
7cc1a68a89 |
19
CHANGELOG.md
19
CHANGELOG.md
@@ -1,6 +1,25 @@
|
||||
RELEASE NOTES
|
||||
=============
|
||||
|
||||
v0.31
|
||||
-----------------------
|
||||
- Blanking disabled in GUI for OPS2 (mandatory requirement of standard). [#326](https://github.com/martijnvanbrummelen/nwipe/pull/326)
|
||||
- Total bytes written/read for ALL passes or verifications are now logged. [#326](https://github.com/martijnvanbrummelen/nwipe/pull/326)
|
||||
- Final blanking being enabled is no longer required for verification passes. GUI Fix. [#326](https://github.com/martijnvanbrummelen/nwipe/pull/326)
|
||||
- Add a summary table to the log that shows totals for pass & verification errors. [#325](https://github.com/martijnvanbrummelen/nwipe/pull/325)
|
||||
- Fix the missing 'Verifying' message on final blanking. [#324](https://github.com/martijnvanbrummelen/nwipe/pull/324)
|
||||
- Fix prng selection always using mersenne irrespective of whatever prng the user selected. [#323](https://github.com/martijnvanbrummelen/nwipe/pull/323)
|
||||
- Fix a non functional Isaac prng. (May have never worked even in DBAN/dwipe 2.3.0). [#322](https://github.com/martijnvanbrummelen/nwipe/pull/322)
|
||||
- Log whether the prng produces a stream, if not log failure message. [#321](https://github.com/martijnvanbrummelen/nwipe/pull/321)
|
||||
- Log the specific prng that is initialised. [#320](https://github.com/martijnvanbrummelen/nwipe/pull/320)
|
||||
- Log selection details to the log. [#319](https://github.com/martijnvanbrummelen/nwipe/pull/319)
|
||||
- Improve log messaging. [#317](https://github.com/martijnvanbrummelen/nwipe/pull/317)
|
||||
- Fix auto shutdown option for some distros. [#315](https://github.com/martijnvanbrummelen/nwipe/pull/315)
|
||||
- Fix build for musl. [#301](https://github.com/martijnvanbrummelen/nwipe/pull/301)
|
||||
- Fixes to summary table & fix final status message. [311](https://github.com/martijnvanbrummelen/nwipe/pull/311/commits/12063ad9549860cd625cb91d047bd304217a9ebf)
|
||||
- Updates to --help options [#309](https://github.com/martijnvanbrummelen/nwipe/pull/309/commits/69c9d7d6c5a091c58b3e747078d0022ccdd95a99)
|
||||
- Updates to manpage. [#300](https://github.com/martijnvanbrummelen/nwipe/commit/7cc1a68a89236c4b501dde9149be82c208defccd)
|
||||
|
||||
v0.30
|
||||
-----------------------
|
||||
- Add auto power off option on completion of wipe ( --autopoweroff ) (Thanks PartialVolume)
|
||||
|
||||
@@ -23,7 +23,7 @@ It also includes the following pseudo random number generators:
|
||||
* ISAAC
|
||||
|
||||
It is a fork of the dwipe command used by
|
||||
Darik's Boot and Nuke (dban). nwipe is included with [partedmagic](https://partedmagic.com), [SystemRescueCD](http://www.system-rescue-cd) and
|
||||
Darik's Boot and Nuke (dban). nwipe is included with [partedmagic](https://partedmagic.com), [SystemRescueCD](https://www.system-rescue.org), [gparted live](https://sourceforge.net/projects/gparted/files/gparted-live-testing/1.2.0-2/) and
|
||||
[ShredOS](https://github.com/nadenislamarre/shredos)/[ShredOS 2020](https://github.com/PartialVolume/shredos.2020.02) if you want a quick and easy, bootable CD or USB version. If you want a bootable version of the very latest nwipe master that you can write to a USB stick, see [quick and easy bootable version of nwipe master](https://github.com/martijnvanbrummelen/nwipe#quick--easy-usb-bootable-version-of-nwipe-master-for-x86_64-systems)
|
||||
|
||||
Nwipe was created out of a need to run the DBAN dwipe command outside
|
||||
@@ -104,6 +104,7 @@ First create all the autoconf files:
|
||||
Then compile & install using the following standard commands:
|
||||
```
|
||||
./configure
|
||||
make format (only required if submitting pull requests)
|
||||
make
|
||||
make install
|
||||
```
|
||||
@@ -125,6 +126,7 @@ This can be done using the following compile commands:
|
||||
|
||||
```
|
||||
./configure --prefix=/usr CFLAGS='-O0 -g -Wall -Wextra'
|
||||
make format (necessary if submitting pull requests)
|
||||
make
|
||||
make install
|
||||
```
|
||||
@@ -164,7 +166,7 @@ cd ~/nwipe_master/nwipe/src
|
||||
Note the ./, that means only look in the current directory for nwipe. if you forgot to type ./ the computer would run the older repository version of nwipe.
|
||||
|
||||
Once you have copied the script below into a file called buildnwipe, you need to give the file execute permissions `chmod +x buildnwipe` before you can run it. [Download script](
|
||||
https://drive.google.com/file/d/1-kKgvCvKYYuSH_UUBKrLwsI0Xf7fckGg/view?usp=sharing)
|
||||
https://drive.google.com/file/d/1BsQDlMqtEycAgfk9FpG1sxv3jFz5dzNO/view?usp=sharing)
|
||||
```
|
||||
#!/bin/bash
|
||||
cd "$HOME"
|
||||
@@ -184,6 +186,9 @@ sudo ./nwipe
|
||||
## Quick & Easy, USB bootable version of Nwipe Master for x86_64 systems.
|
||||
If you want to just try out a bootable version of nwipe you can download the ShredOS image that's using the latest version of nwipe master and burn it to a USB stick. Instructions and download can be found [here](https://github.com/PartialVolume/shredos.2020.02/blob/master/README.md#obtaining-and-writing-shredos-to-a-usb-flash-drive-the-easy-way-)
|
||||
|
||||
## Which Linux distro uses the latest Nwipe?
|
||||
See [Repology](https://repology.org/project/nwipe/versions)
|
||||
|
||||
## Bugs
|
||||
|
||||
Bugs can be reported on GitHub:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.64])
|
||||
AC_INIT([nwipe], [0.30], [git@brumit.nl])
|
||||
AC_INIT([nwipe], [0.31], [git@brumit.nl])
|
||||
AM_INIT_AUTOMAKE(foreign subdir-objects)
|
||||
AC_OUTPUT(Makefile src/Makefile man/Makefile)
|
||||
AC_CONFIG_SRCDIR([src/nwipe.c])
|
||||
|
||||
16
man/nwipe.1
16
man/nwipe.1
@@ -1,4 +1,4 @@
|
||||
.TH NWIPE "1" "December 2020" "nwipe version 0.30" "User Commands"
|
||||
.TH NWIPE "1" "June 2021" "nwipe version 0.31" "User Commands"
|
||||
.SH NAME
|
||||
nwipe \- securely erase disks
|
||||
.SH SYNOPSIS
|
||||
@@ -38,8 +38,18 @@ those specified devices immediately.
|
||||
Power off system on completion of wipe delayed for for one minute. During
|
||||
this one minute delay you can abort the shutdown by typing sudo shutdown -c
|
||||
.TP
|
||||
\fB\-\-sync\fR
|
||||
Open devices in sync mode
|
||||
\fB\-\-sync\fR=\fINUM\fR
|
||||
Will perform a syn after NUM writes (default: 10000)
|
||||
.IP
|
||||
0 \- fdatasync after the disk is completely written
|
||||
fdatasync errors not detected until completion.
|
||||
0 is not recommended as disk errors may cause nwipe
|
||||
to appear to hang
|
||||
.IP
|
||||
1 \- fdatasync after every write
|
||||
Warning: Lower values will reduce wipe speeds.
|
||||
.IP
|
||||
1000 \- fdatasync after 1000 writes
|
||||
.TP
|
||||
\fB\-\-noblank\fR
|
||||
Do not perform the final blanking pass after the wipe (default is to blank,
|
||||
|
||||
87
src/gui.c
87
src/gui.c
@@ -123,14 +123,24 @@ const char* options_title = " Options ";
|
||||
const char* stats_title = " Statistics ";
|
||||
|
||||
/* Footer labels. */
|
||||
const char* main_window_footer = "S=Start M=Method P=PRNG V=Verify R=Rounds B=Blanking Space=Select Ctrl-C=Quit";
|
||||
const char* main_window_footer_warning_lower_case_s =
|
||||
" WARNING: To start the wipe press capital S, you pressed lower case s ";
|
||||
const char* main_window_footer = "S=Start m=Method p=PRNG v=Verify r=Rounds b=Blanking Space=Select CTRL+C=Quit";
|
||||
const char* main_window_footer_warning_lower_case_s = " WARNING: To start the wipe press SHIFT+S (uppercase S) ";
|
||||
|
||||
const char* main_window_fotter_warning_no_blanking_with_ops2 =
|
||||
" WARNING: Zero blanking is not allowed with ops2 method ";
|
||||
|
||||
const char* main_window_fotter_warning_no_blanking_with_verify_only =
|
||||
" WARNING: Zero blanking is not allowed with verify method ";
|
||||
|
||||
const char* main_window_footer_warning_no_drive_selected =
|
||||
" No drives selected, use spacebar to select a drive, then press S to start ";
|
||||
const char* selection_footer = "J=Down K=Up Space=Select Backspace=Cancel Ctrl-C=Quit";
|
||||
const char* end_wipe_footer = "B=Blank screen Ctrl-C=Quit";
|
||||
const char* rounds_footer = "Left=Erase Esc=Cancel Ctrl-C=Quit";
|
||||
|
||||
/* Oddly enough, placing extra quotes around the footer strings fixes corruption to the right
|
||||
* of the footer message when the terminal is resized, a quirk in ncurses? - DO NOT REMOVE THE \" */
|
||||
const char* selection_footer = "\"J=Down K=Up Space=Select Backspace=Cancel Ctrl+C=Quit\"";
|
||||
const char* end_wipe_footer = "\"B=Blank screen Ctrl+C=Quit\"";
|
||||
const char* rounds_footer = "\"Left=Erase Esc=Cancel Ctrl+C=Quit\"";
|
||||
|
||||
const char* wipes_finished_footer = "Wipe finished - press enter to exit. Logged to STDOUT";
|
||||
|
||||
/* The number of lines available in the terminal */
|
||||
@@ -465,7 +475,7 @@ void nwipe_gui_create_all_windows_on_terminal_resize( const char* footer_text )
|
||||
/* If the user has resized the terminal then recreate the windows and panels */
|
||||
if( stdscr_cols_previous != stdscr_cols || stdscr_lines_previous != stdscr_lines )
|
||||
{
|
||||
/* save the revised terminal size so we check whether the user has resized next time */
|
||||
/* Save the revised terminal size so we check whether the user has resized next time */
|
||||
stdscr_lines_previous = stdscr_lines;
|
||||
stdscr_cols_previous = stdscr_cols;
|
||||
|
||||
@@ -541,7 +551,7 @@ void nwipe_gui_select( int count, nwipe_context_t** c )
|
||||
/* Flag, Valid key hit = 1, anything else = 0 */
|
||||
int validkeyhit;
|
||||
|
||||
/* counts number of drives and partitions that have been selected */
|
||||
/* Counts number of drives and partitions that have been selected */
|
||||
int number_of_selected_contexts = 0;
|
||||
|
||||
/* Control A toggle status -1=indefined, 0=all drives delected, 1=all drives selected */
|
||||
@@ -550,7 +560,7 @@ void nwipe_gui_select( int count, nwipe_context_t** c )
|
||||
/* Get the terminal size */
|
||||
getmaxyx( stdscr, stdscr_lines, stdscr_cols );
|
||||
|
||||
/* save the terminal size so we check whether the user has resized */
|
||||
/* Save the terminal size so we check whether the user has resized */
|
||||
stdscr_lines_previous = stdscr_lines;
|
||||
stdscr_cols_previous = stdscr_cols;
|
||||
|
||||
@@ -646,7 +656,7 @@ void nwipe_gui_select( int count, nwipe_context_t** c )
|
||||
waddch( main_window, ' ' );
|
||||
}
|
||||
|
||||
/* In the event of the offset value some how becoming invalid, this if statement will prevent a segfault
|
||||
/* In the event for the offset value somehow becoming invalid, this if statement will prevent a segfault
|
||||
* and the else part will log the out of bounds values for debugging */
|
||||
if( i + offset >= 0 && i + offset < count )
|
||||
{
|
||||
@@ -741,9 +751,9 @@ void nwipe_gui_select( int count, nwipe_context_t** c )
|
||||
keystroke = getch(); // Get user input.
|
||||
timeout( -1 ); // Switch back to blocking mode.
|
||||
|
||||
/* We don't necessarily use these but for future reference, here are some cntrl + key values
|
||||
* ^W - 23, ^E - 5, ^R - 18, ^T - 20, ^Y - 25, ^U - 21, ^I - 9, ^O - 15, ^P - 16, ^A - 1, ^D - 4
|
||||
* ^F - 6, ^G - 7, ^H - 8, ^K - 11, ^L - 12, ^X - 24, ^V - 22, ^B - 2, ^N - 14
|
||||
/* We don't necessarily use all of these. For future reference these are some CTRL+key values
|
||||
* ^A - 1, ^B - 2, ^D - 4, ^E - 5, ^F - 6, ^G - 7, ^H - 8, ^I - 9, ^K - 11, ^L - 12, ^N - 14,
|
||||
* ^O - 15, ^P - 16, ^R - 18, ^T - 20, ^U - 21, ^V - 22, ^W - 23, ^X - 24, ^Y - 25
|
||||
* Use nwipe_log( NWIPE_LOG_DEBUG, "Key Name: %s - %u", keyname(keystroke),keystroke) to
|
||||
* figure out what code is returned by what ever key combination */
|
||||
|
||||
@@ -967,6 +977,38 @@ void nwipe_gui_select( int count, nwipe_context_t** c )
|
||||
|
||||
validkeyhit = 1;
|
||||
|
||||
if( nwipe_options.method == &nwipe_ops2 )
|
||||
{
|
||||
/* Warn the user about that zero blanking with the ops2 method is not allowed */
|
||||
wattron( footer_window, COLOR_PAIR( 10 ) );
|
||||
nwipe_gui_amend_footer_window( main_window_fotter_warning_no_blanking_with_ops2 );
|
||||
doupdate();
|
||||
sleep( 3 );
|
||||
wattroff( footer_window, COLOR_PAIR( 10 ) );
|
||||
|
||||
/* After the delay return footer text back to key help */
|
||||
nwipe_gui_amend_footer_window( main_window_footer );
|
||||
doupdate();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if( nwipe_options.method == &nwipe_verify )
|
||||
{
|
||||
/* Warn the user about that zero blanking with the ops2 method is not allowed */
|
||||
wattron( footer_window, COLOR_PAIR( 10 ) );
|
||||
nwipe_gui_amend_footer_window( main_window_fotter_warning_no_blanking_with_verify_only );
|
||||
doupdate();
|
||||
sleep( 3 );
|
||||
wattroff( footer_window, COLOR_PAIR( 10 ) );
|
||||
|
||||
/* After the delay return footer text back to key help */
|
||||
nwipe_gui_amend_footer_window( main_window_footer );
|
||||
doupdate();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* Run the noblank dialog. */
|
||||
nwipe_gui_noblank();
|
||||
break;
|
||||
@@ -1145,6 +1187,13 @@ void nwipe_gui_options( void )
|
||||
} /* switch verify */
|
||||
|
||||
mvwprintw( options_window, NWIPE_GUI_OPTIONS_ROUNDS_Y, NWIPE_GUI_OPTIONS_ROUNDS_X, "Rounds: " );
|
||||
|
||||
/* Disable blanking for ops2 and verify methods */
|
||||
if( nwipe_options.method == &nwipe_ops2 || nwipe_options.method == &nwipe_verify )
|
||||
{
|
||||
nwipe_options.noblank = 1;
|
||||
}
|
||||
|
||||
if( nwipe_options.noblank )
|
||||
{
|
||||
wprintw( options_window, "%i (no final blanking pass)", nwipe_options.rounds );
|
||||
@@ -1818,10 +1867,6 @@ void nwipe_gui_noblank( void )
|
||||
{
|
||||
nwipe_options.noblank = focus;
|
||||
}
|
||||
if( nwipe_options.noblank )
|
||||
{
|
||||
nwipe_options.verify = NWIPE_VERIFY_NONE;
|
||||
}
|
||||
return;
|
||||
|
||||
case KEY_BACKSPACE:
|
||||
@@ -2428,7 +2473,7 @@ void* nwipe_gui_status( void* ptr )
|
||||
show_panel( options_panel );
|
||||
show_panel( main_panel );
|
||||
|
||||
/* reprint the footer */
|
||||
/* Reprint the footer */
|
||||
nwipe_gui_title( footer_window, end_wipe_footer );
|
||||
|
||||
// Refresh the footer_window ;
|
||||
@@ -2514,7 +2559,7 @@ void* nwipe_gui_status( void* ptr )
|
||||
|
||||
} /* keystroke */
|
||||
|
||||
/* if wipe has completed and user has specified auto poweroff or nowait then we can skip waiting for the user to
|
||||
/* If wipe has completed and user has specified auto poweroff or nowait then we can skip waiting for the user to
|
||||
* press return */
|
||||
if( !nwipe_active )
|
||||
{
|
||||
@@ -2643,7 +2688,7 @@ void* nwipe_gui_status( void* ptr )
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if the wipe thread is no longer active, replace the spinner with a space */
|
||||
/* If the wipe thread is no longer active, replace the spinner with a space */
|
||||
spinner_string[0] = ' ';
|
||||
}
|
||||
spinner_string[1] = 0;
|
||||
@@ -2889,7 +2934,7 @@ int spinner( nwipe_context_t** ptr, int device_idx )
|
||||
/* The spinner characters |/-\|/-\ */
|
||||
char sc[9] = "|/-\\|/-\\/";
|
||||
|
||||
/* check sanity of index */
|
||||
/* Check sanity of index */
|
||||
if( c[device_idx]->spinner_idx < 0 || c[device_idx]->spinner_idx > 7 )
|
||||
{
|
||||
return 1;
|
||||
|
||||
@@ -16,7 +16,7 @@ MODIFIED:
|
||||
|
||||
#ifndef RAND
|
||||
#define RAND
|
||||
#define RANDSIZL (8) /* I recommend 8 for crypto, 4 for simulations */
|
||||
#define RANDSIZL (4) /* I recommend 8 for crypto, 4 for simulations */
|
||||
#define RANDSIZ (1<<RANDSIZL)
|
||||
|
||||
/* context of random number generator */
|
||||
|
||||
103
src/logging.c
103
src/logging.c
@@ -601,6 +601,9 @@ int nwipe_log_sysinfo()
|
||||
|
||||
void nwipe_log_summary( nwipe_context_t** ptr, int nwipe_selected )
|
||||
{
|
||||
/* Prints two summary tables, the first is the device pass and verification summary
|
||||
* and the second is the main summary table detaining the drives, status, throughput,
|
||||
* model and serial number */
|
||||
int i;
|
||||
int idx_src;
|
||||
int idx_dest;
|
||||
@@ -646,12 +649,74 @@ void nwipe_log_summary( nwipe_context_t** ptr, int nwipe_selected )
|
||||
/* A pointer to the system time struct. */
|
||||
struct tm* p;
|
||||
|
||||
/* Nothing to do, user didn't select any devices */
|
||||
if( nwipe_selected == 0 )
|
||||
/* Nothing to do, user never started a wipe so no summary table required. */
|
||||
if( global_wipe_status == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Print the pass and verifications table */
|
||||
|
||||
/* IMPORTANT: Keep maximum columns (line length) to 80 characters for use with 80x30 terminals, Shredos, ALT-F2 etc
|
||||
* --------------------------------01234567890123456789012345678901234567890123456789012345678901234567890123456789-*/
|
||||
nwipe_log( NWIPE_LOG_NOTIMESTAMP, "" );
|
||||
nwipe_log( NWIPE_LOG_NOTIMESTAMP,
|
||||
"******************************** Error Summary *********************************" );
|
||||
nwipe_log( NWIPE_LOG_NOTIMESTAMP, "! Device | Pass Errors | Verifications Errors |" );
|
||||
nwipe_log( NWIPE_LOG_NOTIMESTAMP,
|
||||
"--------------------------------------------------------------------------------" );
|
||||
|
||||
for( i = 0; i < nwipe_selected; i++ )
|
||||
{
|
||||
if( c[i]->pass_errors != 0 || c[i]->verify_errors != 0 )
|
||||
{
|
||||
strncpy( exclamation_flag, "!", 1 );
|
||||
exclamation_flag[1] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( c[i]->wipe_status == 0 )
|
||||
{
|
||||
strncpy( exclamation_flag, " ", 1 );
|
||||
exclamation_flag[1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Device name, strip any prefixed /dev/.. leaving up to 6 right justified
|
||||
* characters eg " sda", prefixed with space to 6 characters, note that
|
||||
* we are processing the strings right to left */
|
||||
|
||||
idx_dest = 6;
|
||||
device[idx_dest--] = 0;
|
||||
idx_src = strlen( c[i]->device_name );
|
||||
idx_src--;
|
||||
|
||||
while( idx_dest >= 0 )
|
||||
{
|
||||
/* if the device name contains a / start prefixing spaces */
|
||||
if( c[i]->device_name[idx_src] == '/' )
|
||||
{
|
||||
device[idx_dest--] = ' ';
|
||||
continue;
|
||||
}
|
||||
if( idx_src >= 0 )
|
||||
{
|
||||
device[idx_dest--] = c[i]->device_name[idx_src--];
|
||||
}
|
||||
}
|
||||
nwipe_log( NWIPE_LOG_NOTIMESTAMP,
|
||||
"%s %s | %10llu | %10llu |",
|
||||
exclamation_flag,
|
||||
device,
|
||||
c[i]->pass_errors,
|
||||
c[i]->verify_errors );
|
||||
}
|
||||
|
||||
nwipe_log( NWIPE_LOG_NOTIMESTAMP,
|
||||
"********************************************************************************" );
|
||||
|
||||
/* Print the main summary table */
|
||||
|
||||
/* initialise */
|
||||
total_throughput = 0;
|
||||
|
||||
@@ -662,7 +727,7 @@ void nwipe_log_summary( nwipe_context_t** ptr, int nwipe_selected )
|
||||
* --------------------------------01234567890123456789012345678901234567890123456789012345678901234567890123456789-*/
|
||||
nwipe_log( NWIPE_LOG_NOTIMESTAMP, "" );
|
||||
nwipe_log( NWIPE_LOG_NOTIMESTAMP,
|
||||
"********************************************************************************" );
|
||||
"********************************* Drive Status *********************************" );
|
||||
nwipe_log( NWIPE_LOG_NOTIMESTAMP, "! Device | Status | Thru-put | HH:MM:SS | Model/Serial Number" );
|
||||
nwipe_log( NWIPE_LOG_NOTIMESTAMP,
|
||||
"--------------------------------------------------------------------------------" );
|
||||
@@ -711,7 +776,7 @@ void nwipe_log_summary( nwipe_context_t** ptr, int nwipe_selected )
|
||||
else
|
||||
{
|
||||
|
||||
if( c[i]->pass_errors != 0 )
|
||||
if( c[i]->pass_errors != 0 || c[i]->verify_errors != 0 )
|
||||
{
|
||||
strncpy( exclamation_flag, "!", 1 );
|
||||
exclamation_flag[1] = 0;
|
||||
@@ -721,15 +786,7 @@ void nwipe_log_summary( nwipe_context_t** ptr, int nwipe_selected )
|
||||
}
|
||||
else
|
||||
{
|
||||
if( user_abort == 1 )
|
||||
{
|
||||
strncpy( exclamation_flag, "!", 1 );
|
||||
exclamation_flag[1] = 0;
|
||||
|
||||
strncpy( status, "UABORTED", 8 );
|
||||
status[8] = 0;
|
||||
}
|
||||
else
|
||||
if( c[i]->wipe_status == 0 )
|
||||
{
|
||||
strncpy( exclamation_flag, " ", 1 );
|
||||
exclamation_flag[1] = 0;
|
||||
@@ -737,6 +794,26 @@ void nwipe_log_summary( nwipe_context_t** ptr, int nwipe_selected )
|
||||
strncpy( status, " Erased ", 8 );
|
||||
status[8] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( user_abort == 1 )
|
||||
{
|
||||
strncpy( exclamation_flag, "!", 1 );
|
||||
exclamation_flag[1] = 0;
|
||||
|
||||
strncpy( status, "UABORTED", 8 );
|
||||
status[8] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If this ever happens, there is a bug ! */
|
||||
strncpy( exclamation_flag, " ", 1 );
|
||||
exclamation_flag[1] = 0;
|
||||
|
||||
strncpy( status, "INSANITY", 8 );
|
||||
status[8] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
351
src/method.c
351
src/method.c
@@ -34,7 +34,7 @@
|
||||
*
|
||||
* WARNING: Never change nwipe_options after calling a method.
|
||||
*
|
||||
* NOTE: The nwipe_runmethod function appends a final pass to all methods.
|
||||
* NOTE: The nwipe_runmethod function appends a user selectable final blanking (zero) pass to all methods.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -131,9 +131,9 @@ void* nwipe_zero( void* ptr )
|
||||
|
||||
/* setup for a zero-fill. */
|
||||
|
||||
char zerofill[1] = {'\x00'};
|
||||
nwipe_pattern_t patterns[] = {{1, &zerofill[0]}, // pass 1: 0s
|
||||
{0, NULL}};
|
||||
char zerofill[1] = { '\x00' };
|
||||
nwipe_pattern_t patterns[] = { { 1, &zerofill[0] }, // pass 1: 0s
|
||||
{ 0, NULL } };
|
||||
|
||||
/* Run the method. */
|
||||
c->result = nwipe_runmethod( c, patterns );
|
||||
@@ -163,7 +163,7 @@ void* nwipe_verify( void* ptr )
|
||||
c->wipe_status = 1;
|
||||
|
||||
/* Do nothing because nwipe_runmethod appends a zero-fill. */
|
||||
nwipe_pattern_t patterns[] = {{0, NULL}};
|
||||
nwipe_pattern_t patterns[] = { { 0, NULL } };
|
||||
|
||||
/* Run the method. */
|
||||
c->result = nwipe_runmethod( c, patterns );
|
||||
@@ -199,14 +199,14 @@ void* nwipe_dod522022m( void* ptr )
|
||||
/* Random characters. (Elements 2 and 6 are unused.) */
|
||||
char dod[7];
|
||||
|
||||
nwipe_pattern_t patterns[] = {{1, &dod[0]}, // Pass 1: A random character.
|
||||
{1, &dod[1]}, // Pass 2: The bitwise complement of pass 1.
|
||||
{-1, ""}, // Pass 3: A random stream.
|
||||
{1, &dod[3]}, // Pass 4: A random character.
|
||||
{1, &dod[4]}, // Pass 5: A random character.
|
||||
{1, &dod[5]}, // Pass 6: The bitwise complement of pass 5.
|
||||
{-1, ""}, // Pass 7: A random stream.
|
||||
{0, NULL}};
|
||||
nwipe_pattern_t patterns[] = { { 1, &dod[0] }, // Pass 1: A random character.
|
||||
{ 1, &dod[1] }, // Pass 2: The bitwise complement of pass 1.
|
||||
{ -1, "" }, // Pass 3: A random stream.
|
||||
{ 1, &dod[3] }, // Pass 4: A random character.
|
||||
{ 1, &dod[4] }, // Pass 5: A random character.
|
||||
{ 1, &dod[5] }, // Pass 6: The bitwise complement of pass 5.
|
||||
{ -1, "" }, // Pass 7: A random stream.
|
||||
{ 0, NULL } };
|
||||
|
||||
/* Load the array with random characters. */
|
||||
r = read( c->entropy_fd, &dod, sizeof( dod ) );
|
||||
@@ -274,10 +274,10 @@ void* nwipe_dodshort( void* ptr )
|
||||
/* Random characters. (Element 3 is unused.) */
|
||||
char dod[3];
|
||||
|
||||
nwipe_pattern_t patterns[] = {{1, &dod[0]}, // Pass 1: A random character.
|
||||
{1, &dod[1]}, // Pass 2: The bitwise complement of pass 1.
|
||||
{-1, ""}, // Pass 3: A random stream.
|
||||
{0, NULL}};
|
||||
nwipe_pattern_t patterns[] = { { 1, &dod[0] }, // Pass 1: A random character.
|
||||
{ 1, &dod[1] }, // Pass 2: The bitwise complement of pass 1.
|
||||
{ -1, "" }, // Pass 3: A random stream.
|
||||
{ 0, NULL } };
|
||||
|
||||
/* Load the array with random characters. */
|
||||
r = read( c->entropy_fd, &dod, sizeof( dod ) );
|
||||
@@ -348,42 +348,42 @@ void* nwipe_gutmann( void* ptr )
|
||||
int n;
|
||||
|
||||
/* Define the Gutmann method. */
|
||||
nwipe_pattern_t book[] = {{-1, ""}, // Random pass.
|
||||
{-1, ""}, // Random pass.
|
||||
{-1, ""}, // Random pass.
|
||||
{-1, ""}, // Random pass.
|
||||
{3, "\x55\x55\x55"}, // Static pass: 0x555555 01010101 01010101 01010101
|
||||
{3, "\xAA\xAA\xAA"}, // Static pass: 0XAAAAAA 10101010 10101010 10101010
|
||||
{3, "\x92\x49\x24"}, // Static pass: 0x924924 10010010 01001001 00100100
|
||||
{3, "\x49\x24\x92"}, // Static pass: 0x492492 01001001 00100100 10010010
|
||||
{3, "\x24\x92\x49"}, // Static pass: 0x249249 00100100 10010010 01001001
|
||||
{3, "\x00\x00\x00"}, // Static pass: 0x000000 00000000 00000000 00000000
|
||||
{3, "\x11\x11\x11"}, // Static pass: 0x111111 00010001 00010001 00010001
|
||||
{3, "\x22\x22\x22"}, // Static pass: 0x222222 00100010 00100010 00100010
|
||||
{3, "\x33\x33\x33"}, // Static pass: 0x333333 00110011 00110011 00110011
|
||||
{3, "\x44\x44\x44"}, // Static pass: 0x444444 01000100 01000100 01000100
|
||||
{3, "\x55\x55\x55"}, // Static pass: 0x555555 01010101 01010101 01010101
|
||||
{3, "\x66\x66\x66"}, // Static pass: 0x666666 01100110 01100110 01100110
|
||||
{3, "\x77\x77\x77"}, // Static pass: 0x777777 01110111 01110111 01110111
|
||||
{3, "\x88\x88\x88"}, // Static pass: 0x888888 10001000 10001000 10001000
|
||||
{3, "\x99\x99\x99"}, // Static pass: 0x999999 10011001 10011001 10011001
|
||||
{3, "\xAA\xAA\xAA"}, // Static pass: 0xAAAAAA 10101010 10101010 10101010
|
||||
{3, "\xBB\xBB\xBB"}, // Static pass: 0xBBBBBB 10111011 10111011 10111011
|
||||
{3, "\xCC\xCC\xCC"}, // Static pass: 0xCCCCCC 11001100 11001100 11001100
|
||||
{3, "\xDD\xDD\xDD"}, // Static pass: 0xDDDDDD 11011101 11011101 11011101
|
||||
{3, "\xEE\xEE\xEE"}, // Static pass: 0xEEEEEE 11101110 11101110 11101110
|
||||
{3, "\xFF\xFF\xFF"}, // Static pass: 0xFFFFFF 11111111 11111111 11111111
|
||||
{3, "\x92\x49\x24"}, // Static pass: 0x924924 10010010 01001001 00100100
|
||||
{3, "\x49\x24\x92"}, // Static pass: 0x492492 01001001 00100100 10010010
|
||||
{3, "\x24\x92\x49"}, // Static pass: 0x249249 00100100 10010010 01001001
|
||||
{3, "\x6D\xB6\xDB"}, // Static pass: 0x6DB6DB 01101101 10110110 11011011
|
||||
{3, "\xB6\xDB\x6D"}, // Static pass: 0xB6DB6D 10110110 11011011 01101101
|
||||
{3, "\xDB\x6D\xB6"}, // Static pass: 0XDB6DB6 11011011 01101101 10110110
|
||||
{-1, ""}, // Random pass.
|
||||
{-1, ""}, // Random pass.
|
||||
{-1, ""}, // Random pass.
|
||||
{-1, ""}, // Random pass.
|
||||
{0, NULL}};
|
||||
nwipe_pattern_t book[] = { { -1, "" }, // Random pass.
|
||||
{ -1, "" }, // Random pass.
|
||||
{ -1, "" }, // Random pass.
|
||||
{ -1, "" }, // Random pass.
|
||||
{ 3, "\x55\x55\x55" }, // Static pass: 0x555555 01010101 01010101 01010101
|
||||
{ 3, "\xAA\xAA\xAA" }, // Static pass: 0XAAAAAA 10101010 10101010 10101010
|
||||
{ 3, "\x92\x49\x24" }, // Static pass: 0x924924 10010010 01001001 00100100
|
||||
{ 3, "\x49\x24\x92" }, // Static pass: 0x492492 01001001 00100100 10010010
|
||||
{ 3, "\x24\x92\x49" }, // Static pass: 0x249249 00100100 10010010 01001001
|
||||
{ 3, "\x00\x00\x00" }, // Static pass: 0x000000 00000000 00000000 00000000
|
||||
{ 3, "\x11\x11\x11" }, // Static pass: 0x111111 00010001 00010001 00010001
|
||||
{ 3, "\x22\x22\x22" }, // Static pass: 0x222222 00100010 00100010 00100010
|
||||
{ 3, "\x33\x33\x33" }, // Static pass: 0x333333 00110011 00110011 00110011
|
||||
{ 3, "\x44\x44\x44" }, // Static pass: 0x444444 01000100 01000100 01000100
|
||||
{ 3, "\x55\x55\x55" }, // Static pass: 0x555555 01010101 01010101 01010101
|
||||
{ 3, "\x66\x66\x66" }, // Static pass: 0x666666 01100110 01100110 01100110
|
||||
{ 3, "\x77\x77\x77" }, // Static pass: 0x777777 01110111 01110111 01110111
|
||||
{ 3, "\x88\x88\x88" }, // Static pass: 0x888888 10001000 10001000 10001000
|
||||
{ 3, "\x99\x99\x99" }, // Static pass: 0x999999 10011001 10011001 10011001
|
||||
{ 3, "\xAA\xAA\xAA" }, // Static pass: 0xAAAAAA 10101010 10101010 10101010
|
||||
{ 3, "\xBB\xBB\xBB" }, // Static pass: 0xBBBBBB 10111011 10111011 10111011
|
||||
{ 3, "\xCC\xCC\xCC" }, // Static pass: 0xCCCCCC 11001100 11001100 11001100
|
||||
{ 3, "\xDD\xDD\xDD" }, // Static pass: 0xDDDDDD 11011101 11011101 11011101
|
||||
{ 3, "\xEE\xEE\xEE" }, // Static pass: 0xEEEEEE 11101110 11101110 11101110
|
||||
{ 3, "\xFF\xFF\xFF" }, // Static pass: 0xFFFFFF 11111111 11111111 11111111
|
||||
{ 3, "\x92\x49\x24" }, // Static pass: 0x924924 10010010 01001001 00100100
|
||||
{ 3, "\x49\x24\x92" }, // Static pass: 0x492492 01001001 00100100 10010010
|
||||
{ 3, "\x24\x92\x49" }, // Static pass: 0x249249 00100100 10010010 01001001
|
||||
{ 3, "\x6D\xB6\xDB" }, // Static pass: 0x6DB6DB 01101101 10110110 11011011
|
||||
{ 3, "\xB6\xDB\x6D" }, // Static pass: 0xB6DB6D 10110110 11011011 01101101
|
||||
{ 3, "\xDB\x6D\xB6" }, // Static pass: 0XDB6DB6 11011011 01101101 10110110
|
||||
{ -1, "" }, // Random pass.
|
||||
{ -1, "" }, // Random pass.
|
||||
{ -1, "" }, // Random pass.
|
||||
{ -1, "" }, // Random pass.
|
||||
{ 0, NULL } };
|
||||
|
||||
/* Put the book array into this array in random order. */
|
||||
nwipe_pattern_t patterns[36];
|
||||
@@ -439,8 +439,6 @@ void* nwipe_gutmann( void* ptr )
|
||||
|
||||
/* Mark this element as having been used. */
|
||||
book[j].length = 0;
|
||||
|
||||
nwipe_log( NWIPE_LOG_DEBUG, "nwipe_gutmann: Set patterns[%i] = book[%i].", i, j );
|
||||
}
|
||||
|
||||
/* Ensure that the array is terminated. */
|
||||
@@ -636,11 +634,11 @@ void* nwipe_is5enh( void* ptr )
|
||||
|
||||
c->wipe_status = 1;
|
||||
|
||||
char is5enh[3] = {'\x00', '\xFF', '\x00'};
|
||||
nwipe_pattern_t patterns[] = {{1, &is5enh[0]}, // Pass 1: 0s
|
||||
{1, &is5enh[1]}, // Pass 2: 1s
|
||||
{-1, &is5enh[2]}, // Pass 3: random bytes with verification
|
||||
{0, NULL}};
|
||||
char is5enh[3] = { '\x00', '\xFF', '\x00' };
|
||||
nwipe_pattern_t patterns[] = { { 1, &is5enh[0] }, // Pass 1: 0s
|
||||
{ 1, &is5enh[1] }, // Pass 2: 1s
|
||||
{ -1, &is5enh[2] }, // Pass 3: random bytes with verification
|
||||
{ 0, NULL } };
|
||||
c->result = nwipe_runmethod( c, patterns );
|
||||
|
||||
c->wipe_status = 0;
|
||||
@@ -668,7 +666,7 @@ void* nwipe_random( void* ptr )
|
||||
c->wipe_status = 1;
|
||||
|
||||
/* Define the random method. */
|
||||
nwipe_pattern_t patterns[] = {{-1, ""}, {0, NULL}};
|
||||
nwipe_pattern_t patterns[] = { { -1, "" }, { 0, NULL } };
|
||||
|
||||
/* Run the method. */
|
||||
c->result = nwipe_runmethod( c, patterns );
|
||||
@@ -701,7 +699,7 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
|
||||
i = 0;
|
||||
|
||||
/* The zero-fill pattern for the final pass of most methods. */
|
||||
nwipe_pattern_t pattern_zero = {1, "\x00"};
|
||||
nwipe_pattern_t pattern_zero = { 1, "\x00" };
|
||||
|
||||
/* Create the PRNG state buffer. */
|
||||
c->prng_seed.length = NWIPE_KNOB_PRNG_STATE_LENGTH;
|
||||
@@ -727,18 +725,6 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
|
||||
/* Set the number of bytes that will be written across all passes in one round. */
|
||||
c->pass_size = c->pass_count * c->device_size;
|
||||
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_ALL )
|
||||
{
|
||||
/* We must read back all passes, so double the byte count. */
|
||||
c->pass_size *= 2;
|
||||
}
|
||||
|
||||
/* Tell the parent the number of rounds that will be run. */
|
||||
c->round_count = nwipe_options.rounds;
|
||||
|
||||
/* Set the initial number of bytes that will be written across all rounds. */
|
||||
c->round_size = c->pass_size;
|
||||
|
||||
/* For the selected method, calculate the correct round_size value (for correct percentage calculation) */
|
||||
calculate_round_size( c );
|
||||
|
||||
@@ -830,6 +816,8 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
|
||||
r = nwipe_static_verify( c, &patterns[i] );
|
||||
c->pass_type = NWIPE_PASS_NONE;
|
||||
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "%llu bytes read from %s", c->pass_done, c->device_name );
|
||||
|
||||
/* Check for a fatal error. */
|
||||
if( r < 0 )
|
||||
{
|
||||
@@ -902,6 +890,8 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
|
||||
r = nwipe_random_verify( c );
|
||||
c->pass_type = NWIPE_PASS_NONE;
|
||||
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "%llu bytes read from %s", c->pass_done, c->device_name );
|
||||
|
||||
/* Check for a fatal error. */
|
||||
if( r < 0 )
|
||||
{
|
||||
@@ -976,6 +966,8 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
|
||||
/* The final ops2 pass. */
|
||||
r = nwipe_random_pass( c );
|
||||
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "%llu bytes written to %s", c->pass_done, c->device_name );
|
||||
|
||||
/* Check for a fatal error. */
|
||||
if( r < 0 )
|
||||
{
|
||||
@@ -984,22 +976,22 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
|
||||
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_LAST || nwipe_options.verify == NWIPE_VERIFY_ALL )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "Verifying the final random pattern on %s is empty.", c->device_name );
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "Verifying final random pattern FRP on %s", c->device_name );
|
||||
|
||||
/* Verify the final zero pass. */
|
||||
r = nwipe_random_verify( c );
|
||||
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "%llu bytes read from %s", c->pass_done, c->device_name );
|
||||
|
||||
/* Check for a fatal error. */
|
||||
if( r < 0 )
|
||||
{
|
||||
return r;
|
||||
}
|
||||
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "Verified the final random pattern on '%s' is empty.", c->device_name );
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "[SUCCESS] Verified FRP on '%s' matches", c->device_name );
|
||||
}
|
||||
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "Wrote final random pattern to '%s'.", c->device_name );
|
||||
|
||||
} /* final ops2 */
|
||||
|
||||
else if( nwipe_options.method == &nwipe_verify )
|
||||
@@ -1022,7 +1014,7 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
|
||||
}
|
||||
else
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_ERROR, "[FAILURE] %s IS NOT empty.", c->device_name );
|
||||
nwipe_log( NWIPE_LOG_ERROR, "[FAILURE] %s is not empty .", c->device_name );
|
||||
}
|
||||
|
||||
} /* verify */
|
||||
@@ -1037,6 +1029,9 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
|
||||
/* The final zero pass. */
|
||||
r = nwipe_static_pass( c, &pattern_zero );
|
||||
|
||||
/* Log number of bytes written to disk */
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "%llu bytes written to %s", c->pass_done, c->device_name );
|
||||
|
||||
/* Check for a fatal error. */
|
||||
if( r < 0 )
|
||||
{
|
||||
@@ -1048,7 +1043,12 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "Verifying that %s is empty.", c->device_name );
|
||||
|
||||
/* Verify the final zero pass. */
|
||||
c->pass_type = NWIPE_PASS_VERIFY;
|
||||
r = nwipe_static_verify( c, &pattern_zero );
|
||||
c->pass_type = NWIPE_PASS_NONE;
|
||||
|
||||
/* Log number of bytes read from disk */
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "%llu bytes read from %s", c->pass_done, c->device_name );
|
||||
|
||||
/* Check for a fatal error. */
|
||||
if( r < 0 )
|
||||
@@ -1066,7 +1066,14 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
|
||||
}
|
||||
}
|
||||
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "[SUCCESS] Blanked device %s", c->device_name );
|
||||
if( c->verify_errors == 0 && c->pass_errors == 0 )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "[SUCCESS] Blanked device %s", c->device_name );
|
||||
}
|
||||
else
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "[FAILURE] %s may not be blanked", c->device_name );
|
||||
}
|
||||
|
||||
} /* final blank */
|
||||
|
||||
@@ -1104,24 +1111,23 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns )
|
||||
|
||||
void calculate_round_size( nwipe_context_t* c )
|
||||
{
|
||||
/* This is where the round size is adjusted. round_size is used in the running percentage completion
|
||||
/* This is where the round size is calculated. round_size is used in the running percentage completion
|
||||
* calculation. round size is calculated based on pass_size, pass_count, number of rounds, blanking
|
||||
* on/off and verification on/off
|
||||
* on/off and verification All/Last/None
|
||||
*
|
||||
* To hopefully make this adjustment more understandable, I have presented each calculation
|
||||
* under each method. This should make it easier to add a new method here without breaking the
|
||||
* calculations for other methods.
|
||||
* To hopefully make this calculation more understandable, I have separated the calculations that apply to
|
||||
* all methods and processed first then created a switch statement that contains method specific changes if any
|
||||
*/
|
||||
|
||||
/* Don't change the order of these values as the case statements use their index in the array */
|
||||
void* array_methods[] = {&nwipe_zero,
|
||||
&nwipe_ops2,
|
||||
&nwipe_dodshort,
|
||||
&nwipe_dod522022m,
|
||||
&nwipe_gutmann,
|
||||
&nwipe_random,
|
||||
&nwipe_is5enh,
|
||||
NULL};
|
||||
void* array_methods[] = { &nwipe_zero,
|
||||
&nwipe_ops2,
|
||||
&nwipe_dodshort,
|
||||
&nwipe_dod522022m,
|
||||
&nwipe_gutmann,
|
||||
&nwipe_random,
|
||||
&nwipe_is5enh,
|
||||
NULL };
|
||||
int i;
|
||||
|
||||
/* This while loop allows us to effectively create a const so we can use a case statement rather than if statements.
|
||||
@@ -1141,118 +1147,110 @@ void calculate_round_size( nwipe_context_t* c )
|
||||
i++;
|
||||
}
|
||||
|
||||
/* Multiple the round_size by the number of rounds (times) the user wants to wipe the drive with this method.
|
||||
*/
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_ALL )
|
||||
{
|
||||
/* We must read back all passes, so double the byte count. */
|
||||
c->pass_size *= 2;
|
||||
}
|
||||
|
||||
/* Tell the parent the number of rounds that will be run. */
|
||||
c->round_count = nwipe_options.rounds;
|
||||
|
||||
/* Set the initial number of bytes that will be written across all rounds.
|
||||
c->pass_size includes write AND verification passes if 'verify_all' is selected
|
||||
but does not include the final blanking pass or the verify_last option */
|
||||
c->round_size = c->pass_size;
|
||||
|
||||
/* Multiple the round_size by the number of rounds (times) the user wants to wipe the drive with this method. */
|
||||
c->round_size *= c->round_count;
|
||||
|
||||
/* For each method create the correct round_size value */
|
||||
/* Now increase size based on whether blanking is enabled and verification */
|
||||
if( nwipe_options.noblank == 0 )
|
||||
{
|
||||
/* Blanking enabled so increase round size */
|
||||
c->round_size += c->device_size;
|
||||
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_LAST || nwipe_options.verify == NWIPE_VERIFY_ALL )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Blanking not enabled, check for 'Verify_last', increase round size if enabled. */
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_LAST )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
}
|
||||
|
||||
/* Additional method specific round_size adjustments go in this switch statement */
|
||||
|
||||
switch( selected_method )
|
||||
{
|
||||
case 0:
|
||||
/* NWIPE_ZERO
|
||||
/* NWIPE_ZERO - No additional calculation required
|
||||
* ---------- */
|
||||
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_ALL )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_LAST )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
if( nwipe_options.noblank == 0 )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
/* NWIPE_OPS2
|
||||
* ---------- */
|
||||
|
||||
/* Required for the 9th and final random pass */
|
||||
/* Required for mandatory 9th and final random pass */
|
||||
c->round_size += c->device_size;
|
||||
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_LAST )
|
||||
/* Required for selectable 9th and final random verification */
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_ALL || nwipe_options.verify == NWIPE_VERIFY_LAST )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_ALL )
|
||||
|
||||
/* As no final zero blanking pass is permitted by this standard reduce round size if it's seelected */
|
||||
if( nwipe_options.noblank == 0 )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
/* Reduce for blanking pass */
|
||||
c->round_size -= c->device_size;
|
||||
|
||||
/* Reduce for blanking pass verification */
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_ALL || nwipe_options.verify == NWIPE_VERIFY_LAST )
|
||||
{
|
||||
c->round_size -= c->device_size;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_LAST )
|
||||
{
|
||||
/* If blanking off & verification on reduce round size */
|
||||
c->round_size -= c->device_size;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
/* DoD Short
|
||||
/* DoD Short - No additional calculation required
|
||||
* --------- */
|
||||
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_LAST )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_ALL )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
if( nwipe_options.noblank == 0 )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
/* DOD 522022m
|
||||
/* DOD 522022m - No additional calculation required
|
||||
* ----------- */
|
||||
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_LAST )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_ALL )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
if( nwipe_options.noblank == 0 )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
/* GutMann
|
||||
/* GutMann - No additional calculation required
|
||||
* ------- */
|
||||
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_LAST )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_ALL )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
if( nwipe_options.noblank == 0 )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
/* PRNG (random)
|
||||
/* PRNG (random) - No additional calculation required
|
||||
* ------------- */
|
||||
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_LAST )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_ALL )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
if( nwipe_options.noblank == 0 )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
break;
|
||||
|
||||
case 6:
|
||||
@@ -1260,25 +1258,20 @@ void calculate_round_size( nwipe_context_t* c )
|
||||
* ------------ */
|
||||
|
||||
/* This method ALWAYS verifies the 3rd pass so increase by device size,
|
||||
* and does not need to be increased by device size for VERIFY_ALL*/
|
||||
* but NOT if VERIFY_ALL has been selected, but first .. */
|
||||
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_LAST )
|
||||
/* Reduce as Verify_Last already included previously if blanking was off */
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_LAST && nwipe_options.noblank == 1 )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
c->round_size -= c->device_size;
|
||||
}
|
||||
if( nwipe_options.verify == NWIPE_VERIFY_ALL )
|
||||
|
||||
/* Adjusts for verify on every third pass multiplied by number of rounds */
|
||||
if( nwipe_options.verify != NWIPE_VERIFY_ALL )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Adjusts for verify on every third pass multiplied by number of rounds */
|
||||
c->round_size += ( c->device_size * c->round_count );
|
||||
}
|
||||
if( nwipe_options.noblank == 0 )
|
||||
{
|
||||
c->round_size += c->device_size;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
61
src/nwipe.c
61
src/nwipe.c
@@ -32,7 +32,6 @@
|
||||
#include <signal.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/types.h>
|
||||
#include <bits/sigthread.h>
|
||||
|
||||
#include "nwipe.h"
|
||||
#include "context.h"
|
||||
@@ -53,6 +52,7 @@
|
||||
|
||||
int terminate_signal;
|
||||
int user_abort;
|
||||
int global_wipe_status;
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
@@ -88,6 +88,13 @@ int main( int argc, char** argv )
|
||||
/* nwipes return status value, set prior to exit at the end of nwipe, as no other exit points allowed */
|
||||
int return_status = 0;
|
||||
|
||||
/* Initialise, flag indicating whether a wipe has actually started or not 0=no, 1=yes */
|
||||
global_wipe_status = 0;
|
||||
|
||||
/* Initialise flags that indicates whether a fatal or non fatal error occured on ANY drive */
|
||||
int fatal_errors_flag = 0;
|
||||
int non_fatal_errors_flag = 0;
|
||||
|
||||
/* Two arrays are used, containing pointers to the the typedef for each disk */
|
||||
/* The first array (c1) points to all devices, the second points to only */
|
||||
/* the disks selected for wiping. */
|
||||
@@ -216,12 +223,6 @@ int main( int argc, char** argv )
|
||||
/* The user must manually select devices. */
|
||||
c1[i]->select = NWIPE_SELECT_FALSE;
|
||||
}
|
||||
|
||||
/* Set the PRNG implementation. */
|
||||
c1[i]->prng = nwipe_options.prng;
|
||||
c1[i]->prng_seed.length = 0;
|
||||
c1[i]->prng_seed.s = 0;
|
||||
c1[i]->prng_state = 0;
|
||||
}
|
||||
|
||||
/* Check for initialization errors. */
|
||||
@@ -257,9 +258,15 @@ int main( int argc, char** argv )
|
||||
}
|
||||
}
|
||||
|
||||
/* Count the number of selected contexts. */
|
||||
for( i = 0; i < nwipe_enumerated; i++ )
|
||||
{
|
||||
/* Set the PRNG implementation, which must always come after the function nwipe_gui_select ! */
|
||||
c1[i]->prng = nwipe_options.prng;
|
||||
c1[i]->prng_seed.length = 0;
|
||||
c1[i]->prng_seed.s = 0;
|
||||
c1[i]->prng_state = 0;
|
||||
|
||||
/* Count the number of selected contexts. */
|
||||
if( c1[i]->select == NWIPE_SELECT_TRUE )
|
||||
{
|
||||
nwipe_selected += 1;
|
||||
@@ -282,6 +289,12 @@ int main( int argc, char** argv )
|
||||
/* TODO: free c1 and c2 memory. */
|
||||
if( user_abort == 0 )
|
||||
{
|
||||
/* Log the wipe options that have been selected immediately prior to the start of the wipe */
|
||||
nwipe_options_log();
|
||||
|
||||
/* The wipe has been initiated */
|
||||
global_wipe_status = 1;
|
||||
|
||||
for( i = 0; i < nwipe_selected; i++ )
|
||||
{
|
||||
/* A result buffer for the BLKGETSIZE64 ioctl. */
|
||||
@@ -583,6 +596,7 @@ int main( int argc, char** argv )
|
||||
if( c2[i]->result > 0 )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_FATAL, "Nwipe exited with non fatal errors on device = %s\n", c2[i]->device_name );
|
||||
non_fatal_errors_flag = 1;
|
||||
return_status = 1;
|
||||
}
|
||||
}
|
||||
@@ -593,6 +607,7 @@ int main( int argc, char** argv )
|
||||
if( c2[i]->result < 0 )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_ERROR, "Nwipe exited with fatal errors on device = %s\n", c2[i]->device_name );
|
||||
fatal_errors_flag = 1;
|
||||
return_status = -1;
|
||||
}
|
||||
}
|
||||
@@ -601,9 +616,33 @@ int main( int argc, char** argv )
|
||||
/* Generate and send the drive status summary to the log */
|
||||
nwipe_log_summary( c2, nwipe_selected );
|
||||
|
||||
if( return_status == 0 )
|
||||
/* Print a one line status message for the user */
|
||||
if( return_status == 0 || return_status == 1 )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_INFO, "Nwipe successfully exited." );
|
||||
if( user_abort == 1 )
|
||||
{
|
||||
if( global_wipe_status == 1 )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_INFO,
|
||||
"Nwipe was aborted by the user. Check the summary table for the drive status." );
|
||||
}
|
||||
else
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_INFO, "Nwipe was aborted by the user prior to the wipe starting." );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( fatal_errors_flag == 1 || non_fatal_errors_flag == 1 )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_INFO,
|
||||
"Nwipe exited with errors, check the log & summary table for individual drive status." );
|
||||
}
|
||||
else
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_INFO, "Nwipe successfully completed. See summary table for details." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cleanup();
|
||||
@@ -778,7 +817,7 @@ int cleanup()
|
||||
}
|
||||
void check_for_autopoweroff( void )
|
||||
{
|
||||
char cmd[] = "shutdown -P +1 \"System going down in one minute\"";
|
||||
char cmd[] = "shutdown -Ph +1 \"System going down in one minute\"";
|
||||
FILE* fp;
|
||||
int r; // A result buffer.
|
||||
|
||||
|
||||
@@ -73,6 +73,9 @@ void* signal_hand( void* );
|
||||
/* System errors. */
|
||||
extern int errno;
|
||||
|
||||
/* 0=wipe not yet started, 1=wipe has been started by the user */
|
||||
extern int global_wipe_status;
|
||||
|
||||
/* Global array to hold log values to print when logging to STDOUT */
|
||||
/* char **log_lines;
|
||||
int log_current_element = 0;
|
||||
|
||||
@@ -58,58 +58,58 @@ int nwipe_options_parse( int argc, char** argv )
|
||||
/* The list of acceptable long options. */
|
||||
static struct option nwipe_options_long[] = {
|
||||
/* Set when the user wants to wipe without a confirmation prompt. */
|
||||
{"autonuke", no_argument, 0, 0},
|
||||
{ "autonuke", no_argument, 0, 0 },
|
||||
|
||||
/* Set when the user wants to have the system powerdown on completion of wipe. */
|
||||
{"autopoweroff", no_argument, 0, 0},
|
||||
{ "autopoweroff", no_argument, 0, 0 },
|
||||
|
||||
/* A GNU standard option. Corresponds to the 'h' short option. */
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
|
||||
/* The wipe method. Corresponds to the 'm' short option. */
|
||||
{"method", required_argument, 0, 'm'},
|
||||
{ "method", required_argument, 0, 'm' },
|
||||
|
||||
/* Log file. Corresponds to the 'l' short option. */
|
||||
{"logfile", required_argument, 0, 'l'},
|
||||
{ "logfile", required_argument, 0, 'l' },
|
||||
|
||||
/* Exclude devices, comma separated list */
|
||||
{"exclude", required_argument, 0, 'e'},
|
||||
{ "exclude", required_argument, 0, 'e' },
|
||||
|
||||
/* The Pseudo Random Number Generator. */
|
||||
{"prng", required_argument, 0, 'p'},
|
||||
{ "prng", required_argument, 0, 'p' },
|
||||
|
||||
/* The number of times to run the method. */
|
||||
{"rounds", required_argument, 0, 'r'},
|
||||
{ "rounds", required_argument, 0, 'r' },
|
||||
|
||||
/* Whether to blank the disk after wiping. */
|
||||
{"noblank", no_argument, 0, 0},
|
||||
{ "noblank", no_argument, 0, 0 },
|
||||
|
||||
/* Whether to ignore all USB devices. */
|
||||
{"nousb", no_argument, 0, 0},
|
||||
{ "nousb", no_argument, 0, 0 },
|
||||
|
||||
/* Whether to exit after wiping or wait for a keypress. */
|
||||
{"nowait", no_argument, 0, 0},
|
||||
{ "nowait", no_argument, 0, 0 },
|
||||
|
||||
/* Whether to allow signals to interrupt a wipe. */
|
||||
{"nosignals", no_argument, 0, 0},
|
||||
{ "nosignals", no_argument, 0, 0 },
|
||||
|
||||
/* Whether to exit after wiping or wait for a keypress. */
|
||||
{"nogui", no_argument, 0, 0},
|
||||
{ "nogui", no_argument, 0, 0 },
|
||||
|
||||
/* A flag to indicate whether the devices whould be opened in sync mode. */
|
||||
{"sync", required_argument, 0, 0},
|
||||
{ "sync", required_argument, 0, 0 },
|
||||
|
||||
/* Verify that wipe patterns are being written to the device. */
|
||||
{"verify", required_argument, 0, 0},
|
||||
{ "verify", required_argument, 0, 0 },
|
||||
|
||||
/* Display program version. */
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{ "verbose", no_argument, 0, 'v' },
|
||||
|
||||
/* Display program version. */
|
||||
{"version", no_argument, 0, 'V'},
|
||||
{ "version", no_argument, 0, 'V' },
|
||||
|
||||
/* Requisite padding for getopt(). */
|
||||
{0, 0, 0, 0}};
|
||||
{ 0, 0, 0, 0 } };
|
||||
|
||||
/* Set default options. */
|
||||
nwipe_options.autonuke = 0;
|
||||
@@ -399,6 +399,9 @@ int nwipe_options_parse( int argc, char** argv )
|
||||
|
||||
void nwipe_options_log( void )
|
||||
{
|
||||
extern nwipe_prng_t nwipe_twister;
|
||||
extern nwipe_prng_t nwipe_isaac;
|
||||
|
||||
/**
|
||||
* Prints a manifest of options to the log.
|
||||
*/
|
||||
@@ -444,6 +447,23 @@ void nwipe_options_log( void )
|
||||
}
|
||||
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " banner = %s", banner );
|
||||
|
||||
if( nwipe_options.prng == &nwipe_twister )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " prng = Mersenne Twister" );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( nwipe_options.prng == &nwipe_isaac )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " prng = Isaac" );
|
||||
}
|
||||
else
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " prng = Undefined" );
|
||||
}
|
||||
}
|
||||
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " method = %s", nwipe_method_label( nwipe_options.method ) );
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " rounds = %i", nwipe_options.rounds );
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " sync = %i", nwipe_options.sync );
|
||||
@@ -489,13 +509,13 @@ void display_help()
|
||||
puts( " for one minute. During this one minute delay you can" );
|
||||
puts( " abort the shutdown by typing sudo shutdown -c\n" );
|
||||
printf( " --sync=NUM Will perform a sync after NUM writes (default: %d)\n", DEFAULT_SYNC_RATE );
|
||||
puts( " 0 - fdatasync after the disk is completely written" );
|
||||
puts( " fdatasync errors not detected until completion." );
|
||||
puts( " 0 is not recommended as disk errors may cause nwipe" );
|
||||
puts( " to appear to hang" );
|
||||
puts( " 1 - fdatasync after every write" );
|
||||
puts( " Warning: Lower values will reduce wipe speeds." );
|
||||
puts( " 1000000 - fdatasync after 1000000 writes etc.)\n" );
|
||||
puts( " 0 - fdatasync after the disk is completely written" );
|
||||
puts( " fdatasync errors not detected until completion." );
|
||||
puts( " 0 is not recommended as disk errors may cause" );
|
||||
puts( " nwipe to appear to hang" );
|
||||
puts( " 1 - fdatasync after every write" );
|
||||
puts( " Warning: Lower values will reduce wipe speeds." );
|
||||
puts( " 1000 - fdatasync after 1000 writes etc.\n" );
|
||||
puts( " --verify=TYPE Whether to perform verification of erasure" );
|
||||
puts( " (default: last)" );
|
||||
puts( " off - Do not verify" );
|
||||
@@ -514,16 +534,16 @@ void display_help()
|
||||
puts( " -p, --prng=METHOD PRNG option (mersenne|twister|isaac)\n" );
|
||||
puts( " -r, --rounds=NUM Number of times to wipe the device using the selected" );
|
||||
puts( " method (default: 1)\n" );
|
||||
puts( " --noblank Do not blank disk after wipe" );
|
||||
puts( " --noblank Do NOT blank disk after wipe" );
|
||||
puts( " (default is to complete a final blank pass)\n" );
|
||||
puts( " --nowait Do not wait for a key before exiting" );
|
||||
puts( " --nowait Do NOT wait for a key before exiting" );
|
||||
puts( " (default is to wait)\n" );
|
||||
puts( " --nosignals Do not allow signals to interrupt a wipe" );
|
||||
puts( " --nosignals Do NOT allow signals to interrupt a wipe" );
|
||||
puts( " (default is to allow)\n" );
|
||||
puts( " --nogui Do not show the GUI interface. Automatically invokes" );
|
||||
puts( " --nogui Do NOT show the GUI interface. Automatically invokes" );
|
||||
puts( " the nowait option. Must be used with the --autonuke" );
|
||||
puts( " option. Send SIGUSR1 to log current stats\n" );
|
||||
puts( " --nousb Do show or wipe any USB devices whether in GUI" );
|
||||
puts( " --nousb Do NOT show or wipe any USB devices whether in GUI" );
|
||||
puts( " mode, --nogui or --autonuke modes.\n" );
|
||||
puts( " -e, --exclude=DEVICES Up to ten comma separated devices to be excluded" );
|
||||
puts( " --exclude=/dev/sdc" );
|
||||
|
||||
28
src/pass.c
28
src/pass.c
@@ -248,6 +248,9 @@ int nwipe_random_pass( NWIPE_METHOD_SIGNATURE )
|
||||
/* Counter to track when to do a fdatasync. */
|
||||
int i = 0;
|
||||
|
||||
/* general index counter */
|
||||
int idx;
|
||||
|
||||
if( c->prng_seed.s == NULL )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_SANITY, "__FUNCTION__: Null seed pointer." );
|
||||
@@ -260,8 +263,9 @@ int nwipe_random_pass( NWIPE_METHOD_SIGNATURE )
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Create the output buffer. */
|
||||
b = malloc( c->device_stat.st_blksize );
|
||||
/* Create the initialised output buffer. Initialised because we don't want memory leaks
|
||||
* to disk in the event of some future undetected bug in a prng or it's implementation ) */
|
||||
b = calloc( c->device_stat.st_blksize, sizeof( char ) );
|
||||
|
||||
/* Check the memory allocation. */
|
||||
if( !b )
|
||||
@@ -317,6 +321,26 @@ int nwipe_random_pass( NWIPE_METHOD_SIGNATURE )
|
||||
/* Fill the output buffer with the random pattern. */
|
||||
c->prng->read( &c->prng_state, b, blocksize );
|
||||
|
||||
/* For the first block only, check the prng actually wrote something to the buffer */
|
||||
if( z == c->device_size )
|
||||
{
|
||||
idx = c->device_stat.st_blksize;
|
||||
while( idx > 0 )
|
||||
{
|
||||
if( b[idx] != 0 )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "prng stream is active" );
|
||||
break;
|
||||
}
|
||||
idx--;
|
||||
}
|
||||
if( idx == 0 )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_FATAL, "ERROR, prng wrote nothing to the buffer" );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Write the next block out to the device. */
|
||||
r = write( c->device_fd, b, blocksize );
|
||||
|
||||
|
||||
45
src/prng.c
45
src/prng.c
@@ -9,7 +9,7 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
@@ -25,9 +25,9 @@
|
||||
#include "mt19937ar-cok/mt19937ar-cok.h"
|
||||
#include "isaac_rand/isaac_rand.h"
|
||||
|
||||
nwipe_prng_t nwipe_twister = {"Mersenne Twister (mt19937ar-cok)", nwipe_twister_init, nwipe_twister_read};
|
||||
nwipe_prng_t nwipe_twister = { "Mersenne Twister (mt19937ar-cok)", nwipe_twister_init, nwipe_twister_read };
|
||||
|
||||
nwipe_prng_t nwipe_isaac = {"ISAAC (rand.c 20010626)", nwipe_isaac_init, nwipe_isaac_read};
|
||||
nwipe_prng_t nwipe_isaac = { "ISAAC (rand.c 20010626)", nwipe_isaac_init, nwipe_isaac_read };
|
||||
|
||||
int nwipe_u32tobuffer( u8* buffer, u32 rand, int len )
|
||||
{
|
||||
@@ -53,6 +53,8 @@ int nwipe_u32tobuffer( u8* buffer, u32 rand, int len )
|
||||
|
||||
int nwipe_twister_init( NWIPE_PRNG_INIT_SIGNATURE )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "Initialising Mersenne Twister prng" );
|
||||
|
||||
if( *state == NULL )
|
||||
{
|
||||
/* This is the first time that we have been called. */
|
||||
@@ -91,6 +93,8 @@ int nwipe_isaac_init( NWIPE_PRNG_INIT_SIGNATURE )
|
||||
int count;
|
||||
randctx* isaac_state = *state;
|
||||
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "Initialising Isaac prng" );
|
||||
|
||||
if( *state == NULL )
|
||||
{
|
||||
/* This is the first time that we have been called. */
|
||||
@@ -136,18 +140,31 @@ int nwipe_isaac_init( NWIPE_PRNG_INIT_SIGNATURE )
|
||||
|
||||
int nwipe_isaac_read( NWIPE_PRNG_READ_SIGNATURE )
|
||||
{
|
||||
/* The purpose of this function is unclear, as it does not do anything except immediately return !
|
||||
* Because the variables in the macro NWIPE_PRNG_READ_SIGNATURE were then unused this throws
|
||||
* up a handful of compiler warnings, related to variables being unused. To stop the compiler warnings
|
||||
* I've simply put in a (void) var so that compiler sees the variable are supposed to be unused.
|
||||
*
|
||||
* As this code works, I thought it best not to remove this function, just in case it serves
|
||||
* some purpose or is there for future use.
|
||||
*/
|
||||
u32 i = 0;
|
||||
u32 ii;
|
||||
u32 words = count / SIZE_OF_ISAAC; // the values of isaac is strictly 4 bytes
|
||||
u32 remain = count % SIZE_OF_ISAAC; // the values of isaac is strictly 4 bytes
|
||||
|
||||
(void) state;
|
||||
(void) buffer;
|
||||
(void) count;
|
||||
randctx* isaac_state = *state;
|
||||
|
||||
/* Isaac returns 4-bytes per call, so progress by 4 bytes. */
|
||||
for( ii = 0; ii < words; ++ii )
|
||||
{
|
||||
/* get the next 32bit random number */
|
||||
isaac( isaac_state );
|
||||
|
||||
nwipe_u32tobuffer( (u8*) ( buffer + i ), isaac_state->randrsl[0], SIZE_OF_ISAAC );
|
||||
i = i + SIZE_OF_ISAAC;
|
||||
}
|
||||
|
||||
/* If there is some remainder copy only relevant number of bytes to not overflow the buffer. */
|
||||
if( remain > 0 )
|
||||
{
|
||||
/* get the next 32bit random number */
|
||||
isaac( isaac_state );
|
||||
|
||||
nwipe_u32tobuffer( (u8*) ( buffer + i ), isaac_state->randrsl[0], SIZE_OF_ISAAC );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -54,4 +54,7 @@ int nwipe_isaac_read( NWIPE_PRNG_READ_SIGNATURE );
|
||||
/* Size of the twister is not derived from the architecture, but it is strictly 4 bytes */
|
||||
#define SIZE_OF_TWISTER 4
|
||||
|
||||
/* Size of the isaac is not derived from the architecture, but it is strictly 4 bytes */
|
||||
#define SIZE_OF_ISAAC 4
|
||||
|
||||
#endif /* PRNG_H_ */
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
* used by configure to dynamically assign those values
|
||||
* to documentation files.
|
||||
*/
|
||||
const char* version_string = "0.30";
|
||||
const char* version_string = "0.31";
|
||||
const char* program_name = "nwipe";
|
||||
const char* author_name = "Martijn van Brummelen";
|
||||
const char* email_address = "git@brumit.nl";
|
||||
const char* years = "2020";
|
||||
const char* years = "2021";
|
||||
const char* copyright = "Copyright Darik Horn <dajhorn-dban@vanadac.com>\n\
|
||||
Modifications to original dwipe Copyright Andy Beverley <andy@andybev.com>\n\
|
||||
This is free software; see the source for copying conditions.\n\
|
||||
There is NO warranty; not even for MERCHANTABILITY or FITNESS\n\
|
||||
FOR A PARTICULAR PURPOSE.\n";
|
||||
const char* banner = "nwipe 0.30";
|
||||
const char* banner = "nwipe 0.31";
|
||||
|
||||
Reference in New Issue
Block a user