Digital signature¶
Name¶
Digital signature
Summary¶
This pattern encapsulates the common considerations one should take into account when using digital signatures.
Parent¶
Problem¶
Solution¶
A digital signature is a tag that is computed from a message, i.e. data elements and/or action requests, using a public-key algorithm.2 3 A digital signature is computed from a message using a private key, whereas the corresponding public key can be used to verify whether a message and digital signature match. Digital signatures can be used to provide three properties2:
- Data integrity: assurance that the received message is identical to one signed;
- Data origin authentication: assurance of who originated (signed) the message; and
- Non-repudiation: as the private key used to compute the signature should only be known the owner of this key, a digital signature provides strong evidence of exactly who originally signed the message, i.e. the owner of the key. Thereby making it difficult to digitally sign data and successfully deny doing so later on.
The first two properties can also be achieved using Message Authentication Codes (MAC), but MACs cannot reliably achieve the third property, non-repudiation.
Roles¶
- EntityA (: Entity) an entity that wants to create a digital signature for some message(s)
- EntityA <- Cryptographic action.Entity
- EntityB (: Entity) an entity that wants to verify the digital signature for given message(s)
- EntityA <- Cryptographic action.Entity
- Signature generator (: Cryptographic
primitive) a cryptographic primitive that at least supports generating digital signatures
- Signature generator <- Cryptographic action.Cryptographer
- Signature verifier (: Cryptographic
primitive) a cryptographic primitive that at least supports verifying digital signatures
- Signature verifier <- Cryptographic action.Cryptographer
Info
The roles of Signature generator and Signature verifier can be performed by a single (instance of an) entity.
If a single system requires both signature generation and verification a single entity, i.e. cryptographic library, should be used for this.
Similarly, the EntityA and EntityB roles can be performed by a single entity (instance) as well.
Actions¶
- generate (: Action) a new digital signature for the provided message
musing the private key identified inprivKeyInfo- generate <- Cryptographic action.crypto_action
- verify (: Action) whether a given message
mcorresponds to the message signed by digital signaturesigusing the public key identified inpubKeyInfo- verify <- Cryptographic action.crypto_action
Data elements¶
- m (: Data) the plaintext message that need to be signed or for which a digital signature must be verified
- m <- Cryptographic action.input
- sig (: Data) a digital signature generated for some message
- Generation: sig <- Cryptographic action.output
- Verification: sig <- Cryptographic action.input
- privKeyInfo (: Data) information on the private signing key to be used for generating a signature.
The exact information depends on the chosen key management method (cf. Cryptographic key management).
- Tags: Untampered, Secret
- privKeyInfo <- Cryptographic action.keyInfo
- pubKeyInfo (: Data) information on the public verification key to be used for verifying a signature.
The exact information depends on the chosen key management method (cf. Cryptographic key management).
- Tags: Untampered
- pubKeyInfo <- Cryptographic action.keyInfo
- config (: Data) the configuration for the
Signature generatorand/orSignature verifiercontaining, for example, the desired cipher (optional)- Tags: Untampered
- ok (: Data) indication that a signature was correct with respect to the provided message
- Verification: ok <- Cryptographic action.output
- error (: Data) indication that a signature was not valid with respect to the provided message.
This may be because the message was modified since the signature was generated or that a different private key than the one corresponding to the identified public key was used to generate the signature.
- Verification: error <- Cryptographic action.output
Behaviour¶
In order to generate a digital signature for a message m:
EntityArequests theSignature generatorto generate a new digital signature and provides the plaintext messagemalong with the necessary information on the private key to be used.- The
Signature generatorgenerates the requested signature and replies it toEntityB.

In order to verify a given digital signature against a message m:
EntityBrequests theSignature verifierto verify a digital signature and provides the signature itself, the plaintext messagemand the necessary information on the public key to be used.- The
Signature verifierverifies whether the message signed by the signature matches the plaintextm. If so, theSignature verifierconfirms this toEntityB, otherwise an error message is replied.

