view common/listutil.h @ 59:3f6378647371

Start work on cinst. Strhelp new helpers to work with C String arrays and to have a terminating malloc / realloc
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 18 Mar 2014 10:04:30 +0000
parents 37fc66967517
children 8ffbb48528ae
line wrap: on
line source
#ifndef LISTUTIL_H
#define LISTUTIL_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stddef.h>

/**
 * @file listutil.h
 * @brief Functions to work with the certificate list.
 */

/**
 * @brief Status of the List Operations
 */
typedef enum {
    Valid = 100, // Could be read and signature matched
    UnknownError = 1, // The expected unexpected
    TooLarge = 2, // Failed because the file exeeds the limit
    InvalidFormat = 3, // File does not appear to be in list format
    InvalidSignature = 4, // Signature was invalid
    SeekFailed = 5, // Could not seek in the file
    ReadFailed = 6, // File exists but could not read the file
    IncompatibleVersion = 7 // The Format Version does not match
} list_status_t;

/**
 * @brief Obtain the complete and verified Certificate list.
 *
 * This checks if the file fileName is a valid certificate
 * list signed by the key specified in pubkey.h
 *
 * The caller has to free data.
 *
 * @param[in] fileName Name of the file (UTF-8 encoded).
 * @param[out] data Newly allocated pointer to the file content.
 * @param[out] size Size in Bytes of the file content.
 *
 * @return status of the operation.
 */
list_status_t read_and_verify_list(const char *fileName, char **data, size_t *size);

/** @brief verify the certificate list
 *
 * The public key to verify against is the static publicKeyPEM data defined
 * in the pubkey header.
 *
 *  @param [in] data the list data
 *  @param [in] size the size of the data
 *
 *  @returns 0 if the list is valid a polarssl error or -1 otherwise
 */
int verify_list(char *data, size_t size);
#ifdef __cplusplus
}
#endif
#endif

http://wald.intevation.org/projects/trustbridge/