![]() |
GNUnet
0.11.x
|
API for GNS record-related crypto. More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_signatures.h"
#include "gnunet_arm_service.h"
#include "gnunet_gnsrecord_lib.h"
#include "gnunet_dnsparser_lib.h"
#include "gnunet_tun_lib.h"
Go to the source code of this file.
Data Structures | |
struct | KeyCacheLine |
Line in cache mapping private keys to public keys. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "gnsrecord", __VA_ARGS__) |
#define | CSIZE 64 |
Functions | |
ssize_t | ecdsa_symmetric_decrypt (const void *block, size_t size, const unsigned char *key, const unsigned char *ctr, void *result) |
ssize_t | ecdsa_symmetric_encrypt (const void *block, size_t size, const unsigned char *key, const unsigned char *ctr, void *result) |
static void | 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. More... | |
static struct GNUNET_GNSRECORD_Block * | 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) |
Sign name and records. More... | |
struct GNUNET_GNSRECORD_Block * | GNUNET_GNSRECORD_block_create (const struct GNUNET_IDENTITY_PrivateKey *key, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count) |
Sign name and records. More... | |
struct GNUNET_GNSRECORD_Block * | GNUNET_GNSRECORD_block_create2 (const struct GNUNET_IDENTITY_PrivateKey *pkey, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count) |
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). More... | |
enum GNUNET_GenericReturnValue | GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block) |
Check if a signature is valid. More... | |
enum GNUNET_GenericReturnValue | block_decrypt_ecdsa (const struct GNUNET_GNSRECORD_EcdsaBlock *block, const struct GNUNET_CRYPTO_EcdsaPublicKey *zone_key, const char *label, GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls) |
enum GNUNET_GenericReturnValue | GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block, const struct GNUNET_IDENTITY_PublicKey *zone_key, const char *label, GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls) |
Decrypt block. More... | |
void | GNUNET_GNSRECORD_query_from_private_key (const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, struct GNUNET_HashCode *query) |
Calculate the DHT query for a given label in a given zone. More... | |
void | GNUNET_GNSRECORD_query_from_public_key (const struct GNUNET_IDENTITY_PublicKey *pub, const char *label, struct GNUNET_HashCode *query) |
Calculate the DHT query for a given label in a given zone. More... | |
API for GNS record-related crypto.
Definition in file gnsrecord_crypto.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "gnsrecord", __VA_ARGS__) |
Definition at line 38 of file gnsrecord_crypto.c.
#define CSIZE 64 |
Referenced by GNUNET_GNSRECORD_block_create2().
ssize_t ecdsa_symmetric_decrypt | ( | const void * | block, |
size_t | size, | ||
const unsigned char * | key, | ||
const unsigned char * | ctr, | ||
void * | result | ||
) |
Definition at line 41 of file gnsrecord_crypto.c.
References GNUNET_assert, GNUNET_CRYPTO_AES_KEY_LENGTH, handle, and size.
Referenced by block_decrypt_ecdsa().
ssize_t ecdsa_symmetric_encrypt | ( | const void * | block, |
size_t | size, | ||
const unsigned char * | key, | ||
const unsigned char * | ctr, | ||
void * | result | ||
) |
Definition at line 69 of file gnsrecord_crypto.c.
References GNUNET_assert, GNUNET_CRYPTO_AES_KEY_LENGTH, handle, and size.
Referenced by block_create_ecdsa().
|
static |
Derive session key and iv from label and public key.
iv | initialization vector to initialize |
skey | session key to initialize |
label | label to use for KDF |
pub | public key to use for KDF |
4 byte nonce
Expiration time 64 bit.
Set counter part to 1
Definition at line 105 of file gnsrecord_crypto.c.
References GNUNET_CRYPTO_AES_KEY_LENGTH, and GNUNET_CRYPTO_kdf().
Referenced by block_create_ecdsa(), and block_decrypt_ecdsa().
|
static |
Sign name and records.
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 |
Definition at line 145 of file gnsrecord_crypto.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_AbsoluteNBO::abs_value_us__, derive_block_aes_key(), GNUNET_GNSRECORD_EcdsaBlock::derived_key, GNUNET_GNSRECORD_Block::ecdsa_block, ecdsa_symmetric_encrypt(), GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_EcdsaBlock::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_assert, GNUNET_break, GNUNET_CRYPTO_AES_KEY_LENGTH, GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_CRYPTO_ecdsa_private_key_derive(), GNUNET_CRYPTO_ecdsa_sign_(), 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_memcpy, GNUNET_OK, GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN, GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_hton(), payload, GNUNET_CRYPTO_EccSignaturePurpose::purpose, GNUNET_GNSRECORD_EcdsaBlock::purpose, GNUNET_TIME_Relative::rel_value_us, GNUNET_GNSRECORD_EcdsaBlock::signature, GNUNET_CRYPTO_EccSignaturePurpose::size, and GNUNET_GNSRECORD_Block::type.
Referenced by GNUNET_GNSRECORD_block_create(), and GNUNET_GNSRECORD_block_create2().
enum GNUNET_GenericReturnValue block_decrypt_ecdsa | ( | const struct GNUNET_GNSRECORD_EcdsaBlock * | block, |
const struct GNUNET_CRYPTO_EcdsaPublicKey * | zone_key, | ||
const char * | label, | ||
GNUNET_GNSRECORD_RecordCallback | proc, | ||
void * | proc_cls | ||
) |
Definition at line 381 of file gnsrecord_crypto.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_AbsoluteNBO::abs_value_us__, derive_block_aes_key(), ecdsa_symmetric_decrypt(), GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_EcdsaBlock::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_break, GNUNET_break_op, GNUNET_CRYPTO_AES_KEY_LENGTH, GNUNET_ERROR_TYPE_INFO, GNUNET_GNSRECORD_records_deserialize(), GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_RF_SHADOW_RECORD, GNUNET_log, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_absolute_get(), GNUNET_YES, KeyCacheLine::key, payload, GNUNET_GNSRECORD_EcdsaBlock::purpose, and GNUNET_CRYPTO_EccSignaturePurpose::size.
Referenced by GNUNET_GNSRECORD_block_decrypt().