File pa/gpg.c

  $Revision: 1.43 $

gpg.c - core of the PA module. Contains functions that are used to check the PGP authentication in a message.
Status: COMPLETE, REVUED, TESTED

Included Files


Global Variable Lock

pthread_mutex_t Lock
Included from /home/shane/release/RIP/include/ca_defs.h
Visible in:  aa/aa.c
   ac/ac_persistence.c
   ac/access_control.c
   au/AU_util.c
   ca/ca_configFns.c
   ca/ca_initFn.c
   ca/ca_sanityCheck.c
   ca/ca_sourceLoader.c
   ca/ca_values.c
   co/constants.c
   df/defs.c
   er/er.c
   er/er_arrays.c
   er/er_macro.c
   er/er_paths.c
   er/er_print.c
   ip/ip.c
   ma/bitmask.c
   mm/mm.c
   nh/nh.c
   pa/gpg.c
Used in: ca_get_adminIntElement()ca/ca_configFns.c
  ca_get_adminStrElement()ca/ca_configFns.c
  ca_get_boolean()ca/ca_configFns.c
  ca_get_dirlist()ca/ca_configFns.c
  ca_get_int()ca/ca_configFns.c
  ca_get_string()ca/ca_configFns.c
  ca_set_boolean()ca/ca_configFns.c
  ca_srchandle2Intelement()ca/ca_configFns.c
  ca_srchandle2Strelement()ca/ca_configFns.c

External Variables

EP_TreeHeight
extern int EP_TreeHeight
Defined in: ep/mail_parser.c

EP_Node_ID
extern int EP_Node_ID
Defined in: ep/mail_parser.c

EP_Debug
extern int EP_Debug
Defined in: ep/mail_parser.c

sd1
extern int sd1[2]


Local Variables

tmpdir
static char* tmpdir
Used in: NT_add_to_cross_hash()
  NT_add_to_frwd_hash()
  NT_add_to_ntfy_hash()
  NT_forw_create_req()
  PA_SetTmpDir()
  PA_VerifySignature()

outputPrefix
static char* outputPrefix
Used in: PA_ParseMessage()
  PA_SetOutputPrefix()

keyRing
static char* keyRing
Used in: PA_SetKeyRing()
  PA_VerifySignature()
  VerifySignAndExplodeFile()

gpgCmd
static char* gpgCmd
Used in: GetFingerPrint()
  GetKeyID()
  GetKeyOwner()
  PA_Decrypt()
  PA_ImportKey()
  PA_RemoveKey()
  PA_RemoveKey_withKeyID()
  PA_SetGPGCmd()
  PA_VerifySignature()
  VerifySignAndExplodeFile()


Global Function GetFingerPrint()

Get the fingerprint of a PGP key.

ImportKeyObject *iKO The imported key object
void GetFingerPrint ( struct ImportKeyObject* iKO )
Prototyped in: /home/shane/release/RIP/include/gpg.h
Calls: ER_perror()er/er.c
  ___errno(), exit(), fdopen(), fdwrap_close(), fgets(), spawn_job(), sprintf(), sscanf(), strcpy(), strerror(), strlen(), strstr(), waitpid()
Called by: PA_ImportKey()pa/gpg.c
References Variables: gpgCmdpa/gpg.c
  sd1

Global Function GetKeyID()

Get the KeyID of a PGP key.
void GetKeyID ( struct ImportKeyObject* iKO )
struct ImportKeyObject* iKO
The structure containing the key of which we want the KeyID
Prototyped in: pa/gpg.c
Calls: ER_perror()er/er.c
  ___errno(), exit(), fdopen(), fdwrap_close(), fgets(), nfslock(), nfsunlock(), spawn_job(), sscanf(), strcpy(), strerror(), strrchr(), strstr(), waitpid()
Called by: PA_RemoveKey()pa/gpg.c
References Variables: gpgCmdpa/gpg.c
  sd1

Global Function GetKeyOwner()

Get the owner of a PGP key.

ImportKeyObject *iKO The imported key object
void GetKeyOwner ( struct ImportKeyObject* iKO )
Prototyped in: /home/shane/release/RIP/include/gpg.h
Calls: ER_perror()er/er.c
  ___errno(), exit(), fdopen(), fdwrap_close(), fgets(), spawn_job(), sprintf(), sscanf(), strcpy(), strerror(), strlen(), strstr(), waitpid()
