summaryrefslogtreecommitdiff
path: root/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/rsa.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/rsa.h')
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/rsa.h121
1 files changed, 121 insertions, 0 deletions
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/rsa.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/rsa.h
new file mode 100755
index 0000000000..dbb0e45412
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/rsa.h
@@ -0,0 +1,121 @@
1/*
2 * Copyright (c) 2000, 2002 Virtual Unlimited B.V.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 */
19
20/*!\file rsa.h
21 * \brief RSA algorithm.
22 * \author Bob Deblier <bob.deblier@pandora.be>
23 * \ingroup IF_m IF_rsa_m
24 */
25
26#ifndef _RSA_H
27#define _RSA_H
28
29#include "beecrypt/rsakp.h"
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35/*!\fn int rsapub(const mpbarrett* n, const mpnumber* e, const mpnumber* m, mpnumber* c)
36 * \brief This function performs a raw RSA public key operation.
37 *
38 * This function can be used for encryption and verifying.
39 *
40 * It performs the following operation:
41 * \li \f$c=m^{e}\ \textrm{mod}\ n\f$
42 *
43 * \param n The RSA modulus.
44 * \param e The RSA public exponent.
45 * \param m The message.
46 * \param c The ciphertext.
47 * \retval 0 on success.
48 * \retval -1 on failure.
49 */
50BEECRYPTAPI
51int rsapub(const mpbarrett* n, const mpnumber* e,
52 const mpnumber* m, mpnumber* c);
53
54/*!\fn int rsapri(const mpbarrett* n, const mpnumber* d, const mpnumber* c, mpnumber* m)
55 * \brief This function performs a raw RSA private key operation.
56 *
57 * This function can be used for decryption and signing.
58 *
59 * It performs the operation:
60 * \li \f$m=c^{d}\ \textrm{mod}\ n\f$
61 *
62 * \param n The RSA modulus.
63 * \param d The RSA private exponent.
64 * \param c The ciphertext.
65 * \param m The message.
66 * \retval 0 on success.
67 * \retval -1 on failure.
68 */
69BEECRYPTAPI
70int rsapri(const mpbarrett* n, const mpnumber* d,
71 const mpnumber* c, mpnumber* m);
72
73/*!\fn int rsapricrt(const mpbarrett* n, const mpbarrett* p, const mpbarrett* q, const mpnumber* dp, const mpnumber* dq, const mpnumber* qi, const mpnumber* c, mpnumber* m)
74 *
75 * \brief This function performs a raw RSA private key operation, with
76 * application of the Chinese Remainder Theorem.
77 *
78 * It performs the operation:
79 * \li \f$j_1=c^{dp}\ \textrm{mod}\ p\f$
80 * \li \f$j_2=c^{dq}\ \textrm{mod}\ q\f$
81 * \li \f$h=qi \cdot (j_1-j_2)\ \textrm{mod}\ p\f$
82 * \li \f$m=j_2+hq\f$
83 *
84 * \param n The RSA modulus.
85 * \param p The first RSA prime factor.
86 * \param q The second RSA prime factor.
87 * \param dp
88 * \param dq
89 * \param qi
90 * \param c The ciphertext.
91 * \param m The message.
92 * \retval 0 on success.
93 * \retval -1 on failure.
94 */
95BEECRYPTAPI
96int rsapricrt(const mpbarrett* n, const mpbarrett* p, const mpbarrett* q,
97 const mpnumber* dp, const mpnumber* dq, const mpnumber* qi,
98 const mpnumber* c, mpnumber* m);
99
100/*!\fn int rsavrfy(const mpbarrett* n, const mpnumber* e, const mpnumber* m, const mpnumber* c)
101 * \brief This function performs a raw RSA verification.
102 *
103 * It verifies if ciphertext \a c was encrypted from cleartext \a m
104 * with the private key matching the given public key \a (n, e).
105 *
106 * \param n The RSA modulus.
107 * \param e The RSA public exponent.
108 * \param m The cleartext message.
109 * \param c The ciphertext message.
110 * \retval 1 on success.
111 * \retval 0 on failure.
112 */
113BEECRYPTAPI
114int rsavrfy(const mpbarrett* n, const mpnumber* e,
115 const mpnumber* m, const mpnumber* c);
116
117#ifdef __cplusplus
118}
119#endif
120
121#endif