2025-09-27 14:15:22 -04:00
|
|
|
#ifndef SLEEP_H
|
|
|
|
|
#define SLEEP_H
|
2025-10-02 11:55:48 -04:00
|
|
|
// TODO implement SLEEP
|
2025-09-27 14:15:22 -04:00
|
|
|
/*metadata.key
|
|
|
|
|
metadata.signatures
|
|
|
|
|
metadata.bitfield
|
|
|
|
|
metadata.tree
|
|
|
|
|
metadata.data
|
|
|
|
|
content.key
|
|
|
|
|
content.signatures
|
|
|
|
|
content.bitfield
|
|
|
|
|
content.tree*/
|
2025-10-02 11:55:48 -04:00
|
|
|
#include "key.h"
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
// test
|
|
|
|
|
#include <assert.h>
|
2025-09-27 14:15:22 -04:00
|
|
|
|
2025-10-02 11:55:48 -04:00
|
|
|
#define SLEEP_HEADER_SIZE 32u
|
|
|
|
|
|
|
|
|
|
#define SLEEP_ALGO_BLAKE2B "BLAKE2b"
|
|
|
|
|
#define SLEEP_ALGO_ED25519 "Ed25519"
|
|
|
|
|
|
|
|
|
|
typedef struct sleep_header {
|
|
|
|
|
uint32_t magic_be;
|
|
|
|
|
uint8_t version;
|
|
|
|
|
uint16_t entry_size_be;
|
|
|
|
|
uint8_t algo_len;
|
|
|
|
|
char algo[24];
|
|
|
|
|
} sleep_header_t;
|
|
|
|
|
|
|
|
|
|
// crypto helpers
|
|
|
|
|
#ifdef SLEEP_SALT
|
|
|
|
|
int sleep_gen_ed25519(uint8_t pubkey[32], uint8_t seckey[64]);
|
|
|
|
|
// sign
|
|
|
|
|
int sleep_sign_ed25519(const uint8_t *msg, size_t msglen,
|
|
|
|
|
const uint8_t seckey[64], uint8_t sig_out[64]);
|
|
|
|
|
// verify
|
|
|
|
|
int sleep_verify_ed25519(const uint8_t *msg, size_t msglen,
|
|
|
|
|
const uint8_t pubkey[32], const uint8_t sig[64]);
|
|
|
|
|
// discovery
|
|
|
|
|
int sleep_compute_discovery_key(const uint8_t pubkey[32], uint8_t out32[32]);
|
|
|
|
|
#endif /* SLEEP_SALT */
|
|
|
|
|
|
|
|
|
|
// function decs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* SLEEP_H */
|