aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2020-08-01 16:08:38 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2020-08-01 16:08:38 +0200
commit2bb07d251cc8eead7a0fcf1c0c7100477f107027 (patch)
tree7a5416b77e8a8a69e18a3be524fe078cd381c1b0 /src/include
parent754d8c1b496624e5c879af7d142fc9fd34de3a21 (diff)
parent54b5a20700a1ed27b1067a7cd55329ddc5b0d611 (diff)
downloadgnunet-2bb07d251cc8eead7a0fcf1c0c7100477f107027.tar.gz
gnunet-2bb07d251cc8eead7a0fcf1c0c7100477f107027.zip
Merge branch 'master' of ssh://gnunet.org/gnunet
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_buffer_lib.h15
-rw-r--r--src/include/gnunet_common.h38
-rw-r--r--src/include/gnunet_core_service.h116
-rw-r--r--src/include/gnunet_crypto_lib.h13
-rw-r--r--src/include/gnunet_json_lib.h2
-rw-r--r--src/include/gnunet_peerstore_service.h18
-rw-r--r--src/include/gnunet_protocols.h5
-rw-r--r--src/include/gnunet_signatures.h5
8 files changed, 191 insertions, 21 deletions
diff --git a/src/include/gnunet_buffer_lib.h b/src/include/gnunet_buffer_lib.h
index e09ec130a..046aee72b 100644
--- a/src/include/gnunet_buffer_lib.h
+++ b/src/include/gnunet_buffer_lib.h
@@ -110,6 +110,21 @@ GNUNET_buffer_write_str (struct GNUNET_Buffer *buf, const char *str);
110 110
111 111
112/** 112/**
113 * Write data encoded via #GNUNET_STRINGS_data_to_string to the buffer.
114 *
115 * Grows the buffer if necessary.
116 *
117 * @param buf buffer to write to
118 * @param data data to read from
119 * @param len number of bytes to copy from @a data to @a buf
120 */
121void
122GNUNET_buffer_write_data_encoded (struct GNUNET_Buffer *buf,
123 const char *data,
124 size_t len);
125
126
127/**
113 * Write a path component to a buffer, ensuring that 128 * Write a path component to a buffer, ensuring that
114 * there is exactly one slash between the previous contents 129 * there is exactly one slash between the previous contents
115 * of the buffer and the new string. 130 * of the buffer and the new string.
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index 91d4a5bd4..b2f99cd55 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -457,11 +457,11 @@ __attribute__ ((format (printf, 2, 3)));
457 __extension__ ({ \ 457 __extension__ ({ \
458 int _gnunet_boolean_var_; \ 458 int _gnunet_boolean_var_; \
459 if (expr) \ 459 if (expr) \
460 _gnunet_boolean_var_ = 1; \ 460 _gnunet_boolean_var_ = 1; \
461 else \ 461 else \
462 _gnunet_boolean_var_ = 0; \ 462 _gnunet_boolean_var_ = 0; \
463 _gnunet_boolean_var_; \ 463 _gnunet_boolean_var_; \
464 }) 464 })
465#define GN_LIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 1)) 465#define GN_LIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 1))
466#define GN_UNLIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 0)) 466#define GN_UNLIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 0))
467#else 467#else
@@ -499,12 +499,12 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind,
499 ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \ 499 ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \
500 { \ 500 { \
501 if (GN_UNLIKELY (log_call_enabled == -1)) \ 501 if (GN_UNLIKELY (log_call_enabled == -1)) \
502 log_call_enabled = \ 502 log_call_enabled = \
503 GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \ 503 GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \
504 (comp), \ 504 (comp), \
505 __FILE__, \ 505 __FILE__, \
506 __FUNCTION__, \ 506 __FUNCTION__, \
507 __LINE__); \ 507 __LINE__); \
508 if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \ 508 if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \
509 { \ 509 { \
510 GNUNET_log_skip (-1, GNUNET_NO); \ 510 GNUNET_log_skip (-1, GNUNET_NO); \
@@ -512,7 +512,7 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind,
512 else \ 512 else \
513 { \ 513 { \
514 if (GN_UNLIKELY (log_call_enabled)) \ 514 if (GN_UNLIKELY (log_call_enabled)) \
515 GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \ 515 GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \
516 } \ 516 } \
517 } \ 517 } \
518 } while (0) 518 } while (0)
@@ -525,12 +525,12 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind,
525 ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \ 525 ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \
526 { \ 526 { \
527 if (GN_UNLIKELY (log_call_enabled == -1)) \ 527 if (GN_UNLIKELY (log_call_enabled == -1)) \
528 log_call_enabled = \ 528 log_call_enabled = \
529 GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \ 529 GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \
530 NULL, \ 530 NULL, \
531 __FILE__, \ 531 __FILE__, \
532 __FUNCTION__, \ 532 __FUNCTION__, \
533 __LINE__); \ 533 __LINE__); \
534 if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \ 534 if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \
535 { \ 535 { \
536 GNUNET_log_skip (-1, GNUNET_NO); \ 536 GNUNET_log_skip (-1, GNUNET_NO); \
@@ -538,7 +538,7 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind,
538 else \ 538 else \
539 { \ 539 { \
540 if (GN_UNLIKELY (log_call_enabled)) \ 540 if (GN_UNLIKELY (log_call_enabled)) \
541 GNUNET_log_nocheck ((kind), __VA_ARGS__); \ 541 GNUNET_log_nocheck ((kind), __VA_ARGS__); \
542 } \ 542 } \
543 } \ 543 } \
544 } while (0) 544 } while (0)
@@ -1319,8 +1319,8 @@ GNUNET_is_zero_ (const void *a,
1319 * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier. NULL is allowed. 1319 * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier. NULL is allowed.
1320 */ 1320 */
1321#define GNUNET_free(ptr) do { \ 1321#define GNUNET_free(ptr) do { \
1322 GNUNET_xfree_ (ptr, __FILE__, __LINE__); \ 1322 GNUNET_xfree_ (ptr, __FILE__, __LINE__); \
1323 ptr = NULL; \ 1323 ptr = NULL; \
1324} while (0) 1324} while (0)
1325 1325
1326 1326
diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h
index 66b292c3c..60bc3c2a6 100644
--- a/src/include/gnunet_core_service.h
+++ b/src/include/gnunet_core_service.h
@@ -48,6 +48,122 @@ extern "C" {
48 */ 48 */
49#define GNUNET_CORE_VERSION 0x00000001 49#define GNUNET_CORE_VERSION 0x00000001
50 50
51GNUNET_NETWORK_STRUCT_BEGIN
52
53/**
54 * Message transmitted with the signed ephemeral key of a peer. The
55 * session key is then derived from the two ephemeral keys (ECDHE).
56 */
57struct EphemeralKeyMessage
58{
59 /**
60 * Message type is #GNUNET_MESSAGE_TYPE_CORE_EPHEMERAL_KEY.
61 */
62 struct GNUNET_MessageHeader header;
63
64 /**
65 * Status of the sender (should be in `enum PeerStateMachine`), nbo.
66 */
67 int32_t sender_status GNUNET_PACKED;
68
69 /**
70 * An ECC signature of the @e origin_identity asserting the validity
71 * of the given ephemeral key.
72 */
73 struct GNUNET_CRYPTO_EddsaSignature signature;
74
75 /**
76 * Information about what is being signed.
77 */
78 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
79
80 /**
81 * At what time was this key created (beginning of validity).
82 */
83 struct GNUNET_TIME_AbsoluteNBO creation_time;
84
85 /**
86 * When does the given ephemeral key expire (end of validity).
87 */
88 struct GNUNET_TIME_AbsoluteNBO expiration_time;
89
90 /**
91 * Ephemeral public ECC key.
92 */
93 struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key;
94
95 /**
96 * Public key of the signing peer (persistent version, not the
97 * ephemeral public key).
98 */
99 struct GNUNET_PeerIdentity origin_identity;
100};
101
102
103/**
104 * We're sending an (encrypted) PING to the other peer to check if it
105 * can decrypt. The other peer should respond with a PONG with the
106 * same content, except this time encrypted with the receiver's key.
107 */
108struct PingMessage
109{
110 /**
111 * Message type is #GNUNET_MESSAGE_TYPE_CORE_PING.
112 */
113 struct GNUNET_MessageHeader header;
114
115 /**
116 * Seed for the IV
117 */
118 uint32_t iv_seed GNUNET_PACKED;
119
120 /**
121 * Intended target of the PING, used primarily to check
122 * that decryption actually worked.
123 */
124 struct GNUNET_PeerIdentity target;
125
126 /**
127 * Random number chosen to make replay harder.
128 */
129 uint32_t challenge GNUNET_PACKED;
130};
131
132
133/**
134 * Response to a PING. Includes data from the original PING.
135 */
136struct PongMessage
137{
138 /**
139 * Message type is #GNUNET_MESSAGE_TYPE_CORE_PONG.
140 */
141 struct GNUNET_MessageHeader header;
142
143 /**
144 * Seed for the IV
145 */
146 uint32_t iv_seed GNUNET_PACKED;
147
148 /**
149 * Random number to make replay attacks harder.
150 */
151 uint32_t challenge GNUNET_PACKED;
152
153 /**
154 * Reserved, always zero.
155 */
156 uint32_t reserved;
157
158 /**
159 * Intended target of the PING, used primarily to check
160 * that decryption actually worked.
161 */
162 struct GNUNET_PeerIdentity target;
163};
164
165
166GNUNET_NETWORK_STRUCT_END
51 167
52/** 168/**
53 * Opaque handle to the service. 169 * Opaque handle to the service.
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 320701643..f8eef5406 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -289,6 +289,17 @@ struct GNUNET_CRYPTO_SymmetricSessionKey
289 unsigned char twofish_key[GNUNET_CRYPTO_AES_KEY_LENGTH]; 289 unsigned char twofish_key[GNUNET_CRYPTO_AES_KEY_LENGTH];
290}; 290};
291 291
292/**
293 * Type of a nonce used for challenges.
294 */
295struct ChallengeNonceP
296{
297 /**
298 * The value of the nonce. Note that this is NOT a hash.
299 */
300 struct GNUNET_ShortHashCode value;
301};
302
292GNUNET_NETWORK_STRUCT_END 303GNUNET_NETWORK_STRUCT_END
293 304
294/** 305/**
@@ -1779,7 +1790,7 @@ GNUNET_CRYPTO_eddsa_verify_ (
1779 */ 1790 */
1780#define GNUNET_CRYPTO_eddsa_verify(purp,ps,sig,pub) ({ \ 1791#define GNUNET_CRYPTO_eddsa_verify(purp,ps,sig,pub) ({ \
1781 /* check size is set correctly */ \ 1792 /* check size is set correctly */ \
1782 GNUNET_assert (htonl ((ps)->purpose.size) == sizeof (*(ps))); \ 1793 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
1783 /* check 'ps' begins with the purpose */ \ 1794 /* check 'ps' begins with the purpose */ \
1784 GNUNET_static_assert (((void*) (ps)) == \ 1795 GNUNET_static_assert (((void*) (ps)) == \
1785 ((void*) &(ps)->purpose)); \ 1796 ((void*) &(ps)->purpose)); \
diff --git a/src/include/gnunet_json_lib.h b/src/include/gnunet_json_lib.h
index 95d136239..07a14d329 100644
--- a/src/include/gnunet_json_lib.h
+++ b/src/include/gnunet_json_lib.h
@@ -127,7 +127,7 @@ struct GNUNET_JSON_Specification
127 * @param[out] which index into @a spec did we encounter an error 127 * @param[out] which index into @a spec did we encounter an error
128 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 128 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
129 */ 129 */
130int 130enum GNUNET_GenericReturnValue
131GNUNET_JSON_parse (const json_t *root, 131GNUNET_JSON_parse (const json_t *root,
132 struct GNUNET_JSON_Specification *spec, 132 struct GNUNET_JSON_Specification *spec,
133 const char **error_json_name, 133 const char **error_json_name,
diff --git a/src/include/gnunet_peerstore_service.h b/src/include/gnunet_peerstore_service.h
index cd68dad66..91a8f2e66 100644
--- a/src/include/gnunet_peerstore_service.h
+++ b/src/include/gnunet_peerstore_service.h
@@ -67,6 +67,24 @@ extern "C" {
67#define GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME \ 67#define GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME \
68 "transport-dv-learn-monotonic-time" 68 "transport-dv-learn-monotonic-time"
69 69
70/**
71 * Key used to store sender's monotonic time from handshake message.
72 */
73#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE \
74 "transport-tcp-communicator-handshake"
75
76/**
77 * Key used to store sender's monotonic time from handshake ack message.
78 */
79#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK \
80 "transport-tcp-communicator-handshake-ack"
81
82/**
83 * Key used to store sender's monotonic time from rekey message.
84 */
85#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY \
86 "transport-tcp-communicator-rekey"
87
70 88
71/** 89/**
72 * Options for storing values in PEERSTORE 90 * Options for storing values in PEERSTORE
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 0db6150aa..5af58664f 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -3293,6 +3293,11 @@ extern "C" {
3293#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_FINISH 1452 3293#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_FINISH 1452
3294 3294
3295/** 3295/**
3296 * TCP communicator confirmation ack.
3297 */
3298#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK 1453
3299
3300/**
3296 * UDP KX acknowledgement. 3301 * UDP KX acknowledgement.
3297 */ 3302 */
3298#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK 1460 3303#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK 1460
diff --git a/src/include/gnunet_signatures.h b/src/include/gnunet_signatures.h
index 503113770..7c0c1d104 100644
--- a/src/include/gnunet_signatures.h
+++ b/src/include/gnunet_signatures.h
@@ -246,6 +246,11 @@ extern "C"
246 */ 246 */
247#define GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR 38 247#define GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR 38
248 248
249/**
250 * Signature by a peer sending back the nonce received at initial handshake.
251 */
252#define GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE_ACK 39
253
249#if 0 /* keep Emacsens' auto-indent happy */ 254#if 0 /* keep Emacsens' auto-indent happy */
250{ 255{
251#endif 256#endif