Patch 4.1B / INTRODUCTION

Crypto++ is a free c++ library available with source file.

The version 4.1 support few compilers but c++ builder is not supported unlike the version 3.2 which is supported with few issues.

The goal of this patch is to make this library compatible with c++ builder at least at the same level

Installation for c++ builder 5

Be sure to use at least c++ builder 5 update #1. See the last section about the status of version 6

If you have not the update you can download it from Borland

Download crypto++ 4.1  and copy files to the project folder

Download my patch (or second source) and copy files to the same folder

The project file cryptotst.bpr can be used do compile the validation program cryptotst.

if you have any problem you can visits my site on www.chez.com/psylon (french site, sorry) or e-mail me

User manual

Interface change

Sorry but some modifications change the syntax for few templates

Original syntax Replacement syntax
HMAC<t> HMACB(t)
XMACC<t> XMACCB(t)
MDCB<t> MDCB(t)

Compatibility

This patch has been tested with c++ builder 5 update 1.

without update 1 you will have a compiler error on zdeflate.cpp module

Some algorithms don't pass validation test :

// pass=ElGamalValidate() && pass;
// pass=LUCELGValidate() && pass;

The same were not working in version 3.2

Some others don't pass general bench :

CRC32, BlumGoldwasser

 

Warning about cfb usage 

CFB decryption must be associated with encryption object, eg :

cfb = new CFBDecryption(*rijndaelEncrypt,iv);


From the authors of the library, this way is the normal way for cfb usage.

Description of patch : 

Description of patchs applied to crypto4.1 for c++ builder 5p1 :

1/ limitation on template parameter

Can't pass a parameter from derived template to base template, 

so in files changed : hmac.h,xormac.h,mdc.h
caller changed : ecrypto.h,default.h,bench.cpp,randpool.h,valid3.cpp,randpool.cpp

hmac.h : 

template <class T> class HMAC : public MessageAuthenticationCode, public VariableKeyLength<16, 0, T::BLOCKSIZE>
is replaced by 
template <class T,unsigned int BLOCKSIZE> class HMAC : public MessageAuthenticationCode, public VariableKeyLength<16, 0, BLOCKSIZE>
same modification in each function
to have an easier caller macro is defined
#define HMACB(t) <t,t::BLOCKSIZE>

xormac.h :

template <class T> class XMACC : public IteratedHash<typename T::HashWordType, T::HIGHFIRST, T::BLOCKSIZE>, public MessageAuthenticationCode
is replaced by 
template <class T,bool HIGHFIRST,unsigned int BLOCKSIZE> class XMACC : public IteratedHash<typename T::HashWordType,
/*T::*/HIGHFIRST, /*T::*/BLOCKSIZE>, public MessageAuthenticationCode
same modification in each function
to have an easier caller macro is defined
#define XMACCB(t) XMACC<t,t::HIGHFIRST,t::BLOCKSIZE>

mdc.h :

template <class T> class MDC : public FixedBlockSize<T::DIGESTSIZE>, public FixedKeyLength<T::BLOCKSIZE>
is replaced by
template <class T,unsigned int DIGESTSIZE,unsigned int BLOCKSIZE> class MDC :
public FixedBlockSize</*T::*/DIGESTSIZE>, public FixedKeyLength</*T::*/BLOCKSIZE>
#define MDCB(t) MDC<t,t::DIGESTSIZE,t::BLOCKSIZE>

2/ Borland bug on algebra compilation 

Borland deny to create MultiplicativeGroupT member inside AbstractRing. it declare it abstract

extract MultiplicativeGroupT from AbstractRing similary to version 3 but 
less proper because I didn't see V3 before my modification

files changed algebra.h, algebra.cpp

3/ runtime bug on pubkey module 

borland seem losts in virtual propagation table from trap in pubkey

re-integrate in rsaFunction class (file rsa.h) the two functions : 
Integer MaxPreimage() const {return n-1;} // leon
Integer MaxImage() const {return n-1;} // leon
same for luc.h,rabin.h,rw.h 
little difference for rw :
Integer MaxImage() const {return ImageBound()-1;} // leon

4/ Borland bug on PK_WithPrecomputation

In dsa.h, elgamal.h, ecrypto.h replacement macro has been defined and used : 

#ifndef PK_WithPrecomputationB
#define PK_WithPrecomputationB(t) virtual PK_Precomputation,public virtual t
#endif

I replaced reference from PK_WithPrecomputation to PK_WithPrecomputationB

Borland seems not like this emty class wich refer two other one causing crash in my own program test on DSA even if the validation test was working. This allow to pass validation test on ECXXX but not elgamal sorry.

5/ Theses validation fail in version 4.1

// pass=ElGamalValidate() && pass;
// pass=LUCELGValidate() && pass;
so valid1.cpp has been modified to skip these test.

 6/ Specific files

cryptotst.bpr & cryptotst.bpf : borland projects files

cryptotst.cpp : main test file

c++ builder 6

The patch doesn't work today for c++ builder 6, I'm locked on some compilation error. Sorry

Here is the current state of my work:

C++ builder seems to have problème to find the std::swap function.

You can correct it in change "std::swap" to ::swap and adding in begining of the file:

#include <algorith.h>
for files
bulletblowfish.c
bulletcast.c
bulletdes.c
bulletmisc.h
bulletgf2n.c
bulletpolynomi.c
bulletinteger.c
bulletqueue.c
bulletsapphire.c
bulletshark.c
bulletsquare.c

Compilation problem on 

bulleteccrypto.c std:lower_bound-> ::lower_bound
bulletzdeflate.c

patch 5.0

Travaux en cours de test sous c++ builder 5

bulletsimple.h deletion of protected on the Sink class

crypto 5.1

Thanks to WBR, Dmitry, i try again with

bulletc++ builder patch 4
bulletcrypto 5.1

Changes:

bulletsimple.h comment some requalification in protected on the Sink class
bulletarc4.c crash internal error, removed from the list
bulletalgparam.h : class AlgorithmParameters conversion problem in value parameter unable to find a solution