2 * Copyright (c) 2000-2001,2011,2014 Apple Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
23 /* ====================================================================
24 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
26 * Redistribution and use in source and binary forms, with or without
27 * modification, are permitted provided that the following conditions
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
33 * 2. Redistributions in binary form must reproduce the above copyright
34 * notice, this list of conditions and the following disclaimer in
35 * the documentation and/or other materials provided with the
38 * 3. All advertising materials mentioning features or use of this
39 * software must display the following acknowledgment:
40 * "This product includes software developed by the OpenSSL Project
41 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
43 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44 * endorse or promote products derived from this software without
45 * prior written permission. For written permission, please contact
46 * licensing@OpenSSL.org.
48 * 5. Products derived from this software may not be called "OpenSSL"
49 * nor may "OpenSSL" appear in their names without prior written
50 * permission of the OpenSSL Project.
52 * 6. Redistributions of any form whatsoever must retain the following
54 * "This product includes software developed by the OpenSSL Project
55 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
57 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68 * OF THE POSSIBILITY OF SUCH DAMAGE.
69 * ====================================================================
71 * This product includes cryptographic software written by Eric Young
72 * (eay@cryptsoft.com). This product includes software written by Tim
73 * Hudson (tjh@cryptsoft.com).
79 #include <openssl/bn.h>
80 #include <openssl/rsa.h>
81 #include <openssl/rand.h>
83 /* This is a dummy RSA implementation that just returns errors when called.
84 * It is designed to allow some RSA functions to work while stopping those
85 * covered by the RSA patent. That is RSA, encryption, decryption, signing
86 * and verify is not allowed but RSA key generation, key checking and other
87 * operations (like storing RSA keys) are permitted.
90 static int RSA_null_public_encrypt(int flen
, unsigned char *from
,
91 unsigned char *to
, RSA
*rsa
,int padding
);
92 static int RSA_null_private_encrypt(int flen
, unsigned char *from
,
93 unsigned char *to
, RSA
*rsa
,int padding
);
94 static int RSA_null_public_decrypt(int flen
, unsigned char *from
,
95 unsigned char *to
, RSA
*rsa
,int padding
);
96 static int RSA_null_private_decrypt(int flen
, unsigned char *from
,
97 unsigned char *to
, RSA
*rsa
,int padding
);
98 #if 0 /* not currently used */
99 static int RSA_null_mod_exp(BIGNUM
*r0
, BIGNUM
*i
, RSA
*rsa
);
101 static int RSA_null_init(RSA
*rsa
);
102 static int RSA_null_finish(RSA
*rsa
);
103 static const RSA_METHOD rsa_null_meth
={
105 RSA_null_public_encrypt
,
106 RSA_null_public_decrypt
,
107 RSA_null_private_encrypt
,
108 RSA_null_private_decrypt
,
116 const RSA_METHOD
*RSA_null_method(void)
118 return(&rsa_null_meth
);
121 static int RSA_null_public_encrypt(int flen
, unsigned char *from
,
122 unsigned char *to
, RSA
*rsa
, int padding
)
124 RSAerr(RSA_F_RSA_NULL
, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED
);
128 static int RSA_null_private_encrypt(int flen
, unsigned char *from
,
129 unsigned char *to
, RSA
*rsa
, int padding
)
131 RSAerr(RSA_F_RSA_NULL
, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED
);
135 static int RSA_null_private_decrypt(int flen
, unsigned char *from
,
136 unsigned char *to
, RSA
*rsa
, int padding
)
138 RSAerr(RSA_F_RSA_NULL
, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED
);
142 static int RSA_null_public_decrypt(int flen
, unsigned char *from
,
143 unsigned char *to
, RSA
*rsa
, int padding
)
145 RSAerr(RSA_F_RSA_NULL
, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED
);
149 #if 0 /* not currently used */
150 static int RSA_null_mod_exp(BIGNUM
*r0
, BIGNUM
*I
, RSA
*rsa
)
152 RSAerr(RSA_F_RSA_NULL
, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED
);
157 static int RSA_null_init(RSA
*rsa
)
162 static int RSA_null_finish(RSA
*rsa
)