|
| void | GNR_derive_block_aes_key (unsigned char *ctr, unsigned char *key, const char *label, uint64_t exp, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub) |
| | Derive session key and iv from label and public key.
|
| |
| void | GNR_derive_block_xsalsa_key (unsigned char *nonce, unsigned char *key, const char *label, uint64_t exp, const struct GNUNET_CRYPTO_EddsaPublicKey *pub) |
| | Derive session key and iv from label and public key.
|
| |
| static enum GNUNET_GenericReturnValue | block_sign_ecdsa (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey, const char *label, struct GNUNET_GNSRECORD_Block *block) |
| |
| static enum GNUNET_GenericReturnValue | block_sign_eddsa (const struct GNUNET_CRYPTO_EddsaPrivateKey *key, const struct GNUNET_CRYPTO_EddsaPublicKey *pkey, const char *label, struct GNUNET_GNSRECORD_Block *block) |
| |
| enum GNUNET_GenericReturnValue | GNUNET_GNSRECORD_block_sign (const struct GNUNET_CRYPTO_BlindablePrivateKey *key, const char *label, struct GNUNET_GNSRECORD_Block *block) |
| | Sign a block create with GNUNET_GNSRECORD_block_create_unsigned.
|
| |
| static enum GNUNET_GenericReturnValue | block_create_ecdsa (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Block **block, int sign) |
| | Sign name and records.
|
| |
| static enum GNUNET_GenericReturnValue | block_create_eddsa (const struct GNUNET_CRYPTO_EddsaPrivateKey *key, const struct GNUNET_CRYPTO_EddsaPublicKey *pkey, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Block **block, int sign) |
| | Sign name and records (EDDSA version)
|
| |
| enum GNUNET_GenericReturnValue | GNUNET_GNSRECORD_block_create (const struct GNUNET_CRYPTO_BlindablePrivateKey *key, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Block **result) |
| | Sign name and records.
|
| |
| static enum GNUNET_GenericReturnValue | block_create2 (const struct GNUNET_CRYPTO_BlindablePrivateKey *pkey, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Block **result, int sign) |
| |
| enum GNUNET_GenericReturnValue | GNUNET_GNSRECORD_block_create_unsigned (const struct GNUNET_CRYPTO_BlindablePrivateKey *pkey, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Block **result) |
| | Create name and records but do not sign! Sign later with GNUNET_GNSRECORD_block_sign().
|
| |
| enum GNUNET_GenericReturnValue | GNUNET_GNSRECORD_block_create2 (const struct GNUNET_CRYPTO_BlindablePrivateKey *pkey, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Block **result) |
| | Sign name and records, cache derived public key (also keeps the private key in static memory, so do not use this function if keeping the private key in the process'es RAM is a major issue).
|
| |
| enum GNUNET_GenericReturnValue | GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block) |
| | Check if a signature is valid.
|
| |
| static enum GNUNET_GenericReturnValue | block_decrypt_ecdsa (const struct GNUNET_GNSRECORD_Block *block, const struct GNUNET_CRYPTO_EcdsaPublicKey *zone_key, const char *label, GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls) |
| |
| static enum GNUNET_GenericReturnValue | block_decrypt_eddsa (const struct GNUNET_GNSRECORD_Block *block, const struct GNUNET_CRYPTO_EddsaPublicKey *zone_key, const char *label, GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls) |
| |
| void | GNUNET_GNSRECORD_query_from_private_key (const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, const char *label, struct GNUNET_HashCode *query) |
| | Calculate the DHT query for a given label in a given zone.
|
| |
| void | GNUNET_GNSRECORD_query_from_public_key (const struct GNUNET_CRYPTO_BlindablePublicKey *pub, const char *label, struct GNUNET_HashCode *query) |
| | Calculate the DHT query for a given label in a given zone.
|
| |
| static enum GNUNET_GenericReturnValue | block_open_ecdsa (void *cls, const char *label, const struct GNUNET_GNSRECORD_Block *block, GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls) |
| |
| static enum GNUNET_GenericReturnValue | block_open_eddsa (void *cls, const char *label, const struct GNUNET_GNSRECORD_Block *block, GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls) |
| |
| static enum GNUNET_GenericReturnValue | block_seal_not_implemented (void *cls, const char *label, struct GNUNET_TIME_Absolute expire, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data rd[rd_count], struct GNUNET_GNSRECORD_Block **result) |
| |
| static enum GNUNET_GenericReturnValue | block_seal (void *cls, const char *label, struct GNUNET_TIME_Absolute expire, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data rd[rd_count], struct GNUNET_GNSRECORD_Block **result) |
| |
| struct GNUNET_GNSRECORD_EncryptionContext * | GNUNET_GNSRECORD_encryption_context_setup_owner (const struct GNUNET_CRYPTO_BlindablePrivateKey *sk) |
| | Create a new encryption context for the zone owner.
|
| |
| struct GNUNET_GNSRECORD_EncryptionContext * | GNUNET_GNSRECORD_encryption_context_setup_resolver (const struct GNUNET_CRYPTO_BlindablePublicKey *zkey) |
| | Create a new encryption context for a resolver.
|
| |
| void | GNUNET_GNSRECORD_encryption_context_destroy (struct GNUNET_GNSRECORD_EncryptionContext *ec) |
| | Cleanup and free the encryption context.
|
| |
| enum GNUNET_GenericReturnValue | GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block, const struct GNUNET_CRYPTO_BlindablePublicKey *zone_key, const char *label, GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls) |
| | Decrypt block.
|
| |
API for GNS record-related crypto.
- Author
- Martin Schanzenbach
-
Matthias Wachs
-
Christian Grothoff
Definition in file gnsrecord_crypto.c.
Definition at line 91 of file gnsrecord_crypto.c.
97{
100 size_t size = ntohl (block->
size) -
sizeof (*block) +
sizeof (*gnr_block);
101
103 ecblock = &(block)->ecdsa_block;
108
110 size -
sizeof (*gnr_block));
112 label,
113 "gns",
117 label,
118 "gns",
121 {
125 }
128}
static char * pkey
Public key of the zone to look in, in ASCII.
#define GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN
GNS record set signature (GNS)
void GNUNET_CRYPTO_ecdsa_public_key_derive(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, const char *label, const char *context, struct GNUNET_CRYPTO_EcdsaPublicKey *result)
Derive a public key from a given public key and a label.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_sign_derived(const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, const char *context, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, struct GNUNET_CRYPTO_EcdsaSignature *sig)
This is a signature function for ECDSA which takes a private key, derives/blinds it and signs the mes...
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
static unsigned int size
Size of the "table".
Information we have in an encrypted block with record data (i.e.
struct GNUNET_TIME_AbsoluteNBO expiration_time
Expiration time of the block.
struct GNUNET_CRYPTO_SignaturePurpose purpose
Number of bytes signed; also specifies the number of bytes of encrypted data that follow.
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 size
Size of the block.
Information we have in an encrypted block with record data (i.e.
struct GNUNET_CRYPTO_EcdsaSignature signature
Signature of the block.
struct GNUNET_TIME_AbsoluteNBO expiration_time
Expiration time of the block.
struct GNUNET_CRYPTO_EcdsaPublicKey derived_key
Derived key used for signing; hash of this is the query.
References GNUNET_GNSRECORD_EcdsaBlock::derived_key, GNUNET_GNSRECORD_EcdsaBlock::expiration_time, GNRBlockPS::expiration_time, GNUNET_break, GNUNET_CRYPTO_ecdsa_public_key_derive(), GNUNET_CRYPTO_ecdsa_sign_derived(), GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_OK, GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN, GNUNET_SYSERR, key, pkey, GNUNET_CRYPTO_SignaturePurpose::purpose, GNRBlockPS::purpose, GNUNET_GNSRECORD_EcdsaBlock::signature, GNUNET_CRYPTO_SignaturePurpose::size, GNUNET_GNSRECORD_Block::size, and size.
Referenced by block_create_ecdsa(), and GNUNET_GNSRECORD_block_sign().
Sign name and records.
- Parameters
-
| key | the private key |
| pkey | associated public key |
| expire | block expiration |
| label | the name for the records |
| rd | record data |
| rd_count | number of records |
| block | the block result. Must be allocated sufficiently. |
| sign | sign the block GNUNET_NO if block will be signed later. |
- Returns
- GNUNET_SYSERR on error (otherwise GNUNET_OK)
Definition at line 215 of file gnsrecord_crypto.c.
223{
231
232 if (payload_len < 0)
233 {
236 }
238 {
241 }
242
244 for (
unsigned int i = 0; i <
rd_count; i++)
245 {
248 {
250
251
252 rdc[i].flags &= ~GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
253 t.rel_value_us = rdc[i].expiration_time;
255 }
256 }
257
260 {
262
265 rdc,
266 payload_len,
268 ecblock = &(*block)->ecdsa_block;
272 skey,
273 label,
277 payload_len,
278 skey,
279 ctr,
280 &ecblock[1]);
281 }
286 {
290 }
292}
static enum GNUNET_GenericReturnValue block_sign_ecdsa(const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey, const char *label, struct GNUNET_GNSRECORD_Block *block)
void GNR_derive_block_aes_key(unsigned char *ctr, unsigned char *key, const char *label, uint64_t exp, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Derive session key and iv from label and public key.
#define GNUNET_GNSRECORD_TYPE_PKEY
WARNING: This header is generated! In order to add GNS record types, you must register them in GANA,...
static char * expire
DID Document expiration Date Attribute String.
static struct GNUNET_SCHEDULER_Task * t
Main task.
static unsigned int rd_count
Number of records for currently parsed set.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
static unsigned long long payload
How much data are we currently storing in the database?
void GNUNET_CRYPTO_aes_ctr(const void *in_buf, size_t in_buf_len, const unsigned char key[(256/8)], const unsigned char iv[(128/8)], void *out_buf)
Decrypt or encrypt a given block using a symmetric key using AES in counter mode.
#define GNUNET_GNSRECORD_MAX_BLOCK_SIZE
Maximum size of a value that can be stored in a GNS block.
ssize_t GNUNET_GNSRECORD_records_serialize(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, size_t dest_size, char *dest)
Serialize the given records to the given destination buffer.
ssize_t GNUNET_GNSRECORD_records_get_size(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Calculate how many bytes we will need to serialize the given records.
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
#define GNUNET_NZL(l)
Macro used to avoid using 0 for the length of a variable-size array (Non-Zero-Length).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
uint64_t abs_value_us__
The actual value (in network byte order).
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_AbsoluteNBO::abs_value_us__, block_sign_ecdsa(), GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_EcdsaBlock::expiration_time, expire, GNUNET_GNSRECORD_Data::flags, GNR_derive_block_aes_key(), GNUNET_assert, GNUNET_break, GNUNET_CRYPTO_aes_ctr(), GNUNET_CRYPTO_AES_KEY_LENGTH, GNUNET_free, GNUNET_GNSRECORD_MAX_BLOCK_SIZE, GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_TYPE_PKEY, GNUNET_malloc, GNUNET_NZL, GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_hton(), GNUNET_YES, key, payload, pkey, rd, rd_count, and t.
Referenced by block_create2(), and GNUNET_GNSRECORD_block_create().
Sign name and records (EDDSA version)
- Parameters
-
| key | the private key |
| pkey | associated public key |
| expire | block expiration |
| label | the name for the records |
| rd | record data |
| rd_count | number of records |
| block | where to store the block. Must be allocated sufficiently. |
| sign | GNUNET_YES if block shall be signed as well |
- Returns
- GNUNET_SYSERR on error (otherwise GNUNET_OK)
Definition at line 309 of file gnsrecord_crypto.c.
317{
321 unsigned char nonce[crypto_secretbox_NONCEBYTES];
322 unsigned char skey[crypto_secretbox_KEYBYTES];
325
326 if (payload_len < 0)
327 {
330 }
332 {
335 }
336
338 for (
unsigned int i = 0; i <
rd_count; i++)
339 {
342 {
344
345
346 rdc[i].flags &= ~GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
347 t.rel_value_us = rdc[i].expiration_time;
349 }
350 }
351
353 + payload_len + crypto_secretbox_MACBYTES);
355 + payload_len + crypto_secretbox_MACBYTES);
356 {
358
361 rdc,
362 payload_len,
364 edblock = &(*block)->eddsa_block;
368 skey,
369 label,
374 payload_len,
376 skey,
377 nonce,
378 &edblock[1]));
382 }
384}
void GNR_derive_block_xsalsa_key(unsigned char *nonce, unsigned char *key, const char *label, uint64_t exp, const struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Derive session key and iv from label and public key.
static enum GNUNET_GenericReturnValue block_sign_eddsa(const struct GNUNET_CRYPTO_EddsaPrivateKey *key, const struct GNUNET_CRYPTO_EddsaPublicKey *pkey, const char *label, struct GNUNET_GNSRECORD_Block *block)
#define GNUNET_GNSRECORD_TYPE_EDKEY
GNS zone delegation (EDKEY)
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_xsalsa20poly1305_encrypt(size_t in_buf_len, const unsigned char in_buf[in_buf_len], const unsigned char key[crypto_secretbox_xsalsa20poly1305_KEYBYTES], const unsigned char nonce[crypto_secretbox_xsalsa20poly1305_NONCEBYTES], void *out_buf)
Encrypt the given data using XSalsa20-Poly1305.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_AbsoluteNBO::abs_value_us__, block_sign_eddsa(), GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_EddsaBlock::expiration_time, expire, GNUNET_GNSRECORD_Data::flags, GNR_derive_block_xsalsa_key(), GNUNET_assert, GNUNET_break, GNUNET_CRYPTO_xsalsa20poly1305_encrypt(), GNUNET_GNSRECORD_MAX_BLOCK_SIZE, GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_TYPE_EDKEY, GNUNET_malloc, GNUNET_NZL, GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_hton(), GNUNET_YES, key, payload, pkey, rd, rd_count, and t.
Referenced by block_create2(), and GNUNET_GNSRECORD_block_create().
Definition at line 452 of file gnsrecord_crypto.c.
459{
463 char *norm_label;
464#define CSIZE 64
467
469
471 {
473
475 if (0 != memcmp (&
line->key,
478 {
479
483 }
487 norm_label,
491 sign);
492 }
494 {
496 &edpubkey);
498 &edpubkey,
500 norm_label,
504 sign);
505 }
506#undef CSIZE
509}
static enum GNUNET_GenericReturnValue block_create_ecdsa(const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Block **block, int sign)
Sign name and records.
static enum GNUNET_GenericReturnValue block_create_eddsa(const struct GNUNET_CRYPTO_EddsaPrivateKey *key, const struct GNUNET_CRYPTO_EddsaPublicKey *pkey, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Block **block, int sign)
Sign name and records (EDDSA version)
static char * line
Desired phone line (string to be converted to a hash).
static char * res
Currently read line or NULL on EOF.
static int result
Global testing status.
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.
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Derive key.
char * GNUNET_GNSRECORD_string_normalize(const char *src)
Normalize a UTF-8 string to a GNS name.
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_PUBLIC_KEY_TYPE_EDDSA
EDDSA identity.
@ GNUNET_PUBLIC_KEY_TYPE_ECDSA
The identity type.
Private ECC key encoded for transmission.
Line in cache mapping private keys to public keys.
References block_create_ecdsa(), block_create_eddsa(), CSIZE, expire, GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_CRYPTO_eddsa_key_get_public(), GNUNET_free, GNUNET_GNSRECORD_string_normalize(), GNUNET_PUBLIC_KEY_TYPE_ECDSA, GNUNET_PUBLIC_KEY_TYPE_EDDSA, GNUNET_SYSERR, key, KeyCacheLine::key, line, pkey, rd, rd_count, res, and result.
Referenced by block_seal(), GNUNET_GNSRECORD_block_create2(), and GNUNET_GNSRECORD_block_create_unsigned().
Definition at line 605 of file gnsrecord_crypto.c.
611{
612 size_t payload_len = ntohl (block->
size)
616
617 if (ntohl (block->
size) <
619 {
622 }
626 label,
628 zone_key);
629 {
632
634 payload_len,
636 ctr,
641 {
642
645 }
646 {
648 unsigned int j;
650
656 {
659 }
660
662 j = 0;
663 for (
unsigned int i = 0; i <
rd_count; i++)
664 {
666 {
667
669 continue;
670 }
671
673 {
675
676 for (
unsigned int k = 0; k <
rd_count; k++)
677 {
678 if (k == i)
679 continue;
680 if (
rd[i].expiration_time < now.abs_value_us)
682 if ((
rd[k].record_type ==
rd[i].record_type) &&
683 (
rd[k].expiration_time >= now.abs_value_us) &&
685 {
688 "Ignoring shadow record\n");
689 break;
690 }
691 }
693 {
695 if (j != i)
697 j++;
698 }
699 }
700 else if (
rd[i].expiration_time >= now.abs_value_us)
701 {
702
703 if (j != i)
705 j++;
706 }
707 else
708 {
710
713 "Excluding record that expired %s (%llu ago)\n",
715 (
unsigned long long)
rd[i].expiration_time
716 - now.abs_value_us);
717 }
718 }
720 if (NULL != proc)
721 proc (proc_cls,
724 }
725 }
727}
int GNUNET_GNSRECORD_records_deserialize(size_t len, const char *src, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *dest)
Deserialize the given records to the given destination.
unsigned int GNUNET_GNSRECORD_records_deserialize_get_size(size_t len, const char *src)
@ GNUNET_GNSRECORD_RF_SHADOW
This record should not be used unless all (other) records in the set with an absolute expiration time...
#define GNUNET_log(kind,...)
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
struct GNUNET_GNSRECORD_EcdsaBlock ecdsa_block
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
uint64_t expiration_time
Expiration time for the DNS record.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_AbsoluteNBO::abs_value_us__, GNUNET_GNSRECORD_Block::ecdsa_block, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_EcdsaBlock::expiration_time, GNUNET_GNSRECORD_Data::flags, GNR_derive_block_aes_key(), GNUNET_assert, GNUNET_break_op, GNUNET_CRYPTO_aes_ctr(), GNUNET_CRYPTO_AES_KEY_LENGTH, GNUNET_ERROR_TYPE_INFO, GNUNET_GNSRECORD_records_deserialize(), GNUNET_GNSRECORD_records_deserialize_get_size(), GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_RF_SHADOW, GNUNET_log, GNUNET_NO, GNUNET_NZL, GNUNET_OK, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_absolute_get(), GNUNET_YES, key, payload, rd, rd_count, and GNUNET_GNSRECORD_Block::size.
Referenced by block_open_ecdsa().
Definition at line 731 of file gnsrecord_crypto.c.
737{
738 size_t payload_len = ntohl (block->
size)
740 unsigned char nonce[crypto_secretbox_NONCEBYTES];
741 unsigned char key[crypto_secretbox_KEYBYTES];
742
743 if (ntohl (block->
size) <
745 {
748 }
751 label,
753 ,
754 zone_key);
755 {
758
761 payload_len,
762 (unsigned char*) &block[1],
764 nonce,
766 payload_len -= crypto_secretbox_MACBYTES;
770 {
771
774 }
775 {
777 unsigned int j;
779
785 {
788 }
789
791 j = 0;
792 for (
unsigned int i = 0; i <
rd_count; i++)
793 {
795 {
796
798 continue;
799 }
800
802 {
804
805 for (
unsigned int k = 0; k <
rd_count; k++)
806 {
807 if (k == i)
808 continue;
809 if (
rd[i].expiration_time < now.abs_value_us)
811 if ((
rd[k].record_type ==
rd[i].record_type) &&
812 (
rd[k].expiration_time >= now.abs_value_us) &&
814 {
817 "Ignoring shadow record\n");
818 break;
819 }
820 }
822 {
824 if (j != i)
826 j++;
827 }
828 }
829 else if (
rd[i].expiration_time >= now.abs_value_us)
830 {
831
832 if (j != i)
834 j++;
835 }
836 else
837 {
839
842 "Excluding record that expired %s (%llu ago)\n",
844 (
unsigned long long)
rd[i].expiration_time
845 - now.abs_value_us);
846 }
847 }
849 if (NULL != proc)
850 proc (proc_cls,
853 }
854 }
856}
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_xsalsa20poly1305_decrypt(size_t in_buf_len, const unsigned char in_buf[in_buf_len], const unsigned char key[crypto_secretbox_xsalsa20poly1305_KEYBYTES], const unsigned char nonce[crypto_secretbox_xsalsa20poly1305_NONCEBYTES], void *out_buf)
Encrypt the given data using XSalsa20-Poly1305.
struct GNUNET_GNSRECORD_EddsaBlock eddsa_block
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_AbsoluteNBO::abs_value_us__, GNUNET_GNSRECORD_Block::eddsa_block, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_EddsaBlock::expiration_time, GNUNET_GNSRECORD_Data::flags, GNR_derive_block_xsalsa_key(), GNUNET_assert, GNUNET_break_op, GNUNET_CRYPTO_xsalsa20poly1305_decrypt(), GNUNET_ERROR_TYPE_INFO, GNUNET_GNSRECORD_records_deserialize(), GNUNET_GNSRECORD_records_deserialize_get_size(), GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_RF_SHADOW, GNUNET_log, GNUNET_NO, GNUNET_NZL, GNUNET_OK, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_absolute_get(), GNUNET_YES, key, payload, rd, rd_count, and GNUNET_GNSRECORD_Block::size.
Referenced by block_open_eddsa().