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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
/* t-protect.c - Module tests for protect.c
* Copyright (C) 2005 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* GnuPG 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 2 of the License, or
* (at your option) any later version.
*
* GnuPG 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include <config.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "agent.h"
#define pass() do { ; } while(0)
#define fail() do { fprintf (stderr, "%s:%d: test failed\n",\
__FILE__,__LINE__); \
exit (1); \
} while(0)
static void
test_agent_protect (void)
{
/* Protect the key encoded in canonical format in PLAINKEY. We assume
a valid S-Exp here. */
/* int agent_protect (const unsigned char *plainkey, const char *passphrase, */
/* unsigned char **result, size_t *resultlen); */
}
static void
test_agent_unprotect (void)
{
/* Unprotect the key encoded in canonical format. We assume a valid
S-Exp here. */
/* int */
/* agent_unprotect (const unsigned char *protectedkey, const char *passphrase, */
/* unsigned char **result, size_t *resultlen) */
}
static void
test_agent_private_key_type (void)
{
/* Check the type of the private key, this is one of the constants:
PRIVATE_KEY_UNKNOWN if we can't figure out the type (this is the
value 0), PRIVATE_KEY_CLEAR for an unprotected private key.
PRIVATE_KEY_PROTECTED for an protected private key or
PRIVATE_KEY_SHADOWED for a sub key where the secret parts are stored
elsewhere. */
/* int */
/* agent_private_key_type (const unsigned char *privatekey) */
}
static void
test_make_shadow_info (void)
{
static struct
{
const char *snstr;
const char *idstr;
const char *expected;
} data[] = {
{ "", "", NULL },
};
int i;
unsigned char *result;
for (i=0; i < DIM(data); i++)
{
result = make_shadow_info (data[i].snstr, data[i].idstr);
if (!result && !data[i].expected)
pass ();
else if (!result && data[i].expected)
fail ();
else if (!data[i].expected)
fail ();
/* fixme: Need to compare the result but also need to check
proper S-expression syntax. */
}
}
static void
test_agent_shadow_key (void)
{
/* Create a shadow key from a public key. We use the shadow protocol
"ti-v1" and insert the S-expressionn SHADOW_INFO. The resulting
S-expression is returned in an allocated buffer RESULT will point
to. The input parameters are expected to be valid canonicalized
S-expressions */
/* int */
/* agent_shadow_key (const unsigned char *pubkey, */
/* const unsigned char *shadow_info, */
/* unsigned char **result) */
}
static void
test_agent_get_shadow_info (void)
{
/* Parse a canonical encoded shadowed key and return a pointer to the
inner list with the shadow_info */
/* int */
/* agent_get_shadow_info (const unsigned char *shadowkey, */
/* unsigned char const **shadow_info) */
}
int
main (int argc, char **argv)
{
test_agent_protect ();
test_agent_unprotect ();
test_agent_private_key_type ();
test_make_shadow_info ();
test_agent_shadow_key ();
test_agent_get_shadow_info ();
return 0;
}
|