Rich Salz | 6286757 | 2016-05-17 14:24:46 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 3 | * |
Rich Salz | 6286757 | 2016-05-17 14:24:46 -0400 | [diff] [blame] | 4 | * 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. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <stdio.h> |
Richard Levitte | b39fc56 | 2015-05-14 16:56:48 +0200 | [diff] [blame] | 11 | #include "internal/cryptlib.h" |
Rich Salz | 3c27208 | 2016-03-18 14:30:20 -0400 | [diff] [blame] | 12 | #include <openssl/rsa.h> |
Bodo Möller | ec57782 | 1999-04-23 22:13:45 +0000 | [diff] [blame] | 13 | #include <openssl/evp.h> |
| 14 | #include <openssl/objects.h> |
| 15 | #include <openssl/x509.h> |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 16 | |
Dr. Stephen Henson | f733a5e | 2006-04-07 16:42:09 +0000 | [diff] [blame] | 17 | int EVP_PKEY_decrypt_old(unsigned char *key, const unsigned char *ek, int ekl, |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 18 | EVP_PKEY *priv) |
| 19 | { |
| 20 | int ret = -1; |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 21 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 22 | #ifndef OPENSSL_NO_RSA |
Dr. Stephen Henson | 3aeb934 | 2016-01-19 00:21:12 +0000 | [diff] [blame] | 23 | if (EVP_PKEY_id(priv) != EVP_PKEY_RSA) { |
Ralf S. Engelschall | 13e91dd | 1998-12-22 15:59:57 +0000 | [diff] [blame] | 24 | #endif |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 25 | 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 Henson | 3aeb934 | 2016-01-19 00:21:12 +0000 | [diff] [blame] | 31 | RSA_private_decrypt(ekl, ek, key, EVP_PKEY_get0_RSA(priv), |
| 32 | RSA_PKCS1_PADDING); |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 33 | err: |
| 34 | #endif |
| 35 | return (ret); |
| 36 | } |