View | Details | Raw Unified | Return to bug 808594
Collapse All | Expand All

(-)a/src/cms_common.c (-3 / +23 lines)
Lines 795-800 err: Link Here
795
	return -1;
795
	return -1;
796
}
796
}
797
797
798
#if 1
799
#define dprintf(fmt, ...)
800
#else
801
#define dprintf(fmt, args...) printf(fmt, ## args)
802
#endif
803
798
int
804
int
799
generate_digest(cms_context *cms, Pe *pe)
805
generate_digest(cms_context *cms, Pe *pe)
800
{
806
{
Lines 860-865 generate_digest(cms_context *cms, Pe *pe) Link Here
860
		cms->log(cms, LOG_ERR, "Pe header is invalid");
866
		cms->log(cms, LOG_ERR, "Pe header is invalid");
861
		goto error;
867
		goto error;
862
	}
868
	}
869
	dprintf("beginning of hash\n");
870
	dprintf("digesting %lx + %lx\n", hash_base - map, hash_size);
863
	generate_digest_step(cms, hash_base, hash_size);
871
	generate_digest_step(cms, hash_base, hash_size);
864
872
865
	/* 5. Skip over the image checksum
873
	/* 5. Skip over the image checksum
Lines 882-887 generate_digest(cms_context *cms, Pe *pe) Link Here
882
		goto error;
890
		goto error;
883
	}
891
	}
884
	generate_digest_step(cms, hash_base, hash_size);
892
	generate_digest_step(cms, hash_base, hash_size);
893
	dprintf("digesting %lx + %lx\n", hash_base - map, hash_size);
885
894
886
	/* 8. Skip over the crt dir
895
	/* 8. Skip over the crt dir
887
	 * 9. Hash everything up to the end of the image header. */
896
	 * 9. Hash everything up to the end of the image header. */
Lines 895-900 generate_digest(cms_context *cms, Pe *pe) Link Here
895
		goto error;
904
		goto error;
896
	}
905
	}
897
	generate_digest_step(cms, hash_base, hash_size);
906
	generate_digest_step(cms, hash_base, hash_size);
907
	dprintf("digesting %lx + %lx\n", hash_base - map, hash_size);
898
908
899
	/* 10. Set SUM_OF_BYTES_HASHED to the size of the header. */
909
	/* 10. Set SUM_OF_BYTES_HASHED to the size of the header. */
900
	hashed_bytes = pe32opthdr ? pe32opthdr->header_size
910
	hashed_bytes = pe32opthdr ? pe32opthdr->header_size
Lines 926-931 generate_digest(cms_context *cms, Pe *pe) Link Here
926
		}
936
		}
927
937
928
		generate_digest_step(cms, hash_base, hash_size);
938
		generate_digest_step(cms, hash_base, hash_size);
939
		dprintf("digesting %lx + %lx\n", hash_base - map, hash_size);
929
940
930
		hashed_bytes += hash_size;
941
		hashed_bytes += hash_size;
931
	}
942
	}
Lines 938-945 generate_digest(cms_context *cms, Pe *pe) Link Here
938
			cms->log(cms, LOG_ERR, "Pe has invalid trailing data");
949
			cms->log(cms, LOG_ERR, "Pe has invalid trailing data");
939
			goto error_shdrs;
950
			goto error_shdrs;
940
		}
951
		}
941
		generate_digest_step(cms, hash_base, hash_size);
952
		if (hash_size % 16 != 0) {
953
			size_t tmp_size = hash_size + (16 - (hash_size % 16));
954
			uint8_t tmp_array[tmp_size];
955
			memset(tmp_array, '\0', tmp_size);
956
			memcpy(tmp_array, hash_base, hash_size);
957
			generate_digest_step(cms, tmp_array, tmp_size);
958
			dprintf("digesting %lx + %lx\n", (unsigned long)tmp_array, tmp_size);
959
		} else {
960
			generate_digest_step(cms, hash_base, hash_size);
961
			dprintf("digesting %lx + %lx\n", hash_base - map, hash_size);
962
		}
