Maxim nexpaq / nexpaq_dev
Committer:
nexpaq
Date:
Fri Nov 04 20:54:50 2016 +0000
Revision:
1:d96dbedaebdb
Parent:
0:6c56fb4bc5f0
Removed extra directories for other platforms

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 0:6c56fb4bc5f0 1 /**
nexpaq 0:6c56fb4bc5f0 2 * \file pkcs12.h
nexpaq 0:6c56fb4bc5f0 3 *
nexpaq 0:6c56fb4bc5f0 4 * \brief PKCS#12 Personal Information Exchange Syntax
nexpaq 0:6c56fb4bc5f0 5 *
nexpaq 0:6c56fb4bc5f0 6 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
nexpaq 0:6c56fb4bc5f0 7 * SPDX-License-Identifier: Apache-2.0
nexpaq 0:6c56fb4bc5f0 8 *
nexpaq 0:6c56fb4bc5f0 9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
nexpaq 0:6c56fb4bc5f0 10 * not use this file except in compliance with the License.
nexpaq 0:6c56fb4bc5f0 11 * You may obtain a copy of the License at
nexpaq 0:6c56fb4bc5f0 12 *
nexpaq 0:6c56fb4bc5f0 13 * http://www.apache.org/licenses/LICENSE-2.0
nexpaq 0:6c56fb4bc5f0 14 *
nexpaq 0:6c56fb4bc5f0 15 * Unless required by applicable law or agreed to in writing, software
nexpaq 0:6c56fb4bc5f0 16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
nexpaq 0:6c56fb4bc5f0 17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
nexpaq 0:6c56fb4bc5f0 18 * See the License for the specific language governing permissions and
nexpaq 0:6c56fb4bc5f0 19 * limitations under the License.
nexpaq 0:6c56fb4bc5f0 20 *
nexpaq 0:6c56fb4bc5f0 21 * This file is part of mbed TLS (https://tls.mbed.org)
nexpaq 0:6c56fb4bc5f0 22 */
nexpaq 0:6c56fb4bc5f0 23 #ifndef MBEDTLS_PKCS12_H
nexpaq 0:6c56fb4bc5f0 24 #define MBEDTLS_PKCS12_H
nexpaq 0:6c56fb4bc5f0 25
nexpaq 0:6c56fb4bc5f0 26 #include "md.h"
nexpaq 0:6c56fb4bc5f0 27 #include "cipher.h"
nexpaq 0:6c56fb4bc5f0 28 #include "asn1.h"
nexpaq 0:6c56fb4bc5f0 29
nexpaq 0:6c56fb4bc5f0 30 #include <stddef.h>
nexpaq 0:6c56fb4bc5f0 31
nexpaq 0:6c56fb4bc5f0 32 #define MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA -0x1F80 /**< Bad input parameters to function. */
nexpaq 0:6c56fb4bc5f0 33 #define MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE -0x1F00 /**< Feature not available, e.g. unsupported encryption scheme. */
nexpaq 0:6c56fb4bc5f0 34 #define MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT -0x1E80 /**< PBE ASN.1 data not as expected. */
nexpaq 0:6c56fb4bc5f0 35 #define MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH -0x1E00 /**< Given private key password does not allow for correct decryption. */
nexpaq 0:6c56fb4bc5f0 36
nexpaq 0:6c56fb4bc5f0 37 #define MBEDTLS_PKCS12_DERIVE_KEY 1 /**< encryption/decryption key */
nexpaq 0:6c56fb4bc5f0 38 #define MBEDTLS_PKCS12_DERIVE_IV 2 /**< initialization vector */
nexpaq 0:6c56fb4bc5f0 39 #define MBEDTLS_PKCS12_DERIVE_MAC_KEY 3 /**< integrity / MAC key */
nexpaq 0:6c56fb4bc5f0 40
nexpaq 0:6c56fb4bc5f0 41 #define MBEDTLS_PKCS12_PBE_DECRYPT 0
nexpaq 0:6c56fb4bc5f0 42 #define MBEDTLS_PKCS12_PBE_ENCRYPT 1
nexpaq 0:6c56fb4bc5f0 43
nexpaq 0:6c56fb4bc5f0 44 #ifdef __cplusplus
nexpaq 0:6c56fb4bc5f0 45 extern "C" {
nexpaq 0:6c56fb4bc5f0 46 #endif
nexpaq 0:6c56fb4bc5f0 47
nexpaq 0:6c56fb4bc5f0 48 /**
nexpaq 0:6c56fb4bc5f0 49 * \brief PKCS12 Password Based function (encryption / decryption)
nexpaq 0:6c56fb4bc5f0 50 * for pbeWithSHAAnd128BitRC4
nexpaq 0:6c56fb4bc5f0 51 *
nexpaq 0:6c56fb4bc5f0 52 * \param pbe_params an ASN1 buffer containing the pkcs-12PbeParams structure
nexpaq 0:6c56fb4bc5f0 53 * \param mode either MBEDTLS_PKCS12_PBE_ENCRYPT or MBEDTLS_PKCS12_PBE_DECRYPT
nexpaq 0:6c56fb4bc5f0 54 * \param pwd the password used (may be NULL if no password is used)
nexpaq 0:6c56fb4bc5f0 55 * \param pwdlen length of the password (may be 0)
nexpaq 0:6c56fb4bc5f0 56 * \param input the input data
nexpaq 0:6c56fb4bc5f0 57 * \param len data length
nexpaq 0:6c56fb4bc5f0 58 * \param output the output buffer
nexpaq 0:6c56fb4bc5f0 59 *
nexpaq 0:6c56fb4bc5f0 60 * \return 0 if successful, or a MBEDTLS_ERR_XXX code
nexpaq 0:6c56fb4bc5f0 61 */
nexpaq 0:6c56fb4bc5f0 62 int mbedtls_pkcs12_pbe_sha1_rc4_128( mbedtls_asn1_buf *pbe_params, int mode,
nexpaq 0:6c56fb4bc5f0 63 const unsigned char *pwd, size_t pwdlen,
nexpaq 0:6c56fb4bc5f0 64 const unsigned char *input, size_t len,
nexpaq 0:6c56fb4bc5f0 65 unsigned char *output );
nexpaq 0:6c56fb4bc5f0 66
nexpaq 0:6c56fb4bc5f0 67 /**
nexpaq 0:6c56fb4bc5f0 68 * \brief PKCS12 Password Based function (encryption / decryption)
nexpaq 0:6c56fb4bc5f0 69 * for cipher-based and mbedtls_md-based PBE's
nexpaq 0:6c56fb4bc5f0 70 *
nexpaq 0:6c56fb4bc5f0 71 * \param pbe_params an ASN1 buffer containing the pkcs-12PbeParams structure
nexpaq 0:6c56fb4bc5f0 72 * \param mode either MBEDTLS_PKCS12_PBE_ENCRYPT or MBEDTLS_PKCS12_PBE_DECRYPT
nexpaq 0:6c56fb4bc5f0 73 * \param cipher_type the cipher used
nexpaq 0:6c56fb4bc5f0 74 * \param md_type the mbedtls_md used
nexpaq 0:6c56fb4bc5f0 75 * \param pwd the password used (may be NULL if no password is used)
nexpaq 0:6c56fb4bc5f0 76 * \param pwdlen length of the password (may be 0)
nexpaq 0:6c56fb4bc5f0 77 * \param input the input data
nexpaq 0:6c56fb4bc5f0 78 * \param len data length
nexpaq 0:6c56fb4bc5f0 79 * \param output the output buffer
nexpaq 0:6c56fb4bc5f0 80 *
nexpaq 0:6c56fb4bc5f0 81 * \return 0 if successful, or a MBEDTLS_ERR_XXX code
nexpaq 0:6c56fb4bc5f0 82 */
nexpaq 0:6c56fb4bc5f0 83 int mbedtls_pkcs12_pbe( mbedtls_asn1_buf *pbe_params, int mode,
nexpaq 0:6c56fb4bc5f0 84 mbedtls_cipher_type_t cipher_type, mbedtls_md_type_t md_type,
nexpaq 0:6c56fb4bc5f0 85 const unsigned char *pwd, size_t pwdlen,
nexpaq 0:6c56fb4bc5f0 86 const unsigned char *input, size_t len,
nexpaq 0:6c56fb4bc5f0 87 unsigned char *output );
nexpaq 0:6c56fb4bc5f0 88
nexpaq 0:6c56fb4bc5f0 89 /**
nexpaq 0:6c56fb4bc5f0 90 * \brief The PKCS#12 derivation function uses a password and a salt
nexpaq 0:6c56fb4bc5f0 91 * to produce pseudo-random bits for a particular "purpose".
nexpaq 0:6c56fb4bc5f0 92 *
nexpaq 0:6c56fb4bc5f0 93 * Depending on the given id, this function can produce an
nexpaq 0:6c56fb4bc5f0 94 * encryption/decryption key, an nitialization vector or an
nexpaq 0:6c56fb4bc5f0 95 * integrity key.
nexpaq 0:6c56fb4bc5f0 96 *
nexpaq 0:6c56fb4bc5f0 97 * \param data buffer to store the derived data in
nexpaq 0:6c56fb4bc5f0 98 * \param datalen length to fill
nexpaq 0:6c56fb4bc5f0 99 * \param pwd password to use (may be NULL if no password is used)
nexpaq 0:6c56fb4bc5f0 100 * \param pwdlen length of the password (may be 0)
nexpaq 0:6c56fb4bc5f0 101 * \param salt salt buffer to use
nexpaq 0:6c56fb4bc5f0 102 * \param saltlen length of the salt
nexpaq 0:6c56fb4bc5f0 103 * \param mbedtls_md mbedtls_md type to use during the derivation
nexpaq 0:6c56fb4bc5f0 104 * \param id id that describes the purpose (can be MBEDTLS_PKCS12_DERIVE_KEY,
nexpaq 0:6c56fb4bc5f0 105 * MBEDTLS_PKCS12_DERIVE_IV or MBEDTLS_PKCS12_DERIVE_MAC_KEY)
nexpaq 0:6c56fb4bc5f0 106 * \param iterations number of iterations
nexpaq 0:6c56fb4bc5f0 107 *
nexpaq 0:6c56fb4bc5f0 108 * \return 0 if successful, or a MD, BIGNUM type error.
nexpaq 0:6c56fb4bc5f0 109 */
nexpaq 0:6c56fb4bc5f0 110 int mbedtls_pkcs12_derivation( unsigned char *data, size_t datalen,
nexpaq 0:6c56fb4bc5f0 111 const unsigned char *pwd, size_t pwdlen,
nexpaq 0:6c56fb4bc5f0 112 const unsigned char *salt, size_t saltlen,
nexpaq 0:6c56fb4bc5f0 113 mbedtls_md_type_t mbedtls_md, int id, int iterations );
nexpaq 0:6c56fb4bc5f0 114
nexpaq 0:6c56fb4bc5f0 115 #ifdef __cplusplus
nexpaq 0:6c56fb4bc5f0 116 }
nexpaq 0:6c56fb4bc5f0 117 #endif
nexpaq 0:6c56fb4bc5f0 118
nexpaq 0:6c56fb4bc5f0 119 #endif /* pkcs12.h */