1 // Copyright (c) 2017 Martijn Rijkeboer <mrr@sru-systems.com> 2 // 3 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or 4 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license 5 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your 6 // option. This file may not be copied, modified, or distributed 7 // except according to those terms. 8 9 /// Default number of lanes (degree of parallelism). 10 pub const DEF_LANES: u32 = 1; 11 12 /// Minimum number of lanes (degree of parallelism). 13 pub const MIN_LANES: u32 = 1; 14 15 /// Maximum number of lanes (degree of parallelism). 16 pub const MAX_LANES: u32 = 0x00FFFFFF; 17 18 /// Number of synchronization points between lanes per pass. 19 pub const SYNC_POINTS: u32 = 4; 20 21 /// Default digest size in bytes. 22 pub const DEF_HASH_LENGTH: u32 = 32; 23 24 /// Minimum digest size in bytes. 25 pub const MIN_HASH_LENGTH: u32 = 4; 26 27 /// Maximum digest size in bytes. 28 pub const MAX_HASH_LENGTH: u32 = 0xFFFFFFFF; 29 30 /// Default number of memory blocks (2^12). 31 pub const DEF_MEMORY: u32 = 4096; 32 33 /// Minimum number of memory blocks (each of BLOCK_SIZE bytes). 34 pub const MIN_MEMORY: u32 = 2 * SYNC_POINTS; 35 36 /// Maximum number of memory blocks (each of BLOCK_SIZE bytes). 37 #[cfg(target_pointer_width = "32")] 38 pub const MAX_MEMORY: u32 = 0x200000; 39 #[cfg(target_pointer_width = "64")] 40 pub const MAX_MEMORY: u32 = 0xFFFFFFFF; 41 42 /// Default number of passes. 43 pub const DEF_TIME: u32 = 3; 44 45 /// Minimum number of passes 46 pub const MIN_TIME: u32 = 1; 47 48 /// Maximum number of passes. 49 pub const MAX_TIME: u32 = 0xFFFFFFFF; 50 51 /// Minimum password length in bytes. 52 pub const MIN_PWD_LENGTH: u32 = 0; 53 54 /// Maximum password length in bytes. 55 pub const MAX_PWD_LENGTH: u32 = 0xFFFFFFFF; 56 57 /// Minimum associated data length in bytes. 58 pub const MIN_AD_LENGTH: u32 = 0; 59 60 /// Maximum associated data length in bytes. 61 pub const MAX_AD_LENGTH: u32 = 0xFFFFFFFF; 62 63 /// Minimum salt length in bytes. 64 pub const MIN_SALT_LENGTH: u32 = 8; 65 66 /// Maximum salt length in bytes. 67 pub const MAX_SALT_LENGTH: u32 = 0xFFFFFFFF; 68 69 /// Minimum key length in bytes. 70 pub const MIN_SECRET_LENGTH: u32 = 0; 71 72 /// Maximum key length in bytes. 73 pub const MAX_SECRET_LENGTH: u32 = 0xFFFFFFFF; 74 75 /// Memory block size in bytes. 76 pub const BLOCK_SIZE: usize = 1024; 77 78 /// Number of quad words in a block. 79 pub const QWORDS_IN_BLOCK: usize = BLOCK_SIZE / 8; 80 81 /// Number of pseudo-random values generated by one call to Blake in Argon2i 82 /// to generate reference block positions. 83 pub const ADDRESSES_IN_BLOCK: u32 = 128; 84 85 /// Pre-hashing digest length. 86 pub const PREHASH_DIGEST_LENGTH: usize = 64; 87 88 /// Pre-hashing digest length with extension. 89 pub const PREHASH_SEED_LENGTH: usize = 72; 90 91 /// Blake2b output length in bytes. 92 pub const BLAKE2B_OUT_LENGTH: usize = 64; 93