Skip to content

Commit d5e2c78

Browse files
committed
crypto providers structure
heading levels fixed some sections moved minor edits
1 parent f56a4ec commit d5e2c78

File tree

4 files changed

+79
-70
lines changed

4 files changed

+79
-70
lines changed

docs/crypto-providers/cryptoki.md

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ For Cryptoki-based signing, tool setup can be complex. Unlike the KSP/CSP provid
110110
111111
If your signing tool does not provide guidance for using Cryptoki libraries, you probably need a solid understanding of the specific tool chain to configure it. For better results, please also refer to [signing flow](/crypto-providers#flow).
112112
113-
## OpenSSL {#openssl}
113+
## Common code signing tools
114+
115+
### OpenSSL {#openssl}
114116
115117
_[OpenSSL]_ is a toolkit that provides a range of cryptographic operations, including signing.
116118
@@ -119,9 +121,9 @@ _[OpenSSL]_ is a toolkit that provides a range of cryptographic operations, incl
119121
>
120122
> Only latest OpenSSL 1.1 and 3.x versions are supported. For Linux, see also the notes in [supported Linux distributions](#supported-linux-distributions).
121123
122-
### Setup {#openssl-setup}
124+
#### Setup {#openssl-setup}
123125
124-
#### Install the `libp11` OpenSSL engine
126+
##### Install the `libp11` OpenSSL engine
125127
126128
_OpenSSL_ cannot directly communicate with a Cryptoki library. Instead, the [OpenSC pkcs11 OpenSSL engine (`libp11`)](https://github.com/OpenSC/libp11) can be used as adapter between OpenSSL and the SignPath Cryptoki library.
127129
@@ -132,7 +134,7 @@ _OpenSSL_ cannot directly communicate with a Cryptoki library. Instead, the [Ope
132134
133135
**Linux:** Install the OpenSC pkcs11 engine via your package manager (e.g. `apt-get install libengine-pkcs11-openssl` on Debian-based or `dnf install openssl-pkcs11` on RedHat-based distros).
134136
135-
#### Configure OpenSSL
137+
##### Configure OpenSSL
136138
137139
Set the following variables:
138140
@@ -160,7 +162,7 @@ export PKCS11_MODULE_PATH="/path/to/libSignPath.Cryptoki.so"
160162
openssl dgst -engine pkcs11 -keyform engine -sign "pkcs11:id=$ProjectSlug/$SigningPolicySlug;type=private;pin-value=CONFIG" -sha256 -out "artifact.sig" "artifact.bin"
161163
~~~
162164
163-
#### Alternative OpenSSL configuration via `OPENSSL_CONF`
165+
##### Alternative OpenSSL configuration via `OPENSSL_CONF`
164166
165167
An _alternative_ to using the `OPENSSL_ENGINES`/`PKCS11_MODULE_PATH` env variables is to use create a `openssl-signpath.cnf` file as follows and set the `OPENSSL_CONF` env to point to the configuration file.
166168
@@ -182,7 +184,7 @@ init = 0
182184
PIN = CONFIG
183185
~~~
184186
185-
### Invocation {#openssl-invocation}
187+
#### Invocation {#openssl-invocation}
186188
187189
_OpenSSL_ provides a variety of commands that can be used for signing. In this section, a few of them are outlined.
188190
@@ -205,7 +207,7 @@ Generally, all commands require the following parameters to work with the SignPa
205207
| `-inkey` | `pkcs11:id=$ProjectSlug/$SigningPolicySlug;type=private;pin-value=CONFIG` | A PKCS #11 URI including _Project_ and _Signing Policy_ slug, see also [Cryptoki parameters](#cryptoki-parameters).
206208
{: .break-column-2 }
207209
208-
#### openssl dgst
210+
##### openssl dgst
209211
210212
The _[dgst][openssl-dsgt]_ command calculates digests of files, but can also be used to create and verify signatures.
211213
@@ -220,7 +222,7 @@ openssl dgst -engine pkcs11 -keyform engine -sign "pkcs11:id=$ProjectSlug/$Signi
220222
>
221223
> The following digests are supported: `sha256`, `sha384`, `sha512`
222224
223-
#### openssl pkeyutl
225+
##### openssl pkeyutl
224226
225227
The _[pkeyutl][openssl-pkeyutl]_ command performs low-level cryptographic operations, such as signing.
226228
@@ -245,7 +247,7 @@ Sample: sign the hash code in `artifact.hash.bin` using PSS padding, write the s
245247
openssl pkeyutl -engine pkcs11 -keyform engine -inkey "pkcs11:id=$ProjectSlug/$SigningPolicySlug;type=private;pin-value=CONFIG" -sign -in "artifact.hash.bin" -out "artifact.sig" -pkeyopt digest:sha256 -pkeyopt rsa_padding_mode:pss -pkeyopt rsa_pss_saltlen:-1 -pkeyopt rsa_mgf1_md:sha256
246248
~~~
247249
248-
#### openssl cms
250+
##### openssl cms
249251
250252
The _[cms][openssl-cms]_ command can be used to create embedded S/MIME or detached PEM/DER signatures. It uses the Cryptographic Message Syntax format (CMS, formerly known as PKCS#7).
251253
@@ -261,7 +263,7 @@ Sample: sign the file `artifact.bin` using `certificate.pem`, write the detached
261263
openssl cms -engine pkcs11 -signer "certificate.pem" -inkey "pkcs11:id=$ProjectSlug/$SigningPolicySlug;type=private;pin-value=CONFIG" -keyform engine -sign -binary -in "artifact.bin" -noattr -out "artifact.sig" -outform PEM
262264
~~~
263265
264-
## osslsigncode {#osslsigncode}
266+
### osslsigncode {#osslsigncode}
265267
266268
_[osslsigncode]_ is a tool that allows applying Windows Authenticode signatures on Linux systems using OpenSSL. Accordingly, it also requires an OpenSC pkcs11 OpenSSL engine installation. See the [OpenSSL](#openssl) section for details.
267269
@@ -270,15 +272,15 @@ _[osslsigncode]_ is a tool that allows applying Windows Authenticode signatures
270272
>
271273
> Only osslsigncode 2.x or higher is supported. Also see the notes in [supported Linux distributions](#supported-linux-distributions) regarding the supported OpenSSL versions.
272274
273-
### Setup {#osslsigncode-setup}
275+
#### Setup {#osslsigncode-setup}
274276
275277
`osslsigncode` requires the X.509 certificate corresponding to the SignPath Project and Signing Policy to be downloaded from SignPath and converted to _PEM format_. You can convert the certificate using OpenSSL via the following example.
276278
277279
~~~ powershell
278280
openssl x509 -inform DER -in "certificate.cer" -outform PEM -out "certificate.pem"
279281
~~~
280282
281-
### Invocation {#osslsigncode-invocation}
283+
#### Invocation {#osslsigncode-invocation}
282284
283285
~~~ powershell
284286
osslsigncode sign `
@@ -303,11 +305,11 @@ osslsigncode sign `
303305
> ./RunScenario.sh -Scenario osslsigncode -OrganizationId "$OrganizationId" -ApiToken "$ApiToken" -ProjectSlug "hash-signing" -SigningPolicySlug "test-signing"
304306
> ```
305307
306-
## OpenSC pkcs11-tool (Linux) {#opensc-pkcs11-tool}
308+
### OpenSC pkcs11-tool (Linux) {#opensc-pkcs11-tool}
307309
308310
The [OpenSC](https://github.com/OpenSC/OpenSC) [`pkcs11-tool`](https://linux.die.net/man/1/pkcs11-tool) utility can be used to troubleshoot PKCS #11 modules (e.g. listing all available objects or supported algorithms) but also can be used to read certificates/public keys and to perform signing operations.
309311
310-
### Setup {#opensc-pkcs11-tool-setup}
312+
#### Setup {#opensc-pkcs11-tool-setup}
311313
312314
{:.panel.info}
313315
> **`pkcs11-tool` before version 0.23**
@@ -316,7 +318,7 @@ The [OpenSC](https://github.com/OpenSC/OpenSC) [`pkcs11-tool`](https://linux.die
316318
>
317319
> _Background: `pkcs11-tool` used to open the Cryptoki session in a read/write mode (see [GitHub issue #2182](https://github.com/OpenSC/OpenSC/issues/2182)) and therefore fails with `PKCS11 function C_OpenSession failed: rv = CKR_TOKEN_WRITE_PROTECTED`. This flag enables compatibility with these earlier versions._
318320
319-
### Invocation {#opensc-pkcs11-tool-invocation}
321+
#### Invocation {#opensc-pkcs11-tool-invocation}
320322
321323
{:.panel.tip}
322324
> **Tip**
@@ -328,7 +330,7 @@ The [OpenSC](https://github.com/OpenSC/OpenSC) [`pkcs11-tool`](https://linux.die
328330
> ```
329331
>
330332
331-
#### Common parameters
333+
##### Common parameters
332334
333335
~~~ powershell
334336
pkcs11-tool --module $LibSignPathCryptokiPath --pin CONFIG ...
@@ -339,15 +341,15 @@ pkcs11-tool --module $LibSignPathCryptokiPath --pin CONFIG ...
339341
| `--module` | `/path/to/libSignPath.Cryptoki.so` | Path to the SignPath Cryptoki library
340342
| `--pin` | `CONFIG` or `$OrganizationId:$ApiToken` | See [PIN parameter](#cryptoki-parameters)
341343
342-
#### Listing available PKCS #11 objects
344+
##### Listing available PKCS #11 objects
343345
344346
The following command lists available objects, which corresponds to the list of signing policies for which the authenticated user has _Submitter_ permissions.
345347
346348
~~~ powershell
347349
pkcs11-tool --module $LibSignPathCryptokiPath --pin CONFIG --list-objects
348350
~~~
349351
350-
#### Signing operation
352+
##### Signing operation
351353
352354
The following sample call shows an RSA signing operation using PSS padding and SHA-256.
353355
@@ -364,11 +366,11 @@ pkcs11-tool --module $LibSignPathCryptokiPath --pin CONFIG `
364366
| `--label` | `$ProjectSlug/$SigningPolicySlug` | _Project_ and _Signing Policy_ slugs, separated by a forward slash
365367
| `--input-file` | `/path/to/hash.bin` | File containing a hash in _binary_ form
366368
367-
## Java jarsigner {#jarsigner}
369+
### Java jarsigner {#jarsigner}
368370
369371
The [`jarsigner`](https://docs.oracle.com/en/java/javase/17/docs/specs/man/jarsigner.html) command signs and verifies Java archives (e.g. JAR, WAR, EAR). It is included with the Java Development Kit (JDK).
370372
371-
### Setup {#jarsigner-setup}
373+
#### Setup {#jarsigner-setup}
372374
373375
1. Configure the SunPKCS11 Provider
374376
* OpenJDK: the provider is configured automatically

docs/crypto-providers/gpg.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ description: Creating GPG signatures with SignPath
1010

1111
[GNU Privacy Guard](https://gnupg.org/), also known as GPG or GnuPG, is an Open Source implementation of the OpenPGP standard. This section provides information about using GPG with SignPath, as well as some code signing tools that build on GPG.
1212

13-
## Terminology
13+
### Terminology
1414

1515
GPG uses various terms for certificates. We use the term **_GPG key_** in our GPG documentation, but keep in mind that other parts of the SignPath documentation will use the general term _certificate_. See [Managing Certificates](/managing-certificates#certificate-types) for more information.
1616

@@ -49,6 +49,8 @@ See [SignPath Crypto Providers](/crypto-providers/#crypto-provider-configuration
4949

5050
## Signing code with GPG
5151

52+
### Common signing tools
53+
5254
The [Linux samples] contain complete example scripts (including all preparation steps) to sign and verify files using the following formats and tools:
5355

5456
| Format | Signing invocation | Sample script | Note

docs/crypto-providers/macos.md

Lines changed: 53 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ show_toc: 3
66
description: SignPath macOS CryptoTokenKit Crypto Provider
77
---
88

9-
## General instructions
9+
## Setup
1010

1111
This section provides information to use SignPath with any tool that supports macOS CryptoTokenKit.
1212

@@ -22,13 +22,13 @@ Simply copy-deploy the `SignPathCryptoTokenKit.app` application to the target sy
2222

2323
See [SignPath Crypto Providers](/crypto-providers/#crypto-provider-configuration) for general configuration options.
2424

25-
### Background
25+
## Usage
2626

27-
macOS allows CryptoTokenKit extensions to be registered in the system. Through these extensions, key material and certificates can be provided. An extension is only available while the application that provides the extension is running. Therefore, before calling signing tools like `codesign`, the `SignPathCryptoTokenKit.app` needs to be started.
27+
### General usage
2828

29-
### Usage
29+
#### Enable the CryptoTokenKit extension
3030

31-
The `SignPathCryptoTokenKit.app` application loads all available certificates for the given parameters and makes them avaialble in the macOS keychain through a CryptoTokenKit extension. The application supports the following parameters (all of them are optional):
31+
Start the `SignPathCryptoTokenKit.app` application to load certificates into the macOS keychain through a CryptoTokenKit extension. The application supports the following parameters (all optional):
3232

3333
| Parameter | Value | Default | Description
3434
|-------------------------|------------------------------|-------------------------------|---------------------------------------
@@ -49,6 +49,11 @@ open SignPathCryptoTokenKit.app --args \
4949
--organization-id 0241f767-69c8-448d-ad5e-8bd453916068
5050
~~~
5151

52+
{:.panel.info}
53+
> Background
54+
>
55+
> SignPath uses the CryptoTokenKit extension mechanism to provide keys and certificates can be provided. The application that registers the extension must be running. Therefore, before calling signing tools like `codesign`, the `SignPathCryptoTokenKit.app` needs to be started.
56+
5257
#### Project and signing policy {#usage-project-signing-policy}
5358

5459
Identify a specific _Signing Policy_ by specifying _Project_ and _Signing Policy_ slugs. The SignPath CryptoTokenKit provider will select that policy's certificate.
@@ -62,48 +67,7 @@ Default values can be provided as [configuration values](index#crypto-provider-c
6267
>
6368
> This works fine if a certificate clearly identifies a single Signing Policy. However, if a certificate is referenced by more than one available _Signing Policy_, using it will result in an ambiguous reference error.
6469
65-
### Troubleshooting
66-
67-
Loading the certificates and making them available in the macOS keychain can take up to 20 seconds.
68-
69-
#### Logs
70-
71-
Unless specified otherwise, the log files are stored in `~/Library/Logs/SignPathCryptoTokenKit/` and `~/Library/Containers/io.signpath.apps.CryptoTokenKit/Data/Library/Logs/ctk/` respectively.
72-
73-
#### Useful commands:
74-
75-
The following commands are helpful to make sure the setup is correct:
76-
77-
Using the `security` command, the registered smart cards can be listed. This list should contain an entry `io.signpath.apps.SignPathCryptoTokenKit.ctk:<identifier>`
78-
~~~bash
79-
security list-smartcard
80-
~~~
81-
82-
Using the `pluginkit` tool, the registration of the token driver can be verified. The command lists all registered tokens and should also list `io.signpath.apps.CryptoTokenKit($Version)`.
83-
84-
~~~bash
85-
pluginkit -m -v -p com.apple.ctk-tokens
86-
~~~
87-
88-
The smartcard service on macOS sometimes has issues. If the certificates cannot be loaded, the service can be restarted by running the following command:
89-
90-
~~~bash
91-
killall ctkd
92-
~~~
93-
94-
{:.panel.info}
95-
> **Info: Updated intermediate certificate**
96-
>
97-
> When creating a certificate in the Apple Developer portal, the intermediate certificate can be selected. On some machines, the new intermediate certificate is still missing. You can download it [here](https://www.apple.com/certificateauthority/DeveloperIDG2CA.cer).
98-
99-
{:.panel.warning}
100-
> **Warning: Produce correct timestamps**
101-
>
102-
> When using codesign (or any other signing tool) directly, you are responsible for correct time stamping. See [Timestamps](/crypto-providers#timestamps)
103-
104-
[codesign]: https://developer.apple.com/library/archive/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html
105-
106-
## codesign {#codesign}
70+
### codesign {#codesign}
10771

10872
_[codesign]_ is a command line tool by Apple.
10973

@@ -124,7 +88,7 @@ codesign -s MyCertificateSubjectName MyApp.app
12488
>
12589
> `codesign` requires an "Apple Developer Application" certificate.
12690
127-
## productsign {#productsign}
91+
### productsign {#productsign}
12892

12993
_productsign_ is a command line tool by Apple.
13094

@@ -144,3 +108,44 @@ productsign --timestamp --sign "XX6NBJ3UUF" MyInstaller.pkg MyInstaller-signed.p
144108
> **Info: Using the right certificate**
145109
>
146110
> `productsign` requires an "Apple Developer Installer" certificate.
111+
112+
## Troubleshooting
113+
114+
Loading the certificates and making them available in the macOS keychain can take up to 20 seconds.
115+
116+
### Logs
117+
118+
Unless specified otherwise, the log files are stored in `~/Library/Logs/SignPathCryptoTokenKit/` and `~/Library/Containers/io.signpath.apps.CryptoTokenKit/Data/Library/Logs/ctk/` respectively.
119+
120+
### Useful commands
121+
122+
The following commands are helpful to make sure the setup is correct:
123+
124+
Using the `security` command, the registered smart cards can be listed. This list should contain an entry `io.signpath.apps.SignPathCryptoTokenKit.ctk:<identifier>`
125+
~~~bash
126+
security list-smartcard
127+
~~~
128+
129+
Using the `pluginkit` tool, the registration of the token driver can be verified. The command lists all registered tokens and should also list `io.signpath.apps.CryptoTokenKit($Version)`.
130+
131+
~~~bash
132+
pluginkit -m -v -p com.apple.ctk-tokens
133+
~~~
134+
135+
The smartcard service on macOS sometimes has issues. If the certificates cannot be loaded, the service can be restarted by running the following command:
136+
137+
~~~bash
138+
killall ctkd
139+
~~~
140+
141+
{:.panel.info}
142+
> **Info: Updated intermediate certificate**
143+
>
144+
> When creating a certificate in the Apple Developer portal, the intermediate certificate can be selected. On some machines, the new intermediate certificate is still missing. You can download it [here](https://www.apple.com/certificateauthority/DeveloperIDG2CA.cer).
145+
146+
{:.panel.warning}
147+
> **Warning: Produce correct timestamps**
148+
>
149+
> When using codesign (or any other signing tool) directly, you are responsible for correct time stamping. See [Timestamps](/crypto-providers#timestamps)
150+
151+
[codesign]: https://developer.apple.com/library/archive/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html

docs/crypto-providers/rest-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ curl -H "Authorization: Bearer $API_TOKEN" \
8484

8585
## Retrieve Signing Policy details {#retrieve-signing-policy-details}
8686

87-
Use `GET {{site.sp_api_url}}/v1/$OrganizationId/Cryptoki/MySigningPolicies?``projectSlug=$Project&signingPolicySlug=$SigningPolicy` to get information about the signing plicy, including the X.509 certificate and RSA key parameters.
87+
Use `GET {{site.sp_api_url}}/v1/$OrganizationId/Cryptoki/MySigningPolicies?``projectSlug=$Project&signingPolicySlug=$SigningPolicy` to get information about the signing policy, including the X.509 certificate and RSA key parameters.
8888

8989
(If project and signing policy are not specified, this API returns all signing policies where user identified by the API token is assigned as _Submitter_.)
9090

0 commit comments

Comments
 (0)