cryptlib  3.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
user.h
Go to the documentation of this file.
1 /****************************************************************************
2 * *
3 * User Routines Header File *
4 * Copyright Peter Gutmann 1999-2007 *
5 * *
6 ****************************************************************************/
7 
8 #ifndef _USER_DEFINED
9 
10 #define _USER_DEFINED
11 
12 /* Initialisation states for the user object */
13 
14 typedef enum {
15  USER_STATE_NONE, /* No initialisation state */
16  USER_STATE_SOINITED, /* SSO inited, not usable */
17  USER_STATE_USERINITED, /* User inited, usable */
18  USER_STATE_LOCKED, /* Disabled, not usable */
19  USER_STATE_LAST /* Last possible state */
21 
22 /* User information flags. These are:
23 
24  FLAG_ZEROISE: Zeroise in progress, further messages (except destroy) are
25  bounced, and all files are deleted on destroy */
26 
27 #define USER_FLAG_NONE 0x00 /* No flag */
28 #define USER_FLAG_ZEROISE 0x01 /* Zeroise in progress */
29 
30 /* Content disposition when writing configuration data */
31 
32 typedef enum {
33  CONFIG_DISPOSITION_NONE, /* No disposition type */
34  CONFIG_DISPOSITION_NO_CHANGE, /* No change in data and certificates */
35  CONFIG_DISPOSITION_EMPTY_CONFIG_FILE, /* No data/certs present, empty file */
36  CONFIG_DISPOSITION_TRUSTED_CERTS_ONLY, /* Only trusted certs present */
37  CONFIG_DISPOSITION_DATA_ONLY, /* Only configuratin data present */
38  CONFIG_DISPOSITION_BOTH, /* Both data and certificates present */
39  CONFIG_DISPOSITION_LAST /* Last possible disposition type */
41 
42 /****************************************************************************
43 * *
44 * Data Structures *
45 * *
46 ****************************************************************************/
47 
48 /* User information as stored in the user info file */
49 
50 typedef struct {
51  CRYPT_USER_TYPE type; /* User type */
52  USER_STATE_TYPE state; /* User state */
53  BUFFER( CRYPT_MAX_TEXTSIZE, userNameLength ) \
54  BYTE userName[ CRYPT_MAX_TEXTSIZE + 8 ];
55  int userNameLength; /* User name */
57  BYTE userID[ KEYID_SIZE + 8 ];
59  BYTE creatorID[ KEYID_SIZE + 8 ];/* ID of user and creator of this user */
60  int fileRef; /* User info file reference */
62 
63 /* The structure that stores the information on a user */
64 
65 typedef struct UI {
66  /* Control and status information */
67  int flags; /* User flags */
68  USER_FILE_INFO userFileInfo; /* General user info */
69 
70  /* User index information for the default user */
71  void *userIndexPtr;
72 
73  /* Configuration options for this user. These are managed through the
74  user config code, so they're just treated as a dynamically-allocated
75  blob within the user object */
78 
79  /* Certificate trust information for this user, and a flag indicating
80  whether the trust info has changed and potentially needs to be
81  committed to disk. This requires access to cert-internal details
82  so it's handled externally via the cert code, the user object just
83  sees the info as an opaque blob */
84  void *trustInfoPtr;
86 
87  /* The user object contains an associated keyset which is used to store
88  user information to disk. In addition for SOs and CAs it also
89  contains an associated encryption context, either a private key (for
90  an SO) or a conventional key (for a CA) */
91  CRYPT_KEYSET iKeyset; /* Keyset */
92  CRYPT_CONTEXT iCryptContext; /* Private/secret key */
93 
94  /* Error information */
95  CRYPT_ATTRIBUTE_TYPE errorLocus;/* Error locus */
96  CRYPT_ERRTYPE_TYPE errorType; /* Error type */
97 
98  /* The object's handle, used when sending messages to the object when
99  only the xxx_INFO is available */
101  } USER_INFO;
102 
103 /****************************************************************************
104 * *
105 * Internal API Functions *
106 * *
107 ****************************************************************************/
108 
109 /* User attribute handling functions */
110 
111 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 2 ) ) \
112 int getUserAttribute( INOUT USER_INFO *userInfoPtr,
115 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 2 ) ) \
116 int getUserAttributeS( INOUT USER_INFO *userInfoPtr,
120 int setUserAttribute( INOUT USER_INFO *userInfoPtr,
121  IN_INT_Z const int value,
123 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 2 ) ) \
124 int setUserAttributeS( INOUT USER_INFO *userInfoPtr,
125  IN_BUFFER( dataLength ) const void *data,
129 int deleteUserAttribute( INOUT USER_INFO *userInfoPtr,
131 
132 /* Prototypes for functions in user.c */
133 
134 CHECK_RETVAL \
135 const USER_FILE_INFO *getPrimarySoUserInfo( void );
137 BOOLEAN isZeroisePassword( IN_BUFFER( passwordLen ) const char *password,
140 int zeroiseUsers( INOUT USER_INFO *userInfoPtr );
141 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 2 ) ) \
142 int setUserPassword( INOUT USER_INFO *userInfoPtr,
143  IN_BUFFER( passwordLength ) const char *password,
146 int initUserIndex( OUT_OPT_PTR void **userIndexPtrPtr );
147 STDC_NONNULL_ARG( ( 1 ) ) \
148 void endUserIndex( INOUT void *userIndexPtr );
149 
150 /* Prototypes for functions in user_cfg.c */
151 
152 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 2 ) ) \
153 int initOptions( OUT_OPT_PTR void **configOptionsPtr,
155 STDC_NONNULL_ARG( ( 1 ) ) \
156 void endOptions( INOUT_ARRAY( configOptionsCount ) TYPECAST( OPTION_INFO * ) \
157  void *configOptions,
158  IN_INT_SHORT const int configOptionsCount );
160 int setOption( INOUT_ARRAY( configOptionsCount ) TYPECAST( OPTION_INFO * ) \
161  void *configOptions,
164  IN_INT const int value );
166 int setOptionSpecial( INOUT_ARRAY( configOptionsCount ) TYPECAST( OPTION_INFO * ) \
167  void *configOptions,
168  IN_INT_SHORT const int configOptionsCount,
171  IN_INT const int value );
172 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 4 ) ) \
173 int setOptionString( INOUT_ARRAY( configOptionsCount ) TYPECAST( OPTION_INFO * ) \
174  void *configOptions,
175  IN_INT_SHORT const int configOptionsCount,
177  IN_BUFFER( valueLength ) const char *value,
179 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 4 ) ) \
180 int getOption( IN_ARRAY( configOptionsCount ) TYPECAST( OPTION_INFO * ) \
181  const void *configOptions,
182  IN_INT_SHORT const int configOptionsCount,
183  IN_ATTRIBUTE const CRYPT_ATTRIBUTE_TYPE option,
184  OUT_INT_Z int *value );
185 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 4, 5 ) ) \
186 int getOptionString( IN_ARRAY( configOptionsCount ) TYPECAST( OPTION_INFO * ) \
187  const void *configOptions,
188  IN_INT_SHORT const int configOptionsCount,
189  IN_ATTRIBUTE const CRYPT_ATTRIBUTE_TYPE option,
190  OUT_OPT_PTR const void **strPtrPtr,
191  OUT_LENGTH_SHORT_Z int *strLen );
193 int deleteOption( INOUT_ARRAY( configOptionsCount ) TYPECAST( OPTION_INFO * ) \
194  void *configOptions,
195  IN_INT_SHORT const int configOptionsCount,
196  IN_ATTRIBUTE const CRYPT_ATTRIBUTE_TYPE option );
197 
198 /* Prototypes for functions in user_rw.c */
199 
201 int readConfig( IN_HANDLE const CRYPT_USER iCryptUser,
202  IN_STRING const char *fileName,
203  INOUT_OPT void *trustInfoPtr );
204 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 3, 4 ) ) \
205 int getConfigDisposition( INOUT_ARRAY( configOptionsCount ) TYPECAST( OPTION_INFO * ) \
206  void *configOptions,
207  IN_INT_SHORT const int configOptionsCount,
208  const void *trustInfoPtr,
209  OUT_ENUM( CONFIG_DISPOSITION ) \
210  CONFIG_DISPOSITION_TYPE *disposition );
211 CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 3, 4 ) ) \
212 int prepareConfigData( INOUT_ARRAY( configOptionsCount ) TYPECAST( OPTION_INFO * ) \
213  void *configOptions,
214  IN_INT_SHORT const int configOptionsCount,
216  OUT_LENGTH_Z int *dataLength );
218 int commitConfigData( IN_STRING const char *fileName,
219  IN_BUFFER_OPT( dataLength ) const void *data,
223 int deleteConfig( IN_STRING const char *fileName );
224 
225 #endif /* _USER_DEFINED */