/*-
 * Scram-rs - a SCRAM authentification authorization library
 * 
 * Copyright (C) 2021  Aleksandr Morozov
 * Copyright (C) 2025 Aleksandr Morozov
 * 
 * The syslog-rs crate can be redistributed and/or modified
 * under the terms of either of the following licenses:
 *
 *   1. the Mozilla Public License Version 2.0 (the “MPL”) OR
 *
 *   2. The MIT License (MIT)
 *                     
 *   3. EUROPEAN UNION PUBLIC LICENCE v. 1.2 EUPL © the European Union 2007, 2016
 */


/*! Scram-RS (Sync and Async)
 
 
 Provides a SASL SCRAM:
 - SHA1 
 - SHA256 
 - SHA512 
 - -PLUS

 Features:
 - default: "std", "use_ring"

 - `use_ring` - adds crate: [ring] as an alternative hashing and other crypto functions.

 - `use_aws_lc` - adds crate: [aws_lc_rs]  to the crate and a trait objects becomes available, also the dependancy is added automatically.  Sell crate's licenses. Picked: ISC and ISC

 - `exclude_sha1` - if enabled excludes the SHA1.
 
 - `std` - when set uses std lib, if removed, a no_std + alloc
    A program which includes this crate is based on standart library i.e std.
    For non-std an alloc crate is exported.
    Enabled by default.
    If CAPI was NOT excluded, and std was excluded, the crate will not be able to 
    allocate memory in heap. For this reason, the set_allocator() should be called 
    before using this crate in C program.
 
 - `with_async` - insludes async code

 - `with_capi` - includes CAPI code.

 - `xor_without_u128` - do not use the u128 type while performing XOR of arrays
  
 Default features:
 
 - std

 - use_ring

 - use_aws_lc

 For default crypto crates:
 scram-rs = { version = "0.22", default-features = true}
 
 For `ring` crypto crates:
 scram-rs = { version = "0.22", default-features = false, features = ["std", "use_ring"]}
 
 ### scram_sha256_server() sync tests (DEBUG) on AMD Ryzen 5 7600X 6-Core Processor 5453 MHz
 
A SHA-256 test

| iteration | rust-native | use_ring | use_aws_lc |
|-----------|-------------|----------|------------|
| 1         | 20.137667ms | 8.74799ms| 1.049665ms |
 
 For usage see ./examples/
 For C usage see ./tests/
 
 Files:
 - scram.rs contains client/server sync and async protocol handler
 - scram_sync.rs a synchronious realization of the protocol handler
 - scram_async.rs an asynchronious realization of the protocol handler
 - scram_parser.rs a scram message parser
 - scram_state.rs a global state of the protocol handler
 - scram_hashing.rs contains all supported hashers implementation
 - scram_error.rs error reporting code
 - scram_common.rs a common code
 - scram_cb.rs a channel bind code
 - scram_auth.rs a authentification callbacks and interface
*/

#![cfg_attr(not(feature = "std"), no_std)]

#[cfg(not(feature = "std"))]
extern crate alloc;

#[cfg(feature = "with_async")]
extern crate async_trait;
extern crate getrandom;
extern crate base64;
extern crate pbkdf2;
extern crate hmac;
extern crate sha3;
extern crate sha2;
extern crate sha1;
extern crate md5;


#[cfg(feature = "use_ring")]
extern crate ring;

#[cfg(feature = "use_aws_lc")]
extern crate aws_lc_rs;

/// A common items for the whole crate which is related to SCRAM.
pub mod scram;

/// A common code for channel binding protocol.
pub mod scram_cb;

/// A helpers for auth.
pub mod scram_auth;

/// A hashing algorithms.
pub mod scram_hashing;

/// A common code which is not related to SCRAM.
pub mod scram_common;

/// Crate's error alias.
pub mod scram_error;

/// Async code client/server.
#[cfg(feature = "with_async")]
pub mod scram_async;

mod scram_parser;
mod scram_state;

/// Sync code client/server.
pub mod scram_sync;

/// Sync client.
pub mod scram_sync_client;

/// Sync server.
pub mod scram_sync_server;

/// Channel binding helper for sync code.
#[macro_use]
pub mod scram_cbh;

/// SHA1
pub mod scram_hashing_sha1;

/// SHA256
pub mod scram_hashing_sha2;

/// SHA512
pub mod scram_hashing_sha5;

/// SHA3-512
pub mod scram_hashing_sha3_5;

/// C API
#[cfg(feature = "with_capi")]
pub mod c_api;

/// A dynamic instancing for sync client/server.
pub mod scram_dyn;

pub use scram::*;
pub use scram_auth::*;
pub use scram_common::*;
pub use scram_cb::ChannelBindType;
pub use scram_hashing::*;
pub use scram_error::*;
pub use scram_cbh::*;
pub use scram_dyn::*;
pub use scram_common::ScramTypes;

#[cfg(feature = "use_aws_lc")]
pub use scram_hashing_sha1::ScramSha1AwsLc;
#[cfg(feature = "use_ring")]
pub use scram_hashing_sha1::ScramSha1Ring;
pub use scram_hashing_sha1::ScramSha1RustNative;

#[cfg(feature = "use_aws_lc")]
pub use scram_hashing_sha2::ScramSha256AwsLc;
#[cfg(feature = "use_ring")]
pub use scram_hashing_sha2::ScramSha256Ring;
pub use scram_hashing_sha2::ScramSha256RustNative;

pub use scram_hashing_sha3_5::ScramSha3_512RustNative;

#[cfg(feature = "use_aws_lc")]
pub use scram_hashing_sha5::ScramSha512AwsLc;
#[cfg(feature = "use_ring")]
pub use scram_hashing_sha5::ScramSha512Ring;
pub use scram_hashing_sha5::ScramSha512RustNative;

#[cfg(feature = "with_async")]
pub use async_trait::async_trait;


