2 * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 #include "internal/cryptlib.h"
12 #include <openssl/bn.h>
16 * This is a dummy RSA implementation that just returns errors when called.
17 * It is designed to allow some RSA functions to work while stopping those
18 * covered by the RSA patent. That is RSA, encryption, decryption, signing
19 * and verify is not allowed but RSA key generation, key checking and other
20 * operations (like storing RSA keys) are permitted.
23 static int RSA_null_public_encrypt(int flen, const unsigned char *from,
24 unsigned char *to, RSA *rsa, int padding);
25 static int RSA_null_private_encrypt(int flen, const unsigned char *from,
26 unsigned char *to, RSA *rsa, int padding);
27 static int RSA_null_public_decrypt(int flen, const unsigned char *from,
28 unsigned char *to, RSA *rsa, int padding);
29 static int RSA_null_private_decrypt(int flen, const unsigned char *from,
30 unsigned char *to, RSA *rsa, int padding);
31 static int RSA_null_init(RSA *rsa);
32 static int RSA_null_finish(RSA *rsa);
33 static RSA_METHOD rsa_null_meth = {
35 RSA_null_public_encrypt,
36 RSA_null_public_decrypt,
37 RSA_null_private_encrypt,
38 RSA_null_private_decrypt,
50 const RSA_METHOD *RSA_null_method(void)
52 return (&rsa_null_meth);
55 static int RSA_null_public_encrypt(int flen, const unsigned char *from,
56 unsigned char *to, RSA *rsa, int padding)
58 RSAerr(RSA_F_RSA_NULL_PUBLIC_ENCRYPT, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
62 static int RSA_null_private_encrypt(int flen, const unsigned char *from,
63 unsigned char *to, RSA *rsa, int padding)
65 RSAerr(RSA_F_RSA_NULL_PRIVATE_ENCRYPT,
66 RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
70 static int RSA_null_private_decrypt(int flen, const unsigned char *from,
71 unsigned char *to, RSA *rsa, int padding)
73 RSAerr(RSA_F_RSA_NULL_PRIVATE_DECRYPT,
74 RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
78 static int RSA_null_public_decrypt(int flen, const unsigned char *from,
79 unsigned char *to, RSA *rsa, int padding)
81 RSAerr(RSA_F_RSA_NULL_PUBLIC_DECRYPT, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
85 static int RSA_null_init(RSA *rsa)
90 static int RSA_null_finish(RSA *rsa)