This commit is contained in:
number571 2024-05-11 03:48:24 +07:00
parent f7d9cae09d
commit 3a034aa361
6 changed files with 19029 additions and 19044 deletions

View File

@ -8,7 +8,7 @@ If a problem is found and such a problem becomes critical, a new version of the
Most of the project updates are related to patch versions. The minor version, in turn, is updated solely based on considerations of stability of all functions during manual testing. Thus, patch versions are directly related to fixing problems and creating new functionality, while minor versions are related to standardizing everything created in patch versions. Most of the project updates are related to patch versions. The minor version, in turn, is updated solely based on considerations of stability of all functions during manual testing. Thus, patch versions are directly related to fixing problems and creating new functionality, while minor versions are related to standardizing everything created in patch versions.
You can find out more about all the changes made during the correction or update of the project in the file CHANGELOG.md. You can find out more about all the changes made during the correction or update of the project in the file [CHANGELOG.md](https://github.com/number571/go-peer/blob/master/CHANGELOG.md).
## Reporting a Vulnerability ## Reporting a Vulnerability

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
```bash ```bash
usage: usage:
./main [service-name] [login] ./main -salt=[service-name] -work=[diff-size]
stdin: stdin:
[master-key]EOL [master-key]EOL
``` ```
@ -14,12 +14,12 @@ EOL - End of Line (Enter)
## Example ## Example
```bash ```bash
$ go run . service-name login $ go run . -salt="service-name" -work=24
> master-key master-key
62ZD5+xzT+eQkqFjNJqLryOsLSxSUzfCMEHlt6Y4dEo= EvCqIyPVq9ydjspox6GqN63ggT0xrUfNFnFgwAy1odQ=
``` ```
```bash ```bash
$ echo "master-key" | go run . service-name login $ echo "master-key" | go run . -salt="service-name" -work=24
> 62ZD5+xzT+eQkqFjNJqLryOsLSxSUzfCMEHlt6Y4dEo= EvCqIyPVq9ydjspox6GqN63ggT0xrUfNFnFgwAy1odQ=
``` ```

View File

@ -3,40 +3,25 @@ package main
import ( import (
"bufio" "bufio"
"encoding/base64" "encoding/base64"
"flag"
"fmt" "fmt"
"os" "os"
"github.com/number571/go-peer/pkg/crypto/hashing"
"github.com/number571/go-peer/pkg/crypto/keybuilder" "github.com/number571/go-peer/pkg/crypto/keybuilder"
) )
const (
cWorkSize = 22
)
func main() { func main() {
if len(os.Args) != 3 { saltParam := flag.String("salt", "_salt_", "default salt value")
panic(fmt.Sprintf( workParam := flag.Uint("work", 24, "default work value")
"usage:\n\t%s\nstdin:\n\t%s\n\n", flag.Parse()
"./main [service] [login]",
"[master-key]EOF",
))
}
var ( keyBuilder := keybuilder.NewKeyBuilder(1<<(*workParam), []byte(*saltParam))
service = []byte(os.Args[1]) gotPassword := keyBuilder.Build(readUntilEOL())
login = []byte(os.Args[2])
)
keyBuilder := keybuilder.NewKeyBuilder(1<<cWorkSize, login) fmt.Println(base64.URLEncoding.EncodeToString(gotPassword))
extendedKey := keyBuilder.Build(readUntilEOF("> "))
passBytes := hashing.NewHMACSHA256Hasher(extendedKey, service).ToBytes()
fmt.Println(base64.StdEncoding.EncodeToString(passBytes))
} }
func readUntilEOF(prefix string) string { func readUntilEOL() string {
fmt.Print(prefix)
res, _, err := bufio.NewReader(os.Stdin).ReadLine() res, _, err := bufio.NewReader(os.Stdin).ReadLine()
if err != nil { if err != nil {
panic(err) panic(err)

View File

@ -187,7 +187,7 @@ func (p *sNode) GetConnections() map[string]conn.IConn {
p.fMutex.RLock() p.fMutex.RLock()
defer p.fMutex.RUnlock() defer p.fMutex.RUnlock()
var mapping = make(map[string]conn.IConn, len(p.fConnections)) mapping := make(map[string]conn.IConn, len(p.fConnections))
for addr, conn := range p.fConnections { for addr, conn := range p.fConnections {
mapping[addr] = conn mapping[addr] = conn
} }

File diff suppressed because it is too large Load Diff