footing 0.1.4

Feature-gated foundations for Rust backend services
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
//! Password storage security built around PHC-formatted Argon2id hashes.
//!
//! `PasswordService` owns algorithm selection, parameter profile, password
//! length limits, verification, and rehash assessment. Application code should
//! call this module instead of depending on `argon2` directly.
//!
//! ```rust
//! use footing::auth::PasswordService;
//!
//! let service = PasswordService::new();
//! let stored_hash = service.hash_password("correct horse battery staple").unwrap();
//! let verification = service
//!     .verify_and_assess("correct horse battery staple", &stored_hash)
//!     .unwrap();
//!
//! assert!(verification.verified());
//! if verification.needs_rehash() {
//!     let upgraded_hash = service.hash_password("correct horse battery staple").unwrap();
//!     assert_ne!(stored_hash, upgraded_hash);
//! }
//! ```
//!
use argon2::{
    Algorithm, Argon2, Params, PasswordHash, PasswordHasher as Argon2PasswordHasher,
    PasswordVerifier as _, Version,
    password_hash::{SaltString, rand_core::OsRng},
};
use thiserror::Error;

use crate::result::{ClassifyError, ErrorKind};

/// Default maximum accepted password length in bytes.
pub const DEFAULT_MAX_PASSWORD_BYTES: usize = 1024;
/// Default Argon2id memory cost in KiB.
pub const DEFAULT_ARGON2ID_MEMORY_COST_KIB: u32 = 19 * 1024;
/// Default Argon2id iteration count.
pub const DEFAULT_ARGON2ID_TIME_COST: u32 = 2;
/// Default Argon2id degree of parallelism.
pub const DEFAULT_ARGON2ID_PARALLELISM: u32 = 1;
/// Default Argon2id output length in bytes.
pub const DEFAULT_ARGON2ID_OUTPUT_BYTES: usize = 32;
/// Numeric representation of Argon2 version 1.3.
pub const ARGON2_VERSION_13: u32 = 0x13;

// This stable, non-secret value makes the dummy hash reusable across service
// instances without coupling the library to any consuming application.
const DUMMY_PASSWORD_SALT: &[u8] = b"password-enumeration-timing-guard";

#[derive(Debug, Error)]
#[non_exhaustive]
/// Errors that can occur while handling security.
pub enum SecurityError {
    #[error("password must not exceed {max} bytes")]
    /// The password exceeds the supported length.
    PasswordTooLong {
        #[doc = "The configured upper bound."]
        max: usize,
    },
    #[error("password policy is invalid")]
    /// The password policy is invalid.
    InvalidPasswordPolicy,
    #[error("password hash profile is invalid")]
    /// The password hash profile is invalid.
    InvalidPasswordHashProfile,
    #[error("password hash failed")]
    /// Indicates password hash.
    PasswordHash,
    #[error("password hash is invalid")]
    /// The password hash is invalid.
    InvalidPasswordHash,
    #[error("password hash algorithm is unsupported")]
    /// The password hash is unsupported.
    UnsupportedPasswordHash,
    #[error("password verification failed")]
    /// Indicates password verify.
    PasswordVerify,
}

impl ClassifyError for SecurityError {
    fn error_kind(&self) -> ErrorKind {
        match self {
            Self::PasswordTooLong { .. }
            | Self::InvalidPasswordPolicy
            | Self::InvalidPasswordHashProfile
            | Self::InvalidPasswordHash
            | Self::UnsupportedPasswordHash => ErrorKind::Validation,
            Self::PasswordHash | Self::PasswordVerify => ErrorKind::Internal,
        }
    }

