uint8_t *nR;
uint8_t *nL;
int32_t pklen;
- char *pk;
+ uint8_t *pk;
int32_t hashlen;
int32_t siglen;
char *sig;
return t;
}
-static _Bool set_new_transform(struct site *st, char *pk)
+static _Bool set_new_transform(struct site *st, uint8_t *pk, int32_t pklen)
{
_Bool ok;
assert(!st->sharedsecret);
st->sharedsecret = safe_malloc(st->chosen_dh->shared_len,
"site:sharedsecret");
+ pk[pklen]=0; /* clobbers the following signature length, which we've
+ * already copied */
if (!st->chosen_dh->makeshared(st->chosen_dh->st,
st->dhsecret,st->chosen_dh->secret_len,
- pk,
+ pk,pklen,
st->sharedsecret,
st->chosen_dh->shared_len))
return False;
{
void *hst;
uint8_t *hash;
- string_t dhpub, sig;
+ string_t sig;
+ uint8_t *pklen_addr;
+ int32_t pklen;
+ void *pk;
unsigned minor;
st->retries=st->setup_retries;
buf_append_uint8(&st->buffer,st->chosen_dh->capab_bit);
} while (0);
- dhpub=st->chosen_dh->makepublic(st->chosen_dh->st,
+ pklen_addr=buf_append(&st->buffer,2);
+ pk=buf_append(&st->buffer,st->chosen_dh->public_len);
+ pklen=st->chosen_dh->makepublic(st->chosen_dh->st,
+ pk,st->chosen_dh->public_len,
st->dhsecret,st->chosen_dh->secret_len);
- buf_append_string(&st->buffer,dhpub);
- free(dhpub);
+ put_uint16(pklen_addr,pklen);
+ buf_unappend(&st->buffer,st->chosen_dh->public_len-pklen);
hash=safe_malloc(st->hash->len, "generate_msg");
hst=st->hash->init();
st->hash->update(hst,st->buffer.start,st->buffer.size);
generate_dhsecret(st);
/* Generate the shared key and set up the transform */
- if (!set_new_transform(st,m.pk)) return False;
+ if (!set_new_transform(st,m.pk,m.pklen)) return False;
return True;
}
m.pk[m.pklen]=0;
/* Generate the shared key and set up the transform */
- if (!set_new_transform(st,m.pk)) return False;
+ if (!set_new_transform(st,m.pk,m.pklen)) return False;
return True;
}