[shacrypt] push by Nightgunner5 - * src/commandline.c:... on 2010-03-13 15:26 GMT

0 views
Skip to first unread message

shac...@googlecode.com

unread,
Mar 13, 2010, 10:27:52 AM3/13/10
to shac...@googlegroups.com
Revision: 7aad6b0ab5
Author: Nightgunner5
Date: Sat Mar 13 07:26:35 2010
Log: * src/commandline.c:
Fix SEGFAULT when using shacrypt with no arguments.

* src/shacrypt.c, src/shacrypt.h:
Start work on ShuffleCrypt. More on this later. (Don't use the
functions yet!)
http://code.google.com/p/shacrypt/source/detail?r=7aad6b0ab5

Modified:
/ChangeLog
/configure
/src/commandline.c
/src/gui.c
/src/shacrypt.c
/src/shacrypt.h

=======================================
--- /ChangeLog Tue Mar 2 13:53:13 2010
+++ /ChangeLog Sat Mar 13 07:26:35 2010
@@ -1,3 +1,12 @@
+2010-03-13 Nightgunner5 <nightg...@llamaslayers.net>
+
+ * src/commandline.c:
+ Fix SEGFAULT when using shacrypt with no arguments.
+
+ * src/shacrypt.c, src/shacrypt.h:
+ Start work on ShuffleCrypt. More on this later. (Don't use the
+ functions yet!)
+
2010-03-02 Nightgunner5 <nightg...@llamaslayers.net>

* configure.ac, src/third-party/mt19937ar.h, build-aux/config.h.in:
=======================================
--- /configure Sat Feb 27 20:17:00 2010
+++ /configure Sat Mar 13 07:26:35 2010
@@ -3990,8 +3990,9 @@
SED="$ac_cv_path_SED"
rm -f conftest.sed

-# Extract the first word of "windres", so it can be a program name with
args.
-set dummy windres; ac_word=$2
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}windres", so it can be a
program name with args.
+set dummy ${ac_tool_prefix}windres; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_WINDRES_EXE+set}" = set; then :
@@ -4007,7 +4008,7 @@
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" &&
$as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
- ac_cv_prog_WINDRES_EXE="windres"
+ ac_cv_prog_WINDRES_EXE="${ac_tool_prefix}windres"
$as_echo "$as_me:${as_lineno-$LINENO}: found
$as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
@@ -4027,6 +4028,60 @@
fi


+fi
+if test -z "$ac_cv_prog_WINDRES_EXE"; then
+ ac_ct_WINDRES_EXE=$WINDRES_EXE
+ # Extract the first word of "windres", so it can be a program name with
args.
+set dummy windres; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_WINDRES_EXE+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_WINDRES_EXE"; then
+ ac_cv_prog_ac_ct_WINDRES_EXE="$ac_ct_WINDRES_EXE" # Let the user
override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" &&
$as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_ac_ct_WINDRES_EXE="windres"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found
$as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_WINDRES_EXE=$ac_cv_prog_ac_ct_WINDRES_EXE
+if test -n "$ac_ct_WINDRES_EXE"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_WINDRES_EXE" >&5
+$as_echo "$ac_ct_WINDRES_EXE" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_WINDRES_EXE" = x; then
+ WINDRES_EXE="windres"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not
prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host
triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ WINDRES_EXE=$ac_ct_WINDRES_EXE
+ fi
+else
+ WINDRES_EXE="$ac_cv_prog_WINDRES_EXE"
+fi
+

# Check file extensions

