qml: introduce HorizontalResizehandle
[vlc.git] / src / misc / update.h
blob227870f0cee7c52cd79cdad198b84654951bd174
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 <stdatomic.h>
25 #include <vlc_update.h>
27 enum /* Packet types */
29 SIGNATURE_PACKET = 0x02,
30 PUBLIC_KEY_PACKET = 0x06,
31 USER_ID_PACKET = 0x0d
34 enum /* Signature types */
36 BINARY_SIGNATURE = 0x00,
37 TEXT_SIGNATURE = 0x01,
39 /* Public keys signatures */
40 GENERIC_KEY_SIGNATURE = 0x10, /* No assumption of verification */
41 PERSONA_KEY_SIGNATURE = 0x11, /* No verification has been made */
42 CASUAL_KEY_SIGNATURE = 0x12, /* Some casual verification */
43 POSITIVE_KEY_SIGNATURE = 0x13 /* Substantial verification */
46 enum /* Signature subpacket types */
48 ISSUER_SUBPACKET = 0x10
51 struct public_key_packet_t
54 uint8_t version; /* we use only version 4 */
55 uint8_t timestamp[4]; /* creation time of the key */
56 uint8_t algo; /* DSA or RSA */
58 /* the multi precision integers, with their 2 bytes length header */
59 union {
60 struct {
61 uint8_t p[2+3072/8];
62 uint8_t q[2+256/8];
63 uint8_t g[2+3072/8];
64 uint8_t y[2+3072/8];
65 } dsa ;
66 struct {
67 uint8_t n[2+4096/8];
68 uint8_t e[2+4096/8];
69 } rsa;
70 } sig;
73 /* used for public key and file signatures */
74 struct signature_packet_t
76 uint8_t version; /* 3 or 4 */
78 uint8_t type;
79 uint8_t public_key_algo; /* DSA or RSA */
80 uint8_t digest_algo;
82 uint8_t hash_verification[2];
83 uint8_t issuer_longid[8];
85 union /* version specific data */
87 struct
89 uint8_t hashed_data_len[2]; /* scalar number */
90 uint8_t *hashed_data; /* hashed_data_len bytes */
91 uint8_t unhashed_data_len[2]; /* scalar number */
92 uint8_t *unhashed_data; /* unhashed_data_len bytes */
93 } v4;
94 struct
96 uint8_t hashed_data_len; /* MUST be 5 */
97 uint8_t timestamp[4]; /* 4 bytes scalar number */
98 } v3;
99 } specific;
101 /* The part below is made of consecutive MPIs, their number and size being
102 * public-key-algorithm dependent.
104 union {
105 struct {
106 uint8_t r[2+256/8];
107 uint8_t s[2+256/8];
108 } dsa;
109 struct {
110 uint8_t s[2+4096/8];
111 } rsa;
112 } algo_specific;
115 typedef struct public_key_packet_t public_key_packet_t;
116 typedef struct signature_packet_t signature_packet_t;
118 struct public_key_t
120 uint8_t longid[8]; /* Long id */
121 uint8_t *psz_username; /* USER ID */
123 public_key_packet_t key; /* Public key packet */
125 signature_packet_t sig; /* Signature packet, by the embedded key */
128 typedef struct public_key_t public_key_t;
131 * Non blocking binary download
133 typedef struct
135 struct vlc_object_t obj;
137 vlc_thread_t thread;
138 atomic_bool aborted;
139 update_t *p_update;
140 char *psz_destdir;
141 } update_download_thread_t;
144 * Non blocking update availability verification
146 typedef struct
148 vlc_thread_t thread;
150 update_t *p_update;
151 void (*pf_callback)( void *, bool );
152 void *p_data;
153 } update_check_thread_t;
156 * The update object. Stores (and caches) all information relative to updates
158 struct update_t
160 libvlc_int_t *p_libvlc;
161 vlc_mutex_t lock;
162 struct update_release_t release; ///< Release (version)
163 public_key_t *p_pkey;
164 update_download_thread_t *p_download;
165 update_check_thread_t *p_check;
169 * download a public key (the last one) from videolan server, and parse it
171 public_key_t *
172 download_key(
173 vlc_object_t *p_this, const uint8_t *p_longid,
174 const uint8_t *p_signature_issuer );
177 * fill a public_key_t with public key data, including:
178 * * public key packet
179 * * signature packet issued by key which long id is p_sig_issuer
180 * * user id packet
183 parse_public_key(
184 const uint8_t *p_key_data, size_t i_key_len, public_key_t *p_key,
185 const uint8_t *p_sig_issuer );
188 * Verify an OpenPGP signature made on some hash, with some public key
191 verify_signature(signature_packet_t *sign, public_key_packet_t *p_key,
192 uint8_t *p_hash );
195 * Download the signature associated to a document or a binary file.
196 * We're given the file's url, we just append ".asc" to it and download
199 download_signature(
200 vlc_object_t *p_this, signature_packet_t *p_sig, const char *psz_url );
203 * return a hash of a text
205 uint8_t *
206 hash_from_text(
207 const char *psz_text, signature_packet_t *p_sig );
210 * return a hash of a file
212 uint8_t *
213 hash_from_file(
214 const char *psz_file, signature_packet_t *p_sig );
217 * return a hash of a public key
219 uint8_t *
220 hash_from_public_key( public_key_t *p_pkey );