]> git.sesse.net Git - vlc/commitdiff
Privatise some structs and enumerations of PGP update
authorRafaël Carré <funman@videolan.org>
Tue, 27 May 2008 10:33:47 +0000 (12:33 +0200)
committerRafaël Carré <funman@videolan.org>
Tue, 27 May 2008 23:20:52 +0000 (01:20 +0200)
Export update_GetRelease() to the plugins
Modify qt4 & wx GUIs to reflect this change

extras/buildsystem/cmake/CMakeLists/src_CMakeLists.txt
include/vlc_update.h
modules/gui/qt4/dialogs/help.cpp
modules/gui/wxwidgets/dialogs/updatevlc.cpp
src/Makefile.am
src/misc/update.c
src/misc/update.h [new file with mode: 0644]

index 3e03c1efc224e183db70ec896f5f3373200a61f4..8315c0ba930786883c553a3d417afada0fc1e372 100644 (file)
@@ -118,6 +118,7 @@ set( SOURCES_libvlccore_common
     misc/variables.h
     misc/variables.c
     misc/error.c
+    misc/update.h
     misc/update.c
     ${CMAKE_BINARY_DIR}/src/misc/revision.c
     input/vlm.c
index a32c474e62baa393e3eb90d9f1c3b3221515e5ee..b9dbda8c26a58666b23679531463edf45efb5e1d 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * vlc_update.h: VLC update and plugins download
+ * vlc_update.h: VLC update download
  *****************************************************************************
  * Copyright © 2005-2007 the VideoLAN team
  * $Id$
  * @{
  */
 
-/* Go reading the rfc 4880 ! NOW !! */
-
-/*
- * XXX
- *  When PGP-signing a file, we only sign a SHA-1 hash of this file
- *  The DSA key size requires that we use an algorithm which produce
- *  a 160 bits long hash
- *  An alternative is RIPEMD160 , which you can use by giving the option
- *      --digest-algo RIPEMD160 to GnuPG
- *
- *  As soon as SHA-1 is broken, this method is not secure anymore, because an
- *  attacker could generate a file with the same SHA-1 hash.
- *
- *  Whenever this happens, we need to use another algorithm / type of key.
- * XXX
- */
-
-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 */
-};
-
-enum    /* Signature subpacket types */
-{
-    ISSUER_SUBPACKET    = 0x10
-};
-
-struct public_key_packet_t
-{ /* a public key packet (DSA/SHA-1) is 418 bytes */
-
-    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 and file signatures */
-struct signature_packet_t
-{
-    uint8_t version; /* 3 or 4 */
-
-    uint8_t type;
-    uint8_t public_key_algo;    /* DSA only */
-    uint8_t digest_algo;        /* SHA-1 only */
-
-    uint8_t hash_verification[2];
-    uint8_t issuer_longid[8];
-
-    union   /* version specific data */
-    {
-        struct
-        {
-            uint8_t hashed_data_len[2];     /* scalar number */
-            uint8_t *hashed_data;           /* hashed_data_len bytes */
-            uint8_t unhashed_data_len[2];   /* scalar number */
-            uint8_t *unhashed_data;         /* unhashed_data_len bytes */
-        } v4;
-        struct
-        {
-            uint8_t hashed_data_len;    /* MUST be 5 */
-            uint8_t timestamp[4];       /* 4 bytes scalar number */
-        } v3;
-    } specific;
-
-    /* The part below is made of consecutive MPIs, their number and size being
-     * public-key-algorithm dependant.
-     *
-     * Since we use DSA signatures only, there is 2 integers, r & s, made of:
-     *      2 bytes for the integer length (scalar number)
-     *      160 bits (20 bytes) for the integer itself
-     *
-     * Note: the integers may be less than 160 significant bits
-     */
-    uint8_t r[2+20];
-    uint8_t s[2+20];
-};
-
-typedef struct public_key_packet_t public_key_packet_t;
-typedef struct signature_packet_t signature_packet_t;
-
-struct public_key_t
-{
-    uint8_t longid[8];       /* Long id */
-    uint8_t *psz_username;    /* USER ID */
-
-    public_key_packet_t key;       /* Public key packet */
-
-    signature_packet_t sig;     /* Signature packet, by the embedded key */
-};
-
-typedef struct public_key_t public_key_t;
-
 /**
  * Describes an update VLC release number
  */
@@ -174,16 +52,7 @@ struct update_release_t
     char* psz_desc;     ///< Release description
 };
 
-/**
- * The update object. Stores (and caches) all information relative to updates
- */
-struct update_t
-{
-    libvlc_int_t *p_libvlc;
-    vlc_mutex_t lock;
-    struct update_release_t release;    ///< Release (version)
-    public_key_t *p_pkey;
-};
+typedef struct update_release_t update_release_t;
 
 #define update_New( a ) __update_New( VLC_OBJECT( a ) )
 
@@ -192,6 +61,7 @@ VLC_EXPORT( void, update_Delete, ( update_t * ) );
 VLC_EXPORT( void, update_Check, ( update_t *, void (*callback)( void*, bool ), void * ) );
 VLC_EXPORT( bool, update_NeedUpgrade, ( update_t * ) );
 VLC_EXPORT( void, update_Download, ( update_t *, char* ) );
+VLC_EXPORT( update_release_t*, update_GetRelease, ( update_t * ) );
 
 /**
  * @}
index f2422db3f65c1b11b3f97776f6c8592a6d85fe5a..256988f4242650f1df84cd355fb78a4243a82d37 100644 (file)
@@ -286,10 +286,12 @@ void UpdateDialog::updateNotify( bool b_result )
     {
         if( update_NeedUpgrade( p_update ) )
         {
+            update_release_t *p_release = update_GetRelease( p_update );
+            assert( p_release );
             b_checked = true;
             updateButton->setText( "Download" );
             updateLabel->setText( qtr( "There is a new version of VLC :\n" )
-                                + qfu( p_update->release.psz_desc )  );
+                                + qfu( p_release->psz_desc )  );
         }
         else
             updateLabel->setText( qtr( "You have the latest version of VLC" ) );
index b470d10cb3f8d30ad74d65a35f43157448b2b75f..8f4fd2249c155c0eb9323fc36d079f7167819cfc 100644 (file)
@@ -113,9 +113,13 @@ void UpdateVLC::OnCheckForUpdate( wxCommandEvent& event )
                       i_image );*/
 
     if( update_NeedUpgrade( p_update ) )
-        main_sizer->Add( new wxStaticText( this, -1, wxU( p_update->release.psz_desc )
+    {
+        update_release_t *p_release = update_GetRelease( p_update );
+        assert( p_release );
+        main_sizer->Add( new wxStaticText( this, -1, wxU( p_release->psz_desc )
                          + wxU( "\nYou can download the latest version of VLC at the adress :\n" )
-                         + wxU( p_update->release.psz_url ) ) );
+                         + wxU( p_release->psz_url ) ) );
+    }
     else
         main_sizer->Add( new wxStaticText( this, -1,
                          wxU( _( "\nYou have the latest version of VLC\n" ) ) ) );
index 58604c8ee746141729a486390fa9e7eac803b20e..f3a6aafa5bbc829ba289bbf83c68ed2e881ea5ae 100644 (file)
@@ -358,6 +358,7 @@ SOURCES_libvlc_common = \
        misc/variables.h \
        misc/variables.c \
        misc/error.c \
+       misc/variables.h \
        misc/update.c \
        misc/xml.c \
        misc/devices.c \
index dbbf3685e956699a997005088a94a51350bb958d..b2db1f6d89739506a906e6080893d117479d1019 100644 (file)
@@ -52,6 +52,7 @@
 #include <gcrypt.h>
 #include <vlc_gcrypt.h>
 
+#include "update.h"
 
 /*****************************************************************************
  * Misc defines
@@ -1638,6 +1639,12 @@ end:
 
     vlc_object_release( p_udt );
 }
+
+update_release_t *update_GetRelease( update_t *p_update )
+{
+    return &p_update->release;
+}
+
 #else
 update_t *__update_New( vlc_object_t *p_this )
 {
@@ -1666,4 +1673,10 @@ void update_Download( update_t *p_update, char *psz_destdir )
 {
     (void)p_update; (void)psz_destdir;
 }
+
+update_release_t *update_GetRelease( update_t *p_update )
+{
+    (void)p_update;
+    return NULL;
+}
 #endif
diff --git a/src/misc/update.h b/src/misc/update.h
new file mode 100644 (file)
index 0000000..ba37402
--- /dev/null
@@ -0,0 +1,155 @@
+/*****************************************************************************
+ * update.h: VLC PGP update private API
+ *****************************************************************************
+ * Copyright © 2007-2008 the VideoLAN team
+ *
+ * Authors: Rafaël Carré <funman@videolanorg>
+ *
+ * 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
+ * the Free Software Foundation; either release 2 of the License, or
+ * (at your option) any later release.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/* Go reading the rfc 4880 ! NOW !! */
+
+/*
+ * XXX
+ *  When PGP-signing a file, we only sign a SHA-1 hash of this file
+ *  The DSA key size requires that we use an algorithm which produce
+ *  a 160 bits long hash
+ *  An alternative is RIPEMD160 , which you can use by giving the option
+ *      --digest-algo RIPEMD160 to GnuPG
+ *
+ *  As soon as SHA-1 is broken, this method is not secure anymore, because an
+ *  attacker could generate a file with the same SHA-1 hash.
+ *
+ *  Whenever this happens, we need to use another algorithm / type of key.
+ * XXX
+ */
+
+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 */
+};
+
+enum    /* Signature subpacket types */
+{
+    ISSUER_SUBPACKET    = 0x10
+};
+
+struct public_key_packet_t
+{ /* a public key packet (DSA/SHA-1) is 418 bytes */
+
+    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 and file signatures */
+struct signature_packet_t
+{
+    uint8_t version; /* 3 or 4 */
+
+    uint8_t type;
+    uint8_t public_key_algo;    /* DSA only */
+    uint8_t digest_algo;        /* SHA-1 only */
+
+    uint8_t hash_verification[2];
+    uint8_t issuer_longid[8];
+
+    union   /* version specific data */
+    {
+        struct
+        {
+            uint8_t hashed_data_len[2];     /* scalar number */
+            uint8_t *hashed_data;           /* hashed_data_len bytes */
+            uint8_t unhashed_data_len[2];   /* scalar number */
+            uint8_t *unhashed_data;         /* unhashed_data_len bytes */
+        } v4;
+        struct
+        {
+            uint8_t hashed_data_len;    /* MUST be 5 */
+            uint8_t timestamp[4];       /* 4 bytes scalar number */
+        } v3;
+    } specific;
+
+/* The part below is made of consecutive MPIs, their number and size being
+ * public-key-algorithm dependant.
+ *
+ * Since we use DSA signatures only, there is 2 integers, r & s, made of:
+ *      2 bytes for the integer length (scalar number)
+ *      160 bits (20 bytes) for the integer itself
+ *
+ * Note: the integers may be less than 160 significant bits
+ */
+    uint8_t r[2+20];
+    uint8_t s[2+20];
+};
+
+typedef struct public_key_packet_t public_key_packet_t;
+typedef struct signature_packet_t signature_packet_t;
+
+struct public_key_t
+{
+    uint8_t longid[8];       /* Long id */
+    uint8_t *psz_username;    /* USER ID */
+
+    public_key_packet_t key;       /* Public key packet */
+
+    signature_packet_t sig;     /* Signature packet, by the embedded key */
+};
+
+typedef struct public_key_t public_key_t;
+
+/**
+ * The update object. Stores (and caches) all information relative to updates
+ */
+struct update_t
+{
+    libvlc_int_t *p_libvlc;
+    vlc_mutex_t lock;
+    struct update_release_t release;    ///< Release (version)
+    public_key_t *p_pkey;
+};
+