base32.c File Reference

#include <config.h>
#include <isc/base32.h>
#include <isc/buffer.h>
#include <isc/lex.h>
#include <isc/region.h>
#include <isc/string.h>
#include <isc/util.h>

Go to the source code of this file.

Data Structures

struct  base32_decode_ctx_t
 State of a base32 decoding process in progress. More...

Defines

#define RETERR(x)

Functions

static isc_result_t base32_totext (isc_region_t *source, int wordlength, const char *wordbreak, isc_buffer_t *target, const char base[], char pad)
isc_result_t isc_base32_totext (isc_region_t *source, int wordlength, const char *wordbreak, isc_buffer_t *target)
isc_result_t isc_base32hex_totext (isc_region_t *source, int wordlength, const char *wordbreak, isc_buffer_t *target)
isc_result_t isc_base32hexnp_totext (isc_region_t *source, int wordlength, const char *wordbreak, isc_buffer_t *target)
 Convert data into base32 encoded text.
static void base32_decode_init (base32_decode_ctx_t *ctx, int length, const char base[], isc_boolean_t pad, isc_buffer_t *target)
static isc_result_t base32_decode_char (base32_decode_ctx_t *ctx, int c)
static isc_result_t base32_decode_finish (base32_decode_ctx_t *ctx)
static isc_result_t base32_tobuffer (isc_lex_t *lexer, const char base[], isc_boolean_t pad, isc_buffer_t *target, int length)
isc_result_t isc_base32_tobuffer (isc_lex_t *lexer, isc_buffer_t *target, int length)
isc_result_t isc_base32hex_tobuffer (isc_lex_t *lexer, isc_buffer_t *target, int length)
isc_result_t isc_base32hexnp_tobuffer (isc_lex_t *lexer, isc_buffer_t *target, int length)
 Convert text encoded in base32, base32hex, or base32hex non-padded from a lexer context into data.
static isc_result_t base32_decodestring (const char *cstr, const char base[], isc_boolean_t pad, isc_buffer_t *target)
isc_result_t isc_base32_decodestring (const char *cstr, isc_buffer_t *target)
isc_result_t isc_base32hex_decodestring (const char *cstr, isc_buffer_t *target)
isc_result_t isc_base32hexnp_decodestring (const char *cstr, isc_buffer_t *target)
 Decode a null-terminated string in base32, base32hex, or base32hex non-padded.
static isc_result_t base32_decoderegion (isc_region_t *source, const char base[], isc_boolean_t pad, isc_buffer_t *target)
isc_result_t isc_base32_decoderegion (isc_region_t *source, isc_buffer_t *target)
isc_result_t isc_base32hex_decoderegion (isc_region_t *source, isc_buffer_t *target)
isc_result_t isc_base32hexnp_decoderegion (isc_region_t *source, isc_buffer_t *target)
 Decode a packed (no white space permitted) region in base32, base32hex or base32hex non-padded.
static isc_result_t str_totext (const char *source, isc_buffer_t *target)
static isc_result_t mem_tobuffer (isc_buffer_t *target, void *base, unsigned int length)

Variables

static const char base32 []
static const char base32hex []


Detailed Description

Definition in file base32.c.


Define Documentation

#define RETERR (  ) 

Value:

do { \
        isc_result_t _r = (x); \
        if (_r != ISC_R_SUCCESS) \
                return (_r); \
        } while (0)

Definition at line 30 of file base32.c.

