- /* Convert the encrypted random data to a hexadecimal formatted string */
-
- bin2hex(enckey, hexkey, len);
- hexkey[len * 2] = '\0';
-
- /* Send the meta key */
-
- bool result = send_request(c, "%d %d %d %d %d %s", METAKEY,
- cipher_get_nid(&c->outcipher),
- digest_get_nid(&c->outdigest), c->outmaclength,
- c->outcompression, hexkey);
-
- c->status.encryptout = true;
- return result;
-}
-
-static bool metakey_ec_h(connection_t *c, const char *request) {
- size_t siglen = ecdsa_size(&c->ecdsa);
- char in[MAX_STRING_SIZE];
- char key[MAX_STRING_SIZE];
- char sig[siglen];
+ // Recover the filename from the cookie and the key
+ char *fingerprint = ecdsa_get_base64_public_key(mesh->invitation_key);
+ char hash[64];
+ char hashbuf[18 + strlen(fingerprint)];
+ char cookie[25];
+ memcpy(hashbuf, data, 18);
+ memcpy(hashbuf + 18, fingerprint, sizeof(hashbuf) - 18);
+ sha512(hashbuf, sizeof(hashbuf), hash);
+ b64encode_urlsafe(hash, cookie, 18);
+ free(fingerprint);