Archived
1
0
This commit is contained in:
Jeff Becker 2017-08-25 10:43:29 -04:00
parent cc5d94ee5f
commit d61228215e
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
8 changed files with 528 additions and 538 deletions

View File

@ -17,10 +17,9 @@ import (
// wrapper arround malloc/free // wrapper arround malloc/free
type Buffer struct { type Buffer struct {
ptr unsafe.Pointer; ptr unsafe.Pointer
length C.int; length C.int
size C.size_t; size C.size_t
} }
// wrapper arround nacl.malloc // wrapper arround nacl.malloc

View File

@ -78,7 +78,7 @@ func GetSignPubkey(sk []byte) ([]byte, error) {
func LoadSignKey(seed []byte) *KeyPair { func LoadSignKey(seed []byte) *KeyPair {
seed_len := C.crypto_sign_seedbytes() seed_len := C.crypto_sign_seedbytes()
if C.size_t(len(seed)) != seed_len { if C.size_t(len(seed)) != seed_len {
return nil panic(fmt.Sprintf("Bad seed length %d bytes", len(seed)))
} }
seedbuff := NewBuffer(seed) seedbuff := NewBuffer(seed)
defer seedbuff.Free() defer seedbuff.Free()
@ -109,7 +109,6 @@ func GenBoxKeypair() *KeyPair {
return nil return nil
} }
// get public key from secret key // get public key from secret key
func GetBoxPubkey(sk []byte) []byte { func GetBoxPubkey(sk []byte) []byte {
sk_len := C.crypto_box_seedbytes() sk_len := C.crypto_box_seedbytes()
@ -170,7 +169,6 @@ func CryptoSignPublicLen() int {
return int(C.crypto_sign_publickeybytes()) return int(C.crypto_sign_publickeybytes())
} }
func CryptoSignSecretLen() int { func CryptoSignSecretLen() int {
return int(C.crypto_sign_secretkeybytes()) return int(C.crypto_sign_secretkeybytes())
} }

View File

@ -35,7 +35,6 @@ func CryptoSignPrivKeySize() int {
return int(C.crypto_sign_secretkeybytes()) return int(C.crypto_sign_secretkeybytes())
} }
// initialize sodium // initialize sodium
func init() { func init() {
status := C.sodium_init() status := C.sodium_init()

View File

@ -6,7 +6,6 @@ package nacl
// #include <sodium.h> // #include <sodium.h>
import "C" import "C"
// sign data detached with secret key sk // sign data detached with secret key sk
func CryptoSignDetached(msg, sk []byte) []byte { func CryptoSignDetached(msg, sk []byte) []byte {
msgbuff := NewBuffer(msg) msgbuff := NewBuffer(msg)
@ -31,7 +30,6 @@ func CryptoSignDetached(msg, sk []byte) []byte {
return nil return nil
} }
// sign data with secret key sk // sign data with secret key sk
// return detached sig // return detached sig
// this uses crypto_sign instead pf crypto_sign_detached // this uses crypto_sign instead pf crypto_sign_detached

View File

@ -10,7 +10,6 @@ import (
// TOY encrypted authenticated stream protocol like tls // TOY encrypted authenticated stream protocol like tls
var BadHandshake = errors.New("Bad handshake") var BadHandshake = errors.New("Bad handshake")
var ShortWrite = errors.New("short write") var ShortWrite = errors.New("short write")
var ShortRead = errors.New("short read") var ShortRead = errors.New("short read")
@ -211,7 +210,6 @@ func (cs *CryptoStream) Handshake() (err error) {
return return
} }
// create a client // create a client
func Client(stream io.ReadWriteCloser, local_sk, remote_pk []byte) (c *CryptoStream) { func Client(stream io.ReadWriteCloser, local_sk, remote_pk []byte) (c *CryptoStream) {
c = &CryptoStream{ c = &CryptoStream{
@ -227,7 +225,6 @@ func Client(stream io.ReadWriteCloser, local_sk, remote_pk []byte) (c *CryptoStr
return c return c
} }
type CryptoConn struct { type CryptoConn struct {
stream *CryptoStream stream *CryptoStream
conn net.Conn conn net.Conn

View File

@ -6,7 +6,6 @@ package nacl
// #include <sodium.h> // #include <sodium.h>
import "C" import "C"
// verify a fucky detached sig // verify a fucky detached sig
func CryptoVerifyFucky(msg, sig, pk []byte) bool { func CryptoVerifyFucky(msg, sig, pk []byte) bool {
var smsg []byte var smsg []byte