Skip to content

Commit 6bc9105

Browse files
committed
file format fixes
1 parent 9b2df1c commit 6bc9105

File tree

5 files changed

+97
-103
lines changed

5 files changed

+97
-103
lines changed

CHANGELOG.md

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
1-
=== 2.0 (2018-xx-xx)
1+
### 2.0 (2018-xx-xx)
22

33
- ported to OpenSSL 1.1.x
44
- ported to SoftHSM2
55
- add support for pkcs11-based hardware tokens
6-
(Patch from Leif Johansson)
6+
(Patch from Leif Johansson)
77
- improved error reporting of timestamping errors
8-
(Patch from Carlo Teubner)
8+
(Patch from Carlo Teubner)
99

10-
=== 1.7.1 (2014-07-11)
10+
### 1.7.1 (2014-07-11)
1111

1212
- MSI: added -add-msi-dse option
13-
(Patch from Mikkel Krautz)
13+
(Patch from Mikkel Krautz)
1414
- MSI: fix build when GSF_CAN_READ_MSI_METADATA defined
15-
(Patch from Mikkel Krautz)
15+
(Patch from Mikkel Krautz)
1616

17-
=== 1.7 (2014-07-10)
17+
### 1.7 (2014-07-10)
1818

1919
- add support for nested signatures
20-
(Patch from Mikkel Krautz)
20+
(Patch from Mikkel Krautz)
2121
- fix compilation problem with OpenSSL < 1.0.0
2222
- added OpenSSL linkage exception to license
2323

24-
=== 1.6 (2014-01-21)
24+
### 1.6 (2014-01-21)
2525

2626
- add support for reading password from file
2727
- add support for asking for password (on systems that
2828
provide support for it)
2929
- add support for compiling and running on Windows
30-
(Patch from Heiko Hund)
30+
(Patch from Heiko Hund)
3131
- fix compilation without curl
32-
(Fix from Heiko Hund)
32+
(Fix from Heiko Hund)
3333
- added support for giving multiple timestamp servers
3434
as arguments (first one that succeeds will be used)
3535
- signatures on hierarchical MSI files were broken
36-
(Fix from Mikkel Krautz)
36+
(Fix from Mikkel Krautz)
3737
- MSI: Add support for MsiDigitalSignatureEx signature
38-
(Patch from Mikkel Krautz)
38+
(Patch from Mikkel Krautz)
3939
- add support for adding additional/cross certificates
4040
through -ac option
41-
(Thanks to Lars Munch for idea + testing)
41+
(Thanks to Lars Munch for idea + testing)
4242
- MSI: Add support for signature extract/remove/verify
43-
(Patches from Mikkel Krautz)
43+
(Patches from Mikkel Krautz)
4444
- PE/MSI: Implement -require-leaf-hash for verify.
45-
(Patch from Mikkel Krautz)
45+
(Patch from Mikkel Krautz)
4646

47-
=== 1.5.2 (2013-03-13)
47+
### 1.5.2 (2013-03-13)
4848

4949
- added support for signing with SHA-384 and SHA-512
5050
- added support for page hashing (-ph option)
5151

52-
=== 1.5.1 (2013-03-12)
52+
### 1.5.1 (2013-03-12)
5353

5454
- forgot to bump version number...
5555

56-
=== 1.5 (2013-03-12)
56+
### 1.5 (2013-03-12)
5757

5858
- added support for signing MSI files (patch from Marc-André Lureau)
5959
- calculate correct PE checksum instead of setting it to 0
60-
(patch from Roland Schwingel)
60+
(patch from Roland Schwingel)
6161
- added support for RFC3161 timestamping (-ts option)
6262
- added support for extracting/removing/verifying signature on PE files
6363
- fixed problem with not being able to decode timestamps with no newlines
@@ -66,26 +66,25 @@
6666
- added support for reading certificates from PEM files
6767
- renamed program option: -spc to -certs (old option name still valid)
6868

69-
70-
=== 1.4 (2011-08-12)
69+
### 1.4 (2011-08-12)
7170

