diff --git a/go/certificate.go b/go/certificate.go index 0c4464da..b37f8053 100644 --- a/go/certificate.go +++ b/go/certificate.go @@ -1,2 +1,20 @@ /* +build cgo */ package gmssl + +/* +#include +#include +*/ +import "C" + +import ( + "errors" +) + +func GetAttributesFromCertificate(cert string) (map[string]string, error) { + return nil, errors.New("Not implemented") +} + +func GetPublicKeyFromCertificate(cert string) (*PublicKey, error) { + return nil, errors.New("Not implemented") +} diff --git a/go/engine.go b/go/engine.go index 0c4464da..1cf8f8bc 100644 --- a/go/engine.go +++ b/go/engine.go @@ -1,2 +1,39 @@ /* +build cgo */ package gmssl + +/* +#include +*/ +import "C" + +import ( + "errors" +) + +func GetEngineNames() []string { + return []string{"skf", "sdf"} +} + +type Engine struct { + engine *C.ENGINE +} + +func OpenEngine(name string, args map[string]string) (*Engine, error) { + return nil, errors.New("Not implemented") +} + +func (eng *Engine) ExecuteCommand(cmd_name string, arg string, optinal bool) (string, error) { + return "", errors.New("Not implemented") +} + +func (eng *Engine) LoadPrivateKey(key_id string, args map[string]string) (*PrivateKey, error) { + return nil, errors.New("Not implemented") +} + +func (eng *Engine) LoadPublicKey(key_id string, args map[string]string) (*PublicKey, error) { + return nil, errors.New("Not implemented") +} + +func (eng *Engine) LoadCertificate(ca_dn []string, args map[string]string) (string, error) { + return "", errors.New("Not implemented") +} diff --git a/go/kdf.go b/go/kdf.go deleted file mode 100644 index 0c4464da..00000000 --- a/go/kdf.go +++ /dev/null @@ -1,2 +0,0 @@ -/* +build cgo */ -package gmssl diff --git a/go/pbkdf.go b/go/pbkdf.go new file mode 100644 index 00000000..bd360679 --- /dev/null +++ b/go/pbkdf.go @@ -0,0 +1,21 @@ +/* +build cgo */ +package gmssl + +/* +#include +*/ +import "C" + +import ( + "errors" +) + +func GetKeyDeriveFunctions(aliases bool) []string { + return []string{"PBKDF2v1", "PBKDFv2", "scrypt"} +} + +func DeriveKeyFromPassword(scheme string, args map[string]string, password string, salt []byte) ([]byte, error) { + return nil, errors.New("Not implemented") +} + + diff --git a/go/pkey.go b/go/pkey.go index 7b154cb9..969e3d32 100644 --- a/go/pkey.go +++ b/go/pkey.go @@ -130,5 +130,20 @@ func (pkey *PublicKey) Verify(scheme string, args map[string]string, data, signa } func (pkey *PrivateKey) DeriveKey(scheme string, args map[string]string, publicKey PublicKey) ([]byte, error) { + ctx := C.EVP_PKEY_CTX_new(pkey.pkey, nil) + if ctx == nil { + return nil, errors.New("Failure") + } + if 1 != C.EVP_PKEY_derive_init(ctx) { + } + /* + if 1 != C.EVP_PKEY_derive_set_peer(ctx, PublicKey.pkey) { + } + */ + + outbuf := make([]byte, C.EVP_PKEY_size(pkey.pkey)) + outlen := C.size_t(len(outbuf)) + if 1 != C.EVP_PKEY_derive(ctx, (*C.uchar)(&outbuf[0]), &outlen) { + } return nil, errors.New("Not implemented") }