53 Commits
v0.30 ... v0.31

Author SHA1 Message Date
PartialVolume
cf3ae6a0f6 Merge pull request #328 from PartialVolume/update_to_0.31
Update to 0.31
2021-06-05 20:23:12 +01:00
PartialVolume
a88eeb9383 Update to 0.31 2021-06-05 19:40:00 +01:00
PartialVolume
a84894f317 Update CHANGELOG.md with version 0.31 changes
Update CHANGELOG.md with version 0.31 changes
2021-06-05 00:17:41 +01:00
PartialVolume
5c3eed8813 Merge pull request #326 from PartialVolume/Enable_verification_on_zero_pass_without_additional_blanking_pass
Allow Last Pass Verify to work without requiring final blanking (zero) pass.
2021-06-04 10:36:35 +01:00
PartialVolume
4b1c7007ff Various fixes to methods
1. Allows zero fill to be verified when blanking off.
Prior to this if you wanted to verify a zero pass,
blanking had to be on. This meant a zero pass, then a
blanking pass then a verify, effectively two zero passes
and a verify. This is now fixed so you can now do a zero
pass with verification without a blanking pass. This knocks
a third off the wipe time of a zero fill with verification.

This also means all other methods can have either all their
passes or just the last pass verified without blanking being
enabled.

2. OPS2 method requires the last pass to be random, the GUI
now disables the use of the blanking option for this message
and displays a warning message that a final blanking pass is
not allowed for OPS2. It never did a final blanking pass
anyway, even if it was selected, but this makes it clearer in
the GUI.

3. The caculate_round_size() function was improved by reducing
some duplicated code and bring the full calculation into this function.

4. On completion of each pass or verification the total number of
bytes written or read for each pass or verification is logged.
2021-06-04 10:20:23 +01:00
PartialVolume
970d74f0d5 Bump minor version number from 009 to 010 2021-06-01 02:36:51 +01:00
PartialVolume
c815235f7b Merge pull request #325 from PartialVolume/Add_count_of_fatal_non-fatal_and_verification_errors_to_summary_table
Add pass and verification summary table to log
2021-06-01 02:30:50 +01:00
PartialVolume
dcfa13a8db Add pass and verification summary table to log 2021-06-01 02:21:00 +01:00
PartialVolume
a1560de8b5 Merge pull request #324 from PartialVolume/Fixes_verify_status_message_not_shown_on_blanking_pass
Fix blanking pass verification status message
2021-05-31 23:44:41 +01:00
PartialVolume
18386f225e Fix blanking pass verification status message
Although the blanking pass verification is
completed correctly the GUI status message
did not show the status as 'Verifying', the
status message continued to say blanking.

This patch fixes the GUI message so if
verification and blanking pass are enabled,
then when blanking is complete and verification
starts the drive status message changes from
'blanking' to 'Verifying'.
2021-05-31 23:41:19 +01:00
PartialVolume
1f3b36f141 Merge pull request #323 from PartialVolume/Fix_mersenne_prng_always_being_used_even_when_user_selected_isaac
Fix the prng GUI selection
2021-05-30 23:09:01 +01:00
PartialVolume
962e1053dd Fix the prng GUI selection
This patch fixes the issue where irrespective
of whether the user selects mersenne or isaac
in the GUI, mersenne is always used without the
user being aware mersenne was being used instead
of isaac.
2021-05-30 23:05:47 +01:00
PartialVolume
93ea5f85d0 Merge pull request #322 from PartialVolume/populate_the_empty_isaac_read_function_with_some_actual_code
Fix non functional isaac prng
2021-05-30 22:34:36 +01:00
PartialVolume
76a7be696c Fix non functional isaac prng
Since at least 2013 (the initial nwipe commit),
isaac has never functioned. When the issac prng
was selected in the GUI, nwipe used the mersenne
twister prng instead. Not that you would ever
have known, as there were no log entries saying which
prng was being actively used.

However, I don't believe this was just an nwipe
issue, looking at the code for DBAN's dwipe the
same function nwipe_isaac_read( NWIPE_PRNG_READ_SIGNATURE )
exists as it does in nwipe. In both cases the function
has no code that actually does anything.

This patch populates this function and brings isaac
back to life !

This bug was also responsible for verification errors
when the option prng=isaac was used on the command
line. Worse still, if you used prng=isaac on the
command line then wiped using method=prng, no verification
and no blanking you would expect to see random data. You
don't, instead you would see either all zeros or mainly
zeros because the uninitialised buffer that should have
contained random data instead contained initialised text
data such as partial log entries. This patch and previously
submitted patches fix all these problems related to the
isaac implementation.

