GNUnet 0.28.0-dev.2-5-gff43856e1
 
Loading...
Searching...
No Matches
fs_publish_ublock.h File Reference

publish a UBLOCK in GNUnet More...

Include dependency graph for fs_publish_ublock.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(* GNUNET_FS_UBlockContinuation) (void *cls, const char *emsg)
 Signature of a function called as the continuation of a UBlock publication.
 

Functions

void GNUNET_FS_ublock_decrypt_ (const void *input, size_t input_len, const struct GNUNET_CRYPTO_EddsaPublicKey *ns, const char *label, void *output)
 Decrypt the given UBlock, storing the result in output.
 
struct GNUNET_FS_PublishUblockContextGNUNET_FS_publish_ublock_ (struct GNUNET_FS_Handle *h, struct GNUNET_DATASTORE_Handle *dsh, const char *label, const char *ulabel, const struct GNUNET_CRYPTO_EddsaPrivateKey *ns, const struct GNUNET_FS_MetaData *meta, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_BlockOptions *bo, enum GNUNET_FS_PublishOptions options, GNUNET_FS_UBlockContinuation cont, void *cont_cls)
 Publish a UBlock.
 
void GNUNET_FS_publish_ublock_cancel_ (struct GNUNET_FS_PublishUblockContext *uc)
 Abort UBlock publishing operation.
 

Detailed Description

publish a UBLOCK in GNUnet

See also
https://gnunet.org/encoding and #2564
Author
Krista Bennett
Christian Grothoff

Definition in file fs_publish_ublock.h.

Typedef Documentation

◆ GNUNET_FS_UBlockContinuation

typedef void(* GNUNET_FS_UBlockContinuation) (void *cls, const char *emsg)

Signature of a function called as the continuation of a UBlock publication.

Parameters
clsclosure
emsgerror message, NULL on success

Definition at line 68 of file fs_publish_ublock.h.

Function Documentation

◆ GNUNET_FS_ublock_decrypt_()

void GNUNET_FS_ublock_decrypt_ ( const void *  input,
size_t  input_len,
const struct GNUNET_CRYPTO_EddsaPublicKey ns,
const char *  label,
void *  output 
)

Decrypt the given UBlock, storing the result in output.

Parameters
inputinput data
input_lennumber of bytes in input
nspublic key under which the UBlock was stored
labellabel under which the UBlock was stored
outputwhere to write the result, has input_len bytes

Definition at line 66 of file fs_publish_ublock.c.

