#ifndef HIDE_H
#define HIDE_H
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define HIDE_OK 0
#define HIDE_ERR_INVALID_ARGUMENT 1
#define HIDE_ERR_WRONG_PASSPHRASE 2
#define HIDE_ERR_NOT_A_KEY 3
#define HIDE_ERR_AUTHENTICATION 4
#define HIDE_ERR_NO_MATCHING_RECIPIENT 5
#define HIDE_ERR_MALFORMED 6
#define HIDE_ERR_TOO_LARGE 7
#define HIDE_ERR_CHALLENGE_EXPIRED 8
#define HIDE_ERR_CHALLENGE_REPLAYED 9
#define HIDE_ERR_PANIC 98
#define HIDE_ERR_INTERNAL 99
#define HIDE_KEY_RAW 0
#define HIDE_KEY_PROTECTED 1
#define HIDE_PUBLIC_KEY_LEN 1216
#define HIDE_MIN_PASSPHRASE_LEN 8
#define HIDE_SIGNATURE_LEN 3373
#define HIDE_VERIFYING_KEY_LEN 1984
#define HIDE_NONCE_LEN 32
typedef struct {
uint8_t *data;
size_t len;
size_t capacity;
} HideBuffer;
typedef struct HideSecretKey HideSecretKey;
const char *hide_error_message(int32_t code);
const char *hide_version(void);
HideBuffer hide_buffer_empty(void);
void hide_buffer_free(HideBuffer *buffer);
int32_t hide_keypair_generate(HideSecretKey **out_secret, HideBuffer *out_public);
int32_t hide_inspect_key(const uint8_t *data, size_t len, int32_t *out_kind);
int32_t hide_secret_key_open(const uint8_t *data, size_t len,
const char *passphrase ,
HideSecretKey **out_secret);
int32_t hide_secret_key_protect(const HideSecretKey *secret, const char *passphrase,
HideBuffer *out);
int32_t hide_secret_key_public(const HideSecretKey *secret, HideBuffer *out);
void hide_secret_key_free(HideSecretKey *secret);
int32_t hide_public_key_armor(const uint8_t *data, size_t len, HideBuffer *out);
int32_t hide_public_key_dearmor(const char *text, HideBuffer *out);
int32_t hide_encrypt(const uint8_t *plaintext, size_t plaintext_len,
const uint8_t *recipients, size_t recipient_count,
const char *filename, const char *media_type,
HideBuffer *out);
int32_t hide_decrypt(const uint8_t *container, size_t container_len,
const HideSecretKey *secret, HideBuffer *out,
HideBuffer *out_filename, HideBuffer *out_media_type);
typedef struct HideSigningIdentity HideSigningIdentity;
typedef struct HideSpentNonces HideSpentNonces;
int32_t hide_identity_generate(const char *passphrase, HideBuffer *out_key_file);
int32_t hide_signing_identity_open(const uint8_t *data, size_t len,
const char *passphrase,
HideSigningIdentity **out_identity);
int32_t hide_signing_identity_public(const HideSigningIdentity *identity,
HideBuffer *out);
void hide_signing_identity_free(HideSigningIdentity *identity);
int32_t hide_sign_message(const HideSigningIdentity *identity,
const uint8_t *context, size_t context_len,
const uint8_t *message, size_t message_len,
HideBuffer *out);
int32_t hide_verify_message(const uint8_t *public_key, size_t public_key_len,
const uint8_t *context, size_t context_len,
const uint8_t *message, size_t message_len,
const uint8_t *signature, size_t signature_len);
int32_t hide_challenge_new(const char *audience, uint64_t now,
uint64_t valid_for, HideBuffer *out);
int32_t hide_challenge_answer(const HideSigningIdentity *identity,
const uint8_t *challenge, size_t challenge_len,
HideBuffer *out);
HideSpentNonces *hide_spent_nonces_new(void);
void hide_spent_nonces_free(HideSpentNonces *spent);
int32_t hide_challenge_accept(HideSpentNonces *spent,
const uint8_t *challenge, size_t challenge_len,
const uint8_t *signature, size_t signature_len,
const uint8_t *public_key, size_t public_key_len,
uint64_t now);
#ifdef __cplusplus
}
#endif
#endif