942
	}
963
	}
964
	dprintf("end of hash\n");
943
965
944
	rc = generate_digest_finish(cms);
966
	rc = generate_digest_finish(cms);
945
	if (rc < 0)
967
	if (rc < 0)
946
- 
947
--
948
src/cms_common.c |    4 ++--
968
src/cms_common.c |    4 ++--
949
src/cms_common.h |    2 +-
969
src/cms_common.h |    2 +-
950
src/daemon.c     |    6 +++---
970
src/daemon.c     |    6 +++---
951
src/pesign.c     |   15 ++++++++-------
971
src/pesign.c     |   15 ++++++++-------
952
4 files changed, 14 insertions(+), 13 deletions(-)
972
4 files changed, 14 insertions(+), 13 deletions(-)
(-)a/src/cms_common.c (-2 / +2 lines)
Lines 802-808 err: Link Here
802
#endif
802
#endif
803
803
804
int
804
int
805
generate_digest(cms_context *cms, Pe *pe)
805
generate_digest(cms_context *cms, Pe *pe, int padded)
806
{
806
{
807
	void *hash_base;
807
	void *hash_base;
808
	size_t hash_size;
808
	size_t hash_size;
Lines 949-955 generate_digest(cms_context *cms, Pe *pe) Link Here
949
			cms->log(cms, LOG_ERR, "Pe has invalid trailing data");
949
			cms->log(cms, LOG_ERR, "Pe has invalid trailing data");
950
			goto error_shdrs;
950
			goto error_shdrs;
951
		}
951
		}
