Reconstruction of des.exe/undes.exe

This commit is contained in:
2026-09-09 23:28:46 +02:00
parent b90136f137
commit 5aa37bf374
64 changed files with 13344 additions and 2 deletions
+122
View File
@@ -0,0 +1,122 @@
/*
* Common support reconstructed from DES/UNDES V1.1.0 executables.
* Original program copyright: (C) 1998 H.N.M. Dijkema, GPL.
*
* This is reconstructed source, not the original source text. The helper
* behaviour and strings below are derived directly from des.exe/undes.exe.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "des_common.h"
DES_INT32 desKnownVersions[] = {
DES_FILE_VERSION,
(DES_INT32) -1
};
const char *desProgramVersion =
"DES/UNDES V1.1.0, (C) 1998 H.N.M. Dijkema (GPL)";
const char *desCopyrightText =
" Copyright (C) 1998 H.N.M. Dijkema\n"
"\n"
" This product includes software developed by Eric Young (eay@mincom.oz.au)\n"
"\n"
" This program is free software; you can redistribute it and/or modify\n"
" it under the terms of the GNU General Public License as published by\n"
" the Free Software Foundation; either version 2 of the License, or\n"
" (at your option) any later version.\n"
"\n"
" This program is distributed in the hope that it will be useful,\n"
" but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
" GNU General Public License for more details.\n"
"\n"
" You should have received a copy of the GNU General Public License\n"
" along with this program; if not, write to the Free Software\n"
" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n"
"\n"
" You can contact the author by electronic mail, hnmdijkema@freemail.nl\n"
"\n"
"\n"
"Acknowledgements\n"
"----------------\n"
"The author of CRYPTLIB, Peter Putmann of University of Auckland\n"
"cryptl99.zip Free encryption library for DOS/UNIX/Windows\n"
"\n"
"The DES and 3DES encryption code was contributed by Eric Young\n"
"<eay@psych.psy.uq.oz.au> and is part of his libdes package.\n"
"The primary ftp site for the full libdes is\n"
" ftp://ftp.psy.uq.oz.au/pub/Crypto/DES/libdes-x.xx.tar.gz.\n"
"\n";
void checkRead( int result )
{
if( result == -1 )
{
fprintf( stderr, "\nFATAL : error reading input stream\n" );
perror( "MESSAGE " );
exit( 3 );
}
}
void checkWrite( FILE *stream )
{
if( ferror( stream ) )
{
fprintf( stderr, "\nFATAL : error writing output stream\n" );
perror( "MESSAGE " );
exit( 3 );
}
}
void checkOpen( FILE *stream, const char *name )
{
if( stream == NULL )
{
fprintf( stderr, "\nFATAL : Cannot open '%s'\n", name );
perror( "MESSAGE " );
exit( 3 );
}
}
void checkVersion( DES_INT32 version )
{
int i = 0;
while( desKnownVersions[ i ] != version &&
desKnownVersions[ i ] != (DES_INT32) -1 )
i++;
if( desKnownVersions[ i ] == (DES_INT32) -1 )
{
fprintf( stderr,
"I don't know the version of this file, can't decrypt this\n" );
exit( 1 );
}
}
/*
* The compiler output proves that the marker is formed from a signed 16-bit
* word: abs(word), followed by negation and sign-extension to 32 bits.
*/
DES_INT32 negativeMarker( const unsigned char *p )
{
DES_INT16 value;
DES_UINT16 magnitude;
DES_UINT16 negated;
memcpy( &value, p, sizeof( value ) );
/* Emulate 16-bit Turbo C arithmetic exactly, including -32768. */
if( value < 0 )
magnitude = (DES_UINT16) ( -(DES_INT32) value );
else
magnitude = (DES_UINT16) value;
negated = (DES_UINT16) ( 0U - magnitude );
memcpy( &value, &negated, sizeof( value ) );
return( (DES_INT32) value );
}