format with go fmt

This commit is contained in:
Jeff Becker
2016-01-29 07:22:31 -05:00
parent f2c6e01206
commit 1e471e4e00
38 changed files with 694 additions and 729 deletions

View File

@@ -1,7 +1,7 @@
package crypto
import (
"crypto/md5"
"crypto/md5"
)
const IPAD = byte(0x36)
@@ -11,33 +11,33 @@ type HMACKey [32]byte
type HMACDigest [16]byte
func (hk HMACKey) xor(p byte) (i []byte) {
i = make([]byte, 64)
for idx, b := range hk {
i[idx] = b ^ p
}
c := 32
for c > 0 {
c--
i[c+32] = p
}
return
i = make([]byte, 64)
for idx, b := range hk {
i[idx] = b ^ p
}
c := 32
for c > 0 {
c--
i[c+32] = p
}
return
}
//
// do i2p hmac
// do i2p hmac
//
func I2PHMAC(data []byte, k HMACKey) (d HMACDigest) {
buff := make([]byte, 64+len(data))
ip := k.xor(IPAD)
copy(buff, ip)
copy(buff[64:], data)
h := md5.Sum(buff)
buff = make([]byte, 96)
copy(buff, k.xor(OPAD))
copy(buff[64:], h[:])
// go zeros slices so we do not have to zero
d = md5.Sum(buff)
return
buff := make([]byte, 64+len(data))
ip := k.xor(IPAD)
copy(buff, ip)
copy(buff[64:], data)
h := md5.Sum(buff)
buff = make([]byte, 96)
copy(buff, k.xor(OPAD))
copy(buff[64:], h[:])
// go zeros slices so we do not have to zero
d = md5.Sum(buff)
return
}