Stop using tabs for indentation

This commit is contained in:
Michał Trojnara 2023-03-25 23:39:52 +01:00
parent 246f0abbfc
commit 0204d04a25
8 changed files with 6295 additions and 6295 deletions

1294
cab.c

File diff suppressed because it is too large Load Diff

254
cat.c
View File

@ -11,14 +11,14 @@
#include "helpers.h" #include "helpers.h"
const u_char pkcs7_signed_data[] = { const u_char pkcs7_signed_data[] = {
0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
0x01, 0x07, 0x02, 0x01, 0x07, 0x02,
}; };
struct cat_ctx_st { struct cat_ctx_st {
uint32_t sigpos; uint32_t sigpos;
uint32_t siglen; uint32_t siglen;
uint32_t fileend; uint32_t fileend;
}; };
/* FILE_FORMAT method prototypes */ /* FILE_FORMAT method prototypes */
@ -30,12 +30,12 @@ static BIO *cat_bio_free(BIO *hash, BIO *outdata);
static void cat_ctx_cleanup(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata); static void cat_ctx_cleanup(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata);
FILE_FORMAT file_format_cat = { FILE_FORMAT file_format_cat = {
.ctx_new = cat_ctx_new, .ctx_new = cat_ctx_new,
.pkcs7_extract = cat_pkcs7_extract, .pkcs7_extract = cat_pkcs7_extract,
.pkcs7_prepare = cat_pkcs7_prepare, .pkcs7_prepare = cat_pkcs7_prepare,
.append_pkcs7 = cat_append_pkcs7, .append_pkcs7 = cat_append_pkcs7,
.bio_free = cat_bio_free, .bio_free = cat_bio_free,
.ctx_cleanup = cat_ctx_cleanup, .ctx_cleanup = cat_ctx_cleanup,
}; };
/* Prototypes */ /* Prototypes */
@ -54,59 +54,59 @@ static CAT_CTX *cat_ctx_get(char *indata, uint32_t filesize);
*/ */
static FILE_FORMAT_CTX *cat_ctx_new(GLOBAL_OPTIONS *options, BIO *hash, BIO *outdata) static FILE_FORMAT_CTX *cat_ctx_new(GLOBAL_OPTIONS *options, BIO *hash, BIO *outdata)
{ {
FILE_FORMAT_CTX *ctx; FILE_FORMAT_CTX *ctx;
CAT_CTX *cat_ctx; CAT_CTX *cat_ctx;
uint32_t filesize; uint32_t filesize;
/* squash unused parameter warnings */ /* squash unused parameter warnings */
(void)outdata; (void)outdata;
(void)hash; (void)hash;
if (options->cmd == CMD_REMOVE || options->cmd==CMD_ATTACH) { if (options->cmd == CMD_REMOVE || options->cmd==CMD_ATTACH) {
printf("Unsupported command\n"); printf("Unsupported command\n");
return NULL; /* FAILED */ return NULL; /* FAILED */
} }
if (options->cmd == CMD_VERIFY) { if (options->cmd == CMD_VERIFY) {
printf("Use -catalog option\n"); printf("Use -catalog option\n");
return NULL; /* FAILED */ return NULL; /* FAILED */
} }
filesize = get_file_size(options->infile); filesize = get_file_size(options->infile);
if (filesize == 0) if (filesize == 0)
return NULL; /* FAILED */ return NULL; /* FAILED */
options->indata = map_file(options->infile, filesize); options->indata = map_file(options->infile, filesize);
if (!options->indata) { if (!options->indata) {
return NULL; /* FAILED */ return NULL; /* FAILED */
} }
/* the maximum size of a supported cat file is (2^24 -1) bytes */ /* the maximum size of a supported cat file is (2^24 -1) bytes */
if (memcmp(options->indata + ((GET_UINT8_LE(options->indata+1) == 0x82) ? 4 : 5), if (memcmp(options->indata + ((GET_UINT8_LE(options->indata+1) == 0x82) ? 4 : 5),
pkcs7_signed_data, sizeof pkcs7_signed_data)) { pkcs7_signed_data, sizeof pkcs7_signed_data)) {
unmap_file(options->infile, filesize); unmap_file(options->infile, filesize);
return NULL; /* FAILED */ return NULL; /* FAILED */
} }
cat_ctx = cat_ctx_get(options->indata, filesize); cat_ctx = cat_ctx_get(options->indata, filesize);
if (!cat_ctx) { if (!cat_ctx) {
unmap_file(options->infile, filesize); unmap_file(options->infile, filesize);
return NULL; /* FAILED */ return NULL; /* FAILED */
} }
ctx = OPENSSL_malloc(sizeof(FILE_FORMAT_CTX)); ctx = OPENSSL_malloc(sizeof(FILE_FORMAT_CTX));
ctx->format = &file_format_cat; ctx->format = &file_format_cat;
ctx->options = options; ctx->options = options;
ctx->cat_ctx = cat_ctx; ctx->cat_ctx = cat_ctx;
/* Push hash on outdata, if hash is NULL the function does nothing */ /* Push hash on outdata, if hash is NULL the function does nothing */
BIO_push(hash, outdata); BIO_push(hash, outdata);
if (options->nest) if (options->nest)
/* I've not tried using set_nested_signature as signtool won't do this */ /* I've not tried using set_nested_signature as signtool won't do this */
printf("Warning: CAT files do not support nesting\n"); printf("Warning: CAT files do not support nesting\n");
if (options->jp >= 0) if (options->jp >= 0)
printf("Warning: -jp option is only valid for CAB files\n"); printf("Warning: -jp option is only valid for CAB files\n");
if (options->pagehash == 1) if (options->pagehash == 1)
printf("Warning: -ph option is only valid for PE files\n"); printf("Warning: -ph option is only valid for PE files\n");
if (options->add_msi_dse == 1) if (options->add_msi_dse == 1)
printf("Warning: -add-msi-dse option is only valid for MSI files\n"); printf("Warning: -add-msi-dse option is only valid for MSI files\n");
return ctx; return ctx;
} }
/* /*
@ -116,7 +116,7 @@ static FILE_FORMAT_CTX *cat_ctx_new(GLOBAL_OPTIONS *options, BIO *hash, BIO *out
*/ */
static PKCS7 *cat_pkcs7_extract(FILE_FORMAT_CTX *ctx) static PKCS7 *cat_pkcs7_extract(FILE_FORMAT_CTX *ctx)
{ {
return pkcs7_get(ctx->options->indata, ctx->cat_ctx->sigpos, ctx->cat_ctx->siglen); return pkcs7_get(ctx->options->indata, ctx->cat_ctx->sigpos, ctx->cat_ctx->siglen);
} }
/* /*
@ -128,37 +128,37 @@ static PKCS7 *cat_pkcs7_extract(FILE_FORMAT_CTX *ctx)
*/ */
static PKCS7 *cat_pkcs7_prepare(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata) static PKCS7 *cat_pkcs7_prepare(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata)
{ {
PKCS7 *cursig = NULL, *p7 = NULL; PKCS7 *cursig = NULL, *p7 = NULL;
/* squash unused parameter warnings */ /* squash unused parameter warnings */
(void)outdata; (void)outdata;
(void)hash; (void)hash;
/* Obtain an existing signature */ /* Obtain an existing signature */
cursig = pkcs7_get(ctx->options->indata, ctx->cat_ctx->sigpos, ctx->cat_ctx->siglen); cursig = pkcs7_get(ctx->options->indata, ctx->cat_ctx->sigpos, ctx->cat_ctx->siglen);
if (!cursig) { if (!cursig) {
printf("Unable to extract existing signature\n"); printf("Unable to extract existing signature\n");
return NULL; /* FAILED */ return NULL; /* FAILED */
} }
if (ctx->options->cmd == CMD_ADD || ctx->options->cmd == CMD_ATTACH) { if (ctx->options->cmd == CMD_ADD || ctx->options->cmd == CMD_ATTACH) {
p7 = cursig; p7 = cursig;
} else if (ctx->options->cmd == CMD_SIGN) { } else if (ctx->options->cmd == CMD_SIGN) {
/* Create a new signature */ /* Create a new signature */
p7 = pkcs7_create(ctx); p7 = pkcs7_create(ctx);
if (!p7) { if (!p7) {
printf("Creating a new signature failed\n"); printf("Creating a new signature failed\n");
PKCS7_free(cursig); PKCS7_free(cursig);
return NULL; /* FAILED */ return NULL; /* FAILED */
} }
if (!add_ms_ctl_object(p7, cursig)) { if (!add_ms_ctl_object(p7, cursig)) {
printf("Adding MS_CTL_OBJID failed\n"); printf("Adding MS_CTL_OBJID failed\n");
PKCS7_free(p7); PKCS7_free(p7);
PKCS7_free(cursig); PKCS7_free(cursig);
return NULL; /* FAILED */ return NULL; /* FAILED */
} }
PKCS7_free(cursig); PKCS7_free(cursig);
} }
return p7; /* OK */ return p7; /* OK */
} }
/* /*
@ -170,22 +170,22 @@ static PKCS7 *cat_pkcs7_prepare(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata)
*/ */
static int cat_append_pkcs7(FILE_FORMAT_CTX *ctx, BIO *outdata, PKCS7 *p7) static int cat_append_pkcs7(FILE_FORMAT_CTX *ctx, BIO *outdata, PKCS7 *p7)
{ {
u_char *p = NULL; u_char *p = NULL;
int len; /* signature length */ int len; /* signature length */
/* squash the unused parameter warning */ /* squash the unused parameter warning */
(void)ctx; (void)ctx;
if (((len = i2d_PKCS7(p7, NULL)) <= 0) if (((len = i2d_PKCS7(p7, NULL)) <= 0)
|| (p = OPENSSL_malloc((size_t)len)) == NULL) { || (p = OPENSSL_malloc((size_t)len)) == NULL) {
printf("i2d_PKCS memory allocation failed: %d\n", len); printf("i2d_PKCS memory allocation failed: %d\n", len);
return 1; /* FAILED */ return 1; /* FAILED */
} }
i2d_PKCS7(p7, &p); i2d_PKCS7(p7, &p);
p -= len; p -= len;
i2d_PKCS7_bio(outdata, p7); i2d_PKCS7_bio(outdata, p7);
OPENSSL_free(p); OPENSSL_free(p);
return 0; /* OK */ return 0; /* OK */
} }
/* /*
@ -196,11 +196,11 @@ static int cat_append_pkcs7(FILE_FORMAT_CTX *ctx, BIO *outdata, PKCS7 *p7)
*/ */
static BIO *cat_bio_free(BIO *hash, BIO *outdata) static BIO *cat_bio_free(BIO *hash, BIO *outdata)
{ {
/* squash the unused parameter warning */ /* squash the unused parameter warning */
(void)outdata; (void)outdata;
BIO_free_all(hash); BIO_free_all(hash);
return NULL; return NULL;
} }
/* /*
@ -213,19 +213,19 @@ static BIO *cat_bio_free(BIO *hash, BIO *outdata)
*/ */
static void cat_ctx_cleanup(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata) static void cat_ctx_cleanup(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata)
{ {
if (outdata) { if (outdata) {
BIO_free_all(hash); BIO_free_all(hash);
if (ctx->options->outfile) { if (ctx->options->outfile) {
#ifdef WIN32 #ifdef WIN32
_unlink(ctx->options->outfile); _unlink(ctx->options->outfile);
#else #else
unlink(ctx->options->outfile); unlink(ctx->options->outfile);
#endif /* WIN32 */ #endif /* WIN32 */
} }
} }
unmap_file(ctx->options->indata, ctx->cat_ctx->fileend); unmap_file(ctx->options->indata, ctx->cat_ctx->fileend);
OPENSSL_free(ctx->cat_ctx); OPENSSL_free(ctx->cat_ctx);
OPENSSL_free(ctx); OPENSSL_free(ctx);
} }
/* /*
@ -240,24 +240,24 @@ static void cat_ctx_cleanup(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata)
*/ */
static CAT_CTX *cat_ctx_get(char *indata, uint32_t filesize) static CAT_CTX *cat_ctx_get(char *indata, uint32_t filesize)
{ {
CAT_CTX *cat_ctx; CAT_CTX *cat_ctx;
/* squash the unused parameter warning */ /* squash the unused parameter warning */
(void)indata; (void)indata;
cat_ctx = OPENSSL_zalloc(sizeof(CAT_CTX)); cat_ctx = OPENSSL_zalloc(sizeof(CAT_CTX));
cat_ctx->sigpos = 0; cat_ctx->sigpos = 0;
cat_ctx->siglen = filesize; cat_ctx->siglen = filesize;
cat_ctx->fileend = filesize; cat_ctx->fileend = filesize;
return cat_ctx; /* OK */ return cat_ctx; /* OK */
} }
/* /*
Local Variables: Local Variables:
c-basic-offset: 4 c-basic-offset: 4
tab-width: 4 tab-width: 4
indent-tabs-mode: t indent-tabs-mode: nil
End: End:
vim: set ts=4 noexpandtab: vim: set ts=4 expandtab:
*/ */

