From 256faddab548c8a7479108f0fdc2de1b61c85ec3 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 5 Mar 2015 20:16:47 -0800 Subject: [PATCH] Golint cleanup utils/crypto/sha*,cpu,md5 --- pkg/utils/checksum/crc32c/crc32c_linux.go | 7 ++++--- pkg/utils/cpu/cpu_test.go | 4 +--- pkg/utils/crypto/md5/md5.go | 2 +- pkg/utils/crypto/sha1/sha1.go | 4 ++-- pkg/utils/crypto/sha256/sha256.go | 4 ++-- pkg/utils/crypto/sha512/sha512.go | 6 +++--- pkg/utils/crypto/x509/generator.go | 11 ++++++----- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/pkg/utils/checksum/crc32c/crc32c_linux.go b/pkg/utils/checksum/crc32c/crc32c_linux.go index fc234bd98..3d8b8885c 100644 --- a/pkg/utils/checksum/crc32c/crc32c_linux.go +++ b/pkg/utils/checksum/crc32c/crc32c_linux.go @@ -5,6 +5,7 @@ // Package crc32 implements the 32-bit cyclic redundancy check, or CRC-32, // checksum. See http://en.wikipedia.org/wiki/Cyclic_redundancy_check for // information. + package crc32c import ( @@ -38,7 +39,7 @@ func (d *digest) Sum(in []byte) []byte { return append(in, byte(s>>24), byte(s>>16), byte(s>>8), byte(s)) } -// Return current crc in digest object +// Sum32 - return current crc in digest object func (d *digest) Sum32() uint32 { return d.crc } // Reset default crc @@ -57,7 +58,7 @@ func (d *digest) Write(p []byte) (n int, err error) { /// Convenience functions -// Single caller crc helper +// Sum32 - single caller crc helper func Sum32(data []byte) uint32 { crc32 := New() crc32.Reset() @@ -65,7 +66,7 @@ func Sum32(data []byte) uint32 { return crc32.Sum32() } -// Low memory footprint io.Reader based crc helper +// Sum - low memory footprint io.Reader based crc helper func Sum(reader io.Reader) (uint32, error) { h := New() var err error diff --git a/pkg/utils/cpu/cpu_test.go b/pkg/utils/cpu/cpu_test.go index 3fbd7a89d..3c0be597a 100644 --- a/pkg/utils/cpu/cpu_test.go +++ b/pkg/utils/cpu/cpu_test.go @@ -43,10 +43,8 @@ func hasCPUFeatureFromOS(feature string) (bool, error) { return true, nil } return false, nil - } else { - // TODO find new way to test cpu flags on windows - return false, errors.New("Not Implemented on this platform") } + return false, errors.New("Not Implemented on this platform") } func (s *MySuite) TestHasSSE41(c *C) { diff --git a/pkg/utils/crypto/md5/md5.go b/pkg/utils/crypto/md5/md5.go index 883d98847..ad0e44c32 100644 --- a/pkg/utils/crypto/md5/md5.go +++ b/pkg/utils/crypto/md5/md5.go @@ -21,7 +21,7 @@ import ( "io" ) -// Low memory footprint io.Reader based md5sum helper +// Sum - low memory footprint io.Reader based md5sum helper func Sum(reader io.Reader) ([]byte, error) { hash := md5.New() var err error diff --git a/pkg/utils/crypto/sha1/sha1.go b/pkg/utils/crypto/sha1/sha1.go index af6a15527..f0ef819b9 100644 --- a/pkg/utils/crypto/sha1/sha1.go +++ b/pkg/utils/crypto/sha1/sha1.go @@ -143,7 +143,7 @@ func (d *digest) checkSum() [Size]byte { /// Convenience functions -// Single caller sha1 helper +// Sum1 - single caller sha1 helper func Sum1(data []byte) [Size]byte { var d digest d.Reset() @@ -151,7 +151,7 @@ func Sum1(data []byte) [Size]byte { return d.checkSum() } -// io.Reader based streaming sha1 helper +// Sum - io.Reader based streaming sha1 helper func Sum(reader io.Reader) ([]byte, error) { h := New() var err error diff --git a/pkg/utils/crypto/sha256/sha256.go b/pkg/utils/crypto/sha256/sha256.go index 669ab79d8..95489ddb6 100644 --- a/pkg/utils/crypto/sha256/sha256.go +++ b/pkg/utils/crypto/sha256/sha256.go @@ -151,7 +151,7 @@ func (d *digest) checkSum() [Size]byte { /// Convenience functions -// Single caller sha256 helper +// Sum256 - single caller sha256 helper func Sum256(data []byte) [Size]byte { var d digest d.Reset() @@ -159,7 +159,7 @@ func Sum256(data []byte) [Size]byte { return d.checkSum() } -// io.Reader based streaming sha256 helper +// Sum - io.Reader based streaming sha256 helper func Sum(reader io.Reader) ([]byte, error) { h := New() var err error diff --git a/pkg/utils/crypto/sha512/sha512.go b/pkg/utils/crypto/sha512/sha512.go index 7b1810a9d..b2fd58bad 100644 --- a/pkg/utils/crypto/sha512/sha512.go +++ b/pkg/utils/crypto/sha512/sha512.go @@ -157,7 +157,7 @@ func (d *digest) checkSum() [Size]byte { /// Convenience functions -// Single caller sha512 helper +// Sum512 - single caller sha512 helper func Sum512(data []byte) [Size]byte { var d digest d.Reset() @@ -165,7 +165,7 @@ func Sum512(data []byte) [Size]byte { return d.checkSum() } -// io.Reader based streaming sha512 helper +// Sum - io.Reader based streaming sha512 helper func Sum(reader io.Reader) ([]byte, error) { h := New() var err error @@ -182,7 +182,7 @@ func Sum(reader io.Reader) ([]byte, error) { return h.Sum(nil), nil } -// Similar to 'Sum()' but returns a [Size]byte +// SumStream - similar to 'Sum()' but returns a [Size]byte func SumStream(reader io.Reader) ([Size]byte, error) { var returnValue [Size]byte sumSlice, err := Sum(reader) diff --git a/pkg/utils/crypto/x509/generator.go b/pkg/utils/crypto/x509/generator.go index 650135b3f..5a1ba581c 100644 --- a/pkg/utils/crypto/x509/generator.go +++ b/pkg/utils/crypto/x509/generator.go @@ -31,13 +31,14 @@ import ( "time" ) -// Based on http://golang.org/src/crypto/tls/generate_cert.go +// Certificates - based on http://golang.org/src/crypto/tls/generate_cert.go type Certificates struct { CertPemBlock []byte CertKeyBlock []byte } -type X509Params struct { +// Params - various x.509 parameters +type Params struct { Hostname string IsCA bool EcdsaCurve string @@ -72,9 +73,9 @@ func pemBlockForKey(priv interface{}) *pem.Block { } } -// Generate certificates using custom parameters -func (tls *Certificates) GenerateCertificates(params X509Params) error { - var rsaBits int = 2048 +// GenerateCertificates - generate certificates using custom x.509 parameters +func (tls *Certificates) GenerateCertificates(params Params) error { + var rsaBits = 2048 var priv interface{} var err error