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
27enum /* Packet types */
28{
31 USER_ID_PACKET = 0x0d
32};
33
34enum /* 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
46enum /* Signature subpacket types */
47{
48 ISSUER_SUBPACKET = 0x10
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
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;
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];
109 struct {
110 uint8_t s[2+4096/8];
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
129
130/**
131 * Non blocking binary download
132 */
133typedef struct
134{
136
138 atomic_bool aborted;
142
143/**
144 * Non blocking update availability verification
145 */
146typedef 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 */
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 */
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 */
182int
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 */
190int
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 */
198int
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 */
205uint8_t *
207 const char *psz_text, signature_packet_t *p_sig );
208
209/*
210 * return a hash of a file
211 */
212uint8_t *
214 const char *psz_file, signature_packet_t *p_sig );
215
216/*
217 * return a hash of a public key
218 */
219uint8_t *
Definition: vlc_objects.h:91
Definition: update.h:52
uint8_t q[2+256/8]
Definition: update.h:62
uint8_t n[2+4096/8]
Definition: update.h:67
struct public_key_packet_t::@90::@92 rsa
uint8_t version
Definition: update.h:54
uint8_t timestamp[4]
Definition: update.h:55
uint8_t e[2+4096/8]
Definition: update.h:68
uint8_t algo
Definition: update.h:56
uint8_t y[2+3072/8]
Definition: update.h:64
union public_key_packet_t::@90 sig
uint8_t g[2+3072/8]
Definition: update.h:63
struct public_key_packet_t::@90::@91 dsa
uint8_t p[2+3072/8]
Definition: update.h:61
Definition: update.h:119
uint8_t * psz_username
Definition: update.h:121
uint8_t longid[8]
Definition: update.h:120
signature_packet_t sig
Definition: update.h:125
public_key_packet_t key
Definition: update.h:123
Definition: update.h:75
uint8_t timestamp[4]
Definition: update.h:97
uint8_t r[2+256/8]
Definition: update.h:106
uint8_t hash_verification[2]
Definition: update.h:82
uint8_t issuer_longid[8]
Definition: update.h:83
uint8_t version
Definition: update.h:76
struct signature_packet_t::@94::@97 dsa
struct signature_packet_t::@93::@95 v4
uint8_t s[2+256/8]
Definition: update.h:107
uint8_t * hashed_data
Definition: update.h:90
uint8_t * unhashed_data
Definition: update.h:92
uint8_t unhashed_data_len[2]
Definition: update.h:91
union signature_packet_t::@93 specific
struct signature_packet_t::@94::@98 rsa
union signature_packet_t::@94 algo_specific
uint8_t public_key_algo
Definition: update.h:79
uint8_t type
Definition: update.h:78
struct signature_packet_t::@93::@96 v3
uint8_t hashed_data_len[2]
Definition: update.h:89
uint8_t digest_algo
Definition: update.h:80
Non blocking update availability verification.
Definition: update.h:147
update_t * p_update
Definition: update.h:150
void * p_data
Definition: update.h:152
vlc_thread_t thread
Definition: update.h:148
Non blocking binary download.
Definition: update.h:134
char * psz_destdir
Definition: update.h:140
update_t * p_update
Definition: update.h:139
atomic_bool aborted
Definition: update.h:138
vlc_thread_t thread
Definition: update.h:137
Describes an update VLC release number.
Definition: vlc_update.h:41
char * psz_url
Download URL.
Definition: vlc_update.h:46
The update object.
Definition: update.h:159
struct update_release_t release
Release (version)
Definition: update.h:162
vlc_mutex_t lock
Definition: update.h:161
public_key_t * p_pkey
Definition: update.h:163
update_download_thread_t * p_download
Definition: update.h:164
update_check_thread_t * p_check
Definition: update.h:165
libvlc_int_t * p_libvlc
Definition: update.h:160
Mutex.
Definition: vlc_threads.h:195
VLC object common members.
Definition: vlc_objects.h:45
struct vlc_object_marker * obj
Definition: vlc_objects.h:49
Thread handle.
Definition: vlc_threads.h:160
@ GENERIC_KEY_SIGNATURE
Definition: update.h:40
@ BINARY_SIGNATURE
Definition: update.h:36
@ POSITIVE_KEY_SIGNATURE
Definition: update.h:43
@ PERSONA_KEY_SIGNATURE
Definition: update.h:41
@ CASUAL_KEY_SIGNATURE
Definition: update.h:42
@ TEXT_SIGNATURE
Definition: update.h:37
uint8_t * hash_from_text(const char *psz_text, signature_packet_t *p_sig)
Definition: update_crypto.c:791
@ USER_ID_PACKET
Definition: update.h:31
@ SIGNATURE_PACKET
Definition: update.h:29
@ PUBLIC_KEY_PACKET
Definition: update.h:30
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 * hash_from_file(const char *psz_file, signature_packet_t *p_sig)
Definition: update_crypto.c:826
@ ISSUER_SUBPACKET
Definition: update.h:48
int verify_signature(signature_packet_t *sign, public_key_packet_t *p_key, uint8_t *p_hash)
Definition: update_crypto.c:588
int download_signature(vlc_object_t *p_this, signature_packet_t *p_sig, const char *psz_url)
Definition: update_crypto.c:996
uint8_t * hash_from_public_key(public_key_t *p_pkey)
Definition: update_crypto.c:846
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 software update interface.