The Assimilation Project  based on Assimilation version 1.1.7.1474836767
cryptcurve25519.c File Reference

Implements the CryptCurve25519 class class - A Frame for encrypting packets. More...

#include <glib/gstdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <pwd.h>
#include <errno.h>
#include <string.h>
#include <projectcommon.h>
#include <frameset.h>
#include <sodium.h>
#include <misc.h>
#include <cryptcurve25519.h>
#include <frametypes.h>
#include <generic_tlv_min.h>
#include <tlvhelper.h>
Include dependency graph for cryptcurve25519.c:

Go to the source code of this file.

Macros

#define EOS   '\0'
 
#define KEY_NAMING_CHECKSUM   G_CHECKSUM_MD5
 
#define DEBUGCKSUM2(msg, buf, bufsize)   {if (DEBUG >= 2) cryptcurve25519_debug_checksum(__FUNCTION__, __LINE__, msg, buf, bufsize);}
 
#define DEBUGCKSUM3(msg, buf, bufsize)   {if (DEBUG >= 3) cryptcurve25519_debug_checksum(__FUNCTION__, __LINE__, msg, buf, bufsize);}
 
#define DEBUGCKSUM4(msg, buf, bufsize)   {if (DEBUG >= 4) cryptcurve25519_debug_checksum(__FUNCTION__, __LINE__, msg, buf, bufsize);}
 
#define TLVLEN(receiverkey_id, senderkey_id)
 

Functions

FSTATIC void _cryptcurve25519_finalize (AssimObj *aself)
 Finalize (free) a CryptCurve25519 object. More...
 
FSTATIC gboolean _cryptcurve25519_default_isvalid (const Frame *fself,gconstpointer tlvstart,gconstpointer pktend)
 CryptCurve25519 class 'isvalid' member function (checks for valid cryptcurve25519 objects) More...
 
FSTATIC void _cryptcurve25519_updatedata (Frame *f,gpointer tlvstart,gconstpointer pktend,FrameSet *unused_fs)
 We update the data in the packet from our CryptCurve25519 object with the side-effect of encrypting all the frames already put into the packet. More...
 
FSTATIC gboolean _is_valid_curve25519_key_id (const char *key_id,enum keytype ktype)
 CryptCurve25519 class function to check if a given curve25519 key id is valid This name might come from a bad guy, so let's carefully scrub the name More...
 
FSTATIC gboolean _is_legal_curve25519_key_id (const char *key_id)
 CryptCurve25519 class function to check if a given curve25519 key id is properly formatted This name might come from a bad guy, so let's carefully scrub the name More...
 
FSTATIC char * _cache_curve25519_key_id_to_dirname (const char *key_id,enum keytype ktype)
 Map a key name on the wire to a file name in the filesystem We make this a function on the idea that we might eventually want to have hashed subdirectories or something similar... More...
 
FSTATIC void _cryptcurve25519_make_cryptdir (const char *dirname)
 Make a directory for storing keys in... More...
 
FSTATIC gboolean _cache_curve25519_keypair (const char *key_id)
 Validate and cache the requested curve25519 keypair (or just public if no private) If it's already in memory (like a temporary key) we won't look for it on disk. More...
 
FSTATIC gboolean _cryptcurve25519_save_a_key (const char *key_id, enum keytype ktype,gconstpointer key)
 Save a curve25519 key to a file. More...
 
FSTATIC enum keytype _cryptcurve25519_keytype_from_filename (const char *filename)
 Determine the type of key this might be according to its filename. More...
 
FSTATIC char * _cryptcurve25519_key_id_from_filename (const char *filename)
 Determine the key_id this might is according to its pathname. More...
 
FSTATIC void dump_memory (const char *label, const guint8 *start, const guint8 *end)
 
FSTATIC char * cryptcurve25519_naming_checksum (const guint8 *buf,size_t buflen)
 Return a malloced string containing the KEY_NAMING_CHECKSUM type checksum of the given data. More...
 
FSTATIC void cryptcurve25519_debug_checksum (const char *function,int lineno,const char *message,const guint8 *buf,size_t bufsize)
 Print a debug checksum message. More...
 
WINEXPORT char * curve25519_key_id_to_filename (const char *key_id, enum keytype ktype)
 
WINEXPORT gboolean cryptcurve25519_purge_keypair (const char *key_id)
 Purge a cryptcurve25519 key from the filesystem and from memory. More...
 
WINEXPORT void cryptcurve25519_cache_all_keypairs (void)
 We read in and cache all the key pairs (or public keys) that we find in CRYPTKEYDIR. More...
 
CryptCurve25519cryptcurve25519_new (guint16 frame_type, const char *sender_key_id, const char *receiver_key_id, gboolean forsending, gsize objsize)
 Construct a new CryptCurve25519 object (frame). More...
 
WINEXPORT Framecryptcurve25519_tlvconstructor (gpointer tlvstart, gconstpointer pktend, gpointer *ignorednewpkt, gpointer *ignoredpktend)
 Given marshalled packet data corresponding to an CryptCurve25519 frame return the corresponding Frame In other words, un-marshall the data... More...
 
WINEXPORT void cryptcurve25519_gen_temp_keypair (const char *key_id)
 Generate a temporary (non-persistent) key pair. More...
 
WINEXPORT char * cryptcurve25519_gen_persistent_keypair (const char *giveitaname)
 Create a persistent keypair and write it to disk Returns a MALLOCed string with the key id for the key pair. More...
 
WINEXPORT gboolean cryptcurve25519_save_public_key (const char *key_id, gpointer public_key, int keysize)
 Save a public key away to disk so it's completely usable... More...
 
WINEXPORT CryptFramecryptcurve25519_new_generic (const char *sender_key_id, const char *receiver_key_id, gboolean forsending)
 Generic "new" function to use with cryptframe_set_encryption_method() More...
 
WINEXPORT void cryptcurve25519_set_encryption_method (void)
 Function just to make setting the encryption method simpler from Python. More...
 

Detailed Description

Implements the CryptCurve25519 class class - A Frame for encrypting packets.

It uses libsodium to implement public key encryption in packets.

This file is part of the Assimilation Project.

Author
Copyright © 2011, 2012 - Alan Robertson alanr.nosp@m.@uni.nosp@m.x.sh
The Assimilation software is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Assimilation software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the Assimilation Project software. If not, see http://www.gnu.org/licenses/

Definition in file cryptcurve25519.c.

Macro Definition Documentation

#define EOS   '\0'

Definition at line 42 of file cryptcurve25519.c.

Referenced by _is_legal_curve25519_key_id().

#define KEY_NAMING_CHECKSUM   G_CHECKSUM_MD5

Definition at line 43 of file cryptcurve25519.c.

Referenced by cryptcurve25519_naming_checksum().