2015-01-22 11:40:55 +08:00
|
|
|
/*
|
2016-05-18 02:52:22 +08:00
|
|
|
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
2001-07-27 06:34:45 +08:00
|
|
|
*
|
2016-05-18 02:52:22 +08: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
|
2001-07-27 06:34:45 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2015-05-14 22:56:48 +08:00
|
|
|
#include "internal/cryptlib.h"
|
2001-07-27 06:34:45 +08:00
|
|
|
#include <openssl/pkcs12.h>
|
|
|
|
|
2016-08-18 00:27:05 +08:00
|
|
|
PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(const X509_SIG *p8, const char *pass,
|
2015-01-22 11:40:55 +08:00
|
|
|
int passlen)
|
2001-07-27 06:34:45 +08:00
|
|
|
{
|
2016-08-18 00:27:05 +08:00
|
|
|
const X509_ALGOR *dalg;
|
|
|
|
const ASN1_OCTET_STRING *doct;
|
|
|
|
X509_SIG_get0(p8, &dalg, &doct);
|
2016-03-10 23:04:46 +08:00
|
|
|
return PKCS12_item_decrypt_d2i(dalg,
|
2015-01-22 11:40:55 +08:00
|
|
|
ASN1_ITEM_rptr(PKCS8_PRIV_KEY_INFO), pass,
|
2016-03-10 23:04:46 +08:00
|
|
|
passlen, doct, 1);
|
2001-07-27 06:34:45 +08:00
|
|
|
}
|