952
		if (hash_size % 16 != 0) {
952
		if (hash_size % 16 != 0 && padded) {
953
			size_t tmp_size = hash_size + (16 - (hash_size % 16));
953
			size_t tmp_size = hash_size + (16 - (hash_size % 16));
954
			uint8_t tmp_array[tmp_size];
954
			uint8_t tmp_array[tmp_size];
955
			memset(tmp_array, '\0', tmp_size);
955
			memset(tmp_array, '\0', tmp_size);
(-)a/src/cms_common.h (-1 / +1 lines)
Lines 105-111 extern int generate_spc_link(cms_context *cms, SpcLink *slp, Link Here
105
105
106
extern int generate_spc_string(cms_context *cms, SECItem *ssp, char *str,
106
extern int generate_spc_string(cms_context *cms, SECItem *ssp, char *str,
107
				int len);
107
				int len);
108
extern int generate_digest(cms_context *cms, Pe *pe);
108
extern int generate_digest(cms_context *cms, Pe *pe, int padded);
109
extern int generate_signature(cms_context *ctx);
109
extern int generate_signature(cms_context *ctx);
110
extern int unlock_nss_token(cms_context *ctx);
110
extern int unlock_nss_token(cms_context *ctx);
111
extern int find_certificate(cms_context *ctx);
111
extern int find_certificate(cms_context *ctx);
(-)a/src/daemon.c (-3 / +3 lines)
Lines 433-439 malformed: Link Here
433
		if (rc < 0)
433
		if (rc < 0)
434
			goto finish;
434
			goto finish;
435
435
436
		rc = generate_digest(ctx->cms, outpe);
436
		rc = generate_digest(ctx->cms, outpe, 1);
437
		if (rc < 0) {
437
		if (rc < 0) {
438
err_attached:
438
err_attached:
439
			pe_end(outpe);
439
			pe_end(outpe);
Lines 448-454 err_attached: Link Here
448
		if (sigspace < 0)
448
		if (sigspace < 0)
449
			goto err_attached;
449
			goto err_attached;
450
		allocate_signature_space(outpe, sigspace);
450
		allocate_signature_space(outpe, sigspace);
451
		rc = generate_digest(ctx->cms, outpe);
451
		rc = generate_digest(ctx->cms, outpe, 1);
452
		if (rc < 0)
452
		if (rc < 0)
453
			goto err_attached;
453
			goto err_attached;
454
		rc = generate_signature(ctx->cms);
454
		rc = generate_signature(ctx->cms);
Lines 463-469 err_attached: Link Here
463
			ctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,
463
			ctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,
464
				"pesignd: could not truncate output file: %m");
464
				"pesignd: could not truncate output file: %m");
465
		}
465
		}
466
		rc = generate_digest(ctx->cms, inpe);
466
		rc = generate_digest(ctx->cms, inpe, 1);
467
		if (rc < 0) {
467
		if (rc < 0) {
468
err_detached:
468
err_detached:
469
			if (ftruncate(outfd, 0) != 0) {
469
			if (ftruncate(outfd, 0) != 0) {
(-)a/src/pesign.c (-9 / +8 lines)
Lines 473-479 main(int argc, char *argv[]) Link Here
473
			"force overwriting of output file", NULL },
473
			"force overwriting of output file", NULL },
474
		{"sign", 's', POPT_ARG_VAL, &ctxp->sign, 1,
474
		{"sign", 's', POPT_ARG_VAL, &ctxp->sign, 1,
475
			"create a new signature", NULL },
475
			"create a new signature", NULL },
476
		{"hash", 'h', POPT_ARG_VAL, &ctxp->hash, 1, "hash binary", NULL },
476
		{"hash", 'h', POPT_ARG_VAL, &ctxp->hash, 1,
477
			"hash binary", NULL },
477
		{"digest_type", 'd', POPT_ARG_STRING|POPT_ARGFLAG_SHOW_DEFAULT,
478
		{"digest_type", 'd', POPT_ARG_STRING|POPT_ARGFLAG_SHOW_DEFAULT,
478
			&digest_name, 0, "digest type to use for pe hash" },
479
			&digest_name, 0, "digest type to use for pe hash" },
479
		{"import-signed-certificate", 'm',
480
		{"import-signed-certificate", 'm',
Lines 669-675 main(int argc, char *argv[]) Link Here
669
			open_input(ctxp);
670
			open_input(ctxp);
670
			open_output(ctxp);
671
			open_output(ctxp);
671
			close_input(ctxp);
672
			close_input(ctxp);
672
			generate_digest(ctxp->cms_ctx, ctxp->outpe);
673
			generate_digest(ctxp->cms_ctx, ctxp->outpe, 1);
673
			sigspace = calculate_signature_space(ctxp->cms_ctx,
674
			sigspace = calculate_signature_space(ctxp->cms_ctx,
674
								ctxp->outpe);
675
								ctxp->outpe);
675
			allocate_signature_space(ctxp->outpe, sigspace);
676
			allocate_signature_space(ctxp->outpe, sigspace);
Lines 683-689 main(int argc, char *argv[]) Link Here
683
		case EXPORT_SATTRS:
684
		case EXPORT_SATTRS:
684
			open_input(ctxp);
685
			open_input(ctxp);
685
			open_sattr_output(ctxp);
686
			open_sattr_output(ctxp);
686
			generate_digest(ctxp->cms_ctx, ctxp->inpe);
687
			generate_digest(ctxp->cms_ctx, ctxp->inpe, 1);
687
			generate_sattr_blob(ctxp);
688
			generate_sattr_blob(ctxp);
688
			close_sattr_output(ctxp);
689
			close_sattr_output(ctxp);
689
			close_input(ctxp);
690
			close_input(ctxp);
Lines 779-785 main(int argc, char *argv[]) Link Here
779
			break;
780
			break;
780
		case GENERATE_DIGEST|PRINT_DIGEST:
781
		case GENERATE_DIGEST|PRINT_DIGEST:
781
			open_input(ctxp);
782
			open_input(ctxp);
782
			generate_digest(ctxp->cms_ctx, ctxp->inpe);
783
			generate_digest(ctxp->cms_ctx, ctxp->inpe, 0);
783
			print_digest(ctxp);
784
			print_digest(ctxp);
784
			break;
785
			break;
785
		/* generate a signature and save it in a separate file */
786
		/* generate a signature and save it in a separate file */
Lines 793-799 main(int argc, char *argv[]) Link Here
793
			}
794
			}
794
			open_input(ctxp);
795
			open_input(ctxp);
795
			open_sig_output(ctxp);
796
			open_sig_output(ctxp);
796
			generate_digest(ctxp->cms_ctx, ctxp->inpe);
797
			generate_digest(ctxp->cms_ctx, ctxp->inpe, 1);
797
			generate_signature(ctxp->cms_ctx);
798
			generate_signature(ctxp->cms_ctx);
798
			export_signature(ctxp->cms_ctx, ctxp->outsigfd, ctxp->ascii);
799
			export_signature(ctxp->cms_ctx, ctxp->outsigfd, ctxp->ascii);
799
			break;
800
			break;
Lines 814-824 main(int argc, char *argv[]) Link Here
814
			open_input(ctxp);
815
			open_input(ctxp);
815
			open_output(ctxp);
816
			open_output(ctxp);
816
			close_input(ctxp);
817
			close_input(ctxp);
817
			generate_digest(ctxp->cms_ctx, ctxp->outpe);
818
			generate_digest(ctxp->cms_ctx, ctxp->outpe, 1);
818
			sigspace = calculate_signature_space(ctxp->cms_ctx,
819
			sigspace = calculate_signature_space(ctxp->cms_ctx,
819
							     ctxp->outpe);
820
							     ctxp->outpe);
820
			allocate_signature_space(ctxp->outpe, sigspace);
821
			allocate_signature_space(ctxp->outpe, sigspace);
821
			generate_digest(ctxp->cms_ctx, ctxp->outpe);
822
			generate_digest(ctxp->cms_ctx, ctxp->outpe, 1);
822
			generate_signature(ctxp->cms_ctx);
823
			generate_signature(ctxp->cms_ctx);
823
			insert_signature(ctxp->cms_ctx, ctxp->signum);
824
			insert_signature(ctxp->cms_ctx, ctxp->signum);
824
			finalize_signatures(ctxp->cms_ctx->signatures,
825
			finalize_signatures(ctxp->cms_ctx->signatures,
825
- 
826
certificate list.
826
certificate list.
827
--
828
src/wincert.c |   22 +++++++++++++++++++++-
827
src/wincert.c |   22 +++++++++++++++++++++-
829
1 file changed, 21 insertions(+), 1 deletion(-)
828
1 file changed, 21 insertions(+), 1 deletion(-)
(-)a/src/wincert.c (-3 / +21 lines)
Lines 42-47 generate_cert_list(SECItem **signatures, int num_signatures, Link Here
42
	*cert_list_size = cl_size;
42
	*cert_list_size = cl_size;
43
43
44
	for (int i = 0; i < num_signatures; i++) {
44
	for (int i = 0; i < num_signatures; i++) {
45
		/* pe-coff 8.2 adds some text that says each cert list
46
		 * entry is 8-byte aligned, so that means we need to align
47
		 * them here. */
48
		if ((intptr_t)data % 8 != 0)
49
			data = (uint8_t *)((intptr_t)data + (8 - ((intptr_t)data % 8)));
45
		struct cert_list_entry *cle = (struct cert_list_entry *)data;
50
		struct cert_list_entry *cle = (struct cert_list_entry *)data;
46
		cle->wc.length = signatures[i]->len +
51
		cle->wc.length = signatures[i]->len +
47
			sizeof (win_certificate);
52
			sizeof (win_certificate);
Lines 170-175 done: Link Here
170
175
171
		iter->n += sizeof (*tmpcert) + length;
176
		iter->n += sizeof (*tmpcert) + length;
172
177
178
		/* each cert list entry must be aligned to an 8-byte
179
		 * boundary */
180
		if (iter->n % 8 != 0)
181
			iter->n += 8 - (iter->n % 8);
182
173
		return 1;
183
		return 1;
174
	}
184
	}
175
}
185
}
Lines 208-215 size_t Link Here
208
get_reserved_sig_space(cms_context *cms, Pe *pe)
218
get_reserved_sig_space(cms_context *cms, Pe *pe)
209
{
219
{
210
	size_t ret = 0;
220
	size_t ret = 0;
211
	for (int i = 0; i < cms->num_signatures; i++)
221
	for (int i = 0; i < cms->num_signatures; i++) {
212
		ret += cms->signatures[i]->len + sizeof (win_certificate);
222
		ret += cms->signatures[i]->len + sizeof (win_certificate);
223
		/* each certificate list entry must be 8-byte aligned,
224
		 * so we need to account for that in our space calculation */
225
		if (ret % 8 != 0)
226
			ret += 8 - (ret % 8);
227
	}
213
	return ret;
228
	return ret;
214
}
229
}
215
230
Lines 238-243 err: Link Here
238
253
239
	size_t res = get_reserved_sig_space(cms, pe);
254
	size_t res = get_reserved_sig_space(cms, pe);
240
255
256
	/* pe-coff 8.2 adds some text that says each cert list entry is
257
	 * 8-byte aligned, so that means we need alignment space here. */
258
	if (res % 8 != 0)
259
		res += 8 - (res % 8);
260
241
	ssize_t ret = res + sig.len + sizeof(win_certificate) -
261
	ssize_t ret = res + sig.len + sizeof(win_certificate) -
242
						available_cert_space(pe);
262
						available_cert_space(pe);
243
263
244
- 
245
Gary Lin)
264
Gary Lin)
246
--
247
libdpe/common.h        |    2 ++
265
libdpe/common.h        |    2 ++
248
libdpe/pe_allocspace.c |    4 ++--
266
libdpe/pe_allocspace.c |    4 ++--
249
src/wincert.c          |   24 ++++++++++--------------
267
src/wincert.c          |   24 ++++++++++--------------
250
3 files changed, 14 insertions(+), 16 deletions(-)
268
3 files changed, 14 insertions(+), 16 deletions(-)
(-)a/libdpe/common.h (+2 lines)
Lines 31-36 Link Here
31
31
32
#define is_64_bit(pe) ((pe)->flags & IMAGE_FILE_32BIT_MACHINE)
32
#define is_64_bit(pe) ((pe)->flags & IMAGE_FILE_32BIT_MACHINE)
33
33
34
#define ALIGNMENT_PADDING(address, align) ((align - (address % align)) % align)
35
34
#define xfree(x) ({if (x) { free(x); x = NULL; }})
36
#define xfree(x) ({if (x) { free(x); x = NULL; }})
35
#define xmunmap(addr, size) ({if (addr) { munmap(addr,size); addr = NULL; }})
37
#define xmunmap(addr, size) ({if (addr) { munmap(addr,size); addr = NULL; }})
36
38
(-)a/libdpe/pe_allocspace.c (-2 / +2 lines)
Lines 86-92 pe_extend_file(Pe *pe, size_t size, uint32_t *new_space, int align) Link Here
86
	void *new = NULL;
86
	void *new = NULL;
87
87
88
	if (align)
88
	if (align)
89
		align = (pe->maximum_size + size) % align;
89
		align = ALIGNMENT_PADDING(pe->maximum_size, align);
90
	int extra = size + align;
90
	int extra = size + align;
91
91
92
	int rc = ftruncate(pe->fildes, pe->maximum_size + extra);
92
	int rc = ftruncate(pe->fildes, pe->maximum_size + extra);
Lines 119-125 pe_allocspace(Pe *pe, size_t size, uint32_t *offset) Link Here
119
119
120
	/* XXX PJFIX TODO: this should try to find space in the already
120
	/* XXX PJFIX TODO: this should try to find space in the already
121
	 * mapped regions. */
121
	 * mapped regions. */
122
	rc = pe_extend_file(pe, size, offset, 0);
122
	rc = pe_extend_file(pe, size, offset, 8);
123
	if (rc < 0)
123
	if (rc < 0)
124
		return -1;
124
		return -1;
125
	return 0;
125
	return 0;
(-)a/src/wincert.c (-16 / +10 lines)
Lines 19-24 Link Here
19
19
20
#include "pesign.h"
20
#include "pesign.h"
21
21
22
#define ALIGNMENT_PADDING(address, align) ((align - (address % align)) % align)
23
22
struct cert_list_entry {
24
struct cert_list_entry {
23
	win_certificate wc;
25
	win_certificate wc;
24
	uint8_t data[];
26
	uint8_t data[];
Lines 32-37 generate_cert_list(SECItem **signatures, int num_signatures, Link Here
32
	for (int i = 0; i < num_signatures; i++) {
34
	for (int i = 0; i < num_signatures; i++) {
33
		cl_size += sizeof (win_certificate);
35
		cl_size += sizeof (win_certificate);
34
		cl_size += signatures[i]->len;
36
		cl_size += signatures[i]->len;
37
		cl_size += ALIGNMENT_PADDING(cl_size, 8);
35
	}
38
	}
36
39
37
	uint8_t *data = malloc(cl_size);
40
	uint8_t *data = malloc(cl_size);
Lines 45-60 generate_cert_list(SECItem **signatures, int num_signatures, Link Here
45
		/* pe-coff 8.2 adds some text that says each cert list
48
		/* pe-coff 8.2 adds some text that says each cert list
46
		 * entry is 8-byte aligned, so that means we need to align
49
		 * entry is 8-byte aligned, so that means we need to align
47
		 * them here. */
50
		 * them here. */
48
		if ((intptr_t)data % 8 != 0)
49
			data = (uint8_t *)((intptr_t)data + (8 - ((intptr_t)data % 8)));
50
		struct cert_list_entry *cle = (struct cert_list_entry *)data;
51
		struct cert_list_entry *cle = (struct cert_list_entry *)data;
51
		cle->wc.length = signatures[i]->len +
52
		cle->wc.length = signatures[i]->len +
53
			ALIGNMENT_PADDING(signatures[i]->len, 8) +
52
			sizeof (win_certificate);
54
			sizeof (win_certificate);
53
		cle->wc.revision = WIN_CERT_REVISION_2_0;
55
		cle->wc.revision = WIN_CERT_REVISION_2_0;
54
		cle->wc.cert_type = WIN_CERT_TYPE_PKCS_SIGNED_DATA;
56
		cle->wc.cert_type = WIN_CERT_TYPE_PKCS_SIGNED_DATA;
55
		memcpy(&cle->data[0], signatures[i]->data,
57
		memcpy(&cle->data[0], signatures[i]->data,
56
					signatures[i]->len);
58
					signatures[i]->len);
57
		data += sizeof (win_certificate) + signatures[i]->len;
59
		data += sizeof (win_certificate) + signatures[i]->len;
60
		data += ALIGNMENT_PADDING(signatures[i]->len, 8);
58
	}
61
	}
59
62
60
	return 0;
63
	return 0;
Lines 175-185 done: Link Here
175
178
176
		iter->n += sizeof (*tmpcert) + length;
179
		iter->n += sizeof (*tmpcert) + length;
177
180
178
		/* each cert list entry must be aligned to an 8-byte
179
		 * boundary */
180
		if (iter->n % 8 != 0)
181
			iter->n += 8 - (iter->n % 8);
182
183
		return 1;
181
		return 1;
184
	}
182
	}
185
}
183
}
Lines 222-229 get_reserved_sig_space(cms_context *cms, Pe *pe) Link Here
222
		ret += cms->signatures[i]->len + sizeof (win_certificate);