7271
- improved build system (patch from Alon Bar-Lev)
7372
- support reading cert+key from PKCS12 file (patch from Alon Bar-Lev)
7473
- support reading key from PEM file
7574
- added support for sha1/sha256 - default hash is now sha1
7675
- added flag for commercial signing (default is individual)
7776

78-
=== 1.3.1 (2009-08-07)
77+
### 1.3.1 (2009-08-07)
7978

8079
- support signing of 64-bit executables (fix from Paul Kendall)
8180

82-
=== 1.3 (2008-01-31)
81+
### 1.3 (2008-01-31)
8382

8483
- fixed padding problem (fix from Ryan Rubley)
8584
- allow signing of already signed files (fix from Ryan Rubley)
8685
- added Ryan Rubley's PVK-to-DER guide into the README
8786

88-
=== 1.2 (2005-01-21)
87+
### 1.2 (2005-01-21)
8988

9089
- autoconf:ed (Thanks to Roy Keene)
9190
- added documentation
@@ -94,6 +93,6 @@
9493
- compiles without curl, which means no timestamping
9594
- version number output
9695

97-
=== 1.1 (2005-01-19)
96+
### 1.1 (2005-01-19)
9897

9998
- Initial release

LICENSE.txt

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
1-
/*
2-
OpenSSL based Authenticode signing for PE/MSI/Java CAB files.
1+
OpenSSL based Authenticode signing for PE/MSI/Java CAB files.
32

4-
Copyright (C) 2005-2014 Per Allansson <[email protected]>
5-
Copyright (C) 2018 Michał Trojnara <[email protected]>
3+
Copyright (C) 2005-2014 Per Allansson <[email protected]>
4+
Copyright (C) 2018 Michał Trojnara <[email protected]>
65

7-
This program is free software: you can redistribute it and/or modify
8-
it under the terms of the GNU General Public License as published by
9-
the Free Software Foundation, either version 3 of the License, or
10-
(at your option) any later version.
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
1110

12-
This program is distributed in the hope that it will be useful,
13-
but WITHOUT ANY WARRANTY; without even the implied warranty of
14-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15-
GNU General Public License for more details.
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
1615

17-
You should have received a copy of the GNU General Public License
18-
along with this program. If not, see <http://www.gnu.org/licenses/>.
19-
20-
In addition, as a special exception, the copyright holders give
21-
permission to link the code of portions of this program with the
22-
OpenSSL library under certain conditions as described in each
23-
individual source file, and distribute linked combinations
24-
including the two.
25-
You must obey the GNU General Public License in all respects
26-
for all of the code used other than OpenSSL. If you modify
27-
file(s) with this exception, you may extend this exception to your
28-
version of the file(s), but you are not obligated to do so. If you
29-
do not wish to do so, delete this exception statement from your
30-
version. If you delete this exception statement from all source
31-
files in the program, then also delete it here.
32-
*/
16+
You should have received a copy of the GNU General Public License
17+
along with this program. If not, see <http://www.gnu.org/licenses/>.
3318

19+
In addition, as a special exception, the copyright holders give
20+
permission to link the code of portions of this program with the
21+
OpenSSL library under certain conditions as described in each
22+
individual source file, and distribute linked combinations
23+
including the two.
24+
You must obey the GNU General Public License in all respects
25+
for all of the code used other than OpenSSL. If you modify
26+
file(s) with this exception, you may extend this exception to your
27+
version of the file(s), but you are not obligated to do so. If you
28+
do not wish to do so, delete this exception statement from your
29+
version. If you delete this exception statement from all source
30+
files in the program, then also delete it here.

README.md

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
osslsigncode
22
============
33

4-
5-
== WHAT IS IT?
4+
## WHAT IS IT?
65

76
osslsigncode is a small tool that implements part of the functionality
87
of the Microsoft tool signtool.exe - more exactly the Authenticode
98
signing and timestamping. But osslsigncode is based on OpenSSL and cURL,
109
and thus should be able to compile on most platforms where these exist.
1110

12-
13-
== WHY?
11+
## WHY?
1412

