The Assimilation Project  based on Assimilation version 0.5.1435932971
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
CryptFrame class

Class for encrypting FrameSets. More...

Collaboration diagram for CryptFrame class:

Modules

 CryptCurve25519 class
 Class for encrypting FrameSets.
 

Macros

#define DEBUGCKSUM3(msg, buf)   {if (DEBUG >= 3) _cryptframe_debug_checksum(__FUNCTION__, __LINE__, msg, buf);}
 
#define DEBUGCKSUM4(msg, buf)   {if (DEBUG >= 4) _cryptframe_debug_checksum(__FUNCTION__, __LINE__, msg, buf);}
 
#define INITMAPS   {if (!maps_inityet) {_cryptframe_initialize_maps();}}
 

Functions

FSTATIC gboolean _cryptframe_default_isvalid (const Frame *self,gconstpointer tlvptr,gconstpointer pktend)
 CryptFrame class 'isvalid' member function (checks for valid cryptframe objects) More...
 
FSTATIC void _cryptframe_finalize (AssimObj *aself)
 Finalize (destructor) function for our CryptFramePublicKey objects. More...
 
FSTATIC CryptFramePublicKeycryptframe_public_key_by_id (const char *key_id)
 Return the non-const public key with the given id. More...
 
FSTATIC CryptFramePrivateKeycryptframe_private_key_by_id (const char *key_id)
 Return the non-const private key with the given id. More...
 
CryptFramecryptframe_new (guint16 frame_type, const char *sender_key_id, const char *receiver_key_id, gsize objsize)
 Construct a new CryptFrame This can only be used directly for creating subclassed CryptFrame frames because CryptFrame is an abstract class... More...
 
WINEXPORT Framecryptframe_tlvconstructor (gpointer tlvstart, gconstpointer pktend, gpointer *ignorednewpkt, gpointer *ignoredpktend)
 Given marshalled packet data corresponding to an CryptFrame - which we can't do because we're an abstract class... More...
 
FSTATIC void _cryptframe_publickey_finalize (AssimObj *pubkey)
 Finalize (destructor) function for our CryptFramePublicKey objects. More...
 
FSTATIC void _cryptframe_privatekey_finalize (AssimObj *privkey)
 Finalize (destructor) function for our CryptFramePrivateKey objects. More...
 
FSTATIC void _cryptframe_debug_checksum (const char *function,int lineno,const char *message,const guint8 *buf)
 Print a debug checksum message. More...
 
FSTATIC void _cryptframe_initialize_maps (void)
 Initialize all our maps. More...
 
WINEXPORT void cryptframe_shutdown (void)
 Shut down our key caches and so on... (destroy our maps) More...
 
WINEXPORT CryptFramePublicKeycryptframe_publickey_new (const char *key_id, gpointer public_key)
 Create a persistent keypair and write it to disk. More...
 
WINEXPORT CryptFramePrivateKeycryptframe_privatekey_new (const char *key_id, gpointer private_key)
 Create a new private key - or return the existing private key with this id. More...
 