220
		ret += cms->signatures[i]->len + sizeof (win_certificate);
223
		/* each certificate list entry must be 8-byte aligned,
221
		/* each certificate list entry must be 8-byte aligned,
224
		 * so we need to account for that in our space calculation */
222
		 * so we need to account for that in our space calculation */
225
		if (ret % 8 != 0)
223
		ret += ALIGNMENT_PADDING(ret, 8);
226
			ret += 8 - (ret % 8);
227
	}
224
	}
228
	return ret;
225
	return ret;
229
}
226
}
Lines 253-266 err: Link Here
253
250
254
	size_t res = get_reserved_sig_space(cms, pe);
251
	size_t res = get_reserved_sig_space(cms, pe);
255
252
256
	/* pe-coff 8.2 adds some text that says each cert list entry is
257
	 * 8-byte aligned, so that means we need alignment space here. */
258
	if (res % 8 != 0)
259
		res += 8 - (res % 8);
260
261
	ssize_t ret = res + sig.len + sizeof(win_certificate) -
253
	ssize_t ret = res + sig.len + sizeof(win_certificate) -
262
						available_cert_space(pe);
254
						available_cert_space(pe);
263
255
256
	/* pe-coff 8.2 adds some text that says each cert list entry is
257
	 * 8-byte aligned, so that means we need alignment space here. */
