The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CryptFrame class

Class for encrypting FrameSets. More...

Collaboration diagram for CryptFrame class:

Modules

 CryptCurve25519 class
 Class for encrypting FrameSets.
 

Macros

#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...
 
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_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 new public key - or return the existing public key with this id. 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...
 
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...
 
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 void cryptframe_set_dest_public_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 void cryptframe_set_encryption_method (CryptFrame *(*method)(const char *sender_key_id, const char *receiver_key_id))
 

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))
 
#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 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 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 48 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 62 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 136 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 184 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 168 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 272 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(), 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 309 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 GList* cryptframe_get_identities ( void  )

Return a GList of strings of all known identities.

Definition at line 364 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 372 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 416 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 409 of file cryptframe.c.

References CryptFramePrivateKey::key_id.

Referenced by cryptcurve25519_new(), 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 355 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 80 of file cryptframe.c.

References _cryptframe_default_isvalid(), _cryptframe_finalize(), _AssimObj::_finalize, _Frame::baseclass, 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 457 of file cryptframe.c.

References addr_to_public_key_map, CryptFramePublicKey::key_id, and CryptFramePrivateKey::key_id.

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

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 258 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 225 of file cryptframe.c.

References __FUNCTION__, _cryptframe_privatekey_finalize(), _AssimObj::_finalize, assimobj_new(), cryptframe_private_key_by_id(), 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 249 of file cryptframe.c.

References CASTTOCLASS, and INITMAPS.

Referenced by _cache_curve25519_keypair(), 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 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 201 of file cryptframe.c.

References _cryptframe_publickey_finalize(), _AssimObj::_finalize, assimobj_new(), cryptframe_public_key_by_id(), 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 379 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 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 427 of file cryptframe.c.

References addr_to_public_key_map, INITMAPS, and REF.

Referenced by cryptframe_set_dest_public_key_id().

Here is the caller graph for this function:

WINEXPORT void cryptframe_set_dest_public_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 444 of file cryptframe.c.

References CASTTOCLASS, cryptframe_set_dest_public_key(), and INITMAPS.

Referenced by cma.AssimCclasses.pyCryptFrame::dest_set_public_key_id(), main(), and nanoprobe_associate_cma_key().

Here is the call graph for this function:

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)
WINEXPORT void cryptframe_set_encryption_method ( CryptFrame **  methodconst char *sender_key_id,const char *receiver_key_id)
Parameters
methodmethod/constructor for encryption

Definition at line 471 of file cryptframe.c.

Referenced by cryptcurve25519_set_encryption_method(), 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 391 of file cryptframe.c.

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

Referenced by fakecma_startup(), 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 153 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 105 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 346 of file cryptframe.c.

References INITMAPS.

Referenced by cryptframe_associate_identity(), cryptframe_purge_key_id(), cryptframe_whois_public_key(), and frameset_sender_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 337 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