Golint cleanup utils/crypto/sha*,cpu,md5

master
Harshavardhana 10 years ago
parent 66e31445ff
commit 256faddab5
  1. 7
      pkg/utils/checksum/crc32c/crc32c_linux.go
  2. 4
      pkg/utils/cpu/cpu_test.go
  3. 2
      pkg/utils/crypto/md5/md5.go
  4. 4
      pkg/utils/crypto/sha1/sha1.go
  5. 4
      pkg/utils/crypto/sha256/sha256.go
  6. 6
      pkg/utils/crypto/sha512/sha512.go
  7. 11
      pkg/utils/crypto/x509/generator.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

@ -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) {

@ -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

@ -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

@ -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

@ -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)

@ -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

Loading…
Cancel
Save