GNUnet 0.22.0
crypto_hpke.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2024 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
26#include "platform.h"
27#include "gnunet_common.h"
28#include <sodium.h>
29#include <stdint.h>
30#include "gnunet_util_lib.h"
31#include "sodium/crypto_scalarmult.h"
32#include "sodium/crypto_scalarmult_curve25519.h"
33#include "sodium/utils.h"
34
51labeled_extract (const char *ctx_str,
52 const void *salt, size_t salt_len,
53 const void *label, size_t label_len,
54 const void *ikm, size_t ikm_len,
55 const uint8_t *suite_id, size_t suite_id_len,
56 struct GNUNET_ShortHashCode *prk)
57{
58 size_t labeled_ikm_len = strlen (ctx_str) + suite_id_len
59 + label_len + ikm_len;
60 uint8_t labeled_ikm[labeled_ikm_len];
61 uint8_t *tmp = labeled_ikm;
62
63 // labeled_ikm = concat("HPKE-v1", suite_id, label, ikm)
64 memcpy (tmp, ctx_str, strlen (ctx_str));
65 tmp += strlen (ctx_str);
66 memcpy (tmp, suite_id, suite_id_len);
67 tmp += suite_id_len;
68 memcpy (tmp, label, label_len);
69 tmp += label_len;
70 memcpy (tmp, ikm, ikm_len);
71 // return Extract(salt, labeled_ikm)
73 salt, salt_len,
74 labeled_ikm, labeled_ikm_len);
75}
76
77
94labeled_expand (const char *ctx_str,
95 const struct GNUNET_ShortHashCode *prk,
96 const char *label, size_t label_len,
97 const void *info, size_t info_len,
98 const uint8_t *suite_id, size_t suite_id_len,
99 void *out_buf,
100 uint16_t out_len)
101{
102 uint8_t labeled_info[2 + strlen (ctx_str) + suite_id_len + label_len
103 + info_len];
104 uint8_t *tmp = labeled_info;
105 uint16_t out_len_nbo = htons (out_len);
106
107 // labeled_info = concat(I2OSP(L, 2), "HPKE-v1", suite_id,
108 // label, info)
109 memcpy (tmp, &out_len_nbo, 2);
110 tmp += 2;
111 memcpy (tmp, ctx_str, strlen (ctx_str));
112 tmp += strlen (ctx_str);
113 memcpy (tmp, suite_id, suite_id_len);
114 tmp += suite_id_len;
115 memcpy (tmp, label, label_len);
116 tmp += label_len;
117 memcpy (tmp, info, info_len);
118 return GNUNET_CRYPTO_hkdf_expand (out_buf, out_len, prk,
119 labeled_info, sizeof labeled_info, NULL);
120}
121
122
125 size_t dh_len,
126 const char *extract_ctx,
127 const char *expand_ctx,
128 const void*extract_lbl, size_t
129 extract_lbl_len,
130 const void*expand_lbl, size_t
131 expand_lbl_len,
132 const uint8_t *kem_context,
133 size_t kem_context_len,
134 const uint8_t *suite_id, size_t
135 suite_id_len,
136 struct GNUNET_ShortHashCode *
137 shared_secret)
138{
139 struct GNUNET_ShortHashCode prk;
140 // eae_prk = LabeledExtract("", "eae_prk", dh)
141 labeled_extract (extract_ctx,
142 NULL, 0,
143 extract_lbl, extract_lbl_len,
144 dh, dh_len,
145 suite_id, suite_id_len,
146 &prk);
147 return labeled_expand (expand_ctx,
148 &prk,
149 expand_lbl, expand_lbl_len,
150 kem_context, kem_context_len,
151 suite_id, suite_id_len,
152 shared_secret, sizeof *shared_secret);
153}
154
155
156// DHKEM(X25519, HKDF-256): kem_id = 32
157// concat("KEM", I2OSP(kem_id, 2))
158static uint8_t GNUNET_CRYPTO_HPKE_KEM_SUITE_ID[] = { 'K', 'E', 'M',
159 0x00, 0x20 };
160
161// DHKEM(X25519Elligator, HKDF-256): kem_id = 0x0030
162// concat("KEM", I2OSP(kem_id, 2))
163static uint8_t GNUNET_CRYPTO_HPKE_KEM_ELLIGATOR_SUITE_ID[] = { 'K', 'E', 'M',
164 0x00, 0x30 };
166authkem_encaps_norand (uint8_t *suite_id, size_t suite_id_len,
167 const struct GNUNET_CRYPTO_EcdhePublicKey *pkR,
168 const struct GNUNET_CRYPTO_EcdhePrivateKey *skS,
170 const struct GNUNET_CRYPTO_EcdhePrivateKey *skE,
171 struct GNUNET_ShortHashCode *shared_secret)
172{
173 struct GNUNET_CRYPTO_EcdhePublicKey dh[2];
175 uint8_t kem_context[sizeof *c + sizeof *pkR + sizeof pkS];
176
177 // skE, pkE = GenerateKeyPair()
179 (struct GNUNET_CRYPTO_EcdhePublicKey*) c);
180
181 // dh = DH(skE, pkR)
182 if (GNUNET_OK != GNUNET_CRYPTO_ecdh_x25519 (skE, pkR,
183 &dh[0]))
184 return GNUNET_SYSERR; // ValidationError
185 // dh = DH(skS, pkR)
186 if (GNUNET_OK != GNUNET_CRYPTO_ecdh_x25519 (skS, pkR,
187 &dh[1]))
188 return GNUNET_SYSERR; // ValidationError
189 // enc = SerializePublicKey(pkE) is a NOP, see Section 7.1.1
190 // pkRm = SerializePublicKey(pkR) is a NOP, see Section 7.1.1
191 // pkSm = SerializePublicKey(pk(skS)) is a NOP, see Section 7.1.1
193 &pkS);
194 // kem_context = concat(enc, pkRm, pkSm)
195 memcpy (kem_context, c, sizeof *c);
196 memcpy (kem_context + sizeof *c, pkR, sizeof *pkR);
197 memcpy (kem_context + sizeof *c + sizeof *pkR, &pkS, sizeof pkS);
198 // shared_secret = ExtractAndExpand(dh, kem_context)
200 dh, sizeof (struct GNUNET_CRYPTO_EcdhePublicKey) * 2,
201 "HPKE-v1",
202 "HPKE-v1",
203 "eae_prk", strlen ("eae_prk"),
204 "shared_secret", strlen ("shared_secret"),
205 kem_context, sizeof kem_context,
206 suite_id, suite_id_len,
207 shared_secret);
208}
209
210
213 const struct GNUNET_CRYPTO_EcdhePublicKey *pkR,
214 const struct GNUNET_CRYPTO_EcdhePrivateKey *skS,
216 const struct GNUNET_CRYPTO_EcdhePrivateKey *skE,
217 struct GNUNET_ShortHashCode *shared_secret)
218{
219 // enc = SerializePublicKey(pkE) is a NOP, see Section 7.1.1
221 skE,
222 (struct GNUNET_CRYPTO_EcdhePublicKey*) c);
225 pkR, skS, c, skE, shared_secret);
226}
227
228
231 const struct GNUNET_CRYPTO_EcdhePublicKey *pkR,
232 const struct GNUNET_CRYPTO_EcdhePrivateKey *skS,
234 struct GNUNET_ShortHashCode *shared_secret)
235{
237 // skE, pkE = GenerateKeyPair()
239
240 return GNUNET_CRYPTO_hpke_authkem_encaps_norand (pkR, skS, c, &skE,
241 shared_secret);
242}
243
244
246kem_encaps_norand (uint8_t *suite_id, size_t suite_id_len,
247 const struct GNUNET_CRYPTO_EcdhePublicKey *pkR,
248 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
249 const struct GNUNET_CRYPTO_EcdhePrivateKey *skE,
250 struct GNUNET_ShortHashCode *shared_secret)
251{
253 uint8_t kem_context[sizeof *c + sizeof *pkR];
254
255 // dh = DH(skE, pkR)
256 if (GNUNET_OK != GNUNET_CRYPTO_ecdh_x25519 (skE, pkR,
257 &dh))
258 {
260 "HPKE KEM encaps: Validation error\n");
261 return GNUNET_SYSERR; // ValidationError
262 }
263 // enc = SerializePublicKey(pkE) is a NOP, see Section 7.1.1
264 // pkRm = SerializePublicKey(pkR) is a NOP, see Section 7.1.1
265 // kem_context = concat(enc, pkRm)
266 memcpy (kem_context, c, sizeof *c);
267 memcpy (kem_context + sizeof *c, pkR, sizeof *pkR);
268 // shared_secret = ExtractAndExpand(dh, kem_context)
270 &dh, sizeof dh,
271 "HPKE-v1",
272 "HPKE-v1",
273 "eae_prk", strlen ("eae_prk"),
274 "shared_secret", strlen ("shared_secret"),
275 kem_context, sizeof kem_context,
276 suite_id, suite_id_len,
277 shared_secret);
278}
279
280
283 const struct GNUNET_CRYPTO_EcdhePublicKey *pkR,
285 const struct GNUNET_CRYPTO_EcdhePrivateKey *skE,
286 struct GNUNET_ShortHashCode *shared_secret)
287{
288 // enc = SerializePublicKey(pkE) is a NOP, see Section 7.1.1
290 skE,
294 pkR, enc, skE, shared_secret);
295}
296
297
301 struct GNUNET_ShortHashCode *shared_secret)
302{
304 // skE, pkE = GenerateKeyPair()
306
307 return GNUNET_CRYPTO_hpke_kem_encaps_norand (pub, c, &skE, shared_secret);
308}
309
310
314 struct GNUNET_ShortHashCode *shared_secret)
315{
317
318 // This maps the ed25519 point to X25519
319 if (0 != crypto_sign_ed25519_pk_to_curve25519 (pkR.q_y, pub->q_y))
320 return GNUNET_SYSERR;
321
322 return GNUNET_CRYPTO_hpke_kem_encaps (&pkR, c, shared_secret);
323}
324
325
328 const struct GNUNET_CRYPTO_EcdhePrivateKey *skR,
329 const struct GNUNET_CRYPTO_EcdhePublicKey *pkS,
330 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
331 struct GNUNET_ShortHashCode *shared_secret)
332{
333 struct GNUNET_CRYPTO_EcdhePublicKey dh[2];
334 uint8_t pkR[crypto_scalarmult_BYTES];
335 uint8_t kem_context[sizeof *c + sizeof pkR + sizeof *pkS];
336
337 // pkE = DeserializePublicKey(enc) is a NOP, see Section 7.1.1
338 // dh = DH(skE, pkR)
340 (struct
342 &dh[0]))
343 return GNUNET_SYSERR; // ValidationError
344 // dh = DH(skS, pkR)
345 if (GNUNET_OK != GNUNET_CRYPTO_ecdh_x25519 (skR, pkS,
346 &dh[1]))
347 return GNUNET_SYSERR; // ValidationError
348 // pkRm = DeserializePublicKey(pk(skR)) is a NOP, see Section 7.1.1
349 crypto_scalarmult_curve25519_base (pkR, skR->d);
350 // kem_context = concat(enc, pkRm)
351 memcpy (kem_context, c, sizeof *c);
352 memcpy (kem_context + sizeof *c, pkR, sizeof pkR);
353 memcpy (kem_context + sizeof *c + sizeof pkR,
354 pkS, sizeof *pkS);
355 // shared_secret = ExtractAndExpand(dh, kem_context)
357 dh, sizeof (struct GNUNET_CRYPTO_EcdhePublicKey) * 2,
358 "HPKE-v1",
359 "HPKE-v1",
360 "eae_prk", strlen ("eae_prk"),
361 "shared_secret", strlen ("shared_secret"),
362 kem_context, sizeof kem_context,
365 shared_secret);
366}
367
368
371 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
372 struct GNUNET_ShortHashCode *shared_secret)
373{
375 uint8_t kem_context[sizeof *c + crypto_scalarmult_curve25519_BYTES];
376 uint8_t pkR[crypto_scalarmult_BYTES];
377
378 // pkE = DeserializePublicKey(enc) is a NOP, see Section 7.1.1
379 // dh = DH(skR, pkE)
380 if (GNUNET_OK !=
383 &dh))
384 return GNUNET_SYSERR; // ValidationError
385
386 // pkRm = DeserializePublicKey(pk(skR)) is a NOP, see Section 7.1.1
387 crypto_scalarmult_curve25519_base (pkR, skR->d);
388 // kem_context = concat(enc, pkRm)
389 memcpy (kem_context, c, sizeof *c);
390 memcpy (kem_context + sizeof *c, pkR, sizeof pkR);
391 // shared_secret = ExtractAndExpand(dh, kem_context)
393 &dh, sizeof dh,
394 "HPKE-v1",
395 "HPKE-v1",
396 "eae_prk", strlen ("eae_prk"),
397 "shared_secret", strlen ("shared_secret"),
398 kem_context, sizeof kem_context,
401 shared_secret);
402}
403
404
405// FIXME use Ed -> Curve conversion???
409 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
410 struct GNUNET_ShortHashCode *shared_secret)
411{
413
414 // This maps the ed25519 point to X25519
415 if (0 != crypto_sign_ed25519_sk_to_curve25519 (skR.d, priv->d))
416 return GNUNET_SYSERR;
417 return GNUNET_CRYPTO_hpke_kem_decaps (&skR, c, shared_secret);
418
419}
420
421
424 uint8_t random_tweak,
425 const struct GNUNET_CRYPTO_EcdhePublicKey *pkR,
428 struct GNUNET_ShortHashCode *shared_secret)
429{
431 // skE, pkE = GenerateElligatorKeyPair()
432 // enc = SerializePublicKey(pkE) == c is the elligator representative
434 skE,
435 &pkE,
436 (struct
438 *) c);
439
442 pkR, c, (const struct
444 shared_secret);
445}
446
447
450 const struct GNUNET_CRYPTO_EcdhePublicKey *pkR,
452 struct GNUNET_ShortHashCode *shared_secret)
453{
454 uint8_t random_tweak;
456
458 &random_tweak,
459 sizeof(uint8_t));
460
461 // skE, pkE = GenerateElligatorKeyPair()
463
464 return GNUNET_CRYPTO_hpke_elligator_kem_encaps_norand (random_tweak, pkR, c,
465 &skE, shared_secret);
466}
467
468
471 const struct GNUNET_CRYPTO_EcdhePrivateKey *skR,
472 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
473 struct GNUNET_ShortHashCode *shared_secret)
474{
478 uint8_t kem_context[sizeof *r + crypto_scalarmult_curve25519_BYTES];
479 uint8_t pkR[crypto_scalarmult_BYTES];
480
482 // pkE = DeserializePublicKey(enc) Elligator deserialize!
484 // dh = DH(skR, pkE)
486 &dh));
487 // pkRm = DeserializePublicKey(pk(skR)) is a NOP, see Section 7.1.1
488 crypto_scalarmult_curve25519_base (pkR, skR->d);
489 memcpy (kem_context, r, sizeof *r);
490 memcpy (kem_context + sizeof *r, pkR, sizeof pkR);
491 // shared_secret = ExtractAndExpand(dh, kem_context)
493 &dh, sizeof dh,
494 "HPKE-v1",
495 "HPKE-v1",
496 "eae_prk", strlen ("eae_prk"),
497 "shared_secret", strlen ("shared_secret"),
498 kem_context, sizeof kem_context,
501 shared_secret);
502}
503
504
507 const struct GNUNET_CRYPTO_EcdhePublicKey *pkR,
508 const struct GNUNET_CRYPTO_EcdhePrivateKey *skS,
511 struct GNUNET_ShortHashCode *shared_secret)
512{
514 // skE, pkE = GenerateElligatorKeyPair()
515 // enc = SerializePublicKey(pkE) == c is the elligator representative
517 skE, &pkE,
519
522 ,
523 pkR, skS, c,
524 (const struct
526 shared_secret);
527}
528
529
532 const struct GNUNET_CRYPTO_EcdhePublicKey *pkR,
533 const struct GNUNET_CRYPTO_EcdhePrivateKey *skS,
535 struct GNUNET_ShortHashCode *shared_secret)
536{
538 // skE, pkE = GenerateElligatorKeyPair()
540
542 shared_secret);
543}
544
545
548 const uint8_t *psk, size_t psk_len,
549 const uint8_t *psk_id, size_t psk_id_len)
550{
551 bool got_psk;
552 bool got_psk_id;
553
554 got_psk = (0 != psk_len);
555 got_psk_id = (0 != psk_id_len);
556
557 if (got_psk != got_psk_id)
558 {
560 "Inconsistent PSK inputs\n");
561 return GNUNET_SYSERR;
562 }
563
564 if (got_psk &&
567 {
569 "PSK input provided when not needed\n");
570 return GNUNET_SYSERR;
571 }
572 if (! got_psk &&
575 {
577 "Missing required PSK input\n");
578 return GNUNET_SYSERR;
579 }
580 return GNUNET_OK;
581}
582
583
587 const struct GNUNET_ShortHashCode *shared_secret,
588 const uint8_t *info, size_t info_len,
589 const uint8_t *psk, size_t psk_len,
590 const uint8_t *psk_id, size_t psk_id_len,
592{
593 struct GNUNET_ShortHashCode psk_id_hash;
594 struct GNUNET_ShortHashCode info_hash;
595 struct GNUNET_ShortHashCode secret;
596 uint8_t key_schedule_context[1 + sizeof info_hash * 2];
597 uint8_t suite_id[strlen ("HPKE") + 6];
598 uint16_t kem_id = htons (32); // FIXME hardcode as constant
599 uint16_t kdf_id = htons (1); // HKDF-256 FIXME hardcode as constant
600 uint16_t aead_id = htons (3); // ChaCha20Poly1305 FIXME hardcode as constant
601
602 // DHKEM(X25519, HKDF-256): kem_id = 32
603 // concat("KEM", I2OSP(kem_id, 2))
604 memcpy (suite_id, "HPKE", 4);
605 memcpy (suite_id + 4, &kem_id, 2);
606 memcpy (suite_id + 6, &kdf_id, 2);
607 memcpy (suite_id + 8, &aead_id, 2);
608
609 if (GNUNET_OK != verify_psk_inputs (mode, psk, psk_len, psk_id, psk_id_len))
610 return GNUNET_SYSERR;
611
612 if (GNUNET_OK != labeled_extract ("HPKE-v1", NULL, 0,
613 "psk_id_hash", strlen ("psk_id_hash"),
614 psk_id, psk_id_len,
615 suite_id, sizeof suite_id, &psk_id_hash))
616 return GNUNET_SYSERR;
617 if (GNUNET_OK != labeled_extract ("HPKE-v1", NULL, 0,
618 "info_hash", strlen ("info_hash"),
619 info, info_len,
620 suite_id, sizeof suite_id, &info_hash))
621 return GNUNET_SYSERR;
622 memcpy (key_schedule_context, &mode, 1);
623 memcpy (key_schedule_context + 1, &psk_id_hash, sizeof psk_id_hash);
624 memcpy (key_schedule_context + 1 + sizeof psk_id_hash,
625 &info_hash, sizeof info_hash);
626 if (GNUNET_OK != labeled_extract ("HPKE-v1",
627 shared_secret, sizeof *shared_secret,
628 "secret", strlen ("secret"),
629 psk, psk_len,
630 suite_id, sizeof suite_id, &secret))
631 return GNUNET_SYSERR;
632 // key = LabeledExpand(secret, "key", key_schedule_context, Nk)
633 // Note: Nk == sizeof ctx->key
634 if (GNUNET_OK != labeled_expand ("HPKE-v1",
635 &secret,
636 "key", strlen ("key"),
637 &key_schedule_context,
638 sizeof key_schedule_context,
639 suite_id, sizeof suite_id,
640 ctx->key, sizeof ctx->key))
641 return GNUNET_SYSERR;
642 // base_nonce = LabeledExpand(secret, "base_nonce",
643 // key_schedule_context, Nn)
644 if (GNUNET_OK != labeled_expand ("HPKE-v1",
645 &secret,
646 "base_nonce", strlen ("base_nonce"),
647 &key_schedule_context,
648 sizeof key_schedule_context,
649 suite_id, sizeof suite_id,
650 ctx->base_nonce, sizeof ctx->base_nonce))
651 return GNUNET_SYSERR;
652 // exporter_secret = LabeledExpand(secret, "exp",
653 // key_schedule_context, Nh)
654 if (GNUNET_OK != labeled_expand ("HPKE-v1",
655 &secret,
656 "exp", strlen ("exp"),
657 &key_schedule_context,
658 sizeof key_schedule_context,
659 suite_id, sizeof suite_id,
660 &ctx->exporter_secret,
661 sizeof ctx->exporter_secret))
662 return GNUNET_SYSERR;
663 ctx->seq = 0;
664 ctx->role = role;
665 return GNUNET_OK;
666}
667
668
671 enum GNUNET_CRYPTO_HpkeKem kem,
675 const struct GNUNET_CRYPTO_EcdhePublicKey *pkR,
676 const uint8_t *info, size_t info_len,
677 const uint8_t *psk, size_t psk_len,
678 const uint8_t *psk_id, size_t psk_id_len,
681{
682 struct GNUNET_ShortHashCode shared_secret;
683
684 switch (mode)
685 {
689 {
691 &shared_secret))
692 return GNUNET_SYSERR;
693 break;
694 }
695 else if (kem ==
697 {
698 uint8_t random_tweak;
700 &random_tweak,
701 sizeof(uint8_t));
702 if (GNUNET_OK !=
704 pkR,
705 enc,
706 (struct
708 *) skE,
709 &shared_secret))
710 return GNUNET_SYSERR;
711 }
712 break;
715 if (NULL == skS)
716 return GNUNET_SYSERR;
718 enc, skE,
719 &shared_secret))
720 return GNUNET_SYSERR;
721 break;
722 default:
723 return GNUNET_SYSERR;
724 }
726 mode,
727 &shared_secret,
728 info, info_len,
729 psk, psk_len,
730 psk_id, psk_id_len,
731 ctx))
732 return GNUNET_SYSERR;
733 return GNUNET_OK;
734}
735
736
739 const uint8_t *info, size_t info_len,
742{
744 // skE, pkE = GenerateKeyPair()
746
750 &sk, NULL,
751 pkR, info, info_len,
752 NULL, 0,
753 NULL, 0,
754 enc,
755 ctx);
756}
757
758
761 enum GNUNET_CRYPTO_HpkeKem kem,
764 const struct GNUNET_CRYPTO_EcdhePrivateKey *skR,
765 const struct GNUNET_CRYPTO_EcdhePublicKey *pkS,
766 const uint8_t *info, size_t info_len,
767 const uint8_t *psk, size_t psk_len,
768 const uint8_t *psk_id, size_t psk_id_len,
770{
771 struct GNUNET_ShortHashCode shared_secret;
772
773 switch (mode)
774 {
778 {
780 &shared_secret))
781 return GNUNET_SYSERR;
782 }
783 else if (kem ==
785 {
787 enc,
788 &shared_secret))
789 return GNUNET_SYSERR;
790 }
791 break;
794 if (NULL == pkS)
795 return GNUNET_SYSERR;
797 enc,
798 &shared_secret))
799 return GNUNET_SYSERR;
800 break;
801 default:
802 return GNUNET_SYSERR;
803 }
805 mode,
806 &shared_secret,
807 info, info_len,
808 psk, psk_len,
809 psk_id, psk_id_len,
810 ctx))
811 return GNUNET_SYSERR;
812 return GNUNET_OK;
813}
814
815
819 const struct GNUNET_CRYPTO_EcdhePrivateKey *skR,
820 const uint8_t *info, size_t info_len,
822{
826 enc, skR, NULL,
827 info, info_len,
828 NULL, 0, NULL, 0, ctx);
829}
830
831
834{
835 if (ctx->seq >= UINT64_MAX)
836 {
837 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MessageLimitReached\n");
838 return GNUNET_SYSERR;
839 }
840 ctx->seq = GNUNET_htonll (GNUNET_ntohll (ctx->seq) + 1);
841 return GNUNET_OK;
842}
843
844
845static void
847 uint8_t *nonce)
848{
849 size_t offset = GNUNET_CRYPTO_HPKE_NONCE_LEN - sizeof ctx->seq;
850 int j = 0;
851 for (int i = 0; i < GNUNET_CRYPTO_HPKE_NONCE_LEN; i++)
852 {
853 // FIXME correct byte order?
854 if (i < offset)
855 memset (&nonce[i], ctx->base_nonce[i], 1);
856 else
857 nonce[i] = ctx->base_nonce[i] ^ ((uint8_t*) &ctx->seq)[j++];
858 }
859}
860
861
864 const uint8_t*aad, size_t aad_len,
865 const uint8_t *pt, size_t pt_len,
866 uint8_t *ct, unsigned long long *ct_len_p)
867{
868 uint8_t comp_nonce[GNUNET_CRYPTO_HPKE_NONCE_LEN];
869 if (ctx->role != GNUNET_CRYPTO_HPKE_ROLE_S)
870 {
872 "HPKE: Wrong role; called as receiver (%d)!\n",
873 ctx->role);
874 return GNUNET_SYSERR;
875 }
876 compute_nonce (ctx, comp_nonce);
877 crypto_aead_chacha20poly1305_ietf_encrypt (ct, ct_len_p,
878 pt, pt_len,
879 aad, aad_len,
880 NULL,
881 comp_nonce,
882 ctx->key);
883 if (GNUNET_OK != increment_seq (ctx))
884 {
886 "HPKE: Seq increment failed!\n");
887 return GNUNET_SYSERR;
888 }
889 return GNUNET_OK;
890}
891
892
895 const uint8_t*aad, size_t aad_len,
896 const uint8_t *ct, size_t ct_len,
897 uint8_t *pt, unsigned long long *pt_len)
898{
899 uint8_t comp_nonce[GNUNET_CRYPTO_HPKE_NONCE_LEN];
900 if (ctx->role != GNUNET_CRYPTO_HPKE_ROLE_R)
901 {
903 "HPKE: Wrong role; called as sender (%d)!\n",
904 ctx->role);
905 return GNUNET_SYSERR;
906 }
907 compute_nonce (ctx, comp_nonce);
908 if (0 != crypto_aead_chacha20poly1305_ietf_decrypt (pt, pt_len,
909 NULL,
910 ct, ct_len,
911 aad, aad_len,
912 comp_nonce,
913 ctx->key))
914 {
915 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "OpenError\n");
916 return GNUNET_SYSERR;
917 }
918 if (GNUNET_OK != increment_seq (ctx))
919 {
921 "HPKE: Seq increment failed!\n");
922 return GNUNET_SYSERR;
923 }
924 return GNUNET_OK;
925}
926
927
930 const uint8_t *info, size_t info_len,
931 const uint8_t*aad, size_t aad_len,
932 const uint8_t *pt, size_t pt_len,
933 uint8_t *ct, unsigned long long *ct_len_p)
934{
937 uint8_t *ct_off;
938
940 ct_off = (uint8_t*) &enc[1];
942 info, info_len,
943 enc, &ctx))
944 {
946 "HPKE: Sender setup failed!\n");
947 return GNUNET_SYSERR;
948 }
950 aad, aad_len,
951 pt, pt_len,
952 ct_off,
953 ct_len_p);
954}
955
956
959 const struct GNUNET_CRYPTO_EcdhePrivateKey *skR,
960 const uint8_t *info, size_t info_len,
961 const uint8_t*aad, size_t aad_len,
962 const uint8_t *ct, size_t ct_len,
963 uint8_t *pt, unsigned long long *pt_len_p)
964{
967 uint8_t *ct_off;
968
970 ct_off = (uint8_t*) &enc[1];
972 info, info_len,
973 &ctx))
974 {
976 "HPKE: Receiver setup failed!\n");
977 return GNUNET_SYSERR;
978 }
980 aad, aad_len,
981 ct_off,
982 ct_len - sizeof *enc,
983 pt,
984 pt_len_p);
985}
986
987
990 struct GNUNET_CRYPTO_EcdhePublicKey *x25519)
991{
992 switch (ntohl (pk->type))
993 {
995 if (0 != crypto_sign_ed25519_pk_to_curve25519 (x25519->q_y,
996 pk->ecdsa_key.q_y))
997 return GNUNET_SYSERR;
998 return GNUNET_OK;
1000 if (0 != crypto_sign_ed25519_pk_to_curve25519 (x25519->q_y,
1001 pk->eddsa_key.q_y))
1002 return GNUNET_SYSERR;
1003 return GNUNET_OK;
1004 default:
1005 return GNUNET_SYSERR;
1006 }
1007 return GNUNET_SYSERR;
1008
1009}
1010
1011
1014 struct GNUNET_CRYPTO_EcdhePrivateKey *x25519)
1015{
1016 switch (ntohl (sk->type))
1017 {
1019 memcpy (x25519->d, sk->ecdsa_key.d,
1020 sizeof sk->ecdsa_key.d);
1021 return GNUNET_OK;
1023 if (0 != crypto_sign_ed25519_sk_to_curve25519 (x25519->d,
1024 sk->eddsa_key.d))
1025 return GNUNET_SYSERR;
1026 return GNUNET_OK;
1027 default:
1028 return GNUNET_SYSERR;
1029 }
1030 return GNUNET_SYSERR;
1031
1032}
static enum GNUNET_GenericReturnValue authkem_encaps_norand(uint8_t *suite_id, size_t suite_id_len, const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, const struct GNUNET_CRYPTO_EcdhePrivateKey *skS, struct GNUNET_CRYPTO_HpkeEncapsulation *c, const struct GNUNET_CRYPTO_EcdhePrivateKey *skE, struct GNUNET_ShortHashCode *shared_secret)
Definition: crypto_hpke.c:166
static void compute_nonce(struct GNUNET_CRYPTO_HpkeContext *ctx, uint8_t *nonce)
Definition: crypto_hpke.c:846
static enum GNUNET_GenericReturnValue key_schedule(enum GNUNET_CRYPTO_HpkeRole role, enum GNUNET_CRYPTO_HpkeMode mode, const struct GNUNET_ShortHashCode *shared_secret, const uint8_t *info, size_t info_len, const uint8_t *psk, size_t psk_len, const uint8_t *psk_id, size_t psk_id_len, struct GNUNET_CRYPTO_HpkeContext *ctx)
Definition: crypto_hpke.c:585
static enum GNUNET_GenericReturnValue increment_seq(struct GNUNET_CRYPTO_HpkeContext *ctx)
Definition: crypto_hpke.c:833
static enum GNUNET_GenericReturnValue labeled_extract(const char *ctx_str, const void *salt, size_t salt_len, const void *label, size_t label_len, const void *ikm, size_t ikm_len, const uint8_t *suite_id, size_t suite_id_len, struct GNUNET_ShortHashCode *prk)
A RFC9180 inspired labeled extract.
Definition: crypto_hpke.c:51
static enum GNUNET_GenericReturnValue kem_encaps_norand(uint8_t *suite_id, size_t suite_id_len, const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, const struct GNUNET_CRYPTO_EcdhePrivateKey *skE, struct GNUNET_ShortHashCode *shared_secret)
Definition: crypto_hpke.c:246
static enum GNUNET_GenericReturnValue verify_psk_inputs(enum GNUNET_CRYPTO_HpkeMode mode, const uint8_t *psk, size_t psk_len, const uint8_t *psk_id, size_t psk_id_len)
Definition: crypto_hpke.c:547
static uint8_t GNUNET_CRYPTO_HPKE_KEM_SUITE_ID[]
Definition: crypto_hpke.c:158
static enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_labeled_extract_and_expand(const void *dh, size_t dh_len, const char *extract_ctx, const char *expand_ctx, const void *extract_lbl, size_t extract_lbl_len, const void *expand_lbl, size_t expand_lbl_len, const uint8_t *kem_context, size_t kem_context_len, const uint8_t *suite_id, size_t suite_id_len, struct GNUNET_ShortHashCode *shared_secret)
Definition: crypto_hpke.c:124
static enum GNUNET_GenericReturnValue labeled_expand(const char *ctx_str, const struct GNUNET_ShortHashCode *prk, const char *label, size_t label_len, const void *info, size_t info_len, const uint8_t *suite_id, size_t suite_id_len, void *out_buf, uint16_t out_len)
A RFC9180 inspired labeled extract.
Definition: crypto_hpke.c:94
static uint8_t GNUNET_CRYPTO_HPKE_KEM_ELLIGATOR_SUITE_ID[]
Definition: crypto_hpke.c:163
static struct GNUNET_FS_Handle * ctx
static OpusEncoder * enc
OPUS encoder.
struct GNUNET_CRYPTO_PrivateKey pk
Private key from command line option, or NULL.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:47
static struct GNUNET_CRYPTO_PowSalt salt
Salt for PoW calculations.
Definition: gnunet-scrypt.c:34
#define info
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
static enum @44 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_kem_encaps_norand(const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, struct GNUNET_CRYPTO_HpkeEncapsulation *enc, const struct GNUNET_CRYPTO_EcdhePrivateKey *skE, struct GNUNET_ShortHashCode *shared_secret)
Deterministic variant of GNUNET_CRYPTO_hpke_kem_encaps.
Definition: crypto_hpke.c:282
void GNUNET_CRYPTO_ecdhe_key_create(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:454
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_authkem_encaps_norand(const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, const struct GNUNET_CRYPTO_EcdhePrivateKey *skS, struct GNUNET_CRYPTO_HpkeEncapsulation *c, const struct GNUNET_CRYPTO_EcdhePrivateKey *skE, struct GNUNET_ShortHashCode *shared_secret)
Encapsulate authenticated key material for a X25519 public key.
Definition: crypto_hpke.c:212
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_kem_decaps(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Decapsulate a key for a private EdDSA key.
Definition: crypto_hpke.c:407
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdhe_elligator_key_get_public(const struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *sk, struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_CRYPTO_ElligatorRepresentative *repr)
Generates a valid public key for elligator's inverse map by adding a lower order point to a prime ord...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_x25519_ecdh(const struct GNUNET_CRYPTO_EcdhePrivateKey *sk, const struct GNUNET_CRYPTO_EcdhePublicKey *pk, struct GNUNET_CRYPTO_EcdhePublicKey *dh)
Derive key material from a ECDH public key and a private X25519 key.
Definition: crypto_ecc.c:767
void GNUNET_CRYPTO_ecdhe_elligator_key_create(struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *sk)
Generates a private key for Curve25519.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_kem_decaps(const struct GNUNET_CRYPTO_EcdhePrivateKey *skR, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Carries out ecdh decapsulation with own private key and the representative of the received public key...
Definition: crypto_hpke.c:470
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_kem_encaps(const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Encapsulate key material for a X25519 public key.
Definition: crypto_hpke.c:299
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_authkem_decaps(const struct GNUNET_CRYPTO_EcdhePrivateKey *skR, const struct GNUNET_CRYPTO_EcdhePublicKey *pkS, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Decapsulate a key for a private X25519 key.
Definition: crypto_hpke.c:327
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_kem_decaps(const struct GNUNET_CRYPTO_EcdhePrivateKey *skR, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Decapsulate a key for a private X25519 key.
Definition: crypto_hpke.c:370
void GNUNET_CRYPTO_ecdhe_elligator_decoding(struct GNUNET_CRYPTO_EcdhePublicKey *point, bool *high_y, const struct GNUNET_CRYPTO_ElligatorRepresentative *representative)
Clears the most significant bit and second most significant bit of the serialized representaive befor...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdhe_elligator_key_get_public_norand(uint8_t random_tweak, const struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *sk, struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_CRYPTO_ElligatorRepresentative *repr)
Generates a valid public key for elligator's inverse map by adding a lower order point to a prime ord...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_kem_encaps(const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Carries out ecdh encapsulation with given public key and the private key from a freshly created ephem...
Definition: crypto_hpke.c:449
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_kem_encaps_norand(uint8_t random_tweak, const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, struct GNUNET_CRYPTO_HpkeEncapsulation *c, const struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *skE, struct GNUNET_ShortHashCode *shared_secret)
Carries out ecdh encapsulation with given public key and the private key from a freshly created ephem...
Definition: crypto_hpke.c:423
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdh_x25519(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_CRYPTO_EcdhePublicKey *dh)
Derive key material from a EdDSA public key and a private ECDH key.
Definition: crypto_ecc.c:783
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_kem_encaps(const struct GNUNET_CRYPTO_EddsaPublicKey *pub, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Encapsulate key material for a EdDSA public key.
Definition: crypto_hpke.c:312
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_authkem_encaps(const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, const struct GNUNET_CRYPTO_EcdhePrivateKey *skS, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Encapsulate authenticated key material for a X25519 public key.
Definition: crypto_hpke.c:230
void GNUNET_CRYPTO_ecdhe_key_get_public(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, struct GNUNET_CRYPTO_EcdhePublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:217
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_authkem_encaps_norand(const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, const struct GNUNET_CRYPTO_EcdhePrivateKey *skS, struct GNUNET_CRYPTO_HpkeEncapsulation *c, const struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *skE, struct GNUNET_ShortHashCode *shared_secret)
Encapsulate authenticated key material for a X25519 public key.
Definition: crypto_hpke.c:506
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_authkem_encaps(const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, const struct GNUNET_CRYPTO_EcdhePrivateKey *skS, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Encapsulate authenticated key material for a X25519 public key.
Definition: crypto_hpke.c:531
@ GNUNET_CRYPTO_QUALITY_NONCE
Randomness for IVs etc.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf_extract(struct GNUNET_ShortHashCode *prk, const void *salt, size_t salt_len, const void *ikm, size_t ikm_len)
HKDF-Extract using SHA256.
Definition: crypto_hkdf.c:224
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf_expand(void *result, size_t out_len, const struct GNUNET_ShortHashCode *prk,...)
HKDF-Expand using SHA256.
Definition: crypto_hkdf.c:156
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_open_oneshot(const struct GNUNET_CRYPTO_EcdhePrivateKey *skR, const uint8_t *info, size_t info_len, const uint8_t *aad, size_t aad_len, const uint8_t *ct, size_t ct_len, uint8_t *pt, unsigned long long *pt_len_p)
RFC9180 HPKE encryption.
Definition: crypto_hpke.c:958
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sender_setup2(enum GNUNET_CRYPTO_HpkeKem kem, enum GNUNET_CRYPTO_HpkeMode mode, struct GNUNET_CRYPTO_EcdhePrivateKey *skE, struct GNUNET_CRYPTO_EcdhePrivateKey *skS, const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, const uint8_t *info, size_t info_len, const uint8_t *psk, size_t psk_len, const uint8_t *psk_id, size_t psk_id_len, struct GNUNET_CRYPTO_HpkeEncapsulation *enc, struct GNUNET_CRYPTO_HpkeContext *ctx)
RFC9180 HPKE encryption.
Definition: crypto_hpke.c:670
GNUNET_CRYPTO_HpkeKem
#define GNUNET_log(kind,...)
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_seal_oneshot(const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, const uint8_t *info, size_t info_len, const uint8_t *aad, size_t aad_len, const uint8_t *pt, size_t pt_len, uint8_t *ct, unsigned long long *ct_len_p)
RFC9180 HPKE encryption.
Definition: crypto_hpke.c:929
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_seal(struct GNUNET_CRYPTO_HpkeContext *ctx, const uint8_t *aad, size_t aad_len, const uint8_t *pt, size_t pt_len, uint8_t *ct, unsigned long long *ct_len_p)
RFC9180 HPKE encryption.
Definition: crypto_hpke.c:863
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_open(struct GNUNET_CRYPTO_HpkeContext *ctx, const uint8_t *aad, size_t aad_len, const uint8_t *ct, size_t ct_len, uint8_t *pt, unsigned long long *pt_len)
RFC9180 HPKE encryption.
Definition: crypto_hpke.c:894
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37
#define GNUNET_CRYPTO_HPKE_NONCE_LEN
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sk_to_x25519(const struct GNUNET_CRYPTO_PrivateKey *sk, struct GNUNET_CRYPTO_EcdhePrivateKey *x25519)
Convert a GNUnet identity key to a key sutiable for HPKE (X25519)
Definition: crypto_hpke.c:1013
GNUNET_CRYPTO_HpkeMode
HPKE RFC 9180.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_pk_to_x25519(const struct GNUNET_CRYPTO_PublicKey *pk, struct GNUNET_CRYPTO_EcdhePublicKey *x25519)
Convert a GNUnet identity key to a key sutiable for HPKE (X25519)
Definition: crypto_hpke.c:989
GNUNET_GenericReturnValue
Named constants for return values.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_receiver_setup(const struct GNUNET_CRYPTO_HpkeEncapsulation *enc, const struct GNUNET_CRYPTO_EcdhePrivateKey *skR, const uint8_t *info, size_t info_len, struct GNUNET_CRYPTO_HpkeContext *ctx)
RFC9180 HPKE encryption.
Definition: crypto_hpke.c:817
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_receiver_setup2(enum GNUNET_CRYPTO_HpkeKem kem, enum GNUNET_CRYPTO_HpkeMode mode, const struct GNUNET_CRYPTO_HpkeEncapsulation *enc, const struct GNUNET_CRYPTO_EcdhePrivateKey *skR, const struct GNUNET_CRYPTO_EcdhePublicKey *pkS, const uint8_t *info, size_t info_len, const uint8_t *psk, size_t psk_len, const uint8_t *psk_id, size_t psk_id_len, struct GNUNET_CRYPTO_HpkeContext *ctx)
RFC9180 HPKE encryption.
Definition: crypto_hpke.c:760
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sender_setup(const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, const uint8_t *info, size_t info_len, struct GNUNET_CRYPTO_HpkeEncapsulation *enc, struct GNUNET_CRYPTO_HpkeContext *ctx)
RFC9180 HPKE encryption.
Definition: crypto_hpke.c:738
GNUNET_CRYPTO_HpkeRole
@ GNUNET_CRYPTO_HPKE_KEM_DH_X25519_HKDF256
@ GNUNET_CRYPTO_HPKE_KEM_DH_X25519ELLIGATOR_HKDF256
@ GNUNET_PUBLIC_KEY_TYPE_EDDSA
EDDSA identity.
@ GNUNET_PUBLIC_KEY_TYPE_ECDSA
The identity type.
@ GNUNET_CRYPTO_HPKE_MODE_PSK
@ GNUNET_CRYPTO_HPKE_MODE_AUTH_PSK
@ GNUNET_CRYPTO_HPKE_MODE_BASE
@ GNUNET_CRYPTO_HPKE_MODE_AUTH
@ GNUNET_OK
@ GNUNET_SYSERR
@ GNUNET_CRYPTO_HPKE_ROLE_R
@ GNUNET_CRYPTO_HPKE_ROLE_S
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_ERROR
Private ECC key encoded for transmission.
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and encr...
unsigned char q_y[256/8]
Q consists of an x- and a y-value, each mod p (256 bits), given here in affine coordinates and Ed2551...
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Private ECC key encoded for transmission.
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
unsigned char q_y[256/8]
Point Q consists of a y-value mod p (256 bits); the x-value is always positive.
Special private ECC key generated by GNUNET_CRYPTO_ecdhe_elligator_key_create.
Elligator representative (always for Curve25519)
uint8_t r[256/8]
Represents an element of Curve25519 finite field.
HPKE DHKEM encapsulation (X25519) See RFC 9180.
A private key for an identity as per LSD0001.
uint32_t type
Type of public key.
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_key
AN EdDSA identtiy key.
struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key
An ECDSA identity key.
An identity key as per LSD0001.
A 256-bit hashcode.