31 lines
No EOL
1.3 KiB
Rust
31 lines
No EOL
1.3 KiB
Rust
// trifid-api, an open source reimplementation of the Defined Networking nebula management server.
|
|
// Copyright (C) 2023 c0repwn3r
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
use base64::Engine;
|
|
use totp_rs::Algorithm;
|
|
|
|
pub const TOTP_ALGORITHM: Algorithm = Algorithm::SHA1;
|
|
pub const TOTP_DIGITS: usize = 6;
|
|
pub const TOTP_SKEW: u8 = 1;
|
|
pub const TOTP_STEP: u64 = 30;
|
|
pub const TOTP_ISSUER: &str = "trifidapi";
|
|
|
|
pub fn base64decode(val: &str) -> Result<Vec<u8>, base64::DecodeError> {
|
|
base64::engine::general_purpose::STANDARD.decode(val)
|
|
}
|
|
pub fn base64encode(val: Vec<u8>) -> String {
|
|
base64::engine::general_purpose::STANDARD.encode(val)
|
|
} |