A separate commit will fix the GUI prng selection which
was leading everybody to believe isaac was being used
when in fact it was mersenne all along.
2021-05-30 22:30:31 +01:00
PartialVolume
630d107558 Merge pull request #321 from PartialVolume/check_prng_is_generating_data
Check that the prng produces output.
2021-05-29 21:31:47 +01:00
PartialVolume
5adc34b9e3 Check that the prng produces output.
Additional log messages are produced and a failed prng
causes a wipe failure. The buffer that outputs prng data
to the disk is now initialised with zeros (calloc rather than malloc)
to avoid uninitialised memory leakage to the disk in the event of some
unforeseen bug. This initialised buffer is also required for the check
process.

Why do this check? At a future date more prng methods may be added. This
is a very basic check that they produce some output although the output
is not verified in terms of it's randomness. This check was also
implemented to show an existing bug in the Isaac implementation in nwipe.

See the example log below that shows a failed prng. This would be caused
by a bug in the prng implementation. See the last few messages after
pass 3/3 starts. 3/3 in DoD short is the prng pass.

[2021/05/29 20:30:27]  notice: Invoking method 'DoD Short' on /dev/loop29
[2021/05/29 20:30:27]  notice: Starting round 1 of 1 on /dev/loop29
[2021/05/29 20:30:27]  notice: Starting pass 1/3, round 1/1, on /dev/loop29
[2021/05/29 20:30:39]  notice: 1073741824 bytes written to /dev/loop29
[2021/05/29 20:30:39]  notice: Finished pass 1/3, round 1/1, on /dev/loop29
[2021/05/29 20:30:39]  notice: Starting pass 2/3, round 1/1, on /dev/loop29
[2021/05/29 20:30:58]  notice: 1073741824 bytes written to /dev/loop29
[2021/05/29 20:30:58]  notice: Finished pass 2/3, round 1/1, on /dev/loop29
[2021/05/29 20:30:58]  notice: Starting pass 3/3, round 1/1, on /dev/loop29
[2021/05/29 20:30:58]  notice: Initialising Isaac prng
[2021/05/29 20:30:58]   fatal: ERROR, prng wrote nothing to the buffer
[2021/05/29 20:30:58]  notice: 0 bytes written to /dev/loop29
[2021/05/29 20:31:03]   error: Nwipe exited with fatal errors on device = /dev/loop29

********************************************************************************
! Device | Status | Thru-put | HH:MM:SS | Model/Serial Number
--------------------------------------------------------------------------------
! loop29 |-FAILED-|  69 MB/s | 00:00:31 | Loopback device/
--------------------------------------------------------------------------------
[2021/05/29 20:31:03] Total Throughput  69 MB/s, DoD Short, 1R+NB+NV
********************************************************************************

A message is also shown for a successful prng output. i.e "prng is active"
See example below.

[2021/05/29 20:04:30]  notice: Invoking method 'DoD Short' on /dev/loop29
[2021/05/29 20:04:30]  notice: Starting round 1 of 1 on /dev/loop29
[2021/05/29 20:04:30]  notice: Starting pass 1/3, round 1/1, on /dev/loop29
[2021/05/29 20:04:44]  notice: 1073741824 bytes written to /dev/loop29
[2021/05/29 20:04:44]  notice: Finished pass 1/3, round 1/1, on /dev/loop29
[2021/05/29 20:04:44]  notice: Starting pass 2/3, round 1/1, on /dev/loop29
[2021/05/29 20:04:59]  notice: 1073741824 bytes written to /dev/loop29
[2021/05/29 20:04:59]  notice: Finished pass 2/3, round 1/1, on /dev/loop29
[2021/05/29 20:04:59]  notice: Starting pass 3/3, round 1/1, on /dev/loop29
[2021/05/29 20:04:59]  notice: Initialising Mersenne Twister prng
[2021/05/29 20:04:59]  notice: prng stream is active
[2021/05/29 20:05:25]  notice: 1073741824 bytes written to /dev/loop29
2021-05-29 21:23:38 +01:00
PartialVolume
5bc61f2bdd Merge pull request #320 from PartialVolume/Log_intialisation_of_prng_method
Logs the specific prng that is initialised.
2021-05-28 19:54:49 +01:00
PartialVolume
b55b020a83 Log the initialisation of the prng type
Logs the specific prng that is initialised.
2021-05-28 19:45:19 +01:00
PartialVolume
b34c99b81b Bump banner & version minor version 2021-05-27 14:23:34 +01:00
PartialVolume
63d20dc4be Merge pull request #319 from PartialVolume/Add_details_of_wipe_to_log
log the nwipe options that the wipe/s is going to use.
2021-05-27 14:16:14 +01:00
PartialVolume
2111206fa3 Add nwipe options that have been selected.
The log now contains wipe configuration detail
such as method, prng, blanking, sync, rounds etc.
2021-05-27 14:06:57 +01:00
PartialVolume
5263a23cd6 Merge pull request #317 from PartialVolume/Fix_contradictory_log_messaging
Fixes contradictory log messages.
2021-05-27 08:18:29 +01:00
PartialVolume
a6b60bfd15 Fixes contradictory log messages.
1. The log reported verification errors while also
showing an entry in the log that said "[SUCCESS] Blanked /dev/...".
The blanked device message now shows [FAILURE] /dev/... may not be blanked"
if any verification errors are detected for a specific drive.

