@@ -45,7 +45,6 @@ static FILE_FORMAT_CTX *cab_ctx_new(GLOBAL_OPTIONS *options, BIO *hash, BIO *out
4545static ASN1_OBJECT * cab_obsolete_link_get (u_char * * p , int * plen , FILE_FORMAT_CTX * ctx );
4646static PKCS7 * cab_pkcs7_contents_get (FILE_FORMAT_CTX * ctx , BIO * hash , const EVP_MD * md );
4747static int cab_hash_length_get (FILE_FORMAT_CTX * ctx );
48- static int cab_check_file (FILE_FORMAT_CTX * ctx , int detached );
4948static u_char * cab_digest_calc (FILE_FORMAT_CTX * ctx , const EVP_MD * md );
5049static int cab_verify_digests (FILE_FORMAT_CTX * ctx , PKCS7 * p7 );
5150static PKCS7 * cab_pkcs7_extract (FILE_FORMAT_CTX * ctx );
@@ -57,13 +56,13 @@ static int cab_append_pkcs7(FILE_FORMAT_CTX *ctx, BIO *outdata, PKCS7 *p7);
5756static void cab_update_data_size (FILE_FORMAT_CTX * ctx , BIO * outdata , PKCS7 * p7 );
5857static BIO * cab_bio_free (BIO * hash , BIO * outdata );
5958static void cab_ctx_cleanup (FILE_FORMAT_CTX * ctx , BIO * hash , BIO * outdata );
59+ static int cab_is_detaching_supported (void );
6060
6161FILE_FORMAT file_format_cab = {
6262 .ctx_new = cab_ctx_new ,
6363 .data_blob_get = cab_obsolete_link_get ,
6464 .pkcs7_contents_get = cab_pkcs7_contents_get ,
6565 .hash_length_get = cab_hash_length_get ,
66- .check_file = cab_check_file ,
6766 .digest_calc = cab_digest_calc ,
6867 .verify_digests = cab_verify_digests ,
6968 .pkcs7_extract = cab_pkcs7_extract ,
@@ -74,7 +73,8 @@ FILE_FORMAT file_format_cab = {
7473 .append_pkcs7 = cab_append_pkcs7 ,
7574 .update_data_size = cab_update_data_size ,
7675 .bio_free = cab_bio_free ,
77- .ctx_cleanup = cab_ctx_cleanup
76+ .ctx_cleanup = cab_ctx_cleanup ,
77+ .is_detaching_supported = cab_is_detaching_supported
7878};
7979
8080/* Prototypes */
@@ -83,6 +83,7 @@ static int cab_add_jp_attribute(PKCS7 *p7, int jp);
8383static size_t cab_write_optional_names (BIO * outdata , char * indata , size_t len , uint16_t flags );
8484static int cab_modify_header (FILE_FORMAT_CTX * ctx , BIO * hash , BIO * outdata );
8585static int cab_add_header (FILE_FORMAT_CTX * ctx , BIO * hash , BIO * outdata );
86+ static int cab_check_file (FILE_FORMAT_CTX * ctx );
8687
8788/*
8889 * FILE_FORMAT method definitions
@@ -192,34 +193,6 @@ static int cab_hash_length_get(FILE_FORMAT_CTX *ctx)
192193 return EVP_MD_size (ctx -> options -> md );
193194}
194195
195- /*
196- * Check if the signature exists.
197- * [in, out] ctx: structure holds input and output data
198- * [in] detached: embedded/detached PKCS#7 signature switch
199- * [returns] 0 on error or 1 on success
200- */
201- static int cab_check_file (FILE_FORMAT_CTX * ctx , int detached )
202- {
203- if (!ctx ) {
204- printf ("Init error\n\n" );
205- return 0 ; /* FAILED */
206- }
207- if (detached ) {
208- printf ("Checking the specified catalog file\n\n" );
209- return 1 ; /* OK */
210- }
211- if (ctx -> cab_ctx -> header_size != 20 ) {
212- printf ("No signature found\n\n" );
213- return 0 ; /* FAILED */
214- }
215- if (ctx -> cab_ctx -> sigpos == 0 || ctx -> cab_ctx -> siglen == 0
216- || ctx -> cab_ctx -> sigpos > ctx -> cab_ctx -> fileend ) {
217- printf ("No signature found\n\n" );
218- return 0 ; /* FAILED */
219- }
220- return 1 ; /* OK */
221- }
222-
223196/*
224197 * Compute a message digest value of the signed or unsigned CAB file.
225198 * [in] ctx: structure holds input and output data
@@ -397,8 +370,7 @@ static PKCS7 *cab_pkcs7_extract(FILE_FORMAT_CTX *ctx)
397370{
398371 const u_char * blob ;
399372
400- if (ctx -> cab_ctx -> sigpos == 0 || ctx -> cab_ctx -> siglen == 0
401- || ctx -> cab_ctx -> sigpos > ctx -> cab_ctx -> fileend ) {
373+ if (!cab_check_file (ctx )) {
402374 return NULL ; /* FAILED */
403375 }
404376 blob = (u_char * )ctx -> options -> indata + ctx -> cab_ctx -> sigpos ;
@@ -432,8 +404,7 @@ static int cab_remove_pkcs7(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata)
432404 /* squash the unused parameter warning */
433405 (void )hash ;
434406
435- if (ctx -> cab_ctx -> sigpos == 0 || ctx -> cab_ctx -> siglen == 0
436- || ctx -> cab_ctx -> sigpos > ctx -> cab_ctx -> fileend ) {
407+ if (!cab_check_file (ctx )) {
437408 return 1 ; /* FAILED, no signature */
438409 }
439410 buf = OPENSSL_malloc (SIZE_64K );
@@ -655,6 +626,11 @@ static void cab_ctx_cleanup(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata)
655626 OPENSSL_free (ctx );
656627}
657628
629+ static int cab_is_detaching_supported (void )
630+ {
631+ return 1 ; /* OK */
632+ }
633+
658634/*
659635 * CAB helper functions
660636 */
@@ -972,6 +948,29 @@ static int cab_add_header(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata)
972948 return 1 ; /* OK */
973949}
974950
951+ /*
952+ * Check if the signature exists.
953+ * [in, out] ctx: structure holds input and output data
954+ * [returns] 0 on error or 1 on success
955+ */
956+ static int cab_check_file (FILE_FORMAT_CTX * ctx )
957+ {
958+ if (!ctx ) {
959+ printf ("Init error\n\n" );
960+ return 0 ; /* FAILED */
961+ }
962+ if (ctx -> cab_ctx -> header_size != 20 ) {
963+ printf ("No signature found\n\n" );
964+ return 0 ; /* FAILED */
965+ }
966+ if (ctx -> cab_ctx -> sigpos == 0 || ctx -> cab_ctx -> siglen == 0
967+ || ctx -> cab_ctx -> sigpos > ctx -> cab_ctx -> fileend ) {
968+ printf ("No signature found\n\n" );
969+ return 0 ; /* FAILED */
970+ }
971+ return 1 ; /* OK */
972+ }
973+
975974/*
976975Local Variables:
977976 c-basic-offset: 4
0 commit comments