mirror of
https://github.com/Luzifer/cloudkeys-go.git
synced 2024-11-10 07:00:08 +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
1.6 KiB
Go
63 lines
1.6 KiB
Go
// Copyright 2015 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 pkcs12
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/hex"
|
|
"testing"
|
|
)
|
|
|
|
var bmpStringTests = []struct {
|
|
in string
|
|
expectedHex string
|
|
shouldFail bool
|
|
}{
|
|
{"", "0000", false},
|
|
// Example from https://tools.ietf.org/html/rfc7292#appendix-B.
|
|
{"Beavis", "0042006500610076006900730000", false},
|
|
// Some characters from the "Letterlike Symbols Unicode block".
|
|
{"\u2115 - Double-struck N", "21150020002d00200044006f00750062006c0065002d00730074007200750063006b0020004e0000", false},
|
|
// any character outside the BMP should trigger an error.
|
|
{"\U0001f000 East wind (Mahjong)", "", true},
|
|
}
|
|
|
|
func TestBMPString(t *testing.T) {
|
|
for i, test := range bmpStringTests {
|
|
expected, err := hex.DecodeString(test.expectedHex)
|
|
if err != nil {
|
|
t.Fatalf("#%d: failed to decode expectation", i)
|
|
}
|
|
|
|
out, err := bmpString(test.in)
|
|
if err == nil && test.shouldFail {
|
|
t.Errorf("#%d: expected to fail, but produced %x", i, out)
|
|
continue
|
|
}
|
|
|
|
if err != nil && !test.shouldFail {
|
|
t.Errorf("#%d: failed unexpectedly: %s", i, err)
|
|
continue
|
|
}
|
|
|
|
if !test.shouldFail {
|
|
if !bytes.Equal(out, expected) {
|
|
t.Errorf("#%d: expected %s, got %x", i, test.expectedHex, out)
|
|
continue
|
|
}
|
|
|
|
roundTrip, err := decodeBMPString(out)
|
|
if err != nil {
|
|
t.Errorf("#%d: decoding output gave an error: %s", i, err)
|
|
continue
|
|
}
|
|
|
|
if roundTrip != test.in {
|
|
t.Errorf("#%d: decoding output resulted in %q, but it should have been %q", i, roundTrip, test.in)
|
|
continue
|
|
}
|
|
}
|
|
}
|
|
}
|