libdigidocpp
|
#include <RSACrypt.h>
Public Member Functions | |
RSACrypt (X509 *cert, RSA *privateKey) | |
RSACrypt (X509 *cert) | |
RSACrypt (RSA *privateKey) | |
~RSACrypt () | |
std::vector< unsigned char > | sign (const Signer::Digest &digest) throw (IOException) |
bool | verify (int digestMethod, std::vector< unsigned char > digest, std::vector< unsigned char > signature) throw (IOException) |
Static Public Member Functions | |
static RSA * | loadRSAPrivateKey (const std::string &path) throw (IOException) |
Private Attributes | |
X509 * | cert |
RSA * | privateKey |
Wrapper for RSA crypto function in OpenSSL. Currently implemented RSA signature verification and signing with private RSA key.
Definition at line 37 of file RSACrypt.h.
digidoc::RSACrypt::RSACrypt | ( | X509 * | cert, |
RSA * | privateKey | ||
) |
Initialize RSA crypter.
cert | X.509 certificate. |
privateKey | RSA private key, must match with the provided X.509 certificate. |
Definition at line 32 of file RSACrypt.cpp.
digidoc::RSACrypt::RSACrypt | ( | X509 * | cert | ) |
Initialize RSA crypter.
cert | X.509 certificate. |
Definition at line 43 of file RSACrypt.cpp.
digidoc::RSACrypt::RSACrypt | ( | RSA * | privateKey | ) |
Initialize RSA crypter.
privateKey | RSA private key. |
Definition at line 54 of file RSACrypt.cpp.
digidoc::RSACrypt::~RSACrypt | ( | ) |
Definition at line 63 of file RSACrypt.cpp.
|
static |
Loads RSA private key from file. NB! This struct must be freed using RSA_free() function from OpenSSL or with RSA_scope struct.
path | PEM formatted RSA private key file path. |
IOException | throws exception if the file does not contain RSA private key. |
Definition at line 154 of file RSACrypt.cpp.
References file, and THROW_IOEXCEPTION.
Referenced by testRSASigner().
std::vector< unsigned char > digidoc::RSACrypt::sign | ( | const Signer::Digest & | digest | ) | throw (IOException) |
Signs the digest with provided RSA private key.
digestMethod | digest method (e.g NID_sha1 for SHA1, see openssl/obj_mac.h). |
digest | digest value, this value is signed with the private RSA key. |
IOException |
Definition at line 75 of file RSACrypt.cpp.
References THROW_IOEXCEPTION.
Referenced by digidoc::RSASigner::sign().
bool digidoc::RSACrypt::verify | ( | int | digestMethod, |
std::vector< unsigned char > | digest, | ||
std::vector< unsigned char > | signature | ||
) | throw (IOException) |
Verify signature with RSA public key from X.509 certificate.
digestMethod | digest method (e.g NID_sha1 for SHA1, see openssl/obj_mac.h). |
digest | digest value, this value is compared with the digest value decrypted from the signature . |
signature | signature value, this value is decrypted to get the digest and compared with the digest value provided in digest . |
true
if the signature value matches with the digest, otherwise false
is returned. IOException | throws exception if X.509 certificate is not missing or does not have a RSA public key. |
Definition at line 120 of file RSACrypt.cpp.
References int(), and THROW_IOEXCEPTION.
|
private |
Definition at line 50 of file RSACrypt.h.
|
private |
Definition at line 51 of file RSACrypt.h.