diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-10-14 19:47:32 +0200 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-10-15 12:11:18 +0200 |
commit | 96c802b46be51e5c45f34e2de823f787d26c2929 (patch) | |
tree | 457ccfd8f9a61563af86318739c4a8f964a57025 /src/include/gnunet_identity_service.h | |
parent | c14e3a2769ff0f15fdbb32797e37e43ce2344fa3 (diff) | |
download | gnunet-96c802b46be51e5c45f34e2de823f787d26c2929.tar.gz gnunet-96c802b46be51e5c45f34e2de823f787d26c2929.zip |
- towards crypto agility; wip
Diffstat (limited to 'src/include/gnunet_identity_service.h')
-rw-r--r-- | src/include/gnunet_identity_service.h | 107 |
1 files changed, 102 insertions, 5 deletions
diff --git a/src/include/gnunet_identity_service.h b/src/include/gnunet_identity_service.h index 94127248e..c72e6d146 100644 --- a/src/include/gnunet_identity_service.h +++ b/src/include/gnunet_identity_service.h | |||
@@ -57,6 +57,21 @@ extern "C" { | |||
57 | */ | 57 | */ |
58 | #define GNUNET_IDENTITY_VERSION 0x00000100 | 58 | #define GNUNET_IDENTITY_VERSION 0x00000100 |
59 | 59 | ||
60 | enum GNUNET_IDENTITY_KeyType | ||
61 | { | ||
62 | /** | ||
63 | * The identity type. The value is the same as the | ||
64 | * PKEY record type. | ||
65 | */ | ||
66 | GNUNET_IDENTITY_TYPE_ECDSA = 65536, | ||
67 | |||
68 | /** | ||
69 | * EDDSA identity. The value is the same as the EDKEY | ||
70 | * record type. | ||
71 | */ | ||
72 | GNUNET_IDENTITY_TYPE_EDDSA = 65599 // FIXME | ||
73 | }; | ||
74 | |||
60 | /** | 75 | /** |
61 | * Handle to access the identity service. | 76 | * Handle to access the identity service. |
62 | */ | 77 | */ |
@@ -67,6 +82,61 @@ struct GNUNET_IDENTITY_Handle; | |||
67 | */ | 82 | */ |
68 | struct GNUNET_IDENTITY_Ego; | 83 | struct GNUNET_IDENTITY_Ego; |
69 | 84 | ||
85 | |||
86 | /** | ||
87 | * A private key for an identity as per LSD0001. | ||
88 | */ | ||
89 | struct GNUNET_IDENTITY_PrivateKey | ||
90 | { | ||
91 | /** | ||
92 | * Type of public key. | ||
93 | * Defined by the GNS zone type value. | ||
94 | * In NBO. | ||
95 | */ | ||
96 | uint32_t type; | ||
97 | |||
98 | union | ||
99 | { | ||
100 | /** | ||
101 | * An ECDSA identity key. | ||
102 | */ | ||
103 | struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key; | ||
104 | |||
105 | /** | ||
106 | * AN EdDSA identtiy key | ||
107 | */ | ||
108 | struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_key; | ||
109 | }; | ||
110 | }; | ||
111 | |||
112 | |||
113 | /** | ||
114 | * An identity key as per LSD0001. | ||
115 | */ | ||
116 | struct GNUNET_IDENTITY_PublicKey | ||
117 | { | ||
118 | /** | ||
119 | * Type of public key. | ||
120 | * Defined by the GNS zone type value. | ||
121 | * In NBO. | ||
122 | */ | ||
123 | uint32_t type; | ||
124 | |||
125 | union | ||
126 | { | ||
127 | /** | ||
128 | * An ECDSA identity key. | ||
129 | */ | ||
130 | struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_key; | ||
131 | |||
132 | /** | ||
133 | * AN EdDSA identtiy key | ||
134 | */ | ||
135 | struct GNUNET_CRYPTO_EddsaPublicKey eddsa_key; | ||
136 | }; | ||
137 | }; | ||
138 | |||
139 | |||
70 | /** | 140 | /** |
71 | * Handle for an operation with the identity service. | 141 | * Handle for an operation with the identity service. |
72 | */ | 142 | */ |
@@ -79,7 +149,7 @@ struct GNUNET_IDENTITY_Operation; | |||
79 | * @param ego the ego | 149 | * @param ego the ego |
80 | * @return associated ECC key, valid as long as the ego is valid | 150 | * @return associated ECC key, valid as long as the ego is valid |
81 | */ | 151 | */ |
82 | const struct GNUNET_CRYPTO_EcdsaPrivateKey * | 152 | const struct GNUNET_IDENTITY_PrivateKey * |
83 | GNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego); | 153 | GNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego); |
84 | 154 | ||
85 | 155 | ||
@@ -100,7 +170,7 @@ GNUNET_IDENTITY_ego_get_anonymous (void); | |||
100 | */ | 170 | */ |
101 | void | 171 | void |
102 | GNUNET_IDENTITY_ego_get_public_key (struct GNUNET_IDENTITY_Ego *ego, | 172 | GNUNET_IDENTITY_ego_get_public_key (struct GNUNET_IDENTITY_Ego *ego, |
103 | struct GNUNET_CRYPTO_EcdsaPublicKey *pk); | 173 | struct GNUNET_IDENTITY_PublicKey *pk); |
104 | 174 | ||
105 | 175 | ||
106 | /** | 176 | /** |
@@ -224,7 +294,7 @@ GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h); | |||
224 | typedef void | 294 | typedef void |
225 | (*GNUNET_IDENTITY_CreateContinuation) ( | 295 | (*GNUNET_IDENTITY_CreateContinuation) ( |
226 | void *cls, | 296 | void *cls, |
227 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, | 297 | const struct GNUNET_IDENTITY_PrivateKey *pk, |
228 | const char *emsg); | 298 | const char *emsg); |
229 | 299 | ||
230 | 300 | ||
@@ -234,6 +304,7 @@ typedef void | |||
234 | * @param id identity service to use | 304 | * @param id identity service to use |
235 | * @param name desired name | 305 | * @param name desired name |
236 | * @param privkey desired private key or NULL to create one | 306 | * @param privkey desired private key or NULL to create one |
307 | * @param ktype the type of key to create. Ignored if privkey != NULL. | ||
237 | * @param cont function to call with the result (will only be called once) | 308 | * @param cont function to call with the result (will only be called once) |
238 | * @param cont_cls closure for @a cont | 309 | * @param cont_cls closure for @a cont |
239 | * @return handle to abort the operation | 310 | * @return handle to abort the operation |
@@ -241,7 +312,8 @@ typedef void | |||
241 | struct GNUNET_IDENTITY_Operation * | 312 | struct GNUNET_IDENTITY_Operation * |
242 | GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id, | 313 | GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id, |
243 | const char *name, | 314 | const char *name, |
244 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey, | 315 | const struct GNUNET_IDENTITY_PrivateKey *privkey, |
316 | enum GNUNET_IDENTITY_KeyType ktype, | ||
245 | GNUNET_IDENTITY_CreateContinuation cont, | 317 | GNUNET_IDENTITY_CreateContinuation cont, |
246 | void *cont_cls); | 318 | void *cont_cls); |
247 | 319 | ||
@@ -291,6 +363,31 @@ GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id, | |||
291 | void | 363 | void |
292 | GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op); | 364 | GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op); |
293 | 365 | ||
366 | ssize_t | ||
367 | GNUNET_IDENTITY_key_get_length (const struct GNUNET_IDENTITY_PublicKey *key); | ||
368 | |||
369 | char * | ||
370 | GNUNET_IDENTITY_public_key_to_string (const struct | ||
371 | GNUNET_IDENTITY_PublicKey *key); | ||
372 | |||
373 | |||
374 | char * | ||
375 | GNUNET_IDENTITY_private_key_to_string (const struct | ||
376 | GNUNET_IDENTITY_PrivateKey *key); | ||
377 | |||
378 | |||
379 | enum GNUNET_GenericReturnValue | ||
380 | GNUNET_IDENTITY_public_key_from_string (const char*str, | ||
381 | struct GNUNET_IDENTITY_PublicKey *key); | ||
382 | |||
383 | enum GNUNET_GenericReturnValue | ||
384 | GNUNET_IDENTITY_private_key_from_string (const char*str, | ||
385 | struct GNUNET_IDENTITY_PrivateKey *key); | ||
386 | |||
387 | enum GNUNET_GenericReturnValue | ||
388 | GNUNET_IDENTITY_key_get_public (const struct GNUNET_IDENTITY_PrivateKey *privkey, | ||
389 | struct GNUNET_IDENTITY_PublicKey *key); | ||
390 | |||
294 | 391 | ||
295 | /* ************* convenience API to lookup an ego ***************** */ | 392 | /* ************* convenience API to lookup an ego ***************** */ |
296 | 393 | ||
@@ -344,7 +441,7 @@ GNUNET_IDENTITY_ego_lookup_cancel (struct GNUNET_IDENTITY_EgoLookup *el); | |||
344 | typedef void | 441 | typedef void |
345 | (*GNUNET_IDENTITY_EgoSuffixCallback) ( | 442 | (*GNUNET_IDENTITY_EgoSuffixCallback) ( |
346 | void *cls, | 443 | void *cls, |
347 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 444 | const struct GNUNET_IDENTITY_PrivateKey *priv, |
348 | const char *ego_name); | 445 | const char *ego_name); |
349 | 446 | ||
350 | 447 | ||