diff --git a/CHANGELOG.md b/CHANGELOG.md index 7297a139..30476a52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/cmd/tools/pmanager/README.md b/cmd/tools/pmanager/README.md new file mode 100644 index 00000000..2e771c79 --- /dev/null +++ b/cmd/tools/pmanager/README.md @@ -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= +``` diff --git a/cmd/tools/pmanager/main.go b/cmd/tools/pmanager/main.go new file mode 100644 index 00000000..924a2de9 --- /dev/null +++ b/cmd/tools/pmanager/main.go @@ -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 +} diff --git a/cmd/tools/pmanager/pmanager_test.go b/cmd/tools/pmanager/pmanager_test.go new file mode 100644 index 00000000..f03d9f65 --- /dev/null +++ b/cmd/tools/pmanager/pmanager_test.go @@ -0,0 +1,5 @@ +package main + +import "testing" + +func TestNothing(t *testing.T) {} diff --git a/docs/abstract_anonymous_networks.docx b/docs/abstract_anonymous_networks.docx index 4c026c9b..651aae5e 100644 Binary files a/docs/abstract_anonymous_networks.docx and b/docs/abstract_anonymous_networks.docx differ diff --git a/docs/abstract_anonymous_networks.pdf b/docs/abstract_anonymous_networks.pdf index 2a724e2f..07889b6f 100644 Binary files a/docs/abstract_anonymous_networks.pdf and b/docs/abstract_anonymous_networks.pdf differ diff --git a/examples/_cmd/anon_messenger/_docker/default/_mounted_node1/hlm.stg b/examples/_cmd/anon_messenger/_docker/default/_mounted_node1/hlm.stg index 6ad69ccf..e6f33219 100644 Binary files a/examples/_cmd/anon_messenger/_docker/default/_mounted_node1/hlm.stg and b/examples/_cmd/anon_messenger/_docker/default/_mounted_node1/hlm.stg differ diff --git a/examples/_cmd/anon_messenger/_docker/default/_mounted_node2/hlm.stg b/examples/_cmd/anon_messenger/_docker/default/_mounted_node2/hlm.stg index c93ea997..615b95c8 100644 Binary files a/examples/_cmd/anon_messenger/_docker/default/_mounted_node2/hlm.stg and b/examples/_cmd/anon_messenger/_docker/default/_mounted_node2/hlm.stg differ diff --git a/examples/_cmd/anon_messenger/default/node1_hlm/hlm.stg b/examples/_cmd/anon_messenger/default/node1_hlm/hlm.stg index de3f9a11..e6f33219 100644 Binary files a/examples/_cmd/anon_messenger/default/node1_hlm/hlm.stg and b/examples/_cmd/anon_messenger/default/node1_hlm/hlm.stg differ diff --git a/examples/_cmd/anon_messenger/default/node2_hlm/hlm.stg b/examples/_cmd/anon_messenger/default/node2_hlm/hlm.stg index 3574afed..615b95c8 100644 Binary files a/examples/_cmd/anon_messenger/default/node2_hlm/hlm.stg and b/examples/_cmd/anon_messenger/default/node2_hlm/hlm.stg differ diff --git a/examples/_cmd/anon_messenger/secret_channel/node1_hlm/hlm.stg b/examples/_cmd/anon_messenger/secret_channel/node1_hlm/hlm.stg index 1fb10fbe..e6f33219 100644 Binary files a/examples/_cmd/anon_messenger/secret_channel/node1_hlm/hlm.stg and b/examples/_cmd/anon_messenger/secret_channel/node1_hlm/hlm.stg differ diff --git a/examples/_cmd/anon_messenger/secret_channel/node2_hlm/hlm.stg b/examples/_cmd/anon_messenger/secret_channel/node2_hlm/hlm.stg index b4a823e7..615b95c8 100644 Binary files a/examples/_cmd/anon_messenger/secret_channel/node2_hlm/hlm.stg and b/examples/_cmd/anon_messenger/secret_channel/node2_hlm/hlm.stg differ diff --git a/pkg/crypto/entropy/entropy.go b/pkg/crypto/entropy/entropy.go index bd995f35..c04b3ae1 100644 --- a/pkg/crypto/entropy/entropy.go +++ b/pkg/crypto/entropy/entropy.go @@ -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{}, diff --git a/pkg/crypto/entropy/entropy_test.go b/pkg/crypto/entropy/entropy_test.go index 4518abec..f458211e 100644 --- a/pkg/crypto/entropy/entropy_test.go +++ b/pkg/crypto/entropy/entropy_test.go @@ -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 }