added nonce and public key, preparing for cryptography negotiation
This commit is contained in:
parent
5666a8a2ef
commit
6d5f7410c6
1 changed files with 8 additions and 4 deletions
|
@ -40,7 +40,9 @@ void libp2p_secio_secure_session_free(struct SecureSession* in) {
|
||||||
* @returns true(1) on success, otherwise false(0)
|
* @returns true(1) on success, otherwise false(0)
|
||||||
*/
|
*/
|
||||||
int libp2p_secio_generate_nonce(char* results, int length) {
|
int libp2p_secio_generate_nonce(char* results, int length) {
|
||||||
results = "abcdefghijklmno";
|
FILE* fd = fopen("/dev/urandom", "r");
|
||||||
|
fread(results, 1, length, fd);
|
||||||
|
fclose(fd);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,8 +89,7 @@ int libp2p_secio_handshake(struct SecureSession* session, struct RsaPrivateKey*
|
||||||
results = NULL;
|
results = NULL;
|
||||||
results_size = 0;
|
results_size = 0;
|
||||||
|
|
||||||
// hash the protobuf of the public key
|
// get public key and put it in a struct PublicKey
|
||||||
// get public key
|
|
||||||
if (!libp2p_crypto_public_key_protobuf_decode(propose_in->public_key, propose_in->public_key_size, &public_key))
|
if (!libp2p_crypto_public_key_protobuf_decode(propose_in->public_key, propose_in->public_key_size, &public_key))
|
||||||
goto exit;
|
goto exit;
|
||||||
// generate their peer id
|
// generate their peer id
|
||||||
|
@ -107,7 +108,10 @@ int libp2p_secio_handshake(struct SecureSession* session, struct RsaPrivateKey*
|
||||||
// we have their information, now we need to gather ours.
|
// we have their information, now we need to gather ours.
|
||||||
|
|
||||||
// will need:
|
// will need:
|
||||||
//
|
// public key
|
||||||
|
propose_out->public_key_size = public_key->data_size;
|
||||||
|
propose_out->public_key = (unsigned char*)malloc(public_key->data_size);
|
||||||
|
memcpy(propose_out->public_key, public_key->data, public_key->data_size);
|
||||||
// supported exchanges
|
// supported exchanges
|
||||||
libp2p_secio_propose_set_property((void**)&propose_out->exchanges, &propose_out->exchanges_size, SupportedExchanges, strlen(SupportedExchanges));
|
libp2p_secio_propose_set_property((void**)&propose_out->exchanges, &propose_out->exchanges_size, SupportedExchanges, strlen(SupportedExchanges));
|
||||||
// supported ciphers
|
// supported ciphers
|
||||||
|
|
Loading…
Reference in a new issue