WINEXPORT gboolean cryptframe_associate_identity (const char *identity, const char *key_id)
 Associate the given key id with the given identity Note that it is OK to associate multiple key ids with a given identity but it is NOT OK to associate multiple identities with a given key id Return TRUE if we could make the association (it's OK to make the same valid association multiple times) More...
 
WINEXPORT gboolean cryptframe_dissociate_identity (const char *identity, const char *key_id)
 Dissociate the given key from the given identity (analogous to revoking the key) More...
 
WINEXPORT const char * cryptframe_whois_public_key (const CryptFramePublicKey *public_key)
 Return the identity associated with the given public key object. More...
 
WINEXPORT const char * cryptframe_whois_key_id (const char *key_id)
 Return the identity associated with the given key id. More...
 
WINEXPORT GHashTable * cryptframe_key_ids_for (const char *identity)
 Return a GHashTable of strings of all the key ids associated with the given identity. More...
 
WINEXPORT GList * cryptframe_get_identities (void)
 Return a GList of strings of all known identities. More...
 
WINEXPORT GList * cryptframe_get_key_ids (void)
 Return a GList of strings of all known key ids. More...
 
WINEXPORT void cryptframe_purge_key_id (const char *key_id)
 
WINEXPORT void cryptframe_set_signing_key_id (const char *key_id)
 Set the default signing key. More...
 
WINEXPORT const char * cryptframe_get_signing_key_id (void)
 Return the key_id of the default signing key. More...
 
WINEXPORT CryptFramePrivateKeycryptframe_get_signing_key (void)
 Return the default signing key. More...
 
WINEXPORT void cryptframe_set_dest_public_key (NetAddr *destaddr, CryptFramePublicKey *destkey)
 Set the encryption key to use when sending to destaddr Set destkey to NULL to stop encrypting to that destination. More...
 
WINEXPORT gboolean cryptframe_set_dest_key_id (NetAddr *destaddr, const char *key_id)
 Set the encryption key to use when sending to destaddr Set destkey to NULL to stop encrypting to that destination. More...
 
WINEXPORT CryptFramecryptframe_new_by_destaddr (const NetAddr *destaddr)
 Construct a CryptFrame class appropriate for encrypting messages to destaddr More...
 
WINEXPORT const char * cryptframe_get_dest_key_id (const NetAddr *destaddr)
 Return the key_id associated with the given destination address. More...
 
WINEXPORT void cryptframe_set_encryption_method (CryptFrame *(*method)(const char *sender_key_id, const char *receiver_key_id, gboolean forsending))
 

Variables

GHashTable * addr_to_public_key_map = NULL
 Maps NetAddr class to public key. More...
 
WINEXPORT void cryptframe_set_encryption_method (CryptFrame *(*)(const char *sender_key_id, const char *receiver_key_id, gboolean forsending))
 
#define MAXCRYPTKEYNAMELENGTH   64
 Maximum length of a crypt key name. More...
 
typedef struct _CryptFrame CryptFrame
 

Detailed Description

Class for encrypting FrameSets.

Macro Definition Documentation

#define DEBUGCKSUM3 (   msg,
  buf 
)    {if (DEBUG >= 3) _cryptframe_debug_checksum(__FUNCTION__, __LINE__, msg, buf);}

Definition at line 120 of file cryptframe.c.

Referenced by cryptframe_privatekey_new(), and cryptframe_publickey_new().

#define DEBUGCKSUM4 (   msg,
  buf 
)    {if (DEBUG >= 4) _cryptframe_debug_checksum(__FUNCTION__, __LINE__, msg, buf);}

Definition at line 121 of file cryptframe.c.

#define MAXCRYPTKEYNAMELENGTH   64

Maximum length of a crypt key name.

Definition at line 31 of file cryptframe.h.

Referenced by _is_legal_curve25519_key_id().

Typedef Documentation

typedef struct _CryptFrame CryptFrame

Definition at line 32 of file cryptframe.h.

Function Documentation

FSTATIC void _cryptframe_debug_checksum ( const char *  function,
int  lineno,
const char *  message,
const guint8 *  buf 
)

Print a debug checksum message.

Parameters
[in]functionfunction name
[in]linenoline number
[in]messagemessage
[in]bufbuffer to checksum

Definition at line 205 of file cryptframe.c.

FSTATIC gboolean _cryptframe_default_isvalid ( const Frame self,
gconstpointer  tlvptr,
gconstpointer  pktend 
)

CryptFrame class 'isvalid' member function (checks for valid cryptframe objects)

Abstract base class - always FALSE

Parameters
[in]selfCryptFrame object ('this')
[in]tlvptrPointer to the TLV for this CryptFrame
[in]pktendPointer to one byte past the end of the packet

Definition at line 50 of file cryptframe.c.

Referenced by cryptframe_new().

Here is the caller graph for this function:

FSTATIC void _cryptframe_finalize ( AssimObj aself)

Finalize (destructor) function for our CryptFramePublicKey objects.

Parameters
aselfobject to finalize/destroy

Definition at line 64 of file cryptframe.c.

References CASTTOCLASS.

Referenced by cryptframe_new().