1513
Why not use signtool.exe? Because I don't want to go to a Windows
1614
machine every time I need to sign a binary - I can compile and build
@@ -19,26 +17,24 @@ since the signtool.exe makes good use of the CryptoAPI in Windows, and
1917
these APIs aren't (yet?) fully implemented in Wine, so the signtool.exe
2018
tool would fail. And, so, osslsigncode was born.
2119

22-
23-
== WHAT CAN IT DO?
20+
## WHAT CAN IT DO?
2421

2522
It can sign and timestamp PE (EXE/SYS/DLL/etc), CAB and MSI files. It supports
2623
the equivalent of signtool.exe's "-j javasign.dll -jp low", i.e. add a
2724
valid signature for a CAB file containing Java files. It supports getting
2825
the timestamp through a proxy as well. It also supports signature verification,
2926
removal and extraction.
3027

31-
32-
== INSTALLATION
28+
## INSTALLATION
3329

3430
The usual way:
35-
31+
```
3632
./configure
3733
make
3834
make install
35+
```
3936

40-
41-
== USAGE
37+
## USAGE
4238

4339
Before you can sign a file you need a Software Publishing
4440
Certificate (spc) and a corresponding private key.
@@ -54,39 +50,39 @@ key which must be a key file in DER or PEM format, or if osslsigncode was
5450
compiled against OpenSSL 1.0.0 or later, in PVK format.
5551

5652
To sign a PE or MSI file you can now do:
57-
53+
```
5854
osslsigncode sign -certs <cert-file> -key <der-key-file> \
59-
-n "Your Application" -i http://www.yourwebsite.com/ \
60-
-in yourapp.exe -out yourapp-signed.exe
61-
55+
-n "Your Application" -i http://www.yourwebsite.com/ \
56+
-in yourapp.exe -out yourapp-signed.exe
57+
```
6258
or if you are using a PEM or PVK key file with a password together
6359
with a PEM certificate:
64-
60+
```
6561
osslsigncode sign -certs <cert-file> \
66-
-key <key-file> -pass <key-password> \
67-
-n "Your Application" -i http://www.yourwebsite.com/ \
68-
-in yourapp.exe -out yourapp-signed.exe
69-
62+
-key <key-file> -pass <key-password> \
63+
-n "Your Application" -i http://www.yourwebsite.com/ \
64+
-in yourapp.exe -out yourapp-signed.exe
65+
```
7066
or if you want to add a timestamp as well:
71-
67+
```
7268
osslsigncode sign -certs <cert-file> -key <key-file> \
73-
-n "Your Application" -i http://www.yourwebsite.com/ \
74-
-t http://timestamp.verisign.com/scripts/timstamp.dll \
75-
-in yourapp.exe -out yourapp-signed.exe
76-
69+
-n "Your Application" -i http://www.yourwebsite.com/ \
70+
-t http://timestamp.verisign.com/scripts/timstamp.dll \
71+
-in yourapp.exe -out yourapp-signed.exe
72+
```
7773
You can use a certificate and key stored in a PKCS#12 container:
78-
74+
```
7975
osslsigncode sign -pkcs12 <pkcs12-file> -pass <pkcs12-password> \
80-
-n "Your Application" -i http://www.yourwebsite.com/ \
81-
-in yourapp.exe -out yourapp-signed.exe
82-
76+
-n "Your Application" -i http://www.yourwebsite.com/ \
77+
-in yourapp.exe -out yourapp-signed.exe
78+
```
8379
To sign a CAB file containing java class files:
84-
80+
```
8581
osslsigncode sign -certs <cert-file> -key <key-file> \
86-
-n "Your Application" -i http://www.yourwebsite.com/ \
87-
-jp low \
88-
-in yourapp.cab -out yourapp-signed.cab
89-
82+
-n "Your Application" -i http://www.yourwebsite.com/ \
83+
-jp low \
84+
-in yourapp.cab -out yourapp-signed.cab
85+
```
9086
Only the 'low' parameter is currently supported.
9187

9288
You can check that the signed file is correct by right-clicking
@@ -95,9 +91,7 @@ and then choose the signature from the list, and click on
9591
Details. You should then be presented with a dialog that says
9692
amongst other things that "This digital signature is OK".
9793