258
	ret += ALIGNMENT_PADDING(ret, 8);
259
264
	//free(sig.data);
260
	//free(sig.data);
265
261
266
	return ret;
262
	return ret;
267
- 
268
--
269
libdpe/pe_allocspace.c |    2 +-
263
libdpe/pe_allocspace.c |    2 +-
270
1 file changed, 1 insertion(+), 1 deletion(-)
264
1 file changed, 1 insertion(+), 1 deletion(-)
(-)a/libdpe/pe_allocspace.c (-3 / +1 lines)
Lines 119-125 pe_allocspace(Pe *pe, size_t size, uint32_t *offset) Link Here
119
119
120
	/* XXX PJFIX TODO: this should try to find space in the already
120
	/* XXX PJFIX TODO: this should try to find space in the already
121
	 * mapped regions. */
121
	 * mapped regions. */
122
	rc = pe_extend_file(pe, size, offset, 8);
122
	rc = pe_extend_file(pe, size, offset, 16);
123
	if (rc < 0)
123
	if (rc < 0)
124
		return -1;
124
		return -1;
125
	return 0;
125
	return 0;
126
- 
127
--
128
src/pesign.c |    5 ++++-
126
src/pesign.c |    5 ++++-
129
1 file changed, 4 insertions(+), 1 deletion(-)
127
1 file changed, 4 insertions(+), 1 deletion(-)
(-)a/src/pesign.c (-2 / +4 lines)
Lines 440-445 main(int argc, char *argv[]) Link Here
440
	int remove = 0;
