1 .TH zpm-sign 8 2019-03-09 "ZPM 0.7.0"
3 zpm-sign \- manage package signatures
22 .BI -I " inputhexstring"
28 .BI -m " messagestring"
33 manages signatures on zpm packages. It can generate signing keys,
34 sign files, and verify signatures. The ed25519 algorithms are
35 used exclusively, and all the signature code is taken from the
38 Private keys are potentially encrypted with chacha20 before storing
41 Signatures are always detached signatures.
43 The \-k option is used to specify a key. Keys are looked for
44 in the keyring file (or taken literally from the command line
45 if the \-h option is given).
46 The \-i option can be used to specify a
47 key file to look for a key in. If the \-k option is given, or the ZPM_KEY
48 environment variable is set, a key which matches that string in the id portion
49 of the key is looked for, otherwise the first secret key found is used. If the
50 \-i option is not given, a key will be searched for in a file given with the
51 ZPM_KEYFILE environment variable or in ~/.zpm/key Alternatively, a hex encoded
52 private key can be specified directly with the \-I option. If several of these
53 options apply, The \-I option takes precedence. I.e. command line beats
54 environment variables beats defaults.
56 If the private key needs a passphrase, it can be specified via the \-p
57 option or the ZPM_KEYPASS environment variable, neither of which
58 is secure. Otherwise, if /dev/tty can be opened, zpm-sign will
59 attempt to ask for a passphrase.
61 For signing or generating a public key, a private key is looked for, and if not
62 specified, the first one found in the keyring file is used.
64 For signature verification, no key needs to be specified as the public
65 key is contained in the signature.
69 Inputs to a regular signature are:
70 .TP the secret key used to sign the message,
71 See above for methods to specify a secret key.
74 Defaults to the current time read from the system clock.
75 Can be specified with the \-T option.
78 Defaults to never. Can be specified with the \-E optino.
80 The message to be signed.
81 Is read from stdin, a command line argument, or the \-m option.
82 If both an argument and a \-m option are given the \-m option wins.
84 When a raw signature is created (with the \-r option), the
86 The signature is output to stdout, or the output file given with the
87 \-o option. A signature packet is output unless the \-b option is given,
88 in which case only the hex encoded signature is output.
89 .SS Key Generation Mode
90 A new private key is generated with \-g
92 A signature can be verified with \-v
96 Output the raw signature or key data without wrapping it in a
100 Generate a private key
103 Extract a public key from a private key.
106 Sign a file or message. In addition to the message to be signed,
107 signature metadata is signed.
110 Verify a signature on a file or message.
116 Increase the debug level. May be given more than once.
119 Output the raw signature, rather than a full zpm certificate.
120 This also just signs the data given, without any signature
123 .BI \-p " passphrase"
124 Specify a passphrase to decrypt or encrypt a private key. If not given here,
125 the environment variable ZPM_SIGN_PP is used. Neither of these options
126 are very secure, the command line in particular is generally readable
130 Specify a message to be signed or verified. If not set with the -m option, the
131 message is taken from file named with the first non-option argument.
134 Take the private key for message signing from the path given. This
135 defaults to ~/.zpm/key. If ~/.zpm/key is not found and the euid
136 is root, /var/lib/zpm/key is tried.
139 Take the private key from the command line argument. This is not
140 particularly secure and is primarily intended for testing.
143 Use sigstring as the signature to verify.
146 Specify a message to be signed or verified. If not set with the -m option, the
147 message is taken from file named with the first non-option argument.
150 Specify a timestamp to be used for signing instead of the current time.
151 Must be specified as a decimal representation of the unix timestamp
153 .SH PACKET AND FILE FORMAT
155 Signatures and keys are output as hexencoded packet bytestrings. All are 256
156 bytes, (512 bytes as hex encoded). Reserved bytes in packet formats must be
157 zero. The last 8 bytes are reserved.
159 On disk format is a series of 32 bytes, hex encoded, followed by
160 a newline. This takes one line per 32 bytes, thus 4 lines for 128,
161 8 lines for 256. If we waste 8 bytes at the end, we have 8 lines
162 and 512 bytes encoded, the last line will be short by 16 characters,
163 so that the actual size on disk is 512 bytes.
165 Timestamps are 8 byte little endian integers of seconds since the epoch. or
166 unix time, or some such. Times are a mess. Unix time is leap second unaware,
167 and ambiguous during leap seconds. UTC requires a database of leap seconds for
168 past time, and the specified second in the future possibly changes. TAI is
169 good, but currently 37 seconds behind UTC, which is just weird.
171 All key and signature data begin with an 8 byte header, consisting of
174 5A 50 4D 53 = "ZPMS" in ascii.
175 01 = one byte version number
176 xx = one byte packet type
177 xx xx = two bytes packet information
180 There are the following packet types.
182 The public key is derivable from the secret key, so the public key is not
185 private key format is:
186 "ZPMS" 4 byte magic "ZPMS"
187 byte 0x01 = version 1
188 byte 0x01 = private key
189 byte 0x01 = chacha encrypted, 0x00 = plain/raw key bytes
190 byte 0x00 reserved, probably "key usage"
192 8 bytes creation time, little endian
193 8 bytes expiration time, little endian
194 8 bytes password salt, note, nist wants 16, but we're not using nist
195 approved hash algorithms anyway.
197 could have 16 bytes of IV for chacha to encrypt.
198 Can probably use those, hashed with the password as the salt, but
199 not very much salt then.
201 8 bytes reserved trailer
205 public key format is:
206 "ZPMS" 4 byte magic "ZPMS"
208 0x02 1 byte "public key packet"
211 0x.. 32 bytes public key
212 0x.. 24 bytes reserved : create, expire, 8 reserved
213 0x.. 64 bytes reserved : self sig
214 120 bytes reserved : id = 1 byte id length, n bytes id, zeros
215 8 bytes reserved trailer
216 0x.. revocation signatures
218 0x.. certification signatures
222 Data, Key, and Revocation signatures all have the same format,
223 with the exception of the packet type byte at offset 5. Type
224 0x03 is a data signature used for signing arbitrary data. Type
225 0x04 is a key signature used to sign public keys. Type 0x05 is
226 a revocation signature, used to revoke signatures.
228 "ZPMS" 4 byte magic "ZPMS"
230 0x03 1 byte "signature packet"
233 0x.. 8 bytes timestamp of signature time
234 0x.. 8 bytes timestamp of signature expiration, 0 if none
235 0x.. 64 bytes of actual signature
236 0x.. 32 bytes of public key making the signature
237 0x.. 8 bytes reserved
239 8 bytes reserved trailer
243 .B zpm sign -s \fIpath\fR
244 Sign the contents of the file found at \fIpath\fR using the default secret key
245 with a signing timestamp of the current time and no expiration date. The
246 signature packet will be written to stdout.
248 .B zpm sign -s -m 'foo'
249 Sign the string 'foo'.
251 .B printf '%s' foo | zpm sign -s
252 Sign the string 'foo' as in the above example, the message being read
255 .B zpm sign -s -r -m 'foo'
256 Sign the string 'foo' directly using the default private key, no
257 additional information is signed, and the output is a hex encoded
258 raw signature with no additional newlines, making up 128 characters
259 of output. There is no way to output just the raw signature while
260 still adding the timestamps and such, but the raw signature can be
261 extracted from a signature packet.
264 -I 'c5aa8df43f9f837bedb7442f31dcb7b166d38535076f094b85ce3a2e0b4458f7' \\
266 Sign the two byte hex encoded message af82 with the raw hex encoded
267 secret key given by the -I argument. The result will be
268 6291d657deec24024827e69c3abe01a30ce548a284743a445e3680d7db5ac3ac
269 18ff9b538d16f290ae67f760984dc6594a7c15e9716ed28dc027beceea1ec40a
270 all on a single line with no trailing newline.
272 0 on success non zero on failure
275 Timestamps are a mess. Unix time is leap second unaware, and ambiguous during
276 leap seconds. UTC requires a database of leap seconds for past time, and the
277 specified second in the future possibly changes. TAI is good, but currently 37
278 seconds behind UTC, which is just weird. Regardless of the above, unix
279 time was chosen for general compatibility with time functions.
281 There is no binding of a notion of an identity to a public key.
283 There is no trust level of a public key. A reserved byte could be
284 used for this, but the semantics then need to be designed.
285 .SH NOTES ON CRYPTOGRAPHY
286 The general methods described by SEC 1 Ver 2.0 were followed, but
287 this is not an implementation of that scheme, because different
290 Chacha20 is used to encrypt private keys.
301 .R http://www.secg.org SEC 1 Ver 2.0