Home | History | Annotate | Line # | Download | only in sodium
      1 #ifndef crypto_pwhash_argon2id_H
      2 #define crypto_pwhash_argon2id_H
      3 
      4 #include <limits.h>
      5 #include <stddef.h>
      6 #include <stdint.h>
      7 
      8 #include "export.h"
      9 
     10 #ifdef __cplusplus
     11 # ifdef __GNUC__
     12 #  pragma GCC diagnostic ignored "-Wlong-long"
     13 # endif
     14 extern "C" {
     15 #endif
     16 
     17 #define crypto_pwhash_argon2id_ALG_ARGON2ID13 2
     18 SODIUM_EXPORT
     19 int crypto_pwhash_argon2id_alg_argon2id13(void);
     20 
     21 #define crypto_pwhash_argon2id_BYTES_MIN 16U
     22 SODIUM_EXPORT
     23 size_t crypto_pwhash_argon2id_bytes_min(void);
     24 
     25 #define crypto_pwhash_argon2id_BYTES_MAX SODIUM_MIN(SODIUM_SIZE_MAX, 4294967295U)
     26 SODIUM_EXPORT
     27 size_t crypto_pwhash_argon2id_bytes_max(void);
     28 
     29 #define crypto_pwhash_argon2id_PASSWD_MIN 0U
     30 SODIUM_EXPORT
     31 size_t crypto_pwhash_argon2id_passwd_min(void);
     32 
     33 #define crypto_pwhash_argon2id_PASSWD_MAX 4294967295U
     34 SODIUM_EXPORT
     35 size_t crypto_pwhash_argon2id_passwd_max(void);
     36 
     37 #define crypto_pwhash_argon2id_SALTBYTES 16U
     38 SODIUM_EXPORT
     39 size_t crypto_pwhash_argon2id_saltbytes(void);
     40 
     41 #define crypto_pwhash_argon2id_STRBYTES 128U
     42 SODIUM_EXPORT
     43 size_t crypto_pwhash_argon2id_strbytes(void);
     44 
     45 #define crypto_pwhash_argon2id_STRPREFIX "$argon2id$"
     46 SODIUM_EXPORT
     47 const char *crypto_pwhash_argon2id_strprefix(void);
     48 
     49 #define crypto_pwhash_argon2id_OPSLIMIT_MIN 1U
     50 SODIUM_EXPORT
     51 size_t crypto_pwhash_argon2id_opslimit_min(void);
     52 
     53 #define crypto_pwhash_argon2id_OPSLIMIT_MAX 4294967295U
     54 SODIUM_EXPORT
     55 size_t crypto_pwhash_argon2id_opslimit_max(void);
     56 
     57 #define crypto_pwhash_argon2id_MEMLIMIT_MIN 8192U
     58 SODIUM_EXPORT
     59 size_t crypto_pwhash_argon2id_memlimit_min(void);
     60 
     61 #define crypto_pwhash_argon2id_MEMLIMIT_MAX \
     62     ((SIZE_MAX >= 4398046510080U) ? 4398046510080U : (SIZE_MAX >= 2147483648U) ? 2147483648U : 32768U)
     63 SODIUM_EXPORT
     64 size_t crypto_pwhash_argon2id_memlimit_max(void);
     65 
     66 #define crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE 2U
     67 SODIUM_EXPORT
     68 size_t crypto_pwhash_argon2id_opslimit_interactive(void);
     69 
     70 #define crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE 67108864U
     71 SODIUM_EXPORT
     72 size_t crypto_pwhash_argon2id_memlimit_interactive(void);
     73 
     74 #define crypto_pwhash_argon2id_OPSLIMIT_MODERATE 3U
     75 SODIUM_EXPORT
     76 size_t crypto_pwhash_argon2id_opslimit_moderate(void);
     77 
     78 #define crypto_pwhash_argon2id_MEMLIMIT_MODERATE 268435456U
     79 SODIUM_EXPORT
     80 size_t crypto_pwhash_argon2id_memlimit_moderate(void);
     81 
     82 #define crypto_pwhash_argon2id_OPSLIMIT_SENSITIVE 4U
     83 SODIUM_EXPORT
     84 size_t crypto_pwhash_argon2id_opslimit_sensitive(void);
     85 
     86 #define crypto_pwhash_argon2id_MEMLIMIT_SENSITIVE 1073741824U
     87 SODIUM_EXPORT
     88 size_t crypto_pwhash_argon2id_memlimit_sensitive(void);
     89 
     90 SODIUM_EXPORT
     91 int crypto_pwhash_argon2id(unsigned char * const out,
     92                            unsigned long long outlen,
     93                            const char * const passwd,
     94                            unsigned long long passwdlen,
     95                            const unsigned char * const salt,
     96                            unsigned long long opslimit, size_t memlimit,
     97                            int alg)
     98             __attribute__ ((warn_unused_result));
     99 
    100 SODIUM_EXPORT
    101 int crypto_pwhash_argon2id_str(char out[crypto_pwhash_argon2id_STRBYTES],
    102                                const char * const passwd,
    103                                unsigned long long passwdlen,
    104                                unsigned long long opslimit, size_t memlimit)
    105             __attribute__ ((warn_unused_result));
    106 
    107 SODIUM_EXPORT
    108 int crypto_pwhash_argon2id_str_verify(const char str[crypto_pwhash_argon2id_STRBYTES],
    109                                       const char * const passwd,
    110                                       unsigned long long passwdlen)
    111             __attribute__ ((warn_unused_result));
    112 
    113 SODIUM_EXPORT
    114 int crypto_pwhash_argon2id_str_needs_rehash(const char str[crypto_pwhash_argon2id_STRBYTES],
    115                                             unsigned long long opslimit, size_t memlimit)
    116             __attribute__ ((warn_unused_result));
    117 
    118 #ifdef __cplusplus
    119 }
    120 #endif
    121 
    122 #endif
    123