== How to fix it in Botan

=== Code examples

include::../../common/fix/code-rationale.adoc[]

==== Noncompliant code example

include::../../common/fix/rsa.adoc[]

[source,cpp,diff-id=1,diff-type=noncompliant]
----
#include <botan/pubkey.h>
#include <botan/rng.h>
#include <botan/rsa.h>

void encrypt() {
    std::unique_ptr<Botan::RandomNumberGenerator>   rng(new Botan::System_RNG);
    Botan::RSA_PrivateKey                           rsaKey(*rng, 1024); // Noncompliant
}
----

include::../../common/fix/dl-group.adoc[]

[source,cpp,diff-id=2,diff-type=noncompliant]
----
#include <botan/dl_group.h>

void encrypt() {
    Botan::DL_Group("dsa/botan/1024"); // Noncompliant
}
----

include::../../common/fix/ec.adoc[]

[source,cpp,diff-id=3,diff-type=noncompliant]
----
#include <botan/ec_group.h>

void encrypt() {
    Botan::EC_Group("secp160k1"); // Noncompliant
}
----

==== Compliant solution

[source,cpp,diff-id=1,diff-type=compliant]
----
#include <botan/pubkey.h>
#include <botan/rng.h>
#include <botan/rsa.h>

void encrypt() {
    std::unique_ptr<Botan::RandomNumberGenerator>   rng(new Botan::System_RNG);
    Botan::RSA_PrivateKey                           rsaKey(*rng, 2048);
}
----

[source,cpp,diff-id=2,diff-type=compliant]
----
#include <botan/dl_group.h>

void encrypt() {
    Botan::DL_Group("dsa/botan/2048");
}
----

[source,cpp,diff-id=3,diff-type=compliant]
----
#include <botan/ec_group.h>

void encrypt() {
    Botan::EC_Group("secp224k1");
}
----

=== How does this work?

include::../../common/fix/fix.adoc[]

=== Going the extra mile

include::../../common/extra-mile/pre-quantum.adoc[]
