supercop

Basic CLI for supercop
git clone git://git.finwo.net/app/supercop
Log | Files | Refs | README | LICENSE

encode.c (524B)


      1 #include <stdlib.h>
      2 #include <string.h>
      3 
      4 #include "common.h"
      5 
      6 #ifdef __cplusplus
      7 extern "C" {
      8 #endif
      9 
     10 char * fmt_0x00_encode(struct KeyPair *kp, size_t *len) {
     11   char *result;
     12   if (!kp || !kp->public_key || !len) return NULL;
     13   result = malloc(1 + 32 + 64);
     14   if (!result) return NULL;
     15   result[0] = 0;
     16   memcpy(result + 1, kp->public_key, 32);
     17   *len = 1 + 32;
     18   if (kp->private_key) {
     19     memcpy(result + 33, kp->private_key, 64);
     20     *len = 1 + 32 + 64;
     21   }
     22   return result;
     23 }
     24 
     25 #ifdef __cplusplus
     26 } // extern "C"
     27 #endif