70aa21f17ce66bf147b1a0a8b26ce77fae5d25f3
[platform/upstream/nettle.git] / 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_signature_prefix _nettle_pkcs1_signature_prefix
46 #define pkcs1_rsa_digest_encode nettle_pkcs1_rsa_digest_encode
47 #define pkcs1_rsa_md5_encode nettle_pkcs1_rsa_md5_encode
48 #define pkcs1_rsa_md5_encode_digest nettle_pkcs1_rsa_md5_encode_digest
49 #define pkcs1_rsa_sha1_encode nettle_pkcs1_rsa_sha1_encode
50 #define pkcs1_rsa_sha1_encode_digest nettle_pkcs1_rsa_sha1_encode_digest
51 #define pkcs1_rsa_sha256_encode nettle_pkcs1_rsa_sha256_encode
52 #define pkcs1_rsa_sha256_encode_digest nettle_pkcs1_rsa_sha256_encode_digest
53 #define pkcs1_rsa_sha512_encode nettle_pkcs1_rsa_sha512_encode
54 #define pkcs1_rsa_sha512_encode_digest nettle_pkcs1_rsa_sha512_encode_digest
55 #define pkcs1_encrypt nettle_pkcs1_encrypt
56 #define pkcs1_decrypt nettle_pkcs1_decrypt
57
58 struct md5_ctx;
59 struct sha1_ctx;
60 struct sha256_ctx;
61 struct sha512_ctx;
62
63 uint8_t *
64 _pkcs1_signature_prefix(unsigned key_size,
65                         uint8_t *buffer,
66                         unsigned id_size,
67                         const uint8_t *id,
68                         unsigned digest_size);
69
70 int
71 pkcs1_encrypt (size_t key_size,
72                /* For padding */
73                void *random_ctx, nettle_random_func *random,
74                size_t length, const uint8_t *message,
75                mpz_t m);
76
77 int
78 pkcs1_decrypt (size_t key_size,
79                const mpz_t m,
80                size_t *length, uint8_t *message);
81
82 int
83 pkcs1_rsa_digest_encode(mpz_t m, size_t key_size,
84                         size_t di_length, const uint8_t *digest_info);
85
86 int
87 pkcs1_rsa_md5_encode(mpz_t m, size_t length, struct md5_ctx *hash);
88
89 int
90 pkcs1_rsa_md5_encode_digest(mpz_t m, size_t length, const uint8_t *digest);
91
92 int
93 pkcs1_rsa_sha1_encode(mpz_t m, size_t length, struct sha1_ctx *hash);
94
95 int
96 pkcs1_rsa_sha1_encode_digest(mpz_t m, size_t length, const uint8_t *digest);
97
98 int
99 pkcs1_rsa_sha256_encode(mpz_t m, size_t length, struct sha256_ctx *hash);
100
101 int
102 pkcs1_rsa_sha256_encode_digest(mpz_t m, size_t length, const uint8_t *digest);
103
104 int
105 pkcs1_rsa_sha512_encode(mpz_t m, size_t length, struct sha512_ctx *hash);
106
107 int
108 pkcs1_rsa_sha512_encode_digest(mpz_t m, size_t length, const uint8_t *digest);
109
110 #ifdef __cplusplus
111 }
112 #endif
113
114 #endif /* NETTLE_PKCS1_H_INCLUDED */