|
| 1 | +/* |
| 2 | + * Copyright (c) 2014, Vsevolod Stakhov |
| 3 | + * |
| 4 | + * All rights reserved. |
| 5 | + * |
| 6 | + * Redistribution and use in source and binary forms, with or without |
| 7 | + * modification, are permitted provided that the following conditions are met: |
| 8 | + * * Redistributions of source code must retain the above copyright |
| 9 | + * notice, this list of conditions and the following disclaimer. |
| 10 | + * * Redistributions in binary form must reproduce the above copyright |
| 11 | + * notice, this list of conditions and the following disclaimer in the |
| 12 | + * documentation and/or other materials provided with the distribution. |
| 13 | + * |
| 14 | + * THIS SOFTWARE IS PROVIDED BY AUTHOR ''AS IS'' AND ANY |
| 15 | + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 16 | + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 17 | + * DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY |
| 18 | + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 19 | + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 20 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 21 | + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 23 | + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | + */ |
| 25 | + |
| 26 | +#include "rdns.h" |
| 27 | +#include "dns_private.h" |
| 28 | +#include "rdns_curve.h" |
| 29 | + |
| 30 | +struct rdns_curve_entry { |
| 31 | + char *name; |
| 32 | + char pubkey[RDSN_CURVE_PUBKEY_LEN]; |
| 33 | + UT_hash_handle hh; |
| 34 | +}; |
| 35 | + |
| 36 | +struct rdns_curve_ctx { |
| 37 | + struct rdns_curve_entry *entries; |
| 38 | +}; |
| 39 | + |
| 40 | +struct rdns_curve_ctx* |
| 41 | +rdns_curve_ctx_new (void) |
| 42 | +{ |
| 43 | + struct rdns_curve_ctx *new; |
| 44 | + |
| 45 | + new = calloc (1, sizeof (struct rdns_curve_ctx)); |
| 46 | + |
| 47 | + return new; |
| 48 | +} |
| 49 | + |
| 50 | + |
| 51 | +void |
| 52 | +rdns_curve_ctx_add_key (struct rdns_curve_ctx *ctx, |
| 53 | + const char *name, const char *pubkey) |
| 54 | +{ |
| 55 | + struct rdns_curve_entry *entry; |
| 56 | + int len; |
| 57 | + |
| 58 | + len = strlen (pubkey); |
| 59 | + |
| 60 | + if (len == RDSN_CURVE_PUBKEY_LEN) { |
| 61 | + entry = malloc (sizeof (struct rdns_curve_entry)); |
| 62 | + entry->name = strdup (name); |
| 63 | + memcpy (entry->pubkey, pubkey, sizeof (entry->pubkey)); |
| 64 | + HASH_ADD_KEYPTR (hh, ctx->entries, entry->name, strlen (entry->name), entry); |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +void rdns_curve_ctx_destroy (struct rdns_curve_ctx *ctx) |
| 69 | +{ |
| 70 | + struct rdns_curve_entry *entry, *tmp; |
| 71 | + |
| 72 | + HASH_ITER (hh, ctx->entries, entry, tmp) { |
| 73 | + free (entry->name); |
| 74 | + free (entry); |
| 75 | + } |
| 76 | + |
| 77 | + free (ctx); |
| 78 | +} |
| 79 | + |
| 80 | +void |
| 81 | +rdns_curve_register_plugin (struct rdns_resolver *resolver, |
| 82 | + struct rdns_curve_ctx *ctx) |
| 83 | +{ |
| 84 | + |
| 85 | +} |
0 commit comments