This commit is contained in:
number571 2023-06-25 15:48:52 +07:00
parent f5f51e38b7
commit 6ee343c456
14 changed files with 77 additions and 4 deletions

View File

@ -15,6 +15,7 @@ In progress...
- Example `_cmd/echo_service`: append docker-compose examples
- Example `_cmd/anon_messenger`: append docker-compose examples
- Projects `tools`: append encryptor application
- Projects `tools`: append pmanager application
- Projects `tools`: refactoring storage application
### CHANGES
@ -32,6 +33,7 @@ In progress...
### BUG FIXES
- Project `hidden_lake/messenger`: append checks pStateManager.GetWrapperDB().Get() on nil
- Package `crypto/entropy`: fix range hashes with one input data
<!-- ... -->

View File

@ -0,0 +1,19 @@
# PManager
> Stateless password manager
```bash
usage:
./main [service-name]
stdin:
[master-key]EOF
```
EOF - End of File (Ctrl+D)
## Example
```bash
$ echo "master-key" | go run . service-name login
fsJ5+QUz5nv/JK3VdqYWqzqQoMy0pg7FqQQtQKq2cnw=
```

View File

@ -0,0 +1,44 @@
package main
import (
"encoding/base64"
"fmt"
"io"
"os"
"github.com/number571/go-peer/pkg/crypto/entropy"
"github.com/number571/go-peer/pkg/crypto/hashing"
)
const (
workSize = 20
)
func main() {
if len(os.Args) != 3 {
panic(fmt.Sprintf(
"usage:\n\t%s\nstdin:\n\t%s\n\n",
"./main [service] [login]",
"[master-key]EOF",
))
}
var (
service = []byte(os.Args[1])
login = []byte(os.Args[2])
)
booster := entropy.NewEntropyBooster(workSize, login)
extendedKey := booster.BoostEntropy(readUntilEOF())
passBytes := hashing.NewHMACSHA256Hasher(extendedKey, service).ToBytes()
fmt.Println(base64.StdEncoding.EncodeToString(passBytes))
}
func readUntilEOF() []byte {
res, err := io.ReadAll(os.Stdin)
if err != nil {
panic(err)
}
return res
}

View File

@ -0,0 +1,5 @@
package main
import "testing"
func TestNothing(t *testing.T) {}

Binary file not shown.

View File

@ -32,7 +32,7 @@ func (p *sEntropyBooster) BoostEntropy(pData []byte) []byte {
for i := uint64(0); i < lim; i++ {
data = hashing.NewSHA256Hasher(bytes.Join(
[][]byte{
pData,
data,
p.fSalt,
},
[]byte{},

View File

@ -4,10 +4,14 @@ import (
"bytes"
"testing"
"github.com/number571/go-peer/pkg/crypto/hashing"
"github.com/number571/go-peer/pkg/encoding"
testutils "github.com/number571/go-peer/test/_data"
)
const (
tcHash = "57daf58ec9ea7be6dbcb8a67aea76bdcfa32db40a7a3cae3d90bc977dc293599"
)
func TestEntropy(t *testing.T) {
var (
msg = []byte("hello, world!")
@ -15,8 +19,7 @@ func TestEntropy(t *testing.T) {
)
hash := NewEntropyBooster(testutils.TCWorkSize, salt).BoostEntropy(msg)
if bytes.Equal(hash, hashing.NewSHA256Hasher(msg).ToBytes()) {
if encoding.HexEncode(hash) != tcHash {
t.Error("hash is correct?")
return
}