2016-05-18 02:24:46 +08:00
|
|
|
/*
|
|
|
|
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
1998-12-21 18:56:39 +08:00
|
|
|
*
|
2018-12-06 20:40:06 +08:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-18 02:24:46 +08:00
|
|
|
* 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
|
1998-12-21 18:56:39 +08:00
|
|
|
*/
|
|
|
|
|
2020-02-12 13:03:51 +08:00
|
|
|
/*
|
|
|
|
* RSA low level APIs are deprecated for public use, but still ok for
|
|
|
|
* internal use.
|
|
|
|
*/
|
|
|
|
#include "internal/deprecated.h"
|
|
|
|
|
1998-12-21 18:56:39 +08:00
|
|
|
#include <stdio.h>
|
2015-05-14 22:56:48 +08:00
|
|
|
#include "internal/cryptlib.h"
|
2016-03-19 02:30:20 +08:00
|
|
|
#include <openssl/rsa.h>
|
1999-04-24 06:13:45 +08:00
|
|
|
#include <openssl/evp.h>
|
|
|
|
#include <openssl/objects.h>
|
|
|
|
#include <openssl/x509.h>
|
1998-12-21 18:56:39 +08:00
|
|
|
|
2006-04-08 00:42:09 +08:00
|
|
|
int EVP_PKEY_decrypt_old(unsigned char *key, const unsigned char *ek, int ekl,
|
2015-01-22 11:40:55 +08:00
|
|
|
EVP_PKEY *priv)
|
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
|
2001-02-20 00:06:34 +08:00
|
|
|
#ifndef OPENSSL_NO_RSA
|
2016-01-19 08:21:12 +08:00
|
|
|
if (EVP_PKEY_id(priv) != EVP_PKEY_RSA) {
|
1998-12-22 23:59:57 +08:00
|
|
|
#endif
|
2015-01-22 11:40:55 +08:00
|
|
|
EVPerr(EVP_F_EVP_PKEY_DECRYPT_OLD, EVP_R_PUBLIC_KEY_NOT_RSA);
|
2001-02-20 00:06:34 +08:00
|
|
|
#ifndef OPENSSL_NO_RSA
|
2015-01-22 11:40:55 +08:00
|
|
|
goto err;
|
|
|
|
}
|
1998-12-21 18:56:39 +08:00
|
|
|
|
2015-01-22 11:40:55 +08:00
|
|
|
ret =
|
2016-01-19 08:21:12 +08:00
|
|
|
RSA_private_decrypt(ekl, ek, key, EVP_PKEY_get0_RSA(priv),
|
|
|
|
RSA_PKCS1_PADDING);
|
2015-01-22 11:40:55 +08:00
|
|
|
err:
|
1998-12-22 23:59:57 +08:00
|
|
|
#endif
|
2017-10-17 22:04:09 +08:00
|
|
|
return ret;
|
2015-01-22 11:40:55 +08:00
|
|
|
}
|