Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
go-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ai3
go-common
Commits
62b40add
Commit
62b40add
authored
4 months ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Switch new password default to Argon2id
parent
3d4cd358
No related branches found
No related tags found
No related merge requests found
Pipeline
#86049
passed
4 months ago
Stage: test
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
cmd/pwtool/main.go
+1
-1
1 addition, 1 deletion
cmd/pwtool/main.go
pwhash/argon2.go
+3
-3
3 additions, 3 deletions
pwhash/argon2.go
pwhash/password.go
+2
-2
2 additions, 2 deletions
pwhash/password.go
pwhash/password_test.go
+3
-3
3 additions, 3 deletions
pwhash/password_test.go
with
9 additions
and
9 deletions
cmd/pwtool/main.go
+
1
−
1
View file @
62b40add
...
...
@@ -86,7 +86,7 @@ func mkhash() (pwhash.PasswordHash, string, error) {
name
:=
*
algo
switch
*
algo
{
case
"argon2"
:
h
=
pwhash
.
NewArgon2WithParams
(
uint32
(
*
argon2Time
),
uint32
(
*
argon2Mem
*
1024
),
uint8
(
*
argon2Threads
))
h
=
pwhash
.
NewArgon2
Std
WithParams
(
uint32
(
*
argon2Time
),
uint32
(
*
argon2Mem
*
1024
),
uint8
(
*
argon2Threads
))
name
=
fmt
.
Sprintf
(
"%s(%d/%d/%d)"
,
*
algo
,
*
argon2Time
,
*
argon2Mem
,
*
argon2Threads
)
case
"scrypt"
:
h
=
pwhash
.
NewScryptWithParams
(
*
scryptN
,
*
scryptR
,
*
scryptP
)
...
...
This diff is collapsed.
Click to expand it.
pwhash/argon2.go
+
3
−
3
View file @
62b40add
...
...
@@ -43,8 +43,8 @@ func newArgon2PasswordHash(kind string, keySize int, time, mem uint32, threads u
}
// NewArgon2 returns an Argon2i-based PasswordHash using the default parameters.
func
NewArgon2
()
PasswordHash
{
return
NewArgon2WithParams
(
func
NewArgon2
Legacy
()
PasswordHash
{
return
NewArgon2
Legacy
WithParams
(
defaultArgon2Params
.
Time
,
defaultArgon2Params
.
Memory
,
defaultArgon2Params
.
Threads
,
...
...
@@ -53,7 +53,7 @@ func NewArgon2() PasswordHash {
// NewArgon2WithParams returns an Argon2i-based PasswordHash using the
// specified parameters for time, memory, and number of threads.
func
NewArgon2WithParams
(
time
,
mem
uint32
,
threads
uint8
)
PasswordHash
{
func
NewArgon2
Legacy
WithParams
(
time
,
mem
uint32
,
threads
uint8
)
PasswordHash
{
return
newArgon2PasswordHash
(
kindArgon2I
,
argonLegacyKeySize
,
time
,
mem
,
threads
,
&
a2LegacyCodec
{})
}
...
...
This diff is collapsed.
Click to expand it.
pwhash/password.go
+
2
−
2
View file @
62b40add
...
...
@@ -52,7 +52,7 @@ var prefixRegistry = map[string]PasswordHash{
"$5$"
:
NewSystemCrypt
(),
"$6$"
:
NewSystemCrypt
(),
"$s$"
:
NewScrypt
(),
"$a2$"
:
NewArgon2
(),
"$a2$"
:
NewArgon2
Legacy
(),
"$argon2i$"
:
NewArgon2Std
(),
"$argon2id$"
:
NewArgon2Std
(),
}
...
...
@@ -74,7 +74,7 @@ func ComparePassword(encrypted, password string) bool {
var
DefaultEncryptAlgorithm
PasswordHash
func
init
()
{
DefaultEncryptAlgorithm
=
NewArgon2
()
DefaultEncryptAlgorithm
=
NewArgon2
Std
()
}
// Encrypt will encrypt a password with the default algorithm.
...
...
This diff is collapsed.
Click to expand it.
pwhash/password_test.go
+
3
−
3
View file @
62b40add
...
...
@@ -5,8 +5,8 @@ import (
"testing"
)
func
TestArgon2
(
t
*
testing
.
T
)
{
testImpl
(
t
,
NewArgon2
())
func
TestArgon2
Legacy
(
t
*
testing
.
T
)
{
testImpl
(
t
,
NewArgon2
Legacy
())
}
func
TestArgon2Std
(
t
*
testing
.
T
)
{
...
...
@@ -102,7 +102,7 @@ func BenchmarkArgon2(b *testing.B) {
for
_
,
tp
:=
range
testParams
{
name
:=
fmt
.
Sprintf
(
"%d/%d/%d"
,
tp
.
Time
,
tp
.
Memory
,
tp
.
Threads
)
b
.
Run
(
name
,
func
(
b
*
testing
.
B
)
{
h
:=
NewArgon2WithParams
(
tp
.
Time
,
tp
.
Memory
,
tp
.
Threads
)
h
:=
NewArgon2
Std
WithParams
(
tp
.
Time
,
tp
.
Memory
,
tp
.
Threads
)
encPw
:=
h
.
Encrypt
(
goodPw
)
b
.
ResetTimer
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment