cryptlib
3.4.1
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Macros
keyset
pgp_key.h
Go to the documentation of this file.
1
/****************************************************************************
2
* *
3
* PGP Keyset Definitions Header File *
4
* Copyright Peter Gutmann 1996-2007 *
5
* *
6
****************************************************************************/
7
8
#ifndef _PGPKEY_DEFINED
9
10
#define _PGPKEY_DEFINED
11
12
#ifndef _PGP_DEFINED
13
#if defined( INC_ALL )
14
#include "
pgp.h
"
15
#else
16
#include "
misc/pgp.h
"
17
#endif
/* Compiler-specific includes */
18
#endif
/* _PGP_DEFINED */
19
20
/****************************************************************************
21
* *
22
* PGP Keyring Constants *
23
* *
24
****************************************************************************/
25
26
/* Each PGP key can contain an arbitrary number of user IDs, we only track
27
the following maximum number. Further IDs are read and stored, but not
28
indexed or searched on */
29
30
#define MAX_PGP_USERIDS 16
31
32
/* When reading a PGP keyring we implement a sliding window that reads a
33
certain amount of data into a lookahead buffer and then tries to identify
34
a key packet group in the buffer. The following value determines the size
35
of the lookahead. Unfortunately we have to keep this above a certain
36
minimum size in order to handle PGP 8.x's inclusion of photo IDs in
37
keyrings, which means that the smallest size that we can safely use is
38
about 8kb */
39
40
#define KEYRING_BUFSIZE 8192
41
42
/****************************************************************************
43
* *
44
* PGP Keyring Types and Structures *
45
* *
46
****************************************************************************/
47
48
/* Key-related information needed to create a cryptlib context from PGP key
49
data */
50
51
typedef
struct
{
52
/* Key data information */
53
CRYPT_ALGO_TYPE
pkcAlgo
;
/* Key algorithm */
54
int
usageFlags
;
/* Keymgmt flags permitted usage */
55
BUFFER_FIXED
(
PGP_KEYID_SIZE
)
\
56
BYTE
pgpKeyID[
PGP_KEYID_SIZE
+ 8 ];
57
BUFFER_FIXED
(
PGP_KEYID_SIZE
)
\
58
BYTE
openPGPkeyID[
PGP_KEYID_SIZE
+ 8 ];
59
BUFFER_FIXED
( pubKeyDataLen ) \
60
void *pubKeyData;
61
BUFFER_OPT_FIXED
( privKeyDataLen ) \
62
void *privKeyData;
/* Pointer to encoded pub/priv key data */
63
int
pubKeyDataLen
, privKeyDataLen;
64
65
/* Key data protection information */
66
CRYPT_ALGO_TYPE
cryptAlgo
;
/* Key wrap algorithm */
67
int
aesKeySize
;
/* Key size if algo == AES */
68
BUFFER
(
CRYPT_MAX_IVSIZE
, ivSize )
\
69
BYTE
iv[
CRYPT_MAX_IVSIZE
+ 8 ];
/* Key wrap IV */
70
int
ivSize
;
71
CRYPT_ALGO_TYPE
hashAlgo
;
/* Password hashing algo */
72
BUFFER
(
PGP_SALTSIZE
, saltSize )
\
73
BYTE
salt
[
PGP_SALTSIZE
+ 8 ];
/* Password hashing salt */
74
int
saltSize
;
75
int
keySetupIterations
;
/* Password hashing iterations */
76
BOOLEAN
hashedChecksum
;
/* Key checksum is SHA-1 hash */
77
}
PGP_KEYINFO
;
78
79
/* The following structure contains the the information for one personality,
80
which covers one or more of a private key, public key, and subkeys. PGP
81
encodes keys in a complex manner by writing them as groups of (implicitly)
82
connected packets that require arbitrary amounts of lookahead to parse.
83
To handle this we read the overall encoded key data as a single unit and
84
store it in a dynamically-allocated buffer, then set up pointers to
85
locations of relevant data (public and private keys and user IDs) within
86
the overall key data. To further complicate matters, there can be a key
87
and subkey associated with the same information, so we have to maintain
88
two lots of physical keying information for each logical key */
89
90
typedef
struct
{
91
BUFFER_FIXED
(
keyDataLen
) \
92
void *
keyData
;
/* Encoded key data */
93
int
keyDataLen
;
94
PGP_KEYINFO
key
,
subKey
;
/* Key and subkey information */
95
ARRAY
(
MAX_PGP_USERIDS
, lastUserID ) \
96
char *userID[
MAX_PGP_USERIDS
+ 8 ];
/* UserIDs */
97
ARRAY
(
MAX_PGP_USERIDS
, lastUserID ) \
98
int userIDlen[
MAX_PGP_USERIDS
+ 8 ];
99
int
lastUserID
;
/* Last used userID */
100
BOOLEAN
isOpenPGP
;
/* Whether data is PGP 2.x or OpenPGP */
101
}
PGP_INFO
;
102
103
/* When we're searching for a key, we need to compare each one against a
104
collection of match criteria. The following structure contains the
105
information that we match against */
106
107
typedef
struct
{
108
CONST_INIT
CRYPT_KEYID_TYPE
keyIDtype
;
/* Key ID type */
109
BUFFER_FIXED
(
keyIDlength
) \
110
const
void
*
keyID
;
111
CONST_INIT
int
keyIDlength
;
/* Key ID */
112
CONST_INIT
int
flags
;
/* Key usage flags */
113
}
KEY_MATCH_INFO
;
114
115
/****************************************************************************
116
* *
117
* PGP Keyring Functions *
118
* *
119
****************************************************************************/
120
121
/* Utility functions in pgp.c */
122
123
STDC_NONNULL_ARG
( ( 1 ) ) \
124
void pgpFreeEntry(
INOUT
PGP_INFO
*pgpInfo );
125
CHECK_RETVAL_BOOL
STDC_NONNULL_ARG
( ( 1, 2, 3 ) )
\
126
BOOLEAN
pgpCheckKeyMatch(
const
PGP_INFO
*pgpInfo,
127
const
PGP_KEYINFO
*
keyInfo
,
128
const
KEY_MATCH_INFO
*
keyMatchInfo
);
129
130
/* Prototypes for functions in pgp_rd.c */
131
132
CHECK_RETVAL
STDC_NONNULL_ARG
( ( 1, 2, 6 ) ) \
133
int pgpReadKeyring(
INOUT
STREAM
*
stream
,
134
IN_ARRAY
(
maxNoPgpObjects
)
PGP_INFO
*pgpInfo,
135
IN_LENGTH_SHORT
const
int
maxNoPgpObjects
,
136
IN_OPT
const
KEY_MATCH_INFO
*
keyMatchInfo
,
137
INOUT_OPT
PGP_KEYINFO
**
matchedKeyInfoPtrPtr
,
138
INOUT
ERROR_INFO
*
errorInfo
);
139
140
#endif
/* _PGPKEY_DEFINED */
Generated on Thu Jan 10 2013 10:00:49 for cryptlib by
1.8.2