159191Skris/* rsa_null.c */ 2296465Sdelphij/* 3296465Sdelphij * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project 4296465Sdelphij * 1999. 559191Skris */ 659191Skris/* ==================================================================== 759191Skris * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 859191Skris * 959191Skris * Redistribution and use in source and binary forms, with or without 1059191Skris * modification, are permitted provided that the following conditions 1159191Skris * are met: 1259191Skris * 1359191Skris * 1. Redistributions of source code must retain the above copyright 14296465Sdelphij * notice, this list of conditions and the following disclaimer. 1559191Skris * 1659191Skris * 2. Redistributions in binary form must reproduce the above copyright 1759191Skris * notice, this list of conditions and the following disclaimer in 1859191Skris * the documentation and/or other materials provided with the 1959191Skris * distribution. 2059191Skris * 2159191Skris * 3. All advertising materials mentioning features or use of this 2259191Skris * software must display the following acknowledgment: 2359191Skris * "This product includes software developed by the OpenSSL Project 2459191Skris * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 2559191Skris * 2659191Skris * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 2759191Skris * endorse or promote products derived from this software without 2859191Skris * prior written permission. For written permission, please contact 2959191Skris * licensing@OpenSSL.org. 3059191Skris * 3159191Skris * 5. Products derived from this software may not be called "OpenSSL" 3259191Skris * nor may "OpenSSL" appear in their names without prior written 3359191Skris * permission of the OpenSSL Project. 3459191Skris * 3559191Skris * 6. Redistributions of any form whatsoever must retain the following 3659191Skris * acknowledgment: 3759191Skris * "This product includes software developed by the OpenSSL Project 3859191Skris * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 3959191Skris * 4059191Skris * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 4159191Skris * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 4259191Skris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 4359191Skris * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 4459191Skris * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 4559191Skris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 4659191Skris * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 4759191Skris * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 4859191Skris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 4959191Skris * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 5059191Skris * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 5159191Skris * OF THE POSSIBILITY OF SUCH DAMAGE. 5259191Skris * ==================================================================== 5359191Skris * 5459191Skris * This product includes cryptographic software written by Eric Young 5559191Skris * (eay@cryptsoft.com). This product includes software written by Tim 5659191Skris * Hudson (tjh@cryptsoft.com). 5759191Skris * 5859191Skris */ 5959191Skris 6059191Skris#include <stdio.h> 6159191Skris#include "cryptlib.h" 6259191Skris#include <openssl/bn.h> 6359191Skris#include <openssl/rsa.h> 6459191Skris#include <openssl/rand.h> 6559191Skris 66296465Sdelphij/* 67296465Sdelphij * This is a dummy RSA implementation that just returns errors when called. 6859191Skris * It is designed to allow some RSA functions to work while stopping those 6959191Skris * covered by the RSA patent. That is RSA, encryption, decryption, signing 7059191Skris * and verify is not allowed but RSA key generation, key checking and other 7159191Skris * operations (like storing RSA keys) are permitted. 7259191Skris */ 7359191Skris 74109998Smarkmstatic int RSA_null_public_encrypt(int flen, const unsigned char *from, 75296465Sdelphij unsigned char *to, RSA *rsa, int padding); 76109998Smarkmstatic int RSA_null_private_encrypt(int flen, const unsigned char *from, 77296465Sdelphij unsigned char *to, RSA *rsa, int padding); 78109998Smarkmstatic int RSA_null_public_decrypt(int flen, const unsigned char *from, 79296465Sdelphij unsigned char *to, RSA *rsa, int padding); 80109998Smarkmstatic int RSA_null_private_decrypt(int flen, const unsigned char *from, 81296465Sdelphij unsigned char *to, RSA *rsa, int padding); 82296465Sdelphij#if 0 /* not currently used */ 83109998Smarkmstatic int RSA_null_mod_exp(const BIGNUM *r0, const BIGNUM *i, RSA *rsa); 8459191Skris#endif 8559191Skrisstatic int RSA_null_init(RSA *rsa); 8659191Skrisstatic int RSA_null_finish(RSA *rsa); 87296465Sdelphijstatic RSA_METHOD rsa_null_meth = { 88296465Sdelphij "Null RSA", 89296465Sdelphij RSA_null_public_encrypt, 90296465Sdelphij RSA_null_public_decrypt, 91296465Sdelphij RSA_null_private_encrypt, 92296465Sdelphij RSA_null_private_decrypt, 93296465Sdelphij NULL, 94296465Sdelphij NULL, 95296465Sdelphij RSA_null_init, 96296465Sdelphij RSA_null_finish, 97296465Sdelphij 0, 98296465Sdelphij NULL, 99296465Sdelphij NULL, 100296465Sdelphij NULL, 101296465Sdelphij NULL 102296465Sdelphij}; 10359191Skris 104109998Smarkmconst RSA_METHOD *RSA_null_method(void) 105296465Sdelphij{ 106296465Sdelphij return (&rsa_null_meth); 107296465Sdelphij} 10859191Skris 109109998Smarkmstatic int RSA_null_public_encrypt(int flen, const unsigned char *from, 110296465Sdelphij unsigned char *to, RSA *rsa, int padding) 111296465Sdelphij{ 112296465Sdelphij RSAerr(RSA_F_RSA_NULL_PUBLIC_ENCRYPT, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED); 113296465Sdelphij return -1; 114296465Sdelphij} 11559191Skris 116109998Smarkmstatic int RSA_null_private_encrypt(int flen, const unsigned char *from, 117296465Sdelphij unsigned char *to, RSA *rsa, int padding) 118296465Sdelphij{ 119296465Sdelphij RSAerr(RSA_F_RSA_NULL_PRIVATE_ENCRYPT, 120296465Sdelphij RSA_R_RSA_OPERATIONS_NOT_SUPPORTED); 121296465Sdelphij return -1; 122296465Sdelphij} 12359191Skris 124109998Smarkmstatic int RSA_null_private_decrypt(int flen, const unsigned char *from, 125296465Sdelphij unsigned char *to, RSA *rsa, int padding) 126296465Sdelphij{ 127296465Sdelphij RSAerr(RSA_F_RSA_NULL_PRIVATE_DECRYPT, 128296465Sdelphij RSA_R_RSA_OPERATIONS_NOT_SUPPORTED); 129296465Sdelphij return -1; 130296465Sdelphij} 13159191Skris 132109998Smarkmstatic int RSA_null_public_decrypt(int flen, const unsigned char *from, 133296465Sdelphij unsigned char *to, RSA *rsa, int padding) 134296465Sdelphij{ 135296465Sdelphij RSAerr(RSA_F_RSA_NULL_PUBLIC_DECRYPT, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED); 136296465Sdelphij return -1; 137296465Sdelphij} 13859191Skris 139296465Sdelphij#if 0 /* not currently used */ 14059191Skrisstatic int RSA_null_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa) 141296465Sdelphij{ 142296465Sdelphij ... err(RSA_F_RSA_NULL_MOD_EXP, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED); 143296465Sdelphij return -1; 144296465Sdelphij} 14559191Skris#endif 14659191Skris 14759191Skrisstatic int RSA_null_init(RSA *rsa) 148296465Sdelphij{ 149296465Sdelphij return (1); 150296465Sdelphij} 15159191Skris 15259191Skrisstatic int RSA_null_finish(RSA *rsa) 153296465Sdelphij{ 154296465Sdelphij return (1); 155296465Sdelphij} 156