diff options
author | Never <[email protected]> | 2017-06-16 15:40:02 +0200 |
---|---|---|
committer | Never <[email protected]> | 2017-06-16 16:00:16 +0200 |
commit | fb4f6216fd2b8fad337a026e17bac11444f569f6 (patch) | |
tree | 0ac5a2f09d64c890fedaee27e71f955f847e8d02 /doc | |
parent | 40feca3a3235d9ca49e7443619451205ccb3fd06 (diff) |
Updated key checking in manual
Diffstat (limited to 'doc')
-rw-r--r-- | doc/manual/pubkey.rst | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/doc/manual/pubkey.rst b/doc/manual/pubkey.rst index bd975400e..afc130a0a 100644 --- a/doc/manual/pubkey.rst +++ b/doc/manual/pubkey.rst @@ -322,7 +322,7 @@ Key Checking Most public key algorithms have limitations or restrictions on their parameters. For example RSA requires an odd exponent, and algorithms -based on the discrete logarithm problem need a generator $> 1$. +based on the discrete logarithm problem need a generator > 1. Each public key type has a function @@ -338,6 +338,30 @@ Each public key type has a function entity. If *strong* is ``true``, then it does "strong" checking, which includes expensive operations like primality checking. +As key checks are not automatically performed they must be called +manually after loading keys from untrusted sources. If a key from an untrusted source +is not checked, the implementation might be vulnerable to algorithm specific attacks. + +The following example loads the Subject Public Key from the x509 certificate ``cert.pem`` and checks the +loaded key. If the key check fails a respective error is thrown. + +.. code-block:: cpp + + #include <botan/x509cert.h> + #include <botan/auto_rng.h> + #include <botan/rng.h> + + int main() + { + Botan::X509_Certificate cert("cert.pem"); + std::unique_ptr<Botan::RandomNumberGenerator> rng(new Botan::AutoSeeded_RNG); + std::unique_ptr<Botan::Public_Key> key(cert.subject_public_key()); + if(!key->check_key(*rng.get(), false)) + { + throw std::invalid_argument("Loaded key is invalid"); + } + } + Encryption --------------------------------- |