📄 privatekey.h
字号:
#ifndef PRIVATEKEY_H_#define PRIVATEKEY_H_#include <libmcrypto/config.h>#include <libmutil/Exception.h>#include <openssl/pem.h>#include <openssl/evp.h>#include <openssl/err.h>#include <libmcrypto/OpenSSLUtil.h>#include <string>#include <iostream>#include <fstream>/** * This class represents a private key (RSA). * The implementation of this class referes to the openssl library. */class LIBMCRYPTO_API PrivateKey{ public: /** * The constructor creates a new private key by opening it from a file. * @param file Filename (whole path) * @param passwd Password for private key */ PrivateKey(std::string file, std::string passwd); /** * Destructor of PrivateKey */ ~PrivateKey(); /** * This method creates a signature for the given data. * The signing process is implemented with the openssl functions. * @param data byte_t array with the data * @param dataLength Length of the data * @param signature byte_t array in which the signature is stored * @param signatureLength Length of the signature * @return boolean value if the signing was successful */ bool sign(byte_t* data, unsigned int dataLength, byte_t* signature, unsigned int& signatureLength); /** * Static method to check if a given private key is password protected. * @param file Filename (whole path) * @return boolean value if the key is protected by password */ static bool needsPasswd(std::string file); private: /** * openssl private key */ EVP_PKEY * privateKey;};class LIBMCRYPTO_API PrivateKeyException : public Exception{ public: /** * PrivateKey exception representing an exception withing the private key. * @param desc Description of the exception */ PrivateKeyException(const char *desc) : Exception(desc) {};};#endif /*PRIVATEKEY_H_*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -