CryptoPP in a Juce module


#1


Hi community,
I am trying to adapt Wei Dai's Crypto++ Library into a Juce Module format. I have managed to sort out many problems but there is one that I cannot figure out how to solve.
 The problem is that the CryptoPP's translation units seem not to be ready to be collected in a single .cpp file. There are several same type definition, for instance:
 
gost.cpp

typedef BlockGetAndPut<word32, LittleEndian> Block;

mars.cpp

typedef BlockGetAndPut<word32, LittleEndian> Block;


Same thing happens with function templates.
I just wonder if there is any way to cope with this situation, I mean, to sort out this amalgamated compilation in order to try to compile CryptoPP similar in the original way.
Thank you in advance
Gabriel
 


#2

Demand DRYness from the souce? :)


#3

Good point, but IMO I think it is a mature project, so, difficult to modify it.

Any alternative?


#4

Not that I know of, sadly... You could derive the repository and do the edits yourself? Looks like it's under the Boost Software License - I think you're safe, but IANAL and so suggest you double-check if you think that's a good idea.


#5

I'm trying to do it, but tough to cope with it.


#6

I wrote a script that generates a separate .cpp file for the module and it worked for me.

#!/bin/bash

cryptopplib="cryptopp565"
module_name=“cryptopp”

flist=(
‘1|cryptlib’
‘2|cpu’
‘3|integer’

‘3way’
‘adler32’
‘algebra’
‘algparam’
‘arc4’
‘asn’
‘authenc’
‘base32’
‘base64’
‘basecode’
‘bfinit’
‘blake2’
‘blowfish’
‘blumshub’
‘camellia’
‘cast’
‘casts’
‘cbcmac’
‘ccm’
‘chacha’
‘channels’
‘cmac’
‘crc’
‘default’
‘des’
‘dessp’
‘dh’
‘dh2’
‘dll’
‘dsa’
‘eax’
‘ec2n’
‘eccrypto’
‘ecp’
‘elgamal’
‘emsa2’
‘eprecomp’
‘esign’
‘files’
‘filters’
‘fips140’
‘fipstest’
‘gcm’
‘gf256’
‘gf2_32’
‘gf2n’
‘gfpcrypt’
‘gost’
‘gzip’
‘hex’
‘hmac’
‘hrtimer’
‘ida’
‘idea’
‘iterhash’
‘keccak’
‘luc’
‘mars’
‘marss’
‘md2’
‘md4’
‘md5’
‘misc’
‘modes’
‘mqueue’
‘mqv’
‘nbtheory’
‘network’
‘oaep’
‘osrng’
‘panama’
‘pkcspad’
‘polynomi’
‘pssr’
‘pubkey’
‘queue’
‘rabin’
‘randpool’
‘rc2’
‘rc5’
‘rc6’
‘rdrand’
‘rdtables’
‘rijndael’
‘ripemd’
‘rng’
‘rsa’
‘rw’
‘safer’
‘salsa’
‘seal’
‘seed’
‘serpent’
‘sha’
‘sha3’
‘shacal2’
‘shark’
‘sharkbox’
‘skipjack’
‘socketft’
‘sosemanuk’
‘square’
‘squaretb’
‘strciphr’
‘tea’
‘tftables’
‘tiger’
‘tigertab’
‘trdlocal’
‘ttmac’
‘twofish’
‘vmac’
‘wait’
‘wake’
‘whrlpool’
‘xtr’
‘xtrcrypt’
‘zdeflate’
‘zinflate’
‘zlib’
)

for f in "${flist[@]}"
do
if [[ f == *"|"* ]]; then s=({f//|/ })
module_file_name={s[0]} include_file_name={s[1]}
else
module_file_name=$f
include_file_name=f fi fname="{module_name}_$module_file_name.cpp"
echo "Creating $fname"
echo “#include “$cryptopplib/$include_file_name.cpp”” > $fname
done

echo “Done.”