1 /* Copyright 2014 Donald Stufft and individual contributors 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 static const int PYNACL_HAS_CRYPTO_PWHASH_SCRYPTSALSA208SHA256; 17 18 size_t crypto_pwhash_scryptsalsa208sha256_saltbytes(void); 19 size_t crypto_pwhash_scryptsalsa208sha256_strbytes(void); 20 size_t crypto_pwhash_scryptsalsa208sha256_bytes_min(void); 21 size_t crypto_pwhash_scryptsalsa208sha256_bytes_max(void); 22 size_t crypto_pwhash_scryptsalsa208sha256_passwd_min(void); 23 size_t crypto_pwhash_scryptsalsa208sha256_passwd_max(void); 24 size_t crypto_pwhash_scryptsalsa208sha256_opslimit_min(void); 25 size_t crypto_pwhash_scryptsalsa208sha256_opslimit_max(void); 26 size_t crypto_pwhash_scryptsalsa208sha256_memlimit_min(void); 27 size_t crypto_pwhash_scryptsalsa208sha256_memlimit_max(void); 28 size_t crypto_pwhash_scryptsalsa208sha256_opslimit_interactive(void); 29 size_t crypto_pwhash_scryptsalsa208sha256_memlimit_interactive(void); 30 size_t crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive(void); 31 size_t crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive(void); 32 33 const char *crypto_pwhash_scryptsalsa208sha256_strprefix(void); 34 35 int crypto_pwhash_scryptsalsa208sha256_ll(const uint8_t * const passwd, 36 size_t passwdlen, 37 const uint8_t * salt, 38 size_t saltlen, 39 uint64_t N, uint32_t r, uint32_t p, 40 uint8_t * buf, size_t buflen); 41 42 /* #define crypto_pwhash_scryptsalsa208sha256_STRBYTES 102 */ 43 int crypto_pwhash_scryptsalsa208sha256_str(char out[102], 44 const char * const passwd, 45 unsigned long long passwdlen, 46 unsigned long long opslimit, 47 size_t memlimit); 48 49 int crypto_pwhash_scryptsalsa208sha256_str_verify(const char str[102], 50 const char * const passwd, 51 unsigned long long passwdlen); 52 53 /* 54 * argon2 bindings 55 */ 56 57 /* 58 * general argon2 limits 59 */ 60 61 size_t crypto_pwhash_strbytes(void); 62 size_t crypto_pwhash_saltbytes(void); 63 size_t crypto_pwhash_bytes_min(void); 64 size_t crypto_pwhash_bytes_max(void); 65 size_t crypto_pwhash_passwd_min(void); 66 size_t crypto_pwhash_passwd_max(void); 67 68 /* 69 * available algorithms identifiers 70 */ 71 72 int crypto_pwhash_alg_default(void); 73 int crypto_pwhash_alg_argon2i13(void); 74 int crypto_pwhash_alg_argon2id13(void); 75 76 /* 77 * argon2i recommended limits 78 */ 79 80 size_t crypto_pwhash_argon2i_memlimit_interactive(void); 81 size_t crypto_pwhash_argon2i_memlimit_moderate(void); 82 size_t crypto_pwhash_argon2i_memlimit_sensitive(void); 83 size_t crypto_pwhash_argon2i_memlimit_min(void); 84 size_t crypto_pwhash_argon2i_memlimit_max(void); 85 size_t crypto_pwhash_argon2i_opslimit_min(void); 86 size_t crypto_pwhash_argon2i_opslimit_max(void); 87 size_t crypto_pwhash_argon2i_opslimit_interactive(void); 88 size_t crypto_pwhash_argon2i_opslimit_moderate(void); 89 size_t crypto_pwhash_argon2i_opslimit_sensitive(void); 90 91 /* 92 * argon2id recommended limits 93 */ 94 95 size_t crypto_pwhash_argon2id_memlimit_interactive(void); 96 size_t crypto_pwhash_argon2id_memlimit_moderate(void); 97 size_t crypto_pwhash_argon2id_memlimit_sensitive(void); 98 size_t crypto_pwhash_argon2id_memlimit_min(void); 99 size_t crypto_pwhash_argon2id_memlimit_max(void); 100 size_t crypto_pwhash_argon2id_opslimit_min(void); 101 size_t crypto_pwhash_argon2id_opslimit_max(void); 102 size_t crypto_pwhash_argon2id_opslimit_interactive(void); 103 size_t crypto_pwhash_argon2id_opslimit_moderate(void); 104 size_t crypto_pwhash_argon2id_opslimit_sensitive(void); 105 106 /* 107 * libsodium's default argon2 algorithm recommended limits 108 */ 109 110 size_t crypto_pwhash_memlimit_interactive(void); 111 size_t crypto_pwhash_memlimit_moderate(void); 112 size_t crypto_pwhash_memlimit_sensitive(void); 113 size_t crypto_pwhash_memlimit_min(void); 114 size_t crypto_pwhash_memlimit_max(void); 115 size_t crypto_pwhash_opslimit_min(void); 116 size_t crypto_pwhash_opslimit_max(void); 117 size_t crypto_pwhash_opslimit_interactive(void); 118 size_t crypto_pwhash_opslimit_moderate(void); 119 size_t crypto_pwhash_opslimit_sensitive(void); 120 121 /* 122 * Modular crypt string prefix for implemented argon2 constructions 123 */ 124 125 const char *crypto_pwhash_argon2i_strprefix(void); 126 const char *crypto_pwhash_argon2id_strprefix(void); 127 128 /* 129 * crypto_pwhash raw constructs 130 */ 131 132 int crypto_pwhash(unsigned char * const out, unsigned long long outlen, 133 const char * const passwd, unsigned long long passwdlen, 134 const unsigned char * const salt, 135 unsigned long long opslimit, size_t memlimit, int alg); 136 137 /* 138 * #define crypto_pwhash_argon2i_STRBYTES 128U 139 * #define crypto_pwhash_STRBYTES crypto_pwhash_argon2i_STRBYTES 140 */ 141 142 int crypto_pwhash_str_alg(char out[128], 143 const char * const passwd, 144 unsigned long long passwdlen, 145 unsigned long long opslimit, 146 size_t memlimit, 147 int alg); 148 149 int crypto_pwhash_str_verify(const char str[128], 150 const char * const passwd, 151 unsigned long long passwdlen); 152 153 int crypto_pwhash_str_needs_rehash(const char str[128], 154 unsigned long long opslimit, size_t memlimit); 155