all repos — TinyCrypT @ d9bf94a6b2ab55ec2edb23888eb00182cc52652c

Short and sweet classical cryptographic primitives

test.c (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
#include "tinycrypt/ed25519.h"
#include <stdint.h>
#include <stdio.h>

static uint8_t SK4[] = {
  0x6d, 0xf9, 0x34, 0x0c, 0x13, 0x8c, 0xc1, 0x88, 0xb5, 0xfe, 0x44,
  0x64, 0xeb, 0xaa, 0x3f, 0x7f, 0xc2, 0x06, 0xa2, 0xd5, 0x5c, 0x34,
  0x34, 0x70, 0x7e, 0x74, 0xc9, 0xfc, 0x04, 0xe2, 0x0e, 0xbb,
};
static uint8_t PK4[] = {
  0xc0, 0xda, 0xc1, 0x02, 0xc4, 0x53, 0x31, 0x86, 0xe2, 0x5d, 0xc4,
  0x31, 0x28, 0x47, 0x23, 0x53, 0xea, 0xab, 0xdb, 0x87, 0x8b, 0x15,
  0x2a, 0xeb, 0x8e, 0x00, 0x1f, 0x92, 0xd9, 0x02, 0x33, 0xa7,
};
static uint8_t MSG4[] = {
  0x5f,
  0x4c,
  0x89,
  0x89,
};
static uint8_t SIG4[] = {
  0x12, 0x4f, 0x6f, 0xc6, 0xb0, 0xd1, 0x00, 0x84, 0x27, 0x69, 0xe7, 0x1b, 0xd5,
  0x30, 0x66, 0x4d, 0x88, 0x8d, 0xf8, 0x50, 0x7d, 0xf6, 0xc5, 0x6d, 0xed, 0xfd,
  0xb5, 0x09, 0xae, 0xb9, 0x34, 0x16, 0xe2, 0x6b, 0x91, 0x8d, 0x38, 0xaa, 0x06,
  0x30, 0x5d, 0xf3, 0x09, 0x56, 0x97, 0xc1, 0x8b, 0x2a, 0xa8, 0x32, 0xea, 0xa5,
  0x2e, 0xdc, 0x0a, 0xe4, 0x9f, 0xba, 0xe5, 0xa8, 0x5e, 0x15, 0x0c, 0x07,
};

int
main (int argc, char **argv)
{
  uint8_t actual_signature[64];
  uint8_t working_buf[sizeof (MSG4) + 64];
  tct_ed25519_sign (MSG4, sizeof (MSG4), SK4, PK4, working_buf,
                    actual_signature);
  for (unsigned int i = 0; i < 32; ++i)
    {
      printf ("%02x", SIG4[i]);
    }
  printf ("\n");
  for (unsigned int i = 0; i < 32; ++i)
    {
      printf ("%02x", actual_signature[i]);
    }
  printf ("\n");
  for (unsigned int i = 0; i < 32; ++i)
    {
      printf ("%02x", SIG4[63 - i]);
    }
  printf ("\n");
  for (unsigned int i = 0; i < 32; ++i)
    {
      printf ("%02x", actual_signature[63 - i]);
    }
  printf ("\n");
  return 0;
}