/* * X.509 Public Key * (C) 1999-2010 Jack Lloyd * * Distributed under the terms of the Botan license */ #ifndef BOTAN_X509_PUBLIC_KEY_H__ #define BOTAN_X509_PUBLIC_KEY_H__ #include #include #include #include namespace Botan { /** * This namespace contains functions for handling X.509 public keys */ namespace X509 { /** * BER encode a key * @param key the public key to encode * @return BER encoding of this key */ BOTAN_DLL MemoryVector BER_encode(const Public_Key& key); /** * PEM encode a public key into a string. * @param key the key to encode * @return PEM encoded key */ BOTAN_DLL std::string PEM_encode(const Public_Key& key); /** * Create a public key from a data source. * @param source the source providing the DER or PEM encoded key * @return new public key object */ BOTAN_DLL Public_Key* load_key(DataSource& source); /** * Create a public key from a file * @param filename pathname to the file to load * @return new public key object */ BOTAN_DLL Public_Key* load_key(const std::string& filename); /** * Create a public key from a memory region. * @param enc the memory region containing the DER or PEM encoded key * @return new public key object */ BOTAN_DLL Public_Key* load_key(const MemoryRegion& enc); /** * Copy a key. * @param key the public key to copy * @return new public key object */ BOTAN_DLL Public_Key* copy_key(const Public_Key& key); /** * Create the key constraints for a specific public key. * @param pub_key the public key from which the basic set of * constraints to be placed in the return value is derived * @param limits additional limits that will be incorporated into the * return value * @return combination of key type specific constraints and * additional limits */ BOTAN_DLL Key_Constraints find_constraints(const Public_Key& pub_key, Key_Constraints limits); /** * Encode a key into a pipe. * @deprecated Use PEM_encode or BER_encode instead * * @param key the public key to encode * @param pipe the pipe to feed the encoded key into * @param encoding the encoding type to use */ inline void encode(const Public_Key& key, Pipe& pipe, X509_Encoding encoding = PEM) { if(encoding == PEM) pipe.write(X509::PEM_encode(key)); else pipe.write(X509::BER_encode(key)); } } } #endif