1 /*****************************************************************************
2 * vlc_update.h: VLC update and plugins download
3 *****************************************************************************
4 * Copyright © 2005-2007 the VideoLAN team
7 * Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
8 * Rafaël Carré <funman@videolanorg>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either release 2 of the License, or
13 * (at your option) any later release.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 #if !defined( __LIBVLC__ )
26 #error You are not libvlc or one of its plugins. You cannot include this file
37 * \defgroup update Update
42 /* Go reading the rfc 4880 ! NOW !! */
46 * When PGP-signing a file, we only sign a SHA-1 hash of this file
48 * As soon as SHA-1 is broken, this method is not secure anymore, because an
49 * attacker could generate a file with the same SHA-1 hash.
51 * Whenever this happens, we need to use another algorithm / type of key.
55 enum /* Public key algorithms */
57 /* we will only use DSA public keys */
58 PUBLIC_KEY_ALGO_DSA = 0x11
61 enum /* Digest algorithms */
63 /* and DSA use SHA-1 digest */
64 DIGEST_ALGO_SHA1 = 0x02
67 enum /* Packet types */
69 SIGNATURE_PACKET = 0x02,
70 PUBLIC_KEY_PACKET = 0x06,
74 enum /* Signature types */
76 BINARY_SIGNATURE = 0x00,
77 TEXT_SIGNATURE = 0x01,
79 /* Public keys signatures */
80 GENERIC_KEY_SIGNATURE = 0x10, /* No assumption of verification */
81 PERSONA_KEY_SIGNATURE = 0x11, /* No verification has been made */
82 CASUAL_KEY_SIGNATURE = 0x12, /* Some casual verification */
83 POSITIVE_KEY_SIGNATURE = 0x13 /* Substantial verification */
86 enum /* Signature subpacket types */
88 ISSUER_SUBPACKET = 0x10
91 struct public_key_packet_t
92 { /* a public key packet (DSA/SHA-1) is 418 bytes */
94 uint8_t version; /* we use only version 4 */
95 uint8_t timestamp[4]; /* creation time of the key */
96 uint8_t algo; /* we only use DSA */
97 /* the multi precision integers, with their 2 bytes length header */
104 /* used for public key and file signatures */
105 struct signature_packet_t
107 uint8_t version; /* 3 or 4 */
110 uint8_t public_key_algo; /* DSA only */
111 uint8_t digest_algo; /* SHA-1 only */
113 uint8_t hash_verification[2];
114 uint8_t issuer_longid[8];
116 union /* version specific data */
120 uint8_t hashed_data_len[2]; /* scalar number */
121 uint8_t *hashed_data; /* hashed_data_len bytes */
122 uint8_t unhashed_data_len[2]; /* scalar number */
123 uint8_t *unhashed_data; /* unhashed_data_len bytes */
127 uint8_t hashed_data_len; /* MUST be 5 */
128 uint8_t timestamp[4]; /* 4 bytes scalar number */
132 /* The part below is made of consecutive MPIs, their number and size being
133 * public-key-algorithm dependant.
135 * Since we use DSA signatures only, there is 2 integers, r & s, made of:
136 * 2 bytes for the integer length (scalar number)
137 * 160 bits (20 bytes) for the integer itself
139 * Note: the integers may be less than 160 significant bits
145 typedef struct public_key_packet_t public_key_packet_t;
146 typedef struct signature_packet_t signature_packet_t;
150 uint8_t longid[8]; /* Long id */
151 uint8_t *psz_username; /* USER ID */
153 public_key_packet_t key; /* Public key packet */
155 signature_packet_t sig; /* Signature packet, by the embedded key */
158 typedef struct public_key_t public_key_t;
161 * Describes an update VLC release number
163 struct update_release_t
165 int i_major; ///< Version major
166 int i_minor; ///< Version minor
167 int i_revision; ///< Version revision
168 unsigned char extra;///< Version extra
169 char* psz_url; ///< Download URL
170 char* psz_desc; ///< Release description
174 * The update object. Stores (and caches) all information relative to updates
178 libvlc_int_t *p_libvlc;
180 struct update_release_t release; ///< Release (version)
181 public_key_t *p_pkey;
184 #define update_New( a ) __update_New( VLC_OBJECT( a ) )
186 VLC_EXPORT( update_t *, __update_New, ( vlc_object_t * ) );
187 VLC_EXPORT( void, update_Delete, ( update_t * ) );
188 VLC_EXPORT( void, update_Check, ( update_t *, void (*callback)( void*, bool ), void * ) );
189 VLC_EXPORT( bool, update_NeedUpgrade, ( update_t * ) );
190 VLC_EXPORT( void, update_Download, ( update_t *, char* ) );