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 | |
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) |
enum GNUNET_GenericReturnValue | eddsa_symmetric_decrypt (const void *block, size_t size, const unsigned char *key, const unsigned char *nonce, void *result) |
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) |
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) |
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_IDENTITY_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) |
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_IDENTITY_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_IDENTITY_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_IDENTITY_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_IDENTITY_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_IDENTITY_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... | |
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) |
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_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 31 of file gnsrecord_crypto.c.
#define CSIZE 64 |
ssize_t ecdsa_symmetric_decrypt | ( | const void * | block, |
size_t | size, | ||
const unsigned char * | key, | ||
const unsigned char * | ctr, | ||
void * | result | ||
) |
Definition at line 34 of file gnsrecord_crypto.c.
References GNUNET_assert, GNUNET_CRYPTO_AES_KEY_LENGTH, handle, key, result, and size.
ssize_t ecdsa_symmetric_encrypt | ( | const void * | block, |
size_t | size, | ||
const unsigned char * | key, | ||
const unsigned char * | ctr, | ||
void * | result | ||
) |
Definition at line 61 of file gnsrecord_crypto.c.
References GNUNET_assert, GNUNET_CRYPTO_AES_KEY_LENGTH, handle, key, result, and size.
enum GNUNET_GenericReturnValue eddsa_symmetric_decrypt | ( | const void * | block, |
size_t | size, | ||
const unsigned char * | key, | ||
const unsigned char * | nonce, | ||
void * | result | ||
) |
Definition at line 61 of file gnsrecord_crypto.c.
enum GNUNET_GenericReturnValue eddsa_symmetric_encrypt | ( | const void * | block, |
size_t | size, | ||
const unsigned char * | key, | ||
const unsigned char * | nonce, | ||
void * | result | ||
) |
Definition at line 61 of file gnsrecord_crypto.c.
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 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 run_edkey().
|
static |
Definition at line 186 of file gnsrecord_crypto.c.
Referenced by block_create2().
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 | ||
) |
Definition at line 186 of file gnsrecord_crypto.c.
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 | ||
) |
Definition at line 186 of file gnsrecord_crypto.c.
|
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 186 of file gnsrecord_crypto.c.
References GNUNET_GNSRECORD_records_get_size(), len, rd, and rd_count.
|
static |
Definition at line 406 of file gnsrecord_crypto.c.
Referenced by block_create2().
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)
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 406 of file gnsrecord_crypto.c.
References GNUNET_GNSRECORD_records_get_size(), len, rd, and rd_count.
|
static |
Definition at line 512 of file gnsrecord_crypto.c.
References block_get_size_ecdsa(), block_get_size_eddsa(), GNUNET_assert, GNUNET_GNSRECORD_TYPE_EDKEY, GNUNET_GNSRECORD_TYPE_PKEY, GNUNET_IDENTITY_key_get_public(), key, pkey, rd, rd_count, and res.
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 | ||
) |
Definition at line 512 of file gnsrecord_crypto.c.
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 | ||
) |
Definition at line 512 of file gnsrecord_crypto.c.