*** ../secure_delete-2.2/sswap.c Sun Oct 3 19:11:51 1999 --- sswap.c Sat Feb 19 15:59:41 2000 *************** *** 29,34 **** --- 29,38 ---- #include #include + /* definitions for the Mersenne Twister*/ + void seedMT(unsigned long seed); + void blockMTxor(void * mem, size_t len); + /* SWAP_PAGESIZE is an important variable. You have to set this * to your header length of your swapdevice. For Linux this is 4096, * I don't know for the other OSs. To be sure, set this to 0 and *************** *** 51,56 **** --- 55,63 ---- char *prog; char buf[BLOCKSIZE]; int verbose; + int libcrand = 1; + int nodevrandom = 0; + int nomfmrll = 0; int fd; int slow = O_SYNC; FILE *file; *************** *** 65,70 **** --- 72,79 ---- printf("\t-f fast (and insecure mode): no /dev/urandom, no synchronize mode.\n"); printf("\t-l lessens the security (use twice for total insecure mode).\n"); printf("\t-v is verbose mode.\n"); + printf("\t-m skip passes for MFM/RLL disks, because nobody uses them\n"); + printf("\t-k do not use /dev/random to gather entropy\n"); printf("\nYou must disable the swapspace before using this program! This is *BETA*!\n"); exit(1); } *************** *** 85,92 **** int loop; if (devrandom == NULL) ! for (loop = 0; loop < BLOCKSIZE; loop++) ! buf[loop] = (unsigned char) (256.0*rand()/(RAND_MAX+1.0)); else fread(&buf, BLOCKSIZE, 1, devrandom); } --- 94,104 ---- int loop; if (devrandom == NULL) ! if(libcrand) ! for (loop = 0; loop < BLOCKSIZE; loop += 2) ! (int) buf[loop] = rand(); ! else ! blockMTxor(buf, BLOCKSIZE); else fread(&buf, BLOCKSIZE, 1, devrandom); } *************** *** 128,137 **** --- 140,153 ---- case 1 : printf("Wipe mode is insecure (two passes [0xff/random])\n"); break; default: printf("Wipe mode is secure (38 special passes)\n"); } + if(nomfmrll) + printf("skipping 28 passes for MFM and RLL disks\n"); + printf("Writing to swap device %s: ", filename); } if (slow && mode) + if(!nodevrandom) if ((devrandom = fopen(RANDOM_DEVICE, "r")) != NULL) if (verbose) printf("Using %s for random input.\n", RANDOM_DEVICE); *************** *** 157,173 **** } if ((mode < 2) && (turn > 0)) break; if ((turn>=5) && (turn<=31)) { fill_buf(write_modes[turn-5]); do {} while (fwrite(&buf, 1, BLOCKSIZE, file) == BLOCKSIZE); } else { do { random_buf(); } while (fwrite(&buf, 1, BLOCKSIZE, file) == BLOCKSIZE); - } - FLUSH; if (verbose) printf("*"); } fclose(file); if (devrandom) --- 173,193 ---- } if ((mode < 2) && (turn > 0)) break; if ((turn>=5) && (turn<=31)) { + if(!nomfmrll) { fill_buf(write_modes[turn-5]); do {} while (fwrite(&buf, 1, BLOCKSIZE, file) == BLOCKSIZE); + if (verbose) + printf("*"); + } } else { do { random_buf(); } while (fwrite(&buf, 1, BLOCKSIZE, file) == BLOCKSIZE); if (verbose) printf("*"); } + FLUSH; + } fclose(file); if (devrandom) *************** *** 202,208 **** help(); while (1) { ! result = getopt(argc, argv, "FfLlSsVv"); if (result<0) break; switch (result) { case 'F' : --- 222,228 ---- help(); while (1) { ! result = getopt(argc, argv, "FfLlSsVvMmCcKk"); if (result<0) break; switch (result) { case 'F' : *************** *** 217,222 **** --- 237,251 ---- case 'V' : case 'v' : verbose++; break; + case 'C' : + case 'c' : libcrand++; + break; + case 'K' : + case 'k' : nodevrandom++;; + break; + case 'M' : + case 'm' : nomfmrll++;; + break; default : help(); } } *************** *** 227,232 **** --- 256,277 ---- signal(SIGINT, cleanup); signal(SIGTERM, cleanup); signal(SIGHUP, cleanup); + + /* try to seed some entropy into the c library we use multiply and + modulo instead of addition or xor to get a better spreading of + our entropy in the (unsigned int) we feed to sramd(3) */ + srand((unsigned int)(((long long) getpid () * + (long long) time(0) * + (long long) getppid() * + (long long) clock()) % 0xffff)); + + /* now seed the MT. since it takes a 64 value we do not + have to do this modulo stuff */ + seedMT((long long) getpid () * + (long long) time(0) * + (long long) getppid() * + (long long) rand() * + (long long) clock()); smash_it(argv[optind], secure); /* thats all */ *** ../secure_delete-2.2/srm.c Sun Oct 3 19:11:38 1999 --- srm.c Sat Feb 19 15:44:16 2000 *************** *** 31,36 **** --- 31,39 ---- #include #include + /* definitions for the Mersenne Twister*/ + void seedMT(unsigned long seed); + void blockMTxor(void * mem, size_t len); #define RANDOM_DEVICE "/dev/urandom" /* must not exist */ #define BLOCKSIZE 32769 /* must be mod 3 = 0, should be >= 16k */ *************** *** 57,62 **** --- 60,68 ---- int slow = O_SYNC; int verbose = 0; int recursive = 0; + int libcrand = 0; + int nodevrandom = 0; + int nomfmrll = 0; void help () { printf("%s %s\n\n",prog, VERSION); *************** *** 67,72 **** --- 73,81 ---- printf("\t-d ignore the two dot special files \".\" and \"..\".\n"); printf("\t-f fast (and insecure mode): no /dev/urandom, no synchronize mode.\n"); printf("\t-l lessens the security (use twice for total insecure mode).\n"); + printf("\t-k do not use the kernel random pool\n"); + printf("\t-m do mot do MFM/RLL passes.\n"); + printf("\t-c use libc rand()\n"); printf("\t-v is verbose mode.\n"); exit(1); } *************** *** 87,94 **** int loop; if (devrandom == NULL) ! for (loop = 0; loop < bufsize; loop++) ! buf[loop] = (unsigned char) (256.0*rand()/(RAND_MAX+1.0)); else fread(&buf, bufsize, 1, devrandom); } --- 96,106 ---- int loop; if (devrandom == NULL) ! if(libcrand) ! for (loop = 0; loop < BLOCKSIZE; loop += 2) ! (int) buf[loop] = rand(); ! else ! blockMTxor(buf, BLOCKSIZE); else fread(&buf, bufsize, 1, devrandom); } *************** *** 234,253 **** rewind(f); if ((mode < 2) && (turn > 0)) break; if ((turn>=5) && (turn<=31)) { fill_buf(write_modes[turn-5]); for (counter=1; counter<=writes; counter++) fwrite(&buf, 1, bufsize, f); } else { for (counter=1; counter<=writes; counter++) { random_buf(); fwrite(&buf, 1, bufsize, f); } } fflush(f); if (fsync(file) < 0) FLUSH; - if (verbose) - printf("*"); } (void) fclose(f); --- 246,269 ---- rewind(f); if ((mode < 2) && (turn > 0)) break; if ((turn>=5) && (turn<=31)) { + if(!nomfmrll) { fill_buf(write_modes[turn-5]); for (counter=1; counter<=writes; counter++) fwrite(&buf, 1, bufsize, f); + if (verbose) + printf("*"); + } } else { for (counter=1; counter<=writes; counter++) { random_buf(); fwrite(&buf, 1, bufsize, f); + if (verbose) + printf("*"); } } fflush(f); if (fsync(file) < 0) FLUSH; } (void) fclose(f); *************** *** 276,281 **** --- 292,300 ---- newname[i] = 97+(int) (27.0*rand()/(RAND_MAX+1.0)); result = lstat(newname, &filestat); turn++; + /* on linux this doesn't help much since linux is NOT syncing + metadata on sync() */ + FLUSH; } while ((result >= 0)&&(turn<=100)); if (turn<=100) { result = rename(filename, newname); *************** *** 339,345 **** help(); while (1) { ! result = getopt(argc, argv, "DdFfLlRrSsVv"); if (result<0) break; switch (result) { case 'd' : --- 358,364 ---- help(); while (1) { ! result = getopt(argc, argv, "DdFfLlRrSsVvCcKkMm"); if (result<0) break; switch (result) { case 'd' : *************** *** 360,365 **** --- 379,393 ---- case 'V' : case 'v' : verbose++; break; + case 'C' : + case 'c' : libcrand++; + break; + case 'K' : + case 'k' : nodevrandom++;; + break; + case 'M' : + case 'm' : nomfmrll++;; + break; default : help(); } } *************** *** 371,377 **** if (BLOCKSIZE % 3 > 0) fprintf(stderr, "Warning: incompiled blocksize is not a multiple of 3!\n"); (void) setvbuf(stdout, NULL, _IONBF, 0); ! srand( (getpid()+getuid()+getgid()) ^ time(0) ); signal(SIGINT, cleanup); signal(SIGTERM, cleanup); --- 399,419 ---- if (BLOCKSIZE % 3 > 0) fprintf(stderr, "Warning: incompiled blocksize is not a multiple of 3!\n"); (void) setvbuf(stdout, NULL, _IONBF, 0); ! ! srand((unsigned int)(((long long) getpid () * ! (long long) time(0) * ! (long long) getppid() * ! (long long) clock() * ! (long long) getuid() * ! (long long) getgid()) % 0xffff)); ! ! /* now seed the MT. since it takes a 64 bit value we do not ! have to do this modulo stuff */ ! seedMT((long long) getpid () * ! (long long) time(0) * ! (long long) getppid() * ! (long long) rand() * ! (long long) clock()); signal(SIGINT, cleanup); signal(SIGTERM, cleanup); *************** *** 385,391 **** --- 427,436 ---- break; default: printf("Wipe mode is secure (38 special passes)\n"); } + if(nomfmrll) + printf("skipping 28 passes for MFM and RLL disks\n"); if (slow && secure) + if(!nodevrandom) if ((devrandom = fopen(RANDOM_DEVICE, "r")) != NULL) if (verbose) printf("Using %s for random input.\n", RANDOM_DEVICE); *** ../secure_delete-2.2/sfill.c Sun Oct 3 19:11:06 1999 --- sfill.c Sat Feb 19 15:49:04 2000 *************** *** 52,57 **** --- 52,60 ---- int slow = O_SYNC; FILE *f; FILE *devrandom = NULL; + int libcrand = 1; + int nodevrandom = 0; + int nomfmrll = 0; void help() { printf("%s %s\n\n",prog, VERSION); *************** *** 61,66 **** --- 64,72 ---- printf("Options:\n"); printf("\t-f fast (and insecure mode): no /dev/urandom, no synchronize mode.\n"); printf("\t-l lessens the security (use twice for total insecure mode).\n"); + printf("\t-k do not use the kernel random pool\n"); + printf("\t-m do mot do MFM/RLL passes.\n"); + printf("\t-c use libc rand()\n"); printf("\t-v is verbose mode.\n"); exit(1); } *************** *** 81,88 **** int loop; if (devrandom == NULL) ! for (loop = 0; loop < BLOCKSIZE; loop++) ! buf[loop] = (unsigned char) (256.0*rand()/(RAND_MAX+1.0)); else fread(&buf, BLOCKSIZE, 1, devrandom); } --- 87,97 ---- int loop; if (devrandom == NULL) ! if(libcrand) ! for (loop = 0; loop < BLOCKSIZE; loop += 2) ! (int) buf[loop] = rand(); ! else ! blockMTxor(buf, BLOCKSIZE); else fread(&buf, BLOCKSIZE, 1, devrandom); } *************** *** 122,139 **** rewind(f); if ((mode < 2) && (turn > 0)) break; if ((turn>=5) && (turn<=31)) { fill_buf(write_modes[turn-5]); do {} while (fwrite(&buf, 1, BLOCKSIZE, f) == BLOCKSIZE); } else { do { random_buf(); } while (fwrite(&buf, 1, BLOCKSIZE, f) == BLOCKSIZE); } fflush(f); fsync(file); FLUSH; - if (verbose) - printf("*"); } (void) fclose(f); --- 131,152 ---- rewind(f); if ((mode < 2) && (turn > 0)) break; if ((turn>=5) && (turn<=31)) { + if(!nomfmrll) { fill_buf(write_modes[turn-5]); do {} while (fwrite(&buf, 1, BLOCKSIZE, f) == BLOCKSIZE); + if (verbose) + printf("*"); + } } else { do { random_buf(); } while (fwrite(&buf, 1, BLOCKSIZE, f) == BLOCKSIZE); + if (verbose) + printf("*"); } fflush(f); fsync(file); FLUSH; } (void) fclose(f); *************** *** 179,185 **** help(); while (1) { ! result = getopt(argc, argv, "fFlLsSvV"); if (result<0) break; switch (result) { case 'f' : --- 192,198 ---- help(); while (1) { ! result = getopt(argc, argv, "fFlLsSvVcCmMkK"); if (result<0) break; switch (result) { case 'f' : *************** *** 194,199 **** --- 207,221 ---- case 'v' : case 'V' : verbose++; break; + case 'C' : + case 'c' : libcrand++; + break; + case 'K' : + case 'k' : nodevrandom++;; + break; + case 'M' : + case 'm' : nomfmrll++;; + break; default : help(); } } *************** *** 208,215 **** fprintf(stderr,"%s : not a directory\n",newname); } else { ! /* Generate random unique name for tempfile */ ! srand(getpid()+getuid()); if (newname[strlen(newname)-1] != DIR_SEPERATOR) { result = strlen(newname); --- 230,250 ---- fprintf(stderr,"%s : not a directory\n",newname); } else { ! /* Generate random unique name for tempfile */ ! srand((unsigned int)(((long long) getpid () * ! (long long) time(0) * ! (long long) getppid() * ! (long long) clock() * ! (long long) getuid() * ! (long long) getgid()) % 0xffff)); ! ! /* now seed the MT. since it takes a 64 bit value we do not ! have to do this modulo stuff */ ! seedMT((long long) getpid () * ! (long long) time(0) * ! (long long) getppid() * ! (long long) rand() * ! (long long) clock()); if (newname[strlen(newname)-1] != DIR_SEPERATOR) { result = strlen(newname); *************** *** 239,244 **** --- 274,280 ---- fprintf(stderr, "Warning: incompiled blocksize is not a multiple of 3!\n"); if (slow && secure) + if(!nodevrandom) if ((devrandom = fopen(RANDOM_DEVICE, "r")) != NULL) if (verbose) printf("Using %s for random input.\n", RANDOM_DEVICE); *************** *** 251,256 **** --- 287,295 ---- break; default: printf("Wipe mode is secure (38 special passes)\n"); } + if(nomfmrll) + printf("skipping 28 passes for MFM and RLL disks\n"); + printf("Wiping now ...\n"); } *** ../secure_delete-2.2/smem.c Sun Oct 3 19:11:18 1999 --- smem.c Sat Feb 19 15:56:26 2000 *************** *** 28,42 **** #include #include #define RANDOM_DEVICE "/dev/urandom" /* must not exist */ #define BLOCKSIZE 65536 char *VERSION = "v2.2 by van Hauser/THC http://www.infowar.co.uk/thc"; char *prog; char buf[BLOCKSIZE+2]; ! int verbose = 0; int slow = 1; FILE *devrandom = NULL; void help() { printf("%s %s\n\n",prog, VERSION); --- 28,49 ---- #include #include + /* definitions for the Mersenne Twister*/ + void seedMT(unsigned long seed); + void blockMTxor(void * mem, size_t len); + #define RANDOM_DEVICE "/dev/urandom" /* must not exist */ #define BLOCKSIZE 65536 char *VERSION = "v2.2 by van Hauser/THC http://www.infowar.co.uk/thc"; char *prog; char buf[BLOCKSIZE+2]; ! int nomfmrll = 0; int slow = 1; FILE *devrandom = NULL; + int verbose = 0; + int libcrand = 0; + int nodevrandom = 0; void help() { printf("%s %s\n\n",prog, VERSION); *************** *** 46,51 **** --- 53,61 ---- printf("Options:\n"); printf("\t-f fast (and insecure mode): no /dev/urandom.\n"); printf("\t-l lessens the security (use twice for total insecure mode).\n"); + printf("\t-k do not use the kernel random pool\n"); + printf("\t-m do mot do MFM/RLL passes.\n"); + printf("\t-c use libc rand()\n"); printf("\t-v is verbose mode.\n"); exit(1); } *************** *** 66,73 **** int loop; if (devrandom == NULL) ! for (loop = 0; loop < BLOCKSIZE; loop++) ! buf[loop] = (unsigned char) (256.0*rand()/(RAND_MAX+1.0)); else fread(&buf, BLOCKSIZE, 1, devrandom); } --- 76,86 ---- int loop; if (devrandom == NULL) ! if(libcrand) ! for (loop = 0; loop < BLOCKSIZE; loop += 2) ! (int) buf[loop] = rand(); ! else ! blockMTxor(buf, BLOCKSIZE); else fread(&buf, BLOCKSIZE, 1, devrandom); } *************** *** 96,104 **** --- 109,120 ---- case 1 : printf("Wipe mode is insecure (two passes [0x00/random])\n"); break; default: printf("Wipe mode is secure (38 special passes)\n"); } + if(nomfmrll) + printf("skipping 28 passes for MFM and RLL disks\n"); } if (slow && mode) + if(!nodevrandom) if ((devrandom = fopen(RANDOM_DEVICE, "r")) != NULL) if (verbose) printf("Using %s for random input.\n", RANDOM_DEVICE); *************** *** 139,144 **** --- 155,161 ---- for (turn=0; turn<=36; turn++) { if ((mode == 1) && (turn > 0)) break; if ((turn>=5) && (turn<=31)) { + if(!nomfmrll) memcpy(ptr, buffers[turn-5], BLOCKSIZE); } else { random_buf(); *************** *** 147,152 **** --- 164,170 ---- } } if (verbose && (counter > 8)) { /* every 512kb */ + if(!nomfmrll) printf("*"); counter = 0; } else counter++; *************** *** 178,184 **** help(); while (1) { ! result = getopt(argc, argv, "FfLlSsVv"); if (result<0) break; switch (result) { case 'F' : --- 196,202 ---- help(); while (1) { ! result = getopt(argc, argv, "FfLlSsVvCcKkMm"); if (result<0) break; switch (result) { case 'F' : *************** *** 193,198 **** --- 211,225 ---- case 'V' : case 'v' : verbose++; break; + case 'C' : + case 'c' : libcrand++; + break; + case 'K' : + case 'k' : nodevrandom++;; + break; + case 'M' : + case 'm' : nomfmrll++;; + break; default : help(); } } *************** *** 205,210 **** --- 232,252 ---- signal(SIGTERM, cleanup); signal(SIGHUP, cleanup); signal(SIGALRM, cleanup); + + srand((unsigned int)(((long long) getpid () * + (long long) time(0) * + (long long) getppid() * + (long long) clock() * + (long long) getuid() * + (long long) getgid()) % 0xffff)); + + /* now seed the MT. since it takes a 64 bit value we do not + have to do this modulo stuff */ + seedMT((long long) getpid () * + (long long) time(0) * + (long long) getppid() * + (long long) rand() * + (long long) clock()); smash_it(secure); *** ../secure_delete-2.2/Makefile Sun Oct 3 19:03:52 1999 --- Makefile Sat Feb 19 15:49:27 2000 *************** *** 10,26 **** @echo "I hope YOU have fun!" @echo ! srm: srm.c ! $(CC) -O2 -o srm srm.c strip srm ! sfill: sfill.c ! $(CC) -O2 -o sfill sfill.c strip sfill ! sswap: sswap.c ! $(CC) -O2 -o sswap sswap.c ! strip sswap ! smem: smem.c ! $(CC) -O2 -o smem smem.c strip smem clean: --- 10,26 ---- @echo "I hope YOU have fun!" @echo ! srm: srm.c mt19937-cokus.c ! $(CC) -O2 -o srm srm.c mt19937-cokus.c strip srm ! sfill: sfill.c mt19937-cokus.c ! $(CC) -O2 -o sfill sfill.c mt19937-cokus.c strip sfill ! sswap: sswap.c mt19937-cokus.c ! $(CC) -O2 -o sswap sswap.c mt19937-cokus.c ! # strip sswap ! smem: smem.c mt19937-cokus.c ! $(CC) -O2 -o smem smem.c mt19937-cokus.c strip smem clean: *** ../secure_delete-2.2/CHANGES Sun Oct 3 19:04:55 1999 --- CHANGES Sat Feb 19 15:36:30 2000 *************** *** 1,3 **** --- 1,14 ---- + v2.2d (Feburary 2000) + (smem/sfill/sswap) there was no entropy feed to the PNRG, fixed this + (all) changed the calls to srand() to get better entropy + (all) changed the calls to rand() to be much faster + (all) included the `Mersenne Twister' random number + generator MT19937 + (all) included -c MT use rand() instead of the MT + (all) included -k to not use /dev/random + (all) included -m to skip the MFM/RLL passes. Nobody is + using this type of Disk + v2.2 (October 1999) (WWW) ugh, the redirector service base.org is down! WWW site: http://www.infowar.co.uk/thc