* src/commandline.c:
Fix ShuffleCrypt.
* src/shacrypt.glade:
Fix various UI bugs.
* src/gui.c:
Add ShuffleCrypt support.
* tests/t3.sh:
Fix a logic error.
http://code.google.com/p/shacrypt/source/detail?r=f56d135502
Modified:
/ChangeLog
/src/Makefile.am
/src/Makefile.in
/src/commandline.c
/src/gui.c
/src/shacrypt.c
/src/shacrypt.glade
/src/shacrypt.h
/tests/t3.sh
=======================================
--- /ChangeLog Sat Mar 13 08:49:22 2010
+++ /ChangeLog Sat Mar 20 12:15:42 2010
@@ -1,3 +1,20 @@
+2010-03-20 Nightgunner5 <nightg...@llamaslayers.net>
+
+ * src/Makefile.am, src/Makefile.in:
+ Add support for @URL@ in the Glade file.
+
+ * src/commandline.c:
+ Fix ShuffleCrypt.
+
+ * src/shacrypt.glade:
+ Fix various UI bugs.
+
+ * src/gui.c:
+ Add ShuffleCrypt support.
+
+ * tests/t3.sh:
+ Fix a logic error.
+
2010-03-13 Nightgunner5 <nightg...@llamaslayers.net>
* src/commandline.c:
=======================================
--- /src/Makefile.am Sat Feb 27 20:17:00 2010
+++ /src/Makefile.am Sat Mar 20 12:15:42 2010
@@ -12,7 +12,6 @@
bin_PROGRAMS = shacrypt
shacrypt_SOURCES = commandline.c shacrypt.h
shacrypt_LDADD = libshacrypt.a
-shacrypt_CPPFLAGS = -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib
if WANT_GUI
bin_PROGRAMS += shacrypt-gui$(EXEEXT)
@@ -22,7 +21,8 @@
CLEANFILES = glade.h
glade.h: shacrypt.glade glade.sed Makefile
- $(SED) -f $(srcdir)/glade.sed -e 's/[@]VERSION[@]/$(VERSION)/g' <
$(srcdir)/shacrypt.glade > glade.h
+ $(SED) -f $(srcdir)/glade.sed -e 's/[@]VERSION[@]/$(VERSION)/g'
-e 's,[@]URL[@],$(PACKAGE_URL),g' \
+ < $(srcdir)/shacrypt.glade > glade.h
shacrypt-gui.rc: shacrypt-gui.rc.in Makefile
$(SED) -e 's/[@]VERSION[@]/$(VERSION)/g'
-e 's/[@]COMMAVERSION[@]/$(COMMAVERSION)/' \
=======================================
--- /src/Makefile.in Sat Feb 27 20:17:00 2010
+++ /src/Makefile.in Sat Mar 20 12:15:42 2010
@@ -88,7 +88,7 @@
third-party/libshacrypt_a-whirlpool.$(OBJEXT)
libshacrypt_a_OBJECTS = $(am_libshacrypt_a_OBJECTS)
PROGRAMS = $(bin_PROGRAMS)
-am_shacrypt_OBJECTS = shacrypt-commandline.$(OBJEXT)
+am_shacrypt_OBJECTS = commandline.$(OBJEXT)
shacrypt_OBJECTS = $(am_shacrypt_OBJECTS)
shacrypt_DEPENDENCIES = libshacrypt.a
am_shacrypt_gui_OBJECTS = shacrypt_gui-gui.$(OBJEXT)
@@ -230,7 +230,6 @@
libshacrypt_a_CFLAGS = $(DWINDOWS) $(AM_CFLAGS)
shacrypt_SOURCES = commandline.c shacrypt.h
shacrypt_LDADD = libshacrypt.a
-shacrypt_CPPFLAGS = -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib
BUILT_SOURCES = glade.h
CLEANFILES = glade.h
SUFFIXES = .rc
@@ -399,8 +398,8 @@
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/commandline.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/libshacrypt_a-shacrypt.Po@am__quote@
-@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/shacrypt-commandline.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/shacrypt_gui-gui.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@third-party/$(DEPDIR)/libshacrypt_a-cubehash.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@third-party/$(DEPDIR)/libshacrypt_a-md5c.Po@am__quote@
@@ -508,20 +507,6 @@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp)
@AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
$(AM_CPPFLAGS) $(CPPFLAGS) $(libshacrypt_a_CFLAGS) $(CFLAGS) -c -o
third-party/libshacrypt_a-whirlpool.obj `if test
-f 'third-party/whirlpool.c'; then $(CYGPATH_W) 'third-party/whirlpool.c';
else $(CYGPATH_W) '$(srcdir)/third-party/whirlpool.c'; fi`
-shacrypt-commandline.o: commandline.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
$(shacrypt_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT
shacrypt-commandline.o -MD -MP -MF $(DEPDIR)/shacrypt-commandline.Tpo -c -o
shacrypt-commandline.o `test -f 'commandline.c' ||
echo '$(srcdir)/'`commandline.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/shacrypt-commandline.Tpo
$(DEPDIR)/shacrypt-commandline.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='commandline.c'
object='shacrypt-commandline.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp)
@AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
$(shacrypt_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o
shacrypt-commandline.o `test -f 'commandline.c' ||
echo '$(srcdir)/'`commandline.c
-
-shacrypt-commandline.obj: commandline.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
$(shacrypt_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT
shacrypt-commandline.obj -MD -MP -MF $(DEPDIR)/shacrypt-commandline.Tpo -c
-o shacrypt-commandline.obj `if test -f 'commandline.c'; then
$(CYGPATH_W) 'commandline.c'; else $(CYGPATH_W) '$(srcdir)/commandline.c';
fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/shacrypt-commandline.Tpo
$(DEPDIR)/shacrypt-commandline.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='commandline.c'
object='shacrypt-commandline.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp)
@AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
$(shacrypt_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o
shacrypt-commandline.obj `if test -f 'commandline.c'; then
$(CYGPATH_W) 'commandline.c'; else $(CYGPATH_W) '$(srcdir)/commandline.c';
fi`
-
shacrypt_gui-gui.o: gui.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
$(AM_CPPFLAGS) $(CPPFLAGS) $(shacrypt_gui_CFLAGS) $(CFLAGS) -MT
shacrypt_gui-gui.o -MD -MP -MF $(DEPDIR)/shacrypt_gui-gui.Tpo -c -o
shacrypt_gui-gui.o `test -f 'gui.c' || echo '$(srcdir)/'`gui.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/shacrypt_gui-gui.Tpo
$(DEPDIR)/shacrypt_gui-gui.Po
@@ -766,7 +751,8 @@
glade.h: shacrypt.glade glade.sed Makefile
- $(SED) -f $(srcdir)/glade.sed -e 's/[@]VERSION[@]/$(VERSION)/g' <
$(srcdir)/shacrypt.glade > glade.h
+ $(SED) -f $(srcdir)/glade.sed -e 's/[@]VERSION[@]/$(VERSION)/g'
-e 's,[@]URL[@],$(PACKAGE_URL),g' \
+ < $(srcdir)/shacrypt.glade > glade.h
shacrypt-gui.rc: shacrypt-gui.rc.in Makefile
$(SED) -e 's/[@]VERSION[@]/$(VERSION)/g'
-e 's/[@]COMMAVERSION[@]/$(COMMAVERSION)/' \
=======================================
--- /src/commandline.c Sat Mar 13 14:09:52 2010
+++ /src/commandline.c Sat Mar 20 12:15:42 2010
@@ -129,8 +129,9 @@
unsigned char fbuf[256] = {0},
ibuf[256] = {0},
obuf[256] = {0},
- algos = '\0',
- scramblekey[256] = {0};
+ randkey[256] = {0},
+ scramblekey[256] = {0},
+ algos = '\0';
SHACrypt_Context s;
if ( strlen( argv[1] ) > 1 ) {
@@ -188,25 +189,26 @@
o = stdout;
}
- n = SHACrypt_GetRand( algos, fbuf );
-
- SHACrypt_Init( &s, argv[2], strlen( argv[2] ), algos, fbuf, n );
-
- fwrite( identifier, 1, 3, o ); // Identifier
- fwrite( "\3\0", 1, 2, o ); // Format version
- fputc( (unsigned char)(n - 1), o ); // Random seed length
- fwrite( fbuf, 1, n, o ); // Random seed
- fputc( algos, o ); // Hash alogithms used
+ n = SHACrypt_GetRand( algos, randkey );
+
+ SHACrypt_Init( &s, argv[2], strlen( argv[2] ), algos, randkey, n );
+
+ fwrite( identifier, 1, 3, o ); // Identifier
+ fwrite( "\3\0", 1, 2, o ); // Format version
+ fputc( (unsigned char)( n - 1 ), o ); // Random seed length
+ fwrite( randkey, 1, n, o ); // Random seed
+ fputc( algos, o ); // Hash alogithms used
n = SHACrypt_GetRand( algos, scramblekey );
- SHACrypt_SetScramble( &s, scramblekey, n );
/* We need to also encrypt the scramble key */
- fbuf[0] = (unsigned char)(n - 1);
+ fbuf[0] = (unsigned char)( n - 1 );
SHACrypt_Process( &s, fbuf, obuf, 1 );
- fwrite( obuf, 1, 1, o ); // Scramble key length
+ fputc( obuf[0], o ); // Scramble key length
SHACrypt_Process( &s, scramblekey, obuf, n );
- fwrite( obuf, 1, n, o ); // Scramble key
+ fwrite( obuf, 1, n, o ); // Scramble key
+
+ SHACrypt_SetScramble( &s, scramblekey, n );
/* Do the actual encryption */
while ( ( n = fread( fbuf, 1, 256, f ) ) > 0 ) {
@@ -224,6 +226,7 @@
unsigned char fbuf[256] = {0},
ibuf[256] = {0},
obuf[256] = {0},
+ randkey[256] = {0},
scramblekey[256] = {0},
algos,
randlen,
@@ -251,17 +254,17 @@
test( strncmp( fbuf, identifier, 3 ), "SHACrypt File Identifier" );
if ( fbuf[3] == '\1' && fbuf[4] == '\0' ) {
randlen = '\x13';
- fread( fbuf, 1, 20, f );
+ fread( randkey, 1, 20, f );
algos = '\x01';
version = 2;
} else if ( fbuf[3] == '\2' && fbuf[4] == '\0' ) {
randlen = fgetc( f );
- fread( fbuf, 1, (int)randlen + 1, f );
+ fread( randkey, 1, (int)randlen + 1, f );
algos = fgetc( f );
version = 2;
} else if ( fbuf[3] == '\3' && fbuf[4] == '\0' ) {
randlen = fgetc( f );
- fread( fbuf, 1, (int)randlen + 1, f );
+ fread( randkey, 1, (int)randlen + 1, f );
algos = fgetc( f );
version = 3;
} else {
@@ -269,11 +272,11 @@
exit( 1 );
}
- SHACrypt_Init( &s, argv[2], strlen( argv[2] ), algos, fbuf,
(int)randlen + 1 );
+ SHACrypt_Init( &s, argv[2], strlen( argv[2] ), algos, randkey,
(int)randlen + 1 );
/* Get the scramble key */
if ( version >= 3 ) {
- n = fread( fbuf, 1, 1, f );
+ fbuf[0] = fgetc( f );
SHACrypt_Process( &s, fbuf, obuf, 1 );
scramblelen = obuf[0];
@@ -285,9 +288,12 @@
/* Do the actual decryption */
while ( ( n = fread( fbuf, 1, 256, f ) ) > 0 ) {
- if ( version >= 3 )
- SHACrypt_Unscramble( &s, fbuf, ibuf, n );
- SHACrypt_Process( &s, ibuf, obuf, n );
+ if ( version >= 3 ) {
+ SHACrypt_Process( &s, fbuf, ibuf, n );
+ SHACrypt_Unscramble( &s, ibuf, obuf, n );
+ } else {
+ SHACrypt_Process( &s, fbuf, obuf, n );
+ }
fwrite( obuf, 1, n, o );
}
@@ -331,12 +337,12 @@
int n;
FILE *f,
*o;
- static char fbuf[256] = {0},
- obuf[256] = {0};
SHACrypt_Context s;
unsigned char algos,
randlen,
- *version;
+ *version,
+ fbuf[256] = {0},
+ obuf[256] = {0};
if ( argc > 3 ) {
f = fopen( argv[3], "rb");
=======================================
--- /src/gui.c Sat Mar 13 14:09:52 2010
+++ /src/gui.c Sat Mar 20 12:15:42 2010
@@ -197,14 +197,14 @@
G_MODULE_EXPORT unsigned char encrypt_step2_get_algos() {
unsigned char algos = '\0';
- GtkToggleButton* sha1;
- GtkToggleButton* sha224;
- GtkToggleButton* sha256;
- GtkToggleButton* sha384;
- GtkToggleButton* sha512;
- GtkToggleButton* md5;
- GtkToggleButton* cubehash;
- GtkToggleButton* whirlpool;
+ GtkToggleButton *sha1,
+ *sha224,
+ *sha256,
+ *sha384,
+ *sha512,
+ *md5,
+ *cubehash,
+ *whirlpool;
sha1 = GTK_TOGGLE_BUTTON( gtk_builder_get_object(
builder, "check_e2_sha1" ) );
sha224 = GTK_TOGGLE_BUTTON( gtk_builder_get_object(
builder, "check_e2_sha224" ) );
@@ -262,11 +262,11 @@
}
G_MODULE_EXPORT void encrypt_step3() {
- GtkWindow* step3;
- GtkEntry* pass;
- GtkFileChooser* file;
- GtkProgressBar* progress;
- GtkRange* seedlen;
+ GtkWindow *step3;
+ GtkEntry *pass;
+ GtkFileChooser *file;
+ GtkProgressBar *progress;
+ GtkRange *seedlen;
step3 = GTK_WINDOW( gtk_builder_get_object( builder, "encrypt_step3" )
);
pass = GTK_ENTRY( gtk_builder_get_object(
builder, "field_e2_password1" ) );
@@ -274,19 +274,25 @@
progress = GTK_PROGRESS_BAR( gtk_builder_get_object(
builder, "progressbar_e3_progress" ) );
seedlen = GTK_RANGE( gtk_builder_get_object(
builder, "hscale_e2_randomseed" ) );
+ gdk_threads_enter();
gtk_progress_bar_set_text( progress, NULL );
gtk_window_set_deletable( step3, FALSE );
-
- FILE* f;
- FILE* o;
+ gdk_threads_leave();
+
+ FILE *f,
+ *o;
unsigned long i, n,
- size;
+ size;
SHACrypt_Context s;
- unsigned char algos = encrypt_step2_get_algos();
- static char fbuf[256] = {0},
- obuf[256] = {0},
- tmp[1024] = {0};
- char* filename;
+ unsigned char algos = encrypt_step2_get_algos(),
+ fbuf[256] = {0},
+ ibuf[256] = {0},
+ obuf[256] = {0},
+ randkey[256] = {0},
+ scramblekey[256] = {0},
+ percentage[8] = {0},
+ *tmp,
+ *filename;
filename = gtk_file_chooser_get_filename( file );
@@ -294,28 +300,39 @@
f = fopen( filename, "rb" );
- sprintf( tmp, "%s.shacrypt", filename );
+ tmp = g_strdup_printf( "%s.shacrypt", filename );
i = 0;
while ( ( o = fopen( tmp, "rb" ) ) != NULL ) {
fclose( o );
+ g_free( tmp );
i++;
- sprintf( tmp, "%s_%lu.shacrypt", filename, i );
+ tmp = g_strdup_printf( "%s_%lu.shacrypt", filename, i );
}
o = fopen( tmp, "wb" );
-
- for ( i = 0; i < n; i++ )
- fbuf[i] = g_random_int_range( 0, 255 );
-
- SHACrypt_Init( &s, (char*)gtk_entry_get_text( pass ),
gtk_entry_get_text_length( pass ), algos, fbuf, n );
+ g_free( tmp );
+
+ SHACrypt_GenRand( randkey, n );
+
+ SHACrypt_Init( &s, (char*)gtk_entry_get_text( pass ),
gtk_entry_get_text_length( pass ), algos, randkey, n );
fwrite( identifier, 1, 3, o ); // Identifier
- fwrite( "\2\0", 1, 2, o ); // Format version
+ fwrite( "\3\0", 1, 2, o ); // Format version
fputc( (unsigned char)(n - 1), o ); // Random seed length
- fwrite( fbuf, 1, n, o ); // Random seed
+ fwrite( randkey, 1, n, o ); // Random seed
fputc( algos, o ); // Hash alogithms used
+ SHACrypt_GenRand( scramblekey, n );
+ SHACrypt_SetScramble( &s, scramblekey, n );
+
+ /* We need to also encrypt the scramble key */
+ fbuf[0] = (unsigned char)(n - 1);
+ SHACrypt_Process( &s, fbuf, obuf, 1 );
+ fwrite( obuf, 1, 1, o ); // Scramble key length
+ SHACrypt_Process( &s, scramblekey, obuf, n );
+ fwrite( obuf, 1, n, o ); // Scramble key
+
fseek( f, 0, SEEK_END );
size = ftell( f );
fseek( f, 0, SEEK_SET );
@@ -326,9 +343,14 @@
while ( ( n = fread( fbuf, 1, 256, f ) ) > 0 ) {
i += n;
+ gdk_threads_enter();
+ sprintf( percentage, "%.2f%%", (double)i / size * 100 );
+ gtk_progress_bar_set_text( progress, percentage );
gtk_progress_bar_set_fraction( progress, (double)i / size );
-
- SHACrypt_Process( &s, fbuf, obuf, n );
+ gdk_threads_leave();
+
+ SHACrypt_Scramble( &s, fbuf, ibuf, n );
+ SHACrypt_Process( &s, ibuf, obuf, n );
fwrite( obuf, 1, n, o );
}
@@ -336,9 +358,9 @@
fclose( f );
fclose( o );
- GtkEntry* pass1;
- GtkEntry* pass2;
- GtkProgressBar* meter;
+ GtkEntry *pass1,
+ *pass2;
+ GtkProgressBar *meter;
pass1 = GTK_ENTRY( gtk_builder_get_object(
builder, "field_e2_password1" ) );
pass2 = GTK_ENTRY( gtk_builder_get_object(
builder, "field_e2_password2" ) );
@@ -350,6 +372,7 @@
gtk_progress_bar_set_fraction( meter, 0.0 );
gtk_progress_bar_set_text( progress, "Done!" );
+ gtk_progress_bar_set_fraction( progress, 1.0 );
gtk_window_set_deletable( step3, TRUE );
}
@@ -385,7 +408,7 @@
gtk_widget_show( step3 );
gtk_widget_hide( step2 );
-
+
g_thread_create( (GThreadFunc)encrypt_step3, NULL, FALSE, NULL );
} else {
GtkProgressBar* meter;
@@ -396,7 +419,7 @@
}
}
-G_MODULE_EXPORT void encrypt_step2_cancel( GtkWidget* button, gpointer
data ) {
+G_MODULE_EXPORT void encrypt_step2_cancel( GtkWidget *button, gpointer
data ) {
GtkWidget* step2;
GtkEntry* pass1;
GtkEntry* pass2;
@@ -416,15 +439,15 @@
}
/* Decryption */
-G_MODULE_EXPORT void button_pressed_decrypt( GtkWidget* button, gpointer
data ) {
+G_MODULE_EXPORT void button_pressed_decrypt( GtkWidget *button, gpointer
data ) {
GtkWidget* step1;
step1 = GTK_WIDGET( gtk_builder_get_object( builder, "decrypt_step1" )
);
gtk_widget_show( step1 );
}
-G_MODULE_EXPORT void decrypt_step1_ok( GtkWidget* button, gpointer data ) {
- GtkFileChooser* file;
+G_MODULE_EXPORT void decrypt_step1_ok( GtkWidget *button, gpointer data ) {
+ GtkFileChooser *file;
file = GTK_FILE_CHOOSER( gtk_builder_get_object(
builder, "file_d1_select" ) );
@@ -433,8 +456,8 @@
return;
// Make sure it's an SHACrypt file.
- FILE* f;
- char fbuf[5];
+ FILE *f;
+ unsigned char fbuf[5];
f = fopen( gtk_file_chooser_get_filename( file ), "rb" );
@@ -444,8 +467,8 @@
if ( f != NULL )
fclose( f );
- if ( strncmp( fbuf, identifier, 3 ) != 0 || fbuf[3] < '\1' || fbuf[3]
> '\2' || fbuf[4] != '\0' ) {
- GtkWidget* invalid_file;
+ if ( strncmp( fbuf, identifier, 3 ) != 0 || fbuf[3] < '\1' ||
fbuf[4] != '\0' ) {
+ GtkWidget *invalid_file;
invalid_file = GTK_WIDGET( gtk_builder_get_object(
builder, "decrypt_step1_error_notshacrypt" ) );
@@ -454,8 +477,18 @@
return;
}
- GtkWidget* step1;
- GtkWidget* step2;
+ if ( fbuf[3] > '\3' ) {
+ GtkWidget *new_version;
+
+ new_version = GTK_WIDGET( gtk_builder_get_object(
builder, "decrypt_step1_error_newversion" ) );
+
+ gtk_widget_show( new_version );
+
+ return;
+ }
+
+ GtkWidget *step1,
+ *step2;
step1 = GTK_WIDGET( gtk_builder_get_object( builder, "decrypt_step1" )
);
step2 = GTK_WIDGET( gtk_builder_get_object( builder, "decrypt_step2" )
);
@@ -464,46 +497,60 @@
gtk_widget_hide( step1 );
}
-G_MODULE_EXPORT void decrypt_step1_cancel( GtkWidget* button, gpointer
data ) {
- GtkWidget* step1;
+G_MODULE_EXPORT void decrypt_step1_cancel( GtkWidget *button, gpointer
data ) {
+ GtkWidget *step1;
step1 = GTK_WIDGET( gtk_builder_get_object( builder, "decrypt_step1" )
);
gtk_widget_hide( step1 );
}
-G_MODULE_EXPORT void decrypt_step1_error_ok( GtkWidget* button, gpointer
data ) {
- GtkWidget* error;
+G_MODULE_EXPORT void decrypt_step1_error1_ok( GtkWidget *button, gpointer
data ) {
+ GtkWidget *error;
error = GTK_WIDGET( gtk_builder_get_object(
builder, "decrypt_step1_error_notshacrypt" ) );
gtk_widget_hide( error );
}
+
+G_MODULE_EXPORT void decrypt_step1_error2_ok( GtkWidget *button, gpointer
data ) {
+ GtkWidget *error;
+ error = GTK_WIDGET( gtk_builder_get_object(
builder, "decrypt_step1_error_newversion" ) );
+
+ gtk_widget_hide( error );
+}
G_MODULE_EXPORT void decrypt_step3() {
- GtkWindow* step3;
- GtkEntry* pass;
- GtkFileChooser* file;
- GtkProgressBar* progress;
+ GtkWindow *step3;
+ GtkEntry *pass;
+ GtkFileChooser *file;
+ GtkProgressBar *progress;
step3 = GTK_WINDOW( gtk_builder_get_object( builder, "decrypt_step3" )
);
pass = GTK_ENTRY( gtk_builder_get_object( builder, "field_d2_password"
) );
file = GTK_FILE_CHOOSER( gtk_builder_get_object(
builder, "file_d1_select" ) );
progress = GTK_PROGRESS_BAR( gtk_builder_get_object(
builder, "progressbar_d3_progress" ) );
+ gdk_threads_enter();
gtk_progress_bar_set_text( progress, NULL );
gtk_window_set_deletable( step3, FALSE );
-
- FILE* f;
- FILE* o;
- unsigned long i, size, n;
+ gdk_threads_leave();
+
+ FILE *f,
+ *o;
+ unsigned long i, size, n, version;
SHACrypt_Context s;
unsigned char algos = '\0',
- randlen = '\0';
- static char fbuf[256] = {0},
- obuf[256] = {0};
- char** filename = g_strsplit( gtk_file_chooser_get_filename( file
), ".", -1 );
- char* filename_prefix;
- char* filename_suffix;
- char* tmp;
+ randlen = '\0',
+ fbuf[256] = {0},
+ ibuf[256] = {0},
+ obuf[256] = {0},
+ percentage[8] = {0},
+ randkey[256] = {0},
+ scramblekey[256] = {0},
+ scramblelen,
+ **filename = g_strsplit( gtk_file_chooser_get_filename(
file ), ".", -1 ),
+ *filename_prefix,
+ *filename_suffix,
+ *tmp;
f = fopen( g_strjoinv( ".", filename ), "rb" );
@@ -526,7 +573,8 @@
tmp = g_strdup_printf( "%s%s", filename_prefix, filename_suffix );
i = 0;
- while ( fopen( tmp, "rb" ) != NULL ) {
+ while ( ( o = fopen( tmp, "rb" ) ) != NULL ) {
+ fclose( o );
g_free( tmp );
i++;
tmp = g_strdup_printf( "%s_%lu%s", filename_prefix, i,
filename_suffix );
@@ -542,16 +590,24 @@
if ( fbuf[3] == '\1' ) {
randlen = '\x13';
- fread( fbuf, 1, 20, f );
+ fread( randkey, 1, 20, f );
algos = '\x01';
+ version = 2;
}
if ( fbuf[3] == '\2' ) {
randlen = fgetc( f );
- fread( fbuf, 1, (int)randlen + 1, f );
+ fread( randkey, 1, (int)randlen + 1, f );
algos = fgetc( f );
+ version = 2;
+ }
+ if ( fbuf[3] == '\3' ) {
+ randlen = fgetc( f );
+ fread( randkey, 1, (int)randlen + 1, f );
+ algos = fgetc( f );
+ version = 3;
}
- SHACrypt_Init( &s, g_strdup( gtk_entry_get_text( pass ) ),
gtk_entry_get_text_length( pass ), algos, fbuf, (int)randlen + 1 );
+ SHACrypt_Init( &s, g_strdup( gtk_entry_get_text( pass ) ),
gtk_entry_get_text_length( pass ), algos, randkey, (int)randlen + 1 );
gtk_entry_set_text( pass, "" );
@@ -559,15 +615,38 @@
fseek( f, 0, SEEK_END );
size = ftell( f ) - i;
fseek( f, i, SEEK_SET );
+
+ /* Get the scramble key */
+ if ( version >= 3 ) {
+ n = fread( fbuf, 1, 1, f );
+ size--;
+ SHACrypt_Process( &s, fbuf, obuf, 1 );
+ scramblelen = obuf[0];
+
+ n = fread( fbuf, 1, (int)scramblelen + 1, f );
+ size -= n;
+ SHACrypt_Process( &s, fbuf, scramblekey, n );
+
+ SHACrypt_SetScramble( &s, scramblekey, n );
+ }
i = 0;
/* Do the actual encryption */
while ( ( n = fread( fbuf, 1, 256, f ) ) > 0 ) {
i += n;
+ gdk_threads_enter();
+ sprintf( percentage, "%.2f%%", (double)i / size * 100 );
+ gtk_progress_bar_set_text( progress, percentage );
gtk_progress_bar_set_fraction( progress, (double)i / size );
-
- SHACrypt_Process( &s, fbuf, obuf, n );
+ gdk_threads_leave();
+
+ if ( version >= 3 ) {
+ SHACrypt_Process( &s, fbuf, ibuf, n );
+ SHACrypt_Unscramble( &s, ibuf, obuf, n );
+ } else {
+ SHACrypt_Process( &s, fbuf, obuf, n );
+ }
fwrite( obuf, 1, n, o );
}
@@ -576,6 +655,7 @@
fclose( o );
gtk_progress_bar_set_text( progress, "Done!" );
+ gtk_progress_bar_set_fraction( progress, 1.0 );
gtk_window_set_deletable( step3, TRUE );
}
@@ -590,8 +670,8 @@
return;
}
- GtkWidget* step2;
- GtkWidget* step3;
+ GtkWidget *step2,
+ *step3;
step2 = GTK_WIDGET( gtk_builder_get_object( builder, "decrypt_step2" )
);
step3 = GTK_WIDGET( gtk_builder_get_object( builder, "decrypt_step3" )
);
@@ -602,9 +682,9 @@
g_thread_create( (GThreadFunc)decrypt_step3, NULL, FALSE, NULL );
}
-G_MODULE_EXPORT void decrypt_step2_cancel( GtkWidget* button, gpointer
data ) {
- GtkWidget* step2;
- GtkEntry* pass;
+G_MODULE_EXPORT void decrypt_step2_cancel( GtkWidget *button, gpointer
data ) {
+ GtkWidget *step2;
+ GtkEntry *pass;
step2 = GTK_WIDGET( gtk_builder_get_object( builder, "decrypt_step2" )
);
pass = GTK_ENTRY( gtk_builder_get_object( builder, "field_d2_password"
) );
@@ -614,22 +694,36 @@
}
/* Asymmetric */
-G_MODULE_EXPORT void button_pressed_asymmetric( GtkWidget* button,
gpointer data ) {
- GtkWidget* step1;
+G_MODULE_EXPORT void button_pressed_asymmetric( GtkWidget *button,
gpointer data ) {
+ GtkWidget *step1;
step1 = GTK_WIDGET( gtk_builder_get_object(
builder, "asymmetric_step1" ) );
gtk_widget_show( step1 );
}
-G_MODULE_EXPORT void asymmetric_step1_cancel( GtkWidget* button, gpointer
data ) {
- GtkWidget* step1;
+G_MODULE_EXPORT void asymmetric_step1_cancel( GtkWidget *button, gpointer
data ) {
+ GtkWidget *step1;
step1 = GTK_WIDGET( gtk_builder_get_object(
builder, "asymmetric_step1" ) );
gtk_widget_hide( step1 );
}
-G_MODULE_EXPORT void asymmetric_step1_ok( GtkWidget* button, gpointer data
) {
- GtkFileChooser* file;
+G_MODULE_EXPORT void asymmetric_step1_error1_ok( GtkWidget *button,
gpointer data ) {
+ GtkWidget *error;
+ error = GTK_WIDGET( gtk_builder_get_object(
builder, "asymmetric_step1_error_notshacrypt" ) );
+
+ gtk_widget_hide( error );
+}
+
+G_MODULE_EXPORT void asymmetric_step1_error2_ok( GtkWidget *button,
gpointer data ) {
+ GtkWidget *error;
+ error = GTK_WIDGET( gtk_builder_get_object(
builder, "asymmetric_step1_error_newversion" ) );
+
+ gtk_widget_hide( error );
+}
+
+G_MODULE_EXPORT void asymmetric_step1_ok( GtkWidget *button, gpointer data
) {
+ GtkFileChooser *file;
file = GTK_FILE_CHOOSER( gtk_builder_get_object(
builder, "file_a1_select" ) );
@@ -638,7 +732,7 @@
return;
// Make sure it's an SHACrypt file.
- FILE* f;
+ FILE *f;
char fbuf[5];
f = fopen( gtk_file_chooser_get_filename( file ), "rb" );
@@ -650,8 +744,8 @@
fclose( f );
}
- if ( strncmp( fbuf, identifier, 3 ) != 0 || fbuf[3] < '\1' || fbuf[3]
> '\2' || fbuf[4] != '\0' ) {
- GtkWidget* invalid_file;
+ if ( strncmp( fbuf, identifier, 3 ) != 0 || fbuf[3] < '\1' ||
fbuf[4] != '\0' ) {
+ GtkWidget *invalid_file;
invalid_file = GTK_WIDGET( gtk_builder_get_object(
builder, "asymmetric_step1_error_notshacrypt" ) );
@@ -659,6 +753,16 @@
return;
}
+
+ if ( fbuf[3] > '\3' ) {
+ GtkWidget *new_version;
+
+ new_version = GTK_WIDGET( gtk_builder_get_object(
builder, "asymmetric_step1_error_newversion" ) );
+
+ gtk_widget_show( new_version );
+
+ return;
+ }
// Now on to the actual displaying part.
GtkWidget* step1;
@@ -763,29 +867,35 @@
}
G_MODULE_EXPORT void asymmetric_step3() {
- GtkWindow* step3;
- GtkEntry* pass;
- GtkFileChooser* file;
- GtkProgressBar* progress;
+ GtkWindow *step3;
+ GtkEntry *pass,
+ *pass2;
+ GtkFileChooser *file;
+ GtkProgressBar *progress;
step3 = GTK_WINDOW( gtk_builder_get_object(
builder, "asymmetric_step3" ) );
pass = GTK_ENTRY( gtk_builder_get_object(
builder, "field_a2_password1" ) );
+ pass2 = GTK_ENTRY( gtk_builder_get_object(
builder, "field_a2_password2" ) );
file = GTK_FILE_CHOOSER( gtk_builder_get_object(
builder, "file_a1_select" ) );
progress = GTK_PROGRESS_BAR( gtk_builder_get_object(
builder, "progressbar_a3_progress" ) );
+ gdk_threads_enter();
gtk_progress_bar_set_text( progress, NULL );
gtk_window_set_deletable( step3, FALSE );
-
- FILE* f;
- FILE* o;
+ gdk_threads_leave();
+
+ FILE *f,
+ *o;
unsigned long i, size, n;
SHACrypt_Context s;
unsigned char algos = '\0',
- randlen = '\0';
- static char fbuf[256] = {0},
- obuf[256] = {0};
- char* filename = gtk_file_chooser_get_filename( file );
- char* tmp;
+ randlen = '\0',
+ fbuf[256] = {0},
+ obuf[256] = {0},
+ percentage[8] = {0},
+ *filename = gtk_file_chooser_get_filename( file ),
+ *tmp,
+ *version;
f = fopen( filename, "rb" );
@@ -794,7 +904,8 @@
tmp = g_strdup_printf( "%s_1.shacrypt", filename );
i = 1;
- while ( fopen( tmp, "rb" ) != NULL ) {
+ while ( ( o = fopen( tmp, "rb" ) ) != NULL ) {
+ fclose( o );
g_free( tmp );
i++;
tmp = g_strdup_printf( "%s_%lu.shacrypt", filename, i );
@@ -811,15 +922,23 @@
randlen = '\x13';
fread( fbuf, 1, 20, f );
algos = '\x01';
+ version = "\2\0";
}
if ( fbuf[3] == '\2' ) {
randlen = fgetc( f );
fread( fbuf, 1, (int)randlen + 1, f );
algos = fgetc( f );
+ version = "\2\0";
+ }
+ if ( fbuf[3] == '\3' ) {
+ randlen = fgetc( f );
+ fread( fbuf, 1, (int)randlen + 1, f );
+ algos = fgetc( f );
+ version = "\3\0";
}
fwrite( identifier, 1, 3, o );
- fwrite( "\2\0", 1, 2, o );
+ fwrite( version, 1, 2, o );
fputc( randlen, o );
fwrite( fbuf, 1, (int)randlen + 1, o );
fputc( algos, o );
@@ -827,6 +946,7 @@
SHACrypt_Init( &s, g_strdup( gtk_entry_get_text( pass ) ),
gtk_entry_get_text_length( pass ), algos, fbuf, (int)randlen + 1 );
gtk_entry_set_text( pass, "" );
+ gtk_entry_set_text( pass2, "" );
i = ftell( f );
fseek( f, 0, SEEK_END );
@@ -838,7 +958,11 @@
while ( ( n = fread( fbuf, 1, 256, f ) ) > 0 ) {
i += n;
+ gdk_threads_enter();
+ sprintf( percentage, "%.2f%%", (double)i / size * 100 );
+ gtk_progress_bar_set_text( progress, percentage );
gtk_progress_bar_set_fraction( progress, (double)i / size );
+ gdk_threads_leave();
SHACrypt_Process( &s, fbuf, obuf, n );
@@ -849,6 +973,7 @@
fclose( o );
gtk_progress_bar_set_text( progress, "Done!" );
+ gtk_progress_bar_set_fraction( progress, 1.0 );
gtk_window_set_deletable( step3, TRUE );
}
@@ -878,6 +1003,9 @@
step2 = GTK_WIDGET( gtk_builder_get_object(
builder, "asymmetric_step2" ) );
step3 = GTK_WIDGET( gtk_builder_get_object(
builder, "asymmetric_step3" ) );
+ gtk_widget_show( step3 );
+ gtk_widget_hide( step2 );
+
g_thread_create( (GThreadFunc)asymmetric_step3, NULL, FALSE, NULL
);
} else {
GtkProgressBar* meter;
@@ -908,10 +1036,10 @@
}
int main( int argc, char** argv ) {
- GtkWidget* window;
- GtkWindow* tempwindow;
- GError* error = NULL;
- GdkPixbuf* icon;
+ GtkWidget *window;
+ GtkWindow *tempwindow;
+ GError *error = NULL;
+ GdkPixbuf *icon;
gtk_init( &argc, &argv );
=======================================
--- /src/shacrypt.c Sat Mar 13 14:09:52 2010
+++ /src/shacrypt.c Sat Mar 20 12:15:42 2010
@@ -147,7 +147,7 @@
}
void SHACrypt_Init( struct SHACrypt_Context *ctx, unsigned char *password,
unsigned int passlen,
- unsigned char algos, unsigned char *rand, unsigned
char randlen ) {
+ unsigned char algos, unsigned char *rand, unsigned int
randlen ) {
ctx->algos = algos;
ctx->password = password;
ctx->passlen = passlen;
@@ -330,7 +330,7 @@
* @since 1.2.2
* @version 1.2.2
*/
-void SHACrypt_SetScramble( SHACrypt_Context *ctx, unsigned char *code,
unsigned char len ) {
+void SHACrypt_SetScramble( SHACrypt_Context *ctx, unsigned char *code,
unsigned int len ) {
ctx->scramblekey = code;
ctx->scramblelen = len;
@@ -405,14 +405,16 @@
*/
void SHACrypt_Scramble( SHACrypt_Context* ctx, char* in, char* out,
unsigned int len ) {
unsigned int i;
- unsigned char c;
+ unsigned char c,
+ tmp,
+ buf[256] = {0};
// First pass: Just copy
for ( i = 0; i < len; i++ ) {
out[i] = in[i];
}
- // Second pass: The actual swapping
+ // Second pass: Make the buffer
for ( i = 0; i < len; i++ ) {
c = 0;
@@ -512,9 +514,15 @@
ctx->scramble_whirlpool_ptr++;
}
- out[c % len] ^= out[i];
- out[i] ^= out[c % len];
- out[c % len] ^= out[i];
+ buf[i] = c;
+ }
+
+ // Third pass: The actual swapping
+ for ( i = 0; i < len; i++ ) {
+ c = buf[i];
+ tmp = out[i];
+ out[i] = out[c % len];
+ out[c % len] = tmp;
}
}
@@ -525,7 +533,8 @@
void SHACrypt_Unscramble( SHACrypt_Context* ctx, char* in, char* out,
unsigned int len ) {
unsigned int i;
unsigned char c,
- *buf;
+ tmp,
+ buf[256] = {0};
// First pass: Just copy
for ( i = 0; i < len; i++ ) {
@@ -533,7 +542,6 @@
}
// Second pass: Make the buffer
- buf = malloc( len * sizeof( unsigned char ) );
for ( i = 0; i < len; i++ ) {
c = 0;
@@ -637,12 +645,14 @@
}
// Third pass: The actual swapping
- for ( i = len; i > -1; i-- ) {
+ for ( i = len - 1; i > 0; i-- ) {
c = buf[i];
- out[c % len] ^= out[i];
- out[i] ^= out[c % len];
- out[c % len] ^= out[i];
- }
-
- free( buf );
-}
+ tmp = out[i];
+ out[i] = out[c % len];
+ out[c % len] = tmp;
+ }
+ c = buf[0];
+ tmp = out[0];
+ out[0] = out[c % len];
+ out[c % len] = tmp;
+}
=======================================
--- /src/shacrypt.glade Sat Feb 27 09:31:24 2010
+++ /src/shacrypt.glade Sat Mar 20 12:15:42 2010
@@ -683,8 +683,8 @@
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="preview_widget_active">False</property>
- <property name="filter">filter_shacrypt_ext</property>
<property name="use_preview_label">False</property>
+ <property name="filter">filter_shacrypt_ext</property>
<signal name="file_activated" handler="decrypt_step1_ok"/>
</object>
<packing>
@@ -783,7 +783,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
- <signal name="clicked" handler="decrypt_step1_error_ok"/>
+ <signal name="clicked" handler="decrypt_step1_error1_ok"/>
</object>
<packing>
<property name="expand">False</property>
@@ -804,6 +804,57 @@
<action-widget response="0">button_d1b_ok</action-widget>
</action-widgets>
</object>
+ <object class="GtkMessageDialog" id="decrypt_step1_error_newversion">
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Error reading file</property>
+ <property name="resizable">False</property>
+ <property name="modal">True</property>
+ <property name="window_position">center-on-parent</property>
+ <property name="type_hint">notification</property>
+ <property name="skip_taskbar_hint">True</property>
+ <property name="transient_for">decrypt_step1</property>
+ <property name="message_type">error</property>
+ <property name="text" translatable="yes">File could not be
read</property>
+ <property name="secondary_text" translatable="yes">The file you
selected claims to be from a newer version of SHACrypt than the one you're
currently running.
+
+Go to the SHACrypt website at <@URL@> for new versions.</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox15">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area15">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button_d1c_ok">
+ <property name="label">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="decrypt_step1_error2_ok"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">button_d1c_ok</action-widget>
+ </action-widgets>
+ </object>
<object class="GtkDialog" id="decrypt_step2">
<property name="border_width">5</property>
<property name="title" translatable="yes">Decrypt a file (Step 2 of
3)</property>
@@ -955,6 +1006,8 @@
<property name="title" translatable="yes">Asymmetric Encryption (Step
1 of 3)</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
+ <property name="default_width">500</property>
+ <property name="default_height">400</property>
<property name="type_hint">dialog</property>
<property name="transient_for">main</property>
<property name="has_separator">False</property>
@@ -969,8 +1022,8 @@
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="preview_widget_active">False</property>
- <property name="filter">filter_shacrypt_ext</property>
<property name="use_preview_label">False</property>
+ <property name="filter">filter_shacrypt_ext</property>
<signal name="file_activated" handler="asymmetric_step1_ok"/>
</object>
<packing>
@@ -1054,6 +1107,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
+ <signal name="clicked"
handler="asymmetric_step1_error1_ok"/>
</object>
<packing>
<property name="expand">False</property>
@@ -1074,6 +1128,57 @@
<action-widget response="0">button_a1b_ok</action-widget>
</action-widgets>
</object>
+ <object class="GtkMessageDialog" id="asymmetric_step1_error_newversion">
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Error reading file</property>
+ <property name="resizable">False</property>
+ <property name="modal">True</property>
+ <property name="window_position">center-on-parent</property>
+ <property name="type_hint">notification</property>
+ <property name="skip_taskbar_hint">True</property>
+ <property name="transient_for">asymmetric_step1</property>
+ <property name="message_type">error</property>
+ <property name="text" translatable="yes">File could not be
read</property>
+ <property name="secondary_text" translatable="yes">The file you
selected claims to be from a newer version of SHACrypt than the one you're
currently running.
+
+Go to the SHACrypt website at <@URL@> for new versions.</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox17">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area17">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button_a1c_ok">
+ <property name="label">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked"
handler="asymmetric_step1_error2_ok"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">button_a1c_ok</action-widget>
+ </action-widgets>
+ </object>
<object class="GtkDialog" id="asymmetric_step2">
<property name="border_width">5</property>
<property name="title" translatable="yes">Asymmetric Encryption (Step
2 of 3)</property>
@@ -1252,6 +1357,7 @@
<property name="type_hint">dialog</property>
<property name="deletable">False</property>
<property name="transient_for">asymmetric_step2</property>
+ <signal name="delete_event" handler="gtk_widget_hide_on_delete"/>
<child>
<object class="GtkVBox" id="vbox8">
<property name="visible">True</property>
=======================================
--- /src/shacrypt.h Sat Mar 13 14:09:52 2010
+++ /src/shacrypt.h Sat Mar 20 12:15:42 2010
@@ -101,20 +101,20 @@
unsigned char algos,
*password,
*scramblekey,
- *rand,
+ *rand;
+ unsigned int passlen,
scramblelen,
randlen;
- unsigned int passlen;
} SHACrypt_Context;
int SHACrypt_GetLength( unsigned char algos );
int SHACrypt_GetRand( unsigned char algos, char *rand );
void SHACrypt_Init( SHACrypt_Context *ctx, unsigned char *password,
unsigned int passlen,
- unsigned char algos, unsigned char *rand, unsigned
char randlen );
+ unsigned char algos, unsigned char *rand, unsigned int
randlen );
void SHACrypt_Process( SHACrypt_Context *ctx, char *in, char *out,
unsigned int len );
// Added in format v3
-void SHACrypt_InitScramble( SHACrypt_Context *ctx, unsigned char *code,
unsigned char len );
+void SHACrypt_SetScramble( SHACrypt_Context *ctx, unsigned char *code,
unsigned int len );
void SHACrypt_Scramble( SHACrypt_Context *ctx, char *in, char *out,
unsigned int len );
void SHACrypt_Unscramble( SHACrypt_Context *ctx, char *in, char *out,
unsigned int len );
#endif
=======================================
--- /tests/t3.sh Sat Feb 27 09:31:24 2010
+++ /tests/t3.sh Sat Mar 20 12:15:42 2010
@@ -15,7 +15,7 @@
$SHACRYPT d test f3a.tmp f3b.tmp
result=$?
-if [[ "$result" != "0" ]]
+if [[ "$result" == "0" ]]
then cmp -s rand3.tmp f3b.tmp
result=$?
fi