Referenced by add_rdata_to_list(), atob_tobuffer(), base32_decode_char(), base32_decode_finish(), base32_decoderegion(), base32_decodestring(), base32_tobuffer(), base32_totext(), base64_decode_char(), btoa_totext(), buildquery(), byte_atob(), configure_staticstub(), digest_afsdb(), digest_ch_a(), digest_in_kx(), digest_in_srv(), digest_mx(), digest_rp(), digest_soa(), dns_cert_fromtext(), dns_dnssec_findmatchingkeys(), dns_dnssec_findzonekeys2(), dns_dnssec_keylistfromrdataset(), dns_dnssec_signmessage(), dns_dnssec_updatekeys(), dns_dnssec_verifymessage(), dns_ds_buildrdata(), dns_dsdigest_fromtext(), dns_hashalg_fromtext(), dns_nsec_build(), dns_rcode_fromtext(), dns_secalg_fromtext(), dns_secproto_fromtext(), dns_tkey_builddhquery(), dns_tkey_buildgssquery(), dns_tkey_gssnegotiate(), dns_tkey_processdeleteresponse(), dns_tkey_processdhresponse(), dns_tkey_processgssresponse(), dns_tkey_processquery(), dns_tsigrcode_fromtext(), dns_ttl_totext2(), dst_gssapi_acceptctx(), dst_gssapi_initctx(), dst_key_fromgssapi(), dst_key_fromnamedfile(), dst_key_privatefrombuffer(), dst_lib_init2(), fromstruct_afsdb(), fromstruct_any_tsig(), fromstruct_caa(), fromstruct_cdnskey(), fromstruct_cds(), fromstruct_cert(), fromstruct_ch_a(), fromstruct_dlv(), fromstruct_dnskey(), fromstruct_ds(), fromstruct_gpos(), fromstruct_hinfo(), fromstruct_hip(), fromstruct_in_a6(), fromstruct_in_kx(), fromstruct_in_px(), fromstruct_in_srv(), fromstruct_in_wks(), fromstruct_ipseckey(), fromstruct_isdn(), fromstruct_key(), fromstruct_keydata(), fromstruct_l32(), fromstruct_l64(), fromstruct_loc(), fromstruct_lp(), fromstruct_minfo(), fromstruct_mx(), fromstruct_naptr(), fromstruct_nid(), fromstruct_nsec(), fromstruct_nsec3(), fromstruct_nsec3param(), fromstruct_nxt(), fromstruct_rp(), fromstruct_rrsig(), fromstruct_rt(), fromstruct_sig(), fromstruct_soa(), fromstruct_sshfp(), fromstruct_tkey(), fromstruct_tlsa(), fromstruct_uri(), fromstruct_x25(), fromtext_afsdb(), fromtext_any_tsig(), fromtext_caa(), fromtext_cdnskey(), fromtext_cds(), fromtext_cert(), fromtext_ch_a(), fromtext_cname(), fromtext_dlv(), fromtext_dname(), fromtext_dnskey(), fromtext_ds(), fromtext_eui48(), fromtext_eui64(), fromtext_gpos(), fromtext_hinfo(), fromtext_hip(), fromtext_hs_a(), fromtext_in_a(), fromtext_in_a6(), fromtext_in_aaaa(), fromtext_in_apl(), fromtext_in_kx(), fromtext_in_nsap(), fromtext_in_nsap_ptr(), fromtext_in_px(), fromtext_in_srv(), fromtext_in_wks(), fromtext_ipseckey(), fromtext_isdn(), fromtext_key(), fromtext_keydata(), fromtext_l32(), fromtext_l64(), fromtext_loc(), fromtext_lp(), fromtext_mb(), fromtext_md(), fromtext_mf(), fromtext_mg(), fromtext_minfo(), fromtext_mr(), fromtext_mx(), fromtext_naptr(), fromtext_nid(), fromtext_ns(), fromtext_nsec(), fromtext_nsec3(), fromtext_nsec3param(), fromtext_nxt(), fromtext_ptr(), fromtext_rp(), fromtext_rrsig(), fromtext_rt(), fromtext_sig(), fromtext_soa(), fromtext_spf(), fromtext_sshfp(), fromtext_tkey(), fromtext_tlsa(), fromtext_txt(), fromtext_uri(), fromtext_x25(), fromwire_any_tsig(), fromwire_caa(), fromwire_cdnskey(), fromwire_ch_a(), fromwire_dnskey(), fromwire_gpos(), fromwire_hinfo(), fromwire_hip(), fromwire_in_a6(), fromwire_in_kx(), fromwire_in_nsap(), fromwire_in_px(), fromwire_in_srv(), fromwire_ipseckey(), fromwire_isdn(), fromwire_key(), fromwire_lp(), fromwire_minfo(), fromwire_mx(), fromwire_naptr(), fromwire_nsec(), fromwire_nsec3(), fromwire_nsec3param(), fromwire_nxt(), fromwire_rp(), fromwire_rrsig(), fromwire_sig(), fromwire_soa(), fromwire_tkey(), hex_decode_char(), isc_base64_decodestring(), isc_base64_tobuffer(), isc_base64_totext(), isc_hex_decodestring(), isc_hex_tobuffer(), isc_hex_totext(), ns_tkeyctx_fromconfig(), ns_zone_configure(), process_dhtkey(), process_gsstkey(), publish_key(), question_totext(), rdataset_totext(), remove_key(), tostruct_afsdb(), tostruct_any_tsig(), tostruct_ch_a(), tostruct_cname(), tostruct_dname(), tostruct_in_a6(), tostruct_in_kx(), tostruct_in_nsap_ptr(), tostruct_in_px(), tostruct_in_srv(), tostruct_ipseckey(), tostruct_lp(), tostruct_mb(), tostruct_md(), tostruct_mf(), tostruct_mg(), tostruct_minfo(), tostruct_mr(), tostruct_mx(), tostruct_ns(), tostruct_nsec(), tostruct_nxt(), tostruct_ptr(), tostruct_rp(), tostruct_rrsig(), tostruct_rt(), tostruct_sig(), tostruct_soa(), tostruct_tkey(), totext_afsdb(), totext_any_tsig(), totext_caa(), totext_cdnskey(), totext_cds(), totext_cert(), totext_ch_a(), totext_dlv(), totext_dnskey(), totext_ds(), totext_gpos(), totext_hinfo(), totext_hip(), totext_in_a6(), totext_in_apl(), totext_in_dhcid(), totext_in_kx(), totext_in_nsap(), totext_in_px(), totext_in_srv(), totext_in_wks(), totext_ipseckey(), totext_isdn(), totext_key(), totext_keydata(), totext_l32(), totext_l64(), totext_lp(), totext_minfo(), totext_mx(), totext_naptr(), totext_nid(), totext_nsec(), totext_nsec3(), totext_nsec3param(), totext_nxt(), totext_openpgpkey(), totext_opt(), totext_rp(), totext_rrsig(), totext_rt(), totext_sig(), totext_soa(), totext_spf(), totext_sshfp(), totext_tkey(), totext_tlsa(), totext_txt(), totext_uri(), towire_any_tsig(), towire_ch_a(), towire_in_a6(), towire_in_kx(), towire_in_px(), towire_in_srv(), towire_minfo(), towire_mx(), towire_naptr(), towire_nsec(), towire_nxt(), towire_rp(), towire_rrsig(), towire_sig(), towire_soa(), towire_tkey(), and unknown_fromtext().


