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

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

<h1>CMS_sign_add1_signer(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_sign_add1_signer, CMS_SignerInfo_sign - add a signer to a CMS_ContentInfo signed data structure.
</PRE>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/cms.h&gt;
</PRE>
<PRE> CMS_SignerInfo *CMS_sign_add1_signer(CMS_ContentInfo *cms, X509 *signcert, EVP_PKEY *pkey, const EVP_MD *md, unsigned int flags);
</PRE>
<PRE> int CMS_SignerInfo_sign(CMS_SignerInfo *si);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
<CODE>CMS_sign_add1_signer()</CODE> adds a signer with certificate <STRONG>signcert</STRONG> and private key <STRONG>pkey</STRONG> using message digest <STRONG>md</STRONG> to CMS_ContentInfo SignedData structure <STRONG>cms</STRONG>.

</P>
<P>
The CMS_ContentInfo structure should be obtained from an initial call to
<CODE>CMS_sign()</CODE> with the flag <STRONG>CMS_PARTIAL</STRONG> set or in the case or re-signing a valid CMS_ContentInfo SignedData
structure.

</P>
<P>
If the <STRONG>md</STRONG> parameter is <STRONG>NULL</STRONG> then the default digest for the public key algorithm will be used.

</P>
<P>
Unless the <STRONG>CMS_REUSE_DIGEST</STRONG> flag is set the returned CMS_ContentInfo structure is not complete and must
be finalized either by streaming (if applicable) or a call to
<CODE>CMS_final().</CODE>

</P>
<P>
The <CODE>CMS_SignerInfo_sign()</CODE> function will explicitly sign a
CMS_SignerInfo structure, its main use is when <STRONG>CMS_REUSE_DIGEST</STRONG> and <STRONG>CMS_PARTIAL</STRONG> flags are both set.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
The main purpose of <CODE>CMS_sign_add1_signer()</CODE> is to provide finer
control over a CMS signed data structure where the simpler
<CODE>CMS_sign()</CODE> function defaults are not appropriate. For example
if multiple signers or non default digest algorithms are needed. New
attributes can also be added using the returned CMS_SignerInfo structure
and the CMS attribute utility functions or the CMS signed receipt request
functions.

</P>
<P>
Any of the following flags (ored together) can be passed in the <STRONG>flags</STRONG>
parameter.

</P>
<P>
If <STRONG>CMS_REUSE_DIGEST</STRONG> is set then an attempt is made to copy the content digest value from the
CMS_ContentInfo structure: to add a signer to an existing structure. An
error occurs if a matching digest value cannot be found to copy. The
returned CMS_ContentInfo structure will be valid and finalized when this
flag is set.

</P>
<P>
If <STRONG>CMS_PARTIAL</STRONG> is set in addition to <STRONG>CMS_REUSE_DIGEST</STRONG> then the CMS_SignerInfo structure will not be finalized so additional
attributes can be added. In this case an explicit call to
<CODE>CMS_SignerInfo_sign()</CODE> is needed to finalize it.

</P>
<P>
If <STRONG>CMS_NOCERTS</STRONG> is set the signer's certificate will not be included in the CMS_ContentInfo
structure, the signer's certificate must still be supplied in the <STRONG>signcert</STRONG> parameter though. This can reduce the size of the signature if the signers
certificate can be obtained by other means: for example a previously signed
message.

</P>
<P>
The SignedData structure includes several CMS signedAttributes including
the signing time, the CMS content type and the supported list of ciphers in
an SMIMECapabilities attribute. If <STRONG>CMS_NOATTR</STRONG> is set then no signedAttributes will be used. If <STRONG>CMS_NOSMIMECAP</STRONG> is set then just the SMIMECapabilities are omitted.

</P>
<P>
OpenSSL will by default identify signing 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 the signing certificate does not have a subject key identifier
extension.

</P>
<P>
If present the SMIMECapabilities attribute indicates support for the
following algorithms in preference order: 256 bit AES, Gost R3411-94, Gost
28147-89, 192 bit AES, 128 bit AES, triple DES, 128 bit RC2, 64 bit RC2,
DES and 40 bit RC2. If any of these algorithms is not available then it
will not be included: for example the GOST algorithms will not be included
if the GOST ENGINE is not loaded.

</P>
<P>
<CODE>CMS_sign_add1_signer()</CODE> returns an internal pointer to the
CMS_SignerInfo structure just added, this can be used to set additional
attributes before it is finalized.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>CMS_sign1_add_signers()</CODE> returns an internal pointer to the
CMS_SignerInfo 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_sign.html#">CMS_sign(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_sign_add1_signer()</CODE> was added to OpenSSL 0.9.8

</P>
:}

