Botan
1.11.15
|
00001 /* 00002 * X.509 Public Key 00003 * (C) 1999-2010 Jack Lloyd 00004 * 00005 * Botan is released under the Simplified BSD License (see license.txt) 00006 */ 00007 00008 #ifndef BOTAN_X509_PUBLIC_KEY_H__ 00009 #define BOTAN_X509_PUBLIC_KEY_H__ 00010 00011 #include <botan/pk_keys.h> 00012 #include <botan/alg_id.h> 00013 #include <botan/pipe.h> 00014 #include <string> 00015 00016 namespace Botan { 00017 00018 /** 00019 * The two types of X509 encoding supported by Botan. 00020 */ 00021 enum X509_Encoding { RAW_BER, PEM }; 00022 00023 /** 00024 * This namespace contains functions for handling X.509 public keys 00025 */ 00026 namespace X509 { 00027 00028 /** 00029 * BER encode a key 00030 * @param key the public key to encode 00031 * @return BER encoding of this key 00032 */ 00033 BOTAN_DLL std::vector<byte> BER_encode(const Public_Key& key); 00034 00035 /** 00036 * PEM encode a public key into a string. 00037 * @param key the key to encode 00038 * @return PEM encoded key 00039 */ 00040 BOTAN_DLL std::string PEM_encode(const Public_Key& key); 00041 00042 /** 00043 * Create a public key from a data source. 00044 * @param source the source providing the DER or PEM encoded key 00045 * @return new public key object 00046 */ 00047 BOTAN_DLL Public_Key* load_key(DataSource& source); 00048 00049 /** 00050 * Create a public key from a file 00051 * @param filename pathname to the file to load 00052 * @return new public key object 00053 */ 00054 BOTAN_DLL Public_Key* load_key(const std::string& filename); 00055 00056 /** 00057 * Create a public key from a memory region. 00058 * @param enc the memory region containing the DER or PEM encoded key 00059 * @return new public key object 00060 */ 00061 BOTAN_DLL Public_Key* load_key(const std::vector<byte>& enc); 00062 00063 /** 00064 * Copy a key. 00065 * @param key the public key to copy 00066 * @return new public key object 00067 */ 00068 BOTAN_DLL Public_Key* copy_key(const Public_Key& key); 00069 00070 } 00071 00072 } 00073 00074 #endif