=======================================
--- /src/commandline.c Sat Feb 27 20:17:00 2010
+++ /src/commandline.c Sat Mar 13 07:26:35 2010
@@ -2,7 +2,7 @@
* SHACrypt command line
*
* SHACrypt - Encrypt files using cryptographic hash functions
- * Copyright (C) 2009 LlamaSlayers
+ * Copyright (C) 2010 LlamaSlayers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -356,13 +356,13 @@
*/
int main( int argc, char **argv ) {
// Remove leading - from the command unless it has two
- if ( argc > 0 && argv[1][0] == '-' && argv[1][1] != '-' )
+ if ( argc > 1 && argv[1][0] == '-' && argv[1][1] != '-' )
argv[1]++;

/**
* Help
*/
- if ( argc < 1 || strcmp( argv[1], "--help" ) == 0 ) {
+ if ( argc == 1 || strcmp( argv[1], "--help" ) == 0 ) {
showhelp( argv[0], "h" );
} else if ( argv[1][0] == 'h' ) {
showhelp( argv[0], argv[1] );
=======================================
--- /src/gui.c Sat Feb 27 09:31:24 2010
+++ /src/gui.c Sat Mar 13 07:26:35 2010
@@ -2,7 +2,7 @@
* SHACrypt graphical user interface
*
* SHACrypt - Encrypt files using cryptographic hash functions
- * Copyright (C) 2009 LlamaSlayers
+ * Copyright (C) 2010 LlamaSlayers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
=======================================
--- /src/shacrypt.c Sat Feb 27 20:17:00 2010
+++ /src/shacrypt.c Sat Mar 13 07:26:35 2010
@@ -2,7 +2,7 @@
* SHACrypt main code
*
* SHACrypt - Encrypt files using cryptographic hash functions
- * Copyright (C) 2009 LlamaSlayers
+ * Copyright (C) 2010 LlamaSlayers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @since 1.1.2
- * @version 1.2
+ * @version 1.2.2
*/

#include <stdio.h>
@@ -151,6 +151,8 @@
ctx->algos = algos;
ctx->password = password;
ctx->passlen = passlen;
+ ctx->rand = rand;
+ ctx->randlen = randlen;

if ( algos & '\x01' ) {
ctx->sha1_ptr = 0;
@@ -217,7 +219,7 @@
}
}

-void SHACrypt_Process( SHACrypt_Context* ctx, char* in, char* out,
unsigned int len ) {
+void SHACrypt_Process( SHACrypt_Context *ctx, char *in, char *out,
unsigned int len ) {
int i;
char c;

@@ -323,3 +325,314 @@
out[i] = c;
}
}
+
+/**
+ * @since 1.2.2
+ * @version 1.2.2
+ */
+void SHACrypt_SetScramble( SHACrypt_Context *ctx, unsigned char *code,
unsigned char len ) {
+ ctx->scramblekey = code;
+ ctx->scramblelen = len;
+
+ if ( ctx->algos & '\x01' ) {
+ ctx->scramble_sha1_ptr = 0;
+ SHA1Reset( &ctx->scramble_sha1 );
+ SHA1Input( &ctx->scramble_sha1, ctx->rand, ctx->randlen );
+ SHA1Input( &ctx->scramble_sha1, code, len );
+ SHA1Result( &ctx->scramble_sha1, ctx->scramble_sha1_res );
+ }
+
+ if ( ctx->algos & '\x02' ) {
+ ctx->scramble_sha224_ptr = 0;
+ sha224_init( &ctx->scramble_sha224 );
+ sha224_update( &ctx->scramble_sha224, ctx->rand, ctx->randlen );
+ sha224_update( &ctx->scramble_sha224, code, len );
+ sha224_final( &ctx->scramble_sha224, ctx->scramble_sha224_res );
+ }
+
+ if ( ctx->algos & '\x04' ) {
+ ctx->scramble_sha256_ptr = 0;
+ sha256_init( &ctx->scramble_sha256 );
+ sha256_update( &ctx->scramble_sha256, ctx->rand, ctx->randlen );
+ sha256_update( &ctx->scramble_sha256, code, len );
+ sha256_final( &ctx->scramble_sha256, ctx->scramble_sha256_res );
+ }
+
+ if ( ctx->algos & '\x08' ) {
+ ctx->scramble_sha384_ptr = 0;
+ sha384_init( &ctx->scramble_sha384 );
+ sha384_update( &ctx->scramble_sha384, ctx->rand, ctx->randlen );
+ sha384_update( &ctx->scramble_sha384, code, len );
+ sha384_final( &ctx->scramble_sha384, ctx->scramble_sha384_res );
+ }
+
+ if ( ctx->algos & '\x10' ) {
+ ctx->scramble_sha512_ptr = 0;
+ sha512_init( &ctx->scramble_sha512 );
+ sha512_update( &ctx->scramble_sha512, ctx->rand, ctx->randlen );
+ sha512_update( &ctx->scramble_sha512, code, len );
+ sha512_final( &ctx->scramble_sha512, ctx->scramble_sha512_res );
+ }
+
+ if ( ctx->algos & '\x20' ) {
+ ctx->scramble_md5_ptr = 0;
+ MD5Init( &ctx->scramble_md5 );
+ MD5Update( &ctx->scramble_md5, ctx->rand, ctx->randlen );
+ MD5Update( &ctx->scramble_md5, code, len );
+ MD5Final( ctx->scramble_md5_res, &ctx->scramble_md5 );
+ }
+
+ if ( ctx->algos & '\x40' ) {
+ ctx->scramble_cube_ptr = 0;
+ CubeHash_Init( &ctx->scramble_cube, 512 );
+ CubeHash_Update( &ctx->scramble_cube, ctx->rand, (int)ctx->randlen
<< 2 );
+ CubeHash_Update( &ctx->scramble_cube, code, (int)len << 2 );
+ CubeHash_Final( &ctx->scramble_cube, ctx->scramble_cube_res );
+ }
+
+ if ( ctx->algos & '\x80' ) {
+ ctx->scramble_whirlpool_ptr = 0;
+ NESSIEinit( &ctx->scramble_whirlpool );
+ NESSIEadd( ctx->rand, (int)ctx->randlen << 3,
&ctx->scramble_whirlpool );
+ NESSIEadd( code, (int)len << 3, &ctx->scramble_whirlpool );
+ NESSIEfinalize( &ctx->scramble_whirlpool,
ctx->scramble_whirlpool_res );
+ }
+}
+
+/**
+ * @since 1.2.2
+ * @version 1.2.2
+ */
+void SHACrypt_Scramble( SHACrypt_Context* ctx, char* in, char* out,
unsigned int len ) {
+ int i;
+ char c;
+
+ // First pass: Just copy
+ for ( i = 0; i < len; i++ ) {
+ out[i] = in[i];
+ }
+
+ // Second pass: The actual swapping
+ for ( i = 0; i < len; i++ ) {
+ c = 0;
+
+ if ( ctx->algos & '\x01' ) {
+ if ( ctx->shuffle_sha1_ptr > 19 ) {
+ ctx->shuffle_sha1_ptr = 0;
+ SHA1Reset( &ctx->shuffle_sha1 );
+ SHA1Input( &ctx->shuffle_sha1, ctx->shuffle_sha1_res, 20 );
+ SHA1Input( &ctx->shuffle_sha1, ctx->shufflekey,
ctx->shufflelen );
+ SHA1Result( &ctx->shuffle_sha1, ctx->shuffle_sha1_res );
+ }
+ c ^= shuffle_ctx->sha1_res[ctx->shuffle_sha1_ptr];
+ ctx->shuffle_sha1_ptr++;
+ }
+
+ if ( ctx->algos & '\x02' ) {
+ if ( ctx->shuffle_sha224_ptr > 27 ) {
+ ctx->shuffle_sha224_ptr = 0;
+ sha224_init( &ctx->shuffle_sha224 );
+ sha224_update( &ctx->shuffle_sha224,
ctx->shuffle_sha224_res, 28 );
+ sha224_update( &ctx->shuffle_sha224, ctx->shufflekey,
ctx->shufflelen );
+ sha224_final( &ctx->shuffle_sha224,
ctx->shuffle_sha224_res );
+ }
+ c ^= ctx->shuffle_sha224_res[ctx->shuffle_sha224_ptr];
+ ctx->shuffle_sha224_ptr++;
+ }
+
+ if ( ctx->algos & '\x04' ) {
+ if ( ctx->shuffle_sha256_ptr > 31 ) {
+ ctx->shuffle_sha256_ptr = 0;
+ sha256_init( &ctx->shuffle_sha256 );
+ sha256_update( &ctx->shuffle_sha256,
ctx->shuffle_sha256_res, 32 );
+ sha256_update( &ctx->shuffle_sha256, ctx->shufflekey,
ctx->shufflelen );
+ sha256_final( &ctx->shuffle_sha256,
ctx->shuffle_sha256_res );
+ }
+ c ^= ctx->shuffle_sha256_res[ctx->shuffle_sha256_ptr];
+ ctx->shuffle_sha256_ptr++;
+ }
+
+ if ( ctx->algos & '\x08' ) {
+ if ( ctx->shuffle_sha384_ptr > 47 ) {
+ ctx->shuffle_sha384_ptr = 0;
+ sha384_init( &ctx->shuffle_sha384 );
+ sha384_update( &ctx->shuffle_sha384,
ctx->shuffle_sha384_res, 48 );
+ sha384_update( &ctx->shuffle_sha384, ctx->shufflekey,
ctx->shufflelen );
+ sha384_final( &ctx->shuffle_sha384,
ctx->shuffle_sha384_res );
+ }
+ c ^= ctx->shuffle_sha384_res[ctx->shuffle_sha384_ptr];
+ ctx->shuffle_sha384_ptr++;
+ }
+
+ if ( ctx->algos & '\x10' ) {
+ if ( ctx->shuffle_sha512_ptr > 63 ) {
+ ctx->shuffle_sha512_ptr = 0;
+ sha512_init( &ctx->shuffle_sha512 );
+ sha512_update( &ctx->shuffle_sha512,
ctx->shuffle_sha512_res, 64 );
+ sha512_update( &ctx->shuffle_sha512, ctx->shufflekey,
ctx->shufflelen );
+ sha512_final( &ctx->shuffle_sha512,
ctx->shuffle_sha512_res );
+ }
+ c ^= ctx->shuffle_sha512_res[ctx->shuffle_sha512_ptr];
+ ctx->shuffle_sha512_ptr++;
+ }
+
+ if ( ctx->algos & '\x20' ) {
+ if ( ctx->shuffle_md5_ptr > 15 ) {
+ ctx->shuffle_md5_ptr = 0;
+ MD5Init( &ctx->shuffle_md5 );
+ MD5Update( &ctx->shuffle_md5, ctx->shuffle_md5_res, 16 );
+ MD5Update( &ctx->shuffle_md5, ctx->shufflekey,
ctx->shufflelen );
+ MD5Final( ctx->shuffle_md5_res, &ctx->shuffle_md5 );
+ }
+ c ^= ctx->shuffle_md5_res[ctx->shuffle_md5_ptr];
+ ctx->shuffle_md5_ptr++;
+ }
+
+ if ( ctx->algos & '\x40' ) {
+ if ( ctx->shuffle_cube_ptr > 63 ) {
+ ctx->shuffle_cube_ptr = 0;
+ CubeHash_Init( &ctx->shuffle_cube, 512 );
+ CubeHash_Update( &ctx->shuffle_cube,
ctx->shuffle_cube_res, 512 );
+ CubeHash_Update( &ctx->shuffle_cube, ctx->shufflekey,
(int)ctx->shufflelen << 3 );
+ CubeHash_Final( &ctx->shuffle_cube, ctx->shuffle_cube_res
);
+ }
+ c ^= ctx->shuffle_cube_res[ctx->shuffle_cube_ptr];
+ ctx->shuffle_cube_ptr++;
+ }
+
+ if ( ctx->algos & '\x80' ) {
+ if ( ctx->shuffle_whirlpool_ptr > 63 ) {
+ ctx->shuffle_whirlpool_ptr = 0;
+ NESSIEinit( &ctx->shuffle_whirlpool );
+ NESSIEadd( ctx->shuffle_whirlpool_res, 512,
&ctx->shuffle_whirlpool );
+ NESSIEadd( ctx->shufflekey, (int)ctx->shufflelen << 3,
&ctx->shuffle_whirlpool );
+ NESSIEfinalize( &ctx->shuffle_whirlpool,
ctx->shuffle_whirlpool_res );
+ }
+ c ^= ctx->shuffle_whirlpool_res[ctx->shuffle_whirlpool_ptr];
+ ctx->shuffle_whirlpool_ptr++;
+ }
+
+ out[c % len] ^= out[i];
+ out[i] ^= out[c % len];
+ out[c % len] ^= out[i];
+ }
+}
+
+/**
+ * @since 1.2.2
+ * @version 1.2.2
+ */
+void SHACrypt_Unscramble( SHACrypt_Context* ctx, char* in, char* out,
unsigned int len ) {
+ int i;
+ char c;
+
+ // First pass: Just copy
+ for ( i = 0; i < len; i++ ) {
+ out[i] = in[i];
+ }
+
+ // Second pass: The actual swapping
+ for ( i = len; i > -1; i-- ) {
+ c = 0;
+
+ if ( ctx->algos & '\x01' ) {
+ if ( ctx->shuffle_sha1_ptr > 19 ) {
+ ctx->shuffle_sha1_ptr = 0;
+ SHA1Reset( &ctx->shuffle_sha1 );
+ SHA1Input( &ctx->shuffle_sha1, ctx->shuffle_sha1_res, 20 );
+ SHA1Input( &ctx->shuffle_sha1, ctx->shufflekey,
ctx->shufflelen );
+ SHA1Result( &ctx->shuffle_sha1, ctx->shuffle_sha1_res );
+ }
+ c ^= shuffle_ctx->sha1_res[ctx->shuffle_sha1_ptr];
+ ctx->shuffle_sha1_ptr++;
+ }
+
+ if ( ctx->algos & '\x02' ) {
+ if ( ctx->shuffle_sha224_ptr > 27 ) {
+ ctx->shuffle_sha224_ptr = 0;
+ sha224_init( &ctx->shuffle_sha224 );
+ sha224_update( &ctx->shuffle_sha224,
ctx->shuffle_sha224_res, 28 );
+ sha224_update( &ctx->shuffle_sha224, ctx->shufflekey,
ctx->shufflelen );
+ sha224_final( &ctx->shuffle_sha224,
ctx->shuffle_sha224_res );
+ }
+ c ^= ctx->shuffle_sha224_res[ctx->shuffle_sha224_ptr];
+ ctx->shuffle_sha224_ptr++;
+ }
+
+ if ( ctx->algos & '\x04' ) {
+ if ( ctx->shuffle_sha256_ptr > 31 ) {
+ ctx->shuffle_sha256_ptr = 0;
+ sha256_init( &ctx->shuffle_sha256 );
+ sha256_update( &ctx->shuffle_sha256,
ctx->shuffle_sha256_res, 32 );
+ sha256_update( &ctx->shuffle_sha256, ctx->shufflekey,
ctx->shufflelen );
+ sha256_final( &ctx->shuffle_sha256,
ctx->shuffle_sha256_res );
+ }
+ c ^= ctx->shuffle_sha256_res[ctx->shuffle_sha256_ptr];
+ ctx->shuffle_sha256_ptr++;
+ }
+
+ if ( ctx->algos & '\x08' ) {
+ if ( ctx->shuffle_sha384_ptr > 47 ) {
+ ctx->shuffle_sha384_ptr = 0;
+ sha384_init( &ctx->shuffle_sha384 );
+ sha384_update( &ctx->shuffle_sha384,
ctx->shuffle_sha384_res, 48 );
+ sha384_update( &ctx->shuffle_sha384, ctx->shufflekey,
ctx->shufflelen );
+ sha384_final( &ctx->shuffle_sha384,
ctx->shuffle_sha384_res );
+ }
+ c ^= ctx->shuffle_sha384_res[ctx->shuffle_sha384_ptr];
+ ctx->shuffle_sha384_ptr++;
+ }
+
+ if ( ctx->algos & '\x10' ) {
+ if ( ctx->shuffle_sha512_ptr > 63 ) {
+ ctx->shuffle_sha512_ptr = 0;
+ sha512_init( &ctx->shuffle_sha512 );
+ sha512_update( &ctx->shuffle_sha512,
ctx->shuffle_sha512_res, 64 );
+ sha512_update( &ctx->shuffle_sha512, ctx->shufflekey,
ctx->shufflelen );
+ sha512_final( &ctx->shuffle_sha512,
ctx->shuffle_sha512_res );
+ }
+ c ^= ctx->shuffle_sha512_res[ctx->shuffle_sha512_ptr];
+ ctx->shuffle_sha512_ptr++;
+ }
+
+ if ( ctx->algos & '\x20' ) {
+ if ( ctx->shuffle_md5_ptr > 15 ) {
+ ctx->shuffle_md5_ptr = 0;
+ MD5Init( &ctx->shuffle_md5 );
+ MD5Update( &ctx->shuffle_md5, ctx->shuffle_md5_res, 16 );
+ MD5Update( &ctx->shuffle_md5, ctx->shufflekey,
ctx->shufflelen );
+ MD5Final( ctx->shuffle_md5_res, &ctx->shuffle_md5 );
+ }
+ c ^= ctx->shuffle_md5_res[ctx->shuffle_md5_ptr];
+ ctx->shuffle_md5_ptr++;
+ }
+
+ if ( ctx->algos & '\x40' ) {
+ if ( ctx->shuffle_cube_ptr > 63 ) {
+ ctx->shuffle_cube_ptr = 0;
+ CubeHash_Init( &ctx->shuffle_cube, 512 );
+ CubeHash_Update( &ctx->shuffle_cube,
ctx->shuffle_cube_res, 512 );
+ CubeHash_Update( &ctx->shuffle_cube, ctx->shufflekey,
(int)ctx->shufflelen << 3 );
+ CubeHash_Final( &ctx->shuffle_cube, ctx->shuffle_cube_res
);
+ }
+ c ^= ctx->shuffle_cube_res[ctx->shuffle_cube_ptr];
+ ctx->shuffle_cube_ptr++;
+ }
+
+ if ( ctx->algos & '\x80' ) {
+ if ( ctx->shuffle_whirlpool_ptr > 63 ) {
+ ctx->shuffle_whirlpool_ptr = 0;
+ NESSIEinit( &ctx->shuffle_whirlpool );
+ NESSIEadd( ctx->shuffle_whirlpool_res, 512,
&ctx->shuffle_whirlpool );
+ NESSIEadd( ctx->shufflekey, (int)ctx->shufflelen << 3,
&ctx->shuffle_whirlpool );
+ NESSIEfinalize( &ctx->shuffle_whirlpool,
ctx->shuffle_whirlpool_res );
+ }
+ c ^= ctx->shuffle_whirlpool_res[ctx->shuffle_whirlpool_ptr];
+ ctx->shuffle_whirlpool_ptr++;
+ }
+
+ out[c % len] ^= out[i];
+ out[i] ^= out[c % len];
+ out[c % len] ^= out[i];
+ }
+}
=======================================
--- /src/shacrypt.h Sat Feb 27 09:31:24 2010
+++ /src/shacrypt.h Sat Mar 13 07:26:35 2010
@@ -2,7 +2,7 @@
* SHACrypt header
*
* SHACrypt - Encrypt files using cryptographic hash functions
- * Copyright (C) 2009 LlamaSlayers
+ * Copyright (C) 2010 LlamaSlayers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,15 +18,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @since 1.1.2
- * @version 1.2
+ * @version 1.2.2
*/

#ifndef _SHACRYPT_H_
#define _SHACRYPT_H_
// Legacy methods
-int SHACrypt_XOR( char* in1, char* in2, char* out, int len );
-int SHACrypt_GenKey( char* oldkey, char* newkey, char* password );
-int SHACrypt_GenRand( char* data, int len );
+int SHACrypt_XOR( char *in1, char *in2, char *out, int len );
+int SHACrypt_GenKey( char *oldkey, char *newkey, char *password );
+int SHACrypt_GenRand( char *data, int len );

// Methods added in the MultiHash branch
#include "third-party/sha1.h"
@@ -66,15 +66,54 @@
cube_ptr,
whirlpool_ptr;

+ // Scramble hash contexts
+ SHA1Context scramble_sha1;
+ sha224_ctx scramble_sha224;
+ sha256_ctx scramble_sha256;
+ sha384_ctx scramble_sha384;
+ sha512_ctx scramble_sha512;
+ MD5_CTX scramble_md5;
+ CubeHash_hashState scramble_cube;
+ NESSIEstruct scramble_whirlpool;
+
+ // Scramble hash results
+ unsigned char scramble_sha1_res[20],
+ scramble_sha224_res[28],
+ scramble_sha256_res[32],
+ scramble_sha384_res[48],
+ scramble_sha512_res[64],
+ scramble_md5_res[16],
+ scramble_cube_res[64],
+ scramble_whirlpool_res[64];
+
+ // Scramble hash result pointers
+ unsigned char scramble_sha1_ptr,
+ scramble_sha224_ptr,
+ scramble_sha256_ptr,
+ scramble_sha384_ptr,
+ scramble_sha512_ptr,
+ scramble_md5_ptr,
+ scramble_cube_ptr,
+ scramble_whirlpool_ptr;
+
// Other variables
- unsigned char algos;
- unsigned char* password;
- unsigned int passlen;
+ unsigned char algos,
+ *password,
+ *scramblekey,
+ *rand,
+ 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 );
-void SHACrypt_Process( SHACrypt_Context* ctx, char* in, char* out,
unsigned int len );
+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 );
+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_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

Reply all
Reply to author
Forward
0 new messages