You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
downloadclient/downloadclient.cc

51 lines
1.2 KiB

4 years ago
// this file is under GNU General Public License 3.0
// see LICENSE.txt
#include "downloadclient.hh"
4 years ago
#include <iostream>
#include <sstream>
4 years ago
namespace pEp {
namespace UpdateClient {
PublicKey load_key(string filename)
{
CryptoPP::RSA::PublicKey key;
try {
CryptoPP::ByteQueue queue;
3 years ago
CryptoPP::FileSource file(filename.c_str(), true);
file.TransferTo(queue);
queue.MessageEnd();
key.Load(queue);
}
catch (exception&) {
throw CannotLoadKey(filename);
}
return key;
}
3 years ago
string update(product p, PublicKey update_key, notifyRead_t *notifyRead)
4 years ago
{
4 years ago
UpdateStream us { UpdateDevice(p) };
4 years ago
try {
us->open(update_key, notifyRead);
4 years ago
}
4 years ago
catch (exception&) { }
if (us->filename() == "")
throw DownloadError();
return us->filename();
}
3 years ago
string update(product p, string keyfile, notifyRead_t *notifyRead)
4 years ago
{
PublicKey update_key = load_key(keyfile);
return update(p, update_key, notifyRead);
4 years ago
}
}
}