aboutsummaryrefslogtreecommitdiff
path: root/src/identity-token/identity-token.h
blob: 1520dcf6aa498d100ae9d68c4d88cfa21c85951f (plain) (blame)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#ifndef GNUNET_IDENTITY_TOKEN_H
#define GNUNET_IDENTITY_TOKEN_H



#include "gnunet_crypto_lib.h"
#include <jansson.h>

struct IdentityToken
{
  /**
   * JSON header
   */
  json_t *header;

  /**
   * JSON Payload
   */
  json_t *payload;

  /**
   * Token Signature
   */
  struct GNUNET_CRYPTO_EcdsaSignature signature;
  
  /**
   * Audience Pubkey
   */
  struct GNUNET_CRYPTO_EcdsaPublicKey aud_key;
};

struct IdentityTokenCodePayload
{
  /**
   * Nonce
   */
  char* nonce;

  /**
   * Label
   */
  char *label;

  /**
   * Issuing Identity
   */
  struct GNUNET_CRYPTO_EcdsaPublicKey identity_key;
};


struct IdentityTokenCode
{
  /**
   * Meta info
   */
  struct IdentityTokenCodePayload *payload;

  /**
   * ECDH Pubkey
   */
  struct GNUNET_CRYPTO_EcdhePublicKey ecdh_pubkey;

  /**
   * Signature
   */
  struct GNUNET_CRYPTO_EcdsaSignature signature;

  /**
   * Target identity
   */
  struct GNUNET_CRYPTO_EcdsaPublicKey aud_key;
};



struct IdentityToken*
identity_token_create (const char* issuer,
                       const char* audience);

void
identity_token_destroy (struct IdentityToken *token);

void
identity_token_add_attr (const struct IdentityToken *token,
                         const char* key,
                         const char* value);
void
identity_token_add_json (const struct IdentityToken *token,
                         const char* key,
                         json_t* value);

int 
identity_token_serialize (const struct IdentityToken *token,
                          const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key,
                          struct GNUNET_CRYPTO_EcdhePrivateKey **ecdhe_privkey,
                          char **result);

int
identity_token_parse (const char* raw_data,
                      const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key,
                      struct IdentityToken **result);

int
identity_token_parse2 (const char* raw_data,
                       const struct GNUNET_CRYPTO_EcdhePrivateKey *priv_key,
                       const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
                       struct IdentityToken **result);

int
identity_token_to_string (const struct IdentityToken *token,
                          const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key,
                          char **result);

struct IdentityTokenCode*
identity_token_code_create (const char* nonce_str,
                            const struct GNUNET_CRYPTO_EcdsaPublicKey* identity_pkey,
                            const char* lbl_str,
                            const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key);

int
identity_token_code_serialize (struct IdentityTokenCode *identity_token_code,
                               const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key,
                               char **result);

void
identity_token_code_destroy (struct IdentityTokenCode *token_code);


int
identity_token_code_parse (const char* raw_data,
                           const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key,
                           struct IdentityTokenCode **result);

#endif