2015-01-22 03:40:55 +00:00
|
|
|
/*
|
2016-05-17 18:51:34 +00:00
|
|
|
* Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
|
1999-09-08 18:02:25 +00:00
|
|
|
*
|
2016-05-17 18:51:34 +00:00
|
|
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
1999-09-08 18:02:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2015-05-14 14:56:48 +00:00
|
|
|
#include "internal/cryptlib.h"
|
1999-09-08 18:02:25 +00:00
|
|
|
#include <openssl/bn.h>
|
2016-04-02 16:46:17 +00:00
|
|
|
#include "rsa_locl.h"
|
1999-09-08 18:02:25 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
/*
|
|
|
|
* This is a dummy RSA implementation that just returns errors when called.
|
1999-09-08 18:02:25 +00:00
|
|
|
* It is designed to allow some RSA functions to work while stopping those
|
|
|
|
* covered by the RSA patent. That is RSA, encryption, decryption, signing
|
|
|
|
* and verify is not allowed but RSA key generation, key checking and other
|
|
|
|
* operations (like storing RSA keys) are permitted.
|
|
|
|
*/
|
|
|
|
|
2000-11-06 22:34:17 +00:00
|
|
|
static int RSA_null_public_encrypt(int flen, const unsigned char *from,
|
2015-01-22 03:40:55 +00:00
|
|
|
unsigned char *to, RSA *rsa, int padding);
|
2000-11-06 22:34:17 +00:00
|
|
|
static int RSA_null_private_encrypt(int flen, const unsigned char *from,
|
2015-01-22 03:40:55 +00:00
|
|
|
unsigned char *to, RSA *rsa, int padding);
|
2000-11-06 22:34:17 +00:00
|
|
|
static int RSA_null_public_decrypt(int flen, const unsigned char *from,
|
2015-01-22 03:40:55 +00:00
|
|
|
unsigned char *to, RSA *rsa, int padding);
|
2000-11-06 22:34:17 +00:00
|
|
|
static int RSA_null_private_decrypt(int flen, const unsigned char *from,
|
2015-01-22 03:40:55 +00:00
|
|
|
unsigned char *to, RSA *rsa, int padding);
|
1999-09-08 18:02:25 +00:00
|
|
|
static int RSA_null_init(RSA *rsa);
|
|
|
|
static int RSA_null_finish(RSA *rsa);
|
2015-01-22 03:40:55 +00:00
|
|
|
static RSA_METHOD rsa_null_meth = {
|
|
|
|
"Null RSA",
|
|
|
|
RSA_null_public_encrypt,
|
|
|
|
RSA_null_public_decrypt,
|
|
|
|
RSA_null_private_encrypt,
|
|
|
|
RSA_null_private_decrypt,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
RSA_null_init,
|
|
|
|
RSA_null_finish,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
1999-09-08 18:02:25 +00:00
|
|
|
|
2000-11-07 13:49:46 +00:00
|
|
|
const RSA_METHOD *RSA_null_method(void)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
|
|
|
return (&rsa_null_meth);
|
|
|
|
}
|
1999-09-08 18:02:25 +00:00
|
|
|
|
2000-11-06 22:34:17 +00:00
|
|
|
static int RSA_null_public_encrypt(int flen, const unsigned char *from,
|
2015-01-22 03:40:55 +00:00
|
|
|
unsigned char *to, RSA *rsa, int padding)
|
|
|
|
{
|
|
|
|
RSAerr(RSA_F_RSA_NULL_PUBLIC_ENCRYPT, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
|
|
|
|
return -1;
|
|
|
|
}
|
1999-09-08 18:02:25 +00:00
|
|
|
|
2000-11-06 22:34:17 +00:00
|
|
|
static int RSA_null_private_encrypt(int flen, const unsigned char *from,
|
2015-01-22 03:40:55 +00:00
|
|
|
unsigned char *to, RSA *rsa, int padding)
|
|
|
|
{
|
|
|
|
RSAerr(RSA_F_RSA_NULL_PRIVATE_ENCRYPT,
|
|
|
|
RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
|
|
|
|
return -1;
|
|
|
|
}
|
1999-09-08 18:02:25 +00:00
|
|
|
|
2000-11-06 22:34:17 +00:00
|
|
|
static int RSA_null_private_decrypt(int flen, const unsigned char *from,
|
2015-01-22 03:40:55 +00:00
|
|
|
unsigned char *to, RSA *rsa, int padding)
|
|
|
|
{
|
|
|
|
RSAerr(RSA_F_RSA_NULL_PRIVATE_DECRYPT,
|
|
|
|
RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
|
|
|
|
return -1;
|
|
|
|
}
|
1999-09-08 18:02:25 +00:00
|
|
|
|
2000-11-06 22:34:17 +00:00
|
|
|
static int RSA_null_public_decrypt(int flen, const unsigned char *from,
|
2015-01-22 03:40:55 +00:00
|
|
|
unsigned char *to, RSA *rsa, int padding)
|
|
|
|
{
|
|
|
|
RSAerr(RSA_F_RSA_NULL_PUBLIC_DECRYPT, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
|
|
|
|
return -1;
|
|
|
|
}
|
1999-09-08 18:02:25 +00:00
|
|
|
|
|
|
|
static int RSA_null_init(RSA *rsa)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
|
|
|
return (1);
|
|
|
|
}
|
1999-09-08 18:02:25 +00:00
|
|
|
|
|
|
|
static int RSA_null_finish(RSA *rsa)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
|
|
|
return (1);
|
|
|
|
}
|