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
47 * The DSA key size requires that we use an algorithm which produce
48 * a 160 bits long hash
49 * An alternative is RIPEMD160 , which you can use by giving the option
50 * --digest-algo RIPEMD160 to GnuPG
52 * As soon as SHA-1 is broken, this method is not secure anymore, because an
53 * attacker could generate a file with the same SHA-1 hash.
55 * Whenever this happens, we need to use another algorithm / type of key.
59 enum /* Public key algorithms */
61 /* we will only use DSA public keys */
62 PUBLIC_KEY_ALGO_DSA = 0x11
65 enum /* Digest algorithms */
67 /* and DSA use SHA-1 digest */
68 DIGEST_ALGO_SHA1 = 0x02
71 enum /* Packet types */
73 SIGNATURE_PACKET = 0x02,
74 PUBLIC_KEY_PACKET = 0x06,
78 enum /* Signature types */
80 BINARY_SIGNATURE = 0x00,
81 TEXT_SIGNATURE = 0x01,
83 /* Public keys signatures */
84 GENERIC_KEY_SIGNATURE = 0x10, /* No assumption of verification */
85 PERSONA_KEY_SIGNATURE = 0x11, /* No verification has been made */
86 CASUAL_KEY_SIGNATURE = 0x12, /* Some casual verification */
87 POSITIVE_KEY_SIGNATURE = 0x13 /* Substantial verification */
90 enum /* Signature subpacket types */
92 ISSUER_SUBPACKET = 0x10
95 struct public_key_packet_t
96 { /* a public key packet (DSA/SHA-1) is 418 bytes */
98 uint8_t version; /* we use only version 4 */
99 uint8_t timestamp[4]; /* creation time of the key */
100 uint8_t algo; /* we only use DSA */
101 /* the multi precision integers, with their 2 bytes length header */
108 /* used for public key and file signatures */
109 struct signature_packet_t
111 uint8_t version; /* 3 or 4 */
114 uint8_t public_key_algo; /* DSA only */
115 uint8_t digest_algo; /* SHA-1 only */
117 uint8_t hash_verification[2];
118 uint8_t issuer_longid[8];
120 union /* version specific data */
124 uint8_t hashed_data_len[2]; /* scalar number */
125 uint8_t *hashed_data; /* hashed_data_len bytes */
126 uint8_t unhashed_data_len[2]; /* scalar number */
127 uint8_t *unhashed_data; /* unhashed_data_len bytes */
131 uint8_t hashed_data_len; /* MUST be 5 */
132 uint8_t timestamp[4]; /* 4 bytes scalar number */
136 /* The part below is made of consecutive MPIs, their number and size being
137 * public-key-algorithm dependant.
139 * Since we use DSA signatures only, there is 2 integers, r & s, made of:
140 * 2 bytes for the integer length (scalar number)
141 * 160 bits (20 bytes) for the integer itself
143 * Note: the integers may be less than 160 significant bits
149 typedef struct public_key_packet_t public_key_packet_t;
150 typedef struct signature_packet_t signature_packet_t;
154 uint8_t longid[8]; /* Long id */
155 uint8_t *psz_username; /* USER ID */
157 public_key_packet_t key; /* Public key packet */
159 signature_packet_t sig; /* Signature packet, by the embedded key */
162 typedef struct public_key_t public_key_t;
165 * Describes an update VLC release number
167 struct update_release_t
169 int i_major; ///< Version major
170 int i_minor; ///< Version minor
171 int i_revision; ///< Version revision
172 unsigned char extra;///< Version extra
173 char* psz_url; ///< Download URL
174 char* psz_desc; ///< Release description
178 * The update object. Stores (and caches) all information relative to updates
182 libvlc_int_t *p_libvlc;
184 struct update_release_t release; ///< Release (version)
185 public_key_t *p_pkey;
188 #define update_New( a ) __update_New( VLC_OBJECT( a ) )
190 VLC_EXPORT( update_t *, __update_New, ( vlc_object_t * ) );
191 VLC_EXPORT( void, update_Delete, ( update_t * ) );
192 VLC_EXPORT( void, update_Check, ( update_t *, void (*callback)( void*, bool ), void * ) );
193 VLC_EXPORT( bool, update_NeedUpgrade, ( update_t * ) );
194 VLC_EXPORT( void, update_Download, ( update_t *, char* ) );