3 * The RSA publickey algorithm, RSAREF compatible interface.
6 /* nettle, low-level cryptographics library
8 * Copyright (C) 2001 Niels Möller
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,
26 #ifndef NETTLE_RSA_COMPAT_H_INCLUDED
27 #define NETTLE_RSA_COMPAT_H_INCLUDED
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
49 uint8_t modulus
[MAX_RSA_MODULUS_LEN
];
50 uint8_t exponent
[MAX_RSA_MODULUS_LEN
];
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
];
64 /* Only MD5 is supported for now */
70 /* Digest algorithms */
71 /* DA_MD2 not implemented */
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 */
94 R_SignInit(R_SIGNATURE_CTX
*ctx
,
98 R_SignUpdate(R_SIGNATURE_CTX
*ctx
,
100 /* Length is an unsigned char according to rsaref.txt,
101 * but that must be a typo. */
105 R_SignFinal(R_SIGNATURE_CTX
*ctx
,
108 R_RSA_PRIVATE_KEY
*key
);
111 R_VerifyInit(R_SIGNATURE_CTX
*ctx
,
112 int digestAlgorithm
);
115 R_VerifyUpdate(R_SIGNATURE_CTX
*ctx
,
117 /* Length is an unsigned char according to rsaref.txt,
118 * but that must be a typo. */
122 R_VerifyFinal(R_SIGNATURE_CTX
*ctx
,
125 R_RSA_PUBLIC_KEY
*key
);
131 #endif /* NETTLE_RSA_COMPAT_H_INCLUDED */