Beispiel #1
0
uint8_t cipher_generate(lob_t keys, lob_t secrets)
{
  uint8_t secret[uECC_BYTES], key[uECC_BYTES*2], comp[uECC_BYTES+1];

  if(!uECC_make_key(key, secret)) return 1;
  uECC_compress(key,comp);
  lob_set_base32(keys,"1a",comp,uECC_BYTES+1);
  lob_set_base32(secrets,"1a",secret,uECC_BYTES);

  return 0;
}
Beispiel #2
0
uint8_t cipher_generate(lob_t keys, lob_t secrets)
{
  uint8_t secret[SECRET_BYTES], key[KEY_BYTES], comp[COMP_BYTES];

  if(!uECC_make_key(key, secret, curve)) return 1;
  uECC_compress(key,comp, curve);
  lob_set_base32(keys,"1c",comp,COMP_BYTES);
  lob_set_base32(secrets,"1c",secret,SECRET_BYTES);

  return 0;
}
Beispiel #3
0
remote_t remote_new(lob_t key, uint8_t *token)
{
  uint8_t hash[32];
  remote_t remote;
  if(!key || key->body_len != uECC_BYTES+1) return LOG("invalid key %d != %d",(key)?key->body_len:0,uECC_BYTES+1);

  if(!(remote = malloc(sizeof(struct remote_struct)))) return NULL;
  memset(remote,0,sizeof (struct remote_struct));

  // copy in key and make ephemeral ones
  uECC_decompress(key->body,remote->key);
  uECC_make_key(remote->ekey, remote->esecret);
  uECC_compress(remote->ekey, remote->ecomp);
  if(token)
  {
    cipher_hash(remote->ecomp,16,hash);
    memcpy(token,hash,16);
  }

  // generate a random seq starting point for message IV's
  e3x_rand((uint8_t*)&(remote->seq),4);

  return remote;
}