feisty meow concerns codebase 2.140
old_school_rsa_crypto.h
Go to the documentation of this file.
1#ifndef OLD_SCHOOL_RSA_CRYPTO_CLASS
2#define OLD_SCHOOL_RSA_CRYPTO_CLASS
3
4/*****************************************************************************\
5* *
6* Name : RSA public key encryption *
7* Author : Chris Koeritz *
8* *
9*******************************************************************************
10* Copyright (c) 2005-$now By Author. This program is free software; you can *
11* redistribute it and/or modify it under the terms of the GNU General Public *
12* License as published by the Free Software Foundation; either version 2 of *
13* the License or (at your option) any later version. This is online at: *
14* http://www.fsf.org/copyleft/gpl.html *
15* Please send any updates to: fred@gruntose.com *
16\*****************************************************************************/
17
18#include <basis/byte_array.h>
19#include <basis/contracts.h>
20
21// forward.
22typedef struct rsa_st RSA;
23
24namespace crypto {
25
27
32{
33public:
34 old_school_rsa_crypto(int key_size);
36
41
48
50
51 virtual ~old_school_rsa_crypto();
52
54
55 DEFINE_CLASS_NAME("old_school_rsa_crypto");
56
57 bool set_key(basis::byte_array &key);
59
63 bool set_key(RSA *key);
65
67 bool check_key(RSA *key);
69
70 bool public_encrypt(const basis::byte_array &source, basis::byte_array &target) const;
72
75 bool private_decrypt(const basis::byte_array &source, basis::byte_array &target) const;
77
78 bool private_encrypt(const basis::byte_array &source, basis::byte_array &target) const;
80
83 bool public_decrypt(const basis::byte_array &source, basis::byte_array &target) const;
85
86 bool public_key(basis::byte_array &pubkey) const;
88 bool private_key(basis::byte_array &privkey) const;
90
92 static RSA *generate_key(int key_size);
94
95private:
96 RSA *_key;
97};
98
99} //namespace.
100
101#endif
102
A very common template for a dynamic array of bytes.
Definition byte_array.h:36
Root object for any class that knows its own name.
Definition contracts.h:123
Supports public key encryption and decryption.
bool private_key(basis::byte_array &privkey) const
makes a copy of the private key held here.
bool check_key(RSA *key)
checks the RSA "key" provided for validity.
bool private_encrypt(const basis::byte_array &source, basis::byte_array &target) const
encrypts "source" using our private key and stores it in "target".
const old_school_rsa_crypto & operator=(const old_school_rsa_crypto &to_copy)
bool private_decrypt(const basis::byte_array &source, basis::byte_array &target) const
decrypts "source" using our private key and stores it in "target".
bool set_key(basis::byte_array &key)
resets this object's key to "key".
bool public_encrypt(const basis::byte_array &source, basis::byte_array &target) const
encrypts "source" using our public key and stores it in "target".
DEFINE_CLASS_NAME("old_school_rsa_crypto")
static RSA * generate_key(int key_size)
creates a random RSA key using the lower-level openssl methods.
bool public_decrypt(const basis::byte_array &source, basis::byte_array &target) const
decrypts "source" using our public key and stores it in "target".
bool public_key(basis::byte_array &pubkey) const
makes a copy of the public key held here.
struct rsa_st RSA