Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbedtls by
pkcs12.h
00001 /** 00002 * \file pkcs12.h 00003 * 00004 * \brief PKCS#12 Personal Information Exchange Syntax 00005 * 00006 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 00007 * SPDX-License-Identifier: Apache-2.0 00008 * 00009 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00010 * not use this file except in compliance with the License. 00011 * You may obtain a copy of the License at 00012 * 00013 * http://www.apache.org/licenses/LICENSE-2.0 00014 * 00015 * Unless required by applicable law or agreed to in writing, software 00016 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00017 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00018 * See the License for the specific language governing permissions and 00019 * limitations under the License. 00020 * 00021 * This file is part of mbed TLS (https://tls.mbed.org) 00022 */ 00023 #ifndef MBEDTLS_PKCS12_H 00024 #define MBEDTLS_PKCS12_H 00025 00026 #include "md.h" 00027 #include "cipher.h" 00028 #include "asn1.h" 00029 00030 #include <stddef.h> 00031 00032 #define MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA -0x1F80 /**< Bad input parameters to function. */ 00033 #define MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE -0x1F00 /**< Feature not available, e.g. unsupported encryption scheme. */ 00034 #define MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT -0x1E80 /**< PBE ASN.1 data not as expected. */ 00035 #define MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH -0x1E00 /**< Given private key password does not allow for correct decryption. */ 00036 00037 #define MBEDTLS_PKCS12_DERIVE_KEY 1 /**< encryption/decryption key */ 00038 #define MBEDTLS_PKCS12_DERIVE_IV 2 /**< initialization vector */ 00039 #define MBEDTLS_PKCS12_DERIVE_MAC_KEY 3 /**< integrity / MAC key */ 00040 00041 #define MBEDTLS_PKCS12_PBE_DECRYPT 0 00042 #define MBEDTLS_PKCS12_PBE_ENCRYPT 1 00043 00044 #ifdef __cplusplus 00045 extern "C" { 00046 #endif 00047 00048 /** 00049 * \brief PKCS12 Password Based function (encryption / decryption) 00050 * for pbeWithSHAAnd128BitRC4 00051 * 00052 * \param pbe_params an ASN1 buffer containing the pkcs-12PbeParams structure 00053 * \param mode either MBEDTLS_PKCS12_PBE_ENCRYPT or MBEDTLS_PKCS12_PBE_DECRYPT 00054 * \param pwd the password used (may be NULL if no password is used) 00055 * \param pwdlen length of the password (may be 0) 00056 * \param input the input data 00057 * \param len data length 00058 * \param output the output buffer 00059 * 00060 * \return 0 if successful, or a MBEDTLS_ERR_XXX code 00061 */ 00062 int mbedtls_pkcs12_pbe_sha1_rc4_128( mbedtls_asn1_buf *pbe_params, int mode, 00063 const unsigned char *pwd, size_t pwdlen, 00064 const unsigned char *input, size_t len, 00065 unsigned char *output ); 00066 00067 /** 00068 * \brief PKCS12 Password Based function (encryption / decryption) 00069 * for cipher-based and mbedtls_md-based PBE's 00070 * 00071 * \param pbe_params an ASN1 buffer containing the pkcs-12PbeParams structure 00072 * \param mode either MBEDTLS_PKCS12_PBE_ENCRYPT or MBEDTLS_PKCS12_PBE_DECRYPT 00073 * \param cipher_type the cipher used 00074 * \param md_type the mbedtls_md used 00075 * \param pwd the password used (may be NULL if no password is used) 00076 * \param pwdlen length of the password (may be 0) 00077 * \param input the input data 00078 * \param len data length 00079 * \param output the output buffer 00080 * 00081 * \return 0 if successful, or a MBEDTLS_ERR_XXX code 00082 */ 00083 int mbedtls_pkcs12_pbe( mbedtls_asn1_buf *pbe_params, int mode, 00084 mbedtls_cipher_type_t cipher_type, mbedtls_md_type_t md_type, 00085 const unsigned char *pwd, size_t pwdlen, 00086 const unsigned char *input, size_t len, 00087 unsigned char *output ); 00088 00089 /** 00090 * \brief The PKCS#12 derivation function uses a password and a salt 00091 * to produce pseudo-random bits for a particular "purpose". 00092 * 00093 * Depending on the given id, this function can produce an 00094 * encryption/decryption key, an nitialization vector or an 00095 * integrity key. 00096 * 00097 * \param data buffer to store the derived data in 00098 * \param datalen length to fill 00099 * \param pwd password to use (may be NULL if no password is used) 00100 * \param pwdlen length of the password (may be 0) 00101 * \param salt salt buffer to use 00102 * \param saltlen length of the salt 00103 * \param mbedtls_md mbedtls_md type to use during the derivation 00104 * \param id id that describes the purpose (can be MBEDTLS_PKCS12_DERIVE_KEY, 00105 * MBEDTLS_PKCS12_DERIVE_IV or MBEDTLS_PKCS12_DERIVE_MAC_KEY) 00106 * \param iterations number of iterations 00107 * 00108 * \return 0 if successful, or a MD, BIGNUM type error. 00109 */ 00110 int mbedtls_pkcs12_derivation( unsigned char *data, size_t datalen, 00111 const unsigned char *pwd, size_t pwdlen, 00112 const unsigned char *salt, size_t saltlen, 00113 mbedtls_md_type_t mbedtls_md, int id, int iterations ); 00114 00115 #ifdef __cplusplus 00116 } 00117 #endif 00118 00119 #endif /* pkcs12.h */
Generated on Tue Jul 12 2022 17:25:42 by
