/[winpt]/trunk/Include/wptKeyEdit.h
ViewVC logotype

Annotation of /trunk/Include/wptKeyEdit.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 329 - (hide annotations)
Fri Sep 25 16:08:14 2009 UTC (15 years, 5 months ago) by twoaday
File MIME type: text/plain
File size: 6124 byte(s)


1 werner 37 /* wptKeyEdit.h
2 twoaday 329 * Copyright (C) 2003, 2004, 2009 Timo Schulz
3 werner 37 *
4     * This file is part of WinPT.
5     *
6     * WinPT is free software; you can redistribute it and/or
7     * modify it under the terms of the GNU General Public License
8     * as published by the Free Software Foundation; either version 2
9     * of the License, or (at your option) any later version.
10     *
11     * WinPT 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 GNU
14     * General Public License for more details.
15     */
16    
17     #ifndef WPT_KEY_EDIT_H
18     #define WPT_KEY_EDIT_H
19    
20     /* IDs for all possible gpg edit key commands. */
21     enum gpg_editkey_t {
22     GPG_EDITKEY_SIGN = 1,
23     GPG_EDITKEY_LSIGN = 2,
24     GPG_EDITKEY_NRSIGN = 19,
25     GPG_EDITKEY_NRLSIGN = 22,
26     GPG_EDITKEY_TSIGN = 20,
27     GPG_EDITKEY_TRUST = 3,
28     GPG_EDITKEY_ADDUID = 4,
29     GPG_EDITKEY_DELUID = 5,
30     GPG_EDITKEY_DELKEY = 6,
31     GPG_EDITKEY_ADDKEY = 7,
32     GPG_EDITKEY_PASSWD = 8,
33     GPG_EDITKEY_PRIMARY = 9,
34     GPG_EDITKEY_EXPIRE = 10,
35     GPG_EDITKEY_REVSIG = 11,
36     GPG_EDITKEY_REVKEY = 12,
37     GPG_EDITKEY_REVOKE = 13, /* revoke the whole key */
38     GPG_EDITKEY_ADDREV = 14,
39     GPG_EDITKEY_ADDPHOTO= 15,
40     GPG_EDITKEY_ENABLE = 16,
41     GPG_EDITKEY_DISABLE = 17,
42     GPG_EDITKEY_SETPREF = 18,
43     GPG_EDITKEY_DELSIG = 21,
44     GPG_EDITKEY_KEYSERV = 23,
45 twoaday 119 GPG_EDITKEY_REVUID = 24,
46 twoaday 200 GPG_EDITKEY_CLEAN = 25,
47 twoaday 206 GPG_EDITKEY_NOTATION= 26,
48 twoaday 260 GPG_EDITKEY_MINIMIZE= 27,
49     GPG_EDITKEY_ADDCARDKEY=28
50 werner 37 };
51    
52     /* Reasons for revocations. */
53     enum gpg_revoke_t {
54     GPG_REVOKE_INSECURE = 1,
55     GPG_REVOKE_SUPERSEDED = 2,
56     GPG_REVOKE_NOUSED = 3
57     };
58    
59     /* Contain information about designated revokers. */
60     struct gpg_desig_rev_s {
61     struct gpg_desig_rev_s *next;
62     gpgme_pubkey_algo_t pubkey_algo;
63     char fpr[41];
64     };
65     typedef struct gpg_desig_rev_s *gpg_desig_rev_t;
66    
67     /* Context to hold all user-ID information. */
68     struct gpg_user_id_info_s {
69     struct gpg_user_id_info_s *next;
70     struct {
71     unsigned int revoked:1;
72     unsigned int invalid:1;
73     unsigned int primary:1;
74     unsigned int mdc:1;
75     unsigned int no_ks_modify:1;
76     } flags;
77     int validity;
78     char *name;
79     char *email;
80     char *prefs;
81     int index;
82     };
83     typedef struct gpg_user_id_info_s *gpg_uid_info_t;
84    
85     /* Class to abstract the gpg edit key interface. */
86     class GpgKeyEdit {
87     private:
88     gpgme_key_t key;
89     gpgme_ctx_t ctx;
90     int resval;
91     int type;
92    
93 twoaday 176 bool key_has_passwd;
94    
95 twoaday 260 int sig_index; /* signature index. */
96     int key_index; /* key index. */
97     int uid_index; /* userid index. */
98 twoaday 170
99 twoaday 329 int valid;
100 twoaday 176
101 werner 37 public:
102     int cnt;
103     int cmd_sent;
104     const char *pass;
105     const char *new_pass;
106 twoaday 234 const char *new_prefs;
107 werner 37 const char *url;
108     int trust_id;
109 twoaday 200 char *notation;
110 werner 37 char *name, *cmt, *email;
111     const char *exp_date; /* XXX */
112     gpgme_pubkey_algo_t pubkey_algo;
113 twoaday 200 unsigned int pubkey_size;
114 werner 37 int flags;
115     int sig_class;
116     int reason;
117    
118     public:
119 twoaday 279 GpgKeyEdit (void);
120 werner 37 GpgKeyEdit (gpgme_key_t key);
121     GpgKeyEdit (const char *keyid);
122     ~GpgKeyEdit (void);
123    
124     bool isValid (void);
125     void reset (void);
126 twoaday 175
127 twoaday 170 void clear (void);
128 twoaday 175 void clearPassphrase (void);
129 werner 37
130 twoaday 176 void setNoPassphrase (bool val);
131 twoaday 260 void setPassphrase (const char *_pass);
132     void setPassphrase2 (const char *_pass2);
133 twoaday 329 void setPassphraseCallback (gpgme_passphrase_cb_t cb, void *cb_value);
134     bool usePassphraseCallback (void);
135 werner 37 void setKey (gpgme_key_t key);
136     void setKeyID (const char *keyid);
137     void setLocalUser (gpgme_key_t locusr);
138 twoaday 170 void setCallback (gpgme_progress_cb_t cb, void *cb_value);
139 werner 37 void setResult (int val);
140     int getResult (void);
141    
142 twoaday 170 gpgme_key_t getKey (void);
143     int getType (void);
144     int getUseridIndex (void);
145     int getKeyIndex (void);
146     int getSigIndex (void);
147 twoaday 176 int getValidDays (void);
148 twoaday 170
149 twoaday 200 gpgme_error_t addNotation (int uid_idx, const char *notation);
150 twoaday 170 gpgme_error_t signUserid (int uid_idx, int mode, int sig_class,
151     const char *exp_date);
152 werner 37 gpgme_error_t signKey (int mode, int sig_class, const char *exp_date);
153     gpgme_error_t setTrust (gpgme_validity_t trust);
154     gpgme_error_t addUserid (const char *name, const char *cmt,
155     const char *email);
156     gpgme_error_t delUserid (int index);
157     gpgme_error_t delKey (int index);
158     gpgme_error_t addSubkey (gpgme_pubkey_algo_t pubkey_algo,
159     unsigned int nbits, long valid);
160     gpgme_error_t changePassphrase (const char *new_pass, int allow_empty);
161     gpgme_error_t setPrimaryUserid (int uid_indx);
162     gpgme_error_t setKeyExpireDate (int key_index, long exp_timestamp,
163     bool exp_days);
164     gpgme_error_t revokeUserid (int uid_indx);
165     gpgme_error_t revokeSignature (int uid_index, int sig_index);
166     gpgme_error_t revokeSubkey (int key_index, int reason, const char *cmt);
167     gpgme_error_t addDesignatedRevoker (const char *uid);
168     gpgme_error_t addPhotoid (const char *jpg_file);
169     gpgme_error_t enable (void);
170     gpgme_error_t disable (void);
171     gpgme_error_t setUseridPreferences (int uid_index, const char *new_prefs);
172     gpgme_error_t delUseridSignature (int uid_index, int sig_index);
173     gpgme_error_t setPreferredKeyserver (int uid_index, const char *url);
174 twoaday 119 gpgme_error_t cleanKey (void);
175 twoaday 206 gpgme_error_t minimizeKey (void);
176 werner 37
177 twoaday 260 gpgme_error_t addCardKey (int type);
178    
179 werner 37 gpgme_error_t getUseridInfo (gpg_uid_info_t *r_uinf);
180    
181     gpgme_error_t getDesignatedRevoker (gpg_desig_rev_t *r_rev);
182     };
183    
184     BOOL keyedit_add_subkey (winpt_key_t k, HWND dlg, listview_ctrl_t lv);
185     BOOL keyedit_add_userid (winpt_key_t k, HWND dlg, listview_ctrl_t lv);
186     BOOL keyedit_add_revoker (winpt_key_t k, HWND dlg);
187     BOOL keyedit_add_photo (winpt_key_t k, HWND dlg );
188     BOOL keyedit_change_passwd (winpt_key_t k, HWND dlg);
189     BOOL keyedit_set_pref_keyserver (winpt_key_t k, HWND dlg);
190    
191     gpgme_error_t gpg_editkey (gpgme_ctx_t ctx, gpgme_key_t key, GpgKeyEdit *ek);
192     void gpg_uid_info_release (gpg_uid_info_t inf);
193     void gpg_desig_rev_release (gpg_desig_rev_t rev);
194    
195     #endif /*WPT_KEY_EDIT_H*/

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26