1 /*****************************************************************************
2 * update.h: VLC PGP update private API
3 *****************************************************************************
4 * Copyright © 2007-2008 VLC authors and VideoLAN
6 * Authors: Rafaël Carré <funman@videolanorg>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either release 2 of the License, or
11 * (at your option) any later release.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 #include <stdatomic.h>
25 #include <vlc_update.h>
27 enum /* Packet types */
29 SIGNATURE_PACKET
= 0x02,
30 PUBLIC_KEY_PACKET
= 0x06,
34 enum /* Signature types */
36 BINARY_SIGNATURE
= 0x00,
37 TEXT_SIGNATURE
= 0x01,
39 /* Public keys signatures */
40 GENERIC_KEY_SIGNATURE
= 0x10, /* No assumption of verification */
41 PERSONA_KEY_SIGNATURE
= 0x11, /* No verification has been made */
42 CASUAL_KEY_SIGNATURE
= 0x12, /* Some casual verification */
43 POSITIVE_KEY_SIGNATURE
= 0x13 /* Substantial verification */
46 enum /* Signature subpacket types */
48 ISSUER_SUBPACKET
= 0x10
51 struct public_key_packet_t
54 uint8_t version
; /* we use only version 4 */
55 uint8_t timestamp
[4]; /* creation time of the key */
56 uint8_t algo
; /* DSA or RSA */
58 /* the multi precision integers, with their 2 bytes length header */
73 /* used for public key and file signatures */
74 struct signature_packet_t
76 uint8_t version
; /* 3 or 4 */
79 uint8_t public_key_algo
; /* DSA or RSA */
82 uint8_t hash_verification
[2];
83 uint8_t issuer_longid
[8];
85 union /* version specific data */
89 uint8_t hashed_data_len
[2]; /* scalar number */
90 uint8_t *hashed_data
; /* hashed_data_len bytes */
91 uint8_t unhashed_data_len
[2]; /* scalar number */
92 uint8_t *unhashed_data
; /* unhashed_data_len bytes */
96 uint8_t hashed_data_len
; /* MUST be 5 */
97 uint8_t timestamp
[4]; /* 4 bytes scalar number */
101 /* The part below is made of consecutive MPIs, their number and size being
102 * public-key-algorithm dependent.
115 typedef struct public_key_packet_t public_key_packet_t
;
116 typedef struct signature_packet_t signature_packet_t
;
120 uint8_t longid
[8]; /* Long id */
121 uint8_t *psz_username
; /* USER ID */
123 public_key_packet_t key
; /* Public key packet */
125 signature_packet_t sig
; /* Signature packet, by the embedded key */
128 typedef struct public_key_t public_key_t
;
131 * Non blocking binary download
135 struct vlc_object_t obj
;
141 } update_download_thread_t
;
144 * Non blocking update availability verification
151 void (*pf_callback
)( void *, bool );
153 } update_check_thread_t
;
156 * The update object. Stores (and caches) all information relative to updates
160 libvlc_int_t
*p_libvlc
;
162 struct update_release_t release
; ///< Release (version)
163 public_key_t
*p_pkey
;
164 update_download_thread_t
*p_download
;
165 update_check_thread_t
*p_check
;
169 * download a public key (the last one) from videolan server, and parse it
173 vlc_object_t
*p_this
, const uint8_t *p_longid
,
174 const uint8_t *p_signature_issuer
);
177 * fill a public_key_t with public key data, including:
178 * * public key packet
179 * * signature packet issued by key which long id is p_sig_issuer
184 const uint8_t *p_key_data
, size_t i_key_len
, public_key_t
*p_key
,
185 const uint8_t *p_sig_issuer
);
188 * Verify an OpenPGP signature made on some hash, with some public key
191 verify_signature(signature_packet_t
*sign
, public_key_packet_t
*p_key
,
195 * Download the signature associated to a document or a binary file.
196 * We're given the file's url, we just append ".asc" to it and download
200 vlc_object_t
*p_this
, signature_packet_t
*p_sig
, const char *psz_url
);
203 * return a hash of a text
207 const char *psz_text
, signature_packet_t
*p_sig
);
210 * return a hash of a file
214 const char *psz_file
, signature_packet_t
*p_sig
);
217 * return a hash of a public key
220 hash_from_public_key( public_key_t
*p_pkey
);