Function Documentation

static isc_result_t str_totext ( const char *  source,
isc_buffer_t target 
) [static]

These static functions are also present in lib/dns/rdata.c. I'm not sure where they should go. -- bwelling

Definition at line 398 of file base32.c.

References isc_region::base, isc_buffer_add, isc_buffer_availableregion, ISC_R_NOSPACE, ISC_R_SUCCESS, and isc_region::length.

Referenced by base32_totext(), btoa_totext(), dns_mnemonic_totext(), dns_rdataclass_totext(), dns_rdatatype_totext(), isc_base64_totext(), isc_hex_totext(), ncache_summary(), rdataset_totext(), totext_afsdb(), totext_any_tsig(), totext_caa(), totext_cdnskey(), totext_cds(), totext_cert(), totext_ch_a(), totext_dlv(), totext_dnskey(), totext_ds(), totext_eui48(), totext_eui64(), totext_gpos(), totext_hinfo(), totext_hip(), totext_in_a6(), totext_in_apl(), totext_in_dhcid(), totext_in_kx(), totext_in_nsap(), totext_in_px(), totext_in_srv(), totext_in_wks(), totext_ipseckey(), totext_isdn(), totext_key(), totext_keydata(), totext_l32(), totext_l64(), totext_loc(), totext_lp(), totext_minfo(), totext_mx(), totext_naptr(), totext_nid(), totext_nsec(), totext_nsec3(), totext_nsec3param(), totext_nxt(), totext_openpgpkey(), totext_opt(), totext_rp(), totext_rrsig(), totext_rt(), totext_sig(), totext_soa(), totext_spf(), totext_sshfp(), totext_tkey(), totext_tlsa(), totext_txt(), totext_uri(), and unknown_totext().

