📄 dst.h
字号:
/* * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2002 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. *//* $Id: dst.h,v 1.1.6.5 2006/01/27 23:57:44 marka Exp $ */#ifndef DST_DST_H#define DST_DST_H 1/*! \file */#include <isc/lang.h>#include <dns/types.h>ISC_LANG_BEGINDECLS/*** *** Types ***//*% * The dst_key structure is opaque. Applications should use the accessor * functions provided to retrieve key attributes. If an application needs * to set attributes, new accessor functions will be written. */typedef struct dst_key dst_key_t;typedef struct dst_context dst_context_t;/* DST algorithm codes */#define DST_ALG_UNKNOWN 0#define DST_ALG_RSAMD5 1#define DST_ALG_RSA DST_ALG_RSAMD5 /*%< backwards compatibility */#define DST_ALG_DH 2#define DST_ALG_DSA 3#define DST_ALG_ECC 4#define DST_ALG_RSASHA1 5#define DST_ALG_HMACMD5 157#define DST_ALG_GSSAPI 160#define DST_ALG_HMACSHA1 161 /* XXXMPA */#define DST_ALG_HMACSHA224 162 /* XXXMPA */#define DST_ALG_HMACSHA256 163 /* XXXMPA */#define DST_ALG_HMACSHA384 164 /* XXXMPA */#define DST_ALG_HMACSHA512 165 /* XXXMPA */#define DST_ALG_PRIVATE 254#define DST_ALG_EXPAND 255#define DST_MAX_ALGS 255/*% A buffer of this size is large enough to hold any key */#define DST_KEY_MAXSIZE 1280/*% * A buffer of this size is large enough to hold the textual representation * of any key */#define DST_KEY_MAXTEXTSIZE 2048/*% 'Type' for dst_read_key() */#define DST_TYPE_KEY 0x1000000 /* KEY key */#define DST_TYPE_PRIVATE 0x2000000#define DST_TYPE_PUBLIC 0x4000000/*** *** Functions ***/isc_result_tdst_lib_init(isc_mem_t *mctx, isc_entropy_t *ectx, unsigned int eflags);/*%< * Initializes the DST subsystem. * * Requires: * \li "mctx" is a valid memory context * \li "ectx" is a valid entropy context * * Returns: * \li ISC_R_SUCCESS * \li ISC_R_NOMEMORY * * Ensures: * \li DST is properly initialized. */voiddst_lib_destroy(void);/*%< * Releases all resources allocated by DST. */isc_boolean_tdst_algorithm_supported(unsigned int alg);/*%< * Checks that a given algorithm is supported by DST. * * Returns: * \li ISC_TRUE * \li ISC_FALSE */isc_result_tdst_context_create(dst_key_t *key, isc_mem_t *mctx, dst_context_t **dctxp);/*%< * Creates a context to be used for a sign or verify operation. * * Requires: * \li "key" is a valid key. * \li "mctx" is a valid memory context. * \li dctxp != NULL && *dctxp == NULL * * Returns: * \li ISC_R_SUCCESS * \li ISC_R_NOMEMORY * * Ensures: * \li *dctxp will contain a usable context. */voiddst_context_destroy(dst_context_t **dctxp);/*%< * Destroys all memory associated with a context. * * Requires: * \li *dctxp != NULL && *dctxp == NULL * * Ensures: * \li *dctxp == NULL */isc_result_tdst_context_adddata(dst_context_t *dctx, const isc_region_t *data);/*%< * Incrementally adds data to the context to be used in a sign or verify * operation. * * Requires: * \li "dctx" is a valid context * \li "data" is a valid region * * Returns: * \li ISC_R_SUCCESS * \li DST_R_SIGNFAILURE * \li all other errors indicate failure */isc_result_tdst_context_sign(dst_context_t *dctx, isc_buffer_t *sig);/*%< * Computes a signature using the data and key stored in the context. * * Requires: * \li "dctx" is a valid context. * \li "sig" is a valid buffer. * * Returns: * \li ISC_R_SUCCESS * \li DST_R_VERIFYFAILURE * \li all other errors indicate failure * * Ensures: * \li "sig" will contain the signature */isc_result_tdst_context_verify(dst_context_t *dctx, isc_region_t *sig);/*%< * Verifies the signature using the data and key stored in the context. * * Requires: * \li "dctx" is a valid context. * \li "sig" is a valid region. * * Returns: * \li ISC_R_SUCCESS * \li all other errors indicate failure * * Ensures: * \li "sig" will contain the signature */isc_result_tdst_key_computesecret(const dst_key_t *pub, const dst_key_t *priv, isc_buffer_t *secret);/*%< * Computes a shared secret from two (Diffie-Hellman) keys. * * Requires: * \li "pub" is a valid key that can be used to derive a shared secret * \li "priv" is a valid private key that can be used to derive a shared secret * \li "secret" is a valid buffer * * Returns: * \li ISC_R_SUCCESS * \li any other result indicates failure * * Ensures: * \li If successful, secret will contain the derived shared secret. */isc_result_tdst_key_fromfile(dns_name_t *name, dns_keytag_t id, unsigned int alg, int type, const char *directory, isc_mem_t *mctx, dst_key_t **keyp);/*%< * Reads a key from permanent storage. The key can either be a public or * private key, and is specified by name, algorithm, and id. If a private key * is specified, the public key must also be present. If directory is NULL, * the current directory is assumed. * * Requires: * \li "name" is a valid absolute dns name. * \li "id" is a valid key tag identifier. * \li "alg" is a supported key algorithm. * \li "type" is DST_TYPE_PUBLIC, DST_TYPE_PRIVATE, or the bitwise union. * DST_TYPE_KEY look for a KEY record otherwise DNSKEY * \li "mctx" is a valid memory context. * \li "keyp" is not NULL and "*keyp" is NULL. * * Returns: * \li ISC_R_SUCCESS * \li any other result indicates failure * * Ensures: * \li If successful, *keyp will contain a valid key. */isc_result_tdst_key_fromnamedfile(const char *filename, int type, isc_mem_t *mctx, dst_key_t **keyp);/*%< * Reads a key from permanent storage. The key can either be a public or * key, and is specified by filename. If a private key is specified, the * public key must also be present. * * Requires: * \li "filename" is not NULL * \li "type" is DST_TYPE_PUBLIC, DST_TYPE_PRIVATE, or the bitwise union * DST_TYPE_KEY look for a KEY record otherwise DNSKEY * \li "mctx" is a valid memory context * \li "keyp" is not NULL and "*keyp" is NULL. * * Returns: * \li ISC_R_SUCCESS * \li any other result indicates failure * * Ensures: * \li If successful, *keyp will contain a valid key. */isc_result_tdst_key_read_public(const char *filename, int type, isc_mem_t *mctx, dst_key_t **keyp);/*%< * Reads a public key from permanent storage. The key must be a public key. * * Requires: * \li "filename" is not NULL * \li "type" is DST_TYPE_KEY look for a KEY record otherwise DNSKEY * \li "mctx" is a valid memory context * \li "keyp" is not NULL and "*keyp" is NULL. * * Returns: * \li ISC_R_SUCCESS * \li DST_R_BADKEYTYPE if the key type is not the expected one * \li ISC_R_UNEXPECTEDTOKEN if the file can not be parsed as a public key * \li any other result indicates failure * * Ensures: * \li If successful, *keyp will contain a valid key. */isc_result_tdst_key_tofile(const dst_key_t *key, int type, const char *directory);/*%< * Writes a key to permanent storage. The key can either be a public or * private key. Public keys are written in DNS format and private keys * are written as a set of base64 encoded values. If directory is NULL, * the current directory is assumed. * * Requires: * \li "key" is a valid key. * \li "type" is DST_TYPE_PUBLIC, DST_TYPE_PRIVATE, or the bitwise union * * Returns: * \li ISC_R_SUCCESS * \li any other result indicates failure */isc_result_tdst_key_fromdns(dns_name_t *name, dns_rdataclass_t rdclass, isc_buffer_t *source, isc_mem_t *mctx, dst_key_t **keyp);/*%< * Converts a DNS KEY record into a DST key. * * Requires: * \li "name" is a valid absolute dns name. * \li "source" is a valid buffer. There must be at least 4 bytes available.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -