Botan 2.19.0
Crypto and TLS for C&
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
13namespace Botan {
14
16 {
17 return m_group.p_bits();
18 }
19
21 {
23 }
24
26 {
29 }
30
31std::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 {
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 {
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}
const std::vector< uint8_t > & get_parameters() const
Definition: asn1_obj.h:446
BER_Decoder & decode(bool &out)
Definition: ber_dec.h:170
secure_vector< uint8_t > get_contents()
Definition: der_enc.cpp:152
DER_Encoder & encode(bool b)
Definition: der_enc.cpp:285
std::vector< uint8_t > DER_encode(Format format) const
Definition: dl_group.cpp:553
size_t p_bits() const
Definition: dl_group.cpp:451
bool verify_public_element(const BigInt &y) const
Definition: dl_group.cpp:347
bool verify_element_pair(const BigInt &y, const BigInt &x) const
Definition: dl_group.cpp:364
size_t estimated_strength() const
Definition: dl_group.cpp:473
void BER_decode(const std::vector< uint8_t > &ber, Format format)
Definition: dl_group.cpp:612
bool verify_group(RandomNumberGenerator &rng, bool strong=true) const
Definition: dl_group.cpp:380
secure_vector< uint8_t > private_key_bits() const override
Definition: dl_algo.cpp:52
bool check_key(RandomNumberGenerator &rng, bool) const override
Definition: dl_algo.cpp:78
size_t key_length() const override
Definition: dl_algo.cpp:15
AlgorithmIdentifier algorithm_identifier() const override
Definition: dl_algo.cpp:25
std::vector< uint8_t > public_key_bits() const override
Definition: dl_algo.cpp:31
virtual DL_Group::Format group_format() const =0
size_t estimated_strength() const override
Definition: dl_algo.cpp:20
bool check_key(RandomNumberGenerator &rng, bool) const override
Definition: dl_algo.cpp:69
virtual OID get_oid() const
Definition: pk_keys.cpp:53
Definition: alg_id.cpp:13
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65