static isc_result_t mem_tobuffer ( isc_buffer_t target,
void *  base,
unsigned int  length 
) [static]

These static functions are also present in lib/dns/rdata.c. I'm not sure where they should go. -- bwelling

Definition at line 414 of file base32.c.

References isc_region::base, isc_buffer_add, isc_buffer_availableregion, ISC_R_NOSPACE, ISC_R_SUCCESS, and isc_region::length.

Referenced by base32_decode_char(), base64_decode_char(), fromstruct_any_tsig(), fromstruct_cdnskey(), fromstruct_cds(), fromstruct_cert(), fromstruct_dlv(), fromstruct_dnskey(), fromstruct_ds(), fromstruct_eui48(), fromstruct_eui64(), fromstruct_gpos(), fromstruct_hinfo(), fromstruct_hip(), fromstruct_in_a6(), fromstruct_in_aaaa(), fromstruct_in_dhcid(), fromstruct_in_nsap(), fromstruct_in_wks(), fromstruct_ipseckey(), fromstruct_isdn(), fromstruct_key(), fromstruct_keydata(), fromstruct_l64(), fromstruct_naptr(), fromstruct_nid(), fromstruct_nsec(), fromstruct_nsec3(), fromstruct_nsec3param(), fromstruct_null(), fromstruct_nxt(), fromstruct_openpgpkey(), fromstruct_opt(), fromstruct_rrsig(), fromstruct_sig(), fromstruct_spf(), fromstruct_sshfp(), fromstruct_tkey(), fromstruct_tlsa(), fromstruct_txt(), fromstruct_unspec(), fromstruct_uri(), fromstruct_x25(), fromtext_caa(), fromtext_cdnskey(), fromtext_cds(), fromtext_cert(), fromtext_dnskey(), fromtext_ds(), fromtext_eui48(), fromtext_eui64(), fromtext_in_a6(), fromtext_in_apl(), fromtext_in_nsap(), fromtext_in_wks(), fromtext_key(), fromtext_keydata(), fromtext_l64(), fromtext_loc(), fromtext_nid(), fromtext_nsec(), fromtext_nsec3(), fromtext_nxt(), fromtext_rrsig(), fromtext_sig(), fromwire_any_tsig(), fromwire_caa(), fromwire_cdnskey(), fromwire_cds(), fromwire_cert(), fromwire_dlv(), fromwire_dnskey(), fromwire_ds(), fromwire_eui48(), fromwire_eui64(), fromwire_hip(), fromwire_in_a6(), fromwire_in_apl(), fromwire_in_dhcid(), fromwire_in_kx(), fromwire_in_nsap(), fromwire_in_px(), fromwire_in_srv(), fromwire_ipseckey(), fromwire_key(), fromwire_keydata(), fromwire_l32(), fromwire_l64(), fromwire_loc(), fromwire_lp(), fromwire_mx(), fromwire_naptr(), fromwire_nid(), fromwire_nsec(), fromwire_nsec3(), fromwire_nsec3param(), fromwire_null(), fromwire_nxt(), fromwire_openpgpkey(), fromwire_rrsig(), fromwire_sig(), fromwire_sshfp(), fromwire_tkey(), fromwire_tlsa(), fromwire_unspec(), fromwire_uri(), hex_decode_char(), towire_any_tsig(), towire_caa(), towire_cdnskey(), towire_cds(), towire_cert(), towire_dlv(), towire_dnskey(), towire_ds(), towire_eui48(), towire_eui64(), towire_gpos(), towire_hinfo(), towire_hip(), towire_in_a6(), towire_in_apl(), towire_in_dhcid(), towire_in_kx(), towire_in_nsap(), towire_in_px(), towire_in_srv(), towire_in_wks(), towire_ipseckey(), towire_isdn(), towire_key(), towire_keydata(), towire_l32(), towire_l64(), towire_loc(), towire_lp(), towire_mx(), towire_naptr(), towire_nid(), towire_nsec(), towire_nsec3(), towire_nsec3param(), towire_null(), towire_nxt(), towire_openpgpkey(), towire_opt(), towire_rrsig(), towire_sig(), towire_sshfp(), towire_tkey(), towire_tlsa(), towire_unspec(), towire_uri(), and towire_x25().

