Botan 1.10.17
x509_obj.h
Go to the documentation of this file.
1/*
2* X.509 SIGNED Object
3* (C) 1999-2007 Jack Lloyd
4*
5* Distributed under the terms of the Botan license
6*/
7
8#ifndef BOTAN_X509_OBJECT_H__
9#define BOTAN_X509_OBJECT_H__
10
11#include <botan/asn1_obj.h>
12#include <botan/pipe.h>
13#include <botan/pubkey_enums.h>
14#include <botan/rng.h>
15#include <vector>
16
17namespace Botan {
18
19/**
20* This class represents abstract X.509 signed objects as
21* in the X.500 SIGNED macro
22*/
23class BOTAN_DLL X509_Object
24 {
25 public:
26 /**
27 * The underlying data that is to be or was signed
28 * @return data that is or was signed
29 */
31
32 /**
33 * @return signature on tbs_data()
34 */
36
37 /**
38 * @return signature algorithm that was used to generate signature
39 */
41
42 /**
43 * @return hash algorithm that was used to generate signature
44 */
45 std::string hash_used_for_signature() const;
46
47 /**
48 * Create a signed X509 object.
49 * @param signer the signer used to sign the object
50 * @param rng the random number generator to use
51 * @param alg_id the algorithm identifier of the signature scheme
52 * @param tbs the tbs bits to be signed
53 * @return signed X509 object
54 */
55 static MemoryVector<byte> make_signed(class PK_Signer* signer,
57 const AlgorithmIdentifier& alg_id,
58 const MemoryRegion<byte>& tbs);
59
60 /**
61 * Check the signature on this data
62 * @param key the public key purportedly used to sign this data
63 * @return true if the signature is valid, otherwise false
64 */
65 bool check_signature(class Public_Key& key) const;
66
67 /**
68 * Check the signature on this data
69 * @param key the public key purportedly used to sign this data
70 * the pointer will be deleted after use
71 * @return true if the signature is valid, otherwise false
72 */
73 bool check_signature(class Public_Key* key) const;
74
75 /**
76 * @return BER encoding of this
77 */
79
80 /**
81 * @return PEM encoding of this
82 */
83 std::string PEM_encode() const;
84
85 /**
86 * Encode this to a pipe
87 * @deprecated use BER_encode or PEM_encode instead
88 * @param out the pipe to write to
89 * @param encoding the encoding to use
90 */
91 BOTAN_DEPRECATED("Use BER_encode or PEM_encode")
92 void encode(Pipe& out, X509_Encoding encoding = PEM) const;
93
94 virtual ~X509_Object() {}
95 protected:
96 X509_Object(DataSource& src, const std::string& pem_labels);
97 X509_Object(const std::string& file, const std::string& pem_labels);
98
99 void do_decode();
103 private:
104 virtual void force_decode() = 0;
105 void init(DataSource&, const std::string&);
106 void decode_info(DataSource&);
107 std::vector<std::string> PEM_labels_allowed;
108 std::string PEM_label_pref;
109 };
110
111}
112
113#endif
static MemoryVector< byte > make_signed(class PK_Signer *signer, RandomNumberGenerator &rng, const AlgorithmIdentifier &alg_id, const MemoryRegion< byte > &tbs)
Definition x509_obj.cpp:204
bool check_signature(class Public_Key &key) const
Definition x509_obj.cpp:178
MemoryVector< byte > sig
Definition x509_obj.h:102
std::string hash_used_for_signature() const
Definition x509_obj.cpp:148
X509_Object(DataSource &src, const std::string &pem_labels)
Definition x509_obj.cpp:24
std::string PEM_encode() const
Definition x509_obj.cpp:116
AlgorithmIdentifier signature_algorithm() const
Definition x509_obj.cpp:140
MemoryVector< byte > tbs_data() const
Definition x509_obj.cpp:124
MemoryVector< byte > signature() const
Definition x509_obj.cpp:132
AlgorithmIdentifier sig_algo
Definition x509_obj.h:101
MemoryVector< byte > BER_encode() const
Definition x509_obj.cpp:100
virtual ~X509_Object()
Definition x509_obj.h:94
MemoryVector< byte > tbs_bits
Definition x509_obj.h:102
void encode(Pipe &out, X509_Encoding encoding=PEM) const
Definition x509_obj.cpp:89