
#use wml::openssl-macros area=docs page=CMS_add1_recipient_cert

<title>Documents, CMS_add1_recipient_cert(3)</title>

<h1>CMS_add1_recipient_cert(3)</h1>

#use wml::imp::generic

{:
## What's this? [[s|(<STRONG>[^<].+?)</A>(</STRONG><DD>)|$1$2|sg]]
[[s|<P>\s+<P>|<P>|sg]]
[[s|<P>\s+</|</|sg]]
[[s|<DD>\s*<DT>|<DD>&nbsp;<DT>|sg]]
[[s|<DD>\s*</DL>|<DD>&nbsp;</DL>|sg]]
[[s|\[|&#91;|sg]]
[[s|\]|&#93;|sg]]

<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#NAME">NAME</A>
	<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
	<LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
	<LI><A HREF="#NOTES">NOTES</A>
	<LI><A HREF="#RETURN_VALUES">RETURN VALUES</A>
	<LI><A HREF="#SEE_ALSO">SEE ALSO</A>
	<LI><A HREF="#HISTORY">HISTORY</A>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="NAME">NAME</A></H1>
<PRE> CMS_add1_recipient_cert, CMS_add0_recipient_key - add recipients to a CMS enveloped data structure
</PRE>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/cms.h&gt;
</PRE>
<PRE> CMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms, X509 *recip, unsigned int flags);
</PRE>
<PRE> CMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid, unsigned char *key, size_t keylen, unsigned char *id, size_t idlen, ASN1_GENERALIZEDTIME *date, ASN1_OBJECT *otherTypeId, ASN1_TYPE *otherType);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
<CODE>CMS_add1_recipient_cert()</CODE> adds recipient <STRONG>recip</STRONG> to CMS_ContentInfo enveloped data structure <STRONG>cms</STRONG> as a KeyTransRecipientInfo structure.

</P>
<P>
<CODE>CMS_add0_recipient_key()</CODE> adds symmetric key <STRONG>key</STRONG> of length <STRONG>keylen</STRONG> using wrapping algorithm <STRONG>nid</STRONG>, identifier <STRONG>id</STRONG> of length <STRONG>idlen</STRONG> and optional values <STRONG>date</STRONG>, <STRONG>otherTypeId</STRONG> and <STRONG>otherType</STRONG> to CMS_ContentInfo enveloped data structure <STRONG>cms</STRONG> as a KEKRecipientInfo structure.

</P>
<P>
The CMS_ContentInfo structure should be obtained from an initial call to
<CODE>CMS_encrypt()</CODE> with the flag <STRONG>CMS_PARTIAL</STRONG> set.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
The main purpose of this function is to provide finer control over a CMS
enveloped data structure where the simpler <CODE>CMS_encrypt()</CODE>
function defaults are not appropriate. For example if one or more
KEKRecipientInfo structures need to be added. New attributes can also be
added using the returned CMS_RecipientInfo structure and the CMS attribute
utility functions.

</P>
<P>
OpenSSL will by default identify recipient certificates using issuer name
and serial number. If <STRONG>CMS_USE_KEYID</STRONG> is set it will use the subject key identifier value instead. An error
occurs if all recipient certificates do not have a subject key identifier
extension.

</P>
<P>
Currently only AES based key wrapping algorithms are supported for <STRONG>nid</STRONG>, specifically: NID_id_aes128_wrap, NID_id_aes192_wrap and
NID_id_aes256_wrap. If <STRONG>nid</STRONG> is set to <STRONG>NID_undef</STRONG> then an AES wrap algorithm will be used consistent with <STRONG>keylen</STRONG>.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>CMS_add1_recipient_cert()</CODE> and
<CODE>CMS_add0_recipient_key()</CODE> return an internal pointer to the
CMS_RecipientInfo structure just added or NULL if an error occurs.

</P>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
<A HREF="../crypto/ERR_get_error.html#">ERR_get_error(3)</A>, <A HREF="../crypto/CMS_decrypt.html#">CMS_decrypt(3)</A>,
<A HREF="../crypto/CMS_final.html#">CMS_final(3)</A>,

</P>
<P>
<HR>
<H1><A NAME="HISTORY">HISTORY</A></H1>
<P>
<CODE>CMS_add1_recipient_cert()</CODE> and
<CODE>CMS_add0_recipient_key()</CODE> were added to OpenSSL 0.9.8

</P>
:}


