ObjFW
OFPBKDF2.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #ifndef __STDC_LIMIT_MACROS
17 # define __STDC_LIMIT_MACROS
18 #endif
19 #ifndef __STDC_CONSTANT_MACROS
20 # define __STDC_CONSTANT_MACROS
21 #endif
22 
23 #import "macros.h"
24 
25 OF_ASSUME_NONNULL_BEGIN
26 
29 @class OFHMAC;
30 
34 typedef struct {
36  __unsafe_unretained OFHMAC *HMAC;
38  size_t iterations;
40  const unsigned char *salt;
42  size_t saltLength;
44  const char *password;
48  unsigned char *key;
54  size_t keyLength;
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
71 extern void OFPBKDF2(OFPBKDF2Parameters parameters);
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 OF_ASSUME_NONNULL_END
void OFPBKDF2(OFPBKDF2Parameters parameters)
Derives a key from a password and a salt using PBKDF2.
Definition: OFPBKDF2.m:29
A class which provides methods to calculate an HMAC.
Definition: OFHMAC.h:28
The parameters for OFPBKDF2.
Definition: OFPBKDF2.h:34
size_t passwordLength
The length of the password.
Definition: OFPBKDF2.h:46
size_t saltLength
The length of the salt.
Definition: OFPBKDF2.h:42
unsigned char * key
The buffer to write the key to.
Definition: OFPBKDF2.h:48
bool allowsSwappableMemory
Whether data may be stored in swappable memory.
Definition: OFPBKDF2.h:56
size_t keyLength
The desired length for the derived key.
Definition: OFPBKDF2.h:54
size_t iterations
The number of iterations to perform.
Definition: OFPBKDF2.h:38
const char * password
The password to derive a key from.
Definition: OFPBKDF2.h:44
const unsigned char * salt
The salt to derive a key with.
Definition: OFPBKDF2.h:40