aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples/ecdsa.cpp
blob: bd40e897bd4fdb065b242cbf50e3eea57f00eaea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <botan/botan.h>
#include <botan/ecdsa.h>

#include <memory>
#include <iostream>

using namespace Botan;

int main()
   {
   try
      {
      std::auto_ptr<RandomNumberGenerator> rng(
         RandomNumberGenerator::make_rng());

      EC_Domain_Params params = get_EC_Dom_Pars_by_oid("1.3.132.0.8");

      std::cout << params.get_curve().get_p() << "\n";
      std::cout << params.get_order() << "\n";

      ECDSA_PrivateKey ecdsa(*rng, params);

      std::cout << X509::PEM_encode(ecdsa);
      }
   catch(std::exception& e)
      {
      std::cout << e.what() << "\n";
      }
   }