API for GNS record-related crypto. More...
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 | |
static ssize_t | ecdsa_symmetric_decrypt (const void *block, size_t size, const unsigned char *key, const unsigned char *ctr, void *result) |
static ssize_t | ecdsa_symmetric_encrypt (const void *block, size_t size, const unsigned char *key, const unsigned char *ctr, void *result) |
static enum GNUNET_GenericReturnValue | eddsa_symmetric_decrypt (const void *block, size_t size, const unsigned char *key, const unsigned char *nonce, void *result) |
static enum GNUNET_GenericReturnValue | eddsa_symmetric_encrypt (const void *block, size_t size, const unsigned char *key, const unsigned char *nonce, void *result) |
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. More... | |
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. More... | |
static ssize_t | block_get_size_ecdsa (const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count) |
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_PrivateKey *key, const char *label, struct GNUNET_GNSRECORD_Block *block) |
Sign a block create with GNUNET_GNSRECORD_block_create_unsigned. More... | |
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. More... | |
static ssize_t | block_get_size_eddsa (const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count) |
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) More... | |
ssize_t | GNUNET_GNSRECORD_block_calculate_size (const struct GNUNET_CRYPTO_PrivateKey *key, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count) |
Get size of buffer for block creation. More... | |
enum GNUNET_GenericReturnValue | GNUNET_GNSRECORD_block_create (const struct GNUNET_CRYPTO_PrivateKey *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. More... | |
static enum GNUNET_GenericReturnValue | block_create2 (const struct GNUNET_CRYPTO_PrivateKey *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_PrivateKey *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(). More... | |
enum GNUNET_GenericReturnValue | GNUNET_GNSRECORD_block_create2 (const struct GNUNET_CRYPTO_PrivateKey *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). More... | |
enum GNUNET_GenericReturnValue | GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block) |
Check if a signature is valid. More... | |
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) |
enum GNUNET_GenericReturnValue | GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block, const struct GNUNET_CRYPTO_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_CRYPTO_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_CRYPTO_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 31 of file gnsrecord_crypto.c.
#define CSIZE 64 |
|
static |
Definition at line 34 of file gnsrecord_crypto.c.
References GNUNET_assert, GNUNET_CRYPTO_AES_KEY_LENGTH, handle, key, result, and size.
Referenced by block_decrypt_ecdsa().
|
static |
Definition at line 61 of file gnsrecord_crypto.c.
References GNUNET_assert, GNUNET_CRYPTO_AES_KEY_LENGTH, handle, key, result, and size.
Referenced by block_create_ecdsa().
|
static |
Definition at line 88 of file gnsrecord_crypto.c.
References GNUNET_OK, GNUNET_SYSERR, key, result, and size.
Referenced by block_decrypt_eddsa().
|
static |
Definition at line 112 of file gnsrecord_crypto.c.
References GNUNET_OK, GNUNET_SYSERR, key, result, and size.
Referenced by block_create_eddsa().
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.
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 129 of file gnsrecord_crypto.c.
References GNUNET_CRYPTO_AES_KEY_LENGTH, GNUNET_CRYPTO_kdf(), key, and pub.
Referenced by block_create_ecdsa(), block_decrypt_ecdsa(), and run_pkey().
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.
nonce | initialization vector to initialize |
skey | session key to initialize |
label | label to use for KDF |
pub | public key to use for KDF |
16 byte nonce
Expiration time 64 bit.
Definition at line 158 of file gnsrecord_crypto.c.
References GNUNET_CRYPTO_kdf(), key, and pub.
Referenced by block_create_eddsa(), block_decrypt_eddsa(), and run_edkey().
|
static |
Definition at line 186 of file gnsrecord_crypto.c.
References GNUNET_GNSRECORD_records_get_size(), rd, and rd_count.
Referenced by GNUNET_GNSRECORD_block_calculate_size().
|
static |
Definition at line 200 of file gnsrecord_crypto.c.
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_EccSignaturePurpose::purpose, GNRBlockPS::purpose, GNUNET_GNSRECORD_EcdsaBlock::signature, GNUNET_CRYPTO_EccSignaturePurpose::size, GNUNET_GNSRECORD_Block::size, and size.
Referenced by block_create_ecdsa(), and GNUNET_GNSRECORD_block_sign().
|
static |
Definition at line 241 of file gnsrecord_crypto.c.
References GNUNET_GNSRECORD_EddsaBlock::derived_key, GNUNET_GNSRECORD_EddsaBlock::expiration_time, GNRBlockPS::expiration_time, GNUNET_CRYPTO_eddsa_public_key_derive(), GNUNET_CRYPTO_eddsa_sign_derived(), GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_OK, GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN, key, pkey, GNUNET_CRYPTO_EccSignaturePurpose::purpose, GNRBlockPS::purpose, GNUNET_GNSRECORD_EddsaBlock::signature, GNUNET_CRYPTO_EccSignaturePurpose::size, GNUNET_GNSRECORD_Block::size, and size.
Referenced by block_create_eddsa(), and GNUNET_GNSRECORD_block_sign().
|
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 |
block | the block result. Must be allocated sufficiently. |
sign | sign the block GNUNET_NO if block will be signed later. |
Definition at line 324 of file gnsrecord_crypto.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_AbsoluteNBO::abs_value_us__, block_sign_ecdsa(), ecdsa_symmetric_encrypt(), 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_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().
|
static |
Definition at line 406 of file gnsrecord_crypto.c.
References GNUNET_GNSRECORD_records_get_size(), rd, and rd_count.
Referenced by GNUNET_GNSRECORD_block_calculate_size().
|
static |
Sign name and records (EDDSA version)
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 |
Definition at line 434 of file gnsrecord_crypto.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_AbsoluteNBO::abs_value_us__, block_sign_eddsa(), eddsa_symmetric_encrypt(), 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_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().
|
static |
Definition at line 602 of file gnsrecord_crypto.c.
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, line, pkey, rd, rd_count, res, and result.
Referenced by GNUNET_GNSRECORD_block_create2(), and GNUNET_GNSRECORD_block_create_unsigned().
|
static |
Definition at line 734 of file gnsrecord_crypto.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_AbsoluteNBO::abs_value_us__, GNUNET_GNSRECORD_Block::ecdsa_block, ecdsa_symmetric_decrypt(), 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_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 GNUNET_GNSRECORD_block_decrypt().
|
static |
Definition at line 859 of file gnsrecord_crypto.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_AbsoluteNBO::abs_value_us__, GNUNET_GNSRECORD_Block::eddsa_block, eddsa_symmetric_decrypt(), 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_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 GNUNET_GNSRECORD_block_decrypt().