static isc_result_t base32_totext ( isc_region_t source,
int  wordlength,
const char *  wordbreak,
isc_buffer_t target,
const char  base[],
char  pad 
) [static]

Definition at line 56 of file base32.c.

References isc_region::base, ISC_R_SUCCESS, isc_region_consume, isc_region::length, RETERR, and str_totext().

Referenced by isc_base32_totext(), isc_base32hex_totext(), and isc_base32hexnp_totext().

isc_result_t isc_base32_totext ( isc_region_t source,
int  wordlength,
const char *  wordbreak,
isc_buffer_t target 
)

Definition at line 121 of file base32.c.

References base32, and base32_totext().

isc_result_t isc_base32hex_totext ( isc_region_t source,
int  wordlength,
const char *  wordbreak,
isc_buffer_t target 
)

Definition at line 129 of file base32.c.

References base32_totext(), and base32hex.

Referenced by checknext().

isc_result_t isc_base32hexnp_totext ( isc_region_t source,
int  wordlength,
const char *  wordbreak,
isc_buffer_t target 
)

Convert data into base32 encoded text.

Notes:

Requires: Ensures:

Definition at line 137 of file base32.c.

References base32_totext(), and base32hex.

Referenced by dns_nsec3_hashname(), and totext_nsec3().

static void base32_decode_init ( base32_decode_ctx_t ctx,
int  length,
const char  base[],
isc_boolean_t  pad,
isc_buffer_t target 
) [inline, static]

Definition at line 159 of file base32.c.

References base32_decode_ctx_t::base, base32_decode_ctx_t::digits, ISC_FALSE, base32_decode_ctx_t::length, base32_decode_ctx_t::pad, base32_decode_ctx_t::seen_32, base32_decode_ctx_t::seen_end, and base32_decode_ctx_t::target.

Referenced by base32_decoderegion(), base32_decodestring(), and base32_tobuffer().

static isc_result_t base32_decode_char ( base32_decode_ctx_t ctx,
int  c 
) [inline, static]

Definition at line 172 of file base32.c.

References base32_decode_ctx_t::base, base32_decode_ctx_t::digits, ISC_R_BADBASE32, ISC_R_SUCCESS, ISC_TRUE, base32_decode_ctx_t::length, mem_tobuffer(), base32_decode_ctx_t::pad, RETERR, s, base32_decode_ctx_t::seen_32, base32_decode_ctx_t::seen_end, base32_decode_ctx_t::target, and base32_decode_ctx_t::val.

Referenced by base32_decode_finish(), base32_decoderegion(), base32_decodestring(), and base32_tobuffer().

static isc_result_t base32_decode_finish ( base32_decode_ctx_t ctx  )  [inline, static]

Definition at line 267 of file base32.c.

References base32_decode_char(), base32_decode_ctx_t::digits, ISC_R_BADBASE32, ISC_R_SUCCESS, ISC_R_UNEXPECTEDEND, ISC_TRUE, base32_decode_ctx_t::length, base32_decode_ctx_t::pad, and RETERR.

Referenced by base32_decoderegion(), base32_decodestring(), and base32_tobuffer().

static isc_result_t base32_tobuffer ( isc_lex_t lexer,
const char  base[],
isc_boolean_t  pad,
isc_buffer_t target,
int  length 
) [static]

Definition at line 286 of file base32.c.

References isc_tokenvalue_t::as_textregion, isc_textregion::base, base32_decode_char(), base32_decode_finish(), base32_decode_init(), ISC_FALSE, isc_lex_getmastertoken(), isc_lex_ungettoken(), ISC_R_SUCCESS, isc_tokentype_string, ISC_TRUE, isc_textregion::length, base32_decode_ctx_t::length, RETERR, base32_decode_ctx_t::seen_end, token, isc_token::type, and isc_token::value.

Referenced by isc_base32_tobuffer(), isc_base32hex_tobuffer(), and isc_base32hexnp_tobuffer().

isc_result_t isc_base32_tobuffer ( isc_lex_t lexer,
isc_buffer_t target,
int  length 
)

Definition at line 318 of file base32.c.

