|
Botan 3.14.1
Crypto and TLS for C&
|
#include <pk_options.h>
Friends | |
| class | PK_Signature_Options_Reader |
Signature generation/verification options
The normal usage of this is in a builder style, eg
PK_Signature_Options() .with_hash("SHA-256") .with_der_encoded_signature() .with_context("Foo")
Every option that is set must be understood by the signature scheme in use. If a scheme does not support an option (for example a context for RSA, or a salt for Ed25519) then constructing the PK_Signer or PK_Verifier throws an exception; an option is never silently ignored.
Definition at line 49 of file pk_options.h.
|
default |
Create an empty PK_Signature_Options
This can be further parameterized by calling with_xxx functions
Referenced by operator=(), operator=(), PK_Signature_Options(), PK_Signature_Options(), with_context(), with_context(), with_der_encoded_signature(), with_deterministic_signature(), with_explicit_trailer_field(), with_externally_computed_prehash(), with_hash(), with_padding(), with_prehash(), with_provider(), with_salt_size(), and ~PK_Signature_Options().
|
default |
References PK_Signature_Options().
|
default |
References PK_Signature_Options().
|
default |
|
default |
References PK_Signature_Options().
|
default |
References PK_Signature_Options().
| std::string Botan::PK_Signature_Options::to_string | ( | ) | const |
Format this PK_Signature_Options as a string
This is primarily intended for debugging and error messages; the format is not fixed
Definition at line 227 of file pk_options.cpp.
References Botan::hex_encode(), and name.
Referenced by ~PK_Signature_Options().
| PK_Signature_Options Botan::PK_Signature_Options::with_context | ( | std::span< const uint8_t > | context | ) |
Specify a context
Some signature schemes allow specifying a context with the signature. This is typically a fixed string that identifies a protocol or peer.
For SM2 this context is the user identifier
If the scheme does not support contextual identifiers, then an exception will be thrown.
Definition at line 77 of file pk_options.cpp.
References BOTAN_STATE_CHECK_MSG, and PK_Signature_Options().
Referenced by Botan::parse_legacy_sig_options(), and ~PK_Signature_Options().
| PK_Signature_Options Botan::PK_Signature_Options::with_context | ( | std::string_view | context | ) |
Specify a context as a string
Equivalent to the version taking a span above; just uses the bytes of the string instead.
Definition at line 84 of file pk_options.cpp.
References Botan::as_span_of_bytes(), BOTAN_STATE_CHECK_MSG, and PK_Signature_Options().
| PK_Signature_Options Botan::PK_Signature_Options::with_der_encoded_signature | ( | bool | der = true | ) |
Specify producing or expecting a DER encoded signature
This is mostly used with ECDSA
For schemes that do not support such formatting (such as RSA or post-quantum schemes), an exception will be thrown when the PK_Signer or PK_Verifier is created.
Definition at line 110 of file pk_options.cpp.
References BOTAN_STATE_CHECK_MSG, and PK_Signature_Options().
Referenced by ~PK_Signature_Options().
| PK_Signature_Options Botan::PK_Signature_Options::with_deterministic_signature | ( | bool | deterministic = true | ) |
Request producing a deterministic signature
Some signature schemes are always deterministic, or always randomized. Others support both randomized or deterministic options. This allows requesting this. For signatures which are always deterministic this option has no effect. Schemes which can only produce randomized signatures reject this option.
This option is ignored for verification
Definition at line 101 of file pk_options.cpp.
References BOTAN_STATE_CHECK_MSG, and PK_Signature_Options().
Referenced by Botan::parse_legacy_sig_options(), and ~PK_Signature_Options().
| PK_Signature_Options Botan::PK_Signature_Options::with_explicit_trailer_field | ( | bool | trailer = true | ) |
Specify producing or expecting an explicit trailer field
Certain RSA padding schemes, such as PSS and ISO-9796, support two different trailer fields. One is an "implicit" trailer, which does not directly identify the hash. The other is an "explicit" trailer, which does.
Note that currently this option is only supported by ISO-9796. While some standards allow PSS to use a trailer field, others (such as RFC 4055) prohibit using explicit trailers for PSS, and it is not currently supported.
Definition at line 118 of file pk_options.cpp.
References BOTAN_STATE_CHECK_MSG, and PK_Signature_Options().
Referenced by Botan::parse_legacy_sig_options(), and ~PK_Signature_Options().
| PK_Signature_Options Botan::PK_Signature_Options::with_externally_computed_prehash | ( | std::optional< std::string > | hash = std::nullopt | ) |
Specify that the caller has already hashed the message
With this option the data passed to the signature operation is not the message but a hash of it, which the caller computed. The library signs (or verifies) the provided digest directly, without hashing it again.
The hash function that was used can be named either here or via with_hash (if both are given they must agree). Naming it allows the scheme to check the digest length and to identify the hash in the signature where the format requires it (for example the PKCS #1 v1.5 DigestInfo). If no hash is named the input is signed as an opaque byte string.
If the scheme does not support signing an externally computed hash, it will throw an exception when presented with such an option.
This cannot be combined with with_prehash
Definition at line 52 of file pk_options.cpp.
References BOTAN_STATE_CHECK_MSG, and PK_Signature_Options().
Referenced by Botan::parse_legacy_sig_options(), and ~PK_Signature_Options().
| PK_Signature_Options Botan::PK_Signature_Options::with_hash | ( | std::string_view | hash | ) |
Specify the hash function to use for signing/verification
Most, but not all, schemes require specifying a hash function.
Definition at line 21 of file pk_options.cpp.
References BOTAN_STATE_CHECK_MSG, and PK_Signature_Options().
Referenced by Botan::parse_legacy_sig_options(), and ~PK_Signature_Options().
| PK_Signature_Options Botan::PK_Signature_Options::with_padding | ( | std::string_view | padding | ) |
Specify a padding scheme
This is mostly/only used for RSA
If the scheme does not support a padding option, it will throw an exception when presented with such an option.
Definition at line 30 of file pk_options.cpp.
References BOTAN_STATE_CHECK_MSG, and PK_Signature_Options().
Referenced by Botan::parse_legacy_sig_options(), and ~PK_Signature_Options().
| PK_Signature_Options Botan::PK_Signature_Options::with_prehash | ( | std::optional< std::string > | prehash = std::nullopt | ) |
Request that the library prehash the message
Some signature schemes, such as Ed25519, normally sign the entire message along with some context data. However such schemes also sometimes offer a prehashing variant where the message is hashed on its own, then the hash is signed.
With this option the library computes the prehash itself; the caller still provides the full message. If given this specifies what hash function to use for prehashing. If prehash is nullopt, this requests prehashing using an algorithm specific default function.
If the scheme does not support prehashing, it will throw an exception when presented with such an option.
This cannot be combined with with_externally_computed_prehash
Definition at line 39 of file pk_options.cpp.
References BOTAN_STATE_CHECK_MSG, and PK_Signature_Options().
Referenced by Botan::parse_legacy_sig_options(), and ~PK_Signature_Options().
| PK_Signature_Options Botan::PK_Signature_Options::with_provider | ( | std::string_view | provider | ) |
Specify a provider that should be used
This is rarely relevant
Definition at line 67 of file pk_options.cpp.
References BOTAN_STATE_CHECK_MSG, and PK_Signature_Options().
Referenced by Botan::Private_Key::create_signature_op(), Botan::Public_Key::create_verification_op(), and ~PK_Signature_Options().
| PK_Signature_Options Botan::PK_Signature_Options::with_salt_size | ( | size_t | salt_size | ) |
Specify the size of salt to be used
A small number of padding schemes (most importantly RSA-PSS) use a randomized salt. This allows controlling the size of the salt that is used.
Definition at line 92 of file pk_options.cpp.
References BOTAN_ARG_CHECK, BOTAN_STATE_CHECK_MSG, and PK_Signature_Options().
Referenced by ~PK_Signature_Options().
|
friend |
Definition at line 188 of file pk_options.h.
References PK_Signature_Options_Reader.
Referenced by PK_Signature_Options_Reader.