]> Cypherpunks.ru repositories - govpn.git/blobdiff - src/cypherpunks.ru/govpn/verifier.go
golint fixes
[govpn.git] / src / cypherpunks.ru / govpn / verifier.go
index 832fafe2dacf4981ee3ffc39e20aa5cde77d3a68..1e3fc61fbd9e42c1dc16389aff0e06555bac8d43 100644 (file)
@@ -1,6 +1,6 @@
 /*
 GoVPN -- simple secure free software virtual private network daemon
-Copyright (C) 2014-2016 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2014-2017 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -36,23 +36,27 @@ import (
 )
 
 const (
+       // DefaultS default Balloon space cost
        DefaultS = 1 << 20 / 32
+       // DefaultT default Balloon time cost
        DefaultT = 1 << 4
+       // DefaultP default Balloon number of job
        DefaultP = 2
 )
 
+// Verifier is used to verify a peer
 type Verifier struct {
        S   int
        T   int
        P   int
-       Id  *PeerId
+       ID  *PeerID
        Pub *[ed25519.PublicKeySize]byte
 }
 
-// Generate new verifier for given peer, with specified password and
+// VerifierNew generate new verifier for given peer, with specified password and
 // hashing parameters.
-func VerifierNew(s, t, p int, id *PeerId) *Verifier {
-       return &Verifier{S: s, T: t, P: p, Id: id}
+func VerifierNew(s, t, p int, id *PeerID) *Verifier {
+       return &Verifier{S: s, T: t, P: p, ID: id}
 }
 
 func blake2bKeyless() hash.Hash {
@@ -63,10 +67,10 @@ func blake2bKeyless() hash.Hash {
        return h
 }
 
-// Apply the password: create Ed25519 keypair based on it, save public
+// PasswordApply apply the password: create Ed25519 keypair based on it, save public
 // key in verifier.
 func (v *Verifier) PasswordApply(password string) *[ed25519.PrivateKeySize]byte {
-       r := balloon.H(blake2bKeyless, []byte(password), v.Id[:], v.S, v.T, v.P)
+       r := balloon.H(blake2bKeyless, []byte(password), v.ID[:], v.S, v.T, v.P)
        defer SliceZero(r)
        src := bytes.NewBuffer(r)
        pub, prv, err := ed25519.GenerateKey(src)
@@ -77,7 +81,7 @@ func (v *Verifier) PasswordApply(password string) *[ed25519.PrivateKeySize]byte
        return prv
 }
 
-// Parse either short or long verifier form.
+// VerifierFromString parse either short or long verifier form.
 func VerifierFromString(input string) (*Verifier, error) {
        ss := strings.Split(input, "$")
        if len(ss) < 4 || ss[1] != "balloon" {
@@ -95,8 +99,8 @@ func VerifierFromString(input string) (*Verifier, error) {
        v := Verifier{S: s, T: t, P: p}
        id := new([IDSize]byte)
        copy(id[:], salt)
-       pid := PeerId(*id)
-       v.Id = &pid
+       pid := PeerID(*id)
+       v.ID = &pid
        if len(ss) == 5 {
                pub, err := base64.RawStdEncoding.DecodeString(ss[4])
                if err != nil {
@@ -108,16 +112,16 @@ func VerifierFromString(input string) (*Verifier, error) {
        return &v, nil
 }
 
-// Short verifier string form -- it is useful for the client.
+// ShortForm short verifier string form -- it is useful for the client.
 // Does not include public key.
 func (v *Verifier) ShortForm() string {
        return fmt.Sprintf(
                "$balloon$s=%d,t=%d,p=%d$%s",
-               v.S, v.T, v.P, base64.RawStdEncoding.EncodeToString(v.Id[:]),
+               v.S, v.T, v.P, base64.RawStdEncoding.EncodeToString(v.ID[:]),
        )
 }
 
-// Long verifier string form -- it is useful for the server.
+// LongForm long verifier string form -- it is useful for the server.
 // Includes public key.
 func (v *Verifier) LongForm() string {
        return fmt.Sprintf(
@@ -126,7 +130,7 @@ func (v *Verifier) LongForm() string {
        )
 }
 
-// Read the key either from text file (if path is specified), or
+// KeyRead read the key either from text file (if path is specified), or
 // from the terminal.
 func KeyRead(path string) (string, error) {
        var p []byte