<div dir="ltr">Thank you for the responses.<div><br></div><div>I have implemented encryption that adds a secret key, and secret key id using:</div><div>CMS_add0_recipient_key,</div><div>CMS_EncryptData_encrypt,</div><div>SMIME_write_CMS</div><div>The output file looks correct, but I need to decrypt it back to be sure.</div><div><br></div><div>I would like to be able to get the secret key id from the envelope data to then search a database for the key, and then CMS_decrypt.  I have yet to determine the most straightforward way of getting the key ids from the envelope/wrapped content of cms.</div><div><br></div><div>Is there a combination if I have SMIME_read the cms from a file like:</div><div>  keyId =  cms->envelopedData->keyId?</div><div><br></div><div>Or do I need to handle a stack_of recipient infos in order to get the key id from kekri0_get_id?</div><div><br></div><div>Thanks again,<br></div><div>Abe</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 5, 2016 at 7:39 AM, Dr. Stephen Henson <span dir="ltr"><<a href="mailto:steve@openssl.org" target="_blank">steve@openssl.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Mon, Apr 04, 2016, Abe Racioppo wrote:<br>
<br>
> Hey guys,<br>
><br>
> I'm trying to use the CMS operations in libcrypto but with a symmetric key<br>
> encryption key instead of x509.<br>
><br>
> I'm thinking I want to use a combination of<br>
><br>
> CMS_RecipientInfo_set0_pkey,<br>
> SMIME_write_CMS,<br>
> and<br>
> CMS_EncryptedData_encrypt.<br>
><br>
> Has anyone done this before and can give me some direction?  This is my<br>
> first time working with openssl and am getting kinda lost.<br>
><br>
<br>
</span>You have several options here.<br>
<br>
You can just use the encrypted data type with a key directly.<br>
<br>
You can use the enveloped data type with a symmetric wrapping key.<br>
<br>
You can use the enveloped data type with a password based recipient info.<br>
<br>
Which you use depends on the application you have in mind.<br>
<br>
In the first case you just call CMS_EncryptData_encrypt() followed by<br>
SMIME_write_CMS().<br>
<br>
Steve.<br>
--<br>
Dr Stephen N. Henson. OpenSSL project core developer.<br>
Commercial tech support now available see: <a href="http://www.openssl.org" rel="noreferrer" target="_blank">http://www.openssl.org</a><br>
<div class="HOEnZb"><div class="h5">--<br>
openssl-users mailing list<br>
To unsubscribe: <a href="https://mta.openssl.org/mailman/listinfo/openssl-users" rel="noreferrer" target="_blank">https://mta.openssl.org/mailman/listinfo/openssl-users</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div>signature</div></div>
</div></div>