Avis Client Library: avis/keys.h Source File

- Main Page
- Data Structures
- Files

# avis/keys.h

Go to the documentation of this file.

    00001 /*
    00002  *  Avis Elvin client library for C.
    00003  *
    00004  *  Copyright (C) 2008 Matthew Phillips <avis@mattp.name>
    00005  *
    00006  *  This program is free software; you can redistribute it and/or
    00007  *  modify it under the terms of version 3 of the GNU Lesser General
    00008  *  Public License as published by the Free Software Foundation.
    00009  *
    00010  *  This program is distributed in the hope that it will be useful,
    00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    00013  *  General Public License for more details.
    00014  *
    00015  *  You should have received a copy of the GNU General Public License
    00016  *  along with this program. If not, see <http://www.gnu.org/licenses/>.
    00017  */
    00021 #ifndef ELVIN_KEYS_H
    00022 #define ELVIN_KEYS_H
    00023
    00024 #include <string.h>
    00025
    00026 #include <avis/defs.h>
    00027 #include <avis/stdtypes.h>
    00028 #include <avis/arrays.h>
    00029
    00033 #define EMPTY_KEYS (&_empty_keys)
    00034
    00051 typedef struct
    00052 {
    00053   uint8_t * data;
    00054   uint32_t  length;
    00055 } Key;
    00056
    00079 typedef struct
    00080 {
    00081   ArrayList keys [3];
    00082 } Keys;
    00083
    00084 struct KeyScheme_t;
    00085
    00124 typedef struct KeyScheme_t * KeyScheme;
    00125
    00126 AVIS_PUBLIC_DATA struct KeyScheme_t _KEY_SCHEME_SHA1_DUAL;
    00127 AVIS_PUBLIC_DATA struct KeyScheme_t _KEY_SCHEME_SHA1_PRODUCER;
    00128 AVIS_PUBLIC_DATA struct KeyScheme_t _KEY_SCHEME_SHA1_CONSUMER;
    00129
    00135 #define KEY_SCHEME_SHA1_DUAL (&_KEY_SCHEME_SHA1_DUAL)
    00136
    00142 #define KEY_SCHEME_SHA1_PRODUCER (&_KEY_SCHEME_SHA1_PRODUCER)
    00143
    00149 #define KEY_SCHEME_SHA1_CONSUMER (&_KEY_SCHEME_SHA1_CONSUMER)
    00150
    00151 AVIS_PUBLIC_DATA Keys _empty_keys;
    00152
    00159 #define elvin_keys_create() \
    00160   (elvin_keys_init ((Keys *)avis_emalloc (sizeof (Keys))))
    00161
    00168 #define elvin_keys_destroy(keys) \
    00169   if ((keys) != EMPTY_KEYS && (keys) != NULL) \
    00170   {\
    00171     elvin_keys_free (keys); free (keys); \
    00172   }\
    00173   keys = NULL;\
    00174
    00175
    00180 AVIS_PUBLIC
    00181 Keys *elvin_keys_init (Keys *keys);
    00182
    00193 AVIS_PUBLIC
    00194 Keys *elvin_keys_copy (Keys *keys);
    00195
    00203 AVIS_PUBLIC
    00204 void elvin_keys_free (Keys *keys);
    00205
    00209 AVIS_PUBLIC
    00210 bool elvin_keys_equal (Keys *keys1, Keys *keys2);
    00211
    00225 AVIS_PUBLIC
    00226 bool elvin_keys_add (Keys *keys, KeyScheme scheme, Key key);
    00227
    00244 AVIS_PUBLIC
    00245 bool elvin_keys_add_dual_consumer (Keys *keys, KeyScheme scheme, Key key);
    00246
    00263 AVIS_PUBLIC
    00264 bool elvin_keys_add_dual_producer (Keys *keys, KeyScheme scheme, Key key);
    00265
    00272 AVIS_PUBLIC
    00273 void elvin_key_free (Key key);
    00274
    00280 #define elvin_key_copy(key) \
    00281   (elvin_key_create_from_data ((key).data, (key).length))
    00282
    00291 AVIS_PUBLIC
    00292 Key elvin_key_create_from_string (const char *str);
    00293
    00304 AVIS_PUBLIC
    00305 Key elvin_key_create_from_data (const uint8_t *data, size_t length);
    00306
    00318 AVIS_PUBLIC
    00319 Key elvin_key_create_public (Key private_key, KeyScheme scheme);
    00320
    00324 AVIS_PUBLIC
    00325 bool elvin_key_equal (Key key1, Key key2);
    00326
    00327 #endif /* ELVIN_KEYS_H */