GNUnet 0.21.1
crypto_pkey.c File Reference

api to interact handle generic public keys More...

#include "platform.h"
#include "gnunet_util_lib.h"
Include dependency graph for crypto_pkey.c:

Go to the source code of this file.

Functions

static enum GNUNET_GenericReturnValue check_key_type (uint32_t type)
 
ssize_t GNUNET_CRYPTO_private_key_get_length (const struct GNUNET_CRYPTO_PrivateKey *key)
 Get the compacted length of a GNUNET_CRYPTO_PrivateKey. More...
 
ssize_t GNUNET_CRYPTO_public_key_get_length (const struct GNUNET_CRYPTO_PublicKey *key)
 Get the compacted length of a GNUNET_CRYPTO_PublicKey. More...
 
ssize_t GNUNET_CRYPTO_private_key_length_by_type (enum GNUNET_CRYPTO_KeyType kt)
 
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_public_key_from_buffer (const void *buffer, size_t len, struct GNUNET_CRYPTO_PublicKey *key, size_t *kb_read)
 Reads a GNUNET_CRYPTO_PublicKey from a compact buffer. More...
 
ssize_t GNUNET_CRYPTO_write_public_key_to_buffer (const struct GNUNET_CRYPTO_PublicKey *key, void *buffer, size_t len)
 Writes a GNUNET_CRYPTO_PublicKey to a compact buffer. More...
 
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_private_key_from_buffer (const void *buffer, size_t len, struct GNUNET_CRYPTO_PrivateKey *key, size_t *kb_read)
 Reads a GNUNET_CRYPTO_PrivateKey from a compact buffer. More...
 
ssize_t GNUNET_CRYPTO_write_private_key_to_buffer (const struct GNUNET_CRYPTO_PrivateKey *key, void *buffer, size_t len)
 Writes a GNUNET_CRYPTO_PrivateKey to a compact buffer. More...
 
ssize_t GNUNET_CRYPTO_signature_get_length (const struct GNUNET_CRYPTO_Signature *sig)
 Get the compacted length of a GNUNET_CRYPTO_Signature. More...
 
ssize_t GNUNET_CRYPTO_signature_get_raw_length_by_type (uint32_t type)
 Get the compacted length of a signature by type. More...
 
ssize_t GNUNET_CRYPTO_read_signature_from_buffer (struct GNUNET_CRYPTO_Signature *sig, const void *buffer, size_t len)
 Reads a GNUNET_CRYPTO_Signature from a compact buffer. More...
 
ssize_t GNUNET_CRYPTO_write_signature_to_buffer (const struct GNUNET_CRYPTO_Signature *sig, void *buffer, size_t len)
 Writes a GNUNET_CRYPTO_Signature to a compact buffer. More...
 
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_sign_raw_ (const struct GNUNET_CRYPTO_PrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, unsigned char *sig)
 Sign a given block. More...
 
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_sign_ (const struct GNUNET_CRYPTO_PrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_Signature *sig)
 Sign a given block. More...
 
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_signature_verify_ (uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_Signature *sig, const struct GNUNET_CRYPTO_PublicKey *pub)
 Verify a given signature. More...
 
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_signature_verify_raw_ (uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const unsigned char *sig, const struct GNUNET_CRYPTO_PublicKey *pub)
 Verify a given signature. More...
 
ssize_t GNUNET_CRYPTO_encrypt_old (const void *block, size_t size, const struct GNUNET_CRYPTO_PublicKey *pub, struct GNUNET_CRYPTO_EcdhePublicKey *ecc, void *result)
 Encrypt a block with GNUNET_CRYPTO_PublicKey and derives a GNUNET_CRYPTO_EcdhePublicKey which is required for decryption using ecdh to derive a symmetric key. More...
 
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_encrypt (const void *pt, size_t pt_size, const struct GNUNET_CRYPTO_PublicKey *pub, void *ct_buf, size_t ct_size)
 Encrypt a block with GNUNET_CRYPTO_PublicKey and derives a GNUNET_CRYPTO_EcdhePublicKey which is required for decryption using ecdh to derive a symmetric key. More...
 
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_decrypt (const void *ct_buf, size_t ct_size, const struct GNUNET_CRYPTO_PrivateKey *priv, void *pt, size_t pt_size)
 Decrypt a given block with GNUNET_CRYPTO_PrivateKey and a given GNUNET_CRYPTO_EcdhePublicKey using ecdh to derive a symmetric key. More...
 
ssize_t GNUNET_CRYPTO_decrypt_old (const void *block, size_t size, const struct GNUNET_CRYPTO_PrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *ecc, void *result)
 Decrypt a given block with GNUNET_CRYPTO_PrivateKey and a given GNUNET_CRYPTO_EcdhePublicKey using ecdh to derive a symmetric key. More...
 
char * GNUNET_CRYPTO_public_key_to_string (const struct GNUNET_CRYPTO_PublicKey *key)
 Creates a (Base32) string representation of the public key. More...
 
char * GNUNET_CRYPTO_private_key_to_string (const struct GNUNET_CRYPTO_PrivateKey *key)
 Creates a (Base32) string representation of the private key. More...
 
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_public_key_from_string (const char *str, struct GNUNET_CRYPTO_PublicKey *key)
 Parses a (Base32) string representation of the public key. More...
 
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_private_key_from_string (const char *str, struct GNUNET_CRYPTO_PrivateKey *key)
 Parses a (Base32) string representation of the private key. More...
 
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_key_get_public (const struct GNUNET_CRYPTO_PrivateKey *privkey, struct GNUNET_CRYPTO_PublicKey *key)
 Retrieves the public key representation of a private key. More...
 

Detailed Description

api to interact handle generic public keys

Author
Martin Schanzenbach

Definition in file crypto_pkey.c.

Function Documentation

◆ check_key_type()

static enum GNUNET_GenericReturnValue check_key_type ( uint32_t  type)
static

Definition at line 32 of file crypto_pkey.c.

33{
34 switch (type)
35 {
38 return GNUNET_OK;
39 default:
40 return GNUNET_SYSERR;
41 }
42 return GNUNET_SYSERR;
43}
static uint32_t type
Type string converted to DNS type value.
@ GNUNET_PUBLIC_KEY_TYPE_EDDSA
EDDSA identity.
@ GNUNET_PUBLIC_KEY_TYPE_ECDSA
The identity type.
@ GNUNET_OK
@ GNUNET_SYSERR

References GNUNET_OK, GNUNET_PUBLIC_KEY_TYPE_ECDSA, GNUNET_PUBLIC_KEY_TYPE_EDDSA, GNUNET_SYSERR, and type.

Referenced by GNUNET_CRYPTO_private_key_from_string(), and GNUNET_CRYPTO_public_key_from_string().

Here is the caller graph for this function:

◆ GNUNET_CRYPTO_private_key_length_by_type()

ssize_t GNUNET_CRYPTO_private_key_length_by_type ( enum GNUNET_CRYPTO_KeyType  kt)

Definition at line 85 of file crypto_pkey.c.

86{
87 switch (kt)
88 {
90 return sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey);
91 break;
93 return sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey);
94 break;
95 default:
96 GNUNET_break (0);
97 }
98 return -1;
99}
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
Private ECC key encoded for transmission.

References GNUNET_break, GNUNET_PUBLIC_KEY_TYPE_ECDSA, and GNUNET_PUBLIC_KEY_TYPE_EDDSA.