| 673 | } |
| 674 | |
| 675 | void SecretRecoverFile(int threshold, const char *outFilename, char *const *inFilenames) |
| 676 | { |
| 677 | CRYPTOPP_ASSERT(threshold >= 1 && threshold <=1000); |
| 678 | if (threshold < 1 || threshold > 1000) |
| 679 | throw InvalidArgument("SecretRecoverFile: " + IntToString(threshold) + " is not in range [1, 1000]"); |
| 680 | |
| 681 | SecretRecovery recovery(threshold, new FileSink(outFilename)); |
| 682 | |
| 683 | vector_member_ptrs<FileSource> fileSources(threshold); |
| 684 | SecByteBlock channel(4); |
| 685 | int i; |
| 686 | for (i=0; i<threshold; i++) |
| 687 | { |
| 688 | fileSources[i].reset(new FileSource(inFilenames[i], false)); |
| 689 | fileSources[i]->Pump(4); |
| 690 | fileSources[i]->Get(channel, 4); |
| 691 | fileSources[i]->Attach(new ChannelSwitch(recovery, string((char *)channel.begin(), 4))); |
| 692 | } |
| 693 | |
| 694 | while (fileSources[0]->Pump(256)) |
| 695 | for (i=1; i<threshold; i++) |
| 696 | fileSources[i]->Pump(256); |
| 697 | |
| 698 | for (i=0; i<threshold; i++) |
| 699 | fileSources[i]->PumpAll(); |
| 700 | } |
| 701 | |
| 702 | void InformationDisperseFile(int threshold, int nShares, const char *filename) |
| 703 | { |
no test coverage detected