@@ -56,7 +56,6 @@ struct CDoc1Writer::Private final: public XMLWriter
5656 std::string documentFormat = " ENCDOC-XML|1.1" ;
5757 std::string &lastError;
5858 std::vector<FileEntry> files;
59- std::vector<Recipient> rcpts;
6059
6160 int64_t writeEncryptionProperties (bool use_ddoc);
6261 int64_t writeKeyInfo (bool use_ddoc, const std::vector<Recipient> &rcpts, const Crypto::Key& transportKey);
@@ -233,7 +232,7 @@ CDoc1Writer::encrypt(libcdoc::MultiDataSource& src, const std::vector<libcdoc::R
233232 if (keys.empty ())
234233 return WORKFLOW_ERROR;
235234 RET_ERROR (beginEncryption ());
236- d-> rcpts = keys;
235+ rcpts = keys;
237236 Crypto::Key transportKey = Crypto::generateKey (d->method );
238237 int n_components = src.getNumComponents ();
239238 bool use_ddoc = (n_components > 1 ) || (n_components == libcdoc::NOT_IMPLEMENTED);
@@ -272,7 +271,7 @@ CDoc1Writer::encrypt(libcdoc::MultiDataSource& src, const std::vector<libcdoc::R
272271libcdoc::result_t
273272CDoc1Writer::beginEncryption ()
274273{
275- if (!dst )
274+ if (d )
276275 return WORKFLOW_ERROR;
277276 d = std::make_unique<Private>(*dst, last_error);
278277 return libcdoc::OK;
@@ -281,9 +280,9 @@ CDoc1Writer::beginEncryption()
281280libcdoc::result_t
282281CDoc1Writer::addRecipient (const libcdoc::Recipient& rcpt)
283282{
284- if (! d)
283+ if (d)
285284 return WORKFLOW_ERROR;
286- d-> rcpts .push_back (rcpt);
285+ rcpts.push_back (rcpt);
287286 return libcdoc::OK;
288287}
289288
@@ -309,12 +308,12 @@ CDoc1Writer::writeData(const uint8_t *src, size_t size)
309308libcdoc::result_t
310309CDoc1Writer::finishEncryption ()
311310{
312- if (!d || d-> rcpts .empty () || d->files .empty ())
311+ if (!d || rcpts.empty () || d->files .empty ())
313312 return WORKFLOW_ERROR;
314313 bool use_ddoc = d->files .size () > 1 ;
315314 libcdoc::Crypto::Key transportKey = libcdoc::Crypto::generateKey (d->method );
316315
317- RET_ERROR (d->writeKeyInfo (use_ddoc, d-> rcpts , transportKey));
316+ RET_ERROR (d->writeKeyInfo (use_ddoc, rcpts, transportKey));
318317 RET_ERROR (d->writeElement (Private::DENC, " CipherData" , [&] {
319318 return d->writeBase64Element (Private::DENC, " CipherValue" , [&](DataConsumer &dst) -> int64_t {
320319 EncryptionConsumer enc (dst, d->method , transportKey);
0 commit comments