Added "GetSvrTypeFromUri()" and supporting code.
[platform/upstream/iotivity.git] / resource / csdk / security / include / pbkdf2.h
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #ifndef _PBKDF2_H
22 #define _PBKDF2_H
23
24 #include <stdio.h>
25 #include <stdint.h>
26
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31
32 /**
33  * The number of iterations desired to derived key.
34  * (Recommened by RFC 2898)
35  */
36 #define PBKDF_ITERATIONS 1000
37
38 /**
39  * Function to derive cryptographic key from the password. (RFC 2898)
40  * In this implementation, HMAC with SHA2 is considered as a pseudorandom function
41  *
42  * @param passwd is the master password from which a derived key is generated.
43  * @param pLen is the byte size of the passwd.
44  * @param salt is a cryptographic salt.
45  * @param saltlen is the byte size of the salt.
46  * @param iteration is the number of iterations desired.
47  * @param keyLen is the desired byte size of the derived key. (should be the same as
48  *       derivedKey size)
49  * @param derivedKey is the generated derived key
50  *
51  * @return  0 on success
52  */
53 int DeriveCryptoKeyFromPassword(const unsigned char* passwd, size_t pLen,
54                                 const uint8_t* salt, const size_t saltLen,
55                                 const size_t iterations,
56                                 const size_t keyLen, uint8_t* derivedKey);
57
58 #ifdef __cplusplus
59 }
60 #endif
61 #endif // _PBKDF2_H
62