Skip to content

Commit

Permalink
gofmt -s
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesruan committed Aug 30, 2016
1 parent 904953c commit 5fd4f9c
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 34 deletions.
4 changes: 2 additions & 2 deletions aead_chacha20poly1305.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (b Bytes) AEADCPEncrypt(ad Bytes, n AEADCPNonce, k AEADCPKey) (c Bytes) {
checkTypedSize(&n, "public nonce")
checkTypedSize(&k, "secret key")

c = make([]byte, b.Length() + cryptoAEADChaCha20Poly1305IETFABytes)
c = make([]byte, b.Length()+cryptoAEADChaCha20Poly1305IETFABytes)
var outlen C.ulonglong

if int(C.crypto_aead_chacha20poly1305_ietf_encrypt(
Expand All @@ -73,7 +73,7 @@ func (b Bytes) AEADCPEncrypt(ad Bytes, n AEADCPNonce, k AEADCPKey) (c Bytes) {
func (b Bytes) AEADCPDecrypt(ad Bytes, n AEADCPNonce, k AEADCPKey) (m Bytes, err error) {
checkTypedSize(&n, "public nonce")
checkTypedSize(&k, "secret key")
m = make([]byte, b.Length() - cryptoAEADChaCha20Poly1305IETFABytes)
m = make([]byte, b.Length()-cryptoAEADChaCha20Poly1305IETFABytes)
var outlen C.ulonglong

if int(C.crypto_aead_chacha20poly1305_ietf_decrypt(
Expand Down
5 changes: 2 additions & 3 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ package sodium
import "C"

var (
cryptoAuthBytes = int(C.crypto_auth_bytes())
cryptoAuthKeyBytes = int(C.crypto_auth_keybytes())
cryptoAuthBytes = int(C.crypto_auth_bytes())
cryptoAuthKeyBytes = int(C.crypto_auth_keybytes())
)

type MACKey struct {
Expand Down Expand Up @@ -60,4 +60,3 @@ func (b Bytes) AuthVerify(mac MAC, key MACKey) (err error) {

return
}

1 change: 0 additions & 1 deletion box.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,3 @@ func (b Bytes) BoxOpenDetached(mac BoxMAC, n BoxNonce, pk BoxPublicKey, sk BoxSe

return
}

26 changes: 13 additions & 13 deletions generichash.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ var (
//The Hash's and key's size can be any between 16 bytes (128 bits) to
// 64 bytes (512 bits) based on different application.
type GenericHash struct {
size int
size int
blocksize int
key *GenericHashKey
sum []byte
state *C.struct_crypto_generichash_blake2b_state
key *GenericHashKey
sum []byte
state *C.struct_crypto_generichash_blake2b_state
}

type GenericHashKey struct {
Expand All @@ -52,11 +52,11 @@ func NewGenericHash(outlen int) GenericHash {
checkSizeInRange(outlen, cryptoGenericHashBytesMin, cryptoGenericHashBytesMax, "out")
state := new(C.struct_crypto_generichash_blake2b_state)
hash := GenericHash{
size: outlen,
size: outlen,
blocksize: 128,
key: nil,
sum: nil,
state: state,
key: nil,
sum: nil,
state: state,
}
hash.Reset()
return hash
Expand All @@ -68,11 +68,11 @@ func NewGenericHashKeyed(outlen int, key GenericHashKey) GenericHash {
state := new(C.struct_crypto_generichash_blake2b_state)
checkTypedSize(&key, "generic hash key")
hash := GenericHash{
size: outlen,
size: outlen,
blocksize: 128,
key: &key,
sum: nil,
state: state,
key: &key,
sum: nil,
state: state,
}
hash.Reset()
return hash
Expand Down Expand Up @@ -114,7 +114,7 @@ func (g *GenericHash) Reset() {
//Use GenericHash.Write([]byte) to hash chunks of message.
//
//Implements crypto/hash.Hash
func (g *GenericHash) Write(p []byte)(n int, err error) {
func (g *GenericHash) Write(p []byte) (n int, err error) {
if g.sum != nil {
return 0, fmt.Errorf("hash finalized")
}
Expand Down
13 changes: 6 additions & 7 deletions pwhash.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ package sodium
import "C"

var (
cryptoPWHashSaltBytes = int(C.crypto_pwhash_saltbytes())
cryptoPWHashStrBytes = int(C.crypto_pwhash_strbytes())
cryptoPWHashSaltBytes = int(C.crypto_pwhash_saltbytes())
cryptoPWHashStrBytes = int(C.crypto_pwhash_strbytes())
CryptoPWHashOpsLimitInteractive = int(C.crypto_pwhash_opslimit_interactive())
CryptoPWHashMemLimitInteractive = int(C.crypto_pwhash_memlimit_interactive())
CryptoPWHashOpsLimitModerate = int(C.crypto_pwhash_opslimit_moderate())
CryptoPWHashMemLimitModerate = int(C.crypto_pwhash_memlimit_moderate())
CryptoPWHashOpsLimitSensitive = int(C.crypto_pwhash_opslimit_sensitive())
CryptoPWHashMemLimitSensitive = int(C.crypto_pwhash_memlimit_sensitive())

CryptoPWHashOpsLimitModerate = int(C.crypto_pwhash_opslimit_moderate())
CryptoPWHashMemLimitModerate = int(C.crypto_pwhash_memlimit_moderate())
CryptoPWHashOpsLimitSensitive = int(C.crypto_pwhash_opslimit_sensitive())
CryptoPWHashMemLimitSensitive = int(C.crypto_pwhash_memlimit_sensitive())
)

type PWHashSalt struct {
Expand Down
2 changes: 0 additions & 2 deletions scalarmult.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func CryptoScalarmultBase(n Scalar) (q Scalar) {
return Scalar{qb}
}


//CryptoScalarmult calculates common key 'q' from private key 'n' and
//other's public key 'p'
func CryptoScalarmult(n, p Scalar) (q ScalarMult) {
Expand All @@ -59,4 +58,3 @@ func CryptoScalarmult(n, p Scalar) (q ScalarMult) {

return ScalarMult{qb}
}

6 changes: 3 additions & 3 deletions secretbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ package sodium
import "C"

var (
cryptoSecretBoxKeyBytes = int(C.crypto_secretbox_keybytes())
cryptoSecretBoxNonceBytes = int(C.crypto_secretbox_noncebytes())
cryptoSecretBoxMacBytes = int(C.crypto_secretbox_macbytes())
cryptoSecretBoxKeyBytes = int(C.crypto_secretbox_keybytes())
cryptoSecretBoxNonceBytes = int(C.crypto_secretbox_noncebytes())
cryptoSecretBoxMacBytes = int(C.crypto_secretbox_macbytes())
)

type SecretBoxKey struct {
Expand Down
2 changes: 2 additions & 0 deletions shorthash.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ var (
type ShortHash struct {
Bytes
}

func (s ShortHash) Size() int {
return cryptoShortHashBytes
}

type ShortHashKey struct {
Bytes
}

func (s ShortHashKey) Size() int {
return cryptoShortHashKeyBytes
}
Expand Down
4 changes: 2 additions & 2 deletions sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func MakeSignKP() SignKP {
panic("see libsodium")
}

return SignKP {
return SignKP{
SignPublicKey{pkb},
SignSecretKey{skb},
}
Expand All @@ -48,7 +48,7 @@ func SeedSignKP(seed SignSeed) SignKP {
panic("see libsodium")
}

return SignKP {
return SignKP{
SignPublicKey{pkb},
SignSecretKey{skb},
}
Expand Down
2 changes: 1 addition & 1 deletion sodium.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (b *Bytes) setBytes(s Bytes) {
//Nonce is used to protect secret key. It is important to not use the same nonce for a given key.
type Nonce interface {
Typed
Next() //Next unused nonce
Next() //Next unused nonce
}

//Randomize fill the Typed with random bytes.
Expand Down

0 comments on commit 5fd4f9c

Please sign in to comment.