From d2839286cef26ab257c992c2c1947fd4369ea463 Mon Sep 17 00:00:00 2001 From: Jussi Date: Sat, 9 Nov 2024 15:23:09 +0200 Subject: [PATCH] feat: remove `test_unsafe` --- .gitignore | 1 + README.md | 10 +--------- lib/argon2_elixir.ex | 9 +++------ lib/benchmark.ex | 3 +-- mix.exs | 4 ++-- native/argon2/src/lib.rs | 3 --- test/argon2_test.exs | 7 ------- 7 files changed, 8 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 966d73b..380d5b1 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ argon2id_elixir-*.tar .DS_Store /.elixir_ls/ *.xml +native/argon2/target/ diff --git a/README.md b/README.md index c7b416d..d85a22f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Fast and secure Argon2 password hashing library for Elixir. - Uses the pure Rust implementation of Argon2 - Only Argon2i implementation (version 0x13) at the moment -- Built-in security presets (OWASP, Strong, Test/Unsafe) +- Built-in security presets (OWASP, Strong) ## Installation @@ -56,9 +56,6 @@ hash = Argon2.hash_password("secure_password123") # Strong - Higher security for sensitive applications hash = Argon2.hash_password("secure_password123", "strong") - -# Test - Fast but unsafe, only for testing purposes -hash = Argon2.hash_password("secure_password123", "test_unsafe") ``` Preset specifications: @@ -86,11 +83,6 @@ STRONG: Hash time: 145ms Verify time: 139ms Memory: 65MB - -TEST_UNSAFE: - Hash time: 1ms - Verify time: 1ms - Memory: 1MB ``` ## Development diff --git a/lib/argon2_elixir.ex b/lib/argon2_elixir.ex index 7eb0892..f314444 100644 --- a/lib/argon2_elixir.ex +++ b/lib/argon2_elixir.ex @@ -1,15 +1,13 @@ defmodule Argon2 do @moduledoc """ - Argon2 password hashing for Elixir using Rust NIFs. + Argon2 password hashing using Rust. - This module provides a secure way to hash passwords using the Argon2i algorithm - with configuration presets following security best practices. + This module provides a secure way to hash passwords using the Argon2i algorithm. ## Security Presets * `:owasp` (default) - OWASP recommended settings (m=19456, t=2, p=1) * `:strong` - Higher security settings (m=65540, t=3, p=4) - * `:test_unsafe` - Fast settings for testing only (m=1024, t=1, p=1) ## Examples @@ -34,7 +32,6 @@ defmodule Argon2 do * Passwords must be at least 8 characters long * Each hash uses a unique random salt - * The `:test_unsafe` preset should never be used in production """ @type password :: String.t() @@ -46,7 +43,7 @@ defmodule Argon2 do ## Options - * `config` - One of `"owasp"` (default), `"strong"`, or `"test_unsafe"` + * `config` - One of `"owasp"` (default) or `"strong"` ## Examples diff --git a/lib/benchmark.ex b/lib/benchmark.ex index afdf3b2..c915c8d 100644 --- a/lib/benchmark.ex +++ b/lib/benchmark.ex @@ -4,7 +4,7 @@ defmodule Argon2.Benchmark do """ def run(rounds \\ 5) do - configs = [nil, "strong", "test_unsafe"] + configs = [nil, "strong"] password = "benchmark_password123" IO.puts("Configuration Benchmarks (averaged over #{rounds} runs):\n") @@ -37,7 +37,6 @@ defmodule Argon2.Benchmark do case config do "owasp" -> 19 "strong" -> 65 - "test_unsafe" -> 1 end IO.puts(""" diff --git a/mix.exs b/mix.exs index 41a31e6..4b44020 100644 --- a/mix.exs +++ b/mix.exs @@ -6,7 +6,7 @@ defmodule Argon2.MixProject do def project do [ app: :argon2id_elixir, - version: "1.0.0", + version: "1.1.0", elixir: "~> 1.17", start_permanent: Mix.env() == :prod, deps: deps(), @@ -113,7 +113,7 @@ defmodule Argon2.MixProject do [ main: "Argon2", source_url: @source_url, - extras: ["README.md"], + extras: ["README.md", "LICENSE-APACHE", "LICENSE-MIT"], groups_for_modules: [ Core: [ Argon2, diff --git a/native/argon2/src/lib.rs b/native/argon2/src/lib.rs index 8d4bf5b..b91fa70 100644 --- a/native/argon2/src/lib.rs +++ b/native/argon2/src/lib.rs @@ -13,7 +13,6 @@ const MIN_PASSWORD_LENGTH: usize = 8; enum ConfigType { Owasp, Strong, - TestUnsafe, } impl ConfigType { @@ -21,7 +20,6 @@ impl ConfigType { match self { ConfigType::Owasp => Params::new(19456, 2, 1, None).expect("Invalid OWASP config"), ConfigType::Strong => Params::new(65540, 3, 4, None).expect("Invalid strong config"), - ConfigType::TestUnsafe => Params::new(1024, 1, 1, None).expect("Invalid test config"), } } } @@ -39,7 +37,6 @@ fn hash_password(password: String, config_type: Option) -> Result ConfigType::Strong, - Some("test_unsafe") => ConfigType::TestUnsafe, _ => ConfigType::Owasp, }; diff --git a/test/argon2_test.exs b/test/argon2_test.exs index d1101f5..91ae462 100644 --- a/test/argon2_test.exs +++ b/test/argon2_test.exs @@ -16,13 +16,6 @@ defmodule Argon2Test do assert String.starts_with?(hash, "$argon2i$v=19$m=65540,t=3,p=4$") end - test "hashes a password with test/development config" do - config = "test_unsafe" - hash = Argon2.hash_password("password123", config) - assert is_binary(hash) - assert String.starts_with?(hash, "$argon2i$v=19$m=1024,t=1,p=1") - end - test "generates different hashes for the same password" do hash1 = Argon2.hash_password("same_password123") hash2 = Argon2.hash_password("same_password123")