Here is the caller graph for this function:

FSTATIC void _cryptframe_initialize_maps ( void  )

Initialize all our maps.

Definition at line 142 of file cryptframe.c.

References addr_to_public_key_map, assim_g_notify_unref(), netaddr_g_hash_equal(), and netaddr_g_hash_hash().

Here is the call graph for this function:

FSTATIC void _cryptframe_privatekey_finalize ( AssimObj privkey)

Finalize (destructor) function for our CryptFramePrivateKey objects.

Parameters
privkeyobject to finalize/destroy

Definition at line 190 of file cryptframe.c.

References _assimobj_finalize(), and CASTTOCLASS.

Referenced by cryptframe_privatekey_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void _cryptframe_publickey_finalize ( AssimObj pubkey)

Finalize (destructor) function for our CryptFramePublicKey objects.

Parameters
pubkeyobject to finalize/destroy

Definition at line 174 of file cryptframe.c.

References _assimobj_finalize(), and CASTTOCLASS.

Referenced by cryptframe_publickey_new().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT gboolean cryptframe_associate_identity ( const char *  identity,
const char *  key_id 
)

Associate the given key id with the given identity Note that it is OK to associate multiple key ids with a given identity but it is NOT OK to associate multiple identities with a given key id Return TRUE if we could make the association (it's OK to make the same valid association multiple times)

Parameters
[in]identityidentity to associate key with
[in]key_idkey to associate with identity

Definition at line 293 of file cryptframe.c.

References __FUNCTION__, cryptframe_key_ids_for(), cryptframe_public_key_by_id(), cryptframe_whois_key_id(), and INITMAPS.

Referenced by cma.AssimCclasses.pyCryptFrame::associate_identity(), fakecma_startup(), main(), and nanoprobe_initialize_keys().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT gboolean cryptframe_dissociate_identity ( const char *  identity,
const char *  key_id 
)

Dissociate the given key from the given identity (analogous to revoking the key)

Parameters
[in]identityidentity to dissociate key from
[in]key_idkey id to "revoke"

Definition at line 334 of file cryptframe.c.

References cryptframe_key_ids_for(), and INITMAPS.

Referenced by cryptframe_purge_key_id().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT const char* cryptframe_get_dest_key_id ( const NetAddr destaddr)

Return the key_id associated with the given destination address.

Definition at line 504 of file cryptframe.c.

References addr_to_public_key_map, CASTTOCLASS, INITMAPS, and CryptFramePublicKey::key_id.

Referenced by cryptframe_new_by_destaddr(), and cma.AssimCclasses.pyCryptFrame::get_dest_key_id().

Here is the caller graph for this function:

WINEXPORT GList* cryptframe_get_identities ( void  )

Return a GList of strings of all known identities.

Definition at line 389 of file cryptframe.c.

References INITMAPS.

WINEXPORT GList* cryptframe_get_key_ids ( void  )

Return a GList of strings of all known key ids.

Definition at line 397 of file cryptframe.c.

References INITMAPS.

Referenced by cma.AssimCclasses.pyCryptFrame::get_key_ids(), and nanoprobe_initialize_keys().

Here is the caller graph for this function:

WINEXPORT CryptFramePrivateKey* cryptframe_get_signing_key ( void  )

Return the default signing key.

Definition at line 441 of file cryptframe.c.

Referenced by nanoprobe_initialize_keys().

Here is the caller graph for this function:

WINEXPORT const char* cryptframe_get_signing_key_id ( void  )

Return the key_id of the default signing key.

Definition at line 434 of file cryptframe.c.

References CryptFramePrivateKey::key_id.

Referenced by cryptcurve25519_new(), fakecma_startup(), and nano_reqconfig().

Here is the caller graph for this function:

WINEXPORT GHashTable* cryptframe_key_ids_for ( const char *  identity)

Return a GHashTable of strings of all the key ids associated with the given identity.

Definition at line 380 of file cryptframe.c.

References INITMAPS.

Referenced by cryptframe_associate_identity(), cryptframe_dissociate_identity(), and nanoprobe_initialize_keys().

Here is the caller graph for this function:

CryptFrame* cryptframe_new ( guint16  frame_type,
const char *  sender_key_id,
const char *  receiver_key_id,
gsize  objsize 
)

Construct a new CryptFrame This can only be used directly for creating subclassed CryptFrame frames because CryptFrame is an abstract class...

Parameters
[in]frame_typeTLV type of CryptFrame
[in]sender_key_idSender key id
[in]receiver_key_idReceiver key id
[in]objsizesize of object

Definition at line 82 of file cryptframe.c.

References _cryptframe_default_isvalid(), _cryptframe_finalize(), _AssimObj::_finalize, _Frame::baseclass, BINDDEBUG, frame_new(), _Frame::isvalid, and NEWSUBCLASS.

Referenced by cryptcurve25519_new().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT CryptFrame* cryptframe_new_by_destaddr ( const NetAddr destaddr)

Construct a CryptFrame class appropriate for encrypting messages to destaddr

Definition at line 488 of file cryptframe.c.

References cryptframe_get_dest_key_id(), INITMAPS, and CryptFramePrivateKey::key_id.

Referenced by cma.AssimCclasses.pyCryptFrame::__init__(), _netio_sendaframeset(), and _netio_sendframesets().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT CryptFramePrivateKey * cryptframe_private_key_by_id ( const char *  key_id)

Return the non-const private key with the given id.

Parameters
[in]key_idKey id of the given private key being sought

Definition at line 279 of file cryptframe.c.

References CASTTOCLASS, and INITMAPS.

Referenced by _is_valid_curve25519_key_id(), cryptcurve25519_new(), cryptcurve25519_tlvconstructor(), cryptframe_privatekey_new(), cryptframe_set_signing_key_id(), and cma.AssimCclasses.pyCryptCurve25519::initkeys().

Here is the caller graph for this function:

WINEXPORT CryptFramePrivateKey* cryptframe_privatekey_new ( const char *  key_id,
gpointer  private_key 
)

Create a new private key - or return the existing private key with this id.

Parameters
[in]key_idKey id of given private key
[in]private_keyMALLOCed private key

Definition at line 245 of file cryptframe.c.

References __FUNCTION__, _cryptframe_privatekey_finalize(), _AssimObj::_finalize, assimobj_new(), cryptframe_private_key_by_id(), DEBUGCKSUM3, INITMAPS, and NEWSUBCLASS.

Referenced by _cache_curve25519_keypair(), cryptcurve25519_gen_persistent_keypair(), and cryptcurve25519_gen_temp_keypair().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT CryptFramePublicKey * cryptframe_public_key_by_id ( const char *  key_id)

Return the non-const public key with the given id.

[in] Key id of public key being sought

Definition at line 270 of file cryptframe.c.

References CASTTOCLASS, and INITMAPS.

Referenced by _cache_curve25519_keypair(), _cryptcurve25519_save_a_key(), cryptcurve25519_new(), cryptcurve25519_save_public_key(), cryptcurve25519_tlvconstructor(), cryptframe_associate_identity(), cryptframe_publickey_new(), nano_reqconfig(), and nanoprobe_initialize_keys().

Here is the caller graph for this function:

WINEXPORT CryptFramePublicKey* cryptframe_publickey_new ( const char *  key_id,
gpointer  public_key 
)

Create a persistent keypair and write it to disk.

Create a new public key - or return the existing public key with this id

Parameters
key_idKey id of the given public key
public_keyMALLOCed public key

Definition at line 220 of file cryptframe.c.

References _cryptframe_publickey_finalize(), _AssimObj::_finalize, assimobj_new(), cryptframe_public_key_by_id(), DEBUGCKSUM3, FRAMETYPE_PUBKEYCURVE25519, INITMAPS, and NEWSUBCLASS.

Referenced by _cache_curve25519_keypair(), cryptcurve25519_gen_persistent_keypair(), cryptcurve25519_gen_temp_keypair(), and cryptcurve25519_save_public_key().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT void cryptframe_purge_key_id ( const char *  key_id)

Definition at line 404 of file cryptframe.c.

References cryptframe_dissociate_identity(), and cryptframe_whois_key_id().

Referenced by cryptcurve25519_purge_keypair().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT gboolean cryptframe_set_dest_key_id ( NetAddr destaddr,
const char *  key_id 
)

Set the encryption key to use when sending to destaddr Set destkey to NULL to stop encrypting to that destination.

Parameters
destaddrDestination addr,port
key_idPublic key id to use when encrypting

Definition at line 470 of file cryptframe.c.

References __FUNCTION__, CASTTOCLASS, cryptframe_set_dest_public_key(), and INITMAPS.

Referenced by _nanoprobe_associate_cma_addrs(), _nanoprobe_is_cma_frameset(), cma.AssimCclasses.pyCryptFrame::dest_set_key_id(), fakecma_startup(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT void cryptframe_set_dest_public_key ( NetAddr destaddr,
CryptFramePublicKey destkey 
)

Set the encryption key to use when sending to destaddr Set destkey to NULL to stop encrypting to that destination.

Parameters
destaddrDestination addr,port
destkeyPublic key to use when encrypting

Definition at line 453 of file cryptframe.c.

References addr_to_public_key_map, INITMAPS, and REF.

Referenced by cryptframe_set_dest_key_id().

Here is the caller graph for this function:

WINEXPORT void cryptframe_set_encryption_method ( CryptFrame *)(const char *sender_key_id, const char *receiver_key_id, gboolean forsending)
WINEXPORT void cryptframe_set_encryption_method ( CryptFrame **  methodconst char *sender_key_id,const char *receiver_key_id,gboolean forsending)
Parameters
methodmethod/constructor for encryption

Definition at line 518 of file cryptframe.c.

Referenced by cryptcurve25519_set_encryption_method(), fakecma_startup(), main(), and nanoprobe_initialize_keys().

Here is the caller graph for this function:

WINEXPORT void cryptframe_set_signing_key_id ( const char *  key_id)

Set the default signing key.

Definition at line 416 of file cryptframe.c.

References __FUNCTION__, cryptframe_private_key_by_id(), REF, and UNREF.

Referenced by cma.AssimCclasses.pyCryptCurve25519::initkeys(), main(), and nanoprobe_initialize_keys().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT void cryptframe_shutdown ( void  )

Shut down our key caches and so on... (destroy our maps)

Definition at line 159 of file cryptframe.c.

References addr_to_public_key_map, and UNREF.

Referenced by main(), and nano_shutdown().

Here is the caller graph for this function:

WINEXPORT Frame* cryptframe_tlvconstructor ( gpointer  tlvstart,
gconstpointer  pktend,
gpointer *  ignorednewpkt,
gpointer *  ignoredpktend 
)

Given marshalled packet data corresponding to an CryptFrame - which we can't do because we're an abstract class...

Parameters
[in]tlvstartStart of marshalled CStringFrame data
[in]pktendPointer to first invalid byte past 'tlvstart'
ignorednewpkt[ignored] replacement packet
ignoredpktend[ignored] end of replacement packet

Definition at line 108 of file cryptframe.c.

WINEXPORT const char* cryptframe_whois_key_id ( const char *  key_id)

Return the identity associated with the given key id.

Parameters
[in]key_idkey id whose identity is sought

Definition at line 371 of file cryptframe.c.

References INITMAPS.

Referenced by _fsprotocol_receive(), cryptframe_associate_identity(), cryptframe_purge_key_id(), cryptframe_whois_public_key(), frameset_sender_identity(), and cma.AssimCclasses.pyCryptFrame::get_identity().

Here is the caller graph for this function:

WINEXPORT const char* cryptframe_whois_public_key ( const CryptFramePublicKey public_key)

Return the identity associated with the given public key object.

Parameters
[in]public_keypublic key whose identity is sought

Definition at line 362 of file cryptframe.c.

References cryptframe_whois_key_id(), INITMAPS, and CryptFramePublicKey::key_id.

Here is the call graph for this function:

Variable Documentation

GHashTable* addr_to_public_key_map = NULL