2016-05-18 02:24:46 +08:00
|
|
|
/*
|
2021-03-11 21:27:36 +08:00
|
|
|
* Copyright 1995-2021 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-10-04 22:34:31 +08:00
|
|
|
/* We need to use the deprecated RSA low level calls */
|
|
|
|
#define OPENSSL_SUPPRESS_DEPRECATED
|
2020-02-12 13:03:51 +08:00
|
|
|
|
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>
|
2021-03-02 23:52:00 +08:00
|
|
|
#include "crypto/evp.h"
|
1998-12-21 18:56:39 +08:00
|
|
|
|
2015-01-22 11:40:55 +08:00
|
|
|
int EVP_PKEY_encrypt_old(unsigned char *ek, const unsigned char *key,
|
|
|
|
int key_len, EVP_PKEY *pubk)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
2016-01-19 08:21:12 +08:00
|
|
|
if (EVP_PKEY_id(pubk) != EVP_PKEY_RSA) {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_EVP, EVP_R_PUBLIC_KEY_NOT_RSA);
|
2015-01-22 11:40:55 +08:00
|
|
|
goto err;
|
|
|
|
}
|
2021-03-02 23:52:00 +08:00
|
|
|
|
2015-01-22 11:40:55 +08:00
|
|
|
ret =
|
2021-03-02 23:52:00 +08:00
|
|
|
RSA_public_encrypt(key_len, key, ek, evp_pkey_get0_RSA_int(pubk),
|
2015-01-22 11:40:55 +08:00
|
|
|
RSA_PKCS1_PADDING);
|
|
|
|
err:
|
2017-10-17 22:04:09 +08:00
|
|
|
return ret;
|
2015-01-22 11:40:55 +08:00
|
|
|
}
|