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
36 #include <vlc_stream.h> /* key & signature downloading */
37 #include <vlc_strings.h> /* b64 decoding */
38 #include <vlc_charset.h> /* utf8_fopen() */
39 #include <gcrypt.h> /* cryptography and digest algorithms */
42 * \defgroup update Update
47 enum /* Public key algorithms */
49 /* we will only use DSA public keys */
50 PUBLIC_KEY_ALGO_DSA = 0x11
53 enum /* Digest algorithms */
55 /* and DSA use SHA-1 digest */
56 DIGEST_ALGO_SHA1 = 0x02
59 enum /* Packet types */
61 SIGNATURE_PACKET = 0x02,
62 PUBLIC_KEY_PACKET = 0x06,
66 enum /* Signature types */
68 BINARY_SIGNATURE = 0x00,
69 TEXT_SIGNATURE = 0x01,
71 /* Public keys signatures */
72 GENERIC_KEY_SIGNATURE = 0x10, /* No assumption of verification */
73 PERSONA_KEY_SIGNATURE = 0x11, /* No verification has been made */
74 CASUAL_KEY_SIGNATURE = 0x12, /* Some casual verification */
75 POSITIVE_KEY_SIGNATURE = 0x13 /* Substantial verification */
79 enum /* Signature subpacket types */
81 ISSUER_SUBPACKET = 0x10
86 struct public_key_packet_t
87 { /* a public key packet (DSA/SHA-1) is 418 bytes */
89 uint8_t version; /* we use only version 4 */
90 uint8_t timestamp[4]; /* creation time of the key */
91 uint8_t algo; /* we only use DSA */
92 /* the multi precision integers, with their 2 bytes length header */
99 /* used for public key signatures */
100 struct signature_packet_v4_t
101 { /* hashed_data or unhashed_data can be empty, so the signature packet is
102 * theorically at least 54 bytes long, but always more than that. */
106 uint8_t public_key_algo;
108 uint8_t hashed_data_len[2];
109 uint8_t *hashed_data;
110 uint8_t unhashed_data_len[2];
111 uint8_t *unhashed_data;
112 uint8_t hash_verification[2];
114 /* The part below is made of consecutive MPIs, their number and size being
115 * public-key-algorithm dependant.
116 * But since we use DSA signatures only, we fix it. */
121 /* Used for binary document signatures (to be compatible with older software)
122 * DSA/SHA-1 is always 65 bytes */
123 struct signature_packet_v3_t
126 uint8_t version; /* 3 */
127 uint8_t hashed_data_len; /* MUST be 5 */
129 uint8_t timestamp[4]; /* 4 bytes scalar number */
130 uint8_t issuer_longid[8]; /* The key which signed the document */
131 uint8_t public_key_algo; /* we only know about DSA */
132 uint8_t digest_algo; /* and his little sister SHA-1 */
133 uint8_t hash_verification[2];/* the 2 1st bytes of the SHA-1 hash */
135 /* The part below is made of consecutive MPIs, their number and size being
136 * public-key-algorithm dependant.
137 * But since we use DSA signatures only, we fix it. */
142 typedef struct public_key_packet_t public_key_packet_t;
143 typedef struct signature_packet_v4_t signature_packet_v4_t;
144 typedef struct signature_packet_v3_t signature_packet_v3_t;
148 uint8_t longid[8]; /* Long id */
149 uint8_t *psz_username; /* USER ID */
151 public_key_packet_t key; /* Public key packet */
153 signature_packet_v4_t sig; /* Signature packet, by the embedded key */
156 typedef struct public_key_t public_key_t;
160 UpdateReleaseStatusOlder,
161 UpdateReleaseStatusEqual,
162 UpdateReleaseStatusNewer
166 * Describes an update VLC release number
168 struct update_release_t
170 int i_major; ///< Version major
171 int i_minor; ///< Version minor
172 int i_revision; ///< Version revision
173 unsigned char extra;///< Version extra
174 char* psz_url; ///< Download URL
175 char* psz_desc; ///< Release description
179 * The update object. Stores (and caches) all information relative to updates
183 libvlc_int_t *p_libvlc;
185 struct update_release_t release; ///< Release (version)
186 public_key_t *p_pkey;
189 #define update_New( a ) __update_New( VLC_OBJECT( a ) )
191 VLC_EXPORT( update_t *, __update_New, ( vlc_object_t * ) );
192 VLC_EXPORT( void, update_Delete, ( update_t * ) );
193 VLC_EXPORT( void, update_Check, ( update_t *, void (*callback)( void*, vlc_bool_t ), void * ) );
194 VLC_EXPORT( int, update_CompareReleaseToCurrent, ( update_t * ) );
195 VLC_EXPORT( void, update_Download, ( update_t *, char* ) );