Called by: PA_ImportKey()pa/gpg.c
References Variables: gpgCmdpa/gpg.c
  sd1

Global Function PA_Decrypt()

Decrypt a PGP-encrypted file.


Note: This functions is not used by PA/EP/MM It can be useful in the future.... (FP)
void PA_Decrypt ( struct ReadCryptedObject* rDO )
struct ReadCryptedObject* rDO
The object to be decrypted
Prototyped in: /home/shane/release/RIP/include/gpg.h
Calls: ER_perror()er/er.c
  ___errno(), exit(), fdopen(), fdwrap_close(), fgets(), spawn_job(), strcat(), strcpy(), strerror(), waitpid()
References Variables: gpgCmdpa/gpg.c
  sd1

Global Function PA_ImportKey()

Import a PGP key.
void PA_ImportKey ( struct ImportKeyObject* iKO )
struct ImportKeyObject* iKO
The structure where the imported key goes
Prototyped in: /home/shane/release/RIP/include/gpg.h
Calls: ER_perror()er/er.c
  GetFingerPrint()pa/gpg.c
  GetKeyOwner()pa/gpg.c
  PA_RemoveKey_withKeyID()pa/gpg.c
  ___errno(), exit(), fdopen(), fdwrap_close(), fgets(), g_list_append(), nfslock(), nfsunlock(), printf(), spawn_job(), sscanf(), strcpy(), strerror(), strrchr(), strstr(), waitpid()
References Variables: gpgCmdpa/gpg.c
  sd1, tracing

Global Function PA_ParseMessage()

Parse a file and look for PGP-signed elements inside. 
EPNodePtr PA_ParseMessage ( EPNodePtr ptr )
EPNodePtr ptr
The pointer to the EP treenode containing the file to be parsed.
Prototyped in: /home/shane/release/RIP/include/gpg.h
Calls: EP_DefineNewNode()ep/mail_parser.c
  EP_MIMEParse()ep/mail_parser.c
  ER_dbg_va()er/er.c
  PA_ParseMessage()pa/gpg.c
  VerifySignAndExplodeFile()pa/gpg.c
  fdwrap_fclose(), fgets(), fopen(), fputs(), strstr()
Called by: EP_MIMEParse()ep/mail_parser.c
  EP_ParseText()ep/mail_parser.c
  PA_ParseMessage()pa/gpg.c
  parse_text_plain()mm/mm.c
References Variables: EP_Node_IDep/mail_parser.c
  outputPrefixpa/gpg.c

Global Function PA_RemoveKey()

Remove a PGP key.
void PA_RemoveKey ( struct ImportKeyObject* iKO )
struct ImportKeyObject* iKO
The structure containing the key to be removed
Prototyped in: /home/shane/release/RIP/include/gpg.h
Calls: ER_perror()er/er.c
  GetKeyID()pa/gpg.c
  ___errno(), exit(), fdopen(), fdwrap_close(), fgets(), nfslock(), nfsunlock(), spawn_job(), sprintf(), strcpy(), strerror(), strrchr(), strstr(), waitpid()
References Variables: gpgCmdpa/gpg.c
  sd1

Global Function PA_RemoveKey_withKeyID()

