Program Listing for File keys.h
↰ Return to documentation for file (caprock/keys.h
)
/*
* This file is part of caprock.
*
* Author(s): Jens Finkhaeuser <jens@finkhaeuser.de>
*
* Copyright (c) 2022 Interpeer gUG (haftungsbeschränkt).
*
* SPDX-License-Identifier: GPL-3.0-only
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef CAPROCK_KEYS_H
#define CAPROCK_KEYS_H
#include <caprock.h>
#include <caprock/codec.h>
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
typedef struct caprock_key caprock_key;
typedef struct caprock_key_pair
{
caprock_key * pubkey;
caprock_key * privkey;
} caprock_key_pair;
CAPROCK_API void caprock_key_init(caprock_key ** key);
CAPROCK_API caprock_key_pair caprock_key_init_pair();
CAPROCK_API int caprock_key_is_valid(caprock_key const * key);
CAPROCK_API int caprock_key_is_public(caprock_key const * key);
CAPROCK_API int caprock_key_is_private(caprock_key const * key);
CAPROCK_API caprock_error_t
caprock_key_read_public(caprock_key * pubkey, void const * buffer, size_t bufsize,
char const * password);
CAPROCK_API caprock_error_t
caprock_key_read_private(caprock_key * privkey, void const * buffer, size_t bufsize,
char const * password);
CAPROCK_API caprock_error_t
caprock_key_read_pair(caprock_key_pair * pair, void const * buffer, size_t bufsize,
char const * password);
CAPROCK_API caprock_error_t
caprock_key_extract_public(caprock_key ** pubkey, caprock_key_pair const * pair);
typedef enum {
CIH_ANY = 0,
CIH_224 = 1,
CIH_256 = 2,
CIH_384 = 3,
CIH_512 = 4,
} caprock_identifier_hash_length;
CAPROCK_API caprock_error_t
caprock_key_identifier_public(
caprock_field_identifier tag,
void * buffer, size_t * bufsize,
caprock_key const * pubkey,
caprock_identifier_hash_length hash_length);
CAPROCK_API caprock_error_t
caprock_key_identifier_pair(
caprock_field_identifier tag,
void * buffer, size_t * bufsize,
caprock_key_pair const * pair,
caprock_identifier_hash_length hash_length);
CAPROCK_API void
caprock_key_free(caprock_key ** key);
CAPROCK_API void
caprock_key_free_pair(caprock_key_pair * pair);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // guard