VLC  4.0.0-dev
update.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * update.h: VLC PGP update private API
3  *****************************************************************************
4  * Copyright © 2007-2008 VLC authors and VideoLAN
5  *
6  * Authors: Rafaël Carré <funman@videolanorg>
7  *
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.
12  *
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.
17  *
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  *****************************************************************************/
22 
23 #include <stdatomic.h>
24 
25 #include <vlc_update.h>
26 
27 enum /* Packet types */
28 {
32 };
33 
34 enum /* Signature types */
35 {
38 
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 */
44 };
45 
46 enum /* Signature subpacket types */
47 {
49 };
50 
52 {
53 
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 */
57 
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;
71 };
72 
73 /* used for public key and file signatures */
75 {
76  uint8_t version; /* 3 or 4 */
77 
78  uint8_t type;
79  uint8_t public_key_algo; /* DSA or RSA */
80  uint8_t digest_algo;
81 
82  uint8_t hash_verification[2];
83  uint8_t issuer_longid[8];
84 
85  union /* version specific data */
86  {
87  struct
88  {
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
95  {
96  uint8_t hashed_data_len; /* MUST be 5 */
97  uint8_t timestamp[4]; /* 4 bytes scalar number */
98  } v3;
99  } specific;
100 
101 /* The part below is made of consecutive MPIs, their number and size being
102  * public-key-algorithm dependent.
103  */
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;
113 };
114 
117 
119 {
120  uint8_t longid[8]; /* Long id */
121  uint8_t *psz_username; /* USER ID */
122 
123  public_key_packet_t key; /* Public key packet */
124 
125  signature_packet_t sig; /* Signature packet, by the embedded key */
126 };
127 
128 typedef struct public_key_t public_key_t;
129 
130 /**
131  * Non blocking binary download
132  */
133 typedef struct
134 {
136 
138  atomic_bool aborted;
140  char *psz_destdir;
142 
143 /**
144  * Non blocking update availability verification
145  */
146 typedef struct
147 {
149 
151  void (*pf_callback)( void *, bool );
152  void *p_data;
154 
155 /**
156  * The update object. Stores (and caches) all information relative to updates
157  */
158 struct update_t
159 {
162  struct update_release_t release; ///< Release (version)
166 };
167 
168 /*
169  * download a public key (the last one) from videolan server, and parse it
170  */
171 public_key_t *
173  vlc_object_t *p_this, const uint8_t *p_longid,
174  const uint8_t *p_signature_issuer );
175 
176 /*
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
181  */
182 int
184  const uint8_t *p_key_data, size_t i_key_len, public_key_t *p_key,
185  const uint8_t *p_sig_issuer );
186 
187 /*
188  * Verify an OpenPGP signature made on some hash, with some public key
189  */
190 int
192  uint8_t *p_hash );
193 
194 /*
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
197  */
198 int
200  vlc_object_t *p_this, signature_packet_t *p_sig, const char *psz_url );
201 
202 /*
203  * return a hash of a text
204  */
205 uint8_t *
207  const char *psz_text, signature_packet_t *p_sig );
208 
209 /*
210  * return a hash of a file
211  */
212 uint8_t *
214  const char *psz_file, signature_packet_t *p_sig );
215 
216 /*
217  * return a hash of a public key
218  */
219 uint8_t *
Definition: update.h:37
uint8_t q[2+256/8]
Definition: update.h:62
Describes an update VLC release number.
Definition: vlc_update.h:40
Definition: update.h:51
uint8_t timestamp[4]
Definition: update.h:55
Definition: vlc_objects.h:115
uint8_t p[2+3072/8]
Definition: update.h:61
Definition: update.h:31
Definition: update.h:42
uint8_t * psz_username
Definition: update.h:121
update_download_thread_t * p_download
Definition: update.h:164
Definition: update.h:74
uint8_t e[2+4096/8]
Definition: update.h:68
public_key_t * p_pkey
Definition: update.h:163
vlc_thread_t thread
Definition: update.h:137
The update object.
Definition: update.h:158
int verify_signature(signature_packet_t *sign, public_key_packet_t *p_key, uint8_t *p_hash)
Definition: update_crypto.c:588
struct vlc_object_marker * obj
Definition: vlc_objects.h:48
uint8_t algo
Definition: update.h:56
Non blocking binary download.
Definition: update.h:133
Thread handle.
Definition: vlc_threads.h:208
Definition: update.h:36
vlc_thread_t thread
Definition: update.h:148
Definition: update.h:30
Mutex.
Definition: vlc_threads.h:266
Definition: update.h:29
uint8_t version
Definition: update.h:54
char * psz_url
Download URL.
Definition: vlc_update.h:46
int parse_public_key(const uint8_t *p_key_data, size_t i_key_len, public_key_t *p_key, const uint8_t *p_sig_issuer)
Definition: update_crypto.c:606
uint8_t type
Definition: update.h:78
uint8_t y[2+3072/8]
Definition: update.h:64
uint8_t * hashed_data
Definition: update.h:90
Definition: update.h:41
void * p_data
Definition: update.h:152
signature_packet_t sig
Definition: update.h:125
uint8_t public_key_algo
Definition: update.h:79
public_key_packet_t key
Definition: update.h:123
uint8_t version
Definition: update.h:76
union public_key_packet_t::@85 sig
Definition: update.h:118
struct public_key_packet_t::@85::@86 dsa
Definition: update.h:40
struct public_key_packet_t::@85::@87 rsa
uint8_t * hash_from_text(const char *psz_text, signature_packet_t *p_sig)
Definition: update_crypto.c:791
update_t * p_update
Definition: update.h:150
Non blocking update availability verification.
Definition: update.h:146
uint8_t n[2+4096/8]
Definition: update.h:67
libvlc_int_t * p_libvlc
Definition: update.h:160
uint8_t * hash_from_file(const char *psz_file, signature_packet_t *p_sig)
Definition: update_crypto.c:826
Definition: update.h:48
Definition: update.h:43
uint8_t g[2+3072/8]
Definition: update.h:63
uint8_t * hash_from_public_key(public_key_t *p_pkey)
Definition: update_crypto.c:846
int download_signature(vlc_object_t *p_this, signature_packet_t *p_sig, const char *psz_url)
Definition: update_crypto.c:996
VLC software update interface.
VLC object common members.
Definition: vlc_objects.h:43
uint8_t * unhashed_data
Definition: update.h:92
uint8_t digest_algo
Definition: update.h:80
public_key_t * download_key(vlc_object_t *p_this, const uint8_t *p_longid, const uint8_t *p_signature_issuer)
Definition: update_crypto.c:931
vlc_mutex_t lock
Definition: update.h:161
char * psz_destdir
Definition: update.h:140
update_check_thread_t * p_check
Definition: update.h:165
update_t * p_update
Definition: update.h:139
atomic_bool aborted
Definition: update.h:138