Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
virtual P6R::P6ERR P6R::p6ISign2::sign ( P6CRYPTODATASOURCE pInData,
P6CRYPTODATASINK pOutData,
P6BOOL  base64Encode,
P6SIGNHMAC  hmac 
)
pure virtual

Sign the data pointed to by pInData given the key and the key type set in setKey.

setKey() must be called at least once before this function is called. If either an RSA, EC, or DSA cipher is desired then the private key must be passed to setKey() before this function is called. If SYM is used then the shared symetric key must be passed first to setKey().

A data source can be a buffer or a file. A data source can be text or binary data. The resulting signature (a binary value) can be encoded into ASCII by placing it into a base64 representation. The resulting signature can be written out to a buffer or to a file by itself. Note that if a file is the data sink, then any existing contents of that file are erased before the signature is written to it.

When signing using DSA keys, the hmac specified MUST be SH_SHA1.

Parameters
pInData[ in ] Generate a signature for this input data.
pOutData[ in ] Pointer to where to copy the signature value.
base64Encode[ in ] Flag indicating whether the signature should be encoded in base64 (otherwise it is binary string)
hmac[ in ] the hash algorithm to use for the message digest. See P6R::P6SIGNHMAC.
Returns
SuccessP6R::eOk 
FailureeNotInitializedA successful call to initialize was not made before this call.
eFormatErrorA DSA private key has not been loaded via loadDSAKeyPair.
eInvalidArgOne of the parameters is NULL.
eNotFoundFile data source does not exist.
eIoErrorWrite to file data sink failed.
eTooSmallThe buffer data sink is too small to contain the generated value.
eTooBigInternal error
eMissingKeysetKey must be called before this function.
eWrongKeyClassPrivate or symetric keys only can sign data.
eInvalidHMACA DSA key is being used for signing, but the HMAC specified was not SH_SHA1.
eFailAndExceptionThe signature calculation failed. Exception record provides detailed error info.