PSS and the Salt
RSA-PSS mixes a salt into the padded block; with a salt length of 0 the 64-byte signature of a test key is fixed and can be checked by hand-written code, with the default salt two signatures of one message differ and both verify.
The question
The last lesson signed with PKCS#1 v1.5, where the padded block is fixed by the message. RSA-PSS, defined in RFC 8017 section 8.1, builds the block differently: it hashes the message together with a salt and then masks the result. What goes into the block, how long may the salt be on a 512-bit key, and what happens when the salt is empty?
The key alice is test material, a 512-bit key made for these lessons. The signature that the command checks was made once with it and is fixed.
Work it by hand
RFC 8017 section 9.1.1 builds the block EM in these steps. Write hLen for the hash length, 32 bytes for SHA-256, sLen for the salt length and emLen for the block length, 64 bytes here, because the first bit of the 512-bit block is cleared and the block has 511 bits.
- mHash is the SHA-256 digest of the message. M' is eight zero bytes, then mHash, then the salt.
- H is the SHA-256 digest of M', 32 bytes.
- DB is emLen minus sLen minus hLen minus 2 zero bytes, then 01, then the salt. For an empty salt that is 30 zero bytes and 01.
- A mask of the same length as DB, made from H with the function MGF1, is combined with DB by XOR.
- EM is the masked DB, then H, then the byte bc.
Step 3 of the RFC stops with "encoding error" if emLen is below hLen plus sLen plus 2. So the salt of this key is at most 64 minus 32 minus 2, which is 30 bytes. The signature is EM to the power d, modulo n.
Run it
The command checks a PSS signature: -verify with the public key in/pub.txt, the signature file in/sig.bin, the message in/message.txt hashed with SHA-256, the padding mode pss and a salt length of 0. A salt length given here must be the one that was used to sign; without the option OpenSSL accepts any length that fits.
The message is pay 10 to bob and a line feed, the signature is the fixed 64 bytes of the test key, and the command prints Signature Verified Successfully.

Public test material, generated for this lesson. Never use it for anything real.
# Reads the public key in in/pub.txt, the signature in in/sig.bin
# and the message in in/message.txt.
pkeyutl -verify -pubin -inkey in/pub.txt -rawin -in in/message.txt \
-digest sha256 -pkeyopt rsa_padding_mode:pss -pkeyopt rsa_pss_saltlen:0 \
-sigfile in/sig.bin
{
"answer": "Signature Verified Successfully"
}You can change the message or the signature. A changed message stops the command with the message "OpenSSL: RSA lib", and so does a wrong salt length: with rsa_pss_saltlen:20 the signature, made with a salt of 0, fails the same way (the command itself prints "salt length check failed" and "Signature Verification Failure", which the page does not show). Leaving the salt option out also verifies it, because OpenSSL then accepts any salt length that fits; leaving the padding mode out fails.
Your turn
The command below should sign the message in in/message.txt with the private key in in/key.txt using RSA-PSS with SHA-256 and a salt length of 0, and write the 64 signature bytes to out.bin. Decide whether it does, and edit it so that it does. Check runs your command on the data shown and on four others, each a different message.

Public test material, generated for this lesson. Never use it for anything real.
# Reads the private key in in/key.txt and the message in in/message.txt.
# Writes 64 bytes to out.bin. Check runs it with other messages.
pkeyutl -sign -inkey in/key.txt -rawin -in in/message.txt -digest sha256 \
-out out.bin
{
"answer": "77c1be7dd9ebc0f0eb307cb67bf382310918bcc4b04039c79011a3a6fcf88600d04238181c0f56297d050403f8287319cd6caede0100eebe3e4a07dfc485d82b",
"file": "out.bin",
"bytes": 64
}Write one command that signs the file in/message.txt with the RSA private key in in/key.txt using RSA-PSS with SHA-256, MGF1 with SHA-256 and a salt length of 0, and writes the 64 signature bytes to out.bin. Check runs your command with other messages in that file, one of them empty.
Read the result carefully
With a salt length of 0 the signature is fixed by the key and the message, which is why Check can compare bytes. With the default salt, two signatures of the same message differ (measured with lmssl 0.2.2: three runs gave 287f93ef, 5d22c5ae and 5f483df1 as first bytes; stated here, not run on this page), and both verify: the salt is random. A signature with a salt has no fixed bytes to compare, only a check that passes or fails.
A salt of 31 bytes or more does not fit this key: signing with rsa_pss_saltlen:31 stops with "Public Key operation error: RSA lib" (the command's first error line, "data too large for key size", is not shown). The page shows no timing, no key protection and no reason to choose one scheme for a real system; the keys are test material and 512 bits is far too small to use.
Recap
- RSA-PSS hashes the message with a salt into H, masks a padded block with a function of H, and ends the block with bc.
- The block is 64 bytes for this key, so the salt is at most 30 bytes.
- With a salt length of 0 the signature is fixed; with the default salt it differs every time and still verifies.
- Verification needs the padding mode and a matching salt length.