2. If a verification error occurred, the error would be correctly
shown in the GUI and in the logs but the summary table drive status
would show 'ERASED' not 'FAILED'. Now corrected so that the tables
drive status field shows 'FAILED' if any verification error is detected.
Prior to this it was marking the status as 'FAILED' only if the O.S
detected write errors. In practise most drive errors are detected
by the write I/O process on syncing but this will now detect errors not
recognised by the O.S. and found by the verification process. Despite
this the textual log and GUI correcty reported verification errors.

3. The final log message "Nwipe exited successfully" was checking for
fatal errors but ignoring non fatal errors despite being reported in
the log.

The final message now reads
either "Nwipe Exited Succesfully" if no fatal and non fatal errors were
detected. Alternatively it displays ...
"Nwipe exited with errors, check the log & summary table for individual drive status."
if any fatal OR non fatal errors are detected.
2021-05-27 08:07:20 +01:00
PartialVolume
d8d627dce3 Merge pull request #315 from PartialVolume/Fix_shutdown
Fix shutdown on buildroot based distros such as shredos 2020, while maintaining compatibility with Ubuntu/Debian etc.
2021-04-19 15:34:21 +01:00
PartialVolume
95d0b3f382 Fix shutdown on buildroot based distros
The shutdown command that nwipe currently uses is
"shutdown -P +1 "Broadcast shutdown message".
While the above command works works fine on Ubuntu 18.04 LTS it
does not work on the version of shutdown used in buildroot, failing
with the error:
"shutdown -H and -P flags can only be used along with -h flag"

Luckily there is a shutdown command with options that work correctly
on both buildroot (ShredOS) and Ubuntu 18.04 LTS, this is
shutdown -Ph +1 "Broadcast shutdown message". i.e. the option -h has been added.
2021-04-19 15:22:43 +01:00
PartialVolume
055d2e8b0c Bump minor revision 2021-03-17 21:28:29 +00:00
PartialVolume
9f0674b3b9 Merge pull request #314 from andrewvaughanj/code_formatting
Run 'make format'
2021-03-17 21:27:03 +00:00
PartialVolume
5f332a407d Merge pull request #313 from andrewvaughanj/fix_global_wipe_status
Correcting multiple definition of 'global_wipe_status'
2021-03-17 21:26:28 +00:00
Andrew V. Jones
543a880064 Run 'make format'
Signed-off-by: Andrew V. Jones <andrewvaughanj@gmail.com>
2021-03-17 17:41:32 +00:00
Andrew V. Jones
62c604bc0e Correcting multiple definition of 'global_wipe_status'
Signed-off-by: Andrew V. Jones <andrewvaughanj@gmail.com>
2021-03-17 16:07:37 +00:00
PartialVolume
2bc62a7217 Update README.md with link to gparted live 2021-02-17 21:16:55 +00:00
PartialVolume
7f5bc5aa34 Merge pull request #301 from ndowens/master
bits/sigthread.h is a glibc only and is not needed
2021-02-05 17:07:29 +00:00
PartialVolume
7fa5c98023 Merge pull request #312 from PartialVolume/fix_footer_corruption_on_resize_and_method_rounds_blanking_selection
Fixes footer bar corruption to the right of the message
2021-02-04 21:51:26 +00:00
PartialVolume
4e159a902c Merge branch 'master' into fix_footer_corruption_on_resize_and_method_rounds_blanking_selection 2021-02-04 21:50:06 +00:00
PartialVolume
3090b0682f Fixes footer bar corruption to the right of the message
This bug only occurs when you resize the terminal while
on the drive selection screen, then switch to method, rounds
or blanking. To the right of the message the text background
is now blue and not white and random box characters appear.

