i18n: missing . at the end of a sentence
[vlc.git] / src / misc / update.h
blobddb89b6eeb4d04070fae12d2185a150bdb7e6b13
1 /*****************************************************************************
2 * update.h: VLC PGP update private API
3 *****************************************************************************
4 * Copyright © 2007-2008 VLC authors and VideoLAN
6 * Authors: Rafaël Carré <funman@videolanorg>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either release 2 of the License, or
11 * (at your option) any later release.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 #include <vlc_update.h>
24 #include <vlc_atomic.h>
26 enum /* Packet types */
28 SIGNATURE_PACKET = 0x02,
29 PUBLIC_KEY_PACKET = 0x06,
30 USER_ID_PACKET = 0x0d
33 enum /* Signature types */
35 BINARY_SIGNATURE = 0x00,
36 TEXT_SIGNATURE = 0x01,
38 /* Public keys signatures */
39 GENERIC_KEY_SIGNATURE = 0x10, /* No assumption of verification */
40 PERSONA_KEY_SIGNATURE = 0x11, /* No verification has been made */
41 CASUAL_KEY_SIGNATURE = 0x12, /* Some casual verification */
42 POSITIVE_KEY_SIGNATURE = 0x13 /* Substantial verification */
45 enum /* Signature subpacket types */
47 ISSUER_SUBPACKET = 0x10
50 struct public_key_packet_t
53 uint8_t version; /* we use only version 4 */
54 uint8_t timestamp[4]; /* creation time of the key */
55 uint8_t algo; /* DSA or RSA */
57 /* the multi precision integers, with their 2 bytes length header */
58 union {
59 struct {
60 uint8_t p[2+3072/8];
61 uint8_t q[2+256/8];
62 uint8_t g[2+3072/8];
63 uint8_t y[2+3072/8];
64 } dsa ;
65 struct {
66 uint8_t n[2+4096/8];
67 uint8_t e[2+4096/8];
68 } rsa;
69 } sig;
72 /* used for public key and file signatures */
73 struct signature_packet_t
75 uint8_t version; /* 3 or 4 */
77 uint8_t type;
78 uint8_t public_key_algo; /* DSA or RSA */
79 uint8_t digest_algo;
81 uint8_t hash_verification[2];
82 uint8_t issuer_longid[8];
84 union /* version specific data */
86 struct
88 uint8_t hashed_data_len[2]; /* scalar number */
89 uint8_t *hashed_data; /* hashed_data_len bytes */
90 uint8_t unhashed_data_len[2]; /* scalar number */
91 uint8_t *unhashed_data; /* unhashed_data_len bytes */
92 } v4;
93 struct
95 uint8_t hashed_data_len; /* MUST be 5 */
96 uint8_t timestamp[4]; /* 4 bytes scalar number */
97 } v3;
98 } specific;
100 /* The part below is made of consecutive MPIs, their number and size being
101 * public-key-algorithm dependent.
103 union {
104 struct {
105 uint8_t r[2+256/8];
106 uint8_t s[2+256/8];
107 } dsa;
108 struct {
109 uint8_t s[2+4096/8];
110 } rsa;
111 } algo_specific;
114 typedef struct public_key_packet_t public_key_packet_t;
115 typedef struct signature_packet_t signature_packet_t;
117 struct public_key_t
119 uint8_t longid[8]; /* Long id */
120 uint8_t *psz_username; /* USER ID */
122 public_key_packet_t key; /* Public key packet */
124 signature_packet_t sig; /* Signature packet, by the embedded key */
127 typedef struct public_key_t public_key_t;
130 * Non blocking binary download
132 typedef struct
134 VLC_COMMON_MEMBERS
136 vlc_thread_t thread;
137 atomic_bool aborted;
138 update_t *p_update;
139 char *psz_destdir;
140 } update_download_thread_t;
143 * Non blocking update availability verification
145 typedef struct
147 vlc_thread_t thread;
149 update_t *p_update;
150 void (*pf_callback)( void *, bool );
151 void *p_data;
152 } update_check_thread_t;
155 * The update object. Stores (and caches) all information relative to updates
157 struct update_t
159 libvlc_int_t *p_libvlc;
160 vlc_mutex_t lock;
161 struct update_release_t release; ///< Release (version)
162 public_key_t *p_pkey;
163 update_download_thread_t *p_download;
164 update_check_thread_t *p_check;
168 * download a public key (the last one) from videolan server, and parse it
170 public_key_t *
171 download_key(
172 vlc_object_t *p_this, const uint8_t *p_longid,
173 const uint8_t *p_signature_issuer );
176 * fill a public_key_t with public key data, including:
177 * * public key packet
178 * * signature packet issued by key which long id is p_sig_issuer
179 * * user id packet
182 parse_public_key(
183 const uint8_t *p_key_data, size_t i_key_len, public_key_t *p_key,
184 const uint8_t *p_sig_issuer );
187 * Verify an OpenPGP signature made on some hash, with some public key
190 verify_signature(signature_packet_t *sign, public_key_packet_t *p_key,
191 uint8_t *p_hash );
194 * Download the signature associated to a document or a binary file.
195 * We're given the file's url, we just append ".asc" to it and download
198 download_signature(
199 vlc_object_t *p_this, signature_packet_t *p_sig, const char *psz_url );
202 * return a hash of a text
204 uint8_t *
205 hash_from_text(
206 const char *psz_text, signature_packet_t *p_sig );
209 * return a hash of a file
211 uint8_t *
212 hash_from_file(
213 const char *psz_file, signature_packet_t *p_sig );
216 * return a hash of a public key
218 uint8_t *
219 hash_from_public_key( public_key_t *p_pkey );