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,
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 */
72 /* used for public key and file signatures */
73 struct signature_packet_t
75 uint8_t version
; /* 3 or 4 */
78 uint8_t public_key_algo
; /* DSA or RSA */
81 uint8_t hash_verification
[2];
82 uint8_t issuer_longid
[8];
84 union /* version specific data */
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 */
95 uint8_t hashed_data_len
; /* MUST be 5 */
96 uint8_t timestamp
[4]; /* 4 bytes scalar number */
100 /* The part below is made of consecutive MPIs, their number and size being
101 * public-key-algorithm dependent.
114 typedef struct public_key_packet_t public_key_packet_t
;
115 typedef struct signature_packet_t signature_packet_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
140 } update_download_thread_t
;
143 * Non blocking update availability verification
150 void (*pf_callback
)( void *, bool );
152 } update_check_thread_t
;
155 * The update object. Stores (and caches) all information relative to updates
159 libvlc_int_t
*p_libvlc
;
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
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
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
,
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
199 vlc_object_t
*p_this
, signature_packet_t
*p_sig
, const char *psz_url
);
202 * return a hash of a text
206 const char *psz_text
, signature_packet_t
*p_sig
);
209 * return a hash of a file
213 const char *psz_file
, signature_packet_t
*p_sig
);
216 * return a hash of a public key
219 hash_from_public_key( public_key_t
*p_pkey
);