References base32, base32_tobuffer(), and ISC_TRUE.

isc_result_t isc_base32hex_tobuffer ( isc_lex_t lexer,
isc_buffer_t target,
int  length 
)

Definition at line 323 of file base32.c.

References base32_tobuffer(), base32hex, and ISC_TRUE.

isc_result_t isc_base32hexnp_tobuffer ( isc_lex_t lexer,
isc_buffer_t target,
int  length 
)

Convert text encoded in base32, base32hex, or base32hex non-padded from a lexer context into data.

Requires:

Ensures:

Definition at line 328 of file base32.c.

References base32_tobuffer(), base32hex, and ISC_FALSE.

static isc_result_t base32_decodestring ( const char *  cstr,
const char  base[],
isc_boolean_t  pad,
isc_buffer_t target 
) [static]

Definition at line 333 of file base32.c.

References base32_decode_char(), base32_decode_finish(), base32_decode_init(), ISC_R_SUCCESS, and RETERR.

Referenced by isc_base32_decodestring(), isc_base32hex_decodestring(), and isc_base32hexnp_decodestring().

isc_result_t isc_base32_decodestring ( const char *  cstr,
isc_buffer_t target 
)

Definition at line 352 of file base32.c.

References base32, base32_decodestring(), and ISC_TRUE.

isc_result_t isc_base32hex_decodestring ( const char *  cstr,
isc_buffer_t target 
)

Definition at line 357 of file base32.c.

References base32_decodestring(), base32hex, and ISC_TRUE.

isc_result_t isc_base32hexnp_decodestring ( const char *  cstr,
isc_buffer_t target 
)

Decode a null-terminated string in base32, base32hex, or base32hex non-padded.

Requires:

Returns: Other error returns are any possible error code from:

Definition at line 362 of file base32.c.

References base32_decodestring(), base32hex, and ISC_FALSE.

Referenced by fromtext_nsec3().

static isc_result_t base32_decoderegion ( isc_region_t source,
const char  base[],
isc_boolean_t  pad,
isc_buffer_t target 
) [static]

Definition at line 367 of file base32.c.

References isc_region::base, base32_decode_char(), base32_decode_finish(), base32_decode_init(), ISC_R_SUCCESS, isc_region_consume, isc_region::length, and RETERR.

Referenced by isc_base32_decoderegion(), isc_base32hex_decoderegion(), and isc_base32hexnp_decoderegion().

isc_result_t isc_base32_decoderegion ( isc_region_t source,
isc_buffer_t target 
)

Definition at line 383 of file base32.c.

References base32, base32_decoderegion(), and ISC_TRUE.

isc_result_t isc_base32hex_decoderegion ( isc_region_t source,
isc_buffer_t target 
)

Definition at line 388 of file base32.c.

References base32_decoderegion(), base32hex, and ISC_TRUE.

Referenced by dns_nsec3_noexistnodata(), nsec3clean(), and record_found().

isc_result_t isc_base32hexnp_decoderegion ( isc_region_t source,
isc_buffer_t target 
)

Decode a packed (no white space permitted) region in base32, base32hex or base32hex non-padded.

Requires:

Returns:

Definition at line 393 of file base32.c.

References base32_decoderegion(), base32hex, and ISC_FALSE.

Referenced by checkowner_nsec3(), and isdelegation().


Variable Documentation

const char base32[] [static]

Initial value:

         "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=abcdefghijklmnopqrstuvwxyz234567"

Definition at line 50 of file base32.c.

Referenced by isc_base32_decoderegion(), isc_base32_decodestring(), isc_base32_tobuffer(), and isc_base32_totext().

const char base32hex[] [static]

Initial value:

        "0123456789ABCDEFGHIJKLMNOPQRSTUV=0123456789abcdefghijklmnopqrstuv"

Definition at line 52 of file base32.c.

Referenced by isc_base32hex_decoderegion(), isc_base32hex_decodestring(), isc_base32hex_tobuffer(), isc_base32hex_totext(), isc_base32hexnp_decoderegion(), isc_base32hexnp_decodestring(), isc_base32hexnp_tobuffer(), and isc_base32hexnp_totext().


Generated on Tue Apr 28 17:41:14 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha