summaryrefslogtreecommitdiff
path: root/src/hello/test_hello-ng.c
blob: e6b1d42a01a98387988f1f7fe0eea1461d4bb7e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_nt_lib.h"
#include "gnunet_hello_lib.h"

int
main (int argc,
      char *argv[])
{
  struct GNUNET_CRYPTO_EddsaPublicKey pubKey;
  struct GNUNET_CRYPTO_EddsaPrivateKey privKey;
  struct GNUNET_PeerIdentity pid;
  struct GNUNET_TIME_Absolute t = GNUNET_TIME_absolute_get ();
  char *res;
  size_t res_len;
  enum GNUNET_NetworkType nt;

  GNUNET_CRYPTO_eddsa_key_create (&privKey);
  GNUNET_CRYPTO_eddsa_key_get_public (&privKey,
                                      &pubKey);
  pid.public_key = pubKey;
  GNUNET_HELLO_sign_address ("127.0.0.1:8080",
                             GNUNET_NT_LAN,
                             t,
                             &privKey,
                             (void**)&res,
                             &res_len);
  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
              "%s\n", res);
  GNUNET_assert (NULL !=
                 GNUNET_HELLO_extract_address ((void**)res,
                                               res_len,
                                               &pid,
                                               &nt,
                                               &t));
  return 0;
}