Download
Documentation
Development
Examples
Donations
Contributions
Forum
Sources
API
Core
Crypto
rsa.h
1
/*
2
** ClanLib SDK
3
** Copyright (c) 1997-2013 The ClanLib Team
4
**
5
** This software is provided 'as-is', without any express or implied
6
** warranty. In no event will the authors be held liable for any damages
7
** arising from the use of this software.
8
**
9
** Permission is granted to anyone to use this software for any purpose,
10
** including commercial applications, and to alter it and redistribute it
11
** freely, subject to the following restrictions:
12
**
13
** 1. The origin of this software must not be misrepresented; you must not
14
** claim that you wrote the original software. If you use this software
15
** in a product, an acknowledgment in the product documentation would be
16
** appreciated but is not required.
17
** 2. Altered source versions must be plainly marked as such, and must not be
18
** misrepresented as being the original software.
19
** 3. This notice may not be removed or altered from any source distribution.
20
**
21
** Note: Some of the libraries ClanLib may link to may have additional
22
** requirements or restrictions.
23
**
24
** File Author(s):
25
**
26
** Mark Page
27
** Michael J. Fromberger
28
*/
29
30
// This class is based on the original MPI library (not NSS, because of license restrictions) with some modifications.
31
// Some ideas and algorithms are from NSS (Netscape Security Suite). Where they have been used, the function contains a reference note
32
//
33
// Note, since September 2011, I believe the MPI homepage is now: http://spinning-yarns.org/michael/mpi/
34
// The license is as follows
35
// This software was written by Michael J. Fromberger,
36
// http://www.dartmouth.edu/~sting/
37
//
38
// See the MPI home page at
39
// http://www.dartmouth.edu/~sting/mpi/
40
//
41
// This software is in the public domain. It is entirely free, and you
42
// may use it and/or redistribute it for whatever purpose you choose;
43
// however, as free software, it is provided without warranty of any
44
// kind, not even the implied warranty of merchantability or fitness for
45
// a particular purpose.
46
47
48
#pragma once
49
50
#include "../api_core.h"
51
52
namespace
clan
53
{
56
57
class
Random;
58
class
Secret;
59
class
DataBuffer;
60
64
class
CL_API_CORE
RSA
65
{
68
69
public
:
70
79
static
void
create_keypair(
Random
&random,
Secret
&out_private_exponent,
DataBuffer
&out_public_exponent,
DataBuffer
&out_modulus,
int
key_size_in_bits = 1024,
int
public_exponent_value = 65537);
80
89
static
DataBuffer
encrypt(
int
block_type,
Random
&random,
const
DataBuffer
&in_public_exponent,
const
DataBuffer
&in_modulus,
const
Secret
&in_data);
90
102
static
DataBuffer
encrypt(
int
block_type,
Random
&random,
const
void
*in_public_exponent,
unsigned
int
in_public_exponent_size,
const
void
*in_modulus,
unsigned
int
in_modulus_size,
const
void
*in_data,
unsigned
int
in_data_size);
103
113
static
Secret
decrypt(
const
Secret
&in_private_exponent,
const
DataBuffer
&in_modulus,
const
DataBuffer
&in_data);
114
126
static
Secret
decrypt(
const
Secret
&in_private_exponent,
const
void
*in_modulus,
unsigned
int
in_modulus_size,
const
void
*in_data,
unsigned
int
in_data_size);
128
};
129
130
}
131
clan::Random
Random class.
Definition:
random.h:47
clan::RSA
RSA class.
Definition:
rsa.h:64
clan::DataBuffer
General purpose data buffer.
Definition:
databuffer.h:43
clan::Secret
Key class.
Definition:
secret.h:46