From b1c6a5f56a99f263d726428a06f151ecc51cca0a Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 26 Nov 2017 14:01:46 +1300 Subject: [PATCH] adc: working PID/CID login --HG-- branch : adc --- AdcProtocol.go | 17 ++--------------- tth.go | 6 ++++++ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/AdcProtocol.go b/AdcProtocol.go index 7deef6c..6e661c1 100644 --- a/AdcProtocol.go +++ b/AdcProtocol.go @@ -60,32 +60,18 @@ func NewAdcProtocol(hc *HubConnection) Protocol { func (this *AdcProtocol) pid2cid(pid_base32 string) (string, error) { - /* - Generate random data and store it in PID_raw, then; - PID = Base32( PID_raw ) - CID = Base32( Hash( PID_raw ) ) - - For GPA/PAS, assuming that '12345' is the random data supplied in GPA, then; - PAS = Base32( Hash( password + '12345' ) ) - */ - pid_raw, err := base32.StdEncoding.DecodeString(pid_base32 + "=") if err != nil { return "", err } - cid_raw, err := TTH(string(pid_raw)) - if err != nil { - return "", err - } - + cid_raw := Tiger(string(pid_raw)) cid_base32 := Base32(cid_raw) return cid_base32, nil } func (this *AdcProtocol) ProcessCommand(msg string) { - this.hc.processEvent(HubEvent{EventType: EVENT_DEBUG_MESSAGE, Message: msg}) if len(msg) == 0 { return @@ -168,6 +154,7 @@ func (this *AdcProtocol) ProcessCommand(msg string) { // default: + this.hc.processEvent(HubEvent{EventType: EVENT_DEBUG_MESSAGE, Message: msg}) this.malformed(parts) } } diff --git a/tth.go b/tth.go index fe2c175..612bef4 100644 --- a/tth.go +++ b/tth.go @@ -33,3 +33,9 @@ func TTH(input string) ([]byte, error) { leafHash.Write([]byte("\x00" + input)) return leafHash.Sum(nil), nil } + +func Tiger(input string) []byte { + leafHash := tiger.New() + leafHash.Write([]byte(input)) + return leafHash.Sum(nil) +}