98-
99-
100-
== CONVERTING FROM PVK TO DER
94+
## CONVERTING FROM PVK TO DER
10195

10296
(This guide was written by Ryan Rubley)
10397

@@ -116,22 +110,24 @@ use instead of your *.spc file. It's the same basic thing, in a different format
116110
For your PVK file, you will need to download a little utility called
117111
PVK.EXE. This can currently be downloaded at
118112

119-
http://support.globalsign.net/en/objectsign/PVK.zip
113+
http://support.globalsign.net/en/objectsign/PVK.zip
120114

121-
Run: pvk -in foo.pvk -nocrypt -out foo.pem
115+
Run:
116+
```
117+
pvk -in foo.pvk -nocrypt -out foo.pem
118+
```
122119

123120
This will convert your PVK file to a PEM file.
124121
From there, you can copy the PEM file to a Linux box, and run:
125-
122+
```
126123
openssl rsa -outform der -in foo.pem -out foo.der
127-
124+
```
128125
This will convert your PEM file to a DER file.
129126

130127
You need the *.p7b and *.der files to use osslsigncode, instead of your
131128
*.spc and *.pvk files.
132129

133-
134-
== BUGS, QUESTIONS etc.
130+
## BUGS, QUESTIONS etc.
135131

136132
Send an email to [email protected]
137133

README.unauthblob.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# This is NOT the official repo for osslsigncode
1+
# This is NOT the official repo for osslsigncode
2+
23
This project was copied from osslsigncode 1.7.1 to apply some patches for compiling with cygwin and being able to add unauthenticated blobs. The official source for the project is at: http://sourceforge.net/projects/osslsigncode/
34

45
## Features added
6+
57
Adds the argument "-addUnauthenticatedBlob" to add a 1024 byte unauthenticated blob of data to the signature in the same area as the timestamp. This can be used while signing, while timestamping (new `add` command added to allow just time-stamping, after a file has been code signed, or by itself.
68

79
Examples:
@@ -34,10 +36,9 @@ This technique (but not this project) is used by Dropbox, GoToMeeting, and Summi
3436
- https://tech.dropbox.com/2014/08/tech-behind-dropboxs-new-user-experience-for-mobile/
3537
- http://blogs.msdn.com/b/ieinternals/archive/2014/09/04/personalizing-installers-using-unauthenticated-data-inside-authenticode-signed-binaries.aspx
3638

37-
3839
## WARNING
39-
The capability this adds can allow you to do dumb things. Be very careful with what you put in the unauthenticated blob, as an attacker could modify this. Do NOT under any circumstances put a URL here that you will use to download an additional file. If you do do that, you would need to check the newly downloaded file is code signed AND that it has been signed with your cert AND that it is the version you expect. You should consider using asymmetrical encryption for the data you put in the blob, such that the executable contains the public key to decrypt the data. Basically, be VERY careful.
4040

41+
The capability this adds can allow you to do dumb things. Be very careful with what you put in the unauthenticated blob, as an attacker could modify this. Do NOT under any circumstances put a URL here that you will use to download an additional file. If you do do that, you would need to check the newly downloaded file is code signed AND that it has been signed with your cert AND that it is the version you expect. You should consider using asymmetrical encryption for the data you put in the blob, such that the executable contains the public key to decrypt the data. Basically, be VERY careful.
4142

4243
## Compiling under cygwin
4344

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# softhsm-example-token
12

23
This directory contains a basic setup for testing pkcs11-support. If you get
34
this to work you have a decent chance of using your real HSM or hardware token.
@@ -10,9 +11,9 @@ You need the following packages (ubuntu/debian names):
1011
Type 'make' to generate a softhsm token with a test-key on id a1b2 with PIN-code
1112
"secret1". To use this token with osslsigncode try something like this (from this
1213
directory):
13-
14-
../../osslsigncode sign \
14+
```
15+
../../osslsigncode sign \
1516
-pkcs11engine /usr/lib/engines-1.1/pkcs11.so \
1617
-pkcs11module /usr/lib/libsofthsm2.so -key a1b2 -certs test.crt ...
17-
18+
```
1819
Use 'secret1' as the password at the prompt.

0 commit comments

Comments
 (0)