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
type Buffer struct {
ptr unsafe.Pointer;
length C.int;
size C.size_t;
ptr unsafe.Pointer
length C.int
size C.size_t
}
// wrapper arround nacl.malloc

View File

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

View File

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

View File

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

View File

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

View File

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