#include <config.h>
#include <isc/base64.h>
#include <isc/dir.h>
#include <isc/fsaccess.h>
#include <isc/lex.h>
#include <isc/mem.h>
#include <isc/stdtime.h>
#include <isc/string.h>
#include <isc/util.h>
#include <isc/file.h>
#include <dns/time.h>
#include <dns/log.h>
#include "dst_internal.h"
#include "dst_parse.h"
#include "dst/result.h"
Go to the source code of this file.
Data Structures | |
struct | parse_map |
Defines | |
#define | DST_AS_STR(t) ((t).value.as_textregion.base) |
Principal Author: Brian Wellington
| |
#define | PRIVATE_KEY_STR "Private-key-format:" |
#define | ALGORITHM_STR "Algorithm:" |
#define | TIMING_NTAGS (DST_MAX_TIMES + 1) |
#define | NUMERIC_NTAGS (DST_MAX_NUMERIC + 1) |
#define | NEXTTOKEN(lex, opt, token) |
#define | READLINE(lex, opt, token) |
Functions | |
static int | find_value (const char *s, const unsigned int alg) |
static const char * | find_tag (const int value) |
static int | find_metadata (const char *s, const char *tags[], int ntags) |
static int | find_timedata (const char *s) |
static int | find_numericdata (const char *s) |
static int | check_rsa (const dst_private_t *priv, isc_boolean_t external) |
static int | check_dh (const dst_private_t *priv) |
static int | check_dsa (const dst_private_t *priv, isc_boolean_t external) |
static int | check_gost (const dst_private_t *priv, isc_boolean_t external) |
static int | check_ecdsa (const dst_private_t *priv, isc_boolean_t external) |
static int | check_hmac_md5 (const dst_private_t *priv, isc_boolean_t old) |
static int | check_hmac_sha (const dst_private_t *priv, unsigned int ntags, unsigned int alg) |
static int | check_data (const dst_private_t *priv, const unsigned int alg, isc_boolean_t old, isc_boolean_t external) |
void | dst__privstruct_free (dst_private_t *priv, isc_mem_t *mctx) |
isc_result_t | dst__privstruct_parse (dst_key_t *key, unsigned int alg, isc_lex_t *lex, isc_mem_t *mctx, dst_private_t *priv) |
isc_result_t | dst__privstruct_writefile (const dst_key_t *key, const dst_private_t *priv, const char *directory) |
Variables | |
static const char * | timetags [TIMING_NTAGS] |
static const char * | numerictags [NUMERIC_NTAGS] |
static struct parse_map | map [] |
Definition in file dst_parse.c.
#define DST_AS_STR | ( | t | ) | ((t).value.as_textregion.base) |
Principal Author: Brian Wellington
Definition at line 56 of file dst_parse.c.
#define PRIVATE_KEY_STR "Private-key-format:" |
Definition at line 58 of file dst_parse.c.
Referenced by dst__privstruct_parse(), and dst__privstruct_writefile().
#define ALGORITHM_STR "Algorithm:" |
Definition at line 59 of file dst_parse.c.
Referenced by dst__privstruct_parse(), and dst__privstruct_writefile().
#define TIMING_NTAGS (DST_MAX_TIMES + 1) |
Definition at line 61 of file dst_parse.c.
Referenced by dst__privstruct_parse(), dst__privstruct_writefile(), and find_timedata().
#define NUMERIC_NTAGS (DST_MAX_NUMERIC + 1) |
Definition at line 72 of file dst_parse.c.
Referenced by dst__privstruct_parse(), dst__privstruct_writefile(), and find_numericdata().
#define NEXTTOKEN | ( | lex, | |||
opt, | |||||
token | ) |
Value:
do { \ ret = isc_lex_gettoken(lex, opt, token); \ if (ret != ISC_R_SUCCESS) \ goto fail; \ } while (0)
#define READLINE | ( | lex, | |||
opt, | |||||
token | ) |
Value:
do { \ ret = isc_lex_gettoken(lex, opt, token); \ if (ret == ISC_R_EOF) \ break; \ else if (ret != ISC_R_SUCCESS) \ goto fail; \ } while ((*token).type != isc_tokentype_eol)
Referenced by dst__privstruct_parse().
static int find_value | ( | const char * | s, | |
const unsigned int | alg | |||
) | [static] |
Definition at line 137 of file dst_parse.c.
References parse_map::tag, TAG_ALG, and parse_map::value.
Referenced by dst__privstruct_parse().
static const char* find_tag | ( | const int | value | ) | [static] |
Definition at line 149 of file dst_parse.c.
References parse_map::tag.
Referenced by dst__privstruct_writefile().
static int find_metadata | ( | const char * | s, | |
const char * | tags[], | |||
int | ntags | |||
) | [static] |
static int find_timedata | ( | const char * | s | ) | [static] |
Definition at line 173 of file dst_parse.c.
References find_metadata(), timetags, and TIMING_NTAGS.
Referenced by dst__privstruct_parse().
static int find_numericdata | ( | const char * | s | ) | [static] |
Definition at line 178 of file dst_parse.c.
References find_metadata(), NUMERIC_NTAGS, and numerictags.
Referenced by dst__privstruct_parse().
static int check_rsa | ( | const dst_private_t * | priv, | |
isc_boolean_t | external | |||
) | [static] |
Definition at line 183 of file dst_parse.c.
References DST_ALG_RSAMD5, dst_private::elements, ISC_FALSE, ISC_TRUE, dst_private::nelements, RSA_NTAGS, TAG, dst_private_element::tag, TAG_RSA_COEFFICIENT, TAG_RSA_ENGINE, TAG_RSA_EXPONENT1, TAG_RSA_EXPONENT2, TAG_RSA_LABEL, TAG_RSA_MODULUS, TAG_RSA_PRIME1, TAG_RSA_PRIME2, TAG_RSA_PRIVATEEXPONENT, TAG_RSA_PUBLICEXPONENT, and TAG_SHIFT.
Referenced by check_data().
static int check_dh | ( | const dst_private_t * | priv | ) | [static] |
Definition at line 225 of file dst_parse.c.
References DH_NTAGS, DST_ALG_DH, dst_private::elements, dst_private::nelements, TAG, and dst_private_element::tag.
Referenced by check_data().
static int check_dsa | ( | const dst_private_t * | priv, | |
isc_boolean_t | external | |||
) | [static] |
Definition at line 240 of file dst_parse.c.
References DSA_NTAGS, DST_ALG_DSA, dst_private::elements, dst_private::nelements, TAG, and dst_private_element::tag.
Referenced by check_data().
static int check_gost | ( | const dst_private_t * | priv, | |
isc_boolean_t | external | |||
) | [static] |
Definition at line 260 of file dst_parse.c.
References DST_ALG_ECCGOST, dst_private::elements, GOST_NTAGS, dst_private::nelements, TAG, and dst_private_element::tag.
Referenced by check_data().
static int check_ecdsa | ( | const dst_private_t * | priv, | |
isc_boolean_t | external | |||
) | [static] |
Definition at line 274 of file dst_parse.c.
References DST_ALG_ECDSA256, ECDSA_NTAGS, dst_private::elements, ISC_FALSE, ISC_TRUE, dst_private::nelements, TAG, dst_private_element::tag, TAG_ECDSA_ENGINE, TAG_ECDSA_LABEL, TAG_ECDSA_PRIVATEKEY, and TAG_SHIFT.
Referenced by check_data().
static int check_hmac_md5 | ( | const dst_private_t * | priv, | |
isc_boolean_t | old | |||
) | [static] |
Definition at line 306 of file dst_parse.c.
References DST_ALG_HMACMD5, dst_private::elements, HMACMD5_NTAGS, dst_private::nelements, OLD_HMACMD5_NTAGS, TAG, dst_private_element::tag, and TAG_HMACMD5_KEY.
Referenced by check_data().
static int check_hmac_sha | ( | const dst_private_t * | priv, | |
unsigned int | ntags, | |||
unsigned int | alg | |||
) | [static] |
Definition at line 333 of file dst_parse.c.
References dst_private::elements, dst_private::nelements, TAG, and dst_private_element::tag.
Referenced by check_data().
static int check_data | ( | const dst_private_t * | priv, | |
const unsigned int | alg, | |||
isc_boolean_t | old, | |||
isc_boolean_t | external | |||
) | [static] |
Definition at line 350 of file dst_parse.c.
References check_dh(), check_dsa(), check_ecdsa(), check_gost(), check_hmac_md5(), check_hmac_sha(), check_rsa(), DST_ALG_DH, DST_ALG_DSA, DST_ALG_ECCGOST, DST_ALG_ECDSA256, DST_ALG_ECDSA384, DST_ALG_HMACMD5, DST_ALG_HMACSHA1, DST_ALG_HMACSHA224, DST_ALG_HMACSHA256, DST_ALG_HMACSHA384, DST_ALG_HMACSHA512, DST_ALG_NSEC3DSA, DST_ALG_NSEC3RSASHA1, DST_ALG_RSAMD5, DST_ALG_RSASHA1, DST_ALG_RSASHA256, DST_ALG_RSASHA512, DST_R_UNSUPPORTEDALG, HMACSHA1_NTAGS, HMACSHA224_NTAGS, HMACSHA256_NTAGS, HMACSHA384_NTAGS, and HMACSHA512_NTAGS.
Referenced by dst__privstruct_parse(), and dst__privstruct_writefile().
void dst__privstruct_free | ( | dst_private_t * | priv, | |
isc_mem_t * | mctx | |||
) |
Definition at line 389 of file dst_parse.c.
References dst_private_element::data, dst_private::elements, isc_mem_put, MAXFIELDSIZE, and dst_private::nelements.
Referenced by dst__privstruct_parse(), hmacmd5_parse(), hmacsha1_parse(), hmacsha224_parse(), hmacsha256_parse(), hmacsha384_parse(), and hmacsha512_parse().
isc_result_t dst__privstruct_parse | ( | dst_key_t * | key, | |
unsigned int | alg, | |||
isc_lex_t * | lex, | |||
isc_mem_t * | mctx, | |||
dst_private_t * | priv | |||
) |
Definition at line 404 of file dst_parse.c.
References ALGORITHM_STR, isc_tokenvalue_t::as_ulong, isc_region::base, check_data(), dst_private_element::data, dns_time32_fromtext(), dst__privstruct_free(), DST_AS_STR, dst_key_alg(), dst_key_setnum(), dst_key_setprivateformat(), dst_key_settime(), DST_MAJOR_VERSION, DST_MINOR_VERSION, DST_R_INVALIDPRIVATEKEY, dst_private::elements, find_numericdata(), find_timedata(), find_value(), INSIST, isc_base64_tobuffer(), isc_buffer_init, isc_buffer_usedregion, ISC_FALSE, isc_lex_gettoken(), ISC_LEXOPT_EOL, ISC_LEXOPT_NUMBER, isc_mem_get, isc_mem_put, ISC_R_EOF, ISC_R_SUCCESS, isc_tokentype_eol, isc_tokentype_number, isc_tokentype_string, ISC_TRUE, isc_region::length, dst_private_element::length, MAXFIELDS, MAXFIELDSIZE, dst_private::nelements, NEXTTOKEN, NUMERIC_NTAGS, PRIVATE_KEY_STR, r, READLINE, REQUIRE, dst_private_element::tag, parse_map::tag, TIMING_NTAGS, token, isc_token::type, and isc_token::value.
Referenced by hmacmd5_parse(), hmacsha1_parse(), hmacsha224_parse(), hmacsha256_parse(), hmacsha384_parse(), and hmacsha512_parse().
isc_result_t dst__privstruct_writefile | ( | const dst_key_t * | key, | |
const dst_private_t * | priv, | |||
const char * | directory | |||
) |
Definition at line 611 of file dst_parse.c.
References ALGORITHM_STR, isc_region::base, buffer, check_data(), dst_private_element::data, dns_lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_DNSSEC, dns_time32_totext(), DST_ALG_DH, DST_ALG_DSA, DST_ALG_ECCGOST, DST_ALG_ECDSA256, DST_ALG_ECDSA384, DST_ALG_HMACMD5, DST_ALG_HMACSHA1, DST_ALG_HMACSHA224, DST_ALG_HMACSHA256, DST_ALG_HMACSHA384, DST_ALG_HMACSHA512, DST_ALG_NSEC3DSA, DST_ALG_NSEC3RSASHA1, DST_ALG_RSAMD5, DST_ALG_RSASHA1, DST_ALG_RSASHA256, DST_ALG_RSASHA512, dst_key_alg(), dst_key_buildfilename(), dst_key_getnum(), dst_key_getprivateformat(), dst_key_gettime(), DST_MAJOR_VERSION, DST_MINOR_VERSION, DST_R_INVALIDPRIVATEKEY, DST_R_WRITEERROR, DST_TYPE_PRIVATE, dst_private::elements, find_tag(), isc_base64_totext(), isc_buffer_init, isc_buffer_usedregion, ISC_DIR_NAMEMAX, ISC_FALSE, isc_file_mode(), isc_fsaccess_add(), ISC_FSACCESS_OWNER, ISC_FSACCESS_READ, isc_fsaccess_set(), ISC_FSACCESS_WRITE, ISC_LOG_WARNING, isc_log_write(), ISC_R_SUCCESS, dst_private_element::length, isc_region::length, MAXFIELDSIZE, dst_private::nelements, NUMERIC_NTAGS, numerictags, PRIVATE_KEY_STR, r, REQUIRE, s, dst_private_element::tag, timetags, TIMING_NTAGS, and parse_map::value.
Referenced by hmacmd5_tofile(), hmacsha1_tofile(), hmacsha224_tofile(), hmacsha256_tofile(), hmacsha384_tofile(), and hmacsha512_tofile().
const char* timetags[TIMING_NTAGS] [static] |
Initial value:
{ "Created:", "Publish:", "Activate:", "Revoke:", "Inactive:", "Delete:", "DSPublish:" }
Definition at line 62 of file dst_parse.c.
Referenced by dst__privstruct_writefile(), and find_timedata().
const char* numerictags[NUMERIC_NTAGS] [static] |
Initial value:
{ "Predecessor:", "Successor:", "MaxTTL:", "RollPeriod:" }
Definition at line 73 of file dst_parse.c.
Referenced by dst__privstruct_writefile(), and find_numericdata().
Definition at line 85 of file dst_parse.c.
Referenced by cfg_map_count(), cfg_map_get(), cfg_parse_mapbody(), cfg_parser_mapadd(), check_dns64(), configure_view(), and ns_server_showzone().