To me it seems to be a bug not in nwipe but in curses, however
placing double quotes around the message fixes the problem. I
also found that the contents of the message appeared to trigger
the problem, possibly the '=' symbol, however the fact that
the main selection text does not require the quotes is most odd.
Still, this simple fix seems to get rid of the problem.
2021-02-04 21:40:26 +00:00
PartialVolume
d2dff52407 Merge pull request #310 from Firminator/patch-1
Update gui.c - Add CTRL+A
2021-02-01 11:43:46 +00:00
PartialVolume
58a5184c88 Removed CTRL+A=SelectALL from help as it makes the help text greater than 80 characters required for system working with frame buffer displays using 80x25. I have a plan to make the help line responsive or multipage to overcome this limitation so more commands can be added. Secondly, one line needed to be formatted to pass CI format check. 2021-02-01 11:40:52 +00:00
PartialVolume
6dcaaa6920 Update README.md with make format
If submitting pull requests, you must `make format` prior to commiting code and submitting a pull request otherwise you pull request will fail the CI that checks formatting.
2021-01-31 00:17:35 +00:00
PartialVolume
8e9e2ae90f Update README.md with make format
If submitting pull requests, you must `make format` prior to commiting code and submitting a pull request otherwise you pull request will fail the CI that checks formatting.
2021-01-31 00:15:58 +00:00
PartialVolume
02e356e0ec Merge pull request #311 from PartialVolume/fix_uaborted_message_in_summary_table
Fixes to summary table & fix final status message Fixes #308
2021-01-30 19:17:15 +00:00
PartialVolume
12063ad954 Fixes to summary table & fix final status message
1. Prior to this fix, if a user aborted a multi drive using control-C,
and if some of the drives had completed their wipe either
successfully or with a I/O failures, the summary log would say
UABORTED for all drives. UABORTED is acceptable status for drives that
hadn't completed their wipe but for drives that had completed the wipe,
the summary table should have gave either a ERASED or FAILED status
message. This fix corrects the summary status when using control-c to
abort a multi drive wipe where some drives have completed and some have
not.

2. If I wipe was selected but not started and then the user used
control-C to abort nwipe, the summary table would possibly
intermittently be displayed showing the last drive wiped. The correct
behaviour is that no summary table is displayed if the wipe hasn't been
started yet. This fix corrects the behaviour of the summary table when
control-c is used and a drive has been selected for wiping but not
started, in this scenario the summary table is NOT displayed.

3. When nwipe exits it always prints the message "nwipe successfully
exited". To make this single line message more informative it now
reports a different message depending upon the wipe status.

These four messages are:

"Nwipe was aborted by the user. Check the summary table for the drive
status" -  When the user aborts during a wipe.

"Nwipe was aborted by the user prior to the wipe starting."

"Nwipe exited with fatal errors, check the summary table for individual
drive status." - When one or more drives failed.

"Nwipe successfully completed. See summary table for details." - When
selected drives were all erased without error.
2021-01-30 19:08:05 +00:00
Firminator
66d239c980 Update gui.c - Add CTRL+A
... and reduce confusion about lowercase and uppercase option. All options are now defaulting to show as lowercase in the GUI except Start which can only be invoked with SHIFT S to prevent accidental start of wipe. Unless someone enjoys pressing additionally SHIFT for B and R and V and all the other options I'd propose it might be time to remove unneeded code for this :)
2021-01-30 13:37:48 -05:00
PartialVolume
462777d92b Merge pull request #309 from Firminator/patch-1
Corrected --nousb
2021-01-30 09:14:50 +00:00
Firminator
69c9d7d6c5 Corrected --nousb
emphasized that no[gui,blank,wait,signals,usb] will ignore things
2021-01-29 21:13:37 -05:00
PartialVolume
fffee8bb34 Update README.md
Updated link to buildnwipe script
2021-01-08 23:35:07 +00:00
PartialVolume
b8a536a02f Merge pull request #303 from NoNameForMee/master
Correct one external link in README.md
2021-01-08 23:13:33 +00:00
NoNameForMee
0c542660ff Correct one external link in README.md
To official website of SystemRescue (also known as SystemRescueCd).
2021-01-08 20:35:45 +01:00
PartialVolume
412917ab17 Update README.md
Add link to repology with reference to nwipe. Information on which version of Nwipe is in which distro version.
2021-01-07 21:01:14 +00:00
Nathan Owens
f5501ccc45 bits/sigthread.h is a glibc only and is not needed 2020-12-21 12:23:53 -06:00
PartialVolume
d819330583 bump minor banner revision 2020-12-19 18:32:39 +00:00
PartialVolume
2061346ace Merge pull request #300 from andreasheil/update-man-and-help
Update man and help
2020-12-19 18:30:51 +00:00
Andreas Heil
69fed30dde fix typo and reformat 2020-12-18 10:14:06 +01:00
Andreas Heil
7cc1a68a89 updated manpage 2020-12-18 10:13:35 +01:00
15 changed files with 535 additions and 280 deletions

View File

@@ -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)

View File

@@ -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:

View File

@@ -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])

View File

@@ -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,

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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;
}
}
}
}

View File

@@ -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;
}
}

View File

@@ -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.

View File

@@ -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;

View File

@@ -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" );

View File

@@ -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 );

View File

@@ -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;
}

View File

@@ -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_ */

View File

@@ -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";