    fn error_code(&self) -> crate::result::ErrorCode {
        crate::result::ErrorCode::internal(match self {
            Self::PasswordTooLong { .. } => "password_too_long",
            Self::InvalidPasswordPolicy => "invalid_password_policy",
            Self::InvalidPasswordHashProfile => "invalid_password_hash_profile",
            Self::PasswordHash => "password_hash_failed",
            Self::InvalidPasswordHash => "invalid_password_hash",
            Self::UnsupportedPasswordHash => "unsupported_password_hash",
            Self::PasswordVerify => "password_verification_failed",
        })
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// Policy controlling password.
pub struct PasswordPolicy {
    max_password_bytes: usize,
}

impl PasswordPolicy {
    /// Creates a new instance.
    pub const fn new(max_password_bytes: usize) -> Result<Self, SecurityError> {
        if max_password_bytes == 0 {
            return Err(SecurityError::InvalidPasswordPolicy);
        }

        Ok(Self { max_password_bytes })
    }

    #[must_use]
    /// Returns the maximum password bytes.
    pub const fn max_password_bytes(&self) -> usize {
        self.max_password_bytes
    }

    fn validate_password(self, password: &str) -> Result<(), SecurityError> {
        if password.len() > self.max_password_bytes {
            return Err(SecurityError::PasswordTooLong {
                max: self.max_password_bytes,
            });
        }

        Ok(())
    }
}

impl Default for PasswordPolicy {
    fn default() -> Self {
        Self {
            max_password_bytes: DEFAULT_MAX_PASSWORD_BYTES,
        }
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// Represents Argon2id profile.
pub struct Argon2idProfile {
    memory_cost_kib: u32,
    time_cost: u32,
    parallelism: u32,
    output_bytes: usize,
}

impl Argon2idProfile {
    /// Creates a new instance.
    pub const fn new(
        memory_cost_kib: u32,
        time_cost: u32,
        parallelism: u32,
        output_bytes: usize,
    ) -> Result<Self, SecurityError> {
        if time_cost < Params::MIN_T_COST {
            return Err(SecurityError::InvalidPasswordHashProfile);
        }
        if parallelism < Params::MIN_P_COST || parallelism > Params::MAX_P_COST {
            return Err(SecurityError::InvalidPasswordHashProfile);
        }
        if memory_cost_kib < Params::MIN_M_COST || memory_cost_kib < parallelism * 8 {
            return Err(SecurityError::InvalidPasswordHashProfile);
        }
        if output_bytes < Params::MIN_OUTPUT_LEN || output_bytes > Params::MAX_OUTPUT_LEN {
            return Err(SecurityError::InvalidPasswordHashProfile);
        }

        Ok(Self {
            memory_cost_kib,
            time_cost,
            parallelism,
            output_bytes,
        })
    }

    #[must_use]
    /// Returns the OWASP minimum Argon2id cost profile.
    pub const fn owasp_minimum() -> Self {
        Self {
            memory_cost_kib: DEFAULT_ARGON2ID_MEMORY_COST_KIB,
            time_cost: DEFAULT_ARGON2ID_TIME_COST,
            parallelism: DEFAULT_ARGON2ID_PARALLELISM,
            output_bytes: DEFAULT_ARGON2ID_OUTPUT_BYTES,
        }
    }

    #[must_use]
    /// Returns the memory cost KiB.
    pub const fn memory_cost_kib(&self) -> u32 {
        self.memory_cost_kib
    }

    #[must_use]
    /// Returns the time cost.
    pub const fn time_cost(&self) -> u32 {
        self.time_cost
    }

    #[must_use]
    /// Returns the parallelism.
    pub const fn parallelism(&self) -> u32 {
        self.parallelism
    }

    #[must_use]
    /// Returns the output bytes.
    pub const fn output_bytes(&self) -> usize {
        self.output_bytes
    }

    fn params(self) -> Result<Params, SecurityError> {
        Params::new(
            self.memory_cost_kib,
            self.time_cost,
            self.parallelism,
            Some(self.output_bytes),
        )
        .map_err(|_| SecurityError::InvalidPasswordHashProfile)
    }
}

impl Default for Argon2idProfile {
    fn default() -> Self {
        Self::owasp_minimum()
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
/// Represents password hash profile.
pub struct PasswordHashProfile {
    argon2id: Argon2idProfile,
}

impl PasswordHashProfile {
    #[must_use]
    /// Creates a password-hash profile using Argon2id.
    pub const fn argon2id(argon2id: Argon2idProfile) -> Self {
        Self { argon2id }
    }

    #[must_use]
    /// Returns a password-hash profile using the OWASP minimum costs.
    pub const fn owasp_minimum() -> Self {
        Self {
            argon2id: Argon2idProfile::owasp_minimum(),
        }
    }

    #[must_use]
    /// Returns the Argon2id profile.
    pub const fn argon2id_profile(&self) -> Argon2idProfile {
        self.argon2id
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
/// Enumerates the supported password hash algorithm values.
pub enum PasswordHashAlgorithm {
    /// Indicates Argon2d.
    Argon2d,
    /// Indicates Argon2i.
    Argon2i,
    /// Indicates Argon2id.
    Argon2id,
    /// The value is unknown.
    Unknown,
}

impl PasswordHashAlgorithm {
    #[must_use]
    /// Returns whether this value is Argon2id.
    pub const fn is_argon2id(self) -> bool {
        matches!(self, Self::Argon2id)
    }

    fn from_identifier(identifier: &str) -> Self {
        match identifier {
            "argon2d" => Self::Argon2d,
            "argon2i" => Self::Argon2i,
            "argon2id" => Self::Argon2id,
            _ => Self::Unknown,
        }
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// Represents password hash metadata.
pub struct PasswordHashMetadata {
    algorithm: PasswordHashAlgorithm,
    version: Option<u32>,
    memory_cost_kib: Option<u32>,
    time_cost: Option<u32>,
    parallelism: Option<u32>,
    output_bytes: Option<usize>,
}

impl PasswordHashMetadata {
    #[must_use]
    /// Returns the algorithm.
    pub const fn algorithm(&self) -> PasswordHashAlgorithm {
        self.algorithm
    }

    #[must_use]
    /// Returns the version.
    pub const fn version(&self) -> Option<u32> {
        self.version
    }

    #[must_use]
    /// Returns the memory cost KiB.
    pub const fn memory_cost_kib(&self) -> Option<u32> {
        self.memory_cost_kib
    }

    #[must_use]
    /// Returns the time cost.
    pub const fn time_cost(&self) -> Option<u32> {
        self.time_cost
    }

    #[must_use]
    /// Returns the parallelism.
    pub const fn parallelism(&self) -> Option<u32> {
        self.parallelism
    }

    #[must_use]
    /// Returns the output bytes.
    pub const fn output_bytes(&self) -> Option<usize> {
        self.output_bytes
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// Represents password hash assessment.
pub struct PasswordHashAssessment {
    metadata: PasswordHashMetadata,
    needs_rehash: bool,
}

impl PasswordHashAssessment {
    #[must_use]
    /// Returns the metadata.
    pub const fn metadata(&self) -> PasswordHashMetadata {
        self.metadata
    }

    #[must_use]
    /// Returns the needs rehash.
    pub const fn needs_rehash(&self) -> bool {
        self.needs_rehash
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// Represents password verification.
pub struct PasswordVerification {
    assessment: PasswordHashAssessment,
    verified: bool,
}

impl PasswordVerification {
    #[must_use]
    /// Returns the verified.
    pub const fn verified(&self) -> bool {
        self.verified
    }

    #[must_use]
    /// Returns the needs rehash.
    pub const fn needs_rehash(&self) -> bool {
        self.verified && self.assessment.needs_rehash
    }

    #[must_use]
    /// Returns the assessment.
    pub const fn assessment(&self) -> PasswordHashAssessment {
        self.assessment
    }
}

#[derive(Debug, Clone, Default)]
/// Service for password.
pub struct PasswordService {
    profile: PasswordHashProfile,
    policy: PasswordPolicy,
}

impl PasswordService {
    #[must_use]
    /// Creates a new instance.
    pub fn new() -> Self {
        Self::default()
    }

    #[must_use]
    /// Configures policy and returns the updated value.
    pub fn with_policy(mut self, policy: PasswordPolicy) -> Self {
        self.policy = policy;
        self
    }

    #[must_use]
    /// Configures profile and returns the updated value.
    pub fn with_profile(mut self, profile: PasswordHashProfile) -> Self {
        self.profile = profile;
        self
    }

    #[must_use]
    /// Returns the policy.
    pub const fn policy(&self) -> PasswordPolicy {
        self.policy
    }

    #[must_use]
    /// Returns the profile.
    pub const fn profile(&self) -> PasswordHashProfile {
        self.profile
    }

    /// Hashes password.
    pub fn hash_password(&self, password: &str) -> Result<String, SecurityError> {
        self.policy.validate_password(password)?;

        let salt = SaltString::generate(&mut OsRng);
        self.argon2()?
            .hash_password(password.as_bytes(), &salt)
            .map(|hash| hash.to_string())
            .map_err(|_| SecurityError::PasswordHash)
    }

    /// Builds a reusable hash for authentication timing equalization.
    ///
    /// The fixed salt is intentional: this hash is never persisted or used as
    /// a credential. Reusing it avoids generating a new Argon2 hash for every
    /// unknown login identifier while retaining this service's exact cost
    /// profile during verification.
    pub fn dummy_password_hash(&self) -> Result<String, SecurityError> {
        let salt =
            SaltString::encode_b64(DUMMY_PASSWORD_SALT).map_err(|_| SecurityError::PasswordHash)?;
        self.argon2()?
            .hash_password(b"", &salt)
            .map(|hash| hash.to_string())
            .map_err(|_| SecurityError::PasswordHash)
    }

    /// Verifies password.
    pub fn verify_password(
        &self,
        password: &str,
        password_hash: &str,
    ) -> Result<bool, SecurityError> {
        self.verify_and_assess(password, password_hash)
            .map(|verification| verification.verified())
    }

    /// Verifies and assess.
    pub fn verify_and_assess(
        &self,
        password: &str,
        password_hash: &str,
    ) -> Result<PasswordVerification, SecurityError> {
        self.policy.validate_password(password)?;

        let parsed =
            PasswordHash::new(password_hash).map_err(|_| SecurityError::InvalidPasswordHash)?;
        let assessment = self.assess_parsed_hash(&parsed);

        match self.argon2()?.verify_password(password.as_bytes(), &parsed) {
            Ok(()) => Ok(PasswordVerification {
                assessment,
                verified: true,
            }),
            Err(argon2::password_hash::Error::Password) => Ok(PasswordVerification {
                assessment,
                verified: false,
            }),
            Err(argon2::password_hash::Error::Algorithm) => {
                Err(SecurityError::UnsupportedPasswordHash)
            }
            Err(_) => Err(SecurityError::PasswordVerify),
        }
    }

    /// Assesses password hash.
    pub fn assess_password_hash(
        &self,
        password_hash: &str,
    ) -> Result<PasswordHashAssessment, SecurityError> {
        let parsed =
            PasswordHash::new(password_hash).map_err(|_| SecurityError::InvalidPasswordHash)?;
        Ok(self.assess_parsed_hash(&parsed))
    }

    fn assess_parsed_hash(&self, parsed: &PasswordHash<'_>) -> PasswordHashAssessment {
        let metadata = password_hash_metadata(parsed);
        PasswordHashAssessment {
            metadata,
            needs_rehash: self.hash_needs_rehash(metadata),
        }
    }

    fn hash_needs_rehash(&self, metadata: PasswordHashMetadata) -> bool {
        let profile = self.profile.argon2id_profile();
        !metadata.algorithm.is_argon2id()
            || metadata.version != Some(ARGON2_VERSION_13)
            || metadata
                .memory_cost_kib
                .is_none_or(|value| value < profile.memory_cost_kib())
            || metadata
                .time_cost
                .is_none_or(|value| value < profile.time_cost())
            || metadata
                .parallelism
                .is_none_or(|value| value < profile.parallelism())
            || metadata
                .output_bytes
                .is_none_or(|value| value < profile.output_bytes())
    }

    fn argon2(&self) -> Result<Argon2<'_>, SecurityError> {
        Ok(Argon2::new(
            Algorithm::Argon2id,
            Version::V0x13,
            self.profile.argon2id_profile().params()?,
        ))
    }
}

fn password_hash_metadata(parsed: &PasswordHash<'_>) -> PasswordHashMetadata {
    let params = Params::try_from(parsed).ok();
    PasswordHashMetadata {
        algorithm: PasswordHashAlgorithm::from_identifier(parsed.algorithm.as_str()),
        version: parsed.version,
        memory_cost_kib: params.as_ref().map(Params::m_cost),
        time_cost: params.as_ref().map(Params::t_cost),
        parallelism: params.as_ref().map(Params::p_cost),
        output_bytes: params.and_then(|params| params.output_len()),
    }
}

#[cfg(test)]
mod tests {
    use super::{
        Argon2idProfile, PasswordHashAlgorithm, PasswordHashProfile, PasswordPolicy,
        PasswordService, SecurityError,
    };

    #[test]
    fn hashes_with_explicit_argon2id_profile() {
        let service = PasswordService::new();
        let password_hash = service
            .hash_password("correct horse battery staple")
            .expect("test password should hash");
        let assessment = service
            .assess_password_hash(&password_hash)
            .expect("test password hash should parse");
        let metadata = assessment.metadata();

        assert_eq!(metadata.algorithm(), PasswordHashAlgorithm::Argon2id);
        assert_eq!(metadata.version(), Some(super::ARGON2_VERSION_13));
        assert_eq!(
            metadata.memory_cost_kib(),
            Some(super::DEFAULT_ARGON2ID_MEMORY_COST_KIB)
        );
        assert_eq!(
            metadata.time_cost(),
            Some(super::DEFAULT_ARGON2ID_TIME_COST)
        );
        assert_eq!(
            metadata.parallelism(),
            Some(super::DEFAULT_ARGON2ID_PARALLELISM)
        );
        assert_eq!(
            metadata.output_bytes(),
            Some(super::DEFAULT_ARGON2ID_OUTPUT_BYTES)
        );
        assert!(!assessment.needs_rehash());
    }

    #[test]
    fn verifies_matching_password() {
        let service = PasswordService::new();
        let password_hash = service
            .hash_password("correct horse battery staple")
            .expect("test password should hash");

        let verification = service
            .verify_and_assess("correct horse battery staple", &password_hash)
            .expect("test password hash should parse");

        assert!(verification.verified());
        assert!(!verification.needs_rehash());
    }

    #[test]
    fn dummy_hash_reuses_the_configured_argon2_cost_profile() {
        let service = PasswordService::new();
        let dummy_hash = service
            .dummy_password_hash()
            .expect("dummy password hash should build");

        let assessment = service
            .assess_password_hash(&dummy_hash)
            .expect("dummy password hash should parse");
        assert!(!assessment.needs_rehash());
        assert!(!service.verify_password("not-empty", &dummy_hash).unwrap());
    }

    #[test]
    fn rejects_non_matching_password() {
        let service = PasswordService::new();
        let password_hash = service
            .hash_password("correct horse battery staple")
            .expect("test password should hash");

        let verification = service
            .verify_and_assess("wrong password", &password_hash)
            .expect("test password hash should parse");

        assert!(!verification.verified());
        assert!(!verification.needs_rehash());
    }

    #[test]
    fn rejects_invalid_hash_format() {
        let service = PasswordService::new();
        let result = service.verify_password("password", "not-a-password-hash");

        assert!(matches!(result, Err(SecurityError::InvalidPasswordHash)));
    }

    #[test]
    fn marks_weaker_hashes_for_rehash_after_successful_verification() {
        let weak_profile =
            PasswordHashProfile::argon2id(Argon2idProfile::new(8, 1, 1, 16).unwrap());
        let weak_service = PasswordService::new().with_profile(weak_profile);
        let password_hash = weak_service
            .hash_password("correct horse battery staple")
            .expect("test password should hash");

        let verification = PasswordService::new()
            .verify_and_assess("correct horse battery staple", &password_hash)
            .expect("test password hash should parse");

        assert!(verification.verified());
        assert!(verification.needs_rehash());
    }

    #[test]
    fn rejects_oversized_passwords() {
        let service = PasswordService::new()
            .with_policy(PasswordPolicy::new(4).expect("policy should be valid"));

        assert!(matches!(
            service.hash_password("12345"),
            Err(SecurityError::PasswordTooLong { max: 4 })
        ));
        assert!(matches!(
            service.verify_password("12345", "not-a-password-hash"),
            Err(SecurityError::PasswordTooLong { max: 4 })
        ));
    }

    #[test]
    fn rejects_invalid_password_policy() {
        assert!(matches!(
            PasswordPolicy::new(0),
            Err(SecurityError::InvalidPasswordPolicy)
        ));
    }

    #[test]
    fn rejects_invalid_argon2id_profile() {
        assert!(matches!(
            Argon2idProfile::new(0, 2, 1, 32),
            Err(SecurityError::InvalidPasswordHashProfile)
        ));
        assert!(matches!(
            Argon2idProfile::new(8, 0, 1, 32),
            Err(SecurityError::InvalidPasswordHashProfile)
        ));
        assert!(matches!(
            Argon2idProfile::new(8, 1, 0, 32),
            Err(SecurityError::InvalidPasswordHashProfile)
        ));
        assert!(matches!(
            Argon2idProfile::new(8, 1, 1, 1),
            Err(SecurityError::InvalidPasswordHashProfile)
        ));
    }
}