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>
13 #include <openssl/rand.h>
17 * This is a dummy RSA implementation that just returns errors when called.
18 * It is designed to allow some RSA functions to work while stopping those
19 * covered by the RSA patent. That is RSA, encryption, decryption, signing
20 * and verify is not allowed but RSA key generation, key checking and other
21 * operations (like storing RSA keys) are permitted.
24 static int RSA_null_public_encrypt(int flen, const unsigned char *from,
25 unsigned char *to, RSA *rsa, int padding);
26 static int RSA_null_private_encrypt(int flen, const unsigned char *from,
27 unsigned char *to, RSA *rsa, int padding);
28 static int RSA_null_public_decrypt(int flen, const unsigned char *from,
29 unsigned char *to, RSA *rsa, int padding);
30 static int RSA_null_private_decrypt(int flen, const unsigned char *from,
31 unsigned char *to, RSA *rsa, int padding);
32 static int RSA_null_init(RSA *rsa);
33 static int RSA_null_finish(RSA *rsa);
34 static RSA_METHOD rsa_null_meth = {
36 RSA_null_public_encrypt,
37 RSA_null_public_decrypt,
38 RSA_null_private_encrypt,
39 RSA_null_private_decrypt,
51 const RSA_METHOD *RSA_null_method(void)
53 return (&rsa_null_meth);
56 static int RSA_null_public_encrypt(int flen, const unsigned char *from,
57 unsigned char *to, RSA *rsa, int padding)
59 RSAerr(RSA_F_RSA_NULL_PUBLIC_ENCRYPT, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
63 static int RSA_null_private_encrypt(int flen, const unsigned char *from,
64 unsigned char *to, RSA *rsa, int padding)
66 RSAerr(RSA_F_RSA_NULL_PRIVATE_ENCRYPT,
67 RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
71 static int RSA_null_private_decrypt(int flen, const unsigned char *from,
72 unsigned char *to, RSA *rsa, int padding)
74 RSAerr(RSA_F_RSA_NULL_PRIVATE_DECRYPT,
75 RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
79 static int RSA_null_public_decrypt(int flen, const unsigned char *from,
80 unsigned char *to, RSA *rsa, int padding)
82 RSAerr(RSA_F_RSA_NULL_PUBLIC_DECRYPT, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
86 static int RSA_null_init(RSA *rsa)
91 static int RSA_null_finish(RSA *rsa)