#include "al/sign.h"
#include "stdlib.h"
#include "sha256.h"

void *sign_ctx_init()
{
  void *ctx = mem_get_block(sizeof(sha256_context));
  sha256_starts((sha256_context*)ctx);

  return ctx;
}

void *sign_gen_init()
{
  void *sign = mem_get_block(sizeof(uint8_t)*32);
  return sign;
}

void *sign_ref_init()
{
  void *sign = mem_get_block(sizeof(uint8_t)*32);
  return sign;
}

void sign_update(void *ctx, uint32_t *addr, size_t size)
{
  sha256_update((sha256_context*)ctx, (uint8_t*)addr, (uint32_t)size);
}

void sign_set(void *ctx, void *sign)
{
  sha256_finish(ctx, (uint8_t*)sign);
}

void sign_free(void *ctx, void *sign)
{
  mem_free_block(ctx);
  mem_free_block(sign);
}

void sign_get_ref(void *sign)
{
}

bool sign_compare(void *sign_ref, void *sign_gen)
{
  return true;
}
