# dkim_sign()

[back to index]

SYNOPSIS

    #include <dkim.h>
    DKIM *dkim_sign(
    	DKIM_LIB *libhandle,
    	const char *id,
    	void *memclosure,
    	const unsigned char *secretkey,
    	const unsigned char *selector,
    	const unsigned char *domain,
    	dkim_canon_t hdrcanon_alg,
    	dkim_canon_t bodycanon_alg,
    	dkim_alg_t sign_alg,
    	ssize_t length
    	DKIM_STAT *statp
    );

Create a new handle for signing a message.

DESCRIPTION

Called When | `dkim_sign()` is called when preparing to process a new message that will be signed later by a private key.

ARGUMENTS

Argument | Description
--- | ---
libhandle | DKIM library instance handle, returned by an earlier call to `dkim_init()`.
id | An opaque, printable string for identifying this message, suitable for use in logging or debug output.
memclosure | Opaque memory closure, passed directly to the caller-provided `malloc()` and/or `free()` replacement functions.
secretkey | The private key to be used when signing this message. This must be a NULL-terminated string containing either a PEM-formatted private key, or a DER-formatted private key after being encoded with base64.
selector | The name of the selector to be reported in the signature on this message.
domain | The domain doing the signing; this will be the domain whose DNS will be queried by the verifier for key data.
hdrcanon_alg | The canonicalization algorithm to use when preparing the headers of this message for signing.
bodycanon_alg | The canonicalization algorithm to use when preparing the body of this message for signing.
sign_alg | The signing algorithm to use when generating the signature to be attached to this message.
length | The number of bytes of the body to sign. A value of -1 will cause the entire message to be signed.
statp | Pointer to a `DKIM_STAT` object which receives the completion status of this operation.

NOTES

- `DKIM_STAT_INVALID` can be returned if, for example, a signing handle using SHA256 is requested when the library was not compiled against a version of OpenSSL that had support for that hash algorithm.

RETURN VALUES

- On success, a pointer to the created `DKIM` handle is returned.
- On failure, NULL is returned and the value of `statp` is updated to indicate the cause of the problem.

Copyright (c) 2005-2007 Sendmail, Inc. and its suppliers. All rights reserved.
Copyright (c) 2009-2011, 2014, The Trusted Domain Project. All rights reserved.
By using this file, you agree to the terms and conditions set forth in the respective licenses.