Role considerations¶
Reuse existing libraries (Signature generator, Signature verifier)¶
Specialisation of Cryptographic action.Reuse existing libraries
One important criterion to consider when considering possible libraries is that they support the recommended ciphers, where libraries supporting only deprecated ciphers should be avoided. See below for concrete recommendations concerning ciphers.
Use keys for a single purpose (Entity)¶
Specialisation of Cryptographic action.Use keys for a single purpose
Concretely, a key pair that is used to sign messages and verify the resulting signatures should not be used to, for example, encrypt and decrypt messages as well.
Design for change (EntityA, EntityB, Signature generator, Signature verifier)¶
Specialisation of Cryptographic action.Design for change
Cipher selection¶
The Digital Signature Algorithm (DSA) is deprecated for generating digital signatures and should only be used to verify digital signatures generated with it in the past.3 Recommended algorithms for digital signatures are RSA, ECDSA, and EdDSA.
Key length¶
The advised key length varies depending on the underlying cipher and selected source, one can use online tools to compare the the different advises.
In summary, when using the RSA the minimal advised key length is 2048 bits for signatures that are used for a short while3, e.g. to sign short-term authentication tokens. For digital signatures that need to be protected for a longer period, e.g. in the order of years, longer key lengths such as 3072 bits are advised for RSA.6 5 4: In case protection for a very long period, e.g. 30+ years, is relevant consideration, RSA keys of 15360 bits are advised.5 6
For ciphers based on elliptic curves, such as ECDSA, a minimal public key length of 256 bits is advised to achieve a security strength similar to AES with a 128 bit key 6 7 2 as well as RSA with a 3072 bit key4. Therefore, a minimal key length of 256 bits is advised for elliptic curve based ciphers when signatures will be used short to mid-long term (e.g. maximum 10 years6). For signatures that are intended to be used for a longer period an minimal key length of 512 bits are advised.5 6
Data considerations¶
privKeyInfo¶
Specialisation of Cryptographic action.keyInfo
A private key that is used to generate digital signatures should at all times be kept confidential and its integrity should be protected. This concerns both when the private key is stored persistently as well as when it is transmitted between entities.
A private key used for signature generation should not be used for longer than one to three years.1 A private signature key that is no longer used to generate signatures should be destroyed.
pubKeyInfo¶
Specialisation of Cryptographic action.keyInfo
The integrity of a public key that is used to verify digital signatures should at all times be protected. This concerns both when the key is stored persistently as well as when it is transmitted between entities.
A public key used for signature verification may be used for a longer period than its corresponding private key.1 This is necessary to be able to verify signatures after the private key used to generated them has already been deprecated.
config¶
Specialisation of Cryptographic action.config
Implementations¶
None
References¶
-
E. Barker, ‘Recommendation for Key Management: Part 1 – General’, NIST, 800–57 Part 1, May 2020. [Online]. Available: https://doi.org/10.6028/NIST.SP.800-57pt1r5 ↩↩
-
P. C. van Oorschot, Computer Security and the Internet - Tools and Jewels. 2020. [Online]. Available: https://doi.org/10.1007/978-3-030-33649-3 ↩↩↩
-
NIST, ‘Digital Signature Standard (DSS)’, NIST, FIPS 186–5, Oct. 2019. [Online]. Available: https://doi.org/10.6028/NIST.FIPS.186-5-draft ↩↩↩
-
S. Nakov, Practical Cryptography for Developers. 2018. [Online]. Available: https://cryptobook.nakov.com/ ↩↩
-
‘Algorithms, Key Size and Protocols Report (2018)’, Feb. 2018. [Online]. Available: https://www.ecrypt.eu.org/csa/documents/D5.4-FinalAlgKeySizeProt.pdf ↩↩↩
-
N. P. Smart et al., ‘Algorithms, Key size and parameters report’, ENISA, Nov. 2014. [Online]. Available: https://www.enisa.europa.eu/publications/algorithms-key-size-and-parameters-report-2014 ↩↩↩↩↩
-
E. Barker, ‘Recommendation for Key Management: Part 1 – General’, NIST, 800–57 Part 1, May 2020. [Online]. Available: https://doi.org/10.6028/NIST.SP.800-57pt1r5 ↩