.. _program_listing_file_caprock_basics.h: Program Listing for File basics.h ================================= |exhale_lsh| :ref:`Return to documentation for file ` (``caprock/basics.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /* * This file is part of caprock. * * Author(s): Jens Finkhaeuser * * 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 . **/ #ifndef CAPROCK_BASICS_H #define CAPROCK_BASICS_H #include #include #ifdef __cplusplus extern "C" { #endif // __cplusplus CAPROCK_API extern char const * const CAPROCK_EXPIRY_POLICY_ISSUER; CAPROCK_API extern char const * const CAPROCK_EXPIRY_POLICY_LOCAL; CAPROCK_API extern char const * const CAPROCK_CLAIMS_WILDCARD; CAPROCK_API extern size_t const CAPROCK_IDENTIFIER_MIN_SIZE; CAPROCK_API extern size_t const CAPROCK_IDENTIFIER_MAX_SIZE; typedef struct caprock_claim { char const * subject; size_t subject_size; char const * predicate; size_t predicate_size; char const * object; size_t object_size; } caprock_claim; typedef enum { CSA_AUTO = 0, CSA_RAW = 1, CSA_SHA2 = 2, CSA_SHA3 = 3, } caprock_signature_algorithm; CAPROCK_API caprock_error_t caprock_grant_create( void * buffer, size_t * bufsize, // Output buffer caprock_key_pair const * issuer, // Since we need to sign, a key pair. uint64_t sequence_no, // Validity ensured by caller. char const * from, // ISO-8601 as NULL-terminated string char const * to, // same char const * expiry_policy, // One of the constants above. caprock_claim const * claims, // Array of claims size_t claims_size, // 1 for a single claim. caprock_identifier_hash_length issuer_hash_length, caprock_signature_algorithm sigalg ); #define caprock_token_create caprock_grant_create CAPROCK_API caprock_error_t caprock_revocation_create( void * buffer, size_t * bufsize, // Output buffer caprock_key_pair const * issuer, // Since we need to sign, a key pair. uint64_t sequence_no, // Validity ensured by caller. char const * from, // ISO-8601 as NULL-terminated string char const * to, // same char const * expiry_policy, // One of the constants above. caprock_claim const * claims, // Array of claims size_t claims_size, // 1 for a single claim. caprock_identifier_hash_length issuer_hash_length, caprock_signature_algorithm sigalg ); CAPROCK_API caprock_error_t caprock_token_validate( void const * token, size_t token_size, // Serialized token char const * now, // ISO-8601 current timestamp caprock_key const * verifier // Public key ); typedef caprock_error_t (*caprock_token_iterator)( void * buffer, size_t * bufsize, void * baton ); typedef enum caprock_validation_flags { CIF_NONE = 0x00, CIF_IGNORE_OUT_OF_ORDER = 0x01, CIF_IGNORE_GAPS = 0x02, CIF_IGNORE_FAILED_SIG = 0x04, CIF_ALL = CIF_IGNORE_OUT_OF_ORDER | CIF_IGNORE_GAPS | CIF_IGNORE_FAILED_SIG // TODO add flags as needed } caprock_validation_flags; CAPROCK_API caprock_error_t caprock_claim_validate( caprock_claim const * claims, // Array of claims size_t claims_size, // 1 for a single claim. char const * now, // ISO-8601 current timestamp void * buffer, size_t bufsize, // Buffer for temporarily holding tokens caprock_token_iterator iterator, // Tokens to process void * iterator_baton, // Baton for the iterator; can be NULL caprock_key const * verifier, // Public key int flags // Flags ); CAPROCK_API caprock_error_t caprock_issuer_from_token( void * issuer_buffer, size_t * issuer_buffer_size, void const * token_buffer, size_t token_buffer_size ); CAPROCK_API caprock_error_t caprock_create_object_id(void * buffer, size_t * bufsize, char const * name, size_t name_size, caprock_identifier_hash_length hash_length); #ifdef __cplusplus } // extern "C" #endif // __cplusplus #endif // guard