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
; /* we only use DSA */
56 /* the multi precision integers, with their 2 bytes length header */
63 /* used for public key and file signatures */
64 struct signature_packet_t
66 uint8_t version
; /* 3 or 4 */
69 uint8_t public_key_algo
; /* DSA only */
72 uint8_t hash_verification
[2];
73 uint8_t issuer_longid
[8];
75 union /* version specific data */
79 uint8_t hashed_data_len
[2]; /* scalar number */
80 uint8_t *hashed_data
; /* hashed_data_len bytes */
81 uint8_t unhashed_data_len
[2]; /* scalar number */
82 uint8_t *unhashed_data
; /* unhashed_data_len bytes */
86 uint8_t hashed_data_len
; /* MUST be 5 */
87 uint8_t timestamp
[4]; /* 4 bytes scalar number */
91 /* The part below is made of consecutive MPIs, their number and size being
92 * public-key-algorithm dependent.
94 * Since we use DSA signatures only, there is 2 integers, r & s.
95 * They range from 160 for 1k keys to 256 bits for 3k keys.
101 typedef struct public_key_packet_t public_key_packet_t
;
102 typedef struct signature_packet_t signature_packet_t
;
106 uint8_t longid
[8]; /* Long id */
107 uint8_t *psz_username
; /* USER ID */
109 public_key_packet_t key
; /* Public key packet */
111 signature_packet_t sig
; /* Signature packet, by the embedded key */
114 typedef struct public_key_t public_key_t
;
117 * Non blocking binary download
127 } update_download_thread_t
;
130 * Non blocking update availability verification
137 void (*pf_callback
)( void *, bool );
139 } update_check_thread_t
;
142 * The update object. Stores (and caches) all information relative to updates
146 libvlc_int_t
*p_libvlc
;
148 struct update_release_t release
; ///< Release (version)
149 public_key_t
*p_pkey
;
150 update_download_thread_t
*p_download
;
151 update_check_thread_t
*p_check
;
155 * download a public key (the last one) from videolan server, and parse it
159 vlc_object_t
*p_this
, const uint8_t *p_longid
,
160 const uint8_t *p_signature_issuer
);
163 * fill a public_key_t with public key data, including:
164 * * public key packet
165 * * signature packet issued by key which long id is p_sig_issuer
170 const uint8_t *p_key_data
, size_t i_key_len
, public_key_t
*p_key
,
171 const uint8_t *p_sig_issuer
);
174 * Verify an OpenPGP signature made on some hash, with some DSA public key
177 verify_signature(signature_packet_t
*sign
, public_key_packet_t
*p_key
,
181 * Download the signature associated to a document or a binary file.
182 * We're given the file's url, we just append ".asc" to it and download
186 vlc_object_t
*p_this
, signature_packet_t
*p_sig
, const char *psz_url
);
189 * return a hash of a text
193 const char *psz_text
, signature_packet_t
*p_sig
);
196 * return a hash of a file
200 const char *psz_file
, signature_packet_t
*p_sig
);
203 * return a hash of a public key
206 hash_from_public_key( public_key_t
*p_pkey
);