Botan  2.8.0
Crypto and TLS for C++11
dl_algo.cpp
Go to the documentation of this file.
1 /*
2 * DL Scheme
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #include <botan/dl_algo.h>
9 #include <botan/numthry.h>
10 #include <botan/der_enc.h>
11 #include <botan/ber_dec.h>
12 
13 namespace Botan {
14 
16  {
17  return m_group.p_bits();
18  }
19 
21  {
22  return m_group.estimated_strength();
23  }
24 
26  {
29  }
30 
31 std::vector<uint8_t> DL_Scheme_PublicKey::public_key_bits() const
32  {
33  std::vector<uint8_t> output;
34  DER_Encoder(output).encode(m_y);
35  return output;
36  }
37 
39  m_y(y),
40  m_group(group)
41  {
42  }
43 
45  const std::vector<uint8_t>& key_bits,
46  DL_Group::Format format) :
47  m_group(alg_id.get_parameters(), format)
48  {
49  BER_Decoder(key_bits).decode(m_y);
50  }
51 
53  {
54  return DER_Encoder().encode(m_x).get_contents();
55  }
56 
58  const secure_vector<uint8_t>& key_bits,
59  DL_Group::Format format)
60  {
61  m_group.BER_decode(alg_id.get_parameters(), format);
62 
63  BER_Decoder(key_bits).decode(m_x);
64  }
65 
66 /*
67 * Check Public DL Parameters
68 */
70  bool strong) const
71  {
72  return m_group.verify_group(rng, strong) && m_group.verify_public_element(m_y);
73  }
74 
75 /*
76 * Check DL Scheme Private Parameters
77 */
79  bool strong) const
80  {
81  return m_group.verify_group(rng, strong) && m_group.verify_element_pair(m_y, m_x);
82  }
83 
84 }
size_t key_length() const override
Definition: dl_algo.cpp:15
bool check_key(RandomNumberGenerator &rng, bool) const override
Definition: dl_algo.cpp:69
secure_vector< uint8_t > get_contents()
Definition: der_enc.cpp:152
BER_Decoder & decode(bool &out)
Definition: ber_dec.h:170
bool verify_group(RandomNumberGenerator &rng, bool strong=true) const
Definition: dl_group.cpp:372
DER_Encoder & encode(bool b)
Definition: der_enc.cpp:285
virtual OID get_oid() const
Definition: pk_keys.cpp:53
AlgorithmIdentifier algorithm_identifier() const override
Definition: dl_algo.cpp:25
secure_vector< uint8_t > private_key_bits() const override
Definition: dl_algo.cpp:52
bool verify_public_element(const BigInt &y) const
Definition: dl_group.cpp:339
std::vector< uint8_t > DER_encode(Format format) const
Definition: dl_group.cpp:533
virtual DL_Group::Format group_format() const =0
size_t estimated_strength() const override
Definition: dl_algo.cpp:20
Definition: alg_id.cpp:13
std::vector< uint8_t > public_key_bits() const override
Definition: dl_algo.cpp:31
size_t p_bits() const
Definition: dl_group.cpp:436
const std::vector< uint8_t > & get_parameters() const
Definition: alg_id.h:38
bool check_key(RandomNumberGenerator &rng, bool) const override
Definition: dl_algo.cpp:78
void BER_decode(const std::vector< uint8_t > &ber, Format format)
Definition: dl_group.cpp:592
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88
bool verify_element_pair(const BigInt &y, const BigInt &x) const
Definition: dl_group.cpp:356
size_t estimated_strength() const
Definition: dl_group.cpp:458