440
	int remove = 0;
441
	int daemon = 0;
441
	int daemon = 0;
442
	int fork = 1;
442
	int fork = 1;
443
	int padding = 0;
443
444
444
	char *digest_name = "sha256";
445
	char *digest_name = "sha256";
445
	char *tokenname = "NSS Certificate DB";
446
	char *tokenname = "NSS Certificate DB";
Lines 518-523 main(int argc, char *argv[]) Link Here
518
			"run as a daemon process", NULL },
519
			"run as a daemon process", NULL },
519
		{"nofork", 'N', POPT_ARG_VAL, &fork, 0,
520
		{"nofork", 'N', POPT_ARG_VAL, &fork, 0,
520
			"don't fork when daemonizing", NULL },
521
			"don't fork when daemonizing", NULL },
522
		{"padding", 'P', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN,
523
			&padding, 1, "pad data section", NULL },
521
		POPT_AUTOALIAS
524
		POPT_AUTOALIAS
522
		POPT_AUTOHELP
525
		POPT_AUTOHELP
523
		POPT_TABLEEND
526
		POPT_TABLEEND
Lines 780-786 main(int argc, char *argv[]) Link Here
780
			break;
783
			break;
781
		case GENERATE_DIGEST|PRINT_DIGEST:
784
		case GENERATE_DIGEST|PRINT_DIGEST:
782
			open_input(ctxp);
785
			open_input(ctxp);
783
			generate_digest(ctxp->cms_ctx, ctxp->inpe, 0);
786
			generate_digest(ctxp->cms_ctx, ctxp->inpe, padding);
784
			print_digest(ctxp);
787
			print_digest(ctxp);
785
			break;
788
			break;
786
		/* generate a signature and save it in a separate file */
789
		/* generate a signature and save it in a separate file */
787
- 

Return to bug 808594