Hi Douglas,
Let's try and get you moving... I took the following from Crypto++ 5.2.1.
Jeff
************************************************
************************************************
>From Usage (actually, usage.dat):
- To secret share a file (shares will be named file.000, file.001, etc)
cryptest ss threshold number-of-shares file
- To reconstruct a secret-shared file
cryptest sr file share1 share2 [....]
(number of shares given must be equal to threshold)
- To information disperse a file (shares will be named file.000, file.001, etc)
cryptest id threshold number-of-shares file
- To reconstruct an information-dispersed file
cryptest ir file share1 share2 [....]
(number of shares given must be equal to threshold)
************************************************
************************************************
And the functions. See test.cpp, lines 491-592
************************************************
void SecretShareFile(int threshold, int nShares, const char *filename, const
char *seed)
{
assert(nShares<=1000);
RandomPool rng;
rng.Put((byte *)seed, strlen(seed));
ChannelSwitch *channelSwitch;
FileSource source(filename, false, new SecretSharing(rng, threshold,
nShares, channelSwitch = new ChannelSwitch));
vector_member_ptrs<FileSink> fileSinks(nShares);
string channel;
for (int i=0; i<nShares; i++)
{
char extension[5] = ".000";
extension[1]='0'+byte(i/100);
extension[2]='0'+byte((i/10)%10);
extension[3]='0'+byte(i%10);
fileSinks[i].reset(new FileSink((string(filename)+extension).c_str()));
channel = WordToString<word32>(i);
fileSinks[i]->Put((byte *)channel.data(), 4);
channelSwitch->AddRoute(channel, *fileSinks[i],
BufferedTransformation::NULL_CHANNEL);
}
source.PumpAll();
}
************************************************
void SecretRecoverFile(int threshold, const char *outFilename, char *const
*inFilenames)
{
assert(threshold<=1000);
SecretRecovery recovery(threshold, new FileSink(outFilename));
vector_member_ptrs<FileSource> fileSources(threshold);
SecByteBlock channel(4);
int i;
for (i=0; i<threshold; i++)
{
fileSources[i].reset(new FileSource(inFilenames[i], false));
fileSources[i]->Pump(4);
fileSources[i]->Get(channel, 4);
fileSources[i]->Attach(new ChannelSwitch(recovery, string((char
*)channel.begin(), 4)));
}
while (fileSources[0]->Pump(256))
for (i=1; i<threshold; i++)
fileSources[i]->Pump(256);
for (i=0; i<threshold; i++)
fileSources[i]->PumpAll();
}
************************************************
void InformationDisperseFile(int threshold, int nShares, const char *filename)
{
assert(nShares<=1000);
ChannelSwitch *channelSwitch;
FileSource source(filename, false, new InformationDispersal(threshold,
nShares, channelSwitch = new ChannelSwitch));
vector_member_ptrs<FileSink> fileSinks(nShares);
string channel;
for (int i=0; i<nShares; i++)
{
char extension[5] = ".000";
extension[1]='0'+byte(i/100);
extension[2]='0'+byte((i/10)%10);
extension[3]='0'+byte(i%10);
fileSinks[i].reset(new FileSink((string(filename)+extension).c_str()));
channel = WordToString<word32>(i);
fileSinks[i]->Put((byte *)channel.data(), 4);
channelSwitch->AddRoute(channel, *fileSinks[i],
BufferedTransformation::NULL_CHANNEL);
}
source.PumpAll();
}
************************************************
void InformationRecoverFile(int threshold, const char *outFilename, char *const
*inFilenames)
{
assert(threshold<=1000);
InformationRecovery recovery(threshold, new FileSink(outFilename));
vector_member_ptrs<FileSource> fileSources(threshold);
SecByteBlock channel(4);
int i;
for (i=0; i<threshold; i++)
{
fileSources[i].reset(new FileSource(inFilenames[i], false));
fileSources[i]->Pump(4);
fileSources[i]->Get(channel, 4);
fileSources[i]->Attach(new ChannelSwitch(recovery, string((char
*)channel.begin(), 4)));
}
while (fileSources[0]->Pump(256))
for (i=1; i<threshold; i++)
fileSources[i]->Pump(256);
for (i=0; i<threshold; i++)
fileSources[i]->PumpAll();
}