<HTML><BODY><div><div class="js-helper js-readmsg-msg"><div id="style_15831539320179371337_BODY"><div class="class_1583224522"><div>No, I want to get CMS Enveloped data in the end of the procedure. </div><div> </div><div>Firstly, I initialize the encryption operation by adding recipient certificates, algorithms, etc., then send the data in chunks for encryption and receive them in an encrypted format for further writing to the file. At the end of the operation, I call the finalizing of the encryption, which adds the final bytes 0x00 0x00 to the cms structure for internal blocks, meaning the end of each cms block - this is what I mean. As far as I know CryptMsgUpdate() in CryptoApi allows it - I'm trying to explain my purpose to you better using examples.</div><div>I want to get something similar in OpenSSL. It’s possible?</div><div> </div><div>Now I use such method:</div><div style="text-align:center">…</div><div><div>cms = CMS_encrypt(certs, NULL, cipher, CMS_STREAM | CMS_BINARY); //call it once at the start</div><div> </div><div>BIO* input = CMS_dataInit(cms, NULL); //call it once at the start</div><div><br>BIO_write(input, pbData, cbData);//call each time to add another part of data</div><div> </div><div>CMS_dataFinal(cms, input); //call it once in the end of encryption</div></div><div style="text-align:center">…</div><div style="text-align:center"> </div><div>This method allows me to read data in stream mode and send it to BIO_write(). But I can’t send encrypted data by parts — only after calling CMS_dataFinal() — from cms structure. Thanks for any help.</div><div> </div><div class="mail-quote-collapse"><blockquote style="border-left:1px solid #0857A6;margin:10px;padding:0 0 0 10px;"><span data-email="beldmit@gmail.com" data-name="Dmitry Belyavsky" data-quote-id="1699969806461181788" data-timestamp="1582898100" data-type="sender">Пятница, 28 февраля 2020, 16:55 +03:00 от Dmitry Belyavsky <<a href="/compose?To=beldmit@gmail.com">beldmit@gmail.com</a>>:<br> </span><div data-quote-id="1699969806461181788" data-type="body"><div id=""><div class="js-helper_mailru_css_attribute_postfix js-readmsg-msg_mailru_css_attribute_postfix"><style type="text/css"></style><div><div id="style_15828981431322854380_BODY_mailru_css_attribute_postfix"><div class="class_1583154529_mailru_css_attribute_postfix"><div dir="ltr">Hello,<div> </div><div>If you mean encryption/decryption only, I strongly suppose you should look at EVP_CipherInit/Update/Final functions.</div></div> <div class="gmail_quote_mailru_css_attribute_postfix_mailru_css_attribute_postfix"><div class="mail-quote-collapse"><div class="gmail_attr_mailru_css_attribute_postfix_mailru_css_attribute_postfix" dir="ltr"><span data-email="openssl-users@openssl.org" data-name="Илья Юркевич (Ilya Yurkevich) via openssl-users" data-quote-id="1699969806461181789" data-timestamp="1582897980" data-type="sender"><span>On Fri, Feb 28, 2020 at 4:53 PM Ilya Yurkevich via openssl-users <<a href="http://e.mail.ru/compose/?mailto=mailto%3aopenssl%2dusers@openssl.org" rel="noopener noreferrer" target="_blank">openssl-users@openssl.org</a>> wrote:</span></span></div><div><div data-quote-id="1699969806461181789" data-type="body"><blockquote class="gmail_quote_mailru_css_attribute_postfix_mailru_css_attribute_postfix" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div><div><div id="gmail-m_5627950174390739659style_15827028460894656143_BODY_mailru_css_attribute_postfix_mailru_css_attribute_postfix"><div><div><p><span lang="EN-US">Hello,</span></p><p><span lang="EN-US">I have a client, that sends me data, that I need to encrypt, in few steps. I can use such functions in PKCS11: C_EncryptInit (...), C_EncryptUpdate (...), C_EncryptFinal (...). It allows me add data, that will be encrypted at every step, using C_EncryptUpdate </span> function.</p><p><span lang="EN-US"> </span></p><p><span lang="EN-US">In OpenSSL I found CMS_encrypt (...) with flag = CMS_STREAM, but I can't understand how I can add data as I described above or another way? I get data in unsigned char* every time. Any help would be appreciated. Thanks.</span></p></div></div></div></div></div></div></div></blockquote></div></div></div></div> <div> </div>--<div class="gmail_signature_mailru_css_attribute_postfix_mailru_css_attribute_postfix" dir="ltr">SY, Dmitry Belyavsky</div></div></div></div></div></div></div></blockquote></div></div></div></div></div><style type="text/css"></style></BODY></HTML>