mirror of
https://github.com/Luzifer/cloudkeys-go.git
synced 2024-11-14 08:52:44 +00:00
Knut Ahlers
a1df72edc5
commitf0db1ff1f8
Author: Knut Ahlers <knut@ahlers.me> Date: Sun Dec 24 12:19:56 2017 +0100 Mark option as deprecated Signed-off-by: Knut Ahlers <knut@ahlers.me> commit9891df2a16
Author: Knut Ahlers <knut@ahlers.me> Date: Sun Dec 24 12:11:56 2017 +0100 Fix: Typo Signed-off-by: Knut Ahlers <knut@ahlers.me> commit836006de64
Author: Knut Ahlers <knut@ahlers.me> Date: Sun Dec 24 12:04:20 2017 +0100 Add new dependencies Signed-off-by: Knut Ahlers <knut@ahlers.me> commitd64fee60c8
Author: Knut Ahlers <knut@ahlers.me> Date: Sun Dec 24 11:55:52 2017 +0100 Replace insecure password hashing Prior this commit passwords were hashed with a static salt and using the SHA1 hashing function. This could lead to passwords being attackable in case someone gets access to the raw data stored inside the database. This commit introduces password hashing using bcrypt hashing function which addresses this issue. Old passwords are not automatically re-hashed as they are unknown. Replacing the old password scheme is not that easy and needs #10 to be solved. Therefore the old hashing scheme is kept for compatibility reason. Signed-off-by: Knut Ahlers <knut@ahlers.me> Signed-off-by: Knut Ahlers <knut@ahlers.me> closes #14 closes #15
63 lines
2.1 KiB
Go
63 lines
2.1 KiB
Go
// Copyright 2014 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// IMPLEMENTATION NOTE: To avoid a package loop, this file is in three places:
|
|
// ssh/, ssh/agent, and ssh/test/. It should be kept in sync across all three
|
|
// instances.
|
|
|
|
package ssh
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"fmt"
|
|
|
|
"golang.org/x/crypto/ssh/testdata"
|
|
)
|
|
|
|
var (
|
|
testPrivateKeys map[string]interface{}
|
|
testSigners map[string]Signer
|
|
testPublicKeys map[string]PublicKey
|
|
)
|
|
|
|
func init() {
|
|
var err error
|
|
|
|
n := len(testdata.PEMBytes)
|
|
testPrivateKeys = make(map[string]interface{}, n)
|
|
testSigners = make(map[string]Signer, n)
|
|
testPublicKeys = make(map[string]PublicKey, n)
|
|
for t, k := range testdata.PEMBytes {
|
|
testPrivateKeys[t], err = ParseRawPrivateKey(k)
|
|
if err != nil {
|
|
panic(fmt.Sprintf("Unable to parse test key %s: %v", t, err))
|
|
}
|
|
testSigners[t], err = NewSignerFromKey(testPrivateKeys[t])
|
|
if err != nil {
|
|
panic(fmt.Sprintf("Unable to create signer for test key %s: %v", t, err))
|
|
}
|
|
testPublicKeys[t] = testSigners[t].PublicKey()
|
|
}
|
|
|
|
// Create a cert and sign it for use in tests.
|
|
testCert := &Certificate{
|
|
Nonce: []byte{}, // To pass reflect.DeepEqual after marshal & parse, this must be non-nil
|
|
ValidPrincipals: []string{"gopher1", "gopher2"}, // increases test coverage
|
|
ValidAfter: 0, // unix epoch
|
|
ValidBefore: CertTimeInfinity, // The end of currently representable time.
|
|
Reserved: []byte{}, // To pass reflect.DeepEqual after marshal & parse, this must be non-nil
|
|
Key: testPublicKeys["ecdsa"],
|
|
SignatureKey: testPublicKeys["rsa"],
|
|
Permissions: Permissions{
|
|
CriticalOptions: map[string]string{},
|
|
Extensions: map[string]string{},
|
|
},
|
|
}
|
|
testCert.SignCert(rand.Reader, testSigners["rsa"])
|
|
testPrivateKeys["cert"] = testPrivateKeys["ecdsa"]
|
|
testSigners["cert"], err = NewCertSigner(testCert, testSigners["ecdsa"])
|
|
if err != nil {
|
|
panic(fmt.Sprintf("Unable to create certificate signer: %v", err))
|
|
}
|
|
}
|