cfb8: Fix decrypt path
[gd/nettle] / pkcs1.h
1 /* pkcs1.h
2
3    PKCS1 embedding.
4
5    Copyright (C) 2003 Niels Möller
6
7    This file is part of GNU Nettle.
8
9    GNU Nettle is free software: you can redistribute it and/or
10    modify it under the terms of either:
11
12      * the GNU Lesser General Public License as published by the Free
13        Software Foundation; either version 3 of the License, or (at your
14        option) any later version.
15
16    or
17
18      * the GNU General Public License as published by the Free
19        Software Foundation; either version 2 of the License, or (at your
20        option) any later version.
21
22    or both in parallel, as here.
23
24    GNU Nettle is distributed in the hope that it will be useful,
25    but WITHOUT ANY WARRANTY; without even the implied warranty of
26    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
27    General Public License for more details.
28
29    You should have received copies of the GNU General Public License and
30    the GNU Lesser General Public License along with this program.  If
31    not, see http://www.gnu.org/licenses/.
32 */
33
34 #ifndef NETTLE_PKCS1_H_INCLUDED
35 #define NETTLE_PKCS1_H_INCLUDED
36
37 #include "nettle-types.h"
38 #include "bignum.h"
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 /* Name mangling */
45 #define pkcs1_rsa_digest_encode nettle_pkcs1_rsa_digest_encode
46 #define pkcs1_rsa_md5_encode nettle_pkcs1_rsa_md5_encode
47 #define pkcs1_rsa_md5_encode_digest nettle_pkcs1_rsa_md5_encode_digest
48 #define pkcs1_rsa_sha1_encode nettle_pkcs1_rsa_sha1_encode
49 #define pkcs1_rsa_sha1_encode_digest nettle_pkcs1_rsa_sha1_encode_digest
50 #define pkcs1_rsa_sha256_encode nettle_pkcs1_rsa_sha256_encode
51 #define pkcs1_rsa_sha256_encode_digest nettle_pkcs1_rsa_sha256_encode_digest
52 #define pkcs1_rsa_sha512_encode nettle_pkcs1_rsa_sha512_encode
53 #define pkcs1_rsa_sha512_encode_digest nettle_pkcs1_rsa_sha512_encode_digest
54 #define pkcs1_encrypt nettle_pkcs1_encrypt
55 #define pkcs1_decrypt nettle_pkcs1_decrypt
56
57 struct md5_ctx;
58 struct sha1_ctx;
59 struct sha256_ctx;
60 struct sha512_ctx;
61
62 int
63 pkcs1_encrypt (size_t key_size,
64                /* For padding */
65                void *random_ctx, nettle_random_func *random,
66                size_t length, const uint8_t *message,
67                mpz_t m);
68
69 int
70 pkcs1_decrypt (size_t key_size,
71                const mpz_t m,
72                size_t *length, uint8_t *message);
73
74 int
75 pkcs1_rsa_digest_encode(mpz_t m, size_t key_size,
76                         size_t di_length, const uint8_t *digest_info);
77
78 int
79 pkcs1_rsa_md5_encode(mpz_t m, size_t length, struct md5_ctx *hash);
80
81 int
82 pkcs1_rsa_md5_encode_digest(mpz_t m, size_t length, const uint8_t *digest);
83
84 int
85 pkcs1_rsa_sha1_encode(mpz_t m, size_t length, struct sha1_ctx *hash);
86
87 int
88 pkcs1_rsa_sha1_encode_digest(mpz_t m, size_t length, const uint8_t *digest);
89
90 int
91 pkcs1_rsa_sha256_encode(mpz_t m, size_t length, struct sha256_ctx *hash);
92
93 int
94 pkcs1_rsa_sha256_encode_digest(mpz_t m, size_t length, const uint8_t *digest);
95
96 int
97 pkcs1_rsa_sha512_encode(mpz_t m, size_t length, struct sha512_ctx *hash);
98
99 int
100 pkcs1_rsa_sha512_encode_digest(mpz_t m, size_t length, const uint8_t *digest);
101
102 #ifdef __cplusplus
103 }
104 #endif
105
106 #endif /* NETTLE_PKCS1_H_INCLUDED */