diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2022-10-29 18:06:26 +0900 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2022-10-29 18:06:26 +0900 |
commit | 0f2da4636e108c70697c589d9e38781f2bafefba (patch) | |
tree | 0e831befd71d4323596cdae55e8431df7720c531 /src/include/gnunet_identity_service.h | |
parent | 4e2259f14be320c8e2fe2a672a473e09677269c4 (diff) | |
download | gnunet-0f2da4636e108c70697c589d9e38781f2bafefba.tar.gz gnunet-0f2da4636e108c70697c589d9e38781f2bafefba.zip |
IDENTITY
This commit is a major rework of the unclean GNUNET_IDENTITY_*Key
structures and its use in serialized objects (e.g. RPC messages).
The structures are now no longer to be used directly but instead through
their serialization helper functions whenever needed.
Diffstat (limited to 'src/include/gnunet_identity_service.h')
-rw-r--r-- | src/include/gnunet_identity_service.h | 82 |
1 files changed, 68 insertions, 14 deletions
diff --git a/src/include/gnunet_identity_service.h b/src/include/gnunet_identity_service.h index d234ff552..cd745ba51 100644 --- a/src/include/gnunet_identity_service.h +++ b/src/include/gnunet_identity_service.h | |||
@@ -85,11 +85,10 @@ struct GNUNET_IDENTITY_Handle; | |||
85 | */ | 85 | */ |
86 | struct GNUNET_IDENTITY_Ego; | 86 | struct GNUNET_IDENTITY_Ego; |
87 | 87 | ||
88 | // FIXME: these types are NOT packed, | ||
89 | // NOT 64-bit aligned, but used in messages!!?? | ||
90 | |||
91 | /** | 88 | /** |
92 | * A private key for an identity as per LSD0001. | 89 | * A private key for an identity as per LSD0001. |
90 | * Note that these types are NOT packed and MUST NOT be used in RPC | ||
91 | * messages. Use the respective serialization functions. | ||
93 | */ | 92 | */ |
94 | struct GNUNET_IDENTITY_PrivateKey | 93 | struct GNUNET_IDENTITY_PrivateKey |
95 | { | 94 | { |
@@ -406,8 +405,7 @@ GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op); | |||
406 | * @return -1 on error, else the compacted length of the key. | 405 | * @return -1 on error, else the compacted length of the key. |
407 | */ | 406 | */ |
408 | ssize_t | 407 | ssize_t |
409 | GNUNET_IDENTITY_key_get_length (const struct GNUNET_IDENTITY_PublicKey *key); | 408 | GNUNET_IDENTITY_public_key_get_length (const struct GNUNET_IDENTITY_PublicKey *key); |
410 | |||
411 | 409 | ||
412 | /** | 410 | /** |
413 | * Reads a #GNUNET_IDENTITY_PublicKey from a compact buffer. | 411 | * Reads a #GNUNET_IDENTITY_PublicKey from a compact buffer. |
@@ -416,15 +414,32 @@ GNUNET_IDENTITY_key_get_length (const struct GNUNET_IDENTITY_PublicKey *key); | |||
416 | * If the buffer is too small, the function returns -1 as error. | 414 | * If the buffer is too small, the function returns -1 as error. |
417 | * If the buffer does not contain a valid key, it returns -2 as error. | 415 | * If the buffer does not contain a valid key, it returns -2 as error. |
418 | * | 416 | * |
419 | * @param key the key | ||
420 | * @param buffer the buffer | 417 | * @param buffer the buffer |
421 | * @param len the length of buffer | 418 | * @param len the length of buffer |
422 | * @return -1 or -2 on error, else the amount of bytes read from the buffer | 419 | * @param key the key |
420 | * @param the amount of bytes read from the buffer | ||
421 | * @return GNUNET_SYSERR on error | ||
422 | */ | ||
423 | enum GNUNET_GenericReturnValue | ||
424 | GNUNET_IDENTITY_read_public_key_from_buffer (const void *buffer, | ||
425 | size_t len, | ||
426 | struct | ||
427 | GNUNET_IDENTITY_PublicKey *key, | ||
428 | size_t *read); | ||
429 | |||
430 | /** | ||
431 | * Get the compacted length of a #GNUNET_IDENTITY_PrivateKey. | ||
432 | * Compacted means that it returns the minimum number of bytes this | ||
433 | * key is long, as opposed to the union structure inside | ||
434 | * #GNUNET_IDENTITY_PrivateKey. | ||
435 | * Useful for compact serializations. | ||
436 | * | ||
437 | * @param key the key. | ||
438 | * @return -1 on error, else the compacted length of the key. | ||
423 | */ | 439 | */ |
424 | ssize_t | 440 | ssize_t |
425 | GNUNET_IDENTITY_read_key_from_buffer (struct GNUNET_IDENTITY_PublicKey *key, | 441 | GNUNET_IDENTITY_private_key_get_length (const struct |
426 | const void*buffer, | 442 | GNUNET_IDENTITY_PrivateKey *key); |
427 | size_t len); | ||
428 | 443 | ||
429 | 444 | ||
430 | /** | 445 | /** |
@@ -440,10 +455,49 @@ GNUNET_IDENTITY_read_key_from_buffer (struct GNUNET_IDENTITY_PublicKey *key, | |||
440 | * @return -1 or -2 on error, else the amount of bytes written to the buffer | 455 | * @return -1 or -2 on error, else the amount of bytes written to the buffer |
441 | */ | 456 | */ |
442 | ssize_t | 457 | ssize_t |
443 | GNUNET_IDENTITY_write_key_to_buffer (const struct | 458 | GNUNET_IDENTITY_write_public_key_to_buffer (const struct |
444 | GNUNET_IDENTITY_PublicKey *key, | 459 | GNUNET_IDENTITY_PublicKey *key, |
445 | void*buffer, | 460 | void*buffer, |
446 | size_t len); | 461 | size_t len); |
462 | |||
463 | |||
464 | /** | ||
465 | * Reads a #GNUNET_IDENTITY_PrivateKey from a compact buffer. | ||
466 | * The buffer has to contain at least the compacted length of | ||
467 | * a #GNUNET_IDENTITY_PrivateKey in bytes. | ||
468 | * If the buffer is too small, the function returns GNUNET_SYSERR as error. | ||
469 | * | ||
470 | * @param buffer the buffer | ||
471 | * @param len the length of buffer | ||
472 | * @param key the key | ||
473 | * @param the amount of bytes read from the buffer | ||
474 | * @return GNUNET_SYSERR on error | ||
475 | */ | ||
476 | enum GNUNET_GenericReturnValue | ||
477 | GNUNET_IDENTITY_read_private_key_from_buffer (const void*buffer, | ||
478 | size_t len, | ||
479 | struct | ||
480 | GNUNET_IDENTITY_PrivateKey *key, | ||
481 | size_t *read); | ||
482 | |||
483 | |||
484 | /** | ||
485 | * Writes a #GNUNET_IDENTITY_PrivateKey to a compact buffer. | ||
486 | * The buffer requires space for at least the compacted length of | ||
487 | * a #GNUNET_IDENTITY_PrivateKey in bytes. | ||
488 | * If the buffer is too small, the function returns -1 as error. | ||
489 | * If the key is not valid, it returns -2 as error. | ||
490 | * | ||
491 | * @param key the key | ||
492 | * @param buffer the buffer | ||
493 | * @param len the length of buffer | ||
494 | * @return -1 or -2 on error, else the amount of bytes written to the buffer | ||
495 | */ | ||
496 | ssize_t | ||
497 | GNUNET_IDENTITY_write_private_key_to_buffer (const struct | ||
498 | GNUNET_IDENTITY_PrivateKey *key, | ||
499 | void*buffer, | ||
500 | size_t len); | ||
447 | 501 | ||
448 | 502 | ||
449 | /** | 503 | /** |