mirror of
https://github.com/number571/go-peer.git
synced 2026-09-14 11:05:42 +05:00
update
This commit is contained in:
parent
f5f51e38b7
commit
6ee343c456
@ -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
|
||||
|
||||
<!-- ... -->
|
||||
|
||||
|
||||
19
cmd/tools/pmanager/README.md
Normal file
19
cmd/tools/pmanager/README.md
Normal 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=
|
||||
```
|
||||
44
cmd/tools/pmanager/main.go
Normal file
44
cmd/tools/pmanager/main.go
Normal 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
|
||||
}
|
||||
5
cmd/tools/pmanager/pmanager_test.go
Normal file
5
cmd/tools/pmanager/pmanager_test.go
Normal file
@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestNothing(t *testing.T) {}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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{},
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user