mirror of
https://github.com/martijnvanbrummelen/nwipe.git
synced 2026-02-21 14:32:15 +00:00
Compare commits
60 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f5c05506f | ||
|
|
23c69f34c1 | ||
|
|
0b1cb83013 | ||
|
|
17f23ba03b | ||
|
|
22665fa781 | ||
|
|
95dc8abcf3 | ||
|
|
fd55f48267 | ||
|
|
d9ba357722 | ||
|
|
8a85d7e96f | ||
|
|
cac9b17f9b | ||
|
|
37109daae7 | ||
|
|
052852d475 | ||
|
|
4b20e7ca76 | ||
|
|
c8a5a16108 | ||
|
|
4e64cab3c3 | ||
|
|
5f65683f63 | ||
|
|
7b170bb444 | ||
|
|
464bf788c5 | ||
|
|
16e78b8523 | ||
|
|
f71b23afc4 | ||
|
|
e7d9ff73fe | ||
|
|
1fce0eb936 | ||
|
|
72c5cd8a0f | ||
|
|
0f06e91ce5 | ||
|
|
0f26c8ea68 | ||
|
|
9c63eef565 | ||
|
|
db9e7ef1aa | ||
|
|
7039f381af | ||
|
|
b808b8402c | ||
|
|
c6fa743f15 | ||
|
|
61e8e4663f | ||
|
|
ea198137de | ||
|
|
263d5d161f | ||
|
|
15c444e2eb | ||
|
|
1e1eadbc0a | ||
|
|
d01b00b4f8 | ||
|
|
3c0c8408f6 | ||
|
|
a619de6134 | ||
|
|
3176688f3e | ||
|
|
b03f063e89 | ||
|
|
f9fd45f129 | ||
|
|
d10dca3bed | ||
|
|
8fa0d8c1f4 | ||
|
|
47ff866968 | ||
|
|
edfabad8a1 | ||
|
|
2f44978db4 | ||
|
|
fbe6e9d150 | ||
|
|
3ba8d3814b | ||
|
|
8a9a718221 | ||
|
|
a86f366147 | ||
|
|
e1627b3dc5 | ||
|
|
167e4787b7 | ||
|
|
5a63140baf | ||
|
|
35009577ca | ||
|
|
2b65e93207 | ||
|
|
69dda249c2 | ||
|
|
124ec1e4a9 | ||
|
|
57c14286db | ||
|
|
ae5d2355cb | ||
|
|
51d33b9f61 |
31
.gitignore
vendored
Normal file
31
.gitignore
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache/
|
||||
compile
|
||||
config.h
|
||||
config.h.in
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
depcomp
|
||||
install-sh
|
||||
man/Makefile
|
||||
man/Makefile.in
|
||||
missing
|
||||
src/.deps/
|
||||
src/Makefile
|
||||
src/Makefile.in
|
||||
src/nwipe
|
||||
src/nwipe-device.o
|
||||
src/nwipe-gui.o
|
||||
src/nwipe-isaac_rand.o
|
||||
src/nwipe-logging.o
|
||||
src/nwipe-method.o
|
||||
src/nwipe-mt19937ar-cok.o
|
||||
src/nwipe-nwipe.o
|
||||
src/nwipe-options.o
|
||||
src/nwipe-pass.o
|
||||
src/nwipe-prng.o
|
||||
src/nwipe-version.o
|
||||
stamp-h1
|
||||
39
README
39
README
@@ -10,14 +10,49 @@ make install
|
||||
|
||||
The ncurses, pthreads and parted libraries are required for compiling.
|
||||
For any problems, please use the Github page:
|
||||
https://github.com/abeverley/nwipe
|
||||
https://github.com/martijnvanbrummelen/nwipe
|
||||
|
||||
Andy Beverley
|
||||
Martijn van Brummelen
|
||||
|
||||
|
||||
RELEASE NOTES
|
||||
=============
|
||||
|
||||
v0.23
|
||||
- make serial visible again on 32Bit machines
|
||||
|
||||
v0.22
|
||||
- Update manpage
|
||||
- use long long for device size
|
||||
- Use ped_unit_format_byte function to display(friendly) size of device
|
||||
|
||||
v0.21
|
||||
- Fix ETA not updating properly and bad total throughput display. Thanks (Niels Bassler).
|
||||
|
||||
v0.20
|
||||
- Fix build when panel header is not in /usr/include (Thanks Vincent Untz).
|
||||
|
||||
v0.19
|
||||
- Fix building on Fedora(Unknown off64_t) bug #19.
|
||||
- Use PRNG instead of zero's bug #7. Thanks xambroz.
|
||||
|
||||
v0.18
|
||||
=====
|
||||
- Fixed grammar.
|
||||
- Move from loff_t to off64_t for musl libc support.
|
||||
- Add "--nosignals" option.
|
||||
- Automake needs the dist_ prefix to include man pages in 'make dist'.
|
||||
- Remove more compiler warnings.
|
||||
- Add libintl, libuuid dependencies to allow parted static link
|
||||
|
||||
v0.17
|
||||
=====
|
||||
- Remove control reaches end of non-void function" warnings(Thanks Vincent
|
||||
Untz).
|
||||
- Remove unused variables (thanks Vincent Untz).
|
||||
- Change start key to 'S' instead of F10 (closes debian bug #755474).
|
||||
- Fix problem with unusable device (Closes debian bug #755473).
|
||||
|
||||
v0.16
|
||||
=====
|
||||
- Fix problems building with clang compiler (thanks Martijn van Brummelen)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
nwipe is a command that will securely erase disks using a variety of
|
||||
recognised methods. It is a fork of the dwipe command used by
|
||||
Darik's Boot and Nuke (dban). nwipe is included with partedmagic if
|
||||
Darik's Boot and Nuke (dban). nwipe is included with partedmagic if you
|
||||
want a quick and easy bootable CD version. nwipe was created out of
|
||||
a need to run the DBAN dwipe command outside of DBAN, in order to
|
||||
allow its use with any host distribution, thus giving better hardware
|
||||
|
||||
17
configure.ac
17
configure.ac
@@ -2,8 +2,8 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.64])
|
||||
AC_INIT(nwipe, 0.16, andy@andybev.com)
|
||||
AM_INIT_AUTOMAKE(nwipe, 0.16)
|
||||
AC_INIT(nwipe, 0.23, git@brumit.nl)
|
||||
AM_INIT_AUTOMAKE(nwipe, 0.23)
|
||||
AC_OUTPUT(Makefile src/Makefile man/Makefile)
|
||||
AC_CONFIG_SRCDIR([src/nwipe.c])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
@@ -21,7 +21,14 @@ PKG_CHECK_MODULES(
|
||||
CFLAGS="${CFLAGS} ${PANEL_CFLAGS}"
|
||||
LIBS="${LIBS} ${PANEL_LIBS}"
|
||||
],
|
||||
[AC_CHECK_LIB([panel], [main], ,[AC_MSG_ERROR([ncurses panel library not found])])]
|
||||
[AC_CHECK_LIB([panel], [main], [
|
||||
LIBS="-lpanel $LIBS"
|
||||
AC_CHECK_HEADERS(panel.h,, [
|
||||
AC_CHECK_HEADERS(ncurses/panel.h, [
|
||||
AC_DEFINE([PANEL_IN_SUBDIR], [ncurses/], [Look for ncurses headers in subdir])
|
||||
], [AC_MSG_ERROR([ncurses panel headers not found])])
|
||||
])
|
||||
], [AC_MSG_ERROR([ncurses panel library not found])])]
|
||||
)
|
||||
|
||||
PKG_CHECK_MODULES(
|
||||
@@ -42,7 +49,9 @@ PKG_CHECK_MODULES(
|
||||
)]
|
||||
)
|
||||
|
||||
AC_CHECK_LIB([parted], [ped_device_probe_all], ,[AC_MSG_ERROR([parted development library not found])])
|
||||
AC_CHECK_LIB([intl], [libintl_dgettext]) # needed to statically link libparted, but not given in its pkgconfig file
|
||||
AC_CHECK_LIB([uuid], [uuid_generate]) # needed to statically link libparted, but not given in its pkgconfig file
|
||||
PKG_CHECK_MODULES([PARTED], [libparted])
|
||||
AC_CHECK_LIB([pthread], [main], ,[AC_MSG_ERROR([pthread development library not found])])
|
||||
|
||||
# Checks for header files.
|
||||
|
||||
@@ -1 +1 @@
|
||||
man_MANS = nwipe.1
|
||||
dist_man_MANS = nwipe.1
|
||||
|
||||
12
man/nwipe.1
12
man/nwipe.1
@@ -1,4 +1,4 @@
|
||||
.TH NWIPE "1" "March 2014" "nwipe version 0.16" "User Commands"
|
||||
.TH NWIPE "1" "December 2017" "nwipe version 0.23" "User Commands"
|
||||
.SH NAME
|
||||
nwipe \- securely erase disks
|
||||
.SH SYNOPSIS
|
||||
@@ -40,6 +40,9 @@ Open devices in sync mode
|
||||
\fB\-\-nowait\fR
|
||||
Do not wait for a key before exiting (default is to wait).
|
||||
.TP
|
||||
\fB\-\-nosignals\fR
|
||||
Do not allow signals to interrupt a wipe (default is to allow).
|
||||
.TP
|
||||
\fB\-\-nogui\fR
|
||||
Do not show the GUI interface. Can only be used with the autonuke option.
|
||||
Nowait option is automatically invoked with the nogui option.
|
||||
@@ -75,11 +78,10 @@ PRNG option (mersenne|twister|isaac)
|
||||
\fB\-r\fR, \fB\-\-rounds\fR=\fINUM\fR
|
||||
Number of times to wipe the device using the selected method (default: 1)
|
||||
.SH BUGS
|
||||
Please see the sourceforge site for the latest list
|
||||
(http://nwipe.sourceforge.net)
|
||||
Please see the github site for the latest list
|
||||
(https://github.com/martijnvanbrummelen/nwipe/issues)
|
||||
.SH AUTHOR
|
||||
Nwipe was released by Andy Beverley <andy@andybev.com>
|
||||
as modified version of dwipe from DBAN by Darik Horn <dajhorn-dban@vanadac.com>.
|
||||
Nwipe is developed by Martijn van Brummelen <github@brumit.nl>
|
||||
.SH "SEE ALSO"
|
||||
.BR shred (1),
|
||||
.BR dwipe (1),
|
||||
|
||||
@@ -7,3 +7,5 @@ AM_LDFLAGS =
|
||||
# the previous manual Makefile
|
||||
bin_PROGRAMS = nwipe
|
||||
nwipe_SOURCES = context.h isaac_rand.c logging.h options.h prng.h nwipe.c gui.c isaac_rand.h method.h pass.c device.c gui.h isaac_standard.h mt19937ar-cok.c nwipe.h mt19937ar-cok.h pass.h device.h logging.c method.c options.c prng.c version.c version.h
|
||||
nwipe_CFLAGS = $(PARTED_CFLAGS)
|
||||
nwipe_LDADD = $(PARTED_LIBS)
|
||||
|
||||
@@ -72,48 +72,49 @@ typedef struct nwipe_speedring_t_
|
||||
|
||||
typedef struct nwipe_context_t_
|
||||
{
|
||||
int block_size; /* The soft block size reported the device. */
|
||||
int device_bus; /* The device bus number. */
|
||||
int device_fd; /* The file descriptor of the device file being wiped. */
|
||||
int device_host; /* The host number. */
|
||||
struct hd_driveid device_id; /* The WIN_IDENTIFY data for IDE drives. */
|
||||
int device_lun; /* The device logical unit number. */
|
||||
int device_major; /* The major device number. */
|
||||
int device_minor; /* The minor device number. */
|
||||
int device_part; /* The device partition or slice number. */
|
||||
char* device_name; /* The device file name. */
|
||||
loff_t device_size; /* The device size in bytes. */
|
||||
struct stat device_stat; /* The device file state from fstat(). */
|
||||
nwipe_device_t device_type; /* Indicates an IDE, SCSI, or Compaq SMART device. */
|
||||
int device_target; /* The device target. */
|
||||
u64 eta; /* The estimated number of seconds until method completion. */
|
||||
int entropy_fd; /* The entropy source. Usually /dev/urandom. */
|
||||
char* label; /* The string that we will show the user. */
|
||||
int pass_count; /* The number of passes performed by the working wipe method. */
|
||||
u64 pass_done; /* The number of bytes that have already been i/o'd in this pass. */
|
||||
u64 pass_errors; /* The number of errors across all passes. */
|
||||
u64 pass_size; /* The total number of i/o bytes across all passes. */
|
||||
nwipe_pass_t pass_type; /* The type of the current working pass. */
|
||||
int pass_working; /* The current working pass. */
|
||||
nwipe_prng_t* prng; /* The PRNG implementation. */
|
||||
nwipe_entropy_t prng_seed; /* The random data that is used to seed the PRNG. */
|
||||
void* prng_state; /* The private internal state of the PRNG. */
|
||||
int result; /* The process return value. */
|
||||
int round_count; /* The number of rounds performed by the working wipe method. */
|
||||
u64 round_done; /* The number of bytes that have already been i/o'd. */
|
||||
u64 round_errors; /* The number of errors across all rounds. */
|
||||
u64 round_size; /* The total number of i/o bytes across all rounds. */
|
||||
double round_percent; /* The percentage complete across all rounds. */
|
||||
int round_working; /* The current working round. */
|
||||
int sector_size; /* The hard sector size reported by the device. */
|
||||
nwipe_select_t select; /* Indicates whether this device should be wiped. */
|
||||
int signal; /* Set when the child is killed by a signal. */
|
||||
nwipe_speedring_t speedring; /* Ring buffer for computing the rolling throughput average. */
|
||||
short sync_status; /* A flag to indicate when the method is syncing. */
|
||||
pthread_t thread; /* The ID of the thread. */
|
||||
u64 throughput; /* Average throughput in bytes per second. */
|
||||
u64 verify_errors; /* The number of verification errors across all passes. */
|
||||
struct hd_driveid identity; /* The serial number of the drive (where applicable) */
|
||||
int block_size; /* The soft block size reported the device. */
|
||||
int device_bus; /* The device bus number. */
|
||||
int device_fd; /* The file descriptor of the device file being wiped. */
|
||||
int device_host; /* The host number. */
|
||||
struct hd_driveid device_id; /* The WIN_IDENTIFY data for IDE drives. */
|
||||
int device_lun; /* The device logical unit number. */
|
||||
int device_major; /* The major device number. */
|
||||
int device_minor; /* The minor device number. */
|
||||
int device_part; /* The device partition or slice number. */
|
||||
char* device_name; /* The device file name. */
|
||||
long long device_size; /* The device size in bytes. */
|
||||
char* device_size_text; /* The device size in a more (human)readable format. */
|
||||
struct stat device_stat; /* The device file state from fstat(). */
|
||||
nwipe_device_t device_type; /* Indicates an IDE, SCSI, or Compaq SMART device. */
|
||||
int device_target; /* The device target. */
|
||||
u64 eta; /* The estimated number of seconds until method completion. */
|
||||
int entropy_fd; /* The entropy source. Usually /dev/urandom. */
|
||||
char* label; /* The string that we will show the user. */
|
||||
int pass_count; /* The number of passes performed by the working wipe method. */
|
||||
u64 pass_done; /* The number of bytes that have already been i/o'd in this pass. */
|
||||
u64 pass_errors; /* The number of errors across all passes. */
|
||||
u64 pass_size; /* The total number of i/o bytes across all passes. */
|
||||
nwipe_pass_t pass_type; /* The type of the current working pass. */
|
||||
int pass_working; /* The current working pass. */
|
||||
nwipe_prng_t* prng; /* The PRNG implementation. */
|
||||
nwipe_entropy_t prng_seed; /* The random data that is used to seed the PRNG. */
|
||||
void* prng_state; /* The private internal state of the PRNG. */
|
||||
int result; /* The process return value. */
|
||||
int round_count; /* The number of rounds performed by the working wipe method. */
|
||||
u64 round_done; /* The number of bytes that have already been i/o'd. */
|
||||
u64 round_errors; /* The number of errors across all rounds. */
|
||||
u64 round_size; /* The total number of i/o bytes across all rounds. */
|
||||
double round_percent; /* The percentage complete across all rounds. */
|
||||
int round_working; /* The current working round. */
|
||||
int sector_size; /* The hard sector size reported by the device. */
|
||||
nwipe_select_t select; /* Indicates whether this device should be wiped. */
|
||||
int signal; /* Set when the child is killed by a signal. */
|
||||
nwipe_speedring_t speedring; /* Ring buffer for computing the rolling throughput average. */
|
||||
short sync_status; /* A flag to indicate when the method is syncing. */
|
||||
pthread_t thread; /* The ID of the thread. */
|
||||
u64 throughput; /* Average throughput in bytes per second. */
|
||||
u64 verify_errors; /* The number of verification errors across all passes. */
|
||||
struct hd_driveid identity; /* The serial number of the drive (where applicable) */
|
||||
} nwipe_context_t;
|
||||
|
||||
|
||||
|
||||
@@ -19,9 +19,7 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Why is this needed? Segfaults without it */
|
||||
#include <netinet/in.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "nwipe.h"
|
||||
#include "context.h"
|
||||
@@ -30,7 +28,6 @@
|
||||
#include "logging.h"
|
||||
|
||||
#include <parted/parted.h>
|
||||
#include <parted/debug.h>
|
||||
|
||||
int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount );
|
||||
|
||||
@@ -124,6 +121,7 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount )
|
||||
next_device->label = dev->model;
|
||||
next_device->device_name = dev->path;
|
||||
next_device->device_size = dev->length * dev->sector_size;
|
||||
next_device->device_size_text = ped_unit_format_byte(dev, dev->length * dev->sector_size);
|
||||
/* Attempt to get serial number of device. */
|
||||
ioctl(next_device->device_fd, HDIO_GET_IDENTITY, &next_device->identity);
|
||||
|
||||
|
||||
29
src/gui.c
29
src/gui.c
@@ -29,7 +29,6 @@
|
||||
* and things like ncurses libmenu are not worth the storage overhead.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Why is this needed? Segfaults without it */
|
||||
#include <netinet/in.h>
|
||||
|
||||
@@ -41,6 +40,8 @@
|
||||
#include "gui.h"
|
||||
#include "pass.h"
|
||||
#include "logging.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
#define NWIPE_GUI_PANE 8
|
||||
|
||||
@@ -123,7 +124,7 @@ const char* options_title = " Options ";
|
||||
const char* stats_title = " Statistics ";
|
||||
|
||||
/* Footer labels. */
|
||||
const char* nwipe_buttons1 = "Ctrl-C=Quit F10=Start M=Method P=PRNG V=Verify R=Rounds B=Blanking-pass Space=Select";
|
||||
const char* nwipe_buttons1 = "Ctrl-C=Quit S=Start M=Method P=PRNG V=Verify R=Rounds B=Blanking-pass Space=Select";
|
||||
const char* nwipe_buttons2 = " J=Up K=Down Space=Select";
|
||||
const char* nwipe_buttons3 = " B=Blank screen, ctrl-c=Quit";
|
||||
|
||||
@@ -229,7 +230,7 @@ void nwipe_gui_init( void )
|
||||
wclear( header_window );
|
||||
|
||||
/* Print the product banner. */
|
||||
nwipe_gui_title( header_window, nwipe_options.banner );
|
||||
nwipe_gui_title( header_window, banner );
|
||||
|
||||
/* Create the footer window. */
|
||||
footer_window = newwin( NWIPE_GUI_FOOTER_H, NWIPE_GUI_FOOTER_W, NWIPE_GUI_FOOTER_Y, NWIPE_GUI_FOOTER_X );
|
||||
@@ -446,40 +447,40 @@ void nwipe_gui_select( int count, nwipe_context_t** c )
|
||||
{
|
||||
case NWIPE_SELECT_TRUE:
|
||||
|
||||
wprintw( main_window, " [wipe] %i. %s - %s %s (%lld bytes)", (i + offset + 1),
|
||||
wprintw( main_window, " [wipe] %i. %s - %s %s (%s)", (i + offset + 1),
|
||||
c[i+offset]->device_name,
|
||||
c[i+offset]->label,
|
||||
c[i+offset]->identity.serial_no,
|
||||
c[i+offset]->device_size );
|
||||
c[i+offset]->device_size_text );
|
||||
break;
|
||||
|
||||
case NWIPE_SELECT_FALSE:
|
||||
/* Print an element that is not selected. */
|
||||
wprintw( main_window, " [ ] %i. %s - %s %s (%lld bytes)", (i + offset +1),
|
||||
wprintw( main_window, " [ ] %i. %s - %s %s (%s)", (i + offset +1),
|
||||
c[i+offset]->device_name,
|
||||
c[i+offset]->label,
|
||||
c[i+offset]->identity.serial_no,
|
||||
c[i+offset]->device_size );
|
||||
c[i+offset]->device_size_text );
|
||||
break;
|
||||
|
||||
case NWIPE_SELECT_TRUE_PARENT:
|
||||
|
||||
/* This element will be wiped when its parent is wiped. */
|
||||
wprintw( main_window, " [****] %i. %s - %s %s (%lld bytes)", (i + offset +1),
|
||||
wprintw( main_window, " [****] %i. %s - %s %s (%s)", (i + offset +1),
|
||||
c[i+offset]->device_name,
|
||||
c[i+offset]->label,
|
||||
c[i+offset]->identity.serial_no,
|
||||
c[i+offset]->device_size );
|
||||
c[i+offset]->device_size_text );
|
||||
break;
|
||||
|
||||
case NWIPE_SELECT_FALSE_CHILD:
|
||||
|
||||
/* We can't wipe this element because it has a child that is being wiped. */
|
||||
wprintw( main_window, " [----] %i. %s - %s %s (%lld bytes)", (i + offset +1),
|
||||
wprintw( main_window, " [----] %i. %s - %s %s (%s)", (i + offset +1),
|
||||
c[i+offset]->device_name,
|
||||
c[i+offset]->label,
|
||||
c[i+offset]->identity.serial_no,
|
||||
c[i+offset]->device_size );
|
||||
c[i+offset]->device_size_text );
|
||||
break;
|
||||
|
||||
case NWIPE_SELECT_DISABLED:
|
||||
@@ -750,7 +751,7 @@ void nwipe_gui_select( int count, nwipe_context_t** c )
|
||||
|
||||
} /* keystroke switch */
|
||||
|
||||
} while( keystroke != KEY_F(10) && keystroke != ERR );
|
||||
} while( keystroke != 'S' && keystroke != ERR );
|
||||
|
||||
/* Clear the main window. */
|
||||
werase( main_window );
|
||||
@@ -2017,6 +2018,7 @@ void *nwipe_gui_status( void *ptr )
|
||||
wrefresh( footer_window );
|
||||
nwipe_misc_thread_data->gui_thread = 0;
|
||||
|
||||
return NULL;
|
||||
} /* nwipe_gui_status */
|
||||
|
||||
int compute_stats(void *ptr)
|
||||
@@ -2035,6 +2037,9 @@ int compute_stats(void *ptr)
|
||||
int i;
|
||||
|
||||
time_t nwipe_time_now = time( NULL );
|
||||
|
||||
nwipe_misc_thread_data->throughput = 0;
|
||||
nwipe_misc_thread_data->maxeta = 0;
|
||||
|
||||
/* Enumerate all contexts to compute statistics. */
|
||||
for( i = 0 ; i < count ; i++ )
|
||||
|
||||
@@ -29,8 +29,10 @@ void isaac(ctx)
|
||||
randctx *ctx;
|
||||
{
|
||||
register ub4 a,b,x,y,*m,*mm,*m2,*r,*mend;
|
||||
mm=ctx->randmem; r=ctx->randrsl;
|
||||
a = ctx->randa; b = ctx->randb + (++ctx->randc);
|
||||
mm=ctx->randmem;
|
||||
r=ctx->randrsl;
|
||||
a = ctx->randa;
|
||||
b = ctx->randb + (++ctx->randc);
|
||||
for (m = mm, mend = m2 = m+(RANDSIZ/2); m<mend; )
|
||||
{
|
||||
rngstep( a<<13, a, b, mm, m, m2, r, x);
|
||||
@@ -84,20 +86,44 @@ word flag;
|
||||
/* initialize using the contents of r[] as the seed */
|
||||
for (i=0; i<RANDSIZ; i+=8)
|
||||
{
|
||||
a+=r[i ]; b+=r[i+1]; c+=r[i+2]; d+=r[i+3];
|
||||
e+=r[i+4]; f+=r[i+5]; g+=r[i+6]; h+=r[i+7];
|
||||
a+=r[i ];
|
||||
b+=r[i+1];
|
||||
c+=r[i+2];
|
||||
d+=r[i+3];
|
||||
e+=r[i+4];
|
||||
f+=r[i+5];
|
||||
g+=r[i+6];
|
||||
h+=r[i+7];
|
||||
mix(a,b,c,d,e,f,g,h);
|
||||
m[i ]=a; m[i+1]=b; m[i+2]=c; m[i+3]=d;
|
||||
m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h;
|
||||
m[i ]=a;
|
||||
m[i+1]=b;
|
||||
m[i+2]=c;
|
||||
m[i+3]=d;
|
||||
m[i+4]=e;
|
||||
m[i+5]=f;
|
||||
m[i+6]=g;
|
||||
m[i+7]=h;
|
||||
}
|
||||
/* do a second pass to make all of the seed affect all of m */
|
||||
for (i=0; i<RANDSIZ; i+=8)
|
||||
{
|
||||
a+=m[i ]; b+=m[i+1]; c+=m[i+2]; d+=m[i+3];
|
||||
e+=m[i+4]; f+=m[i+5]; g+=m[i+6]; h+=m[i+7];
|
||||
a+=m[i ];
|
||||
b+=m[i+1];
|
||||
c+=m[i+2];
|
||||
d+=m[i+3];
|
||||
e+=m[i+4];
|
||||
f+=m[i+5];
|
||||
g+=m[i+6];
|
||||
h+=m[i+7];
|
||||
mix(a,b,c,d,e,f,g,h);
|
||||
m[i ]=a; m[i+1]=b; m[i+2]=c; m[i+3]=d;
|
||||
m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h;
|
||||
m[i ]=a;
|
||||
m[i+1]=b;
|
||||
m[i+2]=c;
|
||||
m[i+3]=d;
|
||||
m[i+4]=e;
|
||||
m[i+5]=f;
|
||||
m[i+6]=g;
|
||||
m[i+7]=h;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -106,8 +132,14 @@ word flag;
|
||||
for (i=0; i<RANDSIZ; i+=8)
|
||||
{
|
||||
mix(a,b,c,d,e,f,g,h);
|
||||
m[i ]=a; m[i+1]=b; m[i+2]=c; m[i+3]=d;
|
||||
m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h;
|
||||
m[i ]=a;
|
||||
m[i+1]=b;
|
||||
m[i+2]=c;
|
||||
m[i+3]=d;
|
||||
m[i+4]=e;
|
||||
m[i+5]=f;
|
||||
m[i+6]=g;
|
||||
m[i+7]=h;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ void nwipe_log( nwipe_log_t level, const char* format, ... )
|
||||
|
||||
/* Get the current time. */
|
||||
t = time( NULL );
|
||||
p = gmtime( &t );
|
||||
p = localtime( &t );
|
||||
|
||||
pthread_mutex_lock( &mutex1 );
|
||||
|
||||
|
||||
@@ -111,6 +111,7 @@ void *nwipe_zero( void *ptr )
|
||||
/* Finished. Set the thread ID to 0 so that the GUI knows */
|
||||
c->thread = 0;
|
||||
|
||||
return NULL;
|
||||
} /* nwipe_zero */
|
||||
|
||||
|
||||
@@ -173,6 +174,7 @@ void *nwipe_dod522022m( void *ptr )
|
||||
/* Finished. Set the thread ID to 0 so that the GUI knows */
|
||||
c->thread = 0;
|
||||
|
||||
return NULL;
|
||||
} /* nwipe_dod522022m */
|
||||
|
||||
|
||||
@@ -229,6 +231,7 @@ void *nwipe_dodshort( void *ptr )
|
||||
/* Finished. Set the thread ID to 0 so that the GUI knows */
|
||||
c->thread = 0;
|
||||
|
||||
return NULL;
|
||||
} /* nwipe_dodshort */
|
||||
|
||||
|
||||
@@ -355,6 +358,7 @@ void *nwipe_gutmann( void *ptr )
|
||||
/* Finished. Set the thread ID to 0 so that the GUI knows */
|
||||
c->thread = 0;
|
||||
|
||||
return NULL;
|
||||
} /* nwipe_gutmann */
|
||||
|
||||
|
||||
@@ -506,6 +510,7 @@ void *nwipe_ops2( void *ptr )
|
||||
/* Finished. Set the thread ID to 0 so that the GUI knows */
|
||||
c->thread = 0;
|
||||
|
||||
return NULL;
|
||||
} /* nwipe_ops2 */
|
||||
|
||||
|
||||
@@ -534,6 +539,7 @@ void *nwipe_random( void *ptr )
|
||||
/* Finished. Set the thread ID to 0 so that the GUI knows */
|
||||
c->thread = 0;
|
||||
|
||||
return NULL;
|
||||
} /* nwipe_random */
|
||||
|
||||
|
||||
|
||||
41
src/nwipe.c
41
src/nwipe.c
@@ -48,18 +48,9 @@ int main( int argc, char** argv )
|
||||
int nwipe_enumerated; /* The number of contexts that have been enumerated. */
|
||||
int nwipe_error = 0; /* An error counter. */
|
||||
int nwipe_selected = 0; /* The number of contexts that have been selected. */
|
||||
int nwipe_shmid; /* A shared memory handle for the context array. */
|
||||
int nwipe_wait = 0; /* The number of child processes that have returned. */
|
||||
pthread_t nwipe_gui_thread; /* The thread ID of the GUI thread. */
|
||||
pthread_t nwipe_sigint_thread; /* The thread ID of the sigint handler. */
|
||||
|
||||
/* The list of device filenames. */
|
||||
char** nwipe_names = NULL;
|
||||
|
||||
/* Used to write-out the result file. */
|
||||
char nwipe_result_file [FILENAME_MAX];
|
||||
FILE* nwipe_result_fp;
|
||||
|
||||
/* The entropy source file handle. */
|
||||
int nwipe_entropy;
|
||||
|
||||
@@ -78,9 +69,6 @@ int main( int argc, char** argv )
|
||||
/* Initialised and populated in device scan. */
|
||||
nwipe_context_t **c1 = 0;
|
||||
|
||||
/* The array of pointers to contexts that will actually be wiped. */
|
||||
nwipe_context_t **c2 = (nwipe_context_t **)malloc(nwipe_enumerated * sizeof(nwipe_context_t *));
|
||||
|
||||
/* Parse command line options. */
|
||||
nwipe_optind = nwipe_options_parse( argc, argv );
|
||||
|
||||
@@ -104,14 +92,21 @@ int main( int argc, char** argv )
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
argv += nwipe_optind;
|
||||
argv += nwipe_optind;
|
||||
argc -= nwipe_optind;
|
||||
|
||||
nwipe_enumerated = nwipe_device_get( &c1, argv, argc );
|
||||
if ( nwipe_enumerated == 0 )
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* The array of pointers to contexts that will actually be wiped. */
|
||||
nwipe_context_t **c2 = (nwipe_context_t **)malloc(nwipe_enumerated * sizeof(nwipe_context_t *));
|
||||
|
||||
/* Open the entropy source. */
|
||||
nwipe_entropy = open( NWIPE_KNOB_ENTROPY, O_RDONLY );
|
||||
|
||||
@@ -151,12 +146,14 @@ int main( int argc, char** argv )
|
||||
nwipe_misc_thread_data.gui_thread = &nwipe_gui_thread;
|
||||
nwipe_thread_data_ptr.nwipe_misc_thread_data = &nwipe_misc_thread_data;
|
||||
|
||||
pthread_attr_t pthread_attr;
|
||||
pthread_attr_init(&pthread_attr);
|
||||
pthread_attr_setdetachstate(&pthread_attr, PTHREAD_CREATE_DETACHED);
|
||||
|
||||
pthread_create( &nwipe_sigint_thread, &pthread_attr, signal_hand, &nwipe_thread_data_ptr);
|
||||
if( !nwipe_options.nosignals )
|
||||
{
|
||||
pthread_attr_t pthread_attr;
|
||||
pthread_attr_init(&pthread_attr);
|
||||
pthread_attr_setdetachstate(&pthread_attr, PTHREAD_CREATE_DETACHED);
|
||||
|
||||
pthread_create( &nwipe_sigint_thread, &pthread_attr, signal_hand, &nwipe_thread_data_ptr);
|
||||
}
|
||||
|
||||
/* A context struct for each device has already been created. */
|
||||
/* Now set specific nwipe options */
|
||||
@@ -358,7 +355,7 @@ int main( int argc, char** argv )
|
||||
}
|
||||
|
||||
|
||||
if( c2[i]->device_size == (loff_t)-1 )
|
||||
if( c2[i]->device_size == (long long)-1 )
|
||||
{
|
||||
/* We cannot determine the size of this device. */
|
||||
nwipe_perror( errno, __FUNCTION__, "lseek" );
|
||||
@@ -371,7 +368,7 @@ int main( int argc, char** argv )
|
||||
/* Reset the file pointer. */
|
||||
r = lseek( c2[i]->device_fd, 0, SEEK_SET );
|
||||
|
||||
if( r == (loff_t)-1 )
|
||||
if( r == (off64_t)-1 )
|
||||
{
|
||||
nwipe_perror( errno, __FUNCTION__, "lseek" );
|
||||
nwipe_log( NWIPE_LOG_ERROR, "Unable to reset the '%s' file offset.", c2[i]->device_name );
|
||||
@@ -527,7 +524,7 @@ void *signal_hand(void *ptr)
|
||||
|
||||
if ( c[i]->thread )
|
||||
{
|
||||
char *status;
|
||||
char *status = "";
|
||||
switch( c[i]->pass_type )
|
||||
{
|
||||
case NWIPE_PASS_FINAL_BLANK:
|
||||
|
||||
12
src/nwipe.h
12
src/nwipe.h
@@ -31,6 +31,11 @@
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#endif
|
||||
|
||||
/* workaround for Fedora */
|
||||
#ifndef off64_t
|
||||
# define off64_t off_t
|
||||
#endif
|
||||
|
||||
/* Busybox headers. */
|
||||
#ifdef BB_VER
|
||||
#include "busybox.h"
|
||||
@@ -65,12 +70,15 @@ extern int log_current_element;
|
||||
extern int log_elements_allocated;
|
||||
extern pthread_mutex_t mutex1;
|
||||
|
||||
/* Ncurses headers. Assume panel.h is in same place.*/
|
||||
/* Ncurses headers. */
|
||||
#ifdef NCURSES_IN_SUBDIR
|
||||
#include <ncurses/ncurses.h>
|
||||
#include <ncurses/panel.h>
|
||||
#else
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
#ifdef PANEL_IN_SUBDIR
|
||||
#include <ncurses/panel.h>
|
||||
#else
|
||||
#include <panel.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -42,9 +42,6 @@ int nwipe_options_parse( int argc, char** argv )
|
||||
extern nwipe_prng_t nwipe_twister;
|
||||
extern nwipe_prng_t nwipe_isaac;
|
||||
|
||||
/* The maximum banner size, including the null. */
|
||||
const int nwipe_banner_size = 81;
|
||||
|
||||
/* The getopt() result holder. */
|
||||
int nwipe_opt;
|
||||
|
||||
@@ -81,6 +78,9 @@ int nwipe_options_parse( int argc, char** argv )
|
||||
/* Whether to exit after wiping or wait for a keypress. */
|
||||
{ "nowait", no_argument, 0, 0 },
|
||||
|
||||
/* Whether to allow signals to interrupt a wipe. */
|
||||
{ "nosignals", no_argument, 0, 0 },
|
||||
|
||||
/* Whether to exit after wiping or wait for a keypress. */
|
||||
{ "nogui", no_argument, 0, 0 },
|
||||
|
||||
@@ -97,15 +97,6 @@ int nwipe_options_parse( int argc, char** argv )
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
/* Note that COLS isn't available until ncurses is initialized. */
|
||||
nwipe_options.banner = malloc( nwipe_banner_size );
|
||||
|
||||
/* Set the default product banner. */
|
||||
/* TODO: Add version constant. */
|
||||
strncpy ( nwipe_options.banner, program_name, nwipe_banner_size);
|
||||
strncat ( nwipe_options.banner, " ", nwipe_banner_size - strlen (nwipe_options.banner) - 1);
|
||||
strncat ( nwipe_options.banner, version_string, nwipe_banner_size - strlen (nwipe_options.banner) - 1);
|
||||
strncat ( nwipe_options.banner, " (based on DBAN's dwipe - Darik's Wipe)", nwipe_banner_size - strlen (nwipe_options.banner) - 1);
|
||||
|
||||
/* Set default options. */
|
||||
nwipe_options.autonuke = 0;
|
||||
@@ -114,6 +105,7 @@ int nwipe_options_parse( int argc, char** argv )
|
||||
nwipe_options.rounds = 1;
|
||||
nwipe_options.noblank = 0;
|
||||
nwipe_options.nowait = 0;
|
||||
nwipe_options.nosignals= 0;
|
||||
nwipe_options.nogui = 0;
|
||||
nwipe_options.sync = 0;
|
||||
nwipe_options.verify = NWIPE_VERIFY_LAST;
|
||||
@@ -151,6 +143,12 @@ int nwipe_options_parse( int argc, char** argv )
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "nosignals" ) == 0 )
|
||||
{
|
||||
nwipe_options.nosignals = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "nogui" ) == 0 )
|
||||
{
|
||||
nwipe_options.nogui = 1;
|
||||
@@ -276,7 +274,7 @@ int nwipe_options_parse( int argc, char** argv )
|
||||
|| nwipe_options.rounds < 1
|
||||
)
|
||||
{
|
||||
fprintf( stderr, "Error: The rounds argument must be a postive integer.\n" );
|
||||
fprintf( stderr, "Error: The rounds argument must be a positive integer.\n" );
|
||||
exit( EINVAL );
|
||||
}
|
||||
|
||||
@@ -332,12 +330,17 @@ void nwipe_options_log( void )
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " do not wait for a key before exiting" );
|
||||
}
|
||||
|
||||
if( nwipe_options.nosignals )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " do not allow signals to interrupt a wipe" );
|
||||
}
|
||||
|
||||
if( nwipe_options.nogui )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " do not show GUI interface" );
|
||||
}
|
||||
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " banner = %s", nwipe_options.banner );
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " banner = %s", banner );
|
||||
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 );
|
||||
@@ -394,6 +397,7 @@ display_help()
|
||||
puts(" -r, --rounds=NUM Number of times to wipe the device using the selected method (default: 1)" );
|
||||
puts(" --noblank Do not blank disk after wipe (default is to complete a final blank pass)" );
|
||||
puts(" --nowait Do not wait for a key before exiting (default is to wait)" );
|
||||
puts(" --nosignals Do not allow signals to interrupt a wipe (default is to allow)" );
|
||||
puts(" --nogui Do not show the GUI interface. Automatically invokes the nowait option" );
|
||||
puts(" Must be used with --autonuke option. Send SIGUSR1 to log current stats");
|
||||
puts("");
|
||||
|
||||
@@ -48,8 +48,9 @@ typedef struct /* nwipe_options_t */
|
||||
{
|
||||
int autonuke; /* Do not prompt the user for confirmation when set. */
|
||||
int noblank; /* Do not perform a final blanking pass. */
|
||||
int nowait; /* Do not wait for a final key before exiting. */
|
||||
int nogui ; /* Do not show the GUI. */
|
||||
int nowait; /* Do not wait for a final key before exiting. */
|
||||
int nosignals; /* Do not allow signals to interrupt a wipe. */
|
||||
int nogui ; /* Do not show the GUI. */
|
||||
char* banner; /* The product banner shown on the top line of the screen. */
|
||||
// nwipe_method_t method; /* A function pointer to the wipe method that will be used. */
|
||||
void* method; /* A function pointer to the wipe method that will be used. */
|
||||
|
||||
24
src/pass.c
24
src/pass.c
@@ -46,7 +46,7 @@ int nwipe_random_verify( nwipe_context_t* c )
|
||||
size_t blocksize;
|
||||
|
||||
/* The result buffer for calls to lseek. */
|
||||
loff_t offset;
|
||||
off64_t offset;
|
||||
|
||||
/* The input buffer. */
|
||||
char* b;
|
||||
@@ -98,7 +98,7 @@ int nwipe_random_verify( nwipe_context_t* c )
|
||||
/* Reset the pass byte counter. */
|
||||
c->pass_done = 0;
|
||||
|
||||
if( offset == (loff_t)-1 )
|
||||
if( offset == (off64_t)-1 )
|
||||
{
|
||||
nwipe_perror( errno, __FUNCTION__, "lseek" );
|
||||
nwipe_log( NWIPE_LOG_FATAL, "Unable to reset the '%s' file offset.", c->device_name );
|
||||
@@ -177,7 +177,7 @@ int nwipe_random_verify( nwipe_context_t* c )
|
||||
/* Bump the file pointer to the next block. */
|
||||
offset = lseek( c->device_fd, s, SEEK_CUR );
|
||||
|
||||
if( offset == (loff_t)-1 )
|
||||
if( offset == (off64_t)-1 )
|
||||
{
|
||||
nwipe_perror( errno, __FUNCTION__, "lseek" );
|
||||
nwipe_log( NWIPE_LOG_ERROR, "Unable to bump the '%s' file offset after a partial read.", c->device_name );
|
||||
@@ -225,7 +225,7 @@ int nwipe_random_pass( NWIPE_METHOD_SIGNATURE )
|
||||
size_t blocksize;
|
||||
|
||||
/* The result buffer for calls to lseek. */
|
||||
loff_t offset;
|
||||
off64_t offset;
|
||||
|
||||
/* The output buffer. */
|
||||
char* b;
|
||||
@@ -267,7 +267,7 @@ int nwipe_random_pass( NWIPE_METHOD_SIGNATURE )
|
||||
/* Reset the pass byte counter. */
|
||||
c->pass_done = 0;
|
||||
|
||||
if( offset == (loff_t)-1 )
|
||||
if( offset == (off64_t)-1 )
|
||||
{
|
||||
nwipe_perror( errno, __FUNCTION__, "lseek" );
|
||||
nwipe_log( NWIPE_LOG_FATAL, "Unable to reset the '%s' file offset.", c->device_name );
|
||||
@@ -328,7 +328,7 @@ int nwipe_random_pass( NWIPE_METHOD_SIGNATURE )
|
||||
/* Bump the file pointer to the next block. */
|
||||
offset = lseek( c->device_fd, s, SEEK_CUR );
|
||||
|
||||
if( offset == (loff_t)-1 )
|
||||
if( offset == (off64_t)-1 )
|
||||
{
|
||||
nwipe_perror( errno, __FUNCTION__, "lseek" );
|
||||
nwipe_log( NWIPE_LOG_ERROR, "Unable to bump the '%s' file offset after a partial write.", c->device_name );
|
||||
@@ -388,7 +388,7 @@ int nwipe_static_verify( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern )
|
||||
size_t blocksize;
|
||||
|
||||
/* The result buffer for calls to lseek. */
|
||||
loff_t offset;
|
||||
off64_t offset;
|
||||
|
||||
/* The input buffer. */
|
||||
char* b;
|
||||
@@ -470,7 +470,7 @@ int nwipe_static_verify( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern )
|
||||
/* Reset the pass byte counter. */
|
||||
c->pass_done = 0;
|
||||
|
||||
if( offset == (loff_t)-1 )
|
||||
if( offset == (off64_t)-1 )
|
||||
{
|
||||
nwipe_perror( errno, __FUNCTION__, "lseek" );
|
||||
nwipe_log( NWIPE_LOG_FATAL, "Unable to reset the '%s' file offset.", c->device_name );
|
||||
@@ -534,7 +534,7 @@ int nwipe_static_verify( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern )
|
||||
/* Bump the file pointer to the next block. */
|
||||
offset = lseek( c->device_fd, s, SEEK_CUR );
|
||||
|
||||
if( offset == (loff_t)-1 )
|
||||
if( offset == (off64_t)-1 )
|
||||
{
|
||||
nwipe_perror( errno, __FUNCTION__, "lseek" );
|
||||
nwipe_log( NWIPE_LOG_ERROR, "Unable to bump the '%s' file offset after a partial read.", c->device_name );
|
||||
@@ -587,7 +587,7 @@ int nwipe_static_pass( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern )
|
||||
size_t blocksize;
|
||||
|
||||
/* The result buffer for calls to lseek. */
|
||||
loff_t offset;
|
||||
off64_t offset;
|
||||
|
||||
/* The output buffer. */
|
||||
char* b;
|
||||
@@ -638,7 +638,7 @@ int nwipe_static_pass( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern )
|
||||
/* Reset the pass byte counter. */
|
||||
c->pass_done = 0;
|
||||
|
||||
if( offset == (loff_t)-1 )
|
||||
if( offset == (off64_t)-1 )
|
||||
{
|
||||
nwipe_perror( errno, __FUNCTION__, "lseek" );
|
||||
nwipe_log( NWIPE_LOG_FATAL, "Unable to reset the '%s' file offset.", c->device_name );
|
||||
@@ -697,7 +697,7 @@ int nwipe_static_pass( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern )
|
||||
/* Bump the file pointer to the next block. */
|
||||
offset = lseek( c->device_fd, s, SEEK_CUR );
|
||||
|
||||
if( offset == (loff_t)-1 )
|
||||
if( offset == (off64_t)-1 )
|
||||
{
|
||||
nwipe_perror( errno, __FUNCTION__, "lseek" );
|
||||
nwipe_log( NWIPE_LOG_ERROR, "Unable to bump the '%s' file offset after a partial write.", c->device_name );
|
||||
|
||||
38
src/prng.c
38
src/prng.c
@@ -25,6 +25,7 @@
|
||||
#include "mt19937ar-cok.h"
|
||||
#include "isaac_rand.h"
|
||||
|
||||
|
||||
nwipe_prng_t nwipe_twister =
|
||||
{
|
||||
"Mersenne Twister (mt19937ar-cok)",
|
||||
@@ -40,6 +41,25 @@ nwipe_prng_t nwipe_isaac =
|
||||
};
|
||||
|
||||
|
||||
/* Print given number of bytes from unsigned integer number to a byte stream buffer starting with low-endian*/
|
||||
int nwipe_u32tobuffer(u8 *buffer, u32 rand, int len)
|
||||
{
|
||||
int i;
|
||||
u8 c; //single char
|
||||
if (len > sizeof(u32))
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_FATAL, "Tried to print longer number than the value passed." );
|
||||
len = sizeof(u32);
|
||||
}
|
||||
|
||||
for (i=0 ; i < len; i++)
|
||||
{
|
||||
c=rand & 0xFFUL;
|
||||
rand = rand >> 8;
|
||||
buffer[i]=c;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nwipe_twister_init( NWIPE_PRNG_INIT_SIGNATURE )
|
||||
{
|
||||
@@ -54,21 +74,23 @@ int nwipe_twister_init( NWIPE_PRNG_INIT_SIGNATURE )
|
||||
|
||||
int nwipe_twister_read( NWIPE_PRNG_READ_SIGNATURE )
|
||||
{
|
||||
u32 i=0;
|
||||
u32 ii;
|
||||
u32 words = count / sizeof( u32 );
|
||||
u32 remain = count % sizeof( u32 );
|
||||
u32 words = count / SIZE_OF_TWISTER ; // the values of twister_genrand_int32 is strictly 4 bytes
|
||||
u32 remain = count % SIZE_OF_TWISTER ; // the values of twister_genrand_int32 is strictly 4 bytes
|
||||
|
||||
/* Twister returns 4-bytes per call, so cast the buffer into words. */
|
||||
/* Twister returns 4-bytes per call, so progress by 4 bytes. */
|
||||
for( ii = 0; ii < words; ++ii )
|
||||
{
|
||||
((u32*)buffer)[ii] = twister_genrand_int32( (twister_state_t*)*state );
|
||||
nwipe_u32tobuffer((u8*)(buffer+i), twister_genrand_int32( (twister_state_t*)*state ), SIZE_OF_TWISTER) ;
|
||||
i = i + SIZE_OF_TWISTER;
|
||||
}
|
||||
|
||||
/* Fill the buffer tail if the count is not evenly divided by the size of u32. */
|
||||
for( ii = 1; ii <= remain; ++ii )
|
||||
/* If there is some remainder copy only relevant number of bytes to not
|
||||
* overflow the buffer. */
|
||||
if ( remain > 0 )
|
||||
{
|
||||
/* Notice how three bytes are discarded by doing this. */
|
||||
((u8*)buffer)[count-ii] = twister_genrand_int32( (twister_state_t*)*state );
|
||||
nwipe_u32tobuffer((u8*)(buffer+i), twister_genrand_int32( (twister_state_t*)*state ), remain) ;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -51,6 +51,10 @@ int nwipe_twister_read( NWIPE_PRNG_READ_SIGNATURE );
|
||||
int nwipe_isaac_init( NWIPE_PRNG_INIT_SIGNATURE );
|
||||
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
|
||||
|
||||
|
||||
#endif /* PRNG_H_ */
|
||||
|
||||
/* eof */
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
* used by configure to dynamically assign those values
|
||||
* to documentation files.
|
||||
*/
|
||||
const char *version_string = "0.16";
|
||||
const char *version_string = "0.22";
|
||||
const char *program_name = "nwipe";
|
||||
const char *author_name = "Andy Beverley";
|
||||
const char *email_address = "andy@andybev.com";
|
||||
const char *years = "2012";
|
||||
const char *author_name = "Martijn van Brummelen";
|
||||
const char *email_address = "git@brumit.nl";
|
||||
const char *years = "2017";
|
||||
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.22 (based on DBAN's dwipe - Darik's Wipe)";
|
||||
|
||||
@@ -6,5 +6,6 @@ extern char *program_name;
|
||||
extern char *author_name;
|
||||
extern char *email_address;
|
||||
extern char *copyright;
|
||||
extern char *banner;
|
||||
|
||||
#endif/*__VERSION_H*/
|
||||
|
||||
Reference in New Issue
Block a user