summaryrefslogtreecommitdiff
path: root/plugins/CryptoPP/src/GPGw/passphrases.cpp
blob: 01e17ec4b942e529fc05b5d4d63ec9b6c861d3dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "../commonheaders.h"
#include "gpgw.h"

// globale variablen
struct passphrase_t *passphrases;
int passphrasecount;


void initPassphrases(void)
{
  passphrasecount=0;
  passphrases=NULL;
}


void releasePassphrases(void)
{
  int i;

  for(i=0; i<passphrasecount; i++)
    memset(passphrases[i].passphrase, 0, sizeof(passphrases[i].passphrase));

  free(passphrases);
}


void addPassphrase(const char *akeyuserid, const char *apassphrase)
{
  passphrasecount++;
  passphrases = (passphrase_t*)realloc(passphrases, sizeof(struct passphrase_t)*passphrasecount);

  strcpy(passphrases[passphrasecount-1].keyuserid, akeyuserid);
  strcpy(passphrases[passphrasecount-1].passphrase, apassphrase);
}


char *getPassphrase(const char *akeyuserid)
{
  int i;
  char *result;

  result=NULL;
  for(i=0; i<passphrasecount; i++)
  {
    if(strcmp(passphrases[i].keyuserid, akeyuserid)==0)
      result=passphrases[i].passphrase;
  }

  return result;
}