Botan 1.10.17

signed_obj.h
Go to the documentation of this file.
1 /*
2 * EAC SIGNED Object
3 * (C) 2007 FlexSecure GmbH
4 * 2008 Jack Lloyd
5 *
6 * Distributed under the terms of the Botan license
7 */
8
9 #ifndef BOTAN_EAC_SIGNED_OBJECT_H__
10 #define BOTAN_EAC_SIGNED_OBJECT_H__
11
12 #include <botan/asn1_obj.h>
13 #include <botan/pubkey_enums.h>
14 #include <botan/pipe.h>
15 #include <vector>
16
17 namespace Botan {
18
19 /**
20 * This class represents abstract signed EAC object
21 */
22 class BOTAN_DLL EAC_Signed_Object
23 {
24 public:
25 /**
26 * Get the TBS (to-be-signed) data in this object.
27 * @return DER encoded TBS data of this object
28 */
29 virtual SecureVector<byte> tbs_data() const = 0;
30
31 /**
32 * Get the signature of this object as a concatenation, i.e. if the
33 * signature consists of multiple parts (like in the case of ECDSA)
34 * these will be concatenated.
35 * @return signature as a concatenation of its parts
36 */
37
38 /*
39 NOTE: this is here only because abstract signature objects have
40 not yet been introduced
41 */
42 virtual SecureVector<byte> get_concat_sig() const = 0;
43
44 /**
45 * Get the signature algorithm identifier used to sign this object.
46 * @result the signature algorithm identifier
47 */
48 AlgorithmIdentifier signature_algorithm() const;
49
50 /**
51 * Check the signature of this object.
52 * @param key the public key associated with this signed object
53 * @param sig the signature we are checking
54 * @return true if the signature was created by the private key
55 * associated with this public key
56 */
57 bool check_signature(class Public_Key& key,
58 const MemoryRegion<byte>& sig) const;
59
60 /**
61 * Write this object DER encoded into a specified pipe.
62 * @param pipe the pipe to write the encoded object to
63 * @param encoding the encoding type to use
64 */
65 virtual void encode(Pipe& pipe,
66 X509_Encoding encoding = PEM) const = 0;
67
68 /**
69 * BER encode this object.
70 * @return result containing the BER representation of this object.
71 */
72 SecureVector<byte> BER_encode() const;
73
74 /**
75 * PEM encode this object.
76 * @return result containing the PEM representation of this object.
77 */
78 std::string PEM_encode() const;
79
80 virtual ~EAC_Signed_Object() {}
81 protected:
82 void do_decode();
83 EAC_Signed_Object() {}
84
85 AlgorithmIdentifier sig_algo;
86 SecureVector<byte> tbs_bits;
87 std::string PEM_label_pref;
88 std::vector<std::string> PEM_labels_allowed;
89 private:
90 virtual void force_decode() = 0;
91 };
92
93 }
94
95 #endif
Botan::PKCS8::BER_encode
SecureVector< byte > BER_encode(const Private_Key &key)
Definition: pkcs8.cpp:134
Botan::EAC_Signed_Object::sig_algo
AlgorithmIdentifier sig_algo
Definition: signed_obj.h:85
Botan::EAC_Signed_Object::EAC_Signed_Object
EAC_Signed_Object()
Definition: signed_obj.h:83
Botan::X509_Encoding
X509_Encoding
Definition: pubkey_enums.h:67
Botan::PKCS8::PEM_encode
std::string PEM_encode(const Private_Key &key)
Definition: pkcs8.cpp:150
Botan::EAC_Signed_Object::PEM_label_pref
std::string PEM_label_pref
Definition: signed_obj.h:87
Botan::MemoryRegion< byte >
Botan
Definition: algo_base.h:14
Botan::EAC_Signed_Object::PEM_labels_allowed
std::vector< std::string > PEM_labels_allowed
Definition: signed_obj.h:88
Botan::PEM
Definition: pubkey_enums.h:67
Botan::Public_Key
Definition: pk_keys.h:21
Botan::EAC_Signed_Object::~EAC_Signed_Object
virtual ~EAC_Signed_Object()
Definition: signed_obj.h:80
Botan::PEM_Code::encode
std::string encode(const byte der[], size_t length, const std::string &label, size_t width)
Definition: pem.cpp:19
Botan::AlgorithmIdentifier
Definition: alg_id.h:20
Botan::SecureVector< byte >
Botan::Pipe
Definition: pipe.h:25
Botan::EAC_Signed_Object::tbs_bits
SecureVector< byte > tbs_bits
Definition: signed_obj.h:86
Botan::EAC_Signed_Object
Definition: signed_obj.h:22