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