sfinx

sphincs+ inspired signing utility
git clone git://git.finwo.net/app/sfinx
Log | Files | Refs | README | LICENSE

thread_dump.c (1341B)


      1 // Prints signatures for a fixed seed, path, and message, so a -pthread build
      2 // and a plain build can be diffed byte for byte
      3 
      4 #include <stdint.h>
      5 #include <stdio.h>
      6 #include <string.h>
      7 
      8 #include "src/sfinx.c"
      9 
     10 int main(void) {
     11   static const uint8_t seed[32] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
     12                                    0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
     13                                    0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f};
     14   static const uint8_t path[3]  = {0x0a, 0x1b, 0x2c};
     15   static const char    msg[]    = "sfinx thread dump";
     16   static const int     bits[]   = {224, 256, 384, 512};
     17   size_t               msg_len  = sizeof(msg) - 1;
     18 
     19   for (size_t s = 0; s < sizeof(bits) / sizeof(bits[0]); s++) {
     20     for (size_t n = 1; n <= 3; n += 2) {
     21       uint8_t sig[32768];
     22       size_t  sig_len = 0;
     23       if (sfinx_tree_sign((sfinx_hash)bits[s], seed, sizeof(seed), path, n, (const uint8_t *)msg, msg_len, sig,
     24                           sizeof(sig), &sig_len) != SFINX_OK) {
     25         fprintf(stderr, "sign failed for L%d N%zu\n", bits[s], n);
     26         return 1;
     27       }
     28       printf("L=%d N=%zu ", bits[s], n);
     29       for (size_t i = 0; i < sig_len; i++) {
     30         printf("%02x", sig[i]);
     31       }
     32       printf("\n");
     33     }
     34   }
     35   return 0;
     36 }