ObjFW
Toggle main menu visibility
Loading...
Searching...
No Matches
OFScrypt.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008-2026 Jonathan Schleifer <js@nil.im>
3
*
4
* All rights reserved.
5
*
6
* This program is free software: you can redistribute it and/or modify it
7
* under the terms of the GNU Lesser General Public License version 3.0 only,
8
* as published by the Free Software Foundation.
9
*
10
* This program is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13
* version 3.0 for more details.
14
*
15
* You should have received a copy of the GNU Lesser General Public License
16
* version 3.0 along with this program. If not, see
17
* <https://www.gnu.org/licenses/>.
18
*/
19
20
#ifndef __STDC_LIMIT_MACROS
21
# define __STDC_LIMIT_MACROS
22
#endif
23
#ifndef __STDC_CONSTANT_MACROS
24
# define __STDC_CONSTANT_MACROS
25
#endif
26
27
#import "
macros.h
"
28
29
OF_ASSUME_NONNULL_BEGIN
30
32
33
@class
OFHMAC
;
34
38
typedef
struct
{
40
size_t
blockSize
;
42
size_t
costFactor
;
44
size_t
parallelization
;
46
const
unsigned
char
*
salt
;
48
size_t
saltLength
;
50
const
char
*
password
;
52
size_t
passwordLength
;
54
unsigned
char
*
key
;
60
size_t
keyLength
;
62
bool
allowsSwappableMemory
;
63
}
OFScryptParameters
;
64
65
#ifdef __cplusplus
66
extern
"C"
{
67
#endif
68
/* No OF_VISIBILITY_INTERNAL so tests can call it. */
69
extern
void
_OFSalsa20_8Core(uint32_t buffer[_Nonnull 16]);
70
extern
void
_OFScryptBlockMix(uint32_t *output,
const
uint32_t *input,
71
size_t
blockSize);
72
extern
void
_OFScryptROMix(uint32_t *buffer,
size_t
blockSize,
73
size_t
costFactor, uint32_t *tmp);
74
80
extern
void
OFScrypt
(
OFScryptParameters
parameters);
81
#ifdef __cplusplus
82
}
83
#endif
84
85
OF_ASSUME_NONNULL_END
OFScrypt
void OFScrypt(OFScryptParameters parameters)
Derives a key from a password and a salt using scrypt.
Definition
OFScrypt.m:145
OFHMAC
A class which provides methods to calculate an HMAC.
Definition
OFHMAC.h:32
macros.h
OFScryptParameters
The parameters for OFScrypt.
Definition
OFScrypt.h:38
OFScryptParameters::parallelization
size_t parallelization
The parallelization to use.
Definition
OFScrypt.h:44
OFScryptParameters::keyLength
size_t keyLength
The desired length for the derived key.
Definition
OFScrypt.h:60
OFScryptParameters::saltLength
size_t saltLength
The length of the salt.
Definition
OFScrypt.h:48
OFScryptParameters::password
const char * password
The password to derive a key from.
Definition
OFScrypt.h:50
OFScryptParameters::allowsSwappableMemory
bool allowsSwappableMemory
Whether data may be stored in swappable memory.
Definition
OFScrypt.h:62
OFScryptParameters::key
unsigned char * key
The buffer to write the key to.
Definition
OFScrypt.h:54
OFScryptParameters::blockSize
size_t blockSize
The block size to use.
Definition
OFScrypt.h:40
OFScryptParameters::costFactor
size_t costFactor
The CPU/memory cost factor to use.
Definition
OFScrypt.h:42
OFScryptParameters::salt
const unsigned char * salt
The salt to derive a key with.
Definition
OFScrypt.h:46
OFScryptParameters::passwordLength
size_t passwordLength
The length of the password.
Definition
OFScrypt.h:52
src
OFScrypt.h
Generated by
1.17.0