71{
74
76 label, ns);
78 input,
79 &skey,
80 &iv,
81 output);
82}
static void derive_ublock_encryption_key(struct GNUNET_CRYPTO_XSalsa20SecretKey *skey, struct GNUNET_CRYPTO_XSalsa20Nonce *iv, const char *label, const struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Derive the key for symmetric encryption/decryption from the public key and the label.
static struct GNUNET_NAMECACHE_Handle * ns
Handle to the namecache.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_xsalsa20poly1305_decrypt(size_t in_buf_len, const unsigned char in_buf[in_buf_len], const struct GNUNET_CRYPTO_XSalsa20SecretKey *key, const struct GNUNET_CRYPTO_XSalsa20Nonce *nonce, void *out_buf)
Encrypt the given data using XSalsa20-Poly1305.

References derive_ublock_encryption_key(), GNUNET_CRYPTO_xsalsa20poly1305_decrypt(), and ns.

Referenced by decrypt_block_with_keyword(), process_kblock_for_unindex(), and process_sblock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_publish_ublock_()

struct GNUNET_FS_PublishUblockContext * GNUNET_FS_publish_ublock_ ( struct GNUNET_FS_Handle h,
struct GNUNET_DATASTORE_Handle dsh,
const char *  label,
const char *  ulabel,
const struct GNUNET_CRYPTO_EddsaPrivateKey ns,
const struct GNUNET_FS_MetaData meta,
const struct GNUNET_FS_Uri uri,
const struct GNUNET_FS_BlockOptions bo,
enum GNUNET_FS_PublishOptions  options,
GNUNET_FS_UBlockContinuation  cont,
void *  cont_cls 
)

Publish a UBlock.

Parameters
hhandle to the file sharing subsystem
dshdatastore handle to use for storage operation
labelidentifier to use
ulabelupdate label to use, may be an empty string for none
nsnamespace to publish in
metametadata to use
uriURI to refer to in the UBlock
boper-block options
optionspublication options
contcontinuation
cont_clsclosure for cont
Returns
NULL on error (cont will still be called)

Definition at line 155 of file fs_publish_ublock.c.

165{
167 struct GNUNET_HashCode query;
172 char *uris;
173 size_t size;
174 char *kbe;
175 char *sptr;
176 ssize_t mdsize;
177 size_t slen;
178 size_t ulen;
179 struct UBlock *ub_plain;
180 struct UBlock *ub_enc;
181
182 /* compute ublock to publish */
183 if (NULL == meta)
184 mdsize = 0;
185 else
187 GNUNET_assert (mdsize >= 0);
189 slen = strlen (uris) + 1;
190 if (NULL == ulabel)
191 ulen = 1;
192 else
193 ulen = strlen (ulabel) + 1;
194 size = mdsize + sizeof(struct UBlock) + slen + ulen;
195 if (size > MAX_UBLOCK_SIZE)
196 {
198 mdsize = size - sizeof(struct UBlock) - (slen + ulen);
199 }
200 ub_plain = GNUNET_malloc (size);
201 kbe = (char *) &ub_plain[1];
202 if (NULL != ulabel)
203 GNUNET_memcpy (kbe, ulabel, ulen);
204 kbe += ulen;
205 GNUNET_memcpy (kbe, uris, slen);
206 kbe += slen;
207 GNUNET_free (uris);
208 sptr = kbe;
209 if (NULL != meta)
210 mdsize =
211 GNUNET_FS_meta_data_serialize (meta, &sptr, mdsize,
213 if (-1 == mdsize)
214 {
215 GNUNET_break (0);
216 GNUNET_free (ub_plain);
217 cont (cont_cls, _ ("Internal error."));
218 return NULL;
219 }
220 size = sizeof(struct UBlock) + slen + mdsize + ulen + sizeof (struct
222
224 "Publishing under identifier `%s'\n",
225 label);
226 /* get public key of the namespace */
228 &pub);
230 label, &pub);
231
232 /* encrypt ublock */
233 ub_enc = GNUNET_malloc (size);
234 GNUNET_CRYPTO_xsalsa20poly1305_encrypt (ulen + slen + mdsize,
235 (unsigned char*) &ub_plain[1],
236 &skey,
237 &iv,
238 &ub_enc[1]);
239 GNUNET_free (ub_plain);
240 ub_enc->purpose.size = htonl (size
241 - sizeof(struct GNUNET_CRYPTO_EddsaSignature));
243
244 /* derive signing-key from 'label' and public key of the namespace */
245 GNUNET_CRYPTO_eddsa_private_key_derive (ns, label, "fs-ublock", &nsd);
247 &ub_enc->verification_key);
250 label,
251 "fs-ublock",
252 &ub_enc->purpose,
253 &ub_enc->signature));
255 sizeof(ub_enc->verification_key),
256 &query);
257
259 uc->cont = cont;
260 uc->cont_cls = cont_cls;
261 if (NULL != dsh)
262 {
263 uc->qre =
265 0,
266 &query,
267 size,
268 ub_enc,
274 -2, 1,
276 }
277 else
278 {
280 uc);
281 }
282 GNUNET_free (ub_enc);
283 return uc;
284}
static void run_cont(void *cls)
Run the continuation.
static void ublock_put_cont(void *cls, int32_t success, struct GNUNET_TIME_Absolute min_expiration, const char *msg)
Continuation of GNUNET_FS_publish_ublock_().
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static struct GNUNET_FS_MetaData * meta
Meta-data provided via command-line option.
static struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
static struct GNUNET_DATASTORE_Handle * dsh
Datastore handle.
static struct GNUNET_FS_UnindexContext * uc
@ GNUNET_BLOCK_TYPE_FS_UBLOCK
Type of a block representing any type of search result (universal).
#define GNUNET_SIGNATURE_PURPOSE_FS_UBLOCK
UBlock Signature, done using DSS, not ECC (GNUnet-FS)
#define MAX_UBLOCK_SIZE
Maximum legal size for a ublock.
Definition block_fs.h:45
void GNUNET_CRYPTO_eddsa_private_key_derive(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const char *label, const char *context, struct GNUNET_CRYPTO_EddsaPrivateScalar *result)
Derive a private scalar from a given private key and a label.
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
Definition crypto_ecc.c:201
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_xsalsa20poly1305_encrypt(size_t in_buf_len, const unsigned char in_buf[in_buf_len], const struct GNUNET_CRYPTO_XSalsa20SecretKey *key, const struct GNUNET_CRYPTO_XSalsa20Nonce *nonce, void *out_buf)
Encrypt the given data using XSalsa20-Poly1305.
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_put(struct GNUNET_DATASTORE_Handle *h, uint32_t rid, const struct GNUNET_HashCode *key, size_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the datastore.
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition fs_uri.c:2034
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition crypto_hash.c:40
#define GNUNET_log(kind,...)
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_derived(const struct GNUNET_CRYPTO_EddsaPrivateKey *pkey, const char *label, const char *context, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
This is a signature function for EdDSA which takes a private key and derives it using the label and c...
void GNUNET_CRYPTO_eddsa_key_get_public_from_scalar(const struct GNUNET_CRYPTO_EddsaPrivateScalar *s, struct GNUNET_CRYPTO_EddsaPublicKey *pkey)
Extract the public key of the given private scalar.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
ssize_t GNUNET_FS_meta_data_get_serialized_size(const struct GNUNET_FS_MetaData *md)
Get the size of the full meta-data in serialized form.
Definition meta_data.c:858
ssize_t GNUNET_FS_meta_data_serialize(const struct GNUNET_FS_MetaData *md, char **target, size_t max, enum GNUNET_FS_MetaDataSerializationOptions opt)
Serialize meta-data to target.
Definition meta_data.c:637
@ GNUNET_FS_META_DATA_SERIALIZE_PART
If not enough space is available, it is acceptable to only serialize some of the metadata.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition scheduler.c:1310
static unsigned int size
Size of the "table".
Definition peer.c:68
#define _(String)
GNU gettext support macro.
Definition platform.h:179
Private ECC scalar encoded for transmission.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
an ECC signature using EdDSA.
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
uint32_t anonymity_level
At which anonymity level should the block be shared? (0: no anonymity, 1: normal GAP,...
uint32_t content_priority
How important is it for us to store the block? If we run out of space, the highest-priority,...
uint32_t replication_level
How often should we try to migrate the block to other peers? Only used if "CONTENT_PUSHING" is set to...
struct GNUNET_TIME_Absolute expiration_time
At what time should the block expire? Data blocks (DBLOCKS and IBLOCKS) may still be used even if the...
Context for 'ublock_put_cont'.
A 512-bit hashcode.
universal block for keyword and namespace search results
Definition block_fs.h:54
struct GNUNET_CRYPTO_EddsaSignature signature
Signature using pseudonym and search keyword / identifier.
Definition block_fs.h:58
struct GNUNET_CRYPTO_SignaturePurpose purpose
What is being signed and why?
Definition block_fs.h:63
struct GNUNET_CRYPTO_EddsaPublicKey verification_key
Public key used to sign this block.
Definition block_fs.h:68

References _, GNUNET_FS_BlockOptions::anonymity_level, bo, GNUNET_FS_BlockOptions::content_priority, derive_ublock_encryption_key(), dsh, GNUNET_FS_BlockOptions::expiration_time, GNUNET_assert, GNUNET_BLOCK_TYPE_FS_UBLOCK, GNUNET_break, GNUNET_CRYPTO_eddsa_key_get_public(), GNUNET_CRYPTO_eddsa_key_get_public_from_scalar(), GNUNET_CRYPTO_eddsa_private_key_derive(), GNUNET_CRYPTO_eddsa_sign_derived(), GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_xsalsa20poly1305_encrypt(), GNUNET_DATASTORE_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_FS_meta_data_get_serialized_size(), GNUNET_FS_meta_data_serialize(), GNUNET_FS_META_DATA_SERIALIZE_PART, GNUNET_FS_uri_to_string(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_new, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SIGNATURE_PURPOSE_FS_UBLOCK, MAX_UBLOCK_SIZE, meta, ns, pub, UBlock::purpose, GNUNET_CRYPTO_SignaturePurpose::purpose, GNUNET_FS_BlockOptions::replication_level, run_cont(), UBlock::signature, GNUNET_CRYPTO_SignaturePurpose::size, size, ublock_put_cont(), uc, uri, and UBlock::verification_key.

Referenced by GNUNET_FS_publish_sks(), and publish_ksk_cont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_publish_ublock_cancel_()

void GNUNET_FS_publish_ublock_cancel_ ( struct GNUNET_FS_PublishUblockContext uc)

Abort UBlock publishing operation.

Parameters
ucoperation to abort.

Definition at line 293 of file fs_publish_ublock.c.

294{
295 if (NULL != uc->qre)
297 if (NULL != uc->task)
299 GNUNET_free (uc);
300}
void GNUNET_DATASTORE_cancel(struct GNUNET_DATASTORE_QueueEntry *qe)
Cancel a datastore operation.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:986

References GNUNET_DATASTORE_cancel(), GNUNET_free, GNUNET_SCHEDULER_cancel(), and uc.

Referenced by GNUNET_FS_publish_ksk_cancel(), and GNUNET_FS_publish_sks_cancel().

Here is the call graph for this function:
Here is the caller graph for this function: