~ubuntu-branches/ubuntu/natty/gnupg2/natty-security

« back to all changes in this revision

Viewing changes to agent/t-protect.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Urlichs
  • Date: 2005-12-08 22:13:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051208221321-4rvs2vu835iam5wv
Tags: 1.9.19-2
* Convert debian/changelog to UTF-8.
* Put gnupg-agent and gpgsm lintian overrides in the respectively
  right package.  Closes: #335066
* Added debhelper tokens to maintainer scripts.
* xsession fixes:
  o Added host name to gpg-agent PID file name.  Closes: #312717
  o Fixed xsession script to be able to run under zsh.  Closes: #308516
  o Don't run gpg-agent if one is already running.  Closes: #336480
* debian/control:
  o Fixed package description of gpgsm package.  Closes: #299842
  o Added mention of gpg-agent to description of gnupg-agent package.
    Closes: #304355
* Thanks to Peter Eisentraut <petere@debian.org> for all of the above.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* t-protect.c - Module tests for protect.c
 
2
 * Copyright (C) 2005 Free Software Foundation, Inc.
 
3
 *
 
4
 * This file is part of GnuPG.
 
5
 *
 
6
 * GnuPG is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * GnuPG is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
19
 */
 
20
 
 
21
#include <config.h>
 
22
#include <errno.h>
 
23
#include <stdio.h>
 
24
#include <stdlib.h>
 
25
#include <assert.h>
 
26
 
 
27
#include "agent.h"
 
28
 
 
29
 
 
30
#define pass()  do { ; } while(0)
 
31
#define fail()  do { fprintf (stderr, "%s:%d: test failed\n",\
 
32
                              __FILE__,__LINE__);            \
 
33
                     exit (1);                               \
 
34
                   } while(0)
 
35
 
 
36
 
 
37
static void
 
38
test_agent_protect (void)
 
39
{
 
40
  /* Protect the key encoded in canonical format in PLAINKEY.  We assume
 
41
     a valid S-Exp here. */
 
42
/*   int  agent_protect (const unsigned char *plainkey, const char *passphrase, */
 
43
/*                       unsigned char **result, size_t *resultlen); */
 
44
}
 
45
 
 
46
 
 
47
static void
 
48
test_agent_unprotect (void)
 
49
{
 
50
  /* Unprotect the key encoded in canonical format.  We assume a valid
 
51
     S-Exp here. */
 
52
/*   int  */
 
53
/*     agent_unprotect (const unsigned char *protectedkey, const char *passphrase, */
 
54
/*                      unsigned char **result, size_t *resultlen) */
 
55
}
 
56
 
 
57
 
 
58
static void
 
59
test_agent_private_key_type (void)
 
60
{
 
61
/* Check the type of the private key, this is one of the constants:
 
62
   PRIVATE_KEY_UNKNOWN if we can't figure out the type (this is the
 
63
   value 0), PRIVATE_KEY_CLEAR for an unprotected private key.
 
64
   PRIVATE_KEY_PROTECTED for an protected private key or
 
65
   PRIVATE_KEY_SHADOWED for a sub key where the secret parts are stored
 
66
   elsewhere. */
 
67
/* int */
 
68
/* agent_private_key_type (const unsigned char *privatekey) */
 
69
}
 
70
 
 
71
 
 
72
static void
 
73
test_make_shadow_info (void)
 
74
{
 
75
#if 0
 
76
  static struct 
 
77
  {
 
78
    const char *snstr; 
 
79
    const char *idstr;
 
80
    const char *expected;
 
81
  } data[] = {
 
82
    { "", "", NULL },
 
83
    
 
84
  };
 
85
  int i;
 
86
  unsigned char *result;
 
87
 
 
88
  for (i=0; i < DIM(data); i++)
 
89
    {
 
90
      result =  make_shadow_info (data[i].snstr, data[i].idstr);
 
91
      if (!result && !data[i].expected)
 
92
        pass ();
 
93
      else if (!result && data[i].expected)
 
94
        fail ();
 
95
      else if (!data[i].expected)
 
96
        fail ();
 
97
      /* fixme: Need to compare the result but also need to check
 
98
         proper S-expression syntax. */
 
99
    }
 
100
#endif
 
101
}
 
102
 
 
103
 
 
104
 
 
105
static void
 
106
test_agent_shadow_key (void)
 
107
{
 
108
/* Create a shadow key from a public key.  We use the shadow protocol
 
109
  "ti-v1" and insert the S-expressionn SHADOW_INFO.  The resulting
 
110
  S-expression is returned in an allocated buffer RESULT will point
 
111
  to. The input parameters are expected to be valid canonicalized
 
112
  S-expressions */
 
113
/* int  */
 
114
/* agent_shadow_key (const unsigned char *pubkey, */
 
115
/*                   const unsigned char *shadow_info, */
 
116
/*                   unsigned char **result) */
 
117
}
 
118
 
 
119
 
 
120
static void
 
121
test_agent_get_shadow_info (void)
 
122
{
 
123
/* Parse a canonical encoded shadowed key and return a pointer to the
 
124
   inner list with the shadow_info */
 
125
/* int  */
 
126
/* agent_get_shadow_info (const unsigned char *shadowkey, */
 
127
/*                        unsigned char const **shadow_info) */
 
128
}
 
129
 
 
130
 
 
131
 
 
132
 
 
133
int
 
134
main (int argc, char **argv)
 
135
{
 
136
  test_agent_protect ();
 
137
  test_agent_unprotect ();
 
138
  test_agent_private_key_type ();
 
139
  test_make_shadow_info ();
 
140
  test_agent_shadow_key ();
 
141
  test_agent_get_shadow_info ();
 
142
 
 
143
  return 0;
 
144
}