make
g++ -g -msse2 -pipe -c 3way.cpp
<snip>
g++ -g -msse2 -pipe -c ida.cpp
In file included from /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.1/../../../../include/c++/3.4.1/backward/strstream:51,
from polynomi.cpp:10,
from ida.cpp:10:
/usr/lib/gcc/i586-mandrake-linux-gnu/3.4.1/../../../../include/c++/3.4.1/backward/backward_warning.h:32:2: warning: #war
ning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found
in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ inclu
des, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
g++ -g -msse2 -pipe -c idea.cpp
<snip>
g++ -g -msse2 -pipe -c polynomi.cpp
In file included from /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.1/../../../../include/c++/3.4.1/backward/strstream:51,
from polynomi.cpp:10:
/usr/lib/gcc/i586-mandrake-linux-gnu/3.4.1/../../../../include/c++/3.4.1/backward/backward_warning.h:32:2: warning: #war
ning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found
in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ inclu
des, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
g++ -g -msse2 -pipe -c pssr.cpp
<snip>
g++ -g -msse2 -pipe -c zdeflate.cpp
secblock.h: In member function `T& CryptoPP::SecBlock<T, A>::operator[](I) [with I = unsigned char, T = unsigned int, A = CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 286u, CryptoPP::NullAllocator<unsigned int> >]':
zdeflate.cpp:527: instantiated from here
secblock.h:251: warning: comparison is always true due to limited range of data type
g++ -g -msse2 -pipe -c zinflate.cpp
g++ -g -msse2 -pipe -c zlib.cpp
ar -cr libcryptopp.a 3way.o adler32.o algebra.o algparam.o arc4.o asn.o base32.o base64.o basecode.o bfinit.o blowfis .o blumshub.o camellia.o cast.o casts.o cbcmac.o channels.o crc.o cryptlib.o default.o des.o dessp.o dh2.o dh.o dll.o d a.o ec2n.o eccrypto.o ecp.o elgamal.o eprecomp.o esign.o files.o filters.o fips140.o fipstest.o gf2_32.o gf256.o gf2n.o gfpcrypt.o gost.o gzip.o haval.o helloworld.o hex.o hmac.o hrtimer.o ida.o idea.o integer.o iterhash.o luc.o mars.o mar s.o md2.o md4.o md5.o md5mac.o misc.o modes.o modexppc.o mqueue.o mqv.o nbtheory.o network.o oaep.o osrng.o panama.o pc .o pkcspad.o polynomi.o pssr.o pubkey.o queue.o rabin.o randpool.o rc2.o rc5.o rc6.o rdtables.o rijndael.o ripemd.o rng o rsa.o rw.o safer.o seal.o serpent.o shacal2.o sha.o sharkbox.o shark.o simple.o skipjack.o socketft.o square.o square b.o strciphr.o tea.o tftables.o tiger.o tigertab.o trdlocal.o ttmac.o twofish.o wait.o wake.o whrlpool.o winpipes.o xtr o xtrcrypt.o zdeflate.o zinflate.o zlib.o
ranlib libcryptopp.a
g++ -g -msse2 -pipe -c bench.cpp
g++ -g -msse2 -pipe -c bench2.cpp
g++ -g -msse2 -pipe -c test.cpp
g++ -g -msse2 -pipe -c validat1.cpp
g++ -g -msse2 -pipe -c validat2.cpp
g++ -g -msse2 -pipe -c validat3.cpp
g++ -g -msse2 -pipe -c adhoc.cpp
g++ -g -msse2 -pipe -c datatest.cpp
g++ -g -msse2 -pipe -c regtest.cpp
g++ -g -msse2 -pipe -c fipsalgt.cpp
g++ -g -msse2 -pipe -c dlltest.cpp
g++ -o cryptest.exe -g -msse2 -pipe bench.o bench2.o test.o validat1.o validat2.o validat3.o adhoc.o datatest.o regtest.o fipsalgt.o dlltest.o -L. -lcryptopp
However my code really doesn't work at all. It could be because I'm being really think with the way I'm calling SHA or CBC_MAC and would really appeciate if if somebody could give me a hint (well a BIG HINT) on getting both especially the latter to work.
Even odder is:
./cryptest.exe m cryptest.exe
MD5: 65bbe0d21070440c917b6272e08824be
SHA-1: c439cd98e01b9272b73ab9c0ba690310212c2514
RIPEMD-160: e495771327d4c0591c47e9bd44029d76c247a341
SHA-256: [EMAIL PROTECTED] cryptopp521]#
Works fine under mandrake so it's obviously something I'm doing wrong
Cheers
Gecko (aka Cath)
On 9/4/05, Jeffrey Walton <[EMAIL PROTECTED]> wrote:
Hi Gecko,
How does the library compile when using the makefile? I suspect it may be a
path issue, but I've seen a lot of posts on gcc issues in general. Have you
gone through the archive on gcc/g++ issues?
Jeff
----- Original Message -----
From: "The Gecko" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Saturday, September 03, 2005 1:09 PM
Subject: Issues with SHA (or even CBC) MAC - trying to read in a file to a
buffer and MAC
Hi,
First off let me apologise if my code sytle and question are REALL lame,
I've not done any C/C++ for a long time. I've been trying to impliment a SHA
(or even CBC_MAC) for a file which I have read into a char or byte buffer.
The problem is that this thing refuses point blank to compile under Linux
(Mandrake 10.1, g++ --version is 3.41
I'm using g++ -g -msse2 -pipe codetest.cpp -o a.out where codetest.cpp is in
the same folder as everything from the unzipped crypto++ libraries.
The code is:
--------------------
#define CRYPTOPP_CBCMAC_H
//#include "stdafx.h"
#include "seckey.h"
#include "secblock.h"
#include "pch.h"
#include "cryptlib.h"
#include "cbcmac.h "
#include "sha.h"
#include "hmac.h"
#include <iostream>
#include <fstream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include < string.h>
#include "md5.h"
#include "filters.h"
#include "files.h"
#include "hex.h"
using namespace std;
using namespace CryptoPP;
int main()
{
FILE* pinfile; //Associates the pointer with a file to read in
FILE* poutfile; //and out
FILE* keyfile;
FILE* hashkey;
byte * buffery;
char * buffer2;
char filein[32];
long lSize;
int x, y;
int anykey;
byte * thekey;
byte keylength;
cout << "To hash a file press 1 + ENTER" <<std::endl;
cin >> anykey;
/***************************** ********
ENCRYPTION
*************************************/
if (anykey == 1)
{
cout << "What is the file to encrypt:" <<std::endl;
cin >> filein;
//Open the file and the key in read only mode
pinfile = fopen ( filein , "rb" );
if (pinfile==NULL) exit (1);
hashkey = fopen ( "key.txt" , "rb" );
if (hashkey==NULL) exit (1);
// obtain file size.
fseek (pinfile , 0 , SEEK_END);
lSize = ftell (pinfile);
rewind (pinfile);
fseek (hashkey , 0 , SEEK_END);
keylength = ftell (hashkey);
rewind (hashkey);
// DANGER WILL ROBINSON DANGER
// allocate memory to contain the whole file.
buffery = (byte*) malloc (lSize);
buffer2 = (char*) malloc (8);
thekey = (byte*) malloc(keylength);
if (buffery == NULL) exit (2);
// DANGER WILL ROBINSON DANGER
// whole file copied into buffer.
fread (buffery,1,lSize,pinfile);
byte * bufferzz9;
bufferzz9 = (byte*) malloc (2 * SHA::DIGESTSIZE);
HMAC<SHA > mac;
mac.SetKey(thekey, keylength);
mac.Update(buffery, lSize);
mac.Final(bufferzz9);
//TRIED WITH CBC_MAC No joy either
//CBC_MAC_Base<CBC_MAC>(thekey, keylength).CalculateDigest(bufferzz9,
buffery, lSize);
// )) or ) here?
// Clear up mess made
fclose (pinfile);
free (buffery);
free (buffer2);
}
return 0;
}
----------
The error begins:
/home/dev/cryptopp521/seckey.h:145: undefined reference to `vtable for
CryptoPP::HMAC_Base'
/home/dev/tmp/cclsTN2o.o(.gnu.linkonce.t._ZN8CryptoPP9HMAC_BaseD2Ev+0x17):
In function `CryptoPP::HMAC_Base::~HMAC_Base()':
/home/dev/cryptopp521/JpegCoder2.cpp:93: undefined reference to `vtable for
CryptoPP::HMAC_Base'
/home/dev/tmp/cclsTN2o.o(.gnu.linkonce.t._ZN8CryptoPP25SimpleKeyedTransforma
tionINS_18HashTransformationEED2Ev+0xb):
In function
And goes on for about 100 lines.
It seems tro be a linking issue as using g++ -g -msse2 -pipe -c
codetest.cpp-o
a.out produces no problems
How can I basically read in a file and generate a MAC for it. I'd like to
know both SHA and CBC_MAC really for education purposes.
Thanks
T Gecko
