Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / nettle / rsa-compat.h
blob95b5592b9187e7f733698793dd20c999f5f97fc5
1 /* rsa-compat.h
3 * The RSA publickey algorithm, RSAREF compatible interface.
4 */
6 /* nettle, low-level cryptographics library
8 * Copyright (C) 2001 Niels Möller
9 *
10 * The nettle library is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or (at your
13 * option) any later version.
15 * The nettle library is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with the nettle library; see the file COPYING.LIB. If not, write to
22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23 * MA 02111-1301, USA.
26 #ifndef NETTLE_RSA_COMPAT_H_INCLUDED
27 #define NETTLE_RSA_COMPAT_H_INCLUDED
29 #include "rsa.h"
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
35 /* Name mangling */
36 #define R_SignInit nettle_R_SignInit
37 #define R_SignUpdate nettle_R_SignUpdate
38 #define R_SignFinal nettle_R_SignFinal
39 #define R_VerifyInit nettle_R_VerifyInit
40 #define R_VerifyUpdate nettle_R_VerifyUpdate
41 #define R_VerifyFinal nettle_R_VerifyFinal
43 /* 256 octets or 2048 bits */
44 #define MAX_RSA_MODULUS_LEN 256
46 typedef struct
48 unsigned bits;
49 uint8_t modulus[MAX_RSA_MODULUS_LEN];
50 uint8_t exponent[MAX_RSA_MODULUS_LEN];
51 } R_RSA_PUBLIC_KEY;
53 typedef struct
55 unsigned bits;
56 uint8_t modulus[MAX_RSA_MODULUS_LEN];
57 uint8_t publicExponent[MAX_RSA_MODULUS_LEN];
58 uint8_t exponent[MAX_RSA_MODULUS_LEN];
59 uint8_t prime[2][MAX_RSA_MODULUS_LEN];
60 uint8_t primeExponent[2][MAX_RSA_MODULUS_LEN];
61 uint8_t coefficient[MAX_RSA_MODULUS_LEN];
62 } R_RSA_PRIVATE_KEY;
64 /* Only MD5 is supported for now */
65 typedef struct
67 struct md5_ctx hash;
68 } R_SIGNATURE_CTX;
70 /* Digest algorithms */
71 /* DA_MD2 not implemented */
72 enum { DA_MD5 = 1 };
74 /* Return values */
75 enum {
76 RE_SUCCESS = 0,
77 RE_CONTENT_ENCODING, /* encryptedContent has RFC 1421 encoding error */
78 RE_DATA, /* other party's private value out of range */
79 RE_DIGEST_ALGORITHM, /* message-digest algorithm is invalid */
80 RE_ENCODING, /* encoded block has RFC 1421 encoding error */
81 RE_ENCRYPTION_ALGORITHM, /* encryption algorithm is invalid */
82 RE_KEY, /* recovered data encryption key cannot decrypt */
83 RE_KEY_ENCODING, /* encrypted key has RFC 1421 encoding error */
84 RE_LEN, /* signatureLen out of range */
85 RE_MODULUS_LEN, /* modulus length invalid */
86 RE_NEED_RANDOM, /* random structure is not seeded */
87 RE_PRIVATE_KEY, /* private key cannot encrypt message digest, */
88 RE_PUBLIC_KEY, /* publicKey cannot decrypt signature */
89 RE_SIGNATURE, /* signature is incorrect */
90 RE_SIGNATURE_ENCODING, /* encodedSignature has RFC 1421 encoding error */
93 int
94 R_SignInit(R_SIGNATURE_CTX *ctx,
95 int digestAlgorithm);
97 int
98 R_SignUpdate(R_SIGNATURE_CTX *ctx,
99 const uint8_t *data,
100 /* Length is an unsigned char according to rsaref.txt,
101 * but that must be a typo. */
102 unsigned length);
105 R_SignFinal(R_SIGNATURE_CTX *ctx,
106 uint8_t *signature,
107 unsigned *length,
108 R_RSA_PRIVATE_KEY *key);
111 R_VerifyInit(R_SIGNATURE_CTX *ctx,
112 int digestAlgorithm);
115 R_VerifyUpdate(R_SIGNATURE_CTX *ctx,
116 const uint8_t *data,
117 /* Length is an unsigned char according to rsaref.txt,
118 * but that must be a typo. */
119 unsigned length);
122 R_VerifyFinal(R_SIGNATURE_CTX *ctx,
123 uint8_t *signature,
124 unsigned length,
125 R_RSA_PUBLIC_KEY *key);
127 #ifdef __cplusplus
129 #endif
131 #endif /* NETTLE_RSA_COMPAT_H_INCLUDED */