Botan 1.10.17
x509_key.h
Go to the documentation of this file.
1/*
2* X.509 Public Key
3* (C) 1999-2010 Jack Lloyd
4*
5* Distributed under the terms of the Botan license
6*/
7
8#ifndef BOTAN_X509_PUBLIC_KEY_H__
9#define BOTAN_X509_PUBLIC_KEY_H__
10
11#include <botan/pk_keys.h>
12#include <botan/alg_id.h>
13#include <botan/pubkey_enums.h>
14#include <botan/pipe.h>
15#include <string>
16
17namespace Botan {
18
19/**
20* This namespace contains functions for handling X.509 public keys
21*/
22namespace X509 {
23
24/**
25* BER encode a key
26* @param key the public key to encode
27* @return BER encoding of this key
28*/
29BOTAN_DLL MemoryVector<byte> BER_encode(const Public_Key& key);
30
31/**
32* PEM encode a public key into a string.
33* @param key the key to encode
34* @return PEM encoded key
35*/
36BOTAN_DLL std::string PEM_encode(const Public_Key& key);
37
38/**
39* Create a public key from a data source.
40* @param source the source providing the DER or PEM encoded key
41* @return new public key object
42*/
43BOTAN_DLL Public_Key* load_key(DataSource& source);
44
45/**
46* Create a public key from a file
47* @param filename pathname to the file to load
48* @return new public key object
49*/
50BOTAN_DLL Public_Key* load_key(const std::string& filename);
51
52/**
53* Create a public key from a memory region.
54* @param enc the memory region containing the DER or PEM encoded key
55* @return new public key object
56*/
57BOTAN_DLL Public_Key* load_key(const MemoryRegion<byte>& enc);
58
59/**
60* Copy a key.
61* @param key the public key to copy
62* @return new public key object
63*/
64BOTAN_DLL Public_Key* copy_key(const Public_Key& key);
65
66/**
67* Create the key constraints for a specific public key.
68* @param pub_key the public key from which the basic set of
69* constraints to be placed in the return value is derived
70* @param limits additional limits that will be incorporated into the
71* return value
72* @return combination of key type specific constraints and
73* additional limits
74*/
75BOTAN_DLL Key_Constraints find_constraints(const Public_Key& pub_key,
76 Key_Constraints limits);
77
78/**
79* Encode a key into a pipe.
80* @deprecated Use PEM_encode or BER_encode instead
81*
82* @param key the public key to encode
83* @param pipe the pipe to feed the encoded key into
84* @param encoding the encoding type to use
85*/
86BOTAN_DEPRECATED("Use PEM_encode or BER_encode")
87inline void encode(const Public_Key& key,
88 Pipe& pipe,
89 X509_Encoding encoding = PEM)
90 {
91 if(encoding == PEM)
92 pipe.write(X509::PEM_encode(key));
93 else
94 pipe.write(X509::BER_encode(key));
95 }
96
97}
98
99}
100
101#endif
std::string PEM_encode(const Public_Key &key)
Definition x509_key.cpp:34
MemoryVector< byte > BER_encode(const Public_Key &key)
Definition x509_key.cpp:21
Public_Key * copy_key(const Public_Key &key)
Definition x509_key.cpp:104
Public_Key * load_key(DataSource &source)
Definition x509_key.cpp:43
Key_Constraints find_constraints(const Public_Key &pub_key, Key_Constraints limits)
Definition x509_key.cpp:113
void encode(const Public_Key &key, Pipe &pipe, X509_Encoding encoding=PEM)
Definition x509_key.h:87
Key_Constraints