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
48 uint8_t modulus
[MAX_RSA_MODULUS_LEN
];
49 uint8_t exponent
[MAX_RSA_MODULUS_LEN
];
54 uint8_t modulus
[MAX_RSA_MODULUS_LEN
];
55 uint8_t publicExponent
[MAX_RSA_MODULUS_LEN
];
56 uint8_t exponent
[MAX_RSA_MODULUS_LEN
];
57 uint8_t prime
[2][MAX_RSA_MODULUS_LEN
];
58 uint8_t primeExponent
[2][MAX_RSA_MODULUS_LEN
];
59 uint8_t coefficient
[MAX_RSA_MODULUS_LEN
];
62 /* Only MD5 is supported for now */
67 /* Digest algorithms */
68 /* DA_MD2 not implemented */
74 RE_CONTENT_ENCODING
, /* encryptedContent has RFC 1421 encoding error */
75 RE_DATA
, /* other party's private value out of range */
76 RE_DIGEST_ALGORITHM
, /* message-digest algorithm is invalid */
77 RE_ENCODING
, /* encoded block has RFC 1421 encoding error */
78 RE_ENCRYPTION_ALGORITHM
, /* encryption algorithm is invalid */
79 RE_KEY
, /* recovered data encryption key cannot decrypt */
80 RE_KEY_ENCODING
, /* encrypted key has RFC 1421 encoding error */
81 RE_LEN
, /* signatureLen out of range */
82 RE_MODULUS_LEN
, /* modulus length invalid */
83 RE_NEED_RANDOM
, /* random structure is not seeded */
84 RE_PRIVATE_KEY
, /* private key cannot encrypt message digest, */
85 RE_PUBLIC_KEY
, /* publicKey cannot decrypt signature */
86 RE_SIGNATURE
, /* signature is incorrect */
87 RE_SIGNATURE_ENCODING
, /* encodedSignature has RFC 1421 encoding error */
91 R_SignInit(R_SIGNATURE_CTX
* ctx
, int digestAlgorithm
);
94 R_SignUpdate(R_SIGNATURE_CTX
* ctx
, const uint8_t * data
,
95 /* Length is an unsigned char according to rsaref.txt,
96 * but that must be a typo. */
100 R_SignFinal(R_SIGNATURE_CTX
* ctx
,
102 unsigned *length
, R_RSA_PRIVATE_KEY
* key
);
105 R_VerifyInit(R_SIGNATURE_CTX
* ctx
, int digestAlgorithm
);
108 R_VerifyUpdate(R_SIGNATURE_CTX
* ctx
, const uint8_t * data
,
109 /* Length is an unsigned char according to rsaref.txt,
110 * but that must be a typo. */
114 R_VerifyFinal(R_SIGNATURE_CTX
* ctx
,
116 unsigned length
, R_RSA_PUBLIC_KEY
* key
);
121 #endif /* NETTLE_RSA_COMPAT_H_INCLUDED */