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
|
|
|
*
|
2016-05-17 18:24:46 +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
|
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
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
int EVP_PKEY_encrypt_old(unsigned char *ek, const unsigned char *key,
|
|
|
|
int key_len, EVP_PKEY *pubk)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
2001-02-19 16:06:34 +00:00
|
|
|
#ifndef OPENSSL_NO_RSA
|
2016-01-19 00:21:12 +00:00
|
|
|
if (EVP_PKEY_id(pubk) != 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_ENCRYPT_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;
|
|
|
|
}
|
|
|
|
ret =
|
2016-01-19 00:21:12 +00:00
|
|
|
RSA_public_encrypt(key_len, key, ek, EVP_PKEY_get0_RSA(pubk),
|
2015-01-22 03:40:55 +00:00
|
|
|
RSA_PKCS1_PADDING);
|
|
|
|
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
|
|
|
}
|