Repository navigation
SKeySizeSpec
#include <certpp/crypto/keys.hpp> --- certpp::crypto
The valid key sizes for a cryptographic algorithm.
SKeySize minSize-
SKeySize maxSize--- < Minimum key size in bits. -
SKeySize step--- < Maximum key size in bits.
Default constructor; all fields zero.
Constructs a spec accepting a single size.
-
size--- The key size in bits.
-
minSize--- Minimum key size in bits. -
maxSize--- Maximum key size in bits. -
step--- Increment step for valid key sizes in bits.
Returns: true if minSize, maxSize, and step are all zero.
Returns: true if this specification is not empty.
Returns: true if this specification is empty.
Checks if a given key size is included in the valid key sizes.
-
size--- The key size in bits to check.
Returns: true if size is valid according to this specification.
-
other--- The other key size specification to compare with.
Returns: A negative value if this is less than other, zero if equal, positive if greater.
Returns: true if this specification is less than the other specification.
Returns: true if this specification is less than or equal to the other specification.
Returns: true if this specification is greater than the other specification.
Returns: true if this specification is greater than or equal to the other specification.
Returns: true if this specification is equal to the other specification.
Returns: true if this specification is not equal to the other specification.
Checks a caller-supplied key size against what the algorithm actually accepts, before generateKeyPair() rejects it. A spec built from one size has step 0 and includes() only that size; RSA's is a range with a step, so 2048 passes and 2049 does not.
// given: const crypto::IAsymmetricPtr& algo, crypto::SKeySize requested
bool accepted = false;
for (const crypto::SKeySizeSpec& spec : algo->keySizes()) {
if (spec.includes(requested)) {
accepted = true;
break;
}
}
if (!accepted) {
return; // generateKeyPair() would answer ERET_KEY_SIZE
}
crypto::SKeyPair pair;
if (algo->generateKeyPair(requested, pair) != ERET_OK) {
return;
}Reference generated from certpp/crypto/keys.hpp at commit 0834b29 (v1.0.1). The header is authoritative --- if this page disagrees with it, the header is right and this page needs regenerating.