Remove a PGP key, using its KeyID (otherwise it's the same as PA_RemoveKey
void PA_RemoveKey_withKeyID ( struct ImportKeyObject* iKO )
struct ImportKeyObject* iKO
The structure containing the key to be removed
Prototyped in: /home/shane/release/RIP/include/gpg.h
Calls: ER_perror()er/er.c
  ___errno(), exit(), fdopen(), fdwrap_close(), fgets(), nfslock(), nfsunlock(), spawn_job(), sprintf(), strcpy(), strerror(), strrchr(), strstr(), waitpid()
Called by: PA_ImportKey()pa/gpg.c
References Variables: gpgCmdpa/gpg.c
  sd1

Global Function PA_SetGPGCmd()

Set the GPG command line.


This memory allocated is never freed, maybe a PA_end function?
void PA_SetGPGCmd ( char* path )
char* path
The path including command name
Prototyped in: /home/shane/release/RIP/include/gpg.h
Calls: pa_strcpy()pa/gpg.c
References Variables: gpgCmdpa/gpg.c

Global Function PA_SetKeyRing()

Set the path to the Keyring.
void PA_SetKeyRing ( char* path )
char* path
The path including file name
Prototyped in: /home/shane/release/RIP/include/gpg.h
Calls: pa_strcpy()pa/gpg.c
References Variables: keyRingpa/gpg.c

Global Function PA_SetOutputPrefix()

Set the path to the output file.
void PA_SetOutputPrefix ( char* path )
char* path
The path including file name
Prototyped in: /home/shane/release/RIP/include/gpg.h
Calls: pa_strcpy()pa/gpg.c
Called by: EP_MIMEParse()ep/mail_parser.c
  EP_ParseMail()ep/mail_parser.c
  EP_ParseText()ep/mail_parser.c
References Variables: outputPrefixpa/gpg.c

Global Function PA_SetTmpDir()

Set the GPG temporary directory.


This memory allocated is never freed, maybe a PA_end function?
void PA_SetTmpDir ( char* dir )
char* dir
The directory
Calls: pa_strcpy()pa/gpg.c
References Variables: tmpdirpa/gpg.c

Global Function PA_VerifySignature()

Verify a detached PGP signature.
void PA_VerifySignature ( struct VerifySignObject* vSO )
struct VerifySignObject* vSO
The signed object structure to be verified.
Prototyped in: /home/shane/release/RIP/include/gpg.h
Calls: ER_perror()er/er.c
  ___errno(), exit(), fdopen(), fdwrap_close(), fgets(), mkstemp(), open(), read(), spawn_job(), sprintf(), sscanf(), strcat(), strcmp(), strcpy(), strerror(), strstr(), unlink(), waitpid(), write()
Called by: parse_multipart_signed()mm/mm.c
References Variables: gpgCmdpa/gpg.c
  keyRingpa/gpg.c
  tmpdirpa/gpg.c
  sd1

Global Function VerifySignAndExplodeFile()

Verify the PGP signature and extract the signed part in a file.
void VerifySignAndExplodeFile ( EPNodePtr ptr )
EPNodePtr ptr
The pointer to the EP treenode containing the originating file
Prototyped in: pa/gpg.c
Calls: ER_perror()er/er.c
  UT_free_real(), UT_strdup_real(), ___errno(), exit(), fdopen(), fdwrap_close(), fdwrap_fclose(), fgets(), fopen(), fprintf(), spawn_job(), sprintf(), sscanf(), strcpy(), strerror(), strstr(), unlink(), waitpid()
Called by: PA_ParseMessage()pa/gpg.c
References Variables: gpgCmdpa/gpg.c
  keyRingpa/gpg.c
  sd1

Global Function pa_strcpy()

Copies a string with memory allocation care.

char* dest The destination string char* orig The origin string
void pa_strcpy ( char** dest, char* orig )
Calls: free(), malloc(), strcpy(), strlen()
Called by: PA_SetGPGCmd()pa/gpg.c
  PA_SetKeyRing()pa/gpg.c
  PA_SetOutputPrefix()pa/gpg.c
  PA_SetTmpDir()pa/gpg.c

Local Function asctime_r()

static char* asctime_r ( const struct tm* __tm, char* __buf )
Included from: /usr/include/time.h
Calls: __posix_asctime_r()

Local Function ctime_r()

static char* ctime_r ( const time_t* __time, char* __buf )
Included from: /usr/include/time.h
Calls: __posix_ctime_r()

Local Function getlogin_r()

static int getlogin_r ( char* __name, int __len )
Included from: /usr/include/unistd.h
Calls: __posix_getlogin_r()

Local Function readdir_r()

static int readdir_r ( DIR* __dp, struct dirent* __ent, struct dirent** __res )
Included from: /usr/include/dirent.h
Calls: __posix_readdir_r()

Local Function sigwait()

static int sigwait ( const sigset_t* __setp, int* __signo )
Included from: /usr/include/signal.h
Calls: __posix_sigwait()

Local Function ttyname_r()

static int ttyname_r ( int __fildes, char* __buf, size_t __size )
Included from: /usr/include/unistd.h
Calls: __posix_ttyname_r()