| 643 | } |
| 644 | |
| 645 | void SecretShareFile(int threshold, int nShares, const char *filename, const char *seed) |
| 646 | { |
| 647 | CRYPTOPP_ASSERT(nShares >= 1 && nShares<=1000); |
| 648 | if (nShares < 1 || nShares > 1000) |
| 649 | throw InvalidArgument("SecretShareFile: " + IntToString(nShares) + " is not in range [1, 1000]"); |
| 650 | |
| 651 | RandomPool rng; |
| 652 | rng.IncorporateEntropy((byte *)seed, strlen(seed)); |
| 653 | |
| 654 | ChannelSwitch *channelSwitch = NULL; |
| 655 | FileSource source(filename, false, new SecretSharing(rng, threshold, nShares, channelSwitch = new ChannelSwitch)); |
| 656 | |
| 657 | vector_member_ptrs<FileSink> fileSinks(nShares); |
| 658 | string channel; |
| 659 | for (int i=0; i<nShares; i++) |
| 660 | { |
| 661 | char extension[5] = ".000"; |
| 662 | extension[1]='0'+byte(i/100); |
| 663 | extension[2]='0'+byte((i/10)%10); |
| 664 | extension[3]='0'+byte(i%10); |
| 665 | fileSinks[i].reset(new FileSink((string(filename)+extension).c_str())); |
| 666 | |
| 667 | channel = WordToString<word32>(i); |
| 668 | fileSinks[i]->Put((const byte *)channel.data(), 4); |
| 669 | channelSwitch->AddRoute(channel, *fileSinks[i], DEFAULT_CHANNEL); |
| 670 | } |
| 671 | |
| 672 | source.PumpAll(); |
| 673 | } |
| 674 | |
| 675 | void SecretRecoverFile(int threshold, const char *outFilename, char *const *inFilenames) |
| 676 | { |
no test coverage detected