# Sendmail DomainKeys Identified Mail (DKIM) Library

## Introduction

DomainKeys Identified Mail ("DKIM") is a specification for signing messages at the domain level using simple cryptographic methods to prevent the falsification of sender domains. While the most obvious application of this is to defense against spam, other applications can make use of this capability.

DKIM is an amalgamation of DomainKeys, created by Yahoo!, Inc., and Internet Identified Mail (IIM) created by Cisco, Inc. Both can be found as historical RFCs documents via the IETF web sites. More information about DomainKeys can be found here.

This API (`libdkim`) allows an application to sign or verify messages according to the DKIM proposed standard. Also provided is an implementation of a filter, using Sendmail's milter package, that uses `libdkim` to implement this facility.

## Data Types

Data Type | Description
`DKIM` | A signing/verifying context for a message.
`dkim_alg_t` | A signature generation/verification method.
`dkim_canon_t` | A canonicalization method.
`DKIM_CBSTAT` | Return value/status from user-provided callbacks.
`DKIM_DNSSEC` | Key and policy record security evaluation codes.
`DKIM_LIB` | An instance of the `libdkim` service.
`dkim_param_t` | A signature parameter.
`dkim_policy_t` | A sender signing policy.
`DKIM_PRESULT` | A policy evaluation result.
`DKIM_PSTATE` | Polciy lookup state information.
`dkim_query_t` | A key query method.
`DKIM_SIGERROR` | Signature evaluation error codes.
`DKIM_SIGINFO` | Private handle referencing information about a particular signature on a signed message.
`dkim_sigkey_t` | Private key data.
`DKIM_STAT` | Return value/status.

## Functions

Function | Description
Administration
`dkim_init()` | Initialize an instance of the DKIM service.
`dkim_flush_cache()` | Flush the key/policy cache.
`dkim_getcachestats()` | Retrive caching statistics.
`dkim_set_dns_callback()` | Request a call back into the main program from time to time while waiting for DNS results.
`dkim_set_final()` | Provide a function to perform final signature analysis and/or re-ordering during verifications.
`dkim_set_key_lookup()` | Provide a function to perform key lookups, replacing the internal implementation.
`dkim_set_policy_lookup()` | Provide a function to perform policy lookups, replacing the internal implementation.
`dkim_set_prescreen()` | Provide a function to perform signature prescreening and/or re-ordering during verifications.
`dkim_set_signature_handle()` | Provide a function to allocate a user-side signature description structure and return a pointer to it.
`dkim_set_signature_handle_free()` | Provide a function to deallocate a user-side signature description structure.
`dkim_set_signature_tagvalues()` | Provide a function to receive signature-specific tags and values for user-side analysis.
`dkim_ssl_version()` | Retrieve the OpenSSL version used when the library was compiled.
`dkim_close()` | Terminate an instance of the DKIM service.
Signing
`dkim_sign()` | Allocate a new DKIM handle for signing a message.
`dkim_getsighdr()` | Generate and return a signature header.
`dkim_set_margin()` | Set the wrapping margin to use for signature header generation.
`dkim_set_signer()` | Set the message signer.
Verifying
`dkim_verify()` | Allocate a new DKIM handle for verifying a message.
`dkim_diffheaders()` | Compare original headers to received headers and look for approximate matches to identify header munging in order to explain verification failures.
`dkim_get_user_context()` | Retrieve a specific user context pointer for a sign or verify operation previously set by a call to `dkim_set_user_context()`.
`dkim_getdomain()` | Return the sending domain from a message represented by a DKIM handle.
`dkim_geterror()` | Retrieve the most recent internal error message associated with a DKIM handle.
`dkim_getmode()` | Return the mode (signing or verifying) of a DKIM handle.
`dkim_getpolicystr()` | Translate a policy code into a user-friendly string.
`dkim_getpresult()` | Retrieve detail about the sender's policy evaluation with respect to the message associated with a DKIM handle.
`dkim_getpresultstr()` | Translate a policy result code into a user-friendly string.
`dkim_getresultstr()` | Translate a DKIM_STAT constant into a string.
`dkim_getsiglist()` | Retrieve the array of signature handles associated with a message.
`dkim_getsignature()` | Retrieve the signature handle to be used for final message disposition.
`dkim_minbody()` | Return number of bytes required to satisfy all active canonicalizations referenced by a DKIM handle.
`dkim_ohdrs()` | Retrieve the original header set from a signature if such were present.
`dkim_policy()` | Evaluate sender signing policy information.
`dkim_policy_getdnssec()` | Retrieve DNSSEC evaluation of a sending domain's policy record.
`dkim_policy_getreportinfo()` | Retrieve information required to generate a policy failure report.
`dkim_set_user_context()` | Set a specific user context pointer for a sign or verify operation which will be passed to user callbacks.
`dkim_sig_getbh()` | Retrieve body hash test result from a signature handle.
`dkim_sig_getcanonlen()` | Retrieve information regarding total canonicalized body length, and the size of what was actually signed.
`dkim_sig_getcontext()` | Retrieve user-side context specific to a signature.
`dkim_sig_getdnssec()` | Retrieve DNSSEC evaluation of a signature's key record.
`dkim_sig_getdomain()` | Retrieve the domain name found in the signature on a message.
`dkim_sig_geterror()` | Retrieve the error code associated with a rejected/disqualified signature.
`dkim_sig_geterrorstr()` | Retrieve the text version of a signature error code.
`dkim_sig_getflags()` | Retrieve processing flags from a signature handle.
`dkim_sig_getidentity()` | Retrieve the identity of the signing agent from a signature or message.
`dkim_sig_getkeysize()` | Retrieve the size in bits of the key used to verify a message.
`dkim_sig_getreportinfo()` | Retrieve information required to generate a verification failure report.
`dkim_sig_getselector()` | Retrieve the selector found in a signature on a message.
`dkim_sig_getsignalg()` | Retrieve the signature algorithm used to sign a message.
`dkim_sig_getsigntime()` | Retrieve the timestamp on the signature of a message.
`dkim_sig_hdrsigned()` | Determine whether or not a particular header was signed.
`dkim_sig_ignore()` | Flag a signature to be ignored when verifying.
`dkim_sig_process()` | Process a signature for validity.
Processing
`dkim_header()` | Process a header.
`dkim_eoh()` | Identify end of headers.
`dkim_body()` | Process a body chunk.
`dkim_eom()` | Identify end of message.
`dkim_chunk()` | Process a message chunk.
Utility
`dkim_key_syntax()` | Check the syntax of a key record.
`dkim_options()` | Get or set library options.
`dkim_policy_syntax()` | Check the syntax of a policy record.
`dkim_sig_syntax()` | Check the syntax of a signature.
`rfc2822_mailbox_split()` | Parse an RFC2822 header, e.g. `From:`, to get user and domain.
Cleanup
`dkim_free()` | Destroy a per-message handle of the DKIM service.

An overview of the general use of this API is available here.

Copyright (c) 2005-2008 Sendmail, Inc. and its suppliers. All rights reserved.
By using this file, you agree to the terms and conditions set forth in the LICENSE.