mirror of
https://github.com/Luzifer/cloudkeys-go.git
synced 2024-11-09 22:50:05 +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
59 lines
1.1 KiB
Go
59 lines
1.1 KiB
Go
// Copyright 2011 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.
|
|
|
|
package openpgp
|
|
|
|
import "hash"
|
|
|
|
// NewCanonicalTextHash reformats text written to it into the canonical
|
|
// form and then applies the hash h. See RFC 4880, section 5.2.1.
|
|
func NewCanonicalTextHash(h hash.Hash) hash.Hash {
|
|
return &canonicalTextHash{h, 0}
|
|
}
|
|
|
|
type canonicalTextHash struct {
|
|
h hash.Hash
|
|
s int
|
|
}
|
|
|
|
var newline = []byte{'\r', '\n'}
|
|
|
|
func (cth *canonicalTextHash) Write(buf []byte) (int, error) {
|
|
start := 0
|
|
|
|
for i, c := range buf {
|
|
switch cth.s {
|
|
case 0:
|
|
if c == '\r' {
|
|
cth.s = 1
|
|
} else if c == '\n' {
|
|
cth.h.Write(buf[start:i])
|
|
cth.h.Write(newline)
|
|
start = i + 1
|
|
}
|
|
case 1:
|
|
cth.s = 0
|
|
}
|
|
}
|
|
|
|
cth.h.Write(buf[start:])
|
|
return len(buf), nil
|
|
}
|
|
|
|
func (cth *canonicalTextHash) Sum(in []byte) []byte {
|
|
return cth.h.Sum(in)
|
|
}
|
|
|
|
func (cth *canonicalTextHash) Reset() {
|
|
cth.h.Reset()
|
|
cth.s = 0
|
|
}
|
|
|
|
func (cth *canonicalTextHash) Size() int {
|
|
return cth.h.Size()
|
|
}
|
|
|
|
func (cth *canonicalTextHash) BlockSize() int {
|
|
return cth.h.BlockSize()
|
|
}
|