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