xref: /aosp_15_r20/external/scrypt/lib/crypto/crypto_scrypt.h (revision cd192fa97f712aaa0b7692ec7c6cc9c7ad6c8620)
1*cd192fa9SAndroid Build Coastguard Worker /*-
2*cd192fa9SAndroid Build Coastguard Worker  * Copyright 2009 Colin Percival
3*cd192fa9SAndroid Build Coastguard Worker  * All rights reserved.
4*cd192fa9SAndroid Build Coastguard Worker  *
5*cd192fa9SAndroid Build Coastguard Worker  * Redistribution and use in source and binary forms, with or without
6*cd192fa9SAndroid Build Coastguard Worker  * modification, are permitted provided that the following conditions
7*cd192fa9SAndroid Build Coastguard Worker  * are met:
8*cd192fa9SAndroid Build Coastguard Worker  * 1. Redistributions of source code must retain the above copyright
9*cd192fa9SAndroid Build Coastguard Worker  *    notice, this list of conditions and the following disclaimer.
10*cd192fa9SAndroid Build Coastguard Worker  * 2. Redistributions in binary form must reproduce the above copyright
11*cd192fa9SAndroid Build Coastguard Worker  *    notice, this list of conditions and the following disclaimer in the
12*cd192fa9SAndroid Build Coastguard Worker  *    documentation and/or other materials provided with the distribution.
13*cd192fa9SAndroid Build Coastguard Worker  *
14*cd192fa9SAndroid Build Coastguard Worker  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*cd192fa9SAndroid Build Coastguard Worker  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*cd192fa9SAndroid Build Coastguard Worker  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*cd192fa9SAndroid Build Coastguard Worker  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*cd192fa9SAndroid Build Coastguard Worker  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*cd192fa9SAndroid Build Coastguard Worker  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*cd192fa9SAndroid Build Coastguard Worker  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*cd192fa9SAndroid Build Coastguard Worker  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*cd192fa9SAndroid Build Coastguard Worker  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*cd192fa9SAndroid Build Coastguard Worker  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*cd192fa9SAndroid Build Coastguard Worker  * SUCH DAMAGE.
25*cd192fa9SAndroid Build Coastguard Worker  *
26*cd192fa9SAndroid Build Coastguard Worker  * This file was originally written by Colin Percival as part of the Tarsnap
27*cd192fa9SAndroid Build Coastguard Worker  * online backup system.
28*cd192fa9SAndroid Build Coastguard Worker  */
29*cd192fa9SAndroid Build Coastguard Worker #ifndef _CRYPTO_SCRYPT_H_
30*cd192fa9SAndroid Build Coastguard Worker #define _CRYPTO_SCRYPT_H_
31*cd192fa9SAndroid Build Coastguard Worker 
32*cd192fa9SAndroid Build Coastguard Worker #include <stdint.h>
33*cd192fa9SAndroid Build Coastguard Worker 
34*cd192fa9SAndroid Build Coastguard Worker /**
35*cd192fa9SAndroid Build Coastguard Worker  * crypto_scrypt(passwd, passwdlen, salt, saltlen, N, r, p, buf, buflen):
36*cd192fa9SAndroid Build Coastguard Worker  * Compute scrypt(passwd[0 .. passwdlen - 1], salt[0 .. saltlen - 1], N, r,
37*cd192fa9SAndroid Build Coastguard Worker  * p, buflen) and write the result into buf.  The parameters r, p, and buflen
38*cd192fa9SAndroid Build Coastguard Worker  * must satisfy r * p < 2^30 and buflen <= (2^32 - 1) * 32.  The parameter N
39*cd192fa9SAndroid Build Coastguard Worker  * must be a power of 2 greater than 1.
40*cd192fa9SAndroid Build Coastguard Worker  *
41*cd192fa9SAndroid Build Coastguard Worker  * Return 0 on success; or -1 on error.
42*cd192fa9SAndroid Build Coastguard Worker  */
43*cd192fa9SAndroid Build Coastguard Worker int crypto_scrypt(const uint8_t *, size_t, const uint8_t *, size_t, uint64_t,
44*cd192fa9SAndroid Build Coastguard Worker     uint32_t, uint32_t, uint8_t *, size_t);
45*cd192fa9SAndroid Build Coastguard Worker 
46*cd192fa9SAndroid Build Coastguard Worker #endif /* !_CRYPTO_SCRYPT_H_ */
47