Botan  2.6.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  {
34  }
35 
37  m_y(y),
38  m_group(group)
39  {
40  }
41 
43  const std::vector<uint8_t>& key_bits,
44  DL_Group::Format format) :
45  m_group(alg_id.get_parameters(), format)
46  {
47  BER_Decoder(key_bits).decode(m_y);
48  }
49 
51  {
52  return DER_Encoder().encode(m_x).get_contents();
53  }
54 
56  const secure_vector<uint8_t>& key_bits,
57  DL_Group::Format format)
58  {
59  m_group.BER_decode(alg_id.get_parameters(), format);
60 
61  BER_Decoder(key_bits).decode(m_x);
62  }
63 
64 /*
65 * Check Public DL Parameters
66 */
68  bool strong) const
69  {
70  return m_group.verify_group(rng, strong) && m_group.verify_public_element(m_y);
71  }
72 
73 /*
74 * Check DL Scheme Private Parameters
75 */
77  bool strong) const
78  {
79  return m_group.verify_group(rng, strong) && m_group.verify_element_pair(m_y, m_x);
80  }
81 
82 }
size_t key_length() const override
Definition: dl_algo.cpp:15
bool check_key(RandomNumberGenerator &rng, bool) const override
Definition: dl_algo.cpp:67
std::vector< uint8_t > get_contents_unlocked()
Definition: der_enc.h:27
secure_vector< uint8_t > get_contents()
Definition: der_enc.cpp:123
BER_Decoder & decode(bool &v)
Definition: ber_dec.cpp:338
bool verify_group(RandomNumberGenerator &rng, bool strong=true) const
Definition: dl_group.cpp:342
DER_Encoder & encode(bool b)
Definition: der_enc.cpp:202
virtual OID get_oid() const
Definition: pk_keys.cpp:51
AlgorithmIdentifier algorithm_identifier() const override
Definition: dl_algo.cpp:25
secure_vector< uint8_t > private_key_bits() const override
Definition: dl_algo.cpp:50
bool verify_public_element(const BigInt &y) const
Definition: dl_group.cpp:309
std::vector< uint8_t > DER_encode(Format format) const
Definition: dl_group.cpp:455
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:406
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:76
void BER_decode(const std::vector< uint8_t > &ber, Format format)
Definition: dl_group.cpp:515
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:326
size_t estimated_strength() const
Definition: dl_group.cpp:416