854
helpers.c

File diff suppressed because it is too large Load Diff

View File

@ -28,8 +28,8 @@ int compare_digests(u_char *mdbuf, u_char *cmdbuf, int mdtype);
Local Variables: Local Variables:
c-basic-offset: 4 c-basic-offset: 4
tab-width: 4 tab-width: 4
indent-tabs-mode: t indent-tabs-mode: nil
End: End:
vim: set ts=4 noexpandtab: vim: set ts=4 expandtab:
*/ */

3134
msi.c

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -211,151 +211,151 @@
#define DO_EXIT_2(x, y, z) { printf(x, y, z); goto err_cleanup; } #define DO_EXIT_2(x, y, z) { printf(x, y, z); goto err_cleanup; }
typedef enum { typedef enum {
CMD_SIGN, CMD_SIGN,
CMD_EXTRACT, CMD_EXTRACT,
CMD_REMOVE, CMD_REMOVE,
CMD_VERIFY, CMD_VERIFY,
CMD_ADD, CMD_ADD,
CMD_ATTACH, CMD_ATTACH,
CMD_HELP, CMD_HELP,
CMD_DEFAULT CMD_DEFAULT
} cmd_type_t; } cmd_type_t;
typedef unsigned char u_char; typedef unsigned char u_char;
typedef struct { typedef struct {
char *infile; char *infile;
char *outfile; char *outfile;
char *sigfile; char *sigfile;
char *certfile; char *certfile;
char *xcertfile; char *xcertfile;
char *keyfile; char *keyfile;
char *pvkfile; char *pvkfile;
char *pkcs12file; char *pkcs12file;
int output_pkcs7; int output_pkcs7;
#ifndef OPENSSL_NO_ENGINE #ifndef OPENSSL_NO_ENGINE
char *p11engine; char *p11engine;
char *p11module; char *p11module;
char *p11cert; char *p11cert;
#endif /* OPENSSL_NO_ENGINE */ #endif /* OPENSSL_NO_ENGINE */
int askpass; int askpass;
char *readpass; char *readpass;
char *pass; char *pass;
int comm; int comm;
int pagehash; int pagehash;
char *desc; char *desc;
const EVP_MD *md; const EVP_MD *md;
char *url; char *url;
time_t time; time_t time;
#ifdef ENABLE_CURL #ifdef ENABLE_CURL
char *turl[MAX_TS_SERVERS]; char *turl[MAX_TS_SERVERS];
int nturl; int nturl;
char *tsurl[MAX_TS_SERVERS]; char *tsurl[MAX_TS_SERVERS];
int ntsurl; int ntsurl;
char *proxy; char *proxy;
int noverifypeer; int noverifypeer;
#endif /* ENABLE_CURL */ #endif /* ENABLE_CURL */
int addBlob; int addBlob;
int nest; int nest;
int ignore_timestamp; int ignore_timestamp;
int verbose; int verbose;
int add_msi_dse; int add_msi_dse;
char *catalog; char *catalog;
char *cafile; char *cafile;
char *crlfile; char *crlfile;
char *tsa_cafile; char *tsa_cafile;
char *tsa_crlfile; char *tsa_crlfile;
char *leafhash; char *leafhash;
int jp; int jp;
#if OPENSSL_VERSION_NUMBER>=0x30000000L #if OPENSSL_VERSION_NUMBER>=0x30000000L
int legacy; int legacy;
#endif /* OPENSSL_VERSION_NUMBER>=0x30000000L */ #endif /* OPENSSL_VERSION_NUMBER>=0x30000000L */
EVP_PKEY *pkey; EVP_PKEY *pkey;
X509 *cert; X509 *cert;
STACK_OF(X509) *certs; STACK_OF(X509) *certs;
STACK_OF(X509) *xcerts; STACK_OF(X509) *xcerts;
STACK_OF(X509_CRL) *crls; STACK_OF(X509_CRL) *crls;
cmd_type_t cmd; cmd_type_t cmd;
char *indata; char *indata;
} GLOBAL_OPTIONS; } GLOBAL_OPTIONS;
/* /*
* ASN.1 definitions (more or less from official MS Authenticode docs) * ASN.1 definitions (more or less from official MS Authenticode docs)
*/ */
typedef struct { typedef struct {
int type; int type;
union { union {
ASN1_BMPSTRING *unicode; ASN1_BMPSTRING *unicode;
ASN1_IA5STRING *ascii; ASN1_IA5STRING *ascii;
} value; } value;
} SpcString; } SpcString;
DECLARE_ASN1_FUNCTIONS(SpcString) DECLARE_ASN1_FUNCTIONS(SpcString)
typedef struct { typedef struct {
ASN1_OCTET_STRING *classId; ASN1_OCTET_STRING *classId;
ASN1_OCTET_STRING *serializedData; ASN1_OCTET_STRING *serializedData;
} SpcSerializedObject; } SpcSerializedObject;
DECLARE_ASN1_FUNCTIONS(SpcSerializedObject) DECLARE_ASN1_FUNCTIONS(SpcSerializedObject)
typedef struct { typedef struct {
int type; int type;
union { union {
ASN1_IA5STRING *url; ASN1_IA5STRING *url;
SpcSerializedObject *moniker; SpcSerializedObject *moniker;
SpcString *file; SpcString *file;
} value; } value;
} SpcLink; } SpcLink;
DECLARE_ASN1_FUNCTIONS(SpcLink) DECLARE_ASN1_FUNCTIONS(SpcLink)
typedef struct { typedef struct {
SpcString *programName; SpcString *programName;
SpcLink *moreInfo; SpcLink *moreInfo;
} SpcSpOpusInfo; } SpcSpOpusInfo;
DECLARE_ASN1_FUNCTIONS(SpcSpOpusInfo) DECLARE_ASN1_FUNCTIONS(SpcSpOpusInfo)
typedef struct { typedef struct {
ASN1_OBJECT *type; ASN1_OBJECT *type;
ASN1_TYPE *value; ASN1_TYPE *value;
} SpcAttributeTypeAndOptionalValue; } SpcAttributeTypeAndOptionalValue;
DECLARE_ASN1_FUNCTIONS(SpcAttributeTypeAndOptionalValue) DECLARE_ASN1_FUNCTIONS(SpcAttributeTypeAndOptionalValue)
typedef struct { typedef struct {
ASN1_OBJECT *algorithm; ASN1_OBJECT *algorithm;
ASN1_TYPE *parameters; ASN1_TYPE *parameters;
} AlgorithmIdentifier; } AlgorithmIdentifier;
DECLARE_ASN1_FUNCTIONS(AlgorithmIdentifier) DECLARE_ASN1_FUNCTIONS(AlgorithmIdentifier)
typedef struct { typedef struct {
AlgorithmIdentifier *digestAlgorithm; AlgorithmIdentifier *digestAlgorithm;
ASN1_OCTET_STRING *digest; ASN1_OCTET_STRING *digest;
} DigestInfo; } DigestInfo;
DECLARE_ASN1_FUNCTIONS(DigestInfo) DECLARE_ASN1_FUNCTIONS(DigestInfo)
typedef struct { typedef struct {
SpcAttributeTypeAndOptionalValue *data; SpcAttributeTypeAndOptionalValue *data;
DigestInfo *messageDigest; DigestInfo *messageDigest;
} SpcIndirectDataContent; } SpcIndirectDataContent;
DECLARE_ASN1_FUNCTIONS(SpcIndirectDataContent) DECLARE_ASN1_FUNCTIONS(SpcIndirectDataContent)
typedef struct CatalogAuthAttr_st { typedef struct CatalogAuthAttr_st {
ASN1_OBJECT *type; ASN1_OBJECT *type;
ASN1_TYPE *contents; ASN1_TYPE *contents;
} CatalogAuthAttr; } CatalogAuthAttr;
DEFINE_STACK_OF(CatalogAuthAttr) DEFINE_STACK_OF(CatalogAuthAttr)
DECLARE_ASN1_FUNCTIONS(CatalogAuthAttr) DECLARE_ASN1_FUNCTIONS(CatalogAuthAttr)
typedef struct { typedef struct {
AlgorithmIdentifier *digestAlgorithm; AlgorithmIdentifier *digestAlgorithm;
ASN1_OCTET_STRING *digest; ASN1_OCTET_STRING *digest;
} MessageImprint; } MessageImprint;
DECLARE_ASN1_FUNCTIONS(MessageImprint) DECLARE_ASN1_FUNCTIONS(MessageImprint)
@ -363,15 +363,15 @@ DECLARE_ASN1_FUNCTIONS(MessageImprint)
#ifdef ENABLE_CURL #ifdef ENABLE_CURL
typedef struct { typedef struct {
ASN1_OBJECT *type; ASN1_OBJECT *type;
ASN1_OCTET_STRING *signature; ASN1_OCTET_STRING *signature;
} TimeStampRequestBlob; } TimeStampRequestBlob;
DECLARE_ASN1_FUNCTIONS(TimeStampRequestBlob) DECLARE_ASN1_FUNCTIONS(TimeStampRequestBlob)
typedef struct { typedef struct {
ASN1_OBJECT *type; ASN1_OBJECT *type;
TimeStampRequestBlob *blob; TimeStampRequestBlob *blob;
} TimeStampRequest; } TimeStampRequest;
DECLARE_ASN1_FUNCTIONS(TimeStampRequest) DECLARE_ASN1_FUNCTIONS(TimeStampRequest)
@ -379,27 +379,27 @@ DECLARE_ASN1_FUNCTIONS(TimeStampRequest)
/* RFC3161 Time stamping */ /* RFC3161 Time stamping */
typedef struct { typedef struct {
ASN1_INTEGER *status; ASN1_INTEGER *status;
STACK_OF(ASN1_UTF8STRING) *statusString; STACK_OF(ASN1_UTF8STRING) *statusString;
ASN1_BIT_STRING *failInfo; ASN1_BIT_STRING *failInfo;
} PKIStatusInfo; } PKIStatusInfo;
DECLARE_ASN1_FUNCTIONS(PKIStatusInfo) DECLARE_ASN1_FUNCTIONS(PKIStatusInfo)
typedef struct { typedef struct {
PKIStatusInfo *status; PKIStatusInfo *status;
PKCS7 *token; PKCS7 *token;
} TimeStampResp; } TimeStampResp;
DECLARE_ASN1_FUNCTIONS(TimeStampResp) DECLARE_ASN1_FUNCTIONS(TimeStampResp)
typedef struct { typedef struct {
ASN1_INTEGER *version; ASN1_INTEGER *version;
MessageImprint *messageImprint; MessageImprint *messageImprint;
ASN1_OBJECT *reqPolicy; ASN1_OBJECT *reqPolicy;
ASN1_INTEGER *nonce; ASN1_INTEGER *nonce;
ASN1_BOOLEAN certReq; ASN1_BOOLEAN certReq;
STACK_OF(X509_EXTENSION) *extensions; STACK_OF(X509_EXTENSION) *extensions;
} TimeStampReq; } TimeStampReq;
DECLARE_ASN1_FUNCTIONS(TimeStampReq) DECLARE_ASN1_FUNCTIONS(TimeStampReq)
@ -407,47 +407,47 @@ DECLARE_ASN1_FUNCTIONS(TimeStampReq)
#endif /* ENABLE_CURL */ #endif /* ENABLE_CURL */
typedef struct { typedef struct {
ASN1_INTEGER *seconds; ASN1_INTEGER *seconds;
ASN1_INTEGER *millis; ASN1_INTEGER *millis;
ASN1_INTEGER *micros; ASN1_INTEGER *micros;
} TimeStampAccuracy; } TimeStampAccuracy;
DECLARE_ASN1_FUNCTIONS(TimeStampAccuracy) DECLARE_ASN1_FUNCTIONS(TimeStampAccuracy)
typedef struct { typedef struct {
ASN1_INTEGER *version; ASN1_INTEGER *version;
ASN1_OBJECT *policy_id; ASN1_OBJECT *policy_id;
MessageImprint *messageImprint; MessageImprint *messageImprint;
ASN1_INTEGER *serial; ASN1_INTEGER *serial;
ASN1_GENERALIZEDTIME *time; ASN1_GENERALIZEDTIME *time;
TimeStampAccuracy *accuracy; TimeStampAccuracy *accuracy;
ASN1_BOOLEAN ordering; ASN1_BOOLEAN ordering;
ASN1_INTEGER *nonce; ASN1_INTEGER *nonce;
GENERAL_NAME *tsa; GENERAL_NAME *tsa;
STACK_OF(X509_EXTENSION) *extensions; STACK_OF(X509_EXTENSION) *extensions;
} TimeStampToken; } TimeStampToken;
DECLARE_ASN1_FUNCTIONS(TimeStampToken) DECLARE_ASN1_FUNCTIONS(TimeStampToken)
typedef struct { typedef struct {
ASN1_OCTET_STRING *digest; ASN1_OCTET_STRING *digest;
STACK_OF(CatalogAuthAttr) *attributes; STACK_OF(CatalogAuthAttr) *attributes;
} CatalogInfo; } CatalogInfo;
DEFINE_STACK_OF(CatalogInfo) DEFINE_STACK_OF(CatalogInfo)
DECLARE_ASN1_FUNCTIONS(CatalogInfo) DECLARE_ASN1_FUNCTIONS(CatalogInfo)
typedef struct { typedef struct {
/* 1.3.6.1.4.1.311.12.1.1 MS_CATALOG_LIST */ /* 1.3.6.1.4.1.311.12.1.1 MS_CATALOG_LIST */
SpcAttributeTypeAndOptionalValue *type; SpcAttributeTypeAndOptionalValue *type;
ASN1_OCTET_STRING *identifier; ASN1_OCTET_STRING *identifier;
ASN1_UTCTIME *time; ASN1_UTCTIME *time;
/* 1.3.6.1.4.1.311.12.1.2 CatalogVersion = 1 /* 1.3.6.1.4.1.311.12.1.2 CatalogVersion = 1
* 1.3.6.1.4.1.311.12.1.3 CatalogVersion = 2 */ * 1.3.6.1.4.1.311.12.1.3 CatalogVersion = 2 */
SpcAttributeTypeAndOptionalValue *version; SpcAttributeTypeAndOptionalValue *version;
STACK_OF(CatalogInfo) *header_attributes; STACK_OF(CatalogInfo) *header_attributes;
/* 1.3.6.1.4.1.311.12.2.1 CAT_NAMEVALUE_OBJID */ /* 1.3.6.1.4.1.311.12.2.1 CAT_NAMEVALUE_OBJID */
ASN1_TYPE *filename; ASN1_TYPE *filename;
} MsCtlContent; } MsCtlContent;
DECLARE_ASN1_FUNCTIONS(MsCtlContent) DECLARE_ASN1_FUNCTIONS(MsCtlContent)
@ -459,8 +459,8 @@ typedef struct cab_ctx_st CAB_CTX;
typedef struct cat_ctx_st CAT_CTX; typedef struct cat_ctx_st CAT_CTX;
typedef struct { typedef struct {
FILE_FORMAT *format; FILE_FORMAT *format;
GLOBAL_OPTIONS *options; GLOBAL_OPTIONS *options;
union { union {
MSI_CTX *msi_ctx; MSI_CTX *msi_ctx;
PE_CTX *pe_ctx; PE_CTX *pe_ctx;
@ -475,27 +475,27 @@ extern FILE_FORMAT file_format_cab;
extern FILE_FORMAT file_format_cat; extern FILE_FORMAT file_format_cat;
struct file_format_st { struct file_format_st {
FILE_FORMAT_CTX *(*ctx_new) (GLOBAL_OPTIONS *option, BIO *hash, BIO *outdata); FILE_FORMAT_CTX *(*ctx_new) (GLOBAL_OPTIONS *option, BIO *hash, BIO *outdata);
ASN1_OBJECT *(*data_blob_get) (u_char **p, int *plen, FILE_FORMAT_CTX *ctx); ASN1_OBJECT *(*data_blob_get) (u_char **p, int *plen, FILE_FORMAT_CTX *ctx);
int (*check_file) (FILE_FORMAT_CTX *ctx, int detached); int (*check_file) (FILE_FORMAT_CTX *ctx, int detached);
u_char *(*digest_calc) (FILE_FORMAT_CTX *ctx, const EVP_MD *md); u_char *(*digest_calc) (FILE_FORMAT_CTX *ctx, const EVP_MD *md);
int (*verify_digests) (FILE_FORMAT_CTX *ctx, PKCS7 *p7); int (*verify_digests) (FILE_FORMAT_CTX *ctx, PKCS7 *p7);
int (*verify_indirect_data) (FILE_FORMAT_CTX *ctx, SpcAttributeTypeAndOptionalValue *obj); int (*verify_indirect_data) (FILE_FORMAT_CTX *ctx, SpcAttributeTypeAndOptionalValue *obj);
PKCS7 *(*pkcs7_extract) (FILE_FORMAT_CTX *ctx); PKCS7 *(*pkcs7_extract) (FILE_FORMAT_CTX *ctx);
int (*remove_pkcs7) (FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata); int (*remove_pkcs7) (FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata);
PKCS7 *(*pkcs7_prepare) (FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata); PKCS7 *(*pkcs7_prepare) (FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata);
int (*append_pkcs7) (FILE_FORMAT_CTX *ctx, BIO *outdata, PKCS7 *p7); int (*append_pkcs7) (FILE_FORMAT_CTX *ctx, BIO *outdata, PKCS7 *p7);
void (*update_data_size) (FILE_FORMAT_CTX *data, BIO *outdata, PKCS7 *p7); void (*update_data_size) (FILE_FORMAT_CTX *data, BIO *outdata, PKCS7 *p7);
BIO *(*bio_free) (BIO *hash, BIO *outdata); BIO *(*bio_free) (BIO *hash, BIO *outdata);
void (*ctx_cleanup) (FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata); void (*ctx_cleanup) (FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata);
}; };
/* /*
Local Variables: Local Variables:
c-basic-offset: 4 c-basic-offset: 4
tab-width: 4 tab-width: 4
indent-tabs-mode: t indent-tabs-mode: nil
End: End:
vim: set ts=4 noexpandtab: vim: set ts=4 expandtab:
*/ */

1618
pe.c

File diff suppressed because it is too large Load Diff