blob: 6bec4062c8fffe2dffc34a0efc365f9fed9dc853 [file] [log] [blame]
Rich Salz62867572016-05-17 14:24:46 -04001/*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
Ralf S. Engelschall58964a41998-12-21 10:56:39 +00003 *
Rich Salz62867572016-05-17 14:24:46 -04004 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
Ralf S. Engelschall58964a41998-12-21 10:56:39 +00008 */
9
10#include <stdio.h>
Richard Levitteb39fc562015-05-14 16:56:48 +020011#include "internal/cryptlib.h"
Rich Salz3c272082016-03-18 14:30:20 -040012#include <openssl/rsa.h>
Bodo Möllerec577821999-04-23 22:13:45 +000013#include <openssl/evp.h>
14#include <openssl/objects.h>
15#include <openssl/x509.h>
Ralf S. Engelschall58964a41998-12-21 10:56:39 +000016
Dr. Stephen Hensonf733a5e2006-04-07 16:42:09 +000017int EVP_PKEY_decrypt_old(unsigned char *key, const unsigned char *ek, int ekl,
Matt Caswell0f113f32015-01-22 03:40:55 +000018 EVP_PKEY *priv)
19{
20 int ret = -1;
Ralf S. Engelschall58964a41998-12-21 10:56:39 +000021
Matt Caswell0f113f32015-01-22 03:40:55 +000022#ifndef OPENSSL_NO_RSA
Dr. Stephen Henson3aeb9342016-01-19 00:21:12 +000023 if (EVP_PKEY_id(priv) != EVP_PKEY_RSA) {
Ralf S. Engelschall13e91dd1998-12-22 15:59:57 +000024#endif
Matt Caswell0f113f32015-01-22 03:40:55 +000025 EVPerr(EVP_F_EVP_PKEY_DECRYPT_OLD, EVP_R_PUBLIC_KEY_NOT_RSA);
26#ifndef OPENSSL_NO_RSA
27 goto err;
28 }
29
30 ret =
Dr. Stephen Henson3aeb9342016-01-19 00:21:12 +000031 RSA_private_decrypt(ekl, ek, key, EVP_PKEY_get0_RSA(priv),
32 RSA_PKCS1_PADDING);
Matt Caswell0f113f32015-01-22 03:40:55 +000033 err:
34#endif
35 return (ret);
36}