X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=include%2Fvlc_update.h;h=1ca9ae4190f74cec28661659a1edc4b16ef9e395;hb=eb6f43ef97be034b2ea3b71b56263cf9f487b6ce;hp=f2588ebdfa33a8b1f907614bb89635f117aeae83;hpb=89e093a7a1f0b47b17bd6b1236567efb0de142d5;p=vlc diff --git a/include/vlc_update.h b/include/vlc_update.h index f2588ebdfa..1ca9ae4190 100644 --- a/include/vlc_update.h +++ b/include/vlc_update.h @@ -1,10 +1,11 @@ /***************************************************************************** * vlc_update.h: VLC update and plugins download ***************************************************************************** - * Copyright (C) 2005 the VideoLAN team + * Copyright © 2005-2007 the VideoLAN team * $Id$ * * Authors: Antoine Cellerier + * Rafaël Carré * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,89 +26,153 @@ #error You are not libvlc or one of its plugins. You cannot include this file #endif +#ifdef UPDATE_CHECK + #ifndef _VLC_UPDATE_H #define _VLC_UPDATE_H #include +#include /* key & signature downloading */ +#include /* b64 decoding */ +#include /* utf8_fopen() */ +#include /* cryptography and digest algorithms */ + /** * \defgroup update Update * * @{ */ -#define UPDATE_FILE_TYPE_ALL (~0) -#define UPDATE_FILE_TYPE_NONE 0 +enum /* Public key algorithms */ +{ + /* we will only use DSA public keys */ + PUBLIC_KEY_ALGO_DSA = 0x11 +}; + +enum /* Digest algorithms */ +{ + /* and DSA use SHA-1 digest */ + DIGEST_ALGO_SHA1 = 0x02 +}; + +enum /* Packet types */ +{ + SIGNATURE_PACKET = 0x02, + PUBLIC_KEY_PACKET = 0x06, + USER_ID_PACKET = 0x0d +}; + +enum /* Signature types */ +{ + BINARY_SIGNATURE = 0x00, + TEXT_SIGNATURE = 0x01, + + /* Public keys signatures */ + GENERIC_KEY_SIGNATURE = 0x10, /* No assumption of verification */ + PERSONA_KEY_SIGNATURE = 0x11, /* No verification has been made */ + CASUAL_KEY_SIGNATURE = 0x12, /* Some casual verification */ + POSITIVE_KEY_SIGNATURE = 0x13 /* Substantial verification */ +}; -#define UPDATE_FILE_TYPE_UNDEF 1 -#define UPDATE_FILE_TYPE_INFO 2 -#define UPDATE_FILE_TYPE_SOURCE 4 -#define UPDATE_FILE_TYPE_BINARY 8 -#define UPDATE_FILE_TYPE_PLUGIN 16 -#define UPDATE_RELEASE_STATUS_ALL (~0) -#define UPDATE_RELEASE_STATUS_NONE 0 +enum /* Signature subpacket types */ +{ + ISSUER_SUBPACKET = 0x10 +}; -#define UPDATE_RELEASE_STATUS_OLDER 1 -#define UPDATE_RELEASE_STATUS_EQUAL 2 -#define UPDATE_RELEASE_STATUS_NEWER 4 -#define UPDATE_RELEASE_TYPE_STABLE 1 -#define UPDATE_RELEASE_TYPE_TESTING 2 -#define UPDATE_RELEASE_TYPE_UNSTABLE 4 -#define UPDATE_FAIL 0 -#define UPDATE_SUCCESS 1 -#define UPDATE_NEXT 0 -#define UPDATE_PREV 2 -#define UPDATE_MIRROR 4 -#define UPDATE_RELEASE 8 -#define UPDATE_FILE 16 -#define UPDATE_RESET 32 +struct public_key_packet_t +{ /* a public key packet (DSA/SHA-1) is 418 bytes */ -/** - * Describes an update file - */ -struct update_file_t + uint8_t version; /* we use only version 4 */ + uint8_t timestamp[4]; /* creation time of the key */ + uint8_t algo; /* we only use DSA */ + /* the multi precision integers, with their 2 bytes length header */ + uint8_t p[2+128]; + uint8_t q[2+20]; + uint8_t g[2+128]; + uint8_t y[2+128]; +}; + +/* used for public key signatures */ +struct signature_packet_v4_t +{ /* hashed_data or unhashed_data can be empty, so the signature packet is + * theorically at least 54 bytes long, but always more than that. */ + + uint8_t version; + uint8_t type; + uint8_t public_key_algo; + uint8_t digest_algo; + uint8_t hashed_data_len[2]; + uint8_t *hashed_data; + uint8_t unhashed_data_len[2]; + uint8_t *unhashed_data; + uint8_t hash_verification[2]; + + /* The part below is made of consecutive MPIs, their number and size being + * public-key-algorithm dependant. + * But since we use DSA signatures only, we fix it. */ + uint8_t r[2+20]; + uint8_t s[2+20]; +}; + +/* Used for binary document signatures (to be compatible with older software) + * DSA/SHA-1 is always 65 bytes */ +struct signature_packet_v3_t { - int i_type; ///< File type - char* psz_md5; ///< MD5 hash - long int l_size; ///< File size in bytes - char* psz_url; ///< Relative (to a mirror) or absolute url - char* psz_description; ///< Plain text description + uint8_t header[2]; + uint8_t version; /* 3 */ + uint8_t hashed_data_len; /* MUST be 5 */ + uint8_t type; + uint8_t timestamp[4]; /* 4 bytes scalar number */ + uint8_t issuer_longid[8]; /* The key which signed the document */ + uint8_t public_key_algo; /* we only know about DSA */ + uint8_t digest_algo; /* and his little sister SHA-1 */ + uint8_t hash_verification[2];/* the 2 1st bytes of the SHA-1 hash */ + + /* The part below is made of consecutive MPIs, their number and size being + * public-key-algorithm dependant. + * But since we use DSA signatures only, we fix it. */ + uint8_t r[2+20]; + uint8_t s[2+20]; }; -/** - * Describes an update VLC release number - */ -struct update_release_t +typedef struct public_key_packet_t public_key_packet_t; +typedef struct signature_packet_v4_t signature_packet_v4_t; +typedef struct signature_packet_v3_t signature_packet_v3_t; + +struct public_key_t { - char* psz_major; ///< Version major string - char* psz_minor; ///< Version minor string - char* psz_revision; ///< Version revision string - char* psz_extra; ///< Version extra string + uint8_t longid[8]; /* Long id */ + uint8_t *psz_username; /* USER ID */ - char* psz_svn_revision; ///< SVN revision + public_key_packet_t key; /* Public key packet */ - int i_type; ///< Release type + signature_packet_v4_t sig; /* Signature packet, by the embedded key */ +}; - int i_status; ///< Release status compared to current VLC version +typedef struct public_key_t public_key_t; - struct update_file_t* p_files; ///< Files list - int i_files; ///< Number of files in the files list +enum +{ + UpdateReleaseStatusOlder, + UpdateReleaseStatusEqual, + UpdateReleaseStatusNewer }; /** - * Describes a mirror + * Describes an update VLC release number */ -struct update_mirror_t +struct update_release_t { - char *psz_name; ///< Mirror name - char *psz_location; ///< Mirror geographical location - char *psz_type; ///< Mirror type (FTP, HTTP, ...) - - char *psz_base_url; ///< Mirror base url - + int i_major; ///< Version major + int i_minor; ///< Version minor + int i_revision; ///< Version revision + unsigned char extra;///< Version extra + char* psz_url; ///< Download URL + char* psz_desc; ///< Release description }; /** @@ -116,63 +181,23 @@ struct update_mirror_t struct update_t { libvlc_int_t *p_libvlc; - vlc_mutex_t lock; - - struct update_release_t *p_releases; ///< Releases (version) list - int i_releases; ///< Number of releases - vlc_bool_t b_releases; ///< True if we have a releases list - - struct update_mirror_t *p_mirrors; ///< Mirrors list - int i_mirrors; ///< Number of mirrors - vlc_bool_t b_mirrors; ///< True if we have a mirrors list -}; - -/** - * The update iterator structure. Usefull to browse the update object seamlessly - */ -struct update_iterator_t -{ - update_t *p_u; ///< Pointer to VLC update object - - int i_r; ///< Position in the releases list - int i_f; ///< Position in the release's files list - int i_m; ///< Position in the mirrors list - - int i_t; ///< File type bitmask - int i_rs; ///< Release status bitmask - int i_rt; ///< Release type bitmask - - struct update_file_t file; ///< Local copy of the current file's information - struct - { - char *psz_version; ///< Version string - char *psz_svn_revision; ///< SVN revision - int i_status; ///< Status - int i_type; ///< Type - } release; ///< Local 'copy' of the current release's information - struct - { - char *psz_name; ///< Name - char *psz_location; ///< Geographical location - char *psz_type; ///< Type (HTTP, FTP, ...) - } mirror; ///< Local 'copy' of the current mirror's information + struct update_release_t release; ///< Release (version) + public_key_t *p_pkey; }; #define update_New( a ) __update_New( VLC_OBJECT( a ) ) VLC_EXPORT( update_t *, __update_New, ( vlc_object_t * ) ); -VLC_EXPORT( void, update_Delete, (update_t * ) ); -VLC_EXPORT( void, update_Check, ( update_t *, vlc_bool_t ) ); - -VLC_EXPORT( update_iterator_t *, update_iterator_New, ( update_t * ) ); -VLC_EXPORT( void, update_iterator_Delete, ( update_iterator_t * ) ); -VLC_EXPORT( unsigned int, update_iterator_Action, ( update_iterator_t *, int ) ); -VLC_EXPORT( unsigned int, update_iterator_ChooseMirrorAndFile, ( update_iterator_t *, int, int, int ) ); -VLC_EXPORT( void, update_download, ( update_iterator_t *, const char * ) ); +VLC_EXPORT( void, update_Delete, ( update_t * ) ); +VLC_EXPORT( void, update_Check, ( update_t *, void (*callback)( void*, vlc_bool_t ), void * ) ); +VLC_EXPORT( int, update_CompareReleaseToCurrent, ( update_t * ) ); +VLC_EXPORT( void, update_Download, ( update_t *, char* ) ); /** * @} */ #endif + +#endif