mbed TLS Build

Dependents:   Slave-prot-prod

Committer:
williequesada
Date:
Tue Jun 04 16:03:38 2019 +0000
Revision:
1:1a219dea6cb5
Parent:
0:cdf462088d13
compartir a Pablo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
markrad 0:cdf462088d13 1 /**
markrad 0:cdf462088d13 2 * \file pkcs5.h
markrad 0:cdf462088d13 3 *
markrad 0:cdf462088d13 4 * \brief PKCS#5 functions
markrad 0:cdf462088d13 5 *
markrad 0:cdf462088d13 6 * \author Mathias Olsson <mathias@kompetensum.com>
markrad 0:cdf462088d13 7 *
markrad 0:cdf462088d13 8 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
markrad 0:cdf462088d13 9 * SPDX-License-Identifier: Apache-2.0
markrad 0:cdf462088d13 10 *
markrad 0:cdf462088d13 11 * Licensed under the Apache License, Version 2.0 (the "License"); you may
markrad 0:cdf462088d13 12 * not use this file except in compliance with the License.
markrad 0:cdf462088d13 13 * You may obtain a copy of the License at
markrad 0:cdf462088d13 14 *
markrad 0:cdf462088d13 15 * http://www.apache.org/licenses/LICENSE-2.0
markrad 0:cdf462088d13 16 *
markrad 0:cdf462088d13 17 * Unless required by applicable law or agreed to in writing, software
markrad 0:cdf462088d13 18 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
markrad 0:cdf462088d13 19 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
markrad 0:cdf462088d13 20 * See the License for the specific language governing permissions and
markrad 0:cdf462088d13 21 * limitations under the License.
markrad 0:cdf462088d13 22 *
markrad 0:cdf462088d13 23 * This file is part of mbed TLS (https://tls.mbed.org)
markrad 0:cdf462088d13 24 */
markrad 0:cdf462088d13 25 #ifndef MBEDTLS_PKCS5_H
markrad 0:cdf462088d13 26 #define MBEDTLS_PKCS5_H
markrad 0:cdf462088d13 27
markrad 0:cdf462088d13 28 #include "asn1.h"
markrad 0:cdf462088d13 29 #include "md.h"
markrad 0:cdf462088d13 30
markrad 0:cdf462088d13 31 #include <stddef.h>
markrad 0:cdf462088d13 32 #include <stdint.h>
markrad 0:cdf462088d13 33
markrad 0:cdf462088d13 34 #define MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA -0x2f80 /**< Bad input parameters to function. */
markrad 0:cdf462088d13 35 #define MBEDTLS_ERR_PKCS5_INVALID_FORMAT -0x2f00 /**< Unexpected ASN.1 data. */
markrad 0:cdf462088d13 36 #define MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE -0x2e80 /**< Requested encryption or digest alg not available. */
markrad 0:cdf462088d13 37 #define MBEDTLS_ERR_PKCS5_PASSWORD_MISMATCH -0x2e00 /**< Given private key password does not allow for correct decryption. */
markrad 0:cdf462088d13 38
markrad 0:cdf462088d13 39 #define MBEDTLS_PKCS5_DECRYPT 0
markrad 0:cdf462088d13 40 #define MBEDTLS_PKCS5_ENCRYPT 1
markrad 0:cdf462088d13 41
markrad 0:cdf462088d13 42 #ifdef __cplusplus
markrad 0:cdf462088d13 43 extern "C" {
markrad 0:cdf462088d13 44 #endif
markrad 0:cdf462088d13 45
markrad 0:cdf462088d13 46 /**
markrad 0:cdf462088d13 47 * \brief PKCS#5 PBES2 function
markrad 0:cdf462088d13 48 *
markrad 0:cdf462088d13 49 * \param pbe_params the ASN.1 algorithm parameters
markrad 0:cdf462088d13 50 * \param mode either MBEDTLS_PKCS5_DECRYPT or MBEDTLS_PKCS5_ENCRYPT
markrad 0:cdf462088d13 51 * \param pwd password to use when generating key
markrad 0:cdf462088d13 52 * \param pwdlen length of password
markrad 0:cdf462088d13 53 * \param data data to process
markrad 0:cdf462088d13 54 * \param datalen length of data
markrad 0:cdf462088d13 55 * \param output output buffer
markrad 0:cdf462088d13 56 *
markrad 0:cdf462088d13 57 * \returns 0 on success, or a MBEDTLS_ERR_XXX code if verification fails.
markrad 0:cdf462088d13 58 */
markrad 0:cdf462088d13 59 int mbedtls_pkcs5_pbes2( const mbedtls_asn1_buf *pbe_params, int mode,
markrad 0:cdf462088d13 60 const unsigned char *pwd, size_t pwdlen,
markrad 0:cdf462088d13 61 const unsigned char *data, size_t datalen,
markrad 0:cdf462088d13 62 unsigned char *output );
markrad 0:cdf462088d13 63
markrad 0:cdf462088d13 64 /**
markrad 0:cdf462088d13 65 * \brief PKCS#5 PBKDF2 using HMAC
markrad 0:cdf462088d13 66 *
markrad 0:cdf462088d13 67 * \param ctx Generic HMAC context
markrad 0:cdf462088d13 68 * \param password Password to use when generating key
markrad 0:cdf462088d13 69 * \param plen Length of password
markrad 0:cdf462088d13 70 * \param salt Salt to use when generating key
markrad 0:cdf462088d13 71 * \param slen Length of salt
markrad 0:cdf462088d13 72 * \param iteration_count Iteration count
markrad 0:cdf462088d13 73 * \param key_length Length of generated key in bytes
markrad 0:cdf462088d13 74 * \param output Generated key. Must be at least as big as key_length
markrad 0:cdf462088d13 75 *
markrad 0:cdf462088d13 76 * \returns 0 on success, or a MBEDTLS_ERR_XXX code if verification fails.
markrad 0:cdf462088d13 77 */
markrad 0:cdf462088d13 78 int mbedtls_pkcs5_pbkdf2_hmac( mbedtls_md_context_t *ctx, const unsigned char *password,
markrad 0:cdf462088d13 79 size_t plen, const unsigned char *salt, size_t slen,
markrad 0:cdf462088d13 80 unsigned int iteration_count,
markrad 0:cdf462088d13 81 uint32_t key_length, unsigned char *output );
markrad 0:cdf462088d13 82
markrad 0:cdf462088d13 83 /**
markrad 0:cdf462088d13 84 * \brief Checkup routine
markrad 0:cdf462088d13 85 *
markrad 0:cdf462088d13 86 * \return 0 if successful, or 1 if the test failed
markrad 0:cdf462088d13 87 */
markrad 0:cdf462088d13 88 int mbedtls_pkcs5_self_test( int verbose );
markrad 0:cdf462088d13 89
markrad 0:cdf462088d13 90 #ifdef __cplusplus
markrad 0:cdf462088d13 91 }
markrad 0:cdf462088d13 92 #endif
markrad 0:cdf462088d13 93
markrad 0:cdf462088d13 94 #endif /* pkcs5.h */